fix sketch on face (#2745)

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-06-21 21:49:12 -07:00
committed by GitHub
parent 0f3f923019
commit 226ed37c5f
4 changed files with 14 additions and 6 deletions

View File

@ -1394,7 +1394,6 @@ export class SceneEntities {
streamDimensions streamDimensions
) )
let _entity_id = entity_id let _entity_id = entity_id
console.log('things', _entity_id, rest)
if (!_entity_id) return if (!_entity_id) return
if ( if (
engineCommandManager.defaultPlanes?.xy === _entity_id || engineCommandManager.defaultPlanes?.xy === _entity_id ||
@ -1423,7 +1422,6 @@ export class SceneEntities {
.sub(sceneInfra.camControls.target) .sub(sceneInfra.camControls.target)
if (engineCommandManager.defaultPlanes?.xy === _entity_id) { if (engineCommandManager.defaultPlanes?.xy === _entity_id) {
console.log('XY')
zAxis = [0, 0, 1] zAxis = [0, 0, 1]
yAxis = [0, 1, 0] yAxis = [0, 1, 0]
if (camVector.z < 0) { if (camVector.z < 0) {
@ -1431,7 +1429,6 @@ export class SceneEntities {
_entity_id = engineCommandManager.defaultPlanes?.negXy || '' _entity_id = engineCommandManager.defaultPlanes?.negXy || ''
} }
} else if (engineCommandManager.defaultPlanes?.yz === _entity_id) { } else if (engineCommandManager.defaultPlanes?.yz === _entity_id) {
console.log('YZ')
zAxis = [1, 0, 0] zAxis = [1, 0, 0]
yAxis = [0, 0, 1] yAxis = [0, 0, 1]
if (camVector.x < 0) { if (camVector.x < 0) {
@ -1439,7 +1436,6 @@ export class SceneEntities {
_entity_id = engineCommandManager.defaultPlanes?.negYz || '' _entity_id = engineCommandManager.defaultPlanes?.negYz || ''
} }
} else if (engineCommandManager.defaultPlanes?.xz === _entity_id) { } else if (engineCommandManager.defaultPlanes?.xz === _entity_id) {
console.log('XZ')
zAxis = [0, 1, 0] zAxis = [0, 1, 0]
yAxis = [0, 0, 1] yAxis = [0, 0, 1]
_entity_id = engineCommandManager.defaultPlanes?.negXz || '' _entity_id = engineCommandManager.defaultPlanes?.negXz || ''
@ -1493,6 +1489,7 @@ export class SceneEntities {
kclManager.ast, kclManager.ast,
artifact.range artifact.range
) )
const extrudePathToNode = extrusions?.range const extrudePathToNode = extrusions?.range
? getNodePathFromSourceRange(kclManager.ast, extrusions.range) ? getNodePathFromSourceRange(kclManager.ast, extrusions.range)
: [] : []

View File

@ -507,6 +507,7 @@ export const ModelingMachineProvider = ({
}, },
'animate-to-face': async (_, { data }) => { 'animate-to-face': async (_, { data }) => {
if (data.type === 'extrudeFace') { if (data.type === 'extrudeFace') {
console.log('data', data)
const { modifiedAst, pathToNode: pathToNewSketchNode } = const { modifiedAst, pathToNode: pathToNewSketchNode } =
sketchOnExtrudedFace( sketchOnExtrudedFace(
kclManager.ast, kclManager.ast,

View File

@ -1466,6 +1466,9 @@ export class EngineCommandManager extends EventTarget {
if (command && command.type === 'pending') { if (command && command.type === 'pending') {
const resolve = command.resolve const resolve = command.resolve
const oldArtifact = this.artifactMap[id] as ArtifactMapCommand & {
extrusions?: string[]
}
const artifact = { const artifact = {
type: 'result', type: 'result',
range: command.range, range: command.range,
@ -1474,7 +1477,10 @@ export class EngineCommandManager extends EventTarget {
parentId: command.parentId ? command.parentId : undefined, parentId: command.parentId ? command.parentId : undefined,
data: modelingResponse, data: modelingResponse,
raw, raw,
} as const } as ArtifactMapCommand & { extrusions?: string[] }
if (oldArtifact?.extrusions) {
artifact.extrusions = oldArtifact.extrusions
}
this.artifactMap[id] = artifact this.artifactMap[id] = artifact
if ( if (
(command.commandType === 'entity_linear_pattern' && (command.commandType === 'entity_linear_pattern' &&
@ -1903,6 +1909,8 @@ export class EngineCommandManager extends EventTarget {
} else { } else {
typedTarget.extrusions = [id] typedTarget.extrusions = [id]
} }
// Update in the map.
this.artifactMap[command.target] = typedTarget
} }
} }
return promise return promise

View File

@ -1,12 +1,14 @@
[package] [package]
name = "kcl-test-server" name = "kcl-test-server"
description = "A test server for KCL"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
license = "MIT"
[dependencies] [dependencies]
anyhow = "1.0.86" anyhow = "1.0.86"
hyper = { version = "0.14.29", features = ["server"] } hyper = { version = "0.14.29", features = ["server"] }
kcl-lib = { path = "../kcl" } kcl-lib = { version = "0.1.62", path = "../kcl" }
pico-args = "0.5.0" pico-args = "0.5.0"
serde = { version = "1.0.203", features = ["derive"] } serde = { version = "1.0.203", features = ["derive"] }
serde_json = "1.0.117" serde_json = "1.0.117"