@babylonjs/lite-gl 0.1.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/mesh.js ADDED
@@ -0,0 +1,334 @@
1
+ import { I as getEffectAttributeLocation, m as onContextRestored, k as offContextRestored } from "./effect-BxxwfB_O.js";
2
+ import { a as applyGLStates } from "./state--j_ncWIi.js";
3
+ const ARRAY_BUFFER = 34962;
4
+ const ELEMENT_ARRAY_BUFFER = 34963;
5
+ const STATIC_DRAW = 35044;
6
+ const DYNAMIC_DRAW = 35048;
7
+ const FLOAT = 5126;
8
+ const TRIANGLES = 4;
9
+ const UNSIGNED_SHORT = 5123;
10
+ const UNSIGNED_INT = 5125;
11
+ function createVertexBuffer(engine, data, dynamic = false) {
12
+ const gl = engine.gl;
13
+ const handle = gl.createBuffer();
14
+ if (handle === null) {
15
+ throw new Error("lite-gl: gl.createBuffer returned null (vertex buffer)");
16
+ }
17
+ const vb = {
18
+ handle,
19
+ byteLength: data.byteLength,
20
+ _data: data,
21
+ _dynamic: dynamic,
22
+ _disposed: false,
23
+ _deleteGpu: () => {
24
+ },
25
+ _restore: () => {
26
+ }
27
+ };
28
+ vb._deleteGpu = (g) => {
29
+ g.deleteBuffer(vb.handle);
30
+ };
31
+ vb._restore = (target) => {
32
+ const g = target.gl;
33
+ const fresh = g.createBuffer();
34
+ if (fresh === null) {
35
+ return;
36
+ }
37
+ vb.handle = fresh;
38
+ bindArrayBufferRaw(target, fresh);
39
+ g.bufferData(ARRAY_BUFFER, vb._data, vb._dynamic ? DYNAMIC_DRAW : STATIC_DRAW);
40
+ };
41
+ bindArrayBufferRaw(engine, handle);
42
+ gl.bufferData(ARRAY_BUFFER, data, dynamic ? DYNAMIC_DRAW : STATIC_DRAW);
43
+ engine._buffers.push(vb);
44
+ return vb;
45
+ }
46
+ function updateVertexBuffer(engine, vb, data, dstByteOffset = 0) {
47
+ if (engine._isLost || engine._disposed || vb._disposed) {
48
+ return;
49
+ }
50
+ bindArrayBufferRaw(engine, vb.handle);
51
+ engine.gl.bufferSubData(ARRAY_BUFFER, dstByteOffset, data);
52
+ if (dstByteOffset === 0 && data.byteLength >= vb.byteLength) {
53
+ vb._data = data;
54
+ vb.byteLength = data.byteLength;
55
+ }
56
+ }
57
+ function createIndexBuffer(engine, data) {
58
+ const gl = engine.gl;
59
+ const handle = gl.createBuffer();
60
+ if (handle === null) {
61
+ throw new Error("lite-gl: gl.createBuffer returned null (index buffer)");
62
+ }
63
+ const is32 = data instanceof Uint32Array;
64
+ const ib = {
65
+ handle,
66
+ count: data.length,
67
+ is32Bits: is32,
68
+ _data: data,
69
+ _disposed: false,
70
+ _deleteGpu: () => {
71
+ },
72
+ _restore: () => {
73
+ }
74
+ };
75
+ ib._deleteGpu = (g) => {
76
+ g.deleteBuffer(ib.handle);
77
+ };
78
+ ib._restore = (target) => {
79
+ const g = target.gl;
80
+ const fresh = g.createBuffer();
81
+ if (fresh === null) {
82
+ return;
83
+ }
84
+ ib.handle = fresh;
85
+ bindDefaultVao(target);
86
+ g.bindBuffer(ELEMENT_ARRAY_BUFFER, fresh);
87
+ target._state.boundElementBuffer = fresh;
88
+ g.bufferData(ELEMENT_ARRAY_BUFFER, ib._data, STATIC_DRAW);
89
+ };
90
+ bindDefaultVao(engine);
91
+ gl.bindBuffer(ELEMENT_ARRAY_BUFFER, handle);
92
+ engine._state.boundElementBuffer = handle;
93
+ gl.bufferData(ELEMENT_ARRAY_BUFFER, data, STATIC_DRAW);
94
+ engine._buffers.push(ib);
95
+ return ib;
96
+ }
97
+ function disposeBuffer(engine, buffer) {
98
+ if (buffer._disposed) {
99
+ return;
100
+ }
101
+ buffer._disposed = true;
102
+ const i = engine._buffers.indexOf(buffer);
103
+ if (i !== -1) {
104
+ engine._buffers.splice(i, 1);
105
+ }
106
+ const s = engine._state;
107
+ if (!engine._isLost && !engine._disposed) {
108
+ engine.gl.deleteBuffer(buffer.handle);
109
+ }
110
+ if (s.boundArrayBuffer === buffer.handle) {
111
+ s.boundArrayBuffer = null;
112
+ }
113
+ if (s.boundElementBuffer === buffer.handle) {
114
+ s.boundElementBuffer = null;
115
+ }
116
+ }
117
+ function bindIndexBuffer(engine, ib) {
118
+ if (engine._isLost || engine._disposed || ib._disposed) {
119
+ return;
120
+ }
121
+ bindDefaultVao(engine);
122
+ const s = engine._state;
123
+ if (s.boundElementBuffer === ib.handle) {
124
+ return;
125
+ }
126
+ engine.gl.bindBuffer(ELEMENT_ARRAY_BUFFER, ib.handle);
127
+ s.boundElementBuffer = ib.handle;
128
+ }
129
+ function bindAttributes(engine, vb, descriptors, effect, computeStride = false) {
130
+ if (engine._isLost || engine._disposed || vb._disposed || !effect.isReady) {
131
+ return;
132
+ }
133
+ const gl = engine.gl;
134
+ const s = engine._state;
135
+ bindDefaultVao(engine);
136
+ bindArrayBufferRaw(engine, vb.handle);
137
+ let stride = 0;
138
+ if (computeStride) {
139
+ for (let i = 0; i < descriptors.length; i++) {
140
+ stride += descriptors[i].size * 4;
141
+ }
142
+ }
143
+ for (let i = 0; i < descriptors.length; i++) {
144
+ const d = descriptors[i];
145
+ const loc = d.index !== void 0 ? d.index : d.name !== void 0 ? getEffectAttributeLocation(engine, effect, d.name) : -1;
146
+ if (loc < 0) {
147
+ continue;
148
+ }
149
+ if (!s.enabledAttribs[loc]) {
150
+ gl.enableVertexAttribArray(loc);
151
+ s.enabledAttribs[loc] = true;
152
+ }
153
+ gl.vertexAttribPointer(loc, d.size, d.type ?? FLOAT, d.normalized ?? false, stride, d.offset ?? 0);
154
+ gl.vertexAttribDivisor(loc, d.divisor === void 0 ? 1 : d.divisor);
155
+ s.instanceLocations.push(loc);
156
+ }
157
+ }
158
+ function unbindInstanceAttributes(engine) {
159
+ if (engine._isLost || engine._disposed) {
160
+ return;
161
+ }
162
+ const gl = engine.gl;
163
+ const locs = engine._state.instanceLocations;
164
+ for (let i = 0; i < locs.length; i++) {
165
+ gl.vertexAttribDivisor(locs[i], 0);
166
+ }
167
+ locs.length = 0;
168
+ }
169
+ function drawIndexed(engine, ib, indexCount, indexStart = 0, instanceCount = 0) {
170
+ if (engine._isLost || engine._disposed || ib._disposed) {
171
+ return;
172
+ }
173
+ if (engine._state.currentProgram === null) {
174
+ return;
175
+ }
176
+ bindIndexBuffer(engine, ib);
177
+ const gl = engine.gl;
178
+ const type = ib.is32Bits ? UNSIGNED_INT : UNSIGNED_SHORT;
179
+ const byteOffset = indexStart * (ib.is32Bits ? 4 : 2);
180
+ applyGLStates(engine);
181
+ if (instanceCount > 0) {
182
+ gl.drawElementsInstanced(TRIANGLES, indexCount, type, byteOffset, instanceCount);
183
+ } else {
184
+ gl.drawElements(TRIANGLES, indexCount, type, byteOffset);
185
+ }
186
+ }
187
+ function createMeshVao(engine, vertexBuffers, indexBuffer, effect) {
188
+ const gl = engine.gl;
189
+ if (!effect.isReady) {
190
+ throw new Error("lite-gl: createMeshVao requires a ready effect (poll isEffectReady first)");
191
+ }
192
+ const handle = gl.createVertexArray();
193
+ if (handle === null) {
194
+ throw new Error("lite-gl: gl.createVertexArray returned null (mesh VAO)");
195
+ }
196
+ const bindings = [];
197
+ for (const vbb of vertexBuffers) {
198
+ let stride = 0;
199
+ if (vbb.computeStride) {
200
+ for (let i = 0; i < vbb.attributes.length; i++) {
201
+ stride += vbb.attributes[i].size * 4;
202
+ }
203
+ }
204
+ const attrs = [];
205
+ for (let i = 0; i < vbb.attributes.length; i++) {
206
+ const d = vbb.attributes[i];
207
+ const loc = d.index !== void 0 ? d.index : d.name !== void 0 ? getEffectAttributeLocation(engine, effect, d.name) : -1;
208
+ if (loc < 0) {
209
+ continue;
210
+ }
211
+ attrs.push({
212
+ loc,
213
+ size: d.size,
214
+ type: d.type ?? FLOAT,
215
+ normalized: d.normalized ?? false,
216
+ stride,
217
+ offset: d.offset ?? 0,
218
+ divisor: d.divisor === void 0 ? 1 : d.divisor
219
+ });
220
+ }
221
+ bindings.push({ buffer: vbb.buffer, attrs });
222
+ }
223
+ const vao = { handle, _disposed: false, _indexBuffer: indexBuffer, _bindings: bindings, _restore: () => {
224
+ } };
225
+ vao._restore = () => {
226
+ if (engine._isLost || engine._disposed || vao._disposed) {
227
+ return;
228
+ }
229
+ const fresh = engine.gl.createVertexArray();
230
+ if (fresh === null) {
231
+ return;
232
+ }
233
+ vao.handle = fresh;
234
+ recordMeshVao(engine, vao);
235
+ };
236
+ recordMeshVao(engine, vao);
237
+ onContextRestored(engine, vao._restore);
238
+ return vao;
239
+ }
240
+ function bindMeshVao(engine, vao) {
241
+ if (engine._isLost || engine._disposed || vao._disposed) {
242
+ return;
243
+ }
244
+ const s = engine._state;
245
+ if (s.boundVao === vao.handle) {
246
+ return;
247
+ }
248
+ engine.gl.bindVertexArray(vao.handle);
249
+ s.boundVao = vao.handle;
250
+ s.boundElementBuffer = vao._indexBuffer.handle;
251
+ }
252
+ function drawMesh(engine, vao, instanceCount = 0) {
253
+ if (engine._isLost || engine._disposed || vao._disposed) {
254
+ return;
255
+ }
256
+ if (engine._state.currentProgram === null) {
257
+ return;
258
+ }
259
+ bindMeshVao(engine, vao);
260
+ applyGLStates(engine);
261
+ const ib = vao._indexBuffer;
262
+ const gl = engine.gl;
263
+ const type = ib.is32Bits ? UNSIGNED_INT : UNSIGNED_SHORT;
264
+ if (instanceCount > 0) {
265
+ gl.drawElementsInstanced(TRIANGLES, ib.count, type, 0, instanceCount);
266
+ } else {
267
+ gl.drawElements(TRIANGLES, ib.count, type, 0);
268
+ }
269
+ }
270
+ function disposeMeshVao(engine, vao) {
271
+ if (vao._disposed) {
272
+ return;
273
+ }
274
+ vao._disposed = true;
275
+ offContextRestored(engine, vao._restore);
276
+ if (!engine._isLost && !engine._disposed) {
277
+ const s = engine._state;
278
+ engine.gl.deleteVertexArray(vao.handle);
279
+ if (s.boundVao === vao.handle) {
280
+ engine.gl.bindVertexArray(null);
281
+ s.boundVao = null;
282
+ s.boundElementBuffer = null;
283
+ }
284
+ }
285
+ }
286
+ function recordMeshVao(engine, vao) {
287
+ const gl = engine.gl;
288
+ const s = engine._state;
289
+ gl.bindVertexArray(vao.handle);
290
+ s.boundVao = vao.handle;
291
+ for (const b of vao._bindings) {
292
+ bindArrayBufferRaw(engine, b.buffer.handle);
293
+ for (const a of b.attrs) {
294
+ gl.enableVertexAttribArray(a.loc);
295
+ gl.vertexAttribPointer(a.loc, a.size, a.type, a.normalized, a.stride, a.offset);
296
+ gl.vertexAttribDivisor(a.loc, a.divisor);
297
+ }
298
+ }
299
+ gl.bindBuffer(ELEMENT_ARRAY_BUFFER, vao._indexBuffer.handle);
300
+ gl.bindVertexArray(null);
301
+ s.boundVao = null;
302
+ s.boundElementBuffer = null;
303
+ }
304
+ function bindDefaultVao(engine) {
305
+ const s = engine._state;
306
+ if (s.boundVao !== null) {
307
+ engine.gl.bindVertexArray(null);
308
+ s.boundVao = null;
309
+ s.boundElementBuffer = null;
310
+ }
311
+ }
312
+ function bindArrayBufferRaw(engine, handle) {
313
+ const s = engine._state;
314
+ if (s.boundArrayBuffer === handle) {
315
+ return;
316
+ }
317
+ engine.gl.bindBuffer(ARRAY_BUFFER, handle);
318
+ s.boundArrayBuffer = handle;
319
+ }
320
+ export {
321
+ bindAttributes,
322
+ bindIndexBuffer,
323
+ bindMeshVao,
324
+ createIndexBuffer,
325
+ createMeshVao,
326
+ createVertexBuffer,
327
+ disposeBuffer,
328
+ disposeMeshVao,
329
+ drawIndexed,
330
+ drawMesh,
331
+ unbindInstanceAttributes,
332
+ updateVertexBuffer
333
+ };
334
+ //# sourceMappingURL=mesh.js.map
package/mesh.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mesh.js","sources":["../src/mesh.ts"],"sourcesContent":["/**\n * Sub-entry: indexed meshes, dynamic vertex/index buffers, and hardware\n * instancing.\n *\n * Dynamic-importable via `import { ... } from \"@babylonjs/lite-gl/mesh\"` so\n * consumers that only render the fullscreen quad / sprites don't pull the mesh\n * code into their bundles.\n *\n * This is the lite-gl equivalent of Babylon's `ThinEngine.createVertexBuffer` /\n * `createIndexBuffer` / `_releaseBuffer` / `bindIndexBuffer` /\n * `bindInstancesBuffer` / `unbindInstanceAttributes` / `drawElementsType`. The\n * attribute binder reproduces Babylon's instancing semantics EXACTLY, including\n * the `computeStride = false → stride 0` \"sliding window\" used by ShapeBuilder's\n * tape buffers (consecutive instances read overlapping vec4 windows) and the\n * `divisor === undefined → 1` default.\n *\n * The mesh path runs on the DEFAULT (null) VAO — every buffer/attribute op binds\n * `gl.bindVertexArray(null)` first, so it never corrupts the quad / sprite VAOs.\n * Vertex and index buffers retain their CPU data and re-upload automatically on\n * `webglcontextrestored`.\n */\nimport type { GLEngineContext } from \"./context.js\";\nimport { onContextRestored, offContextRestored } from \"./context.js\";\nimport { getEffectAttributeLocation, type GLEffect } from \"./effect.js\";\nimport { applyGLStates } from \"./apply-states.js\";\n\n/** GL `gl.ARRAY_BUFFER`. */\nconst ARRAY_BUFFER = 0x8892;\n/** GL `gl.ELEMENT_ARRAY_BUFFER`. */\nconst ELEMENT_ARRAY_BUFFER = 0x8893;\n/** GL `gl.STATIC_DRAW`. */\nconst STATIC_DRAW = 0x88e4;\n/** GL `gl.DYNAMIC_DRAW`. */\nconst DYNAMIC_DRAW = 0x88e8;\n/** GL `gl.FLOAT`. */\nconst FLOAT = 0x1406;\n/** GL `gl.TRIANGLES`. */\nconst TRIANGLES = 0x0004;\n/** GL `gl.UNSIGNED_SHORT`. */\nconst UNSIGNED_SHORT = 0x1403;\n/** GL `gl.UNSIGNED_INT`. */\nconst UNSIGNED_INT = 0x1405;\n\n/** A GPU vertex buffer holding interleaved float vertex data. The lite-gl\n * counterpart of Babylon's `DataBuffer` for vertex data. */\nexport interface GLVertexBuffer {\n /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */\n handle: WebGLBuffer;\n /** Size of the GL buffer in bytes. */\n byteLength: number;\n /** @internal */\n _disposed: boolean;\n /** @internal Delete the underlying GL buffer. */\n _deleteGpu: (gl: WebGL2RenderingContext) => void;\n /** @internal Re-create + re-upload the retained CPU data into a fresh handle. */\n _restore: (engine: GLEngineContext) => void;\n /** @internal Retained CPU data for context-restore replay (the creation /\n * last full-buffer upload). */\n _data: Float32Array;\n /** @internal `true` for `DYNAMIC_DRAW` (updated via `updateVertexBuffer`). */\n _dynamic: boolean;\n}\n\n/** A GPU index buffer. The lite-gl counterpart of Babylon's `DataBuffer` for\n * index data. */\nexport interface GLIndexBuffer {\n /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */\n handle: WebGLBuffer;\n /** Number of indices. */\n count: number;\n /** `true` for 32-bit (`Uint32Array`) indices, `false` for 16-bit. */\n is32Bits: boolean;\n /** @internal */\n _disposed: boolean;\n /** @internal Delete the underlying GL buffer. */\n _deleteGpu: (gl: WebGL2RenderingContext) => void;\n /** @internal Re-create + re-upload the retained CPU data into a fresh handle. */\n _restore: (engine: GLEngineContext) => void;\n /** @internal Retained CPU data for context-restore replay. */\n _data: Uint16Array | Uint32Array;\n}\n\n/**\n * Describes one vertex attribute fed from a buffer — the lite-gl equivalent of\n * Babylon's `InstancingAttributeInfo`. Pass an array of these to\n * {@link bindAttributes}.\n */\nexport interface GLAttributeDescriptor {\n /** Attribute name; resolved to a location via the effect when `index` is\n * omitted (`Effect.getAttributeLocationByName`). */\n name?: string;\n /** Explicit attribute location. When set, overrides the `name` lookup. */\n index?: number;\n /** Number of components, 1–4. */\n size: number;\n /** Byte offset of this attribute's first element within the buffer. Default 0. */\n offset?: number;\n /**\n * Per-instance vertex divisor. **Omitted/`undefined` → `1` (instanced)**,\n * matching Babylon's `bindInstancesBuffer`. Pass `0` explicitly for a\n * per-vertex attribute (e.g. the base mesh position).\n */\n divisor?: number;\n /** GL component type. Default `gl.FLOAT`. */\n type?: GLenum;\n /** Normalize fixed-point integer data to `[0,1]`/`[-1,1]`. Default `false`. */\n normalized?: boolean;\n}\n\n/* ──────────────────────────────── buffers ──────────────────────────────── */\n\n/**\n * Create a GPU vertex buffer from interleaved float data.\n *\n * @param engine - The engine.\n * @param data - The vertex data. Retained by reference for context-restore — do\n * not mutate it in place; use {@link updateVertexBuffer} to change contents.\n * @param dynamic - Hint that the buffer will be updated frequently\n * (`DYNAMIC_DRAW`). Default `false` (`STATIC_DRAW`).\n * @returns The new {@link GLVertexBuffer}.\n */\nexport function createVertexBuffer(engine: GLEngineContext, data: Float32Array, dynamic = false): GLVertexBuffer {\n const gl = engine.gl;\n const handle = gl.createBuffer();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (vertex buffer)\");\n }\n const vb: GLVertexBuffer = {\n handle,\n byteLength: data.byteLength,\n _data: data,\n _dynamic: dynamic,\n _disposed: false,\n _deleteGpu: () => {},\n _restore: () => {},\n };\n vb._deleteGpu = (g: WebGL2RenderingContext): void => {\n g.deleteBuffer(vb.handle);\n };\n vb._restore = (target: GLEngineContext): void => {\n const g = target.gl;\n const fresh = g.createBuffer();\n if (fresh === null) {\n return;\n }\n vb.handle = fresh;\n bindArrayBufferRaw(target, fresh);\n g.bufferData(ARRAY_BUFFER, vb._data, vb._dynamic ? DYNAMIC_DRAW : STATIC_DRAW);\n };\n bindArrayBufferRaw(engine, handle);\n gl.bufferData(ARRAY_BUFFER, data, dynamic ? DYNAMIC_DRAW : STATIC_DRAW);\n engine._buffers.push(vb);\n return vb;\n}\n\n/**\n * Upload new contents into (part of) a vertex buffer via `bufferSubData`. A\n * full-buffer update from offset 0 also refreshes the retained CPU data used\n * for context-restore.\n *\n * @param engine - The engine.\n * @param vb - The vertex buffer to update.\n * @param data - The new float data.\n * @param dstByteOffset - Destination byte offset within the buffer. Default 0.\n */\nexport function updateVertexBuffer(engine: GLEngineContext, vb: GLVertexBuffer, data: Float32Array, dstByteOffset = 0): void {\n if (engine._isLost || engine._disposed || vb._disposed) {\n return;\n }\n bindArrayBufferRaw(engine, vb.handle);\n engine.gl.bufferSubData(ARRAY_BUFFER, dstByteOffset, data);\n if (dstByteOffset === 0 && data.byteLength >= vb.byteLength) {\n vb._data = data;\n vb.byteLength = data.byteLength;\n }\n}\n\n/**\n * Create a GPU index buffer. `Uint16Array` → 16-bit indices, `Uint32Array` →\n * 32-bit. Binds the default VAO first so it never corrupts the quad / sprite\n * VAO element bindings.\n *\n * @param engine - The engine.\n * @param data - The index data. Retained by reference for context-restore.\n * @returns The new {@link GLIndexBuffer}.\n */\nexport function createIndexBuffer(engine: GLEngineContext, data: Uint16Array | Uint32Array): GLIndexBuffer {\n const gl = engine.gl;\n const handle = gl.createBuffer();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (index buffer)\");\n }\n const is32 = data instanceof Uint32Array;\n const ib: GLIndexBuffer = {\n handle,\n count: data.length,\n is32Bits: is32,\n _data: data,\n _disposed: false,\n _deleteGpu: () => {},\n _restore: () => {},\n };\n ib._deleteGpu = (g: WebGL2RenderingContext): void => {\n g.deleteBuffer(ib.handle);\n };\n ib._restore = (target: GLEngineContext): void => {\n const g = target.gl;\n const fresh = g.createBuffer();\n if (fresh === null) {\n return;\n }\n ib.handle = fresh;\n bindDefaultVao(target);\n g.bindBuffer(ELEMENT_ARRAY_BUFFER, fresh);\n target._state.boundElementBuffer = fresh;\n g.bufferData(ELEMENT_ARRAY_BUFFER, ib._data, STATIC_DRAW);\n };\n bindDefaultVao(engine);\n gl.bindBuffer(ELEMENT_ARRAY_BUFFER, handle);\n engine._state.boundElementBuffer = handle;\n gl.bufferData(ELEMENT_ARRAY_BUFFER, data, STATIC_DRAW);\n engine._buffers.push(ib);\n return ib;\n}\n\n/** Dispose a vertex or index buffer (delete the GL buffer + unregister). Clears\n * the array/element-buffer cache slot if it pointed at this buffer. Idempotent. */\nexport function disposeBuffer(engine: GLEngineContext, buffer: GLVertexBuffer | GLIndexBuffer): void {\n if (buffer._disposed) {\n return;\n }\n buffer._disposed = true;\n const i = engine._buffers.indexOf(buffer);\n if (i !== -1) {\n engine._buffers.splice(i, 1);\n }\n const s = engine._state;\n if (!engine._isLost && !engine._disposed) {\n engine.gl.deleteBuffer(buffer.handle);\n }\n if (s.boundArrayBuffer === buffer.handle) {\n s.boundArrayBuffer = null;\n }\n if (s.boundElementBuffer === buffer.handle) {\n s.boundElementBuffer = null;\n }\n}\n\n/* ────────────────────────────── binding + draw ──────────────────────────── */\n\n/**\n * Bind an index buffer as the current element-array buffer (on the default\n * VAO). Cached. The lite-gl equivalent of Babylon's `_bindIndexBufferWithCache`.\n *\n * @param engine - The engine.\n * @param ib - The index buffer to bind.\n */\nexport function bindIndexBuffer(engine: GLEngineContext, ib: GLIndexBuffer): void {\n if (engine._isLost || engine._disposed || ib._disposed) {\n return;\n }\n bindDefaultVao(engine);\n const s = engine._state;\n if (s.boundElementBuffer === ib.handle) {\n return;\n }\n engine.gl.bindBuffer(ELEMENT_ARRAY_BUFFER, ib.handle);\n s.boundElementBuffer = ib.handle;\n}\n\n/**\n * Configure vertex attributes from `vb`, reproducing Babylon's\n * `bindInstancesBuffer` exactly. For each descriptor: resolves the location\n * (explicit `index` or via the effect), enables the attribute array, issues\n * `vertexAttribPointer`, and sets the vertex divisor (`undefined → 1`). Every\n * touched location is tracked so {@link unbindInstanceAttributes} can reset its\n * divisor afterwards.\n *\n * `computeStride` controls the GL stride passed to `vertexAttribPointer`:\n * - `false` (default) → stride `0`: each attribute is independently tightly\n * packed. Combined with overlapping `offset`s this yields the \"sliding window\"\n * ShapeBuilder uses for distance-field tape buffers.\n * - `true` → stride = Σ(`size`·4 bytes): interleaved per-vertex/per-instance.\n *\n * Runs on the default (null) VAO — never corrupts the quad / sprite VAOs.\n * No-op on a lost/disposed context or before the effect is ready.\n *\n * @param engine - The engine.\n * @param vb - The buffer supplying the attribute data.\n * @param descriptors - The attribute layout.\n * @param effect - The effect whose attribute locations resolve unnamed indices.\n * @param computeStride - See above. Default `false`.\n */\nexport function bindAttributes(engine: GLEngineContext, vb: GLVertexBuffer, descriptors: readonly GLAttributeDescriptor[], effect: GLEffect, computeStride = false): void {\n if (engine._isLost || engine._disposed || vb._disposed || !effect.isReady) {\n return;\n }\n const gl = engine.gl;\n const s = engine._state;\n bindDefaultVao(engine);\n bindArrayBufferRaw(engine, vb.handle);\n\n let stride = 0;\n if (computeStride) {\n for (let i = 0; i < descriptors.length; i++) {\n stride += (descriptors[i] as GLAttributeDescriptor).size * 4;\n }\n }\n\n for (let i = 0; i < descriptors.length; i++) {\n const d = descriptors[i] as GLAttributeDescriptor;\n const loc = d.index !== undefined ? d.index : d.name !== undefined ? getEffectAttributeLocation(engine, effect, d.name) : -1;\n if (loc < 0) {\n continue;\n }\n if (!s.enabledAttribs[loc]) {\n gl.enableVertexAttribArray(loc);\n s.enabledAttribs[loc] = true;\n }\n gl.vertexAttribPointer(loc, d.size, d.type ?? FLOAT, d.normalized ?? false, stride, d.offset ?? 0);\n gl.vertexAttribDivisor(loc, d.divisor === undefined ? 1 : d.divisor);\n s.instanceLocations.push(loc);\n }\n}\n\n/**\n * Reset the vertex divisor of every attribute touched by {@link bindAttributes}\n * back to 0 — the lite-gl equivalent of Babylon's `unbindInstanceAttributes`.\n * Call after an instanced draw so a following non-instanced draw is not skewed.\n * No-op on a lost/disposed context.\n *\n * @param engine - The engine.\n */\nexport function unbindInstanceAttributes(engine: GLEngineContext): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const gl = engine.gl;\n const locs = engine._state.instanceLocations;\n for (let i = 0; i < locs.length; i++) {\n gl.vertexAttribDivisor(locs[i] as number, 0);\n }\n locs.length = 0;\n}\n\n/**\n * Draw indexed triangles from `ib` — the lite-gl equivalent of Babylon's\n * `drawElementsType` (triangle fill mode). When `instanceCount > 0` issues\n * `drawElementsInstanced`, otherwise `drawElements`. No-op on a lost/disposed\n * context or when no program is current.\n *\n * @param engine - The engine.\n * @param ib - The index buffer (also bound as a side-effect, cached).\n * @param indexCount - Number of indices to draw.\n * @param indexStart - First index offset (in indices, not bytes). Default 0.\n * @param instanceCount - Instance count for instanced draws. Default 0\n * (non-instanced).\n */\nexport function drawIndexed(engine: GLEngineContext, ib: GLIndexBuffer, indexCount: number, indexStart = 0, instanceCount = 0): void {\n if (engine._isLost || engine._disposed || ib._disposed) {\n return;\n }\n if (engine._state.currentProgram === null) {\n return;\n }\n bindIndexBuffer(engine, ib);\n const gl = engine.gl;\n const type = ib.is32Bits ? UNSIGNED_INT : UNSIGNED_SHORT;\n const byteOffset = indexStart * (ib.is32Bits ? 4 : 2);\n applyGLStates(engine);\n if (instanceCount > 0) {\n gl.drawElementsInstanced(TRIANGLES, indexCount, type, byteOffset, instanceCount);\n } else {\n gl.drawElements(TRIANGLES, indexCount, type, byteOffset);\n }\n}\n\n/* ────────────────────────── static mesh VAO ─────────────────────────────\n * The VAO-cached counterpart of the manual `bindAttributes` path above — Babylon's\n * `recordVertexArrayObject` / `_cachedVertexArrayObject` for STATIC meshes. A\n * `GLMeshVao` records the whole attribute layout (enable + pointer + divisor for\n * every attribute, across one or more vertex buffers) AND the index binding into a\n * single VAO ONCE. The per-frame draw is then just `bindVertexArray` +\n * `drawElements[Instanced]` — zero per-draw `vertexAttribPointer`/`vertexAttribDivisor`,\n * and no `unbindInstanceAttributes` (the VAO isolates the divisors from the default\n * VAO). Use this for fixed-layout meshes; keep `bindAttributes` for dynamic layouts\n * (e.g. ShapeBuilder's per-draw sliding-window tape buffers). */\n\n/** One vertex buffer + its attribute layout, for {@link createMeshVao}. */\nexport interface GLMeshVertexBuffer {\n /** The buffer supplying this group's attributes. */\n buffer: GLVertexBuffer;\n /** The attributes read from `buffer` (same shape as {@link bindAttributes}). */\n attributes: readonly GLAttributeDescriptor[];\n /** Stride mode (see {@link bindAttributes}): `false` (default) → stride `0`\n * per attribute; `true` → interleaved stride = Σ(`size`·4). */\n computeStride?: boolean;\n}\n\n/** A recorded Vertex Array Object capturing a static mesh's attribute layout +\n * index binding. Bind + draw it with {@link drawMesh} each frame — the GPU\n * replays the entire attribute setup from one `bindVertexArray`. Re-recorded\n * automatically on `webglcontextrestored`. */\nexport interface GLMeshVao {\n /** The live `WebGLVertexArrayObject`. Swapped on `webglcontextrestored`. */\n handle: WebGLVertexArrayObject;\n /** @internal */\n _disposed: boolean;\n /** @internal The index buffer recorded into the VAO. */\n _indexBuffer: GLIndexBuffer;\n /** @internal Resolved attribute bindings, reused to re-record on restore. */\n _bindings: _ResolvedBinding[];\n /** @internal `webglcontextrestored` re-record hook. */\n _restore: () => void;\n}\n\n/** @internal A single attribute with its location resolved once at record time\n * (locations are stable across re-link via `bindAttribLocation`, so the VAO can\n * re-record on context-restore without the effect). */\ninterface _ResolvedAttr {\n loc: number;\n size: number;\n type: number;\n normalized: boolean;\n stride: number;\n offset: number;\n divisor: number;\n}\n\n/** @internal A vertex buffer + its resolved attributes. */\ninterface _ResolvedBinding {\n buffer: GLVertexBuffer;\n attrs: _ResolvedAttr[];\n}\n\n/**\n * Record a static mesh's attribute layout + index binding into a new VAO. The\n * effect MUST be ready (its attribute locations are resolved here, once). Returns\n * a {@link GLMeshVao} to draw with {@link drawMesh}.\n *\n * @param engine - The engine.\n * @param vertexBuffers - One or more buffers + their attribute layouts.\n * @param indexBuffer - The index buffer recorded into the VAO.\n * @param effect - The effect whose attribute locations resolve unnamed indices.\n * @returns The recorded {@link GLMeshVao}.\n */\nexport function createMeshVao(engine: GLEngineContext, vertexBuffers: readonly GLMeshVertexBuffer[], indexBuffer: GLIndexBuffer, effect: GLEffect): GLMeshVao {\n const gl = engine.gl;\n // The effect's attribute locations are resolved (once) below; an unready effect\n // would resolve every name to -1 → a silently-empty VAO. Fail fast — callers\n // must gate on isEffectReady (see scene10's first-ready-frame creation).\n if (!effect.isReady) {\n throw new Error(\"lite-gl: createMeshVao requires a ready effect (poll isEffectReady first)\");\n }\n const handle = gl.createVertexArray();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createVertexArray returned null (mesh VAO)\");\n }\n // Resolve every attribute location ONCE (stable across re-link), so a restore\n // re-record needs only the buffer handles, not the effect.\n const bindings: _ResolvedBinding[] = [];\n for (const vbb of vertexBuffers) {\n let stride = 0;\n if (vbb.computeStride) {\n for (let i = 0; i < vbb.attributes.length; i++) {\n stride += (vbb.attributes[i] as GLAttributeDescriptor).size * 4;\n }\n }\n const attrs: _ResolvedAttr[] = [];\n for (let i = 0; i < vbb.attributes.length; i++) {\n const d = vbb.attributes[i] as GLAttributeDescriptor;\n const loc = d.index !== undefined ? d.index : d.name !== undefined ? getEffectAttributeLocation(engine, effect, d.name) : -1;\n if (loc < 0) {\n continue;\n }\n attrs.push({\n loc,\n size: d.size,\n type: d.type ?? FLOAT,\n normalized: d.normalized ?? false,\n stride,\n offset: d.offset ?? 0,\n divisor: d.divisor === undefined ? 1 : d.divisor,\n });\n }\n bindings.push({ buffer: vbb.buffer, attrs });\n }\n const vao: GLMeshVao = { handle, _disposed: false, _indexBuffer: indexBuffer, _bindings: bindings, _restore: () => {} };\n vao._restore = (): void => {\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n const fresh = engine.gl.createVertexArray();\n if (fresh === null) {\n return;\n }\n vao.handle = fresh;\n recordMeshVao(engine, vao);\n };\n recordMeshVao(engine, vao);\n onContextRestored(engine, vao._restore);\n return vao;\n}\n\n/**\n * Bind a {@link GLMeshVao} (cached `gl.bindVertexArray`). Rarely called directly —\n * {@link drawMesh} binds it for you. Binding restores the VAO's recorded element\n * binding, so the element-buffer cache is updated in lock-step.\n *\n * @param engine - The engine.\n * @param vao - The mesh VAO to bind.\n */\nexport function bindMeshVao(engine: GLEngineContext, vao: GLMeshVao): void {\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n const s = engine._state;\n if (s.boundVao === vao.handle) {\n return;\n }\n engine.gl.bindVertexArray(vao.handle);\n s.boundVao = vao.handle;\n s.boundElementBuffer = vao._indexBuffer.handle;\n}\n\n/**\n * Draw a static mesh recorded with {@link createMeshVao}: binds its VAO (cached),\n * flushes deferred GL state, and issues ONE `drawElements` (or\n * `drawElementsInstanced` when `instanceCount > 0`) over the VAO's full index\n * buffer. No per-draw attribute (re)binding. No-op on a lost/disposed context, a\n * disposed VAO, or when no program is current.\n *\n * @param engine - The engine.\n * @param vao - The mesh VAO to draw.\n * @param instanceCount - Instance count for instanced draws. Default 0 (non-instanced).\n */\nexport function drawMesh(engine: GLEngineContext, vao: GLMeshVao, instanceCount = 0): void {\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n if (engine._state.currentProgram === null) {\n return;\n }\n bindMeshVao(engine, vao);\n applyGLStates(engine);\n const ib = vao._indexBuffer;\n const gl = engine.gl;\n const type = ib.is32Bits ? UNSIGNED_INT : UNSIGNED_SHORT;\n if (instanceCount > 0) {\n gl.drawElementsInstanced(TRIANGLES, ib.count, type, 0, instanceCount);\n } else {\n gl.drawElements(TRIANGLES, ib.count, type, 0);\n }\n}\n\n/** Dispose a {@link GLMeshVao}: delete the VAO and unregister its restore hook.\n * Does NOT dispose the vertex/index buffers (the caller owns those). Idempotent. */\nexport function disposeMeshVao(engine: GLEngineContext, vao: GLMeshVao): void {\n if (vao._disposed) {\n return;\n }\n vao._disposed = true;\n offContextRestored(engine, vao._restore);\n if (!engine._isLost && !engine._disposed) {\n const s = engine._state;\n engine.gl.deleteVertexArray(vao.handle);\n if (s.boundVao === vao.handle) {\n // Return to the default VAO so the cache stays coherent.\n engine.gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n }\n }\n}\n\n/** @internal Record `vao._bindings` + the index binding into `vao.handle`. Leaves\n * the default (null) VAO bound afterwards (so the mesh VAO is not left current),\n * forgetting the element-buffer cache. Touches neither `s.enabledAttribs` (those\n * track the DEFAULT VAO) nor the divisor reset — all of that lives in the VAO. */\nfunction recordMeshVao(engine: GLEngineContext, vao: GLMeshVao): void {\n const gl = engine.gl;\n const s = engine._state;\n gl.bindVertexArray(vao.handle);\n s.boundVao = vao.handle;\n for (const b of vao._bindings) {\n bindArrayBufferRaw(engine, b.buffer.handle);\n for (const a of b.attrs) {\n gl.enableVertexAttribArray(a.loc);\n gl.vertexAttribPointer(a.loc, a.size, a.type, a.normalized, a.stride, a.offset);\n gl.vertexAttribDivisor(a.loc, a.divisor);\n }\n }\n gl.bindBuffer(ELEMENT_ARRAY_BUFFER, vao._indexBuffer.handle);\n gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n}\n\n/* ──────────────────────────── internal helpers ──────────────────────────── */\n\n/** Bind the default (null) VAO if not already bound. The mesh path lives here so\n * it never disturbs the quad / sprite VAO state. Binding a VAO restores ITS\n * element-array binding, so the element-buffer cache is forgotten on the\n * switch (the next `bindIndexBuffer` re-binds). */\nfunction bindDefaultVao(engine: GLEngineContext): void {\n const s = engine._state;\n if (s.boundVao !== null) {\n engine.gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n }\n}\n\n/** Cached `gl.bindBuffer(ARRAY_BUFFER, …)`. ARRAY_BUFFER binding is global (not\n * VAO state), so this cache is coherent across VAO switches. */\nfunction bindArrayBufferRaw(engine: GLEngineContext, handle: WebGLBuffer): void {\n const s = engine._state;\n if (s.boundArrayBuffer === handle) {\n return;\n }\n engine.gl.bindBuffer(ARRAY_BUFFER, handle);\n s.boundArrayBuffer = handle;\n}\n"],"names":[],"mappings":";;AA2BA,MAAM,eAAe;AAErB,MAAM,uBAAuB;AAE7B,MAAM,cAAc;AAEpB,MAAM,eAAe;AAErB,MAAM,QAAQ;AAEd,MAAM,YAAY;AAElB,MAAM,iBAAiB;AAEvB,MAAM,eAAe;AAgFd,SAAS,mBAAmB,QAAyB,MAAoB,UAAU,OAAuB;AAC7G,QAAM,KAAK,OAAO;AAClB,QAAM,SAAS,GAAG,aAAA;AAClB,MAAI,WAAW,MAAM;AACjB,UAAM,IAAI,MAAM,wDAAwD;AAAA,EAC5E;AACA,QAAM,KAAqB;AAAA,IACvB;AAAA,IACA,YAAY,KAAK;AAAA,IACjB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,WAAW;AAAA,IACX,YAAY,MAAM;AAAA,IAAC;AAAA,IACnB,UAAU,MAAM;AAAA,IAAC;AAAA,EAAA;AAErB,KAAG,aAAa,CAAC,MAAoC;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AM,IAAI,OAAO;AACjB,MAAI,EAAE,qBAAqB,QAAQ;AAC/B;AAAA,EACJ;AACA,SAAO,GAAG,WAAW,cAAc,MAAM;AACzC,IAAE,mBAAmB;AACzB;"}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@babylonjs/lite-gl",
3
+ "version": "0.1.0",
4
+ "description": "Function-based, tree-shakeable WebGL2 micro-engine for fullscreen effects, sprites and dynamic textures — the WebGL counterpart of @babylonjs/lite.",
5
+ "keywords": [
6
+ "babylon",
7
+ "babylonjs",
8
+ "webgl",
9
+ "webgl2",
10
+ "effect",
11
+ "shader",
12
+ "sprite",
13
+ "lite",
14
+ "rendering"
15
+ ],
16
+ "license": "Apache-2.0",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/BabylonJS/Babylon-Lite.git",
20
+ "directory": "packages/babylon-lite-gl"
21
+ },
22
+ "homepage": "https://github.com/BabylonJS/Babylon-Lite/tree/main/packages/babylon-lite-gl",
23
+ "type": "module",
24
+ "main": "./index.js",
25
+ "module": "./index.js",
26
+ "types": "./index.d.ts",
27
+ "sideEffects": false,
28
+ "exports": {
29
+ ".": {
30
+ "import": "./index.js",
31
+ "types": "./index.d.ts"
32
+ },
33
+ "./html-texture": {
34
+ "import": "./html-texture.js",
35
+ "types": "./html-texture.d.ts"
36
+ },
37
+ "./sprites": {
38
+ "import": "./sprites.js",
39
+ "types": "./sprites.d.ts"
40
+ },
41
+ "./render-target": {
42
+ "import": "./render-target.js",
43
+ "types": "./render-target.d.ts"
44
+ },
45
+ "./mesh": {
46
+ "import": "./mesh.js",
47
+ "types": "./mesh.d.ts"
48
+ },
49
+ "./depth-stencil": {
50
+ "import": "./depth-stencil.js",
51
+ "types": "./depth-stencil.d.ts"
52
+ },
53
+ "./scissor": {
54
+ "import": "./scissor.js",
55
+ "types": "./scissor.d.ts"
56
+ },
57
+ "./dynamic-texture": {
58
+ "import": "./dynamic-texture.js",
59
+ "types": "./dynamic-texture.d.ts"
60
+ }
61
+ }
62
+ }