From 7017bb5fb7c3eb88d8df40c3245af24fc702eb81 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sat, 29 Oct 2022 18:43:22 -0400 Subject: [PATCH] set index angle from clicked face --- src/kiri-mode/cam/client.js | 5 +++++ src/kiri/tools.js | 14 ++++++++------ src/kiri/widget.js | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/kiri-mode/cam/client.js b/src/kiri-mode/cam/client.js index a9303cc6..f2efd0b2 100644 --- a/src/kiri-mode/cam/client.js +++ b/src/kiri-mode/cam/client.js @@ -1317,6 +1317,11 @@ CAM.init = function(kiri, api) { api.event.emit('tool.mesh.face-up'); } + api.event.on('tool.mesh.face-normal', normal => { + poppedRec.degrees = (Math.atan2(normal.y, normal.z) * (180 / Math.PI)).round(2); + poppedRec.absolute = true; + }); + createPopOp('index', { degrees: 'camIndexAxis', absolute: 'camIndexAbs' diff --git a/src/kiri/tools.js b/src/kiri/tools.js index ebf78a66..0951cded 100644 --- a/src/kiri/tools.js +++ b/src/kiri/tools.js @@ -49,7 +49,8 @@ function onLayFlatSelect() { } function onFaceUpSelect() { - // todo + api.event.emit('tool.mesh.face-normal', lastface.normal); + endIt(); } function startIt() { @@ -89,13 +90,13 @@ api.event.on('key.esc', endIt); api.event.on('tool.mesh.face-up', () => { opName = 'face select'; - opDone = onLayFlatSelect; + onDone = onFaceUpSelect; startIt(); }); api.event.on('tool.mesh.lay-flat', () => { opName = 'lay flat'; - opDone = onLayFlatSelect; + onDone = onLayFlatSelect; startIt(); }); @@ -110,14 +111,15 @@ api.event.on('mouse.hover', (ev) => { let obj = lastobj = int.object; let norm = int.face.normal; let widget = obj.widget; - let opos = widget.track.pos; + let track = widget.track; + let opos = track.pos; obj.add(pmesh); pmesh.position.x = point.x - opos.x + norm.x * 0.1; pmesh.position.y = -point.z - opos.y + norm.y * 0.1; pmesh.position.z = point.y + norm.z * 0.1; // todo also need to account for z top offset in cam mode - if (widget.track.indexed) { - pmesh.position.z += widget.track.indexed / 2; + if (track.indexed) { + pmesh.position.z += track.indexed / 2 + track.tzoff; } let q = new Quaternion().setFromUnitVectors( new Vector3(0,0,1), diff --git a/src/kiri/widget.js b/src/kiri/widget.js index dd044228..792cbd37 100644 --- a/src/kiri/widget.js +++ b/src/kiri/widget.js @@ -480,6 +480,7 @@ class Widget { mesh.position.z = -this.track.zcut || 0; this.track.top = mbz; } + this.track.tzoff = mbz - z; if (this.track.indexed) { mesh.position.z -= this.track.indexed / 2; }