set index angle from clicked face

This commit is contained in:
Stewart Allen 2022-10-29 18:43:22 -04:00
commit 7017bb5fb7
3 changed files with 14 additions and 6 deletions

View file

@ -1317,6 +1317,11 @@ CAM.init = function(kiri, api) {
api.event.emit('tool.mesh.face-up'); 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', { createPopOp('index', {
degrees: 'camIndexAxis', degrees: 'camIndexAxis',
absolute: 'camIndexAbs' absolute: 'camIndexAbs'

View file

@ -49,7 +49,8 @@ function onLayFlatSelect() {
} }
function onFaceUpSelect() { function onFaceUpSelect() {
// todo api.event.emit('tool.mesh.face-normal', lastface.normal);
endIt();
} }
function startIt() { function startIt() {
@ -89,13 +90,13 @@ api.event.on('key.esc', endIt);
api.event.on('tool.mesh.face-up', () => { api.event.on('tool.mesh.face-up', () => {
opName = 'face select'; opName = 'face select';
opDone = onLayFlatSelect; onDone = onFaceUpSelect;
startIt(); startIt();
}); });
api.event.on('tool.mesh.lay-flat', () => { api.event.on('tool.mesh.lay-flat', () => {
opName = 'lay flat'; opName = 'lay flat';
opDone = onLayFlatSelect; onDone = onLayFlatSelect;
startIt(); startIt();
}); });
@ -110,14 +111,15 @@ api.event.on('mouse.hover', (ev) => {
let obj = lastobj = int.object; let obj = lastobj = int.object;
let norm = int.face.normal; let norm = int.face.normal;
let widget = obj.widget; let widget = obj.widget;
let opos = widget.track.pos; let track = widget.track;
let opos = track.pos;
obj.add(pmesh); obj.add(pmesh);
pmesh.position.x = point.x - opos.x + norm.x * 0.1; pmesh.position.x = point.x - opos.x + norm.x * 0.1;
pmesh.position.y = -point.z - opos.y + norm.y * 0.1; pmesh.position.y = -point.z - opos.y + norm.y * 0.1;
pmesh.position.z = point.y + norm.z * 0.1; pmesh.position.z = point.y + norm.z * 0.1;
// todo also need to account for z top offset in cam mode // todo also need to account for z top offset in cam mode
if (widget.track.indexed) { if (track.indexed) {
pmesh.position.z += widget.track.indexed / 2; pmesh.position.z += track.indexed / 2 + track.tzoff;
} }
let q = new Quaternion().setFromUnitVectors( let q = new Quaternion().setFromUnitVectors(
new Vector3(0,0,1), new Vector3(0,0,1),

View file

@ -480,6 +480,7 @@ class Widget {
mesh.position.z = -this.track.zcut || 0; mesh.position.z = -this.track.zcut || 0;
this.track.top = mbz; this.track.top = mbz;
} }
this.track.tzoff = mbz - z;
if (this.track.indexed) { if (this.track.indexed) {
mesh.position.z -= this.track.indexed / 2; mesh.position.z -= this.track.indexed / 2;
} }