@shopware-ag/dive 1.19.0 → 1.19.1-beta.1
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/build/dive.cjs +388 -220
- package/build/dive.cjs.map +1 -1
- package/build/dive.js +395 -21946
- package/build/dive.js.map +1 -1
- package/build/dive.mjs +28206 -0
- package/build/dive.mjs.map +1 -0
- package/build/src/ar/AR.d.ts +37 -14
- package/build/src/ar/arquicklook/ARQuickLook.d.ts +5 -6
- package/build/src/ar/sceneviewer/SceneViewer.d.ts +42 -6
- package/build/src/com/actions/scene/launchar.d.ts +5 -2
- package/build/src/converter/Converter.d.ts +21 -0
- package/build/src/dive.d.ts +3 -2
- package/build/src/exporter/Exporter.d.ts +11 -0
- package/build/src/helper/applyMixins/applyMixins.d.ts +22 -6
- package/build/src/info/Info.d.ts +37 -13
- package/build/src/interface/Movable.d.ts +5 -5
- package/build/src/interface/Selectable.d.ts +4 -4
- package/build/src/loader/Loader.d.ts +11 -0
- package/build/src/model/Model.d.ts +2 -2
- package/build/src/node/Node.d.ts +3 -3
- package/build/src/scene/root/Root.d.ts +1 -1
- package/build/src/types/ExporterOptions.d.ts +15 -0
- package/build/src/types/FileTypes.d.ts +27 -0
- package/build/src/types/index.d.ts +4 -0
- package/build/src/types/info/index.d.ts +66 -0
- package/package.json +17 -3
- package/build/src/exporters/usdz/USDZExporter.d.ts +0 -15
- package/build/src/loadingmanager/LoadingManager.d.ts +0 -14
- package/src/__test__/DIVE.test.ts +0 -274
- package/src/animation/AnimationSystem.ts +0 -34
- package/src/animation/__test__/AnimationSystem.test.ts +0 -40
- package/src/ar/AR.ts +0 -98
- package/src/ar/__test__/AR.test.ts +0 -187
- package/src/ar/arquicklook/ARQuickLook.ts +0 -93
- package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +0 -93
- package/src/ar/sceneviewer/SceneViewer.ts +0 -74
- package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +0 -93
- package/src/ar/webxr/WebXR.ts +0 -176
- package/src/ar/webxr/controller/WebXRController.ts +0 -340
- package/src/ar/webxr/crosshair/WebXRCrosshair.ts +0 -35
- package/src/ar/webxr/origin/WebXROrigin.ts +0 -192
- package/src/ar/webxr/overlay/Overlay.ts +0 -50
- package/src/ar/webxr/raycaster/WebXRRaycaster.ts +0 -131
- package/src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts +0 -102
- package/src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts +0 -49
- package/src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts +0 -356
- package/src/axiscamera/AxisCamera.ts +0 -108
- package/src/axiscamera/__test__/AxisCamera.test.ts +0 -150
- package/src/camera/PerspectiveCamera.ts +0 -63
- package/src/camera/__test__/PerspectiveCamera.test.ts +0 -36
- package/src/com/Communication.ts +0 -808
- package/src/com/__test__/Communication.test.ts +0 -1024
- package/src/com/actions/camera/computeencompassingview.ts +0 -10
- package/src/com/actions/camera/getcameratransform.ts +0 -10
- package/src/com/actions/camera/movecamera.ts +0 -18
- package/src/com/actions/camera/resetcamera.ts +0 -5
- package/src/com/actions/camera/setcameralayer.ts +0 -5
- package/src/com/actions/camera/setcameratransform.ts +0 -10
- package/src/com/actions/camera/zoomcamera.ts +0 -5
- package/src/com/actions/index.ts +0 -61
- package/src/com/actions/media/generatemedia.ts +0 -18
- package/src/com/actions/object/addobject.ts +0 -7
- package/src/com/actions/object/deleteobject.ts +0 -7
- package/src/com/actions/object/deselectobject.ts +0 -7
- package/src/com/actions/object/getallobjects.ts +0 -7
- package/src/com/actions/object/getobjects.ts +0 -7
- package/src/com/actions/object/model/dropit.ts +0 -5
- package/src/com/actions/object/model/modelloaded.ts +0 -5
- package/src/com/actions/object/model/placeonfloor.ts +0 -5
- package/src/com/actions/object/selectobject.ts +0 -7
- package/src/com/actions/object/setparent.ts +0 -10
- package/src/com/actions/object/updateobject.ts +0 -7
- package/src/com/actions/renderer/startrender.ts +0 -5
- package/src/com/actions/scene/exportscene.ts +0 -7
- package/src/com/actions/scene/getallscenedata.ts +0 -7
- package/src/com/actions/scene/launchar.ts +0 -7
- package/src/com/actions/scene/setbackground.ts +0 -5
- package/src/com/actions/scene/updatescene.ts +0 -11
- package/src/com/actions/toolbox/select/setgizmomode.ts +0 -5
- package/src/com/actions/toolbox/transform/setgizmoscalelinked.ts +0 -5
- package/src/com/actions/toolbox/transform/setgizmovisible.ts +0 -5
- package/src/com/actions/toolbox/usetool.ts +0 -7
- package/src/com/types/COMBaseEntity.ts +0 -9
- package/src/com/types/COMEntity.ts +0 -7
- package/src/com/types/COMEntityType.ts +0 -1
- package/src/com/types/COMGeometry.ts +0 -8
- package/src/com/types/COMGeometryType.ts +0 -9
- package/src/com/types/COMGroup.ts +0 -9
- package/src/com/types/COMLight.ts +0 -11
- package/src/com/types/COMMaterial.ts +0 -12
- package/src/com/types/COMModel.ts +0 -12
- package/src/com/types/COMPov.ts +0 -8
- package/src/com/types/COMPrimitive.ts +0 -12
- package/src/com/types/index.ts +0 -23
- package/src/constant/AxisHelperColors.ts +0 -7
- package/src/constant/GridColors.ts +0 -2
- package/src/constant/VisibilityLayerMask.ts +0 -5
- package/src/controls/OrbitControls.ts +0 -211
- package/src/controls/__test__/OrbitControls.test.ts +0 -256
- package/src/dive.ts +0 -363
- package/src/events/EventExecutor.ts +0 -35
- package/src/exporters/usdz/USDZExporter.ts +0 -21
- package/src/exporters/usdz/__test__/USDZExporter.test.ts +0 -57
- package/src/gizmo/Gizmo.ts +0 -144
- package/src/gizmo/handles/AxisHandle.ts +0 -153
- package/src/gizmo/handles/RadialHandle.ts +0 -149
- package/src/gizmo/handles/ScaleHandle.ts +0 -195
- package/src/gizmo/plane/GizmoPlane.ts +0 -84
- package/src/gizmo/rotate/RotateGizmo.ts +0 -143
- package/src/gizmo/scale/ScaleGizmo.ts +0 -125
- package/src/gizmo/translate/TranslateGizmo.ts +0 -114
- package/src/grid/Grid.ts +0 -34
- package/src/grid/__test__/Grid.test.ts +0 -28
- package/src/group/Group.ts +0 -184
- package/src/group/__test__/Group.test.ts +0 -212
- package/src/helper/applyMixins/__test__/applyMixins.test.ts +0 -30
- package/src/helper/applyMixins/applyMixins.ts +0 -18
- package/src/helper/findInterface/__test__/findInterface.test.ts +0 -63
- package/src/helper/findInterface/findInterface.ts +0 -13
- package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +0 -40
- package/src/helper/findSceneRecursive/findSceneRecursive.ts +0 -16
- package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +0 -186
- package/src/helper/getObjectDelta/getObjectDelta.ts +0 -105
- package/src/helper/isInterface/__test__/implementsInterface.test.ts +0 -19
- package/src/helper/isInterface/implementsInterface.ts +0 -9
- package/src/info/Info.ts +0 -154
- package/src/info/__test__/Info.test.ts +0 -338
- package/src/interface/Draggable.ts +0 -14
- package/src/interface/Hoverable.ts +0 -14
- package/src/interface/Movable.ts +0 -12
- package/src/interface/Rotatable.ts +0 -10
- package/src/interface/Scalable.ts +0 -10
- package/src/interface/Selectable.ts +0 -11
- package/src/io/IO.ts +0 -62
- package/src/io/__test__/IO.test.ts +0 -116
- package/src/io/gltf/GLTFIO.ts +0 -56
- package/src/io/gltf/__test__/GLTFIO.test.ts +0 -108
- package/src/light/AmbientLight.ts +0 -39
- package/src/light/PointLight.ts +0 -115
- package/src/light/SceneLight.ts +0 -63
- package/src/light/__test__/AmbientLight.test.ts +0 -29
- package/src/light/__test__/PointLight.test.ts +0 -74
- package/src/light/__test__/SceneLight.test.ts +0 -47
- package/src/loadingmanager/LoadingManager.ts +0 -50
- package/src/loadingmanager/__test__/LoadingManager.test.ts +0 -27
- package/src/math/__test__/DIVEMath.test.ts +0 -12
- package/src/math/ceil/__test__/ceilExp.test.ts +0 -12
- package/src/math/ceil/ceilExp.ts +0 -6
- package/src/math/degToRad/__test__/degToRad.test.ts +0 -172
- package/src/math/degToRad/degToRad.ts +0 -5
- package/src/math/floor/__test__/floorExp.test.ts +0 -14
- package/src/math/floor/floorExp.ts +0 -6
- package/src/math/helper/__test__/shift.test.ts +0 -12
- package/src/math/helper/shift.ts +0 -4
- package/src/math/index.ts +0 -28
- package/src/math/radToDeg/__test__/radToDeg.test.ts +0 -155
- package/src/math/radToDeg/radToDeg.ts +0 -5
- package/src/math/round/__test__/roundExp.test.ts +0 -14
- package/src/math/round/roundExp.ts +0 -10
- package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +0 -20
- package/src/math/signedAngleTo/signedAngleTo.ts +0 -20
- package/src/math/toFixed/__test__/toFixedExp.test.ts +0 -14
- package/src/math/toFixed/toFixedExp.ts +0 -9
- package/src/math/truncate/__test__/truncateExp.test.ts +0 -14
- package/src/math/truncate/truncateExp.ts +0 -9
- package/src/mediacreator/MediaCreator.ts +0 -75
- package/src/mediacreator/__test__/MediaCreator.test.ts +0 -155
- package/src/model/Model.ts +0 -185
- package/src/model/__test__/Model.test.ts +0 -222
- package/src/module/Module.ts +0 -45
- package/src/module/__test__/Module.test.ts +0 -54
- package/src/node/Node.ts +0 -98
- package/src/node/__test__/Node.test.ts +0 -120
- package/src/primitive/Primitive.ts +0 -299
- package/src/primitive/__test__/Primitive.test.ts +0 -281
- package/src/primitive/floor/Floor.ts +0 -45
- package/src/primitive/floor/__test__/Floor.test.ts +0 -24
- package/src/renderer/Renderer.ts +0 -215
- package/src/renderer/__test__/Renderer.test.ts +0 -228
- package/src/scene/Scene.ts +0 -106
- package/src/scene/__test__/Scene.test.ts +0 -124
- package/src/scene/root/Root.ts +0 -426
- package/src/scene/root/__test__/Root.test.ts +0 -903
- package/src/scene/xrroot/XRRoot.ts +0 -56
- package/src/scene/xrroot/xrlightroot/XRLightRoot.ts +0 -80
- package/src/toolbox/BaseTool.ts +0 -319
- package/src/toolbox/Toolbox.ts +0 -129
- package/src/toolbox/__test__/BaseTool.test.ts +0 -627
- package/src/toolbox/__test__/Toolbox.test.ts +0 -143
- package/src/toolbox/select/SelectTool.ts +0 -92
- package/src/toolbox/select/__test__/SelectTool.test.ts +0 -237
- package/src/toolbox/transform/TransformTool.ts +0 -166
- package/src/toolbox/transform/__test__/TransformTool.test.ts +0 -147
- package/src/types/SceneData.ts +0 -26
- package/src/types/SceneObjects.ts +0 -14
- package/src/types/SceneType.ts +0 -14
- package/src/types/index.ts +0 -5
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
|
|
2
|
-
import DIVEPerspectiveCamera from '../camera/PerspectiveCamera.ts';
|
|
3
|
-
import { DIVERenderer } from '../renderer/Renderer.ts';
|
|
4
|
-
import { type Box3, MathUtils, Vector3, Vector3Like } from 'three';
|
|
5
|
-
import { Easing } from '@tweenjs/tween.js';
|
|
6
|
-
import { type DIVEAnimationSystem } from '../animation/AnimationSystem.ts';
|
|
7
|
-
|
|
8
|
-
export type DIVEOrbitControlsSettings = {
|
|
9
|
-
enableDamping: boolean;
|
|
10
|
-
dampingFactor: number;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const DIVEOrbitControlsDefaultSettings: DIVEOrbitControlsSettings = {
|
|
14
|
-
enableDamping: true,
|
|
15
|
-
dampingFactor: 0.04,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Orbit Controls. Basic functionality to orbit around a given target point in the scene.
|
|
20
|
-
*
|
|
21
|
-
* @module
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
export default class DIVEOrbitControls extends OrbitControls {
|
|
25
|
-
public static readonly DEFAULT_ZOOM_FACTOR = 1;
|
|
26
|
-
|
|
27
|
-
private _animationSystem: DIVEAnimationSystem;
|
|
28
|
-
|
|
29
|
-
private last: { pos: Vector3Like; target: Vector3Like } | null = null;
|
|
30
|
-
|
|
31
|
-
private animating: boolean = false;
|
|
32
|
-
private locked: boolean = false;
|
|
33
|
-
|
|
34
|
-
private stopMoveTo: () => void = () => {};
|
|
35
|
-
private stopRevertLast: () => void = () => {};
|
|
36
|
-
|
|
37
|
-
public object: DIVEPerspectiveCamera;
|
|
38
|
-
public domElement: HTMLCanvasElement;
|
|
39
|
-
|
|
40
|
-
private _removePreRenderCallback: () => void = () => {};
|
|
41
|
-
|
|
42
|
-
constructor(
|
|
43
|
-
camera: DIVEPerspectiveCamera,
|
|
44
|
-
renderer: DIVERenderer,
|
|
45
|
-
animationSystem: DIVEAnimationSystem,
|
|
46
|
-
settings: Partial<DIVEOrbitControlsSettings> = DIVEOrbitControlsDefaultSettings,
|
|
47
|
-
) {
|
|
48
|
-
super(camera, renderer.domElement);
|
|
49
|
-
|
|
50
|
-
this._animationSystem = animationSystem;
|
|
51
|
-
|
|
52
|
-
this.domElement = renderer.domElement;
|
|
53
|
-
|
|
54
|
-
this.object = camera;
|
|
55
|
-
|
|
56
|
-
const id = renderer.AddPreRenderCallback(() => {
|
|
57
|
-
this.preRenderCallback();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
this._removePreRenderCallback = () => {
|
|
61
|
-
renderer.RemovePreRenderCallback(id);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
this.enableDamping =
|
|
65
|
-
settings.enableDamping ||
|
|
66
|
-
DIVEOrbitControlsDefaultSettings.enableDamping;
|
|
67
|
-
this.dampingFactor =
|
|
68
|
-
settings.dampingFactor ||
|
|
69
|
-
DIVEOrbitControlsDefaultSettings.dampingFactor;
|
|
70
|
-
|
|
71
|
-
// initialize camera transformation
|
|
72
|
-
this.object.position.set(0, 2, 2);
|
|
73
|
-
this.target.copy({ x: 0, y: 0.5, z: 0 });
|
|
74
|
-
this.update();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public Dispose(): void {
|
|
78
|
-
this._removePreRenderCallback();
|
|
79
|
-
this.dispose();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
public ComputeEncompassingView(bb: Box3): {
|
|
83
|
-
position: Vector3Like;
|
|
84
|
-
target: Vector3Like;
|
|
85
|
-
} {
|
|
86
|
-
const center = bb.getCenter(new Vector3());
|
|
87
|
-
const size = bb.getSize(new Vector3());
|
|
88
|
-
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
89
|
-
const direction = this.object.position.clone().normalize();
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
position: direction.multiplyScalar(distance),
|
|
93
|
-
target: center,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
public ZoomIn(by?: number): void {
|
|
98
|
-
const zoomBy = by || DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
99
|
-
const { minDistance, maxDistance } = this;
|
|
100
|
-
this.minDistance = this.maxDistance = MathUtils.clamp(
|
|
101
|
-
this.getDistance() - zoomBy,
|
|
102
|
-
minDistance + zoomBy,
|
|
103
|
-
maxDistance - zoomBy,
|
|
104
|
-
);
|
|
105
|
-
this.update();
|
|
106
|
-
this.minDistance = minDistance;
|
|
107
|
-
this.maxDistance = maxDistance;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
public ZoomOut(by?: number): void {
|
|
111
|
-
const zoomBy = by || DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
112
|
-
const { minDistance, maxDistance } = this;
|
|
113
|
-
this.minDistance = this.maxDistance = MathUtils.clamp(
|
|
114
|
-
this.getDistance() + zoomBy,
|
|
115
|
-
minDistance + zoomBy,
|
|
116
|
-
maxDistance - zoomBy,
|
|
117
|
-
);
|
|
118
|
-
this.update();
|
|
119
|
-
this.minDistance = minDistance;
|
|
120
|
-
this.maxDistance = maxDistance;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
public MoveTo(
|
|
124
|
-
pos: Vector3Like | undefined,
|
|
125
|
-
target: Vector3Like | undefined,
|
|
126
|
-
duration: number,
|
|
127
|
-
lock: boolean,
|
|
128
|
-
): void {
|
|
129
|
-
if (this.animating) return;
|
|
130
|
-
|
|
131
|
-
const toPosition = pos || this.object.position.clone();
|
|
132
|
-
const toTarget = target || this.target.clone();
|
|
133
|
-
|
|
134
|
-
this.stopRevertLast();
|
|
135
|
-
|
|
136
|
-
if (!this.locked)
|
|
137
|
-
this.last = {
|
|
138
|
-
pos: this.object.position.clone(),
|
|
139
|
-
target: this.target.clone(),
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
this.animating = duration > 0;
|
|
143
|
-
this.locked = lock;
|
|
144
|
-
this.enabled = false;
|
|
145
|
-
|
|
146
|
-
const tweenPos = this._animationSystem
|
|
147
|
-
.Animate(this.object.position)
|
|
148
|
-
.to(toPosition, duration)
|
|
149
|
-
.easing(Easing.Quadratic.Out)
|
|
150
|
-
.start();
|
|
151
|
-
|
|
152
|
-
const tweenQuat = this._animationSystem
|
|
153
|
-
.Animate(this.target)
|
|
154
|
-
.to(toTarget, duration)
|
|
155
|
-
.easing(Easing.Quadratic.Out)
|
|
156
|
-
.onUpdate(() => {
|
|
157
|
-
this.object.lookAt(this.target);
|
|
158
|
-
})
|
|
159
|
-
.onComplete(() => {
|
|
160
|
-
this.animating = false;
|
|
161
|
-
this.enabled = !lock;
|
|
162
|
-
})
|
|
163
|
-
.start();
|
|
164
|
-
|
|
165
|
-
this.stopMoveTo = () => {
|
|
166
|
-
tweenPos.stop();
|
|
167
|
-
tweenQuat.stop();
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
public RevertLast(duration: number): void {
|
|
172
|
-
if (this.animating || !this.locked) return;
|
|
173
|
-
|
|
174
|
-
this.stopMoveTo();
|
|
175
|
-
|
|
176
|
-
this.animating = duration > 0;
|
|
177
|
-
this.enabled = false;
|
|
178
|
-
|
|
179
|
-
const { pos, target } = this.last!;
|
|
180
|
-
|
|
181
|
-
const tweenPos = this._animationSystem
|
|
182
|
-
.Animate(this.object.position)
|
|
183
|
-
.to(pos, duration)
|
|
184
|
-
.easing(Easing.Quadratic.Out)
|
|
185
|
-
.start();
|
|
186
|
-
|
|
187
|
-
const tweenQuat = this._animationSystem
|
|
188
|
-
.Animate(this.target)
|
|
189
|
-
.to(target, duration)
|
|
190
|
-
.easing(Easing.Quadratic.Out)
|
|
191
|
-
.onUpdate(() => {
|
|
192
|
-
this.object.lookAt(this.target);
|
|
193
|
-
})
|
|
194
|
-
.onComplete(() => {
|
|
195
|
-
this.animating = false;
|
|
196
|
-
this.locked = false;
|
|
197
|
-
this.enabled = true;
|
|
198
|
-
})
|
|
199
|
-
.start();
|
|
200
|
-
|
|
201
|
-
this.stopRevertLast = () => {
|
|
202
|
-
tweenPos.stop();
|
|
203
|
-
tweenQuat.stop();
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
private preRenderCallback = (): void => {
|
|
208
|
-
if (this.locked) return;
|
|
209
|
-
this.update();
|
|
210
|
-
};
|
|
211
|
-
}
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import DIVEOrbitControls from '../OrbitControls';
|
|
2
|
-
import type DIVEPerspectiveCamera from '../../camera/PerspectiveCamera';
|
|
3
|
-
import { DIVERenderer } from '../../renderer/Renderer';
|
|
4
|
-
import { Box3 } from 'three';
|
|
5
|
-
import { DIVEAnimationSystem } from '../../animation/AnimationSystem';
|
|
6
|
-
import { Tween } from '@tweenjs/tween.js';
|
|
7
|
-
|
|
8
|
-
jest.mock('../../renderer/Renderer', () => {
|
|
9
|
-
return jest.fn(function () {
|
|
10
|
-
this.domElement = {
|
|
11
|
-
style: {},
|
|
12
|
-
};
|
|
13
|
-
this.AddPreRenderCallback = (callback: () => void) => {
|
|
14
|
-
callback();
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
return this;
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
jest.mock('../../animation/AnimationSystem', () => {
|
|
22
|
-
return {
|
|
23
|
-
DIVEAnimationSystem: jest.fn(function () {
|
|
24
|
-
this.domElement = {
|
|
25
|
-
style: {},
|
|
26
|
-
};
|
|
27
|
-
this.Animate = <T extends object>(obj: T) => {
|
|
28
|
-
return new Tween<T>(obj);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return this;
|
|
32
|
-
}),
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const moveToPos = { x: 10, y: 0, z: 0 };
|
|
37
|
-
const moveToQuat = { x: 0, y: 0, z: 0 };
|
|
38
|
-
const moveToDuration = 1000;
|
|
39
|
-
|
|
40
|
-
const mockCamera = {
|
|
41
|
-
position: {
|
|
42
|
-
clone: jest.fn(() => {
|
|
43
|
-
return mockCamera.position;
|
|
44
|
-
}),
|
|
45
|
-
normalize: jest.fn(() => {
|
|
46
|
-
return mockCamera.position;
|
|
47
|
-
}),
|
|
48
|
-
multiplyScalar: jest.fn(() => {
|
|
49
|
-
return mockCamera.position;
|
|
50
|
-
}),
|
|
51
|
-
set: jest.fn(() => {
|
|
52
|
-
return mockCamera.position;
|
|
53
|
-
}),
|
|
54
|
-
},
|
|
55
|
-
lookAt: jest.fn(),
|
|
56
|
-
} as unknown as DIVEPerspectiveCamera;
|
|
57
|
-
const mockRenderer = {
|
|
58
|
-
render: jest.fn(),
|
|
59
|
-
OnResize: jest.fn(),
|
|
60
|
-
getViewport: jest.fn(),
|
|
61
|
-
setViewport: jest.fn(),
|
|
62
|
-
AddPreRenderCallback: jest.fn((callback) => {
|
|
63
|
-
callback();
|
|
64
|
-
}),
|
|
65
|
-
AddPostRenderCallback: jest.fn((callback) => {
|
|
66
|
-
callback();
|
|
67
|
-
}),
|
|
68
|
-
RemovePreRenderCallback: jest.fn(),
|
|
69
|
-
RemovePostRenderCallback: jest.fn(),
|
|
70
|
-
} as unknown as DIVERenderer;
|
|
71
|
-
|
|
72
|
-
const mockAnimSystem = new DIVEAnimationSystem(mockRenderer);
|
|
73
|
-
|
|
74
|
-
describe('dive/controls/DIVEOrbitControls', () => {
|
|
75
|
-
afterEach(() => {
|
|
76
|
-
jest.clearAllMocks();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('should instantiate', () => {
|
|
80
|
-
const controller = new DIVEOrbitControls(
|
|
81
|
-
mockCamera,
|
|
82
|
-
mockRenderer,
|
|
83
|
-
mockAnimSystem,
|
|
84
|
-
{},
|
|
85
|
-
);
|
|
86
|
-
expect(controller).toBeDefined();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should instantiate with settings', () => {
|
|
90
|
-
const controller = new DIVEOrbitControls(
|
|
91
|
-
mockCamera,
|
|
92
|
-
mockRenderer,
|
|
93
|
-
mockAnimSystem,
|
|
94
|
-
{
|
|
95
|
-
enableDamping: false,
|
|
96
|
-
dampingFactor: 0.5,
|
|
97
|
-
},
|
|
98
|
-
);
|
|
99
|
-
expect(controller).toBeDefined();
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('should dispose', () => {
|
|
103
|
-
const controller = new DIVEOrbitControls(
|
|
104
|
-
mockCamera,
|
|
105
|
-
mockRenderer,
|
|
106
|
-
mockAnimSystem,
|
|
107
|
-
);
|
|
108
|
-
expect(() => controller.Dispose()).not.toThrow();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should compute encompassing view', () => {
|
|
112
|
-
const controller = new DIVEOrbitControls(
|
|
113
|
-
mockCamera,
|
|
114
|
-
mockRenderer,
|
|
115
|
-
mockAnimSystem,
|
|
116
|
-
);
|
|
117
|
-
expect(() =>
|
|
118
|
-
controller.ComputeEncompassingView(new Box3()),
|
|
119
|
-
).not.toThrow();
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('should zoom in with default value', () => {
|
|
123
|
-
const controller = new DIVEOrbitControls(
|
|
124
|
-
mockCamera,
|
|
125
|
-
mockRenderer,
|
|
126
|
-
mockAnimSystem,
|
|
127
|
-
);
|
|
128
|
-
expect(() => controller.ZoomIn()).not.toThrow();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('should zoom in with custom value', () => {
|
|
132
|
-
const controller = new DIVEOrbitControls(
|
|
133
|
-
mockCamera,
|
|
134
|
-
mockRenderer,
|
|
135
|
-
mockAnimSystem,
|
|
136
|
-
);
|
|
137
|
-
expect(() => controller.ZoomIn(10)).not.toThrow();
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('should zoom out with default value', () => {
|
|
141
|
-
const controller = new DIVEOrbitControls(
|
|
142
|
-
mockCamera,
|
|
143
|
-
mockRenderer,
|
|
144
|
-
mockAnimSystem,
|
|
145
|
-
);
|
|
146
|
-
expect(() => controller.ZoomOut()).not.toThrow();
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('should zoom out with custom value', () => {
|
|
150
|
-
const controller = new DIVEOrbitControls(
|
|
151
|
-
mockCamera,
|
|
152
|
-
mockRenderer,
|
|
153
|
-
mockAnimSystem,
|
|
154
|
-
);
|
|
155
|
-
expect(() => controller.ZoomOut(10)).not.toThrow();
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('should move to', () => {
|
|
159
|
-
const controller = new DIVEOrbitControls(
|
|
160
|
-
mockCamera,
|
|
161
|
-
mockRenderer,
|
|
162
|
-
mockAnimSystem,
|
|
163
|
-
);
|
|
164
|
-
expect(() =>
|
|
165
|
-
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, false),
|
|
166
|
-
).not.toThrow();
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('should revert move to', () => {
|
|
170
|
-
const controller = new DIVEOrbitControls(
|
|
171
|
-
mockCamera,
|
|
172
|
-
mockRenderer,
|
|
173
|
-
mockAnimSystem,
|
|
174
|
-
);
|
|
175
|
-
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
|
|
176
|
-
expect(() => controller.RevertLast(moveToDuration)).not.toThrow();
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('should revert move to without values', () => {
|
|
180
|
-
const controller = new DIVEOrbitControls(
|
|
181
|
-
mockCamera,
|
|
182
|
-
mockRenderer,
|
|
183
|
-
mockAnimSystem,
|
|
184
|
-
);
|
|
185
|
-
expect(() =>
|
|
186
|
-
controller.MoveTo(undefined, undefined, moveToDuration, true),
|
|
187
|
-
).not.toThrow();
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it('should revert move to with lock', async () => {
|
|
191
|
-
const controller = new DIVEOrbitControls(
|
|
192
|
-
mockCamera,
|
|
193
|
-
mockRenderer,
|
|
194
|
-
mockAnimSystem,
|
|
195
|
-
);
|
|
196
|
-
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
|
|
197
|
-
expect(() => controller.RevertLast(moveToDuration)).not.toThrow();
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it('should move after revert with lock', async () => {
|
|
201
|
-
const controller = new DIVEOrbitControls(
|
|
202
|
-
mockCamera,
|
|
203
|
-
mockRenderer,
|
|
204
|
-
mockAnimSystem,
|
|
205
|
-
);
|
|
206
|
-
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
|
|
207
|
-
controller.RevertLast(moveToDuration);
|
|
208
|
-
expect(() =>
|
|
209
|
-
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true),
|
|
210
|
-
).not.toThrow();
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('should catch multiple move tos', () => {
|
|
214
|
-
const controller = new DIVEOrbitControls(
|
|
215
|
-
mockCamera,
|
|
216
|
-
mockRenderer,
|
|
217
|
-
mockAnimSystem,
|
|
218
|
-
);
|
|
219
|
-
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
|
|
220
|
-
controller.RevertLast(moveToDuration);
|
|
221
|
-
expect(() =>
|
|
222
|
-
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true),
|
|
223
|
-
).not.toThrow();
|
|
224
|
-
controller['animating'] = true;
|
|
225
|
-
expect(() =>
|
|
226
|
-
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true),
|
|
227
|
-
).not.toThrow();
|
|
228
|
-
expect(() =>
|
|
229
|
-
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true),
|
|
230
|
-
).not.toThrow();
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
it('should catch multiple reverts', () => {
|
|
234
|
-
const controller = new DIVEOrbitControls(
|
|
235
|
-
mockCamera,
|
|
236
|
-
mockRenderer,
|
|
237
|
-
mockAnimSystem,
|
|
238
|
-
);
|
|
239
|
-
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
|
|
240
|
-
expect(() => controller.RevertLast(moveToDuration)).not.toThrow();
|
|
241
|
-
expect(() => controller.RevertLast(moveToDuration)).not.toThrow();
|
|
242
|
-
expect(() => controller.RevertLast(moveToDuration)).not.toThrow();
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it('should execute preRenderCallback', () => {
|
|
246
|
-
const controller = new DIVEOrbitControls(
|
|
247
|
-
mockCamera,
|
|
248
|
-
mockRenderer,
|
|
249
|
-
mockAnimSystem,
|
|
250
|
-
);
|
|
251
|
-
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
|
|
252
|
-
expect(() => controller['preRenderCallback']()).not.toThrow();
|
|
253
|
-
controller['locked'] = true;
|
|
254
|
-
expect(() => controller['preRenderCallback']()).not.toThrow();
|
|
255
|
-
});
|
|
256
|
-
});
|