@combeenation/3d-viewer 4.0.0-alpha9 → 4.0.0-beta4

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 (105) hide show
  1. package/README.md +112 -111
  2. package/dist/lib-cjs/api/classes/animationInterface.d.ts +8 -8
  3. package/dist/lib-cjs/api/classes/animationInterface.js +1 -1
  4. package/dist/lib-cjs/api/classes/dottedPath.d.ts +79 -79
  5. package/dist/lib-cjs/api/classes/dottedPath.js +190 -190
  6. package/dist/lib-cjs/api/classes/element.d.ts +125 -130
  7. package/dist/lib-cjs/api/classes/element.js +682 -739
  8. package/dist/lib-cjs/api/classes/element.js.map +1 -1
  9. package/dist/lib-cjs/api/classes/elementParameterizable.d.ts +14 -14
  10. package/dist/lib-cjs/api/classes/elementParameterizable.js +134 -134
  11. package/dist/lib-cjs/api/classes/event.d.ts +312 -326
  12. package/dist/lib-cjs/api/classes/event.js +357 -371
  13. package/dist/lib-cjs/api/classes/event.js.map +1 -1
  14. package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
  15. package/dist/lib-cjs/api/classes/eventBroadcaster.js +53 -53
  16. package/dist/lib-cjs/api/classes/parameter.d.ts +165 -259
  17. package/dist/lib-cjs/api/classes/parameter.js +267 -387
  18. package/dist/lib-cjs/api/classes/parameter.js.map +1 -1
  19. package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
  20. package/dist/lib-cjs/api/classes/parameterObservable.js +126 -101
  21. package/dist/lib-cjs/api/classes/parameterObservable.js.map +1 -1
  22. package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -15
  23. package/dist/lib-cjs/api/classes/parameterizable.js +149 -149
  24. package/dist/lib-cjs/api/classes/placementAnimation.d.ts +38 -38
  25. package/dist/lib-cjs/api/classes/placementAnimation.js +138 -138
  26. package/dist/lib-cjs/api/classes/variant.d.ts +190 -224
  27. package/dist/lib-cjs/api/classes/variant.js +873 -1137
  28. package/dist/lib-cjs/api/classes/variant.js.map +1 -1
  29. package/dist/lib-cjs/api/classes/variantInstance.d.ts +41 -45
  30. package/dist/lib-cjs/api/classes/variantInstance.js +98 -108
  31. package/dist/lib-cjs/api/classes/variantInstance.js.map +1 -1
  32. package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -17
  33. package/dist/lib-cjs/api/classes/variantParameterizable.js +92 -92
  34. package/dist/lib-cjs/api/classes/viewer.d.ts +128 -131
  35. package/dist/lib-cjs/api/classes/viewer.js +486 -538
  36. package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
  37. package/dist/lib-cjs/api/classes/viewerLight.d.ts +65 -66
  38. package/dist/lib-cjs/api/classes/viewerLight.js +322 -389
  39. package/dist/lib-cjs/api/classes/viewerLight.js.map +1 -1
  40. package/dist/lib-cjs/api/internal/debugViewer.d.ts +13 -13
  41. package/dist/lib-cjs/api/internal/debugViewer.js +87 -87
  42. package/dist/lib-cjs/api/internal/lensRendering.d.ts +8 -8
  43. package/dist/lib-cjs/api/internal/lensRendering.js +11 -11
  44. package/dist/lib-cjs/api/internal/sceneSetup.d.ts +6 -10
  45. package/dist/lib-cjs/api/internal/sceneSetup.js +227 -231
  46. package/dist/lib-cjs/api/internal/sceneSetup.js.map +1 -1
  47. package/dist/lib-cjs/api/manager/animationManager.d.ts +29 -29
  48. package/dist/lib-cjs/api/manager/animationManager.js +121 -121
  49. package/dist/lib-cjs/api/manager/sceneManager.d.ts +32 -32
  50. package/dist/lib-cjs/api/manager/sceneManager.js +132 -132
  51. package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +90 -90
  52. package/dist/lib-cjs/api/manager/variantInstanceManager.js +321 -321
  53. package/dist/lib-cjs/api/store/specStorage.d.ts +24 -24
  54. package/dist/lib-cjs/api/store/specStorage.js +51 -51
  55. package/dist/lib-cjs/api/util/babylonHelper.d.ts +125 -175
  56. package/dist/lib-cjs/api/util/babylonHelper.js +368 -520
  57. package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
  58. package/dist/lib-cjs/api/util/globalTypes.d.ts +279 -321
  59. package/dist/lib-cjs/api/util/globalTypes.js +1 -1
  60. package/dist/lib-cjs/api/util/resourceHelper.d.ts +51 -26
  61. package/dist/lib-cjs/api/util/resourceHelper.js +243 -237
  62. package/dist/lib-cjs/api/util/resourceHelper.js.map +1 -1
  63. package/dist/lib-cjs/api/util/stringHelper.d.ts +9 -9
  64. package/dist/lib-cjs/api/util/stringHelper.js +25 -25
  65. package/dist/lib-cjs/buildinfo.json +3 -3
  66. package/dist/lib-cjs/index.d.ts +46 -48
  67. package/dist/lib-cjs/index.js +82 -86
  68. package/dist/lib-cjs/index.js.map +1 -1
  69. package/dist/webpack-stats.json +0 -0
  70. package/package.json +83 -83
  71. package/src/api/classes/animationInterface.ts +11 -11
  72. package/src/api/classes/dottedPath.ts +189 -189
  73. package/src/api/classes/element.ts +617 -635
  74. package/src/api/classes/{parameterizable.ts → elementParameterizable.ts} +78 -89
  75. package/src/api/classes/event.ts +355 -370
  76. package/src/api/classes/eventBroadcaster.ts +54 -54
  77. package/src/api/classes/parameter.ts +277 -408
  78. package/src/api/classes/parameterObservable.ts +121 -99
  79. package/src/api/classes/placementAnimation.ts +133 -133
  80. package/src/api/classes/variant.ts +670 -806
  81. package/src/api/classes/variantInstance.ts +81 -88
  82. package/src/api/classes/viewer.ts +421 -473
  83. package/src/api/internal/debugViewer.ts +81 -81
  84. package/src/api/internal/lensRendering.ts +10 -10
  85. package/src/api/internal/sceneSetup.ts +204 -194
  86. package/src/api/manager/animationManager.ts +116 -116
  87. package/src/api/manager/sceneManager.ts +105 -105
  88. package/src/api/manager/variantInstanceManager.ts +236 -236
  89. package/src/api/store/specStorage.ts +53 -53
  90. package/src/api/util/babylonHelper.ts +392 -553
  91. package/src/api/util/globalTypes.ts +318 -369
  92. package/src/api/util/resourceHelper.ts +187 -157
  93. package/src/buildinfo.json +2 -2
  94. package/src/commonjs.tsconfig.json +13 -13
  95. package/src/declaration.tsconfig.json +10 -10
  96. package/src/dev.ts +46 -44
  97. package/src/es6.tsconfig.json +13 -13
  98. package/src/index.ts +87 -91
  99. package/src/pagesconfig.json +57 -52
  100. package/src/tsconfig.json +43 -43
  101. package/src/tsconfig.types.json +9 -9
  102. package/src/types.d.ts +4 -4
  103. package/src/api/classes/variantParameterizable.ts +0 -73
  104. package/src/api/classes/viewerLight.ts +0 -330
  105. package/src/api/util/stringHelper.ts +0 -26
@@ -1,740 +1,683 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Element = void 0;
4
- var tslib_1 = require("tslib");
5
- var highlightLayer_1 = require("@babylonjs/core/Layers/highlightLayer");
6
- var material_1 = require("@babylonjs/core/Materials/material");
7
- var standardMaterial_1 = require("@babylonjs/core/Materials/standardMaterial");
8
- var dynamicTexture_1 = require("@babylonjs/core/Materials/Textures/dynamicTexture");
9
- var math_color_1 = require("@babylonjs/core/Maths/math.color");
10
- var abstractMesh_1 = require("@babylonjs/core/Meshes/abstractMesh");
11
- var instancedMesh_1 = require("@babylonjs/core/Meshes/instancedMesh");
12
- var mesh_1 = require("@babylonjs/core/Meshes/mesh");
13
- var transformNode_1 = require("@babylonjs/core/Meshes/transformNode");
14
- var lodash_es_1 = require("lodash-es");
15
- var babylonHelper_1 = require("../util/babylonHelper");
16
- var resourceHelper_1 = require("../util/resourceHelper");
17
- var variantParameterizable_1 = require("./../classes/variantParameterizable");
18
- var dottedPath_1 = require("./dottedPath");
19
- var parameter_1 = require("./parameter");
20
- /**
21
- * An {@link Element} of a {@link Variant}. Acts as a container for diverse definitions. Lives only in the context of a
22
- * {@link Variant}.
23
- *
24
- * When used in typings, refer to via its alias {@link VariantElement} to prevent name clashes with the web APIs
25
- * [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) class
26
- */
27
- var Element = /** @class */ (function (_super) {
28
- tslib_1.__extends(Element, _super);
29
- /**
30
- * Constructor.
31
- */
32
- function Element(variant, name) {
33
- var _a;
34
- var _this = _super.call(this, variant, name) || this;
35
- _this.variant = variant;
36
- _this.name = name;
37
- _this.nodes = [];
38
- _this._dottedNodes = new Map();
39
- if ((_a = process.env.NODE_ENV) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('dev')) {
40
- _this.assertPathDefinitions();
41
- }
42
- var nodes = _this.variant.inheritedNodes.map(function (node) { return babylonHelper_1.cloneTransformNode(node, _this.filterNode.bind(_this)); });
43
- _this.nodes = nodes.filter(function (node) { return !!node; });
44
- _this._dottedNodes = babylonHelper_1.mapToDottedNodes(_this.nodes, function (node) { return node instanceof transformNode_1.TransformNode; });
45
- _this.addParameterObservers();
46
- return _this;
47
- }
48
- /**
49
- * Creates an {@link Element} with given name.
50
- */
51
- Element.create = function (variant, name) {
52
- return tslib_1.__awaiter(this, void 0, void 0, function () {
53
- return tslib_1.__generator(this, function (_a) {
54
- return [2 /*return*/, new Element(variant, name)];
55
- });
56
- });
57
- };
58
- Object.defineProperty(Element.prototype, "dottedPath", {
59
- /**
60
- * The {@link DottedPath} in the built tree of {@link Element}s.
61
- * E.g. "_.top-1.sub-2.sub-sub-3.el-1"
62
- */
63
- get: function () {
64
- return dottedPath_1.DottedPath.create(this.variant.dottedPath).addPart(this.name);
65
- },
66
- enumerable: false,
67
- configurable: true
68
- });
69
- Object.defineProperty(Element.prototype, "id", {
70
- /**
71
- * The id representing a {@link DottedPath}.
72
- */
73
- get: function () {
74
- var dottedPath = dottedPath_1.DottedPath.create(this.dottedPath);
75
- dottedPath.shiftPart(); // remove root
76
- return dottedPath.path;
77
- },
78
- enumerable: false,
79
- configurable: true
80
- });
81
- Object.defineProperty(Element.prototype, "definition", {
82
- /**
83
- * The {@link ElementDefinition} of the {@link Element}.
84
- */
85
- get: function () {
86
- var definition = this.variant.structureJson.elements[this.name];
87
- if (lodash_es_1.isArray(definition)) {
88
- return {
89
- paths: {
90
- include: definition
91
- }
92
- };
93
- }
94
- return definition;
95
- },
96
- enumerable: false,
97
- configurable: true
98
- });
99
- Object.defineProperty(Element.prototype, "pathDefinitions", {
100
- /**
101
- * The {@link PathDefinitions} of the {@link Element}.
102
- */
103
- get: function () {
104
- return this.definition.paths;
105
- },
106
- enumerable: false,
107
- configurable: true
108
- });
109
- Object.defineProperty(Element.prototype, "traceableDefinitions", {
110
- /**
111
- * The {@link TraceableDefinitions} of the {@link Element}.
112
- */
113
- get: function () {
114
- return this.definition.traceables || {};
115
- },
116
- enumerable: false,
117
- configurable: true
118
- });
119
- Object.defineProperty(Element.prototype, "paintableDefinitions", {
120
- /**
121
- * The {@link PaintableDefinition} of the {@link Element}.
122
- */
123
- get: function () {
124
- return this.definition.paintables || {};
125
- },
126
- enumerable: false,
127
- configurable: true
128
- });
129
- Object.defineProperty(Element.prototype, "inheritedParameters", {
130
- /**
131
- * The inherited {@link ParameterBag}.
132
- * Merges the {@link Variant}'s parameters and those from the {@link Element}.
133
- */
134
- get: function () {
135
- return lodash_es_1.merge({}, this.variant.inheritedParameters, this.parameters);
136
- },
137
- enumerable: false,
138
- configurable: true
139
- });
140
- Object.defineProperty(Element.prototype, "highlightLayer", {
141
- get: function () {
142
- return this._highlightLayer;
143
- },
144
- /**
145
- * @protected
146
- */
147
- set: function (layer) {
148
- this._highlightLayer = layer;
149
- },
150
- enumerable: false,
151
- configurable: true
152
- });
153
- /**
154
- * Destroys this {@link Element} and dispose all nodes.
155
- */
156
- Element.prototype.destroy = function () {
157
- this.nodes.forEach(function (node) {
158
- node.dispose();
159
- });
160
- return this;
161
- };
162
- /**
163
- * Gets a node by its {@link DottedPath}.
164
- */
165
- Element.prototype.getNode = function (dottedPath) {
166
- var _dottedPath = dottedPath_1.DottedPath.create(dottedPath);
167
- var keys = Array.from(this._dottedNodes.keys()).map(function (dp) { return dp.path; });
168
- var values = Array.from(this._dottedNodes.values());
169
- var node = values[keys.indexOf(_dottedPath.path)];
170
- if (!node) {
171
- throw new Error("Node with path \"" + _dottedPath.path + "\" does not exist for element \"" + this.id + "\".");
172
- }
173
- return node;
174
- };
175
- /**
176
- * Gets a mesh by its {@link DottedPath}.
177
- */
178
- Element.prototype.getMesh = function (dottedPath) {
179
- return tslib_1.__awaiter(this, void 0, void 0, function () {
180
- var node;
181
- return tslib_1.__generator(this, function (_a) {
182
- switch (_a.label) {
183
- case 0: return [4 /*yield*/, this.getNode(dottedPath)];
184
- case 1:
185
- node = _a.sent();
186
- if (node instanceof mesh_1.Mesh) {
187
- return [2 /*return*/, node];
188
- }
189
- return [2 /*return*/, null];
190
- }
191
- });
192
- });
193
- };
194
- /**
195
- * Gets a {@link PaintableDefinition} by its name.
196
- */
197
- Element.prototype.getPaintableDefinition = function (name) {
198
- if (!this.paintableDefinitions || !this.paintableDefinitions[name]) {
199
- throw new Error("No paintable \"" + name + "\" defined for element \"" + this.id + "\".");
200
- }
201
- return this.paintableDefinitions[name];
202
- };
203
- /**
204
- * Gets a {@link TraceableDefinition} by its name.
205
- */
206
- Element.prototype.getTraceableDefinition = function (name) {
207
- if (!this.traceableDefinitions || !this.traceableDefinitions[name]) {
208
- throw new Error("No traceable \"" + name + "\" defined to add observer in element \"" + this.id + "\".");
209
- }
210
- return this.traceableDefinitions[name];
211
- };
212
- /**
213
- * Gets the paintable Node by its name.
214
- */
215
- Element.prototype.getPaintableNode = function (name) {
216
- return this.getNode(this.getPaintableDefinition(name).path);
217
- };
218
- /**
219
- * Gets the traceable Node by its name.
220
- */
221
- Element.prototype.getTraceableNode = function (name) {
222
- return this.getNode(this.getTraceableDefinition(name).path);
223
- };
224
- /**
225
- * @see {@link VariantParameterizable.commitParameters}
226
- * @emit {@link Event.ELEMENT_PARAMETER_COMMITTED}
227
- */
228
- Element.prototype.commitParameters = function (parameters) {
229
- return tslib_1.__awaiter(this, void 0, void 0, function () {
230
- return tslib_1.__generator(this, function (_a) {
231
- return [2 /*return*/, _super.prototype.commitParameters.call(this, parameters)];
232
- });
233
- });
234
- };
235
- /**
236
- * Adds an observer function for camera matrix changes.
237
- * The `observer` gets 2 parameters: the `AbstractMesh` and a `ClientRect` object.
238
- */
239
- Element.prototype.addTraceableObserver = function (traceable, observer, payload) {
240
- var _this = this;
241
- if (payload && !(payload instanceof HTMLElement)) {
242
- throw new Error("Payload for camera observer must be an instance of \"HTMLElement\" in element \"" + this.id + "\".");
243
- }
244
- if (!this.traceableDefinitions || !this.traceableDefinitions[traceable]) {
245
- throw new Error("No traceable \"" + traceable + "\" defined to add observer in element \"" + this.id + "\".");
246
- }
247
- var node = this.getTraceableNode(traceable);
248
- if (!(node instanceof abstractMesh_1.AbstractMesh)) {
249
- throw new Error("The path must be an instance of \"AbstractMesh\" for camera observer in element \"" + this.id + "\".");
250
- }
251
- this.variant.viewer.sceneManager.activeCamera.onViewMatrixChangedObservable.add(function (eventData, eventState) {
252
- var position = babylonHelper_1.getClientRectFromMesh(node, _this.variant.viewer.scene, _this.variant.viewer.canvas);
253
- if (payload) {
254
- payload.style.top = position.top + "px";
255
- payload.style.left = position.left + "px";
256
- }
257
- observer(node, position);
258
- });
259
- return this;
260
- };
261
- /**
262
- * Draws a `ImageBitmap` or `OffscreenCanvas` onto a `paintable` defined via {@link PaintableDefinition}.
263
- */
264
- Element.prototype.drawPaintable = function (paintable, imageSource) {
265
- var paintableDefinition = this.getPaintableDefinition(paintable);
266
- var node = this.getPaintableNode(paintable);
267
- if (!(node instanceof abstractMesh_1.AbstractMesh)) {
268
- throw new Error("The path must be an instance of \"AbstractMesh\" for paintable \"" + paintable + "\" " +
269
- ("in element \"" + this.id + "\"."));
270
- }
271
- if (node.material && !lodash_es_1.has(node.metadata, 'dirty.material')) {
272
- babylonHelper_1.cloneTransformNodeMaterial(node);
273
- }
274
- if (!node.material) {
275
- node.material = new standardMaterial_1.StandardMaterial(this.id + "." + paintable + ".material", this.variant.viewer.scene);
276
- }
277
- node.material.transparencyMode = material_1.Material.MATERIAL_ALPHATESTANDBLEND;
278
- if (!lodash_es_1.has(node.metadata, 'dirty.material.texture')) {
279
- // inject initial value and mark as dirty
280
- babylonHelper_1.injectNodeMetadata(node, { dirty: { material: { texture: true } } });
281
- }
282
- var widthAndHeight = {
283
- width: imageSource.width,
284
- height: imageSource.height
285
- };
286
- if (lodash_es_1.isNumber(paintableDefinition.textureOptions)) {
287
- widthAndHeight.width = paintableDefinition.textureOptions;
288
- widthAndHeight.height = paintableDefinition.textureOptions;
289
- }
290
- else if (lodash_es_1.isPlainObject(paintableDefinition.textureOptions)) {
291
- widthAndHeight.width = paintableDefinition.textureOptions.width;
292
- widthAndHeight.height = paintableDefinition.textureOptions.height;
293
- }
294
- var texture = new dynamicTexture_1.DynamicTexture(this.id + "." + paintable + ".texture", widthAndHeight, this.variant.viewer.scene, false);
295
- babylonHelper_1.setMaterialTexture(node, texture, false);
296
- var ctx = texture.getContext();
297
- // flip texture context horizontal with translate and scale
298
- ctx.drawImage(imageSource, 0, 0);
299
- texture.update(false);
300
- return this;
301
- };
302
- /**
303
- * Draws a SVG string onto a `paintable` defined via {@link PaintableDefinition}.
304
- */
305
- Element.prototype.drawPaintableFromSvg = function (paintable, svgSource) {
306
- return tslib_1.__awaiter(this, void 0, void 0, function () {
307
- var source;
308
- return tslib_1.__generator(this, function (_a) {
309
- switch (_a.label) {
310
- case 0: return [4 /*yield*/, resourceHelper_1.createImageBitmapFromSvg(svgSource)];
311
- case 1:
312
- source = _a.sent();
313
- return [2 /*return*/, this.drawPaintable(paintable, source)];
314
- }
315
- });
316
- });
317
- };
318
- /**
319
- * Draws an Image from source (URL/URI) onto a `paintable` defined via {@link PaintableDefinition}.
320
- */
321
- Element.prototype.drawPaintableFromImgSrc = function (paintable, imgSource) {
322
- return tslib_1.__awaiter(this, void 0, void 0, function () {
323
- var source;
324
- return tslib_1.__generator(this, function (_a) {
325
- switch (_a.label) {
326
- case 0: return [4 /*yield*/, resourceHelper_1.createImageBitmapFromImgSrc(imgSource)];
327
- case 1:
328
- source = _a.sent();
329
- return [2 /*return*/, this.drawPaintable(paintable, source)];
330
- }
331
- });
332
- });
333
- };
334
- /**
335
- * Adds the default {@link ParameterObserver}s which are called every time {@link commitParameters} is called.
336
- */
337
- Element.prototype.addParameterObservers = function () {
338
- var _this = this;
339
- this._parameterObservers.set(parameter_1.Parameter.VISIBLE, [
340
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
341
- var visible;
342
- return tslib_1.__generator(this, function (_a) {
343
- try {
344
- visible = parameter_1.Parameter.parseBoolean(newValue);
345
- }
346
- catch (e) {
347
- return [2 /*return*/];
348
- }
349
- if (visible === true) {
350
- element.nodes.forEach(function (node) {
351
- babylonHelper_1.injectNodeMetadata(node, { visibility: node.isEnabled() });
352
- babylonHelper_1.activateTransformNode(node);
353
- });
354
- }
355
- else if (visible === false) {
356
- element.nodes.forEach(function (node) {
357
- babylonHelper_1.injectNodeMetadata(node, { visibility: node.isEnabled() });
358
- babylonHelper_1.deactivateTransformNode(node);
359
- });
360
- }
361
- return [2 /*return*/];
362
- });
363
- }); }
364
- ]);
365
- this._parameterObservers.set(parameter_1.Parameter.SCALING, [
366
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
367
- return tslib_1.__generator(this, function (_a) {
368
- // we have to deal just with root nodes here due to relative impacts in a node tree
369
- element.nodes.forEach(function (node) { return node.scaling = parameter_1.Parameter.parseScaling(newValue); });
370
- return [2 /*return*/];
371
- });
372
- }); }
373
- ]);
374
- this._parameterObservers.set(parameter_1.Parameter.MATERIAL, [
375
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
376
- var material;
377
- return tslib_1.__generator(this, function (_a) {
378
- material = element.variant.getMaterial(newValue.toString());
379
- element.nodes.forEach(function (node) {
380
- babylonHelper_1.assertTransformNode(node, function (node) {
381
- if (node instanceof instancedMesh_1.InstancedMesh) {
382
- throw new Error("Changing parameter \"" + parameter_1.Parameter.MATERIAL + "\" " +
383
- "of an InstancedMesh is not supported. " +
384
- ("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
385
- }
386
- });
387
- babylonHelper_1.setMaterial(node, material);
388
- });
389
- return [2 /*return*/];
390
- });
391
- }); }
392
- ]);
393
- this._parameterObservers.set(parameter_1.Parameter.MATERIAL_COLOR, [
394
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
395
- var color;
396
- return tslib_1.__generator(this, function (_a) {
397
- color = parameter_1.Parameter.parseColor(newValue);
398
- element.nodes.forEach(function (node) {
399
- babylonHelper_1.assertTransformNode(node, function (node) {
400
- if (node instanceof instancedMesh_1.InstancedMesh) {
401
- throw new Error("Changing parameter \"" + parameter_1.Parameter.MATERIAL_COLOR + "\" " +
402
- "of an InstancedMesh is not supported. " +
403
- ("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
404
- }
405
- });
406
- if (!lodash_es_1.has(node.metadata, 'dirty.material')) {
407
- babylonHelper_1.cloneTransformNodeMaterial(node);
408
- }
409
- if (!lodash_es_1.has(node.metadata, 'dirty.material.color')) {
410
- // inject initial value and mark as dirty
411
- babylonHelper_1.injectNodeMetadata(node, { dirty: { material: { color: oldValue } } });
412
- }
413
- babylonHelper_1.setMaterialColor(node, color);
414
- });
415
- return [2 /*return*/];
416
- });
417
- }); }
418
- ]);
419
- this._parameterObservers.set(parameter_1.Parameter.MATERIAL_METALLNESS, [
420
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
421
- var metallness;
422
- return tslib_1.__generator(this, function (_a) {
423
- metallness = parameter_1.Parameter.parseNumber(newValue);
424
- element.nodes.forEach(function (node) {
425
- babylonHelper_1.assertTransformNode(node, function (node) {
426
- if (node instanceof instancedMesh_1.InstancedMesh) {
427
- throw new Error("Changing parameter \"" + parameter_1.Parameter.MATERIAL_METALLNESS + "\" " +
428
- "of an InstancedMesh is not supported. " +
429
- ("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
430
- }
431
- });
432
- if (!lodash_es_1.has(node.metadata, 'dirty.material')) {
433
- babylonHelper_1.cloneTransformNodeMaterial(node);
434
- }
435
- if (!lodash_es_1.has(node.metadata, 'dirty.material.metallness')) {
436
- // inject initial value and mark as dirty
437
- babylonHelper_1.injectNodeMetadata(node, { dirty: { material: { metallness: oldValue } } });
438
- }
439
- babylonHelper_1.setMaterialMetallness(node, metallness);
440
- });
441
- return [2 /*return*/];
442
- });
443
- }); }
444
- ]);
445
- this._parameterObservers.set(parameter_1.Parameter.MATERIAL_ROUGHNESS, [
446
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
447
- var roughness;
448
- return tslib_1.__generator(this, function (_a) {
449
- roughness = parameter_1.Parameter.parseNumber(newValue);
450
- element.nodes.forEach(function (node) {
451
- babylonHelper_1.assertTransformNode(node, function (node) {
452
- if (node instanceof instancedMesh_1.InstancedMesh) {
453
- throw new Error("Changing parameter \"" + parameter_1.Parameter.MATERIAL_ROUGHNESS + "\" " +
454
- "of an InstancedMesh is not supported. " +
455
- ("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
456
- }
457
- });
458
- if (!lodash_es_1.has(node.metadata, 'dirty.material')) {
459
- babylonHelper_1.cloneTransformNodeMaterial(node);
460
- }
461
- if (!lodash_es_1.has(node.metadata, 'dirty.material.roughness')) {
462
- // inject initial value and mark as dirty
463
- babylonHelper_1.injectNodeMetadata(node, { dirty: { material: { roughness: oldValue } } });
464
- }
465
- babylonHelper_1.setMaterialRoughness(node, roughness);
466
- });
467
- return [2 /*return*/];
468
- });
469
- }); }
470
- ]);
471
- this._parameterObservers.set(parameter_1.Parameter.HIGHLIGHT_COLOR, [
472
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
473
- var _a;
474
- return tslib_1.__generator(this, function (_b) {
475
- // trigger Parameter.HIGHLIGHTED observers
476
- (_a = this._parameterObservers.get(parameter_1.Parameter.HIGHLIGHTED)) === null || _a === void 0 ? void 0 : _a.forEach(function (observer) {
477
- observer(element, !!element.highlighted, !!element.highlighted);
478
- });
479
- return [2 /*return*/];
480
- });
481
- }); }
482
- ]);
483
- this._parameterObservers.set(parameter_1.Parameter.HIGHLIGHT_ENABLED, [
484
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
485
- var curr;
486
- var _a;
487
- return tslib_1.__generator(this, function (_b) {
488
- try {
489
- curr = parameter_1.Parameter.parseBoolean(newValue);
490
- }
491
- catch (e) {
492
- return [2 /*return*/];
493
- }
494
- switch (curr) {
495
- case true:
496
- if (element._highlightLayer) {
497
- break;
498
- }
499
- element.highlightLayer = new highlightLayer_1.HighlightLayer(dottedPath_1.DottedPath.create(element.id).addPart('highlight').path, element.variant.viewer.scene);
500
- break;
501
- case false:
502
- (_a = element.highlightLayer) === null || _a === void 0 ? void 0 : _a.dispose();
503
- break;
504
- }
505
- return [2 /*return*/];
506
- });
507
- }); }
508
- ]);
509
- this._parameterObservers.set(parameter_1.Parameter.HIGHLIGHTED, [
510
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
511
- var highlighted;
512
- var _this = this;
513
- var _a;
514
- return tslib_1.__generator(this, function (_b) {
515
- if (!element.inheritedParameters[parameter_1.Parameter.HIGHLIGHT_ENABLED]) {
516
- return [2 /*return*/];
517
- }
518
- // trigger Parameter.HIGHLIGHT_ENABLED observers to ensure HighlightLayer
519
- (_a = this._parameterObservers.get(parameter_1.Parameter.HIGHLIGHT_ENABLED)) === null || _a === void 0 ? void 0 : _a.forEach(function (observer) {
520
- observer(element, _this.parameters[parameter_1.Parameter.HIGHLIGHT_ENABLED], true);
521
- });
522
- try {
523
- highlighted = parameter_1.Parameter.parseBoolean(newValue);
524
- }
525
- catch (e) {
526
- return [2 /*return*/];
527
- }
528
- // Add/Remove meshes to previously created highlight layers.
529
- if (highlighted === true) {
530
- element.nodes.forEach(function (node) {
531
- babylonHelper_1.assertTransformNode(node, function (node) {
532
- if (node instanceof instancedMesh_1.InstancedMesh) {
533
- throw new Error("Changing parameter \"" + parameter_1.Parameter.HIGHLIGHTED + "\" " +
534
- "of an InstancedMesh is not supported. " +
535
- ("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
536
- }
537
- });
538
- var color = math_color_1.Color3.Green();
539
- if (element.inheritedParameters[parameter_1.Parameter.HIGHLIGHT_COLOR]) {
540
- color = parameter_1.Parameter.parseColor(element.inheritedParameters[parameter_1.Parameter.HIGHLIGHT_COLOR]);
541
- }
542
- if (typeof element._highlightLayer !== "undefined") {
543
- babylonHelper_1.addToHighlightLayer(element._highlightLayer, color, node);
544
- }
545
- });
546
- }
547
- else if (highlighted === false) {
548
- element.nodes.forEach(function (node) {
549
- if (typeof element._highlightLayer !== "undefined") {
550
- babylonHelper_1.removeFromHighlightLayer(element._highlightLayer, node);
551
- }
552
- });
553
- }
554
- return [2 /*return*/];
555
- });
556
- }); }
557
- ]);
558
- this._parameterObservers.set(parameter_1.Parameter.POSITION, [
559
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
560
- return tslib_1.__generator(this, function (_a) {
561
- // we have to deal just with root nodes here due to relative impacts in a node tree
562
- element.nodes.forEach(function (node) { return babylonHelper_1.moveTransformNode(node, parameter_1.Parameter.parseVector(newValue)); });
563
- return [2 /*return*/];
564
- });
565
- }); }
566
- ]);
567
- this._parameterObservers.set(parameter_1.Parameter.ROTATION, [
568
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
569
- return tslib_1.__generator(this, function (_a) {
570
- switch (_a.label) {
571
- case 0:
572
- if (!(parameter_1.Parameter.POSITION in element.inheritedParameters)) return [3 /*break*/, 2];
573
- return [4 /*yield*/, element.commitParameter(parameter_1.Parameter.POSITION, element.inheritedParameters[parameter_1.Parameter.POSITION])];
574
- case 1:
575
- _a.sent();
576
- _a.label = 2;
577
- case 2:
578
- // we have to deal just with root nodes here due to relative impacts in a node tree
579
- element.nodes.forEach(function (node) { return babylonHelper_1.rotateTransformNode(node, parameter_1.Parameter.parseRotation(newValue)); });
580
- return [2 /*return*/];
581
- }
582
- });
583
- }); }
584
- ]);
585
- this._parameterObservers.set(parameter_1.Parameter.CAST_SHADOW, [
586
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
587
- var castShadow, lightCsl;
588
- return tslib_1.__generator(this, function (_a) {
589
- switch (_a.label) {
590
- case 0:
591
- try {
592
- castShadow = parameter_1.Parameter.parseBoolean(newValue);
593
- }
594
- catch (e) {
595
- return [2 /*return*/];
596
- }
597
- lightCsl = element.inheritedParameters[parameter_1.Parameter.CAST_SHADOW_FROM_LIGHTS];
598
- if (!lightCsl) {
599
- lightCsl = element.variant.inheritedViewerLights.map(function (l) { return l.name; }).join(',');
600
- }
601
- if (!(castShadow === true)) return [3 /*break*/, 2];
602
- return [4 /*yield*/, this.castShadowValueHandler(lightCsl, babylonHelper_1.addToShadowGenerator)];
603
- case 1:
604
- _a.sent();
605
- _a.label = 2;
606
- case 2:
607
- if (!(castShadow === false)) return [3 /*break*/, 4];
608
- return [4 /*yield*/, this.castShadowValueHandler(lightCsl, babylonHelper_1.removeFromShadowGenerator)];
609
- case 3:
610
- _a.sent();
611
- _a.label = 4;
612
- case 4: return [2 /*return*/];
613
- }
614
- });
615
- }); }
616
- ]);
617
- this._parameterObservers.set(parameter_1.Parameter.CAST_SHADOW_FROM_LIGHTS, [
618
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
619
- var lightCsl;
620
- return tslib_1.__generator(this, function (_a) {
621
- switch (_a.label) {
622
- case 0:
623
- lightCsl = element.variant.inheritedViewerLights.map(function (l) { return l.name; }).join(',');
624
- // cleanup all shadow generators
625
- return [4 /*yield*/, this.castShadowValueHandler(lightCsl, babylonHelper_1.removeFromShadowGenerator)];
626
- case 1:
627
- // cleanup all shadow generators
628
- _a.sent();
629
- if (!(element.castShadow === true)) return [3 /*break*/, 3];
630
- // if newValue is undefined or '' then set newValue to lightCsl (use all lights)
631
- if (!newValue) {
632
- newValue = lightCsl;
633
- }
634
- return [4 /*yield*/, this.castShadowValueHandler(newValue, babylonHelper_1.addToShadowGenerator)];
635
- case 2:
636
- _a.sent();
637
- _a.label = 3;
638
- case 3: return [2 /*return*/];
639
- }
640
- });
641
- }); }
642
- ]);
643
- this._parameterObservers.set(parameter_1.Parameter.RECEIVE_SHADOWS, [
644
- function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
645
- return tslib_1.__generator(this, function (_a) {
646
- element.nodes.forEach(function (node) { return babylonHelper_1.setReceiveShadows(node, parameter_1.Parameter.parseBoolean(newValue)); });
647
- return [2 /*return*/];
648
- });
649
- }); }
650
- ]);
651
- return this;
652
- };
653
- /**
654
- * Filter for nodes that are not defined or excluded in the `pathDefinitions`.
655
- */
656
- Element.prototype.filterNode = function (node) {
657
- var _this = this;
658
- var includeTokens = [];
659
- this.pathDefinitions.include.forEach(function (dottedPath) {
660
- includeTokens = lodash_es_1.union(includeTokens, dottedPath_1.DottedPath.create(dottedPath).leafTokens);
661
- });
662
- var shallKeep = function (dp) {
663
- var isDirectlyIncluded = !!includeTokens.find(function (_dp) { return _dp === dp.path; });
664
- var isSubOfIncluded = !!_this.pathDefinitions.include.find(function (_dp) {
665
- return dp.path.startsWith("" + _dp + dottedPath_1.DottedPath.DELIMITER);
666
- });
667
- return isDirectlyIncluded || isSubOfIncluded;
668
- };
669
- var shallExclude = function (dp) {
670
- if (!_this.pathDefinitions.exclude) {
671
- return false;
672
- }
673
- return !!_this.pathDefinitions.exclude.find(function (_dp) { return dp.path === _dp; });
674
- };
675
- return shallKeep(node.metadata.dottedPath) && !shallExclude(node.metadata.dottedPath);
676
- };
677
- /**
678
- * Asserts whether all {@link pathDefinitions} link to a valid `Node` path.
679
- * @protected
680
- */
681
- Element.prototype.assertPathDefinitions = function () {
682
- var _this = this;
683
- var _a;
684
- var dottedNodes = this.variant.inheritedDottedNodes;
685
- if (dottedNodes.size === 0) {
686
- throw new Error("There are no mapped nodes for element \"" + this.id + "\".");
687
- }
688
- var include = this.pathDefinitions.include.map(function (path) { return dottedPath_1.DottedPath.create(path).path; });
689
- var exclude = (_a = this.pathDefinitions.exclude) === null || _a === void 0 ? void 0 : _a.map(function (path) { return dottedPath_1.DottedPath.create(path).path; });
690
- var keys = Array.from(dottedNodes.keys()).map(function (dottedPath) { return dottedPath.path; });
691
- lodash_es_1.union(include, exclude).forEach(function (path) {
692
- if (keys.indexOf(path) === -1) {
693
- throw new Error("Node with path \"" + path + "\" does not exist for element \"" + _this.id + "\".");
694
- }
695
- });
696
- };
697
- /**
698
- * Handles callback for given light parameter.
699
- */
700
- Element.prototype.castShadowValueHandler = function (lightCsl, mutator) {
701
- return tslib_1.__awaiter(this, void 0, void 0, function () {
702
- var lights, _i, _a, lightName, viewerLight, shadowGenerators;
703
- var _this = this;
704
- return tslib_1.__generator(this, function (_b) {
705
- switch (_b.label) {
706
- case 0:
707
- lights = [];
708
- _i = 0, _a = parameter_1.Parameter.parseCommaSeparatedList(lightCsl);
709
- _b.label = 1;
710
- case 1:
711
- if (!(_i < _a.length)) return [3 /*break*/, 4];
712
- lightName = _a[_i];
713
- return [4 /*yield*/, this.variant.getViewerLight(lightName)];
714
- case 2:
715
- viewerLight = _b.sent();
716
- if (viewerLight) {
717
- lights.push(viewerLight.light);
718
- }
719
- _b.label = 3;
720
- case 3:
721
- _i++;
722
- return [3 /*break*/, 1];
723
- case 4:
724
- shadowGenerators = lights
725
- .map(function (light) { return light === null || light === void 0 ? void 0 : light.getShadowGenerator(); })
726
- .filter(Boolean);
727
- shadowGenerators.forEach(function (generator) {
728
- _this.nodes.forEach(function (node) {
729
- mutator(generator, node);
730
- });
731
- });
732
- return [2 /*return*/];
733
- }
734
- });
735
- });
736
- };
737
- return Element;
738
- }(variantParameterizable_1.VariantParameterizable));
739
- exports.Element = Element;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Element = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var highlightLayer_1 = require("@babylonjs/core/Layers/highlightLayer");
6
+ var material_1 = require("@babylonjs/core/Materials/material");
7
+ var standardMaterial_1 = require("@babylonjs/core/Materials/standardMaterial");
8
+ var dynamicTexture_1 = require("@babylonjs/core/Materials/Textures/dynamicTexture");
9
+ var math_axis_1 = require("@babylonjs/core/Maths/math.axis");
10
+ var math_color_1 = require("@babylonjs/core/Maths/math.color");
11
+ var abstractMesh_1 = require("@babylonjs/core/Meshes/abstractMesh");
12
+ var instancedMesh_1 = require("@babylonjs/core/Meshes/instancedMesh");
13
+ var mesh_1 = require("@babylonjs/core/Meshes/mesh");
14
+ var transformNode_1 = require("@babylonjs/core/Meshes/transformNode");
15
+ var lodash_es_1 = require("lodash-es");
16
+ var babylonHelper_1 = require("../util/babylonHelper");
17
+ var resourceHelper_1 = require("../util/resourceHelper");
18
+ var dottedPath_1 = require("./dottedPath");
19
+ var elementParameterizable_1 = require("./elementParameterizable");
20
+ var event_1 = require("./event");
21
+ var parameter_1 = require("./parameter");
22
+ /**
23
+ * An {@link Element} of a {@link Variant}. Acts as a container for diverse definitions. Lives only in the context of a
24
+ * {@link Variant}.
25
+ *
26
+ * When used in typings, refer to via its alias {@link VariantElement} to prevent name clashes with the web APIs
27
+ * [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) class
28
+ */
29
+ var Element = /** @class */ (function (_super) {
30
+ tslib_1.__extends(Element, _super);
31
+ /**
32
+ * Constructor.
33
+ */
34
+ function Element(variant, name) {
35
+ var _a;
36
+ var _this = _super.call(this) || this;
37
+ _this.variant = variant;
38
+ _this.name = name;
39
+ _this._dottedNodes = new Map();
40
+ _this._parameterObservers = new Map();
41
+ _this.nodes = [];
42
+ if ((_a = process.env.NODE_ENV) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('dev')) {
43
+ _this.assertPathDefinitions();
44
+ }
45
+ var nodes = _this.variant.inheritedNodes.map(function (node) { return babylonHelper_1.cloneTransformNode(node, _this.filterNode.bind(_this)); });
46
+ _this.nodes = nodes.filter(function (node) { return !!node; });
47
+ _this._dottedNodes = babylonHelper_1.mapToDottedNodes(_this.nodes, function (node) { return node instanceof transformNode_1.TransformNode; });
48
+ _this.addParameterObservers();
49
+ return _this;
50
+ }
51
+ Object.defineProperty(Element.prototype, "dottedPath", {
52
+ /**
53
+ * The {@link DottedPath} in the built tree of {@link Element}s.
54
+ * E.g. "_.top-1.sub-2.sub-sub-3.el-1"
55
+ */
56
+ get: function () {
57
+ return dottedPath_1.DottedPath.create(this.variant.dottedPath).addPart(this.name);
58
+ },
59
+ enumerable: false,
60
+ configurable: true
61
+ });
62
+ Object.defineProperty(Element.prototype, "id", {
63
+ /**
64
+ * The id representing a {@link DottedPath}.
65
+ */
66
+ get: function () {
67
+ var dottedPath = dottedPath_1.DottedPath.create(this.dottedPath);
68
+ dottedPath.shiftPart(); // remove root
69
+ return dottedPath.path;
70
+ },
71
+ enumerable: false,
72
+ configurable: true
73
+ });
74
+ Object.defineProperty(Element.prototype, "definition", {
75
+ /**
76
+ * The {@link ElementDefinition} of the {@link Element}.
77
+ */
78
+ get: function () {
79
+ var definition = this.variant.structureJson.elements[this.name];
80
+ if (lodash_es_1.isArray(definition)) {
81
+ return {
82
+ paths: {
83
+ include: definition
84
+ }
85
+ };
86
+ }
87
+ return definition;
88
+ },
89
+ enumerable: false,
90
+ configurable: true
91
+ });
92
+ Object.defineProperty(Element.prototype, "pathDefinitions", {
93
+ /**
94
+ * The {@link PathDefinitions} of the {@link Element}.
95
+ */
96
+ get: function () {
97
+ return this.definition.paths;
98
+ },
99
+ enumerable: false,
100
+ configurable: true
101
+ });
102
+ Object.defineProperty(Element.prototype, "traceableDefinitions", {
103
+ /**
104
+ * The {@link TraceableDefinitions} of the {@link Element}.
105
+ */
106
+ get: function () {
107
+ return this.definition.traceables || {};
108
+ },
109
+ enumerable: false,
110
+ configurable: true
111
+ });
112
+ Object.defineProperty(Element.prototype, "paintableDefinitions", {
113
+ /**
114
+ * The {@link PaintableDefinition} of the {@link Element}.
115
+ */
116
+ get: function () {
117
+ return this.definition.paintables || {};
118
+ },
119
+ enumerable: false,
120
+ configurable: true
121
+ });
122
+ Object.defineProperty(Element.prototype, "inheritedParameters", {
123
+ /**
124
+ * The inherited {@link ParameterBag}.
125
+ * Merges the {@link Variant}'s parameters and those from the {@link Element}.
126
+ */
127
+ get: function () {
128
+ return lodash_es_1.merge({}, this.variant.inheritedParameters, this.parameters);
129
+ },
130
+ enumerable: false,
131
+ configurable: true
132
+ });
133
+ Object.defineProperty(Element.prototype, "highlightLayer", {
134
+ get: function () {
135
+ return this._highlightLayer;
136
+ },
137
+ /**
138
+ * @protected
139
+ */
140
+ set: function (layer) {
141
+ this._highlightLayer = layer;
142
+ },
143
+ enumerable: false,
144
+ configurable: true
145
+ });
146
+ /**
147
+ * Destroys this {@link Element} and dispose all nodes.
148
+ */
149
+ Element.prototype.destroy = function () {
150
+ this.nodes.forEach(function (node) {
151
+ node.dispose();
152
+ });
153
+ return this;
154
+ };
155
+ /**
156
+ * Gets a node by its {@link DottedPath}.
157
+ */
158
+ Element.prototype.getNode = function (dottedPath) {
159
+ var _dottedPath = dottedPath_1.DottedPath.create(dottedPath);
160
+ var keys = Array.from(this._dottedNodes.keys()).map(function (dp) { return dp.path; });
161
+ var values = Array.from(this._dottedNodes.values());
162
+ var node = values[keys.indexOf(_dottedPath.path)];
163
+ if (!node) {
164
+ throw new Error("Node with path \"" + _dottedPath.path + "\" does not exist for element \"" + this.id + "\".");
165
+ }
166
+ return node;
167
+ };
168
+ /**
169
+ * Gets a mesh by its {@link DottedPath}.
170
+ */
171
+ Element.prototype.getMesh = function (dottedPath) {
172
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
173
+ var node;
174
+ return tslib_1.__generator(this, function (_a) {
175
+ switch (_a.label) {
176
+ case 0: return [4 /*yield*/, this.getNode(dottedPath)];
177
+ case 1:
178
+ node = _a.sent();
179
+ if (node instanceof mesh_1.Mesh) {
180
+ return [2 /*return*/, node];
181
+ }
182
+ return [2 /*return*/, null];
183
+ }
184
+ });
185
+ });
186
+ };
187
+ /**
188
+ * Gets a {@link PaintableDefinition} by its name.
189
+ */
190
+ Element.prototype.getPaintableDefinition = function (name) {
191
+ if (!this.paintableDefinitions || !this.paintableDefinitions[name]) {
192
+ throw new Error("No paintable \"" + name + "\" defined for element \"" + this.id + "\".");
193
+ }
194
+ return this.paintableDefinitions[name];
195
+ };
196
+ /**
197
+ * Gets a {@link TraceableDefinition} by its name.
198
+ */
199
+ Element.prototype.getTraceableDefinition = function (name) {
200
+ if (!this.traceableDefinitions || !this.traceableDefinitions[name]) {
201
+ throw new Error("No traceable \"" + name + "\" defined to add observer in element \"" + this.id + "\".");
202
+ }
203
+ return this.traceableDefinitions[name];
204
+ };
205
+ /**
206
+ * Gets the paintable Node by its name.
207
+ */
208
+ Element.prototype.getPaintableNode = function (name) {
209
+ return this.getNode(this.getPaintableDefinition(name).path);
210
+ };
211
+ /**
212
+ * Gets the traceable Node by its name.
213
+ */
214
+ Element.prototype.getTraceableNode = function (name) {
215
+ return this.getNode(this.getTraceableDefinition(name).path);
216
+ };
217
+ /**
218
+ * Places the given {@link ParameterBag} in the {@link Element}'s parameters, replaces all patterns in the
219
+ * {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
220
+ *
221
+ * @emit {@link Event.ELEMENT_PARAMETER_COMMITTED}
222
+ */
223
+ Element.prototype.commitParameters = function (parameters) {
224
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
225
+ var oldParameters, observerPromises, _loop_1, this_1, parameter;
226
+ var _this = this;
227
+ return tslib_1.__generator(this, function (_a) {
228
+ switch (_a.label) {
229
+ case 0:
230
+ if (!parameters) {
231
+ parameters = {};
232
+ }
233
+ oldParameters = lodash_es_1.cloneDeep(this.parameters);
234
+ lodash_es_1.merge(this.parameters, parameters);
235
+ observerPromises = [];
236
+ _loop_1 = function (parameter) {
237
+ var oldParameterValue = oldParameters[parameter];
238
+ var newParameterValue = this_1.parameters[parameter];
239
+ this_1.variant.assertParameter(this_1.variant.inheritedParameterDeclaration, parameter, newParameterValue);
240
+ if (oldParameterValue === newParameterValue) {
241
+ return "continue";
242
+ }
243
+ // parameter changed
244
+ var parameterObservers = resourceHelper_1.mergeMaps(this_1._parameterObservers, this_1.parameterObservers);
245
+ if (parameterObservers.has(parameter)) {
246
+ var observers = parameterObservers.get(parameter);
247
+ observerPromises = lodash_es_1.concat(observerPromises, observers.map(function (observer) {
248
+ var observerResult = observer(_this, oldParameterValue, newParameterValue);
249
+ return Promise.resolve(observerResult).then(function () {
250
+ _this.broadcastEvent(event_1.Event.ELEMENT_PARAMETER_COMMITTED, _this, parameter, oldParameterValue, newParameterValue);
251
+ });
252
+ }));
253
+ }
254
+ };
255
+ this_1 = this;
256
+ for (parameter in this.parameters) {
257
+ _loop_1(parameter);
258
+ }
259
+ return [4 /*yield*/, Promise.all(observerPromises)];
260
+ case 1:
261
+ _a.sent();
262
+ return [2 /*return*/, this];
263
+ }
264
+ });
265
+ });
266
+ };
267
+ /**
268
+ * Adds an observer function for camera matrix changes.
269
+ * The `observer` gets 2 parameters: the `AbstractMesh` and a `ClientRect` object.
270
+ */
271
+ Element.prototype.addTraceableObserver = function (traceable, observer, payload) {
272
+ var _this = this;
273
+ if (payload && !(payload instanceof HTMLElement)) {
274
+ throw new Error("Payload for camera observer must be an instance of \"HTMLElement\" in element \"" + this.id + "\".");
275
+ }
276
+ if (!this.traceableDefinitions || !this.traceableDefinitions[traceable]) {
277
+ throw new Error("No traceable \"" + traceable + "\" defined to add observer in element \"" + this.id + "\".");
278
+ }
279
+ var node = this.getTraceableNode(traceable);
280
+ if (!(node instanceof abstractMesh_1.AbstractMesh)) {
281
+ throw new Error("The path must be an instance of \"AbstractMesh\" for camera observer in element \"" + this.id + "\".");
282
+ }
283
+ this.variant.viewer.sceneManager.activeCamera.onViewMatrixChangedObservable.add(function (eventData, eventState) {
284
+ var position = babylonHelper_1.getClientRectFromMesh(node, _this.variant.viewer.scene, _this.variant.viewer.canvas);
285
+ if (payload) {
286
+ payload.style.top = position.top + "px";
287
+ payload.style.left = position.left + "px";
288
+ }
289
+ observer(node, position);
290
+ });
291
+ return this;
292
+ };
293
+ /**
294
+ * Draws a `ImageBitmap` or `OffscreenCanvas` onto a `paintable` defined via {@link PaintableDefinition}.
295
+ */
296
+ Element.prototype.drawPaintable = function (paintable, imageSource) {
297
+ // node and material checks and preperation
298
+ var node = this.getPaintableNode(paintable);
299
+ if (!(node instanceof abstractMesh_1.AbstractMesh)) {
300
+ throw new Error("The path must be an instance of \"AbstractMesh\" for paintable \"" + paintable + "\" " +
301
+ ("in element \"" + this.id + "\"."));
302
+ }
303
+ if (node.material && !lodash_es_1.get(node.metadata, 'dirty.material')) {
304
+ babylonHelper_1.cloneTransformNodeMaterial(node);
305
+ }
306
+ if (!node.material) {
307
+ node.material = new standardMaterial_1.StandardMaterial(this.id + "." + paintable + ".material", this.variant.viewer.scene);
308
+ }
309
+ node.material.transparencyMode = material_1.Material.MATERIAL_ALPHATESTANDBLEND;
310
+ if (!lodash_es_1.get(node.metadata, 'dirty.material.texture')) {
311
+ // inject initial value and mark as dirty
312
+ babylonHelper_1.injectTransformNodeMetadata(node, { dirty: { material: { texture: true } } });
313
+ }
314
+ // consider width and height of the paintable
315
+ var widthAndHeight = {
316
+ width: imageSource.width,
317
+ height: imageSource.height
318
+ };
319
+ var paintableDefinition = this.getPaintableDefinition(paintable);
320
+ if (lodash_es_1.isNumber(paintableDefinition.textureOptions)) {
321
+ widthAndHeight.width = paintableDefinition.textureOptions;
322
+ widthAndHeight.height = paintableDefinition.textureOptions;
323
+ }
324
+ else if (lodash_es_1.isPlainObject(paintableDefinition.textureOptions)) {
325
+ widthAndHeight.width = paintableDefinition.textureOptions.width;
326
+ widthAndHeight.height = paintableDefinition.textureOptions.height;
327
+ }
328
+ // create dynamic texture on which the image can be drawn
329
+ var texture = new dynamicTexture_1.DynamicTexture(this.id + "." + paintable + ".texture", widthAndHeight, this.variant.viewer.scene, false);
330
+ // draw image on texture
331
+ var ctx = texture.getContext();
332
+ ctx.drawImage(imageSource, 0, 0);
333
+ texture.update(false);
334
+ // finally apply the texture on the desired node material
335
+ babylonHelper_1.setMaterialTexture(node, texture, false);
336
+ return this;
337
+ };
338
+ /**
339
+ * Draws a SVG string onto a `paintable` defined via {@link PaintableDefinition}.
340
+ */
341
+ Element.prototype.drawPaintableFromSvg = function (paintable, svgSource) {
342
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
343
+ var image;
344
+ return tslib_1.__generator(this, function (_a) {
345
+ switch (_a.label) {
346
+ case 0: return [4 /*yield*/, resourceHelper_1.createImageFromSvg(svgSource)];
347
+ case 1:
348
+ image = _a.sent();
349
+ return [2 /*return*/, this.drawPaintable(paintable, image)];
350
+ }
351
+ });
352
+ });
353
+ };
354
+ /**
355
+ * Draws an Image from source (URL/URI) onto a `paintable` defined via {@link PaintableDefinition}.
356
+ */
357
+ Element.prototype.drawPaintableFromImgSrc = function (paintable, imgSource) {
358
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
359
+ var image;
360
+ return tslib_1.__generator(this, function (_a) {
361
+ switch (_a.label) {
362
+ case 0: return [4 /*yield*/, resourceHelper_1.createImageFromImgSrc(imgSource)];
363
+ case 1:
364
+ image = _a.sent();
365
+ return [2 /*return*/, this.drawPaintable(paintable, image)];
366
+ }
367
+ });
368
+ });
369
+ };
370
+ /**
371
+ * Adds the default {@link ParameterObserver}s which are called every time {@link commitParameters} is called.
372
+ */
373
+ Element.prototype.addParameterObservers = function () {
374
+ var _this = this;
375
+ this._parameterObservers.set(parameter_1.Parameter.VISIBLE, [
376
+ function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
377
+ var visible;
378
+ return tslib_1.__generator(this, function (_a) {
379
+ try {
380
+ visible = parameter_1.Parameter.parseBoolean(newValue);
381
+ }
382
+ catch (e) {
383
+ return [2 /*return*/];
384
+ }
385
+ if (visible === true) {
386
+ element.nodes.forEach(function (node) {
387
+ babylonHelper_1.injectTransformNodeMetadata(node, { visibility: node.isEnabled() });
388
+ babylonHelper_1.activateTransformNode(node);
389
+ });
390
+ }
391
+ else if (visible === false) {
392
+ element.nodes.forEach(function (node) {
393
+ babylonHelper_1.injectTransformNodeMetadata(node, { visibility: node.isEnabled() });
394
+ babylonHelper_1.deactivateTransformNode(node);
395
+ });
396
+ }
397
+ return [2 /*return*/];
398
+ });
399
+ }); }
400
+ ]);
401
+ this._parameterObservers.set(parameter_1.Parameter.SCALING, [
402
+ function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
403
+ return tslib_1.__generator(this, function (_a) {
404
+ // we have to deal just with root nodes here due to relative impacts in a node tree
405
+ element.nodes.forEach(function (node) { return node.scaling = parameter_1.Parameter.parseScaling(newValue); });
406
+ return [2 /*return*/];
407
+ });
408
+ }); }
409
+ ]);
410
+ this._parameterObservers.set(parameter_1.Parameter.MATERIAL, [
411
+ function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
412
+ var material;
413
+ return tslib_1.__generator(this, function (_a) {
414
+ material = element.variant.getMaterial(newValue.toString());
415
+ element.nodes.forEach(function (node) {
416
+ babylonHelper_1.assertTransformNode(node, function (node) {
417
+ if (node instanceof instancedMesh_1.InstancedMesh) {
418
+ throw new Error("Changing parameter \"" + parameter_1.Parameter.MATERIAL + "\" " +
419
+ "of an InstancedMesh is not supported. " +
420
+ ("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
421
+ }
422
+ });
423
+ babylonHelper_1.setMaterial(node, material);
424
+ });
425
+ return [2 /*return*/];
426
+ });
427
+ }); }
428
+ ]);
429
+ this._parameterObservers.set(parameter_1.Parameter.MATERIAL_COLOR, [
430
+ function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
431
+ var color;
432
+ return tslib_1.__generator(this, function (_a) {
433
+ color = parameter_1.Parameter.parseColor(newValue);
434
+ element.nodes.forEach(function (node) {
435
+ babylonHelper_1.assertTransformNode(node, function (node) {
436
+ if (node instanceof instancedMesh_1.InstancedMesh) {
437
+ throw new Error("Changing parameter \"" + parameter_1.Parameter.MATERIAL_COLOR + "\" " +
438
+ "of an InstancedMesh is not supported. " +
439
+ ("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
440
+ }
441
+ });
442
+ if (!lodash_es_1.get(node.metadata, 'dirty.material')) {
443
+ babylonHelper_1.cloneTransformNodeMaterial(node);
444
+ }
445
+ if (!lodash_es_1.get(node.metadata, 'dirty.material.color')) {
446
+ // inject initial value and mark as dirty
447
+ babylonHelper_1.injectTransformNodeMetadata(node, { dirty: { material: { color: oldValue } } });
448
+ }
449
+ babylonHelper_1.setMaterialColor(node, color);
450
+ });
451
+ return [2 /*return*/];
452
+ });
453
+ }); }
454
+ ]);
455
+ this._parameterObservers.set(parameter_1.Parameter.MATERIAL_METALLNESS, [
456
+ function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
457
+ var metallness;
458
+ return tslib_1.__generator(this, function (_a) {
459
+ metallness = parameter_1.Parameter.parseNumber(newValue);
460
+ element.nodes.forEach(function (node) {
461
+ babylonHelper_1.assertTransformNode(node, function (node) {
462
+ if (node instanceof instancedMesh_1.InstancedMesh) {
463
+ throw new Error("Changing parameter \"" + parameter_1.Parameter.MATERIAL_METALLNESS + "\" " +
464
+ "of an InstancedMesh is not supported. " +
465
+ ("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
466
+ }
467
+ });
468
+ if (!lodash_es_1.get(node.metadata, 'dirty.material')) {
469
+ babylonHelper_1.cloneTransformNodeMaterial(node);
470
+ }
471
+ if (!lodash_es_1.get(node.metadata, 'dirty.material.metallness')) {
472
+ // inject initial value and mark as dirty
473
+ babylonHelper_1.injectTransformNodeMetadata(node, { dirty: { material: { metallness: oldValue } } });
474
+ }
475
+ babylonHelper_1.setMaterialMetallness(node, metallness);
476
+ });
477
+ return [2 /*return*/];
478
+ });
479
+ }); }
480
+ ]);
481
+ this._parameterObservers.set(parameter_1.Parameter.MATERIAL_ROUGHNESS, [
482
+ function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
483
+ var roughness;
484
+ return tslib_1.__generator(this, function (_a) {
485
+ roughness = parameter_1.Parameter.parseNumber(newValue);
486
+ element.nodes.forEach(function (node) {
487
+ babylonHelper_1.assertTransformNode(node, function (node) {
488
+ if (node instanceof instancedMesh_1.InstancedMesh) {
489
+ throw new Error("Changing parameter \"" + parameter_1.Parameter.MATERIAL_ROUGHNESS + "\" " +
490
+ "of an InstancedMesh is not supported. " +
491
+ ("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
492
+ }
493
+ });
494
+ if (!lodash_es_1.get(node.metadata, 'dirty.material')) {
495
+ babylonHelper_1.cloneTransformNodeMaterial(node);
496
+ }
497
+ if (!lodash_es_1.get(node.metadata, 'dirty.material.roughness')) {
498
+ // inject initial value and mark as dirty
499
+ babylonHelper_1.injectTransformNodeMetadata(node, { dirty: { material: { roughness: oldValue } } });
500
+ }
501
+ babylonHelper_1.setMaterialRoughness(node, roughness);
502
+ });
503
+ return [2 /*return*/];
504
+ });
505
+ }); }
506
+ ]);
507
+ this._parameterObservers.set(parameter_1.Parameter.HIGHLIGHT_COLOR, [
508
+ function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
509
+ var _a;
510
+ return tslib_1.__generator(this, function (_b) {
511
+ // trigger Parameter.HIGHLIGHTED observers
512
+ (_a = this._parameterObservers.get(parameter_1.Parameter.HIGHLIGHTED)) === null || _a === void 0 ? void 0 : _a.forEach(function (observer) {
513
+ observer(element, !!element.highlighted, !!element.highlighted);
514
+ });
515
+ return [2 /*return*/];
516
+ });
517
+ }); }
518
+ ]);
519
+ this._parameterObservers.set(parameter_1.Parameter.HIGHLIGHT_ENABLED, [
520
+ function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
521
+ var curr;
522
+ var _a;
523
+ return tslib_1.__generator(this, function (_b) {
524
+ try {
525
+ curr = parameter_1.Parameter.parseBoolean(newValue);
526
+ }
527
+ catch (e) {
528
+ return [2 /*return*/];
529
+ }
530
+ switch (curr) {
531
+ case true:
532
+ if (element._highlightLayer) {
533
+ break;
534
+ }
535
+ element.highlightLayer = new highlightLayer_1.HighlightLayer(dottedPath_1.DottedPath.create(element.id).addPart('highlight').path, element.variant.viewer.scene);
536
+ break;
537
+ case false:
538
+ (_a = element.highlightLayer) === null || _a === void 0 ? void 0 : _a.dispose();
539
+ break;
540
+ }
541
+ return [2 /*return*/];
542
+ });
543
+ }); }
544
+ ]);
545
+ this._parameterObservers.set(parameter_1.Parameter.HIGHLIGHTED, [
546
+ function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
547
+ var highlighted;
548
+ var _this = this;
549
+ var _a;
550
+ return tslib_1.__generator(this, function (_b) {
551
+ if (!element.inheritedParameters[parameter_1.Parameter.HIGHLIGHT_ENABLED]) {
552
+ return [2 /*return*/];
553
+ }
554
+ // trigger Parameter.HIGHLIGHT_ENABLED observers to ensure HighlightLayer
555
+ (_a = this._parameterObservers.get(parameter_1.Parameter.HIGHLIGHT_ENABLED)) === null || _a === void 0 ? void 0 : _a.forEach(function (observer) {
556
+ observer(element, _this.parameters[parameter_1.Parameter.HIGHLIGHT_ENABLED], true);
557
+ });
558
+ try {
559
+ highlighted = parameter_1.Parameter.parseBoolean(newValue);
560
+ }
561
+ catch (e) {
562
+ return [2 /*return*/];
563
+ }
564
+ // Add/Remove meshes to previously created highlight layers.
565
+ if (highlighted === true) {
566
+ element.nodes.forEach(function (node) {
567
+ babylonHelper_1.assertTransformNode(node, function (node) {
568
+ if (node instanceof instancedMesh_1.InstancedMesh) {
569
+ throw new Error("Changing parameter \"" + parameter_1.Parameter.HIGHLIGHTED + "\" " +
570
+ "of an InstancedMesh is not supported. " +
571
+ ("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
572
+ }
573
+ });
574
+ var color = math_color_1.Color3.Green();
575
+ if (element.inheritedParameters[parameter_1.Parameter.HIGHLIGHT_COLOR]) {
576
+ color = parameter_1.Parameter.parseColor(element.inheritedParameters[parameter_1.Parameter.HIGHLIGHT_COLOR]);
577
+ }
578
+ if (typeof element._highlightLayer !== "undefined") {
579
+ babylonHelper_1.addToHighlightLayer(element._highlightLayer, color, node);
580
+ }
581
+ });
582
+ }
583
+ else if (highlighted === false) {
584
+ element.nodes.forEach(function (node) {
585
+ if (typeof element._highlightLayer !== "undefined") {
586
+ babylonHelper_1.removeFromHighlightLayer(element._highlightLayer, node);
587
+ }
588
+ });
589
+ }
590
+ return [2 /*return*/];
591
+ });
592
+ }); }
593
+ ]);
594
+ this._parameterObservers.set(parameter_1.Parameter.POSITION, [
595
+ function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
596
+ return tslib_1.__generator(this, function (_a) {
597
+ // we have to deal just with root nodes here due to relative impacts in a node tree
598
+ element.nodes.forEach(function (node) {
599
+ // remember absolute position and reset it before translating
600
+ if (!lodash_es_1.get(node.metadata, 'position')) {
601
+ node.metadata.position = node.absolutePosition.clone();
602
+ }
603
+ node.setAbsolutePosition(node.metadata.position);
604
+ // move
605
+ var distance = parameter_1.Parameter.parseVector(newValue);
606
+ node.translate(math_axis_1.Axis.X, distance.x, math_axis_1.Space.WORLD);
607
+ node.translate(math_axis_1.Axis.Y, distance.y, math_axis_1.Space.WORLD);
608
+ node.translate(math_axis_1.Axis.Z, distance.z, math_axis_1.Space.WORLD);
609
+ });
610
+ return [2 /*return*/];
611
+ });
612
+ }); }
613
+ ]);
614
+ this._parameterObservers.set(parameter_1.Parameter.ROTATION, [
615
+ function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
616
+ return tslib_1.__generator(this, function (_a) {
617
+ // we have to deal just with root nodes here due to relative impacts in a node tree
618
+ element.nodes.forEach(function (node) {
619
+ // remember absolute rotation and reset it before translating
620
+ if (!lodash_es_1.get(node.metadata, 'rotation')) {
621
+ node.metadata.rotation = node.rotation.clone();
622
+ }
623
+ node.rotation = node.metadata.rotation;
624
+ // rotate
625
+ var rotation = parameter_1.Parameter.parseRotation(newValue);
626
+ node.rotate(math_axis_1.Axis.X, rotation.x, math_axis_1.Space.WORLD);
627
+ node.rotate(math_axis_1.Axis.Y, rotation.y, math_axis_1.Space.WORLD);
628
+ node.rotate(math_axis_1.Axis.Z, rotation.z, math_axis_1.Space.WORLD);
629
+ });
630
+ return [2 /*return*/];
631
+ });
632
+ }); }
633
+ ]);
634
+ return this;
635
+ };
636
+ /**
637
+ * Filter for nodes that are not defined or excluded in the `pathDefinitions`.
638
+ */
639
+ Element.prototype.filterNode = function (node) {
640
+ var _this = this;
641
+ var includeTokens = [];
642
+ this.pathDefinitions.include.forEach(function (dottedPath) {
643
+ includeTokens = lodash_es_1.union(includeTokens, dottedPath_1.DottedPath.create(dottedPath).leafTokens);
644
+ });
645
+ var shallKeep = function (dp) {
646
+ var isDirectlyIncluded = !!includeTokens.find(function (_dp) { return _dp === dp.path; });
647
+ var isSubOfIncluded = !!_this.pathDefinitions.include.find(function (_dp) {
648
+ return dp.path.startsWith("" + _dp + dottedPath_1.DottedPath.DELIMITER);
649
+ });
650
+ return isDirectlyIncluded || isSubOfIncluded;
651
+ };
652
+ var shallExclude = function (dp) {
653
+ if (!_this.pathDefinitions.exclude) {
654
+ return false;
655
+ }
656
+ return !!_this.pathDefinitions.exclude.find(function (_dp) { return dp.path === _dp; });
657
+ };
658
+ return shallKeep(node.metadata.dottedPath) && !shallExclude(node.metadata.dottedPath);
659
+ };
660
+ /**
661
+ * Asserts whether all {@link pathDefinitions} link to a valid `Node` path.
662
+ * @protected
663
+ */
664
+ Element.prototype.assertPathDefinitions = function () {
665
+ var _this = this;
666
+ var _a;
667
+ var dottedNodes = this.variant.inheritedDottedNodes;
668
+ if (dottedNodes.size === 0) {
669
+ throw new Error("There are no mapped nodes for element \"" + this.id + "\".");
670
+ }
671
+ var include = this.pathDefinitions.include.map(function (path) { return dottedPath_1.DottedPath.create(path).path; });
672
+ var exclude = (_a = this.pathDefinitions.exclude) === null || _a === void 0 ? void 0 : _a.map(function (path) { return dottedPath_1.DottedPath.create(path).path; });
673
+ var keys = Array.from(dottedNodes.keys()).map(function (dottedPath) { return dottedPath.path; });
674
+ lodash_es_1.union(include, exclude).forEach(function (path) {
675
+ if (keys.indexOf(path) === -1) {
676
+ throw new Error("Node with path \"" + path + "\" does not exist for element \"" + _this.id + "\".");
677
+ }
678
+ });
679
+ };
680
+ return Element;
681
+ }(elementParameterizable_1.ElementParameterizable));
682
+ exports.Element = Element;
740
683
  //# sourceMappingURL=element.js.map