babylonjs-addons 8.22.2 → 8.23.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.
@@ -435,704 +435,2691 @@ export type BMFont = {
435
435
  };
436
436
 
437
437
  }
438
- declare module "babylonjs-addons/htmlMesh/pointerEventsCaptureBehavior" {
439
- import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
440
- import { Behavior } from "babylonjs/Behaviors/behavior";
438
+ declare module "babylonjs-addons/lottie/worker" {
439
+ export {};
440
+
441
+ }
442
+ declare module "babylonjs-addons/lottie/lottiePlayer" {
441
443
  /**
442
- * Behavior for any content that can capture pointer events, i.e. bypass the Babylon pointer event handling
443
- * and receive pointer events directly. It will register the capture triggers and negotiate the capture and
444
- * release of pointer events. Curerntly this applies only to HtmlMesh
444
+ * Configuration options for the Lottie animation player.
445
445
  */
446
- export class PointerEventsCaptureBehavior implements Behavior<AbstractMesh> {
447
- private _captureCallback;
448
- private _releaseCallback;
449
- /** gets or sets behavior's name */
450
- name: string;
451
- private _attachedMesh;
452
- /** @internal */
453
- _captureOnPointerEnter: boolean;
446
+ export type AnimationConfiguration = {
454
447
  /**
455
- * Gets or sets the mesh that the behavior is attached to
448
+ * Whether the animation should play on a loop or not
456
449
  */
457
- get attachedMesh(): AbstractMesh | null;
458
- set attachedMesh(value: AbstractMesh | null);
459
- constructor(_captureCallback: () => void, _releaseCallback: () => void, { captureOnPointerEnter }?: {
460
- captureOnPointerEnter?: boolean | undefined;
461
- });
450
+ loopAnimation: boolean;
462
451
  /**
463
- * Set if the behavior should capture pointer events when the pointer enters the mesh
452
+ * Size of the sprite atlas texture.
453
+ * Default is 2048.
464
454
  */
465
- set captureOnPointerEnter(captureOnPointerEnter: boolean);
455
+ spriteAtlasSize: number;
466
456
  /**
467
- * Function called when the behavior needs to be initialized (before attaching it to a target)
457
+ * Gap size around sprites in the atlas.
458
+ * Default is 5.
468
459
  */
469
- init(): void;
460
+ gapSize: number;
470
461
  /**
471
- * Called when the behavior is attached to a target
472
- * @param mesh defines the target where the behavior is attached to
462
+ * Maximum number of sprites the renderer can handle at once.
463
+ * Default is 64.
473
464
  */
474
- attach(mesh: AbstractMesh): void;
465
+ spritesCapacity: number;
475
466
  /**
476
- * Called when the behavior is detached from its target
467
+ * Background color for the animation canvas.
468
+ * Default is white with full opacity.
477
469
  */
478
- detach(): void;
470
+ backgroundColor: {
471
+ r: number;
472
+ g: number;
473
+ b: number;
474
+ a: number;
475
+ };
479
476
  /**
480
- * Dispose the behavior
477
+ * Minimum scale factor to prevent too small sprites.
478
+ * Default is 5.
479
+ */
480
+ scaleMultiplier: number;
481
+ /**
482
+ * Scale factor for the rendering.
483
+ * Default is 1.
484
+ */
485
+ devicePixelRatio: number;
486
+ /**
487
+ * Number of steps to sample cubic bezier easing functions for animations.
488
+ * Default is 4.
489
+ */
490
+ easingSteps: number;
491
+ /**
492
+ * Whether to ignore opacity animations for performance.
493
+ * Default is true.
494
+ */
495
+ ignoreOpacityAnimations: boolean;
496
+ /**
497
+ * Whether to support device lost events for WebGL contexts.
498
+ * Default is false.
499
+ */
500
+ supportDeviceLost: boolean;
501
+ };
502
+ /**
503
+ * LottiePlayer is a class that allows you to play Lottie animations using Babylon.js.
504
+ * It plays the animations in a worker thread using OffscreenCanvas.
505
+ * 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.
506
+ */
507
+ export class LottiePlayer {
508
+ private _playing;
509
+ private _disposed;
510
+ private _worker;
511
+ private _canvas;
512
+ private _resizeObserver;
513
+ private readonly _container;
514
+ private readonly _animationFile;
515
+ private readonly _configuration;
516
+ /**
517
+ * Creates a new instance of the LottiePlayer.
518
+ * @param container The HTMLDivElement to create the canvas in and render the animation on.
519
+ * @param animationFile The URL of the Lottie animation file to be played.
520
+ * @param configuration Optional configuration object to customize the animation playback.
521
+ */
522
+ constructor(container: HTMLDivElement, animationFile: string, configuration?: Partial<AnimationConfiguration>);
523
+ /**
524
+ * Loads and plays a lottie animation.
525
+ * @returns True if the animation is successfully set up to play, false if the animation couldn't play.
526
+ */
527
+ playAnimation(): boolean;
528
+ /**
529
+ * Disposes the LottiePlayer instance, cleaning up resources and event listeners.
481
530
  */
482
531
  dispose(): void;
483
- releasePointerEvents(): void;
484
- capturePointerEvents(): void;
532
+ private _onWindowResize;
533
+ private _onBeforeUnload;
485
534
  }
486
535
 
487
536
  }
488
- declare module "babylonjs-addons/htmlMesh/pointerEventsCapture" {
489
- type CaptureReleaseCallback = () => void;
490
- /**
491
- * Get the id of the object currently capturing pointer events
492
- * @returns The id of the object currently capturing pointer events
493
- * or null if no object is capturing pointer events
494
- */
495
- export const getCapturingId: () => string | null;
496
- /**
497
- * Request that the object with the given id capture pointer events. If there is no current
498
- * owner, then the request is granted immediately. If there is a current owner, then the request
499
- * is queued until the current owner releases pointer events.
500
- * @param requestId An id to identify the request. This id will be used to match the capture
501
- * request with the release request.
502
- * @param captureCallback The callback to call when the request is granted and the object is capturing
503
- * @param releaseCallback The callback to call when the object is no longer capturing pointer events
504
- */
505
- export const requestCapture: (requestId: string, captureCallback: CaptureReleaseCallback, releaseCallback: CaptureReleaseCallback) => void;
537
+ declare module "babylonjs-addons/lottie/index" {
538
+ export { LottiePlayer, AnimationConfiguration } from "babylonjs-addons/lottie/lottiePlayer";
539
+
540
+ }
541
+ declare module "babylonjs-addons/lottie/sprites/spritePacker" {
542
+ import "babylonjs/Engines/Extensions/engine.dynamicTexture";
543
+ import { ThinEngine } from "babylonjs/Engines/thinEngine";
544
+ import { IVector2Like } from "babylonjs/Maths/math.like";
545
+ import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
546
+ import { RawGroupShape } from "babylonjs-addons/lottie/lottie/rawTypes";
547
+ import { AnimationConfiguration } from "babylonjs-addons/lottie/lottiePlayer";
506
548
  /**
507
- * Release pointer events from the object with the given id. If the object is the current owner
508
- * then pointer events are released immediately. If the object is not the current owner, then the
509
- * associated capture request is removed from the queue. If there is no matching capture request
510
- * in the queue, then the release request is added to a list of unmatched release requests and will
511
- * negate the next capture request with the same id. This is to guard against the possibility that
512
- * the release request arrived before the capture request.
513
- * @param requestId The id which should match the id of the capture request
549
+ * Information about a sprite in the sprite atlas.
514
550
  */
515
- export const requestRelease: (requestId: string | null) => void;
551
+ export type SpriteAtlasInfo = {
552
+ /**
553
+ * Offset in the x axis of the sprite in the atlas.
554
+ * Normalized between 0 and 1, left to right.
555
+ */
556
+ uOffset: number;
557
+ /**
558
+ * Offset in the y axis of the sprite in the atlas.
559
+ * Normalized between 0 and 1, top to bottom.
560
+ */
561
+ vOffset: number;
562
+ /**
563
+ * Width of the sprite in the atlas.
564
+ * In pixels.
565
+ */
566
+ cellWidth: number;
567
+ /**
568
+ * Height of the sprite in the atlas.
569
+ * In pixels.
570
+ */
571
+ cellHeight: number;
572
+ /**
573
+ * Width of the sprite in the screen.
574
+ * In pixels.
575
+ */
576
+ widthPx: number;
577
+ /**
578
+ * Height of the sprite in the screen.
579
+ * In pixels.
580
+ */
581
+ heightPx: number;
582
+ /**
583
+ * X coordinate of the center of the sprite bounding box, used for final positioning in the screen
584
+ */
585
+ centerX: number;
586
+ /**
587
+ * Y coordinate of the center of the sprite bounding box, used for final positioning in the screen
588
+ */
589
+ centerY: number;
590
+ };
516
591
  /**
517
- * Release pointer events from the current owner
592
+ * SpritePacker is a class that handles the packing of sprites into a texture atlas.
518
593
  */
519
- export const releaseCurrent: () => void;
520
- global {
521
- interface Window {
522
- "pointer-events-capture-debug": boolean | null;
523
- }
524
- }
525
- export {};
526
-
594
+ export class SpritePacker {
595
+ private readonly _engine;
596
+ private readonly _configuration;
597
+ private _spritesCanvas;
598
+ private _spritesCanvasContext;
599
+ private readonly _spritesInternalTexture;
600
+ private readonly _spritesTexture;
601
+ private _isDirty;
602
+ private _currentX;
603
+ private _currentY;
604
+ private _maxRowHeight;
605
+ private _spriteAtlasInfo;
606
+ /**
607
+ * Gets the texture atlas that contains all the sprites packed by this SpritePacker.
608
+ * @returns The texture atlas containing the sprites.
609
+ */
610
+ get texture(): ThinTexture;
611
+ /**
612
+ * Creates a new instance of SpritePacker.
613
+ * @param engine Engine that will render the sprites.
614
+ * @param configuration Configuration options for the sprite packer.
615
+ */
616
+ constructor(engine: ThinEngine, configuration: AnimationConfiguration);
617
+ /**
618
+ * Adds a vector shape that comes from lottie data to the sprite atlas.
619
+ * @param rawGroup The raw group shape to add to the atlas.
620
+ * @param scalingFactor The scaling factor to apply to the shape.
621
+ * @returns The information on how to find the sprite in the atlas.
622
+ */
623
+ addLottieShape(rawGroup: RawGroupShape, scalingFactor: IVector2Like): SpriteAtlasInfo;
624
+ /**
625
+ * Updates the internal atlas texture with the information that has been added to the SpritePacker.
626
+ */
627
+ updateAtlasTexture(): void;
628
+ /**
629
+ * Releases the canvas and its context to allow garbage collection.
630
+ */
631
+ releaseCanvas(): void;
632
+ private _drawVectorShape;
633
+ private _drawRectangle;
634
+ private _drawPath;
635
+ private _drawFill;
636
+ private _drawGradientFill;
637
+ private _drawLinearGradientFill;
638
+ private _drawRadialGradientFill;
639
+ private _addColorStops;
640
+ private _gradientColorsToCssColor;
641
+ private _lottieColorToCSSColor;
527
642
  }
528
- declare module "babylonjs-addons/htmlMesh/index" {
529
- import { HtmlMeshRenderer } from "babylonjs-addons/htmlMesh/htmlMeshRenderer";
530
- import { HtmlMesh } from "babylonjs-addons/htmlMesh/htmlMesh";
531
- import { PointerEventsCaptureBehavior } from "babylonjs-addons/htmlMesh/pointerEventsCaptureBehavior";
532
- import { FitStrategy } from "babylonjs-addons/htmlMesh/fitStrategy";
533
- export { HtmlMeshRenderer, HtmlMesh, PointerEventsCaptureBehavior, FitStrategy };
534
643
 
535
644
  }
536
- declare module "babylonjs-addons/htmlMesh/htmlMeshRenderer" {
537
- import { Scene } from "babylonjs/scene";
538
- import { Matrix } from "babylonjs/Maths/math";
539
- import { HtmlMesh } from "babylonjs-addons/htmlMesh/htmlMesh";
540
- import { Camera } from "babylonjs/Cameras/camera";
541
- import { SubMesh } from "babylonjs/Meshes/subMesh";
542
- /**
543
- * A function that compares two submeshes and returns a number indicating which
544
- * should be rendered first.
545
- */
546
- type RenderOrderFunction = (subMeshA: SubMesh, subMeshB: SubMesh) => number;
645
+ declare module "babylonjs-addons/lottie/sprites/spriteNode" {
646
+ import { ThinSprite } from "babylonjs/Sprites/thinSprite";
647
+ import { ScalarProperty, Vector2Property } from "babylonjs-addons/lottie/lottie/parsedTypes";
648
+ import { Node } from "babylonjs-addons/lottie/rendering/node";
547
649
  /**
548
- * An instance of this is required to render HtmlMeshes in the scene.
549
- * if using HtmlMeshes, you must not set render order for group 0 using
550
- * scene.setRenderingOrder. You must instead pass the compare functions
551
- * to the HtmlMeshRenderer constructor. If you do not, then your render
552
- * order will be overwritten if the HtmlMeshRenderer is created after and
553
- * the HtmlMeshes will not render correctly (they will appear in front of
554
- * meshes that are actually in front of them) if the HtmlMeshRenderer is
555
- * created before.
650
+ * Represents a sprite in the scene graph.
556
651
  */
557
- export class HtmlMeshRenderer {
558
- private _containerId?;
559
- private _inSceneElements?;
560
- private _overlayElements?;
561
- private _engine;
562
- private _cache;
563
- private _width;
564
- private _height;
565
- private _heightHalf;
566
- private _cameraWorldMatrix?;
567
- private _temp;
568
- private _lastDevicePixelRatio;
569
- private _cameraMatrixUpdated;
570
- private _previousCanvasDocumentPosition;
571
- private _renderObserver;
652
+ export class SpriteNode extends Node {
653
+ private _sprite;
654
+ private _originalWidth;
655
+ private _originalHeight;
656
+ private _firstTime;
572
657
  /**
573
- * Contruct an instance of HtmlMeshRenderer
574
- * @param scene
575
- * @param options object containing the following optional properties:
576
- * @returns
658
+ * Creates a new SpriteNode instance.
659
+ * @param id Unique identifier for the sprite node.
660
+ * @param ignoreOpacityAnimations If there are no animations on opacity, mark this as true to ignore and optimize CPU usage.
661
+ * @param sprite The sprite associated with this node.
662
+ * @param position The position of the sprite in the scene.
663
+ * @param rotation The rotation of the sprite in degrees.
664
+ * @param scale The scale of the sprite in the scene.
665
+ * @param opacity The opacity of the sprite.
666
+ * @param parent The parent node in the scene graph.
577
667
  */
578
- constructor(scene: Scene, { parentContainerId, _containerId, enableOverlayRender, defaultOpaqueRenderOrder, defaultAlphaTestRenderOrder, defaultTransparentRenderOrder, }?: {
579
- parentContainerId?: string | null;
580
- _containerId?: string;
581
- defaultOpaqueRenderOrder?: RenderOrderFunction;
582
- defaultAlphaTestRenderOrder?: RenderOrderFunction;
583
- defaultTransparentRenderOrder?: RenderOrderFunction;
584
- enableOverlayRender?: boolean;
585
- });
668
+ constructor(id: string, ignoreOpacityAnimations: boolean, sprite: ThinSprite, position?: Vector2Property, rotation?: ScalarProperty, scale?: Vector2Property, opacity?: ScalarProperty, parent?: Node);
586
669
  /**
587
- * Dispose of the HtmlMeshRenderer
670
+ * Updates the node's properties based on the current frame of the animation.
671
+ * @param frame Frame number we are playing in the animation.
672
+ * @param isParentUpdated Whether the parent node has been updated.
673
+ * @param isReset Whether the node is being reset.
674
+ * @returns True if the node was updated, false otherwise.
588
675
  */
589
- dispose(): void;
590
- protected _init(scene: Scene, parentContainerId: string | null, enableOverlayRender: boolean, defaultOpaqueRenderOrder: RenderOrderFunction, defaultAlphaTestRenderOrder: RenderOrderFunction, defaultTransparentRenderOrder: RenderOrderFunction): void;
591
- private _createRenderLayerElements;
592
- protected _getSize(): {
593
- width: number;
594
- height: number;
595
- };
596
- protected _setSize(width: number, height: number): void;
597
- protected _getCameraCssMatrix(matrix: Matrix): string;
598
- protected _getHtmlContentCssMatrix(matrix: Matrix, useRightHandedSystem: boolean): string;
599
- protected _getTransformationMatrix(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): Matrix;
600
- protected _renderHtmlMesh(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): void;
601
- protected _render(scene: Scene, camera: Camera): void;
602
- protected _updateBaseScaleFactor(htmlMesh: HtmlMesh): void;
603
- protected _updateContainerPositionIfNeeded(): void;
604
- protected _onCameraMatrixChanged: (camera: Camera) => void;
605
- private _epsilon;
606
- private _getAncestorMarginsAndPadding;
676
+ update(frame: number, isParentUpdated?: boolean, isReset?: boolean): boolean;
607
677
  }
608
- export {};
609
678
 
610
679
  }
611
- declare module "babylonjs-addons/htmlMesh/htmlMesh" {
612
- import { Mesh } from "babylonjs/Meshes/mesh";
613
- import { Scene } from "babylonjs/scene";
614
- import { FitStrategyType } from "babylonjs-addons/htmlMesh/fitStrategy";
680
+ declare module "babylonjs-addons/lottie/rendering/renderingManager" {
681
+ import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
682
+ import "babylonjs/Shaders/sprites.vertex";
683
+ import "babylonjs/Shaders/sprites.fragment";
684
+ import { ThinEngine } from "babylonjs/Engines/thinEngine";
685
+ import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
686
+ import { ThinSprite } from "babylonjs/Sprites/thinSprite";
687
+ import { ThinMatrix } from "babylonjs-addons/lottie/maths/matrix";
688
+ import { AnimationConfiguration } from "babylonjs-addons/lottie/lottiePlayer";
615
689
  /**
616
- * This class represents HTML content that we want to render as though it is part of the scene. The HTML content is actually
617
- * rendered below the canvas, but a depth mask is created by this class that writes to the depth buffer but does not
618
- * write to the color buffer, effectively punching a hole in the canvas. CSS transforms are used to scale, translate, and rotate
619
- * the HTML content so that it matches the camera and mesh orientation. The class supports interactions in editable and non-editable mode.
620
- * In non-editable mode (the default), events are passed to the HTML content when the pointer is over the mask (and not occluded by other meshes
621
- * in the scene).
622
- * @see https://playground.babylonjs.com/#HVHYJC#5
623
- * @see https://playground.babylonjs.com/#B17TC7#112
690
+ * Represents all the sprites from the animation and manages their rendering.
624
691
  */
625
- export class HtmlMesh extends Mesh {
692
+ export class RenderingManager {
693
+ private readonly _engine;
694
+ private readonly _spritesRenderer;
695
+ private readonly _spritesTexture;
696
+ private _sprites;
697
+ private readonly _configuration;
626
698
  /**
627
- * Helps identifying a html mesh from a regular mesh
699
+ * Creates a new instance of the RenderingManager.
700
+ * @param engine ThinEngine instance used for rendering.
701
+ * @param spriteTexture The texture atlas containing the sprites.
702
+ * @param configuration Configuration options for the rendering manager.
628
703
  */
629
- get isHtmlMesh(): boolean;
630
- private _enabled;
631
- private _ready;
704
+ constructor(engine: ThinEngine, spriteTexture: ThinTexture, configuration: AnimationConfiguration);
632
705
  /**
633
- * @internal
706
+ * Adds a sprite to the rendering manager.
707
+ * @param sprite Sprite to add to the rendering manager.
634
708
  */
635
- _isCanvasOverlay: boolean;
636
- private _requiresUpdate;
637
- private _element?;
638
- private _width?;
639
- private _height?;
640
- private _inverseScaleMatrix;
641
- private _captureOnPointerEnter;
642
- private _pointerEventCaptureBehavior;
643
- private _sourceWidth;
644
- private _sourceHeight;
709
+ addSprite(sprite: ThinSprite): void;
645
710
  /**
646
- * Return the source width of the content in pixels
711
+ * Prepares the rendering manager for rendering.
647
712
  */
648
- get sourceWidth(): number | null;
713
+ ready(): void;
649
714
  /**
650
- * Return the source height of the content in pixels
715
+ * Renders all the sprites in the rendering manager.
716
+ * @param worldMatrix World matrix to apply to the sprites.
717
+ * @param projectionMatrix Projection matrix to apply to the sprites.
651
718
  */
652
- get sourceHeight(): number | null;
653
- private _worldMatrixUpdateObserver;
654
- private _fitStrategy;
719
+ render(worldMatrix: ThinMatrix, projectionMatrix: ThinMatrix): void;
655
720
  /**
656
- * Contruct an instance of HtmlMesh
657
- * @param scene
658
- * @param id The id of the mesh. Will be used as the id of the HTML element as well.
659
- * @param options object with optional parameters
721
+ * Disposes the rendering manager and its resources.
660
722
  */
661
- constructor(scene: Scene, id: string, { captureOnPointerEnter, isCanvasOverlay, fitStrategy }?: {
662
- captureOnPointerEnter?: boolean | undefined;
663
- isCanvasOverlay?: boolean | undefined;
664
- fitStrategy?: FitStrategyType | undefined;
665
- });
723
+ dispose(): void;
724
+ private _customSpriteUpdate;
725
+ }
726
+
727
+ }
728
+ declare module "babylonjs-addons/lottie/rendering/node" {
729
+ import { IVector2Like } from "babylonjs/Maths/math.like";
730
+ import { ScalarProperty, Vector2Property } from "babylonjs-addons/lottie/lottie/parsedTypes";
731
+ import { ThinMatrix } from "babylonjs-addons/lottie/maths/matrix";
732
+ /**
733
+ * Represents a node in the scenegraph that contains the animation information from a lottie animation layer or group.
734
+ */
735
+ export class Node {
736
+ private readonly _id;
737
+ private readonly _ignoreOpacityAnimations;
738
+ private readonly _position;
739
+ private readonly _rotation;
740
+ private readonly _scale;
741
+ private _worldMatrix;
742
+ private _localMatrix;
743
+ private _globalMatrix;
744
+ private readonly _opacity;
745
+ private readonly _parent;
746
+ private readonly _children;
747
+ private _isVisible;
748
+ private _isAnimated;
749
+ private _animationsFunctions;
750
+ protected _isControl: boolean;
751
+ protected _isShape: boolean;
666
752
  /**
667
- * The width of the content in pixels
753
+ * Gets the id of this node.
754
+ * @returns The unique identifier of this node.
668
755
  */
669
- get width(): number | undefined;
756
+ get id(): string;
670
757
  /**
671
- * The height of the content in pixels
758
+ * Gets the childer of this node.
759
+ * @returns An array of child nodes.
672
760
  */
673
- get height(): number | undefined;
761
+ get children(): Node[];
674
762
  /**
675
- * The HTML element that is being rendered as a mesh
763
+ * Gets whether this node is a shape.
764
+ * @returns True if this node is a shape, false otherwise.
676
765
  */
677
- get element(): HTMLElement | undefined;
766
+ get isShape(): boolean;
678
767
  /**
679
- * True if the mesh has been moved, rotated, or scaled since the last time this
680
- * property was read. This property is reset to false after reading.
768
+ * Gets the world matrix of this node.
769
+ * @returns The world matrix.
681
770
  */
682
- get requiresUpdate(): boolean;
771
+ get worldMatrix(): ThinMatrix;
683
772
  /**
684
- * Enable capture for the pointer when entering the mesh area
773
+ * Gets whether this node is animated.
774
+ * @returns True if this node has animations, false otherwise.
685
775
  */
686
- set captureOnPointerEnter(captureOnPointerEnter: boolean);
776
+ get isAnimated(): boolean;
687
777
  /**
688
- * Disposes of the mesh and the HTML element
778
+ * Gets the opacity of this node.
779
+ * If the node is not visible, the opacity will be 0.
780
+ * @returns The opacity of the node, from 0 to 1.
689
781
  */
690
- dispose(): void;
782
+ get opacity(): number;
691
783
  /**
692
- * @internal
784
+ * Gets the initial scale of this node.
785
+ * @returns The initial scale.
693
786
  */
694
- _markAsUpdated(): void;
787
+ get startScale(): IVector2Like;
695
788
  /**
696
- * Sets the content of the element to the specified content adjusting the mesh scale to match and making it visible.
697
- * If the the specified content is undefined, then it will make the mesh invisible. In either case it will clear the
698
- * element content first.
699
- * @param element The element to render as a mesh
700
- * @param width The width of the mesh in Babylon units
701
- * @param height The height of the mesh in Babylon units
789
+ * Gets the parent node of this node.
790
+ * @returns The parent node, or undefined if this is a root node.
702
791
  */
703
- setContent(element: HTMLElement, width: number, height: number): void;
704
- setEnabled(enabled: boolean): void;
792
+ get parent(): Node | undefined;
705
793
  /**
706
- * Sets the content size in pixels
707
- * @param width width of the source
708
- * @param height height of the source
794
+ * Sets the node visibility.
795
+ * @param value The new visibility value.
709
796
  */
710
- setContentSizePx(width: number, height: number): void;
711
- protected _setAsReady(ready: boolean): void;
712
- protected _doSetEnabled(enabled: boolean): void;
713
- protected _updateScaleIfNecessary(): void;
714
- protected _createMask(): void;
715
- protected _setElementzIndex(zIndex: number): void;
797
+ set isVisible(value: boolean);
716
798
  /**
717
- * Callback used by the PointerEventsCaptureBehavior to capture pointer events
799
+ * Constructs a new node.
800
+ * @param id Unique identifier for the node.
801
+ * @param ignoreOpacityAnimations If there are no animations on opacity, mark this as true to ignore and optimize CPU usage.
802
+ * @param position Position of the node in the scene.
803
+ * @param rotation Rotation of the node in degrees.
804
+ * @param scale Scale of the node in the scene.
805
+ * @param opacity Opacity of the node, from 0 to 1.
806
+ * @param parent Parent node in the scenegraph.
718
807
  */
719
- capturePointerEvents(): void;
808
+ constructor(id: string, ignoreOpacityAnimations: boolean, position?: Vector2Property, rotation?: ScalarProperty, scale?: Vector2Property, opacity?: ScalarProperty, parent?: Node);
720
809
  /**
721
- * Callback used by the PointerEventsCaptureBehavior to release pointer events
810
+ * Resets the node's properties to their initial values.
722
811
  */
723
- releasePointerEvents(): void;
724
- protected _createElement(): HTMLDivElement | undefined;
812
+ reset(): void;
813
+ /**
814
+ * Updates the node's properties based on the current frame of the animation.
815
+ * @param frame Frame number we are playing in the animation.
816
+ * @param isParentUpdated Whether the parent node has been updated.
817
+ * @param isReset Whether the node is being reset.
818
+ * @returns True if the node was updated, false otherwise.
819
+ */
820
+ update(frame: number, isParentUpdated?: boolean, isReset?: boolean): boolean;
821
+ private _updatePosition;
822
+ private _updateRotation;
823
+ private _updateScale;
824
+ private _updateOpacity;
725
825
  }
726
826
 
727
827
  }
728
- declare module "babylonjs-addons/htmlMesh/fitStrategy" {
729
- export type FitStrategyType = {
730
- wrapElement(element: HTMLElement): HTMLElement;
731
- updateSize(sizingElement: HTMLElement, width: number, height: number): void;
828
+ declare module "babylonjs-addons/lottie/rendering/controlNode" {
829
+ import { ScalarProperty, Vector2Property } from "babylonjs-addons/lottie/lottie/parsedTypes";
830
+ import { Node } from "babylonjs-addons/lottie/rendering/node";
831
+ /**
832
+ * This represents a top node of the scenegraph in a Lottie animation.
833
+ * Each top level layer in Lottie is represented by a control node node.
834
+ */
835
+ export class ControlNode extends Node {
836
+ private _inFrame;
837
+ private _outFrame;
838
+ /**
839
+ * Constructs a new control node.
840
+ * @param id Unique identifier for the node.
841
+ * @param ignoreOpacityAnimations If there are no animations on opacity, mark this as true to ignore and optimize CPU usage.
842
+ * @param inFrame Frame at which the node becomes active.
843
+ * @param outFrame Frame at which the node becomes inactive.
844
+ * @param position Position of the node in the scene.
845
+ * @param rotation Rotation of the node in degrees.
846
+ * @param scale Scale of the node in the scene.
847
+ * @param opacity Opacity of the node, from 0 to 1.
848
+ * @param parent Parent node in the scenegraph.
849
+ */
850
+ constructor(id: string, ignoreOpacityAnimations: boolean, inFrame: number, outFrame: number, position?: Vector2Property, rotation?: ScalarProperty, scale?: Vector2Property, opacity?: ScalarProperty, parent?: Node);
851
+ /**
852
+ * Updates the node's properties based on the current frame of the animation.
853
+ * This node will only be updated if the current frame is within the in and out range.
854
+ * @param frame Frame number we are playing in the animation.
855
+ * @param isParentUpdated Whether the parent node has been updated.
856
+ * @param isReset Whether the node is being reset.
857
+ * @returns True if the node was updated, false otherwise.
858
+ */
859
+ update(frame: number, isParentUpdated?: boolean, isReset?: boolean): boolean;
860
+ }
861
+
862
+ }
863
+ declare module "babylonjs-addons/lottie/rendering/animationController" {
864
+ import "babylonjs/Engines/Extensions/engine.alpha";
865
+ import "babylonjs/Shaders/sprites.vertex";
866
+ import "babylonjs/Shaders/sprites.fragment";
867
+ import { AnimationConfiguration } from "babylonjs-addons/lottie/lottiePlayer";
868
+ /**
869
+ * Class that controls the playing of lottie animations using Babylon.js
870
+ */
871
+ export class AnimationController {
872
+ private _isReady;
873
+ private readonly _canvas;
874
+ private readonly _configuration;
875
+ private readonly _engine;
876
+ private readonly _spritePacker;
877
+ private _animation?;
878
+ private readonly _viewport;
879
+ private readonly _projectionMatrix;
880
+ private readonly _worldMatrix;
881
+ private _frameDuration;
882
+ private _currentFrame;
883
+ private _isPlaying;
884
+ private _animationFrameId;
885
+ private _lastFrameTime;
886
+ private _deltaTime;
887
+ private _loop;
888
+ private _accumulatedTime;
889
+ private _framesToAdvance;
890
+ private readonly _renderingManager;
891
+ /**
892
+ * Gets the canvas used for rendering the animation.
893
+ * @returns The canvas element used for rendering.
894
+ */
895
+ get view(): HTMLCanvasElement;
896
+ /**
897
+ * Gets the height of the animation in pixels.
898
+ * @returns The height of the animation in pixels.
899
+ */
900
+ get animationHeight(): number;
901
+ /**
902
+ * Gets the width of the animation in pixels.
903
+ * @returns The width of the animation in pixels.
904
+ */
905
+ get animationWidth(): number;
906
+ /**
907
+ * Creates a new instance of the Player.
908
+ * @param canvas The canvas element to render the animation on.
909
+ * @param animationJson The JSON string of the Lottie animation to be played.
910
+ * @param configuration The configuration for the animation player.
911
+ */
912
+ constructor(canvas: HTMLCanvasElement, animationJson: string, configuration: AnimationConfiguration);
913
+ /**
914
+ * Plays the animation.
915
+ * @param loop If true, the animation will loop when it reaches the end.
916
+ */
917
+ playAnimation(loop?: boolean): void;
918
+ /**
919
+ * Stops the animation playback.
920
+ */
921
+ stopAnimation(): void;
922
+ /**
923
+ * Sets the rendering size for the engine
924
+ * @param width Width of the rendering canvas
925
+ * @param height Height of the rendering canvas
926
+ */
927
+ setSize(width: number, height: number): void;
928
+ /**
929
+ * Disposes the player and releases all resources.
930
+ */
931
+ dispose(): void;
932
+ private _cleanTree;
933
+ private _startRenderLoop;
934
+ private _render;
935
+ }
936
+
937
+ }
938
+ declare module "babylonjs-addons/lottie/maths/matrix" {
939
+ import { IMatrixLike, IVector2Like } from "babylonjs/Maths/math.like";
940
+ import { Tuple } from "babylonjs/types";
941
+ /**
942
+ * Represents a Babylon.js thin version of a Matrix
943
+ * We are only exposing what we truly need in the scope of
944
+ * the Lottie Renderer project preventing the dependency on the full
945
+ * Babylon.js math system.
946
+ */
947
+ export class ThinMatrix implements IMatrixLike {
948
+ /**
949
+ * Prevents global conflicts on update as shader programs are shared.
950
+ */
951
+ private static _UPDATE_FLAG_SEED;
952
+ /**
953
+ * Current update flag used to know whether a Matrix has changed since previous render or not.
954
+ * This helps identifying if a Matrix needs to be
955
+ * uploaded to a shader program.
956
+ */
957
+ updateFlag: number;
958
+ private readonly _data;
959
+ /**
960
+ * Creates a new ThinMatrix instance.
961
+ */
962
+ constructor();
963
+ /**
964
+ * Set the matrix values.
965
+ * @param m11 Value for row 1, column 1
966
+ * @param m12 Value for row 1, column 2
967
+ * @param m13 Value for row 1, column 3
968
+ * @param m14 Value for row 1, column 4
969
+ * @param m21 Value for row 2, column 1
970
+ * @param m22 Value for row 2, column 2
971
+ * @param m23 Value for row 2, column 3
972
+ * @param m24 Value for row 2, column 4
973
+ * @param m31 Value for row 3, column 1
974
+ * @param m32 Value for row 3, column 2
975
+ * @param m33 Value for row 3, column 3
976
+ * @param m34 Value for row 3, column 4
977
+ * @param m41 Value for row 4, column 1
978
+ * @param m42 Value for row 4, column 2
979
+ * @param m43 Value for row 4, column 3
980
+ * @param m44 Value for row 4, column 4
981
+ * @returns The updated ThinMatrix instance
982
+ */
983
+ 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;
984
+ /**
985
+ * Set the matrix to an identity matrix.
986
+ * @returns The updated ThinMatrix instance
987
+ */
988
+ identity(): ThinMatrix;
989
+ /**
990
+ * Stores a left-handed orthographic projection into a given matrix
991
+ * @param left defines the viewport left coordinate
992
+ * @param right defines the viewport right coordinate
993
+ * @param bottom defines the viewport bottom coordinate
994
+ * @param top defines the viewport top coordinate
995
+ * @param znear defines the near clip plane
996
+ * @param zfar defines the far clip plane
997
+ * @returns The updated ThinMatrix instance
998
+ */
999
+ orthoOffCenterLeftHanded(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): ThinMatrix;
1000
+ /**
1001
+ * Sets a matrix to a value composed by merging scale (vector2), rotation (roll around z) and translation (vector2)
1002
+ * This only updates the parts of the matrix that are used for 2D transformations.
1003
+ * @param scale defines the scale vector
1004
+ * @param roll defines the rotation around z
1005
+ * @param translation defines the translation vector
1006
+ * @returns the updated ThinMatrix instance
1007
+ */
1008
+ compose(scale: IVector2Like, roll: number, translation: IVector2Like): ThinMatrix;
1009
+ /**
1010
+ * Sets the current matrix with the multiplication result of the current Matrix and the given one
1011
+ * This only updates the parts of the matrix that are used for 2D transformations.
1012
+ * @param other defines the second operand
1013
+ * @param output the matrix to store the result in
1014
+ * @returns the current matrix
1015
+ */
1016
+ multiplyToRef(other: ThinMatrix, output: ThinMatrix): ThinMatrix;
1017
+ /**
1018
+ * Returns the matrix data array.
1019
+ * @returns The matrix data
1020
+ */
1021
+ asArray(): Tuple<number, 16>;
1022
+ /**
1023
+ * Decomposes the matrix into scale, rotation, and translation.
1024
+ * @param scale Scale vector to store the scale values
1025
+ * @param translation Translation vector to store the translation values
1026
+ * @returns The rotation in radians
1027
+ */
1028
+ decompose(scale: IVector2Like, translation: IVector2Like): number;
1029
+ }
1030
+
1031
+ }
1032
+ declare module "babylonjs-addons/lottie/maths/boundingBox" {
1033
+ import { RawGroupShape } from "babylonjs-addons/lottie/lottie/rawTypes";
1034
+ /**
1035
+ * Represents a bounding box for a shape in the animation.
1036
+ */
1037
+ export type BoundingBox = {
1038
+ /**
1039
+ * Height of the bounding box
1040
+ */
1041
+ height: number;
1042
+ /**
1043
+ * Width of the bounding box
1044
+ */
1045
+ width: number;
1046
+ /**
1047
+ * X coordinate of the center of the bounding box
1048
+ */
1049
+ centerX: number;
1050
+ /**
1051
+ * Y coordinate of the center of the bounding box
1052
+ */
1053
+ centerY: number;
732
1054
  };
733
- export const FitStrategy: {
734
- CONTAIN: FitStrategyType;
735
- COVER: FitStrategyType;
736
- STRETCH: FitStrategyType;
737
- NONE: FitStrategyType;
1055
+ /**
1056
+ * Calculates the bounding box for a group shape in a Lottie animation.
1057
+ * @param rawGroup The raw group shape to calculate the bounding box for
1058
+ * @returns The bounding box for the group shape
1059
+ */
1060
+ export function GetBoundingBox(rawGroup: RawGroupShape): BoundingBox;
1061
+
1062
+ }
1063
+ declare module "babylonjs-addons/lottie/maths/bezier" {
1064
+ /**
1065
+ * Represents a Babylon.js thin version of a cubic bezier curve
1066
+ * We are only exposing what we truly need in the scope of
1067
+ * the Lottie Renderer project preventing the dependency on the full
1068
+ * Babylon.js animation system.
1069
+ */
1070
+ export class BezierCurve {
1071
+ /**
1072
+ * X of the first control point
1073
+ */
1074
+ readonly x1: number;
1075
+ /**
1076
+ * Y of the first control point
1077
+ */
1078
+ readonly y1: number;
1079
+ /**
1080
+ * X of the second control point
1081
+ */
1082
+ readonly x2: number;
1083
+ /**
1084
+ * Y of the second control point
1085
+ */
1086
+ readonly y2: number;
1087
+ private readonly _easingSteps;
1088
+ private readonly _f0;
1089
+ private readonly _f1;
1090
+ private readonly _f2;
1091
+ /**
1092
+ * Instantiates a bezier function
1093
+ * @see http://cubic-bezier.com/#.17,.67,.83,.67
1094
+ * @param x1 Defines the x component of the start tangent in the bezier curve
1095
+ * @param y1 Defines the y component of the start tangent in the bezier curve
1096
+ * @param x2 Defines the x component of the end tangent in the bezier curve
1097
+ * @param y2 Defines the y component of the end tangent in the bezier curve
1098
+ * @param easingSteps Number of steps to sample the bezier curve for easing
1099
+ */
1100
+ constructor(x1: number | undefined, y1: number | undefined, x2: number | undefined, y2: number | undefined, easingSteps: number);
1101
+ /**
1102
+ * Interpolates the bezier curve at a given time
1103
+ * @param t Defines the time to evaluate the bezier curve at, between 0 and 1
1104
+ * @returns The interpolated value at time t
1105
+ */
1106
+ interpolate(t: number): number;
1107
+ }
1108
+
1109
+ }
1110
+ declare module "babylonjs-addons/lottie/lottie/rawTypes" {
1111
+ export type RawLottieAnimation = {
1112
+ v: string;
1113
+ fr: number;
1114
+ ip: number;
1115
+ op: number;
1116
+ w: number;
1117
+ h: number;
1118
+ nm?: string;
1119
+ layers: RawLottieLayer[];
1120
+ };
1121
+ export type RawLottieLayer = {
1122
+ ind?: number;
1123
+ ty: RawLayerType;
1124
+ nm?: string;
1125
+ parent?: number;
1126
+ hd?: boolean;
1127
+ sr?: number;
1128
+ ao?: number;
1129
+ ip?: number;
1130
+ op?: number;
1131
+ st?: number;
1132
+ ct?: number;
1133
+ ks: RawTransform;
1134
+ shapes?: RawGraphicElement[];
1135
+ };
1136
+ export type RawGraphicElement = {
1137
+ nm?: string;
1138
+ hd?: boolean;
1139
+ ty: RawShapeType;
1140
+ bm?: number;
1141
+ ix?: number;
1142
+ };
1143
+ export type RawGroupShape = RawGraphicElement & {
1144
+ it?: RawGraphicElement[];
1145
+ };
1146
+ export type RawRectangleShape = RawGraphicElement & {
1147
+ d: RawShapeDirection;
1148
+ p: RawPositionProperty;
1149
+ s: RawVectorProperty;
1150
+ r: RawScalarProperty;
1151
+ };
1152
+ export type RawPathShape = RawGraphicElement & {
1153
+ d: RawShapeDirection;
1154
+ ks: RawBezierShapeProperty;
1155
+ };
1156
+ export type RawFillShape = RawGraphicElement & {
1157
+ o: RawScalarProperty;
1158
+ c: RawColorProperty;
1159
+ r: RawFillRule;
1160
+ };
1161
+ export type RawGradientFillShape = RawGraphicElement & {
1162
+ o: RawScalarProperty;
1163
+ g: RawGradientsProperty;
1164
+ s: RawPositionProperty;
1165
+ e: RawPositionProperty;
1166
+ t: RawGradientType;
1167
+ h: RawScalarProperty;
1168
+ a?: RawScalarProperty;
1169
+ r: RawFillRule;
738
1170
  };
1171
+ export type RawTransformShape = RawGraphicElement & {
1172
+ a: RawPositionProperty;
1173
+ p: RawPositionProperty;
1174
+ r: RawScalarProperty;
1175
+ s: RawVectorProperty;
1176
+ o: RawScalarProperty;
1177
+ sk: RawScalarProperty;
1178
+ sa: RawScalarProperty;
1179
+ };
1180
+ export type RawTransform = {
1181
+ a?: RawPositionProperty;
1182
+ p?: RawPositionProperty;
1183
+ r?: RawScalarProperty;
1184
+ s?: RawVectorProperty;
1185
+ o?: RawScalarProperty;
1186
+ };
1187
+ export type RawScalarProperty = {
1188
+ a: RawNumberBoolean;
1189
+ k: number | RawVectorKeyframe[];
1190
+ };
1191
+ export type RawVectorProperty = {
1192
+ a: RawNumberBoolean;
1193
+ k: number[] | RawVectorKeyframe[];
1194
+ l: number;
1195
+ };
1196
+ export type RawVectorKeyframe = {
1197
+ t: number;
1198
+ s: number[];
1199
+ h?: RawNumberBoolean;
1200
+ i?: RawKeyFrameEasing;
1201
+ o?: RawKeyFrameEasing;
1202
+ };
1203
+ export type RawPositionProperty = {
1204
+ a: RawNumberBoolean;
1205
+ k: number[] | RawPositionKeyframe[];
1206
+ l: number;
1207
+ };
1208
+ export type RawPositionKeyframe = {
1209
+ t: number;
1210
+ h?: RawNumberBoolean;
1211
+ i?: RawKeyFrameEasing;
1212
+ o?: RawKeyFrameEasing;
1213
+ s: number[];
1214
+ ti: number[];
1215
+ to: number[];
1216
+ };
1217
+ export type RawBezierShapeProperty = {
1218
+ a: RawNumberBoolean;
1219
+ k: RawBezier | RawBezierShapeKeyframe[];
1220
+ };
1221
+ export type RawBezierShapeKeyframe = {
1222
+ t: number;
1223
+ h?: RawNumberBoolean;
1224
+ i?: RawKeyFrameEasing;
1225
+ o?: RawKeyFrameEasing;
1226
+ s: RawBezier[];
1227
+ };
1228
+ export type RawColorProperty = {
1229
+ a: RawNumberBoolean;
1230
+ k: number[] | RawColorKeyframe[];
1231
+ };
1232
+ export type RawColorKeyframe = {
1233
+ t: number;
1234
+ h?: RawNumberBoolean;
1235
+ i?: RawKeyFrameEasing;
1236
+ o?: RawKeyFrameEasing;
1237
+ s: number[];
1238
+ };
1239
+ export type RawGradientsProperty = {
1240
+ p: number;
1241
+ k: RawGradientProperty;
1242
+ };
1243
+ export type RawGradientProperty = {
1244
+ a: RawNumberBoolean;
1245
+ k: number[];
1246
+ };
1247
+ export type RawKeyFrameEasing = {
1248
+ x: number | number[];
1249
+ y: number | number[];
1250
+ };
1251
+ export type RawBezier = {
1252
+ c: boolean;
1253
+ i: number[][];
1254
+ o: number[][];
1255
+ v: number[][];
1256
+ };
1257
+ export type RawNumberBoolean = 0 | 1;
1258
+ export type RawLayerType = 0 | 1 | 2 | 3 | 4 | 5 | 6;
1259
+ export type RawShapeType = "fl" | "gf" | "gr" | "tr" | "sh" | "rc";
1260
+ export type RawShapeDirection = 1 | 3;
1261
+ export type RawFillRule = 1 | 2;
1262
+ export type RawGradientType = 1 | 2;
1263
+
1264
+ }
1265
+ declare module "babylonjs-addons/lottie/lottie/parsedTypes" {
1266
+ import { IVector2Like } from "babylonjs/Maths/math.like";
1267
+ import { BezierCurve } from "babylonjs-addons/lottie/maths/bezier";
1268
+ import { Node } from "babylonjs-addons/lottie/rendering/node";
1269
+ /**
1270
+ * Represents a Babylon.js thin version of a Lottie animation.
1271
+ */
1272
+ export type AnimationInfo = {
1273
+ /**
1274
+ * Frame number where the animation starts.
1275
+ */
1276
+ startFrame: number;
1277
+ /**
1278
+ * Frame number where the animation ends.
1279
+ */
1280
+ endFrame: number;
1281
+ /**
1282
+ * Frame rate of the animation.
1283
+ */
1284
+ frameRate: number;
1285
+ /**
1286
+ * Width of the animation in pixels
1287
+ */
1288
+ widthPx: number;
1289
+ /**
1290
+ * Height of the animation in pixels
1291
+ */
1292
+ heightPx: number;
1293
+ /**
1294
+ * Nodes representing the animation
1295
+ */
1296
+ nodes: Node[];
1297
+ };
1298
+ /**
1299
+ * Transform properties for a Lottie animation.
1300
+ * Any of these properties may be animated.
1301
+ */
1302
+ export type Transform = {
1303
+ /**
1304
+ * The anchor point of the layer, which is the point around which transformations are applied.
1305
+ */
1306
+ anchorPoint: Vector2Property;
1307
+ /**
1308
+ * The position of the layer in the animation.
1309
+ */
1310
+ position: Vector2Property;
1311
+ /**
1312
+ * The rotation of the layer in degrees.
1313
+ */
1314
+ rotation: ScalarProperty;
1315
+ /**
1316
+ * The scale of the layer in the X and Y axis.
1317
+ */
1318
+ scale: Vector2Property;
1319
+ /**
1320
+ * The opacity of the layer, represented as a scalar value.
1321
+ */
1322
+ opacity: ScalarProperty;
1323
+ };
1324
+ /**
1325
+ * Represents a scalar that can be animated.
1326
+ */
1327
+ export type ScalarProperty = {
1328
+ /**
1329
+ * The initial value of the property at the start of the animation.
1330
+ */
1331
+ startValue: number;
1332
+ /**
1333
+ * The current value of the property during the animation.
1334
+ */
1335
+ currentValue: number;
1336
+ /**
1337
+ * An array of keyframes for the property.
1338
+ */
1339
+ keyframes?: ScalarKeyframe[];
1340
+ /**
1341
+ * The index of the current keyframe being processed in the animation.
1342
+ */
1343
+ currentKeyframeIndex: number;
1344
+ };
1345
+ /**
1346
+ * Represents a keyframe for a scalar property.
1347
+ */
1348
+ export type ScalarKeyframe = {
1349
+ /**
1350
+ * The value at this keyframe.
1351
+ */
1352
+ value: number;
1353
+ /**
1354
+ * The time at which this keyframe occurs in the animation, in frames.
1355
+ */
1356
+ time: number;
1357
+ /**
1358
+ * The easing function applied to the transition from this keyframe to the next one.
1359
+ */
1360
+ easeFunction: BezierCurve;
1361
+ };
1362
+ /**
1363
+ * Represents a 2D vector that can be animated.
1364
+ */
1365
+ export type Vector2Property = {
1366
+ /**
1367
+ * The initial value at the start of the animation.
1368
+ */
1369
+ startValue: IVector2Like;
1370
+ /**
1371
+ * The current value during the animation.
1372
+ */
1373
+ currentValue: IVector2Like;
1374
+ /**
1375
+ * An array of keyframes for the property.
1376
+ */
1377
+ keyframes?: Vector2Keyframe[];
1378
+ /**
1379
+ * The index of the current keyframe being processed in the animation.
1380
+ */
1381
+ currentKeyframeIndex: number;
1382
+ };
1383
+ /**
1384
+ * Represents a keyframe for a 2D vector property.
1385
+ */
1386
+ export type Vector2Keyframe = {
1387
+ /**
1388
+ * The value at this keyframe.
1389
+ */
1390
+ value: IVector2Like;
1391
+ /**
1392
+ * The time at which this keyframe occurs in the animation, in frames.
1393
+ */
1394
+ time: number;
1395
+ /**
1396
+ * The easing function applied to the transition from this keyframe to the next one.
1397
+ * This is used for the first dimension of the vector.
1398
+ */
1399
+ easeFunction1: BezierCurve;
1400
+ /**
1401
+ * The easing function applied to the transition from this keyframe to the next one.
1402
+ * This is used for the second dimension of the vector.
1403
+ */
1404
+ easeFunction2: BezierCurve;
1405
+ };
1406
+
1407
+ }
1408
+ declare module "babylonjs-addons/lottie/lottie/animationParser" {
1409
+ import { AnimationInfo } from "babylonjs-addons/lottie/lottie/parsedTypes";
1410
+ import { SpritePacker } from "babylonjs-addons/lottie/sprites/spritePacker";
1411
+ import { RenderingManager } from "babylonjs-addons/lottie/rendering/renderingManager";
1412
+ import { AnimationConfiguration } from "babylonjs-addons/lottie/lottiePlayer";
1413
+ /**
1414
+ * Parses a lottie animation file and converts it into a format that can be rendered by Babylon.js
1415
+ * Important: not all lottie features are supported, you can call .debug() after parsing an animation to see what features were not supported.
1416
+ */
1417
+ export class AnimationParser {
1418
+ private _packer;
1419
+ private readonly _renderingManager;
1420
+ private readonly _configuration;
1421
+ private readonly _animationInfo;
1422
+ private _unsupportedFeatures;
1423
+ private _parentNodes;
1424
+ private _rootNodes;
1425
+ private _shape;
1426
+ /**
1427
+ * Get the animation information parsed from the Lottie file.
1428
+ */
1429
+ get animationInfo(): AnimationInfo;
1430
+ /**
1431
+ * Creates a new instance of the Lottie animations parser.
1432
+ * @param packer Object that packs the sprites from the animation into a texture atlas.
1433
+ * @param fileContentAsJsonString The content of the lottie file as a JSON string.
1434
+ * @param configuration Configuration options for the animation parser.
1435
+ * @param renderingManager Object that manages the rendering of the sprites in the animation.
1436
+ */
1437
+ constructor(packer: SpritePacker, fileContentAsJsonString: string, configuration: AnimationConfiguration, renderingManager: RenderingManager);
1438
+ /**
1439
+ * Logs to the console all issues that were encountered during parsing the file.
1440
+ */
1441
+ debug(): void;
1442
+ private _loadFromData;
1443
+ private _parseLayer;
1444
+ private _parseShapes;
1445
+ private _parseGroupShape;
1446
+ private _parseTransform;
1447
+ private _fromLottieScalarToBabylonScalar;
1448
+ private _fromLottieVector2ToBabylonVector2;
1449
+ private _calculateFinalVector;
1450
+ private _getScaleFactor;
1451
+ private _validatePathShape;
1452
+ private _validateRectangleShape;
1453
+ private _validateFillShape;
1454
+ private _validateGradientFillShape;
1455
+ }
1456
+
1457
+ }
1458
+ declare module "babylonjs-addons/htmlMesh/pointerEventsCaptureBehavior" {
1459
+ import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
1460
+ import { Behavior } from "babylonjs/Behaviors/behavior";
1461
+ /**
1462
+ * Behavior for any content that can capture pointer events, i.e. bypass the Babylon pointer event handling
1463
+ * and receive pointer events directly. It will register the capture triggers and negotiate the capture and
1464
+ * release of pointer events. Curerntly this applies only to HtmlMesh
1465
+ */
1466
+ export class PointerEventsCaptureBehavior implements Behavior<AbstractMesh> {
1467
+ private _captureCallback;
1468
+ private _releaseCallback;
1469
+ /** gets or sets behavior's name */
1470
+ name: string;
1471
+ private _attachedMesh;
1472
+ /** @internal */
1473
+ _captureOnPointerEnter: boolean;
1474
+ /**
1475
+ * Gets or sets the mesh that the behavior is attached to
1476
+ */
1477
+ get attachedMesh(): AbstractMesh | null;
1478
+ set attachedMesh(value: AbstractMesh | null);
1479
+ constructor(_captureCallback: () => void, _releaseCallback: () => void, { captureOnPointerEnter }?: {
1480
+ captureOnPointerEnter?: boolean | undefined;
1481
+ });
1482
+ /**
1483
+ * Set if the behavior should capture pointer events when the pointer enters the mesh
1484
+ */
1485
+ set captureOnPointerEnter(captureOnPointerEnter: boolean);
1486
+ /**
1487
+ * Function called when the behavior needs to be initialized (before attaching it to a target)
1488
+ */
1489
+ init(): void;
1490
+ /**
1491
+ * Called when the behavior is attached to a target
1492
+ * @param mesh defines the target where the behavior is attached to
1493
+ */
1494
+ attach(mesh: AbstractMesh): void;
1495
+ /**
1496
+ * Called when the behavior is detached from its target
1497
+ */
1498
+ detach(): void;
1499
+ /**
1500
+ * Dispose the behavior
1501
+ */
1502
+ dispose(): void;
1503
+ releasePointerEvents(): void;
1504
+ capturePointerEvents(): void;
1505
+ }
1506
+
1507
+ }
1508
+ declare module "babylonjs-addons/htmlMesh/pointerEventsCapture" {
1509
+ type CaptureReleaseCallback = () => void;
1510
+ /**
1511
+ * Get the id of the object currently capturing pointer events
1512
+ * @returns The id of the object currently capturing pointer events
1513
+ * or null if no object is capturing pointer events
1514
+ */
1515
+ export const getCapturingId: () => string | null;
1516
+ /**
1517
+ * Request that the object with the given id capture pointer events. If there is no current
1518
+ * owner, then the request is granted immediately. If there is a current owner, then the request
1519
+ * is queued until the current owner releases pointer events.
1520
+ * @param requestId An id to identify the request. This id will be used to match the capture
1521
+ * request with the release request.
1522
+ * @param captureCallback The callback to call when the request is granted and the object is capturing
1523
+ * @param releaseCallback The callback to call when the object is no longer capturing pointer events
1524
+ */
1525
+ export const requestCapture: (requestId: string, captureCallback: CaptureReleaseCallback, releaseCallback: CaptureReleaseCallback) => void;
1526
+ /**
1527
+ * Release pointer events from the object with the given id. If the object is the current owner
1528
+ * then pointer events are released immediately. If the object is not the current owner, then the
1529
+ * associated capture request is removed from the queue. If there is no matching capture request
1530
+ * in the queue, then the release request is added to a list of unmatched release requests and will
1531
+ * negate the next capture request with the same id. This is to guard against the possibility that
1532
+ * the release request arrived before the capture request.
1533
+ * @param requestId The id which should match the id of the capture request
1534
+ */
1535
+ export const requestRelease: (requestId: string | null) => void;
1536
+ /**
1537
+ * Release pointer events from the current owner
1538
+ */
1539
+ export const releaseCurrent: () => void;
1540
+ global {
1541
+ interface Window {
1542
+ "pointer-events-capture-debug": boolean | null;
1543
+ }
1544
+ }
1545
+ export {};
1546
+
1547
+ }
1548
+ declare module "babylonjs-addons/htmlMesh/index" {
1549
+ import { HtmlMeshRenderer } from "babylonjs-addons/htmlMesh/htmlMeshRenderer";
1550
+ import { HtmlMesh } from "babylonjs-addons/htmlMesh/htmlMesh";
1551
+ import { PointerEventsCaptureBehavior } from "babylonjs-addons/htmlMesh/pointerEventsCaptureBehavior";
1552
+ import { FitStrategy } from "babylonjs-addons/htmlMesh/fitStrategy";
1553
+ export { HtmlMeshRenderer, HtmlMesh, PointerEventsCaptureBehavior, FitStrategy };
1554
+
1555
+ }
1556
+ declare module "babylonjs-addons/htmlMesh/htmlMeshRenderer" {
1557
+ import { Scene } from "babylonjs/scene";
1558
+ import { Matrix } from "babylonjs/Maths/math";
1559
+ import { HtmlMesh } from "babylonjs-addons/htmlMesh/htmlMesh";
1560
+ import { Camera } from "babylonjs/Cameras/camera";
1561
+ import { SubMesh } from "babylonjs/Meshes/subMesh";
1562
+ /**
1563
+ * A function that compares two submeshes and returns a number indicating which
1564
+ * should be rendered first.
1565
+ */
1566
+ type RenderOrderFunction = (subMeshA: SubMesh, subMeshB: SubMesh) => number;
1567
+ /**
1568
+ * An instance of this is required to render HtmlMeshes in the scene.
1569
+ * if using HtmlMeshes, you must not set render order for group 0 using
1570
+ * scene.setRenderingOrder. You must instead pass the compare functions
1571
+ * to the HtmlMeshRenderer constructor. If you do not, then your render
1572
+ * order will be overwritten if the HtmlMeshRenderer is created after and
1573
+ * the HtmlMeshes will not render correctly (they will appear in front of
1574
+ * meshes that are actually in front of them) if the HtmlMeshRenderer is
1575
+ * created before.
1576
+ */
1577
+ export class HtmlMeshRenderer {
1578
+ private _containerId?;
1579
+ private _inSceneElements?;
1580
+ private _overlayElements?;
1581
+ private _engine;
1582
+ private _cache;
1583
+ private _width;
1584
+ private _height;
1585
+ private _heightHalf;
1586
+ private _cameraWorldMatrix?;
1587
+ private _temp;
1588
+ private _lastDevicePixelRatio;
1589
+ private _cameraMatrixUpdated;
1590
+ private _previousCanvasDocumentPosition;
1591
+ private _renderObserver;
1592
+ /**
1593
+ * Contruct an instance of HtmlMeshRenderer
1594
+ * @param scene
1595
+ * @param options object containing the following optional properties:
1596
+ * @returns
1597
+ */
1598
+ constructor(scene: Scene, { parentContainerId, _containerId, enableOverlayRender, defaultOpaqueRenderOrder, defaultAlphaTestRenderOrder, defaultTransparentRenderOrder, }?: {
1599
+ parentContainerId?: string | null;
1600
+ _containerId?: string;
1601
+ defaultOpaqueRenderOrder?: RenderOrderFunction;
1602
+ defaultAlphaTestRenderOrder?: RenderOrderFunction;
1603
+ defaultTransparentRenderOrder?: RenderOrderFunction;
1604
+ enableOverlayRender?: boolean;
1605
+ });
1606
+ /**
1607
+ * Dispose of the HtmlMeshRenderer
1608
+ */
1609
+ dispose(): void;
1610
+ protected _init(scene: Scene, parentContainerId: string | null, enableOverlayRender: boolean, defaultOpaqueRenderOrder: RenderOrderFunction, defaultAlphaTestRenderOrder: RenderOrderFunction, defaultTransparentRenderOrder: RenderOrderFunction): void;
1611
+ private _createRenderLayerElements;
1612
+ protected _getSize(): {
1613
+ width: number;
1614
+ height: number;
1615
+ };
1616
+ protected _setSize(width: number, height: number): void;
1617
+ protected _getCameraCssMatrix(matrix: Matrix): string;
1618
+ protected _getHtmlContentCssMatrix(matrix: Matrix, useRightHandedSystem: boolean): string;
1619
+ protected _getTransformationMatrix(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): Matrix;
1620
+ protected _renderHtmlMesh(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): void;
1621
+ protected _render(scene: Scene, camera: Camera): void;
1622
+ protected _updateBaseScaleFactor(htmlMesh: HtmlMesh): void;
1623
+ protected _updateContainerPositionIfNeeded(): void;
1624
+ protected _onCameraMatrixChanged: (camera: Camera) => void;
1625
+ private _epsilon;
1626
+ private _getAncestorMarginsAndPadding;
1627
+ }
1628
+ export {};
1629
+
1630
+ }
1631
+ declare module "babylonjs-addons/htmlMesh/htmlMesh" {
1632
+ import { Mesh } from "babylonjs/Meshes/mesh";
1633
+ import { Scene } from "babylonjs/scene";
1634
+ import { FitStrategyType } from "babylonjs-addons/htmlMesh/fitStrategy";
1635
+ /**
1636
+ * This class represents HTML content that we want to render as though it is part of the scene. The HTML content is actually
1637
+ * rendered below the canvas, but a depth mask is created by this class that writes to the depth buffer but does not
1638
+ * write to the color buffer, effectively punching a hole in the canvas. CSS transforms are used to scale, translate, and rotate
1639
+ * the HTML content so that it matches the camera and mesh orientation. The class supports interactions in editable and non-editable mode.
1640
+ * In non-editable mode (the default), events are passed to the HTML content when the pointer is over the mask (and not occluded by other meshes
1641
+ * in the scene).
1642
+ * @see https://playground.babylonjs.com/#HVHYJC#5
1643
+ * @see https://playground.babylonjs.com/#B17TC7#112
1644
+ */
1645
+ export class HtmlMesh extends Mesh {
1646
+ /**
1647
+ * Helps identifying a html mesh from a regular mesh
1648
+ */
1649
+ get isHtmlMesh(): boolean;
1650
+ private _enabled;
1651
+ private _ready;
1652
+ /**
1653
+ * @internal
1654
+ */
1655
+ _isCanvasOverlay: boolean;
1656
+ private _requiresUpdate;
1657
+ private _element?;
1658
+ private _width?;
1659
+ private _height?;
1660
+ private _inverseScaleMatrix;
1661
+ private _captureOnPointerEnter;
1662
+ private _pointerEventCaptureBehavior;
1663
+ private _sourceWidth;
1664
+ private _sourceHeight;
1665
+ /**
1666
+ * Return the source width of the content in pixels
1667
+ */
1668
+ get sourceWidth(): number | null;
1669
+ /**
1670
+ * Return the source height of the content in pixels
1671
+ */
1672
+ get sourceHeight(): number | null;
1673
+ private _worldMatrixUpdateObserver;
1674
+ private _fitStrategy;
1675
+ /**
1676
+ * Contruct an instance of HtmlMesh
1677
+ * @param scene
1678
+ * @param id The id of the mesh. Will be used as the id of the HTML element as well.
1679
+ * @param options object with optional parameters
1680
+ */
1681
+ constructor(scene: Scene, id: string, { captureOnPointerEnter, isCanvasOverlay, fitStrategy }?: {
1682
+ captureOnPointerEnter?: boolean | undefined;
1683
+ isCanvasOverlay?: boolean | undefined;
1684
+ fitStrategy?: FitStrategyType | undefined;
1685
+ });
1686
+ /**
1687
+ * The width of the content in pixels
1688
+ */
1689
+ get width(): number | undefined;
1690
+ /**
1691
+ * The height of the content in pixels
1692
+ */
1693
+ get height(): number | undefined;
1694
+ /**
1695
+ * The HTML element that is being rendered as a mesh
1696
+ */
1697
+ get element(): HTMLElement | undefined;
1698
+ /**
1699
+ * True if the mesh has been moved, rotated, or scaled since the last time this
1700
+ * property was read. This property is reset to false after reading.
1701
+ */
1702
+ get requiresUpdate(): boolean;
1703
+ /**
1704
+ * Enable capture for the pointer when entering the mesh area
1705
+ */
1706
+ set captureOnPointerEnter(captureOnPointerEnter: boolean);
1707
+ /**
1708
+ * Disposes of the mesh and the HTML element
1709
+ */
1710
+ dispose(): void;
1711
+ /**
1712
+ * @internal
1713
+ */
1714
+ _markAsUpdated(): void;
1715
+ /**
1716
+ * Sets the content of the element to the specified content adjusting the mesh scale to match and making it visible.
1717
+ * If the the specified content is undefined, then it will make the mesh invisible. In either case it will clear the
1718
+ * element content first.
1719
+ * @param element The element to render as a mesh
1720
+ * @param width The width of the mesh in Babylon units
1721
+ * @param height The height of the mesh in Babylon units
1722
+ */
1723
+ setContent(element: HTMLElement, width: number, height: number): void;
1724
+ setEnabled(enabled: boolean): void;
1725
+ /**
1726
+ * Sets the content size in pixels
1727
+ * @param width width of the source
1728
+ * @param height height of the source
1729
+ */
1730
+ setContentSizePx(width: number, height: number): void;
1731
+ protected _setAsReady(ready: boolean): void;
1732
+ protected _doSetEnabled(enabled: boolean): void;
1733
+ protected _updateScaleIfNecessary(): void;
1734
+ protected _createMask(): void;
1735
+ protected _setElementzIndex(zIndex: number): void;
1736
+ /**
1737
+ * Callback used by the PointerEventsCaptureBehavior to capture pointer events
1738
+ */
1739
+ capturePointerEvents(): void;
1740
+ /**
1741
+ * Callback used by the PointerEventsCaptureBehavior to release pointer events
1742
+ */
1743
+ releasePointerEvents(): void;
1744
+ protected _createElement(): HTMLDivElement | undefined;
1745
+ }
1746
+
1747
+ }
1748
+ declare module "babylonjs-addons/htmlMesh/fitStrategy" {
1749
+ export type FitStrategyType = {
1750
+ wrapElement(element: HTMLElement): HTMLElement;
1751
+ updateSize(sizingElement: HTMLElement, width: number, height: number): void;
1752
+ };
1753
+ export const FitStrategy: {
1754
+ CONTAIN: FitStrategyType;
1755
+ COVER: FitStrategyType;
1756
+ STRETCH: FitStrategyType;
1757
+ NONE: FitStrategyType;
1758
+ };
1759
+
1760
+ }
1761
+
1762
+ declare module "babylonjs-addons" {
1763
+ export * from "babylonjs-addons/index";
1764
+ }
1765
+
1766
+
1767
+ declare module ADDONS {
1768
+
1769
+
1770
+ /**
1771
+ * Abstract Node class from Babylon.js
1772
+ */
1773
+ export interface INodeLike {
1774
+ getWorldMatrix(): BABYLON.IMatrixLike;
1775
+ }
1776
+ /**
1777
+ * Class used to render text using MSDF (Multi-channel Signed Distance Field) technique
1778
+ * Thanks a lot to the work of Bhushan_Wagh and zb_sj for their amazing work on MSDF for Babylon.js
1779
+ * #6RLCWP#16
1780
+ * Star wars scroller: #6RLCWP#29
1781
+ * With metrics: #6RLCWP#35
1782
+ * Thickness: #IABMEZ#3
1783
+ * Solar system: #9YCDYC#9
1784
+ * Stroke: #6RLCWP#37
1785
+ */
1786
+ export class TextRenderer implements BABYLON.IDisposable {
1787
+ private readonly _useVAO;
1788
+ private _engine;
1789
+ private _shaderLanguage;
1790
+ private _vertexBuffers;
1791
+ private _spriteBuffer;
1792
+ private _worldBuffer;
1793
+ private _uvBuffer;
1794
+ private _drawWrapperBase;
1795
+ private _vertexArrayObject;
1796
+ private _font;
1797
+ private _charMatrices;
1798
+ private _charUvs;
1799
+ private _isDirty;
1800
+ private _baseLine;
1801
+ private _scalingMatrix;
1802
+ private _fontScaleMatrix;
1803
+ private _offsetMatrix;
1804
+ private _translationMatrix;
1805
+ private _baseMatrix;
1806
+ private _scaledMatrix;
1807
+ private _localMatrix;
1808
+ private _finalMatrix;
1809
+ private _lineMatrix;
1810
+ private _parentWorldMatrix;
1811
+ /**
1812
+ * Gets or sets the color of the text
1813
+ */
1814
+ color: BABYLON.IColor4Like;
1815
+ /**
1816
+ * Gets or sets the color of the stroke around the text
1817
+ */
1818
+ strokeColor: BABYLON.IColor4Like;
1819
+ /**
1820
+ * Gets or sets the width of the stroke around the text (inset)
1821
+ */
1822
+ strokeInsetWidth: number;
1823
+ /**
1824
+ * Gets or sets the width of the stroke around the text (outset)
1825
+ */
1826
+ strokeOutsetWidth: number;
1827
+ /**
1828
+ * Gets or sets the thickness of the text (0 means as defined in the font)
1829
+ * Value must be between -0.5 and 0.5
1830
+ */
1831
+ thicknessControl: number;
1832
+ private _parent;
1833
+ /**
1834
+ * Gets or sets the parent of the text renderer
1835
+ */
1836
+ get parent(): BABYLON.Nullable<INodeLike>;
1837
+ set parent(value: BABYLON.Nullable<INodeLike>);
1838
+ private _transformMatrix;
1839
+ /**
1840
+ * Gets or sets the transform matrix of the text renderer
1841
+ * It will be applied in that order:
1842
+ * parent x transform x paragraph world
1843
+ */
1844
+ get transformMatrix(): BABYLON.IMatrixLike;
1845
+ set transformMatrix(value: BABYLON.IMatrixLike);
1846
+ /**
1847
+ * Gets or sets if the text is billboarded
1848
+ */
1849
+ isBillboard: boolean;
1850
+ /**
1851
+ * Gets or sets if the text is screen projected
1852
+ * This will work only if the text is billboarded
1853
+ */
1854
+ isBillboardScreenProjected: boolean;
1855
+ /**
1856
+ * Gets the number of characters in the text renderer
1857
+ */
1858
+ get characterCount(): number;
1859
+ /**
1860
+ * Gets or sets if the text renderer should ignore the depth buffer
1861
+ * Default is false
1862
+ */
1863
+ ignoreDepthBuffer: boolean;
1864
+ private constructor();
1865
+ private _resizeBuffers;
1866
+ private _setShaders;
1867
+ /**
1868
+ * Add a paragraph of text to the renderer
1869
+ * @param text define the text to add
1870
+ * @param options define the options to use for the paragraph (optional)
1871
+ * @param worldMatrix define the world matrix to use for the paragraph (optional)
1872
+ */
1873
+ addParagraph(text: string, options?: Partial<ParagraphOptions>, worldMatrix?: BABYLON.IMatrixLike): void;
1874
+ /**
1875
+ * Render the text using the provided view and projection matrices
1876
+ * @param viewMatrix define the view matrix to use
1877
+ * @param projectionMatrix define the projection matrix to use
1878
+ */
1879
+ render(viewMatrix: BABYLON.IMatrixLike, projectionMatrix: BABYLON.IMatrixLike): void;
1880
+ /**
1881
+ * Release associated resources
1882
+ */
1883
+ dispose(): void;
1884
+ /**
1885
+ * Creates a new TextRenderer instance asynchronously
1886
+ * @param font define the font asset to use
1887
+ * @param engine define the engine to use
1888
+ * @returns a promise that resolves to the created TextRenderer instance
1889
+ */
1890
+ static CreateTextRendererAsync(font: FontAsset, engine: BABYLON.AbstractEngine): Promise<TextRenderer>;
1891
+ }
1892
+
1893
+
1894
+ /** @internal */
1895
+ export type ParagraphOptions = {
1896
+ maxWidth: number;
1897
+ lineHeight: number;
1898
+ letterSpacing: number;
1899
+ tabSize: number;
1900
+ whiteSpace: "pre-line";
1901
+ textAlign: "left" | "right" | "center";
1902
+ translate: BABYLON.IVector2Like | undefined;
1903
+ };
1904
+ /** @internal */
1905
+ export var DefaultParagraphOptions: ParagraphOptions;
1906
+
1907
+
1908
+
1909
+
1910
+ /**
1911
+ * Class representing a font asset for SDF (Signed Distance Field) rendering.
1912
+ */
1913
+ export class FontAsset implements BABYLON.IDisposable {
1914
+ private readonly _chars;
1915
+ private readonly _charsRegex;
1916
+ private readonly _kernings;
1917
+ /** @internal */
1918
+ readonly _font: SdfFont;
1919
+ /**
1920
+ * Gets the font scale value
1921
+ */
1922
+ readonly scale: number;
1923
+ /**
1924
+ * Gets the list of used textures
1925
+ */
1926
+ readonly textures: BABYLON.Texture[];
1927
+ /**
1928
+ * Creates a new FontAsset instance.
1929
+ * @param definitionData defines the font data in JSON format.
1930
+ * @param textureUrl defines the url of the texture to use for the font.
1931
+ * @param scene defines the hosting scene.
1932
+ */
1933
+ constructor(definitionData: string, textureUrl: string, scene?: BABYLON.Scene);
1934
+ dispose(): void;
1935
+ private _updateFallbacks;
1936
+ /** @internal */
1937
+ _getChar(charCode: number): BMFontChar;
1938
+ /** @internal */
1939
+ _getKerning(first: number, second: number): number;
1940
+ /** @internal */
1941
+ _unsupportedChars(text: string): string;
1942
+ }
1943
+
1944
+
1945
+ /** @internal */
1946
+ export var msdfVertexShaderWGSL: {
1947
+ name: string;
1948
+ shader: string;
1949
+ };
1950
+
1951
+
1952
+ /** @internal */
1953
+ export var msdfPixelShaderWGSL: {
1954
+ name: string;
1955
+ shader: string;
1956
+ };
1957
+
1958
+
1959
+ /** @internal */
1960
+ export var msdfVertexShader: {
1961
+ name: string;
1962
+ shader: string;
1963
+ };
1964
+
1965
+
1966
+ /** @internal */
1967
+ export var msdfPixelShader: {
1968
+ name: string;
1969
+ shader: string;
1970
+ };
1971
+
1972
+
1973
+ /** @internal */
1974
+ export class SdfTextParagraph {
1975
+ readonly text: string;
1976
+ readonly fontAsset: FontAsset;
1977
+ readonly options: ParagraphOptions;
1978
+ get lineHeight(): number;
1979
+ readonly paragraph: string;
1980
+ readonly lines: SdfTextLine[];
1981
+ readonly width: number;
1982
+ readonly height: number;
1983
+ readonly glyphs: SdfGlyph[];
1984
+ constructor(text: string, fontAsset: FontAsset, options?: Partial<ParagraphOptions>);
1985
+ private _computeMetrics;
1986
+ private _breakLines;
1987
+ private _collapse;
1988
+ private _wrap;
1989
+ }
1990
+
1991
+
1992
+ /** @internal */
1993
+ export type SdfTextLine = {
1994
+ text: string;
1995
+ glyphs: SdfGlyph[];
1996
+ start: number;
1997
+ end: number;
1998
+ width: number;
1999
+ };
2000
+
2001
+
2002
+
2003
+
2004
+ /** @internal */
2005
+ export type SdfGlyph = {
2006
+ char: BMFontChar;
2007
+ /** index of the line */
2008
+ line: number;
2009
+ /** position within the line */
2010
+ position: number;
2011
+ x: number;
2012
+ y: number;
2013
+ };
2014
+
2015
+
2016
+ export type SdfFontDistanceField = {
2017
+ fieldType: "sdf" | "msdf";
2018
+ distanceRange: number;
2019
+ };
2020
+ export type SdfFont = BMFont & {
2021
+ distanceField: SdfFontDistanceField;
2022
+ };
2023
+
2024
+
2025
+ /**
2026
+ * Holds information on how the font was generated.
2027
+ */
2028
+ export type BMFontInfo = {
2029
+ /** The name of the font */
2030
+ face: string;
2031
+ /** The size of the font */
2032
+ size: number;
2033
+ /** The font is bold */
2034
+ bold: number;
2035
+ /** The font is italic */
2036
+ italic: number;
2037
+ /** The charset of the font */
2038
+ charset: string[];
2039
+ /** The charset is unicode */
2040
+ unicode: number;
2041
+ /** The font height stretch in percentage. 100% means no stretch. */
2042
+ stretchH: number;
2043
+ /** Set to 1 if smoothing was turned on. */
2044
+ smooth: number;
2045
+ /** The supersampling level used. 1 means no supersampling was used. */
2046
+ aa: number;
2047
+ /** The padding for each character (up, right, down, left). */
2048
+ padding: [number, number, number, number];
2049
+ /** The spacing for each character (horizontal, vertical). */
2050
+ spacing: [number, number];
2051
+ /**
2052
+ * The outline thickness for the characters.
2053
+ *
2054
+ * @remark missing in msdf-bmfont-xml
2055
+ */
2056
+ outline?: number;
2057
+ };
2058
+ /**
2059
+ * Holds information common to all characters.
2060
+ */
2061
+ export type BMFontCommon = {
2062
+ /** Distance in pixels between each line of text */
2063
+ lineHeight: number;
2064
+ /** The number of pixels from the absolute top of the line to the base of the characters */
2065
+ base: number;
2066
+ /** The width of the texture, normally used to scale the x pos of the character image */
2067
+ scaleW: number;
2068
+ /** The height of the texture, normally used to scale the y pos of the character image */
2069
+ scaleH: number;
2070
+ /** The number of pages in the font */
2071
+ pages: number;
2072
+ /** Set to 1 if the monochrome characters have been packed into each of the texture channels. In this case alphaChnl describes what is stored in each channel. */
2073
+ packed: number;
2074
+ /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
2075
+ alphaChnl: number;
2076
+ /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
2077
+ redChnl: number;
2078
+ /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
2079
+ greenChnl: number;
2080
+ /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
2081
+ blueChnl: number;
2082
+ };
2083
+ /** Name of a texture file. There is one for each page in the font. */
2084
+ export type BMFontPages = {
2085
+ [id: number]: string;
2086
+ } & Array<string>;
2087
+ /**
2088
+ * Describes a single character in the font
2089
+ */
2090
+ export type BMFontChar = {
2091
+ /** Character id (charCode) */
2092
+ id: number;
2093
+ /** Left position of the character image in the texture. */
2094
+ x: number;
2095
+ /** Right position of the character image in the texture */
2096
+ y: number;
2097
+ /** Width of the chracter image in the texture */
2098
+ width: number;
2099
+ /** Height of the chracter image in the texture */
2100
+ height: number;
2101
+ /** Horizontal offset to be applied on screen */
2102
+ xoffset: number;
2103
+ /** Vertical offset to be applied on screen */
2104
+ yoffset: number;
2105
+ /** Horizontal advance after the character */
2106
+ xadvance: number;
2107
+ /** Page index where the character image is found */
2108
+ page: number;
2109
+ /** Texture channel where the chracter image is found
2110
+ * - 1 = blue
2111
+ * - 2 = green
2112
+ * - 3 = red
2113
+ * - 8 = alpha
2114
+ * - 15 = all channels
2115
+ */
2116
+ chnl: number;
2117
+ } & BMFontCharExtra;
2118
+ /**
2119
+ * additional context from msdf-bmfont-xml
2120
+ */
2121
+ export type BMFontCharExtra = {
2122
+ /** index of opentype.js glyph */
2123
+ index: number;
2124
+ /** actual character*/
2125
+ char: string;
2126
+ };
2127
+ /**
2128
+ * The kerning information is used to adjust the distance between certain characters, e.g. some characters should be placed closer to each other than others.
2129
+ */
2130
+ export type BMFontKerning = {
2131
+ /** The first character id. */
2132
+ first: number;
2133
+ /** The second character id. */
2134
+ second: number;
2135
+ /** How much the x position should be adjusted when drawing the second character immediately following the first. */
2136
+ amount: number;
2137
+ };
2138
+ /**
2139
+ * Compatible with [msdf-bmfont-xml](https://github.com/soimy/msdf-bmfont-xml)
2140
+ * @see https://www.angelcode.com/products/bmfont/doc/file_format.html
2141
+ */
2142
+ export type BMFont = {
2143
+ /** {@inheritDoc BMFontInfo} */
2144
+ info: BMFontInfo;
2145
+ /** {@inheritDoc BMFontCommon} */
2146
+ common: BMFontCommon;
2147
+ /** {@inheritDoc BMFontPages} */
2148
+ pages: BMFontPages;
2149
+ /** {@inheritDoc BMFontChar} */
2150
+ chars: BMFontChar[];
2151
+ /** {@inheritDoc BMFontKerning} */
2152
+ kernings: BMFontKerning[];
2153
+ };
2154
+
2155
+
2156
+
2157
+
2158
+ /**
2159
+ * Configuration options for the Lottie animation player.
2160
+ */
2161
+ export type AnimationConfiguration = {
2162
+ /**
2163
+ * Whether the animation should play on a loop or not
2164
+ */
2165
+ loopAnimation: boolean;
2166
+ /**
2167
+ * Size of the sprite atlas texture.
2168
+ * Default is 2048.
2169
+ */
2170
+ spriteAtlasSize: number;
2171
+ /**
2172
+ * Gap size around sprites in the atlas.
2173
+ * Default is 5.
2174
+ */
2175
+ gapSize: number;
2176
+ /**
2177
+ * Maximum number of sprites the renderer can handle at once.
2178
+ * Default is 64.
2179
+ */
2180
+ spritesCapacity: number;
2181
+ /**
2182
+ * Background color for the animation canvas.
2183
+ * Default is white with full opacity.
2184
+ */
2185
+ backgroundColor: {
2186
+ r: number;
2187
+ g: number;
2188
+ b: number;
2189
+ a: number;
2190
+ };
2191
+ /**
2192
+ * Minimum scale factor to prevent too small sprites.
2193
+ * Default is 5.
2194
+ */
2195
+ scaleMultiplier: number;
2196
+ /**
2197
+ * Scale factor for the rendering.
2198
+ * Default is 1.
2199
+ */
2200
+ devicePixelRatio: number;
2201
+ /**
2202
+ * Number of steps to sample cubic bezier easing functions for animations.
2203
+ * Default is 4.
2204
+ */
2205
+ easingSteps: number;
2206
+ /**
2207
+ * Whether to ignore opacity animations for performance.
2208
+ * Default is true.
2209
+ */
2210
+ ignoreOpacityAnimations: boolean;
2211
+ /**
2212
+ * Whether to support device lost events for WebGL contexts.
2213
+ * Default is false.
2214
+ */
2215
+ supportDeviceLost: boolean;
2216
+ };
2217
+ /**
2218
+ * LottiePlayer is a class that allows you to play Lottie animations using Babylon.js.
2219
+ * It plays the animations in a worker thread using OffscreenCanvas.
2220
+ * 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.
2221
+ */
2222
+ export class LottiePlayer {
2223
+ private _playing;
2224
+ private _disposed;
2225
+ private _worker;
2226
+ private _canvas;
2227
+ private _resizeObserver;
2228
+ private readonly _container;
2229
+ private readonly _animationFile;
2230
+ private readonly _configuration;
2231
+ /**
2232
+ * Creates a new instance of the LottiePlayer.
2233
+ * @param container The HTMLDivElement to create the canvas in and render the animation on.
2234
+ * @param animationFile The URL of the Lottie animation file to be played.
2235
+ * @param configuration Optional configuration object to customize the animation playback.
2236
+ */
2237
+ constructor(container: HTMLDivElement, animationFile: string, configuration?: Partial<AnimationConfiguration>);
2238
+ /**
2239
+ * Loads and plays a lottie animation.
2240
+ * @returns True if the animation is successfully set up to play, false if the animation couldn't play.
2241
+ */
2242
+ playAnimation(): boolean;
2243
+ /**
2244
+ * Disposes the LottiePlayer instance, cleaning up resources and event listeners.
2245
+ */
2246
+ dispose(): void;
2247
+ private _onWindowResize;
2248
+ private _onBeforeUnload;
2249
+ }
739
2250
 
740
- }
741
2251
 
742
- declare module "babylonjs-addons" {
743
- export * from "babylonjs-addons/index";
744
- }
745
2252
 
746
2253
 
747
- declare module ADDONS {
2254
+ /**
2255
+ * Information about a sprite in the sprite atlas.
2256
+ */
2257
+ export type SpriteAtlasInfo = {
2258
+ /**
2259
+ * Offset in the x axis of the sprite in the atlas.
2260
+ * Normalized between 0 and 1, left to right.
2261
+ */
2262
+ uOffset: number;
2263
+ /**
2264
+ * Offset in the y axis of the sprite in the atlas.
2265
+ * Normalized between 0 and 1, top to bottom.
2266
+ */
2267
+ vOffset: number;
2268
+ /**
2269
+ * Width of the sprite in the atlas.
2270
+ * In pixels.
2271
+ */
2272
+ cellWidth: number;
2273
+ /**
2274
+ * Height of the sprite in the atlas.
2275
+ * In pixels.
2276
+ */
2277
+ cellHeight: number;
2278
+ /**
2279
+ * Width of the sprite in the screen.
2280
+ * In pixels.
2281
+ */
2282
+ widthPx: number;
2283
+ /**
2284
+ * Height of the sprite in the screen.
2285
+ * In pixels.
2286
+ */
2287
+ heightPx: number;
2288
+ /**
2289
+ * X coordinate of the center of the sprite bounding box, used for final positioning in the screen
2290
+ */
2291
+ centerX: number;
2292
+ /**
2293
+ * Y coordinate of the center of the sprite bounding box, used for final positioning in the screen
2294
+ */
2295
+ centerY: number;
2296
+ };
2297
+ /**
2298
+ * SpritePacker is a class that handles the packing of sprites into a texture atlas.
2299
+ */
2300
+ export class SpritePacker {
2301
+ private readonly _engine;
2302
+ private readonly _configuration;
2303
+ private _spritesCanvas;
2304
+ private _spritesCanvasContext;
2305
+ private readonly _spritesInternalTexture;
2306
+ private readonly _spritesTexture;
2307
+ private _isDirty;
2308
+ private _currentX;
2309
+ private _currentY;
2310
+ private _maxRowHeight;
2311
+ private _spriteAtlasInfo;
2312
+ /**
2313
+ * Gets the texture atlas that contains all the sprites packed by this SpritePacker.
2314
+ * @returns The texture atlas containing the sprites.
2315
+ */
2316
+ get texture(): BABYLON.ThinTexture;
2317
+ /**
2318
+ * Creates a new instance of SpritePacker.
2319
+ * @param engine Engine that will render the sprites.
2320
+ * @param configuration Configuration options for the sprite packer.
2321
+ */
2322
+ constructor(engine: BABYLON.ThinEngine, configuration: AnimationConfiguration);
2323
+ /**
2324
+ * Adds a vector shape that comes from lottie data to the sprite atlas.
2325
+ * @param rawGroup The raw group shape to add to the atlas.
2326
+ * @param scalingFactor The scaling factor to apply to the shape.
2327
+ * @returns The information on how to find the sprite in the atlas.
2328
+ */
2329
+ addLottieShape(rawGroup: RawGroupShape, scalingFactor: BABYLON.IVector2Like): SpriteAtlasInfo;
2330
+ /**
2331
+ * Updates the internal atlas texture with the information that has been added to the SpritePacker.
2332
+ */
2333
+ updateAtlasTexture(): void;
2334
+ /**
2335
+ * Releases the canvas and its context to allow garbage collection.
2336
+ */
2337
+ releaseCanvas(): void;
2338
+ private _drawVectorShape;
2339
+ private _drawRectangle;
2340
+ private _drawPath;
2341
+ private _drawFill;
2342
+ private _drawGradientFill;
2343
+ private _drawLinearGradientFill;
2344
+ private _drawRadialGradientFill;
2345
+ private _addColorStops;
2346
+ private _gradientColorsToCssColor;
2347
+ private _lottieColorToCSSColor;
2348
+ }
748
2349
 
749
2350
 
750
2351
  /**
751
- * Abstract Node class from Babylon.js
2352
+ * Represents a sprite in the scene graph.
752
2353
  */
753
- export interface INodeLike {
754
- getWorldMatrix(): BABYLON.IMatrixLike;
2354
+ export class SpriteNode extends Node {
2355
+ private _sprite;
2356
+ private _originalWidth;
2357
+ private _originalHeight;
2358
+ private _firstTime;
2359
+ /**
2360
+ * Creates a new SpriteNode instance.
2361
+ * @param id Unique identifier for the sprite node.
2362
+ * @param ignoreOpacityAnimations If there are no animations on opacity, mark this as true to ignore and optimize CPU usage.
2363
+ * @param sprite The sprite associated with this node.
2364
+ * @param position The position of the sprite in the scene.
2365
+ * @param rotation The rotation of the sprite in degrees.
2366
+ * @param scale The scale of the sprite in the scene.
2367
+ * @param opacity The opacity of the sprite.
2368
+ * @param parent The parent node in the scene graph.
2369
+ */
2370
+ constructor(id: string, ignoreOpacityAnimations: boolean, sprite: BABYLON.ThinSprite, position?: Vector2Property, rotation?: ScalarProperty, scale?: Vector2Property, opacity?: ScalarProperty, parent?: Node);
2371
+ /**
2372
+ * Updates the node's properties based on the current frame of the animation.
2373
+ * @param frame Frame number we are playing in the animation.
2374
+ * @param isParentUpdated Whether the parent node has been updated.
2375
+ * @param isReset Whether the node is being reset.
2376
+ * @returns True if the node was updated, false otherwise.
2377
+ */
2378
+ update(frame: number, isParentUpdated?: boolean, isReset?: boolean): boolean;
755
2379
  }
2380
+
2381
+
756
2382
  /**
757
- * Class used to render text using MSDF (Multi-channel Signed Distance Field) technique
758
- * Thanks a lot to the work of Bhushan_Wagh and zb_sj for their amazing work on MSDF for Babylon.js
759
- * #6RLCWP#16
760
- * Star wars scroller: #6RLCWP#29
761
- * With metrics: #6RLCWP#35
762
- * Thickness: #IABMEZ#3
763
- * Solar system: #9YCDYC#9
764
- * Stroke: #6RLCWP#37
2383
+ * Represents all the sprites from the animation and manages their rendering.
765
2384
  */
766
- export class TextRenderer implements BABYLON.IDisposable {
767
- private readonly _useVAO;
768
- private _engine;
769
- private _shaderLanguage;
770
- private _vertexBuffers;
771
- private _spriteBuffer;
772
- private _worldBuffer;
773
- private _uvBuffer;
774
- private _drawWrapperBase;
775
- private _vertexArrayObject;
776
- private _font;
777
- private _charMatrices;
778
- private _charUvs;
779
- private _isDirty;
780
- private _baseLine;
781
- private _scalingMatrix;
782
- private _fontScaleMatrix;
783
- private _offsetMatrix;
784
- private _translationMatrix;
785
- private _baseMatrix;
786
- private _scaledMatrix;
787
- private _localMatrix;
788
- private _finalMatrix;
789
- private _lineMatrix;
790
- private _parentWorldMatrix;
2385
+ export class RenderingManager {
2386
+ private readonly _engine;
2387
+ private readonly _spritesRenderer;
2388
+ private readonly _spritesTexture;
2389
+ private _sprites;
2390
+ private readonly _configuration;
791
2391
  /**
792
- * Gets or sets the color of the text
2392
+ * Creates a new instance of the RenderingManager.
2393
+ * @param engine BABYLON.ThinEngine instance used for rendering.
2394
+ * @param spriteTexture The texture atlas containing the sprites.
2395
+ * @param configuration Configuration options for the rendering manager.
793
2396
  */
794
- color: BABYLON.IColor4Like;
2397
+ constructor(engine: BABYLON.ThinEngine, spriteTexture: BABYLON.ThinTexture, configuration: AnimationConfiguration);
795
2398
  /**
796
- * Gets or sets the color of the stroke around the text
2399
+ * Adds a sprite to the rendering manager.
2400
+ * @param sprite Sprite to add to the rendering manager.
797
2401
  */
798
- strokeColor: BABYLON.IColor4Like;
2402
+ addSprite(sprite: BABYLON.ThinSprite): void;
799
2403
  /**
800
- * Gets or sets the width of the stroke around the text (inset)
2404
+ * Prepares the rendering manager for rendering.
801
2405
  */
802
- strokeInsetWidth: number;
2406
+ ready(): void;
803
2407
  /**
804
- * Gets or sets the width of the stroke around the text (outset)
2408
+ * Renders all the sprites in the rendering manager.
2409
+ * @param worldMatrix World matrix to apply to the sprites.
2410
+ * @param projectionMatrix Projection matrix to apply to the sprites.
805
2411
  */
806
- strokeOutsetWidth: number;
2412
+ render(worldMatrix: ThinMatrix, projectionMatrix: ThinMatrix): void;
807
2413
  /**
808
- * Gets or sets the thickness of the text (0 means as defined in the font)
809
- * Value must be between -0.5 and 0.5
2414
+ * Disposes the rendering manager and its resources.
810
2415
  */
811
- thicknessControl: number;
812
- private _parent;
2416
+ dispose(): void;
2417
+ private _customSpriteUpdate;
2418
+ }
2419
+
2420
+
2421
+ /**
2422
+ * Represents a node in the scenegraph that contains the animation information from a lottie animation layer or group.
2423
+ */
2424
+ export class Node {
2425
+ private readonly _id;
2426
+ private readonly _ignoreOpacityAnimations;
2427
+ private readonly _position;
2428
+ private readonly _rotation;
2429
+ private readonly _scale;
2430
+ private _worldMatrix;
2431
+ private _localMatrix;
2432
+ private _globalMatrix;
2433
+ private readonly _opacity;
2434
+ private readonly _parent;
2435
+ private readonly _children;
2436
+ private _isVisible;
2437
+ private _isAnimated;
2438
+ private _animationsFunctions;
2439
+ protected _isControl: boolean;
2440
+ protected _isShape: boolean;
813
2441
  /**
814
- * Gets or sets the parent of the text renderer
2442
+ * Gets the id of this node.
2443
+ * @returns The unique identifier of this node.
815
2444
  */
816
- get parent(): BABYLON.Nullable<INodeLike>;
817
- set parent(value: BABYLON.Nullable<INodeLike>);
818
- private _transformMatrix;
2445
+ get id(): string;
819
2446
  /**
820
- * Gets or sets the transform matrix of the text renderer
821
- * It will be applied in that order:
822
- * parent x transform x paragraph world
2447
+ * Gets the childer of this node.
2448
+ * @returns An array of child nodes.
823
2449
  */
824
- get transformMatrix(): BABYLON.IMatrixLike;
825
- set transformMatrix(value: BABYLON.IMatrixLike);
2450
+ get children(): Node[];
826
2451
  /**
827
- * Gets or sets if the text is billboarded
2452
+ * Gets whether this node is a shape.
2453
+ * @returns True if this node is a shape, false otherwise.
828
2454
  */
829
- isBillboard: boolean;
2455
+ get isShape(): boolean;
830
2456
  /**
831
- * Gets or sets if the text is screen projected
832
- * This will work only if the text is billboarded
2457
+ * Gets the world matrix of this node.
2458
+ * @returns The world matrix.
833
2459
  */
834
- isBillboardScreenProjected: boolean;
2460
+ get worldMatrix(): ThinMatrix;
835
2461
  /**
836
- * Gets the number of characters in the text renderer
2462
+ * Gets whether this node is animated.
2463
+ * @returns True if this node has animations, false otherwise.
837
2464
  */
838
- get characterCount(): number;
2465
+ get isAnimated(): boolean;
839
2466
  /**
840
- * Gets or sets if the text renderer should ignore the depth buffer
841
- * Default is false
2467
+ * Gets the opacity of this node.
2468
+ * If the node is not visible, the opacity will be 0.
2469
+ * @returns The opacity of the node, from 0 to 1.
842
2470
  */
843
- ignoreDepthBuffer: boolean;
844
- private constructor();
845
- private _resizeBuffers;
846
- private _setShaders;
2471
+ get opacity(): number;
847
2472
  /**
848
- * Add a paragraph of text to the renderer
849
- * @param text define the text to add
850
- * @param options define the options to use for the paragraph (optional)
851
- * @param worldMatrix define the world matrix to use for the paragraph (optional)
2473
+ * Gets the initial scale of this node.
2474
+ * @returns The initial scale.
852
2475
  */
853
- addParagraph(text: string, options?: Partial<ParagraphOptions>, worldMatrix?: BABYLON.IMatrixLike): void;
2476
+ get startScale(): BABYLON.IVector2Like;
854
2477
  /**
855
- * Render the text using the provided view and projection matrices
856
- * @param viewMatrix define the view matrix to use
857
- * @param projectionMatrix define the projection matrix to use
2478
+ * Gets the parent node of this node.
2479
+ * @returns The parent node, or undefined if this is a root node.
858
2480
  */
859
- render(viewMatrix: BABYLON.IMatrixLike, projectionMatrix: BABYLON.IMatrixLike): void;
2481
+ get parent(): Node | undefined;
860
2482
  /**
861
- * Release associated resources
2483
+ * Sets the node visibility.
2484
+ * @param value The new visibility value.
862
2485
  */
863
- dispose(): void;
2486
+ set isVisible(value: boolean);
864
2487
  /**
865
- * Creates a new TextRenderer instance asynchronously
866
- * @param font define the font asset to use
867
- * @param engine define the engine to use
868
- * @returns a promise that resolves to the created TextRenderer instance
2488
+ * Constructs a new node.
2489
+ * @param id Unique identifier for the node.
2490
+ * @param ignoreOpacityAnimations If there are no animations on opacity, mark this as true to ignore and optimize CPU usage.
2491
+ * @param position Position of the node in the scene.
2492
+ * @param rotation Rotation of the node in degrees.
2493
+ * @param scale Scale of the node in the scene.
2494
+ * @param opacity Opacity of the node, from 0 to 1.
2495
+ * @param parent Parent node in the scenegraph.
869
2496
  */
870
- static CreateTextRendererAsync(font: FontAsset, engine: BABYLON.AbstractEngine): Promise<TextRenderer>;
2497
+ constructor(id: string, ignoreOpacityAnimations: boolean, position?: Vector2Property, rotation?: ScalarProperty, scale?: Vector2Property, opacity?: ScalarProperty, parent?: Node);
2498
+ /**
2499
+ * Resets the node's properties to their initial values.
2500
+ */
2501
+ reset(): void;
2502
+ /**
2503
+ * Updates the node's properties based on the current frame of the animation.
2504
+ * @param frame Frame number we are playing in the animation.
2505
+ * @param isParentUpdated Whether the parent node has been updated.
2506
+ * @param isReset Whether the node is being reset.
2507
+ * @returns True if the node was updated, false otherwise.
2508
+ */
2509
+ update(frame: number, isParentUpdated?: boolean, isReset?: boolean): boolean;
2510
+ private _updatePosition;
2511
+ private _updateRotation;
2512
+ private _updateScale;
2513
+ private _updateOpacity;
871
2514
  }
872
2515
 
873
2516
 
874
- /** @internal */
875
- export type ParagraphOptions = {
876
- maxWidth: number;
877
- lineHeight: number;
878
- letterSpacing: number;
879
- tabSize: number;
880
- whiteSpace: "pre-line";
881
- textAlign: "left" | "right" | "center";
882
- translate: BABYLON.IVector2Like | undefined;
883
- };
884
- /** @internal */
885
- export var DefaultParagraphOptions: ParagraphOptions;
886
-
887
-
2517
+ /**
2518
+ * This represents a top node of the scenegraph in a Lottie animation.
2519
+ * Each top level layer in Lottie is represented by a control node node.
2520
+ */
2521
+ export class ControlNode extends Node {
2522
+ private _inFrame;
2523
+ private _outFrame;
2524
+ /**
2525
+ * Constructs a new control node.
2526
+ * @param id Unique identifier for the node.
2527
+ * @param ignoreOpacityAnimations If there are no animations on opacity, mark this as true to ignore and optimize CPU usage.
2528
+ * @param inFrame Frame at which the node becomes active.
2529
+ * @param outFrame Frame at which the node becomes inactive.
2530
+ * @param position Position of the node in the scene.
2531
+ * @param rotation Rotation of the node in degrees.
2532
+ * @param scale Scale of the node in the scene.
2533
+ * @param opacity Opacity of the node, from 0 to 1.
2534
+ * @param parent Parent node in the scenegraph.
2535
+ */
2536
+ constructor(id: string, ignoreOpacityAnimations: boolean, inFrame: number, outFrame: number, position?: Vector2Property, rotation?: ScalarProperty, scale?: Vector2Property, opacity?: ScalarProperty, parent?: Node);
2537
+ /**
2538
+ * Updates the node's properties based on the current frame of the animation.
2539
+ * This node will only be updated if the current frame is within the in and out range.
2540
+ * @param frame Frame number we are playing in the animation.
2541
+ * @param isParentUpdated Whether the parent node has been updated.
2542
+ * @param isReset Whether the node is being reset.
2543
+ * @returns True if the node was updated, false otherwise.
2544
+ */
2545
+ update(frame: number, isParentUpdated?: boolean, isReset?: boolean): boolean;
2546
+ }
888
2547
 
889
2548
 
890
2549
  /**
891
- * Class representing a font asset for SDF (Signed Distance Field) rendering.
2550
+ * Class that controls the playing of lottie animations using Babylon.js
892
2551
  */
893
- export class FontAsset implements BABYLON.IDisposable {
894
- private readonly _chars;
895
- private readonly _charsRegex;
896
- private readonly _kernings;
897
- /** @internal */
898
- readonly _font: SdfFont;
2552
+ export class AnimationController {
2553
+ private _isReady;
2554
+ private readonly _canvas;
2555
+ private readonly _configuration;
2556
+ private readonly _engine;
2557
+ private readonly _spritePacker;
2558
+ private _animation?;
2559
+ private readonly _viewport;
2560
+ private readonly _projectionMatrix;
2561
+ private readonly _worldMatrix;
2562
+ private _frameDuration;
2563
+ private _currentFrame;
2564
+ private _isPlaying;
2565
+ private _animationFrameId;
2566
+ private _lastFrameTime;
2567
+ private _deltaTime;
2568
+ private _loop;
2569
+ private _accumulatedTime;
2570
+ private _framesToAdvance;
2571
+ private readonly _renderingManager;
899
2572
  /**
900
- * Gets the font scale value
2573
+ * Gets the canvas used for rendering the animation.
2574
+ * @returns The canvas element used for rendering.
901
2575
  */
902
- readonly scale: number;
2576
+ get view(): HTMLCanvasElement;
903
2577
  /**
904
- * Gets the list of used textures
2578
+ * Gets the height of the animation in pixels.
2579
+ * @returns The height of the animation in pixels.
905
2580
  */
906
- readonly textures: BABYLON.Texture[];
2581
+ get animationHeight(): number;
907
2582
  /**
908
- * Creates a new FontAsset instance.
909
- * @param definitionData defines the font data in JSON format.
910
- * @param textureUrl defines the url of the texture to use for the font.
911
- * @param scene defines the hosting scene.
2583
+ * Gets the width of the animation in pixels.
2584
+ * @returns The width of the animation in pixels.
2585
+ */
2586
+ get animationWidth(): number;
2587
+ /**
2588
+ * Creates a new instance of the Player.
2589
+ * @param canvas The canvas element to render the animation on.
2590
+ * @param animationJson The JSON string of the Lottie animation to be played.
2591
+ * @param configuration The configuration for the animation player.
2592
+ */
2593
+ constructor(canvas: HTMLCanvasElement, animationJson: string, configuration: AnimationConfiguration);
2594
+ /**
2595
+ * Plays the animation.
2596
+ * @param loop If true, the animation will loop when it reaches the end.
2597
+ */
2598
+ playAnimation(loop?: boolean): void;
2599
+ /**
2600
+ * Stops the animation playback.
2601
+ */
2602
+ stopAnimation(): void;
2603
+ /**
2604
+ * Sets the rendering size for the engine
2605
+ * @param width Width of the rendering canvas
2606
+ * @param height Height of the rendering canvas
2607
+ */
2608
+ setSize(width: number, height: number): void;
2609
+ /**
2610
+ * Disposes the player and releases all resources.
912
2611
  */
913
- constructor(definitionData: string, textureUrl: string, scene?: BABYLON.Scene);
914
2612
  dispose(): void;
915
- private _updateFallbacks;
916
- /** @internal */
917
- _getChar(charCode: number): BMFontChar;
918
- /** @internal */
919
- _getKerning(first: number, second: number): number;
920
- /** @internal */
921
- _unsupportedChars(text: string): string;
2613
+ private _cleanTree;
2614
+ private _startRenderLoop;
2615
+ private _render;
922
2616
  }
923
2617
 
924
2618
 
925
- /** @internal */
926
- export var msdfVertexShaderWGSL: {
927
- name: string;
928
- shader: string;
929
- };
930
-
931
-
932
- /** @internal */
933
- export var msdfPixelShaderWGSL: {
934
- name: string;
935
- shader: string;
936
- };
937
-
938
-
939
- /** @internal */
940
- export var msdfVertexShader: {
941
- name: string;
942
- shader: string;
943
- };
944
-
945
-
946
- /** @internal */
947
- export var msdfPixelShader: {
948
- name: string;
949
- shader: string;
950
- };
951
-
952
-
953
- /** @internal */
954
- export class SdfTextParagraph {
955
- readonly text: string;
956
- readonly fontAsset: FontAsset;
957
- readonly options: ParagraphOptions;
958
- get lineHeight(): number;
959
- readonly paragraph: string;
960
- readonly lines: SdfTextLine[];
961
- readonly width: number;
962
- readonly height: number;
963
- readonly glyphs: SdfGlyph[];
964
- constructor(text: string, fontAsset: FontAsset, options?: Partial<ParagraphOptions>);
965
- private _computeMetrics;
966
- private _breakLines;
967
- private _collapse;
968
- private _wrap;
2619
+ /**
2620
+ * Represents a Babylon.js thin version of a Matrix
2621
+ * We are only exposing what we truly need in the scope of
2622
+ * the Lottie Renderer project preventing the dependency on the full
2623
+ * Babylon.js math system.
2624
+ */
2625
+ export class ThinMatrix implements BABYLON.IMatrixLike {
2626
+ /**
2627
+ * Prevents global conflicts on update as shader programs are shared.
2628
+ */
2629
+ private static _UPDATE_FLAG_SEED;
2630
+ /**
2631
+ * Current update flag used to know whether a Matrix has changed since previous render or not.
2632
+ * This helps identifying if a Matrix needs to be
2633
+ * uploaded to a shader program.
2634
+ */
2635
+ updateFlag: number;
2636
+ private readonly _data;
2637
+ /**
2638
+ * Creates a new ThinMatrix instance.
2639
+ */
2640
+ constructor();
2641
+ /**
2642
+ * Set the matrix values.
2643
+ * @param m11 Value for row 1, column 1
2644
+ * @param m12 Value for row 1, column 2
2645
+ * @param m13 Value for row 1, column 3
2646
+ * @param m14 Value for row 1, column 4
2647
+ * @param m21 Value for row 2, column 1
2648
+ * @param m22 Value for row 2, column 2
2649
+ * @param m23 Value for row 2, column 3
2650
+ * @param m24 Value for row 2, column 4
2651
+ * @param m31 Value for row 3, column 1
2652
+ * @param m32 Value for row 3, column 2
2653
+ * @param m33 Value for row 3, column 3
2654
+ * @param m34 Value for row 3, column 4
2655
+ * @param m41 Value for row 4, column 1
2656
+ * @param m42 Value for row 4, column 2
2657
+ * @param m43 Value for row 4, column 3
2658
+ * @param m44 Value for row 4, column 4
2659
+ * @returns The updated ThinMatrix instance
2660
+ */
2661
+ 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;
2662
+ /**
2663
+ * Set the matrix to an identity matrix.
2664
+ * @returns The updated ThinMatrix instance
2665
+ */
2666
+ identity(): ThinMatrix;
2667
+ /**
2668
+ * Stores a left-handed orthographic projection into a given matrix
2669
+ * @param left defines the viewport left coordinate
2670
+ * @param right defines the viewport right coordinate
2671
+ * @param bottom defines the viewport bottom coordinate
2672
+ * @param top defines the viewport top coordinate
2673
+ * @param znear defines the near clip plane
2674
+ * @param zfar defines the far clip plane
2675
+ * @returns The updated ThinMatrix instance
2676
+ */
2677
+ orthoOffCenterLeftHanded(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): ThinMatrix;
2678
+ /**
2679
+ * Sets a matrix to a value composed by merging scale (vector2), rotation (roll around z) and translation (vector2)
2680
+ * This only updates the parts of the matrix that are used for 2D transformations.
2681
+ * @param scale defines the scale vector
2682
+ * @param roll defines the rotation around z
2683
+ * @param translation defines the translation vector
2684
+ * @returns the updated ThinMatrix instance
2685
+ */
2686
+ compose(scale: BABYLON.IVector2Like, roll: number, translation: BABYLON.IVector2Like): ThinMatrix;
2687
+ /**
2688
+ * Sets the current matrix with the multiplication result of the current Matrix and the given one
2689
+ * This only updates the parts of the matrix that are used for 2D transformations.
2690
+ * @param other defines the second operand
2691
+ * @param output the matrix to store the result in
2692
+ * @returns the current matrix
2693
+ */
2694
+ multiplyToRef(other: ThinMatrix, output: ThinMatrix): ThinMatrix;
2695
+ /**
2696
+ * Returns the matrix data array.
2697
+ * @returns The matrix data
2698
+ */
2699
+ asArray(): BABYLON.Tuple<number, 16>;
2700
+ /**
2701
+ * Decomposes the matrix into scale, rotation, and translation.
2702
+ * @param scale Scale vector to store the scale values
2703
+ * @param translation Translation vector to store the translation values
2704
+ * @returns The rotation in radians
2705
+ */
2706
+ decompose(scale: BABYLON.IVector2Like, translation: BABYLON.IVector2Like): number;
969
2707
  }
970
2708
 
971
2709
 
972
- /** @internal */
973
- export type SdfTextLine = {
974
- text: string;
975
- glyphs: SdfGlyph[];
976
- start: number;
977
- end: number;
2710
+ /**
2711
+ * Represents a bounding box for a shape in the animation.
2712
+ */
2713
+ export type BoundingBox = {
2714
+ /**
2715
+ * Height of the bounding box
2716
+ */
2717
+ height: number;
2718
+ /**
2719
+ * Width of the bounding box
2720
+ */
978
2721
  width: number;
2722
+ /**
2723
+ * X coordinate of the center of the bounding box
2724
+ */
2725
+ centerX: number;
2726
+ /**
2727
+ * Y coordinate of the center of the bounding box
2728
+ */
2729
+ centerY: number;
979
2730
  };
2731
+ /**
2732
+ * Calculates the bounding box for a group shape in a Lottie animation.
2733
+ * @param rawGroup The raw group shape to calculate the bounding box for
2734
+ * @returns The bounding box for the group shape
2735
+ */
2736
+ export function GetBoundingBox(rawGroup: RawGroupShape): BoundingBox;
980
2737
 
981
2738
 
2739
+ /**
2740
+ * Represents a Babylon.js thin version of a cubic bezier curve
2741
+ * We are only exposing what we truly need in the scope of
2742
+ * the Lottie Renderer project preventing the dependency on the full
2743
+ * Babylon.js animation system.
2744
+ */
2745
+ export class BezierCurve {
2746
+ /**
2747
+ * X of the first control point
2748
+ */
2749
+ readonly x1: number;
2750
+ /**
2751
+ * Y of the first control point
2752
+ */
2753
+ readonly y1: number;
2754
+ /**
2755
+ * X of the second control point
2756
+ */
2757
+ readonly x2: number;
2758
+ /**
2759
+ * Y of the second control point
2760
+ */
2761
+ readonly y2: number;
2762
+ private readonly _easingSteps;
2763
+ private readonly _f0;
2764
+ private readonly _f1;
2765
+ private readonly _f2;
2766
+ /**
2767
+ * Instantiates a bezier function
2768
+ * @see http://cubic-bezier.com/#.17,.67,.83,.67
2769
+ * @param x1 Defines the x component of the start tangent in the bezier curve
2770
+ * @param y1 Defines the y component of the start tangent in the bezier curve
2771
+ * @param x2 Defines the x component of the end tangent in the bezier curve
2772
+ * @param y2 Defines the y component of the end tangent in the bezier curve
2773
+ * @param easingSteps Number of steps to sample the bezier curve for easing
2774
+ */
2775
+ constructor(x1: number | undefined, y1: number | undefined, x2: number | undefined, y2: number | undefined, easingSteps: number);
2776
+ /**
2777
+ * Interpolates the bezier curve at a given time
2778
+ * @param t Defines the time to evaluate the bezier curve at, between 0 and 1
2779
+ * @returns The interpolated value at time t
2780
+ */
2781
+ interpolate(t: number): number;
2782
+ }
982
2783
 
983
2784
 
984
- /** @internal */
985
- export type SdfGlyph = {
986
- char: BMFontChar;
987
- /** index of the line */
988
- line: number;
989
- /** position within the line */
990
- position: number;
991
- x: number;
992
- y: number;
2785
+ export type RawLottieAnimation = {
2786
+ v: string;
2787
+ fr: number;
2788
+ ip: number;
2789
+ op: number;
2790
+ w: number;
2791
+ h: number;
2792
+ nm?: string;
2793
+ layers: RawLottieLayer[];
993
2794
  };
994
-
995
-
996
- export type SdfFontDistanceField = {
997
- fieldType: "sdf" | "msdf";
998
- distanceRange: number;
2795
+ export type RawLottieLayer = {
2796
+ ind?: number;
2797
+ ty: RawLayerType;
2798
+ nm?: string;
2799
+ parent?: number;
2800
+ hd?: boolean;
2801
+ sr?: number;
2802
+ ao?: number;
2803
+ ip?: number;
2804
+ op?: number;
2805
+ st?: number;
2806
+ ct?: number;
2807
+ ks: RawTransform;
2808
+ shapes?: RawGraphicElement[];
999
2809
  };
1000
- export type SdfFont = BMFont & {
1001
- distanceField: SdfFontDistanceField;
2810
+ export type RawGraphicElement = {
2811
+ nm?: string;
2812
+ hd?: boolean;
2813
+ ty: RawShapeType;
2814
+ bm?: number;
2815
+ ix?: number;
2816
+ };
2817
+ export type RawGroupShape = RawGraphicElement & {
2818
+ it?: RawGraphicElement[];
2819
+ };
2820
+ export type RawRectangleShape = RawGraphicElement & {
2821
+ d: RawShapeDirection;
2822
+ p: RawPositionProperty;
2823
+ s: RawVectorProperty;
2824
+ r: RawScalarProperty;
2825
+ };
2826
+ export type RawPathShape = RawGraphicElement & {
2827
+ d: RawShapeDirection;
2828
+ ks: RawBezierShapeProperty;
2829
+ };
2830
+ export type RawFillShape = RawGraphicElement & {
2831
+ o: RawScalarProperty;
2832
+ c: RawColorProperty;
2833
+ r: RawFillRule;
2834
+ };
2835
+ export type RawGradientFillShape = RawGraphicElement & {
2836
+ o: RawScalarProperty;
2837
+ g: RawGradientsProperty;
2838
+ s: RawPositionProperty;
2839
+ e: RawPositionProperty;
2840
+ t: RawGradientType;
2841
+ h: RawScalarProperty;
2842
+ a?: RawScalarProperty;
2843
+ r: RawFillRule;
2844
+ };
2845
+ export type RawTransformShape = RawGraphicElement & {
2846
+ a: RawPositionProperty;
2847
+ p: RawPositionProperty;
2848
+ r: RawScalarProperty;
2849
+ s: RawVectorProperty;
2850
+ o: RawScalarProperty;
2851
+ sk: RawScalarProperty;
2852
+ sa: RawScalarProperty;
2853
+ };
2854
+ export type RawTransform = {
2855
+ a?: RawPositionProperty;
2856
+ p?: RawPositionProperty;
2857
+ r?: RawScalarProperty;
2858
+ s?: RawVectorProperty;
2859
+ o?: RawScalarProperty;
2860
+ };
2861
+ export type RawScalarProperty = {
2862
+ a: RawNumberBoolean;
2863
+ k: number | RawVectorKeyframe[];
2864
+ };
2865
+ export type RawVectorProperty = {
2866
+ a: RawNumberBoolean;
2867
+ k: number[] | RawVectorKeyframe[];
2868
+ l: number;
2869
+ };
2870
+ export type RawVectorKeyframe = {
2871
+ t: number;
2872
+ s: number[];
2873
+ h?: RawNumberBoolean;
2874
+ i?: RawKeyFrameEasing;
2875
+ o?: RawKeyFrameEasing;
2876
+ };
2877
+ export type RawPositionProperty = {
2878
+ a: RawNumberBoolean;
2879
+ k: number[] | RawPositionKeyframe[];
2880
+ l: number;
2881
+ };
2882
+ export type RawPositionKeyframe = {
2883
+ t: number;
2884
+ h?: RawNumberBoolean;
2885
+ i?: RawKeyFrameEasing;
2886
+ o?: RawKeyFrameEasing;
2887
+ s: number[];
2888
+ ti: number[];
2889
+ to: number[];
2890
+ };
2891
+ export type RawBezierShapeProperty = {
2892
+ a: RawNumberBoolean;
2893
+ k: RawBezier | RawBezierShapeKeyframe[];
2894
+ };
2895
+ export type RawBezierShapeKeyframe = {
2896
+ t: number;
2897
+ h?: RawNumberBoolean;
2898
+ i?: RawKeyFrameEasing;
2899
+ o?: RawKeyFrameEasing;
2900
+ s: RawBezier[];
1002
2901
  };
2902
+ export type RawColorProperty = {
2903
+ a: RawNumberBoolean;
2904
+ k: number[] | RawColorKeyframe[];
2905
+ };
2906
+ export type RawColorKeyframe = {
2907
+ t: number;
2908
+ h?: RawNumberBoolean;
2909
+ i?: RawKeyFrameEasing;
2910
+ o?: RawKeyFrameEasing;
2911
+ s: number[];
2912
+ };
2913
+ export type RawGradientsProperty = {
2914
+ p: number;
2915
+ k: RawGradientProperty;
2916
+ };
2917
+ export type RawGradientProperty = {
2918
+ a: RawNumberBoolean;
2919
+ k: number[];
2920
+ };
2921
+ export type RawKeyFrameEasing = {
2922
+ x: number | number[];
2923
+ y: number | number[];
2924
+ };
2925
+ export type RawBezier = {
2926
+ c: boolean;
2927
+ i: number[][];
2928
+ o: number[][];
2929
+ v: number[][];
2930
+ };
2931
+ export type RawNumberBoolean = 0 | 1;
2932
+ export type RawLayerType = 0 | 1 | 2 | 3 | 4 | 5 | 6;
2933
+ export type RawShapeType = "fl" | "gf" | "gr" | "tr" | "sh" | "rc";
2934
+ export type RawShapeDirection = 1 | 3;
2935
+ export type RawFillRule = 1 | 2;
2936
+ export type RawGradientType = 1 | 2;
1003
2937
 
1004
2938
 
1005
2939
  /**
1006
- * Holds information on how the font was generated.
2940
+ * Represents a Babylon.js thin version of a Lottie animation.
1007
2941
  */
1008
- export type BMFontInfo = {
1009
- /** The name of the font */
1010
- face: string;
1011
- /** The size of the font */
1012
- size: number;
1013
- /** The font is bold */
1014
- bold: number;
1015
- /** The font is italic */
1016
- italic: number;
1017
- /** The charset of the font */
1018
- charset: string[];
1019
- /** The charset is unicode */
1020
- unicode: number;
1021
- /** The font height stretch in percentage. 100% means no stretch. */
1022
- stretchH: number;
1023
- /** Set to 1 if smoothing was turned on. */
1024
- smooth: number;
1025
- /** The supersampling level used. 1 means no supersampling was used. */
1026
- aa: number;
1027
- /** The padding for each character (up, right, down, left). */
1028
- padding: [number, number, number, number];
1029
- /** The spacing for each character (horizontal, vertical). */
1030
- spacing: [number, number];
2942
+ export type AnimationInfo = {
1031
2943
  /**
1032
- * The outline thickness for the characters.
1033
- *
1034
- * @remark missing in msdf-bmfont-xml
2944
+ * Frame number where the animation starts.
1035
2945
  */
1036
- outline?: number;
2946
+ startFrame: number;
2947
+ /**
2948
+ * Frame number where the animation ends.
2949
+ */
2950
+ endFrame: number;
2951
+ /**
2952
+ * Frame rate of the animation.
2953
+ */
2954
+ frameRate: number;
2955
+ /**
2956
+ * Width of the animation in pixels
2957
+ */
2958
+ widthPx: number;
2959
+ /**
2960
+ * Height of the animation in pixels
2961
+ */
2962
+ heightPx: number;
2963
+ /**
2964
+ * Nodes representing the animation
2965
+ */
2966
+ nodes: Node[];
1037
2967
  };
1038
2968
  /**
1039
- * Holds information common to all characters.
2969
+ * Transform properties for a Lottie animation.
2970
+ * Any of these properties may be animated.
1040
2971
  */
1041
- export type BMFontCommon = {
1042
- /** Distance in pixels between each line of text */
1043
- lineHeight: number;
1044
- /** The number of pixels from the absolute top of the line to the base of the characters */
1045
- base: number;
1046
- /** The width of the texture, normally used to scale the x pos of the character image */
1047
- scaleW: number;
1048
- /** The height of the texture, normally used to scale the y pos of the character image */
1049
- scaleH: number;
1050
- /** The number of pages in the font */
1051
- pages: number;
1052
- /** Set to 1 if the monochrome characters have been packed into each of the texture channels. In this case alphaChnl describes what is stored in each channel. */
1053
- packed: number;
1054
- /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
1055
- alphaChnl: number;
1056
- /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
1057
- redChnl: number;
1058
- /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
1059
- greenChnl: number;
1060
- /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
1061
- blueChnl: number;
2972
+ export type Transform = {
2973
+ /**
2974
+ * The anchor point of the layer, which is the point around which transformations are applied.
2975
+ */
2976
+ anchorPoint: Vector2Property;
2977
+ /**
2978
+ * The position of the layer in the animation.
2979
+ */
2980
+ position: Vector2Property;
2981
+ /**
2982
+ * The rotation of the layer in degrees.
2983
+ */
2984
+ rotation: ScalarProperty;
2985
+ /**
2986
+ * The scale of the layer in the X and Y axis.
2987
+ */
2988
+ scale: Vector2Property;
2989
+ /**
2990
+ * The opacity of the layer, represented as a scalar value.
2991
+ */
2992
+ opacity: ScalarProperty;
1062
2993
  };
1063
- /** Name of a texture file. There is one for each page in the font. */
1064
- export type BMFontPages = {
1065
- [id: number]: string;
1066
- } & Array<string>;
1067
2994
  /**
1068
- * Describes a single character in the font
2995
+ * Represents a scalar that can be animated.
1069
2996
  */
1070
- export type BMFontChar = {
1071
- /** Character id (charCode) */
1072
- id: number;
1073
- /** Left position of the character image in the texture. */
1074
- x: number;
1075
- /** Right position of the character image in the texture */
1076
- y: number;
1077
- /** Width of the chracter image in the texture */
1078
- width: number;
1079
- /** Height of the chracter image in the texture */
1080
- height: number;
1081
- /** Horizontal offset to be applied on screen */
1082
- xoffset: number;
1083
- /** Vertical offset to be applied on screen */
1084
- yoffset: number;
1085
- /** Horizontal advance after the character */
1086
- xadvance: number;
1087
- /** Page index where the character image is found */
1088
- page: number;
1089
- /** Texture channel where the chracter image is found
1090
- * - 1 = blue
1091
- * - 2 = green
1092
- * - 3 = red
1093
- * - 8 = alpha
1094
- * - 15 = all channels
2997
+ export type ScalarProperty = {
2998
+ /**
2999
+ * The initial value of the property at the start of the animation.
1095
3000
  */
1096
- chnl: number;
1097
- } & BMFontCharExtra;
3001
+ startValue: number;
3002
+ /**
3003
+ * The current value of the property during the animation.
3004
+ */
3005
+ currentValue: number;
3006
+ /**
3007
+ * An array of keyframes for the property.
3008
+ */
3009
+ keyframes?: ScalarKeyframe[];
3010
+ /**
3011
+ * The index of the current keyframe being processed in the animation.
3012
+ */
3013
+ currentKeyframeIndex: number;
3014
+ };
1098
3015
  /**
1099
- * additional context from msdf-bmfont-xml
3016
+ * Represents a keyframe for a scalar property.
1100
3017
  */
1101
- export type BMFontCharExtra = {
1102
- /** index of opentype.js glyph */
1103
- index: number;
1104
- /** actual character*/
1105
- char: string;
3018
+ export type ScalarKeyframe = {
3019
+ /**
3020
+ * The value at this keyframe.
3021
+ */
3022
+ value: number;
3023
+ /**
3024
+ * The time at which this keyframe occurs in the animation, in frames.
3025
+ */
3026
+ time: number;
3027
+ /**
3028
+ * The easing function applied to the transition from this keyframe to the next one.
3029
+ */
3030
+ easeFunction: BezierCurve;
1106
3031
  };
1107
3032
  /**
1108
- * The kerning information is used to adjust the distance between certain characters, e.g. some characters should be placed closer to each other than others.
3033
+ * Represents a 2D vector that can be animated.
1109
3034
  */
1110
- export type BMFontKerning = {
1111
- /** The first character id. */
1112
- first: number;
1113
- /** The second character id. */
1114
- second: number;
1115
- /** How much the x position should be adjusted when drawing the second character immediately following the first. */
1116
- amount: number;
3035
+ export type Vector2Property = {
3036
+ /**
3037
+ * The initial value at the start of the animation.
3038
+ */
3039
+ startValue: BABYLON.IVector2Like;
3040
+ /**
3041
+ * The current value during the animation.
3042
+ */
3043
+ currentValue: BABYLON.IVector2Like;
3044
+ /**
3045
+ * An array of keyframes for the property.
3046
+ */
3047
+ keyframes?: Vector2Keyframe[];
3048
+ /**
3049
+ * The index of the current keyframe being processed in the animation.
3050
+ */
3051
+ currentKeyframeIndex: number;
1117
3052
  };
1118
3053
  /**
1119
- * Compatible with [msdf-bmfont-xml](https://github.com/soimy/msdf-bmfont-xml)
1120
- * @see https://www.angelcode.com/products/bmfont/doc/file_format.html
3054
+ * Represents a keyframe for a 2D vector property.
1121
3055
  */
1122
- export type BMFont = {
1123
- /** {@inheritDoc BMFontInfo} */
1124
- info: BMFontInfo;
1125
- /** {@inheritDoc BMFontCommon} */
1126
- common: BMFontCommon;
1127
- /** {@inheritDoc BMFontPages} */
1128
- pages: BMFontPages;
1129
- /** {@inheritDoc BMFontChar} */
1130
- chars: BMFontChar[];
1131
- /** {@inheritDoc BMFontKerning} */
1132
- kernings: BMFontKerning[];
3056
+ export type Vector2Keyframe = {
3057
+ /**
3058
+ * The value at this keyframe.
3059
+ */
3060
+ value: BABYLON.IVector2Like;
3061
+ /**
3062
+ * The time at which this keyframe occurs in the animation, in frames.
3063
+ */
3064
+ time: number;
3065
+ /**
3066
+ * The easing function applied to the transition from this keyframe to the next one.
3067
+ * This is used for the first dimension of the vector.
3068
+ */
3069
+ easeFunction1: BezierCurve;
3070
+ /**
3071
+ * The easing function applied to the transition from this keyframe to the next one.
3072
+ * This is used for the second dimension of the vector.
3073
+ */
3074
+ easeFunction2: BezierCurve;
1133
3075
  };
1134
3076
 
1135
3077
 
3078
+ /**
3079
+ * Parses a lottie animation file and converts it into a format that can be rendered by Babylon.js
3080
+ * Important: not all lottie features are supported, you can call .debug() after parsing an animation to see what features were not supported.
3081
+ */
3082
+ export class AnimationParser {
3083
+ private _packer;
3084
+ private readonly _renderingManager;
3085
+ private readonly _configuration;
3086
+ private readonly _animationInfo;
3087
+ private _unsupportedFeatures;
3088
+ private _parentNodes;
3089
+ private _rootNodes;
3090
+ private _shape;
3091
+ /**
3092
+ * Get the animation information parsed from the Lottie file.
3093
+ */
3094
+ get animationInfo(): AnimationInfo;
3095
+ /**
3096
+ * Creates a new instance of the Lottie animations parser.
3097
+ * @param packer Object that packs the sprites from the animation into a texture atlas.
3098
+ * @param fileContentAsJsonString The content of the lottie file as a JSON string.
3099
+ * @param configuration Configuration options for the animation parser.
3100
+ * @param renderingManager Object that manages the rendering of the sprites in the animation.
3101
+ */
3102
+ constructor(packer: SpritePacker, fileContentAsJsonString: string, configuration: AnimationConfiguration, renderingManager: RenderingManager);
3103
+ /**
3104
+ * Logs to the console all issues that were encountered during parsing the file.
3105
+ */
3106
+ debug(): void;
3107
+ private _loadFromData;
3108
+ private _parseLayer;
3109
+ private _parseShapes;
3110
+ private _parseGroupShape;
3111
+ private _parseTransform;
3112
+ private _fromLottieScalarToBabylonScalar;
3113
+ private _fromLottieVector2ToBabylonVector2;
3114
+ private _calculateFinalVector;
3115
+ private _getScaleFactor;
3116
+ private _validatePathShape;
3117
+ private _validateRectangleShape;
3118
+ private _validateFillShape;
3119
+ private _validateGradientFillShape;
3120
+ }
3121
+
3122
+
1136
3123
  /**
1137
3124
  * BABYLON.Behavior for any content that can capture pointer events, i.e. bypass the Babylon pointer event handling
1138
3125
  * and receive pointer events directly. It will register the capture triggers and negotiate the capture and