@shopware-ag/dive 1.12.1 → 1.14.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.
- package/build/dive.cjs +458 -405
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +314 -78
- package/build/dive.d.ts +314 -78
- package/build/dive.js +430 -377
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/__test__/DIVE.test.ts +33 -29
- package/src/axiscamera/AxisCamera.ts +1 -1
- package/src/axiscamera/__test__/AxisCamera.test.ts +1 -1
- package/src/com/Communication.ts +59 -14
- package/src/com/__test__/Communication.test.ts +111 -31
- package/src/com/actions/index.ts +2 -0
- package/src/com/actions/object/addobject.ts +1 -1
- package/src/com/actions/object/deleteobject.ts +1 -1
- package/src/com/actions/object/deselectobject.ts +1 -1
- package/src/com/actions/object/getallobjects.ts +1 -1
- package/src/com/actions/object/getobjects.ts +1 -1
- package/src/com/actions/object/selectobject.ts +1 -1
- package/src/com/actions/object/setparent.ts +9 -0
- package/src/com/actions/object/updateobject.ts +1 -1
- package/src/com/actions/scene/getallscenedata.ts +1 -1
- package/src/com/types/COMBaseEntity.ts +9 -0
- package/src/com/types/COMEntity.ts +7 -0
- package/src/com/types/COMEntityType.ts +1 -0
- package/src/com/types/COMGeometry.ts +6 -0
- package/src/com/types/COMGroup.ts +9 -0
- package/src/com/types/COMLight.ts +10 -0
- package/src/com/types/COMMaterial.ts +12 -0
- package/src/com/types/COMModel.ts +12 -0
- package/src/com/types/COMPov.ts +8 -0
- package/src/com/types/COMPrimitive.ts +12 -0
- package/src/com/types/index.ts +21 -0
- package/src/dive.ts +9 -16
- package/src/grid/Grid.ts +1 -1
- package/src/grid/__test__/Grid.test.ts +1 -1
- package/src/group/Group.ts +126 -0
- package/src/group/__test__/Group.test.ts +100 -0
- package/src/helper/findSceneRecursive/findSceneRecursive.ts +1 -1
- package/src/light/AmbientLight.ts +3 -0
- package/src/light/PointLight.ts +6 -3
- package/src/light/SceneLight.ts +2 -0
- package/src/light/__test__/PointLight.test.ts +8 -6
- package/src/light/__test__/SceneLight.test.ts +8 -6
- package/src/loadingmanager/LoadingManager.ts +1 -1
- package/src/loadingmanager/__test__/LoadingManager.test.ts +1 -1
- package/src/mediacreator/MediaCreator.ts +1 -1
- package/src/mediacreator/__test__/MediaCreator.test.ts +6 -4
- package/src/model/Model.ts +8 -7
- package/src/model/__test__/Model.test.ts +13 -10
- package/src/primitive/Primitive.ts +4 -3
- package/src/primitive/__test__/Primitive.test.ts +9 -7
- package/src/primitive/floor/Floor.ts +1 -1
- package/src/primitive/floor/__test__/Floor.test.ts +1 -1
- package/src/renderer/__test__/Renderer.test.ts +1 -1
- package/src/scene/Scene.ts +29 -9
- package/src/scene/__test__/Scene.test.ts +33 -19
- package/src/scene/root/Root.ts +239 -72
- package/src/scene/root/__test__/Root.test.ts +476 -114
- package/src/toolbox/BaseTool.ts +1 -1
- package/src/toolbox/Toolbox.ts +1 -1
- package/src/toolbox/__test__/BaseTool.test.ts +1 -1
- package/src/toolbox/__test__/Toolbox.test.ts +1 -1
- package/src/toolbox/select/SelectTool.ts +1 -1
- package/src/toolbox/select/__test__/SelectTool.test.ts +11 -9
- package/src/toolbox/transform/TransformTool.ts +1 -1
- package/src/toolbox/transform/__test__/TransformTool.test.ts +12 -10
- package/src/types/SceneObjects.ts +14 -0
- package/src/types/index.ts +5 -0
- package/src/com/index.ts +0 -3
- package/src/com/types.ts +0 -58
- package/src/scene/root/lightroot/LightRoot.ts +0 -99
- package/src/scene/root/lightroot/__test__/LightRoot.test.ts +0 -145
- package/src/scene/root/modelroot/ModelRoot.ts +0 -98
- package/src/scene/root/modelroot/__test__/ModelRoot.test.ts +0 -189
- package/src/scene/root/primitiveroot/PrimitiveRoot.ts +0 -88
- package/src/scene/root/primitiveroot/__test__/PrimitiveRoot.test.ts +0 -181
package/build/dive.cjs
CHANGED
|
@@ -671,13 +671,10 @@ var DIVERenderer = class extends import_three.WebGLRenderer {
|
|
|
671
671
|
};
|
|
672
672
|
|
|
673
673
|
// src/scene/Scene.ts
|
|
674
|
-
var
|
|
674
|
+
var import_three13 = require("three");
|
|
675
675
|
|
|
676
676
|
// src/scene/root/Root.ts
|
|
677
|
-
var
|
|
678
|
-
|
|
679
|
-
// src/scene/root/lightroot/LightRoot.ts
|
|
680
|
-
var import_three7 = require("three");
|
|
677
|
+
var import_three10 = require("three");
|
|
681
678
|
|
|
682
679
|
// src/light/AmbientLight.ts
|
|
683
680
|
var import_three2 = require("three");
|
|
@@ -685,6 +682,8 @@ init_VisibilityLayerMask();
|
|
|
685
682
|
var DIVEAmbientLight = class extends import_three2.Object3D {
|
|
686
683
|
constructor() {
|
|
687
684
|
super();
|
|
685
|
+
this.isDIVELight = true;
|
|
686
|
+
this.isDIVEAmbientLight = true;
|
|
688
687
|
this.name = "DIVEAmbientLight";
|
|
689
688
|
this._light = new import_three2.AmbientLight(16777215, 1);
|
|
690
689
|
this._light.layers.mask = PRODUCT_LAYER_MASK;
|
|
@@ -840,6 +839,10 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
840
839
|
returnValue = this.generateMedia(payload);
|
|
841
840
|
break;
|
|
842
841
|
}
|
|
842
|
+
case "SET_PARENT": {
|
|
843
|
+
returnValue = this.setParent(payload);
|
|
844
|
+
break;
|
|
845
|
+
}
|
|
843
846
|
}
|
|
844
847
|
this.dispatch(action, payload);
|
|
845
848
|
return returnValue;
|
|
@@ -866,8 +869,8 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
866
869
|
name: this.scene.name,
|
|
867
870
|
mediaItem: null,
|
|
868
871
|
backgroundColor: "#" + this.scene.background.getHexString(),
|
|
869
|
-
floorEnabled: this.scene.
|
|
870
|
-
floorColor: "#" + this.scene.
|
|
872
|
+
floorEnabled: this.scene.Floor.visible,
|
|
873
|
+
floorColor: "#" + this.scene.Floor.material.color.getHexString(),
|
|
871
874
|
userCamera: {
|
|
872
875
|
position: this.controller.object.position.clone(),
|
|
873
876
|
target: this.controller.target.clone()
|
|
@@ -895,6 +898,7 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
895
898
|
}
|
|
896
899
|
addObject(payload) {
|
|
897
900
|
if (this.registered.get(payload.id)) return false;
|
|
901
|
+
if (payload.parent === void 0) payload.parent = null;
|
|
898
902
|
this.registered.set(payload.id, payload);
|
|
899
903
|
this.scene.AddSceneObject(payload);
|
|
900
904
|
return true;
|
|
@@ -904,7 +908,7 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
904
908
|
if (!objectToUpdate) return false;
|
|
905
909
|
this.registered.set(payload.id, __spreadValues(__spreadValues({}, objectToUpdate), payload));
|
|
906
910
|
const updatedObject = this.registered.get(payload.id);
|
|
907
|
-
this.scene.UpdateSceneObject(updatedObject);
|
|
911
|
+
this.scene.UpdateSceneObject(__spreadProps(__spreadValues({}, payload), { id: updatedObject.id, entityType: updatedObject.entityType }));
|
|
908
912
|
Object.assign(payload, updatedObject);
|
|
909
913
|
return true;
|
|
910
914
|
}
|
|
@@ -1023,14 +1027,14 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
1023
1027
|
updateScene(payload) {
|
|
1024
1028
|
if (payload.name !== void 0) this.scene.name = payload.name;
|
|
1025
1029
|
if (payload.backgroundColor !== void 0) this.scene.SetBackground(payload.backgroundColor);
|
|
1026
|
-
if (payload.gridEnabled !== void 0) this.scene.
|
|
1027
|
-
if (payload.floorEnabled !== void 0) this.scene.
|
|
1028
|
-
if (payload.floorColor !== void 0) this.scene.
|
|
1030
|
+
if (payload.gridEnabled !== void 0) this.scene.Grid.SetVisibility(payload.gridEnabled);
|
|
1031
|
+
if (payload.floorEnabled !== void 0) this.scene.Floor.SetVisibility(payload.floorEnabled);
|
|
1032
|
+
if (payload.floorColor !== void 0) this.scene.Floor.SetColor(payload.floorColor);
|
|
1029
1033
|
payload.name = this.scene.name;
|
|
1030
1034
|
payload.backgroundColor = "#" + this.scene.background.getHexString();
|
|
1031
|
-
payload.gridEnabled = this.scene.
|
|
1032
|
-
payload.floorEnabled = this.scene.
|
|
1033
|
-
payload.floorColor = "#" + this.scene.
|
|
1035
|
+
payload.gridEnabled = this.scene.Grid.visible;
|
|
1036
|
+
payload.floorEnabled = this.scene.Floor.visible;
|
|
1037
|
+
payload.floorColor = "#" + this.scene.Floor.material.color.getHexString();
|
|
1034
1038
|
return true;
|
|
1035
1039
|
}
|
|
1036
1040
|
generateMedia(payload) {
|
|
@@ -1046,6 +1050,31 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
1046
1050
|
payload.dataUri = this.mediaGenerator.GenerateMedia(position, target, payload.width, payload.height);
|
|
1047
1051
|
return true;
|
|
1048
1052
|
}
|
|
1053
|
+
setParent(payload) {
|
|
1054
|
+
const object = this.registered.get(payload.object.id);
|
|
1055
|
+
if (!object) return false;
|
|
1056
|
+
const sceneObject = this.scene.GetSceneObject(object);
|
|
1057
|
+
if (!sceneObject) return false;
|
|
1058
|
+
if (payload.parent === null) {
|
|
1059
|
+
this.scene.Root.attach(sceneObject);
|
|
1060
|
+
return true;
|
|
1061
|
+
}
|
|
1062
|
+
if (payload.object.id === payload.parent.id) {
|
|
1063
|
+
return false;
|
|
1064
|
+
}
|
|
1065
|
+
const parent = this.registered.get(payload.parent.id);
|
|
1066
|
+
if (!parent) {
|
|
1067
|
+
this.scene.Root.attach(sceneObject);
|
|
1068
|
+
return true;
|
|
1069
|
+
}
|
|
1070
|
+
const parentObject = this.scene.GetSceneObject(parent);
|
|
1071
|
+
if (!parentObject) {
|
|
1072
|
+
this.scene.Root.attach(sceneObject);
|
|
1073
|
+
return true;
|
|
1074
|
+
}
|
|
1075
|
+
parentObject.attach(sceneObject);
|
|
1076
|
+
return true;
|
|
1077
|
+
}
|
|
1049
1078
|
};
|
|
1050
1079
|
_DIVECommunication.__instances = [];
|
|
1051
1080
|
var DIVECommunication = _DIVECommunication;
|
|
@@ -1055,6 +1084,8 @@ init_VisibilityLayerMask();
|
|
|
1055
1084
|
var DIVEPointLight = class extends import_three5.Object3D {
|
|
1056
1085
|
constructor() {
|
|
1057
1086
|
super();
|
|
1087
|
+
this.isDIVELight = true;
|
|
1088
|
+
this.isDIVEPointLight = true;
|
|
1058
1089
|
this.isMoveable = true;
|
|
1059
1090
|
this.isSelectable = true;
|
|
1060
1091
|
this.gizmo = null;
|
|
@@ -1103,6 +1134,8 @@ var import_three6 = require("three");
|
|
|
1103
1134
|
var DIVESceneLight = class extends import_three6.Object3D {
|
|
1104
1135
|
constructor() {
|
|
1105
1136
|
super();
|
|
1137
|
+
this.isDIVELight = true;
|
|
1138
|
+
this.isDIVESceneLight = true;
|
|
1106
1139
|
this.name = "DIVESceneLight";
|
|
1107
1140
|
this._hemiLight = new import_three6.HemisphereLight(16777215, 16777215, 2);
|
|
1108
1141
|
this._hemiLight.layers.mask = PRODUCT_LAYER_MASK;
|
|
@@ -1137,86 +1170,8 @@ var DIVESceneLight = class extends import_three6.Object3D {
|
|
|
1137
1170
|
}
|
|
1138
1171
|
};
|
|
1139
1172
|
|
|
1140
|
-
// src/scene/root/lightroot/LightRoot.ts
|
|
1141
|
-
var DIVELightRoot = class extends import_three7.Object3D {
|
|
1142
|
-
constructor() {
|
|
1143
|
-
super();
|
|
1144
|
-
this.name = "LightRoot";
|
|
1145
|
-
}
|
|
1146
|
-
GetLight(object) {
|
|
1147
|
-
if (object.id === void 0) {
|
|
1148
|
-
console.warn("LightRoot.GetLight: object.id is undefined");
|
|
1149
|
-
return void 0;
|
|
1150
|
-
}
|
|
1151
|
-
return this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1152
|
-
}
|
|
1153
|
-
UpdateLight(light) {
|
|
1154
|
-
if (light.id === void 0) {
|
|
1155
|
-
console.warn(`LightRoot.UpdateLight: light.id is undefined`);
|
|
1156
|
-
return;
|
|
1157
|
-
}
|
|
1158
|
-
let sceneObject = this.children.find((object3D) => object3D.userData.id === light.id);
|
|
1159
|
-
if (!sceneObject) {
|
|
1160
|
-
switch (light.type) {
|
|
1161
|
-
case "scene": {
|
|
1162
|
-
sceneObject = new DIVESceneLight();
|
|
1163
|
-
break;
|
|
1164
|
-
}
|
|
1165
|
-
case "ambient": {
|
|
1166
|
-
sceneObject = new DIVEAmbientLight();
|
|
1167
|
-
break;
|
|
1168
|
-
}
|
|
1169
|
-
case "point": {
|
|
1170
|
-
sceneObject = new DIVEPointLight();
|
|
1171
|
-
break;
|
|
1172
|
-
}
|
|
1173
|
-
default: {
|
|
1174
|
-
console.warn(`LightRoot.UpdateLight: Unknown light type: ${light.type}`);
|
|
1175
|
-
return;
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
sceneObject.userData.id = light.id;
|
|
1179
|
-
this.add(sceneObject);
|
|
1180
|
-
}
|
|
1181
|
-
if (light.name !== void 0 && light.name !== null) sceneObject.name = light.name;
|
|
1182
|
-
if (light.position !== void 0 && light.position !== null) sceneObject.position.set(light.position.x, light.position.y, light.position.z);
|
|
1183
|
-
if (light.intensity !== void 0 && light.intensity !== null) sceneObject.SetIntensity(light.intensity);
|
|
1184
|
-
if (light.enabled !== void 0 && light.enabled !== null) sceneObject.SetEnabled(light.enabled);
|
|
1185
|
-
if (light.color !== void 0 && light.color !== null) sceneObject.SetColor(new import_three7.Color(light.color));
|
|
1186
|
-
if (light.visible !== void 0 && light.visible !== null) sceneObject.visible = light.visible;
|
|
1187
|
-
}
|
|
1188
|
-
DeleteLight(light) {
|
|
1189
|
-
if (light.id === void 0) {
|
|
1190
|
-
console.warn("LightRoot.DeleteLight: light.id is undefined");
|
|
1191
|
-
return;
|
|
1192
|
-
}
|
|
1193
|
-
const sceneObject = this.children.find((object3D) => object3D.userData.id === light.id);
|
|
1194
|
-
if (!sceneObject) {
|
|
1195
|
-
console.warn(`LightRoot.DeleteLight: Light with id ${light.id} not found`);
|
|
1196
|
-
return;
|
|
1197
|
-
}
|
|
1198
|
-
const findScene = (object) => {
|
|
1199
|
-
if (object.parent !== null) {
|
|
1200
|
-
return findScene(object.parent);
|
|
1201
|
-
}
|
|
1202
|
-
;
|
|
1203
|
-
return object;
|
|
1204
|
-
};
|
|
1205
|
-
const scene = findScene(sceneObject);
|
|
1206
|
-
scene.children.find((object) => {
|
|
1207
|
-
if ("isTransformControls" in object) {
|
|
1208
|
-
object.detach();
|
|
1209
|
-
}
|
|
1210
|
-
});
|
|
1211
|
-
this.remove(sceneObject);
|
|
1212
|
-
}
|
|
1213
|
-
};
|
|
1214
|
-
|
|
1215
|
-
// src/scene/root/modelroot/ModelRoot.ts
|
|
1216
|
-
var import_three9 = require("three");
|
|
1217
|
-
|
|
1218
1173
|
// src/model/Model.ts
|
|
1219
|
-
var
|
|
1174
|
+
var import_three7 = require("three");
|
|
1220
1175
|
init_VisibilityLayerMask();
|
|
1221
1176
|
|
|
1222
1177
|
// src/helper/findSceneRecursive/findSceneRecursive.ts
|
|
@@ -1228,16 +1183,17 @@ var findSceneRecursive = (object) => {
|
|
|
1228
1183
|
};
|
|
1229
1184
|
|
|
1230
1185
|
// src/model/Model.ts
|
|
1231
|
-
var DIVEModel = class extends
|
|
1186
|
+
var DIVEModel = class extends import_three7.Object3D {
|
|
1232
1187
|
constructor() {
|
|
1233
1188
|
super();
|
|
1189
|
+
this.isDIVEModel = true;
|
|
1234
1190
|
this.isSelectable = true;
|
|
1235
1191
|
this.isMoveable = true;
|
|
1236
1192
|
this.gizmo = null;
|
|
1237
1193
|
this._mesh = null;
|
|
1238
1194
|
this._material = null;
|
|
1239
1195
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1240
|
-
this.boundingBox = new
|
|
1196
|
+
this.boundingBox = new import_three7.Box3();
|
|
1241
1197
|
}
|
|
1242
1198
|
SetModel(gltf) {
|
|
1243
1199
|
this.clear();
|
|
@@ -1261,7 +1217,7 @@ var DIVEModel = class extends import_three8.Object3D {
|
|
|
1261
1217
|
this.position.set(position.x, position.y, position.z);
|
|
1262
1218
|
}
|
|
1263
1219
|
SetRotation(rotation) {
|
|
1264
|
-
this.rotation.setFromVector3(new
|
|
1220
|
+
this.rotation.setFromVector3(new import_three7.Vector3(rotation.x, rotation.y, rotation.z));
|
|
1265
1221
|
}
|
|
1266
1222
|
SetScale(scale) {
|
|
1267
1223
|
this.scale.set(scale.x, scale.y, scale.z);
|
|
@@ -1273,13 +1229,13 @@ var DIVEModel = class extends import_three8.Object3D {
|
|
|
1273
1229
|
}
|
|
1274
1230
|
SetMaterial(material) {
|
|
1275
1231
|
if (!this._material) {
|
|
1276
|
-
this._material = new
|
|
1232
|
+
this._material = new import_three7.MeshStandardMaterial();
|
|
1277
1233
|
}
|
|
1278
1234
|
if (material.vertexColors !== void 0) {
|
|
1279
1235
|
this._material.vertexColors = material.vertexColors;
|
|
1280
1236
|
}
|
|
1281
1237
|
if (material.color !== void 0) {
|
|
1282
|
-
this._material.color
|
|
1238
|
+
this._material.color.set(material.color);
|
|
1283
1239
|
}
|
|
1284
1240
|
if (material.map !== void 0) {
|
|
1285
1241
|
this._material.map = material.map;
|
|
@@ -1307,7 +1263,6 @@ var DIVEModel = class extends import_three8.Object3D {
|
|
|
1307
1263
|
}
|
|
1308
1264
|
if (this._mesh) {
|
|
1309
1265
|
this._mesh.material = this._material;
|
|
1310
|
-
this._mesh.material.needsUpdate = true;
|
|
1311
1266
|
}
|
|
1312
1267
|
}
|
|
1313
1268
|
SetToWorldOrigin() {
|
|
@@ -1327,9 +1282,9 @@ var DIVEModel = class extends import_three8.Object3D {
|
|
|
1327
1282
|
return;
|
|
1328
1283
|
}
|
|
1329
1284
|
const bottomY = this.boundingBox.min.y * this.scale.y;
|
|
1330
|
-
const bbBottomCenter = this.localToWorld(this.boundingBox.getCenter(new
|
|
1285
|
+
const bbBottomCenter = this.localToWorld(this.boundingBox.getCenter(new import_three7.Vector3()).multiply(this.scale));
|
|
1331
1286
|
bbBottomCenter.y = bottomY + this.position.y;
|
|
1332
|
-
const raycaster = new
|
|
1287
|
+
const raycaster = new import_three7.Raycaster(bbBottomCenter, new import_three7.Vector3(0, -1, 0));
|
|
1333
1288
|
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1334
1289
|
const intersections = raycaster.intersectObjects(findSceneRecursive(this).Root.children, true);
|
|
1335
1290
|
if (intersections.length > 0) {
|
|
@@ -1338,7 +1293,7 @@ var DIVEModel = class extends import_three8.Object3D {
|
|
|
1338
1293
|
const meshBB = mesh.geometry.boundingBox;
|
|
1339
1294
|
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1340
1295
|
const oldPos = this.position.clone();
|
|
1341
|
-
const newPos = this.position.clone().setY(worldPos.y).sub(new
|
|
1296
|
+
const newPos = this.position.clone().setY(worldPos.y).sub(new import_three7.Vector3(0, bottomY, 0));
|
|
1342
1297
|
this.position.copy(newPos);
|
|
1343
1298
|
if (this.position.y === oldPos.y) return;
|
|
1344
1299
|
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position, rotation: this.rotation, scale: this.scale });
|
|
@@ -1390,96 +1345,24 @@ var DIVELoadingManager = class {
|
|
|
1390
1345
|
}
|
|
1391
1346
|
};
|
|
1392
1347
|
|
|
1393
|
-
// src/scene/root/modelroot/ModelRoot.ts
|
|
1394
|
-
var DIVEModelRoot = class extends import_three9.Object3D {
|
|
1395
|
-
constructor() {
|
|
1396
|
-
super();
|
|
1397
|
-
this.name = "ModelRoot";
|
|
1398
|
-
this.loadingManager = new DIVELoadingManager();
|
|
1399
|
-
}
|
|
1400
|
-
GetModel(object) {
|
|
1401
|
-
if (object.id === void 0) {
|
|
1402
|
-
console.warn("ModelRoot.GetModel: object.id is undefined");
|
|
1403
|
-
return void 0;
|
|
1404
|
-
}
|
|
1405
|
-
return this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1406
|
-
}
|
|
1407
|
-
UpdateModel(object) {
|
|
1408
|
-
if (object.id === void 0) {
|
|
1409
|
-
console.warn("ModelRoot.UpdateModel: object.id is undefined");
|
|
1410
|
-
return;
|
|
1411
|
-
}
|
|
1412
|
-
let sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1413
|
-
if (!sceneObject && object.uri !== void 0) {
|
|
1414
|
-
const model = new DIVEModel();
|
|
1415
|
-
sceneObject = model;
|
|
1416
|
-
sceneObject.userData.id = object.id;
|
|
1417
|
-
this.add(sceneObject);
|
|
1418
|
-
this.loadingManager.LoadGLTF(object.uri).then((gltf) => {
|
|
1419
|
-
var _a;
|
|
1420
|
-
model.SetModel(gltf);
|
|
1421
|
-
(_a = DIVECommunication.get(object.id)) == null ? void 0 : _a.PerformAction("MODEL_LOADED", { id: object.id });
|
|
1422
|
-
});
|
|
1423
|
-
}
|
|
1424
|
-
if (object.position !== void 0) sceneObject.SetPosition(object.position);
|
|
1425
|
-
if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
|
|
1426
|
-
if (object.scale !== void 0) sceneObject.SetScale(object.scale);
|
|
1427
|
-
if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
|
|
1428
|
-
if (object.material !== void 0) sceneObject.SetMaterial(object.material);
|
|
1429
|
-
}
|
|
1430
|
-
DeleteModel(object) {
|
|
1431
|
-
if (object.id === void 0) {
|
|
1432
|
-
console.warn(`ModelRoot.DeleteModel: object.id is undefined`);
|
|
1433
|
-
return;
|
|
1434
|
-
}
|
|
1435
|
-
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1436
|
-
if (!sceneObject) {
|
|
1437
|
-
console.warn(`ModelRoot.DeleteModel: Model with id ${object.id} not found`);
|
|
1438
|
-
return;
|
|
1439
|
-
}
|
|
1440
|
-
const findScene = (object2) => {
|
|
1441
|
-
if (object2.parent !== null) {
|
|
1442
|
-
return findScene(object2.parent);
|
|
1443
|
-
}
|
|
1444
|
-
;
|
|
1445
|
-
return object2;
|
|
1446
|
-
};
|
|
1447
|
-
const scene = findScene(sceneObject);
|
|
1448
|
-
scene.children.find((object2) => {
|
|
1449
|
-
if ("isTransformControls" in object2) {
|
|
1450
|
-
object2.detach();
|
|
1451
|
-
}
|
|
1452
|
-
});
|
|
1453
|
-
this.remove(sceneObject);
|
|
1454
|
-
}
|
|
1455
|
-
PlaceOnFloor(object) {
|
|
1456
|
-
if (object.id === void 0) console.warn("ModelRoot.PlaceOnFloor: object.id is undefined");
|
|
1457
|
-
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1458
|
-
if (!sceneObject) return;
|
|
1459
|
-
sceneObject.PlaceOnFloor();
|
|
1460
|
-
}
|
|
1461
|
-
};
|
|
1462
|
-
|
|
1463
|
-
// src/scene/root/primitiveroot/PrimitiveRoot.ts
|
|
1464
|
-
var import_three11 = require("three");
|
|
1465
|
-
|
|
1466
1348
|
// src/primitive/Primitive.ts
|
|
1467
|
-
var
|
|
1349
|
+
var import_three8 = require("three");
|
|
1468
1350
|
init_VisibilityLayerMask();
|
|
1469
|
-
var DIVEPrimitive = class extends
|
|
1351
|
+
var DIVEPrimitive = class extends import_three8.Object3D {
|
|
1470
1352
|
constructor() {
|
|
1471
1353
|
super();
|
|
1354
|
+
this.isDIVEPrimitive = true;
|
|
1472
1355
|
this.isSelectable = true;
|
|
1473
1356
|
this.isMoveable = true;
|
|
1474
1357
|
this.gizmo = null;
|
|
1475
1358
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1476
|
-
this._mesh = new
|
|
1359
|
+
this._mesh = new import_three8.Mesh();
|
|
1477
1360
|
this._mesh.layers.mask = PRODUCT_LAYER_MASK;
|
|
1478
1361
|
this._mesh.castShadow = true;
|
|
1479
1362
|
this._mesh.receiveShadow = true;
|
|
1480
|
-
this._mesh.material = new
|
|
1363
|
+
this._mesh.material = new import_three8.MeshStandardMaterial();
|
|
1481
1364
|
this.add(this._mesh);
|
|
1482
|
-
this._boundingBox = new
|
|
1365
|
+
this._boundingBox = new import_three8.Box3();
|
|
1483
1366
|
}
|
|
1484
1367
|
SetGeometry(geometry) {
|
|
1485
1368
|
this._mesh.geometry = this.assembleGeometry(geometry);
|
|
@@ -1489,7 +1372,7 @@ var DIVEPrimitive = class extends import_three10.Object3D {
|
|
|
1489
1372
|
this.position.set(position.x, position.y, position.z);
|
|
1490
1373
|
}
|
|
1491
1374
|
SetRotation(rotation) {
|
|
1492
|
-
this.rotation.setFromVector3(new
|
|
1375
|
+
this.rotation.setFromVector3(new import_three8.Vector3(rotation.x, rotation.y, rotation.z));
|
|
1493
1376
|
}
|
|
1494
1377
|
SetScale(scale) {
|
|
1495
1378
|
this.scale.set(scale.x, scale.y, scale.z);
|
|
@@ -1505,7 +1388,7 @@ var DIVEPrimitive = class extends import_three10.Object3D {
|
|
|
1505
1388
|
primitiveMaterial.vertexColors = material.vertexColors;
|
|
1506
1389
|
}
|
|
1507
1390
|
if (material.color !== void 0) {
|
|
1508
|
-
primitiveMaterial.color = new
|
|
1391
|
+
primitiveMaterial.color = new import_three8.Color(material.color);
|
|
1509
1392
|
}
|
|
1510
1393
|
if (material.map !== void 0) {
|
|
1511
1394
|
primitiveMaterial.map = material.map;
|
|
@@ -1550,9 +1433,9 @@ var DIVEPrimitive = class extends import_three10.Object3D {
|
|
|
1550
1433
|
return;
|
|
1551
1434
|
}
|
|
1552
1435
|
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1553
|
-
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new
|
|
1436
|
+
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new import_three8.Vector3()).multiply(this.scale));
|
|
1554
1437
|
bbBottomCenter.y = bottomY + this.position.y;
|
|
1555
|
-
const raycaster = new
|
|
1438
|
+
const raycaster = new import_three8.Raycaster(bbBottomCenter, new import_three8.Vector3(0, -1, 0));
|
|
1556
1439
|
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1557
1440
|
const intersections = raycaster.intersectObjects(findSceneRecursive(this).Root.children, true);
|
|
1558
1441
|
if (intersections.length > 0) {
|
|
@@ -1561,7 +1444,7 @@ var DIVEPrimitive = class extends import_three10.Object3D {
|
|
|
1561
1444
|
const meshBB = mesh.geometry.boundingBox;
|
|
1562
1445
|
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1563
1446
|
const oldPos = this.position.clone();
|
|
1564
|
-
const newPos = this.position.clone().setY(worldPos.y).sub(new
|
|
1447
|
+
const newPos = this.position.clone().setY(worldPos.y).sub(new import_three8.Vector3(0, bottomY, 0));
|
|
1565
1448
|
this.position.copy(newPos);
|
|
1566
1449
|
if (this.position.y === oldPos.y) return;
|
|
1567
1450
|
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position, rotation: this.rotation, scale: this.scale });
|
|
@@ -1596,182 +1479,145 @@ var DIVEPrimitive = class extends import_three10.Object3D {
|
|
|
1596
1479
|
case "plane":
|
|
1597
1480
|
return this.createPlaneGeometry(geometry);
|
|
1598
1481
|
default:
|
|
1599
|
-
return new
|
|
1482
|
+
return new import_three8.BufferGeometry();
|
|
1600
1483
|
}
|
|
1601
1484
|
}
|
|
1602
1485
|
createCylinderGeometry(geometry) {
|
|
1603
|
-
const geo = new
|
|
1486
|
+
const geo = new import_three8.CylinderGeometry(geometry.width / 2, geometry.width / 2, geometry.height, 64);
|
|
1604
1487
|
geo.translate(0, geometry.height / 2, 0);
|
|
1605
1488
|
return geo;
|
|
1606
1489
|
}
|
|
1607
1490
|
createSphereGeometry(geometry) {
|
|
1608
|
-
const geo = new
|
|
1491
|
+
const geo = new import_three8.SphereGeometry(geometry.width / 2, 256, 256);
|
|
1609
1492
|
return geo;
|
|
1610
1493
|
}
|
|
1611
1494
|
createPyramidGeometry(geometry) {
|
|
1612
|
-
const geo = new
|
|
1495
|
+
const geo = new import_three8.ConeGeometry(geometry.width / 2, geometry.height, 4, 1, true);
|
|
1613
1496
|
geo.rotateY(Math.PI / 4);
|
|
1614
1497
|
geo.translate(0, geometry.height / 2, 0);
|
|
1615
1498
|
return geo;
|
|
1616
1499
|
}
|
|
1617
1500
|
createBoxGeometry(geometry) {
|
|
1618
|
-
const geo = new
|
|
1501
|
+
const geo = new import_three8.BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1619
1502
|
geo.translate(0, geometry.height / 2, 0);
|
|
1620
1503
|
return geo;
|
|
1621
1504
|
}
|
|
1622
1505
|
createConeGeometry(geometry) {
|
|
1623
|
-
const geo = new
|
|
1506
|
+
const geo = new import_three8.ConeGeometry(geometry.width / 2, geometry.height, 256);
|
|
1624
1507
|
geo.translate(0, geometry.height / 2, 0);
|
|
1625
1508
|
return geo;
|
|
1626
1509
|
}
|
|
1627
1510
|
createWallGeometry(geometry) {
|
|
1628
|
-
const geo = new
|
|
1511
|
+
const geo = new import_three8.BoxGeometry(geometry.width, geometry.height, geometry.depth || 0.05, 16);
|
|
1629
1512
|
geo.translate(0, geometry.height / 2, 0);
|
|
1630
1513
|
return geo;
|
|
1631
1514
|
}
|
|
1632
1515
|
createPlaneGeometry(geometry) {
|
|
1633
|
-
const geo = new
|
|
1516
|
+
const geo = new import_three8.BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1634
1517
|
geo.translate(0, geometry.height / 2, 0);
|
|
1635
1518
|
return geo;
|
|
1636
1519
|
}
|
|
1637
1520
|
};
|
|
1638
1521
|
|
|
1639
|
-
// src/
|
|
1640
|
-
var
|
|
1522
|
+
// src/group/Group.ts
|
|
1523
|
+
var import_three9 = require("three");
|
|
1524
|
+
var DIVEGroup = class extends import_three9.Object3D {
|
|
1641
1525
|
constructor() {
|
|
1642
1526
|
super();
|
|
1643
|
-
this.
|
|
1527
|
+
this.isDIVEGroup = true;
|
|
1528
|
+
this.isSelectable = true;
|
|
1529
|
+
this.isMoveable = true;
|
|
1530
|
+
this.name = "DIVEGroup";
|
|
1531
|
+
this._bb = new import_three9.Box3();
|
|
1532
|
+
this._boxMesh = new import_three9.Mesh(new import_three9.BoxGeometry(0, 0, 0), new import_three9.MeshBasicMaterial({ color: 16711680, wireframe: true }));
|
|
1533
|
+
this._boxMesh.visible = false;
|
|
1534
|
+
this.add(this._boxMesh);
|
|
1644
1535
|
}
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
console.warn("PrimitiveRoot.GetPrimitive: object.id is undefined");
|
|
1648
|
-
return void 0;
|
|
1649
|
-
}
|
|
1650
|
-
return this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1536
|
+
SetPosition(position) {
|
|
1537
|
+
this.position.set(position.x, position.y, position.z);
|
|
1651
1538
|
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
console.warn("PrimitiveRoot.UpdatePrimitive: object.id is undefined");
|
|
1655
|
-
return;
|
|
1656
|
-
}
|
|
1657
|
-
let sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1658
|
-
if (!sceneObject && object.geometry !== void 0) {
|
|
1659
|
-
const primitive = new DIVEPrimitive();
|
|
1660
|
-
primitive.SetGeometry(object.geometry);
|
|
1661
|
-
sceneObject = primitive;
|
|
1662
|
-
sceneObject.userData.id = object.id;
|
|
1663
|
-
this.add(sceneObject);
|
|
1664
|
-
}
|
|
1665
|
-
if (object.position !== void 0) sceneObject.SetPosition(object.position);
|
|
1666
|
-
if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
|
|
1667
|
-
if (object.scale !== void 0) sceneObject.SetScale(object.scale);
|
|
1668
|
-
if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
|
|
1669
|
-
if (object.material !== void 0) sceneObject.SetMaterial(object.material);
|
|
1539
|
+
SetRotation(rotation) {
|
|
1540
|
+
this.rotation.setFromVector3(new import_three9.Vector3(rotation.x, rotation.y, rotation.z));
|
|
1670
1541
|
}
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
console.warn(`PrimitiveRoot.DeletePrimitive: Primitive with id ${object.id} not found`);
|
|
1679
|
-
return;
|
|
1680
|
-
}
|
|
1681
|
-
const findScene = (object2) => {
|
|
1682
|
-
if (object2.parent !== null) {
|
|
1683
|
-
return findScene(object2.parent);
|
|
1684
|
-
}
|
|
1685
|
-
;
|
|
1686
|
-
return object2;
|
|
1687
|
-
};
|
|
1688
|
-
const scene = findScene(sceneObject);
|
|
1689
|
-
scene.children.find((object2) => {
|
|
1690
|
-
if ("isTransformControls" in object2) {
|
|
1691
|
-
object2.detach();
|
|
1692
|
-
}
|
|
1542
|
+
SetScale(scale) {
|
|
1543
|
+
this.scale.set(scale.x, scale.y, scale.z);
|
|
1544
|
+
}
|
|
1545
|
+
SetVisibility(visible) {
|
|
1546
|
+
this.traverse((child) => {
|
|
1547
|
+
if (child.uuid === this._boxMesh.uuid) return;
|
|
1548
|
+
child.visible = visible;
|
|
1693
1549
|
});
|
|
1694
|
-
this.remove(sceneObject);
|
|
1695
1550
|
}
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1699
|
-
if (!sceneObject) return;
|
|
1700
|
-
sceneObject.PlaceOnFloor();
|
|
1551
|
+
SetBoundingBoxVisibility(visible) {
|
|
1552
|
+
this._boxMesh.visible = visible;
|
|
1701
1553
|
}
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
var DIVEFloor = class extends import_three12.Mesh {
|
|
1708
|
-
constructor() {
|
|
1709
|
-
super(new import_three12.PlaneGeometry(1e4, 1e4), new import_three12.MeshStandardMaterial({ color: new import_three12.Color(150 / 255, 150 / 255, 150 / 255) }));
|
|
1710
|
-
this.isFloor = true;
|
|
1711
|
-
this.name = "Floor";
|
|
1712
|
-
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1713
|
-
this.receiveShadow = true;
|
|
1714
|
-
this.rotateX(-Math.PI / 2);
|
|
1554
|
+
attach(object) {
|
|
1555
|
+
super.attach(object);
|
|
1556
|
+
this.recalculatePosition();
|
|
1557
|
+
this.updateBoxMesh();
|
|
1558
|
+
return this;
|
|
1715
1559
|
}
|
|
1716
|
-
|
|
1717
|
-
|
|
1560
|
+
remove(object) {
|
|
1561
|
+
super.remove(object);
|
|
1562
|
+
this.recalculatePosition();
|
|
1563
|
+
this.updateBoxMesh();
|
|
1564
|
+
return this;
|
|
1718
1565
|
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1566
|
+
/**
|
|
1567
|
+
* Recalculates the position of the group based on it's bounding box.
|
|
1568
|
+
* Children's world positions are kept.
|
|
1569
|
+
*/
|
|
1570
|
+
recalculatePosition() {
|
|
1571
|
+
var _a;
|
|
1572
|
+
const childrensWorldPositions = this.children.map((child) => child.getWorldPosition(new import_three9.Vector3()));
|
|
1573
|
+
const bbcenter = this.updateBB();
|
|
1574
|
+
this.position.copy(bbcenter);
|
|
1575
|
+
this.children.forEach((child, i) => {
|
|
1576
|
+
if (child.uuid === this._boxMesh.uuid) return;
|
|
1577
|
+
child.position.copy(this.worldToLocal(childrensWorldPositions[i]));
|
|
1578
|
+
});
|
|
1579
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position });
|
|
1721
1580
|
}
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
super();
|
|
1734
|
-
this.name = "Grid";
|
|
1735
|
-
const grid = new import_three13.GridHelper(100, 100, GRID_CENTER_LINE_COLOR, GRID_SIDE_LINE_COLOR);
|
|
1736
|
-
grid.material.depthTest = false;
|
|
1737
|
-
grid.layers.mask = HELPER_LAYER_MASK;
|
|
1738
|
-
this.add(grid);
|
|
1581
|
+
/**
|
|
1582
|
+
* Updates the bounding box of the group.
|
|
1583
|
+
* @returns {Vector3} The new center of the bounding box.
|
|
1584
|
+
*/
|
|
1585
|
+
updateBB() {
|
|
1586
|
+
this._bb.makeEmpty();
|
|
1587
|
+
this.children.forEach((child) => {
|
|
1588
|
+
if (child.uuid === this._boxMesh.uuid) return;
|
|
1589
|
+
this._bb.expandByObject(child);
|
|
1590
|
+
});
|
|
1591
|
+
return this._bb.getCenter(new import_three9.Vector3());
|
|
1739
1592
|
}
|
|
1740
|
-
|
|
1741
|
-
this.
|
|
1593
|
+
updateBoxMesh() {
|
|
1594
|
+
this._boxMesh.geometry = new import_three9.BoxGeometry(this._bb.max.x - this._bb.min.x, this._bb.max.y - this._bb.min.y, this._bb.max.z - this._bb.min.z);
|
|
1595
|
+
}
|
|
1596
|
+
onMove() {
|
|
1597
|
+
var _a;
|
|
1598
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position, rotation: this.rotation, scale: this.scale });
|
|
1599
|
+
}
|
|
1600
|
+
onSelect() {
|
|
1601
|
+
var _a;
|
|
1602
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1603
|
+
}
|
|
1604
|
+
onDeselect() {
|
|
1605
|
+
var _a;
|
|
1606
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1742
1607
|
}
|
|
1743
1608
|
};
|
|
1744
1609
|
|
|
1745
1610
|
// src/scene/root/Root.ts
|
|
1746
|
-
var DIVERoot = class extends
|
|
1747
|
-
get Floor() {
|
|
1748
|
-
return this.floor;
|
|
1749
|
-
}
|
|
1750
|
-
get Grid() {
|
|
1751
|
-
return this.grid;
|
|
1752
|
-
}
|
|
1611
|
+
var DIVERoot = class extends import_three10.Object3D {
|
|
1753
1612
|
constructor() {
|
|
1754
1613
|
super();
|
|
1614
|
+
this.isDIVERoot = true;
|
|
1755
1615
|
this.name = "Root";
|
|
1756
|
-
this.
|
|
1757
|
-
this.add(this.lightRoot);
|
|
1758
|
-
this.modelRoot = new DIVEModelRoot();
|
|
1759
|
-
this.add(this.modelRoot);
|
|
1760
|
-
this.primitiveRoot = new DIVEPrimitiveRoot();
|
|
1761
|
-
this.add(this.primitiveRoot);
|
|
1762
|
-
this.floor = new DIVEFloor();
|
|
1763
|
-
this.add(this.floor);
|
|
1764
|
-
this.grid = new DIVEGrid();
|
|
1765
|
-
this.add(this.grid);
|
|
1616
|
+
this.loadingManager = new DIVELoadingManager();
|
|
1766
1617
|
}
|
|
1767
1618
|
ComputeSceneBB() {
|
|
1768
|
-
const bb = new
|
|
1769
|
-
this.
|
|
1770
|
-
if ("isObject3D" in object) {
|
|
1771
|
-
bb.expandByObject(object);
|
|
1772
|
-
}
|
|
1773
|
-
});
|
|
1774
|
-
this.primitiveRoot.traverse((object) => {
|
|
1619
|
+
const bb = new import_three10.Box3();
|
|
1620
|
+
this.traverse((object) => {
|
|
1775
1621
|
if ("isObject3D" in object) {
|
|
1776
1622
|
bb.expandByObject(object);
|
|
1777
1623
|
}
|
|
@@ -1779,20 +1625,7 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1779
1625
|
return bb;
|
|
1780
1626
|
}
|
|
1781
1627
|
GetSceneObject(object) {
|
|
1782
|
-
|
|
1783
|
-
case "pov": {
|
|
1784
|
-
return void 0;
|
|
1785
|
-
}
|
|
1786
|
-
case "light": {
|
|
1787
|
-
return this.lightRoot.GetLight(object);
|
|
1788
|
-
}
|
|
1789
|
-
case "model": {
|
|
1790
|
-
return this.modelRoot.GetModel(object);
|
|
1791
|
-
}
|
|
1792
|
-
case "primitive": {
|
|
1793
|
-
return this.primitiveRoot.GetPrimitive(object);
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1628
|
+
return this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1796
1629
|
}
|
|
1797
1630
|
AddSceneObject(object) {
|
|
1798
1631
|
switch (object.entityType) {
|
|
@@ -1800,15 +1633,19 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1800
1633
|
break;
|
|
1801
1634
|
}
|
|
1802
1635
|
case "light": {
|
|
1803
|
-
this.
|
|
1636
|
+
this.updateLight(object);
|
|
1804
1637
|
break;
|
|
1805
1638
|
}
|
|
1806
1639
|
case "model": {
|
|
1807
|
-
this.
|
|
1640
|
+
this.updateModel(object);
|
|
1808
1641
|
break;
|
|
1809
1642
|
}
|
|
1810
1643
|
case "primitive": {
|
|
1811
|
-
this.
|
|
1644
|
+
this.updatePrimitive(object);
|
|
1645
|
+
break;
|
|
1646
|
+
}
|
|
1647
|
+
case "group": {
|
|
1648
|
+
this.updateGroup(object);
|
|
1812
1649
|
break;
|
|
1813
1650
|
}
|
|
1814
1651
|
}
|
|
@@ -1819,15 +1656,19 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1819
1656
|
break;
|
|
1820
1657
|
}
|
|
1821
1658
|
case "light": {
|
|
1822
|
-
this.
|
|
1659
|
+
this.updateLight(object);
|
|
1823
1660
|
break;
|
|
1824
1661
|
}
|
|
1825
1662
|
case "model": {
|
|
1826
|
-
this.
|
|
1663
|
+
this.updateModel(object);
|
|
1827
1664
|
break;
|
|
1828
1665
|
}
|
|
1829
1666
|
case "primitive": {
|
|
1830
|
-
this.
|
|
1667
|
+
this.updatePrimitive(object);
|
|
1668
|
+
break;
|
|
1669
|
+
}
|
|
1670
|
+
case "group": {
|
|
1671
|
+
this.updateGroup(object);
|
|
1831
1672
|
break;
|
|
1832
1673
|
}
|
|
1833
1674
|
}
|
|
@@ -1838,15 +1679,19 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1838
1679
|
break;
|
|
1839
1680
|
}
|
|
1840
1681
|
case "light": {
|
|
1841
|
-
this.
|
|
1682
|
+
this.deleteLight(object);
|
|
1842
1683
|
break;
|
|
1843
1684
|
}
|
|
1844
1685
|
case "model": {
|
|
1845
|
-
this.
|
|
1686
|
+
this.deleteModel(object);
|
|
1846
1687
|
break;
|
|
1847
1688
|
}
|
|
1848
1689
|
case "primitive": {
|
|
1849
|
-
this.
|
|
1690
|
+
this.deletePrimitive(object);
|
|
1691
|
+
break;
|
|
1692
|
+
}
|
|
1693
|
+
case "group": {
|
|
1694
|
+
this.deleteGroup(object);
|
|
1850
1695
|
break;
|
|
1851
1696
|
}
|
|
1852
1697
|
}
|
|
@@ -1857,31 +1702,239 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1857
1702
|
case "light": {
|
|
1858
1703
|
break;
|
|
1859
1704
|
}
|
|
1860
|
-
case "model":
|
|
1861
|
-
this.modelRoot.PlaceOnFloor(object);
|
|
1862
|
-
break;
|
|
1863
|
-
}
|
|
1705
|
+
case "model":
|
|
1864
1706
|
case "primitive": {
|
|
1865
|
-
this.
|
|
1707
|
+
this.placeOnFloor(object);
|
|
1866
1708
|
break;
|
|
1867
1709
|
}
|
|
1868
1710
|
}
|
|
1869
1711
|
}
|
|
1712
|
+
updateLight(light) {
|
|
1713
|
+
let sceneObject = this.GetSceneObject(light);
|
|
1714
|
+
if (!sceneObject) {
|
|
1715
|
+
switch (light.type) {
|
|
1716
|
+
case "scene": {
|
|
1717
|
+
sceneObject = new DIVESceneLight();
|
|
1718
|
+
break;
|
|
1719
|
+
}
|
|
1720
|
+
case "ambient": {
|
|
1721
|
+
sceneObject = new DIVEAmbientLight();
|
|
1722
|
+
break;
|
|
1723
|
+
}
|
|
1724
|
+
case "point": {
|
|
1725
|
+
sceneObject = new DIVEPointLight();
|
|
1726
|
+
break;
|
|
1727
|
+
}
|
|
1728
|
+
default: {
|
|
1729
|
+
console.warn(`Root.updateLight: Unknown light type: ${light.type}`);
|
|
1730
|
+
return;
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
sceneObject.userData.id = light.id;
|
|
1734
|
+
this.add(sceneObject);
|
|
1735
|
+
}
|
|
1736
|
+
if (light.name !== void 0 && light.name !== null) sceneObject.name = light.name;
|
|
1737
|
+
if (light.position !== void 0 && light.position !== null) sceneObject.position.set(light.position.x, light.position.y, light.position.z);
|
|
1738
|
+
if (light.intensity !== void 0 && light.intensity !== null) sceneObject.SetIntensity(light.intensity);
|
|
1739
|
+
if (light.enabled !== void 0 && light.enabled !== null) sceneObject.SetEnabled(light.enabled);
|
|
1740
|
+
if (light.color !== void 0 && light.color !== null) sceneObject.SetColor(new import_three10.Color(light.color));
|
|
1741
|
+
if (light.visible !== void 0 && light.visible !== null) sceneObject.visible = light.visible;
|
|
1742
|
+
if (light.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, light), { parent: light.parent }));
|
|
1743
|
+
}
|
|
1744
|
+
updateModel(model) {
|
|
1745
|
+
let sceneObject = this.GetSceneObject(model);
|
|
1746
|
+
if (!sceneObject) {
|
|
1747
|
+
const created = new DIVEModel();
|
|
1748
|
+
sceneObject = created;
|
|
1749
|
+
sceneObject.userData.id = model.id;
|
|
1750
|
+
this.add(sceneObject);
|
|
1751
|
+
}
|
|
1752
|
+
if (model.uri !== void 0) {
|
|
1753
|
+
this.loadingManager.LoadGLTF(model.uri).then((gltf) => {
|
|
1754
|
+
var _a;
|
|
1755
|
+
sceneObject.SetModel(gltf);
|
|
1756
|
+
(_a = DIVECommunication.get(model.id)) == null ? void 0 : _a.PerformAction("MODEL_LOADED", { id: model.id });
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
if (model.name !== void 0) sceneObject.name = model.name;
|
|
1760
|
+
if (model.position !== void 0) sceneObject.SetPosition(model.position);
|
|
1761
|
+
if (model.rotation !== void 0) sceneObject.SetRotation(model.rotation);
|
|
1762
|
+
if (model.scale !== void 0) sceneObject.SetScale(model.scale);
|
|
1763
|
+
if (model.visible !== void 0) sceneObject.SetVisibility(model.visible);
|
|
1764
|
+
if (model.material !== void 0) sceneObject.SetMaterial(model.material);
|
|
1765
|
+
if (model.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, model), { parent: model.parent }));
|
|
1766
|
+
}
|
|
1767
|
+
updatePrimitive(primitive) {
|
|
1768
|
+
let sceneObject = this.GetSceneObject(primitive);
|
|
1769
|
+
if (!sceneObject) {
|
|
1770
|
+
const created = new DIVEPrimitive();
|
|
1771
|
+
sceneObject = created;
|
|
1772
|
+
sceneObject.userData.id = primitive.id;
|
|
1773
|
+
this.add(sceneObject);
|
|
1774
|
+
}
|
|
1775
|
+
if (primitive.name !== void 0) sceneObject.name = primitive.name;
|
|
1776
|
+
if (primitive.geometry !== void 0) sceneObject.SetGeometry(primitive.geometry);
|
|
1777
|
+
if (primitive.position !== void 0) sceneObject.SetPosition(primitive.position);
|
|
1778
|
+
if (primitive.rotation !== void 0) sceneObject.SetRotation(primitive.rotation);
|
|
1779
|
+
if (primitive.scale !== void 0) sceneObject.SetScale(primitive.scale);
|
|
1780
|
+
if (primitive.visible !== void 0) sceneObject.SetVisibility(primitive.visible);
|
|
1781
|
+
if (primitive.material !== void 0) sceneObject.SetMaterial(primitive.material);
|
|
1782
|
+
if (primitive.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, primitive), { parent: primitive.parent }));
|
|
1783
|
+
}
|
|
1784
|
+
updateGroup(group) {
|
|
1785
|
+
let sceneObject = this.GetSceneObject(group);
|
|
1786
|
+
if (!sceneObject) {
|
|
1787
|
+
const created = new DIVEGroup();
|
|
1788
|
+
sceneObject = created;
|
|
1789
|
+
sceneObject.userData.id = group.id;
|
|
1790
|
+
this.add(sceneObject);
|
|
1791
|
+
}
|
|
1792
|
+
if (group.name !== void 0) sceneObject.name = group.name;
|
|
1793
|
+
if (group.position !== void 0) sceneObject.SetPosition(group.position);
|
|
1794
|
+
if (group.rotation !== void 0) sceneObject.SetRotation(group.rotation);
|
|
1795
|
+
if (group.scale !== void 0) sceneObject.SetScale(group.scale);
|
|
1796
|
+
if (group.visible !== void 0) sceneObject.SetVisibility(group.visible);
|
|
1797
|
+
if (group.bbVisible !== void 0) sceneObject.SetBoundingBoxVisibility(group.bbVisible);
|
|
1798
|
+
if (group.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, group), { parent: group.parent }));
|
|
1799
|
+
}
|
|
1800
|
+
deleteLight(light) {
|
|
1801
|
+
const sceneObject = this.GetSceneObject(light);
|
|
1802
|
+
if (!sceneObject) {
|
|
1803
|
+
console.warn(`Root.deleteLight: Light with id ${light.id} not found`);
|
|
1804
|
+
return;
|
|
1805
|
+
}
|
|
1806
|
+
this.detachTransformControls(sceneObject);
|
|
1807
|
+
this.remove(sceneObject);
|
|
1808
|
+
}
|
|
1809
|
+
deleteModel(model) {
|
|
1810
|
+
const sceneObject = this.GetSceneObject(model);
|
|
1811
|
+
if (!sceneObject) {
|
|
1812
|
+
console.warn(`Root.deleteModel: Model with id ${model.id} not found`);
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
this.detachTransformControls(sceneObject);
|
|
1816
|
+
this.remove(sceneObject);
|
|
1817
|
+
}
|
|
1818
|
+
deletePrimitive(primitive) {
|
|
1819
|
+
const sceneObject = this.GetSceneObject(primitive);
|
|
1820
|
+
if (!sceneObject) {
|
|
1821
|
+
console.warn(`Root.deletePrimitive: Primitive with id ${primitive.id} not found`);
|
|
1822
|
+
return;
|
|
1823
|
+
}
|
|
1824
|
+
this.detachTransformControls(sceneObject);
|
|
1825
|
+
this.remove(sceneObject);
|
|
1826
|
+
}
|
|
1827
|
+
deleteGroup(group) {
|
|
1828
|
+
const sceneObject = this.GetSceneObject(group);
|
|
1829
|
+
if (!sceneObject) {
|
|
1830
|
+
console.warn(`Root.deleteGroup: Group with id ${group.id} not found`);
|
|
1831
|
+
return;
|
|
1832
|
+
}
|
|
1833
|
+
this.detachTransformControls(sceneObject);
|
|
1834
|
+
for (let i = sceneObject.children.length - 1; i >= 0; i--) {
|
|
1835
|
+
this.attach(sceneObject.children[i]);
|
|
1836
|
+
}
|
|
1837
|
+
sceneObject.parent.remove(sceneObject);
|
|
1838
|
+
}
|
|
1839
|
+
placeOnFloor(object) {
|
|
1840
|
+
const sceneObject = this.GetSceneObject(object);
|
|
1841
|
+
if (!sceneObject) return;
|
|
1842
|
+
sceneObject.PlaceOnFloor();
|
|
1843
|
+
}
|
|
1844
|
+
setParent(object) {
|
|
1845
|
+
const sceneObject = this.GetSceneObject(object);
|
|
1846
|
+
if (!sceneObject) return;
|
|
1847
|
+
if (sceneObject.parent) {
|
|
1848
|
+
sceneObject.parent.remove(sceneObject);
|
|
1849
|
+
}
|
|
1850
|
+
if (object.parent !== null) {
|
|
1851
|
+
const parent = this.GetSceneObject(object.parent);
|
|
1852
|
+
if (!parent) return;
|
|
1853
|
+
parent.attach(sceneObject);
|
|
1854
|
+
} else {
|
|
1855
|
+
this.attach(sceneObject);
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
detachTransformControls(object) {
|
|
1859
|
+
this.findScene(object).children.find((object2) => {
|
|
1860
|
+
if ("isTransformControls" in object2) {
|
|
1861
|
+
object2.detach();
|
|
1862
|
+
}
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
findScene(object) {
|
|
1866
|
+
if (object.parent !== null) {
|
|
1867
|
+
return this.findScene(object.parent);
|
|
1868
|
+
}
|
|
1869
|
+
;
|
|
1870
|
+
return object;
|
|
1871
|
+
}
|
|
1872
|
+
};
|
|
1873
|
+
|
|
1874
|
+
// src/constant/GridColors.ts
|
|
1875
|
+
var GRID_CENTER_LINE_COLOR = "#888888";
|
|
1876
|
+
var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
1877
|
+
|
|
1878
|
+
// src/grid/Grid.ts
|
|
1879
|
+
init_VisibilityLayerMask();
|
|
1880
|
+
var import_three11 = require("three");
|
|
1881
|
+
var DIVEGrid = class extends import_three11.Object3D {
|
|
1882
|
+
constructor() {
|
|
1883
|
+
super();
|
|
1884
|
+
this.name = "Grid";
|
|
1885
|
+
const grid = new import_three11.GridHelper(100, 100, GRID_CENTER_LINE_COLOR, GRID_SIDE_LINE_COLOR);
|
|
1886
|
+
grid.material.depthTest = false;
|
|
1887
|
+
grid.layers.mask = HELPER_LAYER_MASK;
|
|
1888
|
+
this.add(grid);
|
|
1889
|
+
}
|
|
1890
|
+
SetVisibility(visible) {
|
|
1891
|
+
this.visible = visible;
|
|
1892
|
+
}
|
|
1893
|
+
};
|
|
1894
|
+
|
|
1895
|
+
// src/primitive/floor/Floor.ts
|
|
1896
|
+
var import_three12 = require("three");
|
|
1897
|
+
init_VisibilityLayerMask();
|
|
1898
|
+
var DIVEFloor = class extends import_three12.Mesh {
|
|
1899
|
+
constructor() {
|
|
1900
|
+
super(new import_three12.PlaneGeometry(1e4, 1e4), new import_three12.MeshStandardMaterial({ color: new import_three12.Color(150 / 255, 150 / 255, 150 / 255) }));
|
|
1901
|
+
this.isFloor = true;
|
|
1902
|
+
this.name = "Floor";
|
|
1903
|
+
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1904
|
+
this.receiveShadow = true;
|
|
1905
|
+
this.rotateX(-Math.PI / 2);
|
|
1906
|
+
}
|
|
1907
|
+
SetVisibility(visible) {
|
|
1908
|
+
this.visible = visible;
|
|
1909
|
+
}
|
|
1910
|
+
SetColor(color) {
|
|
1911
|
+
this.material.color = new import_three12.Color(color);
|
|
1912
|
+
}
|
|
1870
1913
|
};
|
|
1871
1914
|
|
|
1872
1915
|
// src/scene/Scene.ts
|
|
1873
|
-
var DIVEScene = class extends
|
|
1916
|
+
var DIVEScene = class extends import_three13.Scene {
|
|
1874
1917
|
get Root() {
|
|
1875
1918
|
return this.root;
|
|
1876
1919
|
}
|
|
1920
|
+
get Floor() {
|
|
1921
|
+
return this.floor;
|
|
1922
|
+
}
|
|
1923
|
+
get Grid() {
|
|
1924
|
+
return this.grid;
|
|
1925
|
+
}
|
|
1877
1926
|
constructor() {
|
|
1878
1927
|
super();
|
|
1879
|
-
this.background = new
|
|
1928
|
+
this.background = new import_three13.Color(16777215);
|
|
1880
1929
|
this.root = new DIVERoot();
|
|
1881
1930
|
this.add(this.root);
|
|
1931
|
+
this.floor = new DIVEFloor();
|
|
1932
|
+
this.add(this.floor);
|
|
1933
|
+
this.grid = new DIVEGrid();
|
|
1934
|
+
this.add(this.grid);
|
|
1882
1935
|
}
|
|
1883
1936
|
SetBackground(color) {
|
|
1884
|
-
this.background = new
|
|
1937
|
+
this.background = new import_three13.Color(color);
|
|
1885
1938
|
}
|
|
1886
1939
|
ComputeSceneBB() {
|
|
1887
1940
|
return this.Root.ComputeSceneBB();
|
|
@@ -1890,7 +1943,7 @@ var DIVEScene = class extends import_three15.Scene {
|
|
|
1890
1943
|
return this.Root.GetSceneObject(object);
|
|
1891
1944
|
}
|
|
1892
1945
|
AddSceneObject(object) {
|
|
1893
|
-
this.Root.
|
|
1946
|
+
this.Root.AddSceneObject(object);
|
|
1894
1947
|
}
|
|
1895
1948
|
UpdateSceneObject(object) {
|
|
1896
1949
|
this.Root.UpdateSceneObject(object);
|
|
@@ -1908,7 +1961,7 @@ init_PerspectiveCamera();
|
|
|
1908
1961
|
|
|
1909
1962
|
// src/controls/OrbitControls.ts
|
|
1910
1963
|
var import_OrbitControls = require("three/examples/jsm/controls/OrbitControls");
|
|
1911
|
-
var
|
|
1964
|
+
var import_three14 = require("three");
|
|
1912
1965
|
var import_tween = require("@tweenjs/tween.js");
|
|
1913
1966
|
var DIVEOrbitControlsDefaultSettings = {
|
|
1914
1967
|
enableDamping: true,
|
|
@@ -1950,8 +2003,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
1950
2003
|
this.dispose();
|
|
1951
2004
|
}
|
|
1952
2005
|
ComputeEncompassingView(bb) {
|
|
1953
|
-
const center = bb.getCenter(new
|
|
1954
|
-
const size = bb.getSize(new
|
|
2006
|
+
const center = bb.getCenter(new import_three14.Vector3());
|
|
2007
|
+
const size = bb.getSize(new import_three14.Vector3());
|
|
1955
2008
|
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
1956
2009
|
const direction = this.object.position.clone().normalize();
|
|
1957
2010
|
return {
|
|
@@ -1962,7 +2015,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
1962
2015
|
ZoomIn(by) {
|
|
1963
2016
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
1964
2017
|
const { minDistance, maxDistance } = this;
|
|
1965
|
-
this.minDistance = this.maxDistance =
|
|
2018
|
+
this.minDistance = this.maxDistance = import_three14.MathUtils.clamp(this.getDistance() - zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
1966
2019
|
this.update();
|
|
1967
2020
|
this.minDistance = minDistance;
|
|
1968
2021
|
this.maxDistance = maxDistance;
|
|
@@ -1970,7 +2023,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
1970
2023
|
ZoomOut(by) {
|
|
1971
2024
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
1972
2025
|
const { minDistance, maxDistance } = this;
|
|
1973
|
-
this.minDistance = this.maxDistance =
|
|
2026
|
+
this.minDistance = this.maxDistance = import_three14.MathUtils.clamp(this.getDistance() + zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
1974
2027
|
this.update();
|
|
1975
2028
|
this.minDistance = minDistance;
|
|
1976
2029
|
this.maxDistance = maxDistance;
|
|
@@ -2118,7 +2171,7 @@ var DIVEAnimationSystem = class {
|
|
|
2118
2171
|
};
|
|
2119
2172
|
|
|
2120
2173
|
// src/axiscamera/AxisCamera.ts
|
|
2121
|
-
var
|
|
2174
|
+
var import_three15 = require("three");
|
|
2122
2175
|
var import_three_spritetext = __toESM(require("three-spritetext"), 1);
|
|
2123
2176
|
init_VisibilityLayerMask();
|
|
2124
2177
|
|
|
@@ -2131,18 +2184,18 @@ var AxesColorGreen = AxesColorGreenLetter;
|
|
|
2131
2184
|
var AxesColorBlue = AxesColorBlueLetter;
|
|
2132
2185
|
|
|
2133
2186
|
// src/axiscamera/AxisCamera.ts
|
|
2134
|
-
var DIVEAxisCamera = class extends
|
|
2187
|
+
var DIVEAxisCamera = class extends import_three15.OrthographicCamera {
|
|
2135
2188
|
constructor(renderer, scene, controls) {
|
|
2136
2189
|
super(-1, 1, 1, -1, 0.1, 100);
|
|
2137
2190
|
this.layers.mask = COORDINATE_LAYER_MASK;
|
|
2138
|
-
this.axesHelper = new
|
|
2191
|
+
this.axesHelper = new import_three15.AxesHelper(0.5);
|
|
2139
2192
|
this.axesHelper.layers.mask = COORDINATE_LAYER_MASK;
|
|
2140
2193
|
this.axesHelper.material.depthTest = false;
|
|
2141
2194
|
this.axesHelper.position.set(0, 0, -1);
|
|
2142
2195
|
this.axesHelper.setColors(
|
|
2143
|
-
new
|
|
2144
|
-
new
|
|
2145
|
-
new
|
|
2196
|
+
new import_three15.Color(AxesColorRed),
|
|
2197
|
+
new import_three15.Color(AxesColorGreen),
|
|
2198
|
+
new import_three15.Color(AxesColorBlue)
|
|
2146
2199
|
);
|
|
2147
2200
|
const x = new import_three_spritetext.default("X", 0.2, AxesColorRedLetter);
|
|
2148
2201
|
const y = new import_three_spritetext.default("Y", 0.2, AxesColorGreenLetter);
|
|
@@ -2160,7 +2213,7 @@ var DIVEAxisCamera = class extends import_three17.OrthographicCamera {
|
|
|
2160
2213
|
this._renderer = renderer;
|
|
2161
2214
|
this._scene = scene;
|
|
2162
2215
|
this._scene.add(this);
|
|
2163
|
-
const restoreViewport = new
|
|
2216
|
+
const restoreViewport = new import_three15.Vector4();
|
|
2164
2217
|
this._renderCallbackId = renderer.AddPostRenderCallback(() => {
|
|
2165
2218
|
const restoreBackground = scene.background;
|
|
2166
2219
|
scene.background = null;
|
|
@@ -2179,7 +2232,7 @@ var DIVEAxisCamera = class extends import_three17.OrthographicCamera {
|
|
|
2179
2232
|
this._scene.remove(this);
|
|
2180
2233
|
}
|
|
2181
2234
|
SetFromCameraMatrix(matrix) {
|
|
2182
|
-
this.axesHelper.rotation.setFromRotationMatrix(new
|
|
2235
|
+
this.axesHelper.rotation.setFromRotationMatrix(new import_three15.Matrix4().extractRotation(matrix).invert());
|
|
2183
2236
|
}
|
|
2184
2237
|
};
|
|
2185
2238
|
|
|
@@ -2243,58 +2296,6 @@ var getObjectDelta = (a, b) => {
|
|
|
2243
2296
|
return delta;
|
|
2244
2297
|
};
|
|
2245
2298
|
|
|
2246
|
-
// src/math/helper/shift.ts
|
|
2247
|
-
function shift(value, exponent) {
|
|
2248
|
-
const subvalues = (value + "e").split("e");
|
|
2249
|
-
return +(subvalues[0] + "e" + (+subvalues[1] + (exponent || 0)));
|
|
2250
|
-
}
|
|
2251
|
-
|
|
2252
|
-
// src/math/ceil/ceilExp.ts
|
|
2253
|
-
function ceilExp(number, decimals = 0) {
|
|
2254
|
-
const n = shift(number, +decimals);
|
|
2255
|
-
return shift(Math.ceil(n), -decimals);
|
|
2256
|
-
}
|
|
2257
|
-
|
|
2258
|
-
// src/math/floor/floorExp.ts
|
|
2259
|
-
function floorExp(number, decimals = 0) {
|
|
2260
|
-
const n = shift(number, +decimals);
|
|
2261
|
-
return shift(Math.floor(n), -decimals);
|
|
2262
|
-
}
|
|
2263
|
-
|
|
2264
|
-
// src/math/round/roundExp.ts
|
|
2265
|
-
function roundExponential(number, decimals = 0) {
|
|
2266
|
-
if (number < 0) return -roundExponential(-number, decimals);
|
|
2267
|
-
const n = shift(number, +decimals);
|
|
2268
|
-
return shift(Math.round(n), -decimals);
|
|
2269
|
-
}
|
|
2270
|
-
|
|
2271
|
-
// src/math/signedAngleTo/signedAngleTo.ts
|
|
2272
|
-
function signedAngleTo(vecA, vecB, planeNormal) {
|
|
2273
|
-
return Math.atan2(vecA.clone().cross(vecB).dot(planeNormal), vecB.clone().dot(vecA));
|
|
2274
|
-
}
|
|
2275
|
-
|
|
2276
|
-
// src/math/toFixed/toFixedExp.ts
|
|
2277
|
-
function toFixedExp(number, decimals = 0) {
|
|
2278
|
-
const n = shift(number, +decimals);
|
|
2279
|
-
return shift(Math.round(n), -decimals).toFixed(decimals);
|
|
2280
|
-
}
|
|
2281
|
-
|
|
2282
|
-
// src/math/truncate/truncateExp.ts
|
|
2283
|
-
function truncateExp(number, decimals = 0) {
|
|
2284
|
-
const n = shift(number, +decimals);
|
|
2285
|
-
return shift(Math.trunc(n), -decimals);
|
|
2286
|
-
}
|
|
2287
|
-
|
|
2288
|
-
// src/math/index.ts
|
|
2289
|
-
var DIVEMath = {
|
|
2290
|
-
ceilExp,
|
|
2291
|
-
floorExp,
|
|
2292
|
-
roundExp: roundExponential,
|
|
2293
|
-
toFixedExp,
|
|
2294
|
-
truncateExp,
|
|
2295
|
-
signedAngleTo
|
|
2296
|
-
};
|
|
2297
|
-
|
|
2298
2299
|
// src/dive.ts
|
|
2299
2300
|
var import_MathUtils2 = require("three/src/math/MathUtils");
|
|
2300
2301
|
|
|
@@ -2395,6 +2396,58 @@ var DIVEInfo = class {
|
|
|
2395
2396
|
};
|
|
2396
2397
|
DIVEInfo._supportsWebXR = null;
|
|
2397
2398
|
|
|
2399
|
+
// src/math/helper/shift.ts
|
|
2400
|
+
function shift(value, exponent) {
|
|
2401
|
+
const subvalues = (value + "e").split("e");
|
|
2402
|
+
return +(subvalues[0] + "e" + (+subvalues[1] + (exponent || 0)));
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
// src/math/ceil/ceilExp.ts
|
|
2406
|
+
function ceilExp(number, decimals = 0) {
|
|
2407
|
+
const n = shift(number, +decimals);
|
|
2408
|
+
return shift(Math.ceil(n), -decimals);
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
// src/math/floor/floorExp.ts
|
|
2412
|
+
function floorExp(number, decimals = 0) {
|
|
2413
|
+
const n = shift(number, +decimals);
|
|
2414
|
+
return shift(Math.floor(n), -decimals);
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
// src/math/round/roundExp.ts
|
|
2418
|
+
function roundExponential(number, decimals = 0) {
|
|
2419
|
+
if (number < 0) return -roundExponential(-number, decimals);
|
|
2420
|
+
const n = shift(number, +decimals);
|
|
2421
|
+
return shift(Math.round(n), -decimals);
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
// src/math/signedAngleTo/signedAngleTo.ts
|
|
2425
|
+
function signedAngleTo(vecA, vecB, planeNormal) {
|
|
2426
|
+
return Math.atan2(vecA.clone().cross(vecB).dot(planeNormal), vecB.clone().dot(vecA));
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
// src/math/toFixed/toFixedExp.ts
|
|
2430
|
+
function toFixedExp(number, decimals = 0) {
|
|
2431
|
+
const n = shift(number, +decimals);
|
|
2432
|
+
return shift(Math.round(n), -decimals).toFixed(decimals);
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
// src/math/truncate/truncateExp.ts
|
|
2436
|
+
function truncateExp(number, decimals = 0) {
|
|
2437
|
+
const n = shift(number, +decimals);
|
|
2438
|
+
return shift(Math.trunc(n), -decimals);
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
// src/math/index.ts
|
|
2442
|
+
var DIVEMath = {
|
|
2443
|
+
ceilExp,
|
|
2444
|
+
floorExp,
|
|
2445
|
+
roundExp: roundExponential,
|
|
2446
|
+
toFixedExp,
|
|
2447
|
+
truncateExp,
|
|
2448
|
+
signedAngleTo
|
|
2449
|
+
};
|
|
2450
|
+
|
|
2398
2451
|
// src/dive.ts
|
|
2399
2452
|
var DIVEDefaultSettings = {
|
|
2400
2453
|
autoResize: true,
|