@shopware-ag/dive 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dive.cjs +475 -452
- 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 +455 -432
- 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 -15
- 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 +50 -34
- package/src/primitive/__test__/Primitive.test.ts +39 -21
- 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,98 +1345,26 @@ 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;
|
|
1363
|
+
this._mesh.material = new import_three8.MeshStandardMaterial();
|
|
1480
1364
|
this.add(this._mesh);
|
|
1481
|
-
this._boundingBox = new
|
|
1365
|
+
this._boundingBox = new import_three8.Box3();
|
|
1482
1366
|
}
|
|
1483
1367
|
SetGeometry(geometry) {
|
|
1484
|
-
this.clear();
|
|
1485
1368
|
this._mesh.geometry = this.assembleGeometry(geometry);
|
|
1486
1369
|
this._boundingBox.setFromObject(this._mesh);
|
|
1487
1370
|
}
|
|
@@ -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);
|
|
@@ -1501,20 +1384,34 @@ var DIVEPrimitive = class extends import_three10.Object3D {
|
|
|
1501
1384
|
}
|
|
1502
1385
|
SetMaterial(material) {
|
|
1503
1386
|
const primitiveMaterial = this._mesh.material;
|
|
1504
|
-
if (material.
|
|
1505
|
-
|
|
1506
|
-
|
|
1387
|
+
if (material.vertexColors !== void 0) {
|
|
1388
|
+
primitiveMaterial.vertexColors = material.vertexColors;
|
|
1389
|
+
}
|
|
1390
|
+
if (material.color !== void 0) {
|
|
1391
|
+
primitiveMaterial.color = new import_three8.Color(material.color);
|
|
1392
|
+
}
|
|
1393
|
+
if (material.map !== void 0) {
|
|
1394
|
+
primitiveMaterial.map = material.map;
|
|
1395
|
+
}
|
|
1396
|
+
if (material.normalMap !== void 0) {
|
|
1397
|
+
primitiveMaterial.normalMap = material.normalMap;
|
|
1398
|
+
}
|
|
1399
|
+
if (material.roughness !== void 0) {
|
|
1400
|
+
primitiveMaterial.roughness = material.roughness;
|
|
1401
|
+
}
|
|
1507
1402
|
if (material.roughnessMap !== void 0) {
|
|
1508
1403
|
primitiveMaterial.roughnessMap = material.roughnessMap;
|
|
1509
1404
|
if (primitiveMaterial.roughnessMap) {
|
|
1510
1405
|
primitiveMaterial.roughness = 1;
|
|
1511
1406
|
}
|
|
1512
1407
|
}
|
|
1513
|
-
if (material.metalness !== void 0)
|
|
1408
|
+
if (material.metalness !== void 0) {
|
|
1409
|
+
primitiveMaterial.metalness = material.metalness;
|
|
1410
|
+
}
|
|
1514
1411
|
if (material.metalnessMap !== void 0) {
|
|
1515
1412
|
primitiveMaterial.metalnessMap = material.metalnessMap;
|
|
1516
1413
|
if (primitiveMaterial.metalnessMap) {
|
|
1517
|
-
primitiveMaterial.metalness =
|
|
1414
|
+
primitiveMaterial.metalness = 0;
|
|
1518
1415
|
}
|
|
1519
1416
|
}
|
|
1520
1417
|
if (this._mesh) this._mesh.material = primitiveMaterial;
|
|
@@ -1536,9 +1433,9 @@ var DIVEPrimitive = class extends import_three10.Object3D {
|
|
|
1536
1433
|
return;
|
|
1537
1434
|
}
|
|
1538
1435
|
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1539
|
-
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new
|
|
1436
|
+
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new import_three8.Vector3()).multiply(this.scale));
|
|
1540
1437
|
bbBottomCenter.y = bottomY + this.position.y;
|
|
1541
|
-
const raycaster = new
|
|
1438
|
+
const raycaster = new import_three8.Raycaster(bbBottomCenter, new import_three8.Vector3(0, -1, 0));
|
|
1542
1439
|
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1543
1440
|
const intersections = raycaster.intersectObjects(findSceneRecursive(this).Root.children, true);
|
|
1544
1441
|
if (intersections.length > 0) {
|
|
@@ -1547,7 +1444,7 @@ var DIVEPrimitive = class extends import_three10.Object3D {
|
|
|
1547
1444
|
const meshBB = mesh.geometry.boundingBox;
|
|
1548
1445
|
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1549
1446
|
const oldPos = this.position.clone();
|
|
1550
|
-
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));
|
|
1551
1448
|
this.position.copy(newPos);
|
|
1552
1449
|
if (this.position.y === oldPos.y) return;
|
|
1553
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 });
|
|
@@ -1582,212 +1479,131 @@ var DIVEPrimitive = class extends import_three10.Object3D {
|
|
|
1582
1479
|
case "plane":
|
|
1583
1480
|
return this.createPlaneGeometry(geometry);
|
|
1584
1481
|
default:
|
|
1585
|
-
return new
|
|
1482
|
+
return new import_three8.BufferGeometry();
|
|
1586
1483
|
}
|
|
1587
1484
|
}
|
|
1588
1485
|
createCylinderGeometry(geometry) {
|
|
1589
|
-
|
|
1486
|
+
const geo = new import_three8.CylinderGeometry(geometry.width / 2, geometry.width / 2, geometry.height, 64);
|
|
1487
|
+
geo.translate(0, geometry.height / 2, 0);
|
|
1488
|
+
return geo;
|
|
1590
1489
|
}
|
|
1591
1490
|
createSphereGeometry(geometry) {
|
|
1592
|
-
|
|
1491
|
+
const geo = new import_three8.SphereGeometry(geometry.width / 2, 256, 256);
|
|
1492
|
+
return geo;
|
|
1593
1493
|
}
|
|
1594
1494
|
createPyramidGeometry(geometry) {
|
|
1595
|
-
const geo = new
|
|
1596
|
-
|
|
1597
|
-
geo.
|
|
1598
|
-
width / 2,
|
|
1599
|
-
0,
|
|
1600
|
-
depth / 2,
|
|
1601
|
-
// right back
|
|
1602
|
-
width / 2,
|
|
1603
|
-
0,
|
|
1604
|
-
-depth / 2,
|
|
1605
|
-
// right front
|
|
1606
|
-
-width / 2,
|
|
1607
|
-
0,
|
|
1608
|
-
-depth / 2,
|
|
1609
|
-
// left front
|
|
1610
|
-
-width / 2,
|
|
1611
|
-
0,
|
|
1612
|
-
depth / 2,
|
|
1613
|
-
// left back
|
|
1614
|
-
0,
|
|
1615
|
-
height,
|
|
1616
|
-
0
|
|
1617
|
-
// top
|
|
1618
|
-
], 3));
|
|
1619
|
-
geo.setIndex(new import_three10.Uint32BufferAttribute([
|
|
1620
|
-
1,
|
|
1621
|
-
0,
|
|
1622
|
-
4,
|
|
1623
|
-
2,
|
|
1624
|
-
1,
|
|
1625
|
-
4,
|
|
1626
|
-
3,
|
|
1627
|
-
2,
|
|
1628
|
-
4,
|
|
1629
|
-
3,
|
|
1630
|
-
0,
|
|
1631
|
-
4,
|
|
1632
|
-
0,
|
|
1633
|
-
1,
|
|
1634
|
-
2,
|
|
1635
|
-
0,
|
|
1636
|
-
2,
|
|
1637
|
-
3
|
|
1638
|
-
], 1));
|
|
1495
|
+
const geo = new import_three8.ConeGeometry(geometry.width / 2, geometry.height, 4, 1, true);
|
|
1496
|
+
geo.rotateY(Math.PI / 4);
|
|
1497
|
+
geo.translate(0, geometry.height / 2, 0);
|
|
1639
1498
|
return geo;
|
|
1640
1499
|
}
|
|
1641
1500
|
createBoxGeometry(geometry) {
|
|
1642
|
-
|
|
1501
|
+
const geo = new import_three8.BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1502
|
+
geo.translate(0, geometry.height / 2, 0);
|
|
1503
|
+
return geo;
|
|
1643
1504
|
}
|
|
1644
1505
|
createConeGeometry(geometry) {
|
|
1645
|
-
|
|
1506
|
+
const geo = new import_three8.ConeGeometry(geometry.width / 2, geometry.height, 256);
|
|
1507
|
+
geo.translate(0, geometry.height / 2, 0);
|
|
1508
|
+
return geo;
|
|
1646
1509
|
}
|
|
1647
1510
|
createWallGeometry(geometry) {
|
|
1648
|
-
|
|
1511
|
+
const geo = new import_three8.BoxGeometry(geometry.width, geometry.height, geometry.depth || 0.05, 16);
|
|
1512
|
+
geo.translate(0, geometry.height / 2, 0);
|
|
1513
|
+
return geo;
|
|
1649
1514
|
}
|
|
1650
1515
|
createPlaneGeometry(geometry) {
|
|
1651
|
-
|
|
1516
|
+
const geo = new import_three8.BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1517
|
+
geo.translate(0, geometry.height / 2, 0);
|
|
1518
|
+
return geo;
|
|
1652
1519
|
}
|
|
1653
1520
|
};
|
|
1654
1521
|
|
|
1655
|
-
// src/
|
|
1656
|
-
var
|
|
1522
|
+
// src/group/Group.ts
|
|
1523
|
+
var import_three9 = require("three");
|
|
1524
|
+
var DIVEGroup = class extends import_three9.Object3D {
|
|
1657
1525
|
constructor() {
|
|
1658
1526
|
super();
|
|
1659
|
-
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);
|
|
1660
1535
|
}
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
console.warn("PrimitiveRoot.GetPrimitive: object.id is undefined");
|
|
1664
|
-
return void 0;
|
|
1665
|
-
}
|
|
1666
|
-
return this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1536
|
+
SetPosition(position) {
|
|
1537
|
+
this.position.set(position.x, position.y, position.z);
|
|
1667
1538
|
}
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
console.warn("PrimitiveRoot.UpdatePrimitive: object.id is undefined");
|
|
1671
|
-
return;
|
|
1672
|
-
}
|
|
1673
|
-
let sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1674
|
-
if (!sceneObject && object.geometry !== void 0) {
|
|
1675
|
-
const primitive = new DIVEPrimitive();
|
|
1676
|
-
primitive.SetGeometry(object.geometry);
|
|
1677
|
-
sceneObject = primitive;
|
|
1678
|
-
sceneObject.userData.id = object.id;
|
|
1679
|
-
this.add(sceneObject);
|
|
1680
|
-
}
|
|
1681
|
-
if (object.position !== void 0) sceneObject.SetPosition(object.position);
|
|
1682
|
-
if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
|
|
1683
|
-
if (object.scale !== void 0) sceneObject.SetScale(object.scale);
|
|
1684
|
-
if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
|
|
1685
|
-
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));
|
|
1686
1541
|
}
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
console.warn(`PrimitiveRoot.DeletePrimitive: Primitive with id ${object.id} not found`);
|
|
1695
|
-
return;
|
|
1696
|
-
}
|
|
1697
|
-
const findScene = (object2) => {
|
|
1698
|
-
if (object2.parent !== null) {
|
|
1699
|
-
return findScene(object2.parent);
|
|
1700
|
-
}
|
|
1701
|
-
;
|
|
1702
|
-
return object2;
|
|
1703
|
-
};
|
|
1704
|
-
const scene = findScene(sceneObject);
|
|
1705
|
-
scene.children.find((object2) => {
|
|
1706
|
-
if ("isTransformControls" in object2) {
|
|
1707
|
-
object2.detach();
|
|
1708
|
-
}
|
|
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;
|
|
1709
1549
|
});
|
|
1710
|
-
this.remove(sceneObject);
|
|
1711
1550
|
}
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1715
|
-
if (!sceneObject) return;
|
|
1716
|
-
sceneObject.PlaceOnFloor();
|
|
1551
|
+
SetBoundingBoxVisibility(visible) {
|
|
1552
|
+
this._boxMesh.visible = visible;
|
|
1717
1553
|
}
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
var DIVEFloor = class extends import_three12.Mesh {
|
|
1724
|
-
constructor() {
|
|
1725
|
-
super(new import_three12.PlaneGeometry(1e4, 1e4), new import_three12.MeshStandardMaterial({ color: new import_three12.Color(150 / 255, 150 / 255, 150 / 255) }));
|
|
1726
|
-
this.isFloor = true;
|
|
1727
|
-
this.name = "Floor";
|
|
1728
|
-
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1729
|
-
this.receiveShadow = true;
|
|
1730
|
-
this.rotateX(-Math.PI / 2);
|
|
1554
|
+
attach(object) {
|
|
1555
|
+
super.attach(object);
|
|
1556
|
+
this.recalculatePosition();
|
|
1557
|
+
this.updateBoxMesh();
|
|
1558
|
+
return this;
|
|
1731
1559
|
}
|
|
1732
|
-
|
|
1733
|
-
|
|
1560
|
+
remove(object) {
|
|
1561
|
+
super.remove(object);
|
|
1562
|
+
this.recalculatePosition();
|
|
1563
|
+
this.updateBoxMesh();
|
|
1564
|
+
return this;
|
|
1734
1565
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
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
|
+
});
|
|
1737
1578
|
}
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
super();
|
|
1750
|
-
this.name = "Grid";
|
|
1751
|
-
const grid = new import_three13.GridHelper(100, 100, GRID_CENTER_LINE_COLOR, GRID_SIDE_LINE_COLOR);
|
|
1752
|
-
grid.material.depthTest = false;
|
|
1753
|
-
grid.layers.mask = HELPER_LAYER_MASK;
|
|
1754
|
-
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());
|
|
1755
1590
|
}
|
|
1756
|
-
|
|
1757
|
-
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);
|
|
1758
1593
|
}
|
|
1759
1594
|
};
|
|
1760
1595
|
|
|
1761
1596
|
// src/scene/root/Root.ts
|
|
1762
|
-
var DIVERoot = class extends
|
|
1763
|
-
get Floor() {
|
|
1764
|
-
return this.floor;
|
|
1765
|
-
}
|
|
1766
|
-
get Grid() {
|
|
1767
|
-
return this.grid;
|
|
1768
|
-
}
|
|
1597
|
+
var DIVERoot = class extends import_three10.Object3D {
|
|
1769
1598
|
constructor() {
|
|
1770
1599
|
super();
|
|
1600
|
+
this.isDIVERoot = true;
|
|
1771
1601
|
this.name = "Root";
|
|
1772
|
-
this.
|
|
1773
|
-
this.add(this.lightRoot);
|
|
1774
|
-
this.modelRoot = new DIVEModelRoot();
|
|
1775
|
-
this.add(this.modelRoot);
|
|
1776
|
-
this.primitiveRoot = new DIVEPrimitiveRoot();
|
|
1777
|
-
this.add(this.primitiveRoot);
|
|
1778
|
-
this.floor = new DIVEFloor();
|
|
1779
|
-
this.add(this.floor);
|
|
1780
|
-
this.grid = new DIVEGrid();
|
|
1781
|
-
this.add(this.grid);
|
|
1602
|
+
this.loadingManager = new DIVELoadingManager();
|
|
1782
1603
|
}
|
|
1783
1604
|
ComputeSceneBB() {
|
|
1784
|
-
const bb = new
|
|
1785
|
-
this.
|
|
1786
|
-
if ("isObject3D" in object) {
|
|
1787
|
-
bb.expandByObject(object);
|
|
1788
|
-
}
|
|
1789
|
-
});
|
|
1790
|
-
this.primitiveRoot.traverse((object) => {
|
|
1605
|
+
const bb = new import_three10.Box3();
|
|
1606
|
+
this.traverse((object) => {
|
|
1791
1607
|
if ("isObject3D" in object) {
|
|
1792
1608
|
bb.expandByObject(object);
|
|
1793
1609
|
}
|
|
@@ -1795,20 +1611,7 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1795
1611
|
return bb;
|
|
1796
1612
|
}
|
|
1797
1613
|
GetSceneObject(object) {
|
|
1798
|
-
|
|
1799
|
-
case "pov": {
|
|
1800
|
-
return void 0;
|
|
1801
|
-
}
|
|
1802
|
-
case "light": {
|
|
1803
|
-
return this.lightRoot.GetLight(object);
|
|
1804
|
-
}
|
|
1805
|
-
case "model": {
|
|
1806
|
-
return this.modelRoot.GetModel(object);
|
|
1807
|
-
}
|
|
1808
|
-
case "primitive": {
|
|
1809
|
-
return this.primitiveRoot.GetPrimitive(object);
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1614
|
+
return this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1812
1615
|
}
|
|
1813
1616
|
AddSceneObject(object) {
|
|
1814
1617
|
switch (object.entityType) {
|
|
@@ -1816,15 +1619,19 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1816
1619
|
break;
|
|
1817
1620
|
}
|
|
1818
1621
|
case "light": {
|
|
1819
|
-
this.
|
|
1622
|
+
this.updateLight(object);
|
|
1820
1623
|
break;
|
|
1821
1624
|
}
|
|
1822
1625
|
case "model": {
|
|
1823
|
-
this.
|
|
1626
|
+
this.updateModel(object);
|
|
1824
1627
|
break;
|
|
1825
1628
|
}
|
|
1826
1629
|
case "primitive": {
|
|
1827
|
-
this.
|
|
1630
|
+
this.updatePrimitive(object);
|
|
1631
|
+
break;
|
|
1632
|
+
}
|
|
1633
|
+
case "group": {
|
|
1634
|
+
this.updateGroup(object);
|
|
1828
1635
|
break;
|
|
1829
1636
|
}
|
|
1830
1637
|
}
|
|
@@ -1835,15 +1642,19 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1835
1642
|
break;
|
|
1836
1643
|
}
|
|
1837
1644
|
case "light": {
|
|
1838
|
-
this.
|
|
1645
|
+
this.updateLight(object);
|
|
1839
1646
|
break;
|
|
1840
1647
|
}
|
|
1841
1648
|
case "model": {
|
|
1842
|
-
this.
|
|
1649
|
+
this.updateModel(object);
|
|
1843
1650
|
break;
|
|
1844
1651
|
}
|
|
1845
1652
|
case "primitive": {
|
|
1846
|
-
this.
|
|
1653
|
+
this.updatePrimitive(object);
|
|
1654
|
+
break;
|
|
1655
|
+
}
|
|
1656
|
+
case "group": {
|
|
1657
|
+
this.updateGroup(object);
|
|
1847
1658
|
break;
|
|
1848
1659
|
}
|
|
1849
1660
|
}
|
|
@@ -1854,15 +1665,19 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1854
1665
|
break;
|
|
1855
1666
|
}
|
|
1856
1667
|
case "light": {
|
|
1857
|
-
this.
|
|
1668
|
+
this.deleteLight(object);
|
|
1858
1669
|
break;
|
|
1859
1670
|
}
|
|
1860
1671
|
case "model": {
|
|
1861
|
-
this.
|
|
1672
|
+
this.deleteModel(object);
|
|
1862
1673
|
break;
|
|
1863
1674
|
}
|
|
1864
1675
|
case "primitive": {
|
|
1865
|
-
this.
|
|
1676
|
+
this.deletePrimitive(object);
|
|
1677
|
+
break;
|
|
1678
|
+
}
|
|
1679
|
+
case "group": {
|
|
1680
|
+
this.deleteGroup(object);
|
|
1866
1681
|
break;
|
|
1867
1682
|
}
|
|
1868
1683
|
}
|
|
@@ -1873,31 +1688,239 @@ var DIVERoot = class extends import_three14.Object3D {
|
|
|
1873
1688
|
case "light": {
|
|
1874
1689
|
break;
|
|
1875
1690
|
}
|
|
1876
|
-
case "model":
|
|
1877
|
-
this.modelRoot.PlaceOnFloor(object);
|
|
1878
|
-
break;
|
|
1879
|
-
}
|
|
1691
|
+
case "model":
|
|
1880
1692
|
case "primitive": {
|
|
1881
|
-
this.
|
|
1693
|
+
this.placeOnFloor(object);
|
|
1882
1694
|
break;
|
|
1883
1695
|
}
|
|
1884
1696
|
}
|
|
1885
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
|
+
}
|
|
1886
1899
|
};
|
|
1887
1900
|
|
|
1888
1901
|
// src/scene/Scene.ts
|
|
1889
|
-
var DIVEScene = class extends
|
|
1902
|
+
var DIVEScene = class extends import_three13.Scene {
|
|
1890
1903
|
get Root() {
|
|
1891
1904
|
return this.root;
|
|
1892
1905
|
}
|
|
1906
|
+
get Floor() {
|
|
1907
|
+
return this.floor;
|
|
1908
|
+
}
|
|
1909
|
+
get Grid() {
|
|
1910
|
+
return this.grid;
|
|
1911
|
+
}
|
|
1893
1912
|
constructor() {
|
|
1894
1913
|
super();
|
|
1895
|
-
this.background = new
|
|
1914
|
+
this.background = new import_three13.Color(16777215);
|
|
1896
1915
|
this.root = new DIVERoot();
|
|
1897
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);
|
|
1898
1921
|
}
|
|
1899
1922
|
SetBackground(color) {
|
|
1900
|
-
this.background = new
|
|
1923
|
+
this.background = new import_three13.Color(color);
|
|
1901
1924
|
}
|
|
1902
1925
|
ComputeSceneBB() {
|
|
1903
1926
|
return this.Root.ComputeSceneBB();
|
|
@@ -1906,7 +1929,7 @@ var DIVEScene = class extends import_three15.Scene {
|
|
|
1906
1929
|
return this.Root.GetSceneObject(object);
|
|
1907
1930
|
}
|
|
1908
1931
|
AddSceneObject(object) {
|
|
1909
|
-
this.Root.
|
|
1932
|
+
this.Root.AddSceneObject(object);
|
|
1910
1933
|
}
|
|
1911
1934
|
UpdateSceneObject(object) {
|
|
1912
1935
|
this.Root.UpdateSceneObject(object);
|
|
@@ -1924,7 +1947,7 @@ init_PerspectiveCamera();
|
|
|
1924
1947
|
|
|
1925
1948
|
// src/controls/OrbitControls.ts
|
|
1926
1949
|
var import_OrbitControls = require("three/examples/jsm/controls/OrbitControls");
|
|
1927
|
-
var
|
|
1950
|
+
var import_three14 = require("three");
|
|
1928
1951
|
var import_tween = require("@tweenjs/tween.js");
|
|
1929
1952
|
var DIVEOrbitControlsDefaultSettings = {
|
|
1930
1953
|
enableDamping: true,
|
|
@@ -1966,8 +1989,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
1966
1989
|
this.dispose();
|
|
1967
1990
|
}
|
|
1968
1991
|
ComputeEncompassingView(bb) {
|
|
1969
|
-
const center = bb.getCenter(new
|
|
1970
|
-
const size = bb.getSize(new
|
|
1992
|
+
const center = bb.getCenter(new import_three14.Vector3());
|
|
1993
|
+
const size = bb.getSize(new import_three14.Vector3());
|
|
1971
1994
|
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
1972
1995
|
const direction = this.object.position.clone().normalize();
|
|
1973
1996
|
return {
|
|
@@ -1978,7 +2001,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
1978
2001
|
ZoomIn(by) {
|
|
1979
2002
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
1980
2003
|
const { minDistance, maxDistance } = this;
|
|
1981
|
-
this.minDistance = this.maxDistance =
|
|
2004
|
+
this.minDistance = this.maxDistance = import_three14.MathUtils.clamp(this.getDistance() - zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
1982
2005
|
this.update();
|
|
1983
2006
|
this.minDistance = minDistance;
|
|
1984
2007
|
this.maxDistance = maxDistance;
|
|
@@ -1986,7 +2009,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
1986
2009
|
ZoomOut(by) {
|
|
1987
2010
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
1988
2011
|
const { minDistance, maxDistance } = this;
|
|
1989
|
-
this.minDistance = this.maxDistance =
|
|
2012
|
+
this.minDistance = this.maxDistance = import_three14.MathUtils.clamp(this.getDistance() + zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
1990
2013
|
this.update();
|
|
1991
2014
|
this.minDistance = minDistance;
|
|
1992
2015
|
this.maxDistance = maxDistance;
|
|
@@ -2134,7 +2157,7 @@ var DIVEAnimationSystem = class {
|
|
|
2134
2157
|
};
|
|
2135
2158
|
|
|
2136
2159
|
// src/axiscamera/AxisCamera.ts
|
|
2137
|
-
var
|
|
2160
|
+
var import_three15 = require("three");
|
|
2138
2161
|
var import_three_spritetext = __toESM(require("three-spritetext"), 1);
|
|
2139
2162
|
init_VisibilityLayerMask();
|
|
2140
2163
|
|
|
@@ -2147,18 +2170,18 @@ var AxesColorGreen = AxesColorGreenLetter;
|
|
|
2147
2170
|
var AxesColorBlue = AxesColorBlueLetter;
|
|
2148
2171
|
|
|
2149
2172
|
// src/axiscamera/AxisCamera.ts
|
|
2150
|
-
var DIVEAxisCamera = class extends
|
|
2173
|
+
var DIVEAxisCamera = class extends import_three15.OrthographicCamera {
|
|
2151
2174
|
constructor(renderer, scene, controls) {
|
|
2152
2175
|
super(-1, 1, 1, -1, 0.1, 100);
|
|
2153
2176
|
this.layers.mask = COORDINATE_LAYER_MASK;
|
|
2154
|
-
this.axesHelper = new
|
|
2177
|
+
this.axesHelper = new import_three15.AxesHelper(0.5);
|
|
2155
2178
|
this.axesHelper.layers.mask = COORDINATE_LAYER_MASK;
|
|
2156
2179
|
this.axesHelper.material.depthTest = false;
|
|
2157
2180
|
this.axesHelper.position.set(0, 0, -1);
|
|
2158
2181
|
this.axesHelper.setColors(
|
|
2159
|
-
new
|
|
2160
|
-
new
|
|
2161
|
-
new
|
|
2182
|
+
new import_three15.Color(AxesColorRed),
|
|
2183
|
+
new import_three15.Color(AxesColorGreen),
|
|
2184
|
+
new import_three15.Color(AxesColorBlue)
|
|
2162
2185
|
);
|
|
2163
2186
|
const x = new import_three_spritetext.default("X", 0.2, AxesColorRedLetter);
|
|
2164
2187
|
const y = new import_three_spritetext.default("Y", 0.2, AxesColorGreenLetter);
|
|
@@ -2176,7 +2199,7 @@ var DIVEAxisCamera = class extends import_three17.OrthographicCamera {
|
|
|
2176
2199
|
this._renderer = renderer;
|
|
2177
2200
|
this._scene = scene;
|
|
2178
2201
|
this._scene.add(this);
|
|
2179
|
-
const restoreViewport = new
|
|
2202
|
+
const restoreViewport = new import_three15.Vector4();
|
|
2180
2203
|
this._renderCallbackId = renderer.AddPostRenderCallback(() => {
|
|
2181
2204
|
const restoreBackground = scene.background;
|
|
2182
2205
|
scene.background = null;
|
|
@@ -2195,7 +2218,7 @@ var DIVEAxisCamera = class extends import_three17.OrthographicCamera {
|
|
|
2195
2218
|
this._scene.remove(this);
|
|
2196
2219
|
}
|
|
2197
2220
|
SetFromCameraMatrix(matrix) {
|
|
2198
|
-
this.axesHelper.rotation.setFromRotationMatrix(new
|
|
2221
|
+
this.axesHelper.rotation.setFromRotationMatrix(new import_three15.Matrix4().extractRotation(matrix).invert());
|
|
2199
2222
|
}
|
|
2200
2223
|
};
|
|
2201
2224
|
|
|
@@ -2259,58 +2282,6 @@ var getObjectDelta = (a, b) => {
|
|
|
2259
2282
|
return delta;
|
|
2260
2283
|
};
|
|
2261
2284
|
|
|
2262
|
-
// src/math/helper/shift.ts
|
|
2263
|
-
function shift(value, exponent) {
|
|
2264
|
-
const subvalues = (value + "e").split("e");
|
|
2265
|
-
return +(subvalues[0] + "e" + (+subvalues[1] + (exponent || 0)));
|
|
2266
|
-
}
|
|
2267
|
-
|
|
2268
|
-
// src/math/ceil/ceilExp.ts
|
|
2269
|
-
function ceilExp(number, decimals = 0) {
|
|
2270
|
-
const n = shift(number, +decimals);
|
|
2271
|
-
return shift(Math.ceil(n), -decimals);
|
|
2272
|
-
}
|
|
2273
|
-
|
|
2274
|
-
// src/math/floor/floorExp.ts
|
|
2275
|
-
function floorExp(number, decimals = 0) {
|
|
2276
|
-
const n = shift(number, +decimals);
|
|
2277
|
-
return shift(Math.floor(n), -decimals);
|
|
2278
|
-
}
|
|
2279
|
-
|
|
2280
|
-
// src/math/round/roundExp.ts
|
|
2281
|
-
function roundExponential(number, decimals = 0) {
|
|
2282
|
-
if (number < 0) return -roundExponential(-number, decimals);
|
|
2283
|
-
const n = shift(number, +decimals);
|
|
2284
|
-
return shift(Math.round(n), -decimals);
|
|
2285
|
-
}
|
|
2286
|
-
|
|
2287
|
-
// src/math/signedAngleTo/signedAngleTo.ts
|
|
2288
|
-
function signedAngleTo(vecA, vecB, planeNormal) {
|
|
2289
|
-
return Math.atan2(vecA.clone().cross(vecB).dot(planeNormal), vecB.clone().dot(vecA));
|
|
2290
|
-
}
|
|
2291
|
-
|
|
2292
|
-
// src/math/toFixed/toFixedExp.ts
|
|
2293
|
-
function toFixedExp(number, decimals = 0) {
|
|
2294
|
-
const n = shift(number, +decimals);
|
|
2295
|
-
return shift(Math.round(n), -decimals).toFixed(decimals);
|
|
2296
|
-
}
|
|
2297
|
-
|
|
2298
|
-
// src/math/truncate/truncateExp.ts
|
|
2299
|
-
function truncateExp(number, decimals = 0) {
|
|
2300
|
-
const n = shift(number, +decimals);
|
|
2301
|
-
return shift(Math.trunc(n), -decimals);
|
|
2302
|
-
}
|
|
2303
|
-
|
|
2304
|
-
// src/math/index.ts
|
|
2305
|
-
var DIVEMath = {
|
|
2306
|
-
ceilExp,
|
|
2307
|
-
floorExp,
|
|
2308
|
-
roundExp: roundExponential,
|
|
2309
|
-
toFixedExp,
|
|
2310
|
-
truncateExp,
|
|
2311
|
-
signedAngleTo
|
|
2312
|
-
};
|
|
2313
|
-
|
|
2314
2285
|
// src/dive.ts
|
|
2315
2286
|
var import_MathUtils2 = require("three/src/math/MathUtils");
|
|
2316
2287
|
|
|
@@ -2411,6 +2382,58 @@ var DIVEInfo = class {
|
|
|
2411
2382
|
};
|
|
2412
2383
|
DIVEInfo._supportsWebXR = null;
|
|
2413
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
|
+
|
|
2414
2437
|
// src/dive.ts
|
|
2415
2438
|
var DIVEDefaultSettings = {
|
|
2416
2439
|
autoResize: true,
|