@babylonjs/addons 8.22.2 → 8.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/lottie/index.d.ts +1 -0
  2. package/lottie/index.js +3 -0
  3. package/lottie/index.js.map +1 -0
  4. package/lottie/lottie/animationParser.d.ts +47 -0
  5. package/lottie/lottie/animationParser.js +368 -0
  6. package/lottie/lottie/animationParser.js.map +1 -0
  7. package/lottie/lottie/parsedTypes.d.ts +140 -0
  8. package/lottie/lottie/parsedTypes.js +2 -0
  9. package/lottie/lottie/parsedTypes.js.map +1 -0
  10. package/lottie/lottie/rawTypes.d.ts +152 -0
  11. package/lottie/lottie/rawTypes.js +4 -0
  12. package/lottie/lottie/rawTypes.js.map +1 -0
  13. package/lottie/lottiePlayer.d.ts +92 -0
  14. package/lottie/lottiePlayer.js +101 -0
  15. package/lottie/lottiePlayer.js.map +1 -0
  16. package/lottie/maths/bezier.d.ts +44 -0
  17. package/lottie/maths/bezier.js +53 -0
  18. package/lottie/maths/bezier.js.map +1 -0
  19. package/lottie/maths/boundingBox.d.ts +28 -0
  20. package/lottie/maths/boundingBox.js +155 -0
  21. package/lottie/maths/boundingBox.js.map +1 -0
  22. package/lottie/maths/matrix.d.ts +91 -0
  23. package/lottie/maths/matrix.js +174 -0
  24. package/lottie/maths/matrix.js.map +1 -0
  25. package/lottie/rendering/animationController.d.ts +72 -0
  26. package/lottie/rendering/animationController.js +210 -0
  27. package/lottie/rendering/animationController.js.map +1 -0
  28. package/lottie/rendering/controlNode.d.ts +32 -0
  29. package/lottie/rendering/controlNode.js +39 -0
  30. package/lottie/rendering/controlNode.js.map +1 -0
  31. package/lottie/rendering/node.d.ts +97 -0
  32. package/lottie/rendering/node.js +331 -0
  33. package/lottie/rendering/node.js.map +1 -0
  34. package/lottie/rendering/renderingManager.d.ts +45 -0
  35. package/lottie/rendering/renderingManager.js +61 -0
  36. package/lottie/rendering/renderingManager.js.map +1 -0
  37. package/lottie/sprites/spriteNode.d.ts +32 -0
  38. package/lottie/sprites/spriteNode.js +52 -0
  39. package/lottie/sprites/spriteNode.js.map +1 -0
  40. package/lottie/sprites/spritePacker.d.ts +101 -0
  41. package/lottie/sprites/spritePacker.js +237 -0
  42. package/lottie/sprites/spritePacker.js.map +1 -0
  43. package/lottie/worker.d.ts +1 -0
  44. package/lottie/worker.js +39 -0
  45. package/lottie/worker.js.map +1 -0
  46. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parsedTypes.js","sourceRoot":"","sources":["../../../../../dev/addons/src/lottie/lottie/parsedTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { IVector2Like } from \"core/Maths/math.like\";\r\n\r\nimport type { BezierCurve } from \"../maths/bezier\";\r\n\r\nimport type { Node } from \"../rendering/node\";\r\n\r\n/**\r\n * Represents a Babylon.js thin version of a Lottie animation.\r\n */\r\nexport type AnimationInfo = {\r\n /**\r\n * Frame number where the animation starts.\r\n */\r\n startFrame: number;\r\n /**\r\n * Frame number where the animation ends.\r\n */\r\n endFrame: number;\r\n /**\r\n * Frame rate of the animation.\r\n */\r\n frameRate: number;\r\n /**\r\n * Width of the animation in pixels\r\n */\r\n widthPx: number;\r\n /**\r\n * Height of the animation in pixels\r\n */\r\n heightPx: number;\r\n /**\r\n * Nodes representing the animation\r\n */\r\n nodes: Node[];\r\n};\r\n\r\n/**\r\n * Transform properties for a Lottie animation.\r\n * Any of these properties may be animated.\r\n */\r\nexport type Transform = {\r\n /**\r\n * The anchor point of the layer, which is the point around which transformations are applied.\r\n */\r\n anchorPoint: Vector2Property;\r\n /**\r\n * The position of the layer in the animation.\r\n */\r\n position: Vector2Property;\r\n /**\r\n * The rotation of the layer in degrees.\r\n */\r\n rotation: ScalarProperty;\r\n /**\r\n * The scale of the layer in the X and Y axis.\r\n */\r\n scale: Vector2Property;\r\n /**\r\n * The opacity of the layer, represented as a scalar value.\r\n */\r\n opacity: ScalarProperty;\r\n};\r\n\r\n/**\r\n * Represents a scalar that can be animated.\r\n */\r\nexport type ScalarProperty = {\r\n /**\r\n * The initial value of the property at the start of the animation.\r\n */\r\n startValue: number;\r\n /**\r\n * The current value of the property during the animation.\r\n */\r\n currentValue: number;\r\n /**\r\n * An array of keyframes for the property.\r\n */\r\n keyframes?: ScalarKeyframe[];\r\n /**\r\n * The index of the current keyframe being processed in the animation.\r\n */\r\n currentKeyframeIndex: number;\r\n};\r\n\r\n/**\r\n * Represents a keyframe for a scalar property.\r\n */\r\nexport type ScalarKeyframe = {\r\n /**\r\n * The value at this keyframe.\r\n */\r\n value: number;\r\n /**\r\n * The time at which this keyframe occurs in the animation, in frames.\r\n */\r\n time: number;\r\n /**\r\n * The easing function applied to the transition from this keyframe to the next one.\r\n */\r\n easeFunction: BezierCurve;\r\n};\r\n\r\n/**\r\n * Represents a 2D vector that can be animated.\r\n */\r\nexport type Vector2Property = {\r\n /**\r\n * The initial value at the start of the animation.\r\n */\r\n startValue: IVector2Like;\r\n /**\r\n * The current value during the animation.\r\n */\r\n currentValue: IVector2Like;\r\n /**\r\n * An array of keyframes for the property.\r\n */\r\n keyframes?: Vector2Keyframe[];\r\n /**\r\n * The index of the current keyframe being processed in the animation.\r\n */\r\n currentKeyframeIndex: number;\r\n};\r\n\r\n/**\r\n * Represents a keyframe for a 2D vector property.\r\n */\r\nexport type Vector2Keyframe = {\r\n /**\r\n * The value at this keyframe.\r\n */\r\n value: IVector2Like;\r\n /**\r\n * The time at which this keyframe occurs in the animation, in frames.\r\n */\r\n time: number;\r\n /**\r\n * The easing function applied to the transition from this keyframe to the next one.\r\n * This is used for the first dimension of the vector.\r\n */\r\n easeFunction1: BezierCurve;\r\n /**\r\n * The easing function applied to the transition from this keyframe to the next one.\r\n * This is used for the second dimension of the vector.\r\n */\r\n easeFunction2: BezierCurve;\r\n};\r\n"]}
@@ -0,0 +1,152 @@
1
+ export type RawLottieAnimation = {
2
+ v: string;
3
+ fr: number;
4
+ ip: number;
5
+ op: number;
6
+ w: number;
7
+ h: number;
8
+ nm?: string;
9
+ layers: RawLottieLayer[];
10
+ };
11
+ export type RawLottieLayer = {
12
+ ind?: number;
13
+ ty: RawLayerType;
14
+ nm?: string;
15
+ parent?: number;
16
+ hd?: boolean;
17
+ sr?: number;
18
+ ao?: number;
19
+ ip?: number;
20
+ op?: number;
21
+ st?: number;
22
+ ct?: number;
23
+ ks: RawTransform;
24
+ shapes?: RawGraphicElement[];
25
+ };
26
+ export type RawGraphicElement = {
27
+ nm?: string;
28
+ hd?: boolean;
29
+ ty: RawShapeType;
30
+ bm?: number;
31
+ ix?: number;
32
+ };
33
+ export type RawGroupShape = RawGraphicElement & {
34
+ it?: RawGraphicElement[];
35
+ };
36
+ export type RawRectangleShape = RawGraphicElement & {
37
+ d: RawShapeDirection;
38
+ p: RawPositionProperty;
39
+ s: RawVectorProperty;
40
+ r: RawScalarProperty;
41
+ };
42
+ export type RawPathShape = RawGraphicElement & {
43
+ d: RawShapeDirection;
44
+ ks: RawBezierShapeProperty;
45
+ };
46
+ export type RawFillShape = RawGraphicElement & {
47
+ o: RawScalarProperty;
48
+ c: RawColorProperty;
49
+ r: RawFillRule;
50
+ };
51
+ export type RawGradientFillShape = RawGraphicElement & {
52
+ o: RawScalarProperty;
53
+ g: RawGradientsProperty;
54
+ s: RawPositionProperty;
55
+ e: RawPositionProperty;
56
+ t: RawGradientType;
57
+ h: RawScalarProperty;
58
+ a?: RawScalarProperty;
59
+ r: RawFillRule;
60
+ };
61
+ export type RawTransformShape = RawGraphicElement & {
62
+ a: RawPositionProperty;
63
+ p: RawPositionProperty;
64
+ r: RawScalarProperty;
65
+ s: RawVectorProperty;
66
+ o: RawScalarProperty;
67
+ sk: RawScalarProperty;
68
+ sa: RawScalarProperty;
69
+ };
70
+ export type RawTransform = {
71
+ a?: RawPositionProperty;
72
+ p?: RawPositionProperty;
73
+ r?: RawScalarProperty;
74
+ s?: RawVectorProperty;
75
+ o?: RawScalarProperty;
76
+ };
77
+ export type RawScalarProperty = {
78
+ a: RawNumberBoolean;
79
+ k: number | RawVectorKeyframe[];
80
+ };
81
+ export type RawVectorProperty = {
82
+ a: RawNumberBoolean;
83
+ k: number[] | RawVectorKeyframe[];
84
+ l: number;
85
+ };
86
+ export type RawVectorKeyframe = {
87
+ t: number;
88
+ s: number[];
89
+ h?: RawNumberBoolean;
90
+ i?: RawKeyFrameEasing;
91
+ o?: RawKeyFrameEasing;
92
+ };
93
+ export type RawPositionProperty = {
94
+ a: RawNumberBoolean;
95
+ k: number[] | RawPositionKeyframe[];
96
+ l: number;
97
+ };
98
+ export type RawPositionKeyframe = {
99
+ t: number;
100
+ h?: RawNumberBoolean;
101
+ i?: RawKeyFrameEasing;
102
+ o?: RawKeyFrameEasing;
103
+ s: number[];
104
+ ti: number[];
105
+ to: number[];
106
+ };
107
+ export type RawBezierShapeProperty = {
108
+ a: RawNumberBoolean;
109
+ k: RawBezier | RawBezierShapeKeyframe[];
110
+ };
111
+ export type RawBezierShapeKeyframe = {
112
+ t: number;
113
+ h?: RawNumberBoolean;
114
+ i?: RawKeyFrameEasing;
115
+ o?: RawKeyFrameEasing;
116
+ s: RawBezier[];
117
+ };
118
+ export type RawColorProperty = {
119
+ a: RawNumberBoolean;
120
+ k: number[] | RawColorKeyframe[];
121
+ };
122
+ export type RawColorKeyframe = {
123
+ t: number;
124
+ h?: RawNumberBoolean;
125
+ i?: RawKeyFrameEasing;
126
+ o?: RawKeyFrameEasing;
127
+ s: number[];
128
+ };
129
+ export type RawGradientsProperty = {
130
+ p: number;
131
+ k: RawGradientProperty;
132
+ };
133
+ export type RawGradientProperty = {
134
+ a: RawNumberBoolean;
135
+ k: number[];
136
+ };
137
+ export type RawKeyFrameEasing = {
138
+ x: number | number[];
139
+ y: number | number[];
140
+ };
141
+ export type RawBezier = {
142
+ c: boolean;
143
+ i: number[][];
144
+ o: number[][];
145
+ v: number[][];
146
+ };
147
+ export type RawNumberBoolean = 0 | 1;
148
+ export type RawLayerType = 0 | 1 | 2 | 3 | 4 | 5 | 6;
149
+ export type RawShapeType = "fl" | "gf" | "gr" | "tr" | "sh" | "rc";
150
+ export type RawShapeDirection = 1 | 3;
151
+ export type RawFillRule = 1 | 2;
152
+ export type RawGradientType = 1 | 2;
@@ -0,0 +1,4 @@
1
+ /* eslint-disable jsdoc/require-jsdoc */
2
+ /* eslint-disable @typescript-eslint/no-unused-vars */
3
+ export {};
4
+ //# sourceMappingURL=rawTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rawTypes.js","sourceRoot":"","sources":["../../../../../dev/addons/src/lottie/lottie/rawTypes.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,sDAAsD","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\r\n/* eslint-disable @typescript-eslint/no-unused-vars */\r\n\r\n// Types for the raw Lottie .json data\r\n\r\n// General animation data\r\nexport type RawLottieAnimation = {\r\n v: string; // Version\r\n fr: number; // Framerate in frames per second\r\n ip: number; // \tFrame the animation starts at (usually 0)\r\n op: number; // \tFrame the animation stops/loops at, which makes this the duration in frames when ip is 0\r\n w: number; // Width\r\n h: number; // Height\r\n nm?: string; // Human readable name\r\n layers: RawLottieLayer[]; // Layers\r\n};\r\n\r\n// Layer data\r\nexport type RawLottieLayer = {\r\n ind?: number; // Index that can be used for parenting and referenced in expressions\r\n ty: RawLayerType; // Layer type (0: precomp, 1: solid, 2: image, 3: null, 4: shape, 5: text)\r\n nm?: string; // Human readable name\r\n parent?: number; // Must be the ind property of another layer\r\n hd?: boolean; // Hidden\r\n sr?: number; // Time Stretch\r\n ao?: number; // Auto-Orient (0: false, 1: true), if 1, the layer will rotate itself to match its animated position path\r\n ip?: number; // Frame when the layer becomes visible\r\n op?: number; // Frame when the layer becomes invisible\r\n st?: number; // Start time\r\n ct?: number; // Collapse Transform (0: false, 1: true), marks that transforms should be applied before masks\r\n ks: RawTransform; // Layer transform\r\n shapes?: RawGraphicElement[];\r\n};\r\n\r\nexport type RawGraphicElement = {\r\n nm?: string; // Human readable name\r\n hd?: boolean; // Hidden\r\n ty: RawShapeType; // Type ('gr' for group, 'rc' for rectangle, 'el' for ellipse, 'sh' for path, etc.)\r\n bm?: number; // Blend mode\r\n ix?: number; // Index\r\n};\r\n\r\nexport type RawGroupShape = RawGraphicElement & {\r\n it?: RawGraphicElement[]; // shapes\r\n};\r\n\r\nexport type RawRectangleShape = RawGraphicElement & {\r\n d: RawShapeDirection; // direction the shape is drawn as, mostly relevant when using trim path\r\n p: RawPositionProperty; // center of the rectangle\r\n s: RawVectorProperty; // size of the rectangle\r\n r: RawScalarProperty; // rounded corners radius\r\n};\r\n\r\nexport type RawPathShape = RawGraphicElement & {\r\n d: RawShapeDirection; // direction the shape is drawn as, mostly relevant when using trim path\r\n ks: RawBezierShapeProperty; // bezier path\r\n};\r\n\r\nexport type RawFillShape = RawGraphicElement & {\r\n o: RawScalarProperty; // Opacity, 100 means fully opaque\r\n c: RawColorProperty; // Color\r\n r: RawFillRule; // fill rule\r\n};\r\n\r\nexport type RawGradientFillShape = RawGraphicElement & {\r\n o: RawScalarProperty; // Opacity, 100 means fully opaque\r\n g: RawGradientsProperty; // Gradient colors\r\n s: RawPositionProperty; // Starting point of the gradient\r\n e: RawPositionProperty; // End point of the gradient\r\n t: RawGradientType; // type of the gradient\r\n h: RawScalarProperty; // highlight length as a percentage between s and e\r\n a?: RawScalarProperty; // highlight angle in clockwise degrees, relative to the direction from s to e\r\n r: RawFillRule; // fill rule\r\n};\r\n\r\nexport type RawTransformShape = RawGraphicElement & {\r\n a: RawPositionProperty; // anchor point\r\n p: RawPositionProperty; // position/translation\r\n r: RawScalarProperty; // rotation in degrees, clockwise\r\n s: RawVectorProperty; // scale factor, [100, 100] for no scaling\r\n o: RawScalarProperty; // opacity\r\n sk: RawScalarProperty; // skew amount as an angle in degrees\r\n sa: RawScalarProperty; // skew axis, direction along which skew is applied, in degrees (0 skes along the x axis, 90 along the Y axys)\r\n};\r\n\r\nexport type RawTransform = {\r\n a?: RawPositionProperty; // Anchor point: a position (relative to its parent) around which transformations are applied (ie: center for rotation / scale)\r\n p?: RawPositionProperty; // Position / Translation\r\n r?: RawScalarProperty; // Rotation in degrees, clockwise\r\n s?: RawVectorProperty; // Scale factor, [100, 100] for no scaling\r\n o?: RawScalarProperty; // Opacity\r\n};\r\n\r\nexport type RawScalarProperty = {\r\n a: RawNumberBoolean; // Animated (0: false, 1: true)\r\n k: number | RawVectorKeyframe[]; // When it's not animated, k will contain the value directly. When animated, k will be an array of keyframes.\r\n};\r\n\r\nexport type RawVectorProperty = {\r\n a: RawNumberBoolean; // Animated (0: false, 1: true)\r\n k: number[] | RawVectorKeyframe[]; // When it's not animated, k will contain the value directly. When animated, k will be an array of keyframes.\r\n l: number; // Number of components in the value arrays. If present values will be truncated or expanded to match this length when accessed from expressions\r\n};\r\n\r\nexport type RawVectorKeyframe = {\r\n t: number; // Time, Frame number\r\n s: number[]; // Value at this keyframe\r\n h?: RawNumberBoolean; // Hold flag (0: false, 1: true)\r\n i?: RawKeyFrameEasing; // In tangent, easing tangent going into the next keyframe\r\n o?: RawKeyFrameEasing; // Out tanget, easing tangent leaving the current keyframe\r\n};\r\n\r\nexport type RawPositionProperty = {\r\n a: RawNumberBoolean; // Animated (0: false, 1: true)\r\n k: number[] | RawPositionKeyframe[]; // When it's not animated, k will contain the value directly. When animated, k will be an array of keyframes.\r\n l: number; // Number of components in the value arrays. If present values will be truncated or expanded to match this length when accessed from expressions\r\n};\r\n\r\nexport type RawPositionKeyframe = {\r\n t: number; // Time, Frame number\r\n h?: RawNumberBoolean; // Hold flag (0: false, 1: true)\r\n i?: RawKeyFrameEasing; // In tangent, easing tangent going into the next keyframe\r\n o?: RawKeyFrameEasing; // Out tanget, easing tangent leaving the current keyframe\r\n s: number[]; // Value at this keyframe\r\n ti: number[]; // Value In Tangent, tangent for values (eg: moving position around a curved path)\r\n to: number[]; // Value Out Tangent, tangent for values (eg: moving position around a curved path)\r\n};\r\n\r\nexport type RawBezierShapeProperty = {\r\n a: RawNumberBoolean; // Animated (0: false, 1: true)\r\n k: RawBezier | RawBezierShapeKeyframe[]; // When it's not animated, k will contain the value directly. When animated, k will be an array of keyframes\r\n};\r\n\r\nexport type RawBezierShapeKeyframe = {\r\n t: number; // Time, Frame number\r\n h?: RawNumberBoolean; // Hold flag (0: false, 1: true)\r\n i?: RawKeyFrameEasing; // In tangent, easing tangent going into the next keyframe\r\n o?: RawKeyFrameEasing; // Out tanget, easing tangent leaving the current keyframe\r\n s: RawBezier[]; // Value at this keyframe\r\n};\r\n\r\nexport type RawColorProperty = {\r\n a: RawNumberBoolean; // Animated (0: false, 1: true)\r\n k: number[] | RawColorKeyframe[]; // When it's not animated, k will contain the value directly. When animated, k will be an array of keyframes\r\n};\r\n\r\nexport type RawColorKeyframe = {\r\n t: number; // Time, Frame number\r\n h?: RawNumberBoolean; // Hold flag (0: false, 1: true)\r\n i?: RawKeyFrameEasing; // In tangent, easing tangent going into the next keyframe\r\n o?: RawKeyFrameEasing; // Out tanget, easing tangent leaving the current keyframe\r\n s: number[]; // Value at this keyframe\r\n};\r\n\r\nexport type RawGradientsProperty = {\r\n p: number; // Color stop count\r\n k: RawGradientProperty;\r\n};\r\n\r\nexport type RawGradientProperty = {\r\n a: RawNumberBoolean; // Animated (0: false, 1: true)\r\n k: number[]; // Gradient colors array\r\n};\r\n\r\nexport type RawKeyFrameEasing = {\r\n x: number | number[]; // Time component: 0 means start time of the keyframe, 1 means time of the next keyframe.\r\n y: number | number[]; // Value interpolation component: 0 means start value of the keyframe, 1 means value at the next keyframe.\r\n};\r\n\r\nexport type RawBezier = {\r\n c: boolean; // Closed\r\n i: number[][]; // In tangents, array of points, each point is an array of coordinates. These points are along the in tangents relative to the corresponding v\r\n o: number[][]; // Out tangents, array of points, each point is an array of coordinates. These points are along the out tangents relative to the corresponding v\r\n v: number[][]; // Vertices, array of points, each point is an array of coordinates. These points are along the bezier path\r\n};\r\n\r\nexport type RawNumberBoolean = 0 | 1; // 0: false, 1: true;\r\nexport type RawLayerType = 0 | 1 | 2 | 3 | 4 | 5 | 6; // Layer type (0: precomposition, 1: solid, 2: image, 3: null, 4: shape, 5: text, 6: audio)\r\nexport type RawShapeType = \"fl\" | \"gf\" | \"gr\" | \"tr\" | \"sh\" | \"rc\"; // Shape type (fl: fill, gf: gradient fill, gr: group, tr: transform, sh: path, rc: rectangle)\r\nexport type RawShapeDirection = 1 | 3; // 1: clockwise, 3: counter-clockwise\r\nexport type RawFillRule = 1 | 2; // Fill rule (1: non-zero, everything is colored (You can think of this as an OR), 2: even-odd, colored based on intersections and path direction, can be used to create \"holes\")\r\nexport type RawGradientType = 1 | 2; // Gradient type (1: linear, 2: radial)\r\n"]}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Configuration options for the Lottie animation player.
3
+ */
4
+ export type AnimationConfiguration = {
5
+ /**
6
+ * Whether the animation should play on a loop or not
7
+ */
8
+ loopAnimation: boolean;
9
+ /**
10
+ * Size of the sprite atlas texture.
11
+ * Default is 2048.
12
+ */
13
+ spriteAtlasSize: number;
14
+ /**
15
+ * Gap size around sprites in the atlas.
16
+ * Default is 5.
17
+ */
18
+ gapSize: number;
19
+ /**
20
+ * Maximum number of sprites the renderer can handle at once.
21
+ * Default is 64.
22
+ */
23
+ spritesCapacity: number;
24
+ /**
25
+ * Background color for the animation canvas.
26
+ * Default is white with full opacity.
27
+ */
28
+ backgroundColor: {
29
+ r: number;
30
+ g: number;
31
+ b: number;
32
+ a: number;
33
+ };
34
+ /**
35
+ * Minimum scale factor to prevent too small sprites.
36
+ * Default is 5.
37
+ */
38
+ scaleMultiplier: number;
39
+ /**
40
+ * Scale factor for the rendering.
41
+ * Default is 1.
42
+ */
43
+ devicePixelRatio: number;
44
+ /**
45
+ * Number of steps to sample cubic bezier easing functions for animations.
46
+ * Default is 4.
47
+ */
48
+ easingSteps: number;
49
+ /**
50
+ * Whether to ignore opacity animations for performance.
51
+ * Default is true.
52
+ */
53
+ ignoreOpacityAnimations: boolean;
54
+ /**
55
+ * Whether to support device lost events for WebGL contexts.
56
+ * Default is false.
57
+ */
58
+ supportDeviceLost: boolean;
59
+ };
60
+ /**
61
+ * LottiePlayer is a class that allows you to play Lottie animations using Babylon.js.
62
+ * It plays the animations in a worker thread using OffscreenCanvas.
63
+ * 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.
64
+ */
65
+ export declare class LottiePlayer {
66
+ private _playing;
67
+ private _disposed;
68
+ private _worker;
69
+ private _canvas;
70
+ private _resizeObserver;
71
+ private readonly _container;
72
+ private readonly _animationFile;
73
+ private readonly _configuration;
74
+ /**
75
+ * Creates a new instance of the LottiePlayer.
76
+ * @param container The HTMLDivElement to create the canvas in and render the animation on.
77
+ * @param animationFile The URL of the Lottie animation file to be played.
78
+ * @param configuration Optional configuration object to customize the animation playback.
79
+ */
80
+ constructor(container: HTMLDivElement, animationFile: string, configuration?: Partial<AnimationConfiguration>);
81
+ /**
82
+ * Loads and plays a lottie animation.
83
+ * @returns True if the animation is successfully set up to play, false if the animation couldn't play.
84
+ */
85
+ playAnimation(): boolean;
86
+ /**
87
+ * Disposes the LottiePlayer instance, cleaning up resources and event listeners.
88
+ */
89
+ dispose(): void;
90
+ private _onWindowResize;
91
+ private _onBeforeUnload;
92
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * LottiePlayer is a class that allows you to play Lottie animations using Babylon.js.
3
+ * It plays the animations in a worker thread using OffscreenCanvas.
4
+ * 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.
5
+ */
6
+ export class LottiePlayer {
7
+ /**
8
+ * Creates a new instance of the LottiePlayer.
9
+ * @param container The HTMLDivElement to create the canvas in and render the animation on.
10
+ * @param animationFile The URL of the Lottie animation file to be played.
11
+ * @param configuration Optional configuration object to customize the animation playback.
12
+ */
13
+ constructor(container, animationFile, configuration) {
14
+ this._playing = false;
15
+ this._disposed = false;
16
+ this._worker = null;
17
+ this._canvas = null;
18
+ this._resizeObserver = null;
19
+ this._onWindowResize = () => {
20
+ if (this._disposed || !this._canvas || !this._worker) {
21
+ return;
22
+ }
23
+ const w = this._canvas.clientWidth;
24
+ const h = this._canvas.clientHeight;
25
+ this._worker.postMessage({ width: w, height: h });
26
+ };
27
+ this._onBeforeUnload = () => {
28
+ this._worker?.terminate();
29
+ this._worker = null;
30
+ };
31
+ this._container = container;
32
+ this._animationFile = animationFile;
33
+ this._configuration = configuration ?? {};
34
+ }
35
+ /**
36
+ * Loads and plays a lottie animation.
37
+ * @returns True if the animation is successfully set up to play, false if the animation couldn't play.
38
+ */
39
+ playAnimation() {
40
+ if (this._playing || this._disposed) {
41
+ return false;
42
+ }
43
+ if ("OffscreenCanvas" in window) {
44
+ // Create the canvas element
45
+ this._canvas = document.createElement("canvas");
46
+ this._canvas.width = this._container.clientWidth;
47
+ this._canvas.height = this._container.clientHeight;
48
+ // Style the canvas to fill the container
49
+ this._canvas.style.width = "100%";
50
+ this._canvas.style.height = "100%";
51
+ this._canvas.style.display = "block";
52
+ // Append the canvas to the container
53
+ this._container.appendChild(this._canvas);
54
+ const offscreen = this._canvas.transferControlToOffscreen();
55
+ this._worker = new Worker(new URL("./worker.ts", import.meta.url), { type: "module" });
56
+ this._worker.onmessage = (evt) => {
57
+ if (evt.data.animationWidth && evt.data.animationHeight && this._canvas) {
58
+ this._canvas.style.width = `${evt.data.animationWidth}px`;
59
+ this._canvas.style.height = `${evt.data.animationHeight}px`;
60
+ }
61
+ };
62
+ this._worker.postMessage({ canvas: offscreen, file: this._animationFile, config: this._configuration }, [offscreen]);
63
+ this._playing = true;
64
+ window.addEventListener("resize", this._onWindowResize);
65
+ window.addEventListener("beforeunload", this._onBeforeUnload);
66
+ if ("ResizeObserver" in window) {
67
+ this._resizeObserver = new ResizeObserver(() => {
68
+ if (this._disposed || !this._canvas || !this._worker) {
69
+ return;
70
+ }
71
+ const w = this._canvas.clientWidth;
72
+ const h = this._canvas.clientHeight;
73
+ this._worker.postMessage({ width: w, height: h });
74
+ });
75
+ this._resizeObserver.observe(this._container);
76
+ }
77
+ return true;
78
+ }
79
+ else {
80
+ return false;
81
+ }
82
+ }
83
+ /**
84
+ * Disposes the LottiePlayer instance, cleaning up resources and event listeners.
85
+ */
86
+ dispose() {
87
+ window.removeEventListener("resize", this._onWindowResize);
88
+ window.removeEventListener("beforeunload", this._onBeforeUnload);
89
+ if (this._resizeObserver) {
90
+ this._resizeObserver.disconnect();
91
+ this._resizeObserver = null;
92
+ }
93
+ this._onBeforeUnload();
94
+ if (this._canvas) {
95
+ this._container.removeChild(this._canvas);
96
+ this._canvas = null;
97
+ }
98
+ this._disposed = true;
99
+ }
100
+ }
101
+ //# sourceMappingURL=lottiePlayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lottiePlayer.js","sourceRoot":"","sources":["../../../../dev/addons/src/lottie/lottiePlayer.ts"],"names":[],"mappings":"AAyDA;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAWrB;;;;;OAKG;IACH,YAAmB,SAAyB,EAAE,aAAqB,EAAE,aAA+C;QAhB5G,aAAQ,GAAY,KAAK,CAAC;QAC1B,cAAS,GAAY,KAAK,CAAC;QAC3B,YAAO,GAAqB,IAAI,CAAC;QACjC,YAAO,GAAgC,IAAI,CAAC;QAC5C,oBAAe,GAA6B,IAAI,CAAC;QAoGjD,oBAAe,GAAG,GAAG,EAAE;YAC3B,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACnD,OAAO;YACX,CAAC;YAED,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;YACnC,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;YAEpC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;QACtD,CAAC,CAAC;QAEM,oBAAe,GAAG,GAAG,EAAE;Y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,EAAE,CAAC,CAAC;gBACtD,CAAC,CAAC,CAAC;gBAEH,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAClD,CAAC;YAED,OAAO,IAAI,CAAC;QAChB,CAAC;aAAM,CAAC;YACJ,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAC3D,MAAM,CAAC,mBAAmB,CAAC,cAAc,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAEjE,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACvB,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;YAClC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAChC,CAAC;QAED,IAAI,CAAC,eAAe,EAAE,CAAC;QAEvB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC1C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACxB,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;CAiBJ","sourcesContent":["import type { Nullable } from \"core/types\";\r\n\r\n/**\r\n * Configuration options for the Lottie animation player.\r\n */\r\nexport type AnimationConfiguration = {\r\n /**\r\n * Whether the animation should play on a loop or not\r\n */\r\n loopAnimation: boolean;\r\n /**\r\n * Size of the sprite atlas texture.\r\n * Default is 2048.\r\n */\r\n spriteAtlasSize: number;\r\n /**\r\n * Gap size around sprites in the atlas.\r\n * Default is 5.\r\n */\r\n gapSize: number;\r\n /**\r\n * Maximum number of sprites the renderer can handle at once.\r\n * Default is 64.\r\n */\r\n spritesCapacity: number;\r\n /**\r\n * Background color for the animation canvas.\r\n * Default is white with full opacity.\r\n */\r\n backgroundColor: { r: number; g: number; b: number; a: number };\r\n /**\r\n * Minimum scale factor to prevent too small sprites.\r\n * Default is 5.\r\n */\r\n scaleMultiplier: number;\r\n /**\r\n * Scale factor for the rendering.\r\n * Default is 1.\r\n */\r\n devicePixelRatio: number;\r\n /**\r\n * Number of steps to sample cubic bezier easing functions for animations.\r\n * Default is 4.\r\n */\r\n easingSteps: number;\r\n /**\r\n * Whether to ignore opacity animations for performance.\r\n * Default is true.\r\n */\r\n ignoreOpacityAnimations: boolean;\r\n /**\r\n * Whether to support device lost events for WebGL contexts.\r\n * Default is false.\r\n */\r\n supportDeviceLost: boolean;\r\n};\r\n\r\n/**\r\n * LottiePlayer is a class that allows you to play Lottie animations using Babylon.js.\r\n * It plays the animations in a worker thread using OffscreenCanvas.\r\n * 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.\r\n */\r\nexport class LottiePlayer {\r\n private _playing: boolean = false;\r\n private _disposed: boolean = false;\r\n private _worker: Nullable<Worker> = null;\r\n private _canvas: Nullable<HTMLCanvasElement> = null;\r\n private _resizeObserver: Nullable<ResizeObserver> = null;\r\n\r\n private readonly _container: HTMLDivElement;\r\n private readonly _animationFile: string;\r\n private readonly _configuration: Partial<AnimationConfiguration>;\r\n\r\n /**\r\n * Creates a new instance of the LottiePlayer.\r\n * @param container The HTMLDivElement to create the canvas in and render the animation on.\r\n * @param animationFile The URL of the Lottie animation file to be played.\r\n * @param configuration Optional configuration object to customize the animation playback.\r\n */\r\n public constructor(container: HTMLDivElement, animationFile: string, configuration?: Partial<AnimationConfiguration>) {\r\n this._container = container;\r\n this._animationFile = animationFile;\r\n this._configuration = configuration ?? {};\r\n }\r\n\r\n /**\r\n * Loads and plays a lottie animation.\r\n * @returns True if the animation is successfully set up to play, false if the animation couldn't play.\r\n */\r\n public playAnimation(): boolean {\r\n if (this._playing || this._disposed) {\r\n return false;\r\n }\r\n\r\n if (\"OffscreenCanvas\" in window) {\r\n // Create the canvas element\r\n this._canvas = document.createElement(\"canvas\");\r\n this._canvas.width = this._container.clientWidth;\r\n this._canvas.height = this._container.clientHeight;\r\n\r\n // Style the canvas to fill the container\r\n this._canvas.style.width = \"100%\";\r\n this._canvas.style.height = \"100%\";\r\n this._canvas.style.display = \"block\";\r\n\r\n // Append the canvas to the container\r\n this._container.appendChild(this._canvas);\r\n\r\n const offscreen = this._canvas.transferControlToOffscreen();\r\n\r\n this._worker = new Worker(new URL(\"./worker.ts\", import.meta.url), { type: \"module\" });\r\n this._worker.onmessage = (evt: MessageEvent) => {\r\n if (evt.data.animationWidth && evt.data.animationHeight && this._canvas) {\r\n this._canvas.style.width = `${evt.data.animationWidth}px`;\r\n this._canvas.style.height = `${evt.data.animationHeight}px`;\r\n }\r\n };\r\n\r\n this._worker.postMessage({ canvas: offscreen, file: this._animationFile, config: this._configuration }, [offscreen]);\r\n this._playing = true;\r\n\r\n window.addEventListener(\"resize\", this._onWindowResize);\r\n window.addEventListener(\"beforeunload\", this._onBeforeUnload);\r\n\r\n if (\"ResizeObserver\" in window) {\r\n this._resizeObserver = new ResizeObserver(() => {\r\n if (this._disposed || !this._canvas || !this._worker) {\r\n return;\r\n }\r\n\r\n const w = this._canvas.clientWidth;\r\n const h = this._canvas.clientHeight;\r\n\r\n this._worker.postMessage({ width: w, height: h });\r\n });\r\n\r\n this._resizeObserver.observe(this._container);\r\n }\r\n\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the LottiePlayer instance, cleaning up resources and event listeners.\r\n */\r\n public dispose(): void {\r\n window.removeEventListener(\"resize\", this._onWindowResize);\r\n window.removeEventListener(\"beforeunload\", this._onBeforeUnload);\r\n\r\n if (this._resizeObserver) {\r\n this._resizeObserver.disconnect();\r\n this._resizeObserver = null;\r\n }\r\n\r\n this._onBeforeUnload();\r\n\r\n if (this._canvas) {\r\n this._container.removeChild(this._canvas);\r\n this._canvas = null;\r\n }\r\n\r\n this._disposed = true;\r\n }\r\n\r\n private _onWindowResize = () => {\r\n if (this._disposed || !this._canvas || !this._worker) {\r\n return;\r\n }\r\n\r\n const w = this._canvas.clientWidth;\r\n const h = this._canvas.clientHeight;\r\n\r\n this._worker.postMessage({ width: w, height: h });\r\n };\r\n\r\n private _onBeforeUnload = () => {\r\n this._worker?.terminate();\r\n this._worker = null;\r\n };\r\n}\r\n"]}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Represents a Babylon.js thin version of a cubic bezier curve
3
+ * We are only exposing what we truly need in the scope of
4
+ * the Lottie Renderer project preventing the dependency on the full
5
+ * Babylon.js animation system.
6
+ */
7
+ export declare class BezierCurve {
8
+ /**
9
+ * X of the first control point
10
+ */
11
+ readonly x1: number;
12
+ /**
13
+ * Y of the first control point
14
+ */
15
+ readonly y1: number;
16
+ /**
17
+ * X of the second control point
18
+ */
19
+ readonly x2: number;
20
+ /**
21
+ * Y of the second control point
22
+ */
23
+ readonly y2: number;
24
+ private readonly _easingSteps;
25
+ private readonly _f0;
26
+ private readonly _f1;
27
+ private readonly _f2;
28
+ /**
29
+ * Instantiates a bezier function
30
+ * @see http://cubic-bezier.com/#.17,.67,.83,.67
31
+ * @param x1 Defines the x component of the start tangent in the bezier curve
32
+ * @param y1 Defines the y component of the start tangent in the bezier curve
33
+ * @param x2 Defines the x component of the end tangent in the bezier curve
34
+ * @param y2 Defines the y component of the end tangent in the bezier curve
35
+ * @param easingSteps Number of steps to sample the bezier curve for easing
36
+ */
37
+ constructor(x1: number | undefined, y1: number | undefined, x2: number | undefined, y2: number | undefined, easingSteps: number);
38
+ /**
39
+ * Interpolates the bezier curve at a given time
40
+ * @param t Defines the time to evaluate the bezier curve at, between 0 and 1
41
+ * @returns The interpolated value at time t
42
+ */
43
+ interpolate(t: number): number;
44
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Represents a Babylon.js thin version of a cubic bezier curve
3
+ * We are only exposing what we truly need in the scope of
4
+ * the Lottie Renderer project preventing the dependency on the full
5
+ * Babylon.js animation system.
6
+ */
7
+ export class BezierCurve {
8
+ /**
9
+ * Instantiates a bezier function
10
+ * @see http://cubic-bezier.com/#.17,.67,.83,.67
11
+ * @param x1 Defines the x component of the start tangent in the bezier curve
12
+ * @param y1 Defines the y component of the start tangent in the bezier curve
13
+ * @param x2 Defines the x component of the end tangent in the bezier curve
14
+ * @param y2 Defines the y component of the end tangent in the bezier curve
15
+ * @param easingSteps Number of steps to sample the bezier curve for easing
16
+ */
17
+ constructor(x1 = 0, y1 = 0, x2 = 1, y2 = 1, easingSteps) {
18
+ this.x1 = x1;
19
+ this.y1 = y1;
20
+ this.x2 = x2;
21
+ this.y2 = y2;
22
+ this._easingSteps = easingSteps;
23
+ // Pre-calculate coefficients
24
+ this._f0 = 1 - 3 * this.x2 + 3 * this.x1;
25
+ this._f1 = 3 * this.x2 - 6 * this.x1;
26
+ this._f2 = 3 * this.x1;
27
+ }
28
+ /**
29
+ * Interpolates the bezier curve at a given time
30
+ * @param t Defines the time to evaluate the bezier curve at, between 0 and 1
31
+ * @returns The interpolated value at time t
32
+ */
33
+ interpolate(t) {
34
+ if (t === 0) {
35
+ return 0;
36
+ }
37
+ if (t === 1) {
38
+ return 1;
39
+ }
40
+ let refinedT = t;
41
+ for (let i = 0; i < this._easingSteps; i++) {
42
+ const refinedT2 = refinedT * refinedT;
43
+ const refinedT3 = refinedT2 * refinedT;
44
+ const x = this._f0 * refinedT3 + this._f1 * refinedT2 + this._f2 * refinedT;
45
+ const slope = 1.0 / (3.0 * this._f0 * refinedT2 + 2.0 * this._f1 * refinedT + this._f2);
46
+ refinedT -= (x - t) * slope;
47
+ refinedT = Math.min(1, Math.max(0, refinedT));
48
+ }
49
+ // Resolve cubic bezier for the given x
50
+ return 3 * (1 - refinedT) * (1 - refinedT) * refinedT * this.y1 + 3 * (1 - refinedT) * refinedT * refinedT * this.y2 + refinedT * refinedT * refinedT;
51
+ }
52
+ }
53
+ //# sourceMappingURL=bezier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bezier.js","sourceRoot":"","sources":["../../../../../d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AG,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC;YAC5E,MAAM,KAAK,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YACxF,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;YAC5B,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;QAClD,CAAC;QAED,uCAAuC;QACvC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC,EAAE,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC1J,CAAC;CACJ","sourcesContent":["/**\r\n * Represents a Babylon.js thin version of a cubic bezier curve\r\n * We are only exposing what we truly need in the scope of\r\n * the Lottie Renderer project preventing the dependency on the full\r\n * Babylon.js animation system.\r\n */\r\nexport class BezierCurve {\r\n /**\r\n * X of the first control point\r\n */\r\n public readonly x1: number;\r\n /**\r\n * Y of the first control point\r\n */\r\n public readonly y1: number;\r\n /**\r\n * X of the second control point\r\n */\r\n public readonly x2: number;\r\n /**\r\n * Y of the second control point\r\n */\r\n public readonly y2: number;\r\n\r\n private readonly _easingSteps: number;\r\n\r\n private readonly _f0: number;\r\n private readonly _f1: number;\r\n private readonly _f2: number;\r\n\r\n /**\r\n * Instantiates a bezier function\r\n * @see http://cubic-bezier.com/#.17,.67,.83,.67\r\n * @param x1 Defines the x component of the start tangent in the bezier curve\r\n * @param y1 Defines the y component of the start tangent in the bezier curve\r\n * @param x2 Defines the x component of the end tangent in the bezier curve\r\n * @param y2 Defines the y component of the end tangent in the bezier curve\r\n * @param easingSteps Number of steps to sample the bezier curve for easing\r\n */\r\n constructor(x1: number = 0, y1: number = 0, x2: number = 1, y2: number = 1, easingSteps: number) {\r\n this.x1 = x1;\r\n this.y1 = y1;\r\n this.x2 = x2;\r\n this.y2 = y2;\r\n this._easingSteps = easingSteps;\r\n\r\n // Pre-calculate coefficients\r\n this._f0 = 1 - 3 * this.x2 + 3 * this.x1;\r\n this._f1 = 3 * this.x2 - 6 * this.x1;\r\n this._f2 = 3 * this.x1;\r\n }\r\n\r\n /**\r\n * Interpolates the bezier curve at a given time\r\n * @param t Defines the time to evaluate the bezier curve at, between 0 and 1\r\n * @returns The interpolated value at time t\r\n */\r\n public interpolate(t: number): number {\r\n if (t === 0) {\r\n return 0;\r\n }\r\n\r\n if (t === 1) {\r\n return 1;\r\n }\r\n\r\n let refinedT = t;\r\n\r\n for (let i = 0; i < this._easingSteps; i++) {\r\n const refinedT2 = refinedT * refinedT;\r\n const refinedT3 = refinedT2 * refinedT;\r\n const x = this._f0 * refinedT3 + this._f1 * refinedT2 + this._f2 * refinedT;\r\n const slope = 1.0 / (3.0 * this._f0 * refinedT2 + 2.0 * this._f1 * refinedT + this._f2);\r\n refinedT -= (x - t) * slope;\r\n refinedT = Math.min(1, Math.max(0, refinedT));\r\n }\r\n\r\n // Resolve cubic bezier for the given x\r\n return 3 * (1 - refinedT) * (1 - refinedT) * refinedT * this.y1 + 3 * (1 - refinedT) * refinedT * refinedT * this.y2 + refinedT * refinedT * refinedT;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,28 @@
1
+ import type { RawGroupShape } from "../lottie/rawTypes.js";
2
+ /**
3
+ * Represents a bounding box for a shape in the animation.
4
+ */
5
+ export type BoundingBox = {
6
+ /**
7
+ * Height of the bounding box
8
+ */
9
+ height: number;
10
+ /**
11
+ * Width of the bounding box
12
+ */
13
+ width: number;
14
+ /**
15
+ * X coordinate of the center of the bounding box
16
+ */
17
+ centerX: number;
18
+ /**
19
+ * Y coordinate of the center of the bounding box
20
+ */
21
+ centerY: number;
22
+ };
23
+ /**
24
+ * Calculates the bounding box for a group shape in a Lottie animation.
25
+ * @param rawGroup The raw group shape to calculate the bounding box for
26
+ * @returns The bounding box for the group shape
27
+ */
28
+ export declare function GetBoundingBox(rawGroup: RawGroupShape): BoundingBox;