@shopware-ag/dive 1.16.0 → 1.16.2
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/README.md +271 -40
- package/build/dive.cjs +575 -159
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +83 -57
- package/build/dive.d.ts +83 -57
- package/build/dive.js +614 -164
- package/build/dive.js.map +1 -1
- package/package.json +72 -60
- package/src/__test__/DIVE.test.ts +35 -31
- package/src/animation/AnimationSystem.ts +4 -4
- package/src/animation/__test__/AnimationSystem.test.ts +3 -3
- package/src/axiscamera/AxisCamera.ts +31 -11
- package/src/axiscamera/__test__/AxisCamera.test.ts +18 -10
- package/src/camera/PerspectiveCamera.ts +28 -13
- package/src/camera/__test__/PerspectiveCamera.test.ts +2 -2
- package/src/com/Communication.ts +282 -100
- package/src/com/__test__/Communication.test.ts +207 -141
- package/src/com/actions/camera/computeencompassingview.ts +8 -7
- package/src/com/actions/camera/getcameratransform.ts +8 -7
- package/src/com/actions/camera/movecamera.ts +16 -13
- package/src/com/actions/camera/resetcamera.ts +4 -3
- package/src/com/actions/camera/setcameralayer.ts +4 -3
- package/src/com/actions/camera/setcameratransform.ts +8 -7
- package/src/com/actions/camera/zoomcamera.ts +4 -3
- package/src/com/actions/index.ts +54 -54
- package/src/com/actions/media/generatemedia.ts +17 -13
- package/src/com/actions/object/addobject.ts +5 -4
- package/src/com/actions/object/deleteobject.ts +5 -4
- package/src/com/actions/object/deselectobject.ts +5 -4
- package/src/com/actions/object/getallobjects.ts +5 -4
- package/src/com/actions/object/getobjects.ts +5 -4
- package/src/com/actions/object/model/dropit.ts +4 -3
- package/src/com/actions/object/model/modelloaded.ts +4 -3
- package/src/com/actions/object/model/placeonfloor.ts +4 -3
- package/src/com/actions/object/selectobject.ts +5 -4
- package/src/com/actions/object/setparent.ts +8 -7
- package/src/com/actions/object/updateobject.ts +5 -4
- package/src/com/actions/scene/exportscene.ts +5 -4
- package/src/com/actions/scene/getallscenedata.ts +24 -18
- package/src/com/actions/scene/setbackground.ts +4 -3
- package/src/com/actions/scene/updatescene.ts +10 -9
- package/src/com/actions/toolbox/select/setgizmomode.ts +4 -3
- package/src/com/actions/toolbox/transform/setgizmovisible.ts +4 -3
- package/src/com/actions/toolbox/usetool.ts +5 -4
- package/src/com/types/COMBaseEntity.ts +2 -2
- package/src/com/types/COMEntity.ts +6 -6
- package/src/com/types/COMEntityType.ts +1 -1
- package/src/com/types/COMGeometry.ts +2 -2
- package/src/com/types/COMGroup.ts +3 -3
- package/src/com/types/COMLight.ts +3 -3
- package/src/com/types/COMMaterial.ts +2 -2
- package/src/com/types/COMModel.ts +4 -4
- package/src/com/types/COMPov.ts +3 -3
- package/src/com/types/COMPrimitive.ts +5 -5
- package/src/com/types/index.ts +10 -10
- package/src/constant/AxisHelperColors.ts +1 -1
- package/src/constant/GridColors.ts +1 -1
- package/src/controls/OrbitControls.ts +62 -29
- package/src/controls/__test__/OrbitControls.test.ts +133 -39
- package/src/dive.ts +82 -36
- package/src/gizmo/Gizmo.ts +21 -13
- package/src/gizmo/handles/AxisHandle.ts +40 -17
- package/src/gizmo/handles/RadialHandle.ts +39 -15
- package/src/gizmo/handles/ScaleHandle.ts +62 -25
- package/src/gizmo/plane/GizmoPlane.ts +5 -6
- package/src/gizmo/rotate/RotateGizmo.ts +58 -16
- package/src/gizmo/scale/ScaleGizmo.ts +37 -15
- package/src/gizmo/translate/TranslateGizmo.ts +34 -14
- package/src/grid/Grid.ts +13 -5
- package/src/grid/__test__/Grid.test.ts +5 -3
- package/src/group/Group.ts +9 -7
- package/src/group/__test__/Group.test.ts +8 -6
- package/src/helper/applyMixins/__test__/applyMixins.test.ts +9 -6
- package/src/helper/applyMixins/applyMixins.ts +6 -3
- package/src/helper/findInterface/__test__/findInterface.test.ts +28 -18
- package/src/helper/findInterface/findInterface.ts +7 -4
- package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +1 -1
- package/src/helper/findSceneRecursive/findSceneRecursive.ts +1 -1
- package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +43 -7
- package/src/helper/getObjectDelta/getObjectDelta.ts +13 -9
- package/src/helper/isInterface/__test__/implementsInterface.test.ts +1 -1
- package/src/helper/isInterface/implementsInterface.ts +6 -3
- package/src/info/Info.ts +20 -16
- package/src/info/__test__/Info.test.ts +67 -36
- package/src/interface/Draggable.ts +2 -2
- package/src/interface/Hoverable.ts +2 -2
- package/src/interface/Movable.ts +1 -1
- package/src/interface/Rotatable.ts +1 -1
- package/src/interface/Scalable.ts +1 -1
- package/src/io/IO.ts +21 -43
- package/src/io/__test__/IO.test.ts +16 -62
- package/src/io/gltf/GLTFIO.ts +34 -31
- package/src/io/gltf/__test__/GLTFIO.test.ts +88 -78
- package/src/light/PointLight.ts +42 -9
- package/src/light/SceneLight.ts +5 -5
- package/src/light/__test__/AmbientLight.test.ts +5 -4
- package/src/light/__test__/PointLight.test.ts +14 -10
- package/src/light/__test__/SceneLight.test.ts +19 -13
- package/src/loadingmanager/LoadingManager.ts +11 -6
- package/src/loadingmanager/__test__/LoadingManager.test.ts +14 -9
- package/src/math/__test__/DIVEMath.test.ts +1 -1
- package/src/math/ceil/__test__/ceilExp.test.ts +1 -1
- package/src/math/ceil/ceilExp.ts +2 -2
- package/src/math/floor/__test__/floorExp.test.ts +1 -1
- package/src/math/floor/floorExp.ts +2 -2
- package/src/math/helper/__test__/shift.test.ts +1 -1
- package/src/math/helper/shift.ts +1 -1
- package/src/math/index.ts +7 -7
- package/src/math/round/__test__/roundExp.test.ts +1 -1
- package/src/math/round/roundExp.ts +6 -3
- package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +10 -4
- package/src/math/signedAngleTo/signedAngleTo.ts +11 -4
- package/src/math/toFixed/__test__/toFixedExp.test.ts +9 -9
- package/src/math/toFixed/toFixedExp.ts +6 -3
- package/src/math/truncate/__test__/truncateExp.test.ts +1 -1
- package/src/math/truncate/truncateExp.ts +6 -3
- package/src/mediacreator/MediaCreator.ts +20 -10
- package/src/mediacreator/__test__/MediaCreator.test.ts +27 -12
- package/src/model/Model.ts +35 -7
- package/src/model/__test__/Model.test.ts +71 -44
- package/src/node/Node.ts +34 -12
- package/src/node/__test__/Node.test.ts +17 -13
- package/src/primitive/Primitive.ts +78 -13
- package/src/primitive/__test__/Primitive.test.ts +49 -38
- package/src/primitive/floor/Floor.ts +14 -3
- package/src/primitive/floor/__test__/Floor.test.ts +10 -4
- package/src/renderer/Renderer.ts +46 -15
- package/src/renderer/__test__/Renderer.test.ts +74 -24
- package/src/scene/Scene.ts +9 -3
- package/src/scene/__test__/Scene.test.ts +2 -2
- package/src/scene/root/Root.ts +142 -75
- package/src/scene/root/__test__/Root.test.ts +439 -111
- package/src/toolbox/BaseTool.ts +69 -33
- package/src/toolbox/Toolbox.ts +37 -17
- package/src/toolbox/__test__/BaseTool.test.ts +324 -160
- package/src/toolbox/__test__/Toolbox.test.ts +31 -14
- package/src/toolbox/select/SelectTool.ts +24 -19
- package/src/toolbox/select/__test__/SelectTool.test.ts +95 -59
- package/src/toolbox/transform/TransformTool.ts +40 -17
- package/src/toolbox/transform/__test__/TransformTool.test.ts +22 -15
- package/src/types/SceneObjects.ts +8 -8
- package/src/types/SceneType.ts +3 -3
- package/src/types/index.ts +3 -6
package/package.json
CHANGED
|
@@ -1,62 +1,74 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
2
|
+
"name": "@shopware-ag/dive",
|
|
3
|
+
"version": "1.16.2",
|
|
4
|
+
"description": "Shopware Spatial Framework",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./build/dive.cjs",
|
|
7
|
+
"module": "./build/dive.js",
|
|
8
|
+
"types": "./build/dive.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"build",
|
|
11
|
+
"LICENSE",
|
|
12
|
+
"package.json",
|
|
13
|
+
"README.md",
|
|
14
|
+
"src"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"dive",
|
|
18
|
+
"shopware",
|
|
19
|
+
"sw6",
|
|
20
|
+
"three",
|
|
21
|
+
"three.js",
|
|
22
|
+
"3d",
|
|
23
|
+
"typescript"
|
|
24
|
+
],
|
|
25
|
+
"repository": "git@github.com:shopware/dive.git",
|
|
26
|
+
"author": "ffrank <f.frank@shopware.com>",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"browserslist": [
|
|
29
|
+
"> 1%, not dead, not ie 11, not op_mini all"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@tweenjs/tween.js": "^23.1.1",
|
|
33
|
+
"lodash": "^4.17.21",
|
|
34
|
+
"three": "^0.163.0",
|
|
35
|
+
"three-spritetext": "^1.8.2"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@eslint/js": "^9.1.1",
|
|
39
|
+
"@types/jest": "^29.5.12",
|
|
40
|
+
"@types/lodash": "^4.17.12",
|
|
41
|
+
"@types/node": "^20.12.7",
|
|
42
|
+
"@types/three": "^0.163.0",
|
|
43
|
+
"eslint": "^9.1.1",
|
|
44
|
+
"globals": "^15.0.0",
|
|
45
|
+
"jest": "^29.7.0",
|
|
46
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
47
|
+
"jsdom": "^24.0.0",
|
|
48
|
+
"prettier": "^3.3.3",
|
|
49
|
+
"prettier-plugin-multiline-arrays": "^3.0.6",
|
|
50
|
+
"ts-jest": "^29.1.2",
|
|
51
|
+
"ts-node": "^10.9.2",
|
|
52
|
+
"tsc": "^2.0.4",
|
|
53
|
+
"tsup": "^8.0.2",
|
|
54
|
+
"typescript": "^5.4.5",
|
|
55
|
+
"typescript-eslint": "^7.7.1"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsup",
|
|
59
|
+
"dev": "tsup --watch",
|
|
60
|
+
"lint": "eslint",
|
|
61
|
+
"lint:actions": "yarn lint:actions:transpile && yarn lint:actions:check && yarn lint:actions:cleanup",
|
|
62
|
+
"lint:actions:transpile": "yarn tsc --resolveJsonModule --esModuleInterop ci/lint/lint-actions.ts && mv ci/lint/lint-actions.js ci/lint/lint-actions.cjs",
|
|
63
|
+
"lint:actions:check": "yarn node ci/lint/lint-actions.cjs",
|
|
64
|
+
"lint:actions:cleanup": "node -e \"require('fs').unlinkSync('ci/lint/lint-actions.cjs')\"",
|
|
65
|
+
"prettier:check": "prettier --check .",
|
|
66
|
+
"prettier:fix": "prettier --write .",
|
|
67
|
+
"unit": "jest",
|
|
68
|
+
"coverage": "jest --coverage",
|
|
69
|
+
"generate-readme": "yarn generate-readme:transpile && yarn generate-readme:write && yarn generate-readme:cleanup",
|
|
70
|
+
"generate-readme:transpile": "yarn tsc --resolveJsonModule --esModuleInterop ci/readme/generate-readme.ts && mv ci/readme/generate-readme.js ci/readme/generate-readme.cjs",
|
|
71
|
+
"generate-readme:write": "node ci/readme/generate-readme.cjs",
|
|
72
|
+
"generate-readme:cleanup": "node -e \"require('fs').unlinkSync('ci/readme/generate-readme.cjs')\""
|
|
73
|
+
}
|
|
62
74
|
}
|
|
@@ -25,15 +25,19 @@ jest.mock('three', () => {
|
|
|
25
25
|
return this;
|
|
26
26
|
}),
|
|
27
27
|
MathUtils: {
|
|
28
|
-
generateUUID: () => {
|
|
28
|
+
generateUUID: () => {
|
|
29
|
+
return 'test_uuid';
|
|
30
|
+
},
|
|
29
31
|
},
|
|
30
|
-
}
|
|
32
|
+
};
|
|
31
33
|
});
|
|
32
34
|
|
|
33
35
|
jest.mock('three/src/math/MathUtils', () => {
|
|
34
36
|
return {
|
|
35
|
-
generateUUID: () => {
|
|
36
|
-
|
|
37
|
+
generateUUID: () => {
|
|
38
|
+
return 'test_uuid';
|
|
39
|
+
},
|
|
40
|
+
};
|
|
37
41
|
});
|
|
38
42
|
|
|
39
43
|
jest.mock('../com/Communication.ts', () => {
|
|
@@ -43,14 +47,16 @@ jest.mock('../com/Communication.ts', () => {
|
|
|
43
47
|
position: { x: 0, y: 0, z: 0 },
|
|
44
48
|
target: { x: 0, y: 0, z: 0 },
|
|
45
49
|
});
|
|
46
|
-
this.Subscribe = jest.fn(
|
|
47
|
-
callback({ id:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
this.Subscribe = jest.fn(
|
|
51
|
+
(action: string, callback: (data: { id: string }) => void) => {
|
|
52
|
+
callback({ id: 'incorrect id' });
|
|
53
|
+
callback({ id: 'test_uuid' });
|
|
54
|
+
},
|
|
55
|
+
);
|
|
50
56
|
this.DestroyInstance = jest.fn();
|
|
51
57
|
|
|
52
58
|
return this;
|
|
53
|
-
})
|
|
59
|
+
}),
|
|
54
60
|
};
|
|
55
61
|
});
|
|
56
62
|
|
|
@@ -81,7 +87,7 @@ jest.mock('../renderer/Renderer.ts', () => {
|
|
|
81
87
|
this.Dispose = jest.fn();
|
|
82
88
|
return this;
|
|
83
89
|
}),
|
|
84
|
-
}
|
|
90
|
+
};
|
|
85
91
|
});
|
|
86
92
|
|
|
87
93
|
jest.mock('../scene/Scene.ts', () => {
|
|
@@ -93,16 +99,16 @@ jest.mock('../scene/Scene.ts', () => {
|
|
|
93
99
|
this.dispatchEvent = jest.fn();
|
|
94
100
|
this.position = {
|
|
95
101
|
set: jest.fn(),
|
|
96
|
-
}
|
|
102
|
+
};
|
|
97
103
|
this.SetIntensity = jest.fn();
|
|
98
104
|
this.SetEnabled = jest.fn();
|
|
99
105
|
this.SetColor = jest.fn();
|
|
100
106
|
this.userData = {
|
|
101
107
|
id: undefined,
|
|
102
|
-
}
|
|
108
|
+
};
|
|
103
109
|
this.removeFromParent = jest.fn();
|
|
104
110
|
return this;
|
|
105
|
-
})
|
|
111
|
+
}),
|
|
106
112
|
};
|
|
107
113
|
});
|
|
108
114
|
|
|
@@ -113,13 +119,13 @@ jest.mock('../camera/PerspectiveCamera.ts', () => {
|
|
|
113
119
|
this.dispatchEvent = jest.fn();
|
|
114
120
|
this.position = {
|
|
115
121
|
set: jest.fn(),
|
|
116
|
-
}
|
|
122
|
+
};
|
|
117
123
|
this.SetIntensity = jest.fn();
|
|
118
124
|
this.SetEnabled = jest.fn();
|
|
119
125
|
this.SetColor = jest.fn();
|
|
120
126
|
this.userData = {
|
|
121
127
|
id: undefined,
|
|
122
|
-
}
|
|
128
|
+
};
|
|
123
129
|
this.removeFromParent = jest.fn();
|
|
124
130
|
this.OnResize = jest.fn();
|
|
125
131
|
return this;
|
|
@@ -133,13 +139,13 @@ jest.mock('../controls/OrbitControls.ts', () => {
|
|
|
133
139
|
this.dispatchEvent = jest.fn();
|
|
134
140
|
this.position = {
|
|
135
141
|
set: jest.fn(),
|
|
136
|
-
}
|
|
142
|
+
};
|
|
137
143
|
this.SetIntensity = jest.fn();
|
|
138
144
|
this.SetEnabled = jest.fn();
|
|
139
145
|
this.SetColor = jest.fn();
|
|
140
146
|
this.userData = {
|
|
141
147
|
id: undefined,
|
|
142
|
-
}
|
|
148
|
+
};
|
|
143
149
|
this.removeFromParent = jest.fn();
|
|
144
150
|
this.Dispose = jest.fn();
|
|
145
151
|
return this;
|
|
@@ -153,13 +159,13 @@ jest.mock('../toolbox/Toolbox.ts', () => {
|
|
|
153
159
|
this.dispatchEvent = jest.fn();
|
|
154
160
|
this.position = {
|
|
155
161
|
set: jest.fn(),
|
|
156
|
-
}
|
|
162
|
+
};
|
|
157
163
|
this.SetIntensity = jest.fn();
|
|
158
164
|
this.SetEnabled = jest.fn();
|
|
159
165
|
this.SetColor = jest.fn();
|
|
160
166
|
this.userData = {
|
|
161
167
|
id: undefined,
|
|
162
|
-
}
|
|
168
|
+
};
|
|
163
169
|
this.Dispose = jest.fn();
|
|
164
170
|
this.removeFromParent = jest.fn();
|
|
165
171
|
return this;
|
|
@@ -173,13 +179,13 @@ jest.mock('../axiscamera/AxisCamera.ts', () => {
|
|
|
173
179
|
this.dispatchEvent = jest.fn();
|
|
174
180
|
this.position = {
|
|
175
181
|
set: jest.fn(),
|
|
176
|
-
}
|
|
182
|
+
};
|
|
177
183
|
this.SetIntensity = jest.fn();
|
|
178
184
|
this.SetEnabled = jest.fn();
|
|
179
185
|
this.SetColor = jest.fn();
|
|
180
186
|
this.userData = {
|
|
181
187
|
id: undefined,
|
|
182
|
-
}
|
|
188
|
+
};
|
|
183
189
|
this.removeFromParent = jest.fn();
|
|
184
190
|
this.SetFromCameraMatrix = jest.fn();
|
|
185
191
|
this.Dispose = jest.fn();
|
|
@@ -208,7 +214,7 @@ describe('dive/DIVE', () => {
|
|
|
208
214
|
|
|
209
215
|
const settings = {
|
|
210
216
|
displayAxes: true,
|
|
211
|
-
}
|
|
217
|
+
};
|
|
212
218
|
dive = new DIVE(settings);
|
|
213
219
|
expect(() => dive.Dispose()).not.toThrow();
|
|
214
220
|
});
|
|
@@ -233,7 +239,7 @@ describe('dive/DIVE', () => {
|
|
|
233
239
|
orbitControls: {
|
|
234
240
|
enableDamping: false,
|
|
235
241
|
dampingFactor: 0,
|
|
236
|
-
}
|
|
242
|
+
},
|
|
237
243
|
} as DIVESettings;
|
|
238
244
|
const dive = new DIVE(settings);
|
|
239
245
|
expect(dive).toBeDefined();
|
|
@@ -280,23 +286,21 @@ describe('dive/DIVE', () => {
|
|
|
280
286
|
orbitControls: {
|
|
281
287
|
enableDamping: false,
|
|
282
288
|
dampingFactor: 0,
|
|
283
|
-
}
|
|
284
|
-
}
|
|
289
|
+
},
|
|
290
|
+
};
|
|
285
291
|
|
|
286
292
|
dive.Settings = {
|
|
287
293
|
autoResize: true,
|
|
288
|
-
}
|
|
294
|
+
};
|
|
289
295
|
|
|
290
296
|
Object.assign(dive.Canvas, { parentElement: null });
|
|
291
297
|
|
|
292
298
|
dive.Settings = {
|
|
293
299
|
autoResize: false,
|
|
294
|
-
}
|
|
300
|
+
};
|
|
295
301
|
|
|
296
302
|
dive.Settings = {
|
|
297
303
|
autoResize: true,
|
|
298
|
-
}
|
|
304
|
+
};
|
|
299
305
|
});
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
});
|
|
306
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Tween, update as updateTween } from
|
|
2
|
-
import { DIVERenderer } from
|
|
1
|
+
import { Tween, update as updateTween } from '@tweenjs/tween.js';
|
|
2
|
+
import { DIVERenderer } from '../renderer/Renderer';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Updates all animations.
|
|
@@ -17,7 +17,7 @@ export class DIVEAnimationSystem {
|
|
|
17
17
|
|
|
18
18
|
this._rendererCallbackId = this._renderer.AddPreRenderCallback(() => {
|
|
19
19
|
this.Update();
|
|
20
|
-
})
|
|
20
|
+
});
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
public Dispose(): void {
|
|
@@ -31,4 +31,4 @@ export class DIVEAnimationSystem {
|
|
|
31
31
|
public Animate<T extends object>(object: T): Tween<T> {
|
|
32
32
|
return new Tween<T>(object);
|
|
33
33
|
}
|
|
34
|
-
}
|
|
34
|
+
}
|
|
@@ -3,9 +3,9 @@ import { DIVEAnimationSystem } from '../AnimationSystem';
|
|
|
3
3
|
|
|
4
4
|
jest.mock('@tweenjs/tween.js', () => {
|
|
5
5
|
return {
|
|
6
|
-
Tween: jest.fn(() => {
|
|
6
|
+
Tween: jest.fn(() => {}),
|
|
7
7
|
update: jest.fn(),
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
const mockRenderer = {
|
|
@@ -44,4 +44,4 @@ describe('dive/animation/DIVEAnimationSystem', () => {
|
|
|
44
44
|
const anim = new DIVEAnimationSystem(mockRenderer);
|
|
45
45
|
expect(() => anim.Dispose()).not.toThrow();
|
|
46
46
|
});
|
|
47
|
-
});
|
|
47
|
+
});
|
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
AxesHelper,
|
|
3
|
+
Color,
|
|
4
|
+
Material,
|
|
5
|
+
Matrix4,
|
|
6
|
+
OrthographicCamera,
|
|
7
|
+
Vector4,
|
|
8
|
+
} from 'three';
|
|
9
|
+
import SpriteText from 'three-spritetext';
|
|
10
|
+
import { COORDINATE_LAYER_MASK } from '../constant/VisibilityLayerMask.ts';
|
|
11
|
+
import {
|
|
12
|
+
AxesColorRed,
|
|
13
|
+
AxesColorGreen,
|
|
14
|
+
AxesColorBlue,
|
|
15
|
+
AxesColorRedLetter,
|
|
16
|
+
AxesColorGreenLetter,
|
|
17
|
+
AxesColorBlueLetter,
|
|
18
|
+
} from '../constant/AxisHelperColors.ts';
|
|
19
|
+
import { DIVERenderer } from '../renderer/Renderer.ts';
|
|
20
|
+
import { DIVEScene } from '../scene/Scene.ts';
|
|
21
|
+
import DIVEOrbitControls from '../controls/OrbitControls.ts';
|
|
8
22
|
|
|
9
23
|
/**
|
|
10
24
|
* Shows the scene axes in the bottom left corner of the screen.
|
|
@@ -20,7 +34,11 @@ export default class DIVEAxisCamera extends OrthographicCamera {
|
|
|
20
34
|
|
|
21
35
|
private _renderCallbackId: string;
|
|
22
36
|
|
|
23
|
-
constructor(
|
|
37
|
+
constructor(
|
|
38
|
+
renderer: DIVERenderer,
|
|
39
|
+
scene: DIVEScene,
|
|
40
|
+
controls: DIVEOrbitControls,
|
|
41
|
+
) {
|
|
24
42
|
super(-1, 1, 1, -1, 0.1, 100);
|
|
25
43
|
|
|
26
44
|
this.layers.mask = COORDINATE_LAYER_MASK;
|
|
@@ -33,7 +51,7 @@ export default class DIVEAxisCamera extends OrthographicCamera {
|
|
|
33
51
|
this.axesHelper.setColors(
|
|
34
52
|
new Color(AxesColorRed),
|
|
35
53
|
new Color(AxesColorGreen),
|
|
36
|
-
new Color(AxesColorBlue)
|
|
54
|
+
new Color(AxesColorBlue),
|
|
37
55
|
);
|
|
38
56
|
|
|
39
57
|
const x = new SpriteText('X', 0.2, AxesColorRedLetter);
|
|
@@ -83,6 +101,8 @@ export default class DIVEAxisCamera extends OrthographicCamera {
|
|
|
83
101
|
}
|
|
84
102
|
|
|
85
103
|
public SetFromCameraMatrix(matrix: Matrix4): void {
|
|
86
|
-
this.axesHelper.rotation.setFromRotationMatrix(
|
|
104
|
+
this.axesHelper.rotation.setFromRotationMatrix(
|
|
105
|
+
new Matrix4().extractRotation(matrix).invert(),
|
|
106
|
+
);
|
|
87
107
|
}
|
|
88
|
-
}
|
|
108
|
+
}
|
|
@@ -12,8 +12,13 @@ jest.mock('three', () => {
|
|
|
12
12
|
return this;
|
|
13
13
|
}),
|
|
14
14
|
Matrix4: jest.fn(function () {
|
|
15
|
-
this.extractRotation = jest.fn(() => {
|
|
16
|
-
|
|
15
|
+
this.extractRotation = jest.fn(() => {
|
|
16
|
+
return this;
|
|
17
|
+
});
|
|
18
|
+
this.invert = jest.fn(() => {
|
|
19
|
+
return this;
|
|
20
|
+
});
|
|
21
|
+
// prettier-multiline-arrays-next-line-pattern: 4
|
|
17
22
|
this.elements = [
|
|
18
23
|
1, 0, 0, 0,
|
|
19
24
|
0, 1, 0, 0,
|
|
@@ -23,7 +28,6 @@ jest.mock('three', () => {
|
|
|
23
28
|
return this;
|
|
24
29
|
}),
|
|
25
30
|
OrthographicCamera: jest.fn(function () {
|
|
26
|
-
|
|
27
31
|
this.isObject3D = true;
|
|
28
32
|
this.parent = null;
|
|
29
33
|
this.dispatchEvent = jest.fn();
|
|
@@ -53,10 +57,10 @@ jest.mock('three', () => {
|
|
|
53
57
|
this.setColors = jest.fn();
|
|
54
58
|
this.rotation = {
|
|
55
59
|
setFromRotationMatrix: jest.fn(),
|
|
56
|
-
}
|
|
60
|
+
};
|
|
57
61
|
return this;
|
|
58
62
|
}),
|
|
59
|
-
}
|
|
63
|
+
};
|
|
60
64
|
});
|
|
61
65
|
|
|
62
66
|
jest.mock('three-spritetext', () => {
|
|
@@ -72,9 +76,8 @@ jest.mock('three-spritetext', () => {
|
|
|
72
76
|
set: jest.fn(),
|
|
73
77
|
},
|
|
74
78
|
removeFromParent: jest.fn(),
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
)
|
|
79
|
+
};
|
|
80
|
+
});
|
|
78
81
|
});
|
|
79
82
|
|
|
80
83
|
const mockRenderer = {
|
|
@@ -188,7 +191,11 @@ let textAxisCamera: DIVEAxisCamera;
|
|
|
188
191
|
|
|
189
192
|
describe('dive/axiscamera/DIVEAxisCamera', () => {
|
|
190
193
|
beforeEach(() => {
|
|
191
|
-
textAxisCamera = new DIVEAxisCamera(
|
|
194
|
+
textAxisCamera = new DIVEAxisCamera(
|
|
195
|
+
mockRenderer,
|
|
196
|
+
mockScene,
|
|
197
|
+
mockController,
|
|
198
|
+
);
|
|
192
199
|
});
|
|
193
200
|
|
|
194
201
|
it('should instantiate', () => {
|
|
@@ -198,6 +205,7 @@ describe('dive/axiscamera/DIVEAxisCamera', () => {
|
|
|
198
205
|
it('should set rotation from Matrix4', () => {
|
|
199
206
|
expect.assertions(0);
|
|
200
207
|
const matrix = {
|
|
208
|
+
// prettier-multiline-arrays-next-line-pattern: 4
|
|
201
209
|
elements: [
|
|
202
210
|
1, 0, 0, 0,
|
|
203
211
|
0, 1, 0, 0,
|
|
@@ -211,4 +219,4 @@ describe('dive/axiscamera/DIVEAxisCamera', () => {
|
|
|
211
219
|
it('should dispose', () => {
|
|
212
220
|
textAxisCamera.Dispose();
|
|
213
221
|
});
|
|
214
|
-
});
|
|
222
|
+
});
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { PerspectiveCamera } from
|
|
2
|
-
import {
|
|
1
|
+
import { PerspectiveCamera } from 'three';
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_LAYER_MASK,
|
|
4
|
+
HELPER_LAYER_MASK,
|
|
5
|
+
PRODUCT_LAYER_MASK,
|
|
6
|
+
UI_LAYER_MASK,
|
|
7
|
+
} from '../constant/VisibilityLayerMask.ts';
|
|
3
8
|
|
|
4
9
|
export type DIVEPerspectiveCameraSettings = {
|
|
5
10
|
fov: number;
|
|
6
11
|
near: number;
|
|
7
12
|
far: number;
|
|
8
|
-
}
|
|
13
|
+
};
|
|
9
14
|
|
|
10
|
-
export const DIVEPerspectiveCameraDefaultSettings: DIVEPerspectiveCameraSettings =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
export const DIVEPerspectiveCameraDefaultSettings: DIVEPerspectiveCameraSettings =
|
|
16
|
+
{
|
|
17
|
+
fov: 80,
|
|
18
|
+
near: 0.1,
|
|
19
|
+
far: 1000,
|
|
20
|
+
};
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
23
|
* A Perspective camera. Can change the layer mask to show different objects.
|
|
@@ -20,17 +26,23 @@ export const DIVEPerspectiveCameraDefaultSettings: DIVEPerspectiveCameraSettings
|
|
|
20
26
|
*/
|
|
21
27
|
|
|
22
28
|
export default class DIVEPerspectiveCamera extends PerspectiveCamera {
|
|
23
|
-
public static readonly EDITOR_VIEW_LAYER_MASK =
|
|
29
|
+
public static readonly EDITOR_VIEW_LAYER_MASK =
|
|
30
|
+
DEFAULT_LAYER_MASK |
|
|
31
|
+
UI_LAYER_MASK |
|
|
32
|
+
HELPER_LAYER_MASK |
|
|
33
|
+
PRODUCT_LAYER_MASK;
|
|
24
34
|
public static readonly LIVE_VIEW_LAYER_MASK = PRODUCT_LAYER_MASK;
|
|
25
35
|
|
|
26
|
-
public onSetCameraLayer: (mask: number) => void = () => {
|
|
36
|
+
public onSetCameraLayer: (mask: number) => void = () => {};
|
|
27
37
|
|
|
28
|
-
constructor(
|
|
38
|
+
constructor(
|
|
39
|
+
settings: Partial<DIVEPerspectiveCameraSettings> = DIVEPerspectiveCameraDefaultSettings,
|
|
40
|
+
) {
|
|
29
41
|
super(
|
|
30
42
|
settings.fov || DIVEPerspectiveCameraDefaultSettings.fov,
|
|
31
43
|
1,
|
|
32
44
|
settings.near || DIVEPerspectiveCameraDefaultSettings.near,
|
|
33
|
-
settings.far || DIVEPerspectiveCameraDefaultSettings.far
|
|
45
|
+
settings.far || DIVEPerspectiveCameraDefaultSettings.far,
|
|
34
46
|
);
|
|
35
47
|
|
|
36
48
|
this.layers.mask = DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK;
|
|
@@ -42,7 +54,10 @@ export default class DIVEPerspectiveCamera extends PerspectiveCamera {
|
|
|
42
54
|
}
|
|
43
55
|
|
|
44
56
|
public SetCameraLayer(layer: 'LIVE' | 'EDITOR'): void {
|
|
45
|
-
this.layers.mask =
|
|
57
|
+
this.layers.mask =
|
|
58
|
+
layer === 'LIVE'
|
|
59
|
+
? DIVEPerspectiveCamera.LIVE_VIEW_LAYER_MASK
|
|
60
|
+
: DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK;
|
|
46
61
|
this.onSetCameraLayer(this.layers.mask);
|
|
47
62
|
}
|
|
48
63
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import DIVEPerspectiveCamera
|
|
1
|
+
import DIVEPerspectiveCamera from '../PerspectiveCamera';
|
|
2
2
|
|
|
3
3
|
let cam: DIVEPerspectiveCamera;
|
|
4
4
|
|
|
@@ -33,4 +33,4 @@ describe('dive/camera/DIVEPerspectiveCamera', () => {
|
|
|
33
33
|
expect(() => cam.SetCameraLayer('LIVE')).not.toThrow();
|
|
34
34
|
expect(() => cam.SetCameraLayer('EDITOR')).not.toThrow();
|
|
35
35
|
});
|
|
36
|
-
});
|
|
36
|
+
});
|