@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 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 () {
@@ -2966,8 +3033,8 @@
2966
3033
  Builder.prototype._preloadMaterials = function () {
2967
3034
  if (this._decos && this._decos.length) {
2968
3035
  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; }))));
3036
+ .filter(function (d) { return (d.gameObjectName || d.materialUrl) && d.type === decoNodeType_enum.DecoNodeType.Variation; })
3037
+ .map(function (d) { return d; }))));
2971
3038
  this._variationHelper.preloadVariations(materials);
2972
3039
  }
2973
3040
  };