updates
Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> more Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -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 || ''
|
||||||
|
|||||||
@ -506,6 +506,7 @@ export const ModelingMachineProvider = ({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
'animate-to-face': async (_, { data }) => {
|
'animate-to-face': async (_, { data }) => {
|
||||||
|
console.log('animate-to-face', data)
|
||||||
if (data.type === 'extrudeFace') {
|
if (data.type === 'extrudeFace') {
|
||||||
const { modifiedAst, pathToNode: pathToNewSketchNode } =
|
const { modifiedAst, pathToNode: pathToNewSketchNode } =
|
||||||
sketchOnExtrudedFace(
|
sketchOnExtrudedFace(
|
||||||
|
|||||||
@ -43,15 +43,27 @@ export function startSketchOnDefault(
|
|||||||
name = ''
|
name = ''
|
||||||
): { modifiedAst: Program; id: string; pathToNode: PathToNode } {
|
): { modifiedAst: Program; id: string; pathToNode: PathToNode } {
|
||||||
const _node = { ...node }
|
const _node = { ...node }
|
||||||
const _name =
|
const surfaceName =
|
||||||
name || findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.SKETCH)
|
name || findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.SURFACE)
|
||||||
|
|
||||||
const startSketchOn = createCallExpressionStdLib('startSketchOn', [
|
const startSketchOn = createCallExpressionStdLib('startSketchOn', [
|
||||||
createLiteral(axis),
|
createLiteral(axis),
|
||||||
])
|
])
|
||||||
|
|
||||||
const variableDeclaration = createVariableDeclaration(_name, startSketchOn)
|
const surfaceVariableDeclaration = createVariableDeclaration(
|
||||||
_node.body = [...node.body, variableDeclaration]
|
surfaceName,
|
||||||
|
startSketchOn
|
||||||
|
)
|
||||||
|
_node.body = [..._node.body, surfaceVariableDeclaration]
|
||||||
|
|
||||||
|
// Create the variable for the sketch.
|
||||||
|
const sketchName =
|
||||||
|
name || findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.SKETCH)
|
||||||
|
const sketchVariableDeclaration = createVariableDeclaration(
|
||||||
|
sketchName,
|
||||||
|
createIdentifier(surfaceName)
|
||||||
|
)
|
||||||
|
_node.body = [..._node.body, sketchVariableDeclaration]
|
||||||
const sketchIndex = _node.body.length - 1
|
const sketchIndex = _node.body.length - 1
|
||||||
|
|
||||||
let pathToNode: PathToNode = [
|
let pathToNode: PathToNode = [
|
||||||
@ -64,7 +76,7 @@ export function startSketchOnDefault(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
modifiedAst: _node,
|
modifiedAst: _node,
|
||||||
id: _name,
|
id: sketchName,
|
||||||
pathToNode,
|
pathToNode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,10 +345,11 @@ export function sketchOnExtrudedFace(
|
|||||||
cap: 'none' | 'start' | 'end' = 'none'
|
cap: 'none' | 'start' | 'end' = 'none'
|
||||||
): { modifiedAst: Program; pathToNode: PathToNode } {
|
): { modifiedAst: Program; pathToNode: PathToNode } {
|
||||||
let _node = { ...node }
|
let _node = { ...node }
|
||||||
const newSketchName = findUniqueName(
|
const newSurfaceName = findUniqueName(
|
||||||
node,
|
node,
|
||||||
KCL_DEFAULT_CONSTANT_PREFIXES.SKETCH
|
KCL_DEFAULT_CONSTANT_PREFIXES.SURFACE
|
||||||
)
|
)
|
||||||
|
|
||||||
const { node: oldSketchNode } = getNodeFromPath<VariableDeclarator>(
|
const { node: oldSketchNode } = getNodeFromPath<VariableDeclarator>(
|
||||||
_node,
|
_node,
|
||||||
sketchPathToNode,
|
sketchPathToNode,
|
||||||
@ -372,8 +385,8 @@ export function sketchOnExtrudedFace(
|
|||||||
_tag = cap.toUpperCase()
|
_tag = cap.toUpperCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
const newSketch = createVariableDeclaration(
|
const newSurface = createVariableDeclaration(
|
||||||
newSketchName,
|
newSurfaceName,
|
||||||
createCallExpressionStdLib('startSketchOn', [
|
createCallExpressionStdLib('startSketchOn', [
|
||||||
createIdentifier(extrudeName ? extrudeName : oldSketchName),
|
createIdentifier(extrudeName ? extrudeName : oldSketchName),
|
||||||
createLiteral(_tag),
|
createLiteral(_tag),
|
||||||
@ -381,22 +394,33 @@ export function sketchOnExtrudedFace(
|
|||||||
'const'
|
'const'
|
||||||
)
|
)
|
||||||
|
|
||||||
const expressionIndex = Math.max(
|
console.log('sketchPathToNode', sketchPathToNode)
|
||||||
sketchPathToNode[1][0] as number,
|
console.log('extrudePathToNode', extrudePathToNode)
|
||||||
extrudePathToNode[1][0] as number
|
_node.body = [..._node.body, newSurface]
|
||||||
|
|
||||||
|
// Create the variable for the sketch.
|
||||||
|
const newSketchName = findUniqueName(
|
||||||
|
node,
|
||||||
|
KCL_DEFAULT_CONSTANT_PREFIXES.SKETCH
|
||||||
)
|
)
|
||||||
_node.body.splice(expressionIndex + 1, 0, newSketch)
|
const sketchVariableDeclaration = createVariableDeclaration(
|
||||||
const newpathToNode: PathToNode = [
|
newSketchName,
|
||||||
|
createIdentifier(newSurfaceName)
|
||||||
|
)
|
||||||
|
_node.body = [..._node.body, sketchVariableDeclaration]
|
||||||
|
const sketchIndex = _node.body.length - 1
|
||||||
|
|
||||||
|
let newPathToNode: PathToNode = [
|
||||||
['body', ''],
|
['body', ''],
|
||||||
[expressionIndex + 1, 'index'],
|
[sketchIndex, 'index'],
|
||||||
['declarations', 'VariableDeclaration'],
|
['declarations', 'VariableDeclaration'],
|
||||||
[0, 'index'],
|
['0', 'index'],
|
||||||
['init', 'VariableDeclarator'],
|
['init', 'VariableDeclarator'],
|
||||||
]
|
]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
modifiedAst: _node,
|
modifiedAst: _node,
|
||||||
pathToNode: newpathToNode,
|
pathToNode: newPathToNode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,8 @@ export const ONBOARDING_PROJECT_NAME = 'Tutorial Project $nn'
|
|||||||
* These are used to generate unique names for new objects.
|
* These are used to generate unique names for new objects.
|
||||||
* */
|
* */
|
||||||
export const KCL_DEFAULT_CONSTANT_PREFIXES = {
|
export const KCL_DEFAULT_CONSTANT_PREFIXES = {
|
||||||
|
SURFACE: 'surface',
|
||||||
|
PROFILE: 'profile',
|
||||||
SKETCH: 'sketch',
|
SKETCH: 'sketch',
|
||||||
EXTRUDE: 'extrude',
|
EXTRUDE: 'extrude',
|
||||||
} as const
|
} as const
|
||||||
|
|||||||
@ -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"
|
||||||
|
|||||||
Reference in New Issue
Block a user