@ignifx/core 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/decoders/draco3dgltf.LICENSE.md +201 -0
- package/decoders/draco_decoder.js +116 -0
- package/decoders/draco_decoder_gltf.wasm +0 -0
- package/decoders/vendored.json +22 -0
- package/dist/agx-tone-mapping-Cgt844j6.js +53 -0
- package/dist/agx-tone-mapping-Cgt844j6.js.map +1 -0
- package/dist/auto-exposure-uzPn0beO.js +246 -0
- package/dist/auto-exposure-uzPn0beO.js.map +1 -0
- package/dist/bloom-hdr-CLtQj-oY.js +315 -0
- package/dist/bloom-hdr-CLtQj-oY.js.map +1 -0
- package/dist/contact-shadows-T523EXaP.js +84 -0
- package/dist/contact-shadows-T523EXaP.js.map +1 -0
- package/dist/{decoders-CHJ7vduE.js → decoders-BUQrlS8U.js} +3 -2
- package/dist/decoders-BUQrlS8U.js.map +1 -0
- package/dist/{environment-Cq2BmA96.js → environment-DPi0_0SP.js} +18 -4
- package/dist/environment-DPi0_0SP.js.map +1 -0
- package/dist/gtao-_nr0b6-E.js +630 -0
- package/dist/gtao-_nr0b6-E.js.map +1 -0
- package/dist/hdr-output-BrUvpAsE.js +525 -0
- package/dist/hdr-output-BrUvpAsE.js.map +1 -0
- package/dist/index.d.ts +509 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1522 -512
- package/dist/index.js.map +1 -1
- package/dist/{instanced-mesh-instance-DYwH0vLi.js → instanced-mesh-instance-NnODkvqK.js} +2 -2
- package/dist/{instanced-mesh-instance-DYwH0vLi.js.map → instanced-mesh-instance-NnODkvqK.js.map} +1 -1
- package/dist/mat4-D6exvAuO.js +949 -0
- package/dist/mat4-D6exvAuO.js.map +1 -0
- package/dist/{render-path-Dx0learj.js → render-path-Be7WgN7r.js} +35 -4
- package/dist/render-path-Be7WgN7r.js.map +1 -0
- package/dist/{render-texture-IuR0iFVa.js → render-texture-C_TnaSz2.js} +28 -2
- package/dist/render-texture-C_TnaSz2.js.map +1 -0
- package/dist/scene-color-passes-DlNr-qyZ.js +65 -0
- package/dist/scene-color-passes-DlNr-qyZ.js.map +1 -0
- package/dist/scene-inputs-BxGOsnIZ.js +318 -0
- package/dist/scene-inputs-BxGOsnIZ.js.map +1 -0
- package/dist/{shader-material-CDQ0Y5kN.js → shader-material-B6p66wB8.js} +17 -6
- package/dist/shader-material-B6p66wB8.js.map +1 -0
- package/dist/{shader-material-BPb_oEZQ.js → shader-material-C0TAUr4t.js} +102 -4
- package/dist/shader-material-C0TAUr4t.js.map +1 -0
- package/dist/ssgi-Dm-maZrc.js +113 -0
- package/dist/ssgi-Dm-maZrc.js.map +1 -0
- package/dist/{surface-shader-CwQ03yHG.js → surface-shader-BaK0kvBB.js} +2 -2
- package/dist/{surface-shader-CwQ03yHG.js.map → surface-shader-BaK0kvBB.js.map} +1 -1
- package/dist/taa-BwBZLy11.js +480 -0
- package/dist/taa-BwBZLy11.js.map +1 -0
- package/dist/{vec3-T2PasQZv.js → vec3-D-0Y2mzE.js} +4 -948
- package/dist/vec3-D-0Y2mzE.js.map +1 -0
- package/package.json +4 -2
- package/dist/decoders-CHJ7vduE.js.map +0 -1
- package/dist/environment-Cq2BmA96.js.map +0 -1
- package/dist/hdr-output-DDpIo4Q5.js +0 -300
- package/dist/hdr-output-DDpIo4Q5.js.map +0 -1
- package/dist/render-path-Dx0learj.js.map +0 -1
- package/dist/render-texture-IuR0iFVa.js.map +0 -1
- package/dist/shader-material-BPb_oEZQ.js.map +0 -1
- package/dist/shader-material-CDQ0Y5kN.js.map +0 -1
- package/dist/vec3-T2PasQZv.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
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 {
|
|
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-
|
|
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";
|
|
6
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";
|
|
9
|
-
import { n as installOffscreenRenderPath } from "./render-path-
|
|
10
|
+
import { n as installOffscreenRenderPath } from "./render-path-Be7WgN7r.js";
|
|
10
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";
|
|
11
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";
|
|
12
|
-
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, setShadowTaskCasterMeshes, setSubtreeVisible, setSurfaceSize, startEngine, stopEngine, updateStorageBuffer, updateTexture2DFromPixels } from "@babylonjs/lite";
|
|
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";
|
|
13
14
|
//#region src/signal/signal.ts
|
|
14
15
|
/** One attached handler. `handler === null` marks the entry dead and awaiting compaction. */
|
|
15
16
|
var Connection = class {
|
|
@@ -4816,7 +4817,7 @@ function createServiceKey(name) {
|
|
|
4816
4817
|
*
|
|
4817
4818
|
* @public
|
|
4818
4819
|
*/
|
|
4819
|
-
const VERSION = "0.
|
|
4820
|
+
const VERSION = "0.16.0";
|
|
4820
4821
|
//#endregion
|
|
4821
4822
|
//#region src/assets/delivery-system.ts
|
|
4822
4823
|
/**
|
|
@@ -7173,7 +7174,7 @@ function environmentSchema() {
|
|
|
7173
7174
|
//#endregion
|
|
7174
7175
|
//#region src/render/instanced-mesh-support.ts
|
|
7175
7176
|
/** The dynamically imported adapter, memoised for the process. */
|
|
7176
|
-
let layer = null;
|
|
7177
|
+
let layer$1 = null;
|
|
7177
7178
|
/**
|
|
7178
7179
|
* Loads the thin-instance adapter, once per process.
|
|
7179
7180
|
*
|
|
@@ -7182,8 +7183,8 @@ let layer = null;
|
|
|
7182
7183
|
* @internal
|
|
7183
7184
|
*/
|
|
7184
7185
|
async function loadInstancedMeshSupport() {
|
|
7185
|
-
const loaded = layer ?? await import("./instanced-mesh-instance-
|
|
7186
|
-
layer = loaded;
|
|
7186
|
+
const loaded = layer$1 ?? await import("./instanced-mesh-instance-NnODkvqK.js");
|
|
7187
|
+
layer$1 = loaded;
|
|
7187
7188
|
return loaded;
|
|
7188
7189
|
}
|
|
7189
7190
|
/**
|
|
@@ -7194,7 +7195,7 @@ async function loadInstancedMeshSupport() {
|
|
|
7194
7195
|
* @internal
|
|
7195
7196
|
*/
|
|
7196
7197
|
function instancedMeshSupport() {
|
|
7197
|
-
return layer;
|
|
7198
|
+
return layer$1;
|
|
7198
7199
|
}
|
|
7199
7200
|
//#endregion
|
|
7200
7201
|
//#region src/render/shader-support.ts
|
|
@@ -7210,7 +7211,7 @@ let surfaceLayer = null;
|
|
|
7210
7211
|
* @internal
|
|
7211
7212
|
*/
|
|
7212
7213
|
async function loadShaderSupport() {
|
|
7213
|
-
const loaded = shaderLayer ?? await import("./shader-material-
|
|
7214
|
+
const loaded = shaderLayer ?? await import("./shader-material-B6p66wB8.js").then((n) => n.n);
|
|
7214
7215
|
shaderLayer = loaded;
|
|
7215
7216
|
await loaded.loadShaderMaterialAdapter();
|
|
7216
7217
|
return loaded;
|
|
@@ -7233,7 +7234,7 @@ function shaderSupport() {
|
|
|
7233
7234
|
* @internal
|
|
7234
7235
|
*/
|
|
7235
7236
|
async function loadSurfaceShaderSupport() {
|
|
7236
|
-
const loaded = surfaceLayer ?? await import("./surface-shader-
|
|
7237
|
+
const loaded = surfaceLayer ?? await import("./surface-shader-BaK0kvBB.js");
|
|
7237
7238
|
surfaceLayer = loaded;
|
|
7238
7239
|
return loaded;
|
|
7239
7240
|
}
|
|
@@ -9099,12 +9100,29 @@ function enableGpuTiming(engine) {
|
|
|
9099
9100
|
setGpuTimingEnabled(engine, true);
|
|
9100
9101
|
}
|
|
9101
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
|
+
/**
|
|
9102
9120
|
* Reads the latest per-task GPU timing snapshot.
|
|
9103
9121
|
*
|
|
9104
9122
|
* @remarks
|
|
9105
9123
|
* Check `status` first: `"unsupported"` on a device without timestamp queries, `"disabled"` until
|
|
9106
9124
|
* per-task timing is switched on, `"pending"` until the first readback lands, `"error"` when the
|
|
9107
|
-
* 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 —
|
|
9108
9126
|
* `"shadow"`, `"scene"`, and whatever a post-process task was named.
|
|
9109
9127
|
*
|
|
9110
9128
|
* @param engine - The engine to read.
|
|
@@ -10236,14 +10254,29 @@ function readTargetSizePx(engine, out) {
|
|
|
10236
10254
|
readSurfaceSizePx(engine, out);
|
|
10237
10255
|
}
|
|
10238
10256
|
/**
|
|
10239
|
-
* Turns whole-frame GPU timing on.
|
|
10257
|
+
* Turns whole-frame and per-task GPU timing on.
|
|
10240
10258
|
*
|
|
10241
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"`.
|
|
10242
10262
|
*
|
|
10243
10263
|
* @internal
|
|
10244
10264
|
*/
|
|
10245
|
-
function startGpuTiming(engine) {
|
|
10265
|
+
async function startGpuTiming(engine) {
|
|
10246
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);
|
|
10247
10280
|
}
|
|
10248
10281
|
/**
|
|
10249
10282
|
* Reads the latest per-task GPU timing snapshot, in ignifx's own shape.
|
|
@@ -10281,7 +10314,7 @@ function readTaskTimings(engine) {
|
|
|
10281
10314
|
* @internal
|
|
10282
10315
|
*/
|
|
10283
10316
|
async function loadRenderTextureFactory() {
|
|
10284
|
-
return (await import("./render-texture-
|
|
10317
|
+
return (await import("./render-texture-C_TnaSz2.js")).createLiteRenderTexture;
|
|
10285
10318
|
}
|
|
10286
10319
|
//#endregion
|
|
10287
10320
|
//#region src/render/image-processing-color.ts
|
|
@@ -10403,6 +10436,9 @@ function applyCurve(curve, color) {
|
|
|
10403
10436
|
case "neutral":
|
|
10404
10437
|
neutral(color);
|
|
10405
10438
|
return;
|
|
10439
|
+
case "agx":
|
|
10440
|
+
agx(color);
|
|
10441
|
+
return;
|
|
10406
10442
|
default: assertNever(curve, "tone mapping");
|
|
10407
10443
|
}
|
|
10408
10444
|
}
|
|
@@ -10463,6 +10499,45 @@ function neutral(color) {
|
|
|
10463
10499
|
color.g = color.g * scale + (newPeak - color.g * scale) * blend;
|
|
10464
10500
|
color.b = color.b * scale + (newPeak - color.b * scale) * blend;
|
|
10465
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
|
+
}
|
|
10466
10541
|
/**
|
|
10467
10542
|
* Clamps to `[0, 1]`.
|
|
10468
10543
|
*
|
|
@@ -10481,6 +10556,18 @@ function saturate(value) {
|
|
|
10481
10556
|
*/
|
|
10482
10557
|
const RENDER_TEXTURE_MAX_SIZE = 4096;
|
|
10483
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
|
+
/**
|
|
10484
10571
|
* Checks a render texture's size.
|
|
10485
10572
|
*
|
|
10486
10573
|
* @param width - The requested width.
|
|
@@ -10687,6 +10774,74 @@ function renderTextureUnusableError(member) {
|
|
|
10687
10774
|
*/
|
|
10688
10775
|
const CANVAS_ALPHA_MODES = ["opaque", "premultiplied"];
|
|
10689
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
|
+
/**
|
|
10784
|
+
* The rendering quality tiers, in the order the inspector lists them
|
|
10785
|
+
* (`docs/standards/coding-standards.md` §7 gives each tier's GPU budget).
|
|
10786
|
+
*
|
|
10787
|
+
* @remarks
|
|
10788
|
+
* - `"custom"` (default): every effect is exactly as the section and the `PostProcessStack`s say.
|
|
10789
|
+
* - `"low"`: GTAO at half resolution; no HDR, TAA, contact shadows or SSGI.
|
|
10790
|
+
* - `"medium"`: adds HDR and TAA, and lets a stack run contact shadows.
|
|
10791
|
+
* - `"high"`: GTAO at full resolution, and lets a stack run SSGI.
|
|
10792
|
+
*
|
|
10793
|
+
* @public
|
|
10794
|
+
*/
|
|
10795
|
+
const RENDERING_QUALITIES = [
|
|
10796
|
+
"custom",
|
|
10797
|
+
"low",
|
|
10798
|
+
"medium",
|
|
10799
|
+
"high"
|
|
10800
|
+
];
|
|
10801
|
+
/** The presets of the three named tiers; `"custom"` has none. Bloom and tone mapping stay as authored. */
|
|
10802
|
+
const QUALITY_PRESETS = {
|
|
10803
|
+
low: {
|
|
10804
|
+
hdr: false,
|
|
10805
|
+
taa: false,
|
|
10806
|
+
ambientOcclusion: true,
|
|
10807
|
+
ambientOcclusionQuality: "half",
|
|
10808
|
+
contactShadows: false,
|
|
10809
|
+
ssgi: false
|
|
10810
|
+
},
|
|
10811
|
+
medium: {
|
|
10812
|
+
hdr: true,
|
|
10813
|
+
taa: true,
|
|
10814
|
+
ambientOcclusion: true,
|
|
10815
|
+
ambientOcclusionQuality: "half",
|
|
10816
|
+
contactShadows: true,
|
|
10817
|
+
ssgi: false
|
|
10818
|
+
},
|
|
10819
|
+
high: {
|
|
10820
|
+
hdr: true,
|
|
10821
|
+
taa: true,
|
|
10822
|
+
ambientOcclusion: true,
|
|
10823
|
+
ambientOcclusionQuality: "full",
|
|
10824
|
+
contactShadows: true,
|
|
10825
|
+
ssgi: true
|
|
10826
|
+
}
|
|
10827
|
+
};
|
|
10828
|
+
/**
|
|
10829
|
+
* The preset of a quality tier.
|
|
10830
|
+
*
|
|
10831
|
+
* @param quality - The tier; anything that is not a named tier reads as `"custom"`.
|
|
10832
|
+
* @returns The preset, or `null` for `"custom"`.
|
|
10833
|
+
*
|
|
10834
|
+
* @internal
|
|
10835
|
+
*/
|
|
10836
|
+
function renderingQualityPreset(quality) {
|
|
10837
|
+
switch (quality) {
|
|
10838
|
+
case "low":
|
|
10839
|
+
case "medium":
|
|
10840
|
+
case "high": return QUALITY_PRESETS[quality];
|
|
10841
|
+
default: return null;
|
|
10842
|
+
}
|
|
10843
|
+
}
|
|
10844
|
+
/**
|
|
10690
10845
|
* The name the `rendering` project settings section is registered under.
|
|
10691
10846
|
*
|
|
10692
10847
|
* @public
|
|
@@ -10702,6 +10857,46 @@ const DEFAULT_BRDF_LUT_ADDRESS = "environments/brdf-lut.png";
|
|
|
10702
10857
|
const DEFAULT_MSAA_SAMPLES = 4;
|
|
10703
10858
|
/** The only other sample count WebGPU allows for a multisampled attachment. */
|
|
10704
10859
|
const SINGLE_SAMPLE = 1;
|
|
10860
|
+
/**
|
|
10861
|
+
* The auto exposure a project that names none gets: off, metering EV −6 to 6, adapting at 2 per
|
|
10862
|
+
* second towards brighter scenes and 1 towards darker ones, with no compensation.
|
|
10863
|
+
*
|
|
10864
|
+
* @returns A fresh record.
|
|
10865
|
+
*
|
|
10866
|
+
* @public
|
|
10867
|
+
*/
|
|
10868
|
+
function defaultAutoExposureSettings() {
|
|
10869
|
+
return {
|
|
10870
|
+
enabled: false,
|
|
10871
|
+
minEv: -6,
|
|
10872
|
+
maxEv: 6,
|
|
10873
|
+
speedUp: 2,
|
|
10874
|
+
speedDown: 1,
|
|
10875
|
+
compensation: 0
|
|
10876
|
+
};
|
|
10877
|
+
}
|
|
10878
|
+
/** The ambient-occlusion section a project that names none gets. */
|
|
10879
|
+
const DEFAULT_AMBIENT_OCCLUSION = {
|
|
10880
|
+
enabled: false,
|
|
10881
|
+
quality: "half",
|
|
10882
|
+
radius: .5,
|
|
10883
|
+
intensity: 1,
|
|
10884
|
+
falloff: .6
|
|
10885
|
+
};
|
|
10886
|
+
/**
|
|
10887
|
+
* The TAA record a project that names none gets: off.
|
|
10888
|
+
*
|
|
10889
|
+
* @returns A fresh record.
|
|
10890
|
+
*/
|
|
10891
|
+
function defaultTaaSettings() {
|
|
10892
|
+
return {
|
|
10893
|
+
enabled: false,
|
|
10894
|
+
blend: .1,
|
|
10895
|
+
sharpness: 0,
|
|
10896
|
+
clamp: true,
|
|
10897
|
+
cutDistance: 10
|
|
10898
|
+
};
|
|
10899
|
+
}
|
|
10705
10900
|
/** The clear colour a project that names none gets: opaque black. */
|
|
10706
10901
|
const DEFAULT_CLEAR_COLOR = "#000000";
|
|
10707
10902
|
/**
|
|
@@ -10738,7 +10933,11 @@ function defaultRenderingSettings() {
|
|
|
10738
10933
|
a: 1
|
|
10739
10934
|
},
|
|
10740
10935
|
brdfLut: DEFAULT_BRDF_LUT_ADDRESS,
|
|
10741
|
-
hdr: false
|
|
10936
|
+
hdr: false,
|
|
10937
|
+
autoExposure: defaultAutoExposureSettings(),
|
|
10938
|
+
ambientOcclusion: { ...DEFAULT_AMBIENT_OCCLUSION },
|
|
10939
|
+
taa: defaultTaaSettings(),
|
|
10940
|
+
quality: "custom"
|
|
10742
10941
|
};
|
|
10743
10942
|
}
|
|
10744
10943
|
/**
|
|
@@ -10779,10 +10978,95 @@ function renderingSettingsSchema() {
|
|
|
10779
10978
|
requiredLimits: map(f64(0, { min: 0 }), { tooltip: "Extra WebGPU device limits to request." }),
|
|
10780
10979
|
clearColor: color(DEFAULT_CLEAR_COLOR, { tooltip: "The colour the scene is cleared to, in sRGB. A Camera or Environment overrides it." }),
|
|
10781
10980
|
brdfLut: str(DEFAULT_BRDF_LUT_ADDRESS, { tooltip: "Address of the RGBD BRDF lookup table." }),
|
|
10782
|
-
hdr: bool(false, { tooltip: "Render in HDR (rgba16float) and tone map in one final pass.
|
|
10981
|
+
hdr: bool(false, { tooltip: "Render in HDR (rgba16float) and tone map in one final pass. Custom post effects ordered first see linear colour." }),
|
|
10982
|
+
autoExposure: record({
|
|
10983
|
+
enabled: bool(false, { tooltip: "Meter the HDR scene and adapt the exposure. Needs hdr." }),
|
|
10984
|
+
minEv: f64(-6, { tooltip: "Darkest metered EV (log2 luminance) the exposure follows." }),
|
|
10985
|
+
maxEv: f64(6, { tooltip: "Brightest metered EV (log2 luminance) the exposure follows." }),
|
|
10986
|
+
speedUp: f64(2, {
|
|
10987
|
+
min: 0,
|
|
10988
|
+
tooltip: "Adaptation rate per second when the scene gets brighter."
|
|
10989
|
+
}),
|
|
10990
|
+
speedDown: f64(1, {
|
|
10991
|
+
min: 0,
|
|
10992
|
+
tooltip: "Adaptation rate per second when the scene gets darker."
|
|
10993
|
+
}),
|
|
10994
|
+
compensation: f64(0, { tooltip: "Stops added to the computed exposure; positive is brighter." })
|
|
10995
|
+
}),
|
|
10996
|
+
ambientOcclusion: record({
|
|
10997
|
+
enabled: bool(false, { tooltip: "Screen-space ambient occlusion (GTAO) on environment light." }),
|
|
10998
|
+
quality: enumOf(AMBIENT_OCCLUSION_QUALITIES, DEFAULT_AMBIENT_OCCLUSION.quality, { tooltip: "half: half resolution, 2 slices × 4 steps. full: full resolution, 3 slices × 6 steps." }),
|
|
10999
|
+
radius: f64(DEFAULT_AMBIENT_OCCLUSION.radius, {
|
|
11000
|
+
min: .01,
|
|
11001
|
+
tooltip: "How far an occluder may be from the surface it darkens, in metres."
|
|
11002
|
+
}),
|
|
11003
|
+
intensity: f64(DEFAULT_AMBIENT_OCCLUSION.intensity, {
|
|
11004
|
+
min: 0,
|
|
11005
|
+
max: 8,
|
|
11006
|
+
tooltip: "Exponent on the visibility: 1 is physically based, larger is darker."
|
|
11007
|
+
}),
|
|
11008
|
+
falloff: f64(DEFAULT_AMBIENT_OCCLUSION.falloff, {
|
|
11009
|
+
min: 0,
|
|
11010
|
+
max: 1,
|
|
11011
|
+
tooltip: "Fraction of the radius over which occluders fade out."
|
|
11012
|
+
})
|
|
11013
|
+
}),
|
|
11014
|
+
taa: record({
|
|
11015
|
+
enabled: bool(false, { tooltip: "Temporal anti-aliasing. Needs rendering.hdr." }),
|
|
11016
|
+
blend: f64(.1, {
|
|
11017
|
+
min: .01,
|
|
11018
|
+
max: 1,
|
|
11019
|
+
tooltip: "Weight of the current frame; lower is smoother."
|
|
11020
|
+
}),
|
|
11021
|
+
sharpness: f64(0, {
|
|
11022
|
+
min: 0,
|
|
11023
|
+
max: 1,
|
|
11024
|
+
tooltip: "Output sharpening, 0 to 1."
|
|
11025
|
+
}),
|
|
11026
|
+
clamp: bool(true, { tooltip: "Clip history to the current neighbourhood, against ghosting." }),
|
|
11027
|
+
cutDistance: f64(10, {
|
|
11028
|
+
min: 0,
|
|
11029
|
+
tooltip: "Camera jump per frame, in world units, that resets history."
|
|
11030
|
+
})
|
|
11031
|
+
}, { tooltip: "Temporal anti-aliasing (jittered frames accumulated over time). Needs rendering.hdr." }),
|
|
11032
|
+
quality: enumOf(RENDERING_QUALITIES, "custom", { tooltip: "Quality tier. low: half-res GTAO. medium: adds HDR, TAA, contact shadows. high: full-res GTAO, SSGI. custom: as set. Fields you set win." })
|
|
10783
11033
|
});
|
|
10784
11034
|
}
|
|
10785
11035
|
/**
|
|
11036
|
+
* Reads the declared `ambientOcclusion` record with every field filled in and in range.
|
|
11037
|
+
*
|
|
11038
|
+
* @remarks
|
|
11039
|
+
* The settings store merges a section shallowly, so `ambientOcclusion: { enabled: true }` arrives
|
|
11040
|
+
* without the other fields (see {@link toRenderingFeatures}); each missing or out-of-range value
|
|
11041
|
+
* reads as its default or its nearest bound.
|
|
11042
|
+
*
|
|
11043
|
+
* @param declared - The record as resolved, possibly partial; `undefined` when absent.
|
|
11044
|
+
* @returns A complete record.
|
|
11045
|
+
*
|
|
11046
|
+
* @internal
|
|
11047
|
+
*/
|
|
11048
|
+
function resolveAmbientOcclusion(declared) {
|
|
11049
|
+
const value = declared ?? {};
|
|
11050
|
+
const defaults = DEFAULT_AMBIENT_OCCLUSION;
|
|
11051
|
+
return {
|
|
11052
|
+
enabled: value.enabled === true,
|
|
11053
|
+
quality: value.quality === "full" ? "full" : "half",
|
|
11054
|
+
radius: Math.max(.01, finite(value.radius, defaults.radius)),
|
|
11055
|
+
intensity: Math.min(8, Math.max(0, finite(value.intensity, defaults.intensity))),
|
|
11056
|
+
falloff: Math.min(1, Math.max(0, finite(value.falloff, defaults.falloff)))
|
|
11057
|
+
};
|
|
11058
|
+
}
|
|
11059
|
+
/**
|
|
11060
|
+
* A finite number, or a fallback.
|
|
11061
|
+
*
|
|
11062
|
+
* @param input - The declared value.
|
|
11063
|
+
* @param fallback - What a missing or non-finite value reads as.
|
|
11064
|
+
* @returns The number.
|
|
11065
|
+
*/
|
|
11066
|
+
function finite(input, fallback) {
|
|
11067
|
+
return typeof input === "number" && Number.isFinite(input) ? input : fallback;
|
|
11068
|
+
}
|
|
11069
|
+
/**
|
|
10786
11070
|
* Reads the declared feature block as the adapter's own flag record.
|
|
10787
11071
|
*
|
|
10788
11072
|
* @remarks
|
|
@@ -10805,9 +11089,44 @@ function toRenderingFeatures(settings) {
|
|
|
10805
11089
|
const name = RENDERING_FEATURE_NAMES[index];
|
|
10806
11090
|
if (name !== void 0) features[name] = declared[name] === true;
|
|
10807
11091
|
}
|
|
11092
|
+
if (resolveAmbientOcclusion(settings.ambientOcclusion).enabled) features["materialPlugins"] = true;
|
|
10808
11093
|
return features;
|
|
10809
11094
|
}
|
|
10810
11095
|
/**
|
|
11096
|
+
* Reads the declared `taa` record with every field filled in.
|
|
11097
|
+
*
|
|
11098
|
+
* @remarks
|
|
11099
|
+
* The settings store merges a section shallowly (see {@link toRenderingFeatures}), so
|
|
11100
|
+
* `taa: { enabled: true }` arrives without the other fields; each missing or mistyped one reads as
|
|
11101
|
+
* its default.
|
|
11102
|
+
*
|
|
11103
|
+
* @param settings - The resolved section.
|
|
11104
|
+
* @returns A complete record.
|
|
11105
|
+
*
|
|
11106
|
+
* @internal
|
|
11107
|
+
*/
|
|
11108
|
+
function resolveTaaSettings(settings) {
|
|
11109
|
+
const declared = settings.taa ?? {};
|
|
11110
|
+
const defaults = defaultTaaSettings();
|
|
11111
|
+
return {
|
|
11112
|
+
enabled: declared.enabled === true,
|
|
11113
|
+
blend: finiteOr(declared.blend, defaults.blend),
|
|
11114
|
+
sharpness: finiteOr(declared.sharpness, defaults.sharpness),
|
|
11115
|
+
clamp: declared.clamp !== false,
|
|
11116
|
+
cutDistance: finiteOr(declared.cutDistance, defaults.cutDistance)
|
|
11117
|
+
};
|
|
11118
|
+
}
|
|
11119
|
+
/**
|
|
11120
|
+
* A declared number, or the fallback when it is missing or not finite.
|
|
11121
|
+
*
|
|
11122
|
+
* @param value - The declared value.
|
|
11123
|
+
* @param fallback - The default.
|
|
11124
|
+
* @returns The number to use.
|
|
11125
|
+
*/
|
|
11126
|
+
function finiteOr(value, fallback) {
|
|
11127
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
11128
|
+
}
|
|
11129
|
+
/**
|
|
10811
11130
|
* Translates the section into the options the adapter hands `createEngine`.
|
|
10812
11131
|
*
|
|
10813
11132
|
* @remarks
|
|
@@ -10853,6 +11172,77 @@ function toRendererOptions(settings, resolutionScale) {
|
|
|
10853
11172
|
function toSurfaceFormat(settings) {
|
|
10854
11173
|
return settings.format === "" ? null : settings.format;
|
|
10855
11174
|
}
|
|
11175
|
+
/**
|
|
11176
|
+
* The auto exposure knobs the HDR path is built with, or `null` when it stays off.
|
|
11177
|
+
*
|
|
11178
|
+
* @remarks
|
|
11179
|
+
* The settings store merges a section shallowly (see {@link toRenderingFeatures}), so a project that
|
|
11180
|
+
* writes `autoExposure: { enabled: true }` leaves the other fields `undefined`; each one falls back to
|
|
11181
|
+
* its default here.
|
|
11182
|
+
*
|
|
11183
|
+
* @param settings - The resolved section.
|
|
11184
|
+
* @returns The knobs, or `null` when `hdr` or `autoExposure.enabled` is off.
|
|
11185
|
+
*
|
|
11186
|
+
* @internal
|
|
11187
|
+
*/
|
|
11188
|
+
function toAutoExposureOptions(settings) {
|
|
11189
|
+
const declared = settings.autoExposure;
|
|
11190
|
+
if (!settings.hdr || declared.enabled !== true) return null;
|
|
11191
|
+
const defaults = defaultAutoExposureSettings();
|
|
11192
|
+
return {
|
|
11193
|
+
minEv: declared.minEv ?? defaults.minEv,
|
|
11194
|
+
maxEv: declared.maxEv ?? defaults.maxEv,
|
|
11195
|
+
speedUp: declared.speedUp ?? defaults.speedUp,
|
|
11196
|
+
speedDown: declared.speedDown ?? defaults.speedDown,
|
|
11197
|
+
compensation: declared.compensation ?? defaults.compensation
|
|
11198
|
+
};
|
|
11199
|
+
}
|
|
11200
|
+
/**
|
|
11201
|
+
* The section with its quality tier applied: what the renderer runs with.
|
|
11202
|
+
*
|
|
11203
|
+
* @remarks
|
|
11204
|
+
* `"custom"` returns the section unchanged. A named tier fills `hdr`, `taa.enabled`,
|
|
11205
|
+
* `ambientOcclusion.enabled` and `ambientOcclusion.quality` from its preset, except where the project
|
|
11206
|
+
* wrote the field itself. The resolved section cannot say which fields those are (the store fills
|
|
11207
|
+
* in defaults), so the caller passes what the project declared.
|
|
11208
|
+
*
|
|
11209
|
+
* @param settings - The resolved section.
|
|
11210
|
+
* @param declared - The project's own `rendering` value, before defaults; `undefined` when absent.
|
|
11211
|
+
* @returns The effective section; the input when the tier is `"custom"`.
|
|
11212
|
+
*
|
|
11213
|
+
* @internal
|
|
11214
|
+
*/
|
|
11215
|
+
function applyRenderingQuality(settings, declared) {
|
|
11216
|
+
const preset = renderingQualityPreset(settings.quality);
|
|
11217
|
+
if (preset === null) return settings;
|
|
11218
|
+
const section = fieldsOf(declared);
|
|
11219
|
+
const taa = fieldsOf(section["taa"]);
|
|
11220
|
+
const occlusion = fieldsOf(section["ambientOcclusion"]);
|
|
11221
|
+
const resolvedOcclusion = resolveAmbientOcclusion(settings.ambientOcclusion);
|
|
11222
|
+
return {
|
|
11223
|
+
...settings,
|
|
11224
|
+
hdr: typeof section["hdr"] === "boolean" ? settings.hdr : preset.hdr,
|
|
11225
|
+
taa: {
|
|
11226
|
+
...resolveTaaSettings(settings),
|
|
11227
|
+
enabled: typeof taa["enabled"] === "boolean" ? taa["enabled"] : preset.taa
|
|
11228
|
+
},
|
|
11229
|
+
ambientOcclusion: {
|
|
11230
|
+
...resolvedOcclusion,
|
|
11231
|
+
enabled: typeof occlusion["enabled"] === "boolean" ? occlusion["enabled"] : preset.ambientOcclusion,
|
|
11232
|
+
quality: typeof occlusion["quality"] === "string" ? resolvedOcclusion.quality : preset.ambientOcclusionQuality
|
|
11233
|
+
}
|
|
11234
|
+
};
|
|
11235
|
+
}
|
|
11236
|
+
/**
|
|
11237
|
+
* The own fields of a declared record.
|
|
11238
|
+
*
|
|
11239
|
+
* @param value - What the project wrote.
|
|
11240
|
+
* @returns Its fields, or an empty record when it is not an object.
|
|
11241
|
+
*/
|
|
11242
|
+
function fieldsOf(value) {
|
|
11243
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return {};
|
|
11244
|
+
return Object.fromEntries(Object.entries(value));
|
|
11245
|
+
}
|
|
10856
11246
|
//#endregion
|
|
10857
11247
|
//#region src/render/renderer.ts
|
|
10858
11248
|
/**
|
|
@@ -10919,8 +11309,10 @@ const MAX_RESOLUTION_SCALE = 1;
|
|
|
10919
11309
|
* @internal
|
|
10920
11310
|
*/
|
|
10921
11311
|
var RendererImpl = class {
|
|
10922
|
-
/** The resolved `rendering` settings section. */
|
|
11312
|
+
/** The resolved `rendering` settings section, with its `quality` tier applied. */
|
|
10923
11313
|
settings;
|
|
11314
|
+
/** The `rendering.quality` tier's preset, which caps a stack's effects; `null` for `"custom"`. */
|
|
11315
|
+
qualityPreset;
|
|
10924
11316
|
/** `true` once a topology change needs one `rebuildSceneRenderables` this frame. */
|
|
10925
11317
|
needsRenderableRebuild = false;
|
|
10926
11318
|
/** `true` once a `castShadows` or caster-set change needs the caster lists rebuilt this frame. */
|
|
@@ -10971,7 +11363,7 @@ var RendererImpl = class {
|
|
|
10971
11363
|
this.#assertRenderLoop(member);
|
|
10972
11364
|
const create = await loadRenderTextureFactory();
|
|
10973
11365
|
this.#assertRenderLoop(member);
|
|
10974
|
-
return create(this.engine, this.scene, width, height);
|
|
11366
|
+
return create(this.engine, this.scene, width, height, EDITOR_ONLY_METADATA_KEY);
|
|
10975
11367
|
},
|
|
10976
11368
|
release: (texture) => {
|
|
10977
11369
|
this.#renderTextures.delete(texture);
|
|
@@ -10983,6 +11375,14 @@ var RendererImpl = class {
|
|
|
10983
11375
|
#gpuAdapters = [];
|
|
10984
11376
|
#handles = null;
|
|
10985
11377
|
#presenter = null;
|
|
11378
|
+
/** The shared scene inputs' owner (`../lite/gpu/scene-inputs.ts`), loaded by the first acquire. */
|
|
11379
|
+
#sceneInputs = null;
|
|
11380
|
+
/** The same owner once loaded, so `dispose()` can free it synchronously. */
|
|
11381
|
+
#sceneInputsHost = null;
|
|
11382
|
+
/** The GTAO pass (`../lite/gpu/gtao.ts`), when `rendering.ambientOcclusion` is on. */
|
|
11383
|
+
#ambientOcclusion = null;
|
|
11384
|
+
/** The TAA passes (`../lite/gpu/taa.ts`), when `rendering.taa` installed them. */
|
|
11385
|
+
#taa = null;
|
|
10986
11386
|
#defaultMaterial = null;
|
|
10987
11387
|
#resolutionScale = 1;
|
|
10988
11388
|
#pixelRatio;
|
|
@@ -11032,6 +11432,7 @@ var RendererImpl = class {
|
|
|
11032
11432
|
constructor(app, settings) {
|
|
11033
11433
|
this.#app = app;
|
|
11034
11434
|
this.settings = settings;
|
|
11435
|
+
this.qualityPreset = renderingQualityPreset(settings.quality);
|
|
11035
11436
|
this.#features = toRenderingFeatures(settings);
|
|
11036
11437
|
this.#pixelRatio = settings.maxDevicePixelRatio;
|
|
11037
11438
|
const counters = app.diagnostics.registerGroup(RENDER_DIAGNOSTICS_GROUP, RENDER_DIAGNOSTICS_COUNTERS);
|
|
@@ -11109,6 +11510,77 @@ var RendererImpl = class {
|
|
|
11109
11510
|
return this.#presenter;
|
|
11110
11511
|
}
|
|
11111
11512
|
/**
|
|
11513
|
+
* Leases the shared scene inputs — depth, normals, velocity and a depth pyramid from one geometry
|
|
11514
|
+
* pass (`docs/architecture/07-rendering.md` §2.12) — for a screen-space effect.
|
|
11515
|
+
*
|
|
11516
|
+
* @remarks
|
|
11517
|
+
* The first call loads the `scene-inputs` chunk and adds the pass to the frame graph; the last
|
|
11518
|
+
* `release()` removes it. Nothing is loaded or added until an effect calls this.
|
|
11519
|
+
*
|
|
11520
|
+
* @returns The lease, or `null` under the null engine or once the renderer is disposed.
|
|
11521
|
+
*
|
|
11522
|
+
* @internal
|
|
11523
|
+
*/
|
|
11524
|
+
async acquireSceneInputs() {
|
|
11525
|
+
if (this.isHeadless || this.#isDisposed) return null;
|
|
11526
|
+
const { engine, scene } = this;
|
|
11527
|
+
this.#sceneInputs ??= import("./scene-inputs-BxGOsnIZ.js").then((module) => {
|
|
11528
|
+
const host = module.createSceneInputsHost(engine, scene);
|
|
11529
|
+
this.#sceneInputsHost = host;
|
|
11530
|
+
if (this.#isDisposed) host.dispose();
|
|
11531
|
+
return host;
|
|
11532
|
+
});
|
|
11533
|
+
return (await this.#sceneInputs).acquire(this.#isSceneRegistered);
|
|
11534
|
+
}
|
|
11535
|
+
/**
|
|
11536
|
+
* Installs temporal anti-aliasing when `rendering.taa.enabled` is on (GI plan steps G5–G6).
|
|
11537
|
+
*
|
|
11538
|
+
* @remarks
|
|
11539
|
+
* Loads the `taa` chunk and leases the scene inputs only then. TAA needs the HDR render path;
|
|
11540
|
+
* without `rendering.hdr` it logs a warning and stays off. `app.initialize()` calls it once, after
|
|
11541
|
+
* the engine exists and before the scene is registered.
|
|
11542
|
+
*
|
|
11543
|
+
* @returns A promise that settles once the passes are in the frame graph, or at once when off.
|
|
11544
|
+
*
|
|
11545
|
+
* @internal
|
|
11546
|
+
*/
|
|
11547
|
+
async installTemporalAntiAliasing() {
|
|
11548
|
+
const options = resolveTaaSettings(this.settings);
|
|
11549
|
+
if (!options.enabled || this.isHeadless || this.#taa !== null) return;
|
|
11550
|
+
const hdr = this.#presenter?.hdr ?? null;
|
|
11551
|
+
if (hdr === null) {
|
|
11552
|
+
this.#app.log.warn("rendering.taa needs rendering.hdr; temporal anti-aliasing stays off.");
|
|
11553
|
+
return;
|
|
11554
|
+
}
|
|
11555
|
+
const module = await import("./taa-BwBZLy11.js");
|
|
11556
|
+
const inputs = await this.acquireSceneInputs();
|
|
11557
|
+
if (inputs === null) return;
|
|
11558
|
+
this.#taa = module.installTemporalAntiAliasing(this.engine, this.scene, hdr, inputs, options, this.#isSceneRegistered);
|
|
11559
|
+
}
|
|
11560
|
+
/**
|
|
11561
|
+
* The TAA passes, when installed.
|
|
11562
|
+
*
|
|
11563
|
+
* @returns The handle, or `null`.
|
|
11564
|
+
*
|
|
11565
|
+
* @internal
|
|
11566
|
+
*/
|
|
11567
|
+
get taa() {
|
|
11568
|
+
return this.#taa;
|
|
11569
|
+
}
|
|
11570
|
+
resetTemporalHistory() {
|
|
11571
|
+
this.#taa?.reset();
|
|
11572
|
+
}
|
|
11573
|
+
/**
|
|
11574
|
+
* How many scene-input leases are live; `0` before the first acquire.
|
|
11575
|
+
*
|
|
11576
|
+
* @returns The count.
|
|
11577
|
+
*
|
|
11578
|
+
* @internal
|
|
11579
|
+
*/
|
|
11580
|
+
get sceneInputsUserCount() {
|
|
11581
|
+
return this.#sceneInputsHost?.userCount ?? 0;
|
|
11582
|
+
}
|
|
11583
|
+
/**
|
|
11112
11584
|
* Whether `app.start()` has registered the render scene, after which Lite has compiled what it is
|
|
11113
11585
|
* going to compile.
|
|
11114
11586
|
*
|
|
@@ -11168,8 +11640,14 @@ var RendererImpl = class {
|
|
|
11168
11640
|
set profileTasks(value) {
|
|
11169
11641
|
this.#profileTasks = value;
|
|
11170
11642
|
if (this.isHeadless) return;
|
|
11171
|
-
|
|
11172
|
-
|
|
11643
|
+
const reportFailure = (error) => {
|
|
11644
|
+
this.#app.log.warn(`renderer.profileTasks could not switch per-task GPU timing: ${String(error)}`);
|
|
11645
|
+
};
|
|
11646
|
+
if (value) startGpuTiming(this.engine).catch(reportFailure);
|
|
11647
|
+
else {
|
|
11648
|
+
disableGpuTiming(this.engine);
|
|
11649
|
+
stopTaskTiming(this.engine).catch(reportFailure);
|
|
11650
|
+
}
|
|
11173
11651
|
}
|
|
11174
11652
|
/**
|
|
11175
11653
|
* Whether the shader clock runs in an edit-mode app.
|
|
@@ -11629,6 +12107,60 @@ var RendererImpl = class {
|
|
|
11629
12107
|
};
|
|
11630
12108
|
this.#presenter = presenter;
|
|
11631
12109
|
this.applyClearColor(this.settings.clearColor);
|
|
12110
|
+
if (!this.isHeadless && resolveAmbientOcclusion(this.settings.ambientOcclusion).enabled) this.requireGpuAdapter(this.#installAmbientOcclusion());
|
|
12111
|
+
}
|
|
12112
|
+
/**
|
|
12113
|
+
* Loads the GTAO chunk and builds the pass on a scene-inputs lease (`rendering.ambientOcclusion`).
|
|
12114
|
+
*
|
|
12115
|
+
* @returns A promise that settles once the pass is in the frame graph.
|
|
12116
|
+
*/
|
|
12117
|
+
async #installAmbientOcclusion() {
|
|
12118
|
+
const settings = resolveAmbientOcclusion(this.settings.ambientOcclusion);
|
|
12119
|
+
const [module, inputs] = await Promise.all([import("./gtao-_nr0b6-E.js"), this.acquireSceneInputs()]);
|
|
12120
|
+
if (inputs === null) return;
|
|
12121
|
+
if (this.#isDisposed) {
|
|
12122
|
+
inputs.release();
|
|
12123
|
+
return;
|
|
12124
|
+
}
|
|
12125
|
+
const pass = await module.createAmbientOcclusion(this.engine, this.scene, inputs, {
|
|
12126
|
+
quality: settings.quality,
|
|
12127
|
+
radius: settings.radius,
|
|
12128
|
+
intensity: settings.intensity,
|
|
12129
|
+
falloff: settings.falloff,
|
|
12130
|
+
onError: (error) => {
|
|
12131
|
+
this.#app.onError.emit({
|
|
12132
|
+
error,
|
|
12133
|
+
source: "asset",
|
|
12134
|
+
phase: null,
|
|
12135
|
+
entity: null,
|
|
12136
|
+
component: null
|
|
12137
|
+
});
|
|
12138
|
+
}
|
|
12139
|
+
}, this.#isSceneRegistered);
|
|
12140
|
+
if (this.#isDisposed) {
|
|
12141
|
+
pass.dispose();
|
|
12142
|
+
return;
|
|
12143
|
+
}
|
|
12144
|
+
this.#ambientOcclusion = pass;
|
|
12145
|
+
}
|
|
12146
|
+
/**
|
|
12147
|
+
* The GTAO pass's per-frame work: gives new PBR materials the AO plugin. The `PreRender` system
|
|
12148
|
+
* calls it every frame; it does nothing while `rendering.ambientOcclusion` is off.
|
|
12149
|
+
*
|
|
12150
|
+
* @internal
|
|
12151
|
+
*/
|
|
12152
|
+
updateAmbientOcclusion() {
|
|
12153
|
+
this.#ambientOcclusion?.update(this.#isSceneRegistered);
|
|
12154
|
+
}
|
|
12155
|
+
/**
|
|
12156
|
+
* Whether the GTAO pass is built and running.
|
|
12157
|
+
*
|
|
12158
|
+
* @returns `true` once `rendering.ambientOcclusion` has installed it.
|
|
12159
|
+
*
|
|
12160
|
+
* @internal
|
|
12161
|
+
*/
|
|
12162
|
+
get isAmbientOcclusionActive() {
|
|
12163
|
+
return this.#ambientOcclusion !== null;
|
|
11632
12164
|
}
|
|
11633
12165
|
/**
|
|
11634
12166
|
* Writes an sRGB colour onto the render scene's clear colour, so it presents as authored.
|
|
@@ -11840,14 +12372,19 @@ var RendererImpl = class {
|
|
|
11840
12372
|
return this.#isDisposed ? [] : held;
|
|
11841
12373
|
}
|
|
11842
12374
|
/**
|
|
11843
|
-
* Releases the open overlays, the picker
|
|
11844
|
-
* as a disposer.
|
|
12375
|
+
* Releases the open overlays, the picker, the warm-up probes and the scene inputs. The core
|
|
12376
|
+
* extension registers it as a disposer.
|
|
11845
12377
|
*
|
|
11846
12378
|
* @internal
|
|
11847
12379
|
*/
|
|
11848
12380
|
dispose() {
|
|
11849
12381
|
this.#isDisposed = true;
|
|
11850
12382
|
this.#afterRebuild.length = 0;
|
|
12383
|
+
this.#ambientOcclusion?.dispose();
|
|
12384
|
+
this.#ambientOcclusion = null;
|
|
12385
|
+
this.#sceneInputsHost?.dispose();
|
|
12386
|
+
this.#sceneInputsHost = null;
|
|
12387
|
+
this.#taa = null;
|
|
11851
12388
|
for (const overlay of this.#overlays.values()) overlay.dispose();
|
|
11852
12389
|
for (const texture of this.#renderTextures) texture.dispose();
|
|
11853
12390
|
const picker = this.#picker;
|
|
@@ -13101,6 +13638,8 @@ var Light = class Light extends Component {
|
|
|
13101
13638
|
#appliedSpotAngle = NaN;
|
|
13102
13639
|
#appliedSpotExponent = NaN;
|
|
13103
13640
|
#appliedShadows = false;
|
|
13641
|
+
/** A copy of the `shadows` record the current generator was built from, or `null` without one. */
|
|
13642
|
+
#appliedShadowSettings = null;
|
|
13104
13643
|
#appliedIncludeSize = -1;
|
|
13105
13644
|
#appliedExcludeSize = -1;
|
|
13106
13645
|
#entityVersion = -1;
|
|
@@ -13273,24 +13812,28 @@ var Light = class Light extends Component {
|
|
|
13273
13812
|
}
|
|
13274
13813
|
}
|
|
13275
13814
|
/**
|
|
13276
|
-
* Attaches or detaches the shadow generator the `shadows` record asks for.
|
|
13815
|
+
* Attaches, rebuilds or detaches the shadow generator the `shadows` record asks for.
|
|
13816
|
+
*
|
|
13817
|
+
* @remarks
|
|
13818
|
+
* Lite reads every field (technique, map size, the cascade knobs) only when it builds a
|
|
13819
|
+
* generator, so a change to any of them on a light that already casts builds a new one.
|
|
13277
13820
|
*
|
|
13278
13821
|
* @param renderer - The rendering service, for the engine and the feature flags.
|
|
13279
|
-
* @returns `true` when a generator was attached or detached.
|
|
13822
|
+
* @returns `true` when a generator was attached, rebuilt or detached.
|
|
13280
13823
|
*/
|
|
13281
13824
|
#applyShadows(renderer) {
|
|
13282
13825
|
const light = this.#light;
|
|
13283
13826
|
const wanted = this.shadows.enabled && this.isEnabledInHierarchy && renderer.features.shadows && !renderer.isHeadless;
|
|
13284
|
-
|
|
13827
|
+
const isStale = wanted && !sameShadowSettings(this.#appliedShadowSettings, this.shadows);
|
|
13828
|
+
if (light === null || wanted === this.#appliedShadows && !isStale) {
|
|
13285
13829
|
this.#warnAboutShadows(renderer);
|
|
13286
13830
|
return false;
|
|
13287
13831
|
}
|
|
13288
13832
|
if (renderer.isRebuildInFlight) return false;
|
|
13289
13833
|
this.#appliedShadows = wanted;
|
|
13290
|
-
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
}
|
|
13834
|
+
this.#releaseGenerator(renderer);
|
|
13835
|
+
if (!wanted) return true;
|
|
13836
|
+
this.#appliedShadowSettings = { ...this.shadows };
|
|
13294
13837
|
this.#generator = attachShadows(renderer.engine, light, this.shadows);
|
|
13295
13838
|
renderer.needsShadowLayoutReset = true;
|
|
13296
13839
|
return true;
|
|
@@ -13333,6 +13876,7 @@ var Light = class Light extends Component {
|
|
|
13333
13876
|
const generator = this.#generator;
|
|
13334
13877
|
const light = this.#light;
|
|
13335
13878
|
this.#generator = null;
|
|
13879
|
+
this.#appliedShadowSettings = null;
|
|
13336
13880
|
if (generator !== null) {
|
|
13337
13881
|
detachShadows(renderer.scene, light, generator);
|
|
13338
13882
|
renderer.needsShadowLayoutReset = true;
|
|
@@ -13350,6 +13894,7 @@ var Light = class Light extends Component {
|
|
|
13350
13894
|
this.#light = null;
|
|
13351
13895
|
this.#appliedType = null;
|
|
13352
13896
|
this.#appliedShadows = false;
|
|
13897
|
+
this.#appliedShadowSettings = null;
|
|
13353
13898
|
const remove = () => {
|
|
13354
13899
|
if (generator !== null) {
|
|
13355
13900
|
detachShadows(renderer.scene, light, generator);
|
|
@@ -13361,6 +13906,34 @@ var Light = class Light extends Component {
|
|
|
13361
13906
|
else renderer.afterRebuild(remove);
|
|
13362
13907
|
}
|
|
13363
13908
|
};
|
|
13909
|
+
/** Every field of {@link LightShadowSettings}; Lite reads all of them when it builds a generator. */
|
|
13910
|
+
const SHADOW_SETTING_KEYS = [
|
|
13911
|
+
"enabled",
|
|
13912
|
+
"technique",
|
|
13913
|
+
"mapSize",
|
|
13914
|
+
"bias",
|
|
13915
|
+
"normalBias",
|
|
13916
|
+
"darkness",
|
|
13917
|
+
"cascades",
|
|
13918
|
+
"maxDistance",
|
|
13919
|
+
"stabilizeCascades",
|
|
13920
|
+
"cascadeLambda",
|
|
13921
|
+
"cascadeBlend"
|
|
13922
|
+
];
|
|
13923
|
+
/**
|
|
13924
|
+
* Whether a generator built from `applied` still matches the declared `shadows` record.
|
|
13925
|
+
*
|
|
13926
|
+
* @param applied - The record the generator was built from, or `null` when there is none.
|
|
13927
|
+
* @param declared - The component's record now.
|
|
13928
|
+
* @returns `true` when every field is the same.
|
|
13929
|
+
*
|
|
13930
|
+
* @internal
|
|
13931
|
+
*/
|
|
13932
|
+
function sameShadowSettings(applied, declared) {
|
|
13933
|
+
if (applied === null) return false;
|
|
13934
|
+
for (const key of SHADOW_SETTING_KEYS) if (applied[key] !== declared[key]) return false;
|
|
13935
|
+
return true;
|
|
13936
|
+
}
|
|
13364
13937
|
/**
|
|
13365
13938
|
* Builds the Lite light of one kind, unparented and at the world origin.
|
|
13366
13939
|
*
|
|
@@ -14827,6 +15400,12 @@ function collectNames(node, out) {
|
|
|
14827
15400
|
*/
|
|
14828
15401
|
const MESHOPT_DECODER_FILE = "meshopt_decoder.js";
|
|
14829
15402
|
/**
|
|
15403
|
+
* The file name of the Draco decoder script Lite injects.
|
|
15404
|
+
*
|
|
15405
|
+
* @internal
|
|
15406
|
+
*/
|
|
15407
|
+
const DRACO_DECODER_FILE = "draco_decoder.js";
|
|
15408
|
+
/**
|
|
14830
15409
|
* The transcoder modules `babylon.ktx2Decoder.js` fetches, as `[class, static property, file]`:
|
|
14831
15410
|
* the class in the decoder's `KTX2DECODER` namespace whose property holds the URL, and the file
|
|
14832
15411
|
* name it is served under. These are the defaults in `@babylonjs/ktx2decoder`'s
|
|
@@ -14886,8 +15465,9 @@ const KTX2_TRANSCODER_FILES = [
|
|
|
14886
15465
|
*
|
|
14887
15466
|
* @remarks
|
|
14888
15467
|
* The transcoders are only worth overriding together with the decoder script that reads them, so
|
|
14889
|
-
* they are ignored when the manifest has no `babylon.ktx2Decoder.js`. Lite takes the meshopt
|
|
14890
|
-
*
|
|
15468
|
+
* they are ignored when the manifest has no `babylon.ktx2Decoder.js`. Lite takes the meshopt and
|
|
15469
|
+
* Draco decoders' **directories**, so an entry is used only when its URL ends in the file name, and
|
|
15470
|
+
* the Draco script only when its WebAssembly is listed in the same directory.
|
|
14891
15471
|
*
|
|
14892
15472
|
* @param manifest - The asset manifest.
|
|
14893
15473
|
* @returns The locations; a `null` field means the manifest does not list that decoder.
|
|
@@ -14911,13 +15491,25 @@ function decoderUrlsFromManifest(manifest) {
|
|
|
14911
15491
|
[property]: url
|
|
14912
15492
|
};
|
|
14913
15493
|
}
|
|
14914
|
-
const
|
|
15494
|
+
const meshoptBaseUrl = directoryOf(urls.get(MESHOPT_DECODER_FILE), MESHOPT_DECODER_FILE);
|
|
15495
|
+
const dracoDirectory = directoryOf(urls.get(DRACO_DECODER_FILE), DRACO_DECODER_FILE);
|
|
14915
15496
|
return {
|
|
14916
15497
|
ktx2Decoder,
|
|
14917
15498
|
ktx2Transcoders,
|
|
14918
|
-
meshoptBaseUrl
|
|
15499
|
+
meshoptBaseUrl,
|
|
15500
|
+
dracoBaseUrl: dracoDirectory !== null && urls.get("draco_decoder_gltf.wasm") === `${dracoDirectory}draco_decoder_gltf.wasm` ? dracoDirectory : null
|
|
14919
15501
|
};
|
|
14920
15502
|
}
|
|
15503
|
+
/**
|
|
15504
|
+
* The directory a file is served from, when its URL ends in the name Lite appends.
|
|
15505
|
+
*
|
|
15506
|
+
* @param url - The manifest URL, or `undefined` when the manifest has no entry.
|
|
15507
|
+
* @param file - The file name Lite appends to the directory.
|
|
15508
|
+
* @returns The directory with its trailing slash, or `null`.
|
|
15509
|
+
*/
|
|
15510
|
+
function directoryOf(url, file) {
|
|
15511
|
+
return url?.endsWith(file) === true ? url.slice(0, url.length - file.length) : null;
|
|
15512
|
+
}
|
|
14921
15513
|
/** What {@link configureDecoders} last handed Lite, so an unchanged manifest costs one comparison. */
|
|
14922
15514
|
let appliedKey = null;
|
|
14923
15515
|
/**
|
|
@@ -14936,10 +15528,10 @@ let appliedKey = null;
|
|
|
14936
15528
|
*/
|
|
14937
15529
|
async function configureDecoders(app) {
|
|
14938
15530
|
const urls = decoderUrlsFromManifest(app.assets.manifest);
|
|
14939
|
-
if (urls.ktx2Decoder === null && urls.meshoptBaseUrl === null) return;
|
|
15531
|
+
if (urls.ktx2Decoder === null && urls.meshoptBaseUrl === null && urls.dracoBaseUrl === null) return;
|
|
14940
15532
|
const key = JSON.stringify(urls);
|
|
14941
15533
|
if (key === appliedKey) return;
|
|
14942
|
-
(await import("./decoders-
|
|
15534
|
+
(await import("./decoders-BUQrlS8U.js")).applyLiteDecoderUrls(urls);
|
|
14943
15535
|
appliedKey = key;
|
|
14944
15536
|
}
|
|
14945
15537
|
//#endregion
|
|
@@ -15142,9 +15734,11 @@ function createModelAsset(address, container, scene) {
|
|
|
15142
15734
|
* ## Decoders
|
|
15143
15735
|
*
|
|
15144
15736
|
* A glTF may need one of Lite's run-time decoders: `KHR_texture_basisu` images go through the KTX2
|
|
15145
|
-
* decoder
|
|
15146
|
-
* `
|
|
15147
|
-
*
|
|
15737
|
+
* decoder, `EXT_meshopt_compression` buffers through the meshopt decoder and
|
|
15738
|
+
* `KHR_draco_mesh_compression` primitives through the Draco decoder. Lite loads them from
|
|
15739
|
+
* `cdn.babylonjs.com` (Draco: from `/`) unless told otherwise, so the loader calls
|
|
15740
|
+
* `configureDecoders` first, which points Lite at the copies `@ignifx/vite-plugin` serves
|
|
15741
|
+
* (`../decoder-urls.ts`). Lite fetches a decoder only when a file uses its extension.
|
|
15148
15742
|
*
|
|
15149
15743
|
* ## Headless
|
|
15150
15744
|
*
|
|
@@ -15387,7 +15981,7 @@ function loadTexture(engine, url, options) {
|
|
|
15387
15981
|
* @internal
|
|
15388
15982
|
*/
|
|
15389
15983
|
async function loadKtx2Texture(engine, url, options = {}) {
|
|
15390
|
-
return (await import("./decoders-
|
|
15984
|
+
return (await import("./decoders-BUQrlS8U.js")).loadKtx2TextureWithOptions(engine, url, options);
|
|
15391
15985
|
}
|
|
15392
15986
|
/**
|
|
15393
15987
|
* Loads a Basis Universal (`.basis`) texture from a URL.
|
|
@@ -15405,7 +15999,7 @@ async function loadKtx2Texture(engine, url, options = {}) {
|
|
|
15405
15999
|
* @internal
|
|
15406
16000
|
*/
|
|
15407
16001
|
async function loadBasisTexture(engine, url, options = {}) {
|
|
15408
|
-
return (await import("./decoders-
|
|
16002
|
+
return (await import("./decoders-BUQrlS8U.js")).loadBasisTextureWithOptions(engine, url, options);
|
|
15409
16003
|
}
|
|
15410
16004
|
/**
|
|
15411
16005
|
* Creates a 2D texture from tightly packed RGBA8 bytes.
|
|
@@ -17208,6 +17802,12 @@ var PostProcessChain = class {
|
|
|
17208
17802
|
#isFrameGraphBuilt;
|
|
17209
17803
|
/** The sampled ping-pong links the custom effects read and write. */
|
|
17210
17804
|
#sampledLinks = [];
|
|
17805
|
+
/** The `rgba16float` links the custom effects ahead of the HDR output pass ping-pong through. */
|
|
17806
|
+
#linearLinks = [];
|
|
17807
|
+
/** What the HDR output pass reads while the chain is enabled; `null` when no effect runs ahead of it. */
|
|
17808
|
+
#linearOutput = null;
|
|
17809
|
+
/** How many tasks run after the output pass, on display colour; only those take over the swapchain. */
|
|
17810
|
+
#displayTaskCount = 0;
|
|
17211
17811
|
/** The recorded custom effects, in chain order. */
|
|
17212
17812
|
#custom = [];
|
|
17213
17813
|
/** The bloom task, when the chain has one; the one task whose tuning is retuned live. */
|
|
@@ -17245,7 +17845,9 @@ var PostProcessChain = class {
|
|
|
17245
17845
|
const plainLinks = [];
|
|
17246
17846
|
let source = presenter.sceneColor;
|
|
17247
17847
|
let sourceTexture = null;
|
|
17248
|
-
|
|
17848
|
+
const first = effectTasks === null ? 0 : this.#recordLinearEffects(effectTasks, engine, scene, ordered);
|
|
17849
|
+
const linearTaskCount = this.#tasks.length;
|
|
17850
|
+
for (let index = first; index < ordered.length; index += 1) {
|
|
17249
17851
|
const effect = ordered[index];
|
|
17250
17852
|
if (effect === void 0) continue;
|
|
17251
17853
|
const isLast = index === ordered.length - 1;
|
|
@@ -17273,6 +17875,8 @@ var PostProcessChain = class {
|
|
|
17273
17875
|
source = target;
|
|
17274
17876
|
sourceTexture = link?.texture ?? null;
|
|
17275
17877
|
}
|
|
17878
|
+
this.#displayTaskCount = this.#tasks.length - linearTaskCount;
|
|
17879
|
+
if (this.#displayTaskCount === 0) return;
|
|
17276
17880
|
presenter.setPresentEnabled(false);
|
|
17277
17881
|
}
|
|
17278
17882
|
/**
|
|
@@ -17333,7 +17937,8 @@ var PostProcessChain = class {
|
|
|
17333
17937
|
const task = this.#tasks[index];
|
|
17334
17938
|
if (task !== void 0) setPostProcessTaskEnabled(task, enabled);
|
|
17335
17939
|
}
|
|
17336
|
-
if (this.#
|
|
17940
|
+
if (this.#linearOutput !== null) this.#presenter.hdr?.setOutputSource(enabled ? this.#linearOutput : null);
|
|
17941
|
+
if (this.#displayTaskCount > 0) this.#presenter.setPresentEnabled(!enabled);
|
|
17337
17942
|
}
|
|
17338
17943
|
/**
|
|
17339
17944
|
* Uploads every custom effect's uniform bytes, and only the ones that changed.
|
|
@@ -17382,8 +17987,15 @@ var PostProcessChain = class {
|
|
|
17382
17987
|
}
|
|
17383
17988
|
}
|
|
17384
17989
|
if (this.#tasks.length > 0) this.#presenter.setPresentEnabled(true);
|
|
17990
|
+
if (this.#linearOutput !== null) {
|
|
17991
|
+
this.#presenter.hdr?.setOutputSource(null);
|
|
17992
|
+
this.#linearOutput = null;
|
|
17993
|
+
}
|
|
17385
17994
|
const effects = effectTaskSupport();
|
|
17386
17995
|
for (const recorded of this.#custom) effects?.disposeCustomEffect(recorded.effect);
|
|
17996
|
+
for (const link of this.#linearLinks) effects?.disposeEffectChainLink(link);
|
|
17997
|
+
this.#linearLinks.length = 0;
|
|
17998
|
+
this.#displayTaskCount = 0;
|
|
17387
17999
|
for (const link of this.#sampledLinks) effects?.disposeEffectChainLink(link);
|
|
17388
18000
|
this.#custom.length = 0;
|
|
17389
18001
|
this.#sampledLinks.length = 0;
|
|
@@ -17431,6 +18043,56 @@ var PostProcessChain = class {
|
|
|
17431
18043
|
return effects.createCustomEffectTask(engine, scene, `ignifx:post-effect:${request.address}`, wrapper, target);
|
|
17432
18044
|
}
|
|
17433
18045
|
/**
|
|
18046
|
+
* Under `rendering.hdr`, records the custom effects ordered before any built-in one ahead of the
|
|
18047
|
+
* output pass, where they read and write linear `rgba16float` colour (GI plan step G3).
|
|
18048
|
+
*
|
|
18049
|
+
* @remarks
|
|
18050
|
+
* The first reads the scene's HDR texture directly, which is already a sampled `Texture2D`, so no
|
|
18051
|
+
* copy is needed; the last one's link becomes the output pass's input. Built-in effects and every
|
|
18052
|
+
* effect after the first of them stay behind the output pass: Lite's bloom, SMAA and
|
|
18053
|
+
* image-processing tasks expect display colour in the surface's format.
|
|
18054
|
+
*
|
|
18055
|
+
* @param effects - The effect adapter.
|
|
18056
|
+
* @param engine - The engine.
|
|
18057
|
+
* @param scene - The scene.
|
|
18058
|
+
* @param ordered - The chain's effects, in order.
|
|
18059
|
+
* @returns How many leading effects were recorded; `0` without HDR.
|
|
18060
|
+
*/
|
|
18061
|
+
#recordLinearEffects(effects, engine, scene, ordered) {
|
|
18062
|
+
const hdr = this.#presenter.hdr;
|
|
18063
|
+
if (hdr === null) return 0;
|
|
18064
|
+
let sourceTexture = hdr.sceneTexture;
|
|
18065
|
+
let count = 0;
|
|
18066
|
+
for (; count < ordered.length; count += 1) {
|
|
18067
|
+
const effect = ordered[count];
|
|
18068
|
+
if (effect?.name !== "custom") break;
|
|
18069
|
+
const link = this.#nextLinearLink(effects, engine, sourceTexture);
|
|
18070
|
+
const task = this.#recordCustom(effects, engine, scene, effect, sourceTexture, link.target);
|
|
18071
|
+
hdr.insertLinearTask(task, this.#isFrameGraphBuilt);
|
|
18072
|
+
this.#tasks.push(task);
|
|
18073
|
+
sourceTexture = link.texture;
|
|
18074
|
+
}
|
|
18075
|
+
if (count > 0) {
|
|
18076
|
+
this.#linearOutput = sourceTexture;
|
|
18077
|
+
hdr.setOutputSource(sourceTexture);
|
|
18078
|
+
}
|
|
18079
|
+
return count;
|
|
18080
|
+
}
|
|
18081
|
+
/**
|
|
18082
|
+
* Returns an `rgba16float` link other than the one an effect reads, creating it on first use.
|
|
18083
|
+
*
|
|
18084
|
+
* @param effects - The effect adapter.
|
|
18085
|
+
* @param engine - The engine.
|
|
18086
|
+
* @param source - The texture the next effect reads.
|
|
18087
|
+
* @returns The link to write.
|
|
18088
|
+
*/
|
|
18089
|
+
#nextLinearLink(effects, engine, source) {
|
|
18090
|
+
for (const link of this.#linearLinks) if (link.texture !== source) return link;
|
|
18091
|
+
const created = effects.createEffectChainLink(engine, "rgba16float", engine.canvas.width, engine.canvas.height, `ignifx:post-effect-linear-${String(this.#linearLinks.length)}`);
|
|
18092
|
+
this.#linearLinks.push(created);
|
|
18093
|
+
return created;
|
|
18094
|
+
}
|
|
18095
|
+
/**
|
|
17434
18096
|
* The next sampled ping-pong link that is not the one being read.
|
|
17435
18097
|
*
|
|
17436
18098
|
* @remarks
|
|
@@ -17617,6 +18279,184 @@ function nextLink(engine, links, source) {
|
|
|
17617
18279
|
return created;
|
|
17618
18280
|
}
|
|
17619
18281
|
//#endregion
|
|
18282
|
+
//#region src/render/hdr-bloom-support.ts
|
|
18283
|
+
/** The loaded module, memoised for the process. */
|
|
18284
|
+
let layer = null;
|
|
18285
|
+
/** The pending import, so concurrent callers share it. */
|
|
18286
|
+
let loading = null;
|
|
18287
|
+
/**
|
|
18288
|
+
* Loads the HDR bloom chunk, once per process.
|
|
18289
|
+
*
|
|
18290
|
+
* @returns The module.
|
|
18291
|
+
*
|
|
18292
|
+
* @internal
|
|
18293
|
+
*/
|
|
18294
|
+
async function loadHdrBloomSupport() {
|
|
18295
|
+
loading ??= import("./bloom-hdr-CLtQj-oY.js").then((module) => {
|
|
18296
|
+
layer = module;
|
|
18297
|
+
return module;
|
|
18298
|
+
});
|
|
18299
|
+
return loading;
|
|
18300
|
+
}
|
|
18301
|
+
/**
|
|
18302
|
+
* The HDR bloom chunk, if it has been loaded.
|
|
18303
|
+
*
|
|
18304
|
+
* @returns The module, or `null` before {@link loadHdrBloomSupport} settled.
|
|
18305
|
+
*
|
|
18306
|
+
* @internal
|
|
18307
|
+
*/
|
|
18308
|
+
function hdrBloomSupport() {
|
|
18309
|
+
return layer;
|
|
18310
|
+
}
|
|
18311
|
+
//#endregion
|
|
18312
|
+
//#region src/render/screen-space-effects.ts
|
|
18313
|
+
/** Numbers each Lite camera object, so the key can name it. */
|
|
18314
|
+
let cameraIds = null;
|
|
18315
|
+
/** The next camera number. */
|
|
18316
|
+
let nextCameraId = 1;
|
|
18317
|
+
/**
|
|
18318
|
+
* The scene-colour effects of one `PostProcessStack`.
|
|
18319
|
+
*
|
|
18320
|
+
* @internal
|
|
18321
|
+
*/
|
|
18322
|
+
var ScreenSpaceEffects = class {
|
|
18323
|
+
/** The key the current (or pending) build was started for; `""` when nothing should run. */
|
|
18324
|
+
#key = "";
|
|
18325
|
+
/** Bumped by every new build and by dispose, so a superseded async build cleans up after itself. */
|
|
18326
|
+
#generation = 0;
|
|
18327
|
+
#built = null;
|
|
18328
|
+
/**
|
|
18329
|
+
* Whether a build is live.
|
|
18330
|
+
*
|
|
18331
|
+
* @returns `true` once the passes are in the frame graph.
|
|
18332
|
+
*/
|
|
18333
|
+
get isBuilt() {
|
|
18334
|
+
return this.#built !== null;
|
|
18335
|
+
}
|
|
18336
|
+
/**
|
|
18337
|
+
* How many frame-graph tasks the passes added.
|
|
18338
|
+
*
|
|
18339
|
+
* @returns The count, `0` while nothing is built.
|
|
18340
|
+
*/
|
|
18341
|
+
get taskCount() {
|
|
18342
|
+
return this.#built?.installed.taskCount ?? 0;
|
|
18343
|
+
}
|
|
18344
|
+
/**
|
|
18345
|
+
* Builds, rebuilds or tears down the passes to match the records, then pushes the live tuning.
|
|
18346
|
+
* Called from the stack's `sync` every `PreRender`.
|
|
18347
|
+
*
|
|
18348
|
+
* @param renderer - The rendering service.
|
|
18349
|
+
* @param contact - The `contactShadows` record.
|
|
18350
|
+
* @param ssgi - The `ssgi` record.
|
|
18351
|
+
* @param isEnabled - Whether the stack is enabled in the hierarchy.
|
|
18352
|
+
*/
|
|
18353
|
+
sync(renderer, contact, ssgi, isEnabled) {
|
|
18354
|
+
const tier = renderer.qualityPreset;
|
|
18355
|
+
const runsContact = contact.enabled && (tier === null || tier.contactShadows);
|
|
18356
|
+
const runsSsgi = ssgi.enabled && (tier === null || tier.ssgi);
|
|
18357
|
+
const key = buildKey(renderer, runsContact, runsSsgi, ssgi.halfResolution, isEnabled);
|
|
18358
|
+
if (key !== this.#key) {
|
|
18359
|
+
this.#key = key;
|
|
18360
|
+
this.#teardown(renderer.isSceneRegistered);
|
|
18361
|
+
if (key !== "") this.#build(renderer, runsContact ? contact : null, runsSsgi ? ssgi : null, this.#generation).catch((failure) => {
|
|
18362
|
+
renderer.app.log.error(`PostProcessStack could not build contact shadows or SSGI: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
18363
|
+
});
|
|
18364
|
+
return;
|
|
18365
|
+
}
|
|
18366
|
+
const built = this.#built;
|
|
18367
|
+
if (built === null) return;
|
|
18368
|
+
built.contact?.update(contact);
|
|
18369
|
+
built.ssgi?.update(ssgi, renderer.isSceneRegistered);
|
|
18370
|
+
}
|
|
18371
|
+
/**
|
|
18372
|
+
* Removes everything, and stops a build in flight.
|
|
18373
|
+
*
|
|
18374
|
+
* @param isSceneRegistered - Whether materials the SSGI plugin leaves must be rebuilt.
|
|
18375
|
+
*/
|
|
18376
|
+
dispose(isSceneRegistered) {
|
|
18377
|
+
this.#key = "";
|
|
18378
|
+
this.#teardown(isSceneRegistered);
|
|
18379
|
+
}
|
|
18380
|
+
/**
|
|
18381
|
+
* Frees the current build and invalidates any pending one.
|
|
18382
|
+
*
|
|
18383
|
+
* @param isSceneRegistered - Whether materials the SSGI plugin leaves must be rebuilt.
|
|
18384
|
+
*/
|
|
18385
|
+
#teardown(isSceneRegistered) {
|
|
18386
|
+
this.#generation += 1;
|
|
18387
|
+
const built = this.#built;
|
|
18388
|
+
this.#built = null;
|
|
18389
|
+
if (built === null) return;
|
|
18390
|
+
built.ssgi?.dispose(isSceneRegistered);
|
|
18391
|
+
built.installed.dispose();
|
|
18392
|
+
built.inputs.release();
|
|
18393
|
+
}
|
|
18394
|
+
/**
|
|
18395
|
+
* Loads the chunks, leases the scene inputs, and installs the passes.
|
|
18396
|
+
*
|
|
18397
|
+
* @param renderer - The rendering service.
|
|
18398
|
+
* @param contact - The `contactShadows` record, or `null` when it does not run.
|
|
18399
|
+
* @param ssgi - The `ssgi` record, or `null` when it does not run.
|
|
18400
|
+
* @param generation - The generation this build belongs to.
|
|
18401
|
+
*/
|
|
18402
|
+
async #build(renderer, contact, ssgi, generation) {
|
|
18403
|
+
const [inputs, wiring, contactModule, ssgiModule] = await Promise.all([
|
|
18404
|
+
renderer.acquireSceneInputs(),
|
|
18405
|
+
import("./scene-color-passes-DlNr-qyZ.js"),
|
|
18406
|
+
contact === null ? null : import("./contact-shadows-T523EXaP.js"),
|
|
18407
|
+
ssgi === null ? null : import("./ssgi-Dm-maZrc.js")
|
|
18408
|
+
]);
|
|
18409
|
+
const presenter = renderer.presenter;
|
|
18410
|
+
const camera = renderer.isHeadless ? null : renderer.scene.camera;
|
|
18411
|
+
if (generation !== this.#generation || inputs === null || presenter === null || camera === null) {
|
|
18412
|
+
inputs?.release();
|
|
18413
|
+
return;
|
|
18414
|
+
}
|
|
18415
|
+
const { engine, scene } = renderer;
|
|
18416
|
+
const passes = [];
|
|
18417
|
+
const contactPass = contact === null ? null : contactModule?.createContactShadowsPass(engine, scene, inputs.depthTarget, camera, contact) ?? null;
|
|
18418
|
+
if (contactPass !== null) passes.push(contactPass);
|
|
18419
|
+
const ssgiPass = ssgi === null ? null : ssgiModule?.createSsgiPass(engine, scene, inputs.depthTarget, camera, {
|
|
18420
|
+
tuning: ssgi,
|
|
18421
|
+
halfResolution: ssgi.halfResolution,
|
|
18422
|
+
usePlugin: renderer.settings.hdr || renderer.features.materialPlugins
|
|
18423
|
+
}) ?? null;
|
|
18424
|
+
if (ssgiPass !== null) passes.push(ssgiPass);
|
|
18425
|
+
const installed = wiring.installSceneColorPasses(engine, scene, presenter, passes, renderer.isSceneRegistered);
|
|
18426
|
+
this.#built = {
|
|
18427
|
+
inputs,
|
|
18428
|
+
installed,
|
|
18429
|
+
contact: contactPass,
|
|
18430
|
+
ssgi: ssgiPass
|
|
18431
|
+
};
|
|
18432
|
+
if (contact !== null) contactPass?.update(contact);
|
|
18433
|
+
if (ssgi !== null) ssgiPass?.update(ssgi, renderer.isSceneRegistered);
|
|
18434
|
+
}
|
|
18435
|
+
};
|
|
18436
|
+
/**
|
|
18437
|
+
* The build's identity: which passes run, SSGI's resolution, and the camera; `""` for none.
|
|
18438
|
+
*
|
|
18439
|
+
* @param renderer - The rendering service.
|
|
18440
|
+
* @param runsContact - Whether contact shadows run.
|
|
18441
|
+
* @param runsSsgi - Whether SSGI runs.
|
|
18442
|
+
* @param ssgiHalf - SSGI's `halfResolution`.
|
|
18443
|
+
* @param isEnabled - Whether the stack is enabled in the hierarchy.
|
|
18444
|
+
* @returns The key.
|
|
18445
|
+
*/
|
|
18446
|
+
function buildKey(renderer, runsContact, runsSsgi, ssgiHalf, isEnabled) {
|
|
18447
|
+
if (!isEnabled || !runsContact && !runsSsgi || renderer.isHeadless || renderer.presenter === null) return "";
|
|
18448
|
+
const camera = renderer.scene.camera;
|
|
18449
|
+
if (camera === null) return "";
|
|
18450
|
+
cameraIds ??= /* @__PURE__ */ new WeakMap();
|
|
18451
|
+
let id = cameraIds.get(camera);
|
|
18452
|
+
if (id === void 0) {
|
|
18453
|
+
id = nextCameraId;
|
|
18454
|
+
nextCameraId += 1;
|
|
18455
|
+
cameraIds.set(camera, id);
|
|
18456
|
+
}
|
|
18457
|
+
return `${runsContact ? "contact" : ""}|${runsSsgi ? `ssgi:${ssgiHalf ? "half" : "full"}` : ""}|camera:${String(id)}`;
|
|
18458
|
+
}
|
|
18459
|
+
//#endregion
|
|
17620
18460
|
//#region src/render/post-process-stack.ts
|
|
17621
18461
|
/**
|
|
17622
18462
|
* One instance of a post-process chain, attached to the main camera's entity
|
|
@@ -17647,6 +18487,8 @@ var PostProcessStack = class PostProcessStack extends Component {
|
|
|
17647
18487
|
static allowMultiple = false;
|
|
17648
18488
|
/** The serialized field declarations (ADR-0004). */
|
|
17649
18489
|
static schema = postProcessSchema();
|
|
18490
|
+
/** The contact-shadow and SSGI passes, which run on the scene colour before the chain. */
|
|
18491
|
+
#screenSpace = new ScreenSpaceEffects();
|
|
17650
18492
|
/** Applies the schema defaults, exactly as `Component.define` would. */
|
|
17651
18493
|
constructor() {
|
|
17652
18494
|
super();
|
|
@@ -17655,6 +18497,10 @@ var PostProcessStack = class PostProcessStack extends Component {
|
|
|
17655
18497
|
#chain = null;
|
|
17656
18498
|
#built = "";
|
|
17657
18499
|
#hasWarnedAboutFeature = false;
|
|
18500
|
+
/** The HDR bloom chain, once a stack under `rendering.hdr` asked for bloom. */
|
|
18501
|
+
#hdrBloom = null;
|
|
18502
|
+
/** Whether loading the HDR bloom chunk failed, so it is reported once. */
|
|
18503
|
+
#hdrBloomFailed = false;
|
|
17658
18504
|
/** The shader addresses whose compilation already failed, so the report is made once each. */
|
|
17659
18505
|
#failedShaders = /* @__PURE__ */ new Set();
|
|
17660
18506
|
/** The entry buffer `#chainKey` refills every frame. */
|
|
@@ -17679,7 +18525,18 @@ var PostProcessStack = class PostProcessStack extends Component {
|
|
|
17679
18525
|
* `postProcessing` rendering feature is off.
|
|
17680
18526
|
*/
|
|
17681
18527
|
get taskCount() {
|
|
17682
|
-
return this.#chain?.taskCount ?? 0;
|
|
18528
|
+
return (this.#chain?.taskCount ?? 0) + (this.#hdrBloom?.taskCount ?? 0);
|
|
18529
|
+
}
|
|
18530
|
+
/**
|
|
18531
|
+
* The HDR bloom chain, once it is recorded.
|
|
18532
|
+
*
|
|
18533
|
+
* @returns The chain, or `null` without `rendering.hdr`, before bloom was enabled, or while its
|
|
18534
|
+
* chunk loads.
|
|
18535
|
+
*
|
|
18536
|
+
* @internal
|
|
18537
|
+
*/
|
|
18538
|
+
get hdrBloom() {
|
|
18539
|
+
return this.#hdrBloom;
|
|
17683
18540
|
}
|
|
17684
18541
|
/** Nothing to do at attach: the chain is built on the first sync that wants an effect. */
|
|
17685
18542
|
onAttach() {
|
|
@@ -17688,10 +18545,14 @@ var PostProcessStack = class PostProcessStack extends Component {
|
|
|
17688
18545
|
}
|
|
17689
18546
|
/** Disables and disposes every task the stack recorded. */
|
|
17690
18547
|
onDetach() {
|
|
18548
|
+
this.#screenSpace.dispose(this.#screenSpace.isBuilt && rendererOfStack(this).isSceneRegistered);
|
|
17691
18549
|
const chain = this.#chain;
|
|
17692
18550
|
this.#chain = null;
|
|
17693
18551
|
this.#built = "";
|
|
17694
18552
|
chain?.dispose();
|
|
18553
|
+
const bloom = this.#hdrBloom;
|
|
18554
|
+
this.#hdrBloom = null;
|
|
18555
|
+
bloom?.dispose();
|
|
17695
18556
|
}
|
|
17696
18557
|
/**
|
|
17697
18558
|
* Builds the chain when the effects it should hold change, and keeps the recorded tasks' tuning
|
|
@@ -17714,16 +18575,61 @@ var PostProcessStack = class PostProcessStack extends Component {
|
|
|
17714
18575
|
* @internal
|
|
17715
18576
|
*/
|
|
17716
18577
|
sync(renderer) {
|
|
18578
|
+
this.#syncHdrBloom(renderer);
|
|
18579
|
+
this.#screenSpace.sync(renderer, this.contactShadows, this.ssgi, this.isEnabledInHierarchy);
|
|
17717
18580
|
const wanted = this.#chainKey(renderer);
|
|
17718
18581
|
if (wanted !== this.#built) {
|
|
17719
18582
|
this.#rebuild(renderer, wanted);
|
|
17720
18583
|
return;
|
|
17721
18584
|
}
|
|
17722
|
-
if (!this.#hasWarnedAboutFeature && !renderer.features.postProcessing) this.#warnAboutFeature(renderer, this.plannedChain().length);
|
|
18585
|
+
if (!this.#hasWarnedAboutFeature && !renderer.features.postProcessing) this.#warnAboutFeature(renderer, this.plannedChain().length + this.#screenSpaceCount());
|
|
17723
18586
|
const surface = renderer.surface;
|
|
17724
18587
|
applyPostProcessSettings(this.#chain, this.isEnabledInHierarchy, this.bloom, this.smaa, renderer.effectClock, surface?.width ?? 0, surface?.height ?? 0, renderer.isSceneRegistered);
|
|
17725
18588
|
}
|
|
17726
18589
|
/**
|
|
18590
|
+
* Keeps the HDR bloom chain in step with the `bloom` record under `rendering.hdr`.
|
|
18591
|
+
*
|
|
18592
|
+
* @remarks
|
|
18593
|
+
* The chain is built once, the first frame bloom is wanted after its chunk has loaded, and is
|
|
18594
|
+
* then only switched on or off: Lite cannot remove its tasks, and nothing in the record changes
|
|
18595
|
+
* its shape. Until the chunk is in, the frame presents without bloom.
|
|
18596
|
+
*
|
|
18597
|
+
* @param renderer - The rendering service, for the presenter and the scene.
|
|
18598
|
+
*/
|
|
18599
|
+
#syncHdrBloom(renderer) {
|
|
18600
|
+
const hdr = renderer.presenter?.hdr ?? null;
|
|
18601
|
+
const isWanted = hdr !== null && this.bloom.enabled && this.isEnabledInHierarchy;
|
|
18602
|
+
if (this.#hdrBloom === null) {
|
|
18603
|
+
if (!isWanted || this.#hdrBloomFailed) return;
|
|
18604
|
+
const support = hdrBloomSupport();
|
|
18605
|
+
if (support === null) {
|
|
18606
|
+
loadHdrBloomSupport().catch((failure) => {
|
|
18607
|
+
this.#reportHdrBloomFailure(renderer, failure);
|
|
18608
|
+
});
|
|
18609
|
+
return;
|
|
18610
|
+
}
|
|
18611
|
+
this.#hdrBloom = support.installHdrBloom(renderer.engine, renderer.scene, hdr, renderer.isSceneRegistered);
|
|
18612
|
+
}
|
|
18613
|
+
const bloom = this.bloom;
|
|
18614
|
+
this.#hdrBloom.setEnabled(isWanted);
|
|
18615
|
+
this.#hdrBloom.apply({
|
|
18616
|
+
intensity: bloom.intensity,
|
|
18617
|
+
radius: bloom.radius,
|
|
18618
|
+
threshold: bloom.hdrThreshold
|
|
18619
|
+
});
|
|
18620
|
+
}
|
|
18621
|
+
/**
|
|
18622
|
+
* Reports, once, that the HDR bloom chunk did not load.
|
|
18623
|
+
*
|
|
18624
|
+
* @param renderer - The rendering service, for the log.
|
|
18625
|
+
* @param failure - What the import threw.
|
|
18626
|
+
*/
|
|
18627
|
+
#reportHdrBloomFailure(renderer, failure) {
|
|
18628
|
+
if (this.#hdrBloomFailed) return;
|
|
18629
|
+
this.#hdrBloomFailed = true;
|
|
18630
|
+
renderer.app.log.error(`HDR bloom could not be loaded, so {entity} renders without it. ${String(failure)}`, this.entity.name);
|
|
18631
|
+
}
|
|
18632
|
+
/**
|
|
17727
18633
|
* Replaces the chain with one that holds the effects the fields currently ask for.
|
|
17728
18634
|
*
|
|
17729
18635
|
* @remarks
|
|
@@ -17742,7 +18648,15 @@ var PostProcessStack = class PostProcessStack extends Component {
|
|
|
17742
18648
|
previous?.dispose();
|
|
17743
18649
|
const requests = this.#requests(renderer);
|
|
17744
18650
|
this.#chain = recordPostProcessChain(renderer.engine, renderer.scene, renderer.presenter, renderer.isHeadless, requests, renderer.isSceneRegistered, this.isEnabledInHierarchy, this.#reportRefusedValues);
|
|
17745
|
-
this.#warnAboutFeature(renderer, requests.length);
|
|
18651
|
+
this.#warnAboutFeature(renderer, requests.length + this.#screenSpaceCount());
|
|
18652
|
+
}
|
|
18653
|
+
/**
|
|
18654
|
+
* How many of the scene-colour passes the fields ask for.
|
|
18655
|
+
*
|
|
18656
|
+
* @returns 0, 1 or 2.
|
|
18657
|
+
*/
|
|
18658
|
+
#screenSpaceCount() {
|
|
18659
|
+
return (this.contactShadows.enabled ? 1 : 0) + (this.ssgi.enabled ? 1 : 0);
|
|
17746
18660
|
}
|
|
17747
18661
|
/**
|
|
17748
18662
|
* Says once, at warning level, that the stack asks for effects the project did not opt into.
|
|
@@ -17775,9 +18689,10 @@ var PostProcessStack = class PostProcessStack extends Component {
|
|
|
17775
18689
|
*/
|
|
17776
18690
|
#requests(renderer) {
|
|
17777
18691
|
const sourceIsSrgb = renderer.settings.srgb;
|
|
18692
|
+
const isHdr = renderer.settings.hdr;
|
|
17778
18693
|
const requests = [];
|
|
17779
18694
|
for (const entry of this.#entries()) {
|
|
17780
|
-
if (!entry.enabled) continue;
|
|
18695
|
+
if (!entry.enabled || isHdr && entry.name === "bloom") continue;
|
|
17781
18696
|
const settings = entry.settings;
|
|
17782
18697
|
if (entry.name !== "custom" || settings === null) {
|
|
17783
18698
|
requests.push({
|
|
@@ -17867,11 +18782,12 @@ var PostProcessStack = class PostProcessStack extends Component {
|
|
|
17867
18782
|
*/
|
|
17868
18783
|
#chainKey(renderer) {
|
|
17869
18784
|
const entries = this.#fillEntries(this.#entryScratch);
|
|
18785
|
+
const isHdr = renderer.settings.hdr;
|
|
17870
18786
|
let key = "";
|
|
17871
18787
|
let hasCustom = false;
|
|
17872
18788
|
for (let index = 0; index < entries.length; index += 1) {
|
|
17873
18789
|
const entry = entries[index];
|
|
17874
|
-
if (entry === void 0 || !entry.enabled) continue;
|
|
18790
|
+
if (entry === void 0 || !entry.enabled || isHdr && entry.name === "bloom") continue;
|
|
17875
18791
|
const settings = entry.settings;
|
|
17876
18792
|
if (entry.name !== "custom" || settings === null) {
|
|
17877
18793
|
key = key === "" ? entry.name : `${key},${entry.name}`;
|
|
@@ -17888,7 +18804,7 @@ var PostProcessStack = class PostProcessStack extends Component {
|
|
|
17888
18804
|
const part = `custom:${settings.shader?.address ?? ""}:${textures}`;
|
|
17889
18805
|
key = key === "" ? part : `${key},${part}`;
|
|
17890
18806
|
}
|
|
17891
|
-
if (this.bloom.enabled) key = `${key}|scale=${String(this.bloom.scale)}`;
|
|
18807
|
+
if (this.bloom.enabled && !isHdr) key = `${key}|scale=${String(this.bloom.scale)}`;
|
|
17892
18808
|
if (hasCustom) {
|
|
17893
18809
|
const surface = renderer.surface;
|
|
17894
18810
|
key = `${key}|size=${String(surface?.width ?? 0)}x${String(surface?.height ?? 0)}`;
|
|
@@ -17951,6 +18867,17 @@ function fallbackTexture(app, declaration) {
|
|
|
17951
18867
|
return shaderSupport()?.shaderMaterialsOf(app).fallbackTexture(declaration) ?? null;
|
|
17952
18868
|
}
|
|
17953
18869
|
/**
|
|
18870
|
+
* Reaches the rendering service from a stack, for the tests that drive `sync` by hand.
|
|
18871
|
+
*
|
|
18872
|
+
* @param stack - The component.
|
|
18873
|
+
* @returns The service.
|
|
18874
|
+
*
|
|
18875
|
+
* @internal
|
|
18876
|
+
*/
|
|
18877
|
+
function rendererOfStack(stack) {
|
|
18878
|
+
return rendererInternals(stack.app.renderer);
|
|
18879
|
+
}
|
|
18880
|
+
/**
|
|
17954
18881
|
* Builds the component's declared fields.
|
|
17955
18882
|
*
|
|
17956
18883
|
* @returns The schema. Built inside a function, not at module scope: a schema field is a function
|
|
@@ -17982,8 +18909,22 @@ function postProcessSchema() {
|
|
|
17982
18909
|
min: .05,
|
|
17983
18910
|
max: 1,
|
|
17984
18911
|
tooltip: "Fraction of full resolution the blur runs at."
|
|
18912
|
+
}),
|
|
18913
|
+
intensity: f32(.1, {
|
|
18914
|
+
min: 0,
|
|
18915
|
+
max: 1,
|
|
18916
|
+
tooltip: "HDR bloom only: how much glow is mixed into the frame."
|
|
18917
|
+
}),
|
|
18918
|
+
radius: f32(.7, {
|
|
18919
|
+
min: 0,
|
|
18920
|
+
max: 1,
|
|
18921
|
+
tooltip: "HDR bloom only: how far the glow spreads, from tight (0) to wide (1)."
|
|
18922
|
+
}),
|
|
18923
|
+
hdrThreshold: f32(0, {
|
|
18924
|
+
min: 0,
|
|
18925
|
+
tooltip: "HDR bloom only: linear luminance below which nothing glows; 0 lets every pixel glow by its energy."
|
|
17985
18926
|
})
|
|
17986
|
-
}, { tooltip: "Bloom." }),
|
|
18927
|
+
}, { 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." }),
|
|
17987
18928
|
smaa: record({
|
|
17988
18929
|
enabled: bool(false, { tooltip: "Whether subpixel morphological anti-aliasing runs." }),
|
|
17989
18930
|
order: i32(1, { tooltip: "Position in the chain; lower runs first." }),
|
|
@@ -18009,7 +18950,51 @@ function postProcessSchema() {
|
|
|
18009
18950
|
order: i32(10, { tooltip: "Position in the chain; lower runs first." }),
|
|
18010
18951
|
values: custom(postEffectValuesCodec(), { tooltip: "Overrides of the file's declared uniform defaults, by declared name." }),
|
|
18011
18952
|
textures: map(asset(TextureAsset), { tooltip: "Textures for the file's declared samplers." })
|
|
18012
|
-
}), [], { tooltip: "Custom full-screen WGSL effects, ordered among the built-ins by order." })
|
|
18953
|
+
}), [], { tooltip: "Custom full-screen WGSL effects, ordered among the built-ins by order." }),
|
|
18954
|
+
contactShadows: record({
|
|
18955
|
+
enabled: bool(false, { tooltip: "Whether screen-space contact shadows run." }),
|
|
18956
|
+
intensity: f32(.6, {
|
|
18957
|
+
min: 0,
|
|
18958
|
+
max: 4,
|
|
18959
|
+
tooltip: "How dark a contact gets."
|
|
18960
|
+
}),
|
|
18961
|
+
length: f32(.3, {
|
|
18962
|
+
min: .001,
|
|
18963
|
+
tooltip: "How far each ray marches towards the light, in world units."
|
|
18964
|
+
}),
|
|
18965
|
+
thickness: f32(.35, {
|
|
18966
|
+
min: .001,
|
|
18967
|
+
tooltip: "Assumed thickness behind each depth sample, in world units."
|
|
18968
|
+
}),
|
|
18969
|
+
samples: u32(8, {
|
|
18970
|
+
min: 1,
|
|
18971
|
+
max: 64,
|
|
18972
|
+
tooltip: "March steps per pixel."
|
|
18973
|
+
})
|
|
18974
|
+
}, { tooltip: "Short shadows where objects meet, towards the main directional light. Runs on the scene colour before the chain; needs rendering.features.postProcessing." }),
|
|
18975
|
+
ssgi: record({
|
|
18976
|
+
enabled: bool(false, { tooltip: "Whether screen-space global illumination runs (beta, desktop tier)." }),
|
|
18977
|
+
intensity: f32(1, {
|
|
18978
|
+
min: 0,
|
|
18979
|
+
max: 4,
|
|
18980
|
+
tooltip: "How strongly the bounced light is added."
|
|
18981
|
+
}),
|
|
18982
|
+
radius: f32(2, {
|
|
18983
|
+
min: .001,
|
|
18984
|
+
tooltip: "How far each ray marches, in world units."
|
|
18985
|
+
}),
|
|
18986
|
+
samples: u32(8, {
|
|
18987
|
+
min: 1,
|
|
18988
|
+
max: 64,
|
|
18989
|
+
tooltip: "March steps per ray."
|
|
18990
|
+
}),
|
|
18991
|
+
halfResolution: bool(true, { tooltip: "Trace at half resolution. A change rebuilds the pass." }),
|
|
18992
|
+
environmentDiffuse: f32(.5, {
|
|
18993
|
+
min: 0,
|
|
18994
|
+
max: 1,
|
|
18995
|
+
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."
|
|
18996
|
+
})
|
|
18997
|
+
}, { tooltip: "One bounce of the lit scene colour (beta, desktop tier). Runs on the scene colour before the chain; needs rendering.features.postProcessing." })
|
|
18013
18998
|
});
|
|
18014
18999
|
}
|
|
18015
19000
|
//#endregion
|
|
@@ -18119,6 +19104,7 @@ var RenderSyncSystem = class {
|
|
|
18119
19104
|
renderer.syncRenderTextures(cameras);
|
|
18120
19105
|
topologyChanged = this.#applyEnvironment(world) || topologyChanged;
|
|
18121
19106
|
renderer.refreshClearColor();
|
|
19107
|
+
renderer.updateAmbientOcclusion();
|
|
18122
19108
|
this.#applyStacks(world);
|
|
18123
19109
|
this.#areCastersDirty = this.#areCastersDirty || castersChanged;
|
|
18124
19110
|
if (renderer.materialCacheResets.unconfirmed && !this.#isRebuildDue && !renderer.isRebuildInFlight) this.#rebuildRenderables();
|
|
@@ -20799,6 +21785,472 @@ function collectAssetRefs(value, add) {
|
|
|
20799
21785
|
for (const key of Object.keys(object)) collectAssetRefs(object[key] ?? null, add);
|
|
20800
21786
|
}
|
|
20801
21787
|
//#endregion
|
|
21788
|
+
//#region src/schema/validate.ts
|
|
21789
|
+
/**
|
|
21790
|
+
* The inclusive bounds of a signed 32-bit integer.
|
|
21791
|
+
*
|
|
21792
|
+
* @internal
|
|
21793
|
+
*/
|
|
21794
|
+
const I32_RANGE = [-2147483648, 2147483647];
|
|
21795
|
+
/**
|
|
21796
|
+
* The inclusive bounds of an unsigned 32-bit integer.
|
|
21797
|
+
*
|
|
21798
|
+
* @internal
|
|
21799
|
+
*/
|
|
21800
|
+
const U32_RANGE = [0, 4294967295];
|
|
21801
|
+
/**
|
|
21802
|
+
* Checks a numeric value against its kind's integer rules and the field's `min`/`max` options.
|
|
21803
|
+
*
|
|
21804
|
+
* @param kind - The numeric field kind.
|
|
21805
|
+
* @param options - The field's options.
|
|
21806
|
+
* @param value - The value to check.
|
|
21807
|
+
* @param path - The property path for reported issues.
|
|
21808
|
+
* @param issues - The collector to append to.
|
|
21809
|
+
*
|
|
21810
|
+
* @internal
|
|
21811
|
+
*/
|
|
21812
|
+
function validateNumber(kind, options, value, path, issues) {
|
|
21813
|
+
if (typeof value !== "number") {
|
|
21814
|
+
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a ${kind} number, received ${typeof value}.`));
|
|
21815
|
+
return;
|
|
21816
|
+
}
|
|
21817
|
+
if (!Number.isFinite(value)) {
|
|
21818
|
+
issues.push(issue(SchemaIssueCode.nonFiniteNumber, path, `${String(value)} cannot be written to JSON.`));
|
|
21819
|
+
return;
|
|
21820
|
+
}
|
|
21821
|
+
if (kind === "i32" || kind === "u32") {
|
|
21822
|
+
if (Number.isInteger(value)) {
|
|
21823
|
+
const [low, high] = kind === "u32" ? U32_RANGE : I32_RANGE;
|
|
21824
|
+
if (value < low || value > high) issues.push(issue(SchemaIssueCode.outOfRange, path, `${value} is outside the ${kind} range.`));
|
|
21825
|
+
} else issues.push(issue(SchemaIssueCode.outOfRange, path, `${kind} requires a whole number, received ${value}.`));
|
|
21826
|
+
}
|
|
21827
|
+
const { min, max } = options;
|
|
21828
|
+
if (min !== void 0 && value < min) issues.push(issue(SchemaIssueCode.outOfRange, path, `${value} is below the declared minimum ${min}.`));
|
|
21829
|
+
if (max !== void 0 && value > max) issues.push(issue(SchemaIssueCode.outOfRange, path, `${value} is above the declared maximum ${max}.`));
|
|
21830
|
+
}
|
|
21831
|
+
/**
|
|
21832
|
+
* Checks that every named channel of an object value is a finite number, optionally within bounds.
|
|
21833
|
+
*
|
|
21834
|
+
* @param names - The channel names to require.
|
|
21835
|
+
* @param bounds - Inclusive `[low, high]` bounds each channel must fall in, or `null` for none.
|
|
21836
|
+
* @param label - How the value is named in messages.
|
|
21837
|
+
* @param value - The value to check.
|
|
21838
|
+
* @param path - The property path for reported issues.
|
|
21839
|
+
* @param issues - The collector to append to.
|
|
21840
|
+
*
|
|
21841
|
+
* @internal
|
|
21842
|
+
*/
|
|
21843
|
+
function validateChannels(names, bounds, label, value, path, issues) {
|
|
21844
|
+
if (!isPlainObject(value)) {
|
|
21845
|
+
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a ${label} object, received ${typeof value}.`));
|
|
21846
|
+
return;
|
|
21847
|
+
}
|
|
21848
|
+
for (const name of names) {
|
|
21849
|
+
const channel = value[name];
|
|
21850
|
+
const channelAt = childPath(path, name);
|
|
21851
|
+
if (typeof channel !== "number") {
|
|
21852
|
+
issues.push(issue(SchemaIssueCode.typeMismatch, channelAt, `expected a number, received ${typeof channel}.`));
|
|
21853
|
+
continue;
|
|
21854
|
+
}
|
|
21855
|
+
if (!Number.isFinite(channel)) {
|
|
21856
|
+
issues.push(issue(SchemaIssueCode.nonFiniteNumber, channelAt, `${String(channel)} cannot be written to JSON.`));
|
|
21857
|
+
continue;
|
|
21858
|
+
}
|
|
21859
|
+
if (bounds !== null && (channel < bounds[0] || channel > bounds[1])) issues.push(issue(SchemaIssueCode.outOfRange, channelAt, `${channel} is outside the ${bounds[0]}–${bounds[1]} range.`));
|
|
21860
|
+
}
|
|
21861
|
+
}
|
|
21862
|
+
/**
|
|
21863
|
+
* Checks one value against one field definition, appending to a collector.
|
|
21864
|
+
*
|
|
21865
|
+
* @param field - The field to check against.
|
|
21866
|
+
* @param value - The value to check.
|
|
21867
|
+
* @param path - The property path for reported issues.
|
|
21868
|
+
* @param issues - The collector to append to.
|
|
21869
|
+
*
|
|
21870
|
+
* @internal
|
|
21871
|
+
*/
|
|
21872
|
+
function validateInto(field, value, path, issues) {
|
|
21873
|
+
const { spec } = field;
|
|
21874
|
+
switch (spec.kind) {
|
|
21875
|
+
case "f32":
|
|
21876
|
+
case "f64":
|
|
21877
|
+
case "i32":
|
|
21878
|
+
case "u32":
|
|
21879
|
+
validateNumber(spec.kind, field.options, value, path, issues);
|
|
21880
|
+
return;
|
|
21881
|
+
case "bool":
|
|
21882
|
+
if (typeof value !== "boolean") issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a boolean, received ${typeof value}.`));
|
|
21883
|
+
return;
|
|
21884
|
+
case "str":
|
|
21885
|
+
if (typeof value !== "string") issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a string, received ${typeof value}.`));
|
|
21886
|
+
return;
|
|
21887
|
+
case "vec2":
|
|
21888
|
+
case "vec3":
|
|
21889
|
+
case "vec4":
|
|
21890
|
+
case "quat":
|
|
21891
|
+
validateChannels(VECTOR_COMPONENTS.slice(0, spec.components), null, spec.kind, value, path, issues);
|
|
21892
|
+
return;
|
|
21893
|
+
case "color":
|
|
21894
|
+
validateChannels(COLOR_CHANNELS, [0, 1], "color", value, path, issues);
|
|
21895
|
+
return;
|
|
21896
|
+
case "enum":
|
|
21897
|
+
if (typeof value !== "string") issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a string, received ${typeof value}.`));
|
|
21898
|
+
else if (!spec.values.includes(value)) issues.push(issue(SchemaIssueCode.outOfRange, path, `"${value}" is not one of [${spec.values.join(", ")}].`));
|
|
21899
|
+
return;
|
|
21900
|
+
case "entityRef":
|
|
21901
|
+
case "componentRef":
|
|
21902
|
+
if (value !== null && typeof value !== "object") issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a ${spec.kind} target or null, received ${typeof value}.`));
|
|
21903
|
+
return;
|
|
21904
|
+
case "asset":
|
|
21905
|
+
if (value === null) return;
|
|
21906
|
+
if (!isPlainObject(value)) {
|
|
21907
|
+
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a loaded asset handle or null.`));
|
|
21908
|
+
return;
|
|
21909
|
+
}
|
|
21910
|
+
if (typeof value["address"] !== "string") issues.push(issue(SchemaIssueCode.typeMismatch, childPath(path, "address"), `expected a string address.`));
|
|
21911
|
+
return;
|
|
21912
|
+
case "array":
|
|
21913
|
+
if (!isArray(value)) {
|
|
21914
|
+
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected an array, received ${typeof value}.`));
|
|
21915
|
+
return;
|
|
21916
|
+
}
|
|
21917
|
+
for (let index = 0; index < value.length; index += 1) validateInto(spec.item, value[index], indexPath(path, index), issues);
|
|
21918
|
+
return;
|
|
21919
|
+
case "record":
|
|
21920
|
+
if (!isPlainObject(value)) {
|
|
21921
|
+
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected an object, received ${typeof value}.`));
|
|
21922
|
+
return;
|
|
21923
|
+
}
|
|
21924
|
+
collectPropsIssues(spec.fields, value, path, issues);
|
|
21925
|
+
return;
|
|
21926
|
+
case "map":
|
|
21927
|
+
if (!isPlainObject(value)) {
|
|
21928
|
+
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected an object, received ${typeof value}.`));
|
|
21929
|
+
return;
|
|
21930
|
+
}
|
|
21931
|
+
for (const [key, entry] of Object.entries(value)) validateInto(spec.value, entry, indexPath(path, key), issues);
|
|
21932
|
+
return;
|
|
21933
|
+
case "optional":
|
|
21934
|
+
if (value !== null) validateInto(spec.inner, value, path, issues);
|
|
21935
|
+
return;
|
|
21936
|
+
case "layerMask":
|
|
21937
|
+
if (!isArray(value)) {
|
|
21938
|
+
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected an array of layer names.`));
|
|
21939
|
+
return;
|
|
21940
|
+
}
|
|
21941
|
+
for (let index = 0; index < value.length; index += 1) if (typeof value[index] !== "string") issues.push(issue(SchemaIssueCode.typeMismatch, indexPath(path, index), `expected a layer name string.`));
|
|
21942
|
+
return;
|
|
21943
|
+
case "curve": {
|
|
21944
|
+
if (!isPlainObject(value)) {
|
|
21945
|
+
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a curve object.`));
|
|
21946
|
+
return;
|
|
21947
|
+
}
|
|
21948
|
+
const keys = value["keys"];
|
|
21949
|
+
if (!isArray(keys)) {
|
|
21950
|
+
issues.push(issue(SchemaIssueCode.typeMismatch, childPath(path, "keys"), `expected an array of curve keys.`));
|
|
21951
|
+
return;
|
|
21952
|
+
}
|
|
21953
|
+
for (let index = 0; index < keys.length; index += 1) validateCurveKey(keys[index], indexPath(childPath(path, "keys"), index), issues);
|
|
21954
|
+
return;
|
|
21955
|
+
}
|
|
21956
|
+
case "custom": return;
|
|
21957
|
+
default: assertNever(spec, "schema field kind");
|
|
21958
|
+
}
|
|
21959
|
+
}
|
|
21960
|
+
/**
|
|
21961
|
+
* Checks one animation curve key.
|
|
21962
|
+
*
|
|
21963
|
+
* @param key - The candidate key.
|
|
21964
|
+
* @param path - The property path for reported issues.
|
|
21965
|
+
* @param issues - The collector to append to.
|
|
21966
|
+
*
|
|
21967
|
+
* @internal
|
|
21968
|
+
*/
|
|
21969
|
+
function validateCurveKey(key, path, issues) {
|
|
21970
|
+
if (!isArray(key) || key.length !== 4) {
|
|
21971
|
+
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected [time, value, inTangent, outTangent].`));
|
|
21972
|
+
return;
|
|
21973
|
+
}
|
|
21974
|
+
for (let index = 0; index < 4; index += 1) {
|
|
21975
|
+
const component = key[index];
|
|
21976
|
+
if (typeof component !== "number") issues.push(issue(SchemaIssueCode.typeMismatch, indexPath(path, index), `expected a number.`));
|
|
21977
|
+
else if (!Number.isFinite(component)) issues.push(issue(SchemaIssueCode.nonFiniteNumber, indexPath(path, index), `${String(component)} cannot be written to JSON.`));
|
|
21978
|
+
}
|
|
21979
|
+
}
|
|
21980
|
+
/**
|
|
21981
|
+
* Checks a bag of property values against a schema, appending to a collector.
|
|
21982
|
+
*
|
|
21983
|
+
* @param schema - The schema that says which names are legal and how they are typed.
|
|
21984
|
+
* @param props - The values to check.
|
|
21985
|
+
* @param path - The property path prefix for reported issues.
|
|
21986
|
+
* @param issues - The collector to append to.
|
|
21987
|
+
*
|
|
21988
|
+
* @internal
|
|
21989
|
+
*/
|
|
21990
|
+
function collectPropsIssues(schema, props, path, issues) {
|
|
21991
|
+
for (const name of Object.keys(props)) if (!Object.hasOwn(schema, name)) issues.push(issue(SchemaIssueCode.unknownField, childPath(path, name), `the schema declares no field "${name}".`));
|
|
21992
|
+
for (const [name, field] of Object.entries(schema)) {
|
|
21993
|
+
const value = props[name];
|
|
21994
|
+
if (value !== void 0) validateInto(field, value, childPath(path, name), issues);
|
|
21995
|
+
}
|
|
21996
|
+
}
|
|
21997
|
+
/**
|
|
21998
|
+
* Checks one value against one field definition. Nothing is thrown: the result is data, and the
|
|
21999
|
+
* caller decides whether a problem is a development-time error or a logged diagnostic
|
|
22000
|
+
* (`CONSTITUTION.md` §3.9).
|
|
22001
|
+
*
|
|
22002
|
+
* Checks performed are the value's type, finiteness for numbers, whole-number and 32-bit range for
|
|
22003
|
+
* `i32`/`u32`, `min`/`max` from the field options, enum membership, sRGB 0–1 range for colors, and
|
|
22004
|
+
* recursion into `array`, `record`, `map`, and `optional`.
|
|
22005
|
+
*
|
|
22006
|
+
* @param field - The field to check against.
|
|
22007
|
+
* @param value - The value to check.
|
|
22008
|
+
* @param path - A property path prefix used when reporting issues; defaults to the empty path.
|
|
22009
|
+
* @returns Every problem found, in discovery order; empty when the value is valid.
|
|
22010
|
+
*
|
|
22011
|
+
* @example
|
|
22012
|
+
* ```ts
|
|
22013
|
+
* validateValue(f32(0, { min: 0 }), -1);
|
|
22014
|
+
* // [{ path: "", code: "IGX-0606", message: "-1 is below the declared minimum 0." }]
|
|
22015
|
+
* ```
|
|
22016
|
+
*
|
|
22017
|
+
* @public
|
|
22018
|
+
*/
|
|
22019
|
+
function validateValue(field, value, path = "") {
|
|
22020
|
+
const issues = [];
|
|
22021
|
+
validateInto(field, value, path, issues);
|
|
22022
|
+
return issues;
|
|
22023
|
+
}
|
|
22024
|
+
/**
|
|
22025
|
+
* Checks a bag of property values against a schema. Names the schema does not declare are reported
|
|
22026
|
+
* as `IGX-0607`; names the caller omits are legal, because omitted props take schema defaults
|
|
22027
|
+
* (`docs/architecture/06-serialization-and-scene-format.md` §2).
|
|
22028
|
+
*
|
|
22029
|
+
* @param schema - The schema to check against.
|
|
22030
|
+
* @param props - The values to check, keyed by field name.
|
|
22031
|
+
* @param path - A property path prefix used when reporting issues; defaults to the empty path.
|
|
22032
|
+
* @returns Every problem found, in discovery order; empty when the props are valid.
|
|
22033
|
+
*
|
|
22034
|
+
* @public
|
|
22035
|
+
*/
|
|
22036
|
+
function validateProps(schema, props, path = "") {
|
|
22037
|
+
const issues = [];
|
|
22038
|
+
collectPropsIssues(schema, props, path, issues);
|
|
22039
|
+
return issues;
|
|
22040
|
+
}
|
|
22041
|
+
//#endregion
|
|
22042
|
+
//#region src/settings/settings-store.ts
|
|
22043
|
+
/**
|
|
22044
|
+
* Reports whether a value is a plain object rather than an array, a primitive, or `null`.
|
|
22045
|
+
*
|
|
22046
|
+
* @param value - The candidate.
|
|
22047
|
+
* @returns `true` when the value can be read as a bag of named props.
|
|
22048
|
+
*/
|
|
22049
|
+
function isPropertyBag(value) {
|
|
22050
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22051
|
+
}
|
|
22052
|
+
/**
|
|
22053
|
+
* The per-app settings table.
|
|
22054
|
+
*
|
|
22055
|
+
* @internal
|
|
22056
|
+
*/
|
|
22057
|
+
var SettingsStore = class {
|
|
22058
|
+
#sections = /* @__PURE__ */ new Map();
|
|
22059
|
+
#input;
|
|
22060
|
+
#mode;
|
|
22061
|
+
#log;
|
|
22062
|
+
#isFrozen = false;
|
|
22063
|
+
/**
|
|
22064
|
+
* Creates the settings table of one app.
|
|
22065
|
+
*
|
|
22066
|
+
* @param input - What the project supplied, keyed by section name.
|
|
22067
|
+
* @param mode - `"development"` throws on an invalid or unknown section; `"production"` logs and
|
|
22068
|
+
* falls back to the registered defaults (§5).
|
|
22069
|
+
* @param log - Where the production-mode complaints go.
|
|
22070
|
+
*/
|
|
22071
|
+
constructor(input, mode, log) {
|
|
22072
|
+
this.#input = input;
|
|
22073
|
+
this.#mode = mode;
|
|
22074
|
+
this.#log = log;
|
|
22075
|
+
}
|
|
22076
|
+
/**
|
|
22077
|
+
* The core `layers` section.
|
|
22078
|
+
*
|
|
22079
|
+
* @returns The project's layer names.
|
|
22080
|
+
*/
|
|
22081
|
+
get layers() {
|
|
22082
|
+
return this.section("layers");
|
|
22083
|
+
}
|
|
22084
|
+
/**
|
|
22085
|
+
* The core `sortingLayers` section.
|
|
22086
|
+
*
|
|
22087
|
+
* @returns The project's sorting-layer names.
|
|
22088
|
+
*/
|
|
22089
|
+
get sortingLayers() {
|
|
22090
|
+
return this.section("sortingLayers");
|
|
22091
|
+
}
|
|
22092
|
+
/**
|
|
22093
|
+
* The core `time` section.
|
|
22094
|
+
*
|
|
22095
|
+
* @returns The initial clock settings.
|
|
22096
|
+
*/
|
|
22097
|
+
get time() {
|
|
22098
|
+
return this.section("time");
|
|
22099
|
+
}
|
|
22100
|
+
/**
|
|
22101
|
+
* Reads a resolved section.
|
|
22102
|
+
*
|
|
22103
|
+
* @typeParam S - The section's resolved shape, as its owner declared it.
|
|
22104
|
+
* @param name - The section name.
|
|
22105
|
+
* @returns The frozen resolved section.
|
|
22106
|
+
* @throws IgnifxError with code `IGX-0407` when the section was never registered.
|
|
22107
|
+
*/
|
|
22108
|
+
section(name) {
|
|
22109
|
+
const section = this.#sections.get(name);
|
|
22110
|
+
if (section === void 0) throw new IgnifxError(CoreErrorCode.unknownSettingsSection, `${name} is not a registered settings section.`, {
|
|
22111
|
+
context: { section: name },
|
|
22112
|
+
hint: "A section exists once the extension that owns it has run its register() hook."
|
|
22113
|
+
});
|
|
22114
|
+
return section.value;
|
|
22115
|
+
}
|
|
22116
|
+
/**
|
|
22117
|
+
* Registers and immediately resolves a section, so `ctx.settings(name)` works inside the same
|
|
22118
|
+
* `register` call that declared it (`04-extensions.md` §1).
|
|
22119
|
+
*
|
|
22120
|
+
* @param name - The section name as it appears in `ignifx.config.ts`.
|
|
22121
|
+
* @param schema - The schema the project's values are validated against.
|
|
22122
|
+
* @param defaults - The values used for everything the project omits, as a bag of named props.
|
|
22123
|
+
* @param owner - The extension registering the section, named in diagnostics.
|
|
22124
|
+
* @throws IgnifxError with code `IGX-0408` in development when the project's values do not
|
|
22125
|
+
* validate, and with code `IGX-0607` when a field is named after an `Object.prototype` member.
|
|
22126
|
+
*/
|
|
22127
|
+
register(name, schema, defaults, owner) {
|
|
22128
|
+
assertNoInheritedFieldNames(schema, "settings");
|
|
22129
|
+
const base = isPropertyBag(defaults) ? defaults : createDefaults(schema);
|
|
22130
|
+
const value = this.#resolve(name, schema, base);
|
|
22131
|
+
this.#sections.set(name, {
|
|
22132
|
+
schema,
|
|
22133
|
+
owner,
|
|
22134
|
+
defaults: base,
|
|
22135
|
+
value: Object.freeze(value)
|
|
22136
|
+
});
|
|
22137
|
+
}
|
|
22138
|
+
/**
|
|
22139
|
+
* What the project itself wrote for a section, before the defaults were merged in.
|
|
22140
|
+
*
|
|
22141
|
+
* @remarks
|
|
22142
|
+
* The resolved section cannot tell a field the project wrote from one it left at its default;
|
|
22143
|
+
* `rendering.quality` needs that, because a field the project wrote wins over its tier.
|
|
22144
|
+
*
|
|
22145
|
+
* @param name - The section name.
|
|
22146
|
+
* @returns The project's raw value, or `undefined` when it declared none.
|
|
22147
|
+
*/
|
|
22148
|
+
declared(name) {
|
|
22149
|
+
return this.#input[name];
|
|
22150
|
+
}
|
|
22151
|
+
/**
|
|
22152
|
+
* Every registered section, in registration order, for `describeSettings`.
|
|
22153
|
+
*
|
|
22154
|
+
* @returns The sections, keyed by name.
|
|
22155
|
+
*/
|
|
22156
|
+
registrations() {
|
|
22157
|
+
return this.#sections;
|
|
22158
|
+
}
|
|
22159
|
+
/**
|
|
22160
|
+
* Reports whether a section has been registered.
|
|
22161
|
+
*
|
|
22162
|
+
* @param name - The section name.
|
|
22163
|
+
* @returns `true` when an extension owns the section.
|
|
22164
|
+
*/
|
|
22165
|
+
has(name) {
|
|
22166
|
+
return this.#sections.has(name);
|
|
22167
|
+
}
|
|
22168
|
+
/**
|
|
22169
|
+
* Checks that every section the project supplied is owned by some extension (§5) and closes the
|
|
22170
|
+
* table to further registration.
|
|
22171
|
+
*
|
|
22172
|
+
* @throws IgnifxError with code `IGX-0407` in development when the project declares a section no
|
|
22173
|
+
* extension registered.
|
|
22174
|
+
*/
|
|
22175
|
+
freeze() {
|
|
22176
|
+
for (const name of Object.keys(this.#input)) {
|
|
22177
|
+
if (this.#sections.has(name)) continue;
|
|
22178
|
+
if (this.#mode === "development") throw new IgnifxError(CoreErrorCode.unknownSettingsSection, `${name} is not a registered settings section.`, {
|
|
22179
|
+
context: { section: name },
|
|
22180
|
+
hint: "Register the extension that owns the section, or remove it from the project settings."
|
|
22181
|
+
});
|
|
22182
|
+
this.#log.warn(`Ignoring the unknown settings section ${name}.`);
|
|
22183
|
+
}
|
|
22184
|
+
this.#isFrozen = true;
|
|
22185
|
+
}
|
|
22186
|
+
/**
|
|
22187
|
+
* Whether {@link SettingsStore.freeze} has run.
|
|
22188
|
+
*
|
|
22189
|
+
* @returns `true` once the table is closed.
|
|
22190
|
+
*/
|
|
22191
|
+
get isFrozen() {
|
|
22192
|
+
return this.#isFrozen;
|
|
22193
|
+
}
|
|
22194
|
+
/**
|
|
22195
|
+
* Merges the project's values for one section over its defaults, validating them first.
|
|
22196
|
+
*
|
|
22197
|
+
* @param name - The section name.
|
|
22198
|
+
* @param schema - The owner's schema.
|
|
22199
|
+
* @param defaults - The owner's defaults.
|
|
22200
|
+
* @returns The resolved section.
|
|
22201
|
+
* @throws IgnifxError with code `IGX-0408` in development when validation fails.
|
|
22202
|
+
*/
|
|
22203
|
+
#resolve(name, schema, defaults) {
|
|
22204
|
+
const provided = this.#input[name];
|
|
22205
|
+
const resolved = { ...defaults };
|
|
22206
|
+
if (provided === void 0) return resolved;
|
|
22207
|
+
const props = this.#toPropertyBag(schema, provided);
|
|
22208
|
+
if (props === null) return this.#reject(name, `${name} settings must be an object.`, resolved);
|
|
22209
|
+
const issues = validateProps(schema, props, name);
|
|
22210
|
+
if (issues.length > 0) {
|
|
22211
|
+
const detail = issues.map((entry) => `${entry.path}: ${entry.message}`).join("; ");
|
|
22212
|
+
return this.#reject(name, detail, resolved);
|
|
22213
|
+
}
|
|
22214
|
+
return Object.assign(resolved, props);
|
|
22215
|
+
}
|
|
22216
|
+
/**
|
|
22217
|
+
* Applies the single-field shorthand: a section whose schema declares exactly one field may be
|
|
22218
|
+
* written as that field's value.
|
|
22219
|
+
*
|
|
22220
|
+
* @param schema - The owner's schema.
|
|
22221
|
+
* @param provided - What the project supplied.
|
|
22222
|
+
* @returns A bag of named props, or `null` when the value cannot be read as one.
|
|
22223
|
+
*/
|
|
22224
|
+
#toPropertyBag(schema, provided) {
|
|
22225
|
+
if (isPropertyBag(provided)) return provided;
|
|
22226
|
+
const names = Object.keys(schema);
|
|
22227
|
+
const only = names[0];
|
|
22228
|
+
if (names.length !== 1 || only === void 0) return null;
|
|
22229
|
+
return { [only]: provided };
|
|
22230
|
+
}
|
|
22231
|
+
/**
|
|
22232
|
+
* Handles an invalid section: a throw in development, a log line and the defaults in production
|
|
22233
|
+
* (§5).
|
|
22234
|
+
*
|
|
22235
|
+
* @param name - The section name.
|
|
22236
|
+
* @param detail - What was wrong.
|
|
22237
|
+
* @param defaults - The values to fall back to.
|
|
22238
|
+
* @returns The defaults, in production.
|
|
22239
|
+
* @throws IgnifxError with code `IGX-0408` in development.
|
|
22240
|
+
*/
|
|
22241
|
+
#reject(name, detail, defaults) {
|
|
22242
|
+
if (this.#mode === "development") throw new IgnifxError(CoreErrorCode.invalidSettings, `The ${name} settings section is invalid: ${detail}`, {
|
|
22243
|
+
context: {
|
|
22244
|
+
section: name,
|
|
22245
|
+
issues: detail
|
|
22246
|
+
},
|
|
22247
|
+
hint: "Check the section against the schema the owning extension registered."
|
|
22248
|
+
});
|
|
22249
|
+
this.#log.warn("The {section} settings section is invalid and was replaced by its defaults: {issues}", name, detail);
|
|
22250
|
+
return defaults;
|
|
22251
|
+
}
|
|
22252
|
+
};
|
|
22253
|
+
//#endregion
|
|
20802
22254
|
//#region src/math/quat.ts
|
|
20803
22255
|
/**
|
|
20804
22256
|
* A rotation, stored as a unit quaternion. Quaternions are how ignifx stores every rotation:
|
|
@@ -23480,13 +24932,17 @@ function registerCore(ctx) {
|
|
|
23480
24932
|
* @remarks
|
|
23481
24933
|
* The order matters in one place: the section is registered *first*, because `ctx.registerSettings`
|
|
23482
24934
|
* resolves it immediately and {@link RendererImpl} is constructed from the resolved value inside
|
|
23483
|
-
* this same `register` call. Everything after that only needs the service to exist.
|
|
24935
|
+
* this same `register` call. Everything after that only needs the service to exist. The renderer
|
|
24936
|
+
* gets the section with its `quality` tier applied, so `renderer.settings` is what actually runs.
|
|
23484
24937
|
*
|
|
23485
24938
|
* @param ctx - The registration surface.
|
|
23486
24939
|
*/
|
|
23487
24940
|
function registerRendering(ctx) {
|
|
23488
24941
|
ctx.registerSettings(RENDERING_SETTINGS_SECTION, renderingSettingsSchema(), defaultRenderingSettings());
|
|
23489
|
-
const
|
|
24942
|
+
const store = ctx.app.settings;
|
|
24943
|
+
const declared = store instanceof SettingsStore ? store.declared(RENDERING_SETTINGS_SECTION) : void 0;
|
|
24944
|
+
const settings = applyRenderingQuality(ctx.settings(RENDERING_SETTINGS_SECTION), declared);
|
|
24945
|
+
const renderer = new RendererImpl(ctx.app, settings);
|
|
23490
24946
|
ctx.registerService(RendererService, renderer);
|
|
23491
24947
|
ctx.registerComponents([
|
|
23492
24948
|
Camera,
|
|
@@ -25661,6 +27117,8 @@ function createHeadlessEngine() {
|
|
|
25661
27117
|
* @param features.postProcessing - `true` to render into an offscreen target and composite it.
|
|
25662
27118
|
* @param features.hdr - `true` to render into an `rgba16float` target and tone map it in a final
|
|
25663
27119
|
* pass (`./gpu/hdr-output.ts`, its own chunk, loaded only then). Implies the offscreen path.
|
|
27120
|
+
* @param features.autoExposure - With `hdr`, the auto exposure knobs (`./gpu/auto-exposure.ts`, its
|
|
27121
|
+
* own chunk, loaded only then); `null` or absent leaves it off.
|
|
25664
27122
|
* @returns The engine, the scene, and the presenter when there is one.
|
|
25665
27123
|
* @throws IgnifxError with code `IGX-0701` when WebGPU is unavailable.
|
|
25666
27124
|
*
|
|
@@ -25673,8 +27131,11 @@ async function createRenderEngine(canvas, options, features) {
|
|
|
25673
27131
|
const offscreen = hdr || features?.postProcessing === true;
|
|
25674
27132
|
const scene = createRenderScene(engine, { offscreen });
|
|
25675
27133
|
let presenter = null;
|
|
25676
|
-
if (hdr)
|
|
25677
|
-
|
|
27134
|
+
if (hdr) {
|
|
27135
|
+
const knobs = features.autoExposure ?? null;
|
|
27136
|
+
const exposure = knobs === null ? null : await import("./auto-exposure-uzPn0beO.js");
|
|
27137
|
+
presenter = (await import("./hdr-output-BrUvpAsE.js")).installHdrRenderPath(engine, scene, exposure === null || knobs === null ? void 0 : (hdrTexture) => exposure.installAutoExposure(engine, scene, hdrTexture, knobs));
|
|
27138
|
+
} else if (offscreen) presenter = installOffscreenRenderPath(engine, scene);
|
|
25678
27139
|
return {
|
|
25679
27140
|
engine,
|
|
25680
27141
|
scene,
|
|
@@ -26817,459 +28278,6 @@ function snap(accumulator, step) {
|
|
|
26817
28278
|
return accumulator;
|
|
26818
28279
|
}
|
|
26819
28280
|
//#endregion
|
|
26820
|
-
//#region src/schema/validate.ts
|
|
26821
|
-
/**
|
|
26822
|
-
* The inclusive bounds of a signed 32-bit integer.
|
|
26823
|
-
*
|
|
26824
|
-
* @internal
|
|
26825
|
-
*/
|
|
26826
|
-
const I32_RANGE = [-2147483648, 2147483647];
|
|
26827
|
-
/**
|
|
26828
|
-
* The inclusive bounds of an unsigned 32-bit integer.
|
|
26829
|
-
*
|
|
26830
|
-
* @internal
|
|
26831
|
-
*/
|
|
26832
|
-
const U32_RANGE = [0, 4294967295];
|
|
26833
|
-
/**
|
|
26834
|
-
* Checks a numeric value against its kind's integer rules and the field's `min`/`max` options.
|
|
26835
|
-
*
|
|
26836
|
-
* @param kind - The numeric field kind.
|
|
26837
|
-
* @param options - The field's options.
|
|
26838
|
-
* @param value - The value to check.
|
|
26839
|
-
* @param path - The property path for reported issues.
|
|
26840
|
-
* @param issues - The collector to append to.
|
|
26841
|
-
*
|
|
26842
|
-
* @internal
|
|
26843
|
-
*/
|
|
26844
|
-
function validateNumber(kind, options, value, path, issues) {
|
|
26845
|
-
if (typeof value !== "number") {
|
|
26846
|
-
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a ${kind} number, received ${typeof value}.`));
|
|
26847
|
-
return;
|
|
26848
|
-
}
|
|
26849
|
-
if (!Number.isFinite(value)) {
|
|
26850
|
-
issues.push(issue(SchemaIssueCode.nonFiniteNumber, path, `${String(value)} cannot be written to JSON.`));
|
|
26851
|
-
return;
|
|
26852
|
-
}
|
|
26853
|
-
if (kind === "i32" || kind === "u32") {
|
|
26854
|
-
if (Number.isInteger(value)) {
|
|
26855
|
-
const [low, high] = kind === "u32" ? U32_RANGE : I32_RANGE;
|
|
26856
|
-
if (value < low || value > high) issues.push(issue(SchemaIssueCode.outOfRange, path, `${value} is outside the ${kind} range.`));
|
|
26857
|
-
} else issues.push(issue(SchemaIssueCode.outOfRange, path, `${kind} requires a whole number, received ${value}.`));
|
|
26858
|
-
}
|
|
26859
|
-
const { min, max } = options;
|
|
26860
|
-
if (min !== void 0 && value < min) issues.push(issue(SchemaIssueCode.outOfRange, path, `${value} is below the declared minimum ${min}.`));
|
|
26861
|
-
if (max !== void 0 && value > max) issues.push(issue(SchemaIssueCode.outOfRange, path, `${value} is above the declared maximum ${max}.`));
|
|
26862
|
-
}
|
|
26863
|
-
/**
|
|
26864
|
-
* Checks that every named channel of an object value is a finite number, optionally within bounds.
|
|
26865
|
-
*
|
|
26866
|
-
* @param names - The channel names to require.
|
|
26867
|
-
* @param bounds - Inclusive `[low, high]` bounds each channel must fall in, or `null` for none.
|
|
26868
|
-
* @param label - How the value is named in messages.
|
|
26869
|
-
* @param value - The value to check.
|
|
26870
|
-
* @param path - The property path for reported issues.
|
|
26871
|
-
* @param issues - The collector to append to.
|
|
26872
|
-
*
|
|
26873
|
-
* @internal
|
|
26874
|
-
*/
|
|
26875
|
-
function validateChannels(names, bounds, label, value, path, issues) {
|
|
26876
|
-
if (!isPlainObject(value)) {
|
|
26877
|
-
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a ${label} object, received ${typeof value}.`));
|
|
26878
|
-
return;
|
|
26879
|
-
}
|
|
26880
|
-
for (const name of names) {
|
|
26881
|
-
const channel = value[name];
|
|
26882
|
-
const channelAt = childPath(path, name);
|
|
26883
|
-
if (typeof channel !== "number") {
|
|
26884
|
-
issues.push(issue(SchemaIssueCode.typeMismatch, channelAt, `expected a number, received ${typeof channel}.`));
|
|
26885
|
-
continue;
|
|
26886
|
-
}
|
|
26887
|
-
if (!Number.isFinite(channel)) {
|
|
26888
|
-
issues.push(issue(SchemaIssueCode.nonFiniteNumber, channelAt, `${String(channel)} cannot be written to JSON.`));
|
|
26889
|
-
continue;
|
|
26890
|
-
}
|
|
26891
|
-
if (bounds !== null && (channel < bounds[0] || channel > bounds[1])) issues.push(issue(SchemaIssueCode.outOfRange, channelAt, `${channel} is outside the ${bounds[0]}–${bounds[1]} range.`));
|
|
26892
|
-
}
|
|
26893
|
-
}
|
|
26894
|
-
/**
|
|
26895
|
-
* Checks one value against one field definition, appending to a collector.
|
|
26896
|
-
*
|
|
26897
|
-
* @param field - The field to check against.
|
|
26898
|
-
* @param value - The value to check.
|
|
26899
|
-
* @param path - The property path for reported issues.
|
|
26900
|
-
* @param issues - The collector to append to.
|
|
26901
|
-
*
|
|
26902
|
-
* @internal
|
|
26903
|
-
*/
|
|
26904
|
-
function validateInto(field, value, path, issues) {
|
|
26905
|
-
const { spec } = field;
|
|
26906
|
-
switch (spec.kind) {
|
|
26907
|
-
case "f32":
|
|
26908
|
-
case "f64":
|
|
26909
|
-
case "i32":
|
|
26910
|
-
case "u32":
|
|
26911
|
-
validateNumber(spec.kind, field.options, value, path, issues);
|
|
26912
|
-
return;
|
|
26913
|
-
case "bool":
|
|
26914
|
-
if (typeof value !== "boolean") issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a boolean, received ${typeof value}.`));
|
|
26915
|
-
return;
|
|
26916
|
-
case "str":
|
|
26917
|
-
if (typeof value !== "string") issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a string, received ${typeof value}.`));
|
|
26918
|
-
return;
|
|
26919
|
-
case "vec2":
|
|
26920
|
-
case "vec3":
|
|
26921
|
-
case "vec4":
|
|
26922
|
-
case "quat":
|
|
26923
|
-
validateChannels(VECTOR_COMPONENTS.slice(0, spec.components), null, spec.kind, value, path, issues);
|
|
26924
|
-
return;
|
|
26925
|
-
case "color":
|
|
26926
|
-
validateChannels(COLOR_CHANNELS, [0, 1], "color", value, path, issues);
|
|
26927
|
-
return;
|
|
26928
|
-
case "enum":
|
|
26929
|
-
if (typeof value !== "string") issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a string, received ${typeof value}.`));
|
|
26930
|
-
else if (!spec.values.includes(value)) issues.push(issue(SchemaIssueCode.outOfRange, path, `"${value}" is not one of [${spec.values.join(", ")}].`));
|
|
26931
|
-
return;
|
|
26932
|
-
case "entityRef":
|
|
26933
|
-
case "componentRef":
|
|
26934
|
-
if (value !== null && typeof value !== "object") issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a ${spec.kind} target or null, received ${typeof value}.`));
|
|
26935
|
-
return;
|
|
26936
|
-
case "asset":
|
|
26937
|
-
if (value === null) return;
|
|
26938
|
-
if (!isPlainObject(value)) {
|
|
26939
|
-
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a loaded asset handle or null.`));
|
|
26940
|
-
return;
|
|
26941
|
-
}
|
|
26942
|
-
if (typeof value["address"] !== "string") issues.push(issue(SchemaIssueCode.typeMismatch, childPath(path, "address"), `expected a string address.`));
|
|
26943
|
-
return;
|
|
26944
|
-
case "array":
|
|
26945
|
-
if (!isArray(value)) {
|
|
26946
|
-
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected an array, received ${typeof value}.`));
|
|
26947
|
-
return;
|
|
26948
|
-
}
|
|
26949
|
-
for (let index = 0; index < value.length; index += 1) validateInto(spec.item, value[index], indexPath(path, index), issues);
|
|
26950
|
-
return;
|
|
26951
|
-
case "record":
|
|
26952
|
-
if (!isPlainObject(value)) {
|
|
26953
|
-
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected an object, received ${typeof value}.`));
|
|
26954
|
-
return;
|
|
26955
|
-
}
|
|
26956
|
-
collectPropsIssues(spec.fields, value, path, issues);
|
|
26957
|
-
return;
|
|
26958
|
-
case "map":
|
|
26959
|
-
if (!isPlainObject(value)) {
|
|
26960
|
-
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected an object, received ${typeof value}.`));
|
|
26961
|
-
return;
|
|
26962
|
-
}
|
|
26963
|
-
for (const [key, entry] of Object.entries(value)) validateInto(spec.value, entry, indexPath(path, key), issues);
|
|
26964
|
-
return;
|
|
26965
|
-
case "optional":
|
|
26966
|
-
if (value !== null) validateInto(spec.inner, value, path, issues);
|
|
26967
|
-
return;
|
|
26968
|
-
case "layerMask":
|
|
26969
|
-
if (!isArray(value)) {
|
|
26970
|
-
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected an array of layer names.`));
|
|
26971
|
-
return;
|
|
26972
|
-
}
|
|
26973
|
-
for (let index = 0; index < value.length; index += 1) if (typeof value[index] !== "string") issues.push(issue(SchemaIssueCode.typeMismatch, indexPath(path, index), `expected a layer name string.`));
|
|
26974
|
-
return;
|
|
26975
|
-
case "curve": {
|
|
26976
|
-
if (!isPlainObject(value)) {
|
|
26977
|
-
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected a curve object.`));
|
|
26978
|
-
return;
|
|
26979
|
-
}
|
|
26980
|
-
const keys = value["keys"];
|
|
26981
|
-
if (!isArray(keys)) {
|
|
26982
|
-
issues.push(issue(SchemaIssueCode.typeMismatch, childPath(path, "keys"), `expected an array of curve keys.`));
|
|
26983
|
-
return;
|
|
26984
|
-
}
|
|
26985
|
-
for (let index = 0; index < keys.length; index += 1) validateCurveKey(keys[index], indexPath(childPath(path, "keys"), index), issues);
|
|
26986
|
-
return;
|
|
26987
|
-
}
|
|
26988
|
-
case "custom": return;
|
|
26989
|
-
default: assertNever(spec, "schema field kind");
|
|
26990
|
-
}
|
|
26991
|
-
}
|
|
26992
|
-
/**
|
|
26993
|
-
* Checks one animation curve key.
|
|
26994
|
-
*
|
|
26995
|
-
* @param key - The candidate key.
|
|
26996
|
-
* @param path - The property path for reported issues.
|
|
26997
|
-
* @param issues - The collector to append to.
|
|
26998
|
-
*
|
|
26999
|
-
* @internal
|
|
27000
|
-
*/
|
|
27001
|
-
function validateCurveKey(key, path, issues) {
|
|
27002
|
-
if (!isArray(key) || key.length !== 4) {
|
|
27003
|
-
issues.push(issue(SchemaIssueCode.typeMismatch, path, `expected [time, value, inTangent, outTangent].`));
|
|
27004
|
-
return;
|
|
27005
|
-
}
|
|
27006
|
-
for (let index = 0; index < 4; index += 1) {
|
|
27007
|
-
const component = key[index];
|
|
27008
|
-
if (typeof component !== "number") issues.push(issue(SchemaIssueCode.typeMismatch, indexPath(path, index), `expected a number.`));
|
|
27009
|
-
else if (!Number.isFinite(component)) issues.push(issue(SchemaIssueCode.nonFiniteNumber, indexPath(path, index), `${String(component)} cannot be written to JSON.`));
|
|
27010
|
-
}
|
|
27011
|
-
}
|
|
27012
|
-
/**
|
|
27013
|
-
* Checks a bag of property values against a schema, appending to a collector.
|
|
27014
|
-
*
|
|
27015
|
-
* @param schema - The schema that says which names are legal and how they are typed.
|
|
27016
|
-
* @param props - The values to check.
|
|
27017
|
-
* @param path - The property path prefix for reported issues.
|
|
27018
|
-
* @param issues - The collector to append to.
|
|
27019
|
-
*
|
|
27020
|
-
* @internal
|
|
27021
|
-
*/
|
|
27022
|
-
function collectPropsIssues(schema, props, path, issues) {
|
|
27023
|
-
for (const name of Object.keys(props)) if (!Object.hasOwn(schema, name)) issues.push(issue(SchemaIssueCode.unknownField, childPath(path, name), `the schema declares no field "${name}".`));
|
|
27024
|
-
for (const [name, field] of Object.entries(schema)) {
|
|
27025
|
-
const value = props[name];
|
|
27026
|
-
if (value !== void 0) validateInto(field, value, childPath(path, name), issues);
|
|
27027
|
-
}
|
|
27028
|
-
}
|
|
27029
|
-
/**
|
|
27030
|
-
* Checks one value against one field definition. Nothing is thrown: the result is data, and the
|
|
27031
|
-
* caller decides whether a problem is a development-time error or a logged diagnostic
|
|
27032
|
-
* (`CONSTITUTION.md` §3.9).
|
|
27033
|
-
*
|
|
27034
|
-
* Checks performed are the value's type, finiteness for numbers, whole-number and 32-bit range for
|
|
27035
|
-
* `i32`/`u32`, `min`/`max` from the field options, enum membership, sRGB 0–1 range for colors, and
|
|
27036
|
-
* recursion into `array`, `record`, `map`, and `optional`.
|
|
27037
|
-
*
|
|
27038
|
-
* @param field - The field to check against.
|
|
27039
|
-
* @param value - The value to check.
|
|
27040
|
-
* @param path - A property path prefix used when reporting issues; defaults to the empty path.
|
|
27041
|
-
* @returns Every problem found, in discovery order; empty when the value is valid.
|
|
27042
|
-
*
|
|
27043
|
-
* @example
|
|
27044
|
-
* ```ts
|
|
27045
|
-
* validateValue(f32(0, { min: 0 }), -1);
|
|
27046
|
-
* // [{ path: "", code: "IGX-0606", message: "-1 is below the declared minimum 0." }]
|
|
27047
|
-
* ```
|
|
27048
|
-
*
|
|
27049
|
-
* @public
|
|
27050
|
-
*/
|
|
27051
|
-
function validateValue(field, value, path = "") {
|
|
27052
|
-
const issues = [];
|
|
27053
|
-
validateInto(field, value, path, issues);
|
|
27054
|
-
return issues;
|
|
27055
|
-
}
|
|
27056
|
-
/**
|
|
27057
|
-
* Checks a bag of property values against a schema. Names the schema does not declare are reported
|
|
27058
|
-
* as `IGX-0607`; names the caller omits are legal, because omitted props take schema defaults
|
|
27059
|
-
* (`docs/architecture/06-serialization-and-scene-format.md` §2).
|
|
27060
|
-
*
|
|
27061
|
-
* @param schema - The schema to check against.
|
|
27062
|
-
* @param props - The values to check, keyed by field name.
|
|
27063
|
-
* @param path - A property path prefix used when reporting issues; defaults to the empty path.
|
|
27064
|
-
* @returns Every problem found, in discovery order; empty when the props are valid.
|
|
27065
|
-
*
|
|
27066
|
-
* @public
|
|
27067
|
-
*/
|
|
27068
|
-
function validateProps(schema, props, path = "") {
|
|
27069
|
-
const issues = [];
|
|
27070
|
-
collectPropsIssues(schema, props, path, issues);
|
|
27071
|
-
return issues;
|
|
27072
|
-
}
|
|
27073
|
-
//#endregion
|
|
27074
|
-
//#region src/settings/settings-store.ts
|
|
27075
|
-
/**
|
|
27076
|
-
* Reports whether a value is a plain object rather than an array, a primitive, or `null`.
|
|
27077
|
-
*
|
|
27078
|
-
* @param value - The candidate.
|
|
27079
|
-
* @returns `true` when the value can be read as a bag of named props.
|
|
27080
|
-
*/
|
|
27081
|
-
function isPropertyBag(value) {
|
|
27082
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27083
|
-
}
|
|
27084
|
-
/**
|
|
27085
|
-
* The per-app settings table.
|
|
27086
|
-
*
|
|
27087
|
-
* @internal
|
|
27088
|
-
*/
|
|
27089
|
-
var SettingsStore = class {
|
|
27090
|
-
#sections = /* @__PURE__ */ new Map();
|
|
27091
|
-
#input;
|
|
27092
|
-
#mode;
|
|
27093
|
-
#log;
|
|
27094
|
-
#isFrozen = false;
|
|
27095
|
-
/**
|
|
27096
|
-
* Creates the settings table of one app.
|
|
27097
|
-
*
|
|
27098
|
-
* @param input - What the project supplied, keyed by section name.
|
|
27099
|
-
* @param mode - `"development"` throws on an invalid or unknown section; `"production"` logs and
|
|
27100
|
-
* falls back to the registered defaults (§5).
|
|
27101
|
-
* @param log - Where the production-mode complaints go.
|
|
27102
|
-
*/
|
|
27103
|
-
constructor(input, mode, log) {
|
|
27104
|
-
this.#input = input;
|
|
27105
|
-
this.#mode = mode;
|
|
27106
|
-
this.#log = log;
|
|
27107
|
-
}
|
|
27108
|
-
/**
|
|
27109
|
-
* The core `layers` section.
|
|
27110
|
-
*
|
|
27111
|
-
* @returns The project's layer names.
|
|
27112
|
-
*/
|
|
27113
|
-
get layers() {
|
|
27114
|
-
return this.section("layers");
|
|
27115
|
-
}
|
|
27116
|
-
/**
|
|
27117
|
-
* The core `sortingLayers` section.
|
|
27118
|
-
*
|
|
27119
|
-
* @returns The project's sorting-layer names.
|
|
27120
|
-
*/
|
|
27121
|
-
get sortingLayers() {
|
|
27122
|
-
return this.section("sortingLayers");
|
|
27123
|
-
}
|
|
27124
|
-
/**
|
|
27125
|
-
* The core `time` section.
|
|
27126
|
-
*
|
|
27127
|
-
* @returns The initial clock settings.
|
|
27128
|
-
*/
|
|
27129
|
-
get time() {
|
|
27130
|
-
return this.section("time");
|
|
27131
|
-
}
|
|
27132
|
-
/**
|
|
27133
|
-
* Reads a resolved section.
|
|
27134
|
-
*
|
|
27135
|
-
* @typeParam S - The section's resolved shape, as its owner declared it.
|
|
27136
|
-
* @param name - The section name.
|
|
27137
|
-
* @returns The frozen resolved section.
|
|
27138
|
-
* @throws IgnifxError with code `IGX-0407` when the section was never registered.
|
|
27139
|
-
*/
|
|
27140
|
-
section(name) {
|
|
27141
|
-
const section = this.#sections.get(name);
|
|
27142
|
-
if (section === void 0) throw new IgnifxError(CoreErrorCode.unknownSettingsSection, `${name} is not a registered settings section.`, {
|
|
27143
|
-
context: { section: name },
|
|
27144
|
-
hint: "A section exists once the extension that owns it has run its register() hook."
|
|
27145
|
-
});
|
|
27146
|
-
return section.value;
|
|
27147
|
-
}
|
|
27148
|
-
/**
|
|
27149
|
-
* Registers and immediately resolves a section, so `ctx.settings(name)` works inside the same
|
|
27150
|
-
* `register` call that declared it (`04-extensions.md` §1).
|
|
27151
|
-
*
|
|
27152
|
-
* @param name - The section name as it appears in `ignifx.config.ts`.
|
|
27153
|
-
* @param schema - The schema the project's values are validated against.
|
|
27154
|
-
* @param defaults - The values used for everything the project omits, as a bag of named props.
|
|
27155
|
-
* @param owner - The extension registering the section, named in diagnostics.
|
|
27156
|
-
* @throws IgnifxError with code `IGX-0408` in development when the project's values do not
|
|
27157
|
-
* validate, and with code `IGX-0607` when a field is named after an `Object.prototype` member.
|
|
27158
|
-
*/
|
|
27159
|
-
register(name, schema, defaults, owner) {
|
|
27160
|
-
assertNoInheritedFieldNames(schema, "settings");
|
|
27161
|
-
const base = isPropertyBag(defaults) ? defaults : createDefaults(schema);
|
|
27162
|
-
const value = this.#resolve(name, schema, base);
|
|
27163
|
-
this.#sections.set(name, {
|
|
27164
|
-
schema,
|
|
27165
|
-
owner,
|
|
27166
|
-
defaults: base,
|
|
27167
|
-
value: Object.freeze(value)
|
|
27168
|
-
});
|
|
27169
|
-
}
|
|
27170
|
-
/**
|
|
27171
|
-
* Every registered section, in registration order, for `describeSettings`.
|
|
27172
|
-
*
|
|
27173
|
-
* @returns The sections, keyed by name.
|
|
27174
|
-
*/
|
|
27175
|
-
registrations() {
|
|
27176
|
-
return this.#sections;
|
|
27177
|
-
}
|
|
27178
|
-
/**
|
|
27179
|
-
* Reports whether a section has been registered.
|
|
27180
|
-
*
|
|
27181
|
-
* @param name - The section name.
|
|
27182
|
-
* @returns `true` when an extension owns the section.
|
|
27183
|
-
*/
|
|
27184
|
-
has(name) {
|
|
27185
|
-
return this.#sections.has(name);
|
|
27186
|
-
}
|
|
27187
|
-
/**
|
|
27188
|
-
* Checks that every section the project supplied is owned by some extension (§5) and closes the
|
|
27189
|
-
* table to further registration.
|
|
27190
|
-
*
|
|
27191
|
-
* @throws IgnifxError with code `IGX-0407` in development when the project declares a section no
|
|
27192
|
-
* extension registered.
|
|
27193
|
-
*/
|
|
27194
|
-
freeze() {
|
|
27195
|
-
for (const name of Object.keys(this.#input)) {
|
|
27196
|
-
if (this.#sections.has(name)) continue;
|
|
27197
|
-
if (this.#mode === "development") throw new IgnifxError(CoreErrorCode.unknownSettingsSection, `${name} is not a registered settings section.`, {
|
|
27198
|
-
context: { section: name },
|
|
27199
|
-
hint: "Register the extension that owns the section, or remove it from the project settings."
|
|
27200
|
-
});
|
|
27201
|
-
this.#log.warn(`Ignoring the unknown settings section ${name}.`);
|
|
27202
|
-
}
|
|
27203
|
-
this.#isFrozen = true;
|
|
27204
|
-
}
|
|
27205
|
-
/**
|
|
27206
|
-
* Whether {@link SettingsStore.freeze} has run.
|
|
27207
|
-
*
|
|
27208
|
-
* @returns `true` once the table is closed.
|
|
27209
|
-
*/
|
|
27210
|
-
get isFrozen() {
|
|
27211
|
-
return this.#isFrozen;
|
|
27212
|
-
}
|
|
27213
|
-
/**
|
|
27214
|
-
* Merges the project's values for one section over its defaults, validating them first.
|
|
27215
|
-
*
|
|
27216
|
-
* @param name - The section name.
|
|
27217
|
-
* @param schema - The owner's schema.
|
|
27218
|
-
* @param defaults - The owner's defaults.
|
|
27219
|
-
* @returns The resolved section.
|
|
27220
|
-
* @throws IgnifxError with code `IGX-0408` in development when validation fails.
|
|
27221
|
-
*/
|
|
27222
|
-
#resolve(name, schema, defaults) {
|
|
27223
|
-
const provided = this.#input[name];
|
|
27224
|
-
const resolved = { ...defaults };
|
|
27225
|
-
if (provided === void 0) return resolved;
|
|
27226
|
-
const props = this.#toPropertyBag(schema, provided);
|
|
27227
|
-
if (props === null) return this.#reject(name, `${name} settings must be an object.`, resolved);
|
|
27228
|
-
const issues = validateProps(schema, props, name);
|
|
27229
|
-
if (issues.length > 0) {
|
|
27230
|
-
const detail = issues.map((entry) => `${entry.path}: ${entry.message}`).join("; ");
|
|
27231
|
-
return this.#reject(name, detail, resolved);
|
|
27232
|
-
}
|
|
27233
|
-
return Object.assign(resolved, props);
|
|
27234
|
-
}
|
|
27235
|
-
/**
|
|
27236
|
-
* Applies the single-field shorthand: a section whose schema declares exactly one field may be
|
|
27237
|
-
* written as that field's value.
|
|
27238
|
-
*
|
|
27239
|
-
* @param schema - The owner's schema.
|
|
27240
|
-
* @param provided - What the project supplied.
|
|
27241
|
-
* @returns A bag of named props, or `null` when the value cannot be read as one.
|
|
27242
|
-
*/
|
|
27243
|
-
#toPropertyBag(schema, provided) {
|
|
27244
|
-
if (isPropertyBag(provided)) return provided;
|
|
27245
|
-
const names = Object.keys(schema);
|
|
27246
|
-
const only = names[0];
|
|
27247
|
-
if (names.length !== 1 || only === void 0) return null;
|
|
27248
|
-
return { [only]: provided };
|
|
27249
|
-
}
|
|
27250
|
-
/**
|
|
27251
|
-
* Handles an invalid section: a throw in development, a log line and the defaults in production
|
|
27252
|
-
* (§5).
|
|
27253
|
-
*
|
|
27254
|
-
* @param name - The section name.
|
|
27255
|
-
* @param detail - What was wrong.
|
|
27256
|
-
* @param defaults - The values to fall back to.
|
|
27257
|
-
* @returns The defaults, in production.
|
|
27258
|
-
* @throws IgnifxError with code `IGX-0408` in development.
|
|
27259
|
-
*/
|
|
27260
|
-
#reject(name, detail, defaults) {
|
|
27261
|
-
if (this.#mode === "development") throw new IgnifxError(CoreErrorCode.invalidSettings, `The ${name} settings section is invalid: ${detail}`, {
|
|
27262
|
-
context: {
|
|
27263
|
-
section: name,
|
|
27264
|
-
issues: detail
|
|
27265
|
-
},
|
|
27266
|
-
hint: "Check the section against the schema the owning extension registered."
|
|
27267
|
-
});
|
|
27268
|
-
this.#log.warn("The {section} settings section is invalid and was replaced by its defaults: {issues}", name, detail);
|
|
27269
|
-
return defaults;
|
|
27270
|
-
}
|
|
27271
|
-
};
|
|
27272
|
-
//#endregion
|
|
27273
28281
|
//#region src/storage/memory-backend.ts
|
|
27274
28282
|
/**
|
|
27275
28283
|
* The in-memory storage backend: the default for a headless app, and the one every unit test in the
|
|
@@ -34317,18 +35325,20 @@ var AppImpl = class {
|
|
|
34317
35325
|
await this.#host.register(list);
|
|
34318
35326
|
this.#settings.freeze();
|
|
34319
35327
|
this.assets.applySettings(this.#settings.section("assets"));
|
|
34320
|
-
const
|
|
35328
|
+
const renderer = rendererInternals(this.renderer);
|
|
35329
|
+
const rendering = renderer.settings;
|
|
34321
35330
|
if (this.#mode === "development") await enableLiteErrorDecoding();
|
|
34322
35331
|
const canvas = this.#canvas;
|
|
34323
|
-
const renderer = rendererInternals(this.renderer);
|
|
34324
35332
|
this.#handles = canvas === null ? createHeadlessEngine() : await createRenderEngine(canvas, this.#engineOptions(rendering), {
|
|
34325
35333
|
postProcessing: renderer.renderingFeatures.postProcessing,
|
|
34326
|
-
hdr: rendering.hdr
|
|
35334
|
+
hdr: rendering.hdr,
|
|
35335
|
+
autoExposure: toAutoExposureOptions(rendering)
|
|
34327
35336
|
});
|
|
34328
35337
|
if (canvas !== null) this.platform.setWebGpu(await probeWebGpuInfo());
|
|
34329
35338
|
this.assets.attachEngine(this.#handles.engine);
|
|
34330
35339
|
renderer.attachHandles(this.#handles.engine, this.#handles.scene, this.#handles.presenter);
|
|
34331
35340
|
this.#enableDeviceLossRecovery(rendering);
|
|
35341
|
+
await renderer.installTemporalAntiAliasing();
|
|
34332
35342
|
const time = this.#settings.time;
|
|
34333
35343
|
this.time.applySettings(time.fixedDeltaTime, time.maximumDeltaTime, time.timeScale);
|
|
34334
35344
|
const world = createWorld({
|
|
@@ -37072,6 +38082,6 @@ function settingsJsonSchema(app) {
|
|
|
37072
38082
|
};
|
|
37073
38083
|
}
|
|
37074
38084
|
//#endregion
|
|
37075
|
-
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, 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, 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 };
|
|
38085
|
+
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_QUALITIES, 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 };
|
|
37076
38086
|
|
|
37077
38087
|
//# sourceMappingURL=index.js.map
|