Fix rectangle tool flakiness (#3190)
* Refactor line tool and rectangle tool to share same "no points" code path * Remove console.log * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Re-run CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -1238,7 +1238,20 @@ export const modelingMachine = createMachine(
|
||||
},
|
||||
'listen for rectangle origin': ({ sketchDetails }) => {
|
||||
if (!sketchDetails) return
|
||||
sceneEntitiesManager.setupRectangleOriginListener()
|
||||
sceneEntitiesManager.setupNoPointsListener({
|
||||
sketchDetails,
|
||||
afterClick: (args) => {
|
||||
const twoD = args.intersectionPoint?.twoD
|
||||
if (twoD) {
|
||||
sceneInfra.modelingSend({
|
||||
type: 'Add rectangle origin',
|
||||
data: [twoD.x, twoD.y],
|
||||
})
|
||||
} else {
|
||||
console.error('No intersection point found')
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
'set up draft rectangle': ({ sketchDetails }, { data }) => {
|
||||
if (!sketchDetails || !data) return
|
||||
@ -1268,39 +1281,10 @@ export const modelingMachine = createMachine(
|
||||
},
|
||||
'setup noPoints onClick listener': ({ sketchDetails }) => {
|
||||
if (!sketchDetails) return
|
||||
sceneEntitiesManager.createIntersectionPlane()
|
||||
const quaternion = quaternionFromUpNForward(
|
||||
new Vector3(...sketchDetails.yAxis),
|
||||
new Vector3(...sketchDetails.zAxis)
|
||||
)
|
||||
sceneEntitiesManager.intersectionPlane &&
|
||||
sceneEntitiesManager.intersectionPlane.setRotationFromQuaternion(
|
||||
quaternion
|
||||
)
|
||||
sceneEntitiesManager.intersectionPlane &&
|
||||
sceneEntitiesManager.intersectionPlane.position.copy(
|
||||
new Vector3(...(sketchDetails?.origin || [0, 0, 0]))
|
||||
)
|
||||
sceneInfra.setCallbacks({
|
||||
onClick: async (args) => {
|
||||
if (!args) return
|
||||
if (args.mouseEvent.which !== 1) return
|
||||
const { intersectionPoint } = args
|
||||
if (!intersectionPoint?.twoD || !sketchDetails?.sketchPathToNode)
|
||||
return
|
||||
const addStartProfileAtRes = addStartProfileAt(
|
||||
kclManager.ast,
|
||||
sketchDetails.sketchPathToNode,
|
||||
[intersectionPoint.twoD.x, intersectionPoint.twoD.y]
|
||||
)
|
||||
|
||||
if (trap(addStartProfileAtRes)) return
|
||||
const { modifiedAst } = addStartProfileAtRes
|
||||
|
||||
await kclManager.updateAst(modifiedAst, false)
|
||||
sceneEntitiesManager.removeIntersectionPlane()
|
||||
sceneInfra.modelingSend('Add start point')
|
||||
},
|
||||
sceneEntitiesManager.setupNoPointsListener({
|
||||
sketchDetails,
|
||||
afterClick: () => sceneInfra.modelingSend('Add start point'),
|
||||
})
|
||||
},
|
||||
'add axis n grid': ({ sketchDetails }) => {
|
||||
|
Reference in New Issue
Block a user