diff --git a/src/moto/orbit.js b/src/moto/orbit.js index 893fcc34..bcb65686 100644 --- a/src/moto/orbit.js +++ b/src/moto/orbit.js @@ -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) { diff --git a/src/moto/space.js b/src/moto/space.js index 7a17b473..808cf02a 100644 --- a/src/moto/space.js +++ b/src/moto/space.js @@ -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') {