@ignifx/core 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/dist/{environment-CvVC1lPa.js → environment-CTM7BAyb.js} +3 -3
  2. package/dist/{environment-CvVC1lPa.js.map → environment-CTM7BAyb.js.map} +1 -1
  3. package/dist/{ignifx-error-R1ma_Lzv.js → ignifx-error-CRh89KUJ.js} +4 -1
  4. package/dist/ignifx-error-CRh89KUJ.js.map +1 -0
  5. package/dist/index.d.ts +32 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +234 -17
  8. package/dist/index.js.map +1 -1
  9. package/dist/{material-plugin-CTaWZXEk.js → material-plugin-Cfw_h_Mg.js} +2 -2
  10. package/dist/{material-plugin-CTaWZXEk.js.map → material-plugin-Cfw_h_Mg.js.map} +1 -1
  11. package/dist/{post-effect-compiler-Cq6cshjL.js → post-effect-compiler-Rce26Eue.js} +2 -2
  12. package/dist/{post-effect-compiler-Cq6cshjL.js.map → post-effect-compiler-Rce26Eue.js.map} +1 -1
  13. package/dist/{shader-material-fOI9Upt3.js → shader-material-CJxMJEUO.js} +3 -3
  14. package/dist/{shader-material-fOI9Upt3.js.map → shader-material-CJxMJEUO.js.map} +1 -1
  15. package/dist/{shader-material-BzVY0ySR.js → shader-material-F-CL4D70.js} +2 -2
  16. package/dist/{shader-material-BzVY0ySR.js.map → shader-material-F-CL4D70.js.map} +1 -1
  17. package/dist/{shader-pragma-CNAK4SIb.js → shader-pragma-D4HKC9vP.js} +2 -2
  18. package/dist/{shader-pragma-CNAK4SIb.js.map → shader-pragma-D4HKC9vP.js.map} +1 -1
  19. package/dist/{surface-shader-fJ2MOez0.js → surface-shader-Chs7wOAE.js} +4 -4
  20. package/dist/{surface-shader-fJ2MOez0.js.map → surface-shader-Chs7wOAE.js.map} +1 -1
  21. package/package.json +1 -1
  22. package/dist/ignifx-error-R1ma_Lzv.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
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-R1ma_Lzv.js";
1
+ import { a as CORE_ERROR_MESSAGES, c as THIRD_PARTY_ERROR_PREFIX, i as isIgnifxError, l as isValidErrorCode, n as assertNever, o as CoreErrorCode, r as formatErrorMessage, s as ErrorRange, t as IgnifxError } from "./ignifx-error-CRh89KUJ.js";
2
2
  import { _ as sign, a as approximately, c as degToRad, d as lerp, f as lerpAngleDegrees, g as repeat, h as radToDeg, i as RAD_TO_DEG, l as deltaAngleDegrees, m as pingPong, n as DEG_TO_RAD, o as clamp, p as moveTowards, r as EPSILON, s as clamp01, t as Color, u as inverseLerp, v as smoothStep, y as wrapAngleDegrees } from "./color-CpvebMIh.js";
3
3
  import { A as linkParent, B as tagNode, C as setMeshSubtreeVisible, D as updateMeshUvs$1, E as updateMeshPositions$1, F as readNodeTag, I as readWorldMatrix, L as reparentKeepingWorld, M as localRotation, N as localScale, O as createNode, P as parentNode, R as setNodeName, S as setMeshRenderOrder, T as updateMeshNormals$1, V as worldMatrixVersion, a as createCapsuleMesh, b as setMeshPickable, c as createMeshFromGeometry, d as createTorusMesh, g as removeMeshFromScene, h as recomputeMeshBounds, i as createBoxMesh, j as localPosition, k as disposeNode, l as createPlaneMesh, m as overrideSubtreeMaterials, n as cloneMeshUnderNode, o as createCylinderMesh, p as disposeMeshTemplate, r as collectSubtreeMeshes, s as createGroundMesh, t as addMeshToScene, u as createSphereMesh, v as setMeshId, w as updateMeshColors$1, x as setMeshReceiveShadows, y as setMeshMaterial, z as setNodeSelfVisible } from "./mesh-CnK_PX46.js";
4
- 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-CvVC1lPa.js";
5
- import { a as defineMaterialPlugin, c as MATERIAL_ALPHA_MODES, d as createStandardMaterialFromProps, f as markMaterialDirty, g as setPbrMetallicRoughness, h as setPbrBaseColor, i as MATERIAL_PLUGIN_SAMPLER_BUDGET, l as createDefaultMaterial, m as setMaterialAlpha, n as MATERIAL_PLUGIN_DEFAULT_PRIORITY, o as isLiteMaterialPluginPoint, r as MATERIAL_PLUGIN_RESERVED_NAMES, t as LITE_MATERIAL_PLUGIN_POINTS, u as createPbrMaterialFromProps } from "./material-plugin-CTaWZXEk.js";
4
+ 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-CTM7BAyb.js";
5
+ import { a as defineMaterialPlugin, c as MATERIAL_ALPHA_MODES, d as createStandardMaterialFromProps, f as markMaterialDirty, g as setPbrMetallicRoughness, h as setPbrBaseColor, i as MATERIAL_PLUGIN_SAMPLER_BUDGET, l as createDefaultMaterial, m as setMaterialAlpha, n as MATERIAL_PLUGIN_DEFAULT_PRIORITY, o as isLiteMaterialPluginPoint, r as MATERIAL_PLUGIN_RESERVED_NAMES, t as LITE_MATERIAL_PLUGIN_POINTS, u as createPbrMaterialFromProps } from "./material-plugin-Cfw_h_Mg.js";
6
6
  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-C42XJFmo.js";
7
7
  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";
8
- import { acquireTexture, addTask, addToScene, buildFrameGraphTask, captureScreenshot, cloneTransformNode, createBloomPostProcessTask, createCopyToTextureTask, createCsmDirectionalShadowGenerator, createDirectionalLight, createEngine, createEsmDirectionalShadowGenerator, createFontFromBuffer, createFreeCamera, createGpuPicker, createHemisphericLight, createImageProcessingTask, createMeshFromData, createNullEngine, createPcfDirectionalShadowGenerator, createPcfSpotlightShadowGenerator, createPointLight, createRenderTarget, createRenderTask, createSceneContext, createSmaaPostProcessTask, createSpotLight, createStorageBuffer, createTexture2DFromPixels, disableOrthographicCamera, disposeEngine, disposePicker, disposeScene, disposeStorageBuffer, enableBoneControl, enableDeviceLostSceneRecovery, enableMaterialPlugins, enableMaterialStencil, enableOrthographicCamera, enablePbrLightmap, enableStandardSkeleton, forceWebGpuDeviceLossForTesting, getEffectiveAspectRatio, getFrameGraph, getProjectionMatrix, getRenderTaskGpuTimings, getViewMatrix, getViewProjectionMatrix, isShaderMaterial, loadTexture2D, onBeforeRender, pickAsync, pickWithRay, rebuildSceneRenderables, registerScene, registerSceneWithShadowSupport, releaseTexture, removeFromScene, resizeEngine, resolveCameraViewport, setGpuTimingEnabled, setShadowTaskCasterMeshes, setSubtreeVisible, setSurfaceSize, startEngine, stopEngine, updateStorageBuffer, updateTexture2DFromPixels } from "@babylonjs/lite";
8
+ import { acquireTexture, addTask, addToScene, buildFrameGraphTask, captureScreenshot, cloneTransformNode, createBloomPostProcessTask, createCopyToTextureTask, createCsmDirectionalShadowGenerator, createDirectionalLight, createEngine, createEsmDirectionalShadowGenerator, createFontFromBuffer, createFreeCamera, createGpuPicker, createHemisphericLight, createImageProcessingTask, createMeshFromData, createNullEngine, createPcfDirectionalShadowGenerator, createPcfSpotlightShadowGenerator, createPointLight, createRenderTarget, createRenderTask, createSceneContext, createSmaaPostProcessTask, createSpotLight, createStorageBuffer, createTexture2DFromPixels, disableOrthographicCamera, disposeEngine, disposePicker, disposeScene, disposeStorageBuffer, enableBoneControl, enableDeviceLostSceneRecovery, enableMaterialPlugins, enableMaterialStencil, enableOrthographicCamera, enablePbrLightmap, enableSkeletonShadows, enableStandardSkeleton, forceWebGpuDeviceLossForTesting, getEffectiveAspectRatio, getFrameGraph, getProjectionMatrix, getRenderTaskGpuTimings, getViewMatrix, getViewProjectionMatrix, isPbrMaterial, isShaderMaterial, loadTexture2D, onBeforeRender, pickAsync, pickWithRay, rebuildSceneRenderables, registerScene, registerSceneWithShadowSupport, releaseTexture, removeFromScene, resizeEngine, resolveCameraViewport, setGpuTimingEnabled, setShadowTaskCasterMeshes, setSubtreeVisible, setSurfaceSize, startEngine, stopEngine, updateStorageBuffer, updateTexture2DFromPixels } from "@babylonjs/lite";
9
9
  //#region src/signal/signal.ts
10
10
  /** One attached handler. `handler === null` marks the entry dead and awaiting compaction. */
11
11
  var Connection = class {
@@ -7344,7 +7344,7 @@ function environmentDefinition(overrides = {}) {
7344
7344
  *
7345
7345
  * @param scene - The render scene.
7346
7346
  * @param rotationDegrees - The rotation around world Y, in degrees.
7347
- * @param blur - How blurred the specular reflection is, 0 to 1.
7347
+ * @param blur - How blurred the visible skybox is, 0 to 1.
7348
7348
  *
7349
7349
  * @internal
7350
7350
  */
@@ -7793,7 +7793,7 @@ function environmentSchema() {
7793
7793
  blur: f32(0, {
7794
7794
  min: 0,
7795
7795
  max: 1,
7796
- tooltip: "How blurred the specular reflection is."
7796
+ tooltip: "How blurred the visible skybox is, 0 to 1. Reflections and lighting are not blurred."
7797
7797
  }),
7798
7798
  skybox: record({
7799
7799
  enabled: bool(SKYBOX_ENABLED_DEFAULT, { tooltip: "Whether a skybox is drawn; set it in the .environment.json." }),
@@ -7872,7 +7872,7 @@ let surfaceLayer = null;
7872
7872
  * @internal
7873
7873
  */
7874
7874
  async function loadShaderSupport() {
7875
- const loaded = shaderLayer ?? await import("./shader-material-fOI9Upt3.js").then((n) => n.n);
7875
+ const loaded = shaderLayer ?? await import("./shader-material-CJxMJEUO.js").then((n) => n.n);
7876
7876
  shaderLayer = loaded;
7877
7877
  await loaded.loadShaderMaterialAdapter();
7878
7878
  return loaded;
@@ -7895,7 +7895,7 @@ function shaderSupport() {
7895
7895
  * @internal
7896
7896
  */
7897
7897
  async function loadSurfaceShaderSupport() {
7898
- const loaded = surfaceLayer ?? await import("./surface-shader-fJ2MOez0.js");
7898
+ const loaded = surfaceLayer ?? await import("./surface-shader-Chs7wOAE.js");
7899
7899
  surfaceLayer = loaded;
7900
7900
  return loaded;
7901
7901
  }
@@ -9798,6 +9798,64 @@ function canWarmUp(material) {
9798
9798
  return !isShaderMaterial(material) || material.storageBufferDecls.length === 0;
9799
9799
  }
9800
9800
  //#endregion
9801
+ //#region src/lite/pbr-deformers.ts
9802
+ /**
9803
+ * Which kinds of vertex deformation the PBR meshes of a scene use (`docs/architecture/07-rendering.md`
9804
+ * §2.2).
9805
+ *
9806
+ * Everything here is `@internal`.
9807
+ *
9808
+ * ## Why the render layer has to know (verified against `@babylonjs/lite@1.27.0`)
9809
+ *
9810
+ * Lite registers the PBR skinning and morph-target shader fragments only inside a full build of
9811
+ * the PBR group, and only when that build contains a skinned or morphed mesh (`buildPbrRenderables`,
9812
+ * `lib/material/pbr/pbr-renderable.js` 114-117). A mesh added after `registerScene` to a PBR group
9813
+ * that already exists is built at once by the group's `rebuildSingle` instead
9814
+ * (`processMaterialSwaps`, `lib/scene/scene-material-swap.js` 22-45), and that never registers
9815
+ * them. ignifx's warm-up builds the PBR group at start whenever the scene has a light (ADR-0014).
9816
+ *
9817
+ * So the first skinned model a page adds after `app.start()` is composed without its skinning
9818
+ * fragment, and Lite caches that bind-group layout under a key that does not say which fragments
9819
+ * were registered (`getOrCreatePbrBindings`, `lib/material/pbr/pbr-pipeline.js` 33-36). The next
9820
+ * renderable rebuild registers the fragment, reuses the cached layout, and builds a bind group with
9821
+ * one more entry than it: WebGPU rejects every frame from then on ("Binding entry sampler not set",
9822
+ * group 1, entries[3]) and the canvas stays black. The fragments are registered process-wide, so
9823
+ * every later app in the page was fine.
9824
+ *
9825
+ * The render sync system compares what this reports with what a full build has already composed,
9826
+ * and clears Lite's layout caches before the rebuild that first sees a new kind. Until that
9827
+ * rebuild, one frame after the mesh arrives, a skinned mesh draws in its bind pose; a morphed one
9828
+ * gets a shader that does not compile, so WebGPU rejects that frame or two.
9829
+ */
9830
+ /**
9831
+ * The deformation kinds, as bits of the mask {@link readPbrDeformers} returns.
9832
+ *
9833
+ * @internal
9834
+ */
9835
+ const PBR_DEFORMER = {
9836
+ /** A mesh skinned by a skeleton. */
9837
+ skin: 1,
9838
+ /** A mesh with morph targets. */
9839
+ morph: 2
9840
+ };
9841
+ /**
9842
+ * Reads which deformation kinds the scene's PBR meshes use.
9843
+ *
9844
+ * @param scene - The scene, or anything with its mesh list.
9845
+ * @returns A mask of {@link PBR_DEFORMER} bits; `0` when no PBR mesh deforms.
9846
+ *
9847
+ * @internal
9848
+ */
9849
+ function readPbrDeformers(scene) {
9850
+ let kinds = 0;
9851
+ for (const mesh of scene.meshes) {
9852
+ if (!isPbrMaterial(mesh.material)) continue;
9853
+ if (mesh.skeleton) kinds |= PBR_DEFORMER.skin;
9854
+ if (mesh.morphTargets) kinds |= PBR_DEFORMER.morph;
9855
+ }
9856
+ return kinds;
9857
+ }
9858
+ //#endregion
9801
9859
  //#region src/lite/render-diagnostics.ts
9802
9860
  /**
9803
9861
  * Render diagnostics and engine option mapping (`docs/architecture/07-rendering.md` §1 and §5) —
@@ -10712,6 +10770,11 @@ var RendererImpl = class {
10712
10770
  needsCasterRebuild = false;
10713
10771
  /** `true` once a light gained or lost a shadow generator, so the next rebuild needs fresh layouts. */
10714
10772
  needsShadowLayoutReset = false;
10773
+ /**
10774
+ * The PBR deformation kinds (`PBR_DEFORMER` bits) a full renderable build has already composed on
10775
+ * this engine. A kind missing from it gets fresh layouts on its first rebuild (`../lite/pbr-deformers.ts`).
10776
+ */
10777
+ builtPbrDeformers = 0;
10715
10778
  /** `true` once a camera was added, removed, enabled, disabled, or re-prioritised. */
10716
10779
  needsCameraSelect = true;
10717
10780
  /** `true` once the world has been told it has no enabled camera, so `IGX-0706` is logged once. */
@@ -11282,6 +11345,7 @@ var RendererImpl = class {
11282
11345
  */
11283
11346
  markSceneRegistered() {
11284
11347
  this.#isSceneRegistered = true;
11348
+ this.builtPbrDeformers = readPbrDeformers(this.scene);
11285
11349
  }
11286
11350
  /**
11287
11351
  * Records whether Babylon Lite's render loop is driving frames, which is what decides whether a
@@ -11498,6 +11562,7 @@ var InstancedMeshRenderer = class InstancedMeshRenderer extends Component {
11498
11562
  #appliedCastShadows = false;
11499
11563
  #hasAppliedSettings = false;
11500
11564
  #hasWarnedAboutLateSetting = false;
11565
+ #hasWarnedAboutLodWithoutCulling = false;
11501
11566
  /**
11502
11567
  * The Babylon Lite meshes this renderer draws. Unstable escape hatch
11503
11568
  * (`docs/architecture/00-overview.md` §3).
@@ -11691,6 +11756,17 @@ var InstancedMeshRenderer = class InstancedMeshRenderer extends Component {
11691
11756
  this.app.log.warn(`${CoreErrorCode.instancingSettingTooLate}: {entity} changed {field} on an InstancedMeshRenderer after the scene was registered; the value in use was kept. Set capacity, gpuCulling and lod.mesh before app.start().`, this.entity.name, field);
11692
11757
  }
11693
11758
  /**
11759
+ * Says once, at warning level, that a LOD partner was declared with GPU culling off. Lite picks
11760
+ * the far instances in the culling pass, so without it the partner never draws.
11761
+ *
11762
+ * @param lod - The `lod` field being applied.
11763
+ */
11764
+ #warnAboutLodWithoutCulling(lod) {
11765
+ if (this.#hasWarnedAboutLodWithoutCulling || this.gpuCulling || lod === null || lod.mesh === null) return;
11766
+ this.#hasWarnedAboutLodWithoutCulling = true;
11767
+ this.app.log.warn(`${CoreErrorCode.instancingLodWithoutCulling}: {entity} declares an InstancedMeshRenderer lod with gpuCulling off; the LOD mesh never draws. Turn gpuCulling on.`, this.entity.name);
11768
+ }
11769
+ /**
11694
11770
  * Builds or rebuilds the meshes when the template or a baked setting changed.
11695
11771
  *
11696
11772
  * @param renderer - The rendering service, for the scene.
@@ -11713,6 +11789,7 @@ var InstancedMeshRenderer = class InstancedMeshRenderer extends Component {
11713
11789
  this.#appliedLodHandle = lodField?.mesh ?? null;
11714
11790
  this.#upload.appliedCapacity = capacity;
11715
11791
  this.#appliedGpuCulling = this.gpuCulling;
11792
+ this.#warnAboutLodWithoutCulling(lodField);
11716
11793
  const template = loaded?.lite.mesh ?? null;
11717
11794
  if (template === null) return removed;
11718
11795
  const support = instancedMeshSupport();
@@ -11829,7 +11906,7 @@ function instancedMeshRendererSchema() {
11829
11906
  min: 1,
11830
11907
  tooltip: "The largest instance count; fixed once the scene is registered."
11831
11908
  }),
11832
- gpuCulling: bool(true, { tooltip: "Cull instances on the GPU; fixed once the scene is registered." }),
11909
+ gpuCulling: bool(true, { tooltip: "Cull instances on the GPU; fixed once the scene is registered. The lod partner needs it." }),
11833
11910
  castShadows: bool(true, { tooltip: "Whether the instances are rendered into shadow maps." }),
11834
11911
  receiveShadows: bool(true, { tooltip: "Whether shadow maps darken the instances." }),
11835
11912
  renderOrder: i32(0, { tooltip: "Sort key within the opaque or transparent phase; lower draws first." }),
@@ -11844,7 +11921,7 @@ function instancedMeshRendererSchema() {
11844
11921
  min: 0,
11845
11922
  tooltip: "Width of the per-instance dither window centred on the distance."
11846
11923
  })
11847
- }), { tooltip: "An optional coarse mesh for far instances; needs gpuCulling." })
11924
+ }), { tooltip: "An optional coarse mesh for far instances; draws only while gpuCulling is on." })
11848
11925
  });
11849
11926
  }
11850
11927
  //#endregion
@@ -12276,7 +12353,8 @@ function readMaterialEpoch(scene) {
12276
12353
  * Makes the next renderable rebuild create fresh bind-group layouts for every material.
12277
12354
  *
12278
12355
  * @remarks
12279
- * Call it before {@link rebuildRenderables} whenever a light gained or lost a shadow generator.
12356
+ * Call it before {@link rebuildRenderables} whenever a light gained or lost a shadow generator,
12357
+ * and when the scene gained its first skinned or morphed PBR mesh (`./pbr-deformers.ts`).
12280
12358
  * Lite caches a material's bindings, shadow bind-group layout included, under a key that does not
12281
12359
  * name the shadow maps (`getOrCreatePbrBindings`, `lib/material/pbr/pbr-pipeline.js` 36). So after
12282
12360
  * the number of shadow-casting lights changes, a rebuild reuses a layout sized for the old number
@@ -12379,7 +12457,115 @@ function toSpotConfig(settings) {
12379
12457
  return config;
12380
12458
  }
12381
12459
  //#endregion
12460
+ //#region src/lite/shadow-caster-shapes.ts
12461
+ /**
12462
+ * Tracks the bone poses and shader uniforms of one shadow generator's casters.
12463
+ *
12464
+ * @remarks
12465
+ * Call {@link ShadowCasterShapes.watch} whenever the generator starts drawing a new caster list,
12466
+ * then {@link ShadowCasterShapes.hasChanged} once per frame. PCF and CSM build a new shadow task
12467
+ * state whenever a caster's material changes, and the render sync system hands ESM a new caster list
12468
+ * when one does, so watching per state follows material swaps too. Only `watch` allocates.
12469
+ *
12470
+ * Morph targets would need the same treatment, but ignifx has no morph-target support yet.
12471
+ *
12472
+ * @internal
12473
+ */
12474
+ var ShadowCasterShapes = class {
12475
+ /** The skinned casters. */
12476
+ #skinned = [];
12477
+ /** Each skinned caster's bone matrices when the map was last drawn, by the same index. */
12478
+ #poses = [];
12479
+ /** The shader materials the casters draw their shadows with. */
12480
+ #shaders = [];
12481
+ /** Each shader material's uniform and resource versions, summed, by the same index. */
12482
+ #shaderVersions = [];
12483
+ /**
12484
+ * Starts tracking a new caster list.
12485
+ *
12486
+ * @param casters - The meshes the generator draws.
12487
+ */
12488
+ watch(casters) {
12489
+ this.#skinned.length = 0;
12490
+ this.#poses.length = 0;
12491
+ this.#shaders.length = 0;
12492
+ this.#shaderVersions.length = 0;
12493
+ for (const mesh of casters) {
12494
+ const bones = mesh.skeleton?.boneMatrices;
12495
+ if (bones !== void 0) {
12496
+ this.#skinned.push(mesh);
12497
+ this.#poses.push(bones.slice());
12498
+ }
12499
+ const shader = shadowShaderMaterial(mesh);
12500
+ if (shader !== null && !this.#shaders.includes(shader)) {
12501
+ this.#shaders.push(shader);
12502
+ this.#shaderVersions.push(shaderVersion(shader));
12503
+ }
12504
+ }
12505
+ }
12506
+ /**
12507
+ * Whether any tracked caster changed shape since the last call (or since {@link watch}).
12508
+ *
12509
+ * @returns `true` when a bone pose or a shader material's uniforms changed.
12510
+ */
12511
+ hasChanged() {
12512
+ let changed = false;
12513
+ for (let index = 0; index < this.#skinned.length; index += 1) {
12514
+ const bones = this.#skinned[index]?.skeleton?.boneMatrices;
12515
+ const pose = this.#poses[index];
12516
+ if (bones === void 0 || pose === void 0 || hasSameValues(pose, bones)) continue;
12517
+ if (pose.length === bones.length) pose.set(bones);
12518
+ else this.#poses[index] = bones.slice();
12519
+ changed = true;
12520
+ }
12521
+ for (let index = 0; index < this.#shaders.length; index += 1) {
12522
+ const shader = this.#shaders[index];
12523
+ if (shader === void 0) continue;
12524
+ const version = shaderVersion(shader);
12525
+ if (version !== this.#shaderVersions[index]) {
12526
+ this.#shaderVersions[index] = version;
12527
+ changed = true;
12528
+ }
12529
+ }
12530
+ return changed;
12531
+ }
12532
+ };
12533
+ /**
12534
+ * The shader material a caster's shadow is drawn with, if it is one.
12535
+ *
12536
+ * @param mesh - A caster.
12537
+ * @returns The material, or `null` when the caster's shadow is not drawn by a shader material.
12538
+ */
12539
+ function shadowShaderMaterial(mesh) {
12540
+ let material = mesh.material;
12541
+ while (material?._shadowCasterMaterial !== void 0) material = material._shadowCasterMaterial;
12542
+ return material?._buildGroup?._materialFamily === "shader" ? material : null;
12543
+ }
12544
+ /**
12545
+ * A number that grows whenever a shader material's uniforms or bound resources change.
12546
+ *
12547
+ * @param material - A shader material.
12548
+ * @returns The sum of its two version counters; both only ever grow.
12549
+ */
12550
+ function shaderVersion(material) {
12551
+ return (material._uniformVersion ?? 0) + (material._resourceVersion ?? 0);
12552
+ }
12553
+ /**
12554
+ * Whether two arrays hold the same values.
12555
+ *
12556
+ * @param a - One array.
12557
+ * @param b - The other.
12558
+ * @returns `true` when both have the same length and elements.
12559
+ */
12560
+ function hasSameValues(a, b) {
12561
+ if (a.length !== b.length) return false;
12562
+ for (let index = 0; index < a.length; index += 1) if (a[index] !== b[index]) return false;
12563
+ return true;
12564
+ }
12565
+ //#endregion
12382
12566
  //#region src/lite/gpu/shadow-generator.ts
12567
+ /** What Lite's caster gate reads as "never drawn" (`lib/shadow/pcf-shadow-task-hooks.js` 90). */
12568
+ const NEVER_DRAWN = -1;
12383
12569
  /**
12384
12570
  * Builds the shadow generator a light's declared settings ask for.
12385
12571
  *
@@ -12400,7 +12586,9 @@ function toSpotConfig(settings) {
12400
12586
  */
12401
12587
  function createShadowGeneratorForLight(engine, light, settings) {
12402
12588
  const generator = light.lightType === "spot" ? createPcfSpotlightShadowGenerator(engine, light, toSpotConfig(settings)) : createDirectionalGenerator(engine, light, settings);
12589
+ enableSkeletonShadows(generator);
12403
12590
  recordReplacedShadowTaskStates(generator);
12591
+ redrawChangedCasterShapes(generator);
12404
12592
  return generator;
12405
12593
  }
12406
12594
  /**
@@ -12408,7 +12596,7 @@ function createShadowGeneratorForLight(engine, light, settings) {
12408
12596
  * can draw (see the module header for the frame this prevents).
12409
12597
  *
12410
12598
  * @remarks
12411
- * Lite's own `enableDeformableShadowCasters` wraps the same hook the same way
12599
+ * Lite's own `enableDeformableShadowBounds` wraps the same hook the same way
12412
12600
  * (`lib/shadow/deformable-shadow-casters.js` 98-104). A state built for a *new* caster array is
12413
12601
  * left alone, because the shadow task records that one itself.
12414
12602
  *
@@ -12420,13 +12608,40 @@ function recordReplacedShadowTaskStates(generator) {
12420
12608
  if (ensure === void 0) return;
12421
12609
  hooks._ensureShadowTaskState = (engine, scene, casterMeshes) => {
12422
12610
  const previous = hooks._shadowTaskState;
12611
+ const previousCasters = previous?._casterMeshes;
12423
12612
  const state = ensure(engine, scene, casterMeshes);
12424
12613
  if (state !== previous && casterMeshes.length === 0) stopMirroringEmptyStates(scene, state);
12425
- if (previous !== void 0 && state !== previous && state._casterMeshes === previous._casterMeshes) state._task.record();
12614
+ if (previous !== void 0 && state !== previous && state._casterMeshes === previousCasters) state._task.record();
12426
12615
  return state;
12427
12616
  };
12428
12617
  }
12429
12618
  /**
12619
+ * Makes a generator redraw its map in any frame where a caster changed shape without moving: a new
12620
+ * bone pose, or a shader material whose uniforms changed (see the module header).
12621
+ *
12622
+ * @remarks
12623
+ * It forgets the caster version the map was drawn at, which is what Lite's own gate compares
12624
+ * against, so the pass draws as if it never had. A pose change is found by comparing bone matrices,
12625
+ * not by asking whether an animator ran: a paused animator, or a skinned model with no animator at
12626
+ * all, costs no redraw, while bone control and every other writer is still caught.
12627
+ *
12628
+ * @param generator - A generator from one of Lite's four factories.
12629
+ */
12630
+ function redrawChangedCasterShapes(generator) {
12631
+ const hooks = generator;
12632
+ const render = hooks._renderShadowMap;
12633
+ if (render === void 0) return;
12634
+ const shapes = new ShadowCasterShapes();
12635
+ let watched = null;
12636
+ hooks._renderShadowMap = (engine, state) => {
12637
+ if (state !== watched) {
12638
+ watched = state;
12639
+ shapes.watch(state._casterMeshes);
12640
+ } else if (shapes.hasChanged()) state._lastCasterVersion = NEVER_DRAWN;
12641
+ return render(engine, state);
12642
+ };
12643
+ }
12644
+ /**
12430
12645
  * Keeps a shadow task state built for no casters from drawing the scene's renderables.
12431
12646
  *
12432
12647
  * @remarks
@@ -14252,7 +14467,7 @@ let effectLayer = null;
14252
14467
  * @internal
14253
14468
  */
14254
14469
  async function loadPostEffectSupport() {
14255
- const [compiler, effects] = await Promise.all([compilerLayer ?? import("./post-effect-compiler-Cq6cshjL.js"), effectLayer ?? import("./effect-task-CMbuO6Kb.js")]);
14470
+ const [compiler, effects] = await Promise.all([compilerLayer ?? import("./post-effect-compiler-Rce26Eue.js"), effectLayer ?? import("./effect-task-CMbuO6Kb.js")]);
14256
14471
  compilerLayer = compiler;
14257
14472
  effectLayer = effects;
14258
14473
  }
@@ -14390,7 +14605,7 @@ function createShaderLoader() {
14390
14605
  type: SHADER_ASSET_TYPE,
14391
14606
  extensions: SHADER_FILE_EXTENSIONS,
14392
14607
  async load(ctx) {
14393
- const [source, pragma] = await Promise.all([ctx.fetchText(), import("./shader-pragma-CNAK4SIb.js")]);
14608
+ const [source, pragma] = await Promise.all([ctx.fetchText(), import("./shader-pragma-D4HKC9vP.js")]);
14394
14609
  const declaration = pragma.parseShaderDeclaration(source, ctx.address);
14395
14610
  await loadShaderSupport();
14396
14611
  if (declaration.kind === "surface") await loadSurfaceShaderSupport();
@@ -17190,11 +17405,13 @@ var RenderSyncSystem = class {
17190
17405
  do {
17191
17406
  if (renderer.isHeadless || !renderer.isSceneRegistered) return;
17192
17407
  try {
17193
- if (renderer.needsShadowLayoutReset) {
17408
+ const deformers = readPbrDeformers(renderer.scene);
17409
+ if (renderer.needsShadowLayoutReset || (deformers & ~renderer.builtPbrDeformers) !== 0) {
17194
17410
  renderer.needsShadowLayoutReset = false;
17195
17411
  forgetMaterialBindingLayouts(renderer.engine);
17196
17412
  }
17197
17413
  await rebuildRenderables(renderer.scene);
17414
+ renderer.builtPbrDeformers |= deformers;
17198
17415
  } catch (error) {
17199
17416
  renderer.app.onError.emit({
17200
17417
  error,
@@ -34204,7 +34421,7 @@ function describeEnvironmentFileFormat() {
34204
34421
  blur: {
34205
34422
  kind: "f32",
34206
34423
  default: 0,
34207
- description: "How blurred the specular reflection is, 0 to 1."
34424
+ description: "How blurred the visible skybox is, 0 to 1; reflections are not blurred."
34208
34425
  },
34209
34426
  rotation: {
34210
34427
  kind: "f32",