@combeenation/3d-viewer 4.0.0-beta5 → 4.0.0-rc1

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 (95) hide show
  1. package/README.md +114 -114
  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 +130 -130
  7. package/dist/lib-cjs/api/classes/element.js +743 -743
  8. package/dist/lib-cjs/api/classes/elementParameterizable.d.ts +14 -14
  9. package/dist/lib-cjs/api/classes/elementParameterizable.js +134 -134
  10. package/dist/lib-cjs/api/classes/event.d.ts +326 -326
  11. package/dist/lib-cjs/api/classes/event.js +371 -371
  12. package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
  13. package/dist/lib-cjs/api/classes/eventBroadcaster.js +53 -53
  14. package/dist/lib-cjs/api/classes/parameter.d.ts +259 -259
  15. package/dist/lib-cjs/api/classes/parameter.js +387 -387
  16. package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
  17. package/dist/lib-cjs/api/classes/parameterObservable.js +101 -101
  18. package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -15
  19. package/dist/lib-cjs/api/classes/parameterizable.js +149 -149
  20. package/dist/lib-cjs/api/classes/placementAnimation.d.ts +38 -38
  21. package/dist/lib-cjs/api/classes/placementAnimation.js +149 -149
  22. package/dist/lib-cjs/api/classes/variant.d.ts +234 -234
  23. package/dist/lib-cjs/api/classes/variant.js +1147 -1147
  24. package/dist/lib-cjs/api/classes/variantInstance.d.ts +45 -45
  25. package/dist/lib-cjs/api/classes/variantInstance.js +108 -108
  26. package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -17
  27. package/dist/lib-cjs/api/classes/variantParameterizable.js +92 -92
  28. package/dist/lib-cjs/api/classes/viewer.d.ts +131 -131
  29. package/dist/lib-cjs/api/classes/viewer.js +567 -560
  30. package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
  31. package/dist/lib-cjs/api/classes/viewerLight.d.ts +66 -66
  32. package/dist/lib-cjs/api/classes/viewerLight.js +389 -389
  33. package/dist/lib-cjs/api/internal/debugViewer.d.ts +13 -13
  34. package/dist/lib-cjs/api/internal/debugViewer.js +87 -87
  35. package/dist/lib-cjs/api/internal/lensRendering.d.ts +8 -8
  36. package/dist/lib-cjs/api/internal/lensRendering.js +11 -11
  37. package/dist/lib-cjs/api/internal/sceneSetup.d.ts +10 -10
  38. package/dist/lib-cjs/api/internal/sceneSetup.js +231 -231
  39. package/dist/lib-cjs/api/manager/animationManager.d.ts +29 -29
  40. package/dist/lib-cjs/api/manager/animationManager.js +121 -121
  41. package/dist/lib-cjs/api/manager/sceneManager.d.ts +32 -32
  42. package/dist/lib-cjs/api/manager/sceneManager.js +132 -132
  43. package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +90 -90
  44. package/dist/lib-cjs/api/manager/variantInstanceManager.js +321 -321
  45. package/dist/lib-cjs/api/store/specStorage.d.ts +24 -24
  46. package/dist/lib-cjs/api/store/specStorage.js +51 -51
  47. package/dist/lib-cjs/api/util/babylonHelper.d.ts +175 -175
  48. package/dist/lib-cjs/api/util/babylonHelper.js +520 -520
  49. package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
  50. package/dist/lib-cjs/api/util/globalTypes.d.ts +333 -333
  51. package/dist/lib-cjs/api/util/globalTypes.js +1 -1
  52. package/dist/lib-cjs/api/util/resourceHelper.d.ts +53 -53
  53. package/dist/lib-cjs/api/util/resourceHelper.js +240 -240
  54. package/dist/lib-cjs/api/util/stringHelper.d.ts +9 -9
  55. package/dist/lib-cjs/api/util/stringHelper.js +25 -25
  56. package/dist/lib-cjs/buildinfo.json +3 -3
  57. package/dist/lib-cjs/index.d.ts +48 -48
  58. package/dist/lib-cjs/index.js +86 -86
  59. package/dist/webpack-stats.json +0 -0
  60. package/package.json +83 -83
  61. package/src/api/classes/animationInterface.ts +11 -11
  62. package/src/api/classes/dottedPath.ts +189 -189
  63. package/src/api/classes/element.ts +644 -644
  64. package/src/api/classes/event.ts +370 -370
  65. package/src/api/classes/eventBroadcaster.ts +54 -54
  66. package/src/api/classes/parameter.ts +408 -408
  67. package/src/api/classes/parameterObservable.ts +99 -99
  68. package/src/api/classes/parameterizable.ts +89 -89
  69. package/src/api/classes/placementAnimation.ts +143 -143
  70. package/src/api/classes/variant.ts +817 -817
  71. package/src/api/classes/variantInstance.ts +88 -88
  72. package/src/api/classes/variantParameterizable.ts +73 -73
  73. package/src/api/classes/viewer.ts +487 -478
  74. package/src/api/classes/viewerLight.ts +330 -330
  75. package/src/api/internal/debugViewer.ts +81 -81
  76. package/src/api/internal/lensRendering.ts +10 -10
  77. package/src/api/internal/sceneSetup.ts +193 -193
  78. package/src/api/manager/animationManager.ts +116 -116
  79. package/src/api/manager/sceneManager.ts +105 -105
  80. package/src/api/manager/variantInstanceManager.ts +236 -236
  81. package/src/api/store/specStorage.ts +53 -53
  82. package/src/api/util/babylonHelper.ts +555 -553
  83. package/src/api/util/globalTypes.ts +379 -379
  84. package/src/api/util/resourceHelper.ts +184 -184
  85. package/src/api/util/stringHelper.ts +25 -25
  86. package/src/buildinfo.json +2 -2
  87. package/src/commonjs.tsconfig.json +13 -13
  88. package/src/declaration.tsconfig.json +10 -10
  89. package/src/dev.ts +42 -42
  90. package/src/es6.tsconfig.json +13 -13
  91. package/src/index.ts +91 -91
  92. package/src/pagesconfig.json +61 -61
  93. package/src/tsconfig.json +43 -43
  94. package/src/tsconfig.types.json +9 -9
  95. package/src/types.d.ts +4 -4
@@ -1,553 +1,555 @@
1
- import { HighlightLayer } from '@babylonjs/core/Layers/highlightLayer';
2
- import { Light } from '@babylonjs/core/Lights/light';
3
- import { ShadowGenerator } from '@babylonjs/core/Lights/Shadows/shadowGenerator';
4
- import { Material } from '@babylonjs/core/Materials/material';
5
- import { PBRMaterial } from '@babylonjs/core/Materials/PBR/pbrMaterial';
6
- import { StandardMaterial } from '@babylonjs/core/Materials/standardMaterial';
7
- import { Axis } from '@babylonjs/core/Maths/math.axis';
8
- import { Color3 } from '@babylonjs/core/Maths/math.color';
9
- import { Quaternion, Vector3 } from '@babylonjs/core/Maths/math.vector';
10
- import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';
11
- import { InstancedMesh } from '@babylonjs/core/Meshes/instancedMesh';
12
- import { Mesh } from '@babylonjs/core/Meshes/mesh';
13
- import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
14
- import { Node } from '@babylonjs/core/node';
15
- import { Scene } from '@babylonjs/core/scene';
16
- import { cloneDeep, get, has, merge } from 'lodash-es';
17
- import { DottedPath } from '../classes/dottedPath';
18
-
19
- /**
20
- * @param node
21
- * @return Node
22
- */
23
- const getRootNode = function( node: Node ): Node {
24
- let _node = node;
25
- while( _node.parent ) {
26
- _node = _node.parent;
27
- }
28
- return _node;
29
- }
30
-
31
- /**
32
- * @param nodes
33
- * @param predicate
34
- * @return Map<DottedPath, T>
35
- */
36
- const mapToDottedNodes = function <T>( nodes: Node[],
37
- predicate?: ( node: Node ) => boolean ): Map<DottedPath, T> {
38
- const map = new Map<DottedPath, T>();
39
- const addNodes = function( _node: Node ) {
40
- if( predicate && predicate( _node ) ) {
41
- map.set( _node.metadata.dottedPath, _node as any );
42
- }
43
- _node.getChildren().forEach( child => {
44
- addNodes( child );
45
- } );
46
- };
47
- nodes.forEach( node => {
48
- addNodes( node );
49
- } );
50
- return map;
51
- };
52
-
53
- /**
54
- * @param node
55
- * @return DottedPath
56
- */
57
- const getDottedPathForNode = function( node: Node ): DottedPath {
58
- const dottedPath = DottedPath.create( node.name );
59
- let _parent = node;
60
- while( _parent.parent ) {
61
- _parent = _parent.parent;
62
- dottedPath.unshiftPart( _parent.name );
63
- }
64
- return dottedPath;
65
- };
66
-
67
- /**
68
- * @param node
69
- * @param predicate
70
- * @param deep
71
- * @return TransformNode | null
72
- */
73
- const cloneTransformNode = function( node: TransformNode,
74
- predicate?: ( node: TransformNode ) => boolean,
75
- deep: boolean = true ): TransformNode | null {
76
- if( predicate && !predicate( node ) ) {
77
- return null;
78
- }
79
- const clone = node.clone( node.name, node.parent, true );
80
- if( clone ) {
81
- clone.metadata = cloneDeep( node.metadata );
82
- }
83
- if( deep ) {
84
- const children = node.getChildTransformNodes( true );
85
- children.forEach( child => {
86
- const clonedChild = cloneTransformNode( child, predicate, deep );
87
- if( clonedChild ) {
88
- clonedChild.parent = clone;
89
- }
90
- } );
91
- }
92
- return clone;
93
- };
94
-
95
- /**
96
- * @param node
97
- */
98
- const cloneNodeWithParents = function( node: Node | null ): Node | null {
99
- let clone = null;
100
- if( node instanceof TransformNode ) {
101
- clone = node.clone( node.name, cloneNodeWithParents( node.parent ), true );
102
- } else if( node instanceof Light ) {
103
- clone = node.clone( node.name, cloneNodeWithParents( node.parent ) );
104
- } else if( node ) {
105
- throw new Error( `Cloning of "${node?.constructor.name}" is not implemented (yet).` );
106
- }
107
- return clone;
108
- };
109
-
110
- /**
111
- * @param node
112
- * @param deep
113
- * @param prefix
114
- * @return TransformNode
115
- */
116
- const cloneTransformNodeMaterial = function( node: TransformNode,
117
- prefix: DottedPathArgument = '',
118
- deep: boolean = true ): TransformNode {
119
- if( node instanceof AbstractMesh && node.material ) {
120
- const _prefix = DottedPath.create( prefix ).addParts([
121
- 'node',
122
- node.uniqueId.toString()
123
- ]);
124
- node.material = node.material.clone( _prefix.path );
125
- }
126
- if( deep ) {
127
- const children = node.getChildTransformNodes( true );
128
- children.forEach( child => cloneTransformNodeMaterial( child, prefix, deep ) );
129
- }
130
- return node;
131
- };
132
-
133
- /**
134
- * @param node
135
- * @param deep
136
- * @param metadata
137
- */
138
- const injectNodeMetadata = function( node: Node, metadata: {}, deep: boolean = true ) {
139
- node.metadata = merge( {}, node.metadata, metadata );
140
- if( deep && node instanceof TransformNode ) {
141
- const children = node.getChildTransformNodes( true );
142
- children.forEach( child => injectNodeMetadata( child, metadata, deep ) );
143
- }
144
- };
145
-
146
- /**
147
- * @param node
148
- * @param assertCallable
149
- * @param callableParameters
150
- * @param deep
151
- */
152
- const assertTransformNode = function( node: TransformNode,
153
- assertCallable: CallableFunction,
154
- callableParameters: any[] = [],
155
- deep: boolean = true ) {
156
- assertCallable(node, ...callableParameters);
157
- if( deep ) {
158
- const children = node.getChildTransformNodes( true );
159
- children.forEach( child => assertTransformNode( child, assertCallable, callableParameters, deep ) );
160
- }
161
- };
162
-
163
- /**
164
- * @param node
165
- * @param deep
166
- */
167
- const activateTransformNode = function( node: TransformNode, deep: boolean = true ) {
168
- node.setEnabled( true );
169
- /*
170
- if( node instanceof AbstractMesh ) {
171
- node.visibility = 1;
172
- node.isPickable = true;
173
- }
174
- */
175
- if( deep ) {
176
- node.getChildTransformNodes( true ).forEach( child => activateTransformNode( child, deep ) );
177
- }
178
- };
179
-
180
- /**
181
- * @param node
182
- * @param deep
183
- */
184
- const deactivateTransformNode = function( node: TransformNode, deep: boolean = true ) {
185
- node.setEnabled( false );
186
- /*
187
- if( node instanceof AbstractMesh ) {
188
- node.visibility = 0;
189
- node.isPickable = false;
190
- }
191
- */
192
- if( deep ) {
193
- node.getChildTransformNodes( true ).forEach( child => deactivateTransformNode( child, deep ) );
194
- }
195
- };
196
-
197
- /**
198
- * @param node
199
- */
200
- const enableNodeWithParents = function( node: Node ) {
201
- node.setEnabled( true );
202
- if ( node.parent ) {
203
- enableNodeWithParents( node.parent );
204
- }
205
- };
206
-
207
- /**
208
- * @param node
209
- */
210
- const disableNodeWithParents = function( node: Node ) {
211
- node.setEnabled( false );
212
- if ( node.parent ) {
213
- disableNodeWithParents( node.parent );
214
- }
215
- };
216
-
217
- /**
218
- * Attention: this function mutates the position of a node. Keep in mind that there are dependencies to other
219
- * functions moving nodes around.
220
- * @param node
221
- * @param rotation
222
- */
223
- const rotateTransformNode = function( node: TransformNode, rotation: Vector3 ): TransformNode {
224
- // remember absolute rotation and reset it before translating
225
- if( !has( node.metadata, 'rotation.initial' ) ) {
226
- injectNodeMetadata( node, { 'rotation.initial': node.rotationQuaternion?.asArray() }, false );
227
- }
228
- if( !has( node.metadata, 'rotation.position' ) || get( node.metadata, 'position.dirty' ) ) {
229
- let rotationPosition = node.absolutePosition.clone();
230
- if( has( node.metadata, 'rotation.offset' ) ) {
231
- rotationPosition = rotationPosition.subtract( get( node.metadata, 'rotation.offset' ) as Vector3 );
232
- }
233
- injectNodeMetadata( node, { 'rotation.position': rotationPosition }, false );
234
- injectNodeMetadata( node, { 'position.dirty': false }, false );
235
- }
236
- node.setAbsolutePosition( get( node.metadata, 'rotation.position' ) );
237
- if( node.metadata.rotation ) {
238
- node.rotationQuaternion = Quaternion.FromArray( get( node.metadata, 'rotation.initial' ) as [] );
239
- }
240
- node.rotateAround( Vector3.Zero(), Axis.X, rotation.x );
241
- node.rotateAround( Vector3.Zero(), Axis.Y, rotation.y );
242
- node.rotateAround( Vector3.Zero(), Axis.Z, rotation.z );
243
- node.computeWorldMatrix( true );
244
- injectNodeMetadata( node, {
245
- 'rotation.offset': node.absolutePosition.subtract( get( node.metadata, 'rotation.position' ) as Vector3 )
246
- }, false );
247
- return node;
248
- };
249
-
250
- /**
251
- * Attention: this function mutates the position of a node. Keep in mind that there are dependencies to other
252
- * functions moving nodes around.
253
- * @param node
254
- * @param distance
255
- */
256
- const moveTransformNode = function( node: TransformNode, distance: Vector3 ): TransformNode {
257
- // remember absolute position and reset it before translating
258
- if( !has( node.metadata, 'position.initial' ) ) {
259
- injectNodeMetadata( node, { 'position.initial': node.absolutePosition.clone() }, false );
260
- }
261
- let position = get( node.metadata, 'position.initial' ) as Vector3;
262
- if( has( node.metadata, 'rotation.offset' ) ) {
263
- position = position.add( get( node.metadata, 'rotation.offset' ) as Vector3 );
264
- }
265
- node.setAbsolutePosition( position.add( distance ) );
266
- injectNodeMetadata( node, { 'position.dirty': true }, false );
267
- return node;
268
- };
269
-
270
- /**
271
- * @param node
272
- * @param material
273
- * @param deep
274
- */
275
- const setMaterial = function( node: TransformNode, material: Material, deep: boolean = true ) {
276
- if( node instanceof AbstractMesh ) {
277
- node.material = material;
278
- }
279
- if( deep ) {
280
- node.getChildTransformNodes( true ).forEach( child => setMaterial( child, material, deep ) );
281
- }
282
- };
283
-
284
- /**
285
- * !!! Warning !!!
286
- * This function is not public API. Whilst it can help solving certain problems, it only works reliably in well defined
287
- * situations and can cause unwanted side effects under some conditions. Use carefully at your own risk!
288
- *
289
- * See https://combeenation.myjetbrains.com/youtrack/issue/CB-5906 for further details regarding this warning.
290
- *
291
- * Set material of an instanced meshes source mesh.
292
- * Changes the material of all instanced meshes which have the same source mesh.
293
- *
294
- * @param node
295
- * @param material
296
- * @param deep
297
- *
298
- * @ignore
299
- */
300
- const setSourceNodeMaterial = function( node: TransformNode, material: Material, deep: boolean = true ) {
301
- const warn = ` You're using "setSourceNodeMaterial" which is not public API.
302
- Whilst it can help solving certain problems, it only works reliably in well defined situations and can cause unwanted side effects under some conditions.
303
- Use carefully at your own risk!`;
304
- console.warn(`!!! Warning !!!\n${warn}`);
305
-
306
- if( node instanceof InstancedMesh ) {
307
- node.sourceMesh.material = material;
308
- }
309
- if( deep ) {
310
- node.getChildTransformNodes( true ).forEach( child => setSourceNodeMaterial( child, material, deep ) );
311
- }
312
- };
313
-
314
- /**
315
- * @param node
316
- * @param color
317
- * @param deep
318
- */
319
- const setMaterialColor = function( node: TransformNode, color: Color3, deep: boolean = true ) {
320
- if( node instanceof AbstractMesh && node.material ) {
321
- const materialCls = node.material.getClassName();
322
- switch( materialCls ) {
323
- case 'PBRMaterial':
324
- (node.material as PBRMaterial).albedoColor = color.toLinearSpace();
325
- break;
326
- case 'StandardMaterial':
327
- (node.material as StandardMaterial).diffuseColor = color;
328
- break;
329
- default:
330
- throw new Error( `Setting color for material of instance "${materialCls}" not implemented (yet).` );
331
- }
332
- }
333
- if( deep ) {
334
- node.getChildTransformNodes( true ).forEach( child => setMaterialColor( child, color, deep ) );
335
- }
336
- };
337
-
338
- /**
339
- * @param node
340
- * @param texture
341
- * @param deep
342
- */
343
- const setMaterialTexture = function( node: TransformNode, texture: Texture, deep: boolean = true ) {
344
- if( node instanceof AbstractMesh && node.material ) {
345
- const materialCls = node.material.getClassName();
346
- switch( materialCls ) {
347
- case 'PBRMaterial':
348
- (node.material as PBRMaterial).albedoTexture = texture;
349
- break;
350
- case 'StandardMaterial':
351
- (node.material as StandardMaterial).diffuseTexture = texture;
352
- break;
353
- default:
354
- throw new Error( `Setting texture for material of instance "${materialCls}" not implemented (yet).` );
355
- }
356
- }
357
- if( deep ) {
358
- node.getChildTransformNodes( true ).forEach( child => setMaterialTexture( child, texture, deep ) );
359
- }
360
- };
361
-
362
- /**
363
- * @param node
364
- * @param metallness
365
- * @param deep
366
- */
367
- const setMaterialMetallness = function( node: TransformNode, metallness: number, deep: boolean = true ) {
368
- if( node instanceof AbstractMesh && node.material ) {
369
- const materialCls = node.material.getClassName();
370
- switch( materialCls ) {
371
- case 'PBRMaterial':
372
- (node.material as PBRMaterial).metallic = metallness;
373
- break;
374
- default:
375
- throw new Error( `Setting metallness for material of instance "${materialCls}" not implemented (yet).` );
376
- }
377
- }
378
- if( deep ) {
379
- node.getChildTransformNodes( true ).forEach( child => setMaterialMetallness( child, metallness, deep ) );
380
- }
381
- };
382
-
383
- /**
384
- * @param node
385
- * @param roughness
386
- * @param deep
387
- */
388
- const setMaterialRoughness = function( node: TransformNode, roughness: number, deep: boolean = true ) {
389
- if( node instanceof AbstractMesh && node.material ) {
390
- const materialCls = node.material.getClassName();
391
- switch( materialCls ) {
392
- case 'PBRMaterial':
393
- (node.material as PBRMaterial).roughness = roughness;
394
- break;
395
- case 'StandardMaterial':
396
- (node.material as StandardMaterial).roughness = roughness;
397
- break;
398
- default:
399
- throw new Error( `Setting roughness for material of instance "${materialCls}" not implemented (yet).` );
400
- }
401
- }
402
- if( deep ) {
403
- node.getChildTransformNodes( true ).forEach( child => setMaterialRoughness( child, roughness, deep ) );
404
- }
405
- };
406
-
407
- /**
408
- * @param node
409
- * @param layer
410
- * @param color
411
- * @param deep
412
- */
413
- const addToHighlightLayer = function( layer: HighlightLayer, color: Color3, node: TransformNode, deep: boolean = true ) {
414
- if( node instanceof AbstractMesh ) {
415
- layer.addMesh( (node as Mesh), color );
416
- }
417
- if( deep ) {
418
- node.getChildTransformNodes( true ).forEach(
419
- child => addToHighlightLayer( layer, color, child, deep )
420
- );
421
- }
422
- };
423
-
424
- /**
425
- * @param node
426
- * @param layer
427
- * @param deep
428
- */
429
- const removeFromHighlightLayer = function( layer: HighlightLayer, node: TransformNode, deep: boolean = true ) {
430
- if( node instanceof AbstractMesh ) {
431
- layer.removeMesh( (node as Mesh) );
432
- }
433
- if( deep ) {
434
- node.getChildTransformNodes( true ).forEach(
435
- child => removeFromHighlightLayer( layer, child, deep )
436
- );
437
- }
438
- };
439
-
440
- /**
441
- * @param node
442
- * @param receiveShadows
443
- * @param deep
444
- */
445
- const setReceiveShadows = function( node: TransformNode, receiveShadows: boolean, deep: boolean = true ) {
446
- if( node instanceof AbstractMesh ) {
447
- node.receiveShadows = receiveShadows;
448
- }
449
- if( deep ) {
450
- node.getChildTransformNodes( true ).forEach(
451
- child => setReceiveShadows( child, receiveShadows, deep )
452
- );
453
- }
454
- };
455
-
456
- /**
457
- * @param node
458
- * @param generator
459
- * @param deep
460
- */
461
- const addToShadowGenerator = function( generator: ShadowGenerator, node: TransformNode, deep: boolean = true ) {
462
- if( node instanceof AbstractMesh ) {
463
- // We have to remove the node because there's no duplicate check in babylon
464
- generator.removeShadowCaster( node, false );
465
- generator.addShadowCaster( node, false );
466
- }
467
- if( deep ) {
468
- node.getChildTransformNodes( true ).forEach(
469
- child => addToShadowGenerator( generator, child, deep )
470
- );
471
- }
472
- };
473
-
474
- /**
475
- * @param node
476
- * @param generator
477
- * @param deep
478
- */
479
- const removeFromShadowGenerator = function( generator: ShadowGenerator, node: TransformNode, deep: boolean = true ) {
480
- if( node instanceof AbstractMesh ) {
481
- generator.removeShadowCaster( node, false );
482
- }
483
- if( deep ) {
484
- node.getChildTransformNodes( true ).forEach(
485
- child => removeFromShadowGenerator( generator, child, deep )
486
- );
487
- }
488
- };
489
-
490
- /**
491
- * https://forum.babylonjs.com/t/get-mesh-bounding-box-position-and-size-in-2d-screen-coordinates/1058/3
492
- * @param mesh
493
- * @param scene
494
- * @param canvas
495
- */
496
- const getClientRectFromMesh = function( mesh: AbstractMesh, scene: Scene, canvas: HTMLCanvasElement ): ClientRect {
497
- // get bounding box of the mesh
498
- const meshVectors = mesh.getBoundingInfo().boundingBox.vectors;
499
- // get the matrix and viewport needed to project the vectors onto the screen
500
- const worldMatrix = mesh.getWorldMatrix();
501
- const transformMatrix = scene.getTransformMatrix();
502
- const viewport = scene.activeCamera!.viewport;
503
- // loop though all the vectors and project them against the current camera viewport to get a set of coordinates
504
- const coordinates = meshVectors.map( vector => {
505
- const projection = Vector3.Project( vector, worldMatrix, transformMatrix, viewport );
506
- projection.x = projection.x * canvas.clientWidth;
507
- projection.y = projection.y * canvas.clientHeight;
508
- return projection;
509
- } );
510
- // get the min and max for all the coordinates so we can calculate the largest possible screen size
511
- const maxX = Math.max.apply( Math, coordinates.map( o => o.x ) );
512
- const minX = Math.min.apply( Math, coordinates.map( o => o.x ) );
513
- const maxY = Math.max.apply( Math, coordinates.map( o => o.y ) );
514
- const minY = Math.min.apply( Math, coordinates.map( o => o.y ) );
515
- // return a ClientRect from this
516
- return {
517
- width: maxX - minX,
518
- height: maxY - minY,
519
- left: minX,
520
- top: minY,
521
- right: maxX,
522
- bottom: maxY,
523
- } as ClientRect;
524
- };
525
-
526
- export {
527
- getRootNode,
528
- mapToDottedNodes,
529
- getDottedPathForNode,
530
- cloneTransformNode,
531
- cloneNodeWithParents,
532
- cloneTransformNodeMaterial,
533
- injectNodeMetadata,
534
- assertTransformNode,
535
- activateTransformNode,
536
- deactivateTransformNode,
537
- enableNodeWithParents,
538
- disableNodeWithParents,
539
- rotateTransformNode,
540
- moveTransformNode,
541
- setMaterial,
542
- setSourceNodeMaterial,
543
- setMaterialColor,
544
- setMaterialTexture,
545
- setMaterialMetallness,
546
- setMaterialRoughness,
547
- addToHighlightLayer,
548
- removeFromHighlightLayer,
549
- setReceiveShadows,
550
- addToShadowGenerator,
551
- removeFromShadowGenerator,
552
- getClientRectFromMesh
553
- };
1
+ import { HighlightLayer } from '@babylonjs/core/Layers/highlightLayer';
2
+ import { Light } from '@babylonjs/core/Lights/light';
3
+ import { ShadowGenerator } from '@babylonjs/core/Lights/Shadows/shadowGenerator';
4
+ import { Material } from '@babylonjs/core/Materials/material';
5
+ import { PBRMaterial } from '@babylonjs/core/Materials/PBR/pbrMaterial';
6
+ import { StandardMaterial } from '@babylonjs/core/Materials/standardMaterial';
7
+ import { Axis } from '@babylonjs/core/Maths/math.axis';
8
+ import { Color3 } from '@babylonjs/core/Maths/math.color';
9
+ import { Quaternion, Vector3 } from '@babylonjs/core/Maths/math.vector';
10
+ import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';
11
+ import { InstancedMesh } from '@babylonjs/core/Meshes/instancedMesh';
12
+ import { Mesh } from '@babylonjs/core/Meshes/mesh';
13
+ import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
14
+ import { Node } from '@babylonjs/core/node';
15
+ import { Scene } from '@babylonjs/core/scene';
16
+ import { Nullable } from '@babylonjs/core/types';
17
+ import { cloneDeep, get, has, merge } from 'lodash-es';
18
+ import { DottedPath } from '../classes/dottedPath';
19
+
20
+ /**
21
+ * @param node
22
+ * @return Node
23
+ */
24
+ const getRootNode = function( node: Node ): Node {
25
+ let _node = node;
26
+ while( _node.parent ) {
27
+ _node = _node.parent;
28
+ }
29
+ return _node;
30
+ }
31
+
32
+ /**
33
+ * @param nodes
34
+ * @param predicate
35
+ * @return Map<DottedPath, T>
36
+ */
37
+ const mapToDottedNodes = function <T>( nodes: Node[],
38
+ predicate?: ( node: Node ) => boolean ): Map<DottedPath, T> {
39
+ const map = new Map<DottedPath, T>();
40
+ const addNodes = function( _node: Node ) {
41
+ if( predicate && predicate( _node ) ) {
42
+ map.set( _node.metadata.dottedPath, _node as any );
43
+ }
44
+ _node.getChildren().forEach( child => {
45
+ addNodes( child );
46
+ } );
47
+ };
48
+ nodes.forEach( node => {
49
+ addNodes( node );
50
+ } );
51
+ return map;
52
+ };
53
+
54
+ /**
55
+ * @param node
56
+ * @return DottedPath
57
+ */
58
+ const getDottedPathForNode = function( node: Node ): DottedPath {
59
+ const dottedPath = DottedPath.create( node.name );
60
+ let _parent = node;
61
+ while( _parent.parent ) {
62
+ _parent = _parent.parent;
63
+ dottedPath.unshiftPart( _parent.name );
64
+ }
65
+ return dottedPath;
66
+ };
67
+
68
+ /**
69
+ * @param node
70
+ * @param predicate
71
+ * @param deep
72
+ * @return TransformNode | null
73
+ */
74
+ const cloneTransformNode = function( node: TransformNode,
75
+ predicate?: ( node: TransformNode ) => boolean,
76
+ deep: boolean = true ): TransformNode | null {
77
+ if( predicate && !predicate( node ) ) {
78
+ return null;
79
+ }
80
+ const clone = node.clone( node.name, node.parent, true );
81
+ if( clone ) {
82
+ clone.metadata = cloneDeep( node.metadata );
83
+ }
84
+ if( deep ) {
85
+ const children = node.getChildTransformNodes( true );
86
+ children.forEach( child => {
87
+ const clonedChild = cloneTransformNode( child, predicate, deep );
88
+ if( clonedChild ) {
89
+ clonedChild.parent = clone;
90
+ }
91
+ } );
92
+ }
93
+ return clone;
94
+ };
95
+
96
+ /**
97
+ * @param node
98
+ */
99
+ const cloneNodeWithParents = function( node: Node | null ): Node | null {
100
+ let clone = null;
101
+ if( node instanceof TransformNode ) {
102
+ clone = node.clone( node.name, cloneNodeWithParents( node.parent ) as Nullable<Node>, true );
103
+ } else if( node instanceof Light ) {
104
+ clone = node.clone( node.name, cloneNodeWithParents( node.parent ) as Nullable<Node> );
105
+ } else if( node ) {
106
+ throw new Error( `Cloning of "${node?.constructor.name}" is not implemented (yet).` );
107
+ }
108
+ return clone;
109
+ };
110
+
111
+ /**
112
+ * @param node
113
+ * @param deep
114
+ * @param prefix
115
+ * @return TransformNode
116
+ */
117
+ const cloneTransformNodeMaterial = function( node: TransformNode,
118
+ prefix: DottedPathArgument = '',
119
+ deep: boolean = true ): TransformNode {
120
+ if( node instanceof AbstractMesh && node.material ) {
121
+ const _prefix = DottedPath.create( prefix ).addParts([
122
+ 'node',
123
+ node.uniqueId.toString()
124
+ ]);
125
+ node.material = node.material.clone( _prefix.path );
126
+ }
127
+ if( deep ) {
128
+ const children = node.getChildTransformNodes( true );
129
+ children.forEach( child => cloneTransformNodeMaterial( child, prefix, deep ) );
130
+ }
131
+ return node;
132
+ };
133
+
134
+ /**
135
+ * @param node
136
+ * @param deep
137
+ * @param metadata
138
+ */
139
+ const injectNodeMetadata = function( node: Node, metadata: {}, deep: boolean = true ) {
140
+ node.metadata = merge( {}, node.metadata, metadata );
141
+ if( deep && node instanceof TransformNode ) {
142
+ const children = node.getChildTransformNodes( true );
143
+ children.forEach( child => injectNodeMetadata( child, metadata, deep ) );
144
+ }
145
+ };
146
+
147
+ /**
148
+ * @param node
149
+ * @param assertCallable
150
+ * @param callableParameters
151
+ * @param deep
152
+ */
153
+ const assertTransformNode = function( node: TransformNode,
154
+ assertCallable: CallableFunction,
155
+ callableParameters: any[] = [],
156
+ deep: boolean = true ) {
157
+ assertCallable(node, ...callableParameters);
158
+ if( deep ) {
159
+ const children = node.getChildTransformNodes( true );
160
+ children.forEach( child => assertTransformNode( child, assertCallable, callableParameters, deep ) );
161
+ }
162
+ };
163
+
164
+ /**
165
+ * @param node
166
+ * @param deep
167
+ */
168
+ const activateTransformNode = function( node: TransformNode, deep: boolean = true ) {
169
+ node.setEnabled( true );
170
+ /*
171
+ if( node instanceof AbstractMesh ) {
172
+ node.visibility = 1;
173
+ node.isPickable = true;
174
+ }
175
+ */
176
+ if( deep ) {
177
+ node.getChildTransformNodes( true ).forEach( child => activateTransformNode( child, deep ) );
178
+ }
179
+ };
180
+
181
+ /**
182
+ * @param node
183
+ * @param deep
184
+ */
185
+ const deactivateTransformNode = function( node: TransformNode, deep: boolean = true ) {
186
+ node.setEnabled( false );
187
+ /*
188
+ if( node instanceof AbstractMesh ) {
189
+ node.visibility = 0;
190
+ node.isPickable = false;
191
+ }
192
+ */
193
+ if( deep ) {
194
+ node.getChildTransformNodes( true ).forEach( child => deactivateTransformNode( child, deep ) );
195
+ }
196
+ };
197
+
198
+ /**
199
+ * @param node
200
+ */
201
+ const enableNodeWithParents = function( node: Node ) {
202
+ node.setEnabled( true );
203
+ if ( node.parent ) {
204
+ enableNodeWithParents( node.parent );
205
+ }
206
+ };
207
+
208
+ /**
209
+ * @param node
210
+ */
211
+ const disableNodeWithParents = function( node: Node ) {
212
+ node.setEnabled( false );
213
+ if ( node.parent ) {
214
+ disableNodeWithParents( node.parent );
215
+ }
216
+ };
217
+
218
+ /**
219
+ * Attention: this function mutates the position of a node. Keep in mind that there are dependencies to other
220
+ * functions moving nodes around.
221
+ * @param node
222
+ * @param rotation
223
+ */
224
+ const rotateTransformNode = function( node: TransformNode, rotation: Vector3 ): TransformNode {
225
+ // remember absolute rotation and reset it before translating
226
+ if( !has( node.metadata, 'rotation.initial' ) ) {
227
+ let rotationQuaternion = node.rotationQuaternion;
228
+ if( !rotationQuaternion ) {
229
+ rotationQuaternion = Quaternion.RotationYawPitchRoll( node.rotation.x, node.rotation.y, node.rotation.z );
230
+ }
231
+ injectNodeMetadata( node, { 'rotation.initial': rotationQuaternion.asArray() }, false );
232
+ }
233
+ if( !has( node.metadata, 'rotation.position' ) || get( node.metadata, 'position.dirty' ) ) {
234
+ let rotationPosition = node.absolutePosition.clone();
235
+ if( has( node.metadata, 'rotation.offset' ) ) {
236
+ rotationPosition = rotationPosition.subtract( get( node.metadata, 'rotation.offset' ) as Vector3 );
237
+ }
238
+ injectNodeMetadata( node, { 'rotation.position': rotationPosition }, false );
239
+ injectNodeMetadata( node, { 'position.dirty': false }, false );
240
+ }
241
+ node.setAbsolutePosition( get( node.metadata, 'rotation.position' ) );
242
+ node.rotationQuaternion = Quaternion.FromArray( get( node.metadata, 'rotation.initial' ) as [] );
243
+ node.rotateAround( Vector3.Zero(), Axis.X, rotation.x );
244
+ node.rotateAround( Vector3.Zero(), Axis.Y, rotation.y );
245
+ node.rotateAround( Vector3.Zero(), Axis.Z, rotation.z );
246
+ node.computeWorldMatrix( true );
247
+ const rotationOffset = node.absolutePosition.subtract( get( node.metadata, 'rotation.position' ) as Vector3 );
248
+ injectNodeMetadata( node, { 'rotation.offset': rotationOffset }, false );
249
+ return node;
250
+ };
251
+
252
+ /**
253
+ * Attention: this function mutates the position of a node. Keep in mind that there are dependencies to other
254
+ * functions moving nodes around.
255
+ * @param node
256
+ * @param distance
257
+ */
258
+ const moveTransformNode = function( node: TransformNode, distance: Vector3 ): TransformNode {
259
+ // remember absolute position and reset it before translating
260
+ if( !has( node.metadata, 'position.initial' ) ) {
261
+ injectNodeMetadata( node, { 'position.initial': node.absolutePosition.clone() }, false );
262
+ }
263
+ let position = get( node.metadata, 'position.initial' ) as Vector3;
264
+ if( has( node.metadata, 'rotation.offset' ) ) {
265
+ position = position.add( get( node.metadata, 'rotation.offset' ) as Vector3 );
266
+ }
267
+ node.setAbsolutePosition( position.add( distance ) );
268
+ injectNodeMetadata( node, { 'position.dirty': true }, false );
269
+ return node;
270
+ };
271
+
272
+ /**
273
+ * @param node
274
+ * @param material
275
+ * @param deep
276
+ */
277
+ const setMaterial = function( node: TransformNode, material: Material, deep: boolean = true ) {
278
+ if( node instanceof AbstractMesh ) {
279
+ node.material = material;
280
+ }
281
+ if( deep ) {
282
+ node.getChildTransformNodes( true ).forEach( child => setMaterial( child, material, deep ) );
283
+ }
284
+ };
285
+
286
+ /**
287
+ * !!! Warning !!!
288
+ * This function is not public API. Whilst it can help solving certain problems, it only works reliably in well defined
289
+ * situations and can cause unwanted side effects under some conditions. Use carefully at your own risk!
290
+ *
291
+ * See https://combeenation.myjetbrains.com/youtrack/issue/CB-5906 for further details regarding this warning.
292
+ *
293
+ * Set material of an instanced meshes source mesh.
294
+ * Changes the material of all instanced meshes which have the same source mesh.
295
+ *
296
+ * @param node
297
+ * @param material
298
+ * @param deep
299
+ *
300
+ * @ignore
301
+ */
302
+ const setSourceNodeMaterial = function( node: TransformNode, material: Material, deep: boolean = true ) {
303
+ const warn = ` You're using "setSourceNodeMaterial" which is not public API.
304
+ Whilst it can help solving certain problems, it only works reliably in well defined situations and can cause unwanted side effects under some conditions.
305
+ Use carefully at your own risk!`;
306
+ console.warn(`!!! Warning !!!\n${warn}`);
307
+
308
+ if( node instanceof InstancedMesh ) {
309
+ node.sourceMesh.material = material;
310
+ }
311
+ if( deep ) {
312
+ node.getChildTransformNodes( true ).forEach( child => setSourceNodeMaterial( child, material, deep ) );
313
+ }
314
+ };
315
+
316
+ /**
317
+ * @param node
318
+ * @param color
319
+ * @param deep
320
+ */
321
+ const setMaterialColor = function( node: TransformNode, color: Color3, deep: boolean = true ) {
322
+ if( node instanceof AbstractMesh && node.material ) {
323
+ const materialCls = node.material.getClassName();
324
+ switch( materialCls ) {
325
+ case 'PBRMaterial':
326
+ (node.material as PBRMaterial).albedoColor = color.toLinearSpace();
327
+ break;
328
+ case 'StandardMaterial':
329
+ (node.material as StandardMaterial).diffuseColor = color;
330
+ break;
331
+ default:
332
+ throw new Error( `Setting color for material of instance "${materialCls}" not implemented (yet).` );
333
+ }
334
+ }
335
+ if( deep ) {
336
+ node.getChildTransformNodes( true ).forEach( child => setMaterialColor( child, color, deep ) );
337
+ }
338
+ };
339
+
340
+ /**
341
+ * @param node
342
+ * @param texture
343
+ * @param deep
344
+ */
345
+ const setMaterialTexture = function( node: TransformNode, texture: Texture, deep: boolean = true ) {
346
+ if( node instanceof AbstractMesh && node.material ) {
347
+ const materialCls = node.material.getClassName();
348
+ switch( materialCls ) {
349
+ case 'PBRMaterial':
350
+ (node.material as PBRMaterial).albedoTexture = texture;
351
+ break;
352
+ case 'StandardMaterial':
353
+ (node.material as StandardMaterial).diffuseTexture = texture;
354
+ break;
355
+ default:
356
+ throw new Error( `Setting texture for material of instance "${materialCls}" not implemented (yet).` );
357
+ }
358
+ }
359
+ if( deep ) {
360
+ node.getChildTransformNodes( true ).forEach( child => setMaterialTexture( child, texture, deep ) );
361
+ }
362
+ };
363
+
364
+ /**
365
+ * @param node
366
+ * @param metallness
367
+ * @param deep
368
+ */
369
+ const setMaterialMetallness = function( node: TransformNode, metallness: number, deep: boolean = true ) {
370
+ if( node instanceof AbstractMesh && node.material ) {
371
+ const materialCls = node.material.getClassName();
372
+ switch( materialCls ) {
373
+ case 'PBRMaterial':
374
+ (node.material as PBRMaterial).metallic = metallness;
375
+ break;
376
+ default:
377
+ throw new Error( `Setting metallness for material of instance "${materialCls}" not implemented (yet).` );
378
+ }
379
+ }
380
+ if( deep ) {
381
+ node.getChildTransformNodes( true ).forEach( child => setMaterialMetallness( child, metallness, deep ) );
382
+ }
383
+ };
384
+
385
+ /**
386
+ * @param node
387
+ * @param roughness
388
+ * @param deep
389
+ */
390
+ const setMaterialRoughness = function( node: TransformNode, roughness: number, deep: boolean = true ) {
391
+ if( node instanceof AbstractMesh && node.material ) {
392
+ const materialCls = node.material.getClassName();
393
+ switch( materialCls ) {
394
+ case 'PBRMaterial':
395
+ (node.material as PBRMaterial).roughness = roughness;
396
+ break;
397
+ case 'StandardMaterial':
398
+ (node.material as StandardMaterial).roughness = roughness;
399
+ break;
400
+ default:
401
+ throw new Error( `Setting roughness for material of instance "${materialCls}" not implemented (yet).` );
402
+ }
403
+ }
404
+ if( deep ) {
405
+ node.getChildTransformNodes( true ).forEach( child => setMaterialRoughness( child, roughness, deep ) );
406
+ }
407
+ };
408
+
409
+ /**
410
+ * @param node
411
+ * @param layer
412
+ * @param color
413
+ * @param deep
414
+ */
415
+ const addToHighlightLayer = function( layer: HighlightLayer, color: Color3, node: TransformNode, deep: boolean = true ) {
416
+ if( node instanceof AbstractMesh ) {
417
+ layer.addMesh( (node as Mesh), color );
418
+ }
419
+ if( deep ) {
420
+ node.getChildTransformNodes( true ).forEach(
421
+ child => addToHighlightLayer( layer, color, child, deep )
422
+ );
423
+ }
424
+ };
425
+
426
+ /**
427
+ * @param node
428
+ * @param layer
429
+ * @param deep
430
+ */
431
+ const removeFromHighlightLayer = function( layer: HighlightLayer, node: TransformNode, deep: boolean = true ) {
432
+ if( node instanceof AbstractMesh ) {
433
+ layer.removeMesh( (node as Mesh) );
434
+ }
435
+ if( deep ) {
436
+ node.getChildTransformNodes( true ).forEach(
437
+ child => removeFromHighlightLayer( layer, child, deep )
438
+ );
439
+ }
440
+ };
441
+
442
+ /**
443
+ * @param node
444
+ * @param receiveShadows
445
+ * @param deep
446
+ */
447
+ const setReceiveShadows = function( node: TransformNode, receiveShadows: boolean, deep: boolean = true ) {
448
+ if( node instanceof AbstractMesh ) {
449
+ node.receiveShadows = receiveShadows;
450
+ }
451
+ if( deep ) {
452
+ node.getChildTransformNodes( true ).forEach(
453
+ child => setReceiveShadows( child, receiveShadows, deep )
454
+ );
455
+ }
456
+ };
457
+
458
+ /**
459
+ * @param node
460
+ * @param generator
461
+ * @param deep
462
+ */
463
+ const addToShadowGenerator = function( generator: ShadowGenerator, node: TransformNode, deep: boolean = true ) {
464
+ if( node instanceof AbstractMesh ) {
465
+ // We have to remove the node because there's no duplicate check in babylon
466
+ generator.removeShadowCaster( node, false );
467
+ generator.addShadowCaster( node, false );
468
+ }
469
+ if( deep ) {
470
+ node.getChildTransformNodes( true ).forEach(
471
+ child => addToShadowGenerator( generator, child, deep )
472
+ );
473
+ }
474
+ };
475
+
476
+ /**
477
+ * @param node
478
+ * @param generator
479
+ * @param deep
480
+ */
481
+ const removeFromShadowGenerator = function( generator: ShadowGenerator, node: TransformNode, deep: boolean = true ) {
482
+ if( node instanceof AbstractMesh ) {
483
+ generator.removeShadowCaster( node, false );
484
+ }
485
+ if( deep ) {
486
+ node.getChildTransformNodes( true ).forEach(
487
+ child => removeFromShadowGenerator( generator, child, deep )
488
+ );
489
+ }
490
+ };
491
+
492
+ /**
493
+ * https://forum.babylonjs.com/t/get-mesh-bounding-box-position-and-size-in-2d-screen-coordinates/1058/3
494
+ * @param mesh
495
+ * @param scene
496
+ * @param canvas
497
+ */
498
+ const getClientRectFromMesh = function( mesh: AbstractMesh, scene: Scene, canvas: HTMLCanvasElement ): ClientRect {
499
+ // get bounding box of the mesh
500
+ const meshVectors = mesh.getBoundingInfo().boundingBox.vectors;
501
+ // get the matrix and viewport needed to project the vectors onto the screen
502
+ const worldMatrix = mesh.getWorldMatrix();
503
+ const transformMatrix = scene.getTransformMatrix();
504
+ const viewport = scene.activeCamera!.viewport;
505
+ // loop though all the vectors and project them against the current camera viewport to get a set of coordinates
506
+ const coordinates = meshVectors.map( vector => {
507
+ const projection = Vector3.Project( vector, worldMatrix, transformMatrix, viewport );
508
+ projection.x = projection.x * canvas.clientWidth;
509
+ projection.y = projection.y * canvas.clientHeight;
510
+ return projection;
511
+ } );
512
+ // get the min and max for all the coordinates so we can calculate the largest possible screen size
513
+ const maxX = Math.max.apply( Math, coordinates.map( o => o.x ) );
514
+ const minX = Math.min.apply( Math, coordinates.map( o => o.x ) );
515
+ const maxY = Math.max.apply( Math, coordinates.map( o => o.y ) );
516
+ const minY = Math.min.apply( Math, coordinates.map( o => o.y ) );
517
+ // return a ClientRect from this
518
+ return {
519
+ width: maxX - minX,
520
+ height: maxY - minY,
521
+ left: minX,
522
+ top: minY,
523
+ right: maxX,
524
+ bottom: maxY,
525
+ } as ClientRect;
526
+ };
527
+
528
+ export {
529
+ getRootNode,
530
+ mapToDottedNodes,
531
+ getDottedPathForNode,
532
+ cloneTransformNode,
533
+ cloneNodeWithParents,
534
+ cloneTransformNodeMaterial,
535
+ injectNodeMetadata,
536
+ assertTransformNode,
537
+ activateTransformNode,
538
+ deactivateTransformNode,
539
+ enableNodeWithParents,
540
+ disableNodeWithParents,
541
+ rotateTransformNode,
542
+ moveTransformNode,
543
+ setMaterial,
544
+ setSourceNodeMaterial,
545
+ setMaterialColor,
546
+ setMaterialTexture,
547
+ setMaterialMetallness,
548
+ setMaterialRoughness,
549
+ addToHighlightLayer,
550
+ removeFromHighlightLayer,
551
+ setReceiveShadows,
552
+ addToShadowGenerator,
553
+ removeFromShadowGenerator,
554
+ getClientRectFromMesh
555
+ };