@shapediver/viewer.rendering-engine.camera-engine 2.12.8 → 3.0.0

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 (143) hide show
  1. package/dist/implementation/CameraEngine.d.ts +5 -7
  2. package/dist/implementation/CameraEngine.d.ts.map +1 -1
  3. package/dist/implementation/CameraEngine.js +68 -27
  4. package/dist/implementation/CameraEngine.js.map +1 -1
  5. package/dist/implementation/camera/AbstractCamera.d.ts +7 -5
  6. package/dist/implementation/camera/AbstractCamera.d.ts.map +1 -1
  7. package/dist/implementation/camera/AbstractCamera.js +15 -8
  8. package/dist/implementation/camera/AbstractCamera.js.map +1 -1
  9. package/dist/implementation/camera/OrthographicCamera.d.ts +10 -13
  10. package/dist/implementation/camera/OrthographicCamera.d.ts.map +1 -1
  11. package/dist/implementation/camera/OrthographicCamera.js +53 -52
  12. package/dist/implementation/camera/OrthographicCamera.js.map +1 -1
  13. package/dist/implementation/camera/PerspectiveCamera.d.ts +9 -12
  14. package/dist/implementation/camera/PerspectiveCamera.d.ts.map +1 -1
  15. package/dist/implementation/camera/PerspectiveCamera.js +33 -38
  16. package/dist/implementation/camera/PerspectiveCamera.js.map +1 -1
  17. package/dist/implementation/controls/AbstractCameraControls.d.ts +156 -5
  18. package/dist/implementation/controls/AbstractCameraControls.d.ts.map +1 -1
  19. package/dist/implementation/controls/AbstractCameraControls.js +260 -6
  20. package/dist/implementation/controls/AbstractCameraControls.js.map +1 -1
  21. package/dist/implementation/controls/CameraControlsEventDistribution.d.ts +38 -0
  22. package/dist/implementation/controls/CameraControlsEventDistribution.d.ts.map +1 -0
  23. package/dist/implementation/controls/{perspective/CameraControlsEventDistribution.js → CameraControlsEventDistribution.js} +71 -71
  24. package/dist/implementation/controls/CameraControlsEventDistribution.js.map +1 -0
  25. package/dist/implementation/controls/{perspective/CameraControlsLogic.d.ts → CameraControlsLogic.d.ts} +5 -5
  26. package/dist/implementation/controls/CameraControlsLogic.d.ts.map +1 -0
  27. package/dist/implementation/controls/{perspective/CameraControlsLogic.js → CameraControlsLogic.js} +74 -44
  28. package/dist/implementation/controls/CameraControlsLogic.js.map +1 -0
  29. package/dist/implementation/controls/OrthographicCameraControls.d.ts +4 -67
  30. package/dist/implementation/controls/OrthographicCameraControls.d.ts.map +1 -1
  31. package/dist/implementation/controls/OrthographicCameraControls.js +22 -90
  32. package/dist/implementation/controls/OrthographicCameraControls.js.map +1 -1
  33. package/dist/implementation/controls/PerspectiveCameraControls.d.ts +4 -151
  34. package/dist/implementation/controls/PerspectiveCameraControls.d.ts.map +1 -1
  35. package/dist/implementation/controls/PerspectiveCameraControls.js +21 -247
  36. package/dist/implementation/controls/PerspectiveCameraControls.js.map +1 -1
  37. package/dist/implementation/interpolation/CameraInterpolationManager.d.ts +3 -3
  38. package/dist/implementation/interpolation/CameraInterpolationManager.d.ts.map +1 -1
  39. package/dist/implementation/interpolation/CameraInterpolationManager.js +5 -5
  40. package/dist/implementation/interpolation/CameraInterpolationManager.js.map +1 -1
  41. package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.d.ts +3 -3
  42. package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.d.ts.map +1 -1
  43. package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.js +11 -11
  44. package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.js.map +1 -1
  45. package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.d.ts +3 -3
  46. package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.d.ts.map +1 -1
  47. package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.js +6 -6
  48. package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.js.map +1 -1
  49. package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.d.ts +4 -4
  50. package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.d.ts.map +1 -1
  51. package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.js +6 -6
  52. package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.js.map +1 -1
  53. package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.d.ts +3 -3
  54. package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.d.ts.map +1 -1
  55. package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.js +6 -6
  56. package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.js.map +1 -1
  57. package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.d.ts +3 -3
  58. package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.d.ts.map +1 -1
  59. package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.js +9 -9
  60. package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.js.map +1 -1
  61. package/dist/index.d.ts +6 -8
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +6 -6
  64. package/dist/index.js.map +1 -1
  65. package/dist/interfaces/ICameraEngine.d.ts +7 -7
  66. package/dist/interfaces/ICameraEngine.d.ts.map +1 -1
  67. package/dist/interfaces/ICameraEngine.js +3 -0
  68. package/dist/interfaces/ICameraEngine.js.map +1 -1
  69. package/dist/interfaces/camera/ICamera.d.ts +23 -22
  70. package/dist/interfaces/camera/ICamera.d.ts.map +1 -1
  71. package/dist/interfaces/camera/ICamera.js +1 -0
  72. package/dist/interfaces/camera/ICamera.js.map +1 -1
  73. package/dist/interfaces/camera/IOrthographicCamera.d.ts +8 -7
  74. package/dist/interfaces/camera/IOrthographicCamera.d.ts.map +1 -1
  75. package/dist/interfaces/camera/IOrthographicCamera.js +4 -0
  76. package/dist/interfaces/camera/IOrthographicCamera.js.map +1 -1
  77. package/dist/interfaces/camera/IPerspectiveCamera.d.ts +2 -2
  78. package/dist/interfaces/camera/IPerspectiveCamera.d.ts.map +1 -1
  79. package/dist/interfaces/controls/ICameraControls.d.ts +73 -2
  80. package/dist/interfaces/controls/ICameraControls.d.ts.map +1 -1
  81. package/dist/interfaces/controls/ICameraControls.js +1 -0
  82. package/dist/interfaces/controls/ICameraControls.js.map +1 -1
  83. package/dist/interfaces/controls/ICameraControlsEventDistribution.d.ts +1 -1
  84. package/dist/interfaces/controls/ICameraControlsEventDistribution.d.ts.map +1 -1
  85. package/dist/interfaces/controls/ICameraControlsLogic.d.ts +4 -1
  86. package/dist/interfaces/controls/ICameraControlsLogic.d.ts.map +1 -1
  87. package/dist/interfaces/interpolation/ICameraInterpolation.d.ts +2 -2
  88. package/dist/interfaces/interpolation/ICameraInterpolation.d.ts.map +1 -1
  89. package/package.json +8 -8
  90. package/src/implementation/CameraEngine.ts +111 -70
  91. package/src/implementation/camera/AbstractCamera.ts +24 -16
  92. package/src/implementation/camera/OrthographicCamera.ts +84 -85
  93. package/src/implementation/camera/PerspectiveCamera.ts +64 -69
  94. package/src/implementation/controls/AbstractCameraControls.ts +303 -14
  95. package/src/implementation/controls/{perspective/CameraControlsEventDistribution.ts → CameraControlsEventDistribution.ts} +96 -75
  96. package/src/implementation/controls/{perspective/CameraControlsLogic.ts → CameraControlsLogic.ts} +90 -53
  97. package/src/implementation/controls/OrthographicCameraControls.ts +27 -121
  98. package/src/implementation/controls/PerspectiveCameraControls.ts +28 -294
  99. package/src/implementation/interpolation/CameraInterpolationManager.ts +40 -45
  100. package/src/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.ts +19 -22
  101. package/src/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.ts +15 -16
  102. package/src/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.ts +17 -19
  103. package/src/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.ts +12 -14
  104. package/src/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.ts +18 -20
  105. package/src/index.ts +18 -21
  106. package/src/interfaces/ICameraEngine.ts +24 -11
  107. package/src/interfaces/camera/ICamera.ts +45 -41
  108. package/src/interfaces/camera/IOrthographicCamera.ts +27 -9
  109. package/src/interfaces/camera/IPerspectiveCamera.ts +13 -5
  110. package/src/interfaces/controls/ICameraControls.ts +49 -6
  111. package/src/interfaces/controls/ICameraControlsEventDistribution.ts +5 -2
  112. package/src/interfaces/controls/ICameraControlsLogic.ts +6 -3
  113. package/src/interfaces/interpolation/ICameraInterpolation.ts +6 -2
  114. package/dist/implementation/controls/orthographic/CameraControlsEventDistribution.d.ts +0 -32
  115. package/dist/implementation/controls/orthographic/CameraControlsEventDistribution.d.ts.map +0 -1
  116. package/dist/implementation/controls/orthographic/CameraControlsEventDistribution.js +0 -230
  117. package/dist/implementation/controls/orthographic/CameraControlsEventDistribution.js.map +0 -1
  118. package/dist/implementation/controls/orthographic/CameraControlsLogic.d.ts +0 -28
  119. package/dist/implementation/controls/orthographic/CameraControlsLogic.d.ts.map +0 -1
  120. package/dist/implementation/controls/orthographic/CameraControlsLogic.js +0 -243
  121. package/dist/implementation/controls/orthographic/CameraControlsLogic.js.map +0 -1
  122. package/dist/implementation/controls/perspective/CameraControlsEventDistribution.d.ts +0 -32
  123. package/dist/implementation/controls/perspective/CameraControlsEventDistribution.d.ts.map +0 -1
  124. package/dist/implementation/controls/perspective/CameraControlsEventDistribution.js.map +0 -1
  125. package/dist/implementation/controls/perspective/CameraControlsLogic.d.ts.map +0 -1
  126. package/dist/implementation/controls/perspective/CameraControlsLogic.js.map +0 -1
  127. package/dist/interfaces/controls/ICameraControlsUsage.d.ts +0 -22
  128. package/dist/interfaces/controls/ICameraControlsUsage.d.ts.map +0 -1
  129. package/dist/interfaces/controls/ICameraControlsUsage.js +0 -3
  130. package/dist/interfaces/controls/ICameraControlsUsage.js.map +0 -1
  131. package/dist/interfaces/controls/IOrthographicCameraControls.d.ts +0 -30
  132. package/dist/interfaces/controls/IOrthographicCameraControls.d.ts.map +0 -1
  133. package/dist/interfaces/controls/IOrthographicCameraControls.js +0 -3
  134. package/dist/interfaces/controls/IOrthographicCameraControls.js.map +0 -1
  135. package/dist/interfaces/controls/IPerspectiveCameraControls.d.ts +0 -65
  136. package/dist/interfaces/controls/IPerspectiveCameraControls.d.ts.map +0 -1
  137. package/dist/interfaces/controls/IPerspectiveCameraControls.js +0 -3
  138. package/dist/interfaces/controls/IPerspectiveCameraControls.js.map +0 -1
  139. package/src/implementation/controls/orthographic/CameraControlsEventDistribution.ts +0 -234
  140. package/src/implementation/controls/orthographic/CameraControlsLogic.ts +0 -271
  141. package/src/interfaces/controls/ICameraControlsUsage.ts +0 -30
  142. package/src/interfaces/controls/IOrthographicCameraControls.ts +0 -13
  143. package/src/interfaces/controls/IPerspectiveCameraControls.ts +0 -33
@@ -1,130 +1,36 @@
1
- import { IOrthographicControlsSettingsV3 } from '@shapediver/viewer.settings';
2
- import { SettingsEngine, StateEngine } from '@shapediver/viewer.shared.services';
3
-
4
- import { CAMERA_TYPE, ICamera } from '../..';
5
- import { IOrthographicCameraControls } from '../../interfaces/controls/IOrthographicCameraControls';
6
1
  import { AbstractCameraControls } from './AbstractCameraControls';
7
- import {
8
- CameraControlsEventDistribution as OrthographicCameraControlsEventDistribution,
9
- } from './orthographic/CameraControlsEventDistribution';
10
- import { CameraControlsLogic as OrthographicCameraControlsLogic } from './orthographic/CameraControlsLogic';
11
-
12
- export class OrthographicCameraControls extends AbstractCameraControls implements IOrthographicCameraControls {
13
- // #region Properties (9)
14
-
15
- private _damping: number = 0.1;
16
- private _enableKeyPan: boolean = false;
17
- private _enablePan: boolean = true;
18
- private _enableZoom: boolean = true;
19
- private _input: { keys: { up: number, down: number, left: number, right: number }, mouse: { rotate: number, zoom: number, pan: number }, touch: { rotate: number, zoom: number, pan: number } } = { keys: { up: 38, down: 40, left: 37, right: 39 }, mouse: { rotate: 0, zoom: 1, pan: 2 }, touch: { rotate: 1, zoom: 2, pan: 2 }, };
20
- private _keyPanSpeed: number = 0.5;
21
- private _movementSmoothness: number = 0.5;
22
- private _panSpeed: number = 0.5;
23
- private _zoomSpeed: number = 0.5;
24
-
25
- private readonly _stateEngine: StateEngine = StateEngine.instance;
26
-
27
- // #endregion Properties (9)
2
+ import { ICamera } from '../..';
3
+ import { CameraControlsLogic } from './CameraControlsLogic';
4
+ import { CameraControlsEventDistribution, } from './CameraControlsEventDistribution';
5
+ export class OrthographicCameraControls extends AbstractCameraControls {
6
+ // #region Properties (2)
7
+
8
+ private _settingsAdjustments = {
9
+ autoRotationSpeed: 2 * Math.PI / 60 / 60,
10
+ damping: 1.0,
11
+ movementSmoothness: 1.0,
12
+ panSpeed: 1.75,
13
+ rotationSpeed: Math.PI,
14
+ zoomSpeed: 0.025,
15
+ };
16
+ private _touchAdjustments = {
17
+ autoRotationSpeed: 1.0,
18
+ damping: 1.0,
19
+ movementSmoothness: 1.0,
20
+ panSpeed: 4.0 / 1.75,
21
+ rotationSpeed: 1.5,
22
+ zoomSpeed: 100.0,
23
+ };
24
+
25
+ // #endregion Properties (2)
28
26
 
29
27
  // #region Constructors (1)
30
28
 
31
29
  constructor(camera: ICamera, enabled: boolean) {
32
- super(camera, enabled, CAMERA_TYPE.ORTHOGRAPHIC);
33
- this._cameraLogic = new OrthographicCameraControlsLogic(this);
34
- this._cameraControlsEventDistribution = new OrthographicCameraControlsEventDistribution(this, <OrthographicCameraControlsLogic>this._cameraLogic);
35
- }
36
-
37
- public applySettings(settingsEngine: SettingsEngine) {
38
- const cameraSetting = settingsEngine.camera.cameras[this.camera.id];
39
- if(!cameraSetting) return;
40
- this.reset();
41
- const controlsSettings = <IOrthographicControlsSettingsV3>cameraSetting.controls;
42
- this.damping = controlsSettings.damping;
43
- this.enableKeyPan = controlsSettings.enableKeyPan;
44
- this.enablePan = controlsSettings.enablePan;
45
- this.enableZoom = controlsSettings.enableZoom;
46
- // this.input = controlsSettings.input;
47
- this.keyPanSpeed = controlsSettings.keyPanSpeed;
48
- this.movementSmoothness = controlsSettings.movementSmoothness;
49
- this.panSpeed = controlsSettings.panSpeed;
50
- this.zoomSpeed = controlsSettings.zoomSpeed;
30
+ super(camera, enabled);
31
+ this._cameraLogic = new CameraControlsLogic(this, this._settingsAdjustments, this._touchAdjustments);
32
+ this._cameraControlsEventDistribution = new CameraControlsEventDistribution(this, this._cameraLogic);
51
33
  }
52
34
 
53
35
  // #endregion Constructors (1)
54
-
55
- // #region Public Accessors (18)
56
-
57
- public get damping(): number {
58
- return this._damping;
59
- }
60
-
61
- public set damping(value: number) {
62
- this._damping = value;
63
- }
64
-
65
- public get enableKeyPan(): boolean {
66
- return this._enableKeyPan;
67
- }
68
-
69
- public set enableKeyPan(value: boolean) {
70
- this._enableKeyPan = value;
71
- }
72
-
73
- public get enablePan(): boolean {
74
- return this._enablePan;
75
- }
76
-
77
- public set enablePan(value: boolean) {
78
- this._enablePan = value;
79
- }
80
-
81
- public get enableZoom(): boolean {
82
- return this._enableZoom;
83
- }
84
-
85
- public set enableZoom(value: boolean) {
86
- this._enableZoom = value;
87
- }
88
-
89
- public get input(): { keys: { up: number, down: number, left: number, right: number }, mouse: { rotate: number, zoom: number, pan: number }, touch: { rotate: number, zoom: number, pan: number } } {
90
- return this._input;
91
- }
92
-
93
- public set input(value: { keys: { up: number, down: number, left: number, right: number }, mouse: { rotate: number, zoom: number, pan: number }, touch: { rotate: number, zoom: number, pan: number } }) {
94
- this._input = value;
95
- }
96
-
97
- public get keyPanSpeed(): number {
98
- return this._keyPanSpeed;
99
- }
100
-
101
- public set keyPanSpeed(value: number) {
102
- this._keyPanSpeed = value;
103
- }
104
-
105
- public get movementSmoothness(): number {
106
- return this._movementSmoothness;
107
- }
108
-
109
- public set movementSmoothness(value: number) {
110
- this._movementSmoothness = value;
111
- }
112
-
113
- public get panSpeed(): number {
114
- return this._panSpeed;
115
- }
116
-
117
- public set panSpeed(value: number) {
118
- this._panSpeed = value;
119
- }
120
-
121
- public get zoomSpeed(): number {
122
- return this._zoomSpeed;
123
- }
124
-
125
- public set zoomSpeed(value: number) {
126
- this._zoomSpeed = value;
127
- }
128
-
129
- // #endregion Public Accessors (18)
130
36
  }
@@ -1,303 +1,37 @@
1
- import { IOrbitControlsSettingsV3 } from '@shapediver/viewer.settings';
2
- import { SettingsEngine, StateEngine, Converter } from '@shapediver/viewer.shared.services';
3
- import { vec3 } from 'gl-matrix';
4
-
5
- import { CAMERA_TYPE, ICamera } from '../..';
6
- import { IPerspectiveCameraControls } from '../../interfaces/controls/IPerspectiveCameraControls';
7
1
  import { AbstractCameraControls } from './AbstractCameraControls';
8
- import {
9
- CameraControlsEventDistribution as OrbitCameraControlsEventDistribution,
10
- } from './perspective/CameraControlsEventDistribution';
11
- import { CameraControlsLogic as OrbitCameraControlsLogic } from './perspective/CameraControlsLogic';
12
-
13
- export class PerspectiveCameraControls extends AbstractCameraControls implements IPerspectiveCameraControls {
14
- // #region Properties (25)
15
-
16
- private readonly _converter: Converter = Converter.instance;
17
- private readonly _stateEngine: StateEngine = StateEngine.instance;
18
-
19
- private _autoRotationSpeed: number = 0;
20
- private _cubePositionRestriction: { min: vec3, max: vec3 } = { min: vec3.fromValues(-Infinity, -Infinity, -Infinity), max: vec3.fromValues(Infinity, Infinity, Infinity) };
21
- private _cubeTargetRestriction: { min: vec3, max: vec3 } = { min: vec3.fromValues(-Infinity, -Infinity, -Infinity), max: vec3.fromValues(Infinity, Infinity, Infinity) };
22
- private _damping: number = 0.1;
23
- private _enableAutoRotation: boolean = false;
24
- private _enableAzimuthRotation: boolean = true;
25
- private _enableKeyPan: boolean = false;
26
- private _enablePan: boolean = true;
27
- private _enablePolarRotation: boolean = true;
28
- private _enableRotation: boolean = true;
29
- private _enableTurntableControls: boolean = false;
30
- private _enableZoom: boolean = true;
31
- private _input: { keys: { up: number, down: number, left: number, right: number }, mouse: { rotate: number, zoom: number, pan: number }, touch: { rotate: number, zoom: number, pan: number } } = { keys: { up: 38, down: 40, left: 37, right: 39 }, mouse: { rotate: 0, zoom: 1, pan: 2 }, touch: { rotate: 1, zoom: 2, pan: 2 }, };
32
- private _keyPanSpeed: number = 0.5;
33
- private _movementSmoothness: number = 0.5;
34
- private _panSpeed: number = 0.5;
35
- private _rotationRestriction: { minPolarAngle: number, maxPolarAngle: number, minAzimuthAngle: number, maxAzimuthAngle: number } = { minPolarAngle: 0, maxPolarAngle: 180, minAzimuthAngle: -Infinity, maxAzimuthAngle: Infinity };
36
- private _rotationSpeed: number = 0.5;
37
- private _spherePositionRestriction: { center: vec3, radius: number } = { center: vec3.create(), radius: Infinity };
38
- private _sphereTargetRestriction: { center: vec3, radius: number } = { center: vec3.create(), radius: Infinity };
39
- private _turntableCenter: vec3 = vec3.create();
40
- private _zoomRestriction: { minDistance: number, maxDistance: number } = { minDistance: 0, maxDistance: Infinity };
41
- private _zoomSpeed: number = 0.5;
42
-
43
- // #endregion Properties (25)
2
+ import { CameraControlsLogic } from './CameraControlsLogic';
3
+ import { ICamera } from '../..';
4
+ import { CameraControlsEventDistribution, } from './CameraControlsEventDistribution';
5
+
6
+ export class PerspectiveCameraControls extends AbstractCameraControls {
7
+ // #region Properties (3)
8
+
9
+ private _settingsAdjustments = {
10
+ autoRotationSpeed: 2 * Math.PI / 60 / 60,
11
+ damping: 1.0,
12
+ movementSmoothness: 1.0,
13
+ panSpeed: 1.75,
14
+ rotationSpeed: Math.PI,
15
+ zoomSpeed: 0.025,
16
+ };
17
+ private _touchAdjustments = {
18
+ autoRotationSpeed: 1.0,
19
+ damping: 1.0,
20
+ movementSmoothness: 1.0,
21
+ panSpeed: 1.0 / 1.75,
22
+ rotationSpeed: 1.5,
23
+ zoomSpeed: 100.0,
24
+ };
25
+
26
+ // #endregion Properties (3)
44
27
 
45
28
  // #region Constructors (1)
46
29
 
47
30
  constructor(camera: ICamera, enabled: boolean) {
48
- super(camera, enabled, CAMERA_TYPE.PERSPECTIVE);
49
- this._cameraLogic = new OrbitCameraControlsLogic(this);
50
- this._cameraControlsEventDistribution = new OrbitCameraControlsEventDistribution(this, <OrbitCameraControlsLogic>this._cameraLogic);
31
+ super(camera, enabled);
32
+ this._cameraLogic = new CameraControlsLogic(this, this._settingsAdjustments, this._touchAdjustments);
33
+ this._cameraControlsEventDistribution = new CameraControlsEventDistribution(this, this._cameraLogic);
51
34
  }
52
35
 
53
36
  // #endregion Constructors (1)
54
-
55
- // #region Public Accessors (46)
56
-
57
- public get autoRotationSpeed(): number {
58
- return this._autoRotationSpeed;
59
- }
60
-
61
- public set autoRotationSpeed(value: number) {
62
- this._autoRotationSpeed = value;
63
- }
64
-
65
- public get cubePositionRestriction(): { min: vec3, max: vec3 } {
66
- return this._cubePositionRestriction;
67
- }
68
-
69
- public set cubePositionRestriction(value: { min: vec3, max: vec3 }) {
70
- this._cubePositionRestriction = value;
71
- }
72
-
73
- public get cubeTargetRestriction(): { min: vec3, max: vec3 } {
74
- return this._cubeTargetRestriction;
75
- }
76
-
77
- public set cubeTargetRestriction(value: { min: vec3, max: vec3 }) {
78
- this._cubeTargetRestriction = value;
79
- }
80
-
81
- public get damping(): number {
82
- return this._damping;
83
- }
84
-
85
- public set damping(value: number) {
86
- this._damping = value;
87
- }
88
-
89
- public get enableAutoRotation(): boolean {
90
- return this._enableAutoRotation;
91
- }
92
-
93
- public set enableAutoRotation(value: boolean) {
94
- this._enableAutoRotation = value;
95
- }
96
-
97
- public get enableAzimuthRotation(): boolean {
98
- return this._enableAzimuthRotation;
99
- }
100
-
101
- public set enableAzimuthRotation(value: boolean) {
102
- this._enableAzimuthRotation = value;
103
- }
104
-
105
- public get enableKeyPan(): boolean {
106
- return this._enableKeyPan;
107
- }
108
-
109
- public set enableKeyPan(value: boolean) {
110
- this._enableKeyPan = value;
111
- }
112
-
113
- public get enablePan(): boolean {
114
- return this._enablePan;
115
- }
116
-
117
- public set enablePan(value: boolean) {
118
- this._enablePan = value;
119
- }
120
-
121
- public get enablePolarRotation(): boolean {
122
- return this._enablePolarRotation;
123
- }
124
-
125
- public set enablePolarRotation(value: boolean) {
126
- this._enablePolarRotation = value;
127
- }
128
-
129
- public get enableRotation(): boolean {
130
- return this._enableRotation;
131
- }
132
-
133
- public set enableRotation(value: boolean) {
134
- this._enableRotation = value;
135
- }
136
-
137
- public get enableTurntableControls(): boolean {
138
- return this._enableTurntableControls;
139
- }
140
-
141
- public set enableTurntableControls(value: boolean) {
142
- this._enableTurntableControls = value;
143
- }
144
-
145
- public get enableZoom(): boolean {
146
- return this._enableZoom;
147
- }
148
-
149
- public set enableZoom(value: boolean) {
150
- this._enableZoom = value;
151
- }
152
-
153
- public get input(): { keys: { up: number, down: number, left: number, right: number }, mouse: { rotate: number, zoom: number, pan: number }, touch: { rotate: number, zoom: number, pan: number } } {
154
- return this._input;
155
- }
156
-
157
- public set input(value: { keys: { up: number, down: number, left: number, right: number }, mouse: { rotate: number, zoom: number, pan: number }, touch: { rotate: number, zoom: number, pan: number } }) {
158
- this._input = value;
159
- }
160
-
161
- public get keyPanSpeed(): number {
162
- return this._keyPanSpeed;
163
- }
164
-
165
- public set keyPanSpeed(value: number) {
166
- this._keyPanSpeed = value;
167
- }
168
-
169
- public get movementSmoothness(): number {
170
- return this._movementSmoothness;
171
- }
172
-
173
- public set movementSmoothness(value: number) {
174
- this._movementSmoothness = value;
175
- }
176
-
177
- public get panSpeed(): number {
178
- return this._panSpeed;
179
- }
180
-
181
- public set panSpeed(value: number) {
182
- this._panSpeed = value;
183
- }
184
-
185
- public get rotationRestriction(): { minPolarAngle: number, maxPolarAngle: number, minAzimuthAngle: number, maxAzimuthAngle: number } {
186
- return this._rotationRestriction;
187
- }
188
-
189
- public set rotationRestriction(value: { minPolarAngle: number, maxPolarAngle: number, minAzimuthAngle: number, maxAzimuthAngle: number }) {
190
- this._rotationRestriction = value;
191
- }
192
-
193
- public get rotationSpeed(): number {
194
- return this._rotationSpeed;
195
- }
196
-
197
- public set rotationSpeed(value: number) {
198
- this._rotationSpeed = value;
199
- }
200
-
201
- public get spherePositionRestriction(): { center: vec3, radius: number } {
202
- return this._spherePositionRestriction;
203
- }
204
-
205
- public set spherePositionRestriction(value: { center: vec3, radius: number }) {
206
- this._spherePositionRestriction = value;
207
- }
208
-
209
- public get sphereTargetRestriction(): { center: vec3, radius: number } {
210
- return this._sphereTargetRestriction;
211
- }
212
-
213
- public set sphereTargetRestriction(value: { center: vec3, radius: number }) {
214
- this._sphereTargetRestriction = value;
215
- }
216
-
217
- public get turntableCenter(): vec3 {
218
- return this._turntableCenter;
219
- }
220
-
221
- public set turntableCenter(value: vec3) {
222
- this._turntableCenter = value;
223
- }
224
-
225
- public get zoomRestriction(): { minDistance: number, maxDistance: number } {
226
- return this._zoomRestriction;
227
- }
228
-
229
- public set zoomRestriction(value: { minDistance: number, maxDistance: number }) {
230
- this._zoomRestriction = value;
231
- }
232
-
233
- public get zoomSpeed(): number {
234
- return this._zoomSpeed;
235
- }
236
-
237
- public set zoomSpeed(value: number) {
238
- this._zoomSpeed = value;
239
- }
240
-
241
- // #endregion Public Accessors (46)
242
-
243
- // #region Public Methods (1)
244
-
245
- public applySettings(settingsEngine: SettingsEngine) {
246
- const cameraSetting = settingsEngine.camera.cameras[this.camera.id];
247
- if (!cameraSetting) return;
248
- this.reset();
249
- const controlsSettings = <IOrbitControlsSettingsV3>cameraSetting.controls;
250
- this.autoRotationSpeed = controlsSettings.autoRotationSpeed;
251
- this.damping = controlsSettings.damping;
252
- this.enableAutoRotation = controlsSettings.enableAutoRotation;
253
- this.enableKeyPan = controlsSettings.enableKeyPan;
254
- this.enablePan = controlsSettings.enablePan;
255
- this.enableRotation = controlsSettings.enableRotation;
256
- this.enableZoom = controlsSettings.enableZoom;
257
- // this.input = controlsSettings.input;
258
- this.keyPanSpeed = controlsSettings.keyPanSpeed;
259
- this.movementSmoothness = controlsSettings.movementSmoothness;
260
- this.rotationSpeed = controlsSettings.rotationSpeed;
261
- this.panSpeed = controlsSettings.panSpeed;
262
- this.zoomSpeed = controlsSettings.zoomSpeed;
263
-
264
- if (controlsSettings.restrictions.position.cube.min.x === null) controlsSettings.restrictions.position.cube.min.x = -Infinity;
265
- if (controlsSettings.restrictions.position.cube.min.y === null) controlsSettings.restrictions.position.cube.min.y = -Infinity;
266
- if (controlsSettings.restrictions.position.cube.min.z === null) controlsSettings.restrictions.position.cube.min.z = -Infinity;
267
- if (controlsSettings.restrictions.position.cube.max.x === null) controlsSettings.restrictions.position.cube.max.x = Infinity;
268
- if (controlsSettings.restrictions.position.cube.max.y === null) controlsSettings.restrictions.position.cube.max.y = Infinity;
269
- if (controlsSettings.restrictions.position.cube.max.z === null) controlsSettings.restrictions.position.cube.max.z = Infinity;
270
- if (controlsSettings.restrictions.position.sphere.radius === null) controlsSettings.restrictions.position.sphere.radius = Infinity;
271
- if (controlsSettings.restrictions.target.cube.min.x === null) controlsSettings.restrictions.target.cube.min.x = -Infinity;
272
- if (controlsSettings.restrictions.target.cube.min.y === null) controlsSettings.restrictions.target.cube.min.y = -Infinity;
273
- if (controlsSettings.restrictions.target.cube.min.z === null) controlsSettings.restrictions.target.cube.min.z = -Infinity;
274
- if (controlsSettings.restrictions.target.cube.max.x === null) controlsSettings.restrictions.target.cube.max.x = Infinity;
275
- if (controlsSettings.restrictions.target.cube.max.y === null) controlsSettings.restrictions.target.cube.max.y = Infinity;
276
- if (controlsSettings.restrictions.target.cube.max.z === null) controlsSettings.restrictions.target.cube.max.z = Infinity;
277
- if (controlsSettings.restrictions.target.sphere.radius === null) controlsSettings.restrictions.target.sphere.radius = Infinity;
278
- if (controlsSettings.restrictions.rotation.minAzimuthAngle === null) controlsSettings.restrictions.rotation.minAzimuthAngle = -Infinity;
279
- if (controlsSettings.restrictions.rotation.maxAzimuthAngle === null) controlsSettings.restrictions.rotation.maxAzimuthAngle = Infinity;
280
- if (controlsSettings.restrictions.zoom.maxDistance === null) controlsSettings.restrictions.zoom.maxDistance = Infinity;
281
-
282
- this.cubePositionRestriction = {
283
- min: this._converter.toVec3(controlsSettings.restrictions.position.cube.min),
284
- max: this._converter.toVec3(controlsSettings.restrictions.position.cube.max)
285
- };
286
- this.spherePositionRestriction = {
287
- center: this._converter.toVec3(controlsSettings.restrictions.position.sphere.center),
288
- radius: controlsSettings.restrictions.position.sphere.radius
289
- };
290
- this.cubeTargetRestriction = {
291
- min: this._converter.toVec3(controlsSettings.restrictions.target.cube.min),
292
- max: this._converter.toVec3(controlsSettings.restrictions.target.cube.max)
293
- };
294
- this.sphereTargetRestriction = {
295
- center: this._converter.toVec3(controlsSettings.restrictions.target.sphere.center),
296
- radius: controlsSettings.restrictions.target.sphere.radius
297
- };
298
- this.rotationRestriction = controlsSettings.restrictions.rotation;
299
- this.zoomRestriction = controlsSettings.restrictions.zoom;
300
- }
301
-
302
- // #endregion Public Methods (1)
303
37
  }
@@ -1,38 +1,36 @@
1
- import * as TWEEN from '@tweenjs/tween.js'
2
- import { vec3 } from 'gl-matrix'
3
-
4
- import { CameraMultipleInterpolation } from './interpolationMethods/CameraMultipleInterpolation'
5
- import { CameraSphericalInterpolation } from './interpolationMethods/CameraSphericalInterpolation'
6
- import { ICameraControlsUsage } from '../../interfaces/controls/ICameraControlsUsage'
7
- import { ICamera, ICameraOptions } from '../../interfaces/camera/ICamera'
8
- import { CameraLinearInterpolation } from './interpolationMethods/CameraLinearInterpolation'
9
- import { CameraCylindricalInterpolation } from './interpolationMethods/CameraCylindricalInterpolation'
10
- import { ICameraInterpolation } from '../../interfaces/interpolation/ICameraInterpolation'
1
+ import * as TWEEN from '@tweenjs/tween.js';
2
+ import { CameraCylindricalInterpolation } from './interpolationMethods/CameraCylindricalInterpolation';
3
+ import { CameraLinearInterpolation } from './interpolationMethods/CameraLinearInterpolation';
4
+ import { CameraMultipleInterpolation } from './interpolationMethods/CameraMultipleInterpolation';
5
+ import { CameraSphericalInterpolation } from './interpolationMethods/CameraSphericalInterpolation';
6
+ import { ICamera, ICameraOptions } from '../../interfaces/camera/ICamera';
7
+ import { ICameraControls } from '../../interfaces/controls/ICameraControls';
8
+ import { ICameraInterpolation } from '../../interfaces/interpolation/ICameraInterpolation';
9
+ import { vec3 } from 'gl-matrix';
11
10
 
12
11
  export class CameraInterpolationManager {
13
- // #region Properties (3)
14
-
12
+ // #region Properties (2)
15
13
 
16
14
  private TweenWrapper = class {
17
15
  private _properties: { delta: 0 } = { delta: 0 };
18
- private _tween!: TWEEN.Tween<{ delta: number }>;
19
- private _resolve!: Function;
16
+ private _tween!: TWEEN.Tween<{ delta: number }>;
17
+ private _resolve!: (value: boolean | PromiseLike<boolean>) => void;
20
18
 
21
- constructor(options: {duration: number, easing: (amount: number) => number, coordinates: string, interpolation: Function }, cb: ICameraInterpolation, onComplete: Function) {
19
+ constructor(options: { duration: number, easing: (amount: number) => number, coordinates: string, interpolation: (v: number[], k: number) => number }, cb: ICameraInterpolation, onComplete: () => void) {
22
20
  this._tween = new TWEEN.Tween(this._properties);
23
- this._tween.easing(options.easing);
21
+ this._tween.easing(options.easing);
24
22
  this._tween.to({ delta: 1.0 }, options.duration);
25
23
 
26
24
  this._tween.onUpdate((v) => {
27
25
  cb.onUpdate(v);
28
26
  });
29
-
27
+
30
28
  this._tween.onStop((v) => {
31
- if(cb.onStop) cb.onStop(v);
29
+ if (cb.onStop) cb.onStop(v);
32
30
  this._resolve(true);
33
31
  });
34
32
  this._tween.onComplete((v) => {
35
- if(cb.onComplete) cb.onComplete(v);
33
+ if (cb.onComplete) cb.onComplete(v);
36
34
  onComplete();
37
35
  this._resolve(true);
38
36
  });
@@ -51,14 +49,14 @@ export class CameraInterpolationManager {
51
49
  };
52
50
  private _tween: any;
53
51
 
54
- // #endregion Properties (3)
52
+ // #endregion Properties (2)
55
53
 
56
54
  // #region Constructors (1)
57
55
 
58
56
  constructor(
59
57
  private readonly _camera: ICamera,
60
- private readonly _cameraControls: ICameraControlsUsage
61
- ) {
58
+ private readonly _cameraControls: ICameraControls
59
+ ) {
62
60
  }
63
61
 
64
62
  // #endregion Constructors (1)
@@ -68,38 +66,36 @@ export class CameraInterpolationManager {
68
66
  public active(): boolean {
69
67
  return this._tween ? true : false;
70
68
  }
69
+
71
70
  /**
72
71
  * cameraTween
73
72
  */
74
- public interpolate(path: { position: vec3, target: vec3 }[], options: ICameraOptions = {}) : Promise<boolean>
75
- {
76
-
73
+ public interpolate(path: { position: vec3, target: vec3 }[], options: ICameraOptions = {}): Promise<boolean> {
77
74
  const newPath: { position: vec3, target: vec3 }[] = [];
78
- for(let i = 0; i < path.length; i++)
75
+ for (let i = 0; i < path.length; i++)
79
76
  newPath.push({
80
77
  position: path[i].position,
81
78
  target: path[i].target,
82
79
  });
83
-
84
80
 
85
- if(this._tween) {
81
+ if (this._tween) {
86
82
  this._tween.stop();
87
83
  this._tween = null;
88
84
  }
89
- let parsedOptions = this.optionsParser(options);
90
-
85
+ const parsedOptions = this.optionsParser(options);
86
+
91
87
  this._tween = new this.TweenWrapper(
92
- parsedOptions,
93
- newPath.length === 2 ?
88
+ parsedOptions,
89
+ newPath.length === 2 ?
94
90
  this.getCameraInterpolation(newPath[0], newPath[1], parsedOptions.coordinates) :
95
- new CameraMultipleInterpolation(this._camera, this._cameraControls, newPath, parsedOptions.interpolation),
91
+ new CameraMultipleInterpolation(this._camera, this._cameraControls, newPath, parsedOptions.interpolation),
96
92
  () => { this._tween = null; }
97
93
  );
98
94
  return this._tween.start();
99
95
  }
100
96
 
101
97
  public stop(): void {
102
- if(this._tween) this._tween.stop();
98
+ if (this._tween) this._tween.stop();
103
99
  this._tween = null;
104
100
  }
105
101
 
@@ -108,7 +104,7 @@ export class CameraInterpolationManager {
108
104
  // #region Private Methods (2)
109
105
 
110
106
  private getCameraInterpolation(from: { position: vec3, target: vec3 }, to: { position: vec3, target: vec3 }, type: string) {
111
- switch(type) {
107
+ switch (type) {
112
108
  case 'linear':
113
109
  return new CameraLinearInterpolation(this._camera, this._cameraControls, from, to);
114
110
  case 'spherical':
@@ -120,32 +116,31 @@ export class CameraInterpolationManager {
120
116
  }
121
117
  }
122
118
 
123
- private optionsParser(options: ICameraOptions): {duration: number, easing: (amount: number) => number, coordinates: string, interpolation: (v: number[], k: number) => number }
124
- {
119
+ private optionsParser(options: ICameraOptions): { duration: number, easing: (amount: number) => number, coordinates: string, interpolation: (v: number[], k: number) => number } {
125
120
  let easing = TWEEN.Easing.Quartic.InOut;
126
- if(typeof options.easing === 'string') {
121
+ if (typeof options.easing === 'string') {
127
122
  const keys = options.easing.split('.');
128
123
  const easingFamily = TWEEN.Easing[<keyof typeof TWEEN.Easing>keys[0]];
129
- if(easingFamily) {
124
+ if (easingFamily) {
130
125
  const easingFunction = easingFamily[<keyof typeof easingFamily>keys[1]];
131
- if(easingFunction) easing = easingFunction;
126
+ if (easingFunction) easing = easingFunction;
132
127
  }
133
- } else if(typeof options.easing === 'function') {
128
+ } else if (typeof options.easing === 'function') {
134
129
  easing = <(amount: number) => number>options.easing;
135
130
  }
136
131
 
137
132
  let interpolation = TWEEN.Interpolation.CatmullRom;
138
- if(typeof options.interpolation === 'string') {
133
+ if (typeof options.interpolation === 'string') {
139
134
  const interpolationFunction = TWEEN.Interpolation[<keyof typeof TWEEN.Interpolation>options.interpolation];
140
- if(interpolationFunction && interpolationFunction !== TWEEN.Interpolation.Utils) interpolation = <(v: number[], k: number) => number>interpolationFunction;
141
- } else if(typeof options.interpolation === 'function') {
135
+ if (interpolationFunction && interpolationFunction !== TWEEN.Interpolation.Utils) interpolation = <(v: number[], k: number) => number>interpolationFunction;
136
+ } else if (typeof options.interpolation === 'function') {
142
137
  interpolation = <(v: number[], k: number) => number>options.interpolation;
143
138
  }
144
139
 
145
140
  return {
146
141
  duration: options.duration && options.duration >= 0 ? options.duration : 0,
147
142
  easing,
148
- coordinates: options.coordinates !== 'spherical' && options.coordinates !== 'linear' && options.coordinates !== 'cylindrical' ? 'cylindrical' : options.coordinates,
143
+ coordinates: options.coordinates !== 'spherical' && options.coordinates !== 'linear' && options.coordinates !== 'cylindrical' ? 'cylindrical' : options.coordinates,
149
144
  interpolation
150
145
  };
151
146
  }