cost part001 = startSketchOn(..) should be undone . . . (#1404)

* undo sketch if no lines have been created

* fix sketch axis bug

* fix wrong event origin bug

* race condition on animation ending

* remove logs

* codespell
This commit is contained in:
Kurt Hutten
2024-02-14 05:35:05 +11:00
committed by GitHub
parent cfbc77b62f
commit f30601bd2c
6 changed files with 94 additions and 79 deletions

View File

@ -36,6 +36,7 @@ import { modelingMachineConfig } from 'lib/commandBarConfigs/modelingCommandConf
import { setupSingleton } from 'clientSideScene/setup'
import { getSketchQuaternion } from 'clientSideScene/clientSideScene'
import { startSketchOnDefault } from 'lang/modifyAst'
import { Program } from 'lang/wasm'
type MachineContext<T extends AnyStateMachine> = {
state: StateFrom<T>
@ -189,6 +190,17 @@ export const ModelingMachineProvider = ({
},
},
services: {
'AST-undo-startSketchOn': async ({ sketchPathToNode }) => {
if (!sketchPathToNode) return
const newAst: Program = JSON.parse(JSON.stringify(kclManager.ast))
const varDecIndex = sketchPathToNode[1][0]
// remove body item at varDecIndex
newAst.body = newAst.body.filter((_, i) => i !== varDecIndex)
await kclManager.executeAstMock(newAst, { updates: 'code' })
setupSingleton.setCallbacks({
onClick: () => {},
})
},
'animate-to-face': async (_, { data: { plane, normal } }) => {
const { modifiedAst, pathToNode } = startSketchOnDefault(
kclManager.ast,