@colijnit/configurator 259.1.5 → 261.1.0
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/README.md +28 -28
- package/bundles/colijnit-configurator.umd.js +110 -43
- package/bundles/colijnit-configurator.umd.js.map +1 -1
- package/esm2015/app/builder.js +3 -3
- package/esm2015/app/components/answers/answer/answer.component.js +18 -18
- package/esm2015/app/components/shared/loader/loader.component.js +12 -12
- package/esm2015/app/components/shared/shared.module.js +1 -1
- package/esm2015/app/directives/visibility-observer-master.directive.js +1 -1
- package/esm2015/app/directives/visibility-observer.directive.js +1 -1
- package/esm2015/app/services/configurator.service.js +1 -1
- package/esm2015/app/services/image-cache.service.js +1 -1
- package/esm2015/helper/variation-helper.js +61 -35
- package/esm2015/model/material.js +1 -1
- package/esm2015/model/variation-settings.js +1 -1
- package/esm2015/model/variation.js +1 -1
- package/esm2015/utils/asset.utils.js +1 -1
- package/esm2015/utils/file.utils.js +1 -1
- package/esm2015/utils/image.utils.js +1 -1
- package/esm2015/utils/threed.utils.js +1 -1
- package/esm2015/utils/variation-utils.js +28 -1
- package/fesm2015/colijnit-configurator.js +117 -64
- package/fesm2015/colijnit-configurator.js.map +1 -1
- package/helper/variation-helper.d.ts +2 -1
- package/package.json +3 -3
- package/utils/variation-utils.d.ts +1 -0
|
@@ -769,6 +769,33 @@ class VariationUtils {
|
|
|
769
769
|
}
|
|
770
770
|
});
|
|
771
771
|
}
|
|
772
|
+
static LoadVariationByUrl(materialCode, url) {
|
|
773
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
774
|
+
if (!url) {
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
777
|
+
if (!url.includes('ione3d')) {
|
|
778
|
+
url = url.concat('.ione3d');
|
|
779
|
+
}
|
|
780
|
+
if (!window.hasOwnProperty('downloadVariation')) {
|
|
781
|
+
console.error('downloadVariation not defined in window global');
|
|
782
|
+
throw new Error('downloadVariation not defined in window global');
|
|
783
|
+
}
|
|
784
|
+
if (this.MaterialCache.has(materialCode)) {
|
|
785
|
+
return this.MaterialCache.get(materialCode);
|
|
786
|
+
}
|
|
787
|
+
try {
|
|
788
|
+
const file = yield window.downloadVariation(url);
|
|
789
|
+
const settings = yield VariationUtils.GetVariationSettingsFromFile(materialCode, file);
|
|
790
|
+
this.MaterialCache.set(materialCode, settings);
|
|
791
|
+
return settings;
|
|
792
|
+
}
|
|
793
|
+
catch (err) {
|
|
794
|
+
console.error('Error loading variation:', err);
|
|
795
|
+
throw err;
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
}
|
|
772
799
|
// public static GetMaterialFromName(variationFolder: string, material: any): Promise<MeshStandardMaterial> {
|
|
773
800
|
// return new Promise((resolve: Function) => {
|
|
774
801
|
// if (!material) {
|
|
@@ -1130,17 +1157,20 @@ class VariationHelper extends BaseUtils {
|
|
|
1130
1157
|
try {
|
|
1131
1158
|
const len = parts.length;
|
|
1132
1159
|
for (let i = 0; i < len; i++) {
|
|
1160
|
+
let partSettings;
|
|
1161
|
+
if (parts[i].decoNode && parts[i].decoNode.materialUrl && parts[i].decoNode.type === DecoNodeType.Part) {
|
|
1162
|
+
partSettings = yield VariationUtils.LoadVariationByUrl(parts[i].decoNode.materialCode, parts[i].decoNode.materialUrl);
|
|
1163
|
+
}
|
|
1133
1164
|
if (parts[i].decoNode && parts[i].decoNode.gameObjectName && parts[i].decoNode.type === DecoNodeType.Part) {
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
}
|
|
1165
|
+
partSettings = yield VariationUtils.LoadVariation(this.assetPath, parts[i].decoNode.gameObjectName || parts[i].decoId);
|
|
1166
|
+
}
|
|
1167
|
+
if (partSettings) {
|
|
1168
|
+
const partVariation = new Variation();
|
|
1169
|
+
partVariation.decoId = parseFloat(parts[i].decoNode.id);
|
|
1170
|
+
partVariation.brandId = parts[i].decoNode.brandId;
|
|
1171
|
+
partVariation.gameObjectName = parts[i].decoNode.gameObjectName;
|
|
1172
|
+
partVariation.material = yield AssetUtils.CreateMaterialFromAsset(partSettings);
|
|
1173
|
+
this._applyMaterialPart(obj, partVariation, parts[i].node, usePbr);
|
|
1144
1174
|
}
|
|
1145
1175
|
}
|
|
1146
1176
|
}
|
|
@@ -1168,8 +1198,14 @@ class VariationHelper extends BaseUtils {
|
|
|
1168
1198
|
const lastKnownVariations = [];
|
|
1169
1199
|
const variationPromise = [];
|
|
1170
1200
|
for (let j = 0; j < variations.length; j++) {
|
|
1171
|
-
|
|
1172
|
-
|
|
1201
|
+
let variationsName = '';
|
|
1202
|
+
if (variations[j].materialCode && variations[j].materialUrl) {
|
|
1203
|
+
variationsName = variations[j].materialCode;
|
|
1204
|
+
}
|
|
1205
|
+
else {
|
|
1206
|
+
variationsName = variations[j].gameObjectName || parts[i].decoId;
|
|
1207
|
+
}
|
|
1208
|
+
variationPromise.push(this.loadTheVariation(variationsName).then((variationSettings) => {
|
|
1173
1209
|
const newVariation = new Variation();
|
|
1174
1210
|
newVariation.decoId = variations[j].constructor.name === 'Variation' ? variations[j].decoId : parseFloat(variations[j].id);
|
|
1175
1211
|
newVariation.node = variations[j].constructor.name === 'Variation' ? variations[j].node : variations[j].nodeId;
|
|
@@ -1211,29 +1247,46 @@ class VariationHelper extends BaseUtils {
|
|
|
1211
1247
|
}
|
|
1212
1248
|
}
|
|
1213
1249
|
preloadVariations(fileNames) {
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
settings.
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
settings.loaded.next(null);
|
|
1234
|
-
});
|
|
1250
|
+
fileNames.forEach((node) => {
|
|
1251
|
+
if (node.materialUrl) {
|
|
1252
|
+
if (node.materialCode && !this.get(node.materialCode)) {
|
|
1253
|
+
const settings = new VariationSettings();
|
|
1254
|
+
settings.id = node.materialCode;
|
|
1255
|
+
settings.loading = true;
|
|
1256
|
+
this._variations.push(settings);
|
|
1257
|
+
VariationUtils.LoadVariationByUrl(node.materialCode, node.materialUrl).then((variationSettings) => {
|
|
1258
|
+
settings.loading = false;
|
|
1259
|
+
if (variationSettings) {
|
|
1260
|
+
settings.copyFrom(variationSettings);
|
|
1261
|
+
}
|
|
1262
|
+
settings.loaded.next(settings);
|
|
1263
|
+
}).catch((err) => {
|
|
1264
|
+
console.error(`Error loading variation ${node.materialCode}:`, err);
|
|
1265
|
+
settings.loading = false;
|
|
1266
|
+
settings.loaded.next(null);
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1235
1269
|
}
|
|
1236
|
-
|
|
1270
|
+
else if (node.gameObjectName) {
|
|
1271
|
+
if (!this.get(node.gameObjectName)) {
|
|
1272
|
+
const settings = new VariationSettings();
|
|
1273
|
+
settings.id = node.gameObjectName;
|
|
1274
|
+
settings.loading = true;
|
|
1275
|
+
this._variations.push(settings);
|
|
1276
|
+
VariationUtils.LoadVariation(this.assetPath, node.gameObjectName).then((variationSettings) => {
|
|
1277
|
+
settings.loading = false;
|
|
1278
|
+
if (variationSettings) {
|
|
1279
|
+
settings.copyFrom(variationSettings);
|
|
1280
|
+
}
|
|
1281
|
+
settings.loaded.next(settings);
|
|
1282
|
+
}).catch((err) => {
|
|
1283
|
+
console.error(`Error loading variation ${node.gameObjectName}:`, err);
|
|
1284
|
+
settings.loading = false;
|
|
1285
|
+
settings.loaded.next(null);
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
});
|
|
1237
1290
|
}
|
|
1238
1291
|
loadTheVariation(fileName) {
|
|
1239
1292
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1933,8 +1986,8 @@ class Builder {
|
|
|
1933
1986
|
_preloadMaterials() {
|
|
1934
1987
|
if (this._decos && this._decos.length) {
|
|
1935
1988
|
const materials = [...new Set(this._decos
|
|
1936
|
-
.filter(d => d.gameObjectName && d.type === DecoNodeType.Variation)
|
|
1937
|
-
.map(d => d
|
|
1989
|
+
.filter(d => (d.gameObjectName || d.materialUrl) && d.type === DecoNodeType.Variation)
|
|
1990
|
+
.map(d => d))];
|
|
1938
1991
|
this._variationHelper.preloadVariations(materials);
|
|
1939
1992
|
}
|
|
1940
1993
|
}
|
|
@@ -2480,23 +2533,23 @@ class AnswerComponent {
|
|
|
2480
2533
|
AnswerComponent.decorators = [
|
|
2481
2534
|
{ type: Component, args: [{
|
|
2482
2535
|
selector: 'answer',
|
|
2483
|
-
template: `
|
|
2484
|
-
<div class="ione-configurator">
|
|
2485
|
-
<div class="answer-wrapper">
|
|
2486
|
-
<div class="answer-content" @answerAppear>
|
|
2487
|
-
<div class="answer-thumbnail">
|
|
2488
|
-
<rp-loader *ngIf="answer.imageData === ''"></rp-loader>
|
|
2489
|
-
<img *ngIf="answer.imageData !== '' && answer.imageData !== null" class="answer-img" [src]="answer.imageData">
|
|
2490
|
-
</div>
|
|
2491
|
-
<div class="answer-title-wrapper">
|
|
2492
|
-
<span class="answer-title" [textContent]="answer.commercialAnswer"></span>
|
|
2493
|
-
</div>
|
|
2494
|
-
<div class="price">
|
|
2495
|
-
<span class="price-value"></span>
|
|
2496
|
-
</div>
|
|
2497
|
-
</div>
|
|
2498
|
-
</div>
|
|
2499
|
-
</div>
|
|
2536
|
+
template: `
|
|
2537
|
+
<div class="ione-configurator">
|
|
2538
|
+
<div class="answer-wrapper">
|
|
2539
|
+
<div class="answer-content" @answerAppear>
|
|
2540
|
+
<div class="answer-thumbnail">
|
|
2541
|
+
<rp-loader *ngIf="answer.imageData === ''"></rp-loader>
|
|
2542
|
+
<img *ngIf="answer.imageData !== '' && answer.imageData !== null" class="answer-img" [src]="answer.imageData">
|
|
2543
|
+
</div>
|
|
2544
|
+
<div class="answer-title-wrapper">
|
|
2545
|
+
<span class="answer-title" [textContent]="answer.commercialAnswer"></span>
|
|
2546
|
+
</div>
|
|
2547
|
+
<div class="price">
|
|
2548
|
+
<span class="price-value"></span>
|
|
2549
|
+
</div>
|
|
2550
|
+
</div>
|
|
2551
|
+
</div>
|
|
2552
|
+
</div>
|
|
2500
2553
|
`,
|
|
2501
2554
|
animations: [
|
|
2502
2555
|
trigger('answerAppear', [
|
|
@@ -2623,17 +2676,17 @@ class LoaderComponent {
|
|
|
2623
2676
|
LoaderComponent.decorators = [
|
|
2624
2677
|
{ type: Component, args: [{
|
|
2625
2678
|
selector: 'rp-loader',
|
|
2626
|
-
template: `
|
|
2627
|
-
<div class="loader-wrapper">
|
|
2628
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="44" height="44" viewBox="0 0 44 44" stroke="#3760a1">
|
|
2629
|
-
<g fill="none" fill-rule="evenodd" stroke-width="3">
|
|
2630
|
-
<circle class="ripple1" cx="22" cy="22" r="19">
|
|
2631
|
-
</circle>
|
|
2632
|
-
<circle class="ripple2" cx="22" cy="22" r="19">
|
|
2633
|
-
</circle>
|
|
2634
|
-
</g>
|
|
2635
|
-
</svg>
|
|
2636
|
-
</div>
|
|
2679
|
+
template: `
|
|
2680
|
+
<div class="loader-wrapper">
|
|
2681
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="44" height="44" viewBox="0 0 44 44" stroke="#3760a1">
|
|
2682
|
+
<g fill="none" fill-rule="evenodd" stroke-width="3">
|
|
2683
|
+
<circle class="ripple1" cx="22" cy="22" r="19">
|
|
2684
|
+
</circle>
|
|
2685
|
+
<circle class="ripple2" cx="22" cy="22" r="19">
|
|
2686
|
+
</circle>
|
|
2687
|
+
</g>
|
|
2688
|
+
</svg>
|
|
2689
|
+
</div>
|
|
2637
2690
|
`,
|
|
2638
2691
|
styles: [":host{-webkit-user-select:none;user-select:none;pointer-events:none}:host .loader-wrapper{z-index:1100;position:absolute;width:54px;height:54px}:host .loader-wrapper svg{width:100%;height:100%}:host .loader-wrapper svg .ripple1{transform-origin:center;animation:ripple 1.5s infinite}:host .loader-wrapper svg .ripple2{transform-origin:center;animation:ripple 1.5s infinite .4s}@keyframes ripple{0%{transform:scale(0);opacity:1}to{transform:scale(1);opacity:0}}\n"]
|
|
2639
2692
|
},] }
|