@shapediver/viewer.rendering-engine.camera-engine 2.10.1-rc.0 → 2.12.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.
- package/dist/implementation/CameraEngine.js +45 -41
- package/dist/implementation/CameraEngine.js.map +1 -1
- package/dist/implementation/camera/AbstractCamera.d.ts +5 -3
- package/dist/implementation/camera/AbstractCamera.d.ts.map +1 -1
- package/dist/implementation/camera/AbstractCamera.js +71 -36
- package/dist/implementation/camera/AbstractCamera.js.map +1 -1
- package/dist/implementation/camera/OrthographicCamera.js +72 -68
- package/dist/implementation/camera/OrthographicCamera.js.map +1 -1
- package/dist/implementation/camera/PerspectiveCamera.js +69 -65
- package/dist/implementation/camera/PerspectiveCamera.js.map +1 -1
- package/dist/implementation/controls/AbstractCameraControls.d.ts +13 -7
- package/dist/implementation/controls/AbstractCameraControls.d.ts.map +1 -1
- package/dist/implementation/controls/AbstractCameraControls.js +105 -68
- package/dist/implementation/controls/AbstractCameraControls.js.map +1 -1
- package/dist/implementation/controls/OrthographicCameraControls.d.ts.map +1 -1
- package/dist/implementation/controls/OrthographicCameraControls.js +16 -12
- package/dist/implementation/controls/OrthographicCameraControls.js.map +1 -1
- package/dist/implementation/controls/PerspectiveCameraControls.d.ts +15 -3
- package/dist/implementation/controls/PerspectiveCameraControls.d.ts.map +1 -1
- package/dist/implementation/controls/PerspectiveCameraControls.js +126 -92
- package/dist/implementation/controls/PerspectiveCameraControls.js.map +1 -1
- package/dist/implementation/controls/orthographic/CameraControlsEventDistribution.d.ts +3 -3
- package/dist/implementation/controls/orthographic/CameraControlsEventDistribution.d.ts.map +1 -1
- package/dist/implementation/controls/orthographic/CameraControlsEventDistribution.js +36 -24
- package/dist/implementation/controls/orthographic/CameraControlsEventDistribution.js.map +1 -1
- package/dist/implementation/controls/orthographic/CameraControlsLogic.d.ts.map +1 -1
- package/dist/implementation/controls/orthographic/CameraControlsLogic.js +70 -68
- package/dist/implementation/controls/orthographic/CameraControlsLogic.js.map +1 -1
- package/dist/implementation/controls/perspective/CameraControlsEventDistribution.d.ts +4 -4
- package/dist/implementation/controls/perspective/CameraControlsEventDistribution.d.ts.map +1 -1
- package/dist/implementation/controls/perspective/CameraControlsEventDistribution.js +44 -33
- package/dist/implementation/controls/perspective/CameraControlsEventDistribution.js.map +1 -1
- package/dist/implementation/controls/perspective/CameraControlsLogic.d.ts +3 -2
- package/dist/implementation/controls/perspective/CameraControlsLogic.d.ts.map +1 -1
- package/dist/implementation/controls/perspective/CameraControlsLogic.js +147 -121
- package/dist/implementation/controls/perspective/CameraControlsLogic.js.map +1 -1
- package/dist/implementation/interpolation/CameraInterpolationManager.js +38 -11
- package/dist/implementation/interpolation/CameraInterpolationManager.js.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.js +25 -21
- package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.js.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.js +12 -8
- package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.js.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.js +12 -8
- package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.js.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.js +12 -8
- package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.js.map +1 -1
- package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.js +19 -15
- package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.js.map +1 -1
- package/dist/index.js +19 -11
- package/dist/index.js.map +1 -1
- package/dist/interfaces/ICameraEngine.js +5 -2
- package/dist/interfaces/ICameraEngine.js.map +1 -1
- package/dist/interfaces/camera/ICamera.d.ts +9 -8
- package/dist/interfaces/camera/ICamera.d.ts.map +1 -1
- package/dist/interfaces/camera/ICamera.js +2 -1
- package/dist/interfaces/camera/IOrthographicCamera.js +5 -2
- package/dist/interfaces/camera/IOrthographicCamera.js.map +1 -1
- package/dist/interfaces/camera/IPerspectiveCamera.js +2 -1
- package/dist/interfaces/controls/ICameraControls.d.ts +4 -3
- package/dist/interfaces/controls/ICameraControls.d.ts.map +1 -1
- package/dist/interfaces/controls/ICameraControls.js +2 -1
- package/dist/interfaces/controls/ICameraControlsEventDistribution.js +2 -1
- package/dist/interfaces/controls/ICameraControlsLogic.d.ts +3 -2
- package/dist/interfaces/controls/ICameraControlsLogic.d.ts.map +1 -1
- package/dist/interfaces/controls/ICameraControlsLogic.js +2 -1
- package/dist/interfaces/controls/ICameraControlsUsage.js +2 -1
- package/dist/interfaces/controls/IOrthographicCameraControls.js +2 -1
- package/dist/interfaces/controls/IPerspectiveCameraControls.d.ts +4 -0
- package/dist/interfaces/controls/IPerspectiveCameraControls.d.ts.map +1 -1
- package/dist/interfaces/controls/IPerspectiveCameraControls.js +2 -1
- package/dist/interfaces/interpolation/ICameraInterpolation.js +2 -1
- package/package.json +8 -8
- package/src/implementation/camera/AbstractCamera.ts +44 -37
- package/src/implementation/controls/AbstractCameraControls.ts +113 -70
- package/src/implementation/controls/OrthographicCameraControls.ts +9 -9
- package/src/implementation/controls/PerspectiveCameraControls.ts +114 -73
- package/src/implementation/controls/orthographic/CameraControlsEventDistribution.ts +61 -56
- package/src/implementation/controls/orthographic/CameraControlsLogic.ts +45 -53
- package/src/implementation/controls/perspective/CameraControlsEventDistribution.ts +83 -80
- package/src/implementation/controls/perspective/CameraControlsLogic.ts +100 -81
- package/src/interfaces/camera/ICamera.ts +31 -26
- package/src/interfaces/controls/ICameraControls.ts +5 -5
- package/src/interfaces/controls/ICameraControlsLogic.ts +6 -2
- package/src/interfaces/controls/IPerspectiveCameraControls.ts +10 -2
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { mat4, vec3 } from 'gl-matrix'
|
|
2
|
-
import { EventEngine, EVENTTYPE } from '@shapediver/viewer.shared.services'
|
|
1
|
+
import { mat4, vec2, vec3 } from 'gl-matrix';
|
|
2
|
+
import { EventEngine, EVENTTYPE } from '@shapediver/viewer.shared.services';
|
|
3
3
|
|
|
4
|
-
import { CAMERA_TYPE } from '../../interfaces/ICameraEngine'
|
|
5
|
-
import { ICamera, ICameraOptions } from '../../interfaces/camera/ICamera'
|
|
6
|
-
import { ICameraControlsUsage } from '../../interfaces/controls/ICameraControlsUsage'
|
|
7
|
-
import { CameraInterpolationManager } from '../interpolation/CameraInterpolationManager'
|
|
8
|
-
import { ICameraControlsEventDistribution } from '../../interfaces/controls/ICameraControlsEventDistribution'
|
|
9
|
-
import { ICameraControlsLogic } from '../../interfaces/controls/ICameraControlsLogic'
|
|
4
|
+
import { CAMERA_TYPE } from '../../interfaces/ICameraEngine';
|
|
5
|
+
import { ICamera, ICameraOptions } from '../../interfaces/camera/ICamera';
|
|
6
|
+
import { ICameraControlsUsage } from '../../interfaces/controls/ICameraControlsUsage';
|
|
7
|
+
import { CameraInterpolationManager } from '../interpolation/CameraInterpolationManager';
|
|
8
|
+
import { ICameraControlsEventDistribution } from '../../interfaces/controls/ICameraControlsEventDistribution';
|
|
9
|
+
import { ICameraControlsLogic } from '../../interfaces/controls/ICameraControlsLogic';
|
|
10
10
|
|
|
11
11
|
export class AbstractCameraControls implements ICameraControlsUsage {
|
|
12
|
-
// #region Properties (
|
|
12
|
+
// #region Properties (15)
|
|
13
13
|
|
|
14
14
|
private readonly _cameraInterpolationManager: CameraInterpolationManager;
|
|
15
15
|
private readonly _eventEngine: EventEngine = EventEngine.instance;
|
|
@@ -25,6 +25,10 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
25
25
|
matrix?: mat4,
|
|
26
26
|
vector?: vec3
|
|
27
27
|
}[],
|
|
28
|
+
sceneRotation: {
|
|
29
|
+
theta: number,
|
|
30
|
+
phi: number
|
|
31
|
+
}[]
|
|
28
32
|
};
|
|
29
33
|
private _moving: boolean = false;
|
|
30
34
|
private _movingDuration: number = 0;
|
|
@@ -38,15 +42,20 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
38
42
|
matrix?: mat4,
|
|
39
43
|
vector?: vec3
|
|
40
44
|
}[],
|
|
45
|
+
sceneRotation: {
|
|
46
|
+
theta: number,
|
|
47
|
+
phi: number
|
|
48
|
+
}[]
|
|
41
49
|
};
|
|
42
50
|
private _position: vec3 = vec3.create();
|
|
51
|
+
private _sceneRotation: vec2 = vec2.create();
|
|
43
52
|
private _target: vec3 = vec3.create();
|
|
44
53
|
private _viewportId?: string;
|
|
45
54
|
|
|
46
55
|
protected _cameraControlsEventDistribution!: ICameraControlsEventDistribution;
|
|
47
56
|
protected _cameraLogic!: ICameraControlsLogic;
|
|
48
57
|
|
|
49
|
-
// #endregion Properties (
|
|
58
|
+
// #endregion Properties (15)
|
|
50
59
|
|
|
51
60
|
// #region Constructors (1)
|
|
52
61
|
|
|
@@ -56,17 +65,20 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
56
65
|
type: CAMERA_TYPE
|
|
57
66
|
) {
|
|
58
67
|
this._cameraInterpolationManager = new CameraInterpolationManager(this._camera, this);
|
|
59
|
-
this._manualInteractionTransformations = { position: [], target: [] };
|
|
60
|
-
this._nonmanualInteractionTransformations = { position: [], target: [] };
|
|
68
|
+
this._manualInteractionTransformations = { position: [], target: [], sceneRotation: [] };
|
|
69
|
+
this._nonmanualInteractionTransformations = { position: [], target: [], sceneRotation: [] };
|
|
61
70
|
}
|
|
62
71
|
|
|
63
72
|
// #endregion Constructors (1)
|
|
64
73
|
|
|
65
|
-
// #region Public Accessors (
|
|
74
|
+
// #region Public Accessors (13)
|
|
66
75
|
|
|
67
|
-
public
|
|
68
|
-
this.
|
|
69
|
-
|
|
76
|
+
public get camera(): ICamera {
|
|
77
|
+
return this._camera;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public set camera(value: ICamera) {
|
|
81
|
+
this._camera = value;
|
|
70
82
|
}
|
|
71
83
|
|
|
72
84
|
public get cameraControlsEventDistribution(): ICameraControlsEventDistribution {
|
|
@@ -88,9 +100,9 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
88
100
|
public set enabled(value: boolean) {
|
|
89
101
|
if (!value) {
|
|
90
102
|
this._manualInteraction = false;
|
|
91
|
-
this._manualInteractionTransformations = { position: [], target: [] };
|
|
103
|
+
this._manualInteractionTransformations = { position: [], target: [], sceneRotation: [] };
|
|
92
104
|
this._nonmanualInteraction = false;
|
|
93
|
-
this._nonmanualInteractionTransformations = { position: [], target: [] };
|
|
105
|
+
this._nonmanualInteractionTransformations = { position: [], target: [], sceneRotation: [] };
|
|
94
106
|
|
|
95
107
|
this._cameraControlsEventDistribution.reset();
|
|
96
108
|
this._cameraLogic.reset();
|
|
@@ -98,14 +110,6 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
98
110
|
this._enabled = value;
|
|
99
111
|
}
|
|
100
112
|
|
|
101
|
-
public get camera(): ICamera {
|
|
102
|
-
return this._camera;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
public set camera(value: ICamera) {
|
|
106
|
-
this._camera = value;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
113
|
public get position(): vec3 {
|
|
110
114
|
return this._position;
|
|
111
115
|
}
|
|
@@ -114,6 +118,14 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
114
118
|
this._position = value;
|
|
115
119
|
}
|
|
116
120
|
|
|
121
|
+
public get sceneRotation(): vec2 {
|
|
122
|
+
return this._sceneRotation;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public set sceneRotation(value: vec2) {
|
|
126
|
+
this._sceneRotation = value;
|
|
127
|
+
}
|
|
128
|
+
|
|
117
129
|
public get target(): vec3 {
|
|
118
130
|
return this._target;
|
|
119
131
|
}
|
|
@@ -122,72 +134,87 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
122
134
|
this._target = value;
|
|
123
135
|
}
|
|
124
136
|
|
|
125
|
-
// #endregion Public Accessors (
|
|
137
|
+
// #endregion Public Accessors (13)
|
|
126
138
|
|
|
127
|
-
// #region Public Methods (
|
|
139
|
+
// #region Public Methods (16)
|
|
128
140
|
|
|
129
141
|
public animate(path: { position: vec3, target: vec3 }[], options: ICameraOptions): Promise<boolean> {
|
|
130
|
-
if(options && options.duration === 0) {
|
|
131
|
-
this._position = path[path.length-1].position;
|
|
132
|
-
this._target = path[path.length-1].target;
|
|
142
|
+
if (options && options.duration === 0) {
|
|
143
|
+
this._position = path[path.length - 1].position;
|
|
144
|
+
this._target = path[path.length - 1].target;
|
|
133
145
|
return new Promise<boolean>(resolve => resolve(true));
|
|
134
146
|
}
|
|
135
|
-
|
|
147
|
+
|
|
136
148
|
this._manualInteraction = false;
|
|
137
|
-
this._manualInteractionTransformations = { position: [], target: [] };
|
|
149
|
+
this._manualInteractionTransformations = { position: [], target: [], sceneRotation: [] };
|
|
138
150
|
return this._cameraInterpolationManager.interpolate(path, options);
|
|
139
151
|
}
|
|
140
152
|
|
|
141
|
-
public
|
|
153
|
+
public applyPositionMatrix(matrix: mat4, manualInteraction?: boolean | undefined): void {
|
|
142
154
|
if (this._manualInteraction || manualInteraction) {
|
|
143
155
|
this._manualInteraction = true;
|
|
144
|
-
this._manualInteractionTransformations.position.push({
|
|
156
|
+
this._manualInteractionTransformations.position.push({ matrix });
|
|
145
157
|
} else {
|
|
146
158
|
this._nonmanualInteraction = true;
|
|
147
|
-
this._nonmanualInteractionTransformations.position.push({
|
|
159
|
+
this._nonmanualInteractionTransformations.position.push({ matrix });
|
|
148
160
|
}
|
|
149
161
|
}
|
|
150
162
|
|
|
151
|
-
public
|
|
163
|
+
public applyPositionVector(vector: vec3, manualInteraction?: boolean | undefined): void {
|
|
152
164
|
if (this._manualInteraction || manualInteraction) {
|
|
153
165
|
this._manualInteraction = true;
|
|
154
|
-
this._manualInteractionTransformations.
|
|
166
|
+
this._manualInteractionTransformations.position.push({ vector });
|
|
155
167
|
} else {
|
|
156
168
|
this._nonmanualInteraction = true;
|
|
157
|
-
this._nonmanualInteractionTransformations.
|
|
169
|
+
this._nonmanualInteractionTransformations.position.push({ vector });
|
|
158
170
|
}
|
|
159
171
|
}
|
|
160
172
|
|
|
161
|
-
public
|
|
173
|
+
public applyRotation(vector: vec2, manualInteraction?: boolean | undefined): void {
|
|
162
174
|
if (this._manualInteraction || manualInteraction) {
|
|
163
175
|
this._manualInteraction = true;
|
|
164
|
-
this._manualInteractionTransformations.
|
|
176
|
+
this._manualInteractionTransformations.sceneRotation.push({ theta: vector[0], phi: vector[1] });
|
|
165
177
|
} else {
|
|
166
178
|
this._nonmanualInteraction = true;
|
|
167
|
-
this._nonmanualInteractionTransformations.
|
|
179
|
+
this._nonmanualInteractionTransformations.sceneRotation.push({ theta: vector[0], phi: vector[1] });
|
|
168
180
|
}
|
|
169
181
|
}
|
|
170
182
|
|
|
171
183
|
public applyTargetMatrix(matrix: mat4, manualInteraction?: boolean | undefined): void {
|
|
172
184
|
if (this._manualInteraction || manualInteraction) {
|
|
173
185
|
this._manualInteraction = true;
|
|
174
|
-
this._manualInteractionTransformations.target.push({matrix});
|
|
186
|
+
this._manualInteractionTransformations.target.push({ matrix });
|
|
187
|
+
} else {
|
|
188
|
+
this._nonmanualInteraction = true;
|
|
189
|
+
this._nonmanualInteractionTransformations.target.push({ matrix });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
public applyTargetVector(vector: vec3, manualInteraction?: boolean | undefined): void {
|
|
194
|
+
if (this._manualInteraction || manualInteraction) {
|
|
195
|
+
this._manualInteraction = true;
|
|
196
|
+
this._manualInteractionTransformations.target.push({ vector });
|
|
175
197
|
} else {
|
|
176
198
|
this._nonmanualInteraction = true;
|
|
177
|
-
this._nonmanualInteractionTransformations.target.push({
|
|
199
|
+
this._nonmanualInteractionTransformations.target.push({ vector });
|
|
178
200
|
}
|
|
179
201
|
}
|
|
180
202
|
|
|
181
203
|
public applyUpMatrix(matrix: mat4, manualInteraction?: boolean | undefined): void {
|
|
182
204
|
// https://shapediver.atlassian.net/browse/SS-2949
|
|
183
|
-
throw new Error(
|
|
205
|
+
throw new Error('Method not implemented.');
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
public assignViewer(viewportId: string, canvas: HTMLCanvasElement) {
|
|
209
|
+
this._canvas = canvas;
|
|
210
|
+
this._viewportId = viewportId;
|
|
184
211
|
}
|
|
185
212
|
|
|
186
213
|
public getPositionWithManualUpdates(): vec3 {
|
|
187
214
|
let position = vec3.clone(this._position);
|
|
188
215
|
if (this._manualInteraction) {
|
|
189
216
|
for (let i = this._manualInteractionTransformations.position.length - 1; i >= 0; i--) {
|
|
190
|
-
if(this._manualInteractionTransformations.position[i].matrix) {
|
|
217
|
+
if (this._manualInteractionTransformations.position[i].matrix) {
|
|
191
218
|
position = vec3.transformMat4(position, position, this._manualInteractionTransformations.position[i].matrix!);
|
|
192
219
|
} else {
|
|
193
220
|
position = vec3.add(position, position, this._manualInteractionTransformations.position[i].vector!);
|
|
@@ -197,11 +224,15 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
197
224
|
return position;
|
|
198
225
|
}
|
|
199
226
|
|
|
227
|
+
public getPositionWithUpdates(): vec3 {
|
|
228
|
+
return this.getPosition();
|
|
229
|
+
}
|
|
230
|
+
|
|
200
231
|
public getTargetWithManualUpdates(): vec3 {
|
|
201
232
|
let target = vec3.clone(this._target);
|
|
202
233
|
if (this._manualInteraction) {
|
|
203
234
|
for (let i = this._manualInteractionTransformations.target.length - 1; i >= 0; i--) {
|
|
204
|
-
if(this._manualInteractionTransformations.target[i].matrix) {
|
|
235
|
+
if (this._manualInteractionTransformations.target[i].matrix) {
|
|
205
236
|
target = vec3.transformMat4(target, target, this._manualInteractionTransformations.target[i].matrix!);
|
|
206
237
|
} else {
|
|
207
238
|
target = vec3.add(target, target, this._manualInteractionTransformations.target[i].vector!);
|
|
@@ -211,10 +242,6 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
211
242
|
return target;
|
|
212
243
|
}
|
|
213
244
|
|
|
214
|
-
public getPositionWithUpdates(): vec3 {
|
|
215
|
-
return this.getPosition();
|
|
216
|
-
}
|
|
217
|
-
|
|
218
245
|
public getTargetWithUpdates(): vec3 {
|
|
219
246
|
return this.getTarget();
|
|
220
247
|
}
|
|
@@ -232,59 +259,61 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
232
259
|
this._cameraLogic.reset();
|
|
233
260
|
}
|
|
234
261
|
|
|
235
|
-
public update(time: number): { position: vec3, target: vec3 } {
|
|
236
|
-
if (!this._enabled)
|
|
237
|
-
return { position: vec3.clone(this._position), target: vec3.clone(this._target) };
|
|
262
|
+
public update(time: number): { position: vec3, target: vec3, sceneRotation: vec2 } {
|
|
263
|
+
if (!this._enabled)
|
|
264
|
+
return { position: vec3.clone(this._position), target: vec3.clone(this._target), sceneRotation: vec2.clone(this._sceneRotation) };
|
|
238
265
|
|
|
239
266
|
// reset all values
|
|
240
|
-
if(this._manualInteraction === true && this._cameraInterpolationManager.active())
|
|
241
|
-
this._cameraInterpolationManager.stop()
|
|
267
|
+
if (this._manualInteraction === true && this._cameraInterpolationManager.active())
|
|
268
|
+
this._cameraInterpolationManager.stop();
|
|
242
269
|
|
|
243
|
-
|
|
270
|
+
const { position, target, sceneRotation } = this._cameraLogic.restrict(this.getPosition(), this.getTarget(), this.getSceneRotation());
|
|
244
271
|
this._position = vec3.clone(position);
|
|
245
272
|
this._target = vec3.clone(target);
|
|
273
|
+
this._sceneRotation = sceneRotation ? vec2.clone(sceneRotation) : vec2.create();
|
|
246
274
|
|
|
247
275
|
this._manualInteraction = false;
|
|
248
|
-
this._manualInteractionTransformations = { position: [], target: [] };
|
|
276
|
+
this._manualInteractionTransformations = { position: [], target: [], sceneRotation: [] };
|
|
249
277
|
this._nonmanualInteraction = this._cameraInterpolationManager.active();
|
|
250
|
-
this._nonmanualInteractionTransformations = { position: [], target: [] };
|
|
278
|
+
this._nonmanualInteractionTransformations = { position: [], target: [], sceneRotation: [] };
|
|
251
279
|
|
|
252
280
|
this._cameraLogic.update(time, this._nonmanualInteraction);
|
|
253
281
|
|
|
254
282
|
const oldMovement = this._moving;
|
|
255
283
|
const cameraDefinition = {
|
|
256
284
|
position: vec3.clone(this._position),
|
|
257
|
-
target: vec3.clone(this._target)
|
|
285
|
+
target: vec3.clone(this._target),
|
|
286
|
+
sceneRotation: vec2.clone(this._sceneRotation)
|
|
258
287
|
};
|
|
259
288
|
|
|
260
289
|
this._movingDuration += time;
|
|
261
290
|
this._moving = (this._manualInteraction || this._nonmanualInteraction);
|
|
262
291
|
|
|
263
|
-
switch(true) {
|
|
292
|
+
switch (true) {
|
|
264
293
|
case oldMovement !== this._moving && this._moving === true:
|
|
265
294
|
this._eventEngine.emitEvent(EVENTTYPE.CAMERA.CAMERA_START, { viewportId: this._viewportId, cameraId: this.camera.id });
|
|
266
295
|
break;
|
|
267
296
|
case oldMovement !== this._moving && this._moving === false:
|
|
268
297
|
this._eventEngine.emitEvent(EVENTTYPE.CAMERA.CAMERA_END, { viewportId: this._viewportId, cameraId: this.camera.id });
|
|
269
298
|
break;
|
|
270
|
-
default:
|
|
299
|
+
default:
|
|
271
300
|
this._eventEngine.emitEvent(EVENTTYPE.CAMERA.CAMERA_MOVE, { viewportId: this._viewportId, cameraId: this.camera.id });
|
|
272
301
|
}
|
|
273
|
-
|
|
302
|
+
|
|
274
303
|
if (!this._moving) this._movingDuration = 0;
|
|
275
304
|
|
|
276
305
|
return cameraDefinition;
|
|
277
306
|
}
|
|
278
307
|
|
|
279
|
-
// #endregion Public Methods (
|
|
308
|
+
// #endregion Public Methods (16)
|
|
280
309
|
|
|
281
|
-
// #region Private Methods (
|
|
310
|
+
// #region Private Methods (3)
|
|
282
311
|
|
|
283
312
|
private getPosition(): vec3 {
|
|
284
313
|
let position = vec3.clone(this._position);
|
|
285
314
|
if (this._manualInteraction) {
|
|
286
315
|
for (let i = this._manualInteractionTransformations.position.length - 1; i >= 0; i--) {
|
|
287
|
-
if(this._manualInteractionTransformations.position[i].matrix) {
|
|
316
|
+
if (this._manualInteractionTransformations.position[i].matrix) {
|
|
288
317
|
position = vec3.transformMat4(position, position, this._manualInteractionTransformations.position[i].matrix!);
|
|
289
318
|
} else {
|
|
290
319
|
position = vec3.add(position, position, this._manualInteractionTransformations.position[i].vector!);
|
|
@@ -292,7 +321,7 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
292
321
|
}
|
|
293
322
|
} else if (this._nonmanualInteraction) {
|
|
294
323
|
for (let i = this._nonmanualInteractionTransformations.position.length - 1; i >= 0; i--) {
|
|
295
|
-
if(this._nonmanualInteractionTransformations.position[i].matrix) {
|
|
324
|
+
if (this._nonmanualInteractionTransformations.position[i].matrix) {
|
|
296
325
|
position = vec3.transformMat4(position, position, this._nonmanualInteractionTransformations.position[i].matrix!);
|
|
297
326
|
} else {
|
|
298
327
|
position = vec3.add(position, position, this._nonmanualInteractionTransformations.position[i].vector!);
|
|
@@ -302,11 +331,25 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
302
331
|
return position;
|
|
303
332
|
}
|
|
304
333
|
|
|
334
|
+
private getSceneRotation(): vec2 {
|
|
335
|
+
let sceneRotation = vec2.clone(this._sceneRotation);
|
|
336
|
+
if (this._manualInteraction) {
|
|
337
|
+
for (let i = this._manualInteractionTransformations.sceneRotation.length - 1; i >= 0; i--) {
|
|
338
|
+
sceneRotation = vec2.add(sceneRotation, sceneRotation, vec2.fromValues(this._manualInteractionTransformations.sceneRotation[i].theta, this._manualInteractionTransformations.sceneRotation[i].phi));
|
|
339
|
+
}
|
|
340
|
+
} else if (this._nonmanualInteraction) {
|
|
341
|
+
for (let i = this._nonmanualInteractionTransformations.sceneRotation.length - 1; i >= 0; i--) {
|
|
342
|
+
sceneRotation = vec2.add(sceneRotation, sceneRotation, vec2.fromValues(this._nonmanualInteractionTransformations.sceneRotation[i].theta, this._nonmanualInteractionTransformations.sceneRotation[i].phi));
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return sceneRotation;
|
|
346
|
+
}
|
|
347
|
+
|
|
305
348
|
private getTarget(): vec3 {
|
|
306
349
|
let target = vec3.clone(this._target);
|
|
307
350
|
if (this._manualInteraction) {
|
|
308
351
|
for (let i = this._manualInteractionTransformations.target.length - 1; i >= 0; i--) {
|
|
309
|
-
if(this._manualInteractionTransformations.target[i].matrix) {
|
|
352
|
+
if (this._manualInteractionTransformations.target[i].matrix) {
|
|
310
353
|
target = vec3.transformMat4(target, target, this._manualInteractionTransformations.target[i].matrix!);
|
|
311
354
|
} else {
|
|
312
355
|
target = vec3.add(target, target, this._manualInteractionTransformations.target[i].vector!);
|
|
@@ -314,7 +357,7 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
314
357
|
}
|
|
315
358
|
} else if (this._nonmanualInteraction) {
|
|
316
359
|
for (let i = this._nonmanualInteractionTransformations.target.length - 1; i >= 0; i--) {
|
|
317
|
-
if(this._nonmanualInteractionTransformations.target[i].matrix) {
|
|
360
|
+
if (this._nonmanualInteractionTransformations.target[i].matrix) {
|
|
318
361
|
target = vec3.transformMat4(target, target, this._nonmanualInteractionTransformations.target[i].matrix!);
|
|
319
362
|
} else {
|
|
320
363
|
target = vec3.add(target, target, this._nonmanualInteractionTransformations.target[i].vector!);
|
|
@@ -324,5 +367,5 @@ export class AbstractCameraControls implements ICameraControlsUsage {
|
|
|
324
367
|
return target;
|
|
325
368
|
}
|
|
326
369
|
|
|
327
|
-
// #endregion Private Methods (
|
|
370
|
+
// #endregion Private Methods (3)
|
|
328
371
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { IOrthographicControlsSettingsV3 } from '@shapediver/viewer.settings'
|
|
2
|
-
import { SettingsEngine, StateEngine } from '@shapediver/viewer.shared.services'
|
|
1
|
+
import { IOrthographicControlsSettingsV3 } from '@shapediver/viewer.settings';
|
|
2
|
+
import { SettingsEngine, StateEngine } from '@shapediver/viewer.shared.services';
|
|
3
3
|
|
|
4
|
-
import { CAMERA_TYPE, ICamera } from '../..'
|
|
5
|
-
import { IOrthographicCameraControls } from '../../interfaces/controls/IOrthographicCameraControls'
|
|
6
|
-
import { AbstractCameraControls } from './AbstractCameraControls'
|
|
4
|
+
import { CAMERA_TYPE, ICamera } from '../..';
|
|
5
|
+
import { IOrthographicCameraControls } from '../../interfaces/controls/IOrthographicCameraControls';
|
|
6
|
+
import { AbstractCameraControls } from './AbstractCameraControls';
|
|
7
7
|
import {
|
|
8
8
|
CameraControlsEventDistribution as OrthographicCameraControlsEventDistribution,
|
|
9
|
-
} from './orthographic/CameraControlsEventDistribution'
|
|
10
|
-
import { CameraControlsLogic as OrthographicCameraControlsLogic } from './orthographic/CameraControlsLogic'
|
|
9
|
+
} from './orthographic/CameraControlsEventDistribution';
|
|
10
|
+
import { CameraControlsLogic as OrthographicCameraControlsLogic } from './orthographic/CameraControlsLogic';
|
|
11
11
|
|
|
12
12
|
export class OrthographicCameraControls extends AbstractCameraControls implements IOrthographicCameraControls {
|
|
13
13
|
// #region Properties (9)
|
|
@@ -16,7 +16,7 @@ export class OrthographicCameraControls extends AbstractCameraControls implement
|
|
|
16
16
|
private _enableKeyPan: boolean = false;
|
|
17
17
|
private _enablePan: boolean = true;
|
|
18
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:
|
|
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
20
|
private _keyPanSpeed: number = 0.5;
|
|
21
21
|
private _movementSmoothness: number = 0.5;
|
|
22
22
|
private _panSpeed: number = 0.5;
|
|
@@ -43,7 +43,7 @@ export class OrthographicCameraControls extends AbstractCameraControls implement
|
|
|
43
43
|
this.enableKeyPan = controlsSettings.enableKeyPan;
|
|
44
44
|
this.enablePan = controlsSettings.enablePan;
|
|
45
45
|
this.enableZoom = controlsSettings.enableZoom;
|
|
46
|
-
this.input = controlsSettings.input;
|
|
46
|
+
// this.input = controlsSettings.input;
|
|
47
47
|
this.keyPanSpeed = controlsSettings.keyPanSpeed;
|
|
48
48
|
this.movementSmoothness = controlsSettings.movementSmoothness;
|
|
49
49
|
this.panSpeed = controlsSettings.panSpeed;
|