@ignifx/core 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/agx-tone-mapping-Cgt844j6.js +53 -0
  2. package/dist/agx-tone-mapping-Cgt844j6.js.map +1 -0
  3. package/dist/auto-exposure-uzPn0beO.js +246 -0
  4. package/dist/auto-exposure-uzPn0beO.js.map +1 -0
  5. package/dist/bloom-hdr-CLtQj-oY.js +315 -0
  6. package/dist/bloom-hdr-CLtQj-oY.js.map +1 -0
  7. package/dist/contact-shadows-T523EXaP.js +84 -0
  8. package/dist/contact-shadows-T523EXaP.js.map +1 -0
  9. package/dist/{environment-C9AjYJgV.js → environment-DPi0_0SP.js} +19 -5
  10. package/dist/environment-DPi0_0SP.js.map +1 -0
  11. package/dist/gtao-_nr0b6-E.js +630 -0
  12. package/dist/gtao-_nr0b6-E.js.map +1 -0
  13. package/dist/hdr-output-BrUvpAsE.js +525 -0
  14. package/dist/hdr-output-BrUvpAsE.js.map +1 -0
  15. package/dist/{ignifx-error-Dq2qJMkZ.js → ignifx-error-oYdVnT1S.js} +16 -1
  16. package/dist/ignifx-error-oYdVnT1S.js.map +1 -0
  17. package/dist/index.d.ts +753 -18
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1679 -183
  20. package/dist/index.js.map +1 -1
  21. package/dist/{instanced-mesh-instance-DYwH0vLi.js → instanced-mesh-instance-NnODkvqK.js} +2 -2
  22. package/dist/{instanced-mesh-instance-DYwH0vLi.js.map → instanced-mesh-instance-NnODkvqK.js.map} +1 -1
  23. package/dist/mat4-D6exvAuO.js +949 -0
  24. package/dist/mat4-D6exvAuO.js.map +1 -0
  25. package/dist/material-CGk5mAah.js +204 -0
  26. package/dist/material-CGk5mAah.js.map +1 -0
  27. package/dist/{material-plugin-BOCB7Stt.js → material-plugin-BUlqLsap.js} +3 -204
  28. package/dist/material-plugin-BUlqLsap.js.map +1 -0
  29. package/dist/{post-effect-compiler-Dw6zW2cG.js → post-effect-compiler-CRek8VxQ.js} +2 -2
  30. package/dist/{post-effect-compiler-Dw6zW2cG.js.map → post-effect-compiler-CRek8VxQ.js.map} +1 -1
  31. package/dist/render-path-Be7WgN7r.js +166 -0
  32. package/dist/render-path-Be7WgN7r.js.map +1 -0
  33. package/dist/render-texture-C_TnaSz2.js +200 -0
  34. package/dist/render-texture-C_TnaSz2.js.map +1 -0
  35. package/dist/scene-color-passes-DlNr-qyZ.js +65 -0
  36. package/dist/scene-color-passes-DlNr-qyZ.js.map +1 -0
  37. package/dist/scene-inputs-BxGOsnIZ.js +318 -0
  38. package/dist/scene-inputs-BxGOsnIZ.js.map +1 -0
  39. package/dist/{shader-material-DRZmqA_S.js → shader-material-B6p66wB8.js} +18 -7
  40. package/dist/shader-material-B6p66wB8.js.map +1 -0
  41. package/dist/{shader-material-BxQn9FT4.js → shader-material-C0TAUr4t.js} +102 -4
  42. package/dist/shader-material-C0TAUr4t.js.map +1 -0
  43. package/dist/{shader-pragma-DrFm5f5m.js → shader-pragma-BKCoZTTA.js} +2 -2
  44. package/dist/{shader-pragma-DrFm5f5m.js.map → shader-pragma-BKCoZTTA.js.map} +1 -1
  45. package/dist/ssgi-Dm-maZrc.js +113 -0
  46. package/dist/ssgi-Dm-maZrc.js.map +1 -0
  47. package/dist/{surface-shader-BgZchRBe.js → surface-shader-BaK0kvBB.js} +5 -4
  48. package/dist/{surface-shader-BgZchRBe.js.map → surface-shader-BaK0kvBB.js.map} +1 -1
  49. package/dist/taa-BwBZLy11.js +480 -0
  50. package/dist/taa-BwBZLy11.js.map +1 -0
  51. package/dist/{vec3-T2PasQZv.js → vec3-D-0Y2mzE.js} +4 -948
  52. package/dist/vec3-D-0Y2mzE.js.map +1 -0
  53. package/package.json +1 -1
  54. package/dist/environment-C9AjYJgV.js.map +0 -1
  55. package/dist/ignifx-error-Dq2qJMkZ.js.map +0 -1
  56. package/dist/material-plugin-BOCB7Stt.js.map +0 -1
  57. package/dist/shader-material-BxQn9FT4.js.map +0 -1
  58. package/dist/shader-material-DRZmqA_S.js.map +0 -1
  59. package/dist/vec3-T2PasQZv.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,13 +1,16 @@
1
- import { a as CORE_ERROR_MESSAGES, c as THIRD_PARTY_ERROR_PREFIX, i as isIgnifxError, l as isValidErrorCode, n as assertNever, o as CoreErrorCode, r as formatErrorMessage, s as ErrorRange, t as IgnifxError } from "./ignifx-error-Dq2qJMkZ.js";
1
+ import { a as CORE_ERROR_MESSAGES, c as THIRD_PARTY_ERROR_PREFIX, i as isIgnifxError, l as isValidErrorCode, n as assertNever, o as CoreErrorCode, r as formatErrorMessage, s as ErrorRange, t as IgnifxError } from "./ignifx-error-oYdVnT1S.js";
2
2
  import { _ as smoothStep, a as clamp, c as deltaAngleDegrees, d as lerpAngleDegrees, f as moveTowards, g as sign, h as repeat, i as approximately, l as inverseLerp, m as radToDeg, n as EPSILON, o as clamp01, p as pingPong, r as RAD_TO_DEG, s as degToRad, t as DEG_TO_RAD, u as lerp, v as wrapAngleDegrees } from "./math-utils-BcDnL-gi.js";
3
- import { $ as basisToQuatToRef, A as setMeshReceiveShadows, B as localPosition, C as overrideSubtreeMaterials, D as setMeshId, E as setMeshBounds, F as updateMeshPositions$1, G as readWorldMatrix, H as localScale, I as updateMeshUvs$1, J as setNodeSelfVisible, K as reparentKeepingWorld, L as createNode, M as setMeshSubtreeVisible, N as updateMeshColors$1, O as setMeshMaterial, P as updateMeshNormals$1, Q as Mat4, R as disposeNode, S as disposeMeshTemplate, T as removeMeshFromScene, U as parentNode, V as localRotation, W as readNodeTag, X as worldMatrixVersion, Y as tagNode, Z as MAT4_IDENTITY, _ as createMeshFromGeometry, a as VEC3_ONE, b as createTorusMesh, c as VEC3_ZERO, d as cloneMeshUnderNode, f as collectSubtreeMeshes, g as createGroundMesh, h as createCylinderMesh, i as VEC3_LEFT, j as setMeshRenderOrder, k as setMeshPickable, l as Vec3, m as createCapsuleMesh, n as VEC3_DOWN, o as VEC3_RIGHT, p as createBoxMesh, q as setNodeName, r as VEC3_FORWARD, s as VEC3_UP, t as VEC3_BACKWARD, u as addMeshToScene, v as createPlaneMesh, w as recomputeMeshBounds, x as detachMeshBounds, y as createSphereMesh, z as linkParent } from "./vec3-T2PasQZv.js";
3
+ import { n as Mat4, r as basisToQuatToRef, t as MAT4_IDENTITY } from "./mat4-D6exvAuO.js";
4
+ import { A as setMeshReceiveShadows, B as localPosition, C as overrideSubtreeMaterials, D as setMeshId, E as setMeshBounds, F as updateMeshPositions$1, G as readWorldMatrix, H as localScale, I as updateMeshUvs$1, J as setNodeSelfVisible, K as reparentKeepingWorld, L as createNode, M as setMeshSubtreeVisible, N as updateMeshColors$1, O as setMeshMaterial, P as updateMeshNormals$1, R as disposeNode, S as disposeMeshTemplate, T as removeMeshFromScene, U as parentNode, V as localRotation, W as readNodeTag, X as worldMatrixVersion, Y as tagNode, _ as createMeshFromGeometry, a as VEC3_ONE, b as createTorusMesh, c as VEC3_ZERO, d as cloneMeshUnderNode, f as collectSubtreeMeshes, g as createGroundMesh, h as createCylinderMesh, i as VEC3_LEFT, j as setMeshRenderOrder, k as setMeshPickable, l as Vec3, m as createCapsuleMesh, n as VEC3_DOWN, o as VEC3_RIGHT, p as createBoxMesh, q as setNodeName, r as VEC3_FORWARD, s as VEC3_UP, t as VEC3_BACKWARD, u as addMeshToScene, v as createPlaneMesh, w as recomputeMeshBounds, x as detachMeshBounds, y as createSphereMesh, z as linkParent } from "./vec3-D-0Y2mzE.js";
4
5
  import { t as Color } from "./color-DrR6GFTd.js";
5
- import { a as readSceneImageProcessing, c as setSceneEnvironmentRotation, l as setSceneFog, n as installSceneEnvironment, o as setSceneClearColor, r as loadSceneEnvironment, s as setSceneEnvironmentBlur, t as TONE_MAPPING_NAMES, u as setSceneImageProcessingOptions } from "./environment-C9AjYJgV.js";
6
- import { a as defineMaterialPlugin, c as MATERIAL_ALPHA_MODES, d as createStandardMaterialFromProps, f as markMaterialDirty, g as setPbrMetallicRoughness, h as setPbrBaseColor, i as MATERIAL_PLUGIN_SAMPLER_BUDGET, l as createDefaultMaterial, m as setMaterialAlpha, n as MATERIAL_PLUGIN_DEFAULT_PRIORITY, o as isLiteMaterialPluginPoint, r as MATERIAL_PLUGIN_RESERVED_NAMES, t as LITE_MATERIAL_PLUGIN_POINTS, u as createPbrMaterialFromProps } from "./material-plugin-BOCB7Stt.js";
6
+ import { a as readSceneImageProcessing, c as setSceneEnvironmentRotation, l as setSceneFog, n as installSceneEnvironment, o as setSceneClearColor, r as loadSceneEnvironment, s as setSceneEnvironmentBlur, t as TONE_MAPPING_NAMES, u as setSceneImageProcessingOptions } from "./environment-DPi0_0SP.js";
7
+ import { a as markMaterialDirty, c as setPbrBaseColor, i as createStandardMaterialFromProps, l as setPbrMetallicRoughness, n as createDefaultMaterial, r as createPbrMaterialFromProps, s as setMaterialAlpha, t as MATERIAL_ALPHA_MODES } from "./material-CGk5mAah.js";
7
8
  import { t as setOwnJsonProperty } from "./json-CzZZ6K4x.js";
8
9
  import { a as postEffectValuesCodec, i as declaredTextureBinding, n as POST_EFFECT_FUNCTION, o as asJsonArray, r as customEffect, s as asJsonObject, t as POST_EFFECT_BUILTIN_UNIFORMS } from "./post-effect-BHl7U56q.js";
10
+ import { n as installOffscreenRenderPath } from "./render-path-Be7WgN7r.js";
9
11
  import { a as SHADER_BLEND_MODES, c as SHADER_KINDS, d as SURFACE_HOOK_NAMES, f as SURFACE_UNIFORM_BLOCK, i as SHADER_ATTRIBUTE_NAMES, l as SHADER_TEXTURE_FALLBACKS, o as SHADER_CULL_MODES, r as LITE_SYSTEM_UNIFORM_NAMES, s as SHADER_INSTANCING_MODES, t as IGNIFX_UNIFORM_NAMES, u as SHADER_UNIFORM_TYPES } from "./shader-declaration-5q__jycG.js";
10
- import { acquireTexture, addTask, addToScene, buildFrameGraphTask, captureScreenshot, cloneTransformNode, createBloomPostProcessTask, createCopyToTextureTask, createCsmDirectionalShadowGenerator, createDirectionalLight, createEngine, createEsmDirectionalShadowGenerator, createFontFromBuffer, createFreeCamera, createGpuPicker, createHemisphericLight, createImageProcessingTask, createMeshFromData, createNullEngine, createPcfDirectionalShadowGenerator, createPcfSpotlightShadowGenerator, createPointLight, createRenderTarget, createRenderTask, createSceneContext, createSmaaPostProcessTask, createSpotLight, createStorageBuffer, createTexture2DFromPixels, disableOrthographicCamera, disposeEngine, disposePicker, disposeScene, disposeStorageBuffer, enableBoneControl, enableDeviceLostSceneRecovery, enableMaterialPlugins, enableMaterialStencil, enableOrthographicCamera, enablePbrLightmap, enableSkeletonShadows, enableStandardSkeleton, forceWebGpuDeviceLossForTesting, getEffectiveAspectRatio, getFrameGraph, getProjectionMatrix, getRenderTaskGpuTimings, getViewMatrix, getViewProjectionMatrix, isPbrMaterial, isShaderMaterial, loadTexture2D, onBeforeRender, pickAsync, pickWithRay, rebuildSceneRenderables, registerScene, registerSceneWithShadowSupport, releaseTexture, removeFromScene, resizeEngine, resolveCameraViewport, setGpuTimingEnabled, setShadowTaskCasterMeshes, setSubtreeVisible, setSurfaceSize, startEngine, stopEngine, updateStorageBuffer, updateTexture2DFromPixels } from "@babylonjs/lite";
12
+ import { a as defineMaterialPlugin, i as MATERIAL_PLUGIN_SAMPLER_BUDGET, n as MATERIAL_PLUGIN_DEFAULT_PRIORITY, o as isLiteMaterialPluginPoint, r as MATERIAL_PLUGIN_RESERVED_NAMES, t as LITE_MATERIAL_PLUGIN_POINTS } from "./material-plugin-BUlqLsap.js";
13
+ import { acquireTexture, addTask, addToScene, buildFrameGraphTask, captureScreenshot, cloneTransformNode, createBloomPostProcessTask, createCsmDirectionalShadowGenerator, createDirectionalLight, createEngine, createEsmDirectionalShadowGenerator, createFontFromBuffer, createFreeCamera, createGpuPicker, createHemisphericLight, createImageProcessingTask, createMeshFromData, createNullEngine, createPcfDirectionalShadowGenerator, createPcfSpotlightShadowGenerator, createPointLight, createRenderTarget, createSceneContext, createSmaaPostProcessTask, createSpotLight, createStorageBuffer, createTexture2DFromPixels, disableOrthographicCamera, disposeEngine, disposePicker, disposeScene, disposeStorageBuffer, enableBoneControl, enableDeviceLostSceneRecovery, enableMaterialPlugins, enableMaterialStencil, enableOrthographicCamera, enablePbrLightmap, enableSkeletonShadows, enableStandardSkeleton, forceWebGpuDeviceLossForTesting, getEffectiveAspectRatio, getFrameGraph, getProjectionMatrix, getRenderTaskGpuTimings, getViewMatrix, getViewProjectionMatrix, isPbrMaterial, isShaderMaterial, loadTexture2D, onBeforeRender, pickAsync, pickWithRay, rebuildSceneRenderables, registerScene, registerSceneWithShadowSupport, releaseTexture, removeFromScene, resizeEngine, resolveCameraViewport, setGpuTimingEnabled, setRenderTaskGpuTimingEnabled, setShadowTaskCasterMeshes, setSubtreeVisible, setSurfaceSize, startEngine, stopEngine, updateStorageBuffer, updateTexture2DFromPixels } from "@babylonjs/lite";
11
14
  //#region src/signal/signal.ts
12
15
  /** One attached handler. `handler === null` marks the entry dead and awaiting compaction. */
13
16
  var Connection = class {
@@ -4814,7 +4817,7 @@ function createServiceKey(name) {
4814
4817
  *
4815
4818
  * @public
4816
4819
  */
4817
- const VERSION = "0.13.0";
4820
+ const VERSION = "0.15.0";
4818
4821
  //#endregion
4819
4822
  //#region src/assets/delivery-system.ts
4820
4823
  /**
@@ -6203,6 +6206,26 @@ var Camera = class Camera extends Component {
6203
6206
  static allowMultiple = false;
6204
6207
  /** The serialized field declarations (ADR-0004). */
6205
6208
  static schema = cameraSchema();
6209
+ /**
6210
+ * The texture this camera renders into every frame, instead of the canvas, or `null` for the
6211
+ * canvas (`docs/architecture/07-rendering.md` §2.11).
6212
+ *
6213
+ * @remarks
6214
+ * A camera with a render target is never the main camera, whatever its `priority`; it draws the
6215
+ * same scene from its own view into the texture, at the texture's aspect, in every frame it is
6216
+ * enabled. Runtime state: it is not serialized. Create the texture with
6217
+ * `app.renderer.createRenderTexture`.
6218
+ *
6219
+ * @example
6220
+ * ```ts
6221
+ * const minimap = app.renderer.createRenderTexture(256, 256);
6222
+ * overhead.renderTarget = minimap;
6223
+ * const pixels = await minimap.readPixels();
6224
+ * ```
6225
+ *
6226
+ * @beta
6227
+ */
6228
+ renderTarget = null;
6206
6229
  /** Applies the schema defaults, exactly as `Component.define` would. */
6207
6230
  constructor() {
6208
6231
  super();
@@ -6369,7 +6392,12 @@ var Camera = class Camera extends Component {
6369
6392
  * @internal
6370
6393
  */
6371
6394
  sync(renderer) {
6372
- renderer.readTargetSize(this.#targetSize);
6395
+ const target = this.renderTarget;
6396
+ if (target === null) renderer.readTargetSize(this.#targetSize);
6397
+ else {
6398
+ this.#targetSize.width = target.width;
6399
+ this.#targetSize.height = target.height;
6400
+ }
6373
6401
  this.#apply();
6374
6402
  }
6375
6403
  /** Writes every field whose value differs from the one last applied. */
@@ -7146,7 +7174,7 @@ function environmentSchema() {
7146
7174
  //#endregion
7147
7175
  //#region src/render/instanced-mesh-support.ts
7148
7176
  /** The dynamically imported adapter, memoised for the process. */
7149
- let layer = null;
7177
+ let layer$1 = null;
7150
7178
  /**
7151
7179
  * Loads the thin-instance adapter, once per process.
7152
7180
  *
@@ -7155,8 +7183,8 @@ let layer = null;
7155
7183
  * @internal
7156
7184
  */
7157
7185
  async function loadInstancedMeshSupport() {
7158
- const loaded = layer ?? await import("./instanced-mesh-instance-DYwH0vLi.js");
7159
- layer = loaded;
7186
+ const loaded = layer$1 ?? await import("./instanced-mesh-instance-NnODkvqK.js");
7187
+ layer$1 = loaded;
7160
7188
  return loaded;
7161
7189
  }
7162
7190
  /**
@@ -7167,7 +7195,7 @@ async function loadInstancedMeshSupport() {
7167
7195
  * @internal
7168
7196
  */
7169
7197
  function instancedMeshSupport() {
7170
- return layer;
7198
+ return layer$1;
7171
7199
  }
7172
7200
  //#endregion
7173
7201
  //#region src/render/shader-support.ts
@@ -7183,7 +7211,7 @@ let surfaceLayer = null;
7183
7211
  * @internal
7184
7212
  */
7185
7213
  async function loadShaderSupport() {
7186
- const loaded = shaderLayer ?? await import("./shader-material-DRZmqA_S.js").then((n) => n.n);
7214
+ const loaded = shaderLayer ?? await import("./shader-material-B6p66wB8.js").then((n) => n.n);
7187
7215
  shaderLayer = loaded;
7188
7216
  await loaded.loadShaderMaterialAdapter();
7189
7217
  return loaded;
@@ -7206,7 +7234,7 @@ function shaderSupport() {
7206
7234
  * @internal
7207
7235
  */
7208
7236
  async function loadSurfaceShaderSupport() {
7209
- const loaded = surfaceLayer ?? await import("./surface-shader-BgZchRBe.js");
7237
+ const loaded = surfaceLayer ?? await import("./surface-shader-BaK0kvBB.js");
7210
7238
  surfaceLayer = loaded;
7211
7239
  return loaded;
7212
7240
  }
@@ -8963,13 +8991,13 @@ function disposeScenePicker(picker) {
8963
8991
  *
8964
8992
  * Everything here is `@internal`.
8965
8993
  *
8966
- * ## Why these need a device (verified against `@babylonjs/lite@1.27.0`)
8994
+ * ## Why these need a device (verified against `@babylonjs/lite@1.34.0`)
8967
8995
  *
8968
- * - `isGpuTimingSupported` and `getRenderTaskGpuTimings` both start with
8969
- * `engine._device.features.has("timestamp-query")` (`lib/engine/engine.js`,
8970
- * `lib/engine/gpu-task-timing.js`). SwiftShader does not expose that feature, so on the CI
8971
- * software adapter the snapshot's `status` is `"unsupported"` — which is why coding standards §10
8972
- * says GPU-timing assertions are skipped there.
8996
+ * - `isGpuTimingSupported` and `getRenderTaskGpuTimings` both check
8997
+ * `engine._device.features.has("timestamp-query")` (`lib/engine/gpu-task-timing.js`). Chromium's
8998
+ * SwiftShader now offers that feature too (GI spike S4, 2026-11-02), but its timings measure a
8999
+ * software rasteriser, so coding standards §10 still skips GPU-timing assertions there; real
9000
+ * numbers come from the host-GPU `gpu-budget` project (§7).
8973
9001
  * - `setSurfaceSize` writes `canvas.width`/`canvas.height` (`lib/engine/surface.js`), and a null
8974
9002
  * engine has no canvas at all.
8975
9003
  * - `resizeEngine` walks the engine's surfaces and re-reads each canvas's client size; for an
@@ -9072,12 +9100,29 @@ function enableGpuTiming(engine) {
9072
9100
  setGpuTimingEnabled(engine, true);
9073
9101
  }
9074
9102
  /**
9103
+ * Turns per-task GPU timing on or off, so `readRenderTaskGpuTimings` reports each frame-graph task.
9104
+ *
9105
+ * @remarks
9106
+ * Lite keeps this separate from whole-frame timing (`enableGpuTiming`), and loads its profiler with
9107
+ * a dynamic import on the first enable, so the snapshot reads `"pending"` until a later frame's
9108
+ * readback lands. Without `timestamp-query` it reads `"unsupported"`.
9109
+ *
9110
+ * @param engine - The engine to measure.
9111
+ * @param enabled - Whether to time each task.
9112
+ * @returns A promise that settles once the profiler is installed (or removed).
9113
+ *
9114
+ * @internal
9115
+ */
9116
+ async function setRenderTaskGpuTiming(engine, enabled) {
9117
+ await setRenderTaskGpuTimingEnabled(engine, enabled);
9118
+ }
9119
+ /**
9075
9120
  * Reads the latest per-task GPU timing snapshot.
9076
9121
  *
9077
9122
  * @remarks
9078
9123
  * Check `status` first: `"unsupported"` on a device without timestamp queries, `"disabled"` until
9079
9124
  * per-task timing is switched on, `"pending"` until the first readback lands, `"error"` when the
9080
- * readback failed. `tasks` is in frame execution order and its names are the frame graph's own —
9125
+ * readback failed, `"available"` otherwise. `tasks` is in frame execution order and its names are the frame graph's own —
9081
9126
  * `"shadow"`, `"scene"`, and whatever a post-process task was named.
9082
9127
  *
9083
9128
  * @param engine - The engine to read.
@@ -10073,8 +10118,9 @@ function toPcfConfig(settings) {
10073
10118
  * Maps the shared settings onto a cascaded shadow map's configuration.
10074
10119
  *
10075
10120
  * @remarks
10076
- * `cascades` becomes `numCascades` and `maxDistance` becomes `shadowMaxZ`; Lite clamps the cascade
10077
- * count to four (`index.d.ts` 3515).
10121
+ * `cascades` becomes `numCascades`, `maxDistance` becomes `shadowMaxZ`, `cascadeLambda` becomes
10122
+ * `lambda` and `cascadeBlend` becomes `cascadeBlendPercentage`; Lite clamps the cascade count to
10123
+ * four (`index.d.ts` 4202–4227).
10078
10124
  *
10079
10125
  * @param settings - The declared settings.
10080
10126
  * @returns Lite's configuration.
@@ -10088,6 +10134,9 @@ function toCsmConfig(settings) {
10088
10134
  if (settings.darkness !== void 0) config.darkness = settings.darkness;
10089
10135
  if (settings.cascades !== void 0) config.numCascades = settings.cascades;
10090
10136
  if (settings.maxDistance !== void 0) config.shadowMaxZ = settings.maxDistance;
10137
+ if (settings.stabilizeCascades !== void 0) config.stabilizeCascades = settings.stabilizeCascades;
10138
+ if (settings.cascadeLambda !== void 0) config.lambda = settings.cascadeLambda;
10139
+ if (settings.cascadeBlend !== void 0) config.cascadeBlendPercentage = settings.cascadeBlend;
10091
10140
  return config;
10092
10141
  }
10093
10142
  /**
@@ -10205,14 +10254,29 @@ function readTargetSizePx(engine, out) {
10205
10254
  readSurfaceSizePx(engine, out);
10206
10255
  }
10207
10256
  /**
10208
- * Turns whole-frame GPU timing on.
10257
+ * Turns whole-frame and per-task GPU timing on.
10209
10258
  *
10210
10259
  * @param engine - The engine to measure.
10260
+ * @returns A promise that settles once per-task timing is installed; until then `readTaskTimings`
10261
+ * reads `"pending"`.
10211
10262
  *
10212
10263
  * @internal
10213
10264
  */
10214
- function startGpuTiming(engine) {
10265
+ async function startGpuTiming(engine) {
10215
10266
  enableGpuTiming(engine);
10267
+ await setRenderTaskGpuTiming(engine, true);
10268
+ }
10269
+ /**
10270
+ * Turns per-task GPU timing off. Whole-frame timing is turned off by `disableGpuTiming`, which
10271
+ * needs no device.
10272
+ *
10273
+ * @param engine - The engine to stop measuring.
10274
+ * @returns A promise that settles once the profiler is removed.
10275
+ *
10276
+ * @internal
10277
+ */
10278
+ async function stopTaskTiming(engine) {
10279
+ await setRenderTaskGpuTiming(engine, false);
10216
10280
  }
10217
10281
  /**
10218
10282
  * Reads the latest per-task GPU timing snapshot, in ignifx's own shape.
@@ -10238,6 +10302,20 @@ function readTaskTimings(engine) {
10238
10302
  tasks
10239
10303
  };
10240
10304
  }
10305
+ /**
10306
+ * Loads the render-to-texture module (`docs/architecture/07-rendering.md` §2.11).
10307
+ *
10308
+ * @remarks
10309
+ * It is loaded on first use, so a game that never renders to a texture ships none of it
10310
+ * (`CONSTITUTION.md` §2.5).
10311
+ *
10312
+ * @returns The function that creates a texture's render pass.
10313
+ *
10314
+ * @internal
10315
+ */
10316
+ async function loadRenderTextureFactory() {
10317
+ return (await import("./render-texture-C_TnaSz2.js")).createLiteRenderTexture;
10318
+ }
10241
10319
  //#endregion
10242
10320
  //#region src/render/image-processing-color.ts
10243
10321
  /** Lite's gamma: a plain 2.2 power, not the piecewise sRGB curve. */
@@ -10297,6 +10375,26 @@ function imageProcessedColor(r, g, b, a, state, out) {
10297
10375
  return out;
10298
10376
  }
10299
10377
  /**
10378
+ * Decodes an sRGB colour the way Lite's PBR fog block decodes its fog colour, for a clear colour
10379
+ * that is image processed later on the GPU (`rendering.hdr`).
10380
+ *
10381
+ * @param r - The sRGB red component, 0 to 1.
10382
+ * @param g - The sRGB green component, 0 to 1.
10383
+ * @param b - The sRGB blue component, 0 to 1.
10384
+ * @param a - The alpha, passed through.
10385
+ * @param out - Receives the linear colour.
10386
+ * @returns `out`.
10387
+ *
10388
+ * @internal
10389
+ */
10390
+ function linearClearColor(r, g, b, a, out) {
10391
+ out.r = decode(r);
10392
+ out.g = decode(g);
10393
+ out.b = decode(b);
10394
+ out.a = a;
10395
+ return out;
10396
+ }
10397
+ /**
10300
10398
  * Lite's fog-colour decode.
10301
10399
  *
10302
10400
  * @param value - The encoded channel.
@@ -10338,6 +10436,9 @@ function applyCurve(curve, color) {
10338
10436
  case "neutral":
10339
10437
  neutral(color);
10340
10438
  return;
10439
+ case "agx":
10440
+ agx(color);
10441
+ return;
10341
10442
  default: assertNever(curve, "tone mapping");
10342
10443
  }
10343
10444
  }
@@ -10398,6 +10499,45 @@ function neutral(color) {
10398
10499
  color.g = color.g * scale + (newPeak - color.g * scale) * blend;
10399
10500
  color.b = color.b * scale + (newPeak - color.b * scale) * blend;
10400
10501
  }
10502
+ /** The lowest exposure AgX encodes, in EV around 0.18 grey. */
10503
+ const AGX_MIN_EV = -12.47393;
10504
+ /** The highest exposure AgX encodes, in EV around 0.18 grey. */
10505
+ const AGX_MAX_EV = 4.026069;
10506
+ /**
10507
+ * ignifx's AgX (`src/lite/gpu/agx-tone-mapping.ts`, Benjamin Wendt's minimal AgX base): inset,
10508
+ * log2 encode, the polynomial sigmoid, outset, then back to linear with `pow(c, 2.2)`.
10509
+ *
10510
+ * @param color - The exposed colour; overwritten.
10511
+ */
10512
+ function agx(color) {
10513
+ const r = agxEncode(.842479062253094 * color.r + .0784335999999992 * color.g + .0792237451477643 * color.b);
10514
+ const g = agxEncode(.0423282422610123 * color.r + .878468636469772 * color.g + .0791661274605434 * color.b);
10515
+ const b = agxEncode(.0423756549057051 * color.r + .0784336 * color.g + .879142973793104 * color.b);
10516
+ color.r = agxDecode(1.19687900512017 * r - .0980208811401368 * g - .0990297440797205 * b);
10517
+ color.g = agxDecode(-.0528968517574562 * r + 1.15190312990417 * g - .0989611768448433 * b);
10518
+ color.b = agxDecode(-.0529716355144438 * r - .0980434501171241 * g + 1.15107367264116 * b);
10519
+ }
10520
+ /**
10521
+ * One inset channel through AgX's log2 encode and its default-contrast sigmoid.
10522
+ *
10523
+ * @param value - The inset channel.
10524
+ * @returns The display-encoded channel.
10525
+ */
10526
+ function agxEncode(value) {
10527
+ const x = (Math.min(Math.max(Math.log2(Math.max(value, 1e-10)), AGX_MIN_EV), AGX_MAX_EV) - AGX_MIN_EV) / 16.499999;
10528
+ const x2 = x * x;
10529
+ const x4 = x2 * x2;
10530
+ return 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + .4298 * x2 + .1191 * x - .00232;
10531
+ }
10532
+ /**
10533
+ * One outset channel back to linear, as the WGSL does before Lite's encode.
10534
+ *
10535
+ * @param value - The outset channel.
10536
+ * @returns The linear channel.
10537
+ */
10538
+ function agxDecode(value) {
10539
+ return Math.max(value, 0) ** GAMMA;
10540
+ }
10401
10541
  /**
10402
10542
  * Clamps to `[0, 1]`.
10403
10543
  *
@@ -10408,6 +10548,198 @@ function saturate(value) {
10408
10548
  return Math.min(Math.max(value, 0), 1);
10409
10549
  }
10410
10550
  //#endregion
10551
+ //#region src/render/render-texture.ts
10552
+ /**
10553
+ * The largest side of a render texture, in pixels.
10554
+ *
10555
+ * @public
10556
+ */
10557
+ const RENDER_TEXTURE_MAX_SIZE = 4096;
10558
+ /**
10559
+ * The Babylon Lite `metadata` key that keeps a render-scene mesh out of every render texture.
10560
+ *
10561
+ * @remarks
10562
+ * A mesh whose `metadata[EDITOR_ONLY_METADATA_KEY]` is `true` draws in the main view but never in
10563
+ * a {@link RenderTexture}: an editor's grid or helper that must not show in its game view or
10564
+ * thumbnails. Set it on a mesh reached through a `.lite` escape hatch, such as
10565
+ * `RenderOverlay.lite.mainScene` (no stability guarantee, `CONSTITUTION.md` §3.4).
10566
+ *
10567
+ * @beta
10568
+ */
10569
+ const EDITOR_ONLY_METADATA_KEY = "ignifxEditorOnly";
10570
+ /**
10571
+ * Checks a render texture's size.
10572
+ *
10573
+ * @param width - The requested width.
10574
+ * @param height - The requested height.
10575
+ * @throws IgnifxError with code `IGX-0730` for a side that is not a whole number from 1 to
10576
+ * {@link RENDER_TEXTURE_MAX_SIZE}.
10577
+ *
10578
+ * @internal
10579
+ */
10580
+ function assertRenderTextureSize(width, height) {
10581
+ const isSide = (side) => Number.isSafeInteger(side) && side >= 1 && side <= 4096;
10582
+ if (!isSide(width) || !isSide(height)) throw new IgnifxError(CoreErrorCode.invalidRenderTextureSize, `A render texture of ${String(width)}x${String(height)}: each side must be a whole number from 1 to ${String(RENDER_TEXTURE_MAX_SIZE)}.`, { context: {
10583
+ member: "app.renderer.createRenderTexture()",
10584
+ width,
10585
+ height,
10586
+ max: RENDER_TEXTURE_MAX_SIZE
10587
+ } });
10588
+ }
10589
+ /**
10590
+ * Tells each live texture which enabled, attached camera renders into it this frame.
10591
+ *
10592
+ * @param cameras - Every camera in the world, in creation order; the last one per texture wins.
10593
+ * @param live - The renderer's live textures; a camera aiming at any other is ignored.
10594
+ *
10595
+ * @internal
10596
+ */
10597
+ function bindFrameCameras(cameras, live) {
10598
+ for (const camera of cameras) {
10599
+ const target = camera.renderTarget;
10600
+ const lite = camera.lite.camera;
10601
+ if (target instanceof RenderTextureImpl && live.has(target) && lite !== null && camera.isEnabledInHierarchy) target.setFrameCamera(lite);
10602
+ }
10603
+ }
10604
+ /**
10605
+ * The renderer's render texture: the per-frame camera choice and the one-frame requests.
10606
+ *
10607
+ * @internal
10608
+ */
10609
+ var RenderTextureImpl = class {
10610
+ width;
10611
+ height;
10612
+ #owner;
10613
+ #pass = null;
10614
+ #creating = null;
10615
+ /** The camera whose `renderTarget` this is, as the current frame's sync found it. */
10616
+ #frameCamera = null;
10617
+ #requests = [];
10618
+ #isDisposed = false;
10619
+ /**
10620
+ * Creates the texture; its GPU pass is created on first use.
10621
+ *
10622
+ * @param owner - The renderer.
10623
+ * @param width - The checked width.
10624
+ * @param height - The checked height.
10625
+ */
10626
+ constructor(owner, width, height) {
10627
+ this.#owner = owner;
10628
+ this.width = width;
10629
+ this.height = height;
10630
+ }
10631
+ get isDisposed() {
10632
+ return this.#isDisposed;
10633
+ }
10634
+ /**
10635
+ * Resolves the texture's GPU pass, creating it once.
10636
+ *
10637
+ * @param member - The API member asking, for the error.
10638
+ * @returns The pass.
10639
+ */
10640
+ async pass(member) {
10641
+ this.assertUsable(member);
10642
+ this.#creating ??= this.#owner.createPass(this.width, this.height, member).then((pass) => {
10643
+ if (this.#isDisposed) pass.dispose();
10644
+ else this.#pass = pass;
10645
+ return pass;
10646
+ }, (error) => {
10647
+ this.#creating = null;
10648
+ throw error;
10649
+ });
10650
+ const pass = await this.#creating;
10651
+ this.assertUsable(member);
10652
+ return pass;
10653
+ }
10654
+ /**
10655
+ * Queues a render through a camera on the next frame.
10656
+ *
10657
+ * @param camera - The Lite camera.
10658
+ * @returns A promise that settles once that frame has been submitted.
10659
+ */
10660
+ request(camera) {
10661
+ return new Promise((resolve) => {
10662
+ this.#requests.push({
10663
+ camera,
10664
+ resolve
10665
+ });
10666
+ });
10667
+ }
10668
+ /**
10669
+ * Notes the camera that renders into this texture every frame. The render sync system calls it
10670
+ * for every enabled camera whose `renderTarget` this is, before {@link RenderTextureImpl.flush}.
10671
+ *
10672
+ * @param camera - The Lite camera.
10673
+ */
10674
+ setFrameCamera(camera) {
10675
+ this.#frameCamera = camera;
10676
+ if (this.#pass === null && this.#creating === null) this.pass("Camera.renderTarget").catch(() => null);
10677
+ }
10678
+ /**
10679
+ * Points the pass at this frame's camera: the oldest request's, else the `renderTarget` one's,
10680
+ * else none. Requests for that camera settle once the frame is submitted.
10681
+ */
10682
+ flush() {
10683
+ const pass = this.#pass;
10684
+ const requested = this.#requests[0]?.camera ?? null;
10685
+ const camera = requested ?? this.#frameCamera;
10686
+ this.#frameCamera = null;
10687
+ if (pass === null) return;
10688
+ pass.setCamera(camera);
10689
+ if (requested === null) return;
10690
+ const served = [];
10691
+ for (let index = this.#requests.length - 1; index >= 0; index -= 1) {
10692
+ const pending = this.#requests[index];
10693
+ if (pending !== void 0 && pending.camera === requested) {
10694
+ served.push(pending);
10695
+ this.#requests.splice(index, 1);
10696
+ }
10697
+ }
10698
+ queueMicrotask(() => {
10699
+ for (const pending of served) pending.resolve();
10700
+ });
10701
+ }
10702
+ async readPixels() {
10703
+ const data = await (await this.pass("RenderTexture.readPixels()")).read();
10704
+ return {
10705
+ width: this.width,
10706
+ height: this.height,
10707
+ data
10708
+ };
10709
+ }
10710
+ dispose() {
10711
+ if (this.#isDisposed) return;
10712
+ this.#isDisposed = true;
10713
+ this.#pass?.dispose();
10714
+ this.#pass = null;
10715
+ this.#owner.release(this);
10716
+ for (const pending of this.#requests.splice(0)) pending.resolve();
10717
+ }
10718
+ /**
10719
+ * Refuses a disposed texture.
10720
+ *
10721
+ * @param member - The API member asking.
10722
+ * @throws IgnifxError with code `IGX-0731` once disposed.
10723
+ */
10724
+ assertUsable(member) {
10725
+ if (this.#isDisposed) throw renderTextureUnusableError(member);
10726
+ }
10727
+ };
10728
+ /**
10729
+ * The error for a disposed or foreign render texture.
10730
+ *
10731
+ * @param member - The API member asking.
10732
+ * @returns The error.
10733
+ *
10734
+ * @internal
10735
+ */
10736
+ function renderTextureUnusableError(member) {
10737
+ return new IgnifxError(CoreErrorCode.renderTextureUnusable, `${member}: the render texture is disposed or belongs to another app.`, {
10738
+ context: { member },
10739
+ hint: "Create a render texture with this app's app.renderer.createRenderTexture() and keep it until you dispose it."
10740
+ });
10741
+ }
10742
+ //#endregion
10411
10743
  //#region src/render/rendering-settings.ts
10412
10744
  /**
10413
10745
  * The `rendering` project settings section (`docs/architecture/04-extensions.md` §5,
@@ -10442,6 +10774,13 @@ function saturate(value) {
10442
10774
  */
10443
10775
  const CANVAS_ALPHA_MODES = ["opaque", "premultiplied"];
10444
10776
  /**
10777
+ * The ambient-occlusion qualities, in the order the inspector lists them: `"half"` computes GTAO at
10778
+ * half resolution with 2 slices of 4 steps a side, `"full"` at full resolution with 3 slices of 6.
10779
+ *
10780
+ * @public
10781
+ */
10782
+ const AMBIENT_OCCLUSION_QUALITIES = ["half", "full"];
10783
+ /**
10445
10784
  * The name the `rendering` project settings section is registered under.
10446
10785
  *
10447
10786
  * @public
@@ -10457,6 +10796,46 @@ const DEFAULT_BRDF_LUT_ADDRESS = "environments/brdf-lut.png";
10457
10796
  const DEFAULT_MSAA_SAMPLES = 4;
10458
10797
  /** The only other sample count WebGPU allows for a multisampled attachment. */
10459
10798
  const SINGLE_SAMPLE = 1;
10799
+ /**
10800
+ * The auto exposure a project that names none gets: off, metering EV −6 to 6, adapting at 2 per
10801
+ * second towards brighter scenes and 1 towards darker ones, with no compensation.
10802
+ *
10803
+ * @returns A fresh record.
10804
+ *
10805
+ * @public
10806
+ */
10807
+ function defaultAutoExposureSettings() {
10808
+ return {
10809
+ enabled: false,
10810
+ minEv: -6,
10811
+ maxEv: 6,
10812
+ speedUp: 2,
10813
+ speedDown: 1,
10814
+ compensation: 0
10815
+ };
10816
+ }
10817
+ /** The ambient-occlusion section a project that names none gets. */
10818
+ const DEFAULT_AMBIENT_OCCLUSION = {
10819
+ enabled: false,
10820
+ quality: "half",
10821
+ radius: .5,
10822
+ intensity: 1,
10823
+ falloff: .6
10824
+ };
10825
+ /**
10826
+ * The TAA record a project that names none gets: off.
10827
+ *
10828
+ * @returns A fresh record.
10829
+ */
10830
+ function defaultTaaSettings() {
10831
+ return {
10832
+ enabled: false,
10833
+ blend: .1,
10834
+ sharpness: 0,
10835
+ clamp: true,
10836
+ cutDistance: 10
10837
+ };
10838
+ }
10460
10839
  /** The clear colour a project that names none gets: opaque black. */
10461
10840
  const DEFAULT_CLEAR_COLOR = "#000000";
10462
10841
  /**
@@ -10492,7 +10871,11 @@ function defaultRenderingSettings() {
10492
10871
  b: 0,
10493
10872
  a: 1
10494
10873
  },
10495
- brdfLut: DEFAULT_BRDF_LUT_ADDRESS
10874
+ brdfLut: DEFAULT_BRDF_LUT_ADDRESS,
10875
+ hdr: false,
10876
+ autoExposure: defaultAutoExposureSettings(),
10877
+ ambientOcclusion: { ...DEFAULT_AMBIENT_OCCLUSION },
10878
+ taa: defaultTaaSettings()
10496
10879
  };
10497
10880
  }
10498
10881
  /**
@@ -10532,10 +10915,95 @@ function renderingSettingsSchema() {
10532
10915
  useFloatingOrigin: bool(false, { tooltip: "Eye-relative upload; needs useHighPrecisionMatrix." }),
10533
10916
  requiredLimits: map(f64(0, { min: 0 }), { tooltip: "Extra WebGPU device limits to request." }),
10534
10917
  clearColor: color(DEFAULT_CLEAR_COLOR, { tooltip: "The colour the scene is cleared to, in sRGB. A Camera or Environment overrides it." }),
10535
- brdfLut: str(DEFAULT_BRDF_LUT_ADDRESS, { tooltip: "Address of the RGBD BRDF lookup table." })
10918
+ brdfLut: str(DEFAULT_BRDF_LUT_ADDRESS, { tooltip: "Address of the RGBD BRDF lookup table." }),
10919
+ hdr: bool(false, { tooltip: "Render in HDR (rgba16float) and tone map in one final pass. Custom post effects ordered first see linear colour." }),
10920
+ autoExposure: record({
10921
+ enabled: bool(false, { tooltip: "Meter the HDR scene and adapt the exposure. Needs hdr." }),
10922
+ minEv: f64(-6, { tooltip: "Darkest metered EV (log2 luminance) the exposure follows." }),
10923
+ maxEv: f64(6, { tooltip: "Brightest metered EV (log2 luminance) the exposure follows." }),
10924
+ speedUp: f64(2, {
10925
+ min: 0,
10926
+ tooltip: "Adaptation rate per second when the scene gets brighter."
10927
+ }),
10928
+ speedDown: f64(1, {
10929
+ min: 0,
10930
+ tooltip: "Adaptation rate per second when the scene gets darker."
10931
+ }),
10932
+ compensation: f64(0, { tooltip: "Stops added to the computed exposure; positive is brighter." })
10933
+ }),
10934
+ ambientOcclusion: record({
10935
+ enabled: bool(false, { tooltip: "Screen-space ambient occlusion (GTAO) on environment light." }),
10936
+ quality: enumOf(AMBIENT_OCCLUSION_QUALITIES, DEFAULT_AMBIENT_OCCLUSION.quality, { tooltip: "half: half resolution, 2 slices × 4 steps. full: full resolution, 3 slices × 6 steps." }),
10937
+ radius: f64(DEFAULT_AMBIENT_OCCLUSION.radius, {
10938
+ min: .01,
10939
+ tooltip: "How far an occluder may be from the surface it darkens, in metres."
10940
+ }),
10941
+ intensity: f64(DEFAULT_AMBIENT_OCCLUSION.intensity, {
10942
+ min: 0,
10943
+ max: 8,
10944
+ tooltip: "Exponent on the visibility: 1 is physically based, larger is darker."
10945
+ }),
10946
+ falloff: f64(DEFAULT_AMBIENT_OCCLUSION.falloff, {
10947
+ min: 0,
10948
+ max: 1,
10949
+ tooltip: "Fraction of the radius over which occluders fade out."
10950
+ })
10951
+ }),
10952
+ taa: record({
10953
+ enabled: bool(false, { tooltip: "Temporal anti-aliasing. Needs rendering.hdr." }),
10954
+ blend: f64(.1, {
10955
+ min: .01,
10956
+ max: 1,
10957
+ tooltip: "Weight of the current frame; lower is smoother."
10958
+ }),
10959
+ sharpness: f64(0, {
10960
+ min: 0,
10961
+ max: 1,
10962
+ tooltip: "Output sharpening, 0 to 1."
10963
+ }),
10964
+ clamp: bool(true, { tooltip: "Clip history to the current neighbourhood, against ghosting." }),
10965
+ cutDistance: f64(10, {
10966
+ min: 0,
10967
+ tooltip: "Camera jump per frame, in world units, that resets history."
10968
+ })
10969
+ }, { tooltip: "Temporal anti-aliasing (jittered frames accumulated over time). Needs rendering.hdr." })
10536
10970
  });
10537
10971
  }
10538
10972
  /**
10973
+ * Reads the declared `ambientOcclusion` record with every field filled in and in range.
10974
+ *
10975
+ * @remarks
10976
+ * The settings store merges a section shallowly, so `ambientOcclusion: { enabled: true }` arrives
10977
+ * without the other fields (see {@link toRenderingFeatures}); each missing or out-of-range value
10978
+ * reads as its default or its nearest bound.
10979
+ *
10980
+ * @param declared - The record as resolved, possibly partial; `undefined` when absent.
10981
+ * @returns A complete record.
10982
+ *
10983
+ * @internal
10984
+ */
10985
+ function resolveAmbientOcclusion(declared) {
10986
+ const value = declared ?? {};
10987
+ const defaults = DEFAULT_AMBIENT_OCCLUSION;
10988
+ return {
10989
+ enabled: value.enabled === true,
10990
+ quality: value.quality === "full" ? "full" : "half",
10991
+ radius: Math.max(.01, finite(value.radius, defaults.radius)),
10992
+ intensity: Math.min(8, Math.max(0, finite(value.intensity, defaults.intensity))),
10993
+ falloff: Math.min(1, Math.max(0, finite(value.falloff, defaults.falloff)))
10994
+ };
10995
+ }
10996
+ /**
10997
+ * A finite number, or a fallback.
10998
+ *
10999
+ * @param input - The declared value.
11000
+ * @param fallback - What a missing or non-finite value reads as.
11001
+ * @returns The number.
11002
+ */
11003
+ function finite(input, fallback) {
11004
+ return typeof input === "number" && Number.isFinite(input) ? input : fallback;
11005
+ }
11006
+ /**
10539
11007
  * Reads the declared feature block as the adapter's own flag record.
10540
11008
  *
10541
11009
  * @remarks
@@ -10558,9 +11026,44 @@ function toRenderingFeatures(settings) {
10558
11026
  const name = RENDERING_FEATURE_NAMES[index];
10559
11027
  if (name !== void 0) features[name] = declared[name] === true;
10560
11028
  }
11029
+ if (resolveAmbientOcclusion(settings.ambientOcclusion).enabled) features["materialPlugins"] = true;
10561
11030
  return features;
10562
11031
  }
10563
11032
  /**
11033
+ * Reads the declared `taa` record with every field filled in.
11034
+ *
11035
+ * @remarks
11036
+ * The settings store merges a section shallowly (see {@link toRenderingFeatures}), so
11037
+ * `taa: { enabled: true }` arrives without the other fields; each missing or mistyped one reads as
11038
+ * its default.
11039
+ *
11040
+ * @param settings - The resolved section.
11041
+ * @returns A complete record.
11042
+ *
11043
+ * @internal
11044
+ */
11045
+ function resolveTaaSettings(settings) {
11046
+ const declared = settings.taa ?? {};
11047
+ const defaults = defaultTaaSettings();
11048
+ return {
11049
+ enabled: declared.enabled === true,
11050
+ blend: finiteOr(declared.blend, defaults.blend),
11051
+ sharpness: finiteOr(declared.sharpness, defaults.sharpness),
11052
+ clamp: declared.clamp !== false,
11053
+ cutDistance: finiteOr(declared.cutDistance, defaults.cutDistance)
11054
+ };
11055
+ }
11056
+ /**
11057
+ * A declared number, or the fallback when it is missing or not finite.
11058
+ *
11059
+ * @param value - The declared value.
11060
+ * @param fallback - The default.
11061
+ * @returns The number to use.
11062
+ */
11063
+ function finiteOr(value, fallback) {
11064
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
11065
+ }
11066
+ /**
10564
11067
  * Translates the section into the options the adapter hands `createEngine`.
10565
11068
  *
10566
11069
  * @remarks
@@ -10606,6 +11109,31 @@ function toRendererOptions(settings, resolutionScale) {
10606
11109
  function toSurfaceFormat(settings) {
10607
11110
  return settings.format === "" ? null : settings.format;
10608
11111
  }
11112
+ /**
11113
+ * The auto exposure knobs the HDR path is built with, or `null` when it stays off.
11114
+ *
11115
+ * @remarks
11116
+ * The settings store merges a section shallowly (see {@link toRenderingFeatures}), so a project that
11117
+ * writes `autoExposure: { enabled: true }` leaves the other fields `undefined`; each one falls back to
11118
+ * its default here.
11119
+ *
11120
+ * @param settings - The resolved section.
11121
+ * @returns The knobs, or `null` when `hdr` or `autoExposure.enabled` is off.
11122
+ *
11123
+ * @internal
11124
+ */
11125
+ function toAutoExposureOptions(settings) {
11126
+ const declared = settings.autoExposure;
11127
+ if (!settings.hdr || declared.enabled !== true) return null;
11128
+ const defaults = defaultAutoExposureSettings();
11129
+ return {
11130
+ minEv: declared.minEv ?? defaults.minEv,
11131
+ maxEv: declared.maxEv ?? defaults.maxEv,
11132
+ speedUp: declared.speedUp ?? defaults.speedUp,
11133
+ speedDown: declared.speedDown ?? defaults.speedDown,
11134
+ compensation: declared.compensation ?? defaults.compensation
11135
+ };
11136
+ }
10609
11137
  //#endregion
10610
11138
  //#region src/render/renderer.ts
10611
11139
  /**
@@ -10716,12 +11244,34 @@ var RendererImpl = class {
10716
11244
  #pickIdentities = /* @__PURE__ */ new WeakMap();
10717
11245
  /** The open overlays, by their Lite scene. */
10718
11246
  #overlays = /* @__PURE__ */ new Map();
11247
+ /** The render textures this renderer created and has not disposed. */
11248
+ #renderTextures = /* @__PURE__ */ new Set();
11249
+ /** What the render textures ask of this renderer. */
11250
+ #renderTextureOwner = {
11251
+ createPass: async (width, height, member) => {
11252
+ this.#assertRenderLoop(member);
11253
+ const create = await loadRenderTextureFactory();
11254
+ this.#assertRenderLoop(member);
11255
+ return create(this.engine, this.scene, width, height, EDITOR_ONLY_METADATA_KEY);
11256
+ },
11257
+ release: (texture) => {
11258
+ this.#renderTextures.delete(texture);
11259
+ }
11260
+ };
10719
11261
  #warmUp = null;
10720
11262
  #syncSystem = null;
10721
11263
  /** Adapter chunks a component asked for; `app.start()` waits for them before it reconciles. */
10722
11264
  #gpuAdapters = [];
10723
11265
  #handles = null;
10724
11266
  #presenter = null;
11267
+ /** The shared scene inputs' owner (`../lite/gpu/scene-inputs.ts`), loaded by the first acquire. */
11268
+ #sceneInputs = null;
11269
+ /** The same owner once loaded, so `dispose()` can free it synchronously. */
11270
+ #sceneInputsHost = null;
11271
+ /** The GTAO pass (`../lite/gpu/gtao.ts`), when `rendering.ambientOcclusion` is on. */
11272
+ #ambientOcclusion = null;
11273
+ /** The TAA passes (`../lite/gpu/taa.ts`), when `rendering.taa` installed them. */
11274
+ #taa = null;
10725
11275
  #defaultMaterial = null;
10726
11276
  #resolutionScale = 1;
10727
11277
  #pixelRatio;
@@ -10848,6 +11398,77 @@ var RendererImpl = class {
10848
11398
  return this.#presenter;
10849
11399
  }
10850
11400
  /**
11401
+ * Leases the shared scene inputs — depth, normals, velocity and a depth pyramid from one geometry
11402
+ * pass (`docs/architecture/07-rendering.md` §2.12) — for a screen-space effect.
11403
+ *
11404
+ * @remarks
11405
+ * The first call loads the `scene-inputs` chunk and adds the pass to the frame graph; the last
11406
+ * `release()` removes it. Nothing is loaded or added until an effect calls this.
11407
+ *
11408
+ * @returns The lease, or `null` under the null engine or once the renderer is disposed.
11409
+ *
11410
+ * @internal
11411
+ */
11412
+ async acquireSceneInputs() {
11413
+ if (this.isHeadless || this.#isDisposed) return null;
11414
+ const { engine, scene } = this;
11415
+ this.#sceneInputs ??= import("./scene-inputs-BxGOsnIZ.js").then((module) => {
11416
+ const host = module.createSceneInputsHost(engine, scene);
11417
+ this.#sceneInputsHost = host;
11418
+ if (this.#isDisposed) host.dispose();
11419
+ return host;
11420
+ });
11421
+ return (await this.#sceneInputs).acquire(this.#isSceneRegistered);
11422
+ }
11423
+ /**
11424
+ * Installs temporal anti-aliasing when `rendering.taa.enabled` is on (GI plan steps G5–G6).
11425
+ *
11426
+ * @remarks
11427
+ * Loads the `taa` chunk and leases the scene inputs only then. TAA needs the HDR render path;
11428
+ * without `rendering.hdr` it logs a warning and stays off. `app.initialize()` calls it once, after
11429
+ * the engine exists and before the scene is registered.
11430
+ *
11431
+ * @returns A promise that settles once the passes are in the frame graph, or at once when off.
11432
+ *
11433
+ * @internal
11434
+ */
11435
+ async installTemporalAntiAliasing() {
11436
+ const options = resolveTaaSettings(this.settings);
11437
+ if (!options.enabled || this.isHeadless || this.#taa !== null) return;
11438
+ const hdr = this.#presenter?.hdr ?? null;
11439
+ if (hdr === null) {
11440
+ this.#app.log.warn("rendering.taa needs rendering.hdr; temporal anti-aliasing stays off.");
11441
+ return;
11442
+ }
11443
+ const module = await import("./taa-BwBZLy11.js");
11444
+ const inputs = await this.acquireSceneInputs();
11445
+ if (inputs === null) return;
11446
+ this.#taa = module.installTemporalAntiAliasing(this.engine, this.scene, hdr, inputs, options, this.#isSceneRegistered);
11447
+ }
11448
+ /**
11449
+ * The TAA passes, when installed.
11450
+ *
11451
+ * @returns The handle, or `null`.
11452
+ *
11453
+ * @internal
11454
+ */
11455
+ get taa() {
11456
+ return this.#taa;
11457
+ }
11458
+ resetTemporalHistory() {
11459
+ this.#taa?.reset();
11460
+ }
11461
+ /**
11462
+ * How many scene-input leases are live; `0` before the first acquire.
11463
+ *
11464
+ * @returns The count.
11465
+ *
11466
+ * @internal
11467
+ */
11468
+ get sceneInputsUserCount() {
11469
+ return this.#sceneInputsHost?.userCount ?? 0;
11470
+ }
11471
+ /**
10851
11472
  * Whether `app.start()` has registered the render scene, after which Lite has compiled what it is
10852
11473
  * going to compile.
10853
11474
  *
@@ -10907,8 +11528,14 @@ var RendererImpl = class {
10907
11528
  set profileTasks(value) {
10908
11529
  this.#profileTasks = value;
10909
11530
  if (this.isHeadless) return;
10910
- if (value) startGpuTiming(this.engine);
10911
- else disableGpuTiming(this.engine);
11531
+ const reportFailure = (error) => {
11532
+ this.#app.log.warn(`renderer.profileTasks could not switch per-task GPU timing: ${String(error)}`);
11533
+ };
11534
+ if (value) startGpuTiming(this.engine).catch(reportFailure);
11535
+ else {
11536
+ disableGpuTiming(this.engine);
11537
+ stopTaskTiming(this.engine).catch(reportFailure);
11538
+ }
10912
11539
  }
10913
11540
  /**
10914
11541
  * Whether the shader clock runs in an edit-mode app.
@@ -11053,6 +11680,82 @@ var RendererImpl = class {
11053
11680
  return captureFrame(this.engine);
11054
11681
  }
11055
11682
  /**
11683
+ * Creates an offscreen texture a camera can render into.
11684
+ *
11685
+ * @param width - The width, in pixels.
11686
+ * @param height - The height, in pixels.
11687
+ * @returns The texture.
11688
+ * @throws IgnifxError with code `IGX-0730` for a side out of range, `IGX-0106` once disposed.
11689
+ */
11690
+ createRenderTexture(width, height) {
11691
+ if (this.#isDisposed) throw new IgnifxError(CoreErrorCode.appDisposed, "The app has been disposed; app.renderer.createRenderTexture() is no longer available.", { context: { member: "app.renderer.createRenderTexture()" } });
11692
+ assertRenderTextureSize(width, height);
11693
+ const texture = new RenderTextureImpl(this.#renderTextureOwner, width, height);
11694
+ this.#renderTextures.add(texture);
11695
+ return texture;
11696
+ }
11697
+ /**
11698
+ * Renders the scene through a camera into a texture on the next frame.
11699
+ *
11700
+ * @param camera - The camera.
11701
+ * @param texture - The texture.
11702
+ * @returns A promise that settles once the frame has been submitted.
11703
+ * @throws IgnifxError with code `IGX-0729`, `IGX-0731` or `IGX-0732`; see the interface.
11704
+ */
11705
+ async renderToTexture(camera, texture) {
11706
+ const member = "app.renderer.renderToTexture()";
11707
+ const owned = this.#ownedRenderTexture(texture, member);
11708
+ const lite = camera.lite.camera;
11709
+ if (lite === null) throw new IgnifxError(CoreErrorCode.renderTextureCameraDetached, "renderToTexture() needs a camera attached to an entity.", {
11710
+ context: { member },
11711
+ hint: "Pass a Camera component that is on an entity, before the entity is destroyed."
11712
+ });
11713
+ this.#assertRenderLoop(member);
11714
+ await owned.pass(member);
11715
+ await owned.request(lite);
11716
+ }
11717
+ /**
11718
+ * Points every render texture's pass at this frame's camera. The `PreRender` sync calls it after
11719
+ * the main camera is chosen.
11720
+ *
11721
+ * @param cameras - Every camera in the world, in creation order.
11722
+ *
11723
+ * @internal
11724
+ */
11725
+ syncRenderTextures(cameras) {
11726
+ if (this.isHeadless || this.#renderTextures.size === 0) return;
11727
+ bindFrameCameras(cameras, this.#renderTextures);
11728
+ for (const texture of this.#renderTextures) texture.flush();
11729
+ }
11730
+ /**
11731
+ * Narrows a texture to one this renderer made and has not disposed.
11732
+ *
11733
+ * @param texture - The texture.
11734
+ * @param member - The API member asking.
11735
+ * @returns The texture.
11736
+ * @throws IgnifxError with code `IGX-0731` otherwise.
11737
+ */
11738
+ #ownedRenderTexture(texture, member) {
11739
+ if (!(texture instanceof RenderTextureImpl) || !this.#renderTextures.has(texture)) throw renderTextureUnusableError(member);
11740
+ return texture;
11741
+ }
11742
+ /**
11743
+ * Refuses render-to-texture work that no frame would ever carry out.
11744
+ *
11745
+ * @param member - The API member asking.
11746
+ * @throws IgnifxError with code `IGX-0729` on a headless or disposed app, or while no render loop
11747
+ * runs.
11748
+ */
11749
+ #assertRenderLoop(member) {
11750
+ if (this.isHeadless || this.#isDisposed || !this.#isLoopRunning || !this.#isSceneRegistered) throw new IgnifxError(CoreErrorCode.renderTextureNeedsRenderLoop, `${member} needs a canvas-backed app whose render loop is running.`, {
11751
+ context: {
11752
+ member,
11753
+ headless: this.isHeadless
11754
+ },
11755
+ hint: this.isHeadless ? "A headless app draws nothing. Create the app with a canvas." : "Call it after app.start() has resolved, and not after app.stop()."
11756
+ });
11757
+ }
11758
+ /**
11056
11759
  * The latest per-task GPU timing snapshot.
11057
11760
  *
11058
11761
  * @returns The snapshot.
@@ -11292,6 +11995,60 @@ var RendererImpl = class {
11292
11995
  };
11293
11996
  this.#presenter = presenter;
11294
11997
  this.applyClearColor(this.settings.clearColor);
11998
+ if (!this.isHeadless && resolveAmbientOcclusion(this.settings.ambientOcclusion).enabled) this.requireGpuAdapter(this.#installAmbientOcclusion());
11999
+ }
12000
+ /**
12001
+ * Loads the GTAO chunk and builds the pass on a scene-inputs lease (`rendering.ambientOcclusion`).
12002
+ *
12003
+ * @returns A promise that settles once the pass is in the frame graph.
12004
+ */
12005
+ async #installAmbientOcclusion() {
12006
+ const settings = resolveAmbientOcclusion(this.settings.ambientOcclusion);
12007
+ const [module, inputs] = await Promise.all([import("./gtao-_nr0b6-E.js"), this.acquireSceneInputs()]);
12008
+ if (inputs === null) return;
12009
+ if (this.#isDisposed) {
12010
+ inputs.release();
12011
+ return;
12012
+ }
12013
+ const pass = await module.createAmbientOcclusion(this.engine, this.scene, inputs, {
12014
+ quality: settings.quality,
12015
+ radius: settings.radius,
12016
+ intensity: settings.intensity,
12017
+ falloff: settings.falloff,
12018
+ onError: (error) => {
12019
+ this.#app.onError.emit({
12020
+ error,
12021
+ source: "asset",
12022
+ phase: null,
12023
+ entity: null,
12024
+ component: null
12025
+ });
12026
+ }
12027
+ }, this.#isSceneRegistered);
12028
+ if (this.#isDisposed) {
12029
+ pass.dispose();
12030
+ return;
12031
+ }
12032
+ this.#ambientOcclusion = pass;
12033
+ }
12034
+ /**
12035
+ * The GTAO pass's per-frame work: gives new PBR materials the AO plugin. The `PreRender` system
12036
+ * calls it every frame; it does nothing while `rendering.ambientOcclusion` is off.
12037
+ *
12038
+ * @internal
12039
+ */
12040
+ updateAmbientOcclusion() {
12041
+ this.#ambientOcclusion?.update(this.#isSceneRegistered);
12042
+ }
12043
+ /**
12044
+ * Whether the GTAO pass is built and running.
12045
+ *
12046
+ * @returns `true` once `rendering.ambientOcclusion` has installed it.
12047
+ *
12048
+ * @internal
12049
+ */
12050
+ get isAmbientOcclusionActive() {
12051
+ return this.#ambientOcclusion !== null;
11295
12052
  }
11296
12053
  /**
11297
12054
  * Writes an sRGB colour onto the render scene's clear colour, so it presents as authored.
@@ -11332,6 +12089,7 @@ var RendererImpl = class {
11332
12089
  }
11333
12090
  /**
11334
12091
  * Re-applies the clear colour when the scene's image processing changed since it was written.
12092
+ * With `rendering.hdr` on it runs the HDR output pass's per-frame update instead.
11335
12093
  *
11336
12094
  * @remarks
11337
12095
  * The `PreRender` system calls it every frame, after the `Environment` has written its image
@@ -11341,6 +12099,11 @@ var RendererImpl = class {
11341
12099
  * @internal
11342
12100
  */
11343
12101
  refreshClearColor() {
12102
+ const hdr = this.#presenter?.hdr ?? null;
12103
+ if (hdr !== null) {
12104
+ hdr.update(this.#isSceneRegistered);
12105
+ return;
12106
+ }
11344
12107
  const current = readSceneImageProcessing(this.scene, this.#processingScratch);
11345
12108
  if (!sameImageProcessing(current, this.#clearProcessing)) this.#writeClearColor(current);
11346
12109
  }
@@ -11355,6 +12118,11 @@ var RendererImpl = class {
11355
12118
  applied.contrast = processing.contrast;
11356
12119
  applied.curve = processing.curve;
11357
12120
  const authored = this.#authoredClear;
12121
+ if ((this.#presenter?.hdr ?? null) !== null) {
12122
+ const out = linearClearColor(authored.r, authored.g, authored.b, authored.a, this.#processedClear);
12123
+ setSceneClearColor(this.scene, out.r, out.g, out.b, out.a);
12124
+ return;
12125
+ }
11358
12126
  const out = imageProcessedColor(authored.r, authored.g, authored.b, authored.a, processing, this.#processedClear);
11359
12127
  setSceneClearColor(this.scene, out.r, out.g, out.b, out.a);
11360
12128
  }
@@ -11492,15 +12260,21 @@ var RendererImpl = class {
11492
12260
  return this.#isDisposed ? [] : held;
11493
12261
  }
11494
12262
  /**
11495
- * Releases the open overlays, the picker and the warm-up probes. The core extension registers it
11496
- * as a disposer.
12263
+ * Releases the open overlays, the picker, the warm-up probes and the scene inputs. The core
12264
+ * extension registers it as a disposer.
11497
12265
  *
11498
12266
  * @internal
11499
12267
  */
11500
12268
  dispose() {
11501
12269
  this.#isDisposed = true;
11502
12270
  this.#afterRebuild.length = 0;
12271
+ this.#ambientOcclusion?.dispose();
12272
+ this.#ambientOcclusion = null;
12273
+ this.#sceneInputsHost?.dispose();
12274
+ this.#sceneInputsHost = null;
12275
+ this.#taa = null;
11503
12276
  for (const overlay of this.#overlays.values()) overlay.dispose();
12277
+ for (const texture of this.#renderTextures) texture.dispose();
11504
12278
  const picker = this.#picker;
11505
12279
  this.#picker = null;
11506
12280
  if (picker !== null) disposeScenePicker(picker);
@@ -12671,7 +13445,10 @@ function toShadowSettings(declared) {
12671
13445
  bias: declared.bias,
12672
13446
  normalBias: declared.normalBias,
12673
13447
  darkness: declared.darkness,
12674
- cascades: declared.cascades
13448
+ cascades: declared.cascades,
13449
+ stabilizeCascades: declared.stabilizeCascades,
13450
+ cascadeLambda: declared.cascadeLambda,
13451
+ cascadeBlend: declared.cascadeBlend
12675
13452
  };
12676
13453
  if (declared.maxDistance > 0) settings.maxDistance = declared.maxDistance;
12677
13454
  return settings;
@@ -12749,6 +13526,8 @@ var Light = class Light extends Component {
12749
13526
  #appliedSpotAngle = NaN;
12750
13527
  #appliedSpotExponent = NaN;
12751
13528
  #appliedShadows = false;
13529
+ /** A copy of the `shadows` record the current generator was built from, or `null` without one. */
13530
+ #appliedShadowSettings = null;
12752
13531
  #appliedIncludeSize = -1;
12753
13532
  #appliedExcludeSize = -1;
12754
13533
  #entityVersion = -1;
@@ -12921,24 +13700,28 @@ var Light = class Light extends Component {
12921
13700
  }
12922
13701
  }
12923
13702
  /**
12924
- * Attaches or detaches the shadow generator the `shadows` record asks for.
13703
+ * Attaches, rebuilds or detaches the shadow generator the `shadows` record asks for.
13704
+ *
13705
+ * @remarks
13706
+ * Lite reads every field (technique, map size, the cascade knobs) only when it builds a
13707
+ * generator, so a change to any of them on a light that already casts builds a new one.
12925
13708
  *
12926
13709
  * @param renderer - The rendering service, for the engine and the feature flags.
12927
- * @returns `true` when a generator was attached or detached.
13710
+ * @returns `true` when a generator was attached, rebuilt or detached.
12928
13711
  */
12929
13712
  #applyShadows(renderer) {
12930
13713
  const light = this.#light;
12931
13714
  const wanted = this.shadows.enabled && this.isEnabledInHierarchy && renderer.features.shadows && !renderer.isHeadless;
12932
- if (light === null || wanted === this.#appliedShadows) {
13715
+ const isStale = wanted && !sameShadowSettings(this.#appliedShadowSettings, this.shadows);
13716
+ if (light === null || wanted === this.#appliedShadows && !isStale) {
12933
13717
  this.#warnAboutShadows(renderer);
12934
13718
  return false;
12935
13719
  }
12936
13720
  if (renderer.isRebuildInFlight) return false;
12937
13721
  this.#appliedShadows = wanted;
12938
- if (!wanted) {
12939
- this.#releaseGenerator(renderer);
12940
- return true;
12941
- }
13722
+ this.#releaseGenerator(renderer);
13723
+ if (!wanted) return true;
13724
+ this.#appliedShadowSettings = { ...this.shadows };
12942
13725
  this.#generator = attachShadows(renderer.engine, light, this.shadows);
12943
13726
  renderer.needsShadowLayoutReset = true;
12944
13727
  return true;
@@ -12981,6 +13764,7 @@ var Light = class Light extends Component {
12981
13764
  const generator = this.#generator;
12982
13765
  const light = this.#light;
12983
13766
  this.#generator = null;
13767
+ this.#appliedShadowSettings = null;
12984
13768
  if (generator !== null) {
12985
13769
  detachShadows(renderer.scene, light, generator);
12986
13770
  renderer.needsShadowLayoutReset = true;
@@ -12998,6 +13782,7 @@ var Light = class Light extends Component {
12998
13782
  this.#light = null;
12999
13783
  this.#appliedType = null;
13000
13784
  this.#appliedShadows = false;
13785
+ this.#appliedShadowSettings = null;
13001
13786
  const remove = () => {
13002
13787
  if (generator !== null) {
13003
13788
  detachShadows(renderer.scene, light, generator);
@@ -13009,6 +13794,34 @@ var Light = class Light extends Component {
13009
13794
  else renderer.afterRebuild(remove);
13010
13795
  }
13011
13796
  };
13797
+ /** Every field of {@link LightShadowSettings}; Lite reads all of them when it builds a generator. */
13798
+ const SHADOW_SETTING_KEYS = [
13799
+ "enabled",
13800
+ "technique",
13801
+ "mapSize",
13802
+ "bias",
13803
+ "normalBias",
13804
+ "darkness",
13805
+ "cascades",
13806
+ "maxDistance",
13807
+ "stabilizeCascades",
13808
+ "cascadeLambda",
13809
+ "cascadeBlend"
13810
+ ];
13811
+ /**
13812
+ * Whether a generator built from `applied` still matches the declared `shadows` record.
13813
+ *
13814
+ * @param applied - The record the generator was built from, or `null` when there is none.
13815
+ * @param declared - The component's record now.
13816
+ * @returns `true` when every field is the same.
13817
+ *
13818
+ * @internal
13819
+ */
13820
+ function sameShadowSettings(applied, declared) {
13821
+ if (applied === null) return false;
13822
+ for (const key of SHADOW_SETTING_KEYS) if (applied[key] !== declared[key]) return false;
13823
+ return true;
13824
+ }
13012
13825
  /**
13013
13826
  * Builds the Lite light of one kind, unparented and at the world origin.
13014
13827
  *
@@ -13117,6 +13930,17 @@ function lightSchema() {
13117
13930
  maxDistance: f32(0, {
13118
13931
  min: 0,
13119
13932
  tooltip: "Shadow distance in metres; 0 takes Lite's default."
13933
+ }),
13934
+ stabilizeCascades: bool(false, { tooltip: "CSM only: a stable cascade fit, so shadow edges do not shimmer as the camera moves." }),
13935
+ cascadeLambda: f32(.5, {
13936
+ min: 0,
13937
+ max: 1,
13938
+ tooltip: "CSM only: cascade split spacing, 0 even to 1 logarithmic (more detail near the camera)."
13939
+ }),
13940
+ cascadeBlend: f32(.1, {
13941
+ min: 0,
13942
+ max: 1,
13943
+ tooltip: "CSM only: the fraction of a cascade that fades into the next; 0 shows hard seams."
13120
13944
  })
13121
13945
  }, { tooltip: "Shadow casting; point and hemispheric lights cannot cast (IGX-0703)." }),
13122
13946
  includeOnly: array(entityRef(), [], { tooltip: "Light only these entities' renderers." }),
@@ -14833,7 +15657,7 @@ let effectLayer = null;
14833
15657
  * @internal
14834
15658
  */
14835
15659
  async function loadPostEffectSupport() {
14836
- const [compiler, effects] = await Promise.all([compilerLayer ?? import("./post-effect-compiler-Dw6zW2cG.js"), effectLayer ?? import("./effect-task-CMbuO6Kb.js")]);
15660
+ const [compiler, effects] = await Promise.all([compilerLayer ?? import("./post-effect-compiler-CRek8VxQ.js"), effectLayer ?? import("./effect-task-CMbuO6Kb.js")]);
14837
15661
  compilerLayer = compiler;
14838
15662
  effectLayer = effects;
14839
15663
  }
@@ -14971,7 +15795,7 @@ function createShaderLoader() {
14971
15795
  type: SHADER_ASSET_TYPE,
14972
15796
  extensions: SHADER_FILE_EXTENSIONS,
14973
15797
  async load(ctx) {
14974
- const [source, pragma] = await Promise.all([ctx.fetchText(), import("./shader-pragma-DrFm5f5m.js")]);
15798
+ const [source, pragma] = await Promise.all([ctx.fetchText(), import("./shader-pragma-BKCoZTTA.js")]);
14975
15799
  const declaration = pragma.parseShaderDeclaration(source, ctx.address);
14976
15800
  await loadShaderSupport();
14977
15801
  if (declaration.kind === "surface") await loadSurfaceShaderSupport();
@@ -16845,6 +17669,12 @@ var PostProcessChain = class {
16845
17669
  #isFrameGraphBuilt;
16846
17670
  /** The sampled ping-pong links the custom effects read and write. */
16847
17671
  #sampledLinks = [];
17672
+ /** The `rgba16float` links the custom effects ahead of the HDR output pass ping-pong through. */
17673
+ #linearLinks = [];
17674
+ /** What the HDR output pass reads while the chain is enabled; `null` when no effect runs ahead of it. */
17675
+ #linearOutput = null;
17676
+ /** How many tasks run after the output pass, on display colour; only those take over the swapchain. */
17677
+ #displayTaskCount = 0;
16848
17678
  /** The recorded custom effects, in chain order. */
16849
17679
  #custom = [];
16850
17680
  /** The bloom task, when the chain has one; the one task whose tuning is retuned live. */
@@ -16882,7 +17712,9 @@ var PostProcessChain = class {
16882
17712
  const plainLinks = [];
16883
17713
  let source = presenter.sceneColor;
16884
17714
  let sourceTexture = null;
16885
- for (let index = 0; index < ordered.length; index += 1) {
17715
+ const first = effectTasks === null ? 0 : this.#recordLinearEffects(effectTasks, engine, scene, ordered);
17716
+ const linearTaskCount = this.#tasks.length;
17717
+ for (let index = first; index < ordered.length; index += 1) {
16886
17718
  const effect = ordered[index];
16887
17719
  if (effect === void 0) continue;
16888
17720
  const isLast = index === ordered.length - 1;
@@ -16910,6 +17742,8 @@ var PostProcessChain = class {
16910
17742
  source = target;
16911
17743
  sourceTexture = link?.texture ?? null;
16912
17744
  }
17745
+ this.#displayTaskCount = this.#tasks.length - linearTaskCount;
17746
+ if (this.#displayTaskCount === 0) return;
16913
17747
  presenter.setPresentEnabled(false);
16914
17748
  }
16915
17749
  /**
@@ -16970,7 +17804,8 @@ var PostProcessChain = class {
16970
17804
  const task = this.#tasks[index];
16971
17805
  if (task !== void 0) setPostProcessTaskEnabled(task, enabled);
16972
17806
  }
16973
- if (this.#tasks.length > 0) this.#presenter.setPresentEnabled(!enabled);
17807
+ if (this.#linearOutput !== null) this.#presenter.hdr?.setOutputSource(enabled ? this.#linearOutput : null);
17808
+ if (this.#displayTaskCount > 0) this.#presenter.setPresentEnabled(!enabled);
16974
17809
  }
16975
17810
  /**
16976
17811
  * Uploads every custom effect's uniform bytes, and only the ones that changed.
@@ -17019,8 +17854,15 @@ var PostProcessChain = class {
17019
17854
  }
17020
17855
  }
17021
17856
  if (this.#tasks.length > 0) this.#presenter.setPresentEnabled(true);
17857
+ if (this.#linearOutput !== null) {
17858
+ this.#presenter.hdr?.setOutputSource(null);
17859
+ this.#linearOutput = null;
17860
+ }
17022
17861
  const effects = effectTaskSupport();
17023
17862
  for (const recorded of this.#custom) effects?.disposeCustomEffect(recorded.effect);
17863
+ for (const link of this.#linearLinks) effects?.disposeEffectChainLink(link);
17864
+ this.#linearLinks.length = 0;
17865
+ this.#displayTaskCount = 0;
17024
17866
  for (const link of this.#sampledLinks) effects?.disposeEffectChainLink(link);
17025
17867
  this.#custom.length = 0;
17026
17868
  this.#sampledLinks.length = 0;
@@ -17068,6 +17910,56 @@ var PostProcessChain = class {
17068
17910
  return effects.createCustomEffectTask(engine, scene, `ignifx:post-effect:${request.address}`, wrapper, target);
17069
17911
  }
17070
17912
  /**
17913
+ * Under `rendering.hdr`, records the custom effects ordered before any built-in one ahead of the
17914
+ * output pass, where they read and write linear `rgba16float` colour (GI plan step G3).
17915
+ *
17916
+ * @remarks
17917
+ * The first reads the scene's HDR texture directly, which is already a sampled `Texture2D`, so no
17918
+ * copy is needed; the last one's link becomes the output pass's input. Built-in effects and every
17919
+ * effect after the first of them stay behind the output pass: Lite's bloom, SMAA and
17920
+ * image-processing tasks expect display colour in the surface's format.
17921
+ *
17922
+ * @param effects - The effect adapter.
17923
+ * @param engine - The engine.
17924
+ * @param scene - The scene.
17925
+ * @param ordered - The chain's effects, in order.
17926
+ * @returns How many leading effects were recorded; `0` without HDR.
17927
+ */
17928
+ #recordLinearEffects(effects, engine, scene, ordered) {
17929
+ const hdr = this.#presenter.hdr;
17930
+ if (hdr === null) return 0;
17931
+ let sourceTexture = hdr.sceneTexture;
17932
+ let count = 0;
17933
+ for (; count < ordered.length; count += 1) {
17934
+ const effect = ordered[count];
17935
+ if (effect?.name !== "custom") break;
17936
+ const link = this.#nextLinearLink(effects, engine, sourceTexture);
17937
+ const task = this.#recordCustom(effects, engine, scene, effect, sourceTexture, link.target);
17938
+ hdr.insertLinearTask(task, this.#isFrameGraphBuilt);
17939
+ this.#tasks.push(task);
17940
+ sourceTexture = link.texture;
17941
+ }
17942
+ if (count > 0) {
17943
+ this.#linearOutput = sourceTexture;
17944
+ hdr.setOutputSource(sourceTexture);
17945
+ }
17946
+ return count;
17947
+ }
17948
+ /**
17949
+ * Returns an `rgba16float` link other than the one an effect reads, creating it on first use.
17950
+ *
17951
+ * @param effects - The effect adapter.
17952
+ * @param engine - The engine.
17953
+ * @param source - The texture the next effect reads.
17954
+ * @returns The link to write.
17955
+ */
17956
+ #nextLinearLink(effects, engine, source) {
17957
+ for (const link of this.#linearLinks) if (link.texture !== source) return link;
17958
+ const created = effects.createEffectChainLink(engine, "rgba16float", engine.canvas.width, engine.canvas.height, `ignifx:post-effect-linear-${String(this.#linearLinks.length)}`);
17959
+ this.#linearLinks.push(created);
17960
+ return created;
17961
+ }
17962
+ /**
17071
17963
  * The next sampled ping-pong link that is not the one being read.
17072
17964
  *
17073
17965
  * @remarks
@@ -17254,6 +18146,181 @@ function nextLink(engine, links, source) {
17254
18146
  return created;
17255
18147
  }
17256
18148
  //#endregion
18149
+ //#region src/render/hdr-bloom-support.ts
18150
+ /** The loaded module, memoised for the process. */
18151
+ let layer = null;
18152
+ /** The pending import, so concurrent callers share it. */
18153
+ let loading = null;
18154
+ /**
18155
+ * Loads the HDR bloom chunk, once per process.
18156
+ *
18157
+ * @returns The module.
18158
+ *
18159
+ * @internal
18160
+ */
18161
+ async function loadHdrBloomSupport() {
18162
+ loading ??= import("./bloom-hdr-CLtQj-oY.js").then((module) => {
18163
+ layer = module;
18164
+ return module;
18165
+ });
18166
+ return loading;
18167
+ }
18168
+ /**
18169
+ * The HDR bloom chunk, if it has been loaded.
18170
+ *
18171
+ * @returns The module, or `null` before {@link loadHdrBloomSupport} settled.
18172
+ *
18173
+ * @internal
18174
+ */
18175
+ function hdrBloomSupport() {
18176
+ return layer;
18177
+ }
18178
+ //#endregion
18179
+ //#region src/render/screen-space-effects.ts
18180
+ /** Numbers each Lite camera object, so the key can name it. */
18181
+ let cameraIds = null;
18182
+ /** The next camera number. */
18183
+ let nextCameraId = 1;
18184
+ /**
18185
+ * The scene-colour effects of one `PostProcessStack`.
18186
+ *
18187
+ * @internal
18188
+ */
18189
+ var ScreenSpaceEffects = class {
18190
+ /** The key the current (or pending) build was started for; `""` when nothing should run. */
18191
+ #key = "";
18192
+ /** Bumped by every new build and by dispose, so a superseded async build cleans up after itself. */
18193
+ #generation = 0;
18194
+ #built = null;
18195
+ /**
18196
+ * Whether a build is live.
18197
+ *
18198
+ * @returns `true` once the passes are in the frame graph.
18199
+ */
18200
+ get isBuilt() {
18201
+ return this.#built !== null;
18202
+ }
18203
+ /**
18204
+ * How many frame-graph tasks the passes added.
18205
+ *
18206
+ * @returns The count, `0` while nothing is built.
18207
+ */
18208
+ get taskCount() {
18209
+ return this.#built?.installed.taskCount ?? 0;
18210
+ }
18211
+ /**
18212
+ * Builds, rebuilds or tears down the passes to match the records, then pushes the live tuning.
18213
+ * Called from the stack's `sync` every `PreRender`.
18214
+ *
18215
+ * @param renderer - The rendering service.
18216
+ * @param contact - The `contactShadows` record.
18217
+ * @param ssgi - The `ssgi` record.
18218
+ * @param isEnabled - Whether the stack is enabled in the hierarchy.
18219
+ */
18220
+ sync(renderer, contact, ssgi, isEnabled) {
18221
+ const key = buildKey(renderer, contact, ssgi, isEnabled);
18222
+ if (key !== this.#key) {
18223
+ this.#key = key;
18224
+ this.#teardown(renderer.isSceneRegistered);
18225
+ if (key !== "") this.#build(renderer, contact, ssgi, this.#generation).catch((failure) => {
18226
+ renderer.app.log.error(`PostProcessStack could not build contact shadows or SSGI: ${failure instanceof Error ? failure.message : String(failure)}`);
18227
+ });
18228
+ return;
18229
+ }
18230
+ const built = this.#built;
18231
+ if (built === null) return;
18232
+ built.contact?.update(contact);
18233
+ built.ssgi?.update(ssgi, renderer.isSceneRegistered);
18234
+ }
18235
+ /**
18236
+ * Removes everything, and stops a build in flight.
18237
+ *
18238
+ * @param isSceneRegistered - Whether materials the SSGI plugin leaves must be rebuilt.
18239
+ */
18240
+ dispose(isSceneRegistered) {
18241
+ this.#key = "";
18242
+ this.#teardown(isSceneRegistered);
18243
+ }
18244
+ /**
18245
+ * Frees the current build and invalidates any pending one.
18246
+ *
18247
+ * @param isSceneRegistered - Whether materials the SSGI plugin leaves must be rebuilt.
18248
+ */
18249
+ #teardown(isSceneRegistered) {
18250
+ this.#generation += 1;
18251
+ const built = this.#built;
18252
+ this.#built = null;
18253
+ if (built === null) return;
18254
+ built.ssgi?.dispose(isSceneRegistered);
18255
+ built.installed.dispose();
18256
+ built.inputs.release();
18257
+ }
18258
+ /**
18259
+ * Loads the chunks, leases the scene inputs, and installs the passes.
18260
+ *
18261
+ * @param renderer - The rendering service.
18262
+ * @param contact - The `contactShadows` record.
18263
+ * @param ssgi - The `ssgi` record.
18264
+ * @param generation - The generation this build belongs to.
18265
+ */
18266
+ async #build(renderer, contact, ssgi, generation) {
18267
+ const [inputs, wiring, contactModule, ssgiModule] = await Promise.all([
18268
+ renderer.acquireSceneInputs(),
18269
+ import("./scene-color-passes-DlNr-qyZ.js"),
18270
+ contact.enabled ? import("./contact-shadows-T523EXaP.js") : null,
18271
+ ssgi.enabled ? import("./ssgi-Dm-maZrc.js") : null
18272
+ ]);
18273
+ const presenter = renderer.presenter;
18274
+ const camera = renderer.isHeadless ? null : renderer.scene.camera;
18275
+ if (generation !== this.#generation || inputs === null || presenter === null || camera === null) {
18276
+ inputs?.release();
18277
+ return;
18278
+ }
18279
+ const { engine, scene } = renderer;
18280
+ const passes = [];
18281
+ const contactPass = contactModule?.createContactShadowsPass(engine, scene, inputs.depthTarget, camera, contact) ?? null;
18282
+ if (contactPass !== null) passes.push(contactPass);
18283
+ const ssgiPass = ssgiModule?.createSsgiPass(engine, scene, inputs.depthTarget, camera, {
18284
+ tuning: ssgi,
18285
+ halfResolution: ssgi.halfResolution,
18286
+ usePlugin: renderer.settings.hdr || renderer.features.materialPlugins
18287
+ }) ?? null;
18288
+ if (ssgiPass !== null) passes.push(ssgiPass);
18289
+ const installed = wiring.installSceneColorPasses(engine, scene, presenter, passes, renderer.isSceneRegistered);
18290
+ this.#built = {
18291
+ inputs,
18292
+ installed,
18293
+ contact: contactPass,
18294
+ ssgi: ssgiPass
18295
+ };
18296
+ contactPass?.update(contact);
18297
+ ssgiPass?.update(ssgi, renderer.isSceneRegistered);
18298
+ }
18299
+ };
18300
+ /**
18301
+ * The build's identity: which passes run, SSGI's resolution, and the camera; `""` for none.
18302
+ *
18303
+ * @param renderer - The rendering service.
18304
+ * @param contact - The `contactShadows` record.
18305
+ * @param ssgi - The `ssgi` record.
18306
+ * @param isEnabled - Whether the stack is enabled in the hierarchy.
18307
+ * @returns The key.
18308
+ */
18309
+ function buildKey(renderer, contact, ssgi, isEnabled) {
18310
+ if (!isEnabled || !contact.enabled && !ssgi.enabled || renderer.isHeadless || renderer.presenter === null) return "";
18311
+ const camera = renderer.scene.camera;
18312
+ if (camera === null) return "";
18313
+ cameraIds ??= /* @__PURE__ */ new WeakMap();
18314
+ let id = cameraIds.get(camera);
18315
+ if (id === void 0) {
18316
+ id = nextCameraId;
18317
+ nextCameraId += 1;
18318
+ cameraIds.set(camera, id);
18319
+ }
18320
+ const gi = ssgi.enabled ? `ssgi:${ssgi.halfResolution ? "half" : "full"}` : "";
18321
+ return `${contact.enabled ? "contact" : ""}|${gi}|camera:${String(id)}`;
18322
+ }
18323
+ //#endregion
17257
18324
  //#region src/render/post-process-stack.ts
17258
18325
  /**
17259
18326
  * One instance of a post-process chain, attached to the main camera's entity
@@ -17284,6 +18351,8 @@ var PostProcessStack = class PostProcessStack extends Component {
17284
18351
  static allowMultiple = false;
17285
18352
  /** The serialized field declarations (ADR-0004). */
17286
18353
  static schema = postProcessSchema();
18354
+ /** The contact-shadow and SSGI passes, which run on the scene colour before the chain. */
18355
+ #screenSpace = new ScreenSpaceEffects();
17287
18356
  /** Applies the schema defaults, exactly as `Component.define` would. */
17288
18357
  constructor() {
17289
18358
  super();
@@ -17292,6 +18361,10 @@ var PostProcessStack = class PostProcessStack extends Component {
17292
18361
  #chain = null;
17293
18362
  #built = "";
17294
18363
  #hasWarnedAboutFeature = false;
18364
+ /** The HDR bloom chain, once a stack under `rendering.hdr` asked for bloom. */
18365
+ #hdrBloom = null;
18366
+ /** Whether loading the HDR bloom chunk failed, so it is reported once. */
18367
+ #hdrBloomFailed = false;
17295
18368
  /** The shader addresses whose compilation already failed, so the report is made once each. */
17296
18369
  #failedShaders = /* @__PURE__ */ new Set();
17297
18370
  /** The entry buffer `#chainKey` refills every frame. */
@@ -17316,7 +18389,18 @@ var PostProcessStack = class PostProcessStack extends Component {
17316
18389
  * `postProcessing` rendering feature is off.
17317
18390
  */
17318
18391
  get taskCount() {
17319
- return this.#chain?.taskCount ?? 0;
18392
+ return (this.#chain?.taskCount ?? 0) + (this.#hdrBloom?.taskCount ?? 0);
18393
+ }
18394
+ /**
18395
+ * The HDR bloom chain, once it is recorded.
18396
+ *
18397
+ * @returns The chain, or `null` without `rendering.hdr`, before bloom was enabled, or while its
18398
+ * chunk loads.
18399
+ *
18400
+ * @internal
18401
+ */
18402
+ get hdrBloom() {
18403
+ return this.#hdrBloom;
17320
18404
  }
17321
18405
  /** Nothing to do at attach: the chain is built on the first sync that wants an effect. */
17322
18406
  onAttach() {
@@ -17325,10 +18409,14 @@ var PostProcessStack = class PostProcessStack extends Component {
17325
18409
  }
17326
18410
  /** Disables and disposes every task the stack recorded. */
17327
18411
  onDetach() {
18412
+ this.#screenSpace.dispose(this.#screenSpace.isBuilt && rendererOfStack(this).isSceneRegistered);
17328
18413
  const chain = this.#chain;
17329
18414
  this.#chain = null;
17330
18415
  this.#built = "";
17331
18416
  chain?.dispose();
18417
+ const bloom = this.#hdrBloom;
18418
+ this.#hdrBloom = null;
18419
+ bloom?.dispose();
17332
18420
  }
17333
18421
  /**
17334
18422
  * Builds the chain when the effects it should hold change, and keeps the recorded tasks' tuning
@@ -17351,16 +18439,61 @@ var PostProcessStack = class PostProcessStack extends Component {
17351
18439
  * @internal
17352
18440
  */
17353
18441
  sync(renderer) {
18442
+ this.#syncHdrBloom(renderer);
18443
+ this.#screenSpace.sync(renderer, this.contactShadows, this.ssgi, this.isEnabledInHierarchy);
17354
18444
  const wanted = this.#chainKey(renderer);
17355
18445
  if (wanted !== this.#built) {
17356
18446
  this.#rebuild(renderer, wanted);
17357
18447
  return;
17358
18448
  }
17359
- if (!this.#hasWarnedAboutFeature && !renderer.features.postProcessing) this.#warnAboutFeature(renderer, this.plannedChain().length);
18449
+ if (!this.#hasWarnedAboutFeature && !renderer.features.postProcessing) this.#warnAboutFeature(renderer, this.plannedChain().length + this.#screenSpaceCount());
17360
18450
  const surface = renderer.surface;
17361
18451
  applyPostProcessSettings(this.#chain, this.isEnabledInHierarchy, this.bloom, this.smaa, renderer.effectClock, surface?.width ?? 0, surface?.height ?? 0, renderer.isSceneRegistered);
17362
18452
  }
17363
18453
  /**
18454
+ * Keeps the HDR bloom chain in step with the `bloom` record under `rendering.hdr`.
18455
+ *
18456
+ * @remarks
18457
+ * The chain is built once, the first frame bloom is wanted after its chunk has loaded, and is
18458
+ * then only switched on or off: Lite cannot remove its tasks, and nothing in the record changes
18459
+ * its shape. Until the chunk is in, the frame presents without bloom.
18460
+ *
18461
+ * @param renderer - The rendering service, for the presenter and the scene.
18462
+ */
18463
+ #syncHdrBloom(renderer) {
18464
+ const hdr = renderer.presenter?.hdr ?? null;
18465
+ const isWanted = hdr !== null && this.bloom.enabled && this.isEnabledInHierarchy;
18466
+ if (this.#hdrBloom === null) {
18467
+ if (!isWanted || this.#hdrBloomFailed) return;
18468
+ const support = hdrBloomSupport();
18469
+ if (support === null) {
18470
+ loadHdrBloomSupport().catch((failure) => {
18471
+ this.#reportHdrBloomFailure(renderer, failure);
18472
+ });
18473
+ return;
18474
+ }
18475
+ this.#hdrBloom = support.installHdrBloom(renderer.engine, renderer.scene, hdr, renderer.isSceneRegistered);
18476
+ }
18477
+ const bloom = this.bloom;
18478
+ this.#hdrBloom.setEnabled(isWanted);
18479
+ this.#hdrBloom.apply({
18480
+ intensity: bloom.intensity,
18481
+ radius: bloom.radius,
18482
+ threshold: bloom.hdrThreshold
18483
+ });
18484
+ }
18485
+ /**
18486
+ * Reports, once, that the HDR bloom chunk did not load.
18487
+ *
18488
+ * @param renderer - The rendering service, for the log.
18489
+ * @param failure - What the import threw.
18490
+ */
18491
+ #reportHdrBloomFailure(renderer, failure) {
18492
+ if (this.#hdrBloomFailed) return;
18493
+ this.#hdrBloomFailed = true;
18494
+ renderer.app.log.error(`HDR bloom could not be loaded, so {entity} renders without it. ${String(failure)}`, this.entity.name);
18495
+ }
18496
+ /**
17364
18497
  * Replaces the chain with one that holds the effects the fields currently ask for.
17365
18498
  *
17366
18499
  * @remarks
@@ -17379,7 +18512,15 @@ var PostProcessStack = class PostProcessStack extends Component {
17379
18512
  previous?.dispose();
17380
18513
  const requests = this.#requests(renderer);
17381
18514
  this.#chain = recordPostProcessChain(renderer.engine, renderer.scene, renderer.presenter, renderer.isHeadless, requests, renderer.isSceneRegistered, this.isEnabledInHierarchy, this.#reportRefusedValues);
17382
- this.#warnAboutFeature(renderer, requests.length);
18515
+ this.#warnAboutFeature(renderer, requests.length + this.#screenSpaceCount());
18516
+ }
18517
+ /**
18518
+ * How many of the scene-colour passes the fields ask for.
18519
+ *
18520
+ * @returns 0, 1 or 2.
18521
+ */
18522
+ #screenSpaceCount() {
18523
+ return (this.contactShadows.enabled ? 1 : 0) + (this.ssgi.enabled ? 1 : 0);
17383
18524
  }
17384
18525
  /**
17385
18526
  * Says once, at warning level, that the stack asks for effects the project did not opt into.
@@ -17412,9 +18553,10 @@ var PostProcessStack = class PostProcessStack extends Component {
17412
18553
  */
17413
18554
  #requests(renderer) {
17414
18555
  const sourceIsSrgb = renderer.settings.srgb;
18556
+ const isHdr = renderer.settings.hdr;
17415
18557
  const requests = [];
17416
18558
  for (const entry of this.#entries()) {
17417
- if (!entry.enabled) continue;
18559
+ if (!entry.enabled || isHdr && entry.name === "bloom") continue;
17418
18560
  const settings = entry.settings;
17419
18561
  if (entry.name !== "custom" || settings === null) {
17420
18562
  requests.push({
@@ -17504,11 +18646,12 @@ var PostProcessStack = class PostProcessStack extends Component {
17504
18646
  */
17505
18647
  #chainKey(renderer) {
17506
18648
  const entries = this.#fillEntries(this.#entryScratch);
18649
+ const isHdr = renderer.settings.hdr;
17507
18650
  let key = "";
17508
18651
  let hasCustom = false;
17509
18652
  for (let index = 0; index < entries.length; index += 1) {
17510
18653
  const entry = entries[index];
17511
- if (entry === void 0 || !entry.enabled) continue;
18654
+ if (entry === void 0 || !entry.enabled || isHdr && entry.name === "bloom") continue;
17512
18655
  const settings = entry.settings;
17513
18656
  if (entry.name !== "custom" || settings === null) {
17514
18657
  key = key === "" ? entry.name : `${key},${entry.name}`;
@@ -17525,7 +18668,7 @@ var PostProcessStack = class PostProcessStack extends Component {
17525
18668
  const part = `custom:${settings.shader?.address ?? ""}:${textures}`;
17526
18669
  key = key === "" ? part : `${key},${part}`;
17527
18670
  }
17528
- if (this.bloom.enabled) key = `${key}|scale=${String(this.bloom.scale)}`;
18671
+ if (this.bloom.enabled && !isHdr) key = `${key}|scale=${String(this.bloom.scale)}`;
17529
18672
  if (hasCustom) {
17530
18673
  const surface = renderer.surface;
17531
18674
  key = `${key}|size=${String(surface?.width ?? 0)}x${String(surface?.height ?? 0)}`;
@@ -17588,6 +18731,17 @@ function fallbackTexture(app, declaration) {
17588
18731
  return shaderSupport()?.shaderMaterialsOf(app).fallbackTexture(declaration) ?? null;
17589
18732
  }
17590
18733
  /**
18734
+ * Reaches the rendering service from a stack, for the tests that drive `sync` by hand.
18735
+ *
18736
+ * @param stack - The component.
18737
+ * @returns The service.
18738
+ *
18739
+ * @internal
18740
+ */
18741
+ function rendererOfStack(stack) {
18742
+ return rendererInternals(stack.app.renderer);
18743
+ }
18744
+ /**
17591
18745
  * Builds the component's declared fields.
17592
18746
  *
17593
18747
  * @returns The schema. Built inside a function, not at module scope: a schema field is a function
@@ -17619,8 +18773,22 @@ function postProcessSchema() {
17619
18773
  min: .05,
17620
18774
  max: 1,
17621
18775
  tooltip: "Fraction of full resolution the blur runs at."
18776
+ }),
18777
+ intensity: f32(.1, {
18778
+ min: 0,
18779
+ max: 1,
18780
+ tooltip: "HDR bloom only: how much glow is mixed into the frame."
18781
+ }),
18782
+ radius: f32(.7, {
18783
+ min: 0,
18784
+ max: 1,
18785
+ tooltip: "HDR bloom only: how far the glow spreads, from tight (0) to wide (1)."
18786
+ }),
18787
+ hdrThreshold: f32(0, {
18788
+ min: 0,
18789
+ tooltip: "HDR bloom only: linear luminance below which nothing glows; 0 lets every pixel glow by its energy."
17622
18790
  })
17623
- }, { tooltip: "Bloom." }),
18791
+ }, { tooltip: "Bloom. With rendering.hdr on, HDR bloom on the linear scene colour replaces the LDR pass and reads intensity, radius and hdrThreshold; without it, the other fields apply." }),
17624
18792
  smaa: record({
17625
18793
  enabled: bool(false, { tooltip: "Whether subpixel morphological anti-aliasing runs." }),
17626
18794
  order: i32(1, { tooltip: "Position in the chain; lower runs first." }),
@@ -17646,7 +18814,51 @@ function postProcessSchema() {
17646
18814
  order: i32(10, { tooltip: "Position in the chain; lower runs first." }),
17647
18815
  values: custom(postEffectValuesCodec(), { tooltip: "Overrides of the file's declared uniform defaults, by declared name." }),
17648
18816
  textures: map(asset(TextureAsset), { tooltip: "Textures for the file's declared samplers." })
17649
- }), [], { tooltip: "Custom full-screen WGSL effects, ordered among the built-ins by order." })
18817
+ }), [], { tooltip: "Custom full-screen WGSL effects, ordered among the built-ins by order." }),
18818
+ contactShadows: record({
18819
+ enabled: bool(false, { tooltip: "Whether screen-space contact shadows run." }),
18820
+ intensity: f32(.6, {
18821
+ min: 0,
18822
+ max: 4,
18823
+ tooltip: "How dark a contact gets."
18824
+ }),
18825
+ length: f32(.3, {
18826
+ min: .001,
18827
+ tooltip: "How far each ray marches towards the light, in world units."
18828
+ }),
18829
+ thickness: f32(.35, {
18830
+ min: .001,
18831
+ tooltip: "Assumed thickness behind each depth sample, in world units."
18832
+ }),
18833
+ samples: u32(8, {
18834
+ min: 1,
18835
+ max: 64,
18836
+ tooltip: "March steps per pixel."
18837
+ })
18838
+ }, { tooltip: "Short shadows where objects meet, towards the main directional light. Runs on the scene colour before the chain; needs rendering.features.postProcessing." }),
18839
+ ssgi: record({
18840
+ enabled: bool(false, { tooltip: "Whether screen-space global illumination runs (beta, desktop tier)." }),
18841
+ intensity: f32(1, {
18842
+ min: 0,
18843
+ max: 4,
18844
+ tooltip: "How strongly the bounced light is added."
18845
+ }),
18846
+ radius: f32(2, {
18847
+ min: .001,
18848
+ tooltip: "How far each ray marches, in world units."
18849
+ }),
18850
+ samples: u32(8, {
18851
+ min: 1,
18852
+ max: 64,
18853
+ tooltip: "March steps per ray."
18854
+ }),
18855
+ halfResolution: bool(true, { tooltip: "Trace at half resolution. A change rebuilds the pass." }),
18856
+ environmentDiffuse: f32(.5, {
18857
+ min: 0,
18858
+ max: 1,
18859
+ tooltip: "How much of the environment's diffuse light remains while SSGI runs, so the bounce is not counted twice. Needs rendering.hdr or the materialPlugins feature."
18860
+ })
18861
+ }, { tooltip: "One bounce of the lit scene colour (beta, desktop tier). Runs on the scene colour before the chain; needs rendering.features.postProcessing." })
17650
18862
  });
17651
18863
  }
17652
18864
  //#endregion
@@ -17753,8 +18965,10 @@ var RenderSyncSystem = class {
17753
18965
  }
17754
18966
  castersChanged = this.#hasEsmMaterialChanged(lights) || castersChanged;
17755
18967
  this.#selectCamera(world, cameras);
18968
+ renderer.syncRenderTextures(cameras);
17756
18969
  topologyChanged = this.#applyEnvironment(world) || topologyChanged;
17757
18970
  renderer.refreshClearColor();
18971
+ renderer.updateAmbientOcclusion();
17758
18972
  this.#applyStacks(world);
17759
18973
  this.#areCastersDirty = this.#areCastersDirty || castersChanged;
17760
18974
  if (renderer.materialCacheResets.unconfirmed && !this.#isRebuildDue && !renderer.isRebuildInFlight) this.#rebuildRenderables();
@@ -17782,6 +18996,7 @@ var RenderSyncSystem = class {
17782
18996
  const camera = cameras[index];
17783
18997
  if (camera === void 0 || !camera.isEnabledInHierarchy) continue;
17784
18998
  camera.sync(renderer);
18999
+ if (camera.renderTarget !== null) continue;
17785
19000
  if (best === null || camera.priority > best.priority) best = camera;
17786
19001
  }
17787
19002
  world.setMainCamera(best);
@@ -23691,6 +24906,44 @@ const Visit = {
23691
24906
  placed: 2
23692
24907
  };
23693
24908
  /**
24909
+ * The app each live extension object is installed in.
24910
+ *
24911
+ * @remarks
24912
+ * The one piece of state shared between apps, because the question "is this object already in
24913
+ * another app?" has no answer inside a single app. An extension object may keep per-app state in
24914
+ * its factory's closure (`physics()` does), so installing it twice would let the second app take
24915
+ * over the first one's services. Created on first use (coding standards §4: nothing allocated at
24916
+ * module scope), and keyed weakly, so a dropped extension is collected.
24917
+ */
24918
+ let installedExtensions = null;
24919
+ /**
24920
+ * Records that an app installs extension objects, refusing any another live app already installed.
24921
+ *
24922
+ * @param list - The extensions.
24923
+ * @param app - The installing app.
24924
+ * @throws IgnifxError with code `IGX-0411` for an object another live app installed.
24925
+ */
24926
+ function claimExtensions(list, app) {
24927
+ const installed = installedExtensions ??= /* @__PURE__ */ new WeakMap();
24928
+ for (const extension of list) {
24929
+ const owner = installed.get(extension);
24930
+ if (owner !== void 0 && owner !== app) throw new IgnifxError(CoreErrorCode.extensionInstalledTwice, `The ${extension.name} extension object is already installed in another app that has not been disposed.`, {
24931
+ context: { extension: extension.name },
24932
+ hint: "Call the extension's factory again for each app, for example physics() once per createApp."
24933
+ });
24934
+ }
24935
+ for (const extension of list) installed.set(extension, app);
24936
+ }
24937
+ /**
24938
+ * Forgets an app's extension objects, so a new app may install them.
24939
+ *
24940
+ * @param list - The extensions.
24941
+ * @param app - The app being disposed.
24942
+ */
24943
+ function releaseExtensions(list, app) {
24944
+ for (const extension of list) if (installedExtensions?.get(extension) === app) installedExtensions.delete(extension);
24945
+ }
24946
+ /**
23694
24947
  * The extension host of one app.
23695
24948
  *
23696
24949
  * @internal
@@ -23722,12 +24975,29 @@ var ExtensionHost = class {
23722
24975
  *
23723
24976
  * @param list - The implicit core extension followed by the game's list.
23724
24977
  * @returns A promise that settles once every `register` hook has finished.
23725
- * @throws IgnifxError with code `IGX-0406` on a duplicate name, `IGX-0403` on a missing required
24978
+ * @throws IgnifxError with code `IGX-0411` for an extension object another live app installed,
24979
+ * `IGX-0406` on a duplicate name, `IGX-0403` on a missing required
23726
24980
  * extension, `IGX-0402` on a `requires` cycle, or `IGX-0404` on an `engine` mismatch in
23727
24981
  * development.
23728
24982
  */
23729
24983
  async register(list) {
23730
24984
  const sorted = this.#sort(list);
24985
+ const app = this.#options.app;
24986
+ claimExtensions(sorted, app);
24987
+ try {
24988
+ await this.#registerSorted(sorted);
24989
+ } catch (error) {
24990
+ releaseExtensions(sorted, app);
24991
+ throw error;
24992
+ }
24993
+ }
24994
+ /**
24995
+ * Validates and registers sorted extensions, in order.
24996
+ *
24997
+ * @param sorted - The extensions, dependencies first.
24998
+ * @returns A promise that settles once every `register` hook has finished.
24999
+ */
25000
+ async #registerSorted(sorted) {
23731
25001
  for (let index = 0; index < sorted.length; index += 1) {
23732
25002
  const extension = sorted[index];
23733
25003
  if (extension !== void 0) this.#checkEngineRange(extension);
@@ -23795,6 +25065,7 @@ var ExtensionHost = class {
23795
25065
  this.#reportTeardown(error);
23796
25066
  }
23797
25067
  this.#disposers.length = 0;
25068
+ releaseExtensions(this.#sorted, this.#options.app);
23798
25069
  }
23799
25070
  /**
23800
25071
  * Whether {@link ExtensionHost.dispose} has begun, for the context's dispose-time checks.
@@ -25145,132 +26416,6 @@ function isWebGpuAvailable() {
25145
26416
  return typeof navigator !== "undefined" && "gpu" in navigator;
25146
26417
  }
25147
26418
  //#endregion
25148
- //#region src/lite/gpu/render-path.ts
25149
- /**
25150
- * The offscreen render path (`docs/architecture/07-rendering.md` §2.7): the frame graph a scene gets
25151
- * when the project declares `rendering.features.postProcessing`.
25152
- *
25153
- * Everything here needs a device.
25154
- *
25155
- * ## Why the default render task is not good enough
25156
- *
25157
- * `createSceneContext` appends a task named `"scene"` that draws straight into the surface's
25158
- * swapchain target — `surface.scRT` for a single-sample surface, or an MSAA colour target that
25159
- * resolves into `scRT` (`lib/scene/scene-core.js` 74-79). Either way the scene's colour ends up in
25160
- * the swapchain texture, and a post-process pass cannot read it: `createSurface` configures the
25161
- * canvas context with no `usage` (`lib/engine/surface.js` 30), so the swapchain texture is
25162
- * `RENDER_ATTACHMENT` only. Binding it as a sampled texture fails WebGPU validation, the whole
25163
- * frame's command buffer is rejected, and the page presents black. That is exactly what the Phase 2
25164
- * visual suite measured, and it is why this module exists.
25165
- *
25166
- * Lite offers no way to retarget the default task after the fact — `RenderTaskConfig.rt` is read
25167
- * when the task is created, and `FrameGraph`'s public surface is only `build`/`execute`/`dispose`
25168
- * (`index.d.ts` 5367). So the scene is created with `defaultRenderTask: false` and this module
25169
- * builds the replacement.
25170
- *
25171
- * ## The graph it builds
25172
- *
25173
- * ```text
25174
- * [shadow] → scene ──→ sceneColor ──→ present ──→ swapchain
25175
- * └─ (a PostProcessStack appends its effects here, and disables present)
25176
- * ```
25177
- *
25178
- * - `scene` is a normal `createRenderTask`. With MSAA it draws into a multisampled colour target
25179
- * that owns its depth and resolves into `sceneColor` through `rst`; without MSAA it draws into
25180
- * `sceneColor` directly with a separate depth target, which is the same split Lite's own default
25181
- * uses (`RenderTaskConfig.depth`, `index.d.ts` 9782).
25182
- * - `sceneColor` is an ordinary `createRenderTarget`, so `buildRenderTarget` allocates it with
25183
- * `RENDER_ATTACHMENT | TEXTURE_BINDING | COPY_SRC | COPY_DST` (`lib/engine/render-target.js`) —
25184
- * the `TEXTURE_BINDING` the swapchain lacks.
25185
- * - `present` is a `createCopyToTextureTask` from `sceneColor` to the swapchain. Copying *into* the
25186
- * swapchain is supported and takes the blit path (`lib/frame-graph/copy-to-texture-task.js`,
25187
- * `swapAsView`); copying *out of* it is refused (Lite error 80), which is the same limit stated
25188
- * from the other side.
25189
- * - The swapchain is written every frame whatever else happens: with no chain, `present` does it;
25190
- * with a chain, the chain's last effect does it and `present` is switched off
25191
- * ({@link ScenePresenter.setPresentEnabled}).
25192
- *
25193
- * ## Resize
25194
- *
25195
- * Every target here is sized by passing the **surface** as `RenderTargetDescriptor.size`, which
25196
- * `resolveSize` re-reads from `canvas.width`/`canvas.height` on every `buildRenderTarget`
25197
- * (`lib/engine/render-target.js`). A surface resize calls the scene's `_resize`, which is
25198
- * `frameGraph.build()` (`lib/scene/scene-core.js` 67-68): every target is reallocated at the new
25199
- * size and every task re-records, which is also what refreshes the bind groups that captured the old
25200
- * texture views. Nothing here has to observe the canvas itself, and nothing is eagerly allocated —
25201
- * `createRenderTargetTexture` would be, and Lite rejects a surface as its size for exactly that
25202
- * reason.
25203
- */
25204
- /** The depth/stencil format Lite's own default render task uses (`lib/scene/scene-core.js` 76-77). */
25205
- const DEPTH_STENCIL_FORMAT = "depth24plus-stencil8";
25206
- /**
25207
- * Builds the scene's render task into an offscreen target and the blit that composites it, and
25208
- * appends both to the scene's frame graph.
25209
- *
25210
- * @remarks
25211
- * Call it immediately after `createSceneContext(engine, { defaultRenderTask: false })` and before
25212
- * `registerScene`: `addTask` appends, so calling it first is what puts `"scene"` ahead of everything
25213
- * a feature adds later, and `registerSceneWithShadowSupport` still unshifts its own `"shadow"` task
25214
- * in front of both.
25215
- *
25216
- * @param engine - The engine, which is also the primary surface.
25217
- * @param scene - The scene created with no default render task.
25218
- * @returns The presenter a `PostProcessStack` builds its chain against.
25219
- *
25220
- * @example
25221
- * ```ts
25222
- * const scene = createSceneContext(engine, { defaultRenderTask: false });
25223
- * const presenter = installOffscreenRenderPath(engine, scene);
25224
- * ```
25225
- *
25226
- * @internal
25227
- */
25228
- function installOffscreenRenderPath(engine, scene) {
25229
- const isMultisampled = engine.msaaSamples > 1;
25230
- const sceneColor = createRenderTarget({
25231
- lbl: "ignifx:scene-color",
25232
- format: engine.format,
25233
- samples: 1,
25234
- size: engine
25235
- });
25236
- const config = {
25237
- name: "scene",
25238
- rt: isMultisampled ? createRenderTarget({
25239
- lbl: "ignifx:scene-color-msaa",
25240
- format: engine.format,
25241
- dFormat: DEPTH_STENCIL_FORMAT,
25242
- samples: engine.msaaSamples,
25243
- size: engine
25244
- }) : sceneColor
25245
- };
25246
- if (isMultisampled) config.rst = sceneColor;
25247
- else config.depth = createRenderTarget({
25248
- lbl: "ignifx:scene-depth",
25249
- dFormat: DEPTH_STENCIL_FORMAT,
25250
- samples: 1,
25251
- size: engine
25252
- });
25253
- addTask(scene, createRenderTask(config, engine, scene));
25254
- const present = createCopyToTextureTask({
25255
- name: "ignifx:present",
25256
- sourceTexture: sceneColor,
25257
- targetTexture: engine.scRT
25258
- }, engine, scene);
25259
- addTask(scene, present);
25260
- let isPresentEnabled = true;
25261
- return {
25262
- sceneColor,
25263
- swapchain: engine.scRT,
25264
- setPresentEnabled(enabled) {
25265
- isPresentEnabled = enabled;
25266
- present.executionEnabled = enabled;
25267
- },
25268
- get isPresentEnabled() {
25269
- return isPresentEnabled;
25270
- }
25271
- };
25272
- }
25273
- //#endregion
25274
26419
  //#region src/lite/render.ts
25275
26420
  /**
25276
26421
  * The GPU half of the Babylon Lite adapter: the two calls that need a real WebGPU device. They are
@@ -25364,6 +26509,10 @@ function createHeadlessEngine() {
25364
26509
  * @param options - Device and surface options; see `createWebGpuEngine`.
25365
26510
  * @param features - Which render path to build.
25366
26511
  * @param features.postProcessing - `true` to render into an offscreen target and composite it.
26512
+ * @param features.hdr - `true` to render into an `rgba16float` target and tone map it in a final
26513
+ * pass (`./gpu/hdr-output.ts`, its own chunk, loaded only then). Implies the offscreen path.
26514
+ * @param features.autoExposure - With `hdr`, the auto exposure knobs (`./gpu/auto-exposure.ts`, its
26515
+ * own chunk, loaded only then); `null` or absent leaves it off.
25367
26516
  * @returns The engine, the scene, and the presenter when there is one.
25368
26517
  * @throws IgnifxError with code `IGX-0701` when WebGPU is unavailable.
25369
26518
  *
@@ -25372,13 +26521,20 @@ function createHeadlessEngine() {
25372
26521
  async function createRenderEngine(canvas, options, features) {
25373
26522
  assertWebGpuAvailable();
25374
26523
  const engine = await createWebGpuEngine(canvas, options);
25375
- const offscreen = features?.postProcessing === true;
26524
+ const hdr = features?.hdr === true;
26525
+ const offscreen = hdr || features?.postProcessing === true;
25376
26526
  const scene = createRenderScene(engine, { offscreen });
26527
+ let presenter = null;
26528
+ if (hdr) {
26529
+ const knobs = features.autoExposure ?? null;
26530
+ const exposure = knobs === null ? null : await import("./auto-exposure-uzPn0beO.js");
26531
+ presenter = (await import("./hdr-output-BrUvpAsE.js")).installHdrRenderPath(engine, scene, exposure === null || knobs === null ? void 0 : (hdrTexture) => exposure.installAutoExposure(engine, scene, hdrTexture, knobs));
26532
+ } else if (offscreen) presenter = installOffscreenRenderPath(engine, scene);
25377
26533
  return {
25378
26534
  engine,
25379
26535
  scene,
25380
26536
  isHeadless: false,
25381
- presenter: offscreen ? installOffscreenRenderPath(engine, scene) : null
26537
+ presenter
25382
26538
  };
25383
26539
  }
25384
26540
  /**
@@ -33719,6 +34875,8 @@ var AppImpl = class {
33719
34875
  #deviceLoss = null;
33720
34876
  #isLoopRunning = false;
33721
34877
  #isRunning = false;
34878
+ /** Whether `onStart` has run: it runs once per app, so a start after `stop()` only restarts the loop. */
34879
+ #hasStarted = false;
33722
34880
  #isDisposed = false;
33723
34881
  /**
33724
34882
  * Runs one ignifx frame from Babylon Lite's render loop.
@@ -33922,6 +35080,10 @@ var AppImpl = class {
33922
35080
  * Runs extension `onStart` hooks and starts the frame loop
33923
35081
  * (`docs/architecture/01-lifecycle-and-time.md` §1).
33924
35082
  *
35083
+ * @remarks
35084
+ * A no-op while the app runs. After `stop()` it restarts the loop where it stopped: `onStart`
35085
+ * hooks run only on the first start, and the render scene stays registered.
35086
+ *
33925
35087
  * @returns A promise that settles once the first frame has been submitted. In headless mode there
33926
35088
  * is no loop to start, so it settles once the hooks have run.
33927
35089
  * @throws IgnifxError with code `IGX-0106` when the app has been disposed.
@@ -33929,13 +35091,16 @@ var AppImpl = class {
33929
35091
  async start() {
33930
35092
  this.#assertUsable("app.start()");
33931
35093
  if (this.#isRunning) return;
33932
- await this.#host.start();
35094
+ if (!this.#hasStarted) {
35095
+ await this.#host.start();
35096
+ this.#hasStarted = true;
35097
+ }
33933
35098
  this.#isRunning = true;
33934
35099
  this.#applicationListeners(true);
33935
35100
  const handles = this.#handles;
33936
35101
  if (this.isHeadless || handles === null) return;
33937
35102
  if (this.#frameCallback !== null) throw new IgnifxError(CoreErrorCode.appNotReady, "app.start() already registered this world's frame callback.", { context: { member: "app.start()" } });
33938
- await this.#registerRenderScene(handles);
35103
+ if (!rendererInternals(this.renderer).isSceneRegistered) await this.#registerRenderScene(handles);
33939
35104
  this.#frameCallback = registerFrameCallback(handles.scene, this.#onLiteFrame);
33940
35105
  this.#isLoopRunning = true;
33941
35106
  rendererInternals(this.renderer).setLoopRunning(true);
@@ -34011,11 +35176,16 @@ var AppImpl = class {
34011
35176
  if (this.#mode === "development") await enableLiteErrorDecoding();
34012
35177
  const canvas = this.#canvas;
34013
35178
  const renderer = rendererInternals(this.renderer);
34014
- this.#handles = canvas === null ? createHeadlessEngine() : await createRenderEngine(canvas, this.#engineOptions(rendering), { postProcessing: renderer.renderingFeatures.postProcessing });
35179
+ this.#handles = canvas === null ? createHeadlessEngine() : await createRenderEngine(canvas, this.#engineOptions(rendering), {
35180
+ postProcessing: renderer.renderingFeatures.postProcessing,
35181
+ hdr: rendering.hdr,
35182
+ autoExposure: toAutoExposureOptions(rendering)
35183
+ });
34015
35184
  if (canvas !== null) this.platform.setWebGpu(await probeWebGpuInfo());
34016
35185
  this.assets.attachEngine(this.#handles.engine);
34017
35186
  renderer.attachHandles(this.#handles.engine, this.#handles.scene, this.#handles.presenter);
34018
35187
  this.#enableDeviceLossRecovery(rendering);
35188
+ await renderer.installTemporalAntiAliasing();
34019
35189
  const time = this.#settings.time;
34020
35190
  this.time.applySettings(time.fixedDeltaTime, time.maximumDeltaTime, time.timeScale);
34021
35191
  const world = createWorld({
@@ -35174,6 +36344,332 @@ function describeMeshFileFormat() {
35174
36344
  };
35175
36345
  }
35176
36346
  //#endregion
36347
+ //#region src/serialization/prefab-overrides.ts
36348
+ /**
36349
+ * Writes an instance's overrides into the prefab file it instances, so every instance of the prefab
36350
+ * gets them — Unity's "Apply to prefab" (ADR-0005).
36351
+ *
36352
+ * @remarks
36353
+ * A pure function over the two files: nothing is loaded, and the same input always gives
36354
+ * byte-identical output through {@link stringifySceneFile}. The rules:
36355
+ *
36356
+ * - Property, `enabled`, transform, and entity-field overrides change the prefab's record. An `add`
36357
+ * appends the component, keeping its uid; a `remove` deletes the component.
36358
+ * - On a prefab with exactly one root, the instance root's own `name`, `transform`, and other entity
36359
+ * fields are its placement, not prefab content, so overrides of the root's entity fields and
36360
+ * transform are skipped.
36361
+ * - Overrides reach only the prefab's own entities. Content of a scene the prefab itself instances
36362
+ * is not addressable by an override path, so a nested prefab is never edited: an override that
36363
+ * names something the prefab file does not hold is skipped.
36364
+ * - An override is skipped when an earlier override that stays on the instance overlaps its path, so
36365
+ * the instance keeps the value it had.
36366
+ * - A skipped override stays on the returned instance. The instance's own `components` are not
36367
+ * overrides and are not touched.
36368
+ * - Other instances of the prefab keep their overrides, which still win over the new prefab values
36369
+ * at the same path. Record {@link PrefabApplyResult.hash} on them, or loading them logs `IGX-0604`.
36370
+ * - References inside added components (`$entity`, `$component`) are copied unchanged.
36371
+ *
36372
+ * @param instance - The instance entry whose overrides to apply; its `scene` should name `asset`.
36373
+ * @param asset - The prefab file the entry instances.
36374
+ * @param selection - Which overrides to apply; all of them by default.
36375
+ * @returns The new prefab file and its hash, the instance entry without the applied overrides, and
36376
+ * what was applied or skipped.
36377
+ * @throws IgnifxError with code `IGX-0609` when a selected override path is outside the grammar.
36378
+ *
36379
+ * @example
36380
+ * ```ts
36381
+ * const result = await applyOverridesToAsset(spawn.instance, prefabFile);
36382
+ * await app.storage.write("prefabs/enemy.prefab.json", stringifySceneFile(result.asset));
36383
+ * ```
36384
+ *
36385
+ * @public
36386
+ */
36387
+ async function applyOverridesToAsset(instance, asset, selection) {
36388
+ const overrides = instance.overrides ?? [];
36389
+ const records = /* @__PURE__ */ new Map();
36390
+ const lookup = /* @__PURE__ */ new Map();
36391
+ const uids = /* @__PURE__ */ new Set();
36392
+ for (const entity of asset.entities) {
36393
+ const data = mutableEntity(entity);
36394
+ records.set(entity.uid, data);
36395
+ lookup.set(entity.uid, {
36396
+ data,
36397
+ components: /* @__PURE__ */ new Map()
36398
+ });
36399
+ uids.add(entity.uid);
36400
+ for (const component of entity.components ?? []) uids.add(component.uid);
36401
+ }
36402
+ const singleRootUid = singleRootOf(asset);
36403
+ const touched = /* @__PURE__ */ new Set();
36404
+ const applied = [];
36405
+ const skipped = [];
36406
+ const remaining = [];
36407
+ for (const override of overrides) {
36408
+ if (!isSelected(override, selection)) {
36409
+ remaining.push(override);
36410
+ continue;
36411
+ }
36412
+ const parsed = parseOverridePath(override.path);
36413
+ let reason = precheck(override, parsed, singleRootUid, uids) ?? shadowedBy(override, remaining);
36414
+ if (reason === null) applyOverrides([override], lookup, (message) => {
36415
+ reason ??= message;
36416
+ });
36417
+ if (reason !== null) {
36418
+ skipped.push({
36419
+ override,
36420
+ reason
36421
+ });
36422
+ remaining.push(override);
36423
+ continue;
36424
+ }
36425
+ touched.add(parsed.entity);
36426
+ const added = addedComponentUid(override);
36427
+ if (added !== null) uids.add(added);
36428
+ applied.push(override);
36429
+ }
36430
+ const next = applied.length === 0 ? asset : {
36431
+ ...asset,
36432
+ entities: asset.entities.map((entity) => {
36433
+ const data = records.get(entity.uid);
36434
+ return data === void 0 || !touched.has(entity.uid) ? entity : canonicalEntity(data);
36435
+ })
36436
+ };
36437
+ const hash = await computeSceneHash(next);
36438
+ return {
36439
+ asset: next,
36440
+ hash,
36441
+ instance: withOverrides(instance, remaining, hash),
36442
+ applied,
36443
+ skipped
36444
+ };
36445
+ }
36446
+ /**
36447
+ * Drops an instance's overrides so it follows its prefab again — Unity's "Revert".
36448
+ *
36449
+ * @remarks
36450
+ * A pure function: the entry's `scene` and `hash` are kept, and `overrides` is omitted when none
36451
+ * remain. Reverting an `add` also reverts the overrides below the added component when the
36452
+ * selection path covers them (`<entityUid>/components/<addedUid>` does).
36453
+ *
36454
+ * @param instance - The instance entry.
36455
+ * @param selection - Which overrides to drop; all of them by default.
36456
+ * @returns The entry without the selected overrides, or `instance` itself when none was selected.
36457
+ *
36458
+ * @example
36459
+ * ```ts
36460
+ * const reverted = revertOverrides(spawn.instance, { paths: [`${rootUid}/components/${aiUid}`] });
36461
+ * ```
36462
+ *
36463
+ * @public
36464
+ */
36465
+ function revertOverrides(instance, selection) {
36466
+ const overrides = instance.overrides ?? [];
36467
+ const remaining = overrides.filter((override) => !isSelected(override, selection));
36468
+ if (remaining.length === overrides.length) return instance;
36469
+ return withOverrides(instance, remaining, instance.hash);
36470
+ }
36471
+ /**
36472
+ * Whether a selection covers an override.
36473
+ *
36474
+ * @param override - The override.
36475
+ * @param selection - The selection; absent or without `paths`, everything.
36476
+ * @returns `true` when the override's target is a selected path or lies below one.
36477
+ */
36478
+ function isSelected(override, selection) {
36479
+ const paths = selection?.paths;
36480
+ if (paths === void 0) return true;
36481
+ const target = targetPath(override);
36482
+ return paths.some((path) => target === path || target.startsWith(`${path}/`));
36483
+ }
36484
+ /**
36485
+ * The path an override acts on: its own path, or for an `add` to a component list the path of the
36486
+ * component it adds, so a selection can name one added component.
36487
+ *
36488
+ * @param override - The override.
36489
+ * @returns The path.
36490
+ */
36491
+ function targetPath(override) {
36492
+ const added = addedComponentUid(override);
36493
+ return added === null ? override.path : `${override.path}/${added}`;
36494
+ }
36495
+ /**
36496
+ * The uid of the component an `add` override appends to a component list.
36497
+ *
36498
+ * @param override - The override.
36499
+ * @returns The uid, or `null` when the override is not such an `add` or names no uid.
36500
+ */
36501
+ function addedComponentUid(override) {
36502
+ if (overrideOp(override) !== "add") return null;
36503
+ const segments = override.path.split("/");
36504
+ if (segments.length !== 2 || segments[1] !== "components") return null;
36505
+ const uid = asJsonObject(override.value)?.["uid"];
36506
+ return typeof uid === "string" ? uid : null;
36507
+ }
36508
+ /**
36509
+ * Checks what the override patcher itself accepts silently but a prefab file must not take.
36510
+ *
36511
+ * @param override - The override.
36512
+ * @param parsed - Its parsed path.
36513
+ * @param singleRootUid - The prefab's only root, or `null`.
36514
+ * @param uids - Every uid the prefab file already uses.
36515
+ * @returns Why the override cannot be applied, or `null`.
36516
+ */
36517
+ function precheck(override, parsed, singleRootUid, uids) {
36518
+ if (parsed.entity === singleRootUid && (parsed.kind === "entityField" || parsed.kind === "transform")) return `"${override.path}" sets the instance root's own ${parsed.kind === "transform" ? "transform" : parsed.field}, which is its placement, not prefab content.`;
36519
+ if (parsed.kind === "transform") {
36520
+ const numbers = asJsonArray(override.value);
36521
+ const length = parsed.channel === "rotation" ? 4 : 3;
36522
+ if (numbers === null || numbers.length !== length || !numbers.every((entry) => typeof entry === "number" && Number.isFinite(entry))) return `"${override.path}" needs ${String(length)} finite numbers.`;
36523
+ }
36524
+ const added = addedComponentUid(override);
36525
+ if (added !== null && uids.has(added)) return `"${override.path}" adds component ${added}, a uid the prefab file already uses.`;
36526
+ return null;
36527
+ }
36528
+ /**
36529
+ * Why an override must stay on the instance: an earlier override that stays there overlaps it, and
36530
+ * once baked into the prefab the applied one would run first and lose to it.
36531
+ *
36532
+ * @param override - The selected override.
36533
+ * @param remaining - The earlier overrides that stay on the instance.
36534
+ * @returns Why the override cannot be applied, or `null`.
36535
+ */
36536
+ function shadowedBy(override, remaining) {
36537
+ const key = overlapKey(override);
36538
+ const earlier = remaining.find((candidate) => {
36539
+ const other = overlapKey(candidate);
36540
+ return addedComponentUid(candidate) === null && (key === other || key.startsWith(`${other}/`) || other.startsWith(`${key}/`));
36541
+ });
36542
+ return earlier === void 0 ? null : `"${override.path}" follows "${earlier.path}", which stays on the instance and overlaps it.`;
36543
+ }
36544
+ /**
36545
+ * The part of an override's path that decides overlap: cut at the prop field, so array index shifts
36546
+ * inside one field count.
36547
+ *
36548
+ * @param override - The override.
36549
+ * @returns The key.
36550
+ */
36551
+ function overlapKey(override) {
36552
+ return override.path.split("/").slice(0, 5).join("/");
36553
+ }
36554
+ /**
36555
+ * The uid of a scene file's only root.
36556
+ *
36557
+ * @param file - The file.
36558
+ * @returns The uid, or `null` when the file has no root or several.
36559
+ */
36560
+ function singleRootOf(file) {
36561
+ const roots = file.entities.filter((entity) => entity.parent === null);
36562
+ return roots.length === 1 ? roots[0]?.uid ?? null : null;
36563
+ }
36564
+ /**
36565
+ * Copies a file record into the mutable shape the override patcher edits.
36566
+ *
36567
+ * @param entity - The record.
36568
+ * @returns A copy that shares nothing the patcher mutates.
36569
+ */
36570
+ function mutableEntity(entity) {
36571
+ return {
36572
+ uid: entity.uid,
36573
+ name: entity.name,
36574
+ parent: entity.parent,
36575
+ ...entity.active === void 0 ? {} : { active: entity.active },
36576
+ ...entity.static === void 0 ? {} : { static: entity.static },
36577
+ ...entity.layer === void 0 ? {} : { layer: entity.layer },
36578
+ ...entity.tags === void 0 ? {} : { tags: [...entity.tags] },
36579
+ transform: {
36580
+ position: [...entity.transform.position],
36581
+ rotation: [...entity.transform.rotation],
36582
+ scale: [...entity.transform.scale]
36583
+ },
36584
+ ...entity.instance === void 0 ? {} : { instance: entity.instance },
36585
+ components: [...entity.components ?? []]
36586
+ };
36587
+ }
36588
+ /**
36589
+ * Writes a patched record back in the serializer's canonical form: its key order, defaults omitted,
36590
+ * tags sorted and unique, numbers canonicalized.
36591
+ *
36592
+ * @param data - The patched record.
36593
+ * @returns The file record.
36594
+ */
36595
+ function canonicalEntity(data) {
36596
+ const tags = [...new Set(data.tags ?? [])].toSorted();
36597
+ return {
36598
+ uid: data.uid,
36599
+ name: data.name,
36600
+ parent: data.parent,
36601
+ ...data.active === false ? { active: false } : {},
36602
+ ...data.static === true ? { static: true } : {},
36603
+ ...data.layer === void 0 || data.layer === "Default" ? {} : { layer: data.layer },
36604
+ ...tags.length === 0 ? {} : { tags },
36605
+ transform: {
36606
+ position: triple(data.transform.position),
36607
+ rotation: [
36608
+ canonicalNumberAt(data.transform.rotation, 0),
36609
+ canonicalNumberAt(data.transform.rotation, 1),
36610
+ canonicalNumberAt(data.transform.rotation, 2),
36611
+ canonicalNumberAt(data.transform.rotation, 3)
36612
+ ],
36613
+ scale: triple(data.transform.scale)
36614
+ },
36615
+ ...data.instance === void 0 ? {} : { instance: data.instance },
36616
+ ...data.components.length === 0 ? {} : { components: data.components.map(canonicalComponent) }
36617
+ };
36618
+ }
36619
+ /**
36620
+ * Writes a component record in the serializer's key order, `enabled` omitted when `true`.
36621
+ *
36622
+ * @param component - The record.
36623
+ * @returns The canonical record.
36624
+ */
36625
+ function canonicalComponent(component) {
36626
+ return {
36627
+ uid: component.uid,
36628
+ type: component.type,
36629
+ ...component.enabled === false ? { enabled: false } : {},
36630
+ ...component.schemaVersion === void 0 ? {} : { schemaVersion: component.schemaVersion },
36631
+ ...component.props === void 0 ? {} : { props: component.props }
36632
+ };
36633
+ }
36634
+ /**
36635
+ * Reads a three-number transform channel.
36636
+ *
36637
+ * @param values - The channel.
36638
+ * @returns The canonical triple.
36639
+ */
36640
+ function triple(values) {
36641
+ return [
36642
+ canonicalNumberAt(values, 0),
36643
+ canonicalNumberAt(values, 1),
36644
+ canonicalNumberAt(values, 2)
36645
+ ];
36646
+ }
36647
+ /**
36648
+ * Reads one canonical number from a transform channel.
36649
+ *
36650
+ * @param values - The channel.
36651
+ * @param index - Which entry.
36652
+ * @returns The canonical number; `0` when the entry is missing.
36653
+ */
36654
+ function canonicalNumberAt(values, index) {
36655
+ return canonicalizeNumber(values[index] ?? 0);
36656
+ }
36657
+ /**
36658
+ * Rebuilds an instance entry with a new override list and hash.
36659
+ *
36660
+ * @param instance - The entry.
36661
+ * @param overrides - The overrides to keep.
36662
+ * @param hash - The hash to record, or `undefined` for none.
36663
+ * @returns The entry, in the serializer's key order, `overrides` omitted when empty.
36664
+ */
36665
+ function withOverrides(instance, overrides, hash) {
36666
+ return {
36667
+ scene: instance.scene,
36668
+ ...hash === void 0 ? {} : { hash },
36669
+ ...overrides.length === 0 ? {} : { overrides }
36670
+ };
36671
+ }
36672
+ //#endregion
35177
36673
  //#region src/serialization/serialize.ts
35178
36674
  /**
35179
36675
  * Writes a scene instance, or a set of entities, as a scene file object
@@ -36433,6 +37929,6 @@ function settingsJsonSchema(app) {
36433
37929
  };
36434
37930
  }
36435
37931
  //#endregion
36436
- export { ASSET_DIAGNOSTICS_COUNTERS, ASSET_DIAGNOSTICS_GROUP, ASSET_MANIFEST_FORMAT, ASSET_MANIFEST_VERSION, AssetLoadError, CANVAS_ALPHA_MODES, CORE_ERROR_MESSAGES, Camera, Color, Component, ComponentRegistry, CoreErrorCode, DEFAULT_ASSET_CONCURRENCY, DEFAULT_ASSET_ROOT, DEFAULT_BRDF_LUT_ADDRESS, DEFAULT_LAYER, DEFAULT_MEMORY_SINK_LIMIT, DEFAULT_STORAGE_NAMESPACE, DEG_TO_RAD, Diagnostics, EASINGS, EASING_NAMES, EMPTY_ASSET_MANIFEST, ENVIRONMENT_ASSET_TYPE, ENVIRONMENT_FILE_EXTENSION, ENVIRONMENT_FILE_EXTENSIONS, ENVIRONMENT_FILE_FORMAT, ENVIRONMENT_FORMAT_VERSION, EPSILON, Entity, Environment, EnvironmentAsset, ErrorRange, FOG_MODE_NAMES, FONT_ASSET_TYPE, FONT_FILE_EXTENSIONS, FRAME_HISTORY_LENGTH, FieldKind, FontAsset, IGNIFX_UNIFORM_NAMES, INVALID_HANDLE, IgnifxError, IndexedDbStorageBackend, InstancedMeshRenderer, LIGHT_TYPES, LITE_MATERIAL_PLUGIN_POINTS, LITE_SYSTEM_UNIFORM_NAMES, LOG_LEVEL_SEVERITY, LayerMask, LayerTable, Light, LogLevel, MAT4_IDENTITY, MATERIAL_ALPHA_MODES, MATERIAL_ASSET_TYPE, MATERIAL_FILE_EXTENSION, MATERIAL_FILE_FORMAT, MATERIAL_FORMAT_VERSION, MATERIAL_KINDS, MATERIAL_PLUGIN_DEFAULT_PRIORITY, MATERIAL_PLUGIN_RESERVED_NAMES, MATERIAL_PLUGIN_SAMPLER_BUDGET, MAX_LAYERS, MAX_ULID_TIME_MS, MESH_ASSET_TYPE, MESH_FILE_EXTENSION, MESH_FILE_FORMAT, MESH_FORMAT_VERSION, MESH_PRIMITIVES, MESH_PRIMITIVE_OPTIONS, MODEL_ASSET_TYPE, MODEL_FILE_EXTENSIONS, Mat4, MaterialAsset, MemoryStorageBackend, MeshAsset, MeshRenderer, Model, ModelAsset, NAMESPACE_SEGMENT_MAX_LENGTH, PBR_TEXTURE_SLOTS, PHASES, PHASE_COUNT, PHASE_NAMES, POST_EFFECT_BUILTIN_UNIFORMS, POST_EFFECT_FUNCTION, PROJECTIONS, Phase, PhysicsCallbackName, PostProcessStack, QUAT_IDENTITY, Quat, RAD_TO_DEG, RENDERING_SETTINGS_SECTION, RENDER_DIAGNOSTICS_COUNTERS, RENDER_DIAGNOSTICS_GROUP, RESERVED_LAYER_NAMES, SCENE_ASSET_TYPE, SCENE_FILE_EXTENSIONS, SCENE_FILE_FORMAT, SCENE_FORMAT_VERSION, SETTINGS_DESCRIPTION_FORMAT, SHADER_ASSET_TYPE, SHADER_ATTRIBUTE_NAMES, SHADER_BLEND_MODES, SHADER_CULL_MODES, SHADER_FILE_EXTENSIONS, SHADER_INSTANCING_MODES, SHADER_KINDS, SHADER_TEXTURE_FALLBACKS, SHADER_UNIFORM_TYPES, SHADOW_TECHNIQUES, STANDARD_TEXTURE_SLOTS, STORAGE_BUFFER_ASSET_TYPE, STORAGE_KEY_MAX_LENGTH, SURFACE_HOOK_NAMES, SURFACE_UNIFORM_BLOCK, SceneAssetToken, SceneInstance, SchemaIssueCode, Script, ScriptCallbackKind, ShaderAsset, Signal, StorageBufferAsset, TEXTURE_ASSET_TYPE, THIRD_PARTY_ERROR_PREFIX, TONE_MAPPING_NAMES, TWEEN_LOOP_FOREVER, TWEEN_SYSTEM_ORDER, TWEEN_VALUE_KINDS, TagSet, TextureAsset, Transform, Tween, UidRemap, VEC2_ONE, VEC2_ZERO, VEC3_BACKWARD, VEC3_DOWN, VEC3_FORWARD, VEC3_LEFT, VEC3_ONE, VEC3_RIGHT, VEC3_UP, VEC3_ZERO, VERSION, Vec2, Vec3, Vec4, World, addComponentFromRecord, applyInit, approximately, array, assertNever, assertSceneDependenciesLoaded, asset, assetRef, binaryAssetLoader, bool, canonicalizeNumber, clamp, clamp01, color, componentRef, computeSceneHash, coreExtension, createApp, createAssetManifest, createConsoleSink, createCryptoRandom, createDefaults, createDiagnosticsGroup, createEnvironmentLoader, createErrorCodeRegistry, createFileStorageBackend, createFontLoader, createFrameSample, createLayerTable, createLogger, createManualClock, createMaterialAsset, createMaterialLoader, createMemorySink, createMeshLoader, createModelLoader, createPerformanceClock, createRay, createSceneAsset, createSceneLoader, createSeededRandom, createServiceKey, createShaderLoader, createStorageBufferAsset, createTextureLoader, createUlidFactory, curve, custom, customEffect, decodeProps, decodeValue, defaultRenderingSettings, defineExtension, defineMaterialPlugin, defineSchema, degToRad, deltaAngleDegrees, describeEnvironmentFileFormat, describeMaterialFileFormat, describeMeshFileFormat, describeRegisteredSchemas, describeSceneFileFormat, describeSchema, describeSchemas, describeSettings, encodeProps, encodeValue, entityRef, enumOf, environmentDefinition, f32, f64, forceRendererDeviceLossForTesting, formatErrorMessage, generateUlid, i32, instantiateScene, inverseLerp, isAssetRef, isIgnifxError, isLiteMaterialPluginPoint, isSceneFileHeader, isUlid, isValidErrorCode, isWebGpuAvailable, jsonAssetLoader, layerMask, lerp, lerpAngleDegrees, loadSceneDependencies, map, meshFileJsonSchema, moveTowards, optional, parseOverridePath, pbrMaterialDefinition, pingPong, platformInternals, quat, radToDeg, record, repeat, resetFrameSample, resolveEase, sceneFileJsonSchema, serializeComponent, serializeEntity, serializeScene, settingsJsonSchema, shaderMaterialDefinition, sign, smoothStep, standardMaterialDefinition, storageInternals, str, stringifySceneFile, textAssetLoader, toJsonSchema, transformSchema, u32, validateProps, validateSceneFile, validateValue, vec2, vec3, vec4, waitFixedUpdate, waitSeconds, waitSecondsRealtime, waitUntil, waitWhile, wrapAngleDegrees };
37932
+ export { AMBIENT_OCCLUSION_QUALITIES, ASSET_DIAGNOSTICS_COUNTERS, ASSET_DIAGNOSTICS_GROUP, ASSET_MANIFEST_FORMAT, ASSET_MANIFEST_VERSION, AssetLoadError, CANVAS_ALPHA_MODES, CORE_ERROR_MESSAGES, Camera, Color, Component, ComponentRegistry, CoreErrorCode, DEFAULT_ASSET_CONCURRENCY, DEFAULT_ASSET_ROOT, DEFAULT_BRDF_LUT_ADDRESS, DEFAULT_LAYER, DEFAULT_MEMORY_SINK_LIMIT, DEFAULT_STORAGE_NAMESPACE, DEG_TO_RAD, Diagnostics, EASINGS, EASING_NAMES, EDITOR_ONLY_METADATA_KEY, EMPTY_ASSET_MANIFEST, ENVIRONMENT_ASSET_TYPE, ENVIRONMENT_FILE_EXTENSION, ENVIRONMENT_FILE_EXTENSIONS, ENVIRONMENT_FILE_FORMAT, ENVIRONMENT_FORMAT_VERSION, EPSILON, Entity, Environment, EnvironmentAsset, ErrorRange, FOG_MODE_NAMES, FONT_ASSET_TYPE, FONT_FILE_EXTENSIONS, FRAME_HISTORY_LENGTH, FieldKind, FontAsset, IGNIFX_UNIFORM_NAMES, INVALID_HANDLE, IgnifxError, IndexedDbStorageBackend, InstancedMeshRenderer, LIGHT_TYPES, LITE_MATERIAL_PLUGIN_POINTS, LITE_SYSTEM_UNIFORM_NAMES, LOG_LEVEL_SEVERITY, LayerMask, LayerTable, Light, LogLevel, MAT4_IDENTITY, MATERIAL_ALPHA_MODES, MATERIAL_ASSET_TYPE, MATERIAL_FILE_EXTENSION, MATERIAL_FILE_FORMAT, MATERIAL_FORMAT_VERSION, MATERIAL_KINDS, MATERIAL_PLUGIN_DEFAULT_PRIORITY, MATERIAL_PLUGIN_RESERVED_NAMES, MATERIAL_PLUGIN_SAMPLER_BUDGET, MAX_LAYERS, MAX_ULID_TIME_MS, MESH_ASSET_TYPE, MESH_FILE_EXTENSION, MESH_FILE_FORMAT, MESH_FORMAT_VERSION, MESH_PRIMITIVES, MESH_PRIMITIVE_OPTIONS, MODEL_ASSET_TYPE, MODEL_FILE_EXTENSIONS, Mat4, MaterialAsset, MemoryStorageBackend, MeshAsset, MeshRenderer, Model, ModelAsset, NAMESPACE_SEGMENT_MAX_LENGTH, PBR_TEXTURE_SLOTS, PHASES, PHASE_COUNT, PHASE_NAMES, POST_EFFECT_BUILTIN_UNIFORMS, POST_EFFECT_FUNCTION, PROJECTIONS, Phase, PhysicsCallbackName, PostProcessStack, QUAT_IDENTITY, Quat, RAD_TO_DEG, RENDERING_SETTINGS_SECTION, RENDER_DIAGNOSTICS_COUNTERS, RENDER_DIAGNOSTICS_GROUP, RENDER_TEXTURE_MAX_SIZE, RESERVED_LAYER_NAMES, SCENE_ASSET_TYPE, SCENE_FILE_EXTENSIONS, SCENE_FILE_FORMAT, SCENE_FORMAT_VERSION, SETTINGS_DESCRIPTION_FORMAT, SHADER_ASSET_TYPE, SHADER_ATTRIBUTE_NAMES, SHADER_BLEND_MODES, SHADER_CULL_MODES, SHADER_FILE_EXTENSIONS, SHADER_INSTANCING_MODES, SHADER_KINDS, SHADER_TEXTURE_FALLBACKS, SHADER_UNIFORM_TYPES, SHADOW_TECHNIQUES, STANDARD_TEXTURE_SLOTS, STORAGE_BUFFER_ASSET_TYPE, STORAGE_KEY_MAX_LENGTH, SURFACE_HOOK_NAMES, SURFACE_UNIFORM_BLOCK, SceneAssetToken, SceneInstance, SchemaIssueCode, Script, ScriptCallbackKind, ShaderAsset, Signal, StorageBufferAsset, TEXTURE_ASSET_TYPE, THIRD_PARTY_ERROR_PREFIX, TONE_MAPPING_NAMES, TWEEN_LOOP_FOREVER, TWEEN_SYSTEM_ORDER, TWEEN_VALUE_KINDS, TagSet, TextureAsset, Transform, Tween, UidRemap, VEC2_ONE, VEC2_ZERO, VEC3_BACKWARD, VEC3_DOWN, VEC3_FORWARD, VEC3_LEFT, VEC3_ONE, VEC3_RIGHT, VEC3_UP, VEC3_ZERO, VERSION, Vec2, Vec3, Vec4, World, addComponentFromRecord, applyInit, applyOverridesToAsset, approximately, array, assertNever, assertSceneDependenciesLoaded, asset, assetRef, binaryAssetLoader, bool, canonicalizeNumber, clamp, clamp01, color, componentRef, computeSceneHash, coreExtension, createApp, createAssetManifest, createConsoleSink, createCryptoRandom, createDefaults, createDiagnosticsGroup, createEnvironmentLoader, createErrorCodeRegistry, createFileStorageBackend, createFontLoader, createFrameSample, createLayerTable, createLogger, createManualClock, createMaterialAsset, createMaterialLoader, createMemorySink, createMeshLoader, createModelLoader, createPerformanceClock, createRay, createSceneAsset, createSceneLoader, createSeededRandom, createServiceKey, createShaderLoader, createStorageBufferAsset, createTextureLoader, createUlidFactory, curve, custom, customEffect, decodeProps, decodeValue, defaultAutoExposureSettings, defaultRenderingSettings, defineExtension, defineMaterialPlugin, defineSchema, degToRad, deltaAngleDegrees, describeEnvironmentFileFormat, describeMaterialFileFormat, describeMeshFileFormat, describeRegisteredSchemas, describeSceneFileFormat, describeSchema, describeSchemas, describeSettings, encodeProps, encodeValue, entityRef, enumOf, environmentDefinition, f32, f64, forceRendererDeviceLossForTesting, formatErrorMessage, generateUlid, i32, instantiateScene, inverseLerp, isAssetRef, isIgnifxError, isLiteMaterialPluginPoint, isSceneFileHeader, isUlid, isValidErrorCode, isWebGpuAvailable, jsonAssetLoader, layerMask, lerp, lerpAngleDegrees, loadSceneDependencies, map, meshFileJsonSchema, moveTowards, optional, parseOverridePath, pbrMaterialDefinition, pingPong, platformInternals, quat, radToDeg, record, repeat, resetFrameSample, resolveEase, revertOverrides, sceneFileJsonSchema, serializeComponent, serializeEntity, serializeScene, settingsJsonSchema, shaderMaterialDefinition, sign, smoothStep, standardMaterialDefinition, storageInternals, str, stringifySceneFile, textAssetLoader, toJsonSchema, transformSchema, u32, validateProps, validateSceneFile, validateValue, vec2, vec3, vec4, waitFixedUpdate, waitSeconds, waitSecondsRealtime, waitUntil, waitWhile, wrapAngleDegrees };
36437
37933
 
36438
37934
  //# sourceMappingURL=index.js.map