@shopware-ag/dive 1.12.1 → 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.
- package/build/dive.cjs +444 -405
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +311 -78
- package/build/dive.d.ts +311 -78
- package/build/dive.js +416 -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 +111 -0
- package/src/group/__test__/Group.test.ts +67 -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,131 @@ 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
|
+
const childrensWorldPositions = this.children.map((child) => child.getWorldPosition(new import_three9.Vector3()));
|
|
1572
|
+
const bbcenter = this.updateBB();
|
|
1573
|
+
this.position.copy(bbcenter);
|
|
1574
|
+
this.children.forEach((child, i) => {
|
|
1575
|
+
if (child.uuid === this._boxMesh.uuid) return;
|
|
1576
|
+
child.position.copy(this.worldToLocal(childrensWorldPositions[i]));
|
|
1577
|
+
});
|
|
1721
1578
|
}
|
|
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);
|
|
1579
|
+
/**
|
|
1580
|
+
* Updates the bounding box of the group.
|
|
1581
|
+
* @returns {Vector3} The new center of the bounding box.
|
|
1582
|
+
*/
|
|
1583
|
+
updateBB() {
|
|
1584
|
+
this._bb.makeEmpty();
|
|
1585
|
+
this.children.forEach((child) => {
|
|
1586
|
+
if (child.uuid === this._boxMesh.uuid) return;
|
|
1587
|
+
this._bb.expandByObject(child);
|
|
1588
|
+
});
|
|
1589
|
+
return this._bb.getCenter(new import_three9.Vector3());
|
|
1739
1590
|
}
|
|
1740
|
-
|
|
1741
|
-
this.
|
|
1591
|
+
updateBoxMesh() {
|
|
1592
|
+
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);
|
|
1742
1593
|
}
|
|
1743
1594
|
};
|
|
1744
1595
|
|
|
1745
1596
|
// 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
|
-
}
|
|
1597
|
+
var DIVERoot = class extends import_three10.Object3D {
|
|
1753
1598
|
constructor() {
|
|
1754
1599
|
super();
|
|
1600
|
+
this.isDIVERoot = true;
|
|
1755
1601
|
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);
|
|
1602
|
+
this.loadingManager = new DIVELoadingManager();
|
|
1766
1603
|
}
|
|
1767
1604
|
ComputeSceneBB() {
|
|
1768
|
-
const bb = new
|
|
1769
|
-
this.
|
|
1770
|
-
if ("isObject3D" in object) {
|
|
1771
|
-
bb.expandByObject(object);
|
|
1772
|
-
}
|
|
1773
|
-
});
|
|
1774
|
-
this.primitiveRoot.traverse((object) => {
|
|
1605
|
+
const bb = new import_three10.Box3();
|
|
1606
|
+
this.traverse((object) => {
|
|
1775
1607
|
if ("isObject3D" in object) {
|
|
1776
1608
|
bb.expandByObject(object);
|
|
1777
1609
|
}
|
|
@@ -1779,20 +1611,7 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1779
1611
|
return bb;
|
|
1780
1612
|
}
|
|
1781
1613
|
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
|
-
}
|
|
1614
|
+
return this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1796
1615
|
}
|
|
1797
1616
|
AddSceneObject(object) {
|
|
1798
1617
|
switch (object.entityType) {
|
|
@@ -1800,15 +1619,19 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1800
1619
|
break;
|
|
1801
1620
|
}
|
|
1802
1621
|
case "light": {
|
|
1803
|
-
this.
|
|
1622
|
+
this.updateLight(object);
|
|
1804
1623
|
break;
|
|
1805
1624
|
}
|
|
1806
1625
|
case "model": {
|
|
1807
|
-
this.
|
|
1626
|
+
this.updateModel(object);
|
|
1808
1627
|
break;
|
|
1809
1628
|
}
|
|
1810
1629
|
case "primitive": {
|
|
1811
|
-
this.
|
|
1630
|
+
this.updatePrimitive(object);
|
|
1631
|
+
break;
|
|
1632
|
+
}
|
|
1633
|
+
case "group": {
|
|
1634
|
+
this.updateGroup(object);
|
|
1812
1635
|
break;
|
|
1813
1636
|
}
|
|
1814
1637
|
}
|
|
@@ -1819,15 +1642,19 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1819
1642
|
break;
|
|
1820
1643
|
}
|
|
1821
1644
|
case "light": {
|
|
1822
|
-
this.
|
|
1645
|
+
this.updateLight(object);
|
|
1823
1646
|
break;
|
|
1824
1647
|
}
|
|
1825
1648
|
case "model": {
|
|
1826
|
-
this.
|
|
1649
|
+
this.updateModel(object);
|
|
1827
1650
|
break;
|
|
1828
1651
|
}
|
|
1829
1652
|
case "primitive": {
|
|
1830
|
-
this.
|
|
1653
|
+
this.updatePrimitive(object);
|
|
1654
|
+
break;
|
|
1655
|
+
}
|
|
1656
|
+
case "group": {
|
|
1657
|
+
this.updateGroup(object);
|
|
1831
1658
|
break;
|
|
1832
1659
|
}
|
|
1833
1660
|
}
|
|
@@ -1838,15 +1665,19 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1838
1665
|
break;
|
|
1839
1666
|
}
|
|
1840
1667
|
case "light": {
|
|
1841
|
-
this.
|
|
1668
|
+
this.deleteLight(object);
|
|
1842
1669
|
break;
|
|
1843
1670
|
}
|
|
1844
1671
|
case "model": {
|
|
1845
|
-
this.
|
|
1672
|
+
this.deleteModel(object);
|
|
1846
1673
|
break;
|
|
1847
1674
|
}
|
|
1848
1675
|
case "primitive": {
|
|
1849
|
-
this.
|
|
1676
|
+
this.deletePrimitive(object);
|
|
1677
|
+
break;
|
|
1678
|
+
}
|
|
1679
|
+
case "group": {
|
|
1680
|
+
this.deleteGroup(object);
|
|
1850
1681
|
break;
|
|
1851
1682
|
}
|
|
1852
1683
|
}
|
|
@@ -1857,31 +1688,239 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1857
1688
|
case "light": {
|
|
1858
1689
|
break;
|
|
1859
1690
|
}
|
|
1860
|
-
case "model":
|
|
1861
|
-
this.modelRoot.PlaceOnFloor(object);
|
|
1862
|
-
break;
|
|
1863
|
-
}
|
|
1691
|
+
case "model":
|
|
1864
1692
|
case "primitive": {
|
|
1865
|
-
this.
|
|
1693
|
+
this.placeOnFloor(object);
|
|
1866
1694
|
break;
|
|
1867
1695
|
}
|
|
1868
1696
|
}
|
|
1869
1697
|
}
|
|
1698
|
+
updateLight(light) {
|
|
1699
|
+
let sceneObject = this.GetSceneObject(light);
|
|
1700
|
+
if (!sceneObject) {
|
|
1701
|
+
switch (light.type) {
|
|
1702
|
+
case "scene": {
|
|
1703
|
+
sceneObject = new DIVESceneLight();
|
|
1704
|
+
break;
|
|
1705
|
+
}
|
|
1706
|
+
case "ambient": {
|
|
1707
|
+
sceneObject = new DIVEAmbientLight();
|
|
1708
|
+
break;
|
|
1709
|
+
}
|
|
1710
|
+
case "point": {
|
|
1711
|
+
sceneObject = new DIVEPointLight();
|
|
1712
|
+
break;
|
|
1713
|
+
}
|
|
1714
|
+
default: {
|
|
1715
|
+
console.warn(`Root.updateLight: Unknown light type: ${light.type}`);
|
|
1716
|
+
return;
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
sceneObject.userData.id = light.id;
|
|
1720
|
+
this.add(sceneObject);
|
|
1721
|
+
}
|
|
1722
|
+
if (light.name !== void 0 && light.name !== null) sceneObject.name = light.name;
|
|
1723
|
+
if (light.position !== void 0 && light.position !== null) sceneObject.position.set(light.position.x, light.position.y, light.position.z);
|
|
1724
|
+
if (light.intensity !== void 0 && light.intensity !== null) sceneObject.SetIntensity(light.intensity);
|
|
1725
|
+
if (light.enabled !== void 0 && light.enabled !== null) sceneObject.SetEnabled(light.enabled);
|
|
1726
|
+
if (light.color !== void 0 && light.color !== null) sceneObject.SetColor(new import_three10.Color(light.color));
|
|
1727
|
+
if (light.visible !== void 0 && light.visible !== null) sceneObject.visible = light.visible;
|
|
1728
|
+
if (light.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, light), { parent: light.parent }));
|
|
1729
|
+
}
|
|
1730
|
+
updateModel(model) {
|
|
1731
|
+
let sceneObject = this.GetSceneObject(model);
|
|
1732
|
+
if (!sceneObject) {
|
|
1733
|
+
const created = new DIVEModel();
|
|
1734
|
+
sceneObject = created;
|
|
1735
|
+
sceneObject.userData.id = model.id;
|
|
1736
|
+
this.add(sceneObject);
|
|
1737
|
+
}
|
|
1738
|
+
if (model.uri !== void 0) {
|
|
1739
|
+
this.loadingManager.LoadGLTF(model.uri).then((gltf) => {
|
|
1740
|
+
var _a;
|
|
1741
|
+
sceneObject.SetModel(gltf);
|
|
1742
|
+
(_a = DIVECommunication.get(model.id)) == null ? void 0 : _a.PerformAction("MODEL_LOADED", { id: model.id });
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
if (model.name !== void 0) sceneObject.name = model.name;
|
|
1746
|
+
if (model.position !== void 0) sceneObject.SetPosition(model.position);
|
|
1747
|
+
if (model.rotation !== void 0) sceneObject.SetRotation(model.rotation);
|
|
1748
|
+
if (model.scale !== void 0) sceneObject.SetScale(model.scale);
|
|
1749
|
+
if (model.visible !== void 0) sceneObject.SetVisibility(model.visible);
|
|
1750
|
+
if (model.material !== void 0) sceneObject.SetMaterial(model.material);
|
|
1751
|
+
if (model.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, model), { parent: model.parent }));
|
|
1752
|
+
}
|
|
1753
|
+
updatePrimitive(primitive) {
|
|
1754
|
+
let sceneObject = this.GetSceneObject(primitive);
|
|
1755
|
+
if (!sceneObject) {
|
|
1756
|
+
const created = new DIVEPrimitive();
|
|
1757
|
+
sceneObject = created;
|
|
1758
|
+
sceneObject.userData.id = primitive.id;
|
|
1759
|
+
this.add(sceneObject);
|
|
1760
|
+
}
|
|
1761
|
+
if (primitive.name !== void 0) sceneObject.name = primitive.name;
|
|
1762
|
+
if (primitive.geometry !== void 0) sceneObject.SetGeometry(primitive.geometry);
|
|
1763
|
+
if (primitive.position !== void 0) sceneObject.SetPosition(primitive.position);
|
|
1764
|
+
if (primitive.rotation !== void 0) sceneObject.SetRotation(primitive.rotation);
|
|
1765
|
+
if (primitive.scale !== void 0) sceneObject.SetScale(primitive.scale);
|
|
1766
|
+
if (primitive.visible !== void 0) sceneObject.SetVisibility(primitive.visible);
|
|
1767
|
+
if (primitive.material !== void 0) sceneObject.SetMaterial(primitive.material);
|
|
1768
|
+
if (primitive.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, primitive), { parent: primitive.parent }));
|
|
1769
|
+
}
|
|
1770
|
+
updateGroup(group) {
|
|
1771
|
+
let sceneObject = this.GetSceneObject(group);
|
|
1772
|
+
if (!sceneObject) {
|
|
1773
|
+
const created = new DIVEGroup();
|
|
1774
|
+
sceneObject = created;
|
|
1775
|
+
sceneObject.userData.id = group.id;
|
|
1776
|
+
this.add(sceneObject);
|
|
1777
|
+
}
|
|
1778
|
+
if (group.name !== void 0) sceneObject.name = group.name;
|
|
1779
|
+
if (group.position !== void 0) sceneObject.SetPosition(group.position);
|
|
1780
|
+
if (group.rotation !== void 0) sceneObject.SetRotation(group.rotation);
|
|
1781
|
+
if (group.scale !== void 0) sceneObject.SetScale(group.scale);
|
|
1782
|
+
if (group.visible !== void 0) sceneObject.SetVisibility(group.visible);
|
|
1783
|
+
if (group.bbVisible !== void 0) sceneObject.SetBoundingBoxVisibility(group.bbVisible);
|
|
1784
|
+
if (group.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, group), { parent: group.parent }));
|
|
1785
|
+
}
|
|
1786
|
+
deleteLight(light) {
|
|
1787
|
+
const sceneObject = this.GetSceneObject(light);
|
|
1788
|
+
if (!sceneObject) {
|
|
1789
|
+
console.warn(`Root.deleteLight: Light with id ${light.id} not found`);
|
|
1790
|
+
return;
|
|
1791
|
+
}
|
|
1792
|
+
this.detachTransformControls(sceneObject);
|
|
1793
|
+
this.remove(sceneObject);
|
|
1794
|
+
}
|
|
1795
|
+
deleteModel(model) {
|
|
1796
|
+
const sceneObject = this.GetSceneObject(model);
|
|
1797
|
+
if (!sceneObject) {
|
|
1798
|
+
console.warn(`Root.deleteModel: Model with id ${model.id} not found`);
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
this.detachTransformControls(sceneObject);
|
|
1802
|
+
this.remove(sceneObject);
|
|
1803
|
+
}
|
|
1804
|
+
deletePrimitive(primitive) {
|
|
1805
|
+
const sceneObject = this.GetSceneObject(primitive);
|
|
1806
|
+
if (!sceneObject) {
|
|
1807
|
+
console.warn(`Root.deletePrimitive: Primitive with id ${primitive.id} not found`);
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
this.detachTransformControls(sceneObject);
|
|
1811
|
+
this.remove(sceneObject);
|
|
1812
|
+
}
|
|
1813
|
+
deleteGroup(group) {
|
|
1814
|
+
const sceneObject = this.GetSceneObject(group);
|
|
1815
|
+
if (!sceneObject) {
|
|
1816
|
+
console.warn(`Root.deleteGroup: Group with id ${group.id} not found`);
|
|
1817
|
+
return;
|
|
1818
|
+
}
|
|
1819
|
+
this.detachTransformControls(sceneObject);
|
|
1820
|
+
for (let i = sceneObject.children.length - 1; i >= 0; i--) {
|
|
1821
|
+
this.attach(sceneObject.children[i]);
|
|
1822
|
+
}
|
|
1823
|
+
sceneObject.parent.remove(sceneObject);
|
|
1824
|
+
}
|
|
1825
|
+
placeOnFloor(object) {
|
|
1826
|
+
const sceneObject = this.GetSceneObject(object);
|
|
1827
|
+
if (!sceneObject) return;
|
|
1828
|
+
sceneObject.PlaceOnFloor();
|
|
1829
|
+
}
|
|
1830
|
+
setParent(object) {
|
|
1831
|
+
const sceneObject = this.GetSceneObject(object);
|
|
1832
|
+
if (!sceneObject) return;
|
|
1833
|
+
if (sceneObject.parent) {
|
|
1834
|
+
sceneObject.parent.remove(sceneObject);
|
|
1835
|
+
}
|
|
1836
|
+
if (object.parent !== null) {
|
|
1837
|
+
const parent = this.GetSceneObject(object.parent);
|
|
1838
|
+
if (!parent) return;
|
|
1839
|
+
parent.attach(sceneObject);
|
|
1840
|
+
} else {
|
|
1841
|
+
this.attach(sceneObject);
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
detachTransformControls(object) {
|
|
1845
|
+
this.findScene(object).children.find((object2) => {
|
|
1846
|
+
if ("isTransformControls" in object2) {
|
|
1847
|
+
object2.detach();
|
|
1848
|
+
}
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
findScene(object) {
|
|
1852
|
+
if (object.parent !== null) {
|
|
1853
|
+
return this.findScene(object.parent);
|
|
1854
|
+
}
|
|
1855
|
+
;
|
|
1856
|
+
return object;
|
|
1857
|
+
}
|
|
1858
|
+
};
|
|
1859
|
+
|
|
1860
|
+
// src/constant/GridColors.ts
|
|
1861
|
+
var GRID_CENTER_LINE_COLOR = "#888888";
|
|
1862
|
+
var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
1863
|
+
|
|
1864
|
+
// src/grid/Grid.ts
|
|
1865
|
+
init_VisibilityLayerMask();
|
|
1866
|
+
var import_three11 = require("three");
|
|
1867
|
+
var DIVEGrid = class extends import_three11.Object3D {
|
|
1868
|
+
constructor() {
|
|
1869
|
+
super();
|
|
1870
|
+
this.name = "Grid";
|
|
1871
|
+
const grid = new import_three11.GridHelper(100, 100, GRID_CENTER_LINE_COLOR, GRID_SIDE_LINE_COLOR);
|
|
1872
|
+
grid.material.depthTest = false;
|
|
1873
|
+
grid.layers.mask = HELPER_LAYER_MASK;
|
|
1874
|
+
this.add(grid);
|
|
1875
|
+
}
|
|
1876
|
+
SetVisibility(visible) {
|
|
1877
|
+
this.visible = visible;
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
|
|
1881
|
+
// src/primitive/floor/Floor.ts
|
|
1882
|
+
var import_three12 = require("three");
|
|
1883
|
+
init_VisibilityLayerMask();
|
|
1884
|
+
var DIVEFloor = class extends import_three12.Mesh {
|
|
1885
|
+
constructor() {
|
|
1886
|
+
super(new import_three12.PlaneGeometry(1e4, 1e4), new import_three12.MeshStandardMaterial({ color: new import_three12.Color(150 / 255, 150 / 255, 150 / 255) }));
|
|
1887
|
+
this.isFloor = true;
|
|
1888
|
+
this.name = "Floor";
|
|
1889
|
+
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1890
|
+
this.receiveShadow = true;
|
|
1891
|
+
this.rotateX(-Math.PI / 2);
|
|
1892
|
+
}
|
|
1893
|
+
SetVisibility(visible) {
|
|
1894
|
+
this.visible = visible;
|
|
1895
|
+
}
|
|
1896
|
+
SetColor(color) {
|
|
1897
|
+
this.material.color = new import_three12.Color(color);
|
|
1898
|
+
}
|
|
1870
1899
|
};
|
|
1871
1900
|
|
|
1872
1901
|
// src/scene/Scene.ts
|
|
1873
|
-
var DIVEScene = class extends
|
|
1902
|
+
var DIVEScene = class extends import_three13.Scene {
|
|
1874
1903
|
get Root() {
|
|
1875
1904
|
return this.root;
|
|
1876
1905
|
}
|
|
1906
|
+
get Floor() {
|
|
1907
|
+
return this.floor;
|
|
1908
|
+
}
|
|
1909
|
+
get Grid() {
|
|
1910
|
+
return this.grid;
|
|
1911
|
+
}
|
|
1877
1912
|
constructor() {
|
|
1878
1913
|
super();
|
|
1879
|
-
this.background = new
|
|
1914
|
+
this.background = new import_three13.Color(16777215);
|
|
1880
1915
|
this.root = new DIVERoot();
|
|
1881
1916
|
this.add(this.root);
|
|
1917
|
+
this.floor = new DIVEFloor();
|
|
1918
|
+
this.add(this.floor);
|
|
1919
|
+
this.grid = new DIVEGrid();
|
|
1920
|
+
this.add(this.grid);
|
|
1882
1921
|
}
|
|
1883
1922
|
SetBackground(color) {
|
|
1884
|
-
this.background = new
|
|
1923
|
+
this.background = new import_three13.Color(color);
|
|
1885
1924
|
}
|
|
1886
1925
|
ComputeSceneBB() {
|
|
1887
1926
|
return this.Root.ComputeSceneBB();
|
|
@@ -1890,7 +1929,7 @@ var DIVEScene = class extends import_three15.Scene {
|
|
|
1890
1929
|
return this.Root.GetSceneObject(object);
|
|
1891
1930
|
}
|
|
1892
1931
|
AddSceneObject(object) {
|
|
1893
|
-
this.Root.
|
|
1932
|
+
this.Root.AddSceneObject(object);
|
|
1894
1933
|
}
|
|
1895
1934
|
UpdateSceneObject(object) {
|
|
1896
1935
|
this.Root.UpdateSceneObject(object);
|
|
@@ -1908,7 +1947,7 @@ init_PerspectiveCamera();
|
|
|
1908
1947
|
|
|
1909
1948
|
// src/controls/OrbitControls.ts
|
|
1910
1949
|
var import_OrbitControls = require("three/examples/jsm/controls/OrbitControls");
|
|
1911
|
-
var
|
|
1950
|
+
var import_three14 = require("three");
|
|
1912
1951
|
var import_tween = require("@tweenjs/tween.js");
|
|
1913
1952
|
var DIVEOrbitControlsDefaultSettings = {
|
|
1914
1953
|
enableDamping: true,
|
|
@@ -1950,8 +1989,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
1950
1989
|
this.dispose();
|
|
1951
1990
|
}
|
|
1952
1991
|
ComputeEncompassingView(bb) {
|
|
1953
|
-
const center = bb.getCenter(new
|
|
1954
|
-
const size = bb.getSize(new
|
|
1992
|
+
const center = bb.getCenter(new import_three14.Vector3());
|
|
1993
|
+
const size = bb.getSize(new import_three14.Vector3());
|
|
1955
1994
|
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
1956
1995
|
const direction = this.object.position.clone().normalize();
|
|
1957
1996
|
return {
|
|
@@ -1962,7 +2001,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
1962
2001
|
ZoomIn(by) {
|
|
1963
2002
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
1964
2003
|
const { minDistance, maxDistance } = this;
|
|
1965
|
-
this.minDistance = this.maxDistance =
|
|
2004
|
+
this.minDistance = this.maxDistance = import_three14.MathUtils.clamp(this.getDistance() - zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
1966
2005
|
this.update();
|
|
1967
2006
|
this.minDistance = minDistance;
|
|
1968
2007
|
this.maxDistance = maxDistance;
|
|
@@ -1970,7 +2009,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
1970
2009
|
ZoomOut(by) {
|
|
1971
2010
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
1972
2011
|
const { minDistance, maxDistance } = this;
|
|
1973
|
-
this.minDistance = this.maxDistance =
|
|
2012
|
+
this.minDistance = this.maxDistance = import_three14.MathUtils.clamp(this.getDistance() + zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
1974
2013
|
this.update();
|
|
1975
2014
|
this.minDistance = minDistance;
|
|
1976
2015
|
this.maxDistance = maxDistance;
|
|
@@ -2118,7 +2157,7 @@ var DIVEAnimationSystem = class {
|
|
|
2118
2157
|
};
|
|
2119
2158
|
|
|
2120
2159
|
// src/axiscamera/AxisCamera.ts
|
|
2121
|
-
var
|
|
2160
|
+
var import_three15 = require("three");
|
|
2122
2161
|
var import_three_spritetext = __toESM(require("three-spritetext"), 1);
|
|
2123
2162
|
init_VisibilityLayerMask();
|
|
2124
2163
|
|
|
@@ -2131,18 +2170,18 @@ var AxesColorGreen = AxesColorGreenLetter;
|
|
|
2131
2170
|
var AxesColorBlue = AxesColorBlueLetter;
|
|
2132
2171
|
|
|
2133
2172
|
// src/axiscamera/AxisCamera.ts
|
|
2134
|
-
var DIVEAxisCamera = class extends
|
|
2173
|
+
var DIVEAxisCamera = class extends import_three15.OrthographicCamera {
|
|
2135
2174
|
constructor(renderer, scene, controls) {
|
|
2136
2175
|
super(-1, 1, 1, -1, 0.1, 100);
|
|
2137
2176
|
this.layers.mask = COORDINATE_LAYER_MASK;
|
|
2138
|
-
this.axesHelper = new
|
|
2177
|
+
this.axesHelper = new import_three15.AxesHelper(0.5);
|
|
2139
2178
|
this.axesHelper.layers.mask = COORDINATE_LAYER_MASK;
|
|
2140
2179
|
this.axesHelper.material.depthTest = false;
|
|
2141
2180
|
this.axesHelper.position.set(0, 0, -1);
|
|
2142
2181
|
this.axesHelper.setColors(
|
|
2143
|
-
new
|
|
2144
|
-
new
|
|
2145
|
-
new
|
|
2182
|
+
new import_three15.Color(AxesColorRed),
|
|
2183
|
+
new import_three15.Color(AxesColorGreen),
|
|
2184
|
+
new import_three15.Color(AxesColorBlue)
|
|
2146
2185
|
);
|
|
2147
2186
|
const x = new import_three_spritetext.default("X", 0.2, AxesColorRedLetter);
|
|
2148
2187
|
const y = new import_three_spritetext.default("Y", 0.2, AxesColorGreenLetter);
|
|
@@ -2160,7 +2199,7 @@ var DIVEAxisCamera = class extends import_three17.OrthographicCamera {
|
|
|
2160
2199
|
this._renderer = renderer;
|
|
2161
2200
|
this._scene = scene;
|
|
2162
2201
|
this._scene.add(this);
|
|
2163
|
-
const restoreViewport = new
|
|
2202
|
+
const restoreViewport = new import_three15.Vector4();
|
|
2164
2203
|
this._renderCallbackId = renderer.AddPostRenderCallback(() => {
|
|
2165
2204
|
const restoreBackground = scene.background;
|
|
2166
2205
|
scene.background = null;
|
|
@@ -2179,7 +2218,7 @@ var DIVEAxisCamera = class extends import_three17.OrthographicCamera {
|
|
|
2179
2218
|
this._scene.remove(this);
|
|
2180
2219
|
}
|
|
2181
2220
|
SetFromCameraMatrix(matrix) {
|
|
2182
|
-
this.axesHelper.rotation.setFromRotationMatrix(new
|
|
2221
|
+
this.axesHelper.rotation.setFromRotationMatrix(new import_three15.Matrix4().extractRotation(matrix).invert());
|
|
2183
2222
|
}
|
|
2184
2223
|
};
|
|
2185
2224
|
|
|
@@ -2243,58 +2282,6 @@ var getObjectDelta = (a, b) => {
|
|
|
2243
2282
|
return delta;
|
|
2244
2283
|
};
|
|
2245
2284
|
|
|
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
2285
|
// src/dive.ts
|
|
2299
2286
|
var import_MathUtils2 = require("three/src/math/MathUtils");
|
|
2300
2287
|
|
|
@@ -2395,6 +2382,58 @@ var DIVEInfo = class {
|
|
|
2395
2382
|
};
|
|
2396
2383
|
DIVEInfo._supportsWebXR = null;
|
|
2397
2384
|
|
|
2385
|
+
// src/math/helper/shift.ts
|
|
2386
|
+
function shift(value, exponent) {
|
|
2387
|
+
const subvalues = (value + "e").split("e");
|
|
2388
|
+
return +(subvalues[0] + "e" + (+subvalues[1] + (exponent || 0)));
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
// src/math/ceil/ceilExp.ts
|
|
2392
|
+
function ceilExp(number, decimals = 0) {
|
|
2393
|
+
const n = shift(number, +decimals);
|
|
2394
|
+
return shift(Math.ceil(n), -decimals);
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
// src/math/floor/floorExp.ts
|
|
2398
|
+
function floorExp(number, decimals = 0) {
|
|
2399
|
+
const n = shift(number, +decimals);
|
|
2400
|
+
return shift(Math.floor(n), -decimals);
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
// src/math/round/roundExp.ts
|
|
2404
|
+
function roundExponential(number, decimals = 0) {
|
|
2405
|
+
if (number < 0) return -roundExponential(-number, decimals);
|
|
2406
|
+
const n = shift(number, +decimals);
|
|
2407
|
+
return shift(Math.round(n), -decimals);
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
// src/math/signedAngleTo/signedAngleTo.ts
|
|
2411
|
+
function signedAngleTo(vecA, vecB, planeNormal) {
|
|
2412
|
+
return Math.atan2(vecA.clone().cross(vecB).dot(planeNormal), vecB.clone().dot(vecA));
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
// src/math/toFixed/toFixedExp.ts
|
|
2416
|
+
function toFixedExp(number, decimals = 0) {
|
|
2417
|
+
const n = shift(number, +decimals);
|
|
2418
|
+
return shift(Math.round(n), -decimals).toFixed(decimals);
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
// src/math/truncate/truncateExp.ts
|
|
2422
|
+
function truncateExp(number, decimals = 0) {
|
|
2423
|
+
const n = shift(number, +decimals);
|
|
2424
|
+
return shift(Math.trunc(n), -decimals);
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
// src/math/index.ts
|
|
2428
|
+
var DIVEMath = {
|
|
2429
|
+
ceilExp,
|
|
2430
|
+
floorExp,
|
|
2431
|
+
roundExp: roundExponential,
|
|
2432
|
+
toFixedExp,
|
|
2433
|
+
truncateExp,
|
|
2434
|
+
signedAngleTo
|
|
2435
|
+
};
|
|
2436
|
+
|
|
2398
2437
|
// src/dive.ts
|
|
2399
2438
|
var DIVEDefaultSettings = {
|
|
2400
2439
|
autoResize: true,
|