@shapediver/viewer.rendering-engine.camera-engine 3.9.0 → 3.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/implementation/CameraEngine.d.ts +5 -5
- package/dist/implementation/CameraEngine.d.ts.map +1 -1
- package/dist/implementation/CameraEngine.js +209 -58
- package/dist/implementation/CameraEngine.js.map +1 -1
- package/dist/implementation/camera/AbstractCamera.d.ts +8 -8
- package/dist/implementation/camera/AbstractCamera.d.ts.map +1 -1
- package/dist/implementation/camera/AbstractCamera.js +25 -9
- package/dist/implementation/camera/AbstractCamera.js.map +1 -1
- package/dist/implementation/camera/OrthographicCamera.d.ts +7 -7
- package/dist/implementation/camera/OrthographicCamera.d.ts.map +1 -1
- package/dist/implementation/camera/OrthographicCamera.js +35 -28
- package/dist/implementation/camera/OrthographicCamera.js.map +1 -1
- package/dist/implementation/camera/PerspectiveCamera.d.ts +7 -7
- package/dist/implementation/camera/PerspectiveCamera.d.ts.map +1 -1
- package/dist/implementation/camera/PerspectiveCamera.js +38 -17
- package/dist/implementation/camera/PerspectiveCamera.js.map +1 -1
- package/dist/implementation/controls/AbstractCameraControls.d.ts +6 -6
- package/dist/implementation/controls/AbstractCameraControls.d.ts.map +1 -1
- package/dist/implementation/controls/AbstractCameraControls.js +139 -48
- package/dist/implementation/controls/AbstractCameraControls.js.map +1 -1
- package/dist/implementation/controls/CameraControlsEventDistribution.d.ts +3 -3
- package/dist/implementation/controls/CameraControlsEventDistribution.d.ts.map +1 -1
- package/dist/implementation/controls/CameraControlsEventDistribution.js +44 -16
- package/dist/implementation/controls/CameraControlsEventDistribution.js.map +1 -1
- package/dist/implementation/controls/CameraControlsLogic.d.ts +3 -3
- package/dist/implementation/controls/CameraControlsLogic.d.ts.map +1 -1
- package/dist/implementation/controls/CameraControlsLogic.js +134 -59
- package/dist/implementation/controls/CameraControlsLogic.js.map +1 -1
- package/dist/implementation/controls/OrthographicCameraControls.d.ts +2 -2
- package/dist/implementation/controls/OrthographicCameraControls.d.ts.map +1 -1
- package/dist/implementation/controls/OrthographicCameraControls.js +4 -3
- package/dist/implementation/controls/OrthographicCameraControls.js.map +1 -1
- package/dist/implementation/controls/PerspectiveCameraControls.d.ts +2 -2
- package/dist/implementation/controls/PerspectiveCameraControls.d.ts.map +1 -1
- package/dist/implementation/controls/PerspectiveCameraControls.js +4 -3
- package/dist/implementation/controls/PerspectiveCameraControls.js.map +1 -1
- package/dist/implementation/interpolation/CameraInterpolationManager.d.ts +3 -3
- package/dist/implementation/interpolation/CameraInterpolationManager.d.ts.map +1 -1
- package/dist/implementation/interpolation/CameraInterpolationManager.js +26 -17
- package/dist/implementation/interpolation/CameraInterpolationManager.js.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.d.ts +4 -4
- package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.d.ts.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.js +8 -5
- package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.js.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.d.ts +4 -4
- package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.d.ts.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.js +1 -2
- package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.js.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.d.ts +4 -4
- package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.d.ts.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.js +2 -3
- package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.js.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.d.ts +4 -4
- package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.d.ts.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.js +1 -2
- package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.js.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.d.ts +4 -4
- package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.d.ts.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.js +3 -3
- package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.js.map +1 -1
- package/dist/index.d.ts +13 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/interfaces/ICameraEngine.d.ts +1 -1
- package/dist/interfaces/ICameraEngine.d.ts.map +1 -1
- package/dist/interfaces/ICameraEngine.js.map +1 -1
- package/dist/interfaces/camera/ICamera.d.ts +9 -9
- package/dist/interfaces/camera/ICamera.d.ts.map +1 -1
- package/dist/interfaces/camera/ICamera.js.map +1 -1
- package/dist/interfaces/camera/IOrthographicCamera.d.ts +2 -2
- package/dist/interfaces/camera/IOrthographicCamera.d.ts.map +1 -1
- package/dist/interfaces/camera/IOrthographicCamera.js.map +1 -1
- package/dist/interfaces/camera/IPerspectiveCamera.d.ts +2 -2
- package/dist/interfaces/camera/IPerspectiveCamera.d.ts.map +1 -1
- package/dist/interfaces/controls/ICameraControls.d.ts +3 -3
- package/dist/interfaces/controls/ICameraControls.d.ts.map +1 -1
- package/dist/interfaces/controls/ICameraControls.js.map +1 -1
- package/dist/interfaces/controls/ICameraControlsEventDistribution.d.ts +1 -1
- package/dist/interfaces/controls/ICameraControlsEventDistribution.d.ts.map +1 -1
- package/dist/interfaces/controls/ICameraControlsLogic.d.ts +1 -1
- package/dist/interfaces/controls/ICameraControlsLogic.d.ts.map +1 -1
- package/dist/interfaces/interpolation/ICameraInterpolation.d.ts.map +1 -1
- package/package.json +50 -50
|
@@ -8,7 +8,7 @@ class CameraControlsEventDistribution {
|
|
|
8
8
|
this._active = {
|
|
9
9
|
rotation: false,
|
|
10
10
|
zoom: false,
|
|
11
|
-
pan: false
|
|
11
|
+
pan: false,
|
|
12
12
|
};
|
|
13
13
|
this._activeEvents = true;
|
|
14
14
|
this._controls = controls;
|
|
@@ -27,9 +27,11 @@ class CameraControlsEventDistribution {
|
|
|
27
27
|
if (this._controls.camera.active === false)
|
|
28
28
|
return;
|
|
29
29
|
const { x, y } = this.convertInput(event);
|
|
30
|
-
const touchEvent = event.pointerType ===
|
|
30
|
+
const touchEvent = event.pointerType === "touch";
|
|
31
31
|
const input = this.getInput(event);
|
|
32
|
-
const mapping = event.pointerType ===
|
|
32
|
+
const mapping = event.pointerType === "touch"
|
|
33
|
+
? this._controls.input.touch
|
|
34
|
+
: this._controls.input.mouse;
|
|
33
35
|
if (input === mapping.rotate && this._controls.enableRotation) {
|
|
34
36
|
this._cameraLogic.rotate(x, y, this._active.rotation, touchEvent);
|
|
35
37
|
this._active.rotation = true;
|
|
@@ -46,9 +48,19 @@ class CameraControlsEventDistribution {
|
|
|
46
48
|
}
|
|
47
49
|
if (input === mapping.zoom && this._controls.enableZoom) {
|
|
48
50
|
let x1 = x, y1 = y;
|
|
49
|
-
if (touchEvent &&
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
if (touchEvent &&
|
|
52
|
+
this._controls.input.touch.zoom === 2 &&
|
|
53
|
+
this._primaryPointerEvent &&
|
|
54
|
+
this._secondaryPointerEvent) {
|
|
55
|
+
x1 =
|
|
56
|
+
((this._primaryPointerEvent.pageX -
|
|
57
|
+
this._secondaryPointerEvent.pageX) /
|
|
58
|
+
window.innerWidth) *
|
|
59
|
+
(window.innerWidth / window.innerHeight);
|
|
60
|
+
y1 =
|
|
61
|
+
(this._primaryPointerEvent.pageY -
|
|
62
|
+
this._secondaryPointerEvent.pageY) /
|
|
63
|
+
window.innerHeight;
|
|
52
64
|
}
|
|
53
65
|
this._cameraLogic.zoom(x1, y1, this._active.zoom, touchEvent);
|
|
54
66
|
this._active.zoom = true;
|
|
@@ -108,16 +120,26 @@ class CameraControlsEventDistribution {
|
|
|
108
120
|
if (this._controls.camera.active === false)
|
|
109
121
|
return;
|
|
110
122
|
const { x, y } = this.convertInput(event);
|
|
111
|
-
const touchEvent = event.pointerType ===
|
|
123
|
+
const touchEvent = event.pointerType === "touch";
|
|
112
124
|
if (this._controls.enableRotation && this._active.rotation)
|
|
113
125
|
this._cameraLogic.rotate(x, y, this._active.rotation, touchEvent);
|
|
114
126
|
if (this._controls.enablePan && this._active.pan)
|
|
115
127
|
this._cameraLogic.pan(x, y, this._active.pan, touchEvent);
|
|
116
128
|
if (this._controls.enableZoom && this._active.zoom) {
|
|
117
129
|
let x1 = x, y1 = y;
|
|
118
|
-
if (touchEvent &&
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
if (touchEvent &&
|
|
131
|
+
this._controls.input.touch.zoom === 2 &&
|
|
132
|
+
this._primaryPointerEvent &&
|
|
133
|
+
this._secondaryPointerEvent) {
|
|
134
|
+
x1 =
|
|
135
|
+
((this._primaryPointerEvent.pageX -
|
|
136
|
+
this._secondaryPointerEvent.pageX) /
|
|
137
|
+
window.innerWidth) *
|
|
138
|
+
(window.innerWidth / window.innerHeight);
|
|
139
|
+
y1 =
|
|
140
|
+
(this._primaryPointerEvent.pageY -
|
|
141
|
+
this._secondaryPointerEvent.pageY) /
|
|
142
|
+
window.innerHeight;
|
|
121
143
|
}
|
|
122
144
|
this._cameraLogic.zoom(x1, y1, this._active.zoom, touchEvent);
|
|
123
145
|
}
|
|
@@ -214,7 +236,7 @@ class CameraControlsEventDistribution {
|
|
|
214
236
|
this._active = {
|
|
215
237
|
rotation: false,
|
|
216
238
|
zoom: false,
|
|
217
|
-
pan: false
|
|
239
|
+
pan: false,
|
|
218
240
|
};
|
|
219
241
|
}
|
|
220
242
|
// #endregion Public Methods (16)
|
|
@@ -222,19 +244,23 @@ class CameraControlsEventDistribution {
|
|
|
222
244
|
convertInput(event) {
|
|
223
245
|
if (this._primaryPointerEvent && this._secondaryPointerEvent) {
|
|
224
246
|
return {
|
|
225
|
-
x: (this._primaryPointerEvent.pageX +
|
|
226
|
-
|
|
247
|
+
x: (this._primaryPointerEvent.pageX +
|
|
248
|
+
this._secondaryPointerEvent.pageX) /
|
|
249
|
+
2,
|
|
250
|
+
y: (this._primaryPointerEvent.pageY +
|
|
251
|
+
this._secondaryPointerEvent.pageY) /
|
|
252
|
+
2,
|
|
227
253
|
};
|
|
228
254
|
}
|
|
229
255
|
else {
|
|
230
256
|
return {
|
|
231
257
|
x: event.clientX,
|
|
232
|
-
y: event.clientY
|
|
258
|
+
y: event.clientY,
|
|
233
259
|
};
|
|
234
260
|
}
|
|
235
261
|
}
|
|
236
262
|
getInput(event) {
|
|
237
|
-
if (event.pointerType ===
|
|
263
|
+
if (event.pointerType === "touch") {
|
|
238
264
|
if (this._secondaryPointerEvent) {
|
|
239
265
|
return 2;
|
|
240
266
|
}
|
|
@@ -250,7 +276,9 @@ class CameraControlsEventDistribution {
|
|
|
250
276
|
// #region Private Methods (1)
|
|
251
277
|
revert() {
|
|
252
278
|
if (this._controls.camera.revertAtMouseUp === true) {
|
|
253
|
-
this._controls.camera.reset({
|
|
279
|
+
this._controls.camera.reset({
|
|
280
|
+
duration: this._controls.camera.revertAtMouseUpDuration,
|
|
281
|
+
});
|
|
254
282
|
}
|
|
255
283
|
}
|
|
256
284
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CameraControlsEventDistribution.js","sourceRoot":"","sources":["../../../src/implementation/controls/CameraControlsEventDistribution.ts"],"names":[],"mappings":";;;AAIA,MAAa,+BAA+B;
|
|
1
|
+
{"version":3,"file":"CameraControlsEventDistribution.js","sourceRoot":"","sources":["../../../src/implementation/controls/CameraControlsEventDistribution.ts"],"names":[],"mappings":";;;AAIA,MAAa,+BAA+B;IAkB3C,4BAA4B;IAE5B,2BAA2B;IAE3B,YAAY,QAAyB,EAAE,WAAiC;QAf9D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oBACnC,CAAC;gBACF,CAAC,EACA,CAAC,IAAI,CAAC,oBAAoB,CAAC,KAAK;oBAC/B,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC;oBACnC,CAAC;aACF,CAAC;SACF;aAAM;YACN,OAAO;gBACN,CAAC,EAAE,KAAK,CAAC,OAAO;gBAChB,CAAC,EAAE,KAAK,CAAC,OAAO;aAChB,CAAC;SACF;IACF,CAAC;IAES,QAAQ,CAAC,KAAmB;QACrC,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE;YAClC,IAAI,IAAI,CAAC,sBAAsB,EAAE;gBAChC,OAAO,CAAC,CAAC;aACT;iBAAM;gBACN,OAAO,CAAC,CAAC;aACT;SACD;aAAM;YACN,OAAO,KAAK,CAAC,MAAM,CAAC;SACpB;IACF,CAAC;IAED,mCAAmC;IAEnC,8BAA8B;IAEtB,MAAM;QACb,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,KAAK,IAAI,EAAE;YACnD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC3B,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,uBAAuB;aACvD,CAAC,CAAC;SACH;IACF,CAAC;CAGD;AAhVD,0EAgVC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { vec2, vec3 } from "gl-matrix";
|
|
2
|
+
import { Adjustments, ICameraControls } from "../../interfaces/controls/ICameraControls";
|
|
3
|
+
import { ICameraControlsLogic } from "../../interfaces/controls/ICameraControlsLogic";
|
|
4
4
|
export declare class CameraControlsLogic implements ICameraControlsLogic {
|
|
5
5
|
private readonly _controls;
|
|
6
6
|
private readonly _settingsAdjustments;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CameraControlsLogic.d.ts","sourceRoot":"","sources":["../../../src/implementation/controls/CameraControlsLogic.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"CameraControlsLogic.d.ts","sourceRoot":"","sources":["../../../src/implementation/controls/CameraControlsLogic.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,IAAI,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AAEjD,OAAO,EACN,WAAW,EACX,eAAe,EACf,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gDAAgD,CAAC;AAKpF,qBAAa,mBAAoB,YAAW,oBAAoB;IAuD9D,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAtDnC,OAAO,CAAC,iBAAiB,CAgBvB;IACF,OAAO,CAAC,QAAQ,CAiBd;IACF,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,KAAK,CAAO;IACpB,OAAO,CAAC,YAAY,CAAO;IAC3B,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,UAAU,CAAiB;IACnC,OAAO,CAAC,YAAY,CAAiB;gBAOnB,SAAS,EAAE,eAAe,EAC1B,oBAAoB,EAAE,WAAW,EACjC,iBAAiB,EAAE,WAAW;IAoBzC,oBAAoB,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,OAAO;IAkE3D,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IA8FhE,KAAK;IA8BL,QAAQ,CACd,QAAQ,EAAE,IAAI,EACd,MAAM,EAAE,IAAI,EACZ,aAAa,EAAE,IAAI,GACjB;QAAC,QAAQ,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,IAAI,CAAC;QAAC,aAAa,EAAE,IAAI,CAAA;KAAC;IAsK/C,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAqFnE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,GAAG,IAAI;IAgHtD,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAqDxE,OAAO,CAAC,gBAAgB;IA2FxB,OAAO,CAAC,yBAAyB;IAgDjC,OAAO,CAAC,oBAAoB;CAe5B"}
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CameraControlsLogic = void 0;
|
|
4
4
|
const viewer_shared_math_1 = require("@shapediver/viewer.shared.math");
|
|
5
5
|
const gl_matrix_1 = require("gl-matrix");
|
|
6
|
-
const OrthographicCamera_1 = require("../camera/OrthographicCamera");
|
|
7
|
-
const ICameraEngine_1 = require("../../interfaces/ICameraEngine");
|
|
8
6
|
const IOrthographicCamera_1 = require("../../interfaces/camera/IOrthographicCamera");
|
|
7
|
+
const ICameraEngine_1 = require("../../interfaces/ICameraEngine");
|
|
8
|
+
const OrthographicCamera_1 = require("../camera/OrthographicCamera");
|
|
9
9
|
class CameraControlsLogic {
|
|
10
10
|
// #endregion Properties (13)
|
|
11
11
|
// #region Constructors (1)
|
|
@@ -15,11 +15,14 @@ class CameraControlsLogic {
|
|
|
15
15
|
this._touchAdjustments = _touchAdjustments;
|
|
16
16
|
// #region Properties (13)
|
|
17
17
|
this._adjustedSettings = {
|
|
18
|
-
autoRotationSpeed: () => this._controls.autoRotationSpeed *
|
|
18
|
+
autoRotationSpeed: () => this._controls.autoRotationSpeed *
|
|
19
|
+
this._settingsAdjustments.autoRotationSpeed,
|
|
19
20
|
damping: () => this._controls.damping * this._settingsAdjustments.damping,
|
|
20
|
-
movementSmoothness: () => this._controls.movementSmoothness *
|
|
21
|
+
movementSmoothness: () => this._controls.movementSmoothness *
|
|
22
|
+
this._settingsAdjustments.movementSmoothness,
|
|
21
23
|
panSpeed: () => this._controls.panSpeed * this._settingsAdjustments.panSpeed,
|
|
22
|
-
rotationSpeed: () => this._controls.rotationSpeed *
|
|
24
|
+
rotationSpeed: () => this._controls.rotationSpeed *
|
|
25
|
+
this._settingsAdjustments.rotationSpeed,
|
|
23
26
|
zoomSpeed: () => this._controls.zoomSpeed * this._settingsAdjustments.zoomSpeed,
|
|
24
27
|
};
|
|
25
28
|
this._damping = {
|
|
@@ -27,17 +30,17 @@ class CameraControlsLogic {
|
|
|
27
30
|
time: 0,
|
|
28
31
|
duration: 0,
|
|
29
32
|
theta: 0,
|
|
30
|
-
phi: 0
|
|
33
|
+
phi: 0,
|
|
31
34
|
},
|
|
32
35
|
zoom: {
|
|
33
36
|
time: 0,
|
|
34
37
|
duration: 0,
|
|
35
|
-
delta: 0
|
|
38
|
+
delta: 0,
|
|
36
39
|
},
|
|
37
40
|
pan: {
|
|
38
41
|
time: 0,
|
|
39
42
|
duration: 0,
|
|
40
|
-
offset: gl_matrix_1.vec3.create()
|
|
43
|
+
offset: gl_matrix_1.vec3.create(),
|
|
41
44
|
},
|
|
42
45
|
};
|
|
43
46
|
this._dollyDelta = 0;
|
|
@@ -61,9 +64,14 @@ class CameraControlsLogic {
|
|
|
61
64
|
if (!(tBox.containsPoint(target) && tSphere.containsPoint(target)))
|
|
62
65
|
return false;
|
|
63
66
|
const currentDistance = gl_matrix_1.vec3.distance(position, target);
|
|
64
|
-
if (currentDistance > this._controls.zoomRestriction.maxDistance ||
|
|
67
|
+
if (currentDistance > this._controls.zoomRestriction.maxDistance ||
|
|
68
|
+
currentDistance < this._controls.zoomRestriction.minDistance)
|
|
65
69
|
return false;
|
|
66
|
-
const minPolarAngle = this._controls.rotationRestriction.minPolarAngle *
|
|
70
|
+
const minPolarAngle = this._controls.rotationRestriction.minPolarAngle *
|
|
71
|
+
(Math.PI / 180), maxPolarAngle = this._controls.rotationRestriction.maxPolarAngle *
|
|
72
|
+
(Math.PI / 180), minAzimuthAngle = this._controls.rotationRestriction.minAzimuthAngle *
|
|
73
|
+
(Math.PI / 180), maxAzimuthAngle = this._controls.rotationRestriction.maxAzimuthAngle *
|
|
74
|
+
(Math.PI / 180);
|
|
67
75
|
if (minAzimuthAngle !== -Infinity ||
|
|
68
76
|
maxAzimuthAngle !== Infinity ||
|
|
69
77
|
minPolarAngle !== 0 ||
|
|
@@ -90,34 +98,46 @@ class CameraControlsLogic {
|
|
|
90
98
|
if (this._panDelta[0] === 0 && this._panDelta[1] === 0)
|
|
91
99
|
return;
|
|
92
100
|
gl_matrix_1.vec2.copy(this._panStart, this._panEnd);
|
|
93
|
-
const adjustedPanSpeed = this._adjustedSettings.panSpeed() *
|
|
101
|
+
const adjustedPanSpeed = this._adjustedSettings.panSpeed() *
|
|
102
|
+
(touch ? this._touchAdjustments.panSpeed : 1.0);
|
|
94
103
|
const offset = this.panDeltaToOffset(gl_matrix_1.vec2.mul(gl_matrix_1.vec2.create(), this._panDelta, gl_matrix_1.vec2.fromValues(adjustedPanSpeed, adjustedPanSpeed)));
|
|
95
104
|
if (this._damping.pan.duration > 0) {
|
|
96
105
|
if (offset[0] < 0) {
|
|
97
|
-
offset[0] = Math.min(offset[0], this._adjustedSettings.movementSmoothness() *
|
|
106
|
+
offset[0] = Math.min(offset[0], this._adjustedSettings.movementSmoothness() *
|
|
107
|
+
this._damping.pan.offset[0]);
|
|
98
108
|
}
|
|
99
109
|
else {
|
|
100
|
-
offset[0] = Math.max(offset[0], this._adjustedSettings.movementSmoothness() *
|
|
110
|
+
offset[0] = Math.max(offset[0], this._adjustedSettings.movementSmoothness() *
|
|
111
|
+
this._damping.pan.offset[0]);
|
|
101
112
|
}
|
|
102
113
|
if (offset[1] < 0) {
|
|
103
|
-
offset[1] = Math.min(offset[1], this._adjustedSettings.movementSmoothness() *
|
|
114
|
+
offset[1] = Math.min(offset[1], this._adjustedSettings.movementSmoothness() *
|
|
115
|
+
this._damping.pan.offset[1]);
|
|
104
116
|
}
|
|
105
117
|
else {
|
|
106
|
-
offset[1] = Math.max(offset[1], this._adjustedSettings.movementSmoothness() *
|
|
118
|
+
offset[1] = Math.max(offset[1], this._adjustedSettings.movementSmoothness() *
|
|
119
|
+
this._damping.pan.offset[1]);
|
|
107
120
|
}
|
|
108
121
|
if (offset[2] < 0) {
|
|
109
|
-
offset[2] = Math.min(offset[2], this._adjustedSettings.movementSmoothness() *
|
|
122
|
+
offset[2] = Math.min(offset[2], this._adjustedSettings.movementSmoothness() *
|
|
123
|
+
this._damping.pan.offset[2]);
|
|
110
124
|
}
|
|
111
125
|
else {
|
|
112
|
-
offset[2] = Math.max(offset[2], this._adjustedSettings.movementSmoothness() *
|
|
126
|
+
offset[2] = Math.max(offset[2], this._adjustedSettings.movementSmoothness() *
|
|
127
|
+
this._damping.pan.offset[2]);
|
|
113
128
|
}
|
|
114
129
|
}
|
|
115
|
-
const damping = 1 -
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
130
|
+
const damping = 1 -
|
|
131
|
+
Math.max(0.01, Math.min(0.99, this._adjustedSettings.damping()));
|
|
132
|
+
const framesOffsetX = (Math.log(1 / Math.abs(offset[0])) - 5 * Math.log(10)) /
|
|
133
|
+
Math.log(damping);
|
|
134
|
+
const framesOffsetY = (Math.log(1 / Math.abs(offset[1])) - 5 * Math.log(10)) /
|
|
135
|
+
Math.log(damping);
|
|
136
|
+
const framesOffsetZ = (Math.log(1 / Math.abs(offset[2])) - 5 * Math.log(10)) /
|
|
137
|
+
Math.log(damping);
|
|
119
138
|
this._damping.pan.time = 0;
|
|
120
|
-
this._damping.pan.duration =
|
|
139
|
+
this._damping.pan.duration =
|
|
140
|
+
Math.max(framesOffsetX, Math.max(framesOffsetY, framesOffsetZ)) * 16.6666;
|
|
121
141
|
this._damping.pan.offset = gl_matrix_1.vec3.clone(offset);
|
|
122
142
|
this._damping.rotation.duration = 0;
|
|
123
143
|
this._damping.zoom.duration = 0;
|
|
@@ -131,17 +151,17 @@ class CameraControlsLogic {
|
|
|
131
151
|
time: 0,
|
|
132
152
|
duration: 0,
|
|
133
153
|
theta: 0,
|
|
134
|
-
phi: 0
|
|
154
|
+
phi: 0,
|
|
135
155
|
},
|
|
136
156
|
zoom: {
|
|
137
157
|
time: 0,
|
|
138
158
|
duration: 0,
|
|
139
|
-
delta: 0
|
|
159
|
+
delta: 0,
|
|
140
160
|
},
|
|
141
161
|
pan: {
|
|
142
162
|
time: 0,
|
|
143
163
|
duration: 0,
|
|
144
|
-
offset: gl_matrix_1.vec3.create()
|
|
164
|
+
offset: gl_matrix_1.vec3.create(),
|
|
145
165
|
},
|
|
146
166
|
};
|
|
147
167
|
this._dollyDelta = 0;
|
|
@@ -166,13 +186,18 @@ class CameraControlsLogic {
|
|
|
166
186
|
target = tSphere.clampPoint(target);
|
|
167
187
|
// zoom restrictions
|
|
168
188
|
const currentDistance = gl_matrix_1.vec3.distance(position, target);
|
|
169
|
-
if (currentDistance > this._controls.zoomRestriction.maxDistance ||
|
|
189
|
+
if (currentDistance > this._controls.zoomRestriction.maxDistance ||
|
|
190
|
+
currentDistance < this._controls.zoomRestriction.minDistance) {
|
|
170
191
|
const direction = gl_matrix_1.vec3.normalize(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), position, target));
|
|
171
192
|
const distance = Math.max(this._controls.zoomRestriction.minDistance, Math.min(this._controls.zoomRestriction.maxDistance, currentDistance));
|
|
172
193
|
gl_matrix_1.vec3.add(position, gl_matrix_1.vec3.multiply(position, direction, gl_matrix_1.vec3.fromValues(distance, distance, distance)), target);
|
|
173
194
|
}
|
|
174
195
|
// angle restrictions
|
|
175
|
-
const minPolarAngle = this._controls.rotationRestriction.minPolarAngle *
|
|
196
|
+
const minPolarAngle = this._controls.rotationRestriction.minPolarAngle *
|
|
197
|
+
(Math.PI / 180), maxPolarAngle = this._controls.rotationRestriction.maxPolarAngle *
|
|
198
|
+
(Math.PI / 180), minAzimuthAngle = this._controls.rotationRestriction.minAzimuthAngle *
|
|
199
|
+
(Math.PI / 180), maxAzimuthAngle = this._controls.rotationRestriction.maxAzimuthAngle *
|
|
200
|
+
(Math.PI / 180);
|
|
176
201
|
if (minAzimuthAngle !== -Infinity ||
|
|
177
202
|
maxAzimuthAngle !== Infinity ||
|
|
178
203
|
minPolarAngle !== 0 ||
|
|
@@ -192,7 +217,9 @@ class CameraControlsLogic {
|
|
|
192
217
|
this._controls.enableObjectControls === true) {
|
|
193
218
|
spherical.theta = Math.max(minAzimuthAngle, Math.min(maxAzimuthAngle, spherical.theta));
|
|
194
219
|
spherical.phi = Math.max(minPolarAngle, Math.min(maxPolarAngle, spherical.phi));
|
|
195
|
-
if (this._controls.enableAzimuthRotation === false ||
|
|
220
|
+
if (this._controls.enableAzimuthRotation === false ||
|
|
221
|
+
this._controls.enablePolarRotation === false ||
|
|
222
|
+
this._controls.enableObjectControls === true) {
|
|
196
223
|
const defaultOffset = gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), this._controls.camera.defaultPosition, this._controls.camera.defaultTarget);
|
|
197
224
|
gl_matrix_1.vec3.transformQuat(defaultOffset, defaultOffset, this._quat);
|
|
198
225
|
const defaultSpherical = new viewer_shared_math_1.Spherical().fromVec3(defaultOffset);
|
|
@@ -217,14 +244,22 @@ class CameraControlsLogic {
|
|
|
217
244
|
this._controls.enableAzimuthRotation === false ||
|
|
218
245
|
this._controls.enablePolarRotation === false) &&
|
|
219
246
|
this._controls.enableObjectControls === false) {
|
|
220
|
-
sceneRotation[1] =
|
|
221
|
-
|
|
247
|
+
sceneRotation[1] =
|
|
248
|
+
this._controls.enableAzimuthRotation === false
|
|
249
|
+
? 0
|
|
250
|
+
: Math.max(minAzimuthAngle, Math.min(maxAzimuthAngle, sceneRotation[1]));
|
|
251
|
+
sceneRotation[0] =
|
|
252
|
+
this._controls.enablePolarRotation === false
|
|
253
|
+
? 0
|
|
254
|
+
: Math.max(minPolarAngle, Math.min(maxPolarAngle, sceneRotation[0]));
|
|
222
255
|
}
|
|
223
256
|
}
|
|
224
257
|
return { position, target, sceneRotation };
|
|
225
258
|
}
|
|
226
259
|
rotate(x, y, active, touch) {
|
|
227
|
-
if (this._controls.camera.type === ICameraEngine_1.CAMERA_TYPE.ORTHOGRAPHIC &&
|
|
260
|
+
if (this._controls.camera.type === ICameraEngine_1.CAMERA_TYPE.ORTHOGRAPHIC &&
|
|
261
|
+
this._controls.camera.direction !==
|
|
262
|
+
IOrthographicCamera_1.ORTHOGRAPHIC_CAMERA_DIRECTION.CUSTOM)
|
|
228
263
|
return;
|
|
229
264
|
if (!active) {
|
|
230
265
|
this._rotateStart = gl_matrix_1.vec2.fromValues(x, y);
|
|
@@ -235,27 +270,39 @@ class CameraControlsLogic {
|
|
|
235
270
|
gl_matrix_1.vec2.copy(this._rotateStart, this._rotateEnd);
|
|
236
271
|
if (!this._controls.canvas)
|
|
237
272
|
return;
|
|
238
|
-
if (this._controls.canvas.clientWidth == 0 ||
|
|
273
|
+
if (this._controls.canvas.clientWidth == 0 ||
|
|
274
|
+
this._controls.canvas.clientHeight == 0)
|
|
239
275
|
return;
|
|
240
276
|
const spherical = new viewer_shared_math_1.Spherical();
|
|
241
|
-
const rotationSpeed = this._adjustedSettings.rotationSpeed() *
|
|
242
|
-
|
|
243
|
-
spherical.
|
|
277
|
+
const rotationSpeed = this._adjustedSettings.rotationSpeed() *
|
|
278
|
+
(touch ? this._touchAdjustments.rotationSpeed : 1.0);
|
|
279
|
+
spherical.theta -=
|
|
280
|
+
(rotationSpeed * this._rotateDelta[0]) /
|
|
281
|
+
this._controls.canvas.clientHeight;
|
|
282
|
+
spherical.phi -=
|
|
283
|
+
(rotationSpeed * this._rotateDelta[1]) /
|
|
284
|
+
this._controls.canvas.clientHeight;
|
|
244
285
|
if (this._damping.rotation.duration > 0) {
|
|
245
286
|
const thetaDelta = this._damping.rotation.theta - spherical.theta;
|
|
246
|
-
spherical.theta +=
|
|
287
|
+
spherical.theta +=
|
|
288
|
+
thetaDelta * this._adjustedSettings.movementSmoothness();
|
|
247
289
|
const phiDelta = this._damping.rotation.phi - spherical.phi;
|
|
248
|
-
spherical.phi +=
|
|
290
|
+
spherical.phi +=
|
|
291
|
+
phiDelta * this._adjustedSettings.movementSmoothness();
|
|
249
292
|
}
|
|
250
293
|
let sphericalForOffset = spherical;
|
|
251
294
|
if (this._controls.enableTurntableControls)
|
|
252
295
|
sphericalForOffset = new viewer_shared_math_1.Spherical(1.0, spherical.phi, 0);
|
|
253
296
|
const offset = this.rotationSphericalToOffset(sphericalForOffset);
|
|
254
|
-
const damping = 1 -
|
|
255
|
-
|
|
256
|
-
const
|
|
297
|
+
const damping = 1 -
|
|
298
|
+
Math.max(0.01, Math.min(1, this._adjustedSettings.damping()));
|
|
299
|
+
const framesTheta = (Math.log(1 / Math.abs(spherical.theta)) - 5 * Math.log(10)) /
|
|
300
|
+
Math.log(damping);
|
|
301
|
+
const framesPhi = (Math.log(1 / Math.abs(spherical.phi)) - 5 * Math.log(10)) /
|
|
302
|
+
Math.log(damping);
|
|
257
303
|
this._damping.rotation.time = 0;
|
|
258
|
-
this._damping.rotation.duration =
|
|
304
|
+
this._damping.rotation.duration =
|
|
305
|
+
Math.max(framesTheta, framesPhi) * 16.6666;
|
|
259
306
|
this._damping.rotation.theta = spherical.theta;
|
|
260
307
|
this._damping.rotation.phi = spherical.phi;
|
|
261
308
|
this._damping.pan.duration = 0;
|
|
@@ -292,7 +339,8 @@ class CameraControlsLogic {
|
|
|
292
339
|
this._damping.pan.time = 0;
|
|
293
340
|
}
|
|
294
341
|
if (this._damping.rotation.duration > 0) {
|
|
295
|
-
if (this._damping.rotation.time + time >
|
|
342
|
+
if (this._damping.rotation.time + time >
|
|
343
|
+
this._damping.rotation.duration) {
|
|
296
344
|
this._damping.rotation.time = this._damping.rotation.duration;
|
|
297
345
|
this._damping.rotation.duration = 0;
|
|
298
346
|
}
|
|
@@ -300,8 +348,12 @@ class CameraControlsLogic {
|
|
|
300
348
|
this._damping.rotation.time += time;
|
|
301
349
|
const frameSinceStart = this._damping.rotation.time / 16.6666;
|
|
302
350
|
const spherical = new viewer_shared_math_1.Spherical();
|
|
303
|
-
spherical.theta =
|
|
304
|
-
|
|
351
|
+
spherical.theta =
|
|
352
|
+
this._damping.rotation.theta *
|
|
353
|
+
Math.pow(damping, frameSinceStart);
|
|
354
|
+
spherical.phi =
|
|
355
|
+
this._damping.rotation.phi *
|
|
356
|
+
Math.pow(damping, frameSinceStart);
|
|
305
357
|
let sphericalForOffset = spherical;
|
|
306
358
|
if (this._controls.enableTurntableControls)
|
|
307
359
|
sphericalForOffset = new viewer_shared_math_1.Spherical(1.0, spherical.phi, 0);
|
|
@@ -310,7 +362,10 @@ class CameraControlsLogic {
|
|
|
310
362
|
if (this._controls.enableTurntableControls)
|
|
311
363
|
this._controls.applyRotation([0, spherical.theta]);
|
|
312
364
|
if (this._controls.enableObjectControls)
|
|
313
|
-
this._controls.applyRotation([
|
|
365
|
+
this._controls.applyRotation([
|
|
366
|
+
spherical.phi,
|
|
367
|
+
spherical.theta,
|
|
368
|
+
]);
|
|
314
369
|
}
|
|
315
370
|
}
|
|
316
371
|
else {
|
|
@@ -324,7 +379,8 @@ class CameraControlsLogic {
|
|
|
324
379
|
else {
|
|
325
380
|
this._damping.zoom.time += time;
|
|
326
381
|
const frameSinceStart = this._damping.zoom.time / 16.6666;
|
|
327
|
-
const delta = this._damping.zoom.delta *
|
|
382
|
+
const delta = this._damping.zoom.delta *
|
|
383
|
+
Math.pow(damping, frameSinceStart);
|
|
328
384
|
const offset = this.zoomDistanceToOffset(delta);
|
|
329
385
|
this._controls.applyPositionVector(offset);
|
|
330
386
|
}
|
|
@@ -356,15 +412,21 @@ class CameraControlsLogic {
|
|
|
356
412
|
this._dollyStart = this._dollyEnd;
|
|
357
413
|
if (this._damping.zoom.duration > 0) {
|
|
358
414
|
if (this._dollyDelta < 0) {
|
|
359
|
-
this._dollyDelta = Math.min(this._dollyDelta, this._adjustedSettings.movementSmoothness() *
|
|
415
|
+
this._dollyDelta = Math.min(this._dollyDelta, this._adjustedSettings.movementSmoothness() *
|
|
416
|
+
this._damping.zoom.delta);
|
|
360
417
|
}
|
|
361
418
|
else {
|
|
362
|
-
this._dollyDelta = Math.max(this._dollyDelta, this._adjustedSettings.movementSmoothness() *
|
|
419
|
+
this._dollyDelta = Math.max(this._dollyDelta, this._adjustedSettings.movementSmoothness() *
|
|
420
|
+
this._damping.zoom.delta);
|
|
363
421
|
}
|
|
364
422
|
}
|
|
365
|
-
const delta = -this._dollyDelta *
|
|
366
|
-
|
|
367
|
-
|
|
423
|
+
const delta = -this._dollyDelta *
|
|
424
|
+
this._adjustedSettings.zoomSpeed() *
|
|
425
|
+
(touch ? this._touchAdjustments.zoomSpeed : 1.0);
|
|
426
|
+
const damping = 1 -
|
|
427
|
+
Math.max(0.01, Math.min(1, this._adjustedSettings.damping()));
|
|
428
|
+
const framesDelta = (Math.log(1 / Math.abs(this._dollyDelta)) - 5 * Math.log(10)) /
|
|
429
|
+
Math.log(damping);
|
|
368
430
|
this._damping.zoom.time = 0;
|
|
369
431
|
this._damping.zoom.duration = framesDelta * 16.6666;
|
|
370
432
|
this._damping.zoom.delta = delta;
|
|
@@ -382,39 +444,50 @@ class CameraControlsLogic {
|
|
|
382
444
|
const panOffset = gl_matrix_1.vec3.create();
|
|
383
445
|
if (!this._controls.canvas)
|
|
384
446
|
return offset;
|
|
385
|
-
if (this._controls.canvas.clientWidth == 0 ||
|
|
447
|
+
if (this._controls.canvas.clientWidth == 0 ||
|
|
448
|
+
this._controls.canvas.clientHeight == 0)
|
|
386
449
|
return offset;
|
|
387
450
|
// perspective
|
|
388
451
|
gl_matrix_1.vec3.subtract(offset, this._controls.getPositionWithManualUpdates(), this._controls.getTargetWithManualUpdates());
|
|
389
452
|
if (this._controls.camera instanceof OrthographicCamera_1.OrthographicCamera) {
|
|
390
|
-
const orthographicCamera = this._controls.camera;
|
|
453
|
+
const orthographicCamera = (this._controls.camera);
|
|
391
454
|
const mat = gl_matrix_1.mat4.targetTo(gl_matrix_1.mat4.create(), orthographicCamera.position, orthographicCamera.target, orthographicCamera.up);
|
|
392
455
|
// // we use only clientHeight here so aspect ratio does not distort speed
|
|
393
456
|
// // left
|
|
394
457
|
const v1 = gl_matrix_1.vec3.fromValues(mat[0], mat[1], mat[2]);
|
|
395
|
-
const scalar1 = -(panDelta[0] *
|
|
458
|
+
const scalar1 = -(((panDelta[0] *
|
|
459
|
+
(orthographicCamera.right - orthographicCamera.left) *
|
|
460
|
+
0.5) /
|
|
461
|
+
((_a = this._controls.canvas) === null || _a === void 0 ? void 0 : _a.clientHeight)) /** orthographicCamera.zoom */);
|
|
396
462
|
gl_matrix_1.vec3.multiply(v1, v1, gl_matrix_1.vec3.fromValues(scalar1, scalar1, scalar1));
|
|
397
463
|
gl_matrix_1.vec3.add(panOffset, panOffset, v1);
|
|
398
464
|
// // up
|
|
399
465
|
const v2 = gl_matrix_1.vec3.fromValues(mat[4], mat[5], mat[6]);
|
|
400
|
-
const scalar2 = panDelta[1] *
|
|
466
|
+
const scalar2 = (panDelta[1] *
|
|
467
|
+
(orthographicCamera.right - orthographicCamera.left) *
|
|
468
|
+
0.5) /
|
|
469
|
+
((_b = this._controls.canvas) === null || _b === void 0 ? void 0 : _b.clientHeight); /** orthographicCamera.zoom */
|
|
401
470
|
gl_matrix_1.vec3.multiply(v2, v2, gl_matrix_1.vec3.fromValues(scalar2, scalar2, scalar2));
|
|
402
471
|
gl_matrix_1.vec3.add(panOffset, panOffset, v2);
|
|
403
472
|
}
|
|
404
473
|
else {
|
|
405
474
|
let targetDistance = gl_matrix_1.vec3.length(offset);
|
|
406
475
|
// half of the fov is center to top of screen
|
|
407
|
-
targetDistance *= Math.tan(((this._controls.camera.fov / 2) *
|
|
476
|
+
targetDistance *= Math.tan(((this._controls.camera.fov / 2) *
|
|
477
|
+
Math.PI) /
|
|
478
|
+
180.0);
|
|
408
479
|
// we use only clientHeight here so aspect ratio does not distort speed
|
|
409
480
|
// left
|
|
410
481
|
const mat = gl_matrix_1.mat4.targetTo(gl_matrix_1.mat4.create(), this._controls.camera.position, this._controls.camera.target, gl_matrix_1.vec3.fromValues(0, 0, 1));
|
|
411
482
|
const v1 = gl_matrix_1.vec3.fromValues(mat[0], mat[1], mat[2]);
|
|
412
|
-
const scalar1 = -(2 * panDelta[0] * targetDistance /
|
|
483
|
+
const scalar1 = -((2 * panDelta[0] * targetDistance) /
|
|
484
|
+
((_c = this._controls.canvas) === null || _c === void 0 ? void 0 : _c.clientHeight));
|
|
413
485
|
gl_matrix_1.vec3.multiply(v1, v1, gl_matrix_1.vec3.fromValues(scalar1, scalar1, scalar1));
|
|
414
486
|
gl_matrix_1.vec3.add(panOffset, panOffset, v1);
|
|
415
487
|
// // up
|
|
416
488
|
const v2 = gl_matrix_1.vec3.fromValues(mat[4], mat[5], mat[6]);
|
|
417
|
-
const scalar2 = 2 * panDelta[1] * targetDistance /
|
|
489
|
+
const scalar2 = (2 * panDelta[1] * targetDistance) /
|
|
490
|
+
((_d = this._controls.canvas) === null || _d === void 0 ? void 0 : _d.clientHeight);
|
|
418
491
|
gl_matrix_1.vec3.multiply(v2, v2, gl_matrix_1.vec3.fromValues(scalar2, scalar2, scalar2));
|
|
419
492
|
gl_matrix_1.vec3.add(panOffset, panOffset, v2);
|
|
420
493
|
}
|
|
@@ -427,7 +500,9 @@ class CameraControlsLogic {
|
|
|
427
500
|
const spherical = new viewer_shared_math_1.Spherical().fromVec3(offset);
|
|
428
501
|
spherical.theta += s.theta;
|
|
429
502
|
spherical.phi += s.phi;
|
|
430
|
-
const minAzimuthAngle = this._controls.rotationRestriction.minAzimuthAngle *
|
|
503
|
+
const minAzimuthAngle = this._controls.rotationRestriction.minAzimuthAngle *
|
|
504
|
+
(Math.PI / 180), maxAzimuthAngle = this._controls.rotationRestriction.maxAzimuthAngle *
|
|
505
|
+
(Math.PI / 180);
|
|
431
506
|
if (spherical.theta > Math.PI) {
|
|
432
507
|
spherical.theta -= 2 * Math.PI;
|
|
433
508
|
if (minAzimuthAngle > spherical.theta) {
|