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