babylonjs-addons 8.23.2 → 8.24.1

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,1313 +435,307 @@ export type BMFont = {
435
435
  };
436
436
 
437
437
  }
438
- declare module "babylonjs-addons/lottie/worker" {
439
- export {};
440
-
441
- }
442
- declare module "babylonjs-addons/lottie/lottiePlayer" {
438
+ declare module "babylonjs-addons/htmlMesh/pointerEventsCaptureBehavior" {
439
+ import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
440
+ import { Behavior } from "babylonjs/Behaviors/behavior";
443
441
  /**
444
- * Configuration options for the Lottie animation player.
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
445
445
  */
446
- export type AnimationConfiguration = {
447
- /**
448
- * Whether the animation should play on a loop or not
449
- */
450
- loopAnimation: boolean;
451
- /**
452
- * Size of the sprite atlas texture.
453
- * Default is 2048.
454
- */
455
- spriteAtlasSize: number;
456
- /**
457
- * Gap size around sprites in the atlas.
458
- * Default is 5.
459
- */
460
- gapSize: number;
461
- /**
462
- * Maximum number of sprites the renderer can handle at once.
463
- * Default is 64.
464
- */
465
- spritesCapacity: number;
466
- /**
467
- * Background color for the animation canvas.
468
- * Default is white with full opacity.
469
- */
470
- backgroundColor: {
471
- r: number;
472
- g: number;
473
- b: number;
474
- a: number;
475
- };
476
- /**
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;
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;
486
454
  /**
487
- * Number of steps to sample cubic bezier easing functions for animations.
488
- * Default is 4.
455
+ * Gets or sets the mesh that the behavior is attached to
489
456
  */
490
- easingSteps: number;
457
+ get attachedMesh(): AbstractMesh | null;
458
+ set attachedMesh(value: AbstractMesh | null);
459
+ constructor(_captureCallback: () => void, _releaseCallback: () => void, { captureOnPointerEnter }?: {
460
+ captureOnPointerEnter?: boolean | undefined;
461
+ });
491
462
  /**
492
- * Whether to ignore opacity animations for performance.
493
- * Default is true.
463
+ * Set if the behavior should capture pointer events when the pointer enters the mesh
494
464
  */
495
- ignoreOpacityAnimations: boolean;
465
+ set captureOnPointerEnter(captureOnPointerEnter: boolean);
496
466
  /**
497
- * Whether to support device lost events for WebGL contexts.
498
- * Default is false.
467
+ * Function called when the behavior needs to be initialized (before attaching it to a target)
499
468
  */
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;
469
+ init(): void;
516
470
  /**
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.
471
+ * Called when the behavior is attached to a target
472
+ * @param mesh defines the target where the behavior is attached to
521
473
  */
522
- constructor(container: HTMLDivElement, animationFile: string, configuration?: Partial<AnimationConfiguration>);
474
+ attach(mesh: AbstractMesh): void;
523
475
  /**
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.
476
+ * Called when the behavior is detached from its target
526
477
  */
527
- playAnimation(): boolean;
478
+ detach(): void;
528
479
  /**
529
- * Disposes the LottiePlayer instance, cleaning up resources and event listeners.
480
+ * Dispose the behavior
530
481
  */
531
482
  dispose(): void;
532
- private _onWindowResize;
533
- private _onBeforeUnload;
534
- }
535
-
483
+ releasePointerEvents(): void;
484
+ capturePointerEvents(): void;
536
485
  }
537
- declare module "babylonjs-addons/lottie/index" {
538
- export { LottiePlayer, AnimationConfiguration } from "babylonjs-addons/lottie/lottiePlayer";
539
486
 
540
487
  }
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";
488
+ declare module "babylonjs-addons/htmlMesh/pointerEventsCapture" {
489
+ type CaptureReleaseCallback = () => void;
548
490
  /**
549
- * Information about a sprite in the sprite atlas.
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
550
494
  */
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
- };
495
+ export const getCapturingId: () => string | null;
591
496
  /**
592
- * SpritePacker is a class that handles the packing of sprites into a texture atlas.
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
593
504
  */
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;
642
- }
643
-
644
- }
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";
505
+ export const requestCapture: (requestId: string, captureCallback: CaptureReleaseCallback, releaseCallback: CaptureReleaseCallback) => void;
649
506
  /**
650
- * Represents a sprite in the scene graph.
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
651
514
  */
652
- export class SpriteNode extends Node {
653
- private _sprite;
654
- private _originalWidth;
655
- private _originalHeight;
656
- private _firstTime;
657
- /**
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.
667
- */
668
- constructor(id: string, ignoreOpacityAnimations: boolean, sprite: ThinSprite, position?: Vector2Property, rotation?: ScalarProperty, scale?: Vector2Property, opacity?: ScalarProperty, parent?: Node);
669
- /**
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.
675
- */
676
- update(frame: number, isParentUpdated?: boolean, isReset?: boolean): boolean;
515
+ export const requestRelease: (requestId: string | null) => void;
516
+ /**
517
+ * Release pointer events from the current owner
518
+ */
519
+ export const releaseCurrent: () => void;
520
+ global {
521
+ interface Window {
522
+ "pointer-events-capture-debug": boolean | null;
523
+ }
677
524
  }
525
+ export {};
526
+
527
+ }
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 };
678
534
 
679
535
  }
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";
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";
689
542
  /**
690
- * Represents all the sprites from the animation and manages their rendering.
543
+ * A function that compares two submeshes and returns a number indicating which
544
+ * should be rendered first.
691
545
  */
692
- export class RenderingManager {
693
- private readonly _engine;
694
- private readonly _spritesRenderer;
695
- private readonly _spritesTexture;
696
- private _sprites;
697
- private readonly _configuration;
698
- /**
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.
703
- */
704
- constructor(engine: ThinEngine, spriteTexture: ThinTexture, configuration: AnimationConfiguration);
705
- /**
706
- * Adds a sprite to the rendering manager.
707
- * @param sprite Sprite to add to the rendering manager.
708
- */
709
- addSprite(sprite: ThinSprite): void;
546
+ type RenderOrderFunction = (subMeshA: SubMesh, subMeshB: SubMesh) => number;
547
+ /**
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.
556
+ */
557
+ export class HtmlMeshRenderer {
710
558
  /**
711
- * Prepares the rendering manager for rendering.
559
+ * Global scale factor applied to the homogeneous `w` component (m[15]) of the
560
+ * transformation matrix when projecting 3D objects into pixel space.
561
+ *
562
+ * This value is used to balance Babylon units against screen pixels, ensuring
563
+ * that HTML-mapped or screen-space objects appear with the correct relative
564
+ * size. Adjust with care, as changing it affects the projection scale of all
565
+ * transformed objects.
566
+ *
567
+ * The default value is `0.00001`, which works well when 1 Babylon unit
568
+ * corresponds to 1 meter, and the typical screen resolution is around
569
+ * 100 pixels per meter (i.e., 1 pixel per centimeter).
712
570
  */
713
- ready(): void;
571
+ static PROJECTION_SCALE_FACTOR: number;
572
+ private _containerId?;
573
+ private _inSceneElements?;
574
+ private _overlayElements?;
575
+ private _engine;
576
+ private _cache;
577
+ private _width;
578
+ private _height;
579
+ private _heightHalf;
580
+ private _cameraWorldMatrix?;
581
+ private _temp;
582
+ private _lastDevicePixelRatio;
583
+ private _cameraMatrixUpdated;
584
+ private _previousCanvasDocumentPosition;
585
+ private _renderObserver;
714
586
  /**
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.
587
+ * Contruct an instance of HtmlMeshRenderer
588
+ * @param scene
589
+ * @param options object containing the following optional properties:
590
+ * @returns
718
591
  */
719
- render(worldMatrix: ThinMatrix, projectionMatrix: ThinMatrix): void;
592
+ constructor(scene: Scene, { parentContainerId, _containerId, enableOverlayRender, defaultOpaqueRenderOrder, defaultAlphaTestRenderOrder, defaultTransparentRenderOrder, }?: {
593
+ parentContainerId?: string | null;
594
+ _containerId?: string;
595
+ defaultOpaqueRenderOrder?: RenderOrderFunction;
596
+ defaultAlphaTestRenderOrder?: RenderOrderFunction;
597
+ defaultTransparentRenderOrder?: RenderOrderFunction;
598
+ enableOverlayRender?: boolean;
599
+ });
720
600
  /**
721
- * Disposes the rendering manager and its resources.
601
+ * Dispose of the HtmlMeshRenderer
722
602
  */
723
603
  dispose(): void;
724
- private _customSpriteUpdate;
604
+ protected _init(scene: Scene, parentContainerId: string | null, enableOverlayRender: boolean, defaultOpaqueRenderOrder: RenderOrderFunction, defaultAlphaTestRenderOrder: RenderOrderFunction, defaultTransparentRenderOrder: RenderOrderFunction): void;
605
+ private _createRenderLayerElements;
606
+ protected _getSize(): {
607
+ width: number;
608
+ height: number;
609
+ };
610
+ protected _setSize(width: number, height: number): void;
611
+ protected _getCameraCssMatrix(matrix: Matrix): string;
612
+ protected _getHtmlContentCssMatrix(matrix: Matrix, useRightHandedSystem: boolean): string;
613
+ protected _getTransformationMatrix(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): Matrix;
614
+ protected _renderHtmlMesh(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): void;
615
+ protected _render(scene: Scene, camera: Camera): void;
616
+ protected _updateBaseScaleFactor(htmlMesh: HtmlMesh): void;
617
+ protected _updateContainerPositionIfNeeded(): void;
618
+ protected _onCameraMatrixChanged: (camera: Camera) => void;
619
+ private _epsilon;
620
+ private _getAncestorMarginsAndPadding;
725
621
  }
622
+ export {};
726
623
 
727
624
  }
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";
625
+ declare module "babylonjs-addons/htmlMesh/htmlMesh" {
626
+ import { Mesh } from "babylonjs/Meshes/mesh";
627
+ import { Scene } from "babylonjs/scene";
628
+ import { FitStrategyType } from "babylonjs-addons/htmlMesh/fitStrategy";
732
629
  /**
733
- * Represents a node in the scenegraph that contains the animation information from a lottie animation layer or group.
630
+ * This class represents HTML content that we want to render as though it is part of the scene. The HTML content is actually
631
+ * rendered below the canvas, but a depth mask is created by this class that writes to the depth buffer but does not
632
+ * write to the color buffer, effectively punching a hole in the canvas. CSS transforms are used to scale, translate, and rotate
633
+ * the HTML content so that it matches the camera and mesh orientation. The class supports interactions in editable and non-editable mode.
634
+ * 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
635
+ * in the scene).
636
+ * @see https://playground.babylonjs.com/#HVHYJC#5
637
+ * @see https://playground.babylonjs.com/#B17TC7#112
734
638
  */
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;
639
+ export class HtmlMesh extends Mesh {
752
640
  /**
753
- * Gets the id of this node.
754
- * @returns The unique identifier of this node.
641
+ * Helps identifying a html mesh from a regular mesh
755
642
  */
756
- get id(): string;
643
+ get isHtmlMesh(): boolean;
644
+ private _enabled;
645
+ private _ready;
757
646
  /**
758
- * Gets the childer of this node.
759
- * @returns An array of child nodes.
647
+ * @internal
760
648
  */
761
- get children(): Node[];
649
+ _isCanvasOverlay: boolean;
650
+ private _requiresUpdate;
651
+ private _element?;
652
+ private _width?;
653
+ private _height?;
654
+ private _inverseScaleMatrix;
655
+ private _captureOnPointerEnter;
656
+ private _pointerEventCaptureBehavior;
657
+ private _sourceWidth;
658
+ private _sourceHeight;
762
659
  /**
763
- * Gets whether this node is a shape.
764
- * @returns True if this node is a shape, false otherwise.
660
+ * Return the source width of the content in pixels
765
661
  */
766
- get isShape(): boolean;
662
+ get sourceWidth(): number | null;
767
663
  /**
768
- * Gets the world matrix of this node.
769
- * @returns The world matrix.
664
+ * Return the source height of the content in pixels
770
665
  */
771
- get worldMatrix(): ThinMatrix;
666
+ get sourceHeight(): number | null;
667
+ private _worldMatrixUpdateObserver;
668
+ private _fitStrategy;
772
669
  /**
773
- * Gets whether this node is animated.
774
- * @returns True if this node has animations, false otherwise.
670
+ * Contruct an instance of HtmlMesh
671
+ * @param scene
672
+ * @param id The id of the mesh. Will be used as the id of the HTML element as well.
673
+ * @param options object with optional parameters
775
674
  */
776
- get isAnimated(): boolean;
675
+ constructor(scene: Scene, id: string, { captureOnPointerEnter, isCanvasOverlay, fitStrategy }?: {
676
+ captureOnPointerEnter?: boolean | undefined;
677
+ isCanvasOverlay?: boolean | undefined;
678
+ fitStrategy?: FitStrategyType | undefined;
679
+ });
777
680
  /**
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.
681
+ * The width of the content in pixels
781
682
  */
782
- get opacity(): number;
683
+ get width(): number | undefined;
783
684
  /**
784
- * Gets the initial scale of this node.
785
- * @returns The initial scale.
685
+ * The height of the content in pixels
786
686
  */
787
- get startScale(): IVector2Like;
687
+ get height(): number | undefined;
788
688
  /**
789
- * Gets the parent node of this node.
790
- * @returns The parent node, or undefined if this is a root node.
689
+ * The HTML element that is being rendered as a mesh
791
690
  */
792
- get parent(): Node | undefined;
691
+ get element(): HTMLElement | undefined;
793
692
  /**
794
- * Sets the node visibility.
795
- * @param value The new visibility value.
693
+ * True if the mesh has been moved, rotated, or scaled since the last time this
694
+ * property was read. This property is reset to false after reading.
796
695
  */
797
- set isVisible(value: boolean);
696
+ get requiresUpdate(): boolean;
798
697
  /**
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.
698
+ * Enable capture for the pointer when entering the mesh area
807
699
  */
808
- constructor(id: string, ignoreOpacityAnimations: boolean, position?: Vector2Property, rotation?: ScalarProperty, scale?: Vector2Property, opacity?: ScalarProperty, parent?: Node);
700
+ set captureOnPointerEnter(captureOnPointerEnter: boolean);
809
701
  /**
810
- * Resets the node's properties to their initial values.
811
- */
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;
825
- }
826
-
827
- }
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.
702
+ * Disposes of the mesh and the HTML element
930
703
  */
931
704
  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;
1054
- };
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;
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
705
  /**
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.
706
+ * @internal
1398
707
  */
1399
- easeFunction1: BezierCurve;
708
+ _markAsUpdated(): void;
1400
709
  /**
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.
710
+ * Sets the content of the element to the specified content adjusting the mesh scale to match and making it visible.
711
+ * If the the specified content is undefined, then it will make the mesh invisible. In either case it will clear the
712
+ * element content first.
713
+ * @param element The element to render as a mesh
714
+ * @param width The width of the mesh in Babylon units
715
+ * @param height The height of the mesh in Babylon units
1403
716
  */
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;
717
+ setContent(element: HTMLElement, width: number, height: number): void;
718
+ setEnabled(enabled: boolean): void;
1426
719
  /**
1427
- * Get the animation information parsed from the Lottie file.
720
+ * Sets the content size in pixels
721
+ * @param width width of the source
722
+ * @param height height of the source
1428
723
  */
1429
- get animationInfo(): AnimationInfo;
724
+ setContentSizePx(width: number, height: number): void;
725
+ protected _setAsReady(ready: boolean): void;
726
+ protected _doSetEnabled(enabled: boolean): void;
727
+ protected _updateScaleIfNecessary(): void;
728
+ protected _createMask(): void;
729
+ protected _setElementzIndex(zIndex: number): void;
1430
730
  /**
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.
731
+ * Callback used by the PointerEventsCaptureBehavior to capture pointer events
1436
732
  */
1437
- constructor(packer: SpritePacker, fileContentAsJsonString: string, configuration: AnimationConfiguration, renderingManager: RenderingManager);
733
+ capturePointerEvents(): void;
1438
734
  /**
1439
- * Logs to the console all issues that were encountered during parsing the file.
735
+ * Callback used by the PointerEventsCaptureBehavior to release pointer events
1440
736
  */
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;
737
+ releasePointerEvents(): void;
738
+ protected _createElement(): HTMLDivElement | undefined;
1745
739
  }
1746
740
 
1747
741
  }
@@ -1749,1377 +743,410 @@ declare module "babylonjs-addons/htmlMesh/fitStrategy" {
1749
743
  export type FitStrategyType = {
1750
744
  wrapElement(element: HTMLElement): HTMLElement;
1751
745
  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
- }
746
+ };
747
+ export const FitStrategy: {
748
+ CONTAIN: FitStrategyType;
749
+ COVER: FitStrategyType;
750
+ STRETCH: FitStrategyType;
751
+ NONE: FitStrategyType;
752
+ };
2250
753
 
754
+ }
2251
755
 
756
+ declare module "babylonjs-addons" {
757
+ export * from "babylonjs-addons/index";
758
+ }
2252
759
 
2253
760
 
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
- }
761
+ declare module ADDONS {
2349
762
 
2350
763
 
2351
764
  /**
2352
- * Represents a sprite in the scene graph.
765
+ * Abstract Node class from Babylon.js
2353
766
  */
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;
767
+ export interface INodeLike {
768
+ getWorldMatrix(): BABYLON.IMatrixLike;
2379
769
  }
2380
-
2381
-
2382
770
  /**
2383
- * Represents all the sprites from the animation and manages their rendering.
771
+ * Class used to render text using MSDF (Multi-channel Signed Distance Field) technique
772
+ * Thanks a lot to the work of Bhushan_Wagh and zb_sj for their amazing work on MSDF for Babylon.js
773
+ * #6RLCWP#16
774
+ * Star wars scroller: #6RLCWP#29
775
+ * With metrics: #6RLCWP#35
776
+ * Thickness: #IABMEZ#3
777
+ * Solar system: #9YCDYC#9
778
+ * Stroke: #6RLCWP#37
2384
779
  */
2385
- export class RenderingManager {
2386
- private readonly _engine;
2387
- private readonly _spritesRenderer;
2388
- private readonly _spritesTexture;
2389
- private _sprites;
2390
- private readonly _configuration;
2391
- /**
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.
2396
- */
2397
- constructor(engine: BABYLON.ThinEngine, spriteTexture: BABYLON.ThinTexture, configuration: AnimationConfiguration);
2398
- /**
2399
- * Adds a sprite to the rendering manager.
2400
- * @param sprite Sprite to add to the rendering manager.
2401
- */
2402
- addSprite(sprite: BABYLON.ThinSprite): void;
780
+ export class TextRenderer implements BABYLON.IDisposable {
781
+ private readonly _useVAO;
782
+ private _engine;
783
+ private _shaderLanguage;
784
+ private _vertexBuffers;
785
+ private _spriteBuffer;
786
+ private _worldBuffer;
787
+ private _uvBuffer;
788
+ private _drawWrapperBase;
789
+ private _vertexArrayObject;
790
+ private _font;
791
+ private _charMatrices;
792
+ private _charUvs;
793
+ private _isDirty;
794
+ private _baseLine;
795
+ private _scalingMatrix;
796
+ private _fontScaleMatrix;
797
+ private _offsetMatrix;
798
+ private _translationMatrix;
799
+ private _baseMatrix;
800
+ private _scaledMatrix;
801
+ private _localMatrix;
802
+ private _finalMatrix;
803
+ private _lineMatrix;
804
+ private _parentWorldMatrix;
2403
805
  /**
2404
- * Prepares the rendering manager for rendering.
806
+ * Gets or sets the color of the text
2405
807
  */
2406
- ready(): void;
808
+ color: BABYLON.IColor4Like;
2407
809
  /**
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.
810
+ * Gets or sets the color of the stroke around the text
2411
811
  */
2412
- render(worldMatrix: ThinMatrix, projectionMatrix: ThinMatrix): void;
812
+ strokeColor: BABYLON.IColor4Like;
2413
813
  /**
2414
- * Disposes the rendering manager and its resources.
814
+ * Gets or sets the width of the stroke around the text (inset)
2415
815
  */
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;
816
+ strokeInsetWidth: number;
2441
817
  /**
2442
- * Gets the id of this node.
2443
- * @returns The unique identifier of this node.
818
+ * Gets or sets the width of the stroke around the text (outset)
2444
819
  */
2445
- get id(): string;
820
+ strokeOutsetWidth: number;
2446
821
  /**
2447
- * Gets the childer of this node.
2448
- * @returns An array of child nodes.
822
+ * Gets or sets the thickness of the text (0 means as defined in the font)
823
+ * Value must be between -0.5 and 0.5
2449
824
  */
2450
- get children(): Node[];
825
+ thicknessControl: number;
826
+ private _parent;
2451
827
  /**
2452
- * Gets whether this node is a shape.
2453
- * @returns True if this node is a shape, false otherwise.
828
+ * Gets or sets the parent of the text renderer
2454
829
  */
2455
- get isShape(): boolean;
830
+ get parent(): BABYLON.Nullable<INodeLike>;
831
+ set parent(value: BABYLON.Nullable<INodeLike>);
832
+ private _transformMatrix;
2456
833
  /**
2457
- * Gets the world matrix of this node.
2458
- * @returns The world matrix.
834
+ * Gets or sets the transform matrix of the text renderer
835
+ * It will be applied in that order:
836
+ * parent x transform x paragraph world
2459
837
  */
2460
- get worldMatrix(): ThinMatrix;
838
+ get transformMatrix(): BABYLON.IMatrixLike;
839
+ set transformMatrix(value: BABYLON.IMatrixLike);
2461
840
  /**
2462
- * Gets whether this node is animated.
2463
- * @returns True if this node has animations, false otherwise.
841
+ * Gets or sets if the text is billboarded
2464
842
  */
2465
- get isAnimated(): boolean;
843
+ isBillboard: boolean;
2466
844
  /**
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.
845
+ * Gets or sets if the text is screen projected
846
+ * This will work only if the text is billboarded
2470
847
  */
2471
- get opacity(): number;
848
+ isBillboardScreenProjected: boolean;
2472
849
  /**
2473
- * Gets the initial scale of this node.
2474
- * @returns The initial scale.
850
+ * Gets the number of characters in the text renderer
2475
851
  */
2476
- get startScale(): BABYLON.IVector2Like;
852
+ get characterCount(): number;
2477
853
  /**
2478
- * Gets the parent node of this node.
2479
- * @returns The parent node, or undefined if this is a root node.
854
+ * Gets or sets if the text renderer should ignore the depth buffer
855
+ * Default is false
2480
856
  */
2481
- get parent(): Node | undefined;
857
+ ignoreDepthBuffer: boolean;
858
+ private constructor();
859
+ private _resizeBuffers;
860
+ private _setShaders;
2482
861
  /**
2483
- * Sets the node visibility.
2484
- * @param value The new visibility value.
862
+ * Add a paragraph of text to the renderer
863
+ * @param text define the text to add
864
+ * @param options define the options to use for the paragraph (optional)
865
+ * @param worldMatrix define the world matrix to use for the paragraph (optional)
2485
866
  */
2486
- set isVisible(value: boolean);
867
+ addParagraph(text: string, options?: Partial<ParagraphOptions>, worldMatrix?: BABYLON.IMatrixLike): void;
2487
868
  /**
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
+ * Render the text using the provided view and projection matrices
870
+ * @param viewMatrix define the view matrix to use
871
+ * @param projectionMatrix define the projection matrix to use
2496
872
  */
2497
- constructor(id: string, ignoreOpacityAnimations: boolean, position?: Vector2Property, rotation?: ScalarProperty, scale?: Vector2Property, opacity?: ScalarProperty, parent?: Node);
873
+ render(viewMatrix: BABYLON.IMatrixLike, projectionMatrix: BABYLON.IMatrixLike): void;
2498
874
  /**
2499
- * Resets the node's properties to their initial values.
875
+ * Release associated resources
2500
876
  */
2501
- reset(): void;
877
+ dispose(): void;
2502
878
  /**
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.
879
+ * Creates a new TextRenderer instance asynchronously
880
+ * @param font define the font asset to use
881
+ * @param engine define the engine to use
882
+ * @returns a promise that resolves to the created TextRenderer instance
2508
883
  */
2509
- update(frame: number, isParentUpdated?: boolean, isReset?: boolean): boolean;
2510
- private _updatePosition;
2511
- private _updateRotation;
2512
- private _updateScale;
2513
- private _updateOpacity;
884
+ static CreateTextRendererAsync(font: FontAsset, engine: BABYLON.AbstractEngine): Promise<TextRenderer>;
2514
885
  }
2515
886
 
2516
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
+ /** @internal */
889
+ export type ParagraphOptions = {
890
+ maxWidth: number;
891
+ lineHeight: number;
892
+ letterSpacing: number;
893
+ tabSize: number;
894
+ whiteSpace: "pre-line";
895
+ textAlign: "left" | "right" | "center";
896
+ translate: BABYLON.IVector2Like | undefined;
897
+ };
898
+ /** @internal */
899
+ export var DefaultParagraphOptions: ParagraphOptions;
900
+
901
+
2547
902
 
2548
903
 
2549
904
  /**
2550
- * Class that controls the playing of lottie animations using Babylon.js
905
+ * Class representing a font asset for SDF (Signed Distance Field) rendering.
2551
906
  */
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;
2572
- /**
2573
- * Gets the canvas used for rendering the animation.
2574
- * @returns The canvas element used for rendering.
2575
- */
2576
- get view(): HTMLCanvasElement;
2577
- /**
2578
- * Gets the height of the animation in pixels.
2579
- * @returns The height of the animation in pixels.
2580
- */
2581
- get animationHeight(): number;
2582
- /**
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;
907
+ export class FontAsset implements BABYLON.IDisposable {
908
+ private readonly _chars;
909
+ private readonly _charsRegex;
910
+ private readonly _kernings;
911
+ /** @internal */
912
+ readonly _font: SdfFont;
2599
913
  /**
2600
- * Stops the animation playback.
914
+ * Gets the font scale value
2601
915
  */
2602
- stopAnimation(): void;
916
+ readonly scale: number;
2603
917
  /**
2604
- * Sets the rendering size for the engine
2605
- * @param width Width of the rendering canvas
2606
- * @param height Height of the rendering canvas
918
+ * Gets the list of used textures
2607
919
  */
2608
- setSize(width: number, height: number): void;
920
+ readonly textures: BABYLON.Texture[];
2609
921
  /**
2610
- * Disposes the player and releases all resources.
922
+ * Creates a new FontAsset instance.
923
+ * @param definitionData defines the font data in JSON format.
924
+ * @param textureUrl defines the url of the texture to use for the font.
925
+ * @param scene defines the hosting scene.
2611
926
  */
927
+ constructor(definitionData: string, textureUrl: string, scene?: BABYLON.Scene);
2612
928
  dispose(): void;
2613
- private _cleanTree;
2614
- private _startRenderLoop;
2615
- private _render;
929
+ private _updateFallbacks;
930
+ /** @internal */
931
+ _getChar(charCode: number): BMFontChar;
932
+ /** @internal */
933
+ _getKerning(first: number, second: number): number;
934
+ /** @internal */
935
+ _unsupportedChars(text: string): string;
2616
936
  }
2617
937
 
2618
938
 
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;
939
+ /** @internal */
940
+ export var msdfVertexShaderWGSL: {
941
+ name: string;
942
+ shader: string;
943
+ };
944
+
945
+
946
+ /** @internal */
947
+ export var msdfPixelShaderWGSL: {
948
+ name: string;
949
+ shader: string;
950
+ };
951
+
952
+
953
+ /** @internal */
954
+ export var msdfVertexShader: {
955
+ name: string;
956
+ shader: string;
957
+ };
958
+
959
+
960
+ /** @internal */
961
+ export var msdfPixelShader: {
962
+ name: string;
963
+ shader: string;
964
+ };
965
+
966
+
967
+ /** @internal */
968
+ export class SdfTextParagraph {
969
+ readonly text: string;
970
+ readonly fontAsset: FontAsset;
971
+ readonly options: ParagraphOptions;
972
+ get lineHeight(): number;
973
+ readonly paragraph: string;
974
+ readonly lines: SdfTextLine[];
975
+ readonly width: number;
976
+ readonly height: number;
977
+ readonly glyphs: SdfGlyph[];
978
+ constructor(text: string, fontAsset: FontAsset, options?: Partial<ParagraphOptions>);
979
+ private _computeMetrics;
980
+ private _breakLines;
981
+ private _collapse;
982
+ private _wrap;
2707
983
  }
2708
984
 
2709
985
 
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
- */
986
+ /** @internal */
987
+ export type SdfTextLine = {
988
+ text: string;
989
+ glyphs: SdfGlyph[];
990
+ start: number;
991
+ end: number;
2721
992
  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;
2730
993
  };
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;
2737
994
 
2738
995
 
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
- }
2783
996
 
2784
997
 
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[];
2794
- };
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[];
2809
- };
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[];
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[];
998
+ /** @internal */
999
+ export type SdfGlyph = {
1000
+ char: BMFontChar;
1001
+ /** index of the line */
1002
+ line: number;
1003
+ /** position within the line */
1004
+ position: number;
1005
+ x: number;
1006
+ y: number;
2920
1007
  };
2921
- export type RawKeyFrameEasing = {
2922
- x: number | number[];
2923
- y: number | number[];
1008
+
1009
+
1010
+ export type SdfFontDistanceField = {
1011
+ fieldType: "sdf" | "msdf";
1012
+ distanceRange: number;
2924
1013
  };
2925
- export type RawBezier = {
2926
- c: boolean;
2927
- i: number[][];
2928
- o: number[][];
2929
- v: number[][];
1014
+ export type SdfFont = BMFont & {
1015
+ distanceField: SdfFontDistanceField;
2930
1016
  };
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;
2937
1017
 
2938
1018
 
2939
1019
  /**
2940
- * Represents a Babylon.js thin version of a Lottie animation.
1020
+ * Holds information on how the font was generated.
2941
1021
  */
2942
- export type AnimationInfo = {
2943
- /**
2944
- * Frame number where the animation starts.
2945
- */
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;
1022
+ export type BMFontInfo = {
1023
+ /** The name of the font */
1024
+ face: string;
1025
+ /** The size of the font */
1026
+ size: number;
1027
+ /** The font is bold */
1028
+ bold: number;
1029
+ /** The font is italic */
1030
+ italic: number;
1031
+ /** The charset of the font */
1032
+ charset: string[];
1033
+ /** The charset is unicode */
1034
+ unicode: number;
1035
+ /** The font height stretch in percentage. 100% means no stretch. */
1036
+ stretchH: number;
1037
+ /** Set to 1 if smoothing was turned on. */
1038
+ smooth: number;
1039
+ /** The supersampling level used. 1 means no supersampling was used. */
1040
+ aa: number;
1041
+ /** The padding for each character (up, right, down, left). */
1042
+ padding: [number, number, number, number];
1043
+ /** The spacing for each character (horizontal, vertical). */
1044
+ spacing: [number, number];
2963
1045
  /**
2964
- * Nodes representing the animation
1046
+ * The outline thickness for the characters.
1047
+ *
1048
+ * @remark missing in msdf-bmfont-xml
2965
1049
  */
2966
- nodes: Node[];
1050
+ outline?: number;
2967
1051
  };
2968
1052
  /**
2969
- * Transform properties for a Lottie animation.
2970
- * Any of these properties may be animated.
1053
+ * Holds information common to all characters.
2971
1054
  */
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;
1055
+ export type BMFontCommon = {
1056
+ /** Distance in pixels between each line of text */
1057
+ lineHeight: number;
1058
+ /** The number of pixels from the absolute top of the line to the base of the characters */
1059
+ base: number;
1060
+ /** The width of the texture, normally used to scale the x pos of the character image */
1061
+ scaleW: number;
1062
+ /** The height of the texture, normally used to scale the y pos of the character image */
1063
+ scaleH: number;
1064
+ /** The number of pages in the font */
1065
+ pages: number;
1066
+ /** 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. */
1067
+ packed: number;
1068
+ /** 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. */
1069
+ alphaChnl: number;
1070
+ /** 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. */
1071
+ redChnl: number;
1072
+ /** 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. */
1073
+ greenChnl: number;
1074
+ /** 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. */
1075
+ blueChnl: number;
2993
1076
  };
1077
+ /** Name of a texture file. There is one for each page in the font. */
1078
+ export type BMFontPages = {
1079
+ [id: number]: string;
1080
+ } & Array<string>;
2994
1081
  /**
2995
- * Represents a scalar that can be animated.
1082
+ * Describes a single character in the font
2996
1083
  */
2997
- export type ScalarProperty = {
2998
- /**
2999
- * The initial value of the property at the start of the animation.
3000
- */
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.
1084
+ export type BMFontChar = {
1085
+ /** Character id (charCode) */
1086
+ id: number;
1087
+ /** Left position of the character image in the texture. */
1088
+ x: number;
1089
+ /** Right position of the character image in the texture */
1090
+ y: number;
1091
+ /** Width of the chracter image in the texture */
1092
+ width: number;
1093
+ /** Height of the chracter image in the texture */
1094
+ height: number;
1095
+ /** Horizontal offset to be applied on screen */
1096
+ xoffset: number;
1097
+ /** Vertical offset to be applied on screen */
1098
+ yoffset: number;
1099
+ /** Horizontal advance after the character */
1100
+ xadvance: number;
1101
+ /** Page index where the character image is found */
1102
+ page: number;
1103
+ /** Texture channel where the chracter image is found
1104
+ * - 1 = blue
1105
+ * - 2 = green
1106
+ * - 3 = red
1107
+ * - 8 = alpha
1108
+ * - 15 = all channels
3012
1109
  */
3013
- currentKeyframeIndex: number;
3014
- };
1110
+ chnl: number;
1111
+ } & BMFontCharExtra;
3015
1112
  /**
3016
- * Represents a keyframe for a scalar property.
1113
+ * additional context from msdf-bmfont-xml
3017
1114
  */
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;
1115
+ export type BMFontCharExtra = {
1116
+ /** index of opentype.js glyph */
1117
+ index: number;
1118
+ /** actual character*/
1119
+ char: string;
3031
1120
  };
3032
1121
  /**
3033
- * Represents a 2D vector that can be animated.
1122
+ * 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.
3034
1123
  */
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;
1124
+ export type BMFontKerning = {
1125
+ /** The first character id. */
1126
+ first: number;
1127
+ /** The second character id. */
1128
+ second: number;
1129
+ /** How much the x position should be adjusted when drawing the second character immediately following the first. */
1130
+ amount: number;
3052
1131
  };
3053
1132
  /**
3054
- * Represents a keyframe for a 2D vector property.
1133
+ * Compatible with [msdf-bmfont-xml](https://github.com/soimy/msdf-bmfont-xml)
1134
+ * @see https://www.angelcode.com/products/bmfont/doc/file_format.html
3055
1135
  */
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;
1136
+ export type BMFont = {
1137
+ /** {@inheritDoc BMFontInfo} */
1138
+ info: BMFontInfo;
1139
+ /** {@inheritDoc BMFontCommon} */
1140
+ common: BMFontCommon;
1141
+ /** {@inheritDoc BMFontPages} */
1142
+ pages: BMFontPages;
1143
+ /** {@inheritDoc BMFontChar} */
1144
+ chars: BMFontChar[];
1145
+ /** {@inheritDoc BMFontKerning} */
1146
+ kernings: BMFontKerning[];
3075
1147
  };
3076
1148
 
3077
1149
 
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
-
3123
1150
  /**
3124
1151
  * BABYLON.Behavior for any content that can capture pointer events, i.e. bypass the Babylon pointer event handling
3125
1152
  * and receive pointer events directly. It will register the capture triggers and negotiate the capture and
@@ -3224,6 +1251,20 @@ declare module ADDONS {
3224
1251
  * created before.
3225
1252
  */
3226
1253
  export class HtmlMeshRenderer {
1254
+ /**
1255
+ * Global scale factor applied to the homogeneous `w` component (m[15]) of the
1256
+ * transformation matrix when projecting 3D objects into pixel space.
1257
+ *
1258
+ * This value is used to balance Babylon units against screen pixels, ensuring
1259
+ * that HTML-mapped or screen-space objects appear with the correct relative
1260
+ * size. Adjust with care, as changing it affects the projection scale of all
1261
+ * transformed objects.
1262
+ *
1263
+ * The default value is `0.00001`, which works well when 1 Babylon unit
1264
+ * corresponds to 1 meter, and the typical screen resolution is around
1265
+ * 100 pixels per meter (i.e., 1 pixel per centimeter).
1266
+ */
1267
+ static PROJECTION_SCALE_FACTOR: number;
3227
1268
  private _containerId?;
3228
1269
  private _inSceneElements?;
3229
1270
  private _overlayElements?;