@colijnit/configurator 261.1.0 → 261.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/fesm2022/colijnit-configurator.mjs +19553 -0
  2. package/fesm2022/colijnit-configurator.mjs.map +1 -0
  3. package/index.d.ts +3301 -0
  4. package/lib/components/answer-card/style/_layout.scss +88 -0
  5. package/lib/components/answer-card/style/_material-definition.scss +3 -0
  6. package/lib/components/answer-card/style/_theme.scss +67 -0
  7. package/lib/components/answer-card/style/material.scss +2 -0
  8. package/lib/components/answer-info-dialog/style/_layout.scss +88 -0
  9. package/lib/components/answer-info-dialog/style/_material-definition.scss +3 -0
  10. package/lib/components/answer-info-dialog/style/_theme.scss +44 -0
  11. package/lib/components/answer-info-dialog/style/material.scss +3 -0
  12. package/lib/components/answers-slideout/style/_layout.scss +199 -0
  13. package/lib/components/answers-slideout/style/_material-definition.scss +3 -0
  14. package/lib/components/answers-slideout/style/_theme.scss +54 -0
  15. package/lib/components/answers-slideout/style/material.scss +3 -0
  16. package/lib/components/color-filter/style/_layout.scss +41 -0
  17. package/lib/components/color-filter/style/_material-definition.scss +3 -0
  18. package/lib/components/color-filter/style/_theme.scss +7 -0
  19. package/lib/components/color-filter/style/material.scss +3 -0
  20. package/lib/components/configurator/style/_layout.scss +7 -0
  21. package/lib/components/configurator/style/_material-definition.scss +3 -0
  22. package/lib/components/configurator/style/_theme.scss +7 -0
  23. package/lib/components/configurator/style/material.scss +3 -0
  24. package/lib/components/configurator-dialog/style/_layout.scss +129 -0
  25. package/lib/components/configurator-dialog/style/_material-definition.scss +4 -0
  26. package/lib/components/configurator-dialog/style/_theme.scss +89 -0
  27. package/lib/components/configurator-dialog/style/material.scss +3 -0
  28. package/lib/components/configurator-loader/style/_layout.scss +72 -0
  29. package/lib/components/configurator-loader/style/_material-definition.scss +5 -0
  30. package/lib/components/configurator-loader/style/_theme.scss +26 -0
  31. package/lib/components/configurator-loader/style/material.scss +14 -0
  32. package/lib/components/configurator-scene/style/_layout.scss +22 -0
  33. package/lib/components/configurator-scene/style/_material-definition.scss +3 -0
  34. package/lib/components/configurator-scene/style/_theme.scss +7 -0
  35. package/lib/components/configurator-scene/style/material.scss +3 -0
  36. package/lib/components/configurator-scene-loader/style/_layout.scss +72 -0
  37. package/lib/components/configurator-scene-loader/style/_material-definition.scss +5 -0
  38. package/lib/components/configurator-scene-loader/style/_theme.scss +26 -0
  39. package/lib/components/configurator-scene-loader/style/material.scss +14 -0
  40. package/lib/components/element-buttons/style/_layout.scss +52 -0
  41. package/lib/components/element-buttons/style/_material-definition.scss +3 -0
  42. package/lib/components/element-buttons/style/_theme.scss +23 -0
  43. package/lib/components/element-buttons/style/material.scss +3 -0
  44. package/lib/components/element-toolbar/element-toolbar.component.scss +59 -0
  45. package/lib/components/element-toolbar/style/_layout.scss +107 -0
  46. package/lib/components/element-toolbar/style/_material-definition.scss +3 -0
  47. package/lib/components/element-toolbar/style/_theme.scss +47 -0
  48. package/lib/components/element-toolbar/style/material.scss +3 -0
  49. package/lib/components/image-zoom/style/_layout.scss +51 -0
  50. package/lib/components/image-zoom/style/_material-definition.scss +3 -0
  51. package/lib/components/image-zoom/style/_theme.scss +17 -0
  52. package/lib/components/image-zoom/style/material.scss +3 -0
  53. package/lib/components/lite-selector/style/_layout.scss +21 -0
  54. package/lib/components/lite-selector/style/_material-definition.scss +3 -0
  55. package/lib/components/lite-selector/style/_theme.scss +7 -0
  56. package/lib/components/lite-selector/style/material.scss +3 -0
  57. package/lib/components/product-configurator/style/_layout.scss +46 -0
  58. package/lib/components/product-configurator/style/_material-definition.scss +3 -0
  59. package/lib/components/product-configurator/style/_theme.scss +22 -0
  60. package/lib/components/product-configurator/style/material.scss +3 -0
  61. package/lib/components/product-configurator-selector/style/_layout.scss +145 -0
  62. package/lib/components/product-configurator-selector/style/_material-definition.scss +3 -0
  63. package/lib/components/product-configurator-selector/style/_theme.scss +57 -0
  64. package/lib/components/product-configurator-selector/style/material.scss +3 -0
  65. package/lib/components/product-configurator-selector-option/style/_layout.scss +7 -0
  66. package/lib/components/product-configurator-selector-option/style/_material-definition.scss +3 -0
  67. package/lib/components/product-configurator-selector-option/style/_theme.scss +7 -0
  68. package/lib/components/product-configurator-selector-option/style/material.scss +3 -0
  69. package/lib/components/product-configurator-selector-option-button/style/_layout.scss +28 -0
  70. package/lib/components/product-configurator-selector-option-button/style/_material-definition.scss +3 -0
  71. package/lib/components/product-configurator-selector-option-button/style/_theme.scss +33 -0
  72. package/lib/components/product-configurator-selector-option-button/style/material.scss +3 -0
  73. package/lib/components/product-configurator-selector-option-checkbox/style/_layout.scss +28 -0
  74. package/lib/components/product-configurator-selector-option-checkbox/style/_material-definition.scss +3 -0
  75. package/lib/components/product-configurator-selector-option-checkbox/style/_theme.scss +27 -0
  76. package/lib/components/product-configurator-selector-option-checkbox/style/material.scss +3 -0
  77. package/lib/components/product-configurator-selector-option-dropdown/style/_layout.scss +34 -0
  78. package/lib/components/product-configurator-selector-option-dropdown/style/_material-definition.scss +3 -0
  79. package/lib/components/product-configurator-selector-option-dropdown/style/_theme.scss +28 -0
  80. package/lib/components/product-configurator-selector-option-dropdown/style/material.scss +3 -0
  81. package/lib/components/product-configurator-selector-option-tile/style/_layout.scss +58 -0
  82. package/lib/components/product-configurator-selector-option-tile/style/_material-definition.scss +3 -0
  83. package/lib/components/product-configurator-selector-option-tile/style/_theme.scss +56 -0
  84. package/lib/components/product-configurator-selector-option-tile/style/material.scss +3 -0
  85. package/lib/components/progress-bar/progress-bar.component.scss +14 -0
  86. package/lib/components/progress-bar/style/_layout.scss +18 -0
  87. package/lib/components/progress-bar/style/_material-definition.scss +3 -0
  88. package/lib/components/progress-bar/style/_theme.scss +10 -0
  89. package/lib/components/progress-bar/style/material.scss +3 -0
  90. package/lib/components/scene-options/style/_layout.scss +52 -0
  91. package/lib/components/scene-options/style/_material-definition.scss +3 -0
  92. package/lib/components/scene-options/style/_theme.scss +7 -0
  93. package/lib/components/scene-options/style/material.scss +3 -0
  94. package/lib/components/selections-summary/style/_layout.scss +87 -0
  95. package/lib/components/selections-summary/style/_material-definition.scss +5 -0
  96. package/lib/components/selections-summary/style/_theme.scss +13 -0
  97. package/lib/components/selections-summary/style/material.scss +3 -0
  98. package/lib/components/selections-summary-line/style/_layout.scss +12 -0
  99. package/lib/components/selections-summary-line/style/_material-definition.scss +4 -0
  100. package/lib/components/selections-summary-line/style/_theme.scss +12 -0
  101. package/lib/components/selections-summary-line/style/material.scss +3 -0
  102. package/lib/components/slideout/style/_layout.scss +27 -0
  103. package/lib/components/slideout/style/_material-definition.scss +3 -0
  104. package/lib/components/slideout/style/_theme.scss +5 -0
  105. package/lib/components/slideout/style/material.scss +3 -0
  106. package/lib/components/summary-line/style/_layout.scss +137 -0
  107. package/lib/components/summary-line/style/_material-definition.scss +4 -0
  108. package/lib/components/summary-line/style/_theme.scss +56 -0
  109. package/lib/components/summary-line/style/material.scss +3 -0
  110. package/lib/components/tag-filter/style/_layout.scss +14 -0
  111. package/lib/components/tag-filter/style/_material-definition.scss +3 -0
  112. package/lib/components/tag-filter/style/_theme.scss +7 -0
  113. package/lib/components/tag-filter/style/material.scss +3 -0
  114. package/lib/components/threedselector/style/_layout.scss +32 -0
  115. package/lib/components/threedselector/style/_material-definition.scss +3 -0
  116. package/lib/components/threedselector/style/_theme.scss +7 -0
  117. package/lib/components/threedselector/style/material.scss +9 -0
  118. package/lib/style/_mixin.scss +9 -0
  119. package/lib/style/configurator-globals.scss +21 -0
  120. package/lib/style/template_variables.scss +37 -0
  121. package/package.json +27 -36
  122. package/README.md +0 -28
  123. package/app/builder.d.ts +0 -75
  124. package/app/components/answers/answer/answer.component.d.ts +0 -11
  125. package/app/components/answers/answers.component.d.ts +0 -8
  126. package/app/components/answers/answers.module.d.ts +0 -2
  127. package/app/components/selections/selections.component.d.ts +0 -21
  128. package/app/components/selections/selections.module.d.ts +0 -2
  129. package/app/components/shared/loader/loader.component.d.ts +0 -2
  130. package/app/components/shared/shared.module.d.ts +0 -2
  131. package/app/directives/visibility-observer-master.directive.d.ts +0 -9
  132. package/app/directives/visibility-observer.directive.d.ts +0 -13
  133. package/app/services/configurator.service.d.ts +0 -19
  134. package/app/services/image-cache.service.d.ts +0 -10
  135. package/app/utils/object.utils.d.ts +0 -7
  136. package/bundles/colijnit-configurator.umd.js +0 -3993
  137. package/bundles/colijnit-configurator.umd.js.map +0 -1
  138. package/colijnit-configurator.d.ts +0 -9
  139. package/colijnit-configurator.metadata.json +0 -1
  140. package/esm2015/app/builder.js +0 -710
  141. package/esm2015/app/components/answers/answer/answer.component.js +0 -66
  142. package/esm2015/app/components/answers/answers.component.js +0 -38
  143. package/esm2015/app/components/answers/answers.module.js +0 -27
  144. package/esm2015/app/components/selections/selections.component.js +0 -129
  145. package/esm2015/app/components/selections/selections.module.js +0 -21
  146. package/esm2015/app/components/shared/loader/loader.component.js +0 -22
  147. package/esm2015/app/components/shared/shared.module.js +0 -19
  148. package/esm2015/app/directives/visibility-observer-master.directive.js +0 -50
  149. package/esm2015/app/directives/visibility-observer.directive.js +0 -55
  150. package/esm2015/app/services/configurator.service.js +0 -79
  151. package/esm2015/app/services/image-cache.service.js +0 -63
  152. package/esm2015/app/utils/object.utils.js +0 -51
  153. package/esm2015/colijnit-configurator.js +0 -10
  154. package/esm2015/helper/variation-helper.js +0 -549
  155. package/esm2015/model/material.js +0 -11
  156. package/esm2015/model/variation-settings.js +0 -54
  157. package/esm2015/model/variation.js +0 -3
  158. package/esm2015/public_api.js +0 -7
  159. package/esm2015/utils/asset.utils.js +0 -124
  160. package/esm2015/utils/base-utils.js +0 -9
  161. package/esm2015/utils/file.utils.js +0 -142
  162. package/esm2015/utils/image.utils.js +0 -66
  163. package/esm2015/utils/object.utils.js +0 -49
  164. package/esm2015/utils/scene-utils.js +0 -187
  165. package/esm2015/utils/threed.utils.js +0 -226
  166. package/esm2015/utils/variation-utils.js +0 -388
  167. package/fesm2015/colijnit-configurator.js +0 -2878
  168. package/fesm2015/colijnit-configurator.js.map +0 -1
  169. package/helper/variation-helper.d.ts +0 -25
  170. package/model/material.d.ts +0 -40
  171. package/model/variation-settings.d.ts +0 -54
  172. package/model/variation.d.ts +0 -10
  173. package/public_api.d.ts +0 -6
  174. package/utils/asset.utils.d.ts +0 -19
  175. package/utils/base-utils.d.ts +0 -4
  176. package/utils/file.utils.d.ts +0 -27
  177. package/utils/image.utils.d.ts +0 -10
  178. package/utils/object.utils.d.ts +0 -7
  179. package/utils/scene-utils.d.ts +0 -7
  180. package/utils/threed.utils.d.ts +0 -16
  181. package/utils/variation-utils.d.ts +0 -16
@@ -1,3993 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three'), require('@colijnit/configuratorapi/build/model/deco-node'), require('@colijnit/configuratorapi/build/model/selection'), require('@colijnit/configuratorapi/build/enum/deco-node-type.enum'), require('@colijnit/configuratorapi/build/enum/deco-node-kind.enum'), require('rxjs'), require('jszip'), require('rxjs/operators'), require('@colijnit/configuratorapi/build/model/article'), 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('@angular/core'), require('@colijnit/ioneconnector/build/service/business-object-factory'), require('@angular/common'), require('@angular/animations')) :
3
- typeof define === 'function' && define.amd ? define('@colijnit/configurator', ['exports', 'three', '@colijnit/configuratorapi/build/model/deco-node', '@colijnit/configuratorapi/build/model/selection', '@colijnit/configuratorapi/build/enum/deco-node-type.enum', '@colijnit/configuratorapi/build/enum/deco-node-kind.enum', 'rxjs', 'jszip', 'rxjs/operators', '@colijnit/configuratorapi/build/model/article', '@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', '@angular/core', '@colijnit/ioneconnector/build/service/business-object-factory', '@angular/common', '@angular/animations'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.colijnit = global.colijnit || {}, global.colijnit.configurator = {}), global.THREE, global.decoNode, global.selection, global.decoNodeType_enum, global.decoNodeKind_enum, global.rxjs, global.JSZip, global.rxjs.operators, global.article, global.configurator, global.notNill_function, global.nodeType_enum, global.isNill_function, global.ng.core, global.businessObjectFactory, global.ng.common, global.ng.animations));
5
- })(this, (function (exports, THREE, decoNode, selection, decoNodeType_enum, decoNodeKind_enum, rxjs, JSZip, operators, article, configurator, notNill_function, nodeType_enum, isNill_function, i0, businessObjectFactory, common, animations) { 'use strict';
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () { return e[k]; }
19
- });
20
- }
21
- });
22
- }
23
- n["default"] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
28
- var JSZip__default = /*#__PURE__*/_interopDefaultLegacy(JSZip);
29
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
30
-
31
- /******************************************************************************
32
- Copyright (c) Microsoft Corporation.
33
-
34
- Permission to use, copy, modify, and/or distribute this software for any
35
- purpose with or without fee is hereby granted.
36
-
37
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
38
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
39
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
40
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
41
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
42
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
43
- PERFORMANCE OF THIS SOFTWARE.
44
- ***************************************************************************** */
45
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
46
- var extendStatics = function (d, b) {
47
- extendStatics = Object.setPrototypeOf ||
48
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
49
- function (d, b) { for (var p in b)
50
- if (Object.prototype.hasOwnProperty.call(b, p))
51
- d[p] = b[p]; };
52
- return extendStatics(d, b);
53
- };
54
- function __extends(d, b) {
55
- if (typeof b !== "function" && b !== null)
56
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
57
- extendStatics(d, b);
58
- function __() { this.constructor = d; }
59
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
60
- }
61
- var __assign = function () {
62
- __assign = Object.assign || function __assign(t) {
63
- for (var s, i = 1, n = arguments.length; i < n; i++) {
64
- s = arguments[i];
65
- for (var p in s)
66
- if (Object.prototype.hasOwnProperty.call(s, p))
67
- t[p] = s[p];
68
- }
69
- return t;
70
- };
71
- return __assign.apply(this, arguments);
72
- };
73
- function __rest(s, e) {
74
- var t = {};
75
- for (var p in s)
76
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
77
- t[p] = s[p];
78
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
79
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
80
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
81
- t[p[i]] = s[p[i]];
82
- }
83
- return t;
84
- }
85
- function __decorate(decorators, target, key, desc) {
86
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
87
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
88
- r = Reflect.decorate(decorators, target, key, desc);
89
- else
90
- for (var i = decorators.length - 1; i >= 0; i--)
91
- if (d = decorators[i])
92
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
93
- return c > 3 && r && Object.defineProperty(target, key, r), r;
94
- }
95
- function __param(paramIndex, decorator) {
96
- return function (target, key) { decorator(target, key, paramIndex); };
97
- }
98
- function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
99
- function accept(f) { if (f !== void 0 && typeof f !== "function")
100
- throw new TypeError("Function expected"); return f; }
101
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
102
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
103
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
104
- var _, done = false;
105
- for (var i = decorators.length - 1; i >= 0; i--) {
106
- var context = {};
107
- for (var p in contextIn)
108
- context[p] = p === "access" ? {} : contextIn[p];
109
- for (var p in contextIn.access)
110
- context.access[p] = contextIn.access[p];
111
- context.addInitializer = function (f) { if (done)
112
- throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
113
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
114
- if (kind === "accessor") {
115
- if (result === void 0)
116
- continue;
117
- if (result === null || typeof result !== "object")
118
- throw new TypeError("Object expected");
119
- if (_ = accept(result.get))
120
- descriptor.get = _;
121
- if (_ = accept(result.set))
122
- descriptor.set = _;
123
- if (_ = accept(result.init))
124
- initializers.unshift(_);
125
- }
126
- else if (_ = accept(result)) {
127
- if (kind === "field")
128
- initializers.unshift(_);
129
- else
130
- descriptor[key] = _;
131
- }
132
- }
133
- if (target)
134
- Object.defineProperty(target, contextIn.name, descriptor);
135
- done = true;
136
- }
137
- ;
138
- function __runInitializers(thisArg, initializers, value) {
139
- var useValue = arguments.length > 2;
140
- for (var i = 0; i < initializers.length; i++) {
141
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
142
- }
143
- return useValue ? value : void 0;
144
- }
145
- ;
146
- function __propKey(x) {
147
- return typeof x === "symbol" ? x : "".concat(x);
148
- }
149
- ;
150
- function __setFunctionName(f, name, prefix) {
151
- if (typeof name === "symbol")
152
- name = name.description ? "[".concat(name.description, "]") : "";
153
- return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
154
- }
155
- ;
156
- function __metadata(metadataKey, metadataValue) {
157
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
158
- return Reflect.metadata(metadataKey, metadataValue);
159
- }
160
- function __awaiter(thisArg, _arguments, P, generator) {
161
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
162
- return new (P || (P = Promise))(function (resolve, reject) {
163
- function fulfilled(value) { try {
164
- step(generator.next(value));
165
- }
166
- catch (e) {
167
- reject(e);
168
- } }
169
- function rejected(value) { try {
170
- step(generator["throw"](value));
171
- }
172
- catch (e) {
173
- reject(e);
174
- } }
175
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
176
- step((generator = generator.apply(thisArg, _arguments || [])).next());
177
- });
178
- }
179
- function __generator(thisArg, body) {
180
- var _ = { label: 0, sent: function () { if (t[0] & 1)
181
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
182
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
183
- function verb(n) { return function (v) { return step([n, v]); }; }
184
- function step(op) {
185
- if (f)
186
- throw new TypeError("Generator is already executing.");
187
- while (g && (g = 0, op[0] && (_ = 0)), _)
188
- try {
189
- 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)
190
- return t;
191
- if (y = 0, t)
192
- op = [op[0] & 2, t.value];
193
- switch (op[0]) {
194
- case 0:
195
- case 1:
196
- t = op;
197
- break;
198
- case 4:
199
- _.label++;
200
- return { value: op[1], done: false };
201
- case 5:
202
- _.label++;
203
- y = op[1];
204
- op = [0];
205
- continue;
206
- case 7:
207
- op = _.ops.pop();
208
- _.trys.pop();
209
- continue;
210
- default:
211
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
212
- _ = 0;
213
- continue;
214
- }
215
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
216
- _.label = op[1];
217
- break;
218
- }
219
- if (op[0] === 6 && _.label < t[1]) {
220
- _.label = t[1];
221
- t = op;
222
- break;
223
- }
224
- if (t && _.label < t[2]) {
225
- _.label = t[2];
226
- _.ops.push(op);
227
- break;
228
- }
229
- if (t[2])
230
- _.ops.pop();
231
- _.trys.pop();
232
- continue;
233
- }
234
- op = body.call(thisArg, _);
235
- }
236
- catch (e) {
237
- op = [6, e];
238
- y = 0;
239
- }
240
- finally {
241
- f = t = 0;
242
- }
243
- if (op[0] & 5)
244
- throw op[1];
245
- return { value: op[0] ? op[1] : void 0, done: true };
246
- }
247
- }
248
- var __createBinding = Object.create ? (function (o, m, k, k2) {
249
- if (k2 === undefined)
250
- k2 = k;
251
- var desc = Object.getOwnPropertyDescriptor(m, k);
252
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
253
- desc = { enumerable: true, get: function () { return m[k]; } };
254
- }
255
- Object.defineProperty(o, k2, desc);
256
- }) : (function (o, m, k, k2) {
257
- if (k2 === undefined)
258
- k2 = k;
259
- o[k2] = m[k];
260
- });
261
- function __exportStar(m, o) {
262
- for (var p in m)
263
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
264
- __createBinding(o, m, p);
265
- }
266
- function __values(o) {
267
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
268
- if (m)
269
- return m.call(o);
270
- if (o && typeof o.length === "number")
271
- return {
272
- next: function () {
273
- if (o && i >= o.length)
274
- o = void 0;
275
- return { value: o && o[i++], done: !o };
276
- }
277
- };
278
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
279
- }
280
- function __read(o, n) {
281
- var m = typeof Symbol === "function" && o[Symbol.iterator];
282
- if (!m)
283
- return o;
284
- var i = m.call(o), r, ar = [], e;
285
- try {
286
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
287
- ar.push(r.value);
288
- }
289
- catch (error) {
290
- e = { error: error };
291
- }
292
- finally {
293
- try {
294
- if (r && !r.done && (m = i["return"]))
295
- m.call(i);
296
- }
297
- finally {
298
- if (e)
299
- throw e.error;
300
- }
301
- }
302
- return ar;
303
- }
304
- /** @deprecated */
305
- function __spread() {
306
- for (var ar = [], i = 0; i < arguments.length; i++)
307
- ar = ar.concat(__read(arguments[i]));
308
- return ar;
309
- }
310
- /** @deprecated */
311
- function __spreadArrays() {
312
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
313
- s += arguments[i].length;
314
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
315
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
316
- r[k] = a[j];
317
- return r;
318
- }
319
- function __spreadArray(to, from, pack) {
320
- if (pack || arguments.length === 2)
321
- for (var i = 0, l = from.length, ar; i < l; i++) {
322
- if (ar || !(i in from)) {
323
- if (!ar)
324
- ar = Array.prototype.slice.call(from, 0, i);
325
- ar[i] = from[i];
326
- }
327
- }
328
- return to.concat(ar || Array.prototype.slice.call(from));
329
- }
330
- function __await(v) {
331
- return this instanceof __await ? (this.v = v, this) : new __await(v);
332
- }
333
- function __asyncGenerator(thisArg, _arguments, generator) {
334
- if (!Symbol.asyncIterator)
335
- throw new TypeError("Symbol.asyncIterator is not defined.");
336
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
337
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
338
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
339
- function verb(n, f) { if (g[n]) {
340
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); };
341
- if (f)
342
- i[n] = f(i[n]);
343
- } }
344
- function resume(n, v) { try {
345
- step(g[n](v));
346
- }
347
- catch (e) {
348
- settle(q[0][3], e);
349
- } }
350
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
351
- function fulfill(value) { resume("next", value); }
352
- function reject(value) { resume("throw", value); }
353
- function settle(f, v) { if (f(v), q.shift(), q.length)
354
- resume(q[0][0], q[0][1]); }
355
- }
356
- function __asyncDelegator(o) {
357
- var i, p;
358
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
359
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
360
- }
361
- function __asyncValues(o) {
362
- if (!Symbol.asyncIterator)
363
- throw new TypeError("Symbol.asyncIterator is not defined.");
364
- var m = o[Symbol.asyncIterator], i;
365
- 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);
366
- 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); }); }; }
367
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
368
- }
369
- function __makeTemplateObject(cooked, raw) {
370
- if (Object.defineProperty) {
371
- Object.defineProperty(cooked, "raw", { value: raw });
372
- }
373
- else {
374
- cooked.raw = raw;
375
- }
376
- return cooked;
377
- }
378
- ;
379
- var __setModuleDefault = Object.create ? (function (o, v) {
380
- Object.defineProperty(o, "default", { enumerable: true, value: v });
381
- }) : function (o, v) {
382
- o["default"] = v;
383
- };
384
- var ownKeys = function (o) {
385
- ownKeys = Object.getOwnPropertyNames || function (o) {
386
- var ar = [];
387
- for (var k in o)
388
- if (Object.prototype.hasOwnProperty.call(o, k))
389
- ar[ar.length] = k;
390
- return ar;
391
- };
392
- return ownKeys(o);
393
- };
394
- function __importStar(mod) {
395
- if (mod && mod.__esModule)
396
- return mod;
397
- var result = {};
398
- if (mod != null)
399
- for (var k = ownKeys(mod), i = 0; i < k.length; i++)
400
- if (k[i] !== "default")
401
- __createBinding(result, mod, k[i]);
402
- __setModuleDefault(result, mod);
403
- return result;
404
- }
405
- function __importDefault(mod) {
406
- return (mod && mod.__esModule) ? mod : { default: mod };
407
- }
408
- function __classPrivateFieldGet(receiver, state, kind, f) {
409
- if (kind === "a" && !f)
410
- throw new TypeError("Private accessor was defined without a getter");
411
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
412
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
413
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
414
- }
415
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
416
- if (kind === "m")
417
- throw new TypeError("Private method is not writable");
418
- if (kind === "a" && !f)
419
- throw new TypeError("Private accessor was defined without a setter");
420
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
421
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
422
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
423
- }
424
- function __classPrivateFieldIn(state, receiver) {
425
- if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
426
- throw new TypeError("Cannot use 'in' operator on non-object");
427
- return typeof state === "function" ? receiver === state : state.has(receiver);
428
- }
429
- function __addDisposableResource(env, value, async) {
430
- if (value !== null && value !== void 0) {
431
- if (typeof value !== "object" && typeof value !== "function")
432
- throw new TypeError("Object expected.");
433
- var dispose, inner;
434
- if (async) {
435
- if (!Symbol.asyncDispose)
436
- throw new TypeError("Symbol.asyncDispose is not defined.");
437
- dispose = value[Symbol.asyncDispose];
438
- }
439
- if (dispose === void 0) {
440
- if (!Symbol.dispose)
441
- throw new TypeError("Symbol.dispose is not defined.");
442
- dispose = value[Symbol.dispose];
443
- if (async)
444
- inner = dispose;
445
- }
446
- if (typeof dispose !== "function")
447
- throw new TypeError("Object not disposable.");
448
- if (inner)
449
- dispose = function () { try {
450
- inner.call(this);
451
- }
452
- catch (e) {
453
- return Promise.reject(e);
454
- } };
455
- env.stack.push({ value: value, dispose: dispose, async: async });
456
- }
457
- else if (async) {
458
- env.stack.push({ async: true });
459
- }
460
- return value;
461
- }
462
- var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
463
- var e = new Error(message);
464
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
465
- };
466
- function __disposeResources(env) {
467
- function fail(e) {
468
- env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
469
- env.hasError = true;
470
- }
471
- var r, s = 0;
472
- function next() {
473
- while (r = env.stack.pop()) {
474
- try {
475
- if (!r.async && s === 1)
476
- return s = 0, env.stack.push(r), Promise.resolve().then(next);
477
- if (r.dispose) {
478
- var result = r.dispose.call(r.value);
479
- if (r.async)
480
- return s |= 2, Promise.resolve(result).then(next, function (e) { fail(e); return next(); });
481
- }
482
- else
483
- s |= 1;
484
- }
485
- catch (e) {
486
- fail(e);
487
- }
488
- }
489
- if (s === 1)
490
- return env.hasError ? Promise.reject(env.error) : Promise.resolve();
491
- if (env.hasError)
492
- throw env.error;
493
- }
494
- return next();
495
- }
496
- function __rewriteRelativeImportExtension(path, preserveJsx) {
497
- if (typeof path === "string" && /^\.\.?\//.test(path)) {
498
- return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
499
- return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
500
- });
501
- }
502
- return path;
503
- }
504
- var tslib_es6 = {
505
- __extends: __extends,
506
- __assign: __assign,
507
- __rest: __rest,
508
- __decorate: __decorate,
509
- __param: __param,
510
- __esDecorate: __esDecorate,
511
- __runInitializers: __runInitializers,
512
- __propKey: __propKey,
513
- __setFunctionName: __setFunctionName,
514
- __metadata: __metadata,
515
- __awaiter: __awaiter,
516
- __generator: __generator,
517
- __createBinding: __createBinding,
518
- __exportStar: __exportStar,
519
- __values: __values,
520
- __read: __read,
521
- __spread: __spread,
522
- __spreadArrays: __spreadArrays,
523
- __spreadArray: __spreadArray,
524
- __await: __await,
525
- __asyncGenerator: __asyncGenerator,
526
- __asyncDelegator: __asyncDelegator,
527
- __asyncValues: __asyncValues,
528
- __makeTemplateObject: __makeTemplateObject,
529
- __importStar: __importStar,
530
- __importDefault: __importDefault,
531
- __classPrivateFieldGet: __classPrivateFieldGet,
532
- __classPrivateFieldSet: __classPrivateFieldSet,
533
- __classPrivateFieldIn: __classPrivateFieldIn,
534
- __addDisposableResource: __addDisposableResource,
535
- __disposeResources: __disposeResources,
536
- __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,
537
- };
538
-
539
- var ObjectUtils$1 = /** @class */ (function () {
540
- function ObjectUtils() {
541
- }
542
- ObjectUtils.DisposeMaterial = function (material) {
543
- var _this = this;
544
- if (!material) {
545
- return;
546
- }
547
- if (Array.isArray(material)) {
548
- material.forEach(function (mtrl) {
549
- _this.materialProps
550
- .filter(function (mapType) { return mtrl[mapType]; })
551
- .forEach(function (mapType) { return mtrl[mapType].dispose(); });
552
- mtrl.dispose();
553
- });
554
- }
555
- else {
556
- this.materialProps
557
- .filter(function (mapType) { return material[mapType] && material[mapType].dispose; })
558
- .forEach(function (mapType) { return material[mapType].dispose(); });
559
- if (material.dispose) {
560
- material.dispose();
561
- }
562
- }
563
- };
564
- ObjectUtils.DisposeObject = function (object) {
565
- var _this = this;
566
- if (!object) {
567
- return;
568
- }
569
- if (object.children.length) {
570
- object.children.forEach(function (child) { return _this.DisposeObject(child); });
571
- }
572
- this.DisposeNode(object);
573
- };
574
- ObjectUtils.DisposeNode = function (node) {
575
- var _this = this;
576
- node.traverse(function (obj) {
577
- if (obj instanceof THREE.Mesh) {
578
- if (obj.geometry) {
579
- obj.geometry.dispose();
580
- }
581
- _this.DisposeMaterial(obj.material);
582
- }
583
- if (typeof obj.dispose === 'function') {
584
- // @ts-ignore
585
- obj.dispose();
586
- }
587
- });
588
- };
589
- return ObjectUtils;
590
- }());
591
- ObjectUtils$1.materialProps = ['map', 'lightMap', 'bumpMap', 'normalMap', 'specularMap', 'envMap', 'aoMap', 'roughnessMap', 'metalnessMap'];
592
-
593
- var ThreedUtils = /** @class */ (function () {
594
- function ThreedUtils() {
595
- this._objectCache = new Map();
596
- }
597
- ThreedUtils.prototype.clearCache = function () {
598
- var objs = Array.from(this._objectCache.values());
599
- objs.forEach(function (o) { return ObjectUtils$1.DisposeObject(o); });
600
- this._objectCache.clear();
601
- };
602
- ThreedUtils.prototype.download3DSource = function (fileName, setVisibleFalse) {
603
- var _this = this;
604
- if (setVisibleFalse === void 0) { setVisibleFalse = true; }
605
- return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
606
- var lookupFileName;
607
- var _this = this;
608
- return __generator(this, function (_a) {
609
- fileName = fileName.replace('.unity3d', '');
610
- lookupFileName = fileName + (fileName.indexOf('.glb') < 0 ? '.glb' : '');
611
- if (this._objectCache.has(lookupFileName)) {
612
- resolve(this._objectCache.get(lookupFileName));
613
- return [2 /*return*/];
614
- }
615
- this.loadGlbSource(lookupFileName, setVisibleFalse)
616
- .then(function (obj) {
617
- _this._objectCache.set(lookupFileName, obj);
618
- resolve(obj);
619
- })
620
- .catch(function () {
621
- reject("GLB source not found! (" + lookupFileName + ")");
622
- });
623
- return [2 /*return*/];
624
- });
625
- }); });
626
- };
627
- ThreedUtils.prototype.readFileAsText = function (file) {
628
- var fileReader = new FileReader();
629
- return new Promise(function (resolve, reject) {
630
- fileReader.onload = function (e) { return resolve(e.target.result); };
631
- fileReader.onerror = function (error) { return reject(error); };
632
- fileReader.readAsText(file);
633
- });
634
- };
635
- ThreedUtils.prototype.loadJsonModel = function (filePath) {
636
- return __awaiter(this, void 0, void 0, function () {
637
- var json, loader;
638
- var _this = this;
639
- return __generator(this, function (_a) {
640
- switch (_a.label) {
641
- case 0:
642
- if (this._objectCache.has(filePath)) {
643
- return [2 /*return*/, Promise.resolve(this._objectCache.get(filePath))];
644
- }
645
- return [4 /*yield*/, this._readJsonFile(filePath)];
646
- case 1:
647
- json = _a.sent();
648
- loader = new THREE__namespace.ObjectLoader();
649
- loader.crossOrigin = 'Anonymous';
650
- return [2 /*return*/, new Promise(function (resolve, reject) {
651
- try {
652
- var obj = loader.parse(json);
653
- _this._objectCache.set(filePath, obj);
654
- resolve(obj);
655
- }
656
- catch (e) {
657
- reject(null);
658
- }
659
- })];
660
- }
661
- });
662
- });
663
- };
664
- ThreedUtils.prototype.loadJsonObjectModel = function (filePath) {
665
- return __awaiter(this, void 0, void 0, function () {
666
- var loader;
667
- var _this = this;
668
- return __generator(this, function (_a) {
669
- if (this._objectCache.has(filePath)) {
670
- return [2 /*return*/, Promise.resolve(this._objectCache.get(filePath))];
671
- }
672
- loader = new THREE__namespace.ObjectLoader();
673
- loader.setCrossOrigin('Anonymous');
674
- loader.setResourcePath('');
675
- return [2 /*return*/, new Promise(function (resolve, reject) {
676
- loader.load(filePath, function (object) {
677
- var obj = (object.type === 'Scene' && object.children[0].type === 'Object3D') ? object.children[0] : object;
678
- _this._objectCache.set(filePath, obj);
679
- resolve(obj);
680
- }, function (xhr) { return null; }, function (error) { return reject(error); });
681
- })];
682
- });
683
- });
684
- };
685
- ThreedUtils.prototype.loadGlbModel = function (file, cleanUp) {
686
- if (cleanUp === void 0) { cleanUp = true; }
687
- return __awaiter(this, void 0, void 0, function () {
688
- var obj;
689
- return __generator(this, function (_a) {
690
- switch (_a.label) {
691
- case 0:
692
- if (this._objectCache.has(file)) {
693
- return [2 /*return*/, Promise.resolve(this._objectCache.get(file))];
694
- }
695
- if (!window.hasOwnProperty('loadGLTF')) {
696
- console.error('loadGLTF not defined in window global');
697
- return [2 /*return*/, null];
698
- }
699
- return [4 /*yield*/, window.loadGLTF(file)];
700
- case 1:
701
- obj = _a.sent();
702
- if (obj) {
703
- this._cleanedUpObjects(obj, cleanUp);
704
- this._objectCache.set(file, obj);
705
- return [2 /*return*/, obj];
706
- }
707
- else {
708
- return [2 /*return*/, null];
709
- }
710
- return [2 /*return*/];
711
- }
712
- });
713
- });
714
- };
715
- ThreedUtils.prototype.loadGlbSource = function (file, setVisibleFalse) {
716
- if (setVisibleFalse === void 0) { setVisibleFalse = true; }
717
- return __awaiter(this, void 0, void 0, function () {
718
- var obj, children, name, parent;
719
- return __generator(this, function (_a) {
720
- switch (_a.label) {
721
- case 0: return [4 /*yield*/, this.loadGlbModel(file, false)];
722
- case 1:
723
- obj = _a.sent();
724
- if (obj) {
725
- obj.children = obj.children.filter(function (c) { return !(c instanceof THREE__namespace.Camera || (c.constructor.name && c.constructor.name.toLowerCase().indexOf('camera') > -1)); });
726
- obj.children.sort(function (a, b) { return a['name'] < b['name'] ? 1 : -1; });
727
- obj.children.forEach(function (c) {
728
- c.traverse(function (t) {
729
- t.visible = !t.name.toLowerCase().startsWith('c_');
730
- });
731
- if (setVisibleFalse) {
732
- c.visible = false;
733
- }
734
- });
735
- if (obj.children.length === 1 && (obj.children[0] instanceof THREE__namespace.Group || obj.children[0].constructor.name === 'Group')) { // flatten children
736
- children = obj.children[0].children.slice();
737
- name = obj.children[0].name;
738
- obj.children.length = 0;
739
- parent = new THREE__namespace.Object3D();
740
- parent.name = name;
741
- parent.children = children;
742
- obj.add(parent);
743
- }
744
- }
745
- return [2 /*return*/, obj];
746
- }
747
- });
748
- });
749
- };
750
- ThreedUtils.prototype.textureFromUrl = function (url) {
751
- return __awaiter(this, void 0, void 0, function () {
752
- return __generator(this, function (_a) {
753
- // url = this._includeBaseUrl(url);
754
- return [2 /*return*/, new Promise(function (resolve, reject) {
755
- var textureLoader = new THREE__namespace.TextureLoader();
756
- // textureLoader.setBaseU(this._settingsService.settings.assetPath);
757
- textureLoader.load(url, function (texture) {
758
- texture.wrapT = THREE__namespace.RepeatWrapping;
759
- texture.wrapS = THREE__namespace.RepeatWrapping;
760
- texture.repeat.set(1, 1);
761
- texture.needsUpdate = true;
762
- return resolve(texture);
763
- }, null, reject);
764
- })];
765
- });
766
- });
767
- };
768
- ThreedUtils.prototype._cleanedUpObjects = function (object, cleanUp) {
769
- var _this = this;
770
- if (cleanUp === void 0) { cleanUp = true; }
771
- var obj = new THREE__namespace.Object3D();
772
- object.children.forEach(function (c) {
773
- if (!(c instanceof THREE__namespace.Camera || (c.constructor.name && c.constructor.name.toLowerCase().indexOf('camera') > -1))) {
774
- if (cleanUp && (c instanceof THREE__namespace.Group || c.constructor.name === 'Group') || (c.children.length === 1 && (c.children[0] instanceof THREE__namespace.Group || c.children[0].constructor.name === 'Group'))) {
775
- _this._addGroupChildrenToObject(c, obj);
776
- }
777
- else if ((cleanUp && !(c instanceof THREE__namespace.Mesh || c.constructor.name === 'Mesh')) || (!(c instanceof THREE__namespace.Mesh || c.constructor.name === 'Mesh') && !c.name && c.children.length > 0)) {
778
- c.children.forEach(function (child) {
779
- child.translateY(c.position.y);
780
- });
781
- c.translateY(-c.position.y);
782
- if (obj.children.length > 0) {
783
- obj.add(c.clone());
784
- }
785
- else {
786
- obj = c.clone();
787
- }
788
- }
789
- else {
790
- // if (c.position.y > 0 || c.position.y < 0) {
791
- // c.children.forEach((child) => {
792
- // child.translateY(c.position.y);
793
- // });
794
- // c.translateY(-c.position.y);
795
- // }
796
- obj.add(c.clone());
797
- }
798
- }
799
- });
800
- var boundingBox = new THREE__namespace.Box3().setFromObject(obj);
801
- var bbCenterPivot = new THREE__namespace.Vector3();
802
- boundingBox.getCenter(bbCenterPivot);
803
- var delta = new THREE__namespace.Vector3().add(bbCenterPivot).negate();
804
- obj.children.forEach(function (cc) {
805
- cc.position.add(delta);
806
- });
807
- return obj;
808
- };
809
- ThreedUtils.prototype._addGroupChildrenToObject = function (group, obj, cleanUp) {
810
- var _this = this;
811
- if (cleanUp === void 0) { cleanUp = true; }
812
- group.children.forEach(function (gc) {
813
- if (cleanUp && (gc instanceof THREE__namespace.Group || gc.constructor.name === 'Group')) {
814
- _this._addGroupChildrenToObject(gc, obj);
815
- }
816
- else {
817
- // gc.translateX(-group.position.x);
818
- gc.translateY(group.position.y);
819
- // gc.translateZ(-group.position.z);
820
- obj.add(gc.clone());
821
- }
822
- });
823
- };
824
- ThreedUtils.prototype._iterateChildren = function (children, callback) {
825
- for (var i = 0; i < children.length; i++) {
826
- var child = children[i];
827
- if (child instanceof THREE__namespace.Mesh || child.constructor.name === 'Mesh') {
828
- callback(child);
829
- }
830
- else {
831
- this._iterateChildren(child.children, callback);
832
- }
833
- }
834
- };
835
- ThreedUtils.prototype._readJsonFile = function (filePath) {
836
- return __awaiter(this, void 0, void 0, function () {
837
- var response, empty_1, e_1;
838
- return __generator(this, function (_a) {
839
- switch (_a.label) {
840
- case 0:
841
- _a.trys.push([0, 5, , 6]);
842
- return [4 /*yield*/, fetch(filePath)];
843
- case 1:
844
- response = _a.sent();
845
- if (!!response.ok) return [3 /*break*/, 2];
846
- return [2 /*return*/, ''];
847
- case 2:
848
- empty_1 = false;
849
- return [4 /*yield*/, response.clone().text().then(function (value) {
850
- if (value === '') {
851
- empty_1 = true;
852
- }
853
- })];
854
- case 3:
855
- _a.sent();
856
- return [2 /*return*/, empty_1 ? {} : response.json()];
857
- case 4: return [3 /*break*/, 6];
858
- case 5:
859
- e_1 = _a.sent();
860
- return [2 /*return*/, ''];
861
- case 6: return [2 /*return*/];
862
- }
863
- });
864
- });
865
- };
866
- return ThreedUtils;
867
- }());
868
-
869
- var SceneUtils = /** @class */ (function () {
870
- function SceneUtils() {
871
- }
872
- SceneUtils.TrySelectorConnection = function (scene, parent, part1, part2, isFirstElement, createAddableFn) {
873
- var addable;
874
- if (createAddableFn) {
875
- addable = part2;
876
- part2 = createAddableFn(addable);
877
- }
878
- if (part1 && part2) {
879
- var con1 = void 0;
880
- var con2 = void 0;
881
- // if part2 is an addable and decoConnection is present, then no need to iterate through connectors
882
- if (addable && addable instanceof selection.Selection && addable.decoConnection) {
883
- con1 = part1.children.find(function (c) { return c.name === addable.decoConnection; });
884
- if (!con1) {
885
- return false;
886
- }
887
- for (var ii = 0; ii < part2.children.length; ii++) {
888
- con2 = part2.children[ii];
889
- // if these connectors can connect connect them
890
- if (!con1['connected'] && !con2['connected'] && this.CanSelectorConnect(part1.children, con1, con2, isFirstElement)) {
891
- // if addable, continue this loop with a new addable
892
- if (addable) {
893
- var newPart2 = createAddableFn(addable, part2, part1);
894
- // reference of part2 changed, so refresh con2
895
- this.SelectorConnect(scene, parent, con1, newPart2.children[ii]);
896
- }
897
- else {
898
- return this.SelectorConnect(scene, parent, con1, con2);
899
- }
900
- }
901
- }
902
- }
903
- else {
904
- for (var i = 0; i < part1.children.length; i++) {
905
- for (var ii = 0; ii < part2.children.length; ii++) {
906
- con1 = part1.children[i];
907
- con2 = part2.children[ii];
908
- // if these connectors can connect connect them
909
- if (!con1['connected'] && !con2['connected'] && this.CanSelectorConnect(part1.children, con1, con2, isFirstElement)) {
910
- // if addable, continue this loop with a new addable
911
- if (addable) {
912
- var newPart2 = createAddableFn(addable, part2, part1);
913
- // reference of part2 changed, so refresh con2
914
- this.SelectorConnect(scene, parent, con1, newPart2.children[ii]);
915
- }
916
- else {
917
- return this.SelectorConnect(scene, parent, con1, con2);
918
- }
919
- }
920
- }
921
- }
922
- }
923
- }
924
- return false;
925
- };
926
- // public static TrySelectorConnection(scene: THREE.Scene, parent: THREE.Object3D,
927
- // part1: any, part2: any, createAddableFn?: Function): boolean {
928
- // let addable: any;
929
- // if (createAddableFn) {
930
- // addable = part2;
931
- // part2 = createAddableFn(addable);
932
- // }
933
- // for (let i = 0; i < part1.children.length; i++) {
934
- // for (let ii = 0; ii < part2.children.length; ii++) {
935
- // const con1: THREE.Object3D = part1.children[i];
936
- // const con2: THREE.Object3D = part2.children[ii];
937
- // // if these connectors can connect connect them
938
- // if (!con1['connected'] && !con2['connected'] && this.CanSelectorConnect(con1, con2)) {
939
- // // if addable, continue this loop with a new addable
940
- // if (addable) {
941
- // const newPart2: THREE.Object3D = createAddableFn(addable, part2, part1);
942
- // // reference of part2 changed, so refresh con2
943
- // this.SelectorConnect(scene, parent, con1, newPart2.children[ii]);
944
- // } else {
945
- // return this.SelectorConnect(scene, parent, con1, con2);
946
- // }
947
- // }
948
- // }
949
- // }
950
- // return false;
951
- // }
952
- SceneUtils.Convert3DPointToScreenPoint = function (point, camera, width, height) {
953
- if (!point) {
954
- return new THREE__namespace.Vector2();
955
- }
956
- var vector = point.clone().project(camera);
957
- vector.x = (vector.x + 1) / 2 * width;
958
- vector.y = -(vector.y - 1) / 2 * height;
959
- return new THREE__namespace.Vector2(vector.x, vector.y);
960
- };
961
- SceneUtils.CanSelectorConnect = function (consPart1, con1, con2, startWithMale) {
962
- var con1Name = (con1.constructor.name === 'Mesh' || con1.constructor.name === 'Object3D') ? con1.name : con1.connector;
963
- var con2Name = (con2.constructor.name === 'Mesh' || con2.constructor.name === 'Object3D') ? con2.name : con2.connector;
964
- var sameParent = (con1.constructor.name === 'Mesh' || con1.constructor.name === 'Object3D') &&
965
- (con2.constructor.name === 'Mesh' || con2.constructor.name === 'Object3D') ? con1.parent === con2.parent : false;
966
- if (!con1Name || !con2Name) {
967
- return false;
968
- }
969
- var parts1 = con1Name.toUpperCase().split('_'), parts2 = con2Name.toUpperCase().split('_');
970
- if (parts1.length >= 3 && parts2.length >= 3 && !sameParent) {
971
- var connectable = parts1[0] === 'C' && parts2[0] === 'C' &&
972
- parts1[1] === parts2[1] && parts1[2] !== parts2[2];
973
- return connectable;
974
- }
975
- return false;
976
- };
977
- // public static CanSelectorConnect(con1: THREE.Object3D | any, con2: THREE.Object3D | any): boolean {
978
- // const con1Name: string = con1 instanceof THREE.Object3D ? con1.name : con1.connector;
979
- // const con2Name: string = con2 instanceof THREE.Object3D ? con2.name : con2.connector;
980
- // const sameParent: boolean = con1 instanceof THREE.Object3D && con2 instanceof THREE.Object3D ? con1.parent === con2.parent : false;
981
- // const parts1: string[] = con1Name.toUpperCase().split('_'),
982
- // parts2: string[] = con2Name.toUpperCase().split('_');
983
- // if (parts1.length >= 3 && parts2.length >= 3 && !sameParent) {
984
- // const connectable: boolean = parts1[0] === 'C' && parts2[0] === 'C' &&
985
- // parts1[1] === parts2[1] && parts1[2] !== parts2[2];
986
- // return connectable;
987
- // }
988
- // return false;
989
- // }
990
- SceneUtils.SelectorConnect = function (scene, parent, con1, con2) {
991
- if (!scene || !parent) {
992
- return false;
993
- }
994
- con1['connectedTo'] = con2 && con2.parent ? con2.parent.name : '';
995
- con2['connectedTo'] = con1 && con1.parent ? con1.parent.name : '';
996
- var motherRotation = new THREE__namespace.Euler(0, 0, 0);
997
- var motherPosition = new THREE__namespace.Vector3(0, 0, 0);
998
- parent.updateMatrixWorld();
999
- motherRotation.copy(parent.rotation);
1000
- parent.getWorldPosition(motherPosition);
1001
- parent.rotation.set(0, 0, 0);
1002
- parent.position.set(0, 0, 0);
1003
- scene.updateMatrixWorld(true);
1004
- var con1Quat = new THREE__namespace.Quaternion();
1005
- if (con1) {
1006
- con1.getWorldQuaternion(con1Quat);
1007
- }
1008
- var con2Quat = new THREE__namespace.Quaternion();
1009
- if (con2) {
1010
- con2.getWorldQuaternion(con2Quat);
1011
- }
1012
- var con1QuatParent = new THREE__namespace.Quaternion();
1013
- if (con1 && con1.parent) {
1014
- con1.parent.getWorldQuaternion(con1QuatParent);
1015
- }
1016
- var con2QuatParent = new THREE__namespace.Quaternion();
1017
- if (con2 && con2.parent) {
1018
- con2.parent.getWorldQuaternion(con2QuatParent);
1019
- }
1020
- var rotation = new THREE__namespace.Quaternion().multiplyQuaternions(con1Quat.invert(), con2Quat).multiply(new THREE__namespace.Quaternion().multiplyQuaternions(con1QuatParent, con1QuatParent));
1021
- if (con2 && con2.parent) {
1022
- con2.parent.quaternion.copy(rotation);
1023
- }
1024
- // Update because the matrix has been tempered with
1025
- scene.updateMatrixWorld(true);
1026
- // Move the connectors towards eachother
1027
- var con1Pos = new THREE__namespace.Vector3();
1028
- if (con1) {
1029
- con1.getWorldPosition(con1Pos);
1030
- }
1031
- var con2Pos = new THREE__namespace.Vector3();
1032
- if (con2) {
1033
- con2.getWorldPosition(con2Pos);
1034
- }
1035
- var move = con1Pos.sub(con2Pos);
1036
- if (con2 && con2.parent) {
1037
- con2.parent.position.x += move.x;
1038
- con2.parent.position.y += move.y;
1039
- con2.parent.position.z += move.z;
1040
- }
1041
- // reset parent's objects rotation and position
1042
- parent.rotation.copy(motherRotation);
1043
- parent.position.copy(motherPosition);
1044
- scene.updateMatrixWorld(true);
1045
- // Set the connected flag
1046
- if (con1) {
1047
- con1['connected'] = true;
1048
- }
1049
- if (con2) {
1050
- con2['connected'] = true;
1051
- }
1052
- return true;
1053
- };
1054
- return SceneUtils;
1055
- }());
1056
-
1057
- var VariationSettingsSettings = /** @class */ (function () {
1058
- function VariationSettingsSettings() {
1059
- }
1060
- return VariationSettingsSettings;
1061
- }());
1062
- var VariationSettings = /** @class */ (function () {
1063
- function VariationSettings() {
1064
- this.settings = new VariationSettingsSettings();
1065
- this.loading = false;
1066
- this.loaded = new rxjs.BehaviorSubject(undefined);
1067
- }
1068
- VariationSettings.prototype.copyFrom = function (settings) {
1069
- this.settings = settings.settings;
1070
- this.texture = settings.texture;
1071
- this.textureFilename = settings.textureFilename;
1072
- this.normal = settings.normal;
1073
- this.normalFilename = settings.normalFilename;
1074
- this.ao = settings.ao;
1075
- this.aoFilename = settings.aoFilename;
1076
- this.metalness = settings.metalness;
1077
- this.metalnessFilename = settings.metalnessFilename;
1078
- this.roughness = settings.roughness;
1079
- this.roughnessFilename = settings.roughnessFilename;
1080
- this.orm = settings.orm;
1081
- this.ormFilename = settings.ormFilename;
1082
- this.displacement = settings.displacement;
1083
- this.displacementValue = settings.displacementValue;
1084
- this.displacementFilename = settings.displacementFilename;
1085
- this.sheen = settings.sheen;
1086
- this.sheenColor = settings.sheenColor;
1087
- this.sheenColorMap = settings.sheenColorMap;
1088
- this.sheenColorMapFilename = settings.sheenColorMapFilename;
1089
- this.transmissionMap = settings.transmissionMap;
1090
- this.transmissionMapFilename = settings.transmissionMapFilename;
1091
- this.sheenRoughness = settings.sheenRoughness;
1092
- this.sheenRoughnessMap = settings.sheenRoughnessMap;
1093
- this.sheenRoughnessMapFilename = settings.sheenRoughnessMapFilename;
1094
- this.emissive = settings.emissive;
1095
- this.emissiveFilename = settings.emissiveFilename;
1096
- this.emissiveIntensity = settings.emissiveIntensity;
1097
- this.emissiveValue = settings.emissiveValue;
1098
- this.opacity = settings.opacity;
1099
- this.transparent = settings.transparent;
1100
- this.envMap = settings.envMap;
1101
- this.envMapFilename = settings.envMapFilename;
1102
- this.envMapIntensity = settings.envMapIntensity;
1103
- this.reflectivity = settings.reflectivity;
1104
- this.side = settings.side;
1105
- this.transmission = settings.transmission;
1106
- this.ior = settings.ior;
1107
- this.thickness = settings.thickness;
1108
- this.specularIntensity = settings.specularIntensity;
1109
- this.material = settings.material;
1110
- };
1111
- return VariationSettings;
1112
- }());
1113
-
1114
- var Material = /** @class */ (function () {
1115
- function Material() {
1116
- this.specular = new THREE.Color(0.3, 0.3, 0.3);
1117
- this.shininess = 0;
1118
- this.repeatX = 4;
1119
- this.repeatY = 4;
1120
- this.loaded = false;
1121
- }
1122
- return Material;
1123
- }());
1124
-
1125
- var BaseUtils = /** @class */ (function () {
1126
- function BaseUtils() {
1127
- }
1128
- BaseUtils.prototype.log = function (message) {
1129
- if (this.debug) {
1130
- this.debug(message);
1131
- console.log(new Date(), message);
1132
- }
1133
- };
1134
- return BaseUtils;
1135
- }());
1136
-
1137
- // @dynamic
1138
- var ImageUtils = /** @class */ (function (_super) {
1139
- __extends(ImageUtils, _super);
1140
- function ImageUtils() {
1141
- return _super !== null && _super.apply(this, arguments) || this;
1142
- }
1143
- ImageUtils.CreateTextureFromBase64 = function (id, base64, material, defaultFlip) {
1144
- if (defaultFlip === void 0) { defaultFlip = false; }
1145
- var _a, _b;
1146
- return __awaiter(this, void 0, void 0, function () {
1147
- var texture_1, loader_1, texture, err_1;
1148
- return __generator(this, function (_c) {
1149
- switch (_c.label) {
1150
- case 0:
1151
- if (ImageUtils.textures.has(id)) {
1152
- return [2 /*return*/, ImageUtils.textures.get(id)];
1153
- }
1154
- _c.label = 1;
1155
- case 1:
1156
- _c.trys.push([1, 5, , 6]);
1157
- if (!window.textureLoader) return [3 /*break*/, 3];
1158
- return [4 /*yield*/, window.textureLoader(base64, material)];
1159
- case 2:
1160
- texture_1 = _c.sent();
1161
- ImageUtils.textures.set(id, texture_1);
1162
- return [2 /*return*/, texture_1];
1163
- case 3:
1164
- loader_1 = new THREE__namespace.TextureLoader();
1165
- return [4 /*yield*/, new Promise(function (resolve, reject) {
1166
- loader_1.load(base64, resolve, undefined, function (err) { return reject(err); });
1167
- })];
1168
- case 4:
1169
- texture = _c.sent();
1170
- texture.anisotropy = 16;
1171
- texture.wrapS = THREE__namespace.RepeatWrapping;
1172
- texture.wrapT = THREE__namespace.RepeatWrapping;
1173
- texture.repeat = new THREE__namespace.Vector2((_a = material === null || material === void 0 ? void 0 : material.repeatX) !== null && _a !== void 0 ? _a : 1, (_b = material === null || material === void 0 ? void 0 : material.repeatY) !== null && _b !== void 0 ? _b : 1);
1174
- texture.flipY = defaultFlip;
1175
- texture.needsUpdate = true;
1176
- ImageUtils.textures.set(id, texture);
1177
- return [2 /*return*/, texture];
1178
- case 5:
1179
- err_1 = _c.sent();
1180
- return [2 /*return*/, null];
1181
- case 6: return [2 /*return*/];
1182
- }
1183
- });
1184
- });
1185
- };
1186
- ImageUtils.getDocBodyWithMimeTypeDefinition = function (fileName, documentBody) {
1187
- if (documentBody === null) {
1188
- return documentBody;
1189
- }
1190
- var fileExtension = fileName.substr(fileName.lastIndexOf('.') + 1);
1191
- switch (fileExtension.toLowerCase()) {
1192
- case 'jpg':
1193
- case 'jpeg':
1194
- return 'data:image/jpg;base64,' + documentBody;
1195
- case 'png':
1196
- return 'data:image/png;base64,' + documentBody;
1197
- case 'gif':
1198
- return 'data:image/gif;base64,' + documentBody;
1199
- case 'bmp':
1200
- return 'data:image/bmp;base64,' + documentBody;
1201
- default:
1202
- return 'data:image/png;base64,' + documentBody;
1203
- }
1204
- };
1205
- ImageUtils.getFixedImageFilepathUrl = function (imageFilepathUrl) {
1206
- return imageFilepathUrl.replace('/content/', '/content43/');
1207
- };
1208
- ImageUtils.ClearCache = function () {
1209
- ImageUtils.textures.forEach(function (value) {
1210
- value.dispose();
1211
- });
1212
- ImageUtils.textures.clear();
1213
- };
1214
- return ImageUtils;
1215
- }(BaseUtils));
1216
- ImageUtils.textures = new Map();
1217
-
1218
- var FurnitureMaterial = /** @class */ (function (_super) {
1219
- __extends(FurnitureMaterial, _super);
1220
- function FurnitureMaterial() {
1221
- return _super !== null && _super.apply(this, arguments) || this;
1222
- }
1223
- return FurnitureMaterial;
1224
- }(Material));
1225
- var AssetUtils = /** @class */ (function () {
1226
- function AssetUtils() {
1227
- }
1228
- AssetUtils.CreateMaterialFromAsset = function (asset) {
1229
- return __awaiter(this, void 0, void 0, function () {
1230
- var material, _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, e_1;
1231
- return __generator(this, function (_o) {
1232
- switch (_o.label) {
1233
- case 0:
1234
- material = new Material();
1235
- _o.label = 1;
1236
- case 1:
1237
- _o.trys.push([1, 26, , 27]);
1238
- if (!asset) {
1239
- return [2 /*return*/, material];
1240
- }
1241
- if (asset.settings) {
1242
- AssetUtils.setSettingsOfMaterial(material, asset.settings);
1243
- }
1244
- if (!asset.texture) return [3 /*break*/, 3];
1245
- _a = material;
1246
- return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_texture', asset.texture, material)];
1247
- case 2:
1248
- _a.texture = _o.sent();
1249
- material.texture.colorSpace = THREE.SRGBColorSpace;
1250
- material.textureFilename = asset.textureFilename;
1251
- _o.label = 3;
1252
- case 3:
1253
- if (!asset.normal) return [3 /*break*/, 5];
1254
- _b = material;
1255
- return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_normal', asset.normal, material)];
1256
- case 4:
1257
- _b.normal = _o.sent();
1258
- material.normalFilename = asset.normalFilename;
1259
- _o.label = 5;
1260
- case 5:
1261
- if (!asset.orm) return [3 /*break*/, 7];
1262
- _c = material;
1263
- return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_orm', asset.orm, material)];
1264
- case 6:
1265
- _c.ao = _o.sent();
1266
- material.roughness = material.ao;
1267
- material.metalness = material.ao;
1268
- material.aoFilename = asset.ormFilename;
1269
- material.roughnessFilename = asset.ormFilename;
1270
- material.metalnessFilename = asset.ormFilename;
1271
- return [3 /*break*/, 13];
1272
- case 7:
1273
- if (!asset.ao) return [3 /*break*/, 9];
1274
- _d = material;
1275
- return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_ao', asset.ao, material)];
1276
- case 8:
1277
- _d.ao = _o.sent();
1278
- material.aoFilename = asset.aoFilename;
1279
- _o.label = 9;
1280
- case 9:
1281
- if (!asset.metalness) return [3 /*break*/, 11];
1282
- _e = material;
1283
- return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_metalness', asset.metalness, material)];
1284
- case 10:
1285
- _e.metalness = _o.sent();
1286
- material.metalnessFilename = asset.metalnessFilename;
1287
- _o.label = 11;
1288
- case 11:
1289
- if (!asset.roughness) return [3 /*break*/, 13];
1290
- _f = material;
1291
- return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_roughness', asset.roughness, material)];
1292
- case 12:
1293
- _f.roughness = _o.sent();
1294
- material.roughnessFilename = asset.roughnessFilename;
1295
- _o.label = 13;
1296
- case 13:
1297
- if (!asset.displacement) return [3 /*break*/, 15];
1298
- _g = material;
1299
- return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_displacement', asset.displacement, material)];
1300
- case 14:
1301
- _g.displacement = _o.sent();
1302
- material.displacementFilename = asset.displacementFilename;
1303
- _o.label = 15;
1304
- case 15:
1305
- if (!asset.envMap) return [3 /*break*/, 17];
1306
- _h = material;
1307
- return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_env', asset.envMap, material, true)];
1308
- case 16:
1309
- _h.envMap = _o.sent();
1310
- material.envMapFilename = asset.envMapFilename;
1311
- _o.label = 17;
1312
- case 17:
1313
- if (!asset.sheenColorMap) return [3 /*break*/, 19];
1314
- _j = material;
1315
- return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_sheen_color', asset.sheenColorMap, material)];
1316
- case 18:
1317
- _j.sheenColorMap = _o.sent();
1318
- material.sheenColorMapFileName = asset.sheenColorMapFilename;
1319
- _o.label = 19;
1320
- case 19:
1321
- if (!asset.sheenRoughnessMap) return [3 /*break*/, 21];
1322
- _k = material;
1323
- return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_sheen_roughness', asset.sheenRoughnessMap, material)];
1324
- case 20:
1325
- _k.sheenRoughnessMap = _o.sent();
1326
- material.sheenRoughnessMapFileName = asset.sheenRoughnessMapFilename;
1327
- _o.label = 21;
1328
- case 21:
1329
- if (!asset.transmissionMap) return [3 /*break*/, 23];
1330
- _l = material;
1331
- return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_transmission', asset.transmissionMap, material)];
1332
- case 22:
1333
- _l.transmissionMap = _o.sent();
1334
- material.transmissionMapFileName = asset.transmissionMapFilename;
1335
- _o.label = 23;
1336
- case 23:
1337
- if (!asset.emissive) return [3 /*break*/, 25];
1338
- _m = material;
1339
- return [4 /*yield*/, ImageUtils.CreateTextureFromBase64(asset.id + '_emissive', asset.emissive, material)];
1340
- case 24:
1341
- _m.emissive = _o.sent();
1342
- material.emissiveFileName = asset.emissiveFilename;
1343
- _o.label = 25;
1344
- case 25:
1345
- material.sheen = asset.sheen;
1346
- material.emissiveIntensityValue = asset.emissiveIntensity;
1347
- material.emissiveValue = asset.emissiveValue;
1348
- material.side = asset.side;
1349
- material.sheenColor = asset.sheenColor;
1350
- material.sheenRoughness = asset.sheenRoughness;
1351
- material.opacity = asset.opacity;
1352
- material.transparent = asset.transparent;
1353
- material.envMapIntensity = asset.envMapIntensity;
1354
- material.reflectivity = asset.reflectivity;
1355
- material.displacementValue = asset.displacementValue;
1356
- material.transmission = asset.transmission;
1357
- material.ior = asset.ior;
1358
- material.thickness = asset.thickness;
1359
- material.specularIntensity = asset.specularIntensity;
1360
- return [3 /*break*/, 27];
1361
- case 26:
1362
- e_1 = _o.sent();
1363
- console.error(e_1);
1364
- return [3 /*break*/, 27];
1365
- case 27: return [2 /*return*/, material];
1366
- }
1367
- });
1368
- });
1369
- };
1370
- AssetUtils.setSettingsOfMaterial = function (material, settings) {
1371
- var shininess = parseFloat(settings['power']);
1372
- if (!isNaN(shininess)) {
1373
- material.shininess = shininess;
1374
- // material.roughness = 1 - (shininess / 100);
1375
- }
1376
- var level = parseFloat(settings['level']);
1377
- if (!isNaN(level)) {
1378
- material.specular = new THREE.Color(level, level, level);
1379
- }
1380
- var repeatObjectUsed = settings.hasOwnProperty('repeat');
1381
- var repeatx = repeatObjectUsed ? parseFloat(settings['repeat']['repeatx']) : parseFloat(settings['repeatx']);
1382
- if (!isNaN(repeatx)) {
1383
- material.repeatX = repeatx;
1384
- }
1385
- var repeaty = repeatObjectUsed ? parseFloat(settings['repeat']['repeaty']) : parseFloat(settings['repeaty']);
1386
- if (!isNaN(repeaty)) {
1387
- material.repeatY = repeaty;
1388
- }
1389
- var metalness = parseFloat(settings['metalness']);
1390
- if (!isNaN(metalness)) {
1391
- material.metalnessValue = Math.min(1, metalness);
1392
- }
1393
- var roughness = parseFloat(settings['roughness']);
1394
- if (!isNaN(roughness)) {
1395
- material.roughnessValue = Math.min(1, roughness);
1396
- }
1397
- };
1398
- return AssetUtils;
1399
- }());
1400
-
1401
- var Variation = /** @class */ (function () {
1402
- function Variation() {
1403
- }
1404
- return Variation;
1405
- }());
1406
-
1407
- // @dynamic
1408
- var VariationUtils = /** @class */ (function () {
1409
- function VariationUtils() {
1410
- }
1411
- VariationUtils.ClearCache = function () {
1412
- this.MaterialCache.clear();
1413
- };
1414
- VariationUtils.LoadVariation = function (assetPath, fileName) {
1415
- return __awaiter(this, void 0, void 0, function () {
1416
- var id, file, settings, err_1;
1417
- return __generator(this, function (_a) {
1418
- switch (_a.label) {
1419
- case 0:
1420
- if (!fileName) {
1421
- return [2 /*return*/, null];
1422
- }
1423
- if (!fileName.includes('ione3d')) {
1424
- fileName = fileName.concat('.ione3d');
1425
- }
1426
- id = fileName.substring(0, fileName.lastIndexOf('.ione3d'));
1427
- if (!assetPath.endsWith('/')) {
1428
- assetPath += '/';
1429
- }
1430
- if (!window.hasOwnProperty('downloadVariation')) {
1431
- console.error('downloadVariation not defined in window global');
1432
- throw new Error('downloadVariation not defined in window global');
1433
- }
1434
- if (this.MaterialCache.has(id)) {
1435
- return [2 /*return*/, this.MaterialCache.get(id)];
1436
- }
1437
- _a.label = 1;
1438
- case 1:
1439
- _a.trys.push([1, 4, , 5]);
1440
- return [4 /*yield*/, window.downloadVariation(assetPath.replace('https://cdn1.colijn-it.nl/', '') + "variation/" + fileName)];
1441
- case 2:
1442
- file = _a.sent();
1443
- return [4 /*yield*/, VariationUtils.GetVariationSettingsFromFile(id, file)];
1444
- case 3:
1445
- settings = _a.sent();
1446
- this.MaterialCache.set(id, settings);
1447
- return [2 /*return*/, settings];
1448
- case 4:
1449
- err_1 = _a.sent();
1450
- console.error('Error loading variation:', err_1);
1451
- throw err_1;
1452
- case 5: return [2 /*return*/];
1453
- }
1454
- });
1455
- });
1456
- };
1457
- VariationUtils.LoadVariationByUrl = function (materialCode, url) {
1458
- return __awaiter(this, void 0, void 0, function () {
1459
- var file, settings, err_2;
1460
- return __generator(this, function (_a) {
1461
- switch (_a.label) {
1462
- case 0:
1463
- if (!url) {
1464
- return [2 /*return*/, null];
1465
- }
1466
- if (!url.includes('ione3d')) {
1467
- url = url.concat('.ione3d');
1468
- }
1469
- if (!window.hasOwnProperty('downloadVariation')) {
1470
- console.error('downloadVariation not defined in window global');
1471
- throw new Error('downloadVariation not defined in window global');
1472
- }
1473
- if (this.MaterialCache.has(materialCode)) {
1474
- return [2 /*return*/, this.MaterialCache.get(materialCode)];
1475
- }
1476
- _a.label = 1;
1477
- case 1:
1478
- _a.trys.push([1, 4, , 5]);
1479
- return [4 /*yield*/, window.downloadVariation(url)];
1480
- case 2:
1481
- file = _a.sent();
1482
- return [4 /*yield*/, VariationUtils.GetVariationSettingsFromFile(materialCode, file)];
1483
- case 3:
1484
- settings = _a.sent();
1485
- this.MaterialCache.set(materialCode, settings);
1486
- return [2 /*return*/, settings];
1487
- case 4:
1488
- err_2 = _a.sent();
1489
- console.error('Error loading variation:', err_2);
1490
- throw err_2;
1491
- case 5: return [2 /*return*/];
1492
- }
1493
- });
1494
- });
1495
- };
1496
- // public static GetMaterialFromName(variationFolder: string, material: any): Promise<MeshStandardMaterial> {
1497
- // return new Promise((resolve: Function) => {
1498
- // if (!material) {
1499
- // resolve(null);
1500
- // }
1501
- // if (this.MaterialCache.has(material.name)) {
1502
- // resolve(this.MaterialCache.get(material.name).clone());
1503
- // } else {
1504
- // VariationUtils.LoadVariation(variationFolder, material.name, false).then((settings: VariationSettings) => {
1505
- // if (settings) {
1506
- // AssetUtils.CreateMaterialFromAsset(settings).then((materialObj: Material) => {
1507
- // const materialParams: MeshStandardMaterialParameters = {};
1508
- // materialParams.name = material.name;
1509
- // materialParams.map = materialObj.texture;
1510
- // materialParams.normalMap = materialObj.normal;
1511
- // materialParams.aoMap = materialObj.ao;
1512
- // materialParams.roughnessMap = materialObj.roughness;
1513
- // materialParams.metalnessMap = materialObj.metalness;
1514
- // materialParams.roughness = 1;
1515
- // materialParams.metalness = 1;
1516
- // const pbrMat: MeshStandardMaterial = new MeshStandardMaterial(materialParams);
1517
- // this.MaterialCache.set(material.name, pbrMat);
1518
- // resolve(pbrMat.clone());
1519
- // });
1520
- // } else {
1521
- // resolve(material);
1522
- // }
1523
- // });
1524
- // }
1525
- // });
1526
- // }
1527
- VariationUtils.GetVariationSettingsFromFile = function (id, compressedFile) {
1528
- return __awaiter(this, void 0, void 0, function () {
1529
- var zipContent, variationSettings, index, material, _a, indexFile;
1530
- return __generator(this, function (_b) {
1531
- switch (_b.label) {
1532
- case 0:
1533
- if (!compressedFile) {
1534
- return [2 /*return*/, null];
1535
- }
1536
- return [4 /*yield*/, VariationUtils.GetZipContent(compressedFile)];
1537
- case 1:
1538
- zipContent = _b.sent();
1539
- variationSettings = new VariationSettings();
1540
- variationSettings.id = id;
1541
- if (!zipContent) return [3 /*break*/, 10];
1542
- if (!zipContent.files['material.glb']) return [3 /*break*/, 4];
1543
- return [4 /*yield*/, zipContent.files['material.glb'].async('arraybuffer')];
1544
- case 2:
1545
- material = _b.sent();
1546
- _a = variationSettings;
1547
- return [4 /*yield*/, VariationUtils.LoadMaterialFromGlb(material)];
1548
- case 3:
1549
- _a.material = _b.sent();
1550
- return [3 /*break*/, 10];
1551
- case 4:
1552
- if (!zipContent.files['index.json']) return [3 /*break*/, 6];
1553
- return [4 /*yield*/, zipContent.files['index.json'].async('string')];
1554
- case 5:
1555
- indexFile = _b.sent();
1556
- index = JSON.parse(indexFile);
1557
- _b.label = 6;
1558
- case 6:
1559
- if (!index) return [3 /*break*/, 8];
1560
- return [4 /*yield*/, VariationUtils.CreateSettingsBasedOnIndex(index, variationSettings, zipContent)];
1561
- case 7:
1562
- _b.sent();
1563
- return [3 /*break*/, 10];
1564
- case 8: return [4 /*yield*/, VariationUtils.CreateSettingsBasedOnFileName(variationSettings, zipContent)];
1565
- case 9:
1566
- _b.sent();
1567
- _b.label = 10;
1568
- case 10: return [2 /*return*/, variationSettings];
1569
- }
1570
- });
1571
- });
1572
- };
1573
- VariationUtils.CreateSettingsBasedOnIndex = function (index, variationSettings, zipContent) {
1574
- return __awaiter(this, void 0, void 0, function () {
1575
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1576
- return __generator(this, function (_o) {
1577
- switch (_o.label) {
1578
- case 0:
1579
- if (!index.normalFile) return [3 /*break*/, 2];
1580
- _a = variationSettings;
1581
- return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.normalFile], index.normalFile)];
1582
- case 1:
1583
- _a.normal = _o.sent();
1584
- variationSettings.normalFilename = index.normalFile;
1585
- _o.label = 2;
1586
- case 2:
1587
- if (!index.diffuseFile) return [3 /*break*/, 4];
1588
- _b = variationSettings;
1589
- return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.diffuseFile], index.diffuseFile)];
1590
- case 3:
1591
- _b.texture = _o.sent();
1592
- variationSettings.textureFilename = index.diffuseFile;
1593
- _o.label = 4;
1594
- case 4:
1595
- if (!index.ormFile) return [3 /*break*/, 6];
1596
- _c = variationSettings;
1597
- return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.ormFile], index.ormFile)];
1598
- case 5:
1599
- _c.orm = _o.sent();
1600
- variationSettings.ormFilename = index.ormFile;
1601
- return [3 /*break*/, 12];
1602
- case 6:
1603
- if (!index.aoFile) return [3 /*break*/, 8];
1604
- _d = variationSettings;
1605
- return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.aoFile], index.aoFile)];
1606
- case 7:
1607
- _d.ao = _o.sent();
1608
- variationSettings.aoFilename = index.aoFile;
1609
- _o.label = 8;
1610
- case 8:
1611
- if (!index.metalnessFile) return [3 /*break*/, 10];
1612
- _e = variationSettings;
1613
- return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.metalnessFile], index.metalnessFile)];
1614
- case 9:
1615
- _e.metalness = _o.sent();
1616
- variationSettings.metalnessFilename = index.metalnessFile;
1617
- _o.label = 10;
1618
- case 10:
1619
- if (!index.roughnessFile) return [3 /*break*/, 12];
1620
- _f = variationSettings;
1621
- return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.roughnessFile], index.roughnessFile)];
1622
- case 11:
1623
- _f.roughness = _o.sent();
1624
- variationSettings.roughnessFilename = index.roughnessFile;
1625
- _o.label = 12;
1626
- case 12:
1627
- if (!index.displacementFile) return [3 /*break*/, 14];
1628
- _g = variationSettings;
1629
- return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.displacementFile], index.displacementFile)];
1630
- case 13:
1631
- _g.displacement = _o.sent();
1632
- variationSettings.displacementFilename = index.displacementFile;
1633
- _o.label = 14;
1634
- case 14:
1635
- if (!index.emissiveFile) return [3 /*break*/, 16];
1636
- _h = variationSettings;
1637
- return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.emissiveFile], index.emissiveFile)];
1638
- case 15:
1639
- _h.emissive = _o.sent();
1640
- variationSettings.emissiveFilename = index.emissiveFile;
1641
- _o.label = 16;
1642
- case 16:
1643
- if (!index.envMapFile) return [3 /*break*/, 18];
1644
- _j = variationSettings;
1645
- return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.envMapFile], index.envMapFile)];
1646
- case 17:
1647
- _j.envMap = _o.sent();
1648
- variationSettings.envMapFilename = index.envMapFile;
1649
- _o.label = 18;
1650
- case 18:
1651
- if (!index.sheenColorMapFile) return [3 /*break*/, 20];
1652
- _k = variationSettings;
1653
- return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.sheenColorMapFile], index.sheenColorMapFile)];
1654
- case 19:
1655
- _k.sheenColorMap = _o.sent();
1656
- variationSettings.sheenColorMapFilename = index.sheenColorMapFile;
1657
- _o.label = 20;
1658
- case 20:
1659
- if (!index.sheenRoughnessMapFile) return [3 /*break*/, 22];
1660
- _l = variationSettings;
1661
- return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.sheenRoughnessMapFile], index.sheenRoughnessMapFile)];
1662
- case 21:
1663
- _l.sheenRoughnessMap = _o.sent();
1664
- variationSettings.sheenRoughnessMapFilename = index.sheenColorMapFile;
1665
- _o.label = 22;
1666
- case 22:
1667
- if (!index.transmissionMapFile) return [3 /*break*/, 24];
1668
- _m = variationSettings;
1669
- return [4 /*yield*/, VariationUtils.LoadFileContentFromZip(zipContent.files[index.transmissionMapFile], index.transmissionMapFile)];
1670
- case 23:
1671
- _m.transmissionMap = _o.sent();
1672
- variationSettings.transmissionMapFilename = index.transmissionMapFile;
1673
- _o.label = 24;
1674
- case 24:
1675
- if (index.repeat) {
1676
- variationSettings.settings.repeatx = index.repeat.repeatx;
1677
- variationSettings.settings.repeaty = index.repeat.repeaty;
1678
- }
1679
- variationSettings.settings.metalness = index.metalness;
1680
- variationSettings.settings.roughness = index.roughness;
1681
- if (index.sheen && typeof index.sheen === 'object') {
1682
- variationSettings.sheen = 1;
1683
- variationSettings.sheenColor = new THREE.Color(index.sheen.r, index.sheen.g, index.sheen.b).getHexString(THREE.SRGBColorSpace);
1684
- }
1685
- else {
1686
- variationSettings.sheen = index.sheen;
1687
- }
1688
- if (index.sheenColor) {
1689
- variationSettings.sheenColor = new THREE.Color(index.sheenColor.r, index.sheenColor.g, index.sheenColor.b).getHexString(THREE.SRGBColorSpace);
1690
- }
1691
- variationSettings.sheenRoughness = index.sheenRoughness;
1692
- variationSettings.envMapIntensity = index.envMapIntensity;
1693
- variationSettings.transparent = index.transparent;
1694
- variationSettings.opacity = index.opacity;
1695
- if (index.emissiveValue) {
1696
- variationSettings.emissiveValue = new THREE.Color(index.emissiveValue.r, index.emissiveValue.g, index.emissiveValue.b).getHexString(THREE.SRGBColorSpace);
1697
- }
1698
- variationSettings.emissiveIntensity = index.emissiveIntensity;
1699
- variationSettings.reflectivity = index.reflectivity;
1700
- variationSettings.displacementValue = index.displacementValue;
1701
- variationSettings.side = index.side;
1702
- variationSettings.transmission = index.transmission;
1703
- variationSettings.ior = index.ior;
1704
- variationSettings.thickness = index.thickness;
1705
- variationSettings.specularIntensity = index.specularIntensity;
1706
- return [2 /*return*/];
1707
- }
1708
- });
1709
- });
1710
- };
1711
- VariationUtils.CreateSettingsBasedOnFileName = function (variationSettings, zipContent) {
1712
- return __awaiter(this, void 0, void 0, function () {
1713
- var allLoaded, _loop_1, this_1, _a, _b, _i, fileName;
1714
- var _this = this;
1715
- return __generator(this, function (_c) {
1716
- switch (_c.label) {
1717
- case 0:
1718
- allLoaded = [];
1719
- _loop_1 = function (fileName) {
1720
- var file_1;
1721
- return __generator(this, function (_d) {
1722
- switch (_d.label) {
1723
- case 0:
1724
- if (!zipContent.files.hasOwnProperty(fileName)) return [3 /*break*/, 2];
1725
- return [4 /*yield*/, zipContent.files[fileName]];
1726
- case 1:
1727
- file_1 = _d.sent();
1728
- if (file_1.name.toLowerCase().indexOf('normal') > -1 && this_1.FileIsImage(file_1.name)) {
1729
- allLoaded.push(zipContent.files[fileName].async('base64').then(function (normalFile) {
1730
- variationSettings.normal = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + normalFile;
1731
- variationSettings.normalFilename = fileName;
1732
- }));
1733
- }
1734
- else if (file_1.name.toLowerCase().indexOf('ao') > -1 && this_1.FileIsImage(file_1.name)) {
1735
- allLoaded.push(zipContent.files[fileName].async('base64').then(function (aoFile) {
1736
- variationSettings.ao = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + aoFile;
1737
- variationSettings.aoFilename = fileName;
1738
- }));
1739
- }
1740
- else if (file_1.name.toLowerCase().indexOf('metalness') > -1 && this_1.FileIsImage(file_1.name)) {
1741
- allLoaded.push(zipContent.files[fileName].async('base64').then(function (metalnessFile) {
1742
- variationSettings.metalness = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + metalnessFile;
1743
- variationSettings.metalnessFilename = fileName;
1744
- }));
1745
- }
1746
- else if (file_1.name.toLowerCase().indexOf('roughness') > -1 && this_1.FileIsImage(file_1.name)) {
1747
- allLoaded.push(zipContent.files[fileName].async('base64').then(function (roughnessFile) {
1748
- variationSettings.roughness = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + roughnessFile;
1749
- variationSettings.roughnessFilename = fileName;
1750
- }));
1751
- }
1752
- else if (file_1.name.toLowerCase().indexOf('diffuse') > -1 && this_1.FileIsImage(file_1.name)) {
1753
- allLoaded.push(zipContent.files[fileName].async('base64').then(function (diffuseFile) {
1754
- variationSettings.texture = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + diffuseFile;
1755
- variationSettings.textureFilename = fileName;
1756
- }));
1757
- }
1758
- else if (file_1.name.toLowerCase().indexOf('displacement') > -1 && this_1.FileIsImage(file_1.name)) {
1759
- allLoaded.push(zipContent.files[fileName].async('base64').then(function (displacementFile) {
1760
- variationSettings.displacement = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + displacementFile;
1761
- variationSettings.displacementFilename = fileName;
1762
- }));
1763
- }
1764
- else if (file_1.name.toLowerCase().indexOf('emissive') > -1 && this_1.FileIsImage(file_1.name)) {
1765
- allLoaded.push(zipContent.files[fileName].async('base64').then(function (emissiveFile) {
1766
- variationSettings.emissive = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + emissiveFile;
1767
- variationSettings.emissiveFilename = fileName;
1768
- }));
1769
- }
1770
- else if (file_1.name.toLowerCase().indexOf('envMap') > -1 && this_1.FileIsImage(file_1.name)) {
1771
- allLoaded.push(zipContent.files[fileName].async('base64').then(function (envMapFile) {
1772
- variationSettings.envMap = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + envMapFile;
1773
- variationSettings.envMapFilename = fileName;
1774
- }));
1775
- }
1776
- else if (file_1.name.toLowerCase().indexOf('sheenColorMap') > -1 && this_1.FileIsImage(file_1.name)) {
1777
- allLoaded.push(zipContent.files[fileName].async('base64').then(function (sheenColorMapFile) {
1778
- variationSettings.sheenColorMap = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + sheenColorMapFile;
1779
- variationSettings.sheenColorMapFilename = fileName;
1780
- }));
1781
- }
1782
- else if (file_1.name.toLowerCase().indexOf('sheenRoughnessMap') > -1 && this_1.FileIsImage(file_1.name)) {
1783
- allLoaded.push(zipContent.files[fileName].async('base64').then(function (sheenRoughnessMapFile) {
1784
- variationSettings.sheenRoughnessMap = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + sheenRoughnessMapFile;
1785
- variationSettings.sheenRoughnessMapFilename = fileName;
1786
- }));
1787
- }
1788
- else if (file_1.name.toLowerCase().indexOf('transmissionMap') > -1 && this_1.FileIsImage(file_1.name)) {
1789
- allLoaded.push(zipContent.files[fileName].async('base64').then(function (transmissionMapFile) {
1790
- variationSettings.transmissionMap = "data:image/" + _this.GetBase64FileType(file_1.name) + ";base64," + transmissionMapFile;
1791
- variationSettings.transmissionMapFilename = fileName;
1792
- }));
1793
- }
1794
- else if (file_1.name.indexOf('.jp') > -1) {
1795
- allLoaded.push(zipContent.files[fileName].async('base64').then(function (textureFile) {
1796
- variationSettings.texture = 'data:image/jpeg;base64,' + textureFile;
1797
- variationSettings.textureFilename = fileName;
1798
- }));
1799
- }
1800
- else if (file_1.name.indexOf('.json') > -1) {
1801
- allLoaded.push(zipContent.files[fileName].async('string').then(function (settingsFile) {
1802
- var settingsFileObj = JSON.parse(settingsFile);
1803
- for (var key in settingsFileObj) {
1804
- if (settingsFileObj.hasOwnProperty(key)) {
1805
- variationSettings.settings[key] = settingsFileObj[key];
1806
- }
1807
- }
1808
- }));
1809
- }
1810
- _d.label = 2;
1811
- case 2: return [2 /*return*/];
1812
- }
1813
- });
1814
- };
1815
- this_1 = this;
1816
- _a = [];
1817
- for (_b in zipContent.files)
1818
- _a.push(_b);
1819
- _i = 0;
1820
- _c.label = 1;
1821
- case 1:
1822
- if (!(_i < _a.length)) return [3 /*break*/, 4];
1823
- fileName = _a[_i];
1824
- return [5 /*yield**/, _loop_1(fileName)];
1825
- case 2:
1826
- _c.sent();
1827
- _c.label = 3;
1828
- case 3:
1829
- _i++;
1830
- return [3 /*break*/, 1];
1831
- case 4: return [4 /*yield*/, Promise.all(allLoaded)];
1832
- case 5:
1833
- _c.sent();
1834
- return [2 /*return*/];
1835
- }
1836
- });
1837
- });
1838
- };
1839
- VariationUtils.LoadMaterialFromJson = function (material) {
1840
- var loader = new THREE.MaterialLoader();
1841
- if (material.textures) {
1842
- var textures = {};
1843
- for (var i = 0; i < material.textures.length; i++) {
1844
- textures[material.textures[i].uuid] = material.textures[i];
1845
- }
1846
- loader.setTextures(textures);
1847
- }
1848
- return loader.parse(material);
1849
- };
1850
- VariationUtils.LoadMaterialFromGlb = function (material) {
1851
- var _this = this;
1852
- return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1853
- var obj;
1854
- return __generator(this, function (_a) {
1855
- switch (_a.label) {
1856
- case 0:
1857
- if (!window.hasOwnProperty('loadGLTF')) {
1858
- console.error('loadGLTF not defined in window global');
1859
- return [2 /*return*/, reject()];
1860
- }
1861
- return [4 /*yield*/, window.loadGLTF(material, false)];
1862
- case 1:
1863
- obj = _a.sent();
1864
- if (obj) {
1865
- return [2 /*return*/, resolve(obj.children[0].material)];
1866
- }
1867
- return [2 /*return*/];
1868
- }
1869
- });
1870
- }); });
1871
- };
1872
- VariationUtils.LoadFileContentFromZip = function (zip, fileName, base64) {
1873
- var _this = this;
1874
- if (base64 === void 0) { base64 = true; }
1875
- return new Promise(function (resolve) {
1876
- if (zip && fileName) {
1877
- zip.async(base64 ? 'base64' : 'string').then(function (fileContent) {
1878
- if (base64) {
1879
- resolve("data:image/" + _this.GetBase64FileType(fileName) + ";base64," + fileContent);
1880
- }
1881
- else {
1882
- resolve(fileContent);
1883
- }
1884
- });
1885
- }
1886
- else {
1887
- resolve(undefined);
1888
- }
1889
- });
1890
- };
1891
- VariationUtils.FileIsImage = function (fileName) {
1892
- var ext = fileName.substring(fileName.lastIndexOf('.') + 1, fileName.length).toLowerCase();
1893
- switch (ext) {
1894
- case 'jpg':
1895
- case 'jpeg':
1896
- case 'png':
1897
- case 'bmp':
1898
- return true;
1899
- default:
1900
- return false;
1901
- }
1902
- };
1903
- VariationUtils.GetBase64FileType = function (fileName) {
1904
- var ext = fileName.substring(fileName.lastIndexOf('.') + 1, fileName.length).toLowerCase();
1905
- switch (ext) {
1906
- case 'jpg':
1907
- case 'jpeg':
1908
- return 'jpeg';
1909
- case 'png':
1910
- return 'png';
1911
- case 'bmp':
1912
- return 'bmp';
1913
- default:
1914
- return 'jpeg';
1915
- }
1916
- };
1917
- // Get the content
1918
- VariationUtils.GetZipContent = function (file) {
1919
- return __awaiter(this, void 0, void 0, function () {
1920
- var jszip, e_1;
1921
- return __generator(this, function (_a) {
1922
- switch (_a.label) {
1923
- case 0:
1924
- _a.trys.push([0, 2, , 3]);
1925
- jszip = new JSZip__default["default"]();
1926
- return [4 /*yield*/, jszip.loadAsync(file)];
1927
- case 1: return [2 /*return*/, _a.sent()];
1928
- case 2:
1929
- e_1 = _a.sent();
1930
- return [2 /*return*/, null];
1931
- case 3: return [2 /*return*/];
1932
- }
1933
- });
1934
- });
1935
- };
1936
- return VariationUtils;
1937
- }());
1938
- VariationUtils.MaterialCache = new Map();
1939
-
1940
- var VariationHelper = /** @class */ (function (_super) {
1941
- __extends(VariationHelper, _super);
1942
- function VariationHelper() {
1943
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
1944
- _this._variations = [];
1945
- _this._lastKnownVariations = new Map();
1946
- return _this;
1947
- }
1948
- VariationHelper.prototype.clearCache = function () {
1949
- var variationMap = Array.from(this._lastKnownVariations.values());
1950
- variationMap.forEach(function (variations) {
1951
- variations.forEach(function (variation) {
1952
- try {
1953
- if (variation.material) {
1954
- if (variation.material.texture) {
1955
- variation.material.texture.dispose();
1956
- }
1957
- if (variation.material.normal) {
1958
- variation.material.normal.dispose();
1959
- }
1960
- if (variation.material.metalness) {
1961
- variation.material.metalness.dispose();
1962
- }
1963
- if (variation.material.roughness) {
1964
- variation.material.roughness.dispose();
1965
- }
1966
- if (variation.material.ao) {
1967
- variation.material.ao.dispose();
1968
- }
1969
- }
1970
- }
1971
- catch (e) {
1972
- }
1973
- });
1974
- });
1975
- VariationUtils.ClearCache();
1976
- ImageUtils.ClearCache();
1977
- };
1978
- VariationHelper.prototype.loadPart = function (obj, parts, usePbr) {
1979
- if (usePbr === void 0) { usePbr = false; }
1980
- return __awaiter(this, void 0, void 0, function () {
1981
- var len, i, partSettings, partVariation, _a, e_1;
1982
- return __generator(this, function (_b) {
1983
- switch (_b.label) {
1984
- case 0:
1985
- _b.trys.push([0, 9, , 10]);
1986
- len = parts.length;
1987
- i = 0;
1988
- _b.label = 1;
1989
- case 1:
1990
- if (!(i < len)) return [3 /*break*/, 8];
1991
- partSettings = void 0;
1992
- if (!(parts[i].decoNode && parts[i].decoNode.materialUrl && parts[i].decoNode.type === decoNodeType_enum.DecoNodeType.Part)) return [3 /*break*/, 3];
1993
- return [4 /*yield*/, VariationUtils.LoadVariationByUrl(parts[i].decoNode.materialCode, parts[i].decoNode.materialUrl)];
1994
- case 2:
1995
- partSettings = _b.sent();
1996
- _b.label = 3;
1997
- case 3:
1998
- if (!(parts[i].decoNode && parts[i].decoNode.gameObjectName && parts[i].decoNode.type === decoNodeType_enum.DecoNodeType.Part)) return [3 /*break*/, 5];
1999
- return [4 /*yield*/, VariationUtils.LoadVariation(this.assetPath, parts[i].decoNode.gameObjectName || parts[i].decoId)];
2000
- case 4:
2001
- partSettings = _b.sent();
2002
- _b.label = 5;
2003
- case 5:
2004
- if (!partSettings) return [3 /*break*/, 7];
2005
- partVariation = new Variation();
2006
- partVariation.decoId = parseFloat(parts[i].decoNode.id);
2007
- partVariation.brandId = parts[i].decoNode.brandId;
2008
- partVariation.gameObjectName = parts[i].decoNode.gameObjectName;
2009
- _a = partVariation;
2010
- return [4 /*yield*/, AssetUtils.CreateMaterialFromAsset(partSettings)];
2011
- case 6:
2012
- _a.material = _b.sent();
2013
- this._applyMaterialPart(obj, partVariation, parts[i].node, usePbr);
2014
- _b.label = 7;
2015
- case 7:
2016
- i++;
2017
- return [3 /*break*/, 1];
2018
- case 8: return [3 /*break*/, 10];
2019
- case 9:
2020
- e_1 = _b.sent();
2021
- console.error(e_1);
2022
- return [3 /*break*/, 10];
2023
- case 10: return [2 /*return*/];
2024
- }
2025
- });
2026
- });
2027
- };
2028
- VariationHelper.prototype.loadVariation = function (obj, parts, usePbr) {
2029
- if (usePbr === void 0) { usePbr = false; }
2030
- return __awaiter(this, void 0, void 0, function () {
2031
- var len, _loop_1, this_1, i, e_2;
2032
- return __generator(this, function (_a) {
2033
- switch (_a.label) {
2034
- case 0:
2035
- _a.trys.push([0, 5, , 6]);
2036
- len = parts.length;
2037
- _loop_1 = function (i) {
2038
- var variations, lastKnownVariations, variationPromise, _loop_2, j;
2039
- return __generator(this, function (_b) {
2040
- switch (_b.label) {
2041
- case 0:
2042
- variations = parts[i].variations;
2043
- if (!variations || variations.length === 0) {
2044
- if (this_1._getLastKnownVariations(parts[i].nodeId)) {
2045
- parts[i].variations = this_1._getLastKnownVariations(parts[i].nodeId);
2046
- this_1._applyVariations(obj, parts[i], usePbr);
2047
- return [2 /*return*/, "continue"];
2048
- }
2049
- else {
2050
- return [2 /*return*/, "continue"];
2051
- }
2052
- }
2053
- lastKnownVariations = [];
2054
- variationPromise = [];
2055
- _loop_2 = function (j) {
2056
- var variationsName = '';
2057
- if (variations[j].materialCode && variations[j].materialUrl) {
2058
- variationsName = variations[j].materialCode;
2059
- }
2060
- else {
2061
- variationsName = variations[j].gameObjectName || parts[i].decoId;
2062
- }
2063
- variationPromise.push(this_1.loadTheVariation(variationsName).then(function (variationSettings) {
2064
- var newVariation = new Variation();
2065
- newVariation.decoId = variations[j].constructor.name === 'Variation' ? variations[j].decoId : parseFloat(variations[j].id);
2066
- newVariation.node = variations[j].constructor.name === 'Variation' ? variations[j].node : variations[j].nodeId;
2067
- newVariation.brandId = variations[j].brandId;
2068
- newVariation.optionText = variations[j].optionText;
2069
- newVariation.gameObjectName = variations[j].gameObjectName;
2070
- newVariation.supplierArticleNr = variations[j].supplierArticleNr;
2071
- newVariation.materialId = variations[j].materialId;
2072
- newVariation.material = variationSettings ? variationSettings.material : null;
2073
- lastKnownVariations.push(newVariation);
2074
- }));
2075
- };
2076
- for (j = 0; j < variations.length; j++) {
2077
- _loop_2(j);
2078
- }
2079
- return [4 /*yield*/, Promise.all(variationPromise)];
2080
- case 1:
2081
- _b.sent();
2082
- this_1._setLastKnownVariations(parts[i].nodeId + "_" + parts[i].node, lastKnownVariations);
2083
- parts[i].variations = lastKnownVariations;
2084
- this_1._applyVariations(obj, parts[i], usePbr);
2085
- return [2 /*return*/];
2086
- }
2087
- });
2088
- };
2089
- this_1 = this;
2090
- i = 0;
2091
- _a.label = 1;
2092
- case 1:
2093
- if (!(i < len)) return [3 /*break*/, 4];
2094
- return [5 /*yield**/, _loop_1(i)];
2095
- case 2:
2096
- _a.sent();
2097
- _a.label = 3;
2098
- case 3:
2099
- i++;
2100
- return [3 /*break*/, 1];
2101
- case 4: return [3 /*break*/, 6];
2102
- case 5:
2103
- e_2 = _a.sent();
2104
- this.log(e_2.message);
2105
- return [3 /*break*/, 6];
2106
- case 6: return [2 /*return*/];
2107
- }
2108
- });
2109
- });
2110
- };
2111
- VariationHelper.prototype.get = function (id) {
2112
- var len = this._variations.length;
2113
- for (var i = 0; i < len; i++) {
2114
- if (this._variations[i].id && this._variations[i].id === id) {
2115
- return this._variations[i];
2116
- }
2117
- }
2118
- };
2119
- VariationHelper.prototype.set = function (variations) {
2120
- var idx = this._variations.findIndex(function (v) { return v.id === variations.id; });
2121
- if (idx > -1) {
2122
- this._variations[idx] = variations;
2123
- }
2124
- else {
2125
- this._variations.push(variations);
2126
- }
2127
- };
2128
- VariationHelper.prototype.preloadVariations = function (fileNames) {
2129
- var _this = this;
2130
- fileNames.forEach(function (node) {
2131
- if (node.materialUrl) {
2132
- if (node.materialCode && !_this.get(node.materialCode)) {
2133
- var settings_1 = new VariationSettings();
2134
- settings_1.id = node.materialCode;
2135
- settings_1.loading = true;
2136
- _this._variations.push(settings_1);
2137
- VariationUtils.LoadVariationByUrl(node.materialCode, node.materialUrl).then(function (variationSettings) {
2138
- settings_1.loading = false;
2139
- if (variationSettings) {
2140
- settings_1.copyFrom(variationSettings);
2141
- }
2142
- settings_1.loaded.next(settings_1);
2143
- }).catch(function (err) {
2144
- console.error("Error loading variation " + node.materialCode + ":", err);
2145
- settings_1.loading = false;
2146
- settings_1.loaded.next(null);
2147
- });
2148
- }
2149
- }
2150
- else if (node.gameObjectName) {
2151
- if (!_this.get(node.gameObjectName)) {
2152
- var settings_2 = new VariationSettings();
2153
- settings_2.id = node.gameObjectName;
2154
- settings_2.loading = true;
2155
- _this._variations.push(settings_2);
2156
- VariationUtils.LoadVariation(_this.assetPath, node.gameObjectName).then(function (variationSettings) {
2157
- settings_2.loading = false;
2158
- if (variationSettings) {
2159
- settings_2.copyFrom(variationSettings);
2160
- }
2161
- settings_2.loaded.next(settings_2);
2162
- }).catch(function (err) {
2163
- console.error("Error loading variation " + node.gameObjectName + ":", err);
2164
- settings_2.loading = false;
2165
- settings_2.loaded.next(null);
2166
- });
2167
- }
2168
- }
2169
- });
2170
- };
2171
- VariationHelper.prototype.loadTheVariation = function (fileName) {
2172
- return __awaiter(this, void 0, void 0, function () {
2173
- var settings, sett;
2174
- return __generator(this, function (_a) {
2175
- switch (_a.label) {
2176
- case 0:
2177
- if (!fileName) {
2178
- return [2 /*return*/, null];
2179
- }
2180
- settings = this.get(fileName);
2181
- if (!settings) {
2182
- return [2 /*return*/, null];
2183
- }
2184
- if (!settings.loading) return [3 /*break*/, 3];
2185
- return [4 /*yield*/, this._waitForVariationToLoad(settings)];
2186
- case 1:
2187
- sett = _a.sent();
2188
- return [4 /*yield*/, this._loadMaterialFromSettings(sett)];
2189
- case 2:
2190
- _a.sent();
2191
- return [2 /*return*/, sett];
2192
- case 3: return [4 /*yield*/, this._loadMaterialFromSettings(settings)];
2193
- case 4:
2194
- _a.sent();
2195
- return [2 /*return*/, settings];
2196
- }
2197
- });
2198
- });
2199
- };
2200
- VariationHelper.prototype._loadMaterialFromSettings = function (settings) {
2201
- return __awaiter(this, void 0, void 0, function () {
2202
- var _a;
2203
- return __generator(this, function (_b) {
2204
- switch (_b.label) {
2205
- case 0:
2206
- if (!settings) return [3 /*break*/, 2];
2207
- if (!!settings.material) return [3 /*break*/, 2];
2208
- _a = settings;
2209
- return [4 /*yield*/, AssetUtils.CreateMaterialFromAsset(settings)];
2210
- case 1:
2211
- _a.material = _b.sent();
2212
- _b.label = 2;
2213
- case 2: return [2 /*return*/];
2214
- }
2215
- });
2216
- });
2217
- };
2218
- VariationHelper.prototype._waitForVariationToLoad = function (settings) {
2219
- return new Promise(function (resolve) {
2220
- settings.loaded.pipe(operators.filter(function (value) { return value !== undefined; }), operators.take(1)).subscribe(function (value) {
2221
- resolve(value);
2222
- });
2223
- });
2224
- };
2225
- VariationHelper.prototype._getChildrenFilterByProp = function (obj, userDataObjectProp, prop, value) {
2226
- return obj.children.filter(function (child) {
2227
- return child.userData &&
2228
- child.userData.hasOwnProperty(userDataObjectProp) &&
2229
- child.userData[userDataObjectProp].hasOwnProperty(prop) &&
2230
- child.userData[userDataObjectProp][prop] === value;
2231
- });
2232
- };
2233
- VariationHelper.prototype._applyMaterialPart = function (obj, partMaterial, nodeId, usePbr) {
2234
- var _this = this;
2235
- if (usePbr === void 0) { usePbr = false; }
2236
- var children = this._getChildrenFilterByProp(obj, 'selection', 'node', nodeId);
2237
- var len = children.length;
2238
- for (var i = 0; i < len; i++) {
2239
- var child = children[i];
2240
- if (child !== null && child !== undefined) {
2241
- child.traverse(function (mesh) {
2242
- if ((mesh instanceof THREE.Mesh || mesh.constructor.name === 'Mesh') && partMaterial) {
2243
- if (Array.isArray(mesh.material)) { // multimaterial support
2244
- for (var j = 0, jlen = mesh.material.length; j < jlen; j++) {
2245
- if (mesh.material[j].name.toLowerCase().indexOf('fixed_frame') !== -1) {
2246
- mesh.material[j] = _this._setMeshMaterialFromVariation(mesh.material[j].name, partMaterial, usePbr);
2247
- }
2248
- }
2249
- }
2250
- else {
2251
- if (mesh.material.name && mesh.material.name.toLowerCase().indexOf('fixed_frame') !== -1) {
2252
- mesh.material = _this._setMeshMaterialFromVariation(mesh.material.name, partMaterial, usePbr);
2253
- }
2254
- }
2255
- }
2256
- });
2257
- }
2258
- }
2259
- };
2260
- VariationHelper.prototype._applyVariations = function (obj, part, usePbr) {
2261
- var _this = this;
2262
- if (usePbr === void 0) { usePbr = false; }
2263
- var children = this._getChildrenFilterByProp(obj, 'selection', 'node', part.node);
2264
- var len = children.length;
2265
- for (var i = 0; i < len; i++) {
2266
- var child = children[i];
2267
- if (child !== null && child !== undefined) {
2268
- child.traverse(function (mesh) {
2269
- if ((mesh instanceof THREE.Mesh || mesh.constructor.name === 'Mesh') && part.variations && part.variations.length > 0 && mesh.name.toLowerCase().indexOf('c_')) {
2270
- for (var j = 0; j < part.variations.length; j++) {
2271
- var variation = part.variations[j];
2272
- if (variation.material) {
2273
- var materialToSearch = !!variation.materialId ? variation.materialId.toLowerCase() : 'default';
2274
- if (Array.isArray(mesh.material)) { // multimaterial support
2275
- for (var m = 0, mlen = mesh.material.length; m < mlen; m++) {
2276
- if (mesh.material[m].name.toLowerCase().indexOf(materialToSearch) !== -1) {
2277
- if ((variation.material instanceof Material || variation.material.constructor.name === 'Material') && variation.material.isMaterial) {
2278
- // it's a THREE.Material
2279
- mesh.material[m] = variation.material;
2280
- if (mesh.material[m].name && (mesh.material[m].name === 'Fixed_Glass' || mesh.material[m].name === 'Default_Glass')) {
2281
- mesh.castShadow = false;
2282
- }
2283
- }
2284
- else {
2285
- mesh.material[m] = _this._setMeshMaterialFromVariation(mesh.material[m].name, variation, usePbr);
2286
- if (mesh.material[m].name && (mesh.material[m].name === 'Fixed_Glass' || mesh.material[m].name === 'Default_Glass')) {
2287
- mesh.castShadow = false;
2288
- }
2289
- }
2290
- }
2291
- }
2292
- }
2293
- else {
2294
- if (mesh.material.name && mesh.material.name.toLowerCase().indexOf(materialToSearch) !== -1) {
2295
- if ((variation.material instanceof Material || variation.material.constructor.name === 'Material') && variation.material.isMaterial) {
2296
- // it's a THREE.Material
2297
- mesh.material = variation.material;
2298
- if (mesh.material.name === 'Fixed_Glass' || mesh.material.name === 'Default_Glass') {
2299
- mesh.castShadow = false;
2300
- }
2301
- }
2302
- else {
2303
- mesh.material = _this._setMeshMaterialFromVariation(mesh.material.name, variation, usePbr);
2304
- if (mesh.material.name === 'Fixed_Glass' || mesh.material.name === 'Default_Glass') {
2305
- mesh.castShadow = false;
2306
- }
2307
- }
2308
- }
2309
- }
2310
- }
2311
- }
2312
- }
2313
- });
2314
- }
2315
- }
2316
- };
2317
- VariationHelper.prototype._setMeshMaterialFromVariation = function (name, variation, usePbr) {
2318
- if (usePbr === void 0) { usePbr = false; }
2319
- var material = variation.material;
2320
- if (material.texture) {
2321
- material.texture.needsUpdate = true;
2322
- material.texture.mapping = THREE.EquirectangularReflectionMapping;
2323
- }
2324
- if (!usePbr) {
2325
- var newMaterial = new THREE.MeshPhongMaterial({
2326
- name: name,
2327
- shininess: material.shininess,
2328
- specular: material.specular,
2329
- map: material.texture,
2330
- normalMap: material.normal
2331
- });
2332
- newMaterial.color.setRGB(0.8, 0.8, 0.8);
2333
- newMaterial.needsUpdate = true;
2334
- return newMaterial;
2335
- }
2336
- if (material.sheen || material.sheenColor || material.reflectivity || material.transmission) { // TODO: Proper check for all unique physical material properties
2337
- var params = {
2338
- // side: material.side ? material.side : FrontSide,
2339
- name: name,
2340
- roughness: material.roughnessValue !== undefined && material.roughnessValue !== null ? material.roughnessValue : 1,
2341
- metalness: material.metalnessValue !== undefined && material.metalnessValue !== null ? material.metalnessValue : 0,
2342
- envMapIntensity: material.envMapIntensity ? material.envMapIntensity : 0.01,
2343
- clearcoatMap: material.clearcoatMap ? material.clearcoatMap : null,
2344
- clearcoatRoughnessMap: material.clearcoatRoughnessMap ? material.clearcoatRoughnessMap : null,
2345
- attenuationDistance: Infinity
2346
- // wireframe: true,
2347
- // opacity: 0.3,
2348
- // transparent: true,
2349
- };
2350
- if (material.displacementValue) {
2351
- params.displacementScale = material.displacementValue;
2352
- }
2353
- if (material.opacity) {
2354
- params.opacity = material.opacity;
2355
- }
2356
- if (material.transparent) {
2357
- params.transparent = material.transparent;
2358
- }
2359
- if (material.emissiveValue) {
2360
- params.emissive = material.emissiveValue;
2361
- }
2362
- if (material.emissiveIntensityValue) {
2363
- params.emissiveIntensity = material.emissiveIntensityValue;
2364
- }
2365
- if (material.texture) {
2366
- params.map = material.texture;
2367
- params.map.needsUpdate = true;
2368
- }
2369
- if (material.ao) {
2370
- params.aoMap = material.ao;
2371
- params.aoMap.needsUpdate = true;
2372
- }
2373
- if (material.roughness) {
2374
- params.roughnessMap = material.roughness;
2375
- params.roughnessMap.needsUpdate = true;
2376
- // material.roughness.magFilter = NearestFilter;
2377
- }
2378
- if (material.metalness) {
2379
- params.metalnessMap = material.metalness;
2380
- params.metalnessMap.needsUpdate = true;
2381
- }
2382
- if (material.normal) {
2383
- params.normalMap = material.normal;
2384
- params.normalMap.needsUpdate = true;
2385
- }
2386
- if (material.displacement) {
2387
- params.displacementMap = material.displacement;
2388
- params.displacementMap.needsUpdate = true;
2389
- }
2390
- if (material.emissive) {
2391
- params.emissiveMap = material.emissive;
2392
- params.emissiveMap.needsUpdate = true;
2393
- }
2394
- if (material.envMap) {
2395
- if (material.envMapIntensity != null || 0) {
2396
- params.envMap = material.envMap;
2397
- params.envMap.needsUpdate = true;
2398
- material.envMap.mapping = THREE.EquirectangularReflectionMapping;
2399
- material.envMap.minFilter = THREE.NearestFilter;
2400
- material.envMap.magFilter = THREE.NearestFilter;
2401
- }
2402
- }
2403
- if (material.reflectivity) {
2404
- params.reflectivity = material.reflectivity;
2405
- }
2406
- if (material.side) {
2407
- params.side = material.side;
2408
- }
2409
- else {
2410
- params.side = THREE.DoubleSide;
2411
- }
2412
- var newMaterial = new THREE.MeshPhysicalMaterial(params);
2413
- newMaterial.color.setRGB(1, 1, 1);
2414
- if (material.sheen) {
2415
- newMaterial.sheen = material.sheen;
2416
- }
2417
- if (material.sheenColor) {
2418
- newMaterial.sheenColor = this._createValidColor(material.sheenColor);
2419
- }
2420
- else {
2421
- // Add fallback for blender render
2422
- newMaterial.sheenColor = new THREE.Color(1, 1, 1);
2423
- }
2424
- if (material.sheenRoughness) {
2425
- newMaterial.sheenRoughness = material.sheenRoughness;
2426
- }
2427
- if (material.sheenColorMap) {
2428
- newMaterial.sheenColorMap = material.sheenColorMap;
2429
- newMaterial.sheenColorMap.needsUpdate = true;
2430
- }
2431
- if (material.sheenRoughnessMap) {
2432
- newMaterial.sheenRoughnessMap = material.sheenRoughnessMap;
2433
- newMaterial.sheenRoughnessMap.needsUpdate = true;
2434
- }
2435
- if (material.transmission) {
2436
- newMaterial.transmission = material.transmission;
2437
- }
2438
- if (material.ior !== undefined && material.ior !== null) {
2439
- newMaterial.ior = material.ior;
2440
- }
2441
- if (material.thickness !== undefined && material.thickness !== null) {
2442
- newMaterial.thickness = material.thickness;
2443
- }
2444
- if (material.specularIntensity !== undefined && material.specularIntensity !== null) {
2445
- newMaterial.specularIntensity = material.specularIntensity;
2446
- }
2447
- if (material.transmissionMap) {
2448
- newMaterial.transmissionMap = material.transmissionMap;
2449
- newMaterial.transmissionMap.needsUpdate = true;
2450
- }
2451
- newMaterial.needsUpdate = true;
2452
- return newMaterial;
2453
- }
2454
- else {
2455
- var params = {
2456
- // side: material.side ? material.side : FrontSide,
2457
- name: name,
2458
- roughness: material.roughnessValue !== undefined && material.roughnessValue !== null ? material.roughnessValue : 1,
2459
- metalness: material.metalnessValue !== undefined && material.metalnessValue !== null ? material.metalnessValue : 0,
2460
- envMapIntensity: material.envMapIntensity ? material.envMapIntensity : 0.01
2461
- // wireframe: true,
2462
- // opacity: 0.3,
2463
- // transparent: true,
2464
- };
2465
- if (material.displacementValue) {
2466
- params.displacementScale = material.displacementValue;
2467
- }
2468
- if (material.opacity) {
2469
- params.opacity = material.opacity;
2470
- }
2471
- if (material.transparent) {
2472
- params.transparent = material.transparent;
2473
- }
2474
- if (material.emissiveValue) {
2475
- params.emissive = material.emissiveValue;
2476
- }
2477
- if (material.emissiveIntensityValue) {
2478
- params.emissiveIntensity = material.emissiveIntensityValue;
2479
- }
2480
- if (material.texture) {
2481
- params.map = material.texture;
2482
- params.map.needsUpdate = true;
2483
- }
2484
- if (material.ao) {
2485
- params.aoMap = material.ao;
2486
- params.aoMap.needsUpdate = true;
2487
- }
2488
- if (material.roughness) {
2489
- params.roughnessMap = material.roughness;
2490
- params.roughnessMap.needsUpdate = true;
2491
- // material.roughness.magFilter = NearestFilter;
2492
- }
2493
- if (material.metalness) {
2494
- params.metalnessMap = material.metalness;
2495
- params.metalnessMap.needsUpdate = true;
2496
- }
2497
- if (material.normal) {
2498
- params.normalMap = material.normal;
2499
- params.normalMap.needsUpdate = true;
2500
- }
2501
- if (material.displacement) {
2502
- params.displacementMap = material.displacement;
2503
- params.displacementMap.needsUpdate = true;
2504
- }
2505
- if (material.emissive) {
2506
- params.emissiveMap = material.emissive;
2507
- params.emissiveMap.needsUpdate = true;
2508
- }
2509
- if (material.envMap) {
2510
- if (material.envMapIntensity != null || 0) {
2511
- params.envMap = material.envMap;
2512
- params.envMap.needsUpdate = true;
2513
- material.envMap.mapping = THREE.EquirectangularReflectionMapping;
2514
- material.envMap.minFilter = THREE.NearestFilter;
2515
- material.envMap.magFilter = THREE.NearestFilter;
2516
- }
2517
- }
2518
- if (material.side) {
2519
- params.side = material.side;
2520
- }
2521
- else {
2522
- params.side = THREE.DoubleSide;
2523
- }
2524
- var newMaterial = new THREE.MeshStandardMaterial(params);
2525
- newMaterial.color.setRGB(1, 1, 1);
2526
- newMaterial.needsUpdate = true;
2527
- return newMaterial;
2528
- }
2529
- };
2530
- VariationHelper.prototype._setLastKnownVariations = function (id, variation) {
2531
- this._lastKnownVariations.set(id, variation);
2532
- };
2533
- VariationHelper.prototype._getLastKnownVariations = function (id) {
2534
- if (this._lastKnownVariations.has(id)) {
2535
- return this._lastKnownVariations.get(id);
2536
- }
2537
- return null;
2538
- };
2539
- VariationHelper.prototype._createValidColor = function (color) {
2540
- if (typeof color === 'string') {
2541
- if (/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(color)) {
2542
- return new THREE.Color("#" + color.replace('#', ''));
2543
- }
2544
- }
2545
- else if (color instanceof THREE.Color || color.constructor.name === 'Color') {
2546
- return color;
2547
- }
2548
- else {
2549
- try {
2550
- return new THREE.Color(color);
2551
- }
2552
- catch (e) {
2553
- return new THREE.Color();
2554
- }
2555
- }
2556
- return new THREE.Color();
2557
- };
2558
- return VariationHelper;
2559
- }(BaseUtils));
2560
-
2561
- var ConfiguratorService = /** @class */ (function () {
2562
- function ConfiguratorService() {
2563
- }
2564
- ConfiguratorService.prototype.initApi = function (options) {
2565
- this._configuratorApi = new configurator.Configurator(options);
2566
- };
2567
- ConfiguratorService.prototype.initNodeInstance = function (goodId) {
2568
- return __awaiter(this, void 0, void 0, function () {
2569
- return __generator(this, function (_a) {
2570
- switch (_a.label) {
2571
- case 0: return [4 /*yield*/, this._configuratorApi.initNodeInstance(goodId)];
2572
- case 1: return [2 /*return*/, _a.sent()];
2573
- }
2574
- });
2575
- });
2576
- };
2577
- ConfiguratorService.prototype.setInstanceToConfigure = function (id, showLoader) {
2578
- if (showLoader === void 0) { showLoader = false; }
2579
- return __awaiter(this, void 0, void 0, function () {
2580
- return __generator(this, function (_a) {
2581
- switch (_a.label) {
2582
- case 0: return [4 /*yield*/, this._configuratorApi.setInstanceToConfigure(id, showLoader)];
2583
- case 1: return [2 /*return*/, _a.sent()];
2584
- }
2585
- });
2586
- });
2587
- };
2588
- ConfiguratorService.prototype.getGoodIdFromSku = function (sku, showLoader) {
2589
- if (showLoader === void 0) { showLoader = false; }
2590
- return __awaiter(this, void 0, void 0, function () {
2591
- return __generator(this, function (_a) {
2592
- switch (_a.label) {
2593
- case 0: return [4 /*yield*/, this._configuratorApi.getGoodIdFromSku(sku, showLoader)];
2594
- case 1: return [2 /*return*/, _a.sent()];
2595
- }
2596
- });
2597
- });
2598
- };
2599
- ConfiguratorService.prototype.getArticleQuickSel = function (goodId, showLoader) {
2600
- if (showLoader === void 0) { showLoader = false; }
2601
- return __awaiter(this, void 0, void 0, function () {
2602
- return __generator(this, function (_a) {
2603
- switch (_a.label) {
2604
- case 0: return [4 /*yield*/, this._configuratorApi.getArticleQuickSel(goodId, showLoader)];
2605
- case 1: return [2 /*return*/, _a.sent()];
2606
- }
2607
- });
2608
- });
2609
- };
2610
- ConfiguratorService.prototype.getSelections = function (showLoader, publicationCode) {
2611
- if (showLoader === void 0) { showLoader = false; }
2612
- if (publicationCode === void 0) { publicationCode = 2; }
2613
- return __awaiter(this, void 0, void 0, function () {
2614
- var selections;
2615
- return __generator(this, function (_a) {
2616
- switch (_a.label) {
2617
- case 0: return [4 /*yield*/, this._configuratorApi.getSelections(showLoader)];
2618
- case 1:
2619
- selections = _a.sent();
2620
- if (selections && selections.resultObjects) {
2621
- selections.resultObjects.filter(function (s) {
2622
- (isNill_function.isNill(s.hierarchicalPublicationCode) || ((s.hierarchicalPublicationCode & publicationCode) > 0)) && ((s.nodeType === nodeType_enum.NodeType.Question && (((s.questionPublicationCode & publicationCode) > 0) || isNill_function.isNill(s.questionPublicationCode))) ||
2623
- (s.nodeType === nodeType_enum.NodeType.Answer && (((s.answerPublicationCode & publicationCode) > 0) || isNill_function.isNill(s.answerPublicationCode))));
2624
- });
2625
- }
2626
- return [2 /*return*/, selections];
2627
- }
2628
- });
2629
- });
2630
- };
2631
- ConfiguratorService.prototype.getDecos = function (showLoader) {
2632
- if (showLoader === void 0) { showLoader = false; }
2633
- return __awaiter(this, void 0, void 0, function () {
2634
- return __generator(this, function (_a) {
2635
- switch (_a.label) {
2636
- case 0: return [4 /*yield*/, this._configuratorApi.getDecos(showLoader)];
2637
- case 1: return [2 /*return*/, _a.sent()];
2638
- }
2639
- });
2640
- });
2641
- };
2642
- ConfiguratorService.prototype.getQuestionAndAnswers = function (showLoader, publicationCode) {
2643
- if (showLoader === void 0) { showLoader = false; }
2644
- if (publicationCode === void 0) { publicationCode = 2; }
2645
- return __awaiter(this, void 0, void 0, function () {
2646
- var questionAndAnswers;
2647
- return __generator(this, function (_a) {
2648
- switch (_a.label) {
2649
- case 0: return [4 /*yield*/, this._configuratorApi.getQuestionAndAnswers(showLoader)];
2650
- case 1:
2651
- questionAndAnswers = _a.sent();
2652
- if (questionAndAnswers && questionAndAnswers.answers) {
2653
- questionAndAnswers.answers.filter(function (answer) {
2654
- (notNill_function.notNill(answer.hierarchicalPublicationCode) && (answer.hierarchicalPublicationCode & publicationCode) === 0) ||
2655
- (answer.type === nodeType_enum.NodeType.Question && (answer.questionPublicationCode & publicationCode) === 0 && notNill_function.notNill(answer.questionPublicationCode)) ||
2656
- (answer.type === nodeType_enum.NodeType.Answer && (answer.publicationCode & publicationCode) === 0 && notNill_function.notNill(answer.publicationCode));
2657
- });
2658
- }
2659
- return [2 /*return*/, questionAndAnswers];
2660
- }
2661
- });
2662
- });
2663
- };
2664
- ConfiguratorService.prototype.getSingleImage = function (nodeId, publication, includeMimetype, thumb, showLoader) {
2665
- return __awaiter(this, void 0, void 0, function () {
2666
- return __generator(this, function (_a) {
2667
- switch (_a.label) {
2668
- case 0:
2669
- if (!nodeId) {
2670
- return [2 /*return*/, null];
2671
- }
2672
- return [4 /*yield*/, this._configuratorApi.getSingleImage(nodeId, publication, includeMimetype, thumb, showLoader)];
2673
- case 1: return [2 /*return*/, _a.sent()];
2674
- }
2675
- });
2676
- });
2677
- };
2678
- ConfiguratorService.prototype.selectSelection = function (selection, showLoader) {
2679
- if (showLoader === void 0) { showLoader = false; }
2680
- return __awaiter(this, void 0, void 0, function () {
2681
- return __generator(this, function (_a) {
2682
- switch (_a.label) {
2683
- case 0: return [4 /*yield*/, this._configuratorApi.selectSelection(selection, showLoader)];
2684
- case 1: return [2 /*return*/, _a.sent()];
2685
- }
2686
- });
2687
- });
2688
- };
2689
- ConfiguratorService.prototype.selectAnswer = function (answer, showLoader) {
2690
- if (showLoader === void 0) { showLoader = false; }
2691
- return __awaiter(this, void 0, void 0, function () {
2692
- return __generator(this, function (_a) {
2693
- switch (_a.label) {
2694
- case 0: return [4 /*yield*/, this._configuratorApi.selectAnswer(answer, showLoader)];
2695
- case 1: return [2 /*return*/, _a.sent()];
2696
- }
2697
- });
2698
- });
2699
- };
2700
- return ConfiguratorService;
2701
- }());
2702
-
2703
- var ObjectUtils = /** @class */ (function () {
2704
- function ObjectUtils() {
2705
- }
2706
- ObjectUtils.DisposeNode = function (node) {
2707
- if (node) {
2708
- node.traverse(function (obj) {
2709
- if (obj instanceof THREE.Mesh) {
2710
- if (obj.geometry) {
2711
- obj.geometry.dispose();
2712
- }
2713
- ObjectUtils.DisposeMaterial(obj.material);
2714
- }
2715
- if (typeof obj.dispose === 'function') {
2716
- // @ts-ignore
2717
- obj.dispose();
2718
- }
2719
- });
2720
- }
2721
- };
2722
- ObjectUtils.DisposeMaterial = function (material) {
2723
- var _this = this;
2724
- if (!material) {
2725
- return;
2726
- }
2727
- if (Array.isArray(material)) {
2728
- material.forEach(function (mtrl) {
2729
- _this.materialProps
2730
- .filter(function (mapType) { return mtrl[mapType]; })
2731
- .forEach(function (mapType) { return mtrl[mapType].dispose(); });
2732
- mtrl.dispose(); // disposes any programs associated with the material
2733
- });
2734
- }
2735
- else {
2736
- this.materialProps
2737
- .filter(function (mapType) { return material[mapType] && material[mapType].dispose; })
2738
- .forEach(function (mapType) { return material[mapType].dispose(); });
2739
- if (material.dispose) {
2740
- material.dispose(); // disposes any programs associated with the material
2741
- }
2742
- }
2743
- };
2744
- ObjectUtils.DisposeObject = function (object) {
2745
- var _this = this;
2746
- if (!object) {
2747
- return;
2748
- }
2749
- if (object.children.length) {
2750
- object.children.forEach(function (child) { return _this.DisposeObject(child); });
2751
- }
2752
- this.DisposeNode(object);
2753
- };
2754
- return ObjectUtils;
2755
- }());
2756
- ObjectUtils.materialProps = ['map', 'lightMap', 'bumpMap', 'normalMap', 'specularMap', 'envMap', 'aoMap', 'roughnessMap', 'metalnessMap'];
2757
-
2758
- var Builder = /** @class */ (function () {
2759
- function Builder() {
2760
- this.selectionsReceived = new rxjs.BehaviorSubject([]);
2761
- this.articleLoaded = new rxjs.BehaviorSubject(undefined);
2762
- this.decosReceived = new rxjs.BehaviorSubject([]);
2763
- this.answersReceived = new rxjs.BehaviorSubject([]);
2764
- this.modelLoaded = new rxjs.BehaviorSubject(null);
2765
- this._selections = [];
2766
- this._answers = [];
2767
- this._decos = [];
2768
- this._placedAdjustables = [];
2769
- this._placedAddables = [];
2770
- this._adjustables = [];
2771
- this._addables = [];
2772
- this._imageCache = new Map();
2773
- this._articleCache = new Map();
2774
- }
2775
- Object.defineProperty(Builder.prototype, "debug", {
2776
- get: function () {
2777
- return this._debug;
2778
- },
2779
- set: function (value) {
2780
- if (value) {
2781
- this._debug = value;
2782
- if (this._variationHelper) {
2783
- this._variationHelper.debug = this._debug;
2784
- }
2785
- }
2786
- },
2787
- enumerable: false,
2788
- configurable: true
2789
- });
2790
- Builder.prototype.init = function (scene, options) {
2791
- this._boFactory = new businessObjectFactory.BusinessObjectFactory();
2792
- this._threedUtils = new ThreedUtils();
2793
- this._variationHelper = new VariationHelper();
2794
- this._variationHelper.debug = this._debug;
2795
- if (!scene) {
2796
- throw 'No scene object provided!';
2797
- }
2798
- this._configuratorService = new ConfiguratorService();
2799
- // this._imageCacheService = new ImageCacheService();
2800
- if (options) {
2801
- this._configuratorService.initApi(options);
2802
- }
2803
- this._scene = scene;
2804
- };
2805
- Builder.prototype.buildModel = function (sku, instanceId, goodId) {
2806
- return __awaiter(this, void 0, void 0, function () {
2807
- var promises, build, e_1;
2808
- return __generator(this, function (_a) {
2809
- switch (_a.label) {
2810
- case 0:
2811
- if (!this._scene) {
2812
- return [2 /*return*/];
2813
- }
2814
- _a.label = 1;
2815
- case 1:
2816
- _a.trys.push([1, 9, , 10]);
2817
- return [4 /*yield*/, this._setInstanceId(sku, instanceId, goodId)];
2818
- case 2:
2819
- _a.sent();
2820
- return [4 /*yield*/, this._prepareConfiguration(this._sku, this._goodId)];
2821
- case 3:
2822
- _a.sent();
2823
- if (!this._source) return [3 /*break*/, 7];
2824
- return [4 /*yield*/, this._configuratorService.setInstanceToConfigure(this._instanceId)];
2825
- case 4:
2826
- _a.sent();
2827
- promises = [];
2828
- this._reset();
2829
- promises.push(this.getQuestionAndAnswers());
2830
- promises.push(this._getSelections(this._instanceId));
2831
- promises.push(this._getDecos());
2832
- return [4 /*yield*/, Promise.all(promises)];
2833
- case 5:
2834
- _a.sent();
2835
- if (this._answers.length > 0) {
2836
- return [2 /*return*/];
2837
- }
2838
- this._linkSelectionsAndDecos();
2839
- this._prepareTheSelections();
2840
- this._preloadMaterials();
2841
- return [4 /*yield*/, this._build()];
2842
- case 6:
2843
- build = _a.sent();
2844
- return [2 /*return*/, build];
2845
- case 7: throw 'GLB source not found!';
2846
- case 8: return [3 /*break*/, 10];
2847
- case 9:
2848
- e_1 = _a.sent();
2849
- throw e_1;
2850
- case 10: return [2 /*return*/];
2851
- }
2852
- });
2853
- });
2854
- };
2855
- Builder.prototype.buildModelFromData = function (selections, decos, assetUrl, cdnUrl, schema) {
2856
- return __awaiter(this, void 0, void 0, function () {
2857
- var _this = this;
2858
- return __generator(this, function (_a) {
2859
- return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
2860
- var build, e_2, e_3;
2861
- return __generator(this, function (_a) {
2862
- switch (_a.label) {
2863
- case 0:
2864
- if (!this._scene) {
2865
- reject('no scene provided!');
2866
- }
2867
- _a.label = 1;
2868
- case 1:
2869
- _a.trys.push([1, 14, , 15]);
2870
- this._log('start build', true);
2871
- return [4 /*yield*/, this._downloadAsset(assetUrl, cdnUrl, schema, selections && selections.length > 1 && decos && decos.length > 0)];
2872
- case 2:
2873
- _a.sent();
2874
- _a.label = 3;
2875
- case 3:
2876
- _a.trys.push([3, , 12, 13]);
2877
- if (!this._source) return [3 /*break*/, 10];
2878
- _a.label = 4;
2879
- case 4:
2880
- _a.trys.push([4, 8, , 9]);
2881
- if (!(selections && selections.length > 1 && decos && decos.length > 0)) return [3 /*break*/, 6];
2882
- this._reset();
2883
- this._selections = selections;
2884
- this._decos = decos;
2885
- this._linkSelectionsAndDecos();
2886
- this._prepareTheSelections();
2887
- this._preloadMaterials();
2888
- return [4 /*yield*/, this._build()];
2889
- case 5:
2890
- build = _a.sent();
2891
- resolve(build);
2892
- return [3 /*break*/, 7];
2893
- case 6:
2894
- resolve(this._source); // just return the source for simplicity
2895
- _a.label = 7;
2896
- case 7: return [3 /*break*/, 9];
2897
- case 8:
2898
- e_2 = _a.sent();
2899
- reject(e_2.message);
2900
- return [3 /*break*/, 9];
2901
- case 9:
2902
- {
2903
- }
2904
- return [3 /*break*/, 11];
2905
- case 10:
2906
- if (assetUrl) {
2907
- reject("Error downloading source: " + assetUrl);
2908
- }
2909
- else {
2910
- reject('No 3D source provided!');
2911
- }
2912
- _a.label = 11;
2913
- case 11: return [3 /*break*/, 13];
2914
- case 12:
2915
- this._cleanUp();
2916
- this._log('finish build', true);
2917
- return [7 /*endfinally*/];
2918
- case 13: return [3 /*break*/, 15];
2919
- case 14:
2920
- e_3 = _a.sent();
2921
- reject(e_3);
2922
- return [3 /*break*/, 15];
2923
- case 15: return [2 /*return*/];
2924
- }
2925
- });
2926
- }); })];
2927
- });
2928
- });
2929
- };
2930
- Builder.prototype.initNodeInstance = function (goodId) {
2931
- return this._configuratorService.initNodeInstance(goodId);
2932
- };
2933
- Builder.prototype.destroy = function () {
2934
- this._threedUtils.clearCache();
2935
- this._variationHelper.clearCache();
2936
- };
2937
- Builder.prototype.selectSelection = function (selection) {
2938
- return __awaiter(this, void 0, void 0, function () {
2939
- return __generator(this, function (_a) {
2940
- switch (_a.label) {
2941
- case 0: return [4 /*yield*/, this._configuratorService.selectSelection(selection, false)];
2942
- case 1:
2943
- _a.sent();
2944
- return [4 /*yield*/, this.getQuestionAndAnswers()];
2945
- case 2:
2946
- _a.sent();
2947
- return [2 /*return*/];
2948
- }
2949
- });
2950
- });
2951
- };
2952
- Builder.prototype.getQuestionAndAnswers = function (publicationCode) {
2953
- return __awaiter(this, void 0, void 0, function () {
2954
- var questionsAndAnswers;
2955
- return __generator(this, function (_a) {
2956
- switch (_a.label) {
2957
- case 0: return [4 /*yield*/, this._configuratorService.getQuestionAndAnswers(false, publicationCode)];
2958
- case 1:
2959
- questionsAndAnswers = _a.sent();
2960
- this._answers = questionsAndAnswers && questionsAndAnswers.answers ? questionsAndAnswers.answers : [];
2961
- this.answersReceived.next(this._answers);
2962
- return [2 /*return*/];
2963
- }
2964
- });
2965
- });
2966
- };
2967
- Builder.prototype.selectAnswer = function (answer) {
2968
- return __awaiter(this, void 0, void 0, function () {
2969
- return __generator(this, function (_a) {
2970
- switch (_a.label) {
2971
- case 0: return [4 /*yield*/, this._configuratorService.selectAnswer(answer, false)];
2972
- case 1:
2973
- _a.sent();
2974
- return [4 /*yield*/, this.getQuestionAndAnswers()];
2975
- case 2:
2976
- _a.sent();
2977
- if (this._answers && this._answers.length === 0) {
2978
- this._build();
2979
- }
2980
- return [2 /*return*/];
2981
- }
2982
- });
2983
- });
2984
- };
2985
- Builder.prototype.getImageForSelectionOrAnswer = function (object) {
2986
- var _this = this;
2987
- var includeMimeType = true, thumb = true;
2988
- return new Promise(function (resolve, reject) {
2989
- if (object && object.nodeId) {
2990
- if (!_this._imageCache.has(object.nodeId)) {
2991
- return _this._configuratorService.getSingleImage(object.nodeId, 4, includeMimeType, thumb, true)
2992
- .then(function (responseData) {
2993
- var base64 = _this._handleResponseData(includeMimeType, thumb, responseData);
2994
- _this._imageCache.set(object.nodeId, base64);
2995
- resolve(base64);
2996
- }).catch(function () {
2997
- reject();
2998
- });
2999
- }
3000
- else {
3001
- resolve(_this._imageCache.get(object.nodeId));
3002
- }
3003
- }
3004
- else {
3005
- reject();
3006
- }
3007
- });
3008
- };
3009
- Builder.prototype._cleanUp = function () {
3010
- this._sku = undefined;
3011
- this._goodId = undefined;
3012
- this._instanceId = undefined;
3013
- this._variationHelper.clearCache();
3014
- };
3015
- Builder.prototype._handleResponseData = function (includeMimetype, thumb, responseData) {
3016
- if (responseData && responseData.resultObject) {
3017
- if (responseData.resultObject.filePath !== null && responseData.resultObject.filePath !== "") {
3018
- return ImageUtils.getFixedImageFilepathUrl(responseData.resultObject.filePath);
3019
- }
3020
- else {
3021
- if (includeMimetype) {
3022
- return ImageUtils.getDocBodyWithMimeTypeDefinition(responseData.resultObject.fileName, thumb ? responseData.resultObject.thumbnailBody : responseData.resultObject.documentBody);
3023
- }
3024
- else {
3025
- return thumb ? responseData.resultObject.thumbnailBody : responseData.resultObject.documentBody;
3026
- }
3027
- }
3028
- }
3029
- else {
3030
- return '';
3031
- }
3032
- };
3033
- Builder.prototype._preloadMaterials = function () {
3034
- if (this._decos && this._decos.length) {
3035
- var materials = __spreadArray([], __read(new Set(this._decos
3036
- .filter(function (d) { return (d.gameObjectName || d.materialUrl) && d.type === decoNodeType_enum.DecoNodeType.Variation; })
3037
- .map(function (d) { return d; }))));
3038
- this._variationHelper.preloadVariations(materials);
3039
- }
3040
- };
3041
- Builder.prototype._setInstanceId = function (sku, instanceId, goodId) {
3042
- return __awaiter(this, void 0, void 0, function () {
3043
- var result;
3044
- return __generator(this, function (_a) {
3045
- switch (_a.label) {
3046
- case 0:
3047
- if (!(!instanceId && !this._instanceId)) return [3 /*break*/, 4];
3048
- if (!!goodId) return [3 /*break*/, 2];
3049
- return [4 /*yield*/, this._getGoodIdFromSku(sku)];
3050
- case 1:
3051
- goodId = _a.sent();
3052
- _a.label = 2;
3053
- case 2:
3054
- this._goodId = goodId;
3055
- return [4 /*yield*/, this.initNodeInstance(this._goodId)];
3056
- case 3:
3057
- result = _a.sent();
3058
- if (result && result.resultObject) {
3059
- this._instanceId = result.resultObject;
3060
- }
3061
- else {
3062
- throw 'Failed to initialize node instance';
3063
- }
3064
- return [3 /*break*/, 5];
3065
- case 4:
3066
- if (!this._instanceId) {
3067
- this._instanceId = instanceId;
3068
- }
3069
- _a.label = 5;
3070
- case 5:
3071
- if (!this._sku) {
3072
- this._sku = sku;
3073
- }
3074
- return [2 /*return*/];
3075
- }
3076
- });
3077
- });
3078
- };
3079
- Builder.prototype._prepareConfiguration = function (sku, goodId) {
3080
- return __awaiter(this, void 0, void 0, function () {
3081
- var article;
3082
- return __generator(this, function (_a) {
3083
- switch (_a.label) {
3084
- case 0: return [4 /*yield*/, this._getArticle(sku, goodId)];
3085
- case 1:
3086
- article = _a.sent();
3087
- if (!(article && article.assetUrl)) return [3 /*break*/, 3];
3088
- if (article.contentDeliveryUrl) {
3089
- this._variationHelper.assetPath =
3090
- article.contentDeliveryUrl +
3091
- (article.contentDeliveryUrl.endsWith('/') ? '' : '/') +
3092
- (article.distSchema ? article.distSchema : 'UP_DBA');
3093
- }
3094
- return [4 /*yield*/, this._downloadAsset(article.assetUrl, article.contentDeliveryUrl, article.distSchema)];
3095
- case 2:
3096
- _a.sent();
3097
- _a.label = 3;
3098
- case 3: return [2 /*return*/];
3099
- }
3100
- });
3101
- });
3102
- };
3103
- Builder.prototype._downloadAsset = function (assetUrl, cdnUrl, schema, setVisibleFalse) {
3104
- if (setVisibleFalse === void 0) { setVisibleFalse = true; }
3105
- return __awaiter(this, void 0, void 0, function () {
3106
- var _a;
3107
- return __generator(this, function (_b) {
3108
- switch (_b.label) {
3109
- case 0:
3110
- _a = this;
3111
- return [4 /*yield*/, this._threedUtils.download3DSource(assetUrl, setVisibleFalse)
3112
- .catch(function (error) {
3113
- throw error;
3114
- })];
3115
- case 1:
3116
- _a._source = _b.sent();
3117
- if (cdnUrl) {
3118
- this._variationHelper.assetPath =
3119
- cdnUrl +
3120
- (cdnUrl.endsWith('/') ? '' : '/') +
3121
- (schema ? schema : 'UP_DBA');
3122
- }
3123
- return [2 /*return*/];
3124
- }
3125
- });
3126
- });
3127
- };
3128
- Builder.prototype._build = function () {
3129
- return __awaiter(this, void 0, void 0, function () {
3130
- var adjustables, obj, connected, i, len, adjustable, ii;
3131
- return __generator(this, function (_a) {
3132
- switch (_a.label) {
3133
- case 0:
3134
- adjustables = this._getAdjustables();
3135
- if (adjustables && adjustables.length === 0 && this._selections && this._selections.length > 0) { // check if article has a gameObject
3136
- if (this._selections[0].nodeType === nodeType_enum.NodeType.Article && this._selections[0].gameObject) {
3137
- adjustables.push(this._selections[0]);
3138
- }
3139
- }
3140
- if (!(adjustables && adjustables.length > 0)) return [3 /*break*/, 2];
3141
- obj = new THREE__namespace.Object3D();
3142
- obj.visible = false; // no need to render visualy
3143
- this._scene.add(obj);
3144
- connected = false;
3145
- this._log('build main model');
3146
- for (i = 0, len = adjustables.length; i < len; i++) {
3147
- adjustable = this._createAdjustable(obj, adjustables[i]);
3148
- if (adjustable) {
3149
- for (ii = this._placedAdjustables.length - 1; ii >= 0; ii--) {
3150
- if (SceneUtils.TrySelectorConnection(this._scene, obj, this._placedAdjustables[ii], adjustable, i === 1)) {
3151
- this._placedAdjustables[ii].visible = true;
3152
- adjustable.visible = true;
3153
- connected = true;
3154
- break;
3155
- }
3156
- connected = false;
3157
- }
3158
- }
3159
- if (!connected && this._placedAdjustables.length > 1) {
3160
- console.warn('No connection found for: ', adjustable.name);
3161
- }
3162
- }
3163
- this._log('place addables');
3164
- this._placeAddables(obj);
3165
- this._log('update pivot');
3166
- this._updatePivot(obj);
3167
- this._log('load variations');
3168
- return [4 /*yield*/, this._loadVariations(obj)];
3169
- case 1:
3170
- _a.sent();
3171
- // this._variationHelper.clearCache();
3172
- this._log('remove from scene');
3173
- this._scene.remove(obj);
3174
- ObjectUtils.DisposeObject(this._source);
3175
- // this._cleanUp();
3176
- this._log('ready!');
3177
- this.modelLoaded.next(obj);
3178
- return [2 /*return*/, obj];
3179
- case 2: throw 'No adjustables found!';
3180
- }
3181
- });
3182
- });
3183
- };
3184
- Builder.prototype._prepareTheSelections = function () {
3185
- var _this = this;
3186
- if (!this._selections || !this._selections.length) {
3187
- return;
3188
- }
3189
- var selections = this._selections.slice();
3190
- var selectionOfArticle = selections.find(function (s) { return s.nodeType === nodeType_enum.NodeType.Article; });
3191
- var adjustableSelections = selections.filter(function (s) { return s.addAdjust === '2'; });
3192
- var isArticleWithMaterial = adjustableSelections.length === 0 &&
3193
- selectionOfArticle.gameObject &&
3194
- selectionOfArticle.gameObject.length > 0;
3195
- // get generic variations
3196
- var globalVariations = this._selections
3197
- .filter(function (s) { return (s.generic || adjustableSelections.length === 1) && s.decoNode.variation && !s.decoNode.type; })
3198
- .map(function (value, index, array) {
3199
- // find selection of variation
3200
- var sel = _this._selections.find(function (s) { return s.artNodeIdDeco === value.decoNode.variation.parentId; });
3201
- if (sel) {
3202
- value.decoNode.variation.supplierArticleNr = sel.supplierArticleNr;
3203
- }
3204
- value.decoNode.variation.materialId = _this._getMaterialIdFromParent(value.node);
3205
- return value.decoNode.variation;
3206
- });
3207
- // commented out for the moment
3208
- // globalVariations.forEach(g => {
3209
- // const parentIdx = selections.findIndex(s => s.decoNode && s.decoNode.id === g.parentId);
3210
- // if (parentIdx) { // remove parent selection
3211
- // selections.splice(parentIdx, 1);
3212
- // }
3213
- // const idx = selections.findIndex(s => s.decoNode && s.decoNode.id === g.id);
3214
- // if (idx) { // move generic variations to top
3215
- // const selection = selections[idx];
3216
- // selections.splice(idx, 1);
3217
- // selections.unshift(selection);
3218
- // }
3219
- // });
3220
- // const usedVariations: FurniturePartVariation[] = [];
3221
- var globalVariationsRewrite = true;
3222
- var len = selections.length;
3223
- var lastAdded;
3224
- var lastAdjustable;
3225
- var newPart = false;
3226
- var previousPresLevel = -1;
3227
- var positioning;
3228
- var optionText;
3229
- var _loop_1 = function (i) {
3230
- var selection = selections[i];
3231
- if (selection.presentationLevel === 1) {
3232
- positioning = selection.hdecoPositioning;
3233
- optionText = selection.question;
3234
- }
3235
- if (selection.presentationLevel > previousPresLevel) {
3236
- selection.hdecoPositioning = selection.hdecoPositioning || positioning;
3237
- }
3238
- if (selection.decoNode) {
3239
- if (selection.decoNode.type === decoNodeType_enum.DecoNodeType.Variation) {
3240
- var decoNode_1 = selection.decoNode;
3241
- decoNode_1.optionText = optionText;
3242
- // find selection of variation and set materialId in case of multimaterial
3243
- decoNode_1.materialId = this_1._getMaterialIdFromParent(decoNode_1.nodeId);
3244
- if (lastAdded) {
3245
- if (newPart) {
3246
- if (decoNode_1.materialId) {
3247
- if (!lastAdded.variations.find(function (v) { return v.id === decoNode_1.id; })) {
3248
- lastAdded.variations.push(decoNode_1);
3249
- }
3250
- }
3251
- else {
3252
- lastAdded.variations = [decoNode_1];
3253
- }
3254
- }
3255
- else {
3256
- if (!lastAdded.variations.find(function (v) { return v.id === decoNode_1.id; })) {
3257
- lastAdded.variations.push(decoNode_1);
3258
- }
3259
- }
3260
- newPart = false;
3261
- }
3262
- else {
3263
- if (globalVariationsRewrite) {
3264
- globalVariations.length = 0;
3265
- globalVariationsRewrite = false;
3266
- }
3267
- if (!globalVariations.find(function (v) { return v.id === decoNode_1.id; })) {
3268
- globalVariations.push(decoNode_1);
3269
- }
3270
- }
3271
- // const variation: FurniturePartVariation = new FurniturePartVariation();
3272
- // variation.BrandId = selection.decoNode.brandId;
3273
- // variation.Description = selection.decoNode.gameObjectName;
3274
- // variation.MaterialId = (selection.decoNode as any).materialId;
3275
- // variation.SupplierArticleNr = (selection.decoNode as any).supplierArticleNr;
3276
- // usedVariations.push(variation);
3277
- }
3278
- else if ((selection.decoNode.type === decoNodeType_enum.DecoNodeType.Part &&
3279
- typeof selection.decoNode.gameObjectName === 'string' &&
3280
- selection.decoNode.gameObjectName.length) || (isArticleWithMaterial)) {
3281
- if (selection.decoNode.kind === decoNodeKind_enum.DecoNodeKind.Adjustable || (isArticleWithMaterial)) {
3282
- selection.variations = globalVariations;
3283
- this_1._adjustables.push(selection);
3284
- if (!lastAdded || (lastAdded.nodeId !== selection.nodeId || lastAdded.node !== selection.node)) {
3285
- newPart = true;
3286
- }
3287
- lastAdded = selection;
3288
- lastAdjustable = selection;
3289
- }
3290
- else if (selection.decoNode.kind === decoNodeKind_enum.DecoNodeKind.Addable) {
3291
- selection.variations = lastAdjustable ? lastAdjustable.variations : globalVariations;
3292
- if (lastAdjustable) {
3293
- lastAdjustable.addables.push(selection);
3294
- }
3295
- this_1._addables.push(selection);
3296
- if (!lastAdded || (lastAdded.nodeId !== selection.nodeId || lastAdded.node !== selection.node)) {
3297
- newPart = true;
3298
- }
3299
- lastAdded = selection;
3300
- }
3301
- }
3302
- }
3303
- previousPresLevel = selection.presentationLevel;
3304
- };
3305
- var this_1 = this;
3306
- for (var i = 0; i < len; i++) {
3307
- _loop_1(i);
3308
- }
3309
- // this._upsertFurniture(this.activeInstance,
3310
- // {Variations: usedVariations});
3311
- };
3312
- /**
3313
- * Returns the materialId of the parent up the tree until presentionlevel 1 is reached
3314
- * @param id
3315
- * @private
3316
- */
3317
- Builder.prototype._getMaterialIdFromParent = function (id) {
3318
- if (this._selections) {
3319
- var idx = this._selections.findIndex(function (s) { return s.node === id; });
3320
- var currentLevel = 999;
3321
- if (idx > -1) {
3322
- for (var i = idx; i > 0; i--) {
3323
- var selection = this._selections[i];
3324
- if (selection.presentationLevel >= currentLevel) {
3325
- break;
3326
- }
3327
- currentLevel = selection.presentationLevel;
3328
- if (selection.hdecoGameObject) {
3329
- return selection.hdecoGameObject;
3330
- }
3331
- }
3332
- }
3333
- }
3334
- return undefined;
3335
- };
3336
- Builder.prototype._createAdjustable = function (parent, adj) {
3337
- var obj = this._source ? this._source.getObjectByName(adj.decoNode.gameObjectName || adj.gameObject) : null;
3338
- if (!obj) {
3339
- // in case of glb files, the importer removes dots from names
3340
- var name = adj.decoNode.gameObjectName.replace(/[.]/g, '');
3341
- obj = this._source ? this._source.getObjectByName(name) : null;
3342
- if (!obj) {
3343
- console.warn("No object with name " + adj.decoNode.gameObjectName + " found!");
3344
- return null;
3345
- }
3346
- }
3347
- var adjustable = obj.clone();
3348
- adjustable.name = this._createUniqueName(parent, obj);
3349
- adjustable.userData.selection = adj;
3350
- adjustable.position.set(0, 0, 0);
3351
- adjustable.traverse(function (c) {
3352
- c.visible = !c.name.toLowerCase().startsWith('c_');
3353
- });
3354
- parent.add(adjustable);
3355
- // the object being added to the customFloorGroup is being recreated so we loose the reference
3356
- // therefor we need to retrieve the created object again
3357
- adjustable = parent.getObjectByName(adjustable.name);
3358
- this._placedAdjustables.push(adjustable);
3359
- return adjustable;
3360
- };
3361
- Builder.prototype._createAddable = function (parent, add, part2, part1) {
3362
- var obj = this._source.getObjectByName(add.decoNode.gameObjectName);
3363
- if (!obj) {
3364
- return null;
3365
- }
3366
- // const selection: Selection = this._getSelectionFromId(adj.artNodeIdDeco);
3367
- var addable = obj.clone();
3368
- addable.name = this._createUniqueName(parent, obj);
3369
- addable.userData.selection = add;
3370
- addable.position.set(0, 0, 0);
3371
- addable.visible = true;
3372
- if (part1 && part2) {
3373
- parent.add(addable);
3374
- this._placedAddables.push(addable);
3375
- return addable;
3376
- }
3377
- return addable;
3378
- };
3379
- Builder.prototype._placeAddables = function (parent) {
3380
- var _this = this;
3381
- var len = this._placedAdjustables.length;
3382
- for (var i = 0; i < len; i++) {
3383
- if (this._placedAdjustables[i].userData.hasOwnProperty('selection') && this._placedAdjustables[i].userData.selection) {
3384
- var adjustableSelection = this._placedAdjustables[i].userData.selection;
3385
- if (adjustableSelection) {
3386
- var lena = adjustableSelection.addables.length;
3387
- var conAddable = void 0;
3388
- for (var ia = 0; ia < lena; ia++) {
3389
- SceneUtils.TrySelectorConnection(this._scene, parent, this._placedAdjustables[i], adjustableSelection.addables[ia], false, function (add, part2, part1) { return _this._createAddable(parent, add, part2, part1); });
3390
- if (conAddable) {
3391
- SceneUtils.TrySelectorConnection(this._scene, parent, conAddable, adjustableSelection.addables[ia], false, function (add, part2, part1) { return _this._createAddable(parent, add, part2, part1); });
3392
- }
3393
- conAddable = this._placedAddables[this._placedAddables.length - 1];
3394
- }
3395
- }
3396
- }
3397
- }
3398
- };
3399
- Builder.prototype._createUniqueName = function (parent, obj) {
3400
- var iteration = 0;
3401
- var name = obj.name;
3402
- var existingObj = parent.getObjectByName(name);
3403
- while (existingObj) {
3404
- iteration++;
3405
- name = obj.name + (iteration !== 0 ? ('_' + iteration) : '');
3406
- existingObj = parent.getObjectByName(name);
3407
- }
3408
- return name;
3409
- };
3410
- Builder.prototype._getGoodIdFromSku = function (sku) {
3411
- return __awaiter(this, void 0, void 0, function () {
3412
- var response;
3413
- return __generator(this, function (_a) {
3414
- switch (_a.label) {
3415
- case 0: return [4 /*yield*/, this._configuratorService.getGoodIdFromSku(sku, false)];
3416
- case 1:
3417
- response = _a.sent();
3418
- if (response && response.validationResult && response.validationResult.success && response.resultObject) {
3419
- return [2 /*return*/, response.resultObject];
3420
- }
3421
- return [2 /*return*/];
3422
- }
3423
- });
3424
- });
3425
- };
3426
- Builder.prototype._getArticle = function (sku, goodId) {
3427
- return __awaiter(this, void 0, void 0, function () {
3428
- var article$1, articleResponse, obj;
3429
- return __generator(this, function (_a) {
3430
- switch (_a.label) {
3431
- case 0:
3432
- if (this._articleCache.has(sku)) {
3433
- this.articleLoaded.next(this._articleCache.get(sku));
3434
- return [2 /*return*/, this._articleCache.get(sku)];
3435
- }
3436
- if (!!goodId) return [3 /*break*/, 2];
3437
- return [4 /*yield*/, this._getGoodIdFromSku(sku)
3438
- .catch(function (error) {
3439
- throw "Article with sku " + sku + " not found!";
3440
- })];
3441
- case 1:
3442
- goodId = _a.sent();
3443
- _a.label = 2;
3444
- case 2: return [4 /*yield*/, this._configuratorService.getArticleQuickSel(goodId, false)];
3445
- case 3:
3446
- articleResponse = _a.sent();
3447
- if (articleResponse && articleResponse.validationResult && articleResponse.validationResult.success && articleResponse.resultObject) {
3448
- if (articleResponse.resultObject.hasOwnProperty('oArticle')) {
3449
- obj = Array.isArray(articleResponse.resultObject['oArticle']) ? articleResponse.resultObject['oArticle'][0] : articleResponse.resultObject['oArticle'];
3450
- article$1 = this._boFactory.makeWithRawBackendData(article.Article, obj);
3451
- }
3452
- else {
3453
- article$1 = this._boFactory.makeWithRawBackendData(article.Article, articleResponse.resultObject);
3454
- }
3455
- }
3456
- this._articleCache.set(sku, article$1);
3457
- this.articleLoaded.next(article$1);
3458
- return [2 /*return*/, article$1];
3459
- }
3460
- });
3461
- });
3462
- };
3463
- Builder.prototype._getSelections = function (instanceId, publicationCode) {
3464
- return __awaiter(this, void 0, void 0, function () {
3465
- var selectionResponse;
3466
- return __generator(this, function (_a) {
3467
- switch (_a.label) {
3468
- case 0:
3469
- this._selections = [];
3470
- return [4 /*yield*/, this._configuratorService.getSelections(false, publicationCode)];
3471
- case 1:
3472
- selectionResponse = _a.sent();
3473
- if (selectionResponse && selectionResponse.resultObjects && selectionResponse.resultObjects.length > 0) {
3474
- this._selections = this._boFactory.makeBOArrayFromRawBackendDataArray(selection.Selection, selectionResponse.resultObjects);
3475
- this._selections.forEach(function (s) { return s.instanceId = instanceId; });
3476
- // const filtered: Selection[] = this._selections.filter(s => s.nodeType !== NodeType.Article && s.presentationLevel === 1);
3477
- this.selectionsReceived.next(this._selections);
3478
- }
3479
- else {
3480
- throw 'No selections found!';
3481
- }
3482
- return [2 /*return*/];
3483
- }
3484
- });
3485
- });
3486
- };
3487
- Builder.prototype._getDecos = function () {
3488
- return __awaiter(this, void 0, void 0, function () {
3489
- var decosResponse;
3490
- return __generator(this, function (_a) {
3491
- switch (_a.label) {
3492
- case 0:
3493
- this._decos = [];
3494
- return [4 /*yield*/, this._configuratorService.getDecos(false)];
3495
- case 1:
3496
- decosResponse = _a.sent();
3497
- if (decosResponse && decosResponse.resultObjects && decosResponse.resultObjects.length > 0) {
3498
- this._decos = this._boFactory.makeBOArrayFromRawBackendDataArray(decoNode.DecoNode, decosResponse.resultObjects);
3499
- this.decosReceived.next(this._decos);
3500
- }
3501
- else {
3502
- throw 'No deconodes found!';
3503
- }
3504
- return [2 /*return*/];
3505
- }
3506
- });
3507
- });
3508
- };
3509
- Builder.prototype._linkSelectionsAndDecos = function () {
3510
- var _this = this;
3511
- if (!this._selections || !this._selections.length) {
3512
- return;
3513
- }
3514
- var len = this._selections.length;
3515
- var _loop_2 = function (i) {
3516
- // const id: string = this.selections[i].artNodeIdDeco;
3517
- var deco = this_2._decos.find(function (d) { return d.nodeId === _this._selections[i].node; });
3518
- if (!deco) {
3519
- deco = new decoNode.DecoNode();
3520
- }
3521
- if (deco.type !== decoNodeType_enum.DecoNodeType.Variation) {
3522
- var variation = this_2._getVariations().find(function (v) { return v.parentId === _this._selections[i].artNodeIdDeco; });
3523
- if (variation) {
3524
- deco.variation = variation;
3525
- }
3526
- }
3527
- this_2._selections[i].decoNode = deco;
3528
- };
3529
- var this_2 = this;
3530
- for (var i = 0; i < len; i++) {
3531
- _loop_2(i);
3532
- }
3533
- };
3534
- Builder.prototype._getVariations = function () {
3535
- if (this._decos && this._decos.length) {
3536
- return this._decos.filter(function (deco) {
3537
- return deco.type === decoNodeType_enum.DecoNodeType.Variation;
3538
- });
3539
- }
3540
- return [];
3541
- };
3542
- Builder.prototype._loadVariations = function (obj) {
3543
- return __awaiter(this, void 0, void 0, function () {
3544
- return __generator(this, function (_a) {
3545
- switch (_a.label) {
3546
- case 0:
3547
- this._log('load variation for parts');
3548
- return [4 /*yield*/, this._variationHelper.loadPart(obj, this._adjustables, true)];
3549
- case 1:
3550
- _a.sent();
3551
- this._log('load variation for adjustables');
3552
- return [4 /*yield*/, this._variationHelper.loadVariation(obj, this._adjustables, true)];
3553
- case 2:
3554
- _a.sent();
3555
- this._log('load variation for addables');
3556
- return [4 /*yield*/, this._variationHelper.loadVariation(obj, this._addables, true)];
3557
- case 3:
3558
- _a.sent();
3559
- this._log('load variation clear cache');
3560
- this._variationHelper.clearCache();
3561
- this._log('load variations done');
3562
- return [2 /*return*/];
3563
- }
3564
- });
3565
- });
3566
- };
3567
- Builder.prototype._getAdjustables = function () {
3568
- if (!this._selections || !this._selections.length) {
3569
- return [];
3570
- }
3571
- return this._selections.filter(function (s) {
3572
- var node = s.decoNode;
3573
- return node && node.gameObjectName && node.type === decoNodeType_enum.DecoNodeType.Part && node.kind === decoNodeKind_enum.DecoNodeKind.Adjustable;
3574
- });
3575
- };
3576
- Builder.prototype._updatePivot = function (obj) {
3577
- var boundingBox = new THREE__namespace.Box3().setFromObject(obj);
3578
- var bbCenterPivot = new THREE__namespace.Vector3();
3579
- boundingBox.getCenter(bbCenterPivot);
3580
- var delta = new THREE__namespace.Vector3().sub(bbCenterPivot).setY(Math.abs(Math.min(boundingBox.min.y, 0)));
3581
- obj.children.forEach(function (child) {
3582
- child.position.add(delta);
3583
- });
3584
- obj.updateWorldMatrix(false, true);
3585
- };
3586
- Builder.prototype._reset = function () {
3587
- this._placedAddables.length = 0;
3588
- this._placedAdjustables.length = 0;
3589
- this._adjustables.length = 0;
3590
- this._addables.length = 0;
3591
- // this._prepareTheSelections();
3592
- };
3593
- Builder.prototype._log = function (message, force) {
3594
- if (force === void 0) { force = false; }
3595
- if (this.debug) {
3596
- this.debug(message);
3597
- console.log(new Date(), message);
3598
- }
3599
- };
3600
- return Builder;
3601
- }());
3602
- Builder.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function Builder_Factory() { return new Builder(); }, token: Builder, providedIn: "root" });
3603
- Builder.decorators = [
3604
- { type: i0.Injectable, args: [{
3605
- providedIn: "root"
3606
- },] }
3607
- ];
3608
- Builder.ctorParameters = function () { return []; };
3609
-
3610
- var AnswersComponent = /** @class */ (function () {
3611
- function AnswersComponent() {
3612
- this.answers = [];
3613
- this.answerClick = new i0.EventEmitter();
3614
- }
3615
- return AnswersComponent;
3616
- }());
3617
- AnswersComponent.decorators = [
3618
- { type: i0.Component, args: [{
3619
- selector: "answers",
3620
- 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 ",
3621
- styles: [".ione-configurator .rp-answers-slideout{position:absolute;top:0;right:0;width:400px;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 lightgray;padding:10px;display:flex;flex-direction:row;border-radius:3px;margin-bottom:3px;box-shadow:2px 1px #d3d3d380;background:white}.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:bold;color:#1a1a1a}.ione-configurator .answer{font-size:12px;font-style:italic;margin-top:3px}.ione-configurator .collapse-wrapper{display:block}.ione-configurator .collapse-content{display:block}.ione-configurator .collapse-handle{position:absolute;top:10px;right:12px;border:solid black;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:-moz-fit-content;height:fit-content;background:transparent;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 lightgray;padding:10px;display:flex;flex-direction:row;border-radius:3px;margin-bottom:3px;box-shadow:2px 1px #d3d3d380;background:white}.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;align-self:center}.ione-configurator .title-wrapper{display:flex;flex-direction:column}.ione-configurator .answer-title-wrapper{text-align:center;align-self:center;margin-left:14px}\n"]
3622
- },] }
3623
- ];
3624
- AnswersComponent.ctorParameters = function () { return []; };
3625
- AnswersComponent.propDecorators = {
3626
- answers: [{ type: i0.Input }],
3627
- selectionTitle: [{ type: i0.Input }],
3628
- answerClick: [{ type: i0.Output }]
3629
- };
3630
-
3631
- var AnswerComponent = /** @class */ (function () {
3632
- function AnswerComponent(_builder) {
3633
- this._builder = _builder;
3634
- }
3635
- Object.defineProperty(AnswerComponent.prototype, "showing", {
3636
- set: function (value) {
3637
- this.answer.imageData = '';
3638
- if (value && this.answer.answer !== 'Skip / Cancel') {
3639
- this._loadThumbnail(this.answer);
3640
- }
3641
- else {
3642
- this.answer.imageData = null;
3643
- }
3644
- },
3645
- enumerable: false,
3646
- configurable: true
3647
- });
3648
- AnswerComponent.prototype.ngOnInit = function () {
3649
- };
3650
- AnswerComponent.prototype._loadThumbnail = function (answer) {
3651
- return __awaiter(this, void 0, void 0, function () {
3652
- return __generator(this, function (_a) {
3653
- switch (_a.label) {
3654
- case 0: return [4 /*yield*/, this._builder.getImageForSelectionOrAnswer(answer).then(function (imageSrc) {
3655
- answer.imageData = imageSrc === "" ? null : imageSrc;
3656
- })];
3657
- case 1:
3658
- _a.sent();
3659
- return [2 /*return*/];
3660
- }
3661
- });
3662
- });
3663
- };
3664
- return AnswerComponent;
3665
- }());
3666
- AnswerComponent.decorators = [
3667
- { type: i0.Component, args: [{
3668
- selector: 'answer',
3669
- 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 ",
3670
- animations: [
3671
- animations.trigger('answerAppear', [
3672
- animations.state('void', animations.style({ 'background': '#dbdbdb' })),
3673
- animations.state('white', animations.style({ 'background': 'white' })),
3674
- animations.transition('void <=> *', animations.animate(500))
3675
- ])
3676
- ],
3677
- styles: [".ione-configurator .rp-answers-slideout{position:absolute;top:0;right:0;width:400px;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 lightgray;padding:10px;display:flex;flex-direction:row;border-radius:3px;margin-bottom:3px;box-shadow:2px 1px #d3d3d380;background:white}.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:bold;color:#1a1a1a}.ione-configurator .answer{font-size:12px;font-style:italic;margin-top:3px}.ione-configurator .collapse-wrapper{display:block}.ione-configurator .collapse-content{display:block}.ione-configurator .collapse-handle{position:absolute;top:10px;right:12px;border:solid black;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:-moz-fit-content;height:fit-content;background:transparent;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 lightgray;padding:10px;display:flex;flex-direction:row;border-radius:3px;margin-bottom:3px;box-shadow:2px 1px #d3d3d380;background:white}.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;align-self:center}.ione-configurator .title-wrapper{display:flex;flex-direction:column}.ione-configurator .answer-title-wrapper{text-align:center;align-self:center;margin-left:14px}\n"]
3678
- },] }
3679
- ];
3680
- AnswerComponent.ctorParameters = function () { return [
3681
- { type: Builder }
3682
- ]; };
3683
- AnswerComponent.propDecorators = {
3684
- answer: [{ type: i0.Input }],
3685
- showing: [{ type: i0.Input }]
3686
- };
3687
-
3688
- var VisibilityObserverMasterDirective = /** @class */ (function () {
3689
- // I initialize the intersection observer parent directive.
3690
- function VisibilityObserverMasterDirective() {
3691
- var _this = this;
3692
- // As each observable child attaches itself to the parent observer, we need to
3693
- // map Elements to Callbacks so that when an Element's intersection changes,
3694
- // we'll know which callback to invoke. For this, we'll use an ES6 Map.
3695
- this._mapping = new Map();
3696
- this._observer = new IntersectionObserver(function (entries) {
3697
- var e_1, _a;
3698
- try {
3699
- for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
3700
- var entry = entries_1_1.value;
3701
- var callback = _this._mapping.get(entry.target);
3702
- if (callback) {
3703
- callback(entry.isIntersecting);
3704
- }
3705
- }
3706
- }
3707
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3708
- finally {
3709
- try {
3710
- if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
3711
- }
3712
- finally { if (e_1) throw e_1.error; }
3713
- }
3714
- }, {
3715
- // This classifies the "intersection" as being a bit outside the
3716
- // viewport. The intent here is give the elements a little time to react
3717
- // to the change before the element is actually visible to the user.
3718
- rootMargin: '300px 0px 300px 0px'
3719
- });
3720
- }
3721
- // I get called once when the host element is being destroyed.
3722
- VisibilityObserverMasterDirective.prototype.ngOnDestroy = function () {
3723
- this._mapping.clear();
3724
- this._observer.disconnect();
3725
- };
3726
- // ---
3727
- // PUBLIC METHODS.
3728
- // ---
3729
- // I add the given Element for intersection observation. When the intersection status
3730
- // changes, the given callback is invoked with the new status.
3731
- VisibilityObserverMasterDirective.prototype.add = function (element, callback) {
3732
- this._mapping.set(element, callback);
3733
- this._observer.observe(element);
3734
- };
3735
- // I remove the given Element from intersection observation.
3736
- VisibilityObserverMasterDirective.prototype.remove = function (element) {
3737
- this._mapping.delete(element);
3738
- this._observer.unobserve(element);
3739
- };
3740
- return VisibilityObserverMasterDirective;
3741
- }());
3742
- VisibilityObserverMasterDirective.decorators = [
3743
- { type: i0.Directive, args: [{
3744
- selector: '[visibilityObserverMaster]'
3745
- },] }
3746
- ];
3747
- VisibilityObserverMasterDirective.ctorParameters = function () { return []; };
3748
-
3749
- var VisibilityObserverDirective = /** @class */ (function () {
3750
- // I initialize the intersection observer directive.
3751
- function VisibilityObserverDirective(parent, elementRef) {
3752
- this.observerEnabled = false;
3753
- // These are just some human-friendly constants to make the HTML template a bit more
3754
- // readable when being consumed as part of SWTCH/CASE statements.
3755
- this.IS_INTERSECTING = true;
3756
- this.IS_NOT_INTERSECTING = false;
3757
- this._parent = parent;
3758
- this._elementRef = elementRef;
3759
- // By default, we're going to assume that the host element is NOT intersecting.
3760
- // Then, we'll use the IntersectionObserver to asynchronously check for changes
3761
- // in viewport visibility.
3762
- this.isIntersecting = false;
3763
- }
3764
- // ---
3765
- // PUBLIC METHODS.
3766
- // ---
3767
- // I get called once when the host element is being destroyed.
3768
- VisibilityObserverDirective.prototype.ngOnDestroy = function () {
3769
- this._parent.remove(this._elementRef.nativeElement);
3770
- this._elementRef = undefined;
3771
- };
3772
- // I get called once after the inputs have been bound for the first time.
3773
- VisibilityObserverDirective.prototype.ngOnInit = function () {
3774
- var _this = this;
3775
- // In this demo, instead of using an IntersectionObserver per Element, we're
3776
- // going to use a shared observer in the parent element. However, we're still
3777
- // going to use a CALLBACK style approach so that we're only reducing the number
3778
- // of IntersectionObserver instances, not the number of Function calls.
3779
- if (this.observerEnabled) {
3780
- this._parent.add(this._elementRef.nativeElement, function (isIntersecting) {
3781
- _this.isIntersecting = isIntersecting;
3782
- if (_this.isIntersecting) {
3783
- _this._parent.remove(_this._elementRef.nativeElement);
3784
- }
3785
- });
3786
- }
3787
- };
3788
- return VisibilityObserverDirective;
3789
- }());
3790
- VisibilityObserverDirective.decorators = [
3791
- { type: i0.Directive, args: [{
3792
- selector: '[visibilityObserver]',
3793
- exportAs: 'intersection'
3794
- },] }
3795
- ];
3796
- VisibilityObserverDirective.ctorParameters = function () { return [
3797
- { type: VisibilityObserverMasterDirective },
3798
- { type: i0.ElementRef }
3799
- ]; };
3800
- VisibilityObserverDirective.propDecorators = {
3801
- observerEnabled: [{ type: i0.Input }]
3802
- };
3803
-
3804
- var LoaderComponent = /** @class */ (function () {
3805
- function LoaderComponent() {
3806
- }
3807
- return LoaderComponent;
3808
- }());
3809
- LoaderComponent.decorators = [
3810
- { type: i0.Component, args: [{
3811
- selector: 'rp-loader',
3812
- 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 ",
3813
- styles: [":host{-webkit-user-select:none;user-select:none;pointer-events:none}:host .loader-wrapper{z-index:1100;position:absolute;width:54px;height:54px}:host .loader-wrapper svg{width:100%;height:100%}:host .loader-wrapper svg .ripple1{transform-origin:center;animation:ripple 1.5s infinite}:host .loader-wrapper svg .ripple2{transform-origin:center;animation:ripple 1.5s infinite .4s}@keyframes ripple{0%{transform:scale(0);opacity:1}to{transform:scale(1);opacity:0}}\n"]
3814
- },] }
3815
- ];
3816
-
3817
- var SharedModule = /** @class */ (function () {
3818
- function SharedModule() {
3819
- }
3820
- return SharedModule;
3821
- }());
3822
- SharedModule.decorators = [
3823
- { type: i0.NgModule, args: [{
3824
- imports: [
3825
- common.CommonModule
3826
- ],
3827
- declarations: [
3828
- LoaderComponent
3829
- ],
3830
- exports: [
3831
- LoaderComponent
3832
- ]
3833
- },] }
3834
- ];
3835
-
3836
- var AnswersModule = /** @class */ (function () {
3837
- function AnswersModule() {
3838
- }
3839
- return AnswersModule;
3840
- }());
3841
- AnswersModule.decorators = [
3842
- { type: i0.NgModule, args: [{
3843
- imports: [
3844
- common.CommonModule,
3845
- SharedModule
3846
- ],
3847
- declarations: [
3848
- AnswersComponent,
3849
- AnswerComponent,
3850
- VisibilityObserverDirective,
3851
- VisibilityObserverMasterDirective
3852
- ],
3853
- exports: [
3854
- AnswersComponent
3855
- ]
3856
- },] }
3857
- ];
3858
-
3859
- var SelectionViewModel = /** @class */ (function () {
3860
- function SelectionViewModel() {
3861
- this.children = [];
3862
- this.expanded = false;
3863
- this.thumbnail = '';
3864
- }
3865
- return SelectionViewModel;
3866
- }());
3867
- var SelectionsComponent = /** @class */ (function () {
3868
- function SelectionsComponent(_builder) {
3869
- this._builder = _builder;
3870
- this.selectionClick = new i0.EventEmitter();
3871
- this.selectionViewModels = [];
3872
- }
3873
- Object.defineProperty(SelectionsComponent.prototype, "selections", {
3874
- set: function (value) {
3875
- this._prepareSelections(value);
3876
- this._loadThumbnails();
3877
- },
3878
- enumerable: false,
3879
- configurable: true
3880
- });
3881
- SelectionsComponent.prototype.expandClicked = function (selectionViewModel, mouseEvent) {
3882
- mouseEvent.preventDefault();
3883
- mouseEvent.stopImmediatePropagation();
3884
- selectionViewModel.expanded = !selectionViewModel.expanded;
3885
- };
3886
- SelectionsComponent.prototype.selectSelection = function (selection, mouseEvent) {
3887
- mouseEvent.preventDefault();
3888
- mouseEvent.stopImmediatePropagation();
3889
- this.selectionClick.next(selection);
3890
- };
3891
- SelectionsComponent.prototype._loadThumbnails = function () {
3892
- return __awaiter(this, void 0, void 0, function () {
3893
- var _this = this;
3894
- return __generator(this, function (_a) {
3895
- if (this.selectionViewModels.length > 0) {
3896
- this.selectionViewModels.forEach(function (viewModel) { return __awaiter(_this, void 0, void 0, function () {
3897
- return __generator(this, function (_a) {
3898
- switch (_a.label) {
3899
- case 0: return [4 /*yield*/, this._builder.getImageForSelectionOrAnswer(viewModel.selection).then(function (imageSrc) {
3900
- viewModel.thumbnail = imageSrc === "" ? null : imageSrc;
3901
- })];
3902
- case 1:
3903
- _a.sent();
3904
- return [2 /*return*/];
3905
- }
3906
- });
3907
- }); });
3908
- }
3909
- return [2 /*return*/];
3910
- });
3911
- });
3912
- };
3913
- SelectionsComponent.prototype._prepareSelections = function (value) {
3914
- var _this = this;
3915
- this.selectionViewModels.length = 0;
3916
- var selectionViewModel;
3917
- value.forEach(function (s) {
3918
- if (s.presentationLevel === 1) {
3919
- selectionViewModel = new SelectionViewModel();
3920
- selectionViewModel.selection = s;
3921
- _this.selectionViewModels.push(selectionViewModel);
3922
- }
3923
- else if (s.presentationLevel > 1) {
3924
- if (selectionViewModel) {
3925
- selectionViewModel.children.push(s);
3926
- }
3927
- }
3928
- });
3929
- };
3930
- return SelectionsComponent;
3931
- }());
3932
- SelectionsComponent.decorators = [
3933
- { type: i0.Component, args: [{
3934
- selector: "selections",
3935
- 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 ",
3936
- animations: [
3937
- animations.trigger('showHideChildren', [
3938
- animations.state('void', animations.style({ 'height': '0' })),
3939
- animations.state('*', animations.style({ 'height': '*' })),
3940
- animations.transition('void <=> *', animations.animate(200))
3941
- ])
3942
- ],
3943
- styles: [".ione-configurator .rp-answers-slideout{position:absolute;top:0;right:0;width:400px;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 lightgray;padding:10px;display:flex;flex-direction:row;border-radius:3px;margin-bottom:3px;box-shadow:2px 1px #d3d3d380;background:white}.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:bold;color:#1a1a1a}.ione-configurator .answer{font-size:12px;font-style:italic;margin-top:3px}.ione-configurator .collapse-wrapper{display:block}.ione-configurator .collapse-content{display:block}.ione-configurator .collapse-handle{position:absolute;top:10px;right:12px;border:solid black;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:-moz-fit-content;height:fit-content;background:transparent;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 lightgray;padding:10px;display:flex;flex-direction:row;border-radius:3px;margin-bottom:3px;box-shadow:2px 1px #d3d3d380;background:white}.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;align-self:center}.ione-configurator .title-wrapper{display:flex;flex-direction:column}.ione-configurator .answer-title-wrapper{text-align:center;align-self:center;margin-left:14px}\n"]
3944
- },] }
3945
- ];
3946
- SelectionsComponent.ctorParameters = function () { return [
3947
- { type: Builder }
3948
- ]; };
3949
- SelectionsComponent.propDecorators = {
3950
- selections: [{ type: i0.Input }],
3951
- selectionClick: [{ type: i0.Output }]
3952
- };
3953
-
3954
- var SelectionsModule = /** @class */ (function () {
3955
- function SelectionsModule() {
3956
- }
3957
- return SelectionsModule;
3958
- }());
3959
- SelectionsModule.decorators = [
3960
- { type: i0.NgModule, args: [{
3961
- imports: [
3962
- common.CommonModule,
3963
- SharedModule
3964
- ],
3965
- declarations: [
3966
- SelectionsComponent
3967
- ],
3968
- exports: [
3969
- SelectionsComponent
3970
- ]
3971
- },] }
3972
- ];
3973
-
3974
- /**
3975
- * Generated bundle index. Do not edit.
3976
- */
3977
-
3978
- exports.AnswersComponent = AnswersComponent;
3979
- exports.AnswersModule = AnswersModule;
3980
- exports.Builder = Builder;
3981
- exports.ConfiguratorService = ConfiguratorService;
3982
- exports.SelectionsComponent = SelectionsComponent;
3983
- exports.SelectionsModule = SelectionsModule;
3984
- exports["ɵa"] = SharedModule;
3985
- exports["ɵb"] = LoaderComponent;
3986
- exports["ɵc"] = AnswerComponent;
3987
- exports["ɵd"] = VisibilityObserverDirective;
3988
- exports["ɵe"] = VisibilityObserverMasterDirective;
3989
-
3990
- Object.defineProperty(exports, '__esModule', { value: true });
3991
-
3992
- }));
3993
- //# sourceMappingURL=colijnit-configurator.umd.js.map