@babylonjs/addons 8.24.0 → 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.
- package/htmlMesh/htmlMeshRenderer.d.ts +14 -0
- package/htmlMesh/htmlMeshRenderer.js +15 -1
- package/htmlMesh/htmlMeshRenderer.js.map +1 -1
- package/package.json +2 -2
- package/lottie/index.d.ts +0 -1
- package/lottie/index.js +0 -3
- package/lottie/index.js.map +0 -1
- package/lottie/lottie/animationParser.d.ts +0 -47
- package/lottie/lottie/animationParser.js +0 -368
- package/lottie/lottie/animationParser.js.map +0 -1
- package/lottie/lottie/parsedTypes.d.ts +0 -140
- package/lottie/lottie/parsedTypes.js +0 -2
- package/lottie/lottie/parsedTypes.js.map +0 -1
- package/lottie/lottie/rawTypes.d.ts +0 -152
- package/lottie/lottie/rawTypes.js +0 -4
- package/lottie/lottie/rawTypes.js.map +0 -1
- package/lottie/lottiePlayer.d.ts +0 -92
- package/lottie/lottiePlayer.js +0 -101
- package/lottie/lottiePlayer.js.map +0 -1
- package/lottie/maths/bezier.d.ts +0 -44
- package/lottie/maths/bezier.js +0 -53
- package/lottie/maths/bezier.js.map +0 -1
- package/lottie/maths/boundingBox.d.ts +0 -28
- package/lottie/maths/boundingBox.js +0 -155
- package/lottie/maths/boundingBox.js.map +0 -1
- package/lottie/maths/matrix.d.ts +0 -91
- package/lottie/maths/matrix.js +0 -174
- package/lottie/maths/matrix.js.map +0 -1
- package/lottie/rendering/animationController.d.ts +0 -72
- package/lottie/rendering/animationController.js +0 -210
- package/lottie/rendering/animationController.js.map +0 -1
- package/lottie/rendering/controlNode.d.ts +0 -32
- package/lottie/rendering/controlNode.js +0 -39
- package/lottie/rendering/controlNode.js.map +0 -1
- package/lottie/rendering/node.d.ts +0 -97
- package/lottie/rendering/node.js +0 -331
- package/lottie/rendering/node.js.map +0 -1
- package/lottie/rendering/renderingManager.d.ts +0 -45
- package/lottie/rendering/renderingManager.js +0 -61
- package/lottie/rendering/renderingManager.js.map +0 -1
- package/lottie/sprites/spriteNode.d.ts +0 -32
- package/lottie/sprites/spriteNode.js +0 -52
- package/lottie/sprites/spriteNode.js.map +0 -1
- package/lottie/sprites/spritePacker.d.ts +0 -101
- package/lottie/sprites/spritePacker.js +0 -237
- package/lottie/sprites/spritePacker.js.map +0 -1
- package/lottie/worker.d.ts +0 -1
- package/lottie/worker.js +0 -39
- package/lottie/worker.js.map +0 -1
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import "@babylonjs/core/Engines/Extensions/engine.dynamicTexture.js";
|
|
2
|
-
import type { ThinEngine } from "@babylonjs/core/Engines/thinEngine.js";
|
|
3
|
-
import type { IVector2Like } from "@babylonjs/core/Maths/math.like.js";
|
|
4
|
-
import { ThinTexture } from "@babylonjs/core/Materials/Textures/thinTexture.js";
|
|
5
|
-
import type { RawGroupShape } from "../lottie/rawTypes.js";
|
|
6
|
-
import type { AnimationConfiguration } from "../lottiePlayer.js";
|
|
7
|
-
/**
|
|
8
|
-
* Information about a sprite in the sprite atlas.
|
|
9
|
-
*/
|
|
10
|
-
export type SpriteAtlasInfo = {
|
|
11
|
-
/**
|
|
12
|
-
* Offset in the x axis of the sprite in the atlas.
|
|
13
|
-
* Normalized between 0 and 1, left to right.
|
|
14
|
-
*/
|
|
15
|
-
uOffset: number;
|
|
16
|
-
/**
|
|
17
|
-
* Offset in the y axis of the sprite in the atlas.
|
|
18
|
-
* Normalized between 0 and 1, top to bottom.
|
|
19
|
-
*/
|
|
20
|
-
vOffset: number;
|
|
21
|
-
/**
|
|
22
|
-
* Width of the sprite in the atlas.
|
|
23
|
-
* In pixels.
|
|
24
|
-
*/
|
|
25
|
-
cellWidth: number;
|
|
26
|
-
/**
|
|
27
|
-
* Height of the sprite in the atlas.
|
|
28
|
-
* In pixels.
|
|
29
|
-
*/
|
|
30
|
-
cellHeight: number;
|
|
31
|
-
/**
|
|
32
|
-
* Width of the sprite in the screen.
|
|
33
|
-
* In pixels.
|
|
34
|
-
*/
|
|
35
|
-
widthPx: number;
|
|
36
|
-
/**
|
|
37
|
-
* Height of the sprite in the screen.
|
|
38
|
-
* In pixels.
|
|
39
|
-
*/
|
|
40
|
-
heightPx: number;
|
|
41
|
-
/**
|
|
42
|
-
* X coordinate of the center of the sprite bounding box, used for final positioning in the screen
|
|
43
|
-
*/
|
|
44
|
-
centerX: number;
|
|
45
|
-
/**
|
|
46
|
-
* Y coordinate of the center of the sprite bounding box, used for final positioning in the screen
|
|
47
|
-
*/
|
|
48
|
-
centerY: number;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* SpritePacker is a class that handles the packing of sprites into a texture atlas.
|
|
52
|
-
*/
|
|
53
|
-
export declare class SpritePacker {
|
|
54
|
-
private readonly _engine;
|
|
55
|
-
private readonly _configuration;
|
|
56
|
-
private _spritesCanvas;
|
|
57
|
-
private _spritesCanvasContext;
|
|
58
|
-
private readonly _spritesInternalTexture;
|
|
59
|
-
private readonly _spritesTexture;
|
|
60
|
-
private _isDirty;
|
|
61
|
-
private _currentX;
|
|
62
|
-
private _currentY;
|
|
63
|
-
private _maxRowHeight;
|
|
64
|
-
private _spriteAtlasInfo;
|
|
65
|
-
/**
|
|
66
|
-
* Gets the texture atlas that contains all the sprites packed by this SpritePacker.
|
|
67
|
-
* @returns The texture atlas containing the sprites.
|
|
68
|
-
*/
|
|
69
|
-
get texture(): ThinTexture;
|
|
70
|
-
/**
|
|
71
|
-
* Creates a new instance of SpritePacker.
|
|
72
|
-
* @param engine Engine that will render the sprites.
|
|
73
|
-
* @param configuration Configuration options for the sprite packer.
|
|
74
|
-
*/
|
|
75
|
-
constructor(engine: ThinEngine, configuration: AnimationConfiguration);
|
|
76
|
-
/**
|
|
77
|
-
* Adds a vector shape that comes from lottie data to the sprite atlas.
|
|
78
|
-
* @param rawGroup The raw group shape to add to the atlas.
|
|
79
|
-
* @param scalingFactor The scaling factor to apply to the shape.
|
|
80
|
-
* @returns The information on how to find the sprite in the atlas.
|
|
81
|
-
*/
|
|
82
|
-
addLottieShape(rawGroup: RawGroupShape, scalingFactor: IVector2Like): SpriteAtlasInfo;
|
|
83
|
-
/**
|
|
84
|
-
* Updates the internal atlas texture with the information that has been added to the SpritePacker.
|
|
85
|
-
*/
|
|
86
|
-
updateAtlasTexture(): void;
|
|
87
|
-
/**
|
|
88
|
-
* Releases the canvas and its context to allow garbage collection.
|
|
89
|
-
*/
|
|
90
|
-
releaseCanvas(): void;
|
|
91
|
-
private _drawVectorShape;
|
|
92
|
-
private _drawRectangle;
|
|
93
|
-
private _drawPath;
|
|
94
|
-
private _drawFill;
|
|
95
|
-
private _drawGradientFill;
|
|
96
|
-
private _drawLinearGradientFill;
|
|
97
|
-
private _drawRadialGradientFill;
|
|
98
|
-
private _addColorStops;
|
|
99
|
-
private _gradientColorsToCssColor;
|
|
100
|
-
private _lottieColorToCSSColor;
|
|
101
|
-
}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import "@babylonjs/core/Engines/Extensions/engine.dynamicTexture.js";
|
|
2
|
-
import { ThinTexture } from "@babylonjs/core/Materials/Textures/thinTexture.js";
|
|
3
|
-
import { GetBoundingBox } from "../maths/boundingBox.js";
|
|
4
|
-
/**
|
|
5
|
-
* SpritePacker is a class that handles the packing of sprites into a texture atlas.
|
|
6
|
-
*/
|
|
7
|
-
export class SpritePacker {
|
|
8
|
-
/**
|
|
9
|
-
* Gets the texture atlas that contains all the sprites packed by this SpritePacker.
|
|
10
|
-
* @returns The texture atlas containing the sprites.
|
|
11
|
-
*/
|
|
12
|
-
get texture() {
|
|
13
|
-
return this._spritesTexture;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new instance of SpritePacker.
|
|
17
|
-
* @param engine Engine that will render the sprites.
|
|
18
|
-
* @param configuration Configuration options for the sprite packer.
|
|
19
|
-
*/
|
|
20
|
-
constructor(engine, configuration) {
|
|
21
|
-
this._engine = engine;
|
|
22
|
-
this._configuration = configuration;
|
|
23
|
-
this._isDirty = false;
|
|
24
|
-
this._currentX = 0;
|
|
25
|
-
this._currentY = 0;
|
|
26
|
-
this._maxRowHeight = 0;
|
|
27
|
-
this._spritesCanvas = new OffscreenCanvas(this._configuration.spriteAtlasSize, this._configuration.spriteAtlasSize);
|
|
28
|
-
this._spritesCanvasContext = this._spritesCanvas.getContext("2d");
|
|
29
|
-
this._spritesInternalTexture = this._engine.createDynamicTexture(this._configuration.spriteAtlasSize, this._configuration.spriteAtlasSize, false, 2); // Linear filtering
|
|
30
|
-
this._engine.updateDynamicTexture(this._spritesInternalTexture, this._spritesCanvas, false);
|
|
31
|
-
this._spritesTexture = new ThinTexture(this._spritesInternalTexture);
|
|
32
|
-
this._spritesTexture.wrapU = 0; // Disable wrapping
|
|
33
|
-
this._spritesTexture.wrapV = 0; // Disable wrapping
|
|
34
|
-
this._spriteAtlasInfo = {
|
|
35
|
-
uOffset: 0,
|
|
36
|
-
vOffset: 0,
|
|
37
|
-
cellWidth: 0,
|
|
38
|
-
cellHeight: 0,
|
|
39
|
-
widthPx: 0,
|
|
40
|
-
heightPx: 0,
|
|
41
|
-
centerX: 0,
|
|
42
|
-
centerY: 0,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Adds a vector shape that comes from lottie data to the sprite atlas.
|
|
47
|
-
* @param rawGroup The raw group shape to add to the atlas.
|
|
48
|
-
* @param scalingFactor The scaling factor to apply to the shape.
|
|
49
|
-
* @returns The information on how to find the sprite in the atlas.
|
|
50
|
-
*/
|
|
51
|
-
addLottieShape(rawGroup, scalingFactor) {
|
|
52
|
-
const boundingBox = GetBoundingBox(rawGroup);
|
|
53
|
-
this._spriteAtlasInfo.cellWidth = boundingBox.width * scalingFactor.x;
|
|
54
|
-
this._spriteAtlasInfo.cellHeight = boundingBox.height * scalingFactor.y;
|
|
55
|
-
this._spriteAtlasInfo.centerX = boundingBox.centerX;
|
|
56
|
-
this._spriteAtlasInfo.centerY = boundingBox.centerY;
|
|
57
|
-
// Check if the sprite fits in the current row
|
|
58
|
-
if (this._currentX + this._spriteAtlasInfo.cellWidth > this._configuration.spriteAtlasSize) {
|
|
59
|
-
this._currentX = 0;
|
|
60
|
-
this._currentY += this._maxRowHeight + this._configuration.gapSize; // Add a gap between sprites to avoid bleeding
|
|
61
|
-
this._maxRowHeight = 0;
|
|
62
|
-
}
|
|
63
|
-
// Normalize the x/y offsets in texture coordinates (0 to 1)
|
|
64
|
-
this._spriteAtlasInfo.uOffset = this._currentX / this._configuration.spriteAtlasSize;
|
|
65
|
-
this._spriteAtlasInfo.vOffset = this._currentY / this._configuration.spriteAtlasSize;
|
|
66
|
-
this._drawVectorShape(rawGroup, boundingBox, scalingFactor);
|
|
67
|
-
this._currentX += this._spriteAtlasInfo.cellWidth + this._configuration.gapSize; // Add a gap between sprites to avoid bleeding
|
|
68
|
-
this._maxRowHeight = Math.max(this._maxRowHeight, this._spriteAtlasInfo.cellHeight);
|
|
69
|
-
this._spriteAtlasInfo.widthPx = boundingBox.width;
|
|
70
|
-
this._spriteAtlasInfo.heightPx = boundingBox.height;
|
|
71
|
-
this._isDirty = true;
|
|
72
|
-
return this._spriteAtlasInfo;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Updates the internal atlas texture with the information that has been added to the SpritePacker.
|
|
76
|
-
*/
|
|
77
|
-
updateAtlasTexture() {
|
|
78
|
-
if (!this._isDirty) {
|
|
79
|
-
return; // No need to update if nothing has changed
|
|
80
|
-
}
|
|
81
|
-
// Update the internal texture with the new canvas content
|
|
82
|
-
this._engine.updateDynamicTexture(this._spritesInternalTexture, this._spritesCanvas, false);
|
|
83
|
-
this._isDirty = false;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Releases the canvas and its context to allow garbage collection.
|
|
87
|
-
*/
|
|
88
|
-
releaseCanvas() {
|
|
89
|
-
this._spritesCanvasContext = undefined; // Clear the context to allow garbage collection
|
|
90
|
-
this._spritesCanvas = undefined; // Clear the canvas to allow garbage collection
|
|
91
|
-
}
|
|
92
|
-
_drawVectorShape(rawGroup, boundingBox, scalingFactor) {
|
|
93
|
-
this._spritesCanvasContext.save();
|
|
94
|
-
this._spritesCanvasContext.translate(this._currentX, this._currentY);
|
|
95
|
-
this._spritesCanvasContext.scale(scalingFactor.x, scalingFactor.y);
|
|
96
|
-
this._spritesCanvasContext.beginPath();
|
|
97
|
-
if (rawGroup.it) {
|
|
98
|
-
for (let i = 0; i < rawGroup.it.length; i++) {
|
|
99
|
-
const shape = rawGroup.it[i];
|
|
100
|
-
switch (shape.ty) {
|
|
101
|
-
case "rc":
|
|
102
|
-
this._drawRectangle(shape);
|
|
103
|
-
break;
|
|
104
|
-
case "sh":
|
|
105
|
-
this._drawPath(shape, boundingBox);
|
|
106
|
-
break;
|
|
107
|
-
case "fl":
|
|
108
|
-
this._drawFill(shape);
|
|
109
|
-
break;
|
|
110
|
-
case "gf":
|
|
111
|
-
this._drawGradientFill(shape, boundingBox);
|
|
112
|
-
break;
|
|
113
|
-
default:
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
this._spritesCanvasContext.restore();
|
|
119
|
-
}
|
|
120
|
-
_drawRectangle(shape) {
|
|
121
|
-
const size = shape.s.k;
|
|
122
|
-
const radius = shape.r.k;
|
|
123
|
-
if (radius <= 0) {
|
|
124
|
-
this._spritesCanvasContext.rect(0, 0, size[0], size[1]);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
this._spritesCanvasContext.roundRect(0, 0, size[0], size[1], radius);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
_drawPath(shape, boundingBox) {
|
|
131
|
-
const pathData = shape.ks.k;
|
|
132
|
-
const xTranslate = boundingBox.width / 2 - boundingBox.centerX;
|
|
133
|
-
const yTranslate = boundingBox.height / 2 - boundingBox.centerY;
|
|
134
|
-
const vertices = pathData.v;
|
|
135
|
-
const inTangents = pathData.i;
|
|
136
|
-
const outTangents = pathData.o;
|
|
137
|
-
if (vertices.length > 0) {
|
|
138
|
-
this._spritesCanvasContext.moveTo(vertices[0][0] + xTranslate, vertices[0][1] + yTranslate);
|
|
139
|
-
for (let i = 0; i < vertices.length - 1; i++) {
|
|
140
|
-
const start = vertices[i];
|
|
141
|
-
const end = vertices[i + 1];
|
|
142
|
-
const outTangent = outTangents[i];
|
|
143
|
-
const inTangent = inTangents[i + 1];
|
|
144
|
-
this._spritesCanvasContext.bezierCurveTo(start[0] + xTranslate + outTangent[0], start[1] + yTranslate + outTangent[1], end[0] + xTranslate + inTangent[0], end[1] + yTranslate + inTangent[1], end[0] + xTranslate, end[1] + yTranslate);
|
|
145
|
-
}
|
|
146
|
-
if (pathData.c) {
|
|
147
|
-
// Close path with curve from last to first point
|
|
148
|
-
const start = vertices[vertices.length - 1];
|
|
149
|
-
const end = vertices[0];
|
|
150
|
-
const outTangent = outTangents[vertices.length - 1];
|
|
151
|
-
const inTangent = inTangents[0];
|
|
152
|
-
this._spritesCanvasContext.bezierCurveTo(start[0] + xTranslate + outTangent[0], start[1] + yTranslate + outTangent[1], end[0] + xTranslate + inTangent[0], end[1] + yTranslate + inTangent[1], end[0] + xTranslate, end[1] + yTranslate);
|
|
153
|
-
this._spritesCanvasContext.closePath();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
_drawFill(fill) {
|
|
158
|
-
const color = this._lottieColorToCSSColor(fill.c.k, fill.o.k / 100);
|
|
159
|
-
this._spritesCanvasContext.fillStyle = color;
|
|
160
|
-
this._spritesCanvasContext.fill();
|
|
161
|
-
}
|
|
162
|
-
_drawGradientFill(fill, boundingBox) {
|
|
163
|
-
switch (fill.t) {
|
|
164
|
-
case 1: {
|
|
165
|
-
this._drawLinearGradientFill(fill, boundingBox);
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
case 2: {
|
|
169
|
-
this._drawRadialGradientFill(fill, boundingBox);
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
_drawLinearGradientFill(fill, boundingBox) {
|
|
175
|
-
const xTranslate = boundingBox.width / 2 - boundingBox.centerX;
|
|
176
|
-
const yTranslate = boundingBox.height / 2 - boundingBox.centerY;
|
|
177
|
-
// Create the gradient
|
|
178
|
-
const startPoint = fill.s.k;
|
|
179
|
-
const endPoint = fill.e.k;
|
|
180
|
-
const gradient = this._spritesCanvasContext.createLinearGradient(startPoint[0] + xTranslate, startPoint[1] + yTranslate, endPoint[0] + xTranslate, endPoint[1] + yTranslate);
|
|
181
|
-
this._addColorStops(gradient, fill);
|
|
182
|
-
this._spritesCanvasContext.fillStyle = gradient;
|
|
183
|
-
this._spritesCanvasContext.fill();
|
|
184
|
-
}
|
|
185
|
-
_drawRadialGradientFill(fill, boundingBox) {
|
|
186
|
-
const xTranslate = boundingBox.width / 2 - boundingBox.centerX;
|
|
187
|
-
const yTranslate = boundingBox.height / 2 - boundingBox.centerY;
|
|
188
|
-
// Create the gradient
|
|
189
|
-
const startPoint = fill.s.k;
|
|
190
|
-
const endPoint = fill.e.k;
|
|
191
|
-
const gradient = this._spritesCanvasContext.createRadialGradient(startPoint[0] + xTranslate, startPoint[1] + yTranslate, 0, endPoint[0] + xTranslate, endPoint[1] + yTranslate, Math.hypot(endPoint[0] - startPoint[0], endPoint[1] - startPoint[1]) // End radius
|
|
192
|
-
);
|
|
193
|
-
this._addColorStops(gradient, fill);
|
|
194
|
-
this._spritesCanvasContext.fillStyle = gradient;
|
|
195
|
-
this._spritesCanvasContext.fill();
|
|
196
|
-
}
|
|
197
|
-
_addColorStops(gradient, fill) {
|
|
198
|
-
const stops = fill.g.p;
|
|
199
|
-
const rawColors = fill.g.k.k;
|
|
200
|
-
let stopsData = undefined;
|
|
201
|
-
if (rawColors.length / stops === 4) {
|
|
202
|
-
stopsData = this._gradientColorsToCssColor(rawColors, stops, false);
|
|
203
|
-
}
|
|
204
|
-
else if (rawColors.length / stops === 6) {
|
|
205
|
-
stopsData = this._gradientColorsToCssColor(rawColors, stops, true);
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
for (let i = 0; i < stops; i++) {
|
|
211
|
-
gradient.addColorStop(stopsData[i].offset, stopsData[i].color);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
_gradientColorsToCssColor(colors, stops, hasAlpha) {
|
|
215
|
-
const skipElement = hasAlpha ? 0 : 1;
|
|
216
|
-
const result = [];
|
|
217
|
-
for (let i = 0; i < stops; i++) {
|
|
218
|
-
const index = i * 4;
|
|
219
|
-
result.push({
|
|
220
|
-
offset: colors[index],
|
|
221
|
-
color: this._lottieColorToCSSColor(colors.slice(index + skipElement, index + 4), 1),
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
return result;
|
|
225
|
-
}
|
|
226
|
-
_lottieColorToCSSColor(color, opacity) {
|
|
227
|
-
if (color.length !== 3 && color.length !== 4) {
|
|
228
|
-
return "rgba(0, 0, 0, 1)"; // Default to black if invalid
|
|
229
|
-
}
|
|
230
|
-
const r = Math.round(color[0] * 255);
|
|
231
|
-
const g = Math.round(color[1] * 255);
|
|
232
|
-
const b = Math.round(color[2] * 255);
|
|
233
|
-
const a = (color[3] || 1) * opacity;
|
|
234
|
-
return `rgba(${r}, ${g}, ${b}, ${a})`;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
//# sourceMappingURL=spritePacker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spritePacker.js","sourceRoot":"","sources":["../../../../../dev/addons/src/lottie/sprites/spritePacker.ts"],"names":[],"mappings":"AAAA,qEAAuD;AAKvD,OAAO,EAAE,WAAW,EAAE,0DAA4C;AAKlE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA8DtD;;GAEG;AACH,MAAM,OAAO,YAAY;IAiBrB;;;OAGG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,eAA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AAC,EAAE,CAAC;YAC3C,OAAO,kBAAkB,CAAC,CAAC,8BAA8B;QAC7D,CAAC;QAED,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC;QAEpC,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;IAC1C,CAAC;CACJ","sourcesContent":["import \"core/Engines/Extensions/engine.dynamicTexture\";\r\n\r\nimport type { ThinEngine } from \"core/Engines/thinEngine\";\r\nimport type { InternalTexture } from \"core/Materials/Textures/internalTexture\";\r\nimport type { IVector2Like } from \"core/Maths/math.like\";\r\nimport { ThinTexture } from \"core/Materials/Textures/thinTexture\";\r\n\r\nimport type { RawBezier, RawFillShape, RawGradientFillShape, RawPathShape, RawRectangleShape, RawGroupShape } from \"../lottie/rawTypes\";\r\n\r\nimport type { BoundingBox } from \"../maths/boundingBox\";\r\nimport { GetBoundingBox } from \"../maths/boundingBox\";\r\n\r\nimport type { AnimationConfiguration } from \"../lottiePlayer\";\r\n\r\n/**\r\n * Information about a sprite in the sprite atlas.\r\n */\r\nexport type SpriteAtlasInfo = {\r\n /**\r\n * Offset in the x axis of the sprite in the atlas.\r\n * Normalized between 0 and 1, left to right.\r\n */\r\n uOffset: number;\r\n /**\r\n * Offset in the y axis of the sprite in the atlas.\r\n * Normalized between 0 and 1, top to bottom.\r\n */\r\n vOffset: number;\r\n\r\n /**\r\n * Width of the sprite in the atlas.\r\n * In pixels.\r\n */\r\n cellWidth: number;\r\n\r\n /**\r\n * Height of the sprite in the atlas.\r\n * In pixels.\r\n */\r\n cellHeight: number;\r\n\r\n /**\r\n * Width of the sprite in the screen.\r\n * In pixels.\r\n */\r\n widthPx: number;\r\n /**\r\n * Height of the sprite in the screen.\r\n * In pixels.\r\n */\r\n heightPx: number;\r\n\r\n /**\r\n * X coordinate of the center of the sprite bounding box, used for final positioning in the screen\r\n */\r\n centerX: number;\r\n\r\n /**\r\n * Y coordinate of the center of the sprite bounding box, used for final positioning in the screen\r\n */\r\n centerY: number;\r\n};\r\n\r\n/**\r\n * Information about a gradient stop.\r\n * Used for gradient fills when adding vector shapes to the sprite atlas.\r\n */\r\ntype GradientStop = {\r\n offset: number;\r\n color: string;\r\n};\r\n\r\n/**\r\n * SpritePacker is a class that handles the packing of sprites into a texture atlas.\r\n */\r\nexport class SpritePacker {\r\n private readonly _engine: ThinEngine;\r\n private readonly _configuration: AnimationConfiguration;\r\n\r\n private _spritesCanvas: OffscreenCanvas;\r\n private _spritesCanvasContext: OffscreenCanvasRenderingContext2D;\r\n private readonly _spritesInternalTexture: InternalTexture;\r\n private readonly _spritesTexture: ThinTexture;\r\n\r\n private _isDirty: boolean; // Indicates if the sprite atlas needs to be updated\r\n private _currentX: number;\r\n private _currentY: number;\r\n private _maxRowHeight: number; // Keep track of the maximum height of the current row to handle sprite packing correctly\r\n\r\n // Variable to avoid allocations\r\n private _spriteAtlasInfo: SpriteAtlasInfo;\r\n\r\n /**\r\n * Gets the texture atlas that contains all the sprites packed by this SpritePacker.\r\n * @returns The texture atlas containing the sprites.\r\n */\r\n public get texture(): ThinTexture {\r\n return this._spritesTexture;\r\n }\r\n\r\n /**\r\n * Creates a new instance of SpritePacker.\r\n * @param engine Engine that will render the sprites.\r\n * @param configuration Configuration options for the sprite packer.\r\n */\r\n public constructor(engine: ThinEngine, configuration: AnimationConfiguration) {\r\n this._engine = engine;\r\n this._configuration = configuration;\r\n this._isDirty = false;\r\n this._currentX = 0;\r\n this._currentY = 0;\r\n this._maxRowHeight = 0;\r\n\r\n this._spritesCanvas = new OffscreenCanvas(this._configuration.spriteAtlasSize, this._configuration.spriteAtlasSize);\r\n this._spritesCanvasContext = this._spritesCanvas.getContext(\"2d\") as OffscreenCanvasRenderingContext2D;\r\n\r\n this._spritesInternalTexture = this._engine.createDynamicTexture(this._configuration.spriteAtlasSize, this._configuration.spriteAtlasSize, false, 2); // Linear filtering\r\n this._engine.updateDynamicTexture(this._spritesInternalTexture, this._spritesCanvas, false);\r\n\r\n this._spritesTexture = new ThinTexture(this._spritesInternalTexture);\r\n this._spritesTexture.wrapU = 0; // Disable wrapping\r\n this._spritesTexture.wrapV = 0; // Disable wrapping\r\n\r\n this._spriteAtlasInfo = {\r\n uOffset: 0,\r\n vOffset: 0,\r\n cellWidth: 0,\r\n cellHeight: 0,\r\n widthPx: 0,\r\n heightPx: 0,\r\n centerX: 0,\r\n centerY: 0,\r\n };\r\n }\r\n\r\n /**\r\n * Adds a vector shape that comes from lottie data to the sprite atlas.\r\n * @param rawGroup The raw group shape to add to the atlas.\r\n * @param scalingFactor The scaling factor to apply to the shape.\r\n * @returns The information on how to find the sprite in the atlas.\r\n */\r\n public addLottieShape(rawGroup: RawGroupShape, scalingFactor: IVector2Like): SpriteAtlasInfo {\r\n const boundingBox = GetBoundingBox(rawGroup);\r\n this._spriteAtlasInfo.cellWidth = boundingBox.width * scalingFactor.x;\r\n this._spriteAtlasInfo.cellHeight = boundingBox.height * scalingFactor.y;\r\n\r\n this._spriteAtlasInfo.centerX = boundingBox.centerX;\r\n this._spriteAtlasInfo.centerY = boundingBox.centerY;\r\n\r\n // Check if the sprite fits in the current row\r\n if (this._currentX + this._spriteAtlasInfo.cellWidth > this._configuration.spriteAtlasSize) {\r\n this._currentX = 0;\r\n this._currentY += this._maxRowHeight + this._configuration.gapSize; // Add a gap between sprites to avoid bleeding\r\n this._maxRowHeight = 0;\r\n }\r\n\r\n // Normalize the x/y offsets in texture coordinates (0 to 1)\r\n this._spriteAtlasInfo.uOffset = this._currentX / this._configuration.spriteAtlasSize;\r\n this._spriteAtlasInfo.vOffset = this._currentY / this._configuration.spriteAtlasSize;\r\n\r\n this._drawVectorShape(rawGroup, boundingBox, scalingFactor);\r\n\r\n this._currentX += this._spriteAtlasInfo.cellWidth + this._configuration.gapSize; // Add a gap between sprites to avoid bleeding\r\n this._maxRowHeight = Math.max(this._maxRowHeight, this._spriteAtlasInfo.cellHeight);\r\n\r\n this._spriteAtlasInfo.widthPx = boundingBox.width;\r\n this._spriteAtlasInfo.heightPx = boundingBox.height;\r\n\r\n this._isDirty = true;\r\n\r\n return this._spriteAtlasInfo;\r\n }\r\n\r\n /**\r\n * Updates the internal atlas texture with the information that has been added to the SpritePacker.\r\n */\r\n public updateAtlasTexture(): void {\r\n if (!this._isDirty) {\r\n return; // No need to update if nothing has changed\r\n }\r\n\r\n // Update the internal texture with the new canvas content\r\n this._engine.updateDynamicTexture(this._spritesInternalTexture, this._spritesCanvas, false);\r\n this._isDirty = false;\r\n }\r\n\r\n /**\r\n * Releases the canvas and its context to allow garbage collection.\r\n */\r\n public releaseCanvas(): void {\r\n this._spritesCanvasContext = undefined as any; // Clear the context to allow garbage collection\r\n this._spritesCanvas = undefined as any; // Clear the canvas to allow garbage collection\r\n }\r\n\r\n private _drawVectorShape(rawGroup: RawGroupShape, boundingBox: BoundingBox, scalingFactor: IVector2Like): void {\r\n this._spritesCanvasContext.save();\r\n\r\n this._spritesCanvasContext.translate(this._currentX, this._currentY);\r\n this._spritesCanvasContext.scale(scalingFactor.x, scalingFactor.y);\r\n\r\n this._spritesCanvasContext.beginPath();\r\n if (rawGroup.it) {\r\n for (let i = 0; i < rawGroup.it.length; i++) {\r\n const shape = rawGroup.it[i];\r\n switch (shape.ty) {\r\n case \"rc\":\r\n this._drawRectangle(shape as RawRectangleShape);\r\n break;\r\n case \"sh\":\r\n this._drawPath(shape as RawPathShape, boundingBox);\r\n break;\r\n case \"fl\":\r\n this._drawFill(shape as RawFillShape);\r\n break;\r\n case \"gf\":\r\n this._drawGradientFill(shape as RawGradientFillShape, boundingBox);\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this._spritesCanvasContext.restore();\r\n }\r\n\r\n private _drawRectangle(shape: RawRectangleShape): void {\r\n const size = shape.s.k as number[];\r\n const radius = shape.r.k as number;\r\n\r\n if (radius <= 0) {\r\n this._spritesCanvasContext.rect(0, 0, size[0], size[1]);\r\n } else {\r\n this._spritesCanvasContext.roundRect(0, 0, size[0], size[1], radius);\r\n }\r\n }\r\n\r\n private _drawPath(shape: RawPathShape, boundingBox: BoundingBox): void {\r\n const pathData = shape.ks.k as RawBezier;\r\n const xTranslate = boundingBox.width / 2 - boundingBox.centerX;\r\n const yTranslate = boundingBox.height / 2 - boundingBox.centerY;\r\n\r\n const vertices = pathData.v;\r\n const inTangents = pathData.i;\r\n const outTangents = pathData.o;\r\n\r\n if (vertices.length > 0) {\r\n this._spritesCanvasContext.moveTo(vertices[0][0] + xTranslate, vertices[0][1] + yTranslate);\r\n\r\n for (let i = 0; i < vertices.length - 1; i++) {\r\n const start = vertices[i];\r\n const end = vertices[i + 1];\r\n const outTangent = outTangents[i];\r\n const inTangent = inTangents[i + 1];\r\n\r\n this._spritesCanvasContext.bezierCurveTo(\r\n start[0] + xTranslate + outTangent[0],\r\n start[1] + yTranslate + outTangent[1],\r\n end[0] + xTranslate + inTangent[0],\r\n end[1] + yTranslate + inTangent[1],\r\n end[0] + xTranslate,\r\n end[1] + yTranslate\r\n );\r\n }\r\n\r\n if (pathData.c) {\r\n // Close path with curve from last to first point\r\n const start = vertices[vertices.length - 1];\r\n const end = vertices[0];\r\n const outTangent = outTangents[vertices.length - 1];\r\n const inTangent = inTangents[0];\r\n\r\n this._spritesCanvasContext.bezierCurveTo(\r\n start[0] + xTranslate + outTangent[0],\r\n start[1] + yTranslate + outTangent[1],\r\n end[0] + xTranslate + inTangent[0],\r\n end[1] + yTranslate + inTangent[1],\r\n end[0] + xTranslate,\r\n end[1] + yTranslate\r\n );\r\n\r\n this._spritesCanvasContext.closePath();\r\n }\r\n }\r\n }\r\n\r\n private _drawFill(fill: RawFillShape): void {\r\n const color = this._lottieColorToCSSColor(fill.c.k as number[], (fill.o.k as number) / 100);\r\n this._spritesCanvasContext.fillStyle = color;\r\n\r\n this._spritesCanvasContext.fill();\r\n }\r\n\r\n private _drawGradientFill(fill: RawGradientFillShape, boundingBox: BoundingBox): void {\r\n switch (fill.t) {\r\n case 1: {\r\n this._drawLinearGradientFill(fill, boundingBox);\r\n break;\r\n }\r\n case 2: {\r\n this._drawRadialGradientFill(fill, boundingBox);\r\n break;\r\n }\r\n }\r\n }\r\n\r\n private _drawLinearGradientFill(fill: RawGradientFillShape, boundingBox: BoundingBox): void {\r\n const xTranslate = boundingBox.width / 2 - boundingBox.centerX;\r\n const yTranslate = boundingBox.height / 2 - boundingBox.centerY;\r\n\r\n // Create the gradient\r\n const startPoint = fill.s.k as number[];\r\n const endPoint = fill.e.k as number[];\r\n const gradient = this._spritesCanvasContext.createLinearGradient(\r\n startPoint[0] + xTranslate,\r\n startPoint[1] + yTranslate,\r\n endPoint[0] + xTranslate,\r\n endPoint[1] + yTranslate\r\n );\r\n\r\n this._addColorStops(gradient, fill);\r\n\r\n this._spritesCanvasContext.fillStyle = gradient;\r\n this._spritesCanvasContext.fill();\r\n }\r\n\r\n private _drawRadialGradientFill(fill: RawGradientFillShape, boundingBox: BoundingBox): void {\r\n const xTranslate = boundingBox.width / 2 - boundingBox.centerX;\r\n const yTranslate = boundingBox.height / 2 - boundingBox.centerY;\r\n\r\n // Create the gradient\r\n const startPoint = fill.s.k as number[];\r\n const endPoint = fill.e.k as number[];\r\n\r\n const gradient = this._spritesCanvasContext.createRadialGradient(\r\n startPoint[0] + xTranslate,\r\n startPoint[1] + yTranslate,\r\n 0,\r\n endPoint[0] + xTranslate,\r\n endPoint[1] + yTranslate,\r\n Math.hypot(endPoint[0] - startPoint[0], endPoint[1] - startPoint[1]) // End radius\r\n );\r\n\r\n this._addColorStops(gradient, fill);\r\n\r\n this._spritesCanvasContext.fillStyle = gradient;\r\n this._spritesCanvasContext.fill();\r\n }\r\n\r\n private _addColorStops(gradient: CanvasGradient, fill: RawGradientFillShape): void {\r\n const stops = fill.g.p;\r\n const rawColors = fill.g.k.k;\r\n\r\n let stopsData: GradientStop[] | undefined = undefined;\r\n if (rawColors.length / stops === 4) {\r\n stopsData = this._gradientColorsToCssColor(rawColors, stops, false);\r\n } else if (rawColors.length / stops === 6) {\r\n stopsData = this._gradientColorsToCssColor(rawColors, stops, true);\r\n } else {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < stops; i++) {\r\n gradient.addColorStop(stopsData[i].offset, stopsData[i].color);\r\n }\r\n }\r\n\r\n private _gradientColorsToCssColor(colors: number[], stops: number, hasAlpha: boolean): GradientStop[] {\r\n const skipElement = hasAlpha ? 0 : 1;\r\n const result: GradientStop[] = [];\r\n for (let i = 0; i < stops; i++) {\r\n const index = i * 4;\r\n result.push({\r\n offset: colors[index],\r\n color: this._lottieColorToCSSColor(colors.slice(index + skipElement, index + 4), 1),\r\n });\r\n }\r\n\r\n return result;\r\n }\r\n\r\n private _lottieColorToCSSColor(color: number[], opacity: number): string {\r\n if (color.length !== 3 && color.length !== 4) {\r\n return \"rgba(0, 0, 0, 1)\"; // Default to black if invalid\r\n }\r\n\r\n const r = Math.round(color[0] * 255);\r\n const g = Math.round(color[1] * 255);\r\n const b = Math.round(color[2] * 255);\r\n const a = (color[3] || 1) * opacity;\r\n\r\n return `rgba(${r}, ${g}, ${b}, ${a})`;\r\n }\r\n}\r\n"]}
|
package/lottie/worker.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lottie/worker.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { AnimationController } from "./rendering/animationController.js";
|
|
2
|
-
let AnimationPlayer = null;
|
|
3
|
-
/**
|
|
4
|
-
* Default configuration for lottie animations playback.
|
|
5
|
-
*/
|
|
6
|
-
const DefaultConfiguration = {
|
|
7
|
-
loopAnimation: false, // By default do not loop animations
|
|
8
|
-
spriteAtlasSize: 2048, // Size of the texture atlas
|
|
9
|
-
gapSize: 5, // Gap around the sprites in the atlas
|
|
10
|
-
spritesCapacity: 64, // Maximum number of sprites the renderer can handle at once
|
|
11
|
-
backgroundColor: { r: 1, g: 1, b: 1, a: 1 }, // Background color for the animation canvas
|
|
12
|
-
scaleMultiplier: 5, // Minimum scale factor to prevent too small sprites,
|
|
13
|
-
devicePixelRatio: 1, // Scale factor,
|
|
14
|
-
easingSteps: 4, // Number of steps to sample easing functions for animations - Less than 4 causes issues with some interpolations
|
|
15
|
-
ignoreOpacityAnimations: true, // Whether to ignore opacity animations for performance
|
|
16
|
-
supportDeviceLost: false, // Whether to support device lost events for WebGL contexts,
|
|
17
|
-
};
|
|
18
|
-
onmessage = async function (evt) {
|
|
19
|
-
if (evt.data.canvas && evt.data.file) {
|
|
20
|
-
const canvas = evt.data.canvas;
|
|
21
|
-
const file = evt.data.file;
|
|
22
|
-
const originalConfig = evt.data.config;
|
|
23
|
-
const finalConfig = {
|
|
24
|
-
...DefaultConfiguration,
|
|
25
|
-
...originalConfig,
|
|
26
|
-
};
|
|
27
|
-
const animationData = await (await fetch(file)).text();
|
|
28
|
-
AnimationPlayer = new AnimationController(canvas, animationData, finalConfig);
|
|
29
|
-
postMessage({
|
|
30
|
-
animationWidth: AnimationPlayer.animationWidth,
|
|
31
|
-
animationHeight: AnimationPlayer.animationHeight,
|
|
32
|
-
});
|
|
33
|
-
AnimationPlayer.playAnimation(finalConfig.loopAnimation);
|
|
34
|
-
}
|
|
35
|
-
else if (evt.data.width && evt.data.height) {
|
|
36
|
-
AnimationPlayer && AnimationPlayer.setSize(evt.data.width, evt.data.height);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=worker.js.map
|
package/lottie/worker.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|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C,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;QAE9E,WAAW,CAAC;YACR,cAAc,EAAE,eAAe,CAAC,cAAc;YAC9C,eAAe,EAAE,eAAe,CAAC,eAAe;SACnD,CAAC,CAAC;QAEH,eAAe,CAAC,aAAa,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC7D,CAAC;SAAM,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QAC3C,eAAe,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChF,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\n\r\nimport type { AnimationConfiguration } from \"./lottiePlayer\";\r\nimport { AnimationController } from \"./rendering/animationController\";\r\n\r\nlet AnimationPlayer: Nullable<AnimationController> = null;\r\n\r\n/**\r\n * Default configuration for lottie animations playback.\r\n */\r\nconst DefaultConfiguration = {\r\n loopAnimation: false, // By default do not loop animations\r\n spriteAtlasSize: 2048, // Size of the texture atlas\r\n gapSize: 5, // Gap around the sprites in the atlas\r\n spritesCapacity: 64, // Maximum number of sprites the renderer can handle at once\r\n backgroundColor: { r: 1, g: 1, b: 1, a: 1 }, // Background color for the animation canvas\r\n scaleMultiplier: 5, // Minimum scale factor to prevent too small sprites,\r\n devicePixelRatio: 1, // Scale factor,\r\n easingSteps: 4, // Number of steps to sample easing functions for animations - Less than 4 causes issues with some interpolations\r\n ignoreOpacityAnimations: true, // Whether to ignore opacity animations for performance\r\n supportDeviceLost: false, // Whether to support device lost events for WebGL contexts,\r\n} as const satisfies AnimationConfiguration;\r\n\r\nonmessage = async function (evt) {\r\n if (evt.data.canvas && evt.data.file) {\r\n const canvas = evt.data.canvas as HTMLCanvasElement;\r\n const file = evt.data.file as string;\r\n const originalConfig = evt.data.config as AnimationConfiguration;\r\n const finalConfig: AnimationConfiguration = {\r\n ...DefaultConfiguration,\r\n ...originalConfig,\r\n };\r\n\r\n const animationData = await (await fetch(file)).text();\r\n AnimationPlayer = new AnimationController(canvas, animationData, finalConfig);\r\n\r\n postMessage({\r\n animationWidth: AnimationPlayer.animationWidth,\r\n animationHeight: AnimationPlayer.animationHeight,\r\n });\r\n\r\n AnimationPlayer.playAnimation(finalConfig.loopAnimation);\r\n } else if (evt.data.width && evt.data.height) {\r\n AnimationPlayer && AnimationPlayer.setSize(evt.data.width, evt.data.height);\r\n }\r\n};\r\n"]}
|