From e80927f38099de7d4bc8452feebc29542be570c9 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Wed, 25 Nov 2020 20:28:59 -0500 Subject: [PATCH] fix unit scale bug with z top offset. fix restoring rotated manual tabs --- notes.md | 1 + package.json | 2 +- src/kiri/main.js | 2 +- src/license.js | 2 +- src/mode/cam/client.js | 29 ++++++++++++++++++----------- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/notes.md b/notes.md index 758c33aa..40532404 100644 --- a/notes.md +++ b/notes.md @@ -72,6 +72,7 @@ * `B` outside cutting direction in roughing mode inverted * `B` clear voids has double interior pass because wrong offset shadow used * `B` top clearing operations should use linear, not offset, passes +* `F` switch z top offset to an z anchor (top/bottom) + offset * `F` use 3 registration holes to prevent rotation accidents (midline offset one axis) * `F` parameterize dropping close points in prep.js. ensure long segments remain straight * `F` flat and volumetric rendering of paths diff --git a/package.json b/package.json index 2d0a7ff3..5c2e587d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grid-apps", - "version": "2.4.3.D", + "version": "2.4.4.D", "description": "grid.space 3d slice & modeling tools", "author": "Stewart Allen ", "license": "MIT", diff --git a/src/kiri/main.js b/src/kiri/main.js index 44c70538..e8ab0d16 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -1066,7 +1066,7 @@ let hasStock = stock.x && stock.y && stock.z; let alignTopOk = WIDGETS.length > 1 && settings.controller.alignTop; let camz = (MODE === MODES.CAM) && (hasStock || alignTopOk); - let czto = hasStock ? settings.process.camZTopOffset * unitScale() : 0; + let czto = hasStock ? settings.process.camZTopOffset : 0; let ztop = camz ? (topZ + topZD) - czto : 0; forAllWidgets(function(widget) { widget.setTopZ(ztop); diff --git a/src/license.js b/src/license.js index 0d1cae29..3ed8b333 100644 --- a/src/license.js +++ b/src/license.js @@ -3,7 +3,7 @@ let terms = { COPYRIGHT: "Copyright (C) Stewart Allen - All Rights Reserved", LICENSE: "See the license.md file included with the source distribution", - VERSION: "2.4.D3" + VERSION: "2.4.D4" }; if (typeof(module) === 'object') { diff --git a/src/mode/cam/client.js b/src/mode/cam/client.js index 7695c7f7..9b8f166d 100644 --- a/src/mode/cam/client.js +++ b/src/mode/cam/client.js @@ -120,19 +120,20 @@ api.feature.hover = false; }); api.event.on("cam.tabs.clear", func.tclear = () => { - func.sdone(); - // clearAllWidgetSupports(); - // API.conf.save(); + func.tdone(); + API.widgets.all().forEach(widget => { + clearTabs(widget); + }); + API.conf.save(); }); api.event.on("slice.begin", () => { if (isCamMode) { - func.sdone(); - // updateVisiblity(); + func.tdone(); } }); api.event.on("key.esc", () => { if (isCamMode) { - func.sdone() + func.tdone() } }); api.event.on("widget.rotate", rot => { @@ -145,12 +146,16 @@ } else { let tabs = API.widgets.annotate(widget.id).tab || []; tabs.forEach(rec => { - let { id, pos } = rec; + let { id, pos, rot } = rec; let tab = widget.tabs[id]; - let vc = new THREE.Vector3(pos.x, pos.y, pos.z); - let m4 = new THREE.Matrix4(); - m4 = m4.makeRotationFromEuler(new THREE.Euler(x || 0, y || 0, z || 0)); - vc.applyMatrix4(m4); + let m4 = new THREE.Matrix4().makeRotationFromEuler(new THREE.Euler(x || 0, y || 0, z || 0)); + // update position vector + let vc = new THREE.Vector3(pos.x, pos.y, pos.z).applyMatrix4(m4); + // update rotation quaternion + rec.rot = new THREE.Quaternion().multiplyQuaternions( + new THREE.Quaternion(rot._x, rot._y, rot._z, rot._w), + new THREE.Quaternion().setFromRotationMatrix(m4) + ); tab.box.geometry.applyMatrix4(m4); tab.box.position.x = pos.x = vc.x; tab.box.position.y = pos.y = vc.y; @@ -263,6 +268,8 @@ widgets.forEach(widget => { const tabs = API.widgets.annotate(widget.id).tab || []; tabs.forEach(rec => { + rec = Object.clone(rec); + rec.rot = new THREE.Quaternion(rec.rot._x ,rec.rot._y, rec.rot._z, rec.rot._w); addWidgetTab(widget, rec); }); });