@colijnit/configurator 260.1.0 → 260.1.2

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 CHANGED
@@ -1,28 +1,28 @@
1
- # Catalog
2
-
3
- This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.1.2.
4
-
5
- ## Development server
6
-
7
- Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8
-
9
- ## Code scaffolding
10
-
11
- Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|module`.
12
-
13
- ## Build
14
-
15
- Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
16
-
17
- ## Running unit tests
18
-
19
- Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20
-
21
- ## Running end-to-end tests
22
-
23
- Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24
- Before running the tests make sure you are serving the app via `ng serve`.
25
-
26
- ## Further help
27
-
28
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
1
+ # Catalog
2
+
3
+ This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.1.2.
4
+
5
+ ## Development server
6
+
7
+ Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8
+
9
+ ## Code scaffolding
10
+
11
+ Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|module`.
12
+
13
+ ## Build
14
+
15
+ Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
16
+
17
+ ## Running unit tests
18
+
19
+ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20
+
21
+ ## Running end-to-end tests
22
+
23
+ Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24
+ Before running the tests make sure you are serving the app via `ng serve`.
25
+
26
+ ## Further help
27
+
28
+ To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
@@ -1454,6 +1454,45 @@
1454
1454
  });
1455
1455
  });
1456
1456
  };
1457
+ VariationUtils.LoadVariationByUrl = function (materialCode, url) {
1458
+ return __awaiter(this, void 0, void 0, function () {
1459
+ var file, settings, err_2;
1460
+ return __generator(this, function (_a) {
1461
+ switch (_a.label) {
1462
+ case 0:
1463
+ if (!url) {
1464
+ return [2 /*return*/, null];
1465
+ }
1466
+ if (!url.includes('ione3d')) {
1467
+ url = url.concat('.ione3d');
1468
+ }
1469
+ if (!window.hasOwnProperty('downloadVariation')) {
1470
+ console.error('downloadVariation not defined in window global');
1471
+ throw new Error('downloadVariation not defined in window global');
1472
+ }
1473
+ if (this.MaterialCache.has(materialCode)) {
1474
+ return [2 /*return*/, this.MaterialCache.get(materialCode)];
1475
+ }
1476
+ _a.label = 1;
1477
+ case 1:
1478
+ _a.trys.push([1, 4, , 5]);
1479
+ return [4 /*yield*/, window.downloadVariation(url)];
1480
+ case 2:
1481
+ file = _a.sent();
1482
+ return [4 /*yield*/, VariationUtils.GetVariationSettingsFromFile(materialCode, file)];
1483
+ case 3:
1484
+ settings = _a.sent();
1485
+ this.MaterialCache.set(materialCode, settings);
1486
+ return [2 /*return*/, settings];
1487
+ case 4:
1488
+ err_2 = _a.sent();
1489
+ console.error('Error loading variation:', err_2);
1490
+ throw err_2;
1491
+ case 5: return [2 /*return*/];
1492
+ }
1493
+ });
1494
+ });
1495
+ };
1457
1496
  // public static GetMaterialFromName(variationFolder: string, material: any): Promise<MeshStandardMaterial> {
1458
1497
  // return new Promise((resolve: Function) => {
1459
1498
  // if (!material) {
@@ -1943,37 +1982,45 @@
1943
1982
  return __generator(this, function (_b) {
1944
1983
  switch (_b.label) {
1945
1984
  case 0:
1946
- _b.trys.push([0, 6, , 7]);
1985
+ _b.trys.push([0, 9, , 10]);
1947
1986
  len = parts.length;
1948
1987
  i = 0;
1949
1988
  _b.label = 1;
1950
1989
  case 1:
1951
- if (!(i < len)) return [3 /*break*/, 5];
1952
- if (!(parts[i].decoNode && parts[i].decoNode.gameObjectName && parts[i].decoNode.type === decoNodeType_enum.DecoNodeType.Part)) return [3 /*break*/, 4];
1953
- return [4 /*yield*/, VariationUtils.LoadVariation(this.assetPath, parts[i].decoNode.gameObjectName || parts[i].decoId)];
1990
+ if (!(i < len)) return [3 /*break*/, 8];
1991
+ partSettings = void 0;
1992
+ if (!(parts[i].decoNode && parts[i].decoNode.materialUrl && parts[i].decoNode.type === decoNodeType_enum.DecoNodeType.Part)) return [3 /*break*/, 3];
1993
+ return [4 /*yield*/, VariationUtils.LoadVariationByUrl(parts[i].decoNode.materialCode, parts[i].decoNode.materialUrl)];
1954
1994
  case 2:
1955
1995
  partSettings = _b.sent();
1956
- if (!partSettings) return [3 /*break*/, 4];
1996
+ _b.label = 3;
1997
+ case 3:
1998
+ if (!(parts[i].decoNode && parts[i].decoNode.gameObjectName && parts[i].decoNode.type === decoNodeType_enum.DecoNodeType.Part)) return [3 /*break*/, 5];
1999
+ return [4 /*yield*/, VariationUtils.LoadVariation(this.assetPath, parts[i].decoNode.gameObjectName || parts[i].decoId)];
2000
+ case 4:
2001
+ partSettings = _b.sent();
2002
+ _b.label = 5;
2003
+ case 5:
2004
+ if (!partSettings) return [3 /*break*/, 7];
1957
2005
  partVariation = new Variation();
1958
2006
  partVariation.decoId = parseFloat(parts[i].decoNode.id);
1959
2007
  partVariation.brandId = parts[i].decoNode.brandId;
1960
2008
  partVariation.gameObjectName = parts[i].decoNode.gameObjectName;
1961
2009
  _a = partVariation;
1962
2010
  return [4 /*yield*/, AssetUtils.CreateMaterialFromAsset(partSettings)];
1963
- case 3:
2011
+ case 6:
1964
2012
  _a.material = _b.sent();
1965
- // parts[i].variation = partVariation;
1966
2013
  this._applyMaterialPart(obj, partVariation, parts[i].node, usePbr);
1967
- _b.label = 4;
1968
- case 4:
2014
+ _b.label = 7;
2015
+ case 7:
1969
2016
  i++;
1970
2017
  return [3 /*break*/, 1];
1971
- case 5: return [3 /*break*/, 7];
1972
- case 6:
2018
+ case 8: return [3 /*break*/, 10];
2019
+ case 9:
1973
2020
  e_1 = _b.sent();
1974
2021
  console.error(e_1);
1975
- return [3 /*break*/, 7];
1976
- case 7: return [2 /*return*/];
2022
+ return [3 /*break*/, 10];
2023
+ case 10: return [2 /*return*/];
1977
2024
  }
1978
2025
  });
1979
2026
  });
@@ -2006,8 +2053,14 @@
2006
2053
  lastKnownVariations = [];
2007
2054
  variationPromise = [];
2008
2055
  _loop_2 = function (j) {
2009
- variationPromise.push(this_1.loadTheVariation(variations[j].gameObjectName || parts[i].decoId)
2010
- .then(function (variationSettings) {
2056
+ var variationsName = '';
2057
+ if (variations[j].materialCode && variations[j].materialUrl) {
2058
+ variationsName = variations[j].materialCode;
2059
+ }
2060
+ else {
2061
+ variationsName = variations[j].gameObjectName || parts[i].decoId;
2062
+ }
2063
+ variationPromise.push(this_1.loadTheVariation(variationsName).then(function (variationSettings) {
2011
2064
  var newVariation = new Variation();
2012
2065
  newVariation.decoId = variations[j].constructor.name === 'Variation' ? variations[j].decoId : parseFloat(variations[j].id);
2013
2066
  newVariation.node = variations[j].constructor.name === 'Variation' ? variations[j].node : variations[j].nodeId;
@@ -2073,33 +2126,47 @@
2073
2126
  }
2074
2127
  };
2075
2128
  VariationHelper.prototype.preloadVariations = function (fileNames) {
2076
- var _loop_3 = function (i) {
2077
- var fileName = fileNames[i];
2078
- if (fileName && !this_2.get(fileName)) {
2079
- var settings_1 = new VariationSettings();
2080
- settings_1.id = fileName;
2081
- settings_1.loading = true;
2082
- this_2._variations.push(settings_1);
2083
- VariationUtils.LoadVariation(this_2.assetPath, fileName)
2084
- .then(function (variationSettings) {
2085
- settings_1.loading = false;
2086
- if (variationSettings) {
2087
- // this.set(variationSettings);
2088
- settings_1.copyFrom(variationSettings);
2089
- }
2090
- settings_1.loaded.next(settings_1);
2091
- })
2092
- .catch(function (err) {
2093
- console.error("Error loading variation " + fileName + ":", err);
2094
- settings_1.loading = false;
2095
- settings_1.loaded.next(null);
2096
- });
2129
+ var _this = this;
2130
+ fileNames.forEach(function (node) {
2131
+ if (node.materialUrl) {
2132
+ if (node.materialCode && !_this.get(node.materialCode)) {
2133
+ var settings_1 = new VariationSettings();
2134
+ settings_1.id = node.materialCode;
2135
+ settings_1.loading = true;
2136
+ _this._variations.push(settings_1);
2137
+ VariationUtils.LoadVariationByUrl(node.materialCode, node.materialUrl).then(function (variationSettings) {
2138
+ settings_1.loading = false;
2139
+ if (variationSettings) {
2140
+ settings_1.copyFrom(variationSettings);
2141
+ }
2142
+ settings_1.loaded.next(settings_1);
2143
+ }).catch(function (err) {
2144
+ console.error("Error loading variation " + node.materialCode + ":", err);
2145
+ settings_1.loading = false;
2146
+ settings_1.loaded.next(null);
2147
+ });
2148
+ }
2097
2149
  }
2098
- };
2099
- var this_2 = this;
2100
- for (var i = 0; i < fileNames.length; i++) {
2101
- _loop_3(i);
2102
- }
2150
+ else if (node.gameObjectName) {
2151
+ if (!_this.get(node.gameObjectName)) {
2152
+ var settings_2 = new VariationSettings();
2153
+ settings_2.id = node.gameObjectName;
2154
+ settings_2.loading = true;
2155
+ _this._variations.push(settings_2);
2156
+ VariationUtils.LoadVariation(_this.assetPath, node.gameObjectName).then(function (variationSettings) {
2157
+ settings_2.loading = false;
2158
+ if (variationSettings) {
2159
+ settings_2.copyFrom(variationSettings);
2160
+ }
2161
+ settings_2.loaded.next(settings_2);
2162
+ }).catch(function (err) {
2163
+ console.error("Error loading variation " + node.gameObjectName + ":", err);
2164
+ settings_2.loading = false;
2165
+ settings_2.loaded.next(null);
2166
+ });
2167
+ }
2168
+ }
2169
+ });
2103
2170
  };
2104
2171
  VariationHelper.prototype.loadTheVariation = function (fileName) {
2105
2172
  return __awaiter(this, void 0, void 0, function () {
@@ -2206,7 +2273,9 @@
2206
2273
  var materialToSearch = !!variation.materialId ? variation.materialId.toLowerCase() : 'default';
2207
2274
  if (Array.isArray(mesh.material)) { // multimaterial support
2208
2275
  for (var m = 0, mlen = mesh.material.length; m < mlen; m++) {
2209
- if (mesh.material[m].name.toLowerCase().indexOf(materialToSearch) !== -1) {
2276
+ // if (mesh.material[m].name.toLowerCase().indexOf(materialToSearch) !== -1) {
2277
+ if ((variation.materialId && mesh.material[m].name.toLowerCase() === materialToSearch) ||
2278
+ (!variation.materialId && mesh.material[m].name.toLowerCase().indexOf(materialToSearch) !== -1)) {
2210
2279
  if ((variation.material instanceof Material || variation.material.constructor.name === 'Material') && variation.material.isMaterial) {
2211
2280
  // it's a THREE.Material
2212
2281
  mesh.material[m] = variation.material;
@@ -2224,7 +2293,9 @@
2224
2293
  }
2225
2294
  }
2226
2295
  else {
2227
- if (mesh.material.name && mesh.material.name.toLowerCase().indexOf(materialToSearch) !== -1) {
2296
+ // if (mesh.material.name && mesh.material.name.toLowerCase().indexOf(materialToSearch) !== -1) {
2297
+ if ((variation.materialId && mesh.material.name.toLowerCase() === materialToSearch) ||
2298
+ (!variation.materialId && mesh.material.name.toLowerCase().indexOf(materialToSearch) !== -1)) {
2228
2299
  if ((variation.material instanceof Material || variation.material.constructor.name === 'Material') && variation.material.isMaterial) {
2229
2300
  // it's a THREE.Material
2230
2301
  mesh.material = variation.material;
@@ -2966,8 +3037,8 @@
2966
3037
  Builder.prototype._preloadMaterials = function () {
2967
3038
  if (this._decos && this._decos.length) {
2968
3039
  var materials = __spreadArray([], __read(new Set(this._decos
2969
- .filter(function (d) { return d.gameObjectName && d.type === decoNodeType_enum.DecoNodeType.Variation; })
2970
- .map(function (d) { return d.gameObjectName; }))));
3040
+ .filter(function (d) { return (d.gameObjectName || d.materialUrl) && d.type === decoNodeType_enum.DecoNodeType.Variation; })
3041
+ .map(function (d) { return d; }))));
2971
3042
  this._variationHelper.preloadVariations(materials);
2972
3043
  }
2973
3044
  };
@@ -3126,11 +3197,11 @@
3126
3197
  selectionOfArticle.gameObject &&
3127
3198
  selectionOfArticle.gameObject.length > 0;
3128
3199
  // get generic variations
3129
- var globalVariations = this._selections
3130
- .filter(function (s) { return (s.generic || adjustableSelections.length === 1) && s.decoNode.variation && !s.decoNode.type; })
3200
+ var globalVariations = selections
3201
+ .filter(function (s) { return (s.generic || adjustableSelections.length === 1) && s.decoNode.variation; } /*&& !s.decoNode.type*/)
3131
3202
  .map(function (value, index, array) {
3132
3203
  // find selection of variation
3133
- var sel = _this._selections.find(function (s) { return s.artNodeIdDeco === value.decoNode.variation.parentId; });
3204
+ var sel = selections.find(function (s) { return s.artNodeIdDeco === value.decoNode.variation.parentId; });
3134
3205
  if (sel) {
3135
3206
  value.decoNode.variation.supplierArticleNr = sel.supplierArticleNr;
3136
3207
  }
@@ -3159,7 +3230,7 @@
3159
3230
  var previousPresLevel = -1;
3160
3231
  var positioning;
3161
3232
  var optionText;
3162
- var _loop_1 = function (i) {
3233
+ for (var i = 0; i < len; i++) {
3163
3234
  var selection = selections[i];
3164
3235
  if (selection.presentationLevel === 1) {
3165
3236
  positioning = selection.hdecoPositioning;
@@ -3170,37 +3241,33 @@
3170
3241
  }
3171
3242
  if (selection.decoNode) {
3172
3243
  if (selection.decoNode.type === decoNodeType_enum.DecoNodeType.Variation) {
3173
- var decoNode_1 = selection.decoNode;
3174
- decoNode_1.optionText = optionText;
3244
+ var decoNode = selection.decoNode;
3245
+ decoNode.optionText = optionText;
3175
3246
  // find selection of variation and set materialId in case of multimaterial
3176
- decoNode_1.materialId = this_1._getMaterialIdFromParent(decoNode_1.nodeId);
3247
+ decoNode.materialId = this._getMaterialIdFromParent(decoNode.nodeId);
3177
3248
  if (lastAdded) {
3178
3249
  if (newPart) {
3179
- if (decoNode_1.materialId) {
3180
- if (!lastAdded.variations.find(function (v) { return v.id === decoNode_1.id; })) {
3181
- lastAdded.variations.push(decoNode_1);
3182
- }
3250
+ if (decoNode.materialId) {
3251
+ lastAdded.variations.push(decoNode);
3183
3252
  }
3184
3253
  else {
3185
- lastAdded.variations = [decoNode_1];
3254
+ lastAdded.variations = [decoNode];
3186
3255
  }
3187
3256
  }
3188
3257
  else {
3189
- if (!lastAdded.variations.find(function (v) { return v.id === decoNode_1.id; })) {
3190
- lastAdded.variations.push(decoNode_1);
3191
- }
3258
+ lastAdded.variations.push(decoNode);
3192
3259
  }
3193
3260
  newPart = false;
3194
3261
  }
3195
- else {
3196
- if (globalVariationsRewrite) {
3197
- globalVariations.length = 0;
3198
- globalVariationsRewrite = false;
3199
- }
3200
- if (!globalVariations.find(function (v) { return v.id === decoNode_1.id; })) {
3201
- globalVariations.push(decoNode_1);
3202
- }
3203
- }
3262
+ // else {
3263
+ // if (globalVariationsRewrite) {
3264
+ // globalVariations.length = 0;
3265
+ // globalVariationsRewrite = false;
3266
+ // }
3267
+ // if (!globalVariations.find(v => v.id === decoNode.id)) {
3268
+ // globalVariations.push(decoNode);
3269
+ // }
3270
+ // }
3204
3271
  // const variation: FurniturePartVariation = new FurniturePartVariation();
3205
3272
  // variation.BrandId = selection.decoNode.brandId;
3206
3273
  // variation.Description = selection.decoNode.gameObjectName;
@@ -3213,7 +3280,7 @@
3213
3280
  selection.decoNode.gameObjectName.length) || (isArticleWithMaterial)) {
3214
3281
  if (selection.decoNode.kind === decoNodeKind_enum.DecoNodeKind.Adjustable || (isArticleWithMaterial)) {
3215
3282
  selection.variations = globalVariations;
3216
- this_1._adjustables.push(selection);
3283
+ this._adjustables.push(selection);
3217
3284
  if (!lastAdded || (lastAdded.nodeId !== selection.nodeId || lastAdded.node !== selection.node)) {
3218
3285
  newPart = true;
3219
3286
  }
@@ -3225,7 +3292,7 @@
3225
3292
  if (lastAdjustable) {
3226
3293
  lastAdjustable.addables.push(selection);
3227
3294
  }
3228
- this_1._addables.push(selection);
3295
+ this._addables.push(selection);
3229
3296
  if (!lastAdded || (lastAdded.nodeId !== selection.nodeId || lastAdded.node !== selection.node)) {
3230
3297
  newPart = true;
3231
3298
  }
@@ -3234,10 +3301,6 @@
3234
3301
  }
3235
3302
  }
3236
3303
  previousPresLevel = selection.presentationLevel;
3237
- };
3238
- var this_1 = this;
3239
- for (var i = 0; i < len; i++) {
3240
- _loop_1(i);
3241
3304
  }
3242
3305
  // this._upsertFurniture(this.activeInstance,
3243
3306
  // {Variations: usedVariations});
@@ -3445,23 +3508,23 @@
3445
3508
  return;
3446
3509
  }
3447
3510
  var len = this._selections.length;
3448
- var _loop_2 = function (i) {
3511
+ var _loop_1 = function (i) {
3449
3512
  // const id: string = this.selections[i].artNodeIdDeco;
3450
- var deco = this_2._decos.find(function (d) { return d.nodeId === _this._selections[i].node; });
3513
+ var deco = this_1._decos.find(function (d) { return d.nodeId === _this._selections[i].node; });
3451
3514
  if (!deco) {
3452
3515
  deco = new decoNode.DecoNode();
3453
3516
  }
3454
3517
  if (deco.type !== decoNodeType_enum.DecoNodeType.Variation) {
3455
- var variation = this_2._getVariations().find(function (v) { return v.parentId === _this._selections[i].artNodeIdDeco; });
3518
+ var variation = this_1._getVariations().find(function (v) { return v.parentId === _this._selections[i].artNodeIdDeco; });
3456
3519
  if (variation) {
3457
3520
  deco.variation = variation;
3458
3521
  }
3459
3522
  }
3460
- this_2._selections[i].decoNode = deco;
3523
+ this_1._selections[i].decoNode = deco;
3461
3524
  };
3462
- var this_2 = this;
3525
+ var this_1 = this;
3463
3526
  for (var i = 0; i < len; i++) {
3464
- _loop_2(i);
3527
+ _loop_1(i);
3465
3528
  }
3466
3529
  };
3467
3530
  Builder.prototype._getVariations = function () {