@colijnit/configurator 12.0.4 → 12.0.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.
- package/app/builder.d.ts +1 -0
- package/bundles/colijnit-configurator.umd.js +169 -59
- package/bundles/colijnit-configurator.umd.js.map +1 -1
- package/colijnit-configurator.metadata.json +1 -1
- package/esm2015/app/builder.js +18 -1
- package/esm2015/helper/variation-helper.js +76 -11
- package/esm2015/model/variation.js +1 -1
- package/fesm2015/colijnit-configurator.js +99 -18
- package/fesm2015/colijnit-configurator.js.map +1 -1
- package/helper/variation-helper.d.ts +7 -0
- package/model/variation.d.ts +1 -0
- package/package.json +1 -1
package/app/builder.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare class Builder {
|
|
|
42
42
|
getImageForSelectionOrAnswer(object: Selection | Answer): Promise<string>;
|
|
43
43
|
_cleanUp(): void;
|
|
44
44
|
private _handleResponseData;
|
|
45
|
+
private _preloadMaterials;
|
|
45
46
|
private _setInstanceId;
|
|
46
47
|
private _prepareConfiguration;
|
|
47
48
|
private _downloadAsset;
|
|
@@ -932,6 +932,15 @@
|
|
|
932
932
|
return SceneUtils;
|
|
933
933
|
}());
|
|
934
934
|
|
|
935
|
+
var VariationSettings = /** @class */ (function () {
|
|
936
|
+
function VariationSettings() {
|
|
937
|
+
this.settings = {};
|
|
938
|
+
this.loading = false;
|
|
939
|
+
this.loaded = new rxjs.Subject();
|
|
940
|
+
}
|
|
941
|
+
return VariationSettings;
|
|
942
|
+
}());
|
|
943
|
+
|
|
935
944
|
var Material = /** @class */ (function () {
|
|
936
945
|
function Material() {
|
|
937
946
|
this.specular = new THREE__namespace.Color(0.3, 0.3, 0.3);
|
|
@@ -1168,15 +1177,6 @@
|
|
|
1168
1177
|
return Variation;
|
|
1169
1178
|
}());
|
|
1170
1179
|
|
|
1171
|
-
var VariationSettings = /** @class */ (function () {
|
|
1172
|
-
function VariationSettings() {
|
|
1173
|
-
this.settings = {};
|
|
1174
|
-
this.loading = false;
|
|
1175
|
-
this.loaded = new rxjs.Subject();
|
|
1176
|
-
}
|
|
1177
|
-
return VariationSettings;
|
|
1178
|
-
}());
|
|
1179
|
-
|
|
1180
1180
|
// @dynamic
|
|
1181
1181
|
var VariationUtils = /** @class */ (function () {
|
|
1182
1182
|
function VariationUtils() {
|
|
@@ -1581,6 +1581,7 @@
|
|
|
1581
1581
|
|
|
1582
1582
|
var VariationHelper = /** @class */ (function () {
|
|
1583
1583
|
function VariationHelper() {
|
|
1584
|
+
this._variations = [];
|
|
1584
1585
|
this._lastKnownVariations = new Map();
|
|
1585
1586
|
}
|
|
1586
1587
|
VariationHelper.prototype.clearCache = function () {
|
|
@@ -1657,68 +1658,155 @@
|
|
|
1657
1658
|
VariationHelper.prototype.loadVariation = function (obj, parts, usePbr) {
|
|
1658
1659
|
if (usePbr === void 0) { usePbr = false; }
|
|
1659
1660
|
return __awaiter(this, void 0, void 0, function () {
|
|
1660
|
-
var len,
|
|
1661
|
-
|
|
1662
|
-
|
|
1661
|
+
var len, _loop_1, this_1, i, e_2;
|
|
1662
|
+
var _this = this;
|
|
1663
|
+
return __generator(this, function (_a) {
|
|
1664
|
+
switch (_a.label) {
|
|
1663
1665
|
case 0:
|
|
1664
|
-
|
|
1666
|
+
_a.trys.push([0, 5, , 6]);
|
|
1665
1667
|
len = parts.length;
|
|
1668
|
+
_loop_1 = function (i) {
|
|
1669
|
+
var variations, lastKnownVariations, variationPromise, _loop_2, j;
|
|
1670
|
+
return __generator(this, function (_b) {
|
|
1671
|
+
switch (_b.label) {
|
|
1672
|
+
case 0:
|
|
1673
|
+
variations = parts[i].variations;
|
|
1674
|
+
if (!variations || variations.length === 0) {
|
|
1675
|
+
if (this_1._getLastKnownVariations(parts[i].nodeId)) {
|
|
1676
|
+
parts[i].variations = this_1._getLastKnownVariations(parts[i].nodeId);
|
|
1677
|
+
this_1._applyVariations(obj, parts[i], usePbr);
|
|
1678
|
+
return [2 /*return*/, "continue"];
|
|
1679
|
+
}
|
|
1680
|
+
else {
|
|
1681
|
+
return [2 /*return*/, "continue"];
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
lastKnownVariations = [];
|
|
1685
|
+
variationPromise = [];
|
|
1686
|
+
_loop_2 = function (j) {
|
|
1687
|
+
variationPromise.push(this_1.loadTheVariation(variations[j].gameObjectName || parts[i].decoId).then(function (variationSettings) { return __awaiter(_this, void 0, void 0, function () {
|
|
1688
|
+
var newVariation, _a;
|
|
1689
|
+
return __generator(this, function (_b) {
|
|
1690
|
+
switch (_b.label) {
|
|
1691
|
+
case 0:
|
|
1692
|
+
newVariation = new Variation();
|
|
1693
|
+
newVariation.decoId = parseFloat(variations[j].id);
|
|
1694
|
+
newVariation.brandId = variations[j].brandId;
|
|
1695
|
+
newVariation.optionText = variations[j].optionText;
|
|
1696
|
+
newVariation.gameObjectName = variations[j].gameObjectName;
|
|
1697
|
+
newVariation.supplierArticleNr = variations[j].supplierArticleNr;
|
|
1698
|
+
newVariation.materialId = variations[j].materialId;
|
|
1699
|
+
_a = newVariation;
|
|
1700
|
+
return [4 /*yield*/, AssetUtils.CreateMaterialFromAsset(variationSettings)];
|
|
1701
|
+
case 1:
|
|
1702
|
+
_a.material = _b.sent();
|
|
1703
|
+
lastKnownVariations.push(newVariation);
|
|
1704
|
+
return [2 /*return*/];
|
|
1705
|
+
}
|
|
1706
|
+
});
|
|
1707
|
+
}); }));
|
|
1708
|
+
};
|
|
1709
|
+
for (j = 0; j < variations.length; j++) {
|
|
1710
|
+
_loop_2(j);
|
|
1711
|
+
}
|
|
1712
|
+
return [4 /*yield*/, Promise.all(variationPromise)];
|
|
1713
|
+
case 1:
|
|
1714
|
+
_b.sent();
|
|
1715
|
+
this_1._setLastKnownVariations(parts[i].nodeId + "_" + parts[i].node, lastKnownVariations);
|
|
1716
|
+
parts[i].variations = lastKnownVariations;
|
|
1717
|
+
this_1._applyVariations(obj, parts[i], usePbr);
|
|
1718
|
+
return [2 /*return*/];
|
|
1719
|
+
}
|
|
1720
|
+
});
|
|
1721
|
+
};
|
|
1722
|
+
this_1 = this;
|
|
1666
1723
|
i = 0;
|
|
1667
|
-
|
|
1724
|
+
_a.label = 1;
|
|
1668
1725
|
case 1:
|
|
1669
|
-
if (!(i < len)) return [3 /*break*/,
|
|
1670
|
-
|
|
1671
|
-
if (!variations || variations.length === 0) {
|
|
1672
|
-
if (this._getLastKnownVariations(parts[i].nodeId)) {
|
|
1673
|
-
parts[i].variations = this._getLastKnownVariations(parts[i].nodeId);
|
|
1674
|
-
this._applyVariations(obj, parts[i], usePbr);
|
|
1675
|
-
return [3 /*break*/, 7];
|
|
1676
|
-
}
|
|
1677
|
-
else {
|
|
1678
|
-
return [3 /*break*/, 7];
|
|
1679
|
-
}
|
|
1680
|
-
}
|
|
1681
|
-
lastKnownVariations = [];
|
|
1682
|
-
j = 0;
|
|
1683
|
-
_b.label = 2;
|
|
1726
|
+
if (!(i < len)) return [3 /*break*/, 4];
|
|
1727
|
+
return [5 /*yield**/, _loop_1(i)];
|
|
1684
1728
|
case 2:
|
|
1685
|
-
|
|
1686
|
-
|
|
1729
|
+
_a.sent();
|
|
1730
|
+
_a.label = 3;
|
|
1687
1731
|
case 3:
|
|
1688
|
-
variationSettings = _b.sent();
|
|
1689
|
-
newVariation = new Variation();
|
|
1690
|
-
newVariation.decoId = parseFloat(variations[j].id);
|
|
1691
|
-
newVariation.brandId = variations[j].brandId;
|
|
1692
|
-
newVariation.gameObjectName = variations[j].gameObjectName;
|
|
1693
|
-
newVariation.supplierArticleNr = variations[j].supplierArticleNr;
|
|
1694
|
-
newVariation.materialId = variations[j].materialId;
|
|
1695
|
-
_a = newVariation;
|
|
1696
|
-
return [4 /*yield*/, AssetUtils.CreateMaterialFromAsset(variationSettings)];
|
|
1697
|
-
case 4:
|
|
1698
|
-
_a.material = _b.sent();
|
|
1699
|
-
lastKnownVariations.push(newVariation);
|
|
1700
|
-
_b.label = 5;
|
|
1701
|
-
case 5:
|
|
1702
|
-
j++;
|
|
1703
|
-
return [3 /*break*/, 2];
|
|
1704
|
-
case 6:
|
|
1705
|
-
this._setLastKnownVariations(parts[i].nodeId, lastKnownVariations);
|
|
1706
|
-
parts[i].variations = lastKnownVariations;
|
|
1707
|
-
this._applyVariations(obj, parts[i], usePbr);
|
|
1708
|
-
_b.label = 7;
|
|
1709
|
-
case 7:
|
|
1710
1732
|
i++;
|
|
1711
1733
|
return [3 /*break*/, 1];
|
|
1712
|
-
case
|
|
1713
|
-
case
|
|
1714
|
-
e_2 =
|
|
1734
|
+
case 4: return [3 /*break*/, 6];
|
|
1735
|
+
case 5:
|
|
1736
|
+
e_2 = _a.sent();
|
|
1715
1737
|
console.error(e_2);
|
|
1716
|
-
return [3 /*break*/,
|
|
1717
|
-
case
|
|
1738
|
+
return [3 /*break*/, 6];
|
|
1739
|
+
case 6: return [2 /*return*/];
|
|
1740
|
+
}
|
|
1741
|
+
});
|
|
1742
|
+
});
|
|
1743
|
+
};
|
|
1744
|
+
VariationHelper.prototype.get = function (id) {
|
|
1745
|
+
var len = this._variations.length;
|
|
1746
|
+
for (var i = 0; i < len; i++) {
|
|
1747
|
+
if (this._variations[i].id && this._variations[i].id === id) {
|
|
1748
|
+
return this._variations[i];
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
VariationHelper.prototype.set = function (variations) {
|
|
1753
|
+
var idx = this._variations.findIndex(function (v) { return v.id === variations.id; });
|
|
1754
|
+
if (idx > -1) {
|
|
1755
|
+
this._variations[idx] = variations;
|
|
1756
|
+
}
|
|
1757
|
+
else {
|
|
1758
|
+
this._variations.push(variations);
|
|
1759
|
+
}
|
|
1760
|
+
};
|
|
1761
|
+
VariationHelper.prototype.preloadVariations = function (schema, fileNames) {
|
|
1762
|
+
var _this = this;
|
|
1763
|
+
fileNames.forEach(function (fileName) {
|
|
1764
|
+
if (fileName && !_this.get(fileName)) {
|
|
1765
|
+
var settings_1 = new VariationSettings();
|
|
1766
|
+
settings_1.id = fileName;
|
|
1767
|
+
settings_1.loading = true;
|
|
1768
|
+
_this._variations.push(settings_1);
|
|
1769
|
+
var assetPath = _this.assetPath;
|
|
1770
|
+
if (!assetPath.endsWith('/')) {
|
|
1771
|
+
assetPath += '/';
|
|
1772
|
+
}
|
|
1773
|
+
VariationUtils.LoadVariation(assetPath, fileName).then(function (variationSettings) {
|
|
1774
|
+
settings_1.loading = false;
|
|
1775
|
+
settings_1.loaded.next(variationSettings);
|
|
1776
|
+
if (variationSettings) {
|
|
1777
|
+
_this.set(variationSettings);
|
|
1778
|
+
}
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
});
|
|
1782
|
+
};
|
|
1783
|
+
VariationHelper.prototype.loadTheVariation = function (fileName) {
|
|
1784
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1785
|
+
var settings;
|
|
1786
|
+
return __generator(this, function (_a) {
|
|
1787
|
+
switch (_a.label) {
|
|
1788
|
+
case 0:
|
|
1789
|
+
if (!fileName) {
|
|
1790
|
+
return [2 /*return*/, null];
|
|
1791
|
+
}
|
|
1792
|
+
if (!this.get(fileName)) return [3 /*break*/, 3];
|
|
1793
|
+
settings = this.get(fileName);
|
|
1794
|
+
if (!settings.loading) return [3 /*break*/, 2];
|
|
1795
|
+
return [4 /*yield*/, this._waitForVariationToLoad(settings)];
|
|
1796
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1797
|
+
case 2: return [2 /*return*/, settings];
|
|
1798
|
+
case 3: return [2 /*return*/];
|
|
1718
1799
|
}
|
|
1719
1800
|
});
|
|
1720
1801
|
});
|
|
1721
1802
|
};
|
|
1803
|
+
VariationHelper.prototype._waitForVariationToLoad = function (settings) {
|
|
1804
|
+
return new Promise(function (resolve) {
|
|
1805
|
+
settings.loaded.subscribe(function (value) {
|
|
1806
|
+
resolve(value);
|
|
1807
|
+
});
|
|
1808
|
+
});
|
|
1809
|
+
};
|
|
1722
1810
|
VariationHelper.prototype._getChildrenFilterByProp = function (obj, userDataObjectProp, prop, value) {
|
|
1723
1811
|
return obj.children.filter(function (child) {
|
|
1724
1812
|
return child.userData &&
|
|
@@ -2255,17 +2343,21 @@
|
|
|
2255
2343
|
_a.label = 1;
|
|
2256
2344
|
case 1:
|
|
2257
2345
|
_a.trys.push([1, 6, , 7]);
|
|
2346
|
+
// console.log(new Date(), 'start build');
|
|
2258
2347
|
return [4 /*yield*/, this._downloadAsset(assetUrl, cdnUrl, schema)];
|
|
2259
2348
|
case 2:
|
|
2349
|
+
// console.log(new Date(), 'start build');
|
|
2260
2350
|
_a.sent();
|
|
2261
2351
|
if (!(selections && selections.length > 1 && decos && decos.length > 0 && this._source)) return [3 /*break*/, 4];
|
|
2262
2352
|
this._selections = selections;
|
|
2263
2353
|
this._decos = decos;
|
|
2264
2354
|
this._linkSelectionsAndDecos();
|
|
2355
|
+
this._preloadMaterials(schema);
|
|
2265
2356
|
return [4 /*yield*/, this._build()];
|
|
2266
2357
|
case 3:
|
|
2267
2358
|
build = _a.sent();
|
|
2268
2359
|
this._cleanUp();
|
|
2360
|
+
// console.log(new Date(), 'finish build');
|
|
2269
2361
|
return [2 /*return*/, build];
|
|
2270
2362
|
case 4: throw 'Unsufficient data provided!';
|
|
2271
2363
|
case 5: return [3 /*break*/, 7];
|
|
@@ -2377,6 +2469,9 @@
|
|
|
2377
2469
|
return '';
|
|
2378
2470
|
}
|
|
2379
2471
|
};
|
|
2472
|
+
Builder.prototype._preloadMaterials = function (schema) {
|
|
2473
|
+
this._variationHelper.preloadVariations(schema, this._decos.map(function (d) { return d.gameObjectName; }));
|
|
2474
|
+
};
|
|
2380
2475
|
Builder.prototype._setInstanceId = function (sku, instanceId, goodId) {
|
|
2381
2476
|
return __awaiter(this, void 0, void 0, function () {
|
|
2382
2477
|
var result;
|
|
@@ -2470,6 +2565,7 @@
|
|
|
2470
2565
|
obj.visible = false; // no need to render visualy
|
|
2471
2566
|
this._scene.add(obj);
|
|
2472
2567
|
connected = false;
|
|
2568
|
+
// console.log(new Date(), 'build main model');
|
|
2473
2569
|
for (i = 0, len = adjustables.length; i < len; i++) {
|
|
2474
2570
|
adjustable = this._createAdjustable(obj, adjustables[i]);
|
|
2475
2571
|
if (adjustable) {
|
|
@@ -2487,14 +2583,20 @@
|
|
|
2487
2583
|
console.warn('No connection found for: ', adjustable.name);
|
|
2488
2584
|
}
|
|
2489
2585
|
}
|
|
2586
|
+
// console.log(new Date(), 'place addables');
|
|
2490
2587
|
this._placeAddables(obj);
|
|
2588
|
+
// console.log(new Date(), 'update pivot');
|
|
2491
2589
|
this._updatePivot(obj);
|
|
2590
|
+
// console.log(new Date(), 'load variations');
|
|
2492
2591
|
return [4 /*yield*/, this._loadVariations(obj)];
|
|
2493
2592
|
case 1:
|
|
2593
|
+
// console.log(new Date(), 'load variations');
|
|
2494
2594
|
_a.sent();
|
|
2495
2595
|
// this._variationHelper.clearCache();
|
|
2596
|
+
// console.log(new Date(), 'remove from scene');
|
|
2496
2597
|
this._scene.remove(obj);
|
|
2497
2598
|
ObjectUtils.DisposeObject(this._source);
|
|
2599
|
+
// console.log(new Date(), 'ready!');
|
|
2498
2600
|
return [2 /*return*/, obj];
|
|
2499
2601
|
case 2: throw 'No adjustables found!';
|
|
2500
2602
|
}
|
|
@@ -2794,15 +2896,23 @@
|
|
|
2794
2896
|
return __awaiter(this, void 0, void 0, function () {
|
|
2795
2897
|
return __generator(this, function (_a) {
|
|
2796
2898
|
switch (_a.label) {
|
|
2797
|
-
case 0:
|
|
2899
|
+
case 0:
|
|
2900
|
+
// console.log(new Date(), 'load variation for parts');
|
|
2901
|
+
return [4 /*yield*/, this._variationHelper.loadPart(obj, this._adjustables, true)];
|
|
2798
2902
|
case 1:
|
|
2903
|
+
// console.log(new Date(), 'load variation for parts');
|
|
2799
2904
|
_a.sent();
|
|
2905
|
+
// console.log(new Date(), 'load variation for adjustables');
|
|
2800
2906
|
return [4 /*yield*/, this._variationHelper.loadVariation(obj, this._adjustables, true)];
|
|
2801
2907
|
case 2:
|
|
2908
|
+
// console.log(new Date(), 'load variation for adjustables');
|
|
2802
2909
|
_a.sent();
|
|
2910
|
+
// console.log(new Date(), 'load variation for addables');
|
|
2803
2911
|
return [4 /*yield*/, this._variationHelper.loadVariation(obj, this._addables, true)];
|
|
2804
2912
|
case 3:
|
|
2913
|
+
// console.log(new Date(), 'load variation for addables');
|
|
2805
2914
|
_a.sent();
|
|
2915
|
+
// console.log(new Date(), 'load variation clear cache');
|
|
2806
2916
|
this._variationHelper.clearCache();
|
|
2807
2917
|
return [2 /*return*/];
|
|
2808
2918
|
}
|