@ignifx/core 0.2.1 → 0.3.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 (37) hide show
  1. package/dist/async-pipelines-CI5uT5iZ.js +26 -0
  2. package/dist/async-pipelines-CI5uT5iZ.js.map +1 -0
  3. package/dist/color-DrR6GFTd.js +351 -0
  4. package/dist/color-DrR6GFTd.js.map +1 -0
  5. package/dist/effect-task-CMbuO6Kb.js +205 -0
  6. package/dist/effect-task-CMbuO6Kb.js.map +1 -0
  7. package/dist/environment-C_JfuAjj.js +224 -0
  8. package/dist/environment-C_JfuAjj.js.map +1 -0
  9. package/dist/ignifx-error-R1ma_Lzv.js +544 -0
  10. package/dist/ignifx-error-R1ma_Lzv.js.map +1 -0
  11. package/dist/index.d.ts +3756 -1656
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +6404 -5777
  14. package/dist/index.js.map +1 -1
  15. package/dist/instanced-mesh-instance-Cgx1H87p.js +701 -0
  16. package/dist/instanced-mesh-instance-Cgx1H87p.js.map +1 -0
  17. package/dist/material-plugin-CTaWZXEk.js +485 -0
  18. package/dist/material-plugin-CTaWZXEk.js.map +1 -0
  19. package/dist/math-utils-BcDnL-gi.js +277 -0
  20. package/dist/math-utils-BcDnL-gi.js.map +1 -0
  21. package/dist/mesh-CnK_PX46.js +811 -0
  22. package/dist/mesh-CnK_PX46.js.map +1 -0
  23. package/dist/post-effect-C42XJFmo.js +155 -0
  24. package/dist/post-effect-C42XJFmo.js.map +1 -0
  25. package/dist/post-effect-compiler-DTlkT1si.js +311 -0
  26. package/dist/post-effect-compiler-DTlkT1si.js.map +1 -0
  27. package/dist/shader-declaration-5q__jycG.js +165 -0
  28. package/dist/shader-declaration-5q__jycG.js.map +1 -0
  29. package/dist/shader-material-DssOqsvZ.js +1009 -0
  30. package/dist/shader-material-DssOqsvZ.js.map +1 -0
  31. package/dist/shader-material-Xk7Oc9UG.js +207 -0
  32. package/dist/shader-material-Xk7Oc9UG.js.map +1 -0
  33. package/dist/shader-pragma-CNAK4SIb.js +685 -0
  34. package/dist/shader-pragma-CNAK4SIb.js.map +1 -0
  35. package/dist/surface-shader-C2HtysNN.js +1397 -0
  36. package/dist/surface-shader-C2HtysNN.js.map +1 -0
  37. package/package.json +1 -1
@@ -0,0 +1,224 @@
1
+ import { n as assertNever } from "./ignifx-error-R1ma_Lzv.js";
2
+ import { s as degToRad } from "./math-utils-BcDnL-gi.js";
3
+ import { AcesToneMapping, NeutralToneMapping, StandardToneMapping, loadEnvironment, setEnvironmentBlur, setEnvironmentRotation, setFog, setSceneImageProcessing } from "@babylonjs/lite";
4
+ //#region src/lite/gpu/environment.ts
5
+ /**
6
+ * ignifx fog mode names mapped to the numbers `FogConfig.mode` uses.
7
+ *
8
+ * @internal
9
+ */
10
+ const FOG_MODES = {
11
+ /** No fog. */
12
+ none: 0,
13
+ /** Exponential fog. */
14
+ exp: 1,
15
+ /** Squared-exponential fog. */
16
+ exp2: 2,
17
+ /** Linear fog between `start` and `end`. */
18
+ linear: 3
19
+ };
20
+ /**
21
+ * The tone-mapping curves `docs/architecture/07-rendering.md` §2.5 exposes.
22
+ *
23
+ * @public
24
+ */
25
+ const TONE_MAPPING_NAMES = [
26
+ "none",
27
+ "standard",
28
+ "aces",
29
+ "neutral"
30
+ ];
31
+ /**
32
+ * Loads an `.env` environment and installs it on a scene.
33
+ *
34
+ * @param scene - The scene to light.
35
+ * @param options - The environment, BRDF, and skybox URLs.
36
+ * @returns The GPU-resident environment textures, for materials that need them explicitly.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * await loadSceneEnvironment(scene, {
41
+ * url: "environments/studio.env",
42
+ * brdfUrl: "environments/brdf-lut.png",
43
+ * });
44
+ * ```
45
+ *
46
+ * @internal
47
+ */
48
+ function loadSceneEnvironment(scene, options) {
49
+ const liteOptions = { brdfUrl: options.brdfUrl };
50
+ if (options.skyboxUrl !== void 0) liteOptions.skyboxUrl = options.skyboxUrl;
51
+ if (options.skyboxSize !== void 0) liteOptions.skyboxSize = options.skyboxSize;
52
+ if (options.skipSkybox !== void 0) liteOptions.skipSkybox = options.skipSkybox;
53
+ if (options.skipGround !== void 0) liteOptions.skipGround = options.skipGround;
54
+ if (options.groundTextureUrl !== void 0) liteOptions.groundTextureUrl = options.groundTextureUrl;
55
+ return loadEnvironment(scene, options.url, liteOptions);
56
+ }
57
+ /**
58
+ * Views a scene through its undeclared environment slot.
59
+ *
60
+ * @param scene - The scene.
61
+ * @returns The same object, typed so the slot is reachable.
62
+ */
63
+ function environmentSlotOf(scene) {
64
+ return scene;
65
+ }
66
+ /**
67
+ * Reports which environment textures a scene is currently lit by.
68
+ *
69
+ * @param scene - The scene to inspect.
70
+ * @returns The installed textures, or `null` when no environment has ever been installed.
71
+ *
72
+ * @internal
73
+ */
74
+ function readSceneEnvironment(scene) {
75
+ return environmentSlotOf(scene)._envTextures ?? null;
76
+ }
77
+ /**
78
+ * Points a scene at an already-loaded set of environment textures, without loading anything.
79
+ *
80
+ * @remarks
81
+ * This is how an `Environment` component swaps environments at runtime: the textures belong to the
82
+ * `EnvironmentAsset` that loaded them and stay alive as long as its handle is retained, so
83
+ * switching between two loaded assets uploads nothing and frees nothing.
84
+ *
85
+ * The specular reflection follows only after the scene's material groups are rebuilt
86
+ * (`rebuildRenderables` in `../shadow.ts`): a PBR bind group holds the cube map's `GPUTextureView`,
87
+ * not the slot. The diffuse harmonics and the LOD scale follow immediately, because the render
88
+ * task's scene-UBO cache is keyed on this object's identity.
89
+ *
90
+ * @param scene - The scene to light.
91
+ * @param textures - The textures to light it with.
92
+ * @returns `true` when the scene was lit by something else and now is not — the caller owes a
93
+ * renderable rebuild; `false` when these textures were already installed and nothing was written.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * if (installSceneEnvironment(scene, asset.lite.textures)) {
98
+ * await rebuildRenderables(scene);
99
+ * }
100
+ * ```
101
+ *
102
+ * @internal
103
+ */
104
+ function installSceneEnvironment(scene, textures) {
105
+ const slot = environmentSlotOf(scene);
106
+ if (slot._envTextures === textures) return false;
107
+ slot._envTextures = textures;
108
+ return true;
109
+ }
110
+ /**
111
+ * Rotates the environment around the world Y axis.
112
+ *
113
+ * @param scene - The scene to rotate the environment of.
114
+ * @param degrees - The rotation, in degrees.
115
+ *
116
+ * @internal
117
+ */
118
+ function setSceneEnvironmentRotation(scene, degrees) {
119
+ setEnvironmentRotation(scene, degToRad(degrees));
120
+ }
121
+ /**
122
+ * Blurs the environment's specular reflection.
123
+ *
124
+ * @param scene - The scene to change.
125
+ * @param blur - The blur amount, 0 to 1.
126
+ *
127
+ * @internal
128
+ */
129
+ function setSceneEnvironmentBlur(scene, blur) {
130
+ setEnvironmentBlur(scene, blur);
131
+ }
132
+ /**
133
+ * Sets the colour the scene is cleared to each frame.
134
+ *
135
+ * @param scene - The scene to change.
136
+ * @param r - The linear red component, 0 to 1.
137
+ * @param g - The linear green component, 0 to 1.
138
+ * @param b - The linear blue component, 0 to 1.
139
+ * @param a - The alpha component; only meaningful with a premultiplied canvas alpha mode.
140
+ *
141
+ * @internal
142
+ */
143
+ function setSceneClearColor(scene, r, g, b, a) {
144
+ const clear = scene.clearColor;
145
+ clear.r = r;
146
+ clear.g = g;
147
+ clear.b = b;
148
+ clear.a = a;
149
+ }
150
+ /**
151
+ * Configures the scene's fog, or turns it off.
152
+ *
153
+ * @param scene - The scene to change.
154
+ * @param mode - The fog falloff, or `"none"` to disable it.
155
+ * @param r - The sRGB red component of the fog colour; Lite's fog block decodes it itself.
156
+ * @param g - The sRGB green component.
157
+ * @param b - The sRGB blue component.
158
+ * @param density - The density, for the exponential modes.
159
+ * @param start - Where linear fog begins, in metres.
160
+ * @param end - Where linear fog reaches full strength, in metres.
161
+ *
162
+ * @internal
163
+ */
164
+ function setSceneFog(scene, mode, r, g, b, density, start, end) {
165
+ if (mode === "none" && scene.fog === null) return;
166
+ setFog(scene, {
167
+ mode: FOG_MODES[mode],
168
+ density,
169
+ start,
170
+ end,
171
+ color: [
172
+ r,
173
+ g,
174
+ b
175
+ ]
176
+ });
177
+ }
178
+ /**
179
+ * Sets exposure, contrast, and the tone-mapping curve.
180
+ *
181
+ * @remarks
182
+ * Asynchronous by nature: tone mapping is compiled into the PBR shaders, so changing it after
183
+ * `registerScene` recompiles the scene's PBR pipelines. Exposure and contrast alone are uniform
184
+ * values, but Lite routes them through the same call.
185
+ *
186
+ * @param scene - The scene to change.
187
+ * @param exposure - The exposure multiplier.
188
+ * @param contrast - The contrast multiplier.
189
+ * @param toneMapping - The curve, or `"none"` to leave the colour untouched.
190
+ * @returns A promise that resolves when any affected pipeline has been rebuilt.
191
+ *
192
+ * @internal
193
+ */
194
+ function setSceneImageProcessingOptions(scene, exposure, contrast, toneMapping) {
195
+ if (toneMapping === "none") return setSceneImageProcessing(scene, {
196
+ exposure,
197
+ contrast,
198
+ toneMappingEnabled: false
199
+ });
200
+ return setSceneImageProcessing(scene, {
201
+ exposure,
202
+ contrast,
203
+ toneMappingEnabled: true,
204
+ toneMapping: toneMappingCurve(toneMapping)
205
+ });
206
+ }
207
+ /**
208
+ * Maps an ignifx tone-mapping name onto the Lite curve object.
209
+ *
210
+ * @param name - The curve name; `"none"` is handled by the caller.
211
+ * @returns The Lite curve.
212
+ */
213
+ function toneMappingCurve(name) {
214
+ switch (name) {
215
+ case "standard": return StandardToneMapping;
216
+ case "aces": return AcesToneMapping;
217
+ case "neutral": return NeutralToneMapping;
218
+ default: return assertNever(name, "tone mapping");
219
+ }
220
+ }
221
+ //#endregion
222
+ export { setSceneClearColor as a, setSceneFog as c, readSceneEnvironment as i, setSceneImageProcessingOptions as l, installSceneEnvironment as n, setSceneEnvironmentBlur as o, loadSceneEnvironment as r, setSceneEnvironmentRotation as s, TONE_MAPPING_NAMES as t };
223
+
224
+ //# sourceMappingURL=environment-C_JfuAjj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment-C_JfuAjj.js","names":[],"sources":["../src/lite/gpu/environment.ts"],"sourcesContent":["import {\n AcesToneMapping,\n loadEnvironment,\n loadSkybox,\n NeutralToneMapping,\n setEnvironmentBlur,\n setEnvironmentRotation,\n setFog,\n setSceneImageProcessing,\n StandardToneMapping,\n} from \"@babylonjs/lite\";\nimport { assertNever } from \"../../errors/ignifx-error.js\";\nimport { degToRad } from \"../../math/math-utils.js\";\nimport type { EnvironmentTextures, SceneContext, ToneMapping } from \"@babylonjs/lite\";\n\n/**\n * Environment half of the Babylon Lite adapter (`docs/architecture/07-rendering.md` §2.5): image\n * based lighting, the skybox, fog, image processing, and the clear colour.\n *\n * Everything here is `@internal`. Loading uploads cube maps, so the module is GPU-only.\n *\n * ## The BRDF LUT is mandatory (verified against `@babylonjs/lite@1.27.0`)\n *\n * `loadEnvironment(scene, url, options)` (`index.d.ts` 6779) takes a **required** `brdfUrl`: Lite\n * decodes the split-sum BRDF lookup table from a pre-baked RGBD PNG rather than computing it, \"for\n * pixel-perfect parity\" with Babylon.js (`lib/_chunks/env-helpers-*.js`, `loadBrdfImage`, which\n * `fetch`es the URL and decodes it with `createImageBitmap`). ignifx ships that PNG as\n * `tests/fixtures/assets/brdf-lut.png`, decoded from Babylon.js's own\n * `_environmentBRDFBase64Texture` (`packages/dev/core/src/Misc/brdfTextureTools.ts`, Apache-2.0).\n * It is 256×256 RGBA8 and 23 KB.\n *\n * ## Fog\n *\n * `SceneContext.fog` is `FogConfig | null` (`index.d.ts` 5350) with a numeric `mode`; Lite exports\n * no named constants for it, so {@link FOG_MODES} maps ignifx's names onto the numbers.\n *\n * **Fog has to be installed with `setFog`, not by assigning the field.** `scene.fog` is what the PBR\n * group builder reads to decide whether a material's program gets the fog block at all\n * (`lib/material/pbr/pbr-renderable.js` 140-159, `PBR_HAS_FOG`), but the block it compiles reads\n * `scene.vFogInfos.x` out of the scene uniform buffer — and the only writer of those slots is\n * `writeFogUbo`, which nothing registers except `setFog`\n * (`lib/scene/scene-ubo-extras.js`: `setFog` is `scene.fog = config` **plus**\n * `_registerSceneUboContributor(scene, writeFogUbo)`, and `_writePassSceneUBO` runs\n * `scene._sceneUboContributors` and nothing else, `lib/frame-graph/render-task.js` 372-379).\n * Lite says as much in `index.d.ts` 10471: \"importing `setFog` is what pulls the fog UBO writer into\n * the bundle\". Assigning `scene.fog` alone therefore compiles the fog block into every PBR pipeline\n * and leaves `vFogInfos` zeroed, so `vFogInfos.x > 0.0` is never true and the scene renders with no\n * fog at all — the cost with none of the effect.\n *\n * A **fresh** config object goes in on every change, because a render task caches its scene UBO on\n * the identity of `scene.fog` (`s[1] === fog`, `lib/frame-graph/render-task.js` 355-371): mutating\n * the installed object in place leaves the cache key equal and the new density or colour never\n * reaches the GPU. Turning fog off writes mode `0`, which is what the already-compiled fog block\n * reads as \"no fog\"; dropping the field back to `null` would only stop the writer and leave the last\n * fog standing. A scene that never had fog keeps its `null` and pays nothing.\n *\n * ## Image processing\n *\n * `setSceneImageProcessing` is **async** (`index.d.ts` 10917) because tone mapping is baked into\n * the PBR shaders at `registerScene` time; changing it recompiles the affected pipelines\n * (`rebuildScenePbrPipelines`). Setting exposure or contrast alone still goes through the same\n * call. Note that `loadEnvironment` **overwrites** all three (`toneMappingEnabled = true`,\n * `exposure = 0.8`, `contrast = 1.2`) as a side effect of installing an environment, which is why\n * the `Environment` component re-applies its own image processing after every install.\n *\n * ## Swapping the installed environment: `scene._envTextures`\n *\n * Lite 1.27.0 declares **no** public way to replace, clear, or read back a registered scene's\n * environment. `index.d.ts` has no `scene.environmentTexture`, no `unloadEnvironment`, and no\n * setter of any kind; `loadEnvironment` is the only installer and it fetches, decodes, and uploads\n * a fresh cube map every call. What it actually installs is one field —\n * `scene._envTextures = textures` (`lib/_chunks/env-helpers-CRI1i-A3.js` 24, and the same line in\n * `lib/loader-hdr/load-hdr.js` 23, `lib/loader-env/load-dds-env.js` 177 and\n * `lib/loader-gltf/gltf-ext-lights-image-based.js` 65) — and every consumer reads that field:\n *\n * - the PBR group builder, which bakes the cube view and sampler into each material's bind group\n * (`lib/material/pbr/pbr-material.js` 12 → `lib/material/pbr/pbr-renderable.js`);\n * - the scene-uniform packer, for `lodGenerationScale` (`lib/frame-graph/scene-uniforms-pack.js` 21);\n * - the env UBO contributor, for the diffuse spherical harmonics (`lib/scene/scene-ubo-extras.js` 24);\n * - the blur contributor, for `lodGenerationOffset` (`lib/scene/set-environment-blur.js` 8);\n * - the render task's scene-UBO cache key, which is keyed on the **object identity** of the field\n * (`lib/frame-graph/render-task.js` 358), so a new object re-uploads the harmonics by itself.\n *\n * Lite's own device-lost recovery replaces the field exactly this way\n * (`lib/loader-env/environment-recovery.js` 16 and 38), so {@link installSceneEnvironment} writes it\n * too. Bind groups are the one consumer that does *not* re-read it: they hold the `GPUTextureView`,\n * so a swap only reaches the specular reflection once the material groups have been rebuilt, which\n * `rebuildSceneRenderables` does (`lib/scene/scene-rebuild.js`, `rebuildEachGroup`). The\n * `Environment` component therefore reports an install as a topology change and lets the render-sync\n * system fire its one coalesced rebuild. This is the only place in ignifx that touches a Lite field\n * `index.d.ts` does not declare, which is what the adapter boundary exists for\n * (`CONSTITUTION.md` §3.4, ADR-0002); it is pinned by\n * `packages/core/test/lite/render/environment.browser.test.ts`, which fails loudly if the field is\n * renamed.\n */\n\n/**\n * The GPU-resident image-based-lighting textures `loadEnvironment` resolves to, re-exported under an\n * ignifx name (`CONSTITUTION.md` §3.4, coding standards §4).\n *\n * @remarks\n * Unstable; excluded from the stability guarantees of `CONSTITUTION.md` Article IV.\n *\n * @public\n */\nexport type LiteEnvironmentTextures = EnvironmentTextures;\n\n/**\n * ignifx fog mode names mapped to the numbers `FogConfig.mode` uses.\n *\n * @internal\n */\nexport const FOG_MODES = {\n /** No fog. */\n none: 0,\n /** Exponential fog. */\n exp: 1,\n /** Squared-exponential fog. */\n exp2: 2,\n /** Linear fog between `start` and `end`. */\n linear: 3,\n} as const;\n\n/**\n * The union of the fog mode names.\n *\n * @internal\n */\nexport type FogMode = keyof typeof FOG_MODES;\n\n/**\n * The tone-mapping curves `docs/architecture/07-rendering.md` §2.5 exposes.\n *\n * @public\n */\nexport const TONE_MAPPING_NAMES = [\"none\", \"standard\", \"aces\", \"neutral\"] as const;\n\n/**\n * The union of the tone-mapping curve names.\n *\n * @internal\n */\nexport type ToneMappingName = (typeof TONE_MAPPING_NAMES)[number];\n\n/**\n * How an ignifx `Environment` component configures image based lighting.\n *\n * @internal\n */\nexport interface EnvironmentLoadOptions {\n /** The `.env` file holding the prefiltered specular cube map and its spherical harmonics. */\n readonly url: string;\n /** The RGBD PNG BRDF lookup table. Required by Lite. */\n readonly brdfUrl: string;\n /** A `.dds` or `.env` skybox. Omit for a flat background. */\n readonly skyboxUrl?: string;\n /** The skybox cube's size, in metres. Lite defaults to 20. */\n readonly skyboxSize?: number;\n /** Skip the skybox entirely. */\n readonly skipSkybox?: boolean;\n /** Skip the reflective ground plane Lite would otherwise add. */\n readonly skipGround?: boolean;\n /** A texture for that ground plane. */\n readonly groundTextureUrl?: string;\n}\n\n/**\n * Loads an `.env` environment and installs it on a scene.\n *\n * @param scene - The scene to light.\n * @param options - The environment, BRDF, and skybox URLs.\n * @returns The GPU-resident environment textures, for materials that need them explicitly.\n *\n * @example\n * ```ts\n * await loadSceneEnvironment(scene, {\n * url: \"environments/studio.env\",\n * brdfUrl: \"environments/brdf-lut.png\",\n * });\n * ```\n *\n * @internal\n */\nexport function loadSceneEnvironment(\n scene: SceneContext,\n options: EnvironmentLoadOptions,\n): Promise<EnvironmentTextures> {\n const liteOptions: {\n brdfUrl: string;\n skyboxUrl?: string;\n skyboxSize?: number;\n skipSkybox?: boolean;\n skipGround?: boolean;\n groundTextureUrl?: string;\n } = { brdfUrl: options.brdfUrl };\n if (options.skyboxUrl !== undefined) {\n liteOptions.skyboxUrl = options.skyboxUrl;\n }\n if (options.skyboxSize !== undefined) {\n liteOptions.skyboxSize = options.skyboxSize;\n }\n if (options.skipSkybox !== undefined) {\n liteOptions.skipSkybox = options.skipSkybox;\n }\n if (options.skipGround !== undefined) {\n liteOptions.skipGround = options.skipGround;\n }\n if (options.groundTextureUrl !== undefined) {\n liteOptions.groundTextureUrl = options.groundTextureUrl;\n }\n return loadEnvironment(scene, options.url, liteOptions);\n}\n\n/**\n * The scene fields Babylon Lite 1.27.0 writes for image-based lighting but does not declare in\n * `index.d.ts`. Adapter-internal Lite mirror (coding standards §5.1); see the module header for the\n * `lib/` lines that prove each one.\n */\ninterface SceneEnvironmentSlot {\n /** What `loadEnvironment` installed, or `undefined` on a scene that has never had one. */\n _envTextures?: EnvironmentTextures | undefined;\n}\n\n/**\n * Views a scene through its undeclared environment slot.\n *\n * @param scene - The scene.\n * @returns The same object, typed so the slot is reachable.\n */\nfunction environmentSlotOf(scene: SceneContext): SceneEnvironmentSlot {\n // Boundary assertion (coding standards §5.2): `SceneContext` is a plain object literal Lite\n // creates in `lib/scene/scene-core.js`, and `_envTextures` is one of its own fields — it is\n // absent from `index.d.ts` because it is not part of Lite's declared surface, not because it is\n // a different object. See the module header for every `lib/` line that reads or writes it.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return scene as SceneContext & SceneEnvironmentSlot;\n}\n\n/**\n * Reports which environment textures a scene is currently lit by.\n *\n * @param scene - The scene to inspect.\n * @returns The installed textures, or `null` when no environment has ever been installed.\n *\n * @internal\n */\nexport function readSceneEnvironment(scene: SceneContext): EnvironmentTextures | null {\n // The underscore is Lite's, not ignifx's: coding standards §5.1 reserves `_field` for exactly\n // this, an adapter-internal mirror of a Lite field, and the module header proves the name.\n // oxlint-disable-next-line no-underscore-dangle\n return environmentSlotOf(scene)._envTextures ?? null;\n}\n\n/**\n * Points a scene at an already-loaded set of environment textures, without loading anything.\n *\n * @remarks\n * This is how an `Environment` component swaps environments at runtime: the textures belong to the\n * `EnvironmentAsset` that loaded them and stay alive as long as its handle is retained, so\n * switching between two loaded assets uploads nothing and frees nothing.\n *\n * The specular reflection follows only after the scene's material groups are rebuilt\n * (`rebuildRenderables` in `../shadow.ts`): a PBR bind group holds the cube map's `GPUTextureView`,\n * not the slot. The diffuse harmonics and the LOD scale follow immediately, because the render\n * task's scene-UBO cache is keyed on this object's identity.\n *\n * @param scene - The scene to light.\n * @param textures - The textures to light it with.\n * @returns `true` when the scene was lit by something else and now is not — the caller owes a\n * renderable rebuild; `false` when these textures were already installed and nothing was written.\n *\n * @example\n * ```ts\n * if (installSceneEnvironment(scene, asset.lite.textures)) {\n * await rebuildRenderables(scene);\n * }\n * ```\n *\n * @internal\n */\nexport function installSceneEnvironment(scene: SceneContext, textures: EnvironmentTextures): boolean {\n const slot = environmentSlotOf(scene);\n // As in `readSceneEnvironment`: an adapter-internal Lite mirror (coding standards §5.1).\n // oxlint-disable-next-line no-underscore-dangle\n if (slot._envTextures === textures) {\n return false;\n }\n // oxlint-disable-next-line no-underscore-dangle\n slot._envTextures = textures;\n return true;\n}\n\n/**\n * Loads a six-face cube-map skybox from a base URL.\n *\n * @param scene - The scene to give a background.\n * @param baseUrl - The URL prefix each face name is appended to.\n * @param extension - The face file extension, such as `\".jpg\"`.\n * @param size - The skybox cube's size, in metres.\n * @returns A promise that resolves when the faces are uploaded.\n *\n * @internal\n */\nexport function loadSceneSkybox(scene: SceneContext, baseUrl: string, extension: string, size?: number): Promise<void> {\n return loadSkybox(scene, baseUrl, extension, size);\n}\n\n/**\n * Rotates the environment around the world Y axis.\n *\n * @param scene - The scene to rotate the environment of.\n * @param degrees - The rotation, in degrees.\n *\n * @internal\n */\nexport function setSceneEnvironmentRotation(scene: SceneContext, degrees: number): void {\n setEnvironmentRotation(scene, degToRad(degrees));\n}\n\n/**\n * Blurs the environment's specular reflection.\n *\n * @param scene - The scene to change.\n * @param blur - The blur amount, 0 to 1.\n *\n * @internal\n */\nexport function setSceneEnvironmentBlur(scene: SceneContext, blur: number): void {\n setEnvironmentBlur(scene, blur);\n}\n\n/**\n * Sets the colour the scene is cleared to each frame.\n *\n * @param scene - The scene to change.\n * @param r - The linear red component, 0 to 1.\n * @param g - The linear green component, 0 to 1.\n * @param b - The linear blue component, 0 to 1.\n * @param a - The alpha component; only meaningful with a premultiplied canvas alpha mode.\n *\n * @internal\n */\nexport function setSceneClearColor(scene: SceneContext, r: number, g: number, b: number, a: number): void {\n const clear = scene.clearColor;\n clear.r = r;\n clear.g = g;\n clear.b = b;\n clear.a = a;\n}\n\n/**\n * Configures the scene's fog, or turns it off.\n *\n * @param scene - The scene to change.\n * @param mode - The fog falloff, or `\"none\"` to disable it.\n * @param r - The sRGB red component of the fog colour; Lite's fog block decodes it itself.\n * @param g - The sRGB green component.\n * @param b - The sRGB blue component.\n * @param density - The density, for the exponential modes.\n * @param start - Where linear fog begins, in metres.\n * @param end - Where linear fog reaches full strength, in metres.\n *\n * @internal\n */\nexport function setSceneFog(\n scene: SceneContext,\n mode: FogMode,\n r: number,\n g: number,\n b: number,\n density: number,\n start: number,\n end: number,\n): void {\n if (mode === \"none\" && scene.fog === null) {\n // A scene that never had fog pays nothing: no contributor, no fog block in any PBR pipeline.\n return;\n }\n setFog(scene, { mode: FOG_MODES[mode], density, start, end, color: [r, g, b] });\n}\n\n/**\n * Sets exposure, contrast, and the tone-mapping curve.\n *\n * @remarks\n * Asynchronous by nature: tone mapping is compiled into the PBR shaders, so changing it after\n * `registerScene` recompiles the scene's PBR pipelines. Exposure and contrast alone are uniform\n * values, but Lite routes them through the same call.\n *\n * @param scene - The scene to change.\n * @param exposure - The exposure multiplier.\n * @param contrast - The contrast multiplier.\n * @param toneMapping - The curve, or `\"none\"` to leave the colour untouched.\n * @returns A promise that resolves when any affected pipeline has been rebuilt.\n *\n * @internal\n */\nexport function setSceneImageProcessingOptions(\n scene: SceneContext,\n exposure: number,\n contrast: number,\n toneMapping: ToneMappingName,\n): Promise<void> {\n if (toneMapping === \"none\") {\n return setSceneImageProcessing(scene, { exposure, contrast, toneMappingEnabled: false });\n }\n return setSceneImageProcessing(scene, {\n exposure,\n contrast,\n toneMappingEnabled: true,\n toneMapping: toneMappingCurve(toneMapping),\n });\n}\n\n/**\n * Maps an ignifx tone-mapping name onto the Lite curve object.\n *\n * @param name - The curve name; `\"none\"` is handled by the caller.\n * @returns The Lite curve.\n */\nfunction toneMappingCurve(name: Exclude<ToneMappingName, \"none\">): ToneMapping {\n switch (name) {\n case \"standard\":\n return StandardToneMapping;\n case \"aces\":\n return AcesToneMapping;\n case \"neutral\":\n return NeutralToneMapping;\n default:\n return assertNever(name, \"tone mapping\");\n }\n}\n"],"mappings":";;;;;;;;;AAgHA,MAAa,YAAY;;CAEvB,MAAM;;CAEN,KAAK;;CAEL,MAAM;;CAEN,QAAQ;AACV;;;;;;AAcA,MAAa,qBAAqB;CAAC;CAAQ;CAAY;CAAQ;AAAS;;;;;;;;;;;;;;;;;;AAgDxE,SAAgB,qBACd,OACA,SAC8B;CAC9B,MAAM,cAOF,EAAE,SAAS,QAAQ,QAAQ;CAC/B,IAAI,QAAQ,cAAc,KAAA,GACxB,YAAY,YAAY,QAAQ;CAElC,IAAI,QAAQ,eAAe,KAAA,GACzB,YAAY,aAAa,QAAQ;CAEnC,IAAI,QAAQ,eAAe,KAAA,GACzB,YAAY,aAAa,QAAQ;CAEnC,IAAI,QAAQ,eAAe,KAAA,GACzB,YAAY,aAAa,QAAQ;CAEnC,IAAI,QAAQ,qBAAqB,KAAA,GAC/B,YAAY,mBAAmB,QAAQ;CAEzC,OAAO,gBAAgB,OAAO,QAAQ,KAAK,WAAW;AACxD;;;;;;;AAkBA,SAAS,kBAAkB,OAA2C;CAMpE,OAAO;AACT;;;;;;;;;AAUA,SAAgB,qBAAqB,OAAiD;CAIpF,OAAO,kBAAkB,KAAK,CAAC,CAAC,gBAAgB;AAClD;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,wBAAwB,OAAqB,UAAwC;CACnG,MAAM,OAAO,kBAAkB,KAAK;CAGpC,IAAI,KAAK,iBAAiB,UACxB,OAAO;CAGT,KAAK,eAAe;CACpB,OAAO;AACT;;;;;;;;;AAyBA,SAAgB,4BAA4B,OAAqB,SAAuB;CACtF,uBAAuB,OAAO,SAAS,OAAO,CAAC;AACjD;;;;;;;;;AAUA,SAAgB,wBAAwB,OAAqB,MAAoB;CAC/E,mBAAmB,OAAO,IAAI;AAChC;;;;;;;;;;;;AAaA,SAAgB,mBAAmB,OAAqB,GAAW,GAAW,GAAW,GAAiB;CACxG,MAAM,QAAQ,MAAM;CACpB,MAAM,IAAI;CACV,MAAM,IAAI;CACV,MAAM,IAAI;CACV,MAAM,IAAI;AACZ;;;;;;;;;;;;;;;AAgBA,SAAgB,YACd,OACA,MACA,GACA,GACA,GACA,SACA,OACA,KACM;CACN,IAAI,SAAS,UAAU,MAAM,QAAQ,MAEnC;CAEF,OAAO,OAAO;EAAE,MAAM,UAAU;EAAO;EAAS;EAAO;EAAK,OAAO;GAAC;GAAG;GAAG;EAAC;CAAE,CAAC;AAChF;;;;;;;;;;;;;;;;;AAkBA,SAAgB,+BACd,OACA,UACA,UACA,aACe;CACf,IAAI,gBAAgB,QAClB,OAAO,wBAAwB,OAAO;EAAE;EAAU;EAAU,oBAAoB;CAAM,CAAC;CAEzF,OAAO,wBAAwB,OAAO;EACpC;EACA;EACA,oBAAoB;EACpB,aAAa,iBAAiB,WAAW;CAC3C,CAAC;AACH;;;;;;;AAQA,SAAS,iBAAiB,MAAqD;CAC7E,QAAQ,MAAR;EACE,KAAK,YACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,SACE,OAAO,YAAY,MAAM,cAAc;CAC3C;AACF"}