@shopware-ag/dive 1.19.0 → 1.19.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dive.cjs +388 -220
- package/build/dive.cjs.map +1 -1
- package/build/dive.js +395 -21946
- package/build/dive.js.map +1 -1
- package/build/dive.mjs +28206 -0
- package/build/dive.mjs.map +1 -0
- package/build/src/ar/AR.d.ts +37 -14
- package/build/src/ar/arquicklook/ARQuickLook.d.ts +5 -6
- package/build/src/ar/sceneviewer/SceneViewer.d.ts +42 -6
- package/build/src/com/actions/scene/launchar.d.ts +5 -2
- package/build/src/converter/Converter.d.ts +21 -0
- package/build/src/dive.d.ts +3 -2
- package/build/src/exporter/Exporter.d.ts +11 -0
- package/build/src/helper/applyMixins/applyMixins.d.ts +22 -6
- package/build/src/info/Info.d.ts +37 -13
- package/build/src/interface/Movable.d.ts +5 -5
- package/build/src/interface/Selectable.d.ts +4 -4
- package/build/src/loader/Loader.d.ts +11 -0
- package/build/src/model/Model.d.ts +2 -2
- package/build/src/node/Node.d.ts +3 -3
- package/build/src/scene/root/Root.d.ts +1 -1
- package/build/src/types/ExporterOptions.d.ts +15 -0
- package/build/src/types/FileTypes.d.ts +27 -0
- package/build/src/types/index.d.ts +4 -0
- package/build/src/types/info/index.d.ts +66 -0
- package/package.json +17 -3
- package/build/src/exporters/usdz/USDZExporter.d.ts +0 -15
- package/build/src/loadingmanager/LoadingManager.d.ts +0 -14
- package/src/__test__/DIVE.test.ts +0 -274
- package/src/animation/AnimationSystem.ts +0 -34
- package/src/animation/__test__/AnimationSystem.test.ts +0 -40
- package/src/ar/AR.ts +0 -98
- package/src/ar/__test__/AR.test.ts +0 -187
- package/src/ar/arquicklook/ARQuickLook.ts +0 -93
- package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +0 -93
- package/src/ar/sceneviewer/SceneViewer.ts +0 -74
- package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +0 -93
- package/src/ar/webxr/WebXR.ts +0 -176
- package/src/ar/webxr/controller/WebXRController.ts +0 -340
- package/src/ar/webxr/crosshair/WebXRCrosshair.ts +0 -35
- package/src/ar/webxr/origin/WebXROrigin.ts +0 -192
- package/src/ar/webxr/overlay/Overlay.ts +0 -50
- package/src/ar/webxr/raycaster/WebXRRaycaster.ts +0 -131
- package/src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts +0 -102
- package/src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts +0 -49
- package/src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts +0 -356
- package/src/axiscamera/AxisCamera.ts +0 -108
- package/src/axiscamera/__test__/AxisCamera.test.ts +0 -150
- package/src/camera/PerspectiveCamera.ts +0 -63
- package/src/camera/__test__/PerspectiveCamera.test.ts +0 -36
- package/src/com/Communication.ts +0 -808
- package/src/com/__test__/Communication.test.ts +0 -1024
- package/src/com/actions/camera/computeencompassingview.ts +0 -10
- package/src/com/actions/camera/getcameratransform.ts +0 -10
- package/src/com/actions/camera/movecamera.ts +0 -18
- package/src/com/actions/camera/resetcamera.ts +0 -5
- package/src/com/actions/camera/setcameralayer.ts +0 -5
- package/src/com/actions/camera/setcameratransform.ts +0 -10
- package/src/com/actions/camera/zoomcamera.ts +0 -5
- package/src/com/actions/index.ts +0 -61
- package/src/com/actions/media/generatemedia.ts +0 -18
- package/src/com/actions/object/addobject.ts +0 -7
- package/src/com/actions/object/deleteobject.ts +0 -7
- package/src/com/actions/object/deselectobject.ts +0 -7
- package/src/com/actions/object/getallobjects.ts +0 -7
- package/src/com/actions/object/getobjects.ts +0 -7
- package/src/com/actions/object/model/dropit.ts +0 -5
- package/src/com/actions/object/model/modelloaded.ts +0 -5
- package/src/com/actions/object/model/placeonfloor.ts +0 -5
- package/src/com/actions/object/selectobject.ts +0 -7
- package/src/com/actions/object/setparent.ts +0 -10
- package/src/com/actions/object/updateobject.ts +0 -7
- package/src/com/actions/renderer/startrender.ts +0 -5
- package/src/com/actions/scene/exportscene.ts +0 -7
- package/src/com/actions/scene/getallscenedata.ts +0 -7
- package/src/com/actions/scene/launchar.ts +0 -7
- package/src/com/actions/scene/setbackground.ts +0 -5
- package/src/com/actions/scene/updatescene.ts +0 -11
- package/src/com/actions/toolbox/select/setgizmomode.ts +0 -5
- package/src/com/actions/toolbox/transform/setgizmoscalelinked.ts +0 -5
- package/src/com/actions/toolbox/transform/setgizmovisible.ts +0 -5
- package/src/com/actions/toolbox/usetool.ts +0 -7
- package/src/com/types/COMBaseEntity.ts +0 -9
- package/src/com/types/COMEntity.ts +0 -7
- package/src/com/types/COMEntityType.ts +0 -1
- package/src/com/types/COMGeometry.ts +0 -8
- package/src/com/types/COMGeometryType.ts +0 -9
- package/src/com/types/COMGroup.ts +0 -9
- package/src/com/types/COMLight.ts +0 -11
- package/src/com/types/COMMaterial.ts +0 -12
- package/src/com/types/COMModel.ts +0 -12
- package/src/com/types/COMPov.ts +0 -8
- package/src/com/types/COMPrimitive.ts +0 -12
- package/src/com/types/index.ts +0 -23
- package/src/constant/AxisHelperColors.ts +0 -7
- package/src/constant/GridColors.ts +0 -2
- package/src/constant/VisibilityLayerMask.ts +0 -5
- package/src/controls/OrbitControls.ts +0 -211
- package/src/controls/__test__/OrbitControls.test.ts +0 -256
- package/src/dive.ts +0 -363
- package/src/events/EventExecutor.ts +0 -35
- package/src/exporters/usdz/USDZExporter.ts +0 -21
- package/src/exporters/usdz/__test__/USDZExporter.test.ts +0 -57
- package/src/gizmo/Gizmo.ts +0 -144
- package/src/gizmo/handles/AxisHandle.ts +0 -153
- package/src/gizmo/handles/RadialHandle.ts +0 -149
- package/src/gizmo/handles/ScaleHandle.ts +0 -195
- package/src/gizmo/plane/GizmoPlane.ts +0 -84
- package/src/gizmo/rotate/RotateGizmo.ts +0 -143
- package/src/gizmo/scale/ScaleGizmo.ts +0 -125
- package/src/gizmo/translate/TranslateGizmo.ts +0 -114
- package/src/grid/Grid.ts +0 -34
- package/src/grid/__test__/Grid.test.ts +0 -28
- package/src/group/Group.ts +0 -184
- package/src/group/__test__/Group.test.ts +0 -212
- package/src/helper/applyMixins/__test__/applyMixins.test.ts +0 -30
- package/src/helper/applyMixins/applyMixins.ts +0 -18
- package/src/helper/findInterface/__test__/findInterface.test.ts +0 -63
- package/src/helper/findInterface/findInterface.ts +0 -13
- package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +0 -40
- package/src/helper/findSceneRecursive/findSceneRecursive.ts +0 -16
- package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +0 -186
- package/src/helper/getObjectDelta/getObjectDelta.ts +0 -105
- package/src/helper/isInterface/__test__/implementsInterface.test.ts +0 -19
- package/src/helper/isInterface/implementsInterface.ts +0 -9
- package/src/info/Info.ts +0 -154
- package/src/info/__test__/Info.test.ts +0 -338
- package/src/interface/Draggable.ts +0 -14
- package/src/interface/Hoverable.ts +0 -14
- package/src/interface/Movable.ts +0 -12
- package/src/interface/Rotatable.ts +0 -10
- package/src/interface/Scalable.ts +0 -10
- package/src/interface/Selectable.ts +0 -11
- package/src/io/IO.ts +0 -62
- package/src/io/__test__/IO.test.ts +0 -116
- package/src/io/gltf/GLTFIO.ts +0 -56
- package/src/io/gltf/__test__/GLTFIO.test.ts +0 -108
- package/src/light/AmbientLight.ts +0 -39
- package/src/light/PointLight.ts +0 -115
- package/src/light/SceneLight.ts +0 -63
- package/src/light/__test__/AmbientLight.test.ts +0 -29
- package/src/light/__test__/PointLight.test.ts +0 -74
- package/src/light/__test__/SceneLight.test.ts +0 -47
- package/src/loadingmanager/LoadingManager.ts +0 -50
- package/src/loadingmanager/__test__/LoadingManager.test.ts +0 -27
- package/src/math/__test__/DIVEMath.test.ts +0 -12
- package/src/math/ceil/__test__/ceilExp.test.ts +0 -12
- package/src/math/ceil/ceilExp.ts +0 -6
- package/src/math/degToRad/__test__/degToRad.test.ts +0 -172
- package/src/math/degToRad/degToRad.ts +0 -5
- package/src/math/floor/__test__/floorExp.test.ts +0 -14
- package/src/math/floor/floorExp.ts +0 -6
- package/src/math/helper/__test__/shift.test.ts +0 -12
- package/src/math/helper/shift.ts +0 -4
- package/src/math/index.ts +0 -28
- package/src/math/radToDeg/__test__/radToDeg.test.ts +0 -155
- package/src/math/radToDeg/radToDeg.ts +0 -5
- package/src/math/round/__test__/roundExp.test.ts +0 -14
- package/src/math/round/roundExp.ts +0 -10
- package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +0 -20
- package/src/math/signedAngleTo/signedAngleTo.ts +0 -20
- package/src/math/toFixed/__test__/toFixedExp.test.ts +0 -14
- package/src/math/toFixed/toFixedExp.ts +0 -9
- package/src/math/truncate/__test__/truncateExp.test.ts +0 -14
- package/src/math/truncate/truncateExp.ts +0 -9
- package/src/mediacreator/MediaCreator.ts +0 -75
- package/src/mediacreator/__test__/MediaCreator.test.ts +0 -155
- package/src/model/Model.ts +0 -185
- package/src/model/__test__/Model.test.ts +0 -222
- package/src/module/Module.ts +0 -45
- package/src/module/__test__/Module.test.ts +0 -54
- package/src/node/Node.ts +0 -98
- package/src/node/__test__/Node.test.ts +0 -120
- package/src/primitive/Primitive.ts +0 -299
- package/src/primitive/__test__/Primitive.test.ts +0 -281
- package/src/primitive/floor/Floor.ts +0 -45
- package/src/primitive/floor/__test__/Floor.test.ts +0 -24
- package/src/renderer/Renderer.ts +0 -215
- package/src/renderer/__test__/Renderer.test.ts +0 -228
- package/src/scene/Scene.ts +0 -106
- package/src/scene/__test__/Scene.test.ts +0 -124
- package/src/scene/root/Root.ts +0 -426
- package/src/scene/root/__test__/Root.test.ts +0 -903
- package/src/scene/xrroot/XRRoot.ts +0 -56
- package/src/scene/xrroot/xrlightroot/XRLightRoot.ts +0 -80
- package/src/toolbox/BaseTool.ts +0 -319
- package/src/toolbox/Toolbox.ts +0 -129
- package/src/toolbox/__test__/BaseTool.test.ts +0 -627
- package/src/toolbox/__test__/Toolbox.test.ts +0 -143
- package/src/toolbox/select/SelectTool.ts +0 -92
- package/src/toolbox/select/__test__/SelectTool.test.ts +0 -237
- package/src/toolbox/transform/TransformTool.ts +0 -166
- package/src/toolbox/transform/__test__/TransformTool.test.ts +0 -147
- package/src/types/SceneData.ts +0 -26
- package/src/types/SceneObjects.ts +0 -14
- package/src/types/SceneType.ts +0 -14
- package/src/types/index.ts +0 -5
package/src/scene/root/Root.ts
DELETED
|
@@ -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 { 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';
|
|
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 loadingManager: DIVELoadingManager;
|
|
32
|
-
|
|
33
|
-
constructor() {
|
|
34
|
-
super();
|
|
35
|
-
this.name = 'Root';
|
|
36
|
-
|
|
37
|
-
this.loadingManager = new DIVELoadingManager();
|
|
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.loadingManager.LoadGLTF(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
|
-
}
|