@ignifx/core 0.7.0 → 0.8.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 (29) hide show
  1. package/dist/{color-CpvebMIh.js → color-DrR6GFTd.js} +3 -276
  2. package/dist/color-DrR6GFTd.js.map +1 -0
  3. package/dist/{environment-CTM7BAyb.js → environment-mr5wp69e.js} +3 -2
  4. package/dist/{environment-CTM7BAyb.js.map → environment-mr5wp69e.js.map} +1 -1
  5. package/dist/index.d.ts +17 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1023 -2557
  8. package/dist/index.js.map +1 -1
  9. package/dist/{instanced-mesh-instance-Cgx1H87p.js → instanced-mesh-instance-gguMoIeZ.js} +74 -10
  10. package/dist/instanced-mesh-instance-gguMoIeZ.js.map +1 -0
  11. package/dist/math-utils-BcDnL-gi.js +277 -0
  12. package/dist/math-utils-BcDnL-gi.js.map +1 -0
  13. package/dist/shader-declaration-5q__jycG.js.map +1 -1
  14. package/dist/{shader-material-CJxMJEUO.js → shader-material-BIG3UDyu.js} +3 -3
  15. package/dist/{shader-material-CJxMJEUO.js.map → shader-material-BIG3UDyu.js.map} +1 -1
  16. package/dist/{shader-material-F-CL4D70.js → shader-material-U6BKZ8D1.js} +2 -2
  17. package/dist/{shader-material-F-CL4D70.js.map → shader-material-U6BKZ8D1.js.map} +1 -1
  18. package/dist/{shader-pragma-D4HKC9vP.js → shader-pragma-tw6AKaQD.js} +24 -3
  19. package/dist/shader-pragma-tw6AKaQD.js.map +1 -0
  20. package/dist/{surface-shader-Chs7wOAE.js → surface-shader-DAWIDdaa.js} +6 -4
  21. package/dist/{surface-shader-Chs7wOAE.js.map → surface-shader-DAWIDdaa.js.map} +1 -1
  22. package/dist/vec3-B31o_KF_.js +2458 -0
  23. package/dist/vec3-B31o_KF_.js.map +1 -0
  24. package/package.json +1 -1
  25. package/dist/color-CpvebMIh.js.map +0 -1
  26. package/dist/instanced-mesh-instance-Cgx1H87p.js.map +0 -1
  27. package/dist/mesh-CnK_PX46.js +0 -811
  28. package/dist/mesh-CnK_PX46.js.map +0 -1
  29. package/dist/shader-pragma-D4HKC9vP.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"mesh-CnK_PX46.js","names":["updateMeshPositions","updateMeshNormals","updateMeshUvs","updateMeshColors"],"sources":["../src/lite/node.ts","../src/lite/gpu/mesh.ts"],"sourcesContent":["import {\n createTransformNode,\n mat4Decompose,\n setParent,\n setSubtreeVisible,\n type IWorldMatrixProvider,\n type SceneNode,\n} from \"@babylonjs/lite\";\nimport type { MutableQuat, MutableVec3 } from \"../math/types.js\";\n\n/**\n * Scene-graph half of the Babylon Lite adapter: the transform node primitives the kernel's\n * `Transform` component is built from (`docs/architecture/02-scene-graph.md` §5, §5.1). Together\n * with the other files in this directory it is the only place in the package allowed to import\n * `@babylonjs/lite` (`CONSTITUTION.md` §3.4, coding standards §4).\n *\n * Everything here is `@internal`: the kernel decides what becomes public API and what stays behind\n * `Transform`. Nothing in this file is re-exported from `src/index.ts`.\n *\n * ## How Lite computes `worldMatrix` (verified against `@babylonjs/lite@1.27.0`\n * `lib/scene/world-matrix-state.js` and `lib/scene/scene-node.js`)\n *\n * Every node owns a *world-matrix state* holding a cached world matrix, a version counter, a\n * parent link, and a list of the states of the children that were linked through that parent\n * property. The rules that follow from the source are:\n *\n * 1. Writing any TRS value calls the node's dirty hook, which clears the cache, increments the\n * version, and **recursively invalidates every linked descendant** — invalidation is pushed\n * down eagerly, not polled.\n * 2. `ObservableVec3`/`ObservableQuat` per-component setters only fire that hook when the value\n * actually changes; the bulk `set(...)`/`copyFrom(...)` methods fire it unconditionally. So\n * `node.position.x = node.position.x` does not bump the version, while\n * `node.position.set(sameX, sameY, sameZ)` does.\n * 3. `worldMatrix` is a getter. On a cache miss it composes the local matrix from TRS and, when a\n * parent is linked, returns `parentWorld × local` (column-major; translation in elements\n * 12/13/14). A node with no parent returns its local matrix directly.\n * 4. A parent that is a plain {@link IWorldMatrixProvider} rather than a Lite scene node (a camera,\n * for instance) cannot be invalidated eagerly, so the child polls `parent.worldMatrixVersion`\n * on every `worldMatrix` and `worldMatrixVersion` read instead.\n * 5. Nothing in that path touches the scene: a transform node never needs `addToScene` for its\n * matrices to be correct. Only renderable objects do (`docs/architecture/02-scene-graph.md`\n * §5.1).\n */\n\n/**\n * A mutable `{ x, y, z }` accepted as an output parameter. Deliberately the minimal shape: Lite's\n * `Vec3`, the math module's `MutableVec3` (which adds `set`/`copyFrom`), a live `ObservableVec3` over\n * a node's TRS, and a plain object literal all satisfy it, so nothing has to be converted.\n *\n * @internal\n */\nexport interface MutableVec3Like {\n /** The x component. */\n x: number;\n /** The y component. */\n y: number;\n /** The z component. */\n z: number;\n}\n\n/**\n * A mutable `{ x, y, z, w }` accepted as an output parameter. The minimal shape, for the same reason\n * as {@link MutableVec3Like}: Lite's `Quat`, the math module's `MutableQuat`, and a plain object\n * literal all satisfy it.\n *\n * @internal\n */\nexport interface MutableQuatLike {\n /** The x component of the quaternion's vector part. */\n x: number;\n /** The y component of the quaternion's vector part. */\n y: number;\n /** The z component of the quaternion's vector part. */\n z: number;\n /** The scalar part. */\n w: number;\n}\n\n/**\n * A writable 16-element matrix sink in column-major order. `Float32Array` (including the math\n * module's `Mat4.elements`), `Float64Array`, and a plain `number[]` all satisfy it, which is why\n * `length` is a plain `number`: `Float32Array` cannot express the literal `16` that Lite's read-only\n * `Mat4` and the math module's `Mat4Like` declare.\n *\n * @internal\n */\nexport interface MutableMat4Like {\n /** Element count; callers must supply at least 16 slots. */\n readonly length: number;\n /** Column-major element access. */\n [index: number]: number;\n}\n\n/**\n * The ignifx identity written into a Lite node's metadata bag so picking results and physics bodies\n * resolve back to the owning entity (`docs/architecture/00-overview.md` §5,\n * `docs/architecture/02-scene-graph.md` §10).\n *\n * @internal\n */\nexport interface NodeTag {\n /** The dense runtime handle of the entity that owns the node. */\n readonly entity: number;\n /** The component that created the node, when the node is not the entity's own transform. */\n readonly component?: number;\n}\n\n/** The single key ignifx owns inside Lite's open `metadata` record. */\nconst METADATA_KEY = \"ignifx\";\n\n/** Number of elements in a 4x4 matrix. */\nconst MATRIX_LENGTH = 16;\n\n/**\n * Creates a pure transform node at the origin with an identity rotation and unit scale.\n *\n * @remarks\n * The node is deliberately **not** added to any Lite scene: a transform node is only a matrix\n * provider, and `worldMatrix` is valid the moment the node exists (see rule 5 in the module\n * documentation). Renderable Lite objects created by components are parented under it and added\n * with `addToScene` separately.\n *\n * @param name - A human-readable name; Lite never uses it for lookup and it need not be unique.\n * @returns A fresh, unparented transform node.\n *\n * @example\n * ```ts\n * const node = createNode(\"Player\");\n * node.position.set(1, 2, 3);\n * ```\n *\n * @internal\n */\nexport function createNode(name: string): SceneNode {\n return createTransformNode(name);\n}\n\n/**\n * Releases a pure transform node.\n *\n * @remarks\n * Lite requires nothing to release a transform node that was never added to a scene: verified in\n * `lib/scene/transform-node.js` and `lib/scene/scene-node.js`, the node is a plain object holding\n * three observable values, one `Float32Array` for the cached world matrix, and closures — no GPU\n * resource, no ref count, no scene registry. (Reference counting in `lib/resource/ref-count.js`\n * applies to meshes and their GPU buffers only, and `disposeScene` never walks transform nodes.)\n *\n * What *does* need doing is breaking the parent link: a linked parent keeps a reference to this\n * node's world-matrix state so it can invalidate it, so a node dropped while still parented is\n * retained by its parent. This function therefore unlinks the node and drops the ignifx tag. It\n * leaves the node's own `children` alone: the kernel destroys children before parents\n * (`docs/architecture/01-lifecycle-and-time.md` §3 step 9), so each child unlinks itself first.\n *\n * @param node - A node from {@link createNode}.\n *\n * @internal\n */\nexport function disposeNode(node: SceneNode): void {\n linkParent(node, null);\n const metadata = node.metadata;\n if (metadata !== undefined) {\n delete metadata[METADATA_KEY];\n }\n}\n\n/**\n * Links `child` under `parent`, **keeping the child's local values** — its world transform moves\n * with the new parent. This is `setParent(parent, { worldPositionStays: false })` in\n * `docs/architecture/02-scene-graph.md` §5.1.\n *\n * @remarks\n * Lite has no public helper for this case (its own `setParent` preserves the world transform), so\n * the adapter does the linking itself: it assigns `child.parent`, which is the setter that\n * re-registers the child's world-matrix state with the new parent and invalidates the subtree, and\n * maintains the `children` arrays on both the old and the new parent so tree traversal stays\n * consistent. Passing the parent the child already has is a no-op.\n *\n * @param child - The node to move.\n * @param parent - The new parent, or `null` to detach the child to world space.\n *\n * @example\n * ```ts\n * linkParent(child, parent); // child keeps localPosition; its world position changes\n * ```\n *\n * @internal\n */\nexport function linkParent(child: SceneNode, parent: SceneNode | null): void {\n const previous = child.parent;\n if (previous === parent) {\n return;\n }\n const previousChildren = childrenOf(previous);\n if (previousChildren !== null) {\n const index = previousChildren.indexOf(child);\n if (index >= 0) {\n previousChildren.splice(index, 1);\n }\n }\n // The setter, not a field write: it swaps the world-matrix state's parent, re-registers this\n // node in the new parent's invalidation list, and bumps `worldMatrixVersion` down the subtree.\n child.parent = parent;\n if (parent !== null && !parent.children.includes(child)) {\n parent.children.push(child);\n }\n}\n\n/**\n * Reparents `child` under `parent` **keeping its world transform**, by delegating to Lite's own\n * `setParent`. This is `setParent(parent, { worldPositionStays: true })`, the ignifx default\n * (`docs/architecture/02-scene-graph.md` §5.1).\n *\n * @remarks\n * Lite snapshots the child's world matrix, relinks the node (maintaining both `children` arrays),\n * then decomposes `inverse(parentWorld) × childWorld` back into local TRS. Two documented caveats\n * carry straight through to ignifx:\n *\n * - **Singular parent matrices.** When the parent's world matrix has a collapsed axis it cannot be\n * inverted, so no local transform can reproduce the child's world. Lite then keeps the parent\n * link and copies the child's world *position* into its local position, leaving rotation and\n * scale uncompensated. Non-uniform-but-invertible parents are fine; zero scale on any axis is\n * not.\n * - **Canonical, not sign-faithful, decomposition.** The local TRS comes from `mat4Decompose`,\n * which folds a reflection into a negative Y scale. The world matrix is reproduced exactly, but a\n * child that had a negative X scale comes back with a negative Y scale and a different rotation.\n *\n * A third caveat in Lite's TSDoc — that `child.parent` links are only established by `addToScene`,\n * so a node from a freshly loaded asset must have its container added before it is reparented —\n * does not apply to nodes ignifx creates, because {@link linkParent} establishes the link itself.\n *\n * @param child - The node to move.\n * @param parent - The new parent, or `null` to detach the child to world space.\n *\n * @internal\n */\nexport function reparentKeepingWorld(child: SceneNode, parent: SceneNode | null): void {\n setParent(child, parent);\n}\n\n/**\n * Copies a node's world matrix into `out`.\n *\n * @remarks\n * Allocation-free on the ignifx side, which is why the destination is a parameter: Lite's\n * `worldMatrix` getter may recompute up the parent chain, and the object it returns is Lite's own\n * cache — never hold on to it. Lite documents `Mat4` as opaque (\"callers MUST NOT depend on the\n * underlying storage\"); it is a `Float32Array` in 1.27.0 (`lib/math/_matrix-allocator.js`), so\n * copying element by element is the only supported read.\n *\n * @param node - The node to read.\n * @param out - A sink of at least 16 elements, written in column-major order.\n * @returns `out`, for chaining.\n *\n * @internal\n */\nexport function readWorldMatrix(node: SceneNode, out: MutableMat4Like): MutableMat4Like {\n const matrix = node.worldMatrix;\n for (let index = 0; index < MATRIX_LENGTH; index += 1) {\n out[index] = matrix[index] ?? 0;\n }\n return out;\n}\n\n/**\n * Reads a node's world-matrix version — the counter that increases whenever the node's world\n * matrix is invalidated, by its own TRS or by any ancestor's.\n *\n * @remarks\n * Snapshot it to detect movement without comparing matrices; systems that maintain acceleration\n * structures do exactly that (`docs/architecture/02-scene-graph.md` §9). The counter is\n * monotonically increasing but not a change *count*: it moves on invalidation, not on\n * recomputation, and a bulk `position.set(...)` bumps it even when the values are unchanged.\n *\n * @param node - The node to read.\n * @returns The current version.\n *\n * @internal\n */\nexport function worldMatrixVersion(node: SceneNode): number {\n return node.worldMatrixVersion;\n}\n\n/**\n * Decomposes a node's world matrix into translation, rotation, and scale, writing into the three\n * output parameters.\n *\n * @remarks\n * The decomposition is canonical rather than sign-faithful: a mirror is folded into a negative Y\n * scale, so recomposing reproduces the matrix but a matrix built from a negative X or Z scale comes\n * back as a negative Y scale plus a different rotation. A degenerate axis (scale below `1e-8`) is\n * tolerated: the rotation stays finite but is meaningless for that axis.\n *\n * ignifx allocates nothing here, but Lite's `mat4Decompose` allocates its own TRS triple per call\n * (`lib/math/mat4-decompose.js`), so this is not yet a zero-allocation path in the sense of coding\n * standards §7. The math module's in-place decomposition replaces the Lite call when it lands.\n *\n * @param node - The node to read.\n * @param outPosition - Receives the world translation.\n * @param outRotation - Receives the world rotation as a unit quaternion.\n * @param outScale - Receives the per-axis world scale.\n *\n * @internal\n */\nexport function decomposeWorld(\n node: SceneNode,\n outPosition: MutableVec3Like,\n outRotation: MutableQuatLike,\n outScale: MutableVec3Like,\n): void {\n const decomposed = mat4Decompose(node.worldMatrix);\n outPosition.x = decomposed.translation.x;\n outPosition.y = decomposed.translation.y;\n outPosition.z = decomposed.translation.z;\n outRotation.x = decomposed.rotation.x;\n outRotation.y = decomposed.rotation.y;\n outRotation.z = decomposed.rotation.z;\n outRotation.w = decomposed.rotation.w;\n outScale.x = decomposed.scale.x;\n outScale.y = decomposed.scale.y;\n outScale.z = decomposed.scale.z;\n}\n\n/**\n * Shows or hides a node and its whole subtree.\n *\n * @remarks\n * Lite materializes the cascade at write time — it walks `children` and writes `visible` on every\n * descendant — so a node added to the subtree afterwards does not inherit the state and must be\n * set separately. This is how entity deactivation hides render objects\n * (`docs/architecture/01-lifecycle-and-time.md` §6); removing a mesh from its last scene disposes\n * it permanently, so visibility, never removal, is the deactivation path.\n *\n * @param node - The subtree root.\n * @param visible - `true` to show the subtree, `false` to hide it.\n *\n * @internal\n */\nexport function setNodeVisible(node: SceneNode, visible: boolean): void {\n setSubtreeVisible(node, visible);\n}\n\n/**\n * Shows or hides **one** node, without touching its subtree.\n *\n * @remarks\n * Lite's `visible` is per node — the renderer reads each node's own flag, and `setSubtreeVisible`\n * is only a bulk helper that materialises a cascade at write time. ignifx already materialises\n * `activeInHierarchy` over the subtree itself, so it writes one flag per entity: correct for a\n * subtree that mixes active and inactive entities, and linear rather than quadratic.\n *\n * @param node - The node to show or hide.\n * @param visible - `true` to show it, `false` to hide it.\n *\n * @internal\n */\nexport function setNodeSelfVisible(node: SceneNode, visible: boolean): void {\n node.visible = visible;\n}\n\n/**\n * Writes the ignifx identity into a node's Lite metadata bag, under the single `ignifx` key.\n *\n * @remarks\n * `LiteMetadata` is an open record (`{ gltf?: GltfMetadata; [key: string]: unknown }`), so the tag\n * coexists with the `gltf.extras` a glTF load writes. The metadata object is created on demand;\n * nodes ignifx never tags keep `metadata` undefined.\n *\n * @param node - The node to tag.\n * @param tag - The owning entity, and the component that created the node when it is not the\n * entity's own transform.\n *\n * @internal\n */\nexport function tagNode(node: SceneNode, tag: NodeTag): void {\n const metadata = (node.metadata ??= {});\n metadata[METADATA_KEY] = tag;\n}\n\n/**\n * Reads the ignifx identity back from a node.\n *\n * @param node - The node to read; it may be any Lite node, including one ignifx never created.\n * @returns The tag {@link tagNode} wrote, or `null` when the node carries none.\n *\n * @internal\n */\nexport function readNodeTag(node: SceneNode): NodeTag | null {\n const metadata = node.metadata;\n if (metadata === undefined) {\n return null;\n }\n const value = metadata[METADATA_KEY];\n if (typeof value !== \"object\" || value === null || !(\"entity\" in value)) {\n return null;\n }\n const entity = value.entity;\n if (typeof entity !== \"number\") {\n return null;\n }\n const component = \"component\" in value ? value.component : undefined;\n return typeof component === \"number\" ? { entity, component } : { entity };\n}\n\n/**\n * The `children` array of a world-matrix provider, when it has one.\n *\n * @remarks\n * `SceneNode.parent` is typed as the minimal {@link IWorldMatrixProvider}, which declares no\n * `children`, but every parent ignifx links is a scene node. Lite's own `setParent` solves this the\n * same way (`lib/scene/set-parent.js`), and the array check keeps a non-node provider — a camera,\n * say — from being treated as a tree node.\n *\n * @param provider - The candidate parent.\n * @returns The provider's children, or `null` when it is not a tree node.\n */\nfunction childrenOf(provider: IWorldMatrixProvider | null): SceneNode[] | null {\n if (provider === null || !(\"children\" in provider)) {\n return null;\n }\n const children = provider.children;\n // The invariant is that a world-matrix provider with\n // an array-valued `children` is a `SceneNode`, which is what Lite itself assumes here.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return Array.isArray(children) ? (children as SceneNode[]) : null;\n}\n\n/**\n * The Babylon Lite node an ignifx `Transform` wraps, re-exported under an ignifx name so that\n * feature code can name the type without importing `@babylonjs/lite`\n * (`CONSTITUTION.md` §3.4, coding standards §4).\n *\n * @remarks\n * Unstable: it is Lite's type, reachable only through documented `.lite` escape hatches, and it is\n * excluded from the stability guarantees of `CONSTITUTION.md` Article IV.\n *\n * @public\n */\nexport type LiteSceneNode = SceneNode;\n\n/**\n * The node's local position as a live, writable view.\n *\n * @remarks\n * Zero-copy: the returned object *is* Lite's `ObservableVec3` over the node's TRS, so `.x += 1`,\n * `.set(x, y, z)`, and `.copyFrom(v)` write straight through and invalidate the subtree's world\n * matrices (`docs/architecture/02-scene-graph.md` §5). Never hold it past the node's lifetime.\n *\n * @param node - The node to view.\n * @returns The live local position.\n *\n * @internal\n */\nexport function localPosition(node: SceneNode): MutableVec3 {\n return node.position;\n}\n\n/**\n * The node's local rotation as a live, writable view.\n *\n * @param node - The node to view.\n * @returns The live local rotation quaternion.\n *\n * @internal\n */\nexport function localRotation(node: SceneNode): MutableQuat {\n return node.rotationQuaternion;\n}\n\n/**\n * The node's local scale as a live, writable view.\n *\n * @param node - The node to view.\n * @returns The live local scale.\n *\n * @internal\n */\nexport function localScale(node: SceneNode): MutableVec3 {\n return node.scaling;\n}\n\n/**\n * Reads a node's own visibility flag.\n *\n * @remarks\n * Lite leaves `visible` `undefined` on a node that was never hidden, which means *visible*; this\n * normalises that to `true` so callers never have to spell the tri-state out. Only\n * {@link setNodeVisible} writes it, and it materialises the cascade at write time.\n *\n * @param node - The node to read.\n * @returns `true` when the node renders.\n *\n * @internal\n */\nexport function isNodeVisible(node: SceneNode): boolean {\n return node.visible !== false;\n}\n\n/**\n * Renames a node.\n *\n * @remarks\n * Lite never uses the name for lookup, so this is purely for debugging and for the names that show\n * up in Lite-side tooling; ignifx keeps `Entity.name` as the source of truth and mirrors it here.\n *\n * @param node - The node to rename.\n * @param name - The new name.\n *\n * @internal\n */\nexport function setNodeName(node: SceneNode, name: string): void {\n node.name = name;\n}\n\n/**\n * The parent a node is currently linked to, when that parent is itself a scene node.\n *\n * @param node - The node to read.\n * @returns The parent node, or `null` when the node is unparented or its parent is a bare\n * world-matrix provider such as a camera.\n *\n * @internal\n */\nexport function parentNode(node: SceneNode): SceneNode | null {\n const parent = node.parent;\n if (parent === null || !(\"children\" in parent)) {\n return null;\n }\n // A world-matrix provider that carries `children` is\n // a `SceneNode` — the same invariant Lite's own `setParent` relies on.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return parent as SceneNode;\n}\n","import {\n addToScene,\n cloneTransformNode,\n createBox,\n createCapsule,\n createCylinder,\n createGround,\n createMeshFromData,\n createPlane,\n createSphere,\n createTorus,\n removeFromScene,\n setSubtreeVisible,\n updateMeshColors as liteUpdateMeshColors,\n updateMeshNormals as liteUpdateMeshNormals,\n updateMeshPositions as liteUpdateMeshPositions,\n updateMeshUvs as liteUpdateMeshUvs,\n} from \"@babylonjs/lite\";\nimport type {\n BoxOptions,\n CapsuleOptions,\n CylinderOptions,\n EngineContext,\n GroundOptions,\n Material,\n Mesh,\n PlaneOptions,\n SceneContext,\n SceneNode,\n SphereOptions,\n TorusOptions,\n} from \"@babylonjs/lite\";\n\n/**\n * Mesh half of the Babylon Lite adapter (`docs/architecture/07-rendering.md` §2.3). Every function\n * here needs a WebGPU device — `createMeshFromData` uploads four vertex buffers through\n * `engine._device` (`lib/mesh/mesh.js`, `uploadMeshToGPU`) and the null engine has no `_device` —\n * so the whole module lives under `src/lite/gpu/` and is covered by the browser test project.\n *\n * Everything here is `@internal`.\n *\n * ## Ownership, cloning, and disposal (verified against `@babylonjs/lite@1.27.0`)\n *\n * - `cloneTransformNode(mesh)` (`index.d.ts` 1776, `lib/scene/transform-node.js`) shallow-clones a\n * mesh: the clone gets a fresh transform and **the same `_gpu` wrapper object**, with\n * `retain(_gpu)` bumping a reference count. So N clones of one template share exactly one set of\n * GPU buffers — that is spike S2.4's \"instancing shares GPU buffers\", and it is provable by\n * object identity rather than by measuring memory.\n * - Disposal is driven entirely by scene membership. `removeFromScene` calls `unregisterMeshScene`,\n * and only when the mesh has left its **last** scene does it queue `disposeMeshGpu`, which calls\n * `release(_gpu)` and destroys the buffers only when the count drops to one\n * (`lib/scene/scene-remove.js`, `lib/mesh/mesh-dispose.js`, `lib/resource/ref-count.js`). A\n * template that is never added to a scene therefore keeps its buffers alive no matter how many\n * clones come and go — which is what `docs/architecture/07-rendering.md` §2.3 means by \"the\n * template's buffers stay alive while the asset is retained\".\n * - The flip side is that Lite exports **no** mesh disposer. The only public way to release a\n * template's buffers is {@link disposeMeshTemplate}: add it to a scene and take it out again.\n * - `removeFromScene` also recursively removes a mesh's `children` and nulls its `parent`, so\n * removing a `Model`'s root removes the whole instantiated subtree in one call.\n * - Hiding is `setSubtreeVisible` (exported as `setMeshVisible` too, `index.d.ts` 11199): it\n * cascades `visible` down the subtree and bumps a global visibility epoch. Never remove a mesh\n * from the scene to hide it — that disposes it.\n *\n * ## Updating a mesh's vertices (verified against `lib/mesh/mesh-factories.js`)\n *\n * `updateMesh*` writes the GPU buffer and **nothing else**. Three consequences, all of them\n * surprising enough to be worth stating where the calls are:\n *\n * 1. **The retained CPU arrays are not replaced.** `createMeshFromData` keeps `_cpuPositions`,\n * `_cpuNormals`, `_cpuUvs` and `_cpuIndices` — the arrays it was handed — and Lite's CPU ray\n * pick reads them (`lib/picking/ray-pick.js`). Only `updateMeshGeometry`/`resizeMeshGeometry`\n * re-retain, through `retainMeshGeometry`. So an update that hands over a *different* array\n * leaves picking looking at the old geometry, while an update after mutating the retained array\n * in place leaves picking exact. `MeshAsset` keeps its own copy in step for that reason.\n * 2. **Bounds are not recomputed.** `retainMeshGeometry` is what calls `computeAabb` and writes\n * `boundMin`/`boundMax`; the partial updaters do not. `Mesh`'s own declaration says a consumer\n * \"MAY overwrite these with a wider hand-computed box\", so {@link setMeshBounds} exists and\n * `MeshAsset.updatePositions` uses it.\n * 3. **A cloned template cannot be updated at all.** `writeVertexAttributeRange` throws\n * (`ThrowLiteError(360)`) when `mesh._gpu._refCount > 1`, and cloning a mesh retains that very\n * wrapper. A `MeshAsset` a `MeshRenderer` has drawn is therefore frozen; a mesh meant to be\n * edited is a renderable of its own, which is the shape the terrain chunk adapter uses.\n */\n\n/**\n * The Babylon Lite mesh a `MeshAsset` template and a `MeshRenderer` clone are, re-exported under an\n * ignifx name so feature code can name the type without importing `@babylonjs/lite`\n * (`CONSTITUTION.md` §3.4, coding standards §4).\n *\n * @remarks\n * Unstable: it is Lite's own type, reachable only through documented `.lite` escape hatches, and it\n * is excluded from the stability guarantees of `CONSTITUTION.md` Article IV.\n *\n * @public\n */\nexport type LiteMesh = Mesh;\n\n/**\n * Creates a box template.\n *\n * @param engine - The engine that owns the GPU buffers.\n * @param options - A uniform size, or per-axis dimensions.\n * @returns The mesh. It belongs to no scene yet.\n *\n * @example\n * ```ts\n * const template = createBoxMesh(engine, { size: 2 });\n * const instance = cloneMeshUnderNode(template, entityNode);\n * addMeshToScene(scene, instance);\n * ```\n *\n * @internal\n */\nexport function createBoxMesh(engine: EngineContext, options?: number | BoxOptions): Mesh {\n return createBox(engine, options);\n}\n\n/**\n * Creates a sphere template.\n *\n * @param engine - The engine that owns the GPU buffers.\n * @param options - Segment count and diameters.\n * @returns The mesh.\n *\n * @internal\n */\nexport function createSphereMesh(engine: EngineContext, options?: SphereOptions): Mesh {\n return createSphere(engine, options);\n}\n\n/**\n * Creates a plane template in the XY plane.\n *\n * @param engine - The engine that owns the GPU buffers.\n * @param options - Size, or width and height.\n * @returns The mesh.\n *\n * @internal\n */\nexport function createPlaneMesh(engine: EngineContext, options?: PlaneOptions): Mesh {\n return createPlane(engine, options);\n}\n\n/**\n * Creates a subdivided ground template in the XZ plane.\n *\n * @param engine - The engine that owns the GPU buffers.\n * @param options - Width, height, subdivisions, and UV scale.\n * @returns The mesh.\n *\n * @internal\n */\nexport function createGroundMesh(engine: EngineContext, options?: GroundOptions): Mesh {\n return createGround(engine, options);\n}\n\n/**\n * Creates a cylinder template along the Y axis.\n *\n * @param engine - The engine that owns the GPU buffers.\n * @param options - Height, diameters, and tessellation.\n * @returns The mesh.\n *\n * @internal\n */\nexport function createCylinderMesh(engine: EngineContext, options?: CylinderOptions): Mesh {\n return createCylinder(engine, options);\n}\n\n/**\n * Creates a capsule template along the Y axis.\n *\n * @remarks\n * `height` is the **total** height including both caps (`index.d.ts` 1523), which is the same\n * convention `@ignifx/physics`'s capsule collider uses, so a renderer and a collider built from one\n * pair of numbers line up.\n *\n * @param engine - The engine that owns the GPU buffers.\n * @param options - Height, radius, and tessellation.\n * @returns The mesh.\n *\n * @internal\n */\nexport function createCapsuleMesh(engine: EngineContext, options?: CapsuleOptions): Mesh {\n return createCapsule(engine, options);\n}\n\n/**\n * Creates a torus template in the XZ plane.\n *\n * @param engine - The engine that owns the GPU buffers.\n * @param options - Diameter, thickness, and tessellation.\n * @returns The mesh.\n *\n * @internal\n */\nexport function createTorusMesh(engine: EngineContext, options?: TorusOptions): Mesh {\n return createTorus(engine, options);\n}\n\n/**\n * Creates a mesh from raw vertex data.\n *\n * @remarks\n * Lite keeps a reference to the arrays that are handed in — it does not copy them — and uses them\n * for CPU ray picking and bounds (`lib/mesh/mesh-factories.js`). Callers must not mutate them\n * afterwards.\n *\n * @param engine - The engine that owns the GPU buffers.\n * @param name - A debug name.\n * @param positions - Three floats per vertex.\n * @param normals - Three floats per vertex.\n * @param indices - Three indices per triangle.\n * @param uvs - Two floats per vertex, or omitted.\n * @param uvs2 - Two floats per vertex for the second UV set, or omitted.\n * @param tangents - Four floats per vertex, or omitted.\n * @param colors - Four floats per vertex, or omitted.\n * @returns The mesh.\n *\n * @internal\n */\nexport function createMeshFromGeometry(\n engine: EngineContext,\n name: string,\n positions: Float32Array,\n normals: Float32Array,\n indices: Uint32Array,\n uvs?: Float32Array,\n uvs2?: Float32Array,\n tangents?: Float32Array,\n colors?: Float32Array,\n): Mesh {\n return createMeshFromData(engine, name, positions, normals, indices, uvs, uvs2, tangents, colors);\n}\n\n/**\n * Re-uploads part of a mesh's position buffer.\n *\n * @remarks\n * A no-op range is accepted; an out-of-range one, or a mesh whose GPU geometry has co-owners,\n * throws a Lite error (see the module note). It does **not** refresh the CPU picking geometry or\n * the bounds.\n *\n * @param engine - The engine that owns the buffer.\n * @param mesh - The mesh to update.\n * @param positions - Three floats per vertex, read from index 0.\n * @param vertexOffset - The first destination vertex to overwrite.\n * @param vertexCount - How many vertices to write.\n *\n * @internal\n */\nexport function updateMeshPositions(\n engine: EngineContext,\n mesh: Mesh,\n positions: Float32Array,\n vertexOffset: number,\n vertexCount: number,\n): void {\n liteUpdateMeshPositions(engine, mesh, positions, vertexOffset, vertexCount);\n}\n\n/**\n * Re-uploads part of a mesh's normal buffer.\n *\n * @param engine - The engine that owns the buffer.\n * @param mesh - The mesh to update.\n * @param normals - Three floats per vertex.\n * @param vertexOffset - The first destination vertex to overwrite.\n * @param vertexCount - How many vertices to write.\n *\n * @internal\n */\nexport function updateMeshNormals(\n engine: EngineContext,\n mesh: Mesh,\n normals: Float32Array,\n vertexOffset: number,\n vertexCount: number,\n): void {\n liteUpdateMeshNormals(engine, mesh, normals, vertexOffset, vertexCount);\n}\n\n/**\n * Re-uploads part of a mesh's UV buffer.\n *\n * @remarks\n * Lite makes it a no-op when the mesh was created without UVs, rather than an error.\n *\n * @param engine - The engine that owns the buffer.\n * @param mesh - The mesh to update.\n * @param uvs - Two floats per vertex.\n * @param vertexOffset - The first destination vertex to overwrite.\n * @param vertexCount - How many vertices to write.\n *\n * @internal\n */\nexport function updateMeshUvs(\n engine: EngineContext,\n mesh: Mesh,\n uvs: Float32Array,\n vertexOffset: number,\n vertexCount: number,\n): void {\n liteUpdateMeshUvs(engine, mesh, uvs, vertexOffset, vertexCount);\n}\n\n/**\n * Re-uploads part of a mesh's vertex-colour buffer.\n *\n * @remarks\n * The colour attribute is `vec4`, and Lite makes the call a no-op when the mesh was created without\n * colours.\n *\n * @param engine - The engine that owns the buffer.\n * @param mesh - The mesh to update.\n * @param colors - Four floats per vertex.\n * @param vertexOffset - The first destination vertex to overwrite.\n * @param vertexCount - How many vertices to write.\n *\n * @internal\n */\nexport function updateMeshColors(\n engine: EngineContext,\n mesh: Mesh,\n colors: Float32Array,\n vertexOffset: number,\n vertexCount: number,\n): void {\n liteUpdateMeshColors(engine, mesh, colors, vertexOffset, vertexCount);\n}\n\n/**\n * Writes a mesh's object-local bounding box.\n *\n * @remarks\n * `Mesh.boundMin`/`boundMax` are declared consumer-writable, and writing them is the only way to\n * keep the shadow fit, the thin-instance culler and the Havok shape extents honest after a partial\n * vertex update — none of the partial updaters recomputes them. The existing arrays are mutated in\n * place when they are there, so repeated sculpting allocates nothing.\n *\n * @param mesh - The mesh to re-bound.\n * @param minX - The smallest X.\n * @param minY - The smallest Y.\n * @param minZ - The smallest Z.\n * @param maxX - The largest X.\n * @param maxY - The largest Y.\n * @param maxZ - The largest Z.\n *\n * @internal\n */\nexport function setMeshBounds(\n mesh: Mesh,\n minX: number,\n minY: number,\n minZ: number,\n maxX: number,\n maxY: number,\n maxZ: number,\n): void {\n const boundMin = mesh.boundMin;\n if (boundMin === undefined) {\n mesh.boundMin = [minX, minY, minZ];\n } else {\n boundMin[0] = minX;\n boundMin[1] = minY;\n boundMin[2] = minZ;\n }\n const boundMax = mesh.boundMax;\n if (boundMax === undefined) {\n mesh.boundMax = [maxX, maxY, maxZ];\n } else {\n boundMax[0] = maxX;\n boundMax[1] = maxY;\n boundMax[2] = maxZ;\n }\n}\n\n/**\n * Gives a cloned mesh bounding-box arrays of its own.\n *\n * @remarks\n * `cloneMeshNode` shallow-spreads the template (`lib/scene/transform-node.js`), so a clone starts\n * out sharing the template's `boundMin`/`boundMax` arrays and {@link setMeshBounds} — which mutates\n * in place — would write through to the template and to every other clone. Any caller that re-bounds\n * one clone alone has to call this first.\n *\n * @param mesh - The clone.\n *\n * @internal\n */\nexport function detachMeshBounds(mesh: Mesh): void {\n const boundMin = mesh.boundMin;\n if (boundMin !== undefined) {\n mesh.boundMin = [boundMin[0], boundMin[1], boundMin[2]];\n }\n const boundMax = mesh.boundMax;\n if (boundMax !== undefined) {\n mesh.boundMax = [boundMax[0], boundMax[1], boundMax[2]];\n }\n}\n\n/**\n * Recomputes a mesh's object-local bounding box from a position array and writes it.\n *\n * @remarks\n * The partial vertex updaters leave `boundMin`/`boundMax` alone (see the module note), and every\n * consumer that fits a shadow cascade, culls a thin instance, or measures a Havok shape reads them.\n * One linear pass, no allocation. A position array too short to hold one vertex leaves the bounds\n * as they were.\n *\n * @param mesh - The mesh to re-bound.\n * @param positions - Three floats per vertex.\n *\n * @internal\n */\nexport function recomputeMeshBounds(mesh: Mesh, positions: Float32Array): void {\n if (positions.length < 3) {\n return;\n }\n let minX = Number.POSITIVE_INFINITY;\n let minY = Number.POSITIVE_INFINITY;\n let minZ = Number.POSITIVE_INFINITY;\n let maxX = Number.NEGATIVE_INFINITY;\n let maxY = Number.NEGATIVE_INFINITY;\n let maxZ = Number.NEGATIVE_INFINITY;\n for (let index = 0; index + 2 < positions.length; index += 3) {\n const x = positions[index] ?? 0;\n const y = positions[index + 1] ?? 0;\n const z = positions[index + 2] ?? 0;\n minX = x < minX ? x : minX;\n minY = y < minY ? y : minY;\n minZ = z < minZ ? z : minZ;\n maxX = x > maxX ? x : maxX;\n maxY = y > maxY ? y : maxY;\n maxZ = z > maxZ ? z : maxZ;\n }\n setMeshBounds(mesh, minX, minY, minZ, maxX, maxY, maxZ);\n}\n\n/**\n * Clones a template — mesh or transform-node subtree — and parents the clone under an entity node.\n *\n * @remarks\n * The clone shares the template's GPU buffers (see the module note). Cloning a mesh whose buffers\n * were already released throws, which is Lite's way of telling you the template outlived its asset.\n *\n * Only the `parent` link is written; the clone is deliberately **not** pushed into the parent's\n * `children` array, for the same reason cameras and lights are not (`./camera.ts`): ignifx\n * transform nodes are never added to a Lite scene, so nothing in Lite walks their children, and\n * `removeFromScene` nulls a removed mesh's `parent` without touching the array it was listed in —\n * so maintaining it would only create a stale entry to clean up.\n *\n * @param template - The mesh or subtree to clone.\n * @param parent - The entity's transform node, or `null` for world space.\n * @returns The cloned root. Add it to the scene with {@link addMeshToScene}.\n *\n * @internal\n */\nexport function cloneMeshUnderNode(template: SceneNode, parent: SceneNode | null): SceneNode {\n const clone = cloneTransformNode(template);\n clone.parent = parent;\n return clone;\n}\n\n/**\n * Adds a mesh — or a transform-node subtree containing meshes — to a render scene.\n *\n * @remarks\n * `addToScene` recurses into `children` and re-parents each one, so a whole instantiated model goes\n * in with one call. When the scene is already registered, the mesh joins Lite's runtime\n * material-swap queue and appears once its material family's renderable has been rebuilt\n * (`docs/architecture/07-rendering.md` §1.1 and ADR-0014).\n *\n * @param scene - The render scene.\n * @param node - The mesh or subtree root to add.\n *\n * @internal\n */\nexport function addMeshToScene(scene: SceneContext, node: SceneNode): void {\n addToScene(scene, node);\n}\n\n/**\n * Removes a mesh — and everything under it — from a render scene, releasing its GPU buffers when it\n * has left its last scene.\n *\n * @remarks\n * This is destruction, not hiding: use {@link setMeshSubtreeVisible} to hide.\n *\n * @param scene - The render scene.\n * @param node - The mesh or subtree root to remove.\n *\n * @internal\n */\nexport function removeMeshFromScene(scene: SceneContext, node: SceneNode): void {\n removeFromScene(scene, node);\n}\n\n/**\n * Shows or hides a mesh and everything under it.\n *\n * @param node - The subtree root.\n * @param visible - `true` to show it, `false` to hide it.\n *\n * @internal\n */\nexport function setMeshSubtreeVisible(node: SceneNode, visible: boolean): void {\n setSubtreeVisible(node, visible);\n}\n\n/**\n * Assigns a mesh's material.\n *\n * @remarks\n * `Mesh.material` is an accessor once the mesh has joined a scene: writing it queues a material\n * swap on every scene the mesh belongs to (`lib/scene/mesh-scene-registry.js`,\n * `installMaterialSetter`). Assigning the material the mesh already has is a no-op.\n *\n * @param mesh - The mesh to change.\n * @param material - The material to draw it with.\n *\n * @internal\n */\nexport function setMeshMaterial(mesh: Mesh, material: Material): void {\n mesh.material = material;\n}\n\n/**\n * Sets whether a mesh is darkened by shadow maps.\n *\n * @param mesh - The mesh to change.\n * @param receiveShadows - `true` to sample shadow maps on this mesh.\n *\n * @internal\n */\nexport function setMeshReceiveShadows(mesh: Mesh, receiveShadows: boolean): void {\n mesh.receiveShadows = receiveShadows;\n}\n\n/**\n * Sets a mesh's sort key within its phase. Lower values are drawn first.\n *\n * @param mesh - The mesh to change.\n * @param renderOrder - The sort key; it only orders within the opaque or the transparent phase.\n *\n * @internal\n */\nexport function setMeshRenderOrder(mesh: Mesh, renderOrder: number): void {\n mesh.renderOrder = renderOrder;\n}\n\n/**\n * Sets whether picking considers a mesh at all.\n *\n * @remarks\n * `pickable === false` removes the mesh from both the GPU picker's candidate list and the CPU ray\n * test, so it neither occludes nor returns a hit (`index.d.ts` 7214, `lib/picking/ray-pick.js`).\n *\n * @param mesh - The mesh to change.\n * @param pickable - `true` to allow picking.\n *\n * @internal\n */\nexport function setMeshPickable(mesh: Mesh, pickable: boolean): void {\n mesh.pickable = pickable;\n}\n\n/**\n * Gives a mesh the string id Lite's light include/exclude sets match on.\n *\n * @param mesh - The mesh to name.\n * @param id - The id. It should be unique within the scene.\n *\n * @internal\n */\nexport function setMeshId(mesh: Mesh, id: string): void {\n mesh.id = id;\n}\n\n/**\n * Replaces the materials of every mesh in a subtree whose current material carries one of the given\n * names.\n *\n * @remarks\n * `Material.name` is \"populated by loaders from the source asset (e.g. the glTF material name) so\n * callers can look a material up by name\" (`index.d.ts`), which is the identifier\n * `docs/architecture/07-rendering.md` §2.4 means by \"by material name\". Assigning `Mesh.material`\n * queues a material swap on every scene the mesh belongs to; assigning the material a mesh already\n * has is a no-op, so re-running this is cheap.\n *\n * @param node - The subtree root.\n * @param overrides - Source material name to replacement material.\n * @returns How many meshes were re-materialled.\n *\n * @internal\n */\nexport function overrideSubtreeMaterials(node: SceneNode, overrides: ReadonlyMap<string, Material>): number {\n let changed = 0;\n if (\"material\" in node) {\n // A scene node that carries `material` is a mesh —\n // the same structural test Lite's own scene walk uses.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const mesh = node as Mesh;\n const name = mesh.material.name;\n const replacement = name === undefined ? undefined : overrides.get(name);\n if (replacement !== undefined && replacement !== mesh.material) {\n mesh.material = replacement;\n changed += 1;\n }\n }\n const children = node.children;\n for (let index = 0; index < children.length; index += 1) {\n const child = children[index];\n if (child !== undefined) {\n changed += overrideSubtreeMaterials(child, overrides);\n }\n }\n return changed;\n}\n\n/**\n * Releases a template mesh's GPU buffers.\n *\n * @remarks\n * Lite exports no mesh disposer: a mesh's buffers are freed only when it leaves its last scene\n * (`lib/scene/scene-remove.js`). A template that was never added to a scene therefore has to be\n * added and removed to be released, which is exactly what this does. Two consequences the caller\n * must respect:\n *\n * 1. The template must carry no material, or the round trip will build and immediately tear down a\n * renderable for it. Templates created by the factories above start with none.\n * 2. Any clone still alive keeps the shared buffers: the reference count only reaches zero when the\n * last co-owner has gone. Releasing the template while clones are in a scene is safe, but the\n * template can no longer be cloned afterwards.\n *\n * @param scene - Any scene on the template's engine; it is used only as the round trip's vehicle.\n * @param template - The template to release.\n *\n * @internal\n */\nexport function disposeMeshTemplate(scene: SceneContext, template: Mesh): void {\n addToScene(scene, template);\n removeFromScene(scene, template);\n}\n\n/**\n * Collects every mesh in a subtree — the root included — in depth-first order.\n *\n * @remarks\n * A scene node that carries `material` is a mesh: the same structural test\n * {@link overrideSubtreeMaterials} and Lite's own scene walk use (`index.d.ts` 7156 declares\n * `material` on `Mesh` and nowhere on `SceneNode`, 10104).\n *\n * Call it **once**, when the subtree is instantiated. The clone tree `instantiateContainer` built\n * never changes shape afterwards, so walking it again every frame would put a recursion on the\n * render path for an answer that cannot have moved (coding standards §7).\n *\n * @param node - The subtree root.\n * @param out - The list the meshes are appended to; it is not cleared first.\n *\n * @internal\n */\nexport function collectSubtreeMeshes(node: SceneNode, out: Mesh[]): void {\n if (\"material\" in node) {\n // See the note above.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n out.push(node as Mesh);\n }\n const children = node.children;\n for (let index = 0; index < children.length; index += 1) {\n const child = children[index];\n if (child !== undefined) {\n collectSubtreeMeshes(child, out);\n }\n }\n}\n"],"mappings":";;;AA4GA,MAAM,eAAe;;AAGrB,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;AAsBtB,SAAgB,WAAW,MAAyB;CAClD,OAAO,oBAAoB,IAAI;AACjC;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,YAAY,MAAuB;CACjD,WAAW,MAAM,IAAI;CACrB,MAAM,WAAW,KAAK;CACtB,IAAI,aAAa,KAAA,GACf,OAAO,SAAS;AAEpB;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,WAAW,OAAkB,QAAgC;CAC3E,MAAM,WAAW,MAAM;CACvB,IAAI,aAAa,QACf;CAEF,MAAM,mBAAmB,WAAW,QAAQ;CAC5C,IAAI,qBAAqB,MAAM;EAC7B,MAAM,QAAQ,iBAAiB,QAAQ,KAAK;EAC5C,IAAI,SAAS,GACX,iBAAiB,OAAO,OAAO,CAAC;CAEpC;CAGA,MAAM,SAAS;CACf,IAAI,WAAW,QAAQ,CAAC,OAAO,SAAS,SAAS,KAAK,GACpD,OAAO,SAAS,KAAK,KAAK;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,qBAAqB,OAAkB,QAAgC;CACrF,UAAU,OAAO,MAAM;AACzB;;;;;;;;;;;;;;;;;AAkBA,SAAgB,gBAAgB,MAAiB,KAAuC;CACtF,MAAM,SAAS,KAAK;CACpB,KAAK,IAAI,QAAQ,GAAG,QAAQ,eAAe,SAAS,GAClD,IAAI,SAAS,OAAO,UAAU;CAEhC,OAAO;AACT;;;;;;;;;;;;;;;;AAiBA,SAAgB,mBAAmB,MAAyB;CAC1D,OAAO,KAAK;AACd;;;;;;;;;;;;;;;AA2EA,SAAgB,mBAAmB,MAAiB,SAAwB;CAC1E,KAAK,UAAU;AACjB;;;;;;;;;;;;;;;AAgBA,SAAgB,QAAQ,MAAiB,KAAoB;CAC3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ACvE,IAAI,cAAc,MAGhB,IAAI,KAAK,IAAY;CAEvB,MAAM,WAAW,KAAK;CACtB,KAAK,IAAI,QAAQ,GAAG,QAAQ,SAAS,QAAQ,SAAS,GAAG;EACvD,MAAM,QAAQ,SAAS;EACvB,IAAI,UAAU,KAAA,GACZ,qBAAqB,OAAO,GAAG;CAEnC;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"shader-pragma-D4HKC9vP.js","names":[],"sources":["../src/render/shader-pragma.ts"],"sourcesContent":["import { CoreErrorCode } from \"../errors/error-codes.js\";\nimport { IgnifxError } from \"../errors/ignifx-error.js\";\nimport {\n IGNIFX_UNIFORM_NAMES,\n LITE_SYSTEM_UNIFORM_NAMES,\n SHADER_ATTRIBUTE_NAMES,\n SHADER_BLEND_MODES,\n SHADER_CULL_MODES,\n SHADER_INSTANCING_MODES,\n SHADER_TEXTURE_FALLBACKS,\n SHADER_UNIFORM_TYPES,\n} from \"./shader-declaration.js\";\nimport type {\n IgnifxUniformName,\n LiteSystemUniformName,\n ShaderAttributeName,\n ShaderBlendMode,\n ShaderCullMode,\n ShaderDeclaration,\n ShaderDefineDeclaration,\n ShaderInstancingMode,\n ShaderKind,\n ShaderStorageDeclaration,\n ShaderTextureDeclaration,\n ShaderTextureFallback,\n ShaderUniformDeclaration,\n ShaderUniformType,\n} from \"./shader-declaration.js\";\n\n/**\n * Reads the `// @ignifx …` comment pragmas of a `.wgsl` file into a {@link ShaderDeclaration}\n * (grammar: `docs/plan/2026-09-terrain-particles-shaders.md` §3.1; rationale: ADR-0024).\n *\n * Pure string work with no Babylon Lite import, so the build-time validator and the runtime loader\n * can share it. Four rules the grammar itself does not show:\n *\n * - `@ignifx system` mixes Lite's names with ignifx's, and the WGSL reads them from different\n * structs, so they are split into `declaration.system` and `declaration.ignifx`.\n * - An omitted `attributes` directive means `position`; Lite refuses a shader material without it\n * (`lib/material/shader/shader-material.js`, error 293).\n * - A `color(…)` default keeps the authored sRGB numbers; `./shader-material.ts` converts.\n * - `cull front` and `transmissive` on an opaque surface are refused here, with a line number,\n * because Lite has no front-face culling and throws on the second combination (error 295).\n */\n\n/** Matches an `// @ignifx …` line and captures the directive text after it. */\nconst PRAGMA_LINE = /^\\s*\\/\\/\\s*@ignifx\\b(.*)$/;\n\n/** Matches a WGSL identifier. */\nconst IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/** Splits `name: type` at the colon, capturing the identifier and the rest of the line. */\nconst NAME_AND_TYPE = /^([A-Za-z_][A-Za-z0-9_]*)\\s*:\\s*(.*)$/;\n\n/** Matches a leading `tooltip(\"…\")` modifier, capturing the quoted text. */\nconst TOOLTIP_MODIFIER = /^tooltip\\(\\s*\"((?:[^\"\\\\]|\\\\.)*)\"\\s*\\)\\s*/;\n\n/** Matches a leading `range(…)`, `step(…)`, or `color(…)`/`color` modifier. */\nconst CALL_MODIFIER = /^(range|step|color)\\s*(?:\\(([^)]*)\\))?\\s*/;\n\n/** Matches a leading `color(…)` default value, capturing the arguments. */\nconst COLOR_DEFAULT = /^color\\s*\\(([^)]*)\\)\\s*/;\n\n/** Matches a leading parenthesised numeric list, capturing the arguments. */\nconst TUPLE_DEFAULT = /^\\(([^)]*)\\)\\s*/;\n\n/** Matches a leading decimal number, with optional sign and exponent. */\nconst NUMBER_DEFAULT = /^([+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?)\\s*/;\n\n/** How many elements each uniform type holds. */\nconst ELEMENT_COUNTS: Readonly<Record<ShaderUniformType, number>> = Object.freeze({\n f32: 1,\n u32: 1,\n i32: 1,\n \"vec2<f32>\": 2,\n \"vec3<f32>\": 3,\n \"vec4<f32>\": 4,\n \"mat4x4<f32>\": 16,\n});\n\n/** The identity matrix a `mat4x4<f32>` uniform starts at when the file declares no default. */\nconst IDENTITY_MATRIX: readonly number[] = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);\n\n/** The mutable declaration the parser fills in, line by line. */\ninterface DeclarationDraft {\n kind: ShaderKind | null;\n attributes: ShaderAttributeName[] | null;\n readonly system: LiteSystemUniformName[];\n readonly ignifx: IgnifxUniformName[];\n readonly uniforms: ShaderUniformDeclaration[];\n readonly textures: ShaderTextureDeclaration[];\n readonly storage: ShaderStorageDeclaration[];\n readonly defines: ShaderDefineDeclaration[];\n readonly names: Set<string>;\n blend: ShaderBlendMode | null;\n cull: ShaderCullMode | null;\n depthWrite: boolean | null;\n depthTest: boolean | null;\n transmissive: boolean;\n instancing: ShaderInstancingMode | null;\n}\n\n/**\n * Reads a `.wgsl` file's `// @ignifx` pragmas into the declaration the loader, the material\n * builder, and the inspector all read.\n *\n * @param source - The whole file, as text.\n * @param address - The asset address, so a failure names the file.\n * @returns The declaration, with every default filled in.\n * @throws IgnifxError with code `IGX-0719`, carrying the offending `line`, for an unknown directive,\n * a malformed one, a duplicate binding name, an attribute or uniform type Babylon Lite does not\n * have, or a combination it cannot express.\n *\n * @example\n * ```ts\n * const declaration = parseShaderDeclaration(\"// @ignifx shader\\n\", \"shaders/flat.wgsl\");\n * declaration.attributes; // [\"position\"]\n * ```\n *\n * @public\n */\nexport function parseShaderDeclaration(source: string, address: string): ShaderDeclaration {\n const draft: DeclarationDraft = {\n kind: null,\n attributes: null,\n system: [],\n ignifx: [],\n uniforms: [],\n textures: [],\n storage: [],\n defines: [],\n names: new Set<string>(),\n blend: null,\n cull: null,\n depthWrite: null,\n depthTest: null,\n transmissive: false,\n instancing: null,\n };\n const lines = source.split(\"\\n\");\n for (let index = 0; index < lines.length; index += 1) {\n const matched = PRAGMA_LINE.exec(lines[index] ?? \"\");\n if (matched === null) {\n continue;\n }\n readDirective(draft, (matched[1] ?? \"\").trim(), address, index + 1);\n }\n return finish(draft, address);\n}\n\n/**\n * Applies one `// @ignifx …` line to the draft.\n *\n * @param draft - The declaration being built.\n * @param text - The directive text, already trimmed.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readDirective(draft: DeclarationDraft, text: string, address: string, line: number): void {\n if (text.length === 0) {\n throw pragmaError(address, line, \"an @ignifx comment declares no directive\");\n }\n const separator = text.search(/\\s/);\n const directive = separator < 0 ? text : text.slice(0, separator);\n const rest = separator < 0 ? \"\" : text.slice(separator + 1).trim();\n switch (directive) {\n case \"shader\":\n case \"surface\":\n case \"post\":\n readKind(draft, directive, rest, address, line);\n return;\n case \"attributes\":\n readAttributes(draft, rest, address, line);\n return;\n case \"system\":\n readSystem(draft, rest, address, line);\n return;\n case \"uniform\":\n draft.uniforms.push(readUniform(draft, rest, address, line));\n return;\n case \"texture\":\n draft.textures.push(readTexture(draft, rest, address, line));\n return;\n case \"storage\":\n draft.storage.push(readStorage(draft, rest, address, line));\n return;\n case \"define\":\n draft.defines.push(readDefine(draft, rest, address, line));\n return;\n case \"blend\":\n case \"cull\":\n case \"depthWrite\":\n case \"depthTest\":\n case \"transmissive\":\n case \"instancing\":\n readPipeline(draft, text, address, line);\n return;\n default:\n throw pragmaError(address, line, `${JSON.stringify(directive)} is not an @ignifx directive`);\n }\n}\n\n/**\n * Records the file's form, refusing a second one.\n *\n * @param draft - The declaration being built.\n * @param kind - The declared form.\n * @param rest - Whatever followed it, which must be nothing.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readKind(draft: DeclarationDraft, kind: ShaderKind, rest: string, address: string, line: number): void {\n if (rest.length > 0) {\n throw pragmaError(address, line, `@ignifx ${kind} takes no arguments, but found ${JSON.stringify(rest)}`);\n }\n if (draft.kind !== null) {\n throw pragmaError(address, line, `the file already declared @ignifx ${draft.kind}`);\n }\n draft.kind = kind;\n}\n\n/**\n * Records the vertex attributes the vertex stage reads.\n *\n * @param draft - The declaration being built.\n * @param rest - The comma-separated attribute names.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readAttributes(draft: DeclarationDraft, rest: string, address: string, line: number): void {\n if (draft.attributes !== null) {\n throw pragmaError(address, line, \"the file already declared @ignifx attributes\");\n }\n const names = splitList(rest, address, line, \"attributes\");\n const attributes: ShaderAttributeName[] = [];\n for (const name of names) {\n const attribute = matchLiteral(SHADER_ATTRIBUTE_NAMES, name);\n if (attribute === null) {\n throw pragmaError(\n address,\n line,\n `${JSON.stringify(name)} is not a vertex attribute; Babylon Lite has ${SHADER_ATTRIBUTE_NAMES.join(\", \")}`,\n );\n }\n if (attributes.includes(attribute)) {\n throw pragmaError(address, line, `the attribute ${attribute} is declared twice`);\n }\n attributes.push(attribute);\n }\n draft.attributes = attributes;\n}\n\n/**\n * Records the system uniforms, splitting Babylon Lite's names from ignifx's own.\n *\n * @param draft - The declaration being built.\n * @param rest - The comma-separated uniform names.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readSystem(draft: DeclarationDraft, rest: string, address: string, line: number): void {\n const names = splitList(rest, address, line, \"system\");\n for (const name of names) {\n const lite = matchLiteral(LITE_SYSTEM_UNIFORM_NAMES, name);\n if (lite !== null) {\n claimName(draft, lite, address, line, \"system uniform\");\n draft.system.push(lite);\n continue;\n }\n const ignifx = matchLiteral(IGNIFX_UNIFORM_NAMES, name);\n if (ignifx !== null) {\n claimName(draft, ignifx, address, line, \"system uniform\");\n draft.ignifx.push(ignifx);\n continue;\n }\n throw pragmaError(\n address,\n line,\n `${JSON.stringify(name)} is not a system uniform; Babylon Lite has ${LITE_SYSTEM_UNIFORM_NAMES.join(\", \")} and ignifx adds ${IGNIFX_UNIFORM_NAMES.join(\", \")}`,\n );\n }\n}\n\n/**\n * Reads one `// @ignifx uniform name: type [= default] [modifiers]` line.\n *\n * @param draft - The declaration being built, for the name namespace.\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The declaration.\n */\nfunction readUniform(draft: DeclarationDraft, rest: string, address: string, line: number): ShaderUniformDeclaration {\n const split = NAME_AND_TYPE.exec(rest);\n if (split === null) {\n throw pragmaError(address, line, `@ignifx uniform expects \"name: type\", but found ${JSON.stringify(rest)}`);\n }\n const name = split[1] ?? \"\";\n let tail = (split[2] ?? \"\").trim();\n const typeSeparator = tail.search(/[\\s=]/);\n const typeName = typeSeparator < 0 ? tail : tail.slice(0, typeSeparator);\n tail = (typeSeparator < 0 ? \"\" : tail.slice(typeName.length)).trim();\n const type = matchLiteral(SHADER_UNIFORM_TYPES, typeName);\n if (type === null) {\n throw pragmaError(\n address,\n line,\n `${JSON.stringify(typeName)} is not a uniform type; Babylon Lite has ${SHADER_UNIFORM_TYPES.join(\", \")}`,\n );\n }\n claimName(draft, name, address, line, \"uniform\");\n let defaultValue: number | readonly number[] | null = null;\n let isColor = false;\n if (tail.startsWith(\"=\")) {\n tail = tail.slice(1).trim();\n const parsed = readDefaultValue(tail, type, name, address, line);\n defaultValue = parsed.value;\n isColor = parsed.color;\n tail = parsed.tail;\n }\n const modifiers = readModifiers(tail, name, type, address, line);\n return {\n name,\n type,\n defaultValue: defaultValue ?? implicitDefault(type),\n color: isColor || modifiers.color,\n range: modifiers.range,\n step: modifiers.step,\n tooltip: modifiers.tooltip,\n };\n}\n\n/** A parsed `= …` default value and whatever followed it. */\ninterface ParsedDefault {\n /** The numbers the file wrote. */\n readonly value: number | readonly number[];\n /** Whether the value was written as `color(…)`. */\n readonly color: boolean;\n /** The rest of the line. */\n readonly tail: string;\n}\n\n/**\n * Reads the `= …` half of a uniform declaration.\n *\n * @param text - The text after the `=`.\n * @param type - The declared type, which fixes the element count.\n * @param name - The uniform's name, for diagnostics.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The value, whether it was a colour, and the rest of the line.\n */\nfunction readDefaultValue(\n text: string,\n type: ShaderUniformType,\n name: string,\n address: string,\n line: number,\n): ParsedDefault {\n const expected = ELEMENT_COUNTS[type];\n const colorMatch = COLOR_DEFAULT.exec(text);\n if (colorMatch !== null) {\n const numbers = readNumbers(colorMatch[1] ?? \"\", name, address, line);\n if (type !== \"vec3<f32>\" && type !== \"vec4<f32>\") {\n throw pragmaError(address, line, `${name} is a ${type}, so color(…) does not apply to it`);\n }\n assertArity(numbers.length, expected, name, type, address, line);\n return { value: numbers, color: true, tail: text.slice(colorMatch[0].length).trim() };\n }\n const tupleMatch = TUPLE_DEFAULT.exec(text);\n if (tupleMatch !== null) {\n const numbers = readNumbers(tupleMatch[1] ?? \"\", name, address, line);\n assertArity(numbers.length, expected, name, type, address, line);\n return { value: numbers, color: false, tail: text.slice(tupleMatch[0].length).trim() };\n }\n const numberMatch = NUMBER_DEFAULT.exec(text);\n if (numberMatch !== null) {\n assertArity(1, expected, name, type, address, line);\n return { value: Number(numberMatch[1]), color: false, tail: text.slice(numberMatch[0].length).trim() };\n }\n throw pragmaError(address, line, `${name} declares no readable default value after \"=\"`);\n}\n\n/** The optional hints an inspector renders a uniform with. */\ninterface ParsedModifiers {\n /** Whether the bare `color` modifier was present. */\n readonly color: boolean;\n /** The `range(a, b)` bounds, or `null`. */\n readonly range: readonly [number, number] | null;\n /** The `step(s)` increment, or `null`. */\n readonly step: number | null;\n /** The `tooltip(\"…\")` text, or `null`. */\n readonly tooltip: string | null;\n}\n\n/**\n * Reads the `range(…)`, `step(…)`, `color`, and `tooltip(\"…\")` modifiers that close a uniform line.\n *\n * @param text - What is left of the line.\n * @param name - The uniform's name, for diagnostics.\n * @param type - The declared type, which decides whether `color` applies.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The hints.\n */\nfunction readModifiers(\n text: string,\n name: string,\n type: ShaderUniformType,\n address: string,\n line: number,\n): ParsedModifiers {\n let rest = text;\n let color = false;\n let range: readonly [number, number] | null = null;\n let step: number | null = null;\n let tooltip: string | null = null;\n while (rest.length > 0) {\n const tooltipMatch = TOOLTIP_MODIFIER.exec(rest);\n if (tooltipMatch !== null) {\n if (tooltip !== null) {\n throw pragmaError(address, line, `${name} declares tooltip twice`);\n }\n tooltip = (tooltipMatch[1] ?? \"\").replaceAll('\\\\\"', '\"');\n rest = rest.slice(tooltipMatch[0].length);\n continue;\n }\n const callMatch = CALL_MODIFIER.exec(rest);\n if (callMatch === null) {\n throw pragmaError(address, line, `${name} declares ${JSON.stringify(rest)}, which is not a uniform modifier`);\n }\n const modifier = callMatch[1] ?? \"\";\n const argumentText = callMatch[2];\n if (modifier === \"color\") {\n if (argumentText !== undefined) {\n throw pragmaError(address, line, `${name} declares color(…) after its default value`);\n }\n if (type !== \"vec3<f32>\" && type !== \"vec4<f32>\") {\n throw pragmaError(address, line, `${name} is a ${type}, so color does not apply to it`);\n }\n color = true;\n } else if (modifier === \"range\") {\n if (range !== null) {\n throw pragmaError(address, line, `${name} declares range twice`);\n }\n const bounds = readNumbers(argumentText ?? \"\", name, address, line);\n const low = bounds[0];\n const high = bounds[1];\n if (bounds.length !== 2 || low === undefined || high === undefined) {\n throw pragmaError(address, line, `${name} declares range(…) with ${String(bounds.length)} bounds, not 2`);\n }\n range = [low, high];\n } else {\n if (step !== null) {\n throw pragmaError(address, line, `${name} declares step twice`);\n }\n const increments = readNumbers(argumentText ?? \"\", name, address, line);\n const increment = increments[0];\n if (increments.length !== 1 || increment === undefined) {\n throw pragmaError(address, line, `${name} declares step(…) with ${String(increments.length)} values, not 1`);\n }\n step = increment;\n }\n rest = rest.slice(callMatch[0].length);\n }\n return { color, range, step, tooltip };\n}\n\n/**\n * Reads one `// @ignifx texture name [srgb] [normal] [default white|black|transparent] [array]`\n * line.\n *\n * @param draft - The declaration being built, for the name namespace.\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The declaration.\n */\nfunction readTexture(draft: DeclarationDraft, rest: string, address: string, line: number): ShaderTextureDeclaration {\n const tokens = rest.split(/\\s+/).filter((token) => token.length > 0);\n const name = tokens[0];\n if (name === undefined) {\n throw pragmaError(address, line, \"@ignifx texture declares no name\");\n }\n assertIdentifier(name, address, line, \"texture\");\n claimName(draft, name, address, line, \"texture\");\n claimName(draft, `${name}Sampler`, address, line, \"texture sampler\");\n let srgb = false;\n let normal = false;\n let array = false;\n let fallback: ShaderTextureFallback | null = null;\n for (let index = 1; index < tokens.length; index += 1) {\n const token = tokens[index] ?? \"\";\n if (token === \"srgb\") {\n srgb = true;\n } else if (token === \"normal\") {\n normal = true;\n } else if (token === \"array\") {\n array = true;\n } else if (token === \"default\") {\n index += 1;\n const named = matchLiteral(SHADER_TEXTURE_FALLBACKS, tokens[index] ?? \"\");\n if (named === null) {\n throw pragmaError(\n address,\n line,\n `${name} declares default ${JSON.stringify(tokens[index] ?? \"\")}; expected ${SHADER_TEXTURE_FALLBACKS.join(\", \")}`,\n );\n }\n fallback = named;\n } else {\n throw pragmaError(address, line, `${JSON.stringify(token)} is not a texture modifier`);\n }\n }\n return { name, srgb, normal, fallback, array };\n}\n\n/**\n * Reads one `// @ignifx storage name: array<T>` line.\n *\n * @param draft - The declaration being built, for the name namespace.\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The declaration.\n */\nfunction readStorage(draft: DeclarationDraft, rest: string, address: string, line: number): ShaderStorageDeclaration {\n const split = NAME_AND_TYPE.exec(rest);\n if (split === null) {\n throw pragmaError(address, line, `@ignifx storage expects \"name: type\", but found ${JSON.stringify(rest)}`);\n }\n const name = split[1] ?? \"\";\n const type = (split[2] ?? \"\").trim();\n if (type.length === 0) {\n throw pragmaError(address, line, `${name} declares no storage buffer type`);\n }\n claimName(draft, name, address, line, \"storage buffer\");\n return { name, type };\n}\n\n/**\n * Reads one `// @ignifx define NAME = value` line.\n *\n * @param draft - The declaration being built, for the name namespace.\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The declaration.\n */\nfunction readDefine(draft: DeclarationDraft, rest: string, address: string, line: number): ShaderDefineDeclaration {\n const equals = rest.indexOf(\"=\");\n if (equals < 0) {\n throw pragmaError(address, line, `@ignifx define expects \"NAME = value\", but found ${JSON.stringify(rest)}`);\n }\n const name = rest.slice(0, equals).trim();\n const text = rest.slice(equals + 1).trim();\n assertIdentifier(name, address, line, \"define\");\n claimName(draft, name, address, line, \"define\");\n if (text === \"true\" || text === \"false\") {\n return { name, value: text === \"true\" };\n }\n const numberMatch = NUMBER_DEFAULT.exec(text);\n if (numberMatch === null || numberMatch[0].trim().length !== text.length) {\n throw pragmaError(address, line, `${name} declares ${JSON.stringify(text)}; a define is true, false, or a number`);\n }\n return { name, value: Number(numberMatch[1]) };\n}\n\n/**\n * Reads a pipeline-state line, merging it into whatever earlier lines declared.\n *\n * @param draft - The declaration being built.\n * @param text - The whole directive text, starting at its first keyword.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readPipeline(draft: DeclarationDraft, text: string, address: string, line: number): void {\n const tokens = text.split(/\\s+/).filter((token) => token.length > 0);\n for (let index = 0; index < tokens.length; index += 1) {\n const keyword = tokens[index] ?? \"\";\n if (keyword === \"transmissive\") {\n draft.transmissive = true;\n continue;\n }\n index += 1;\n const value = tokens[index] ?? \"\";\n switch (keyword) {\n case \"blend\":\n draft.blend = readPipelineValue(SHADER_BLEND_MODES, draft.blend, keyword, value, address, line);\n break;\n case \"cull\": {\n const cull = readPipelineValue(SHADER_CULL_MODES, draft.cull, keyword, value, address, line);\n if (cull === \"front\") {\n throw pragmaError(\n address,\n line,\n \"Babylon Lite 1.27.0 has no front-face culling for a shader material; declare cull back or cull none and flip the winding\",\n );\n }\n draft.cull = cull;\n break;\n }\n case \"depthWrite\":\n draft.depthWrite = readToggle(draft.depthWrite, keyword, value, address, line);\n break;\n case \"depthTest\":\n draft.depthTest = readToggle(draft.depthTest, keyword, value, address, line);\n break;\n case \"instancing\":\n draft.instancing = readPipelineValue(SHADER_INSTANCING_MODES, draft.instancing, keyword, value, address, line);\n break;\n default:\n throw pragmaError(address, line, `${JSON.stringify(keyword)} is not a pipeline keyword`);\n }\n }\n}\n\n/**\n * Reads one pipeline keyword's value out of a fixed list, refusing a second declaration of it.\n *\n * @typeParam Value - The literal union the keyword accepts.\n * @param allowed - The accepted values.\n * @param current - What an earlier line declared, or `null`.\n * @param keyword - The keyword, for diagnostics.\n * @param value - The token that followed it.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The value.\n */\nfunction readPipelineValue<Value extends string>(\n allowed: readonly Value[],\n current: Value | null,\n keyword: string,\n value: string,\n address: string,\n line: number,\n): Value {\n if (current !== null) {\n throw pragmaError(address, line, `${keyword} is declared twice`);\n }\n const matched = matchLiteral(allowed, value);\n if (matched === null) {\n throw pragmaError(address, line, `${keyword} ${JSON.stringify(value)} is not one of ${allowed.join(\", \")}`);\n }\n return matched;\n}\n\n/**\n * Reads an `on`/`off` toggle, refusing a second declaration of it.\n *\n * @param current - What an earlier line declared, or `null`.\n * @param keyword - The keyword, for diagnostics.\n * @param value - The token that followed it.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns `true` for `on`, `false` for `off`.\n */\nfunction readToggle(current: boolean | null, keyword: string, value: string, address: string, line: number): boolean {\n if (current !== null) {\n throw pragmaError(address, line, `${keyword} is declared twice`);\n }\n if (value !== \"on\" && value !== \"off\") {\n throw pragmaError(address, line, `${keyword} ${JSON.stringify(value)} is not on or off`);\n }\n return value === \"on\";\n}\n\n/**\n * Fills in the defaults and checks the whole-file rules.\n *\n * @param draft - The declaration the parser built.\n * @param address - The asset address, for diagnostics.\n * @returns The finished declaration.\n */\nfunction finish(draft: DeclarationDraft, address: string): ShaderDeclaration {\n const kind = draft.kind;\n if (kind === null) {\n throw pragmaError(address, 1, \"the file declares no @ignifx shader, @ignifx surface, or @ignifx post directive\");\n }\n const declared = draft.attributes;\n if (declared !== null && kind === \"shader\" && !declared.includes(\"position\")) {\n throw pragmaError(address, 1, \"an @ignifx shader file must declare the position attribute\");\n }\n const attributes: readonly ShaderAttributeName[] = declared ?? (kind === \"shader\" ? [\"position\"] : []);\n const blend = draft.blend ?? \"opaque\";\n if (draft.transmissive && blend === \"opaque\") {\n throw pragmaError(\n address,\n 1,\n \"transmissive needs a blended surface; declare blend alpha, additive, or premultiplied\",\n );\n }\n return {\n kind,\n attributes,\n system: draft.system,\n ignifx: draft.ignifx,\n uniforms: draft.uniforms,\n textures: draft.textures,\n storage: draft.storage,\n defines: draft.defines,\n pipeline: {\n blend,\n cull: draft.cull ?? \"back\",\n // Babylon Lite defaults a blended material to depth-read-only and lets an explicit value win\n // (`lib/material/shader/shader-material.js`), which is the rule reproduced here so the\n // declaration itself carries the effective value.\n depthWrite: draft.depthWrite ?? blend === \"opaque\",\n depthTest: draft.depthTest ?? true,\n transmissive: draft.transmissive,\n instancing: draft.instancing ?? \"none\",\n },\n };\n}\n\n/**\n * Splits a comma-separated directive body, refusing an empty entry.\n *\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @param directive - The directive name, for diagnostics.\n * @returns The trimmed entries.\n */\nfunction splitList(rest: string, address: string, line: number, directive: string): readonly string[] {\n if (rest.length === 0) {\n throw pragmaError(address, line, `@ignifx ${directive} declares nothing`);\n }\n const parts = rest.split(\",\");\n const names: string[] = [];\n for (let index = 0; index < parts.length; index += 1) {\n const name = (parts[index] ?? \"\").trim();\n if (name.length === 0) {\n throw pragmaError(address, line, `@ignifx ${directive} has an empty entry`);\n }\n names.push(name);\n }\n return names;\n}\n\n/**\n * Reads a comma-separated list of numbers.\n *\n * @param text - The argument text, without the parentheses.\n * @param name - The declaration's name, for diagnostics.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The numbers.\n */\nfunction readNumbers(text: string, name: string, address: string, line: number): readonly number[] {\n const parts = text.split(\",\");\n const numbers: number[] = [];\n for (let index = 0; index < parts.length; index += 1) {\n const part = (parts[index] ?? \"\").trim();\n const value = Number(part);\n if (part.length === 0 || !Number.isFinite(value)) {\n throw pragmaError(address, line, `${name} declares ${JSON.stringify(part)}, which is not a number`);\n }\n numbers.push(value);\n }\n return numbers;\n}\n\n/**\n * Checks that a default value has as many numbers as its type needs.\n *\n * @param actual - How many numbers the file wrote.\n * @param expected - How many the type holds.\n * @param name - The uniform's name, for diagnostics.\n * @param type - The uniform's type, for diagnostics.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction assertArity(\n actual: number,\n expected: number,\n name: string,\n type: ShaderUniformType,\n address: string,\n line: number,\n): void {\n if (actual !== expected) {\n throw pragmaError(\n address,\n line,\n `${name} is a ${type}, which takes ${String(expected)} numbers, but its default has ${String(actual)}`,\n );\n }\n}\n\n/**\n * The value a uniform starts at when the file declares no default: zeros, or the identity matrix.\n *\n * @param type - The declared type.\n * @returns The default.\n */\nfunction implicitDefault(type: ShaderUniformType): number | readonly number[] {\n if (type === \"mat4x4<f32>\") {\n return IDENTITY_MATRIX;\n }\n const count = ELEMENT_COUNTS[type];\n if (count === 1) {\n return 0;\n }\n const zeros: number[] = [];\n for (let index = 0; index < count; index += 1) {\n zeros.push(0);\n }\n return zeros;\n}\n\n/**\n * Claims one WGSL binding name, refusing a duplicate.\n *\n * @remarks\n * Babylon Lite puts uniforms, samplers, `<name>Sampler` pairs, storage buffers, and defines in one\n * namespace (`assertUniqueName`, `lib/material/shader/shader-material.js`), so the parser checks it\n * here and reports the line instead of letting Lite throw without one.\n *\n * @param draft - The declaration being built.\n * @param name - The name being claimed.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @param what - What kind of binding is claiming it, for diagnostics.\n */\nfunction claimName(draft: DeclarationDraft, name: string, address: string, line: number, what: string): void {\n if (draft.names.has(name)) {\n throw pragmaError(address, line, `${name} is already declared; the ${what} name must be unique in the file`);\n }\n draft.names.add(name);\n}\n\n/**\n * Checks that a name is a WGSL identifier.\n *\n * @param name - The candidate.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @param what - What kind of binding it names, for diagnostics.\n */\nfunction assertIdentifier(name: string, address: string, line: number, what: string): void {\n if (!IDENTIFIER.test(name)) {\n throw pragmaError(address, line, `${JSON.stringify(name)} is not a WGSL identifier for a ${what}`);\n }\n}\n\n/**\n * Narrows a token to one of a fixed list of literals.\n *\n * @typeParam Value - The literal union.\n * @param allowed - The accepted values.\n * @param token - The candidate.\n * @returns The matching literal, or `null`.\n */\nfunction matchLiteral<Value extends string>(allowed: readonly Value[], token: string): Value | null {\n for (let index = 0; index < allowed.length; index += 1) {\n const candidate = allowed[index];\n if (candidate !== undefined && candidate === token) {\n return candidate;\n }\n }\n return null;\n}\n\n/**\n * Builds the `IGX-0719` failure a malformed pragma produces.\n *\n * @param address - The asset address.\n * @param line - The 1-based line number.\n * @param message - What is wrong.\n * @returns The error to throw.\n */\nfunction pragmaError(address: string, line: number, message: string): IgnifxError {\n return new IgnifxError(CoreErrorCode.invalidShaderPragma, `${address} line ${String(line)}: ${message}.`, {\n context: { asset: address, line, message },\n hint: \"The @ignifx pragma grammar is in skills/ignifx/references/formats/wgsl.md.\",\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8CA,MAAM,cAAc;;AAGpB,MAAM,aAAa;;AAGnB,MAAM,gBAAgB;;AAGtB,MAAM,mBAAmB;;AAGzB,MAAM,gBAAgB;;AAGtB,MAAM,gBAAgB;;AAGtB,MAAM,gBAAgB;;AAGtB,MAAM,iBAAiB;;AAGvB,MAAM,iBAA8D,OAAO,OAAO;CAChF,KAAK;CACL,KAAK;CACL,KAAK;CACL,aAAa;CACb,aAAa;CACb,aAAa;CACb,eAAe;AACjB,CAAC;;AAGD,MAAM,kBAAqC,OAAO,OAAO;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;AAAC,CAAC;;;;;;;;;;;;;;;;;;;;AAwCzG,SAAgB,uBAAuB,QAAgB,SAAoC;CACzF,MAAM,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