@colijnit/configurator 1.0.16 → 1.0.18
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/app/builder.d.ts +53 -53
- package/app/components/answers/answer/answer.component.d.ts +11 -11
- package/app/components/answers/answers.component.d.ts +8 -8
- package/app/components/answers/answers.module.d.ts +2 -2
- package/app/components/selections/selections.component.d.ts +22 -22
- package/app/components/selections/selections.module.d.ts +2 -2
- package/app/components/shared/loader/loader.component.d.ts +2 -2
- package/app/components/shared/shared.module.d.ts +2 -2
- package/app/directives/visibility-observer-master.directive.d.ts +9 -9
- package/app/directives/visibility-observer.directive.d.ts +13 -13
- package/app/services/configurator.service.d.ts +22 -22
- package/app/services/image-cache.service.d.ts +10 -10
- package/app/services/locator.service.d.ts +4 -4
- package/bundles/colijnit-configurator.umd.js +2455 -2455
- package/bundles/colijnit-configurator.umd.js.map +1 -1
- package/bundles/colijnit-configurator.umd.min.js +2 -2
- package/bundles/colijnit-configurator.umd.min.js.map +1 -1
- package/colijnit-configurator.d.ts +10 -10
- package/colijnit-configurator.metadata.json +1 -1
- package/esm2015/app/builder.js +477 -477
- package/esm2015/app/components/answers/answer/answer.component.js +66 -61
- package/esm2015/app/components/answers/answers.component.js +40 -37
- package/esm2015/app/components/answers/answers.module.js +28 -28
- package/esm2015/app/components/selections/selections.component.js +128 -108
- package/esm2015/app/components/selections/selections.module.js +22 -22
- package/esm2015/app/components/shared/loader/loader.component.js +12 -12
- package/esm2015/app/components/shared/shared.module.js +20 -20
- package/esm2015/app/directives/visibility-observer-master.directive.js +50 -50
- package/esm2015/app/directives/visibility-observer.directive.js +56 -56
- package/esm2015/app/services/configurator.service.js +94 -94
- package/esm2015/app/services/image-cache.service.js +66 -66
- package/esm2015/app/services/locator.service.js +9 -9
- package/esm2015/colijnit-configurator.js +10 -10
- package/esm2015/helper/variation-helper.js +215 -215
- package/esm2015/model/material.js +10 -10
- package/esm2015/model/variation-settings.js +5 -5
- package/esm2015/model/variation.js +2 -2
- package/esm2015/public_api.js +6 -6
- package/esm2015/utils/asset.utils.js +73 -73
- package/esm2015/utils/file.utils.js +138 -138
- package/esm2015/utils/image.utils.js +51 -51
- package/esm2015/utils/object.utils.js +48 -48
- package/esm2015/utils/scene-utils.js +93 -93
- package/esm2015/utils/threed.utils.js +221 -221
- package/esm2015/utils/variation-utils.js +223 -223
- package/esm5/app/builder.js +591 -591
- package/esm5/app/components/answers/answer/answer.component.js +64 -64
- package/esm5/app/components/answers/answers.component.js +27 -27
- package/esm5/app/components/answers/answers.module.js +31 -31
- package/esm5/app/components/selections/selections.component.js +104 -104
- package/esm5/app/components/selections/selections.module.js +25 -25
- package/esm5/app/components/shared/loader/loader.component.js +15 -15
- package/esm5/app/components/shared/shared.module.js +23 -23
- package/esm5/app/directives/visibility-observer-master.directive.js +63 -63
- package/esm5/app/directives/visibility-observer.directive.js +58 -58
- package/esm5/app/services/configurator.service.js +160 -160
- package/esm5/app/services/image-cache.service.js +69 -69
- package/esm5/app/services/locator.service.js +12 -12
- package/esm5/colijnit-configurator.js +10 -10
- package/esm5/helper/variation-helper.js +267 -267
- package/esm5/model/material.js +12 -12
- package/esm5/model/variation-settings.js +7 -7
- package/esm5/model/variation.js +6 -6
- package/esm5/public_api.js +6 -6
- package/esm5/utils/asset.utils.js +105 -105
- package/esm5/utils/file.utils.js +150 -150
- package/esm5/utils/image.utils.js +55 -55
- package/esm5/utils/object.utils.js +55 -55
- package/esm5/utils/scene-utils.js +97 -97
- package/esm5/utils/threed.utils.js +278 -278
- package/esm5/utils/variation-utils.js +326 -326
- package/fesm2015/colijnit-configurator.js +2016 -1988
- package/fesm2015/colijnit-configurator.js.map +1 -1
- package/fesm5/colijnit-configurator.js +2457 -2457
- package/fesm5/colijnit-configurator.js.map +1 -1
- package/helper/variation-helper.d.ts +14 -14
- package/model/material.d.ts +17 -17
- package/model/variation-settings.d.ts +14 -14
- package/model/variation.d.ts +10 -10
- package/package.json +3 -2
- package/public_api.d.ts +6 -6
- package/utils/asset.utils.d.ts +13 -13
- package/utils/file.utils.d.ts +27 -27
- package/utils/image.utils.d.ts +8 -8
- package/utils/object.utils.d.ts +7 -7
- package/utils/scene-utils.d.ts +7 -7
- package/utils/threed.utils.d.ts +16 -16
- package/utils/variation-utils.d.ts +12 -12
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __awaiter, __generator, __extends, __decorate, __values } from 'tslib';
|
|
2
2
|
import { Mesh, ObjectLoader, Camera, Group, TextureLoader, RepeatWrapping, Object3D, Box3, Vector3, Vector2, Euler, Quaternion, Color, Texture, sRGBEncoding, MeshPhongMaterial, MeshStandardMaterial, Scene } from 'three';
|
|
3
|
-
import { Options } from '@colijnit/
|
|
3
|
+
import { Options } from '@colijnit/ioneconnector/build/model/options';
|
|
4
4
|
import { DecoNode } from '@colijnit/configuratorapi/build/model/deco-node';
|
|
5
|
-
import { BusinessObjectFactory } from '@colijnit/
|
|
5
|
+
import { BusinessObjectFactory } from '@colijnit/ioneconnector/build/service/business-object-factory';
|
|
6
6
|
import { Selection } from '@colijnit/configuratorapi/build/model/selection';
|
|
7
7
|
import { DecoNodeType } from '@colijnit/configuratorapi/build/enum/deco-node-type.enum';
|
|
8
8
|
import axios from 'axios';
|
|
@@ -18,2509 +18,2509 @@ import { BehaviorSubject } from 'rxjs';
|
|
|
18
18
|
import { CommonModule } from '@angular/common';
|
|
19
19
|
import { trigger, state, style, transition, animate } from '@angular/animations';
|
|
20
20
|
|
|
21
|
-
var ObjectUtils = /** @class */ (function () {
|
|
22
|
-
function ObjectUtils() {
|
|
23
|
-
}
|
|
24
|
-
ObjectUtils.DisposeMaterial = function (material) {
|
|
25
|
-
var _this = this;
|
|
26
|
-
if (!material) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (Array.isArray(material)) {
|
|
30
|
-
material.forEach(function (mtrl) {
|
|
31
|
-
_this.materialProps
|
|
32
|
-
.filter(function (mapType) { return mtrl[mapType]; })
|
|
33
|
-
.forEach(function (mapType) { return mtrl[mapType].dispose(); });
|
|
34
|
-
mtrl.dispose();
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
this.materialProps
|
|
39
|
-
.filter(function (mapType) { return material[mapType] && material[mapType].dispose; })
|
|
40
|
-
.forEach(function (mapType) { return material[mapType].dispose(); });
|
|
41
|
-
if (material.dispose) {
|
|
42
|
-
material.dispose();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
ObjectUtils.DisposeObject = function (object) {
|
|
47
|
-
var _this = this;
|
|
48
|
-
if (!object) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (object.children.length) {
|
|
52
|
-
object.children.forEach(function (child) { return _this.DisposeObject(child); });
|
|
53
|
-
}
|
|
54
|
-
this.DisposeNode(object);
|
|
55
|
-
};
|
|
56
|
-
ObjectUtils.DisposeNode = function (node) {
|
|
57
|
-
var _this = this;
|
|
58
|
-
node.traverse(function (obj) {
|
|
59
|
-
if (obj instanceof Mesh) {
|
|
60
|
-
if (obj.geometry) {
|
|
61
|
-
obj.geometry.dispose();
|
|
62
|
-
}
|
|
63
|
-
_this.DisposeMaterial(obj.material);
|
|
64
|
-
}
|
|
65
|
-
if (typeof obj.dispose === 'function') {
|
|
66
|
-
// @ts-ignore
|
|
67
|
-
obj.dispose();
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
ObjectUtils.materialProps = ['map', 'lightMap', 'bumpMap', 'normalMap', 'specularMap', 'envMap', 'aoMap', 'roughnessMap', 'metalnessMap'];
|
|
72
|
-
return ObjectUtils;
|
|
21
|
+
var ObjectUtils = /** @class */ (function () {
|
|
22
|
+
function ObjectUtils() {
|
|
23
|
+
}
|
|
24
|
+
ObjectUtils.DisposeMaterial = function (material) {
|
|
25
|
+
var _this = this;
|
|
26
|
+
if (!material) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(material)) {
|
|
30
|
+
material.forEach(function (mtrl) {
|
|
31
|
+
_this.materialProps
|
|
32
|
+
.filter(function (mapType) { return mtrl[mapType]; })
|
|
33
|
+
.forEach(function (mapType) { return mtrl[mapType].dispose(); });
|
|
34
|
+
mtrl.dispose();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this.materialProps
|
|
39
|
+
.filter(function (mapType) { return material[mapType] && material[mapType].dispose; })
|
|
40
|
+
.forEach(function (mapType) { return material[mapType].dispose(); });
|
|
41
|
+
if (material.dispose) {
|
|
42
|
+
material.dispose();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
ObjectUtils.DisposeObject = function (object) {
|
|
47
|
+
var _this = this;
|
|
48
|
+
if (!object) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (object.children.length) {
|
|
52
|
+
object.children.forEach(function (child) { return _this.DisposeObject(child); });
|
|
53
|
+
}
|
|
54
|
+
this.DisposeNode(object);
|
|
55
|
+
};
|
|
56
|
+
ObjectUtils.DisposeNode = function (node) {
|
|
57
|
+
var _this = this;
|
|
58
|
+
node.traverse(function (obj) {
|
|
59
|
+
if (obj instanceof Mesh) {
|
|
60
|
+
if (obj.geometry) {
|
|
61
|
+
obj.geometry.dispose();
|
|
62
|
+
}
|
|
63
|
+
_this.DisposeMaterial(obj.material);
|
|
64
|
+
}
|
|
65
|
+
if (typeof obj.dispose === 'function') {
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
obj.dispose();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
ObjectUtils.materialProps = ['map', 'lightMap', 'bumpMap', 'normalMap', 'specularMap', 'envMap', 'aoMap', 'roughnessMap', 'metalnessMap'];
|
|
72
|
+
return ObjectUtils;
|
|
73
73
|
}());
|
|
74
74
|
|
|
75
|
-
// Static utility functions holder related to files.
|
|
76
|
-
// @dynamic
|
|
77
|
-
var FileUtils = /** @class */ (function () {
|
|
78
|
-
function FileUtils() {
|
|
79
|
-
}
|
|
80
|
-
// Returns the given dataUri string stripped of the mimetype part.
|
|
81
|
-
FileUtils.StripMimeStringFromDataUri = function (dataUri) {
|
|
82
|
-
if (!dataUri) {
|
|
83
|
-
return '';
|
|
84
|
-
}
|
|
85
|
-
var mimeString = this.GetMimeStringFromDataUri(dataUri);
|
|
86
|
-
return dataUri.substr(mimeString.length + 1);
|
|
87
|
-
};
|
|
88
|
-
FileUtils.GetMimeStringFromDataUri = function (dataUri) {
|
|
89
|
-
if (!dataUri) {
|
|
90
|
-
return '';
|
|
91
|
-
}
|
|
92
|
-
return dataUri.split(',')[0];
|
|
93
|
-
};
|
|
94
|
-
FileUtils.FileExists = function (url, assetPath) {
|
|
95
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
-
var result;
|
|
97
|
-
return __generator(this, function (_a) {
|
|
98
|
-
switch (_a.label) {
|
|
99
|
-
case 0: return [4 /*yield*/, axios({
|
|
100
|
-
method: 'get',
|
|
101
|
-
url: assetPath + "getFiles.php?assetUrl=" + url,
|
|
102
|
-
responseType: "json"
|
|
103
|
-
})];
|
|
104
|
-
case 1:
|
|
105
|
-
result = _a.sent();
|
|
106
|
-
return [2 /*return*/, !!result.data];
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* There is some discrepancy regarding locations of h3d objects
|
|
113
|
-
* Therefor we need to (temporarily?!) fix the content url
|
|
114
|
-
* Also we need to change some additionals
|
|
115
|
-
*/
|
|
116
|
-
FileUtils.FixUrl = function (assetUrl) {
|
|
117
|
-
if (!assetUrl) {
|
|
118
|
-
return '';
|
|
119
|
-
}
|
|
120
|
-
var fixedUrl = assetUrl;
|
|
121
|
-
if (!fixedUrl.endsWith('glb') && !fixedUrl.endsWith('obj') && !fixedUrl.endsWith('glb.gz') && !fixedUrl.endsWith('obj.gz')) {
|
|
122
|
-
fixedUrl = FileUtils.FixUnityUrl(fixedUrl);
|
|
123
|
-
}
|
|
124
|
-
fixedUrl = fixedUrl.replace('/content/', '/content43/');
|
|
125
|
-
return fixedUrl;
|
|
126
|
-
};
|
|
127
|
-
FileUtils.FixGlbUrl = function (assetUrl) {
|
|
128
|
-
if (!assetUrl) {
|
|
129
|
-
return '';
|
|
130
|
-
}
|
|
131
|
-
var fixedUrl = assetUrl;
|
|
132
|
-
if (assetUrl.indexOf('_webplayer') === -1) {
|
|
133
|
-
fixedUrl = assetUrl.concat('_webplayer');
|
|
134
|
-
}
|
|
135
|
-
fixedUrl = fixedUrl.replace('/content/', '/content43/');
|
|
136
|
-
if (!fixedUrl.endsWith('.glb')) {
|
|
137
|
-
fixedUrl = fixedUrl.concat('.glb');
|
|
138
|
-
}
|
|
139
|
-
return fixedUrl;
|
|
140
|
-
};
|
|
141
|
-
// Return the mimetype of the given filename.
|
|
142
|
-
FileUtils.MimeTypeFromFilename = function (fileName) {
|
|
143
|
-
var regEx = /(?:\.([^.]+))?$/; // regex to find extension
|
|
144
|
-
var extension = regEx.exec(fileName)[1];
|
|
145
|
-
switch (extension) {
|
|
146
|
-
case 'jpg':
|
|
147
|
-
case 'jpeg':
|
|
148
|
-
return 'image/jpeg';
|
|
149
|
-
case 'png':
|
|
150
|
-
return 'image/png';
|
|
151
|
-
case 'bmp':
|
|
152
|
-
return 'image/bmp';
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
/**
|
|
156
|
-
* Downloads the given file to the users default download location.
|
|
157
|
-
* @param fileName With or without extension
|
|
158
|
-
* @param content File content as a string
|
|
159
|
-
* @param [mimeType = 'text/plain']
|
|
160
|
-
*/
|
|
161
|
-
FileUtils.DownloadFile = function (fileName, content, mimeType) {
|
|
162
|
-
if (mimeType === void 0) { mimeType = 'text/plain'; }
|
|
163
|
-
var element = document.createElement('a');
|
|
164
|
-
element.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(content));
|
|
165
|
-
element.setAttribute('download', fileName);
|
|
166
|
-
element.style.display = 'none';
|
|
167
|
-
document.body.appendChild(element);
|
|
168
|
-
element.click();
|
|
169
|
-
document.body.removeChild(element);
|
|
170
|
-
};
|
|
171
|
-
// Returns the contents of given file as a text string.
|
|
172
|
-
FileUtils.ReadAsText = function (file) {
|
|
173
|
-
return new Promise(function (resolve) {
|
|
174
|
-
var reader = new FileReader();
|
|
175
|
-
reader.readAsText(file);
|
|
176
|
-
reader.onloadend = function (event) {
|
|
177
|
-
if (event.target.readyState === 2) {
|
|
178
|
-
resolve(event.target.result);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
FileUtils.GetExtensionFromDataUri = function (dataUri) {
|
|
184
|
-
return dataUri.replace(/(data:image\/)(.*?)(;base64.*)/gi, '$2');
|
|
185
|
-
};
|
|
186
|
-
FileUtils.CreateDownloadFileNameFromBase64 = function (dataUri) {
|
|
187
|
-
var ext = this.GetExtensionFromDataUri(dataUri);
|
|
188
|
-
return 'preview.' + ext;
|
|
189
|
-
};
|
|
190
|
-
FileUtils.DownloadFromDataUri = function (dataUri, fileName) {
|
|
191
|
-
var link = document.createElement('a');
|
|
192
|
-
link.download = fileName;
|
|
193
|
-
link.href = dataUri;
|
|
194
|
-
document.body.appendChild(link);
|
|
195
|
-
link.click();
|
|
196
|
-
document.body.removeChild(link);
|
|
197
|
-
};
|
|
198
|
-
// todo remove once Connector deals with mimetypes and this method isn't used anymore
|
|
199
|
-
FileUtils.DocumentBodyToDataUri = function (documentBody, mimeType) {
|
|
200
|
-
if (!!documentBody) {
|
|
201
|
-
return 'data:' + mimeType + ';base64,' + documentBody;
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
return '';
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
FileUtils.FixUnityUrl = function (url) {
|
|
208
|
-
if (url.indexOf('_webplayer') === -1) {
|
|
209
|
-
url = url.concat('_webplayer.ione3d');
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
url = url.replace('_webplayer', '_webplayer.ione3d');
|
|
213
|
-
}
|
|
214
|
-
if (!url.endsWith('.gz')) {
|
|
215
|
-
url = url.concat('.gz');
|
|
216
|
-
}
|
|
217
|
-
return url.replace('.unity3d', '');
|
|
218
|
-
};
|
|
219
|
-
FileUtils._cachedTextureUploads = new Map();
|
|
220
|
-
return FileUtils;
|
|
75
|
+
// Static utility functions holder related to files.
|
|
76
|
+
// @dynamic
|
|
77
|
+
var FileUtils = /** @class */ (function () {
|
|
78
|
+
function FileUtils() {
|
|
79
|
+
}
|
|
80
|
+
// Returns the given dataUri string stripped of the mimetype part.
|
|
81
|
+
FileUtils.StripMimeStringFromDataUri = function (dataUri) {
|
|
82
|
+
if (!dataUri) {
|
|
83
|
+
return '';
|
|
84
|
+
}
|
|
85
|
+
var mimeString = this.GetMimeStringFromDataUri(dataUri);
|
|
86
|
+
return dataUri.substr(mimeString.length + 1);
|
|
87
|
+
};
|
|
88
|
+
FileUtils.GetMimeStringFromDataUri = function (dataUri) {
|
|
89
|
+
if (!dataUri) {
|
|
90
|
+
return '';
|
|
91
|
+
}
|
|
92
|
+
return dataUri.split(',')[0];
|
|
93
|
+
};
|
|
94
|
+
FileUtils.FileExists = function (url, assetPath) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
var result;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0: return [4 /*yield*/, axios({
|
|
100
|
+
method: 'get',
|
|
101
|
+
url: assetPath + "getFiles.php?assetUrl=" + url,
|
|
102
|
+
responseType: "json"
|
|
103
|
+
})];
|
|
104
|
+
case 1:
|
|
105
|
+
result = _a.sent();
|
|
106
|
+
return [2 /*return*/, !!result.data];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* There is some discrepancy regarding locations of h3d objects
|
|
113
|
+
* Therefor we need to (temporarily?!) fix the content url
|
|
114
|
+
* Also we need to change some additionals
|
|
115
|
+
*/
|
|
116
|
+
FileUtils.FixUrl = function (assetUrl) {
|
|
117
|
+
if (!assetUrl) {
|
|
118
|
+
return '';
|
|
119
|
+
}
|
|
120
|
+
var fixedUrl = assetUrl;
|
|
121
|
+
if (!fixedUrl.endsWith('glb') && !fixedUrl.endsWith('obj') && !fixedUrl.endsWith('glb.gz') && !fixedUrl.endsWith('obj.gz')) {
|
|
122
|
+
fixedUrl = FileUtils.FixUnityUrl(fixedUrl);
|
|
123
|
+
}
|
|
124
|
+
fixedUrl = fixedUrl.replace('/content/', '/content43/');
|
|
125
|
+
return fixedUrl;
|
|
126
|
+
};
|
|
127
|
+
FileUtils.FixGlbUrl = function (assetUrl) {
|
|
128
|
+
if (!assetUrl) {
|
|
129
|
+
return '';
|
|
130
|
+
}
|
|
131
|
+
var fixedUrl = assetUrl;
|
|
132
|
+
if (assetUrl.indexOf('_webplayer') === -1) {
|
|
133
|
+
fixedUrl = assetUrl.concat('_webplayer');
|
|
134
|
+
}
|
|
135
|
+
fixedUrl = fixedUrl.replace('/content/', '/content43/');
|
|
136
|
+
if (!fixedUrl.endsWith('.glb')) {
|
|
137
|
+
fixedUrl = fixedUrl.concat('.glb');
|
|
138
|
+
}
|
|
139
|
+
return fixedUrl;
|
|
140
|
+
};
|
|
141
|
+
// Return the mimetype of the given filename.
|
|
142
|
+
FileUtils.MimeTypeFromFilename = function (fileName) {
|
|
143
|
+
var regEx = /(?:\.([^.]+))?$/; // regex to find extension
|
|
144
|
+
var extension = regEx.exec(fileName)[1];
|
|
145
|
+
switch (extension) {
|
|
146
|
+
case 'jpg':
|
|
147
|
+
case 'jpeg':
|
|
148
|
+
return 'image/jpeg';
|
|
149
|
+
case 'png':
|
|
150
|
+
return 'image/png';
|
|
151
|
+
case 'bmp':
|
|
152
|
+
return 'image/bmp';
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Downloads the given file to the users default download location.
|
|
157
|
+
* @param fileName With or without extension
|
|
158
|
+
* @param content File content as a string
|
|
159
|
+
* @param [mimeType = 'text/plain']
|
|
160
|
+
*/
|
|
161
|
+
FileUtils.DownloadFile = function (fileName, content, mimeType) {
|
|
162
|
+
if (mimeType === void 0) { mimeType = 'text/plain'; }
|
|
163
|
+
var element = document.createElement('a');
|
|
164
|
+
element.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(content));
|
|
165
|
+
element.setAttribute('download', fileName);
|
|
166
|
+
element.style.display = 'none';
|
|
167
|
+
document.body.appendChild(element);
|
|
168
|
+
element.click();
|
|
169
|
+
document.body.removeChild(element);
|
|
170
|
+
};
|
|
171
|
+
// Returns the contents of given file as a text string.
|
|
172
|
+
FileUtils.ReadAsText = function (file) {
|
|
173
|
+
return new Promise(function (resolve) {
|
|
174
|
+
var reader = new FileReader();
|
|
175
|
+
reader.readAsText(file);
|
|
176
|
+
reader.onloadend = function (event) {
|
|
177
|
+
if (event.target.readyState === 2) {
|
|
178
|
+
resolve(event.target.result);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
FileUtils.GetExtensionFromDataUri = function (dataUri) {
|
|
184
|
+
return dataUri.replace(/(data:image\/)(.*?)(;base64.*)/gi, '$2');
|
|
185
|
+
};
|
|
186
|
+
FileUtils.CreateDownloadFileNameFromBase64 = function (dataUri) {
|
|
187
|
+
var ext = this.GetExtensionFromDataUri(dataUri);
|
|
188
|
+
return 'preview.' + ext;
|
|
189
|
+
};
|
|
190
|
+
FileUtils.DownloadFromDataUri = function (dataUri, fileName) {
|
|
191
|
+
var link = document.createElement('a');
|
|
192
|
+
link.download = fileName;
|
|
193
|
+
link.href = dataUri;
|
|
194
|
+
document.body.appendChild(link);
|
|
195
|
+
link.click();
|
|
196
|
+
document.body.removeChild(link);
|
|
197
|
+
};
|
|
198
|
+
// todo remove once Connector deals with mimetypes and this method isn't used anymore
|
|
199
|
+
FileUtils.DocumentBodyToDataUri = function (documentBody, mimeType) {
|
|
200
|
+
if (!!documentBody) {
|
|
201
|
+
return 'data:' + mimeType + ';base64,' + documentBody;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
return '';
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
FileUtils.FixUnityUrl = function (url) {
|
|
208
|
+
if (url.indexOf('_webplayer') === -1) {
|
|
209
|
+
url = url.concat('_webplayer.ione3d');
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
url = url.replace('_webplayer', '_webplayer.ione3d');
|
|
213
|
+
}
|
|
214
|
+
if (!url.endsWith('.gz')) {
|
|
215
|
+
url = url.concat('.gz');
|
|
216
|
+
}
|
|
217
|
+
return url.replace('.unity3d', '');
|
|
218
|
+
};
|
|
219
|
+
FileUtils._cachedTextureUploads = new Map();
|
|
220
|
+
return FileUtils;
|
|
221
221
|
}());
|
|
222
222
|
|
|
223
|
-
var ThreedUtils = /** @class */ (function () {
|
|
224
|
-
function ThreedUtils() {
|
|
225
|
-
this._objectCache = new Map();
|
|
226
|
-
}
|
|
227
|
-
ThreedUtils.prototype.clearCache = function () {
|
|
228
|
-
var objs = Array.from(this._objectCache.values());
|
|
229
|
-
objs.forEach(function (o) { return ObjectUtils.DisposeObject(o); });
|
|
230
|
-
this._objectCache.clear();
|
|
231
|
-
};
|
|
232
|
-
ThreedUtils.prototype.download3DSource = function (fileName) {
|
|
233
|
-
var _this = this;
|
|
234
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
235
|
-
var lookupFileName;
|
|
236
|
-
var _this = this;
|
|
237
|
-
return __generator(this, function (_a) {
|
|
238
|
-
switch (_a.label) {
|
|
239
|
-
case 0:
|
|
240
|
-
fileName = fileName.replace('.unity3d', '');
|
|
241
|
-
lookupFileName = fileName + (fileName.indexOf('.glb') < 0 ? '.glb' : '');
|
|
242
|
-
if (this._objectCache.has(lookupFileName)) {
|
|
243
|
-
resolve(this._objectCache.get(lookupFileName));
|
|
244
|
-
return [2 /*return*/];
|
|
245
|
-
}
|
|
246
|
-
return [4 /*yield*/, FileUtils.FileExists(lookupFileName, 'https://cdn1.colijn-it.nl/content43/')];
|
|
247
|
-
case 1:
|
|
248
|
-
if (_a.sent()) {
|
|
249
|
-
this.loadGlbSource(lookupFileName).then(function (obj) {
|
|
250
|
-
_this._objectCache.set(lookupFileName, obj);
|
|
251
|
-
resolve(obj);
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
reject("GLB source not found! (" + lookupFileName + ")");
|
|
256
|
-
}
|
|
257
|
-
return [2 /*return*/];
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
}); });
|
|
261
|
-
};
|
|
262
|
-
ThreedUtils.prototype.readFileAsText = function (file) {
|
|
263
|
-
var fileReader = new FileReader();
|
|
264
|
-
return new Promise(function (resolve, reject) {
|
|
265
|
-
fileReader.onload = function (e) { return resolve(e.target.result); };
|
|
266
|
-
fileReader.onerror = function (error) { return reject(error); };
|
|
267
|
-
fileReader.readAsText(file);
|
|
268
|
-
});
|
|
269
|
-
};
|
|
270
|
-
ThreedUtils.prototype.loadJsonModel = function (filePath) {
|
|
271
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
272
|
-
var json, loader;
|
|
273
|
-
var _this = this;
|
|
274
|
-
return __generator(this, function (_a) {
|
|
275
|
-
switch (_a.label) {
|
|
276
|
-
case 0:
|
|
277
|
-
if (this._objectCache.has(filePath)) {
|
|
278
|
-
return [2 /*return*/, Promise.resolve(this._objectCache.get(filePath))];
|
|
279
|
-
}
|
|
280
|
-
return [4 /*yield*/, this._readJsonFile(filePath)];
|
|
281
|
-
case 1:
|
|
282
|
-
json = _a.sent();
|
|
283
|
-
loader = new ObjectLoader();
|
|
284
|
-
loader.crossOrigin = 'Anonymous';
|
|
285
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
286
|
-
try {
|
|
287
|
-
var obj = loader.parse(json);
|
|
288
|
-
_this._objectCache.set(filePath, obj);
|
|
289
|
-
resolve(obj);
|
|
290
|
-
}
|
|
291
|
-
catch (e) {
|
|
292
|
-
reject(null);
|
|
293
|
-
}
|
|
294
|
-
})];
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
};
|
|
299
|
-
ThreedUtils.prototype.loadJsonObjectModel = function (filePath) {
|
|
300
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
301
|
-
var loader;
|
|
302
|
-
var _this = this;
|
|
303
|
-
return __generator(this, function (_a) {
|
|
304
|
-
if (this._objectCache.has(filePath)) {
|
|
305
|
-
return [2 /*return*/, Promise.resolve(this._objectCache.get(filePath))];
|
|
306
|
-
}
|
|
307
|
-
loader = new ObjectLoader();
|
|
308
|
-
loader.setCrossOrigin('Anonymous');
|
|
309
|
-
loader.setResourcePath('');
|
|
310
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
311
|
-
loader.load(filePath, function (object) {
|
|
312
|
-
var obj = (object.type === 'Scene' && object.children[0].type === 'Object3D') ? object.children[0] : object;
|
|
313
|
-
_this._objectCache.set(filePath, obj);
|
|
314
|
-
resolve(obj);
|
|
315
|
-
}, function (xhr) { return null; }, function (error) { return reject(error); });
|
|
316
|
-
})];
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
};
|
|
320
|
-
ThreedUtils.prototype.loadGlbModel = function (file, cleanUp) {
|
|
321
|
-
if (cleanUp === void 0) { cleanUp = true; }
|
|
322
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
323
|
-
var obj;
|
|
324
|
-
return __generator(this, function (_a) {
|
|
325
|
-
switch (_a.label) {
|
|
326
|
-
case 0:
|
|
327
|
-
if (this._objectCache.has(file)) {
|
|
328
|
-
return [2 /*return*/, Promise.resolve(this._objectCache.get(file))];
|
|
329
|
-
}
|
|
330
|
-
if (!window.hasOwnProperty('loadGLTF')) {
|
|
331
|
-
console.error('loadGLTF not defined in window global');
|
|
332
|
-
return [2 /*return*/, null];
|
|
333
|
-
}
|
|
334
|
-
return [4 /*yield*/, window.loadGLTF(file)];
|
|
335
|
-
case 1:
|
|
336
|
-
obj = _a.sent();
|
|
337
|
-
if (obj) {
|
|
338
|
-
this._cleanedUpObjects(obj, cleanUp);
|
|
339
|
-
this._objectCache.set(file, obj);
|
|
340
|
-
return [2 /*return*/, obj];
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
return [2 /*return*/, null];
|
|
344
|
-
}
|
|
345
|
-
return [2 /*return*/];
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
};
|
|
350
|
-
ThreedUtils.prototype.loadGlbSource = function (file) {
|
|
351
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
352
|
-
var obj, children;
|
|
353
|
-
return __generator(this, function (_a) {
|
|
354
|
-
switch (_a.label) {
|
|
355
|
-
case 0: return [4 /*yield*/, this.loadGlbModel(file, false)];
|
|
356
|
-
case 1:
|
|
357
|
-
obj = _a.sent();
|
|
358
|
-
if (obj) {
|
|
359
|
-
obj.children = obj.children.filter(function (c) { return !(c instanceof Camera); });
|
|
360
|
-
obj.children.sort(function (a, b) { return a['name'] < b['name'] ? 1 : -1; });
|
|
361
|
-
obj.children.forEach(function (c) {
|
|
362
|
-
c.traverse(function (t) {
|
|
363
|
-
t.visible = !t.name.toLowerCase().startsWith('c_');
|
|
364
|
-
});
|
|
365
|
-
c.visible = false;
|
|
366
|
-
});
|
|
367
|
-
if (obj.children.length === 1 && obj.children[0] instanceof Group) { // flatten children
|
|
368
|
-
children = obj.children[0].children.slice();
|
|
369
|
-
obj.children.length = 0;
|
|
370
|
-
obj.children = children;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
return [2 /*return*/, obj];
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
};
|
|
378
|
-
ThreedUtils.prototype.textureFromUrl = function (url) {
|
|
379
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
380
|
-
return __generator(this, function (_a) {
|
|
381
|
-
// url = this._includeBaseUrl(url);
|
|
382
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
383
|
-
var textureLoader = new TextureLoader();
|
|
384
|
-
// textureLoader.setBaseU(this._settingsService.settings.assetPath);
|
|
385
|
-
textureLoader.load(url, function (texture) {
|
|
386
|
-
texture.wrapT = RepeatWrapping;
|
|
387
|
-
texture.wrapS = RepeatWrapping;
|
|
388
|
-
texture.repeat.set(1, 1);
|
|
389
|
-
texture.needsUpdate = true;
|
|
390
|
-
return resolve(texture);
|
|
391
|
-
}, null, reject);
|
|
392
|
-
})];
|
|
393
|
-
});
|
|
394
|
-
});
|
|
395
|
-
};
|
|
396
|
-
ThreedUtils.prototype._cleanedUpObjects = function (object, cleanUp) {
|
|
397
|
-
var _this = this;
|
|
398
|
-
if (cleanUp === void 0) { cleanUp = true; }
|
|
399
|
-
var obj = new Object3D();
|
|
400
|
-
object.children.forEach(function (c) {
|
|
401
|
-
if (!(c instanceof Camera)) {
|
|
402
|
-
if (cleanUp && c instanceof Group || (c.children.length === 1 && c.children[0] instanceof Group)) {
|
|
403
|
-
_this._addGroupChildrenToObject(c, obj);
|
|
404
|
-
}
|
|
405
|
-
else if ((cleanUp && !(c instanceof Mesh)) || (!(c instanceof Mesh) && !c.name && c.children.length > 0)) {
|
|
406
|
-
c.children.forEach(function (child) {
|
|
407
|
-
child.translateY(c.position.y);
|
|
408
|
-
});
|
|
409
|
-
c.translateY(-c.position.y);
|
|
410
|
-
if (obj.children.length > 0) {
|
|
411
|
-
obj.add(c.clone());
|
|
412
|
-
}
|
|
413
|
-
else {
|
|
414
|
-
obj = c.clone();
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
else {
|
|
418
|
-
// if (c.position.y > 0 || c.position.y < 0) {
|
|
419
|
-
// c.children.forEach((child) => {
|
|
420
|
-
// child.translateY(c.position.y);
|
|
421
|
-
// });
|
|
422
|
-
// c.translateY(-c.position.y);
|
|
423
|
-
// }
|
|
424
|
-
obj.add(c.clone());
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
var boundingBox = new Box3().setFromObject(obj);
|
|
429
|
-
var bbCenterPivot = new Vector3();
|
|
430
|
-
boundingBox.getCenter(bbCenterPivot);
|
|
431
|
-
var delta = new Vector3().add(bbCenterPivot).negate();
|
|
432
|
-
obj.children.forEach(function (cc) {
|
|
433
|
-
cc.position.add(delta);
|
|
434
|
-
});
|
|
435
|
-
return obj;
|
|
436
|
-
};
|
|
437
|
-
ThreedUtils.prototype._addGroupChildrenToObject = function (group, obj, cleanUp) {
|
|
438
|
-
var _this = this;
|
|
439
|
-
if (cleanUp === void 0) { cleanUp = true; }
|
|
440
|
-
group.children.forEach(function (gc) {
|
|
441
|
-
if (cleanUp && gc instanceof Group) {
|
|
442
|
-
_this._addGroupChildrenToObject(gc, obj);
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
// gc.translateX(-group.position.x);
|
|
446
|
-
gc.translateY(group.position.y);
|
|
447
|
-
// gc.translateZ(-group.position.z);
|
|
448
|
-
obj.add(gc.clone());
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
};
|
|
452
|
-
ThreedUtils.prototype._iterateChildren = function (children, callback) {
|
|
453
|
-
for (var i = 0; i < children.length; i++) {
|
|
454
|
-
var child = children[i];
|
|
455
|
-
if (child instanceof Mesh) {
|
|
456
|
-
callback(child);
|
|
457
|
-
}
|
|
458
|
-
else {
|
|
459
|
-
this._iterateChildren(child.children, callback);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
};
|
|
463
|
-
ThreedUtils.prototype._readJsonFile = function (filePath) {
|
|
464
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
465
|
-
var response, empty_1, e_1;
|
|
466
|
-
return __generator(this, function (_a) {
|
|
467
|
-
switch (_a.label) {
|
|
468
|
-
case 0:
|
|
469
|
-
_a.trys.push([0, 5, , 6]);
|
|
470
|
-
return [4 /*yield*/, fetch(filePath)];
|
|
471
|
-
case 1:
|
|
472
|
-
response = _a.sent();
|
|
473
|
-
if (!!response.ok) return [3 /*break*/, 2];
|
|
474
|
-
return [2 /*return*/, ''];
|
|
475
|
-
case 2:
|
|
476
|
-
empty_1 = false;
|
|
477
|
-
return [4 /*yield*/, response.clone().text().then(function (value) {
|
|
478
|
-
if (value === '') {
|
|
479
|
-
empty_1 = true;
|
|
480
|
-
}
|
|
481
|
-
})];
|
|
482
|
-
case 3:
|
|
483
|
-
_a.sent();
|
|
484
|
-
return [2 /*return*/, empty_1 ? {} : response.json()];
|
|
485
|
-
case 4: return [3 /*break*/, 6];
|
|
486
|
-
case 5:
|
|
487
|
-
e_1 = _a.sent();
|
|
488
|
-
return [2 /*return*/, ''];
|
|
489
|
-
case 6: return [2 /*return*/];
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
});
|
|
493
|
-
};
|
|
494
|
-
return ThreedUtils;
|
|
223
|
+
var ThreedUtils = /** @class */ (function () {
|
|
224
|
+
function ThreedUtils() {
|
|
225
|
+
this._objectCache = new Map();
|
|
226
|
+
}
|
|
227
|
+
ThreedUtils.prototype.clearCache = function () {
|
|
228
|
+
var objs = Array.from(this._objectCache.values());
|
|
229
|
+
objs.forEach(function (o) { return ObjectUtils.DisposeObject(o); });
|
|
230
|
+
this._objectCache.clear();
|
|
231
|
+
};
|
|
232
|
+
ThreedUtils.prototype.download3DSource = function (fileName) {
|
|
233
|
+
var _this = this;
|
|
234
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
235
|
+
var lookupFileName;
|
|
236
|
+
var _this = this;
|
|
237
|
+
return __generator(this, function (_a) {
|
|
238
|
+
switch (_a.label) {
|
|
239
|
+
case 0:
|
|
240
|
+
fileName = fileName.replace('.unity3d', '');
|
|
241
|
+
lookupFileName = fileName + (fileName.indexOf('.glb') < 0 ? '.glb' : '');
|
|
242
|
+
if (this._objectCache.has(lookupFileName)) {
|
|
243
|
+
resolve(this._objectCache.get(lookupFileName));
|
|
244
|
+
return [2 /*return*/];
|
|
245
|
+
}
|
|
246
|
+
return [4 /*yield*/, FileUtils.FileExists(lookupFileName, 'https://cdn1.colijn-it.nl/content43/')];
|
|
247
|
+
case 1:
|
|
248
|
+
if (_a.sent()) {
|
|
249
|
+
this.loadGlbSource(lookupFileName).then(function (obj) {
|
|
250
|
+
_this._objectCache.set(lookupFileName, obj);
|
|
251
|
+
resolve(obj);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
reject("GLB source not found! (" + lookupFileName + ")");
|
|
256
|
+
}
|
|
257
|
+
return [2 /*return*/];
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}); });
|
|
261
|
+
};
|
|
262
|
+
ThreedUtils.prototype.readFileAsText = function (file) {
|
|
263
|
+
var fileReader = new FileReader();
|
|
264
|
+
return new Promise(function (resolve, reject) {
|
|
265
|
+
fileReader.onload = function (e) { return resolve(e.target.result); };
|
|
266
|
+
fileReader.onerror = function (error) { return reject(error); };
|
|
267
|
+
fileReader.readAsText(file);
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
ThreedUtils.prototype.loadJsonModel = function (filePath) {
|
|
271
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
272
|
+
var json, loader;
|
|
273
|
+
var _this = this;
|
|
274
|
+
return __generator(this, function (_a) {
|
|
275
|
+
switch (_a.label) {
|
|
276
|
+
case 0:
|
|
277
|
+
if (this._objectCache.has(filePath)) {
|
|
278
|
+
return [2 /*return*/, Promise.resolve(this._objectCache.get(filePath))];
|
|
279
|
+
}
|
|
280
|
+
return [4 /*yield*/, this._readJsonFile(filePath)];
|
|
281
|
+
case 1:
|
|
282
|
+
json = _a.sent();
|
|
283
|
+
loader = new ObjectLoader();
|
|
284
|
+
loader.crossOrigin = 'Anonymous';
|
|
285
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
286
|
+
try {
|
|
287
|
+
var obj = loader.parse(json);
|
|
288
|
+
_this._objectCache.set(filePath, obj);
|
|
289
|
+
resolve(obj);
|
|
290
|
+
}
|
|
291
|
+
catch (e) {
|
|
292
|
+
reject(null);
|
|
293
|
+
}
|
|
294
|
+
})];
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
ThreedUtils.prototype.loadJsonObjectModel = function (filePath) {
|
|
300
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
301
|
+
var loader;
|
|
302
|
+
var _this = this;
|
|
303
|
+
return __generator(this, function (_a) {
|
|
304
|
+
if (this._objectCache.has(filePath)) {
|
|
305
|
+
return [2 /*return*/, Promise.resolve(this._objectCache.get(filePath))];
|
|
306
|
+
}
|
|
307
|
+
loader = new ObjectLoader();
|
|
308
|
+
loader.setCrossOrigin('Anonymous');
|
|
309
|
+
loader.setResourcePath('');
|
|
310
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
311
|
+
loader.load(filePath, function (object) {
|
|
312
|
+
var obj = (object.type === 'Scene' && object.children[0].type === 'Object3D') ? object.children[0] : object;
|
|
313
|
+
_this._objectCache.set(filePath, obj);
|
|
314
|
+
resolve(obj);
|
|
315
|
+
}, function (xhr) { return null; }, function (error) { return reject(error); });
|
|
316
|
+
})];
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
ThreedUtils.prototype.loadGlbModel = function (file, cleanUp) {
|
|
321
|
+
if (cleanUp === void 0) { cleanUp = true; }
|
|
322
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
323
|
+
var obj;
|
|
324
|
+
return __generator(this, function (_a) {
|
|
325
|
+
switch (_a.label) {
|
|
326
|
+
case 0:
|
|
327
|
+
if (this._objectCache.has(file)) {
|
|
328
|
+
return [2 /*return*/, Promise.resolve(this._objectCache.get(file))];
|
|
329
|
+
}
|
|
330
|
+
if (!window.hasOwnProperty('loadGLTF')) {
|
|
331
|
+
console.error('loadGLTF not defined in window global');
|
|
332
|
+
return [2 /*return*/, null];
|
|
333
|
+
}
|
|
334
|
+
return [4 /*yield*/, window.loadGLTF(file)];
|
|
335
|
+
case 1:
|
|
336
|
+
obj = _a.sent();
|
|
337
|
+
if (obj) {
|
|
338
|
+
this._cleanedUpObjects(obj, cleanUp);
|
|
339
|
+
this._objectCache.set(file, obj);
|
|
340
|
+
return [2 /*return*/, obj];
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
return [2 /*return*/, null];
|
|
344
|
+
}
|
|
345
|
+
return [2 /*return*/];
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
ThreedUtils.prototype.loadGlbSource = function (file) {
|
|
351
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
352
|
+
var obj, children;
|
|
353
|
+
return __generator(this, function (_a) {
|
|
354
|
+
switch (_a.label) {
|
|
355
|
+
case 0: return [4 /*yield*/, this.loadGlbModel(file, false)];
|
|
356
|
+
case 1:
|
|
357
|
+
obj = _a.sent();
|
|
358
|
+
if (obj) {
|
|
359
|
+
obj.children = obj.children.filter(function (c) { return !(c instanceof Camera); });
|
|
360
|
+
obj.children.sort(function (a, b) { return a['name'] < b['name'] ? 1 : -1; });
|
|
361
|
+
obj.children.forEach(function (c) {
|
|
362
|
+
c.traverse(function (t) {
|
|
363
|
+
t.visible = !t.name.toLowerCase().startsWith('c_');
|
|
364
|
+
});
|
|
365
|
+
c.visible = false;
|
|
366
|
+
});
|
|
367
|
+
if (obj.children.length === 1 && obj.children[0] instanceof Group) { // flatten children
|
|
368
|
+
children = obj.children[0].children.slice();
|
|
369
|
+
obj.children.length = 0;
|
|
370
|
+
obj.children = children;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return [2 /*return*/, obj];
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
};
|
|
378
|
+
ThreedUtils.prototype.textureFromUrl = function (url) {
|
|
379
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
380
|
+
return __generator(this, function (_a) {
|
|
381
|
+
// url = this._includeBaseUrl(url);
|
|
382
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
383
|
+
var textureLoader = new TextureLoader();
|
|
384
|
+
// textureLoader.setBaseU(this._settingsService.settings.assetPath);
|
|
385
|
+
textureLoader.load(url, function (texture) {
|
|
386
|
+
texture.wrapT = RepeatWrapping;
|
|
387
|
+
texture.wrapS = RepeatWrapping;
|
|
388
|
+
texture.repeat.set(1, 1);
|
|
389
|
+
texture.needsUpdate = true;
|
|
390
|
+
return resolve(texture);
|
|
391
|
+
}, null, reject);
|
|
392
|
+
})];
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
};
|
|
396
|
+
ThreedUtils.prototype._cleanedUpObjects = function (object, cleanUp) {
|
|
397
|
+
var _this = this;
|
|
398
|
+
if (cleanUp === void 0) { cleanUp = true; }
|
|
399
|
+
var obj = new Object3D();
|
|
400
|
+
object.children.forEach(function (c) {
|
|
401
|
+
if (!(c instanceof Camera)) {
|
|
402
|
+
if (cleanUp && c instanceof Group || (c.children.length === 1 && c.children[0] instanceof Group)) {
|
|
403
|
+
_this._addGroupChildrenToObject(c, obj);
|
|
404
|
+
}
|
|
405
|
+
else if ((cleanUp && !(c instanceof Mesh)) || (!(c instanceof Mesh) && !c.name && c.children.length > 0)) {
|
|
406
|
+
c.children.forEach(function (child) {
|
|
407
|
+
child.translateY(c.position.y);
|
|
408
|
+
});
|
|
409
|
+
c.translateY(-c.position.y);
|
|
410
|
+
if (obj.children.length > 0) {
|
|
411
|
+
obj.add(c.clone());
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
obj = c.clone();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
// if (c.position.y > 0 || c.position.y < 0) {
|
|
419
|
+
// c.children.forEach((child) => {
|
|
420
|
+
// child.translateY(c.position.y);
|
|
421
|
+
// });
|
|
422
|
+
// c.translateY(-c.position.y);
|
|
423
|
+
// }
|
|
424
|
+
obj.add(c.clone());
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
var boundingBox = new Box3().setFromObject(obj);
|
|
429
|
+
var bbCenterPivot = new Vector3();
|
|
430
|
+
boundingBox.getCenter(bbCenterPivot);
|
|
431
|
+
var delta = new Vector3().add(bbCenterPivot).negate();
|
|
432
|
+
obj.children.forEach(function (cc) {
|
|
433
|
+
cc.position.add(delta);
|
|
434
|
+
});
|
|
435
|
+
return obj;
|
|
436
|
+
};
|
|
437
|
+
ThreedUtils.prototype._addGroupChildrenToObject = function (group, obj, cleanUp) {
|
|
438
|
+
var _this = this;
|
|
439
|
+
if (cleanUp === void 0) { cleanUp = true; }
|
|
440
|
+
group.children.forEach(function (gc) {
|
|
441
|
+
if (cleanUp && gc instanceof Group) {
|
|
442
|
+
_this._addGroupChildrenToObject(gc, obj);
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
// gc.translateX(-group.position.x);
|
|
446
|
+
gc.translateY(group.position.y);
|
|
447
|
+
// gc.translateZ(-group.position.z);
|
|
448
|
+
obj.add(gc.clone());
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
};
|
|
452
|
+
ThreedUtils.prototype._iterateChildren = function (children, callback) {
|
|
453
|
+
for (var i = 0; i < children.length; i++) {
|
|
454
|
+
var child = children[i];
|
|
455
|
+
if (child instanceof Mesh) {
|
|
456
|
+
callback(child);
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
this._iterateChildren(child.children, callback);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
ThreedUtils.prototype._readJsonFile = function (filePath) {
|
|
464
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
465
|
+
var response, empty_1, e_1;
|
|
466
|
+
return __generator(this, function (_a) {
|
|
467
|
+
switch (_a.label) {
|
|
468
|
+
case 0:
|
|
469
|
+
_a.trys.push([0, 5, , 6]);
|
|
470
|
+
return [4 /*yield*/, fetch(filePath)];
|
|
471
|
+
case 1:
|
|
472
|
+
response = _a.sent();
|
|
473
|
+
if (!!response.ok) return [3 /*break*/, 2];
|
|
474
|
+
return [2 /*return*/, ''];
|
|
475
|
+
case 2:
|
|
476
|
+
empty_1 = false;
|
|
477
|
+
return [4 /*yield*/, response.clone().text().then(function (value) {
|
|
478
|
+
if (value === '') {
|
|
479
|
+
empty_1 = true;
|
|
480
|
+
}
|
|
481
|
+
})];
|
|
482
|
+
case 3:
|
|
483
|
+
_a.sent();
|
|
484
|
+
return [2 /*return*/, empty_1 ? {} : response.json()];
|
|
485
|
+
case 4: return [3 /*break*/, 6];
|
|
486
|
+
case 5:
|
|
487
|
+
e_1 = _a.sent();
|
|
488
|
+
return [2 /*return*/, ''];
|
|
489
|
+
case 6: return [2 /*return*/];
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
};
|
|
494
|
+
return ThreedUtils;
|
|
495
495
|
}());
|
|
496
496
|
|
|
497
|
-
var SceneUtils = /** @class */ (function () {
|
|
498
|
-
function SceneUtils() {
|
|
499
|
-
}
|
|
500
|
-
SceneUtils.TrySelectorConnection = function (scene, parent, part1, part2, createAddableFn) {
|
|
501
|
-
var addable;
|
|
502
|
-
if (createAddableFn) {
|
|
503
|
-
addable = part2;
|
|
504
|
-
part2 = createAddableFn(addable);
|
|
505
|
-
}
|
|
506
|
-
for (var i = 0; i < part1.children.length; i++) {
|
|
507
|
-
for (var ii = 0; ii < part2.children.length; ii++) {
|
|
508
|
-
var con1 = part1.children[i];
|
|
509
|
-
var con2 = part2.children[ii];
|
|
510
|
-
// if these connectors can connect connect them
|
|
511
|
-
if (!con1['connected'] && !con2['connected'] && this.CanSelectorConnect(con1, con2)) {
|
|
512
|
-
// if addable, continue this loop with a new addable
|
|
513
|
-
if (addable) {
|
|
514
|
-
var newPart2 = createAddableFn(addable, part2, part1);
|
|
515
|
-
// reference of part2 changed, so refresh con2
|
|
516
|
-
this.SelectorConnect(scene, parent, con1, newPart2.children[ii]);
|
|
517
|
-
}
|
|
518
|
-
else {
|
|
519
|
-
return this.SelectorConnect(scene, parent, con1, con2);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
return false;
|
|
525
|
-
};
|
|
526
|
-
SceneUtils.Convert3DPointToScreenPoint = function (point, camera, width, height) {
|
|
527
|
-
if (!point) {
|
|
528
|
-
return new Vector2();
|
|
529
|
-
}
|
|
530
|
-
var vector = point.clone().project(camera);
|
|
531
|
-
vector.x = (vector.x + 1) / 2 * width;
|
|
532
|
-
vector.y = -(vector.y - 1) / 2 * height;
|
|
533
|
-
return new Vector2(vector.x, vector.y);
|
|
534
|
-
};
|
|
535
|
-
SceneUtils.CanSelectorConnect = function (con1, con2) {
|
|
536
|
-
var con1Name = con1 instanceof Object3D ? con1.name : con1.connector;
|
|
537
|
-
var con2Name = con2 instanceof Object3D ? con2.name : con2.connector;
|
|
538
|
-
var sameParent = con1 instanceof Object3D && con2 instanceof Object3D ? con1.parent === con2.parent : false;
|
|
539
|
-
var parts1 = con1Name.toUpperCase().split('_'), parts2 = con2Name.toUpperCase().split('_');
|
|
540
|
-
if (parts1.length >= 3 && parts2.length >= 3 && !sameParent) {
|
|
541
|
-
var connectable = parts1[0] === 'C' && parts2[0] === 'C' &&
|
|
542
|
-
parts1[1] === parts2[1] && parts1[2] !== parts2[2];
|
|
543
|
-
return connectable;
|
|
544
|
-
}
|
|
545
|
-
return false;
|
|
546
|
-
};
|
|
547
|
-
SceneUtils.SelectorConnect = function (scene, parent, con1, con2) {
|
|
548
|
-
if (!scene || !parent) {
|
|
549
|
-
return false;
|
|
550
|
-
}
|
|
551
|
-
con1['connectedTo'] = con2.parent.name;
|
|
552
|
-
con2['connectedTo'] = con1.parent.name;
|
|
553
|
-
var motherRotation = new Euler(0, 0, 0);
|
|
554
|
-
var motherPosition = new Vector3(0, 0, 0);
|
|
555
|
-
scene.updateMatrixWorld(true);
|
|
556
|
-
motherRotation.copy(parent.rotation);
|
|
557
|
-
parent.getWorldPosition(motherPosition);
|
|
558
|
-
parent.rotation.set(0, 0, 0);
|
|
559
|
-
parent.position.set(0, 0, 0);
|
|
560
|
-
var con1Quat = new Quaternion();
|
|
561
|
-
con1.getWorldQuaternion(con1Quat);
|
|
562
|
-
var con2Quat = new Quaternion();
|
|
563
|
-
con2.getWorldQuaternion(con2Quat);
|
|
564
|
-
var con1QuatParent = new Quaternion();
|
|
565
|
-
con1.parent.getWorldQuaternion(con1QuatParent);
|
|
566
|
-
var con2QuatParent = new Quaternion();
|
|
567
|
-
con2.parent.getWorldQuaternion(con2QuatParent);
|
|
568
|
-
var rotation = new Quaternion().multiplyQuaternions(con1Quat.invert(), con2Quat).multiply(new Quaternion().multiplyQuaternions(con1QuatParent, con1QuatParent));
|
|
569
|
-
con2.parent.quaternion.copy(rotation);
|
|
570
|
-
// Update because the matrix has been tempered with
|
|
571
|
-
scene.updateMatrixWorld(true);
|
|
572
|
-
// Move the connectors towards eachother
|
|
573
|
-
var con1Pos = new Vector3();
|
|
574
|
-
con1.getWorldPosition(con1Pos);
|
|
575
|
-
var con2Pos = new Vector3();
|
|
576
|
-
con2.getWorldPosition(con2Pos);
|
|
577
|
-
var move = con1Pos.sub(con2Pos);
|
|
578
|
-
con2.parent.position.x += move.x;
|
|
579
|
-
con2.parent.position.y += move.y;
|
|
580
|
-
con2.parent.position.z += move.z;
|
|
581
|
-
// reset parent's objects rotation and position
|
|
582
|
-
parent.rotation.copy(motherRotation);
|
|
583
|
-
parent.position.copy(motherPosition);
|
|
584
|
-
scene.updateMatrixWorld(true);
|
|
585
|
-
// Set the connected flag
|
|
586
|
-
con1['connected'] = true;
|
|
587
|
-
con2['connected'] = true;
|
|
588
|
-
return true;
|
|
589
|
-
};
|
|
590
|
-
return SceneUtils;
|
|
497
|
+
var SceneUtils = /** @class */ (function () {
|
|
498
|
+
function SceneUtils() {
|
|
499
|
+
}
|
|
500
|
+
SceneUtils.TrySelectorConnection = function (scene, parent, part1, part2, createAddableFn) {
|
|
501
|
+
var addable;
|
|
502
|
+
if (createAddableFn) {
|
|
503
|
+
addable = part2;
|
|
504
|
+
part2 = createAddableFn(addable);
|
|
505
|
+
}
|
|
506
|
+
for (var i = 0; i < part1.children.length; i++) {
|
|
507
|
+
for (var ii = 0; ii < part2.children.length; ii++) {
|
|
508
|
+
var con1 = part1.children[i];
|
|
509
|
+
var con2 = part2.children[ii];
|
|
510
|
+
// if these connectors can connect connect them
|
|
511
|
+
if (!con1['connected'] && !con2['connected'] && this.CanSelectorConnect(con1, con2)) {
|
|
512
|
+
// if addable, continue this loop with a new addable
|
|
513
|
+
if (addable) {
|
|
514
|
+
var newPart2 = createAddableFn(addable, part2, part1);
|
|
515
|
+
// reference of part2 changed, so refresh con2
|
|
516
|
+
this.SelectorConnect(scene, parent, con1, newPart2.children[ii]);
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
return this.SelectorConnect(scene, parent, con1, con2);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
return false;
|
|
525
|
+
};
|
|
526
|
+
SceneUtils.Convert3DPointToScreenPoint = function (point, camera, width, height) {
|
|
527
|
+
if (!point) {
|
|
528
|
+
return new Vector2();
|
|
529
|
+
}
|
|
530
|
+
var vector = point.clone().project(camera);
|
|
531
|
+
vector.x = (vector.x + 1) / 2 * width;
|
|
532
|
+
vector.y = -(vector.y - 1) / 2 * height;
|
|
533
|
+
return new Vector2(vector.x, vector.y);
|
|
534
|
+
};
|
|
535
|
+
SceneUtils.CanSelectorConnect = function (con1, con2) {
|
|
536
|
+
var con1Name = con1 instanceof Object3D ? con1.name : con1.connector;
|
|
537
|
+
var con2Name = con2 instanceof Object3D ? con2.name : con2.connector;
|
|
538
|
+
var sameParent = con1 instanceof Object3D && con2 instanceof Object3D ? con1.parent === con2.parent : false;
|
|
539
|
+
var parts1 = con1Name.toUpperCase().split('_'), parts2 = con2Name.toUpperCase().split('_');
|
|
540
|
+
if (parts1.length >= 3 && parts2.length >= 3 && !sameParent) {
|
|
541
|
+
var connectable = parts1[0] === 'C' && parts2[0] === 'C' &&
|
|
542
|
+
parts1[1] === parts2[1] && parts1[2] !== parts2[2];
|
|
543
|
+
return connectable;
|
|
544
|
+
}
|
|
545
|
+
return false;
|
|
546
|
+
};
|
|
547
|
+
SceneUtils.SelectorConnect = function (scene, parent, con1, con2) {
|
|
548
|
+
if (!scene || !parent) {
|
|
549
|
+
return false;
|
|
550
|
+
}
|
|
551
|
+
con1['connectedTo'] = con2.parent.name;
|
|
552
|
+
con2['connectedTo'] = con1.parent.name;
|
|
553
|
+
var motherRotation = new Euler(0, 0, 0);
|
|
554
|
+
var motherPosition = new Vector3(0, 0, 0);
|
|
555
|
+
scene.updateMatrixWorld(true);
|
|
556
|
+
motherRotation.copy(parent.rotation);
|
|
557
|
+
parent.getWorldPosition(motherPosition);
|
|
558
|
+
parent.rotation.set(0, 0, 0);
|
|
559
|
+
parent.position.set(0, 0, 0);
|
|
560
|
+
var con1Quat = new Quaternion();
|
|
561
|
+
con1.getWorldQuaternion(con1Quat);
|
|
562
|
+
var con2Quat = new Quaternion();
|
|
563
|
+
con2.getWorldQuaternion(con2Quat);
|
|
564
|
+
var con1QuatParent = new Quaternion();
|
|
565
|
+
con1.parent.getWorldQuaternion(con1QuatParent);
|
|
566
|
+
var con2QuatParent = new Quaternion();
|
|
567
|
+
con2.parent.getWorldQuaternion(con2QuatParent);
|
|
568
|
+
var rotation = new Quaternion().multiplyQuaternions(con1Quat.invert(), con2Quat).multiply(new Quaternion().multiplyQuaternions(con1QuatParent, con1QuatParent));
|
|
569
|
+
con2.parent.quaternion.copy(rotation);
|
|
570
|
+
// Update because the matrix has been tempered with
|
|
571
|
+
scene.updateMatrixWorld(true);
|
|
572
|
+
// Move the connectors towards eachother
|
|
573
|
+
var con1Pos = new Vector3();
|
|
574
|
+
con1.getWorldPosition(con1Pos);
|
|
575
|
+
var con2Pos = new Vector3();
|
|
576
|
+
con2.getWorldPosition(con2Pos);
|
|
577
|
+
var move = con1Pos.sub(con2Pos);
|
|
578
|
+
con2.parent.position.x += move.x;
|
|
579
|
+
con2.parent.position.y += move.y;
|
|
580
|
+
con2.parent.position.z += move.z;
|
|
581
|
+
// reset parent's objects rotation and position
|
|
582
|
+
parent.rotation.copy(motherRotation);
|
|
583
|
+
parent.position.copy(motherPosition);
|
|
584
|
+
scene.updateMatrixWorld(true);
|
|
585
|
+
// Set the connected flag
|
|
586
|
+
con1['connected'] = true;
|
|
587
|
+
con2['connected'] = true;
|
|
588
|
+
return true;
|
|
589
|
+
};
|
|
590
|
+
return SceneUtils;
|
|
591
591
|
}());
|
|
592
592
|
|
|
593
|
-
var Material = /** @class */ (function () {
|
|
594
|
-
function Material() {
|
|
595
|
-
this.specular = new Color(0.3, 0.3, 0.3);
|
|
596
|
-
this.shininess = 0;
|
|
597
|
-
this.repeatX = 4;
|
|
598
|
-
this.repeatY = 4;
|
|
599
|
-
this.loaded = false;
|
|
600
|
-
}
|
|
601
|
-
return Material;
|
|
593
|
+
var Material = /** @class */ (function () {
|
|
594
|
+
function Material() {
|
|
595
|
+
this.specular = new Color(0.3, 0.3, 0.3);
|
|
596
|
+
this.shininess = 0;
|
|
597
|
+
this.repeatX = 4;
|
|
598
|
+
this.repeatY = 4;
|
|
599
|
+
this.loaded = false;
|
|
600
|
+
}
|
|
601
|
+
return Material;
|
|
602
602
|
}());
|
|
603
603
|
|
|
604
|
-
// @dynamic
|
|
605
|
-
var ImageUtils = /** @class */ (function () {
|
|
606
|
-
function ImageUtils() {
|
|
607
|
-
}
|
|
608
|
-
ImageUtils.CreateTextureFromBase64 = function (id, base64, material) {
|
|
609
|
-
return new Promise(function (resolve) {
|
|
610
|
-
if (ImageUtils.textures.has(id)) {
|
|
611
|
-
resolve(ImageUtils.textures.get(id));
|
|
612
|
-
}
|
|
613
|
-
else {
|
|
614
|
-
if (!base64) {
|
|
615
|
-
resolve(new Texture());
|
|
616
|
-
}
|
|
617
|
-
else {
|
|
618
|
-
var loader = new TextureLoader();
|
|
619
|
-
loader.load(base64, function (texture) {
|
|
620
|
-
texture.anisotropy = 16;
|
|
621
|
-
texture.wrapS = RepeatWrapping;
|
|
622
|
-
texture.wrapT = RepeatWrapping;
|
|
623
|
-
texture.repeat = new Vector2(material ? material.repeatX : 1, material ? material.repeatY : 1);
|
|
624
|
-
texture.needsUpdate = true;
|
|
625
|
-
ImageUtils.textures.set(id, texture);
|
|
626
|
-
resolve(texture);
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
});
|
|
631
|
-
};
|
|
632
|
-
ImageUtils.getDocBodyWithMimeTypeDefinition = function (fileName, documentBody) {
|
|
633
|
-
if (documentBody === null) {
|
|
634
|
-
return documentBody;
|
|
635
|
-
}
|
|
636
|
-
var fileExtension = fileName.substr(fileName.lastIndexOf('.') + 1);
|
|
637
|
-
switch (fileExtension.toLowerCase()) {
|
|
638
|
-
case "jpg":
|
|
639
|
-
case "jpeg":
|
|
640
|
-
return "data:image/jpg;base64," + documentBody;
|
|
641
|
-
case "png":
|
|
642
|
-
return "data:image/png;base64," + documentBody;
|
|
643
|
-
case "gif":
|
|
644
|
-
return "data:image/gif;base64," + documentBody;
|
|
645
|
-
case "bmp":
|
|
646
|
-
return "data:image/bmp;base64," + documentBody;
|
|
647
|
-
default:
|
|
648
|
-
return "data:image/png;base64," + documentBody;
|
|
649
|
-
}
|
|
650
|
-
};
|
|
651
|
-
ImageUtils.getFixedImageFilepathUrl = function (imageFilepathUrl) {
|
|
652
|
-
return imageFilepathUrl.replace("/content/", "/content43/");
|
|
653
|
-
};
|
|
654
|
-
ImageUtils.textures = new Map();
|
|
655
|
-
return ImageUtils;
|
|
604
|
+
// @dynamic
|
|
605
|
+
var ImageUtils = /** @class */ (function () {
|
|
606
|
+
function ImageUtils() {
|
|
607
|
+
}
|
|
608
|
+
ImageUtils.CreateTextureFromBase64 = function (id, base64, material) {
|
|
609
|
+
return new Promise(function (resolve) {
|
|
610
|
+
if (ImageUtils.textures.has(id)) {
|
|
611
|
+
resolve(ImageUtils.textures.get(id));
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
if (!base64) {
|
|
615
|
+
resolve(new Texture());
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
var loader = new TextureLoader();
|
|
619
|
+
loader.load(base64, function (texture) {
|
|
620
|
+
texture.anisotropy = 16;
|
|
621
|
+
texture.wrapS = RepeatWrapping;
|
|
622
|
+
texture.wrapT = RepeatWrapping;
|
|
623
|
+
texture.repeat = new Vector2(material ? material.repeatX : 1, material ? material.repeatY : 1);
|
|
624
|
+
texture.needsUpdate = true;
|
|
625
|
+
ImageUtils.textures.set(id, texture);
|
|
626
|
+
resolve(texture);
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
};
|
|
632
|
+
ImageUtils.getDocBodyWithMimeTypeDefinition = function (fileName, documentBody) {
|
|
633
|
+
if (documentBody === null) {
|
|
634
|
+
return documentBody;
|
|
635
|
+
}
|
|
636
|
+
var fileExtension = fileName.substr(fileName.lastIndexOf('.') + 1);
|
|
637
|
+
switch (fileExtension.toLowerCase()) {
|
|
638
|
+
case "jpg":
|
|
639
|
+
case "jpeg":
|
|
640
|
+
return "data:image/jpg;base64," + documentBody;
|
|
641
|
+
case "png":
|
|
642
|
+
return "data:image/png;base64," + documentBody;
|
|
643
|
+
case "gif":
|
|
644
|
+
return "data:image/gif;base64," + documentBody;
|
|
645
|
+
case "bmp":
|
|
646
|
+
return "data:image/bmp;base64," + documentBody;
|
|
647
|
+
default:
|
|
648
|
+
return "data:image/png;base64," + documentBody;
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
ImageUtils.getFixedImageFilepathUrl = function (imageFilepathUrl) {
|
|
652
|
+
return imageFilepathUrl.replace("/content/", "/content43/");
|
|
653
|
+
};
|
|
654
|
+
ImageUtils.textures = new Map();
|
|
655
|
+
return ImageUtils;
|
|
656
656
|
}());
|
|
657
657
|
|
|
658
|
-
var FurnitureMaterial = /** @class */ (function (_super) {
|
|
659
|
-
__extends(FurnitureMaterial, _super);
|
|
660
|
-
function FurnitureMaterial() {
|
|
661
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
662
|
-
}
|
|
663
|
-
return FurnitureMaterial;
|
|
664
|
-
}(Material));
|
|
665
|
-
var AssetUtils = /** @class */ (function () {
|
|
666
|
-
function AssetUtils() {
|
|
667
|
-
}
|
|
668
|
-
AssetUtils.CreateMaterialFromAsset = function (asset) {
|
|
669
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
670
|
-
var material, _a, _b, _c, _d, _e;
|
|
671
|
-
return __generator(this, function (_f) {
|
|
672
|
-
switch (_f.label) {
|
|
673
|
-
case 0:
|
|
674
|
-
material = new Material();
|
|
675
|
-
if (!asset) {
|
|
676
|
-
return [2 /*return*/, material];
|
|
677
|
-
}
|
|
678
|
-
if (asset.settings) {
|
|
679
|
-
AssetUtils.setSettingsOfMaterial(material, asset.settings);
|
|
680
|
-
}
|
|
681
|
-
if (!asset.texture) return [3 /*break*/, 2];
|
|
682
|
-
_a = material;
|
|
683
|
-
return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_texture', asset.texture, material)];
|
|
684
|
-
case 1:
|
|
685
|
-
_a.texture = _f.sent();
|
|
686
|
-
material.texture.encoding = sRGBEncoding;
|
|
687
|
-
material.textureFilename = asset.textureFilename;
|
|
688
|
-
_f.label = 2;
|
|
689
|
-
case 2:
|
|
690
|
-
if (!asset.normal) return [3 /*break*/, 4];
|
|
691
|
-
_b = material;
|
|
692
|
-
return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_normal', asset.normal, material)];
|
|
693
|
-
case 3:
|
|
694
|
-
_b.normal = _f.sent();
|
|
695
|
-
material.normalFilename = asset.normalFilename;
|
|
696
|
-
_f.label = 4;
|
|
697
|
-
case 4:
|
|
698
|
-
if (!asset.ao) return [3 /*break*/, 6];
|
|
699
|
-
_c = material;
|
|
700
|
-
return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_ao', asset.ao, material)];
|
|
701
|
-
case 5:
|
|
702
|
-
_c.ao = _f.sent();
|
|
703
|
-
material.aoFilename = asset.aoFilename;
|
|
704
|
-
_f.label = 6;
|
|
705
|
-
case 6:
|
|
706
|
-
if (!asset.metalness) return [3 /*break*/, 8];
|
|
707
|
-
_d = material;
|
|
708
|
-
return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_metalness', asset.metalness, material)];
|
|
709
|
-
case 7:
|
|
710
|
-
_d.metalness = _f.sent();
|
|
711
|
-
material.metalnessFilename = asset.metalnessFilename;
|
|
712
|
-
_f.label = 8;
|
|
713
|
-
case 8:
|
|
714
|
-
if (!asset.roughness) return [3 /*break*/, 10];
|
|
715
|
-
_e = material;
|
|
716
|
-
return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_roughness', asset.roughness, material)];
|
|
717
|
-
case 9:
|
|
718
|
-
_e.roughness = _f.sent();
|
|
719
|
-
material.roughnessFilename = asset.roughnessFilename;
|
|
720
|
-
_f.label = 10;
|
|
721
|
-
case 10: return [2 /*return*/, material];
|
|
722
|
-
}
|
|
723
|
-
});
|
|
724
|
-
});
|
|
725
|
-
};
|
|
726
|
-
AssetUtils.setSettingsOfMaterial = function (material, settings) {
|
|
727
|
-
var shininess = parseFloat(settings['power']);
|
|
728
|
-
if (!isNaN(shininess)) {
|
|
729
|
-
material.shininess = shininess;
|
|
730
|
-
// material.roughness = 1 - (shininess / 100);
|
|
731
|
-
}
|
|
732
|
-
var level = parseFloat(settings['level']);
|
|
733
|
-
if (!isNaN(level)) {
|
|
734
|
-
material.specular = new Color(level, level, level);
|
|
735
|
-
}
|
|
736
|
-
var repeatObjectUsed = settings.hasOwnProperty('repeat');
|
|
737
|
-
var repeatx = repeatObjectUsed ? parseFloat(settings['repeat']['repeatx']) : parseFloat(settings['repeatx']);
|
|
738
|
-
if (!isNaN(repeatx)) {
|
|
739
|
-
material.repeatX = Math.max(1, repeatx);
|
|
740
|
-
}
|
|
741
|
-
var repeaty = repeatObjectUsed ? parseFloat(settings['repeat']['repeaty']) : parseFloat(settings['repeaty']);
|
|
742
|
-
if (!isNaN(repeaty)) {
|
|
743
|
-
material.repeatY = Math.max(1, repeaty);
|
|
744
|
-
}
|
|
745
|
-
var metalness = parseFloat(settings['metalness']);
|
|
746
|
-
if (!isNaN(metalness)) {
|
|
747
|
-
material.metalnessValue = Math.min(1, metalness);
|
|
748
|
-
}
|
|
749
|
-
var roughness = parseFloat(settings['roughness']);
|
|
750
|
-
if (!isNaN(roughness)) {
|
|
751
|
-
material.roughnessValue = Math.min(1, roughness);
|
|
752
|
-
}
|
|
753
|
-
};
|
|
754
|
-
return AssetUtils;
|
|
658
|
+
var FurnitureMaterial = /** @class */ (function (_super) {
|
|
659
|
+
__extends(FurnitureMaterial, _super);
|
|
660
|
+
function FurnitureMaterial() {
|
|
661
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
662
|
+
}
|
|
663
|
+
return FurnitureMaterial;
|
|
664
|
+
}(Material));
|
|
665
|
+
var AssetUtils = /** @class */ (function () {
|
|
666
|
+
function AssetUtils() {
|
|
667
|
+
}
|
|
668
|
+
AssetUtils.CreateMaterialFromAsset = function (asset) {
|
|
669
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
670
|
+
var material, _a, _b, _c, _d, _e;
|
|
671
|
+
return __generator(this, function (_f) {
|
|
672
|
+
switch (_f.label) {
|
|
673
|
+
case 0:
|
|
674
|
+
material = new Material();
|
|
675
|
+
if (!asset) {
|
|
676
|
+
return [2 /*return*/, material];
|
|
677
|
+
}
|
|
678
|
+
if (asset.settings) {
|
|
679
|
+
AssetUtils.setSettingsOfMaterial(material, asset.settings);
|
|
680
|
+
}
|
|
681
|
+
if (!asset.texture) return [3 /*break*/, 2];
|
|
682
|
+
_a = material;
|
|
683
|
+
return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_texture', asset.texture, material)];
|
|
684
|
+
case 1:
|
|
685
|
+
_a.texture = _f.sent();
|
|
686
|
+
material.texture.encoding = sRGBEncoding;
|
|
687
|
+
material.textureFilename = asset.textureFilename;
|
|
688
|
+
_f.label = 2;
|
|
689
|
+
case 2:
|
|
690
|
+
if (!asset.normal) return [3 /*break*/, 4];
|
|
691
|
+
_b = material;
|
|
692
|
+
return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_normal', asset.normal, material)];
|
|
693
|
+
case 3:
|
|
694
|
+
_b.normal = _f.sent();
|
|
695
|
+
material.normalFilename = asset.normalFilename;
|
|
696
|
+
_f.label = 4;
|
|
697
|
+
case 4:
|
|
698
|
+
if (!asset.ao) return [3 /*break*/, 6];
|
|
699
|
+
_c = material;
|
|
700
|
+
return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_ao', asset.ao, material)];
|
|
701
|
+
case 5:
|
|
702
|
+
_c.ao = _f.sent();
|
|
703
|
+
material.aoFilename = asset.aoFilename;
|
|
704
|
+
_f.label = 6;
|
|
705
|
+
case 6:
|
|
706
|
+
if (!asset.metalness) return [3 /*break*/, 8];
|
|
707
|
+
_d = material;
|
|
708
|
+
return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_metalness', asset.metalness, material)];
|
|
709
|
+
case 7:
|
|
710
|
+
_d.metalness = _f.sent();
|
|
711
|
+
material.metalnessFilename = asset.metalnessFilename;
|
|
712
|
+
_f.label = 8;
|
|
713
|
+
case 8:
|
|
714
|
+
if (!asset.roughness) return [3 /*break*/, 10];
|
|
715
|
+
_e = material;
|
|
716
|
+
return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_roughness', asset.roughness, material)];
|
|
717
|
+
case 9:
|
|
718
|
+
_e.roughness = _f.sent();
|
|
719
|
+
material.roughnessFilename = asset.roughnessFilename;
|
|
720
|
+
_f.label = 10;
|
|
721
|
+
case 10: return [2 /*return*/, material];
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
});
|
|
725
|
+
};
|
|
726
|
+
AssetUtils.setSettingsOfMaterial = function (material, settings) {
|
|
727
|
+
var shininess = parseFloat(settings['power']);
|
|
728
|
+
if (!isNaN(shininess)) {
|
|
729
|
+
material.shininess = shininess;
|
|
730
|
+
// material.roughness = 1 - (shininess / 100);
|
|
731
|
+
}
|
|
732
|
+
var level = parseFloat(settings['level']);
|
|
733
|
+
if (!isNaN(level)) {
|
|
734
|
+
material.specular = new Color(level, level, level);
|
|
735
|
+
}
|
|
736
|
+
var repeatObjectUsed = settings.hasOwnProperty('repeat');
|
|
737
|
+
var repeatx = repeatObjectUsed ? parseFloat(settings['repeat']['repeatx']) : parseFloat(settings['repeatx']);
|
|
738
|
+
if (!isNaN(repeatx)) {
|
|
739
|
+
material.repeatX = Math.max(1, repeatx);
|
|
740
|
+
}
|
|
741
|
+
var repeaty = repeatObjectUsed ? parseFloat(settings['repeat']['repeaty']) : parseFloat(settings['repeaty']);
|
|
742
|
+
if (!isNaN(repeaty)) {
|
|
743
|
+
material.repeatY = Math.max(1, repeaty);
|
|
744
|
+
}
|
|
745
|
+
var metalness = parseFloat(settings['metalness']);
|
|
746
|
+
if (!isNaN(metalness)) {
|
|
747
|
+
material.metalnessValue = Math.min(1, metalness);
|
|
748
|
+
}
|
|
749
|
+
var roughness = parseFloat(settings['roughness']);
|
|
750
|
+
if (!isNaN(roughness)) {
|
|
751
|
+
material.roughnessValue = Math.min(1, roughness);
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
return AssetUtils;
|
|
755
755
|
}());
|
|
756
756
|
|
|
757
|
-
var Variation = /** @class */ (function () {
|
|
758
|
-
function Variation() {
|
|
759
|
-
}
|
|
760
|
-
return Variation;
|
|
757
|
+
var Variation = /** @class */ (function () {
|
|
758
|
+
function Variation() {
|
|
759
|
+
}
|
|
760
|
+
return Variation;
|
|
761
761
|
}());
|
|
762
762
|
|
|
763
|
-
var VariationSettings = /** @class */ (function () {
|
|
764
|
-
function VariationSettings() {
|
|
765
|
-
this.settings = {};
|
|
766
|
-
}
|
|
767
|
-
return VariationSettings;
|
|
763
|
+
var VariationSettings = /** @class */ (function () {
|
|
764
|
+
function VariationSettings() {
|
|
765
|
+
this.settings = {};
|
|
766
|
+
}
|
|
767
|
+
return VariationSettings;
|
|
768
768
|
}());
|
|
769
769
|
|
|
770
|
-
// @dynamic
|
|
771
|
-
var VariationUtils = /** @class */ (function () {
|
|
772
|
-
function VariationUtils() {
|
|
773
|
-
}
|
|
774
|
-
VariationUtils.LoadVariation = function (assetPath, fileName) {
|
|
775
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
776
|
-
var id, file, err_1, mute;
|
|
777
|
-
return __generator(this, function (_a) {
|
|
778
|
-
switch (_a.label) {
|
|
779
|
-
case 0:
|
|
780
|
-
if (!fileName) {
|
|
781
|
-
return [2 /*return*/, null];
|
|
782
|
-
}
|
|
783
|
-
if (fileName.indexOf('ione3d') < 0) {
|
|
784
|
-
fileName = fileName.concat('.ione3d');
|
|
785
|
-
}
|
|
786
|
-
id = fileName.substr(0, fileName.lastIndexOf('.ione3d'));
|
|
787
|
-
_a.label = 1;
|
|
788
|
-
case 1:
|
|
789
|
-
_a.trys.push([1, 4, , 5]);
|
|
790
|
-
if (!assetPath.endsWith('/')) {
|
|
791
|
-
assetPath += '/';
|
|
792
|
-
}
|
|
793
|
-
if (!window.hasOwnProperty('downloadVariation')) {
|
|
794
|
-
console.error('downloadVariation not defined in window global');
|
|
795
|
-
return [2 /*return*/, null];
|
|
796
|
-
}
|
|
797
|
-
return [4 /*yield*/, window.downloadVariation(assetPath.replace('https://cdn1.colijn-it.nl/', '') + "variation/" + fileName)];
|
|
798
|
-
case 2:
|
|
799
|
-
file = _a.sent();
|
|
800
|
-
return [4 /*yield*/, VariationUtils.GetVariationSettingsFromFile(id, file)];
|
|
801
|
-
case 3: return [2 /*return*/, _a.sent()];
|
|
802
|
-
case 4:
|
|
803
|
-
err_1 = _a.sent();
|
|
804
|
-
mute = err_1;
|
|
805
|
-
return [2 /*return*/, null];
|
|
806
|
-
case 5: return [2 /*return*/];
|
|
807
|
-
}
|
|
808
|
-
});
|
|
809
|
-
});
|
|
810
|
-
};
|
|
811
|
-
// public static GetMaterialFromName(variationFolder: string, material: any): Promise<MeshStandardMaterial> {
|
|
812
|
-
// return new Promise((resolve: Function) => {
|
|
813
|
-
// if (!material) {
|
|
814
|
-
// resolve(null);
|
|
815
|
-
// }
|
|
816
|
-
// if (this.MaterialCache.has(material.name)) {
|
|
817
|
-
// resolve(this.MaterialCache.get(material.name).clone());
|
|
818
|
-
// } else {
|
|
819
|
-
// VariationUtils.LoadVariation(variationFolder, material.name, false).then((settings: VariationSettings) => {
|
|
820
|
-
// if (settings) {
|
|
821
|
-
// AssetUtils.CreateMaterialFromAsset(settings).then((materialObj: Material) => {
|
|
822
|
-
// const materialParams: MeshStandardMaterialParameters = {};
|
|
823
|
-
// materialParams.name = material.name;
|
|
824
|
-
// materialParams.map = materialObj.texture;
|
|
825
|
-
// materialParams.normalMap = materialObj.normal;
|
|
826
|
-
// materialParams.aoMap = materialObj.ao;
|
|
827
|
-
// materialParams.roughnessMap = materialObj.roughness;
|
|
828
|
-
// materialParams.metalnessMap = materialObj.metalness;
|
|
829
|
-
// materialParams.roughness = 1;
|
|
830
|
-
// materialParams.metalness = 1;
|
|
831
|
-
// const pbrMat: MeshStandardMaterial = new MeshStandardMaterial(materialParams);
|
|
832
|
-
// this.MaterialCache.set(material.name, pbrMat);
|
|
833
|
-
// resolve(pbrMat.clone());
|
|
834
|
-
// });
|
|
835
|
-
// } else {
|
|
836
|
-
// resolve(material);
|
|
837
|
-
// }
|
|
838
|
-
// });
|
|
839
|
-
// }
|
|
840
|
-
// });
|
|
841
|
-
// }
|
|
842
|
-
VariationUtils.GetVariationSettingsFromFile = function (id, compressedFile) {
|
|
843
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
844
|
-
var zipContent, variationSettings, index, indexFile;
|
|
845
|
-
return __generator(this, function (_a) {
|
|
846
|
-
switch (_a.label) {
|
|
847
|
-
case 0:
|
|
848
|
-
if (!compressedFile) {
|
|
849
|
-
return [2 /*return*/, null];
|
|
850
|
-
}
|
|
851
|
-
return [4 /*yield*/, VariationUtils.GetZipContent(compressedFile)];
|
|
852
|
-
case 1:
|
|
853
|
-
zipContent = _a.sent();
|
|
854
|
-
variationSettings = new VariationSettings();
|
|
855
|
-
variationSettings.id = id;
|
|
856
|
-
if (!zipContent.files['index.json']) return [3 /*break*/, 3];
|
|
857
|
-
return [4 /*yield*/, zipContent.files['index.json'].async('string')];
|
|
858
|
-
case 2:
|
|
859
|
-
indexFile = _a.sent();
|
|
860
|
-
index = JSON.parse(indexFile);
|
|
861
|
-
_a.label = 3;
|
|
862
|
-
case 3:
|
|
863
|
-
if (!index) return [3 /*break*/, 5];
|
|
864
|
-
return [4 /*yield*/, VariationUtils.CreateSettingsBasedOnIndex(index, variationSettings, zipContent)];
|
|
865
|
-
case 4:
|
|
866
|
-
_a.sent();
|
|
867
|
-
return [3 /*break*/, 7];
|
|
868
|
-
case 5: return [4 /*yield*/, VariationUtils.CreateSettingsBasedOnFileName(variationSettings, zipContent)];
|
|
869
|
-
case 6:
|
|
870
|
-
_a.sent();
|
|
871
|
-
_a.label = 7;
|
|
872
|
-
case 7: return [2 /*return*/, variationSettings];
|
|
873
|
-
}
|
|
874
|
-
});
|
|
875
|
-
});
|
|
876
|
-
};
|
|
877
|
-
VariationUtils.CreateSettingsBasedOnIndex = function (index, variationSettings, zipContent) {
|
|
878
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
879
|
-
var _a, _b, _c, _d, _e, _f;
|
|
880
|
-
return __generator(this, function (_g) {
|
|
881
|
-
switch (_g.label) {
|
|
882
|
-
case 0:
|
|
883
|
-
if (!index.normalFile) return [3 /*break*/, 2];
|
|
884
|
-
_a = variationSettings;
|
|
885
|
-
return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.normalFile], index.normalFile)];
|
|
886
|
-
case 1:
|
|
887
|
-
_a.normal = _g.sent();
|
|
888
|
-
variationSettings.normalFilename = index.normalFile;
|
|
889
|
-
_g.label = 2;
|
|
890
|
-
case 2:
|
|
891
|
-
if (!index.aoFile) return [3 /*break*/, 4];
|
|
892
|
-
_b = variationSettings;
|
|
893
|
-
return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.aoFile], index.aoFile)];
|
|
894
|
-
case 3:
|
|
895
|
-
_b.ao = _g.sent();
|
|
896
|
-
variationSettings.aoFilename = index.aoFile;
|
|
897
|
-
_g.label = 4;
|
|
898
|
-
case 4:
|
|
899
|
-
if (!index.metalnessFile) return [3 /*break*/, 6];
|
|
900
|
-
_c = variationSettings;
|
|
901
|
-
return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.metalnessFile], index.metalnessFile)];
|
|
902
|
-
case 5:
|
|
903
|
-
_c.metalness = _g.sent();
|
|
904
|
-
variationSettings.metalnessFilename = index.metalnessFile;
|
|
905
|
-
_g.label = 6;
|
|
906
|
-
case 6:
|
|
907
|
-
if (!index.roughnessFile) return [3 /*break*/, 8];
|
|
908
|
-
_d = variationSettings;
|
|
909
|
-
return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.roughnessFile], index.roughnessFile)];
|
|
910
|
-
case 7:
|
|
911
|
-
_d.roughness = _g.sent();
|
|
912
|
-
variationSettings.roughnessFilename = index.roughnessFile;
|
|
913
|
-
_g.label = 8;
|
|
914
|
-
case 8:
|
|
915
|
-
if (!index.diffuseFile) return [3 /*break*/, 10];
|
|
916
|
-
_e = variationSettings;
|
|
917
|
-
return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.diffuseFile], index.diffuseFile)];
|
|
918
|
-
case 9:
|
|
919
|
-
_e.texture = _g.sent();
|
|
920
|
-
variationSettings.textureFilename = index.diffuseFile;
|
|
921
|
-
_g.label = 10;
|
|
922
|
-
case 10:
|
|
923
|
-
_f = variationSettings;
|
|
924
|
-
return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files['repeat.json'], 'repeat.json', false)];
|
|
925
|
-
case 11:
|
|
926
|
-
_f.settings =
|
|
927
|
-
(_g.sent()) || {};
|
|
928
|
-
Object.assign(variationSettings.settings, index.repeat);
|
|
929
|
-
variationSettings.settings.metalness = index.metalness;
|
|
930
|
-
variationSettings.settings.roughness = index.roughness;
|
|
931
|
-
return [2 /*return*/];
|
|
932
|
-
}
|
|
933
|
-
});
|
|
934
|
-
});
|
|
935
|
-
};
|
|
936
|
-
VariationUtils.CreateSettingsBasedOnFileName = function (variationSettings, zipContent) {
|
|
937
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
938
|
-
var allLoaded, _loop_1, this_1, _a, _b, _i, fileName;
|
|
939
|
-
var _this = this;
|
|
940
|
-
return __generator(this, function (_c) {
|
|
941
|
-
switch (_c.label) {
|
|
942
|
-
case 0:
|
|
943
|
-
allLoaded = [];
|
|
944
|
-
_loop_1 = function (fileName) {
|
|
945
|
-
var file_1;
|
|
946
|
-
return __generator(this, function (_a) {
|
|
947
|
-
switch (_a.label) {
|
|
948
|
-
case 0:
|
|
949
|
-
if (!zipContent.files[fileName]) return [3 /*break*/, 2];
|
|
950
|
-
return [4 /*yield*/, zipContent.files[fileName]];
|
|
951
|
-
case 1:
|
|
952
|
-
file_1 = _a.sent();
|
|
953
|
-
if (file_1.name.toLowerCase().indexOf('normal') > -1 && this_1.FileIsImage(file_1.name)) {
|
|
954
|
-
allLoaded.push(zipContent.files[fileName].async('base64').then(function (normalFile) {
|
|
955
|
-
variationSettings.normal = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + normalFile;
|
|
956
|
-
variationSettings.normalFilename = fileName;
|
|
957
|
-
}));
|
|
958
|
-
}
|
|
959
|
-
else if (file_1.name.toLowerCase().indexOf('ao') > -1 && this_1.FileIsImage(file_1.name)) {
|
|
960
|
-
allLoaded.push(zipContent.files[fileName].async('base64').then(function (aoFile) {
|
|
961
|
-
variationSettings.ao = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + aoFile;
|
|
962
|
-
variationSettings.aoFilename = fileName;
|
|
963
|
-
}));
|
|
964
|
-
}
|
|
965
|
-
else if (file_1.name.toLowerCase().indexOf('metalness') > -1 && this_1.FileIsImage(file_1.name)) {
|
|
966
|
-
allLoaded.push(zipContent.files[fileName].async('base64').then(function (metalnessFile) {
|
|
967
|
-
variationSettings.metalness = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + metalnessFile;
|
|
968
|
-
variationSettings.metalnessFilename = fileName;
|
|
969
|
-
}));
|
|
970
|
-
}
|
|
971
|
-
else if (file_1.name.toLowerCase().indexOf('roughness') > -1 && this_1.FileIsImage(file_1.name)) {
|
|
972
|
-
allLoaded.push(zipContent.files[fileName].async('base64').then(function (roughnessFile) {
|
|
973
|
-
variationSettings.roughness = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + roughnessFile;
|
|
974
|
-
variationSettings.roughnessFilename = fileName;
|
|
975
|
-
}));
|
|
976
|
-
}
|
|
977
|
-
else if (file_1.name.toLowerCase().indexOf('diffuse') > -1 && this_1.FileIsImage(file_1.name)) {
|
|
978
|
-
allLoaded.push(zipContent.files[fileName].async('base64').then(function (diffuseFile) {
|
|
979
|
-
variationSettings.texture = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + diffuseFile;
|
|
980
|
-
variationSettings.textureFilename = fileName;
|
|
981
|
-
}));
|
|
982
|
-
}
|
|
983
|
-
else if (file_1.name.indexOf('.jp') > -1) {
|
|
984
|
-
allLoaded.push(zipContent.files[fileName].async('base64').then(function (textureFile) {
|
|
985
|
-
variationSettings.texture = 'data:image/jpeg;base64,' + textureFile;
|
|
986
|
-
variationSettings.textureFilename = fileName;
|
|
987
|
-
}));
|
|
988
|
-
}
|
|
989
|
-
else if (file_1.name.indexOf('.json') > -1) {
|
|
990
|
-
allLoaded.push(zipContent.files[fileName].async('string').then(function (settingsFile) {
|
|
991
|
-
var settingsFileObj = JSON.parse(settingsFile);
|
|
992
|
-
for (var key in settingsFileObj) {
|
|
993
|
-
if (settingsFileObj[key]) {
|
|
994
|
-
variationSettings.settings[key] = settingsFileObj[key];
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
}));
|
|
998
|
-
}
|
|
999
|
-
_a.label = 2;
|
|
1000
|
-
case 2: return [2 /*return*/];
|
|
1001
|
-
}
|
|
1002
|
-
});
|
|
1003
|
-
};
|
|
1004
|
-
this_1 = this;
|
|
1005
|
-
_a = [];
|
|
1006
|
-
for (_b in zipContent.files)
|
|
1007
|
-
_a.push(_b);
|
|
1008
|
-
_i = 0;
|
|
1009
|
-
_c.label = 1;
|
|
1010
|
-
case 1:
|
|
1011
|
-
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
1012
|
-
fileName = _a[_i];
|
|
1013
|
-
return [5 /*yield**/, _loop_1(fileName)];
|
|
1014
|
-
case 2:
|
|
1015
|
-
_c.sent();
|
|
1016
|
-
_c.label = 3;
|
|
1017
|
-
case 3:
|
|
1018
|
-
_i++;
|
|
1019
|
-
return [3 /*break*/, 1];
|
|
1020
|
-
case 4: return [4 /*yield*/, Promise.all(allLoaded)];
|
|
1021
|
-
case 5:
|
|
1022
|
-
_c.sent();
|
|
1023
|
-
return [2 /*return*/];
|
|
1024
|
-
}
|
|
1025
|
-
});
|
|
1026
|
-
});
|
|
1027
|
-
};
|
|
1028
|
-
VariationUtils.LoadFileContentFromZip = function (zip, fileName, base64) {
|
|
1029
|
-
var _this = this;
|
|
1030
|
-
if (base64 === void 0) { base64 = true; }
|
|
1031
|
-
return new Promise(function (resolve) {
|
|
1032
|
-
if (zip && fileName) {
|
|
1033
|
-
zip.async(base64 ? 'base64' : 'string').then(function (fileContent) {
|
|
1034
|
-
if (base64) {
|
|
1035
|
-
resolve("data:image/" + _this.GetBase64FileType(fileName) + ";base64," + fileContent);
|
|
1036
|
-
}
|
|
1037
|
-
else {
|
|
1038
|
-
resolve(fileContent);
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
else {
|
|
1043
|
-
resolve(undefined);
|
|
1044
|
-
}
|
|
1045
|
-
});
|
|
1046
|
-
};
|
|
1047
|
-
VariationUtils.FileIsImage = function (fileName) {
|
|
1048
|
-
var ext = fileName.substring(fileName.lastIndexOf('.') + 1, fileName.length).toLowerCase();
|
|
1049
|
-
switch (ext) {
|
|
1050
|
-
case 'jpg':
|
|
1051
|
-
case 'jpeg':
|
|
1052
|
-
case 'png':
|
|
1053
|
-
case 'bmp':
|
|
1054
|
-
return true;
|
|
1055
|
-
default:
|
|
1056
|
-
return false;
|
|
1057
|
-
}
|
|
1058
|
-
};
|
|
1059
|
-
VariationUtils.GetBase64FileType = function (fileName) {
|
|
1060
|
-
var ext = fileName.substring(fileName.lastIndexOf('.') + 1, fileName.length).toLowerCase();
|
|
1061
|
-
switch (ext) {
|
|
1062
|
-
case 'jpg':
|
|
1063
|
-
case 'jpeg':
|
|
1064
|
-
return 'jpeg';
|
|
1065
|
-
case 'png':
|
|
1066
|
-
return 'png';
|
|
1067
|
-
case 'bmp':
|
|
1068
|
-
return 'bmp';
|
|
1069
|
-
default:
|
|
1070
|
-
return 'jpeg';
|
|
1071
|
-
}
|
|
1072
|
-
};
|
|
1073
|
-
// Get the content
|
|
1074
|
-
VariationUtils.GetZipContent = function (file) {
|
|
1075
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1076
|
-
var jszip, content;
|
|
1077
|
-
return __generator(this, function (_a) {
|
|
1078
|
-
switch (_a.label) {
|
|
1079
|
-
case 0:
|
|
1080
|
-
jszip = new JSZip();
|
|
1081
|
-
return [4 /*yield*/, jszip.loadAsync(file)];
|
|
1082
|
-
case 1:
|
|
1083
|
-
content = _a.sent();
|
|
1084
|
-
return [2 /*return*/, content];
|
|
1085
|
-
}
|
|
1086
|
-
});
|
|
1087
|
-
});
|
|
1088
|
-
};
|
|
1089
|
-
VariationUtils.MaterialCache = new Map();
|
|
1090
|
-
return VariationUtils;
|
|
770
|
+
// @dynamic
|
|
771
|
+
var VariationUtils = /** @class */ (function () {
|
|
772
|
+
function VariationUtils() {
|
|
773
|
+
}
|
|
774
|
+
VariationUtils.LoadVariation = function (assetPath, fileName) {
|
|
775
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
776
|
+
var id, file, err_1, mute;
|
|
777
|
+
return __generator(this, function (_a) {
|
|
778
|
+
switch (_a.label) {
|
|
779
|
+
case 0:
|
|
780
|
+
if (!fileName) {
|
|
781
|
+
return [2 /*return*/, null];
|
|
782
|
+
}
|
|
783
|
+
if (fileName.indexOf('ione3d') < 0) {
|
|
784
|
+
fileName = fileName.concat('.ione3d');
|
|
785
|
+
}
|
|
786
|
+
id = fileName.substr(0, fileName.lastIndexOf('.ione3d'));
|
|
787
|
+
_a.label = 1;
|
|
788
|
+
case 1:
|
|
789
|
+
_a.trys.push([1, 4, , 5]);
|
|
790
|
+
if (!assetPath.endsWith('/')) {
|
|
791
|
+
assetPath += '/';
|
|
792
|
+
}
|
|
793
|
+
if (!window.hasOwnProperty('downloadVariation')) {
|
|
794
|
+
console.error('downloadVariation not defined in window global');
|
|
795
|
+
return [2 /*return*/, null];
|
|
796
|
+
}
|
|
797
|
+
return [4 /*yield*/, window.downloadVariation(assetPath.replace('https://cdn1.colijn-it.nl/', '') + "variation/" + fileName)];
|
|
798
|
+
case 2:
|
|
799
|
+
file = _a.sent();
|
|
800
|
+
return [4 /*yield*/, VariationUtils.GetVariationSettingsFromFile(id, file)];
|
|
801
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
802
|
+
case 4:
|
|
803
|
+
err_1 = _a.sent();
|
|
804
|
+
mute = err_1;
|
|
805
|
+
return [2 /*return*/, null];
|
|
806
|
+
case 5: return [2 /*return*/];
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
});
|
|
810
|
+
};
|
|
811
|
+
// public static GetMaterialFromName(variationFolder: string, material: any): Promise<MeshStandardMaterial> {
|
|
812
|
+
// return new Promise((resolve: Function) => {
|
|
813
|
+
// if (!material) {
|
|
814
|
+
// resolve(null);
|
|
815
|
+
// }
|
|
816
|
+
// if (this.MaterialCache.has(material.name)) {
|
|
817
|
+
// resolve(this.MaterialCache.get(material.name).clone());
|
|
818
|
+
// } else {
|
|
819
|
+
// VariationUtils.LoadVariation(variationFolder, material.name, false).then((settings: VariationSettings) => {
|
|
820
|
+
// if (settings) {
|
|
821
|
+
// AssetUtils.CreateMaterialFromAsset(settings).then((materialObj: Material) => {
|
|
822
|
+
// const materialParams: MeshStandardMaterialParameters = {};
|
|
823
|
+
// materialParams.name = material.name;
|
|
824
|
+
// materialParams.map = materialObj.texture;
|
|
825
|
+
// materialParams.normalMap = materialObj.normal;
|
|
826
|
+
// materialParams.aoMap = materialObj.ao;
|
|
827
|
+
// materialParams.roughnessMap = materialObj.roughness;
|
|
828
|
+
// materialParams.metalnessMap = materialObj.metalness;
|
|
829
|
+
// materialParams.roughness = 1;
|
|
830
|
+
// materialParams.metalness = 1;
|
|
831
|
+
// const pbrMat: MeshStandardMaterial = new MeshStandardMaterial(materialParams);
|
|
832
|
+
// this.MaterialCache.set(material.name, pbrMat);
|
|
833
|
+
// resolve(pbrMat.clone());
|
|
834
|
+
// });
|
|
835
|
+
// } else {
|
|
836
|
+
// resolve(material);
|
|
837
|
+
// }
|
|
838
|
+
// });
|
|
839
|
+
// }
|
|
840
|
+
// });
|
|
841
|
+
// }
|
|
842
|
+
VariationUtils.GetVariationSettingsFromFile = function (id, compressedFile) {
|
|
843
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
844
|
+
var zipContent, variationSettings, index, indexFile;
|
|
845
|
+
return __generator(this, function (_a) {
|
|
846
|
+
switch (_a.label) {
|
|
847
|
+
case 0:
|
|
848
|
+
if (!compressedFile) {
|
|
849
|
+
return [2 /*return*/, null];
|
|
850
|
+
}
|
|
851
|
+
return [4 /*yield*/, VariationUtils.GetZipContent(compressedFile)];
|
|
852
|
+
case 1:
|
|
853
|
+
zipContent = _a.sent();
|
|
854
|
+
variationSettings = new VariationSettings();
|
|
855
|
+
variationSettings.id = id;
|
|
856
|
+
if (!zipContent.files['index.json']) return [3 /*break*/, 3];
|
|
857
|
+
return [4 /*yield*/, zipContent.files['index.json'].async('string')];
|
|
858
|
+
case 2:
|
|
859
|
+
indexFile = _a.sent();
|
|
860
|
+
index = JSON.parse(indexFile);
|
|
861
|
+
_a.label = 3;
|
|
862
|
+
case 3:
|
|
863
|
+
if (!index) return [3 /*break*/, 5];
|
|
864
|
+
return [4 /*yield*/, VariationUtils.CreateSettingsBasedOnIndex(index, variationSettings, zipContent)];
|
|
865
|
+
case 4:
|
|
866
|
+
_a.sent();
|
|
867
|
+
return [3 /*break*/, 7];
|
|
868
|
+
case 5: return [4 /*yield*/, VariationUtils.CreateSettingsBasedOnFileName(variationSettings, zipContent)];
|
|
869
|
+
case 6:
|
|
870
|
+
_a.sent();
|
|
871
|
+
_a.label = 7;
|
|
872
|
+
case 7: return [2 /*return*/, variationSettings];
|
|
873
|
+
}
|
|
874
|
+
});
|
|
875
|
+
});
|
|
876
|
+
};
|
|
877
|
+
VariationUtils.CreateSettingsBasedOnIndex = function (index, variationSettings, zipContent) {
|
|
878
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
879
|
+
var _a, _b, _c, _d, _e, _f;
|
|
880
|
+
return __generator(this, function (_g) {
|
|
881
|
+
switch (_g.label) {
|
|
882
|
+
case 0:
|
|
883
|
+
if (!index.normalFile) return [3 /*break*/, 2];
|
|
884
|
+
_a = variationSettings;
|
|
885
|
+
return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.normalFile], index.normalFile)];
|
|
886
|
+
case 1:
|
|
887
|
+
_a.normal = _g.sent();
|
|
888
|
+
variationSettings.normalFilename = index.normalFile;
|
|
889
|
+
_g.label = 2;
|
|
890
|
+
case 2:
|
|
891
|
+
if (!index.aoFile) return [3 /*break*/, 4];
|
|
892
|
+
_b = variationSettings;
|
|
893
|
+
return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.aoFile], index.aoFile)];
|
|
894
|
+
case 3:
|
|
895
|
+
_b.ao = _g.sent();
|
|
896
|
+
variationSettings.aoFilename = index.aoFile;
|
|
897
|
+
_g.label = 4;
|
|
898
|
+
case 4:
|
|
899
|
+
if (!index.metalnessFile) return [3 /*break*/, 6];
|
|
900
|
+
_c = variationSettings;
|
|
901
|
+
return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.metalnessFile], index.metalnessFile)];
|
|
902
|
+
case 5:
|
|
903
|
+
_c.metalness = _g.sent();
|
|
904
|
+
variationSettings.metalnessFilename = index.metalnessFile;
|
|
905
|
+
_g.label = 6;
|
|
906
|
+
case 6:
|
|
907
|
+
if (!index.roughnessFile) return [3 /*break*/, 8];
|
|
908
|
+
_d = variationSettings;
|
|
909
|
+
return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.roughnessFile], index.roughnessFile)];
|
|
910
|
+
case 7:
|
|
911
|
+
_d.roughness = _g.sent();
|
|
912
|
+
variationSettings.roughnessFilename = index.roughnessFile;
|
|
913
|
+
_g.label = 8;
|
|
914
|
+
case 8:
|
|
915
|
+
if (!index.diffuseFile) return [3 /*break*/, 10];
|
|
916
|
+
_e = variationSettings;
|
|
917
|
+
return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.diffuseFile], index.diffuseFile)];
|
|
918
|
+
case 9:
|
|
919
|
+
_e.texture = _g.sent();
|
|
920
|
+
variationSettings.textureFilename = index.diffuseFile;
|
|
921
|
+
_g.label = 10;
|
|
922
|
+
case 10:
|
|
923
|
+
_f = variationSettings;
|
|
924
|
+
return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files['repeat.json'], 'repeat.json', false)];
|
|
925
|
+
case 11:
|
|
926
|
+
_f.settings =
|
|
927
|
+
(_g.sent()) || {};
|
|
928
|
+
Object.assign(variationSettings.settings, index.repeat);
|
|
929
|
+
variationSettings.settings.metalness = index.metalness;
|
|
930
|
+
variationSettings.settings.roughness = index.roughness;
|
|
931
|
+
return [2 /*return*/];
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
});
|
|
935
|
+
};
|
|
936
|
+
VariationUtils.CreateSettingsBasedOnFileName = function (variationSettings, zipContent) {
|
|
937
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
938
|
+
var allLoaded, _loop_1, this_1, _a, _b, _i, fileName;
|
|
939
|
+
var _this = this;
|
|
940
|
+
return __generator(this, function (_c) {
|
|
941
|
+
switch (_c.label) {
|
|
942
|
+
case 0:
|
|
943
|
+
allLoaded = [];
|
|
944
|
+
_loop_1 = function (fileName) {
|
|
945
|
+
var file_1;
|
|
946
|
+
return __generator(this, function (_a) {
|
|
947
|
+
switch (_a.label) {
|
|
948
|
+
case 0:
|
|
949
|
+
if (!zipContent.files[fileName]) return [3 /*break*/, 2];
|
|
950
|
+
return [4 /*yield*/, zipContent.files[fileName]];
|
|
951
|
+
case 1:
|
|
952
|
+
file_1 = _a.sent();
|
|
953
|
+
if (file_1.name.toLowerCase().indexOf('normal') > -1 && this_1.FileIsImage(file_1.name)) {
|
|
954
|
+
allLoaded.push(zipContent.files[fileName].async('base64').then(function (normalFile) {
|
|
955
|
+
variationSettings.normal = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + normalFile;
|
|
956
|
+
variationSettings.normalFilename = fileName;
|
|
957
|
+
}));
|
|
958
|
+
}
|
|
959
|
+
else if (file_1.name.toLowerCase().indexOf('ao') > -1 && this_1.FileIsImage(file_1.name)) {
|
|
960
|
+
allLoaded.push(zipContent.files[fileName].async('base64').then(function (aoFile) {
|
|
961
|
+
variationSettings.ao = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + aoFile;
|
|
962
|
+
variationSettings.aoFilename = fileName;
|
|
963
|
+
}));
|
|
964
|
+
}
|
|
965
|
+
else if (file_1.name.toLowerCase().indexOf('metalness') > -1 && this_1.FileIsImage(file_1.name)) {
|
|
966
|
+
allLoaded.push(zipContent.files[fileName].async('base64').then(function (metalnessFile) {
|
|
967
|
+
variationSettings.metalness = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + metalnessFile;
|
|
968
|
+
variationSettings.metalnessFilename = fileName;
|
|
969
|
+
}));
|
|
970
|
+
}
|
|
971
|
+
else if (file_1.name.toLowerCase().indexOf('roughness') > -1 && this_1.FileIsImage(file_1.name)) {
|
|
972
|
+
allLoaded.push(zipContent.files[fileName].async('base64').then(function (roughnessFile) {
|
|
973
|
+
variationSettings.roughness = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + roughnessFile;
|
|
974
|
+
variationSettings.roughnessFilename = fileName;
|
|
975
|
+
}));
|
|
976
|
+
}
|
|
977
|
+
else if (file_1.name.toLowerCase().indexOf('diffuse') > -1 && this_1.FileIsImage(file_1.name)) {
|
|
978
|
+
allLoaded.push(zipContent.files[fileName].async('base64').then(function (diffuseFile) {
|
|
979
|
+
variationSettings.texture = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + diffuseFile;
|
|
980
|
+
variationSettings.textureFilename = fileName;
|
|
981
|
+
}));
|
|
982
|
+
}
|
|
983
|
+
else if (file_1.name.indexOf('.jp') > -1) {
|
|
984
|
+
allLoaded.push(zipContent.files[fileName].async('base64').then(function (textureFile) {
|
|
985
|
+
variationSettings.texture = 'data:image/jpeg;base64,' + textureFile;
|
|
986
|
+
variationSettings.textureFilename = fileName;
|
|
987
|
+
}));
|
|
988
|
+
}
|
|
989
|
+
else if (file_1.name.indexOf('.json') > -1) {
|
|
990
|
+
allLoaded.push(zipContent.files[fileName].async('string').then(function (settingsFile) {
|
|
991
|
+
var settingsFileObj = JSON.parse(settingsFile);
|
|
992
|
+
for (var key in settingsFileObj) {
|
|
993
|
+
if (settingsFileObj[key]) {
|
|
994
|
+
variationSettings.settings[key] = settingsFileObj[key];
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}));
|
|
998
|
+
}
|
|
999
|
+
_a.label = 2;
|
|
1000
|
+
case 2: return [2 /*return*/];
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
};
|
|
1004
|
+
this_1 = this;
|
|
1005
|
+
_a = [];
|
|
1006
|
+
for (_b in zipContent.files)
|
|
1007
|
+
_a.push(_b);
|
|
1008
|
+
_i = 0;
|
|
1009
|
+
_c.label = 1;
|
|
1010
|
+
case 1:
|
|
1011
|
+
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
1012
|
+
fileName = _a[_i];
|
|
1013
|
+
return [5 /*yield**/, _loop_1(fileName)];
|
|
1014
|
+
case 2:
|
|
1015
|
+
_c.sent();
|
|
1016
|
+
_c.label = 3;
|
|
1017
|
+
case 3:
|
|
1018
|
+
_i++;
|
|
1019
|
+
return [3 /*break*/, 1];
|
|
1020
|
+
case 4: return [4 /*yield*/, Promise.all(allLoaded)];
|
|
1021
|
+
case 5:
|
|
1022
|
+
_c.sent();
|
|
1023
|
+
return [2 /*return*/];
|
|
1024
|
+
}
|
|
1025
|
+
});
|
|
1026
|
+
});
|
|
1027
|
+
};
|
|
1028
|
+
VariationUtils.LoadFileContentFromZip = function (zip, fileName, base64) {
|
|
1029
|
+
var _this = this;
|
|
1030
|
+
if (base64 === void 0) { base64 = true; }
|
|
1031
|
+
return new Promise(function (resolve) {
|
|
1032
|
+
if (zip && fileName) {
|
|
1033
|
+
zip.async(base64 ? 'base64' : 'string').then(function (fileContent) {
|
|
1034
|
+
if (base64) {
|
|
1035
|
+
resolve("data:image/" + _this.GetBase64FileType(fileName) + ";base64," + fileContent);
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
resolve(fileContent);
|
|
1039
|
+
}
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
else {
|
|
1043
|
+
resolve(undefined);
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1046
|
+
};
|
|
1047
|
+
VariationUtils.FileIsImage = function (fileName) {
|
|
1048
|
+
var ext = fileName.substring(fileName.lastIndexOf('.') + 1, fileName.length).toLowerCase();
|
|
1049
|
+
switch (ext) {
|
|
1050
|
+
case 'jpg':
|
|
1051
|
+
case 'jpeg':
|
|
1052
|
+
case 'png':
|
|
1053
|
+
case 'bmp':
|
|
1054
|
+
return true;
|
|
1055
|
+
default:
|
|
1056
|
+
return false;
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
VariationUtils.GetBase64FileType = function (fileName) {
|
|
1060
|
+
var ext = fileName.substring(fileName.lastIndexOf('.') + 1, fileName.length).toLowerCase();
|
|
1061
|
+
switch (ext) {
|
|
1062
|
+
case 'jpg':
|
|
1063
|
+
case 'jpeg':
|
|
1064
|
+
return 'jpeg';
|
|
1065
|
+
case 'png':
|
|
1066
|
+
return 'png';
|
|
1067
|
+
case 'bmp':
|
|
1068
|
+
return 'bmp';
|
|
1069
|
+
default:
|
|
1070
|
+
return 'jpeg';
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
// Get the content
|
|
1074
|
+
VariationUtils.GetZipContent = function (file) {
|
|
1075
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1076
|
+
var jszip, content;
|
|
1077
|
+
return __generator(this, function (_a) {
|
|
1078
|
+
switch (_a.label) {
|
|
1079
|
+
case 0:
|
|
1080
|
+
jszip = new JSZip();
|
|
1081
|
+
return [4 /*yield*/, jszip.loadAsync(file)];
|
|
1082
|
+
case 1:
|
|
1083
|
+
content = _a.sent();
|
|
1084
|
+
return [2 /*return*/, content];
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
});
|
|
1088
|
+
};
|
|
1089
|
+
VariationUtils.MaterialCache = new Map();
|
|
1090
|
+
return VariationUtils;
|
|
1091
1091
|
}());
|
|
1092
1092
|
|
|
1093
|
-
var VariationHelper = /** @class */ (function () {
|
|
1094
|
-
function VariationHelper() {
|
|
1095
|
-
this._lastKnownVariations = new Map();
|
|
1096
|
-
}
|
|
1097
|
-
VariationHelper.prototype.clearCache = function () {
|
|
1098
|
-
var valueMap = Array.from(this._lastKnownVariations.values());
|
|
1099
|
-
for (var i = 0; i < valueMap.length; i++) {
|
|
1100
|
-
var values = Array.from(valueMap[i].values());
|
|
1101
|
-
values.forEach(function (variations) {
|
|
1102
|
-
variations.forEach(function (variation) {
|
|
1103
|
-
variation.material.texture.dispose();
|
|
1104
|
-
variation.material.normal.dispose();
|
|
1105
|
-
variation.material.metalness.dispose();
|
|
1106
|
-
variation.material.roughness.dispose();
|
|
1107
|
-
variation.material.ao.dispose();
|
|
1108
|
-
});
|
|
1109
|
-
});
|
|
1110
|
-
}
|
|
1111
|
-
};
|
|
1112
|
-
VariationHelper.prototype.loadPart = function (obj, parts, usePbr) {
|
|
1113
|
-
if (usePbr === void 0) { usePbr = false; }
|
|
1114
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1115
|
-
var len, i, partSettings, partVariation, _a, e_1;
|
|
1116
|
-
return __generator(this, function (_b) {
|
|
1117
|
-
switch (_b.label) {
|
|
1118
|
-
case 0:
|
|
1119
|
-
_b.trys.push([0, 6, , 7]);
|
|
1120
|
-
len = parts.length;
|
|
1121
|
-
i = 0;
|
|
1122
|
-
_b.label = 1;
|
|
1123
|
-
case 1:
|
|
1124
|
-
if (!(i < len)) return [3 /*break*/, 5];
|
|
1125
|
-
if (!(parts[i].decoNode && parts[i].decoNode.gameObjectName && parts[i].decoNode.type === DecoNodeType.Part)) return [3 /*break*/, 4];
|
|
1126
|
-
return [4 /*yield*/, VariationUtils.LoadVariation(this.assetPath, parts[i].decoNode.gameObjectName || parts[i].decoId)];
|
|
1127
|
-
case 2:
|
|
1128
|
-
partSettings = _b.sent();
|
|
1129
|
-
if (!partSettings) return [3 /*break*/, 4];
|
|
1130
|
-
partVariation = new Variation();
|
|
1131
|
-
partVariation.decoId = parseFloat(parts[i].decoNode.id);
|
|
1132
|
-
partVariation.brandId = parts[i].decoNode.brandId;
|
|
1133
|
-
partVariation.gameObjectName = parts[i].decoNode.gameObjectName;
|
|
1134
|
-
_a = partVariation;
|
|
1135
|
-
return [4 /*yield*/, AssetUtils.CreateMaterialFromAsset(partSettings)];
|
|
1136
|
-
case 3:
|
|
1137
|
-
_a.material = _b.sent();
|
|
1138
|
-
// parts[i].variation = partVariation;
|
|
1139
|
-
this._applyMaterialPart(obj, partVariation, parts[i].node, usePbr);
|
|
1140
|
-
_b.label = 4;
|
|
1141
|
-
case 4:
|
|
1142
|
-
i++;
|
|
1143
|
-
return [3 /*break*/, 1];
|
|
1144
|
-
case 5: return [3 /*break*/, 7];
|
|
1145
|
-
case 6:
|
|
1146
|
-
e_1 = _b.sent();
|
|
1147
|
-
console.error(e_1);
|
|
1148
|
-
return [3 /*break*/, 7];
|
|
1149
|
-
case 7: return [2 /*return*/];
|
|
1150
|
-
}
|
|
1151
|
-
});
|
|
1152
|
-
});
|
|
1153
|
-
};
|
|
1154
|
-
VariationHelper.prototype.loadVariation = function (instanceId, obj, parts, usePbr) {
|
|
1155
|
-
if (usePbr === void 0) { usePbr = false; }
|
|
1156
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1157
|
-
var len, i, variations, lastKnownVariations, j, variationSettings, newVariation, _a, e_2;
|
|
1158
|
-
return __generator(this, function (_b) {
|
|
1159
|
-
switch (_b.label) {
|
|
1160
|
-
case 0:
|
|
1161
|
-
_b.trys.push([0, 9, , 10]);
|
|
1162
|
-
len = parts.length;
|
|
1163
|
-
i = 0;
|
|
1164
|
-
_b.label = 1;
|
|
1165
|
-
case 1:
|
|
1166
|
-
if (!(i < len)) return [3 /*break*/, 8];
|
|
1167
|
-
variations = parts[i].variations;
|
|
1168
|
-
if (!variations || variations.length === 0) {
|
|
1169
|
-
if (this._getLastKnownVariations(instanceId, parts[i].nodeId)) {
|
|
1170
|
-
parts[i].variations = this._getLastKnownVariations(instanceId, parts[i].nodeId);
|
|
1171
|
-
this._applyVariations(obj, parts[i], usePbr);
|
|
1172
|
-
return [3 /*break*/, 7];
|
|
1173
|
-
}
|
|
1174
|
-
else {
|
|
1175
|
-
return [3 /*break*/, 7];
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
lastKnownVariations = [];
|
|
1179
|
-
j = 0;
|
|
1180
|
-
_b.label = 2;
|
|
1181
|
-
case 2:
|
|
1182
|
-
if (!(j < variations.length)) return [3 /*break*/, 6];
|
|
1183
|
-
return [4 /*yield*/, VariationUtils.LoadVariation(this.assetPath, variations[j].gameObjectName || parts[i].decoId)];
|
|
1184
|
-
case 3:
|
|
1185
|
-
variationSettings = _b.sent();
|
|
1186
|
-
newVariation = new Variation();
|
|
1187
|
-
newVariation.decoId = parseFloat(variations[j].id);
|
|
1188
|
-
newVariation.brandId = variations[j].brandId;
|
|
1189
|
-
newVariation.gameObjectName = variations[j].gameObjectName;
|
|
1190
|
-
newVariation.supplierArticleNr = variations[j].supplierArticleNr;
|
|
1191
|
-
newVariation.materialId = variations[j].materialId;
|
|
1192
|
-
_a = newVariation;
|
|
1193
|
-
return [4 /*yield*/, AssetUtils.CreateMaterialFromAsset(variationSettings)];
|
|
1194
|
-
case 4:
|
|
1195
|
-
_a.material = _b.sent();
|
|
1196
|
-
lastKnownVariations.push(newVariation);
|
|
1197
|
-
_b.label = 5;
|
|
1198
|
-
case 5:
|
|
1199
|
-
j++;
|
|
1200
|
-
return [3 /*break*/, 2];
|
|
1201
|
-
case 6:
|
|
1202
|
-
this._setLastKnownVariations(instanceId, parts[i].nodeId, lastKnownVariations);
|
|
1203
|
-
parts[i].variations = lastKnownVariations;
|
|
1204
|
-
this._applyVariations(obj, parts[i], usePbr);
|
|
1205
|
-
_b.label = 7;
|
|
1206
|
-
case 7:
|
|
1207
|
-
i++;
|
|
1208
|
-
return [3 /*break*/, 1];
|
|
1209
|
-
case 8: return [3 /*break*/, 10];
|
|
1210
|
-
case 9:
|
|
1211
|
-
e_2 = _b.sent();
|
|
1212
|
-
console.error(e_2);
|
|
1213
|
-
return [3 /*break*/, 10];
|
|
1214
|
-
case 10: return [2 /*return*/];
|
|
1215
|
-
}
|
|
1216
|
-
});
|
|
1217
|
-
});
|
|
1218
|
-
};
|
|
1219
|
-
VariationHelper.prototype._getChildrenFilterByProp = function (obj, userDataObjectProp, prop, value) {
|
|
1220
|
-
return obj.children.filter(function (child) {
|
|
1221
|
-
return child.userData &&
|
|
1222
|
-
child.userData.hasOwnProperty(userDataObjectProp) &&
|
|
1223
|
-
child.userData[userDataObjectProp].hasOwnProperty(prop) &&
|
|
1224
|
-
child.userData[userDataObjectProp][prop] === value;
|
|
1225
|
-
});
|
|
1226
|
-
};
|
|
1227
|
-
VariationHelper.prototype._applyMaterialPart = function (obj, partMaterial, nodeId, usePbr) {
|
|
1228
|
-
var _this = this;
|
|
1229
|
-
if (usePbr === void 0) { usePbr = false; }
|
|
1230
|
-
var children = this._getChildrenFilterByProp(obj, 'selection', 'node', nodeId);
|
|
1231
|
-
var len = children.length;
|
|
1232
|
-
for (var i = 0; i < len; i++) {
|
|
1233
|
-
var child = children[i];
|
|
1234
|
-
if (child !== null && child !== undefined) {
|
|
1235
|
-
child.traverse(function (mesh) {
|
|
1236
|
-
if (mesh instanceof Mesh && partMaterial) {
|
|
1237
|
-
if (Array.isArray(mesh.material)) { // multimaterial support
|
|
1238
|
-
for (var j = 0, jlen = mesh.material.length; j < jlen; j++) {
|
|
1239
|
-
if (mesh.material[j].name.toLowerCase().indexOf('fixed_frame') !== -1) {
|
|
1240
|
-
mesh.material[j] = _this._setMeshMaterialFromVariation(mesh.material[j].name, partMaterial, usePbr);
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
else {
|
|
1245
|
-
if (mesh.material.name.toLowerCase().indexOf('fixed_frame') !== -1) {
|
|
1246
|
-
mesh.material = _this._setMeshMaterialFromVariation(mesh.material.name, partMaterial, usePbr);
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
});
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
};
|
|
1254
|
-
VariationHelper.prototype._applyVariations = function (obj, part, usePbr) {
|
|
1255
|
-
var _this = this;
|
|
1256
|
-
if (usePbr === void 0) { usePbr = false; }
|
|
1257
|
-
var children = this._getChildrenFilterByProp(obj, 'selection', 'node', part.node);
|
|
1258
|
-
var len = children.length;
|
|
1259
|
-
for (var i = 0; i < len; i++) {
|
|
1260
|
-
var child = children[i];
|
|
1261
|
-
if (child !== null && child !== undefined) {
|
|
1262
|
-
child.traverse(function (mesh) {
|
|
1263
|
-
if (mesh instanceof Mesh && part.variations && part.variations.length > 0 && mesh.name.toLowerCase().indexOf('c_')) {
|
|
1264
|
-
for (var j = 0; j < part.variations.length; j++) {
|
|
1265
|
-
var variation = part.variations[j];
|
|
1266
|
-
if (variation.material) {
|
|
1267
|
-
var materialToSearch = !!variation.materialId ? variation.materialId.toLowerCase() : 'default';
|
|
1268
|
-
if (Array.isArray(mesh.material)) { // multimaterial support
|
|
1269
|
-
for (var m = 0, mlen = mesh.material.length; m < mlen; m++) {
|
|
1270
|
-
if (mesh.material[m].name.toLowerCase().indexOf(materialToSearch) !== -1) {
|
|
1271
|
-
mesh.material[m] = _this._setMeshMaterialFromVariation(mesh.material[m].name, variation, usePbr);
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
else {
|
|
1276
|
-
if (mesh.material.name.toLowerCase().indexOf(materialToSearch) !== -1) {
|
|
1277
|
-
mesh.material = _this._setMeshMaterialFromVariation(mesh.material.name, variation, usePbr);
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
});
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
};
|
|
1287
|
-
VariationHelper.prototype._setMeshMaterialFromVariation = function (name, variation, usePbr) {
|
|
1288
|
-
if (usePbr === void 0) { usePbr = false; }
|
|
1289
|
-
if (variation.material.texture) {
|
|
1290
|
-
variation.material.texture.needsUpdate = true;
|
|
1291
|
-
}
|
|
1292
|
-
if (!usePbr) {
|
|
1293
|
-
var material = new MeshPhongMaterial({
|
|
1294
|
-
name: name,
|
|
1295
|
-
shininess: variation.material.shininess,
|
|
1296
|
-
specular: variation.material.specular,
|
|
1297
|
-
map: variation.material.texture,
|
|
1298
|
-
normalMap: variation.material.normal
|
|
1299
|
-
});
|
|
1300
|
-
// material.color.setRGB(0.8, 0.8, 0.8);
|
|
1301
|
-
material.needsUpdate = true;
|
|
1302
|
-
return material;
|
|
1303
|
-
}
|
|
1304
|
-
else {
|
|
1305
|
-
var params = {
|
|
1306
|
-
// side: DoubleSide,
|
|
1307
|
-
name: name,
|
|
1308
|
-
roughness: variation.material.roughnessValue ? variation.material.roughnessValue : 1,
|
|
1309
|
-
metalness: variation.material.metalnessValue ? variation.material.metalnessValue : 0,
|
|
1310
|
-
};
|
|
1311
|
-
if (variation.material.texture) {
|
|
1312
|
-
params.map = variation.material.texture;
|
|
1313
|
-
}
|
|
1314
|
-
if (variation.material.ao) {
|
|
1315
|
-
params.aoMap = variation.material.ao;
|
|
1316
|
-
}
|
|
1317
|
-
if (variation.material.roughness) {
|
|
1318
|
-
params.roughnessMap = variation.material.roughness;
|
|
1319
|
-
}
|
|
1320
|
-
if (variation.material.metalness) {
|
|
1321
|
-
params.metalnessMap = variation.material.metalness;
|
|
1322
|
-
}
|
|
1323
|
-
if (variation.material.normal) {
|
|
1324
|
-
params.normalMap = variation.material.normal;
|
|
1325
|
-
}
|
|
1326
|
-
var material = new MeshStandardMaterial(params);
|
|
1327
|
-
material.color.setRGB(1, 1, 1);
|
|
1328
|
-
material.needsUpdate = true;
|
|
1329
|
-
return material;
|
|
1330
|
-
}
|
|
1331
|
-
};
|
|
1332
|
-
VariationHelper.prototype._setLastKnownVariations = function (instanceId, id, variation) {
|
|
1333
|
-
if (this._lastKnownVariations.has(instanceId)) {
|
|
1334
|
-
var variations = this._lastKnownVariations.get(instanceId);
|
|
1335
|
-
variations.set(id, variation);
|
|
1336
|
-
}
|
|
1337
|
-
else {
|
|
1338
|
-
var variations = new Map();
|
|
1339
|
-
this._lastKnownVariations.set(instanceId, variations.set(id, variation));
|
|
1340
|
-
}
|
|
1341
|
-
};
|
|
1342
|
-
VariationHelper.prototype._getLastKnownVariations = function (instanceId, id) {
|
|
1343
|
-
if (this._lastKnownVariations.has(instanceId)) {
|
|
1344
|
-
var variations = this._lastKnownVariations.get(instanceId);
|
|
1345
|
-
if (variations.has(id)) {
|
|
1346
|
-
return variations.get(id);
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
return null;
|
|
1350
|
-
};
|
|
1351
|
-
return VariationHelper;
|
|
1093
|
+
var VariationHelper = /** @class */ (function () {
|
|
1094
|
+
function VariationHelper() {
|
|
1095
|
+
this._lastKnownVariations = new Map();
|
|
1096
|
+
}
|
|
1097
|
+
VariationHelper.prototype.clearCache = function () {
|
|
1098
|
+
var valueMap = Array.from(this._lastKnownVariations.values());
|
|
1099
|
+
for (var i = 0; i < valueMap.length; i++) {
|
|
1100
|
+
var values = Array.from(valueMap[i].values());
|
|
1101
|
+
values.forEach(function (variations) {
|
|
1102
|
+
variations.forEach(function (variation) {
|
|
1103
|
+
variation.material.texture.dispose();
|
|
1104
|
+
variation.material.normal.dispose();
|
|
1105
|
+
variation.material.metalness.dispose();
|
|
1106
|
+
variation.material.roughness.dispose();
|
|
1107
|
+
variation.material.ao.dispose();
|
|
1108
|
+
});
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
VariationHelper.prototype.loadPart = function (obj, parts, usePbr) {
|
|
1113
|
+
if (usePbr === void 0) { usePbr = false; }
|
|
1114
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1115
|
+
var len, i, partSettings, partVariation, _a, e_1;
|
|
1116
|
+
return __generator(this, function (_b) {
|
|
1117
|
+
switch (_b.label) {
|
|
1118
|
+
case 0:
|
|
1119
|
+
_b.trys.push([0, 6, , 7]);
|
|
1120
|
+
len = parts.length;
|
|
1121
|
+
i = 0;
|
|
1122
|
+
_b.label = 1;
|
|
1123
|
+
case 1:
|
|
1124
|
+
if (!(i < len)) return [3 /*break*/, 5];
|
|
1125
|
+
if (!(parts[i].decoNode && parts[i].decoNode.gameObjectName && parts[i].decoNode.type === DecoNodeType.Part)) return [3 /*break*/, 4];
|
|
1126
|
+
return [4 /*yield*/, VariationUtils.LoadVariation(this.assetPath, parts[i].decoNode.gameObjectName || parts[i].decoId)];
|
|
1127
|
+
case 2:
|
|
1128
|
+
partSettings = _b.sent();
|
|
1129
|
+
if (!partSettings) return [3 /*break*/, 4];
|
|
1130
|
+
partVariation = new Variation();
|
|
1131
|
+
partVariation.decoId = parseFloat(parts[i].decoNode.id);
|
|
1132
|
+
partVariation.brandId = parts[i].decoNode.brandId;
|
|
1133
|
+
partVariation.gameObjectName = parts[i].decoNode.gameObjectName;
|
|
1134
|
+
_a = partVariation;
|
|
1135
|
+
return [4 /*yield*/, AssetUtils.CreateMaterialFromAsset(partSettings)];
|
|
1136
|
+
case 3:
|
|
1137
|
+
_a.material = _b.sent();
|
|
1138
|
+
// parts[i].variation = partVariation;
|
|
1139
|
+
this._applyMaterialPart(obj, partVariation, parts[i].node, usePbr);
|
|
1140
|
+
_b.label = 4;
|
|
1141
|
+
case 4:
|
|
1142
|
+
i++;
|
|
1143
|
+
return [3 /*break*/, 1];
|
|
1144
|
+
case 5: return [3 /*break*/, 7];
|
|
1145
|
+
case 6:
|
|
1146
|
+
e_1 = _b.sent();
|
|
1147
|
+
console.error(e_1);
|
|
1148
|
+
return [3 /*break*/, 7];
|
|
1149
|
+
case 7: return [2 /*return*/];
|
|
1150
|
+
}
|
|
1151
|
+
});
|
|
1152
|
+
});
|
|
1153
|
+
};
|
|
1154
|
+
VariationHelper.prototype.loadVariation = function (instanceId, obj, parts, usePbr) {
|
|
1155
|
+
if (usePbr === void 0) { usePbr = false; }
|
|
1156
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1157
|
+
var len, i, variations, lastKnownVariations, j, variationSettings, newVariation, _a, e_2;
|
|
1158
|
+
return __generator(this, function (_b) {
|
|
1159
|
+
switch (_b.label) {
|
|
1160
|
+
case 0:
|
|
1161
|
+
_b.trys.push([0, 9, , 10]);
|
|
1162
|
+
len = parts.length;
|
|
1163
|
+
i = 0;
|
|
1164
|
+
_b.label = 1;
|
|
1165
|
+
case 1:
|
|
1166
|
+
if (!(i < len)) return [3 /*break*/, 8];
|
|
1167
|
+
variations = parts[i].variations;
|
|
1168
|
+
if (!variations || variations.length === 0) {
|
|
1169
|
+
if (this._getLastKnownVariations(instanceId, parts[i].nodeId)) {
|
|
1170
|
+
parts[i].variations = this._getLastKnownVariations(instanceId, parts[i].nodeId);
|
|
1171
|
+
this._applyVariations(obj, parts[i], usePbr);
|
|
1172
|
+
return [3 /*break*/, 7];
|
|
1173
|
+
}
|
|
1174
|
+
else {
|
|
1175
|
+
return [3 /*break*/, 7];
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
lastKnownVariations = [];
|
|
1179
|
+
j = 0;
|
|
1180
|
+
_b.label = 2;
|
|
1181
|
+
case 2:
|
|
1182
|
+
if (!(j < variations.length)) return [3 /*break*/, 6];
|
|
1183
|
+
return [4 /*yield*/, VariationUtils.LoadVariation(this.assetPath, variations[j].gameObjectName || parts[i].decoId)];
|
|
1184
|
+
case 3:
|
|
1185
|
+
variationSettings = _b.sent();
|
|
1186
|
+
newVariation = new Variation();
|
|
1187
|
+
newVariation.decoId = parseFloat(variations[j].id);
|
|
1188
|
+
newVariation.brandId = variations[j].brandId;
|
|
1189
|
+
newVariation.gameObjectName = variations[j].gameObjectName;
|
|
1190
|
+
newVariation.supplierArticleNr = variations[j].supplierArticleNr;
|
|
1191
|
+
newVariation.materialId = variations[j].materialId;
|
|
1192
|
+
_a = newVariation;
|
|
1193
|
+
return [4 /*yield*/, AssetUtils.CreateMaterialFromAsset(variationSettings)];
|
|
1194
|
+
case 4:
|
|
1195
|
+
_a.material = _b.sent();
|
|
1196
|
+
lastKnownVariations.push(newVariation);
|
|
1197
|
+
_b.label = 5;
|
|
1198
|
+
case 5:
|
|
1199
|
+
j++;
|
|
1200
|
+
return [3 /*break*/, 2];
|
|
1201
|
+
case 6:
|
|
1202
|
+
this._setLastKnownVariations(instanceId, parts[i].nodeId, lastKnownVariations);
|
|
1203
|
+
parts[i].variations = lastKnownVariations;
|
|
1204
|
+
this._applyVariations(obj, parts[i], usePbr);
|
|
1205
|
+
_b.label = 7;
|
|
1206
|
+
case 7:
|
|
1207
|
+
i++;
|
|
1208
|
+
return [3 /*break*/, 1];
|
|
1209
|
+
case 8: return [3 /*break*/, 10];
|
|
1210
|
+
case 9:
|
|
1211
|
+
e_2 = _b.sent();
|
|
1212
|
+
console.error(e_2);
|
|
1213
|
+
return [3 /*break*/, 10];
|
|
1214
|
+
case 10: return [2 /*return*/];
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
});
|
|
1218
|
+
};
|
|
1219
|
+
VariationHelper.prototype._getChildrenFilterByProp = function (obj, userDataObjectProp, prop, value) {
|
|
1220
|
+
return obj.children.filter(function (child) {
|
|
1221
|
+
return child.userData &&
|
|
1222
|
+
child.userData.hasOwnProperty(userDataObjectProp) &&
|
|
1223
|
+
child.userData[userDataObjectProp].hasOwnProperty(prop) &&
|
|
1224
|
+
child.userData[userDataObjectProp][prop] === value;
|
|
1225
|
+
});
|
|
1226
|
+
};
|
|
1227
|
+
VariationHelper.prototype._applyMaterialPart = function (obj, partMaterial, nodeId, usePbr) {
|
|
1228
|
+
var _this = this;
|
|
1229
|
+
if (usePbr === void 0) { usePbr = false; }
|
|
1230
|
+
var children = this._getChildrenFilterByProp(obj, 'selection', 'node', nodeId);
|
|
1231
|
+
var len = children.length;
|
|
1232
|
+
for (var i = 0; i < len; i++) {
|
|
1233
|
+
var child = children[i];
|
|
1234
|
+
if (child !== null && child !== undefined) {
|
|
1235
|
+
child.traverse(function (mesh) {
|
|
1236
|
+
if (mesh instanceof Mesh && partMaterial) {
|
|
1237
|
+
if (Array.isArray(mesh.material)) { // multimaterial support
|
|
1238
|
+
for (var j = 0, jlen = mesh.material.length; j < jlen; j++) {
|
|
1239
|
+
if (mesh.material[j].name.toLowerCase().indexOf('fixed_frame') !== -1) {
|
|
1240
|
+
mesh.material[j] = _this._setMeshMaterialFromVariation(mesh.material[j].name, partMaterial, usePbr);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
else {
|
|
1245
|
+
if (mesh.material.name.toLowerCase().indexOf('fixed_frame') !== -1) {
|
|
1246
|
+
mesh.material = _this._setMeshMaterialFromVariation(mesh.material.name, partMaterial, usePbr);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
};
|
|
1254
|
+
VariationHelper.prototype._applyVariations = function (obj, part, usePbr) {
|
|
1255
|
+
var _this = this;
|
|
1256
|
+
if (usePbr === void 0) { usePbr = false; }
|
|
1257
|
+
var children = this._getChildrenFilterByProp(obj, 'selection', 'node', part.node);
|
|
1258
|
+
var len = children.length;
|
|
1259
|
+
for (var i = 0; i < len; i++) {
|
|
1260
|
+
var child = children[i];
|
|
1261
|
+
if (child !== null && child !== undefined) {
|
|
1262
|
+
child.traverse(function (mesh) {
|
|
1263
|
+
if (mesh instanceof Mesh && part.variations && part.variations.length > 0 && mesh.name.toLowerCase().indexOf('c_')) {
|
|
1264
|
+
for (var j = 0; j < part.variations.length; j++) {
|
|
1265
|
+
var variation = part.variations[j];
|
|
1266
|
+
if (variation.material) {
|
|
1267
|
+
var materialToSearch = !!variation.materialId ? variation.materialId.toLowerCase() : 'default';
|
|
1268
|
+
if (Array.isArray(mesh.material)) { // multimaterial support
|
|
1269
|
+
for (var m = 0, mlen = mesh.material.length; m < mlen; m++) {
|
|
1270
|
+
if (mesh.material[m].name.toLowerCase().indexOf(materialToSearch) !== -1) {
|
|
1271
|
+
mesh.material[m] = _this._setMeshMaterialFromVariation(mesh.material[m].name, variation, usePbr);
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
else {
|
|
1276
|
+
if (mesh.material.name.toLowerCase().indexOf(materialToSearch) !== -1) {
|
|
1277
|
+
mesh.material = _this._setMeshMaterialFromVariation(mesh.material.name, variation, usePbr);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
VariationHelper.prototype._setMeshMaterialFromVariation = function (name, variation, usePbr) {
|
|
1288
|
+
if (usePbr === void 0) { usePbr = false; }
|
|
1289
|
+
if (variation.material.texture) {
|
|
1290
|
+
variation.material.texture.needsUpdate = true;
|
|
1291
|
+
}
|
|
1292
|
+
if (!usePbr) {
|
|
1293
|
+
var material = new MeshPhongMaterial({
|
|
1294
|
+
name: name,
|
|
1295
|
+
shininess: variation.material.shininess,
|
|
1296
|
+
specular: variation.material.specular,
|
|
1297
|
+
map: variation.material.texture,
|
|
1298
|
+
normalMap: variation.material.normal
|
|
1299
|
+
});
|
|
1300
|
+
// material.color.setRGB(0.8, 0.8, 0.8);
|
|
1301
|
+
material.needsUpdate = true;
|
|
1302
|
+
return material;
|
|
1303
|
+
}
|
|
1304
|
+
else {
|
|
1305
|
+
var params = {
|
|
1306
|
+
// side: DoubleSide,
|
|
1307
|
+
name: name,
|
|
1308
|
+
roughness: variation.material.roughnessValue ? variation.material.roughnessValue : 1,
|
|
1309
|
+
metalness: variation.material.metalnessValue ? variation.material.metalnessValue : 0,
|
|
1310
|
+
};
|
|
1311
|
+
if (variation.material.texture) {
|
|
1312
|
+
params.map = variation.material.texture;
|
|
1313
|
+
}
|
|
1314
|
+
if (variation.material.ao) {
|
|
1315
|
+
params.aoMap = variation.material.ao;
|
|
1316
|
+
}
|
|
1317
|
+
if (variation.material.roughness) {
|
|
1318
|
+
params.roughnessMap = variation.material.roughness;
|
|
1319
|
+
}
|
|
1320
|
+
if (variation.material.metalness) {
|
|
1321
|
+
params.metalnessMap = variation.material.metalness;
|
|
1322
|
+
}
|
|
1323
|
+
if (variation.material.normal) {
|
|
1324
|
+
params.normalMap = variation.material.normal;
|
|
1325
|
+
}
|
|
1326
|
+
var material = new MeshStandardMaterial(params);
|
|
1327
|
+
material.color.setRGB(1, 1, 1);
|
|
1328
|
+
material.needsUpdate = true;
|
|
1329
|
+
return material;
|
|
1330
|
+
}
|
|
1331
|
+
};
|
|
1332
|
+
VariationHelper.prototype._setLastKnownVariations = function (instanceId, id, variation) {
|
|
1333
|
+
if (this._lastKnownVariations.has(instanceId)) {
|
|
1334
|
+
var variations = this._lastKnownVariations.get(instanceId);
|
|
1335
|
+
variations.set(id, variation);
|
|
1336
|
+
}
|
|
1337
|
+
else {
|
|
1338
|
+
var variations = new Map();
|
|
1339
|
+
this._lastKnownVariations.set(instanceId, variations.set(id, variation));
|
|
1340
|
+
}
|
|
1341
|
+
};
|
|
1342
|
+
VariationHelper.prototype._getLastKnownVariations = function (instanceId, id) {
|
|
1343
|
+
if (this._lastKnownVariations.has(instanceId)) {
|
|
1344
|
+
var variations = this._lastKnownVariations.get(instanceId);
|
|
1345
|
+
if (variations.has(id)) {
|
|
1346
|
+
return variations.get(id);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
return null;
|
|
1350
|
+
};
|
|
1351
|
+
return VariationHelper;
|
|
1352
1352
|
}());
|
|
1353
1353
|
|
|
1354
|
-
var ServiceLocator = /** @class */ (function () {
|
|
1355
|
-
function ServiceLocator() {
|
|
1356
|
-
}
|
|
1357
|
-
ServiceLocator.injector = undefined;
|
|
1358
|
-
ServiceLocator = __decorate([
|
|
1359
|
-
Injectable()
|
|
1360
|
-
], ServiceLocator);
|
|
1361
|
-
return ServiceLocator;
|
|
1354
|
+
var ServiceLocator = /** @class */ (function () {
|
|
1355
|
+
function ServiceLocator() {
|
|
1356
|
+
}
|
|
1357
|
+
ServiceLocator.injector = undefined;
|
|
1358
|
+
ServiceLocator = __decorate([
|
|
1359
|
+
Injectable()
|
|
1360
|
+
], ServiceLocator);
|
|
1361
|
+
return ServiceLocator;
|
|
1362
1362
|
}());
|
|
1363
1363
|
|
|
1364
|
-
var ConfiguratorService = /** @class */ (function () {
|
|
1365
|
-
function ConfiguratorService(_injector) {
|
|
1366
|
-
this._injector = _injector;
|
|
1367
|
-
if (!ServiceLocator.injector) {
|
|
1368
|
-
ServiceLocator.injector = _injector;
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
ConfiguratorService.prototype.initApi = function (options) {
|
|
1372
|
-
this._configuratorApi = new Configurator(options);
|
|
1373
|
-
};
|
|
1374
|
-
ConfiguratorService.prototype.initNodeInstance = function (goodId) {
|
|
1375
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1376
|
-
return __generator(this, function (_a) {
|
|
1377
|
-
switch (_a.label) {
|
|
1378
|
-
case 0: return [4 /*yield*/, this._configuratorApi.initNodeInstance(goodId)];
|
|
1379
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
1380
|
-
}
|
|
1381
|
-
});
|
|
1382
|
-
});
|
|
1383
|
-
};
|
|
1384
|
-
ConfiguratorService.prototype.setInstanceToConfigure = function (id, showLoader) {
|
|
1385
|
-
if (showLoader === void 0) { showLoader = false; }
|
|
1386
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1387
|
-
return __generator(this, function (_a) {
|
|
1388
|
-
switch (_a.label) {
|
|
1389
|
-
case 0: return [4 /*yield*/, this._configuratorApi.setInstanceToConfigure(id, showLoader)];
|
|
1390
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
1391
|
-
}
|
|
1392
|
-
});
|
|
1393
|
-
});
|
|
1394
|
-
};
|
|
1395
|
-
ConfiguratorService.prototype.getGoodIdFromSku = function (sku, showLoader) {
|
|
1396
|
-
if (showLoader === void 0) { showLoader = false; }
|
|
1397
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1398
|
-
return __generator(this, function (_a) {
|
|
1399
|
-
switch (_a.label) {
|
|
1400
|
-
case 0: return [4 /*yield*/, this._configuratorApi.getGoodIdFromSku(sku, showLoader)];
|
|
1401
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
1402
|
-
}
|
|
1403
|
-
});
|
|
1404
|
-
});
|
|
1405
|
-
};
|
|
1406
|
-
ConfiguratorService.prototype.getArticleQuickSel = function (goodId, showLoader) {
|
|
1407
|
-
if (showLoader === void 0) { showLoader = false; }
|
|
1408
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1409
|
-
return __generator(this, function (_a) {
|
|
1410
|
-
switch (_a.label) {
|
|
1411
|
-
case 0: return [4 /*yield*/, this._configuratorApi.getArticleQuickSel(goodId, showLoader)];
|
|
1412
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
1413
|
-
}
|
|
1414
|
-
});
|
|
1415
|
-
});
|
|
1416
|
-
};
|
|
1417
|
-
ConfiguratorService.prototype.getSelections = function (showLoader, publicationCode) {
|
|
1418
|
-
if (showLoader === void 0) { showLoader = false; }
|
|
1419
|
-
if (publicationCode === void 0) { publicationCode = 2; }
|
|
1420
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1421
|
-
var selections;
|
|
1422
|
-
return __generator(this, function (_a) {
|
|
1423
|
-
switch (_a.label) {
|
|
1424
|
-
case 0: return [4 /*yield*/, this._configuratorApi.getSelections(showLoader)];
|
|
1425
|
-
case 1:
|
|
1426
|
-
selections = _a.sent();
|
|
1427
|
-
selections.resultObjects.filter(function (s) {
|
|
1428
|
-
(isNill(s.hierarchicalPublicationCode) || ((s.hierarchicalPublicationCode & publicationCode) > 0)) && ((s.nodeType === NodeType.Question && (((s.questionPublicationCode & publicationCode) > 0) || isNill(s.questionPublicationCode))) ||
|
|
1429
|
-
(s.nodeType === NodeType.Answer && (((s.answerPublicationCode & publicationCode) > 0) || isNill(s.answerPublicationCode))));
|
|
1430
|
-
});
|
|
1431
|
-
return [2 /*return*/, selections];
|
|
1432
|
-
}
|
|
1433
|
-
});
|
|
1434
|
-
});
|
|
1435
|
-
};
|
|
1436
|
-
ConfiguratorService.prototype.getDecos = function (showLoader) {
|
|
1437
|
-
if (showLoader === void 0) { showLoader = false; }
|
|
1438
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1439
|
-
return __generator(this, function (_a) {
|
|
1440
|
-
switch (_a.label) {
|
|
1441
|
-
case 0: return [4 /*yield*/, this._configuratorApi.getDecos(showLoader)];
|
|
1442
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
1443
|
-
}
|
|
1444
|
-
});
|
|
1445
|
-
});
|
|
1446
|
-
};
|
|
1447
|
-
ConfiguratorService.prototype.getQuestionAndAnswers = function (showLoader, publicationCode) {
|
|
1448
|
-
if (showLoader === void 0) { showLoader = false; }
|
|
1449
|
-
if (publicationCode === void 0) { publicationCode = 2; }
|
|
1450
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1451
|
-
var questionAndAnswers;
|
|
1452
|
-
return __generator(this, function (_a) {
|
|
1453
|
-
switch (_a.label) {
|
|
1454
|
-
case 0: return [4 /*yield*/, this._configuratorApi.getQuestionAndAnswers(showLoader)];
|
|
1455
|
-
case 1:
|
|
1456
|
-
questionAndAnswers = _a.sent();
|
|
1457
|
-
questionAndAnswers.answers.filter(function (answer) {
|
|
1458
|
-
(notNill(answer.hierarchicalPublicationCode) && (answer.hierarchicalPublicationCode & publicationCode) === 0) ||
|
|
1459
|
-
(answer.type === NodeType.Question && (answer.questionPublicationCode & publicationCode) === 0 && notNill(answer.questionPublicationCode)) ||
|
|
1460
|
-
(answer.type === NodeType.Answer && (answer.publicationCode & publicationCode) === 0 && notNill(answer.publicationCode));
|
|
1461
|
-
});
|
|
1462
|
-
return [2 /*return*/, questionAndAnswers];
|
|
1463
|
-
}
|
|
1464
|
-
});
|
|
1465
|
-
});
|
|
1466
|
-
};
|
|
1467
|
-
ConfiguratorService.prototype.getSingleImage = function (nodeId, publication, includeMimetype, thumb, showLoader) {
|
|
1468
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1469
|
-
return __generator(this, function (_a) {
|
|
1470
|
-
switch (_a.label) {
|
|
1471
|
-
case 0:
|
|
1472
|
-
if (!nodeId) {
|
|
1473
|
-
return [2 /*return*/, null];
|
|
1474
|
-
}
|
|
1475
|
-
return [4 /*yield*/, this._configuratorApi.getSingleImage(nodeId, publication, includeMimetype, thumb, showLoader)];
|
|
1476
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
1477
|
-
}
|
|
1478
|
-
});
|
|
1479
|
-
});
|
|
1480
|
-
};
|
|
1481
|
-
ConfiguratorService.prototype.selectSelection = function (selection, showLoader) {
|
|
1482
|
-
if (showLoader === void 0) { showLoader = false; }
|
|
1483
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1484
|
-
return __generator(this, function (_a) {
|
|
1485
|
-
switch (_a.label) {
|
|
1486
|
-
case 0: return [4 /*yield*/, this._configuratorApi.selectSelection(selection, showLoader)];
|
|
1487
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
1488
|
-
}
|
|
1489
|
-
});
|
|
1490
|
-
});
|
|
1491
|
-
};
|
|
1492
|
-
ConfiguratorService.prototype.selectAnswer = function (answer, showLoader) {
|
|
1493
|
-
if (showLoader === void 0) { showLoader = false; }
|
|
1494
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1495
|
-
return __generator(this, function (_a) {
|
|
1496
|
-
switch (_a.label) {
|
|
1497
|
-
case 0: return [4 /*yield*/, this._configuratorApi.selectAnswer(answer, showLoader)];
|
|
1498
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
1499
|
-
}
|
|
1500
|
-
});
|
|
1501
|
-
});
|
|
1502
|
-
};
|
|
1503
|
-
ConfiguratorService.ctorParameters = function () { return [
|
|
1504
|
-
{ type: Injector }
|
|
1505
|
-
]; };
|
|
1506
|
-
ConfiguratorService.ɵprov = ɵɵdefineInjectable({ factory: function ConfiguratorService_Factory() { return new ConfiguratorService(ɵɵinject(INJECTOR)); }, token: ConfiguratorService, providedIn: "root" });
|
|
1507
|
-
ConfiguratorService = __decorate([
|
|
1508
|
-
Injectable({
|
|
1509
|
-
providedIn: 'root'
|
|
1510
|
-
})
|
|
1511
|
-
], ConfiguratorService);
|
|
1512
|
-
return ConfiguratorService;
|
|
1364
|
+
var ConfiguratorService = /** @class */ (function () {
|
|
1365
|
+
function ConfiguratorService(_injector) {
|
|
1366
|
+
this._injector = _injector;
|
|
1367
|
+
if (!ServiceLocator.injector) {
|
|
1368
|
+
ServiceLocator.injector = _injector;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
ConfiguratorService.prototype.initApi = function (options) {
|
|
1372
|
+
this._configuratorApi = new Configurator(options);
|
|
1373
|
+
};
|
|
1374
|
+
ConfiguratorService.prototype.initNodeInstance = function (goodId) {
|
|
1375
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1376
|
+
return __generator(this, function (_a) {
|
|
1377
|
+
switch (_a.label) {
|
|
1378
|
+
case 0: return [4 /*yield*/, this._configuratorApi.initNodeInstance(goodId)];
|
|
1379
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
});
|
|
1383
|
+
};
|
|
1384
|
+
ConfiguratorService.prototype.setInstanceToConfigure = function (id, showLoader) {
|
|
1385
|
+
if (showLoader === void 0) { showLoader = false; }
|
|
1386
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1387
|
+
return __generator(this, function (_a) {
|
|
1388
|
+
switch (_a.label) {
|
|
1389
|
+
case 0: return [4 /*yield*/, this._configuratorApi.setInstanceToConfigure(id, showLoader)];
|
|
1390
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1391
|
+
}
|
|
1392
|
+
});
|
|
1393
|
+
});
|
|
1394
|
+
};
|
|
1395
|
+
ConfiguratorService.prototype.getGoodIdFromSku = function (sku, showLoader) {
|
|
1396
|
+
if (showLoader === void 0) { showLoader = false; }
|
|
1397
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1398
|
+
return __generator(this, function (_a) {
|
|
1399
|
+
switch (_a.label) {
|
|
1400
|
+
case 0: return [4 /*yield*/, this._configuratorApi.getGoodIdFromSku(sku, showLoader)];
|
|
1401
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1402
|
+
}
|
|
1403
|
+
});
|
|
1404
|
+
});
|
|
1405
|
+
};
|
|
1406
|
+
ConfiguratorService.prototype.getArticleQuickSel = function (goodId, showLoader) {
|
|
1407
|
+
if (showLoader === void 0) { showLoader = false; }
|
|
1408
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1409
|
+
return __generator(this, function (_a) {
|
|
1410
|
+
switch (_a.label) {
|
|
1411
|
+
case 0: return [4 /*yield*/, this._configuratorApi.getArticleQuickSel(goodId, showLoader)];
|
|
1412
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1413
|
+
}
|
|
1414
|
+
});
|
|
1415
|
+
});
|
|
1416
|
+
};
|
|
1417
|
+
ConfiguratorService.prototype.getSelections = function (showLoader, publicationCode) {
|
|
1418
|
+
if (showLoader === void 0) { showLoader = false; }
|
|
1419
|
+
if (publicationCode === void 0) { publicationCode = 2; }
|
|
1420
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1421
|
+
var selections;
|
|
1422
|
+
return __generator(this, function (_a) {
|
|
1423
|
+
switch (_a.label) {
|
|
1424
|
+
case 0: return [4 /*yield*/, this._configuratorApi.getSelections(showLoader)];
|
|
1425
|
+
case 1:
|
|
1426
|
+
selections = _a.sent();
|
|
1427
|
+
selections.resultObjects.filter(function (s) {
|
|
1428
|
+
(isNill(s.hierarchicalPublicationCode) || ((s.hierarchicalPublicationCode & publicationCode) > 0)) && ((s.nodeType === NodeType.Question && (((s.questionPublicationCode & publicationCode) > 0) || isNill(s.questionPublicationCode))) ||
|
|
1429
|
+
(s.nodeType === NodeType.Answer && (((s.answerPublicationCode & publicationCode) > 0) || isNill(s.answerPublicationCode))));
|
|
1430
|
+
});
|
|
1431
|
+
return [2 /*return*/, selections];
|
|
1432
|
+
}
|
|
1433
|
+
});
|
|
1434
|
+
});
|
|
1435
|
+
};
|
|
1436
|
+
ConfiguratorService.prototype.getDecos = function (showLoader) {
|
|
1437
|
+
if (showLoader === void 0) { showLoader = false; }
|
|
1438
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1439
|
+
return __generator(this, function (_a) {
|
|
1440
|
+
switch (_a.label) {
|
|
1441
|
+
case 0: return [4 /*yield*/, this._configuratorApi.getDecos(showLoader)];
|
|
1442
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1443
|
+
}
|
|
1444
|
+
});
|
|
1445
|
+
});
|
|
1446
|
+
};
|
|
1447
|
+
ConfiguratorService.prototype.getQuestionAndAnswers = function (showLoader, publicationCode) {
|
|
1448
|
+
if (showLoader === void 0) { showLoader = false; }
|
|
1449
|
+
if (publicationCode === void 0) { publicationCode = 2; }
|
|
1450
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1451
|
+
var questionAndAnswers;
|
|
1452
|
+
return __generator(this, function (_a) {
|
|
1453
|
+
switch (_a.label) {
|
|
1454
|
+
case 0: return [4 /*yield*/, this._configuratorApi.getQuestionAndAnswers(showLoader)];
|
|
1455
|
+
case 1:
|
|
1456
|
+
questionAndAnswers = _a.sent();
|
|
1457
|
+
questionAndAnswers.answers.filter(function (answer) {
|
|
1458
|
+
(notNill(answer.hierarchicalPublicationCode) && (answer.hierarchicalPublicationCode & publicationCode) === 0) ||
|
|
1459
|
+
(answer.type === NodeType.Question && (answer.questionPublicationCode & publicationCode) === 0 && notNill(answer.questionPublicationCode)) ||
|
|
1460
|
+
(answer.type === NodeType.Answer && (answer.publicationCode & publicationCode) === 0 && notNill(answer.publicationCode));
|
|
1461
|
+
});
|
|
1462
|
+
return [2 /*return*/, questionAndAnswers];
|
|
1463
|
+
}
|
|
1464
|
+
});
|
|
1465
|
+
});
|
|
1466
|
+
};
|
|
1467
|
+
ConfiguratorService.prototype.getSingleImage = function (nodeId, publication, includeMimetype, thumb, showLoader) {
|
|
1468
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1469
|
+
return __generator(this, function (_a) {
|
|
1470
|
+
switch (_a.label) {
|
|
1471
|
+
case 0:
|
|
1472
|
+
if (!nodeId) {
|
|
1473
|
+
return [2 /*return*/, null];
|
|
1474
|
+
}
|
|
1475
|
+
return [4 /*yield*/, this._configuratorApi.getSingleImage(nodeId, publication, includeMimetype, thumb, showLoader)];
|
|
1476
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1479
|
+
});
|
|
1480
|
+
};
|
|
1481
|
+
ConfiguratorService.prototype.selectSelection = function (selection, showLoader) {
|
|
1482
|
+
if (showLoader === void 0) { showLoader = false; }
|
|
1483
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1484
|
+
return __generator(this, function (_a) {
|
|
1485
|
+
switch (_a.label) {
|
|
1486
|
+
case 0: return [4 /*yield*/, this._configuratorApi.selectSelection(selection, showLoader)];
|
|
1487
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1488
|
+
}
|
|
1489
|
+
});
|
|
1490
|
+
});
|
|
1491
|
+
};
|
|
1492
|
+
ConfiguratorService.prototype.selectAnswer = function (answer, showLoader) {
|
|
1493
|
+
if (showLoader === void 0) { showLoader = false; }
|
|
1494
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1495
|
+
return __generator(this, function (_a) {
|
|
1496
|
+
switch (_a.label) {
|
|
1497
|
+
case 0: return [4 /*yield*/, this._configuratorApi.selectAnswer(answer, showLoader)];
|
|
1498
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
});
|
|
1502
|
+
};
|
|
1503
|
+
ConfiguratorService.ctorParameters = function () { return [
|
|
1504
|
+
{ type: Injector }
|
|
1505
|
+
]; };
|
|
1506
|
+
ConfiguratorService.ɵprov = ɵɵdefineInjectable({ factory: function ConfiguratorService_Factory() { return new ConfiguratorService(ɵɵinject(INJECTOR)); }, token: ConfiguratorService, providedIn: "root" });
|
|
1507
|
+
ConfiguratorService = __decorate([
|
|
1508
|
+
Injectable({
|
|
1509
|
+
providedIn: 'root'
|
|
1510
|
+
})
|
|
1511
|
+
], ConfiguratorService);
|
|
1512
|
+
return ConfiguratorService;
|
|
1513
1513
|
}());
|
|
1514
1514
|
|
|
1515
|
-
var Builder = /** @class */ (function () {
|
|
1516
|
-
function Builder(scene, options, useInAngular) {
|
|
1517
|
-
this.selectionsReceived = new BehaviorSubject([]);
|
|
1518
|
-
this.answersReceived = new BehaviorSubject([]);
|
|
1519
|
-
this.modelLoaded = new BehaviorSubject(null);
|
|
1520
|
-
this._selections = [];
|
|
1521
|
-
this._answers = [];
|
|
1522
|
-
this._decos = [];
|
|
1523
|
-
this._placedAdjustables = [];
|
|
1524
|
-
this._placedAddables = [];
|
|
1525
|
-
this._adjustables = [];
|
|
1526
|
-
this._addables = [];
|
|
1527
|
-
this._articleCache = new Map();
|
|
1528
|
-
this._boFactory = new BusinessObjectFactory();
|
|
1529
|
-
this._threedUtils = new ThreedUtils();
|
|
1530
|
-
this._variationHelper = new VariationHelper();
|
|
1531
|
-
if (!scene) {
|
|
1532
|
-
throw 'No scene object provided!';
|
|
1533
|
-
}
|
|
1534
|
-
if (!options) {
|
|
1535
|
-
throw 'No connection options provided!';
|
|
1536
|
-
}
|
|
1537
|
-
if (useInAngular) {
|
|
1538
|
-
this._configuratorService = ServiceLocator.injector.get(ConfiguratorService);
|
|
1539
|
-
}
|
|
1540
|
-
else {
|
|
1541
|
-
this._configuratorService = new ConfiguratorService(undefined);
|
|
1542
|
-
}
|
|
1543
|
-
this._configuratorService.initApi(options);
|
|
1544
|
-
this._scene = scene;
|
|
1545
|
-
}
|
|
1546
|
-
Builder.prototype.buildModel = function (sku, instanceId, goodId) {
|
|
1547
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1548
|
-
var promises, e_1;
|
|
1549
|
-
return __generator(this, function (_a) {
|
|
1550
|
-
switch (_a.label) {
|
|
1551
|
-
case 0:
|
|
1552
|
-
if (!this._scene) {
|
|
1553
|
-
return [2 /*return*/];
|
|
1554
|
-
}
|
|
1555
|
-
_a.label = 1;
|
|
1556
|
-
case 1:
|
|
1557
|
-
_a.trys.push([1, 8, , 9]);
|
|
1558
|
-
return [4 /*yield*/, this._setInstanceId(sku, instanceId, goodId)];
|
|
1559
|
-
case 2:
|
|
1560
|
-
_a.sent();
|
|
1561
|
-
return [4 /*yield*/, this._prepareConfiguration(this._sku, this._goodId)];
|
|
1562
|
-
case 3:
|
|
1563
|
-
_a.sent();
|
|
1564
|
-
if (!this._source) return [3 /*break*/, 6];
|
|
1565
|
-
return [4 /*yield*/, this._configuratorService.setInstanceToConfigure(this._instanceId)];
|
|
1566
|
-
case 4:
|
|
1567
|
-
_a.sent();
|
|
1568
|
-
promises = [];
|
|
1569
|
-
promises.push(this.getQuestionAndAnswers());
|
|
1570
|
-
promises.push(this._getSelections(this._instanceId));
|
|
1571
|
-
promises.push(this._getDecos());
|
|
1572
|
-
return [4 /*yield*/, Promise.all(promises)];
|
|
1573
|
-
case 5:
|
|
1574
|
-
_a.sent();
|
|
1575
|
-
if (this._answers.length > 0) {
|
|
1576
|
-
return [2 /*return*/];
|
|
1577
|
-
}
|
|
1578
|
-
this._linkSelectionsAndDecos();
|
|
1579
|
-
return [2 /*return*/, this._build(this._instanceId)];
|
|
1580
|
-
case 6: throw 'GLB source not found!';
|
|
1581
|
-
case 7: return [3 /*break*/, 9];
|
|
1582
|
-
case 8:
|
|
1583
|
-
e_1 = _a.sent();
|
|
1584
|
-
throw e_1;
|
|
1585
|
-
case 9: return [2 /*return*/];
|
|
1586
|
-
}
|
|
1587
|
-
});
|
|
1588
|
-
});
|
|
1589
|
-
};
|
|
1590
|
-
Builder.prototype.initNodeInstance = function (goodId) {
|
|
1591
|
-
return this._configuratorService.initNodeInstance(goodId);
|
|
1592
|
-
};
|
|
1593
|
-
Builder.prototype.destroy = function () {
|
|
1594
|
-
this._threedUtils.clearCache();
|
|
1595
|
-
this._variationHelper.clearCache();
|
|
1596
|
-
};
|
|
1597
|
-
Builder.prototype.selectSelection = function (selection) {
|
|
1598
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1599
|
-
return __generator(this, function (_a) {
|
|
1600
|
-
switch (_a.label) {
|
|
1601
|
-
case 0: return [4 /*yield*/, this._configuratorService.selectSelection(selection, false)];
|
|
1602
|
-
case 1:
|
|
1603
|
-
_a.sent();
|
|
1604
|
-
this.getQuestionAndAnswers();
|
|
1605
|
-
return [2 /*return*/];
|
|
1606
|
-
}
|
|
1607
|
-
});
|
|
1608
|
-
});
|
|
1609
|
-
};
|
|
1610
|
-
Builder.prototype.getQuestionAndAnswers = function (publicationCode) {
|
|
1611
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1612
|
-
var questionsAndAnswers;
|
|
1613
|
-
return __generator(this, function (_a) {
|
|
1614
|
-
switch (_a.label) {
|
|
1615
|
-
case 0: return [4 /*yield*/, this._configuratorService.getQuestionAndAnswers(false, publicationCode)];
|
|
1616
|
-
case 1:
|
|
1617
|
-
questionsAndAnswers = _a.sent();
|
|
1618
|
-
this._answers = questionsAndAnswers.answers;
|
|
1619
|
-
this.answersReceived.next(questionsAndAnswers.answers);
|
|
1620
|
-
return [2 /*return*/];
|
|
1621
|
-
}
|
|
1622
|
-
});
|
|
1623
|
-
});
|
|
1624
|
-
};
|
|
1625
|
-
Builder.prototype.selectAnswer = function (answer) {
|
|
1626
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1627
|
-
var _a, _b;
|
|
1628
|
-
return __generator(this, function (_c) {
|
|
1629
|
-
switch (_c.label) {
|
|
1630
|
-
case 0: return [4 /*yield*/, this._configuratorService.selectAnswer(answer, false)];
|
|
1631
|
-
case 1:
|
|
1632
|
-
_c.sent();
|
|
1633
|
-
_b = (_a = this.modelLoaded).next;
|
|
1634
|
-
return [4 /*yield*/, this.buildModel()];
|
|
1635
|
-
case 2:
|
|
1636
|
-
_b.apply(_a, [_c.sent()]);
|
|
1637
|
-
return [2 /*return*/];
|
|
1638
|
-
}
|
|
1639
|
-
});
|
|
1640
|
-
});
|
|
1641
|
-
};
|
|
1642
|
-
Builder.prototype._setInstanceId = function (sku, instanceId, goodId) {
|
|
1643
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1644
|
-
var result;
|
|
1645
|
-
return __generator(this, function (_a) {
|
|
1646
|
-
switch (_a.label) {
|
|
1647
|
-
case 0:
|
|
1648
|
-
if (!(!instanceId && !this._instanceId)) return [3 /*break*/, 4];
|
|
1649
|
-
if (!!goodId) return [3 /*break*/, 2];
|
|
1650
|
-
return [4 /*yield*/, this._getGoodIdFromSku(sku)];
|
|
1651
|
-
case 1:
|
|
1652
|
-
goodId = _a.sent();
|
|
1653
|
-
_a.label = 2;
|
|
1654
|
-
case 2:
|
|
1655
|
-
this._goodId = goodId;
|
|
1656
|
-
return [4 /*yield*/, this.initNodeInstance(this._goodId)];
|
|
1657
|
-
case 3:
|
|
1658
|
-
result = _a.sent();
|
|
1659
|
-
if (result && result.resultObject) {
|
|
1660
|
-
this._instanceId = result.resultObject;
|
|
1661
|
-
}
|
|
1662
|
-
else {
|
|
1663
|
-
throw 'Failed to initialize node instance';
|
|
1664
|
-
}
|
|
1665
|
-
return [3 /*break*/, 5];
|
|
1666
|
-
case 4:
|
|
1667
|
-
if (!this._instanceId) {
|
|
1668
|
-
this._instanceId = instanceId;
|
|
1669
|
-
}
|
|
1670
|
-
_a.label = 5;
|
|
1671
|
-
case 5:
|
|
1672
|
-
if (!this._sku) {
|
|
1673
|
-
this._sku = sku;
|
|
1674
|
-
}
|
|
1675
|
-
return [2 /*return*/];
|
|
1676
|
-
}
|
|
1677
|
-
});
|
|
1678
|
-
});
|
|
1679
|
-
};
|
|
1680
|
-
Builder.prototype._prepareConfiguration = function (sku, goodId) {
|
|
1681
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1682
|
-
var article, _a;
|
|
1683
|
-
return __generator(this, function (_b) {
|
|
1684
|
-
switch (_b.label) {
|
|
1685
|
-
case 0: return [4 /*yield*/, this._getArticle(sku, goodId)];
|
|
1686
|
-
case 1:
|
|
1687
|
-
article = _b.sent();
|
|
1688
|
-
if (!(article && article.assetUrl)) return [3 /*break*/, 3];
|
|
1689
|
-
_a = this;
|
|
1690
|
-
return [4 /*yield*/, this._threedUtils.download3DSource(article.assetUrl)
|
|
1691
|
-
.catch(function (error) {
|
|
1692
|
-
throw error;
|
|
1693
|
-
})];
|
|
1694
|
-
case 2:
|
|
1695
|
-
_a._source = _b.sent();
|
|
1696
|
-
if (article.contentDeliveryUrl) {
|
|
1697
|
-
this._variationHelper.assetPath =
|
|
1698
|
-
article.contentDeliveryUrl +
|
|
1699
|
-
(article.contentDeliveryUrl.endsWith('/') ? '' : '/') +
|
|
1700
|
-
(article.distSchema ? article.distSchema : 'UP_DBA');
|
|
1701
|
-
}
|
|
1702
|
-
_b.label = 3;
|
|
1703
|
-
case 3: return [2 /*return*/];
|
|
1704
|
-
}
|
|
1705
|
-
});
|
|
1706
|
-
});
|
|
1707
|
-
};
|
|
1708
|
-
Builder.prototype._build = function (instanceId) {
|
|
1709
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1710
|
-
var adjustables, obj, connected, i, len, adjustable, ii, lenii;
|
|
1711
|
-
return __generator(this, function (_a) {
|
|
1712
|
-
switch (_a.label) {
|
|
1713
|
-
case 0:
|
|
1714
|
-
this._reset();
|
|
1715
|
-
adjustables = this._getAdjustables();
|
|
1716
|
-
if (!(adjustables && adjustables.length > 0)) return [3 /*break*/, 2];
|
|
1717
|
-
obj = new Object3D();
|
|
1718
|
-
obj.visible = false; // no need to render visualy
|
|
1719
|
-
this._scene.add(obj);
|
|
1720
|
-
connected = false;
|
|
1721
|
-
for (i = 0, len = adjustables.length; i < len; i++) {
|
|
1722
|
-
adjustable = this._createAdjustable(obj, adjustables[i]);
|
|
1723
|
-
if (adjustable) {
|
|
1724
|
-
for (ii = 0, lenii = this._placedAdjustables.length; ii < lenii; ii++) {
|
|
1725
|
-
if (SceneUtils.TrySelectorConnection(this._scene, obj, this._placedAdjustables[ii], adjustable)) {
|
|
1726
|
-
this._placedAdjustables[ii].visible = true;
|
|
1727
|
-
adjustable.visible = true;
|
|
1728
|
-
connected = true;
|
|
1729
|
-
break;
|
|
1730
|
-
}
|
|
1731
|
-
connected = false;
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
if (!connected && this._placedAdjustables.length > 1) {
|
|
1735
|
-
console.warn('No connection found for: ', adjustable.name);
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1738
|
-
this._placeAddables(obj);
|
|
1739
|
-
this._updatePivot(obj);
|
|
1740
|
-
return [4 /*yield*/, this._loadVariations(obj, instanceId)];
|
|
1741
|
-
case 1:
|
|
1742
|
-
_a.sent();
|
|
1743
|
-
this._scene.remove(obj);
|
|
1744
|
-
return [2 /*return*/, obj];
|
|
1745
|
-
case 2: throw 'No adjustables found!';
|
|
1746
|
-
}
|
|
1747
|
-
});
|
|
1748
|
-
});
|
|
1749
|
-
};
|
|
1750
|
-
Builder.prototype._prepareTheSelections = function () {
|
|
1751
|
-
var _this = this;
|
|
1752
|
-
// get generic variations
|
|
1753
|
-
var globalVariations = this._selections
|
|
1754
|
-
.filter(function (s) { return s.generic && s.decoNode.variation && !s.decoNode.type; })
|
|
1755
|
-
.map(function (value, index, array) {
|
|
1756
|
-
// find selection of variation
|
|
1757
|
-
var sel = _this._selections.find(function (s) { return s.artNodeIdDeco === value.decoNode.variation.id; });
|
|
1758
|
-
if (sel) {
|
|
1759
|
-
value.decoNode.variation.supplierArticleNr = sel.supplierArticleNr;
|
|
1760
|
-
}
|
|
1761
|
-
value.decoNode.variation.materialId = value.hdecoGameObject;
|
|
1762
|
-
return value.decoNode.variation;
|
|
1763
|
-
});
|
|
1764
|
-
// const usedVariations: FurniturePartVariation[] = [];
|
|
1765
|
-
var globalVariationsRewrite = true;
|
|
1766
|
-
var len = this._selections.length;
|
|
1767
|
-
var lastAdded;
|
|
1768
|
-
var lastAdjustable;
|
|
1769
|
-
var newPart = false;
|
|
1770
|
-
var previousPresLevel = -1;
|
|
1771
|
-
var positioning;
|
|
1772
|
-
for (var i = 0; i < len; i++) {
|
|
1773
|
-
var selection = this._selections[i];
|
|
1774
|
-
if (selection.presentationLevel === 1) {
|
|
1775
|
-
positioning = selection.hdecoPositioning;
|
|
1776
|
-
}
|
|
1777
|
-
if (selection.presentationLevel > previousPresLevel) {
|
|
1778
|
-
selection.hdecoPositioning = selection.hdecoPositioning || positioning;
|
|
1779
|
-
}
|
|
1780
|
-
if (selection.decoNode) {
|
|
1781
|
-
if (selection.decoNode.type === DecoNodeType.Variation) {
|
|
1782
|
-
if (lastAdded) {
|
|
1783
|
-
if (newPart) {
|
|
1784
|
-
lastAdded.variations = [selection.decoNode];
|
|
1785
|
-
}
|
|
1786
|
-
else {
|
|
1787
|
-
lastAdded.variations.push(selection.decoNode);
|
|
1788
|
-
}
|
|
1789
|
-
newPart = false;
|
|
1790
|
-
}
|
|
1791
|
-
else {
|
|
1792
|
-
if (globalVariationsRewrite) {
|
|
1793
|
-
globalVariations.length = 0;
|
|
1794
|
-
globalVariationsRewrite = false;
|
|
1795
|
-
}
|
|
1796
|
-
globalVariations.push(selection.decoNode);
|
|
1797
|
-
}
|
|
1798
|
-
// const variation: FurniturePartVariation = new FurniturePartVariation();
|
|
1799
|
-
// variation.BrandId = selection.decoNode.brandId;
|
|
1800
|
-
// variation.Description = selection.decoNode.gameObjectName;
|
|
1801
|
-
// variation.MaterialId = (selection.decoNode as any).materialId;
|
|
1802
|
-
// variation.SupplierArticleNr = (selection.decoNode as any).supplierArticleNr;
|
|
1803
|
-
// usedVariations.push(variation);
|
|
1804
|
-
// this._upsertFurniture(this.activeInstance, {
|
|
1805
|
-
// Variation: selection.decoNode.brandId,
|
|
1806
|
-
// VariationDescription: selection.decoNode.gameObjectName,
|
|
1807
|
-
// SupplierArticleNr: (selection.decoNode as any).supplierArticleNr
|
|
1808
|
-
// });
|
|
1809
|
-
}
|
|
1810
|
-
else if (selection.decoNode.type === DecoNodeType.Part &&
|
|
1811
|
-
typeof selection.decoNode.gameObjectName === 'string' &&
|
|
1812
|
-
selection.decoNode.gameObjectName.length) {
|
|
1813
|
-
if (selection.decoNode.kind === DecoNodeKind.Adjustable) {
|
|
1814
|
-
selection.variations = globalVariations;
|
|
1815
|
-
this._adjustables.push(selection);
|
|
1816
|
-
if (!lastAdded || lastAdded.nodeId !== selection.nodeId) {
|
|
1817
|
-
newPart = true;
|
|
1818
|
-
}
|
|
1819
|
-
lastAdded = selection;
|
|
1820
|
-
lastAdjustable = selection;
|
|
1821
|
-
}
|
|
1822
|
-
else if (selection.decoNode.kind === DecoNodeKind.Addable) {
|
|
1823
|
-
selection.variations = lastAdjustable ? lastAdjustable.variations : globalVariations;
|
|
1824
|
-
if (lastAdjustable) {
|
|
1825
|
-
lastAdjustable.addables.push(selection);
|
|
1826
|
-
}
|
|
1827
|
-
this._addables.push(selection);
|
|
1828
|
-
if (!lastAdded || lastAdded.nodeId !== selection.nodeId) {
|
|
1829
|
-
newPart = true;
|
|
1830
|
-
}
|
|
1831
|
-
lastAdded = selection;
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
previousPresLevel = selection.presentationLevel;
|
|
1836
|
-
}
|
|
1837
|
-
// this._upsertFurniture(this.activeInstance,
|
|
1838
|
-
// {Variations: usedVariations});
|
|
1839
|
-
};
|
|
1840
|
-
Builder.prototype._createAdjustable = function (parent, adj) {
|
|
1841
|
-
var obj = this._source ? this._source.getObjectByName(adj.decoNode.gameObjectName) : null;
|
|
1842
|
-
if (!obj) {
|
|
1843
|
-
// in case of glb files, the importer removes dots from names
|
|
1844
|
-
var name_1 = adj.decoNode.gameObjectName.replace(/[.]/g, '');
|
|
1845
|
-
obj = this._source ? this._source.getObjectByName(name_1) : null;
|
|
1846
|
-
if (!obj) {
|
|
1847
|
-
// console.warn(`No object with name ${adj.decoNode.gameObjectName} found!`);
|
|
1848
|
-
return null;
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
var adjustable = obj.clone();
|
|
1852
|
-
adjustable.name = this._createUniqueName(parent, obj);
|
|
1853
|
-
adjustable.userData.selection = adj;
|
|
1854
|
-
adjustable.position.set(0, 0, 0);
|
|
1855
|
-
adjustable.visible = true;
|
|
1856
|
-
parent.add(adjustable);
|
|
1857
|
-
// the object being added to the customFloorGroup is being recreated so we loose the reference
|
|
1858
|
-
// therefor we need to retrieve the created object again
|
|
1859
|
-
// adjustable = parent.getObjectByName(adjustable.name);
|
|
1860
|
-
this._placedAdjustables.push(adjustable);
|
|
1861
|
-
return adjustable;
|
|
1862
|
-
};
|
|
1863
|
-
Builder.prototype._createAddable = function (parent, add, part2, part1) {
|
|
1864
|
-
var obj = this._source.getObjectByName(add.decoNode.gameObjectName);
|
|
1865
|
-
if (!obj) {
|
|
1866
|
-
return null;
|
|
1867
|
-
}
|
|
1868
|
-
// const selection: Selection = this._getSelectionFromId(adj.artNodeIdDeco);
|
|
1869
|
-
var addable = obj.clone();
|
|
1870
|
-
addable.name = this._createUniqueName(parent, obj);
|
|
1871
|
-
addable.userData.selection = add;
|
|
1872
|
-
addable.position.set(0, 0, 0);
|
|
1873
|
-
addable.visible = true;
|
|
1874
|
-
if (part1 && part2) {
|
|
1875
|
-
parent.add(addable);
|
|
1876
|
-
this._placedAddables.push(addable);
|
|
1877
|
-
return addable;
|
|
1878
|
-
}
|
|
1879
|
-
return addable;
|
|
1880
|
-
};
|
|
1881
|
-
Builder.prototype._placeAddables = function (parent) {
|
|
1882
|
-
var _this = this;
|
|
1883
|
-
var len = this._placedAdjustables.length;
|
|
1884
|
-
for (var i = 0; i < len; i++) {
|
|
1885
|
-
if (this._placedAdjustables[i].userData.hasOwnProperty('selection') && this._placedAdjustables[i].userData.selection) {
|
|
1886
|
-
var adjustableSelection = this._placedAdjustables[i].userData.selection;
|
|
1887
|
-
if (adjustableSelection) {
|
|
1888
|
-
var lena = adjustableSelection.addables.length;
|
|
1889
|
-
var conAddable = void 0;
|
|
1890
|
-
for (var ia = 0; ia < lena; ia++) {
|
|
1891
|
-
SceneUtils.TrySelectorConnection(this._scene, parent, this._placedAdjustables[i], adjustableSelection.addables[ia], function (add, part2, part1) { return _this._createAddable(parent, add, part2, part1); });
|
|
1892
|
-
if (conAddable) {
|
|
1893
|
-
SceneUtils.TrySelectorConnection(this._scene, parent, conAddable, adjustableSelection.addables[ia], function (add, part2, part1) { return _this._createAddable(parent, add, part2, part1); });
|
|
1894
|
-
}
|
|
1895
|
-
conAddable = this._placedAddables[this._placedAddables.length - 1];
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
};
|
|
1901
|
-
Builder.prototype._createUniqueName = function (parent, obj) {
|
|
1902
|
-
var iteration = 0;
|
|
1903
|
-
var name = obj.name;
|
|
1904
|
-
var existingObj = parent.getObjectByName(name);
|
|
1905
|
-
while (existingObj) {
|
|
1906
|
-
iteration++;
|
|
1907
|
-
name = obj.name + (iteration !== 0 ? ('_' + iteration) : '');
|
|
1908
|
-
existingObj = parent.getObjectByName(name);
|
|
1909
|
-
}
|
|
1910
|
-
return name;
|
|
1911
|
-
};
|
|
1912
|
-
Builder.prototype._getGoodIdFromSku = function (sku) {
|
|
1913
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1914
|
-
var response;
|
|
1915
|
-
return __generator(this, function (_a) {
|
|
1916
|
-
switch (_a.label) {
|
|
1917
|
-
case 0: return [4 /*yield*/, this._configuratorService.getGoodIdFromSku(sku, false)];
|
|
1918
|
-
case 1:
|
|
1919
|
-
response = _a.sent();
|
|
1920
|
-
if (response.validationResult.success && response.resultObject) {
|
|
1921
|
-
return [2 /*return*/, response.resultObject];
|
|
1922
|
-
}
|
|
1923
|
-
return [2 /*return*/];
|
|
1924
|
-
}
|
|
1925
|
-
});
|
|
1926
|
-
});
|
|
1927
|
-
};
|
|
1928
|
-
Builder.prototype._getArticle = function (sku, goodId) {
|
|
1929
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1930
|
-
var article, articleResponse, obj;
|
|
1931
|
-
return __generator(this, function (_a) {
|
|
1932
|
-
switch (_a.label) {
|
|
1933
|
-
case 0:
|
|
1934
|
-
if (this._articleCache.has(sku)) {
|
|
1935
|
-
return [2 /*return*/, this._articleCache.get(sku)];
|
|
1936
|
-
}
|
|
1937
|
-
if (!!goodId) return [3 /*break*/, 2];
|
|
1938
|
-
return [4 /*yield*/, this._getGoodIdFromSku(sku)
|
|
1939
|
-
.catch(function (error) {
|
|
1940
|
-
throw "Article with sku " + sku + " not found!";
|
|
1941
|
-
})];
|
|
1942
|
-
case 1:
|
|
1943
|
-
goodId = _a.sent();
|
|
1944
|
-
_a.label = 2;
|
|
1945
|
-
case 2: return [4 /*yield*/, this._configuratorService.getArticleQuickSel(goodId, false)];
|
|
1946
|
-
case 3:
|
|
1947
|
-
articleResponse = _a.sent();
|
|
1948
|
-
if (articleResponse.validationResult.success && articleResponse.resultObject) {
|
|
1949
|
-
if (articleResponse.resultObject.hasOwnProperty('oArticle')) {
|
|
1950
|
-
obj = Array.isArray(articleResponse.resultObject['oArticle']) ? articleResponse.resultObject['oArticle'][0] : articleResponse.resultObject['oArticle'];
|
|
1951
|
-
article = this._boFactory.makeWithRawBackendData(Article, obj);
|
|
1952
|
-
}
|
|
1953
|
-
else {
|
|
1954
|
-
article = this._boFactory.makeWithRawBackendData(Article, articleResponse.resultObject);
|
|
1955
|
-
}
|
|
1956
|
-
}
|
|
1957
|
-
this._articleCache.set(sku, article);
|
|
1958
|
-
return [2 /*return*/, article];
|
|
1959
|
-
}
|
|
1960
|
-
});
|
|
1961
|
-
});
|
|
1962
|
-
};
|
|
1963
|
-
Builder.prototype._getSelections = function (instanceId, publicationCode) {
|
|
1964
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1965
|
-
var selectionResponse;
|
|
1966
|
-
return __generator(this, function (_a) {
|
|
1967
|
-
switch (_a.label) {
|
|
1968
|
-
case 0:
|
|
1969
|
-
this._selections = [];
|
|
1970
|
-
return [4 /*yield*/, this._configuratorService.getSelections(false, publicationCode)];
|
|
1971
|
-
case 1:
|
|
1972
|
-
selectionResponse = _a.sent();
|
|
1973
|
-
if (selectionResponse.resultObjects && selectionResponse.resultObjects.length > 0) {
|
|
1974
|
-
this._selections = this._boFactory.makeBOArrayFromRawBackendDataArray(Selection, selectionResponse.resultObjects);
|
|
1975
|
-
this._selections.forEach(function (s) { return s.instanceId = instanceId; });
|
|
1976
|
-
// const filtered: Selection[] = this._selections.filter(s => s.nodeType !== NodeType.Article && s.presentationLevel === 1);
|
|
1977
|
-
this.selectionsReceived.next(this._selections);
|
|
1978
|
-
}
|
|
1979
|
-
else {
|
|
1980
|
-
throw 'No selections found!';
|
|
1981
|
-
}
|
|
1982
|
-
return [2 /*return*/];
|
|
1983
|
-
}
|
|
1984
|
-
});
|
|
1985
|
-
});
|
|
1986
|
-
};
|
|
1987
|
-
Builder.prototype._getDecos = function () {
|
|
1988
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1989
|
-
var decosResponse;
|
|
1990
|
-
return __generator(this, function (_a) {
|
|
1991
|
-
switch (_a.label) {
|
|
1992
|
-
case 0:
|
|
1993
|
-
this._decos = [];
|
|
1994
|
-
return [4 /*yield*/, this._configuratorService.getDecos(false)];
|
|
1995
|
-
case 1:
|
|
1996
|
-
decosResponse = _a.sent();
|
|
1997
|
-
if (decosResponse.resultObjects && decosResponse.resultObjects.length > 0) {
|
|
1998
|
-
this._decos = this._boFactory.makeBOArrayFromRawBackendDataArray(DecoNode, decosResponse.resultObjects);
|
|
1999
|
-
}
|
|
2000
|
-
else {
|
|
2001
|
-
throw 'No deconodes found!';
|
|
2002
|
-
}
|
|
2003
|
-
return [2 /*return*/];
|
|
2004
|
-
}
|
|
2005
|
-
});
|
|
2006
|
-
});
|
|
2007
|
-
};
|
|
2008
|
-
Builder.prototype._linkSelectionsAndDecos = function () {
|
|
2009
|
-
var _this = this;
|
|
2010
|
-
var len = this._selections.length;
|
|
2011
|
-
var _loop_1 = function (i) {
|
|
2012
|
-
var id = this_1._selections[i].artNodeIdDeco;
|
|
2013
|
-
// if (this._useNodeIdToLink) {
|
|
2014
|
-
// id = `${this._selections[i].node}_${this._selections[i].artNodeIdDeco}`;
|
|
2015
|
-
// }
|
|
2016
|
-
var deco = this_1._decos.find(function (d) { return d.id === id; });
|
|
2017
|
-
if (!deco) {
|
|
2018
|
-
deco = new DecoNode();
|
|
2019
|
-
}
|
|
2020
|
-
var variation = this_1._getVariations().find(function (v) { return v.parentId === _this._selections[i].artNodeIdDeco; });
|
|
2021
|
-
if (variation) {
|
|
2022
|
-
deco.variation = variation;
|
|
2023
|
-
}
|
|
2024
|
-
this_1._selections[i].decoNode = deco;
|
|
2025
|
-
};
|
|
2026
|
-
var this_1 = this;
|
|
2027
|
-
for (var i = 0; i < len; i++) {
|
|
2028
|
-
_loop_1(i);
|
|
2029
|
-
}
|
|
2030
|
-
};
|
|
2031
|
-
Builder.prototype._getVariations = function () {
|
|
2032
|
-
return this._decos.filter(function (deco) {
|
|
2033
|
-
return deco.type === DecoNodeType.Variation;
|
|
2034
|
-
});
|
|
2035
|
-
};
|
|
2036
|
-
Builder.prototype._loadVariations = function (obj, instanceId) {
|
|
2037
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2038
|
-
return __generator(this, function (_a) {
|
|
2039
|
-
switch (_a.label) {
|
|
2040
|
-
case 0: return [4 /*yield*/, this._variationHelper.loadPart(obj, this._adjustables, true)];
|
|
2041
|
-
case 1:
|
|
2042
|
-
_a.sent();
|
|
2043
|
-
return [4 /*yield*/, this._variationHelper.loadVariation(instanceId, obj, this._adjustables, true)];
|
|
2044
|
-
case 2:
|
|
2045
|
-
_a.sent();
|
|
2046
|
-
return [4 /*yield*/, this._variationHelper.loadVariation(instanceId, obj, this._addables, true)];
|
|
2047
|
-
case 3:
|
|
2048
|
-
_a.sent();
|
|
2049
|
-
return [2 /*return*/];
|
|
2050
|
-
}
|
|
2051
|
-
});
|
|
2052
|
-
});
|
|
2053
|
-
};
|
|
2054
|
-
Builder.prototype._getAdjustables = function () {
|
|
2055
|
-
return this._selections.filter(function (s) {
|
|
2056
|
-
var node = s.decoNode;
|
|
2057
|
-
return node && node.gameObjectName && node.type === DecoNodeType.Part && node.kind === DecoNodeKind.Adjustable;
|
|
2058
|
-
});
|
|
2059
|
-
};
|
|
2060
|
-
Builder.prototype._updatePivot = function (obj) {
|
|
2061
|
-
var boundingBox = new Box3().setFromObject(obj);
|
|
2062
|
-
var bbCenterPivot = new Vector3();
|
|
2063
|
-
boundingBox.getCenter(bbCenterPivot);
|
|
2064
|
-
var delta = new Vector3().sub(bbCenterPivot).setY(Math.abs(Math.min(boundingBox.min.y, 0)));
|
|
2065
|
-
obj.children.forEach(function (child) {
|
|
2066
|
-
child.position.add(delta);
|
|
2067
|
-
});
|
|
2068
|
-
obj.updateWorldMatrix(false, true);
|
|
2069
|
-
};
|
|
2070
|
-
Builder.prototype._reset = function () {
|
|
2071
|
-
this._placedAddables.length = 0;
|
|
2072
|
-
this._placedAdjustables.length = 0;
|
|
2073
|
-
this._adjustables.length = 0;
|
|
2074
|
-
this._addables.length = 0;
|
|
2075
|
-
this._prepareTheSelections();
|
|
2076
|
-
};
|
|
2077
|
-
Builder.ctorParameters = function () { return [
|
|
2078
|
-
{ type: Scene },
|
|
2079
|
-
{ type: Options },
|
|
2080
|
-
{ type: Boolean }
|
|
2081
|
-
]; };
|
|
2082
|
-
Builder = __decorate([
|
|
2083
|
-
Injectable()
|
|
2084
|
-
], Builder);
|
|
2085
|
-
return Builder;
|
|
1515
|
+
var Builder = /** @class */ (function () {
|
|
1516
|
+
function Builder(scene, options, useInAngular) {
|
|
1517
|
+
this.selectionsReceived = new BehaviorSubject([]);
|
|
1518
|
+
this.answersReceived = new BehaviorSubject([]);
|
|
1519
|
+
this.modelLoaded = new BehaviorSubject(null);
|
|
1520
|
+
this._selections = [];
|
|
1521
|
+
this._answers = [];
|
|
1522
|
+
this._decos = [];
|
|
1523
|
+
this._placedAdjustables = [];
|
|
1524
|
+
this._placedAddables = [];
|
|
1525
|
+
this._adjustables = [];
|
|
1526
|
+
this._addables = [];
|
|
1527
|
+
this._articleCache = new Map();
|
|
1528
|
+
this._boFactory = new BusinessObjectFactory();
|
|
1529
|
+
this._threedUtils = new ThreedUtils();
|
|
1530
|
+
this._variationHelper = new VariationHelper();
|
|
1531
|
+
if (!scene) {
|
|
1532
|
+
throw 'No scene object provided!';
|
|
1533
|
+
}
|
|
1534
|
+
if (!options) {
|
|
1535
|
+
throw 'No connection options provided!';
|
|
1536
|
+
}
|
|
1537
|
+
if (useInAngular) {
|
|
1538
|
+
this._configuratorService = ServiceLocator.injector.get(ConfiguratorService);
|
|
1539
|
+
}
|
|
1540
|
+
else {
|
|
1541
|
+
this._configuratorService = new ConfiguratorService(undefined);
|
|
1542
|
+
}
|
|
1543
|
+
this._configuratorService.initApi(options);
|
|
1544
|
+
this._scene = scene;
|
|
1545
|
+
}
|
|
1546
|
+
Builder.prototype.buildModel = function (sku, instanceId, goodId) {
|
|
1547
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1548
|
+
var promises, e_1;
|
|
1549
|
+
return __generator(this, function (_a) {
|
|
1550
|
+
switch (_a.label) {
|
|
1551
|
+
case 0:
|
|
1552
|
+
if (!this._scene) {
|
|
1553
|
+
return [2 /*return*/];
|
|
1554
|
+
}
|
|
1555
|
+
_a.label = 1;
|
|
1556
|
+
case 1:
|
|
1557
|
+
_a.trys.push([1, 8, , 9]);
|
|
1558
|
+
return [4 /*yield*/, this._setInstanceId(sku, instanceId, goodId)];
|
|
1559
|
+
case 2:
|
|
1560
|
+
_a.sent();
|
|
1561
|
+
return [4 /*yield*/, this._prepareConfiguration(this._sku, this._goodId)];
|
|
1562
|
+
case 3:
|
|
1563
|
+
_a.sent();
|
|
1564
|
+
if (!this._source) return [3 /*break*/, 6];
|
|
1565
|
+
return [4 /*yield*/, this._configuratorService.setInstanceToConfigure(this._instanceId)];
|
|
1566
|
+
case 4:
|
|
1567
|
+
_a.sent();
|
|
1568
|
+
promises = [];
|
|
1569
|
+
promises.push(this.getQuestionAndAnswers());
|
|
1570
|
+
promises.push(this._getSelections(this._instanceId));
|
|
1571
|
+
promises.push(this._getDecos());
|
|
1572
|
+
return [4 /*yield*/, Promise.all(promises)];
|
|
1573
|
+
case 5:
|
|
1574
|
+
_a.sent();
|
|
1575
|
+
if (this._answers.length > 0) {
|
|
1576
|
+
return [2 /*return*/];
|
|
1577
|
+
}
|
|
1578
|
+
this._linkSelectionsAndDecos();
|
|
1579
|
+
return [2 /*return*/, this._build(this._instanceId)];
|
|
1580
|
+
case 6: throw 'GLB source not found!';
|
|
1581
|
+
case 7: return [3 /*break*/, 9];
|
|
1582
|
+
case 8:
|
|
1583
|
+
e_1 = _a.sent();
|
|
1584
|
+
throw e_1;
|
|
1585
|
+
case 9: return [2 /*return*/];
|
|
1586
|
+
}
|
|
1587
|
+
});
|
|
1588
|
+
});
|
|
1589
|
+
};
|
|
1590
|
+
Builder.prototype.initNodeInstance = function (goodId) {
|
|
1591
|
+
return this._configuratorService.initNodeInstance(goodId);
|
|
1592
|
+
};
|
|
1593
|
+
Builder.prototype.destroy = function () {
|
|
1594
|
+
this._threedUtils.clearCache();
|
|
1595
|
+
this._variationHelper.clearCache();
|
|
1596
|
+
};
|
|
1597
|
+
Builder.prototype.selectSelection = function (selection) {
|
|
1598
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1599
|
+
return __generator(this, function (_a) {
|
|
1600
|
+
switch (_a.label) {
|
|
1601
|
+
case 0: return [4 /*yield*/, this._configuratorService.selectSelection(selection, false)];
|
|
1602
|
+
case 1:
|
|
1603
|
+
_a.sent();
|
|
1604
|
+
this.getQuestionAndAnswers();
|
|
1605
|
+
return [2 /*return*/];
|
|
1606
|
+
}
|
|
1607
|
+
});
|
|
1608
|
+
});
|
|
1609
|
+
};
|
|
1610
|
+
Builder.prototype.getQuestionAndAnswers = function (publicationCode) {
|
|
1611
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1612
|
+
var questionsAndAnswers;
|
|
1613
|
+
return __generator(this, function (_a) {
|
|
1614
|
+
switch (_a.label) {
|
|
1615
|
+
case 0: return [4 /*yield*/, this._configuratorService.getQuestionAndAnswers(false, publicationCode)];
|
|
1616
|
+
case 1:
|
|
1617
|
+
questionsAndAnswers = _a.sent();
|
|
1618
|
+
this._answers = questionsAndAnswers.answers;
|
|
1619
|
+
this.answersReceived.next(questionsAndAnswers.answers);
|
|
1620
|
+
return [2 /*return*/];
|
|
1621
|
+
}
|
|
1622
|
+
});
|
|
1623
|
+
});
|
|
1624
|
+
};
|
|
1625
|
+
Builder.prototype.selectAnswer = function (answer) {
|
|
1626
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1627
|
+
var _a, _b;
|
|
1628
|
+
return __generator(this, function (_c) {
|
|
1629
|
+
switch (_c.label) {
|
|
1630
|
+
case 0: return [4 /*yield*/, this._configuratorService.selectAnswer(answer, false)];
|
|
1631
|
+
case 1:
|
|
1632
|
+
_c.sent();
|
|
1633
|
+
_b = (_a = this.modelLoaded).next;
|
|
1634
|
+
return [4 /*yield*/, this.buildModel()];
|
|
1635
|
+
case 2:
|
|
1636
|
+
_b.apply(_a, [_c.sent()]);
|
|
1637
|
+
return [2 /*return*/];
|
|
1638
|
+
}
|
|
1639
|
+
});
|
|
1640
|
+
});
|
|
1641
|
+
};
|
|
1642
|
+
Builder.prototype._setInstanceId = function (sku, instanceId, goodId) {
|
|
1643
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1644
|
+
var result;
|
|
1645
|
+
return __generator(this, function (_a) {
|
|
1646
|
+
switch (_a.label) {
|
|
1647
|
+
case 0:
|
|
1648
|
+
if (!(!instanceId && !this._instanceId)) return [3 /*break*/, 4];
|
|
1649
|
+
if (!!goodId) return [3 /*break*/, 2];
|
|
1650
|
+
return [4 /*yield*/, this._getGoodIdFromSku(sku)];
|
|
1651
|
+
case 1:
|
|
1652
|
+
goodId = _a.sent();
|
|
1653
|
+
_a.label = 2;
|
|
1654
|
+
case 2:
|
|
1655
|
+
this._goodId = goodId;
|
|
1656
|
+
return [4 /*yield*/, this.initNodeInstance(this._goodId)];
|
|
1657
|
+
case 3:
|
|
1658
|
+
result = _a.sent();
|
|
1659
|
+
if (result && result.resultObject) {
|
|
1660
|
+
this._instanceId = result.resultObject;
|
|
1661
|
+
}
|
|
1662
|
+
else {
|
|
1663
|
+
throw 'Failed to initialize node instance';
|
|
1664
|
+
}
|
|
1665
|
+
return [3 /*break*/, 5];
|
|
1666
|
+
case 4:
|
|
1667
|
+
if (!this._instanceId) {
|
|
1668
|
+
this._instanceId = instanceId;
|
|
1669
|
+
}
|
|
1670
|
+
_a.label = 5;
|
|
1671
|
+
case 5:
|
|
1672
|
+
if (!this._sku) {
|
|
1673
|
+
this._sku = sku;
|
|
1674
|
+
}
|
|
1675
|
+
return [2 /*return*/];
|
|
1676
|
+
}
|
|
1677
|
+
});
|
|
1678
|
+
});
|
|
1679
|
+
};
|
|
1680
|
+
Builder.prototype._prepareConfiguration = function (sku, goodId) {
|
|
1681
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1682
|
+
var article, _a;
|
|
1683
|
+
return __generator(this, function (_b) {
|
|
1684
|
+
switch (_b.label) {
|
|
1685
|
+
case 0: return [4 /*yield*/, this._getArticle(sku, goodId)];
|
|
1686
|
+
case 1:
|
|
1687
|
+
article = _b.sent();
|
|
1688
|
+
if (!(article && article.assetUrl)) return [3 /*break*/, 3];
|
|
1689
|
+
_a = this;
|
|
1690
|
+
return [4 /*yield*/, this._threedUtils.download3DSource(article.assetUrl)
|
|
1691
|
+
.catch(function (error) {
|
|
1692
|
+
throw error;
|
|
1693
|
+
})];
|
|
1694
|
+
case 2:
|
|
1695
|
+
_a._source = _b.sent();
|
|
1696
|
+
if (article.contentDeliveryUrl) {
|
|
1697
|
+
this._variationHelper.assetPath =
|
|
1698
|
+
article.contentDeliveryUrl +
|
|
1699
|
+
(article.contentDeliveryUrl.endsWith('/') ? '' : '/') +
|
|
1700
|
+
(article.distSchema ? article.distSchema : 'UP_DBA');
|
|
1701
|
+
}
|
|
1702
|
+
_b.label = 3;
|
|
1703
|
+
case 3: return [2 /*return*/];
|
|
1704
|
+
}
|
|
1705
|
+
});
|
|
1706
|
+
});
|
|
1707
|
+
};
|
|
1708
|
+
Builder.prototype._build = function (instanceId) {
|
|
1709
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1710
|
+
var adjustables, obj, connected, i, len, adjustable, ii, lenii;
|
|
1711
|
+
return __generator(this, function (_a) {
|
|
1712
|
+
switch (_a.label) {
|
|
1713
|
+
case 0:
|
|
1714
|
+
this._reset();
|
|
1715
|
+
adjustables = this._getAdjustables();
|
|
1716
|
+
if (!(adjustables && adjustables.length > 0)) return [3 /*break*/, 2];
|
|
1717
|
+
obj = new Object3D();
|
|
1718
|
+
obj.visible = false; // no need to render visualy
|
|
1719
|
+
this._scene.add(obj);
|
|
1720
|
+
connected = false;
|
|
1721
|
+
for (i = 0, len = adjustables.length; i < len; i++) {
|
|
1722
|
+
adjustable = this._createAdjustable(obj, adjustables[i]);
|
|
1723
|
+
if (adjustable) {
|
|
1724
|
+
for (ii = 0, lenii = this._placedAdjustables.length; ii < lenii; ii++) {
|
|
1725
|
+
if (SceneUtils.TrySelectorConnection(this._scene, obj, this._placedAdjustables[ii], adjustable)) {
|
|
1726
|
+
this._placedAdjustables[ii].visible = true;
|
|
1727
|
+
adjustable.visible = true;
|
|
1728
|
+
connected = true;
|
|
1729
|
+
break;
|
|
1730
|
+
}
|
|
1731
|
+
connected = false;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
if (!connected && this._placedAdjustables.length > 1) {
|
|
1735
|
+
console.warn('No connection found for: ', adjustable.name);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
this._placeAddables(obj);
|
|
1739
|
+
this._updatePivot(obj);
|
|
1740
|
+
return [4 /*yield*/, this._loadVariations(obj, instanceId)];
|
|
1741
|
+
case 1:
|
|
1742
|
+
_a.sent();
|
|
1743
|
+
this._scene.remove(obj);
|
|
1744
|
+
return [2 /*return*/, obj];
|
|
1745
|
+
case 2: throw 'No adjustables found!';
|
|
1746
|
+
}
|
|
1747
|
+
});
|
|
1748
|
+
});
|
|
1749
|
+
};
|
|
1750
|
+
Builder.prototype._prepareTheSelections = function () {
|
|
1751
|
+
var _this = this;
|
|
1752
|
+
// get generic variations
|
|
1753
|
+
var globalVariations = this._selections
|
|
1754
|
+
.filter(function (s) { return s.generic && s.decoNode.variation && !s.decoNode.type; })
|
|
1755
|
+
.map(function (value, index, array) {
|
|
1756
|
+
// find selection of variation
|
|
1757
|
+
var sel = _this._selections.find(function (s) { return s.artNodeIdDeco === value.decoNode.variation.id; });
|
|
1758
|
+
if (sel) {
|
|
1759
|
+
value.decoNode.variation.supplierArticleNr = sel.supplierArticleNr;
|
|
1760
|
+
}
|
|
1761
|
+
value.decoNode.variation.materialId = value.hdecoGameObject;
|
|
1762
|
+
return value.decoNode.variation;
|
|
1763
|
+
});
|
|
1764
|
+
// const usedVariations: FurniturePartVariation[] = [];
|
|
1765
|
+
var globalVariationsRewrite = true;
|
|
1766
|
+
var len = this._selections.length;
|
|
1767
|
+
var lastAdded;
|
|
1768
|
+
var lastAdjustable;
|
|
1769
|
+
var newPart = false;
|
|
1770
|
+
var previousPresLevel = -1;
|
|
1771
|
+
var positioning;
|
|
1772
|
+
for (var i = 0; i < len; i++) {
|
|
1773
|
+
var selection = this._selections[i];
|
|
1774
|
+
if (selection.presentationLevel === 1) {
|
|
1775
|
+
positioning = selection.hdecoPositioning;
|
|
1776
|
+
}
|
|
1777
|
+
if (selection.presentationLevel > previousPresLevel) {
|
|
1778
|
+
selection.hdecoPositioning = selection.hdecoPositioning || positioning;
|
|
1779
|
+
}
|
|
1780
|
+
if (selection.decoNode) {
|
|
1781
|
+
if (selection.decoNode.type === DecoNodeType.Variation) {
|
|
1782
|
+
if (lastAdded) {
|
|
1783
|
+
if (newPart) {
|
|
1784
|
+
lastAdded.variations = [selection.decoNode];
|
|
1785
|
+
}
|
|
1786
|
+
else {
|
|
1787
|
+
lastAdded.variations.push(selection.decoNode);
|
|
1788
|
+
}
|
|
1789
|
+
newPart = false;
|
|
1790
|
+
}
|
|
1791
|
+
else {
|
|
1792
|
+
if (globalVariationsRewrite) {
|
|
1793
|
+
globalVariations.length = 0;
|
|
1794
|
+
globalVariationsRewrite = false;
|
|
1795
|
+
}
|
|
1796
|
+
globalVariations.push(selection.decoNode);
|
|
1797
|
+
}
|
|
1798
|
+
// const variation: FurniturePartVariation = new FurniturePartVariation();
|
|
1799
|
+
// variation.BrandId = selection.decoNode.brandId;
|
|
1800
|
+
// variation.Description = selection.decoNode.gameObjectName;
|
|
1801
|
+
// variation.MaterialId = (selection.decoNode as any).materialId;
|
|
1802
|
+
// variation.SupplierArticleNr = (selection.decoNode as any).supplierArticleNr;
|
|
1803
|
+
// usedVariations.push(variation);
|
|
1804
|
+
// this._upsertFurniture(this.activeInstance, {
|
|
1805
|
+
// Variation: selection.decoNode.brandId,
|
|
1806
|
+
// VariationDescription: selection.decoNode.gameObjectName,
|
|
1807
|
+
// SupplierArticleNr: (selection.decoNode as any).supplierArticleNr
|
|
1808
|
+
// });
|
|
1809
|
+
}
|
|
1810
|
+
else if (selection.decoNode.type === DecoNodeType.Part &&
|
|
1811
|
+
typeof selection.decoNode.gameObjectName === 'string' &&
|
|
1812
|
+
selection.decoNode.gameObjectName.length) {
|
|
1813
|
+
if (selection.decoNode.kind === DecoNodeKind.Adjustable) {
|
|
1814
|
+
selection.variations = globalVariations;
|
|
1815
|
+
this._adjustables.push(selection);
|
|
1816
|
+
if (!lastAdded || lastAdded.nodeId !== selection.nodeId) {
|
|
1817
|
+
newPart = true;
|
|
1818
|
+
}
|
|
1819
|
+
lastAdded = selection;
|
|
1820
|
+
lastAdjustable = selection;
|
|
1821
|
+
}
|
|
1822
|
+
else if (selection.decoNode.kind === DecoNodeKind.Addable) {
|
|
1823
|
+
selection.variations = lastAdjustable ? lastAdjustable.variations : globalVariations;
|
|
1824
|
+
if (lastAdjustable) {
|
|
1825
|
+
lastAdjustable.addables.push(selection);
|
|
1826
|
+
}
|
|
1827
|
+
this._addables.push(selection);
|
|
1828
|
+
if (!lastAdded || lastAdded.nodeId !== selection.nodeId) {
|
|
1829
|
+
newPart = true;
|
|
1830
|
+
}
|
|
1831
|
+
lastAdded = selection;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
previousPresLevel = selection.presentationLevel;
|
|
1836
|
+
}
|
|
1837
|
+
// this._upsertFurniture(this.activeInstance,
|
|
1838
|
+
// {Variations: usedVariations});
|
|
1839
|
+
};
|
|
1840
|
+
Builder.prototype._createAdjustable = function (parent, adj) {
|
|
1841
|
+
var obj = this._source ? this._source.getObjectByName(adj.decoNode.gameObjectName) : null;
|
|
1842
|
+
if (!obj) {
|
|
1843
|
+
// in case of glb files, the importer removes dots from names
|
|
1844
|
+
var name_1 = adj.decoNode.gameObjectName.replace(/[.]/g, '');
|
|
1845
|
+
obj = this._source ? this._source.getObjectByName(name_1) : null;
|
|
1846
|
+
if (!obj) {
|
|
1847
|
+
// console.warn(`No object with name ${adj.decoNode.gameObjectName} found!`);
|
|
1848
|
+
return null;
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
var adjustable = obj.clone();
|
|
1852
|
+
adjustable.name = this._createUniqueName(parent, obj);
|
|
1853
|
+
adjustable.userData.selection = adj;
|
|
1854
|
+
adjustable.position.set(0, 0, 0);
|
|
1855
|
+
adjustable.visible = true;
|
|
1856
|
+
parent.add(adjustable);
|
|
1857
|
+
// the object being added to the customFloorGroup is being recreated so we loose the reference
|
|
1858
|
+
// therefor we need to retrieve the created object again
|
|
1859
|
+
// adjustable = parent.getObjectByName(adjustable.name);
|
|
1860
|
+
this._placedAdjustables.push(adjustable);
|
|
1861
|
+
return adjustable;
|
|
1862
|
+
};
|
|
1863
|
+
Builder.prototype._createAddable = function (parent, add, part2, part1) {
|
|
1864
|
+
var obj = this._source.getObjectByName(add.decoNode.gameObjectName);
|
|
1865
|
+
if (!obj) {
|
|
1866
|
+
return null;
|
|
1867
|
+
}
|
|
1868
|
+
// const selection: Selection = this._getSelectionFromId(adj.artNodeIdDeco);
|
|
1869
|
+
var addable = obj.clone();
|
|
1870
|
+
addable.name = this._createUniqueName(parent, obj);
|
|
1871
|
+
addable.userData.selection = add;
|
|
1872
|
+
addable.position.set(0, 0, 0);
|
|
1873
|
+
addable.visible = true;
|
|
1874
|
+
if (part1 && part2) {
|
|
1875
|
+
parent.add(addable);
|
|
1876
|
+
this._placedAddables.push(addable);
|
|
1877
|
+
return addable;
|
|
1878
|
+
}
|
|
1879
|
+
return addable;
|
|
1880
|
+
};
|
|
1881
|
+
Builder.prototype._placeAddables = function (parent) {
|
|
1882
|
+
var _this = this;
|
|
1883
|
+
var len = this._placedAdjustables.length;
|
|
1884
|
+
for (var i = 0; i < len; i++) {
|
|
1885
|
+
if (this._placedAdjustables[i].userData.hasOwnProperty('selection') && this._placedAdjustables[i].userData.selection) {
|
|
1886
|
+
var adjustableSelection = this._placedAdjustables[i].userData.selection;
|
|
1887
|
+
if (adjustableSelection) {
|
|
1888
|
+
var lena = adjustableSelection.addables.length;
|
|
1889
|
+
var conAddable = void 0;
|
|
1890
|
+
for (var ia = 0; ia < lena; ia++) {
|
|
1891
|
+
SceneUtils.TrySelectorConnection(this._scene, parent, this._placedAdjustables[i], adjustableSelection.addables[ia], function (add, part2, part1) { return _this._createAddable(parent, add, part2, part1); });
|
|
1892
|
+
if (conAddable) {
|
|
1893
|
+
SceneUtils.TrySelectorConnection(this._scene, parent, conAddable, adjustableSelection.addables[ia], function (add, part2, part1) { return _this._createAddable(parent, add, part2, part1); });
|
|
1894
|
+
}
|
|
1895
|
+
conAddable = this._placedAddables[this._placedAddables.length - 1];
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
};
|
|
1901
|
+
Builder.prototype._createUniqueName = function (parent, obj) {
|
|
1902
|
+
var iteration = 0;
|
|
1903
|
+
var name = obj.name;
|
|
1904
|
+
var existingObj = parent.getObjectByName(name);
|
|
1905
|
+
while (existingObj) {
|
|
1906
|
+
iteration++;
|
|
1907
|
+
name = obj.name + (iteration !== 0 ? ('_' + iteration) : '');
|
|
1908
|
+
existingObj = parent.getObjectByName(name);
|
|
1909
|
+
}
|
|
1910
|
+
return name;
|
|
1911
|
+
};
|
|
1912
|
+
Builder.prototype._getGoodIdFromSku = function (sku) {
|
|
1913
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1914
|
+
var response;
|
|
1915
|
+
return __generator(this, function (_a) {
|
|
1916
|
+
switch (_a.label) {
|
|
1917
|
+
case 0: return [4 /*yield*/, this._configuratorService.getGoodIdFromSku(sku, false)];
|
|
1918
|
+
case 1:
|
|
1919
|
+
response = _a.sent();
|
|
1920
|
+
if (response.validationResult.success && response.resultObject) {
|
|
1921
|
+
return [2 /*return*/, response.resultObject];
|
|
1922
|
+
}
|
|
1923
|
+
return [2 /*return*/];
|
|
1924
|
+
}
|
|
1925
|
+
});
|
|
1926
|
+
});
|
|
1927
|
+
};
|
|
1928
|
+
Builder.prototype._getArticle = function (sku, goodId) {
|
|
1929
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1930
|
+
var article, articleResponse, obj;
|
|
1931
|
+
return __generator(this, function (_a) {
|
|
1932
|
+
switch (_a.label) {
|
|
1933
|
+
case 0:
|
|
1934
|
+
if (this._articleCache.has(sku)) {
|
|
1935
|
+
return [2 /*return*/, this._articleCache.get(sku)];
|
|
1936
|
+
}
|
|
1937
|
+
if (!!goodId) return [3 /*break*/, 2];
|
|
1938
|
+
return [4 /*yield*/, this._getGoodIdFromSku(sku)
|
|
1939
|
+
.catch(function (error) {
|
|
1940
|
+
throw "Article with sku " + sku + " not found!";
|
|
1941
|
+
})];
|
|
1942
|
+
case 1:
|
|
1943
|
+
goodId = _a.sent();
|
|
1944
|
+
_a.label = 2;
|
|
1945
|
+
case 2: return [4 /*yield*/, this._configuratorService.getArticleQuickSel(goodId, false)];
|
|
1946
|
+
case 3:
|
|
1947
|
+
articleResponse = _a.sent();
|
|
1948
|
+
if (articleResponse.validationResult.success && articleResponse.resultObject) {
|
|
1949
|
+
if (articleResponse.resultObject.hasOwnProperty('oArticle')) {
|
|
1950
|
+
obj = Array.isArray(articleResponse.resultObject['oArticle']) ? articleResponse.resultObject['oArticle'][0] : articleResponse.resultObject['oArticle'];
|
|
1951
|
+
article = this._boFactory.makeWithRawBackendData(Article, obj);
|
|
1952
|
+
}
|
|
1953
|
+
else {
|
|
1954
|
+
article = this._boFactory.makeWithRawBackendData(Article, articleResponse.resultObject);
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
this._articleCache.set(sku, article);
|
|
1958
|
+
return [2 /*return*/, article];
|
|
1959
|
+
}
|
|
1960
|
+
});
|
|
1961
|
+
});
|
|
1962
|
+
};
|
|
1963
|
+
Builder.prototype._getSelections = function (instanceId, publicationCode) {
|
|
1964
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1965
|
+
var selectionResponse;
|
|
1966
|
+
return __generator(this, function (_a) {
|
|
1967
|
+
switch (_a.label) {
|
|
1968
|
+
case 0:
|
|
1969
|
+
this._selections = [];
|
|
1970
|
+
return [4 /*yield*/, this._configuratorService.getSelections(false, publicationCode)];
|
|
1971
|
+
case 1:
|
|
1972
|
+
selectionResponse = _a.sent();
|
|
1973
|
+
if (selectionResponse.resultObjects && selectionResponse.resultObjects.length > 0) {
|
|
1974
|
+
this._selections = this._boFactory.makeBOArrayFromRawBackendDataArray(Selection, selectionResponse.resultObjects);
|
|
1975
|
+
this._selections.forEach(function (s) { return s.instanceId = instanceId; });
|
|
1976
|
+
// const filtered: Selection[] = this._selections.filter(s => s.nodeType !== NodeType.Article && s.presentationLevel === 1);
|
|
1977
|
+
this.selectionsReceived.next(this._selections);
|
|
1978
|
+
}
|
|
1979
|
+
else {
|
|
1980
|
+
throw 'No selections found!';
|
|
1981
|
+
}
|
|
1982
|
+
return [2 /*return*/];
|
|
1983
|
+
}
|
|
1984
|
+
});
|
|
1985
|
+
});
|
|
1986
|
+
};
|
|
1987
|
+
Builder.prototype._getDecos = function () {
|
|
1988
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1989
|
+
var decosResponse;
|
|
1990
|
+
return __generator(this, function (_a) {
|
|
1991
|
+
switch (_a.label) {
|
|
1992
|
+
case 0:
|
|
1993
|
+
this._decos = [];
|
|
1994
|
+
return [4 /*yield*/, this._configuratorService.getDecos(false)];
|
|
1995
|
+
case 1:
|
|
1996
|
+
decosResponse = _a.sent();
|
|
1997
|
+
if (decosResponse.resultObjects && decosResponse.resultObjects.length > 0) {
|
|
1998
|
+
this._decos = this._boFactory.makeBOArrayFromRawBackendDataArray(DecoNode, decosResponse.resultObjects);
|
|
1999
|
+
}
|
|
2000
|
+
else {
|
|
2001
|
+
throw 'No deconodes found!';
|
|
2002
|
+
}
|
|
2003
|
+
return [2 /*return*/];
|
|
2004
|
+
}
|
|
2005
|
+
});
|
|
2006
|
+
});
|
|
2007
|
+
};
|
|
2008
|
+
Builder.prototype._linkSelectionsAndDecos = function () {
|
|
2009
|
+
var _this = this;
|
|
2010
|
+
var len = this._selections.length;
|
|
2011
|
+
var _loop_1 = function (i) {
|
|
2012
|
+
var id = this_1._selections[i].artNodeIdDeco;
|
|
2013
|
+
// if (this._useNodeIdToLink) {
|
|
2014
|
+
// id = `${this._selections[i].node}_${this._selections[i].artNodeIdDeco}`;
|
|
2015
|
+
// }
|
|
2016
|
+
var deco = this_1._decos.find(function (d) { return d.id === id; });
|
|
2017
|
+
if (!deco) {
|
|
2018
|
+
deco = new DecoNode();
|
|
2019
|
+
}
|
|
2020
|
+
var variation = this_1._getVariations().find(function (v) { return v.parentId === _this._selections[i].artNodeIdDeco; });
|
|
2021
|
+
if (variation) {
|
|
2022
|
+
deco.variation = variation;
|
|
2023
|
+
}
|
|
2024
|
+
this_1._selections[i].decoNode = deco;
|
|
2025
|
+
};
|
|
2026
|
+
var this_1 = this;
|
|
2027
|
+
for (var i = 0; i < len; i++) {
|
|
2028
|
+
_loop_1(i);
|
|
2029
|
+
}
|
|
2030
|
+
};
|
|
2031
|
+
Builder.prototype._getVariations = function () {
|
|
2032
|
+
return this._decos.filter(function (deco) {
|
|
2033
|
+
return deco.type === DecoNodeType.Variation;
|
|
2034
|
+
});
|
|
2035
|
+
};
|
|
2036
|
+
Builder.prototype._loadVariations = function (obj, instanceId) {
|
|
2037
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2038
|
+
return __generator(this, function (_a) {
|
|
2039
|
+
switch (_a.label) {
|
|
2040
|
+
case 0: return [4 /*yield*/, this._variationHelper.loadPart(obj, this._adjustables, true)];
|
|
2041
|
+
case 1:
|
|
2042
|
+
_a.sent();
|
|
2043
|
+
return [4 /*yield*/, this._variationHelper.loadVariation(instanceId, obj, this._adjustables, true)];
|
|
2044
|
+
case 2:
|
|
2045
|
+
_a.sent();
|
|
2046
|
+
return [4 /*yield*/, this._variationHelper.loadVariation(instanceId, obj, this._addables, true)];
|
|
2047
|
+
case 3:
|
|
2048
|
+
_a.sent();
|
|
2049
|
+
return [2 /*return*/];
|
|
2050
|
+
}
|
|
2051
|
+
});
|
|
2052
|
+
});
|
|
2053
|
+
};
|
|
2054
|
+
Builder.prototype._getAdjustables = function () {
|
|
2055
|
+
return this._selections.filter(function (s) {
|
|
2056
|
+
var node = s.decoNode;
|
|
2057
|
+
return node && node.gameObjectName && node.type === DecoNodeType.Part && node.kind === DecoNodeKind.Adjustable;
|
|
2058
|
+
});
|
|
2059
|
+
};
|
|
2060
|
+
Builder.prototype._updatePivot = function (obj) {
|
|
2061
|
+
var boundingBox = new Box3().setFromObject(obj);
|
|
2062
|
+
var bbCenterPivot = new Vector3();
|
|
2063
|
+
boundingBox.getCenter(bbCenterPivot);
|
|
2064
|
+
var delta = new Vector3().sub(bbCenterPivot).setY(Math.abs(Math.min(boundingBox.min.y, 0)));
|
|
2065
|
+
obj.children.forEach(function (child) {
|
|
2066
|
+
child.position.add(delta);
|
|
2067
|
+
});
|
|
2068
|
+
obj.updateWorldMatrix(false, true);
|
|
2069
|
+
};
|
|
2070
|
+
Builder.prototype._reset = function () {
|
|
2071
|
+
this._placedAddables.length = 0;
|
|
2072
|
+
this._placedAdjustables.length = 0;
|
|
2073
|
+
this._adjustables.length = 0;
|
|
2074
|
+
this._addables.length = 0;
|
|
2075
|
+
this._prepareTheSelections();
|
|
2076
|
+
};
|
|
2077
|
+
Builder.ctorParameters = function () { return [
|
|
2078
|
+
{ type: Scene },
|
|
2079
|
+
{ type: Options },
|
|
2080
|
+
{ type: Boolean }
|
|
2081
|
+
]; };
|
|
2082
|
+
Builder = __decorate([
|
|
2083
|
+
Injectable()
|
|
2084
|
+
], Builder);
|
|
2085
|
+
return Builder;
|
|
2086
2086
|
}());
|
|
2087
2087
|
|
|
2088
|
-
var AnswersComponent = /** @class */ (function () {
|
|
2089
|
-
function AnswersComponent() {
|
|
2090
|
-
this.answers = [];
|
|
2091
|
-
this.answerClick = new EventEmitter();
|
|
2092
|
-
}
|
|
2093
|
-
__decorate([
|
|
2094
|
-
Input()
|
|
2095
|
-
], AnswersComponent.prototype, "answers", void 0);
|
|
2096
|
-
__decorate([
|
|
2097
|
-
Input()
|
|
2098
|
-
], AnswersComponent.prototype, "selectionTitle", void 0);
|
|
2099
|
-
__decorate([
|
|
2100
|
-
Output()
|
|
2101
|
-
], AnswersComponent.prototype, "answerClick", void 0);
|
|
2102
|
-
AnswersComponent = __decorate([
|
|
2103
|
-
Component({
|
|
2104
|
-
selector: "answers",
|
|
2105
|
-
template: "\n <
|
|
2106
|
-
styles: ["
|
|
2107
|
-
})
|
|
2108
|
-
], AnswersComponent);
|
|
2109
|
-
return AnswersComponent;
|
|
2088
|
+
var AnswersComponent = /** @class */ (function () {
|
|
2089
|
+
function AnswersComponent() {
|
|
2090
|
+
this.answers = [];
|
|
2091
|
+
this.answerClick = new EventEmitter();
|
|
2092
|
+
}
|
|
2093
|
+
__decorate([
|
|
2094
|
+
Input()
|
|
2095
|
+
], AnswersComponent.prototype, "answers", void 0);
|
|
2096
|
+
__decorate([
|
|
2097
|
+
Input()
|
|
2098
|
+
], AnswersComponent.prototype, "selectionTitle", void 0);
|
|
2099
|
+
__decorate([
|
|
2100
|
+
Output()
|
|
2101
|
+
], AnswersComponent.prototype, "answerClick", void 0);
|
|
2102
|
+
AnswersComponent = __decorate([
|
|
2103
|
+
Component({
|
|
2104
|
+
selector: "answers",
|
|
2105
|
+
template: "\n <div class=\"ione-configurator\">\n <div class=\"rp-answers-slideout\">\n <h2 class=\"answers-title\" [textContent]=\"selectionTitle\"></h2>\n <div class=\"answers-container\" visibilityObserverMaster>\n <answer *ngFor=\"let answer of answers\"\n (click)=\"answerClick.emit(answer)\"\n [answer]=\"answer\"\n visibilityObserver\n #intersection=\"intersection\"\n [observerEnabled]=\"true\"\n [showing]=\"intersection.isIntersecting\"\n ></answer>\n </div>\n \n </div>\n </div>\n ",
|
|
2106
|
+
styles: [".ione-configurator .rp-answers-slideout{position:absolute;top:0;right:0;width:400px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}.ione-configurator .answers-title{margin-left:10px;color:#1a1a1a}.ione-configurator .answers-container{height:100vh;overflow-y:scroll}.ione-configurator .answer-content{position:relative;overflow:hidden;cursor:pointer;font-size:12px;border:1px solid #d3d3d3;padding:10px;display:flex;flex-direction:row;border-radius:3px;margin-bottom:3px;box-shadow:2px 1px rgba(211,211,211,.5);background:#fff}.ione-configurator .thumbnail{width:54px;min-width:54px;height:54px;min-height:54px;border:1px solid #d3d3d3;border-radius:5px}.ione-configurator .img-size{width:54px;min-width:54px;height:54px;min-height:54px;border-radius:5px}.ione-configurator .answer-wrapper{display:block}.ione-configurator .answer-title{font-size:12px;position:relative;overflow:hidden;cursor:pointer}.ione-configurator .question{font-weight:700;color:#1a1a1a}.ione-configurator .answer{font-size:12px;font-style:italic;margin-top:3px}.ione-configurator .collapse-content,.ione-configurator .collapse-wrapper{display:block}.ione-configurator .collapse-handle{position:absolute;top:10px;right:12px;border:solid #000;border-width:0 3px 3px 0;display:inline-block;padding:3px;transform:rotate(45deg);-webkit-transform:rotate(45deg)}.ione-configurator .collapse-handle.expanded{transform:rotate(-135deg);-webkit-transform:rotate(-135deg)}.ione-configurator .child-selection{margin-left:10px;display:flex;flex-direction:column;margin-top:5px}.ione-configurator .mat-title{margin-left:10px;color:#1a1a1a}.ione-configurator .drawer__header{height:48px}.ione-configurator .rp-selections-summary{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;background:0 0;overflow:auto;position:absolute;top:0;right:0;width:400px}.ione-configurator .selections-content{overflow-y:auto}.ione-configurator .co-summary-line{position:relative;overflow:hidden;cursor:pointer;font-size:12px;border:1px solid #d3d3d3;padding:10px;display:flex;flex-direction:row;border-radius:3px;margin-bottom:3px;box-shadow:2px 1px rgba(211,211,211,.5);background:#fff}.ione-configurator .selection-thumbnail{width:54px;min-width:54px;height:54px;min-height:54px;border:1px solid #d3d3d3;border-radius:5px}.ione-configurator .selection-img{width:54px;min-width:54px;height:54px;min-height:54px;border-radius:5px}.ione-configurator .answer-thumbnail{width:54px;min-width:54px;height:54px;min-height:54px;border:1px solid #d3d3d3;border-radius:5px}.ione-configurator .answer-img{width:54px;min-width:54px;height:54px;min-height:54px;border-radius:5px}.ione-configurator .unloaded{background-color:#d3d3d3}.ione-configurator .titles{margin-left:14px;-ms-grid-row-align:center;align-self:center}.ione-configurator .title-wrapper{display:flex;flex-direction:column}.ione-configurator .answer-title-wrapper{text-align:center;-ms-grid-row-align:center;align-self:center;margin-left:14px}"]
|
|
2107
|
+
})
|
|
2108
|
+
], AnswersComponent);
|
|
2109
|
+
return AnswersComponent;
|
|
2110
2110
|
}());
|
|
2111
2111
|
|
|
2112
|
-
var ImageCacheService = /** @class */ (function () {
|
|
2113
|
-
function ImageCacheService(_configuratorService) {
|
|
2114
|
-
this._configuratorService = _configuratorService;
|
|
2115
|
-
// Map containing the retrieved images, @number = nodeId, @string = base64 string
|
|
2116
|
-
this._imageCache = new Map();
|
|
2117
|
-
}
|
|
2118
|
-
ImageCacheService_1 = ImageCacheService;
|
|
2119
|
-
ImageCacheService._handleResponseData = function (includeMimetype, thumb, responseData) {
|
|
2120
|
-
if (responseData && responseData.resultObject) {
|
|
2121
|
-
if (responseData.resultObject.filePath !== null && responseData.resultObject.filePath !== "") {
|
|
2122
|
-
return ImageUtils.getFixedImageFilepathUrl(responseData.resultObject.filePath);
|
|
2123
|
-
}
|
|
2124
|
-
else {
|
|
2125
|
-
if (includeMimetype) {
|
|
2126
|
-
return ImageUtils.getDocBodyWithMimeTypeDefinition(responseData.resultObject.fileName, thumb ? responseData.resultObject.thumbnailBody : responseData.resultObject.documentBody);
|
|
2127
|
-
}
|
|
2128
|
-
else {
|
|
2129
|
-
return thumb ? responseData.resultObject.thumbnailBody : responseData.resultObject.documentBody;
|
|
2130
|
-
}
|
|
2131
|
-
}
|
|
2132
|
-
}
|
|
2133
|
-
else {
|
|
2134
|
-
return '';
|
|
2135
|
-
}
|
|
2136
|
-
};
|
|
2137
|
-
ImageCacheService.prototype.getImageForSelectionOrAnswer = function (object) {
|
|
2138
|
-
var _this = this;
|
|
2139
|
-
var includeMimeType = true, thumb = true;
|
|
2140
|
-
return new Promise(function (resolve, reject) {
|
|
2141
|
-
if (object && object.nodeId) {
|
|
2142
|
-
if (!_this._imageCache.has(object.nodeId)) {
|
|
2143
|
-
return _this._configuratorService.getSingleImage(object.nodeId, 4, includeMimeType, thumb, true)
|
|
2144
|
-
.then(function (responseData) {
|
|
2145
|
-
var base64 = ImageCacheService_1._handleResponseData(includeMimeType, thumb, responseData);
|
|
2146
|
-
_this._imageCache.set(object.nodeId, base64);
|
|
2147
|
-
resolve(base64);
|
|
2148
|
-
}).catch(function () {
|
|
2149
|
-
reject();
|
|
2150
|
-
});
|
|
2151
|
-
}
|
|
2152
|
-
else {
|
|
2153
|
-
resolve(_this._imageCache.get(object.nodeId));
|
|
2154
|
-
}
|
|
2155
|
-
}
|
|
2156
|
-
else {
|
|
2157
|
-
reject();
|
|
2158
|
-
}
|
|
2159
|
-
});
|
|
2160
|
-
};
|
|
2161
|
-
var ImageCacheService_1;
|
|
2162
|
-
ImageCacheService.ctorParameters = function () { return [
|
|
2163
|
-
{ type: ConfiguratorService }
|
|
2164
|
-
]; };
|
|
2165
|
-
ImageCacheService.ɵprov = ɵɵdefineInjectable({ factory: function ImageCacheService_Factory() { return new ImageCacheService(ɵɵinject(ConfiguratorService)); }, token: ImageCacheService, providedIn: "root" });
|
|
2166
|
-
ImageCacheService = ImageCacheService_1 = __decorate([
|
|
2167
|
-
Injectable({
|
|
2168
|
-
providedIn: 'root'
|
|
2169
|
-
})
|
|
2170
|
-
], ImageCacheService);
|
|
2171
|
-
return ImageCacheService;
|
|
2112
|
+
var ImageCacheService = /** @class */ (function () {
|
|
2113
|
+
function ImageCacheService(_configuratorService) {
|
|
2114
|
+
this._configuratorService = _configuratorService;
|
|
2115
|
+
// Map containing the retrieved images, @number = nodeId, @string = base64 string
|
|
2116
|
+
this._imageCache = new Map();
|
|
2117
|
+
}
|
|
2118
|
+
ImageCacheService_1 = ImageCacheService;
|
|
2119
|
+
ImageCacheService._handleResponseData = function (includeMimetype, thumb, responseData) {
|
|
2120
|
+
if (responseData && responseData.resultObject) {
|
|
2121
|
+
if (responseData.resultObject.filePath !== null && responseData.resultObject.filePath !== "") {
|
|
2122
|
+
return ImageUtils.getFixedImageFilepathUrl(responseData.resultObject.filePath);
|
|
2123
|
+
}
|
|
2124
|
+
else {
|
|
2125
|
+
if (includeMimetype) {
|
|
2126
|
+
return ImageUtils.getDocBodyWithMimeTypeDefinition(responseData.resultObject.fileName, thumb ? responseData.resultObject.thumbnailBody : responseData.resultObject.documentBody);
|
|
2127
|
+
}
|
|
2128
|
+
else {
|
|
2129
|
+
return thumb ? responseData.resultObject.thumbnailBody : responseData.resultObject.documentBody;
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
else {
|
|
2134
|
+
return '';
|
|
2135
|
+
}
|
|
2136
|
+
};
|
|
2137
|
+
ImageCacheService.prototype.getImageForSelectionOrAnswer = function (object) {
|
|
2138
|
+
var _this = this;
|
|
2139
|
+
var includeMimeType = true, thumb = true;
|
|
2140
|
+
return new Promise(function (resolve, reject) {
|
|
2141
|
+
if (object && object.nodeId) {
|
|
2142
|
+
if (!_this._imageCache.has(object.nodeId)) {
|
|
2143
|
+
return _this._configuratorService.getSingleImage(object.nodeId, 4, includeMimeType, thumb, true)
|
|
2144
|
+
.then(function (responseData) {
|
|
2145
|
+
var base64 = ImageCacheService_1._handleResponseData(includeMimeType, thumb, responseData);
|
|
2146
|
+
_this._imageCache.set(object.nodeId, base64);
|
|
2147
|
+
resolve(base64);
|
|
2148
|
+
}).catch(function () {
|
|
2149
|
+
reject();
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
else {
|
|
2153
|
+
resolve(_this._imageCache.get(object.nodeId));
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
else {
|
|
2157
|
+
reject();
|
|
2158
|
+
}
|
|
2159
|
+
});
|
|
2160
|
+
};
|
|
2161
|
+
var ImageCacheService_1;
|
|
2162
|
+
ImageCacheService.ctorParameters = function () { return [
|
|
2163
|
+
{ type: ConfiguratorService }
|
|
2164
|
+
]; };
|
|
2165
|
+
ImageCacheService.ɵprov = ɵɵdefineInjectable({ factory: function ImageCacheService_Factory() { return new ImageCacheService(ɵɵinject(ConfiguratorService)); }, token: ImageCacheService, providedIn: "root" });
|
|
2166
|
+
ImageCacheService = ImageCacheService_1 = __decorate([
|
|
2167
|
+
Injectable({
|
|
2168
|
+
providedIn: 'root'
|
|
2169
|
+
})
|
|
2170
|
+
], ImageCacheService);
|
|
2171
|
+
return ImageCacheService;
|
|
2172
2172
|
}());
|
|
2173
2173
|
|
|
2174
|
-
var AnswerComponent = /** @class */ (function () {
|
|
2175
|
-
function AnswerComponent(_imageCacheService) {
|
|
2176
|
-
this._imageCacheService = _imageCacheService;
|
|
2177
|
-
}
|
|
2178
|
-
Object.defineProperty(AnswerComponent.prototype, "showing", {
|
|
2179
|
-
set: function (value) {
|
|
2180
|
-
this.answer.imageData = '';
|
|
2181
|
-
if (value && this.answer.answer !== 'Skip / Cancel') {
|
|
2182
|
-
this._loadThumbnail(this.answer);
|
|
2183
|
-
}
|
|
2184
|
-
else {
|
|
2185
|
-
this.answer.imageData = null;
|
|
2186
|
-
}
|
|
2187
|
-
},
|
|
2188
|
-
enumerable: true,
|
|
2189
|
-
configurable: true
|
|
2190
|
-
});
|
|
2191
|
-
AnswerComponent.prototype.ngOnInit = function () {
|
|
2192
|
-
};
|
|
2193
|
-
AnswerComponent.prototype._loadThumbnail = function (answer) {
|
|
2194
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2195
|
-
return __generator(this, function (_a) {
|
|
2196
|
-
switch (_a.label) {
|
|
2197
|
-
case 0: return [4 /*yield*/, this._imageCacheService.getImageForSelectionOrAnswer(answer).then(function (imageSrc) {
|
|
2198
|
-
answer.imageData = imageSrc === "" ? null : imageSrc;
|
|
2199
|
-
})];
|
|
2200
|
-
case 1:
|
|
2201
|
-
_a.sent();
|
|
2202
|
-
return [2 /*return*/];
|
|
2203
|
-
}
|
|
2204
|
-
});
|
|
2205
|
-
});
|
|
2206
|
-
};
|
|
2207
|
-
AnswerComponent.ctorParameters = function () { return [
|
|
2208
|
-
{ type: ImageCacheService }
|
|
2209
|
-
]; };
|
|
2210
|
-
__decorate([
|
|
2211
|
-
Input()
|
|
2212
|
-
], AnswerComponent.prototype, "answer", void 0);
|
|
2213
|
-
__decorate([
|
|
2214
|
-
Input()
|
|
2215
|
-
], AnswerComponent.prototype, "showing", null);
|
|
2216
|
-
AnswerComponent = __decorate([
|
|
2217
|
-
Component({
|
|
2218
|
-
selector: 'answer',
|
|
2219
|
-
template: "\n <
|
|
2220
|
-
animations: [
|
|
2221
|
-
trigger('answerAppear', [
|
|
2222
|
-
state('void', style({ 'background': '#dbdbdb' })),
|
|
2223
|
-
state('white', style({ 'background': 'white' })),
|
|
2224
|
-
transition('void <=> *', animate(500))
|
|
2225
|
-
])
|
|
2226
|
-
],
|
|
2227
|
-
styles: [".answer{font-size:12px;position:relative;overflow:hidden;cursor:pointer}
|
|
2228
|
-
})
|
|
2229
|
-
], AnswerComponent);
|
|
2230
|
-
return AnswerComponent;
|
|
2174
|
+
var AnswerComponent = /** @class */ (function () {
|
|
2175
|
+
function AnswerComponent(_imageCacheService) {
|
|
2176
|
+
this._imageCacheService = _imageCacheService;
|
|
2177
|
+
}
|
|
2178
|
+
Object.defineProperty(AnswerComponent.prototype, "showing", {
|
|
2179
|
+
set: function (value) {
|
|
2180
|
+
this.answer.imageData = '';
|
|
2181
|
+
if (value && this.answer.answer !== 'Skip / Cancel') {
|
|
2182
|
+
this._loadThumbnail(this.answer);
|
|
2183
|
+
}
|
|
2184
|
+
else {
|
|
2185
|
+
this.answer.imageData = null;
|
|
2186
|
+
}
|
|
2187
|
+
},
|
|
2188
|
+
enumerable: true,
|
|
2189
|
+
configurable: true
|
|
2190
|
+
});
|
|
2191
|
+
AnswerComponent.prototype.ngOnInit = function () {
|
|
2192
|
+
};
|
|
2193
|
+
AnswerComponent.prototype._loadThumbnail = function (answer) {
|
|
2194
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2195
|
+
return __generator(this, function (_a) {
|
|
2196
|
+
switch (_a.label) {
|
|
2197
|
+
case 0: return [4 /*yield*/, this._imageCacheService.getImageForSelectionOrAnswer(answer).then(function (imageSrc) {
|
|
2198
|
+
answer.imageData = imageSrc === "" ? null : imageSrc;
|
|
2199
|
+
})];
|
|
2200
|
+
case 1:
|
|
2201
|
+
_a.sent();
|
|
2202
|
+
return [2 /*return*/];
|
|
2203
|
+
}
|
|
2204
|
+
});
|
|
2205
|
+
});
|
|
2206
|
+
};
|
|
2207
|
+
AnswerComponent.ctorParameters = function () { return [
|
|
2208
|
+
{ type: ImageCacheService }
|
|
2209
|
+
]; };
|
|
2210
|
+
__decorate([
|
|
2211
|
+
Input()
|
|
2212
|
+
], AnswerComponent.prototype, "answer", void 0);
|
|
2213
|
+
__decorate([
|
|
2214
|
+
Input()
|
|
2215
|
+
], AnswerComponent.prototype, "showing", null);
|
|
2216
|
+
AnswerComponent = __decorate([
|
|
2217
|
+
Component({
|
|
2218
|
+
selector: 'answer',
|
|
2219
|
+
template: "\n <div class=\"ione-configurator\">\n <div class=\"answer-wrapper\">\n <div class=\"answer-content\" @answerAppear>\n <div class=\"answer-thumbnail\">\n <rp-loader *ngIf=\"answer.imageData === ''\"></rp-loader>\n <img *ngIf=\"answer.imageData !== '' && answer.imageData !== null\" class=\"answer-img\" [src]=\"answer.imageData\">\n </div>\n <div class=\"answer-title-wrapper\">\n <span class=\"answer-title\" [textContent]=\"answer.commercialAnswer\"></span>\n </div>\n <div class=\"price\">\n <span class=\"price-value\"></span>\n </div>\n </div>\n </div>\n </div>\n ",
|
|
2220
|
+
animations: [
|
|
2221
|
+
trigger('answerAppear', [
|
|
2222
|
+
state('void', style({ 'background': '#dbdbdb' })),
|
|
2223
|
+
state('white', style({ 'background': 'white' })),
|
|
2224
|
+
transition('void <=> *', animate(500))
|
|
2225
|
+
])
|
|
2226
|
+
],
|
|
2227
|
+
styles: [".ione-configurator .rp-answers-slideout{position:absolute;top:0;right:0;width:400px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}.ione-configurator .answers-title{margin-left:10px;color:#1a1a1a}.ione-configurator .answers-container{height:100vh;overflow-y:scroll}.ione-configurator .answer-content{position:relative;overflow:hidden;cursor:pointer;font-size:12px;border:1px solid #d3d3d3;padding:10px;display:flex;flex-direction:row;border-radius:3px;margin-bottom:3px;box-shadow:2px 1px rgba(211,211,211,.5);background:#fff}.ione-configurator .thumbnail{width:54px;min-width:54px;height:54px;min-height:54px;border:1px solid #d3d3d3;border-radius:5px}.ione-configurator .img-size{width:54px;min-width:54px;height:54px;min-height:54px;border-radius:5px}.ione-configurator .answer-wrapper{display:block}.ione-configurator .answer-title{font-size:12px;position:relative;overflow:hidden;cursor:pointer}.ione-configurator .question{font-weight:700;color:#1a1a1a}.ione-configurator .answer{font-size:12px;font-style:italic;margin-top:3px}.ione-configurator .collapse-content,.ione-configurator .collapse-wrapper{display:block}.ione-configurator .collapse-handle{position:absolute;top:10px;right:12px;border:solid #000;border-width:0 3px 3px 0;display:inline-block;padding:3px;transform:rotate(45deg);-webkit-transform:rotate(45deg)}.ione-configurator .collapse-handle.expanded{transform:rotate(-135deg);-webkit-transform:rotate(-135deg)}.ione-configurator .child-selection{margin-left:10px;display:flex;flex-direction:column;margin-top:5px}.ione-configurator .mat-title{margin-left:10px;color:#1a1a1a}.ione-configurator .drawer__header{height:48px}.ione-configurator .rp-selections-summary{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;background:0 0;overflow:auto;position:absolute;top:0;right:0;width:400px}.ione-configurator .selections-content{overflow-y:auto}.ione-configurator .co-summary-line{position:relative;overflow:hidden;cursor:pointer;font-size:12px;border:1px solid #d3d3d3;padding:10px;display:flex;flex-direction:row;border-radius:3px;margin-bottom:3px;box-shadow:2px 1px rgba(211,211,211,.5);background:#fff}.ione-configurator .selection-thumbnail{width:54px;min-width:54px;height:54px;min-height:54px;border:1px solid #d3d3d3;border-radius:5px}.ione-configurator .selection-img{width:54px;min-width:54px;height:54px;min-height:54px;border-radius:5px}.ione-configurator .answer-thumbnail{width:54px;min-width:54px;height:54px;min-height:54px;border:1px solid #d3d3d3;border-radius:5px}.ione-configurator .answer-img{width:54px;min-width:54px;height:54px;min-height:54px;border-radius:5px}.ione-configurator .unloaded{background-color:#d3d3d3}.ione-configurator .titles{margin-left:14px;-ms-grid-row-align:center;align-self:center}.ione-configurator .title-wrapper{display:flex;flex-direction:column}.ione-configurator .answer-title-wrapper{text-align:center;-ms-grid-row-align:center;align-self:center;margin-left:14px}"]
|
|
2228
|
+
})
|
|
2229
|
+
], AnswerComponent);
|
|
2230
|
+
return AnswerComponent;
|
|
2231
2231
|
}());
|
|
2232
2232
|
|
|
2233
|
-
var VisibilityObserverMasterDirective = /** @class */ (function () {
|
|
2234
|
-
// I initialize the intersection observer parent directive.
|
|
2235
|
-
function VisibilityObserverMasterDirective() {
|
|
2236
|
-
var _this = this;
|
|
2237
|
-
// As each observable child attaches itself to the parent observer, we need to
|
|
2238
|
-
// map Elements to Callbacks so that when an Element's intersection changes,
|
|
2239
|
-
// we'll know which callback to invoke. For this, we'll use an ES6 Map.
|
|
2240
|
-
this._mapping = new Map();
|
|
2241
|
-
this._observer = new IntersectionObserver(function (entries) {
|
|
2242
|
-
var e_1, _a;
|
|
2243
|
-
try {
|
|
2244
|
-
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
2245
|
-
var entry = entries_1_1.value;
|
|
2246
|
-
var callback = _this._mapping.get(entry.target);
|
|
2247
|
-
if (callback) {
|
|
2248
|
-
callback(entry.isIntersecting);
|
|
2249
|
-
}
|
|
2250
|
-
}
|
|
2251
|
-
}
|
|
2252
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2253
|
-
finally {
|
|
2254
|
-
try {
|
|
2255
|
-
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
|
|
2256
|
-
}
|
|
2257
|
-
finally { if (e_1) throw e_1.error; }
|
|
2258
|
-
}
|
|
2259
|
-
}, {
|
|
2260
|
-
// This classifies the "intersection" as being a bit outside the
|
|
2261
|
-
// viewport. The intent here is give the elements a little time to react
|
|
2262
|
-
// to the change before the element is actually visible to the user.
|
|
2263
|
-
rootMargin: '300px 0px 300px 0px'
|
|
2264
|
-
});
|
|
2265
|
-
}
|
|
2266
|
-
// I get called once when the host element is being destroyed.
|
|
2267
|
-
VisibilityObserverMasterDirective.prototype.ngOnDestroy = function () {
|
|
2268
|
-
this._mapping.clear();
|
|
2269
|
-
this._observer.disconnect();
|
|
2270
|
-
};
|
|
2271
|
-
// ---
|
|
2272
|
-
// PUBLIC METHODS.
|
|
2273
|
-
// ---
|
|
2274
|
-
// I add the given Element for intersection observation. When the intersection status
|
|
2275
|
-
// changes, the given callback is invoked with the new status.
|
|
2276
|
-
VisibilityObserverMasterDirective.prototype.add = function (element, callback) {
|
|
2277
|
-
this._mapping.set(element, callback);
|
|
2278
|
-
this._observer.observe(element);
|
|
2279
|
-
};
|
|
2280
|
-
// I remove the given Element from intersection observation.
|
|
2281
|
-
VisibilityObserverMasterDirective.prototype.remove = function (element) {
|
|
2282
|
-
this._mapping.delete(element);
|
|
2283
|
-
this._observer.unobserve(element);
|
|
2284
|
-
};
|
|
2285
|
-
VisibilityObserverMasterDirective = __decorate([
|
|
2286
|
-
Directive({
|
|
2287
|
-
selector: '[visibilityObserverMaster]'
|
|
2288
|
-
})
|
|
2289
|
-
], VisibilityObserverMasterDirective);
|
|
2290
|
-
return VisibilityObserverMasterDirective;
|
|
2233
|
+
var VisibilityObserverMasterDirective = /** @class */ (function () {
|
|
2234
|
+
// I initialize the intersection observer parent directive.
|
|
2235
|
+
function VisibilityObserverMasterDirective() {
|
|
2236
|
+
var _this = this;
|
|
2237
|
+
// As each observable child attaches itself to the parent observer, we need to
|
|
2238
|
+
// map Elements to Callbacks so that when an Element's intersection changes,
|
|
2239
|
+
// we'll know which callback to invoke. For this, we'll use an ES6 Map.
|
|
2240
|
+
this._mapping = new Map();
|
|
2241
|
+
this._observer = new IntersectionObserver(function (entries) {
|
|
2242
|
+
var e_1, _a;
|
|
2243
|
+
try {
|
|
2244
|
+
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
2245
|
+
var entry = entries_1_1.value;
|
|
2246
|
+
var callback = _this._mapping.get(entry.target);
|
|
2247
|
+
if (callback) {
|
|
2248
|
+
callback(entry.isIntersecting);
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2253
|
+
finally {
|
|
2254
|
+
try {
|
|
2255
|
+
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
|
|
2256
|
+
}
|
|
2257
|
+
finally { if (e_1) throw e_1.error; }
|
|
2258
|
+
}
|
|
2259
|
+
}, {
|
|
2260
|
+
// This classifies the "intersection" as being a bit outside the
|
|
2261
|
+
// viewport. The intent here is give the elements a little time to react
|
|
2262
|
+
// to the change before the element is actually visible to the user.
|
|
2263
|
+
rootMargin: '300px 0px 300px 0px'
|
|
2264
|
+
});
|
|
2265
|
+
}
|
|
2266
|
+
// I get called once when the host element is being destroyed.
|
|
2267
|
+
VisibilityObserverMasterDirective.prototype.ngOnDestroy = function () {
|
|
2268
|
+
this._mapping.clear();
|
|
2269
|
+
this._observer.disconnect();
|
|
2270
|
+
};
|
|
2271
|
+
// ---
|
|
2272
|
+
// PUBLIC METHODS.
|
|
2273
|
+
// ---
|
|
2274
|
+
// I add the given Element for intersection observation. When the intersection status
|
|
2275
|
+
// changes, the given callback is invoked with the new status.
|
|
2276
|
+
VisibilityObserverMasterDirective.prototype.add = function (element, callback) {
|
|
2277
|
+
this._mapping.set(element, callback);
|
|
2278
|
+
this._observer.observe(element);
|
|
2279
|
+
};
|
|
2280
|
+
// I remove the given Element from intersection observation.
|
|
2281
|
+
VisibilityObserverMasterDirective.prototype.remove = function (element) {
|
|
2282
|
+
this._mapping.delete(element);
|
|
2283
|
+
this._observer.unobserve(element);
|
|
2284
|
+
};
|
|
2285
|
+
VisibilityObserverMasterDirective = __decorate([
|
|
2286
|
+
Directive({
|
|
2287
|
+
selector: '[visibilityObserverMaster]'
|
|
2288
|
+
})
|
|
2289
|
+
], VisibilityObserverMasterDirective);
|
|
2290
|
+
return VisibilityObserverMasterDirective;
|
|
2291
2291
|
}());
|
|
2292
2292
|
|
|
2293
|
-
var VisibilityObserverDirective = /** @class */ (function () {
|
|
2294
|
-
// I initialize the intersection observer directive.
|
|
2295
|
-
function VisibilityObserverDirective(parent, elementRef) {
|
|
2296
|
-
this.observerEnabled = false;
|
|
2297
|
-
// These are just some human-friendly constants to make the HTML template a bit more
|
|
2298
|
-
// readable when being consumed as part of SWTCH/CASE statements.
|
|
2299
|
-
this.IS_INTERSECTING = true;
|
|
2300
|
-
this.IS_NOT_INTERSECTING = false;
|
|
2301
|
-
this._parent = parent;
|
|
2302
|
-
this._elementRef = elementRef;
|
|
2303
|
-
// By default, we're going to assume that the host element is NOT intersecting.
|
|
2304
|
-
// Then, we'll use the IntersectionObserver to asynchronously check for changes
|
|
2305
|
-
// in viewport visibility.
|
|
2306
|
-
this.isIntersecting = false;
|
|
2307
|
-
}
|
|
2308
|
-
// ---
|
|
2309
|
-
// PUBLIC METHODS.
|
|
2310
|
-
// ---
|
|
2311
|
-
// I get called once when the host element is being destroyed.
|
|
2312
|
-
VisibilityObserverDirective.prototype.ngOnDestroy = function () {
|
|
2313
|
-
this._parent.remove(this._elementRef.nativeElement);
|
|
2314
|
-
this._elementRef = undefined;
|
|
2315
|
-
};
|
|
2316
|
-
// I get called once after the inputs have been bound for the first time.
|
|
2317
|
-
VisibilityObserverDirective.prototype.ngOnInit = function () {
|
|
2318
|
-
var _this = this;
|
|
2319
|
-
// In this demo, instead of using an IntersectionObserver per Element, we're
|
|
2320
|
-
// going to use a shared observer in the parent element. However, we're still
|
|
2321
|
-
// going to use a CALLBACK style approach so that we're only reducing the number
|
|
2322
|
-
// of IntersectionObserver instances, not the number of Function calls.
|
|
2323
|
-
if (this.observerEnabled) {
|
|
2324
|
-
this._parent.add(this._elementRef.nativeElement, function (isIntersecting) {
|
|
2325
|
-
_this.isIntersecting = isIntersecting;
|
|
2326
|
-
if (_this.isIntersecting) {
|
|
2327
|
-
_this._parent.remove(_this._elementRef.nativeElement);
|
|
2328
|
-
}
|
|
2329
|
-
});
|
|
2330
|
-
}
|
|
2331
|
-
};
|
|
2332
|
-
VisibilityObserverDirective.ctorParameters = function () { return [
|
|
2333
|
-
{ type: VisibilityObserverMasterDirective },
|
|
2334
|
-
{ type: ElementRef }
|
|
2335
|
-
]; };
|
|
2336
|
-
__decorate([
|
|
2337
|
-
Input()
|
|
2338
|
-
], VisibilityObserverDirective.prototype, "observerEnabled", void 0);
|
|
2339
|
-
VisibilityObserverDirective = __decorate([
|
|
2340
|
-
Directive({
|
|
2341
|
-
selector: '[visibilityObserver]',
|
|
2342
|
-
exportAs: 'intersection'
|
|
2343
|
-
})
|
|
2344
|
-
], VisibilityObserverDirective);
|
|
2345
|
-
return VisibilityObserverDirective;
|
|
2293
|
+
var VisibilityObserverDirective = /** @class */ (function () {
|
|
2294
|
+
// I initialize the intersection observer directive.
|
|
2295
|
+
function VisibilityObserverDirective(parent, elementRef) {
|
|
2296
|
+
this.observerEnabled = false;
|
|
2297
|
+
// These are just some human-friendly constants to make the HTML template a bit more
|
|
2298
|
+
// readable when being consumed as part of SWTCH/CASE statements.
|
|
2299
|
+
this.IS_INTERSECTING = true;
|
|
2300
|
+
this.IS_NOT_INTERSECTING = false;
|
|
2301
|
+
this._parent = parent;
|
|
2302
|
+
this._elementRef = elementRef;
|
|
2303
|
+
// By default, we're going to assume that the host element is NOT intersecting.
|
|
2304
|
+
// Then, we'll use the IntersectionObserver to asynchronously check for changes
|
|
2305
|
+
// in viewport visibility.
|
|
2306
|
+
this.isIntersecting = false;
|
|
2307
|
+
}
|
|
2308
|
+
// ---
|
|
2309
|
+
// PUBLIC METHODS.
|
|
2310
|
+
// ---
|
|
2311
|
+
// I get called once when the host element is being destroyed.
|
|
2312
|
+
VisibilityObserverDirective.prototype.ngOnDestroy = function () {
|
|
2313
|
+
this._parent.remove(this._elementRef.nativeElement);
|
|
2314
|
+
this._elementRef = undefined;
|
|
2315
|
+
};
|
|
2316
|
+
// I get called once after the inputs have been bound for the first time.
|
|
2317
|
+
VisibilityObserverDirective.prototype.ngOnInit = function () {
|
|
2318
|
+
var _this = this;
|
|
2319
|
+
// In this demo, instead of using an IntersectionObserver per Element, we're
|
|
2320
|
+
// going to use a shared observer in the parent element. However, we're still
|
|
2321
|
+
// going to use a CALLBACK style approach so that we're only reducing the number
|
|
2322
|
+
// of IntersectionObserver instances, not the number of Function calls.
|
|
2323
|
+
if (this.observerEnabled) {
|
|
2324
|
+
this._parent.add(this._elementRef.nativeElement, function (isIntersecting) {
|
|
2325
|
+
_this.isIntersecting = isIntersecting;
|
|
2326
|
+
if (_this.isIntersecting) {
|
|
2327
|
+
_this._parent.remove(_this._elementRef.nativeElement);
|
|
2328
|
+
}
|
|
2329
|
+
});
|
|
2330
|
+
}
|
|
2331
|
+
};
|
|
2332
|
+
VisibilityObserverDirective.ctorParameters = function () { return [
|
|
2333
|
+
{ type: VisibilityObserverMasterDirective },
|
|
2334
|
+
{ type: ElementRef }
|
|
2335
|
+
]; };
|
|
2336
|
+
__decorate([
|
|
2337
|
+
Input()
|
|
2338
|
+
], VisibilityObserverDirective.prototype, "observerEnabled", void 0);
|
|
2339
|
+
VisibilityObserverDirective = __decorate([
|
|
2340
|
+
Directive({
|
|
2341
|
+
selector: '[visibilityObserver]',
|
|
2342
|
+
exportAs: 'intersection'
|
|
2343
|
+
})
|
|
2344
|
+
], VisibilityObserverDirective);
|
|
2345
|
+
return VisibilityObserverDirective;
|
|
2346
2346
|
}());
|
|
2347
2347
|
|
|
2348
|
-
var LoaderComponent = /** @class */ (function () {
|
|
2349
|
-
function LoaderComponent() {
|
|
2350
|
-
}
|
|
2351
|
-
LoaderComponent = __decorate([
|
|
2352
|
-
Component({
|
|
2353
|
-
selector: 'rp-loader',
|
|
2354
|
-
template: "\n <div class=\"loader-wrapper\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"44\" height=\"44\" viewBox=\"0 0 44 44\" stroke=\"#3760a1\">\n <g fill=\"none\" fill-rule=\"evenodd\" stroke-width=\"3\">\n <circle class=\"ripple1\" cx=\"22\" cy=\"22\" r=\"19\">\n </circle>\n <circle class=\"ripple2\" cx=\"22\" cy=\"22\" r=\"19\">\n </circle>\n </g>\n </svg>\n </div>\n ",
|
|
2355
|
-
styles: [":host{-webkit-user-select:none;-moz-user-select:none;-ms-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;-webkit-animation:1.5s infinite ripple;animation:1.5s infinite ripple}:host .loader-wrapper svg .ripple2{transform-origin:center;-webkit-animation:1.5s .4s infinite ripple;animation:1.5s .4s infinite ripple}@-webkit-keyframes ripple{0%{transform:scale(0);opacity:1}100%{transform:scale(1);opacity:0}}@keyframes ripple{0%{transform:scale(0);opacity:1}100%{transform:scale(1);opacity:0}}"]
|
|
2356
|
-
})
|
|
2357
|
-
], LoaderComponent);
|
|
2358
|
-
return LoaderComponent;
|
|
2348
|
+
var LoaderComponent = /** @class */ (function () {
|
|
2349
|
+
function LoaderComponent() {
|
|
2350
|
+
}
|
|
2351
|
+
LoaderComponent = __decorate([
|
|
2352
|
+
Component({
|
|
2353
|
+
selector: 'rp-loader',
|
|
2354
|
+
template: "\n <div class=\"loader-wrapper\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"44\" height=\"44\" viewBox=\"0 0 44 44\" stroke=\"#3760a1\">\n <g fill=\"none\" fill-rule=\"evenodd\" stroke-width=\"3\">\n <circle class=\"ripple1\" cx=\"22\" cy=\"22\" r=\"19\">\n </circle>\n <circle class=\"ripple2\" cx=\"22\" cy=\"22\" r=\"19\">\n </circle>\n </g>\n </svg>\n </div>\n ",
|
|
2355
|
+
styles: [":host{-webkit-user-select:none;-moz-user-select:none;-ms-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;-webkit-animation:1.5s infinite ripple;animation:1.5s infinite ripple}:host .loader-wrapper svg .ripple2{transform-origin:center;-webkit-animation:1.5s .4s infinite ripple;animation:1.5s .4s infinite ripple}@-webkit-keyframes ripple{0%{transform:scale(0);opacity:1}100%{transform:scale(1);opacity:0}}@keyframes ripple{0%{transform:scale(0);opacity:1}100%{transform:scale(1);opacity:0}}"]
|
|
2356
|
+
})
|
|
2357
|
+
], LoaderComponent);
|
|
2358
|
+
return LoaderComponent;
|
|
2359
2359
|
}());
|
|
2360
2360
|
|
|
2361
|
-
var SharedModule = /** @class */ (function () {
|
|
2362
|
-
function SharedModule() {
|
|
2363
|
-
}
|
|
2364
|
-
SharedModule = __decorate([
|
|
2365
|
-
NgModule({
|
|
2366
|
-
imports: [
|
|
2367
|
-
CommonModule
|
|
2368
|
-
],
|
|
2369
|
-
declarations: [
|
|
2370
|
-
LoaderComponent
|
|
2371
|
-
],
|
|
2372
|
-
exports: [
|
|
2373
|
-
LoaderComponent
|
|
2374
|
-
]
|
|
2375
|
-
})
|
|
2376
|
-
], SharedModule);
|
|
2377
|
-
return SharedModule;
|
|
2361
|
+
var SharedModule = /** @class */ (function () {
|
|
2362
|
+
function SharedModule() {
|
|
2363
|
+
}
|
|
2364
|
+
SharedModule = __decorate([
|
|
2365
|
+
NgModule({
|
|
2366
|
+
imports: [
|
|
2367
|
+
CommonModule
|
|
2368
|
+
],
|
|
2369
|
+
declarations: [
|
|
2370
|
+
LoaderComponent
|
|
2371
|
+
],
|
|
2372
|
+
exports: [
|
|
2373
|
+
LoaderComponent
|
|
2374
|
+
]
|
|
2375
|
+
})
|
|
2376
|
+
], SharedModule);
|
|
2377
|
+
return SharedModule;
|
|
2378
2378
|
}());
|
|
2379
2379
|
|
|
2380
|
-
var AnswersModule = /** @class */ (function () {
|
|
2381
|
-
function AnswersModule() {
|
|
2382
|
-
}
|
|
2383
|
-
AnswersModule = __decorate([
|
|
2384
|
-
NgModule({
|
|
2385
|
-
imports: [
|
|
2386
|
-
CommonModule,
|
|
2387
|
-
SharedModule
|
|
2388
|
-
],
|
|
2389
|
-
declarations: [
|
|
2390
|
-
AnswersComponent,
|
|
2391
|
-
AnswerComponent,
|
|
2392
|
-
VisibilityObserverDirective,
|
|
2393
|
-
VisibilityObserverMasterDirective
|
|
2394
|
-
],
|
|
2395
|
-
exports: [
|
|
2396
|
-
AnswersComponent
|
|
2397
|
-
]
|
|
2398
|
-
})
|
|
2399
|
-
], AnswersModule);
|
|
2400
|
-
return AnswersModule;
|
|
2380
|
+
var AnswersModule = /** @class */ (function () {
|
|
2381
|
+
function AnswersModule() {
|
|
2382
|
+
}
|
|
2383
|
+
AnswersModule = __decorate([
|
|
2384
|
+
NgModule({
|
|
2385
|
+
imports: [
|
|
2386
|
+
CommonModule,
|
|
2387
|
+
SharedModule
|
|
2388
|
+
],
|
|
2389
|
+
declarations: [
|
|
2390
|
+
AnswersComponent,
|
|
2391
|
+
AnswerComponent,
|
|
2392
|
+
VisibilityObserverDirective,
|
|
2393
|
+
VisibilityObserverMasterDirective
|
|
2394
|
+
],
|
|
2395
|
+
exports: [
|
|
2396
|
+
AnswersComponent
|
|
2397
|
+
]
|
|
2398
|
+
})
|
|
2399
|
+
], AnswersModule);
|
|
2400
|
+
return AnswersModule;
|
|
2401
2401
|
}());
|
|
2402
2402
|
|
|
2403
|
-
var SelectionViewModel = /** @class */ (function () {
|
|
2404
|
-
function SelectionViewModel() {
|
|
2405
|
-
this.children = [];
|
|
2406
|
-
this.expanded = false;
|
|
2407
|
-
this.thumbnail = '';
|
|
2408
|
-
}
|
|
2409
|
-
return SelectionViewModel;
|
|
2410
|
-
}());
|
|
2411
|
-
var SelectionsComponent = /** @class */ (function () {
|
|
2412
|
-
function SelectionsComponent(_imageCacheService) {
|
|
2413
|
-
this._imageCacheService = _imageCacheService;
|
|
2414
|
-
this.selectionViewModels = [];
|
|
2415
|
-
this.selectionClick = new EventEmitter();
|
|
2416
|
-
}
|
|
2417
|
-
Object.defineProperty(SelectionsComponent.prototype, "selections", {
|
|
2418
|
-
set: function (value) {
|
|
2419
|
-
this._prepareSelections(value);
|
|
2420
|
-
this._loadThumbnails();
|
|
2421
|
-
},
|
|
2422
|
-
enumerable: true,
|
|
2423
|
-
configurable: true
|
|
2424
|
-
});
|
|
2425
|
-
SelectionsComponent.prototype.ngOnInit = function () {
|
|
2426
|
-
};
|
|
2427
|
-
SelectionsComponent.prototype.expandClicked = function (selectionViewModel, mouseEvent) {
|
|
2428
|
-
mouseEvent.preventDefault();
|
|
2429
|
-
mouseEvent.stopImmediatePropagation();
|
|
2430
|
-
selectionViewModel.expanded = !selectionViewModel.expanded;
|
|
2431
|
-
};
|
|
2432
|
-
SelectionsComponent.prototype.selectSelection = function (selection, mouseEvent) {
|
|
2433
|
-
mouseEvent.preventDefault();
|
|
2434
|
-
mouseEvent.stopImmediatePropagation();
|
|
2435
|
-
this.selectionClick.next(selection);
|
|
2436
|
-
};
|
|
2437
|
-
SelectionsComponent.prototype._loadThumbnails = function () {
|
|
2438
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2439
|
-
var _this = this;
|
|
2440
|
-
return __generator(this, function (_a) {
|
|
2441
|
-
if (this.selectionViewModels.length > 0) {
|
|
2442
|
-
this.selectionViewModels.forEach(function (viewModel) { return __awaiter(_this, void 0, void 0, function () {
|
|
2443
|
-
return __generator(this, function (_a) {
|
|
2444
|
-
switch (_a.label) {
|
|
2445
|
-
case 0: return [4 /*yield*/, this._imageCacheService.getImageForSelectionOrAnswer(viewModel.selection).then(function (imageSrc) {
|
|
2446
|
-
viewModel.thumbnail = imageSrc === "" ? null : imageSrc;
|
|
2447
|
-
})];
|
|
2448
|
-
case 1:
|
|
2449
|
-
_a.sent();
|
|
2450
|
-
return [2 /*return*/];
|
|
2451
|
-
}
|
|
2452
|
-
});
|
|
2453
|
-
}); });
|
|
2454
|
-
}
|
|
2455
|
-
return [2 /*return*/];
|
|
2456
|
-
});
|
|
2457
|
-
});
|
|
2458
|
-
};
|
|
2459
|
-
SelectionsComponent.prototype._prepareSelections = function (value) {
|
|
2460
|
-
var _this = this;
|
|
2461
|
-
this.selectionViewModels.length = 0;
|
|
2462
|
-
var selectionViewModel;
|
|
2463
|
-
value.forEach(function (s) {
|
|
2464
|
-
if (s.presentationLevel === 1) {
|
|
2465
|
-
selectionViewModel = new SelectionViewModel();
|
|
2466
|
-
selectionViewModel.selection = s;
|
|
2467
|
-
_this.selectionViewModels.push(selectionViewModel);
|
|
2468
|
-
}
|
|
2469
|
-
else if (s.presentationLevel > 1) {
|
|
2470
|
-
if (selectionViewModel) {
|
|
2471
|
-
selectionViewModel.children.push(s);
|
|
2472
|
-
}
|
|
2473
|
-
}
|
|
2474
|
-
});
|
|
2475
|
-
};
|
|
2476
|
-
SelectionsComponent.ctorParameters = function () { return [
|
|
2477
|
-
{ type: ImageCacheService }
|
|
2478
|
-
]; };
|
|
2479
|
-
__decorate([
|
|
2480
|
-
Input()
|
|
2481
|
-
], SelectionsComponent.prototype, "selections", null);
|
|
2482
|
-
__decorate([
|
|
2483
|
-
Output()
|
|
2484
|
-
], SelectionsComponent.prototype, "selectionClick", void 0);
|
|
2485
|
-
SelectionsComponent = __decorate([
|
|
2486
|
-
Component({
|
|
2487
|
-
selector: "selections",
|
|
2488
|
-
template: "\n <
|
|
2489
|
-
animations: [
|
|
2490
|
-
trigger('showHideChildren', [
|
|
2491
|
-
state('void', style({ 'height': '0' })),
|
|
2492
|
-
state('*', style({ 'height': '*' })),
|
|
2493
|
-
transition('void <=> *', animate(200))
|
|
2494
|
-
])
|
|
2495
|
-
],
|
|
2496
|
-
styles: ["
|
|
2497
|
-
})
|
|
2498
|
-
], SelectionsComponent);
|
|
2499
|
-
return SelectionsComponent;
|
|
2403
|
+
var SelectionViewModel = /** @class */ (function () {
|
|
2404
|
+
function SelectionViewModel() {
|
|
2405
|
+
this.children = [];
|
|
2406
|
+
this.expanded = false;
|
|
2407
|
+
this.thumbnail = '';
|
|
2408
|
+
}
|
|
2409
|
+
return SelectionViewModel;
|
|
2410
|
+
}());
|
|
2411
|
+
var SelectionsComponent = /** @class */ (function () {
|
|
2412
|
+
function SelectionsComponent(_imageCacheService) {
|
|
2413
|
+
this._imageCacheService = _imageCacheService;
|
|
2414
|
+
this.selectionViewModels = [];
|
|
2415
|
+
this.selectionClick = new EventEmitter();
|
|
2416
|
+
}
|
|
2417
|
+
Object.defineProperty(SelectionsComponent.prototype, "selections", {
|
|
2418
|
+
set: function (value) {
|
|
2419
|
+
this._prepareSelections(value);
|
|
2420
|
+
this._loadThumbnails();
|
|
2421
|
+
},
|
|
2422
|
+
enumerable: true,
|
|
2423
|
+
configurable: true
|
|
2424
|
+
});
|
|
2425
|
+
SelectionsComponent.prototype.ngOnInit = function () {
|
|
2426
|
+
};
|
|
2427
|
+
SelectionsComponent.prototype.expandClicked = function (selectionViewModel, mouseEvent) {
|
|
2428
|
+
mouseEvent.preventDefault();
|
|
2429
|
+
mouseEvent.stopImmediatePropagation();
|
|
2430
|
+
selectionViewModel.expanded = !selectionViewModel.expanded;
|
|
2431
|
+
};
|
|
2432
|
+
SelectionsComponent.prototype.selectSelection = function (selection, mouseEvent) {
|
|
2433
|
+
mouseEvent.preventDefault();
|
|
2434
|
+
mouseEvent.stopImmediatePropagation();
|
|
2435
|
+
this.selectionClick.next(selection);
|
|
2436
|
+
};
|
|
2437
|
+
SelectionsComponent.prototype._loadThumbnails = function () {
|
|
2438
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2439
|
+
var _this = this;
|
|
2440
|
+
return __generator(this, function (_a) {
|
|
2441
|
+
if (this.selectionViewModels.length > 0) {
|
|
2442
|
+
this.selectionViewModels.forEach(function (viewModel) { return __awaiter(_this, void 0, void 0, function () {
|
|
2443
|
+
return __generator(this, function (_a) {
|
|
2444
|
+
switch (_a.label) {
|
|
2445
|
+
case 0: return [4 /*yield*/, this._imageCacheService.getImageForSelectionOrAnswer(viewModel.selection).then(function (imageSrc) {
|
|
2446
|
+
viewModel.thumbnail = imageSrc === "" ? null : imageSrc;
|
|
2447
|
+
})];
|
|
2448
|
+
case 1:
|
|
2449
|
+
_a.sent();
|
|
2450
|
+
return [2 /*return*/];
|
|
2451
|
+
}
|
|
2452
|
+
});
|
|
2453
|
+
}); });
|
|
2454
|
+
}
|
|
2455
|
+
return [2 /*return*/];
|
|
2456
|
+
});
|
|
2457
|
+
});
|
|
2458
|
+
};
|
|
2459
|
+
SelectionsComponent.prototype._prepareSelections = function (value) {
|
|
2460
|
+
var _this = this;
|
|
2461
|
+
this.selectionViewModels.length = 0;
|
|
2462
|
+
var selectionViewModel;
|
|
2463
|
+
value.forEach(function (s) {
|
|
2464
|
+
if (s.presentationLevel === 1) {
|
|
2465
|
+
selectionViewModel = new SelectionViewModel();
|
|
2466
|
+
selectionViewModel.selection = s;
|
|
2467
|
+
_this.selectionViewModels.push(selectionViewModel);
|
|
2468
|
+
}
|
|
2469
|
+
else if (s.presentationLevel > 1) {
|
|
2470
|
+
if (selectionViewModel) {
|
|
2471
|
+
selectionViewModel.children.push(s);
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
});
|
|
2475
|
+
};
|
|
2476
|
+
SelectionsComponent.ctorParameters = function () { return [
|
|
2477
|
+
{ type: ImageCacheService }
|
|
2478
|
+
]; };
|
|
2479
|
+
__decorate([
|
|
2480
|
+
Input()
|
|
2481
|
+
], SelectionsComponent.prototype, "selections", null);
|
|
2482
|
+
__decorate([
|
|
2483
|
+
Output()
|
|
2484
|
+
], SelectionsComponent.prototype, "selectionClick", void 0);
|
|
2485
|
+
SelectionsComponent = __decorate([
|
|
2486
|
+
Component({
|
|
2487
|
+
selector: "selections",
|
|
2488
|
+
template: "\n <div class=\"ione-configurator\">\n <div class=\"rp-selections-summary\">\n <header class=\"drawer__header\">\n <h2 class=\"mat-title\" [textContent]=\"'Configuratie'\"></h2>\n <!--<button>-->\n <!---->\n <!--</button>-->\n </header>\n <div class=\"selections-content\">\n <ng-container *ngFor=\"let selectionViewModel of selectionViewModels\">\n\n <div class=\"co-summary-line\" (click)=\"selectSelection(selectionViewModel.selection, $event)\">\n <div class=\"selection-thumbnail\">\n <rp-loader *ngIf=\"selectionViewModel.thumbnail === ''\"></rp-loader>\n <img visibilityObserver *ngIf=\"selectionViewModel.thumbnail !== '' && selectionViewModel.thumbnail !== null\" class=\"selection-img\" [src]=\"selectionViewModel.thumbnail\">\n </div>\n <div class=\"titles\">\n <div class=\"title-wrapper\">\n <label class=\"question\" [textContent]=\"selectionViewModel.selection.question\"></label>\n <span class=\"answer\" [textContent]=\"selectionViewModel.selection.answer\"></span>\n <div *ngIf=\"selectionViewModel.children.length > 0 && selectionViewModel.expanded\" @showHideChildren>\n <div class=\"child-selection\" *ngFor=\"let selection of selectionViewModel.children\"\n (click)=\"selectSelection(selection, $event)\"\n >\n <label class=\"question\" [textContent]=\"selection.commercialQuestion\"></label>\n <span class=\"answer\" [textContent]=\"selection.answer\"></span>\n </div>\n </div>\n </div>\n </div>\n \n <div class=\"price-wrapper\">\n <span class=\"price-value\"></span>\n </div>\n\n <div class=\"collapse-wrapper\">\n <div class=\"collapse-content\">\n <div class=\"collapse-handle\" [class.expanded]=\"selectionViewModel.expanded\"\n *ngIf=\"selectionViewModel.children.length > 0\" (click)=\"expandClicked(selectionViewModel, $event)\"></div>\n </div>\n </div>\n </div>\n\n </ng-container>\n </div>\n </div>\n </div>\n ",
|
|
2489
|
+
animations: [
|
|
2490
|
+
trigger('showHideChildren', [
|
|
2491
|
+
state('void', style({ 'height': '0' })),
|
|
2492
|
+
state('*', style({ 'height': '*' })),
|
|
2493
|
+
transition('void <=> *', animate(200))
|
|
2494
|
+
])
|
|
2495
|
+
],
|
|
2496
|
+
styles: [".ione-configurator .rp-answers-slideout{position:absolute;top:0;right:0;width:400px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}.ione-configurator .answers-title{margin-left:10px;color:#1a1a1a}.ione-configurator .answers-container{height:100vh;overflow-y:scroll}.ione-configurator .answer-content{position:relative;overflow:hidden;cursor:pointer;font-size:12px;border:1px solid #d3d3d3;padding:10px;display:flex;flex-direction:row;border-radius:3px;margin-bottom:3px;box-shadow:2px 1px rgba(211,211,211,.5);background:#fff}.ione-configurator .thumbnail{width:54px;min-width:54px;height:54px;min-height:54px;border:1px solid #d3d3d3;border-radius:5px}.ione-configurator .img-size{width:54px;min-width:54px;height:54px;min-height:54px;border-radius:5px}.ione-configurator .answer-wrapper{display:block}.ione-configurator .answer-title{font-size:12px;position:relative;overflow:hidden;cursor:pointer}.ione-configurator .question{font-weight:700;color:#1a1a1a}.ione-configurator .answer{font-size:12px;font-style:italic;margin-top:3px}.ione-configurator .collapse-content,.ione-configurator .collapse-wrapper{display:block}.ione-configurator .collapse-handle{position:absolute;top:10px;right:12px;border:solid #000;border-width:0 3px 3px 0;display:inline-block;padding:3px;transform:rotate(45deg);-webkit-transform:rotate(45deg)}.ione-configurator .collapse-handle.expanded{transform:rotate(-135deg);-webkit-transform:rotate(-135deg)}.ione-configurator .child-selection{margin-left:10px;display:flex;flex-direction:column;margin-top:5px}.ione-configurator .mat-title{margin-left:10px;color:#1a1a1a}.ione-configurator .drawer__header{height:48px}.ione-configurator .rp-selections-summary{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;background:0 0;overflow:auto;position:absolute;top:0;right:0;width:400px}.ione-configurator .selections-content{overflow-y:auto}.ione-configurator .co-summary-line{position:relative;overflow:hidden;cursor:pointer;font-size:12px;border:1px solid #d3d3d3;padding:10px;display:flex;flex-direction:row;border-radius:3px;margin-bottom:3px;box-shadow:2px 1px rgba(211,211,211,.5);background:#fff}.ione-configurator .selection-thumbnail{width:54px;min-width:54px;height:54px;min-height:54px;border:1px solid #d3d3d3;border-radius:5px}.ione-configurator .selection-img{width:54px;min-width:54px;height:54px;min-height:54px;border-radius:5px}.ione-configurator .answer-thumbnail{width:54px;min-width:54px;height:54px;min-height:54px;border:1px solid #d3d3d3;border-radius:5px}.ione-configurator .answer-img{width:54px;min-width:54px;height:54px;min-height:54px;border-radius:5px}.ione-configurator .unloaded{background-color:#d3d3d3}.ione-configurator .titles{margin-left:14px;-ms-grid-row-align:center;align-self:center}.ione-configurator .title-wrapper{display:flex;flex-direction:column}.ione-configurator .answer-title-wrapper{text-align:center;-ms-grid-row-align:center;align-self:center;margin-left:14px}"]
|
|
2497
|
+
})
|
|
2498
|
+
], SelectionsComponent);
|
|
2499
|
+
return SelectionsComponent;
|
|
2500
2500
|
}());
|
|
2501
2501
|
|
|
2502
|
-
var SelectionsModule = /** @class */ (function () {
|
|
2503
|
-
function SelectionsModule() {
|
|
2504
|
-
}
|
|
2505
|
-
SelectionsModule = __decorate([
|
|
2506
|
-
NgModule({
|
|
2507
|
-
imports: [
|
|
2508
|
-
CommonModule,
|
|
2509
|
-
SharedModule
|
|
2510
|
-
],
|
|
2511
|
-
declarations: [
|
|
2512
|
-
SelectionsComponent
|
|
2513
|
-
],
|
|
2514
|
-
exports: [
|
|
2515
|
-
SelectionsComponent
|
|
2516
|
-
]
|
|
2517
|
-
})
|
|
2518
|
-
], SelectionsModule);
|
|
2519
|
-
return SelectionsModule;
|
|
2502
|
+
var SelectionsModule = /** @class */ (function () {
|
|
2503
|
+
function SelectionsModule() {
|
|
2504
|
+
}
|
|
2505
|
+
SelectionsModule = __decorate([
|
|
2506
|
+
NgModule({
|
|
2507
|
+
imports: [
|
|
2508
|
+
CommonModule,
|
|
2509
|
+
SharedModule
|
|
2510
|
+
],
|
|
2511
|
+
declarations: [
|
|
2512
|
+
SelectionsComponent
|
|
2513
|
+
],
|
|
2514
|
+
exports: [
|
|
2515
|
+
SelectionsComponent
|
|
2516
|
+
]
|
|
2517
|
+
})
|
|
2518
|
+
], SelectionsModule);
|
|
2519
|
+
return SelectionsModule;
|
|
2520
2520
|
}());
|
|
2521
2521
|
|
|
2522
|
-
/**
|
|
2523
|
-
* Generated bundle index. Do not edit.
|
|
2522
|
+
/**
|
|
2523
|
+
* Generated bundle index. Do not edit.
|
|
2524
2524
|
*/
|
|
2525
2525
|
|
|
2526
2526
|
export { AnswersComponent, AnswersModule, Builder, ConfiguratorService, SelectionsComponent, SelectionsModule, SharedModule as ɵa, LoaderComponent as ɵb, AnswerComponent as ɵc, ImageCacheService as ɵd, VisibilityObserverDirective as ɵe, VisibilityObserverMasterDirective as ɵf };
|