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
 | 
			
		||||
        )
 | 
			
		||||
        let _entity_id = entity_id
 | 
			
		||||
        console.log('things', _entity_id, rest)
 | 
			
		||||
        if (!_entity_id) return
 | 
			
		||||
        if (
 | 
			
		||||
          engineCommandManager.defaultPlanes?.xy === _entity_id ||
 | 
			
		||||
@ -1423,7 +1422,6 @@ export class SceneEntities {
 | 
			
		||||
            .sub(sceneInfra.camControls.target)
 | 
			
		||||
 | 
			
		||||
          if (engineCommandManager.defaultPlanes?.xy === _entity_id) {
 | 
			
		||||
            console.log('XY')
 | 
			
		||||
            zAxis = [0, 0, 1]
 | 
			
		||||
            yAxis = [0, 1, 0]
 | 
			
		||||
            if (camVector.z < 0) {
 | 
			
		||||
@ -1431,7 +1429,6 @@ export class SceneEntities {
 | 
			
		||||
              _entity_id = engineCommandManager.defaultPlanes?.negXy || ''
 | 
			
		||||
            }
 | 
			
		||||
          } else if (engineCommandManager.defaultPlanes?.yz === _entity_id) {
 | 
			
		||||
            console.log('YZ')
 | 
			
		||||
            zAxis = [1, 0, 0]
 | 
			
		||||
            yAxis = [0, 0, 1]
 | 
			
		||||
            if (camVector.x < 0) {
 | 
			
		||||
@ -1439,7 +1436,6 @@ export class SceneEntities {
 | 
			
		||||
              _entity_id = engineCommandManager.defaultPlanes?.negYz || ''
 | 
			
		||||
            }
 | 
			
		||||
          } else if (engineCommandManager.defaultPlanes?.xz === _entity_id) {
 | 
			
		||||
            console.log('XZ')
 | 
			
		||||
            zAxis = [0, 1, 0]
 | 
			
		||||
            yAxis = [0, 0, 1]
 | 
			
		||||
            _entity_id = engineCommandManager.defaultPlanes?.negXz || ''
 | 
			
		||||
 | 
			
		||||
@ -506,6 +506,7 @@ export const ModelingMachineProvider = ({
 | 
			
		||||
          })
 | 
			
		||||
        },
 | 
			
		||||
        'animate-to-face': async (_, { data }) => {
 | 
			
		||||
          console.log('animate-to-face', data)
 | 
			
		||||
          if (data.type === 'extrudeFace') {
 | 
			
		||||
            const { modifiedAst, pathToNode: pathToNewSketchNode } =
 | 
			
		||||
              sketchOnExtrudedFace(
 | 
			
		||||
 | 
			
		||||
@ -43,15 +43,27 @@ export function startSketchOnDefault(
 | 
			
		||||
  name = ''
 | 
			
		||||
): { modifiedAst: Program; id: string; pathToNode: PathToNode } {
 | 
			
		||||
  const _node = { ...node }
 | 
			
		||||
  const _name =
 | 
			
		||||
    name || findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.SKETCH)
 | 
			
		||||
  const surfaceName =
 | 
			
		||||
    name || findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.SURFACE)
 | 
			
		||||
 | 
			
		||||
  const startSketchOn = createCallExpressionStdLib('startSketchOn', [
 | 
			
		||||
    createLiteral(axis),
 | 
			
		||||
  ])
 | 
			
		||||
 | 
			
		||||
  const variableDeclaration = createVariableDeclaration(_name, startSketchOn)
 | 
			
		||||
  _node.body = [...node.body, variableDeclaration]
 | 
			
		||||
  const surfaceVariableDeclaration = createVariableDeclaration(
 | 
			
		||||
    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
 | 
			
		||||
 | 
			
		||||
  let pathToNode: PathToNode = [
 | 
			
		||||
@ -64,7 +76,7 @@ export function startSketchOnDefault(
 | 
			
		||||
 | 
			
		||||
  return {
 | 
			
		||||
    modifiedAst: _node,
 | 
			
		||||
    id: _name,
 | 
			
		||||
    id: sketchName,
 | 
			
		||||
    pathToNode,
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -333,10 +345,11 @@ export function sketchOnExtrudedFace(
 | 
			
		||||
  cap: 'none' | 'start' | 'end' = 'none'
 | 
			
		||||
): { modifiedAst: Program; pathToNode: PathToNode } {
 | 
			
		||||
  let _node = { ...node }
 | 
			
		||||
  const newSketchName = findUniqueName(
 | 
			
		||||
  const newSurfaceName = findUniqueName(
 | 
			
		||||
    node,
 | 
			
		||||
    KCL_DEFAULT_CONSTANT_PREFIXES.SKETCH
 | 
			
		||||
    KCL_DEFAULT_CONSTANT_PREFIXES.SURFACE
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
  const { node: oldSketchNode } = getNodeFromPath<VariableDeclarator>(
 | 
			
		||||
    _node,
 | 
			
		||||
    sketchPathToNode,
 | 
			
		||||
@ -372,8 +385,8 @@ export function sketchOnExtrudedFace(
 | 
			
		||||
    _tag = cap.toUpperCase()
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const newSketch = createVariableDeclaration(
 | 
			
		||||
    newSketchName,
 | 
			
		||||
  const newSurface = createVariableDeclaration(
 | 
			
		||||
    newSurfaceName,
 | 
			
		||||
    createCallExpressionStdLib('startSketchOn', [
 | 
			
		||||
      createIdentifier(extrudeName ? extrudeName : oldSketchName),
 | 
			
		||||
      createLiteral(_tag),
 | 
			
		||||
@ -381,22 +394,33 @@ export function sketchOnExtrudedFace(
 | 
			
		||||
    'const'
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
  const expressionIndex = Math.max(
 | 
			
		||||
    sketchPathToNode[1][0] as number,
 | 
			
		||||
    extrudePathToNode[1][0] as number
 | 
			
		||||
    console.log('sketchPathToNode', sketchPathToNode)
 | 
			
		||||
    console.log('extrudePathToNode', extrudePathToNode)
 | 
			
		||||
  _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 newpathToNode: PathToNode = [
 | 
			
		||||
  const sketchVariableDeclaration = createVariableDeclaration(
 | 
			
		||||
    newSketchName,
 | 
			
		||||
    createIdentifier(newSurfaceName)
 | 
			
		||||
  )
 | 
			
		||||
  _node.body = [..._node.body, sketchVariableDeclaration]
 | 
			
		||||
  const sketchIndex = _node.body.length - 1
 | 
			
		||||
 | 
			
		||||
  let newPathToNode: PathToNode = [
 | 
			
		||||
    ['body', ''],
 | 
			
		||||
    [expressionIndex + 1, 'index'],
 | 
			
		||||
    [sketchIndex, 'index'],
 | 
			
		||||
    ['declarations', 'VariableDeclaration'],
 | 
			
		||||
    [0, 'index'],
 | 
			
		||||
    ['0', 'index'],
 | 
			
		||||
    ['init', 'VariableDeclarator'],
 | 
			
		||||
  ]
 | 
			
		||||
 | 
			
		||||
  return {
 | 
			
		||||
    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.
 | 
			
		||||
 * */
 | 
			
		||||
export const KCL_DEFAULT_CONSTANT_PREFIXES = {
 | 
			
		||||
  SURFACE: 'surface',
 | 
			
		||||
  PROFILE: 'profile',
 | 
			
		||||
  SKETCH: 'sketch',
 | 
			
		||||
  EXTRUDE: 'extrude',
 | 
			
		||||
} as const
 | 
			
		||||
 | 
			
		||||
@ -1,12 +1,14 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "kcl-test-server"
 | 
			
		||||
description = "A test server for KCL"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
license = "MIT"
 | 
			
		||||
 | 
			
		||||
[dependencies]
 | 
			
		||||
anyhow = "1.0.86"
 | 
			
		||||
hyper = { version = "0.14.29", features = ["server"] }
 | 
			
		||||
kcl-lib = { path = "../kcl" }
 | 
			
		||||
kcl-lib = { version = "0.1.62", path = "../kcl" }
 | 
			
		||||
pico-args = "0.5.0"
 | 
			
		||||
serde = { version = "1.0.203", features = ["derive"] }
 | 
			
		||||
serde_json = "1.0.117"
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user