@shopware-ag/dive 1.14.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 +109 -160
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +19 -36
- package/build/dive.d.ts +19 -36
- package/build/dive.js +67 -118
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- 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");
|
|
@@ -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
|
}
|
|
@@ -1569,7 +1523,7 @@ var DIVEGroup = class extends import_three9.Object3D {
|
|
|
1569
1523
|
*/
|
|
1570
1524
|
recalculatePosition() {
|
|
1571
1525
|
var _a;
|
|
1572
|
-
const childrensWorldPositions = this.children.map((child) => child.getWorldPosition(new
|
|
1526
|
+
const childrensWorldPositions = this.children.map((child) => child.getWorldPosition(new import_three10.Vector3()));
|
|
1573
1527
|
const bbcenter = this.updateBB();
|
|
1574
1528
|
this.position.copy(bbcenter);
|
|
1575
1529
|
this.children.forEach((child, i) => {
|
|
@@ -1583,32 +1537,27 @@ var DIVEGroup = class extends import_three9.Object3D {
|
|
|
1583
1537
|
* @returns {Vector3} The new center of the bounding box.
|
|
1584
1538
|
*/
|
|
1585
1539
|
updateBB() {
|
|
1586
|
-
this.
|
|
1540
|
+
this._boundingBox.makeEmpty();
|
|
1587
1541
|
this.children.forEach((child) => {
|
|
1588
1542
|
if (child.uuid === this._boxMesh.uuid) return;
|
|
1589
|
-
this.
|
|
1543
|
+
this._boundingBox.expandByObject(child);
|
|
1590
1544
|
});
|
|
1591
|
-
return this.
|
|
1545
|
+
return this._boundingBox.getCenter(new import_three10.Vector3());
|
|
1592
1546
|
}
|
|
1593
1547
|
updateBoxMesh() {
|
|
1594
|
-
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);
|
|
1595
1551
|
}
|
|
1596
1552
|
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 });
|
|
1553
|
+
super.onMove();
|
|
1554
|
+
this.updateBB();
|
|
1555
|
+
this.updateBoxMesh();
|
|
1607
1556
|
}
|
|
1608
1557
|
};
|
|
1609
1558
|
|
|
1610
1559
|
// src/scene/root/Root.ts
|
|
1611
|
-
var DIVERoot = class extends
|
|
1560
|
+
var DIVERoot = class extends import_three11.Object3D {
|
|
1612
1561
|
constructor() {
|
|
1613
1562
|
super();
|
|
1614
1563
|
this.isDIVERoot = true;
|
|
@@ -1616,7 +1565,7 @@ var DIVERoot = class extends import_three10.Object3D {
|
|
|
1616
1565
|
this.loadingManager = new DIVELoadingManager();
|
|
1617
1566
|
}
|
|
1618
1567
|
ComputeSceneBB() {
|
|
1619
|
-
const bb = new
|
|
1568
|
+
const bb = new import_three11.Box3();
|
|
1620
1569
|
this.traverse((object) => {
|
|
1621
1570
|
if ("isObject3D" in object) {
|
|
1622
1571
|
bb.expandByObject(object);
|
|
@@ -1737,7 +1686,7 @@ var DIVERoot = class extends import_three10.Object3D {
|
|
|
1737
1686
|
if (light.position !== void 0 && light.position !== null) sceneObject.position.set(light.position.x, light.position.y, light.position.z);
|
|
1738
1687
|
if (light.intensity !== void 0 && light.intensity !== null) sceneObject.SetIntensity(light.intensity);
|
|
1739
1688
|
if (light.enabled !== void 0 && light.enabled !== null) sceneObject.SetEnabled(light.enabled);
|
|
1740
|
-
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));
|
|
1741
1690
|
if (light.visible !== void 0 && light.visible !== null) sceneObject.visible = light.visible;
|
|
1742
1691
|
if (light.parent !== void 0) this.setParent(__spreadProps(__spreadValues({}, light), { parent: light.parent }));
|
|
1743
1692
|
}
|
|
@@ -1877,12 +1826,12 @@ var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
|
1877
1826
|
|
|
1878
1827
|
// src/grid/Grid.ts
|
|
1879
1828
|
init_VisibilityLayerMask();
|
|
1880
|
-
var
|
|
1881
|
-
var DIVEGrid = class extends
|
|
1829
|
+
var import_three12 = require("three");
|
|
1830
|
+
var DIVEGrid = class extends import_three12.Object3D {
|
|
1882
1831
|
constructor() {
|
|
1883
1832
|
super();
|
|
1884
1833
|
this.name = "Grid";
|
|
1885
|
-
const grid = new
|
|
1834
|
+
const grid = new import_three12.GridHelper(100, 100, GRID_CENTER_LINE_COLOR, GRID_SIDE_LINE_COLOR);
|
|
1886
1835
|
grid.material.depthTest = false;
|
|
1887
1836
|
grid.layers.mask = HELPER_LAYER_MASK;
|
|
1888
1837
|
this.add(grid);
|
|
@@ -1893,11 +1842,11 @@ var DIVEGrid = class extends import_three11.Object3D {
|
|
|
1893
1842
|
};
|
|
1894
1843
|
|
|
1895
1844
|
// src/primitive/floor/Floor.ts
|
|
1896
|
-
var
|
|
1845
|
+
var import_three13 = require("three");
|
|
1897
1846
|
init_VisibilityLayerMask();
|
|
1898
|
-
var DIVEFloor = class extends
|
|
1847
|
+
var DIVEFloor = class extends import_three13.Mesh {
|
|
1899
1848
|
constructor() {
|
|
1900
|
-
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) }));
|
|
1901
1850
|
this.isFloor = true;
|
|
1902
1851
|
this.name = "Floor";
|
|
1903
1852
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
@@ -1908,12 +1857,12 @@ var DIVEFloor = class extends import_three12.Mesh {
|
|
|
1908
1857
|
this.visible = visible;
|
|
1909
1858
|
}
|
|
1910
1859
|
SetColor(color) {
|
|
1911
|
-
this.material.color = new
|
|
1860
|
+
this.material.color = new import_three13.Color(color);
|
|
1912
1861
|
}
|
|
1913
1862
|
};
|
|
1914
1863
|
|
|
1915
1864
|
// src/scene/Scene.ts
|
|
1916
|
-
var DIVEScene = class extends
|
|
1865
|
+
var DIVEScene = class extends import_three14.Scene {
|
|
1917
1866
|
get Root() {
|
|
1918
1867
|
return this.root;
|
|
1919
1868
|
}
|
|
@@ -1925,7 +1874,7 @@ var DIVEScene = class extends import_three13.Scene {
|
|
|
1925
1874
|
}
|
|
1926
1875
|
constructor() {
|
|
1927
1876
|
super();
|
|
1928
|
-
this.background = new
|
|
1877
|
+
this.background = new import_three14.Color(16777215);
|
|
1929
1878
|
this.root = new DIVERoot();
|
|
1930
1879
|
this.add(this.root);
|
|
1931
1880
|
this.floor = new DIVEFloor();
|
|
@@ -1934,7 +1883,7 @@ var DIVEScene = class extends import_three13.Scene {
|
|
|
1934
1883
|
this.add(this.grid);
|
|
1935
1884
|
}
|
|
1936
1885
|
SetBackground(color) {
|
|
1937
|
-
this.background = new
|
|
1886
|
+
this.background = new import_three14.Color(color);
|
|
1938
1887
|
}
|
|
1939
1888
|
ComputeSceneBB() {
|
|
1940
1889
|
return this.Root.ComputeSceneBB();
|
|
@@ -1961,7 +1910,7 @@ init_PerspectiveCamera();
|
|
|
1961
1910
|
|
|
1962
1911
|
// src/controls/OrbitControls.ts
|
|
1963
1912
|
var import_OrbitControls = require("three/examples/jsm/controls/OrbitControls");
|
|
1964
|
-
var
|
|
1913
|
+
var import_three15 = require("three");
|
|
1965
1914
|
var import_tween = require("@tweenjs/tween.js");
|
|
1966
1915
|
var DIVEOrbitControlsDefaultSettings = {
|
|
1967
1916
|
enableDamping: true,
|
|
@@ -2003,8 +1952,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
2003
1952
|
this.dispose();
|
|
2004
1953
|
}
|
|
2005
1954
|
ComputeEncompassingView(bb) {
|
|
2006
|
-
const center = bb.getCenter(new
|
|
2007
|
-
const size = bb.getSize(new
|
|
1955
|
+
const center = bb.getCenter(new import_three15.Vector3());
|
|
1956
|
+
const size = bb.getSize(new import_three15.Vector3());
|
|
2008
1957
|
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
2009
1958
|
const direction = this.object.position.clone().normalize();
|
|
2010
1959
|
return {
|
|
@@ -2015,7 +1964,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
2015
1964
|
ZoomIn(by) {
|
|
2016
1965
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
2017
1966
|
const { minDistance, maxDistance } = this;
|
|
2018
|
-
this.minDistance = this.maxDistance =
|
|
1967
|
+
this.minDistance = this.maxDistance = import_three15.MathUtils.clamp(this.getDistance() - zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
2019
1968
|
this.update();
|
|
2020
1969
|
this.minDistance = minDistance;
|
|
2021
1970
|
this.maxDistance = maxDistance;
|
|
@@ -2023,7 +1972,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
2023
1972
|
ZoomOut(by) {
|
|
2024
1973
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
2025
1974
|
const { minDistance, maxDistance } = this;
|
|
2026
|
-
this.minDistance = this.maxDistance =
|
|
1975
|
+
this.minDistance = this.maxDistance = import_three15.MathUtils.clamp(this.getDistance() + zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
2027
1976
|
this.update();
|
|
2028
1977
|
this.minDistance = minDistance;
|
|
2029
1978
|
this.maxDistance = maxDistance;
|
|
@@ -2171,7 +2120,7 @@ var DIVEAnimationSystem = class {
|
|
|
2171
2120
|
};
|
|
2172
2121
|
|
|
2173
2122
|
// src/axiscamera/AxisCamera.ts
|
|
2174
|
-
var
|
|
2123
|
+
var import_three16 = require("three");
|
|
2175
2124
|
var import_three_spritetext = __toESM(require("three-spritetext"), 1);
|
|
2176
2125
|
init_VisibilityLayerMask();
|
|
2177
2126
|
|
|
@@ -2184,18 +2133,18 @@ var AxesColorGreen = AxesColorGreenLetter;
|
|
|
2184
2133
|
var AxesColorBlue = AxesColorBlueLetter;
|
|
2185
2134
|
|
|
2186
2135
|
// src/axiscamera/AxisCamera.ts
|
|
2187
|
-
var DIVEAxisCamera = class extends
|
|
2136
|
+
var DIVEAxisCamera = class extends import_three16.OrthographicCamera {
|
|
2188
2137
|
constructor(renderer, scene, controls) {
|
|
2189
2138
|
super(-1, 1, 1, -1, 0.1, 100);
|
|
2190
2139
|
this.layers.mask = COORDINATE_LAYER_MASK;
|
|
2191
|
-
this.axesHelper = new
|
|
2140
|
+
this.axesHelper = new import_three16.AxesHelper(0.5);
|
|
2192
2141
|
this.axesHelper.layers.mask = COORDINATE_LAYER_MASK;
|
|
2193
2142
|
this.axesHelper.material.depthTest = false;
|
|
2194
2143
|
this.axesHelper.position.set(0, 0, -1);
|
|
2195
2144
|
this.axesHelper.setColors(
|
|
2196
|
-
new
|
|
2197
|
-
new
|
|
2198
|
-
new
|
|
2145
|
+
new import_three16.Color(AxesColorRed),
|
|
2146
|
+
new import_three16.Color(AxesColorGreen),
|
|
2147
|
+
new import_three16.Color(AxesColorBlue)
|
|
2199
2148
|
);
|
|
2200
2149
|
const x = new import_three_spritetext.default("X", 0.2, AxesColorRedLetter);
|
|
2201
2150
|
const y = new import_three_spritetext.default("Y", 0.2, AxesColorGreenLetter);
|
|
@@ -2213,7 +2162,7 @@ var DIVEAxisCamera = class extends import_three15.OrthographicCamera {
|
|
|
2213
2162
|
this._renderer = renderer;
|
|
2214
2163
|
this._scene = scene;
|
|
2215
2164
|
this._scene.add(this);
|
|
2216
|
-
const restoreViewport = new
|
|
2165
|
+
const restoreViewport = new import_three16.Vector4();
|
|
2217
2166
|
this._renderCallbackId = renderer.AddPostRenderCallback(() => {
|
|
2218
2167
|
const restoreBackground = scene.background;
|
|
2219
2168
|
scene.background = null;
|
|
@@ -2232,7 +2181,7 @@ var DIVEAxisCamera = class extends import_three15.OrthographicCamera {
|
|
|
2232
2181
|
this._scene.remove(this);
|
|
2233
2182
|
}
|
|
2234
2183
|
SetFromCameraMatrix(matrix) {
|
|
2235
|
-
this.axesHelper.rotation.setFromRotationMatrix(new
|
|
2184
|
+
this.axesHelper.rotation.setFromRotationMatrix(new import_three16.Matrix4().extractRotation(matrix).invert());
|
|
2236
2185
|
}
|
|
2237
2186
|
};
|
|
2238
2187
|
|