@ignifx/core 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{color-CpvebMIh.js → color-DrR6GFTd.js} +3 -276
- package/dist/color-DrR6GFTd.js.map +1 -0
- package/dist/{environment-CTM7BAyb.js → environment-mr5wp69e.js} +3 -2
- package/dist/{environment-CTM7BAyb.js.map → environment-mr5wp69e.js.map} +1 -1
- package/dist/index.d.ts +140 -88
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1353 -2797
- package/dist/index.js.map +1 -1
- package/dist/{instanced-mesh-instance-Cgx1H87p.js → instanced-mesh-instance-DYwH0vLi.js} +74 -10
- package/dist/instanced-mesh-instance-DYwH0vLi.js.map +1 -0
- package/dist/{material-plugin-Cfw_h_Mg.js → material-plugin-BRnhfw7K.js} +2 -2
- package/dist/material-plugin-BRnhfw7K.js.map +1 -0
- package/dist/math-utils-BcDnL-gi.js +277 -0
- package/dist/math-utils-BcDnL-gi.js.map +1 -0
- package/dist/shader-declaration-5q__jycG.js.map +1 -1
- package/dist/{shader-material-CJxMJEUO.js → shader-material-BIG3UDyu.js} +3 -3
- package/dist/{shader-material-CJxMJEUO.js.map → shader-material-BIG3UDyu.js.map} +1 -1
- package/dist/{shader-material-F-CL4D70.js → shader-material-U6BKZ8D1.js} +2 -2
- package/dist/{shader-material-F-CL4D70.js.map → shader-material-U6BKZ8D1.js.map} +1 -1
- package/dist/{shader-pragma-D4HKC9vP.js → shader-pragma-tw6AKaQD.js} +24 -3
- package/dist/shader-pragma-tw6AKaQD.js.map +1 -0
- package/dist/{surface-shader-Chs7wOAE.js → surface-shader-Br17yysO.js} +7 -5
- package/dist/{surface-shader-Chs7wOAE.js.map → surface-shader-Br17yysO.js.map} +1 -1
- package/dist/vec3-T2PasQZv.js +2458 -0
- package/dist/vec3-T2PasQZv.js.map +1 -0
- package/package.json +2 -2
- package/dist/color-CpvebMIh.js.map +0 -1
- package/dist/instanced-mesh-instance-Cgx1H87p.js.map +0 -1
- package/dist/material-plugin-Cfw_h_Mg.js.map +0 -1
- package/dist/mesh-CnK_PX46.js +0 -811
- package/dist/mesh-CnK_PX46.js.map +0 -1
- package/dist/shader-pragma-D4HKC9vP.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec3-T2PasQZv.js","names":["updateMeshPositions","updateMeshNormals","updateMeshUvs","updateMeshColors"],"sources":["../src/math/mat4.ts","../src/lite/node.ts","../src/lite/gpu/mesh.ts","../src/math/vec3.ts"],"sourcesContent":["import { degToRad, EPSILON } from \"./math-utils.js\";\nimport type { Mat4Like, MutableQuat, MutableVec3, QuatLike, Vec3Like } from \"./types.js\";\n\n/**\n * The backing store of a {@link Mat4}: a `Float32Array` of exactly 16 elements, in column-major\n * order (`m[column * 4 + row]`). The `length: 16` refinement is what makes it a {@link Mat4Like},\n * and therefore what makes it accepted anywhere Babylon Lite wants a `Mat4`.\n *\n * @public\n */\nexport type Mat4Elements = Float32Array & { readonly length: 16 };\n\n/**\n * Allocates the 16-element column-major storage a matrix owns, pre-filled with zeroes.\n *\n * @returns Fresh, zeroed storage.\n */\nfunction allocateElements(): Mat4Elements {\n // The invariant is that this array is exactly 16\n // elements long, which `Float32Array`'s `length: number` cannot express. Babylon Lite brands its\n // own allocation the same way (`lib/math/_matrix-allocator.js`).\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return new Float32Array(16) as Mat4Elements;\n}\n\n/**\n * The determinant of the upper-left 3×3 basis. Its sign says whether the matrix mirrors, which is\n * how Babylon Lite decides the sign of the decomposed Y scale (`lib/math/mat4-decompose.js`).\n *\n * @param m - The matrix to measure.\n * @returns The 3×3 determinant.\n */\nfunction basisDeterminant(m: Mat4Like): number {\n const m0 = m[0] ?? 0;\n const m1 = m[1] ?? 0;\n const m2 = m[2] ?? 0;\n const m4 = m[4] ?? 0;\n const m5 = m[5] ?? 0;\n const m6 = m[6] ?? 0;\n const m8 = m[8] ?? 0;\n const m9 = m[9] ?? 0;\n const m10 = m[10] ?? 0;\n return m0 * (m5 * m10 - m6 * m9) + m1 * (m6 * m8 - m4 * m10) + m2 * (m4 * m9 - m5 * m8);\n}\n\n/**\n * Writes the unit quaternion of an orthonormal basis into `out`. Arguments are named row-major\n * (`b<row><column>`), matching Babylon Lite's `_quatFromRotationBasis`\n * (`lib/math/quat-from-rotation-matrix.js`), which this reproduces branch for branch.\n *\n * Shared with the quaternion module; not part of the public API.\n *\n * @param b00 - Row 0, column 0.\n * @param b01 - Row 0, column 1.\n * @param b02 - Row 0, column 2.\n * @param b10 - Row 1, column 0.\n * @param b11 - Row 1, column 1.\n * @param b12 - Row 1, column 2.\n * @param b20 - Row 2, column 0.\n * @param b21 - Row 2, column 1.\n * @param b22 - Row 2, column 2.\n * @param out - The quaternion to write.\n *\n * @internal\n */\nexport function basisToQuatToRef(\n b00: number,\n b01: number,\n b02: number,\n b10: number,\n b11: number,\n b12: number,\n b20: number,\n b21: number,\n b22: number,\n out: MutableQuat,\n): void {\n const trace = b00 + b11 + b22;\n if (trace > 0) {\n const s = 0.5 / Math.sqrt(trace + 1);\n out.set((b21 - b12) * s, (b02 - b20) * s, (b10 - b01) * s, 0.25 / s);\n return;\n }\n if (b00 > b11 && b00 > b22) {\n const s = 2 * Math.sqrt(1 + b00 - b11 - b22);\n out.set(0.25 * s, (b01 + b10) / s, (b02 + b20) / s, (b21 - b12) / s);\n return;\n }\n if (b11 > b22) {\n const s = 2 * Math.sqrt(1 + b11 - b00 - b22);\n out.set((b01 + b10) / s, 0.25 * s, (b12 + b21) / s, (b02 - b20) / s);\n return;\n }\n const s = 2 * Math.sqrt(1 + b22 - b00 - b11);\n out.set((b02 + b20) / s, (b12 + b21) / s, 0.25 * s, (b10 - b01) / s);\n}\n\n/**\n * A 4×4 transformation matrix stored column-major in a `Float32Array`, byte-compatible with WGSL's\n * `mat4x4<f32>` and with Babylon Lite's `Mat4` (translation in slots 12/13/14).\n *\n * ignifx is left-handed, Y up, +Z forward (ADR-0011), so the projection helpers are the `LH`\n * family and they use Lite's **reverse depth** convention: the near plane maps to 1 and the far\n * plane to 0.\n *\n * Instance methods mutate the matrix and return `this`; `ToRef` statics write into their `out`\n * matrix and allocate nothing, and are safe when `out` aliases an input. The remaining statics\n * allocate a fresh matrix and say so.\n *\n * @example\n * ```ts\n * const world = new Mat4();\n * Mat4.composeToRef(position, rotation, scale, world);\n *\n * const inverse = new Mat4();\n * if (Mat4.invertToRef(world, inverse)) {\n * Mat4.transformPointToRef(inverse, worldPoint, localPoint);\n * }\n * ```\n *\n * @public\n */\nexport class Mat4 {\n /**\n * The 16 elements, column-major (`elements[column * 4 + row]`). This is the object to hand to\n * anything that wants a {@link Mat4Like} — including Babylon Lite — and the buffer to upload to\n * the GPU. It is never reallocated, so a reference to it stays valid for the matrix's lifetime.\n */\n readonly elements: Mat4Elements;\n\n /**\n * Creates an identity matrix.\n */\n constructor() {\n const e = allocateElements();\n e[0] = 1;\n e[5] = 1;\n e[10] = 1;\n e[15] = 1;\n this.elements = e;\n }\n\n /**\n * Resets this matrix to the identity.\n *\n * @returns This matrix.\n */\n identity(): this {\n const e = this.elements;\n e[0] = 1;\n e[1] = 0;\n e[2] = 0;\n e[3] = 0;\n e[4] = 0;\n e[5] = 1;\n e[6] = 0;\n e[7] = 0;\n e[8] = 0;\n e[9] = 0;\n e[10] = 1;\n e[11] = 0;\n e[12] = 0;\n e[13] = 0;\n e[14] = 0;\n e[15] = 1;\n return this;\n }\n\n /**\n * Copies every element from another matrix.\n *\n * @param m - The matrix to read.\n * @returns This matrix.\n */\n copyFrom(m: Mat4Like): this {\n const e = this.elements;\n for (let i = 0; i < 16; i++) {\n e[i] = m[i] ?? 0;\n }\n return this;\n }\n\n /**\n * Copies this matrix into a new one.\n *\n * @returns A new matrix. **Allocates.**\n */\n clone(): Mat4 {\n return new Mat4().copyFrom(this.elements);\n }\n\n /**\n * Post-multiplies this matrix by another (`this = this * m`), so `m`'s transform is applied first\n * when the product acts on a column vector.\n *\n * @param m - The right-hand matrix.\n * @returns This matrix.\n */\n multiply(m: Mat4Like): this {\n Mat4.multiplyToRef(this.elements, m, this);\n return this;\n }\n\n /**\n * Inverts this matrix in place.\n *\n * @returns `true` on success. When the matrix is singular this returns `false` and leaves the\n * matrix untouched.\n */\n invert(): boolean {\n return Mat4.invertToRef(this.elements, this);\n }\n\n /**\n * Transposes this matrix in place, swapping rows and columns.\n *\n * @returns This matrix.\n */\n transpose(): this {\n Mat4.transposeToRef(this.elements, this);\n return this;\n }\n\n /**\n * The full 4×4 determinant of this matrix.\n *\n * @returns The determinant; zero means the matrix cannot be inverted.\n */\n determinant(): number {\n return Mat4.determinant(this.elements);\n }\n\n /**\n * Compares this matrix with another element by element, with a tolerance.\n *\n * @param m - The matrix to compare against.\n * @param epsilon - The largest per-element difference still considered equal.\n * @returns `true` when every element matches within `epsilon`.\n */\n equalsWithEpsilon(m: Mat4Like, epsilon: number = EPSILON): boolean {\n return Mat4.equalsWithEpsilon(this.elements, m, epsilon);\n }\n\n /**\n * Creates an identity matrix.\n *\n * @returns A new identity matrix. **Allocates.**\n */\n static identity(): Mat4 {\n return new Mat4();\n }\n\n /**\n * Creates a matrix holding a copy of another matrix's elements.\n *\n * @param m - The matrix to copy.\n * @returns A new matrix. **Allocates.**\n */\n static from(m: Mat4Like): Mat4 {\n return new Mat4().copyFrom(m);\n }\n\n /**\n * Builds a translation-rotation-scale matrix, the same composition order Babylon Lite's\n * `mat4Compose` uses (`translation * rotation * scale`).\n *\n * @param position - The translation, in metres.\n * @param rotation - The rotation; assumed to be a unit quaternion.\n * @param scale - The per-axis scale.\n * @returns A new matrix. **Allocates.**\n */\n static compose(position: Vec3Like, rotation: QuatLike, scale: Vec3Like): Mat4 {\n return Mat4.composeToRef(position, rotation, scale, new Mat4());\n }\n\n /**\n * Writes a translation-rotation-scale matrix into `out`.\n *\n * @param position - The translation, in metres.\n * @param rotation - The rotation; assumed to be a unit quaternion.\n * @param scale - The per-axis scale.\n * @param out - The matrix to write.\n * @returns `out`.\n *\n * @example\n * ```ts\n * Mat4.composeToRef(transform.localPosition, transform.localRotation, transform.localScale, local);\n * ```\n */\n static composeToRef(position: Vec3Like, rotation: QuatLike, scale: Vec3Like, out: Mat4): Mat4 {\n const qx = rotation.x;\n const qy = rotation.y;\n const qz = rotation.z;\n const qw = rotation.w;\n const sx = scale.x;\n const sy = scale.y;\n const sz = scale.z;\n const xx = qx * qx;\n const yy = qy * qy;\n const zz = qz * qz;\n const xy = qx * qy;\n const xz = qx * qz;\n const yz = qy * qz;\n const wx = qw * qx;\n const wy = qw * qy;\n const wz = qw * qz;\n const e = out.elements;\n e[0] = (1 - 2 * (yy + zz)) * sx;\n e[1] = 2 * (xy + wz) * sx;\n e[2] = 2 * (xz - wy) * sx;\n e[3] = 0;\n e[4] = 2 * (xy - wz) * sy;\n e[5] = (1 - 2 * (xx + zz)) * sy;\n e[6] = 2 * (yz + wx) * sy;\n e[7] = 0;\n e[8] = 2 * (xz + wy) * sz;\n e[9] = 2 * (yz - wx) * sz;\n e[10] = (1 - 2 * (xx + yy)) * sz;\n e[11] = 0;\n e[12] = position.x;\n e[13] = position.y;\n e[14] = position.z;\n e[15] = 1;\n return out;\n }\n\n /**\n * Splits an affine transformation-rotation-scale matrix back into its parts, using Babylon Lite's\n * convention (`lib/math/mat4-decompose.js`): scales are the lengths of the basis columns, and a\n * mirrored matrix (negative basis determinant) reports a **negative Y scale** rather than\n * silently dropping the reflection. Shear is not detected.\n *\n * @param m - The matrix to split.\n * @param outPosition - Receives the translation.\n * @param outRotation - Receives the rotation as a unit quaternion.\n * @param outScale - Receives the per-axis scale.\n * @returns `true` on success; `false` when a basis column has (near) zero length, in which case\n * the outputs are left untouched.\n *\n * @example\n * ```ts\n * Mat4.decomposeToRef(node.worldMatrix, position, rotation, scale);\n * ```\n */\n static decomposeToRef(\n m: Mat4Like,\n outPosition: MutableVec3,\n outRotation: MutableQuat,\n outScale: MutableVec3,\n ): boolean {\n const m0 = m[0] ?? 0;\n const m1 = m[1] ?? 0;\n const m2 = m[2] ?? 0;\n const m4 = m[4] ?? 0;\n const m5 = m[5] ?? 0;\n const m6 = m[6] ?? 0;\n const m8 = m[8] ?? 0;\n const m9 = m[9] ?? 0;\n const m10 = m[10] ?? 0;\n const sx = Math.hypot(m0, m1, m2);\n const syAbs = Math.hypot(m4, m5, m6);\n const sz = Math.hypot(m8, m9, m10);\n if (sx <= 1e-8 || syAbs <= 1e-8 || sz <= 1e-8) {\n return false;\n }\n const sy = basisDeterminant(m) < 0 ? -syAbs : syAbs;\n const invSx = 1 / sx;\n const invSy = 1 / sy;\n const invSz = 1 / sz;\n // Read the translation before writing anything, so `outPosition` may alias nothing dangerous.\n const tx = m[12] ?? 0;\n const ty = m[13] ?? 0;\n const tz = m[14] ?? 0;\n basisToQuatToRef(\n m0 * invSx,\n m4 * invSy,\n m8 * invSz,\n m1 * invSx,\n m5 * invSy,\n m9 * invSz,\n m2 * invSx,\n m6 * invSy,\n m10 * invSz,\n outRotation,\n );\n const qx = outRotation.x;\n const qy = outRotation.y;\n const qz = outRotation.z;\n const qw = outRotation.w;\n const invLength = 1 / Math.hypot(qx, qy, qz, qw);\n outRotation.set(qx * invLength, qy * invLength, qz * invLength, qw * invLength);\n outPosition.set(tx, ty, tz);\n outScale.set(sx, sy, sz);\n return true;\n }\n\n /**\n * Multiplies two matrices.\n *\n * @param a - The left-hand matrix.\n * @param b - The right-hand matrix.\n * @returns A new matrix holding `a * b`. **Allocates.**\n */\n static multiply(a: Mat4Like, b: Mat4Like): Mat4 {\n return Mat4.multiplyToRef(a, b, new Mat4());\n }\n\n /**\n * Writes `a * b` into `out`. Acting on a column vector, `b` is applied first.\n *\n * @param a - The left-hand matrix.\n * @param b - The right-hand matrix.\n * @param out - The matrix to write; may alias `a` or `b`.\n * @returns `out`.\n */\n static multiplyToRef(a: Mat4Like, b: Mat4Like, out: Mat4): Mat4 {\n const a0 = a[0] ?? 0;\n const a1 = a[1] ?? 0;\n const a2 = a[2] ?? 0;\n const a3 = a[3] ?? 0;\n const a4 = a[4] ?? 0;\n const a5 = a[5] ?? 0;\n const a6 = a[6] ?? 0;\n const a7 = a[7] ?? 0;\n const a8 = a[8] ?? 0;\n const a9 = a[9] ?? 0;\n const a10 = a[10] ?? 0;\n const a11 = a[11] ?? 0;\n const a12 = a[12] ?? 0;\n const a13 = a[13] ?? 0;\n const a14 = a[14] ?? 0;\n const a15 = a[15] ?? 0;\n const b0 = b[0] ?? 0;\n const b1 = b[1] ?? 0;\n const b2 = b[2] ?? 0;\n const b3 = b[3] ?? 0;\n const b4 = b[4] ?? 0;\n const b5 = b[5] ?? 0;\n const b6 = b[6] ?? 0;\n const b7 = b[7] ?? 0;\n const b8 = b[8] ?? 0;\n const b9 = b[9] ?? 0;\n const b10 = b[10] ?? 0;\n const b11 = b[11] ?? 0;\n const b12 = b[12] ?? 0;\n const b13 = b[13] ?? 0;\n const b14 = b[14] ?? 0;\n const b15 = b[15] ?? 0;\n const e = out.elements;\n e[0] = a0 * b0 + a4 * b1 + a8 * b2 + a12 * b3;\n e[1] = a1 * b0 + a5 * b1 + a9 * b2 + a13 * b3;\n e[2] = a2 * b0 + a6 * b1 + a10 * b2 + a14 * b3;\n e[3] = a3 * b0 + a7 * b1 + a11 * b2 + a15 * b3;\n e[4] = a0 * b4 + a4 * b5 + a8 * b6 + a12 * b7;\n e[5] = a1 * b4 + a5 * b5 + a9 * b6 + a13 * b7;\n e[6] = a2 * b4 + a6 * b5 + a10 * b6 + a14 * b7;\n e[7] = a3 * b4 + a7 * b5 + a11 * b6 + a15 * b7;\n e[8] = a0 * b8 + a4 * b9 + a8 * b10 + a12 * b11;\n e[9] = a1 * b8 + a5 * b9 + a9 * b10 + a13 * b11;\n e[10] = a2 * b8 + a6 * b9 + a10 * b10 + a14 * b11;\n e[11] = a3 * b8 + a7 * b9 + a11 * b10 + a15 * b11;\n e[12] = a0 * b12 + a4 * b13 + a8 * b14 + a12 * b15;\n e[13] = a1 * b12 + a5 * b13 + a9 * b14 + a13 * b15;\n e[14] = a2 * b12 + a6 * b13 + a10 * b14 + a14 * b15;\n e[15] = a3 * b12 + a7 * b13 + a11 * b14 + a15 * b15;\n return out;\n }\n\n /**\n * Writes the inverse of `m` into `out`.\n *\n * @param m - The matrix to invert.\n * @param out - The matrix to write; may alias `m`. Left untouched when the inverse does not exist.\n * @returns `true` on success, `false` when `m` is singular. Returning a status rather than `null`\n * keeps the call allocation-free (coding standards §7).\n *\n * @example\n * ```ts\n * if (!Mat4.invertToRef(world, worldToLocal)) {\n * // degenerate scale — skip this entity\n * }\n * ```\n */\n static invertToRef(m: Mat4Like, out: Mat4): boolean {\n const a00 = m[0] ?? 0;\n const a01 = m[1] ?? 0;\n const a02 = m[2] ?? 0;\n const a03 = m[3] ?? 0;\n const a10 = m[4] ?? 0;\n const a11 = m[5] ?? 0;\n const a12 = m[6] ?? 0;\n const a13 = m[7] ?? 0;\n const a20 = m[8] ?? 0;\n const a21 = m[9] ?? 0;\n const a22 = m[10] ?? 0;\n const a23 = m[11] ?? 0;\n const a30 = m[12] ?? 0;\n const a31 = m[13] ?? 0;\n const a32 = m[14] ?? 0;\n const a33 = m[15] ?? 0;\n const b00 = a00 * a11 - a01 * a10;\n const b01 = a00 * a12 - a02 * a10;\n const b02 = a00 * a13 - a03 * a10;\n const b03 = a01 * a12 - a02 * a11;\n const b04 = a01 * a13 - a03 * a11;\n const b05 = a02 * a13 - a03 * a12;\n const b06 = a20 * a31 - a21 * a30;\n const b07 = a20 * a32 - a22 * a30;\n const b08 = a20 * a33 - a23 * a30;\n const b09 = a21 * a32 - a22 * a31;\n const b10 = a21 * a33 - a23 * a31;\n const b11 = a22 * a33 - a23 * a32;\n const determinant = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n // Lite rejects at the same threshold (`lib/math/mat4-invert.js`), so both agree on which\n // matrices are singular.\n if (Math.abs(determinant) < 1e-10) {\n return false;\n }\n const inv = 1 / determinant;\n const e = out.elements;\n e[0] = (a11 * b11 - a12 * b10 + a13 * b09) * inv;\n e[1] = (a02 * b10 - a01 * b11 - a03 * b09) * inv;\n e[2] = (a31 * b05 - a32 * b04 + a33 * b03) * inv;\n e[3] = (a22 * b04 - a21 * b05 - a23 * b03) * inv;\n e[4] = (a12 * b08 - a10 * b11 - a13 * b07) * inv;\n e[5] = (a00 * b11 - a02 * b08 + a03 * b07) * inv;\n e[6] = (a32 * b02 - a30 * b05 - a33 * b01) * inv;\n e[7] = (a20 * b05 - a22 * b02 + a23 * b01) * inv;\n e[8] = (a10 * b10 - a11 * b08 + a13 * b06) * inv;\n e[9] = (a01 * b08 - a00 * b10 - a03 * b06) * inv;\n e[10] = (a30 * b04 - a31 * b02 + a33 * b00) * inv;\n e[11] = (a21 * b02 - a20 * b04 - a23 * b00) * inv;\n e[12] = (a11 * b07 - a10 * b09 - a12 * b06) * inv;\n e[13] = (a00 * b09 - a01 * b07 + a02 * b06) * inv;\n e[14] = (a31 * b01 - a30 * b03 - a32 * b00) * inv;\n e[15] = (a20 * b03 - a21 * b01 + a22 * b00) * inv;\n return true;\n }\n\n /**\n * Writes the transpose of `m` into `out`.\n *\n * @param m - The matrix to transpose.\n * @param out - The matrix to write; may alias `m`.\n * @returns `out`.\n */\n static transposeToRef(m: Mat4Like, out: Mat4): Mat4 {\n const m0 = m[0] ?? 0;\n const m1 = m[1] ?? 0;\n const m2 = m[2] ?? 0;\n const m3 = m[3] ?? 0;\n const m4 = m[4] ?? 0;\n const m5 = m[5] ?? 0;\n const m6 = m[6] ?? 0;\n const m7 = m[7] ?? 0;\n const m8 = m[8] ?? 0;\n const m9 = m[9] ?? 0;\n const m10 = m[10] ?? 0;\n const m11 = m[11] ?? 0;\n const m12 = m[12] ?? 0;\n const m13 = m[13] ?? 0;\n const m14 = m[14] ?? 0;\n const m15 = m[15] ?? 0;\n const e = out.elements;\n e[0] = m0;\n e[1] = m4;\n e[2] = m8;\n e[3] = m12;\n e[4] = m1;\n e[5] = m5;\n e[6] = m9;\n e[7] = m13;\n e[8] = m2;\n e[9] = m6;\n e[10] = m10;\n e[11] = m14;\n e[12] = m3;\n e[13] = m7;\n e[14] = m11;\n e[15] = m15;\n return out;\n }\n\n /**\n * The full 4×4 determinant.\n *\n * @param m - The matrix to measure.\n * @returns The determinant; zero means the matrix cannot be inverted.\n */\n static determinant(m: Mat4Like): number {\n const a00 = m[0] ?? 0;\n const a01 = m[1] ?? 0;\n const a02 = m[2] ?? 0;\n const a03 = m[3] ?? 0;\n const a10 = m[4] ?? 0;\n const a11 = m[5] ?? 0;\n const a12 = m[6] ?? 0;\n const a13 = m[7] ?? 0;\n const a20 = m[8] ?? 0;\n const a21 = m[9] ?? 0;\n const a22 = m[10] ?? 0;\n const a23 = m[11] ?? 0;\n const a30 = m[12] ?? 0;\n const a31 = m[13] ?? 0;\n const a32 = m[14] ?? 0;\n const a33 = m[15] ?? 0;\n const b00 = a00 * a11 - a01 * a10;\n const b01 = a00 * a12 - a02 * a10;\n const b02 = a00 * a13 - a03 * a10;\n const b03 = a01 * a12 - a02 * a11;\n const b04 = a01 * a13 - a03 * a11;\n const b05 = a02 * a13 - a03 * a12;\n const b06 = a20 * a31 - a21 * a30;\n const b07 = a20 * a32 - a22 * a30;\n const b08 = a20 * a33 - a23 * a30;\n const b09 = a21 * a32 - a22 * a31;\n const b10 = a21 * a33 - a23 * a31;\n const b11 = a22 * a33 - a23 * a32;\n return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n }\n\n /**\n * Builds a pure translation matrix.\n *\n * @param x - Translation along X, in metres.\n * @param y - Translation along Y, in metres.\n * @param z - Translation along Z, in metres.\n * @returns A new matrix. **Allocates.**\n */\n static translation(x: number, y: number, z: number): Mat4 {\n return Mat4.translationToRef(x, y, z, new Mat4());\n }\n\n /**\n * Writes a pure translation matrix into `out`.\n *\n * @param x - Translation along X, in metres.\n * @param y - Translation along Y, in metres.\n * @param z - Translation along Z, in metres.\n * @param out - The matrix to write.\n * @returns `out`.\n */\n static translationToRef(x: number, y: number, z: number, out: Mat4): Mat4 {\n const e = out.identity().elements;\n e[12] = x;\n e[13] = y;\n e[14] = z;\n return out;\n }\n\n /**\n * Builds a pure scaling matrix.\n *\n * @param x - Scale along X.\n * @param y - Scale along Y.\n * @param z - Scale along Z.\n * @returns A new matrix. **Allocates.**\n */\n static scaling(x: number, y: number, z: number): Mat4 {\n return Mat4.scalingToRef(x, y, z, new Mat4());\n }\n\n /**\n * Writes a pure scaling matrix into `out`.\n *\n * @param x - Scale along X.\n * @param y - Scale along Y.\n * @param z - Scale along Z.\n * @param out - The matrix to write.\n * @returns `out`.\n */\n static scalingToRef(x: number, y: number, z: number, out: Mat4): Mat4 {\n const e = out.identity().elements;\n e[0] = x;\n e[5] = y;\n e[10] = z;\n return out;\n }\n\n /**\n * Builds a pure rotation matrix from a quaternion.\n *\n * @param q - The rotation; assumed to be a unit quaternion.\n * @returns A new matrix. **Allocates.**\n */\n static fromQuat(q: QuatLike): Mat4 {\n return Mat4.fromQuatToRef(q, new Mat4());\n }\n\n /**\n * Writes a pure rotation matrix into `out`.\n *\n * @param q - The rotation; assumed to be a unit quaternion.\n * @param out - The matrix to write.\n * @returns `out`.\n */\n static fromQuatToRef(q: QuatLike, out: Mat4): Mat4 {\n return Mat4.composeToRef(ZERO_TRANSLATION, q, UNIT_SCALE, out);\n }\n\n /**\n * Builds a left-handed view matrix that places the camera at `eye` looking at `target`.\n *\n * @param eye - The camera position, in metres.\n * @param target - The point to look at, in metres.\n * @param up - The camera's up direction.\n * @returns A new matrix. **Allocates.**\n */\n static lookAtLH(eye: Vec3Like, target: Vec3Like, up: Vec3Like): Mat4 {\n return Mat4.lookAtLHToRef(eye, target, up, new Mat4());\n }\n\n /**\n * Writes a left-handed view matrix into `out`. Reproduces Babylon Lite's `mat4LookAtLHToRef`,\n * including its degenerate-input behaviour: when `eye` and `target` coincide, or when `up` is\n * parallel to the view direction, `out` becomes the identity.\n *\n * @param eye - The camera position, in metres.\n * @param target - The point to look at, in metres.\n * @param up - The camera's up direction.\n * @param out - The matrix to write.\n * @returns `out`.\n */\n static lookAtLHToRef(eye: Vec3Like, target: Vec3Like, up: Vec3Like, out: Mat4): Mat4 {\n const ex = eye.x;\n const ey = eye.y;\n const ez = eye.z;\n let zx = target.x - ex;\n let zy = target.y - ey;\n let zz = target.z - ez;\n const zLength = Math.hypot(zx, zy, zz);\n if (zLength < 1e-10) {\n return out.identity();\n }\n const invZ = 1 / zLength;\n zx *= invZ;\n zy *= invZ;\n zz *= invZ;\n let xx = up.y * zz - up.z * zy;\n let xy = up.z * zx - up.x * zz;\n let xz = up.x * zy - up.y * zx;\n const xLength = Math.hypot(xx, xy, xz);\n if (xLength < 1e-10) {\n return out.identity();\n }\n const invX = 1 / xLength;\n xx *= invX;\n xy *= invX;\n xz *= invX;\n const yx = zy * xz - zz * xy;\n const yy = zz * xx - zx * xz;\n const yz = zx * xy - zy * xx;\n const e = out.elements;\n e[0] = xx;\n e[1] = yx;\n e[2] = zx;\n e[3] = 0;\n e[4] = xy;\n e[5] = yy;\n e[6] = zy;\n e[7] = 0;\n e[8] = xz;\n e[9] = yz;\n e[10] = zz;\n e[11] = 0;\n e[12] = -(xx * ex + xy * ey + xz * ez);\n e[13] = -(yx * ex + yy * ey + yz * ez);\n e[14] = -(zx * ex + zy * ey + zz * ez);\n e[15] = 1;\n return out;\n }\n\n /**\n * Builds a left-handed perspective projection.\n *\n * @param fovDegrees - The vertical field of view, in degrees.\n * @param aspect - The viewport's width divided by its height.\n * @param near - The near plane distance, in metres.\n * @param far - The far plane distance, in metres.\n * @returns A new matrix. **Allocates.**\n */\n static perspectiveLH(fovDegrees: number, aspect: number, near: number, far: number): Mat4 {\n return Mat4.perspectiveLHToRef(fovDegrees, aspect, near, far, new Mat4());\n }\n\n /**\n * Writes a left-handed perspective projection into `out`, matching Babylon Lite's\n * `mat4PerspectiveLHToRef` — which is a **reverse-depth** projection: the near plane maps to\n * clip-space depth 1 and the far plane to 0, the arrangement that keeps float depth precise.\n *\n * @param fovDegrees - The vertical field of view, in degrees.\n * @param aspect - The viewport's width divided by its height.\n * @param near - The near plane distance, in metres.\n * @param far - The far plane distance, in metres.\n * @param out - The matrix to write.\n * @returns `out`.\n */\n static perspectiveLHToRef(fovDegrees: number, aspect: number, near: number, far: number, out: Mat4): Mat4 {\n const cot = 1 / Math.tan(degToRad(fovDegrees) * 0.5);\n const range = far - near;\n const e = out.elements;\n e[0] = cot / aspect;\n e[1] = 0;\n e[2] = 0;\n e[3] = 0;\n e[4] = 0;\n e[5] = cot;\n e[6] = 0;\n e[7] = 0;\n e[8] = 0;\n e[9] = 0;\n e[10] = -near / range;\n e[11] = 1;\n e[12] = 0;\n e[13] = 0;\n e[14] = (far * near) / range;\n e[15] = 0;\n return out;\n }\n\n /**\n * Builds a centred left-handed orthographic projection.\n *\n * @param width - The view width, in metres.\n * @param height - The view height, in metres.\n * @param near - The near plane distance, in metres.\n * @param far - The far plane distance, in metres.\n * @returns A new matrix. **Allocates.**\n */\n static orthoLH(width: number, height: number, near: number, far: number): Mat4 {\n return Mat4.orthoLHToRef(width, height, near, far, new Mat4());\n }\n\n /**\n * Writes a centred left-handed orthographic projection into `out`, with the same reverse-depth\n * convention as {@link Mat4.perspectiveLHToRef}.\n *\n * @param width - The view width, in metres.\n * @param height - The view height, in metres.\n * @param near - The near plane distance, in metres.\n * @param far - The far plane distance, in metres.\n * @param out - The matrix to write.\n * @returns `out`.\n */\n static orthoLHToRef(width: number, height: number, near: number, far: number, out: Mat4): Mat4 {\n const halfWidth = width * 0.5;\n const halfHeight = height * 0.5;\n return Mat4.orthoOffCenterLHToRef(-halfWidth, halfWidth, -halfHeight, halfHeight, near, far, out);\n }\n\n /**\n * Writes an off-centre left-handed orthographic projection into `out`, reproducing Babylon Lite's\n * `mat4OrthoOffCenterLHToRef` (reverse depth).\n *\n * @param left - The left clip plane, in metres.\n * @param right - The right clip plane, in metres.\n * @param bottom - The bottom clip plane, in metres.\n * @param top - The top clip plane, in metres.\n * @param near - The near plane distance, in metres.\n * @param far - The far plane distance, in metres.\n * @param out - The matrix to write.\n * @returns `out`.\n */\n static orthoOffCenterLHToRef(\n left: number,\n right: number,\n bottom: number,\n top: number,\n near: number,\n far: number,\n out: Mat4,\n ): Mat4 {\n const range = far - near;\n const e = out.elements;\n e[0] = 2 / (right - left);\n e[1] = 0;\n e[2] = 0;\n e[3] = 0;\n e[4] = 0;\n e[5] = 2 / (top - bottom);\n e[6] = 0;\n e[7] = 0;\n e[8] = 0;\n e[9] = 0;\n e[10] = -1 / range;\n e[11] = 0;\n e[12] = (left + right) / (left - right);\n e[13] = (top + bottom) / (bottom - top);\n e[14] = far / range;\n e[15] = 1;\n return out;\n }\n\n /**\n * Reads a matrix's translation.\n *\n * @param m - The matrix to read.\n * @param out - The vector to write.\n * @returns `out`.\n */\n static getTranslationToRef<TOut extends MutableVec3>(m: Mat4Like, out: TOut): TOut {\n out.set(m[12] ?? 0, m[13] ?? 0, m[14] ?? 0);\n return out;\n }\n\n /**\n * Reads a matrix's per-axis scale as the lengths of its basis columns, negating Y for a mirrored\n * matrix exactly as {@link Mat4.decomposeToRef} does.\n *\n * @param m - The matrix to read.\n * @param out - The vector to write.\n * @returns `out`.\n */\n static getScaleToRef<TOut extends MutableVec3>(m: Mat4Like, out: TOut): TOut {\n const sx = Math.hypot(m[0] ?? 0, m[1] ?? 0, m[2] ?? 0);\n const syAbs = Math.hypot(m[4] ?? 0, m[5] ?? 0, m[6] ?? 0);\n const sz = Math.hypot(m[8] ?? 0, m[9] ?? 0, m[10] ?? 0);\n out.set(sx, basisDeterminant(m) < 0 ? -syAbs : syAbs, sz);\n return out;\n }\n\n /**\n * Reads a matrix's rotation, dividing the scale out of the basis first.\n *\n * @param m - The matrix to read.\n * @param out - The quaternion to write. Left untouched when a basis column has zero length.\n * @returns `out`.\n */\n static getRotationToRef<TOut extends MutableQuat>(m: Mat4Like, out: TOut): TOut {\n const m0 = m[0] ?? 0;\n const m1 = m[1] ?? 0;\n const m2 = m[2] ?? 0;\n const m4 = m[4] ?? 0;\n const m5 = m[5] ?? 0;\n const m6 = m[6] ?? 0;\n const m8 = m[8] ?? 0;\n const m9 = m[9] ?? 0;\n const m10 = m[10] ?? 0;\n const sx = Math.hypot(m0, m1, m2);\n const syAbs = Math.hypot(m4, m5, m6);\n const sz = Math.hypot(m8, m9, m10);\n if (sx <= 1e-8 || syAbs <= 1e-8 || sz <= 1e-8) {\n return out;\n }\n const invSx = 1 / sx;\n const invSy = 1 / (basisDeterminant(m) < 0 ? -syAbs : syAbs);\n const invSz = 1 / sz;\n basisToQuatToRef(\n m0 * invSx,\n m4 * invSy,\n m8 * invSz,\n m1 * invSx,\n m5 * invSy,\n m9 * invSz,\n m2 * invSx,\n m6 * invSy,\n m10 * invSz,\n out,\n );\n const invLength = 1 / Math.hypot(out.x, out.y, out.z, out.w);\n out.set(out.x * invLength, out.y * invLength, out.z * invLength, out.w * invLength);\n return out;\n }\n\n /**\n * Transforms a point by a matrix, applying translation and the perspective divide.\n *\n * @param m - The transformation.\n * @param point - The point to transform, in metres.\n * @param out - The vector to write; may alias `point`.\n * @returns `out`.\n */\n static transformPointToRef<TOut extends MutableVec3>(m: Mat4Like, point: Vec3Like, out: TOut): TOut {\n const x = point.x;\n const y = point.y;\n const z = point.z;\n const rx = x * (m[0] ?? 0) + y * (m[4] ?? 0) + z * (m[8] ?? 0) + (m[12] ?? 0);\n const ry = x * (m[1] ?? 0) + y * (m[5] ?? 0) + z * (m[9] ?? 0) + (m[13] ?? 0);\n const rz = x * (m[2] ?? 0) + y * (m[6] ?? 0) + z * (m[10] ?? 0) + (m[14] ?? 0);\n const invW = 1 / (x * (m[3] ?? 0) + y * (m[7] ?? 0) + z * (m[11] ?? 0) + (m[15] ?? 0));\n out.set(rx * invW, ry * invW, rz * invW);\n return out;\n }\n\n /**\n * Transforms a direction by a matrix, ignoring translation. Note that this is the plain basis\n * transform: a non-uniformly scaled matrix needs its inverse-transpose to keep normals correct.\n *\n * @param m - The transformation.\n * @param direction - The direction to transform.\n * @param out - The vector to write; may alias `direction`.\n * @returns `out`.\n */\n static transformDirectionToRef<TOut extends MutableVec3>(m: Mat4Like, direction: Vec3Like, out: TOut): TOut {\n const x = direction.x;\n const y = direction.y;\n const z = direction.z;\n out.set(\n x * (m[0] ?? 0) + y * (m[4] ?? 0) + z * (m[8] ?? 0),\n x * (m[1] ?? 0) + y * (m[5] ?? 0) + z * (m[9] ?? 0),\n x * (m[2] ?? 0) + y * (m[6] ?? 0) + z * (m[10] ?? 0),\n );\n return out;\n }\n\n /**\n * Compares two matrices element by element, with a tolerance.\n *\n * @param a - The first matrix.\n * @param b - The second matrix.\n * @param epsilon - The largest per-element difference still considered equal.\n * @returns `true` when every element matches within `epsilon`.\n */\n static equalsWithEpsilon(a: Mat4Like, b: Mat4Like, epsilon: number = EPSILON): boolean {\n for (let i = 0; i < 16; i++) {\n if (Math.abs((a[i] ?? 0) - (b[i] ?? 0)) > epsilon) {\n return false;\n }\n }\n return true;\n }\n}\n\n/**\n * The zero translation {@link Mat4.fromQuatToRef} composes with. Module-scope constant, frozen so it\n * can never be written through.\n */\nconst ZERO_TRANSLATION: Vec3Like = Object.freeze({ x: 0, y: 0, z: 0 });\n\n/**\n * The unit scale {@link Mat4.fromQuatToRef} composes with.\n */\nconst UNIT_SCALE: Vec3Like = Object.freeze({ x: 1, y: 1, z: 1 });\n\n/**\n * A frozen identity matrix, for the common case of \"no transform\". It is a plain {@link Mat4Like}\n * rather than a {@link Mat4} because a `Float32Array` cannot be frozen — pass it to anything that\n * reads a matrix, and use `new Mat4()` when you need one you can write to.\n *\n * @example\n * ```ts\n * Mat4.transformPointToRef(MAT4_IDENTITY, point, out); // copies the point\n * ```\n *\n * @public\n */\nexport const MAT4_IDENTITY: Mat4Like = Object.freeze({\n length: 16,\n 0: 1,\n 1: 0,\n 2: 0,\n 3: 0,\n 4: 0,\n 5: 1,\n 6: 0,\n 7: 0,\n 8: 0,\n 9: 0,\n 10: 1,\n 11: 0,\n 12: 0,\n 13: 0,\n 14: 0,\n 15: 1,\n} as const);\n","import {\n createTransformNode,\n decomposeMat4,\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 `decomposeMat4`,\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 `decomposeMat4` 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 = decomposeMat4(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","import { Mat4 } from \"./mat4.js\";\nimport { EPSILON, lerp } from \"./math-utils.js\";\nimport type { Mat4Like, MutableVec3, Vec3Like } from \"./types.js\";\n\n/**\n * A 3-component vector: a position or a direction in metres, or a per-axis scale. ignifx is\n * left-handed with Y up and +Z forward (ADR-0011), so {@link Vec3.forward} is `(0, 0, 1)` and\n * {@link Vec3.right} is `(1, 0, 0)`.\n *\n * The fields are plain mutable numbers, which is what makes a `Vec3` interchangeable with Babylon\n * Lite's `{ x, y, z }` vectors and with the live {@link MutableVec3} views a `Transform` exposes.\n *\n * Three families of operations, and the names say which is which:\n *\n * - instance methods mutate the receiver and return `this` (`a.add(b)` means `a += b`);\n * - `ToRef` statics write into a final `out` argument, allocate nothing, and are safe when `out`\n * aliases an input — these are what per-frame code uses (coding standards section 7);\n * - the remaining statics return a fresh vector and are documented as allocating.\n *\n * @example\n * ```ts\n * // convenience code\n * const offset = Vec3.add(position, Vec3.scale(direction, distance));\n *\n * // per-frame code: no allocation\n * Vec3.scaleToRef(direction, distance, scratch);\n * Vec3.addToRef(position, scratch, position);\n * ```\n *\n * @public\n */\nexport class Vec3 {\n /** The X component; positive is right. */\n x: number;\n /** The Y component; positive is up. */\n y: number;\n /** The Z component; positive is forward. */\n z: number;\n\n /**\n * Creates a vector.\n *\n * @param x - The X component. Defaults to 0.\n * @param y - The Y component. Defaults to 0.\n * @param z - The Z component. Defaults to 0.\n */\n constructor(x: number = 0, y: number = 0, z: number = 0) {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n\n /**\n * Assigns every component at once.\n *\n * @param x - The new X component.\n * @param y - The new Y component.\n * @param z - The new Z component.\n * @returns This vector.\n */\n set(x: number, y: number, z: number): this {\n this.x = x;\n this.y = y;\n this.z = z;\n return this;\n }\n\n /**\n * Copies every component from another vector.\n *\n * @param v - The vector to read.\n * @returns This vector.\n */\n copyFrom(v: Vec3Like): this {\n this.x = v.x;\n this.y = v.y;\n this.z = v.z;\n return this;\n }\n\n /**\n * Copies this vector into a new one.\n *\n * @returns A new vector. **Allocates.**\n */\n clone(): Vec3 {\n return new Vec3(this.x, this.y, this.z);\n }\n\n /**\n * Adds another vector to this one.\n *\n * @param v - The vector to add.\n * @returns This vector.\n */\n add(v: Vec3Like): this {\n this.x += v.x;\n this.y += v.y;\n this.z += v.z;\n return this;\n }\n\n /**\n * Adds a scaled vector to this one — the \"move by velocity times delta time\" step, without a\n * temporary.\n *\n * @param v - The vector to add.\n * @param scale - The factor to multiply `v` by first.\n * @returns This vector.\n *\n * @example\n * ```ts\n * position.addScaled(velocity, time.deltaTime);\n * ```\n */\n addScaled(v: Vec3Like, scale: number): this {\n this.x += v.x * scale;\n this.y += v.y * scale;\n this.z += v.z * scale;\n return this;\n }\n\n /**\n * Subtracts another vector from this one.\n *\n * @param v - The vector to subtract.\n * @returns This vector.\n */\n subtract(v: Vec3Like): this {\n this.x -= v.x;\n this.y -= v.y;\n this.z -= v.z;\n return this;\n }\n\n /**\n * Multiplies this vector by another component by component.\n *\n * @param v - The vector to multiply by.\n * @returns This vector.\n */\n multiply(v: Vec3Like): this {\n this.x *= v.x;\n this.y *= v.y;\n this.z *= v.z;\n return this;\n }\n\n /**\n * Multiplies every component by a number.\n *\n * @param scale - The factor.\n * @returns This vector.\n */\n scale(scale: number): this {\n this.x *= scale;\n this.y *= scale;\n this.z *= scale;\n return this;\n }\n\n /**\n * Flips this vector to point the other way.\n *\n * @returns This vector.\n */\n negate(): this {\n this.x = -this.x;\n this.y = -this.y;\n this.z = -this.z;\n return this;\n }\n\n /**\n * Scales this vector to unit length. A zero-length vector is left at zero rather than becoming\n * `NaN`, so callers can normalize an unchecked direction safely.\n *\n * @returns This vector.\n */\n normalize(): this {\n const length = Math.hypot(this.x, this.y, this.z);\n if (length === 0) {\n return this;\n }\n return this.scale(1 / length);\n }\n\n /**\n * Replaces this vector with its cross product with another (`this = this x v`).\n *\n * @param v - The right-hand vector.\n * @returns This vector.\n */\n cross(v: Vec3Like): this {\n return Vec3.crossToRef(this, v, this);\n }\n\n /**\n * Moves this vector towards a target by an interpolant.\n *\n * @param target - The vector reached at `t === 1`.\n * @param t - The interpolant; not clamped.\n * @returns This vector.\n */\n lerp(target: Vec3Like, t: number): this {\n return Vec3.lerpToRef(this, target, t, this);\n }\n\n /**\n * The dot product of this vector with another.\n *\n * @param v - The other vector.\n * @returns The dot product.\n */\n dot(v: Vec3Like): number {\n return this.x * v.x + this.y * v.y + this.z * v.z;\n }\n\n /**\n * The length of this vector, in metres.\n *\n * @returns The length.\n */\n length(): number {\n return Math.hypot(this.x, this.y, this.z);\n }\n\n /**\n * The squared length of this vector. Prefer it over `length()` when comparing distances:\n * it skips the square root.\n *\n * @returns The squared length.\n */\n lengthSquared(): number {\n return this.x * this.x + this.y * this.y + this.z * this.z;\n }\n\n /**\n * The distance from this vector to another, in metres.\n *\n * @param v - The other position.\n * @returns The distance.\n */\n distance(v: Vec3Like): number {\n return Math.hypot(this.x - v.x, this.y - v.y, this.z - v.z);\n }\n\n /**\n * The squared distance from this vector to another.\n *\n * @param v - The other position.\n * @returns The squared distance.\n */\n distanceSquared(v: Vec3Like): number {\n return Vec3.distanceSquared(this, v);\n }\n\n /**\n * Compares this vector with another, component by component, with a tolerance.\n *\n * @param v - The vector to compare against.\n * @param epsilon - The largest per-component difference still considered equal.\n * @returns `true` when every component matches within `epsilon`.\n */\n equalsWithEpsilon(v: Vec3Like, epsilon: number = EPSILON): boolean {\n return Vec3.equalsWithEpsilon(this, v, epsilon);\n }\n\n /**\n * Writes this vector into a `Float32Array`, for GPU upload. The output comes first to mirror\n * Babylon Lite's `ObservableVec3.toArray`, the shape the adapter has to interoperate with.\n *\n * @param out - The array to write into.\n * @param offset - The index of the X component. Defaults to 0.\n * @returns `out`.\n */\n toArray(out: Float32Array, offset: number = 0): Float32Array {\n out[offset] = this.x;\n out[offset + 1] = this.y;\n out[offset + 2] = this.z;\n return out;\n }\n\n /**\n * The zero vector.\n *\n * @returns A new `(0, 0, 0)`. **Allocates**; use {@link VEC3_ZERO} when a read-only value will do.\n */\n static zero(): Vec3 {\n return new Vec3(0, 0, 0);\n }\n\n /**\n * The vector whose components are all one.\n *\n * @returns A new `(1, 1, 1)`. **Allocates.**\n */\n static one(): Vec3 {\n return new Vec3(1, 1, 1);\n }\n\n /**\n * The world up direction.\n *\n * @returns A new `(0, 1, 0)`. **Allocates**; see {@link VEC3_UP}.\n */\n static up(): Vec3 {\n return new Vec3(0, 1, 0);\n }\n\n /**\n * The world down direction.\n *\n * @returns A new `(0, -1, 0)`. **Allocates.**\n */\n static down(): Vec3 {\n return new Vec3(0, -1, 0);\n }\n\n /**\n * The world right direction.\n *\n * @returns A new `(1, 0, 0)`. **Allocates**; see {@link VEC3_RIGHT}.\n */\n static right(): Vec3 {\n return new Vec3(1, 0, 0);\n }\n\n /**\n * The world left direction.\n *\n * @returns A new `(-1, 0, 0)`. **Allocates.**\n */\n static left(): Vec3 {\n return new Vec3(-1, 0, 0);\n }\n\n /**\n * The world forward direction. ignifx is left-handed, so forward is **+Z** (ADR-0011).\n *\n * @returns A new `(0, 0, 1)`. **Allocates**; see {@link VEC3_FORWARD}.\n */\n static forward(): Vec3 {\n return new Vec3(0, 0, 1);\n }\n\n /**\n * The world backward direction.\n *\n * @returns A new `(0, 0, -1)`. **Allocates.**\n */\n static backward(): Vec3 {\n return new Vec3(0, 0, -1);\n }\n\n /**\n * Copies any vector-shaped value into a `Vec3`.\n *\n * @param v - The vector to copy.\n * @returns A new vector. **Allocates.**\n *\n * @example\n * ```ts\n * const position = Vec3.from(node.position); // snapshot of a live Lite view\n * ```\n */\n static from(v: Vec3Like): Vec3 {\n return new Vec3(v.x, v.y, v.z);\n }\n\n /**\n * Adds two vectors.\n *\n * @param a - The first vector.\n * @param b - The second vector.\n * @returns A new vector. **Allocates**; use {@link Vec3.addToRef} in per-frame code.\n */\n static add(a: Vec3Like, b: Vec3Like): Vec3 {\n return Vec3.addToRef(a, b, new Vec3());\n }\n\n /**\n * Subtracts one vector from another.\n *\n * @param a - The vector to subtract from.\n * @param b - The vector to subtract.\n * @returns A new vector holding `a - b`. **Allocates.**\n */\n static subtract(a: Vec3Like, b: Vec3Like): Vec3 {\n return Vec3.subtractToRef(a, b, new Vec3());\n }\n\n /**\n * Multiplies a vector by a number.\n *\n * @param v - The vector to scale.\n * @param scale - The factor.\n * @returns A new vector. **Allocates.**\n */\n static scale(v: Vec3Like, scale: number): Vec3 {\n return Vec3.scaleToRef(v, scale, new Vec3());\n }\n\n /**\n * The cross product of two vectors.\n *\n * @param a - The left-hand vector.\n * @param b - The right-hand vector.\n * @returns A new vector holding `a x b`. **Allocates.**\n */\n static cross(a: Vec3Like, b: Vec3Like): Vec3 {\n return Vec3.crossToRef(a, b, new Vec3());\n }\n\n /**\n * A unit-length copy of a vector.\n *\n * @param v - The vector to normalize.\n * @returns A new vector. **Allocates.**\n */\n static normalize(v: Vec3Like): Vec3 {\n return Vec3.normalizeToRef(v, new Vec3());\n }\n\n /**\n * Linearly interpolates between two vectors.\n *\n * @param a - The vector returned at `t === 0`.\n * @param b - The vector returned at `t === 1`.\n * @param t - The interpolant; not clamped.\n * @returns A new vector. **Allocates.**\n */\n static lerp(a: Vec3Like, b: Vec3Like, t: number): Vec3 {\n return Vec3.lerpToRef(a, b, t, new Vec3());\n }\n\n /**\n * Writes `a + b` into `out`.\n *\n * @param a - The first vector.\n * @param b - The second vector.\n * @param out - The vector to write; may alias `a` or `b`.\n * @returns `out`.\n */\n static addToRef<TOut extends MutableVec3>(a: Vec3Like, b: Vec3Like, out: TOut): TOut {\n out.set(a.x + b.x, a.y + b.y, a.z + b.z);\n return out;\n }\n\n /**\n * Writes `a - b` into `out`.\n *\n * @param a - The vector to subtract from.\n * @param b - The vector to subtract.\n * @param out - The vector to write; may alias `a` or `b`.\n * @returns `out`.\n */\n static subtractToRef<TOut extends MutableVec3>(a: Vec3Like, b: Vec3Like, out: TOut): TOut {\n out.set(a.x - b.x, a.y - b.y, a.z - b.z);\n return out;\n }\n\n /**\n * Writes the component-wise product `a * b` into `out`.\n *\n * @param a - The first vector.\n * @param b - The second vector.\n * @param out - The vector to write; may alias `a` or `b`.\n * @returns `out`.\n */\n static multiplyToRef<TOut extends MutableVec3>(a: Vec3Like, b: Vec3Like, out: TOut): TOut {\n out.set(a.x * b.x, a.y * b.y, a.z * b.z);\n return out;\n }\n\n /**\n * Writes `v * scale` into `out`.\n *\n * @param v - The vector to scale.\n * @param scale - The factor.\n * @param out - The vector to write; may alias `v`.\n * @returns `out`.\n */\n static scaleToRef<TOut extends MutableVec3>(v: Vec3Like, scale: number, out: TOut): TOut {\n out.set(v.x * scale, v.y * scale, v.z * scale);\n return out;\n }\n\n /**\n * Writes `-v` into `out`.\n *\n * @param v - The vector to flip.\n * @param out - The vector to write; may alias `v`.\n * @returns `out`.\n */\n static negateToRef<TOut extends MutableVec3>(v: Vec3Like, out: TOut): TOut {\n out.set(-v.x, -v.y, -v.z);\n return out;\n }\n\n /**\n * Writes a unit-length copy of `v` into `out`. A zero-length input is written as zero rather than\n * `NaN`.\n *\n * @param v - The vector to normalize.\n * @param out - The vector to write; may alias `v`.\n * @returns `out`.\n */\n static normalizeToRef<TOut extends MutableVec3>(v: Vec3Like, out: TOut): TOut {\n const length = Math.hypot(v.x, v.y, v.z);\n if (length === 0) {\n out.set(0, 0, 0);\n return out;\n }\n const inv = 1 / length;\n out.set(v.x * inv, v.y * inv, v.z * inv);\n return out;\n }\n\n /**\n * Writes `a x b` into `out`.\n *\n * @param a - The left-hand vector.\n * @param b - The right-hand vector.\n * @param out - The vector to write; may alias `a` or `b`.\n * @returns `out`.\n */\n static crossToRef<TOut extends MutableVec3>(a: Vec3Like, b: Vec3Like, out: TOut): TOut {\n const ax = a.x;\n const ay = a.y;\n const az = a.z;\n const bx = b.x;\n const by = b.y;\n const bz = b.z;\n out.set(ay * bz - az * by, az * bx - ax * bz, ax * by - ay * bx);\n return out;\n }\n\n /**\n * Writes the interpolation of `a` and `b` into `out`.\n *\n * @param a - The vector written at `t === 0`.\n * @param b - The vector written at `t === 1`.\n * @param t - The interpolant; not clamped.\n * @param out - The vector to write; may alias `a` or `b`.\n * @returns `out`.\n */\n static lerpToRef<TOut extends MutableVec3>(a: Vec3Like, b: Vec3Like, t: number, out: TOut): TOut {\n out.set(lerp(a.x, b.x, t), lerp(a.y, b.y, t), lerp(a.z, b.z, t));\n return out;\n }\n\n /**\n * Writes the component-wise minimum of two vectors into `out`.\n *\n * @param a - The first vector.\n * @param b - The second vector.\n * @param out - The vector to write; may alias `a` or `b`.\n * @returns `out`.\n */\n static minToRef<TOut extends MutableVec3>(a: Vec3Like, b: Vec3Like, out: TOut): TOut {\n out.set(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));\n return out;\n }\n\n /**\n * Writes the component-wise maximum of two vectors into `out`.\n *\n * @param a - The first vector.\n * @param b - The second vector.\n * @param out - The vector to write; may alias `a` or `b`.\n * @returns `out`.\n */\n static maxToRef<TOut extends MutableVec3>(a: Vec3Like, b: Vec3Like, out: TOut): TOut {\n out.set(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));\n return out;\n }\n\n /**\n * Transforms a **position** by a matrix into `out`: the matrix's translation is applied and the\n * result is divided by w, so a projection matrix gives clip-space coordinates.\n *\n * @param v - The position to transform, in metres.\n * @param m - The transformation, column-major.\n * @param out - The vector to write; may alias `v`.\n * @returns `out`.\n *\n * @example\n * ```ts\n * Vec3.transformCoordinatesToRef(localPoint, node.worldMatrix, worldPoint);\n * ```\n */\n static transformCoordinatesToRef<TOut extends MutableVec3>(v: Vec3Like, m: Mat4Like, out: TOut): TOut {\n return Mat4.transformPointToRef(m, v, out);\n }\n\n /**\n * Transforms a **direction** by a matrix into `out`, ignoring the matrix's translation.\n *\n * @param v - The direction to transform.\n * @param m - The transformation, column-major.\n * @param out - The vector to write; may alias `v`.\n * @returns `out`.\n */\n static transformNormalToRef<TOut extends MutableVec3>(v: Vec3Like, m: Mat4Like, out: TOut): TOut {\n return Mat4.transformDirectionToRef(m, v, out);\n }\n\n /**\n * The dot product of two vectors.\n *\n * @param a - The first vector.\n * @param b - The second vector.\n * @returns The dot product.\n */\n static dot(a: Vec3Like, b: Vec3Like): number {\n return a.x * b.x + a.y * b.y + a.z * b.z;\n }\n\n /**\n * The length of a vector, in metres.\n *\n * @param v - The vector to measure.\n * @returns The length.\n */\n static length(v: Vec3Like): number {\n return Math.hypot(v.x, v.y, v.z);\n }\n\n /**\n * The squared length of a vector.\n *\n * @param v - The vector to measure.\n * @returns The squared length.\n */\n static lengthSquared(v: Vec3Like): number {\n return v.x * v.x + v.y * v.y + v.z * v.z;\n }\n\n /**\n * The distance between two positions, in metres.\n *\n * @param a - The first position.\n * @param b - The second position.\n * @returns The distance.\n */\n static distance(a: Vec3Like, b: Vec3Like): number {\n return Math.hypot(a.x - b.x, a.y - b.y, a.z - b.z);\n }\n\n /**\n * The squared distance between two positions. Compare squared distances to avoid a square root.\n *\n * @param a - The first position.\n * @param b - The second position.\n * @returns The squared distance.\n */\n static distanceSquared(a: Vec3Like, b: Vec3Like): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n const dz = a.z - b.z;\n return dx * dx + dy * dy + dz * dz;\n }\n\n /**\n * Compares two vectors component by component, with a tolerance.\n *\n * @param a - The first vector.\n * @param b - The second vector.\n * @param epsilon - The largest per-component difference still considered equal.\n * @returns `true` when every component matches within `epsilon`.\n */\n static equalsWithEpsilon(a: Vec3Like, b: Vec3Like, epsilon: number = EPSILON): boolean {\n return Math.abs(a.x - b.x) <= epsilon && Math.abs(a.y - b.y) <= epsilon && Math.abs(a.z - b.z) <= epsilon;\n }\n}\n\n/**\n * The frozen zero vector, `(0, 0, 0)`. Read-only: pass it anywhere a {@link Vec3Like} is wanted, and\n * call {@link Vec3.zero} when you need a vector you can write to.\n *\n * @public\n */\nexport const VEC3_ZERO: Vec3Like = Object.freeze({ x: 0, y: 0, z: 0 });\n\n/**\n * The frozen vector whose components are all one, `(1, 1, 1)` — the identity scale.\n *\n * @public\n */\nexport const VEC3_ONE: Vec3Like = Object.freeze({ x: 1, y: 1, z: 1 });\n\n/**\n * The frozen world up direction, `(0, 1, 0)`.\n *\n * @public\n */\nexport const VEC3_UP: Vec3Like = Object.freeze({ x: 0, y: 1, z: 0 });\n\n/**\n * The frozen world down direction, `(0, -1, 0)`.\n *\n * @public\n */\nexport const VEC3_DOWN: Vec3Like = Object.freeze({ x: 0, y: -1, z: 0 });\n\n/**\n * The frozen world right direction, `(1, 0, 0)`.\n *\n * @public\n */\nexport const VEC3_RIGHT: Vec3Like = Object.freeze({ x: 1, y: 0, z: 0 });\n\n/**\n * The frozen world left direction, `(-1, 0, 0)`.\n *\n * @public\n */\nexport const VEC3_LEFT: Vec3Like = Object.freeze({ x: -1, y: 0, z: 0 });\n\n/**\n * The frozen world forward direction, `(0, 0, 1)`. ignifx is left-handed, so forward is +Z\n * (ADR-0011).\n *\n * @public\n */\nexport const VEC3_FORWARD: Vec3Like = Object.freeze({ x: 0, y: 0, z: 1 });\n\n/**\n * The frozen world backward direction, `(0, 0, -1)`.\n *\n * @public\n */\nexport const VEC3_BACKWARD: Vec3Like = Object.freeze({ x: 0, y: 0, z: -1 });\n"],"mappings":";;;;;;;;AAiBA,SAAS,mBAAiC;CAKxC,uBAAO,IAAI,aAAa,EAAE;AAC5B;;;;;;;;AASA,SAAS,iBAAiB,GAAqB;CAC7C,MAAM,KAAK,EAAE,MAAM;CACnB,MAAM,KAAK,EAAE,MAAM;CACnB,MAAM,KAAK,EAAE,MAAM;CACnB,MAAM,KAAK,EAAE,MAAM;CACnB,MAAM,KAAK,EAAE,MAAM;CACnB,MAAM,KAAK,EAAE,MAAM;CACnB,MAAM,KAAK,EAAE,MAAM;CACnB,MAAM,KAAK,EAAE,MAAM;CACnB,MAAM,MAAM,EAAE,OAAO;CACrB,OAAO,MAAM,KAAK,MAAM,KAAK,MAAM,MAAM,KAAK,KAAK,KAAK,OAAO,MAAM,KAAK,KAAK,KAAK;AACtF;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,iBACd,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACM;CACN,MAAM,QAAQ,MAAM,MAAM;CAC1B,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AK,KAAK,KAAK;CAClC;;;;;;;;;CAUA,OAAO,kBAAkB,GAAa,GAAa,UAAkB,SAAkB;EACrF,OAAO,KAAK,IAAI,EAAE,IAAI,EAAE,CAAC,KAAK,WAAW,KAAK,IAAI,EAAE,IAAI,EAAE,CAAC,KAAK,WAAW,KAAK,IAAI,EAAE,IAAI,EAAE,CAAC,KAAK;CACpG;AACF;;;;;;;AAQA,MAAa,YAAsB,OAAO,OAAO;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE,CAAC;;;;;;AAOrE,MAAa,WAAqB,OAAO,OAAO;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE,CAAC;;;;;;AAOpE,MAAa,UAAoB,OAAO,OAAO;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE,CAAC;;;;;;AAOnE,MAAa,YAAsB,OAAO,OAAO;CAAE,GAAG;CAAG,GAAG;CAAI,GAAG;AAAE,CAAC;;;;;;AAOtE,MAAa,aAAuB,OAAO,OAAO;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE,CAAC;;;;;;AAOtE,MAAa,YAAsB,OAAO,OAAO;CAAE,GAAG;CAAI,GAAG;CAAG,GAAG;AAAE,CAAC;;;;;;;AAQtE,MAAa,eAAyB,OAAO,OAAO;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE,CAAC;;;;;;AAOxE,MAAa,gBAA0B,OAAO,OAAO;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;AAAG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ignifx/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "ignifx core: app, world, entities, components, scripts, and the Babylon Lite adapter boundary.",
|
|
5
5
|
"homepage": "https://ignifx.com",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"provenance": false
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@babylonjs/lite": "1.
|
|
30
|
+
"@babylonjs/lite": "1.34.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"color-CpvebMIh.js","names":[],"sources":["../src/math/math-utils.ts","../src/math/color.ts"],"sourcesContent":["/**\n * Scalar helpers shared by the vector, quaternion and matrix types and by game code.\n *\n * Angles are **degrees** in every public API unless the name ends in `Rad`/`Radians`\n * (coding standards §5.1, ADR-0011). Every function here is a pure scalar function: none of them\n * allocate, so they are safe in per-frame code (coding standards §7).\n */\n\n/**\n * The default tolerance for approximate float comparisons. Chosen for single-precision positions in\n * metres: `Float32Array` round-tripping loses roughly 1e-7 of relative precision, so 1e-6 is the\n * smallest value that does not report false differences on data that has been through the GPU.\n *\n * @public\n */\nexport const EPSILON: number = 1e-6;\n\n/**\n * Multiplier that converts degrees to radians.\n *\n * @public\n */\nexport const DEG_TO_RAD: number = Math.PI / 180;\n\n/**\n * Multiplier that converts radians to degrees.\n *\n * @public\n */\nexport const RAD_TO_DEG: number = 180 / Math.PI;\n\n/**\n * Converts an angle from degrees to radians.\n *\n * @param degrees - The angle in degrees.\n * @returns The same angle in radians.\n *\n * @public\n */\nexport function degToRad(degrees: number): number {\n return degrees * DEG_TO_RAD;\n}\n\n/**\n * Converts an angle from radians to degrees.\n *\n * @param radians - The angle in radians.\n * @returns The same angle in degrees.\n *\n * @public\n */\nexport function radToDeg(radians: number): number {\n return radians * RAD_TO_DEG;\n}\n\n/**\n * Constrains a value to an inclusive range.\n *\n * @param value - The value to constrain.\n * @param min - The lower bound.\n * @param max - The upper bound.\n * @returns `min` when `value` is smaller, `max` when it is larger, otherwise `value` unchanged.\n * `NaN` propagates.\n *\n * @example\n * ```ts\n * clamp(12, 0, 10); // 10\n * ```\n *\n * @public\n */\nexport function clamp(value: number, min: number, max: number): number {\n if (value < min) {\n return min;\n }\n if (value > max) {\n return max;\n }\n return value;\n}\n\n/**\n * Constrains a value to the 0–1 range.\n *\n * @param value - The value to constrain.\n * @returns The value clamped into `[0, 1]`.\n *\n * @public\n */\nexport function clamp01(value: number): number {\n return clamp(value, 0, 1);\n}\n\n/**\n * Linearly interpolates between two values. The interpolant is **not** clamped, so values outside\n * `[0, 1]` extrapolate; wrap `t` in {@link clamp01} when that is not wanted.\n *\n * @param a - The value returned at `t === 0`.\n * @param b - The value returned at `t === 1`.\n * @param t - The interpolant.\n * @returns The interpolated value.\n *\n * @example\n * ```ts\n * lerp(0, 10, 0.25); // 2.5\n * ```\n *\n * @public\n */\nexport function lerp(a: number, b: number, t: number): number {\n return a + (b - a) * t;\n}\n\n/**\n * The inverse of {@link lerp}: finds the interpolant that maps `a`–`b` onto `value`.\n *\n * @param a - The value that maps to 0.\n * @param b - The value that maps to 1.\n * @param value - The value to locate.\n * @returns The interpolant, clamped into `[0, 1]`. Returns 0 when `a` and `b` are equal.\n *\n * @public\n */\nexport function inverseLerp(a: number, b: number, value: number): number {\n if (a === b) {\n return 0;\n }\n return clamp01((value - a) / (b - a));\n}\n\n/**\n * Smoothly interpolates between two edges with a Hermite curve (the GLSL `smoothstep`), easing in\n * and out instead of the straight ramp of {@link lerp}.\n *\n * @param edge0 - The value below which the result is 0.\n * @param edge1 - The value above which the result is 1.\n * @param x - The value to map.\n * @returns A value in `[0, 1]`. Degenerate edges (`edge0 === edge1`) step from 0 to 1 at the edge.\n *\n * @example\n * ```ts\n * smoothStep(0, 1, 0.5); // 0.5, but with zero slope at 0 and 1\n * ```\n *\n * @public\n */\nexport function smoothStep(edge0: number, edge1: number, x: number): number {\n if (edge0 === edge1) {\n return x < edge0 ? 0 : 1;\n }\n const t = clamp01((x - edge0) / (edge1 - edge0));\n return t * t * (3 - 2 * t);\n}\n\n/**\n * Moves a value towards a target without overshooting it.\n *\n * @param current - The value to move.\n * @param target - The value to move towards.\n * @param maxDelta - The largest step allowed this call; negative values move away from the target.\n * @returns The stepped value, exactly `target` once the remaining distance fits in `maxDelta`.\n *\n * @example\n * ```ts\n * // frame-rate independent approach at 2 units per second\n * health = moveTowards(health, 100, 2 * time.deltaTime);\n * ```\n *\n * @public\n */\nexport function moveTowards(current: number, target: number, maxDelta: number): number {\n const delta = target - current;\n if (Math.abs(delta) <= maxDelta) {\n return target;\n }\n return current + (delta < 0 ? -maxDelta : maxDelta);\n}\n\n/**\n * Wraps a value into `[0, length)`, the way a looping animation time behaves. Unlike `%` the result\n * is never negative.\n *\n * @param t - The value to wrap.\n * @param length - The positive period to wrap into.\n * @returns The wrapped value, clamped into `[0, length]` so float error cannot escape the range.\n *\n * @example\n * ```ts\n * repeat(-1, 4); // 3\n * ```\n *\n * @public\n */\nexport function repeat(t: number, length: number): number {\n return clamp(t - Math.floor(t / length) * length, 0, length);\n}\n\n/**\n * Bounces a value back and forth between 0 and `length`, the way a ping-pong animation behaves.\n *\n * @param t - The value to fold.\n * @param length - The positive half-period to fold into.\n * @returns A value in `[0, length]` that rises then falls as `t` increases.\n *\n * @example\n * ```ts\n * pingPong(5, 4); // 3\n * ```\n *\n * @public\n */\nexport function pingPong(t: number, length: number): number {\n return length - Math.abs(repeat(t, length * 2) - length);\n}\n\n/**\n * Compares two numbers with an absolute tolerance. Use this instead of `===` on anything that has\n * been through a matrix, a quaternion or a `Float32Array`.\n *\n * @param a - The first value.\n * @param b - The second value.\n * @param epsilon - The largest difference still considered equal. Defaults to {@link EPSILON}.\n * @returns `true` when the values differ by no more than `epsilon`. `NaN` is never approximately\n * equal to anything, including itself.\n *\n * @public\n */\nexport function approximately(a: number, b: number, epsilon: number = EPSILON): boolean {\n return Math.abs(a - b) <= epsilon;\n}\n\n/**\n * The sign of a value, with zero treated as positive (matching Unity's `Mathf.Sign`, and unlike\n * `Math.sign`, which returns 0 and `-0`).\n *\n * @param value - The value to inspect.\n * @returns `-1` for negative values, `1` for positive values and for both `0` and `-0`, and `NaN`\n * for `NaN`.\n *\n * @public\n */\nexport function sign(value: number): number {\n if (Number.isNaN(value)) {\n return Number.NaN;\n }\n return value < 0 ? -1 : 1;\n}\n\n/**\n * Wraps an angle in degrees into `[-180, 180)`, the range rotations are most readable in.\n *\n * @param degrees - The angle to wrap.\n * @returns The equivalent angle in `[-180, 180)`; exactly `180` wraps to `-180`.\n *\n * @example\n * ```ts\n * wrapAngleDegrees(370); // 10\n * wrapAngleDegrees(-190); // 170\n * ```\n *\n * @public\n */\nexport function wrapAngleDegrees(degrees: number): number {\n return repeat(degrees + 180, 360) - 180;\n}\n\n/**\n * The shortest signed rotation from one angle to another, in degrees.\n *\n * @param fromDegrees - The starting angle.\n * @param toDegrees - The target angle.\n * @returns The signed difference in `[-180, 180)`.\n *\n * @example\n * ```ts\n * deltaAngleDegrees(350, 10); // 20, not -340\n * ```\n *\n * @public\n */\nexport function deltaAngleDegrees(fromDegrees: number, toDegrees: number): number {\n return wrapAngleDegrees(toDegrees - fromDegrees);\n}\n\n/**\n * Interpolates between two angles in degrees the short way around the circle.\n *\n * @param fromDegrees - The angle returned at `t === 0`.\n * @param toDegrees - The angle approached at `t === 1`.\n * @param t - The interpolant; not clamped, matching {@link lerp}.\n * @returns The interpolated angle. It is not wrapped, so feeding the result back in is stable.\n *\n * @example\n * ```ts\n * lerpAngleDegrees(350, 10, 0.5); // 360\n * ```\n *\n * @public\n */\nexport function lerpAngleDegrees(fromDegrees: number, toDegrees: number, t: number): number {\n return fromDegrees + deltaAngleDegrees(fromDegrees, toDegrees) * t;\n}\n","import { clamp01, EPSILON, lerp } from \"./math-utils.js\";\nimport type { ColorLike } from \"./types.js\";\n\n/**\n * Matches `#rrggbb`, `#rrggbbaa`, and the same two without the leading `#`.\n */\nconst HEX_PATTERN = /^#?(?:[\\da-f]{6}|[\\da-f]{8})$/iu;\n\n/**\n * Formats a 0-255 channel as two lowercase hex digits.\n *\n * @param value - The channel value, already rounded into 0-255.\n * @returns Two hex digits.\n */\nfunction hexByte(value: number): string {\n return value.toString(16).padStart(2, \"0\");\n}\n\n/**\n * An RGBA colour whose components are **linear** and normally in 0-1 (values above 1 are allowed\n * and mean HDR intensity). Lighting maths only works in linear space, which is why this is the\n * space ignifx stores; scene files and hex strings are sRGB, and\n * {@link Color.fromHex}/{@link Color.fromSrgb} are the doors between the two\n * (`docs/architecture/06-serialization-and-scene-format.md` section 3).\n *\n * Every method says which space it works in. The rule of thumb: if it takes or returns a hex string\n * or has `Srgb` in its name, it is sRGB; everything else is linear.\n *\n * @example\n * ```ts\n * const tint = Color.fromHex(\"#ff8800\") ?? new Color(1, 1, 1, 1); // parsed as sRGB, stored linear\n * tint.scaleRgb(2); // twice as bright, same alpha\n * tint.toHex(); // back to sRGB: \"#ffbe00\"\n * ```\n *\n * @public\n */\nexport class Color {\n /** The linear red component. */\n r: number;\n /** The linear green component. */\n g: number;\n /** The linear blue component. */\n b: number;\n /** The alpha component in 0-1. Alpha is always linear, never gamma encoded. */\n a: number;\n\n /**\n * Creates a colour from linear components.\n *\n * @param r - The linear red component. Defaults to 0.\n * @param g - The linear green component. Defaults to 0.\n * @param b - The linear blue component. Defaults to 0.\n * @param a - The alpha component. Defaults to 1 (opaque).\n */\n constructor(r: number = 0, g: number = 0, b: number = 0, a: number = 1) {\n this.r = r;\n this.g = g;\n this.b = b;\n this.a = a;\n }\n\n /**\n * Assigns every component at once, in linear space.\n *\n * @param r - The new linear red component.\n * @param g - The new linear green component.\n * @param b - The new linear blue component.\n * @param a - The new alpha component.\n * @returns This colour.\n */\n set(r: number, g: number, b: number, a: number): this {\n this.r = r;\n this.g = g;\n this.b = b;\n this.a = a;\n return this;\n }\n\n /**\n * Copies every component from another colour.\n *\n * @param c - The colour to read.\n * @returns This colour.\n */\n copyFrom(c: ColorLike): this {\n this.r = c.r;\n this.g = c.g;\n this.b = c.b;\n this.a = c.a;\n return this;\n }\n\n /**\n * Copies this colour into a new one.\n *\n * @returns A new colour. **Allocates.**\n */\n clone(): Color {\n return new Color(this.r, this.g, this.b, this.a);\n }\n\n /**\n * Multiplies this colour by another, component by component including alpha — the usual way a\n * tint is applied.\n *\n * @param c - The colour to multiply by.\n * @returns This colour.\n */\n multiply(c: ColorLike): this {\n this.r *= c.r;\n this.g *= c.g;\n this.b *= c.b;\n this.a *= c.a;\n return this;\n }\n\n /**\n * Scales the linear RGB components, leaving alpha alone. This is what \"brighter\" means: alpha is\n * coverage, not colour.\n *\n * @param factor - The intensity factor.\n * @returns This colour.\n */\n scaleRgb(factor: number): this {\n this.r *= factor;\n this.g *= factor;\n this.b *= factor;\n return this;\n }\n\n /**\n * Moves this colour towards a target, in linear space (which is where blending belongs; lerping\n * sRGB values darkens midpoints).\n *\n * @param target - The colour reached at `t === 1`.\n * @param t - The interpolant; not clamped.\n * @returns This colour.\n */\n lerp(target: ColorLike, t: number): this {\n return Color.lerpToRef(this, target, t, this);\n }\n\n /**\n * Compares this colour with another, component by component, with a tolerance.\n *\n * @param c - The colour to compare against.\n * @param epsilon - The largest per-component difference still considered equal.\n * @returns `true` when every component matches within `epsilon`.\n */\n equalsWithEpsilon(c: ColorLike, epsilon: number = EPSILON): boolean {\n return Color.equalsWithEpsilon(this, c, epsilon);\n }\n\n /**\n * Writes the **linear** components into a `Float32Array`, the form a shader wants. The output\n * comes first to mirror Babylon Lite's `toArray` helpers.\n *\n * @param out - The array to write into.\n * @param offset - The index of the red component. Defaults to 0.\n * @returns `out`.\n */\n toArray(out: Float32Array, offset: number = 0): Float32Array {\n out[offset] = this.r;\n out[offset + 1] = this.g;\n out[offset + 2] = this.b;\n out[offset + 3] = this.a;\n return out;\n }\n\n /**\n * Writes this colour's **sRGB-encoded** components into `out`, for display, pickers and files.\n * Components are clamped into 0-1 by the encoding curve.\n *\n * @param out - The colour to write; may be this colour. Its fields hold sRGB values afterwards,\n * not linear ones.\n * @returns `out`.\n */\n toSrgbToRef<TOut extends Color>(out: TOut): TOut {\n return out.set(Color.linearToSrgb(this.r), Color.linearToSrgb(this.g), Color.linearToSrgb(this.b), this.a);\n }\n\n /**\n * Encodes this colour as an sRGB hex string.\n *\n * @returns `#rrggbb` for an opaque colour, `#rrggbbaa` when alpha is below 1. **Allocates a\n * string.**\n *\n * @example\n * ```ts\n * new Color(1, 1, 1, 1).toHex(); // \"#ffffff\"\n * ```\n */\n toHex(): string {\n const r = hexByte(Math.round(Color.linearToSrgb(this.r) * 255));\n const g = hexByte(Math.round(Color.linearToSrgb(this.g) * 255));\n const b = hexByte(Math.round(Color.linearToSrgb(this.b) * 255));\n const alpha = clamp01(this.a);\n if (alpha >= 1) {\n return `#${r}${g}${b}`;\n }\n return `#${r}${g}${b}${hexByte(Math.round(alpha * 255))}`;\n }\n\n /**\n * Opaque white.\n *\n * @returns A new linear `(1, 1, 1, 1)`. **Allocates.**\n */\n static white(): Color {\n return new Color(1, 1, 1, 1);\n }\n\n /**\n * Opaque black.\n *\n * @returns A new linear `(0, 0, 0, 1)`. **Allocates.**\n */\n static black(): Color {\n return new Color(0, 0, 0, 1);\n }\n\n /**\n * Fully transparent black.\n *\n * @returns A new linear `(0, 0, 0, 0)`. **Allocates.**\n */\n static transparent(): Color {\n return new Color(0, 0, 0, 0);\n }\n\n /**\n * Copies any colour-shaped value into a `Color`.\n *\n * @param c - The linear colour to copy.\n * @returns A new colour. **Allocates.**\n */\n static from(c: ColorLike): Color {\n return new Color(c.r, c.g, c.b, c.a);\n }\n\n /**\n * Converts one **sRGB** channel to linear, using the IEC 61966-2-1 curve Babylon Lite uses\n * (`lib/math/color.js`).\n *\n * @param channel - The sRGB channel value; clamped into 0-1.\n * @returns The linear value.\n */\n static srgbToLinear(channel: number): number {\n const c = clamp01(channel);\n return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);\n }\n\n /**\n * Converts one **linear** channel to sRGB, the inverse of {@link Color.srgbToLinear}.\n *\n * @param channel - The linear channel value; clamped into 0-1, so HDR intensity is lost.\n * @returns The sRGB value.\n */\n static linearToSrgb(channel: number): number {\n const c = clamp01(channel);\n return c <= 0.0031308 ? c * 12.92 : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;\n }\n\n /**\n * Builds a colour from **sRGB** components, converting RGB to linear and taking alpha as-is.\n *\n * @param r - The sRGB red component, 0-1.\n * @param g - The sRGB green component, 0-1.\n * @param b - The sRGB blue component, 0-1.\n * @param a - The alpha component, 0-1. Defaults to 1.\n * @returns A new colour holding linear components. **Allocates.**\n */\n static fromSrgb(r: number, g: number, b: number, a: number = 1): Color {\n return Color.fromSrgbToRef(r, g, b, a, new Color());\n }\n\n /**\n * Writes a colour built from **sRGB** components into `out`.\n *\n * @param r - The sRGB red component, 0-1.\n * @param g - The sRGB green component, 0-1.\n * @param b - The sRGB blue component, 0-1.\n * @param a - The alpha component, 0-1.\n * @param out - The colour to write; holds linear components afterwards.\n * @returns `out`.\n */\n static fromSrgbToRef<TOut extends Color>(r: number, g: number, b: number, a: number, out: TOut): TOut {\n return out.set(Color.srgbToLinear(r), Color.srgbToLinear(g), Color.srgbToLinear(b), a);\n }\n\n /**\n * Parses an **sRGB** hex string into a linear colour.\n *\n * @param hex - `#rrggbb` or `#rrggbbaa`, with or without the leading `#`, in either case.\n * @returns A new colour, or `null` when the string is not a hex colour. Colours arrive from files\n * and user input, so a bad one is expected absence rather than API misuse (coding standards\n * section 5.5): the caller decides whether to substitute a default or raise a load error.\n * **Allocates.**\n *\n * @example\n * ```ts\n * const tint = Color.fromHex(\"#ff8800aa\") ?? Color.white();\n * ```\n */\n static fromHex(hex: string): Color | null {\n const out = new Color();\n return Color.fromHexToRef(hex, out) ? out : null;\n }\n\n /**\n * Parses an **sRGB** hex string into `out` as linear components.\n *\n * @param hex - `#rrggbb` or `#rrggbbaa`, with or without the leading `#`, in either case.\n * @param out - The colour to write; left untouched when parsing fails.\n * @returns `true` when `hex` was a valid hex colour.\n */\n static fromHexToRef(hex: string, out: Color): boolean {\n if (!HEX_PATTERN.test(hex)) {\n return false;\n }\n const body = hex.startsWith(\"#\") ? hex.slice(1) : hex;\n const r = Number.parseInt(body.slice(0, 2), 16) / 255;\n const g = Number.parseInt(body.slice(2, 4), 16) / 255;\n const b = Number.parseInt(body.slice(4, 6), 16) / 255;\n const a = body.length === 8 ? Number.parseInt(body.slice(6, 8), 16) / 255 : 1;\n Color.fromSrgbToRef(r, g, b, a, out);\n return true;\n }\n\n /**\n * Writes the component-wise product `a * b` into `out`, in linear space.\n *\n * @param a - The first colour.\n * @param b - The second colour.\n * @param out - The colour to write; may alias `a` or `b`.\n * @returns `out`.\n */\n static multiplyToRef<TOut extends Color>(a: ColorLike, b: ColorLike, out: TOut): TOut {\n return out.set(a.r * b.r, a.g * b.g, a.b * b.b, a.a * b.a);\n }\n\n /**\n * Writes `c` with its RGB scaled and its alpha untouched into `out`.\n *\n * @param c - The colour to scale.\n * @param factor - The intensity factor.\n * @param out - The colour to write; may alias `c`.\n * @returns `out`.\n */\n static scaleRgbToRef<TOut extends Color>(c: ColorLike, factor: number, out: TOut): TOut {\n return out.set(c.r * factor, c.g * factor, c.b * factor, c.a);\n }\n\n /**\n * Writes the linear-space interpolation of `a` and `b` into `out`.\n *\n * @param a - The colour written at `t === 0`.\n * @param b - The colour written at `t === 1`.\n * @param t - The interpolant; not clamped.\n * @param out - The colour to write; may alias `a` or `b`.\n * @returns `out`.\n */\n static lerpToRef<TOut extends Color>(a: ColorLike, b: ColorLike, t: number, out: TOut): TOut {\n return out.set(lerp(a.r, b.r, t), lerp(a.g, b.g, t), lerp(a.b, b.b, t), lerp(a.a, b.a, t));\n }\n\n /**\n * Compares two colours component by component, with a tolerance.\n *\n * @param a - The first colour.\n * @param b - The second colour.\n * @param epsilon - The largest per-component difference still considered equal.\n * @returns `true` when every component matches within `epsilon`.\n */\n static equalsWithEpsilon(a: ColorLike, b: ColorLike, epsilon: number = EPSILON): boolean {\n return (\n Math.abs(a.r - b.r) <= epsilon &&\n Math.abs(a.g - b.g) <= epsilon &&\n Math.abs(a.b - b.b) <= epsilon &&\n Math.abs(a.a - b.a)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AI,EAAE,IAAI,EAAE,CAAC,KAAK,WACvB,KAAK,IAAI,EAAE,IAAI,EAAE,CAAC,KAAK;CAE3B;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instanced-mesh-instance-Cgx1H87p.js","names":["setThinInstances","setThinInstanceCount","flushThinInstances","setThinInstanceColors","enableThinInstanceGpuCulling","enableThinInstanceWorldBounds","enableThinInstanceDynamicDrawCount","setThinInstanceLodPartner","clearThinInstanceLodPartner"],"sources":["../src/lite/gpu/thin-instances.ts","../src/render/gpu/instanced-mesh-instance.ts"],"sourcesContent":["import {\n clearThinInstanceLodPartner as liteClearThinInstanceLodPartner,\n enableThinInstanceDynamicDrawCount as liteEnableThinInstanceDynamicDrawCount,\n enableThinInstanceGpuCulling as liteEnableThinInstanceGpuCulling,\n enableThinInstanceWorldBounds as liteEnableThinInstanceWorldBounds,\n flushThinInstances as liteFlushThinInstances,\n setThinInstanceColors as liteSetThinInstanceColors,\n setThinInstanceCount as liteSetThinInstanceCount,\n setThinInstanceDrawCount as liteSetThinInstanceDrawCount,\n setThinInstanceLodPartner as liteSetThinInstanceLodPartner,\n setThinInstances as liteSetThinInstances,\n} from \"@babylonjs/lite\";\nimport type { Mesh } from \"@babylonjs/lite\";\n\n/**\n * Thin-instance half of the Babylon Lite adapter (`docs/architecture/07-rendering.md` §2.3,\n * `docs/plan/2026-09-terrain-particles-shaders.md` §3.5). Everything here is `@internal` and needs a\n * WebGPU device, so the browser project is what covers it.\n *\n * Lite fixes the order these must be called in, and both the culling opt-in and the LOD pairing only\n * take effect through the renderable `registerScene` compiles:\n *\n * 1. {@link setThinInstances} — its `count` argument becomes `_capacity`, and the GPU buffer is\n * sized `_capacity * 64` bytes for the life of the mesh, so pass the **capacity** here once and\n * lower the active count with {@link setThinInstanceCount} straight afterwards.\n * 2. {@link enableThinInstanceWorldBounds} — gives the scene AABB the cloud rather than the\n * prototype. It does not fix a shadow frustum: `computeDirectionalLightMatrix` reads\n * `boundMin`/`boundMax` directly (`lib/shadow/shadow-base.js` 54).\n * 3. {@link enableThinInstanceGpuCulling} — compute-based, opaque only.\n * 4. {@link enableThinInstanceDynamicDrawCount} — indirect draw arguments, so a later count change\n * keeps the cached bundle valid.\n * 5. {@link setThinInstanceLodPartner} — needs both meshes instanced already and stamps both\n * `_clone`, so neither can be cloned afterwards.\n * 6. `addMeshToScene`, and only then `registerScene`.\n *\n * Moving instances costs three different amounts (`lib/mesh/thin-instance.js`):\n * {@link flushThinInstances} re-uploads the whole active range and is the only sub-range-free path\n * Lite exposes; {@link setThinInstanceCount} re-uploads as well; {@link setThinInstanceDrawCount}\n * uploads nothing but throws until the pool has completed one GPU synchronisation, which is private\n * state — {@link trySetThinInstanceDrawCount} asks by trying.\n */\n\n/**\n * Points a mesh at a matrix slab and fixes its capacity.\n *\n * @remarks\n * The `capacity` argument is written straight to Lite's `_capacity`, which sizes the GPU buffer\n * (`_capacity * 64` bytes) once and for good. Only the first `count` matrices are ever read from\n * `matrices`, and Lite clamps its dirty range to the active count\n * (`lib/mesh/thin-instance-gpu.js`), so a slab shorter than `capacity * 16` floats is safe as long\n * as the active count is lowered with {@link setThinInstanceCount} before the next frame.\n *\n * Lite keeps the array by reference and never copies it: the caller owns it, and mutating it is the\n * intended way to move instances, followed by {@link flushThinInstances}.\n *\n * @param mesh - The mesh to instance.\n * @param matrices - 16 floats per instance, column-major, caller-owned.\n * @param capacity - The largest instance count this mesh will ever draw.\n *\n * @internal\n */\nexport function setThinInstances(mesh: Mesh, matrices: Float32Array, capacity: number): void {\n liteSetThinInstances(mesh, matrices, capacity);\n}\n\n/**\n * Sets how many instances draw, re-uploading the active range.\n *\n * @remarks\n * Prefer {@link trySetThinInstanceDrawCount} for a per-frame change: this one marks `[0, count)`\n * dirty as well, so it costs a `count * 64`-byte upload.\n *\n * @param mesh - The instanced mesh.\n * @param count - The active count, at most the capacity.\n *\n * @internal\n */\nexport function setThinInstanceCount(mesh: Mesh, count: number): void {\n liteSetThinInstanceCount(mesh, count);\n}\n\n/**\n * Sets how many instances draw without re-uploading anything, when Lite accepts it.\n *\n * @remarks\n * Lite requires the pool to have completed one full-capacity GPU synchronisation first and throws\n * otherwise (`lib/mesh/thin-instance.js`, `ThrowLiteError(369)`); the state it checks — the matrix\n * buffer's existence and its version — is private, so the only way to ask is to call. The throw\n * happens before anything is mutated, so a refusal leaves the mesh untouched and the caller can\n * fall back to {@link setThinInstanceCount}.\n *\n * @param mesh - The instanced mesh.\n * @param count - The active count, at most the capacity.\n * @returns `true` when the count was changed, `false` when Lite is not ready for a bare count\n * change yet.\n *\n * @internal\n */\nexport function trySetThinInstanceDrawCount(mesh: Mesh, count: number): boolean {\n try {\n liteSetThinInstanceDrawCount(mesh, count);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Marks the whole active matrix range dirty, after the caller mutated the slab in place.\n *\n * @param mesh - The instanced mesh.\n *\n * @internal\n */\nexport function flushThinInstances(mesh: Mesh): void {\n liteFlushThinInstances(mesh);\n}\n\n/**\n * Installs, replaces, or removes the per-instance RGBA colours.\n *\n * @remarks\n * Lite exports no way to *remove* colours: `setThinInstanceColors` only assigns, and the colour\n * version counters that drive the upload are private. `ThinInstanceData.colors` is declared\n * optional and mutable (`index.d.ts` 12985), so clearing is a direct field write —\n * which is enough, because `syncThinInstanceGpuData` skips the colour upload entirely while\n * `colors` is null, and the renderable rebuild the caller triggers is what drops\n * `useThinInstanceColors` from the compiled pipeline.\n *\n * @param mesh - The instanced mesh.\n * @param colors - Four floats per instance (linear RGBA), or `null` to stop reading colours.\n *\n * @internal\n */\nexport function setThinInstanceColors(mesh: Mesh, colors: Float32Array | null): void {\n if (colors !== null) {\n liteSetThinInstanceColors(mesh, colors);\n return;\n }\n const data = mesh.thinInstances;\n if (data !== null && data !== undefined) {\n data.colors = null;\n }\n}\n\n/**\n * Turns compute-based GPU frustum culling on or off for an instanced mesh.\n *\n * @remarks\n * Opaque meshes only, and it must run after {@link setThinInstances} and before the scene is\n * registered.\n *\n * @param mesh - The instanced mesh.\n * @param enabled - Whether the culling compute pass runs.\n *\n * @internal\n */\nexport function enableThinInstanceGpuCulling(mesh: Mesh, enabled: boolean): void {\n liteEnableThinInstanceGpuCulling(mesh, enabled);\n}\n\n/**\n * Makes a mesh's world bounds the union of its instances' boxes rather than the prototype's own.\n *\n * @remarks\n * The hook it installs is `O(count)` per bounds computation, and it clamps to\n * `matrices.length / 16`, so a short slab cannot walk off the end. It is read by\n * `expandWorldAabbForMesh` — the scene camera's extent and PBR's scene-size probe — and **not** by\n * the directional shadow fit; see the module note.\n *\n * @param mesh - The instanced mesh.\n *\n * @internal\n */\nexport function enableThinInstanceWorldBounds(mesh: Mesh): void {\n liteEnableThinInstanceWorldBounds(mesh);\n}\n\n/**\n * Opts a fixed-capacity pool into indirect draw arguments, so a later count change keeps the\n * cached render bundle valid.\n *\n * @param mesh - The instanced mesh.\n *\n * @internal\n */\nexport function enableThinInstanceDynamicDrawCount(mesh: Mesh): void {\n liteEnableThinInstanceDynamicDrawCount(mesh);\n}\n\n/**\n * Where a LOD pairing switches, and how softly.\n *\n * @internal\n */\nexport interface ThinInstanceLodOptions {\n /** The camera distance, in world units, at which an in-frustum instance switches to the partner. */\n readonly distance: number;\n /** The width of the per-instance threshold dither window centred on `distance`; `0` is a hard cut. */\n readonly band: number;\n}\n\n/**\n * Pairs a GPU-culled instanced mesh with a lower-detail partner.\n *\n * @remarks\n * Both meshes must already carry thin instances, and the partner may reference the very same matrix\n * slab. While paired the partner draws **only** the far bucket, and the pairing switches its own\n * GPU culling on. Lite refuses the pairing when either mesh has more than one thin-instance owner,\n * when the partner is already paired, or when the partner carries colours the full mesh does not\n * (`ThrowLiteError(375)`, `(377)`, `(379)`). Calling it again with the same pair re-sets `distance`\n * and `band` live.\n *\n * @param fullMesh - The near mesh, which owns the culling pass.\n * @param lodMesh - The far mesh.\n * @param options - Where the switch happens, and how softly.\n *\n * @internal\n */\nexport function setThinInstanceLodPartner(fullMesh: Mesh, lodMesh: Mesh, options: ThinInstanceLodOptions): void {\n liteSetThinInstanceLodPartner(fullMesh, lodMesh, { distance: options.distance, band: options.band });\n}\n\n/**\n * Dissolves a LOD pairing, returning both meshes to independent rendering.\n *\n * @remarks\n * A no-op when the mesh is not paired, so it is safe on the teardown path.\n *\n * @param fullMesh - The near mesh of the pair.\n *\n * @internal\n */\nexport function clearThinInstanceLodPartner(fullMesh: Mesh): void {\n liteClearThinInstanceLodPartner(fullMesh);\n}\n\n/**\n * How many instances a mesh is currently drawing, as Lite sees it.\n *\n * @remarks\n * The browser tests assert against Lite's own state rather than against the component's copy of it,\n * which is the only way to prove the two agree.\n *\n * @param mesh - The mesh to read.\n * @returns The active count, or `0` when the mesh carries no thin instances.\n *\n * @internal\n */\nexport function thinInstanceCount(mesh: Mesh): number {\n return mesh.thinInstances?.count ?? 0;\n}\n","import {\n addMeshToScene,\n cloneMeshUnderNode,\n detachMeshBounds,\n removeMeshFromScene,\n setMeshBounds,\n setMeshId,\n setMeshMaterial,\n setMeshPickable,\n setMeshReceiveShadows,\n setMeshRenderOrder,\n setMeshSubtreeVisible,\n} from \"../../lite/gpu/mesh.js\";\nimport {\n clearThinInstanceLodPartner,\n enableThinInstanceDynamicDrawCount,\n enableThinInstanceGpuCulling,\n enableThinInstanceWorldBounds,\n flushThinInstances,\n setThinInstanceColors,\n setThinInstanceCount,\n setThinInstanceLodPartner,\n setThinInstances,\n trySetThinInstanceDrawCount,\n} from \"../../lite/gpu/thin-instances.js\";\nimport { tagNode } from \"../../lite/node.js\";\nimport type { LiteMesh } from \"../../lite/gpu/mesh.js\";\nimport type { LiteMaterial } from \"../../lite/material.js\";\nimport type { LiteSceneNode, NodeTag } from \"../../lite/node.js\";\nimport type { LiteScene } from \"../../lite/scene.js\";\n\n/**\n * One `InstancedMeshRenderer`'s near mesh and its optional LOD partner, and everything that writes\n * to them (`docs/plan/2026-09-terrain-particles-shaders.md` §3.5).\n *\n * Every line needs a WebGPU device, which is why it sits in `src/render/gpu/` — excluded from the\n * Node coverage floor and measured by the browser project — and why the component reaches it through\n * a dynamic `import()` (`../instanced-mesh-support.ts`).\n *\n * `capacity`, `gpuCulling` and the partner's identity are constructor arguments rather than `apply*`\n * methods because Lite fixes all three at `registerScene`; `distance` and `band` may be re-set live\n * by calling the pairing again. Both meshes share one matrix slab, which the pairing requires: it\n * compacts the near mesh's culling output into two buckets drawn from the same matrices.\n *\n * Bounds are the one thing an instanced caster needs that a plain mesh does not.\n * `computeDirectionalLightMatrix` composes `mesh.worldMatrix × mesh.boundMin/boundMax` directly\n * (`lib/shadow/shadow-base.js` 54) and never consults the `_expandWorldBounds` hook\n * `enableThinInstanceWorldBounds` installs, so a cloud left at its prototype's box casts nothing\n * (measured on SwiftShader, 2026-09-08). {@link InstancedMeshInstance.applyBounds} publishes the\n * union of the live placements instead; culling accuracy is unaffected because each instance's cull\n * sphere comes from the real vertices (`lib/mesh/thin-instance-gpu-culling.js` 426).\n */\n\n/** What the component remembers between uploads. Mutated in place, so a frame allocates nothing. */\nexport interface InstancedUploadState {\n /** The whole slab has to be re-pointed and re-uploaded. */\n isSlabDirty: boolean;\n /** The caller mutated the slab in place, so the active range has to be re-uploaded. */\n isRangeDirty: boolean;\n /** The count the meshes were last told about. */\n appliedCount: number;\n /** The capacity the meshes were built with. */\n appliedCapacity: number;\n /** Whether the union bounds have been published at least once. */\n hasAppliedBounds: boolean;\n /** Whether the last upload carried a colour slab. */\n hadColors: boolean;\n}\n\n/** The LOD switch the component declares, as much of it as the adapter reads. */\nexport interface InstancedLodFields {\n /** The camera distance at which an instance switches to the partner. */\n readonly distance: number;\n /** The width of the per-instance dither window. */\n readonly band: number;\n}\n\n/** The LOD partner an instance is built with. */\nexport interface InstancedLodConfig {\n /** The coarse template to clone. */\n readonly template: LiteMesh;\n /** The camera distance, in world units, at which an instance switches to the partner. */\n readonly distance: number;\n /** The width of the per-instance dither window centred on `distance`. */\n readonly band: number;\n}\n\n/** The settings Lite fixes when the meshes are built. */\nexport interface InstancedMeshSettings {\n /** The largest instance count the meshes will ever draw. */\n readonly capacity: number;\n /** Whether the compute culling pass runs. */\n readonly gpuCulling: boolean;\n /** The LOD partner, or `null`. */\n readonly lod: InstancedLodConfig | null;\n}\n\n/**\n * A live instanced mesh, and its LOD partner, in a scene.\n *\n * @internal\n */\nexport class InstancedMeshInstance {\n /** The cloned near mesh, parented under the entity's node. */\n readonly clone: LiteSceneNode;\n\n readonly #lod: LiteSceneNode | null;\n\n #material: LiteMaterial;\n\n #receiveShadows: boolean | null = null;\n\n #renderOrder = Number.NaN;\n\n #pickable: boolean | null = null;\n\n #visible = false;\n\n #lodDistance: number;\n\n #lodBand: number;\n\n readonly #nearBox: Float64Array;\n\n readonly #lodBox: Float64Array | null;\n\n readonly #union = new Float64Array(6);\n\n /**\n * Clones the templates, gives them thin instances, applies the baked settings in Lite's required\n * order, and adds them to the scene.\n *\n * @param scene - The render scene.\n * @param template - The near mesh's template.\n * @param parent - The entity's transform node.\n * @param tag - The owning entity and component, for picking.\n * @param meshId - The string id Lite's light include/exclude sets match on.\n * @param material - The material both meshes draw with. Assigned **before** the meshes join the\n * scene, for the reason `MeshInstance`'s constructor records: `addToScene` buckets a mesh by its\n * material's build group.\n * @param settings - Capacity, GPU culling, and the LOD pairing.\n * @param matrices - The matrix slab, caller-owned and never copied.\n * @param count - How many instances draw.\n * @param colors - Four floats per instance, or `null`.\n */\n constructor(\n scene: LiteScene,\n template: LiteMesh,\n parent: LiteSceneNode,\n tag: NodeTag,\n meshId: string,\n material: LiteMaterial,\n settings: InstancedMeshSettings,\n matrices: Float32Array,\n count: number,\n colors: Float32Array | null,\n ) {\n const clone = cloneMeshUnderNode(template, parent);\n tagNode(clone, tag);\n const mesh = asMesh(clone);\n setMeshId(mesh, meshId);\n setMeshMaterial(mesh, material);\n // A clone shares the template's bound arrays, and `applyBounds` mutates them in place.\n detachMeshBounds(mesh);\n this.#nearBox = readBox(mesh);\n installThinInstances(mesh, settings.capacity, matrices, count, colors);\n enableThinInstanceGpuCulling(mesh, settings.gpuCulling);\n enableThinInstanceDynamicDrawCount(mesh);\n\n const lodConfig = settings.lod;\n let lodClone: LiteSceneNode | null = null;\n let lodBox: Float64Array | null = null;\n if (lodConfig !== null) {\n lodClone = cloneMeshUnderNode(lodConfig.template, parent);\n tagNode(lodClone, tag);\n const lodMesh = asMesh(lodClone);\n setMeshId(lodMesh, `${meshId}#lod`);\n setMeshMaterial(lodMesh, material);\n detachMeshBounds(lodMesh);\n lodBox = readBox(lodMesh);\n installThinInstances(lodMesh, settings.capacity, matrices, count, colors);\n setThinInstanceLodPartner(mesh, lodMesh, { distance: lodConfig.distance, band: lodConfig.band });\n }\n this.#lodBox = lodBox;\n\n this.#material = material;\n this.#lodDistance = lodConfig?.distance ?? 0;\n this.#lodBand = lodConfig?.band ?? 0;\n // Hidden until the first `applyVisible`, so a renderer on an inactive entity never flashes.\n setMeshSubtreeVisible(clone, false);\n addMeshToScene(scene, clone);\n if (lodClone !== null) {\n setMeshSubtreeVisible(lodClone, false);\n addMeshToScene(scene, lodClone);\n }\n this.clone = clone;\n this.#lod = lodClone;\n }\n\n /**\n * Whether the meshes are currently drawn.\n *\n * @returns `true` when Lite's `visible` is set on them.\n */\n get isVisible(): boolean {\n return this.#visible;\n }\n\n /**\n * The near mesh.\n *\n * @returns The clone, typed as a mesh.\n */\n get mesh(): LiteMesh {\n return asMesh(this.clone);\n }\n\n /**\n * The LOD partner.\n *\n * @returns The partner clone, or `null` when the renderer declares no LOD.\n */\n get lodMesh(): LiteMesh | null {\n const lod = this.#lod;\n return lod === null ? null : asMesh(lod);\n }\n\n /**\n * Assigns the material to both meshes, when it changed.\n *\n * @param material - The Lite material to draw with.\n */\n applyMaterial(material: LiteMaterial): void {\n if (material === this.#material) {\n return;\n }\n this.#material = material;\n setMeshMaterial(this.mesh, material);\n const lod = this.lodMesh;\n if (lod !== null) {\n setMeshMaterial(lod, material);\n }\n }\n\n /**\n * Writes the per-mesh flags that changed, to both meshes.\n *\n * @param receiveShadows - Whether shadow maps darken the meshes.\n * @param renderOrder - The sort key within the phase.\n * @param pickable - Whether picking considers the meshes at all.\n */\n applyFlags(receiveShadows: boolean, renderOrder: number, pickable: boolean): void {\n if (this.#receiveShadows !== receiveShadows) {\n this.#receiveShadows = receiveShadows;\n this.#eachMesh(setMeshReceiveShadows, receiveShadows);\n }\n if (this.#renderOrder !== renderOrder) {\n this.#renderOrder = renderOrder;\n this.#eachMesh(setMeshRenderOrder, renderOrder);\n }\n if (this.#pickable !== pickable) {\n this.#pickable = pickable;\n this.#eachMesh(setMeshPickable, pickable);\n }\n }\n\n /**\n * Re-sets the LOD switch distance and dither band, when either changed.\n *\n * @param distance - The camera distance at which an instance switches to the partner.\n * @param band - The width of the per-instance dither window centred on `distance`.\n */\n applyLod(distance: number, band: number): void {\n const lod = this.lodMesh;\n if (lod === null || (distance === this.#lodDistance && band === this.#lodBand)) {\n return;\n }\n this.#lodDistance = distance;\n this.#lodBand = band;\n setThinInstanceLodPartner(this.mesh, lod, { distance, band });\n }\n\n /**\n * Shows or hides both meshes, when the state changed.\n *\n * @param visible - `entity.activeInHierarchy && component.enabled`.\n */\n applyVisible(visible: boolean): void {\n if (visible === this.#visible) {\n return;\n }\n this.#visible = visible;\n setMeshSubtreeVisible(this.clone, visible);\n const lod = this.#lod;\n if (lod !== null) {\n setMeshSubtreeVisible(lod, visible);\n }\n }\n\n /**\n * Re-points both meshes at a matrix slab and re-uploads the active range.\n *\n * @param capacity - The capacity the meshes were built with; re-stating it keeps `_capacity`\n * unchanged, which is what stops Lite from re-creating the GPU buffer.\n * @param matrices - The slab, caller-owned.\n * @param count - How many instances draw.\n * @param colors - Four floats per instance, or `null`.\n */\n applySlab(capacity: number, matrices: Float32Array, count: number, colors: Float32Array | null): void {\n installThinInstances(this.mesh, capacity, matrices, count, colors);\n const lod = this.lodMesh;\n if (lod !== null) {\n installThinInstances(lod, capacity, matrices, count, colors);\n }\n }\n\n /**\n * Changes how many instances draw, by the cheapest route Lite accepts.\n *\n * @param count - The active count, at most the capacity.\n */\n applyCount(count: number): void {\n applyMeshCount(this.mesh, count);\n const lod = this.lodMesh;\n if (lod !== null) {\n applyMeshCount(lod, count);\n }\n }\n\n /**\n * Marks the whole active range dirty, after the caller mutated the slab in place.\n *\n * @param colors - The colour slab, when the renderer has one, so its own dirty range moves too.\n */\n flush(colors: Float32Array | null): void {\n flushThinInstances(this.mesh);\n const lod = this.lodMesh;\n if (lod !== null) {\n flushThinInstances(lod);\n }\n if (colors !== null) {\n setThinInstanceColors(this.mesh, colors);\n if (lod !== null) {\n setThinInstanceColors(lod, colors);\n }\n }\n }\n\n /**\n * Publishes the union of the live instance placements as both meshes' object-local bounds, so a\n * directional light's shadow frustum is fitted to the cloud rather than to the prototype.\n *\n * @remarks\n * `O(count)`, allocation-free, and worth paying only for a caster — see the module note. A count\n * of zero restores the prototype's own box, so an empty cloud does not report an infinite one.\n *\n * @param matrices - The live matrix slab.\n * @param count - How many instances are drawn.\n */\n applyBounds(matrices: Float32Array, count: number): void {\n const near = this.#nearBox;\n const lodBox = this.#lodBox;\n const lod = this.lodMesh;\n if (count <= 0) {\n writeBox(this.mesh, near);\n if (lod !== null && lodBox !== null) {\n writeBox(lod, lodBox);\n }\n return;\n }\n const union = this.#union;\n unionOfPlacements(matrices, count, near, union);\n setMeshBounds(this.mesh, union[0] ?? 0, union[1] ?? 0, union[2] ?? 0, union[3] ?? 0, union[4] ?? 0, union[5] ?? 0);\n if (lod !== null && lodBox !== null) {\n unionOfPlacements(matrices, count, lodBox, union);\n setMeshBounds(lod, union[0] ?? 0, union[1] ?? 0, union[2] ?? 0, union[3] ?? 0, union[4] ?? 0, union[5] ?? 0);\n }\n }\n\n /**\n * Writes everything the component changed since the last frame onto both meshes.\n *\n * @param state - The component's upload state, mutated in place.\n * @param material - The material both meshes draw with.\n * @param receiveShadows - Whether shadow maps darken them.\n * @param renderOrder - The sort key within the phase.\n * @param pickable - Whether picking considers them.\n * @param lod - The LOD record, whose `distance` and `band` Lite re-applies live; `null` for none.\n * @param matrices - The caller-owned matrix slab.\n * @param count - How many instances draw.\n * @param colors - Four floats per instance, or `null`.\n * @param castShadows - Whether the union bounds have to be published for a shadow frustum.\n * @param visible - `entity.activeInHierarchy && component.enabled`.\n * @returns `true` when the compiled pipeline has to change, which only a colour slab arriving or\n * leaving does.\n */\n sync(\n state: InstancedUploadState,\n material: LiteMaterial,\n receiveShadows: boolean,\n renderOrder: number,\n pickable: boolean,\n lod: InstancedLodFields | null,\n matrices: Float32Array,\n count: number,\n colors: Float32Array | null,\n castShadows: boolean,\n visible: boolean,\n ): boolean {\n this.applyMaterial(material);\n this.applyFlags(receiveShadows, renderOrder, pickable);\n if (lod !== null) {\n this.applyLod(lod.distance, lod.band);\n }\n let renderablesChanged = false;\n let placementsMoved = false;\n if (state.isSlabDirty) {\n state.isSlabDirty = false;\n state.isRangeDirty = false;\n this.applySlab(state.appliedCapacity, matrices, count, colors);\n state.appliedCount = count;\n placementsMoved = true;\n const hasColors = colors !== null;\n renderablesChanged = hasColors !== state.hadColors;\n state.hadColors = hasColors;\n } else {\n if (state.isRangeDirty) {\n state.isRangeDirty = false;\n this.flush(colors);\n placementsMoved = true;\n }\n if (count !== state.appliedCount) {\n state.appliedCount = count;\n this.applyCount(count);\n placementsMoved = true;\n }\n }\n // Only a caster pays the `O(count)` bounds pass, and only in a frame whose placements moved.\n if (castShadows && (placementsMoved || !state.hasAppliedBounds)) {\n state.hasAppliedBounds = true;\n this.applyBounds(matrices, count);\n }\n this.applyVisible(visible);\n return renderablesChanged;\n }\n\n /**\n * Appends both meshes to a shadow caster list, when the renderer casts and they are drawn.\n *\n * @param castShadows - Whether the renderer casts.\n * @param out - The caster list being built.\n */\n collectCasters(castShadows: boolean, out: LiteMesh[]): void {\n if (!castShadows || !this.#visible) {\n return;\n }\n out.push(this.mesh);\n const lod = this.lodMesh;\n if (lod !== null) {\n out.push(lod);\n }\n }\n\n /**\n * Dissolves the LOD pairing and removes both meshes from the scene, releasing their share of the\n * templates' buffers.\n *\n * @param scene - The render scene.\n */\n destroy(scene: LiteScene): void {\n const lod = this.#lod;\n if (lod !== null) {\n clearThinInstanceLodPartner(this.mesh);\n removeMeshFromScene(scene, lod);\n }\n removeMeshFromScene(scene, this.clone);\n }\n\n /**\n * Runs a per-mesh Lite setter over the near mesh and the partner.\n *\n * @typeParam T - The setter's value type.\n * @param write - The adapter function to call.\n * @param value - What to write.\n */\n #eachMesh<T>(write: (mesh: LiteMesh, value: T) => void, value: T): void {\n write(this.mesh, value);\n const lod = this.lodMesh;\n if (lod !== null) {\n write(lod, value);\n }\n }\n}\n\n/**\n * Builds the live meshes, filling in the LOD pairing when both templates exist.\n *\n * @param scene - The render scene.\n * @param template - The near mesh's template.\n * @param lodTemplate - The coarse template, or `null`.\n * @param lod - The LOD record the component declares, or `null`.\n * @param parent - The entity's transform node.\n * @param tag - The owning entity and component, for picking.\n * @param meshId - The string id Lite's light include/exclude sets match on.\n * @param material - The material both meshes draw with.\n * @param capacity - The largest instance count the meshes will ever draw.\n * @param gpuCulling - Whether the compute culling pass runs.\n * @param matrices - The matrix slab.\n * @param count - How many instances draw.\n * @param colors - Four floats per instance, or `null`.\n * @returns The instance.\n *\n * @internal\n */\nexport function createInstancedMesh(\n scene: LiteScene,\n template: LiteMesh,\n lodTemplate: LiteMesh | null,\n lod: InstancedLodFields | null,\n parent: LiteSceneNode,\n tag: NodeTag,\n meshId: string,\n material: LiteMaterial,\n capacity: number,\n gpuCulling: boolean,\n matrices: Float32Array,\n count: number,\n colors: Float32Array | null,\n): InstancedMeshInstance {\n const pairing: InstancedLodConfig | null =\n lodTemplate === null || lod === null ? null : { template: lodTemplate, distance: lod.distance, band: lod.band };\n return new InstancedMeshInstance(\n scene,\n template,\n parent,\n tag,\n meshId,\n material,\n { capacity, gpuCulling, lod: pairing },\n matrices,\n count,\n colors,\n );\n}\n\n/**\n * Removes the meshes from the scene, when there are any.\n *\n * @param instance - The live meshes, or `null`.\n * @param scene - The render scene.\n * @returns `true` when something left the scene.\n *\n * @internal\n */\nexport function releaseInstancedMesh(instance: InstancedMeshInstance | null, scene: LiteScene): boolean {\n if (instance === null) {\n return false;\n }\n instance.destroy(scene);\n return true;\n}\n\n/**\n * Gives one mesh its thin instances in the order Lite requires, at a fixed capacity.\n *\n * @remarks\n * `setThinInstances` is handed the **capacity** so that `_capacity` — and the GPU buffer it sizes —\n * never moves; the active count is then lowered in the same breath, before any frame can read the\n * range in between (`src/lite/gpu/thin-instances.ts`).\n *\n * @param mesh - The mesh to instance.\n * @param capacity - The capacity to fix.\n * @param matrices - The slab, caller-owned.\n * @param count - How many instances draw.\n * @param colors - Four floats per instance, or `null`.\n */\nfunction installThinInstances(\n mesh: LiteMesh,\n capacity: number,\n matrices: Float32Array,\n count: number,\n colors: Float32Array | null,\n): void {\n setThinInstances(mesh, matrices, capacity);\n setThinInstanceCount(mesh, count);\n setThinInstanceColors(mesh, colors);\n enableThinInstanceWorldBounds(mesh);\n}\n\n/**\n * Changes one mesh's active count without re-uploading when Lite allows it, and with a re-upload\n * when it does not.\n *\n * @param mesh - The instanced mesh.\n * @param count - The active count.\n */\nfunction applyMeshCount(mesh: LiteMesh, count: number): void {\n if (!trySetThinInstanceDrawCount(mesh, count)) {\n setThinInstanceCount(mesh, count);\n }\n}\n\n/**\n * Reads a mesh's object-local box into six numbers.\n *\n * @remarks\n * A mesh built by any Lite factory carries bounds; the fallback half-metre cube is the same default\n * `computeDirectionalLightMatrix` uses for a mesh that does not\n * (`lib/shadow/shadow-base.js` 62).\n *\n * @param mesh - The mesh to read.\n * @returns `minX, minY, minZ, maxX, maxY, maxZ`.\n */\nfunction readBox(mesh: LiteMesh): Float64Array {\n const min = mesh.boundMin ?? [-0.5, -0.5, -0.5];\n const max = mesh.boundMax ?? [0.5, 0.5, 0.5];\n return Float64Array.of(min[0], min[1], min[2], max[0], max[1], max[2]);\n}\n\n/**\n * Writes a six-number box back onto a mesh.\n *\n * @param mesh - The mesh to re-bound.\n * @param box - `minX, minY, minZ, maxX, maxY, maxZ`.\n */\nfunction writeBox(mesh: LiteMesh, box: Float64Array): void {\n setMeshBounds(mesh, box[0] ?? 0, box[1] ?? 0, box[2] ?? 0, box[3] ?? 0, box[4] ?? 0, box[5] ?? 0);\n}\n\n/**\n * The axis-aligned union of a prototype box placed under every live instance matrix.\n *\n * @remarks\n * The same oriented-box-to-AABB composition Lite's own\n * `expandThinInstanceWorldBounds` uses, minus the world matrix — because `Mesh.boundMin`/`boundMax`\n * are documented to be **object-local**, the frame `worldMatrix` maps out of. Degenerate matrices\n * are skipped, exactly as Lite skips them, so a slot that has not been written yet does not drag\n * the box to the origin.\n *\n * @param matrices - The slab, 16 column-major floats per instance.\n * @param count - How many instances to consider.\n * @param box - The prototype's own box.\n * @param out - Receives `minX, minY, minZ, maxX, maxY, maxZ`.\n */\nfunction unionOfPlacements(matrices: Float32Array, count: number, box: Float64Array, out: Float64Array): void {\n const centreX = ((box[0] ?? 0) + (box[3] ?? 0)) * 0.5;\n const centreY = ((box[1] ?? 0) + (box[4] ?? 0)) * 0.5;\n const centreZ = ((box[2] ?? 0) + (box[5] ?? 0)) * 0.5;\n const extentX = ((box[3] ?? 0) - (box[0] ?? 0)) * 0.5;\n const extentY = ((box[4] ?? 0) - (box[1] ?? 0)) * 0.5;\n const extentZ = ((box[5] ?? 0) - (box[2] ?? 0)) * 0.5;\n out[0] = Number.POSITIVE_INFINITY;\n out[1] = Number.POSITIVE_INFINITY;\n out[2] = Number.POSITIVE_INFINITY;\n out[3] = Number.NEGATIVE_INFINITY;\n out[4] = Number.NEGATIVE_INFINITY;\n out[5] = Number.NEGATIVE_INFINITY;\n const usable = Math.min(count, Math.floor(matrices.length / 16));\n let placed = 0;\n for (let index = 0; index < usable; index += 1) {\n const base = index * 16;\n let scale = 0;\n for (let element = 0; element < 12; element += 1) {\n if (element % 4 !== 3) {\n scale += Math.abs(matrices[base + element] ?? 0);\n }\n }\n if (scale < 1e-9) {\n continue;\n }\n placed += 1;\n for (let row = 0; row < 3; row += 1) {\n const m0 = matrices[base + row] ?? 0;\n const m1 = matrices[base + 4 + row] ?? 0;\n const m2 = matrices[base + 8 + row] ?? 0;\n const centre = (matrices[base + 12 + row] ?? 0) + m0 * centreX + m1 * centreY + m2 * centreZ;\n const radius = Math.abs(m0) * extentX + Math.abs(m1) * extentY + Math.abs(m2) * extentZ;\n const low = centre - radius;\n const high = centre + radius;\n if (low < (out[row] ?? 0)) {\n out[row] = low;\n }\n if (high > (out[row + 3] ?? 0)) {\n out[row + 3] = high;\n }\n }\n }\n if (placed === 0) {\n out.set(box);\n }\n}\n\n/**\n * Narrows a cloned subtree root to a mesh.\n *\n * @remarks\n * The same boundary assertion `MeshInstance` makes, for the same reason: `cloneTransformNode` is\n * typed as returning the wider `SceneNode` because it also clones plain transform nodes, and the\n * clone of a mesh is a mesh (coding standards §5.2).\n *\n * @param node - The clone.\n * @returns The same object, typed as a mesh.\n */\nfunction asMesh(node: LiteSceneNode): LiteMesh {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- see the note above.\n return node as LiteMesh;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgBA,mBAAiB,MAAY,UAAwB,UAAwB;CAC3F,iBAAqB,MAAM,UAAU,QAAQ;AAC/C;;;;;;;;;;;;;AAcA,SAAgBC,uBAAqB,MAAY,OAAqB;CACpE,qBAAyB,MAAM,KAAK;AACtC;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,4BAA4B,MAAY,OAAwB;CAC9E,IAAI;EACF,yBAA6B,MAAM,KAAK;EACxC,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;AASA,SAAgBC,qBAAmB,MAAkB;CACnD,mBAAuB,IAAI;AAC7B;;;;;;;;;;;;;;;;;AAkBA,SAAgBC,wBAAsB,MAAY,QAAmC;CACnF,IAAI,WAAW,MAAM;EACnB,sBAA0B,MAAM,MAAM;EACtC;CACF;CAC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EAGnD,IAAI,QAAQ,MACV;EAEF,UAAU;EACV,KAAK,IAAI,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG;GACnC,MAAM,KAAK,SAAS,OAAO,QAAQ;GACnC,MAAM,KAAK,SAAS,OAAO,IAAI,QAAQ;GACvC,MAAM,KAAK,SAAS,OAAO,IAAI,QAAQ;GACvC,MAAM,UAAU,SAAS,OAAO,KAAK,QAAQ,KAAK,KAAK,UAAU,KAAK,UAAU,KAAK;GACrF,MAAM,SAAS,KAAK,IAAI,EAAE,IAAI,UAAU,KAAK,IAAI,EAAE,IAAI,UAAU,KAAK,IAAI,EAAE,IAAI;GAChF,MAAM,MAAM,SAAS;GACrB,MAAM,OAAO,SAAS;GACtB,IAAI,OAAO,IAAI,QAAQ,IACrB,IAAI,OAAO;GAEb,IAAI,QAAQ,IAAI,MAAM,MAAM,IAC1B,IAAI,MAAM,KAAK;EAEnB;CACF;CACA,IAAI,WAAW,GACb,IAAI,IAAI,GAAG;AAEf;;;;;;;;;;;;AAaA,SAAS,OAAO,MAA+B;CAE7C,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"material-plugin-Cfw_h_Mg.js","names":[],"sources":["../src/lite/material.ts","../src/render/material-plugin.ts"],"sourcesContent":["import {\n createPbrMaterial,\n createStandardMaterial,\n enableMaterialTracking,\n markMaterialUboDirty,\n rebuildMaterial,\n setPbrAlphaCutoff,\n setPbrEmissive,\n setPbrUnlit,\n setStandardBumpTexture,\n setStandardEmissiveTexture,\n setStandardOpacityTexture,\n setStandardSpecularTexture,\n} from \"@babylonjs/lite\";\nimport { assertNever } from \"../errors/ignifx-error.js\";\nimport type { Material, PbrMaterialProps, SceneContext, StandardMaterialProps, Texture2D } from \"@babylonjs/lite\";\n\n/**\n * Material half of the Babylon Lite adapter (`docs/architecture/07-rendering.md` §2.6): the three\n * material kinds a `MaterialAsset` can produce, built from plain ignifx props.\n *\n * Everything here is `@internal`, and every colour that reaches it is **linear** — the sRGB decode\n * belongs to the asset layer.\n *\n * ## What a Lite material is (verified against `@babylonjs/lite@1.27.0`)\n *\n * - A material is plain data plus one private `_buildGroup` function; `createPbrMaterial` is\n * literally `{ ...props, _buildGroup, _uboVersion: 0 }` (`lib/material/pbr/pbr-material.js`), so\n * none of these factories touches the GPU and all of them run under the null engine.\n * - **The build group is a per-family singleton.** `getPbrGroupBuilder()`, `getStandardGroupBuilder()`\n * and `getShaderGroupBuilder()` each memoise one function for the whole process\n * (`lib/material/pbr/pbr-material.js`, `lib/material/standard/create-standard-material.js`,\n * `lib/material/shader/shader-material.js` line 123), and a scene keys its renderable groups by\n * that function (`lib/scene/scene-core.js`, `addToScene`). \"Material family\" in\n * `docs/architecture/07-rendering.md` §1.1 therefore means *pbr*, *standard*, *shader* or *node* —\n * **not** an individual material. Only node materials get a per-material builder\n * (`lib/material/node/node-material.js`). This is what makes {@link warmUpMaterialFamilies} in\n * `./gpu/warm-up.ts` cheap: one hidden mesh per family covers every material in it.\n * - Scalar and vector edits only need `markMaterialUboDirty` (`index.d.ts` 6974), which bumps\n * `_uboVersion`. Anything that changes the compiled feature set — binding or clearing a texture,\n * flipping `doubleSided`, changing culling — needs {@link rebuildMaterialPipelines}.\n *\n * ## The custom WGSL family lives elsewhere\n *\n * `createShaderMaterial` and the `setShader*` setters are in `./gpu/shader-material.ts`, not here:\n * this module is statically reachable from every app through the material asset layer, and Babylon\n * Lite exports one barrel, so a static import of the shader factory would put Lite's whole\n * shader-material pipeline in every entry chunk. That module is reached through a dynamic\n * `import()` instead (`docs/plan/2026-09-terrain-particles-shaders.md` §3.1, \"Bundle cost\").\n */\n\n/**\n * The Babylon Lite material a `MaterialAsset` owns, re-exported under an ignifx name\n * (`CONSTITUTION.md` §3.4, coding standards §4).\n *\n * @remarks\n * Unstable; excluded from the stability guarantees of `CONSTITUTION.md` Article IV.\n *\n * @public\n */\nexport type LiteMaterial = Material;\n\n/**\n * A Babylon Lite physically based material, re-exported under an ignifx name.\n *\n * @remarks\n * Unstable; excluded from the stability guarantees of `CONSTITUTION.md` Article IV.\n *\n * @public\n */\nexport type LitePbrMaterial = PbrMaterialProps;\n\n/**\n * A Babylon Lite Babylon-Standard material, re-exported under an ignifx name.\n *\n * @remarks\n * Unstable; excluded from the stability guarantees of `CONSTITUTION.md` Article IV.\n *\n * @public\n */\nexport type LiteStandardMaterial = StandardMaterialProps;\n\n/** glTF's default alpha cutoff, used when a `\"mask\"` material declares none. */\nconst DEFAULT_ALPHA_CUTOFF = 0.5;\n\n/**\n * How a material's alpha channel is interpreted, in glTF's vocabulary, in the order the inspector\n * lists them (`docs/architecture/07-rendering.md` §2.4).\n *\n * @public\n */\nexport const MATERIAL_ALPHA_MODES = [\"opaque\", \"mask\", \"blend\"] as const;\n\n/**\n * The union of the alpha modes a material can declare.\n *\n * @public\n */\nexport type MaterialAlphaMode = (typeof MATERIAL_ALPHA_MODES)[number];\n\n/**\n * The physically based material properties an ignifx `.material.json` declares\n * (`docs/architecture/06-serialization-and-scene-format.md` §6). Every field is optional; an\n * omitted field leaves Lite's own default in place.\n *\n * @internal\n */\nexport interface PbrMaterialInput {\n /** A human-readable name, used for glTF material overrides and diagnostics. */\n readonly name?: string;\n /** Linear base colour and alpha, multiplied with the base colour texture. */\n readonly baseColor?: readonly [number, number, number, number];\n /** The base colour texture. Load it with an sRGB format. */\n readonly baseColorTexture?: Texture2D;\n /** Metallic factor, 0 to 1. */\n readonly metallic?: number;\n /** Roughness factor, 0 to 1. */\n readonly roughness?: number;\n /** The packed occlusion/roughness/metallic texture (glTF `ORM`). */\n readonly metallicRoughnessTexture?: Texture2D;\n /** The tangent-space normal map. */\n readonly normalTexture?: Texture2D;\n /** Normal map strength. */\n readonly normalScale?: number;\n /** Linear emissive colour. */\n readonly emissive?: readonly [number, number, number];\n /** The emissive texture. */\n readonly emissiveTexture?: Texture2D;\n /** A separate occlusion texture, sampled on UV1 when the ORM texture is not used for it. */\n readonly occlusionTexture?: Texture2D;\n /** How strongly ambient occlusion darkens the surface, 0 to 1. */\n readonly occlusionStrength?: number;\n /** How the alpha channel is interpreted. */\n readonly alphaMode?: MaterialAlphaMode;\n /** The cutoff below which a `\"mask\"` material discards a fragment. */\n readonly alphaCutoff?: number;\n /** Overall material alpha, 0 to 1. */\n readonly alpha?: number;\n /** Whether back faces are drawn. */\n readonly doubleSided?: boolean;\n /** Whether lighting is skipped entirely. */\n readonly unlit?: boolean;\n /** How strongly the environment map contributes. */\n readonly environmentIntensity?: number;\n}\n\n/**\n * The Babylon-Standard material properties an ignifx `.material.json` declares, for the cheap\n * non-PBR path (`docs/architecture/07-rendering.md` §2.6).\n *\n * @internal\n */\nexport interface StandardMaterialInput {\n /** A human-readable name. */\n readonly name?: string;\n /** Linear diffuse colour. */\n readonly diffuse?: readonly [number, number, number];\n /** The diffuse texture. */\n readonly diffuseTexture?: Texture2D;\n /** Linear specular colour. */\n readonly specular?: readonly [number, number, number];\n /** Specular exponent; higher values give a tighter highlight. */\n readonly specularPower?: number;\n /** The specular texture. */\n readonly specularTexture?: Texture2D;\n /** Linear emissive colour. */\n readonly emissive?: readonly [number, number, number];\n /** The emissive texture. */\n readonly emissiveTexture?: Texture2D;\n /** The tangent-space normal map. */\n readonly normalTexture?: Texture2D;\n /** The opacity texture. */\n readonly opacityTexture?: Texture2D;\n /** Overall material alpha, 0 to 1. */\n readonly alpha?: number;\n /** The cutoff below which a fragment is discarded. `0` disables the alpha test. */\n readonly alphaCutoff?: number;\n /** Whether back faces are drawn. */\n readonly doubleSided?: boolean;\n /** Whether lighting is skipped entirely. */\n readonly unlit?: boolean;\n}\n\n/**\n * Builds a Lite PBR material from ignifx props.\n *\n * @param input - The declared properties.\n * @returns The material. It holds no GPU resource of its own; the textures it references do.\n *\n * @example\n * ```ts\n * const gold = createPbrMaterialFromProps({ baseColor: [1, 0.77, 0.34, 1], metallic: 1, roughness: 0.25 });\n * ```\n *\n * @internal\n */\nexport function createPbrMaterialFromProps(input: PbrMaterialInput): PbrMaterialProps {\n const props: Partial<PbrMaterialProps> = {};\n if (input.name !== undefined) {\n props.name = input.name;\n }\n if (input.baseColor !== undefined) {\n props.baseColorFactor = [input.baseColor[0], input.baseColor[1], input.baseColor[2], input.baseColor[3]];\n }\n if (input.baseColorTexture !== undefined) {\n props.baseColorTexture = input.baseColorTexture;\n }\n if (input.metallic !== undefined) {\n props.metallicFactor = input.metallic;\n }\n if (input.roughness !== undefined) {\n props.roughnessFactor = input.roughness;\n }\n if (input.metallicRoughnessTexture !== undefined) {\n props.ormTexture = input.metallicRoughnessTexture;\n }\n if (input.normalTexture !== undefined) {\n props.normalTexture = input.normalTexture;\n }\n if (input.normalScale !== undefined) {\n props.normalTextureScale = input.normalScale;\n }\n if (input.emissiveTexture !== undefined) {\n props.emissiveTexture = input.emissiveTexture;\n }\n if (input.occlusionTexture !== undefined) {\n props.occlusionTexture = input.occlusionTexture;\n }\n if (input.occlusionStrength !== undefined) {\n props.occlusionStrength = input.occlusionStrength;\n }\n if (input.alpha !== undefined) {\n props.alpha = input.alpha;\n }\n if (input.doubleSided !== undefined) {\n props.doubleSided = input.doubleSided;\n }\n if (input.environmentIntensity !== undefined) {\n props.environmentIntensity = input.environmentIntensity;\n }\n if (input.alphaMode === \"blend\") {\n props.alphaBlend = true;\n }\n const material = createPbrMaterial(props);\n if (input.alphaMode === \"mask\") {\n setPbrAlphaCutoff(material, input.alphaCutoff ?? DEFAULT_ALPHA_CUTOFF);\n }\n if (input.emissive !== undefined) {\n setPbrEmissive(material, [input.emissive[0], input.emissive[1], input.emissive[2]]);\n }\n if (input.unlit === true) {\n setPbrUnlit(material);\n }\n return material;\n}\n\n/**\n * Builds a Lite Standard material from ignifx props.\n *\n * @param input - The declared properties.\n * @returns The material.\n *\n * @internal\n */\nexport function createStandardMaterialFromProps(input: StandardMaterialInput): StandardMaterialProps {\n const material = createStandardMaterial();\n if (input.name !== undefined) {\n material.name = input.name;\n }\n if (input.diffuse !== undefined) {\n writeTriple(material.diffuseColor, input.diffuse);\n }\n if (input.specular !== undefined) {\n writeTriple(material.specularColor, input.specular);\n }\n if (input.emissive !== undefined) {\n writeTriple(material.emissiveColor, input.emissive);\n }\n if (input.specularPower !== undefined) {\n material.specularPower = input.specularPower;\n }\n if (input.alpha !== undefined) {\n material.alpha = input.alpha;\n }\n if (input.alphaCutoff !== undefined) {\n material.alphaCutOff = input.alphaCutoff;\n }\n if (input.doubleSided !== undefined) {\n material.backFaceCulling = !input.doubleSided;\n }\n if (input.unlit !== undefined) {\n material.disableLighting = input.unlit;\n }\n if (input.diffuseTexture !== undefined) {\n material.diffuseTexture = input.diffuseTexture;\n }\n if (input.specularTexture !== undefined) {\n setStandardSpecularTexture(material, input.specularTexture);\n }\n if (input.emissiveTexture !== undefined) {\n setStandardEmissiveTexture(material, input.emissiveTexture);\n }\n if (input.normalTexture !== undefined) {\n setStandardBumpTexture(material, input.normalTexture);\n }\n if (input.opacityTexture !== undefined) {\n setStandardOpacityTexture(material, input.opacityTexture);\n }\n return material;\n}\n\n/**\n * The material a `MeshRenderer` uses when it declares none: a neutral, fully rough dielectric.\n *\n * @returns A fresh material. Callers share one instance per app rather than one per renderer.\n *\n * @internal\n */\nexport function createDefaultMaterial(): PbrMaterialProps {\n return createPbrMaterialFromProps({\n name: \"ignifx:default\",\n baseColor: [1, 1, 1, 1],\n metallic: 0,\n roughness: 0.9,\n });\n}\n\n/**\n * Replaces a PBR material's linear base colour.\n *\n * @param material - The material to change.\n * @param r - The linear red component.\n * @param g - The linear green component.\n * @param b - The linear blue component.\n * @param a - The alpha component.\n *\n * @internal\n */\nexport function setPbrBaseColor(material: PbrMaterialProps, r: number, g: number, b: number, a: number): void {\n const factor = material.baseColorFactor;\n if (factor === undefined) {\n material.baseColorFactor = [r, g, b, a];\n } else {\n factor[0] = r;\n factor[1] = g;\n factor[2] = b;\n factor[3] = a;\n }\n markMaterialDirty(material);\n}\n\n/**\n * Replaces a PBR material's metallic and roughness factors.\n *\n * @param material - The material to change.\n * @param metallic - The metallic factor, 0 to 1.\n * @param roughness - The roughness factor, 0 to 1.\n *\n * @internal\n */\nexport function setPbrMetallicRoughness(material: PbrMaterialProps, metallic: number, roughness: number): void {\n material.metallicFactor = metallic;\n material.roughnessFactor = roughness;\n markMaterialDirty(material);\n}\n\n/**\n * Replaces a material's overall alpha.\n *\n * @param material - The PBR or Standard material to change.\n * @param alpha - The new alpha, 0 to 1.\n *\n * @internal\n */\nexport function setMaterialAlpha(material: PbrMaterialProps | StandardMaterialProps, alpha: number): void {\n material.alpha = alpha;\n markMaterialDirty(material);\n}\n\n/**\n * Marks a material's uniform block for re-upload on the next frame.\n *\n * @remarks\n * This is the cheap path and covers every scalar, vector, and colour edit. It does **not** cover\n * changes that alter the compiled feature set; those go through {@link rebuildMaterialPipelines}.\n *\n * @param material - The material that changed.\n *\n * @internal\n */\nexport function markMaterialDirty(material: Material): void {\n markMaterialUboDirty(material);\n}\n\n/**\n * Rebuilds the renderables of a material whose compiled feature set changed.\n *\n * @remarks\n * Needed after binding or clearing a texture, changing culling, or toggling a sub-feature\n * (`index.d.ts` 9413). `rebuildFrameGraph` is left off so a component can batch several material\n * edits and rebuild the frame graph once.\n *\n * @param scene - The scene the material renders in.\n * @param material - The material that changed.\n *\n * @internal\n */\nexport function rebuildMaterialPipelines(scene: SceneContext, material: Material): void {\n rebuildMaterial(scene, material);\n}\n\n/**\n * Installs automatic dirty tracking on a material, so property writes mark its uniform block\n * without an explicit {@link markMaterialDirty}.\n *\n * @remarks\n * Lite installs the tracker by rewriting the material's property descriptors, and the module that\n * does it is loaded lazily, so this is asynchronous (`index.d.ts` 4480,\n * `lib/material/observable-material.js`). Opt-in only: it costs an accessor call per write, which\n * the zero-allocation rules (coding standards §7) do not want on every material.\n *\n * @param material - The PBR or Standard material to track.\n * @returns A promise that resolves once the tracker is installed.\n *\n * @internal\n */\nexport function enableMaterialChangeTracking(material: PbrMaterialProps | StandardMaterialProps): Promise<void> {\n return enableMaterialTracking(material);\n}\n\n/**\n * Reports whether Lite will alpha-blend a material declared with this alpha mode.\n *\n * @param mode - The declared alpha mode.\n * @returns `true` for `\"blend\"`, `false` for `\"opaque\"` and `\"mask\"`.\n *\n * @internal\n */\nexport function isBlendedAlphaMode(mode: MaterialAlphaMode): boolean {\n switch (mode) {\n case \"opaque\":\n case \"mask\":\n return false;\n case \"blend\":\n return true;\n default:\n return assertNever(mode, \"material alpha mode\");\n }\n}\n\n/**\n * Writes three components into a Lite colour tuple in place.\n *\n * @param target - The tuple Lite owns.\n * @param source - The values to copy.\n */\nfunction writeTriple(target: [number, number, number], source: readonly [number, number, number]): void {\n target[0] = source[0];\n target[1] = source[1];\n target[2] = source[2];\n}\n","import { CoreErrorCode } from \"../errors/error-codes.js\";\nimport { assertNever, IgnifxError } from \"../errors/ignifx-error.js\";\nimport { SHADER_UNIFORM_TYPES } from \"./shader-declaration.js\";\nimport type { ShaderTextureDeclaration, ShaderUniformDeclaration, ShaderUniformType } from \"./shader-declaration.js\";\n\n/**\n * The raw Babylon Lite material-plugin points, as a `@beta` escape hatch\n * (`docs/plan/2026-09-terrain-particles-shaders.md` §3.2, ADR-0024).\n *\n * `@beta` because the meaning of each point is whatever the surrounding Lite template declares at\n * that line; ignifx's stable contract is the three hooks of `./surface-shader.ts`. Four rules read\n * out of `@babylonjs/lite@1.27.0`'s `lib/` on 2026-09-08:\n *\n * - Plugin uniforms and samplers are **fragment-stage only** on both families\n * (`lib/material/plugin/plugin-bridge-shared.js` 99), and there is no vertex helper-function\n * channel, so vertex code may read only attributes, `mesh.world` and the scene block, and must be\n * statements rather than functions.\n * - `CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION` is injected **twice** — Lite maps it to the two\n * adjacent PBR slots `AI` and `NI` — so its code must be idempotent or guard itself with a flag\n * set at an earlier point, and must declare nothing at statement level.\n * - Only PBR carries `CUSTOM_FRAGMENT_UPDATE_DIFFUSE` after `CUSTOM_FRAGMENT_UPDATE_ALPHA`;\n * Standard's template orders them the other way and has no `AI`/`NI`/`MF` slots.\n * - `roughness` and `metallic` are `let` in the PBR template and cannot be written.\n */\n\n/**\n * The Babylon Lite injection points a {@link MaterialPluginDefinition} may fill in.\n *\n * @remarks\n * The names are Lite's own (`MaterialPluginPoint`, `index.d.ts` 7084) and are taught verbatim,\n * because a plugin's code is written against the template around the point.\n *\n * @beta\n */\nexport const LITE_MATERIAL_PLUGIN_POINTS = [\n \"CUSTOM_FRAGMENT_DEFINITIONS\",\n \"CUSTOM_FRAGMENT_MAIN_BEGIN\",\n \"CUSTOM_FRAGMENT_UPDATE_ALPHA\",\n \"CUSTOM_FRAGMENT_UPDATE_DIFFUSE\",\n \"CUSTOM_FRAGMENT_BEFORE_LIGHTS\",\n \"CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION\",\n \"CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\",\n \"CUSTOM_VERTEX_MAIN_BEGIN\",\n \"CUSTOM_VERTEX_UPDATE_WORLDPOS\",\n \"CUSTOM_VERTEX_MAIN_END\",\n] as const;\n\n/**\n * One of Babylon Lite's ten material-plugin injection points.\n *\n * @beta\n */\nexport type LiteMaterialPluginPoint = (typeof LITE_MATERIAL_PLUGIN_POINTS)[number];\n\n/**\n * The default priority Babylon Lite gives a plugin with none (`index.d.ts` 7057).\n *\n * @beta\n */\nexport const MATERIAL_PLUGIN_DEFAULT_PRIORITY = 500;\n\n/**\n * How many `texture`/`sampler` pairs one material's plugins may declare together.\n *\n * @remarks\n * Measured on a device on 2026-09-08 (spike S0.2): a fully textured PBR material — base colour,\n * normal, ORM, emissive — with image-based lighting and one PCF shadow light already binds seven\n * textures and seven samplers of the sixteen per stage that every WebGPU implementation guarantees,\n * SwiftShader included, and Lite requests no higher `requiredLimits`. Nine is what is left, and it\n * drops to eight with a second shadow light and seven with a lightmap, so a material that means to\n * be portable should stay well under the cap.\n *\n * @beta\n */\nexport const MATERIAL_PLUGIN_SAMPLER_BUDGET = 9;\n\n/**\n * The WGSL names the PBR and Standard templates already own, which a plugin may not reuse for a\n * uniform field or a sampler.\n *\n * @remarks\n * A plugin's fields land in the host's own uniform block and its samplers in the host's own bind\n * group, so a collision is a duplicate WGSL declaration and the whole material stops compiling with\n * a message that names neither the plugin nor the field. Refusing at attach time is the difference\n * between a sentence and a shader dump. Read from `pbr-template.js` `_baseMaterialUboFields` and\n * `_baseBindings`, and `standard-template.js` `materialStruct` and `_baseBindings`.\n *\n * @beta\n */\nexport const MATERIAL_PLUGIN_RESERVED_NAMES: readonly string[] = Object.freeze([\n // Blocks and entry points the templates declare.\n \"material\",\n \"mesh\",\n \"scene\",\n \"lights\",\n \"pluginUbo\",\n \"shadowParams\",\n \"main\",\n // PBR material uniform fields.\n \"environmentIntensity\",\n \"directIntensity\",\n \"reflectance\",\n \"materialAlpha\",\n \"baseColorFactor\",\n \"metallicFactor\",\n \"roughnessFactor\",\n \"normalScale\",\n \"lightFalloffMode\",\n \"anisotropyParams\",\n // PBR samplers.\n \"baseColorTexture\",\n \"baseColorSampler\",\n \"normalTexture\",\n \"normalSampler_\",\n \"ormTexture\",\n \"ormSampler\",\n \"emissiveTexture\",\n \"emissiveSampler\",\n \"specGlossTexture\",\n \"specGlossSampler\",\n // Standard samplers (`standard-template.js` uses two-letter names).\n \"dT\",\n \"dS\",\n \"mat\",\n \"up\",\n]);\n\n/**\n * What a raw material plugin declares: a name, the values and textures it wants beside the host\n * material's own, and the WGSL it injects.\n *\n * @beta\n */\nexport interface MaterialPluginDefinition {\n /** The plugin's identity. It is part of Lite's pipeline cache key, so it must be stable. */\n readonly name: string;\n /** Lower runs first; Lite's own default is {@link MATERIAL_PLUGIN_DEFAULT_PRIORITY}. */\n readonly priority: number;\n /** The uniform fields appended to the host material's uniform block. Fragment stage only. */\n readonly uniforms: readonly ShaderUniformDeclaration[];\n /** The `texture`/`sampler` pairs added to the host material's bind group. Fragment stage only. */\n readonly textures: readonly ShaderTextureDeclaration[];\n /** The WGSL to inject, by point. Vertex points take statements; there are no vertex helpers. */\n readonly code: Readonly<Partial<Record<LiteMaterialPluginPoint, string>>>;\n}\n\n/**\n * The properties {@link defineMaterialPlugin} accepts; everything but `name` and `code` has a\n * default.\n *\n * @beta\n */\nexport interface MaterialPluginDefinitionInit {\n /** The plugin's identity. */\n readonly name: string;\n /** Lower runs first. Defaults to {@link MATERIAL_PLUGIN_DEFAULT_PRIORITY}. */\n readonly priority?: number;\n /** The uniform fields. Defaults to none. */\n readonly uniforms?: readonly ShaderUniformDeclaration[];\n /** The samplers. Defaults to none. */\n readonly textures?: readonly ShaderTextureDeclaration[];\n /** The WGSL to inject, by point. */\n readonly code: Readonly<Partial<Record<LiteMaterialPluginPoint, string>>>;\n}\n\n/** Matches a WGSL identifier. */\nconst IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/** Matches a legal plugin name: an identifier, optionally with `.`, `:`, or `-` inside it. */\nconst PLUGIN_NAME = /^[A-Za-z_][A-Za-z0-9_]*(?:[.:-][A-Za-z0-9_]+)*$/;\n\n/**\n * Validates a raw material-plugin declaration and fills in its defaults.\n *\n * @remarks\n * Nothing here reaches a device: the result is plain data that `attachSurfaceShaders` and\n * `attachMaterialPlugin` turn into a Lite plugin. The checks are the ones whose failure would\n * otherwise surface as a WGSL compile error with no mention of the plugin — an empty `code`, a\n * duplicate or reserved binding name, a name that is not a WGSL identifier, an unknown injection\n * point, or more samplers than {@link MATERIAL_PLUGIN_SAMPLER_BUDGET}.\n *\n * The **surface-shader compiler produces one of these**, so a bug in this validation is a bug in\n * every surface shader too, which is why it lives here rather than inside the compiler.\n *\n * @param definition - The declaration.\n * @returns The same declaration with `priority`, `uniforms`, and `textures` filled in.\n * @throws IgnifxError with code `IGX-0723` when `code` fills in no point, `IGX-0712` when a name is\n * not a legal, unique, unreserved WGSL identifier or a point name is unknown, or `IGX-0726` when the\n * plugin alone exceeds the sampler budget.\n *\n * @example\n * ```ts\n * const tint = defineMaterialPlugin({\n * name: \"tint\",\n * code: { CUSTOM_FRAGMENT_UPDATE_ALPHA: \"baseColor = baseColor * vec3<f32>(1.0, 0.5, 0.5);\" },\n * });\n * ```\n *\n * @beta\n */\nexport function defineMaterialPlugin(definition: MaterialPluginDefinitionInit): MaterialPluginDefinition {\n const name = definition.name;\n if (!PLUGIN_NAME.test(name)) {\n throw new IgnifxError(\n CoreErrorCode.unknownShaderBinding,\n `${JSON.stringify(name)} is not a legal material-plugin name.`,\n {\n context: { plugin: name, name },\n hint: \"Start with a letter or underscore; letters, digits, underscores, and inner . : - follow.\",\n },\n );\n }\n const points = Object.keys(definition.code);\n let filled = 0;\n for (const point of points) {\n if (!isLiteMaterialPluginPoint(point)) {\n throw new IgnifxError(CoreErrorCode.unknownShaderBinding, `${name} declares no Lite point named ${point}.`, {\n context: { plugin: name, name: point, point },\n hint: `The ten points are ${LITE_MATERIAL_PLUGIN_POINTS.join(\", \")}.`,\n });\n }\n if ((definition.code[point] ?? \"\").trim().length > 0) {\n filled += 1;\n }\n }\n if (filled === 0) {\n throw new IgnifxError(CoreErrorCode.surfaceHookMissing, `${name} injects no WGSL at any Lite point.`, {\n context: { plugin: name, name },\n hint: \"Fill in at least one of the ten points, or do not attach the plugin.\",\n });\n }\n const uniforms = definition.uniforms ?? [];\n const textures = definition.textures ?? [];\n const seen = new Set<string>();\n for (const uniform of uniforms) {\n assertBindingName(name, uniform.name, seen);\n assertUniformType(name, uniform.name, uniform.type);\n }\n for (const texture of textures) {\n assertBindingName(name, texture.name, seen);\n assertBindingName(name, `${texture.name}Sampler`, seen);\n }\n if (textures.length > MATERIAL_PLUGIN_SAMPLER_BUDGET) {\n throw new IgnifxError(\n CoreErrorCode.surfaceSamplerBudgetExceeded,\n `${name} declares ${String(textures.length)} samplers; a material's plugins may declare ${String(MATERIAL_PLUGIN_SAMPLER_BUDGET)} together.`,\n {\n context: { plugin: name, samplers: textures.length, budget: MATERIAL_PLUGIN_SAMPLER_BUDGET },\n hint: \"Pack the maps into fewer textures — an RGBA control map rather than four masks.\",\n },\n );\n }\n return {\n name,\n priority: definition.priority ?? MATERIAL_PLUGIN_DEFAULT_PRIORITY,\n uniforms,\n textures,\n code: definition.code,\n };\n}\n\n/**\n * Whether a string is one of Lite's ten injection points.\n *\n * @param value - The candidate.\n * @returns `true` when Lite accepts it.\n *\n * @beta\n */\nexport function isLiteMaterialPluginPoint(value: string): value is LiteMaterialPluginPoint {\n for (const point of LITE_MATERIAL_PLUGIN_POINTS) {\n if (point === value) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * How many floats one uniform of a declared type occupies on the CPU side.\n *\n * @param type - The declared WGSL type.\n * @returns The component count: 1, 2, 3, 4, or 16.\n *\n * @internal\n */\nexport function uniformComponentCount(type: ShaderUniformType): number {\n switch (type) {\n case \"vec2<f32>\": {\n return 2;\n }\n case \"vec3<f32>\": {\n return 3;\n }\n case \"vec4<f32>\": {\n return 4;\n }\n case \"mat4x4<f32>\": {\n return 16;\n }\n case \"f32\":\n case \"u32\":\n case \"i32\": {\n return 1;\n }\n default: {\n return assertNever(type, \"shader uniform type\");\n }\n }\n}\n\n/**\n * Refuses a binding name that is not a unique, unreserved WGSL identifier.\n *\n * @param plugin - The plugin's name, for the message.\n * @param binding - The candidate name.\n * @param seen - The names already taken by this plugin; the accepted name is added.\n * @throws IgnifxError with code `IGX-0712`.\n */\nfunction assertBindingName(plugin: string, binding: string, seen: Set<string>): void {\n if (!IDENTIFIER.test(binding)) {\n throw new IgnifxError(\n CoreErrorCode.unknownShaderBinding,\n `${plugin} declares ${JSON.stringify(binding)}, which is not a WGSL identifier.`,\n { context: { plugin, name: binding }, hint: \"Use letters, digits, and underscores, starting with a letter.\" },\n );\n }\n if (MATERIAL_PLUGIN_RESERVED_NAMES.includes(binding)) {\n throw new IgnifxError(\n CoreErrorCode.unknownShaderBinding,\n `${plugin} declares ${binding}, which Babylon Lite's own PBR or Standard shader already owns.`,\n { context: { plugin, name: binding }, hint: \"Rename it; a plugin shares the host material's WGSL namespace.\" },\n );\n }\n if (seen.has(binding)) {\n throw new IgnifxError(CoreErrorCode.unknownShaderBinding, `${plugin} declares ${binding} twice.`, {\n context: { plugin, name: binding },\n hint: \"Every uniform and texture of one plugin needs its own name.\",\n });\n }\n seen.add(binding);\n}\n\n/**\n * Refuses a uniform type Lite's plugin bridge cannot carry.\n *\n * @param plugin - The plugin's name, for the message.\n * @param binding - The uniform's name.\n * @param type - The declared type.\n * @throws IgnifxError with code `IGX-0712`.\n */\nfunction assertUniformType(plugin: string, binding: string, type: ShaderUniformType): void {\n if (!SHADER_UNIFORM_TYPES.includes(type)) {\n throw new IgnifxError(CoreErrorCode.unknownShaderBinding, `${plugin}.${binding} declares the type ${type}.`, {\n context: { plugin, name: binding, type },\n hint: `The plugin uniform types are ${SHADER_UNIFORM_TYPES.join(\", \")}.`,\n });\n }\n}\n"],"mappings":";;;;;AAmFA,MAAM,uBAAuB;;;;;;;AAQ7B,MAAa,uBAAuB;CAAC;CAAU;CAAQ;AAAO;;;;;;;;;;;;;;AAyG9D,SAAgB,2BAA2B,OAA2C;CACpF,MAAM,QAAmC,CAAC;CAC1C,IAAI,MAAM,SAAS,KAAA,GACjB,MAAM,OAAO,MAAM;CAErB,IAAI,MAAM,cAAc,KAAA,GACtB,MAAM,kBAAkB;EAAC,MAAM,UAAU;EAAI,MAAM,UAAU;EAAI,MAAM,UAAU;EAAI,MAAM,UAAU;CAAE;CAEzG,IAAI,MAAM,qBAAqB,KAAA,GAC7B,MAAM,mBAAmB,MAAM;CAEjC,IAAI,MAAM,aAAa,KAAA,GACrB,MAAM,iBAAiB,MAAM;CAE/B,IAAI,MAAM,cAAc,KAAA,GACtB,MAAM,kBAAkB,MAAM;CAEhC,IAAI,MAAM,6BAA6B,KAAA,GACrC,MAAM,aAAa,MAAM;CAE3B,IAAI,MAAM,kBAAkB,KAAA,GAC1B,MAAM,gBAAgB,MAAM;CAE9B,IAAI,MAAM,gBAAgB,KAAA,GACxB,MAAM,qBAAqB,MAAM;CAEnC,IAAI,MAAM,oBAAoB,KAAA,GAC5B,MAAM,kBAAkB,MAA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