diff --git a/src/kiri/mode/cam/anim-3d-be.js b/src/kiri/mode/cam/anim-3d-be.js index 1c6fa9f9..1288c65d 100644 --- a/src/kiri/mode/cam/anim-3d-be.js +++ b/src/kiri/mode/cam/anim-3d-be.js @@ -39,7 +39,7 @@ export function init(worker) { const print = worker.current.print; const density = parseInt(settings.controller.animesh) * 1000; const isIndexed = process.camStockIndexed; -console.log({ controller }); + pathIndex = 0; path = print.output.flat(); tools = settings.tools; diff --git a/src/kiri/mode/cam/anim-3d-fe.js b/src/kiri/mode/cam/anim-3d-fe.js index 69ee3b7b..2329bc59 100644 --- a/src/kiri/mode/cam/anim-3d-fe.js +++ b/src/kiri/mode/cam/anim-3d-fe.js @@ -20,6 +20,7 @@ let meshes = {}, origin, color = 0, dark = false, + manifold = false, A2R = Math.PI / 180; export function animate_clear2(api) { @@ -37,6 +38,7 @@ export function animate2(api, delay) { let alert = api.alerts.show("building animation"); let settings = api.conf.get(); dark = settings.controller.dark; + manifold = settings.controller.manifold; client.animate_setup2(settings, data => { handleUpdate(data); if (data) { @@ -52,7 +54,8 @@ export function animate2(api, delay) { speed: anim.speed, trans: anim.trans, model: anim.model, - shade: anim.shade + shade: anim.shade, + path: anim.path }); Object.assign(label, { progress: anim.progress, @@ -63,6 +66,14 @@ export function animate2(api, delay) { a: anim.vala }); + if (manifold) { + anim.trans.classList.remove('hide'); + // anim.shade.classList.remove('hide'); + } else { + anim.trans.classList.add('hide'); + // anim.shade.classList.add('hide'); + } + updateSpeed(0); setTimeout(step, delay || 0); toggleTrans(undefined, false); @@ -76,6 +87,7 @@ export function animate2(api, delay) { button.trans.onclick = toggleTrans; button.model.onclick = toggleModel; button.shade.onclick = toggleStock; + button.path.onclick = togglePath; button.play.style.display = ''; button.pause.style.display = 'none'; @@ -119,7 +131,8 @@ function initPathMesh() { pos = new Float32Array(max * 6), lines = new THREE.LineSegments(geo, mat), vec = new THREE.Vector3(0,0,0), - ang = new THREE.Vector3(1,0,0); + ang = new THREE.Vector3(1,0,0), + show = api.local.get('cam.anim.path') ?? true; geo.setAttribute('position', new THREE.BufferAttribute(pos, 3)); let track = lineTracker = { xro(p) { @@ -159,9 +172,15 @@ function initPathMesh() { lines.setRotationFromEuler(rot); }, visible(bool) { - if (bool !== lines.visible) { + if (show && bool !== lines.visible) { lines.visible = bool; + } else if (!show) { + lines.visible = false; } + }, + show(bool) { + show = bool; + lines.visible = bool; } } space.world.add(lines); @@ -207,8 +226,15 @@ function toggleModel(ev, bool) { } function toggleStock(ev, bool, set) { - set !== false && api.local.toggle('cam.anim.stock', bool); - return api.event.emit('cam.stock.toggle', bool ?? undefined); + bool = api.local.toggle('cam.anim.stock', bool); + for (let [ id, mesh ] of Object.entries(meshes)) { + if (id >= 0) mesh.visible = bool; + } +} + +function togglePath(ev, bool, set) { + bool = api.local.toggle('cam.anim.path', bool); + lineTracker?.show(bool); } function toggleTrans(ev, bool) { diff --git a/src/kiri/mode/cam/init-menu.js b/src/kiri/mode/cam/init-menu.js index ce654c00..c1ae578b 100644 --- a/src/kiri/mode/cam/init-menu.js +++ b/src/kiri/mode/cam/init-menu.js @@ -58,6 +58,7 @@ export function menu() { anim.trans = newButton(null,null,{icon:'',title:"transparency",class:"padleft"}), anim.model = newButton(null,null,{icon:'',title:"show model"}), anim.shade = newButton(null,null,{icon:'',title:"stock box"}), + anim.path = newButton(null,null,{icon:'',title:"path"}), ]) },