implement rotation reset via an unrotate stack

This commit is contained in:
Stewart Allen 2020-06-14 10:00:05 -04:00
commit 8486454d1d
4 changed files with 11 additions and 7 deletions

View file

@ -1897,7 +1897,7 @@
$('mode-sla').onclick = () => { API.mode.set('SLA') }; $('mode-sla').onclick = () => { API.mode.set('SLA') };
$('mode-cam').onclick = () => { API.mode.set('CAM') }; $('mode-cam').onclick = () => { API.mode.set('CAM') };
$('mode-laser').onclick = () => { API.mode.set('LASER') }; $('mode-laser').onclick = () => { API.mode.set('LASER') };
// $('unrotate').onclick = () => { API.widgets.for(w => w.unrotate()) }; $('unrotate').onclick = () => { API.widgets.for(w => w.unrotate()) };
// add app name hover info // add app name hover info
$('app-info').innerText = KIRI.version; $('app-info').innerText = KIRI.version;

View file

@ -112,7 +112,7 @@
if (groups.indexOf(this.group) < 0) { if (groups.indexOf(this.group) < 0) {
groups.push(this.group); groups.push(this.group);
} }
this.roto = new THREE.Matrix4(); this.roto = [];
this.mesh = null; this.mesh = null;
this.points = null; this.points = null;
// todo resolve use of this vs. mesh.bounds // todo resolve use of this vs. mesh.bounds
@ -549,8 +549,8 @@
} else { } else {
m4 = m4.makeRotationFromQuaternion(x); m4 = m4.makeRotationFromQuaternion(x);
} }
this.roto.multiply(m4); this.roto.push(m4);
this.mesh.geometry.applyMatrix4(new THREE.Matrix4().getInverse(m4)); this.mesh.geometry.applyMatrix4(m4);
if (!temp && euler) { if (!temp && euler) {
let rot = this.track.rot; let rot = this.track.rot;
rot.x += (x || 0); rot.x += (x || 0);
@ -560,7 +560,11 @@
}; };
PRO.unrotate = function() { PRO.unrotate = function() {
this.mesh.geometry.applyMatrix4(this.roto); this.roto.reverse().forEach(m => {
this.mesh.geometry.applyMatrix4(new THREE.Matrix4().getInverse(m));
});
this.roto = [];
this.center();
}; };
PRO.mirror = function() { PRO.mirror = function() {

View file

@ -854,7 +854,7 @@ th, tr, td {
padding: 5px; padding: 5px;
margin-right: 5px; margin-right: 5px;
border: 1px solid #ccc; border: 1px solid #ccc;
border-radius: 3px; border-radius: 4px;
background-color: white; background-color: white;
white-space: nowrap; white-space: nowrap;
z-index: 10; z-index: 10;

View file

@ -149,7 +149,7 @@
<label class="grow">Z</label> <label class="grow">Z</label>
<input id="rot_z" class="value center" size="5"/ value="0"> <input id="rot_z" class="value center" size="5"/ value="0">
</div> </div>
<div id="unrotate" class="col j-center noshow">reset</div> <div id="unrotate" class="col j-center">reset</div>
</div> </div>
</div> </div>
<div id="lt-scale" class="lt-menu"> <div id="lt-scale" class="lt-menu">