Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lf94 committed Jan 14, 2025
1 parent cfe472c commit 3a71837
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/clientSideScene/sceneEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ export class SceneEntities {
return astSnapshot
}

const updateCircle3Point = async () => {
const updateCircle3Point = async (opts?: { execute?: true }) => {
const points_ = Array.from(points.values())
const circleParams = calculate_circle_from_3_points(
points_[0].x,
Expand All @@ -1457,16 +1457,25 @@ export class SceneEntities {
points_[2].x,
points_[2].y
)

if (Number.isNaN(circleParams.radius)) return

await createCircle3PointGraphic(
points_,
new Vector2(circleParams.center_x, circleParams.center_y),
circleParams.radius
)
const astWithNewCode = insertCircle3PointKclIntoAstSnapshot(points_)
await codeManager.updateEditorWithAstAndWriteToFile(astWithNewCode)
codeManager.updateCodeStateEditor(recast(astWithNewCode))

if (opts?.execute) {
await kclManager.executeAstMock(astWithNewCode)
}
}

const cleanupFn = () => {
// Fire off writing to file.
// void codeManager.writeToFile()
this.scene.remove(groupOfDrafts)
}

Expand Down Expand Up @@ -1532,6 +1541,7 @@ export class SceneEntities {
},
async onDragEnd(_args) {
target = undefined
await updateCircle3Point({ execute: true })
},
async onClick(args) {
if (points.size >= 3) return
Expand All @@ -1549,7 +1559,7 @@ export class SceneEntities {

if (points.size <= 2) return

await updateCircle3Point()
await updateCircle3Point({ execute: true })
},
})

Expand Down

0 comments on commit 3a71837

Please sign in to comment.