@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,426 +0,0 @@
1
- import { Box3, Color, Object3D } from 'three';
2
- import DIVEAmbientLight from '../../light/AmbientLight.ts';
3
- import DIVEPointLight from '../../light/PointLight.ts';
4
- import DIVESceneLight from '../../light/SceneLight.ts';
5
- import { DIVEModel } from '../../model/Model.ts';
6
- import { DIVECommunication } from '../../com/Communication.ts';
7
- import { DIVEPrimitive } from '../../primitive/Primitive.ts';
8
-
9
- import { type DIVEScene } from '../Scene.ts';
10
- import { type TransformControls } from 'three/examples/jsm/controls/TransformControls';
11
- import {
12
- type COMLight,
13
- type COMModel,
14
- type COMEntity,
15
- type COMPrimitive,
16
- type COMGroup,
17
- } from '../../com/types';
18
- import { type DIVESceneObject } from '../../types';
19
- import { DIVEGroup } from '../../group/Group.ts';
20
- import { Loader } from '../../loader/Loader.ts';
21
-
22
- /**
23
- * A basic scene node to hold grid, floor and all lower level roots.
24
- *
25
- * @module
26
- */
27
-
28
- export class DIVERoot extends Object3D {
29
- readonly isDIVERoot: true = true;
30
-
31
- private loader: Loader;
32
-
33
- constructor() {
34
- super();
35
- this.name = 'Root';
36
-
37
- this.loader = new Loader();
38
- }
39
-
40
- public ComputeSceneBB(): Box3 {
41
- const bb = new Box3();
42
- this.traverse((object: Object3D) => {
43
- if ('isObject3D' in object) {
44
- bb.expandByObject(object);
45
- }
46
- });
47
- return bb;
48
- }
49
-
50
- public GetSceneObject<T extends DIVESceneObject>(
51
- object: Partial<COMEntity> & { id: string },
52
- ): T | undefined {
53
- let foundObject: T | undefined;
54
- this.traverse((object3D) => {
55
- if (foundObject) return;
56
- if (object3D.userData.id === object.id) {
57
- foundObject = object3D as T;
58
- }
59
- });
60
- return foundObject;
61
- }
62
-
63
- public AddSceneObject(object: COMEntity): void {
64
- switch (object.entityType) {
65
- case 'pov': {
66
- break;
67
- }
68
- case 'light': {
69
- this.updateLight(object as COMLight);
70
- break;
71
- }
72
- case 'model': {
73
- this.updateModel(object);
74
- break;
75
- }
76
- case 'primitive': {
77
- this.updatePrimitive(object);
78
- break;
79
- }
80
- case 'group': {
81
- this.updateGroup(object);
82
- break;
83
- }
84
- default: {
85
- console.warn(
86
- `DIVERoot.AddSceneObject: Unknown entity type: ${object.entityType}`,
87
- );
88
- }
89
- }
90
- }
91
-
92
- public UpdateSceneObject(
93
- object: Partial<COMEntity> & { id: string; entityType: string },
94
- ): void {
95
- switch (object.entityType) {
96
- case 'pov': {
97
- break;
98
- }
99
- case 'light': {
100
- this.updateLight(object as COMLight);
101
- break;
102
- }
103
- case 'model': {
104
- this.updateModel(object);
105
- break;
106
- }
107
- case 'primitive': {
108
- this.updatePrimitive(object);
109
- break;
110
- }
111
- case 'group': {
112
- this.updateGroup(object);
113
- break;
114
- }
115
- default: {
116
- console.warn(
117
- `DIVERoot.UpdateSceneObject: Unknown entity type: ${object.entityType}`,
118
- );
119
- }
120
- }
121
- }
122
-
123
- public DeleteSceneObject(
124
- object: Partial<COMEntity> & { id: string; entityType: string },
125
- ): void {
126
- switch (object.entityType) {
127
- case 'pov': {
128
- break;
129
- }
130
- case 'light': {
131
- this.deleteLight(object);
132
- break;
133
- }
134
- case 'model': {
135
- this.deleteModel(object);
136
- break;
137
- }
138
- case 'primitive': {
139
- this.deletePrimitive(object);
140
- break;
141
- }
142
- case 'group': {
143
- this.deleteGroup(object);
144
- break;
145
- }
146
- default: {
147
- console.warn(
148
- `DIVERoot.DeleteSceneObject: Unknown entity type: ${object.entityType}`,
149
- );
150
- }
151
- }
152
- }
153
-
154
- public PlaceOnFloor(
155
- object: Partial<COMEntity> & { id: string; entityType: string },
156
- ): void {
157
- switch (object.entityType) {
158
- case 'pov':
159
- case 'light': {
160
- break;
161
- }
162
- case 'model':
163
- case 'primitive': {
164
- this.placeOnFloor(object);
165
- break;
166
- }
167
- default: {
168
- console.warn(
169
- `DIVERoot.PlaceOnFloor: Unknown entity type: ${object.entityType}`,
170
- );
171
- }
172
- }
173
- }
174
-
175
- private updateLight(
176
- light: Partial<COMLight> & {
177
- id: string;
178
- entityType: string;
179
- type: string;
180
- },
181
- ): void {
182
- let sceneObject = this.GetSceneObject(light);
183
- if (!sceneObject) {
184
- switch (light.type) {
185
- case 'scene': {
186
- sceneObject = new DIVESceneLight();
187
- break;
188
- }
189
- case 'ambient': {
190
- sceneObject = new DIVEAmbientLight();
191
- break;
192
- }
193
- case 'point': {
194
- sceneObject = new DIVEPointLight();
195
- break;
196
- }
197
- default: {
198
- console.warn(
199
- `DIVERoot.updateLight: Unknown light type: ${light.type}`,
200
- );
201
- return;
202
- }
203
- }
204
- sceneObject.userData.id = light.id;
205
- this.add(sceneObject);
206
- }
207
-
208
- if (light.name !== undefined && light.name !== null)
209
- sceneObject.name = light.name;
210
- if (light.position !== undefined && light.position !== null)
211
- sceneObject.position.set(
212
- light.position.x,
213
- light.position.y,
214
- light.position.z,
215
- );
216
- if (light.intensity !== undefined && light.intensity !== null)
217
- (sceneObject as DIVEAmbientLight | DIVEPointLight).SetIntensity(
218
- light.intensity,
219
- );
220
- if (light.enabled !== undefined && light.enabled !== null)
221
- (sceneObject as DIVEAmbientLight | DIVEPointLight).SetEnabled(
222
- light.enabled,
223
- );
224
- if (light.color !== undefined && light.color !== null)
225
- (sceneObject as DIVEAmbientLight | DIVEPointLight).SetColor(
226
- new Color(light.color),
227
- );
228
- if (light.visible !== undefined && light.visible !== null)
229
- (sceneObject as DIVEAmbientLight | DIVEPointLight).visible =
230
- light.visible;
231
- if (light.parentId !== undefined)
232
- this.setParent({ ...light, parentId: light.parentId });
233
- }
234
-
235
- private updateModel(model: Partial<COMModel> & { id: string }): void {
236
- let sceneObject = this.GetSceneObject<DIVESceneObject>(model);
237
- if (!sceneObject) {
238
- const created = new DIVEModel();
239
- sceneObject = created;
240
- sceneObject.userData.id = model.id;
241
- sceneObject.userData.uri = model.uri;
242
- this.add(sceneObject);
243
- }
244
-
245
- if (model.uri !== undefined) {
246
- this.loader.load(model.uri).then((gltf) => {
247
- (sceneObject as DIVEModel).SetModel(gltf);
248
- DIVECommunication.get(model.id!)?.PerformAction(
249
- 'MODEL_LOADED',
250
- { id: model.id! },
251
- );
252
- });
253
- }
254
-
255
- if (model.name !== undefined) sceneObject.name = model.name;
256
- if (model.position !== undefined)
257
- (sceneObject as DIVEModel).SetPosition(model.position);
258
- if (model.rotation !== undefined)
259
- (sceneObject as DIVEModel).SetRotation(model.rotation);
260
- if (model.scale !== undefined)
261
- (sceneObject as DIVEModel).SetScale(model.scale);
262
- if (model.visible !== undefined)
263
- (sceneObject as DIVEModel).SetVisibility(model.visible);
264
- if (model.material !== undefined)
265
- (sceneObject as DIVEModel).SetMaterial(model.material);
266
- if (model.parentId !== undefined)
267
- this.setParent({ ...model, parentId: model.parentId });
268
- }
269
-
270
- private updatePrimitive(
271
- primitive: Partial<COMPrimitive> & { id: string },
272
- ): void {
273
- let sceneObject = this.GetSceneObject<DIVESceneObject>(primitive);
274
- if (!sceneObject) {
275
- const created = new DIVEPrimitive();
276
- sceneObject = created;
277
- sceneObject.userData.id = primitive.id;
278
- this.add(sceneObject);
279
- }
280
-
281
- if (primitive.name !== undefined) sceneObject.name = primitive.name;
282
- if (primitive.geometry !== undefined)
283
- (sceneObject as DIVEPrimitive).SetGeometry(primitive.geometry);
284
- if (primitive.position !== undefined)
285
- (sceneObject as DIVEPrimitive).SetPosition(primitive.position);
286
- if (primitive.rotation !== undefined)
287
- (sceneObject as DIVEPrimitive).SetRotation(primitive.rotation);
288
- if (primitive.scale !== undefined)
289
- (sceneObject as DIVEPrimitive).SetScale(primitive.scale);
290
- if (primitive.visible !== undefined)
291
- (sceneObject as DIVEPrimitive).SetVisibility(primitive.visible);
292
- if (primitive.material !== undefined)
293
- (sceneObject as DIVEPrimitive).SetMaterial(primitive.material);
294
- if (primitive.parentId !== undefined)
295
- this.setParent({ ...primitive, parentId: primitive.parentId });
296
- }
297
-
298
- private updateGroup(group: Partial<COMGroup> & { id: string }): void {
299
- let sceneObject = this.GetSceneObject<DIVESceneObject>(group);
300
- if (!sceneObject) {
301
- const created = new DIVEGroup();
302
- sceneObject = created;
303
- sceneObject.userData.id = group.id;
304
- this.add(sceneObject);
305
- }
306
-
307
- if (group.name !== undefined) sceneObject.name = group.name;
308
- if (group.position !== undefined)
309
- (sceneObject as DIVEGroup).SetPosition(group.position);
310
- if (group.rotation !== undefined)
311
- (sceneObject as DIVEGroup).SetRotation(group.rotation);
312
- if (group.scale !== undefined)
313
- (sceneObject as DIVEGroup).SetScale(group.scale);
314
- if (group.visible !== undefined)
315
- (sceneObject as DIVEGroup).SetVisibility(group.visible);
316
- if (group.bbVisible !== undefined)
317
- (sceneObject as DIVEGroup).SetLinesVisibility(group.bbVisible);
318
- if (group.parentId !== undefined)
319
- this.setParent({ ...group, parentId: group.parentId });
320
- }
321
-
322
- private deleteLight(light: Partial<COMLight> & { id: string }): void {
323
- const sceneObject = this.GetSceneObject(light);
324
- if (!sceneObject) {
325
- console.warn(
326
- `DIVERoot.deleteLight: Light with id ${light.id} not found`,
327
- );
328
- return;
329
- }
330
-
331
- this.detachTransformControls(sceneObject);
332
-
333
- sceneObject.parent!.remove(sceneObject);
334
- }
335
-
336
- private deleteModel(model: Partial<COMModel> & { id: string }): void {
337
- const sceneObject = this.GetSceneObject(model);
338
- if (!sceneObject) {
339
- console.warn(
340
- `DIVERoot.deleteModel: Model with id ${model.id} not found`,
341
- );
342
- return;
343
- }
344
-
345
- this.detachTransformControls(sceneObject);
346
-
347
- sceneObject.parent!.remove(sceneObject);
348
- }
349
-
350
- private deletePrimitive(
351
- primitive: Partial<COMPrimitive> & { id: string },
352
- ): void {
353
- const sceneObject = this.GetSceneObject(primitive);
354
- if (!sceneObject) {
355
- console.warn(
356
- `DIVERoot.deletePrimitive: Primitive with id ${primitive.id} not found`,
357
- );
358
- return;
359
- }
360
-
361
- this.detachTransformControls(sceneObject);
362
-
363
- sceneObject.parent!.remove(sceneObject);
364
- }
365
-
366
- private deleteGroup(group: Partial<COMGroup> & { id: string }): void {
367
- const sceneObject = this.GetSceneObject<DIVEGroup>(group);
368
- if (!sceneObject) {
369
- console.warn(
370
- `DIVERoot.deleteGroup: Group with id ${group.id} not found`,
371
- );
372
- return;
373
- }
374
-
375
- this.detachTransformControls(sceneObject);
376
-
377
- for (let i = sceneObject.members.length - 1; i >= 0; i--) {
378
- this.attach(sceneObject.members[i]);
379
- }
380
-
381
- sceneObject.parent!.remove(sceneObject);
382
- }
383
-
384
- private placeOnFloor(object: Partial<COMEntity> & { id: string }): void {
385
- const sceneObject = this.GetSceneObject(object);
386
- if (!sceneObject) return;
387
-
388
- (sceneObject as DIVEModel | DIVEPrimitive).PlaceOnFloor();
389
- }
390
-
391
- private setParent(
392
- object: Partial<COMEntity> & { id: string; parentId: string | null },
393
- ): void {
394
- const sceneObject = this.GetSceneObject<DIVESceneObject>(object);
395
- if (!sceneObject) return;
396
-
397
- if (object.parentId !== null) {
398
- const parent = this.GetSceneObject<DIVESceneObject>({
399
- id: object.parentId,
400
- });
401
- if (!parent) return;
402
-
403
- // attach to new parent (if exists in scene)
404
- parent.attach(sceneObject);
405
- } else {
406
- // attach to root if no parent is found
407
- this.attach(sceneObject);
408
- }
409
- }
410
-
411
- private detachTransformControls(object: Object3D): void {
412
- // this is only neccessary due to using the old TransformControls instead of the new DIVEGizmo
413
- this.findScene(object).children.find((object) => {
414
- if ('isTransformControls' in object) {
415
- (object as TransformControls).detach();
416
- }
417
- });
418
- }
419
-
420
- private findScene(object: Object3D): DIVEScene {
421
- if (object.parent !== null) {
422
- return this.findScene(object.parent);
423
- }
424
- return object as DIVEScene;
425
- }
426
- }