add circle segment to searches

This commit is contained in:
Kurt Hutten Irev-Dev
2024-08-24 21:59:35 +10:00
parent 1988888699
commit c56c446e15
3 changed files with 21 additions and 9 deletions

View File

@ -918,9 +918,9 @@ export class SceneEntities {
// Prepare to update the THREEjs scene
this.sceneProgramMemory = programMemory
const sketchGroup = sketchGroupFromKclValue(
programMemory.get(
programMemory.get(variableDeclarationName),
variableDeclarationName
), variableDeclarationName)
)
if (err(sketchGroup)) return Promise.reject(sketchGroup)
const sgPaths = sketchGroup.value
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
@ -1322,7 +1322,6 @@ export class SceneEntities {
(group.userData.center[0] - dragTo[0]) ** 2
)
)
console.log('modded', modded)
} else if (
group.name === CIRCLE_SEGMENT &&
subGroup?.name === CIRCLE_CENTER_HANDLE
@ -1335,7 +1334,6 @@ export class SceneEntities {
dragTo,
group.userData.radius
)
console.log('modded', modded)
} else {
modded = changeSketchArguments(
modifiedAst,
@ -1630,7 +1628,7 @@ export class SceneEntities {
const hoveredParent =
sceneInfra.hoveredObject &&
getParentGroup(sceneInfra.hoveredObject, [TANGENTIAL_ARC_TO_SEGMENT])
getParentGroup(sceneInfra.hoveredObject, [CIRCLE_SEGMENT])
let isHandlesVisible = !shouldHideIdle
if (hoveredParent && hoveredParent?.uuid === group?.uuid) {
isHandlesVisible = !shouldHideHover
@ -1899,6 +1897,7 @@ export class SceneEntities {
const parent = getParentGroup(selected, [
STRAIGHT_SEGMENT,
TANGENTIAL_ARC_TO_SEGMENT,
CIRCLE_SEGMENT,
PROFILE_START,
])
if (parent?.userData?.pathToNode) {
@ -1964,6 +1963,7 @@ export class SceneEntities {
const parent = getParentGroup(selected, [
STRAIGHT_SEGMENT,
TANGENTIAL_ARC_TO_SEGMENT,
CIRCLE_SEGMENT,
PROFILE_START,
])
if (parent) {
@ -2161,7 +2161,11 @@ function prepareTruncatedMemoryAndAst(
export function getParentGroup(
object: any,
stopAt: string[] = [STRAIGHT_SEGMENT, TANGENTIAL_ARC_TO_SEGMENT]
stopAt: string[] = [
STRAIGHT_SEGMENT,
TANGENTIAL_ARC_TO_SEGMENT,
CIRCLE_SEGMENT,
]
): Group | null {
if (stopAt.includes(object?.userData?.type)) {
return object

View File

@ -50,6 +50,7 @@ import { applyConstraintAbsDistance } from './Toolbar/SetAbsDistance'
import useStateMachineCommands from 'hooks/useStateMachineCommands'
import { modelingMachineCommandConfig } from 'lib/commandBarConfigs/modelingCommandConfig'
import {
CIRCLE_SEGMENT,
STRAIGHT_SEGMENT,
TANGENTIAL_ARC_TO_SEGMENT,
getParentGroup,
@ -179,6 +180,7 @@ export const ModelingMachineProvider = ({
const parent = getParentGroup(event.data.on, [
STRAIGHT_SEGMENT,
TANGENTIAL_ARC_TO_SEGMENT,
CIRCLE_SEGMENT,
])
const pathToNode = parent?.userData?.pathToNode
const pathToNodeString = JSON.stringify(pathToNode)
@ -196,6 +198,7 @@ export const ModelingMachineProvider = ({
const mouseOnParent = getParentGroup(mouseState.on, [
STRAIGHT_SEGMENT,
TANGENTIAL_ARC_TO_SEGMENT,
CIRCLE_SEGMENT,
])
if (!mouseOnParent || !mouseOnParent?.userData?.pathToNode)
return segmentHoverMap

View File

@ -24,6 +24,7 @@ import {
TANGENTIAL_ARC_TO_SEGMENT,
getParentGroup,
PROFILE_START,
CIRCLE_SEGMENT,
} from 'clientSideScene/sceneEntities'
import { Mesh, Object3D, Object3DEventMap } from 'three'
import { AXIS_GROUP, X_AXIS } from 'clientSideScene/sceneInfra'
@ -150,6 +151,7 @@ export function getEventForSegmentSelection(
const group = getParentGroup(obj, [
STRAIGHT_SEGMENT,
TANGENTIAL_ARC_TO_SEGMENT,
CIRCLE_SEGMENT,
PROFILE_START,
])
const axisGroup = getParentGroup(obj, [AXIS_GROUP])
@ -290,9 +292,12 @@ function updateSceneObjectColors(codeBasedSelections: Selection[]) {
Object.values(sceneEntitiesManager.activeSegments).forEach((segmentGroup) => {
if (
![STRAIGHT_SEGMENT, TANGENTIAL_ARC_TO_SEGMENT, PROFILE_START].includes(
segmentGroup?.name
)
![
STRAIGHT_SEGMENT,
TANGENTIAL_ARC_TO_SEGMENT,
PROFILE_START,
CIRCLE_SEGMENT,
].includes(segmentGroup?.name)
)
return
const nodeMeta = getNodeFromPath<CallExpression>(