@shopware-ag/dive 1.6.3 → 1.6.5
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 +46 -9
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +22 -2
- package/build/dive.d.ts +22 -2
- package/build/dive.js +47 -10
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/__test__/DIVE.test.ts +1 -0
- package/src/animation/AnimationSystem.ts +8 -4
- package/src/animation/__test__/AnimationSystem.test.ts +9 -2
- package/src/com/Communication.ts +8 -2
- package/src/com/__test__/Communication.test.ts +18 -1
- package/src/controls/OrbitControls.ts +23 -7
- package/src/controls/__test__/OrbitControls.test.ts +45 -14
- package/src/dive.ts +9 -5
- package/src/mediacreator/__test__/MediaCreator.test.ts +19 -1
- package/src/toolbox/select/__test__/SelectTool.test.ts +27 -1
- package/src/toolbox/transform/__test__/TransformTool.test.ts +26 -1
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { update as updateTween } from "@tweenjs/tween.js";
|
|
1
|
+
import { Tween, update as updateTween } from "@tweenjs/tween.js";
|
|
2
2
|
import { DIVERenderer } from "../renderer/Renderer";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -8,7 +8,7 @@ import { DIVERenderer } from "../renderer/Renderer";
|
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export class DIVEAnimationSystem {
|
|
12
12
|
private _renderer: DIVERenderer;
|
|
13
13
|
private _rendererCallbackId: string;
|
|
14
14
|
|
|
@@ -16,7 +16,7 @@ export default class DIVEAnimationSystem {
|
|
|
16
16
|
this._renderer = renderer;
|
|
17
17
|
|
|
18
18
|
this._rendererCallbackId = this._renderer.AddPreRenderCallback(() => {
|
|
19
|
-
this.
|
|
19
|
+
this.Update();
|
|
20
20
|
})
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -24,7 +24,11 @@ export default class DIVEAnimationSystem {
|
|
|
24
24
|
this._renderer.RemovePreRenderCallback(this._rendererCallbackId);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
public
|
|
27
|
+
public Update(): void {
|
|
28
28
|
updateTween();
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
public Animate<T extends object>(object: T): Tween<T> {
|
|
32
|
+
return new Tween<T>(object);
|
|
33
|
+
}
|
|
30
34
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DIVERenderer } from '../../renderer/Renderer';
|
|
2
|
-
import DIVEAnimationSystem from '../AnimationSystem';
|
|
2
|
+
import { DIVEAnimationSystem } from '../AnimationSystem';
|
|
3
3
|
|
|
4
4
|
jest.mock('@tweenjs/tween.js', () => {
|
|
5
5
|
return {
|
|
6
|
+
Tween: jest.fn(() => { }),
|
|
6
7
|
update: jest.fn(),
|
|
7
8
|
}
|
|
8
9
|
});
|
|
@@ -28,9 +29,15 @@ describe('dive/animation/DIVEAnimationSystem', () => {
|
|
|
28
29
|
expect(anim).toBeDefined();
|
|
29
30
|
});
|
|
30
31
|
|
|
32
|
+
it('should Animate', () => {
|
|
33
|
+
const anim = new DIVEAnimationSystem(mockRenderer);
|
|
34
|
+
const tween = anim.Animate({});
|
|
35
|
+
expect(tween).toBeDefined();
|
|
36
|
+
});
|
|
37
|
+
|
|
31
38
|
it('should update', () => {
|
|
32
39
|
const anim = new DIVEAnimationSystem(mockRenderer);
|
|
33
|
-
expect(() => anim.
|
|
40
|
+
expect(() => anim.Update()).not.toThrow();
|
|
34
41
|
});
|
|
35
42
|
|
|
36
43
|
it('should dispose', () => {
|
package/src/com/Communication.ts
CHANGED
|
@@ -41,10 +41,16 @@ export default class DIVECommunication {
|
|
|
41
41
|
private static __instances: DIVECommunication[] = [];
|
|
42
42
|
|
|
43
43
|
public static get(id: string): DIVECommunication | undefined {
|
|
44
|
+
const fromComID = this.__instances.find((instance) => instance.id === id);
|
|
45
|
+
if (fromComID) return fromComID;
|
|
44
46
|
return this.__instances.find((instance) => Array.from(instance.registered.values()).find((object) => object.id === id));
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
private
|
|
49
|
+
private _id: string;
|
|
50
|
+
public get id(): string {
|
|
51
|
+
return this._id;
|
|
52
|
+
}
|
|
53
|
+
|
|
48
54
|
private renderer: DIVERenderer;
|
|
49
55
|
private scene: DIVEScene;
|
|
50
56
|
private controller: DIVEOrbitControls;
|
|
@@ -65,7 +71,7 @@ export default class DIVECommunication {
|
|
|
65
71
|
private listeners: Map<keyof Actions, EventListener<keyof Actions>[]> = new Map();
|
|
66
72
|
|
|
67
73
|
constructor(renderer: DIVERenderer, scene: DIVEScene, controls: DIVEOrbitControls, toolbox: DIVEToolbox) {
|
|
68
|
-
this.
|
|
74
|
+
this._id = generateUUID();
|
|
69
75
|
this.renderer = renderer;
|
|
70
76
|
this.scene = scene;
|
|
71
77
|
this.controller = controls;
|
|
@@ -186,10 +186,19 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
186
186
|
|
|
187
187
|
it('should instantiate', () => {
|
|
188
188
|
expect(testCom).toBeDefined();
|
|
189
|
-
expect(() => DIVECommunication.get('id')).not.toThrow();
|
|
190
189
|
expect(DIVECommunication['__instances']).toHaveLength(1);
|
|
191
190
|
});
|
|
192
191
|
|
|
192
|
+
it('should get instance', () => {
|
|
193
|
+
expect(testCom).toBeDefined();
|
|
194
|
+
expect(DIVECommunication.get(testCom.id)).toBeDefined();
|
|
195
|
+
|
|
196
|
+
testCom.PerformAction('ADD_OBJECT', {
|
|
197
|
+
id: 'someID',
|
|
198
|
+
} as COMModel);
|
|
199
|
+
expect(DIVECommunication.get('someID')).toBeDefined();
|
|
200
|
+
});
|
|
201
|
+
|
|
193
202
|
it('should destroy instance', () => {
|
|
194
203
|
expect(testCom).toBeDefined();
|
|
195
204
|
testCom.DestroyInstance();
|
|
@@ -670,6 +679,14 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
670
679
|
expect(visibility).toBe(false);
|
|
671
680
|
});
|
|
672
681
|
|
|
682
|
+
it('should perform action USE_TOOL', () => {
|
|
683
|
+
let success = testCom.PerformAction('USE_TOOL', { tool: 'select' });
|
|
684
|
+
expect(success).toBe(true);
|
|
685
|
+
|
|
686
|
+
success = testCom.PerformAction('USE_TOOL', { tool: 'none' });
|
|
687
|
+
expect(success).toBe(true);
|
|
688
|
+
});
|
|
689
|
+
|
|
673
690
|
it('should perform action MODEL_LOADED', () => {
|
|
674
691
|
const payload = {
|
|
675
692
|
entityType: "model",
|
|
@@ -2,7 +2,8 @@ import { OrbitControls } from "three/examples/jsm/Addons.js";
|
|
|
2
2
|
import DIVEPerspectiveCamera from "../camera/PerspectiveCamera.ts";
|
|
3
3
|
import { DIVERenderer } from "../renderer/Renderer.ts";
|
|
4
4
|
import { type Box3, MathUtils, Vector3, Vector3Like } from "three";
|
|
5
|
-
import { Easing
|
|
5
|
+
import { Easing } from "@tweenjs/tween.js";
|
|
6
|
+
import { type DIVEAnimationSystem } from "../animation/AnimationSystem.ts";
|
|
6
7
|
|
|
7
8
|
export type DIVEOrbitControlsSettings = {
|
|
8
9
|
enableDamping: boolean;
|
|
@@ -23,6 +24,8 @@ export const DIVEOrbitControlsDefaultSettings: DIVEOrbitControlsSettings = {
|
|
|
23
24
|
export default class DIVEOrbitControls extends OrbitControls {
|
|
24
25
|
public static readonly DEFAULT_ZOOM_FACTOR = 1;
|
|
25
26
|
|
|
27
|
+
private _animationSystem: DIVEAnimationSystem;
|
|
28
|
+
|
|
26
29
|
private last: { pos: Vector3Like, target: Vector3Like } | null = null;
|
|
27
30
|
|
|
28
31
|
private animating: boolean = false;
|
|
@@ -34,21 +37,34 @@ export default class DIVEOrbitControls extends OrbitControls {
|
|
|
34
37
|
public object: DIVEPerspectiveCamera;
|
|
35
38
|
public domElement: HTMLCanvasElement;
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
private _removePreRenderCallback: () => void = () => { };
|
|
41
|
+
|
|
42
|
+
constructor(camera: DIVEPerspectiveCamera, renderer: DIVERenderer, animationSystem: DIVEAnimationSystem, settings: DIVEOrbitControlsSettings = DIVEOrbitControlsDefaultSettings) {
|
|
38
43
|
super(camera, renderer.domElement);
|
|
39
44
|
|
|
45
|
+
this._animationSystem = animationSystem;
|
|
46
|
+
|
|
40
47
|
this.domElement = renderer.domElement;
|
|
41
48
|
|
|
42
49
|
this.object = camera;
|
|
43
50
|
|
|
44
|
-
renderer.AddPreRenderCallback(() => {
|
|
51
|
+
const id = renderer.AddPreRenderCallback(() => {
|
|
45
52
|
this.preRenderCallback();
|
|
46
53
|
});
|
|
47
54
|
|
|
55
|
+
this._removePreRenderCallback = () => {
|
|
56
|
+
renderer.RemovePreRenderCallback(id);
|
|
57
|
+
}
|
|
58
|
+
|
|
48
59
|
this.enableDamping = settings.enableDamping;
|
|
49
60
|
this.dampingFactor = settings.dampingFactor;
|
|
50
61
|
}
|
|
51
62
|
|
|
63
|
+
public Dispose(): void {
|
|
64
|
+
this._removePreRenderCallback();
|
|
65
|
+
this.dispose();
|
|
66
|
+
}
|
|
67
|
+
|
|
52
68
|
public ComputeEncompassingView(bb: Box3): { position: Vector3Like, target: Vector3Like } {
|
|
53
69
|
const center = bb.getCenter(new Vector3());
|
|
54
70
|
const size = bb.getSize(new Vector3());
|
|
@@ -93,12 +109,12 @@ export default class DIVEOrbitControls extends OrbitControls {
|
|
|
93
109
|
this.locked = lock;
|
|
94
110
|
this.enabled = false;
|
|
95
111
|
|
|
96
|
-
const tweenPos =
|
|
112
|
+
const tweenPos = this._animationSystem.Animate(this.object.position)
|
|
97
113
|
.to(toPosition, duration)
|
|
98
114
|
.easing(Easing.Quadratic.Out)
|
|
99
115
|
.start();
|
|
100
116
|
|
|
101
|
-
const tweenQuat =
|
|
117
|
+
const tweenQuat = this._animationSystem.Animate(this.target)
|
|
102
118
|
.to(toTarget, duration)
|
|
103
119
|
.easing(Easing.Quadratic.Out)
|
|
104
120
|
.onUpdate(() => {
|
|
@@ -126,12 +142,12 @@ export default class DIVEOrbitControls extends OrbitControls {
|
|
|
126
142
|
|
|
127
143
|
const { pos, target } = this.last!;
|
|
128
144
|
|
|
129
|
-
const tweenPos =
|
|
145
|
+
const tweenPos = this._animationSystem.Animate(this.object.position)
|
|
130
146
|
.to(pos, duration)
|
|
131
147
|
.easing(Easing.Quadratic.Out)
|
|
132
148
|
.start();
|
|
133
149
|
|
|
134
|
-
const tweenQuat =
|
|
150
|
+
const tweenQuat = this._animationSystem.Animate(this.target)
|
|
135
151
|
.to(target, duration)
|
|
136
152
|
.easing(Easing.Quadratic.Out)
|
|
137
153
|
.onUpdate(() => {
|
|
@@ -2,6 +2,15 @@ import DIVEOrbitControls from '../OrbitControls';
|
|
|
2
2
|
import type DIVEPerspectiveCamera from '../../camera/PerspectiveCamera';
|
|
3
3
|
import { DIVERenderer } from '../../renderer/Renderer';
|
|
4
4
|
import { Box3 } from 'three';
|
|
5
|
+
import { DIVEAnimationSystem } from '../../animation/AnimationSystem';
|
|
6
|
+
import { Tween } from '@tweenjs/tween.js';
|
|
7
|
+
|
|
8
|
+
jest.mock('@tweenjs/tween.js', () => {
|
|
9
|
+
return {
|
|
10
|
+
Tween: jest.fn(() => { }),
|
|
11
|
+
update: jest.fn(),
|
|
12
|
+
}
|
|
13
|
+
});
|
|
5
14
|
|
|
6
15
|
jest.mock('three/examples/jsm/Addons.js', () => {
|
|
7
16
|
return {
|
|
@@ -60,6 +69,21 @@ jest.mock('../../renderer/Renderer', () => {
|
|
|
60
69
|
});
|
|
61
70
|
});
|
|
62
71
|
|
|
72
|
+
jest.mock('../../animation/AnimationSystem', () => {
|
|
73
|
+
return {
|
|
74
|
+
DIVEAnimationSystem: jest.fn(function () {
|
|
75
|
+
this.domElement = {
|
|
76
|
+
style: {},
|
|
77
|
+
};
|
|
78
|
+
this.Animate = <T extends object>(obj: T) => {
|
|
79
|
+
return new Tween<T>(obj);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return this;
|
|
83
|
+
}),
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
63
87
|
jest.mock('@tweenjs/tween.js', () => {
|
|
64
88
|
return {
|
|
65
89
|
Easing: {
|
|
@@ -116,72 +140,79 @@ const mockRenderer = {
|
|
|
116
140
|
RemovePostRenderCallback: jest.fn(),
|
|
117
141
|
} as unknown as DIVERenderer;
|
|
118
142
|
|
|
143
|
+
const mockAnimSystem = new DIVEAnimationSystem(mockRenderer);
|
|
144
|
+
|
|
119
145
|
describe('dive/controls/DIVEOrbitControls', () => {
|
|
120
146
|
afterEach(() => {
|
|
121
147
|
jest.clearAllMocks();
|
|
122
148
|
});
|
|
123
149
|
|
|
124
150
|
it('should instantiate', () => {
|
|
125
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
151
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
126
152
|
expect(controller).toBeDefined();
|
|
127
153
|
});
|
|
128
154
|
|
|
155
|
+
it('should dispose', () => {
|
|
156
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
157
|
+
expect(() => controller.Dispose()).not.toThrow();
|
|
158
|
+
});
|
|
159
|
+
|
|
129
160
|
it('should compute encompassing view', () => {
|
|
130
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
161
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
131
162
|
expect(() => controller.ComputeEncompassingView(new Box3())).not.toThrow();
|
|
132
163
|
});
|
|
133
164
|
|
|
134
165
|
it('should zoom in with default value', () => {
|
|
135
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
166
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
136
167
|
expect(() => controller.ZoomIn()).not.toThrow();
|
|
137
168
|
});
|
|
138
169
|
|
|
139
170
|
it('should zoom in with custom value', () => {
|
|
140
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
171
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
141
172
|
expect(() => controller.ZoomIn(10)).not.toThrow();
|
|
142
173
|
});
|
|
143
174
|
|
|
144
175
|
it('should zoom out with default value', () => {
|
|
145
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
176
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
146
177
|
expect(() => controller.ZoomOut()).not.toThrow();
|
|
147
178
|
});
|
|
148
179
|
|
|
149
180
|
it('should zoom out with custom value', () => {
|
|
150
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
181
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
151
182
|
expect(() => controller.ZoomOut(10)).not.toThrow();
|
|
152
183
|
});
|
|
153
184
|
|
|
154
185
|
it('should move to', () => {
|
|
155
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
186
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
156
187
|
expect(() => controller.MoveTo(moveToPos, moveToQuat, moveToDuration, false)).not.toThrow();
|
|
157
188
|
});
|
|
158
189
|
|
|
159
190
|
it('should revert move to', () => {
|
|
160
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
191
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
161
192
|
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
|
|
162
193
|
expect(() => controller.RevertLast(moveToDuration)).not.toThrow();
|
|
163
194
|
});
|
|
164
195
|
|
|
165
196
|
it('should revert move to without values', () => {
|
|
166
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
197
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
167
198
|
expect(() => controller.MoveTo(undefined, undefined, moveToDuration, true)).not.toThrow();
|
|
168
199
|
});
|
|
169
200
|
|
|
170
201
|
it('should revert move to with lock', async () => {
|
|
171
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
202
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
172
203
|
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
|
|
173
204
|
expect(() => controller.RevertLast(moveToDuration)).not.toThrow();
|
|
174
205
|
});
|
|
175
206
|
|
|
176
207
|
it('should move after revert with lock', async () => {
|
|
177
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
208
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
178
209
|
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
|
|
179
210
|
controller.RevertLast(moveToDuration);
|
|
180
211
|
expect(() => controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true)).not.toThrow();
|
|
181
212
|
});
|
|
182
213
|
|
|
183
214
|
it('should catch multiple move tos', () => {
|
|
184
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
215
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
185
216
|
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
|
|
186
217
|
controller.RevertLast(moveToDuration);
|
|
187
218
|
expect(() => controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true)).not.toThrow();
|
|
@@ -191,7 +222,7 @@ describe('dive/controls/DIVEOrbitControls', () => {
|
|
|
191
222
|
});
|
|
192
223
|
|
|
193
224
|
it('should catch multiple reverts', () => {
|
|
194
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
225
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
195
226
|
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
|
|
196
227
|
expect(() => controller.RevertLast(moveToDuration)).not.toThrow();
|
|
197
228
|
expect(() => controller.RevertLast(moveToDuration)).not.toThrow();
|
|
@@ -199,7 +230,7 @@ describe('dive/controls/DIVEOrbitControls', () => {
|
|
|
199
230
|
});
|
|
200
231
|
|
|
201
232
|
it('should execute preRenderCallback', () => {
|
|
202
|
-
const controller = new DIVEOrbitControls(mockCamera, mockRenderer);
|
|
233
|
+
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
203
234
|
controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
|
|
204
235
|
expect(() => controller['preRenderCallback']()).not.toThrow();
|
|
205
236
|
controller['locked'] = true;
|
package/src/dive.ts
CHANGED
|
@@ -4,7 +4,7 @@ import DIVEPerspectiveCamera, { DIVEPerspectiveCameraDefaultSettings, DIVEPerspe
|
|
|
4
4
|
import DIVEOrbitControls, { DIVEOrbitControlsDefaultSettings, DIVEOrbitControlsSettings } from "./controls/OrbitControls.ts";
|
|
5
5
|
import DIVEToolbox from "./toolbox/Toolbox.ts";
|
|
6
6
|
import DIVECommunication from "./com/Communication.ts";
|
|
7
|
-
import DIVEAnimationSystem from "./animation/AnimationSystem.ts";
|
|
7
|
+
import { DIVEAnimationSystem } from "./animation/AnimationSystem.ts";
|
|
8
8
|
import DIVEAxisCamera from "./axiscamera/AxisCamera.ts";
|
|
9
9
|
import { getObjectDelta } from "./helper/getObjectDelta/getObjectDelta.ts";
|
|
10
10
|
|
|
@@ -133,7 +133,7 @@ export default class DIVE {
|
|
|
133
133
|
private communication: DIVECommunication;
|
|
134
134
|
|
|
135
135
|
// additional components
|
|
136
|
-
private animationSystem: DIVEAnimationSystem
|
|
136
|
+
private animationSystem: DIVEAnimationSystem;
|
|
137
137
|
private axisCamera: DIVEAxisCamera | null;
|
|
138
138
|
|
|
139
139
|
// getters
|
|
@@ -194,12 +194,14 @@ export default class DIVE {
|
|
|
194
194
|
this.renderer = new DIVERenderer(this._settings.renderer);
|
|
195
195
|
this.scene = new DIVEScene();
|
|
196
196
|
this.perspectiveCamera = new DIVEPerspectiveCamera(this._settings.perspectiveCamera);
|
|
197
|
-
|
|
197
|
+
|
|
198
|
+
// initialize animation system
|
|
199
|
+
this.animationSystem = new DIVEAnimationSystem(this.renderer);
|
|
200
|
+
|
|
201
|
+
this.orbitControls = new DIVEOrbitControls(this.perspectiveCamera, this.renderer, this.animationSystem, this._settings.orbitControls);
|
|
198
202
|
this.toolbox = new DIVEToolbox(this.scene, this.orbitControls);
|
|
199
203
|
this.communication = new DIVECommunication(this.renderer, this.scene, this.orbitControls, this.toolbox);
|
|
200
204
|
|
|
201
|
-
// initialize animation system
|
|
202
|
-
this.animationSystem = null;
|
|
203
205
|
|
|
204
206
|
// initialize axis camera
|
|
205
207
|
if (this._settings.displayAxes) {
|
|
@@ -227,7 +229,9 @@ export default class DIVE {
|
|
|
227
229
|
public Dispose(): void {
|
|
228
230
|
this.removeResizeObserver();
|
|
229
231
|
this.renderer.Dispose();
|
|
232
|
+
this.orbitControls.Dispose();
|
|
230
233
|
this.axisCamera?.Dispose();
|
|
234
|
+
this.animationSystem.Dispose();
|
|
231
235
|
this.toolbox.Dispose();
|
|
232
236
|
this.communication.DestroyInstance();
|
|
233
237
|
}
|
|
@@ -4,6 +4,7 @@ import DIVEScene from '../../scene/Scene';
|
|
|
4
4
|
import DIVEPerspectiveCamera, { DIVEPerspectiveCameraDefaultSettings } from '../../camera/PerspectiveCamera';
|
|
5
5
|
import { COMPov } from '../../com';
|
|
6
6
|
import DIVEOrbitControls from '../../controls/OrbitControls';
|
|
7
|
+
import { DIVEAnimationSystem } from '../../animation/AnimationSystem';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @jest-environment jsdom
|
|
@@ -83,12 +84,29 @@ jest.mock('../../renderer/Renderer', () => {
|
|
|
83
84
|
}
|
|
84
85
|
});
|
|
85
86
|
|
|
87
|
+
jest.mock('../../animation/AnimationSystem', () => {
|
|
88
|
+
return {
|
|
89
|
+
DIVEAnimationSystem: jest.fn(function () {
|
|
90
|
+
this.domElement = {
|
|
91
|
+
toDataURL: mock_toDataURL,
|
|
92
|
+
}
|
|
93
|
+
this.render = mock_render;
|
|
94
|
+
this.OnResize = jest.fn();
|
|
95
|
+
this.AddPreRenderCallback = jest.fn((callback) => {
|
|
96
|
+
callback();
|
|
97
|
+
return 'id';
|
|
98
|
+
});
|
|
99
|
+
return this;
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
86
104
|
let mediaCreator: DIVEMediaCreator;
|
|
87
105
|
|
|
88
106
|
describe('dive/mediacreator/DIVEMediaCreator', () => {
|
|
89
107
|
beforeEach(() => {
|
|
90
108
|
jest.clearAllMocks();
|
|
91
|
-
mediaCreator = new DIVEMediaCreator(new DIVERenderer(), new DIVEScene(), new DIVEOrbitControls(new DIVEPerspectiveCamera(DIVEPerspectiveCameraDefaultSettings), new DIVERenderer()));
|
|
109
|
+
mediaCreator = new DIVEMediaCreator(new DIVERenderer(), new DIVEScene(), new DIVEOrbitControls(new DIVEPerspectiveCamera(DIVEPerspectiveCameraDefaultSettings), new DIVERenderer(), new DIVEAnimationSystem(new DIVERenderer())));
|
|
92
110
|
});
|
|
93
111
|
|
|
94
112
|
it('should instantiate', () => {
|
|
@@ -6,6 +6,15 @@ import { DIVESelectable } from '../../../interface/Selectable';
|
|
|
6
6
|
import type DIVEPerspectiveCamera from '../../../camera/PerspectiveCamera';
|
|
7
7
|
import { type Object3D } from 'three';
|
|
8
8
|
import { type DIVEBaseTool } from '../../BaseTool';
|
|
9
|
+
import { DIVEAnimationSystem } from '../../../animation/AnimationSystem';
|
|
10
|
+
import { Tween } from '@tweenjs/tween.js';
|
|
11
|
+
|
|
12
|
+
jest.mock('@tweenjs/tween.js', () => {
|
|
13
|
+
return {
|
|
14
|
+
Tween: jest.fn(() => { }),
|
|
15
|
+
update: jest.fn(),
|
|
16
|
+
}
|
|
17
|
+
});
|
|
9
18
|
|
|
10
19
|
jest.mock('../../../renderer/Renderer', () => {
|
|
11
20
|
return jest.fn(function () {
|
|
@@ -39,6 +48,22 @@ jest.mock('../../../controls/OrbitControls', () => {
|
|
|
39
48
|
});
|
|
40
49
|
});
|
|
41
50
|
|
|
51
|
+
|
|
52
|
+
jest.mock('../../../animation/AnimationSystem', () => {
|
|
53
|
+
return {
|
|
54
|
+
DIVEAnimationSystem: jest.fn(function () {
|
|
55
|
+
this.domElement = {
|
|
56
|
+
style: {},
|
|
57
|
+
};
|
|
58
|
+
this.Animate = <T extends object>(obj: T) => {
|
|
59
|
+
return new Tween<T>(obj);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return this;
|
|
63
|
+
}),
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
42
67
|
jest.mock('../../../scene/Scene', () => {
|
|
43
68
|
return jest.fn(function () {
|
|
44
69
|
this.add = jest.fn();
|
|
@@ -115,7 +140,8 @@ const mockRenderer = {
|
|
|
115
140
|
OnResize: jest.fn(),
|
|
116
141
|
} as unknown as DIVERenderer;
|
|
117
142
|
const mockScene: DIVEScene = new DIVEScene();
|
|
118
|
-
const
|
|
143
|
+
const mockAnimSystem = new DIVEAnimationSystem(mockRenderer);
|
|
144
|
+
const mockController: DIVEOrbitControls = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
119
145
|
|
|
120
146
|
describe('dive/toolbox/select/DIVESelectTool', () => {
|
|
121
147
|
it('should test if it is SelectTool', () => {
|
|
@@ -4,6 +4,15 @@ import DIVEOrbitControls from '../../../controls/OrbitControls';
|
|
|
4
4
|
import DIVEPerspectiveCamera from '../../../camera/PerspectiveCamera';
|
|
5
5
|
import { DIVERenderer } from '../../../renderer/Renderer';
|
|
6
6
|
import { type DIVEBaseTool } from '../../BaseTool';
|
|
7
|
+
import { Tween } from '@tweenjs/tween.js';
|
|
8
|
+
import { DIVEAnimationSystem } from '../../../animation/AnimationSystem';
|
|
9
|
+
|
|
10
|
+
jest.mock('@tweenjs/tween.js', () => {
|
|
11
|
+
return {
|
|
12
|
+
Tween: jest.fn(() => { }),
|
|
13
|
+
update: jest.fn(),
|
|
14
|
+
}
|
|
15
|
+
});
|
|
7
16
|
|
|
8
17
|
jest.mock('../../../renderer/Renderer', () => {
|
|
9
18
|
return jest.fn(function () {
|
|
@@ -49,6 +58,21 @@ jest.mock('../../../scene/Scene', () => {
|
|
|
49
58
|
});
|
|
50
59
|
});
|
|
51
60
|
|
|
61
|
+
jest.mock('../../../animation/AnimationSystem', () => {
|
|
62
|
+
return {
|
|
63
|
+
DIVEAnimationSystem: jest.fn(function () {
|
|
64
|
+
this.domElement = {
|
|
65
|
+
style: {},
|
|
66
|
+
};
|
|
67
|
+
this.Animate = <T extends object>(obj: T) => {
|
|
68
|
+
return new Tween<T>(obj);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return this;
|
|
72
|
+
}),
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
52
76
|
const mock_intersectObjects = jest.fn().mockReturnValue([]);
|
|
53
77
|
|
|
54
78
|
jest.mock('three', () => {
|
|
@@ -126,7 +150,8 @@ const mockRenderer = {
|
|
|
126
150
|
RemovePostRenderCallback: jest.fn(),
|
|
127
151
|
} as unknown as DIVERenderer;
|
|
128
152
|
const mockScene: DIVEScene = new DIVEScene();
|
|
129
|
-
const
|
|
153
|
+
const mockAnimSystem = new DIVEAnimationSystem(mockRenderer);
|
|
154
|
+
const mockController: DIVEOrbitControls = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
|
|
130
155
|
|
|
131
156
|
describe('dive/toolbox/select/DIVETransformTool', () => {
|
|
132
157
|
it('should test if it is SelectTool', () => {
|