@babylonjs/lite-gl 1.23.0 → 1.24.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 (68) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +98 -2
  3. package/context.d.ts +5 -0
  4. package/context.js +8 -0
  5. package/context.js.map +1 -1
  6. package/depth-stencil.d.ts +1 -14
  7. package/depth-stencil.js.map +1 -1
  8. package/effect-renderer.d.ts +1 -11
  9. package/effect-renderer.js.map +1 -1
  10. package/effect.d.ts +5 -27
  11. package/effect.js +22 -0
  12. package/effect.js.map +1 -1
  13. package/family.d.ts +470 -0
  14. package/family.js +14 -0
  15. package/family.js.map +1 -0
  16. package/index.d.ts +8 -6
  17. package/index.js +3 -3
  18. package/index.js.map +1 -1
  19. package/mesh.d.ts +4 -1
  20. package/mesh.js +10 -3
  21. package/mesh.js.map +1 -1
  22. package/native/command-stream.d.ts +1 -0
  23. package/native/command-stream.js +135 -0
  24. package/native/command-stream.js.map +1 -0
  25. package/native/context.d.ts +26 -0
  26. package/native/context.js +89 -0
  27. package/native/context.js.map +1 -0
  28. package/native/effect.d.ts +44 -0
  29. package/native/effect.js +276 -0
  30. package/native/effect.js.map +1 -0
  31. package/native/family.d.ts +75 -0
  32. package/native/family.js +2 -0
  33. package/native/family.js.map +1 -0
  34. package/native/identity.d.ts +11 -0
  35. package/native/identity.js +2 -0
  36. package/native/identity.js.map +1 -0
  37. package/native/index.d.ts +25 -0
  38. package/native/index.js +7 -0
  39. package/native/index.js.map +1 -0
  40. package/native/mesh.d.ts +53 -0
  41. package/native/mesh.js +137 -0
  42. package/native/mesh.js.map +1 -0
  43. package/native/render-target.d.ts +35 -0
  44. package/native/render-target.js +159 -0
  45. package/native/render-target.js.map +1 -0
  46. package/native/runtime.d.ts +1 -0
  47. package/native/runtime.js +12 -0
  48. package/native/runtime.js.map +1 -0
  49. package/native/state.d.ts +19 -0
  50. package/native/state.js +104 -0
  51. package/native/state.js.map +1 -0
  52. package/native/texture.d.ts +37 -0
  53. package/native/texture.js +86 -0
  54. package/native/texture.js.map +1 -0
  55. package/package.json +11 -3
  56. package/render-target.d.ts +7 -0
  57. package/render-target.js +38 -0
  58. package/render-target.js.map +1 -1
  59. package/scissor.d.ts +2 -2
  60. package/scissor.js +2 -2
  61. package/scissor.js.map +1 -1
  62. package/state.d.ts +1 -0
  63. package/state.js +2 -5
  64. package/state.js.map +1 -1
  65. package/text/text-renderer.js.map +1 -1
  66. package/web-family.d.ts +87 -0
  67. package/web-family.js +2 -0
  68. package/web-family.js.map +1 -0
@@ -1,5 +1,6 @@
1
1
  import type { GLEngineContext } from "./context.js";
2
2
  import { type GLEffect } from "./effect.js";
3
+ import type { GLViewport } from "./family.js";
3
4
  /** Inputs to `createEffectWrapper`. Mirrors lite's `EffectWrapperOptions`: the
4
5
  * wrapper compiles and OWNS the effect built from this shader source. */
5
6
  export interface GLEffectWrapperOptions {
@@ -43,17 +44,6 @@ export declare function createEffectWrapper(engine: GLEngineContext, options: GL
43
44
  *
44
45
  * @param wrapper - The wrapper to dispose. */
45
46
  export declare function disposeEffectWrapper(wrapper: GLEffectWrapper): void;
46
- /** Pixel-space viewport rectangle passed to `setViewport`. */
47
- export interface GLViewport {
48
- /** Lower-left X origin in physical pixels. */
49
- x: number;
50
- /** Lower-left Y origin in physical pixels. */
51
- y: number;
52
- /** Width in physical pixels. */
53
- w: number;
54
- /** Height in physical pixels. */
55
- h: number;
56
- }
57
47
  /** Cached `gl.viewport`. Defaults to the full canvas in pixel coordinates. */
58
48
  export declare function setViewport(engine: GLEngineContext, viewport?: GLViewport): void;
59
49
  /** Make `wrapper.effect` current — the counterpart of Babylon's
@@ -1 +1 @@
1
- {"version":3,"file":"effect-renderer.js","sourceRoot":"","sources":["../src/effect-renderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAiB,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO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IACzB,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,cAAc,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC;IAE/D,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC;IAC9B,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IACpE,CAAC;IACD,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC;IAChB,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;IAC5C,CAAC,CAAC,kBAAkB,GAAG,GAAG,CAAC;IAC3B,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,oBAAoB,EAAE,YAAY,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC;IAErE,EAAE,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;IAC9B,EAAE,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC;AAED;iDACiD;AACjD,MAAM,cAAc,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACtE,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC","sourcesContent":["import type { GLEngineContext } from \"./context.js\";\nimport { createEffect, disposeEffect, type GLEffect, isEffectReady, useEffect } from \"./effect.js\";\nimport { applyGLStates } from \"./apply-states.js\";\n\n/** Built-in fullscreen-quad vertex shader, used when `GLEffectWrapperOptions`\n * omits `vertexSource`. Maps the package's fullscreen-quad positions\n * (attribute location 0) to clip space and forwards a 0..1 `vUv` varying —\n * the WebGL counterpart of lite's default `vertexWGSL`, so callers can pass\n * only `fragmentSource`. */\nconst DEFAULT_FULLSCREEN_VERTEX_SOURCE = `#version 300 es\nlayout(location = 0) in vec2 position;\nout vec2 vUv;\nvoid main() {\n vUv = position * 0.5 + 0.5;\n gl_Position = vec4(position, 0.0, 1.0);\n}`;\n\n/** Inputs to `createEffectWrapper`. Mirrors lite's `EffectWrapperOptions`: the\n * wrapper compiles and OWNS the effect built from this shader source. */\nexport interface GLEffectWrapperOptions {\n /** Human-readable label for the wrapper and its effect. Defaults to\n * `\"effect-wrapper\"`. */\n name?: string;\n /** GLSL ES 3.00 vertex source. Defaults to a built-in fullscreen-quad\n * vertex shader (exposing a `vUv` varying), mirroring lite's default\n * `vertexWGSL`. */\n vertexSource?: string;\n /** GLSL ES 3.00 fragment source (≙ lite's `fragmentWGSL`). Required. */\n fragmentSource: string;\n /** Declared uniform names. Defaults to none. */\n uniformNames?: readonly string[];\n /** Declared sampler names, in unit-assignment order. Defaults to none. */\n samplerNames?: readonly string[];\n /** Attribute names; the first is bound to location 0. Defaults to\n * `[\"position\"]`. */\n attributeNames?: readonly string[];\n /** Optional `#define` block prepended to both shader stages. */\n defines?: string;\n}\n\n/** A reusable fullscreen effect that compiles and OWNS its `GLEffect` — the\n * WebGL counterpart of lite's `EffectWrapper`. Like lite, the wrapper functions\n * take the wrapper alone (the engine is derived from its effect):\n * `applyEffectWrapper(wrapper)` / `disposeEffectWrapper(wrapper)`. */\nexport interface GLEffectWrapper {\n /** Name alias for the wrapper (and its effect). */\n readonly name: string;\n /** The compiled effect this wrapper owns. Exposed so the per-uniform\n * setters (`setEffectFloat`/`setEffectTexture`/…) can target it — the\n * WebGL divergence from lite's UBO-based `setEffectUniforms(wrapper, …)`. */\n readonly effect: GLEffect;\n /** @internal */\n _disposed: boolean;\n}\n\n/** Compile a fullscreen effect from shader source and wrap it; the wrapper OWNS\n * the resulting `GLEffect`. Mirrors lite's `createEffectWrapper(engine, options)`.\n * When `vertexSource` is omitted, a built-in fullscreen-quad vertex shader is\n * used, so callers can supply only `fragmentSource`. */\nexport function createEffectWrapper(engine: GLEngineContext, options: GLEffectWrapperOptions): GLEffectWrapper {\n const name = options.name ?? \"effect-wrapper\";\n const effect = createEffect(engine, {\n name,\n vertexSource: options.vertexSource ?? DEFAULT_FULLSCREEN_VERTEX_SOURCE,\n fragmentSource: options.fragmentSource,\n uniformNames: options.uniformNames ?? [],\n samplerNames: options.samplerNames ?? [],\n attributeNames: options.attributeNames,\n defines: options.defines,\n });\n return { name, effect, _disposed: false };\n}\n\n/** Dispose the wrapper and the effect it owns (idempotent).\n *\n * @param wrapper - The wrapper to dispose. */\nexport function disposeEffectWrapper(wrapper: GLEffectWrapper): void {\n if (wrapper._disposed) {\n return;\n }\n wrapper._disposed = true;\n disposeEffect(wrapper.effect);\n}\n\n/** Pixel-space viewport rectangle passed to `setViewport`. */\nexport interface GLViewport {\n /** Lower-left X origin in physical pixels. */\n x: number;\n /** Lower-left Y origin in physical pixels. */\n y: number;\n /** Width in physical pixels. */\n w: number;\n /** Height in physical pixels. */\n h: number;\n}\n\n/** Cached `gl.viewport`. Defaults to the full canvas in pixel coordinates. */\nexport function setViewport(engine: GLEngineContext, viewport?: GLViewport): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const x = viewport?.x ?? 0;\n const y = viewport?.y ?? 0;\n const w = viewport?.w ?? engine.canvas.width;\n const h = viewport?.h ?? engine.canvas.height;\n const s = engine._state;\n if (s.viewportX === x && s.viewportY === y && s.viewportW === w && s.viewportH === h) {\n return;\n }\n s.viewportX = x;\n s.viewportY = y;\n s.viewportW = w;\n s.viewportH = h;\n engine.gl.viewport(x, y, w, h);\n}\n\n/** Make `wrapper.effect` current — the counterpart of Babylon's\n * `EffectRenderer.applyEffectWrapper` (lite-gl has no `setEffectWrapper`;\n * this is the only wrapper \"activate\" call). The shared fullscreen quad is\n * bound by {@link drawEffect}, so an existing `GLEffect` needs no wrapper:\n * `if (isEffectReady(e)) { useEffect(e); …setters…; drawEffect(engine); }`.\n *\n * The wrapper's effect must be ready: this polls {@link isEffectReady} itself\n * (finalizing the effect on its first ready poll) and returns `false` without\n * binding anything while the shaders are still compiling, failed to compile,\n * or the context is lost/disposed — skip the frame's `setEffect*` /\n * `drawEffect` calls in that case, otherwise they target whatever program\n * was current before.\n *\n * This MUST be called BEFORE any `setEffect*` call for the same effect in the\n * current frame (uniform setters write to the currently bound program).\n * Typical frame:\n * `if (!applyEffectWrapper(w)) return;` →\n * `setEffectFloat(w.effect, …)` → `drawEffect(engine)`.\n *\n * @param wrapper - The wrapper whose effect to make current.\n * @returns `true` when the effect is ready and now current; `false` when\n * nothing was bound. */\nexport function applyEffectWrapper(wrapper: GLEffectWrapper): boolean {\n // Bail before polling so a disposed wrapper sharing a live effect can't\n // finalize it (useProgram + callbacks); re-check after the poll because\n // ready callbacks it fires may dispose the wrapper.\n if (wrapper._disposed || !isEffectReady(wrapper.effect) || wrapper._disposed) {\n return false;\n }\n useEffect(wrapper.effect);\n return true;\n}\n\n/** Draw the shared fullscreen quad with the current program (from\n * {@link applyEffectWrapper} or `useEffect`) — the counterpart of Babylon's\n * `EffectRenderer.draw`. Lazily creates the quad on first use (and after\n * context restore), binds its VAO (cached), flushes the deferred GL states and\n * issues `gl.drawElements(TRIANGLES, 6, UNSIGNED_SHORT, 0)`. The program's\n * vertex shader must read the quad positions at attribute location 0 (as\n * `createEffectWrapper`'s default vertex shader does). No-op when the context\n * is lost/disposed or there is no current program.\n *\n * @param engine - The engine. */\nexport function drawEffect(engine: GLEngineContext): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n if (engine._state.currentProgram === null) {\n return;\n }\n ensureQuad(engine);\n applyGLStates(engine);\n engine.gl.drawElements(engine.gl.TRIANGLES, 6, engine.gl.UNSIGNED_SHORT, 0);\n}\n\n/** Lazy fullscreen quad. Built on first call; thereafter the VAO is cached on\n * `_state.quadVao` and rebinding is a single cached call. Cleared by\n * `webglcontextlost` and transparently rebuilt by the next\n * `drawEffect` after restore.\n *\n * Position attribute is enabled at location 0 — every effect's\n * `createEffect` calls `gl.bindAttribLocation(program, 0, attributeNames[0])`\n * BEFORE link, so the shared VAO is correct across all programs. */\nfunction ensureQuad(engine: GLEngineContext): void {\n const s = engine._state;\n const gl = engine.gl;\n if (s.quadVao !== null) {\n if (s.boundVao !== s.quadVao) {\n gl.bindVertexArray(s.quadVao);\n s.boundVao = s.quadVao;\n }\n return;\n }\n const vao = gl.createVertexArray();\n if (vao === null) {\n throw new Error(\"lite-gl: gl.createVertexArray returned null\");\n }\n s.quadVao = vao;\n gl.bindVertexArray(vao);\n s.boundVao = vao;\n\n const vbo = gl.createBuffer();\n if (vbo === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (VBO)\");\n }\n s.quadVbo = vbo;\n gl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n s.boundArrayBuffer = vbo;\n gl.bufferData(gl.ARRAY_BUFFER, QUAD_POSITIONS, gl.STATIC_DRAW);\n\n const ibo = gl.createBuffer();\n if (ibo === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (IBO)\");\n }\n s.quadIbo = ibo;\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ibo);\n s.boundElementBuffer = ibo;\n gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, QUAD_INDICES, gl.STATIC_DRAW);\n\n gl.enableVertexAttribArray(0);\n gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);\n}\n\n/** Typed-array literal — pure per bundler convention. Matches Babylon's\n * `EffectRenderer` default geometry exactly. */\nconst QUAD_POSITIONS = new Float32Array([1, 1, -1, 1, -1, -1, 1, -1]);\nconst QUAD_INDICES = new Uint16Array([0, 1, 2, 0, 2, 3]);\n"]}
1
+ {"version":3,"file":"effect-renderer.js","sourceRoot":"","sources":["../src/effect-renderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,a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E,GAAG,CAAC,CAAC;IACpC,CAAC,CAAC,gBAAgB,GAAG,GAAG,CAAC;IACzB,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,cAAc,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC;IAE/D,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC;IAC9B,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IACpE,CAAC;IACD,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC;IAChB,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;IAC5C,CAAC,CAAC,kBAAkB,GAAG,GAAG,CAAC;IAC3B,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,oBAAoB,EAAE,YAAY,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC;IAErE,EAAE,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;IAC9B,EAAE,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC;AAED;iDACiD;AACjD,MAAM,cAAc,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACtE,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC","sourcesContent":["import type { GLEngineContext } from \"./context.js\";\nimport { createEffect, disposeEffect, type GLEffect, isEffectReady, useEffect } from \"./effect.js\";\nimport type { GLViewport } from \"./family.js\";\nimport { applyGLStates } from \"./apply-states.js\";\n\n/** Built-in fullscreen-quad vertex shader, used when `GLEffectWrapperOptions`\n * omits `vertexSource`. Maps the package's fullscreen-quad positions\n * (attribute location 0) to clip space and forwards a 0..1 `vUv` varying —\n * the WebGL counterpart of lite's default `vertexWGSL`, so callers can pass\n * only `fragmentSource`. */\nconst DEFAULT_FULLSCREEN_VERTEX_SOURCE = `#version 300 es\nlayout(location = 0) in vec2 position;\nout vec2 vUv;\nvoid main() {\n vUv = position * 0.5 + 0.5;\n gl_Position = vec4(position, 0.0, 1.0);\n}`;\n\n/** Inputs to `createEffectWrapper`. Mirrors lite's `EffectWrapperOptions`: the\n * wrapper compiles and OWNS the effect built from this shader source. */\nexport interface GLEffectWrapperOptions {\n /** Human-readable label for the wrapper and its effect. Defaults to\n * `\"effect-wrapper\"`. */\n name?: string;\n /** GLSL ES 3.00 vertex source. Defaults to a built-in fullscreen-quad\n * vertex shader (exposing a `vUv` varying), mirroring lite's default\n * `vertexWGSL`. */\n vertexSource?: string;\n /** GLSL ES 3.00 fragment source (≙ lite's `fragmentWGSL`). Required. */\n fragmentSource: string;\n /** Declared uniform names. Defaults to none. */\n uniformNames?: readonly string[];\n /** Declared sampler names, in unit-assignment order. Defaults to none. */\n samplerNames?: readonly string[];\n /** Attribute names; the first is bound to location 0. Defaults to\n * `[\"position\"]`. */\n attributeNames?: readonly string[];\n /** Optional `#define` block prepended to both shader stages. */\n defines?: string;\n}\n\n/** A reusable fullscreen effect that compiles and OWNS its `GLEffect` — the\n * WebGL counterpart of lite's `EffectWrapper`. Like lite, the wrapper functions\n * take the wrapper alone (the engine is derived from its effect):\n * `applyEffectWrapper(wrapper)` / `disposeEffectWrapper(wrapper)`. */\nexport interface GLEffectWrapper {\n /** Name alias for the wrapper (and its effect). */\n readonly name: string;\n /** The compiled effect this wrapper owns. Exposed so the per-uniform\n * setters (`setEffectFloat`/`setEffectTexture`/…) can target it — the\n * WebGL divergence from lite's UBO-based `setEffectUniforms(wrapper, …)`. */\n readonly effect: GLEffect;\n /** @internal */\n _disposed: boolean;\n}\n\n/** Compile a fullscreen effect from shader source and wrap it; the wrapper OWNS\n * the resulting `GLEffect`. Mirrors lite's `createEffectWrapper(engine, options)`.\n * When `vertexSource` is omitted, a built-in fullscreen-quad vertex shader is\n * used, so callers can supply only `fragmentSource`. */\nexport function createEffectWrapper(engine: GLEngineContext, options: GLEffectWrapperOptions): GLEffectWrapper {\n const name = options.name ?? \"effect-wrapper\";\n const effect = createEffect(engine, {\n name,\n vertexSource: options.vertexSource ?? DEFAULT_FULLSCREEN_VERTEX_SOURCE,\n fragmentSource: options.fragmentSource,\n uniformNames: options.uniformNames ?? [],\n samplerNames: options.samplerNames ?? [],\n attributeNames: options.attributeNames,\n defines: options.defines,\n });\n return { name, effect, _disposed: false };\n}\n\n/** Dispose the wrapper and the effect it owns (idempotent).\n *\n * @param wrapper - The wrapper to dispose. */\nexport function disposeEffectWrapper(wrapper: GLEffectWrapper): void {\n if (wrapper._disposed) {\n return;\n }\n wrapper._disposed = true;\n disposeEffect(wrapper.effect);\n}\n\n/** Cached `gl.viewport`. Defaults to the full canvas in pixel coordinates. */\nexport function setViewport(engine: GLEngineContext, viewport?: GLViewport): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const x = viewport?.x ?? 0;\n const y = viewport?.y ?? 0;\n const w = viewport?.w ?? engine.canvas.width;\n const h = viewport?.h ?? engine.canvas.height;\n const s = engine._state;\n if (s.viewportX === x && s.viewportY === y && s.viewportW === w && s.viewportH === h) {\n return;\n }\n s.viewportX = x;\n s.viewportY = y;\n s.viewportW = w;\n s.viewportH = h;\n engine.gl.viewport(x, y, w, h);\n}\n\n/** Make `wrapper.effect` current — the counterpart of Babylon's\n * `EffectRenderer.applyEffectWrapper` (lite-gl has no `setEffectWrapper`;\n * this is the only wrapper \"activate\" call). The shared fullscreen quad is\n * bound by {@link drawEffect}, so an existing `GLEffect` needs no wrapper:\n * `if (isEffectReady(e)) { useEffect(e); …setters…; drawEffect(engine); }`.\n *\n * The wrapper's effect must be ready: this polls {@link isEffectReady} itself\n * (finalizing the effect on its first ready poll) and returns `false` without\n * binding anything while the shaders are still compiling, failed to compile,\n * or the context is lost/disposed — skip the frame's `setEffect*` /\n * `drawEffect` calls in that case, otherwise they target whatever program\n * was current before.\n *\n * This MUST be called BEFORE any `setEffect*` call for the same effect in the\n * current frame (uniform setters write to the currently bound program).\n * Typical frame:\n * `if (!applyEffectWrapper(w)) return;` →\n * `setEffectFloat(w.effect, …)` → `drawEffect(engine)`.\n *\n * @param wrapper - The wrapper whose effect to make current.\n * @returns `true` when the effect is ready and now current; `false` when\n * nothing was bound. */\nexport function applyEffectWrapper(wrapper: GLEffectWrapper): boolean {\n // Bail before polling so a disposed wrapper sharing a live effect can't\n // finalize it (useProgram + callbacks); re-check after the poll because\n // ready callbacks it fires may dispose the wrapper.\n if (wrapper._disposed || !isEffectReady(wrapper.effect) || wrapper._disposed) {\n return false;\n }\n useEffect(wrapper.effect);\n return true;\n}\n\n/** Draw the shared fullscreen quad with the current program (from\n * {@link applyEffectWrapper} or `useEffect`) — the counterpart of Babylon's\n * `EffectRenderer.draw`. Lazily creates the quad on first use (and after\n * context restore), binds its VAO (cached), flushes the deferred GL states and\n * issues `gl.drawElements(TRIANGLES, 6, UNSIGNED_SHORT, 0)`. The program's\n * vertex shader must read the quad positions at attribute location 0 (as\n * `createEffectWrapper`'s default vertex shader does). No-op when the context\n * is lost/disposed or there is no current program.\n *\n * @param engine - The engine. */\nexport function drawEffect(engine: GLEngineContext): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n if (engine._state.currentProgram === null) {\n return;\n }\n ensureQuad(engine);\n applyGLStates(engine);\n engine.gl.drawElements(engine.gl.TRIANGLES, 6, engine.gl.UNSIGNED_SHORT, 0);\n}\n\n/** Lazy fullscreen quad. Built on first call; thereafter the VAO is cached on\n * `_state.quadVao` and rebinding is a single cached call. Cleared by\n * `webglcontextlost` and transparently rebuilt by the next\n * `drawEffect` after restore.\n *\n * Position attribute is enabled at location 0 — every effect's\n * `createEffect` calls `gl.bindAttribLocation(program, 0, attributeNames[0])`\n * BEFORE link, so the shared VAO is correct across all programs. */\nfunction ensureQuad(engine: GLEngineContext): void {\n const s = engine._state;\n const gl = engine.gl;\n if (s.quadVao !== null) {\n if (s.boundVao !== s.quadVao) {\n gl.bindVertexArray(s.quadVao);\n s.boundVao = s.quadVao;\n }\n return;\n }\n const vao = gl.createVertexArray();\n if (vao === null) {\n throw new Error(\"lite-gl: gl.createVertexArray returned null\");\n }\n s.quadVao = vao;\n gl.bindVertexArray(vao);\n s.boundVao = vao;\n\n const vbo = gl.createBuffer();\n if (vbo === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (VBO)\");\n }\n s.quadVbo = vbo;\n gl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n s.boundArrayBuffer = vbo;\n gl.bufferData(gl.ARRAY_BUFFER, QUAD_POSITIONS, gl.STATIC_DRAW);\n\n const ibo = gl.createBuffer();\n if (ibo === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (IBO)\");\n }\n s.quadIbo = ibo;\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ibo);\n s.boundElementBuffer = ibo;\n gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, QUAD_INDICES, gl.STATIC_DRAW);\n\n gl.enableVertexAttribArray(0);\n gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);\n}\n\n/** Typed-array literal — pure per bundler convention. Matches Babylon's\n * `EffectRenderer` default geometry exactly. */\nconst QUAD_POSITIONS = new Float32Array([1, 1, -1, 1, -1, -1, 1, -1]);\nconst QUAD_INDICES = new Uint16Array([0, 1, 2, 0, 2, 3]);\n"]}
package/effect.d.ts CHANGED
@@ -1,32 +1,6 @@
1
1
  import type { GLEngineContext } from "./context.js";
2
+ import type { GLEffectOptions } from "./family.js";
2
3
  import { type GLTexture } from "./texture.js";
3
- /** Inputs to `createEffect`: shader sources plus the uniform, sampler and
4
- * attribute names whose locations are resolved during readiness finalization. */
5
- export interface GLEffectOptions {
6
- /** Human-readable label, surfaced in compile/link error messages. */
7
- name: string;
8
- /** GLSL ES 3.00 source, ready for `gl.shaderSource`. */
9
- vertexSource: string;
10
- /** GLSL ES 3.00 source, ready for `gl.shaderSource`. */
11
- fragmentSource: string;
12
- /** Declared uniform names. Locations are resolved during readiness
13
- * finalization. Names not declared here are legal but allocate cache
14
- * slots lazily on first setter use. */
15
- uniformNames: readonly string[];
16
- /** Declared sampler names, in unit-assignment order. Each gets a fixed
17
- * texture unit assigned during readiness finalization, and
18
- * `gl.uniform1i(loc, unit)` is called exactly once per program lifetime
19
- * (re-run after `webglcontextrestored`). */
20
- samplerNames: readonly string[];
21
- /** Default `["position"]`. The first attribute is bound to location 0 via
22
- * `gl.bindAttribLocation(program, 0, name)` BEFORE link, so the shared
23
- * fullscreen-quad VAO always feeds the same location. */
24
- attributeNames?: readonly string[];
25
- /** Optional `#define` block. Each unique `defines` string must be paired
26
- * with the same vertex/fragment source via a separate `createEffect` call —
27
- * the package does NOT cache compiled variants. */
28
- defines?: string;
29
- }
30
4
  /** A compiled + linked shader program with cached uniform, sampler and
31
5
  * attribute locations. Created by `createEffect`; most fields are managed
32
6
  * internally — drive it via `isEffectReady` / `useEffect` / the `setEffect*`
@@ -141,6 +115,10 @@ export declare function setEffectMatrix3x3(effect: GLEffect, name: string, matri
141
115
  /** `gl.uniform1fv` — a flat float array (`Effect.setFloatArray` / `setArray`).
142
116
  * Not value-cached. */
143
117
  export declare function setEffectFloatArray(effect: GLEffect, name: string, array: Float32Array | number[]): void;
118
+ /** `gl.uniform2fv` — an array of `vec2`s. Not value-cached. */
119
+ export declare function setEffectFloatArray2(effect: GLEffect, name: string, array: Float32Array | number[]): void;
120
+ /** `gl.uniform3fv` — an array of `vec3`s. Not value-cached. */
121
+ export declare function setEffectFloatArray3(effect: GLEffect, name: string, array: Float32Array | number[]): void;
144
122
  /** `gl.uniform4fv` — an array of `vec4`s (`Effect.setFloatArray4` / `setArray4`).
145
123
  * Not value-cached. */
146
124
  export declare function setEffectFloatArray4(effect: GLEffect, name: string, array: Float32Array | number[]): void;
package/effect.js CHANGED
@@ -407,6 +407,28 @@ export function setEffectFloatArray(effect, name, array) {
407
407
  }
408
408
  engine.gl.uniform1fv(loc, array);
409
409
  }
410
+ /** `gl.uniform2fv` — an array of `vec2`s. Not value-cached. */
411
+ export function setEffectFloatArray2(effect, name, array) {
412
+ const engine = effect._engine;
413
+ if (engine._isLost || !effect.isReady) {
414
+ return;
415
+ }
416
+ const location = effect.uniformLocations[name];
417
+ if (location !== null && location !== undefined) {
418
+ engine.gl.uniform2fv(location, array);
419
+ }
420
+ }
421
+ /** `gl.uniform3fv` — an array of `vec3`s. Not value-cached. */
422
+ export function setEffectFloatArray3(effect, name, array) {
423
+ const engine = effect._engine;
424
+ if (engine._isLost || !effect.isReady) {
425
+ return;
426
+ }
427
+ const location = effect.uniformLocations[name];
428
+ if (location !== null && location !== undefined) {
429
+ engine.gl.uniform3fv(location, array);
430
+ }
431
+ }
410
432
  /** `gl.uniform4fv` — an array of `vec4`s (`Effect.setFloatArray4` / `setArray4`).
411
433
  * Not value-cached. */
412
434
  export function setEffectFloatArray4(effect, name, array) {
package/effect.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"effect.js","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,cAAc,EAAkB,MAAM,cAAc,CAAC;AAiH9D;;;0EAG0E;AAC1E,MAAM,UAAU,YAAY,CAAC,MAAuB,EAAE,OAAwB;IAC1E,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,IAAI,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;IAErB,yEAAyE;IACzE,mEAAmE;IACnE,uEAAuE;IACvE,wEAAwE;IAC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pC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACrB,SAAS;QACb,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACrE,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import type { GLEngineContext } from \"./context.js\";\nimport { compileShader, getLinkError, isLinkComplete, linkProgram } from \"./shader.js\";\nimport { bindTextureRaw, type GLTexture } from \"./texture.js\";\n\n/** Inputs to `createEffect`: shader sources plus the uniform, sampler and\n * attribute names whose locations are resolved during readiness finalization. */\nexport interface GLEffectOptions {\n /** Human-readable label, surfaced in compile/link error messages. */\n name: string;\n /** GLSL ES 3.00 source, ready for `gl.shaderSource`. */\n vertexSource: string;\n /** GLSL ES 3.00 source, ready for `gl.shaderSource`. */\n fragmentSource: string;\n /** Declared uniform names. Locations are resolved during readiness\n * finalization. Names not declared here are legal but allocate cache\n * slots lazily on first setter use. */\n uniformNames: readonly string[];\n /** Declared sampler names, in unit-assignment order. Each gets a fixed\n * texture unit assigned during readiness finalization, and\n * `gl.uniform1i(loc, unit)` is called exactly once per program lifetime\n * (re-run after `webglcontextrestored`). */\n samplerNames: readonly string[];\n /** Default `[\"position\"]`. The first attribute is bound to location 0 via\n * `gl.bindAttribLocation(program, 0, name)` BEFORE link, so the shared\n * fullscreen-quad VAO always feeds the same location. */\n attributeNames?: readonly string[];\n /** Optional `#define` block. Each unique `defines` string must be paired\n * with the same vertex/fragment source via a separate `createEffect` call —\n * the package does NOT cache compiled variants. */\n defines?: string;\n}\n\n/** A compiled + linked shader program with cached uniform, sampler and\n * attribute locations. Created by `createEffect`; most fields are managed\n * internally — drive it via `isEffectReady` / `useEffect` / the `setEffect*`\n * setters rather than mutating it directly. */\nexport interface GLEffect {\n /** The `name` from the originating `GLEffectOptions`. */\n readonly name: string;\n /** The options this effect was created from (retained for context-restore). */\n readonly options: GLEffectOptions;\n /** The live `WebGLProgram`. Swapped for a fresh handle after context-restore. */\n program: WebGLProgram;\n /** @internal */\n _vs: WebGLShader;\n /** @internal */\n _fs: WebGLShader;\n /** Resolved during readiness finalization. Missing names map to `null` —\n * setters with a `null` location are silent no-ops (matches Babylon). */\n uniformLocations: { [name: string]: WebGLUniformLocation | null };\n /** Fixed unit assignment for declared samplers, index into\n * `_state.boundTextures`. */\n samplerUnits: { [name: string]: number };\n /**\n * True once `gl.uniform1i(samplerLoc, unit)` has been issued for every\n * declared sampler. Cleared on context-lost so finalization re-runs.\n * @internal\n */\n _samplersAssigned: boolean;\n /** Resolved attribute locations, keyed by attribute name. */\n attributeLocations: { [name: string]: number };\n /**\n * Last-UPLOADED scalar floats. A setter that skips the upload must NOT\n * update this — otherwise a later real set with the same value would\n * incorrectly elide and the GPU would keep stale data.\n * @internal\n */\n readonly _lastF1: { [name: string]: number };\n /**\n * Last-UPLOADED vector floats (vec2/vec3/vec4). Plain `number[]` (NOT\n * `Float32Array`) so values like `0.1` compare equal across frames.\n * @internal\n */\n readonly _lastVec: { [name: string]: number[] };\n /** @internal */\n readonly _lastI1: { [name: string]: number };\n /** True once the program has linked and finalization has run; the\n * `setEffect*` setters are no-ops until then. Poll `isEffectReady` to advance it. */\n isReady: boolean;\n /** The engine that created (and owns) this effect. Effect operations derive\n * their engine from it, so they take the effect alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _compileError: string | null;\n /** @internal */\n _disposed: boolean;\n /**\n * Number of live `createEffect` callers sharing this effect (and its one\n * `WebGLProgram`). `createEffect` returns the cached effect and bumps this\n * when an identical descriptor is requested; `disposeEffect` decrements it\n * and only tears the program down when it reaches 0.\n * @internal\n */\n _refCount: number;\n /**\n * The `_effectCache` key this effect was stored under (the source\n * descriptor). Used by `disposeEffect` to evict the cache entry at refcount\n * 0.\n * @internal\n */\n _cacheKey: string;\n /**\n * Callbacks fired exactly once on the first transition to ready.\n * @internal\n */\n readonly _onCompiled: ((effect: GLEffect) => void)[];\n /**\n * Replay closure for context-restore. Re-compiles + relinks into a fresh\n * `program` field. Finalization happens lazily on the next `isEffectReady`\n * poll.\n * @internal\n */\n _restore: (engine: GLEngineContext) => void;\n}\n\n/** Submit compilation + linking without querying their results. `isReady`\n * starts false; poll `isEffectReady` or opt into `waitForEffect` to finalize.\n * Allocation failures throw synchronously. Shader syntax/link errors are\n * recorded during polling and exposed by `getEffectCompilationError`. */\nexport function createEffect(engine: GLEngineContext, options: GLEffectOptions): GLEffect {\n const attribs = options.attributeNames ?? [\"position\"];\n const gl = engine.gl;\n\n // Per-engine cache keyed by the source descriptor. Identical descriptors\n // share ONE GLEffect (and thus one WebGLProgram), so `useEffect`'s\n // current-program cache can elide redundant `gl.useProgram` across the\n // consumers. The key covers every input that affects the program or its\n // readiness finalization, joined by a NUL separator (cannot appear in GLSL).\n const cacheKey = [options.vertexSource, options.fragmentSource, options.defines ?? \"\", attribs.join(\",\"), options.uniformNames.join(\",\"), options.samplerNames.join(\",\")].join(\n \"\\u0000\"\n );\n const cached = engine._effectCache.get(cacheKey);\n if (cached !== undefined && !cached._disposed) {\n cached._refCount++;\n return cached;\n }\n\n const compiled = compileEffectProgram(gl, options, attribs);\n if (typeof compiled === \"string\") {\n throw new Error(`lite-gl: ${options.name} ${compiled}`);\n }\n const { vs, fs, program } = compiled;\n\n const effect: GLEffect = {\n name: options.name,\n options,\n program,\n _vs: vs,\n _fs: fs,\n uniformLocations: {},\n samplerUnits: {},\n _samplersAssigned: false,\n attributeLocations: {},\n _lastF1: {},\n _lastVec: {},\n _lastI1: {},\n isReady: false,\n _engine: engine,\n _compileError: null,\n _disposed: false,\n _refCount: 1,\n _cacheKey: cacheKey,\n _onCompiled: [],\n _restore: () => {},\n };\n\n effect._restore = (target: GLEngineContext): void => {\n const restored = compileEffectProgram(target.gl, options, attribs);\n if (typeof restored === \"string\") {\n recordCompilationError(effect, `context-restore: ${restored}`);\n return;\n }\n effect.program = restored.program;\n effect._vs = restored.vs;\n effect._fs = restored.fs;\n effect.isReady = false;\n effect._samplersAssigned = false;\n effect.uniformLocations = {};\n effect.attributeLocations = {};\n effect._compileError = null;\n };\n\n engine._effects.push(effect);\n engine._effectCache.set(cacheKey, effect);\n return effect;\n}\n\n/** Shader/program handles allocated as one unit on creation and restoration. */\ninterface EffectProgram {\n vs: WebGLShader;\n fs: WebGLShader;\n program: WebGLProgram;\n}\n\n/** Share allocation and partial-failure cleanup between initial creation and\n * context restoration. Returns a diagnostic on allocation failure; compile\n * and link results are deliberately left to readiness polling. */\nfunction compileEffectProgram(gl: WebGL2RenderingContext, options: GLEffectOptions, attribs: readonly string[]): EffectProgram | string {\n const vs = compileShader(gl, applyDefines(options.vertexSource, options.defines), gl.VERTEX_SHADER);\n if (vs === null) {\n return \"vertex shader allocation failed\";\n }\n const fs = compileShader(gl, applyDefines(options.fragmentSource, options.defines), gl.FRAGMENT_SHADER);\n if (fs === null) {\n gl.deleteShader(vs);\n return \"fragment shader allocation failed\";\n }\n const program = linkProgram(gl, vs, fs, attribs);\n if (program === null) {\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n return \"program allocation failed\";\n }\n return { vs, fs, program };\n}\n\n/** Poll the link state and, on first success, run finalization (uniform-\n * location resolution + one-shot sampler-unit `uniform1i` assignment +\n * `_onCompiled` callbacks). Returns `true` once the effect is usable. */\nexport function isEffectReady(effect: GLEffect): boolean {\n const engine = effect._engine;\n if (\n !effect.isReady &&\n !effect._disposed &&\n !engine._isLost &&\n !engine._disposed &&\n effect._compileError === null &&\n isLinkComplete(engine.gl, effect.program, engine.caps.parallelShaderCompile)\n ) {\n const linkErr = getLinkError(engine.gl, effect.program, effect._vs, effect._fs);\n if (linkErr !== null) {\n recordCompilationError(effect, linkErr);\n } else {\n finalizeEffect(engine, effect);\n }\n }\n // Read back rather than returning `true` after finalization: a ready\n // callback may have disposed the effect or engine (or lost the context).\n return effect.isReady;\n}\n\n/** Poll readiness once and return the recorded compile/link/restore diagnostic.\n * Returns null while pending or when no failure has been recorded; this is\n * not a readiness guarantee. Does not schedule polling. A successful restore\n * allocation clears the previous diagnostic before the new link is checked. */\nexport function getEffectCompilationError(effect: GLEffect): string | null {\n isEffectReady(effect);\n return effect._compileError;\n}\n\nfunction recordCompilationError(effect: GLEffect, error: string): void {\n effect._compileError = error;\n effect.isReady = false;\n console.error(`lite-gl: ${effect.name} ${error}`);\n}\n\n/** Resolves uniform/attribute locations, binds the program (cached), and\n * issues the one-time `gl.uniform1i(samplerLoc, unit)` per declared sampler. */\nfunction finalizeEffect(engine: GLEngineContext, effect: GLEffect): void {\n const gl = engine.gl;\n const program = effect.program;\n for (const name of effect.options.uniformNames) {\n effect.uniformLocations[name] = gl.getUniformLocation(program, name);\n }\n const attribs = effect.options.attributeNames ?? [\"position\"];\n for (const name of attribs) {\n effect.attributeLocations[name] = gl.getAttribLocation(program, name);\n }\n // Switch to this program via the cached helper so _state.currentProgram\n // stays consistent — no raw gl.useProgram outside useEffect.\n useEffect(effect);\n let unit = 0;\n for (const name of effect.options.samplerNames) {\n const loc = gl.getUniformLocation(program, name);\n if (loc !== null) {\n gl.uniform1i(loc, unit);\n }\n effect.samplerUnits[name] = unit;\n unit++;\n }\n effect._samplersAssigned = true;\n effect.isReady = true;\n // Fire and clear the one-shot ready callbacks.\n const cbs = effect._onCompiled.slice();\n effect._onCompiled.length = 0;\n for (const cb of cbs) {\n try {\n cb(effect);\n } catch (err) {\n console.error(`lite-gl: ${effect.name} onCompiled callback threw`, err);\n }\n }\n}\n\n/** Fires `cb` synchronously if the effect is already ready; otherwise queues\n * it for the next finalization. Does not start polling: call `isEffectReady`\n * from the render loop or opt into `waitForEffect`. */\nexport function executeWhenCompiled(effect: GLEffect, cb: (e: GLEffect) => void): void {\n if (isEffectReady(effect)) {\n cb(effect);\n return;\n }\n effect._onCompiled.push(cb);\n}\n\n/** Decrement the share count and, on the last release, delete the effect's\n * program + shaders, unregister it from the context + cache, and clear the\n * cached current-program if it pointed at this effect. A shared effect (still\n * referenced by another `createEffect` caller) is kept alive. Call exactly ONCE\n * per `createEffect` (each call decrements the ref count); safe (no-op) once the\n * effect is fully torn down. */\nexport function disposeEffect(effect: GLEffect): void {\n const engine = effect._engine;\n if (effect._disposed) {\n return;\n }\n if (--effect._refCount > 0) {\n return;\n }\n effect._disposed = true;\n effect.isReady = false;\n const i = engine._effects.indexOf(effect);\n if (i !== -1) {\n engine._effects.splice(i, 1);\n }\n engine._effectCache.delete(effect._cacheKey);\n if (!engine._isLost && !engine._disposed) {\n engine.gl.deleteProgram(effect.program);\n engine.gl.deleteShader(effect._vs);\n engine.gl.deleteShader(effect._fs);\n }\n if (engine._state.currentProgram === effect.program) {\n engine._state.currentProgram = null;\n }\n effect._onCompiled.length = 0;\n}\n\n/** Cached `gl.useProgram`. Low-level: it does NOT check readiness, so poll\n * {@link isEffectReady} first (binding a still-linking program can stall, and\n * a failed one fails the next draw). `applyEffectWrapper` does that poll for\n * wrappers. No-op when the effect is already current, disposed, or the\n * context is lost/disposed. */\nexport function useEffect(effect: GLEffect): void {\n const engine = effect._engine;\n if (engine._isLost || engine._disposed || effect._disposed) {\n return;\n }\n if (engine._state.currentProgram === effect.program) {\n return;\n }\n engine.gl.useProgram(effect.program);\n engine._state.currentProgram = effect.program;\n}\n\n/* ──────────────────────────── cached setters ────────────────────────────\n *\n * Each setter has the shape:\n * 1. bail when context lost / effect not ready (no cache write)\n * 2. lookup uniform location; bail on null (no cache write)\n * 3. compare against last-UPLOADED value; bail on equality\n * 4. write to cache, issue gl.uniform*\n *\n * Step 3's comparison is intentionally bit-equal (===) — NaN inputs re-upload\n * every frame because `NaN !== NaN`, which is the correct safety net for\n * caller bugs.\n */\n\n/** Cached `gl.uniform1f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat(effect: GLEffect, name: string, x: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n if (effect._lastF1[name] === x) {\n return;\n }\n effect._lastF1[name] = x;\n engine.gl.uniform1f(loc, x);\n}\n\n/** Cached `gl.uniform2f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat2(effect: GLEffect, name: string, x: number, y: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n let v = effect._lastVec[name];\n if (v !== undefined && v[0] === x && v[1] === y) {\n return;\n }\n if (v === undefined) {\n v = [x, y];\n effect._lastVec[name] = v;\n } else {\n v[0] = x;\n v[1] = y;\n }\n engine.gl.uniform2f(loc, x, y);\n}\n\n/** Cached `gl.uniform3f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat3(effect: GLEffect, name: string, x: number, y: number, z: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n let v = effect._lastVec[name];\n if (v !== undefined && v[0] === x && v[1] === y && v[2] === z) {\n return;\n }\n if (v === undefined) {\n v = [x, y, z];\n effect._lastVec[name] = v;\n } else {\n v[0] = x;\n v[1] = y;\n v[2] = z;\n }\n engine.gl.uniform3f(loc, x, y, z);\n}\n\n/** Cached `gl.uniform4f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat4(effect: GLEffect, name: string, x: number, y: number, z: number, w: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n let v = effect._lastVec[name];\n if (v !== undefined && v[0] === x && v[1] === y && v[2] === z && v[3] === w) {\n return;\n }\n if (v === undefined) {\n v = [x, y, z, w];\n effect._lastVec[name] = v;\n } else {\n v[0] = x;\n v[1] = y;\n v[2] = z;\n v[3] = w;\n }\n engine.gl.uniform4f(loc, x, y, z, w);\n}\n\n/** Cached `gl.uniform3f` from an r/g/b color object. Delegates to `setEffectFloat3`. */\nexport function setEffectColor3(effect: GLEffect, name: string, c: { r: number; g: number; b: number }): void {\n setEffectFloat3(effect, name, c.r, c.g, c.b);\n}\n\n/** Cached `gl.uniform4f` from an r/g/b/a color object. Delegates to `setEffectFloat4`. */\nexport function setEffectColor4(effect: GLEffect, name: string, c: { r: number; g: number; b: number; a: number }): void {\n setEffectFloat4(effect, name, c.r, c.g, c.b, c.a);\n}\n\n/** Cached `gl.uniform2f` from an `{x,y}` vector object — the lite-gl equivalent\n * of Babylon's `Effect.setVector2`. Delegates to `setEffectFloat2`. */\nexport function setEffectVector2(effect: GLEffect, name: string, v: { x: number; y: number }): void {\n setEffectFloat2(effect, name, v.x, v.y);\n}\n\n/** Cached `gl.uniform4f` from an r/g/b/a color WITHOUT premultiplication — the\n * lite-gl equivalent of Babylon's `Effect.setDirectColor4`. Delegates to\n * `setEffectFloat4` (lite-gl never premultiplies in the uniform setters, so\n * this matches `setEffectColor4`; the distinct name eases the ShapeBuilder\n * port). */\nexport function setEffectDirectColor4(effect: GLEffect, name: string, c: { r: number; g: number; b: number; a: number }): void {\n setEffectFloat4(effect, name, c.r, c.g, c.b, c.a);\n}\n\n/** Cached `gl.uniform1i`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectInt(effect: GLEffect, name: string, x: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n if (effect._lastI1[name] === x) {\n return;\n }\n effect._lastI1[name] = x;\n engine.gl.uniform1i(loc, x);\n}\n\n/* ── Matrix / array setters (uploaded every call — not value-cached) ──────────\n *\n * Matrices and arrays usually change every frame; element-wise caching would\n * cost more than the upload it saves, so these always issue the GL call (the\n * location lookup + ready guards still apply). They cover the ShapeBuilder\n * surface (`setMatrix3x3`, `setFloatArray`, `setFloatArray4`) plus a general\n * 4×4 matrix setter for any future mesh consumer. */\n\n/** `gl.uniformMatrix4fv` from a column-major 4×4 matrix — the lite-gl\n * equivalent of Babylon's `Effect.setMatrix`. Not value-cached. */\nexport function setEffectMatrix(effect: GLEffect, name: string, matrix: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniformMatrix4fv(loc, false, matrix);\n}\n\n/** `gl.uniformMatrix3fv` from a column-major 3×3 matrix — the lite-gl\n * equivalent of Babylon's `Effect.setMatrix3x3`. Not value-cached. */\nexport function setEffectMatrix3x3(effect: GLEffect, name: string, matrix: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniformMatrix3fv(loc, false, matrix);\n}\n\n/** `gl.uniform1fv` — a flat float array (`Effect.setFloatArray` / `setArray`).\n * Not value-cached. */\nexport function setEffectFloatArray(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniform1fv(loc, array);\n}\n\n/** `gl.uniform4fv` — an array of `vec4`s (`Effect.setFloatArray4` / `setArray4`).\n * Not value-cached. */\nexport function setEffectFloatArray4(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniform4fv(loc, array);\n}\n\n/** `gl.uniform1iv` — a flat int array (`Effect.setIntArray`). Not value-cached. */\nexport function setEffectIntArray(effect: GLEffect, name: string, array: Int32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniform1iv(loc, array);\n}\n\n/** Bind a texture to the sampler's pre-assigned unit, or pass `null` to unbind\n * that unit (§4.4). NO `gl.uniform1i` is issued — that was done exactly once per program lifetime during\n * finalization. This is the key win over Babylon's `Effect.setTexture` which\n * re-issues the sampler binding on every call. */\nexport function setEffectTexture(effect: GLEffect, samplerName: string, tex: GLTexture | null): void {\n const engine = effect._engine;\n if (engine._isLost || engine._disposed || !effect.isReady) {\n return;\n }\n const unit = effect.samplerUnits[samplerName];\n if (unit === undefined || tex?._disposed) {\n return;\n }\n bindTextureRaw(engine, unit, tex === null ? null : tex.handle);\n}\n\n/** Resolve (and cache) a vertex-attribute location by name — the lite-gl\n * equivalent of Babylon's `Effect.getAttributeLocationByName`. Locations for\n * declared `attributeNames` are resolved during finalization; this also serves\n * the mesh / instancing path, where attribute names are not declared up-front.\n * Returns `-1` when the attribute is absent (matching `gl.getAttribLocation`).\n * @internal */\nexport function getEffectAttributeLocation(effect: GLEffect, name: string): number {\n const engine = effect._engine;\n const cached = effect.attributeLocations[name];\n if (cached !== undefined) {\n return cached;\n }\n const loc = engine.gl.getAttribLocation(effect.program, name);\n effect.attributeLocations[name] = loc;\n return loc;\n}\n\n/* ──────────────────────────── internal helpers ──────────────────────────── */\n\n/** Inject `options.defines` between the `#version`/precision header and the\n * user shader body. Supports a `// __DEFINES__` marker (preferred — keeps the\n * runtime regex-free, per spec §6.2) OR auto-detects the end of the leading\n * preprocessor / precision lines. */\nfunction applyDefines(source: string, defines: string | undefined): string {\n if (defines === undefined || defines.length === 0) {\n return source;\n }\n const marker = \"// __DEFINES__\";\n const idx = source.indexOf(marker);\n if (idx !== -1) {\n return source.slice(0, idx) + defines + source.slice(idx + marker.length);\n }\n // Fallback: insert after the last `precision` line (or after `#version`).\n const lines = source.split(\"\\n\");\n let insertAt = 0;\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line === undefined) {\n continue;\n }\n const trimmed = line.trim();\n if (trimmed.startsWith(\"#version\") || trimmed.startsWith(\"precision \")) {\n insertAt = i + 1;\n }\n }\n lines.splice(insertAt, 0, defines);\n return lines.join(\"\\n\");\n}\n"]}
1
+ {"version":3,"file":"effect.js","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,cAAc,EAAkB,MAAM,cAAc,CAAC;AAqF9D;;;0EAG0E;AAC1E,MAAM,UAAU,YAAY,CAAC,MAAuB,EAAE,OAAwB;IAC1E,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,IAAI,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;IAErB,yEAAyE;IACzE,mEAAmE;IACnE,uEAAuE;IACvE,wEAAwE;IACxE,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAC1K,QAAQ,CACX,CAA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,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,MAAM,MAAM,GAAG,gBAAgB,CAAC;IAChC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;QACb,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9E,CAAC;IACD,0EAA0E;IAC1E,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACrB,SAAS;QACb,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACrE,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import type { GLEngineContext } from \"./context.js\";\nimport type { GLEffectOptions } from \"./family.js\";\nimport { compileShader, getLinkError, isLinkComplete, linkProgram } from \"./shader.js\";\nimport { bindTextureRaw, type GLTexture } from \"./texture.js\";\n\n/** A compiled + linked shader program with cached uniform, sampler and\n * attribute locations. Created by `createEffect`; most fields are managed\n * internally — drive it via `isEffectReady` / `useEffect` / the `setEffect*`\n * setters rather than mutating it directly. */\nexport interface GLEffect {\n /** The `name` from the originating `GLEffectOptions`. */\n readonly name: string;\n /** The options this effect was created from (retained for context-restore). */\n readonly options: GLEffectOptions;\n /** The live `WebGLProgram`. Swapped for a fresh handle after context-restore. */\n program: WebGLProgram;\n /** @internal */\n _vs: WebGLShader;\n /** @internal */\n _fs: WebGLShader;\n /** Resolved during readiness finalization. Missing names map to `null` —\n * setters with a `null` location are silent no-ops (matches Babylon). */\n uniformLocations: { [name: string]: WebGLUniformLocation | null };\n /** Fixed unit assignment for declared samplers, index into\n * `_state.boundTextures`. */\n samplerUnits: { [name: string]: number };\n /**\n * True once `gl.uniform1i(samplerLoc, unit)` has been issued for every\n * declared sampler. Cleared on context-lost so finalization re-runs.\n * @internal\n */\n _samplersAssigned: boolean;\n /** Resolved attribute locations, keyed by attribute name. */\n attributeLocations: { [name: string]: number };\n /**\n * Last-UPLOADED scalar floats. A setter that skips the upload must NOT\n * update this — otherwise a later real set with the same value would\n * incorrectly elide and the GPU would keep stale data.\n * @internal\n */\n readonly _lastF1: { [name: string]: number };\n /**\n * Last-UPLOADED vector floats (vec2/vec3/vec4). Plain `number[]` (NOT\n * `Float32Array`) so values like `0.1` compare equal across frames.\n * @internal\n */\n readonly _lastVec: { [name: string]: number[] };\n /** @internal */\n readonly _lastI1: { [name: string]: number };\n /** True once the program has linked and finalization has run; the\n * `setEffect*` setters are no-ops until then. Poll `isEffectReady` to advance it. */\n isReady: boolean;\n /** The engine that created (and owns) this effect. Effect operations derive\n * their engine from it, so they take the effect alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _compileError: string | null;\n /** @internal */\n _disposed: boolean;\n /**\n * Number of live `createEffect` callers sharing this effect (and its one\n * `WebGLProgram`). `createEffect` returns the cached effect and bumps this\n * when an identical descriptor is requested; `disposeEffect` decrements it\n * and only tears the program down when it reaches 0.\n * @internal\n */\n _refCount: number;\n /**\n * The `_effectCache` key this effect was stored under (the source\n * descriptor). Used by `disposeEffect` to evict the cache entry at refcount\n * 0.\n * @internal\n */\n _cacheKey: string;\n /**\n * Callbacks fired exactly once on the first transition to ready.\n * @internal\n */\n readonly _onCompiled: ((effect: GLEffect) => void)[];\n /**\n * Replay closure for context-restore. Re-compiles + relinks into a fresh\n * `program` field. Finalization happens lazily on the next `isEffectReady`\n * poll.\n * @internal\n */\n _restore: (engine: GLEngineContext) => void;\n}\n\n/** Submit compilation + linking without querying their results. `isReady`\n * starts false; poll `isEffectReady` or opt into `waitForEffect` to finalize.\n * Allocation failures throw synchronously. Shader syntax/link errors are\n * recorded during polling and exposed by `getEffectCompilationError`. */\nexport function createEffect(engine: GLEngineContext, options: GLEffectOptions): GLEffect {\n const attribs = options.attributeNames ?? [\"position\"];\n const gl = engine.gl;\n\n // Per-engine cache keyed by the source descriptor. Identical descriptors\n // share ONE GLEffect (and thus one WebGLProgram), so `useEffect`'s\n // current-program cache can elide redundant `gl.useProgram` across the\n // consumers. The key covers every input that affects the program or its\n // readiness finalization, joined by a NUL separator (cannot appear in GLSL).\n const cacheKey = [options.vertexSource, options.fragmentSource, options.defines ?? \"\", attribs.join(\",\"), options.uniformNames.join(\",\"), options.samplerNames.join(\",\")].join(\n \"\\u0000\"\n );\n const cached = engine._effectCache.get(cacheKey);\n if (cached !== undefined && !cached._disposed) {\n cached._refCount++;\n return cached;\n }\n\n const compiled = compileEffectProgram(gl, options, attribs);\n if (typeof compiled === \"string\") {\n throw new Error(`lite-gl: ${options.name} ${compiled}`);\n }\n const { vs, fs, program } = compiled;\n\n const effect: GLEffect = {\n name: options.name,\n options,\n program,\n _vs: vs,\n _fs: fs,\n uniformLocations: {},\n samplerUnits: {},\n _samplersAssigned: false,\n attributeLocations: {},\n _lastF1: {},\n _lastVec: {},\n _lastI1: {},\n isReady: false,\n _engine: engine,\n _compileError: null,\n _disposed: false,\n _refCount: 1,\n _cacheKey: cacheKey,\n _onCompiled: [],\n _restore: () => {},\n };\n\n effect._restore = (target: GLEngineContext): void => {\n const restored = compileEffectProgram(target.gl, options, attribs);\n if (typeof restored === \"string\") {\n recordCompilationError(effect, `context-restore: ${restored}`);\n return;\n }\n effect.program = restored.program;\n effect._vs = restored.vs;\n effect._fs = restored.fs;\n effect.isReady = false;\n effect._samplersAssigned = false;\n effect.uniformLocations = {};\n effect.attributeLocations = {};\n effect._compileError = null;\n };\n\n engine._effects.push(effect);\n engine._effectCache.set(cacheKey, effect);\n return effect;\n}\n\n/** Shader/program handles allocated as one unit on creation and restoration. */\ninterface EffectProgram {\n vs: WebGLShader;\n fs: WebGLShader;\n program: WebGLProgram;\n}\n\n/** Share allocation and partial-failure cleanup between initial creation and\n * context restoration. Returns a diagnostic on allocation failure; compile\n * and link results are deliberately left to readiness polling. */\nfunction compileEffectProgram(gl: WebGL2RenderingContext, options: GLEffectOptions, attribs: readonly string[]): EffectProgram | string {\n const vs = compileShader(gl, applyDefines(options.vertexSource, options.defines), gl.VERTEX_SHADER);\n if (vs === null) {\n return \"vertex shader allocation failed\";\n }\n const fs = compileShader(gl, applyDefines(options.fragmentSource, options.defines), gl.FRAGMENT_SHADER);\n if (fs === null) {\n gl.deleteShader(vs);\n return \"fragment shader allocation failed\";\n }\n const program = linkProgram(gl, vs, fs, attribs);\n if (program === null) {\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n return \"program allocation failed\";\n }\n return { vs, fs, program };\n}\n\n/** Poll the link state and, on first success, run finalization (uniform-\n * location resolution + one-shot sampler-unit `uniform1i` assignment +\n * `_onCompiled` callbacks). Returns `true` once the effect is usable. */\nexport function isEffectReady(effect: GLEffect): boolean {\n const engine = effect._engine;\n if (\n !effect.isReady &&\n !effect._disposed &&\n !engine._isLost &&\n !engine._disposed &&\n effect._compileError === null &&\n isLinkComplete(engine.gl, effect.program, engine.caps.parallelShaderCompile)\n ) {\n const linkErr = getLinkError(engine.gl, effect.program, effect._vs, effect._fs);\n if (linkErr !== null) {\n recordCompilationError(effect, linkErr);\n } else {\n finalizeEffect(engine, effect);\n }\n }\n // Read back rather than returning `true` after finalization: a ready\n // callback may have disposed the effect or engine (or lost the context).\n return effect.isReady;\n}\n\n/** Poll readiness once and return the recorded compile/link/restore diagnostic.\n * Returns null while pending or when no failure has been recorded; this is\n * not a readiness guarantee. Does not schedule polling. A successful restore\n * allocation clears the previous diagnostic before the new link is checked. */\nexport function getEffectCompilationError(effect: GLEffect): string | null {\n isEffectReady(effect);\n return effect._compileError;\n}\n\nfunction recordCompilationError(effect: GLEffect, error: string): void {\n effect._compileError = error;\n effect.isReady = false;\n console.error(`lite-gl: ${effect.name} ${error}`);\n}\n\n/** Resolves uniform/attribute locations, binds the program (cached), and\n * issues the one-time `gl.uniform1i(samplerLoc, unit)` per declared sampler. */\nfunction finalizeEffect(engine: GLEngineContext, effect: GLEffect): void {\n const gl = engine.gl;\n const program = effect.program;\n for (const name of effect.options.uniformNames) {\n effect.uniformLocations[name] = gl.getUniformLocation(program, name);\n }\n const attribs = effect.options.attributeNames ?? [\"position\"];\n for (const name of attribs) {\n effect.attributeLocations[name] = gl.getAttribLocation(program, name);\n }\n // Switch to this program via the cached helper so _state.currentProgram\n // stays consistent — no raw gl.useProgram outside useEffect.\n useEffect(effect);\n let unit = 0;\n for (const name of effect.options.samplerNames) {\n const loc = gl.getUniformLocation(program, name);\n if (loc !== null) {\n gl.uniform1i(loc, unit);\n }\n effect.samplerUnits[name] = unit;\n unit++;\n }\n effect._samplersAssigned = true;\n effect.isReady = true;\n // Fire and clear the one-shot ready callbacks.\n const cbs = effect._onCompiled.slice();\n effect._onCompiled.length = 0;\n for (const cb of cbs) {\n try {\n cb(effect);\n } catch (err) {\n console.error(`lite-gl: ${effect.name} onCompiled callback threw`, err);\n }\n }\n}\n\n/** Fires `cb` synchronously if the effect is already ready; otherwise queues\n * it for the next finalization. Does not start polling: call `isEffectReady`\n * from the render loop or opt into `waitForEffect`. */\nexport function executeWhenCompiled(effect: GLEffect, cb: (e: GLEffect) => void): void {\n if (isEffectReady(effect)) {\n cb(effect);\n return;\n }\n effect._onCompiled.push(cb);\n}\n\n/** Decrement the share count and, on the last release, delete the effect's\n * program + shaders, unregister it from the context + cache, and clear the\n * cached current-program if it pointed at this effect. A shared effect (still\n * referenced by another `createEffect` caller) is kept alive. Call exactly ONCE\n * per `createEffect` (each call decrements the ref count); safe (no-op) once the\n * effect is fully torn down. */\nexport function disposeEffect(effect: GLEffect): void {\n const engine = effect._engine;\n if (effect._disposed) {\n return;\n }\n if (--effect._refCount > 0) {\n return;\n }\n effect._disposed = true;\n effect.isReady = false;\n const i = engine._effects.indexOf(effect);\n if (i !== -1) {\n engine._effects.splice(i, 1);\n }\n engine._effectCache.delete(effect._cacheKey);\n if (!engine._isLost && !engine._disposed) {\n engine.gl.deleteProgram(effect.program);\n engine.gl.deleteShader(effect._vs);\n engine.gl.deleteShader(effect._fs);\n }\n if (engine._state.currentProgram === effect.program) {\n engine._state.currentProgram = null;\n }\n effect._onCompiled.length = 0;\n}\n\n/** Cached `gl.useProgram`. Low-level: it does NOT check readiness, so poll\n * {@link isEffectReady} first (binding a still-linking program can stall, and\n * a failed one fails the next draw). `applyEffectWrapper` does that poll for\n * wrappers. No-op when the effect is already current, disposed, or the\n * context is lost/disposed. */\nexport function useEffect(effect: GLEffect): void {\n const engine = effect._engine;\n if (engine._isLost || engine._disposed || effect._disposed) {\n return;\n }\n if (engine._state.currentProgram === effect.program) {\n return;\n }\n engine.gl.useProgram(effect.program);\n engine._state.currentProgram = effect.program;\n}\n\n/* ──────────────────────────── cached setters ────────────────────────────\n *\n * Each setter has the shape:\n * 1. bail when context lost / effect not ready (no cache write)\n * 2. lookup uniform location; bail on null (no cache write)\n * 3. compare against last-UPLOADED value; bail on equality\n * 4. write to cache, issue gl.uniform*\n *\n * Step 3's comparison is intentionally bit-equal (===) — NaN inputs re-upload\n * every frame because `NaN !== NaN`, which is the correct safety net for\n * caller bugs.\n */\n\n/** Cached `gl.uniform1f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat(effect: GLEffect, name: string, x: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n if (effect._lastF1[name] === x) {\n return;\n }\n effect._lastF1[name] = x;\n engine.gl.uniform1f(loc, x);\n}\n\n/** Cached `gl.uniform2f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat2(effect: GLEffect, name: string, x: number, y: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n let v = effect._lastVec[name];\n if (v !== undefined && v[0] === x && v[1] === y) {\n return;\n }\n if (v === undefined) {\n v = [x, y];\n effect._lastVec[name] = v;\n } else {\n v[0] = x;\n v[1] = y;\n }\n engine.gl.uniform2f(loc, x, y);\n}\n\n/** Cached `gl.uniform3f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat3(effect: GLEffect, name: string, x: number, y: number, z: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n let v = effect._lastVec[name];\n if (v !== undefined && v[0] === x && v[1] === y && v[2] === z) {\n return;\n }\n if (v === undefined) {\n v = [x, y, z];\n effect._lastVec[name] = v;\n } else {\n v[0] = x;\n v[1] = y;\n v[2] = z;\n }\n engine.gl.uniform3f(loc, x, y, z);\n}\n\n/** Cached `gl.uniform4f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat4(effect: GLEffect, name: string, x: number, y: number, z: number, w: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n let v = effect._lastVec[name];\n if (v !== undefined && v[0] === x && v[1] === y && v[2] === z && v[3] === w) {\n return;\n }\n if (v === undefined) {\n v = [x, y, z, w];\n effect._lastVec[name] = v;\n } else {\n v[0] = x;\n v[1] = y;\n v[2] = z;\n v[3] = w;\n }\n engine.gl.uniform4f(loc, x, y, z, w);\n}\n\n/** Cached `gl.uniform3f` from an r/g/b color object. Delegates to `setEffectFloat3`. */\nexport function setEffectColor3(effect: GLEffect, name: string, c: { r: number; g: number; b: number }): void {\n setEffectFloat3(effect, name, c.r, c.g, c.b);\n}\n\n/** Cached `gl.uniform4f` from an r/g/b/a color object. Delegates to `setEffectFloat4`. */\nexport function setEffectColor4(effect: GLEffect, name: string, c: { r: number; g: number; b: number; a: number }): void {\n setEffectFloat4(effect, name, c.r, c.g, c.b, c.a);\n}\n\n/** Cached `gl.uniform2f` from an `{x,y}` vector object — the lite-gl equivalent\n * of Babylon's `Effect.setVector2`. Delegates to `setEffectFloat2`. */\nexport function setEffectVector2(effect: GLEffect, name: string, v: { x: number; y: number }): void {\n setEffectFloat2(effect, name, v.x, v.y);\n}\n\n/** Cached `gl.uniform4f` from an r/g/b/a color WITHOUT premultiplication — the\n * lite-gl equivalent of Babylon's `Effect.setDirectColor4`. Delegates to\n * `setEffectFloat4` (lite-gl never premultiplies in the uniform setters, so\n * this matches `setEffectColor4`; the distinct name eases the ShapeBuilder\n * port). */\nexport function setEffectDirectColor4(effect: GLEffect, name: string, c: { r: number; g: number; b: number; a: number }): void {\n setEffectFloat4(effect, name, c.r, c.g, c.b, c.a);\n}\n\n/** Cached `gl.uniform1i`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectInt(effect: GLEffect, name: string, x: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n if (effect._lastI1[name] === x) {\n return;\n }\n effect._lastI1[name] = x;\n engine.gl.uniform1i(loc, x);\n}\n\n/* ── Matrix / array setters (uploaded every call — not value-cached) ──────────\n *\n * Matrices and arrays usually change every frame; element-wise caching would\n * cost more than the upload it saves, so these always issue the GL call (the\n * location lookup + ready guards still apply). They cover the ShapeBuilder\n * surface (`setMatrix3x3`, `setFloatArray`, `setFloatArray4`) plus a general\n * 4×4 matrix setter for any future mesh consumer. */\n\n/** `gl.uniformMatrix4fv` from a column-major 4×4 matrix — the lite-gl\n * equivalent of Babylon's `Effect.setMatrix`. Not value-cached. */\nexport function setEffectMatrix(effect: GLEffect, name: string, matrix: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniformMatrix4fv(loc, false, matrix);\n}\n\n/** `gl.uniformMatrix3fv` from a column-major 3×3 matrix — the lite-gl\n * equivalent of Babylon's `Effect.setMatrix3x3`. Not value-cached. */\nexport function setEffectMatrix3x3(effect: GLEffect, name: string, matrix: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniformMatrix3fv(loc, false, matrix);\n}\n\n/** `gl.uniform1fv` — a flat float array (`Effect.setFloatArray` / `setArray`).\n * Not value-cached. */\nexport function setEffectFloatArray(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniform1fv(loc, array);\n}\n\n/** `gl.uniform2fv` — an array of `vec2`s. Not value-cached. */\nexport function setEffectFloatArray2(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const location = effect.uniformLocations[name];\n if (location !== null && location !== undefined) {\n engine.gl.uniform2fv(location, array);\n }\n}\n\n/** `gl.uniform3fv` — an array of `vec3`s. Not value-cached. */\nexport function setEffectFloatArray3(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const location = effect.uniformLocations[name];\n if (location !== null && location !== undefined) {\n engine.gl.uniform3fv(location, array);\n }\n}\n\n/** `gl.uniform4fv` — an array of `vec4`s (`Effect.setFloatArray4` / `setArray4`).\n * Not value-cached. */\nexport function setEffectFloatArray4(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniform4fv(loc, array);\n}\n\n/** `gl.uniform1iv` — a flat int array (`Effect.setIntArray`). Not value-cached. */\nexport function setEffectIntArray(effect: GLEffect, name: string, array: Int32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniform1iv(loc, array);\n}\n\n/** Bind a texture to the sampler's pre-assigned unit, or pass `null` to unbind\n * that unit (§4.4). NO `gl.uniform1i` is issued — that was done exactly once per program lifetime during\n * finalization. This is the key win over Babylon's `Effect.setTexture` which\n * re-issues the sampler binding on every call. */\nexport function setEffectTexture(effect: GLEffect, samplerName: string, tex: GLTexture | null): void {\n const engine = effect._engine;\n if (engine._isLost || engine._disposed || !effect.isReady) {\n return;\n }\n const unit = effect.samplerUnits[samplerName];\n if (unit === undefined || tex?._disposed) {\n return;\n }\n bindTextureRaw(engine, unit, tex === null ? null : tex.handle);\n}\n\n/** Resolve (and cache) a vertex-attribute location by name — the lite-gl\n * equivalent of Babylon's `Effect.getAttributeLocationByName`. Locations for\n * declared `attributeNames` are resolved during finalization; this also serves\n * the mesh / instancing path, where attribute names are not declared up-front.\n * Returns `-1` when the attribute is absent (matching `gl.getAttribLocation`).\n * @internal */\nexport function getEffectAttributeLocation(effect: GLEffect, name: string): number {\n const engine = effect._engine;\n const cached = effect.attributeLocations[name];\n if (cached !== undefined) {\n return cached;\n }\n const loc = engine.gl.getAttribLocation(effect.program, name);\n effect.attributeLocations[name] = loc;\n return loc;\n}\n\n/* ──────────────────────────── internal helpers ──────────────────────────── */\n\n/** Inject `options.defines` between the `#version`/precision header and the\n * user shader body. Supports a `// __DEFINES__` marker (preferred — keeps the\n * runtime regex-free, per spec §6.2) OR auto-detects the end of the leading\n * preprocessor / precision lines. */\nfunction applyDefines(source: string, defines: string | undefined): string {\n if (defines === undefined || defines.length === 0) {\n return source;\n }\n const marker = \"// __DEFINES__\";\n const idx = source.indexOf(marker);\n if (idx !== -1) {\n return source.slice(0, idx) + defines + source.slice(idx + marker.length);\n }\n // Fallback: insert after the last `precision` line (or after `#version`).\n const lines = source.split(\"\\n\");\n let insertAt = 0;\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line === undefined) {\n continue;\n }\n const trimmed = line.trim();\n if (trimmed.startsWith(\"#version\") || trimmed.startsWith(\"precision \")) {\n insertAt = i + 1;\n }\n }\n lines.splice(insertAt, 0, defines);\n return lines.join(\"\\n\");\n}\n"]}