@fps-games/engine 0.0.1-beta.2 → 0.0.1-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/asset-resource.d.ts +45 -0
- package/dist/asset-resource.d.ts.map +1 -0
- package/dist/asset-resource.js +147 -0
- package/dist/asset-resource.js.map +1 -0
- package/dist/babylon/camera.d.ts +25 -0
- package/dist/babylon/camera.d.ts.map +1 -0
- package/dist/babylon/camera.js +149 -0
- package/dist/babylon/camera.js.map +1 -0
- package/dist/babylon/frame-pump.d.ts +27 -0
- package/dist/babylon/frame-pump.d.ts.map +1 -0
- package/dist/babylon/frame-pump.js +90 -0
- package/dist/babylon/frame-pump.js.map +1 -0
- package/dist/babylon/game-world-plugin-lifecycle.d.ts +26 -0
- package/dist/babylon/game-world-plugin-lifecycle.d.ts.map +1 -0
- package/dist/babylon/game-world-plugin-lifecycle.js +257 -0
- package/dist/babylon/game-world-plugin-lifecycle.js.map +1 -0
- package/dist/babylon/lighting-controller.d.ts.map +1 -1
- package/dist/babylon/lighting-controller.js +162 -16
- package/dist/babylon/lighting-controller.js.map +1 -1
- package/dist/babylon/plugin-contract.d.ts +15 -0
- package/dist/babylon/plugin-contract.d.ts.map +1 -0
- package/dist/babylon/plugin-contract.js +10 -0
- package/dist/babylon/plugin-contract.js.map +1 -0
- package/dist/babylon/renderer/asset-container-instantiation.d.ts +39 -0
- package/dist/babylon/renderer/asset-container-instantiation.d.ts.map +1 -0
- package/dist/babylon/renderer/asset-container-instantiation.js +287 -0
- package/dist/babylon/renderer/asset-container-instantiation.js.map +1 -0
- package/dist/babylon/renderer/brdf-texture-settlement.d.ts +7 -0
- package/dist/babylon/renderer/brdf-texture-settlement.d.ts.map +1 -0
- package/dist/babylon/renderer/brdf-texture-settlement.js +29 -0
- package/dist/babylon/renderer/brdf-texture-settlement.js.map +1 -0
- package/dist/babylon/renderer/environment/environment-texture-controller.d.ts +7 -0
- package/dist/babylon/renderer/environment/environment-texture-controller.d.ts.map +1 -0
- package/dist/babylon/renderer/environment/environment-texture-controller.js +358 -0
- package/dist/babylon/renderer/environment/environment-texture-controller.js.map +1 -0
- package/dist/babylon/renderer/environment/index.d.ts +4 -0
- package/dist/babylon/renderer/environment/index.d.ts.map +1 -0
- package/dist/babylon/renderer/environment/index.js +4 -0
- package/dist/babylon/renderer/environment/index.js.map +1 -0
- package/dist/babylon/renderer/environment/profile.d.ts +3 -0
- package/dist/babylon/renderer/environment/profile.d.ts.map +1 -0
- package/dist/babylon/renderer/environment/profile.js +27 -0
- package/dist/babylon/renderer/environment/profile.js.map +1 -0
- package/dist/babylon/renderer/environment/types.d.ts +24 -0
- package/dist/babylon/renderer/environment/types.d.ts.map +1 -0
- package/dist/babylon/renderer/environment/types.js +6 -0
- package/dist/babylon/renderer/environment/types.js.map +1 -0
- package/dist/babylon/renderer/index.d.ts +26 -0
- package/dist/babylon/renderer/index.d.ts.map +1 -0
- package/dist/babylon/renderer/index.js +26 -0
- package/dist/babylon/renderer/index.js.map +1 -0
- package/dist/babylon/renderer/lighting/directional-light-angles.d.ts +17 -0
- package/dist/babylon/renderer/lighting/directional-light-angles.d.ts.map +1 -0
- package/dist/babylon/renderer/lighting/directional-light-angles.js +67 -0
- package/dist/babylon/renderer/lighting/directional-light-angles.js.map +1 -0
- package/dist/babylon/renderer/material-owner-candidates.d.ts +21 -0
- package/dist/babylon/renderer/material-owner-candidates.d.ts.map +1 -0
- package/dist/babylon/renderer/material-owner-candidates.js +217 -0
- package/dist/babylon/renderer/material-owner-candidates.js.map +1 -0
- package/dist/babylon/renderer/materials/index.d.ts +3 -0
- package/dist/babylon/renderer/materials/index.d.ts.map +1 -0
- package/dist/babylon/renderer/materials/index.js +3 -0
- package/dist/babylon/renderer/materials/index.js.map +1 -0
- package/dist/babylon/renderer/materials/material-runtime.d.ts +29 -0
- package/dist/babylon/renderer/materials/material-runtime.d.ts.map +1 -0
- package/dist/babylon/renderer/materials/material-runtime.js +660 -0
- package/dist/babylon/renderer/materials/material-runtime.js.map +1 -0
- package/dist/babylon/renderer/materials/material-slot-owner.d.ts +42 -0
- package/dist/babylon/renderer/materials/material-slot-owner.d.ts.map +1 -0
- package/dist/babylon/renderer/materials/material-slot-owner.js +318 -0
- package/dist/babylon/renderer/materials/material-slot-owner.js.map +1 -0
- package/dist/babylon/renderer/outlines/babylon-default/apply.d.ts +4 -0
- package/dist/babylon/renderer/outlines/babylon-default/apply.d.ts.map +1 -0
- package/dist/babylon/renderer/outlines/babylon-default/apply.js +45 -0
- package/dist/babylon/renderer/outlines/babylon-default/apply.js.map +1 -0
- package/dist/babylon/renderer/outlines/babylon-default/index.d.ts +3 -0
- package/dist/babylon/renderer/outlines/babylon-default/index.d.ts.map +1 -0
- package/dist/babylon/renderer/outlines/babylon-default/index.js +2 -0
- package/dist/babylon/renderer/outlines/babylon-default/index.js.map +1 -0
- package/dist/babylon/renderer/outlines/babylon-default/types.d.ts +7 -0
- package/dist/babylon/renderer/outlines/babylon-default/types.d.ts.map +1 -0
- package/dist/babylon/renderer/outlines/babylon-default/types.js +2 -0
- package/dist/babylon/renderer/outlines/babylon-default/types.js.map +1 -0
- package/dist/babylon/renderer/outlines/index.d.ts +4 -0
- package/dist/babylon/renderer/outlines/index.d.ts.map +1 -0
- package/dist/babylon/renderer/outlines/index.js +3 -0
- package/dist/babylon/renderer/outlines/index.js.map +1 -0
- package/dist/babylon/renderer/outlines/runtime-override.d.ts +36 -0
- package/dist/babylon/renderer/outlines/runtime-override.d.ts.map +1 -0
- package/dist/babylon/renderer/outlines/runtime-override.js +131 -0
- package/dist/babylon/renderer/outlines/runtime-override.js.map +1 -0
- package/dist/babylon/renderer/outlines/types.d.ts +7 -0
- package/dist/babylon/renderer/outlines/types.d.ts.map +1 -0
- package/dist/babylon/renderer/outlines/types.js +2 -0
- package/dist/babylon/renderer/outlines/types.js.map +1 -0
- package/dist/babylon/renderer/placement/index.d.ts +2 -0
- package/dist/babylon/renderer/placement/index.d.ts.map +1 -0
- package/dist/babylon/renderer/placement/index.js +2 -0
- package/dist/babylon/renderer/placement/index.js.map +1 -0
- package/dist/babylon/renderer/placement/runtime-drop-position.d.ts +24 -0
- package/dist/babylon/renderer/placement/runtime-drop-position.d.ts.map +1 -0
- package/dist/babylon/renderer/placement/runtime-drop-position.js +63 -0
- package/dist/babylon/renderer/placement/runtime-drop-position.js.map +1 -0
- package/dist/babylon/renderer/post-process/babylon-default-pipeline.d.ts +7 -0
- package/dist/babylon/renderer/post-process/babylon-default-pipeline.d.ts.map +1 -0
- package/dist/babylon/renderer/post-process/babylon-default-pipeline.js +301 -0
- package/dist/babylon/renderer/post-process/babylon-default-pipeline.js.map +1 -0
- package/dist/babylon/renderer/post-process/index.d.ts +5 -0
- package/dist/babylon/renderer/post-process/index.d.ts.map +1 -0
- package/dist/babylon/renderer/post-process/index.js +5 -0
- package/dist/babylon/renderer/post-process/index.js.map +1 -0
- package/dist/babylon/renderer/post-process/profile.d.ts +5 -0
- package/dist/babylon/renderer/post-process/profile.d.ts.map +1 -0
- package/dist/babylon/renderer/post-process/profile.js +155 -0
- package/dist/babylon/renderer/post-process/profile.js.map +1 -0
- package/dist/babylon/renderer/post-process/types.d.ts +81 -0
- package/dist/babylon/renderer/post-process/types.d.ts.map +1 -0
- package/dist/babylon/renderer/post-process/types.js +24 -0
- package/dist/babylon/renderer/post-process/types.js.map +1 -0
- package/dist/babylon/renderer/post-process/volume-stack.d.ts +4 -0
- package/dist/babylon/renderer/post-process/volume-stack.d.ts.map +1 -0
- package/dist/babylon/renderer/post-process/volume-stack.js +105 -0
- package/dist/babylon/renderer/post-process/volume-stack.js.map +1 -0
- package/dist/babylon/renderer/rendering/image-node.d.ts +35 -0
- package/dist/babylon/renderer/rendering/image-node.d.ts.map +1 -0
- package/dist/babylon/renderer/rendering/image-node.js +39 -0
- package/dist/babylon/renderer/rendering/image-node.js.map +1 -0
- package/dist/babylon/renderer/rendering/index.d.ts +3 -0
- package/dist/babylon/renderer/rendering/index.d.ts.map +1 -0
- package/dist/babylon/renderer/rendering/index.js +3 -0
- package/dist/babylon/renderer/rendering/index.js.map +1 -0
- package/dist/babylon/renderer/rendering/node-rendering.d.ts +19 -0
- package/dist/babylon/renderer/rendering/node-rendering.d.ts.map +1 -0
- package/dist/babylon/renderer/rendering/node-rendering.js +66 -0
- package/dist/babylon/renderer/rendering/node-rendering.js.map +1 -0
- package/dist/babylon/renderer/shadows/blob-shadow-shaders.d.ts +5 -0
- package/dist/babylon/renderer/shadows/blob-shadow-shaders.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/blob-shadow-shaders.js +46 -0
- package/dist/babylon/renderer/shadows/blob-shadow-shaders.js.map +1 -0
- package/dist/babylon/renderer/shadows/blob-shadow-system.d.ts +5 -0
- package/dist/babylon/renderer/shadows/blob-shadow-system.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/blob-shadow-system.js +402 -0
- package/dist/babylon/renderer/shadows/blob-shadow-system.js.map +1 -0
- package/dist/babylon/renderer/shadows/dynamic-shadow-system.d.ts +87 -0
- package/dist/babylon/renderer/shadows/dynamic-shadow-system.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/dynamic-shadow-system.js +659 -0
- package/dist/babylon/renderer/shadows/dynamic-shadow-system.js.map +1 -0
- package/dist/babylon/renderer/shadows/planar-shadow-shaders.d.ts +7 -0
- package/dist/babylon/renderer/shadows/planar-shadow-shaders.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/planar-shadow-shaders.js +316 -0
- package/dist/babylon/renderer/shadows/planar-shadow-shaders.js.map +1 -0
- package/dist/babylon/renderer/shadows/planar-shadow-system.d.ts +5 -0
- package/dist/babylon/renderer/shadows/planar-shadow-system.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/planar-shadow-system.js +1562 -0
- package/dist/babylon/renderer/shadows/planar-shadow-system.js.map +1 -0
- package/dist/babylon/renderer/shadows/shadow-generator-shaders.d.ts +14 -0
- package/dist/babylon/renderer/shadows/shadow-generator-shaders.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/shadow-generator-shaders.js +14 -0
- package/dist/babylon/renderer/shadows/shadow-generator-shaders.js.map +1 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-depth-backend.d.ts +69 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-depth-backend.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-depth-backend.js +847 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-depth-backend.js.map +1 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-system.d.ts +148 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-system.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-system.js +4533 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-system.js.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-artifact-system.d.ts +4 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-artifact-system.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-artifact-system.js +645 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-artifact-system.js.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-atlas.d.ts +61 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-atlas.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-atlas.js +382 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-atlas.js.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-bake.d.ts +47 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-bake.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-bake.js +285 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-bake.js.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-baker.d.ts +88 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-baker.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-baker.js +830 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-baker.js.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-options.d.ts +3 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-options.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-options.js +60 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-options.js.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-rendering.d.ts +27 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-rendering.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-rendering.js +220 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-rendering.js.map +1 -0
- package/dist/babylon/renderer/shadows/types.d.ts +421 -0
- package/dist/babylon/renderer/shadows/types.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/types.js +127 -0
- package/dist/babylon/renderer/shadows/types.js.map +1 -0
- package/dist/babylon/renderer/world-rendering-controller.d.ts +29 -0
- package/dist/babylon/renderer/world-rendering-controller.d.ts.map +1 -0
- package/dist/babylon/renderer/world-rendering-controller.js +183 -0
- package/dist/babylon/renderer/world-rendering-controller.js.map +1 -0
- package/dist/babylon/renderer-controller.d.ts +93 -0
- package/dist/babylon/renderer-controller.d.ts.map +1 -0
- package/dist/babylon/renderer-controller.js +706 -0
- package/dist/babylon/renderer-controller.js.map +1 -0
- package/dist/babylon/scene-renderer.d.ts +20 -0
- package/dist/babylon/scene-renderer.d.ts.map +1 -0
- package/dist/babylon/scene-renderer.js +58 -0
- package/dist/babylon/scene-renderer.js.map +1 -0
- package/dist/babylon.d.ts +7 -0
- package/dist/babylon.d.ts.map +1 -1
- package/dist/babylon.js +7 -0
- package/dist/babylon.js.map +1 -1
- package/dist/build-info.json +4 -4
- package/dist/camera.d.ts +25 -0
- package/dist/camera.d.ts.map +1 -0
- package/dist/camera.js +68 -0
- package/dist/camera.js.map +1 -0
- package/dist/compiled-scene-data.d.ts +23 -0
- package/dist/compiled-scene-data.d.ts.map +1 -0
- package/dist/compiled-scene-data.js +100 -0
- package/dist/compiled-scene-data.js.map +1 -0
- package/dist/config.d.ts +9 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +21 -0
- package/dist/config.js.map +1 -1
- package/dist/frame.d.ts +32 -0
- package/dist/frame.d.ts.map +1 -0
- package/dist/frame.js +54 -0
- package/dist/frame.js.map +1 -0
- package/dist/ground-decal.d.ts +22 -0
- package/dist/ground-decal.d.ts.map +1 -0
- package/dist/ground-decal.js +48 -0
- package/dist/ground-decal.js.map +1 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/lighting.d.ts +13 -5
- package/dist/lighting.d.ts.map +1 -1
- package/dist/lighting.js +11 -5
- package/dist/lighting.js.map +1 -1
- package/dist/material-owner.d.ts +141 -0
- package/dist/material-owner.d.ts.map +1 -0
- package/dist/material-owner.js +552 -0
- package/dist/material-owner.js.map +1 -0
- package/dist/material-profile.d.ts +62 -0
- package/dist/material-profile.d.ts.map +1 -0
- package/dist/material-profile.js +132 -0
- package/dist/material-profile.js.map +1 -0
- package/dist/rendering/index.d.ts +14 -0
- package/dist/rendering/index.d.ts.map +1 -0
- package/dist/rendering/index.js +12 -0
- package/dist/rendering/index.js.map +1 -0
- package/dist/rendering/rendering-profile-types.d.ts +322 -0
- package/dist/rendering/rendering-profile-types.d.ts.map +1 -0
- package/dist/rendering/rendering-profile-types.js +2 -0
- package/dist/rendering/rendering-profile-types.js.map +1 -0
- package/dist/rendering/rendering-profile-validation.d.ts +2 -0
- package/dist/rendering/rendering-profile-validation.d.ts.map +1 -0
- package/dist/rendering/rendering-profile-validation.js +364 -0
- package/dist/rendering/rendering-profile-validation.js.map +1 -0
- package/dist/rendering/rendering-profile-values.d.ts +19 -0
- package/dist/rendering/rendering-profile-values.d.ts.map +1 -0
- package/dist/rendering/rendering-profile-values.js +79 -0
- package/dist/rendering/rendering-profile-values.js.map +1 -0
- package/dist/rendering/rendering-profile.d.ts +15 -0
- package/dist/rendering/rendering-profile.d.ts.map +1 -0
- package/dist/rendering/rendering-profile.js +442 -0
- package/dist/rendering/rendering-profile.js.map +1 -0
- package/dist/rendering/shadow-map-experiment-depth.d.ts +63 -0
- package/dist/rendering/shadow-map-experiment-depth.d.ts.map +1 -0
- package/dist/rendering/shadow-map-experiment-depth.js +186 -0
- package/dist/rendering/shadow-map-experiment-depth.js.map +1 -0
- package/dist/rendering/shadow-map-experiment-lifecycle.d.ts +94 -0
- package/dist/rendering/shadow-map-experiment-lifecycle.d.ts.map +1 -0
- package/dist/rendering/shadow-map-experiment-lifecycle.js +407 -0
- package/dist/rendering/shadow-map-experiment-lifecycle.js.map +1 -0
- package/dist/rendering/shadow-map-experiment.d.ts +189 -0
- package/dist/rendering/shadow-map-experiment.d.ts.map +1 -0
- package/dist/rendering/shadow-map-experiment.js +549 -0
- package/dist/rendering/shadow-map-experiment.js.map +1 -0
- package/dist/rendering/shadow-quality.d.ts +5 -0
- package/dist/rendering/shadow-quality.d.ts.map +1 -0
- package/dist/rendering/shadow-quality.js +83 -0
- package/dist/rendering/shadow-quality.js.map +1 -0
- package/dist/rendering/shadow-runtime.d.ts +59 -0
- package/dist/rendering/shadow-runtime.d.ts.map +1 -0
- package/dist/rendering/shadow-runtime.js +378 -0
- package/dist/rendering/shadow-runtime.js.map +1 -0
- package/dist/rendering/shadow-settings.d.ts +15 -0
- package/dist/rendering/shadow-settings.d.ts.map +1 -0
- package/dist/rendering/shadow-settings.js +129 -0
- package/dist/rendering/shadow-settings.js.map +1 -0
- package/dist/rendering/shadow-types.d.ts +99 -0
- package/dist/rendering/shadow-types.d.ts.map +1 -0
- package/dist/rendering/shadow-types.js +5 -0
- package/dist/rendering/shadow-types.js.map +1 -0
- package/dist/rendering/shadow-validation.d.ts +3 -0
- package/dist/rendering/shadow-validation.d.ts.map +1 -0
- package/dist/rendering/shadow-validation.js +166 -0
- package/dist/rendering/shadow-validation.js.map +1 -0
- package/dist/rendering/value.d.ts +2 -0
- package/dist/rendering/value.d.ts.map +1 -0
- package/dist/rendering/value.js +6 -0
- package/dist/rendering/value.js.map +1 -0
- package/dist/runtime-data-token.d.ts +4 -0
- package/dist/runtime-data-token.d.ts.map +1 -0
- package/dist/runtime-data-token.js +4 -0
- package/dist/runtime-data-token.js.map +1 -0
- package/dist/runtime-data-types.d.ts +83 -0
- package/dist/runtime-data-types.d.ts.map +1 -0
- package/dist/runtime-data-types.js +2 -0
- package/dist/runtime-data-types.js.map +1 -0
- package/dist/runtime-data.d.ts +18 -0
- package/dist/runtime-data.d.ts.map +1 -0
- package/dist/runtime-data.js +301 -0
- package/dist/runtime-data.js.map +1 -0
- package/dist/runtime-scene-resolvers.d.ts +33 -0
- package/dist/runtime-scene-resolvers.d.ts.map +1 -0
- package/dist/runtime-scene-resolvers.js +36 -0
- package/dist/runtime-scene-resolvers.js.map +1 -0
- package/dist/scene-artifact-types.d.ts +385 -0
- package/dist/scene-artifact-types.d.ts.map +1 -0
- package/dist/scene-artifact-types.js +2 -0
- package/dist/scene-artifact-types.js.map +1 -0
- package/dist/scene-artifact-validation.d.ts +20 -0
- package/dist/scene-artifact-validation.d.ts.map +1 -0
- package/dist/scene-artifact-validation.js +1402 -0
- package/dist/scene-artifact-validation.js.map +1 -0
- package/dist/static-shadow-artifact.d.ts +131 -0
- package/dist/static-shadow-artifact.d.ts.map +1 -0
- package/dist/static-shadow-artifact.js +327 -0
- package/dist/static-shadow-artifact.js.map +1 -0
- package/package.json +51 -1
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
import { Camera } from '@babylonjs/core/Cameras/camera.js';
|
|
2
|
+
import { CascadedShadowGenerator } from '@babylonjs/core/Lights/Shadows/cascadedShadowGenerator.js';
|
|
3
|
+
import { ShadowGenerator } from '@babylonjs/core/Lights/Shadows/shadowGenerator.js';
|
|
4
|
+
import './shadow-generator-shaders.js';
|
|
5
|
+
import { Matrix, Vector3 } from '@babylonjs/core/Maths/math.vector.js';
|
|
6
|
+
import '@babylonjs/core/Lights/Shadows/shadowGeneratorSceneComponent.js';
|
|
7
|
+
const DEFAULT_DYNAMIC_SHADOW_PARAMS = {
|
|
8
|
+
opacity: 0.42,
|
|
9
|
+
softness: 0.4,
|
|
10
|
+
bias: 0.001,
|
|
11
|
+
normalBias: 0.01,
|
|
12
|
+
maxDistance: 48,
|
|
13
|
+
resolution: 1024,
|
|
14
|
+
cascadeCount: 2,
|
|
15
|
+
blurKernel: 4,
|
|
16
|
+
};
|
|
17
|
+
export function createDynamicShadowSystem(scene, directionalLight, options = {}) {
|
|
18
|
+
return new BabylonDynamicShadowSystem(scene, directionalLight, options);
|
|
19
|
+
}
|
|
20
|
+
class BabylonDynamicShadowSystem {
|
|
21
|
+
scene;
|
|
22
|
+
directionalLight;
|
|
23
|
+
options;
|
|
24
|
+
shadowGenerator = null;
|
|
25
|
+
casters = new Set();
|
|
26
|
+
receivers = new Map();
|
|
27
|
+
receiverStates = new Map();
|
|
28
|
+
renderObserver = null;
|
|
29
|
+
initialized = false;
|
|
30
|
+
diagnostics;
|
|
31
|
+
previousSceneShadowsEnabled = null;
|
|
32
|
+
previousLightShadowEnabled = null;
|
|
33
|
+
previousLightAutoUpdateExtends = null;
|
|
34
|
+
previousLightPosition = null;
|
|
35
|
+
previousLightFrustum = null;
|
|
36
|
+
useCsmExplicit = false;
|
|
37
|
+
constructor(scene, directionalLight, options) {
|
|
38
|
+
this.scene = scene;
|
|
39
|
+
this.directionalLight = directionalLight;
|
|
40
|
+
this.useCsmExplicit = hasExplicitUseCsm(options);
|
|
41
|
+
this.options = resolveDynamicShadowOptions(options);
|
|
42
|
+
this.diagnostics = this.createDiagnostics(null, []);
|
|
43
|
+
}
|
|
44
|
+
initialize() {
|
|
45
|
+
if (this.initialized || !this.options.enabled)
|
|
46
|
+
return;
|
|
47
|
+
try {
|
|
48
|
+
this.previousSceneShadowsEnabled = this.scene.shadowsEnabled;
|
|
49
|
+
this.previousLightShadowEnabled = this.directionalLight.shadowEnabled;
|
|
50
|
+
this.previousLightAutoUpdateExtends = this.directionalLight.autoUpdateExtends;
|
|
51
|
+
this.previousLightPosition = this.options.fitStrategy === 'receiver-projected'
|
|
52
|
+
? this.directionalLight.position.clone()
|
|
53
|
+
: null;
|
|
54
|
+
this.previousLightFrustum = {
|
|
55
|
+
left: this.directionalLight.orthoLeft,
|
|
56
|
+
right: this.directionalLight.orthoRight,
|
|
57
|
+
top: this.directionalLight.orthoTop,
|
|
58
|
+
bottom: this.directionalLight.orthoBottom,
|
|
59
|
+
minZ: this.directionalLight.shadowMinZ,
|
|
60
|
+
maxZ: this.directionalLight.shadowMaxZ,
|
|
61
|
+
};
|
|
62
|
+
this.scene.shadowsEnabled = true;
|
|
63
|
+
this.directionalLight.shadowEnabled = true;
|
|
64
|
+
this.directionalLight.autoUpdateExtends = false;
|
|
65
|
+
this.ensureShadowGenerator();
|
|
66
|
+
this.renderObserver = this.scene.onBeforeRenderObservable.add(() => this.refresh());
|
|
67
|
+
this.initialized = true;
|
|
68
|
+
this.refresh();
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
this.dispose();
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
addCaster(mesh) {
|
|
76
|
+
if (isDisposed(mesh))
|
|
77
|
+
return false;
|
|
78
|
+
this.casters.add(mesh);
|
|
79
|
+
if (!this.options.enabled || !this.initialized)
|
|
80
|
+
return true;
|
|
81
|
+
this.shadowGenerator?.addShadowCaster(mesh, true);
|
|
82
|
+
this.refresh();
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
removeCaster(mesh) {
|
|
86
|
+
this.casters.delete(mesh);
|
|
87
|
+
this.shadowGenerator?.removeShadowCaster(mesh, true);
|
|
88
|
+
this.refresh();
|
|
89
|
+
}
|
|
90
|
+
addReceiver(mesh) {
|
|
91
|
+
if (isDisposed(mesh))
|
|
92
|
+
return;
|
|
93
|
+
if (!this.receivers.has(mesh)) {
|
|
94
|
+
this.receivers.set(mesh, createReceiverInfo(mesh, this.receiverStates));
|
|
95
|
+
}
|
|
96
|
+
if (!this.options.enabled || !this.initialized)
|
|
97
|
+
return;
|
|
98
|
+
activateReceiverInfo(this.receivers.get(mesh));
|
|
99
|
+
this.refresh();
|
|
100
|
+
}
|
|
101
|
+
removeReceiver(mesh) {
|
|
102
|
+
const info = this.receivers.get(mesh);
|
|
103
|
+
if (info)
|
|
104
|
+
releaseReceiverInfo(info, this.receiverStates);
|
|
105
|
+
this.receivers.delete(mesh);
|
|
106
|
+
this.refresh();
|
|
107
|
+
}
|
|
108
|
+
setCamera(camera) {
|
|
109
|
+
this.options = {
|
|
110
|
+
...this.options,
|
|
111
|
+
camera,
|
|
112
|
+
};
|
|
113
|
+
if (this.shadowGenerator)
|
|
114
|
+
this.shadowGenerator.camera = camera;
|
|
115
|
+
this.refresh();
|
|
116
|
+
}
|
|
117
|
+
setOptions(options) {
|
|
118
|
+
const previous = this.options;
|
|
119
|
+
if (hasExplicitUseCsm(options))
|
|
120
|
+
this.useCsmExplicit = true;
|
|
121
|
+
this.options = resolveDynamicShadowOptions(options, this.options, this.useCsmExplicit);
|
|
122
|
+
if (this.initialized && previous.fitStrategy !== this.options.fitStrategy) {
|
|
123
|
+
if (this.options.fitStrategy === 'receiver-projected') {
|
|
124
|
+
this.previousLightPosition = this.directionalLight.position.clone();
|
|
125
|
+
}
|
|
126
|
+
else if (this.previousLightPosition) {
|
|
127
|
+
this.directionalLight.position.copyFrom(this.previousLightPosition);
|
|
128
|
+
this.previousLightPosition = null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (previous.enabled && !this.options.enabled) {
|
|
132
|
+
this.dispose();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const generatorNeedsRecreate = previous.params.resolution !== this.options.params.resolution
|
|
136
|
+
|| previous.params.cascadeCount !== this.options.params.cascadeCount
|
|
137
|
+
|| previous.useCsm !== this.options.useCsm;
|
|
138
|
+
if (generatorNeedsRecreate && this.initialized)
|
|
139
|
+
this.recreateShadowGenerator();
|
|
140
|
+
else if (this.shadowGenerator)
|
|
141
|
+
this.shadowGenerator.camera = this.options.camera ?? null;
|
|
142
|
+
if (!previous.enabled && this.options.enabled)
|
|
143
|
+
this.initialize();
|
|
144
|
+
else
|
|
145
|
+
this.refresh();
|
|
146
|
+
}
|
|
147
|
+
refresh() {
|
|
148
|
+
if (!this.options.enabled || !this.initialized)
|
|
149
|
+
return;
|
|
150
|
+
this.pruneDisposedEntries();
|
|
151
|
+
const generator = this.ensureShadowGenerator();
|
|
152
|
+
if (!generator) {
|
|
153
|
+
this.diagnostics = this.createDiagnostics(null, ['shadow generator unavailable']);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
this.applyGeneratorParams(this.options.params);
|
|
157
|
+
this.syncShadowMapRenderList();
|
|
158
|
+
for (const receiver of this.receivers.values())
|
|
159
|
+
activateReceiverInfo(receiver);
|
|
160
|
+
const fit = this.fitDirectionalLightBounds();
|
|
161
|
+
this.diagnostics = this.createDiagnostics(fit, []);
|
|
162
|
+
}
|
|
163
|
+
getShadowGenerator() {
|
|
164
|
+
return this.shadowGenerator;
|
|
165
|
+
}
|
|
166
|
+
getDiagnostics() {
|
|
167
|
+
return cloneDynamicShadowDiagnostics(this.diagnostics);
|
|
168
|
+
}
|
|
169
|
+
dispose() {
|
|
170
|
+
if (this.renderObserver) {
|
|
171
|
+
this.scene.onBeforeRenderObservable.remove(this.renderObserver);
|
|
172
|
+
this.renderObserver = null;
|
|
173
|
+
}
|
|
174
|
+
for (const receiver of this.receivers.values())
|
|
175
|
+
releaseReceiverInfo(receiver, this.receiverStates);
|
|
176
|
+
this.receiverStates.clear();
|
|
177
|
+
this.receivers.clear();
|
|
178
|
+
this.casters.clear();
|
|
179
|
+
this.shadowGenerator?.dispose();
|
|
180
|
+
this.shadowGenerator = null;
|
|
181
|
+
if (this.previousSceneShadowsEnabled !== null) {
|
|
182
|
+
this.scene.shadowsEnabled = this.previousSceneShadowsEnabled;
|
|
183
|
+
this.previousSceneShadowsEnabled = null;
|
|
184
|
+
}
|
|
185
|
+
if (this.previousLightShadowEnabled !== null) {
|
|
186
|
+
this.directionalLight.shadowEnabled = this.previousLightShadowEnabled;
|
|
187
|
+
this.previousLightShadowEnabled = null;
|
|
188
|
+
}
|
|
189
|
+
if (this.previousLightAutoUpdateExtends !== null) {
|
|
190
|
+
this.directionalLight.autoUpdateExtends = this.previousLightAutoUpdateExtends;
|
|
191
|
+
this.previousLightAutoUpdateExtends = null;
|
|
192
|
+
}
|
|
193
|
+
if (this.previousLightPosition) {
|
|
194
|
+
this.directionalLight.position.copyFrom(this.previousLightPosition);
|
|
195
|
+
this.previousLightPosition = null;
|
|
196
|
+
}
|
|
197
|
+
if (this.previousLightFrustum) {
|
|
198
|
+
this.directionalLight.orthoLeft = this.previousLightFrustum.left;
|
|
199
|
+
this.directionalLight.orthoRight = this.previousLightFrustum.right;
|
|
200
|
+
this.directionalLight.orthoTop = this.previousLightFrustum.top;
|
|
201
|
+
this.directionalLight.orthoBottom = this.previousLightFrustum.bottom;
|
|
202
|
+
this.directionalLight.shadowMinZ = this.previousLightFrustum.minZ;
|
|
203
|
+
this.directionalLight.shadowMaxZ = this.previousLightFrustum.maxZ;
|
|
204
|
+
this.previousLightFrustum = null;
|
|
205
|
+
}
|
|
206
|
+
this.initialized = false;
|
|
207
|
+
this.diagnostics = this.createDiagnostics(null, []);
|
|
208
|
+
}
|
|
209
|
+
ensureShadowGenerator() {
|
|
210
|
+
if (this.shadowGenerator)
|
|
211
|
+
return this.shadowGenerator;
|
|
212
|
+
const params = this.options.params;
|
|
213
|
+
if (this.options.useCsm && params.cascadeCount > 1 && CascadedShadowGenerator.IsSupported) {
|
|
214
|
+
const generator = new CascadedShadowGenerator(params.resolution, this.directionalLight, undefined, this.options.camera ?? undefined);
|
|
215
|
+
generator.numCascades = params.cascadeCount;
|
|
216
|
+
generator.stabilizeCascades = true;
|
|
217
|
+
this.shadowGenerator = generator;
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
this.shadowGenerator = new ShadowGenerator(params.resolution, this.directionalLight, undefined, this.options.camera ?? undefined);
|
|
221
|
+
}
|
|
222
|
+
this.applyGeneratorParams(params);
|
|
223
|
+
return this.shadowGenerator;
|
|
224
|
+
}
|
|
225
|
+
recreateShadowGenerator() {
|
|
226
|
+
const existingCasters = [...this.casters];
|
|
227
|
+
this.shadowGenerator?.dispose();
|
|
228
|
+
this.shadowGenerator = null;
|
|
229
|
+
const generator = this.ensureShadowGenerator();
|
|
230
|
+
for (const caster of existingCasters) {
|
|
231
|
+
generator?.addShadowCaster(caster, true);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
applyGeneratorParams(params) {
|
|
235
|
+
const generator = this.shadowGenerator;
|
|
236
|
+
if (!generator)
|
|
237
|
+
return;
|
|
238
|
+
generator.useBlurExponentialShadowMap = false;
|
|
239
|
+
generator.useKernelBlur = false;
|
|
240
|
+
generator.usePercentageCloserFiltering = true;
|
|
241
|
+
generator.filteringQuality = ShadowGenerator.QUALITY_HIGH;
|
|
242
|
+
generator.setDarkness(clamp01(1 - params.opacity));
|
|
243
|
+
generator.bias = params.bias;
|
|
244
|
+
generator.normalBias = params.normalBias;
|
|
245
|
+
if (generator instanceof CascadedShadowGenerator) {
|
|
246
|
+
generator.numCascades = params.cascadeCount;
|
|
247
|
+
generator.shadowMaxZ = params.maxDistance;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
syncShadowMapRenderList() {
|
|
251
|
+
const renderList = this.shadowGenerator?.getShadowMap?.()?.renderList;
|
|
252
|
+
if (!renderList)
|
|
253
|
+
return;
|
|
254
|
+
renderList.length = 0;
|
|
255
|
+
for (const caster of this.casters) {
|
|
256
|
+
if (!isDisposed(caster)) {
|
|
257
|
+
this.shadowGenerator?.addShadowCaster(caster, true);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
fitDirectionalLightBounds() {
|
|
262
|
+
if (this.options.fitStrategy === 'receiver-projected') {
|
|
263
|
+
return this.fitReceiverProjectedDirectionalLightBounds();
|
|
264
|
+
}
|
|
265
|
+
const params = this.options.params;
|
|
266
|
+
const points = this.collectCoveragePoints(params);
|
|
267
|
+
if (points.length === 0)
|
|
268
|
+
return null;
|
|
269
|
+
const worldBounds = boundsFromPoints(points);
|
|
270
|
+
const viewMatrix = createShadowViewMatrix(this.directionalLight);
|
|
271
|
+
const lightPoints = points.map(point => Vector3.TransformCoordinates(point, viewMatrix));
|
|
272
|
+
const lightBounds = boundsFromPoints(lightPoints);
|
|
273
|
+
const padding = readPositiveNumber(this.options.boundsPadding, Math.max(0.5, params.maxDistance * 0.025));
|
|
274
|
+
const rawLeft = lightBounds.min.x - padding;
|
|
275
|
+
const rawRight = lightBounds.max.x + padding;
|
|
276
|
+
const rawBottom = lightBounds.min.y - padding;
|
|
277
|
+
const rawTop = lightBounds.max.y + padding;
|
|
278
|
+
const width = Math.max(1e-4, rawRight - rawLeft);
|
|
279
|
+
const height = Math.max(1e-4, rawTop - rawBottom);
|
|
280
|
+
const texelSize = Math.max(width, height) / params.resolution;
|
|
281
|
+
const bounds = this.options.stableSnapping === false || texelSize <= 0
|
|
282
|
+
? {
|
|
283
|
+
left: rawLeft,
|
|
284
|
+
right: rawRight,
|
|
285
|
+
bottom: rawBottom,
|
|
286
|
+
top: rawTop,
|
|
287
|
+
minZ: lightBounds.min.z - padding,
|
|
288
|
+
maxZ: lightBounds.max.z + padding,
|
|
289
|
+
}
|
|
290
|
+
: {
|
|
291
|
+
left: Math.floor(rawLeft / texelSize) * texelSize,
|
|
292
|
+
right: Math.ceil(rawRight / texelSize) * texelSize,
|
|
293
|
+
bottom: Math.floor(rawBottom / texelSize) * texelSize,
|
|
294
|
+
top: Math.ceil(rawTop / texelSize) * texelSize,
|
|
295
|
+
minZ: Math.floor((lightBounds.min.z - padding) / texelSize) * texelSize,
|
|
296
|
+
maxZ: Math.ceil((lightBounds.max.z + padding) / texelSize) * texelSize,
|
|
297
|
+
};
|
|
298
|
+
this.directionalLight.orthoLeft = bounds.left;
|
|
299
|
+
this.directionalLight.orthoRight = bounds.right;
|
|
300
|
+
this.directionalLight.orthoBottom = bounds.bottom;
|
|
301
|
+
this.directionalLight.orthoTop = bounds.top;
|
|
302
|
+
this.directionalLight.shadowMinZ = bounds.minZ;
|
|
303
|
+
this.directionalLight.shadowMaxZ = Math.max(this.directionalLight.shadowMinZ + 1, bounds.maxZ);
|
|
304
|
+
return {
|
|
305
|
+
world: {
|
|
306
|
+
min: serializeVec3(worldBounds.min),
|
|
307
|
+
max: serializeVec3(worldBounds.max),
|
|
308
|
+
},
|
|
309
|
+
lightOrtho: {
|
|
310
|
+
left: bounds.left,
|
|
311
|
+
right: bounds.right,
|
|
312
|
+
bottom: bounds.bottom,
|
|
313
|
+
top: bounds.top,
|
|
314
|
+
minZ: this.directionalLight.shadowMinZ,
|
|
315
|
+
maxZ: this.directionalLight.shadowMaxZ,
|
|
316
|
+
},
|
|
317
|
+
texelSize,
|
|
318
|
+
cameraProjection: readCameraProjection(this.options.camera),
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
fitReceiverProjectedDirectionalLightBounds() {
|
|
322
|
+
const params = this.options.params;
|
|
323
|
+
const direction = readLightDirection(this.directionalLight.getShadowDirection(0));
|
|
324
|
+
const casterBounds = [...this.casters]
|
|
325
|
+
.filter(caster => !isDisposed(caster))
|
|
326
|
+
.map(readMeshWorldBounds);
|
|
327
|
+
const receiverBounds = [...this.receivers.keys()]
|
|
328
|
+
.filter(receiver => !isDisposed(receiver))
|
|
329
|
+
.map(readMeshWorldBounds);
|
|
330
|
+
const points = [];
|
|
331
|
+
for (const bounds of casterBounds) {
|
|
332
|
+
points.push(...createBoundsCorners(bounds.min, bounds.max));
|
|
333
|
+
for (const receiver of receiverBounds) {
|
|
334
|
+
points.push(...projectBoundsOntoReceiver(bounds, receiver, direction));
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (points.length === 0)
|
|
338
|
+
return null;
|
|
339
|
+
const worldBounds = boundsFromPoints(points);
|
|
340
|
+
const center = worldBounds.min.add(worldBounds.max).scale(0.5);
|
|
341
|
+
const size = worldBounds.max.subtract(worldBounds.min);
|
|
342
|
+
const maxExtent = Math.max(size.x, size.y, size.z);
|
|
343
|
+
const padding = readPositiveNumber(this.options.boundsPadding, Math.max(2, maxExtent * 0.25));
|
|
344
|
+
const halfSize = Math.max(4, maxExtent * 0.5 + padding);
|
|
345
|
+
const distance = Math.max(16, maxExtent + padding * 3);
|
|
346
|
+
this.directionalLight.position.copyFrom(center.subtract(direction.scale(distance)));
|
|
347
|
+
const bounds = {
|
|
348
|
+
left: -halfSize,
|
|
349
|
+
right: halfSize,
|
|
350
|
+
bottom: -halfSize,
|
|
351
|
+
top: halfSize,
|
|
352
|
+
minZ: 0.1,
|
|
353
|
+
maxZ: Math.max(32, distance + maxExtent + padding),
|
|
354
|
+
};
|
|
355
|
+
this.directionalLight.orthoLeft = bounds.left;
|
|
356
|
+
this.directionalLight.orthoRight = bounds.right;
|
|
357
|
+
this.directionalLight.orthoBottom = bounds.bottom;
|
|
358
|
+
this.directionalLight.orthoTop = bounds.top;
|
|
359
|
+
this.directionalLight.shadowMinZ = bounds.minZ;
|
|
360
|
+
this.directionalLight.shadowMaxZ = bounds.maxZ;
|
|
361
|
+
return {
|
|
362
|
+
world: {
|
|
363
|
+
min: serializeVec3(worldBounds.min),
|
|
364
|
+
max: serializeVec3(worldBounds.max),
|
|
365
|
+
},
|
|
366
|
+
lightOrtho: bounds,
|
|
367
|
+
texelSize: (halfSize * 2) / params.resolution,
|
|
368
|
+
cameraProjection: 'none',
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
collectCoveragePoints(params) {
|
|
372
|
+
const points = [];
|
|
373
|
+
const lightDirection = readLightDirection(this.directionalLight.getShadowDirection(0));
|
|
374
|
+
const shadowOffset = lightDirection.scale(params.maxDistance);
|
|
375
|
+
for (const caster of this.casters) {
|
|
376
|
+
points.push(...readMeshBoundsCorners(caster));
|
|
377
|
+
for (const corner of readMeshBoundsCorners(caster))
|
|
378
|
+
points.push(corner.add(shadowOffset));
|
|
379
|
+
}
|
|
380
|
+
for (const receiver of this.receivers.keys())
|
|
381
|
+
points.push(...readMeshBoundsCorners(receiver));
|
|
382
|
+
points.push(...readCameraCoveragePoints(this.options.camera, this.scene, params.maxDistance));
|
|
383
|
+
return points.filter(point => Number.isFinite(point.x) && Number.isFinite(point.y) && Number.isFinite(point.z));
|
|
384
|
+
}
|
|
385
|
+
pruneDisposedEntries() {
|
|
386
|
+
for (const caster of [...this.casters]) {
|
|
387
|
+
if (isDisposed(caster))
|
|
388
|
+
this.casters.delete(caster);
|
|
389
|
+
}
|
|
390
|
+
for (const [receiver, info] of [...this.receivers]) {
|
|
391
|
+
if (isDisposed(receiver)) {
|
|
392
|
+
releaseReceiverInfo(info, this.receiverStates);
|
|
393
|
+
this.receivers.delete(receiver);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
createDiagnostics(bounds, fallbackReasons) {
|
|
398
|
+
const generator = this.shadowGenerator;
|
|
399
|
+
const renderList = generator?.getShadowMap?.()?.renderList ?? [];
|
|
400
|
+
return {
|
|
401
|
+
enabled: this.options.enabled,
|
|
402
|
+
casterCount: this.casters.size,
|
|
403
|
+
receiverCount: this.receivers.size,
|
|
404
|
+
generator: generator
|
|
405
|
+
? {
|
|
406
|
+
className: generator.getClassName?.() ?? null,
|
|
407
|
+
mapSize: generator.getShadowMap?.()?.getSize?.() ?? null,
|
|
408
|
+
darkness: generator.getDarkness?.() ?? null,
|
|
409
|
+
bias: generator.bias ?? null,
|
|
410
|
+
normalBias: generator.normalBias ?? null,
|
|
411
|
+
blurKernel: generator.blurKernel ?? null,
|
|
412
|
+
renderListCount: renderList.length,
|
|
413
|
+
useCsm: generator instanceof CascadedShadowGenerator,
|
|
414
|
+
}
|
|
415
|
+
: null,
|
|
416
|
+
params: { ...this.options.params },
|
|
417
|
+
bounds,
|
|
418
|
+
fallbackReasons,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function resolveDynamicShadowOptions(options, fallback, preserveFallbackUseCsm = false) {
|
|
423
|
+
const params = resolveDynamicShadowParams(options.params, fallback?.params);
|
|
424
|
+
return {
|
|
425
|
+
enabled: options.enabled ?? fallback?.enabled ?? true,
|
|
426
|
+
camera: options.camera ?? fallback?.camera ?? null,
|
|
427
|
+
params,
|
|
428
|
+
useCsm: options.useCsm ?? (preserveFallbackUseCsm ? fallback?.useCsm : undefined) ?? params.cascadeCount > 1,
|
|
429
|
+
fitStrategy: options.fitStrategy ?? fallback?.fitStrategy ?? 'light-space',
|
|
430
|
+
boundsPadding: options.boundsPadding ?? fallback?.boundsPadding,
|
|
431
|
+
stableSnapping: options.stableSnapping ?? fallback?.stableSnapping ?? true,
|
|
432
|
+
debug: options.debug ?? fallback?.debug ?? false,
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
function hasExplicitUseCsm(options) {
|
|
436
|
+
return Object.prototype.hasOwnProperty.call(options, 'useCsm') && typeof options.useCsm === 'boolean';
|
|
437
|
+
}
|
|
438
|
+
export function resolveDynamicShadowParams(params, fallback = DEFAULT_DYNAMIC_SHADOW_PARAMS) {
|
|
439
|
+
return {
|
|
440
|
+
opacity: clamp01(readFiniteNumber(params?.opacity, fallback.opacity)),
|
|
441
|
+
softness: clamp01(readFiniteNumber(params?.softness, fallback.softness)),
|
|
442
|
+
bias: readFiniteNumber(params?.bias, fallback.bias),
|
|
443
|
+
normalBias: readFiniteNumber(params?.normalBias, fallback.normalBias),
|
|
444
|
+
maxDistance: readPositiveNumber(params?.maxDistance, fallback.maxDistance),
|
|
445
|
+
resolution: readShadowResolution(params?.resolution, fallback.resolution),
|
|
446
|
+
cascadeCount: readCascadeCount(params?.cascadeCount, fallback.cascadeCount),
|
|
447
|
+
blurKernel: Math.max(0, Math.round(readFiniteNumber(params?.blurKernel, fallback.blurKernel))),
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
function createReceiverInfo(mesh, receiverStates) {
|
|
451
|
+
const trackedMeshes = [mesh];
|
|
452
|
+
const sourceMesh = mesh.sourceMesh;
|
|
453
|
+
if (sourceMesh && sourceMesh !== mesh)
|
|
454
|
+
trackedMeshes.push(sourceMesh);
|
|
455
|
+
for (const trackedMesh of trackedMeshes)
|
|
456
|
+
acquireReceiverState(trackedMesh, receiverStates);
|
|
457
|
+
return { mesh, trackedMeshes };
|
|
458
|
+
}
|
|
459
|
+
function activateReceiverInfo(info) {
|
|
460
|
+
if (!info)
|
|
461
|
+
return;
|
|
462
|
+
for (const mesh of info.trackedMeshes)
|
|
463
|
+
mesh.receiveShadows = true;
|
|
464
|
+
}
|
|
465
|
+
function acquireReceiverState(mesh, receiverStates) {
|
|
466
|
+
const existing = receiverStates.get(mesh);
|
|
467
|
+
if (existing) {
|
|
468
|
+
existing.refCount += 1;
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
receiverStates.set(mesh, {
|
|
472
|
+
mesh,
|
|
473
|
+
previousReceiveShadows: mesh.receiveShadows,
|
|
474
|
+
refCount: 1,
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
function releaseReceiverInfo(info, receiverStates) {
|
|
478
|
+
for (const mesh of info.trackedMeshes)
|
|
479
|
+
releaseReceiverState(mesh, receiverStates);
|
|
480
|
+
}
|
|
481
|
+
function releaseReceiverState(mesh, receiverStates) {
|
|
482
|
+
const state = receiverStates.get(mesh);
|
|
483
|
+
if (!state)
|
|
484
|
+
return;
|
|
485
|
+
state.refCount -= 1;
|
|
486
|
+
if (state.refCount > 0)
|
|
487
|
+
return;
|
|
488
|
+
state.mesh.receiveShadows = state.previousReceiveShadows;
|
|
489
|
+
receiverStates.delete(mesh);
|
|
490
|
+
}
|
|
491
|
+
function readMeshBoundsCorners(mesh) {
|
|
492
|
+
if (isDisposed(mesh))
|
|
493
|
+
return [];
|
|
494
|
+
mesh.computeWorldMatrix(true);
|
|
495
|
+
const bounds = mesh.getHierarchyBoundingVectors(true);
|
|
496
|
+
return createBoundsCorners(bounds.min, bounds.max);
|
|
497
|
+
}
|
|
498
|
+
function readCameraCoveragePoints(camera, scene, maxDistance) {
|
|
499
|
+
if (!camera)
|
|
500
|
+
return [];
|
|
501
|
+
const position = camera.globalPosition ?? camera.position;
|
|
502
|
+
if (!position)
|
|
503
|
+
return [];
|
|
504
|
+
const forward = safeCameraDirection(camera, Vector3.Forward(), new Vector3(0, 0, 1));
|
|
505
|
+
const right = safeCameraDirection(camera, Vector3.Right(), new Vector3(1, 0, 0));
|
|
506
|
+
const up = safeCameraDirection(camera, Vector3.Up(), new Vector3(0, 1, 0));
|
|
507
|
+
const farDistance = Math.max(1, Math.min(maxDistance, readPositiveNumber(camera.maxZ, maxDistance)));
|
|
508
|
+
const nearDistance = Math.max(0.1, Math.min(farDistance, readPositiveNumber(camera.minZ, 0.1)));
|
|
509
|
+
const aspect = readSceneAspect(scene);
|
|
510
|
+
if (camera.mode === Camera.ORTHOGRAPHIC_CAMERA) {
|
|
511
|
+
const halfHeight = Math.max(0.5, Math.abs(readFiniteNumber(camera.orthoTop, 1) - readFiniteNumber(camera.orthoBottom, -1)) * 0.5);
|
|
512
|
+
const halfWidth = Math.max(0.5, Math.abs(readFiniteNumber(camera.orthoRight, aspect) - readFiniteNumber(camera.orthoLeft, -aspect)) * 0.5);
|
|
513
|
+
return [
|
|
514
|
+
...createCameraPlaneCorners(position.add(forward.scale(nearDistance)), right, up, halfWidth, halfHeight),
|
|
515
|
+
...createCameraPlaneCorners(position.add(forward.scale(farDistance)), right, up, halfWidth, halfHeight),
|
|
516
|
+
];
|
|
517
|
+
}
|
|
518
|
+
const fov = readPositiveNumber(camera.fov, 0.8);
|
|
519
|
+
const farHalfHeight = Math.tan(fov * 0.5) * farDistance;
|
|
520
|
+
const farHalfWidth = farHalfHeight * aspect;
|
|
521
|
+
const nearHalfHeight = Math.tan(fov * 0.5) * nearDistance;
|
|
522
|
+
const nearHalfWidth = nearHalfHeight * aspect;
|
|
523
|
+
return [
|
|
524
|
+
...createCameraPlaneCorners(position.add(forward.scale(nearDistance)), right, up, nearHalfWidth, nearHalfHeight),
|
|
525
|
+
...createCameraPlaneCorners(position.add(forward.scale(farDistance)), right, up, farHalfWidth, farHalfHeight),
|
|
526
|
+
];
|
|
527
|
+
}
|
|
528
|
+
function createCameraPlaneCorners(center, right, up, halfWidth, halfHeight) {
|
|
529
|
+
return [
|
|
530
|
+
center.add(right.scale(-halfWidth)).add(up.scale(-halfHeight)),
|
|
531
|
+
center.add(right.scale(halfWidth)).add(up.scale(-halfHeight)),
|
|
532
|
+
center.add(right.scale(halfWidth)).add(up.scale(halfHeight)),
|
|
533
|
+
center.add(right.scale(-halfWidth)).add(up.scale(halfHeight)),
|
|
534
|
+
];
|
|
535
|
+
}
|
|
536
|
+
function createShadowViewMatrix(light) {
|
|
537
|
+
let lightPosition = light.position;
|
|
538
|
+
if (light.computeTransformedInformation()) {
|
|
539
|
+
lightPosition = light.transformedPosition;
|
|
540
|
+
}
|
|
541
|
+
const lightDirection = readLightDirection(light.getShadowDirection(0));
|
|
542
|
+
if (Math.abs(Vector3.Dot(lightDirection, Vector3.Up())) === 1) {
|
|
543
|
+
lightDirection.z = 1e-13;
|
|
544
|
+
}
|
|
545
|
+
return Matrix.LookAtLH(lightPosition, lightPosition.add(lightDirection), Vector3.Up());
|
|
546
|
+
}
|
|
547
|
+
function boundsFromPoints(points) {
|
|
548
|
+
const min = new Vector3(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
|
|
549
|
+
const max = new Vector3(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY);
|
|
550
|
+
for (const point of points) {
|
|
551
|
+
min.minimizeInPlace(point);
|
|
552
|
+
max.maximizeInPlace(point);
|
|
553
|
+
}
|
|
554
|
+
return { min, max };
|
|
555
|
+
}
|
|
556
|
+
function createBoundsCorners(min, max) {
|
|
557
|
+
return [
|
|
558
|
+
new Vector3(min.x, min.y, min.z),
|
|
559
|
+
new Vector3(max.x, min.y, min.z),
|
|
560
|
+
new Vector3(max.x, max.y, min.z),
|
|
561
|
+
new Vector3(min.x, max.y, min.z),
|
|
562
|
+
new Vector3(min.x, min.y, max.z),
|
|
563
|
+
new Vector3(max.x, min.y, max.z),
|
|
564
|
+
new Vector3(max.x, max.y, max.z),
|
|
565
|
+
new Vector3(min.x, max.y, max.z),
|
|
566
|
+
];
|
|
567
|
+
}
|
|
568
|
+
function readMeshWorldBounds(mesh) {
|
|
569
|
+
mesh.computeWorldMatrix(true);
|
|
570
|
+
const bounds = mesh.getBoundingInfo().boundingBox;
|
|
571
|
+
return { min: bounds.minimumWorld.clone(), max: bounds.maximumWorld.clone() };
|
|
572
|
+
}
|
|
573
|
+
function projectBoundsOntoReceiver(caster, receiver, direction) {
|
|
574
|
+
const receiverY = receiver.max.y;
|
|
575
|
+
if (Math.abs(direction.y) < 1e-6)
|
|
576
|
+
return [];
|
|
577
|
+
return createBoundsCorners(caster.min, caster.max).flatMap(point => {
|
|
578
|
+
const distance = (receiverY - point.y) / direction.y;
|
|
579
|
+
if (!Number.isFinite(distance))
|
|
580
|
+
return [];
|
|
581
|
+
return [point.add(direction.scale(Math.max(0, distance)))];
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
function safeCameraDirection(camera, localAxis, fallback) {
|
|
585
|
+
try {
|
|
586
|
+
const direction = camera.getDirection(localAxis);
|
|
587
|
+
if (isFiniteVector(direction) && direction.lengthSquared() > 1e-8)
|
|
588
|
+
return direction.normalize();
|
|
589
|
+
}
|
|
590
|
+
catch {
|
|
591
|
+
// Camera direction is best-effort diagnostics input; use a stable fallback.
|
|
592
|
+
}
|
|
593
|
+
return fallback.clone();
|
|
594
|
+
}
|
|
595
|
+
function readLightDirection(direction) {
|
|
596
|
+
return isFiniteVector(direction) && direction.lengthSquared() > 1e-8
|
|
597
|
+
? direction.clone().normalize()
|
|
598
|
+
: new Vector3(-0.3, -1, -0.2).normalize();
|
|
599
|
+
}
|
|
600
|
+
function readCameraProjection(camera) {
|
|
601
|
+
if (!camera)
|
|
602
|
+
return 'none';
|
|
603
|
+
return camera.mode === Camera.ORTHOGRAPHIC_CAMERA ? 'orthographic' : 'perspective';
|
|
604
|
+
}
|
|
605
|
+
function readSceneAspect(scene) {
|
|
606
|
+
const engine = scene.getEngine();
|
|
607
|
+
const width = Math.max(1, engine.getRenderWidth());
|
|
608
|
+
const height = Math.max(1, engine.getRenderHeight());
|
|
609
|
+
return width / height;
|
|
610
|
+
}
|
|
611
|
+
function cloneDynamicShadowDiagnostics(diagnostics) {
|
|
612
|
+
return {
|
|
613
|
+
...diagnostics,
|
|
614
|
+
generator: diagnostics.generator ? { ...diagnostics.generator } : null,
|
|
615
|
+
params: { ...diagnostics.params },
|
|
616
|
+
bounds: diagnostics.bounds
|
|
617
|
+
? {
|
|
618
|
+
world: {
|
|
619
|
+
min: { ...diagnostics.bounds.world.min },
|
|
620
|
+
max: { ...diagnostics.bounds.world.max },
|
|
621
|
+
},
|
|
622
|
+
lightOrtho: { ...diagnostics.bounds.lightOrtho },
|
|
623
|
+
texelSize: diagnostics.bounds.texelSize,
|
|
624
|
+
cameraProjection: diagnostics.bounds.cameraProjection,
|
|
625
|
+
}
|
|
626
|
+
: null,
|
|
627
|
+
fallbackReasons: [...diagnostics.fallbackReasons],
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
function serializeVec3(value) {
|
|
631
|
+
return { x: value.x, y: value.y, z: value.z };
|
|
632
|
+
}
|
|
633
|
+
function isFiniteVector(value) {
|
|
634
|
+
return Number.isFinite(value.x) && Number.isFinite(value.y) && Number.isFinite(value.z);
|
|
635
|
+
}
|
|
636
|
+
function isDisposed(mesh) {
|
|
637
|
+
return typeof mesh.isDisposed === 'function' && mesh.isDisposed();
|
|
638
|
+
}
|
|
639
|
+
function readFiniteNumber(value, fallback) {
|
|
640
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
|
|
641
|
+
}
|
|
642
|
+
function readPositiveNumber(value, fallback) {
|
|
643
|
+
const number = readFiniteNumber(value, fallback);
|
|
644
|
+
return number > 0 ? number : fallback;
|
|
645
|
+
}
|
|
646
|
+
function clamp01(value) {
|
|
647
|
+
if (!Number.isFinite(value))
|
|
648
|
+
return 0;
|
|
649
|
+
return Math.min(1, Math.max(0, value));
|
|
650
|
+
}
|
|
651
|
+
function readShadowResolution(value, fallback) {
|
|
652
|
+
return value === 512 || value === 1024 || value === 2048 || value === 4096
|
|
653
|
+
? value
|
|
654
|
+
: fallback;
|
|
655
|
+
}
|
|
656
|
+
function readCascadeCount(value, fallback) {
|
|
657
|
+
return value === 1 || value === 2 || value === 4 ? value : fallback;
|
|
658
|
+
}
|
|
659
|
+
//# sourceMappingURL=dynamic-shadow-system.js.map
|