@ignifx/core 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +17 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1023 -2557
- package/dist/index.js.map +1 -1
- package/dist/{instanced-mesh-instance-Cgx1H87p.js → instanced-mesh-instance-gguMoIeZ.js} +74 -10
- package/dist/instanced-mesh-instance-gguMoIeZ.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-DAWIDdaa.js} +6 -4
- package/dist/{surface-shader-Chs7wOAE.js.map → surface-shader-DAWIDdaa.js.map} +1 -1
- package/dist/vec3-B31o_KF_.js +2458 -0
- package/dist/vec3-B31o_KF_.js.map +1 -0
- package/package.json +1 -1
- package/dist/color-CpvebMIh.js.map +0 -1
- package/dist/instanced-mesh-instance-Cgx1H87p.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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { clearThinInstanceLodPartner, enableThinInstanceDynamicDrawCount, enableThinInstanceGpuCulling, enableThinInstanceWorldBounds, flushThinInstances, setThinInstanceColors, setThinInstanceCount, setThinInstanceDrawCount, setThinInstanceLodPartner, setThinInstances } from "@babylonjs/lite";
|
|
1
|
+
import { A as setMeshReceiveShadows, D as setMeshId, E as setMeshBounds, M as setMeshSubtreeVisible, O as setMeshMaterial, T as removeMeshFromScene, Y as tagNode, d as cloneMeshUnderNode, j as setMeshRenderOrder, k as setMeshPickable, l as Vec3, u as addMeshToScene, x as detachMeshBounds } from "./vec3-B31o_KF_.js";
|
|
2
|
+
import { clearThinInstanceLodPartner, enableThinInstanceDynamicDrawCount, enableThinInstanceGpuCulling, enableThinInstanceWorldBounds, flushThinInstances, setThinInstanceColors, setThinInstanceCount, setThinInstanceCullBoundsPad, setThinInstanceDrawCount, setThinInstanceLodPartner, setThinInstances } from "@babylonjs/lite";
|
|
3
3
|
//#region src/lite/gpu/thin-instances.ts
|
|
4
4
|
/**
|
|
5
5
|
* Thin-instance half of the Babylon Lite adapter (`docs/architecture/07-rendering.md` §2.3,
|
|
@@ -140,6 +140,23 @@ function enableThinInstanceGpuCulling$1(mesh, enabled) {
|
|
|
140
140
|
enableThinInstanceGpuCulling(mesh, enabled);
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
|
+
* Grows every instance's GPU-culling sphere by a world-space distance.
|
|
144
|
+
*
|
|
145
|
+
* @remarks
|
|
146
|
+
* The culler builds each sphere from the prototype's vertices (`lib/mesh/thin-instance-gpu-culling.js`
|
|
147
|
+
* 426), so a vertex stage that moves an instance outside it gets the instance culled while it is
|
|
148
|
+
* still on screen. Lite reads the pad on every culled pass (`index.d.ts` 11232), so it can change
|
|
149
|
+
* live. Needs {@link setThinInstances} first.
|
|
150
|
+
*
|
|
151
|
+
* @param mesh - The instanced mesh that owns the culling pass.
|
|
152
|
+
* @param pad - The extra radius in world units; `0` is the exact sphere.
|
|
153
|
+
*
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
function setThinInstanceCullBoundsPad$1(mesh, pad) {
|
|
157
|
+
setThinInstanceCullBoundsPad(mesh, pad);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
143
160
|
* Makes a mesh's world bounds the union of its instances' boxes rather than the prototype's own.
|
|
144
161
|
*
|
|
145
162
|
* @remarks
|
|
@@ -223,6 +240,12 @@ var InstancedMeshInstance = class {
|
|
|
223
240
|
#nearBox;
|
|
224
241
|
#lodBox;
|
|
225
242
|
#union = /* @__PURE__ */ new Float64Array(6);
|
|
243
|
+
/** The world-space displacement the culling pad and the bounds were last widened by. */
|
|
244
|
+
#displacement = 0;
|
|
245
|
+
/** The same displacement in object units, per axis, as the published bounds carry it. */
|
|
246
|
+
#margin = new Vec3();
|
|
247
|
+
/** Scratch for the entity's world scale. */
|
|
248
|
+
#scale = new Vec3();
|
|
226
249
|
/**
|
|
227
250
|
* Clones the templates, gives them thin instances, applies the baked settings in Lite's required
|
|
228
251
|
* order, and adds them to the scene.
|
|
@@ -420,17 +443,47 @@ var InstancedMeshInstance = class {
|
|
|
420
443
|
const near = this.#nearBox;
|
|
421
444
|
const lodBox = this.#lodBox;
|
|
422
445
|
const lod = this.lodMesh;
|
|
446
|
+
const margin = this.#margin;
|
|
423
447
|
if (count <= 0) {
|
|
424
|
-
writeBox(this.mesh, near);
|
|
425
|
-
if (lod !== null && lodBox !== null) writeBox(lod, lodBox);
|
|
448
|
+
writeBox(this.mesh, near, margin);
|
|
449
|
+
if (lod !== null && lodBox !== null) writeBox(lod, lodBox, margin);
|
|
426
450
|
return;
|
|
427
451
|
}
|
|
428
452
|
const union = this.#union;
|
|
429
453
|
unionOfPlacements(matrices, count, near, union);
|
|
430
|
-
|
|
454
|
+
writeBox(this.mesh, union, margin);
|
|
431
455
|
if (lod !== null && lodBox !== null) {
|
|
432
456
|
unionOfPlacements(matrices, count, lodBox, union);
|
|
433
|
-
|
|
457
|
+
writeBox(lod, union, margin);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Widens both meshes for a vertex stage that moves vertices up to `displacement` metres: the GPU
|
|
462
|
+
* culler pads every instance's sphere, and the bounds published for a shadow frustum grow too.
|
|
463
|
+
*
|
|
464
|
+
* @remarks
|
|
465
|
+
* The culling pad is world-space already. The bounds are object-local, so each axis is divided by
|
|
466
|
+
* the entity's world scale along it. A change clears `state.hasAppliedBounds`, so the next
|
|
467
|
+
* {@link InstancedMeshInstance.sync} re-publishes them.
|
|
468
|
+
*
|
|
469
|
+
* @param state - The component's upload state.
|
|
470
|
+
* @param displacement - The material's displacement, in world metres.
|
|
471
|
+
* @param transform - The entity's transform, whose world scale the meshes inherit.
|
|
472
|
+
*/
|
|
473
|
+
applyDisplacement(state, displacement, transform) {
|
|
474
|
+
if (displacement !== this.#displacement) {
|
|
475
|
+
this.#displacement = displacement;
|
|
476
|
+
setThinInstanceCullBoundsPad$1(this.mesh, displacement);
|
|
477
|
+
}
|
|
478
|
+
const scale = this.#scale;
|
|
479
|
+
if (displacement > 0) transform.lossyScaleToRef(scale);
|
|
480
|
+
const x = objectMargin(displacement, scale.x);
|
|
481
|
+
const y = objectMargin(displacement, scale.y);
|
|
482
|
+
const z = objectMargin(displacement, scale.z);
|
|
483
|
+
const margin = this.#margin;
|
|
484
|
+
if (x !== margin.x || y !== margin.y || z !== margin.z) {
|
|
485
|
+
margin.set(x, y, z);
|
|
486
|
+
state.hasAppliedBounds = false;
|
|
434
487
|
}
|
|
435
488
|
}
|
|
436
489
|
/**
|
|
@@ -623,13 +676,24 @@ function readBox(mesh) {
|
|
|
623
676
|
return Float64Array.of(min[0], min[1], min[2], max[0], max[1], max[2]);
|
|
624
677
|
}
|
|
625
678
|
/**
|
|
626
|
-
* Writes a six-number box back onto a mesh.
|
|
679
|
+
* Writes a six-number box back onto a mesh, grown by a margin on every side.
|
|
627
680
|
*
|
|
628
681
|
* @param mesh - The mesh to re-bound.
|
|
629
682
|
* @param box - `minX, minY, minZ, maxX, maxY, maxZ`.
|
|
683
|
+
* @param margin - How far to grow each axis, in object units.
|
|
684
|
+
*/
|
|
685
|
+
function writeBox(mesh, box, margin) {
|
|
686
|
+
setMeshBounds(mesh, (box[0] ?? 0) - margin.x, (box[1] ?? 0) - margin.y, (box[2] ?? 0) - margin.z, (box[3] ?? 0) + margin.x, (box[4] ?? 0) + margin.y, (box[5] ?? 0) + margin.z);
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Converts a world-space margin into the object-space margin along one axis.
|
|
690
|
+
*
|
|
691
|
+
* @param margin - The margin, in world metres.
|
|
692
|
+
* @param scale - The entity's world scale along the axis.
|
|
693
|
+
* @returns The margin in object units; `0` for no margin or a collapsed axis.
|
|
630
694
|
*/
|
|
631
|
-
function
|
|
632
|
-
|
|
695
|
+
function objectMargin(margin, scale) {
|
|
696
|
+
return margin > 0 && scale > 1e-9 ? margin / scale : 0;
|
|
633
697
|
}
|
|
634
698
|
/**
|
|
635
699
|
* The axis-aligned union of a prototype box placed under every live instance matrix.
|
|
@@ -698,4 +762,4 @@ function asMesh(node) {
|
|
|
698
762
|
//#endregion
|
|
699
763
|
export { InstancedMeshInstance, createInstancedMesh, releaseInstancedMesh };
|
|
700
764
|
|
|
701
|
-
//# sourceMappingURL=instanced-mesh-instance-
|
|
765
|
+
//# sourceMappingURL=instanced-mesh-instance-gguMoIeZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instanced-mesh-instance-gguMoIeZ.js","names":["setThinInstances","setThinInstanceCount","flushThinInstances","setThinInstanceColors","enableThinInstanceGpuCulling","setThinInstanceCullBoundsPad","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 setThinInstanceCullBoundsPad as liteSetThinInstanceCullBoundsPad,\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 * Grows every instance's GPU-culling sphere by a world-space distance.\n *\n * @remarks\n * The culler builds each sphere from the prototype's vertices (`lib/mesh/thin-instance-gpu-culling.js`\n * 426), so a vertex stage that moves an instance outside it gets the instance culled while it is\n * still on screen. Lite reads the pad on every culled pass (`index.d.ts` 11232), so it can change\n * live. Needs {@link setThinInstances} first.\n *\n * @param mesh - The instanced mesh that owns the culling pass.\n * @param pad - The extra radius in world units; `0` is the exact sphere.\n *\n * @internal\n */\nexport function setThinInstanceCullBoundsPad(mesh: Mesh, pad: number): void {\n liteSetThinInstanceCullBoundsPad(mesh, pad);\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 setThinInstanceCullBoundsPad,\n setThinInstanceLodPartner,\n setThinInstances,\n trySetThinInstanceDrawCount,\n} from \"../../lite/gpu/thin-instances.js\";\nimport { tagNode } from \"../../lite/node.js\";\nimport { Vec3 } from \"../../math/vec3.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\";\nimport type { Transform } from \"../../transform/transform.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 /** The world-space displacement the culling pad and the bounds were last widened by. */\n #displacement = 0;\n\n /** The same displacement in object units, per axis, as the published bounds carry it. */\n readonly #margin = new Vec3();\n\n /** Scratch for the entity's world scale. */\n readonly #scale = new Vec3();\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 const margin = this.#margin;\n if (count <= 0) {\n writeBox(this.mesh, near, margin);\n if (lod !== null && lodBox !== null) {\n writeBox(lod, lodBox, margin);\n }\n return;\n }\n const union = this.#union;\n unionOfPlacements(matrices, count, near, union);\n writeBox(this.mesh, union, margin);\n if (lod !== null && lodBox !== null) {\n unionOfPlacements(matrices, count, lodBox, union);\n writeBox(lod, union, margin);\n }\n }\n\n /**\n * Widens both meshes for a vertex stage that moves vertices up to `displacement` metres: the GPU\n * culler pads every instance's sphere, and the bounds published for a shadow frustum grow too.\n *\n * @remarks\n * The culling pad is world-space already. The bounds are object-local, so each axis is divided by\n * the entity's world scale along it. A change clears `state.hasAppliedBounds`, so the next\n * {@link InstancedMeshInstance.sync} re-publishes them.\n *\n * @param state - The component's upload state.\n * @param displacement - The material's displacement, in world metres.\n * @param transform - The entity's transform, whose world scale the meshes inherit.\n */\n applyDisplacement(state: InstancedUploadState, displacement: number, transform: Transform): void {\n if (displacement !== this.#displacement) {\n this.#displacement = displacement;\n // Only the near mesh runs the culling pass; the partner draws from its output.\n setThinInstanceCullBoundsPad(this.mesh, displacement);\n }\n const scale = this.#scale;\n if (displacement > 0) {\n transform.lossyScaleToRef(scale);\n }\n const x = objectMargin(displacement, scale.x);\n const y = objectMargin(displacement, scale.y);\n const z = objectMargin(displacement, scale.z);\n const margin = this.#margin;\n if (x !== margin.x || y !== margin.y || z !== margin.z) {\n margin.set(x, y, z);\n state.hasAppliedBounds = false;\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, grown by a margin on every side.\n *\n * @param mesh - The mesh to re-bound.\n * @param box - `minX, minY, minZ, maxX, maxY, maxZ`.\n * @param margin - How far to grow each axis, in object units.\n */\nfunction writeBox(mesh: LiteMesh, box: Float64Array, margin: Vec3): void {\n setMeshBounds(\n mesh,\n (box[0] ?? 0) - margin.x,\n (box[1] ?? 0) - margin.y,\n (box[2] ?? 0) - margin.z,\n (box[3] ?? 0) + margin.x,\n (box[4] ?? 0) + margin.y,\n (box[5] ?? 0) + margin.z,\n );\n}\n\n/**\n * Converts a world-space margin into the object-space margin along one axis.\n *\n * @param margin - The margin, in world metres.\n * @param scale - The entity's world scale along the axis.\n * @returns The margin in object units; `0` for no margin or a collapsed axis.\n */\nfunction objectMargin(margin: number, scale: number): number {\n return margin > 0 && scale > 1e-9 ? margin / scale : 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,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;CACA,MAAM,OAAO,KAAK;CAClB,IAAI,SAAS,QAAQ,SAAS,KAAA,GAC5B,KAAK,SAAS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;AAaA,SAAS,OAAO,MAA+B;CAE7C,OAAO;AACT"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
//#region src/math/math-utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Scalar helpers shared by the vector, quaternion and matrix types and by game code.
|
|
4
|
+
*
|
|
5
|
+
* Angles are **degrees** in every public API unless the name ends in `Rad`/`Radians`
|
|
6
|
+
* (coding standards §5.1, ADR-0011). Every function here is a pure scalar function: none of them
|
|
7
|
+
* allocate, so they are safe in per-frame code (coding standards §7).
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The default tolerance for approximate float comparisons. Chosen for single-precision positions in
|
|
11
|
+
* metres: `Float32Array` round-tripping loses roughly 1e-7 of relative precision, so 1e-6 is the
|
|
12
|
+
* smallest value that does not report false differences on data that has been through the GPU.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
const EPSILON = 1e-6;
|
|
17
|
+
/**
|
|
18
|
+
* Multiplier that converts degrees to radians.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
const DEG_TO_RAD = Math.PI / 180;
|
|
23
|
+
/**
|
|
24
|
+
* Multiplier that converts radians to degrees.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
const RAD_TO_DEG = 180 / Math.PI;
|
|
29
|
+
/**
|
|
30
|
+
* Converts an angle from degrees to radians.
|
|
31
|
+
*
|
|
32
|
+
* @param degrees - The angle in degrees.
|
|
33
|
+
* @returns The same angle in radians.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
function degToRad(degrees) {
|
|
38
|
+
return degrees * DEG_TO_RAD;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Converts an angle from radians to degrees.
|
|
42
|
+
*
|
|
43
|
+
* @param radians - The angle in radians.
|
|
44
|
+
* @returns The same angle in degrees.
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
function radToDeg(radians) {
|
|
49
|
+
return radians * RAD_TO_DEG;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Constrains a value to an inclusive range.
|
|
53
|
+
*
|
|
54
|
+
* @param value - The value to constrain.
|
|
55
|
+
* @param min - The lower bound.
|
|
56
|
+
* @param max - The upper bound.
|
|
57
|
+
* @returns `min` when `value` is smaller, `max` when it is larger, otherwise `value` unchanged.
|
|
58
|
+
* `NaN` propagates.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* clamp(12, 0, 10); // 10
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
function clamp(value, min, max) {
|
|
68
|
+
if (value < min) return min;
|
|
69
|
+
if (value > max) return max;
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Constrains a value to the 0–1 range.
|
|
74
|
+
*
|
|
75
|
+
* @param value - The value to constrain.
|
|
76
|
+
* @returns The value clamped into `[0, 1]`.
|
|
77
|
+
*
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
function clamp01(value) {
|
|
81
|
+
return clamp(value, 0, 1);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Linearly interpolates between two values. The interpolant is **not** clamped, so values outside
|
|
85
|
+
* `[0, 1]` extrapolate; wrap `t` in {@link clamp01} when that is not wanted.
|
|
86
|
+
*
|
|
87
|
+
* @param a - The value returned at `t === 0`.
|
|
88
|
+
* @param b - The value returned at `t === 1`.
|
|
89
|
+
* @param t - The interpolant.
|
|
90
|
+
* @returns The interpolated value.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* lerp(0, 10, 0.25); // 2.5
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
function lerp(a, b, t) {
|
|
100
|
+
return a + (b - a) * t;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The inverse of {@link lerp}: finds the interpolant that maps `a`–`b` onto `value`.
|
|
104
|
+
*
|
|
105
|
+
* @param a - The value that maps to 0.
|
|
106
|
+
* @param b - The value that maps to 1.
|
|
107
|
+
* @param value - The value to locate.
|
|
108
|
+
* @returns The interpolant, clamped into `[0, 1]`. Returns 0 when `a` and `b` are equal.
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
function inverseLerp(a, b, value) {
|
|
113
|
+
if (a === b) return 0;
|
|
114
|
+
return clamp01((value - a) / (b - a));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Smoothly interpolates between two edges with a Hermite curve (the GLSL `smoothstep`), easing in
|
|
118
|
+
* and out instead of the straight ramp of {@link lerp}.
|
|
119
|
+
*
|
|
120
|
+
* @param edge0 - The value below which the result is 0.
|
|
121
|
+
* @param edge1 - The value above which the result is 1.
|
|
122
|
+
* @param x - The value to map.
|
|
123
|
+
* @returns A value in `[0, 1]`. Degenerate edges (`edge0 === edge1`) step from 0 to 1 at the edge.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* smoothStep(0, 1, 0.5); // 0.5, but with zero slope at 0 and 1
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
function smoothStep(edge0, edge1, x) {
|
|
133
|
+
if (edge0 === edge1) return x < edge0 ? 0 : 1;
|
|
134
|
+
const t = clamp01((x - edge0) / (edge1 - edge0));
|
|
135
|
+
return t * t * (3 - 2 * t);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Moves a value towards a target without overshooting it.
|
|
139
|
+
*
|
|
140
|
+
* @param current - The value to move.
|
|
141
|
+
* @param target - The value to move towards.
|
|
142
|
+
* @param maxDelta - The largest step allowed this call; negative values move away from the target.
|
|
143
|
+
* @returns The stepped value, exactly `target` once the remaining distance fits in `maxDelta`.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* // frame-rate independent approach at 2 units per second
|
|
148
|
+
* health = moveTowards(health, 100, 2 * time.deltaTime);
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
function moveTowards(current, target, maxDelta) {
|
|
154
|
+
const delta = target - current;
|
|
155
|
+
if (Math.abs(delta) <= maxDelta) return target;
|
|
156
|
+
return current + (delta < 0 ? -maxDelta : maxDelta);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Wraps a value into `[0, length)`, the way a looping animation time behaves. Unlike `%` the result
|
|
160
|
+
* is never negative.
|
|
161
|
+
*
|
|
162
|
+
* @param t - The value to wrap.
|
|
163
|
+
* @param length - The positive period to wrap into.
|
|
164
|
+
* @returns The wrapped value, clamped into `[0, length]` so float error cannot escape the range.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* repeat(-1, 4); // 3
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
173
|
+
function repeat(t, length) {
|
|
174
|
+
return clamp(t - Math.floor(t / length) * length, 0, length);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Bounces a value back and forth between 0 and `length`, the way a ping-pong animation behaves.
|
|
178
|
+
*
|
|
179
|
+
* @param t - The value to fold.
|
|
180
|
+
* @param length - The positive half-period to fold into.
|
|
181
|
+
* @returns A value in `[0, length]` that rises then falls as `t` increases.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* pingPong(5, 4); // 3
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
function pingPong(t, length) {
|
|
191
|
+
return length - Math.abs(repeat(t, length * 2) - length);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Compares two numbers with an absolute tolerance. Use this instead of `===` on anything that has
|
|
195
|
+
* been through a matrix, a quaternion or a `Float32Array`.
|
|
196
|
+
*
|
|
197
|
+
* @param a - The first value.
|
|
198
|
+
* @param b - The second value.
|
|
199
|
+
* @param epsilon - The largest difference still considered equal. Defaults to {@link EPSILON}.
|
|
200
|
+
* @returns `true` when the values differ by no more than `epsilon`. `NaN` is never approximately
|
|
201
|
+
* equal to anything, including itself.
|
|
202
|
+
*
|
|
203
|
+
* @public
|
|
204
|
+
*/
|
|
205
|
+
function approximately(a, b, epsilon = EPSILON) {
|
|
206
|
+
return Math.abs(a - b) <= epsilon;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The sign of a value, with zero treated as positive (matching Unity's `Mathf.Sign`, and unlike
|
|
210
|
+
* `Math.sign`, which returns 0 and `-0`).
|
|
211
|
+
*
|
|
212
|
+
* @param value - The value to inspect.
|
|
213
|
+
* @returns `-1` for negative values, `1` for positive values and for both `0` and `-0`, and `NaN`
|
|
214
|
+
* for `NaN`.
|
|
215
|
+
*
|
|
216
|
+
* @public
|
|
217
|
+
*/
|
|
218
|
+
function sign(value) {
|
|
219
|
+
if (Number.isNaN(value)) return NaN;
|
|
220
|
+
return value < 0 ? -1 : 1;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Wraps an angle in degrees into `[-180, 180)`, the range rotations are most readable in.
|
|
224
|
+
*
|
|
225
|
+
* @param degrees - The angle to wrap.
|
|
226
|
+
* @returns The equivalent angle in `[-180, 180)`; exactly `180` wraps to `-180`.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* wrapAngleDegrees(370); // 10
|
|
231
|
+
* wrapAngleDegrees(-190); // 170
|
|
232
|
+
* ```
|
|
233
|
+
*
|
|
234
|
+
* @public
|
|
235
|
+
*/
|
|
236
|
+
function wrapAngleDegrees(degrees) {
|
|
237
|
+
return repeat(degrees + 180, 360) - 180;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* The shortest signed rotation from one angle to another, in degrees.
|
|
241
|
+
*
|
|
242
|
+
* @param fromDegrees - The starting angle.
|
|
243
|
+
* @param toDegrees - The target angle.
|
|
244
|
+
* @returns The signed difference in `[-180, 180)`.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* deltaAngleDegrees(350, 10); // 20, not -340
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
251
|
+
* @public
|
|
252
|
+
*/
|
|
253
|
+
function deltaAngleDegrees(fromDegrees, toDegrees) {
|
|
254
|
+
return wrapAngleDegrees(toDegrees - fromDegrees);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Interpolates between two angles in degrees the short way around the circle.
|
|
258
|
+
*
|
|
259
|
+
* @param fromDegrees - The angle returned at `t === 0`.
|
|
260
|
+
* @param toDegrees - The angle approached at `t === 1`.
|
|
261
|
+
* @param t - The interpolant; not clamped, matching {@link lerp}.
|
|
262
|
+
* @returns The interpolated angle. It is not wrapped, so feeding the result back in is stable.
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```ts
|
|
266
|
+
* lerpAngleDegrees(350, 10, 0.5); // 360
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
function lerpAngleDegrees(fromDegrees, toDegrees, t) {
|
|
272
|
+
return fromDegrees + deltaAngleDegrees(fromDegrees, toDegrees) * t;
|
|
273
|
+
}
|
|
274
|
+
//#endregion
|
|
275
|
+
export { smoothStep as _, clamp as a, deltaAngleDegrees as c, lerpAngleDegrees as d, moveTowards as f, sign as g, repeat as h, approximately as i, inverseLerp as l, radToDeg as m, EPSILON as n, clamp01 as o, pingPong as p, RAD_TO_DEG as r, degToRad as s, DEG_TO_RAD as t, lerp as u, wrapAngleDegrees as v };
|
|
276
|
+
|
|
277
|
+
//# sourceMappingURL=math-utils-BcDnL-gi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math-utils-BcDnL-gi.js","names":[],"sources":["../src/math/math-utils.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"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,UAAkB;;;;;;AAO/B,MAAa,aAAqB,KAAK,KAAK;;;;;;AAO5C,MAAa,aAAqB,MAAM,KAAK;;;;;;;;;AAU7C,SAAgB,SAAS,SAAyB;CAChD,OAAO,UAAU;AACnB;;;;;;;;;AAUA,SAAgB,SAAS,SAAyB;CAChD,OAAO,UAAU;AACnB;;;;;;;;;;;;;;;;;AAkBA,SAAgB,MAAM,OAAe,KAAa,KAAqB;CACrE,IAAI,QAAQ,KACV,OAAO;CAET,IAAI,QAAQ,KACV,OA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AAiB,SAAyB;CACxD,OAAO,OAAO,UAAU,KAAK,GAAG,IAAI;AACtC;;;;;;;;;;;;;;;AAgBA,SAAgB,kBAAkB,aAAqB,WAA2B;CAChF,OAAO,iBAAiB,YAAY,WAAW;AACjD;;;;;;;;;;;;;;;;AAiBA,SAAgB,iBAAiB,aAAqB,WAAmB,GAAmB;CAC1F,OAAO,cAAc,kBAAkB,aAAa,SAAS,IAAI;AACnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-declaration-5q__jycG.js","names":[],"sources":["../src/render/shader-declaration.ts"],"sourcesContent":["/**\n * The vocabulary a `// @ignifx` pragma declares: the three authoring forms, the WGSL types and\n * attribute names Babylon Lite accepts, the uniforms ignifx supplies, and the parsed declaration\n * itself (`docs/plan/2026-09-terrain-particles-shaders.md` §3.1).\n *\n * Split from `./shader-pragma.ts` so these few hundred bytes can stay in the barrel while the parser\n * lives in a chunk only the `.wgsl` loader fetches (`./shader-support.ts`).\n */\n\n/**\n * The three authoring forms the form directive names, in the order the documentation lists them.\n *\n * @public\n */\nexport const SHADER_KINDS = [\"shader\", \"surface\", \"post\"] as const;\n\n/**\n * Which of the three authoring forms a `.wgsl` file is: a full custom material, a surface shader\n * that hooks into the engine's lit materials, or a full-screen post effect.\n *\n * @public\n */\nexport type ShaderKind = (typeof SHADER_KINDS)[number];\n\n/**\n * The WGSL types a declared uniform may have — Babylon Lite's set (`index.d.ts` 11445).\n *\n * @public\n */\nexport const SHADER_UNIFORM_TYPES = [\n \"f32\",\n \"u32\",\n \"i32\",\n \"vec2<f32>\",\n \"vec3<f32>\",\n \"vec4<f32>\",\n \"mat4x4<f32>\",\n] as const;\n\n/**\n * The union of the uniform types a declaration may name.\n *\n * @public\n */\nexport type ShaderUniformType = (typeof SHADER_UNIFORM_TYPES)[number];\n\n/**\n * The vertex attributes a shader material can bind — Babylon Lite's fixed set\n * (`index.d.ts` 11295). A name outside this list is reported with its line.\n *\n * @public\n */\nexport const SHADER_ATTRIBUTE_NAMES = [\n \"position\",\n \"normal\",\n \"uv\",\n \"uv2\",\n \"tangent\",\n \"color\",\n \"joints\",\n \"weights\",\n \"joints1\",\n \"weights1\",\n] as const;\n\n/**\n * The union of the attribute names a declaration may name.\n *\n * @public\n */\nexport type ShaderAttributeName = (typeof SHADER_ATTRIBUTE_NAMES)[number];\n\n/**\n * The uniforms Babylon Lite fills in itself every frame, read in WGSL as `shaderSystem.<name>`\n * (`index.d.ts` 11432).\n *\n * @remarks\n * Two of them lie under `rendering.useFloatingOrigin`: `cameraPosition` reads `(0, 0, 0)` and the\n * world matrices are camera-relative. With instancing on, `world`, `worldView`, and\n * `worldViewProjection` are **not** instance-aware — the shader composes\n * `shaderSystem.world * mat4x4(input.world0, input.world1, input.world2, input.world3)`.\n *\n * @public\n */\nexport const LITE_SYSTEM_UNIFORM_NAMES = [\n \"world\",\n \"view\",\n \"projection\",\n \"viewProjection\",\n \"worldView\",\n \"worldViewProjection\",\n \"cameraPosition\",\n \"screenSize\",\n \"alphaCutoff\",\n] as const;\n\n/**\n * The union of the Babylon Lite system uniform names.\n *\n * @public\n */\nexport type LiteSystemUniformName = (typeof LITE_SYSTEM_UNIFORM_NAMES)[number];\n\n/**\n * The uniforms **ignifx** fills in every frame, read in WGSL as `shaderUniforms.<name>`\n * (`docs/plan/2026-09-terrain-particles-shaders.md` §3.1). Babylon Lite has no clock and no light\n * bindings for a shader material, so these are the engine's own addition.\n *\n * @public\n */\nexport const IGNIFX_UNIFORM_NAMES = [\n \"time\",\n \"unscaledTime\",\n \"deltaTime\",\n \"mainLightDirection\",\n \"mainLightColor\",\n \"ambientColor\",\n] as const;\n\n/**\n * The union of the ignifx-provided uniform names.\n *\n * @public\n */\nexport type IgnifxUniformName = (typeof IGNIFX_UNIFORM_NAMES)[number];\n\n/**\n * The WGSL type of each ignifx-provided uniform, which is what the custom uniform block is laid out\n * from.\n *\n * @internal\n */\nexport const IGNIFX_UNIFORM_TYPES: Readonly<Record<IgnifxUniformName, ShaderUniformType>> = Object.freeze({\n time: \"f32\",\n unscaledTime: \"f32\",\n deltaTime: \"f32\",\n mainLightDirection: \"vec3<f32>\",\n mainLightColor: \"vec3<f32>\",\n ambientColor: \"vec3<f32>\",\n});\n\n/**\n * The 1x1 fallback textures a declaration can bind when nothing else is.\n *\n * @public\n */\nexport const SHADER_TEXTURE_FALLBACKS = [\"white\", \"black\", \"transparent\"] as const;\n\n/**\n * Which 1x1 texture is bound to a declared sampler that nothing has filled in\n * (Godot's `hint_default_*`).\n *\n * @public\n */\nexport type ShaderTextureFallback = (typeof SHADER_TEXTURE_FALLBACKS)[number];\n\n/**\n * How a shader material composites its fragments.\n *\n * @public\n */\nexport const SHADER_BLEND_MODES = [\"opaque\", \"alpha\", \"additive\", \"premultiplied\"] as const;\n\n/**\n * The blend modes a declaration may ask for.\n *\n * @public\n */\nexport type ShaderBlendMode = (typeof SHADER_BLEND_MODES)[number];\n\n/**\n * Which faces are drawn. `\"front\"` is accepted by the grammar and refused by the parser, because\n * Babylon Lite 1.27.0 exposes only `backFaceCulling`.\n *\n * @public\n */\nexport const SHADER_CULL_MODES = [\"back\", \"front\", \"none\"] as const;\n\n/**\n * The face-culling modes a declaration may ask for. `\"front\"` is refused: Babylon Lite 1.27.0\n * exposes only `backFaceCulling`.\n *\n * @public\n */\nexport type ShaderCullMode = (typeof SHADER_CULL_MODES)[number];\n\n/**\n * Which instance streams the vertex stage reads.\n *\n * @public\n */\nexport const SHADER_INSTANCING_MODES = [\"none\", \"matrices\", \"matrices-colors\"] as const;\n\n/**\n * How a declaration expects to be drawn: one mesh at a time, or thin-instanced with a matrix slab\n * and optionally a per-instance colour.\n *\n * @public\n */\nexport type ShaderInstancingMode = (typeof SHADER_INSTANCING_MODES)[number];\n\n/**\n * One `// @ignifx uniform …` line: a value a material sets and the vertex or fragment stage reads\n * as `shaderUniforms.<name>`.\n *\n * @public\n */\nexport interface ShaderUniformDeclaration {\n /** The WGSL identifier. */\n readonly name: string;\n /** The WGSL type. */\n readonly type: ShaderUniformType;\n /**\n * The value a material starts with. A colour default is the **sRGB** value the file wrote; the\n * material layer decodes it to linear on the way to the GPU.\n */\n readonly defaultValue: number | readonly number[];\n /** Whether the value is a colour, declared with `color(…)` or the bare `color` modifier. */\n readonly color: boolean;\n /** The inclusive slider bounds an inspector should offer, or `null`. */\n readonly range: readonly [number, number] | null;\n /** The slider increment an inspector should use, or `null`. */\n readonly step: number | null;\n /** One sentence describing the uniform, or `null`. */\n readonly tooltip: string | null;\n}\n\n/**\n * One `// @ignifx texture …` line: a `texture_2d<f32>` (or `texture_2d_array<f32>`) plus the\n * `<name>Sampler` Babylon Lite generates beside it.\n *\n * @public\n */\nexport interface ShaderTextureDeclaration {\n /** The WGSL identifier; the sampler is `<name>Sampler`. */\n readonly name: string;\n /** Whether the texture holds sRGB-encoded colour, which the texture import needs to know. */\n readonly srgb: boolean;\n /** Whether the texture is a tangent-space normal map. */\n readonly normal: boolean;\n /**\n * Which 1x1 texture is bound when a material binds nothing, or `null` for the implicit `\"white\"`.\n *\n * @remarks\n * A declared sampler that nothing fills in cannot be left unbound: Babylon Lite refuses to build\n * a bind group for it (error 309), so *something* is always bound.\n */\n readonly fallback: ShaderTextureFallback | null;\n /** Whether the binding is a `texture_2d_array<f32>` rather than a `texture_2d<f32>`. */\n readonly array: boolean;\n}\n\n/**\n * One `// @ignifx storage …` line: a read-only storage buffer the shader indexes.\n *\n * @public\n */\nexport interface ShaderStorageDeclaration {\n /** The WGSL identifier. */\n readonly name: string;\n /** The WGSL variable type, verbatim, for example `array<Particle>`. */\n readonly type: string;\n}\n\n/**\n * One `// @ignifx define …` line: a WGSL `const` a material may override.\n *\n * @public\n */\nexport interface ShaderDefineDeclaration {\n /** The WGSL identifier. */\n readonly name: string;\n /** The value; a boolean compiles to `bool`, a number to `f32`. */\n readonly value: boolean | number;\n}\n\n/**\n * The three hooks a `.surface.wgsl` file may provide.\n *\n * @public\n */\nexport const SURFACE_HOOK_NAMES = [\"displace\", \"surface\", \"composite\"] as const;\n\n/**\n * One of the three surface-shader hooks.\n *\n * @public\n */\nexport type SurfaceHookName = (typeof SURFACE_HOOK_NAMES)[number];\n\n/**\n * The uniform block name a surface shader reads its declared uniforms from.\n *\n * @public\n */\nexport const SURFACE_UNIFORM_BLOCK = \"surfaceUniforms\";\n\n/**\n * The pipeline state a `// @ignifx blend …` line declares.\n *\n * @public\n */\nexport interface ShaderPipelineState {\n /** How fragments are composited. */\n readonly blend: ShaderBlendMode;\n /** Which faces are drawn. */\n readonly cull: ShaderCullMode;\n /**\n * Whether the draw writes depth. Defaults to `true` for an opaque surface and `false` for a\n * blended one — Babylon Lite's own rule — unless the file says `depthWrite on` explicitly.\n */\n readonly depthWrite: boolean;\n /** Whether the draw depth-tests at all; `false` compiles `depthCompare: \"always\"`. */\n readonly depthTest: boolean;\n /** Whether the surface samples the opaque scene colour behind it. Requires a blended surface. */\n readonly transmissive: boolean;\n /** Which instance streams the vertex stage reads. */\n readonly instancing: ShaderInstancingMode;\n}\n\n/**\n * Everything a `.wgsl` file declares about itself — the parsed pragmas, with defaults filled in.\n *\n * @public\n */\nexport interface ShaderDeclaration {\n /** Which of the three authoring forms the file is. */\n readonly kind: ShaderKind;\n /** The vertex attributes the vertex stage reads. A `\"shader\"` file always includes `position`. */\n readonly attributes: readonly ShaderAttributeName[];\n /** The Babylon Lite system uniforms, read as `shaderSystem.<name>`. */\n readonly system: readonly LiteSystemUniformName[];\n /** The ignifx-provided uniforms, read as `shaderUniforms.<name>` and written every frame. */\n readonly ignifx: readonly IgnifxUniformName[];\n /** The custom uniforms, read as `shaderUniforms.<name>`. */\n readonly uniforms: readonly ShaderUniformDeclaration[];\n /** The samplers, each generating `<name>` and `<name>Sampler`. */\n readonly textures: readonly ShaderTextureDeclaration[];\n /** The read-only storage buffers. */\n readonly storage: readonly ShaderStorageDeclaration[];\n /** The WGSL `const` declarations a material may override. */\n readonly defines: readonly ShaderDefineDeclaration[];\n /** The pipeline state. */\n readonly pipeline: ShaderPipelineState;\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,eAAe;CAAC;CAAU;CAAW;AAAM;;;;;;AAexD,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAeA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;AAqBA,MAAa,4BAA4B;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;AAgBA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAeA,MAAa,uBAA+E,OAAO,OAAO;CACxG,MAAM;CACN,cAAc;CACd,WAAW;CACX,oBAAoB;CACpB,gBAAgB;CAChB,cAAc;AAChB,CAAC;;;;;;AAOD,MAAa,2BAA2B;CAAC;CAAS;CAAS;AAAa;;;;;;AAexE,MAAa,qBAAqB;CAAC;CAAU;CAAS;CAAY;AAAe;;;;;;;AAejF,MAAa,oBAAoB;CAAC;CAAQ;CAAS;AAAM;;;;;;AAezD,MAAa,0BAA0B;CAAC;CAAQ;CAAY;AAAiB;;;;;;AA0F7E,MAAa,qBAAqB;CAAC;CAAY;CAAW;AAAW;;;;;;AAcrE,MAAa,wBAAwB"}
|
|
1
|
+
{"version":3,"file":"shader-declaration-5q__jycG.js","names":[],"sources":["../src/render/shader-declaration.ts"],"sourcesContent":["/**\n * The vocabulary a `// @ignifx` pragma declares: the three authoring forms, the WGSL types and\n * attribute names Babylon Lite accepts, the uniforms ignifx supplies, and the parsed declaration\n * itself (`docs/plan/2026-09-terrain-particles-shaders.md` §3.1).\n *\n * Split from `./shader-pragma.ts` so these few hundred bytes can stay in the barrel while the parser\n * lives in a chunk only the `.wgsl` loader fetches (`./shader-support.ts`).\n */\n\n/**\n * The three authoring forms the form directive names, in the order the documentation lists them.\n *\n * @public\n */\nexport const SHADER_KINDS = [\"shader\", \"surface\", \"post\"] as const;\n\n/**\n * Which of the three authoring forms a `.wgsl` file is: a full custom material, a surface shader\n * that hooks into the engine's lit materials, or a full-screen post effect.\n *\n * @public\n */\nexport type ShaderKind = (typeof SHADER_KINDS)[number];\n\n/**\n * The WGSL types a declared uniform may have — Babylon Lite's set (`index.d.ts` 11445).\n *\n * @public\n */\nexport const SHADER_UNIFORM_TYPES = [\n \"f32\",\n \"u32\",\n \"i32\",\n \"vec2<f32>\",\n \"vec3<f32>\",\n \"vec4<f32>\",\n \"mat4x4<f32>\",\n] as const;\n\n/**\n * The union of the uniform types a declaration may name.\n *\n * @public\n */\nexport type ShaderUniformType = (typeof SHADER_UNIFORM_TYPES)[number];\n\n/**\n * The vertex attributes a shader material can bind — Babylon Lite's fixed set\n * (`index.d.ts` 11295). A name outside this list is reported with its line.\n *\n * @public\n */\nexport const SHADER_ATTRIBUTE_NAMES = [\n \"position\",\n \"normal\",\n \"uv\",\n \"uv2\",\n \"tangent\",\n \"color\",\n \"joints\",\n \"weights\",\n \"joints1\",\n \"weights1\",\n] as const;\n\n/**\n * The union of the attribute names a declaration may name.\n *\n * @public\n */\nexport type ShaderAttributeName = (typeof SHADER_ATTRIBUTE_NAMES)[number];\n\n/**\n * The uniforms Babylon Lite fills in itself every frame, read in WGSL as `shaderSystem.<name>`\n * (`index.d.ts` 11432).\n *\n * @remarks\n * Two of them lie under `rendering.useFloatingOrigin`: `cameraPosition` reads `(0, 0, 0)` and the\n * world matrices are camera-relative. With instancing on, `world`, `worldView`, and\n * `worldViewProjection` are **not** instance-aware — the shader composes\n * `shaderSystem.world * mat4x4(input.world0, input.world1, input.world2, input.world3)`.\n *\n * @public\n */\nexport const LITE_SYSTEM_UNIFORM_NAMES = [\n \"world\",\n \"view\",\n \"projection\",\n \"viewProjection\",\n \"worldView\",\n \"worldViewProjection\",\n \"cameraPosition\",\n \"screenSize\",\n \"alphaCutoff\",\n] as const;\n\n/**\n * The union of the Babylon Lite system uniform names.\n *\n * @public\n */\nexport type LiteSystemUniformName = (typeof LITE_SYSTEM_UNIFORM_NAMES)[number];\n\n/**\n * The uniforms **ignifx** fills in every frame, read in WGSL as `shaderUniforms.<name>`\n * (`docs/plan/2026-09-terrain-particles-shaders.md` §3.1). Babylon Lite has no clock and no light\n * bindings for a shader material, so these are the engine's own addition.\n *\n * @public\n */\nexport const IGNIFX_UNIFORM_NAMES = [\n \"time\",\n \"unscaledTime\",\n \"deltaTime\",\n \"mainLightDirection\",\n \"mainLightColor\",\n \"ambientColor\",\n] as const;\n\n/**\n * The union of the ignifx-provided uniform names.\n *\n * @public\n */\nexport type IgnifxUniformName = (typeof IGNIFX_UNIFORM_NAMES)[number];\n\n/**\n * The WGSL type of each ignifx-provided uniform, which is what the custom uniform block is laid out\n * from.\n *\n * @internal\n */\nexport const IGNIFX_UNIFORM_TYPES: Readonly<Record<IgnifxUniformName, ShaderUniformType>> = Object.freeze({\n time: \"f32\",\n unscaledTime: \"f32\",\n deltaTime: \"f32\",\n mainLightDirection: \"vec3<f32>\",\n mainLightColor: \"vec3<f32>\",\n ambientColor: \"vec3<f32>\",\n});\n\n/**\n * The 1x1 fallback textures a declaration can bind when nothing else is.\n *\n * @public\n */\nexport const SHADER_TEXTURE_FALLBACKS = [\"white\", \"black\", \"transparent\"] as const;\n\n/**\n * Which 1x1 texture is bound to a declared sampler that nothing has filled in\n * (Godot's `hint_default_*`).\n *\n * @public\n */\nexport type ShaderTextureFallback = (typeof SHADER_TEXTURE_FALLBACKS)[number];\n\n/**\n * How a shader material composites its fragments.\n *\n * @public\n */\nexport const SHADER_BLEND_MODES = [\"opaque\", \"alpha\", \"additive\", \"premultiplied\"] as const;\n\n/**\n * The blend modes a declaration may ask for.\n *\n * @public\n */\nexport type ShaderBlendMode = (typeof SHADER_BLEND_MODES)[number];\n\n/**\n * Which faces are drawn. `\"front\"` is accepted by the grammar and refused by the parser, because\n * Babylon Lite 1.27.0 exposes only `backFaceCulling`.\n *\n * @public\n */\nexport const SHADER_CULL_MODES = [\"back\", \"front\", \"none\"] as const;\n\n/**\n * The face-culling modes a declaration may ask for. `\"front\"` is refused: Babylon Lite 1.27.0\n * exposes only `backFaceCulling`.\n *\n * @public\n */\nexport type ShaderCullMode = (typeof SHADER_CULL_MODES)[number];\n\n/**\n * Which instance streams the vertex stage reads.\n *\n * @public\n */\nexport const SHADER_INSTANCING_MODES = [\"none\", \"matrices\", \"matrices-colors\"] as const;\n\n/**\n * How a declaration expects to be drawn: one mesh at a time, or thin-instanced with a matrix slab\n * and optionally a per-instance colour.\n *\n * @public\n */\nexport type ShaderInstancingMode = (typeof SHADER_INSTANCING_MODES)[number];\n\n/**\n * One `// @ignifx uniform …` line: a value a material sets and the vertex or fragment stage reads\n * as `shaderUniforms.<name>`.\n *\n * @public\n */\nexport interface ShaderUniformDeclaration {\n /** The WGSL identifier. */\n readonly name: string;\n /** The WGSL type. */\n readonly type: ShaderUniformType;\n /**\n * The value a material starts with. A colour default is the **sRGB** value the file wrote; the\n * material layer decodes it to linear on the way to the GPU.\n */\n readonly defaultValue: number | readonly number[];\n /** Whether the value is a colour, declared with `color(…)` or the bare `color` modifier. */\n readonly color: boolean;\n /** The inclusive slider bounds an inspector should offer, or `null`. */\n readonly range: readonly [number, number] | null;\n /** The slider increment an inspector should use, or `null`. */\n readonly step: number | null;\n /** One sentence describing the uniform, or `null`. */\n readonly tooltip: string | null;\n}\n\n/**\n * One `// @ignifx texture …` line: a `texture_2d<f32>` (or `texture_2d_array<f32>`) plus the\n * `<name>Sampler` Babylon Lite generates beside it.\n *\n * @public\n */\nexport interface ShaderTextureDeclaration {\n /** The WGSL identifier; the sampler is `<name>Sampler`. */\n readonly name: string;\n /** Whether the texture holds sRGB-encoded colour, which the texture import needs to know. */\n readonly srgb: boolean;\n /** Whether the texture is a tangent-space normal map. */\n readonly normal: boolean;\n /**\n * Which 1x1 texture is bound when a material binds nothing, or `null` for the implicit `\"white\"`.\n *\n * @remarks\n * A declared sampler that nothing fills in cannot be left unbound: Babylon Lite refuses to build\n * a bind group for it (error 309), so *something* is always bound.\n */\n readonly fallback: ShaderTextureFallback | null;\n /** Whether the binding is a `texture_2d_array<f32>` rather than a `texture_2d<f32>`. */\n readonly array: boolean;\n}\n\n/**\n * One `// @ignifx storage …` line: a read-only storage buffer the shader indexes.\n *\n * @public\n */\nexport interface ShaderStorageDeclaration {\n /** The WGSL identifier. */\n readonly name: string;\n /** The WGSL variable type, verbatim, for example `array<Particle>`. */\n readonly type: string;\n}\n\n/**\n * One `// @ignifx define …` line: a WGSL `const` a material may override.\n *\n * @public\n */\nexport interface ShaderDefineDeclaration {\n /** The WGSL identifier. */\n readonly name: string;\n /** The value; a boolean compiles to `bool`, a number to `f32`. */\n readonly value: boolean | number;\n}\n\n/**\n * The three hooks a `.surface.wgsl` file may provide.\n *\n * @public\n */\nexport const SURFACE_HOOK_NAMES = [\"displace\", \"surface\", \"composite\"] as const;\n\n/**\n * One of the three surface-shader hooks.\n *\n * @public\n */\nexport type SurfaceHookName = (typeof SURFACE_HOOK_NAMES)[number];\n\n/**\n * The uniform block name a surface shader reads its declared uniforms from.\n *\n * @public\n */\nexport const SURFACE_UNIFORM_BLOCK = \"surfaceUniforms\";\n\n/**\n * The pipeline state a `// @ignifx blend …` line declares.\n *\n * @public\n */\nexport interface ShaderPipelineState {\n /** How fragments are composited. */\n readonly blend: ShaderBlendMode;\n /** Which faces are drawn. */\n readonly cull: ShaderCullMode;\n /**\n * Whether the draw writes depth. Defaults to `true` for an opaque surface and `false` for a\n * blended one — Babylon Lite's own rule — unless the file says `depthWrite on` explicitly.\n */\n readonly depthWrite: boolean;\n /** Whether the draw depth-tests at all; `false` compiles `depthCompare: \"always\"`. */\n readonly depthTest: boolean;\n /** Whether the surface samples the opaque scene colour behind it. Requires a blended surface. */\n readonly transmissive: boolean;\n /** Which instance streams the vertex stage reads. */\n readonly instancing: ShaderInstancingMode;\n}\n\n/**\n * Everything a `.wgsl` file declares about itself — the parsed pragmas, with defaults filled in.\n *\n * @public\n */\nexport interface ShaderDeclaration {\n /** Which of the three authoring forms the file is. */\n readonly kind: ShaderKind;\n /** The vertex attributes the vertex stage reads. A `\"shader\"` file always includes `position`. */\n readonly attributes: readonly ShaderAttributeName[];\n /** The Babylon Lite system uniforms, read as `shaderSystem.<name>`. */\n readonly system: readonly LiteSystemUniformName[];\n /** The ignifx-provided uniforms, read as `shaderUniforms.<name>` and written every frame. */\n readonly ignifx: readonly IgnifxUniformName[];\n /** The custom uniforms, read as `shaderUniforms.<name>`. */\n readonly uniforms: readonly ShaderUniformDeclaration[];\n /** The samplers, each generating `<name>` and `<name>Sampler`. */\n readonly textures: readonly ShaderTextureDeclaration[];\n /** The read-only storage buffers. */\n readonly storage: readonly ShaderStorageDeclaration[];\n /** The WGSL `const` declarations a material may override. */\n readonly defines: readonly ShaderDefineDeclaration[];\n /** The pipeline state. */\n readonly pipeline: ShaderPipelineState;\n /**\n * The furthest, in world metres, the vertex stage moves a vertex from where the mesh puts it: the\n * `// @ignifx displace <metres>` line, or `0` when the file has none. Every mesh drawn with the\n * material gets bounds this much larger, so a directional shadow map and GPU instance culling\n * still cover the moved shape.\n */\n readonly displace: number;\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,eAAe;CAAC;CAAU;CAAW;AAAM;;;;;;AAexD,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAeA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;AAqBA,MAAa,4BAA4B;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;AAgBA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAeA,MAAa,uBAA+E,OAAO,OAAO;CACxG,MAAM;CACN,cAAc;CACd,WAAW;CACX,oBAAoB;CACpB,gBAAgB;CAChB,cAAc;AAChB,CAAC;;;;;;AAOD,MAAa,2BAA2B;CAAC;CAAS;CAAS;AAAa;;;;;;AAexE,MAAa,qBAAqB;CAAC;CAAU;CAAS;CAAY;AAAe;;;;;;;AAejF,MAAa,oBAAoB;CAAC;CAAQ;CAAS;AAAM;;;;;;AAezD,MAAa,0BAA0B;CAAC;CAAQ;CAAY;AAAiB;;;;;;AA0F7E,MAAa,qBAAqB;CAAC;CAAY;CAAW;AAAW;;;;;;AAcrE,MAAa,wBAAwB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as CoreErrorCode, t as IgnifxError } from "./ignifx-error-CRh89KUJ.js";
|
|
2
|
-
import { t as Color } from "./color-
|
|
2
|
+
import { t as Color } from "./color-DrR6GFTd.js";
|
|
3
3
|
import { n as IGNIFX_UNIFORM_TYPES, r as LITE_SYSTEM_UNIFORM_NAMES, t as IGNIFX_UNIFORM_NAMES } from "./shader-declaration-5q__jycG.js";
|
|
4
4
|
//#region \0rolldown/runtime.js
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -172,7 +172,7 @@ let adapter = null;
|
|
|
172
172
|
*/
|
|
173
173
|
async function loadShaderMaterialAdapter() {
|
|
174
174
|
if (adapter !== null) return;
|
|
175
|
-
const loaded = await import("./shader-material-
|
|
175
|
+
const loaded = await import("./shader-material-U6BKZ8D1.js");
|
|
176
176
|
loaded.enableShaderUniformCaching();
|
|
177
177
|
adapter = loaded;
|
|
178
178
|
}
|
|
@@ -1006,4 +1006,4 @@ function shapeMismatch(declaration, material, expected, actual) {
|
|
|
1006
1006
|
//#endregion
|
|
1007
1007
|
export { shader_material_exports as n, shaderMaterialsOf as t };
|
|
1008
1008
|
|
|
1009
|
-
//# sourceMappingURL=shader-material-
|
|
1009
|
+
//# sourceMappingURL=shader-material-BIG3UDyu.js.map
|