@shopware-ag/dive 1.8.0 → 1.10.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 +349 -28
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +26 -4
- package/build/dive.d.ts +26 -4
- package/build/dive.js +342 -21
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/com/index.ts +0 -1
- package/src/com/types.ts +27 -3
- package/src/mediacreator/__test__/MediaCreator.test.ts +1 -1
- package/src/model/Model.ts +50 -1
- package/src/model/__test__/Model.test.ts +68 -19
- package/src/primitive/Primitive.ts +210 -0
- package/src/primitive/__test__/Primitive.test.ts +432 -0
- package/src/scene/__test__/Scene.test.ts +2 -2
- package/src/scene/root/Root.ts +44 -3
- package/src/scene/root/__test__/Root.test.ts +71 -27
- package/src/scene/root/lightroot/__test__/LightRoot.test.ts +2 -3
- package/src/scene/root/modelroot/ModelRoot.ts +1 -0
- package/src/scene/root/modelroot/__test__/ModelRoot.test.ts +3 -0
- package/src/scene/root/primitiveroot/PrimitiveRoot.ts +88 -0
- package/src/scene/root/primitiveroot/__test__/PrimitiveRoot.test.ts +181 -0
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_three15 = require("three");
|
|
675
675
|
|
|
676
676
|
// src/scene/root/Root.ts
|
|
677
|
-
var
|
|
677
|
+
var import_three14 = require("three");
|
|
678
678
|
|
|
679
679
|
// src/scene/root/lightroot/LightRoot.ts
|
|
680
680
|
var import_three7 = require("three");
|
|
@@ -1234,6 +1234,8 @@ var DIVEModel = class extends import_three8.Object3D {
|
|
|
1234
1234
|
this.isSelectable = true;
|
|
1235
1235
|
this.isMoveable = true;
|
|
1236
1236
|
this.gizmo = null;
|
|
1237
|
+
this._mesh = null;
|
|
1238
|
+
this._material = null;
|
|
1237
1239
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1238
1240
|
this.boundingBox = new import_three8.Box3();
|
|
1239
1241
|
}
|
|
@@ -1244,6 +1246,14 @@ var DIVEModel = class extends import_three8.Object3D {
|
|
|
1244
1246
|
child.receiveShadow = true;
|
|
1245
1247
|
child.layers.mask = this.layers.mask;
|
|
1246
1248
|
this.boundingBox.expandByObject(child);
|
|
1249
|
+
if (!this._mesh && "isMesh" in child) {
|
|
1250
|
+
this._mesh = child;
|
|
1251
|
+
if (this._material) {
|
|
1252
|
+
this._mesh.material = this._material;
|
|
1253
|
+
} else {
|
|
1254
|
+
this._material = child.material;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1247
1257
|
});
|
|
1248
1258
|
this.add(gltf.scene);
|
|
1249
1259
|
}
|
|
@@ -1261,6 +1271,28 @@ var DIVEModel = class extends import_three8.Object3D {
|
|
|
1261
1271
|
child.visible = visible;
|
|
1262
1272
|
});
|
|
1263
1273
|
}
|
|
1274
|
+
SetMaterial(material) {
|
|
1275
|
+
console.error("HERE", this._mesh);
|
|
1276
|
+
if (!this._material) {
|
|
1277
|
+
this._material = new import_three8.MeshStandardMaterial();
|
|
1278
|
+
}
|
|
1279
|
+
this._material.color = new import_three8.Color(material.color);
|
|
1280
|
+
if (material.roughnessMap) {
|
|
1281
|
+
this._material.roughnessMap = material.roughnessMap;
|
|
1282
|
+
this._material.roughness = 1;
|
|
1283
|
+
} else {
|
|
1284
|
+
this._material.roughness = material.roughness;
|
|
1285
|
+
}
|
|
1286
|
+
if (material.metalnessMap) {
|
|
1287
|
+
this._material.metalnessMap = material.metalnessMap;
|
|
1288
|
+
this._material.metalness = 0;
|
|
1289
|
+
} else {
|
|
1290
|
+
this._material.metalness = material.metalness;
|
|
1291
|
+
}
|
|
1292
|
+
if (this._mesh) {
|
|
1293
|
+
this._mesh.material = this._material;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1264
1296
|
SetToWorldOrigin() {
|
|
1265
1297
|
var _a;
|
|
1266
1298
|
this.position.set(0, 0, 0);
|
|
@@ -1376,6 +1408,7 @@ var DIVEModelRoot = class extends import_three9.Object3D {
|
|
|
1376
1408
|
if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
|
|
1377
1409
|
if (object.scale !== void 0) sceneObject.SetScale(object.scale);
|
|
1378
1410
|
if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
|
|
1411
|
+
if (object.material !== void 0) sceneObject.SetMaterial(object.material);
|
|
1379
1412
|
}
|
|
1380
1413
|
DeleteModel(object) {
|
|
1381
1414
|
if (object.id === void 0) {
|
|
@@ -1410,12 +1443,265 @@ var DIVEModelRoot = class extends import_three9.Object3D {
|
|
|
1410
1443
|
}
|
|
1411
1444
|
};
|
|
1412
1445
|
|
|
1413
|
-
// src/
|
|
1446
|
+
// src/scene/root/primitiveroot/PrimitiveRoot.ts
|
|
1447
|
+
var import_three11 = require("three");
|
|
1448
|
+
|
|
1449
|
+
// src/primitive/Primitive.ts
|
|
1414
1450
|
var import_three10 = require("three");
|
|
1415
1451
|
init_VisibilityLayerMask();
|
|
1416
|
-
var
|
|
1452
|
+
var DIVEPrimitive = class extends import_three10.Object3D {
|
|
1453
|
+
constructor() {
|
|
1454
|
+
super();
|
|
1455
|
+
this.isSelectable = true;
|
|
1456
|
+
this.isMoveable = true;
|
|
1457
|
+
this.gizmo = null;
|
|
1458
|
+
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1459
|
+
this._mesh = new import_three10.Mesh();
|
|
1460
|
+
this._mesh.layers.mask = PRODUCT_LAYER_MASK;
|
|
1461
|
+
this._mesh.castShadow = true;
|
|
1462
|
+
this._mesh.receiveShadow = true;
|
|
1463
|
+
this.add(this._mesh);
|
|
1464
|
+
this._boundingBox = new import_three10.Box3();
|
|
1465
|
+
}
|
|
1466
|
+
SetGeometry(geometry) {
|
|
1467
|
+
this.clear();
|
|
1468
|
+
this._mesh.geometry = this.assembleGeometry(geometry);
|
|
1469
|
+
this._boundingBox.setFromObject(this._mesh);
|
|
1470
|
+
}
|
|
1471
|
+
SetPosition(position) {
|
|
1472
|
+
this.position.set(position.x, position.y, position.z);
|
|
1473
|
+
}
|
|
1474
|
+
SetRotation(rotation) {
|
|
1475
|
+
this.rotation.setFromVector3(new import_three10.Vector3(rotation.x, rotation.y, rotation.z));
|
|
1476
|
+
}
|
|
1477
|
+
SetScale(scale) {
|
|
1478
|
+
this.scale.set(scale.x, scale.y, scale.z);
|
|
1479
|
+
}
|
|
1480
|
+
SetVisibility(visible) {
|
|
1481
|
+
this.traverse((child) => {
|
|
1482
|
+
child.visible = visible;
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
SetMaterial(material) {
|
|
1486
|
+
const primitiveMaterial = this._mesh.material;
|
|
1487
|
+
primitiveMaterial.color = new import_three10.Color(material.color);
|
|
1488
|
+
if (material.roughnessMap) {
|
|
1489
|
+
primitiveMaterial.roughnessMap = material.roughnessMap;
|
|
1490
|
+
primitiveMaterial.roughness = 1;
|
|
1491
|
+
} else {
|
|
1492
|
+
primitiveMaterial.roughness = material.roughness;
|
|
1493
|
+
}
|
|
1494
|
+
if (material.metalnessMap) {
|
|
1495
|
+
primitiveMaterial.metalnessMap = material.metalnessMap;
|
|
1496
|
+
primitiveMaterial.metalness = 0;
|
|
1497
|
+
} else {
|
|
1498
|
+
primitiveMaterial.metalness = material.metalness;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
SetToWorldOrigin() {
|
|
1502
|
+
var _a;
|
|
1503
|
+
this.position.set(0, 0, 0);
|
|
1504
|
+
(_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 });
|
|
1505
|
+
}
|
|
1506
|
+
PlaceOnFloor() {
|
|
1507
|
+
var _a;
|
|
1508
|
+
this.position.y = -this._boundingBox.min.y * this.scale.y;
|
|
1509
|
+
(_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 });
|
|
1510
|
+
}
|
|
1511
|
+
DropIt() {
|
|
1512
|
+
var _a;
|
|
1513
|
+
if (!this.parent) {
|
|
1514
|
+
console.warn("DIVEModel: DropIt() called on a model that is not in the scene.", this);
|
|
1515
|
+
return;
|
|
1516
|
+
}
|
|
1517
|
+
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1518
|
+
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new import_three10.Vector3()).multiply(this.scale));
|
|
1519
|
+
bbBottomCenter.y = bottomY + this.position.y;
|
|
1520
|
+
const raycaster = new import_three10.Raycaster(bbBottomCenter, new import_three10.Vector3(0, -1, 0));
|
|
1521
|
+
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1522
|
+
const intersections = raycaster.intersectObjects(findSceneRecursive(this).Root.children, true);
|
|
1523
|
+
if (intersections.length > 0) {
|
|
1524
|
+
const mesh = intersections[0].object;
|
|
1525
|
+
mesh.geometry.computeBoundingBox();
|
|
1526
|
+
const meshBB = mesh.geometry.boundingBox;
|
|
1527
|
+
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1528
|
+
const oldPos = this.position.clone();
|
|
1529
|
+
const newPos = this.position.clone().setY(worldPos.y).sub(new import_three10.Vector3(0, bottomY, 0));
|
|
1530
|
+
this.position.copy(newPos);
|
|
1531
|
+
if (this.position.y === oldPos.y) return;
|
|
1532
|
+
(_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 });
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
onMove() {
|
|
1536
|
+
var _a;
|
|
1537
|
+
(_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 });
|
|
1538
|
+
}
|
|
1539
|
+
onSelect() {
|
|
1540
|
+
var _a;
|
|
1541
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1542
|
+
}
|
|
1543
|
+
onDeselect() {
|
|
1544
|
+
var _a;
|
|
1545
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1546
|
+
}
|
|
1547
|
+
assembleGeometry(geometry) {
|
|
1548
|
+
switch (geometry.name) {
|
|
1549
|
+
case "cylinder":
|
|
1550
|
+
return this.createCylinderGeometry(geometry);
|
|
1551
|
+
case "sphere":
|
|
1552
|
+
return this.createSphereGeometry(geometry);
|
|
1553
|
+
case "pyramid":
|
|
1554
|
+
return this.createPyramidGeometry(geometry);
|
|
1555
|
+
case "box":
|
|
1556
|
+
return this.createBoxGeometry(geometry);
|
|
1557
|
+
case "cone":
|
|
1558
|
+
return this.createConeGeometry(geometry);
|
|
1559
|
+
case "wall":
|
|
1560
|
+
return this.createWallGeometry(geometry);
|
|
1561
|
+
case "plane":
|
|
1562
|
+
return this.createPlaneGeometry(geometry);
|
|
1563
|
+
default:
|
|
1564
|
+
return new import_three10.BufferGeometry();
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
createCylinderGeometry(geometry) {
|
|
1568
|
+
return new import_three10.CylinderGeometry(geometry.width * 2, geometry.width * 2, geometry.height, 64);
|
|
1569
|
+
}
|
|
1570
|
+
createSphereGeometry(geometry) {
|
|
1571
|
+
return new import_three10.SphereGeometry(geometry.width * 2, 64);
|
|
1572
|
+
}
|
|
1573
|
+
createPyramidGeometry(geometry) {
|
|
1574
|
+
const geo = new import_three10.BufferGeometry();
|
|
1575
|
+
const { width, height, depth } = geometry;
|
|
1576
|
+
geo.setAttribute("position", new import_three10.Float32BufferAttribute([
|
|
1577
|
+
width / 2,
|
|
1578
|
+
0,
|
|
1579
|
+
depth / 2,
|
|
1580
|
+
// right back
|
|
1581
|
+
width / 2,
|
|
1582
|
+
0,
|
|
1583
|
+
-depth / 2,
|
|
1584
|
+
// right front
|
|
1585
|
+
-width / 2,
|
|
1586
|
+
0,
|
|
1587
|
+
-depth / 2,
|
|
1588
|
+
// left front
|
|
1589
|
+
-width / 2,
|
|
1590
|
+
0,
|
|
1591
|
+
depth / 2,
|
|
1592
|
+
// left back
|
|
1593
|
+
0,
|
|
1594
|
+
height,
|
|
1595
|
+
0
|
|
1596
|
+
// top
|
|
1597
|
+
], 3));
|
|
1598
|
+
geo.setIndex(new import_three10.Uint32BufferAttribute([
|
|
1599
|
+
1,
|
|
1600
|
+
0,
|
|
1601
|
+
4,
|
|
1602
|
+
2,
|
|
1603
|
+
1,
|
|
1604
|
+
4,
|
|
1605
|
+
3,
|
|
1606
|
+
2,
|
|
1607
|
+
4,
|
|
1608
|
+
3,
|
|
1609
|
+
0,
|
|
1610
|
+
4,
|
|
1611
|
+
0,
|
|
1612
|
+
1,
|
|
1613
|
+
2,
|
|
1614
|
+
0,
|
|
1615
|
+
2,
|
|
1616
|
+
3
|
|
1617
|
+
], 1));
|
|
1618
|
+
return geo;
|
|
1619
|
+
}
|
|
1620
|
+
createBoxGeometry(geometry) {
|
|
1621
|
+
return new import_three10.BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1622
|
+
}
|
|
1623
|
+
createConeGeometry(geometry) {
|
|
1624
|
+
return new import_three10.CylinderGeometry(0, geometry.width * 2, geometry.height, 64);
|
|
1625
|
+
}
|
|
1626
|
+
createWallGeometry(geometry) {
|
|
1627
|
+
return new import_three10.BoxGeometry(geometry.width, geometry.height, geometry.depth, 16);
|
|
1628
|
+
}
|
|
1629
|
+
createPlaneGeometry(geometry) {
|
|
1630
|
+
return new import_three10.BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
|
|
1634
|
+
// src/scene/root/primitiveroot/PrimitiveRoot.ts
|
|
1635
|
+
var DIVEPrimitiveRoot = class extends import_three11.Object3D {
|
|
1636
|
+
constructor() {
|
|
1637
|
+
super();
|
|
1638
|
+
this.name = "PrimitiveRoot";
|
|
1639
|
+
}
|
|
1640
|
+
GetPrimitive(object) {
|
|
1641
|
+
if (object.id === void 0) {
|
|
1642
|
+
console.warn("PrimitiveRoot.GetPrimitive: object.id is undefined");
|
|
1643
|
+
return void 0;
|
|
1644
|
+
}
|
|
1645
|
+
return this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1646
|
+
}
|
|
1647
|
+
UpdatePrimitive(object) {
|
|
1648
|
+
if (object.id === void 0) {
|
|
1649
|
+
console.warn("PrimitiveRoot.UpdatePrimitive: object.id is undefined");
|
|
1650
|
+
return;
|
|
1651
|
+
}
|
|
1652
|
+
let sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1653
|
+
if (!sceneObject && object.geometry !== void 0) {
|
|
1654
|
+
const primitive = new DIVEPrimitive();
|
|
1655
|
+
primitive.SetGeometry(object.geometry);
|
|
1656
|
+
sceneObject = primitive;
|
|
1657
|
+
sceneObject.userData.id = object.id;
|
|
1658
|
+
this.add(sceneObject);
|
|
1659
|
+
}
|
|
1660
|
+
if (object.position !== void 0) sceneObject.SetPosition(object.position);
|
|
1661
|
+
if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
|
|
1662
|
+
if (object.scale !== void 0) sceneObject.SetScale(object.scale);
|
|
1663
|
+
if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
|
|
1664
|
+
if (object.material !== void 0) sceneObject.SetMaterial(object.material);
|
|
1665
|
+
}
|
|
1666
|
+
DeletePrimitive(object) {
|
|
1667
|
+
if (object.id === void 0) {
|
|
1668
|
+
console.warn(`PrimitiveRoot.DeletePrimitive: object.id is undefined`);
|
|
1669
|
+
return;
|
|
1670
|
+
}
|
|
1671
|
+
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1672
|
+
if (!sceneObject) {
|
|
1673
|
+
console.warn(`PrimitiveRoot.DeletePrimitive: Primitive with id ${object.id} not found`);
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
const findScene = (object2) => {
|
|
1677
|
+
if (object2.parent !== null) {
|
|
1678
|
+
return findScene(object2.parent);
|
|
1679
|
+
}
|
|
1680
|
+
;
|
|
1681
|
+
return object2;
|
|
1682
|
+
};
|
|
1683
|
+
const scene = findScene(sceneObject);
|
|
1684
|
+
scene.children.find((object2) => {
|
|
1685
|
+
if ("isTransformControls" in object2) {
|
|
1686
|
+
object2.detach();
|
|
1687
|
+
}
|
|
1688
|
+
});
|
|
1689
|
+
this.remove(sceneObject);
|
|
1690
|
+
}
|
|
1691
|
+
PlaceOnFloor(object) {
|
|
1692
|
+
if (object.id === void 0) console.warn("PrimitiveRoot.PlaceOnFloor: object.id is undefined");
|
|
1693
|
+
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1694
|
+
if (!sceneObject) return;
|
|
1695
|
+
sceneObject.PlaceOnFloor();
|
|
1696
|
+
}
|
|
1697
|
+
};
|
|
1698
|
+
|
|
1699
|
+
// src/primitive/floor/Floor.ts
|
|
1700
|
+
var import_three12 = require("three");
|
|
1701
|
+
init_VisibilityLayerMask();
|
|
1702
|
+
var DIVEFloor = class extends import_three12.Mesh {
|
|
1417
1703
|
constructor() {
|
|
1418
|
-
super(new
|
|
1704
|
+
super(new import_three12.PlaneGeometry(1e4, 1e4), new import_three12.MeshStandardMaterial({ color: new import_three12.Color(150 / 255, 150 / 255, 150 / 255) }));
|
|
1419
1705
|
this.isFloor = true;
|
|
1420
1706
|
this.name = "Floor";
|
|
1421
1707
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
@@ -1426,7 +1712,7 @@ var DIVEFloor = class extends import_three10.Mesh {
|
|
|
1426
1712
|
this.visible = visible;
|
|
1427
1713
|
}
|
|
1428
1714
|
SetColor(color) {
|
|
1429
|
-
this.material.color = new
|
|
1715
|
+
this.material.color = new import_three12.Color(color);
|
|
1430
1716
|
}
|
|
1431
1717
|
};
|
|
1432
1718
|
|
|
@@ -1436,12 +1722,12 @@ var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
|
1436
1722
|
|
|
1437
1723
|
// src/grid/Grid.ts
|
|
1438
1724
|
init_VisibilityLayerMask();
|
|
1439
|
-
var
|
|
1440
|
-
var DIVEGrid = class extends
|
|
1725
|
+
var import_three13 = require("three");
|
|
1726
|
+
var DIVEGrid = class extends import_three13.Object3D {
|
|
1441
1727
|
constructor() {
|
|
1442
1728
|
super();
|
|
1443
1729
|
this.name = "Grid";
|
|
1444
|
-
const grid = new
|
|
1730
|
+
const grid = new import_three13.GridHelper(100, 100, GRID_CENTER_LINE_COLOR, GRID_SIDE_LINE_COLOR);
|
|
1445
1731
|
grid.material.depthTest = false;
|
|
1446
1732
|
grid.layers.mask = HELPER_LAYER_MASK;
|
|
1447
1733
|
this.add(grid);
|
|
@@ -1452,7 +1738,7 @@ var DIVEGrid = class extends import_three11.Object3D {
|
|
|
1452
1738
|
};
|
|
1453
1739
|
|
|
1454
1740
|
// src/scene/root/Root.ts
|
|
1455
|
-
var DIVERoot = class extends
|
|
1741
|
+
var DIVERoot = class extends import_three14.Object3D {
|
|
1456
1742
|
get Floor() {
|
|
1457
1743
|
return this.floor;
|
|
1458
1744
|
}
|
|
@@ -1466,18 +1752,25 @@ var DIVERoot = class extends import_three12.Object3D {
|
|
|
1466
1752
|
this.add(this.lightRoot);
|
|
1467
1753
|
this.modelRoot = new DIVEModelRoot();
|
|
1468
1754
|
this.add(this.modelRoot);
|
|
1755
|
+
this.primitiveRoot = new DIVEPrimitiveRoot();
|
|
1756
|
+
this.add(this.primitiveRoot);
|
|
1469
1757
|
this.floor = new DIVEFloor();
|
|
1470
1758
|
this.add(this.floor);
|
|
1471
1759
|
this.grid = new DIVEGrid();
|
|
1472
1760
|
this.add(this.grid);
|
|
1473
1761
|
}
|
|
1474
1762
|
ComputeSceneBB() {
|
|
1475
|
-
const bb = new
|
|
1763
|
+
const bb = new import_three14.Box3();
|
|
1476
1764
|
this.modelRoot.traverse((object) => {
|
|
1477
1765
|
if ("isObject3D" in object) {
|
|
1478
1766
|
bb.expandByObject(object);
|
|
1479
1767
|
}
|
|
1480
1768
|
});
|
|
1769
|
+
this.primitiveRoot.traverse((object) => {
|
|
1770
|
+
if ("isObject3D" in object) {
|
|
1771
|
+
bb.expandByObject(object);
|
|
1772
|
+
}
|
|
1773
|
+
});
|
|
1481
1774
|
return bb;
|
|
1482
1775
|
}
|
|
1483
1776
|
GetSceneObject(object) {
|
|
@@ -1491,6 +1784,9 @@ var DIVERoot = class extends import_three12.Object3D {
|
|
|
1491
1784
|
case "model": {
|
|
1492
1785
|
return this.modelRoot.GetModel(object);
|
|
1493
1786
|
}
|
|
1787
|
+
case "primitive": {
|
|
1788
|
+
return this.primitiveRoot.GetPrimitive(object);
|
|
1789
|
+
}
|
|
1494
1790
|
}
|
|
1495
1791
|
}
|
|
1496
1792
|
AddSceneObject(object) {
|
|
@@ -1506,6 +1802,10 @@ var DIVERoot = class extends import_three12.Object3D {
|
|
|
1506
1802
|
this.modelRoot.UpdateModel(object);
|
|
1507
1803
|
break;
|
|
1508
1804
|
}
|
|
1805
|
+
case "primitive": {
|
|
1806
|
+
this.primitiveRoot.UpdatePrimitive(object);
|
|
1807
|
+
break;
|
|
1808
|
+
}
|
|
1509
1809
|
}
|
|
1510
1810
|
}
|
|
1511
1811
|
UpdateSceneObject(object) {
|
|
@@ -1521,6 +1821,10 @@ var DIVERoot = class extends import_three12.Object3D {
|
|
|
1521
1821
|
this.modelRoot.UpdateModel(object);
|
|
1522
1822
|
break;
|
|
1523
1823
|
}
|
|
1824
|
+
case "primitive": {
|
|
1825
|
+
this.primitiveRoot.UpdatePrimitive(object);
|
|
1826
|
+
break;
|
|
1827
|
+
}
|
|
1524
1828
|
}
|
|
1525
1829
|
}
|
|
1526
1830
|
DeleteSceneObject(object) {
|
|
@@ -1536,26 +1840,43 @@ var DIVERoot = class extends import_three12.Object3D {
|
|
|
1536
1840
|
this.modelRoot.DeleteModel(object);
|
|
1537
1841
|
break;
|
|
1538
1842
|
}
|
|
1843
|
+
case "primitive": {
|
|
1844
|
+
this.primitiveRoot.DeletePrimitive(object);
|
|
1845
|
+
break;
|
|
1846
|
+
}
|
|
1539
1847
|
}
|
|
1540
1848
|
}
|
|
1541
1849
|
PlaceOnFloor(object) {
|
|
1542
|
-
|
|
1850
|
+
switch (object.entityType) {
|
|
1851
|
+
case "pov":
|
|
1852
|
+
case "light": {
|
|
1853
|
+
break;
|
|
1854
|
+
}
|
|
1855
|
+
case "model": {
|
|
1856
|
+
this.modelRoot.PlaceOnFloor(object);
|
|
1857
|
+
break;
|
|
1858
|
+
}
|
|
1859
|
+
case "primitive": {
|
|
1860
|
+
this.primitiveRoot.PlaceOnFloor(object);
|
|
1861
|
+
break;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1543
1864
|
}
|
|
1544
1865
|
};
|
|
1545
1866
|
|
|
1546
1867
|
// src/scene/Scene.ts
|
|
1547
|
-
var DIVEScene = class extends
|
|
1868
|
+
var DIVEScene = class extends import_three15.Scene {
|
|
1548
1869
|
get Root() {
|
|
1549
1870
|
return this.root;
|
|
1550
1871
|
}
|
|
1551
1872
|
constructor() {
|
|
1552
1873
|
super();
|
|
1553
|
-
this.background = new
|
|
1874
|
+
this.background = new import_three15.Color(16777215);
|
|
1554
1875
|
this.root = new DIVERoot();
|
|
1555
1876
|
this.add(this.root);
|
|
1556
1877
|
}
|
|
1557
1878
|
SetBackground(color) {
|
|
1558
|
-
this.background = new
|
|
1879
|
+
this.background = new import_three15.Color(color);
|
|
1559
1880
|
}
|
|
1560
1881
|
ComputeSceneBB() {
|
|
1561
1882
|
return this.Root.ComputeSceneBB();
|
|
@@ -1582,7 +1903,7 @@ init_PerspectiveCamera();
|
|
|
1582
1903
|
|
|
1583
1904
|
// src/controls/OrbitControls.ts
|
|
1584
1905
|
var import_OrbitControls = require("three/examples/jsm/controls/OrbitControls");
|
|
1585
|
-
var
|
|
1906
|
+
var import_three16 = require("three");
|
|
1586
1907
|
var import_tween = require("@tweenjs/tween.js");
|
|
1587
1908
|
var DIVEOrbitControlsDefaultSettings = {
|
|
1588
1909
|
enableDamping: true,
|
|
@@ -1624,8 +1945,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
1624
1945
|
this.dispose();
|
|
1625
1946
|
}
|
|
1626
1947
|
ComputeEncompassingView(bb) {
|
|
1627
|
-
const center = bb.getCenter(new
|
|
1628
|
-
const size = bb.getSize(new
|
|
1948
|
+
const center = bb.getCenter(new import_three16.Vector3());
|
|
1949
|
+
const size = bb.getSize(new import_three16.Vector3());
|
|
1629
1950
|
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
1630
1951
|
const direction = this.object.position.clone().normalize();
|
|
1631
1952
|
return {
|
|
@@ -1636,7 +1957,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
1636
1957
|
ZoomIn(by) {
|
|
1637
1958
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
1638
1959
|
const { minDistance, maxDistance } = this;
|
|
1639
|
-
this.minDistance = this.maxDistance =
|
|
1960
|
+
this.minDistance = this.maxDistance = import_three16.MathUtils.clamp(this.getDistance() - zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
1640
1961
|
this.update();
|
|
1641
1962
|
this.minDistance = minDistance;
|
|
1642
1963
|
this.maxDistance = maxDistance;
|
|
@@ -1644,7 +1965,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.O
|
|
|
1644
1965
|
ZoomOut(by) {
|
|
1645
1966
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
1646
1967
|
const { minDistance, maxDistance } = this;
|
|
1647
|
-
this.minDistance = this.maxDistance =
|
|
1968
|
+
this.minDistance = this.maxDistance = import_three16.MathUtils.clamp(this.getDistance() + zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
1648
1969
|
this.update();
|
|
1649
1970
|
this.minDistance = minDistance;
|
|
1650
1971
|
this.maxDistance = maxDistance;
|
|
@@ -1792,7 +2113,7 @@ var DIVEAnimationSystem = class {
|
|
|
1792
2113
|
};
|
|
1793
2114
|
|
|
1794
2115
|
// src/axiscamera/AxisCamera.ts
|
|
1795
|
-
var
|
|
2116
|
+
var import_three17 = require("three");
|
|
1796
2117
|
var import_three_spritetext = __toESM(require("three-spritetext"), 1);
|
|
1797
2118
|
init_VisibilityLayerMask();
|
|
1798
2119
|
|
|
@@ -1805,18 +2126,18 @@ var AxesColorGreen = AxesColorGreenLetter;
|
|
|
1805
2126
|
var AxesColorBlue = AxesColorBlueLetter;
|
|
1806
2127
|
|
|
1807
2128
|
// src/axiscamera/AxisCamera.ts
|
|
1808
|
-
var DIVEAxisCamera = class extends
|
|
2129
|
+
var DIVEAxisCamera = class extends import_three17.OrthographicCamera {
|
|
1809
2130
|
constructor(renderer, scene, controls) {
|
|
1810
2131
|
super(-1, 1, 1, -1, 0.1, 100);
|
|
1811
2132
|
this.layers.mask = COORDINATE_LAYER_MASK;
|
|
1812
|
-
this.axesHelper = new
|
|
2133
|
+
this.axesHelper = new import_three17.AxesHelper(0.5);
|
|
1813
2134
|
this.axesHelper.layers.mask = COORDINATE_LAYER_MASK;
|
|
1814
2135
|
this.axesHelper.material.depthTest = false;
|
|
1815
2136
|
this.axesHelper.position.set(0, 0, -1);
|
|
1816
2137
|
this.axesHelper.setColors(
|
|
1817
|
-
new
|
|
1818
|
-
new
|
|
1819
|
-
new
|
|
2138
|
+
new import_three17.Color(AxesColorRed),
|
|
2139
|
+
new import_three17.Color(AxesColorGreen),
|
|
2140
|
+
new import_three17.Color(AxesColorBlue)
|
|
1820
2141
|
);
|
|
1821
2142
|
const x = new import_three_spritetext.default("X", 0.2, AxesColorRedLetter);
|
|
1822
2143
|
const y = new import_three_spritetext.default("Y", 0.2, AxesColorGreenLetter);
|
|
@@ -1834,7 +2155,7 @@ var DIVEAxisCamera = class extends import_three15.OrthographicCamera {
|
|
|
1834
2155
|
this._renderer = renderer;
|
|
1835
2156
|
this._scene = scene;
|
|
1836
2157
|
this._scene.add(this);
|
|
1837
|
-
const restoreViewport = new
|
|
2158
|
+
const restoreViewport = new import_three17.Vector4();
|
|
1838
2159
|
this._renderCallbackId = renderer.AddPostRenderCallback(() => {
|
|
1839
2160
|
const restoreBackground = scene.background;
|
|
1840
2161
|
scene.background = null;
|
|
@@ -1853,7 +2174,7 @@ var DIVEAxisCamera = class extends import_three15.OrthographicCamera {
|
|
|
1853
2174
|
this._scene.remove(this);
|
|
1854
2175
|
}
|
|
1855
2176
|
SetFromCameraMatrix(matrix) {
|
|
1856
|
-
this.axesHelper.rotation.setFromRotationMatrix(new
|
|
2177
|
+
this.axesHelper.rotation.setFromRotationMatrix(new import_three17.Matrix4().extractRotation(matrix).invert());
|
|
1857
2178
|
}
|
|
1858
2179
|
};
|
|
1859
2180
|
|