@colijnit/configurator 12.0.6 → 12.0.9
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/bundles/colijnit-configurator.umd.js +151 -78
- package/bundles/colijnit-configurator.umd.js.map +1 -1
- package/esm2015/app/builder.js +16 -9
- package/esm2015/helper/variation-helper.js +15 -5
- package/esm2015/model/variation-settings.js +1 -1
- package/esm2015/model/variation.js +1 -1
- package/esm2015/utils/variation-utils.js +65 -33
- package/fesm2015/colijnit-configurator.js +93 -44
- package/fesm2015/colijnit-configurator.js.map +1 -1
- package/helper/variation-helper.d.ts +1 -1
- package/model/variation-settings.d.ts +1 -0
- package/model/variation.d.ts +1 -2
- package/package.json +2 -2
- package/utils/variation-utils.d.ts +2 -0
|
@@ -1186,44 +1186,53 @@
|
|
|
1186
1186
|
};
|
|
1187
1187
|
VariationUtils.LoadVariation = function (assetPath, fileName) {
|
|
1188
1188
|
return __awaiter(this, void 0, void 0, function () {
|
|
1189
|
-
var
|
|
1189
|
+
var _this = this;
|
|
1190
1190
|
return __generator(this, function (_a) {
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1191
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
1192
|
+
var id, file, settings, err_1, mute;
|
|
1193
|
+
return __generator(this, function (_a) {
|
|
1194
|
+
switch (_a.label) {
|
|
1195
|
+
case 0:
|
|
1196
|
+
if (!fileName) {
|
|
1197
|
+
resolve(null);
|
|
1198
|
+
}
|
|
1199
|
+
if (fileName.indexOf('ione3d') < 0) {
|
|
1200
|
+
fileName = fileName.concat('.ione3d');
|
|
1201
|
+
}
|
|
1202
|
+
id = fileName.substr(0, fileName.lastIndexOf('.ione3d'));
|
|
1203
|
+
_a.label = 1;
|
|
1204
|
+
case 1:
|
|
1205
|
+
_a.trys.push([1, 6, , 7]);
|
|
1206
|
+
if (!assetPath.endsWith('/')) {
|
|
1207
|
+
assetPath += '/';
|
|
1208
|
+
}
|
|
1209
|
+
if (!window.hasOwnProperty('downloadVariation')) {
|
|
1210
|
+
console.error('downloadVariation not defined in window global');
|
|
1211
|
+
reject('downloadVariation not defined in window global');
|
|
1212
|
+
}
|
|
1213
|
+
file = void 0;
|
|
1214
|
+
if (!this.MaterialCache.has(id)) return [3 /*break*/, 2];
|
|
1215
|
+
resolve(this.MaterialCache.get(id));
|
|
1216
|
+
return [3 /*break*/, 5];
|
|
1217
|
+
case 2: return [4 /*yield*/, window.downloadVariation(assetPath.replace('https://cdn1.colijn-it.nl/', '') + "variation/" + fileName)];
|
|
1218
|
+
case 3:
|
|
1219
|
+
file = _a.sent();
|
|
1220
|
+
return [4 /*yield*/, VariationUtils.GetVariationSettingsFromFile(id, file)];
|
|
1221
|
+
case 4:
|
|
1222
|
+
settings = _a.sent();
|
|
1223
|
+
this.MaterialCache.set(id, settings);
|
|
1224
|
+
resolve(settings);
|
|
1225
|
+
_a.label = 5;
|
|
1226
|
+
case 5: return [3 /*break*/, 7];
|
|
1227
|
+
case 6:
|
|
1228
|
+
err_1 = _a.sent();
|
|
1229
|
+
mute = err_1;
|
|
1230
|
+
reject(err_1);
|
|
1231
|
+
return [3 /*break*/, 7];
|
|
1232
|
+
case 7: return [2 /*return*/];
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1235
|
+
}); })];
|
|
1227
1236
|
});
|
|
1228
1237
|
});
|
|
1229
1238
|
};
|
|
@@ -1260,36 +1269,46 @@
|
|
|
1260
1269
|
// }
|
|
1261
1270
|
VariationUtils.GetVariationSettingsFromFile = function (id, compressedFile) {
|
|
1262
1271
|
return __awaiter(this, void 0, void 0, function () {
|
|
1263
|
-
var zipContent, variationSettings, index, indexFile;
|
|
1264
|
-
return __generator(this, function (
|
|
1265
|
-
switch (
|
|
1272
|
+
var zipContent, variationSettings, index, material, _a, indexFile;
|
|
1273
|
+
return __generator(this, function (_b) {
|
|
1274
|
+
switch (_b.label) {
|
|
1266
1275
|
case 0:
|
|
1267
1276
|
if (!compressedFile) {
|
|
1268
1277
|
return [2 /*return*/, null];
|
|
1269
1278
|
}
|
|
1270
1279
|
return [4 /*yield*/, VariationUtils.GetZipContent(compressedFile)];
|
|
1271
1280
|
case 1:
|
|
1272
|
-
zipContent =
|
|
1281
|
+
zipContent = _b.sent();
|
|
1273
1282
|
variationSettings = new VariationSettings();
|
|
1274
1283
|
variationSettings.id = id;
|
|
1275
|
-
if (!zipContent) return [3 /*break*/,
|
|
1276
|
-
if (!zipContent.files['
|
|
1277
|
-
return [4 /*yield*/, zipContent.files['
|
|
1284
|
+
if (!zipContent) return [3 /*break*/, 10];
|
|
1285
|
+
if (!zipContent.files['material.glb']) return [3 /*break*/, 4];
|
|
1286
|
+
return [4 /*yield*/, zipContent.files['material.glb'].async('arraybuffer')];
|
|
1278
1287
|
case 2:
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1288
|
+
material = _b.sent();
|
|
1289
|
+
_a = variationSettings;
|
|
1290
|
+
return [4 /*yield*/, VariationUtils.LoadMaterialFromGlb(material)];
|
|
1282
1291
|
case 3:
|
|
1283
|
-
|
|
1284
|
-
return [
|
|
1292
|
+
_a.material = _b.sent();
|
|
1293
|
+
return [3 /*break*/, 10];
|
|
1285
1294
|
case 4:
|
|
1286
|
-
|
|
1287
|
-
return [
|
|
1288
|
-
case 5:
|
|
1295
|
+
if (!zipContent.files['index.json']) return [3 /*break*/, 6];
|
|
1296
|
+
return [4 /*yield*/, zipContent.files['index.json'].async('string')];
|
|
1297
|
+
case 5:
|
|
1298
|
+
indexFile = _b.sent();
|
|
1299
|
+
index = JSON.parse(indexFile);
|
|
1300
|
+
_b.label = 6;
|
|
1289
1301
|
case 6:
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
case 7:
|
|
1302
|
+
if (!index) return [3 /*break*/, 8];
|
|
1303
|
+
return [4 /*yield*/, VariationUtils.CreateSettingsBasedOnIndex(index, variationSettings, zipContent)];
|
|
1304
|
+
case 7:
|
|
1305
|
+
_b.sent();
|
|
1306
|
+
return [3 /*break*/, 10];
|
|
1307
|
+
case 8: return [4 /*yield*/, VariationUtils.CreateSettingsBasedOnFileName(variationSettings, zipContent)];
|
|
1308
|
+
case 9:
|
|
1309
|
+
_b.sent();
|
|
1310
|
+
_b.label = 10;
|
|
1311
|
+
case 10: return [2 /*return*/, variationSettings];
|
|
1293
1312
|
}
|
|
1294
1313
|
});
|
|
1295
1314
|
});
|
|
@@ -1511,6 +1530,39 @@
|
|
|
1511
1530
|
});
|
|
1512
1531
|
});
|
|
1513
1532
|
};
|
|
1533
|
+
VariationUtils.LoadMaterialFromJson = function (material) {
|
|
1534
|
+
var loader = new THREE__namespace.MaterialLoader();
|
|
1535
|
+
if (material.textures) {
|
|
1536
|
+
var textures = {};
|
|
1537
|
+
for (var i = 0; i < material.textures.length; i++) {
|
|
1538
|
+
textures[material.textures[i].uuid] = material.textures[i];
|
|
1539
|
+
}
|
|
1540
|
+
loader.setTextures(textures);
|
|
1541
|
+
}
|
|
1542
|
+
return loader.parse(material);
|
|
1543
|
+
};
|
|
1544
|
+
VariationUtils.LoadMaterialFromGlb = function (material) {
|
|
1545
|
+
var _this = this;
|
|
1546
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
1547
|
+
var obj;
|
|
1548
|
+
return __generator(this, function (_a) {
|
|
1549
|
+
switch (_a.label) {
|
|
1550
|
+
case 0:
|
|
1551
|
+
if (!window.hasOwnProperty('loadGLTF')) {
|
|
1552
|
+
console.error('loadGLTF not defined in window global');
|
|
1553
|
+
return [2 /*return*/, reject()];
|
|
1554
|
+
}
|
|
1555
|
+
return [4 /*yield*/, window.loadGLTF(material, false)];
|
|
1556
|
+
case 1:
|
|
1557
|
+
obj = _a.sent();
|
|
1558
|
+
if (obj) {
|
|
1559
|
+
return [2 /*return*/, resolve(obj.children[0].material)];
|
|
1560
|
+
}
|
|
1561
|
+
return [2 /*return*/];
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
}); });
|
|
1565
|
+
};
|
|
1514
1566
|
VariationUtils.LoadFileContentFromZip = function (zip, fileName, base64) {
|
|
1515
1567
|
var _this = this;
|
|
1516
1568
|
if (base64 === void 0) { base64 = true; }
|
|
@@ -1685,9 +1737,9 @@
|
|
|
1685
1737
|
variationPromise = [];
|
|
1686
1738
|
_loop_2 = function (j) {
|
|
1687
1739
|
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 (
|
|
1690
|
-
switch (
|
|
1740
|
+
var newVariation, _a, _b;
|
|
1741
|
+
return __generator(this, function (_c) {
|
|
1742
|
+
switch (_c.label) {
|
|
1691
1743
|
case 0:
|
|
1692
1744
|
newVariation = new Variation();
|
|
1693
1745
|
newVariation.decoId = parseFloat(variations[j].id);
|
|
@@ -1697,9 +1749,15 @@
|
|
|
1697
1749
|
newVariation.supplierArticleNr = variations[j].supplierArticleNr;
|
|
1698
1750
|
newVariation.materialId = variations[j].materialId;
|
|
1699
1751
|
_a = newVariation;
|
|
1700
|
-
return [
|
|
1701
|
-
|
|
1702
|
-
|
|
1752
|
+
if (!variationSettings.material) return [3 /*break*/, 1];
|
|
1753
|
+
_b = variationSettings.material;
|
|
1754
|
+
return [3 /*break*/, 3];
|
|
1755
|
+
case 1: return [4 /*yield*/, AssetUtils.CreateMaterialFromAsset(variationSettings)];
|
|
1756
|
+
case 2:
|
|
1757
|
+
_b = _c.sent();
|
|
1758
|
+
_c.label = 3;
|
|
1759
|
+
case 3:
|
|
1760
|
+
_a.material = _b;
|
|
1703
1761
|
lastKnownVariations.push(newVariation);
|
|
1704
1762
|
return [2 /*return*/];
|
|
1705
1763
|
}
|
|
@@ -1758,7 +1816,7 @@
|
|
|
1758
1816
|
this._variations.push(variations);
|
|
1759
1817
|
}
|
|
1760
1818
|
};
|
|
1761
|
-
VariationHelper.prototype.preloadVariations = function (
|
|
1819
|
+
VariationHelper.prototype.preloadVariations = function (fileNames) {
|
|
1762
1820
|
var _this = this;
|
|
1763
1821
|
fileNames.forEach(function (fileName) {
|
|
1764
1822
|
if (fileName && !_this.get(fileName)) {
|
|
@@ -1859,13 +1917,23 @@
|
|
|
1859
1917
|
if (Array.isArray(mesh.material)) { // multimaterial support
|
|
1860
1918
|
for (var m = 0, mlen = mesh.material.length; m < mlen; m++) {
|
|
1861
1919
|
if (mesh.material[m].name.toLowerCase().indexOf(materialToSearch) !== -1) {
|
|
1862
|
-
|
|
1920
|
+
if (variation.material instanceof THREE__namespace.Material) {
|
|
1921
|
+
mesh.material[m] = variation.material;
|
|
1922
|
+
}
|
|
1923
|
+
else {
|
|
1924
|
+
mesh.material[m] = _this._setMeshMaterialFromVariation(mesh.material[m].name, variation, usePbr);
|
|
1925
|
+
}
|
|
1863
1926
|
}
|
|
1864
1927
|
}
|
|
1865
1928
|
}
|
|
1866
1929
|
else {
|
|
1867
1930
|
if (mesh.material.name.toLowerCase().indexOf(materialToSearch) !== -1) {
|
|
1868
|
-
|
|
1931
|
+
if (variation.material instanceof THREE__namespace.Material) {
|
|
1932
|
+
mesh.material = variation.material;
|
|
1933
|
+
}
|
|
1934
|
+
else {
|
|
1935
|
+
mesh.material = _this._setMeshMaterialFromVariation(mesh.material.name, variation, usePbr);
|
|
1936
|
+
}
|
|
1869
1937
|
}
|
|
1870
1938
|
}
|
|
1871
1939
|
}
|
|
@@ -2312,6 +2380,7 @@
|
|
|
2312
2380
|
return [4 /*yield*/, Promise.all(promises)];
|
|
2313
2381
|
case 5:
|
|
2314
2382
|
_a.sent();
|
|
2383
|
+
this._preloadMaterials();
|
|
2315
2384
|
if (this._answers.length > 0) {
|
|
2316
2385
|
return [2 /*return*/];
|
|
2317
2386
|
}
|
|
@@ -2319,7 +2388,6 @@
|
|
|
2319
2388
|
return [4 /*yield*/, this._build()];
|
|
2320
2389
|
case 6:
|
|
2321
2390
|
build = _a.sent();
|
|
2322
|
-
this._cleanUp();
|
|
2323
2391
|
return [2 /*return*/, build];
|
|
2324
2392
|
case 7: throw 'GLB source not found!';
|
|
2325
2393
|
case 8: return [3 /*break*/, 10];
|
|
@@ -2351,7 +2419,7 @@
|
|
|
2351
2419
|
this._selections = selections;
|
|
2352
2420
|
this._decos = decos;
|
|
2353
2421
|
this._linkSelectionsAndDecos();
|
|
2354
|
-
this._preloadMaterials(
|
|
2422
|
+
this._preloadMaterials();
|
|
2355
2423
|
return [4 /*yield*/, this._build()];
|
|
2356
2424
|
case 3:
|
|
2357
2425
|
build = _a.sent();
|
|
@@ -2377,12 +2445,14 @@
|
|
|
2377
2445
|
};
|
|
2378
2446
|
Builder.prototype.selectSelection = function (selection) {
|
|
2379
2447
|
return __awaiter(this, void 0, void 0, function () {
|
|
2448
|
+
var questionsAndAnswers;
|
|
2380
2449
|
return __generator(this, function (_a) {
|
|
2381
2450
|
switch (_a.label) {
|
|
2382
2451
|
case 0: return [4 /*yield*/, this._configuratorService.selectSelection(selection, false)];
|
|
2383
2452
|
case 1:
|
|
2384
|
-
_a.sent();
|
|
2385
|
-
this.
|
|
2453
|
+
questionsAndAnswers = _a.sent();
|
|
2454
|
+
this._answers = questionsAndAnswers.answers;
|
|
2455
|
+
this.answersReceived.next(questionsAndAnswers.answers);
|
|
2386
2456
|
return [2 /*return*/];
|
|
2387
2457
|
}
|
|
2388
2458
|
});
|
|
@@ -2405,16 +2475,17 @@
|
|
|
2405
2475
|
};
|
|
2406
2476
|
Builder.prototype.selectAnswer = function (answer) {
|
|
2407
2477
|
return __awaiter(this, void 0, void 0, function () {
|
|
2408
|
-
var
|
|
2409
|
-
return __generator(this, function (
|
|
2410
|
-
switch (
|
|
2478
|
+
var questionsAndAnswers;
|
|
2479
|
+
return __generator(this, function (_a) {
|
|
2480
|
+
switch (_a.label) {
|
|
2411
2481
|
case 0: return [4 /*yield*/, this._configuratorService.selectAnswer(answer, false)];
|
|
2412
2482
|
case 1:
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2483
|
+
questionsAndAnswers = _a.sent();
|
|
2484
|
+
this._answers = questionsAndAnswers.answers;
|
|
2485
|
+
this.answersReceived.next(questionsAndAnswers.answers);
|
|
2486
|
+
if (questionsAndAnswers.answers.length === 0) {
|
|
2487
|
+
this._build();
|
|
2488
|
+
}
|
|
2418
2489
|
return [2 /*return*/];
|
|
2419
2490
|
}
|
|
2420
2491
|
});
|
|
@@ -2468,8 +2539,8 @@
|
|
|
2468
2539
|
return '';
|
|
2469
2540
|
}
|
|
2470
2541
|
};
|
|
2471
|
-
Builder.prototype._preloadMaterials = function (
|
|
2472
|
-
this._variationHelper.preloadVariations(
|
|
2542
|
+
Builder.prototype._preloadMaterials = function () {
|
|
2543
|
+
this._variationHelper.preloadVariations(__spreadArray([], __read(new Set(this._decos.filter(function (d) { return d.gameObjectName !== undefined; }).map(function (d) { return d.gameObjectName; })))));
|
|
2473
2544
|
};
|
|
2474
2545
|
Builder.prototype._setInstanceId = function (sku, instanceId, goodId) {
|
|
2475
2546
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -2594,7 +2665,9 @@
|
|
|
2594
2665
|
this._log('remove from scene');
|
|
2595
2666
|
this._scene.remove(obj);
|
|
2596
2667
|
ObjectUtils.DisposeObject(this._source);
|
|
2668
|
+
// this._cleanUp();
|
|
2597
2669
|
this._log('ready!');
|
|
2670
|
+
this.modelLoaded.next(obj);
|
|
2598
2671
|
return [2 /*return*/, obj];
|
|
2599
2672
|
case 2: throw 'No adjustables found!';
|
|
2600
2673
|
}
|