@combeenation/3d-viewer 3.1.1-alpha7 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -111
- package/dist/lib-cjs/api/classes/animationInterface.d.ts +8 -8
- package/dist/lib-cjs/api/classes/animationInterface.js +1 -1
- package/dist/lib-cjs/api/classes/dottedPath.d.ts +79 -79
- package/dist/lib-cjs/api/classes/dottedPath.js +190 -190
- package/dist/lib-cjs/api/classes/element.d.ts +125 -126
- package/dist/lib-cjs/api/classes/element.js +678 -674
- package/dist/lib-cjs/api/classes/element.js.map +1 -1
- package/dist/lib-cjs/api/classes/elementParameterizable.d.ts +14 -14
- package/dist/lib-cjs/api/classes/elementParameterizable.js +134 -134
- package/dist/lib-cjs/api/classes/event.d.ts +312 -312
- package/dist/lib-cjs/api/classes/event.js +357 -357
- package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
- package/dist/lib-cjs/api/classes/eventBroadcaster.js +53 -53
- package/dist/lib-cjs/api/classes/parameter.d.ts +165 -165
- package/dist/lib-cjs/api/classes/parameter.js +267 -267
- package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
- package/dist/lib-cjs/api/classes/parameterObservable.js +126 -126
- package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -15
- package/dist/lib-cjs/api/classes/parameterizable.js +149 -149
- package/dist/lib-cjs/api/classes/placementAnimation.d.ts +38 -38
- package/dist/lib-cjs/api/classes/placementAnimation.js +138 -138
- package/dist/lib-cjs/api/classes/variant.d.ts +180 -190
- package/dist/lib-cjs/api/classes/variant.js +863 -873
- package/dist/lib-cjs/api/classes/variant.js.map +1 -1
- package/dist/lib-cjs/api/classes/variantInstance.d.ts +41 -41
- package/dist/lib-cjs/api/classes/variantInstance.js +98 -98
- package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -17
- package/dist/lib-cjs/api/classes/variantParameterizable.js +92 -92
- package/dist/lib-cjs/api/classes/viewer.d.ts +128 -128
- package/dist/lib-cjs/api/classes/viewer.js +486 -486
- package/dist/lib-cjs/api/classes/viewerLight.d.ts +65 -66
- package/dist/lib-cjs/api/classes/viewerLight.js +322 -389
- package/dist/lib-cjs/api/classes/viewerLight.js.map +1 -1
- package/dist/lib-cjs/api/internal/debugViewer.d.ts +13 -13
- package/dist/lib-cjs/api/internal/debugViewer.js +87 -87
- package/dist/lib-cjs/api/internal/lensRendering.d.ts +8 -8
- package/dist/lib-cjs/api/internal/lensRendering.js +11 -11
- package/dist/lib-cjs/api/internal/sceneSetup.d.ts +6 -6
- package/dist/lib-cjs/api/internal/sceneSetup.js +227 -227
- package/dist/lib-cjs/api/manager/animationManager.d.ts +29 -29
- package/dist/lib-cjs/api/manager/animationManager.js +121 -121
- package/dist/lib-cjs/api/manager/sceneManager.d.ts +32 -32
- package/dist/lib-cjs/api/manager/sceneManager.js +132 -132
- package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +90 -90
- package/dist/lib-cjs/api/manager/variantInstanceManager.js +321 -321
- package/dist/lib-cjs/api/store/specStorage.d.ts +24 -24
- package/dist/lib-cjs/api/store/specStorage.js +51 -51
- package/dist/lib-cjs/api/util/babylonHelper.d.ts +125 -125
- package/dist/lib-cjs/api/util/babylonHelper.js +368 -368
- package/dist/lib-cjs/api/util/globalTypes.d.ts +275 -275
- package/dist/lib-cjs/api/util/globalTypes.js +1 -1
- package/dist/lib-cjs/api/util/resourceHelper.d.ts +30 -30
- package/dist/lib-cjs/api/util/resourceHelper.js +247 -203
- package/dist/lib-cjs/api/util/resourceHelper.js.map +1 -1
- package/dist/lib-cjs/api/util/stringHelper.d.ts +9 -9
- package/dist/lib-cjs/api/util/stringHelper.js +25 -25
- package/dist/lib-cjs/buildinfo.json +3 -3
- package/dist/lib-cjs/index.d.ts +46 -46
- package/dist/lib-cjs/index.js +82 -82
- package/dist/webpack-stats.json +0 -0
- package/package.json +83 -83
- package/src/api/classes/animationInterface.ts +11 -11
- package/src/api/classes/dottedPath.ts +189 -189
- package/src/api/classes/element.ts +608 -606
- package/src/api/classes/elementParameterizable.ts +78 -78
- package/src/api/classes/event.ts +355 -355
- package/src/api/classes/eventBroadcaster.ts +54 -54
- package/src/api/classes/parameter.ts +277 -277
- package/src/api/classes/parameterObservable.ts +121 -121
- package/src/api/classes/placementAnimation.ts +133 -133
- package/src/api/classes/variant.ts +659 -670
- package/src/api/classes/variantInstance.ts +81 -81
- package/src/api/classes/viewer.ts +421 -421
- package/src/api/internal/debugViewer.ts +81 -81
- package/src/api/internal/lensRendering.ts +10 -10
- package/src/api/internal/sceneSetup.ts +203 -203
- package/src/api/manager/animationManager.ts +116 -116
- package/src/api/manager/sceneManager.ts +105 -105
- package/src/api/manager/variantInstanceManager.ts +236 -236
- package/src/api/store/specStorage.ts +53 -53
- package/src/api/util/babylonHelper.ts +392 -392
- package/src/api/util/globalTypes.ts +314 -314
- package/src/api/util/resourceHelper.ts +168 -155
- package/src/buildinfo.json +2 -2
- package/src/commonjs.tsconfig.json +13 -13
- package/src/declaration.tsconfig.json +10 -10
- package/src/dev.ts +44 -46
- package/src/es6.tsconfig.json +13 -13
- package/src/index.ts +87 -87
- package/src/pagesconfig.json +47 -47
- package/src/tsconfig.json +43 -43
- package/src/tsconfig.types.json +9 -9
- package/src/types.d.ts +4 -4
|
@@ -1,675 +1,679 @@
|
|
|
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
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
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.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
_this.
|
|
48
|
-
_this.
|
|
49
|
-
_this
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
dottedPath.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
*
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
var
|
|
161
|
-
var
|
|
162
|
-
var
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
case
|
|
178
|
-
|
|
179
|
-
node
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
var
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
var
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
*
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
payload.style.
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
babylonHelper_1.
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
babylonHelper_1.
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
babylonHelper_1.
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
(
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
node.
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
node.
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
var
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
var
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
}
|
|
674
|
-
|
|
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
|
+
var paintableDefinition = this.getPaintableDefinition(paintable);
|
|
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
|
+
var widthAndHeight = {
|
|
315
|
+
width: imageSource.width,
|
|
316
|
+
height: imageSource.height
|
|
317
|
+
};
|
|
318
|
+
if (lodash_es_1.isNumber(paintableDefinition.textureOptions)) {
|
|
319
|
+
widthAndHeight.width = paintableDefinition.textureOptions;
|
|
320
|
+
widthAndHeight.height = paintableDefinition.textureOptions;
|
|
321
|
+
}
|
|
322
|
+
else if (lodash_es_1.isPlainObject(paintableDefinition.textureOptions)) {
|
|
323
|
+
widthAndHeight.width = paintableDefinition.textureOptions.width;
|
|
324
|
+
widthAndHeight.height = paintableDefinition.textureOptions.height;
|
|
325
|
+
}
|
|
326
|
+
var texture = new dynamicTexture_1.DynamicTexture(this.id + "." + paintable + ".texture", widthAndHeight, this.variant.viewer.scene, false);
|
|
327
|
+
babylonHelper_1.setMaterialTexture(node, texture, false);
|
|
328
|
+
var ctx = texture.getContext();
|
|
329
|
+
// flip texture context horizontal with translate and scale
|
|
330
|
+
ctx.drawImage(imageSource, 0, 0);
|
|
331
|
+
texture.update(false);
|
|
332
|
+
return this;
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Draws a SVG string onto a `paintable` defined via {@link PaintableDefinition}.
|
|
336
|
+
*/
|
|
337
|
+
Element.prototype.drawPaintableFromSvg = function (paintable, svgSource) {
|
|
338
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
339
|
+
var source;
|
|
340
|
+
return tslib_1.__generator(this, function (_a) {
|
|
341
|
+
switch (_a.label) {
|
|
342
|
+
case 0: return [4 /*yield*/, resourceHelper_1.createImageBitmapFromSvg(svgSource)];
|
|
343
|
+
case 1:
|
|
344
|
+
source = _a.sent();
|
|
345
|
+
return [2 /*return*/, this.drawPaintable(paintable, source)];
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* Draws an Image from source (URL/URI) onto a `paintable` defined via {@link PaintableDefinition}.
|
|
352
|
+
*/
|
|
353
|
+
Element.prototype.drawPaintableFromImgSrc = function (paintable, imgSource) {
|
|
354
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
355
|
+
var source;
|
|
356
|
+
return tslib_1.__generator(this, function (_a) {
|
|
357
|
+
switch (_a.label) {
|
|
358
|
+
case 0: return [4 /*yield*/, resourceHelper_1.createImageBitmapFromImgSrc(imgSource)];
|
|
359
|
+
case 1:
|
|
360
|
+
source = _a.sent();
|
|
361
|
+
return [2 /*return*/, this.drawPaintable(paintable, source)];
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* Adds the default {@link ParameterObserver}s which are called every time {@link commitParameters} is called.
|
|
368
|
+
*/
|
|
369
|
+
Element.prototype.addParameterObservers = function () {
|
|
370
|
+
var _this = this;
|
|
371
|
+
this._parameterObservers.set(parameter_1.Parameter.VISIBLE, [
|
|
372
|
+
function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
373
|
+
var visible;
|
|
374
|
+
return tslib_1.__generator(this, function (_a) {
|
|
375
|
+
try {
|
|
376
|
+
visible = parameter_1.Parameter.parseBoolean(newValue);
|
|
377
|
+
}
|
|
378
|
+
catch (e) {
|
|
379
|
+
return [2 /*return*/];
|
|
380
|
+
}
|
|
381
|
+
if (visible === true) {
|
|
382
|
+
element.nodes.forEach(function (node) {
|
|
383
|
+
babylonHelper_1.injectTransformNodeMetadata(node, { visibility: node.isEnabled() });
|
|
384
|
+
babylonHelper_1.activateTransformNode(node);
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
else if (visible === false) {
|
|
388
|
+
element.nodes.forEach(function (node) {
|
|
389
|
+
babylonHelper_1.injectTransformNodeMetadata(node, { visibility: node.isEnabled() });
|
|
390
|
+
babylonHelper_1.deactivateTransformNode(node);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
return [2 /*return*/];
|
|
394
|
+
});
|
|
395
|
+
}); }
|
|
396
|
+
]);
|
|
397
|
+
this._parameterObservers.set(parameter_1.Parameter.SCALING, [
|
|
398
|
+
function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
399
|
+
return tslib_1.__generator(this, function (_a) {
|
|
400
|
+
// we have to deal just with root nodes here due to relative impacts in a node tree
|
|
401
|
+
element.nodes.forEach(function (node) { return node.scaling = parameter_1.Parameter.parseScaling(newValue); });
|
|
402
|
+
return [2 /*return*/];
|
|
403
|
+
});
|
|
404
|
+
}); }
|
|
405
|
+
]);
|
|
406
|
+
this._parameterObservers.set(parameter_1.Parameter.MATERIAL, [
|
|
407
|
+
function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
408
|
+
var material;
|
|
409
|
+
return tslib_1.__generator(this, function (_a) {
|
|
410
|
+
material = element.variant.getMaterial(newValue.toString());
|
|
411
|
+
element.nodes.forEach(function (node) {
|
|
412
|
+
babylonHelper_1.assertTransformNode(node, function (node) {
|
|
413
|
+
if (node instanceof instancedMesh_1.InstancedMesh) {
|
|
414
|
+
throw new Error("Changing parameter \"" + parameter_1.Parameter.MATERIAL + "\" " +
|
|
415
|
+
"of an InstancedMesh is not supported. " +
|
|
416
|
+
("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
babylonHelper_1.setMaterial(node, material);
|
|
420
|
+
});
|
|
421
|
+
return [2 /*return*/];
|
|
422
|
+
});
|
|
423
|
+
}); }
|
|
424
|
+
]);
|
|
425
|
+
this._parameterObservers.set(parameter_1.Parameter.MATERIAL_COLOR, [
|
|
426
|
+
function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
427
|
+
var color;
|
|
428
|
+
return tslib_1.__generator(this, function (_a) {
|
|
429
|
+
color = parameter_1.Parameter.parseColor(newValue);
|
|
430
|
+
element.nodes.forEach(function (node) {
|
|
431
|
+
babylonHelper_1.assertTransformNode(node, function (node) {
|
|
432
|
+
if (node instanceof instancedMesh_1.InstancedMesh) {
|
|
433
|
+
throw new Error("Changing parameter \"" + parameter_1.Parameter.MATERIAL_COLOR + "\" " +
|
|
434
|
+
"of an InstancedMesh is not supported. " +
|
|
435
|
+
("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
if (!lodash_es_1.get(node.metadata, 'dirty.material')) {
|
|
439
|
+
babylonHelper_1.cloneTransformNodeMaterial(node);
|
|
440
|
+
}
|
|
441
|
+
if (!lodash_es_1.get(node.metadata, 'dirty.material.color')) {
|
|
442
|
+
// inject initial value and mark as dirty
|
|
443
|
+
babylonHelper_1.injectTransformNodeMetadata(node, { dirty: { material: { color: oldValue } } });
|
|
444
|
+
}
|
|
445
|
+
babylonHelper_1.setMaterialColor(node, color);
|
|
446
|
+
});
|
|
447
|
+
return [2 /*return*/];
|
|
448
|
+
});
|
|
449
|
+
}); }
|
|
450
|
+
]);
|
|
451
|
+
this._parameterObservers.set(parameter_1.Parameter.MATERIAL_METALLNESS, [
|
|
452
|
+
function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
453
|
+
var metallness;
|
|
454
|
+
return tslib_1.__generator(this, function (_a) {
|
|
455
|
+
metallness = parameter_1.Parameter.parseNumber(newValue);
|
|
456
|
+
element.nodes.forEach(function (node) {
|
|
457
|
+
babylonHelper_1.assertTransformNode(node, function (node) {
|
|
458
|
+
if (node instanceof instancedMesh_1.InstancedMesh) {
|
|
459
|
+
throw new Error("Changing parameter \"" + parameter_1.Parameter.MATERIAL_METALLNESS + "\" " +
|
|
460
|
+
"of an InstancedMesh is not supported. " +
|
|
461
|
+
("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
if (!lodash_es_1.get(node.metadata, 'dirty.material')) {
|
|
465
|
+
babylonHelper_1.cloneTransformNodeMaterial(node);
|
|
466
|
+
}
|
|
467
|
+
if (!lodash_es_1.get(node.metadata, 'dirty.material.metallness')) {
|
|
468
|
+
// inject initial value and mark as dirty
|
|
469
|
+
babylonHelper_1.injectTransformNodeMetadata(node, { dirty: { material: { metallness: oldValue } } });
|
|
470
|
+
}
|
|
471
|
+
babylonHelper_1.setMaterialMetallness(node, metallness);
|
|
472
|
+
});
|
|
473
|
+
return [2 /*return*/];
|
|
474
|
+
});
|
|
475
|
+
}); }
|
|
476
|
+
]);
|
|
477
|
+
this._parameterObservers.set(parameter_1.Parameter.MATERIAL_ROUGHNESS, [
|
|
478
|
+
function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
479
|
+
var roughness;
|
|
480
|
+
return tslib_1.__generator(this, function (_a) {
|
|
481
|
+
roughness = parameter_1.Parameter.parseNumber(newValue);
|
|
482
|
+
element.nodes.forEach(function (node) {
|
|
483
|
+
babylonHelper_1.assertTransformNode(node, function (node) {
|
|
484
|
+
if (node instanceof instancedMesh_1.InstancedMesh) {
|
|
485
|
+
throw new Error("Changing parameter \"" + parameter_1.Parameter.MATERIAL_ROUGHNESS + "\" " +
|
|
486
|
+
"of an InstancedMesh is not supported. " +
|
|
487
|
+
("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
if (!lodash_es_1.get(node.metadata, 'dirty.material')) {
|
|
491
|
+
babylonHelper_1.cloneTransformNodeMaterial(node);
|
|
492
|
+
}
|
|
493
|
+
if (!lodash_es_1.get(node.metadata, 'dirty.material.roughness')) {
|
|
494
|
+
// inject initial value and mark as dirty
|
|
495
|
+
babylonHelper_1.injectTransformNodeMetadata(node, { dirty: { material: { roughness: oldValue } } });
|
|
496
|
+
}
|
|
497
|
+
babylonHelper_1.setMaterialRoughness(node, roughness);
|
|
498
|
+
});
|
|
499
|
+
return [2 /*return*/];
|
|
500
|
+
});
|
|
501
|
+
}); }
|
|
502
|
+
]);
|
|
503
|
+
this._parameterObservers.set(parameter_1.Parameter.HIGHLIGHT_COLOR, [
|
|
504
|
+
function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
505
|
+
var _a;
|
|
506
|
+
return tslib_1.__generator(this, function (_b) {
|
|
507
|
+
// trigger Parameter.HIGHLIGHTED observers
|
|
508
|
+
(_a = this._parameterObservers.get(parameter_1.Parameter.HIGHLIGHTED)) === null || _a === void 0 ? void 0 : _a.forEach(function (observer) {
|
|
509
|
+
observer(element, !!element.highlighted, !!element.highlighted);
|
|
510
|
+
});
|
|
511
|
+
return [2 /*return*/];
|
|
512
|
+
});
|
|
513
|
+
}); }
|
|
514
|
+
]);
|
|
515
|
+
this._parameterObservers.set(parameter_1.Parameter.HIGHLIGHT_ENABLED, [
|
|
516
|
+
function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
517
|
+
var curr;
|
|
518
|
+
var _a;
|
|
519
|
+
return tslib_1.__generator(this, function (_b) {
|
|
520
|
+
try {
|
|
521
|
+
curr = parameter_1.Parameter.parseBoolean(newValue);
|
|
522
|
+
}
|
|
523
|
+
catch (e) {
|
|
524
|
+
return [2 /*return*/];
|
|
525
|
+
}
|
|
526
|
+
switch (curr) {
|
|
527
|
+
case true:
|
|
528
|
+
if (element._highlightLayer) {
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
element.highlightLayer = new highlightLayer_1.HighlightLayer(dottedPath_1.DottedPath.create(element.id).addPart('highlight').path, element.variant.viewer.scene);
|
|
532
|
+
break;
|
|
533
|
+
case false:
|
|
534
|
+
(_a = element.highlightLayer) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
535
|
+
break;
|
|
536
|
+
}
|
|
537
|
+
return [2 /*return*/];
|
|
538
|
+
});
|
|
539
|
+
}); }
|
|
540
|
+
]);
|
|
541
|
+
this._parameterObservers.set(parameter_1.Parameter.HIGHLIGHTED, [
|
|
542
|
+
function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
543
|
+
var highlighted;
|
|
544
|
+
var _this = this;
|
|
545
|
+
var _a;
|
|
546
|
+
return tslib_1.__generator(this, function (_b) {
|
|
547
|
+
if (!element.inheritedParameters[parameter_1.Parameter.HIGHLIGHT_ENABLED]) {
|
|
548
|
+
return [2 /*return*/];
|
|
549
|
+
}
|
|
550
|
+
// trigger Parameter.HIGHLIGHT_ENABLED observers to ensure HighlightLayer
|
|
551
|
+
(_a = this._parameterObservers.get(parameter_1.Parameter.HIGHLIGHT_ENABLED)) === null || _a === void 0 ? void 0 : _a.forEach(function (observer) {
|
|
552
|
+
observer(element, _this.parameters[parameter_1.Parameter.HIGHLIGHT_ENABLED], true);
|
|
553
|
+
});
|
|
554
|
+
try {
|
|
555
|
+
highlighted = parameter_1.Parameter.parseBoolean(newValue);
|
|
556
|
+
}
|
|
557
|
+
catch (e) {
|
|
558
|
+
return [2 /*return*/];
|
|
559
|
+
}
|
|
560
|
+
// Add/Remove meshes to previously created highlight layers.
|
|
561
|
+
if (highlighted === true) {
|
|
562
|
+
element.nodes.forEach(function (node) {
|
|
563
|
+
babylonHelper_1.assertTransformNode(node, function (node) {
|
|
564
|
+
if (node instanceof instancedMesh_1.InstancedMesh) {
|
|
565
|
+
throw new Error("Changing parameter \"" + parameter_1.Parameter.HIGHLIGHTED + "\" " +
|
|
566
|
+
"of an InstancedMesh is not supported. " +
|
|
567
|
+
("Tried to change node \"" + node.id + "\" on element \"" + element.id + "\"."));
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
var color = math_color_1.Color3.Green();
|
|
571
|
+
if (element.inheritedParameters[parameter_1.Parameter.HIGHLIGHT_COLOR]) {
|
|
572
|
+
color = parameter_1.Parameter.parseColor(element.inheritedParameters[parameter_1.Parameter.HIGHLIGHT_COLOR]);
|
|
573
|
+
}
|
|
574
|
+
if (typeof element._highlightLayer !== "undefined") {
|
|
575
|
+
babylonHelper_1.addToHighlightLayer(element._highlightLayer, color, node);
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
else if (highlighted === false) {
|
|
580
|
+
element.nodes.forEach(function (node) {
|
|
581
|
+
if (typeof element._highlightLayer !== "undefined") {
|
|
582
|
+
babylonHelper_1.removeFromHighlightLayer(element._highlightLayer, node);
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
return [2 /*return*/];
|
|
587
|
+
});
|
|
588
|
+
}); }
|
|
589
|
+
]);
|
|
590
|
+
this._parameterObservers.set(parameter_1.Parameter.POSITION, [
|
|
591
|
+
function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
592
|
+
return tslib_1.__generator(this, function (_a) {
|
|
593
|
+
// we have to deal just with root nodes here due to relative impacts in a node tree
|
|
594
|
+
element.nodes.forEach(function (node) {
|
|
595
|
+
// remember absolute position and reset it before translating
|
|
596
|
+
if (!lodash_es_1.get(node.metadata, 'position')) {
|
|
597
|
+
node.metadata.position = node.absolutePosition.clone();
|
|
598
|
+
}
|
|
599
|
+
node.setAbsolutePosition(node.metadata.position);
|
|
600
|
+
// move
|
|
601
|
+
var distance = parameter_1.Parameter.parseVector(newValue);
|
|
602
|
+
node.translate(math_axis_1.Axis.X, distance.x, math_axis_1.Space.WORLD);
|
|
603
|
+
node.translate(math_axis_1.Axis.Y, distance.y, math_axis_1.Space.WORLD);
|
|
604
|
+
node.translate(math_axis_1.Axis.Z, distance.z, math_axis_1.Space.WORLD);
|
|
605
|
+
});
|
|
606
|
+
return [2 /*return*/];
|
|
607
|
+
});
|
|
608
|
+
}); }
|
|
609
|
+
]);
|
|
610
|
+
this._parameterObservers.set(parameter_1.Parameter.ROTATION, [
|
|
611
|
+
function (element, oldValue, newValue) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
612
|
+
return tslib_1.__generator(this, function (_a) {
|
|
613
|
+
// we have to deal just with root nodes here due to relative impacts in a node tree
|
|
614
|
+
element.nodes.forEach(function (node) {
|
|
615
|
+
// remember absolute rotation and reset it before translating
|
|
616
|
+
if (!lodash_es_1.get(node.metadata, 'rotation')) {
|
|
617
|
+
node.metadata.rotation = node.rotation.clone();
|
|
618
|
+
}
|
|
619
|
+
node.rotation = node.metadata.rotation;
|
|
620
|
+
// rotate
|
|
621
|
+
var rotation = parameter_1.Parameter.parseRotation(newValue);
|
|
622
|
+
node.rotate(math_axis_1.Axis.X, rotation.x, math_axis_1.Space.WORLD);
|
|
623
|
+
node.rotate(math_axis_1.Axis.Y, rotation.y, math_axis_1.Space.WORLD);
|
|
624
|
+
node.rotate(math_axis_1.Axis.Z, rotation.z, math_axis_1.Space.WORLD);
|
|
625
|
+
});
|
|
626
|
+
return [2 /*return*/];
|
|
627
|
+
});
|
|
628
|
+
}); }
|
|
629
|
+
]);
|
|
630
|
+
return this;
|
|
631
|
+
};
|
|
632
|
+
/**
|
|
633
|
+
* Filter for nodes that are not defined or excluded in the `pathDefinitions`.
|
|
634
|
+
*/
|
|
635
|
+
Element.prototype.filterNode = function (node) {
|
|
636
|
+
var _this = this;
|
|
637
|
+
var includeTokens = [];
|
|
638
|
+
this.pathDefinitions.include.forEach(function (dottedPath) {
|
|
639
|
+
includeTokens = lodash_es_1.union(includeTokens, dottedPath_1.DottedPath.create(dottedPath).leafTokens);
|
|
640
|
+
});
|
|
641
|
+
var shallKeep = function (dp) {
|
|
642
|
+
var isDirectlyIncluded = !!includeTokens.find(function (_dp) { return _dp === dp.path; });
|
|
643
|
+
var isSubOfIncluded = !!_this.pathDefinitions.include.find(function (_dp) {
|
|
644
|
+
return dp.path.startsWith("" + _dp + dottedPath_1.DottedPath.DELIMITER);
|
|
645
|
+
});
|
|
646
|
+
return isDirectlyIncluded || isSubOfIncluded;
|
|
647
|
+
};
|
|
648
|
+
var shallExclude = function (dp) {
|
|
649
|
+
if (!_this.pathDefinitions.exclude) {
|
|
650
|
+
return false;
|
|
651
|
+
}
|
|
652
|
+
return !!_this.pathDefinitions.exclude.find(function (_dp) { return dp.path === _dp; });
|
|
653
|
+
};
|
|
654
|
+
return shallKeep(node.metadata.dottedPath) && !shallExclude(node.metadata.dottedPath);
|
|
655
|
+
};
|
|
656
|
+
/**
|
|
657
|
+
* Asserts whether all {@link pathDefinitions} link to a valid `Node` path.
|
|
658
|
+
* @protected
|
|
659
|
+
*/
|
|
660
|
+
Element.prototype.assertPathDefinitions = function () {
|
|
661
|
+
var _this = this;
|
|
662
|
+
var _a;
|
|
663
|
+
var dottedNodes = this.variant.inheritedDottedNodes;
|
|
664
|
+
if (dottedNodes.size === 0) {
|
|
665
|
+
throw new Error("There are no mapped nodes for element \"" + this.id + "\".");
|
|
666
|
+
}
|
|
667
|
+
var include = this.pathDefinitions.include.map(function (path) { return dottedPath_1.DottedPath.create(path).path; });
|
|
668
|
+
var exclude = (_a = this.pathDefinitions.exclude) === null || _a === void 0 ? void 0 : _a.map(function (path) { return dottedPath_1.DottedPath.create(path).path; });
|
|
669
|
+
var keys = Array.from(dottedNodes.keys()).map(function (dottedPath) { return dottedPath.path; });
|
|
670
|
+
lodash_es_1.union(include, exclude).forEach(function (path) {
|
|
671
|
+
if (keys.indexOf(path) === -1) {
|
|
672
|
+
throw new Error("Node with path \"" + path + "\" does not exist for element \"" + _this.id + "\".");
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
};
|
|
676
|
+
return Element;
|
|
677
|
+
}(elementParameterizable_1.ElementParameterizable));
|
|
678
|
+
exports.Element = Element;
|
|
675
679
|
//# sourceMappingURL=element.js.map
|