improve belt rotation (still buggy)
This commit is contained in:
parent
63550dd325
commit
43acc4e652
3 changed files with 20 additions and 8 deletions
1
notes.md
1
notes.md
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
## `C` cosmetic, `F` functional, `P` performance, `B` bug fix
|
||||
|
||||
* `B` normals possibly inverted on faces in 2D to 3D conversion
|
||||
* `F` right click / context menu (object deletion, etc)
|
||||
* `F` detect and report slow framerates
|
||||
* `P` duplicate objects should share same slice data unless rotated or scaled
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@
|
|||
|
||||
rotate(set) {
|
||||
this.view.rotation.x = -set.angle * (Math.PI/180);
|
||||
this.view.position.y = -set.centerz + set.movez;
|
||||
this.view.position.z = -set.movez/2;
|
||||
this.view.position.y += -set.dy;
|
||||
this.view.position.z += -set.dz;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
|
|
|||
|
|
@ -75,14 +75,25 @@ KIRI.worker = {
|
|||
widget.mesh = null;
|
||||
widget.points = null;
|
||||
widget.loadVertices(widget.vertices);
|
||||
let bbox1 = widget.getBoundingBox(true);
|
||||
let bb1 = widget.getBoundingBox(true);
|
||||
let zd = bb1.max.z - bb1.min.z; // z dim
|
||||
// let cy1 = (bb1.max.y + bb1.min.y) / 2;
|
||||
// let cz1 = (bb1.max.z + bb1.min.z) / 2;
|
||||
widget.setPoints(null);
|
||||
widget._rotate(rotation,0,0,true);
|
||||
widget.center();
|
||||
widget.center(false, true);
|
||||
let bb2 = widget.getBoundingBox(true);
|
||||
// let cy2 = (bb2.max.y + bb2.min.y) / 2;
|
||||
// let cz2 = (bb2.max.z + bb2.min.z) / 2;
|
||||
// let angle = Math.atan2(cy1-cy2, cz1-cz2) * (180 / Math.PI);
|
||||
widget.rotated = true;
|
||||
let bbox2 = widget.getBoundingBox(true);
|
||||
let centerz = (bbox2.max.z - bbox2.min.z) / 2;
|
||||
let movez = centerz - (bbox1.max.z - bbox1.min.z) / 2;
|
||||
widget.rotinfo = { centerz, movez, angle: 45 };
|
||||
let rc = Math.sin(Math.PI/4);
|
||||
let cz = (bb2.max.z - bb2.min.z) / 2; // center z post rotate
|
||||
let dy = cz * rc; // dy = cz rotated 45
|
||||
let dz = dy - zd / 2;
|
||||
// console.log({cy1,cz1,cy2,cz2,angle,cy});
|
||||
widget.rotinfo = { angle: 45, dy, dz };
|
||||
widget.getBoundingBox(true);
|
||||
}
|
||||
|
||||
widget.slice(settings, function(error) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue