From 0615c31ceb5a3557c9597c311eb21ce88f858d40 Mon Sep 17 00:00:00 2001 From: theor Date: Fri, 26 Aug 2022 11:27:25 -0400 Subject: [PATCH 1/2] Update cq-viewer.html --- static/cq-viewer.html | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/static/cq-viewer.html b/static/cq-viewer.html index 89754b1..9ed55bc 100644 --- a/static/cq-viewer.html +++ b/static/cq-viewer.html @@ -26,22 +26,43 @@ let viewer = null; let model = [ {}, {} ]; + let cam = { + position:undefined, + target:undefined, + quaternion:undefined, + zoom:undefined, + } + Object.assign(options, cam); + function nc(change) { - // console.debug('viewer info:', JSON.stringify(change, null, 2)); + // position, quaternion, target, zoom + if(change.position) + cam.position = change.position.new; + if(change.quaternion) + cam.quaternion = change.quaternion.new; + if(change.target) + cam.target = change.target.new; + if(change.zoom) + cam.zoom = change.zoom.new; + Object.assign(options, cam); + console.log('viewer info:', JSON.stringify(cam, null, 2), change); } function update_viewer() { - container.innerHTML = ''; - viewer = new Viewer(container, options, nc); - viewer.trimUI(["axes", "axes0", "grid", "ortho", "more", "help"], false); - render(model); + // container.innerHTML = ''; + if(!viewer) + viewer = new Viewer(container, options, nc); + // viewer.trimUI(["axes", "axes0", "grid", "ortho", "more", "help"], false); + render(model); } function render() { + console.log("render", options) viewer.clear(); const [ shapes, states ] = model; const [ group, tree ] = viewer.renderTessellatedShapes(shapes, states, options); viewer.render(group, tree, states, options); + } function get_size_options() { @@ -59,7 +80,7 @@ }); window.addEventListener('message', event => { - // console.debug('received data:', JSON.stringify(event.data.model, null, 2)); + console.debug('received data:', JSON.stringify(event.data.model, null, 2)); if (event.data.options) { options = Object.assign({}, options, event.data.options); } From dbe77711a6ee6d47aff0e777ffbfa153330a62d9 Mon Sep 17 00:00:00 2001 From: theor Date: Fri, 26 Aug 2022 11:28:34 -0400 Subject: [PATCH 2/2] Update cq-viewer.html --- static/cq-viewer.html | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/static/cq-viewer.html b/static/cq-viewer.html index 9ed55bc..197b63d 100644 --- a/static/cq-viewer.html +++ b/static/cq-viewer.html @@ -44,8 +44,7 @@ cam.target = change.target.new; if(change.zoom) cam.zoom = change.zoom.new; - Object.assign(options, cam); - console.log('viewer info:', JSON.stringify(cam, null, 2), change); + Object.assign(options, cam); } function update_viewer() { @@ -57,12 +56,10 @@ } function render() { - console.log("render", options) viewer.clear(); const [ shapes, states ] = model; const [ group, tree ] = viewer.renderTessellatedShapes(shapes, states, options); viewer.render(group, tree, states, options); - } function get_size_options() { @@ -80,7 +77,7 @@ }); window.addEventListener('message', event => { - console.debug('received data:', JSON.stringify(event.data.model, null, 2)); + // console.debug('received data:', JSON.stringify(event.data.model, null, 2)); if (event.data.options) { options = Object.assign({}, options, event.data.options); }