Nadro/adhoc/enter sketch mode bug fix (#4529)
* fix: fixing bugs relating to entering sketchmode * fix: reverting * fix: reverting code and running auto fixers
This commit is contained in:
@ -141,12 +141,14 @@ export class SceneEntities {
|
||||
activeSegments: { [key: string]: Group } = {}
|
||||
intersectionPlane: Mesh | null = null
|
||||
axisGroup: Group | null = null
|
||||
draftPointGroups: Group[] = []
|
||||
currentSketchQuaternion: Quaternion | null = null
|
||||
constructor(engineCommandManager: EngineCommandManager) {
|
||||
this.engineCommandManager = engineCommandManager
|
||||
this.scene = sceneInfra?.scene
|
||||
sceneInfra?.camControls.subscribeToCamChange(this.onCamChange)
|
||||
window.addEventListener('resize', this.onWindowResize)
|
||||
this.createIntersectionPlane()
|
||||
}
|
||||
|
||||
onWindowResize = () => {
|
||||
@ -224,7 +226,6 @@ export class SceneEntities {
|
||||
|
||||
createIntersectionPlane() {
|
||||
if (sceneInfra.scene.getObjectByName(RAYCASTABLE_PLANE)) {
|
||||
// this.removeIntersectionPlane()
|
||||
console.warn('createIntersectionPlane called when it already exists')
|
||||
return
|
||||
}
|
||||
@ -316,10 +317,6 @@ export class SceneEntities {
|
||||
sketchPosition && this.axisGroup.position.set(...sketchPosition)
|
||||
this.scene.add(this.axisGroup)
|
||||
}
|
||||
removeIntersectionPlane() {
|
||||
const intersectionPlane = this.scene.getObjectByName(RAYCASTABLE_PLANE)
|
||||
if (intersectionPlane) this.scene.remove(intersectionPlane)
|
||||
}
|
||||
getDraftPoint() {
|
||||
return this.scene.getObjectByName(DRAFT_POINT)
|
||||
}
|
||||
@ -337,6 +334,7 @@ export class SceneEntities {
|
||||
draftPoint.layers.set(SKETCH_LAYER)
|
||||
group.add(draftPoint)
|
||||
}
|
||||
|
||||
removeDraftPoint() {
|
||||
const draftPoint = this.getDraftPoint()
|
||||
if (draftPoint) draftPoint.removeFromParent()
|
||||
@ -352,8 +350,9 @@ export class SceneEntities {
|
||||
// TODO: Consolidate shared logic between this and setupSketch
|
||||
// Which should just fire when the sketch mode is entered,
|
||||
// instead of in these two separate XState states.
|
||||
this.createIntersectionPlane()
|
||||
|
||||
const draftPointGroup = new Group()
|
||||
this.draftPointGroups.push(draftPointGroup)
|
||||
draftPointGroup.name = DRAFT_POINT_GROUP
|
||||
sketchDetails.origin &&
|
||||
draftPointGroup.position.set(...sketchDetails.origin)
|
||||
@ -456,7 +455,6 @@ export class SceneEntities {
|
||||
|
||||
await kclManager.updateAst(modifiedAst, false)
|
||||
|
||||
this.removeIntersectionPlane()
|
||||
this.scene.remove(draftPointGroup)
|
||||
|
||||
// Now perform the caller-specified action
|
||||
@ -487,8 +485,6 @@ export class SceneEntities {
|
||||
sketch: Sketch
|
||||
variableDeclarationName: string
|
||||
}> {
|
||||
this.createIntersectionPlane()
|
||||
|
||||
const prepared = this.prepareTruncatedMemoryAndAst(
|
||||
sketchPathToNode || [],
|
||||
maybeModdedAst
|
||||
@ -1841,7 +1837,10 @@ export class SceneEntities {
|
||||
reject: () => void,
|
||||
{ removeAxis = true }: { removeAxis?: boolean }
|
||||
) {
|
||||
if (this.intersectionPlane) this.scene.remove(this.intersectionPlane)
|
||||
// Remove all draft groups
|
||||
this.draftPointGroups.forEach((draftPointGroup) => {
|
||||
this.scene.remove(draftPointGroup)
|
||||
})
|
||||
if (this.axisGroup && removeAxis) this.scene.remove(this.axisGroup)
|
||||
const sketchSegments = this.scene.children.find(
|
||||
({ userData }) => userData?.type === SKETCH_GROUP_SEGMENTS
|
||||
|
@ -379,6 +379,7 @@ export class SceneInfra {
|
||||
this.currentMouseVector,
|
||||
this.camControls.camera
|
||||
)
|
||||
|
||||
// Get the intersection of the ray with the default planes
|
||||
const planeIntersects = this.planeRaycaster.intersectObjects(
|
||||
this.scene.children,
|
||||
|
@ -748,14 +748,6 @@ export const modelingMachine = setup({
|
||||
})
|
||||
})().catch(reportRejection)
|
||||
},
|
||||
'conditionally equip line tool': ({ event: { type } }) => {
|
||||
if (type === 'xstate.done.actor.animate-to-face') {
|
||||
sceneInfra.modelingSend({
|
||||
type: 'change tool',
|
||||
data: { tool: 'line' },
|
||||
})
|
||||
}
|
||||
},
|
||||
'setup client side sketch segments': ({
|
||||
context: { sketchDetails, selectionRanges },
|
||||
}) => {
|
||||
@ -860,7 +852,6 @@ export const modelingMachine = setup({
|
||||
|
||||
'listen for circle origin': ({ context: { sketchDetails } }) => {
|
||||
if (!sketchDetails) return
|
||||
sceneEntitiesManager.createIntersectionPlane()
|
||||
const quaternion = quaternionFromUpNForward(
|
||||
new Vector3(...sketchDetails.yAxis),
|
||||
new Vector3(...sketchDetails.zAxis)
|
||||
@ -966,7 +957,6 @@ export const modelingMachine = setup({
|
||||
},
|
||||
'setup noPoints onClick listener': ({ context: { sketchDetails } }) => {
|
||||
if (!sketchDetails) return
|
||||
|
||||
sceneEntitiesManager.setupNoPointsListener({
|
||||
sketchDetails,
|
||||
afterClick: () => sceneInfra.modelingSend({ type: 'Add start point' }),
|
||||
@ -2176,11 +2166,7 @@ export const modelingMachine = setup({
|
||||
'enable copilot',
|
||||
],
|
||||
|
||||
entry: [
|
||||
'add axis n grid',
|
||||
'conditionally equip line tool',
|
||||
'clientToEngine cam sync direction',
|
||||
],
|
||||
entry: ['add axis n grid', 'clientToEngine cam sync direction'],
|
||||
},
|
||||
|
||||
'Sketch no face': {
|
||||
|
Reference in New Issue
Block a user