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