@shopware-ag/dive 1.16.7 → 1.16.9
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 +116 -21
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +86 -72
- package/build/dive.d.ts +86 -72
- package/build/dive.js +137 -35
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/com/actions/scene/getallscenedata.ts +2 -25
- package/src/com/types/COMLight.ts +1 -0
- package/src/dive.ts +1 -0
- package/src/group/Group.ts +16 -1
- package/src/group/__test__/Group.test.ts +97 -0
- package/src/math/degToRad/__test__/degToRad.test.ts +179 -0
- package/src/math/degToRad/degToRad.ts +5 -0
- package/src/math/index.ts +6 -0
- package/src/math/radToDeg/__test__/radToDeg.test.ts +162 -0
- package/src/math/radToDeg/radToDeg.ts +5 -0
- package/src/model/Model.ts +21 -5
- package/src/model/__test__/Model.test.ts +34 -4
- package/src/node/Node.ts +21 -8
- package/src/node/__test__/Node.test.ts +35 -3
- package/src/primitive/Primitive.ts +56 -15
- package/src/primitive/__test__/Primitive.test.ts +39 -1
- package/src/scene/root/__test__/Root.test.ts +39 -0
- package/src/types/SceneData.ts +26 -0
- package/src/types/index.ts +2 -1
package/build/dive.cjs
CHANGED
|
@@ -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.
|
|
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,26 +1462,26 @@ var DIVENode = class extends import_three7.Object3D {
|
|
|
1453
1462
|
"UPDATE_OBJECT",
|
|
1454
1463
|
{
|
|
1455
1464
|
id: this.userData.id,
|
|
1456
|
-
position: this.
|
|
1465
|
+
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
1457
1466
|
rotation: this.rotation,
|
|
1458
1467
|
scale: this.scale
|
|
1459
1468
|
}
|
|
1460
1469
|
);
|
|
1461
1470
|
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Can be called when the object is moved from a foreign object (gizmo, parent, etc.) to update the object's position.
|
|
1473
|
+
*/
|
|
1462
1474
|
onMove() {
|
|
1463
1475
|
var _a;
|
|
1464
1476
|
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
1465
1477
|
"UPDATE_OBJECT",
|
|
1466
1478
|
{
|
|
1467
1479
|
id: this.userData.id,
|
|
1468
|
-
position: this.
|
|
1480
|
+
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
1469
1481
|
rotation: this.rotation,
|
|
1470
1482
|
scale: this.scale
|
|
1471
1483
|
}
|
|
1472
1484
|
);
|
|
1473
|
-
if (this.parent && "isDIVEGroup" in this.parent) {
|
|
1474
|
-
this.parent.UpdateLineTo(this);
|
|
1475
|
-
}
|
|
1476
1485
|
}
|
|
1477
1486
|
onSelect() {
|
|
1478
1487
|
var _a;
|
|
@@ -1500,6 +1509,7 @@ var DIVEModel = class extends DIVENode {
|
|
|
1500
1509
|
}
|
|
1501
1510
|
SetModel(gltf) {
|
|
1502
1511
|
this.clear();
|
|
1512
|
+
this._boundingBox.makeEmpty();
|
|
1503
1513
|
gltf.scene.traverse((child) => {
|
|
1504
1514
|
child.castShadow = true;
|
|
1505
1515
|
child.receiveShadow = true;
|
|
@@ -1555,10 +1565,20 @@ var DIVEModel = class extends DIVENode {
|
|
|
1555
1565
|
}
|
|
1556
1566
|
}
|
|
1557
1567
|
PlaceOnFloor() {
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
this.
|
|
1568
|
+
var _a;
|
|
1569
|
+
const worldPos = this.getWorldPosition(this._positionWorldBuffer);
|
|
1570
|
+
const oldWorldPos = worldPos.clone();
|
|
1571
|
+
worldPos.y = -this._boundingBox.min.y * this.scale.y;
|
|
1572
|
+
if (worldPos.y === oldWorldPos.y) return;
|
|
1573
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
1574
|
+
"UPDATE_OBJECT",
|
|
1575
|
+
{
|
|
1576
|
+
id: this.userData.id,
|
|
1577
|
+
position: worldPos,
|
|
1578
|
+
rotation: this.rotation,
|
|
1579
|
+
scale: this.scale
|
|
1580
|
+
}
|
|
1581
|
+
);
|
|
1562
1582
|
}
|
|
1563
1583
|
DropIt() {
|
|
1564
1584
|
if (!this.parent) {
|
|
@@ -1682,10 +1702,20 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
1682
1702
|
if (this._mesh) this._mesh.material = primitiveMaterial;
|
|
1683
1703
|
}
|
|
1684
1704
|
PlaceOnFloor() {
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
this.
|
|
1705
|
+
var _a;
|
|
1706
|
+
const worldPos = this.getWorldPosition(this._positionWorldBuffer);
|
|
1707
|
+
const oldWorldPos = worldPos.clone();
|
|
1708
|
+
worldPos.y = -this._boundingBox.min.y * this.scale.y;
|
|
1709
|
+
if (worldPos.y === oldWorldPos.y) return;
|
|
1710
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
1711
|
+
"UPDATE_OBJECT",
|
|
1712
|
+
{
|
|
1713
|
+
id: this.userData.id,
|
|
1714
|
+
position: worldPos,
|
|
1715
|
+
rotation: this.rotation,
|
|
1716
|
+
scale: this.scale
|
|
1717
|
+
}
|
|
1718
|
+
);
|
|
1689
1719
|
}
|
|
1690
1720
|
DropIt() {
|
|
1691
1721
|
if (!this.parent) {
|
|
@@ -1719,12 +1749,14 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
1719
1749
|
}
|
|
1720
1750
|
}
|
|
1721
1751
|
assembleGeometry(geometry) {
|
|
1752
|
+
this._mesh.material.flatShading = false;
|
|
1722
1753
|
switch (geometry.name.toLowerCase()) {
|
|
1723
1754
|
case "cylinder":
|
|
1724
1755
|
return this.createCylinderGeometry(geometry);
|
|
1725
1756
|
case "sphere":
|
|
1726
1757
|
return this.createSphereGeometry(geometry);
|
|
1727
1758
|
case "pyramid":
|
|
1759
|
+
this._mesh.material.flatShading = true;
|
|
1728
1760
|
return this.createPyramidGeometry(geometry);
|
|
1729
1761
|
case "cube":
|
|
1730
1762
|
case "box":
|
|
@@ -1759,16 +1791,57 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
1759
1791
|
return geo;
|
|
1760
1792
|
}
|
|
1761
1793
|
createPyramidGeometry(geometry) {
|
|
1762
|
-
const
|
|
1794
|
+
const vertices = new Float32Array([
|
|
1795
|
+
-geometry.width / 2,
|
|
1796
|
+
0,
|
|
1797
|
+
-geometry.depth / 2,
|
|
1798
|
+
// 0
|
|
1799
|
+
geometry.width / 2,
|
|
1800
|
+
0,
|
|
1801
|
+
-geometry.depth / 2,
|
|
1802
|
+
// 1
|
|
1763
1803
|
geometry.width / 2,
|
|
1804
|
+
0,
|
|
1805
|
+
geometry.depth / 2,
|
|
1806
|
+
// 2
|
|
1807
|
+
-geometry.width / 2,
|
|
1808
|
+
0,
|
|
1809
|
+
geometry.depth / 2,
|
|
1810
|
+
// 3
|
|
1811
|
+
0,
|
|
1764
1812
|
geometry.height,
|
|
1813
|
+
0
|
|
1814
|
+
]);
|
|
1815
|
+
const indices = new Uint16Array([
|
|
1816
|
+
0,
|
|
1817
|
+
1,
|
|
1818
|
+
2,
|
|
1819
|
+
0,
|
|
1820
|
+
2,
|
|
1821
|
+
3,
|
|
1822
|
+
0,
|
|
1765
1823
|
4,
|
|
1766
1824
|
1,
|
|
1767
|
-
|
|
1825
|
+
1,
|
|
1826
|
+
4,
|
|
1827
|
+
2,
|
|
1828
|
+
2,
|
|
1829
|
+
4,
|
|
1830
|
+
3,
|
|
1831
|
+
3,
|
|
1832
|
+
4,
|
|
1833
|
+
0
|
|
1834
|
+
]);
|
|
1835
|
+
const geometryBuffer = new import_three9.BufferGeometry();
|
|
1836
|
+
geometryBuffer.setAttribute(
|
|
1837
|
+
"position",
|
|
1838
|
+
new import_three9.BufferAttribute(vertices, 3)
|
|
1768
1839
|
);
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1840
|
+
geometryBuffer.setIndex(new import_three9.BufferAttribute(indices, 1));
|
|
1841
|
+
geometryBuffer.computeVertexNormals();
|
|
1842
|
+
geometryBuffer.computeBoundingBox();
|
|
1843
|
+
geometryBuffer.computeBoundingSphere();
|
|
1844
|
+
return geometryBuffer;
|
|
1772
1845
|
}
|
|
1773
1846
|
createBoxGeometry(geometry) {
|
|
1774
1847
|
const geo = new import_three9.BoxGeometry(
|
|
@@ -1816,6 +1889,14 @@ var DIVEGroup = class extends DIVENode {
|
|
|
1816
1889
|
this._members = [];
|
|
1817
1890
|
this._lines = [];
|
|
1818
1891
|
}
|
|
1892
|
+
SetPosition(position) {
|
|
1893
|
+
super.SetPosition(position);
|
|
1894
|
+
this._members.forEach((member) => {
|
|
1895
|
+
if ("isDIVENode" in member) {
|
|
1896
|
+
member.onMove();
|
|
1897
|
+
}
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1819
1900
|
SetLinesVisibility(visible, object) {
|
|
1820
1901
|
if (!object) {
|
|
1821
1902
|
this._lines.forEach((line) => {
|
|
@@ -2848,7 +2929,7 @@ DIVEInfo._supportsWebXR = null;
|
|
|
2848
2929
|
// package.json
|
|
2849
2930
|
var package_default = {
|
|
2850
2931
|
name: "@shopware-ag/dive",
|
|
2851
|
-
version: "1.16.
|
|
2932
|
+
version: "1.16.9",
|
|
2852
2933
|
description: "Shopware Spatial Framework",
|
|
2853
2934
|
type: "module",
|
|
2854
2935
|
main: "./build/dive.cjs",
|
|
@@ -2966,6 +3047,18 @@ function truncateExp(number, decimals = 0) {
|
|
|
2966
3047
|
return shift(Math.trunc(n), -decimals);
|
|
2967
3048
|
}
|
|
2968
3049
|
|
|
3050
|
+
// src/math/radToDeg/radToDeg.ts
|
|
3051
|
+
var import_three17 = require("three");
|
|
3052
|
+
function radToDeg(radians) {
|
|
3053
|
+
return (import_three17.MathUtils.radToDeg(radians) + 360) % 360;
|
|
3054
|
+
}
|
|
3055
|
+
|
|
3056
|
+
// src/math/degToRad/degToRad.ts
|
|
3057
|
+
var import_three18 = require("three");
|
|
3058
|
+
function degToRad(degrees) {
|
|
3059
|
+
return import_three18.MathUtils.degToRad(degrees);
|
|
3060
|
+
}
|
|
3061
|
+
|
|
2969
3062
|
// src/math/index.ts
|
|
2970
3063
|
var DIVEMath = {
|
|
2971
3064
|
ceilExp,
|
|
@@ -2973,7 +3066,9 @@ var DIVEMath = {
|
|
|
2973
3066
|
roundExp: roundExponential,
|
|
2974
3067
|
toFixedExp,
|
|
2975
3068
|
truncateExp,
|
|
2976
|
-
signedAngleTo
|
|
3069
|
+
signedAngleTo,
|
|
3070
|
+
radToDeg,
|
|
3071
|
+
degToRad
|
|
2977
3072
|
};
|
|
2978
3073
|
|
|
2979
3074
|
// src/dive.ts
|