@colijnit/configurator 12.0.7 → 12.0.8
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 +95 -45
- 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 +34 -8
- package/fesm2015/colijnit-configurator.js +62 -19
- 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 +1 -1
- package/utils/variation-utils.d.ts +2 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three'), require('@colijnit/configuratorapi/build/model/deco-node'), require('@colijnit/configuratorapi/build/service/business-object-factory'), require('@colijnit/configuratorapi/build/model/selection'), require('@colijnit/configuratorapi/build/enum/deco-node-type.enum'), require('axios'), require('@colijnit/configuratorapi/build/enum/deco-node-kind.enum'), require('rxjs'), require('jszip'), require('@colijnit/configuratorapi/build/model/article'), require('@colijnit/configuratorapi/build/configurator'), require('@colijnit/configuratorapi/build/utils/function/not-nill.function'), require('@colijnit/configuratorapi/build/enum/node-type.enum'), require('@colijnit/configuratorapi/build/utils/function/is-nill.function'), require('@angular/core'), require('@angular/common'), require('@angular/animations')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@colijnit/configurator', ['exports', 'three', '@colijnit/configuratorapi/build/model/deco-node', '@colijnit/configuratorapi/build/service/business-object-factory', '@colijnit/configuratorapi/build/model/selection', '@colijnit/configuratorapi/build/enum/deco-node-type.enum', 'axios', '@colijnit/configuratorapi/build/enum/deco-node-kind.enum', 'rxjs', 'jszip', '@colijnit/configuratorapi/build/model/article', '@colijnit/configuratorapi/build/configurator', '@colijnit/configuratorapi/build/utils/function/not-nill.function', '@colijnit/configuratorapi/build/enum/node-type.enum', '@colijnit/configuratorapi/build/utils/function/is-nill.function', '@angular/core', '@angular/common', '@angular/animations'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.colijnit = global.colijnit || {}, global.colijnit.configurator = {}), global.THREE, global.decoNode, global.businessObjectFactory, global.selection, global.decoNodeType_enum, global.axios, global.decoNodeKind_enum, global.rxjs, global.JSZip, global.article, global.configurator, global.notNill_function, global.nodeType_enum, global.isNill_function, global.ng.core, global.ng.common, global.ng.animations));
|
|
5
|
-
})(this, (function (exports, THREE, decoNode, businessObjectFactory, selection, decoNodeType_enum, axios, decoNodeKind_enum, rxjs, JSZip, article, configurator, notNill_function, nodeType_enum, isNill_function, i0, common, animations) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three'), require('@colijnit/configuratorapi/build/model/deco-node'), require('@colijnit/configuratorapi/build/service/business-object-factory'), require('@colijnit/configuratorapi/build/model/selection'), require('@colijnit/configuratorapi/build/enum/deco-node-type.enum'), require('axios'), require('@colijnit/configuratorapi/build/enum/deco-node-kind.enum'), require('rxjs'), require('jszip'), require('three/examples/jsm/loaders/GLTFLoader'), require('@colijnit/configuratorapi/build/model/article'), require('@colijnit/configuratorapi/build/configurator'), require('@colijnit/configuratorapi/build/utils/function/not-nill.function'), require('@colijnit/configuratorapi/build/enum/node-type.enum'), require('@colijnit/configuratorapi/build/utils/function/is-nill.function'), require('@angular/core'), require('@angular/common'), require('@angular/animations')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@colijnit/configurator', ['exports', 'three', '@colijnit/configuratorapi/build/model/deco-node', '@colijnit/configuratorapi/build/service/business-object-factory', '@colijnit/configuratorapi/build/model/selection', '@colijnit/configuratorapi/build/enum/deco-node-type.enum', 'axios', '@colijnit/configuratorapi/build/enum/deco-node-kind.enum', 'rxjs', 'jszip', 'three/examples/jsm/loaders/GLTFLoader', '@colijnit/configuratorapi/build/model/article', '@colijnit/configuratorapi/build/configurator', '@colijnit/configuratorapi/build/utils/function/not-nill.function', '@colijnit/configuratorapi/build/enum/node-type.enum', '@colijnit/configuratorapi/build/utils/function/is-nill.function', '@angular/core', '@angular/common', '@angular/animations'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.colijnit = global.colijnit || {}, global.colijnit.configurator = {}), global.THREE, global.decoNode, global.businessObjectFactory, global.selection, global.decoNodeType_enum, global.axios, global.decoNodeKind_enum, global.rxjs, global.JSZip, global.GLTFLoader, global.article, global.configurator, global.notNill_function, global.nodeType_enum, global.isNill_function, global.ng.core, global.ng.common, global.ng.animations));
|
|
5
|
+
})(this, (function (exports, THREE, decoNode, businessObjectFactory, selection, decoNodeType_enum, axios, decoNodeKind_enum, rxjs, JSZip, GLTFLoader, article, configurator, notNill_function, nodeType_enum, isNill_function, i0, common, animations) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -1269,36 +1269,46 @@
|
|
|
1269
1269
|
// }
|
|
1270
1270
|
VariationUtils.GetVariationSettingsFromFile = function (id, compressedFile) {
|
|
1271
1271
|
return __awaiter(this, void 0, void 0, function () {
|
|
1272
|
-
var zipContent, variationSettings, index, indexFile;
|
|
1273
|
-
return __generator(this, function (
|
|
1274
|
-
switch (
|
|
1272
|
+
var zipContent, variationSettings, index, material, _a, indexFile;
|
|
1273
|
+
return __generator(this, function (_b) {
|
|
1274
|
+
switch (_b.label) {
|
|
1275
1275
|
case 0:
|
|
1276
1276
|
if (!compressedFile) {
|
|
1277
1277
|
return [2 /*return*/, null];
|
|
1278
1278
|
}
|
|
1279
1279
|
return [4 /*yield*/, VariationUtils.GetZipContent(compressedFile)];
|
|
1280
1280
|
case 1:
|
|
1281
|
-
zipContent =
|
|
1281
|
+
zipContent = _b.sent();
|
|
1282
1282
|
variationSettings = new VariationSettings();
|
|
1283
1283
|
variationSettings.id = id;
|
|
1284
|
-
if (!zipContent) return [3 /*break*/,
|
|
1285
|
-
if (!zipContent.files['
|
|
1286
|
-
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')];
|
|
1287
1287
|
case 2:
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1288
|
+
material = _b.sent();
|
|
1289
|
+
_a = variationSettings;
|
|
1290
|
+
return [4 /*yield*/, VariationUtils.LoadMaterialFromGlb(material)];
|
|
1291
1291
|
case 3:
|
|
1292
|
-
|
|
1293
|
-
return [
|
|
1292
|
+
_a.material = _b.sent();
|
|
1293
|
+
return [3 /*break*/, 10];
|
|
1294
1294
|
case 4:
|
|
1295
|
-
|
|
1296
|
-
return [
|
|
1297
|
-
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;
|
|
1298
1301
|
case 6:
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
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];
|
|
1302
1312
|
}
|
|
1303
1313
|
});
|
|
1304
1314
|
});
|
|
@@ -1520,6 +1530,25 @@
|
|
|
1520
1530
|
});
|
|
1521
1531
|
});
|
|
1522
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
|
+
return new Promise(function (resolve) {
|
|
1546
|
+
var loader = new GLTFLoader.GLTFLoader();
|
|
1547
|
+
loader.parse(material, null, function (object) {
|
|
1548
|
+
return resolve(object.scene.children[0].material);
|
|
1549
|
+
});
|
|
1550
|
+
});
|
|
1551
|
+
};
|
|
1523
1552
|
VariationUtils.LoadFileContentFromZip = function (zip, fileName, base64) {
|
|
1524
1553
|
var _this = this;
|
|
1525
1554
|
if (base64 === void 0) { base64 = true; }
|
|
@@ -1694,9 +1723,9 @@
|
|
|
1694
1723
|
variationPromise = [];
|
|
1695
1724
|
_loop_2 = function (j) {
|
|
1696
1725
|
variationPromise.push(this_1.loadTheVariation(variations[j].gameObjectName || parts[i].decoId).then(function (variationSettings) { return __awaiter(_this, void 0, void 0, function () {
|
|
1697
|
-
var newVariation, _a;
|
|
1698
|
-
return __generator(this, function (
|
|
1699
|
-
switch (
|
|
1726
|
+
var newVariation, _a, _b;
|
|
1727
|
+
return __generator(this, function (_c) {
|
|
1728
|
+
switch (_c.label) {
|
|
1700
1729
|
case 0:
|
|
1701
1730
|
newVariation = new Variation();
|
|
1702
1731
|
newVariation.decoId = parseFloat(variations[j].id);
|
|
@@ -1706,9 +1735,15 @@
|
|
|
1706
1735
|
newVariation.supplierArticleNr = variations[j].supplierArticleNr;
|
|
1707
1736
|
newVariation.materialId = variations[j].materialId;
|
|
1708
1737
|
_a = newVariation;
|
|
1709
|
-
return [
|
|
1710
|
-
|
|
1711
|
-
|
|
1738
|
+
if (!variationSettings.material) return [3 /*break*/, 1];
|
|
1739
|
+
_b = variationSettings.material;
|
|
1740
|
+
return [3 /*break*/, 3];
|
|
1741
|
+
case 1: return [4 /*yield*/, AssetUtils.CreateMaterialFromAsset(variationSettings)];
|
|
1742
|
+
case 2:
|
|
1743
|
+
_b = _c.sent();
|
|
1744
|
+
_c.label = 3;
|
|
1745
|
+
case 3:
|
|
1746
|
+
_a.material = _b;
|
|
1712
1747
|
lastKnownVariations.push(newVariation);
|
|
1713
1748
|
return [2 /*return*/];
|
|
1714
1749
|
}
|
|
@@ -1767,7 +1802,7 @@
|
|
|
1767
1802
|
this._variations.push(variations);
|
|
1768
1803
|
}
|
|
1769
1804
|
};
|
|
1770
|
-
VariationHelper.prototype.preloadVariations = function (
|
|
1805
|
+
VariationHelper.prototype.preloadVariations = function (fileNames) {
|
|
1771
1806
|
var _this = this;
|
|
1772
1807
|
fileNames.forEach(function (fileName) {
|
|
1773
1808
|
if (fileName && !_this.get(fileName)) {
|
|
@@ -1868,13 +1903,23 @@
|
|
|
1868
1903
|
if (Array.isArray(mesh.material)) { // multimaterial support
|
|
1869
1904
|
for (var m = 0, mlen = mesh.material.length; m < mlen; m++) {
|
|
1870
1905
|
if (mesh.material[m].name.toLowerCase().indexOf(materialToSearch) !== -1) {
|
|
1871
|
-
|
|
1906
|
+
if (variation.material instanceof THREE__namespace.Material) {
|
|
1907
|
+
mesh.material[m] = variation.material;
|
|
1908
|
+
}
|
|
1909
|
+
else {
|
|
1910
|
+
mesh.material[m] = _this._setMeshMaterialFromVariation(mesh.material[m].name, variation, usePbr);
|
|
1911
|
+
}
|
|
1872
1912
|
}
|
|
1873
1913
|
}
|
|
1874
1914
|
}
|
|
1875
1915
|
else {
|
|
1876
1916
|
if (mesh.material.name.toLowerCase().indexOf(materialToSearch) !== -1) {
|
|
1877
|
-
|
|
1917
|
+
if (variation.material instanceof THREE__namespace.Material) {
|
|
1918
|
+
mesh.material = variation.material;
|
|
1919
|
+
}
|
|
1920
|
+
else {
|
|
1921
|
+
mesh.material = _this._setMeshMaterialFromVariation(mesh.material.name, variation, usePbr);
|
|
1922
|
+
}
|
|
1878
1923
|
}
|
|
1879
1924
|
}
|
|
1880
1925
|
}
|
|
@@ -2321,6 +2366,7 @@
|
|
|
2321
2366
|
return [4 /*yield*/, Promise.all(promises)];
|
|
2322
2367
|
case 5:
|
|
2323
2368
|
_a.sent();
|
|
2369
|
+
this._preloadMaterials();
|
|
2324
2370
|
if (this._answers.length > 0) {
|
|
2325
2371
|
return [2 /*return*/];
|
|
2326
2372
|
}
|
|
@@ -2328,7 +2374,6 @@
|
|
|
2328
2374
|
return [4 /*yield*/, this._build()];
|
|
2329
2375
|
case 6:
|
|
2330
2376
|
build = _a.sent();
|
|
2331
|
-
this._cleanUp();
|
|
2332
2377
|
return [2 /*return*/, build];
|
|
2333
2378
|
case 7: throw 'GLB source not found!';
|
|
2334
2379
|
case 8: return [3 /*break*/, 10];
|
|
@@ -2360,7 +2405,7 @@
|
|
|
2360
2405
|
this._selections = selections;
|
|
2361
2406
|
this._decos = decos;
|
|
2362
2407
|
this._linkSelectionsAndDecos();
|
|
2363
|
-
this._preloadMaterials(
|
|
2408
|
+
this._preloadMaterials();
|
|
2364
2409
|
return [4 /*yield*/, this._build()];
|
|
2365
2410
|
case 3:
|
|
2366
2411
|
build = _a.sent();
|
|
@@ -2386,12 +2431,14 @@
|
|
|
2386
2431
|
};
|
|
2387
2432
|
Builder.prototype.selectSelection = function (selection) {
|
|
2388
2433
|
return __awaiter(this, void 0, void 0, function () {
|
|
2434
|
+
var questionsAndAnswers;
|
|
2389
2435
|
return __generator(this, function (_a) {
|
|
2390
2436
|
switch (_a.label) {
|
|
2391
2437
|
case 0: return [4 /*yield*/, this._configuratorService.selectSelection(selection, false)];
|
|
2392
2438
|
case 1:
|
|
2393
|
-
_a.sent();
|
|
2394
|
-
this.
|
|
2439
|
+
questionsAndAnswers = _a.sent();
|
|
2440
|
+
this._answers = questionsAndAnswers.answers;
|
|
2441
|
+
this.answersReceived.next(questionsAndAnswers.answers);
|
|
2395
2442
|
return [2 /*return*/];
|
|
2396
2443
|
}
|
|
2397
2444
|
});
|
|
@@ -2414,16 +2461,17 @@
|
|
|
2414
2461
|
};
|
|
2415
2462
|
Builder.prototype.selectAnswer = function (answer) {
|
|
2416
2463
|
return __awaiter(this, void 0, void 0, function () {
|
|
2417
|
-
var
|
|
2418
|
-
return __generator(this, function (
|
|
2419
|
-
switch (
|
|
2464
|
+
var questionsAndAnswers;
|
|
2465
|
+
return __generator(this, function (_a) {
|
|
2466
|
+
switch (_a.label) {
|
|
2420
2467
|
case 0: return [4 /*yield*/, this._configuratorService.selectAnswer(answer, false)];
|
|
2421
2468
|
case 1:
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2469
|
+
questionsAndAnswers = _a.sent();
|
|
2470
|
+
this._answers = questionsAndAnswers.answers;
|
|
2471
|
+
this.answersReceived.next(questionsAndAnswers.answers);
|
|
2472
|
+
if (questionsAndAnswers.answers.length === 0) {
|
|
2473
|
+
this._build();
|
|
2474
|
+
}
|
|
2427
2475
|
return [2 /*return*/];
|
|
2428
2476
|
}
|
|
2429
2477
|
});
|
|
@@ -2477,8 +2525,8 @@
|
|
|
2477
2525
|
return '';
|
|
2478
2526
|
}
|
|
2479
2527
|
};
|
|
2480
|
-
Builder.prototype._preloadMaterials = function (
|
|
2481
|
-
this._variationHelper.preloadVariations(
|
|
2528
|
+
Builder.prototype._preloadMaterials = function () {
|
|
2529
|
+
this._variationHelper.preloadVariations(__spreadArray([], __read(new Set(this._decos.filter(function (d) { return d.gameObjectName !== undefined; }).map(function (d) { return d.gameObjectName; })))));
|
|
2482
2530
|
};
|
|
2483
2531
|
Builder.prototype._setInstanceId = function (sku, instanceId, goodId) {
|
|
2484
2532
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -2603,7 +2651,9 @@
|
|
|
2603
2651
|
this._log('remove from scene');
|
|
2604
2652
|
this._scene.remove(obj);
|
|
2605
2653
|
ObjectUtils.DisposeObject(this._source);
|
|
2654
|
+
// this._cleanUp();
|
|
2606
2655
|
this._log('ready!');
|
|
2656
|
+
this.modelLoaded.next(obj);
|
|
2607
2657
|
return [2 /*return*/, obj];
|
|
2608
2658
|
case 2: throw 'No adjustables found!';
|
|
2609
2659
|
}
|