@shopware-ag/dive 1.14.0 → 1.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dive.cjs +111 -161
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +20 -36
- package/build/dive.d.ts +20 -36
- package/build/dive.js +69 -119
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/com/Communication.ts +2 -1
- package/src/com/__test__/Communication.test.ts +3 -2
- package/src/com/actions/scene/getallscenedata.ts +3 -2
- package/src/group/Group.ts +13 -42
- package/src/group/__test__/Group.test.ts +9 -17
- package/src/model/Model.ts +8 -58
- package/src/model/__test__/Model.test.ts +1 -56
- package/src/node/Node.ts +58 -0
- package/src/node/__test__/Node.test.ts +229 -0
- package/src/primitive/Primitive.ts +3 -49
- package/src/primitive/__test__/Primitive.test.ts +0 -55
package/build/dive.cjs
CHANGED
|
@@ -671,10 +671,10 @@ var DIVERenderer = class extends import_three.WebGLRenderer {
|
|
|
671
671
|
};
|
|
672
672
|
|
|
673
673
|
// src/scene/Scene.ts
|
|
674
|
-
var
|
|
674
|
+
var import_three14 = require("three");
|
|
675
675
|
|
|
676
676
|
// src/scene/root/Root.ts
|
|
677
|
-
var
|
|
677
|
+
var import_three11 = require("three");
|
|
678
678
|
|
|
679
679
|
// src/light/AmbientLight.ts
|
|
680
680
|
var import_three2 = require("three");
|
|
@@ -878,7 +878,8 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
878
878
|
spotmarks: [],
|
|
879
879
|
lights: Array.from(this.registered.values()).filter((object) => object.entityType === "light"),
|
|
880
880
|
objects: Array.from(this.registered.values()).filter((object) => object.entityType === "model"),
|
|
881
|
-
cameras: Array.from(this.registered.values()).filter((object) => object.entityType === "pov")
|
|
881
|
+
cameras: Array.from(this.registered.values()).filter((object) => object.entityType === "pov"),
|
|
882
|
+
primitives: Array.from(this.registered.values()).filter((object) => object.entityType === "primitive")
|
|
882
883
|
};
|
|
883
884
|
Object.assign(payload, sceneData);
|
|
884
885
|
return sceneData;
|
|
@@ -1171,7 +1172,7 @@ var DIVESceneLight = class extends import_three6.Object3D {
|
|
|
1171
1172
|
};
|
|
1172
1173
|
|
|
1173
1174
|
// src/model/Model.ts
|
|
1174
|
-
var
|
|
1175
|
+
var import_three8 = require("three");
|
|
1175
1176
|
init_VisibilityLayerMask();
|
|
1176
1177
|
|
|
1177
1178
|
// src/helper/findSceneRecursive/findSceneRecursive.ts
|
|
@@ -1182,18 +1183,57 @@ var findSceneRecursive = (object) => {
|
|
|
1182
1183
|
return object;
|
|
1183
1184
|
};
|
|
1184
1185
|
|
|
1185
|
-
// src/
|
|
1186
|
-
var
|
|
1186
|
+
// src/node/Node.ts
|
|
1187
|
+
var import_three7 = require("three");
|
|
1188
|
+
init_VisibilityLayerMask();
|
|
1189
|
+
var DIVENode = class extends import_three7.Object3D {
|
|
1187
1190
|
constructor() {
|
|
1188
1191
|
super();
|
|
1189
|
-
this.
|
|
1192
|
+
this.isDIVENode = true;
|
|
1190
1193
|
this.isSelectable = true;
|
|
1191
1194
|
this.isMoveable = true;
|
|
1192
1195
|
this.gizmo = null;
|
|
1196
|
+
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1197
|
+
this._boundingBox = new import_three7.Box3();
|
|
1198
|
+
}
|
|
1199
|
+
SetPosition(position) {
|
|
1200
|
+
this.position.set(position.x, position.y, position.z);
|
|
1201
|
+
}
|
|
1202
|
+
SetRotation(rotation) {
|
|
1203
|
+
this.rotation.set(rotation.x, rotation.y, rotation.z);
|
|
1204
|
+
}
|
|
1205
|
+
SetScale(scale) {
|
|
1206
|
+
this.scale.set(scale.x, scale.y, scale.z);
|
|
1207
|
+
}
|
|
1208
|
+
SetVisibility(visible) {
|
|
1209
|
+
this.visible = visible;
|
|
1210
|
+
}
|
|
1211
|
+
SetToWorldOrigin() {
|
|
1212
|
+
var _a;
|
|
1213
|
+
this.position.set(0, 0, 0);
|
|
1214
|
+
(_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 });
|
|
1215
|
+
}
|
|
1216
|
+
onMove() {
|
|
1217
|
+
var _a;
|
|
1218
|
+
(_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 });
|
|
1219
|
+
}
|
|
1220
|
+
onSelect() {
|
|
1221
|
+
var _a;
|
|
1222
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1223
|
+
}
|
|
1224
|
+
onDeselect() {
|
|
1225
|
+
var _a;
|
|
1226
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
|
|
1230
|
+
// src/model/Model.ts
|
|
1231
|
+
var DIVEModel = class extends DIVENode {
|
|
1232
|
+
constructor() {
|
|
1233
|
+
super(...arguments);
|
|
1234
|
+
this.isDIVEModel = true;
|
|
1193
1235
|
this._mesh = null;
|
|
1194
1236
|
this._material = null;
|
|
1195
|
-
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1196
|
-
this.boundingBox = new import_three7.Box3();
|
|
1197
1237
|
}
|
|
1198
1238
|
SetModel(gltf) {
|
|
1199
1239
|
this.clear();
|
|
@@ -1201,7 +1241,7 @@ var DIVEModel = class extends import_three7.Object3D {
|
|
|
1201
1241
|
child.castShadow = true;
|
|
1202
1242
|
child.receiveShadow = true;
|
|
1203
1243
|
child.layers.mask = this.layers.mask;
|
|
1204
|
-
this.
|
|
1244
|
+
this._boundingBox.expandByObject(child);
|
|
1205
1245
|
if (!this._mesh && "isMesh" in child) {
|
|
1206
1246
|
this._mesh = child;
|
|
1207
1247
|
if (this._material) {
|
|
@@ -1213,23 +1253,9 @@ var DIVEModel = class extends import_three7.Object3D {
|
|
|
1213
1253
|
});
|
|
1214
1254
|
this.add(gltf.scene);
|
|
1215
1255
|
}
|
|
1216
|
-
SetPosition(position) {
|
|
1217
|
-
this.position.set(position.x, position.y, position.z);
|
|
1218
|
-
}
|
|
1219
|
-
SetRotation(rotation) {
|
|
1220
|
-
this.rotation.setFromVector3(new import_three7.Vector3(rotation.x, rotation.y, rotation.z));
|
|
1221
|
-
}
|
|
1222
|
-
SetScale(scale) {
|
|
1223
|
-
this.scale.set(scale.x, scale.y, scale.z);
|
|
1224
|
-
}
|
|
1225
|
-
SetVisibility(visible) {
|
|
1226
|
-
this.traverse((child) => {
|
|
1227
|
-
child.visible = visible;
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1230
1256
|
SetMaterial(material) {
|
|
1231
1257
|
if (!this._material) {
|
|
1232
|
-
this._material = new
|
|
1258
|
+
this._material = new import_three8.MeshStandardMaterial();
|
|
1233
1259
|
}
|
|
1234
1260
|
if (material.vertexColors !== void 0) {
|
|
1235
1261
|
this._material.vertexColors = material.vertexColors;
|
|
@@ -1265,14 +1291,9 @@ var DIVEModel = class extends import_three7.Object3D {
|
|
|
1265
1291
|
this._mesh.material = this._material;
|
|
1266
1292
|
}
|
|
1267
1293
|
}
|
|
1268
|
-
SetToWorldOrigin() {
|
|
1269
|
-
var _a;
|
|
1270
|
-
this.position.set(0, 0, 0);
|
|
1271
|
-
(_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 });
|
|
1272
|
-
}
|
|
1273
1294
|
PlaceOnFloor() {
|
|
1274
1295
|
var _a;
|
|
1275
|
-
this.position.y = -this.
|
|
1296
|
+
this.position.y = -this._boundingBox.min.y * this.scale.y;
|
|
1276
1297
|
(_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 });
|
|
1277
1298
|
}
|
|
1278
1299
|
DropIt() {
|
|
@@ -1281,10 +1302,10 @@ var DIVEModel = class extends import_three7.Object3D {
|
|
|
1281
1302
|
console.warn("DIVEModel: DropIt() called on a model that is not in the scene.", this);
|
|
1282
1303
|
return;
|
|
1283
1304
|
}
|
|
1284
|
-
const bottomY = this.
|
|
1285
|
-
const bbBottomCenter = this.localToWorld(this.
|
|
1305
|
+
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1306
|
+
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new import_three8.Vector3()).multiply(this.scale));
|
|
1286
1307
|
bbBottomCenter.y = bottomY + this.position.y;
|
|
1287
|
-
const raycaster = new
|
|
1308
|
+
const raycaster = new import_three8.Raycaster(bbBottomCenter, new import_three8.Vector3(0, -1, 0));
|
|
1288
1309
|
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1289
1310
|
const intersections = raycaster.intersectObjects(findSceneRecursive(this).Root.children, true);
|
|
1290
1311
|
if (intersections.length > 0) {
|
|
@@ -1293,24 +1314,12 @@ var DIVEModel = class extends import_three7.Object3D {
|
|
|
1293
1314
|
const meshBB = mesh.geometry.boundingBox;
|
|
1294
1315
|
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1295
1316
|
const oldPos = this.position.clone();
|
|
1296
|
-
const newPos = this.position.clone().setY(worldPos.y).sub(new
|
|
1317
|
+
const newPos = this.position.clone().setY(worldPos.y).sub(new import_three8.Vector3(0, bottomY, 0));
|
|
1297
1318
|
this.position.copy(newPos);
|
|
1298
1319
|
if (this.position.y === oldPos.y) return;
|
|
1299
1320
|
(_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 });
|
|
1300
1321
|
}
|
|
1301
1322
|
}
|
|
1302
|
-
onMove() {
|
|
1303
|
-
var _a;
|
|
1304
|
-
(_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 });
|
|
1305
|
-
}
|
|
1306
|
-
onSelect() {
|
|
1307
|
-
var _a;
|
|
1308
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1309
|
-
}
|
|
1310
|
-
onDeselect() {
|
|
1311
|
-
var _a;
|
|
1312
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1313
|
-
}
|
|
1314
1323
|
};
|
|
1315
1324
|
|
|
1316
1325
|
// src/loadingmanager/LoadingManager.ts
|
|
@@ -1346,49 +1355,30 @@ var DIVELoadingManager = class {
|
|
|
1346
1355
|
};
|
|
1347
1356
|
|
|
1348
1357
|
// src/primitive/Primitive.ts
|
|
1349
|
-
var
|
|
1358
|
+
var import_three9 = require("three");
|
|
1350
1359
|
init_VisibilityLayerMask();
|
|
1351
|
-
var DIVEPrimitive = class extends
|
|
1360
|
+
var DIVEPrimitive = class extends DIVENode {
|
|
1352
1361
|
constructor() {
|
|
1353
1362
|
super();
|
|
1354
1363
|
this.isDIVEPrimitive = true;
|
|
1355
|
-
this.
|
|
1356
|
-
this.isMoveable = true;
|
|
1357
|
-
this.gizmo = null;
|
|
1358
|
-
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1359
|
-
this._mesh = new import_three8.Mesh();
|
|
1364
|
+
this._mesh = new import_three9.Mesh();
|
|
1360
1365
|
this._mesh.layers.mask = PRODUCT_LAYER_MASK;
|
|
1361
1366
|
this._mesh.castShadow = true;
|
|
1362
1367
|
this._mesh.receiveShadow = true;
|
|
1363
|
-
this._mesh.material = new
|
|
1368
|
+
this._mesh.material = new import_three9.MeshStandardMaterial();
|
|
1364
1369
|
this.add(this._mesh);
|
|
1365
|
-
this._boundingBox = new import_three8.Box3();
|
|
1366
1370
|
}
|
|
1367
1371
|
SetGeometry(geometry) {
|
|
1368
1372
|
this._mesh.geometry = this.assembleGeometry(geometry);
|
|
1369
1373
|
this._boundingBox.setFromObject(this._mesh);
|
|
1370
1374
|
}
|
|
1371
|
-
SetPosition(position) {
|
|
1372
|
-
this.position.set(position.x, position.y, position.z);
|
|
1373
|
-
}
|
|
1374
|
-
SetRotation(rotation) {
|
|
1375
|
-
this.rotation.setFromVector3(new import_three8.Vector3(rotation.x, rotation.y, rotation.z));
|
|
1376
|
-
}
|
|
1377
|
-
SetScale(scale) {
|
|
1378
|
-
this.scale.set(scale.x, scale.y, scale.z);
|
|
1379
|
-
}
|
|
1380
|
-
SetVisibility(visible) {
|
|
1381
|
-
this.traverse((child) => {
|
|
1382
|
-
child.visible = visible;
|
|
1383
|
-
});
|
|
1384
|
-
}
|
|
1385
1375
|
SetMaterial(material) {
|
|
1386
1376
|
const primitiveMaterial = this._mesh.material;
|
|
1387
1377
|
if (material.vertexColors !== void 0) {
|
|
1388
1378
|
primitiveMaterial.vertexColors = material.vertexColors;
|
|
1389
1379
|
}
|
|
1390
1380
|
if (material.color !== void 0) {
|
|
1391
|
-
primitiveMaterial.color = new
|
|
1381
|
+
primitiveMaterial.color = new import_three9.Color(material.color);
|
|
1392
1382
|
}
|
|
1393
1383
|
if (material.map !== void 0) {
|
|
1394
1384
|
primitiveMaterial.map = material.map;
|
|
@@ -1416,11 +1406,6 @@ var DIVEPrimitive = class extends import_three8.Object3D {
|
|
|
1416
1406
|
}
|
|
1417
1407
|
if (this._mesh) this._mesh.material = primitiveMaterial;
|
|
1418
1408
|
}
|
|
1419
|
-
SetToWorldOrigin() {
|
|
1420
|
-
var _a;
|
|
1421
|
-
this.position.set(0, 0, 0);
|
|
1422
|
-
(_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 });
|
|
1423
|
-
}
|
|
1424
1409
|
PlaceOnFloor() {
|
|
1425
1410
|
var _a;
|
|
1426
1411
|
this.position.y = -this._boundingBox.min.y * this.scale.y;
|
|
@@ -1433,9 +1418,9 @@ var DIVEPrimitive = class extends import_three8.Object3D {
|
|
|
1433
1418
|
return;
|
|
1434
1419
|
}
|
|
1435
1420
|
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1436
|
-
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new
|
|
1421
|
+
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new import_three9.Vector3()).multiply(this.scale));
|
|
1437
1422
|
bbBottomCenter.y = bottomY + this.position.y;
|
|
1438
|
-
const raycaster = new
|
|
1423
|
+
const raycaster = new import_three9.Raycaster(bbBottomCenter, new import_three9.Vector3(0, -1, 0));
|
|
1439
1424
|
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1440
1425
|
const intersections = raycaster.intersectObjects(findSceneRecursive(this).Root.children, true);
|
|
1441
1426
|
if (intersections.length > 0) {
|
|
@@ -1444,24 +1429,12 @@ var DIVEPrimitive = class extends import_three8.Object3D {
|
|
|
1444
1429
|
const meshBB = mesh.geometry.boundingBox;
|
|
1445
1430
|
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1446
1431
|
const oldPos = this.position.clone();
|
|
1447
|
-
const newPos = this.position.clone().setY(worldPos.y).sub(new
|
|
1432
|
+
const newPos = this.position.clone().setY(worldPos.y).sub(new import_three9.Vector3(0, bottomY, 0));
|
|
1448
1433
|
this.position.copy(newPos);
|
|
1449
1434
|
if (this.position.y === oldPos.y) return;
|
|
1450
1435
|
(_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 });
|
|
1451
1436
|
}
|
|
1452
1437
|
}
|
|
1453
|
-
onMove() {
|
|
1454
|
-
var _a;
|
|
1455
|
-
(_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 });
|
|
1456
|
-
}
|
|
1457
|
-
onSelect() {
|
|
1458
|
-
var _a;
|
|
1459
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1460
|
-
}
|
|
1461
|
-
onDeselect() {
|
|
1462
|
-
var _a;
|
|
1463
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1464
|
-
}
|
|
1465
1438
|
assembleGeometry(geometry) {
|
|
1466
1439
|
switch (geometry.name) {
|
|
1467
1440
|
case "cylinder":
|
|
@@ -1479,75 +1452,57 @@ var DIVEPrimitive = class extends import_three8.Object3D {
|
|
|
1479
1452
|
case "plane":
|
|
1480
1453
|
return this.createPlaneGeometry(geometry);
|
|
1481
1454
|
default:
|
|
1482
|
-
return new
|
|
1455
|
+
return new import_three9.BufferGeometry();
|
|
1483
1456
|
}
|
|
1484
1457
|
}
|
|
1485
1458
|
createCylinderGeometry(geometry) {
|
|
1486
|
-
const geo = new
|
|
1459
|
+
const geo = new import_three9.CylinderGeometry(geometry.width / 2, geometry.width / 2, geometry.height, 64);
|
|
1487
1460
|
geo.translate(0, geometry.height / 2, 0);
|
|
1488
1461
|
return geo;
|
|
1489
1462
|
}
|
|
1490
1463
|
createSphereGeometry(geometry) {
|
|
1491
|
-
const geo = new
|
|
1464
|
+
const geo = new import_three9.SphereGeometry(geometry.width / 2, 256, 256);
|
|
1492
1465
|
return geo;
|
|
1493
1466
|
}
|
|
1494
1467
|
createPyramidGeometry(geometry) {
|
|
1495
|
-
const geo = new
|
|
1468
|
+
const geo = new import_three9.ConeGeometry(geometry.width / 2, geometry.height, 4, 1, true);
|
|
1496
1469
|
geo.rotateY(Math.PI / 4);
|
|
1497
1470
|
geo.translate(0, geometry.height / 2, 0);
|
|
1498
1471
|
return geo;
|
|
1499
1472
|
}
|
|
1500
1473
|
createBoxGeometry(geometry) {
|
|
1501
|
-
const geo = new
|
|
1474
|
+
const geo = new import_three9.BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1502
1475
|
geo.translate(0, geometry.height / 2, 0);
|
|
1503
1476
|
return geo;
|
|
1504
1477
|
}
|
|
1505
1478
|
createConeGeometry(geometry) {
|
|
1506
|
-
const geo = new
|
|
1479
|
+
const geo = new import_three9.ConeGeometry(geometry.width / 2, geometry.height, 256);
|
|
1507
1480
|
geo.translate(0, geometry.height / 2, 0);
|
|
1508
1481
|
return geo;
|
|
1509
1482
|
}
|
|
1510
1483
|
createWallGeometry(geometry) {
|
|
1511
|
-
const geo = new
|
|
1484
|
+
const geo = new import_three9.BoxGeometry(geometry.width, geometry.height, geometry.depth || 0.05, 16);
|
|
1512
1485
|
geo.translate(0, geometry.height / 2, 0);
|
|
1513
1486
|
return geo;
|
|
1514
1487
|
}
|
|
1515
1488
|
createPlaneGeometry(geometry) {
|
|
1516
|
-
const geo = new
|
|
1489
|
+
const geo = new import_three9.BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1517
1490
|
geo.translate(0, geometry.height / 2, 0);
|
|
1518
1491
|
return geo;
|
|
1519
1492
|
}
|
|
1520
1493
|
};
|
|
1521
1494
|
|
|
1522
1495
|
// src/group/Group.ts
|
|
1523
|
-
var
|
|
1524
|
-
var DIVEGroup = class extends
|
|
1496
|
+
var import_three10 = require("three");
|
|
1497
|
+
var DIVEGroup = class extends DIVENode {
|
|
1525
1498
|
constructor() {
|
|
1526
1499
|
super();
|
|
1527
1500
|
this.isDIVEGroup = true;
|
|
1528
|
-
this.isSelectable = true;
|
|
1529
|
-
this.isMoveable = true;
|
|
1530
1501
|
this.name = "DIVEGroup";
|
|
1531
|
-
this.
|
|
1532
|
-
this._boxMesh = new import_three9.Mesh(new import_three9.BoxGeometry(0, 0, 0), new import_three9.MeshBasicMaterial({ color: 16711680, wireframe: true }));
|
|
1502
|
+
this._boxMesh = new import_three10.Mesh(new import_three10.BoxGeometry(0, 0, 0), new import_three10.MeshBasicMaterial({ color: 16711680, wireframe: true }));
|
|
1533
1503
|
this._boxMesh.visible = false;
|
|
1534
1504
|
this.add(this._boxMesh);
|
|
1535
1505
|
}
|
|
1536
|
-
SetPosition(position) {
|
|
1537
|
-
this.position.set(position.x, position.y, position.z);
|
|
1538
|
-
}
|
|
1539
|
-
SetRotation(rotation) {
|
|
1540
|
-
this.rotation.setFromVector3(new import_three9.Vector3(rotation.x, rotation.y, rotation.z));
|
|
1541
|
-
}
|
|
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;
|
|
1549
|
-
});
|
|
1550
|
-
}
|
|
1551
1506
|
SetBoundingBoxVisibility(visible) {
|
|
1552
1507
|
this._boxMesh.visible = visible;
|
|
1553
1508
|
}
|
|
@@ -1569,7 +1524,7 @@ var DIVEGroup = class extends import_three9.Object3D {
|
|
|
1569
1524
|
*/
|
|
1570
1525
|
recalculatePosition() {
|
|
1571
1526
|
var _a;
|
|
1572
|
-
const childrensWorldPositions = this.children.map((child) => child.getWorldPosition(new
|
|
1527
|
+
const childrensWorldPositions = this.children.map((child) => child.getWorldPosition(new import_three10.Vector3()));
|
|
1573
1528
|
const bbcenter = this.updateBB();
|
|
1574
1529
|
this.position.copy(bbcenter);
|
|
1575
1530
|
this.children.forEach((child, i) => {
|
|
@@ -1583,32 +1538,27 @@ var DIVEGroup = class extends import_three9.Object3D {
|
|
|
1583
1538
|
* @returns {Vector3} The new center of the bounding box.
|
|
1584
1539
|
*/
|
|
1585
1540
|
updateBB() {
|
|
1586
|
-
this.
|
|
1541
|
+
this._boundingBox.makeEmpty();
|
|
1587
1542
|
this.children.forEach((child) => {
|
|
1588
1543
|
if (child.uuid === this._boxMesh.uuid) return;
|
|
1589
|
-
this.
|
|
1544
|
+
this._boundingBox.expandByObject(child);
|
|
1590
1545
|
});
|
|
1591
|
-
return this.
|
|
1546
|
+
return this._boundingBox.getCenter(new import_three10.Vector3());
|
|
1592
1547
|
}
|
|
1593
1548
|
updateBoxMesh() {
|
|
1594
|
-
this._boxMesh.
|
|
1549
|
+
this._boxMesh.quaternion.copy(this.quaternion.clone().invert());
|
|
1550
|
+
this._boxMesh.scale.set(1 / this.scale.x, 1 / this.scale.y, 1 / this.scale.z);
|
|
1551
|
+
this._boxMesh.geometry = new import_three10.BoxGeometry(this._boundingBox.max.x - this._boundingBox.min.x, this._boundingBox.max.y - this._boundingBox.min.y, this._boundingBox.max.z - this._boundingBox.min.z);
|
|
1595
1552
|
}
|
|
1596
1553
|
onMove() {
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
onSelect() {
|
|
1601
|
-
var _a;
|
|
1602
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1603
|
-
}
|
|
1604
|
-
onDeselect() {
|
|
1605
|
-
var _a;
|
|
1606
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1554
|
+
super.onMove();
|
|
1555
|
+
this.updateBB();
|
|
1556
|
+
this.updateBoxMesh();
|
|
1607
1557
|
}
|
|
1608
1558
|
};
|
|
1609
1559
|
|
|
1610
1560
|
// src/scene/root/Root.ts
|
|
1611
|
-
var DIVERoot = class extends
|
|
1561
|
+
var DIVERoot = class extends import_three11.Object3D {
|
|
1612
1562
|
constructor() {
|
|
1613
1563
|
super();
|
|
1614
1564
|
this.isDIVERoot = true;
|
|
@@ -1616,7 +1566,7 @@ var DIVERoot = class extends import_three10.Object3D {
|
|
|
1616
1566
|
this.loadingManager = new DIVELoadingManager();
|
|
1617
1567
|
}
|
|
1618
1568
|
ComputeSceneBB() {
|
|
1619
|
-
const bb = new
|
|
1569
|
+
const bb = new import_three11.Box3();
|
|
1620
1570
|
this.traverse((object) => {
|
|
1621
1571
|
if ("isObject3D" in object) {
|
|
1622
1572
|
bb.expandByObject(object);
|
|
@@ -1737,7 +1687,7 @@ var DIVERoot = class extends import_three10.Object3D {
|
|
|
1737
1687
|
if (light.position !== void 0 && light.position !== null) sceneObject.position.set(light.position.x, light.position.y, light.position.z);
|
|
1738
1688
|
if (light.intensity !== void 0 && light.intensity !== null) sceneObject.SetIntensity(light.intensity);
|
|
1739
1689
|
if (light.enabled !== void 0 && light.enabled !== null) sceneObject.SetEnabled(light.enabled);
|
|
1740
|
-
if (light.color !== void 0 && light.color !== null) sceneObject.SetColor(new
|
|
1690
|
+
if (light.color !== void 0 && light.color !== null) sceneObject.SetColor(new import_three11.Color(light.color));
|
|
1741
1691
|
if (light.visible !== void 0 && light.visible !== null) sceneObject.visible = light.visible;
|
|
1742
1692
|
if (light.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, light), { parent: light.parent }));
|
|
1743
1693
|
}
|
|
@@ -1877,12 +1827,12 @@ var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
|
1877
1827
|
|
|
1878
1828
|
// src/grid/Grid.ts
|
|
1879
1829
|
init_VisibilityLayerMask();
|
|
1880
|
-
var
|
|
1881
|
-
var DIVEGrid = class extends
|
|
1830
|
+
var import_three12 = require("three");
|
|
1831
|
+
var DIVEGrid = class extends import_three12.Object3D {
|
|
1882
1832
|
constructor() {
|
|
1883
1833
|
super();
|
|
1884
1834
|
this.name = "Grid";
|
|
1885
|
-
const grid = new
|
|
1835
|
+
const grid = new import_three12.GridHelper(100, 100, GRID_CENTER_LINE_COLOR, GRID_SIDE_LINE_COLOR);
|
|
1886
1836
|
grid.material.depthTest = false;
|
|
1887
1837
|
grid.layers.mask = HELPER_LAYER_MASK;
|
|
1888
1838
|
this.add(grid);
|
|
@@ -1893,11 +1843,11 @@ var DIVEGrid = class extends import_three11.Object3D {
|
|
|
1893
1843
|
};
|
|
1894
1844
|
|
|
1895
1845
|
// src/primitive/floor/Floor.ts
|
|
1896
|
-
var
|
|
1846
|
+
var import_three13 = require("three");
|
|
1897
1847
|
init_VisibilityLayerMask();
|
|
1898
|
-
var DIVEFloor = class extends
|
|
1848
|
+
var DIVEFloor = class extends import_three13.Mesh {
|
|
1899
1849
|
constructor() {
|
|
1900
|
-
super(new
|
|
1850
|
+
super(new import_three13.PlaneGeometry(1e4, 1e4), new import_three13.MeshStandardMaterial({ color: new import_three13.Color(150 / 255, 150 / 255, 150 / 255) }));
|
|
1901
1851
|
this.isFloor = true;
|
|
1902
1852
|
this.name = "Floor";
|
|
1903
1853
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
@@ -1908,12 +1858,12 @@ var DIVEFloor = class extends import_three12.Mesh {
|
|
|
1908
1858
|
this.visible = visible;
|
|
1909
1859
|
}
|
|
1910
1860
|
SetColor(color) {
|
|
1911
|
-
this.material.color = new
|
|
1861
|
+
this.material.color = new import_three13.Color(color);
|
|
1912
1862
|
}
|
|
1913
1863
|
};
|
|
1914
1864
|
|
|
1915
1865
|
// src/scene/Scene.ts
|
|
1916
|
-
var DIVEScene = class extends
|
|
1866
|
+
var DIVEScene = class extends import_three14.Scene {
|
|
1917
1867
|
get Root() {
|
|
1918
1868
|
return this.root;
|
|
1919
1869
|
}
|
|
@@ -1925,7 +1875,7 @@ var DIVEScene = class extends import_three13.Scene {
|
|
|
1925
1875
|
}
|
|
1926
1876
|
constructor() {
|
|
1927
1877
|
super();
|
|
1928
|
-
this.background = new
|
|
1878
|
+
this.background = new import_three14.Color(16777215);
|
|
1929
1879
|
this.root = new DIVERoot();
|
|
1930
1880
|
this.add(this.root);
|
|
1931
1881
|
this.floor = new DIVEFloor();
|
|
@@ -1934,7 +1884,7 @@ var DIVEScene = class extends import_three13.Scene {
|
|
|
1934
1884
|
this.add(this.grid);
|
|
1935
1885
|
}
|
|
1936
1886
|
SetBackground(color) {
|
|
1937
|
-
this.background = new
|
|
1887
|
+
this.background = new import_three14.Color(color);
|
|
1938
1888
|
}
|
|
1939
1889
|
ComputeSceneBB() {
|
|
1940
1890
|
return this.Root.ComputeSceneBB();
|
|
@@ -1961,7 +1911,7 @@ init_PerspectiveCamera();
|
|
|
1961
1911
|
|
|
1962
1912
|
// src/controls/OrbitControls.ts
|
|
1963
1913
|
var import_OrbitControls = require("three/examples/jsm/controls/OrbitControls");
|
|
1964
|
-
var
|
|
1914
|
+
var import_three15 = require("three");
|
|
1965
1915
|
var import_tween = require("@tweenjs/tween.js");
|
|
1966
1916
|
var DIVEOrbitControlsDefaultSettings = {
|
|
1967
1917
|
enableDamping: true,
|
|
@@ -2003,8 +1953,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
2003
1953
|
this.dispose();
|
|
2004
1954
|
}
|
|
2005
1955
|
ComputeEncompassingView(bb) {
|
|
2006
|
-
const center = bb.getCenter(new
|
|
2007
|
-
const size = bb.getSize(new
|
|
1956
|
+
const center = bb.getCenter(new import_three15.Vector3());
|
|
1957
|
+
const size = bb.getSize(new import_three15.Vector3());
|
|
2008
1958
|
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
2009
1959
|
const direction = this.object.position.clone().normalize();
|
|
2010
1960
|
return {
|
|
@@ -2015,7 +1965,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
2015
1965
|
ZoomIn(by) {
|
|
2016
1966
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
2017
1967
|
const { minDistance, maxDistance } = this;
|
|
2018
|
-
this.minDistance = this.maxDistance =
|
|
1968
|
+
this.minDistance = this.maxDistance = import_three15.MathUtils.clamp(this.getDistance() - zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
2019
1969
|
this.update();
|
|
2020
1970
|
this.minDistance = minDistance;
|
|
2021
1971
|
this.maxDistance = maxDistance;
|
|
@@ -2023,7 +1973,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
2023
1973
|
ZoomOut(by) {
|
|
2024
1974
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
2025
1975
|
const { minDistance, maxDistance } = this;
|
|
2026
|
-
this.minDistance = this.maxDistance =
|
|
1976
|
+
this.minDistance = this.maxDistance = import_three15.MathUtils.clamp(this.getDistance() + zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
2027
1977
|
this.update();
|
|
2028
1978
|
this.minDistance = minDistance;
|
|
2029
1979
|
this.maxDistance = maxDistance;
|
|
@@ -2171,7 +2121,7 @@ var DIVEAnimationSystem = class {
|
|
|
2171
2121
|
};
|
|
2172
2122
|
|
|
2173
2123
|
// src/axiscamera/AxisCamera.ts
|
|
2174
|
-
var
|
|
2124
|
+
var import_three16 = require("three");
|
|
2175
2125
|
var import_three_spritetext = __toESM(require("three-spritetext"), 1);
|
|
2176
2126
|
init_VisibilityLayerMask();
|
|
2177
2127
|
|
|
@@ -2184,18 +2134,18 @@ var AxesColorGreen = AxesColorGreenLetter;
|
|
|
2184
2134
|
var AxesColorBlue = AxesColorBlueLetter;
|
|
2185
2135
|
|
|
2186
2136
|
// src/axiscamera/AxisCamera.ts
|
|
2187
|
-
var DIVEAxisCamera = class extends
|
|
2137
|
+
var DIVEAxisCamera = class extends import_three16.OrthographicCamera {
|
|
2188
2138
|
constructor(renderer, scene, controls) {
|
|
2189
2139
|
super(-1, 1, 1, -1, 0.1, 100);
|
|
2190
2140
|
this.layers.mask = COORDINATE_LAYER_MASK;
|
|
2191
|
-
this.axesHelper = new
|
|
2141
|
+
this.axesHelper = new import_three16.AxesHelper(0.5);
|
|
2192
2142
|
this.axesHelper.layers.mask = COORDINATE_LAYER_MASK;
|
|
2193
2143
|
this.axesHelper.material.depthTest = false;
|
|
2194
2144
|
this.axesHelper.position.set(0, 0, -1);
|
|
2195
2145
|
this.axesHelper.setColors(
|
|
2196
|
-
new
|
|
2197
|
-
new
|
|
2198
|
-
new
|
|
2146
|
+
new import_three16.Color(AxesColorRed),
|
|
2147
|
+
new import_three16.Color(AxesColorGreen),
|
|
2148
|
+
new import_three16.Color(AxesColorBlue)
|
|
2199
2149
|
);
|
|
2200
2150
|
const x = new import_three_spritetext.default("X", 0.2, AxesColorRedLetter);
|
|
2201
2151
|
const y = new import_three_spritetext.default("Y", 0.2, AxesColorGreenLetter);
|
|
@@ -2213,7 +2163,7 @@ var DIVEAxisCamera = class extends import_three15.OrthographicCamera {
|
|
|
2213
2163
|
this._renderer = renderer;
|
|
2214
2164
|
this._scene = scene;
|
|
2215
2165
|
this._scene.add(this);
|
|
2216
|
-
const restoreViewport = new
|
|
2166
|
+
const restoreViewport = new import_three16.Vector4();
|
|
2217
2167
|
this._renderCallbackId = renderer.AddPostRenderCallback(() => {
|
|
2218
2168
|
const restoreBackground = scene.background;
|
|
2219
2169
|
scene.background = null;
|
|
@@ -2232,7 +2182,7 @@ var DIVEAxisCamera = class extends import_three15.OrthographicCamera {
|
|
|
2232
2182
|
this._scene.remove(this);
|
|
2233
2183
|
}
|
|
2234
2184
|
SetFromCameraMatrix(matrix) {
|
|
2235
|
-
this.axesHelper.rotation.setFromRotationMatrix(new
|
|
2185
|
+
this.axesHelper.rotation.setFromRotationMatrix(new import_three16.Matrix4().extractRotation(matrix).invert());
|
|
2236
2186
|
}
|
|
2237
2187
|
};
|
|
2238
2188
|
|