@babylonjs/lite-gl 0.1.0 → 1.0.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.
- package/README.md +10 -35
- package/apply-states.d.ts +1 -0
- package/apply-states.js +30 -0
- package/apply-states.js.map +1 -0
- package/blend.d.ts +123 -0
- package/blend.js +194 -0
- package/blend.js.map +1 -0
- package/context.d.ts +130 -0
- package/context.js +354 -0
- package/context.js.map +1 -0
- package/depth-stencil.d.ts +155 -231
- package/depth-stencil.js +399 -262
- package/depth-stencil.js.map +1 -1
- package/dynamic-texture.d.ts +59 -149
- package/dynamic-texture.js +123 -69
- package/dynamic-texture.js.map +1 -1
- package/effect-renderer.d.ts +65 -0
- package/effect-renderer.js +132 -0
- package/effect-renderer.js.map +1 -0
- package/effect.d.ts +142 -0
- package/effect.js +465 -0
- package/effect.js.map +1 -0
- package/html-texture.d.ts +44 -143
- package/html-texture.js +87 -81
- package/html-texture.js.map +1 -1
- package/index.d.ts +23 -1482
- package/index.js +42 -263
- package/index.js.map +1 -1
- package/mesh.d.ts +210 -307
- package/mesh.js +436 -311
- package/mesh.js.map +1 -1
- package/package.json +5 -29
- package/render-loop.d.ts +8 -0
- package/render-loop.js +62 -0
- package/render-loop.js.map +1 -0
- package/render-target.d.ts +190 -290
- package/render-target.js +459 -328
- package/render-target.js.map +1 -1
- package/scissor.d.ts +30 -72
- package/scissor.js +47 -33
- package/scissor.js.map +1 -1
- package/shader.d.ts +22 -0
- package/shader.js +65 -0
- package/shader.js.map +1 -0
- package/sprites.d.ts +182 -263
- package/sprites.js +426 -10
- package/sprites.js.map +1 -1
- package/state.d.ts +126 -0
- package/state.js +153 -0
- package/state.js.map +1 -0
- package/texture.d.ts +142 -0
- package/texture.js +433 -0
- package/texture.js.map +1 -0
- package/effect-BxxwfB_O.js +0 -737
- package/effect-BxxwfB_O.js.map +0 -1
- package/sprites--1oyVtJ3.js +0 -437
- package/sprites--1oyVtJ3.js.map +0 -1
- package/state--j_ncWIi.js +0 -155
- package/state--j_ncWIi.js.map +0 -1
- package/texture-DaMd1gGm.js +0 -329
- package/texture-DaMd1gGm.js.map +0 -1
package/sprites.d.ts
CHANGED
|
@@ -1,263 +1,182 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
*
|
|
59
|
-
* `
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
*
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
*
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
/** Cell height in texels within the sprite sheet. Optional — defaults to
|
|
184
|
-
* `1`. See {@link GLSpriteRendererOptions.cellWidth}. */
|
|
185
|
-
cellHeight?: number;
|
|
186
|
-
/** Per-corner UV/position inset applied to each quad vertex, in the `[0, 0.5)`
|
|
187
|
-
* range — the `epsilon` constructor argument of Babylon's `SpriteRenderer`.
|
|
188
|
-
* It both insets cell UV sampling (so a cell never bleeds its neighbours) and
|
|
189
|
-
* shrinks the quad by `epsilon * size` per side. Defaults to `0.01` (Babylon's
|
|
190
|
-
* `SpriteRenderer` default). Pass `0` to disable insetting — the lottie atlas
|
|
191
|
-
* does this (it relies on edge-extruded cells + center sampling instead, so a
|
|
192
|
-
* non-zero inset would shrink every sprite by ~`0.01·size` per edge). */
|
|
193
|
-
epsilon?: number;
|
|
194
|
-
/** The sprite-sheet texture. May be swapped later via
|
|
195
|
-
* {@link setSpriteRendererTexture}. */
|
|
196
|
-
texture: GLTexture;
|
|
197
|
-
/** Blend mode for the draw. Defaults to {@link GLBlendMode.ALPHA} (2),
|
|
198
|
-
* matching Babylon's `SpriteRenderer.blendMode` default. */
|
|
199
|
-
blendMode?: GLBlendMode;
|
|
200
|
-
/** When `true` (default), `renderSprites` resets the blend mode to
|
|
201
|
-
* {@link GLBlendMode.DISABLE} after drawing — mirroring Babylon's
|
|
202
|
-
* `SpriteRenderer.autoResetAlpha = true`. Set `false` to leave the
|
|
203
|
-
* renderer's `blendMode` applied after the draw (the lottie player relies
|
|
204
|
-
* on this so its premultiplied alpha mode persists across passes). */
|
|
205
|
-
autoResetAlpha?: boolean;
|
|
206
|
-
/** Accepted for Babylon API parity. lite-gl's default engine has no depth
|
|
207
|
-
* attachment (`depth: false`), so there is no depth pre-pass and this flag
|
|
208
|
-
* has no observable effect; it is stored verbatim for a future depth-aware
|
|
209
|
-
* consumer. Defaults to `false`. */
|
|
210
|
-
disableDepthWrite?: boolean;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Pure-state texture handle. The `handle` field is MUTABLE so the same logical
|
|
215
|
-
* texture survives a `webglcontextrestored` event — every consumer keeps the
|
|
216
|
-
* same `GLTexture` reference; only the internal `WebGLTexture` is swapped.
|
|
217
|
-
*
|
|
218
|
-
* `loadTexture2D` also uses the same handle for the 1×1 placeholder upload AND
|
|
219
|
-
* the final image upload — so a `bindTexture(engine, unit, tex)` made before the
|
|
220
|
-
* image has decoded remains valid once the image arrives.
|
|
221
|
-
*/
|
|
222
|
-
declare interface GLTexture {
|
|
223
|
-
/** The live `WebGLTexture`. MUTABLE — swapped for a fresh handle on
|
|
224
|
-
* `webglcontextrestored` while consumers keep the same `GLTexture` reference. */
|
|
225
|
-
handle: WebGLTexture;
|
|
226
|
-
/** GL texture target (always `gl.TEXTURE_2D` for this package). */
|
|
227
|
-
readonly target: GLenum;
|
|
228
|
-
/** Texture width in texels. Updated once an async upload resolves. */
|
|
229
|
-
width: number;
|
|
230
|
-
/** Texture height in texels. Updated once an async upload resolves. */
|
|
231
|
-
height: number;
|
|
232
|
-
/** True when the texture is safe to sample with final content (placeholders
|
|
233
|
-
* read as not-ready until their image/upload completes). */
|
|
234
|
-
isReady: boolean;
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Build the per-sprite vertex data and draw all visible sprites in one
|
|
238
|
-
* `drawElements` call. Performs no allocations — the vertex scratch is reused
|
|
239
|
-
* and uploaded with `bufferSubData`.
|
|
240
|
-
*
|
|
241
|
-
* No-op when the context is lost/disposed, the renderer is disposed, the
|
|
242
|
-
* texture is not ready, the effect is not ready, or there are no visible
|
|
243
|
-
* sprites. Sets the renderer's blend mode before drawing and resets to
|
|
244
|
-
* {@link GLBlendMode.DISABLE} afterwards (matching Babylon's
|
|
245
|
-
* `autoResetAlpha = true`), so a subsequent `drawEffect` is unaffected.
|
|
246
|
-
*
|
|
247
|
-
* @param renderer - The renderer to draw with.
|
|
248
|
-
* @param sprites - The sprites to draw (only `isVisible !== false` are drawn;
|
|
249
|
-
* excess beyond `capacity` is ignored, matching Babylon).
|
|
250
|
-
* @param deltaTime - Accepted for Babylon API parity; unused (lite-gl `GLSprite`
|
|
251
|
-
* holds no animation state, so `cellIndex` is consumer-driven).
|
|
252
|
-
* @param viewMatrix - Column-major 4x4 view matrix.
|
|
253
|
-
* @param projectionMatrix - Column-major 4x4 projection matrix.
|
|
254
|
-
*/
|
|
255
|
-
export declare function renderSprites(renderer: GLSpriteRenderer, sprites: readonly GLSprite[], deltaTime: number, viewMatrix: Float32Array | number[], projectionMatrix: Float32Array | number[]): void;
|
|
256
|
-
|
|
257
|
-
/** Swap the sprite-sheet texture (≙ Babylon assigning `SpriteRenderer.texture`
|
|
258
|
-
* after an async load). The cell size is unchanged — adjust `cellWidth` /
|
|
259
|
-
* `cellHeight` on the renderer directly if the new sheet differs. No-op when
|
|
260
|
-
* the renderer is disposed. */
|
|
261
|
-
export declare function setSpriteRendererTexture(renderer: GLSpriteRenderer, texture: GLTexture): void;
|
|
262
|
-
|
|
263
|
-
export { }
|
|
1
|
+
/**
|
|
2
|
+
* Sprite / instanced-quad renderer.
|
|
3
|
+
*
|
|
4
|
+
* Part of the public API via the `@babylonjs/lite-gl` barrel. The package is
|
|
5
|
+
* `sideEffects: false`, so consumers that don't render sprites tree-shake it out.
|
|
6
|
+
*
|
|
7
|
+
* This is the lite-gl equivalent of Babylon's `SpriteRenderer` + `ThinSprite`
|
|
8
|
+
* (`Sprites/spriteRenderer.js`, `Sprites/thinSprite.js`). The vertex layout,
|
|
9
|
+
* per-cell UV math and corner/rotation transform are copied verbatim from the
|
|
10
|
+
* non-instanced path of Babylon's `SpriteRenderer` so a future NeonBrush port
|
|
11
|
+
* renders identically. The shaders are the GLSL ES 3.00 translation of
|
|
12
|
+
* Babylon's `Shaders/sprites.vertex.js` / `sprites.fragment.js`, with the
|
|
13
|
+
* fog / log-depth / pixel-perfect / alpha-test branches removed (lite-gl has
|
|
14
|
+
* no depth attachment by default — see notes on `disableDepthWrite` below).
|
|
15
|
+
*/
|
|
16
|
+
import { type GLEngineContext } from "./context.js";
|
|
17
|
+
import { GLBlendMode } from "./blend.js";
|
|
18
|
+
import { type GLTexture } from "./texture.js";
|
|
19
|
+
/** An RGBA color with each channel in `[0, 1]`, used for per-sprite tint. */
|
|
20
|
+
export interface GLSpriteColor {
|
|
21
|
+
/** Red, 0..1. */
|
|
22
|
+
r: number;
|
|
23
|
+
/** Green, 0..1. */
|
|
24
|
+
g: number;
|
|
25
|
+
/** Blue, 0..1. */
|
|
26
|
+
b: number;
|
|
27
|
+
/** Alpha, 0..1. */
|
|
28
|
+
a: number;
|
|
29
|
+
}
|
|
30
|
+
/** A single sprite — a plain data object mirroring the fields of Babylon's
|
|
31
|
+
* `ThinSprite` that the renderer reads. No animation state: `cellIndex` is set
|
|
32
|
+
* directly by the consumer (lite-gl does not port `ThinSprite.playAnimation`). */
|
|
33
|
+
export interface GLSprite {
|
|
34
|
+
/** World-space position of the sprite center. */
|
|
35
|
+
position: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
z: number;
|
|
39
|
+
};
|
|
40
|
+
/** Width in world units. */
|
|
41
|
+
width: number;
|
|
42
|
+
/** Height in world units. */
|
|
43
|
+
height: number;
|
|
44
|
+
/** Rotation angle, in radians. */
|
|
45
|
+
angle: number;
|
|
46
|
+
/** Sprite-sheet cell index (0-based, row-major). Out-of-range / negative
|
|
47
|
+
* values are clamped to 0, matching Babylon's `if (!cellIndex) = 0`. Ignored
|
|
48
|
+
* when a manual UV rect (`uSize`) is set. Optional — defaults to `0`. */
|
|
49
|
+
cellIndex?: number;
|
|
50
|
+
/** Optional tint; defaults to opaque white `{ r: 1, g: 1, b: 1, a: 1 }`. */
|
|
51
|
+
color?: GLSpriteColor;
|
|
52
|
+
/** Flip the cell horizontally. Defaults to `false`. */
|
|
53
|
+
invertU?: boolean;
|
|
54
|
+
/** Flip the cell vertically. Defaults to `false`. */
|
|
55
|
+
invertV?: boolean;
|
|
56
|
+
/** Manual UV rect — normalized left (U) origin in `[0, 1]`, mirroring
|
|
57
|
+
* Babylon's `ThinSprite._xOffset`. Set together with {@link GLSprite.uSize}
|
|
58
|
+
* to address an arbitrary sub-rectangle of the sheet instead of the fixed
|
|
59
|
+
* `cellIndex` grid (used by the lottie atlas, whose cells vary in size). */
|
|
60
|
+
uOffset?: number;
|
|
61
|
+
/** Manual UV rect — normalized top (V) origin in `[0, 1]` (≙ Babylon
|
|
62
|
+
* `ThinSprite._yOffset`). See {@link GLSprite.uSize}. */
|
|
63
|
+
vOffset?: number;
|
|
64
|
+
/** Manual UV rect — cell width in **texels** (≙ Babylon `ThinSprite._xSize`;
|
|
65
|
+
* divided by the texture width when building vertices). Presence of `uSize`
|
|
66
|
+
* switches the sprite into manual-UV mode (the `cellIndex` grid is ignored).
|
|
67
|
+
* `0` samples a single column — the "solid color" trick. */
|
|
68
|
+
uSize?: number;
|
|
69
|
+
/** Manual UV rect — cell height in **texels** (≙ Babylon `ThinSprite._ySize`).
|
|
70
|
+
* See {@link GLSprite.uSize}. Defaults to `0` when `uSize` is set but `vSize`
|
|
71
|
+
* is omitted. */
|
|
72
|
+
vSize?: number;
|
|
73
|
+
/** When `false`, the sprite is skipped. Defaults to `true`. */
|
|
74
|
+
isVisible?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/** Options for {@link createSpriteRenderer}. */
|
|
77
|
+
export interface GLSpriteRendererOptions {
|
|
78
|
+
/** Maximum number of sprites drawable in one `renderSprites` call. Must be
|
|
79
|
+
* an integer in `[1, 16384]` (the `Uint16` index-buffer limit). */
|
|
80
|
+
capacity: number;
|
|
81
|
+
/** Cell width in texels within the sprite sheet, for the fixed-grid
|
|
82
|
+
* `cellIndex` path. Optional — defaults to `1`; irrelevant when every
|
|
83
|
+
* sprite supplies a manual UV rect (`uSize`), as the lottie atlas does. */
|
|
84
|
+
cellWidth?: number;
|
|
85
|
+
/** Cell height in texels within the sprite sheet. Optional — defaults to
|
|
86
|
+
* `1`. See {@link GLSpriteRendererOptions.cellWidth}. */
|
|
87
|
+
cellHeight?: number;
|
|
88
|
+
/** Per-corner UV/position inset applied to each quad vertex, in the `[0, 0.5)`
|
|
89
|
+
* range — the `epsilon` constructor argument of Babylon's `SpriteRenderer`.
|
|
90
|
+
* It both insets cell UV sampling (so a cell never bleeds its neighbours) and
|
|
91
|
+
* shrinks the quad by `epsilon * size` per side. Defaults to `0.01` (Babylon's
|
|
92
|
+
* `SpriteRenderer` default). Pass `0` to disable insetting — the lottie atlas
|
|
93
|
+
* does this (it relies on edge-extruded cells + center sampling instead, so a
|
|
94
|
+
* non-zero inset would shrink every sprite by ~`0.01·size` per edge). */
|
|
95
|
+
epsilon?: number;
|
|
96
|
+
/** The sprite-sheet texture. May be swapped later via
|
|
97
|
+
* {@link setSpriteRendererTexture}. */
|
|
98
|
+
texture: GLTexture;
|
|
99
|
+
/** Blend mode for the draw. Defaults to {@link GLBlendMode.ALPHA} (2),
|
|
100
|
+
* matching Babylon's `SpriteRenderer.blendMode` default. */
|
|
101
|
+
blendMode?: GLBlendMode;
|
|
102
|
+
/** When `true` (default), `renderSprites` resets the blend mode to
|
|
103
|
+
* {@link GLBlendMode.DISABLE} after drawing — mirroring Babylon's
|
|
104
|
+
* `SpriteRenderer.autoResetAlpha = true`. Set `false` to leave the
|
|
105
|
+
* renderer's `blendMode` applied after the draw (the lottie player relies
|
|
106
|
+
* on this so its premultiplied alpha mode persists across passes). */
|
|
107
|
+
autoResetAlpha?: boolean;
|
|
108
|
+
/** Accepted for Babylon API parity. lite-gl's default engine has no depth
|
|
109
|
+
* attachment (`depth: false`), so there is no depth pre-pass and this flag
|
|
110
|
+
* has no observable effect; it is stored verbatim for a future depth-aware
|
|
111
|
+
* consumer. Defaults to `false`. */
|
|
112
|
+
disableDepthWrite?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A sprite renderer owning its own VBO/IBO/VAO and `GLEffect`. Created by
|
|
116
|
+
* {@link createSpriteRenderer}; drive it with {@link renderSprites} and release
|
|
117
|
+
* it with {@link disposeSpriteRenderer}.
|
|
118
|
+
*/
|
|
119
|
+
export interface GLSpriteRenderer {
|
|
120
|
+
/** The sprite-sheet texture sampled by the shader. Swap via
|
|
121
|
+
* {@link setSpriteRendererTexture}. */
|
|
122
|
+
texture: GLTexture;
|
|
123
|
+
/** Cell width in texels (selects the sub-rectangle for `cellIndex`). */
|
|
124
|
+
cellWidth: number;
|
|
125
|
+
/** Cell height in texels. */
|
|
126
|
+
cellHeight: number;
|
|
127
|
+
/** Per-corner UV/position inset (Babylon `SpriteRenderer` `epsilon`). */
|
|
128
|
+
epsilon: number;
|
|
129
|
+
/** Active blend mode applied by `renderSprites` before drawing. */
|
|
130
|
+
blendMode: GLBlendMode;
|
|
131
|
+
/** When `true`, `renderSprites` resets blend to {@link GLBlendMode.DISABLE}
|
|
132
|
+
* after drawing (Babylon `autoResetAlpha`). */
|
|
133
|
+
autoResetAlpha: boolean;
|
|
134
|
+
/** Babylon-parity flag (no effect without a depth attachment). */
|
|
135
|
+
disableDepthWrite: boolean;
|
|
136
|
+
/** Maximum sprites per draw, fixed at creation. */
|
|
137
|
+
readonly capacity: number;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Create a sprite renderer with its own GPU buffers and compiled effect.
|
|
141
|
+
*
|
|
142
|
+
* Preallocates the CPU vertex scratch and the index buffer at `capacity`, so
|
|
143
|
+
* {@link renderSprites} performs no allocations. The sprite GPU buffers are
|
|
144
|
+
* rebuilt automatically on `webglcontextrestored` (the owned effect is rebuilt
|
|
145
|
+
* by the engine's context-restore protocol).
|
|
146
|
+
*
|
|
147
|
+
* @param engine - The engine to create GL resources on.
|
|
148
|
+
* @param options - See {@link GLSpriteRendererOptions}.
|
|
149
|
+
* @returns The new {@link GLSpriteRenderer}.
|
|
150
|
+
* @throws If `capacity` is not an integer in `[1, 16384]`, or if a provided
|
|
151
|
+
* `cellWidth`/`cellHeight` is not positive.
|
|
152
|
+
*/
|
|
153
|
+
export declare function createSpriteRenderer(engine: GLEngineContext, options: GLSpriteRendererOptions): GLSpriteRenderer;
|
|
154
|
+
/**
|
|
155
|
+
* Build the per-sprite vertex data and draw all visible sprites in one
|
|
156
|
+
* `drawElements` call. Performs no allocations — the vertex scratch is reused
|
|
157
|
+
* and uploaded with `bufferSubData`.
|
|
158
|
+
*
|
|
159
|
+
* No-op when the context is lost/disposed, the renderer is disposed, the
|
|
160
|
+
* texture is not ready, the effect is not ready, or there are no visible
|
|
161
|
+
* sprites. Sets the renderer's blend mode before drawing and resets to
|
|
162
|
+
* {@link GLBlendMode.DISABLE} afterwards (matching Babylon's
|
|
163
|
+
* `autoResetAlpha = true`), so a subsequent `drawEffect` is unaffected.
|
|
164
|
+
*
|
|
165
|
+
* @param renderer - The renderer to draw with.
|
|
166
|
+
* @param sprites - The sprites to draw (only `isVisible !== false` are drawn;
|
|
167
|
+
* excess beyond `capacity` is ignored, matching Babylon).
|
|
168
|
+
* @param deltaTime - Accepted for Babylon API parity; unused (lite-gl `GLSprite`
|
|
169
|
+
* holds no animation state, so `cellIndex` is consumer-driven).
|
|
170
|
+
* @param viewMatrix - Column-major 4x4 view matrix.
|
|
171
|
+
* @param projectionMatrix - Column-major 4x4 projection matrix.
|
|
172
|
+
*/
|
|
173
|
+
export declare function renderSprites(renderer: GLSpriteRenderer, sprites: readonly GLSprite[], deltaTime: number, viewMatrix: Float32Array | number[], projectionMatrix: Float32Array | number[]): void;
|
|
174
|
+
/** Swap the sprite-sheet texture (≙ Babylon assigning `SpriteRenderer.texture`
|
|
175
|
+
* after an async load). The cell size is unchanged — adjust `cellWidth` /
|
|
176
|
+
* `cellHeight` on the renderer directly if the new sheet differs. No-op when
|
|
177
|
+
* the renderer is disposed. */
|
|
178
|
+
export declare function setSpriteRendererTexture(renderer: GLSpriteRenderer, texture: GLTexture): void;
|
|
179
|
+
/** Release the renderer's VAO/VBO/IBO and the effect it owns, and unregister
|
|
180
|
+
* its context-restore handler. Idempotent. Does NOT dispose the texture — the
|
|
181
|
+
* consumer that supplied it owns its lifetime. */
|
|
182
|
+
export declare function disposeSpriteRenderer(renderer: GLSpriteRenderer): void;
|