Fixed the issues in #1611. There is still an issue left, where zooming in in orthographic mode, then switching to perspective does not yield the correct camera distance, especially when the controls target is off model (#1616)

This commit is contained in:
Alexandru Popovici
2023-06-16 15:55:27 +03:00
committed by GitHub
parent 5f6a696def
commit a52bb75414
6 changed files with 55 additions and 25 deletions
@@ -47,6 +47,7 @@ export class SpeckleCameraControls extends CameraControls {
private _didZoom = false
private overrideDollyLerpRatio = 0
private overrideZoomLerpRatio = 0
static install() {
_v3A = new Vector3()
_v3B = new Vector3()
@@ -101,6 +102,10 @@ export class SpeckleCameraControls extends CameraControls {
protected _zoomInternal = (delta: number, x: number, y: number): void => {
const zoomScale = Math.pow(0.95, delta * this.dollySpeed)
/** We need to move the camera as well when zooming in orthographic mode */
const dollyScale = Math.pow(0.95, -delta * this.dollySpeed)
const distance = this._sphericalEnd.radius * dollyScale
this.dollyTo(distance, true, 0.9)
// for both PerspectiveCamera and OrthographicCamera
this.zoomTo(this._zoom * zoomScale, false, 1)