@colijnit/configurator 12.0.15 → 12.0.17

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.
@@ -532,7 +532,7 @@
532
532
  };
533
533
  ThreedUtils.prototype.loadGlbSource = function (file) {
534
534
  return __awaiter(this, void 0, void 0, function () {
535
- var obj, children;
535
+ var obj, children, name, parent;
536
536
  return __generator(this, function (_a) {
537
537
  switch (_a.label) {
538
538
  case 0: return [4 /*yield*/, this.loadGlbModel(file, false)];
@@ -549,8 +549,12 @@
549
549
  });
550
550
  if (obj.children.length === 1 && obj.children[0] instanceof THREE__namespace.Group) { // flatten children
551
551
  children = obj.children[0].children.slice();
552
+ name = obj.children[0].name;
552
553
  obj.children.length = 0;
553
- obj.children = children;
554
+ parent = new THREE__namespace.Object3D();
555
+ parent.name = name;
556
+ parent.children = children;
557
+ obj.add(parent);
554
558
  }
555
559
  }
556
560
  return [2 /*return*/, obj];
@@ -773,9 +777,14 @@
773
777
  return SceneUtils;
774
778
  }());
775
779
 
780
+ var VariationSettingsSettings = /** @class */ (function () {
781
+ function VariationSettingsSettings() {
782
+ }
783
+ return VariationSettingsSettings;
784
+ }());
776
785
  var VariationSettings = /** @class */ (function () {
777
786
  function VariationSettings() {
778
- this.settings = {};
787
+ this.settings = new VariationSettingsSettings();
779
788
  this.loading = false;
780
789
  this.loaded = new rxjs.Subject();
781
790
  }
@@ -867,9 +876,9 @@
867
876
  }
868
877
  AssetUtils.CreateMaterialFromAsset = function (asset) {
869
878
  return __awaiter(this, void 0, void 0, function () {
870
- var material, _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, metalness, roughness;
871
- return __generator(this, function (_m) {
872
- switch (_m.label) {
879
+ var material, _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
880
+ return __generator(this, function (_o) {
881
+ switch (_o.label) {
873
882
  case 0:
874
883
  material = new Material();
875
884
  if (!asset) {
@@ -882,24 +891,24 @@
882
891
  _a = material;
883
892
  return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_texture', asset.texture, material)];
884
893
  case 1:
885
- _a.texture = _m.sent();
894
+ _a.texture = _o.sent();
886
895
  material.texture.encoding = THREE.sRGBEncoding;
887
896
  material.textureFilename = asset.textureFilename;
888
- _m.label = 2;
897
+ _o.label = 2;
889
898
  case 2:
890
899
  if (!asset.normal) return [3 /*break*/, 4];
891
900
  _b = material;
892
901
  return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_normal', asset.normal, material)];
893
902
  case 3:
894
- _b.normal = _m.sent();
903
+ _b.normal = _o.sent();
895
904
  material.normalFilename = asset.normalFilename;
896
- _m.label = 4;
905
+ _o.label = 4;
897
906
  case 4:
898
907
  if (!asset.orm) return [3 /*break*/, 6];
899
908
  _c = material;
900
909
  return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_orm', asset.orm, material)];
901
910
  case 5:
902
- _c.ao = _m.sent();
911
+ _c.ao = _o.sent();
903
912
  material.roughness = material.ao;
904
913
  material.metalness = material.ao;
905
914
  material.aoFilename = asset.ormFilename;
@@ -911,74 +920,74 @@
911
920
  _d = material;
912
921
  return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_ao', asset.ao, material)];
913
922
  case 7:
914
- _d.ao = _m.sent();
923
+ _d.ao = _o.sent();
915
924
  material.aoFilename = asset.aoFilename;
916
- _m.label = 8;
925
+ _o.label = 8;
917
926
  case 8:
918
927
  if (!asset.metalness) return [3 /*break*/, 10];
919
928
  _e = material;
920
929
  return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_metalness', asset.metalness, material)];
921
930
  case 9:
922
- _e.metalness = _m.sent();
931
+ _e.metalness = _o.sent();
923
932
  material.metalnessFilename = asset.metalnessFilename;
924
- _m.label = 10;
933
+ _o.label = 10;
925
934
  case 10:
926
935
  if (!asset.roughness) return [3 /*break*/, 12];
927
936
  _f = material;
928
937
  return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_roughness', asset.roughness, material)];
929
938
  case 11:
930
- _f.roughness = _m.sent();
939
+ _f.roughness = _o.sent();
931
940
  material.roughnessFilename = asset.roughnessFilename;
932
- _m.label = 12;
941
+ _o.label = 12;
933
942
  case 12:
934
943
  if (!asset.displacement) return [3 /*break*/, 14];
935
944
  _g = material;
936
945
  return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_displacement', asset.displacement, material)];
937
946
  case 13:
938
- _g.displacement = _m.sent();
947
+ _g.displacement = _o.sent();
939
948
  material.displacementFilename = asset.displacementFilename;
940
- _m.label = 14;
949
+ _o.label = 14;
941
950
  case 14:
942
951
  if (!asset.envMap) return [3 /*break*/, 16];
943
952
  _h = material;
944
953
  return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_env', asset.envMap, material, true)];
945
954
  case 15:
946
- _h.envMap = _m.sent();
955
+ _h.envMap = _o.sent();
947
956
  material.envMapFilename = asset.envMapFilename;
948
- _m.label = 16;
957
+ _o.label = 16;
949
958
  case 16:
950
959
  if (!asset.sheenColorMap) return [3 /*break*/, 18];
951
960
  _j = material;
952
961
  return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_sheen_color', asset.sheenColorMap, material)];
953
962
  case 17:
954
- _j.sheenColorMap = _m.sent();
963
+ _j.sheenColorMap = _o.sent();
955
964
  material.sheenColorMapFileName = asset.sheenColorMapFilename;
956
- _m.label = 18;
965
+ _o.label = 18;
957
966
  case 18:
958
967
  if (!asset.sheenRoughnessMap) return [3 /*break*/, 20];
959
968
  _k = material;
960
969
  return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_sheen_roughness', asset.sheenRoughnessMap, material)];
961
970
  case 19:
962
- _k.sheenRoughnessMap = _m.sent();
971
+ _k.sheenRoughnessMap = _o.sent();
963
972
  material.sheenRoughnessMapFileName = asset.sheenRoughnessMapFilename;
964
- _m.label = 20;
973
+ _o.label = 20;
965
974
  case 20:
966
- if (!asset.emissive) return [3 /*break*/, 22];
975
+ if (!asset.transmissionMap) return [3 /*break*/, 22];
967
976
  _l = material;
968
- return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_emissive', asset.emissive, material)];
977
+ return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_transmission', asset.transmissionMap, material)];
969
978
  case 21:
970
- _l.emissive = _m.sent();
971
- material.emissiveFileName = asset.emissiveFilename;
972
- _m.label = 22;
979
+ _l.transmissionMap = _o.sent();
980
+ material.transmissionMapFileName = asset.transmissionMapFilename;
981
+ _o.label = 22;
973
982
  case 22:
974
- metalness = parseFloat(asset['metalness']);
975
- if (!isNaN(metalness)) {
976
- material.metalnessValue = Math.min(1, metalness);
977
- }
978
- roughness = parseFloat(asset['roughness']);
979
- if (!isNaN(roughness)) {
980
- material.roughnessValue = Math.min(1, roughness);
981
- }
983
+ if (!asset.emissive) return [3 /*break*/, 24];
984
+ _m = material;
985
+ return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_emissive', asset.emissive, material)];
986
+ case 23:
987
+ _m.emissive = _o.sent();
988
+ material.emissiveFileName = asset.emissiveFilename;
989
+ _o.label = 24;
990
+ case 24:
982
991
  material.sheen = asset.sheen;
983
992
  material.emissiveIntensityValue = asset.emissiveIntensity;
984
993
  material.emissiveValue = asset.emissiveValue;
@@ -990,8 +999,10 @@
990
999
  material.envMapIntensity = asset.envMapIntensity;
991
1000
  material.reflectivity = asset.reflectivity;
992
1001
  material.displacementValue = asset.displacementValue;
993
- material.transparency = asset.transparency;
994
1002
  material.transmission = asset.transmission;
1003
+ material.ior = asset.ior;
1004
+ material.thickness = asset.thickness;
1005
+ material.specularIntensity = asset.specularIntensity;
995
1006
  return [2 /*return*/, material];
996
1007
  }
997
1008
  });
@@ -1016,6 +1027,14 @@
1016
1027
  if (!isNaN(repeaty)) {
1017
1028
  material.repeatY = repeaty;
1018
1029
  }
1030
+ var metalness = parseFloat(settings['metalness']);
1031
+ if (!isNaN(metalness)) {
1032
+ material.metalnessValue = Math.min(1, metalness);
1033
+ }
1034
+ var roughness = parseFloat(settings['roughness']);
1035
+ if (!isNaN(roughness)) {
1036
+ material.roughnessValue = Math.min(1, roughness);
1037
+ }
1019
1038
  };
1020
1039
  return AssetUtils;
1021
1040
  }());
@@ -1164,31 +1183,31 @@
1164
1183
  };
1165
1184
  VariationUtils.CreateSettingsBasedOnIndex = function (index, variationSettings, zipContent) {
1166
1185
  return __awaiter(this, void 0, void 0, function () {
1167
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1168
- return __generator(this, function (_m) {
1169
- switch (_m.label) {
1186
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1187
+ return __generator(this, function (_o) {
1188
+ switch (_o.label) {
1170
1189
  case 0:
1171
1190
  if (!index.normalFile) return [3 /*break*/, 2];
1172
1191
  _a = variationSettings;
1173
1192
  return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.normalFile], index.normalFile)];
1174
1193
  case 1:
1175
- _a.normal = _m.sent();
1194
+ _a.normal = _o.sent();
1176
1195
  variationSettings.normalFilename = index.normalFile;
1177
- _m.label = 2;
1196
+ _o.label = 2;
1178
1197
  case 2:
1179
1198
  if (!index.diffuseFile) return [3 /*break*/, 4];
1180
1199
  _b = variationSettings;
1181
1200
  return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.diffuseFile], index.diffuseFile)];
1182
1201
  case 3:
1183
- _b.texture = _m.sent();
1202
+ _b.texture = _o.sent();
1184
1203
  variationSettings.textureFilename = index.diffuseFile;
1185
- _m.label = 4;
1204
+ _o.label = 4;
1186
1205
  case 4:
1187
1206
  if (!index.ormFile) return [3 /*break*/, 6];
1188
1207
  _c = variationSettings;
1189
1208
  return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.ormFile], index.ormFile)];
1190
1209
  case 5:
1191
- _c.orm = _m.sent();
1210
+ _c.orm = _o.sent();
1192
1211
  variationSettings.ormFilename = index.ormFile;
1193
1212
  return [3 /*break*/, 12];
1194
1213
  case 6:
@@ -1196,74 +1215,80 @@
1196
1215
  _d = variationSettings;
1197
1216
  return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.aoFile], index.aoFile)];
1198
1217
  case 7:
1199
- _d.ao = _m.sent();
1218
+ _d.ao = _o.sent();
1200
1219
  variationSettings.aoFilename = index.aoFile;
1201
- _m.label = 8;
1220
+ _o.label = 8;
1202
1221
  case 8:
1203
1222
  if (!index.metalnessFile) return [3 /*break*/, 10];
1204
1223
  _e = variationSettings;
1205
1224
  return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.metalnessFile], index.metalnessFile)];
1206
1225
  case 9:
1207
- _e.metalness = _m.sent();
1226
+ _e.metalness = _o.sent();
1208
1227
  variationSettings.metalnessFilename = index.metalnessFile;
1209
- _m.label = 10;
1228
+ _o.label = 10;
1210
1229
  case 10:
1211
1230
  if (!index.roughnessFile) return [3 /*break*/, 12];
1212
1231
  _f = variationSettings;
1213
1232
  return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.roughnessFile], index.roughnessFile)];
1214
1233
  case 11:
1215
- _f.roughness = _m.sent();
1234
+ _f.roughness = _o.sent();
1216
1235
  variationSettings.roughnessFilename = index.roughnessFile;
1217
- _m.label = 12;
1236
+ _o.label = 12;
1218
1237
  case 12:
1219
1238
  if (!index.displacementFile) return [3 /*break*/, 14];
1220
1239
  _g = variationSettings;
1221
1240
  return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.displacementFile], index.displacementFile)];
1222
1241
  case 13:
1223
- _g.displacement = _m.sent();
1242
+ _g.displacement = _o.sent();
1224
1243
  variationSettings.displacementFilename = index.displacementFile;
1225
- _m.label = 14;
1244
+ _o.label = 14;
1226
1245
  case 14:
1227
1246
  if (!index.emissiveFile) return [3 /*break*/, 16];
1228
1247
  _h = variationSettings;
1229
1248
  return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.emissiveFile], index.emissiveFile)];
1230
1249
  case 15:
1231
- _h.emissive = _m.sent();
1250
+ _h.emissive = _o.sent();
1232
1251
  variationSettings.emissiveFilename = index.emissiveFile;
1233
- _m.label = 16;
1252
+ _o.label = 16;
1234
1253
  case 16:
1235
1254
  if (!index.envMapFile) return [3 /*break*/, 18];
1236
1255
  _j = variationSettings;
1237
1256
  return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.envMapFile], index.envMapFile)];
1238
1257
  case 17:
1239
- _j.envMap = _m.sent();
1258
+ _j.envMap = _o.sent();
1240
1259
  variationSettings.envMapFilename = index.envMapFile;
1241
- _m.label = 18;
1260
+ _o.label = 18;
1242
1261
  case 18:
1243
1262
  if (!index.sheenColorMapFile) return [3 /*break*/, 20];
1244
1263
  _k = variationSettings;
1245
1264
  return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.sheenColorMapFile], index.sheenColorMapFile)];
1246
1265
  case 19:
1247
- _k.sheenColorMap = _m.sent();
1266
+ _k.sheenColorMap = _o.sent();
1248
1267
  variationSettings.sheenColorMapFilename = index.sheenColorMapFile;
1249
- _m.label = 20;
1268
+ _o.label = 20;
1250
1269
  case 20:
1251
1270
  if (!index.sheenRoughnessMapFile) return [3 /*break*/, 22];
1252
1271
  _l = variationSettings;
1253
1272
  return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.sheenRoughnessMapFile], index.sheenRoughnessMapFile)];
1254
1273
  case 21:
1255
- _l.sheenRoughnessMap = _m.sent();
1274
+ _l.sheenRoughnessMap = _o.sent();
1256
1275
  variationSettings.sheenRoughnessMapFilename = index.sheenColorMapFile;
1257
- _m.label = 22;
1276
+ _o.label = 22;
1258
1277
  case 22:
1278
+ if (!index.transmissionMapFile) return [3 /*break*/, 24];
1279
+ _m = variationSettings;
1280
+ return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.transmissionMapFile], index.transmissionMapFile)];
1281
+ case 23:
1282
+ _m.transmissionMap = _o.sent();
1283
+ variationSettings.transmissionMapFilename = index.transmissionMapFile;
1284
+ _o.label = 24;
1285
+ case 24:
1259
1286
  if (index.repeat) {
1260
- variationSettings.settings = {
1261
- repeatx: index.repeat.repeatx,
1262
- repeaty: index.repeat.repeaty
1263
- };
1287
+ variationSettings.settings.repeatx = index.repeat.repeatx;
1288
+ variationSettings.settings.repeaty = index.repeat.repeaty;
1264
1289
  }
1265
- variationSettings.metalness = index.metalness;
1266
- variationSettings.roughness = index.roughness;
1290
+ variationSettings.settings.metalness = index.metalness;
1291
+ variationSettings.settings.roughness = index.roughness;
1267
1292
  if (index.sheen && typeof index.sheen === 'object') {
1268
1293
  variationSettings.sheen = 1;
1269
1294
  variationSettings.sheenColor = new THREE__namespace.Color(index.sheen.r, index.sheen.g, index.sheen.b);
@@ -1285,8 +1310,10 @@
1285
1310
  variationSettings.reflectivity = index.reflectivity;
1286
1311
  variationSettings.displacementValue = index.displacementValue;
1287
1312
  variationSettings.side = index.side;
1288
- variationSettings.transparency = index.transparency;
1289
1313
  variationSettings.transmission = index.transmission;
1314
+ variationSettings.ior = index.ior;
1315
+ variationSettings.thickness = index.thickness;
1316
+ variationSettings.specularIntensity = index.specularIntensity;
1290
1317
  return [2 /*return*/];
1291
1318
  }
1292
1319
  });
@@ -1369,6 +1396,12 @@
1369
1396
  variationSettings.sheenRoughnessMapFilename = fileName;
1370
1397
  }));
1371
1398
  }
1399
+ else if (file_1.name.toLowerCase().indexOf('transmissionMap') > -1 && this_1.FileIsImage(file_1.name)) {
1400
+ allLoaded.push(zipContent.files[fileName].async('base64').then(function (transmissionMapFile) {
1401
+ variationSettings.transmissionMap = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + transmissionMapFile;
1402
+ variationSettings.transmissionMapFilename = fileName;
1403
+ }));
1404
+ }
1372
1405
  else if (file_1.name.indexOf('.jp') > -1) {
1373
1406
  allLoaded.push(zipContent.files[fileName].async('base64').then(function (textureFile) {
1374
1407
  variationSettings.texture = 'data:image/jpeg;base64,' + textureFile;
@@ -1804,9 +1837,15 @@
1804
1837
  if (mesh.material[m].name.toLowerCase().indexOf(materialToSearch) !== -1) {
1805
1838
  if (variation.material instanceof THREE__namespace.Material) {
1806
1839
  mesh.material[m] = variation.material;
1840
+ if (mesh.material[m].name && (mesh.material[m].name === 'Fixed_Glass' || mesh.material[m].name === 'Default_Glass')) {
1841
+ mesh.castShadow = false;
1842
+ }
1807
1843
  }
1808
1844
  else {
1809
1845
  mesh.material[m] = _this._setMeshMaterialFromVariation(mesh.material[m].name, variation, usePbr);
1846
+ if (mesh.material[m].name && (mesh.material[m].name === 'Fixed_Glass' || mesh.material[m].name === 'Default_Glass')) {
1847
+ mesh.castShadow = false;
1848
+ }
1810
1849
  }
1811
1850
  }
1812
1851
  }
@@ -1815,9 +1854,15 @@
1815
1854
  if (mesh.material.name.toLowerCase().indexOf(materialToSearch) !== -1) {
1816
1855
  if (variation.material instanceof THREE__namespace.Material) {
1817
1856
  mesh.material = variation.material;
1857
+ if (mesh.material.name && (mesh.material.name === 'Fixed_Glass' || mesh.material.name === 'Default_Glass')) {
1858
+ mesh.castShadow = false;
1859
+ }
1818
1860
  }
1819
1861
  else {
1820
1862
  mesh.material = _this._setMeshMaterialFromVariation(mesh.material.name, variation, usePbr);
1863
+ if (mesh.material.name && (mesh.material.name === 'Fixed_Glass' || mesh.material.name === 'Default_Glass')) {
1864
+ mesh.castShadow = false;
1865
+ }
1821
1866
  }
1822
1867
  }
1823
1868
  }
@@ -1837,22 +1882,21 @@
1837
1882
  }
1838
1883
  if (!usePbr) {
1839
1884
  var newMaterial = new THREE__namespace.MeshPhongMaterial({
1840
- name: name,
1841
1885
  shininess: material.shininess,
1842
1886
  specular: material.specular,
1843
1887
  map: material.texture,
1844
1888
  normalMap: material.normal
1845
1889
  });
1890
+ newMaterial.name = name;
1846
1891
  newMaterial.color.setRGB(0.8, 0.8, 0.8);
1847
1892
  newMaterial.needsUpdate = true;
1848
1893
  return newMaterial;
1849
1894
  }
1850
- if (material.sheen || material.sheenColor || material.reflectivity) { // TODO: Proper check for all unique physical material properties
1895
+ if (material.sheen || material.sheenColor || material.reflectivity || material.transmission) { // TODO: Proper check for all unique physical material properties
1851
1896
  var params = {
1852
1897
  // side: material.side ? material.side : FrontSide,
1853
- name: name,
1854
- roughness: material.roughnessValue ? material.roughnessValue : 1,
1855
- metalness: material.metalnessValue ? material.metalnessValue : 0,
1898
+ roughness: material.roughnessValue !== undefined && material.roughnessValue !== null ? material.roughnessValue : 1,
1899
+ metalness: material.metalnessValue !== undefined && material.metalnessValue !== null ? material.metalnessValue : 0,
1856
1900
  envMapIntensity: material.envMapIntensity ? material.envMapIntensity : 0.01,
1857
1901
  clearcoatMap: material.clearcoatMap ? material.clearcoatMap : null,
1858
1902
  clearcoatRoughnessMap: material.clearcoatRoughnessMap ? material.clearcoatRoughnessMap : null,
@@ -1866,12 +1910,6 @@
1866
1910
  if (material.opacity) {
1867
1911
  params.opacity = material.opacity;
1868
1912
  }
1869
- if (material.transparency) {
1870
- params.transmission = material.transparency;
1871
- }
1872
- if (material.transmission) {
1873
- params.transmission = material.transmission;
1874
- }
1875
1913
  if (material.transparent) {
1876
1914
  params.transparent = material.transparent;
1877
1915
  }
@@ -1919,13 +1957,14 @@
1919
1957
  material.envMap.magFilter = THREE__namespace.NearestFilter;
1920
1958
  }
1921
1959
  }
1922
- if (material.reflectivity) {
1960
+ if (material.reflectivity !== undefined && material.reflectivity !== null) {
1923
1961
  params.reflectivity = material.reflectivity;
1924
1962
  }
1925
1963
  if (material.side) {
1926
1964
  params.side = material.side;
1927
1965
  }
1928
1966
  var newMaterial = new THREE__namespace.MeshPhysicalMaterial(params);
1967
+ newMaterial.name = name;
1929
1968
  newMaterial.color.setRGB(1, 1, 1);
1930
1969
  if (material.sheen) {
1931
1970
  newMaterial.sheen = material.sheen;
@@ -1947,15 +1986,30 @@
1947
1986
  if (material.transmission) {
1948
1987
  newMaterial.transmission = material.transmission;
1949
1988
  }
1989
+ if (material.ior !== undefined && material.ior !== null) {
1990
+ newMaterial.ior = material.ior;
1991
+ }
1992
+ if (material.thickness !== undefined && material.thickness !== null) {
1993
+ newMaterial.thickness = material.thickness;
1994
+ }
1995
+ if (material.specularIntensity !== undefined && material.specularIntensity !== null) {
1996
+ newMaterial.specularIntensity = material.specularIntensity;
1997
+ }
1998
+ if (material.transmissionMap) {
1999
+ newMaterial.transmissionMap = material.transmissionMap;
2000
+ newMaterial.transmissionMap.needsUpdate = true;
2001
+ }
2002
+ if (newMaterial.name && (newMaterial.name === 'Fixed_Glass' || newMaterial.name === 'Default_Glass')) {
2003
+ newMaterial.format = THREE__namespace.RGBAFormat;
2004
+ }
1950
2005
  newMaterial.needsUpdate = true;
1951
2006
  return newMaterial;
1952
2007
  }
1953
2008
  else {
1954
2009
  var params = {
1955
2010
  // side: material.side ? material.side : FrontSide,
1956
- name: name,
1957
- roughness: material.roughnessValue ? material.roughnessValue : 1,
1958
- metalness: material.metalnessValue ? material.metalnessValue : 0,
2011
+ roughness: material.roughnessValue !== undefined && material.roughnessValue !== null ? material.roughnessValue : 1,
2012
+ metalness: material.metalnessValue !== undefined && material.metalnessValue !== null ? material.metalnessValue : 0,
1959
2013
  envMapIntensity: material.envMapIntensity ? material.envMapIntensity : 0.01
1960
2014
  // wireframe: true,
1961
2015
  // opacity: 0.3,
@@ -1967,12 +2021,6 @@
1967
2021
  if (material.opacity) {
1968
2022
  params.opacity = material.opacity;
1969
2023
  }
1970
- if (material.transparency) {
1971
- params.opacity = material.transparency;
1972
- }
1973
- if (material.transmission) {
1974
- params.opacity = material.transmission;
1975
- }
1976
2024
  if (material.transparent) {
1977
2025
  params.transparent = material.transparent;
1978
2026
  }
@@ -2024,7 +2072,11 @@
2024
2072
  params.side = material.side;
2025
2073
  }
2026
2074
  var newMaterial = new THREE__namespace.MeshStandardMaterial(params);
2075
+ newMaterial.name = name;
2027
2076
  newMaterial.color.setRGB(1, 1, 1);
2077
+ if (newMaterial.name && (newMaterial.name === 'Fixed_Glass' || newMaterial.name === 'Default_Glass')) {
2078
+ newMaterial.format = THREE__namespace.RGBAFormat;
2079
+ }
2028
2080
  newMaterial.needsUpdate = true;
2029
2081
  return newMaterial;
2030
2082
  }
@@ -2313,38 +2365,47 @@
2313
2365
  };
2314
2366
  Builder.prototype.buildModelFromData = function (selections, decos, assetUrl, cdnUrl, schema) {
2315
2367
  return __awaiter(this, void 0, void 0, function () {
2316
- var build, e_2;
2368
+ var _this = this;
2317
2369
  return __generator(this, function (_a) {
2318
- switch (_a.label) {
2319
- case 0:
2320
- if (!this._scene) {
2321
- return [2 /*return*/];
2322
- }
2323
- _a.label = 1;
2324
- case 1:
2325
- _a.trys.push([1, 6, , 7]);
2326
- this._log('start build');
2327
- return [4 /*yield*/, this._downloadAsset(assetUrl, cdnUrl, schema)];
2328
- case 2:
2329
- _a.sent();
2330
- if (!(selections && selections.length > 1 && decos && decos.length > 0 && this._source)) return [3 /*break*/, 4];
2331
- this._selections = selections;
2332
- this._decos = decos;
2333
- this._linkSelectionsAndDecos();
2334
- this._preloadMaterials();
2335
- return [4 /*yield*/, this._build()];
2336
- case 3:
2337
- build = _a.sent();
2338
- this._cleanUp();
2339
- this._log('finish build');
2340
- return [2 /*return*/, build];
2341
- case 4: throw 'Unsufficient data provided!';
2342
- case 5: return [3 /*break*/, 7];
2343
- case 6:
2344
- e_2 = _a.sent();
2345
- throw e_2;
2346
- case 7: return [2 /*return*/];
2347
- }
2370
+ return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
2371
+ var build, e_2;
2372
+ return __generator(this, function (_a) {
2373
+ switch (_a.label) {
2374
+ case 0:
2375
+ if (!this._scene) {
2376
+ reject('no scene provided!');
2377
+ }
2378
+ _a.label = 1;
2379
+ case 1:
2380
+ _a.trys.push([1, 6, , 7]);
2381
+ this._log('start build');
2382
+ return [4 /*yield*/, this._downloadAsset(assetUrl, cdnUrl, schema)];
2383
+ case 2:
2384
+ _a.sent();
2385
+ if (!(selections && selections.length > 1 && decos && decos.length > 0 && this._source)) return [3 /*break*/, 4];
2386
+ this._selections = selections;
2387
+ this._decos = decos;
2388
+ this._linkSelectionsAndDecos();
2389
+ this._preloadMaterials();
2390
+ return [4 /*yield*/, this._build()];
2391
+ case 3:
2392
+ build = _a.sent();
2393
+ this._cleanUp();
2394
+ this._log('finish build');
2395
+ resolve(build);
2396
+ return [3 /*break*/, 5];
2397
+ case 4:
2398
+ reject('Unsufficient data provided!');
2399
+ _a.label = 5;
2400
+ case 5: return [3 /*break*/, 7];
2401
+ case 6:
2402
+ e_2 = _a.sent();
2403
+ reject(e_2);
2404
+ return [3 /*break*/, 7];
2405
+ case 7: return [2 /*return*/];
2406
+ }
2407
+ });
2408
+ }); })];
2348
2409
  });
2349
2410
  });
2350
2411
  };
@@ -2593,37 +2654,67 @@
2593
2654
  .filter(function (s) { return s.generic && s.decoNode.variation && !s.decoNode.type; })
2594
2655
  .map(function (value, index, array) {
2595
2656
  // find selection of variation
2596
- var sel = _this._selections.find(function (s) { return s.artNodeIdDeco === value.decoNode.variation.id; });
2657
+ var sel = _this._selections.find(function (s) { return s.artNodeIdDeco === value.decoNode.variation.parentId; });
2597
2658
  if (sel) {
2598
2659
  value.decoNode.variation.supplierArticleNr = sel.supplierArticleNr;
2599
2660
  }
2600
- value.decoNode.variation.materialId = value.hdecoGameObject;
2661
+ value.decoNode.variation.materialId = _this._getMaterialIdFromParent(value.node);
2601
2662
  return value.decoNode.variation;
2602
2663
  });
2603
- // const usedVariations: FurniturePartVariation[] = [];
2664
+ var selections = this._selections.slice();
2665
+ // commented out for the moment
2666
+ // globalVariations.forEach(g => {
2667
+ // const parentIdx = selections.findIndex(s => s.decoNode && s.decoNode.id === g.parentId);
2668
+ // if (parentIdx) { // remove parent selection
2669
+ // selections.splice(parentIdx, 1);
2670
+ // }
2671
+ // const idx = selections.findIndex(s => s.decoNode && s.decoNode.id === g.id);
2672
+ // if (idx) { // move generic variations to top
2673
+ // const selection = selections[idx];
2674
+ // selections.splice(idx, 1);
2675
+ // selections.unshift(selection);
2676
+ // }
2677
+ // });
2604
2678
  var globalVariationsRewrite = true;
2605
- var len = this._selections.length;
2679
+ var len = selections.length;
2606
2680
  var lastAdded;
2607
2681
  var lastAdjustable;
2608
2682
  var newPart = false;
2609
2683
  var previousPresLevel = -1;
2610
2684
  var positioning;
2685
+ var optionText;
2686
+ var selectionOfArticle = selections.find(function (s) { return s.nodeType === nodeType_enum.NodeType.Article; });
2687
+ var adjustableSelections = selections.filter(function (s) { return s.addAdjust === '2'; });
2688
+ var isArticleWithMaterial = adjustableSelections.length === 0 &&
2689
+ selectionOfArticle &&
2690
+ selectionOfArticle.gameObject &&
2691
+ selectionOfArticle.gameObject.length > 0;
2611
2692
  for (var i = 0; i < len; i++) {
2612
- var selection = this._selections[i];
2693
+ var selection = selections[i];
2613
2694
  if (selection.presentationLevel === 1) {
2614
2695
  positioning = selection.hdecoPositioning;
2696
+ optionText = selection.question;
2615
2697
  }
2616
2698
  if (selection.presentationLevel > previousPresLevel) {
2617
2699
  selection.hdecoPositioning = selection.hdecoPositioning || positioning;
2618
2700
  }
2619
2701
  if (selection.decoNode) {
2620
2702
  if (selection.decoNode.type === decoNodeType_enum.DecoNodeType.Variation) {
2703
+ var decoNode = selection.decoNode;
2704
+ decoNode.optionText = optionText;
2705
+ // find selection of variation and set materialId in case of multimaterial
2706
+ decoNode.materialId = this._getMaterialIdFromParent(decoNode.nodeId);
2621
2707
  if (lastAdded) {
2622
2708
  if (newPart) {
2623
- lastAdded.variations = [selection.decoNode];
2709
+ if (decoNode.materialId) {
2710
+ lastAdded.variations.push(decoNode);
2711
+ }
2712
+ else {
2713
+ lastAdded.variations = [decoNode];
2714
+ }
2624
2715
  }
2625
2716
  else {
2626
- lastAdded.variations.push(selection.decoNode);
2717
+ lastAdded.variations.push(decoNode);
2627
2718
  }
2628
2719
  newPart = false;
2629
2720
  }
@@ -2632,7 +2723,7 @@
2632
2723
  globalVariations.length = 0;
2633
2724
  globalVariationsRewrite = false;
2634
2725
  }
2635
- globalVariations.push(selection.decoNode);
2726
+ globalVariations.push(decoNode);
2636
2727
  }
2637
2728
  // const variation: FurniturePartVariation = new FurniturePartVariation();
2638
2729
  // variation.BrandId = selection.decoNode.brandId;
@@ -2640,19 +2731,14 @@
2640
2731
  // variation.MaterialId = (selection.decoNode as any).materialId;
2641
2732
  // variation.SupplierArticleNr = (selection.decoNode as any).supplierArticleNr;
2642
2733
  // usedVariations.push(variation);
2643
- // this._upsertFurniture(this.activeInstance, {
2644
- // Variation: selection.decoNode.brandId,
2645
- // VariationDescription: selection.decoNode.gameObjectName,
2646
- // SupplierArticleNr: (selection.decoNode as any).supplierArticleNr
2647
- // });
2648
2734
  }
2649
- else if (selection.decoNode.type === decoNodeType_enum.DecoNodeType.Part &&
2735
+ else if ((selection.decoNode.type === decoNodeType_enum.DecoNodeType.Part &&
2650
2736
  typeof selection.decoNode.gameObjectName === 'string' &&
2651
- selection.decoNode.gameObjectName.length) {
2652
- if (selection.decoNode.kind === decoNodeKind_enum.DecoNodeKind.Adjustable) {
2737
+ selection.decoNode.gameObjectName.length) || (isArticleWithMaterial)) {
2738
+ if (selection.decoNode.kind === decoNodeKind_enum.DecoNodeKind.Adjustable || (isArticleWithMaterial)) {
2653
2739
  selection.variations = globalVariations;
2654
2740
  this._adjustables.push(selection);
2655
- if (!lastAdded || lastAdded.nodeId !== selection.nodeId) {
2741
+ if (!lastAdded || (lastAdded.nodeId !== selection.nodeId || lastAdded.node !== selection.node)) {
2656
2742
  newPart = true;
2657
2743
  }
2658
2744
  lastAdded = selection;
@@ -2664,7 +2750,7 @@
2664
2750
  lastAdjustable.addables.push(selection);
2665
2751
  }
2666
2752
  this._addables.push(selection);
2667
- if (!lastAdded || lastAdded.nodeId !== selection.nodeId) {
2753
+ if (!lastAdded || (lastAdded.nodeId !== selection.nodeId || lastAdded.node !== selection.node)) {
2668
2754
  newPart = true;
2669
2755
  }
2670
2756
  lastAdded = selection;
@@ -2676,14 +2762,36 @@
2676
2762
  // this._upsertFurniture(this.activeInstance,
2677
2763
  // {Variations: usedVariations});
2678
2764
  };
2765
+ /**
2766
+ * Returns the materialId of the parent up the tree until presentionlevel 1 is reached
2767
+ * @param id
2768
+ * @private
2769
+ */
2770
+ Builder.prototype._getMaterialIdFromParent = function (id) {
2771
+ var idx = this._selections.findIndex(function (s) { return s.node === id; });
2772
+ var currentLevel = 999;
2773
+ if (idx > -1) {
2774
+ for (var i = idx; i > 0; i--) {
2775
+ var selection = this._selections[i];
2776
+ if (selection.presentationLevel >= currentLevel) {
2777
+ break;
2778
+ }
2779
+ currentLevel = selection.presentationLevel;
2780
+ if (selection.hdecoGameObject) {
2781
+ return selection.hdecoGameObject;
2782
+ }
2783
+ }
2784
+ }
2785
+ return undefined;
2786
+ };
2679
2787
  Builder.prototype._createAdjustable = function (parent, adj) {
2680
- var obj = this._source ? this._source.getObjectByName(adj.decoNode.gameObjectName) : null;
2788
+ var obj = this._source ? this._source.getObjectByName(adj.decoNode.gameObjectName || adj.gameObject) : null;
2681
2789
  if (!obj) {
2682
2790
  // in case of glb files, the importer removes dots from names
2683
2791
  var name = adj.decoNode.gameObjectName.replace(/[.]/g, '');
2684
2792
  obj = this._source ? this._source.getObjectByName(name) : null;
2685
2793
  if (!obj) {
2686
- // console.warn(`No object with name ${adj.decoNode.gameObjectName} found!`);
2794
+ console.warn("No object with name " + adj.decoNode.gameObjectName + " found!");
2687
2795
  return null;
2688
2796
  }
2689
2797
  }
@@ -2691,11 +2799,13 @@
2691
2799
  adjustable.name = this._createUniqueName(parent, obj);
2692
2800
  adjustable.userData.selection = adj;
2693
2801
  adjustable.position.set(0, 0, 0);
2694
- adjustable.visible = true;
2802
+ adjustable.traverse(function (c) {
2803
+ c.visible = !c.name.toLowerCase().startsWith('c_');
2804
+ });
2695
2805
  parent.add(adjustable);
2696
2806
  // the object being added to the customFloorGroup is being recreated so we loose the reference
2697
2807
  // therefor we need to retrieve the created object again
2698
- // adjustable = parent.getObjectByName(adjustable.name);
2808
+ adjustable = parent.getObjectByName(adjustable.name);
2699
2809
  this._placedAdjustables.push(adjustable);
2700
2810
  return adjustable;
2701
2811
  };