Skip to content

Commit

Permalink
better zoomExtents with pivot
Browse files Browse the repository at this point in the history
  • Loading branch information
sdumetz committed Sep 5, 2024
1 parent 342ab8f commit 442f0fb
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions libs/ff-three/source/CameraController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,31 @@ export default class CameraController implements IManip
return;
}


// _vec3a.copy(this.orbit).multiplyScalar(math.DEG2RAD);
// _eua.setFromVector3(_vec3a, "YXZ");
// _quat.setFromEuler(_eua);
// //Position, relative to pivot point
// _vec3b.copy(this.offset).applyEuler(_eua).add(this.pivot);
// //Keep scale
// _vec3c.setFromMatrixScale(object.matrix);
// //Compose everything
// object.matrix.compose(_vec3b, _quat, _vec3c);


// rotate box to camera space
_vec3a.copy(this.orbit).multiplyScalar(math.DEG2RAD);
_quat.setFromEuler(_eua.setFromVector3(_vec3a));
_vec3b.setScalar(0);
_vec3c.setScalar(1);
//Ignore the pivot point for now
//Ignore the pivot point for now. Rotate the box into camera space
_mat4.compose(_vec3b, _quat, _vec3c);

_box3.copy(box).applyMatrix4(_mat4.transpose());
_box3.getSize(_vec3a);
_box3.getCenter(_vec3b);
_vec3b.sub(this.pivot);

_vec3c.copy(this.pivot).applyMatrix4(_mat4);
_vec3b.sub(_vec3c);

offset.x = _vec3b.x;
offset.y = _vec3b.y;
Expand Down

0 comments on commit 442f0fb

Please sign in to comment.