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