@shopware-ag/dive 1.7.0 → 1.9.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/README.md +1 -1
- package/build/dive.cjs +344 -45
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +33 -11
- package/build/dive.d.ts +33 -11
- package/build/dive.js +335 -36
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/__test__/DIVE.test.ts +2 -1
- package/src/camera/PerspectiveCamera.ts +7 -2
- package/src/camera/__test__/PerspectiveCamera.test.ts +11 -2
- package/src/com/index.ts +0 -1
- package/src/com/types.ts +26 -3
- package/src/controls/OrbitControls.ts +9 -4
- package/src/controls/__test__/OrbitControls.test.ts +15 -5
- package/src/dive.ts +10 -8
- package/src/mediacreator/__test__/MediaCreator.test.ts +1 -1
- package/src/primitive/Primitive.ts +210 -0
- package/src/primitive/__test__/Primitive.test.ts +434 -0
- package/src/renderer/Renderer.ts +10 -7
- package/src/renderer/__test__/Renderer.test.ts +11 -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/primitiveroot/PrimitiveRoot.ts +88 -0
- package/src/scene/root/primitiveroot/__test__/PrimitiveRoot.test.ts +181 -0
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<img alt="dive: npm" src="https://img.shields.io/npm/v/%40shopware-ag%2Fdive">
|
|
9
9
|
</a>
|
|
10
10
|
<a href="#badge">
|
|
11
|
-
<img alt="dive:
|
|
11
|
+
<img alt="dive: license" src="https://img.shields.io/npm/l/%40shopware-ag%2Fdive">
|
|
12
12
|
</a>
|
|
13
13
|
<a href="#badge">
|
|
14
14
|
<img alt="dive: types" src="https://img.shields.io/npm/types/%40shopware-ag%2Fdive">
|
package/build/dive.cjs
CHANGED
|
@@ -460,7 +460,12 @@ var init_PerspectiveCamera = __esm({
|
|
|
460
460
|
};
|
|
461
461
|
_DIVEPerspectiveCamera = class _DIVEPerspectiveCamera extends import_three4.PerspectiveCamera {
|
|
462
462
|
constructor(settings = DIVEPerspectiveCameraDefaultSettings) {
|
|
463
|
-
super(
|
|
463
|
+
super(
|
|
464
|
+
settings.fov || DIVEPerspectiveCameraDefaultSettings.fov,
|
|
465
|
+
1,
|
|
466
|
+
settings.near || DIVEPerspectiveCameraDefaultSettings.near,
|
|
467
|
+
settings.far || DIVEPerspectiveCameraDefaultSettings.far
|
|
468
|
+
);
|
|
464
469
|
this.onSetCameraLayer = () => {
|
|
465
470
|
};
|
|
466
471
|
this.layers.mask = _DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK;
|
|
@@ -546,14 +551,16 @@ var DIVERendererDefaultSettings = {
|
|
|
546
551
|
stencil: false,
|
|
547
552
|
shadowMapEnabled: true,
|
|
548
553
|
shadowMapType: import_three.PCFSoftShadowMap,
|
|
549
|
-
toneMapping: import_three.NoToneMapping
|
|
554
|
+
toneMapping: import_three.NoToneMapping,
|
|
555
|
+
canvas: void 0
|
|
550
556
|
};
|
|
551
557
|
var DIVERenderer = class extends import_three.WebGLRenderer {
|
|
552
558
|
constructor(rendererSettings = DIVERendererDefaultSettings) {
|
|
553
559
|
super({
|
|
554
|
-
antialias: rendererSettings.antialias,
|
|
555
|
-
alpha: rendererSettings.alpha,
|
|
556
|
-
preserveDrawingBuffer: true
|
|
560
|
+
antialias: rendererSettings.antialias || DIVERendererDefaultSettings.antialias,
|
|
561
|
+
alpha: rendererSettings.alpha || DIVERendererDefaultSettings.alpha,
|
|
562
|
+
preserveDrawingBuffer: true,
|
|
563
|
+
canvas: rendererSettings.canvas
|
|
557
564
|
});
|
|
558
565
|
// basic functionality members
|
|
559
566
|
this.paused = false;
|
|
@@ -563,9 +570,9 @@ var DIVERenderer = class extends import_three.WebGLRenderer {
|
|
|
563
570
|
this.preRenderCallbacks = /* @__PURE__ */ new Map();
|
|
564
571
|
this.postRenderCallbacks = /* @__PURE__ */ new Map();
|
|
565
572
|
this.setPixelRatio(window.devicePixelRatio);
|
|
566
|
-
this.shadowMap.enabled = rendererSettings.shadowMapEnabled;
|
|
567
|
-
this.shadowMap.type = rendererSettings.shadowMapType;
|
|
568
|
-
this.toneMapping = rendererSettings.toneMapping;
|
|
573
|
+
this.shadowMap.enabled = rendererSettings.shadowMapEnabled || DIVERendererDefaultSettings.shadowMapEnabled;
|
|
574
|
+
this.shadowMap.type = rendererSettings.shadowMapType || DIVERendererDefaultSettings.shadowMapType;
|
|
575
|
+
this.toneMapping = rendererSettings.toneMapping || DIVERendererDefaultSettings.toneMapping;
|
|
569
576
|
this.debug.checkShaderErrors = false;
|
|
570
577
|
}
|
|
571
578
|
// Stops renderings and disposes the renderer.
|
|
@@ -664,10 +671,10 @@ var DIVERenderer = class extends import_three.WebGLRenderer {
|
|
|
664
671
|
};
|
|
665
672
|
|
|
666
673
|
// src/scene/Scene.ts
|
|
667
|
-
var
|
|
674
|
+
var import_three15 = require("three");
|
|
668
675
|
|
|
669
676
|
// src/scene/root/Root.ts
|
|
670
|
-
var
|
|
677
|
+
var import_three14 = require("three");
|
|
671
678
|
|
|
672
679
|
// src/scene/root/lightroot/LightRoot.ts
|
|
673
680
|
var import_three7 = require("three");
|
|
@@ -1403,12 +1410,265 @@ var DIVEModelRoot = class extends import_three9.Object3D {
|
|
|
1403
1410
|
}
|
|
1404
1411
|
};
|
|
1405
1412
|
|
|
1406
|
-
// src/
|
|
1413
|
+
// src/scene/root/primitiveroot/PrimitiveRoot.ts
|
|
1414
|
+
var import_three11 = require("three");
|
|
1415
|
+
|
|
1416
|
+
// src/primitive/Primitive.ts
|
|
1407
1417
|
var import_three10 = require("three");
|
|
1408
1418
|
init_VisibilityLayerMask();
|
|
1409
|
-
var
|
|
1419
|
+
var DIVEPrimitive = class extends import_three10.Object3D {
|
|
1420
|
+
constructor() {
|
|
1421
|
+
super();
|
|
1422
|
+
this.isSelectable = true;
|
|
1423
|
+
this.isMoveable = true;
|
|
1424
|
+
this.gizmo = null;
|
|
1425
|
+
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1426
|
+
this._mesh = new import_three10.Mesh();
|
|
1427
|
+
this._mesh.layers.mask = PRODUCT_LAYER_MASK;
|
|
1428
|
+
this._mesh.castShadow = true;
|
|
1429
|
+
this._mesh.receiveShadow = true;
|
|
1430
|
+
this.add(this._mesh);
|
|
1431
|
+
this._boundingBox = new import_three10.Box3();
|
|
1432
|
+
}
|
|
1433
|
+
SetGeometry(geometry) {
|
|
1434
|
+
this.clear();
|
|
1435
|
+
this._mesh.geometry = this.assembleGeometry(geometry);
|
|
1436
|
+
this._boundingBox.setFromObject(this._mesh);
|
|
1437
|
+
}
|
|
1438
|
+
SetPosition(position) {
|
|
1439
|
+
this.position.set(position.x, position.y, position.z);
|
|
1440
|
+
}
|
|
1441
|
+
SetRotation(rotation) {
|
|
1442
|
+
this.rotation.setFromVector3(new import_three10.Vector3(rotation.x, rotation.y, rotation.z));
|
|
1443
|
+
}
|
|
1444
|
+
SetScale(scale) {
|
|
1445
|
+
this.scale.set(scale.x, scale.y, scale.z);
|
|
1446
|
+
}
|
|
1447
|
+
SetVisibility(visible) {
|
|
1448
|
+
this.traverse((child) => {
|
|
1449
|
+
child.visible = visible;
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
SetMaterial(material) {
|
|
1453
|
+
const primitiveMaterial = this._mesh.material;
|
|
1454
|
+
primitiveMaterial.color = new import_three10.Color(material.color);
|
|
1455
|
+
if (material.roughnessMap) {
|
|
1456
|
+
primitiveMaterial.roughnessMap = material.roughnessMap;
|
|
1457
|
+
primitiveMaterial.roughness = 1;
|
|
1458
|
+
} else {
|
|
1459
|
+
primitiveMaterial.roughness = material.roughness;
|
|
1460
|
+
}
|
|
1461
|
+
if (material.metalnessMap) {
|
|
1462
|
+
primitiveMaterial.metalnessMap = material.metalnessMap;
|
|
1463
|
+
primitiveMaterial.metalness = 0;
|
|
1464
|
+
} else {
|
|
1465
|
+
primitiveMaterial.metalness = material.metalness;
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
SetToWorldOrigin() {
|
|
1469
|
+
var _a;
|
|
1470
|
+
this.position.set(0, 0, 0);
|
|
1471
|
+
(_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 });
|
|
1472
|
+
}
|
|
1473
|
+
PlaceOnFloor() {
|
|
1474
|
+
var _a;
|
|
1475
|
+
this.position.y = -this._boundingBox.min.y * this.scale.y;
|
|
1476
|
+
(_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 });
|
|
1477
|
+
}
|
|
1478
|
+
DropIt() {
|
|
1479
|
+
var _a;
|
|
1480
|
+
if (!this.parent) {
|
|
1481
|
+
console.warn("DIVEModel: DropIt() called on a model that is not in the scene.", this);
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
1484
|
+
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1485
|
+
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new import_three10.Vector3()).multiply(this.scale));
|
|
1486
|
+
bbBottomCenter.y = bottomY + this.position.y;
|
|
1487
|
+
const raycaster = new import_three10.Raycaster(bbBottomCenter, new import_three10.Vector3(0, -1, 0));
|
|
1488
|
+
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1489
|
+
const intersections = raycaster.intersectObjects(findSceneRecursive(this).Root.children, true);
|
|
1490
|
+
if (intersections.length > 0) {
|
|
1491
|
+
const mesh = intersections[0].object;
|
|
1492
|
+
mesh.geometry.computeBoundingBox();
|
|
1493
|
+
const meshBB = mesh.geometry.boundingBox;
|
|
1494
|
+
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1495
|
+
const oldPos = this.position.clone();
|
|
1496
|
+
const newPos = this.position.clone().setY(worldPos.y).sub(new import_three10.Vector3(0, bottomY, 0));
|
|
1497
|
+
this.position.copy(newPos);
|
|
1498
|
+
if (this.position.y === oldPos.y) return;
|
|
1499
|
+
(_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 });
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
onMove() {
|
|
1503
|
+
var _a;
|
|
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
|
+
onSelect() {
|
|
1507
|
+
var _a;
|
|
1508
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1509
|
+
}
|
|
1510
|
+
onDeselect() {
|
|
1511
|
+
var _a;
|
|
1512
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1513
|
+
}
|
|
1514
|
+
assembleGeometry(geometry) {
|
|
1515
|
+
switch (geometry.name) {
|
|
1516
|
+
case "cylinder":
|
|
1517
|
+
return this.createCylinderGeometry(geometry);
|
|
1518
|
+
case "sphere":
|
|
1519
|
+
return this.createSphereGeometry(geometry);
|
|
1520
|
+
case "pyramid":
|
|
1521
|
+
return this.createPyramidGeometry(geometry);
|
|
1522
|
+
case "box":
|
|
1523
|
+
return this.createBoxGeometry(geometry);
|
|
1524
|
+
case "cone":
|
|
1525
|
+
return this.createConeGeometry(geometry);
|
|
1526
|
+
case "wall":
|
|
1527
|
+
return this.createWallGeometry(geometry);
|
|
1528
|
+
case "plane":
|
|
1529
|
+
return this.createPlaneGeometry(geometry);
|
|
1530
|
+
default:
|
|
1531
|
+
return new import_three10.BufferGeometry();
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
createCylinderGeometry(geometry) {
|
|
1535
|
+
return new import_three10.CylinderGeometry(geometry.width * 2, geometry.width * 2, geometry.height, 64);
|
|
1536
|
+
}
|
|
1537
|
+
createSphereGeometry(geometry) {
|
|
1538
|
+
return new import_three10.SphereGeometry(geometry.width * 2, 64);
|
|
1539
|
+
}
|
|
1540
|
+
createPyramidGeometry(geometry) {
|
|
1541
|
+
const geo = new import_three10.BufferGeometry();
|
|
1542
|
+
const { width, height, depth } = geometry;
|
|
1543
|
+
geo.setAttribute("position", new import_three10.Float32BufferAttribute([
|
|
1544
|
+
width / 2,
|
|
1545
|
+
0,
|
|
1546
|
+
depth / 2,
|
|
1547
|
+
// right back
|
|
1548
|
+
width / 2,
|
|
1549
|
+
0,
|
|
1550
|
+
-depth / 2,
|
|
1551
|
+
// right front
|
|
1552
|
+
-width / 2,
|
|
1553
|
+
0,
|
|
1554
|
+
-depth / 2,
|
|
1555
|
+
// left front
|
|
1556
|
+
-width / 2,
|
|
1557
|
+
0,
|
|
1558
|
+
depth / 2,
|
|
1559
|
+
// left back
|
|
1560
|
+
0,
|
|
1561
|
+
height,
|
|
1562
|
+
0
|
|
1563
|
+
// top
|
|
1564
|
+
], 3));
|
|
1565
|
+
geo.setIndex(new import_three10.Uint32BufferAttribute([
|
|
1566
|
+
1,
|
|
1567
|
+
0,
|
|
1568
|
+
4,
|
|
1569
|
+
2,
|
|
1570
|
+
1,
|
|
1571
|
+
4,
|
|
1572
|
+
3,
|
|
1573
|
+
2,
|
|
1574
|
+
4,
|
|
1575
|
+
3,
|
|
1576
|
+
0,
|
|
1577
|
+
4,
|
|
1578
|
+
0,
|
|
1579
|
+
1,
|
|
1580
|
+
2,
|
|
1581
|
+
0,
|
|
1582
|
+
2,
|
|
1583
|
+
3
|
|
1584
|
+
], 1));
|
|
1585
|
+
return geo;
|
|
1586
|
+
}
|
|
1587
|
+
createBoxGeometry(geometry) {
|
|
1588
|
+
return new import_three10.BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1589
|
+
}
|
|
1590
|
+
createConeGeometry(geometry) {
|
|
1591
|
+
return new import_three10.CylinderGeometry(0, geometry.width * 2, geometry.height, 64);
|
|
1592
|
+
}
|
|
1593
|
+
createWallGeometry(geometry) {
|
|
1594
|
+
return new import_three10.BoxGeometry(geometry.width, geometry.height, geometry.depth, 16);
|
|
1595
|
+
}
|
|
1596
|
+
createPlaneGeometry(geometry) {
|
|
1597
|
+
return new import_three10.BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1598
|
+
}
|
|
1599
|
+
};
|
|
1600
|
+
|
|
1601
|
+
// src/scene/root/primitiveroot/PrimitiveRoot.ts
|
|
1602
|
+
var DIVEPrimitiveRoot = class extends import_three11.Object3D {
|
|
1410
1603
|
constructor() {
|
|
1411
|
-
super(
|
|
1604
|
+
super();
|
|
1605
|
+
this.name = "PrimitiveRoot";
|
|
1606
|
+
}
|
|
1607
|
+
GetPrimitive(object) {
|
|
1608
|
+
if (object.id === void 0) {
|
|
1609
|
+
console.warn("PrimitiveRoot.GetPrimitive: object.id is undefined");
|
|
1610
|
+
return void 0;
|
|
1611
|
+
}
|
|
1612
|
+
return this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1613
|
+
}
|
|
1614
|
+
UpdatePrimitive(object) {
|
|
1615
|
+
if (object.id === void 0) {
|
|
1616
|
+
console.warn("PrimitiveRoot.UpdatePrimitive: object.id is undefined");
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
let sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1620
|
+
if (!sceneObject && object.geometry !== void 0) {
|
|
1621
|
+
const primitive = new DIVEPrimitive();
|
|
1622
|
+
primitive.SetGeometry(object.geometry);
|
|
1623
|
+
sceneObject = primitive;
|
|
1624
|
+
sceneObject.userData.id = object.id;
|
|
1625
|
+
this.add(sceneObject);
|
|
1626
|
+
}
|
|
1627
|
+
if (object.position !== void 0) sceneObject.SetPosition(object.position);
|
|
1628
|
+
if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
|
|
1629
|
+
if (object.scale !== void 0) sceneObject.SetScale(object.scale);
|
|
1630
|
+
if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
|
|
1631
|
+
if (object.material !== void 0) sceneObject.SetMaterial(object.material);
|
|
1632
|
+
}
|
|
1633
|
+
DeletePrimitive(object) {
|
|
1634
|
+
if (object.id === void 0) {
|
|
1635
|
+
console.warn(`PrimitiveRoot.DeletePrimitive: object.id is undefined`);
|
|
1636
|
+
return;
|
|
1637
|
+
}
|
|
1638
|
+
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1639
|
+
if (!sceneObject) {
|
|
1640
|
+
console.warn(`PrimitiveRoot.DeletePrimitive: Primitive with id ${object.id} not found`);
|
|
1641
|
+
return;
|
|
1642
|
+
}
|
|
1643
|
+
const findScene = (object2) => {
|
|
1644
|
+
if (object2.parent !== null) {
|
|
1645
|
+
return findScene(object2.parent);
|
|
1646
|
+
}
|
|
1647
|
+
;
|
|
1648
|
+
return object2;
|
|
1649
|
+
};
|
|
1650
|
+
const scene = findScene(sceneObject);
|
|
1651
|
+
scene.children.find((object2) => {
|
|
1652
|
+
if ("isTransformControls" in object2) {
|
|
1653
|
+
object2.detach();
|
|
1654
|
+
}
|
|
1655
|
+
});
|
|
1656
|
+
this.remove(sceneObject);
|
|
1657
|
+
}
|
|
1658
|
+
PlaceOnFloor(object) {
|
|
1659
|
+
if (object.id === void 0) console.warn("PrimitiveRoot.PlaceOnFloor: object.id is undefined");
|
|
1660
|
+
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1661
|
+
if (!sceneObject) return;
|
|
1662
|
+
sceneObject.PlaceOnFloor();
|
|
1663
|
+
}
|
|
1664
|
+
};
|
|
1665
|
+
|
|
1666
|
+
// src/primitive/floor/Floor.ts
|
|
1667
|
+
var import_three12 = require("three");
|
|
1668
|
+
init_VisibilityLayerMask();
|
|
1669
|
+
var DIVEFloor = class extends import_three12.Mesh {
|
|
1670
|
+
constructor() {
|
|
1671
|
+
super(new import_three12.PlaneGeometry(1e4, 1e4), new import_three12.MeshStandardMaterial({ color: new import_three12.Color(150 / 255, 150 / 255, 150 / 255) }));
|
|
1412
1672
|
this.isFloor = true;
|
|
1413
1673
|
this.name = "Floor";
|
|
1414
1674
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
@@ -1419,7 +1679,7 @@ var DIVEFloor = class extends import_three10.Mesh {
|
|
|
1419
1679
|
this.visible = visible;
|
|
1420
1680
|
}
|
|
1421
1681
|
SetColor(color) {
|
|
1422
|
-
this.material.color = new
|
|
1682
|
+
this.material.color = new import_three12.Color(color);
|
|
1423
1683
|
}
|
|
1424
1684
|
};
|
|
1425
1685
|
|
|
@@ -1429,12 +1689,12 @@ var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
|
1429
1689
|
|
|
1430
1690
|
// src/grid/Grid.ts
|
|
1431
1691
|
init_VisibilityLayerMask();
|
|
1432
|
-
var
|
|
1433
|
-
var DIVEGrid = class extends
|
|
1692
|
+
var import_three13 = require("three");
|
|
1693
|
+
var DIVEGrid = class extends import_three13.Object3D {
|
|
1434
1694
|
constructor() {
|
|
1435
1695
|
super();
|
|
1436
1696
|
this.name = "Grid";
|
|
1437
|
-
const grid = new
|
|
1697
|
+
const grid = new import_three13.GridHelper(100, 100, GRID_CENTER_LINE_COLOR, GRID_SIDE_LINE_COLOR);
|
|
1438
1698
|
grid.material.depthTest = false;
|
|
1439
1699
|
grid.layers.mask = HELPER_LAYER_MASK;
|
|
1440
1700
|
this.add(grid);
|
|
@@ -1445,7 +1705,7 @@ var DIVEGrid = class extends import_three11.Object3D {
|
|
|
1445
1705
|
};
|
|
1446
1706
|
|
|
1447
1707
|
// src/scene/root/Root.ts
|
|
1448
|
-
var DIVERoot = class extends
|
|
1708
|
+
var DIVERoot = class extends import_three14.Object3D {
|
|
1449
1709
|
get Floor() {
|
|
1450
1710
|
return this.floor;
|
|
1451
1711
|
}
|
|
@@ -1459,18 +1719,25 @@ var DIVERoot = class extends import_three12.Object3D {
|
|
|
1459
1719
|
this.add(this.lightRoot);
|
|
1460
1720
|
this.modelRoot = new DIVEModelRoot();
|
|
1461
1721
|
this.add(this.modelRoot);
|
|
1722
|
+
this.primitiveRoot = new DIVEPrimitiveRoot();
|
|
1723
|
+
this.add(this.primitiveRoot);
|
|
1462
1724
|
this.floor = new DIVEFloor();
|
|
1463
1725
|
this.add(this.floor);
|
|
1464
1726
|
this.grid = new DIVEGrid();
|
|
1465
1727
|
this.add(this.grid);
|
|
1466
1728
|
}
|
|
1467
1729
|
ComputeSceneBB() {
|
|
1468
|
-
const bb = new
|
|
1730
|
+
const bb = new import_three14.Box3();
|
|
1469
1731
|
this.modelRoot.traverse((object) => {
|
|
1470
1732
|
if ("isObject3D" in object) {
|
|
1471
1733
|
bb.expandByObject(object);
|
|
1472
1734
|
}
|
|
1473
1735
|
});
|
|
1736
|
+
this.primitiveRoot.traverse((object) => {
|
|
1737
|
+
if ("isObject3D" in object) {
|
|
1738
|
+
bb.expandByObject(object);
|
|
1739
|
+
}
|
|
1740
|
+
});
|
|
1474
1741
|
return bb;
|
|
1475
1742
|
}
|
|
1476
1743
|
GetSceneObject(object) {
|
|
@@ -1484,6 +1751,9 @@ var DIVERoot = class extends import_three12.Object3D {
|
|
|
1484
1751
|
case "model": {
|
|
1485
1752
|
return this.modelRoot.GetModel(object);
|
|
1486
1753
|
}
|
|
1754
|
+
case "primitive": {
|
|
1755
|
+
return this.primitiveRoot.GetPrimitive(object);
|
|
1756
|
+
}
|
|
1487
1757
|
}
|
|
1488
1758
|
}
|
|
1489
1759
|
AddSceneObject(object) {
|
|
@@ -1499,6 +1769,10 @@ var DIVERoot = class extends import_three12.Object3D {
|
|
|
1499
1769
|
this.modelRoot.UpdateModel(object);
|
|
1500
1770
|
break;
|
|
1501
1771
|
}
|
|
1772
|
+
case "primitive": {
|
|
1773
|
+
this.primitiveRoot.UpdatePrimitive(object);
|
|
1774
|
+
break;
|
|
1775
|
+
}
|
|
1502
1776
|
}
|
|
1503
1777
|
}
|
|
1504
1778
|
UpdateSceneObject(object) {
|
|
@@ -1514,6 +1788,10 @@ var DIVERoot = class extends import_three12.Object3D {
|
|
|
1514
1788
|
this.modelRoot.UpdateModel(object);
|
|
1515
1789
|
break;
|
|
1516
1790
|
}
|
|
1791
|
+
case "primitive": {
|
|
1792
|
+
this.primitiveRoot.UpdatePrimitive(object);
|
|
1793
|
+
break;
|
|
1794
|
+
}
|
|
1517
1795
|
}
|
|
1518
1796
|
}
|
|
1519
1797
|
DeleteSceneObject(object) {
|
|
@@ -1529,26 +1807,43 @@ var DIVERoot = class extends import_three12.Object3D {
|
|
|
1529
1807
|
this.modelRoot.DeleteModel(object);
|
|
1530
1808
|
break;
|
|
1531
1809
|
}
|
|
1810
|
+
case "primitive": {
|
|
1811
|
+
this.primitiveRoot.DeletePrimitive(object);
|
|
1812
|
+
break;
|
|
1813
|
+
}
|
|
1532
1814
|
}
|
|
1533
1815
|
}
|
|
1534
1816
|
PlaceOnFloor(object) {
|
|
1535
|
-
|
|
1817
|
+
switch (object.entityType) {
|
|
1818
|
+
case "pov":
|
|
1819
|
+
case "light": {
|
|
1820
|
+
break;
|
|
1821
|
+
}
|
|
1822
|
+
case "model": {
|
|
1823
|
+
this.modelRoot.PlaceOnFloor(object);
|
|
1824
|
+
break;
|
|
1825
|
+
}
|
|
1826
|
+
case "primitive": {
|
|
1827
|
+
this.primitiveRoot.PlaceOnFloor(object);
|
|
1828
|
+
break;
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1536
1831
|
}
|
|
1537
1832
|
};
|
|
1538
1833
|
|
|
1539
1834
|
// src/scene/Scene.ts
|
|
1540
|
-
var DIVEScene = class extends
|
|
1835
|
+
var DIVEScene = class extends import_three15.Scene {
|
|
1541
1836
|
get Root() {
|
|
1542
1837
|
return this.root;
|
|
1543
1838
|
}
|
|
1544
1839
|
constructor() {
|
|
1545
1840
|
super();
|
|
1546
|
-
this.background = new
|
|
1841
|
+
this.background = new import_three15.Color(16777215);
|
|
1547
1842
|
this.root = new DIVERoot();
|
|
1548
1843
|
this.add(this.root);
|
|
1549
1844
|
}
|
|
1550
1845
|
SetBackground(color) {
|
|
1551
|
-
this.background = new
|
|
1846
|
+
this.background = new import_three15.Color(color);
|
|
1552
1847
|
}
|
|
1553
1848
|
ComputeSceneBB() {
|
|
1554
1849
|
return this.Root.ComputeSceneBB();
|
|
@@ -1574,14 +1869,14 @@ var DIVEScene = class extends import_three13.Scene {
|
|
|
1574
1869
|
init_PerspectiveCamera();
|
|
1575
1870
|
|
|
1576
1871
|
// src/controls/OrbitControls.ts
|
|
1577
|
-
var
|
|
1578
|
-
var
|
|
1872
|
+
var import_OrbitControls = require("three/examples/jsm/controls/OrbitControls");
|
|
1873
|
+
var import_three16 = require("three");
|
|
1579
1874
|
var import_tween = require("@tweenjs/tween.js");
|
|
1580
1875
|
var DIVEOrbitControlsDefaultSettings = {
|
|
1581
1876
|
enableDamping: true,
|
|
1582
1877
|
dampingFactor: 0.04
|
|
1583
1878
|
};
|
|
1584
|
-
var _DIVEOrbitControls = class _DIVEOrbitControls extends
|
|
1879
|
+
var _DIVEOrbitControls = class _DIVEOrbitControls extends import_OrbitControls.OrbitControls {
|
|
1585
1880
|
constructor(camera, renderer, animationSystem, settings = DIVEOrbitControlsDefaultSettings) {
|
|
1586
1881
|
super(camera, renderer.domElement);
|
|
1587
1882
|
this.last = null;
|
|
@@ -1606,16 +1901,19 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_Addons3.OrbitCo
|
|
|
1606
1901
|
this._removePreRenderCallback = () => {
|
|
1607
1902
|
renderer.RemovePreRenderCallback(id);
|
|
1608
1903
|
};
|
|
1609
|
-
this.enableDamping = settings.enableDamping;
|
|
1610
|
-
this.dampingFactor = settings.dampingFactor;
|
|
1904
|
+
this.enableDamping = settings.enableDamping || DIVEOrbitControlsDefaultSettings.enableDamping;
|
|
1905
|
+
this.dampingFactor = settings.dampingFactor || DIVEOrbitControlsDefaultSettings.dampingFactor;
|
|
1906
|
+
this.object.position.set(0, 2, 2);
|
|
1907
|
+
this.target.copy({ x: 0, y: 0.5, z: 0 });
|
|
1908
|
+
this.update();
|
|
1611
1909
|
}
|
|
1612
1910
|
Dispose() {
|
|
1613
1911
|
this._removePreRenderCallback();
|
|
1614
1912
|
this.dispose();
|
|
1615
1913
|
}
|
|
1616
1914
|
ComputeEncompassingView(bb) {
|
|
1617
|
-
const center = bb.getCenter(new
|
|
1618
|
-
const size = bb.getSize(new
|
|
1915
|
+
const center = bb.getCenter(new import_three16.Vector3());
|
|
1916
|
+
const size = bb.getSize(new import_three16.Vector3());
|
|
1619
1917
|
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
1620
1918
|
const direction = this.object.position.clone().normalize();
|
|
1621
1919
|
return {
|
|
@@ -1626,7 +1924,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_Addons3.OrbitCo
|
|
|
1626
1924
|
ZoomIn(by) {
|
|
1627
1925
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
1628
1926
|
const { minDistance, maxDistance } = this;
|
|
1629
|
-
this.minDistance = this.maxDistance =
|
|
1927
|
+
this.minDistance = this.maxDistance = import_three16.MathUtils.clamp(this.getDistance() - zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
1630
1928
|
this.update();
|
|
1631
1929
|
this.minDistance = minDistance;
|
|
1632
1930
|
this.maxDistance = maxDistance;
|
|
@@ -1634,7 +1932,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_Addons3.OrbitCo
|
|
|
1634
1932
|
ZoomOut(by) {
|
|
1635
1933
|
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
1636
1934
|
const { minDistance, maxDistance } = this;
|
|
1637
|
-
this.minDistance = this.maxDistance =
|
|
1935
|
+
this.minDistance = this.maxDistance = import_three16.MathUtils.clamp(this.getDistance() + zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
|
|
1638
1936
|
this.update();
|
|
1639
1937
|
this.minDistance = minDistance;
|
|
1640
1938
|
this.maxDistance = maxDistance;
|
|
@@ -1782,7 +2080,7 @@ var DIVEAnimationSystem = class {
|
|
|
1782
2080
|
};
|
|
1783
2081
|
|
|
1784
2082
|
// src/axiscamera/AxisCamera.ts
|
|
1785
|
-
var
|
|
2083
|
+
var import_three17 = require("three");
|
|
1786
2084
|
var import_three_spritetext = __toESM(require("three-spritetext"), 1);
|
|
1787
2085
|
init_VisibilityLayerMask();
|
|
1788
2086
|
|
|
@@ -1795,18 +2093,18 @@ var AxesColorGreen = AxesColorGreenLetter;
|
|
|
1795
2093
|
var AxesColorBlue = AxesColorBlueLetter;
|
|
1796
2094
|
|
|
1797
2095
|
// src/axiscamera/AxisCamera.ts
|
|
1798
|
-
var DIVEAxisCamera = class extends
|
|
2096
|
+
var DIVEAxisCamera = class extends import_three17.OrthographicCamera {
|
|
1799
2097
|
constructor(renderer, scene, controls) {
|
|
1800
2098
|
super(-1, 1, 1, -1, 0.1, 100);
|
|
1801
2099
|
this.layers.mask = COORDINATE_LAYER_MASK;
|
|
1802
|
-
this.axesHelper = new
|
|
2100
|
+
this.axesHelper = new import_three17.AxesHelper(0.5);
|
|
1803
2101
|
this.axesHelper.layers.mask = COORDINATE_LAYER_MASK;
|
|
1804
2102
|
this.axesHelper.material.depthTest = false;
|
|
1805
2103
|
this.axesHelper.position.set(0, 0, -1);
|
|
1806
2104
|
this.axesHelper.setColors(
|
|
1807
|
-
new
|
|
1808
|
-
new
|
|
1809
|
-
new
|
|
2105
|
+
new import_three17.Color(AxesColorRed),
|
|
2106
|
+
new import_three17.Color(AxesColorGreen),
|
|
2107
|
+
new import_three17.Color(AxesColorBlue)
|
|
1810
2108
|
);
|
|
1811
2109
|
const x = new import_three_spritetext.default("X", 0.2, AxesColorRedLetter);
|
|
1812
2110
|
const y = new import_three_spritetext.default("Y", 0.2, AxesColorGreenLetter);
|
|
@@ -1824,7 +2122,7 @@ var DIVEAxisCamera = class extends import_three15.OrthographicCamera {
|
|
|
1824
2122
|
this._renderer = renderer;
|
|
1825
2123
|
this._scene = scene;
|
|
1826
2124
|
this._scene.add(this);
|
|
1827
|
-
const restoreViewport = new
|
|
2125
|
+
const restoreViewport = new import_three17.Vector4();
|
|
1828
2126
|
this._renderCallbackId = renderer.AddPostRenderCallback(() => {
|
|
1829
2127
|
const restoreBackground = scene.background;
|
|
1830
2128
|
scene.background = null;
|
|
@@ -1843,7 +2141,7 @@ var DIVEAxisCamera = class extends import_three15.OrthographicCamera {
|
|
|
1843
2141
|
this._scene.remove(this);
|
|
1844
2142
|
}
|
|
1845
2143
|
SetFromCameraMatrix(matrix) {
|
|
1846
|
-
this.axesHelper.rotation.setFromRotationMatrix(new
|
|
2144
|
+
this.axesHelper.rotation.setFromRotationMatrix(new import_three17.Matrix4().extractRotation(matrix).invert());
|
|
1847
2145
|
}
|
|
1848
2146
|
};
|
|
1849
2147
|
|
|
@@ -2132,14 +2430,14 @@ var DIVE = class _DIVE {
|
|
|
2132
2430
|
const settingsDelta = getObjectDelta(this._settings, settings);
|
|
2133
2431
|
if (settingsDelta.renderer) this.renderer = new DIVERenderer(this._settings.renderer);
|
|
2134
2432
|
if (settingsDelta.perspectiveCamera) {
|
|
2135
|
-
this.perspectiveCamera.fov = settingsDelta.perspectiveCamera.fov;
|
|
2136
|
-
this.perspectiveCamera.near = settingsDelta.perspectiveCamera.near;
|
|
2137
|
-
this.perspectiveCamera.far = settingsDelta.perspectiveCamera.far;
|
|
2433
|
+
if (settingsDelta.perspectiveCamera.fov !== void 0) this.perspectiveCamera.fov = settingsDelta.perspectiveCamera.fov;
|
|
2434
|
+
if (settingsDelta.perspectiveCamera.near !== void 0) this.perspectiveCamera.near = settingsDelta.perspectiveCamera.near;
|
|
2435
|
+
if (settingsDelta.perspectiveCamera.far !== void 0) this.perspectiveCamera.far = settingsDelta.perspectiveCamera.far;
|
|
2138
2436
|
this.perspectiveCamera.OnResize(this.renderer.domElement.width, this.renderer.domElement.height);
|
|
2139
2437
|
}
|
|
2140
2438
|
if (settingsDelta.orbitControls) {
|
|
2141
|
-
this.orbitControls.enableDamping = settingsDelta.orbitControls.enableDamping;
|
|
2142
|
-
this.orbitControls.dampingFactor = settingsDelta.orbitControls.dampingFactor;
|
|
2439
|
+
if (settingsDelta.orbitControls.enableDamping !== void 0) this.orbitControls.enableDamping = settingsDelta.orbitControls.enableDamping;
|
|
2440
|
+
if (settingsDelta.orbitControls.dampingFactor !== void 0) this.orbitControls.dampingFactor = settingsDelta.orbitControls.dampingFactor;
|
|
2143
2441
|
}
|
|
2144
2442
|
if (settingsDelta.autoResize !== this._settings.autoResize) {
|
|
2145
2443
|
if (settingsDelta.autoResize) {
|
|
@@ -2182,6 +2480,7 @@ var DIVE = class _DIVE {
|
|
|
2182
2480
|
console.log(this.scene);
|
|
2183
2481
|
}
|
|
2184
2482
|
};
|
|
2483
|
+
console.log("DIVE initialized");
|
|
2185
2484
|
}
|
|
2186
2485
|
Dispose() {
|
|
2187
2486
|
var _a;
|