@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.
Files changed (61) hide show
  1. package/README.md +10 -35
  2. package/apply-states.d.ts +1 -0
  3. package/apply-states.js +30 -0
  4. package/apply-states.js.map +1 -0
  5. package/blend.d.ts +123 -0
  6. package/blend.js +194 -0
  7. package/blend.js.map +1 -0
  8. package/context.d.ts +130 -0
  9. package/context.js +354 -0
  10. package/context.js.map +1 -0
  11. package/depth-stencil.d.ts +155 -231
  12. package/depth-stencil.js +399 -262
  13. package/depth-stencil.js.map +1 -1
  14. package/dynamic-texture.d.ts +59 -149
  15. package/dynamic-texture.js +123 -69
  16. package/dynamic-texture.js.map +1 -1
  17. package/effect-renderer.d.ts +65 -0
  18. package/effect-renderer.js +132 -0
  19. package/effect-renderer.js.map +1 -0
  20. package/effect.d.ts +142 -0
  21. package/effect.js +465 -0
  22. package/effect.js.map +1 -0
  23. package/html-texture.d.ts +44 -143
  24. package/html-texture.js +87 -81
  25. package/html-texture.js.map +1 -1
  26. package/index.d.ts +23 -1482
  27. package/index.js +42 -263
  28. package/index.js.map +1 -1
  29. package/mesh.d.ts +210 -307
  30. package/mesh.js +436 -311
  31. package/mesh.js.map +1 -1
  32. package/package.json +5 -29
  33. package/render-loop.d.ts +8 -0
  34. package/render-loop.js +62 -0
  35. package/render-loop.js.map +1 -0
  36. package/render-target.d.ts +190 -290
  37. package/render-target.js +459 -328
  38. package/render-target.js.map +1 -1
  39. package/scissor.d.ts +30 -72
  40. package/scissor.js +47 -33
  41. package/scissor.js.map +1 -1
  42. package/shader.d.ts +22 -0
  43. package/shader.js +65 -0
  44. package/shader.js.map +1 -0
  45. package/sprites.d.ts +182 -263
  46. package/sprites.js +426 -10
  47. package/sprites.js.map +1 -1
  48. package/state.d.ts +126 -0
  49. package/state.js +153 -0
  50. package/state.js.map +1 -0
  51. package/texture.d.ts +142 -0
  52. package/texture.js +433 -0
  53. package/texture.js.map +1 -0
  54. package/effect-BxxwfB_O.js +0 -737
  55. package/effect-BxxwfB_O.js.map +0 -1
  56. package/sprites--1oyVtJ3.js +0 -437
  57. package/sprites--1oyVtJ3.js.map +0 -1
  58. package/state--j_ncWIi.js +0 -155
  59. package/state--j_ncWIi.js.map +0 -1
  60. package/texture-DaMd1gGm.js +0 -329
  61. package/texture-DaMd1gGm.js.map +0 -1
package/sprites.d.ts CHANGED
@@ -1,263 +1,182 @@
1
- /**
2
- * Create a sprite renderer with its own GPU buffers and compiled effect.
3
- *
4
- * Preallocates the CPU vertex scratch and the index buffer at `capacity`, so
5
- * {@link renderSprites} performs no allocations. The sprite GPU buffers are
6
- * rebuilt automatically on `webglcontextrestored` (the owned effect is rebuilt
7
- * by the engine's context-restore protocol).
8
- *
9
- * @param engine - The engine to create GL resources on.
10
- * @param options - See {@link GLSpriteRendererOptions}.
11
- * @returns The new {@link GLSpriteRenderer}.
12
- * @throws If `capacity` is not an integer in `[1, 16384]`, or if a provided
13
- * `cellWidth`/`cellHeight` is not positive.
14
- */
15
- export declare function createSpriteRenderer(engine: GLEngineContext, options: GLSpriteRendererOptions): GLSpriteRenderer;
16
-
17
- /** Release the renderer's VAO/VBO/IBO and the effect it owns, and unregister
18
- * its context-restore handler. Idempotent. Does NOT dispose the texture — the
19
- * consumer that supplied it owns its lifetime. */
20
- export declare function disposeSpriteRenderer(renderer: GLSpriteRenderer): void;
21
-
22
- /**
23
- * Supported blend presets. Values mirror Babylon's `Constants.ALPHA_*` so the
24
- * raw Babylon integers can be passed straight through.
25
- */
26
- declare const GLBlendMode: {
27
- /** No blending — `gl.disable(gl.BLEND)`. (`Constants.ALPHA_DISABLE`) */
28
- readonly DISABLE: 0;
29
- /** Additive — `blendFuncSeparate(SRC_ALPHA, ONE, ZERO, ONE)`. (`Constants.ALPHA_ADD`) */
30
- readonly ADD: 1;
31
- /** Standard (non-premultiplied) alpha `blendFuncSeparate(SRC_ALPHA, ONE_MINUS_SRC_ALPHA, ONE, ONE)`. (`Constants.ALPHA_COMBINE`) */
32
- readonly ALPHA: 2;
33
- /** Premultiplied alpha — `blendFuncSeparate(ONE, ONE_MINUS_SRC_ALPHA, ONE, ONE)`. (`Constants.ALPHA_PREMULTIPLIED`) */
34
- readonly PREMULTIPLIED: 7;
35
- };
36
-
37
- /** One of the {@link GLBlendMode} preset values (`0`, `1`, `2` or `7`). */
38
- declare type GLBlendMode = (typeof GLBlendMode)[keyof typeof GLBlendMode];
39
-
40
- /** Read-only WebGL2 capability limits, queried once at context creation. */
41
- declare interface GLEngineCaps {
42
- /** `gl.MAX_TEXTURE_SIZE` largest supported texture dimension, in texels. */
43
- readonly maxTextureSize: number;
44
- /** `gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS` number of sampler binding slots. */
45
- readonly maxTextureUnits: number;
46
- /** The `KHR_parallel_shader_compile` extension used for async link polling,
47
- * or null when unsupported linking is then treated as synchronous. */
48
- readonly parallelShaderCompile: {
49
- COMPLETION_STATUS_KHR: number;
50
- } | null;
51
- /** True when 32-bit float color attachments are renderable
52
- * (`EXT_color_buffer_float`). Mirrors Babylon's `caps.textureFloatRender`. */
53
- readonly textureFloatRender: boolean;
54
- /** True when 32-bit float textures support linear filtering
55
- * (`OES_texture_float_linear`). Mirrors `caps.textureFloatLinearFiltering`. */
56
- readonly textureFloatLinearFiltering: boolean;
57
- /** True when 16-bit half-float color attachments are renderable
58
- * (`EXT_color_buffer_float` or `EXT_color_buffer_half_float`). Mirrors
59
- * `caps.textureHalfFloatRender`. */
60
- readonly textureHalfFloatRender: boolean;
61
- /** Half-float linear filteringalways `true` in WebGL2 (it is core).
62
- * Kept as a field to mirror Babylon's `caps.textureHalfFloatLinearFiltering`. */
63
- readonly textureHalfFloatLinearFiltering: boolean;
64
- /** Whether non-power-of-two textures need POT dimensions for mips / wrap.
65
- * Always `false` in WebGL2 (NPOT is core). Mirrors `engine.needPOTTextures`. */
66
- readonly needPOTTextures: boolean;
67
- }
68
-
69
- /**
70
- * Pure-state handle for a WebGL2 canvas + its cached GL state.
71
- *
72
- * INVARIANT: consumers MUST NOT mutate GL state directly through `engine.gl`.
73
- * Doing so silently corrupts the cache in `_state`. The package owns every
74
- * GL call. (`engine.gl` is exposed only so downstream code that already has the
75
- * pattern of poking `engine._gl.getExtension(...)` can do that, but must NOT
76
- * call `bindTexture`/`useProgram`/`bindBuffer`/`viewport`/etc.)
77
- */
78
- declare interface GLEngineContext {
79
- /** The canvas the WebGL2 context was acquired from. An `OffscreenCanvas` is
80
- * supported for worker render paths (e.g. the Lottie player); it has no CSS
81
- * box, so it must be sized explicitly via `setGLEngineSize` rather than the
82
- * CSS-derived `resizeGLEngine`. */
83
- readonly canvas: HTMLCanvasElement | OffscreenCanvas;
84
- /** The raw WebGL2 context. Do NOT mutate GL state through it — see the
85
- * type-level invariant above; the package owns every state-changing call. */
86
- readonly gl: WebGL2RenderingContext;
87
- /** Queried capability limits for this context. */
88
- readonly caps: GLEngineCaps;
89
-
90
- /** A single sprite a plain data object mirroring the fields of Babylon's
91
- * `ThinSprite` that the renderer reads. No animation state: `cellIndex` is set
92
- * directly by the consumer (lite-gl does not port `ThinSprite.playAnimation`). */
93
- export declare interface GLSprite {
94
- /** World-space position of the sprite center. */
95
- position: {
96
- x: number;
97
- y: number;
98
- z: number;
99
- };
100
- /** Width in world units. */
101
- width: number;
102
- /** Height in world units. */
103
- height: number;
104
- /** Rotation angle, in radians. */
105
- angle: number;
106
- /** Sprite-sheet cell index (0-based, row-major). Out-of-range / negative
107
- * values are clamped to 0, matching Babylon's `if (!cellIndex) = 0`. Ignored
108
- * when a manual UV rect (`uSize`) is set. Optional defaults to `0`. */
109
- cellIndex?: number;
110
- /** Optional tint; defaults to opaque white `{ r: 1, g: 1, b: 1, a: 1 }`. */
111
- color?: GLSpriteColor;
112
- /** Flip the cell horizontally. Defaults to `false`. */
113
- invertU?: boolean;
114
- /** Flip the cell vertically. Defaults to `false`. */
115
- invertV?: boolean;
116
- /** Manual UV rect normalized left (U) origin in `[0, 1]`, mirroring
117
- * Babylon's `ThinSprite._xOffset`. Set together with {@link GLSprite.uSize}
118
- * to address an arbitrary sub-rectangle of the sheet instead of the fixed
119
- * `cellIndex` grid (used by the lottie atlas, whose cells vary in size). */
120
- uOffset?: number;
121
- /** Manual UV rect — normalized top (V) origin in `[0, 1]` (≙ Babylon
122
- * `ThinSprite._yOffset`). See {@link GLSprite.uSize}. */
123
- vOffset?: number;
124
- /** Manual UV rect — cell width in **texels** (≙ Babylon `ThinSprite._xSize`;
125
- * divided by the texture width when building vertices). Presence of `uSize`
126
- * switches the sprite into manual-UV mode (the `cellIndex` grid is ignored).
127
- * `0` samples a single column the "solid color" trick. */
128
- uSize?: number;
129
- /** Manual UV rect cell height in **texels** (≙ Babylon `ThinSprite._ySize`).
130
- * See {@link GLSprite.uSize}. Defaults to `0` when `uSize` is set but `vSize`
131
- * is omitted. */
132
- vSize?: number;
133
- /** When `false`, the sprite is skipped. Defaults to `true`. */
134
- isVisible?: boolean;
135
- }
136
-
137
- /** An RGBA color with each channel in `[0, 1]`, used for per-sprite tint. */
138
- export declare interface GLSpriteColor {
139
- /** Red, 0..1. */
140
- r: number;
141
- /** Green, 0..1. */
142
- g: number;
143
- /** Blue, 0..1. */
144
- b: number;
145
- /** Alpha, 0..1. */
146
- a: number;
147
- }
148
-
149
- /**
150
- * A sprite renderer owning its own VBO/IBO/VAO and `GLEffect`. Created by
151
- * {@link createSpriteRenderer}; drive it with {@link renderSprites} and release
152
- * it with {@link disposeSpriteRenderer}.
153
- */
154
- export declare interface GLSpriteRenderer {
155
- /** The sprite-sheet texture sampled by the shader. Swap via
156
- * {@link setSpriteRendererTexture}. */
157
- texture: GLTexture;
158
- /** Cell width in texels (selects the sub-rectangle for `cellIndex`). */
159
- cellWidth: number;
160
- /** Cell height in texels. */
161
- cellHeight: number;
162
- /** Per-corner UV/position inset (Babylon `SpriteRenderer` `epsilon`). */
163
- epsilon: number;
164
- /** Active blend mode applied by `renderSprites` before drawing. */
165
- blendMode: GLBlendMode;
166
- /** When `true`, `renderSprites` resets blend to {@link GLBlendMode.DISABLE}
167
- * after drawing (Babylon `autoResetAlpha`). */
168
- autoResetAlpha: boolean;
169
- /** Babylon-parity flag (no effect without a depth attachment). */
170
- disableDepthWrite: boolean;
171
- /** Maximum sprites per draw, fixed at creation. */
172
- readonly capacity: number;
173
-
174
- /** Options for {@link createSpriteRenderer}. */
175
- export declare interface GLSpriteRendererOptions {
176
- /** Maximum number of sprites drawable in one `renderSprites` call. Must be
177
- * an integer in `[1, 16384]` (the `Uint16` index-buffer limit). */
178
- capacity: number;
179
- /** Cell width in texels within the sprite sheet, for the fixed-grid
180
- * `cellIndex` path. Optional defaults to `1`; irrelevant when every
181
- * sprite supplies a manual UV rect (`uSize`), as the lottie atlas does. */
182
- cellWidth?: number;
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 rectnormalized 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;