@shopware-ag/dive 1.13.0 → 1.15.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 +113 -150
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +20 -34
- package/build/dive.d.ts +20 -34
- package/build/dive.js +71 -108
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/group/Group.ts +18 -32
- package/src/group/__test__/Group.test.ts +42 -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");
|
|
@@ -1171,7 +1171,7 @@ var DIVESceneLight = class extends import_three6.Object3D {
|
|
|
1171
1171
|
};
|
|
1172
1172
|
|
|
1173
1173
|
// src/model/Model.ts
|
|
1174
|
-
var
|
|
1174
|
+
var import_three8 = require("three");
|
|
1175
1175
|
init_VisibilityLayerMask();
|
|
1176
1176
|
|
|
1177
1177
|
// src/helper/findSceneRecursive/findSceneRecursive.ts
|
|
@@ -1182,18 +1182,57 @@ var findSceneRecursive = (object) => {
|
|
|
1182
1182
|
return object;
|
|
1183
1183
|
};
|
|
1184
1184
|
|
|
1185
|
-
// src/
|
|
1186
|
-
var
|
|
1185
|
+
// src/node/Node.ts
|
|
1186
|
+
var import_three7 = require("three");
|
|
1187
|
+
init_VisibilityLayerMask();
|
|
1188
|
+
var DIVENode = class extends import_three7.Object3D {
|
|
1187
1189
|
constructor() {
|
|
1188
1190
|
super();
|
|
1189
|
-
this.
|
|
1191
|
+
this.isDIVENode = true;
|
|
1190
1192
|
this.isSelectable = true;
|
|
1191
1193
|
this.isMoveable = true;
|
|
1192
1194
|
this.gizmo = null;
|
|
1195
|
+
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1196
|
+
this._boundingBox = new import_three7.Box3();
|
|
1197
|
+
}
|
|
1198
|
+
SetPosition(position) {
|
|
1199
|
+
this.position.set(position.x, position.y, position.z);
|
|
1200
|
+
}
|
|
1201
|
+
SetRotation(rotation) {
|
|
1202
|
+
this.rotation.set(rotation.x, rotation.y, rotation.z);
|
|
1203
|
+
}
|
|
1204
|
+
SetScale(scale) {
|
|
1205
|
+
this.scale.set(scale.x, scale.y, scale.z);
|
|
1206
|
+
}
|
|
1207
|
+
SetVisibility(visible) {
|
|
1208
|
+
this.visible = visible;
|
|
1209
|
+
}
|
|
1210
|
+
SetToWorldOrigin() {
|
|
1211
|
+
var _a;
|
|
1212
|
+
this.position.set(0, 0, 0);
|
|
1213
|
+
(_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 });
|
|
1214
|
+
}
|
|
1215
|
+
onMove() {
|
|
1216
|
+
var _a;
|
|
1217
|
+
(_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 });
|
|
1218
|
+
}
|
|
1219
|
+
onSelect() {
|
|
1220
|
+
var _a;
|
|
1221
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1222
|
+
}
|
|
1223
|
+
onDeselect() {
|
|
1224
|
+
var _a;
|
|
1225
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1229
|
+
// src/model/Model.ts
|
|
1230
|
+
var DIVEModel = class extends DIVENode {
|
|
1231
|
+
constructor() {
|
|
1232
|
+
super(...arguments);
|
|
1233
|
+
this.isDIVEModel = true;
|
|
1193
1234
|
this._mesh = null;
|
|
1194
1235
|
this._material = null;
|
|
1195
|
-
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1196
|
-
this.boundingBox = new import_three7.Box3();
|
|
1197
1236
|
}
|
|
1198
1237
|
SetModel(gltf) {
|
|
1199
1238
|
this.clear();
|
|
@@ -1201,7 +1240,7 @@ var DIVEModel = class extends import_three7.Object3D {
|
|
|
1201
1240
|
child.castShadow = true;
|
|
1202
1241
|
child.receiveShadow = true;
|
|
1203
1242
|
child.layers.mask = this.layers.mask;
|
|
1204
|
-
this.
|
|
1243
|
+
this._boundingBox.expandByObject(child);
|
|
1205
1244
|
if (!this._mesh && "isMesh" in child) {
|
|
1206
1245
|
this._mesh = child;
|
|
1207
1246
|
if (this._material) {
|
|
@@ -1213,23 +1252,9 @@ var DIVEModel = class extends import_three7.Object3D {
|
|
|
1213
1252
|
});
|
|
1214
1253
|
this.add(gltf.scene);
|
|
1215
1254
|
}
|
|
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
1255
|
SetMaterial(material) {
|
|
1231
1256
|
if (!this._material) {
|
|
1232
|
-
this._material = new
|
|
1257
|
+
this._material = new import_three8.MeshStandardMaterial();
|
|
1233
1258
|
}
|
|
1234
1259
|
if (material.vertexColors !== void 0) {
|
|
1235
1260
|
this._material.vertexColors = material.vertexColors;
|
|
@@ -1265,14 +1290,9 @@ var DIVEModel = class extends import_three7.Object3D {
|
|
|
1265
1290
|
this._mesh.material = this._material;
|
|
1266
1291
|
}
|
|
1267
1292
|
}
|
|
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
1293
|
PlaceOnFloor() {
|
|
1274
1294
|
var _a;
|
|
1275
|
-
this.position.y = -this.
|
|
1295
|
+
this.position.y = -this._boundingBox.min.y * this.scale.y;
|
|
1276
1296
|
(_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
1297
|
}
|
|
1278
1298
|
DropIt() {
|
|
@@ -1281,10 +1301,10 @@ var DIVEModel = class extends import_three7.Object3D {
|
|
|
1281
1301
|
console.warn("DIVEModel: DropIt() called on a model that is not in the scene.", this);
|
|
1282
1302
|
return;
|
|
1283
1303
|
}
|
|
1284
|
-
const bottomY = this.
|
|
1285
|
-
const bbBottomCenter = this.localToWorld(this.
|
|
1304
|
+
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1305
|
+
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new import_three8.Vector3()).multiply(this.scale));
|
|
1286
1306
|
bbBottomCenter.y = bottomY + this.position.y;
|
|
1287
|
-
const raycaster = new
|
|
1307
|
+
const raycaster = new import_three8.Raycaster(bbBottomCenter, new import_three8.Vector3(0, -1, 0));
|
|
1288
1308
|
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1289
1309
|
const intersections = raycaster.intersectObjects(findSceneRecursive(this).Root.children, true);
|
|
1290
1310
|
if (intersections.length > 0) {
|
|
@@ -1293,24 +1313,12 @@ var DIVEModel = class extends import_three7.Object3D {
|
|
|
1293
1313
|
const meshBB = mesh.geometry.boundingBox;
|
|
1294
1314
|
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1295
1315
|
const oldPos = this.position.clone();
|
|
1296
|
-
const newPos = this.position.clone().setY(worldPos.y).sub(new
|
|
1316
|
+
const newPos = this.position.clone().setY(worldPos.y).sub(new import_three8.Vector3(0, bottomY, 0));
|
|
1297
1317
|
this.position.copy(newPos);
|
|
1298
1318
|
if (this.position.y === oldPos.y) return;
|
|
1299
1319
|
(_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
1320
|
}
|
|
1301
1321
|
}
|
|
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
1322
|
};
|
|
1315
1323
|
|
|
1316
1324
|
// src/loadingmanager/LoadingManager.ts
|
|
@@ -1346,49 +1354,30 @@ var DIVELoadingManager = class {
|
|
|
1346
1354
|
};
|
|
1347
1355
|
|
|
1348
1356
|
// src/primitive/Primitive.ts
|
|
1349
|
-
var
|
|
1357
|
+
var import_three9 = require("three");
|
|
1350
1358
|
init_VisibilityLayerMask();
|
|
1351
|
-
var DIVEPrimitive = class extends
|
|
1359
|
+
var DIVEPrimitive = class extends DIVENode {
|
|
1352
1360
|
constructor() {
|
|
1353
1361
|
super();
|
|
1354
1362
|
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();
|
|
1363
|
+
this._mesh = new import_three9.Mesh();
|
|
1360
1364
|
this._mesh.layers.mask = PRODUCT_LAYER_MASK;
|
|
1361
1365
|
this._mesh.castShadow = true;
|
|
1362
1366
|
this._mesh.receiveShadow = true;
|
|
1363
|
-
this._mesh.material = new
|
|
1367
|
+
this._mesh.material = new import_three9.MeshStandardMaterial();
|
|
1364
1368
|
this.add(this._mesh);
|
|
1365
|
-
this._boundingBox = new import_three8.Box3();
|
|
1366
1369
|
}
|
|
1367
1370
|
SetGeometry(geometry) {
|
|
1368
1371
|
this._mesh.geometry = this.assembleGeometry(geometry);
|
|
1369
1372
|
this._boundingBox.setFromObject(this._mesh);
|
|
1370
1373
|
}
|
|
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
1374
|
SetMaterial(material) {
|
|
1386
1375
|
const primitiveMaterial = this._mesh.material;
|
|
1387
1376
|
if (material.vertexColors !== void 0) {
|
|
1388
1377
|
primitiveMaterial.vertexColors = material.vertexColors;
|
|
1389
1378
|
}
|
|
1390
1379
|
if (material.color !== void 0) {
|
|
1391
|
-
primitiveMaterial.color = new
|
|
1380
|
+
primitiveMaterial.color = new import_three9.Color(material.color);
|
|
1392
1381
|
}
|
|
1393
1382
|
if (material.map !== void 0) {
|
|
1394
1383
|
primitiveMaterial.map = material.map;
|
|
@@ -1416,11 +1405,6 @@ var DIVEPrimitive = class extends import_three8.Object3D {
|
|
|
1416
1405
|
}
|
|
1417
1406
|
if (this._mesh) this._mesh.material = primitiveMaterial;
|
|
1418
1407
|
}
|
|
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
1408
|
PlaceOnFloor() {
|
|
1425
1409
|
var _a;
|
|
1426
1410
|
this.position.y = -this._boundingBox.min.y * this.scale.y;
|
|
@@ -1433,9 +1417,9 @@ var DIVEPrimitive = class extends import_three8.Object3D {
|
|
|
1433
1417
|
return;
|
|
1434
1418
|
}
|
|
1435
1419
|
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1436
|
-
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new
|
|
1420
|
+
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new import_three9.Vector3()).multiply(this.scale));
|
|
1437
1421
|
bbBottomCenter.y = bottomY + this.position.y;
|
|
1438
|
-
const raycaster = new
|
|
1422
|
+
const raycaster = new import_three9.Raycaster(bbBottomCenter, new import_three9.Vector3(0, -1, 0));
|
|
1439
1423
|
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1440
1424
|
const intersections = raycaster.intersectObjects(findSceneRecursive(this).Root.children, true);
|
|
1441
1425
|
if (intersections.length > 0) {
|
|
@@ -1444,24 +1428,12 @@ var DIVEPrimitive = class extends import_three8.Object3D {
|
|
|
1444
1428
|
const meshBB = mesh.geometry.boundingBox;
|
|
1445
1429
|
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1446
1430
|
const oldPos = this.position.clone();
|
|
1447
|
-
const newPos = this.position.clone().setY(worldPos.y).sub(new
|
|
1431
|
+
const newPos = this.position.clone().setY(worldPos.y).sub(new import_three9.Vector3(0, bottomY, 0));
|
|
1448
1432
|
this.position.copy(newPos);
|
|
1449
1433
|
if (this.position.y === oldPos.y) return;
|
|
1450
1434
|
(_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
1435
|
}
|
|
1452
1436
|
}
|
|
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
1437
|
assembleGeometry(geometry) {
|
|
1466
1438
|
switch (geometry.name) {
|
|
1467
1439
|
case "cylinder":
|
|
@@ -1479,75 +1451,57 @@ var DIVEPrimitive = class extends import_three8.Object3D {
|
|
|
1479
1451
|
case "plane":
|
|
1480
1452
|
return this.createPlaneGeometry(geometry);
|
|
1481
1453
|
default:
|
|
1482
|
-
return new
|
|
1454
|
+
return new import_three9.BufferGeometry();
|
|
1483
1455
|
}
|
|
1484
1456
|
}
|
|
1485
1457
|
createCylinderGeometry(geometry) {
|
|
1486
|
-
const geo = new
|
|
1458
|
+
const geo = new import_three9.CylinderGeometry(geometry.width / 2, geometry.width / 2, geometry.height, 64);
|
|
1487
1459
|
geo.translate(0, geometry.height / 2, 0);
|
|
1488
1460
|
return geo;
|
|
1489
1461
|
}
|
|
1490
1462
|
createSphereGeometry(geometry) {
|
|
1491
|
-
const geo = new
|
|
1463
|
+
const geo = new import_three9.SphereGeometry(geometry.width / 2, 256, 256);
|
|
1492
1464
|
return geo;
|
|
1493
1465
|
}
|
|
1494
1466
|
createPyramidGeometry(geometry) {
|
|
1495
|
-
const geo = new
|
|
1467
|
+
const geo = new import_three9.ConeGeometry(geometry.width / 2, geometry.height, 4, 1, true);
|
|
1496
1468
|
geo.rotateY(Math.PI / 4);
|
|
1497
1469
|
geo.translate(0, geometry.height / 2, 0);
|
|
1498
1470
|
return geo;
|
|
1499
1471
|
}
|
|
1500
1472
|
createBoxGeometry(geometry) {
|
|
1501
|
-
const geo = new
|
|
1473
|
+
const geo = new import_three9.BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1502
1474
|
geo.translate(0, geometry.height / 2, 0);
|
|
1503
1475
|
return geo;
|
|
1504
1476
|
}
|
|
1505
1477
|
createConeGeometry(geometry) {
|
|
1506
|
-
const geo = new
|
|
1478
|
+
const geo = new import_three9.ConeGeometry(geometry.width / 2, geometry.height, 256);
|
|
1507
1479
|
geo.translate(0, geometry.height / 2, 0);
|
|
1508
1480
|
return geo;
|
|
1509
1481
|
}
|
|
1510
1482
|
createWallGeometry(geometry) {
|
|
1511
|
-
const geo = new
|
|
1483
|
+
const geo = new import_three9.BoxGeometry(geometry.width, geometry.height, geometry.depth || 0.05, 16);
|
|
1512
1484
|
geo.translate(0, geometry.height / 2, 0);
|
|
1513
1485
|
return geo;
|
|
1514
1486
|
}
|
|
1515
1487
|
createPlaneGeometry(geometry) {
|
|
1516
|
-
const geo = new
|
|
1488
|
+
const geo = new import_three9.BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1517
1489
|
geo.translate(0, geometry.height / 2, 0);
|
|
1518
1490
|
return geo;
|
|
1519
1491
|
}
|
|
1520
1492
|
};
|
|
1521
1493
|
|
|
1522
1494
|
// src/group/Group.ts
|
|
1523
|
-
var
|
|
1524
|
-
var DIVEGroup = class extends
|
|
1495
|
+
var import_three10 = require("three");
|
|
1496
|
+
var DIVEGroup = class extends DIVENode {
|
|
1525
1497
|
constructor() {
|
|
1526
1498
|
super();
|
|
1527
1499
|
this.isDIVEGroup = true;
|
|
1528
|
-
this.isSelectable = true;
|
|
1529
|
-
this.isMoveable = true;
|
|
1530
1500
|
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 }));
|
|
1501
|
+
this._boxMesh = new import_three10.Mesh(new import_three10.BoxGeometry(0, 0, 0), new import_three10.MeshBasicMaterial({ color: 16711680, wireframe: true }));
|
|
1533
1502
|
this._boxMesh.visible = false;
|
|
1534
1503
|
this.add(this._boxMesh);
|
|
1535
1504
|
}
|
|
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
1505
|
SetBoundingBoxVisibility(visible) {
|
|
1552
1506
|
this._boxMesh.visible = visible;
|
|
1553
1507
|
}
|
|
@@ -1568,33 +1522,42 @@ var DIVEGroup = class extends import_three9.Object3D {
|
|
|
1568
1522
|
* Children's world positions are kept.
|
|
1569
1523
|
*/
|
|
1570
1524
|
recalculatePosition() {
|
|
1571
|
-
|
|
1525
|
+
var _a;
|
|
1526
|
+
const childrensWorldPositions = this.children.map((child) => child.getWorldPosition(new import_three10.Vector3()));
|
|
1572
1527
|
const bbcenter = this.updateBB();
|
|
1573
1528
|
this.position.copy(bbcenter);
|
|
1574
1529
|
this.children.forEach((child, i) => {
|
|
1575
1530
|
if (child.uuid === this._boxMesh.uuid) return;
|
|
1576
1531
|
child.position.copy(this.worldToLocal(childrensWorldPositions[i]));
|
|
1577
1532
|
});
|
|
1533
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position });
|
|
1578
1534
|
}
|
|
1579
1535
|
/**
|
|
1580
1536
|
* Updates the bounding box of the group.
|
|
1581
1537
|
* @returns {Vector3} The new center of the bounding box.
|
|
1582
1538
|
*/
|
|
1583
1539
|
updateBB() {
|
|
1584
|
-
this.
|
|
1540
|
+
this._boundingBox.makeEmpty();
|
|
1585
1541
|
this.children.forEach((child) => {
|
|
1586
1542
|
if (child.uuid === this._boxMesh.uuid) return;
|
|
1587
|
-
this.
|
|
1543
|
+
this._boundingBox.expandByObject(child);
|
|
1588
1544
|
});
|
|
1589
|
-
return this.
|
|
1545
|
+
return this._boundingBox.getCenter(new import_three10.Vector3());
|
|
1590
1546
|
}
|
|
1591
1547
|
updateBoxMesh() {
|
|
1592
|
-
this._boxMesh.
|
|
1548
|
+
this._boxMesh.quaternion.copy(this.quaternion.clone().invert());
|
|
1549
|
+
this._boxMesh.scale.set(1 / this.scale.x, 1 / this.scale.y, 1 / this.scale.z);
|
|
1550
|
+
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);
|
|
1551
|
+
}
|
|
1552
|
+
onMove() {
|
|
1553
|
+
super.onMove();
|
|
1554
|
+
this.updateBB();
|
|
1555
|
+
this.updateBoxMesh();
|
|
1593
1556
|
}
|
|
1594
1557
|
};
|
|
1595
1558
|
|
|
1596
1559
|
// src/scene/root/Root.ts
|
|
1597
|
-
var DIVERoot = class extends
|
|
1560
|
+
var DIVERoot = class extends import_three11.Object3D {
|
|
1598
1561
|
constructor() {
|
|
1599
1562
|
super();
|
|
1600
1563
|
this.isDIVERoot = true;
|
|
@@ -1602,7 +1565,7 @@ var DIVERoot = class extends import_three10.Object3D {
|
|
|
1602
1565
|
this.loadingManager = new DIVELoadingManager();
|
|
1603
1566
|
}
|
|
1604
1567
|
ComputeSceneBB() {
|
|
1605
|
-
const bb = new
|
|
1568
|
+
const bb = new import_three11.Box3();
|
|
1606
1569
|
this.traverse((object) => {
|
|
1607
1570
|
if ("isObject3D" in object) {
|
|
1608
1571
|
bb.expandByObject(object);
|
|
@@ -1723,7 +1686,7 @@ var DIVERoot = class extends import_three10.Object3D {
|
|
|
1723
1686
|
if (light.position !== void 0 && light.position !== null) sceneObject.position.set(light.position.x, light.position.y, light.position.z);
|
|
1724
1687
|
if (light.intensity !== void 0 && light.intensity !== null) sceneObject.SetIntensity(light.intensity);
|
|
1725
1688
|
if (light.enabled !== void 0 && light.enabled !== null) sceneObject.SetEnabled(light.enabled);
|
|
1726
|
-
if (light.color !== void 0 && light.color !== null) sceneObject.SetColor(new
|
|
1689
|
+
if (light.color !== void 0 && light.color !== null) sceneObject.SetColor(new import_three11.Color(light.color));
|
|
1727
1690
|
if (light.visible !== void 0 && light.visible !== null) sceneObject.visible = light.visible;
|
|
1728
1691
|
if (light.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, light), { parent: light.parent }));
|
|
1729
1692
|
}
|
|
@@ -1863,12 +1826,12 @@ var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
|
1863
1826
|
|
|
1864
1827
|
// src/grid/Grid.ts
|
|
1865
1828
|
init_VisibilityLayerMask();
|
|
1866
|
-
var
|
|
1867
|
-
var DIVEGrid = class extends
|
|
1829
|
+
var import_three12 = require("three");
|
|
1830
|
+
var DIVEGrid = class extends import_three12.Object3D {
|
|
1868
1831
|
constructor() {
|
|
1869
1832
|
super();
|
|
1870
1833
|
this.name = "Grid";
|
|
1871
|
-
const grid = new
|
|
1834
|
+
const grid = new import_three12.GridHelper(100, 100, GRID_CENTER_LINE_COLOR, GRID_SIDE_LINE_COLOR);
|
|
1872
1835
|
grid.material.depthTest = false;
|
|
1873
1836
|
grid.layers.mask = HELPER_LAYER_MASK;
|
|
1874
1837
|
this.add(grid);
|
|
@@ -1879,11 +1842,11 @@ var DIVEGrid = class extends import_three11.Object3D {
|
|
|
1879
1842
|
};
|
|
1880
1843
|
|
|
1881
1844
|
// src/primitive/floor/Floor.ts
|
|
1882
|
-
var
|
|
1845
|
+
var import_three13 = require("three");
|
|
1883
1846
|
init_VisibilityLayerMask();
|
|
1884
|
-
var DIVEFloor = class extends
|
|
1847
|
+
var DIVEFloor = class extends import_three13.Mesh {
|
|
1885
1848
|
constructor() {
|
|
1886
|
-
super(new
|
|
1849
|
+
super(new import_three13.PlaneGeometry(1e4, 1e4), new import_three13.MeshStandardMaterial({ color: new import_three13.Color(150 / 255, 150 / 255, 150 / 255) }));
|
|
1887
1850
|
this.isFloor = true;
|
|
1888
1851
|
this.name = "Floor";
|
|
1889
1852
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
@@ -1894,12 +1857,12 @@ var DIVEFloor = class extends import_three12.Mesh {
|
|
|
1894
1857
|
this.visible = visible;
|
|
1895
1858
|
}
|
|
1896
1859
|
SetColor(color) {
|
|
1897
|
-
this.material.color = new
|
|
1860
|
+
this.material.color = new import_three13.Color(color);
|
|
1898
1861
|
}
|
|
1899
1862
|
};
|
|
1900
1863
|
|
|
1901
1864
|
// src/scene/Scene.ts
|
|
1902
|
-
var DIVEScene = class extends
|
|
1865
|
+
var DIVEScene = class extends import_three14.Scene {
|
|
1903
1866
|
get Root() {
|
|
1904
1867
|
return this.root;
|
|
1905
1868
|
}
|
|
@@ -1911,7 +1874,7 @@ var DIVEScene = class extends import_three13.Scene {
|
|
|
1911
1874
|
}
|
|
1912
1875
|
constructor() {
|
|
1913
1876
|
super();
|
|
1914
|
-
this.background = new
|
|
1877
|
+
this.background = new import_three14.Color(16777215);
|
|
1915
1878
|
this.root = new DIVERoot();
|
|
1916
1879
|
this.add(this.root);
|
|
1917
1880
|
this.floor = new DIVEFloor();
|
|
@@ -1920,7 +1883,7 @@ var DIVEScene = class extends import_three13.Scene {
|
|
|
1920
1883
|
this.add(this.grid);
|
|
1921
1884
|
}
|
|
1922
1885
|
SetBackground(color) {
|
|
1923
|
-
this.background = new
|
|
1886
|
+
this.background = new import_three14.Color(color);
|
|
1924
1887
|
}
|
|
1925
1888
|
ComputeSceneBB() {
|
|
1926
1889
|
return this.Root.ComputeSceneBB();
|
|
@@ -1947,7 +1910,7 @@ init_PerspectiveCamera();
|
|
|
1947
1910
|
|
|
1948
1911
|
// src/controls/OrbitControls.ts
|
|
1949
1912
|
var import_OrbitControls = require("three/examples/jsm/controls/OrbitControls");
|
|
1950
|
-
var
|
|
1913
|
+
var import_three15 = require("three");
|
|
1951
1914
|
var import_tween = require("@tweenjs/tween.js");
|
|
1952
1915
|
var DIVEOrbitControlsDefaultSettings = {
|
|
1953
1916
|
enableDamping: true,
|
|
@@ -1989,8 +1952,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
1989
1952
|
this.dispose();
|
|
1990
1953
|
}
|
|
1991
1954
|
ComputeEncompassingView(bb) {
|
|
1992
|
-
const center = bb.getCenter(new
|
|
1993
|
-
const size = bb.getSize(new
|
|
1955
|
+
const center = bb.getCenter(new import_three15.Vector3());
|
|
1956
|
+
const size = bb.getSize(new import_three15.Vector3());
|
|
1994
1957
|
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
1995
1958
|
const direction = this.object.position.clone().normalize();
|
|
1996
1959
|
return {
|
|
@@ -2001,7 +1964,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
2001
1964
|
ZoomIn(by) {
|
|
2002
1965
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
2003
1966
|
const { minDistance, maxDistance } = this;
|
|
2004
|
-
this.minDistance = this.maxDistance =
|
|
1967
|
+
this.minDistance = this.maxDistance = import_three15.MathUtils.clamp(this.getDistance() - zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
2005
1968
|
this.update();
|
|
2006
1969
|
this.minDistance = minDistance;
|
|
2007
1970
|
this.maxDistance = maxDistance;
|
|
@@ -2009,7 +1972,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
2009
1972
|
ZoomOut(by) {
|
|
2010
1973
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
2011
1974
|
const { minDistance, maxDistance } = this;
|
|
2012
|
-
this.minDistance = this.maxDistance =
|
|
1975
|
+
this.minDistance = this.maxDistance = import_three15.MathUtils.clamp(this.getDistance() + zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
2013
1976
|
this.update();
|
|
2014
1977
|
this.minDistance = minDistance;
|
|
2015
1978
|
this.maxDistance = maxDistance;
|
|
@@ -2157,7 +2120,7 @@ var DIVEAnimationSystem = class {
|
|
|
2157
2120
|
};
|
|
2158
2121
|
|
|
2159
2122
|
// src/axiscamera/AxisCamera.ts
|
|
2160
|
-
var
|
|
2123
|
+
var import_three16 = require("three");
|
|
2161
2124
|
var import_three_spritetext = __toESM(require("three-spritetext"), 1);
|
|
2162
2125
|
init_VisibilityLayerMask();
|
|
2163
2126
|
|
|
@@ -2170,18 +2133,18 @@ var AxesColorGreen = AxesColorGreenLetter;
|
|
|
2170
2133
|
var AxesColorBlue = AxesColorBlueLetter;
|
|
2171
2134
|
|
|
2172
2135
|
// src/axiscamera/AxisCamera.ts
|
|
2173
|
-
var DIVEAxisCamera = class extends
|
|
2136
|
+
var DIVEAxisCamera = class extends import_three16.OrthographicCamera {
|
|
2174
2137
|
constructor(renderer, scene, controls) {
|
|
2175
2138
|
super(-1, 1, 1, -1, 0.1, 100);
|
|
2176
2139
|
this.layers.mask = COORDINATE_LAYER_MASK;
|
|
2177
|
-
this.axesHelper = new
|
|
2140
|
+
this.axesHelper = new import_three16.AxesHelper(0.5);
|
|
2178
2141
|
this.axesHelper.layers.mask = COORDINATE_LAYER_MASK;
|
|
2179
2142
|
this.axesHelper.material.depthTest = false;
|
|
2180
2143
|
this.axesHelper.position.set(0, 0, -1);
|
|
2181
2144
|
this.axesHelper.setColors(
|
|
2182
|
-
new
|
|
2183
|
-
new
|
|
2184
|
-
new
|
|
2145
|
+
new import_three16.Color(AxesColorRed),
|
|
2146
|
+
new import_three16.Color(AxesColorGreen),
|
|
2147
|
+
new import_three16.Color(AxesColorBlue)
|
|
2185
2148
|
);
|
|
2186
2149
|
const x = new import_three_spritetext.default("X", 0.2, AxesColorRedLetter);
|
|
2187
2150
|
const y = new import_three_spritetext.default("Y", 0.2, AxesColorGreenLetter);
|
|
@@ -2199,7 +2162,7 @@ var DIVEAxisCamera = class extends import_three15.OrthographicCamera {
|
|
|
2199
2162
|
this._renderer = renderer;
|
|
2200
2163
|
this._scene = scene;
|
|
2201
2164
|
this._scene.add(this);
|
|
2202
|
-
const restoreViewport = new
|
|
2165
|
+
const restoreViewport = new import_three16.Vector4();
|
|
2203
2166
|
this._renderCallbackId = renderer.AddPostRenderCallback(() => {
|
|
2204
2167
|
const restoreBackground = scene.background;
|
|
2205
2168
|
scene.background = null;
|
|
@@ -2218,7 +2181,7 @@ var DIVEAxisCamera = class extends import_three15.OrthographicCamera {
|
|
|
2218
2181
|
this._scene.remove(this);
|
|
2219
2182
|
}
|
|
2220
2183
|
SetFromCameraMatrix(matrix) {
|
|
2221
|
-
this.axesHelper.rotation.setFromRotationMatrix(new
|
|
2184
|
+
this.axesHelper.rotation.setFromRotationMatrix(new import_three16.Matrix4().extractRotation(matrix).invert());
|
|
2222
2185
|
}
|
|
2223
2186
|
};
|
|
2224
2187
|
|