This commit is contained in:
Kurt Hutten IrevDev
2022-11-28 19:44:08 +11:00
parent b671db1e81
commit 80f513401c
6 changed files with 30 additions and 12 deletions

View File

@ -21,7 +21,6 @@ import { BasePlanes } from './components/BasePlanes'
import { SketchPlane } from './components/SketchPlane' import { SketchPlane } from './components/SketchPlane'
import { Logs } from './components/Logs' import { Logs } from './components/Logs'
const OrrthographicCamera = OrthographicCamera as any const OrrthographicCamera = OrthographicCamera as any
function App() { function App() {
@ -121,7 +120,7 @@ function App() {
} }
}, [code]) }, [code])
const shouldFormat = useMemo(() => { const shouldFormat = useMemo(() => {
if(!ast) return false if (!ast) return false
const recastedCode = recast(ast) const recastedCode = recast(ast)
return recastedCode !== code return recastedCode !== code
}, [code, ast]) }, [code, ast])
@ -130,7 +129,13 @@ function App() {
<Allotment> <Allotment>
<Logs /> <Logs />
<div className="h-full flex flex-col items-start"> <div className="h-full flex flex-col items-start">
<button disabled={!shouldFormat} onClick={formatCode} className={`${!shouldFormat && "text-gray-300"}`}>format</button> <button
disabled={!shouldFormat}
onClick={formatCode}
className={`${!shouldFormat && 'text-gray-300'}`}
>
format
</button>
<div className="bg-red h-full w-full overflow-auto"> <div className="bg-red h-full w-full overflow-auto">
<CodeMirror <CodeMirror
className="h-full" className="h-full"
@ -180,7 +185,13 @@ function App() {
</div> </div>
{guiMode.mode === 'codeError' && ( {guiMode.mode === 'codeError' && (
<div className="absolute inset-0 bg-gray-700/20"> <div className="absolute inset-0 bg-gray-700/20">
<pre>{'last first: \n\n' + JSON.stringify(lastGuiMode, null, 2) + '\n\n' + JSON.stringify(guiMode)}</pre></div> <pre>
{'last first: \n\n' +
JSON.stringify(lastGuiMode, null, 2) +
'\n\n' +
JSON.stringify(guiMode)}
</pre>
</div>
)} )}
</div> </div>
</div> </div>

View File

@ -20,9 +20,7 @@ export const Toolbar = () => {
</button> </button>
)} )}
{guiMode.mode === 'sketch' && guiMode.sketchMode === 'points' && ( {guiMode.mode === 'sketch' && guiMode.sketchMode === 'points' && (
<button> <button>LineTo TODO</button>
LineTo TODO
</button>
)} )}
{guiMode.mode !== 'default' && ( {guiMode.mode !== 'default' && (
<button onClick={() => setGuiMode({ mode: 'default' })}>exit</button> <button onClick={() => setGuiMode({ mode: 'default' })}>exit</button>

View File

@ -56,9 +56,9 @@ export const BasePlanes = () => {
mode: 'sketch', mode: 'sketch',
sketchMode: 'points', sketchMode: 'points',
axis: axisIndex === 0 ? 'yz' : axisIndex === 1 ? 'xy' : 'xz', axis: axisIndex === 0 ? 'yz' : axisIndex === 1 ? 'xy' : 'xz',
id id,
}) })
updateAst(modifiedAst) updateAst(modifiedAst)
} }
if (guiMode.mode !== 'sketch') { if (guiMode.mode !== 'sketch') {

View File

@ -912,7 +912,10 @@ export function addLine(
): { modifiedAst: Program; id: string } { ): { modifiedAst: Program; id: string } {
const _node = { ...node } const _node = { ...node }
const dumbyStartend = { start: 0, end: 0 } const dumbyStartend = { start: 0, end: 0 }
const { index, sketchDeclaration, sketchExpression } = getSketchStatement(_node, id) const { index, sketchDeclaration, sketchExpression } = getSketchStatement(
_node,
id
)
const line: ExpressionStatement = { const line: ExpressionStatement = {
type: 'ExpressionStatement', type: 'ExpressionStatement',
...dumbyStartend, ...dumbyStartend,

View File

@ -1,7 +1,7 @@
import { BoxGeometry, SphereGeometry, BufferGeometry } from 'three' import { BoxGeometry, SphereGeometry, BufferGeometry } from 'three'
import { mergeBufferGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils' import { mergeBufferGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils'
export function baseGeo({from}: {from: [number, number, number]}) { export function baseGeo({ from }: { from: [number, number, number] }) {
const baseSphere = new SphereGeometry(0.25) const baseSphere = new SphereGeometry(0.25)
baseSphere.translate(from[0], from[1], from[2]) baseSphere.translate(from[0], from[1], from[2])
return baseSphere return baseSphere

View File

@ -43,7 +43,13 @@ export const executor = (
bodyType: 'sketch', bodyType: 'sketch',
}) })
if (_sketch.length === 0) { if (_sketch.length === 0) {
const {programMemory: newProgramMemory} = sketchFns.base(fnMemory, '', [0, 0], 0, 0) const { programMemory: newProgramMemory } = sketchFns.base(
fnMemory,
'',
[0, 0],
0,
0
)
_sketch = newProgramMemory._sketch _sketch = newProgramMemory._sketch
} }
_programMemory.root[variableName] = _sketch _programMemory.root[variableName] = _sketch