@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/mesh.d.ts CHANGED
@@ -1,307 +1,210 @@
1
- /**
2
- * Configure vertex attributes from `vb`, reproducing Babylon's
3
- * `bindInstancesBuffer` exactly. For each descriptor: resolves the location
4
- * (explicit `index` or via the effect), enables the attribute array, issues
5
- * `vertexAttribPointer`, and sets the vertex divisor (`undefined → 1`). Every
6
- * touched location is tracked so {@link unbindInstanceAttributes} can reset its
7
- * divisor afterwards.
8
- *
9
- * `computeStride` controls the GL stride passed to `vertexAttribPointer`:
10
- * - `false` (default) → stride `0`: each attribute is independently tightly
11
- * packed. Combined with overlapping `offset`s this yields the "sliding window"
12
- * ShapeBuilder uses for distance-field tape buffers.
13
- * - `true` → stride = Σ(`size`·4 bytes): interleaved per-vertex/per-instance.
14
- *
15
- * Runs on the default (null) VAO — never corrupts the quad / sprite VAOs.
16
- * No-op on a lost/disposed context or before the effect is ready.
17
- *
18
- * @param engine - The engine.
19
- * @param vb - The buffer supplying the attribute data.
20
- * @param descriptors - The attribute layout.
21
- * @param effect - The effect whose attribute locations resolve unnamed indices.
22
- * @param computeStride - See above. Default `false`.
23
- */
24
- export declare function bindAttributes(engine: GLEngineContext, vb: GLVertexBuffer, descriptors: readonly GLAttributeDescriptor[], effect: GLEffect, computeStride?: boolean): void;
25
-
26
- /**
27
- * Bind an index buffer as the current element-array buffer (on the default
28
- * VAO). Cached. The lite-gl equivalent of Babylon's `_bindIndexBufferWithCache`.
29
- *
30
- * @param engine - The engine.
31
- * @param ib - The index buffer to bind.
32
- */
33
- export declare function bindIndexBuffer(engine: GLEngineContext, ib: GLIndexBuffer): void;
34
-
35
- /**
36
- * Bind a {@link GLMeshVao} (cached `gl.bindVertexArray`). Rarely called directly —
37
- * {@link drawMesh} binds it for you. Binding restores the VAO's recorded element
38
- * binding, so the element-buffer cache is updated in lock-step.
39
- *
40
- * @param engine - The engine.
41
- * @param vao - The mesh VAO to bind.
42
- */
43
- export declare function bindMeshVao(engine: GLEngineContext, vao: GLMeshVao): void;
44
-
45
- /**
46
- * Create a GPU index buffer. `Uint16Array` → 16-bit indices, `Uint32Array` →
47
- * 32-bit. Binds the default VAO first so it never corrupts the quad / sprite
48
- * VAO element bindings.
49
- *
50
- * @param engine - The engine.
51
- * @param data - The index data. Retained by reference for context-restore.
52
- * @returns The new {@link GLIndexBuffer}.
53
- */
54
- export declare function createIndexBuffer(engine: GLEngineContext, data: Uint16Array | Uint32Array): GLIndexBuffer;
55
-
56
- /**
57
- * Record a static mesh's attribute layout + index binding into a new VAO. The
58
- * effect MUST be ready (its attribute locations are resolved here, once). Returns
59
- * a {@link GLMeshVao} to draw with {@link drawMesh}.
60
- *
61
- * @param engine - The engine.
62
- * @param vertexBuffers - One or more buffers + their attribute layouts.
63
- * @param indexBuffer - The index buffer recorded into the VAO.
64
- * @param effect - The effect whose attribute locations resolve unnamed indices.
65
- * @returns The recorded {@link GLMeshVao}.
66
- */
67
- export declare function createMeshVao(engine: GLEngineContext, vertexBuffers: readonly GLMeshVertexBuffer[], indexBuffer: GLIndexBuffer, effect: GLEffect): GLMeshVao;
68
-
69
- /**
70
- * Create a GPU vertex buffer from interleaved float data.
71
- *
72
- * @param engine - The engine.
73
- * @param data - The vertex data. Retained by reference for context-restore — do
74
- * not mutate it in place; use {@link updateVertexBuffer} to change contents.
75
- * @param dynamic - Hint that the buffer will be updated frequently
76
- * (`DYNAMIC_DRAW`). Default `false` (`STATIC_DRAW`).
77
- * @returns The new {@link GLVertexBuffer}.
78
- */
79
- export declare function createVertexBuffer(engine: GLEngineContext, data: Float32Array, dynamic?: boolean): GLVertexBuffer;
80
-
81
- /** Dispose a vertex or index buffer (delete the GL buffer + unregister). Clears
82
- * the array/element-buffer cache slot if it pointed at this buffer. Idempotent. */
83
- export declare function disposeBuffer(engine: GLEngineContext, buffer: GLVertexBuffer | GLIndexBuffer): void;
84
-
85
- /** Dispose a {@link GLMeshVao}: delete the VAO and unregister its restore hook.
86
- * Does NOT dispose the vertex/index buffers (the caller owns those). Idempotent. */
87
- export declare function disposeMeshVao(engine: GLEngineContext, vao: GLMeshVao): void;
88
-
89
- /**
90
- * Draw indexed triangles from `ib` — the lite-gl equivalent of Babylon's
91
- * `drawElementsType` (triangle fill mode). When `instanceCount > 0` issues
92
- * `drawElementsInstanced`, otherwise `drawElements`. No-op on a lost/disposed
93
- * context or when no program is current.
94
- *
95
- * @param engine - The engine.
96
- * @param ib - The index buffer (also bound as a side-effect, cached).
97
- * @param indexCount - Number of indices to draw.
98
- * @param indexStart - First index offset (in indices, not bytes). Default 0.
99
- * @param instanceCount - Instance count for instanced draws. Default 0
100
- * (non-instanced).
101
- */
102
- export declare function drawIndexed(engine: GLEngineContext, ib: GLIndexBuffer, indexCount: number, indexStart?: number, instanceCount?: number): void;
103
-
104
- /**
105
- * Draw a static mesh recorded with {@link createMeshVao}: binds its VAO (cached),
106
- * flushes deferred GL state, and issues ONE `drawElements` (or
107
- * `drawElementsInstanced` when `instanceCount > 0`) over the VAO's full index
108
- * buffer. No per-draw attribute (re)binding. No-op on a lost/disposed context, a
109
- * disposed VAO, or when no program is current.
110
- *
111
- * @param engine - The engine.
112
- * @param vao - The mesh VAO to draw.
113
- * @param instanceCount - Instance count for instanced draws. Default 0 (non-instanced).
114
- */
115
- export declare function drawMesh(engine: GLEngineContext, vao: GLMeshVao, instanceCount?: number): void;
116
-
117
- /**
118
- * Describes one vertex attribute fed from a buffer — the lite-gl equivalent of
119
- * Babylon's `InstancingAttributeInfo`. Pass an array of these to
120
- * {@link bindAttributes}.
121
- */
122
- export declare interface GLAttributeDescriptor {
123
- /** Attribute name; resolved to a location via the effect when `index` is
124
- * omitted (`Effect.getAttributeLocationByName`). */
125
- name?: string;
126
- /** Explicit attribute location. When set, overrides the `name` lookup. */
127
- index?: number;
128
- /** Number of components, 1–4. */
129
- size: number;
130
- /** Byte offset of this attribute's first element within the buffer. Default 0. */
131
- offset?: number;
132
- /**
133
- * Per-instance vertex divisor. **Omitted/`undefined` → `1` (instanced)**,
134
- * matching Babylon's `bindInstancesBuffer`. Pass `0` explicitly for a
135
- * per-vertex attribute (e.g. the base mesh position).
136
- */
137
- divisor?: number;
138
- /** GL component type. Default `gl.FLOAT`. */
139
- type?: GLenum;
140
- /** Normalize fixed-point integer data to `[0,1]`/`[-1,1]`. Default `false`. */
141
- normalized?: boolean;
142
- }
143
-
144
- /** A compiled + linked shader program with cached uniform, sampler and
145
- * attribute locations. Created by `createEffect`; most fields are managed
146
- * internally — drive it via `isEffectReady` / `useEffect` / the `setEffect*`
147
- * setters rather than mutating it directly. */
148
- declare interface GLEffect {
149
- /** The `name` from the originating `GLEffectOptions`. */
150
- readonly name: string;
151
- /** The options this effect was created from (retained for context-restore). */
152
- readonly options: GLEffectOptions;
153
- /** The live `WebGLProgram`. Swapped for a fresh handle after context-restore. */
154
- program: WebGLProgram;
155
1
  /** Resolved during readiness finalization. Missing names map to `null` —
156
- * setters with a `null` location are silent no-ops (matches Babylon). */
157
- uniformLocations: {
158
- [name: string]: WebGLUniformLocation | null;
159
- };
160
- /** Fixed unit assignment for declared samplers, index into
161
- * `_state.boundTextures`. */
162
- samplerUnits: {
163
- [name: string]: number;
164
- };
165
2
  /** Resolved attribute locations, keyed by attribute name. */
166
- attributeLocations: {
167
- [name: string]: number;
168
- };
169
3
  /** True once the program has linked and finalization has run; the
170
- * `setEffect*` setters are no-ops until then. Poll `isEffectReady` to advance it. */
171
- isReady: boolean;
172
-
173
- /** Inputs to `createEffect`: shader sources plus the uniform, sampler and
174
- * attribute names whose locations are resolved during readiness finalization. */
175
- declare interface GLEffectOptions {
176
- /** Human-readable label, surfaced in compile/link error messages. */
177
- name: string;
178
- /** GLSL ES 3.00 source, ready for `gl.shaderSource`. */
179
- vertexSource: string;
180
- /** GLSL ES 3.00 source, ready for `gl.shaderSource`. */
181
- fragmentSource: string;
182
- /** Declared uniform names. Locations are resolved during readiness
183
- * finalization. Names not declared here are legal but allocate cache
184
- * slots lazily on first setter use. */
185
- uniformNames: readonly string[];
186
- /** Declared sampler names, in unit-assignment order. Each gets a fixed
187
- * texture unit assigned during readiness finalization, and
188
- * `gl.uniform1i(loc, unit)` is called exactly once per program lifetime
189
- * (re-run after `webglcontextrestored`). */
190
- samplerNames: readonly string[];
191
- /** Default `["position"]`. The first attribute is bound to location 0 via
192
- * `gl.bindAttribLocation(program, 0, name)` BEFORE link, so the shared
193
- * fullscreen-quad VAO always feeds the same location. */
194
- attributeNames?: readonly string[];
195
- /** Optional `#define` block. Each unique `defines` string must be paired
196
- * with the same vertex/fragment source via a separate `createEffect` call —
197
- * the package does NOT cache compiled variants. */
198
- defines?: string;
199
- }
200
-
201
- /** Read-only WebGL2 capability limits, queried once at context creation. */
202
- declare interface GLEngineCaps {
203
- /** `gl.MAX_TEXTURE_SIZE` largest supported texture dimension, in texels. */
204
- readonly maxTextureSize: number;
205
- /** `gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS` — number of sampler binding slots. */
206
- readonly maxTextureUnits: number;
207
- /** The `KHR_parallel_shader_compile` extension used for async link polling,
208
- * or null when unsupported — linking is then treated as synchronous. */
209
- readonly parallelShaderCompile: {
210
- COMPLETION_STATUS_KHR: number;
211
- } | null;
212
- /** True when 32-bit float color attachments are renderable
213
- * (`EXT_color_buffer_float`). Mirrors Babylon's `caps.textureFloatRender`. */
214
- readonly textureFloatRender: boolean;
215
- /** True when 32-bit float textures support linear filtering
216
- * (`OES_texture_float_linear`). Mirrors `caps.textureFloatLinearFiltering`. */
217
- readonly textureFloatLinearFiltering: boolean;
218
- /** True when 16-bit half-float color attachments are renderable
219
- * (`EXT_color_buffer_float` or `EXT_color_buffer_half_float`). Mirrors
220
- * `caps.textureHalfFloatRender`. */
221
- readonly textureHalfFloatRender: boolean;
222
- /** Half-float linear filtering — always `true` in WebGL2 (it is core).
223
- * Kept as a field to mirror Babylon's `caps.textureHalfFloatLinearFiltering`. */
224
- readonly textureHalfFloatLinearFiltering: boolean;
225
- /** Whether non-power-of-two textures need POT dimensions for mips / wrap.
226
- * Always `false` in WebGL2 (NPOT is core). Mirrors `engine.needPOTTextures`. */
227
- readonly needPOTTextures: boolean;
228
- }
229
-
230
- /**
231
- * Pure-state handle for a WebGL2 canvas + its cached GL state.
232
- *
233
- * INVARIANT: consumers MUST NOT mutate GL state directly through `engine.gl`.
234
- * Doing so silently corrupts the cache in `_state`. The package owns every
235
- * GL call. (`engine.gl` is exposed only so downstream code that already has the
236
- * pattern of poking `engine._gl.getExtension(...)` can do that, but must NOT
237
- * call `bindTexture`/`useProgram`/`bindBuffer`/`viewport`/etc.)
238
- */
239
- declare interface GLEngineContext {
240
- /** The canvas the WebGL2 context was acquired from. An `OffscreenCanvas` is
241
- * supported for worker render paths (e.g. the Lottie player); it has no CSS
242
- * box, so it must be sized explicitly via `setGLEngineSize` rather than the
243
- * CSS-derived `resizeGLEngine`. */
244
- readonly canvas: HTMLCanvasElement | OffscreenCanvas;
245
- /** The raw WebGL2 context. Do NOT mutate GL state through it — see the
246
- * type-level invariant above; the package owns every state-changing call. */
247
- readonly gl: WebGL2RenderingContext;
248
- /** Queried capability limits for this context. */
249
- readonly caps: GLEngineCaps;
250
-
251
- /** A GPU index buffer. The lite-gl counterpart of Babylon's `DataBuffer` for
252
- * index data. */
253
- export declare interface GLIndexBuffer {
254
- /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */
255
- handle: WebGLBuffer;
256
- /** Number of indices. */
257
- count: number;
258
- /** `true` for 32-bit (`Uint32Array`) indices, `false` for 16-bit. */
259
- is32Bits: boolean;
260
-
261
- /** A recorded Vertex Array Object capturing a static mesh's attribute layout +
262
- * index binding. Bind + draw it with {@link drawMesh} each frame — the GPU
263
- * replays the entire attribute setup from one `bindVertexArray`. Re-recorded
264
- * automatically on `webglcontextrestored`. */
265
- export declare interface GLMeshVao {
266
- /** The live `WebGLVertexArrayObject`. Swapped on `webglcontextrestored`. */
267
- handle: WebGLVertexArrayObject;
268
-
269
- /** One vertex buffer + its attribute layout, for {@link createMeshVao}. */
270
- export declare interface GLMeshVertexBuffer {
271
- /** The buffer supplying this group's attributes. */
272
- buffer: GLVertexBuffer;
273
- /** The attributes read from `buffer` (same shape as {@link bindAttributes}). */
274
- attributes: readonly GLAttributeDescriptor[];
275
- /** Stride mode (see {@link bindAttributes}): `false` (default) → stride `0`
276
- * per attribute; `true` interleaved stride = Σ(`size`·4). */
277
- computeStride?: boolean;
278
- }
279
-
280
- /** A GPU vertex buffer holding interleaved float vertex data. The lite-gl
281
- * counterpart of Babylon's `DataBuffer` for vertex data. */
282
- export declare interface GLVertexBuffer {
283
- /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */
284
- handle: WebGLBuffer;
285
- /** Size of the GL buffer in bytes. */
286
- byteLength: number;
287
-
288
- /**
289
- * Reset the vertex divisor of every attribute touched by {@link bindAttributes}
290
- * back to 0 — the lite-gl equivalent of Babylon's `unbindInstanceAttributes`.
291
- * Call after an instanced draw so a following non-instanced draw is not skewed.
292
- * No-op on a lost/disposed context.
293
- *
294
- * @param engine - The engine.
295
- */
296
- export declare function unbindInstanceAttributes(engine: GLEngineContext): void;
297
-
298
- /**
299
- * Upload new contents into (part of) a vertex buffer via `bufferSubData`. A
300
- * full-buffer update from offset 0 also refreshes the retained CPU data used
301
- * for context-restore.
302
- *
303
- * @param engine - The engine.
304
- * @param vb - The vertex buffer to update.
305
- * @param data - The new float data.
306
- * @param dstByteOffset - Destination byte offset within the buffer. Default 0.
307
- */
308
- export declare function updateVertexBuffer(engine: GLEngineContext, vb: GLVertexBuffer, data: Float32Array, dstByteOffset?: number): void;
309
-
310
- export { }
4
+ /**
5
+ * Indexed meshes, dynamic vertex/index buffers, and hardware instancing.
6
+ *
7
+ * Part of the public API via the `@babylonjs/lite-gl` barrel. The package is
8
+ * `sideEffects: false`, so consumers that only render the fullscreen quad /
9
+ * sprites tree-shake the mesh code out.
10
+ *
11
+ * This is the lite-gl equivalent of Babylon's `ThinEngine.createVertexBuffer` /
12
+ * `createIndexBuffer` / `_releaseBuffer` / `bindIndexBuffer` /
13
+ * `bindInstancesBuffer` / `unbindInstanceAttributes` / `drawElementsType`. The
14
+ * attribute binder reproduces Babylon's instancing semantics EXACTLY, including
15
+ * the `computeStride = false → stride 0` "sliding window" used by ShapeBuilder's
16
+ * tape buffers (consecutive instances read overlapping vec4 windows) and the
17
+ * `divisor === undefined 1` default.
18
+ *
19
+ * The mesh path runs on the DEFAULT (null) VAO — every buffer/attribute op binds
20
+ * `gl.bindVertexArray(null)` first, so it never corrupts the quad / sprite VAOs.
21
+ * Vertex and index buffers retain their CPU data and re-upload automatically on
22
+ * `webglcontextrestored`.
23
+ */
24
+ import type { GLEngineContext } from "./context.js";
25
+ import { type GLEffect } from "./effect.js";
26
+ /** A GPU vertex buffer holding interleaved float vertex data. The lite-gl
27
+ * counterpart of Babylon's `DataBuffer` for vertex data. */
28
+ export interface GLVertexBuffer {
29
+ /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */
30
+ handle: WebGLBuffer;
31
+ /** Size of the GL buffer in bytes. */
32
+ byteLength: number;
33
+ }
34
+ /** A GPU index buffer. The lite-gl counterpart of Babylon's `DataBuffer` for
35
+ * index data. */
36
+ export interface GLIndexBuffer {
37
+ /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */
38
+ handle: WebGLBuffer;
39
+ /** Number of indices. */
40
+ count: number;
41
+ /** `true` for 32-bit (`Uint32Array`) indices, `false` for 16-bit. */
42
+ is32Bits: boolean;
43
+ }
44
+ /**
45
+ * Describes one vertex attribute fed from a buffer — the lite-gl equivalent of
46
+ * Babylon's `InstancingAttributeInfo`. Pass an array of these to
47
+ * {@link bindAttributes}.
48
+ */
49
+ export interface GLAttributeDescriptor {
50
+ /** Attribute name; resolved to a location via the effect when `index` is
51
+ * omitted (`Effect.getAttributeLocationByName`). */
52
+ name?: string;
53
+ /** Explicit attribute location. When set, overrides the `name` lookup. */
54
+ index?: number;
55
+ /** Number of components, 1–4. */
56
+ size: number;
57
+ /** Byte offset of this attribute's first element within the buffer. Default 0. */
58
+ offset?: number;
59
+ /**
60
+ * Per-instance vertex divisor. **Omitted/`undefined` `1` (instanced)**,
61
+ * matching Babylon's `bindInstancesBuffer`. Pass `0` explicitly for a
62
+ * per-vertex attribute (e.g. the base mesh position).
63
+ */
64
+ divisor?: number;
65
+ /** GL component type. Default `gl.FLOAT`. */
66
+ type?: GLenum;
67
+ /** Normalize fixed-point integer data to `[0,1]`/`[-1,1]`. Default `false`. */
68
+ normalized?: boolean;
69
+ }
70
+ /**
71
+ * Create a GPU vertex buffer from interleaved float data.
72
+ *
73
+ * @param engine - The engine.
74
+ * @param data - The vertex data. Retained by reference for context-restore do
75
+ * not mutate it in place; use {@link updateVertexBuffer} to change contents.
76
+ * @param dynamic - Hint that the buffer will be updated frequently
77
+ * (`DYNAMIC_DRAW`). Default `false` (`STATIC_DRAW`).
78
+ * @returns The new {@link GLVertexBuffer}.
79
+ */
80
+ export declare function createVertexBuffer(engine: GLEngineContext, data: Float32Array, dynamic?: boolean): GLVertexBuffer;
81
+ /**
82
+ * Upload new contents into (part of) a vertex buffer via `bufferSubData`. A
83
+ * full-buffer update from offset 0 also refreshes the retained CPU data used
84
+ * for context-restore.
85
+ *
86
+ * @param engine - The engine.
87
+ * @param vb - The vertex buffer to update.
88
+ * @param data - The new float data.
89
+ * @param dstByteOffset - Destination byte offset within the buffer. Default 0.
90
+ */
91
+ export declare function updateVertexBuffer(engine: GLEngineContext, vb: GLVertexBuffer, data: Float32Array, dstByteOffset?: number): void;
92
+ /**
93
+ * Create a GPU index buffer. `Uint16Array` → 16-bit indices, `Uint32Array` →
94
+ * 32-bit. Binds the default VAO first so it never corrupts the quad / sprite
95
+ * VAO element bindings.
96
+ *
97
+ * @param engine - The engine.
98
+ * @param data - The index data. Retained by reference for context-restore.
99
+ * @returns The new {@link GLIndexBuffer}.
100
+ */
101
+ export declare function createIndexBuffer(engine: GLEngineContext, data: Uint16Array | Uint32Array): GLIndexBuffer;
102
+ /** Dispose a vertex or index buffer (delete the GL buffer + unregister). Clears
103
+ * the array/element-buffer cache slot if it pointed at this buffer. Idempotent. */
104
+ export declare function disposeBuffer(engine: GLEngineContext, buffer: GLVertexBuffer | GLIndexBuffer): void;
105
+ /**
106
+ * Bind an index buffer as the current element-array buffer (on the default
107
+ * VAO). Cached. The lite-gl equivalent of Babylon's `_bindIndexBufferWithCache`.
108
+ *
109
+ * @param engine - The engine.
110
+ * @param ib - The index buffer to bind.
111
+ */
112
+ export declare function bindIndexBuffer(engine: GLEngineContext, ib: GLIndexBuffer): void;
113
+ /**
114
+ * Configure vertex attributes from `vb`, reproducing Babylon's
115
+ * `bindInstancesBuffer` exactly. For each descriptor: resolves the location
116
+ * (explicit `index` or via the effect), enables the attribute array, issues
117
+ * `vertexAttribPointer`, and sets the vertex divisor (`undefined → 1`). Every
118
+ * touched location is tracked so {@link unbindInstanceAttributes} can reset its
119
+ * divisor afterwards.
120
+ *
121
+ * `computeStride` controls the GL stride passed to `vertexAttribPointer`:
122
+ * - `false` (default) → stride `0`: each attribute is independently tightly
123
+ * packed. Combined with overlapping `offset`s this yields the "sliding window"
124
+ * ShapeBuilder uses for distance-field tape buffers.
125
+ * - `true` stride = Σ(`size`·4 bytes): interleaved per-vertex/per-instance.
126
+ *
127
+ * Runs on the default (null) VAO — never corrupts the quad / sprite VAOs.
128
+ * No-op on a lost/disposed context or before the effect is ready.
129
+ *
130
+ * @param engine - The engine.
131
+ * @param vb - The buffer supplying the attribute data.
132
+ * @param descriptors - The attribute layout.
133
+ * @param effect - The effect whose attribute locations resolve unnamed indices.
134
+ * @param computeStride - See above. Default `false`.
135
+ */
136
+ export declare function bindAttributes(engine: GLEngineContext, vb: GLVertexBuffer, descriptors: readonly GLAttributeDescriptor[], effect: GLEffect, computeStride?: boolean): void;
137
+ /**
138
+ * Reset the vertex divisor of every attribute touched by {@link bindAttributes}
139
+ * back to 0 — the lite-gl equivalent of Babylon's `unbindInstanceAttributes`.
140
+ * Call after an instanced draw so a following non-instanced draw is not skewed.
141
+ * No-op on a lost/disposed context.
142
+ *
143
+ * @param engine - The engine.
144
+ */
145
+ export declare function unbindInstanceAttributes(engine: GLEngineContext): void;
146
+ /**
147
+ * Draw indexed triangles from `ib` — the lite-gl equivalent of Babylon's
148
+ * `drawElementsType` (triangle fill mode). When `instanceCount > 0` issues
149
+ * `drawElementsInstanced`, otherwise `drawElements`. No-op on a lost/disposed
150
+ * context or when no program is current.
151
+ *
152
+ * @param engine - The engine.
153
+ * @param ib - The index buffer (also bound as a side-effect, cached).
154
+ * @param indexCount - Number of indices to draw.
155
+ * @param indexStart - First index offset (in indices, not bytes). Default 0.
156
+ * @param instanceCount - Instance count for instanced draws. Default 0
157
+ * (non-instanced).
158
+ */
159
+ export declare function drawIndexed(engine: GLEngineContext, ib: GLIndexBuffer, indexCount: number, indexStart?: number, instanceCount?: number): void;
160
+ /** One vertex buffer + its attribute layout, for {@link createMeshVao}. */
161
+ export interface GLMeshVertexBuffer {
162
+ /** The buffer supplying this group's attributes. */
163
+ buffer: GLVertexBuffer;
164
+ /** The attributes read from `buffer` (same shape as {@link bindAttributes}). */
165
+ attributes: readonly GLAttributeDescriptor[];
166
+ /** Stride mode (see {@link bindAttributes}): `false` (default) → stride `0`
167
+ * per attribute; `true` → interleaved stride = Σ(`size`·4). */
168
+ computeStride?: boolean;
169
+ }
170
+ /** A recorded Vertex Array Object capturing a static mesh's attribute layout +
171
+ * index binding. Bind + draw it with {@link drawMesh} each frame — the GPU
172
+ * replays the entire attribute setup from one `bindVertexArray`. Re-recorded
173
+ * automatically on `webglcontextrestored`. */
174
+ export interface GLMeshVao {
175
+ /** The live `WebGLVertexArrayObject`. Swapped on `webglcontextrestored`. */
176
+ handle: WebGLVertexArrayObject;
177
+ }
178
+ /**
179
+ * Record a static mesh's attribute layout + index binding into a new VAO. The
180
+ * effect MUST be ready (its attribute locations are resolved here, once). Returns
181
+ * a {@link GLMeshVao} to draw with {@link drawMesh}.
182
+ *
183
+ * @param engine - The engine.
184
+ * @param vertexBuffers - One or more buffers + their attribute layouts.
185
+ * @param indexBuffer - The index buffer recorded into the VAO.
186
+ * @param effect - The effect whose attribute locations resolve unnamed indices.
187
+ * @returns The recorded {@link GLMeshVao}.
188
+ */
189
+ export declare function createMeshVao(engine: GLEngineContext, vertexBuffers: readonly GLMeshVertexBuffer[], indexBuffer: GLIndexBuffer, effect: GLEffect): GLMeshVao;
190
+ /**
191
+ * Bind a {@link GLMeshVao} (cached `gl.bindVertexArray`). Rarely called directly —
192
+ * {@link drawMesh} binds it for you. Binding restores the VAO's recorded element
193
+ * binding, so the element-buffer cache is updated in lock-step.
194
+ *
195
+ * @param engine - The engine.
196
+ * @param vao - The mesh VAO to bind.
197
+ */
198
+ export declare function bindMeshVao(engine: GLEngineContext, vao: GLMeshVao): void;
199
+ /**
200
+ * Draw a static mesh recorded with {@link createMeshVao}: binds its VAO (cached),
201
+ * flushes deferred GL state, and issues ONE `drawElements` (or
202
+ * `drawElementsInstanced` when `instanceCount > 0`) over the VAO's full index
203
+ * buffer. No per-draw attribute (re)binding. No-op on a lost/disposed context, a
204
+ * disposed VAO, or when no program is current.
205
+ *
206
+ * @param engine - The engine.
207
+ * @param vao - The mesh VAO to draw.
208
+ * @param instanceCount - Instance count for instanced draws. Default 0 (non-instanced).
209
+ */
210
+ export declare function drawMesh(engine: GLEngineContext, vao: GLMeshVao, instanceCount?: number): void;
211
+ /** Dispose a {@link GLMeshVao}: delete the VAO and unregister its restore hook.
212
+ * Does NOT dispose the vertex/index buffers (the caller owns those). Idempotent. */
213
+ export declare function disposeMeshVao(engine: GLEngineContext, vao: GLMeshVao): void;