@shopware-ag/dive 1.9.0 → 1.11.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.d.cts CHANGED
@@ -226,6 +226,7 @@ type COMModel = COMBaseEntity & {
226
226
  rotation: Vector3Like;
227
227
  scale: Vector3Like;
228
228
  loaded: boolean;
229
+ material?: Partial<COMMaterial>;
229
230
  };
230
231
  type COMGeometry = {
231
232
  name: string;
@@ -235,6 +236,7 @@ type COMGeometry = {
235
236
  };
236
237
  type COMMaterial = {
237
238
  color: string | number;
239
+ map: Texture | null;
238
240
  roughness: number;
239
241
  roughnessMap: Texture | null;
240
242
  metalness: number;
@@ -245,7 +247,7 @@ type COMPrimitive = COMBaseEntity & {
245
247
  rotation: Vector3Like;
246
248
  scale: Vector3Like;
247
249
  geometry: COMGeometry;
248
- material: COMMaterial;
250
+ material?: Partial<COMMaterial>;
249
251
  };
250
252
  type COMEntity = COMPov | COMLight | COMModel | COMPrimitive;
251
253
 
package/build/dive.d.ts CHANGED
@@ -226,6 +226,7 @@ type COMModel = COMBaseEntity & {
226
226
  rotation: Vector3Like;
227
227
  scale: Vector3Like;
228
228
  loaded: boolean;
229
+ material?: Partial<COMMaterial>;
229
230
  };
230
231
  type COMGeometry = {
231
232
  name: string;
@@ -235,6 +236,7 @@ type COMGeometry = {
235
236
  };
236
237
  type COMMaterial = {
237
238
  color: string | number;
239
+ map: Texture | null;
238
240
  roughness: number;
239
241
  roughnessMap: Texture | null;
240
242
  metalness: number;
@@ -245,7 +247,7 @@ type COMPrimitive = COMBaseEntity & {
245
247
  rotation: Vector3Like;
246
248
  scale: Vector3Like;
247
249
  geometry: COMGeometry;
248
- material: COMMaterial;
250
+ material?: Partial<COMMaterial>;
249
251
  };
250
252
  type COMEntity = COMPov | COMLight | COMModel | COMPrimitive;
251
253
 
package/build/dive.js CHANGED
@@ -649,7 +649,7 @@ var DIVERenderer = class extends WebGLRenderer {
649
649
  };
650
650
 
651
651
  // src/scene/Scene.ts
652
- import { Color as Color7, Scene as Scene2 } from "three";
652
+ import { Color as Color8, Scene as Scene2 } from "three";
653
653
 
654
654
  // src/scene/root/Root.ts
655
655
  import { Box3 as Box33, Object3D as Object3D11 } from "three";
@@ -1195,7 +1195,7 @@ import { Object3D as Object3D7 } from "three";
1195
1195
 
1196
1196
  // src/model/Model.ts
1197
1197
  init_VisibilityLayerMask();
1198
- import { Box3, Object3D as Object3D6, Raycaster as Raycaster2, Vector3 as Vector32 } from "three";
1198
+ import { Box3, Color as Color5, MeshStandardMaterial, Object3D as Object3D6, Raycaster as Raycaster2, Vector3 as Vector32 } from "three";
1199
1199
 
1200
1200
  // src/helper/findSceneRecursive/findSceneRecursive.ts
1201
1201
  var findSceneRecursive = (object) => {
@@ -1212,6 +1212,8 @@ var DIVEModel = class extends Object3D6 {
1212
1212
  this.isSelectable = true;
1213
1213
  this.isMoveable = true;
1214
1214
  this.gizmo = null;
1215
+ this._mesh = null;
1216
+ this._material = null;
1215
1217
  this.layers.mask = PRODUCT_LAYER_MASK;
1216
1218
  this.boundingBox = new Box3();
1217
1219
  }
@@ -1222,6 +1224,14 @@ var DIVEModel = class extends Object3D6 {
1222
1224
  child.receiveShadow = true;
1223
1225
  child.layers.mask = this.layers.mask;
1224
1226
  this.boundingBox.expandByObject(child);
1227
+ if (!this._mesh && "isMesh" in child) {
1228
+ this._mesh = child;
1229
+ if (this._material) {
1230
+ this._mesh.material = this._material;
1231
+ } else {
1232
+ this._material = child.material;
1233
+ }
1234
+ }
1225
1235
  });
1226
1236
  this.add(gltf.scene);
1227
1237
  }
@@ -1239,6 +1249,28 @@ var DIVEModel = class extends Object3D6 {
1239
1249
  child.visible = visible;
1240
1250
  });
1241
1251
  }
1252
+ SetMaterial(material) {
1253
+ if (!this._material) {
1254
+ this._material = new MeshStandardMaterial();
1255
+ }
1256
+ if (material.color !== void 0) this._material.color = new Color5(material.color);
1257
+ if (material.map !== void 0) this._material.map = material.map;
1258
+ if (material.roughness !== void 0) this._material.roughness = material.roughness;
1259
+ if (material.roughnessMap !== void 0) {
1260
+ this._material.roughnessMap = material.roughnessMap;
1261
+ if (this._material.roughnessMap) {
1262
+ this._material.roughness = 1;
1263
+ }
1264
+ }
1265
+ if (material.metalness !== void 0) this._material.metalness = material.metalness;
1266
+ if (material.metalnessMap !== void 0) {
1267
+ this._material.metalnessMap = material.metalnessMap;
1268
+ if (this._material.metalnessMap) {
1269
+ this._material.metalness = 1;
1270
+ }
1271
+ }
1272
+ if (this._mesh) this._mesh.material = this._material;
1273
+ }
1242
1274
  SetToWorldOrigin() {
1243
1275
  var _a;
1244
1276
  this.position.set(0, 0, 0);
@@ -1354,6 +1386,7 @@ var DIVEModelRoot = class extends Object3D7 {
1354
1386
  if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
1355
1387
  if (object.scale !== void 0) sceneObject.SetScale(object.scale);
1356
1388
  if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
1389
+ if (object.material !== void 0) sceneObject.SetMaterial(object.material);
1357
1390
  }
1358
1391
  DeleteModel(object) {
1359
1392
  if (object.id === void 0) {
@@ -1392,7 +1425,7 @@ var DIVEModelRoot = class extends Object3D7 {
1392
1425
  import { Object3D as Object3D9 } from "three";
1393
1426
 
1394
1427
  // 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";
1428
+ import { Box3 as Box32, BoxGeometry, BufferGeometry, Color as Color6, CylinderGeometry, Float32BufferAttribute, Mesh as Mesh3, Object3D as Object3D8, Raycaster as Raycaster3, SphereGeometry as SphereGeometry2, Uint32BufferAttribute, Vector3 as Vector33 } from "three";
1396
1429
  init_VisibilityLayerMask();
1397
1430
  var DIVEPrimitive = class extends Object3D8 {
1398
1431
  constructor() {
@@ -1401,7 +1434,7 @@ var DIVEPrimitive = class extends Object3D8 {
1401
1434
  this.isMoveable = true;
1402
1435
  this.gizmo = null;
1403
1436
  this.layers.mask = PRODUCT_LAYER_MASK;
1404
- this._mesh = new Mesh2();
1437
+ this._mesh = new Mesh3();
1405
1438
  this._mesh.layers.mask = PRODUCT_LAYER_MASK;
1406
1439
  this._mesh.castShadow = true;
1407
1440
  this._mesh.receiveShadow = true;
@@ -1429,19 +1462,23 @@ var DIVEPrimitive = class extends Object3D8 {
1429
1462
  }
1430
1463
  SetMaterial(material) {
1431
1464
  const primitiveMaterial = this._mesh.material;
1432
- primitiveMaterial.color = new Color5(material.color);
1433
- if (material.roughnessMap) {
1465
+ if (material.color !== void 0) primitiveMaterial.color = new Color6(material.color);
1466
+ if (material.map !== void 0) primitiveMaterial.map = material.map;
1467
+ if (material.roughness !== void 0) primitiveMaterial.roughness = material.roughness;
1468
+ if (material.roughnessMap !== void 0) {
1434
1469
  primitiveMaterial.roughnessMap = material.roughnessMap;
1435
- primitiveMaterial.roughness = 1;
1436
- } else {
1437
- primitiveMaterial.roughness = material.roughness;
1470
+ if (primitiveMaterial.roughnessMap) {
1471
+ primitiveMaterial.roughness = 1;
1472
+ }
1438
1473
  }
1439
- if (material.metalnessMap) {
1474
+ if (material.metalness !== void 0) primitiveMaterial.metalness = material.metalness;
1475
+ if (material.metalnessMap !== void 0) {
1440
1476
  primitiveMaterial.metalnessMap = material.metalnessMap;
1441
- primitiveMaterial.metalness = 0;
1442
- } else {
1443
- primitiveMaterial.metalness = material.metalness;
1477
+ if (primitiveMaterial.metalnessMap) {
1478
+ primitiveMaterial.metalness = 1;
1479
+ }
1444
1480
  }
1481
+ if (this._mesh) this._mesh.material = primitiveMaterial;
1445
1482
  }
1446
1483
  SetToWorldOrigin() {
1447
1484
  var _a;
@@ -1643,10 +1680,10 @@ var DIVEPrimitiveRoot = class extends Object3D9 {
1643
1680
 
1644
1681
  // src/primitive/floor/Floor.ts
1645
1682
  init_VisibilityLayerMask();
1646
- import { Color as Color6, Mesh as Mesh3, MeshStandardMaterial as MeshStandardMaterial2, PlaneGeometry } from "three";
1647
- var DIVEFloor = class extends Mesh3 {
1683
+ import { Color as Color7, Mesh as Mesh4, MeshStandardMaterial as MeshStandardMaterial3, PlaneGeometry } from "three";
1684
+ var DIVEFloor = class extends Mesh4 {
1648
1685
  constructor() {
1649
- super(new PlaneGeometry(1e4, 1e4), new MeshStandardMaterial2({ color: new Color6(150 / 255, 150 / 255, 150 / 255) }));
1686
+ super(new PlaneGeometry(1e4, 1e4), new MeshStandardMaterial3({ color: new Color7(150 / 255, 150 / 255, 150 / 255) }));
1650
1687
  this.isFloor = true;
1651
1688
  this.name = "Floor";
1652
1689
  this.layers.mask = PRODUCT_LAYER_MASK;
@@ -1657,7 +1694,7 @@ var DIVEFloor = class extends Mesh3 {
1657
1694
  this.visible = visible;
1658
1695
  }
1659
1696
  SetColor(color) {
1660
- this.material.color = new Color6(color);
1697
+ this.material.color = new Color7(color);
1661
1698
  }
1662
1699
  };
1663
1700
 
@@ -1816,12 +1853,12 @@ var DIVEScene = class extends Scene2 {
1816
1853
  }
1817
1854
  constructor() {
1818
1855
  super();
1819
- this.background = new Color7(16777215);
1856
+ this.background = new Color8(16777215);
1820
1857
  this.root = new DIVERoot();
1821
1858
  this.add(this.root);
1822
1859
  }
1823
1860
  SetBackground(color) {
1824
- this.background = new Color7(color);
1861
+ this.background = new Color8(color);
1825
1862
  }
1826
1863
  ComputeSceneBB() {
1827
1864
  return this.Root.ComputeSceneBB();
@@ -2059,7 +2096,7 @@ var DIVEAnimationSystem = class {
2059
2096
 
2060
2097
  // src/axiscamera/AxisCamera.ts
2061
2098
  init_VisibilityLayerMask();
2062
- import { AxesHelper, Color as Color8, Matrix4, OrthographicCamera, Vector4 } from "three";
2099
+ import { AxesHelper, Color as Color9, Matrix4, OrthographicCamera, Vector4 } from "three";
2063
2100
  import SpriteText from "three-spritetext";
2064
2101
 
2065
2102
  // src/constant/AxisHelperColors.ts
@@ -2080,9 +2117,9 @@ var DIVEAxisCamera = class extends OrthographicCamera {
2080
2117
  this.axesHelper.material.depthTest = false;
2081
2118
  this.axesHelper.position.set(0, 0, -1);
2082
2119
  this.axesHelper.setColors(
2083
- new Color8(AxesColorRed),
2084
- new Color8(AxesColorGreen),
2085
- new Color8(AxesColorBlue)
2120
+ new Color9(AxesColorRed),
2121
+ new Color9(AxesColorGreen),
2122
+ new Color9(AxesColorBlue)
2086
2123
  );
2087
2124
  const x = new SpriteText("X", 0.2, AxesColorRedLetter);
2088
2125
  const y = new SpriteText("Y", 0.2, AxesColorGreenLetter);