diff --git a/online/serve/app/test/cases/zometool-model/index.html b/online/serve/app/test/cases/zometool-model/index.html index 45566993e..554c76617 100644 --- a/online/serve/app/test/cases/zometool-model/index.html +++ b/online/serve/app/test/cases/zometool-model/index.html @@ -27,7 +27,9 @@

Zometool Model Demo

- + + + diff --git a/online/src/wc/zometool/index.jsx b/online/src/wc/zometool/index.jsx index 602ebc957..629213238 100644 --- a/online/src/wc/zometool/index.jsx +++ b/online/src/wc/zometool/index.jsx @@ -29,13 +29,15 @@ const StepControls = props => const atStart = () => index() === 1; // NOTE: scene 0 is the default scene, which we ignore const atEnd = () => index() === maxIndex(); - createEffect( () => setMaxIndex( scenes?.length - 1 ) ); + createEffect( () => { + setMaxIndex( scenes?.length - 1 ) + }); createEffect( () => { if ( props.show ) { requestScene( '#' + index(), { camera: false } ); } else { - requestScene( '#' + maxIndex(), { camera: true } ); + requestScene( '#' + maxIndex(), { camera: true, bom: true } ); } } ); @@ -93,33 +95,35 @@ const StepControls = props => const ZometoolInstructions = props => { + const { scenes } = useViewer(); + const [ hasScenes, setHasScenes ] = createSignal( false ); const [ steps, setSteps ] = createSignal( false ); const toggleSteps = () => setSteps( v => !v ); + createEffect( () => { + setHasScenes( scenes?.length > 1 ) + }); + return ( - - - -
- - - Show Build Steps - - - - - - - - - - -
-
-
-
+
+ +
}> + + Show Build Steps + + + + + + + + + + + + ); } @@ -128,8 +132,14 @@ const renderComponent = ( url, container, dispatch ) => const bindComponent = () => { return ( - - + + + + + + + + ); } diff --git a/online/src/worker/vzome-worker-static.js b/online/src/worker/vzome-worker-static.js index 97b57be5a..974025365 100644 --- a/online/src/worker/vzome-worker-static.js +++ b/online/src/worker/vzome-worker-static.js @@ -55,6 +55,13 @@ const filterScene = ( report, load ) => event => event.payload.scene = { shapes, embedding, polygons }; if ( load.camera ) event.payload.scene.camera = camera; if ( load.lighting ) event.payload.scene.lighting = lighting; + + if ( load.bom ) { + partsPromise .then( ({ colors }) => { + const bom = assemblePartsList( shapes, colors ); + report( { type: 'BOM_CHANGED', payload: bom } ); + }); + } } report( event ); } @@ -119,14 +126,7 @@ const partsPromise = fetch( parts_catalog_url ) .then( response => response.text const clientEvents = report => { - const sceneChanged = ( scene, edit='--START--' ) => - { - report( { type: 'SCENE_RENDERED', payload: { scene, edit } } ); - partsPromise .then( ({ colors }) => { - const bom = assemblePartsList( scene.shapes, colors ); - report( { type: 'BOM_CHANGED', payload: bom } ); - }); - } + const sceneChanged = ( scene, edit='--START--' ) => report( { type: 'SCENE_RENDERED', payload: { scene, edit } } ); const shapeDefined = shape => report( { type: 'SHAPE_DEFINED', payload: shape } ); @@ -327,7 +327,7 @@ const fileImporter = ( report, payload ) => } ) } -const defaultLoad = { camera: true, lighting: true, design: true, }; +const defaultLoad = { camera: true, lighting: true, design: true, bom: false, }; const urlLoader = async ( report, payload ) => {