@shopware-ag/dive 1.19.1-beta.0 → 1.19.1-beta.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.
Files changed (188) hide show
  1. package/build/dive.cjs +362 -199
  2. package/build/dive.cjs.map +1 -1
  3. package/build/dive.js +330 -167
  4. package/build/dive.js.map +1 -1
  5. package/build/dive.mjs +10803 -8714
  6. package/build/dive.mjs.map +1 -1
  7. package/build/src/converter/Converter.d.ts +3 -12
  8. package/build/src/dive.d.ts +1 -0
  9. package/build/src/exporter/Exporter.d.ts +20 -2
  10. package/build/src/loader/Loader.d.ts +0 -4
  11. package/build/src/types/error/index.d.ts +12 -0
  12. package/build/src/types/file/FileTypes.d.ts +17 -0
  13. package/build/src/types/file/index.d.ts +1 -0
  14. package/build/src/types/index.d.ts +5 -8
  15. package/package.json +2 -3
  16. package/build/src/types/ExporterOptions.d.ts +0 -15
  17. package/build/src/types/FileTypes.d.ts +0 -27
  18. package/src/__test__/DIVE.test.ts +0 -274
  19. package/src/animation/AnimationSystem.ts +0 -34
  20. package/src/animation/__test__/AnimationSystem.test.ts +0 -40
  21. package/src/ar/AR.ts +0 -101
  22. package/src/ar/__test__/AR.test.ts +0 -276
  23. package/src/ar/arquicklook/ARQuickLook.ts +0 -53
  24. package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +0 -144
  25. package/src/ar/sceneviewer/SceneViewer.ts +0 -119
  26. package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +0 -190
  27. package/src/ar/webxr/WebXR.ts +0 -177
  28. package/src/ar/webxr/controller/WebXRController.ts +0 -340
  29. package/src/ar/webxr/crosshair/WebXRCrosshair.ts +0 -35
  30. package/src/ar/webxr/origin/WebXROrigin.ts +0 -192
  31. package/src/ar/webxr/overlay/Overlay.ts +0 -50
  32. package/src/ar/webxr/raycaster/WebXRRaycaster.ts +0 -131
  33. package/src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts +0 -102
  34. package/src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts +0 -49
  35. package/src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts +0 -356
  36. package/src/axiscamera/AxisCamera.ts +0 -108
  37. package/src/axiscamera/__test__/AxisCamera.test.ts +0 -150
  38. package/src/camera/PerspectiveCamera.ts +0 -63
  39. package/src/camera/__test__/PerspectiveCamera.test.ts +0 -36
  40. package/src/com/Communication.ts +0 -806
  41. package/src/com/__test__/Communication.test.ts +0 -1030
  42. package/src/com/actions/camera/computeencompassingview.ts +0 -10
  43. package/src/com/actions/camera/getcameratransform.ts +0 -10
  44. package/src/com/actions/camera/movecamera.ts +0 -18
  45. package/src/com/actions/camera/resetcamera.ts +0 -5
  46. package/src/com/actions/camera/setcameralayer.ts +0 -5
  47. package/src/com/actions/camera/setcameratransform.ts +0 -10
  48. package/src/com/actions/camera/zoomcamera.ts +0 -5
  49. package/src/com/actions/index.ts +0 -61
  50. package/src/com/actions/media/generatemedia.ts +0 -18
  51. package/src/com/actions/object/addobject.ts +0 -7
  52. package/src/com/actions/object/deleteobject.ts +0 -7
  53. package/src/com/actions/object/deselectobject.ts +0 -7
  54. package/src/com/actions/object/getallobjects.ts +0 -7
  55. package/src/com/actions/object/getobjects.ts +0 -7
  56. package/src/com/actions/object/model/dropit.ts +0 -5
  57. package/src/com/actions/object/model/modelloaded.ts +0 -5
  58. package/src/com/actions/object/model/placeonfloor.ts +0 -5
  59. package/src/com/actions/object/selectobject.ts +0 -7
  60. package/src/com/actions/object/setparent.ts +0 -10
  61. package/src/com/actions/object/updateobject.ts +0 -7
  62. package/src/com/actions/renderer/startrender.ts +0 -5
  63. package/src/com/actions/scene/exportscene.ts +0 -7
  64. package/src/com/actions/scene/getallscenedata.ts +0 -7
  65. package/src/com/actions/scene/launchar.ts +0 -7
  66. package/src/com/actions/scene/setbackground.ts +0 -5
  67. package/src/com/actions/scene/updatescene.ts +0 -11
  68. package/src/com/actions/toolbox/select/setgizmomode.ts +0 -5
  69. package/src/com/actions/toolbox/transform/setgizmoscalelinked.ts +0 -5
  70. package/src/com/actions/toolbox/transform/setgizmovisible.ts +0 -5
  71. package/src/com/actions/toolbox/usetool.ts +0 -7
  72. package/src/com/types/COMBaseEntity.ts +0 -9
  73. package/src/com/types/COMEntity.ts +0 -7
  74. package/src/com/types/COMEntityType.ts +0 -1
  75. package/src/com/types/COMGeometry.ts +0 -8
  76. package/src/com/types/COMGeometryType.ts +0 -9
  77. package/src/com/types/COMGroup.ts +0 -9
  78. package/src/com/types/COMLight.ts +0 -11
  79. package/src/com/types/COMMaterial.ts +0 -12
  80. package/src/com/types/COMModel.ts +0 -12
  81. package/src/com/types/COMPov.ts +0 -8
  82. package/src/com/types/COMPrimitive.ts +0 -12
  83. package/src/com/types/index.ts +0 -23
  84. package/src/constant/AxisHelperColors.ts +0 -7
  85. package/src/constant/GridColors.ts +0 -2
  86. package/src/constant/VisibilityLayerMask.ts +0 -5
  87. package/src/controls/OrbitControls.ts +0 -211
  88. package/src/controls/__test__/OrbitControls.test.ts +0 -256
  89. package/src/converter/Converter.ts +0 -117
  90. package/src/dive.ts +0 -363
  91. package/src/events/EventExecutor.ts +0 -35
  92. package/src/exporter/Exporter.ts +0 -75
  93. package/src/gizmo/Gizmo.ts +0 -144
  94. package/src/gizmo/handles/AxisHandle.ts +0 -153
  95. package/src/gizmo/handles/RadialHandle.ts +0 -149
  96. package/src/gizmo/handles/ScaleHandle.ts +0 -195
  97. package/src/gizmo/plane/GizmoPlane.ts +0 -84
  98. package/src/gizmo/rotate/RotateGizmo.ts +0 -143
  99. package/src/gizmo/scale/ScaleGizmo.ts +0 -125
  100. package/src/gizmo/translate/TranslateGizmo.ts +0 -114
  101. package/src/grid/Grid.ts +0 -34
  102. package/src/grid/__test__/Grid.test.ts +0 -28
  103. package/src/group/Group.ts +0 -184
  104. package/src/group/__test__/Group.test.ts +0 -212
  105. package/src/helper/applyMixins/__test__/applyMixins.test.ts +0 -30
  106. package/src/helper/applyMixins/applyMixins.ts +0 -70
  107. package/src/helper/findInterface/__test__/findInterface.test.ts +0 -63
  108. package/src/helper/findInterface/findInterface.ts +0 -13
  109. package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +0 -40
  110. package/src/helper/findSceneRecursive/findSceneRecursive.ts +0 -16
  111. package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +0 -186
  112. package/src/helper/getObjectDelta/getObjectDelta.ts +0 -105
  113. package/src/helper/isInterface/__test__/implementsInterface.test.ts +0 -19
  114. package/src/helper/isInterface/implementsInterface.ts +0 -9
  115. package/src/info/Info.ts +0 -178
  116. package/src/info/__test__/Info.test.ts +0 -346
  117. package/src/interface/Draggable.ts +0 -14
  118. package/src/interface/Hoverable.ts +0 -14
  119. package/src/interface/Movable.ts +0 -12
  120. package/src/interface/Rotatable.ts +0 -10
  121. package/src/interface/Scalable.ts +0 -10
  122. package/src/interface/Selectable.ts +0 -11
  123. package/src/io/IO.ts +0 -62
  124. package/src/io/__test__/IO.test.ts +0 -116
  125. package/src/io/gltf/GLTFIO.ts +0 -56
  126. package/src/io/gltf/__test__/GLTFIO.test.ts +0 -108
  127. package/src/light/AmbientLight.ts +0 -39
  128. package/src/light/PointLight.ts +0 -115
  129. package/src/light/SceneLight.ts +0 -63
  130. package/src/light/__test__/AmbientLight.test.ts +0 -29
  131. package/src/light/__test__/PointLight.test.ts +0 -74
  132. package/src/light/__test__/SceneLight.test.ts +0 -47
  133. package/src/loader/Loader.ts +0 -48
  134. package/src/math/__test__/DIVEMath.test.ts +0 -12
  135. package/src/math/ceil/__test__/ceilExp.test.ts +0 -12
  136. package/src/math/ceil/ceilExp.ts +0 -6
  137. package/src/math/degToRad/__test__/degToRad.test.ts +0 -172
  138. package/src/math/degToRad/degToRad.ts +0 -5
  139. package/src/math/floor/__test__/floorExp.test.ts +0 -14
  140. package/src/math/floor/floorExp.ts +0 -6
  141. package/src/math/helper/__test__/shift.test.ts +0 -12
  142. package/src/math/helper/shift.ts +0 -4
  143. package/src/math/index.ts +0 -28
  144. package/src/math/radToDeg/__test__/radToDeg.test.ts +0 -155
  145. package/src/math/radToDeg/radToDeg.ts +0 -5
  146. package/src/math/round/__test__/roundExp.test.ts +0 -14
  147. package/src/math/round/roundExp.ts +0 -10
  148. package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +0 -20
  149. package/src/math/signedAngleTo/signedAngleTo.ts +0 -20
  150. package/src/math/toFixed/__test__/toFixedExp.test.ts +0 -14
  151. package/src/math/toFixed/toFixedExp.ts +0 -9
  152. package/src/math/truncate/__test__/truncateExp.test.ts +0 -14
  153. package/src/math/truncate/truncateExp.ts +0 -9
  154. package/src/mediacreator/MediaCreator.ts +0 -75
  155. package/src/mediacreator/__test__/MediaCreator.test.ts +0 -155
  156. package/src/model/Model.ts +0 -190
  157. package/src/model/__test__/Model.test.ts +0 -215
  158. package/src/module/Module.ts +0 -45
  159. package/src/module/__test__/Module.test.ts +0 -54
  160. package/src/node/Node.ts +0 -100
  161. package/src/node/__test__/Node.test.ts +0 -120
  162. package/src/primitive/Primitive.ts +0 -299
  163. package/src/primitive/__test__/Primitive.test.ts +0 -281
  164. package/src/primitive/floor/Floor.ts +0 -45
  165. package/src/primitive/floor/__test__/Floor.test.ts +0 -24
  166. package/src/renderer/Renderer.ts +0 -215
  167. package/src/renderer/__test__/Renderer.test.ts +0 -228
  168. package/src/scene/Scene.ts +0 -106
  169. package/src/scene/__test__/Scene.test.ts +0 -124
  170. package/src/scene/root/Root.ts +0 -426
  171. package/src/scene/root/__test__/Root.test.ts +0 -903
  172. package/src/scene/xrroot/XRRoot.ts +0 -56
  173. package/src/scene/xrroot/xrlightroot/XRLightRoot.ts +0 -80
  174. package/src/toolbox/BaseTool.ts +0 -319
  175. package/src/toolbox/Toolbox.ts +0 -129
  176. package/src/toolbox/__test__/BaseTool.test.ts +0 -627
  177. package/src/toolbox/__test__/Toolbox.test.ts +0 -143
  178. package/src/toolbox/select/SelectTool.ts +0 -92
  179. package/src/toolbox/select/__test__/SelectTool.test.ts +0 -237
  180. package/src/toolbox/transform/TransformTool.ts +0 -166
  181. package/src/toolbox/transform/__test__/TransformTool.test.ts +0 -147
  182. package/src/types/ExporterOptions.ts +0 -14
  183. package/src/types/FileTypes.ts +0 -37
  184. package/src/types/SceneData.ts +0 -26
  185. package/src/types/SceneObjects.ts +0 -14
  186. package/src/types/SceneType.ts +0 -14
  187. package/src/types/index.ts +0 -31
  188. package/src/types/info/index.ts +0 -76
@@ -1,212 +0,0 @@
1
- import { Object3D, type Vector3Like } from 'three';
2
- import { DIVECommunication } from '../../com/Communication';
3
- import { type DIVENode } from '../../node/Node';
4
- import { DIVEGroup } from '../Group';
5
-
6
- jest.mock('../../com/Communication.ts', () => {
7
- return {
8
- DIVECommunication: {
9
- get: jest.fn(() => {
10
- return {
11
- PerformAction: jest.fn(),
12
- };
13
- }),
14
- },
15
- };
16
- });
17
-
18
- jest.spyOn(DIVECommunication, 'get').mockReturnValue({
19
- PerformAction: jest.fn(),
20
- } as unknown as DIVECommunication);
21
-
22
- let group: DIVEGroup;
23
-
24
- Object3D.prototype.attach = jest.fn();
25
-
26
- describe('dive/group/DIVEGroup', () => {
27
- beforeEach(() => {
28
- group = new DIVEGroup();
29
- });
30
-
31
- afterEach(() => {
32
- jest.clearAllMocks();
33
- });
34
-
35
- it('should instantiate', () => {
36
- expect(group).toBeDefined();
37
- });
38
-
39
- it('should add an object', () => {
40
- const mockObject = new DIVEGroup();
41
-
42
- expect(() => group.attach(mockObject)).not.toThrow();
43
- expect(group.members).toContainEqual(
44
- expect.objectContaining(mockObject),
45
- );
46
-
47
- jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
48
- expect(() => group.attach(mockObject)).not.toThrow();
49
- });
50
-
51
- it('should remove an object', () => {
52
- const mockObject = new DIVEGroup();
53
-
54
- expect(() => group.remove(mockObject)).not.toThrow();
55
- expect(group.children).not.toContain(mockObject);
56
- expect(group.members).not.toContain(mockObject);
57
-
58
- jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
59
- expect(() => group.remove(mockObject)).not.toThrow();
60
- });
61
-
62
- it('should set lines visibility', () => {
63
- expect(() => group.SetLinesVisibility(true)).not.toThrow();
64
-
65
- const mockObject = new DIVEGroup();
66
- expect(() => group.SetLinesVisibility(false, mockObject)).not.toThrow();
67
-
68
- expect(() => group.attach(mockObject)).not.toThrow();
69
- expect(() => group.SetLinesVisibility(false)).not.toThrow();
70
-
71
- expect(() => group.SetLinesVisibility(true, mockObject)).not.toThrow();
72
- });
73
-
74
- it('update lines', () => {
75
- const mockObject = new DIVEGroup();
76
- expect(() => group.UpdateLineTo(mockObject)).not.toThrow();
77
-
78
- expect(() => group.attach(mockObject)).not.toThrow();
79
- expect(() => group.UpdateLineTo(mockObject)).not.toThrow();
80
- });
81
-
82
- it('should onMove', () => {
83
- group.userData.id = 'something';
84
-
85
- expect(() => group.onMove()).not.toThrow();
86
-
87
- jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
88
- expect(() => group.onMove()).not.toThrow();
89
- });
90
-
91
- it('should onSelect', () => {
92
- group.userData.id = 'something';
93
-
94
- expect(() => group.onSelect()).not.toThrow();
95
-
96
- jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
97
- expect(() => group.onSelect()).not.toThrow();
98
- });
99
-
100
- it('should onDeselect', () => {
101
- group.userData.id = 'something';
102
-
103
- expect(() => group.onDeselect()).not.toThrow();
104
-
105
- jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
106
- expect(() => group.onDeselect()).not.toThrow();
107
- });
108
-
109
- it('should onMove', () => {
110
- group.userData.id = 'something';
111
-
112
- expect(() => group.onMove()).not.toThrow();
113
-
114
- jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
115
- expect(() => group.onMove()).not.toThrow();
116
- });
117
-
118
- it('should call onMove on members with isDIVENode', () => {
119
- // Create mock members
120
- const diveNode1: DIVENode = {
121
- isDIVENode: true,
122
- onMove: jest.fn(),
123
- } as unknown as DIVENode;
124
-
125
- const diveNode2: DIVENode = {
126
- isDIVENode: true,
127
- onMove: jest.fn(),
128
- } as unknown as DIVENode;
129
-
130
- const member1: DIVENode = {
131
- // Define other properties/methods if necessary
132
- } as unknown as DIVENode;
133
-
134
- const member2: DIVENode = {
135
- // Define other properties/methods if necessary
136
- } as unknown as DIVENode;
137
-
138
- // Assign the _members array (assuming it's protected or public for testing)
139
- // If _members is private, you might need to use a different approach or modify the class for testability
140
- (group as any)._members = [
141
- diveNode1,
142
- member1,
143
- diveNode2,
144
- member2,
145
- ];
146
-
147
- const position: Vector3Like = { x: 4, y: 5, z: 6 };
148
- group.SetPosition(position);
149
-
150
- // Check that onMove was called on diveNode1 and diveNode2
151
- expect(diveNode1.onMove).toHaveBeenCalled();
152
- expect(diveNode2.onMove).toHaveBeenCalled();
153
-
154
- // Ensure onMove was not called on other members
155
- // Since member1 and member2 don't have onMove, there's nothing to assert here
156
- // If members have onMove, you should mock and verify they are not called
157
- });
158
-
159
- it('should not call onMove on members without isDIVENode', () => {
160
- // Create mock members without isDIVENode
161
- const member1: DIVENode = {
162
- // Define other properties/methods if necessary
163
- } as unknown as DIVENode;
164
-
165
- const member2: DIVENode = {
166
- // Define other properties/methods if necessary
167
- } as unknown as DIVENode;
168
-
169
- // Assign the _members array
170
- (group as any)._members = [
171
- member1,
172
- member2,
173
- ];
174
-
175
- const position: Vector3Like = { x: 7, y: 8, z: 9 };
176
- group.SetPosition(position);
177
-
178
- // Since members do not have onMove, there's nothing to assert
179
- // If members have onMove as optional, you can spy on them to ensure they're not called
180
- });
181
-
182
- it('should handle an empty _members array without errors', () => {
183
- // Assign an empty _members array
184
- (group as any)._members = [];
185
-
186
- const position: Vector3Like = { x: 10, y: 11, z: 12 };
187
- expect(() => group.SetPosition(position)).not.toThrow();
188
- });
189
-
190
- it('should handle _members with mixed types correctly', () => {
191
- // Create mixed members
192
- const diveNode: DIVENode = {
193
- isDIVENode: true,
194
- onMove: jest.fn(),
195
- } as unknown as DIVENode;
196
-
197
- const member: DIVENode = {
198
- // Define other properties/methods if necessary
199
- } as unknown as DIVENode;
200
-
201
- (group as any)._members = [
202
- diveNode,
203
- member,
204
- ];
205
-
206
- const position: Vector3Like = { x: 13, y: 14, z: 15 };
207
- group.SetPosition(position);
208
-
209
- // Ensure onMove is called only on diveNode
210
- expect(diveNode.onMove).toHaveBeenCalled();
211
- });
212
- });
@@ -1,30 +0,0 @@
1
- import { applyMixins } from '../applyMixins.ts';
2
-
3
- class Movable {
4
- move() {}
5
- }
6
-
7
- class Selectable {
8
- select() {}
9
- }
10
-
11
- describe('dive/helper/applyMixins', () => {
12
- it('should apply mixins', () => {
13
- class Product {
14
- doProductThings() {}
15
- }
16
-
17
- interface Product extends Movable, Selectable {}
18
-
19
- applyMixins(Product, [
20
- Movable,
21
- Selectable,
22
- ]);
23
-
24
- const instance = new Product();
25
- expect(instance).toBeDefined();
26
- expect(instance.move).toBeDefined();
27
- expect(instance.select).toBeDefined();
28
- expect(instance.doProductThings).toBeDefined();
29
- });
30
- });
@@ -1,70 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- /* eslint-disable @typescript-eslint/ban-types */
3
- // A generic constructor type.
4
- type Constructor<T = {}> = new (...args: any[]) => T;
5
-
6
- // Converts a union of types to an intersection of types.
7
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
8
- k: infer I,
9
- ) => void
10
- ? I
11
- : never;
12
-
13
- // Merges the instance types of the base class and all mixin classes.
14
- type MixedInstance<
15
- T extends Constructor,
16
- K extends readonly Constructor[],
17
- > = InstanceType<T> & UnionToIntersection<InstanceType<K[number]>>;
18
-
19
- // Recursively flatten the constructor parameter lists for a tuple of constructors.
20
- type FlattenConstructorParams<T extends readonly Constructor[]> =
21
- T extends readonly [infer First, ...infer Rest]
22
- ? First extends Constructor
23
- ? Rest extends readonly Constructor[]
24
- ? [
25
- ...ConstructorParameters<First>,
26
- ...FlattenConstructorParams<Rest>,
27
- ]
28
- : ConstructorParameters<First>
29
- : []
30
- : [];
31
-
32
- // Constructs the mixed constructor type.
33
- // It accepts the parameters of T followed by all the parameters of K and
34
- // produces an instance that is the intersection of the instance types.
35
- type MixedConstructor<
36
- T extends Constructor,
37
- K extends readonly Constructor[],
38
- > = new (
39
- ...args: [...ConstructorParameters<T>, ...FlattenConstructorParams<K>]
40
- ) => MixedInstance<T, K>;
41
-
42
- /**
43
- * Applies mixins to a base class.
44
- *
45
- * @param derivedCtor Base class constructor
46
- * @param constructors Additional constructors that get mixed into the base class
47
- * @returns A mixed constructor with the instance type of the base class and all mixin classes
48
- * @example
49
- * ```
50
- * const SelectableMovableObject3D = applyMixins(Object3D, [DIVESelectable, DIVEMovable]);
51
- * const instance = new SelectableMovableObject3D();
52
- * instance.onMove();
53
- * instance.onSelect();
54
- * ```
55
- */
56
- export function applyMixins<
57
- T extends Constructor,
58
- K extends readonly Constructor[],
59
- >(derivedCtor: T, constructors: K): MixedConstructor<T, K> {
60
- constructors.forEach((baseCtor) => {
61
- Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
62
- Object.defineProperty(
63
- derivedCtor.prototype,
64
- name,
65
- Object.getOwnPropertyDescriptor(baseCtor.prototype, name)!,
66
- );
67
- });
68
- });
69
- return derivedCtor as unknown as MixedConstructor<T, K>;
70
- }
@@ -1,63 +0,0 @@
1
- import { Object3D } from 'three';
2
- import { findInterface } from '../findInterface.ts';
3
-
4
- describe('dive/helper/findInterface', () => {
5
- it('should not find interface', () => {
6
- expect(findInterface(null, 'isInterface')).toBe(undefined);
7
-
8
- const obj = {} as unknown as Object3D;
9
-
10
- expect(findInterface(obj, 'isInterface')).toBe(undefined);
11
-
12
- // add traverse function
13
- obj.traverseAncestors = jest.fn(
14
- (callback: (object: Object3D) => any) => {
15
- callback(obj);
16
- },
17
- );
18
-
19
- expect(findInterface(obj, 'isInterface')).toBe(undefined);
20
- });
21
-
22
- it('should find interface in object', () => {
23
- const obj = {
24
- isInterface: true,
25
- traverseAncestors: jest.fn(
26
- (callback: (object: Object3D) => any) => {
27
- callback(obj);
28
- },
29
- ),
30
- } as unknown as Object3D;
31
-
32
- expect(findInterface(obj, 'isInterface')).toBe(obj);
33
- });
34
-
35
- it('should find interface in parent', () => {
36
- const obj = {
37
- traverseAncestors: jest.fn(
38
- (callback: (object: Object3D) => any) => {
39
- callback(obj);
40
- },
41
- ),
42
- parent: {
43
- isInterface: true,
44
-
45
- traverseAncestors: jest.fn(
46
- (callback: (object: Object3D) => any) => {
47
- callback(obj.parent!);
48
- },
49
- ),
50
-
51
- parent: {
52
- traverseAncestors: jest.fn(
53
- (callback: (object: Object3D) => any) => {
54
- callback(obj.parent!);
55
- },
56
- ),
57
- },
58
- },
59
- } as unknown as Object3D;
60
-
61
- expect(findInterface(obj, 'isInterface')).toBe(obj.parent);
62
- });
63
- });
@@ -1,13 +0,0 @@
1
- import { implementsInterface } from '../isInterface/implementsInterface';
2
- import { type Object3D } from 'three';
3
-
4
- export function findInterface<T>(
5
- object: Object3D | null | undefined,
6
- discriminator: string,
7
- ): (Object3D & T) | undefined {
8
- if (!object) return undefined;
9
-
10
- if (implementsInterface<T>(object, discriminator)) return object;
11
-
12
- return findInterface<T>(object.parent, discriminator);
13
- }
@@ -1,40 +0,0 @@
1
- import type { Object3D } from 'three';
2
- import { findSceneRecursive } from '../findSceneRecursive.ts';
3
-
4
- describe('dive/helper/findSceneRecursive', () => {
5
- it('should find itself if parent is not set', () => {
6
- const obj = {} as Object3D;
7
-
8
- const found = findSceneRecursive(obj);
9
-
10
- expect(found).toStrictEqual(obj);
11
- });
12
-
13
- it('should find itself if it has no parent', () => {
14
- const obj = {
15
- parent: null,
16
- } as Object3D;
17
-
18
- const found = findSceneRecursive(obj);
19
-
20
- expect(found).toStrictEqual(obj);
21
- });
22
-
23
- it('should find itself if it has no parent', () => {
24
- const scene = {
25
- parent: null,
26
- } as Object3D;
27
-
28
- const objparent = {
29
- parent: scene,
30
- } as Object3D;
31
-
32
- const obj = {
33
- parent: objparent,
34
- } as Object3D;
35
-
36
- const found = findSceneRecursive(obj);
37
-
38
- expect(found).toStrictEqual(scene);
39
- });
40
- });
@@ -1,16 +0,0 @@
1
- import { type Object3D } from 'three';
2
- import { type DIVEScene } from '../../scene/Scene';
3
-
4
- /**
5
- * Find the scene object of an object.
6
- *
7
- * @param object - The object to find the scene of.
8
- * @returns The scene object.
9
- */
10
-
11
- export const findSceneRecursive = (object: Object3D): DIVEScene => {
12
- if (object.parent) {
13
- return findSceneRecursive(object.parent);
14
- }
15
- return object as DIVEScene;
16
- };
@@ -1,186 +0,0 @@
1
- import { getObjectDelta } from '../getObjectDelta.ts';
2
-
3
- describe('dive/helper/getObjectDelta', () => {
4
- // NO DELTAS
5
- it('should not find any deltas with empty objects', () => {
6
- const obj0 = {};
7
- const obj1 = {};
8
-
9
- const delta = getObjectDelta(obj0, obj1);
10
-
11
- expect(delta).toStrictEqual({});
12
- });
13
-
14
- it('should not find any deltas with equal references', () => {
15
- const obj0 = {
16
- test0: 'test',
17
- value0: 42,
18
- array0: [
19
- 187,
20
- 6,
21
- 9,
22
- 42,
23
- ],
24
- };
25
- const obj1 = obj0;
26
-
27
- const delta = getObjectDelta(obj0, obj1);
28
-
29
- expect(delta).toStrictEqual({});
30
- });
31
-
32
- it('should not find any deltas with equal objects', () => {
33
- const obj0 = {
34
- test0: 'test',
35
- value0: 42,
36
- array0: [
37
- 187,
38
- 6,
39
- 9,
40
- 42,
41
- ],
42
- };
43
- const obj1 = { ...obj0 };
44
-
45
- const delta = getObjectDelta(obj0, obj1);
46
-
47
- expect(delta).toStrictEqual({});
48
- });
49
-
50
- it('should not find any deltas with empty arrays', () => {
51
- const obj0 = { array0: [] };
52
- const obj1 = { array0: [] };
53
-
54
- const delta = getObjectDelta(obj0, obj1);
55
-
56
- expect(delta).toStrictEqual({});
57
- });
58
-
59
- // DELTAS
60
- it('should find deltas with incorrect types (case a)', () => {
61
- const obj0 = 'test' as unknown as object;
62
- const obj1 = { test: 0 };
63
-
64
- const delta = getObjectDelta(obj0, obj1);
65
-
66
- expect(delta).toStrictEqual(obj1);
67
- });
68
-
69
- it('should find deltas with incorrect types (case b)', () => {
70
- const obj0 = { test: 0 };
71
- const obj1 = 'test' as unknown as object;
72
-
73
- const delta = getObjectDelta(obj0, obj1);
74
-
75
- expect(delta).toStrictEqual(obj1);
76
- });
77
-
78
- it('should find deltas with one empty object', () => {
79
- const obj0 = {};
80
- const obj1 = { test: 0 };
81
-
82
- const delta = getObjectDelta(obj0, obj1);
83
-
84
- expect(delta).toStrictEqual(obj1);
85
- });
86
-
87
- it('should find deltas with different key lengths', () => {
88
- const obj0 = { test: 0 };
89
- const obj1 = { test: 0, test0: 0 };
90
-
91
- const delta = getObjectDelta(obj0, obj1);
92
-
93
- expect(delta).toStrictEqual({ test0: 0 });
94
- });
95
-
96
- it('should find deltas with a type delta', () => {
97
- const obj0 = { test: 'test' };
98
- const obj1 = { test: 0 as unknown as string };
99
-
100
- const delta = getObjectDelta(obj0, obj1);
101
-
102
- expect(delta).toStrictEqual(obj1);
103
- });
104
-
105
- it('should find deltas with a value delta', () => {
106
- const obj0 = { test: 'test' };
107
- const obj1 = { test: 'hello world!' };
108
-
109
- const delta = getObjectDelta(obj0, obj1);
110
-
111
- expect(delta).toStrictEqual(obj1);
112
- });
113
-
114
- it('should find deltas with array value delta', () => {
115
- const obj0 = {
116
- array0: [
117
- 187,
118
- 6,
119
- 9,
120
- 42,
121
- ],
122
- };
123
- const obj1 = {
124
- array0: [
125
- 187,
126
- 6,
127
- 9,
128
- ],
129
- };
130
-
131
- const delta = getObjectDelta(obj0, obj1);
132
-
133
- expect(delta).toStrictEqual(obj1);
134
- });
135
-
136
- it('should find deltas with array type difference', () => {
137
- const obj0 = { array0: 'array0' };
138
- const obj1 = {
139
- array0: [
140
- 187,
141
- 6,
142
- 9,
143
- ] as unknown as string,
144
- };
145
-
146
- const delta = getObjectDelta(obj0, obj1);
147
-
148
- expect(delta).toStrictEqual(obj1);
149
- });
150
-
151
- it('should find deltas with deltas in objects in array', () => {
152
- const obj0 = { array0: [{ test: 0 }] };
153
- const obj1 = { array0: [{ test: 1 }] };
154
-
155
- const delta = getObjectDelta(obj0, obj1);
156
-
157
- expect(delta).toStrictEqual(obj1);
158
- });
159
-
160
- it('should find deltas with undefined value in objects in object', () => {
161
- const obj0 = { object0: undefined as unknown as object };
162
- const obj1 = { object0: { test: 1 } };
163
-
164
- const delta = getObjectDelta(obj0, obj1);
165
-
166
- expect(delta).toStrictEqual(obj1);
167
- });
168
-
169
- it('should find deltas with wrong type in objects in object', () => {
170
- const obj0 = { object0: 'test' };
171
- const obj1 = { object0: { test: 1 } as unknown as string };
172
-
173
- const delta = getObjectDelta(obj0, obj1);
174
-
175
- expect(delta).toStrictEqual(obj1);
176
- });
177
-
178
- it('should find deltas with empty value in objects in object', () => {
179
- const obj0 = { object0: {} };
180
- const obj1 = { object0: { test: 1 } };
181
-
182
- const delta = getObjectDelta(obj0, obj1);
183
-
184
- expect(delta).toStrictEqual(obj1);
185
- });
186
- });