babylonjs-addons 8.24.0 → 8.24.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/babylonjs.addons.d.ts +14 -967
- package/babylonjs.addons.js +1 -1
- package/babylonjs.addons.min.js +1 -1
- package/babylonjs.addons.min.js.map +1 -1
- package/babylonjs.addons.module.d.ts +551 -2510
- package/package.json +2 -2
package/babylonjs.addons.d.ts
CHANGED
@@ -388,973 +388,6 @@ declare module ADDONS {
|
|
388
388
|
};
|
389
389
|
|
390
390
|
|
391
|
-
|
392
|
-
|
393
|
-
/**
|
394
|
-
* Configuration options for the Lottie animation player.
|
395
|
-
*/
|
396
|
-
export type AnimationConfiguration = {
|
397
|
-
/**
|
398
|
-
* Whether the animation should play on a loop or not
|
399
|
-
*/
|
400
|
-
loopAnimation: boolean;
|
401
|
-
/**
|
402
|
-
* Size of the sprite atlas texture.
|
403
|
-
* Default is 2048.
|
404
|
-
*/
|
405
|
-
spriteAtlasSize: number;
|
406
|
-
/**
|
407
|
-
* Gap size around sprites in the atlas.
|
408
|
-
* Default is 5.
|
409
|
-
*/
|
410
|
-
gapSize: number;
|
411
|
-
/**
|
412
|
-
* Maximum number of sprites the renderer can handle at once.
|
413
|
-
* Default is 64.
|
414
|
-
*/
|
415
|
-
spritesCapacity: number;
|
416
|
-
/**
|
417
|
-
* Background color for the animation canvas.
|
418
|
-
* Default is white with full opacity.
|
419
|
-
*/
|
420
|
-
backgroundColor: {
|
421
|
-
r: number;
|
422
|
-
g: number;
|
423
|
-
b: number;
|
424
|
-
a: number;
|
425
|
-
};
|
426
|
-
/**
|
427
|
-
* Minimum scale factor to prevent too small sprites.
|
428
|
-
* Default is 5.
|
429
|
-
*/
|
430
|
-
scaleMultiplier: number;
|
431
|
-
/**
|
432
|
-
* Scale factor for the rendering.
|
433
|
-
* Default is 1.
|
434
|
-
*/
|
435
|
-
devicePixelRatio: number;
|
436
|
-
/**
|
437
|
-
* Number of steps to sample cubic bezier easing functions for animations.
|
438
|
-
* Default is 4.
|
439
|
-
*/
|
440
|
-
easingSteps: number;
|
441
|
-
/**
|
442
|
-
* Whether to ignore opacity animations for performance.
|
443
|
-
* Default is true.
|
444
|
-
*/
|
445
|
-
ignoreOpacityAnimations: boolean;
|
446
|
-
/**
|
447
|
-
* Whether to support device lost events for WebGL contexts.
|
448
|
-
* Default is false.
|
449
|
-
*/
|
450
|
-
supportDeviceLost: boolean;
|
451
|
-
};
|
452
|
-
/**
|
453
|
-
* LottiePlayer is a class that allows you to play Lottie animations using Babylon.js.
|
454
|
-
* It plays the animations in a worker thread using OffscreenCanvas.
|
455
|
-
* Once instance of this class can only be used to play a single animation. If you want to play multiple animations, create a new instance for each animation.
|
456
|
-
*/
|
457
|
-
export class LottiePlayer {
|
458
|
-
private _playing;
|
459
|
-
private _disposed;
|
460
|
-
private _worker;
|
461
|
-
private _canvas;
|
462
|
-
private _resizeObserver;
|
463
|
-
private readonly _container;
|
464
|
-
private readonly _animationFile;
|
465
|
-
private readonly _configuration;
|
466
|
-
/**
|
467
|
-
* Creates a new instance of the LottiePlayer.
|
468
|
-
* @param container The HTMLDivElement to create the canvas in and render the animation on.
|
469
|
-
* @param animationFile The URL of the Lottie animation file to be played.
|
470
|
-
* @param configuration Optional configuration object to customize the animation playback.
|
471
|
-
*/
|
472
|
-
constructor(container: HTMLDivElement, animationFile: string, configuration?: Partial<AnimationConfiguration>);
|
473
|
-
/**
|
474
|
-
* Loads and plays a lottie animation.
|
475
|
-
* @returns True if the animation is successfully set up to play, false if the animation couldn't play.
|
476
|
-
*/
|
477
|
-
playAnimation(): boolean;
|
478
|
-
/**
|
479
|
-
* Disposes the LottiePlayer instance, cleaning up resources and event listeners.
|
480
|
-
*/
|
481
|
-
dispose(): void;
|
482
|
-
private _onWindowResize;
|
483
|
-
private _onBeforeUnload;
|
484
|
-
}
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
/**
|
490
|
-
* Information about a sprite in the sprite atlas.
|
491
|
-
*/
|
492
|
-
export type SpriteAtlasInfo = {
|
493
|
-
/**
|
494
|
-
* Offset in the x axis of the sprite in the atlas.
|
495
|
-
* Normalized between 0 and 1, left to right.
|
496
|
-
*/
|
497
|
-
uOffset: number;
|
498
|
-
/**
|
499
|
-
* Offset in the y axis of the sprite in the atlas.
|
500
|
-
* Normalized between 0 and 1, top to bottom.
|
501
|
-
*/
|
502
|
-
vOffset: number;
|
503
|
-
/**
|
504
|
-
* Width of the sprite in the atlas.
|
505
|
-
* In pixels.
|
506
|
-
*/
|
507
|
-
cellWidth: number;
|
508
|
-
/**
|
509
|
-
* Height of the sprite in the atlas.
|
510
|
-
* In pixels.
|
511
|
-
*/
|
512
|
-
cellHeight: number;
|
513
|
-
/**
|
514
|
-
* Width of the sprite in the screen.
|
515
|
-
* In pixels.
|
516
|
-
*/
|
517
|
-
widthPx: number;
|
518
|
-
/**
|
519
|
-
* Height of the sprite in the screen.
|
520
|
-
* In pixels.
|
521
|
-
*/
|
522
|
-
heightPx: number;
|
523
|
-
/**
|
524
|
-
* X coordinate of the center of the sprite bounding box, used for final positioning in the screen
|
525
|
-
*/
|
526
|
-
centerX: number;
|
527
|
-
/**
|
528
|
-
* Y coordinate of the center of the sprite bounding box, used for final positioning in the screen
|
529
|
-
*/
|
530
|
-
centerY: number;
|
531
|
-
};
|
532
|
-
/**
|
533
|
-
* SpritePacker is a class that handles the packing of sprites into a texture atlas.
|
534
|
-
*/
|
535
|
-
export class SpritePacker {
|
536
|
-
private readonly _engine;
|
537
|
-
private readonly _configuration;
|
538
|
-
private _spritesCanvas;
|
539
|
-
private _spritesCanvasContext;
|
540
|
-
private readonly _spritesInternalTexture;
|
541
|
-
private readonly _spritesTexture;
|
542
|
-
private _isDirty;
|
543
|
-
private _currentX;
|
544
|
-
private _currentY;
|
545
|
-
private _maxRowHeight;
|
546
|
-
private _spriteAtlasInfo;
|
547
|
-
/**
|
548
|
-
* Gets the texture atlas that contains all the sprites packed by this SpritePacker.
|
549
|
-
* @returns The texture atlas containing the sprites.
|
550
|
-
*/
|
551
|
-
get texture(): BABYLON.ThinTexture;
|
552
|
-
/**
|
553
|
-
* Creates a new instance of SpritePacker.
|
554
|
-
* @param engine Engine that will render the sprites.
|
555
|
-
* @param configuration Configuration options for the sprite packer.
|
556
|
-
*/
|
557
|
-
constructor(engine: BABYLON.ThinEngine, configuration: AnimationConfiguration);
|
558
|
-
/**
|
559
|
-
* Adds a vector shape that comes from lottie data to the sprite atlas.
|
560
|
-
* @param rawGroup The raw group shape to add to the atlas.
|
561
|
-
* @param scalingFactor The scaling factor to apply to the shape.
|
562
|
-
* @returns The information on how to find the sprite in the atlas.
|
563
|
-
*/
|
564
|
-
addLottieShape(rawGroup: RawGroupShape, scalingFactor: BABYLON.IVector2Like): SpriteAtlasInfo;
|
565
|
-
/**
|
566
|
-
* Updates the internal atlas texture with the information that has been added to the SpritePacker.
|
567
|
-
*/
|
568
|
-
updateAtlasTexture(): void;
|
569
|
-
/**
|
570
|
-
* Releases the canvas and its context to allow garbage collection.
|
571
|
-
*/
|
572
|
-
releaseCanvas(): void;
|
573
|
-
private _drawVectorShape;
|
574
|
-
private _drawRectangle;
|
575
|
-
private _drawPath;
|
576
|
-
private _drawFill;
|
577
|
-
private _drawGradientFill;
|
578
|
-
private _drawLinearGradientFill;
|
579
|
-
private _drawRadialGradientFill;
|
580
|
-
private _addColorStops;
|
581
|
-
private _gradientColorsToCssColor;
|
582
|
-
private _lottieColorToCSSColor;
|
583
|
-
}
|
584
|
-
|
585
|
-
|
586
|
-
/**
|
587
|
-
* Represents a sprite in the scene graph.
|
588
|
-
*/
|
589
|
-
export class SpriteNode extends Node {
|
590
|
-
private _sprite;
|
591
|
-
private _originalWidth;
|
592
|
-
private _originalHeight;
|
593
|
-
private _firstTime;
|
594
|
-
/**
|
595
|
-
* Creates a new SpriteNode instance.
|
596
|
-
* @param id Unique identifier for the sprite node.
|
597
|
-
* @param ignoreOpacityAnimations If there are no animations on opacity, mark this as true to ignore and optimize CPU usage.
|
598
|
-
* @param sprite The sprite associated with this node.
|
599
|
-
* @param position The position of the sprite in the scene.
|
600
|
-
* @param rotation The rotation of the sprite in degrees.
|
601
|
-
* @param scale The scale of the sprite in the scene.
|
602
|
-
* @param opacity The opacity of the sprite.
|
603
|
-
* @param parent The parent node in the scene graph.
|
604
|
-
*/
|
605
|
-
constructor(id: string, ignoreOpacityAnimations: boolean, sprite: BABYLON.ThinSprite, position?: Vector2Property, rotation?: ScalarProperty, scale?: Vector2Property, opacity?: ScalarProperty, parent?: Node);
|
606
|
-
/**
|
607
|
-
* Updates the node's properties based on the current frame of the animation.
|
608
|
-
* @param frame Frame number we are playing in the animation.
|
609
|
-
* @param isParentUpdated Whether the parent node has been updated.
|
610
|
-
* @param isReset Whether the node is being reset.
|
611
|
-
* @returns True if the node was updated, false otherwise.
|
612
|
-
*/
|
613
|
-
update(frame: number, isParentUpdated?: boolean, isReset?: boolean): boolean;
|
614
|
-
}
|
615
|
-
|
616
|
-
|
617
|
-
/**
|
618
|
-
* Represents all the sprites from the animation and manages their rendering.
|
619
|
-
*/
|
620
|
-
export class RenderingManager {
|
621
|
-
private readonly _engine;
|
622
|
-
private readonly _spritesRenderer;
|
623
|
-
private readonly _spritesTexture;
|
624
|
-
private _sprites;
|
625
|
-
private readonly _configuration;
|
626
|
-
/**
|
627
|
-
* Creates a new instance of the RenderingManager.
|
628
|
-
* @param engine BABYLON.ThinEngine instance used for rendering.
|
629
|
-
* @param spriteTexture The texture atlas containing the sprites.
|
630
|
-
* @param configuration Configuration options for the rendering manager.
|
631
|
-
*/
|
632
|
-
constructor(engine: BABYLON.ThinEngine, spriteTexture: BABYLON.ThinTexture, configuration: AnimationConfiguration);
|
633
|
-
/**
|
634
|
-
* Adds a sprite to the rendering manager.
|
635
|
-
* @param sprite Sprite to add to the rendering manager.
|
636
|
-
*/
|
637
|
-
addSprite(sprite: BABYLON.ThinSprite): void;
|
638
|
-
/**
|
639
|
-
* Prepares the rendering manager for rendering.
|
640
|
-
*/
|
641
|
-
ready(): void;
|
642
|
-
/**
|
643
|
-
* Renders all the sprites in the rendering manager.
|
644
|
-
* @param worldMatrix World matrix to apply to the sprites.
|
645
|
-
* @param projectionMatrix Projection matrix to apply to the sprites.
|
646
|
-
*/
|
647
|
-
render(worldMatrix: ThinMatrix, projectionMatrix: ThinMatrix): void;
|
648
|
-
/**
|
649
|
-
* Disposes the rendering manager and its resources.
|
650
|
-
*/
|
651
|
-
dispose(): void;
|
652
|
-
private _customSpriteUpdate;
|
653
|
-
}
|
654
|
-
|
655
|
-
|
656
|
-
/**
|
657
|
-
* Represents a node in the scenegraph that contains the animation information from a lottie animation layer or group.
|
658
|
-
*/
|
659
|
-
export class Node {
|
660
|
-
private readonly _id;
|
661
|
-
private readonly _ignoreOpacityAnimations;
|
662
|
-
private readonly _position;
|
663
|
-
private readonly _rotation;
|
664
|
-
private readonly _scale;
|
665
|
-
private _worldMatrix;
|
666
|
-
private _localMatrix;
|
667
|
-
private _globalMatrix;
|
668
|
-
private readonly _opacity;
|
669
|
-
private readonly _parent;
|
670
|
-
private readonly _children;
|
671
|
-
private _isVisible;
|
672
|
-
private _isAnimated;
|
673
|
-
private _animationsFunctions;
|
674
|
-
protected _isControl: boolean;
|
675
|
-
protected _isShape: boolean;
|
676
|
-
/**
|
677
|
-
* Gets the id of this node.
|
678
|
-
* @returns The unique identifier of this node.
|
679
|
-
*/
|
680
|
-
get id(): string;
|
681
|
-
/**
|
682
|
-
* Gets the childer of this node.
|
683
|
-
* @returns An array of child nodes.
|
684
|
-
*/
|
685
|
-
get children(): Node[];
|
686
|
-
/**
|
687
|
-
* Gets whether this node is a shape.
|
688
|
-
* @returns True if this node is a shape, false otherwise.
|
689
|
-
*/
|
690
|
-
get isShape(): boolean;
|
691
|
-
/**
|
692
|
-
* Gets the world matrix of this node.
|
693
|
-
* @returns The world matrix.
|
694
|
-
*/
|
695
|
-
get worldMatrix(): ThinMatrix;
|
696
|
-
/**
|
697
|
-
* Gets whether this node is animated.
|
698
|
-
* @returns True if this node has animations, false otherwise.
|
699
|
-
*/
|
700
|
-
get isAnimated(): boolean;
|
701
|
-
/**
|
702
|
-
* Gets the opacity of this node.
|
703
|
-
* If the node is not visible, the opacity will be 0.
|
704
|
-
* @returns The opacity of the node, from 0 to 1.
|
705
|
-
*/
|
706
|
-
get opacity(): number;
|
707
|
-
/**
|
708
|
-
* Gets the initial scale of this node.
|
709
|
-
* @returns The initial scale.
|
710
|
-
*/
|
711
|
-
get startScale(): BABYLON.IVector2Like;
|
712
|
-
/**
|
713
|
-
* Gets the parent node of this node.
|
714
|
-
* @returns The parent node, or undefined if this is a root node.
|
715
|
-
*/
|
716
|
-
get parent(): Node | undefined;
|
717
|
-
/**
|
718
|
-
* Sets the node visibility.
|
719
|
-
* @param value The new visibility value.
|
720
|
-
*/
|
721
|
-
set isVisible(value: boolean);
|
722
|
-
/**
|
723
|
-
* Constructs a new node.
|
724
|
-
* @param id Unique identifier for the node.
|
725
|
-
* @param ignoreOpacityAnimations If there are no animations on opacity, mark this as true to ignore and optimize CPU usage.
|
726
|
-
* @param position Position of the node in the scene.
|
727
|
-
* @param rotation Rotation of the node in degrees.
|
728
|
-
* @param scale Scale of the node in the scene.
|
729
|
-
* @param opacity Opacity of the node, from 0 to 1.
|
730
|
-
* @param parent Parent node in the scenegraph.
|
731
|
-
*/
|
732
|
-
constructor(id: string, ignoreOpacityAnimations: boolean, position?: Vector2Property, rotation?: ScalarProperty, scale?: Vector2Property, opacity?: ScalarProperty, parent?: Node);
|
733
|
-
/**
|
734
|
-
* Resets the node's properties to their initial values.
|
735
|
-
*/
|
736
|
-
reset(): void;
|
737
|
-
/**
|
738
|
-
* Updates the node's properties based on the current frame of the animation.
|
739
|
-
* @param frame Frame number we are playing in the animation.
|
740
|
-
* @param isParentUpdated Whether the parent node has been updated.
|
741
|
-
* @param isReset Whether the node is being reset.
|
742
|
-
* @returns True if the node was updated, false otherwise.
|
743
|
-
*/
|
744
|
-
update(frame: number, isParentUpdated?: boolean, isReset?: boolean): boolean;
|
745
|
-
private _updatePosition;
|
746
|
-
private _updateRotation;
|
747
|
-
private _updateScale;
|
748
|
-
private _updateOpacity;
|
749
|
-
}
|
750
|
-
|
751
|
-
|
752
|
-
/**
|
753
|
-
* This represents a top node of the scenegraph in a Lottie animation.
|
754
|
-
* Each top level layer in Lottie is represented by a control node node.
|
755
|
-
*/
|
756
|
-
export class ControlNode extends Node {
|
757
|
-
private _inFrame;
|
758
|
-
private _outFrame;
|
759
|
-
/**
|
760
|
-
* Constructs a new control node.
|
761
|
-
* @param id Unique identifier for the node.
|
762
|
-
* @param ignoreOpacityAnimations If there are no animations on opacity, mark this as true to ignore and optimize CPU usage.
|
763
|
-
* @param inFrame Frame at which the node becomes active.
|
764
|
-
* @param outFrame Frame at which the node becomes inactive.
|
765
|
-
* @param position Position of the node in the scene.
|
766
|
-
* @param rotation Rotation of the node in degrees.
|
767
|
-
* @param scale Scale of the node in the scene.
|
768
|
-
* @param opacity Opacity of the node, from 0 to 1.
|
769
|
-
* @param parent Parent node in the scenegraph.
|
770
|
-
*/
|
771
|
-
constructor(id: string, ignoreOpacityAnimations: boolean, inFrame: number, outFrame: number, position?: Vector2Property, rotation?: ScalarProperty, scale?: Vector2Property, opacity?: ScalarProperty, parent?: Node);
|
772
|
-
/**
|
773
|
-
* Updates the node's properties based on the current frame of the animation.
|
774
|
-
* This node will only be updated if the current frame is within the in and out range.
|
775
|
-
* @param frame Frame number we are playing in the animation.
|
776
|
-
* @param isParentUpdated Whether the parent node has been updated.
|
777
|
-
* @param isReset Whether the node is being reset.
|
778
|
-
* @returns True if the node was updated, false otherwise.
|
779
|
-
*/
|
780
|
-
update(frame: number, isParentUpdated?: boolean, isReset?: boolean): boolean;
|
781
|
-
}
|
782
|
-
|
783
|
-
|
784
|
-
/**
|
785
|
-
* Class that controls the playing of lottie animations using Babylon.js
|
786
|
-
*/
|
787
|
-
export class AnimationController {
|
788
|
-
private _isReady;
|
789
|
-
private readonly _canvas;
|
790
|
-
private readonly _configuration;
|
791
|
-
private readonly _engine;
|
792
|
-
private readonly _spritePacker;
|
793
|
-
private _animation?;
|
794
|
-
private readonly _viewport;
|
795
|
-
private readonly _projectionMatrix;
|
796
|
-
private readonly _worldMatrix;
|
797
|
-
private _frameDuration;
|
798
|
-
private _currentFrame;
|
799
|
-
private _isPlaying;
|
800
|
-
private _animationFrameId;
|
801
|
-
private _lastFrameTime;
|
802
|
-
private _deltaTime;
|
803
|
-
private _loop;
|
804
|
-
private _accumulatedTime;
|
805
|
-
private _framesToAdvance;
|
806
|
-
private readonly _renderingManager;
|
807
|
-
/**
|
808
|
-
* Gets the canvas used for rendering the animation.
|
809
|
-
* @returns The canvas element used for rendering.
|
810
|
-
*/
|
811
|
-
get view(): HTMLCanvasElement;
|
812
|
-
/**
|
813
|
-
* Gets the height of the animation in pixels.
|
814
|
-
* @returns The height of the animation in pixels.
|
815
|
-
*/
|
816
|
-
get animationHeight(): number;
|
817
|
-
/**
|
818
|
-
* Gets the width of the animation in pixels.
|
819
|
-
* @returns The width of the animation in pixels.
|
820
|
-
*/
|
821
|
-
get animationWidth(): number;
|
822
|
-
/**
|
823
|
-
* Creates a new instance of the Player.
|
824
|
-
* @param canvas The canvas element to render the animation on.
|
825
|
-
* @param animationJson The JSON string of the Lottie animation to be played.
|
826
|
-
* @param configuration The configuration for the animation player.
|
827
|
-
*/
|
828
|
-
constructor(canvas: HTMLCanvasElement, animationJson: string, configuration: AnimationConfiguration);
|
829
|
-
/**
|
830
|
-
* Plays the animation.
|
831
|
-
* @param loop If true, the animation will loop when it reaches the end.
|
832
|
-
*/
|
833
|
-
playAnimation(loop?: boolean): void;
|
834
|
-
/**
|
835
|
-
* Stops the animation playback.
|
836
|
-
*/
|
837
|
-
stopAnimation(): void;
|
838
|
-
/**
|
839
|
-
* Sets the rendering size for the engine
|
840
|
-
* @param width Width of the rendering canvas
|
841
|
-
* @param height Height of the rendering canvas
|
842
|
-
*/
|
843
|
-
setSize(width: number, height: number): void;
|
844
|
-
/**
|
845
|
-
* Disposes the player and releases all resources.
|
846
|
-
*/
|
847
|
-
dispose(): void;
|
848
|
-
private _cleanTree;
|
849
|
-
private _startRenderLoop;
|
850
|
-
private _render;
|
851
|
-
}
|
852
|
-
|
853
|
-
|
854
|
-
/**
|
855
|
-
* Represents a Babylon.js thin version of a Matrix
|
856
|
-
* We are only exposing what we truly need in the scope of
|
857
|
-
* the Lottie Renderer project preventing the dependency on the full
|
858
|
-
* Babylon.js math system.
|
859
|
-
*/
|
860
|
-
export class ThinMatrix implements BABYLON.IMatrixLike {
|
861
|
-
/**
|
862
|
-
* Prevents global conflicts on update as shader programs are shared.
|
863
|
-
*/
|
864
|
-
private static _UPDATE_FLAG_SEED;
|
865
|
-
/**
|
866
|
-
* Current update flag used to know whether a Matrix has changed since previous render or not.
|
867
|
-
* This helps identifying if a Matrix needs to be
|
868
|
-
* uploaded to a shader program.
|
869
|
-
*/
|
870
|
-
updateFlag: number;
|
871
|
-
private readonly _data;
|
872
|
-
/**
|
873
|
-
* Creates a new ThinMatrix instance.
|
874
|
-
*/
|
875
|
-
constructor();
|
876
|
-
/**
|
877
|
-
* Set the matrix values.
|
878
|
-
* @param m11 Value for row 1, column 1
|
879
|
-
* @param m12 Value for row 1, column 2
|
880
|
-
* @param m13 Value for row 1, column 3
|
881
|
-
* @param m14 Value for row 1, column 4
|
882
|
-
* @param m21 Value for row 2, column 1
|
883
|
-
* @param m22 Value for row 2, column 2
|
884
|
-
* @param m23 Value for row 2, column 3
|
885
|
-
* @param m24 Value for row 2, column 4
|
886
|
-
* @param m31 Value for row 3, column 1
|
887
|
-
* @param m32 Value for row 3, column 2
|
888
|
-
* @param m33 Value for row 3, column 3
|
889
|
-
* @param m34 Value for row 3, column 4
|
890
|
-
* @param m41 Value for row 4, column 1
|
891
|
-
* @param m42 Value for row 4, column 2
|
892
|
-
* @param m43 Value for row 4, column 3
|
893
|
-
* @param m44 Value for row 4, column 4
|
894
|
-
* @returns The updated ThinMatrix instance
|
895
|
-
*/
|
896
|
-
setValues(m11: number, m12: number, m13: number, m14: number, m21: number, m22: number, m23: number, m24: number, m31: number, m32: number, m33: number, m34: number, m41: number, m42: number, m43: number, m44: number): ThinMatrix;
|
897
|
-
/**
|
898
|
-
* Set the matrix to an identity matrix.
|
899
|
-
* @returns The updated ThinMatrix instance
|
900
|
-
*/
|
901
|
-
identity(): ThinMatrix;
|
902
|
-
/**
|
903
|
-
* Stores a left-handed orthographic projection into a given matrix
|
904
|
-
* @param left defines the viewport left coordinate
|
905
|
-
* @param right defines the viewport right coordinate
|
906
|
-
* @param bottom defines the viewport bottom coordinate
|
907
|
-
* @param top defines the viewport top coordinate
|
908
|
-
* @param znear defines the near clip plane
|
909
|
-
* @param zfar defines the far clip plane
|
910
|
-
* @returns The updated ThinMatrix instance
|
911
|
-
*/
|
912
|
-
orthoOffCenterLeftHanded(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): ThinMatrix;
|
913
|
-
/**
|
914
|
-
* Sets a matrix to a value composed by merging scale (vector2), rotation (roll around z) and translation (vector2)
|
915
|
-
* This only updates the parts of the matrix that are used for 2D transformations.
|
916
|
-
* @param scale defines the scale vector
|
917
|
-
* @param roll defines the rotation around z
|
918
|
-
* @param translation defines the translation vector
|
919
|
-
* @returns the updated ThinMatrix instance
|
920
|
-
*/
|
921
|
-
compose(scale: BABYLON.IVector2Like, roll: number, translation: BABYLON.IVector2Like): ThinMatrix;
|
922
|
-
/**
|
923
|
-
* Sets the current matrix with the multiplication result of the current Matrix and the given one
|
924
|
-
* This only updates the parts of the matrix that are used for 2D transformations.
|
925
|
-
* @param other defines the second operand
|
926
|
-
* @param output the matrix to store the result in
|
927
|
-
* @returns the current matrix
|
928
|
-
*/
|
929
|
-
multiplyToRef(other: ThinMatrix, output: ThinMatrix): ThinMatrix;
|
930
|
-
/**
|
931
|
-
* Returns the matrix data array.
|
932
|
-
* @returns The matrix data
|
933
|
-
*/
|
934
|
-
asArray(): BABYLON.Tuple<number, 16>;
|
935
|
-
/**
|
936
|
-
* Decomposes the matrix into scale, rotation, and translation.
|
937
|
-
* @param scale Scale vector to store the scale values
|
938
|
-
* @param translation Translation vector to store the translation values
|
939
|
-
* @returns The rotation in radians
|
940
|
-
*/
|
941
|
-
decompose(scale: BABYLON.IVector2Like, translation: BABYLON.IVector2Like): number;
|
942
|
-
}
|
943
|
-
|
944
|
-
|
945
|
-
/**
|
946
|
-
* Represents a bounding box for a shape in the animation.
|
947
|
-
*/
|
948
|
-
export type BoundingBox = {
|
949
|
-
/**
|
950
|
-
* Height of the bounding box
|
951
|
-
*/
|
952
|
-
height: number;
|
953
|
-
/**
|
954
|
-
* Width of the bounding box
|
955
|
-
*/
|
956
|
-
width: number;
|
957
|
-
/**
|
958
|
-
* X coordinate of the center of the bounding box
|
959
|
-
*/
|
960
|
-
centerX: number;
|
961
|
-
/**
|
962
|
-
* Y coordinate of the center of the bounding box
|
963
|
-
*/
|
964
|
-
centerY: number;
|
965
|
-
};
|
966
|
-
/**
|
967
|
-
* Calculates the bounding box for a group shape in a Lottie animation.
|
968
|
-
* @param rawGroup The raw group shape to calculate the bounding box for
|
969
|
-
* @returns The bounding box for the group shape
|
970
|
-
*/
|
971
|
-
export function GetBoundingBox(rawGroup: RawGroupShape): BoundingBox;
|
972
|
-
|
973
|
-
|
974
|
-
/**
|
975
|
-
* Represents a Babylon.js thin version of a cubic bezier curve
|
976
|
-
* We are only exposing what we truly need in the scope of
|
977
|
-
* the Lottie Renderer project preventing the dependency on the full
|
978
|
-
* Babylon.js animation system.
|
979
|
-
*/
|
980
|
-
export class BezierCurve {
|
981
|
-
/**
|
982
|
-
* X of the first control point
|
983
|
-
*/
|
984
|
-
readonly x1: number;
|
985
|
-
/**
|
986
|
-
* Y of the first control point
|
987
|
-
*/
|
988
|
-
readonly y1: number;
|
989
|
-
/**
|
990
|
-
* X of the second control point
|
991
|
-
*/
|
992
|
-
readonly x2: number;
|
993
|
-
/**
|
994
|
-
* Y of the second control point
|
995
|
-
*/
|
996
|
-
readonly y2: number;
|
997
|
-
private readonly _easingSteps;
|
998
|
-
private readonly _f0;
|
999
|
-
private readonly _f1;
|
1000
|
-
private readonly _f2;
|
1001
|
-
/**
|
1002
|
-
* Instantiates a bezier function
|
1003
|
-
* @see http://cubic-bezier.com/#.17,.67,.83,.67
|
1004
|
-
* @param x1 Defines the x component of the start tangent in the bezier curve
|
1005
|
-
* @param y1 Defines the y component of the start tangent in the bezier curve
|
1006
|
-
* @param x2 Defines the x component of the end tangent in the bezier curve
|
1007
|
-
* @param y2 Defines the y component of the end tangent in the bezier curve
|
1008
|
-
* @param easingSteps Number of steps to sample the bezier curve for easing
|
1009
|
-
*/
|
1010
|
-
constructor(x1: number | undefined, y1: number | undefined, x2: number | undefined, y2: number | undefined, easingSteps: number);
|
1011
|
-
/**
|
1012
|
-
* Interpolates the bezier curve at a given time
|
1013
|
-
* @param t Defines the time to evaluate the bezier curve at, between 0 and 1
|
1014
|
-
* @returns The interpolated value at time t
|
1015
|
-
*/
|
1016
|
-
interpolate(t: number): number;
|
1017
|
-
}
|
1018
|
-
|
1019
|
-
|
1020
|
-
export type RawLottieAnimation = {
|
1021
|
-
v: string;
|
1022
|
-
fr: number;
|
1023
|
-
ip: number;
|
1024
|
-
op: number;
|
1025
|
-
w: number;
|
1026
|
-
h: number;
|
1027
|
-
nm?: string;
|
1028
|
-
layers: RawLottieLayer[];
|
1029
|
-
};
|
1030
|
-
export type RawLottieLayer = {
|
1031
|
-
ind?: number;
|
1032
|
-
ty: RawLayerType;
|
1033
|
-
nm?: string;
|
1034
|
-
parent?: number;
|
1035
|
-
hd?: boolean;
|
1036
|
-
sr?: number;
|
1037
|
-
ao?: number;
|
1038
|
-
ip?: number;
|
1039
|
-
op?: number;
|
1040
|
-
st?: number;
|
1041
|
-
ct?: number;
|
1042
|
-
ks: RawTransform;
|
1043
|
-
shapes?: RawGraphicElement[];
|
1044
|
-
};
|
1045
|
-
export type RawGraphicElement = {
|
1046
|
-
nm?: string;
|
1047
|
-
hd?: boolean;
|
1048
|
-
ty: RawShapeType;
|
1049
|
-
bm?: number;
|
1050
|
-
ix?: number;
|
1051
|
-
};
|
1052
|
-
export type RawGroupShape = RawGraphicElement & {
|
1053
|
-
it?: RawGraphicElement[];
|
1054
|
-
};
|
1055
|
-
export type RawRectangleShape = RawGraphicElement & {
|
1056
|
-
d: RawShapeDirection;
|
1057
|
-
p: RawPositionProperty;
|
1058
|
-
s: RawVectorProperty;
|
1059
|
-
r: RawScalarProperty;
|
1060
|
-
};
|
1061
|
-
export type RawPathShape = RawGraphicElement & {
|
1062
|
-
d: RawShapeDirection;
|
1063
|
-
ks: RawBezierShapeProperty;
|
1064
|
-
};
|
1065
|
-
export type RawFillShape = RawGraphicElement & {
|
1066
|
-
o: RawScalarProperty;
|
1067
|
-
c: RawColorProperty;
|
1068
|
-
r: RawFillRule;
|
1069
|
-
};
|
1070
|
-
export type RawGradientFillShape = RawGraphicElement & {
|
1071
|
-
o: RawScalarProperty;
|
1072
|
-
g: RawGradientsProperty;
|
1073
|
-
s: RawPositionProperty;
|
1074
|
-
e: RawPositionProperty;
|
1075
|
-
t: RawGradientType;
|
1076
|
-
h: RawScalarProperty;
|
1077
|
-
a?: RawScalarProperty;
|
1078
|
-
r: RawFillRule;
|
1079
|
-
};
|
1080
|
-
export type RawTransformShape = RawGraphicElement & {
|
1081
|
-
a: RawPositionProperty;
|
1082
|
-
p: RawPositionProperty;
|
1083
|
-
r: RawScalarProperty;
|
1084
|
-
s: RawVectorProperty;
|
1085
|
-
o: RawScalarProperty;
|
1086
|
-
sk: RawScalarProperty;
|
1087
|
-
sa: RawScalarProperty;
|
1088
|
-
};
|
1089
|
-
export type RawTransform = {
|
1090
|
-
a?: RawPositionProperty;
|
1091
|
-
p?: RawPositionProperty;
|
1092
|
-
r?: RawScalarProperty;
|
1093
|
-
s?: RawVectorProperty;
|
1094
|
-
o?: RawScalarProperty;
|
1095
|
-
};
|
1096
|
-
export type RawScalarProperty = {
|
1097
|
-
a: RawNumberBoolean;
|
1098
|
-
k: number | RawVectorKeyframe[];
|
1099
|
-
};
|
1100
|
-
export type RawVectorProperty = {
|
1101
|
-
a: RawNumberBoolean;
|
1102
|
-
k: number[] | RawVectorKeyframe[];
|
1103
|
-
l: number;
|
1104
|
-
};
|
1105
|
-
export type RawVectorKeyframe = {
|
1106
|
-
t: number;
|
1107
|
-
s: number[];
|
1108
|
-
h?: RawNumberBoolean;
|
1109
|
-
i?: RawKeyFrameEasing;
|
1110
|
-
o?: RawKeyFrameEasing;
|
1111
|
-
};
|
1112
|
-
export type RawPositionProperty = {
|
1113
|
-
a: RawNumberBoolean;
|
1114
|
-
k: number[] | RawPositionKeyframe[];
|
1115
|
-
l: number;
|
1116
|
-
};
|
1117
|
-
export type RawPositionKeyframe = {
|
1118
|
-
t: number;
|
1119
|
-
h?: RawNumberBoolean;
|
1120
|
-
i?: RawKeyFrameEasing;
|
1121
|
-
o?: RawKeyFrameEasing;
|
1122
|
-
s: number[];
|
1123
|
-
ti: number[];
|
1124
|
-
to: number[];
|
1125
|
-
};
|
1126
|
-
export type RawBezierShapeProperty = {
|
1127
|
-
a: RawNumberBoolean;
|
1128
|
-
k: RawBezier | RawBezierShapeKeyframe[];
|
1129
|
-
};
|
1130
|
-
export type RawBezierShapeKeyframe = {
|
1131
|
-
t: number;
|
1132
|
-
h?: RawNumberBoolean;
|
1133
|
-
i?: RawKeyFrameEasing;
|
1134
|
-
o?: RawKeyFrameEasing;
|
1135
|
-
s: RawBezier[];
|
1136
|
-
};
|
1137
|
-
export type RawColorProperty = {
|
1138
|
-
a: RawNumberBoolean;
|
1139
|
-
k: number[] | RawColorKeyframe[];
|
1140
|
-
};
|
1141
|
-
export type RawColorKeyframe = {
|
1142
|
-
t: number;
|
1143
|
-
h?: RawNumberBoolean;
|
1144
|
-
i?: RawKeyFrameEasing;
|
1145
|
-
o?: RawKeyFrameEasing;
|
1146
|
-
s: number[];
|
1147
|
-
};
|
1148
|
-
export type RawGradientsProperty = {
|
1149
|
-
p: number;
|
1150
|
-
k: RawGradientProperty;
|
1151
|
-
};
|
1152
|
-
export type RawGradientProperty = {
|
1153
|
-
a: RawNumberBoolean;
|
1154
|
-
k: number[];
|
1155
|
-
};
|
1156
|
-
export type RawKeyFrameEasing = {
|
1157
|
-
x: number | number[];
|
1158
|
-
y: number | number[];
|
1159
|
-
};
|
1160
|
-
export type RawBezier = {
|
1161
|
-
c: boolean;
|
1162
|
-
i: number[][];
|
1163
|
-
o: number[][];
|
1164
|
-
v: number[][];
|
1165
|
-
};
|
1166
|
-
export type RawNumberBoolean = 0 | 1;
|
1167
|
-
export type RawLayerType = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
1168
|
-
export type RawShapeType = "fl" | "gf" | "gr" | "tr" | "sh" | "rc";
|
1169
|
-
export type RawShapeDirection = 1 | 3;
|
1170
|
-
export type RawFillRule = 1 | 2;
|
1171
|
-
export type RawGradientType = 1 | 2;
|
1172
|
-
|
1173
|
-
|
1174
|
-
/**
|
1175
|
-
* Represents a Babylon.js thin version of a Lottie animation.
|
1176
|
-
*/
|
1177
|
-
export type AnimationInfo = {
|
1178
|
-
/**
|
1179
|
-
* Frame number where the animation starts.
|
1180
|
-
*/
|
1181
|
-
startFrame: number;
|
1182
|
-
/**
|
1183
|
-
* Frame number where the animation ends.
|
1184
|
-
*/
|
1185
|
-
endFrame: number;
|
1186
|
-
/**
|
1187
|
-
* Frame rate of the animation.
|
1188
|
-
*/
|
1189
|
-
frameRate: number;
|
1190
|
-
/**
|
1191
|
-
* Width of the animation in pixels
|
1192
|
-
*/
|
1193
|
-
widthPx: number;
|
1194
|
-
/**
|
1195
|
-
* Height of the animation in pixels
|
1196
|
-
*/
|
1197
|
-
heightPx: number;
|
1198
|
-
/**
|
1199
|
-
* Nodes representing the animation
|
1200
|
-
*/
|
1201
|
-
nodes: Node[];
|
1202
|
-
};
|
1203
|
-
/**
|
1204
|
-
* Transform properties for a Lottie animation.
|
1205
|
-
* Any of these properties may be animated.
|
1206
|
-
*/
|
1207
|
-
export type Transform = {
|
1208
|
-
/**
|
1209
|
-
* The anchor point of the layer, which is the point around which transformations are applied.
|
1210
|
-
*/
|
1211
|
-
anchorPoint: Vector2Property;
|
1212
|
-
/**
|
1213
|
-
* The position of the layer in the animation.
|
1214
|
-
*/
|
1215
|
-
position: Vector2Property;
|
1216
|
-
/**
|
1217
|
-
* The rotation of the layer in degrees.
|
1218
|
-
*/
|
1219
|
-
rotation: ScalarProperty;
|
1220
|
-
/**
|
1221
|
-
* The scale of the layer in the X and Y axis.
|
1222
|
-
*/
|
1223
|
-
scale: Vector2Property;
|
1224
|
-
/**
|
1225
|
-
* The opacity of the layer, represented as a scalar value.
|
1226
|
-
*/
|
1227
|
-
opacity: ScalarProperty;
|
1228
|
-
};
|
1229
|
-
/**
|
1230
|
-
* Represents a scalar that can be animated.
|
1231
|
-
*/
|
1232
|
-
export type ScalarProperty = {
|
1233
|
-
/**
|
1234
|
-
* The initial value of the property at the start of the animation.
|
1235
|
-
*/
|
1236
|
-
startValue: number;
|
1237
|
-
/**
|
1238
|
-
* The current value of the property during the animation.
|
1239
|
-
*/
|
1240
|
-
currentValue: number;
|
1241
|
-
/**
|
1242
|
-
* An array of keyframes for the property.
|
1243
|
-
*/
|
1244
|
-
keyframes?: ScalarKeyframe[];
|
1245
|
-
/**
|
1246
|
-
* The index of the current keyframe being processed in the animation.
|
1247
|
-
*/
|
1248
|
-
currentKeyframeIndex: number;
|
1249
|
-
};
|
1250
|
-
/**
|
1251
|
-
* Represents a keyframe for a scalar property.
|
1252
|
-
*/
|
1253
|
-
export type ScalarKeyframe = {
|
1254
|
-
/**
|
1255
|
-
* The value at this keyframe.
|
1256
|
-
*/
|
1257
|
-
value: number;
|
1258
|
-
/**
|
1259
|
-
* The time at which this keyframe occurs in the animation, in frames.
|
1260
|
-
*/
|
1261
|
-
time: number;
|
1262
|
-
/**
|
1263
|
-
* The easing function applied to the transition from this keyframe to the next one.
|
1264
|
-
*/
|
1265
|
-
easeFunction: BezierCurve;
|
1266
|
-
};
|
1267
|
-
/**
|
1268
|
-
* Represents a 2D vector that can be animated.
|
1269
|
-
*/
|
1270
|
-
export type Vector2Property = {
|
1271
|
-
/**
|
1272
|
-
* The initial value at the start of the animation.
|
1273
|
-
*/
|
1274
|
-
startValue: BABYLON.IVector2Like;
|
1275
|
-
/**
|
1276
|
-
* The current value during the animation.
|
1277
|
-
*/
|
1278
|
-
currentValue: BABYLON.IVector2Like;
|
1279
|
-
/**
|
1280
|
-
* An array of keyframes for the property.
|
1281
|
-
*/
|
1282
|
-
keyframes?: Vector2Keyframe[];
|
1283
|
-
/**
|
1284
|
-
* The index of the current keyframe being processed in the animation.
|
1285
|
-
*/
|
1286
|
-
currentKeyframeIndex: number;
|
1287
|
-
};
|
1288
|
-
/**
|
1289
|
-
* Represents a keyframe for a 2D vector property.
|
1290
|
-
*/
|
1291
|
-
export type Vector2Keyframe = {
|
1292
|
-
/**
|
1293
|
-
* The value at this keyframe.
|
1294
|
-
*/
|
1295
|
-
value: BABYLON.IVector2Like;
|
1296
|
-
/**
|
1297
|
-
* The time at which this keyframe occurs in the animation, in frames.
|
1298
|
-
*/
|
1299
|
-
time: number;
|
1300
|
-
/**
|
1301
|
-
* The easing function applied to the transition from this keyframe to the next one.
|
1302
|
-
* This is used for the first dimension of the vector.
|
1303
|
-
*/
|
1304
|
-
easeFunction1: BezierCurve;
|
1305
|
-
/**
|
1306
|
-
* The easing function applied to the transition from this keyframe to the next one.
|
1307
|
-
* This is used for the second dimension of the vector.
|
1308
|
-
*/
|
1309
|
-
easeFunction2: BezierCurve;
|
1310
|
-
};
|
1311
|
-
|
1312
|
-
|
1313
|
-
/**
|
1314
|
-
* Parses a lottie animation file and converts it into a format that can be rendered by Babylon.js
|
1315
|
-
* Important: not all lottie features are supported, you can call .debug() after parsing an animation to see what features were not supported.
|
1316
|
-
*/
|
1317
|
-
export class AnimationParser {
|
1318
|
-
private _packer;
|
1319
|
-
private readonly _renderingManager;
|
1320
|
-
private readonly _configuration;
|
1321
|
-
private readonly _animationInfo;
|
1322
|
-
private _unsupportedFeatures;
|
1323
|
-
private _parentNodes;
|
1324
|
-
private _rootNodes;
|
1325
|
-
private _shape;
|
1326
|
-
/**
|
1327
|
-
* Get the animation information parsed from the Lottie file.
|
1328
|
-
*/
|
1329
|
-
get animationInfo(): AnimationInfo;
|
1330
|
-
/**
|
1331
|
-
* Creates a new instance of the Lottie animations parser.
|
1332
|
-
* @param packer Object that packs the sprites from the animation into a texture atlas.
|
1333
|
-
* @param fileContentAsJsonString The content of the lottie file as a JSON string.
|
1334
|
-
* @param configuration Configuration options for the animation parser.
|
1335
|
-
* @param renderingManager Object that manages the rendering of the sprites in the animation.
|
1336
|
-
*/
|
1337
|
-
constructor(packer: SpritePacker, fileContentAsJsonString: string, configuration: AnimationConfiguration, renderingManager: RenderingManager);
|
1338
|
-
/**
|
1339
|
-
* Logs to the console all issues that were encountered during parsing the file.
|
1340
|
-
*/
|
1341
|
-
debug(): void;
|
1342
|
-
private _loadFromData;
|
1343
|
-
private _parseLayer;
|
1344
|
-
private _parseShapes;
|
1345
|
-
private _parseGroupShape;
|
1346
|
-
private _parseTransform;
|
1347
|
-
private _fromLottieScalarToBabylonScalar;
|
1348
|
-
private _fromLottieVector2ToBabylonVector2;
|
1349
|
-
private _calculateFinalVector;
|
1350
|
-
private _getScaleFactor;
|
1351
|
-
private _validatePathShape;
|
1352
|
-
private _validateRectangleShape;
|
1353
|
-
private _validateFillShape;
|
1354
|
-
private _validateGradientFillShape;
|
1355
|
-
}
|
1356
|
-
|
1357
|
-
|
1358
391
|
/**
|
1359
392
|
* BABYLON.Behavior for any content that can capture pointer events, i.e. bypass the Babylon pointer event handling
|
1360
393
|
* and receive pointer events directly. It will register the capture triggers and negotiate the capture and
|
@@ -1459,6 +492,20 @@ declare module ADDONS {
|
|
1459
492
|
* created before.
|
1460
493
|
*/
|
1461
494
|
export class HtmlMeshRenderer {
|
495
|
+
/**
|
496
|
+
* Global scale factor applied to the homogeneous `w` component (m[15]) of the
|
497
|
+
* transformation matrix when projecting 3D objects into pixel space.
|
498
|
+
*
|
499
|
+
* This value is used to balance Babylon units against screen pixels, ensuring
|
500
|
+
* that HTML-mapped or screen-space objects appear with the correct relative
|
501
|
+
* size. Adjust with care, as changing it affects the projection scale of all
|
502
|
+
* transformed objects.
|
503
|
+
*
|
504
|
+
* The default value is `0.00001`, which works well when 1 Babylon unit
|
505
|
+
* corresponds to 1 meter, and the typical screen resolution is around
|
506
|
+
* 100 pixels per meter (i.e., 1 pixel per centimeter).
|
507
|
+
*/
|
508
|
+
static PROJECTION_SCALE_FACTOR: number;
|
1462
509
|
private _containerId?;
|
1463
510
|
private _inSceneElements?;
|
1464
511
|
private _overlayElements?;
|