@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/src/scene/root/Root.ts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { Box3, Color, Object3D } from
|
|
2
|
-
import DIVEAmbientLight from
|
|
3
|
-
import DIVEPointLight from
|
|
4
|
-
import DIVESceneLight from
|
|
5
|
-
import { DIVEModel } from
|
|
6
|
-
import { DIVELoadingManager } from
|
|
7
|
-
import { DIVECommunication } from
|
|
8
|
-
import { DIVEPrimitive } from
|
|
9
|
-
|
|
10
|
-
import { type DIVEScene } from
|
|
11
|
-
import { type TransformControls } from
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
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 { DIVELoadingManager } from '../../loadingmanager/LoadingManager.ts';
|
|
7
|
+
import { DIVECommunication } from '../../com/Communication.ts';
|
|
8
|
+
import { DIVEPrimitive } from '../../primitive/Primitive.ts';
|
|
9
|
+
|
|
10
|
+
import { type DIVEScene } from '../Scene.ts';
|
|
11
|
+
import { type TransformControls } from 'three/examples/jsm/controls/TransformControls';
|
|
12
|
+
import {
|
|
13
|
+
type COMLight,
|
|
14
|
+
type COMModel,
|
|
15
|
+
type COMEntity,
|
|
16
|
+
type COMPrimitive,
|
|
17
|
+
type COMGroup,
|
|
18
|
+
} from '../../com/types';
|
|
19
|
+
import { type DIVESceneObject } from '../../types';
|
|
20
|
+
import { DIVEGroup } from '../../group/Group.ts';
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
23
|
* A basic scene node to hold grid, floor and all lower level roots.
|
|
@@ -26,7 +32,7 @@ export class DIVERoot extends Object3D {
|
|
|
26
32
|
|
|
27
33
|
constructor() {
|
|
28
34
|
super();
|
|
29
|
-
this.name =
|
|
35
|
+
this.name = 'Root';
|
|
30
36
|
|
|
31
37
|
this.loadingManager = new DIVELoadingManager();
|
|
32
38
|
}
|
|
@@ -42,7 +48,7 @@ export class DIVERoot extends Object3D {
|
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
public GetSceneObject<T extends DIVESceneObject>(
|
|
45
|
-
object: Partial<COMEntity> & { id: string }
|
|
51
|
+
object: Partial<COMEntity> & { id: string },
|
|
46
52
|
): T | undefined {
|
|
47
53
|
let foundObject: T | undefined;
|
|
48
54
|
this.traverse((object3D) => {
|
|
@@ -56,70 +62,74 @@ export class DIVERoot extends Object3D {
|
|
|
56
62
|
|
|
57
63
|
public AddSceneObject(object: COMEntity): void {
|
|
58
64
|
switch (object.entityType) {
|
|
59
|
-
case
|
|
65
|
+
case 'pov': {
|
|
60
66
|
break;
|
|
61
67
|
}
|
|
62
|
-
case
|
|
68
|
+
case 'light': {
|
|
63
69
|
this.updateLight(object);
|
|
64
70
|
break;
|
|
65
71
|
}
|
|
66
|
-
case
|
|
72
|
+
case 'model': {
|
|
67
73
|
this.updateModel(object);
|
|
68
74
|
break;
|
|
69
75
|
}
|
|
70
|
-
case
|
|
76
|
+
case 'primitive': {
|
|
71
77
|
this.updatePrimitive(object);
|
|
72
78
|
break;
|
|
73
79
|
}
|
|
74
|
-
case
|
|
80
|
+
case 'group': {
|
|
75
81
|
this.updateGroup(object);
|
|
76
82
|
break;
|
|
77
83
|
}
|
|
78
84
|
}
|
|
79
85
|
}
|
|
80
86
|
|
|
81
|
-
public UpdateSceneObject(
|
|
87
|
+
public UpdateSceneObject(
|
|
88
|
+
object: Partial<COMEntity> & { id: string },
|
|
89
|
+
): void {
|
|
82
90
|
switch (object.entityType) {
|
|
83
|
-
case
|
|
91
|
+
case 'pov': {
|
|
84
92
|
break;
|
|
85
93
|
}
|
|
86
|
-
case
|
|
94
|
+
case 'light': {
|
|
87
95
|
this.updateLight(object);
|
|
88
96
|
break;
|
|
89
97
|
}
|
|
90
|
-
case
|
|
98
|
+
case 'model': {
|
|
91
99
|
this.updateModel(object);
|
|
92
100
|
break;
|
|
93
101
|
}
|
|
94
|
-
case
|
|
102
|
+
case 'primitive': {
|
|
95
103
|
this.updatePrimitive(object);
|
|
96
104
|
break;
|
|
97
105
|
}
|
|
98
|
-
case
|
|
106
|
+
case 'group': {
|
|
99
107
|
this.updateGroup(object);
|
|
100
108
|
break;
|
|
101
109
|
}
|
|
102
110
|
}
|
|
103
111
|
}
|
|
104
112
|
|
|
105
|
-
public DeleteSceneObject(
|
|
113
|
+
public DeleteSceneObject(
|
|
114
|
+
object: Partial<COMEntity> & { id: string },
|
|
115
|
+
): void {
|
|
106
116
|
switch (object.entityType) {
|
|
107
|
-
case
|
|
117
|
+
case 'pov': {
|
|
108
118
|
break;
|
|
109
119
|
}
|
|
110
|
-
case
|
|
120
|
+
case 'light': {
|
|
111
121
|
this.deleteLight(object);
|
|
112
122
|
break;
|
|
113
123
|
}
|
|
114
|
-
case
|
|
124
|
+
case 'model': {
|
|
115
125
|
this.deleteModel(object);
|
|
116
126
|
break;
|
|
117
127
|
}
|
|
118
|
-
case
|
|
128
|
+
case 'primitive': {
|
|
119
129
|
this.deletePrimitive(object);
|
|
120
130
|
break;
|
|
121
131
|
}
|
|
122
|
-
case
|
|
132
|
+
case 'group': {
|
|
123
133
|
this.deleteGroup(object);
|
|
124
134
|
break;
|
|
125
135
|
}
|
|
@@ -128,12 +138,12 @@ export class DIVERoot extends Object3D {
|
|
|
128
138
|
|
|
129
139
|
public PlaceOnFloor(object: Partial<COMEntity> & { id: string }): void {
|
|
130
140
|
switch (object.entityType) {
|
|
131
|
-
case
|
|
132
|
-
case
|
|
141
|
+
case 'pov':
|
|
142
|
+
case 'light': {
|
|
133
143
|
break;
|
|
134
144
|
}
|
|
135
|
-
case
|
|
136
|
-
case
|
|
145
|
+
case 'model':
|
|
146
|
+
case 'primitive': {
|
|
137
147
|
this.placeOnFloor(object);
|
|
138
148
|
break;
|
|
139
149
|
}
|
|
@@ -157,7 +167,9 @@ export class DIVERoot extends Object3D {
|
|
|
157
167
|
break;
|
|
158
168
|
}
|
|
159
169
|
default: {
|
|
160
|
-
console.warn(
|
|
170
|
+
console.warn(
|
|
171
|
+
`DIVERoot.updateLight: Unknown light type: ${light.type}`,
|
|
172
|
+
);
|
|
161
173
|
return;
|
|
162
174
|
}
|
|
163
175
|
}
|
|
@@ -165,13 +177,31 @@ export class DIVERoot extends Object3D {
|
|
|
165
177
|
this.add(sceneObject);
|
|
166
178
|
}
|
|
167
179
|
|
|
168
|
-
if (light.name !== undefined && light.name !== null)
|
|
169
|
-
|
|
170
|
-
if (light.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
180
|
+
if (light.name !== undefined && light.name !== null)
|
|
181
|
+
sceneObject.name = light.name;
|
|
182
|
+
if (light.position !== undefined && light.position !== null)
|
|
183
|
+
sceneObject.position.set(
|
|
184
|
+
light.position.x,
|
|
185
|
+
light.position.y,
|
|
186
|
+
light.position.z,
|
|
187
|
+
);
|
|
188
|
+
if (light.intensity !== undefined && light.intensity !== null)
|
|
189
|
+
(sceneObject as DIVEAmbientLight | DIVEPointLight).SetIntensity(
|
|
190
|
+
light.intensity,
|
|
191
|
+
);
|
|
192
|
+
if (light.enabled !== undefined && light.enabled !== null)
|
|
193
|
+
(sceneObject as DIVEAmbientLight | DIVEPointLight).SetEnabled(
|
|
194
|
+
light.enabled,
|
|
195
|
+
);
|
|
196
|
+
if (light.color !== undefined && light.color !== null)
|
|
197
|
+
(sceneObject as DIVEAmbientLight | DIVEPointLight).SetColor(
|
|
198
|
+
new Color(light.color),
|
|
199
|
+
);
|
|
200
|
+
if (light.visible !== undefined && light.visible !== null)
|
|
201
|
+
(sceneObject as DIVEAmbientLight | DIVEPointLight).visible =
|
|
202
|
+
light.visible;
|
|
203
|
+
if (light.parentId !== undefined)
|
|
204
|
+
this.setParent({ ...light, parentId: light.parentId });
|
|
175
205
|
}
|
|
176
206
|
|
|
177
207
|
private updateModel(model: Partial<COMModel> & { id: string }): void {
|
|
@@ -186,20 +216,31 @@ export class DIVERoot extends Object3D {
|
|
|
186
216
|
if (model.uri !== undefined) {
|
|
187
217
|
this.loadingManager.LoadGLTF(model.uri).then((gltf) => {
|
|
188
218
|
(sceneObject as DIVEModel).SetModel(gltf);
|
|
189
|
-
DIVECommunication.get(model.id!)?.PerformAction(
|
|
219
|
+
DIVECommunication.get(model.id!)?.PerformAction(
|
|
220
|
+
'MODEL_LOADED',
|
|
221
|
+
{ id: model.id! },
|
|
222
|
+
);
|
|
190
223
|
});
|
|
191
224
|
}
|
|
192
225
|
|
|
193
226
|
if (model.name !== undefined) sceneObject.name = model.name;
|
|
194
|
-
if (model.position !== undefined)
|
|
195
|
-
|
|
196
|
-
if (model.
|
|
197
|
-
|
|
198
|
-
if (model.
|
|
199
|
-
|
|
227
|
+
if (model.position !== undefined)
|
|
228
|
+
(sceneObject as DIVEModel).SetPosition(model.position);
|
|
229
|
+
if (model.rotation !== undefined)
|
|
230
|
+
(sceneObject as DIVEModel).SetRotation(model.rotation);
|
|
231
|
+
if (model.scale !== undefined)
|
|
232
|
+
(sceneObject as DIVEModel).SetScale(model.scale);
|
|
233
|
+
if (model.visible !== undefined)
|
|
234
|
+
(sceneObject as DIVEModel).SetVisibility(model.visible);
|
|
235
|
+
if (model.material !== undefined)
|
|
236
|
+
(sceneObject as DIVEModel).SetMaterial(model.material);
|
|
237
|
+
if (model.parentId !== undefined)
|
|
238
|
+
this.setParent({ ...model, parentId: model.parentId });
|
|
200
239
|
}
|
|
201
240
|
|
|
202
|
-
private updatePrimitive(
|
|
241
|
+
private updatePrimitive(
|
|
242
|
+
primitive: Partial<COMPrimitive> & { id: string },
|
|
243
|
+
): void {
|
|
203
244
|
let sceneObject = this.GetSceneObject<DIVESceneObject>(primitive);
|
|
204
245
|
if (!sceneObject) {
|
|
205
246
|
const created = new DIVEPrimitive();
|
|
@@ -209,13 +250,20 @@ export class DIVERoot extends Object3D {
|
|
|
209
250
|
}
|
|
210
251
|
|
|
211
252
|
if (primitive.name !== undefined) sceneObject.name = primitive.name;
|
|
212
|
-
if (primitive.geometry !== undefined)
|
|
213
|
-
|
|
214
|
-
if (primitive.
|
|
215
|
-
|
|
216
|
-
if (primitive.
|
|
217
|
-
|
|
218
|
-
if (primitive.
|
|
253
|
+
if (primitive.geometry !== undefined)
|
|
254
|
+
(sceneObject as DIVEPrimitive).SetGeometry(primitive.geometry);
|
|
255
|
+
if (primitive.position !== undefined)
|
|
256
|
+
(sceneObject as DIVEPrimitive).SetPosition(primitive.position);
|
|
257
|
+
if (primitive.rotation !== undefined)
|
|
258
|
+
(sceneObject as DIVEPrimitive).SetRotation(primitive.rotation);
|
|
259
|
+
if (primitive.scale !== undefined)
|
|
260
|
+
(sceneObject as DIVEPrimitive).SetScale(primitive.scale);
|
|
261
|
+
if (primitive.visible !== undefined)
|
|
262
|
+
(sceneObject as DIVEPrimitive).SetVisibility(primitive.visible);
|
|
263
|
+
if (primitive.material !== undefined)
|
|
264
|
+
(sceneObject as DIVEPrimitive).SetMaterial(primitive.material);
|
|
265
|
+
if (primitive.parentId !== undefined)
|
|
266
|
+
this.setParent({ ...primitive, parentId: primitive.parentId });
|
|
219
267
|
}
|
|
220
268
|
|
|
221
269
|
private updateGroup(group: Partial<COMGroup> & { id: string }): void {
|
|
@@ -228,18 +276,26 @@ export class DIVERoot extends Object3D {
|
|
|
228
276
|
}
|
|
229
277
|
|
|
230
278
|
if (group.name !== undefined) sceneObject.name = group.name;
|
|
231
|
-
if (group.position !== undefined)
|
|
232
|
-
|
|
233
|
-
if (group.
|
|
234
|
-
|
|
235
|
-
if (group.
|
|
236
|
-
|
|
279
|
+
if (group.position !== undefined)
|
|
280
|
+
(sceneObject as DIVEPrimitive).SetPosition(group.position);
|
|
281
|
+
if (group.rotation !== undefined)
|
|
282
|
+
(sceneObject as DIVEPrimitive).SetRotation(group.rotation);
|
|
283
|
+
if (group.scale !== undefined)
|
|
284
|
+
(sceneObject as DIVEPrimitive).SetScale(group.scale);
|
|
285
|
+
if (group.visible !== undefined)
|
|
286
|
+
(sceneObject as DIVEPrimitive).SetVisibility(group.visible);
|
|
287
|
+
if (group.bbVisible !== undefined)
|
|
288
|
+
(sceneObject as DIVEGroup).SetLinesVisibility(group.bbVisible);
|
|
289
|
+
if (group.parentId !== undefined)
|
|
290
|
+
this.setParent({ ...group, parentId: group.parentId });
|
|
237
291
|
}
|
|
238
292
|
|
|
239
293
|
private deleteLight(light: Partial<COMLight> & { id: string }): void {
|
|
240
294
|
const sceneObject = this.GetSceneObject(light);
|
|
241
295
|
if (!sceneObject) {
|
|
242
|
-
console.warn(
|
|
296
|
+
console.warn(
|
|
297
|
+
`DIVERoot.deleteLight: Light with id ${light.id} not found`,
|
|
298
|
+
);
|
|
243
299
|
return;
|
|
244
300
|
}
|
|
245
301
|
|
|
@@ -251,7 +307,9 @@ export class DIVERoot extends Object3D {
|
|
|
251
307
|
private deleteModel(model: Partial<COMModel> & { id: string }): void {
|
|
252
308
|
const sceneObject = this.GetSceneObject(model);
|
|
253
309
|
if (!sceneObject) {
|
|
254
|
-
console.warn(
|
|
310
|
+
console.warn(
|
|
311
|
+
`DIVERoot.deleteModel: Model with id ${model.id} not found`,
|
|
312
|
+
);
|
|
255
313
|
return;
|
|
256
314
|
}
|
|
257
315
|
|
|
@@ -260,10 +318,14 @@ export class DIVERoot extends Object3D {
|
|
|
260
318
|
this.remove(sceneObject);
|
|
261
319
|
}
|
|
262
320
|
|
|
263
|
-
private deletePrimitive(
|
|
321
|
+
private deletePrimitive(
|
|
322
|
+
primitive: Partial<COMPrimitive> & { id: string },
|
|
323
|
+
): void {
|
|
264
324
|
const sceneObject = this.GetSceneObject(primitive);
|
|
265
325
|
if (!sceneObject) {
|
|
266
|
-
console.warn(
|
|
326
|
+
console.warn(
|
|
327
|
+
`DIVERoot.deletePrimitive: Primitive with id ${primitive.id} not found`,
|
|
328
|
+
);
|
|
267
329
|
return;
|
|
268
330
|
}
|
|
269
331
|
|
|
@@ -275,7 +337,9 @@ export class DIVERoot extends Object3D {
|
|
|
275
337
|
private deleteGroup(group: Partial<COMGroup> & { id: string }): void {
|
|
276
338
|
const sceneObject = this.GetSceneObject(group);
|
|
277
339
|
if (!sceneObject) {
|
|
278
|
-
console.warn(
|
|
340
|
+
console.warn(
|
|
341
|
+
`DIVERoot.deleteGroup: Group with id ${group.id} not found`,
|
|
342
|
+
);
|
|
279
343
|
return;
|
|
280
344
|
}
|
|
281
345
|
|
|
@@ -295,17 +359,20 @@ export class DIVERoot extends Object3D {
|
|
|
295
359
|
(sceneObject as DIVEModel | DIVEPrimitive).PlaceOnFloor();
|
|
296
360
|
}
|
|
297
361
|
|
|
298
|
-
private setParent(
|
|
362
|
+
private setParent(
|
|
363
|
+
object: Partial<COMEntity> & { id: string; parentId: string | null },
|
|
364
|
+
): void {
|
|
299
365
|
const sceneObject = this.GetSceneObject<DIVESceneObject>(object);
|
|
300
366
|
if (!sceneObject) return;
|
|
301
367
|
|
|
302
368
|
if (object.parentId !== null) {
|
|
303
|
-
const parent = this.GetSceneObject<DIVESceneObject>({
|
|
369
|
+
const parent = this.GetSceneObject<DIVESceneObject>({
|
|
370
|
+
id: object.parentId,
|
|
371
|
+
});
|
|
304
372
|
if (!parent) return;
|
|
305
373
|
|
|
306
374
|
// attach to new parent (if exists in scene)
|
|
307
375
|
parent.attach(sceneObject);
|
|
308
|
-
|
|
309
376
|
} else {
|
|
310
377
|
// attach to root if no parent is found
|
|
311
378
|
this.attach(sceneObject);
|
|
@@ -324,7 +391,7 @@ export class DIVERoot extends Object3D {
|
|
|
324
391
|
private findScene(object: Object3D): DIVEScene {
|
|
325
392
|
if (object.parent !== null) {
|
|
326
393
|
return this.findScene(object.parent);
|
|
327
|
-
}
|
|
394
|
+
}
|
|
328
395
|
return object as DIVEScene;
|
|
329
396
|
}
|
|
330
397
|
}
|