@colijnit/configurator 259.1.2 → 259.1.4

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.
Files changed (33) hide show
  1. package/app/components/selections/selections.component.d.ts +1 -1
  2. package/bundles/colijnit-configurator.umd.js +225 -135
  3. package/bundles/colijnit-configurator.umd.js.map +1 -1
  4. package/colijnit-configurator.metadata.json +1 -1
  5. package/esm2015/app/builder.js +81 -43
  6. package/esm2015/app/components/selections/selections.component.js +2 -2
  7. package/esm2015/app/services/configurator.service.js +15 -11
  8. package/esm2015/app/utils/object.utils.js +14 -12
  9. package/esm2015/helper/variation-helper.js +5 -9
  10. package/esm2015/utils/base-utils.js +9 -0
  11. package/esm2015/utils/image.utils.js +27 -29
  12. package/esm2015/utils/scene-utils.js +38 -15
  13. package/esm2015/utils/threed.utils.js +14 -12
  14. package/esm2015/utils/variation-utils.js +1 -1
  15. package/fesm2015/colijnit-configurator.js +196 -126
  16. package/fesm2015/colijnit-configurator.js.map +1 -1
  17. package/helper/variation-helper.d.ts +2 -3
  18. package/package.json +4 -4
  19. package/utils/base-utils.d.ts +4 -0
  20. package/utils/image.utils.d.ts +2 -1
  21. package/utils/threed.utils.d.ts +2 -2
  22. package/colijnit-configurator-259.1.1.tgz +0 -0
  23. package/configurator/index.html +0 -14
  24. package/configurator/main.js +0 -3555
  25. package/configurator/main.js.map +0 -1
  26. package/configurator/polyfills.js +0 -5683
  27. package/configurator/polyfills.js.map +0 -1
  28. package/configurator/runtime.js +0 -149
  29. package/configurator/runtime.js.map +0 -1
  30. package/configurator/styles.css +0 -48
  31. package/configurator/styles.css.map +0 -1
  32. package/configurator/vendor.js +0 -210213
  33. package/configurator/vendor.js.map +0 -1
@@ -599,8 +599,9 @@
599
599
  objs.forEach(function (o) { return ObjectUtils$1.DisposeObject(o); });
600
600
  this._objectCache.clear();
601
601
  };
602
- ThreedUtils.prototype.download3DSource = function (fileName, assetPath) {
602
+ ThreedUtils.prototype.download3DSource = function (fileName, setVisibleFalse) {
603
603
  var _this = this;
604
+ if (setVisibleFalse === void 0) { setVisibleFalse = true; }
604
605
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
605
606
  var lookupFileName;
606
607
  var _this = this;
@@ -611,7 +612,7 @@
611
612
  resolve(this._objectCache.get(lookupFileName));
612
613
  return [2 /*return*/];
613
614
  }
614
- this.loadGlbSource(lookupFileName)
615
+ this.loadGlbSource(lookupFileName, setVisibleFalse)
615
616
  .then(function (obj) {
616
617
  _this._objectCache.set(lookupFileName, obj);
617
618
  resolve(obj);
@@ -711,7 +712,8 @@
711
712
  });
712
713
  });
713
714
  };
714
- ThreedUtils.prototype.loadGlbSource = function (file) {
715
+ ThreedUtils.prototype.loadGlbSource = function (file, setVisibleFalse) {
716
+ if (setVisibleFalse === void 0) { setVisibleFalse = true; }
715
717
  return __awaiter(this, void 0, void 0, function () {
716
718
  var obj, children, name, parent;
717
719
  return __generator(this, function (_a) {
@@ -720,15 +722,17 @@
720
722
  case 1:
721
723
  obj = _a.sent();
722
724
  if (obj) {
723
- obj.children = obj.children.filter(function (c) { return !(c instanceof THREE__namespace.Camera); });
725
+ obj.children = obj.children.filter(function (c) { return !(c instanceof THREE__namespace.Camera || (c.constructor.name && c.constructor.name.toLowerCase().indexOf('camera') > -1)); });
724
726
  obj.children.sort(function (a, b) { return a['name'] < b['name'] ? 1 : -1; });
725
727
  obj.children.forEach(function (c) {
726
728
  c.traverse(function (t) {
727
729
  t.visible = !t.name.toLowerCase().startsWith('c_');
728
730
  });
729
- c.visible = false;
731
+ if (setVisibleFalse) {
732
+ c.visible = false;
733
+ }
730
734
  });
731
- if (obj.children.length === 1 && obj.children[0] instanceof THREE__namespace.Group) { // flatten children
735
+ if (obj.children.length === 1 && (obj.children[0] instanceof THREE__namespace.Group || obj.children[0].constructor.name === 'Group')) { // flatten children
732
736
  children = obj.children[0].children.slice();
733
737
  name = obj.children[0].name;
734
738
  obj.children.length = 0;
@@ -766,11 +770,11 @@
766
770
  if (cleanUp === void 0) { cleanUp = true; }
767
771
  var obj = new THREE__namespace.Object3D();
768
772
  object.children.forEach(function (c) {
769
- if (!(c instanceof THREE__namespace.Camera)) {
770
- if (cleanUp && c instanceof THREE__namespace.Group || (c.children.length === 1 && c.children[0] instanceof THREE__namespace.Group)) {
773
+ if (!(c instanceof THREE__namespace.Camera || (c.constructor.name && c.constructor.name.toLowerCase().indexOf('camera') > -1))) {
774
+ if (cleanUp && (c instanceof THREE__namespace.Group || c.constructor.name === 'Group') || (c.children.length === 1 && (c.children[0] instanceof THREE__namespace.Group || c.children[0].constructor.name === 'Group'))) {
771
775
  _this._addGroupChildrenToObject(c, obj);
772
776
  }
773
- else if ((cleanUp && !(c instanceof THREE__namespace.Mesh)) || (!(c instanceof THREE__namespace.Mesh) && !c.name && c.children.length > 0)) {
777
+ else if ((cleanUp && !(c instanceof THREE__namespace.Mesh || c.constructor.name === 'Mesh')) || (!(c instanceof THREE__namespace.Mesh || c.constructor.name === 'Mesh') && !c.name && c.children.length > 0)) {
774
778
  c.children.forEach(function (child) {
775
779
  child.translateY(c.position.y);
776
780
  });
@@ -806,7 +810,7 @@
806
810
  var _this = this;
807
811
  if (cleanUp === void 0) { cleanUp = true; }
808
812
  group.children.forEach(function (gc) {
809
- if (cleanUp && gc instanceof THREE__namespace.Group) {
813
+ if (cleanUp && (gc instanceof THREE__namespace.Group || gc.constructor.name === 'Group')) {
810
814
  _this._addGroupChildrenToObject(gc, obj);
811
815
  }
812
816
  else {
@@ -820,7 +824,7 @@
820
824
  ThreedUtils.prototype._iterateChildren = function (children, callback) {
821
825
  for (var i = 0; i < children.length; i++) {
822
826
  var child = children[i];
823
- if (child instanceof THREE__namespace.Mesh) {
827
+ if (child instanceof THREE__namespace.Mesh || child.constructor.name === 'Mesh') {
824
828
  callback(child);
825
829
  }
826
830
  else {
@@ -959,6 +963,9 @@
959
963
  var con2Name = (con2.constructor.name === 'Mesh' || con2.constructor.name === 'Object3D') ? con2.name : con2.connector;
960
964
  var sameParent = (con1.constructor.name === 'Mesh' || con1.constructor.name === 'Object3D') &&
961
965
  (con2.constructor.name === 'Mesh' || con2.constructor.name === 'Object3D') ? con1.parent === con2.parent : false;
966
+ if (!con1Name || !con2Name) {
967
+ return false;
968
+ }
962
969
  var parts1 = con1Name.toUpperCase().split('_'), parts2 = con2Name.toUpperCase().split('_');
963
970
  if (parts1.length >= 3 && parts2.length >= 3 && !sameParent) {
964
971
  var connectable = parts1[0] === 'C' && parts2[0] === 'C' &&
@@ -984,8 +991,8 @@
984
991
  if (!scene || !parent) {
985
992
  return false;
986
993
  }
987
- con1['connectedTo'] = con2.parent.name;
988
- con2['connectedTo'] = con1.parent.name;
994
+ con1['connectedTo'] = con2 && con2.parent ? con2.parent.name : '';
995
+ con2['connectedTo'] = con1 && con1.parent ? con1.parent.name : '';
989
996
  var motherRotation = new THREE__namespace.Euler(0, 0, 0);
990
997
  var motherPosition = new THREE__namespace.Vector3(0, 0, 0);
991
998
  parent.updateMatrixWorld();
@@ -995,33 +1002,53 @@
995
1002
  parent.position.set(0, 0, 0);
996
1003
  scene.updateMatrixWorld(true);
997
1004
  var con1Quat = new THREE__namespace.Quaternion();
998
- con1.getWorldQuaternion(con1Quat);
1005
+ if (con1) {
1006
+ con1.getWorldQuaternion(con1Quat);
1007
+ }
999
1008
  var con2Quat = new THREE__namespace.Quaternion();
1000
- con2.getWorldQuaternion(con2Quat);
1009
+ if (con2) {
1010
+ con2.getWorldQuaternion(con2Quat);
1011
+ }
1001
1012
  var con1QuatParent = new THREE__namespace.Quaternion();
1002
- con1.parent.getWorldQuaternion(con1QuatParent);
1013
+ if (con1 && con1.parent) {
1014
+ con1.parent.getWorldQuaternion(con1QuatParent);
1015
+ }
1003
1016
  var con2QuatParent = new THREE__namespace.Quaternion();
1004
- con2.parent.getWorldQuaternion(con2QuatParent);
1017
+ if (con2 && con2.parent) {
1018
+ con2.parent.getWorldQuaternion(con2QuatParent);
1019
+ }
1005
1020
  var rotation = new THREE__namespace.Quaternion().multiplyQuaternions(con1Quat.invert(), con2Quat).multiply(new THREE__namespace.Quaternion().multiplyQuaternions(con1QuatParent, con1QuatParent));
1006
- con2.parent.quaternion.copy(rotation);
1021
+ if (con2 && con2.parent) {
1022
+ con2.parent.quaternion.copy(rotation);
1023
+ }
1007
1024
  // Update because the matrix has been tempered with
1008
1025
  scene.updateMatrixWorld(true);
1009
1026
  // Move the connectors towards eachother
1010
1027
  var con1Pos = new THREE__namespace.Vector3();
1011
- con1.getWorldPosition(con1Pos);
1028
+ if (con1) {
1029
+ con1.getWorldPosition(con1Pos);
1030
+ }
1012
1031
  var con2Pos = new THREE__namespace.Vector3();
1013
- con2.getWorldPosition(con2Pos);
1032
+ if (con2) {
1033
+ con2.getWorldPosition(con2Pos);
1034
+ }
1014
1035
  var move = con1Pos.sub(con2Pos);
1015
- con2.parent.position.x += move.x;
1016
- con2.parent.position.y += move.y;
1017
- con2.parent.position.z += move.z;
1036
+ if (con2 && con2.parent) {
1037
+ con2.parent.position.x += move.x;
1038
+ con2.parent.position.y += move.y;
1039
+ con2.parent.position.z += move.z;
1040
+ }
1018
1041
  // reset parent's objects rotation and position
1019
1042
  parent.rotation.copy(motherRotation);
1020
1043
  parent.position.copy(motherPosition);
1021
1044
  scene.updateMatrixWorld(true);
1022
1045
  // Set the connected flag
1023
- con1['connected'] = true;
1024
- con2['connected'] = true;
1046
+ if (con1) {
1047
+ con1['connected'] = true;
1048
+ }
1049
+ if (con2) {
1050
+ con2['connected'] = true;
1051
+ }
1025
1052
  return true;
1026
1053
  };
1027
1054
  return SceneUtils;
@@ -1095,52 +1122,66 @@
1095
1122
  return Material;
1096
1123
  }());
1097
1124
 
1125
+ var BaseUtils = /** @class */ (function () {
1126
+ function BaseUtils() {
1127
+ }
1128
+ BaseUtils.prototype.log = function (message) {
1129
+ if (this.debug) {
1130
+ this.debug(message);
1131
+ console.log(new Date(), message);
1132
+ }
1133
+ };
1134
+ return BaseUtils;
1135
+ }());
1136
+
1098
1137
  // @dynamic
1099
- var ImageUtils = /** @class */ (function () {
1138
+ var ImageUtils = /** @class */ (function (_super) {
1139
+ __extends(ImageUtils, _super);
1100
1140
  function ImageUtils() {
1141
+ return _super !== null && _super.apply(this, arguments) || this;
1101
1142
  }
1102
1143
  ImageUtils.CreateTextureFromBase64 = function (id, base64, material, defaultFlip) {
1103
- var _this = this;
1104
1144
  if (defaultFlip === void 0) { defaultFlip = false; }
1105
- return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
1106
- var _a, loader;
1107
- return __generator(this, function (_b) {
1108
- switch (_b.label) {
1145
+ var _a, _b;
1146
+ return __awaiter(this, void 0, void 0, function () {
1147
+ var texture_1, loader_1, texture, err_1;
1148
+ return __generator(this, function (_c) {
1149
+ switch (_c.label) {
1109
1150
  case 0:
1110
- if (!ImageUtils.textures.has(id)) return [3 /*break*/, 1];
1111
- resolve(ImageUtils.textures.get(id));
1112
- return [3 /*break*/, 5];
1151
+ if (ImageUtils.textures.has(id)) {
1152
+ return [2 /*return*/, ImageUtils.textures.get(id)];
1153
+ }
1154
+ _c.label = 1;
1113
1155
  case 1:
1114
- if (!!base64) return [3 /*break*/, 2];
1115
- resolve(new THREE__namespace.Texture());
1116
- return [3 /*break*/, 5];
1156
+ _c.trys.push([1, 5, , 6]);
1157
+ if (!window.textureLoader) return [3 /*break*/, 3];
1158
+ return [4 /*yield*/, window.textureLoader(base64, material)];
1117
1159
  case 2:
1118
- if (!window.hasOwnProperty('textureLoader')) return [3 /*break*/, 4];
1119
- _a = resolve;
1120
- return [4 /*yield*/, window.textureLoader(base64)];
1160
+ texture_1 = _c.sent();
1161
+ ImageUtils.textures.set(id, texture_1);
1162
+ return [2 /*return*/, texture_1];
1121
1163
  case 3:
1122
- _a.apply(void 0, [_b.sent()]);
1123
- return [3 /*break*/, 5];
1164
+ loader_1 = new THREE__namespace.TextureLoader();
1165
+ return [4 /*yield*/, new Promise(function (resolve, reject) {
1166
+ loader_1.load(base64, resolve, undefined, function (err) { return reject(err); });
1167
+ })];
1124
1168
  case 4:
1125
- loader = new THREE__namespace.TextureLoader();
1126
- loader.load(base64, function (texture) {
1127
- texture.anisotropy = 16;
1128
- texture.wrapS = THREE__namespace.RepeatWrapping;
1129
- texture.wrapT = THREE__namespace.RepeatWrapping;
1130
- texture.repeat = new THREE__namespace.Vector2(material ? material.repeatX : 1, material ? material.repeatY : 1);
1131
- texture.flipY = defaultFlip;
1132
- texture.needsUpdate = true;
1133
- ImageUtils.textures.set(id, texture);
1134
- resolve(texture);
1135
- }, function () {
1136
- }, function () {
1137
- resolve(new THREE__namespace.Texture());
1138
- });
1139
- _b.label = 5;
1140
- case 5: return [2 /*return*/];
1169
+ texture = _c.sent();
1170
+ texture.anisotropy = 16;
1171
+ texture.wrapS = THREE__namespace.RepeatWrapping;
1172
+ texture.wrapT = THREE__namespace.RepeatWrapping;
1173
+ texture.repeat = new THREE__namespace.Vector2((_a = material === null || material === void 0 ? void 0 : material.repeatX) !== null && _a !== void 0 ? _a : 1, (_b = material === null || material === void 0 ? void 0 : material.repeatY) !== null && _b !== void 0 ? _b : 1);
1174
+ texture.flipY = defaultFlip;
1175
+ texture.needsUpdate = true;
1176
+ ImageUtils.textures.set(id, texture);
1177
+ return [2 /*return*/, texture];
1178
+ case 5:
1179
+ err_1 = _c.sent();
1180
+ return [2 /*return*/, null];
1181
+ case 6: return [2 /*return*/];
1141
1182
  }
1142
1183
  });
1143
- }); });
1184
+ });
1144
1185
  };
1145
1186
  ImageUtils.getDocBodyWithMimeTypeDefinition = function (fileName, documentBody) {
1146
1187
  if (documentBody === null) {
@@ -1171,7 +1212,7 @@
1171
1212
  ImageUtils.textures.clear();
1172
1213
  };
1173
1214
  return ImageUtils;
1174
- }());
1215
+ }(BaseUtils));
1175
1216
  ImageUtils.textures = new Map();
1176
1217
 
1177
1218
  var FurnitureMaterial = /** @class */ (function (_super) {
@@ -1857,10 +1898,13 @@
1857
1898
  }());
1858
1899
  VariationUtils.MaterialCache = new Map();
1859
1900
 
1860
- var VariationHelper = /** @class */ (function () {
1901
+ var VariationHelper = /** @class */ (function (_super) {
1902
+ __extends(VariationHelper, _super);
1861
1903
  function VariationHelper() {
1862
- this._variations = [];
1863
- this._lastKnownVariations = new Map();
1904
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
1905
+ _this._variations = [];
1906
+ _this._lastKnownVariations = new Map();
1907
+ return _this;
1864
1908
  }
1865
1909
  VariationHelper.prototype.clearCache = function () {
1866
1910
  var variationMap = Array.from(this._lastKnownVariations.values());
@@ -2004,7 +2048,7 @@
2004
2048
  case 4: return [3 /*break*/, 6];
2005
2049
  case 5:
2006
2050
  e_2 = _a.sent();
2007
- this._log(e_2.message);
2051
+ this.log(e_2.message);
2008
2052
  return [3 /*break*/, 6];
2009
2053
  case 6: return [2 /*return*/];
2010
2054
  }
@@ -2444,14 +2488,8 @@
2444
2488
  }
2445
2489
  return new THREE.Color();
2446
2490
  };
2447
- VariationHelper.prototype._log = function (message) {
2448
- if (this.debug) {
2449
- this.debug(message);
2450
- console.log(new Date(), message);
2451
- }
2452
- };
2453
2491
  return VariationHelper;
2454
- }());
2492
+ }(BaseUtils));
2455
2493
 
2456
2494
  var ConfiguratorService = /** @class */ (function () {
2457
2495
  function ConfiguratorService() {
@@ -2512,10 +2550,12 @@
2512
2550
  case 0: return [4 /*yield*/, this._configuratorApi.getSelections(showLoader)];
2513
2551
  case 1:
2514
2552
  selections = _a.sent();
2515
- selections.resultObjects.filter(function (s) {
2516
- (isNill_function.isNill(s.hierarchicalPublicationCode) || ((s.hierarchicalPublicationCode & publicationCode) > 0)) && ((s.nodeType === nodeType_enum.NodeType.Question && (((s.questionPublicationCode & publicationCode) > 0) || isNill_function.isNill(s.questionPublicationCode))) ||
2517
- (s.nodeType === nodeType_enum.NodeType.Answer && (((s.answerPublicationCode & publicationCode) > 0) || isNill_function.isNill(s.answerPublicationCode))));
2518
- });
2553
+ if (selections && selections.resultObjects) {
2554
+ selections.resultObjects.filter(function (s) {
2555
+ (isNill_function.isNill(s.hierarchicalPublicationCode) || ((s.hierarchicalPublicationCode & publicationCode) > 0)) && ((s.nodeType === nodeType_enum.NodeType.Question && (((s.questionPublicationCode & publicationCode) > 0) || isNill_function.isNill(s.questionPublicationCode))) ||
2556
+ (s.nodeType === nodeType_enum.NodeType.Answer && (((s.answerPublicationCode & publicationCode) > 0) || isNill_function.isNill(s.answerPublicationCode))));
2557
+ });
2558
+ }
2519
2559
  return [2 /*return*/, selections];
2520
2560
  }
2521
2561
  });
@@ -2542,11 +2582,13 @@
2542
2582
  case 0: return [4 /*yield*/, this._configuratorApi.getQuestionAndAnswers(showLoader)];
2543
2583
  case 1:
2544
2584
  questionAndAnswers = _a.sent();
2545
- questionAndAnswers.answers.filter(function (answer) {
2546
- (notNill_function.notNill(answer.hierarchicalPublicationCode) && (answer.hierarchicalPublicationCode & publicationCode) === 0) ||
2547
- (answer.type === nodeType_enum.NodeType.Question && (answer.questionPublicationCode & publicationCode) === 0 && notNill_function.notNill(answer.questionPublicationCode)) ||
2548
- (answer.type === nodeType_enum.NodeType.Answer && (answer.publicationCode & publicationCode) === 0 && notNill_function.notNill(answer.publicationCode));
2549
- });
2585
+ if (questionAndAnswers && questionAndAnswers.answers) {
2586
+ questionAndAnswers.answers.filter(function (answer) {
2587
+ (notNill_function.notNill(answer.hierarchicalPublicationCode) && (answer.hierarchicalPublicationCode & publicationCode) === 0) ||
2588
+ (answer.type === nodeType_enum.NodeType.Question && (answer.questionPublicationCode & publicationCode) === 0 && notNill_function.notNill(answer.questionPublicationCode)) ||
2589
+ (answer.type === nodeType_enum.NodeType.Answer && (answer.publicationCode & publicationCode) === 0 && notNill_function.notNill(answer.publicationCode));
2590
+ });
2591
+ }
2550
2592
  return [2 /*return*/, questionAndAnswers];
2551
2593
  }
2552
2594
  });
@@ -2595,18 +2637,20 @@
2595
2637
  function ObjectUtils() {
2596
2638
  }
2597
2639
  ObjectUtils.DisposeNode = function (node) {
2598
- node.traverse(function (obj) {
2599
- if (obj instanceof THREE.Mesh) {
2600
- if (obj.geometry) {
2601
- obj.geometry.dispose();
2640
+ if (node) {
2641
+ node.traverse(function (obj) {
2642
+ if (obj instanceof THREE.Mesh) {
2643
+ if (obj.geometry) {
2644
+ obj.geometry.dispose();
2645
+ }
2646
+ ObjectUtils.DisposeMaterial(obj.material);
2602
2647
  }
2603
- ObjectUtils.DisposeMaterial(obj.material);
2604
- }
2605
- if (typeof obj.dispose === 'function') {
2606
- // @ts-ignore
2607
- obj.dispose();
2608
- }
2609
- });
2648
+ if (typeof obj.dispose === 'function') {
2649
+ // @ts-ignore
2650
+ obj.dispose();
2651
+ }
2652
+ });
2653
+ }
2610
2654
  };
2611
2655
  ObjectUtils.DisposeMaterial = function (material) {
2612
2656
  var _this = this;
@@ -2746,7 +2790,7 @@
2746
2790
  var _this = this;
2747
2791
  return __generator(this, function (_a) {
2748
2792
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
2749
- var build, e_2;
2793
+ var build, e_2, e_3;
2750
2794
  return __generator(this, function (_a) {
2751
2795
  switch (_a.label) {
2752
2796
  case 0:
@@ -2755,12 +2799,19 @@
2755
2799
  }
2756
2800
  _a.label = 1;
2757
2801
  case 1:
2758
- _a.trys.push([1, 6, , 7]);
2759
- this._log('start build');
2760
- return [4 /*yield*/, this._downloadAsset(assetUrl, cdnUrl, schema)];
2802
+ _a.trys.push([1, 14, , 15]);
2803
+ this._log('start build', true);
2804
+ return [4 /*yield*/, this._downloadAsset(assetUrl, cdnUrl, schema, selections && selections.length > 1 && decos && decos.length > 0)];
2761
2805
  case 2:
2762
2806
  _a.sent();
2763
- if (!(selections && selections.length > 1 && decos && decos.length > 0 && this._source)) return [3 /*break*/, 4];
2807
+ _a.label = 3;
2808
+ case 3:
2809
+ _a.trys.push([3, , 12, 13]);
2810
+ if (!this._source) return [3 /*break*/, 10];
2811
+ _a.label = 4;
2812
+ case 4:
2813
+ _a.trys.push([4, 8, , 9]);
2814
+ if (!(selections && selections.length > 1 && decos && decos.length > 0)) return [3 /*break*/, 6];
2764
2815
  this._reset();
2765
2816
  this._selections = selections;
2766
2817
  this._decos = decos;
@@ -2768,21 +2819,41 @@
2768
2819
  this._prepareTheSelections();
2769
2820
  this._preloadMaterials();
2770
2821
  return [4 /*yield*/, this._build()];
2771
- case 3:
2822
+ case 5:
2772
2823
  build = _a.sent();
2773
- this._cleanUp();
2774
- this._log('finish build');
2775
2824
  resolve(build);
2776
- return [3 /*break*/, 5];
2777
- case 4:
2778
- reject('Unsufficient data provided!');
2779
- _a.label = 5;
2780
- case 5: return [3 /*break*/, 7];
2825
+ return [3 /*break*/, 7];
2781
2826
  case 6:
2827
+ resolve(this._source); // just return the source for simplicity
2828
+ _a.label = 7;
2829
+ case 7: return [3 /*break*/, 9];
2830
+ case 8:
2782
2831
  e_2 = _a.sent();
2783
- reject(e_2);
2784
- return [3 /*break*/, 7];
2785
- case 7: return [2 /*return*/];
2832
+ reject(e_2.message);
2833
+ return [3 /*break*/, 9];
2834
+ case 9:
2835
+ {
2836
+ }
2837
+ return [3 /*break*/, 11];
2838
+ case 10:
2839
+ if (assetUrl) {
2840
+ reject("Error downloading source: " + assetUrl);
2841
+ }
2842
+ else {
2843
+ reject('No 3D source provided!');
2844
+ }
2845
+ _a.label = 11;
2846
+ case 11: return [3 /*break*/, 13];
2847
+ case 12:
2848
+ this._cleanUp();
2849
+ this._log('finish build', true);
2850
+ return [7 /*endfinally*/];
2851
+ case 13: return [3 /*break*/, 15];
2852
+ case 14:
2853
+ e_3 = _a.sent();
2854
+ reject(e_3);
2855
+ return [3 /*break*/, 15];
2856
+ case 15: return [2 /*return*/];
2786
2857
  }
2787
2858
  });
2788
2859
  }); })];
@@ -2819,8 +2890,8 @@
2819
2890
  case 0: return [4 /*yield*/, this._configuratorService.getQuestionAndAnswers(false, publicationCode)];
2820
2891
  case 1:
2821
2892
  questionsAndAnswers = _a.sent();
2822
- this._answers = questionsAndAnswers.answers;
2823
- this.answersReceived.next(questionsAndAnswers.answers);
2893
+ this._answers = questionsAndAnswers && questionsAndAnswers.answers ? questionsAndAnswers.answers : [];
2894
+ this.answersReceived.next(this._answers);
2824
2895
  return [2 /*return*/];
2825
2896
  }
2826
2897
  });
@@ -2836,7 +2907,7 @@
2836
2907
  return [4 /*yield*/, this.getQuestionAndAnswers()];
2837
2908
  case 2:
2838
2909
  _a.sent();
2839
- if (this._answers.length === 0) {
2910
+ if (this._answers && this._answers.length === 0) {
2840
2911
  this._build();
2841
2912
  }
2842
2913
  return [2 /*return*/];
@@ -2893,9 +2964,12 @@
2893
2964
  }
2894
2965
  };
2895
2966
  Builder.prototype._preloadMaterials = function () {
2896
- this._variationHelper.preloadVariations(this._decos
2897
- .filter(function (d) { return d.gameObjectName && d.type === decoNodeType_enum.DecoNodeType.Variation; })
2898
- .map(function (d) { return d.gameObjectName; }));
2967
+ if (this._decos && this._decos.length) {
2968
+ var materials = __spreadArray([], __read(new Set(this._decos
2969
+ .filter(function (d) { return d.gameObjectName && d.type === decoNodeType_enum.DecoNodeType.Variation; })
2970
+ .map(function (d) { return d.gameObjectName; }))));
2971
+ this._variationHelper.preloadVariations(materials);
2972
+ }
2899
2973
  };
2900
2974
  Builder.prototype._setInstanceId = function (sku, instanceId, goodId) {
2901
2975
  return __awaiter(this, void 0, void 0, function () {
@@ -2959,14 +3033,15 @@
2959
3033
  });
2960
3034
  });
2961
3035
  };
2962
- Builder.prototype._downloadAsset = function (assetUrl, cdnUrl, schema) {
3036
+ Builder.prototype._downloadAsset = function (assetUrl, cdnUrl, schema, setVisibleFalse) {
3037
+ if (setVisibleFalse === void 0) { setVisibleFalse = true; }
2963
3038
  return __awaiter(this, void 0, void 0, function () {
2964
3039
  var _a;
2965
3040
  return __generator(this, function (_b) {
2966
3041
  switch (_b.label) {
2967
3042
  case 0:
2968
3043
  _a = this;
2969
- return [4 /*yield*/, this._threedUtils.download3DSource(assetUrl, cdnUrl)
3044
+ return [4 /*yield*/, this._threedUtils.download3DSource(assetUrl, setVisibleFalse)
2970
3045
  .catch(function (error) {
2971
3046
  throw error;
2972
3047
  })];
@@ -3041,6 +3116,9 @@
3041
3116
  };
3042
3117
  Builder.prototype._prepareTheSelections = function () {
3043
3118
  var _this = this;
3119
+ if (!this._selections || !this._selections.length) {
3120
+ return;
3121
+ }
3044
3122
  var selections = this._selections.slice();
3045
3123
  var selectionOfArticle = selections.find(function (s) { return s.nodeType === nodeType_enum.NodeType.Article; });
3046
3124
  var adjustableSelections = selections.filter(function (s) { return s.addAdjust === '2'; });
@@ -3170,17 +3248,19 @@
3170
3248
  * @private
3171
3249
  */
3172
3250
  Builder.prototype._getMaterialIdFromParent = function (id) {
3173
- var idx = this._selections.findIndex(function (s) { return s.node === id; });
3174
- var currentLevel = 999;
3175
- if (idx > -1) {
3176
- for (var i = idx; i > 0; i--) {
3177
- var selection = this._selections[i];
3178
- if (selection.presentationLevel >= currentLevel) {
3179
- break;
3180
- }
3181
- currentLevel = selection.presentationLevel;
3182
- if (selection.hdecoGameObject) {
3183
- return selection.hdecoGameObject;
3251
+ if (this._selections) {
3252
+ var idx = this._selections.findIndex(function (s) { return s.node === id; });
3253
+ var currentLevel = 999;
3254
+ if (idx > -1) {
3255
+ for (var i = idx; i > 0; i--) {
3256
+ var selection = this._selections[i];
3257
+ if (selection.presentationLevel >= currentLevel) {
3258
+ break;
3259
+ }
3260
+ currentLevel = selection.presentationLevel;
3261
+ if (selection.hdecoGameObject) {
3262
+ return selection.hdecoGameObject;
3263
+ }
3184
3264
  }
3185
3265
  }
3186
3266
  }
@@ -3268,7 +3348,7 @@
3268
3348
  case 0: return [4 /*yield*/, this._configuratorService.getGoodIdFromSku(sku, false)];
3269
3349
  case 1:
3270
3350
  response = _a.sent();
3271
- if (response.validationResult.success && response.resultObject) {
3351
+ if (response && response.validationResult && response.validationResult.success && response.resultObject) {
3272
3352
  return [2 /*return*/, response.resultObject];
3273
3353
  }
3274
3354
  return [2 /*return*/];
@@ -3297,7 +3377,7 @@
3297
3377
  case 2: return [4 /*yield*/, this._configuratorService.getArticleQuickSel(goodId, false)];
3298
3378
  case 3:
3299
3379
  articleResponse = _a.sent();
3300
- if (articleResponse.validationResult.success && articleResponse.resultObject) {
3380
+ if (articleResponse && articleResponse.validationResult && articleResponse.validationResult.success && articleResponse.resultObject) {
3301
3381
  if (articleResponse.resultObject.hasOwnProperty('oArticle')) {
3302
3382
  obj = Array.isArray(articleResponse.resultObject['oArticle']) ? articleResponse.resultObject['oArticle'][0] : articleResponse.resultObject['oArticle'];
3303
3383
  article$1 = this._boFactory.makeWithRawBackendData(article.Article, obj);
@@ -3323,7 +3403,7 @@
3323
3403
  return [4 /*yield*/, this._configuratorService.getSelections(false, publicationCode)];
3324
3404
  case 1:
3325
3405
  selectionResponse = _a.sent();
3326
- if (selectionResponse.resultObjects && selectionResponse.resultObjects.length > 0) {
3406
+ if (selectionResponse && selectionResponse.resultObjects && selectionResponse.resultObjects.length > 0) {
3327
3407
  this._selections = this._boFactory.makeBOArrayFromRawBackendDataArray(selection.Selection, selectionResponse.resultObjects);
3328
3408
  this._selections.forEach(function (s) { return s.instanceId = instanceId; });
3329
3409
  // const filtered: Selection[] = this._selections.filter(s => s.nodeType !== NodeType.Article && s.presentationLevel === 1);
@@ -3347,7 +3427,7 @@
3347
3427
  return [4 /*yield*/, this._configuratorService.getDecos(false)];
3348
3428
  case 1:
3349
3429
  decosResponse = _a.sent();
3350
- if (decosResponse.resultObjects && decosResponse.resultObjects.length > 0) {
3430
+ if (decosResponse && decosResponse.resultObjects && decosResponse.resultObjects.length > 0) {
3351
3431
  this._decos = this._boFactory.makeBOArrayFromRawBackendDataArray(decoNode.DecoNode, decosResponse.resultObjects);
3352
3432
  this.decosReceived.next(this._decos);
3353
3433
  }
@@ -3361,6 +3441,9 @@
3361
3441
  };
3362
3442
  Builder.prototype._linkSelectionsAndDecos = function () {
3363
3443
  var _this = this;
3444
+ if (!this._selections || !this._selections.length) {
3445
+ return;
3446
+ }
3364
3447
  var len = this._selections.length;
3365
3448
  var _loop_2 = function (i) {
3366
3449
  // const id: string = this.selections[i].artNodeIdDeco;
@@ -3382,9 +3465,12 @@
3382
3465
  }
3383
3466
  };
3384
3467
  Builder.prototype._getVariations = function () {
3385
- return this._decos.filter(function (deco) {
3386
- return deco.type === decoNodeType_enum.DecoNodeType.Variation;
3387
- });
3468
+ if (this._decos && this._decos.length) {
3469
+ return this._decos.filter(function (deco) {
3470
+ return deco.type === decoNodeType_enum.DecoNodeType.Variation;
3471
+ });
3472
+ }
3473
+ return [];
3388
3474
  };
3389
3475
  Builder.prototype._loadVariations = function (obj) {
3390
3476
  return __awaiter(this, void 0, void 0, function () {
@@ -3412,6 +3498,9 @@
3412
3498
  });
3413
3499
  };
3414
3500
  Builder.prototype._getAdjustables = function () {
3501
+ if (!this._selections || !this._selections.length) {
3502
+ return [];
3503
+ }
3415
3504
  return this._selections.filter(function (s) {
3416
3505
  var node = s.decoNode;
3417
3506
  return node && node.gameObjectName && node.type === decoNodeType_enum.DecoNodeType.Part && node.kind === decoNodeKind_enum.DecoNodeKind.Adjustable;
@@ -3434,7 +3523,8 @@
3434
3523
  this._addables.length = 0;
3435
3524
  // this._prepareTheSelections();
3436
3525
  };
3437
- Builder.prototype._log = function (message) {
3526
+ Builder.prototype._log = function (message, force) {
3527
+ if (force === void 0) { force = false; }
3438
3528
  if (this.debug) {
3439
3529
  this.debug(message);
3440
3530
  console.log(new Date(), message);
@@ -3710,8 +3800,8 @@
3710
3800
  var SelectionsComponent = /** @class */ (function () {
3711
3801
  function SelectionsComponent(_builder) {
3712
3802
  this._builder = _builder;
3713
- this.selectionViewModels = [];
3714
3803
  this.selectionClick = new i0.EventEmitter();
3804
+ this.selectionViewModels = [];
3715
3805
  }
3716
3806
  Object.defineProperty(SelectionsComponent.prototype, "selections", {
3717
3807
  set: function (value) {