@shopware-ag/dive 1.12.0 → 1.13.0

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 (77) hide show
  1. package/build/dive.cjs +475 -452
  2. package/build/dive.cjs.map +1 -1
  3. package/build/dive.d.cts +311 -78
  4. package/build/dive.d.ts +311 -78
  5. package/build/dive.js +455 -432
  6. package/build/dive.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/__test__/DIVE.test.ts +33 -29
  9. package/src/axiscamera/AxisCamera.ts +1 -1
  10. package/src/axiscamera/__test__/AxisCamera.test.ts +1 -1
  11. package/src/com/Communication.ts +59 -14
  12. package/src/com/__test__/Communication.test.ts +111 -31
  13. package/src/com/actions/index.ts +2 -0
  14. package/src/com/actions/object/addobject.ts +1 -1
  15. package/src/com/actions/object/deleteobject.ts +1 -1
  16. package/src/com/actions/object/deselectobject.ts +1 -1
  17. package/src/com/actions/object/getallobjects.ts +1 -1
  18. package/src/com/actions/object/getobjects.ts +1 -1
  19. package/src/com/actions/object/selectobject.ts +1 -1
  20. package/src/com/actions/object/setparent.ts +9 -0
  21. package/src/com/actions/object/updateobject.ts +1 -1
  22. package/src/com/actions/scene/getallscenedata.ts +1 -1
  23. package/src/com/types/COMBaseEntity.ts +9 -0
  24. package/src/com/types/COMEntity.ts +7 -0
  25. package/src/com/types/COMEntityType.ts +1 -0
  26. package/src/com/types/COMGeometry.ts +6 -0
  27. package/src/com/types/COMGroup.ts +9 -0
  28. package/src/com/types/COMLight.ts +10 -0
  29. package/src/com/types/COMMaterial.ts +12 -0
  30. package/src/com/types/COMModel.ts +12 -0
  31. package/src/com/types/COMPov.ts +8 -0
  32. package/src/com/types/COMPrimitive.ts +12 -0
  33. package/src/com/types/index.ts +21 -0
  34. package/src/dive.ts +9 -15
  35. package/src/grid/Grid.ts +1 -1
  36. package/src/grid/__test__/Grid.test.ts +1 -1
  37. package/src/group/Group.ts +111 -0
  38. package/src/group/__test__/Group.test.ts +67 -0
  39. package/src/helper/findSceneRecursive/findSceneRecursive.ts +1 -1
  40. package/src/light/AmbientLight.ts +3 -0
  41. package/src/light/PointLight.ts +6 -3
  42. package/src/light/SceneLight.ts +2 -0
  43. package/src/light/__test__/PointLight.test.ts +8 -6
  44. package/src/light/__test__/SceneLight.test.ts +8 -6
  45. package/src/loadingmanager/LoadingManager.ts +1 -1
  46. package/src/loadingmanager/__test__/LoadingManager.test.ts +1 -1
  47. package/src/mediacreator/MediaCreator.ts +1 -1
  48. package/src/mediacreator/__test__/MediaCreator.test.ts +6 -4
  49. package/src/model/Model.ts +8 -7
  50. package/src/model/__test__/Model.test.ts +13 -10
  51. package/src/primitive/Primitive.ts +50 -34
  52. package/src/primitive/__test__/Primitive.test.ts +39 -21
  53. package/src/primitive/floor/Floor.ts +1 -1
  54. package/src/primitive/floor/__test__/Floor.test.ts +1 -1
  55. package/src/renderer/__test__/Renderer.test.ts +1 -1
  56. package/src/scene/Scene.ts +29 -9
  57. package/src/scene/__test__/Scene.test.ts +33 -19
  58. package/src/scene/root/Root.ts +239 -72
  59. package/src/scene/root/__test__/Root.test.ts +476 -114
  60. package/src/toolbox/BaseTool.ts +1 -1
  61. package/src/toolbox/Toolbox.ts +1 -1
  62. package/src/toolbox/__test__/BaseTool.test.ts +1 -1
  63. package/src/toolbox/__test__/Toolbox.test.ts +1 -1
  64. package/src/toolbox/select/SelectTool.ts +1 -1
  65. package/src/toolbox/select/__test__/SelectTool.test.ts +11 -9
  66. package/src/toolbox/transform/TransformTool.ts +1 -1
  67. package/src/toolbox/transform/__test__/TransformTool.test.ts +12 -10
  68. package/src/types/SceneObjects.ts +14 -0
  69. package/src/types/index.ts +5 -0
  70. package/src/com/index.ts +0 -3
  71. package/src/com/types.ts +0 -58
  72. package/src/scene/root/lightroot/LightRoot.ts +0 -99
  73. package/src/scene/root/lightroot/__test__/LightRoot.test.ts +0 -145
  74. package/src/scene/root/modelroot/ModelRoot.ts +0 -98
  75. package/src/scene/root/modelroot/__test__/ModelRoot.test.ts +0 -189
  76. package/src/scene/root/primitiveroot/PrimitiveRoot.ts +0 -88
  77. package/src/scene/root/primitiveroot/__test__/PrimitiveRoot.test.ts +0 -181
package/build/dive.js CHANGED
@@ -649,13 +649,10 @@ var DIVERenderer = class extends WebGLRenderer {
649
649
  };
650
650
 
651
651
  // src/scene/Scene.ts
652
- import { Color as Color8, Scene as Scene2 } from "three";
652
+ import { Color as Color7, Scene as Scene2 } from "three";
653
653
 
654
654
  // src/scene/root/Root.ts
655
- import { Box3 as Box33, Object3D as Object3D11 } from "three";
656
-
657
- // src/scene/root/lightroot/LightRoot.ts
658
- import { Color as Color4, Object3D as Object3D5 } from "three";
655
+ import { Box3 as Box34, Color as Color5, Object3D as Object3D8 } from "three";
659
656
 
660
657
  // src/light/AmbientLight.ts
661
658
  init_VisibilityLayerMask();
@@ -663,6 +660,8 @@ import { AmbientLight, Object3D } from "three";
663
660
  var DIVEAmbientLight = class extends Object3D {
664
661
  constructor() {
665
662
  super();
663
+ this.isDIVELight = true;
664
+ this.isDIVEAmbientLight = true;
666
665
  this.name = "DIVEAmbientLight";
667
666
  this._light = new AmbientLight(16777215, 1);
668
667
  this._light.layers.mask = PRODUCT_LAYER_MASK;
@@ -818,6 +817,10 @@ var _DIVECommunication = class _DIVECommunication {
818
817
  returnValue = this.generateMedia(payload);
819
818
  break;
820
819
  }
820
+ case "SET_PARENT": {
821
+ returnValue = this.setParent(payload);
822
+ break;
823
+ }
821
824
  }
822
825
  this.dispatch(action, payload);
823
826
  return returnValue;
@@ -844,8 +847,8 @@ var _DIVECommunication = class _DIVECommunication {
844
847
  name: this.scene.name,
845
848
  mediaItem: null,
846
849
  backgroundColor: "#" + this.scene.background.getHexString(),
847
- floorEnabled: this.scene.Root.Floor.visible,
848
- floorColor: "#" + this.scene.Root.Floor.material.color.getHexString(),
850
+ floorEnabled: this.scene.Floor.visible,
851
+ floorColor: "#" + this.scene.Floor.material.color.getHexString(),
849
852
  userCamera: {
850
853
  position: this.controller.object.position.clone(),
851
854
  target: this.controller.target.clone()
@@ -873,6 +876,7 @@ var _DIVECommunication = class _DIVECommunication {
873
876
  }
874
877
  addObject(payload) {
875
878
  if (this.registered.get(payload.id)) return false;
879
+ if (payload.parent === void 0) payload.parent = null;
876
880
  this.registered.set(payload.id, payload);
877
881
  this.scene.AddSceneObject(payload);
878
882
  return true;
@@ -882,7 +886,7 @@ var _DIVECommunication = class _DIVECommunication {
882
886
  if (!objectToUpdate) return false;
883
887
  this.registered.set(payload.id, __spreadValues(__spreadValues({}, objectToUpdate), payload));
884
888
  const updatedObject = this.registered.get(payload.id);
885
- this.scene.UpdateSceneObject(updatedObject);
889
+ this.scene.UpdateSceneObject(__spreadProps(__spreadValues({}, payload), { id: updatedObject.id, entityType: updatedObject.entityType }));
886
890
  Object.assign(payload, updatedObject);
887
891
  return true;
888
892
  }
@@ -1001,14 +1005,14 @@ var _DIVECommunication = class _DIVECommunication {
1001
1005
  updateScene(payload) {
1002
1006
  if (payload.name !== void 0) this.scene.name = payload.name;
1003
1007
  if (payload.backgroundColor !== void 0) this.scene.SetBackground(payload.backgroundColor);
1004
- if (payload.gridEnabled !== void 0) this.scene.Root.Grid.SetVisibility(payload.gridEnabled);
1005
- if (payload.floorEnabled !== void 0) this.scene.Root.Floor.SetVisibility(payload.floorEnabled);
1006
- if (payload.floorColor !== void 0) this.scene.Root.Floor.SetColor(payload.floorColor);
1008
+ if (payload.gridEnabled !== void 0) this.scene.Grid.SetVisibility(payload.gridEnabled);
1009
+ if (payload.floorEnabled !== void 0) this.scene.Floor.SetVisibility(payload.floorEnabled);
1010
+ if (payload.floorColor !== void 0) this.scene.Floor.SetColor(payload.floorColor);
1007
1011
  payload.name = this.scene.name;
1008
1012
  payload.backgroundColor = "#" + this.scene.background.getHexString();
1009
- payload.gridEnabled = this.scene.Root.Grid.visible;
1010
- payload.floorEnabled = this.scene.Root.Floor.visible;
1011
- payload.floorColor = "#" + this.scene.Root.Floor.material.color.getHexString();
1013
+ payload.gridEnabled = this.scene.Grid.visible;
1014
+ payload.floorEnabled = this.scene.Floor.visible;
1015
+ payload.floorColor = "#" + this.scene.Floor.material.color.getHexString();
1012
1016
  return true;
1013
1017
  }
1014
1018
  generateMedia(payload) {
@@ -1024,6 +1028,31 @@ var _DIVECommunication = class _DIVECommunication {
1024
1028
  payload.dataUri = this.mediaGenerator.GenerateMedia(position, target, payload.width, payload.height);
1025
1029
  return true;
1026
1030
  }
1031
+ setParent(payload) {
1032
+ const object = this.registered.get(payload.object.id);
1033
+ if (!object) return false;
1034
+ const sceneObject = this.scene.GetSceneObject(object);
1035
+ if (!sceneObject) return false;
1036
+ if (payload.parent === null) {
1037
+ this.scene.Root.attach(sceneObject);
1038
+ return true;
1039
+ }
1040
+ if (payload.object.id === payload.parent.id) {
1041
+ return false;
1042
+ }
1043
+ const parent = this.registered.get(payload.parent.id);
1044
+ if (!parent) {
1045
+ this.scene.Root.attach(sceneObject);
1046
+ return true;
1047
+ }
1048
+ const parentObject = this.scene.GetSceneObject(parent);
1049
+ if (!parentObject) {
1050
+ this.scene.Root.attach(sceneObject);
1051
+ return true;
1052
+ }
1053
+ parentObject.attach(sceneObject);
1054
+ return true;
1055
+ }
1027
1056
  };
1028
1057
  _DIVECommunication.__instances = [];
1029
1058
  var DIVECommunication = _DIVECommunication;
@@ -1033,6 +1062,8 @@ init_VisibilityLayerMask();
1033
1062
  var DIVEPointLight = class extends Object3D3 {
1034
1063
  constructor() {
1035
1064
  super();
1065
+ this.isDIVELight = true;
1066
+ this.isDIVEPointLight = true;
1036
1067
  this.isMoveable = true;
1037
1068
  this.isSelectable = true;
1038
1069
  this.gizmo = null;
@@ -1081,6 +1112,8 @@ import { DirectionalLight, HemisphereLight, Object3D as Object3D4 } from "three"
1081
1112
  var DIVESceneLight = class extends Object3D4 {
1082
1113
  constructor() {
1083
1114
  super();
1115
+ this.isDIVELight = true;
1116
+ this.isDIVESceneLight = true;
1084
1117
  this.name = "DIVESceneLight";
1085
1118
  this._hemiLight = new HemisphereLight(16777215, 16777215, 2);
1086
1119
  this._hemiLight.layers.mask = PRODUCT_LAYER_MASK;
@@ -1115,87 +1148,9 @@ var DIVESceneLight = class extends Object3D4 {
1115
1148
  }
1116
1149
  };
1117
1150
 
1118
- // src/scene/root/lightroot/LightRoot.ts
1119
- var DIVELightRoot = class extends Object3D5 {
1120
- constructor() {
1121
- super();
1122
- this.name = "LightRoot";
1123
- }
1124
- GetLight(object) {
1125
- if (object.id === void 0) {
1126
- console.warn("LightRoot.GetLight: object.id is undefined");
1127
- return void 0;
1128
- }
1129
- return this.children.find((object3D) => object3D.userData.id === object.id);
1130
- }
1131
- UpdateLight(light) {
1132
- if (light.id === void 0) {
1133
- console.warn(`LightRoot.UpdateLight: light.id is undefined`);
1134
- return;
1135
- }
1136
- let sceneObject = this.children.find((object3D) => object3D.userData.id === light.id);
1137
- if (!sceneObject) {
1138
- switch (light.type) {
1139
- case "scene": {
1140
- sceneObject = new DIVESceneLight();
1141
- break;
1142
- }
1143
- case "ambient": {
1144
- sceneObject = new DIVEAmbientLight();
1145
- break;
1146
- }
1147
- case "point": {
1148
- sceneObject = new DIVEPointLight();
1149
- break;
1150
- }
1151
- default: {
1152
- console.warn(`LightRoot.UpdateLight: Unknown light type: ${light.type}`);
1153
- return;
1154
- }
1155
- }
1156
- sceneObject.userData.id = light.id;
1157
- this.add(sceneObject);
1158
- }
1159
- if (light.name !== void 0 && light.name !== null) sceneObject.name = light.name;
1160
- if (light.position !== void 0 && light.position !== null) sceneObject.position.set(light.position.x, light.position.y, light.position.z);
1161
- if (light.intensity !== void 0 && light.intensity !== null) sceneObject.SetIntensity(light.intensity);
1162
- if (light.enabled !== void 0 && light.enabled !== null) sceneObject.SetEnabled(light.enabled);
1163
- if (light.color !== void 0 && light.color !== null) sceneObject.SetColor(new Color4(light.color));
1164
- if (light.visible !== void 0 && light.visible !== null) sceneObject.visible = light.visible;
1165
- }
1166
- DeleteLight(light) {
1167
- if (light.id === void 0) {
1168
- console.warn("LightRoot.DeleteLight: light.id is undefined");
1169
- return;
1170
- }
1171
- const sceneObject = this.children.find((object3D) => object3D.userData.id === light.id);
1172
- if (!sceneObject) {
1173
- console.warn(`LightRoot.DeleteLight: Light with id ${light.id} not found`);
1174
- return;
1175
- }
1176
- const findScene = (object) => {
1177
- if (object.parent !== null) {
1178
- return findScene(object.parent);
1179
- }
1180
- ;
1181
- return object;
1182
- };
1183
- const scene = findScene(sceneObject);
1184
- scene.children.find((object) => {
1185
- if ("isTransformControls" in object) {
1186
- object.detach();
1187
- }
1188
- });
1189
- this.remove(sceneObject);
1190
- }
1191
- };
1192
-
1193
- // src/scene/root/modelroot/ModelRoot.ts
1194
- import { Object3D as Object3D7 } from "three";
1195
-
1196
1151
  // src/model/Model.ts
1197
1152
  init_VisibilityLayerMask();
1198
- import { Box3, Color as Color5, MeshStandardMaterial, Object3D as Object3D6, Raycaster as Raycaster2, Vector3 as Vector32 } from "three";
1153
+ import { Box3, MeshStandardMaterial, Object3D as Object3D5, Raycaster as Raycaster2, Vector3 as Vector32 } from "three";
1199
1154
 
1200
1155
  // src/helper/findSceneRecursive/findSceneRecursive.ts
1201
1156
  var findSceneRecursive = (object) => {
@@ -1206,9 +1161,10 @@ var findSceneRecursive = (object) => {
1206
1161
  };
1207
1162
 
1208
1163
  // src/model/Model.ts
1209
- var DIVEModel = class extends Object3D6 {
1164
+ var DIVEModel = class extends Object3D5 {
1210
1165
  constructor() {
1211
1166
  super();
1167
+ this.isDIVEModel = true;
1212
1168
  this.isSelectable = true;
1213
1169
  this.isMoveable = true;
1214
1170
  this.gizmo = null;
@@ -1257,7 +1213,7 @@ var DIVEModel = class extends Object3D6 {
1257
1213
  this._material.vertexColors = material.vertexColors;
1258
1214
  }
1259
1215
  if (material.color !== void 0) {
1260
- this._material.color = new Color5(material.color);
1216
+ this._material.color.set(material.color);
1261
1217
  }
1262
1218
  if (material.map !== void 0) {
1263
1219
  this._material.map = material.map;
@@ -1285,7 +1241,6 @@ var DIVEModel = class extends Object3D6 {
1285
1241
  }
1286
1242
  if (this._mesh) {
1287
1243
  this._mesh.material = this._material;
1288
- this._mesh.material.needsUpdate = true;
1289
1244
  }
1290
1245
  }
1291
1246
  SetToWorldOrigin() {
@@ -1368,85 +1323,13 @@ var DIVELoadingManager = class {
1368
1323
  }
1369
1324
  };
1370
1325
 
1371
- // src/scene/root/modelroot/ModelRoot.ts
1372
- var DIVEModelRoot = class extends Object3D7 {
1373
- constructor() {
1374
- super();
1375
- this.name = "ModelRoot";
1376
- this.loadingManager = new DIVELoadingManager();
1377
- }
1378
- GetModel(object) {
1379
- if (object.id === void 0) {
1380
- console.warn("ModelRoot.GetModel: object.id is undefined");
1381
- return void 0;
1382
- }
1383
- return this.children.find((object3D) => object3D.userData.id === object.id);
1384
- }
1385
- UpdateModel(object) {
1386
- if (object.id === void 0) {
1387
- console.warn("ModelRoot.UpdateModel: object.id is undefined");
1388
- return;
1389
- }
1390
- let sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
1391
- if (!sceneObject && object.uri !== void 0) {
1392
- const model = new DIVEModel();
1393
- sceneObject = model;
1394
- sceneObject.userData.id = object.id;
1395
- this.add(sceneObject);
1396
- this.loadingManager.LoadGLTF(object.uri).then((gltf) => {
1397
- var _a;
1398
- model.SetModel(gltf);
1399
- (_a = DIVECommunication.get(object.id)) == null ? void 0 : _a.PerformAction("MODEL_LOADED", { id: object.id });
1400
- });
1401
- }
1402
- if (object.position !== void 0) sceneObject.SetPosition(object.position);
1403
- if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
1404
- if (object.scale !== void 0) sceneObject.SetScale(object.scale);
1405
- if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
1406
- if (object.material !== void 0) sceneObject.SetMaterial(object.material);
1407
- }
1408
- DeleteModel(object) {
1409
- if (object.id === void 0) {
1410
- console.warn(`ModelRoot.DeleteModel: object.id is undefined`);
1411
- return;
1412
- }
1413
- const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
1414
- if (!sceneObject) {
1415
- console.warn(`ModelRoot.DeleteModel: Model with id ${object.id} not found`);
1416
- return;
1417
- }
1418
- const findScene = (object2) => {
1419
- if (object2.parent !== null) {
1420
- return findScene(object2.parent);
1421
- }
1422
- ;
1423
- return object2;
1424
- };
1425
- const scene = findScene(sceneObject);
1426
- scene.children.find((object2) => {
1427
- if ("isTransformControls" in object2) {
1428
- object2.detach();
1429
- }
1430
- });
1431
- this.remove(sceneObject);
1432
- }
1433
- PlaceOnFloor(object) {
1434
- if (object.id === void 0) console.warn("ModelRoot.PlaceOnFloor: object.id is undefined");
1435
- const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
1436
- if (!sceneObject) return;
1437
- sceneObject.PlaceOnFloor();
1438
- }
1439
- };
1440
-
1441
- // src/scene/root/primitiveroot/PrimitiveRoot.ts
1442
- import { Object3D as Object3D9 } from "three";
1443
-
1444
1326
  // src/primitive/Primitive.ts
1445
- import { Box3 as Box32, BoxGeometry, BufferGeometry, Color as Color6, CylinderGeometry, Float32BufferAttribute, Mesh as Mesh3, Object3D as Object3D8, Raycaster as Raycaster3, SphereGeometry as SphereGeometry2, Uint32BufferAttribute, Vector3 as Vector33 } from "three";
1327
+ import { Box3 as Box32, BoxGeometry, BufferGeometry, Color as Color4, ConeGeometry, CylinderGeometry, Mesh as Mesh3, MeshStandardMaterial as MeshStandardMaterial2, Object3D as Object3D6, Raycaster as Raycaster3, SphereGeometry as SphereGeometry2, Vector3 as Vector33 } from "three";
1446
1328
  init_VisibilityLayerMask();
1447
- var DIVEPrimitive = class extends Object3D8 {
1329
+ var DIVEPrimitive = class extends Object3D6 {
1448
1330
  constructor() {
1449
1331
  super();
1332
+ this.isDIVEPrimitive = true;
1450
1333
  this.isSelectable = true;
1451
1334
  this.isMoveable = true;
1452
1335
  this.gizmo = null;
@@ -1455,11 +1338,11 @@ var DIVEPrimitive = class extends Object3D8 {
1455
1338
  this._mesh.layers.mask = PRODUCT_LAYER_MASK;
1456
1339
  this._mesh.castShadow = true;
1457
1340
  this._mesh.receiveShadow = true;
1341
+ this._mesh.material = new MeshStandardMaterial2();
1458
1342
  this.add(this._mesh);
1459
1343
  this._boundingBox = new Box32();
1460
1344
  }
1461
1345
  SetGeometry(geometry) {
1462
- this.clear();
1463
1346
  this._mesh.geometry = this.assembleGeometry(geometry);
1464
1347
  this._boundingBox.setFromObject(this._mesh);
1465
1348
  }
@@ -1479,20 +1362,34 @@ var DIVEPrimitive = class extends Object3D8 {
1479
1362
  }
1480
1363
  SetMaterial(material) {
1481
1364
  const primitiveMaterial = this._mesh.material;
1482
- if (material.color !== void 0) primitiveMaterial.color = new Color6(material.color);
1483
- if (material.map !== void 0) primitiveMaterial.map = material.map;
1484
- if (material.roughness !== void 0) primitiveMaterial.roughness = material.roughness;
1365
+ if (material.vertexColors !== void 0) {
1366
+ primitiveMaterial.vertexColors = material.vertexColors;
1367
+ }
1368
+ if (material.color !== void 0) {
1369
+ primitiveMaterial.color = new Color4(material.color);
1370
+ }
1371
+ if (material.map !== void 0) {
1372
+ primitiveMaterial.map = material.map;
1373
+ }
1374
+ if (material.normalMap !== void 0) {
1375
+ primitiveMaterial.normalMap = material.normalMap;
1376
+ }
1377
+ if (material.roughness !== void 0) {
1378
+ primitiveMaterial.roughness = material.roughness;
1379
+ }
1485
1380
  if (material.roughnessMap !== void 0) {
1486
1381
  primitiveMaterial.roughnessMap = material.roughnessMap;
1487
1382
  if (primitiveMaterial.roughnessMap) {
1488
1383
  primitiveMaterial.roughness = 1;
1489
1384
  }
1490
1385
  }
1491
- if (material.metalness !== void 0) primitiveMaterial.metalness = material.metalness;
1386
+ if (material.metalness !== void 0) {
1387
+ primitiveMaterial.metalness = material.metalness;
1388
+ }
1492
1389
  if (material.metalnessMap !== void 0) {
1493
1390
  primitiveMaterial.metalnessMap = material.metalnessMap;
1494
1391
  if (primitiveMaterial.metalnessMap) {
1495
- primitiveMaterial.metalness = 1;
1392
+ primitiveMaterial.metalness = 0;
1496
1393
  }
1497
1394
  }
1498
1395
  if (this._mesh) this._mesh.material = primitiveMaterial;
@@ -1564,208 +1461,127 @@ var DIVEPrimitive = class extends Object3D8 {
1564
1461
  }
1565
1462
  }
1566
1463
  createCylinderGeometry(geometry) {
1567
- return new CylinderGeometry(geometry.width * 2, geometry.width * 2, geometry.height, 64);
1464
+ const geo = new CylinderGeometry(geometry.width / 2, geometry.width / 2, geometry.height, 64);
1465
+ geo.translate(0, geometry.height / 2, 0);
1466
+ return geo;
1568
1467
  }
1569
1468
  createSphereGeometry(geometry) {
1570
- return new SphereGeometry2(geometry.width * 2, 64);
1469
+ const geo = new SphereGeometry2(geometry.width / 2, 256, 256);
1470
+ return geo;
1571
1471
  }
1572
1472
  createPyramidGeometry(geometry) {
1573
- const geo = new BufferGeometry();
1574
- const { width, height, depth } = geometry;
1575
- geo.setAttribute("position", new Float32BufferAttribute([
1576
- width / 2,
1577
- 0,
1578
- depth / 2,
1579
- // right back
1580
- width / 2,
1581
- 0,
1582
- -depth / 2,
1583
- // right front
1584
- -width / 2,
1585
- 0,
1586
- -depth / 2,
1587
- // left front
1588
- -width / 2,
1589
- 0,
1590
- depth / 2,
1591
- // left back
1592
- 0,
1593
- height,
1594
- 0
1595
- // top
1596
- ], 3));
1597
- geo.setIndex(new Uint32BufferAttribute([
1598
- 1,
1599
- 0,
1600
- 4,
1601
- 2,
1602
- 1,
1603
- 4,
1604
- 3,
1605
- 2,
1606
- 4,
1607
- 3,
1608
- 0,
1609
- 4,
1610
- 0,
1611
- 1,
1612
- 2,
1613
- 0,
1614
- 2,
1615
- 3
1616
- ], 1));
1473
+ const geo = new ConeGeometry(geometry.width / 2, geometry.height, 4, 1, true);
1474
+ geo.rotateY(Math.PI / 4);
1475
+ geo.translate(0, geometry.height / 2, 0);
1617
1476
  return geo;
1618
1477
  }
1619
1478
  createBoxGeometry(geometry) {
1620
- return new BoxGeometry(geometry.width, geometry.height, geometry.depth);
1479
+ const geo = new BoxGeometry(geometry.width, geometry.height, geometry.depth);
1480
+ geo.translate(0, geometry.height / 2, 0);
1481
+ return geo;
1621
1482
  }
1622
1483
  createConeGeometry(geometry) {
1623
- return new CylinderGeometry(0, geometry.width * 2, geometry.height, 64);
1484
+ const geo = new ConeGeometry(geometry.width / 2, geometry.height, 256);
1485
+ geo.translate(0, geometry.height / 2, 0);
1486
+ return geo;
1624
1487
  }
1625
1488
  createWallGeometry(geometry) {
1626
- return new BoxGeometry(geometry.width, geometry.height, geometry.depth, 16);
1489
+ const geo = new BoxGeometry(geometry.width, geometry.height, geometry.depth || 0.05, 16);
1490
+ geo.translate(0, geometry.height / 2, 0);
1491
+ return geo;
1627
1492
  }
1628
1493
  createPlaneGeometry(geometry) {
1629
- return new BoxGeometry(geometry.width, geometry.height, geometry.depth);
1494
+ const geo = new BoxGeometry(geometry.width, geometry.height, geometry.depth);
1495
+ geo.translate(0, geometry.height / 2, 0);
1496
+ return geo;
1630
1497
  }
1631
1498
  };
1632
1499
 
1633
- // src/scene/root/primitiveroot/PrimitiveRoot.ts
1634
- var DIVEPrimitiveRoot = class extends Object3D9 {
1500
+ // src/group/Group.ts
1501
+ import { Box3 as Box33, BoxGeometry as BoxGeometry2, Mesh as Mesh4, MeshBasicMaterial as MeshBasicMaterial2, Object3D as Object3D7, Vector3 as Vector34 } from "three";
1502
+ var DIVEGroup = class extends Object3D7 {
1635
1503
  constructor() {
1636
1504
  super();
1637
- this.name = "PrimitiveRoot";
1505
+ this.isDIVEGroup = true;
1506
+ this.isSelectable = true;
1507
+ this.isMoveable = true;
1508
+ this.name = "DIVEGroup";
1509
+ this._bb = new Box33();
1510
+ this._boxMesh = new Mesh4(new BoxGeometry2(0, 0, 0), new MeshBasicMaterial2({ color: 16711680, wireframe: true }));
1511
+ this._boxMesh.visible = false;
1512
+ this.add(this._boxMesh);
1638
1513
  }
1639
- GetPrimitive(object) {
1640
- if (object.id === void 0) {
1641
- console.warn("PrimitiveRoot.GetPrimitive: object.id is undefined");
1642
- return void 0;
1643
- }
1644
- return this.children.find((object3D) => object3D.userData.id === object.id);
1514
+ SetPosition(position) {
1515
+ this.position.set(position.x, position.y, position.z);
1645
1516
  }
1646
- UpdatePrimitive(object) {
1647
- if (object.id === void 0) {
1648
- console.warn("PrimitiveRoot.UpdatePrimitive: object.id is undefined");
1649
- return;
1650
- }
1651
- let sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
1652
- if (!sceneObject && object.geometry !== void 0) {
1653
- const primitive = new DIVEPrimitive();
1654
- primitive.SetGeometry(object.geometry);
1655
- sceneObject = primitive;
1656
- sceneObject.userData.id = object.id;
1657
- this.add(sceneObject);
1658
- }
1659
- if (object.position !== void 0) sceneObject.SetPosition(object.position);
1660
- if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
1661
- if (object.scale !== void 0) sceneObject.SetScale(object.scale);
1662
- if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
1663
- if (object.material !== void 0) sceneObject.SetMaterial(object.material);
1517
+ SetRotation(rotation) {
1518
+ this.rotation.setFromVector3(new Vector34(rotation.x, rotation.y, rotation.z));
1664
1519
  }
1665
- DeletePrimitive(object) {
1666
- if (object.id === void 0) {
1667
- console.warn(`PrimitiveRoot.DeletePrimitive: object.id is undefined`);
1668
- return;
1669
- }
1670
- const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
1671
- if (!sceneObject) {
1672
- console.warn(`PrimitiveRoot.DeletePrimitive: Primitive with id ${object.id} not found`);
1673
- return;
1674
- }
1675
- const findScene = (object2) => {
1676
- if (object2.parent !== null) {
1677
- return findScene(object2.parent);
1678
- }
1679
- ;
1680
- return object2;
1681
- };
1682
- const scene = findScene(sceneObject);
1683
- scene.children.find((object2) => {
1684
- if ("isTransformControls" in object2) {
1685
- object2.detach();
1686
- }
1520
+ SetScale(scale) {
1521
+ this.scale.set(scale.x, scale.y, scale.z);
1522
+ }
1523
+ SetVisibility(visible) {
1524
+ this.traverse((child) => {
1525
+ if (child.uuid === this._boxMesh.uuid) return;
1526
+ child.visible = visible;
1687
1527
  });
1688
- this.remove(sceneObject);
1689
1528
  }
1690
- PlaceOnFloor(object) {
1691
- if (object.id === void 0) console.warn("PrimitiveRoot.PlaceOnFloor: object.id is undefined");
1692
- const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
1693
- if (!sceneObject) return;
1694
- sceneObject.PlaceOnFloor();
1529
+ SetBoundingBoxVisibility(visible) {
1530
+ this._boxMesh.visible = visible;
1695
1531
  }
1696
- };
1697
-
1698
- // src/primitive/floor/Floor.ts
1699
- init_VisibilityLayerMask();
1700
- import { Color as Color7, Mesh as Mesh4, MeshStandardMaterial as MeshStandardMaterial3, PlaneGeometry } from "three";
1701
- var DIVEFloor = class extends Mesh4 {
1702
- constructor() {
1703
- super(new PlaneGeometry(1e4, 1e4), new MeshStandardMaterial3({ color: new Color7(150 / 255, 150 / 255, 150 / 255) }));
1704
- this.isFloor = true;
1705
- this.name = "Floor";
1706
- this.layers.mask = PRODUCT_LAYER_MASK;
1707
- this.receiveShadow = true;
1708
- this.rotateX(-Math.PI / 2);
1532
+ attach(object) {
1533
+ super.attach(object);
1534
+ this.recalculatePosition();
1535
+ this.updateBoxMesh();
1536
+ return this;
1709
1537
  }
1710
- SetVisibility(visible) {
1711
- this.visible = visible;
1538
+ remove(object) {
1539
+ super.remove(object);
1540
+ this.recalculatePosition();
1541
+ this.updateBoxMesh();
1542
+ return this;
1712
1543
  }
1713
- SetColor(color) {
1714
- this.material.color = new Color7(color);
1544
+ /**
1545
+ * Recalculates the position of the group based on it's bounding box.
1546
+ * Children's world positions are kept.
1547
+ */
1548
+ recalculatePosition() {
1549
+ const childrensWorldPositions = this.children.map((child) => child.getWorldPosition(new Vector34()));
1550
+ const bbcenter = this.updateBB();
1551
+ this.position.copy(bbcenter);
1552
+ this.children.forEach((child, i) => {
1553
+ if (child.uuid === this._boxMesh.uuid) return;
1554
+ child.position.copy(this.worldToLocal(childrensWorldPositions[i]));
1555
+ });
1715
1556
  }
1716
- };
1717
-
1718
- // src/constant/GridColors.ts
1719
- var GRID_CENTER_LINE_COLOR = "#888888";
1720
- var GRID_SIDE_LINE_COLOR = "#dddddd";
1721
-
1722
- // src/grid/Grid.ts
1723
- init_VisibilityLayerMask();
1724
- import { GridHelper, Object3D as Object3D10 } from "three";
1725
- var DIVEGrid = class extends Object3D10 {
1726
- constructor() {
1727
- super();
1728
- this.name = "Grid";
1729
- const grid = new GridHelper(100, 100, GRID_CENTER_LINE_COLOR, GRID_SIDE_LINE_COLOR);
1730
- grid.material.depthTest = false;
1731
- grid.layers.mask = HELPER_LAYER_MASK;
1732
- this.add(grid);
1557
+ /**
1558
+ * Updates the bounding box of the group.
1559
+ * @returns {Vector3} The new center of the bounding box.
1560
+ */
1561
+ updateBB() {
1562
+ this._bb.makeEmpty();
1563
+ this.children.forEach((child) => {
1564
+ if (child.uuid === this._boxMesh.uuid) return;
1565
+ this._bb.expandByObject(child);
1566
+ });
1567
+ return this._bb.getCenter(new Vector34());
1733
1568
  }
1734
- SetVisibility(visible) {
1735
- this.visible = visible;
1569
+ updateBoxMesh() {
1570
+ this._boxMesh.geometry = new BoxGeometry2(this._bb.max.x - this._bb.min.x, this._bb.max.y - this._bb.min.y, this._bb.max.z - this._bb.min.z);
1736
1571
  }
1737
1572
  };
1738
1573
 
1739
1574
  // src/scene/root/Root.ts
1740
- var DIVERoot = class extends Object3D11 {
1741
- get Floor() {
1742
- return this.floor;
1743
- }
1744
- get Grid() {
1745
- return this.grid;
1746
- }
1575
+ var DIVERoot = class extends Object3D8 {
1747
1576
  constructor() {
1748
1577
  super();
1578
+ this.isDIVERoot = true;
1749
1579
  this.name = "Root";
1750
- this.lightRoot = new DIVELightRoot();
1751
- this.add(this.lightRoot);
1752
- this.modelRoot = new DIVEModelRoot();
1753
- this.add(this.modelRoot);
1754
- this.primitiveRoot = new DIVEPrimitiveRoot();
1755
- this.add(this.primitiveRoot);
1756
- this.floor = new DIVEFloor();
1757
- this.add(this.floor);
1758
- this.grid = new DIVEGrid();
1759
- this.add(this.grid);
1580
+ this.loadingManager = new DIVELoadingManager();
1760
1581
  }
1761
1582
  ComputeSceneBB() {
1762
- const bb = new Box33();
1763
- this.modelRoot.traverse((object) => {
1764
- if ("isObject3D" in object) {
1765
- bb.expandByObject(object);
1766
- }
1767
- });
1768
- this.primitiveRoot.traverse((object) => {
1583
+ const bb = new Box34();
1584
+ this.traverse((object) => {
1769
1585
  if ("isObject3D" in object) {
1770
1586
  bb.expandByObject(object);
1771
1587
  }
@@ -1773,20 +1589,7 @@ var DIVERoot = class extends Object3D11 {
1773
1589
  return bb;
1774
1590
  }
1775
1591
  GetSceneObject(object) {
1776
- switch (object.entityType) {
1777
- case "pov": {
1778
- return void 0;
1779
- }
1780
- case "light": {
1781
- return this.lightRoot.GetLight(object);
1782
- }
1783
- case "model": {
1784
- return this.modelRoot.GetModel(object);
1785
- }
1786
- case "primitive": {
1787
- return this.primitiveRoot.GetPrimitive(object);
1788
- }
1789
- }
1592
+ return this.children.find((object3D) => object3D.userData.id === object.id);
1790
1593
  }
1791
1594
  AddSceneObject(object) {
1792
1595
  switch (object.entityType) {
@@ -1794,15 +1597,19 @@ var DIVERoot = class extends Object3D11 {
1794
1597
  break;
1795
1598
  }
1796
1599
  case "light": {
1797
- this.lightRoot.UpdateLight(object);
1600
+ this.updateLight(object);
1798
1601
  break;
1799
1602
  }
1800
1603
  case "model": {
1801
- this.modelRoot.UpdateModel(object);
1604
+ this.updateModel(object);
1802
1605
  break;
1803
1606
  }
1804
1607
  case "primitive": {
1805
- this.primitiveRoot.UpdatePrimitive(object);
1608
+ this.updatePrimitive(object);
1609
+ break;
1610
+ }
1611
+ case "group": {
1612
+ this.updateGroup(object);
1806
1613
  break;
1807
1614
  }
1808
1615
  }
@@ -1813,15 +1620,19 @@ var DIVERoot = class extends Object3D11 {
1813
1620
  break;
1814
1621
  }
1815
1622
  case "light": {
1816
- this.lightRoot.UpdateLight(object);
1623
+ this.updateLight(object);
1817
1624
  break;
1818
1625
  }
1819
1626
  case "model": {
1820
- this.modelRoot.UpdateModel(object);
1627
+ this.updateModel(object);
1821
1628
  break;
1822
1629
  }
1823
1630
  case "primitive": {
1824
- this.primitiveRoot.UpdatePrimitive(object);
1631
+ this.updatePrimitive(object);
1632
+ break;
1633
+ }
1634
+ case "group": {
1635
+ this.updateGroup(object);
1825
1636
  break;
1826
1637
  }
1827
1638
  }
@@ -1832,15 +1643,19 @@ var DIVERoot = class extends Object3D11 {
1832
1643
  break;
1833
1644
  }
1834
1645
  case "light": {
1835
- this.lightRoot.DeleteLight(object);
1646
+ this.deleteLight(object);
1836
1647
  break;
1837
1648
  }
1838
1649
  case "model": {
1839
- this.modelRoot.DeleteModel(object);
1650
+ this.deleteModel(object);
1840
1651
  break;
1841
1652
  }
1842
1653
  case "primitive": {
1843
- this.primitiveRoot.DeletePrimitive(object);
1654
+ this.deletePrimitive(object);
1655
+ break;
1656
+ }
1657
+ case "group": {
1658
+ this.deleteGroup(object);
1844
1659
  break;
1845
1660
  }
1846
1661
  }
@@ -1851,16 +1666,214 @@ var DIVERoot = class extends Object3D11 {
1851
1666
  case "light": {
1852
1667
  break;
1853
1668
  }
1854
- case "model": {
1855
- this.modelRoot.PlaceOnFloor(object);
1856
- break;
1857
- }
1669
+ case "model":
1858
1670
  case "primitive": {
1859
- this.primitiveRoot.PlaceOnFloor(object);
1671
+ this.placeOnFloor(object);
1860
1672
  break;
1861
1673
  }
1862
1674
  }
1863
1675
  }
1676
+ updateLight(light) {
1677
+ let sceneObject = this.GetSceneObject(light);
1678
+ if (!sceneObject) {
1679
+ switch (light.type) {
1680
+ case "scene": {
1681
+ sceneObject = new DIVESceneLight();
1682
+ break;
1683
+ }
1684
+ case "ambient": {
1685
+ sceneObject = new DIVEAmbientLight();
1686
+ break;
1687
+ }
1688
+ case "point": {
1689
+ sceneObject = new DIVEPointLight();
1690
+ break;
1691
+ }
1692
+ default: {
1693
+ console.warn(`Root.updateLight: Unknown light type: ${light.type}`);
1694
+ return;
1695
+ }
1696
+ }
1697
+ sceneObject.userData.id = light.id;
1698
+ this.add(sceneObject);
1699
+ }
1700
+ if (light.name !== void 0 && light.name !== null) sceneObject.name = light.name;
1701
+ if (light.position !== void 0 && light.position !== null) sceneObject.position.set(light.position.x, light.position.y, light.position.z);
1702
+ if (light.intensity !== void 0 && light.intensity !== null) sceneObject.SetIntensity(light.intensity);
1703
+ if (light.enabled !== void 0 && light.enabled !== null) sceneObject.SetEnabled(light.enabled);
1704
+ if (light.color !== void 0 && light.color !== null) sceneObject.SetColor(new Color5(light.color));
1705
+ if (light.visible !== void 0 && light.visible !== null) sceneObject.visible = light.visible;
1706
+ if (light.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, light), { parent: light.parent }));
1707
+ }
1708
+ updateModel(model) {
1709
+ let sceneObject = this.GetSceneObject(model);
1710
+ if (!sceneObject) {
1711
+ const created = new DIVEModel();
1712
+ sceneObject = created;
1713
+ sceneObject.userData.id = model.id;
1714
+ this.add(sceneObject);
1715
+ }
1716
+ if (model.uri !== void 0) {
1717
+ this.loadingManager.LoadGLTF(model.uri).then((gltf) => {
1718
+ var _a;
1719
+ sceneObject.SetModel(gltf);
1720
+ (_a = DIVECommunication.get(model.id)) == null ? void 0 : _a.PerformAction("MODEL_LOADED", { id: model.id });
1721
+ });
1722
+ }
1723
+ if (model.name !== void 0) sceneObject.name = model.name;
1724
+ if (model.position !== void 0) sceneObject.SetPosition(model.position);
1725
+ if (model.rotation !== void 0) sceneObject.SetRotation(model.rotation);
1726
+ if (model.scale !== void 0) sceneObject.SetScale(model.scale);
1727
+ if (model.visible !== void 0) sceneObject.SetVisibility(model.visible);
1728
+ if (model.material !== void 0) sceneObject.SetMaterial(model.material);
1729
+ if (model.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, model), { parent: model.parent }));
1730
+ }
1731
+ updatePrimitive(primitive) {
1732
+ let sceneObject = this.GetSceneObject(primitive);
1733
+ if (!sceneObject) {
1734
+ const created = new DIVEPrimitive();
1735
+ sceneObject = created;
1736
+ sceneObject.userData.id = primitive.id;
1737
+ this.add(sceneObject);
1738
+ }
1739
+ if (primitive.name !== void 0) sceneObject.name = primitive.name;
1740
+ if (primitive.geometry !== void 0) sceneObject.SetGeometry(primitive.geometry);
1741
+ if (primitive.position !== void 0) sceneObject.SetPosition(primitive.position);
1742
+ if (primitive.rotation !== void 0) sceneObject.SetRotation(primitive.rotation);
1743
+ if (primitive.scale !== void 0) sceneObject.SetScale(primitive.scale);
1744
+ if (primitive.visible !== void 0) sceneObject.SetVisibility(primitive.visible);
1745
+ if (primitive.material !== void 0) sceneObject.SetMaterial(primitive.material);
1746
+ if (primitive.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, primitive), { parent: primitive.parent }));
1747
+ }
1748
+ updateGroup(group) {
1749
+ let sceneObject = this.GetSceneObject(group);
1750
+ if (!sceneObject) {
1751
+ const created = new DIVEGroup();
1752
+ sceneObject = created;
1753
+ sceneObject.userData.id = group.id;
1754
+ this.add(sceneObject);
1755
+ }
1756
+ if (group.name !== void 0) sceneObject.name = group.name;
1757
+ if (group.position !== void 0) sceneObject.SetPosition(group.position);
1758
+ if (group.rotation !== void 0) sceneObject.SetRotation(group.rotation);
1759
+ if (group.scale !== void 0) sceneObject.SetScale(group.scale);
1760
+ if (group.visible !== void 0) sceneObject.SetVisibility(group.visible);
1761
+ if (group.bbVisible !== void 0) sceneObject.SetBoundingBoxVisibility(group.bbVisible);
1762
+ if (group.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, group), { parent: group.parent }));
1763
+ }
1764
+ deleteLight(light) {
1765
+ const sceneObject = this.GetSceneObject(light);
1766
+ if (!sceneObject) {
1767
+ console.warn(`Root.deleteLight: Light with id ${light.id} not found`);
1768
+ return;
1769
+ }
1770
+ this.detachTransformControls(sceneObject);
1771
+ this.remove(sceneObject);
1772
+ }
1773
+ deleteModel(model) {
1774
+ const sceneObject = this.GetSceneObject(model);
1775
+ if (!sceneObject) {
1776
+ console.warn(`Root.deleteModel: Model with id ${model.id} not found`);
1777
+ return;
1778
+ }
1779
+ this.detachTransformControls(sceneObject);
1780
+ this.remove(sceneObject);
1781
+ }
1782
+ deletePrimitive(primitive) {
1783
+ const sceneObject = this.GetSceneObject(primitive);
1784
+ if (!sceneObject) {
1785
+ console.warn(`Root.deletePrimitive: Primitive with id ${primitive.id} not found`);
1786
+ return;
1787
+ }
1788
+ this.detachTransformControls(sceneObject);
1789
+ this.remove(sceneObject);
1790
+ }
1791
+ deleteGroup(group) {
1792
+ const sceneObject = this.GetSceneObject(group);
1793
+ if (!sceneObject) {
1794
+ console.warn(`Root.deleteGroup: Group with id ${group.id} not found`);
1795
+ return;
1796
+ }
1797
+ this.detachTransformControls(sceneObject);
1798
+ for (let i = sceneObject.children.length - 1; i >= 0; i--) {
1799
+ this.attach(sceneObject.children[i]);
1800
+ }
1801
+ sceneObject.parent.remove(sceneObject);
1802
+ }
1803
+ placeOnFloor(object) {
1804
+ const sceneObject = this.GetSceneObject(object);
1805
+ if (!sceneObject) return;
1806
+ sceneObject.PlaceOnFloor();
1807
+ }
1808
+ setParent(object) {
1809
+ const sceneObject = this.GetSceneObject(object);
1810
+ if (!sceneObject) return;
1811
+ if (sceneObject.parent) {
1812
+ sceneObject.parent.remove(sceneObject);
1813
+ }
1814
+ if (object.parent !== null) {
1815
+ const parent = this.GetSceneObject(object.parent);
1816
+ if (!parent) return;
1817
+ parent.attach(sceneObject);
1818
+ } else {
1819
+ this.attach(sceneObject);
1820
+ }
1821
+ }
1822
+ detachTransformControls(object) {
1823
+ this.findScene(object).children.find((object2) => {
1824
+ if ("isTransformControls" in object2) {
1825
+ object2.detach();
1826
+ }
1827
+ });
1828
+ }
1829
+ findScene(object) {
1830
+ if (object.parent !== null) {
1831
+ return this.findScene(object.parent);
1832
+ }
1833
+ ;
1834
+ return object;
1835
+ }
1836
+ };
1837
+
1838
+ // src/constant/GridColors.ts
1839
+ var GRID_CENTER_LINE_COLOR = "#888888";
1840
+ var GRID_SIDE_LINE_COLOR = "#dddddd";
1841
+
1842
+ // src/grid/Grid.ts
1843
+ init_VisibilityLayerMask();
1844
+ import { GridHelper, Object3D as Object3D9 } from "three";
1845
+ var DIVEGrid = class extends Object3D9 {
1846
+ constructor() {
1847
+ super();
1848
+ this.name = "Grid";
1849
+ const grid = new GridHelper(100, 100, GRID_CENTER_LINE_COLOR, GRID_SIDE_LINE_COLOR);
1850
+ grid.material.depthTest = false;
1851
+ grid.layers.mask = HELPER_LAYER_MASK;
1852
+ this.add(grid);
1853
+ }
1854
+ SetVisibility(visible) {
1855
+ this.visible = visible;
1856
+ }
1857
+ };
1858
+
1859
+ // src/primitive/floor/Floor.ts
1860
+ init_VisibilityLayerMask();
1861
+ import { Color as Color6, Mesh as Mesh5, MeshStandardMaterial as MeshStandardMaterial3, PlaneGeometry } from "three";
1862
+ var DIVEFloor = class extends Mesh5 {
1863
+ constructor() {
1864
+ super(new PlaneGeometry(1e4, 1e4), new MeshStandardMaterial3({ color: new Color6(150 / 255, 150 / 255, 150 / 255) }));
1865
+ this.isFloor = true;
1866
+ this.name = "Floor";
1867
+ this.layers.mask = PRODUCT_LAYER_MASK;
1868
+ this.receiveShadow = true;
1869
+ this.rotateX(-Math.PI / 2);
1870
+ }
1871
+ SetVisibility(visible) {
1872
+ this.visible = visible;
1873
+ }
1874
+ SetColor(color) {
1875
+ this.material.color = new Color6(color);
1876
+ }
1864
1877
  };
1865
1878
 
1866
1879
  // src/scene/Scene.ts
@@ -1868,14 +1881,24 @@ var DIVEScene = class extends Scene2 {
1868
1881
  get Root() {
1869
1882
  return this.root;
1870
1883
  }
1884
+ get Floor() {
1885
+ return this.floor;
1886
+ }
1887
+ get Grid() {
1888
+ return this.grid;
1889
+ }
1871
1890
  constructor() {
1872
1891
  super();
1873
- this.background = new Color8(16777215);
1892
+ this.background = new Color7(16777215);
1874
1893
  this.root = new DIVERoot();
1875
1894
  this.add(this.root);
1895
+ this.floor = new DIVEFloor();
1896
+ this.add(this.floor);
1897
+ this.grid = new DIVEGrid();
1898
+ this.add(this.grid);
1876
1899
  }
1877
1900
  SetBackground(color) {
1878
- this.background = new Color8(color);
1901
+ this.background = new Color7(color);
1879
1902
  }
1880
1903
  ComputeSceneBB() {
1881
1904
  return this.Root.ComputeSceneBB();
@@ -1884,7 +1907,7 @@ var DIVEScene = class extends Scene2 {
1884
1907
  return this.Root.GetSceneObject(object);
1885
1908
  }
1886
1909
  AddSceneObject(object) {
1887
- this.Root.UpdateSceneObject(object);
1910
+ this.Root.AddSceneObject(object);
1888
1911
  }
1889
1912
  UpdateSceneObject(object) {
1890
1913
  this.Root.UpdateSceneObject(object);
@@ -1902,7 +1925,7 @@ init_PerspectiveCamera();
1902
1925
 
1903
1926
  // src/controls/OrbitControls.ts
1904
1927
  import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
1905
- import { MathUtils as MathUtils2, Vector3 as Vector34 } from "three";
1928
+ import { MathUtils as MathUtils2, Vector3 as Vector35 } from "three";
1906
1929
  import { Easing } from "@tweenjs/tween.js";
1907
1930
  var DIVEOrbitControlsDefaultSettings = {
1908
1931
  enableDamping: true,
@@ -1944,8 +1967,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends OrbitControls {
1944
1967
  this.dispose();
1945
1968
  }
1946
1969
  ComputeEncompassingView(bb) {
1947
- const center = bb.getCenter(new Vector34());
1948
- const size = bb.getSize(new Vector34());
1970
+ const center = bb.getCenter(new Vector35());
1971
+ const size = bb.getSize(new Vector35());
1949
1972
  const distance = Math.max(size.x, size.y, size.z) * 1.25;
1950
1973
  const direction = this.object.position.clone().normalize();
1951
1974
  return {
@@ -2113,7 +2136,7 @@ var DIVEAnimationSystem = class {
2113
2136
 
2114
2137
  // src/axiscamera/AxisCamera.ts
2115
2138
  init_VisibilityLayerMask();
2116
- import { AxesHelper, Color as Color9, Matrix4, OrthographicCamera, Vector4 } from "three";
2139
+ import { AxesHelper, Color as Color8, Matrix4, OrthographicCamera, Vector4 } from "three";
2117
2140
  import SpriteText from "three-spritetext";
2118
2141
 
2119
2142
  // src/constant/AxisHelperColors.ts
@@ -2134,9 +2157,9 @@ var DIVEAxisCamera = class extends OrthographicCamera {
2134
2157
  this.axesHelper.material.depthTest = false;
2135
2158
  this.axesHelper.position.set(0, 0, -1);
2136
2159
  this.axesHelper.setColors(
2137
- new Color9(AxesColorRed),
2138
- new Color9(AxesColorGreen),
2139
- new Color9(AxesColorBlue)
2160
+ new Color8(AxesColorRed),
2161
+ new Color8(AxesColorGreen),
2162
+ new Color8(AxesColorBlue)
2140
2163
  );
2141
2164
  const x = new SpriteText("X", 0.2, AxesColorRedLetter);
2142
2165
  const y = new SpriteText("Y", 0.2, AxesColorGreenLetter);
@@ -2237,58 +2260,6 @@ var getObjectDelta = (a, b) => {
2237
2260
  return delta;
2238
2261
  };
2239
2262
 
2240
- // src/math/helper/shift.ts
2241
- function shift(value, exponent) {
2242
- const subvalues = (value + "e").split("e");
2243
- return +(subvalues[0] + "e" + (+subvalues[1] + (exponent || 0)));
2244
- }
2245
-
2246
- // src/math/ceil/ceilExp.ts
2247
- function ceilExp(number, decimals = 0) {
2248
- const n = shift(number, +decimals);
2249
- return shift(Math.ceil(n), -decimals);
2250
- }
2251
-
2252
- // src/math/floor/floorExp.ts
2253
- function floorExp(number, decimals = 0) {
2254
- const n = shift(number, +decimals);
2255
- return shift(Math.floor(n), -decimals);
2256
- }
2257
-
2258
- // src/math/round/roundExp.ts
2259
- function roundExponential(number, decimals = 0) {
2260
- if (number < 0) return -roundExponential(-number, decimals);
2261
- const n = shift(number, +decimals);
2262
- return shift(Math.round(n), -decimals);
2263
- }
2264
-
2265
- // src/math/signedAngleTo/signedAngleTo.ts
2266
- function signedAngleTo(vecA, vecB, planeNormal) {
2267
- return Math.atan2(vecA.clone().cross(vecB).dot(planeNormal), vecB.clone().dot(vecA));
2268
- }
2269
-
2270
- // src/math/toFixed/toFixedExp.ts
2271
- function toFixedExp(number, decimals = 0) {
2272
- const n = shift(number, +decimals);
2273
- return shift(Math.round(n), -decimals).toFixed(decimals);
2274
- }
2275
-
2276
- // src/math/truncate/truncateExp.ts
2277
- function truncateExp(number, decimals = 0) {
2278
- const n = shift(number, +decimals);
2279
- return shift(Math.trunc(n), -decimals);
2280
- }
2281
-
2282
- // src/math/index.ts
2283
- var DIVEMath = {
2284
- ceilExp,
2285
- floorExp,
2286
- roundExp: roundExponential,
2287
- toFixedExp,
2288
- truncateExp,
2289
- signedAngleTo
2290
- };
2291
-
2292
2263
  // src/dive.ts
2293
2264
  import { generateUUID as generateUUID2 } from "three/src/math/MathUtils";
2294
2265
 
@@ -2389,6 +2360,58 @@ var DIVEInfo = class {
2389
2360
  };
2390
2361
  DIVEInfo._supportsWebXR = null;
2391
2362
 
2363
+ // src/math/helper/shift.ts
2364
+ function shift(value, exponent) {
2365
+ const subvalues = (value + "e").split("e");
2366
+ return +(subvalues[0] + "e" + (+subvalues[1] + (exponent || 0)));
2367
+ }
2368
+
2369
+ // src/math/ceil/ceilExp.ts
2370
+ function ceilExp(number, decimals = 0) {
2371
+ const n = shift(number, +decimals);
2372
+ return shift(Math.ceil(n), -decimals);
2373
+ }
2374
+
2375
+ // src/math/floor/floorExp.ts
2376
+ function floorExp(number, decimals = 0) {
2377
+ const n = shift(number, +decimals);
2378
+ return shift(Math.floor(n), -decimals);
2379
+ }
2380
+
2381
+ // src/math/round/roundExp.ts
2382
+ function roundExponential(number, decimals = 0) {
2383
+ if (number < 0) return -roundExponential(-number, decimals);
2384
+ const n = shift(number, +decimals);
2385
+ return shift(Math.round(n), -decimals);
2386
+ }
2387
+
2388
+ // src/math/signedAngleTo/signedAngleTo.ts
2389
+ function signedAngleTo(vecA, vecB, planeNormal) {
2390
+ return Math.atan2(vecA.clone().cross(vecB).dot(planeNormal), vecB.clone().dot(vecA));
2391
+ }
2392
+
2393
+ // src/math/toFixed/toFixedExp.ts
2394
+ function toFixedExp(number, decimals = 0) {
2395
+ const n = shift(number, +decimals);
2396
+ return shift(Math.round(n), -decimals).toFixed(decimals);
2397
+ }
2398
+
2399
+ // src/math/truncate/truncateExp.ts
2400
+ function truncateExp(number, decimals = 0) {
2401
+ const n = shift(number, +decimals);
2402
+ return shift(Math.trunc(n), -decimals);
2403
+ }
2404
+
2405
+ // src/math/index.ts
2406
+ var DIVEMath = {
2407
+ ceilExp,
2408
+ floorExp,
2409
+ roundExp: roundExponential,
2410
+ toFixedExp,
2411
+ truncateExp,
2412
+ signedAngleTo
2413
+ };
2414
+
2392
2415
  // src/dive.ts
2393
2416
  var DIVEDefaultSettings = {
2394
2417
  autoResize: true,