add other axis rotate functions
This commit is contained in:
@ -106,7 +106,7 @@ export const executor = (
|
|||||||
)
|
)
|
||||||
_programMemory._sketch = result.programMemory._sketch
|
_programMemory._sketch = result.programMemory._sketch
|
||||||
_programMemory.root[variableName] = result.currentPath
|
_programMemory.root[variableName] = result.currentPath
|
||||||
} else if ('rx' === fnName) {
|
} else if ('rx' === fnName || 'ry' === fnName || 'rz' === fnName) {
|
||||||
const sketch = declaration.init.arguments[1]
|
const sketch = declaration.init.arguments[1]
|
||||||
if(sketch.type !== 'Identifier') throw new Error('rx must be called with an identifier')
|
if(sketch.type !== 'Identifier') throw new Error('rx must be called with an identifier')
|
||||||
const sketchVal = _programMemory.root[sketch.name]
|
const sketchVal = _programMemory.root[sketch.name]
|
||||||
@ -218,7 +218,7 @@ function executePipeBody(body: PipeExpression['body'], programMemory: ProgramMem
|
|||||||
}
|
}
|
||||||
throw new Error('Invalid argument type')
|
throw new Error('Invalid argument type')
|
||||||
})
|
})
|
||||||
if (fnName === 'rx') {
|
if ('rx' === fnName || 'ry' === fnName || 'rz' === fnName) {
|
||||||
const result = sketchFns[fnName](
|
const result = sketchFns[fnName](
|
||||||
programMemory,
|
programMemory,
|
||||||
[expression.start, expression.end],
|
[expression.start, expression.end],
|
||||||
|
@ -203,7 +203,13 @@ export const sketchFns = {
|
|||||||
currentPath,
|
currentPath,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
rx: (
|
rx: RotateOnAxis([1, 0, 0]),
|
||||||
|
ry: RotateOnAxis([0, 1, 0]),
|
||||||
|
rz: RotateOnAxis([0, 0, 1]),
|
||||||
|
}
|
||||||
|
|
||||||
|
function RotateOnAxis(axisMultiplier: [number, number, number]) {
|
||||||
|
return (
|
||||||
programMemory: ProgramMemory,
|
programMemory: ProgramMemory,
|
||||||
sourceRange: SourceRange,
|
sourceRange: SourceRange,
|
||||||
rotationD: number,
|
rotationD: number,
|
||||||
@ -212,10 +218,10 @@ export const sketchFns = {
|
|||||||
const rotationR = rotationD * (Math.PI / 180)
|
const rotationR = rotationD * (Math.PI / 180)
|
||||||
return {
|
return {
|
||||||
type: 'transform',
|
type: 'transform',
|
||||||
rotation: [rotationR, 0, 0],
|
rotation: axisMultiplier.map((axis) => axis * rotationR) as Rotation3,
|
||||||
transform: [0, 0, 0],
|
transform: [0, 0, 0],
|
||||||
sketch,
|
sketch,
|
||||||
sourceRange,
|
sourceRange,
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user