shift + f to fit workspace contents immediate
This commit is contained in:
parent
e5e189cf90
commit
c61fadd68b
2 changed files with 12 additions and 19 deletions
|
|
@ -227,10 +227,10 @@ class Orbit extends EventDispatcher {
|
|||
this.setPosition = function(set) {
|
||||
thetaSet = firstValue([set.left, set.theta, thetaSet]);
|
||||
phiSet = firstValue([set.up, set.phi, phiSet]);
|
||||
if (set.panX) this.target.x = set.panX;
|
||||
if (set.panY) this.target.y = set.panY;
|
||||
if (set.panZ) this.target.z = set.panZ;
|
||||
if (set.scale) scale = set.scale;
|
||||
if (set.panX !== undefined) this.target.x = set.panX;
|
||||
if (set.panY !== undefined) this.target.y = set.panY;
|
||||
if (set.panZ !== undefined) this.target.z = set.panZ;
|
||||
if (set.scale !== undefined) scale = set.scale;
|
||||
};
|
||||
|
||||
this.getPosition = function(scaled) {
|
||||
|
|
|
|||
|
|
@ -1306,27 +1306,20 @@ let Space = {
|
|||
const newPanZ = center.z;
|
||||
|
||||
// First, tween to center the view on the object
|
||||
tweenCam({
|
||||
viewControl.setPosition({
|
||||
left,
|
||||
up: upAngle,
|
||||
panX: newPanX,
|
||||
panY: newPanY,
|
||||
panZ: newPanZ,
|
||||
then: () => {
|
||||
// After centering, adjust zoom to fit
|
||||
// Calculate the actual current distance after recentering
|
||||
const currentDist = camera.position.distanceTo(viewControl.getTarget());
|
||||
const scale = desiredDistance / currentDist;
|
||||
|
||||
// Apply the zoom adjustment
|
||||
viewControl.setPosition({ scale });
|
||||
viewControl.update();
|
||||
requestRefresh();
|
||||
|
||||
// Call user's callback if provided
|
||||
if (then) then();
|
||||
}
|
||||
});
|
||||
|
||||
const currentDist = camera.position.distanceTo(viewControl.getTarget());
|
||||
const scale = desiredDistance / currentDist;
|
||||
viewControl.setPosition({ scale });
|
||||
viewControl.update();
|
||||
|
||||
if (then) then();
|
||||
},
|
||||
setCtrl: (name) => {
|
||||
if (name === 'onshape') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue