@colijnit/configurator 259.1.5 → 260.1.1

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.
Files changed (38) hide show
  1. package/README.md +28 -28
  2. package/bundles/colijnit-configurator.umd.js +112 -49
  3. package/bundles/colijnit-configurator.umd.js.map +1 -1
  4. package/colijnit-configurator-260.1.0.tgz +0 -0
  5. package/colijnit-configurator-260.1.1.tgz +0 -0
  6. package/configurator/index.html +14 -0
  7. package/configurator/main.js +3683 -0
  8. package/configurator/main.js.map +1 -0
  9. package/configurator/polyfills.js +5683 -0
  10. package/configurator/polyfills.js.map +1 -0
  11. package/configurator/runtime.js +149 -0
  12. package/configurator/runtime.js.map +1 -0
  13. package/configurator/styles.css +48 -0
  14. package/configurator/styles.css.map +1 -0
  15. package/configurator/vendor.js +209342 -0
  16. package/configurator/vendor.js.map +1 -0
  17. package/esm2015/app/builder.js +5 -9
  18. package/esm2015/app/components/answers/answer/answer.component.js +18 -18
  19. package/esm2015/app/components/shared/loader/loader.component.js +12 -12
  20. package/esm2015/app/components/shared/shared.module.js +1 -1
  21. package/esm2015/app/directives/visibility-observer-master.directive.js +1 -1
  22. package/esm2015/app/directives/visibility-observer.directive.js +1 -1
  23. package/esm2015/app/services/configurator.service.js +1 -1
  24. package/esm2015/app/services/image-cache.service.js +1 -1
  25. package/esm2015/helper/variation-helper.js +61 -35
  26. package/esm2015/model/material.js +1 -1
  27. package/esm2015/model/variation-settings.js +1 -1
  28. package/esm2015/model/variation.js +1 -1
  29. package/esm2015/utils/asset.utils.js +1 -1
  30. package/esm2015/utils/file.utils.js +1 -1
  31. package/esm2015/utils/image.utils.js +1 -1
  32. package/esm2015/utils/threed.utils.js +1 -1
  33. package/esm2015/utils/variation-utils.js +28 -1
  34. package/fesm2015/colijnit-configurator.js +119 -70
  35. package/fesm2015/colijnit-configurator.js.map +1 -1
  36. package/helper/variation-helper.d.ts +2 -1
  37. package/package.json +3 -3
  38. 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
- const partSettings = yield VariationUtils.LoadVariation(this.assetPath, parts[i].decoNode.gameObjectName || parts[i].decoId);
1135
- if (partSettings) {
1136
- const partVariation = new Variation();
1137
- partVariation.decoId = parseFloat(parts[i].decoNode.id);
1138
- partVariation.brandId = parts[i].decoNode.brandId;
1139
- partVariation.gameObjectName = parts[i].decoNode.gameObjectName;
1140
- partVariation.material = yield AssetUtils.CreateMaterialFromAsset(partSettings);
1141
- // parts[i].variation = partVariation;
1142
- this._applyMaterialPart(obj, partVariation, parts[i].node, usePbr);
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
- variationPromise.push(this.loadTheVariation(variations[j].gameObjectName || parts[i].decoId)
1172
- .then((variationSettings) => {
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
- for (let i = 0; i < fileNames.length; i++) {
1215
- const fileName = fileNames[i];
1216
- if (fileName && !this.get(fileName)) {
1217
- const settings = new VariationSettings();
1218
- settings.id = fileName;
1219
- settings.loading = true;
1220
- this._variations.push(settings);
1221
- VariationUtils.LoadVariation(this.assetPath, fileName)
1222
- .then((variationSettings) => {
1223
- settings.loading = false;
1224
- if (variationSettings) {
1225
- // this.set(variationSettings);
1226
- settings.copyFrom(variationSettings);
1227
- }
1228
- settings.loaded.next(settings);
1229
- })
1230
- .catch((err) => {
1231
- console.error(`Error loading variation ${fileName}:`, err);
1232
- settings.loading = false;
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.gameObjectName))];
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
  }
@@ -2113,18 +2166,14 @@ class Builder {
2113
2166
  if (lastAdded) {
2114
2167
  if (newPart) {
2115
2168
  if (decoNode.materialId) {
2116
- if (!lastAdded.variations.find(v => v.id === decoNode.id)) {
2117
- lastAdded.variations.push(decoNode);
2118
- }
2169
+ lastAdded.variations.push(decoNode);
2119
2170
  }
2120
2171
  else {
2121
2172
  lastAdded.variations = [decoNode];
2122
2173
  }
2123
2174
  }
2124
2175
  else {
2125
- if (!lastAdded.variations.find(v => v.id === decoNode.id)) {
2126
- lastAdded.variations.push(decoNode);
2127
- }
2176
+ lastAdded.variations.push(decoNode);
2128
2177
  }
2129
2178
  newPart = false;
2130
2179
  }
@@ -2480,23 +2529,23 @@ class AnswerComponent {
2480
2529
  AnswerComponent.decorators = [
2481
2530
  { type: Component, args: [{
2482
2531
  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>
2532
+ template: `
2533
+ <div class="ione-configurator">
2534
+ <div class="answer-wrapper">
2535
+ <div class="answer-content" @answerAppear>
2536
+ <div class="answer-thumbnail">
2537
+ <rp-loader *ngIf="answer.imageData === ''"></rp-loader>
2538
+ <img *ngIf="answer.imageData !== '' && answer.imageData !== null" class="answer-img" [src]="answer.imageData">
2539
+ </div>
2540
+ <div class="answer-title-wrapper">
2541
+ <span class="answer-title" [textContent]="answer.commercialAnswer"></span>
2542
+ </div>
2543
+ <div class="price">
2544
+ <span class="price-value"></span>
2545
+ </div>
2546
+ </div>
2547
+ </div>
2548
+ </div>
2500
2549
  `,
2501
2550
  animations: [
2502
2551
  trigger('answerAppear', [
@@ -2623,17 +2672,17 @@ class LoaderComponent {
2623
2672
  LoaderComponent.decorators = [
2624
2673
  { type: Component, args: [{
2625
2674
  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>
2675
+ template: `
2676
+ <div class="loader-wrapper">
2677
+ <svg xmlns="http://www.w3.org/2000/svg" width="44" height="44" viewBox="0 0 44 44" stroke="#3760a1">
2678
+ <g fill="none" fill-rule="evenodd" stroke-width="3">
2679
+ <circle class="ripple1" cx="22" cy="22" r="19">
2680
+ </circle>
2681
+ <circle class="ripple2" cx="22" cy="22" r="19">
2682
+ </circle>
2683
+ </g>
2684
+ </svg>
2685
+ </div>
2637
2686
  `,
2638
2687
  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
2688
  },] }