@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.cjs CHANGED
@@ -1234,6 +1234,8 @@ var DIVEModel = class extends import_three8.Object3D {
1234
1234
  this.isSelectable = true;
1235
1235
  this.isMoveable = true;
1236
1236
  this.gizmo = null;
1237
+ this._mesh = null;
1238
+ this._material = null;
1237
1239
  this.layers.mask = PRODUCT_LAYER_MASK;
1238
1240
  this.boundingBox = new import_three8.Box3();
1239
1241
  }
@@ -1244,6 +1246,14 @@ var DIVEModel = class extends import_three8.Object3D {
1244
1246
  child.receiveShadow = true;
1245
1247
  child.layers.mask = this.layers.mask;
1246
1248
  this.boundingBox.expandByObject(child);
1249
+ if (!this._mesh && "isMesh" in child) {
1250
+ this._mesh = child;
1251
+ if (this._material) {
1252
+ this._mesh.material = this._material;
1253
+ } else {
1254
+ this._material = child.material;
1255
+ }
1256
+ }
1247
1257
  });
1248
1258
  this.add(gltf.scene);
1249
1259
  }
@@ -1261,6 +1271,28 @@ var DIVEModel = class extends import_three8.Object3D {
1261
1271
  child.visible = visible;
1262
1272
  });
1263
1273
  }
1274
+ SetMaterial(material) {
1275
+ if (!this._material) {
1276
+ this._material = new import_three8.MeshStandardMaterial();
1277
+ }
1278
+ if (material.color !== void 0) this._material.color = new import_three8.Color(material.color);
1279
+ if (material.map !== void 0) this._material.map = material.map;
1280
+ if (material.roughness !== void 0) this._material.roughness = material.roughness;
1281
+ if (material.roughnessMap !== void 0) {
1282
+ this._material.roughnessMap = material.roughnessMap;
1283
+ if (this._material.roughnessMap) {
1284
+ this._material.roughness = 1;
1285
+ }
1286
+ }
1287
+ if (material.metalness !== void 0) this._material.metalness = material.metalness;
1288
+ if (material.metalnessMap !== void 0) {
1289
+ this._material.metalnessMap = material.metalnessMap;
1290
+ if (this._material.metalnessMap) {
1291
+ this._material.metalness = 1;
1292
+ }
1293
+ }
1294
+ if (this._mesh) this._mesh.material = this._material;
1295
+ }
1264
1296
  SetToWorldOrigin() {
1265
1297
  var _a;
1266
1298
  this.position.set(0, 0, 0);
@@ -1376,6 +1408,7 @@ var DIVEModelRoot = class extends import_three9.Object3D {
1376
1408
  if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
1377
1409
  if (object.scale !== void 0) sceneObject.SetScale(object.scale);
1378
1410
  if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
1411
+ if (object.material !== void 0) sceneObject.SetMaterial(object.material);
1379
1412
  }
1380
1413
  DeleteModel(object) {
1381
1414
  if (object.id === void 0) {
@@ -1451,19 +1484,23 @@ var DIVEPrimitive = class extends import_three10.Object3D {
1451
1484
  }
1452
1485
  SetMaterial(material) {
1453
1486
  const primitiveMaterial = this._mesh.material;
1454
- primitiveMaterial.color = new import_three10.Color(material.color);
1455
- if (material.roughnessMap) {
1487
+ if (material.color !== void 0) primitiveMaterial.color = new import_three10.Color(material.color);
1488
+ if (material.map !== void 0) primitiveMaterial.map = material.map;
1489
+ if (material.roughness !== void 0) primitiveMaterial.roughness = material.roughness;
1490
+ if (material.roughnessMap !== void 0) {
1456
1491
  primitiveMaterial.roughnessMap = material.roughnessMap;
1457
- primitiveMaterial.roughness = 1;
1458
- } else {
1459
- primitiveMaterial.roughness = material.roughness;
1492
+ if (primitiveMaterial.roughnessMap) {
1493
+ primitiveMaterial.roughness = 1;
1494
+ }
1460
1495
  }
1461
- if (material.metalnessMap) {
1496
+ if (material.metalness !== void 0) primitiveMaterial.metalness = material.metalness;
1497
+ if (material.metalnessMap !== void 0) {
1462
1498
  primitiveMaterial.metalnessMap = material.metalnessMap;
1463
- primitiveMaterial.metalness = 0;
1464
- } else {
1465
- primitiveMaterial.metalness = material.metalness;
1499
+ if (primitiveMaterial.metalnessMap) {
1500
+ primitiveMaterial.metalness = 1;
1501
+ }
1466
1502
  }
1503
+ if (this._mesh) this._mesh.material = primitiveMaterial;
1467
1504
  }
1468
1505
  SetToWorldOrigin() {
1469
1506
  var _a;