@colijnit/configurator 259.1.3 → 259.1.5

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.
@@ -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 {
@@ -2786,7 +2790,7 @@
2786
2790
  var _this = this;
2787
2791
  return __generator(this, function (_a) {
2788
2792
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
2789
- var build, e_2;
2793
+ var build, e_2, e_3;
2790
2794
  return __generator(this, function (_a) {
2791
2795
  switch (_a.label) {
2792
2796
  case 0:
@@ -2795,12 +2799,19 @@
2795
2799
  }
2796
2800
  _a.label = 1;
2797
2801
  case 1:
2798
- _a.trys.push([1, 6, , 7]);
2799
- this._log('start build');
2800
- 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)];
2801
2805
  case 2:
2802
2806
  _a.sent();
2803
- 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];
2804
2815
  this._reset();
2805
2816
  this._selections = selections;
2806
2817
  this._decos = decos;
@@ -2808,21 +2819,41 @@
2808
2819
  this._prepareTheSelections();
2809
2820
  this._preloadMaterials();
2810
2821
  return [4 /*yield*/, this._build()];
2811
- case 3:
2822
+ case 5:
2812
2823
  build = _a.sent();
2813
- this._cleanUp();
2814
- this._log('finish build');
2815
2824
  resolve(build);
2816
- return [3 /*break*/, 5];
2817
- case 4:
2818
- reject('Unsufficient data provided!');
2819
- _a.label = 5;
2820
- case 5: return [3 /*break*/, 7];
2825
+ return [3 /*break*/, 7];
2821
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:
2822
2831
  e_2 = _a.sent();
2823
- reject(e_2);
2824
- return [3 /*break*/, 7];
2825
- 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*/];
2826
2857
  }
2827
2858
  });
2828
2859
  }); })];
@@ -3002,14 +3033,15 @@
3002
3033
  });
3003
3034
  });
3004
3035
  };
3005
- Builder.prototype._downloadAsset = function (assetUrl, cdnUrl, schema) {
3036
+ Builder.prototype._downloadAsset = function (assetUrl, cdnUrl, schema, setVisibleFalse) {
3037
+ if (setVisibleFalse === void 0) { setVisibleFalse = true; }
3006
3038
  return __awaiter(this, void 0, void 0, function () {
3007
3039
  var _a;
3008
3040
  return __generator(this, function (_b) {
3009
3041
  switch (_b.label) {
3010
3042
  case 0:
3011
3043
  _a = this;
3012
- return [4 /*yield*/, this._threedUtils.download3DSource(assetUrl, cdnUrl)
3044
+ return [4 /*yield*/, this._threedUtils.download3DSource(assetUrl, setVisibleFalse)
3013
3045
  .catch(function (error) {
3014
3046
  throw error;
3015
3047
  })];
@@ -3028,7 +3060,7 @@
3028
3060
  };
3029
3061
  Builder.prototype._build = function () {
3030
3062
  return __awaiter(this, void 0, void 0, function () {
3031
- var adjustables, obj, connected, i, len, adjustable, ii, lenii;
3063
+ var adjustables, obj, connected, i, len, adjustable, ii;
3032
3064
  return __generator(this, function (_a) {
3033
3065
  switch (_a.label) {
3034
3066
  case 0:
@@ -3047,7 +3079,7 @@
3047
3079
  for (i = 0, len = adjustables.length; i < len; i++) {
3048
3080
  adjustable = this._createAdjustable(obj, adjustables[i]);
3049
3081
  if (adjustable) {
3050
- for (ii = 0, lenii = this._placedAdjustables.length; ii < lenii; ii++) {
3082
+ for (ii = this._placedAdjustables.length - 1; ii >= 0; ii--) {
3051
3083
  if (SceneUtils.TrySelectorConnection(this._scene, obj, this._placedAdjustables[ii], adjustable, i === 1)) {
3052
3084
  this._placedAdjustables[ii].visible = true;
3053
3085
  adjustable.visible = true;
@@ -3491,7 +3523,8 @@
3491
3523
  this._addables.length = 0;
3492
3524
  // this._prepareTheSelections();
3493
3525
  };
3494
- Builder.prototype._log = function (message) {
3526
+ Builder.prototype._log = function (message, force) {
3527
+ if (force === void 0) { force = false; }
3495
3528
  if (this.debug) {
3496
3529
  this.debug(message);
3497
3530
  console.log(new Date(), message);