@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/build/dive.js
CHANGED
|
@@ -449,7 +449,12 @@ var init_PerspectiveCamera = __esm({
|
|
|
449
449
|
};
|
|
450
450
|
_DIVEPerspectiveCamera = class _DIVEPerspectiveCamera extends PerspectiveCamera {
|
|
451
451
|
constructor(settings = DIVEPerspectiveCameraDefaultSettings) {
|
|
452
|
-
super(
|
|
452
|
+
super(
|
|
453
|
+
settings.fov || DIVEPerspectiveCameraDefaultSettings.fov,
|
|
454
|
+
1,
|
|
455
|
+
settings.near || DIVEPerspectiveCameraDefaultSettings.near,
|
|
456
|
+
settings.far || DIVEPerspectiveCameraDefaultSettings.far
|
|
457
|
+
);
|
|
453
458
|
this.onSetCameraLayer = () => {
|
|
454
459
|
};
|
|
455
460
|
this.layers.mask = _DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK;
|
|
@@ -524,14 +529,16 @@ var DIVERendererDefaultSettings = {
|
|
|
524
529
|
stencil: false,
|
|
525
530
|
shadowMapEnabled: true,
|
|
526
531
|
shadowMapType: PCFSoftShadowMap,
|
|
527
|
-
toneMapping: NoToneMapping
|
|
532
|
+
toneMapping: NoToneMapping,
|
|
533
|
+
canvas: void 0
|
|
528
534
|
};
|
|
529
535
|
var DIVERenderer = class extends WebGLRenderer {
|
|
530
536
|
constructor(rendererSettings = DIVERendererDefaultSettings) {
|
|
531
537
|
super({
|
|
532
|
-
antialias: rendererSettings.antialias,
|
|
533
|
-
alpha: rendererSettings.alpha,
|
|
534
|
-
preserveDrawingBuffer: true
|
|
538
|
+
antialias: rendererSettings.antialias || DIVERendererDefaultSettings.antialias,
|
|
539
|
+
alpha: rendererSettings.alpha || DIVERendererDefaultSettings.alpha,
|
|
540
|
+
preserveDrawingBuffer: true,
|
|
541
|
+
canvas: rendererSettings.canvas
|
|
535
542
|
});
|
|
536
543
|
// basic functionality members
|
|
537
544
|
this.paused = false;
|
|
@@ -541,9 +548,9 @@ var DIVERenderer = class extends WebGLRenderer {
|
|
|
541
548
|
this.preRenderCallbacks = /* @__PURE__ */ new Map();
|
|
542
549
|
this.postRenderCallbacks = /* @__PURE__ */ new Map();
|
|
543
550
|
this.setPixelRatio(window.devicePixelRatio);
|
|
544
|
-
this.shadowMap.enabled = rendererSettings.shadowMapEnabled;
|
|
545
|
-
this.shadowMap.type = rendererSettings.shadowMapType;
|
|
546
|
-
this.toneMapping = rendererSettings.toneMapping;
|
|
551
|
+
this.shadowMap.enabled = rendererSettings.shadowMapEnabled || DIVERendererDefaultSettings.shadowMapEnabled;
|
|
552
|
+
this.shadowMap.type = rendererSettings.shadowMapType || DIVERendererDefaultSettings.shadowMapType;
|
|
553
|
+
this.toneMapping = rendererSettings.toneMapping || DIVERendererDefaultSettings.toneMapping;
|
|
547
554
|
this.debug.checkShaderErrors = false;
|
|
548
555
|
}
|
|
549
556
|
// Stops renderings and disposes the renderer.
|
|
@@ -642,10 +649,10 @@ var DIVERenderer = class extends WebGLRenderer {
|
|
|
642
649
|
};
|
|
643
650
|
|
|
644
651
|
// src/scene/Scene.ts
|
|
645
|
-
import { Color as
|
|
652
|
+
import { Color as Color7, Scene as Scene2 } from "three";
|
|
646
653
|
|
|
647
654
|
// src/scene/root/Root.ts
|
|
648
|
-
import { Box3 as
|
|
655
|
+
import { Box3 as Box33, Object3D as Object3D11 } from "three";
|
|
649
656
|
|
|
650
657
|
// src/scene/root/lightroot/LightRoot.ts
|
|
651
658
|
import { Color as Color4, Object3D as Object3D5 } from "three";
|
|
@@ -1381,12 +1388,265 @@ var DIVEModelRoot = class extends Object3D7 {
|
|
|
1381
1388
|
}
|
|
1382
1389
|
};
|
|
1383
1390
|
|
|
1391
|
+
// src/scene/root/primitiveroot/PrimitiveRoot.ts
|
|
1392
|
+
import { Object3D as Object3D9 } from "three";
|
|
1393
|
+
|
|
1394
|
+
// src/primitive/Primitive.ts
|
|
1395
|
+
import { Box3 as Box32, BoxGeometry, BufferGeometry, Color as Color5, CylinderGeometry, Float32BufferAttribute, Mesh as Mesh2, Object3D as Object3D8, Raycaster as Raycaster3, SphereGeometry as SphereGeometry2, Uint32BufferAttribute, Vector3 as Vector33 } from "three";
|
|
1396
|
+
init_VisibilityLayerMask();
|
|
1397
|
+
var DIVEPrimitive = class extends Object3D8 {
|
|
1398
|
+
constructor() {
|
|
1399
|
+
super();
|
|
1400
|
+
this.isSelectable = true;
|
|
1401
|
+
this.isMoveable = true;
|
|
1402
|
+
this.gizmo = null;
|
|
1403
|
+
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1404
|
+
this._mesh = new Mesh2();
|
|
1405
|
+
this._mesh.layers.mask = PRODUCT_LAYER_MASK;
|
|
1406
|
+
this._mesh.castShadow = true;
|
|
1407
|
+
this._mesh.receiveShadow = true;
|
|
1408
|
+
this.add(this._mesh);
|
|
1409
|
+
this._boundingBox = new Box32();
|
|
1410
|
+
}
|
|
1411
|
+
SetGeometry(geometry) {
|
|
1412
|
+
this.clear();
|
|
1413
|
+
this._mesh.geometry = this.assembleGeometry(geometry);
|
|
1414
|
+
this._boundingBox.setFromObject(this._mesh);
|
|
1415
|
+
}
|
|
1416
|
+
SetPosition(position) {
|
|
1417
|
+
this.position.set(position.x, position.y, position.z);
|
|
1418
|
+
}
|
|
1419
|
+
SetRotation(rotation) {
|
|
1420
|
+
this.rotation.setFromVector3(new Vector33(rotation.x, rotation.y, rotation.z));
|
|
1421
|
+
}
|
|
1422
|
+
SetScale(scale) {
|
|
1423
|
+
this.scale.set(scale.x, scale.y, scale.z);
|
|
1424
|
+
}
|
|
1425
|
+
SetVisibility(visible) {
|
|
1426
|
+
this.traverse((child) => {
|
|
1427
|
+
child.visible = visible;
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
SetMaterial(material) {
|
|
1431
|
+
const primitiveMaterial = this._mesh.material;
|
|
1432
|
+
primitiveMaterial.color = new Color5(material.color);
|
|
1433
|
+
if (material.roughnessMap) {
|
|
1434
|
+
primitiveMaterial.roughnessMap = material.roughnessMap;
|
|
1435
|
+
primitiveMaterial.roughness = 1;
|
|
1436
|
+
} else {
|
|
1437
|
+
primitiveMaterial.roughness = material.roughness;
|
|
1438
|
+
}
|
|
1439
|
+
if (material.metalnessMap) {
|
|
1440
|
+
primitiveMaterial.metalnessMap = material.metalnessMap;
|
|
1441
|
+
primitiveMaterial.metalness = 0;
|
|
1442
|
+
} else {
|
|
1443
|
+
primitiveMaterial.metalness = material.metalness;
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
SetToWorldOrigin() {
|
|
1447
|
+
var _a;
|
|
1448
|
+
this.position.set(0, 0, 0);
|
|
1449
|
+
(_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 });
|
|
1450
|
+
}
|
|
1451
|
+
PlaceOnFloor() {
|
|
1452
|
+
var _a;
|
|
1453
|
+
this.position.y = -this._boundingBox.min.y * this.scale.y;
|
|
1454
|
+
(_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 });
|
|
1455
|
+
}
|
|
1456
|
+
DropIt() {
|
|
1457
|
+
var _a;
|
|
1458
|
+
if (!this.parent) {
|
|
1459
|
+
console.warn("DIVEModel: DropIt() called on a model that is not in the scene.", this);
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1463
|
+
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new Vector33()).multiply(this.scale));
|
|
1464
|
+
bbBottomCenter.y = bottomY + this.position.y;
|
|
1465
|
+
const raycaster = new Raycaster3(bbBottomCenter, new Vector33(0, -1, 0));
|
|
1466
|
+
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1467
|
+
const intersections = raycaster.intersectObjects(findSceneRecursive(this).Root.children, true);
|
|
1468
|
+
if (intersections.length > 0) {
|
|
1469
|
+
const mesh = intersections[0].object;
|
|
1470
|
+
mesh.geometry.computeBoundingBox();
|
|
1471
|
+
const meshBB = mesh.geometry.boundingBox;
|
|
1472
|
+
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1473
|
+
const oldPos = this.position.clone();
|
|
1474
|
+
const newPos = this.position.clone().setY(worldPos.y).sub(new Vector33(0, bottomY, 0));
|
|
1475
|
+
this.position.copy(newPos);
|
|
1476
|
+
if (this.position.y === oldPos.y) return;
|
|
1477
|
+
(_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 });
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
onMove() {
|
|
1481
|
+
var _a;
|
|
1482
|
+
(_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 });
|
|
1483
|
+
}
|
|
1484
|
+
onSelect() {
|
|
1485
|
+
var _a;
|
|
1486
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1487
|
+
}
|
|
1488
|
+
onDeselect() {
|
|
1489
|
+
var _a;
|
|
1490
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1491
|
+
}
|
|
1492
|
+
assembleGeometry(geometry) {
|
|
1493
|
+
switch (geometry.name) {
|
|
1494
|
+
case "cylinder":
|
|
1495
|
+
return this.createCylinderGeometry(geometry);
|
|
1496
|
+
case "sphere":
|
|
1497
|
+
return this.createSphereGeometry(geometry);
|
|
1498
|
+
case "pyramid":
|
|
1499
|
+
return this.createPyramidGeometry(geometry);
|
|
1500
|
+
case "box":
|
|
1501
|
+
return this.createBoxGeometry(geometry);
|
|
1502
|
+
case "cone":
|
|
1503
|
+
return this.createConeGeometry(geometry);
|
|
1504
|
+
case "wall":
|
|
1505
|
+
return this.createWallGeometry(geometry);
|
|
1506
|
+
case "plane":
|
|
1507
|
+
return this.createPlaneGeometry(geometry);
|
|
1508
|
+
default:
|
|
1509
|
+
return new BufferGeometry();
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
createCylinderGeometry(geometry) {
|
|
1513
|
+
return new CylinderGeometry(geometry.width * 2, geometry.width * 2, geometry.height, 64);
|
|
1514
|
+
}
|
|
1515
|
+
createSphereGeometry(geometry) {
|
|
1516
|
+
return new SphereGeometry2(geometry.width * 2, 64);
|
|
1517
|
+
}
|
|
1518
|
+
createPyramidGeometry(geometry) {
|
|
1519
|
+
const geo = new BufferGeometry();
|
|
1520
|
+
const { width, height, depth } = geometry;
|
|
1521
|
+
geo.setAttribute("position", new Float32BufferAttribute([
|
|
1522
|
+
width / 2,
|
|
1523
|
+
0,
|
|
1524
|
+
depth / 2,
|
|
1525
|
+
// right back
|
|
1526
|
+
width / 2,
|
|
1527
|
+
0,
|
|
1528
|
+
-depth / 2,
|
|
1529
|
+
// right front
|
|
1530
|
+
-width / 2,
|
|
1531
|
+
0,
|
|
1532
|
+
-depth / 2,
|
|
1533
|
+
// left front
|
|
1534
|
+
-width / 2,
|
|
1535
|
+
0,
|
|
1536
|
+
depth / 2,
|
|
1537
|
+
// left back
|
|
1538
|
+
0,
|
|
1539
|
+
height,
|
|
1540
|
+
0
|
|
1541
|
+
// top
|
|
1542
|
+
], 3));
|
|
1543
|
+
geo.setIndex(new Uint32BufferAttribute([
|
|
1544
|
+
1,
|
|
1545
|
+
0,
|
|
1546
|
+
4,
|
|
1547
|
+
2,
|
|
1548
|
+
1,
|
|
1549
|
+
4,
|
|
1550
|
+
3,
|
|
1551
|
+
2,
|
|
1552
|
+
4,
|
|
1553
|
+
3,
|
|
1554
|
+
0,
|
|
1555
|
+
4,
|
|
1556
|
+
0,
|
|
1557
|
+
1,
|
|
1558
|
+
2,
|
|
1559
|
+
0,
|
|
1560
|
+
2,
|
|
1561
|
+
3
|
|
1562
|
+
], 1));
|
|
1563
|
+
return geo;
|
|
1564
|
+
}
|
|
1565
|
+
createBoxGeometry(geometry) {
|
|
1566
|
+
return new BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1567
|
+
}
|
|
1568
|
+
createConeGeometry(geometry) {
|
|
1569
|
+
return new CylinderGeometry(0, geometry.width * 2, geometry.height, 64);
|
|
1570
|
+
}
|
|
1571
|
+
createWallGeometry(geometry) {
|
|
1572
|
+
return new BoxGeometry(geometry.width, geometry.height, geometry.depth, 16);
|
|
1573
|
+
}
|
|
1574
|
+
createPlaneGeometry(geometry) {
|
|
1575
|
+
return new BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1576
|
+
}
|
|
1577
|
+
};
|
|
1578
|
+
|
|
1579
|
+
// src/scene/root/primitiveroot/PrimitiveRoot.ts
|
|
1580
|
+
var DIVEPrimitiveRoot = class extends Object3D9 {
|
|
1581
|
+
constructor() {
|
|
1582
|
+
super();
|
|
1583
|
+
this.name = "PrimitiveRoot";
|
|
1584
|
+
}
|
|
1585
|
+
GetPrimitive(object) {
|
|
1586
|
+
if (object.id === void 0) {
|
|
1587
|
+
console.warn("PrimitiveRoot.GetPrimitive: object.id is undefined");
|
|
1588
|
+
return void 0;
|
|
1589
|
+
}
|
|
1590
|
+
return this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1591
|
+
}
|
|
1592
|
+
UpdatePrimitive(object) {
|
|
1593
|
+
if (object.id === void 0) {
|
|
1594
|
+
console.warn("PrimitiveRoot.UpdatePrimitive: object.id is undefined");
|
|
1595
|
+
return;
|
|
1596
|
+
}
|
|
1597
|
+
let sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1598
|
+
if (!sceneObject && object.geometry !== void 0) {
|
|
1599
|
+
const primitive = new DIVEPrimitive();
|
|
1600
|
+
primitive.SetGeometry(object.geometry);
|
|
1601
|
+
sceneObject = primitive;
|
|
1602
|
+
sceneObject.userData.id = object.id;
|
|
1603
|
+
this.add(sceneObject);
|
|
1604
|
+
}
|
|
1605
|
+
if (object.position !== void 0) sceneObject.SetPosition(object.position);
|
|
1606
|
+
if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
|
|
1607
|
+
if (object.scale !== void 0) sceneObject.SetScale(object.scale);
|
|
1608
|
+
if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
|
|
1609
|
+
if (object.material !== void 0) sceneObject.SetMaterial(object.material);
|
|
1610
|
+
}
|
|
1611
|
+
DeletePrimitive(object) {
|
|
1612
|
+
if (object.id === void 0) {
|
|
1613
|
+
console.warn(`PrimitiveRoot.DeletePrimitive: object.id is undefined`);
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1616
|
+
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1617
|
+
if (!sceneObject) {
|
|
1618
|
+
console.warn(`PrimitiveRoot.DeletePrimitive: Primitive with id ${object.id} not found`);
|
|
1619
|
+
return;
|
|
1620
|
+
}
|
|
1621
|
+
const findScene = (object2) => {
|
|
1622
|
+
if (object2.parent !== null) {
|
|
1623
|
+
return findScene(object2.parent);
|
|
1624
|
+
}
|
|
1625
|
+
;
|
|
1626
|
+
return object2;
|
|
1627
|
+
};
|
|
1628
|
+
const scene = findScene(sceneObject);
|
|
1629
|
+
scene.children.find((object2) => {
|
|
1630
|
+
if ("isTransformControls" in object2) {
|
|
1631
|
+
object2.detach();
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1634
|
+
this.remove(sceneObject);
|
|
1635
|
+
}
|
|
1636
|
+
PlaceOnFloor(object) {
|
|
1637
|
+
if (object.id === void 0) console.warn("PrimitiveRoot.PlaceOnFloor: object.id is undefined");
|
|
1638
|
+
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1639
|
+
if (!sceneObject) return;
|
|
1640
|
+
sceneObject.PlaceOnFloor();
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
|
|
1384
1644
|
// src/primitive/floor/Floor.ts
|
|
1385
1645
|
init_VisibilityLayerMask();
|
|
1386
|
-
import { Color as
|
|
1387
|
-
var DIVEFloor = class extends
|
|
1646
|
+
import { Color as Color6, Mesh as Mesh3, MeshStandardMaterial as MeshStandardMaterial2, PlaneGeometry } from "three";
|
|
1647
|
+
var DIVEFloor = class extends Mesh3 {
|
|
1388
1648
|
constructor() {
|
|
1389
|
-
super(new PlaneGeometry(1e4, 1e4), new
|
|
1649
|
+
super(new PlaneGeometry(1e4, 1e4), new MeshStandardMaterial2({ color: new Color6(150 / 255, 150 / 255, 150 / 255) }));
|
|
1390
1650
|
this.isFloor = true;
|
|
1391
1651
|
this.name = "Floor";
|
|
1392
1652
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
@@ -1397,7 +1657,7 @@ var DIVEFloor = class extends Mesh2 {
|
|
|
1397
1657
|
this.visible = visible;
|
|
1398
1658
|
}
|
|
1399
1659
|
SetColor(color) {
|
|
1400
|
-
this.material.color = new
|
|
1660
|
+
this.material.color = new Color6(color);
|
|
1401
1661
|
}
|
|
1402
1662
|
};
|
|
1403
1663
|
|
|
@@ -1407,8 +1667,8 @@ var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
|
1407
1667
|
|
|
1408
1668
|
// src/grid/Grid.ts
|
|
1409
1669
|
init_VisibilityLayerMask();
|
|
1410
|
-
import { GridHelper, Object3D as
|
|
1411
|
-
var DIVEGrid = class extends
|
|
1670
|
+
import { GridHelper, Object3D as Object3D10 } from "three";
|
|
1671
|
+
var DIVEGrid = class extends Object3D10 {
|
|
1412
1672
|
constructor() {
|
|
1413
1673
|
super();
|
|
1414
1674
|
this.name = "Grid";
|
|
@@ -1423,7 +1683,7 @@ var DIVEGrid = class extends Object3D8 {
|
|
|
1423
1683
|
};
|
|
1424
1684
|
|
|
1425
1685
|
// src/scene/root/Root.ts
|
|
1426
|
-
var DIVERoot = class extends
|
|
1686
|
+
var DIVERoot = class extends Object3D11 {
|
|
1427
1687
|
get Floor() {
|
|
1428
1688
|
return this.floor;
|
|
1429
1689
|
}
|
|
@@ -1437,18 +1697,25 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1437
1697
|
this.add(this.lightRoot);
|
|
1438
1698
|
this.modelRoot = new DIVEModelRoot();
|
|
1439
1699
|
this.add(this.modelRoot);
|
|
1700
|
+
this.primitiveRoot = new DIVEPrimitiveRoot();
|
|
1701
|
+
this.add(this.primitiveRoot);
|
|
1440
1702
|
this.floor = new DIVEFloor();
|
|
1441
1703
|
this.add(this.floor);
|
|
1442
1704
|
this.grid = new DIVEGrid();
|
|
1443
1705
|
this.add(this.grid);
|
|
1444
1706
|
}
|
|
1445
1707
|
ComputeSceneBB() {
|
|
1446
|
-
const bb = new
|
|
1708
|
+
const bb = new Box33();
|
|
1447
1709
|
this.modelRoot.traverse((object) => {
|
|
1448
1710
|
if ("isObject3D" in object) {
|
|
1449
1711
|
bb.expandByObject(object);
|
|
1450
1712
|
}
|
|
1451
1713
|
});
|
|
1714
|
+
this.primitiveRoot.traverse((object) => {
|
|
1715
|
+
if ("isObject3D" in object) {
|
|
1716
|
+
bb.expandByObject(object);
|
|
1717
|
+
}
|
|
1718
|
+
});
|
|
1452
1719
|
return bb;
|
|
1453
1720
|
}
|
|
1454
1721
|
GetSceneObject(object) {
|
|
@@ -1462,6 +1729,9 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1462
1729
|
case "model": {
|
|
1463
1730
|
return this.modelRoot.GetModel(object);
|
|
1464
1731
|
}
|
|
1732
|
+
case "primitive": {
|
|
1733
|
+
return this.primitiveRoot.GetPrimitive(object);
|
|
1734
|
+
}
|
|
1465
1735
|
}
|
|
1466
1736
|
}
|
|
1467
1737
|
AddSceneObject(object) {
|
|
@@ -1477,6 +1747,10 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1477
1747
|
this.modelRoot.UpdateModel(object);
|
|
1478
1748
|
break;
|
|
1479
1749
|
}
|
|
1750
|
+
case "primitive": {
|
|
1751
|
+
this.primitiveRoot.UpdatePrimitive(object);
|
|
1752
|
+
break;
|
|
1753
|
+
}
|
|
1480
1754
|
}
|
|
1481
1755
|
}
|
|
1482
1756
|
UpdateSceneObject(object) {
|
|
@@ -1492,6 +1766,10 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1492
1766
|
this.modelRoot.UpdateModel(object);
|
|
1493
1767
|
break;
|
|
1494
1768
|
}
|
|
1769
|
+
case "primitive": {
|
|
1770
|
+
this.primitiveRoot.UpdatePrimitive(object);
|
|
1771
|
+
break;
|
|
1772
|
+
}
|
|
1495
1773
|
}
|
|
1496
1774
|
}
|
|
1497
1775
|
DeleteSceneObject(object) {
|
|
@@ -1507,10 +1785,27 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1507
1785
|
this.modelRoot.DeleteModel(object);
|
|
1508
1786
|
break;
|
|
1509
1787
|
}
|
|
1788
|
+
case "primitive": {
|
|
1789
|
+
this.primitiveRoot.DeletePrimitive(object);
|
|
1790
|
+
break;
|
|
1791
|
+
}
|
|
1510
1792
|
}
|
|
1511
1793
|
}
|
|
1512
1794
|
PlaceOnFloor(object) {
|
|
1513
|
-
|
|
1795
|
+
switch (object.entityType) {
|
|
1796
|
+
case "pov":
|
|
1797
|
+
case "light": {
|
|
1798
|
+
break;
|
|
1799
|
+
}
|
|
1800
|
+
case "model": {
|
|
1801
|
+
this.modelRoot.PlaceOnFloor(object);
|
|
1802
|
+
break;
|
|
1803
|
+
}
|
|
1804
|
+
case "primitive": {
|
|
1805
|
+
this.primitiveRoot.PlaceOnFloor(object);
|
|
1806
|
+
break;
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1514
1809
|
}
|
|
1515
1810
|
};
|
|
1516
1811
|
|
|
@@ -1521,12 +1816,12 @@ var DIVEScene = class extends Scene2 {
|
|
|
1521
1816
|
}
|
|
1522
1817
|
constructor() {
|
|
1523
1818
|
super();
|
|
1524
|
-
this.background = new
|
|
1819
|
+
this.background = new Color7(16777215);
|
|
1525
1820
|
this.root = new DIVERoot();
|
|
1526
1821
|
this.add(this.root);
|
|
1527
1822
|
}
|
|
1528
1823
|
SetBackground(color) {
|
|
1529
|
-
this.background = new
|
|
1824
|
+
this.background = new Color7(color);
|
|
1530
1825
|
}
|
|
1531
1826
|
ComputeSceneBB() {
|
|
1532
1827
|
return this.Root.ComputeSceneBB();
|
|
@@ -1552,8 +1847,8 @@ var DIVEScene = class extends Scene2 {
|
|
|
1552
1847
|
init_PerspectiveCamera();
|
|
1553
1848
|
|
|
1554
1849
|
// src/controls/OrbitControls.ts
|
|
1555
|
-
import { OrbitControls } from "three/examples/jsm/
|
|
1556
|
-
import { MathUtils as MathUtils2, Vector3 as
|
|
1850
|
+
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
|
|
1851
|
+
import { MathUtils as MathUtils2, Vector3 as Vector34 } from "three";
|
|
1557
1852
|
import { Easing } from "@tweenjs/tween.js";
|
|
1558
1853
|
var DIVEOrbitControlsDefaultSettings = {
|
|
1559
1854
|
enableDamping: true,
|
|
@@ -1584,16 +1879,19 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends OrbitControls {
|
|
|
1584
1879
|
this._removePreRenderCallback = () => {
|
|
1585
1880
|
renderer.RemovePreRenderCallback(id);
|
|
1586
1881
|
};
|
|
1587
|
-
this.enableDamping = settings.enableDamping;
|
|
1588
|
-
this.dampingFactor = settings.dampingFactor;
|
|
1882
|
+
this.enableDamping = settings.enableDamping || DIVEOrbitControlsDefaultSettings.enableDamping;
|
|
1883
|
+
this.dampingFactor = settings.dampingFactor || DIVEOrbitControlsDefaultSettings.dampingFactor;
|
|
1884
|
+
this.object.position.set(0, 2, 2);
|
|
1885
|
+
this.target.copy({ x: 0, y: 0.5, z: 0 });
|
|
1886
|
+
this.update();
|
|
1589
1887
|
}
|
|
1590
1888
|
Dispose() {
|
|
1591
1889
|
this._removePreRenderCallback();
|
|
1592
1890
|
this.dispose();
|
|
1593
1891
|
}
|
|
1594
1892
|
ComputeEncompassingView(bb) {
|
|
1595
|
-
const center = bb.getCenter(new
|
|
1596
|
-
const size = bb.getSize(new
|
|
1893
|
+
const center = bb.getCenter(new Vector34());
|
|
1894
|
+
const size = bb.getSize(new Vector34());
|
|
1597
1895
|
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
1598
1896
|
const direction = this.object.position.clone().normalize();
|
|
1599
1897
|
return {
|
|
@@ -1761,7 +2059,7 @@ var DIVEAnimationSystem = class {
|
|
|
1761
2059
|
|
|
1762
2060
|
// src/axiscamera/AxisCamera.ts
|
|
1763
2061
|
init_VisibilityLayerMask();
|
|
1764
|
-
import { AxesHelper, Color as
|
|
2062
|
+
import { AxesHelper, Color as Color8, Matrix4, OrthographicCamera, Vector4 } from "three";
|
|
1765
2063
|
import SpriteText from "three-spritetext";
|
|
1766
2064
|
|
|
1767
2065
|
// src/constant/AxisHelperColors.ts
|
|
@@ -1782,9 +2080,9 @@ var DIVEAxisCamera = class extends OrthographicCamera {
|
|
|
1782
2080
|
this.axesHelper.material.depthTest = false;
|
|
1783
2081
|
this.axesHelper.position.set(0, 0, -1);
|
|
1784
2082
|
this.axesHelper.setColors(
|
|
1785
|
-
new
|
|
1786
|
-
new
|
|
1787
|
-
new
|
|
2083
|
+
new Color8(AxesColorRed),
|
|
2084
|
+
new Color8(AxesColorGreen),
|
|
2085
|
+
new Color8(AxesColorBlue)
|
|
1788
2086
|
);
|
|
1789
2087
|
const x = new SpriteText("X", 0.2, AxesColorRedLetter);
|
|
1790
2088
|
const y = new SpriteText("Y", 0.2, AxesColorGreenLetter);
|
|
@@ -2110,14 +2408,14 @@ var DIVE = class _DIVE {
|
|
|
2110
2408
|
const settingsDelta = getObjectDelta(this._settings, settings);
|
|
2111
2409
|
if (settingsDelta.renderer) this.renderer = new DIVERenderer(this._settings.renderer);
|
|
2112
2410
|
if (settingsDelta.perspectiveCamera) {
|
|
2113
|
-
this.perspectiveCamera.fov = settingsDelta.perspectiveCamera.fov;
|
|
2114
|
-
this.perspectiveCamera.near = settingsDelta.perspectiveCamera.near;
|
|
2115
|
-
this.perspectiveCamera.far = settingsDelta.perspectiveCamera.far;
|
|
2411
|
+
if (settingsDelta.perspectiveCamera.fov !== void 0) this.perspectiveCamera.fov = settingsDelta.perspectiveCamera.fov;
|
|
2412
|
+
if (settingsDelta.perspectiveCamera.near !== void 0) this.perspectiveCamera.near = settingsDelta.perspectiveCamera.near;
|
|
2413
|
+
if (settingsDelta.perspectiveCamera.far !== void 0) this.perspectiveCamera.far = settingsDelta.perspectiveCamera.far;
|
|
2116
2414
|
this.perspectiveCamera.OnResize(this.renderer.domElement.width, this.renderer.domElement.height);
|
|
2117
2415
|
}
|
|
2118
2416
|
if (settingsDelta.orbitControls) {
|
|
2119
|
-
this.orbitControls.enableDamping = settingsDelta.orbitControls.enableDamping;
|
|
2120
|
-
this.orbitControls.dampingFactor = settingsDelta.orbitControls.dampingFactor;
|
|
2417
|
+
if (settingsDelta.orbitControls.enableDamping !== void 0) this.orbitControls.enableDamping = settingsDelta.orbitControls.enableDamping;
|
|
2418
|
+
if (settingsDelta.orbitControls.dampingFactor !== void 0) this.orbitControls.dampingFactor = settingsDelta.orbitControls.dampingFactor;
|
|
2121
2419
|
}
|
|
2122
2420
|
if (settingsDelta.autoResize !== this._settings.autoResize) {
|
|
2123
2421
|
if (settingsDelta.autoResize) {
|
|
@@ -2160,6 +2458,7 @@ var DIVE = class _DIVE {
|
|
|
2160
2458
|
console.log(this.scene);
|
|
2161
2459
|
}
|
|
2162
2460
|
};
|
|
2461
|
+
console.log("DIVE initialized");
|
|
2163
2462
|
}
|
|
2164
2463
|
Dispose() {
|
|
2165
2464
|
var _a;
|