@shapediver/viewer.rendering-engine.camera-engine 3.16.8 → 3.16.10

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.
Files changed (60) hide show
  1. package/dist/implementation/CameraEngine.d.ts +42 -42
  2. package/dist/implementation/CameraEngine.js +607 -607
  3. package/dist/implementation/CameraEngine.js.map +1 -1
  4. package/dist/implementation/camera/AbstractCamera.d.ts +90 -90
  5. package/dist/implementation/camera/AbstractCamera.js +354 -354
  6. package/dist/implementation/camera/AbstractCamera.js.map +1 -1
  7. package/dist/implementation/camera/OrthographicCamera.d.ts +37 -37
  8. package/dist/implementation/camera/OrthographicCamera.js +268 -268
  9. package/dist/implementation/camera/OrthographicCamera.js.map +1 -1
  10. package/dist/implementation/camera/PerspectiveCamera.d.ts +28 -28
  11. package/dist/implementation/camera/PerspectiveCamera.js +250 -250
  12. package/dist/implementation/camera/PerspectiveCamera.js.map +1 -1
  13. package/dist/implementation/controls/AbstractCameraControls.d.ts +217 -217
  14. package/dist/implementation/controls/AbstractCameraControls.js +635 -635
  15. package/dist/implementation/controls/AbstractCameraControls.js.map +1 -1
  16. package/dist/implementation/controls/CameraControlsEventDistribution.d.ts +39 -39
  17. package/dist/implementation/controls/CameraControlsEventDistribution.d.ts.map +1 -1
  18. package/dist/implementation/controls/CameraControlsEventDistribution.js +287 -287
  19. package/dist/implementation/controls/CameraControlsEventDistribution.js.map +1 -1
  20. package/dist/implementation/controls/CameraControlsLogic.d.ts +36 -36
  21. package/dist/implementation/controls/CameraControlsLogic.js +530 -530
  22. package/dist/implementation/controls/CameraControlsLogic.js.map +1 -1
  23. package/dist/implementation/controls/OrthographicCameraControls.d.ts +7 -7
  24. package/dist/implementation/controls/OrthographicCameraControls.js +34 -34
  25. package/dist/implementation/controls/PerspectiveCameraControls.d.ts +7 -7
  26. package/dist/implementation/controls/PerspectiveCameraControls.js +34 -34
  27. package/dist/implementation/interpolation/CameraInterpolationManager.d.ts +22 -22
  28. package/dist/implementation/interpolation/CameraInterpolationManager.js +165 -155
  29. package/dist/implementation/interpolation/CameraInterpolationManager.js.map +1 -1
  30. package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.d.ts +36 -36
  31. package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.js +57 -57
  32. package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.d.ts +26 -26
  33. package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.js +31 -31
  34. package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.d.ts +35 -35
  35. package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.js +45 -45
  36. package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.js.map +1 -1
  37. package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.d.ts +26 -26
  38. package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.js +31 -31
  39. package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.d.ts +32 -32
  40. package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.js +42 -42
  41. package/dist/index.d.ts +16 -16
  42. package/dist/index.js +18 -18
  43. package/dist/interfaces/ICameraEngine.d.ts +12 -12
  44. package/dist/interfaces/ICameraEngine.js +3 -3
  45. package/dist/interfaces/camera/ICamera.d.ts +47 -47
  46. package/dist/interfaces/camera/ICamera.js +2 -2
  47. package/dist/interfaces/camera/IOrthographicCamera.d.ts +8 -8
  48. package/dist/interfaces/camera/IOrthographicCamera.js +3 -3
  49. package/dist/interfaces/camera/IPerspectiveCamera.d.ts +7 -7
  50. package/dist/interfaces/camera/IPerspectiveCamera.js +2 -2
  51. package/dist/interfaces/controls/ICameraControls.d.ts +105 -105
  52. package/dist/interfaces/controls/ICameraControls.d.ts.map +1 -1
  53. package/dist/interfaces/controls/ICameraControls.js +3 -3
  54. package/dist/interfaces/controls/ICameraControlsEventDistribution.d.ts +6 -6
  55. package/dist/interfaces/controls/ICameraControlsEventDistribution.js +2 -2
  56. package/dist/interfaces/controls/ICameraControlsLogic.d.ts +14 -14
  57. package/dist/interfaces/controls/ICameraControlsLogic.js +2 -2
  58. package/dist/interfaces/interpolation/ICameraInterpolation.d.ts +11 -11
  59. package/dist/interfaces/interpolation/ICameraInterpolation.js +2 -2
  60. package/package.json +8 -8
@@ -1,636 +1,636 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractCameraControls = void 0;
4
- const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
5
- const gl_matrix_1 = require("gl-matrix");
6
- const CameraInterpolationManager_1 = require("../interpolation/CameraInterpolationManager");
7
- class AbstractCameraControls {
8
- // #endregion Properties (38)
9
- // #region Constructors (1)
10
- constructor(_camera, _enabled) {
11
- this._camera = _camera;
12
- this._enabled = _enabled;
13
- this._converter = viewer_shared_services_1.Converter.instance;
14
- this._eventEngine = viewer_shared_services_1.EventEngine.instance;
15
- this._autoRotationSpeed = 0;
16
- this._cubePositionRestriction = {
17
- min: gl_matrix_1.vec3.fromValues(-Infinity, -Infinity, -Infinity),
18
- max: gl_matrix_1.vec3.fromValues(Infinity, Infinity, Infinity),
19
- };
20
- this._cubeTargetRestriction = {
21
- min: gl_matrix_1.vec3.fromValues(-Infinity, -Infinity, -Infinity),
22
- max: gl_matrix_1.vec3.fromValues(Infinity, Infinity, Infinity),
23
- };
24
- this._damping = 0.1;
25
- this._enableAutoRotation = false;
26
- this._enableAzimuthRotation = true;
27
- this._enableKeyPan = false;
28
- this._enableObjectControls = false;
29
- this._enablePan = true;
30
- this._enablePolarRotation = true;
31
- this._enableRotation = true;
32
- this._enableTurntableControls = false;
33
- this._enableZoom = true;
34
- this._input = {
35
- keys: { up: 38, down: 40, left: 37, right: 39 },
36
- mouse: { rotate: 0, zoom: 1, pan: 2 },
37
- touch: { rotate: 1, zoom: 2, pan: 2 },
38
- };
39
- this._keyPanSpeed = 0.5;
40
- this._manualInteraction = false;
41
- this._movementSmoothness = 0.5;
42
- this._moving = false;
43
- this._movingDuration = 0;
44
- this._nonmanualInteraction = false;
45
- this._objectControlsCenter = gl_matrix_1.vec3.create();
46
- this._panSpeed = 0.5;
47
- this._position = gl_matrix_1.vec3.create();
48
- this._rotationRestriction = {
49
- minPolarAngle: 0,
50
- maxPolarAngle: 180,
51
- minAzimuthAngle: -Infinity,
52
- maxAzimuthAngle: Infinity,
53
- };
54
- this._rotationSpeed = 0.5;
55
- this._sceneRotation = gl_matrix_1.vec2.create();
56
- this._spherePositionRestriction = {
57
- center: gl_matrix_1.vec3.create(),
58
- radius: Infinity,
59
- };
60
- this._sphereTargetRestriction = {
61
- center: gl_matrix_1.vec3.create(),
62
- radius: Infinity,
63
- };
64
- this._target = gl_matrix_1.vec3.create();
65
- this._turntableCenter = gl_matrix_1.vec3.create();
66
- this._zoomRestriction = {
67
- minDistance: 0,
68
- maxDistance: Infinity,
69
- };
70
- this._zoomSpeed = 0.5;
71
- this._cameraInterpolationManager = new CameraInterpolationManager_1.CameraInterpolationManager(this._camera, this);
72
- this._manualInteractionTransformations = {
73
- position: [],
74
- target: [],
75
- sceneRotation: [],
76
- };
77
- this._nonmanualInteractionTransformations = {
78
- position: [],
79
- target: [],
80
- sceneRotation: [],
81
- };
82
- }
83
- // #endregion Constructors (1)
84
- // #region Public Getters And Setters (59)
85
- get autoRotationSpeed() {
86
- return this._autoRotationSpeed;
87
- }
88
- set autoRotationSpeed(value) {
89
- this._autoRotationSpeed = value;
90
- }
91
- get camera() {
92
- return this._camera;
93
- }
94
- set camera(value) {
95
- this._camera = value;
96
- }
97
- get cameraControlsEventDistribution() {
98
- return this._cameraControlsEventDistribution;
99
- }
100
- get canvas() {
101
- return this._canvas;
102
- }
103
- set canvas(value) {
104
- this._canvas = value;
105
- }
106
- get cubePositionRestriction() {
107
- return this._cubePositionRestriction;
108
- }
109
- set cubePositionRestriction(value) {
110
- this._cubePositionRestriction = value;
111
- }
112
- get cubeTargetRestriction() {
113
- return this._cubeTargetRestriction;
114
- }
115
- set cubeTargetRestriction(value) {
116
- this._cubeTargetRestriction = value;
117
- }
118
- get damping() {
119
- return this._damping;
120
- }
121
- set damping(value) {
122
- this._damping = value;
123
- }
124
- get enableAutoRotation() {
125
- return this._enableAutoRotation;
126
- }
127
- set enableAutoRotation(value) {
128
- this._enableAutoRotation = value;
129
- }
130
- get enableAzimuthRotation() {
131
- return this._enableAzimuthRotation;
132
- }
133
- set enableAzimuthRotation(value) {
134
- this._enableAzimuthRotation = value;
135
- }
136
- get enableKeyPan() {
137
- return this._enableKeyPan;
138
- }
139
- set enableKeyPan(value) {
140
- this._enableKeyPan = value;
141
- }
142
- get enableObjectControls() {
143
- return this._enableObjectControls;
144
- }
145
- set enableObjectControls(value) {
146
- this._enableObjectControls = value;
147
- }
148
- get enablePan() {
149
- return this._enablePan;
150
- }
151
- set enablePan(value) {
152
- this._enablePan = value;
153
- }
154
- get enablePolarRotation() {
155
- return this._enablePolarRotation;
156
- }
157
- set enablePolarRotation(value) {
158
- this._enablePolarRotation = value;
159
- }
160
- get enableRotation() {
161
- return this._enableRotation;
162
- }
163
- set enableRotation(value) {
164
- this._enableRotation = value;
165
- }
166
- get enableTurntableControls() {
167
- return this._enableTurntableControls;
168
- }
169
- set enableTurntableControls(value) {
170
- this._enableTurntableControls = value;
171
- }
172
- get enableZoom() {
173
- return this._enableZoom;
174
- }
175
- set enableZoom(value) {
176
- this._enableZoom = value;
177
- }
178
- get enabled() {
179
- return this._enabled;
180
- }
181
- set enabled(value) {
182
- if (!value) {
183
- this._manualInteraction = false;
184
- this._manualInteractionTransformations = {
185
- position: [],
186
- target: [],
187
- sceneRotation: [],
188
- };
189
- this._nonmanualInteraction = false;
190
- this._nonmanualInteractionTransformations = {
191
- position: [],
192
- target: [],
193
- sceneRotation: [],
194
- };
195
- this._cameraControlsEventDistribution.reset();
196
- this._cameraLogic.reset();
197
- }
198
- this._enabled = value;
199
- }
200
- get input() {
201
- return this._input;
202
- }
203
- set input(value) {
204
- this._input = value;
205
- }
206
- get keyPanSpeed() {
207
- return this._keyPanSpeed;
208
- }
209
- set keyPanSpeed(value) {
210
- this._keyPanSpeed = value;
211
- }
212
- get movementSmoothness() {
213
- return this._movementSmoothness;
214
- }
215
- set movementSmoothness(value) {
216
- this._movementSmoothness = value;
217
- }
218
- get objectControlsCenter() {
219
- return this._objectControlsCenter;
220
- }
221
- set objectControlsCenter(value) {
222
- this._objectControlsCenter = value;
223
- }
224
- get panSpeed() {
225
- return this._panSpeed;
226
- }
227
- set panSpeed(value) {
228
- this._panSpeed = value;
229
- }
230
- get position() {
231
- return this._position;
232
- }
233
- set position(value) {
234
- this._position = value;
235
- }
236
- get rotationRestriction() {
237
- return this._rotationRestriction;
238
- }
239
- set rotationRestriction(value) {
240
- this._rotationRestriction = value;
241
- }
242
- get rotationSpeed() {
243
- return this._rotationSpeed;
244
- }
245
- set rotationSpeed(value) {
246
- this._rotationSpeed = value;
247
- }
248
- get sceneRotation() {
249
- return this._sceneRotation;
250
- }
251
- set sceneRotation(value) {
252
- this._sceneRotation = value;
253
- }
254
- get spherePositionRestriction() {
255
- return this._spherePositionRestriction;
256
- }
257
- set spherePositionRestriction(value) {
258
- this._spherePositionRestriction = value;
259
- }
260
- get sphereTargetRestriction() {
261
- return this._sphereTargetRestriction;
262
- }
263
- set sphereTargetRestriction(value) {
264
- this._sphereTargetRestriction = value;
265
- }
266
- get target() {
267
- return this._target;
268
- }
269
- set target(value) {
270
- this._target = value;
271
- }
272
- get turntableCenter() {
273
- return this._turntableCenter;
274
- }
275
- set turntableCenter(value) {
276
- this._turntableCenter = value;
277
- }
278
- get zoomRestriction() {
279
- return this._zoomRestriction;
280
- }
281
- set zoomRestriction(value) {
282
- this._zoomRestriction = value;
283
- }
284
- get zoomSpeed() {
285
- return this._zoomSpeed;
286
- }
287
- set zoomSpeed(value) {
288
- this._zoomSpeed = value;
289
- }
290
- // #endregion Public Getters And Setters (59)
291
- // #region Public Methods (16)
292
- animate(path, options) {
293
- if (options && options.duration === 0) {
294
- this._position = path[path.length - 1].position;
295
- this._target = path[path.length - 1].target;
296
- return new Promise((resolve) => resolve(true));
297
- }
298
- this._manualInteraction = false;
299
- this._manualInteractionTransformations = {
300
- position: [],
301
- target: [],
302
- sceneRotation: [],
303
- };
304
- return this._cameraInterpolationManager.interpolate(path, options);
305
- }
306
- applyPositionMatrix(matrix, manualInteraction) {
307
- if (this._manualInteraction || manualInteraction) {
308
- this._manualInteraction = true;
309
- this._manualInteractionTransformations.position.push({ matrix });
310
- }
311
- else {
312
- this._nonmanualInteraction = true;
313
- this._nonmanualInteractionTransformations.position.push({ matrix });
314
- }
315
- }
316
- applyPositionVector(vector, manualInteraction) {
317
- if (this._manualInteraction || manualInteraction) {
318
- this._manualInteraction = true;
319
- this._manualInteractionTransformations.position.push({ vector });
320
- }
321
- else {
322
- this._nonmanualInteraction = true;
323
- this._nonmanualInteractionTransformations.position.push({ vector });
324
- }
325
- }
326
- applyRotation(vector, manualInteraction) {
327
- if (this._manualInteraction || manualInteraction) {
328
- this._manualInteraction = true;
329
- this._manualInteractionTransformations.sceneRotation.push({
330
- theta: vector[0],
331
- phi: vector[1],
332
- });
333
- }
334
- else {
335
- this._nonmanualInteraction = true;
336
- this._nonmanualInteractionTransformations.sceneRotation.push({
337
- theta: vector[0],
338
- phi: vector[1],
339
- });
340
- }
341
- }
342
- applySettings(settingsEngine) {
343
- const cameraSetting = settingsEngine.camera.cameras[this.camera.id];
344
- if (!cameraSetting)
345
- return;
346
- this.reset();
347
- const controlsSettings = (cameraSetting.controls);
348
- this.autoRotationSpeed = controlsSettings.autoRotationSpeed;
349
- this.damping = controlsSettings.damping;
350
- this.enableAutoRotation = controlsSettings.enableAutoRotation;
351
- this.enableKeyPan = controlsSettings.enableKeyPan;
352
- this.enablePan = controlsSettings.enablePan;
353
- this.enableRotation = controlsSettings.enableRotation;
354
- this.enableZoom = controlsSettings.enableZoom;
355
- // this.input = controlsSettings.input;
356
- this.keyPanSpeed = controlsSettings.keyPanSpeed;
357
- this.movementSmoothness = controlsSettings.movementSmoothness;
358
- this.rotationSpeed = controlsSettings.rotationSpeed;
359
- this.panSpeed = controlsSettings.panSpeed;
360
- this.zoomSpeed = controlsSettings.zoomSpeed;
361
- this.enableAzimuthRotation = controlsSettings.enableAzimuthRotation;
362
- this.enablePolarRotation = controlsSettings.enablePolarRotation;
363
- this.enableTurntableControls = controlsSettings.enableTurntableControls;
364
- this.enableObjectControls = controlsSettings.enableObjectControls;
365
- this.turntableCenter = this._converter.toVec3(controlsSettings.turntableCenter);
366
- this.objectControlsCenter = this._converter.toVec3(controlsSettings.objectControlsCenter);
367
- if (controlsSettings.restrictions.position.cube.min.x === null)
368
- controlsSettings.restrictions.position.cube.min.x = -Infinity;
369
- if (controlsSettings.restrictions.position.cube.min.y === null)
370
- controlsSettings.restrictions.position.cube.min.y = -Infinity;
371
- if (controlsSettings.restrictions.position.cube.min.z === null)
372
- controlsSettings.restrictions.position.cube.min.z = -Infinity;
373
- if (controlsSettings.restrictions.position.cube.max.x === null)
374
- controlsSettings.restrictions.position.cube.max.x = Infinity;
375
- if (controlsSettings.restrictions.position.cube.max.y === null)
376
- controlsSettings.restrictions.position.cube.max.y = Infinity;
377
- if (controlsSettings.restrictions.position.cube.max.z === null)
378
- controlsSettings.restrictions.position.cube.max.z = Infinity;
379
- if (controlsSettings.restrictions.position.sphere.radius === null)
380
- controlsSettings.restrictions.position.sphere.radius = Infinity;
381
- if (controlsSettings.restrictions.target.cube.min.x === null)
382
- controlsSettings.restrictions.target.cube.min.x = -Infinity;
383
- if (controlsSettings.restrictions.target.cube.min.y === null)
384
- controlsSettings.restrictions.target.cube.min.y = -Infinity;
385
- if (controlsSettings.restrictions.target.cube.min.z === null)
386
- controlsSettings.restrictions.target.cube.min.z = -Infinity;
387
- if (controlsSettings.restrictions.target.cube.max.x === null)
388
- controlsSettings.restrictions.target.cube.max.x = Infinity;
389
- if (controlsSettings.restrictions.target.cube.max.y === null)
390
- controlsSettings.restrictions.target.cube.max.y = Infinity;
391
- if (controlsSettings.restrictions.target.cube.max.z === null)
392
- controlsSettings.restrictions.target.cube.max.z = Infinity;
393
- if (controlsSettings.restrictions.target.sphere.radius === null)
394
- controlsSettings.restrictions.target.sphere.radius = Infinity;
395
- if (controlsSettings.restrictions.rotation.minAzimuthAngle === null)
396
- controlsSettings.restrictions.rotation.minAzimuthAngle = -Infinity;
397
- if (controlsSettings.restrictions.rotation.maxAzimuthAngle === null)
398
- controlsSettings.restrictions.rotation.maxAzimuthAngle = Infinity;
399
- if (controlsSettings.restrictions.zoom.maxDistance === null)
400
- controlsSettings.restrictions.zoom.maxDistance = Infinity;
401
- this.cubePositionRestriction = {
402
- min: this._converter.toVec3(controlsSettings.restrictions.position.cube.min),
403
- max: this._converter.toVec3(controlsSettings.restrictions.position.cube.max),
404
- };
405
- this.spherePositionRestriction = {
406
- center: this._converter.toVec3(controlsSettings.restrictions.position.sphere.center),
407
- radius: controlsSettings.restrictions.position.sphere.radius,
408
- };
409
- this.cubeTargetRestriction = {
410
- min: this._converter.toVec3(controlsSettings.restrictions.target.cube.min),
411
- max: this._converter.toVec3(controlsSettings.restrictions.target.cube.max),
412
- };
413
- this.sphereTargetRestriction = {
414
- center: this._converter.toVec3(controlsSettings.restrictions.target.sphere.center),
415
- radius: controlsSettings.restrictions.target.sphere.radius,
416
- };
417
- this.rotationRestriction = controlsSettings.restrictions.rotation;
418
- this.zoomRestriction = controlsSettings.restrictions.zoom;
419
- }
420
- applyTargetMatrix(matrix, manualInteraction) {
421
- if (this._manualInteraction || manualInteraction) {
422
- this._manualInteraction = true;
423
- this._manualInteractionTransformations.target.push({ matrix });
424
- }
425
- else {
426
- this._nonmanualInteraction = true;
427
- this._nonmanualInteractionTransformations.target.push({ matrix });
428
- }
429
- }
430
- applyTargetVector(vector, manualInteraction) {
431
- if (this._manualInteraction || manualInteraction) {
432
- this._manualInteraction = true;
433
- this._manualInteractionTransformations.target.push({ vector });
434
- }
435
- else {
436
- this._nonmanualInteraction = true;
437
- this._nonmanualInteractionTransformations.target.push({ vector });
438
- }
439
- }
440
- applyUpMatrix(matrix, manualInteraction) {
441
- // https://shapediver.atlassian.net/browse/SS-2949
442
- throw new Error("Method not implemented.");
443
- }
444
- assignViewer(viewportId, canvas) {
445
- this._canvas = canvas;
446
- this._viewportId = viewportId;
447
- }
448
- getPositionWithManualUpdates() {
449
- let position = gl_matrix_1.vec3.clone(this._position);
450
- if (this._manualInteraction) {
451
- for (let i = this._manualInteractionTransformations.position.length - 1; i >= 0; i--) {
452
- if (this._manualInteractionTransformations.position[i].matrix) {
453
- position = gl_matrix_1.vec3.transformMat4(position, position, this._manualInteractionTransformations.position[i]
454
- .matrix);
455
- }
456
- else {
457
- position = gl_matrix_1.vec3.add(position, position, this._manualInteractionTransformations.position[i]
458
- .vector);
459
- }
460
- }
461
- }
462
- return position;
463
- }
464
- getPositionWithUpdates() {
465
- return this.getPosition();
466
- }
467
- getTargetWithManualUpdates() {
468
- let target = gl_matrix_1.vec3.clone(this._target);
469
- if (this._manualInteraction) {
470
- for (let i = this._manualInteractionTransformations.target.length - 1; i >= 0; i--) {
471
- if (this._manualInteractionTransformations.target[i].matrix) {
472
- target = gl_matrix_1.vec3.transformMat4(target, target, this._manualInteractionTransformations.target[i]
473
- .matrix);
474
- }
475
- else {
476
- target = gl_matrix_1.vec3.add(target, target, this._manualInteractionTransformations.target[i]
477
- .vector);
478
- }
479
- }
480
- }
481
- return target;
482
- }
483
- getTargetWithUpdates() {
484
- return this.getTarget();
485
- }
486
- isMoving() {
487
- return this._manualInteraction || this._nonmanualInteraction;
488
- }
489
- isWithinRestrictions(position, target) {
490
- return this._cameraLogic.isWithinRestrictions(position, target);
491
- }
492
- reset() {
493
- this._cameraControlsEventDistribution.reset();
494
- this._cameraLogic.reset();
495
- }
496
- update(time) {
497
- if (!this._enabled)
498
- return {
499
- position: gl_matrix_1.vec3.clone(this._position),
500
- target: gl_matrix_1.vec3.clone(this._target),
501
- sceneRotation: gl_matrix_1.vec2.clone(this._sceneRotation),
502
- };
503
- // reset all values
504
- if (this._manualInteraction === true &&
505
- this._cameraInterpolationManager.active())
506
- this._cameraInterpolationManager.stop();
507
- const { position, target, sceneRotation } = this._cameraLogic.restrict(this.getPosition(), this.getTarget(), this.getSceneRotation());
508
- this._position = gl_matrix_1.vec3.clone(position);
509
- this._target = gl_matrix_1.vec3.clone(target);
510
- this._sceneRotation = sceneRotation
511
- ? gl_matrix_1.vec2.clone(sceneRotation)
512
- : gl_matrix_1.vec2.create();
513
- this._manualInteraction = false;
514
- this._manualInteractionTransformations = {
515
- position: [],
516
- target: [],
517
- sceneRotation: [],
518
- };
519
- this._nonmanualInteraction = this._cameraInterpolationManager.active();
520
- this._nonmanualInteractionTransformations = {
521
- position: [],
522
- target: [],
523
- sceneRotation: [],
524
- };
525
- this._cameraLogic.update(time, this._nonmanualInteraction);
526
- const oldMovement = this._moving;
527
- const cameraDefinition = {
528
- position: gl_matrix_1.vec3.clone(this._position),
529
- target: gl_matrix_1.vec3.clone(this._target),
530
- sceneRotation: gl_matrix_1.vec2.clone(this._sceneRotation),
531
- };
532
- this._movingDuration += time;
533
- this._moving = this._manualInteraction || this._nonmanualInteraction;
534
- switch (true) {
535
- case oldMovement !== this._moving && this._moving === true:
536
- this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.CAMERA.CAMERA_START, {
537
- viewportId: this._viewportId,
538
- cameraId: this.camera.id,
539
- });
540
- break;
541
- case oldMovement !== this._moving && this._moving === false:
542
- this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.CAMERA.CAMERA_END, {
543
- viewportId: this._viewportId,
544
- cameraId: this.camera.id,
545
- });
546
- break;
547
- default:
548
- this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.CAMERA.CAMERA_MOVE, {
549
- viewportId: this._viewportId,
550
- cameraId: this.camera.id,
551
- });
552
- }
553
- if (!this._moving)
554
- this._movingDuration = 0;
555
- return cameraDefinition;
556
- }
557
- // #endregion Public Methods (16)
558
- // #region Private Methods (3)
559
- getPosition() {
560
- let position = gl_matrix_1.vec3.clone(this._position);
561
- if (this._manualInteraction) {
562
- for (let i = this._manualInteractionTransformations.position.length - 1; i >= 0; i--) {
563
- if (this._manualInteractionTransformations.position[i].matrix) {
564
- position = gl_matrix_1.vec3.transformMat4(position, position, this._manualInteractionTransformations.position[i]
565
- .matrix);
566
- }
567
- else {
568
- position = gl_matrix_1.vec3.add(position, position, this._manualInteractionTransformations.position[i]
569
- .vector);
570
- }
571
- }
572
- }
573
- else if (this._nonmanualInteraction) {
574
- for (let i = this._nonmanualInteractionTransformations.position.length -
575
- 1; i >= 0; i--) {
576
- if (this._nonmanualInteractionTransformations.position[i].matrix) {
577
- position = gl_matrix_1.vec3.transformMat4(position, position, this._nonmanualInteractionTransformations.position[i]
578
- .matrix);
579
- }
580
- else {
581
- position = gl_matrix_1.vec3.add(position, position, this._nonmanualInteractionTransformations.position[i]
582
- .vector);
583
- }
584
- }
585
- }
586
- return position;
587
- }
588
- getSceneRotation() {
589
- let sceneRotation = gl_matrix_1.vec2.clone(this._sceneRotation);
590
- if (this._manualInteraction) {
591
- for (let i = this._manualInteractionTransformations.sceneRotation
592
- .length - 1; i >= 0; i--) {
593
- sceneRotation = gl_matrix_1.vec2.add(sceneRotation, sceneRotation, gl_matrix_1.vec2.fromValues(this._manualInteractionTransformations.sceneRotation[i]
594
- .theta, this._manualInteractionTransformations.sceneRotation[i]
595
- .phi));
596
- }
597
- }
598
- else if (this._nonmanualInteraction) {
599
- for (let i = this._nonmanualInteractionTransformations.sceneRotation
600
- .length - 1; i >= 0; i--) {
601
- sceneRotation = gl_matrix_1.vec2.add(sceneRotation, sceneRotation, gl_matrix_1.vec2.fromValues(this._nonmanualInteractionTransformations.sceneRotation[i].theta, this._nonmanualInteractionTransformations.sceneRotation[i].phi));
602
- }
603
- }
604
- return sceneRotation;
605
- }
606
- getTarget() {
607
- let target = gl_matrix_1.vec3.clone(this._target);
608
- if (this._manualInteraction) {
609
- for (let i = this._manualInteractionTransformations.target.length - 1; i >= 0; i--) {
610
- if (this._manualInteractionTransformations.target[i].matrix) {
611
- target = gl_matrix_1.vec3.transformMat4(target, target, this._manualInteractionTransformations.target[i]
612
- .matrix);
613
- }
614
- else {
615
- target = gl_matrix_1.vec3.add(target, target, this._manualInteractionTransformations.target[i]
616
- .vector);
617
- }
618
- }
619
- }
620
- else if (this._nonmanualInteraction) {
621
- for (let i = this._nonmanualInteractionTransformations.target.length - 1; i >= 0; i--) {
622
- if (this._nonmanualInteractionTransformations.target[i].matrix) {
623
- target = gl_matrix_1.vec3.transformMat4(target, target, this._nonmanualInteractionTransformations.target[i]
624
- .matrix);
625
- }
626
- else {
627
- target = gl_matrix_1.vec3.add(target, target, this._nonmanualInteractionTransformations.target[i]
628
- .vector);
629
- }
630
- }
631
- }
632
- return target;
633
- }
634
- }
635
- exports.AbstractCameraControls = AbstractCameraControls;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbstractCameraControls = void 0;
4
+ const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
5
+ const gl_matrix_1 = require("gl-matrix");
6
+ const CameraInterpolationManager_1 = require("../interpolation/CameraInterpolationManager");
7
+ class AbstractCameraControls {
8
+ // #endregion Properties (38)
9
+ // #region Constructors (1)
10
+ constructor(_camera, _enabled) {
11
+ this._camera = _camera;
12
+ this._enabled = _enabled;
13
+ this._converter = viewer_shared_services_1.Converter.instance;
14
+ this._eventEngine = viewer_shared_services_1.EventEngine.instance;
15
+ this._autoRotationSpeed = 0;
16
+ this._cubePositionRestriction = {
17
+ min: gl_matrix_1.vec3.fromValues(-Infinity, -Infinity, -Infinity),
18
+ max: gl_matrix_1.vec3.fromValues(Infinity, Infinity, Infinity),
19
+ };
20
+ this._cubeTargetRestriction = {
21
+ min: gl_matrix_1.vec3.fromValues(-Infinity, -Infinity, -Infinity),
22
+ max: gl_matrix_1.vec3.fromValues(Infinity, Infinity, Infinity),
23
+ };
24
+ this._damping = 0.1;
25
+ this._enableAutoRotation = false;
26
+ this._enableAzimuthRotation = true;
27
+ this._enableKeyPan = false;
28
+ this._enableObjectControls = false;
29
+ this._enablePan = true;
30
+ this._enablePolarRotation = true;
31
+ this._enableRotation = true;
32
+ this._enableTurntableControls = false;
33
+ this._enableZoom = true;
34
+ this._input = {
35
+ keys: { up: 38, down: 40, left: 37, right: 39 },
36
+ mouse: { rotate: 0, zoom: 1, pan: 2 },
37
+ touch: { rotate: 1, zoom: 2, pan: 2 },
38
+ };
39
+ this._keyPanSpeed = 0.5;
40
+ this._manualInteraction = false;
41
+ this._movementSmoothness = 0.5;
42
+ this._moving = false;
43
+ this._movingDuration = 0;
44
+ this._nonmanualInteraction = false;
45
+ this._objectControlsCenter = gl_matrix_1.vec3.create();
46
+ this._panSpeed = 0.5;
47
+ this._position = gl_matrix_1.vec3.create();
48
+ this._rotationRestriction = {
49
+ minPolarAngle: 0,
50
+ maxPolarAngle: 180,
51
+ minAzimuthAngle: -Infinity,
52
+ maxAzimuthAngle: Infinity,
53
+ };
54
+ this._rotationSpeed = 0.5;
55
+ this._sceneRotation = gl_matrix_1.vec2.create();
56
+ this._spherePositionRestriction = {
57
+ center: gl_matrix_1.vec3.create(),
58
+ radius: Infinity,
59
+ };
60
+ this._sphereTargetRestriction = {
61
+ center: gl_matrix_1.vec3.create(),
62
+ radius: Infinity,
63
+ };
64
+ this._target = gl_matrix_1.vec3.create();
65
+ this._turntableCenter = gl_matrix_1.vec3.create();
66
+ this._zoomRestriction = {
67
+ minDistance: 0,
68
+ maxDistance: Infinity,
69
+ };
70
+ this._zoomSpeed = 0.5;
71
+ this._cameraInterpolationManager = new CameraInterpolationManager_1.CameraInterpolationManager(this._camera, this);
72
+ this._manualInteractionTransformations = {
73
+ position: [],
74
+ target: [],
75
+ sceneRotation: [],
76
+ };
77
+ this._nonmanualInteractionTransformations = {
78
+ position: [],
79
+ target: [],
80
+ sceneRotation: [],
81
+ };
82
+ }
83
+ // #endregion Constructors (1)
84
+ // #region Public Getters And Setters (59)
85
+ get autoRotationSpeed() {
86
+ return this._autoRotationSpeed;
87
+ }
88
+ set autoRotationSpeed(value) {
89
+ this._autoRotationSpeed = value;
90
+ }
91
+ get camera() {
92
+ return this._camera;
93
+ }
94
+ set camera(value) {
95
+ this._camera = value;
96
+ }
97
+ get cameraControlsEventDistribution() {
98
+ return this._cameraControlsEventDistribution;
99
+ }
100
+ get canvas() {
101
+ return this._canvas;
102
+ }
103
+ set canvas(value) {
104
+ this._canvas = value;
105
+ }
106
+ get cubePositionRestriction() {
107
+ return this._cubePositionRestriction;
108
+ }
109
+ set cubePositionRestriction(value) {
110
+ this._cubePositionRestriction = value;
111
+ }
112
+ get cubeTargetRestriction() {
113
+ return this._cubeTargetRestriction;
114
+ }
115
+ set cubeTargetRestriction(value) {
116
+ this._cubeTargetRestriction = value;
117
+ }
118
+ get damping() {
119
+ return this._damping;
120
+ }
121
+ set damping(value) {
122
+ this._damping = value;
123
+ }
124
+ get enableAutoRotation() {
125
+ return this._enableAutoRotation;
126
+ }
127
+ set enableAutoRotation(value) {
128
+ this._enableAutoRotation = value;
129
+ }
130
+ get enableAzimuthRotation() {
131
+ return this._enableAzimuthRotation;
132
+ }
133
+ set enableAzimuthRotation(value) {
134
+ this._enableAzimuthRotation = value;
135
+ }
136
+ get enableKeyPan() {
137
+ return this._enableKeyPan;
138
+ }
139
+ set enableKeyPan(value) {
140
+ this._enableKeyPan = value;
141
+ }
142
+ get enableObjectControls() {
143
+ return this._enableObjectControls;
144
+ }
145
+ set enableObjectControls(value) {
146
+ this._enableObjectControls = value;
147
+ }
148
+ get enablePan() {
149
+ return this._enablePan;
150
+ }
151
+ set enablePan(value) {
152
+ this._enablePan = value;
153
+ }
154
+ get enablePolarRotation() {
155
+ return this._enablePolarRotation;
156
+ }
157
+ set enablePolarRotation(value) {
158
+ this._enablePolarRotation = value;
159
+ }
160
+ get enableRotation() {
161
+ return this._enableRotation;
162
+ }
163
+ set enableRotation(value) {
164
+ this._enableRotation = value;
165
+ }
166
+ get enableTurntableControls() {
167
+ return this._enableTurntableControls;
168
+ }
169
+ set enableTurntableControls(value) {
170
+ this._enableTurntableControls = value;
171
+ }
172
+ get enableZoom() {
173
+ return this._enableZoom;
174
+ }
175
+ set enableZoom(value) {
176
+ this._enableZoom = value;
177
+ }
178
+ get enabled() {
179
+ return this._enabled;
180
+ }
181
+ set enabled(value) {
182
+ if (!value) {
183
+ this._manualInteraction = false;
184
+ this._manualInteractionTransformations = {
185
+ position: [],
186
+ target: [],
187
+ sceneRotation: [],
188
+ };
189
+ this._nonmanualInteraction = false;
190
+ this._nonmanualInteractionTransformations = {
191
+ position: [],
192
+ target: [],
193
+ sceneRotation: [],
194
+ };
195
+ this._cameraControlsEventDistribution.reset();
196
+ this._cameraLogic.reset();
197
+ }
198
+ this._enabled = value;
199
+ }
200
+ get input() {
201
+ return this._input;
202
+ }
203
+ set input(value) {
204
+ this._input = value;
205
+ }
206
+ get keyPanSpeed() {
207
+ return this._keyPanSpeed;
208
+ }
209
+ set keyPanSpeed(value) {
210
+ this._keyPanSpeed = value;
211
+ }
212
+ get movementSmoothness() {
213
+ return this._movementSmoothness;
214
+ }
215
+ set movementSmoothness(value) {
216
+ this._movementSmoothness = value;
217
+ }
218
+ get objectControlsCenter() {
219
+ return this._objectControlsCenter;
220
+ }
221
+ set objectControlsCenter(value) {
222
+ this._objectControlsCenter = value;
223
+ }
224
+ get panSpeed() {
225
+ return this._panSpeed;
226
+ }
227
+ set panSpeed(value) {
228
+ this._panSpeed = value;
229
+ }
230
+ get position() {
231
+ return this._position;
232
+ }
233
+ set position(value) {
234
+ this._position = value;
235
+ }
236
+ get rotationRestriction() {
237
+ return this._rotationRestriction;
238
+ }
239
+ set rotationRestriction(value) {
240
+ this._rotationRestriction = value;
241
+ }
242
+ get rotationSpeed() {
243
+ return this._rotationSpeed;
244
+ }
245
+ set rotationSpeed(value) {
246
+ this._rotationSpeed = value;
247
+ }
248
+ get sceneRotation() {
249
+ return this._sceneRotation;
250
+ }
251
+ set sceneRotation(value) {
252
+ this._sceneRotation = value;
253
+ }
254
+ get spherePositionRestriction() {
255
+ return this._spherePositionRestriction;
256
+ }
257
+ set spherePositionRestriction(value) {
258
+ this._spherePositionRestriction = value;
259
+ }
260
+ get sphereTargetRestriction() {
261
+ return this._sphereTargetRestriction;
262
+ }
263
+ set sphereTargetRestriction(value) {
264
+ this._sphereTargetRestriction = value;
265
+ }
266
+ get target() {
267
+ return this._target;
268
+ }
269
+ set target(value) {
270
+ this._target = value;
271
+ }
272
+ get turntableCenter() {
273
+ return this._turntableCenter;
274
+ }
275
+ set turntableCenter(value) {
276
+ this._turntableCenter = value;
277
+ }
278
+ get zoomRestriction() {
279
+ return this._zoomRestriction;
280
+ }
281
+ set zoomRestriction(value) {
282
+ this._zoomRestriction = value;
283
+ }
284
+ get zoomSpeed() {
285
+ return this._zoomSpeed;
286
+ }
287
+ set zoomSpeed(value) {
288
+ this._zoomSpeed = value;
289
+ }
290
+ // #endregion Public Getters And Setters (59)
291
+ // #region Public Methods (16)
292
+ animate(path, options) {
293
+ if (options && options.duration === 0) {
294
+ this._position = path[path.length - 1].position;
295
+ this._target = path[path.length - 1].target;
296
+ return new Promise((resolve) => resolve(true));
297
+ }
298
+ this._manualInteraction = false;
299
+ this._manualInteractionTransformations = {
300
+ position: [],
301
+ target: [],
302
+ sceneRotation: [],
303
+ };
304
+ return this._cameraInterpolationManager.interpolate(path, options);
305
+ }
306
+ applyPositionMatrix(matrix, manualInteraction) {
307
+ if (this._manualInteraction || manualInteraction) {
308
+ this._manualInteraction = true;
309
+ this._manualInteractionTransformations.position.push({ matrix });
310
+ }
311
+ else {
312
+ this._nonmanualInteraction = true;
313
+ this._nonmanualInteractionTransformations.position.push({ matrix });
314
+ }
315
+ }
316
+ applyPositionVector(vector, manualInteraction) {
317
+ if (this._manualInteraction || manualInteraction) {
318
+ this._manualInteraction = true;
319
+ this._manualInteractionTransformations.position.push({ vector });
320
+ }
321
+ else {
322
+ this._nonmanualInteraction = true;
323
+ this._nonmanualInteractionTransformations.position.push({ vector });
324
+ }
325
+ }
326
+ applyRotation(vector, manualInteraction) {
327
+ if (this._manualInteraction || manualInteraction) {
328
+ this._manualInteraction = true;
329
+ this._manualInteractionTransformations.sceneRotation.push({
330
+ theta: vector[0],
331
+ phi: vector[1],
332
+ });
333
+ }
334
+ else {
335
+ this._nonmanualInteraction = true;
336
+ this._nonmanualInteractionTransformations.sceneRotation.push({
337
+ theta: vector[0],
338
+ phi: vector[1],
339
+ });
340
+ }
341
+ }
342
+ applySettings(settingsEngine) {
343
+ const cameraSetting = settingsEngine.camera.cameras[this.camera.id];
344
+ if (!cameraSetting)
345
+ return;
346
+ this.reset();
347
+ const controlsSettings = (cameraSetting.controls);
348
+ this.autoRotationSpeed = controlsSettings.autoRotationSpeed;
349
+ this.damping = controlsSettings.damping;
350
+ this.enableAutoRotation = controlsSettings.enableAutoRotation;
351
+ this.enableKeyPan = controlsSettings.enableKeyPan;
352
+ this.enablePan = controlsSettings.enablePan;
353
+ this.enableRotation = controlsSettings.enableRotation;
354
+ this.enableZoom = controlsSettings.enableZoom;
355
+ // this.input = controlsSettings.input;
356
+ this.keyPanSpeed = controlsSettings.keyPanSpeed;
357
+ this.movementSmoothness = controlsSettings.movementSmoothness;
358
+ this.rotationSpeed = controlsSettings.rotationSpeed;
359
+ this.panSpeed = controlsSettings.panSpeed;
360
+ this.zoomSpeed = controlsSettings.zoomSpeed;
361
+ this.enableAzimuthRotation = controlsSettings.enableAzimuthRotation;
362
+ this.enablePolarRotation = controlsSettings.enablePolarRotation;
363
+ this.enableTurntableControls = controlsSettings.enableTurntableControls;
364
+ this.enableObjectControls = controlsSettings.enableObjectControls;
365
+ this.turntableCenter = this._converter.toVec3(controlsSettings.turntableCenter);
366
+ this.objectControlsCenter = this._converter.toVec3(controlsSettings.objectControlsCenter);
367
+ if (controlsSettings.restrictions.position.cube.min.x === null)
368
+ controlsSettings.restrictions.position.cube.min.x = -Infinity;
369
+ if (controlsSettings.restrictions.position.cube.min.y === null)
370
+ controlsSettings.restrictions.position.cube.min.y = -Infinity;
371
+ if (controlsSettings.restrictions.position.cube.min.z === null)
372
+ controlsSettings.restrictions.position.cube.min.z = -Infinity;
373
+ if (controlsSettings.restrictions.position.cube.max.x === null)
374
+ controlsSettings.restrictions.position.cube.max.x = Infinity;
375
+ if (controlsSettings.restrictions.position.cube.max.y === null)
376
+ controlsSettings.restrictions.position.cube.max.y = Infinity;
377
+ if (controlsSettings.restrictions.position.cube.max.z === null)
378
+ controlsSettings.restrictions.position.cube.max.z = Infinity;
379
+ if (controlsSettings.restrictions.position.sphere.radius === null)
380
+ controlsSettings.restrictions.position.sphere.radius = Infinity;
381
+ if (controlsSettings.restrictions.target.cube.min.x === null)
382
+ controlsSettings.restrictions.target.cube.min.x = -Infinity;
383
+ if (controlsSettings.restrictions.target.cube.min.y === null)
384
+ controlsSettings.restrictions.target.cube.min.y = -Infinity;
385
+ if (controlsSettings.restrictions.target.cube.min.z === null)
386
+ controlsSettings.restrictions.target.cube.min.z = -Infinity;
387
+ if (controlsSettings.restrictions.target.cube.max.x === null)
388
+ controlsSettings.restrictions.target.cube.max.x = Infinity;
389
+ if (controlsSettings.restrictions.target.cube.max.y === null)
390
+ controlsSettings.restrictions.target.cube.max.y = Infinity;
391
+ if (controlsSettings.restrictions.target.cube.max.z === null)
392
+ controlsSettings.restrictions.target.cube.max.z = Infinity;
393
+ if (controlsSettings.restrictions.target.sphere.radius === null)
394
+ controlsSettings.restrictions.target.sphere.radius = Infinity;
395
+ if (controlsSettings.restrictions.rotation.minAzimuthAngle === null)
396
+ controlsSettings.restrictions.rotation.minAzimuthAngle = -Infinity;
397
+ if (controlsSettings.restrictions.rotation.maxAzimuthAngle === null)
398
+ controlsSettings.restrictions.rotation.maxAzimuthAngle = Infinity;
399
+ if (controlsSettings.restrictions.zoom.maxDistance === null)
400
+ controlsSettings.restrictions.zoom.maxDistance = Infinity;
401
+ this.cubePositionRestriction = {
402
+ min: this._converter.toVec3(controlsSettings.restrictions.position.cube.min),
403
+ max: this._converter.toVec3(controlsSettings.restrictions.position.cube.max),
404
+ };
405
+ this.spherePositionRestriction = {
406
+ center: this._converter.toVec3(controlsSettings.restrictions.position.sphere.center),
407
+ radius: controlsSettings.restrictions.position.sphere.radius,
408
+ };
409
+ this.cubeTargetRestriction = {
410
+ min: this._converter.toVec3(controlsSettings.restrictions.target.cube.min),
411
+ max: this._converter.toVec3(controlsSettings.restrictions.target.cube.max),
412
+ };
413
+ this.sphereTargetRestriction = {
414
+ center: this._converter.toVec3(controlsSettings.restrictions.target.sphere.center),
415
+ radius: controlsSettings.restrictions.target.sphere.radius,
416
+ };
417
+ this.rotationRestriction = controlsSettings.restrictions.rotation;
418
+ this.zoomRestriction = controlsSettings.restrictions.zoom;
419
+ }
420
+ applyTargetMatrix(matrix, manualInteraction) {
421
+ if (this._manualInteraction || manualInteraction) {
422
+ this._manualInteraction = true;
423
+ this._manualInteractionTransformations.target.push({ matrix });
424
+ }
425
+ else {
426
+ this._nonmanualInteraction = true;
427
+ this._nonmanualInteractionTransformations.target.push({ matrix });
428
+ }
429
+ }
430
+ applyTargetVector(vector, manualInteraction) {
431
+ if (this._manualInteraction || manualInteraction) {
432
+ this._manualInteraction = true;
433
+ this._manualInteractionTransformations.target.push({ vector });
434
+ }
435
+ else {
436
+ this._nonmanualInteraction = true;
437
+ this._nonmanualInteractionTransformations.target.push({ vector });
438
+ }
439
+ }
440
+ applyUpMatrix(matrix, manualInteraction) {
441
+ // https://shapediver.atlassian.net/browse/SS-2949
442
+ throw new Error("Method not implemented.");
443
+ }
444
+ assignViewer(viewportId, canvas) {
445
+ this._canvas = canvas;
446
+ this._viewportId = viewportId;
447
+ }
448
+ getPositionWithManualUpdates() {
449
+ let position = gl_matrix_1.vec3.clone(this._position);
450
+ if (this._manualInteraction) {
451
+ for (let i = this._manualInteractionTransformations.position.length - 1; i >= 0; i--) {
452
+ if (this._manualInteractionTransformations.position[i].matrix) {
453
+ position = gl_matrix_1.vec3.transformMat4(position, position, this._manualInteractionTransformations.position[i]
454
+ .matrix);
455
+ }
456
+ else {
457
+ position = gl_matrix_1.vec3.add(position, position, this._manualInteractionTransformations.position[i]
458
+ .vector);
459
+ }
460
+ }
461
+ }
462
+ return position;
463
+ }
464
+ getPositionWithUpdates() {
465
+ return this.getPosition();
466
+ }
467
+ getTargetWithManualUpdates() {
468
+ let target = gl_matrix_1.vec3.clone(this._target);
469
+ if (this._manualInteraction) {
470
+ for (let i = this._manualInteractionTransformations.target.length - 1; i >= 0; i--) {
471
+ if (this._manualInteractionTransformations.target[i].matrix) {
472
+ target = gl_matrix_1.vec3.transformMat4(target, target, this._manualInteractionTransformations.target[i]
473
+ .matrix);
474
+ }
475
+ else {
476
+ target = gl_matrix_1.vec3.add(target, target, this._manualInteractionTransformations.target[i]
477
+ .vector);
478
+ }
479
+ }
480
+ }
481
+ return target;
482
+ }
483
+ getTargetWithUpdates() {
484
+ return this.getTarget();
485
+ }
486
+ isMoving() {
487
+ return this._manualInteraction || this._nonmanualInteraction;
488
+ }
489
+ isWithinRestrictions(position, target) {
490
+ return this._cameraLogic.isWithinRestrictions(position, target);
491
+ }
492
+ reset() {
493
+ this._cameraControlsEventDistribution.reset();
494
+ this._cameraLogic.reset();
495
+ }
496
+ update(time) {
497
+ if (!this._enabled)
498
+ return {
499
+ position: gl_matrix_1.vec3.clone(this._position),
500
+ target: gl_matrix_1.vec3.clone(this._target),
501
+ sceneRotation: gl_matrix_1.vec2.clone(this._sceneRotation),
502
+ };
503
+ // reset all values
504
+ if (this._manualInteraction === true &&
505
+ this._cameraInterpolationManager.active())
506
+ this._cameraInterpolationManager.stop();
507
+ const { position, target, sceneRotation } = this._cameraLogic.restrict(this.getPosition(), this.getTarget(), this.getSceneRotation());
508
+ this._position = gl_matrix_1.vec3.clone(position);
509
+ this._target = gl_matrix_1.vec3.clone(target);
510
+ this._sceneRotation = sceneRotation
511
+ ? gl_matrix_1.vec2.clone(sceneRotation)
512
+ : gl_matrix_1.vec2.create();
513
+ this._manualInteraction = false;
514
+ this._manualInteractionTransformations = {
515
+ position: [],
516
+ target: [],
517
+ sceneRotation: [],
518
+ };
519
+ this._nonmanualInteraction = this._cameraInterpolationManager.active();
520
+ this._nonmanualInteractionTransformations = {
521
+ position: [],
522
+ target: [],
523
+ sceneRotation: [],
524
+ };
525
+ this._cameraLogic.update(time, this._nonmanualInteraction);
526
+ const oldMovement = this._moving;
527
+ const cameraDefinition = {
528
+ position: gl_matrix_1.vec3.clone(this._position),
529
+ target: gl_matrix_1.vec3.clone(this._target),
530
+ sceneRotation: gl_matrix_1.vec2.clone(this._sceneRotation),
531
+ };
532
+ this._movingDuration += time;
533
+ this._moving = this._manualInteraction || this._nonmanualInteraction;
534
+ switch (true) {
535
+ case oldMovement !== this._moving && this._moving === true:
536
+ this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.CAMERA.CAMERA_START, {
537
+ viewportId: this._viewportId,
538
+ cameraId: this.camera.id,
539
+ });
540
+ break;
541
+ case oldMovement !== this._moving && this._moving === false:
542
+ this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.CAMERA.CAMERA_END, {
543
+ viewportId: this._viewportId,
544
+ cameraId: this.camera.id,
545
+ });
546
+ break;
547
+ default:
548
+ this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.CAMERA.CAMERA_MOVE, {
549
+ viewportId: this._viewportId,
550
+ cameraId: this.camera.id,
551
+ });
552
+ }
553
+ if (!this._moving)
554
+ this._movingDuration = 0;
555
+ return cameraDefinition;
556
+ }
557
+ // #endregion Public Methods (16)
558
+ // #region Private Methods (3)
559
+ getPosition() {
560
+ let position = gl_matrix_1.vec3.clone(this._position);
561
+ if (this._manualInteraction) {
562
+ for (let i = this._manualInteractionTransformations.position.length - 1; i >= 0; i--) {
563
+ if (this._manualInteractionTransformations.position[i].matrix) {
564
+ position = gl_matrix_1.vec3.transformMat4(position, position, this._manualInteractionTransformations.position[i]
565
+ .matrix);
566
+ }
567
+ else {
568
+ position = gl_matrix_1.vec3.add(position, position, this._manualInteractionTransformations.position[i]
569
+ .vector);
570
+ }
571
+ }
572
+ }
573
+ else if (this._nonmanualInteraction) {
574
+ for (let i = this._nonmanualInteractionTransformations.position.length -
575
+ 1; i >= 0; i--) {
576
+ if (this._nonmanualInteractionTransformations.position[i].matrix) {
577
+ position = gl_matrix_1.vec3.transformMat4(position, position, this._nonmanualInteractionTransformations.position[i]
578
+ .matrix);
579
+ }
580
+ else {
581
+ position = gl_matrix_1.vec3.add(position, position, this._nonmanualInteractionTransformations.position[i]
582
+ .vector);
583
+ }
584
+ }
585
+ }
586
+ return position;
587
+ }
588
+ getSceneRotation() {
589
+ let sceneRotation = gl_matrix_1.vec2.clone(this._sceneRotation);
590
+ if (this._manualInteraction) {
591
+ for (let i = this._manualInteractionTransformations.sceneRotation
592
+ .length - 1; i >= 0; i--) {
593
+ sceneRotation = gl_matrix_1.vec2.add(sceneRotation, sceneRotation, gl_matrix_1.vec2.fromValues(this._manualInteractionTransformations.sceneRotation[i]
594
+ .theta, this._manualInteractionTransformations.sceneRotation[i]
595
+ .phi));
596
+ }
597
+ }
598
+ else if (this._nonmanualInteraction) {
599
+ for (let i = this._nonmanualInteractionTransformations.sceneRotation
600
+ .length - 1; i >= 0; i--) {
601
+ sceneRotation = gl_matrix_1.vec2.add(sceneRotation, sceneRotation, gl_matrix_1.vec2.fromValues(this._nonmanualInteractionTransformations.sceneRotation[i].theta, this._nonmanualInteractionTransformations.sceneRotation[i].phi));
602
+ }
603
+ }
604
+ return sceneRotation;
605
+ }
606
+ getTarget() {
607
+ let target = gl_matrix_1.vec3.clone(this._target);
608
+ if (this._manualInteraction) {
609
+ for (let i = this._manualInteractionTransformations.target.length - 1; i >= 0; i--) {
610
+ if (this._manualInteractionTransformations.target[i].matrix) {
611
+ target = gl_matrix_1.vec3.transformMat4(target, target, this._manualInteractionTransformations.target[i]
612
+ .matrix);
613
+ }
614
+ else {
615
+ target = gl_matrix_1.vec3.add(target, target, this._manualInteractionTransformations.target[i]
616
+ .vector);
617
+ }
618
+ }
619
+ }
620
+ else if (this._nonmanualInteraction) {
621
+ for (let i = this._nonmanualInteractionTransformations.target.length - 1; i >= 0; i--) {
622
+ if (this._nonmanualInteractionTransformations.target[i].matrix) {
623
+ target = gl_matrix_1.vec3.transformMat4(target, target, this._nonmanualInteractionTransformations.target[i]
624
+ .matrix);
625
+ }
626
+ else {
627
+ target = gl_matrix_1.vec3.add(target, target, this._nonmanualInteractionTransformations.target[i]
628
+ .vector);
629
+ }
630
+ }
631
+ }
632
+ return target;
633
+ }
634
+ }
635
+ exports.AbstractCameraControls = AbstractCameraControls;
636
636
  //# sourceMappingURL=AbstractCameraControls.js.map