@shopware-ag/dive 1.16.6 → 1.16.8

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 CHANGED
@@ -423,12 +423,12 @@ var init_SelectTool = __esm({
423
423
  Activate() {
424
424
  }
425
425
  Select(selectable) {
426
- if (selectable.onSelect) selectable.onSelect();
427
426
  this.AttachGizmo(selectable);
427
+ if (selectable.onSelect) selectable.onSelect();
428
428
  }
429
429
  Deselect(selectable) {
430
- if (selectable.onDeselect) selectable.onDeselect();
431
430
  this.DetachGizmo();
431
+ if (selectable.onDeselect) selectable.onDeselect();
432
432
  }
433
433
  AttachGizmo(selectable) {
434
434
  if ("isMovable" in selectable) {
@@ -1432,10 +1432,19 @@ var DIVENode = class extends import_three7.Object3D {
1432
1432
  this.isMovable = true;
1433
1433
  this.gizmo = null;
1434
1434
  this.layers.mask = PRODUCT_LAYER_MASK;
1435
+ this._positionWorldBuffer = new import_three7.Vector3();
1435
1436
  this._boundingBox = new import_three7.Box3();
1436
1437
  }
1437
1438
  SetPosition(position) {
1438
- this.position.set(position.x, position.y, position.z);
1439
+ if (!this.parent) {
1440
+ this.position.set(position.x, position.y, position.z);
1441
+ return;
1442
+ }
1443
+ const newPosition = new import_three7.Vector3(position.x, position.y, position.z);
1444
+ this.position.copy(this.parent.worldToLocal(newPosition));
1445
+ if ("isDIVEGroup" in this.parent) {
1446
+ this.parent.UpdateLineTo(this);
1447
+ }
1439
1448
  }
1440
1449
  SetRotation(rotation) {
1441
1450
  this.rotation.set(rotation.x, rotation.y, rotation.z);
@@ -1453,7 +1462,7 @@ var DIVENode = class extends import_three7.Object3D {
1453
1462
  "UPDATE_OBJECT",
1454
1463
  {
1455
1464
  id: this.userData.id,
1456
- position: this.position,
1465
+ position: this.getWorldPosition(this._positionWorldBuffer),
1457
1466
  rotation: this.rotation,
1458
1467
  scale: this.scale
1459
1468
  }
@@ -1465,14 +1474,11 @@ var DIVENode = class extends import_three7.Object3D {
1465
1474
  "UPDATE_OBJECT",
1466
1475
  {
1467
1476
  id: this.userData.id,
1468
- position: this.position,
1477
+ position: this.getWorldPosition(this._positionWorldBuffer),
1469
1478
  rotation: this.rotation,
1470
1479
  scale: this.scale
1471
1480
  }
1472
1481
  );
1473
- if (this.parent && "isDIVEGroup" in this.parent) {
1474
- this.parent.UpdateLineTo(this);
1475
- }
1476
1482
  }
1477
1483
  onSelect() {
1478
1484
  var _a;
@@ -1500,6 +1506,7 @@ var DIVEModel = class extends DIVENode {
1500
1506
  }
1501
1507
  SetModel(gltf) {
1502
1508
  this.clear();
1509
+ this._boundingBox.makeEmpty();
1503
1510
  gltf.scene.traverse((child) => {
1504
1511
  child.castShadow = true;
1505
1512
  child.receiveShadow = true;
@@ -1555,10 +1562,20 @@ var DIVEModel = class extends DIVENode {
1555
1562
  }
1556
1563
  }
1557
1564
  PlaceOnFloor() {
1558
- const oldPos = this.position.clone();
1559
- this.position.y = -this._boundingBox.min.y * this.scale.y;
1560
- if (this.position.y === oldPos.y) return;
1561
- this.onMove();
1565
+ var _a;
1566
+ const worldPos = this.getWorldPosition(this._positionWorldBuffer);
1567
+ const oldWorldPos = worldPos.clone();
1568
+ worldPos.y = -this._boundingBox.min.y * this.scale.y;
1569
+ if (worldPos.y === oldWorldPos.y) return;
1570
+ (_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
1571
+ "UPDATE_OBJECT",
1572
+ {
1573
+ id: this.userData.id,
1574
+ position: worldPos,
1575
+ rotation: this.rotation,
1576
+ scale: this.scale
1577
+ }
1578
+ );
1562
1579
  }
1563
1580
  DropIt() {
1564
1581
  if (!this.parent) {
@@ -1682,10 +1699,20 @@ var DIVEPrimitive = class extends DIVENode {
1682
1699
  if (this._mesh) this._mesh.material = primitiveMaterial;
1683
1700
  }
1684
1701
  PlaceOnFloor() {
1685
- const oldPos = this.position.clone();
1686
- this.position.y = -this._boundingBox.min.y * this.scale.y;
1687
- if (this.position.y === oldPos.y) return;
1688
- this.onMove();
1702
+ var _a;
1703
+ const worldPos = this.getWorldPosition(this._positionWorldBuffer);
1704
+ const oldWorldPos = worldPos.clone();
1705
+ worldPos.y = -this._boundingBox.min.y * this.scale.y;
1706
+ if (worldPos.y === oldWorldPos.y) return;
1707
+ (_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
1708
+ "UPDATE_OBJECT",
1709
+ {
1710
+ id: this.userData.id,
1711
+ position: worldPos,
1712
+ rotation: this.rotation,
1713
+ scale: this.scale
1714
+ }
1715
+ );
1689
1716
  }
1690
1717
  DropIt() {
1691
1718
  if (!this.parent) {
@@ -1719,12 +1746,14 @@ var DIVEPrimitive = class extends DIVENode {
1719
1746
  }
1720
1747
  }
1721
1748
  assembleGeometry(geometry) {
1749
+ this._mesh.material.flatShading = false;
1722
1750
  switch (geometry.name.toLowerCase()) {
1723
1751
  case "cylinder":
1724
1752
  return this.createCylinderGeometry(geometry);
1725
1753
  case "sphere":
1726
1754
  return this.createSphereGeometry(geometry);
1727
1755
  case "pyramid":
1756
+ this._mesh.material.flatShading = true;
1728
1757
  return this.createPyramidGeometry(geometry);
1729
1758
  case "cube":
1730
1759
  case "box":
@@ -1759,16 +1788,57 @@ var DIVEPrimitive = class extends DIVENode {
1759
1788
  return geo;
1760
1789
  }
1761
1790
  createPyramidGeometry(geometry) {
1762
- const geo = new import_three9.ConeGeometry(
1791
+ const vertices = new Float32Array([
1792
+ -geometry.width / 2,
1793
+ 0,
1794
+ -geometry.depth / 2,
1795
+ // 0
1796
+ geometry.width / 2,
1797
+ 0,
1798
+ -geometry.depth / 2,
1799
+ // 1
1763
1800
  geometry.width / 2,
1801
+ 0,
1802
+ geometry.depth / 2,
1803
+ // 2
1804
+ -geometry.width / 2,
1805
+ 0,
1806
+ geometry.depth / 2,
1807
+ // 3
1808
+ 0,
1764
1809
  geometry.height,
1810
+ 0
1811
+ ]);
1812
+ const indices = new Uint16Array([
1813
+ 0,
1814
+ 1,
1815
+ 2,
1816
+ 0,
1817
+ 2,
1818
+ 3,
1819
+ 0,
1765
1820
  4,
1766
1821
  1,
1767
- true
1822
+ 1,
1823
+ 4,
1824
+ 2,
1825
+ 2,
1826
+ 4,
1827
+ 3,
1828
+ 3,
1829
+ 4,
1830
+ 0
1831
+ ]);
1832
+ const geometryBuffer = new import_three9.BufferGeometry();
1833
+ geometryBuffer.setAttribute(
1834
+ "position",
1835
+ new import_three9.BufferAttribute(vertices, 3)
1768
1836
  );
1769
- geo.rotateY(Math.PI / 4);
1770
- geo.translate(0, geometry.height / 2, 0);
1771
- return geo;
1837
+ geometryBuffer.setIndex(new import_three9.BufferAttribute(indices, 1));
1838
+ geometryBuffer.computeVertexNormals();
1839
+ geometryBuffer.computeBoundingBox();
1840
+ geometryBuffer.computeBoundingSphere();
1841
+ return geometryBuffer;
1772
1842
  }
1773
1843
  createBoxGeometry(geometry) {
1774
1844
  const geo = new import_three9.BoxGeometry(
@@ -2848,7 +2918,7 @@ DIVEInfo._supportsWebXR = null;
2848
2918
  // package.json
2849
2919
  var package_default = {
2850
2920
  name: "@shopware-ag/dive",
2851
- version: "1.16.6",
2921
+ version: "1.16.8",
2852
2922
  description: "Shopware Spatial Framework",
2853
2923
  type: "module",
2854
2924
  main: "./build/dive.cjs",