@spiffcommerce/preview 3.6.2-rc.8 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/index.esm.js +1576 -38
  2. package/dist/index.umd.js +1 -0
  3. package/package.json +4 -6
  4. package/dist/_tslib.esm.js +0 -33
  5. package/dist/animation.esm.js +0 -1364
  6. package/dist/assetCache.esm.js +0 -6
  7. package/dist/assetCache.esm2.js +0 -825
  8. package/dist/blurPostProcess.esm.js +0 -327
  9. package/dist/bumpVertex.esm.js +0 -497
  10. package/dist/compatibilityOptions.esm.js +0 -68
  11. package/dist/configuration.esm.js +0 -121
  12. package/dist/core.esm.js +0 -8135
  13. package/dist/dynamicTexture.esm.js +0 -105
  14. package/dist/dynamicTexture.esm2.js +0 -238
  15. package/dist/easing.esm.js +0 -130
  16. package/dist/effectFallbacks.esm.js +0 -378
  17. package/dist/engine.esm.js +0 -25504
  18. package/dist/glbLoaderExtensions.esm.js +0 -690
  19. package/dist/glowLayer.esm.js +0 -1621
  20. package/dist/glowLayerManager.esm.js +0 -50
  21. package/dist/guid.esm.js +0 -21
  22. package/dist/hdrFilteringFunctions.esm.js +0 -816
  23. package/dist/helperFunctions.esm.js +0 -5145
  24. package/dist/material.esm.js +0 -115
  25. package/dist/material.esm2.js +0 -5245
  26. package/dist/math.axis.esm.js +0 -35
  27. package/dist/math.color.esm.js +0 -1661
  28. package/dist/math.path.esm.js +0 -15
  29. package/dist/math.size.esm.js +0 -137
  30. package/dist/mesh.esm.js +0 -11170
  31. package/dist/modelContainer.esm.js +0 -1895
  32. package/dist/node.esm.js +0 -795
  33. package/dist/pbrBRDFFunctions.esm.js +0 -124
  34. package/dist/pbrMaterial.esm.js +8 -8739
  35. package/dist/productAnimations.esm.js +0 -182
  36. package/dist/productCamera.esm.js +0 -14
  37. package/dist/productCamera.esm2.js +0 -3870
  38. package/dist/renderConstants.esm.js +0 -116
  39. package/dist/renderingPipeline.esm.js +0 -18
  40. package/dist/renderingPipeline.esm2.js +1 -3594
  41. package/dist/sceneLoaderFlags.esm.js +0 -51
  42. package/dist/types.esm.js +0 -30
  43. package/dist/variants.esm.js +0 -16
  44. package/dist/variants.esm2.js +0 -3097
  45. package/dist/webRequest.esm.js +0 -7777
package/dist/node.esm.js DELETED
@@ -1,795 +0,0 @@
1
- import { _ as __decorate, O as Observable, M as Matrix, E as EngineStore, S as SerializationHelper, V as Vector3, a as _WarnImport, s as serialize } from './webRequest.esm.js';
2
-
3
- /** @internal */
4
- class _InternalNodeDataInfo {
5
- constructor() {
6
- this._doNotSerialize = false;
7
- this._isDisposed = false;
8
- this._sceneRootNodesIndex = -1;
9
- this._isEnabled = true;
10
- this._isParentEnabled = true;
11
- this._isReady = true;
12
- this._onEnabledStateChangedObservable = new Observable();
13
- this._onClonedObservable = new Observable();
14
- }
15
- }
16
- /**
17
- * Node is the basic class for all scene objects (Mesh, Light, Camera.)
18
- */
19
- class Node {
20
- /**
21
- * Add a new node constructor
22
- * @param type defines the type name of the node to construct
23
- * @param constructorFunc defines the constructor function
24
- */
25
- static AddNodeConstructor(type, constructorFunc) {
26
- this._NodeConstructors[type] = constructorFunc;
27
- }
28
- /**
29
- * Returns a node constructor based on type name
30
- * @param type defines the type name
31
- * @param name defines the new node name
32
- * @param scene defines the hosting scene
33
- * @param options defines optional options to transmit to constructors
34
- * @returns the new constructor or null
35
- */
36
- static Construct(type, name, scene, options) {
37
- const constructorFunc = this._NodeConstructors[type];
38
- if (!constructorFunc) {
39
- return null;
40
- }
41
- return constructorFunc(name, scene, options);
42
- }
43
- /**
44
- * Gets or sets the accessibility tag to describe the node for accessibility purpose.
45
- */
46
- set accessibilityTag(value) {
47
- this._accessibilityTag = value;
48
- this.onAccessibilityTagChangedObservable.notifyObservers(value);
49
- }
50
- get accessibilityTag() {
51
- return this._accessibilityTag;
52
- }
53
- /**
54
- * Gets or sets a boolean used to define if the node must be serialized
55
- */
56
- get doNotSerialize() {
57
- if (this._nodeDataStorage._doNotSerialize) {
58
- return true;
59
- }
60
- if (this._parentNode) {
61
- return this._parentNode.doNotSerialize;
62
- }
63
- return false;
64
- }
65
- set doNotSerialize(value) {
66
- this._nodeDataStorage._doNotSerialize = value;
67
- }
68
- /**
69
- * Gets a boolean indicating if the node has been disposed
70
- * @returns true if the node was disposed
71
- */
72
- isDisposed() {
73
- return this._nodeDataStorage._isDisposed;
74
- }
75
- /**
76
- * Gets or sets the parent of the node (without keeping the current position in the scene)
77
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/transforms/parent_pivot/parent
78
- */
79
- set parent(parent) {
80
- if (this._parentNode === parent) {
81
- return;
82
- }
83
- const previousParentNode = this._parentNode;
84
- // Remove self from list of children of parent
85
- if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
86
- const index = this._parentNode._children.indexOf(this);
87
- if (index !== -1) {
88
- this._parentNode._children.splice(index, 1);
89
- }
90
- if (!parent && !this._nodeDataStorage._isDisposed) {
91
- this._addToSceneRootNodes();
92
- }
93
- }
94
- // Store new parent
95
- this._parentNode = parent;
96
- // Add as child to new parent
97
- if (this._parentNode) {
98
- if (this._parentNode._children === undefined || this._parentNode._children === null) {
99
- this._parentNode._children = new Array();
100
- }
101
- this._parentNode._children.push(this);
102
- if (!previousParentNode) {
103
- this._removeFromSceneRootNodes();
104
- }
105
- }
106
- // Enabled state
107
- this._syncParentEnabledState();
108
- }
109
- get parent() {
110
- return this._parentNode;
111
- }
112
- /**
113
- * @internal
114
- */
115
- _serializeAsParent(serializationObject) {
116
- serializationObject.parentId = this.uniqueId;
117
- }
118
- /** @internal */
119
- _addToSceneRootNodes() {
120
- if (this._nodeDataStorage._sceneRootNodesIndex === -1) {
121
- this._nodeDataStorage._sceneRootNodesIndex = this._scene.rootNodes.length;
122
- this._scene.rootNodes.push(this);
123
- }
124
- }
125
- /** @internal */
126
- _removeFromSceneRootNodes() {
127
- if (this._nodeDataStorage._sceneRootNodesIndex !== -1) {
128
- const rootNodes = this._scene.rootNodes;
129
- const lastIdx = rootNodes.length - 1;
130
- rootNodes[this._nodeDataStorage._sceneRootNodesIndex] = rootNodes[lastIdx];
131
- rootNodes[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex = this._nodeDataStorage._sceneRootNodesIndex;
132
- this._scene.rootNodes.pop();
133
- this._nodeDataStorage._sceneRootNodesIndex = -1;
134
- }
135
- }
136
- /**
137
- * Gets or sets the animation properties override
138
- */
139
- get animationPropertiesOverride() {
140
- if (!this._animationPropertiesOverride) {
141
- return this._scene.animationPropertiesOverride;
142
- }
143
- return this._animationPropertiesOverride;
144
- }
145
- set animationPropertiesOverride(value) {
146
- this._animationPropertiesOverride = value;
147
- }
148
- /**
149
- * Gets a string identifying the name of the class
150
- * @returns "Node" string
151
- */
152
- getClassName() {
153
- return "Node";
154
- }
155
- /**
156
- * Sets a callback that will be raised when the node will be disposed
157
- */
158
- set onDispose(callback) {
159
- if (this._onDisposeObserver) {
160
- this.onDisposeObservable.remove(this._onDisposeObserver);
161
- }
162
- this._onDisposeObserver = this.onDisposeObservable.add(callback);
163
- }
164
- /**
165
- * An event triggered when the enabled state of the node changes
166
- */
167
- get onEnabledStateChangedObservable() {
168
- return this._nodeDataStorage._onEnabledStateChangedObservable;
169
- }
170
- /**
171
- * An event triggered when the node is cloned
172
- */
173
- get onClonedObservable() {
174
- return this._nodeDataStorage._onClonedObservable;
175
- }
176
- /**
177
- * Creates a new Node
178
- * @param name the name and id to be given to this node
179
- * @param scene the scene this node will be added to
180
- */
181
- constructor(name, scene = null) {
182
- this._isDirty = false;
183
- this._nodeDataStorage = new _InternalNodeDataInfo();
184
- /**
185
- * Gets or sets a string used to store user defined state for the node
186
- */
187
- this.state = "";
188
- /**
189
- * Gets or sets an object used to store user defined information for the node
190
- */
191
- this.metadata = null;
192
- /**
193
- * For internal use only. Please do not use.
194
- */
195
- this.reservedDataStore = null;
196
- this._accessibilityTag = null;
197
- this.onAccessibilityTagChangedObservable = new Observable();
198
- /** @internal */
199
- this._parentContainer = null;
200
- /**
201
- * Gets a list of Animations associated with the node
202
- */
203
- this.animations = new Array();
204
- this._ranges = {};
205
- /**
206
- * Callback raised when the node is ready to be used
207
- */
208
- this.onReady = null;
209
- /** @internal */
210
- this._currentRenderId = -1;
211
- this._parentUpdateId = -1;
212
- /** @internal */
213
- this._childUpdateId = -1;
214
- /** @internal */
215
- this._waitingParentId = null;
216
- /** @internal */
217
- this._waitingParentInstanceIndex = null;
218
- /** @internal */
219
- this._waitingParsedUniqueId = null;
220
- /** @internal */
221
- this._cache = {};
222
- this._parentNode = null;
223
- /** @internal */
224
- this._children = null;
225
- /** @internal */
226
- this._worldMatrix = Matrix.Identity();
227
- /** @internal */
228
- this._worldMatrixDeterminant = 0;
229
- /** @internal */
230
- this._worldMatrixDeterminantIsDirty = true;
231
- this._animationPropertiesOverride = null;
232
- /** @internal */
233
- this._isNode = true;
234
- /**
235
- * An event triggered when the mesh is disposed
236
- */
237
- this.onDisposeObservable = new Observable();
238
- this._onDisposeObserver = null;
239
- // Behaviors
240
- this._behaviors = new Array();
241
- this.name = name;
242
- this.id = name;
243
- this._scene = (scene || EngineStore.LastCreatedScene);
244
- this.uniqueId = this._scene.getUniqueId();
245
- this._initCache();
246
- }
247
- /**
248
- * Gets the scene of the node
249
- * @returns a scene
250
- */
251
- getScene() {
252
- return this._scene;
253
- }
254
- /**
255
- * Gets the engine of the node
256
- * @returns a Engine
257
- */
258
- getEngine() {
259
- return this._scene.getEngine();
260
- }
261
- /**
262
- * Attach a behavior to the node
263
- * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors
264
- * @param behavior defines the behavior to attach
265
- * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
266
- * @returns the current Node
267
- */
268
- addBehavior(behavior, attachImmediately = false) {
269
- const index = this._behaviors.indexOf(behavior);
270
- if (index !== -1) {
271
- return this;
272
- }
273
- behavior.init();
274
- if (this._scene.isLoading && !attachImmediately) {
275
- // We defer the attach when the scene will be loaded
276
- this._scene.onDataLoadedObservable.addOnce(() => {
277
- behavior.attach(this);
278
- });
279
- }
280
- else {
281
- behavior.attach(this);
282
- }
283
- this._behaviors.push(behavior);
284
- return this;
285
- }
286
- /**
287
- * Remove an attached behavior
288
- * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors
289
- * @param behavior defines the behavior to attach
290
- * @returns the current Node
291
- */
292
- removeBehavior(behavior) {
293
- const index = this._behaviors.indexOf(behavior);
294
- if (index === -1) {
295
- return this;
296
- }
297
- this._behaviors[index].detach();
298
- this._behaviors.splice(index, 1);
299
- return this;
300
- }
301
- /**
302
- * Gets the list of attached behaviors
303
- * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors
304
- */
305
- get behaviors() {
306
- return this._behaviors;
307
- }
308
- /**
309
- * Gets an attached behavior by name
310
- * @param name defines the name of the behavior to look for
311
- * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors
312
- * @returns null if behavior was not found else the requested behavior
313
- */
314
- getBehaviorByName(name) {
315
- for (const behavior of this._behaviors) {
316
- if (behavior.name === name) {
317
- return behavior;
318
- }
319
- }
320
- return null;
321
- }
322
- /**
323
- * Returns the latest update of the World matrix
324
- * @returns a Matrix
325
- */
326
- getWorldMatrix() {
327
- if (this._currentRenderId !== this._scene.getRenderId()) {
328
- this.computeWorldMatrix();
329
- }
330
- return this._worldMatrix;
331
- }
332
- /** @internal */
333
- _getWorldMatrixDeterminant() {
334
- if (this._worldMatrixDeterminantIsDirty) {
335
- this._worldMatrixDeterminantIsDirty = false;
336
- this._worldMatrixDeterminant = this._worldMatrix.determinant();
337
- }
338
- return this._worldMatrixDeterminant;
339
- }
340
- /**
341
- * Returns directly the latest state of the mesh World matrix.
342
- * A Matrix is returned.
343
- */
344
- get worldMatrixFromCache() {
345
- return this._worldMatrix;
346
- }
347
- // override it in derived class if you add new variables to the cache
348
- // and call the parent class method
349
- /** @internal */
350
- _initCache() {
351
- this._cache = {};
352
- this._cache.parent = undefined;
353
- }
354
- /**
355
- * @internal
356
- */
357
- updateCache(force) {
358
- if (!force && this.isSynchronized()) {
359
- return;
360
- }
361
- this._cache.parent = this.parent;
362
- this._updateCache();
363
- }
364
- /**
365
- * @internal
366
- */
367
- _getActionManagerForTrigger(trigger, _initialCall = true) {
368
- if (!this.parent) {
369
- return null;
370
- }
371
- return this.parent._getActionManagerForTrigger(trigger, false);
372
- }
373
- // override it in derived class if you add new variables to the cache
374
- // and call the parent class method if !ignoreParentClass
375
- /**
376
- * @internal
377
- */
378
- _updateCache(_ignoreParentClass) { }
379
- // override it in derived class if you add new variables to the cache
380
- /** @internal */
381
- _isSynchronized() {
382
- return true;
383
- }
384
- /** @internal */
385
- _markSyncedWithParent() {
386
- if (this._parentNode) {
387
- this._parentUpdateId = this._parentNode._childUpdateId;
388
- }
389
- }
390
- /** @internal */
391
- isSynchronizedWithParent() {
392
- if (!this._parentNode) {
393
- return true;
394
- }
395
- if (this._parentNode._isDirty || this._parentUpdateId !== this._parentNode._childUpdateId) {
396
- return false;
397
- }
398
- return this._parentNode.isSynchronized();
399
- }
400
- /** @internal */
401
- isSynchronized() {
402
- if (this._cache.parent !== this._parentNode) {
403
- this._cache.parent = this._parentNode;
404
- return false;
405
- }
406
- if (this._parentNode && !this.isSynchronizedWithParent()) {
407
- return false;
408
- }
409
- return this._isSynchronized();
410
- }
411
- /**
412
- * Is this node ready to be used/rendered
413
- * @param _completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
414
- * @returns true if the node is ready
415
- */
416
- isReady(_completeCheck = false) {
417
- return this._nodeDataStorage._isReady;
418
- }
419
- /**
420
- * Flag the node as dirty (Forcing it to update everything)
421
- * @param _property helps children apply precise "dirtyfication"
422
- * @returns this node
423
- */
424
- markAsDirty(_property) {
425
- this._currentRenderId = Number.MAX_VALUE;
426
- this._isDirty = true;
427
- return this;
428
- }
429
- /**
430
- * Is this node enabled?
431
- * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
432
- * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
433
- * @returns whether this node (and its parent) is enabled
434
- */
435
- isEnabled(checkAncestors = true) {
436
- if (checkAncestors === false) {
437
- return this._nodeDataStorage._isEnabled;
438
- }
439
- if (!this._nodeDataStorage._isEnabled) {
440
- return false;
441
- }
442
- return this._nodeDataStorage._isParentEnabled;
443
- }
444
- /** @internal */
445
- _syncParentEnabledState() {
446
- this._nodeDataStorage._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
447
- if (this._children) {
448
- this._children.forEach((c) => {
449
- c._syncParentEnabledState(); // Force children to update accordingly
450
- });
451
- }
452
- }
453
- /**
454
- * Set the enabled state of this node
455
- * @param value defines the new enabled state
456
- */
457
- setEnabled(value) {
458
- if (this._nodeDataStorage._isEnabled === value) {
459
- return;
460
- }
461
- this._nodeDataStorage._isEnabled = value;
462
- this._syncParentEnabledState();
463
- this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(value);
464
- }
465
- /**
466
- * Is this node a descendant of the given node?
467
- * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
468
- * @param ancestor defines the parent node to inspect
469
- * @returns a boolean indicating if this node is a descendant of the given node
470
- */
471
- isDescendantOf(ancestor) {
472
- if (this.parent) {
473
- if (this.parent === ancestor) {
474
- return true;
475
- }
476
- return this.parent.isDescendantOf(ancestor);
477
- }
478
- return false;
479
- }
480
- /**
481
- * @internal
482
- */
483
- _getDescendants(results, directDescendantsOnly = false, predicate) {
484
- if (!this._children) {
485
- return;
486
- }
487
- for (let index = 0; index < this._children.length; index++) {
488
- const item = this._children[index];
489
- if (!predicate || predicate(item)) {
490
- results.push(item);
491
- }
492
- if (!directDescendantsOnly) {
493
- item._getDescendants(results, false, predicate);
494
- }
495
- }
496
- }
497
- /**
498
- * Will return all nodes that have this node as ascendant
499
- * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
500
- * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
501
- * @returns all children nodes of all types
502
- */
503
- getDescendants(directDescendantsOnly, predicate) {
504
- const results = new Array();
505
- this._getDescendants(results, directDescendantsOnly, predicate);
506
- return results;
507
- }
508
- /**
509
- * Get all child-meshes of this node
510
- * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
511
- * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
512
- * @returns an array of AbstractMesh
513
- */
514
- getChildMeshes(directDescendantsOnly, predicate) {
515
- const results = [];
516
- this._getDescendants(results, directDescendantsOnly, (node) => {
517
- return (!predicate || predicate(node)) && node.cullingStrategy !== undefined;
518
- });
519
- return results;
520
- }
521
- /**
522
- * Get all direct children of this node
523
- * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
524
- * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
525
- * @returns an array of Node
526
- */
527
- getChildren(predicate, directDescendantsOnly = true) {
528
- return this.getDescendants(directDescendantsOnly, predicate);
529
- }
530
- /**
531
- * @internal
532
- */
533
- _setReady(state) {
534
- if (state === this._nodeDataStorage._isReady) {
535
- return;
536
- }
537
- if (!state) {
538
- this._nodeDataStorage._isReady = false;
539
- return;
540
- }
541
- if (this.onReady) {
542
- this.onReady(this);
543
- }
544
- this._nodeDataStorage._isReady = true;
545
- }
546
- /**
547
- * Get an animation by name
548
- * @param name defines the name of the animation to look for
549
- * @returns null if not found else the requested animation
550
- */
551
- getAnimationByName(name) {
552
- for (let i = 0; i < this.animations.length; i++) {
553
- const animation = this.animations[i];
554
- if (animation.name === name) {
555
- return animation;
556
- }
557
- }
558
- return null;
559
- }
560
- /**
561
- * Creates an animation range for this node
562
- * @param name defines the name of the range
563
- * @param from defines the starting key
564
- * @param to defines the end key
565
- */
566
- createAnimationRange(name, from, to) {
567
- // check name not already in use
568
- if (!this._ranges[name]) {
569
- this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
570
- for (let i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
571
- if (this.animations[i]) {
572
- this.animations[i].createRange(name, from, to);
573
- }
574
- }
575
- }
576
- }
577
- /**
578
- * Delete a specific animation range
579
- * @param name defines the name of the range to delete
580
- * @param deleteFrames defines if animation frames from the range must be deleted as well
581
- */
582
- deleteAnimationRange(name, deleteFrames = true) {
583
- for (let i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
584
- if (this.animations[i]) {
585
- this.animations[i].deleteRange(name, deleteFrames);
586
- }
587
- }
588
- this._ranges[name] = null; // said much faster than 'delete this._range[name]'
589
- }
590
- /**
591
- * Get an animation range by name
592
- * @param name defines the name of the animation range to look for
593
- * @returns null if not found else the requested animation range
594
- */
595
- getAnimationRange(name) {
596
- return this._ranges[name] || null;
597
- }
598
- /**
599
- * Clone the current node
600
- * @param name Name of the new clone
601
- * @param newParent New parent for the clone
602
- * @param doNotCloneChildren Do not clone children hierarchy
603
- * @returns the new transform node
604
- */
605
- clone(name, newParent, doNotCloneChildren) {
606
- const result = SerializationHelper.Clone(() => new Node(name, this.getScene()), this);
607
- if (newParent) {
608
- result.parent = newParent;
609
- }
610
- if (!doNotCloneChildren) {
611
- // Children
612
- const directDescendants = this.getDescendants(true);
613
- for (let index = 0; index < directDescendants.length; index++) {
614
- const child = directDescendants[index];
615
- child.clone(name + "." + child.name, result);
616
- }
617
- }
618
- return result;
619
- }
620
- /**
621
- * Gets the list of all animation ranges defined on this node
622
- * @returns an array
623
- */
624
- getAnimationRanges() {
625
- const animationRanges = [];
626
- let name;
627
- for (name in this._ranges) {
628
- animationRanges.push(this._ranges[name]);
629
- }
630
- return animationRanges;
631
- }
632
- /**
633
- * Will start the animation sequence
634
- * @param name defines the range frames for animation sequence
635
- * @param loop defines if the animation should loop (false by default)
636
- * @param speedRatio defines the speed factor in which to run the animation (1 by default)
637
- * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
638
- * @returns the object created for this animation. If range does not exist, it will return null
639
- */
640
- beginAnimation(name, loop, speedRatio, onAnimationEnd) {
641
- const range = this.getAnimationRange(name);
642
- if (!range) {
643
- return null;
644
- }
645
- return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
646
- }
647
- /**
648
- * Serialize animation ranges into a JSON compatible object
649
- * @returns serialization object
650
- */
651
- serializeAnimationRanges() {
652
- const serializationRanges = [];
653
- for (const name in this._ranges) {
654
- const localRange = this._ranges[name];
655
- if (!localRange) {
656
- continue;
657
- }
658
- const range = {};
659
- range.name = name;
660
- range.from = localRange.from;
661
- range.to = localRange.to;
662
- serializationRanges.push(range);
663
- }
664
- return serializationRanges;
665
- }
666
- /**
667
- * Computes the world matrix of the node
668
- * @param _force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
669
- * @returns the world matrix
670
- */
671
- computeWorldMatrix(_force) {
672
- if (!this._worldMatrix) {
673
- this._worldMatrix = Matrix.Identity();
674
- }
675
- return this._worldMatrix;
676
- }
677
- /**
678
- * Releases resources associated with this node.
679
- * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
680
- * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
681
- */
682
- dispose(doNotRecurse, disposeMaterialAndTextures = false) {
683
- this._nodeDataStorage._isDisposed = true;
684
- if (!doNotRecurse) {
685
- const nodes = this.getDescendants(true);
686
- for (const node of nodes) {
687
- node.dispose(doNotRecurse, disposeMaterialAndTextures);
688
- }
689
- }
690
- if (!this.parent) {
691
- this._removeFromSceneRootNodes();
692
- }
693
- else {
694
- this.parent = null;
695
- }
696
- // Callback
697
- this.onDisposeObservable.notifyObservers(this);
698
- this.onDisposeObservable.clear();
699
- this.onEnabledStateChangedObservable.clear();
700
- this.onClonedObservable.clear();
701
- // Behaviors
702
- for (const behavior of this._behaviors) {
703
- behavior.detach();
704
- }
705
- this._behaviors.length = 0;
706
- this.metadata = null;
707
- }
708
- /**
709
- * Parse animation range data from a serialization object and store them into a given node
710
- * @param node defines where to store the animation ranges
711
- * @param parsedNode defines the serialization object to read data from
712
- * @param _scene defines the hosting scene
713
- */
714
- static ParseAnimationRanges(node, parsedNode, _scene) {
715
- if (parsedNode.ranges) {
716
- for (let index = 0; index < parsedNode.ranges.length; index++) {
717
- const data = parsedNode.ranges[index];
718
- node.createAnimationRange(data.name, data.from, data.to);
719
- }
720
- }
721
- }
722
- /**
723
- * Return the minimum and maximum world vectors of the entire hierarchy under current node
724
- * @param includeDescendants Include bounding info from descendants as well (true by default)
725
- * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
726
- * @returns the new bounding vectors
727
- */
728
- getHierarchyBoundingVectors(includeDescendants = true, predicate = null) {
729
- // Ensures that all world matrix will be recomputed.
730
- this.getScene().incrementRenderId();
731
- this.computeWorldMatrix(true);
732
- let min;
733
- let max;
734
- const thisAbstractMesh = this;
735
- if (thisAbstractMesh.getBoundingInfo && thisAbstractMesh.subMeshes) {
736
- // If this is an abstract mesh get its bounding info
737
- const boundingInfo = thisAbstractMesh.getBoundingInfo();
738
- min = boundingInfo.boundingBox.minimumWorld.clone();
739
- max = boundingInfo.boundingBox.maximumWorld.clone();
740
- }
741
- else {
742
- min = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
743
- max = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
744
- }
745
- if (includeDescendants) {
746
- const descendants = this.getDescendants(false);
747
- for (const descendant of descendants) {
748
- const childMesh = descendant;
749
- childMesh.computeWorldMatrix(true);
750
- // Filters meshes based on custom predicate function.
751
- if (predicate && !predicate(childMesh)) {
752
- continue;
753
- }
754
- //make sure we have the needed params to get mix and max
755
- if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
756
- continue;
757
- }
758
- const childBoundingInfo = childMesh.getBoundingInfo();
759
- const boundingBox = childBoundingInfo.boundingBox;
760
- const minBox = boundingBox.minimumWorld;
761
- const maxBox = boundingBox.maximumWorld;
762
- Vector3.CheckExtends(minBox, min, max);
763
- Vector3.CheckExtends(maxBox, min, max);
764
- }
765
- }
766
- return {
767
- min: min,
768
- max: max,
769
- };
770
- }
771
- }
772
- /**
773
- * @internal
774
- */
775
- Node._AnimationRangeFactory = (_name, _from, _to) => {
776
- throw _WarnImport("AnimationRange");
777
- };
778
- Node._NodeConstructors = {};
779
- __decorate([
780
- serialize()
781
- ], Node.prototype, "name", void 0);
782
- __decorate([
783
- serialize()
784
- ], Node.prototype, "id", void 0);
785
- __decorate([
786
- serialize()
787
- ], Node.prototype, "uniqueId", void 0);
788
- __decorate([
789
- serialize()
790
- ], Node.prototype, "state", void 0);
791
- __decorate([
792
- serialize()
793
- ], Node.prototype, "metadata", void 0);
794
-
795
- export { Node as N };