@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/viewer.rendering-engine.camera-engine",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Michael Oppitz <michael@shapediver.com>",
|
|
@@ -10,11 +10,10 @@
|
|
|
10
10
|
"test": "__tests__"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"dist",
|
|
14
|
-
"src",
|
|
15
13
|
"package.json",
|
|
14
|
+
"dist/",
|
|
16
15
|
"README.md",
|
|
17
|
-
"
|
|
16
|
+
"LICENSE"
|
|
18
17
|
],
|
|
19
18
|
"publishConfig": {
|
|
20
19
|
"access": "public"
|
|
@@ -39,15 +38,15 @@
|
|
|
39
38
|
"testEnvironment": "node"
|
|
40
39
|
},
|
|
41
40
|
"dependencies": {
|
|
42
|
-
"@shapediver/viewer.rendering-engine.rendering-engine": "3.3.
|
|
41
|
+
"@shapediver/viewer.rendering-engine.rendering-engine": "3.3.6",
|
|
43
42
|
"@shapediver/viewer.settings": "1.0.2",
|
|
44
|
-
"@shapediver/viewer.shared.math": "3.3.
|
|
45
|
-
"@shapediver/viewer.shared.node-tree": "3.3.
|
|
46
|
-
"@shapediver/viewer.shared.services": "3.3.
|
|
47
|
-
"@shapediver/viewer.shared.types": "3.3.
|
|
43
|
+
"@shapediver/viewer.shared.math": "3.3.6",
|
|
44
|
+
"@shapediver/viewer.shared.node-tree": "3.3.6",
|
|
45
|
+
"@shapediver/viewer.shared.services": "3.3.6",
|
|
46
|
+
"@shapediver/viewer.shared.types": "3.3.6",
|
|
48
47
|
"@tweenjs/tween.js": "^18.6.4",
|
|
49
48
|
"detect-it": "4.0.1",
|
|
50
49
|
"gl-matrix": "3.3.0"
|
|
51
50
|
},
|
|
52
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "13aea937b128a001e6e93be300674c4a04624c29"
|
|
53
52
|
}
|
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
import { AbstractCamera } from './camera/AbstractCamera';
|
|
2
|
-
import { Box } from '@shapediver/viewer.shared.math';
|
|
3
|
-
import { CAMERA_TYPE, ICameraEngine } from '../interfaces/ICameraEngine';
|
|
4
|
-
import { ICamera } from '../interfaces/camera/ICamera';
|
|
5
|
-
import { IRenderingEngine } from '@shapediver/viewer.rendering-engine.rendering-engine';
|
|
6
|
-
import { ISceneEvent } from '@shapediver/viewer.shared.types';
|
|
7
|
-
import {
|
|
8
|
-
ITree,
|
|
9
|
-
ITreeNode,
|
|
10
|
-
Tree,
|
|
11
|
-
TreeNode
|
|
12
|
-
} from '@shapediver/viewer.shared.node-tree';
|
|
13
|
-
import { ORTHOGRAPHIC_CAMERA_DIRECTION } from '../interfaces/camera/IOrthographicCamera';
|
|
14
|
-
import { OrthographicCamera } from './camera/OrthographicCamera';
|
|
15
|
-
import { OrthographicCameraControls } from './controls/OrthographicCameraControls';
|
|
16
|
-
import { PerspectiveCamera } from './camera/PerspectiveCamera';
|
|
17
|
-
import { PerspectiveCameraControls } from './controls/PerspectiveCameraControls';
|
|
18
|
-
import { vec3 } from 'gl-matrix';
|
|
19
|
-
import {
|
|
20
|
-
EventEngine,
|
|
21
|
-
EVENTTYPE,
|
|
22
|
-
IEvent,
|
|
23
|
-
Logger,
|
|
24
|
-
SettingsEngine,
|
|
25
|
-
ShapeDiverViewerCameraError,
|
|
26
|
-
StateEngine,
|
|
27
|
-
UuidGenerator,
|
|
28
|
-
} from '@shapediver/viewer.shared.services';
|
|
29
|
-
|
|
30
|
-
export class CameraEngine implements ICameraEngine {
|
|
31
|
-
// #region Properties (11)
|
|
32
|
-
|
|
33
|
-
private readonly _cameraNode: ITreeNode = new TreeNode('cameras');
|
|
34
|
-
private readonly _cameras: {
|
|
35
|
-
[key: string]: ICamera
|
|
36
|
-
} = {};
|
|
37
|
-
private readonly _eventEngine: EventEngine = EventEngine.instance;
|
|
38
|
-
private readonly _logger: Logger = Logger.instance;
|
|
39
|
-
private readonly _stateEngine: StateEngine = StateEngine.instance;
|
|
40
|
-
private readonly _tree: ITree = Tree.instance;
|
|
41
|
-
private readonly _uuidGenerator: UuidGenerator = UuidGenerator.instance;
|
|
42
|
-
|
|
43
|
-
private _camera: ICamera | null = null;
|
|
44
|
-
private _settingsApplied: boolean = false;
|
|
45
|
-
private _update?: () => void;
|
|
46
|
-
|
|
47
|
-
protected _boundingBox: Box = new Box();
|
|
48
|
-
|
|
49
|
-
// #endregion Properties (11)
|
|
50
|
-
|
|
51
|
-
// #region Constructors (1)
|
|
52
|
-
|
|
53
|
-
constructor(private readonly _renderingEngine: IRenderingEngine) {
|
|
54
|
-
this._tree.root.addChild(this._cameraNode);
|
|
55
|
-
this._cameraNode.restrictViewports = [this._renderingEngine.id];
|
|
56
|
-
|
|
57
|
-
this._eventEngine.addListener(EVENTTYPE.SCENE.SCENE_BOUNDING_BOX_CHANGE, (e: IEvent) => {
|
|
58
|
-
const viewerEvent = <ISceneEvent>e;
|
|
59
|
-
if (viewerEvent.viewportId === this._renderingEngine.id) {
|
|
60
|
-
this._boundingBox = new Box(viewerEvent.boundingBox!.min, viewerEvent.boundingBox!.max);
|
|
61
|
-
|
|
62
|
-
const cameras = this.cameras;
|
|
63
|
-
for (const c in cameras)
|
|
64
|
-
cameras[c].boundingBox = this._boundingBox.clone();
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
this._eventEngine.addListener(EVENTTYPE.VIEWPORT.VIEWPORT_UPDATED, (e: IEvent) => {
|
|
69
|
-
const viewerEvent = <ISceneEvent>e;
|
|
70
|
-
if (viewerEvent.viewportId === this._renderingEngine.id) {
|
|
71
|
-
this.searchForNewCameras();
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// #endregion Constructors (1)
|
|
77
|
-
|
|
78
|
-
// #region Public Getters And Setters (4)
|
|
79
|
-
|
|
80
|
-
public get camera(): ICamera | null {
|
|
81
|
-
return this._camera;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
public get cameras(): {
|
|
85
|
-
[key: string]: ICamera
|
|
86
|
-
} {
|
|
87
|
-
return this._cameras;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public get update(): (() => void) | undefined {
|
|
91
|
-
return this._update;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
public set update(value: (() => void) | undefined) {
|
|
95
|
-
this._update = value;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// #endregion Public Getters And Setters (4)
|
|
99
|
-
|
|
100
|
-
// #region Public Methods (8)
|
|
101
|
-
|
|
102
|
-
public activateCameraEvents(): void {
|
|
103
|
-
const cameras = this.cameras;
|
|
104
|
-
for (const c in cameras)
|
|
105
|
-
(<PerspectiveCameraControls | OrthographicCameraControls>cameras[c].controls).cameraControlsEventDistribution.activateCameraEvents();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public applySettings(settingsEngine: SettingsEngine) {
|
|
109
|
-
const cameras = this.cameras;
|
|
110
|
-
for (const c in cameras)
|
|
111
|
-
this.removeCamera(c);
|
|
112
|
-
|
|
113
|
-
for (const id in settingsEngine.settings.camera.cameras) {
|
|
114
|
-
const cameraSetting = settingsEngine.settings.camera.cameras[id];
|
|
115
|
-
if (cameraSetting.type === 'perspective') {
|
|
116
|
-
this.createCamera(CAMERA_TYPE.PERSPECTIVE, id);
|
|
117
|
-
} else {
|
|
118
|
-
const camera = this.createCamera(CAMERA_TYPE.ORTHOGRAPHIC, id);
|
|
119
|
-
(<OrthographicCamera>camera).direction = <ORTHOGRAPHIC_CAMERA_DIRECTION>cameraSetting.type;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
for (const c in cameras)
|
|
124
|
-
cameras[c].applySettings(settingsEngine);
|
|
125
|
-
|
|
126
|
-
const cameraKeys = Object.keys(settingsEngine.settings.camera.cameras);
|
|
127
|
-
|
|
128
|
-
if (cameraKeys.length > 0) {
|
|
129
|
-
if (!settingsEngine.settings.camera.cameraId) {
|
|
130
|
-
this.assignCamera(cameraKeys[0]);
|
|
131
|
-
} else {
|
|
132
|
-
this.assignCamera(settingsEngine.settings.camera.cameraId);
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
this.createDefaultCameras();
|
|
136
|
-
this.camera!.applySettings(settingsEngine);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
this._settingsApplied = true;
|
|
140
|
-
if (this._update) this._update();
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
public assignCamera(id: string): boolean {
|
|
144
|
-
const camera = this.cameras[id];
|
|
145
|
-
if (!camera) return false;
|
|
146
|
-
|
|
147
|
-
for (const c in this.cameras)
|
|
148
|
-
this.cameras[c].active = false;
|
|
149
|
-
|
|
150
|
-
this._camera = camera;
|
|
151
|
-
this._camera.active = true;
|
|
152
|
-
return true;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
public createCamera(type: CAMERA_TYPE, id?: string, isDefault: boolean = false): ICamera {
|
|
156
|
-
const cameras = this.cameras;
|
|
157
|
-
const cameraId = id || this._uuidGenerator.create();
|
|
158
|
-
if (cameras[cameraId])
|
|
159
|
-
throw new ShapeDiverViewerCameraError(`CameraEngine.createCamera: Camera (${type}) with this id (${cameraId}) already exists.`);
|
|
160
|
-
|
|
161
|
-
const initialAspectRatio = (<HTMLDivElement>this._renderingEngine.canvas.parentNode).clientWidth / (<HTMLDivElement>this._renderingEngine.canvas.parentNode).clientHeight;
|
|
162
|
-
const camera = CAMERA_TYPE.PERSPECTIVE === type ? new PerspectiveCamera(cameraId, undefined, initialAspectRatio, isDefault) : new OrthographicCamera(cameraId, undefined, isDefault);
|
|
163
|
-
camera.assignViewer(this._renderingEngine);
|
|
164
|
-
|
|
165
|
-
cameras[cameraId] = camera;
|
|
166
|
-
if (this._settingsApplied && this._renderingEngine.settingsEngine) {
|
|
167
|
-
camera.applySettings(this._renderingEngine.settingsEngine);
|
|
168
|
-
} else {
|
|
169
|
-
camera.zoomTo(undefined, { duration: 0 });
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
this._cameraNode.addData(camera);
|
|
173
|
-
if (this._update) this._update();
|
|
174
|
-
return camera;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
public createDefaultCameras(): void {
|
|
178
|
-
const topCamera = <OrthographicCamera>this.createCamera(CAMERA_TYPE.ORTHOGRAPHIC, 'top', true);
|
|
179
|
-
topCamera.direction = ORTHOGRAPHIC_CAMERA_DIRECTION.TOP;
|
|
180
|
-
const bottomCamera = <OrthographicCamera>this.createCamera(CAMERA_TYPE.ORTHOGRAPHIC, 'bottom', true);
|
|
181
|
-
bottomCamera.direction = ORTHOGRAPHIC_CAMERA_DIRECTION.BOTTOM;
|
|
182
|
-
const leftCamera = <OrthographicCamera>this.createCamera(CAMERA_TYPE.ORTHOGRAPHIC, 'left', true);
|
|
183
|
-
leftCamera.direction = ORTHOGRAPHIC_CAMERA_DIRECTION.LEFT;
|
|
184
|
-
const rightCamera = <OrthographicCamera>this.createCamera(CAMERA_TYPE.ORTHOGRAPHIC, 'right', true);
|
|
185
|
-
rightCamera.direction = ORTHOGRAPHIC_CAMERA_DIRECTION.RIGHT;
|
|
186
|
-
const frontCamera = <OrthographicCamera>this.createCamera(CAMERA_TYPE.ORTHOGRAPHIC, 'front', true);
|
|
187
|
-
frontCamera.direction = ORTHOGRAPHIC_CAMERA_DIRECTION.FRONT;
|
|
188
|
-
const backCamera = <OrthographicCamera>this.createCamera(CAMERA_TYPE.ORTHOGRAPHIC, 'back', true);
|
|
189
|
-
backCamera.direction = ORTHOGRAPHIC_CAMERA_DIRECTION.BACK;
|
|
190
|
-
this.createCamera(CAMERA_TYPE.ORTHOGRAPHIC, 'orthographic');
|
|
191
|
-
const camera = this.createCamera(CAMERA_TYPE.PERSPECTIVE, 'perspective');
|
|
192
|
-
this.assignCamera(camera.id);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
public deactivateCameraEvents(): void {
|
|
196
|
-
const cameras = this.cameras;
|
|
197
|
-
for (const c in cameras)
|
|
198
|
-
(<PerspectiveCameraControls | OrthographicCameraControls>cameras[c].controls).cameraControlsEventDistribution.deactivateCameraEvents();
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
public removeCamera(id: string): boolean {
|
|
202
|
-
const cameras = this.cameras;
|
|
203
|
-
const camera = cameras[id];
|
|
204
|
-
if (!camera) return false;
|
|
205
|
-
if (camera.domEventListenerToken) this._renderingEngine.domEventEngine.removeDomEventListener(camera.domEventListenerToken);
|
|
206
|
-
if (this._camera && this._camera.id === id)
|
|
207
|
-
this._camera = null;
|
|
208
|
-
|
|
209
|
-
delete cameras[id];
|
|
210
|
-
this._cameraNode.removeData(camera);
|
|
211
|
-
if (this._update) this._update();
|
|
212
|
-
return true;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
public saveSettings(settingsEngine: SettingsEngine) {
|
|
216
|
-
settingsEngine.settings.camera.cameraId = this._camera ? this._camera.id : 'perspective';
|
|
217
|
-
settingsEngine.settings.camera.cameras = {};
|
|
218
|
-
|
|
219
|
-
for (const c in this.cameras) {
|
|
220
|
-
const camera = this.cameras[c];
|
|
221
|
-
|
|
222
|
-
if (camera.type === CAMERA_TYPE.PERSPECTIVE) {
|
|
223
|
-
const controls = <PerspectiveCameraControls>(<PerspectiveCamera>camera).controls;
|
|
224
|
-
settingsEngine.camera.cameras[camera.id] = {
|
|
225
|
-
name: camera.name,
|
|
226
|
-
autoAdjust: camera.autoAdjust,
|
|
227
|
-
cameraMovementDuration: camera.cameraMovementDuration,
|
|
228
|
-
enableCameraControls: camera.enableCameraControls,
|
|
229
|
-
revertAtMouseUp: camera.revertAtMouseUp,
|
|
230
|
-
revertAtMouseUpDuration: camera.revertAtMouseUpDuration,
|
|
231
|
-
zoomExtentsFactor: camera.zoomExtentsFactor,
|
|
232
|
-
position: { x: camera.defaultPosition[0], y: camera.defaultPosition[1], z: camera.defaultPosition[2] },
|
|
233
|
-
target: { x: camera.defaultTarget[0], y: camera.defaultTarget[1], z: camera.defaultTarget[2] },
|
|
234
|
-
type: camera.type,
|
|
235
|
-
fov: (<PerspectiveCamera>camera).fov,
|
|
236
|
-
sceneRotation: { x: (<PerspectiveCamera>camera).sceneRotation[0], y: (<PerspectiveCamera>camera).sceneRotation[1] },
|
|
237
|
-
controls: {
|
|
238
|
-
autoRotationSpeed: controls.autoRotationSpeed,
|
|
239
|
-
damping: controls.damping,
|
|
240
|
-
enableAutoRotation: controls.enableAutoRotation,
|
|
241
|
-
enableKeyPan: controls.enableKeyPan,
|
|
242
|
-
enablePan: controls.enablePan,
|
|
243
|
-
enableRotation: controls.enableRotation,
|
|
244
|
-
enableZoom: controls.enableZoom,
|
|
245
|
-
input: controls.input,
|
|
246
|
-
keyPanSpeed: controls.keyPanSpeed,
|
|
247
|
-
movementSmoothness: controls.movementSmoothness,
|
|
248
|
-
rotationSpeed: controls.rotationSpeed,
|
|
249
|
-
panSpeed: controls.panSpeed,
|
|
250
|
-
zoomSpeed: controls.zoomSpeed,
|
|
251
|
-
restrictions: {
|
|
252
|
-
position: {
|
|
253
|
-
cube: {
|
|
254
|
-
min: { x: controls.cubePositionRestriction.min[0], y: controls.cubePositionRestriction.min[1], z: controls.cubePositionRestriction.min[2] },
|
|
255
|
-
max: { x: controls.cubePositionRestriction.max[0], y: controls.cubePositionRestriction.max[1], z: controls.cubePositionRestriction.max[2] },
|
|
256
|
-
},
|
|
257
|
-
sphere: {
|
|
258
|
-
center: { x: controls.spherePositionRestriction.center[0], y: controls.spherePositionRestriction.center[1], z: controls.spherePositionRestriction.center[2] },
|
|
259
|
-
radius: controls.spherePositionRestriction.radius,
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
target: {
|
|
263
|
-
cube: {
|
|
264
|
-
min: { x: controls.cubeTargetRestriction.min[0], y: controls.cubeTargetRestriction.min[1], z: controls.cubeTargetRestriction.min[2] },
|
|
265
|
-
max: { x: controls.cubeTargetRestriction.max[0], y: controls.cubeTargetRestriction.max[1], z: controls.cubeTargetRestriction.max[2] },
|
|
266
|
-
},
|
|
267
|
-
sphere: {
|
|
268
|
-
center: { x: controls.sphereTargetRestriction.center[0], y: controls.sphereTargetRestriction.center[1], z: controls.sphereTargetRestriction.center[2] },
|
|
269
|
-
radius: controls.sphereTargetRestriction.radius,
|
|
270
|
-
},
|
|
271
|
-
},
|
|
272
|
-
rotation: controls.rotationRestriction,
|
|
273
|
-
zoom: controls.zoomRestriction,
|
|
274
|
-
},
|
|
275
|
-
enableAzimuthRotation: controls.enableAzimuthRotation,
|
|
276
|
-
enablePolarRotation: controls.enablePolarRotation,
|
|
277
|
-
enableObjectControls: controls.enableObjectControls,
|
|
278
|
-
enableTurntableControls: controls.enableTurntableControls,
|
|
279
|
-
turntableCenter: { x: controls.turntableCenter[0], y: controls.turntableCenter[1], z: controls.turntableCenter[2] },
|
|
280
|
-
objectControlsCenter: { x: controls.objectControlsCenter[0], y: controls.objectControlsCenter[1], z: controls.objectControlsCenter[2] },
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
} else {
|
|
285
|
-
if (settingsEngine.camera.cameras[camera.id]) {
|
|
286
|
-
const previousDirection = settingsEngine.camera.cameras[camera.id].type;
|
|
287
|
-
|
|
288
|
-
// if the direction changed, but the default position & target did not, there is an issue
|
|
289
|
-
if (previousDirection !== camera.type && (
|
|
290
|
-
settingsEngine.camera.cameras[camera.id].position.x === camera.defaultPosition[0] &&
|
|
291
|
-
settingsEngine.camera.cameras[camera.id].position.y === camera.defaultPosition[1] &&
|
|
292
|
-
settingsEngine.camera.cameras[camera.id].position.z === camera.defaultPosition[2] &&
|
|
293
|
-
settingsEngine.camera.cameras[camera.id].target.x === camera.defaultTarget[0] &&
|
|
294
|
-
settingsEngine.camera.cameras[camera.id].target.y === camera.defaultTarget[1] &&
|
|
295
|
-
settingsEngine.camera.cameras[camera.id].target.z === camera.defaultTarget[2]
|
|
296
|
-
)) {
|
|
297
|
-
camera.defaultPosition = vec3.clone(camera.position);
|
|
298
|
-
camera.defaultTarget = vec3.clone(camera.target);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
const controls = <OrthographicCameraControls>(<OrthographicCamera>camera).controls;
|
|
302
|
-
|
|
303
|
-
settingsEngine.camera.cameras[camera.id] = {
|
|
304
|
-
name: camera.name,
|
|
305
|
-
autoAdjust: camera.autoAdjust,
|
|
306
|
-
cameraMovementDuration: camera.cameraMovementDuration,
|
|
307
|
-
enableCameraControls: camera.enableCameraControls,
|
|
308
|
-
revertAtMouseUp: camera.revertAtMouseUp,
|
|
309
|
-
revertAtMouseUpDuration: camera.revertAtMouseUpDuration,
|
|
310
|
-
zoomExtentsFactor: camera.zoomExtentsFactor,
|
|
311
|
-
position: { x: camera.defaultPosition[0], y: camera.defaultPosition[1], z: camera.defaultPosition[2] },
|
|
312
|
-
target: { x: camera.defaultTarget[0], y: camera.defaultTarget[1], z: camera.defaultTarget[2] },
|
|
313
|
-
type: (<OrthographicCamera>camera).direction,
|
|
314
|
-
sceneRotation: { x: (<OrthographicCamera>camera).sceneRotation[0], y: (<OrthographicCamera>camera).sceneRotation[1] },
|
|
315
|
-
controls: {
|
|
316
|
-
autoRotationSpeed: controls.autoRotationSpeed,
|
|
317
|
-
damping: controls.damping,
|
|
318
|
-
enableAutoRotation: controls.enableAutoRotation,
|
|
319
|
-
enableKeyPan: controls.enableKeyPan,
|
|
320
|
-
enablePan: controls.enablePan,
|
|
321
|
-
enableRotation: controls.enableRotation,
|
|
322
|
-
enableZoom: controls.enableZoom,
|
|
323
|
-
input: controls.input,
|
|
324
|
-
keyPanSpeed: controls.keyPanSpeed,
|
|
325
|
-
movementSmoothness: controls.movementSmoothness,
|
|
326
|
-
rotationSpeed: controls.rotationSpeed,
|
|
327
|
-
panSpeed: controls.panSpeed,
|
|
328
|
-
zoomSpeed: controls.zoomSpeed,
|
|
329
|
-
restrictions: {
|
|
330
|
-
position: {
|
|
331
|
-
cube: {
|
|
332
|
-
min: { x: controls.cubePositionRestriction.min[0], y: controls.cubePositionRestriction.min[1], z: controls.cubePositionRestriction.min[2] },
|
|
333
|
-
max: { x: controls.cubePositionRestriction.max[0], y: controls.cubePositionRestriction.max[1], z: controls.cubePositionRestriction.max[2] },
|
|
334
|
-
},
|
|
335
|
-
sphere: {
|
|
336
|
-
center: { x: controls.spherePositionRestriction.center[0], y: controls.spherePositionRestriction.center[1], z: controls.spherePositionRestriction.center[2] },
|
|
337
|
-
radius: controls.spherePositionRestriction.radius,
|
|
338
|
-
},
|
|
339
|
-
},
|
|
340
|
-
target: {
|
|
341
|
-
cube: {
|
|
342
|
-
min: { x: controls.cubeTargetRestriction.min[0], y: controls.cubeTargetRestriction.min[1], z: controls.cubeTargetRestriction.min[2] },
|
|
343
|
-
max: { x: controls.cubeTargetRestriction.max[0], y: controls.cubeTargetRestriction.max[1], z: controls.cubeTargetRestriction.max[2] },
|
|
344
|
-
},
|
|
345
|
-
sphere: {
|
|
346
|
-
center: { x: controls.sphereTargetRestriction.center[0], y: controls.sphereTargetRestriction.center[1], z: controls.sphereTargetRestriction.center[2] },
|
|
347
|
-
radius: controls.sphereTargetRestriction.radius,
|
|
348
|
-
},
|
|
349
|
-
},
|
|
350
|
-
rotation: controls.rotationRestriction,
|
|
351
|
-
zoom: controls.zoomRestriction,
|
|
352
|
-
},
|
|
353
|
-
enableAzimuthRotation: controls.enableAzimuthRotation,
|
|
354
|
-
enablePolarRotation: controls.enablePolarRotation,
|
|
355
|
-
enableObjectControls: controls.enableObjectControls,
|
|
356
|
-
enableTurntableControls: controls.enableTurntableControls,
|
|
357
|
-
turntableCenter: { x: controls.turntableCenter[0], y: controls.turntableCenter[1], z: controls.turntableCenter[2] },
|
|
358
|
-
objectControlsCenter: { x: controls.objectControlsCenter[0], y: controls.objectControlsCenter[1], z: controls.objectControlsCenter[2] },
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// #endregion Public Methods (8)
|
|
366
|
-
|
|
367
|
-
// #region Private Methods (1)
|
|
368
|
-
|
|
369
|
-
private searchForNewCameras() {
|
|
370
|
-
const getCameraData = (node: ITreeNode) => {
|
|
371
|
-
for (let i = 0; i < node.data.length; i++)
|
|
372
|
-
if ((node.data[i] instanceof AbstractCamera) && !this._cameras[node.data[i].id]) {
|
|
373
|
-
const camera = <AbstractCamera>node.data[i];
|
|
374
|
-
if (camera.viewportId === this._renderingEngine.id)
|
|
375
|
-
this._cameras[camera.id] = camera;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
for (let i = 0; i < node.children.length; i++)
|
|
379
|
-
getCameraData(node.children[i]);
|
|
380
|
-
};
|
|
381
|
-
getCameraData(this._tree.root);
|
|
382
|
-
if (this._update) this._update();
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// #endregion Private Methods (1)
|
|
386
|
-
}
|