cleanup rotation / scale and stub in rotation reset

This commit is contained in:
Stewart Allen 2020-06-13 22:52:46 -04:00
commit a9b04ad26f
4 changed files with 30 additions and 11 deletions

View file

@ -1897,6 +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()) };
// add app name hover info // add app name hover info
$('app-info').innerText = KIRI.version; $('app-info').innerText = KIRI.version;

View file

@ -112,6 +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.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
@ -548,7 +549,8 @@
} else { } else {
m4 = m4.makeRotationFromQuaternion(x); m4 = m4.makeRotationFromQuaternion(x);
} }
this.mesh.geometry.applyMatrix4(m4); this.roto.multiply(m4);
this.mesh.geometry.applyMatrix4(new THREE.Matrix4().getInverse(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);
@ -557,6 +559,10 @@
} }
}; };
PRO.unrotate = function() {
this.mesh.geometry.applyMatrix4(this.roto);
};
PRO.mirror = function() { PRO.mirror = function() {
this.group.forEach(w => { this.group.forEach(w => {
w._mirror(); w._mirror();

View file

@ -424,6 +424,14 @@ th, tr, td {
.txt-sel button { .txt-sel button {
background-color: #ccc; background-color: #ccc;
} }
#pop-rotate .value, #pop-scale .value {
width: 90%;
}
#lock_x, #lock_y, #lock_z {
position: absolute;
left: 2px;
top: 7px;
}
#end { #end {
left: 0; left: 0;

View file

@ -149,6 +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> </div>
</div> </div>
<div id="lt-scale" class="lt-menu"> <div id="lt-scale" class="lt-menu">
@ -156,21 +157,24 @@
<label>scale</label> <label>scale</label>
<div id="pop-scale" class="pop-lcol row fillh russo"> <div id="pop-scale" class="pop-lcol row fillh russo">
<div> <div>
<div><label>X</label><input id="lock_x" type="checkbox" checked/></div> <input id="lock_x" type="checkbox" checked/>
<div><input id="size_x" size="8" class="value"/></div> <div><label>X</label></div>
<div><input id="scale_x" size="8" class="value" value="1"/></div> <div><input id="size_x" xsize="8" class="value"/></div>
<div><input id="scale_x" xsize="8" class="value" value="1"/></div>
</div> </div>
<div> <div>
<div><label>Y</label><input id="lock_y" type="checkbox" checked/></div> <input id="lock_y" type="checkbox" checked/>
<div><input id="size_y" size="8" class="value"/></div> <div><label>Y</label></div>
<div><input id="scale_y" size="8" class="value" value="1"/></div> <div><input id="size_y" xsize="8" class="value"/></div>
<div><input id="scale_y" xsize="8" class="value" value="1"/></div>
</div> </div>
<div> <div>
<div><label>Z</label><input id="lock_z" type="checkbox" checked/></div> <input id="lock_z" type="checkbox" checked/>
<div><input id="size_z" size="8" class="value"/></div> <div><label>Z</label></div>
<div><input id="scale_z" size="8" class="value" value="1"/></div> <div><input id="size_z" xsize="8" class="value"/></div>
<div><input id="scale_z" xsize="8" class="value" value="1"/></div>
</div> </div>
<div> <div class="col j-center">
<div><label>axis</label></div> <div><label>axis</label></div>
<div><label>size</label></div> <div><label>size</label></div>
<div><label>scale</label></div> <div><label>scale</label></div>