Refactor camera calculations to use clamping functions and implement smooth zoom updates.
This commit is contained in:
@@ -1429,7 +1429,8 @@ export class ViewportHost {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.cameraSpherical.radius = fitDistance;
|
this.cameraSpherical.radius =
|
||||||
|
this.clampPerspectiveCameraRadius(fitDistance);
|
||||||
this.cameraSpherical.makeSafe();
|
this.cameraSpherical.makeSafe();
|
||||||
this.applyPerspectiveCameraPose();
|
this.applyPerspectiveCameraPose();
|
||||||
this.emitCameraStateChange();
|
this.emitCameraStateChange();
|
||||||
@@ -1444,10 +1445,8 @@ export class ViewportHost {
|
|||||||
const fitZoom =
|
const fitZoom =
|
||||||
Math.min(visibleWidth, ORTHOGRAPHIC_FRUSTUM_HEIGHT) / fitSize;
|
Math.min(visibleWidth, ORTHOGRAPHIC_FRUSTUM_HEIGHT) / fitSize;
|
||||||
|
|
||||||
this.orthographicCamera.zoom = Math.min(
|
this.orthographicCamera.zoom =
|
||||||
MAX_ORTHOGRAPHIC_ZOOM,
|
this.clampOrthographicCameraZoom(fitZoom);
|
||||||
Math.max(MIN_ORTHOGRAPHIC_ZOOM, fitZoom)
|
|
||||||
);
|
|
||||||
this.applyOrthographicCameraPose();
|
this.applyOrthographicCameraPose();
|
||||||
this.emitCameraStateChange();
|
this.emitCameraStateChange();
|
||||||
}
|
}
|
||||||
@@ -10272,14 +10271,15 @@ export class ViewportHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.animationFrame = window.requestAnimationFrame(this.render);
|
this.animationFrame = window.requestAnimationFrame(this.render);
|
||||||
this.updateGridPositioning();
|
|
||||||
this.updateTransformGizmoPose();
|
|
||||||
const now = performance.now();
|
const now = performance.now();
|
||||||
const dt =
|
const dt =
|
||||||
this.previousFrameTime === 0
|
this.previousFrameTime === 0
|
||||||
? 0
|
? 0
|
||||||
: Math.min((now - this.previousFrameTime) / 1000, 1 / 20);
|
: Math.min((now - this.previousFrameTime) / 1000, 1 / 20);
|
||||||
this.previousFrameTime = now;
|
this.previousFrameTime = now;
|
||||||
|
this.updateSmoothZoom(dt);
|
||||||
|
this.updateGridPositioning();
|
||||||
|
this.updateTransformGizmoPose();
|
||||||
this.volumeTime += dt;
|
this.volumeTime += dt;
|
||||||
|
|
||||||
for (const uniform of this.volumeAnimatedUniforms) {
|
for (const uniform of this.volumeAnimatedUniforms) {
|
||||||
|
|||||||
Reference in New Issue
Block a user