@fps-games/editor 0.1.4-beta.5 → 0.1.5-beta.1
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/build-info.json +16 -16
- package/dist/local-editor-harness.d.ts +24 -5
- package/dist/local-editor-harness.d.ts.map +1 -1
- package/dist/local-editor-harness.js +456 -90
- package/dist/local-editor-harness.js.map +1 -1
- package/dist/local-editor-performance-stats.d.ts +12 -0
- package/dist/local-editor-performance-stats.d.ts.map +1 -0
- package/dist/local-editor-performance-stats.js +46 -0
- package/dist/local-editor-performance-stats.js.map +1 -0
- package/dist/playable-babylon-facade.d.ts +2 -2
- package/dist/playable-babylon-facade.d.ts.map +1 -1
- package/dist/playable-babylon-facade.js +1 -1
- package/dist/playable-babylon-facade.js.map +1 -1
- package/dist/playable-babylon-rendering.d.ts +57 -12
- package/dist/playable-babylon-rendering.d.ts.map +1 -1
- package/dist/playable-babylon-rendering.js +529 -20
- package/dist/playable-babylon-rendering.js.map +1 -1
- package/dist/playable-local-editor-host.d.ts +10 -9
- package/dist/playable-local-editor-host.d.ts.map +1 -1
- package/dist/playable-local-editor-host.js.map +1 -1
- package/dist/playable-sdk.d.ts +5 -3
- package/dist/playable-sdk.d.ts.map +1 -1
- package/dist/playable-sdk.js +3 -2
- package/dist/playable-sdk.js.map +1 -1
- package/dist/static-shadow-cpu-worker.d.ts +7 -0
- package/dist/static-shadow-cpu-worker.d.ts.map +1 -0
- package/dist/static-shadow-cpu-worker.js +221 -0
- package/dist/static-shadow-cpu-worker.js.map +1 -0
- package/node_modules/@fps-games/babylon-renderer/dist/index.d.ts +3 -1
- package/node_modules/@fps-games/babylon-renderer/dist/index.d.ts.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/index.js +3 -1
- package/node_modules/@fps-games/babylon-renderer/dist/index.js.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-artifact-system.d.ts +4 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-artifact-system.d.ts.map +1 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-artifact-system.js +584 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-artifact-system.js.map +1 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-atlas.d.ts +61 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-atlas.d.ts.map +1 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-atlas.js +382 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-atlas.js.map +1 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-bake.d.ts +47 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-bake.d.ts.map +1 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-bake.js +285 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-bake.js.map +1 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-baker.d.ts +88 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-baker.d.ts.map +1 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-baker.js +813 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-baker.js.map +1 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-rendering.d.ts +27 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-rendering.d.ts.map +1 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-rendering.js +220 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-rendering.js.map +1 -0
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-system.d.ts +35 -3
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-system.d.ts.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-system.js +65 -609
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-system.js.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/types.d.ts +169 -14
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/types.d.ts.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/types.js +9 -3
- package/node_modules/@fps-games/babylon-renderer/dist/shadows/types.js.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/package.json +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/index.d.ts +2 -0
- package/node_modules/@fps-games/editor-babylon/dist/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/index.js +2 -0
- package/node_modules/@fps-games/editor-babylon/dist/index.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/performance-monitor.d.ts +34 -0
- package/node_modules/@fps-games/editor-babylon/dist/performance-monitor.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/performance-monitor.js +272 -0
- package/node_modules/@fps-games/editor-babylon/dist/performance-monitor.js.map +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/projection.d.ts +6 -0
- package/node_modules/@fps-games/editor-babylon/dist/projection.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/projection.js +65 -1
- package/node_modules/@fps-games/editor-babylon/dist/projection.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/rendering.d.ts +19 -0
- package/node_modules/@fps-games/editor-babylon/dist/rendering.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/rendering.js +66 -0
- package/node_modules/@fps-games/editor-babylon/dist/rendering.js.map +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/shadow-preview-controller.d.ts +5 -2
- package/node_modules/@fps-games/editor-babylon/dist/shadow-preview-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/shadow-preview-controller.js +65 -32
- package/node_modules/@fps-games/editor-babylon/dist/shadow-preview-controller.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.js +19 -2
- package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/package.json +5 -5
- package/node_modules/@fps-games/editor-browser/dist/index.d.ts +1 -1
- package/node_modules/@fps-games/editor-browser/dist/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/index.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-rendering-actions.d.ts +8 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-rendering-actions.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-rendering-actions.js +14 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-rendering-actions.js.map +1 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-tree.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-tree.js +10 -2
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-tree.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.d.ts +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.js +17 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.js +466 -42
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.d.ts +70 -5
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.d.ts +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.js +595 -5
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/package.json +3 -3
- package/node_modules/@fps-games/editor-core/dist/editor-session.d.ts +14 -1
- package/node_modules/@fps-games/editor-core/dist/editor-session.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/editor-session.js +34 -10
- package/node_modules/@fps-games/editor-core/dist/editor-session.js.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/inspector.d.ts +2 -1
- package/node_modules/@fps-games/editor-core/dist/inspector.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/inspector.js +11 -1
- package/node_modules/@fps-games/editor-core/dist/inspector.js.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/serialized-object.d.ts +7 -0
- package/node_modules/@fps-games/editor-core/dist/serialized-object.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/serialized-object.js +1 -0
- package/node_modules/@fps-games/editor-core/dist/serialized-object.js.map +1 -1
- package/node_modules/@fps-games/editor-core/package.json +2 -2
- package/node_modules/@fps-games/editor-forge-play/package.json +2 -2
- package/node_modules/@fps-games/editor-playable-sdk/dist/asset-placement/document.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/asset-placement/document.js +10 -5
- package/node_modules/@fps-games/editor-playable-sdk/dist/asset-placement/document.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/asset-placement/placement.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/asset-placement/placement.js +3 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/asset-placement/placement.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/document/helpers.d.ts +4 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/document/helpers.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/document/helpers.js +29 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/document/helpers.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/document/types.d.ts +10 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/document/types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/field-schema/schema.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/field-schema/schema.js +3 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/field-schema/schema.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/index.d.ts +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/index.js +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/index.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/inspector/document-sections.d.ts +33 -2
- package/node_modules/@fps-games/editor-playable-sdk/dist/inspector/document-sections.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/inspector/document-sections.js +232 -16
- package/node_modules/@fps-games/editor-playable-sdk/dist/inspector/document-sections.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/inspector/index.d.ts +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/inspector/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/inspector/index.js +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/inspector/index.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/field-patch.d.ts +12 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/field-patch.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/field-patch.js +153 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/field-patch.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/index.d.ts +4 -2
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/index.js +2 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/index.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/reducer.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/reducer.js +4 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/reducer.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/rendering-alpha-index.d.ts +19 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/rendering-alpha-index.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/rendering-alpha-index.js +57 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/rendering-alpha-index.js.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/types.d.ts +7 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/mutation/types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/panel.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/panel.js +620 -36
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/panel.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/profile.d.ts +8 -3
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/profile.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/profile.js +258 -10
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/profile.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/types.d.ts +110 -3
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/runtime-preview/nodes.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/runtime-preview/nodes.js +25 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/runtime-preview/nodes.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/runtime-preview/types.d.ts +2 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/runtime-preview/types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/client.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/client.js +4 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/client.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/companion-configs.d.ts +9 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/companion-configs.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/companion-configs.js +12 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/companion-configs.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/types.d.ts +2 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/descriptors.d.ts +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/descriptors.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/descriptors.js +75 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/descriptors.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/index.d.ts +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/index.js +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/index.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/inspector.d.ts +17 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/inspector.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/inspector.js +262 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/inspector.js.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/object.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/object.js +7 -3
- package/node_modules/@fps-games/editor-playable-sdk/dist/serialized-property/object.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/session/identity.d.ts +6 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/session/identity.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/session/identity.js +31 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/session/identity.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/session/index.d.ts +2 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/session/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/session/index.js +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/session/index.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/session/patches.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/session/patches.js +21 -9
- package/node_modules/@fps-games/editor-playable-sdk/dist/session/patches.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/static-shadows/artifact.d.ts +151 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/static-shadows/artifact.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/static-shadows/artifact.js +445 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/static-shadows/artifact.js.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/static-shadows/index.d.ts +2 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/static-shadows/index.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/static-shadows/index.js +2 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/static-shadows/index.js.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/package.json +3 -3
- package/node_modules/@fps-games/editor-protocol/package.json +1 -1
- package/package.json +8 -8
package/node_modules/@fps-games/babylon-renderer/dist/shadows/static-projected-shadow-system.js
CHANGED
|
@@ -1,363 +1,97 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FreeCamera } from '@babylonjs/core/Cameras/freeCamera.js';
|
|
3
|
-
import { Constants } from '@babylonjs/core/Engines/constants.js';
|
|
4
|
-
import { DirectionalLight } from '@babylonjs/core/Lights/directionalLight.js';
|
|
5
|
-
import { Color3, Color4 } from '@babylonjs/core/Maths/math.color.js';
|
|
6
|
-
import { Vector2, Vector3 } from '@babylonjs/core/Maths/math.vector.js';
|
|
7
|
-
import { Effect } from '@babylonjs/core/Materials/effect.js';
|
|
8
|
-
import { Material } from '@babylonjs/core/Materials/material.js';
|
|
9
|
-
import { ShaderMaterial } from '@babylonjs/core/Materials/shaderMaterial.js';
|
|
10
|
-
import { StandardMaterial } from '@babylonjs/core/Materials/standardMaterial.js';
|
|
11
|
-
import { RenderTargetTexture } from '@babylonjs/core/Materials/Textures/renderTargetTexture.js';
|
|
12
|
-
import { Texture } from '@babylonjs/core/Materials/Textures/texture.js';
|
|
13
|
-
import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh.js';
|
|
14
|
-
import { InstancedMesh } from '@babylonjs/core/Meshes/instancedMesh.js';
|
|
15
|
-
import { Mesh } from '@babylonjs/core/Meshes/mesh.js';
|
|
16
|
-
import { TransformNode } from '@babylonjs/core/Meshes/transformNode.js';
|
|
17
|
-
import { VertexBuffer } from '@babylonjs/core/Buffers/buffer.js';
|
|
18
|
-
import { VertexData } from '@babylonjs/core/Meshes/mesh.vertexData.js';
|
|
1
|
+
import { createStaticProjectedShadowArtifactSystem } from './static-projected-shadow-artifact-system.js';
|
|
19
2
|
import { DEFAULT_STATIC_PROJECTED_SHADOW_OPTIONS, } from './types.js';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.directionalLight = directionalLight;
|
|
31
|
-
this.casters = new Map();
|
|
32
|
-
this.meshAddedObserver = null;
|
|
33
|
-
this.initialized = false;
|
|
34
|
-
this.casterPatterns = [];
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Static projected shadows are artifact-only at runtime. This shim
|
|
5
|
+
* is intentionally not exported from the package barrel; use
|
|
6
|
+
* createStaticProjectedShadowArtifactSystem() instead.
|
|
7
|
+
*/
|
|
8
|
+
export function createStaticProjectedShadowSystem(scene, _directionalLight, options = {}) {
|
|
9
|
+
return new StaticProjectedShadowArtifactOnlyFacade(scene, options);
|
|
10
|
+
}
|
|
11
|
+
class StaticProjectedShadowArtifactOnlyFacade {
|
|
12
|
+
constructor(scene, options) {
|
|
35
13
|
this.options = resolveStaticProjectedShadowOptions(options);
|
|
36
|
-
this.
|
|
14
|
+
this.artifactSystem = createStaticProjectedShadowArtifactSystem(scene, options.artifact ?? null, {
|
|
15
|
+
enabled: this.options.enabled,
|
|
16
|
+
appearance: this.options.appearance,
|
|
17
|
+
bake: {
|
|
18
|
+
blur: this.options.bake.blur,
|
|
19
|
+
},
|
|
20
|
+
debug: this.options.debug,
|
|
21
|
+
});
|
|
37
22
|
}
|
|
38
23
|
initialize() {
|
|
39
|
-
|
|
40
|
-
return;
|
|
41
|
-
this.initialized = true;
|
|
42
|
-
this.refresh();
|
|
24
|
+
this.artifactSystem.initialize();
|
|
43
25
|
}
|
|
44
|
-
addCaster(
|
|
45
|
-
|
|
46
|
-
if (!this.initialized || this.casters.has(root))
|
|
47
|
-
return;
|
|
48
|
-
if (!this.isValidCasterRoot(root))
|
|
49
|
-
return;
|
|
50
|
-
const caster = this.createCaster(root);
|
|
51
|
-
if (caster)
|
|
52
|
-
this.casters.set(root, caster);
|
|
26
|
+
addCaster(_mesh) {
|
|
27
|
+
// Static projected shadows are artifact-only at runtime. Use StaticProjectedShadowBaker during authoring.
|
|
53
28
|
}
|
|
54
|
-
removeCaster(
|
|
55
|
-
|
|
29
|
+
removeCaster(_mesh) {
|
|
30
|
+
// Static projected shadows are artifact-only at runtime. Use setArtifact() to replace displayed chunks.
|
|
56
31
|
}
|
|
57
|
-
invalidateCaster(
|
|
58
|
-
|
|
59
|
-
const wasTracked = this.casters.has(root);
|
|
60
|
-
this.disposeCaster(root);
|
|
61
|
-
if (wasTracked)
|
|
62
|
-
this.addCaster(root);
|
|
32
|
+
invalidateCaster(_mesh) {
|
|
33
|
+
// Runtime invalidation no longer triggers a bake. Re-run the authoring baker and set the artifact instead.
|
|
63
34
|
}
|
|
64
|
-
enableCasterAutoDetection(
|
|
35
|
+
enableCasterAutoDetection(_patterns) {
|
|
65
36
|
this.options = {
|
|
66
37
|
...this.options,
|
|
67
38
|
casters: {
|
|
68
39
|
...this.options.casters,
|
|
69
40
|
autoDetectAll: false,
|
|
70
|
-
includePatterns:
|
|
41
|
+
includePatterns: [],
|
|
71
42
|
},
|
|
72
43
|
};
|
|
73
|
-
this.casterPatterns = [...this.options.casters.includePatterns];
|
|
74
|
-
this.refresh();
|
|
75
|
-
this.ensureMeshObserver();
|
|
76
44
|
}
|
|
77
45
|
enableAutoDetectionForAll() {
|
|
78
46
|
this.options = {
|
|
79
47
|
...this.options,
|
|
80
48
|
casters: {
|
|
81
49
|
...this.options.casters,
|
|
82
|
-
autoDetectAll:
|
|
50
|
+
autoDetectAll: false,
|
|
51
|
+
includePatterns: [],
|
|
83
52
|
},
|
|
84
53
|
};
|
|
85
|
-
this.casterPatterns = [];
|
|
86
|
-
this.refresh();
|
|
87
|
-
this.ensureMeshObserver();
|
|
88
54
|
}
|
|
89
55
|
refresh() {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.tryAutoAddCaster(mesh);
|
|
95
|
-
if (this.options.casters.autoDetectAll || this.casterPatterns.length > 0) {
|
|
96
|
-
this.ensureMeshObserver();
|
|
97
|
-
}
|
|
56
|
+
// Artifact chunks are immutable until setArtifact()/setOptions().
|
|
57
|
+
}
|
|
58
|
+
setArtifact(artifact) {
|
|
59
|
+
this.artifactSystem.setArtifact(artifact ?? null);
|
|
98
60
|
}
|
|
99
61
|
setOptions(options) {
|
|
100
|
-
const wasEnabled = this.options.enabled;
|
|
101
62
|
this.options = resolveStaticProjectedShadowOptions(options, this.options);
|
|
102
|
-
this.
|
|
103
|
-
|
|
104
|
-
this.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this.
|
|
63
|
+
this.artifactSystem.setOptions({
|
|
64
|
+
enabled: this.options.enabled,
|
|
65
|
+
appearance: this.options.appearance,
|
|
66
|
+
bake: {
|
|
67
|
+
blur: this.options.bake.blur,
|
|
68
|
+
},
|
|
69
|
+
debug: this.options.debug,
|
|
70
|
+
});
|
|
71
|
+
if ('artifact' in options)
|
|
72
|
+
this.artifactSystem.setArtifact(options.artifact ?? null);
|
|
109
73
|
}
|
|
110
74
|
getOptions() {
|
|
111
75
|
return cloneResolvedOptions(this.options);
|
|
112
76
|
}
|
|
113
|
-
getCasterInfo(
|
|
114
|
-
|
|
115
|
-
if (!caster)
|
|
116
|
-
return null;
|
|
117
|
-
return {
|
|
118
|
-
source: caster.source,
|
|
119
|
-
shadow: caster.shadow,
|
|
120
|
-
};
|
|
77
|
+
getCasterInfo(_mesh) {
|
|
78
|
+
return null;
|
|
121
79
|
}
|
|
122
80
|
getCasterCount() {
|
|
123
|
-
return
|
|
124
|
-
}
|
|
125
|
-
dispose() {
|
|
126
|
-
if (this.meshAddedObserver) {
|
|
127
|
-
this.scene.onNewMeshAddedObservable.remove(this.meshAddedObserver);
|
|
128
|
-
this.meshAddedObserver = null;
|
|
129
|
-
}
|
|
130
|
-
for (const root of [...this.casters.keys()])
|
|
131
|
-
this.disposeCaster(root);
|
|
132
|
-
this.initialized = false;
|
|
133
|
-
}
|
|
134
|
-
rebuildCasters() {
|
|
135
|
-
const roots = [...this.casters.keys()].filter((root) => !root.isDisposed());
|
|
136
|
-
for (const root of roots)
|
|
137
|
-
this.disposeCaster(root);
|
|
138
|
-
for (const root of roots)
|
|
139
|
-
this.addCaster(root);
|
|
140
|
-
this.refresh();
|
|
141
|
-
}
|
|
142
|
-
createCaster(root) {
|
|
143
|
-
const meshes = collectNodeMeshes(root).filter((mesh) => this.isValidShadowSource(mesh));
|
|
144
|
-
if (meshes.length === 0)
|
|
145
|
-
return null;
|
|
146
|
-
const bounds = buildProjectedBounds(meshes, {
|
|
147
|
-
lightDir: this.resolveShadowDirection(),
|
|
148
|
-
planeY: this.options.plane.height + this.options.plane.yOffset,
|
|
149
|
-
padding: this.options.bake.padding,
|
|
150
|
-
maxSize: this.options.bake.maxSize,
|
|
151
|
-
});
|
|
152
|
-
if (!bounds)
|
|
153
|
-
return null;
|
|
154
|
-
const planeY = this.options.plane.height + this.options.plane.yOffset;
|
|
155
|
-
const lightDir = this.resolveShadowDirection();
|
|
156
|
-
const baked = createBakedShadowMask(meshes, {
|
|
157
|
-
scene: this.scene,
|
|
158
|
-
name: root.name,
|
|
159
|
-
bounds,
|
|
160
|
-
lightDir,
|
|
161
|
-
planeY,
|
|
162
|
-
resolution: this.options.bake.resolution,
|
|
163
|
-
});
|
|
164
|
-
if (!baked)
|
|
165
|
-
return null;
|
|
166
|
-
const material = this.createShadowMaterial(root.name, baked.texture);
|
|
167
|
-
const shadow = this.createShadowRoot(root.name, bounds);
|
|
168
|
-
baked.mesh.name = `${root.name}_staticProjectedShape_0`;
|
|
169
|
-
baked.mesh.material = material;
|
|
170
|
-
baked.mesh.parent = shadow;
|
|
171
|
-
baked.mesh.alphaIndex = STATIC_PROJECTED_SHADOW_ALPHA_INDEX;
|
|
172
|
-
return {
|
|
173
|
-
source: root,
|
|
174
|
-
shadow,
|
|
175
|
-
material,
|
|
176
|
-
texture: baked.texture,
|
|
177
|
-
shadowMeshes: [baked.mesh],
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
createShadowMaterial(name, texture) {
|
|
181
|
-
registerStaticProjectedShadowShaders();
|
|
182
|
-
const material = new ShaderMaterial(`${name}_staticProjectedShadowMaterial`, this.scene, { vertex: STATIC_PROJECTED_SHADOW_SHADER_NAME, fragment: STATIC_PROJECTED_SHADOW_SHADER_NAME }, {
|
|
183
|
-
needAlphaBlending: true,
|
|
184
|
-
needAlphaTesting: false,
|
|
185
|
-
attributes: ['position', 'uv'],
|
|
186
|
-
uniforms: ['worldViewProjection', 'u_shadowColor', 'u_texelSize', 'u_blurRadius'],
|
|
187
|
-
samplers: ['shadowSampler'],
|
|
188
|
-
});
|
|
189
|
-
const color = this.options.appearance.color;
|
|
190
|
-
material.backFaceCulling = false;
|
|
191
|
-
material.disableDepthWrite = true;
|
|
192
|
-
material.depthFunction = Constants.LEQUAL;
|
|
193
|
-
material.transparencyMode = Material.MATERIAL_ALPHABLEND;
|
|
194
|
-
material.alphaMode = Constants.ALPHA_COMBINE;
|
|
195
|
-
material.needAlphaBlending = () => true;
|
|
196
|
-
material.setTexture('shadowSampler', texture);
|
|
197
|
-
material.setColor4('u_shadowColor', new Color4(clamp01(color.r), clamp01(color.g), clamp01(color.b), clamp01(color.a)));
|
|
198
|
-
material.setVector2('u_texelSize', new Vector2(1 / texture.getSize().width, 1 / texture.getSize().height));
|
|
199
|
-
material.setFloat('u_blurRadius', clamp(this.options.bake.blur, 0, 32));
|
|
200
|
-
return material;
|
|
201
|
-
}
|
|
202
|
-
createShadowRoot(name, bounds) {
|
|
203
|
-
const shadow = new Mesh(`${name}_staticProjectedShadow`, this.scene);
|
|
204
|
-
const vertexData = new VertexData();
|
|
205
|
-
vertexData.positions = [bounds.center.x, bounds.center.y, bounds.center.z];
|
|
206
|
-
vertexData.indices = [];
|
|
207
|
-
vertexData.applyToMesh(shadow);
|
|
208
|
-
shadow.isPickable = false;
|
|
209
|
-
shadow.receiveShadows = false;
|
|
210
|
-
shadow.alphaIndex = STATIC_PROJECTED_SHADOW_ALPHA_INDEX;
|
|
211
|
-
shadow.renderOutline = false;
|
|
212
|
-
shadow.renderOverlay = false;
|
|
213
|
-
shadow.metadata = {
|
|
214
|
-
...(shadow.metadata && typeof shadow.metadata === 'object' ? shadow.metadata : {}),
|
|
215
|
-
disableStaticProjectedShadow: true,
|
|
216
|
-
staticProjectedShadowInternal: true,
|
|
217
|
-
};
|
|
218
|
-
return shadow;
|
|
219
|
-
}
|
|
220
|
-
disposeCaster(root) {
|
|
221
|
-
const caster = this.casters.get(root);
|
|
222
|
-
if (!caster)
|
|
223
|
-
return;
|
|
224
|
-
for (const mesh of caster.shadowMeshes) {
|
|
225
|
-
if (!mesh.isDisposed())
|
|
226
|
-
mesh.dispose();
|
|
227
|
-
}
|
|
228
|
-
caster.shadow.dispose();
|
|
229
|
-
const targetIndex = this.scene.customRenderTargets.indexOf(caster.texture);
|
|
230
|
-
if (targetIndex >= 0)
|
|
231
|
-
this.scene.customRenderTargets.splice(targetIndex, 1);
|
|
232
|
-
caster.texture.dispose();
|
|
233
|
-
caster.material.dispose();
|
|
234
|
-
this.casters.delete(root);
|
|
235
|
-
}
|
|
236
|
-
tryAutoAddCaster(mesh) {
|
|
237
|
-
if (!this.initialized || this.casters.has(mesh))
|
|
238
|
-
return;
|
|
239
|
-
if (!this.isValidShadowSource(mesh))
|
|
240
|
-
return;
|
|
241
|
-
if (!this.options.casters.autoDetectAll && !this.matchesCasterPattern(mesh))
|
|
242
|
-
return;
|
|
243
|
-
const root = this.findCasterRoot(mesh);
|
|
244
|
-
if (this.isAlreadyCoveredByCaster(root))
|
|
245
|
-
return;
|
|
246
|
-
this.addCaster(root);
|
|
247
|
-
}
|
|
248
|
-
ensureMeshObserver() {
|
|
249
|
-
if (this.meshAddedObserver)
|
|
250
|
-
return;
|
|
251
|
-
this.meshAddedObserver = this.scene.onNewMeshAddedObservable.add((mesh) => {
|
|
252
|
-
queueMicrotask(() => {
|
|
253
|
-
if (!this.initialized || mesh.isDisposed())
|
|
254
|
-
return;
|
|
255
|
-
this.tryAutoAddCaster(mesh);
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
pruneDisposedCasters() {
|
|
260
|
-
for (const [root, caster] of [...this.casters]) {
|
|
261
|
-
if (root.isDisposed() || caster.shadow.isDisposed())
|
|
262
|
-
this.disposeCaster(root);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
resolveShadowDirection() {
|
|
266
|
-
const direction = this.directionalLight.direction;
|
|
267
|
-
if (direction?.lengthSquared?.() > 1e-6)
|
|
268
|
-
return direction.clone().normalize();
|
|
269
|
-
return DEFAULT_SHADOW_DIRECTION.clone();
|
|
270
|
-
}
|
|
271
|
-
isValidShadowSource(mesh) {
|
|
272
|
-
if (mesh.isDisposed() || !mesh.isEnabled(false))
|
|
273
|
-
return false;
|
|
274
|
-
if (!(mesh instanceof Mesh) && !(mesh instanceof InstancedMesh))
|
|
275
|
-
return false;
|
|
276
|
-
const geometrySource = mesh instanceof InstancedMesh ? mesh.sourceMesh : mesh;
|
|
277
|
-
if (!geometrySource.geometry)
|
|
278
|
-
return false;
|
|
279
|
-
if (!mesh.isVisible)
|
|
280
|
-
return false;
|
|
281
|
-
if (this.isInternalMesh(mesh))
|
|
282
|
-
return false;
|
|
283
|
-
if (this.matchesExcludedPattern(mesh))
|
|
284
|
-
return false;
|
|
285
|
-
mesh.computeWorldMatrix(true);
|
|
286
|
-
const bounds = mesh.getHierarchyBoundingVectors(true);
|
|
287
|
-
const size = bounds.max.subtract(bounds.min);
|
|
288
|
-
const volume = Math.abs(size.x * size.y * size.z);
|
|
289
|
-
return Number.isFinite(volume) && volume >= this.options.casters.minVolume;
|
|
290
|
-
}
|
|
291
|
-
isValidCasterRoot(mesh) {
|
|
292
|
-
if (mesh.isDisposed() || !mesh.isEnabled(false))
|
|
293
|
-
return false;
|
|
294
|
-
if (this.isInternalMesh(mesh))
|
|
295
|
-
return false;
|
|
296
|
-
if (this.matchesExcludedPattern(mesh))
|
|
297
|
-
return false;
|
|
298
|
-
return true;
|
|
299
|
-
}
|
|
300
|
-
matchesCasterPattern(mesh) {
|
|
301
|
-
return this.matchesAnyPattern(mesh, this.casterPatterns);
|
|
302
|
-
}
|
|
303
|
-
matchesExcludedPattern(mesh) {
|
|
304
|
-
return this.matchesAnyPattern(mesh, this.options.casters.excludePatterns);
|
|
305
|
-
}
|
|
306
|
-
matchesAnyPattern(mesh, patterns) {
|
|
307
|
-
if (patterns.length === 0)
|
|
308
|
-
return false;
|
|
309
|
-
const names = this.collectMeshNames(mesh);
|
|
310
|
-
return patterns.some((pattern) => {
|
|
311
|
-
const normalized = pattern.trim().toLowerCase();
|
|
312
|
-
return normalized.length > 0 && names.some((name) => name.includes(normalized));
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
collectMeshNames(mesh) {
|
|
316
|
-
const names = new Set();
|
|
317
|
-
let cursor = mesh;
|
|
318
|
-
while (cursor && typeof cursor === 'object') {
|
|
319
|
-
const name = typeof cursor.name === 'string' ? cursor.name : '';
|
|
320
|
-
if (name)
|
|
321
|
-
names.add(name.toLowerCase());
|
|
322
|
-
cursor = cursor.parent;
|
|
323
|
-
}
|
|
324
|
-
return [...names];
|
|
81
|
+
return 0;
|
|
325
82
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
return !!metadata
|
|
329
|
-
&& typeof metadata === 'object'
|
|
330
|
-
&& (metadata.disableStaticProjectedShadow === true
|
|
331
|
-
|| metadata.staticProjectedShadowInternal === true
|
|
332
|
-
|| metadata.disableBlobShadow === true
|
|
333
|
-
|| metadata.blobShadowInternal === true
|
|
334
|
-
|| metadata.disablePlanarShadow === true
|
|
335
|
-
|| metadata.planarShadowInternal === true);
|
|
83
|
+
getChunkCount() {
|
|
84
|
+
return this.artifactSystem.getChunkCount();
|
|
336
85
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
let parent = mesh.parent;
|
|
340
|
-
while (parent instanceof AbstractMesh || parent instanceof TransformNode) {
|
|
341
|
-
if (parent instanceof AbstractMesh && this.matchesAnyPattern(parent, this.options.casters.rootBoundaryPatterns)) {
|
|
342
|
-
return parent;
|
|
343
|
-
}
|
|
344
|
-
if (parent instanceof AbstractMesh)
|
|
345
|
-
cursor = parent;
|
|
346
|
-
parent = parent.parent;
|
|
347
|
-
}
|
|
348
|
-
return cursor;
|
|
86
|
+
getDiagnostics() {
|
|
87
|
+
return this.artifactSystem.getDiagnostics();
|
|
349
88
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return true;
|
|
353
|
-
for (const caster of this.casters.keys()) {
|
|
354
|
-
if (root.isDescendantOf(caster) || caster.isDescendantOf(root))
|
|
355
|
-
return true;
|
|
356
|
-
}
|
|
357
|
-
return false;
|
|
89
|
+
dispose() {
|
|
90
|
+
this.artifactSystem.dispose();
|
|
358
91
|
}
|
|
359
92
|
}
|
|
360
93
|
export function resolveStaticProjectedShadowOptions(options = {}, fallback = DEFAULT_STATIC_PROJECTED_SHADOW_OPTIONS) {
|
|
94
|
+
const spatialChunkSize = readPositiveNumber(options.bake?.spatialChunkSize ?? options.bake?.maxSize, fallback.bake.spatialChunkSize);
|
|
361
95
|
return {
|
|
362
96
|
enabled: readBoolean(options.enabled, fallback.enabled),
|
|
363
97
|
plane: {
|
|
@@ -379,296 +113,24 @@ export function resolveStaticProjectedShadowOptions(options = {}, fallback = DEF
|
|
|
379
113
|
resolution: readPositiveNumber(options.bake?.resolution, fallback.bake.resolution),
|
|
380
114
|
padding: readNonNegativeNumber(options.bake?.padding, fallback.bake.padding),
|
|
381
115
|
blur: readNonNegativeNumber(options.bake?.blur, fallback.bake.blur),
|
|
382
|
-
maxSize:
|
|
116
|
+
maxSize: spatialChunkSize,
|
|
117
|
+
texelsPerMeter: readPositiveNumber(options.bake?.texelsPerMeter, fallback.bake.texelsPerMeter),
|
|
118
|
+
atlasSize: readPositiveNumber(options.bake?.atlasSize, fallback.bake.atlasSize),
|
|
119
|
+
maxAtlasPages: readPositiveNumber(options.bake?.maxAtlasPages, fallback.bake.maxAtlasPages),
|
|
120
|
+
sdfRadiusPx: readNonNegativeNumber(options.bake?.sdfRadiusPx, fallback.bake.sdfRadiusPx),
|
|
121
|
+
spatialChunkSize,
|
|
122
|
+
targetChunkCount: readPositiveNumber(options.bake?.targetChunkCount, fallback.bake.targetChunkCount),
|
|
383
123
|
},
|
|
384
124
|
casters: {
|
|
385
|
-
autoDetectAll:
|
|
386
|
-
includePatterns:
|
|
125
|
+
autoDetectAll: false,
|
|
126
|
+
includePatterns: [],
|
|
387
127
|
excludePatterns: normalizeStringList(options.casters?.excludePatterns ?? fallback.casters.excludePatterns),
|
|
388
|
-
rootBoundaryPatterns:
|
|
128
|
+
rootBoundaryPatterns: [],
|
|
389
129
|
minVolume: readNonNegativeNumber(options.casters?.minVolume, fallback.casters.minVolume),
|
|
390
130
|
},
|
|
391
131
|
debug: readBoolean(options.debug, fallback.debug),
|
|
392
132
|
};
|
|
393
133
|
}
|
|
394
|
-
function buildProjectedBounds(meshes, options) {
|
|
395
|
-
const lightDir = options.lightDir.clone().normalize();
|
|
396
|
-
if (Math.abs(lightDir.y) < 1e-5)
|
|
397
|
-
return null;
|
|
398
|
-
const points = [];
|
|
399
|
-
for (const mesh of meshes) {
|
|
400
|
-
const geometrySource = mesh instanceof InstancedMesh ? mesh.sourceMesh : mesh;
|
|
401
|
-
if (!(geometrySource instanceof Mesh))
|
|
402
|
-
continue;
|
|
403
|
-
const positions = geometrySource.getVerticesData(VertexBuffer.PositionKind);
|
|
404
|
-
if (!positions || positions.length < 3)
|
|
405
|
-
continue;
|
|
406
|
-
mesh.computeWorldMatrix(true);
|
|
407
|
-
const matrix = mesh.getWorldMatrix();
|
|
408
|
-
for (let index = 0; index < positions.length; index += 3) {
|
|
409
|
-
const point = Vector3.TransformCoordinates(new Vector3(Number(positions[index]), Number(positions[index + 1]), Number(positions[index + 2])), matrix);
|
|
410
|
-
const t = (options.planeY - point.y) / lightDir.y;
|
|
411
|
-
if (t < -1e-4)
|
|
412
|
-
continue;
|
|
413
|
-
points.push(point.add(lightDir.scale(Math.max(0, t))));
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
if (points.length === 0)
|
|
417
|
-
return null;
|
|
418
|
-
let minX = Infinity;
|
|
419
|
-
let maxX = -Infinity;
|
|
420
|
-
let minZ = Infinity;
|
|
421
|
-
let maxZ = -Infinity;
|
|
422
|
-
for (const point of points) {
|
|
423
|
-
minX = Math.min(minX, point.x);
|
|
424
|
-
maxX = Math.max(maxX, point.x);
|
|
425
|
-
minZ = Math.min(minZ, point.z);
|
|
426
|
-
maxZ = Math.max(maxZ, point.z);
|
|
427
|
-
}
|
|
428
|
-
if (![minX, maxX, minZ, maxZ].every(Number.isFinite))
|
|
429
|
-
return null;
|
|
430
|
-
const paddingX = Math.max(options.padding, (maxX - minX) * options.padding);
|
|
431
|
-
const paddingZ = Math.max(options.padding, (maxZ - minZ) * options.padding);
|
|
432
|
-
minX -= paddingX;
|
|
433
|
-
maxX += paddingX;
|
|
434
|
-
minZ -= paddingZ;
|
|
435
|
-
maxZ += paddingZ;
|
|
436
|
-
const centerX = (minX + maxX) * 0.5;
|
|
437
|
-
const centerZ = (minZ + maxZ) * 0.5;
|
|
438
|
-
let width = maxX - minX;
|
|
439
|
-
let depth = maxZ - minZ;
|
|
440
|
-
if (width > options.maxSize) {
|
|
441
|
-
width = options.maxSize;
|
|
442
|
-
minX = centerX - width * 0.5;
|
|
443
|
-
maxX = centerX + width * 0.5;
|
|
444
|
-
}
|
|
445
|
-
if (depth > options.maxSize) {
|
|
446
|
-
depth = options.maxSize;
|
|
447
|
-
minZ = centerZ - depth * 0.5;
|
|
448
|
-
maxZ = centerZ + depth * 0.5;
|
|
449
|
-
}
|
|
450
|
-
return {
|
|
451
|
-
center: new Vector3((minX + maxX) * 0.5, options.planeY, (minZ + maxZ) * 0.5),
|
|
452
|
-
width,
|
|
453
|
-
depth,
|
|
454
|
-
minX,
|
|
455
|
-
maxX,
|
|
456
|
-
minZ,
|
|
457
|
-
maxZ,
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
function collectNodeMeshes(root) {
|
|
461
|
-
const meshes = new Set();
|
|
462
|
-
meshes.add(root);
|
|
463
|
-
for (const child of root.getChildMeshes(false))
|
|
464
|
-
meshes.add(child);
|
|
465
|
-
return [...meshes];
|
|
466
|
-
}
|
|
467
|
-
function createBakedShadowMask(meshes, options) {
|
|
468
|
-
const resolution = clamp(Math.round(options.resolution), 16, 2048);
|
|
469
|
-
const bakeMeshes = createProjectedBakeMeshes(meshes, {
|
|
470
|
-
scene: options.scene,
|
|
471
|
-
name: options.name,
|
|
472
|
-
lightDir: options.lightDir,
|
|
473
|
-
planeY: options.planeY,
|
|
474
|
-
});
|
|
475
|
-
if (bakeMeshes.length === 0)
|
|
476
|
-
return null;
|
|
477
|
-
const bakeCamera = createBakeCamera(`${options.name}_staticProjectedBakeCamera`, options.scene, options.bounds);
|
|
478
|
-
const bakeMaterial = createBakeMaterial(`${options.name}_staticProjectedBakeMaterial`, options.scene);
|
|
479
|
-
const texture = new RenderTargetTexture(`${options.name}_staticProjectedShadowMask`, resolution, options.scene, false, false);
|
|
480
|
-
texture.clearColor = new Color4(0, 0, 0, 0);
|
|
481
|
-
texture.hasAlpha = true;
|
|
482
|
-
texture.wrapU = Texture.CLAMP_ADDRESSMODE;
|
|
483
|
-
texture.wrapV = Texture.CLAMP_ADDRESSMODE;
|
|
484
|
-
texture.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE);
|
|
485
|
-
texture.renderList = bakeMeshes;
|
|
486
|
-
texture.activeCamera = bakeCamera;
|
|
487
|
-
texture.cameraForLOD = bakeCamera;
|
|
488
|
-
texture.disableImageProcessing = true;
|
|
489
|
-
texture.renderParticles = false;
|
|
490
|
-
texture.renderSprites = false;
|
|
491
|
-
texture.enableOutlineRendering = false;
|
|
492
|
-
texture.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
|
|
493
|
-
texture.setMaterialForRendering(bakeMeshes, bakeMaterial);
|
|
494
|
-
try {
|
|
495
|
-
texture.render(false);
|
|
496
|
-
}
|
|
497
|
-
catch {
|
|
498
|
-
for (const mesh of bakeMeshes)
|
|
499
|
-
mesh.dispose();
|
|
500
|
-
const targetIndex = options.scene.customRenderTargets.indexOf(texture);
|
|
501
|
-
if (targetIndex >= 0)
|
|
502
|
-
options.scene.customRenderTargets.splice(targetIndex, 1);
|
|
503
|
-
texture.dispose();
|
|
504
|
-
bakeCamera.dispose();
|
|
505
|
-
bakeMaterial.dispose();
|
|
506
|
-
return null;
|
|
507
|
-
}
|
|
508
|
-
texture.renderList = [];
|
|
509
|
-
texture.activeCamera = null;
|
|
510
|
-
texture.cameraForLOD = null;
|
|
511
|
-
for (const mesh of bakeMeshes)
|
|
512
|
-
mesh.dispose();
|
|
513
|
-
bakeCamera.dispose();
|
|
514
|
-
bakeMaterial.dispose();
|
|
515
|
-
const mesh = createShadowQuad(`${options.name}_staticProjectedShadowBake`, options.scene, options.bounds);
|
|
516
|
-
return { mesh, texture };
|
|
517
|
-
}
|
|
518
|
-
function createProjectedBakeMeshes(meshes, options) {
|
|
519
|
-
const lightDir = options.lightDir.clone().normalize();
|
|
520
|
-
if (Math.abs(lightDir.y) < 1e-5)
|
|
521
|
-
return [];
|
|
522
|
-
const bakeMeshes = [];
|
|
523
|
-
meshes.forEach((mesh, meshIndex) => {
|
|
524
|
-
const geometrySource = mesh instanceof InstancedMesh ? mesh.sourceMesh : mesh;
|
|
525
|
-
if (!(geometrySource instanceof Mesh))
|
|
526
|
-
return;
|
|
527
|
-
const positions = geometrySource.getVerticesData(VertexBuffer.PositionKind);
|
|
528
|
-
const indices = geometrySource.getIndices();
|
|
529
|
-
if (!positions || positions.length < 3 || !indices || indices.length < 3)
|
|
530
|
-
return;
|
|
531
|
-
mesh.computeWorldMatrix(true);
|
|
532
|
-
const matrix = mesh.getWorldMatrix();
|
|
533
|
-
const projectedPositions = [];
|
|
534
|
-
for (let index = 0; index < positions.length; index += 3) {
|
|
535
|
-
const point = Vector3.TransformCoordinates(new Vector3(Number(positions[index]), Number(positions[index + 1]), Number(positions[index + 2])), matrix);
|
|
536
|
-
const t = (options.planeY - point.y) / lightDir.y;
|
|
537
|
-
const projected = point.add(lightDir.scale(Math.max(0, t)));
|
|
538
|
-
projectedPositions.push(projected.x, options.planeY, projected.z);
|
|
539
|
-
}
|
|
540
|
-
const bakeMesh = new Mesh(`${options.name}_staticProjectedBakeProjection_${meshIndex}`, options.scene);
|
|
541
|
-
const vertexData = new VertexData();
|
|
542
|
-
vertexData.positions = projectedPositions;
|
|
543
|
-
vertexData.indices = [...indices];
|
|
544
|
-
vertexData.applyToMesh(bakeMesh);
|
|
545
|
-
bakeMesh.isPickable = false;
|
|
546
|
-
bakeMesh.receiveShadows = false;
|
|
547
|
-
bakeMesh.alphaIndex = STATIC_PROJECTED_SHADOW_ALPHA_INDEX;
|
|
548
|
-
bakeMesh.layerMask = STATIC_PROJECTED_BAKE_LAYER_MASK;
|
|
549
|
-
bakeMesh.metadata = {
|
|
550
|
-
...(bakeMesh.metadata && typeof bakeMesh.metadata === 'object' ? bakeMesh.metadata : {}),
|
|
551
|
-
disableStaticProjectedShadow: true,
|
|
552
|
-
staticProjectedShadowInternal: true,
|
|
553
|
-
};
|
|
554
|
-
bakeMeshes.push(bakeMesh);
|
|
555
|
-
});
|
|
556
|
-
return bakeMeshes;
|
|
557
|
-
}
|
|
558
|
-
function createBakeCamera(name, scene, bounds) {
|
|
559
|
-
const cameraHeight = Math.max(bounds.width, bounds.depth, 1) + 10;
|
|
560
|
-
const camera = new FreeCamera(name, new Vector3(bounds.center.x, bounds.center.y + cameraHeight, bounds.center.z), scene);
|
|
561
|
-
camera.mode = Camera.ORTHOGRAPHIC_CAMERA;
|
|
562
|
-
camera.orthoLeft = -Math.max(bounds.width, 1e-4) * 0.5;
|
|
563
|
-
camera.orthoRight = Math.max(bounds.width, 1e-4) * 0.5;
|
|
564
|
-
camera.orthoBottom = -Math.max(bounds.depth, 1e-4) * 0.5;
|
|
565
|
-
camera.orthoTop = Math.max(bounds.depth, 1e-4) * 0.5;
|
|
566
|
-
camera.minZ = 0.01;
|
|
567
|
-
camera.maxZ = cameraHeight + 1;
|
|
568
|
-
camera.layerMask = STATIC_PROJECTED_BAKE_LAYER_MASK;
|
|
569
|
-
camera.upVector = Vector3.Forward();
|
|
570
|
-
camera.setTarget(bounds.center);
|
|
571
|
-
return camera;
|
|
572
|
-
}
|
|
573
|
-
function createBakeMaterial(name, scene) {
|
|
574
|
-
const material = new StandardMaterial(name, scene);
|
|
575
|
-
material.diffuseColor = Color3.White();
|
|
576
|
-
material.emissiveColor = Color3.White();
|
|
577
|
-
material.alpha = 1;
|
|
578
|
-
material.backFaceCulling = false;
|
|
579
|
-
material.disableLighting = true;
|
|
580
|
-
material.disableDepthWrite = true;
|
|
581
|
-
material.transparencyMode = Material.MATERIAL_OPAQUE;
|
|
582
|
-
return material;
|
|
583
|
-
}
|
|
584
|
-
function registerStaticProjectedShadowShaders() {
|
|
585
|
-
const vertexKey = `${STATIC_PROJECTED_SHADOW_SHADER_NAME}VertexShader`;
|
|
586
|
-
if (Effect.ShadersStore[vertexKey])
|
|
587
|
-
return;
|
|
588
|
-
Effect.ShadersStore[vertexKey] = `
|
|
589
|
-
precision highp float;
|
|
590
|
-
|
|
591
|
-
attribute vec3 position;
|
|
592
|
-
attribute vec2 uv;
|
|
593
|
-
|
|
594
|
-
uniform mat4 worldViewProjection;
|
|
595
|
-
|
|
596
|
-
varying vec2 v_uv;
|
|
597
|
-
|
|
598
|
-
void main() {
|
|
599
|
-
v_uv = uv;
|
|
600
|
-
gl_Position = worldViewProjection * vec4(position, 1.0);
|
|
601
|
-
}
|
|
602
|
-
`;
|
|
603
|
-
Effect.ShadersStore[`${STATIC_PROJECTED_SHADOW_SHADER_NAME}FragmentShader`] = `
|
|
604
|
-
precision highp float;
|
|
605
|
-
|
|
606
|
-
uniform sampler2D shadowSampler;
|
|
607
|
-
uniform vec4 u_shadowColor;
|
|
608
|
-
uniform vec2 u_texelSize;
|
|
609
|
-
uniform float u_blurRadius;
|
|
610
|
-
|
|
611
|
-
varying vec2 v_uv;
|
|
612
|
-
|
|
613
|
-
float sampleMask(vec2 uv) {
|
|
614
|
-
vec4 mask = texture2D(shadowSampler, clamp(uv, vec2(0.0), vec2(1.0)));
|
|
615
|
-
return max(max(mask.r, mask.g), max(mask.b, mask.a));
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
void main() {
|
|
619
|
-
float radius = clamp(u_blurRadius, 0.0, 32.0);
|
|
620
|
-
float alpha = 0.0;
|
|
621
|
-
if (radius < 0.5) {
|
|
622
|
-
alpha = sampleMask(v_uv);
|
|
623
|
-
} else {
|
|
624
|
-
vec2 stepSize = u_texelSize * radius;
|
|
625
|
-
alpha += sampleMask(v_uv) * 0.24;
|
|
626
|
-
alpha += sampleMask(v_uv + vec2(stepSize.x, 0.0)) * 0.12;
|
|
627
|
-
alpha += sampleMask(v_uv - vec2(stepSize.x, 0.0)) * 0.12;
|
|
628
|
-
alpha += sampleMask(v_uv + vec2(0.0, stepSize.y)) * 0.12;
|
|
629
|
-
alpha += sampleMask(v_uv - vec2(0.0, stepSize.y)) * 0.12;
|
|
630
|
-
alpha += sampleMask(v_uv + stepSize) * 0.07;
|
|
631
|
-
alpha += sampleMask(v_uv - stepSize) * 0.07;
|
|
632
|
-
alpha += sampleMask(v_uv + vec2(stepSize.x, -stepSize.y)) * 0.07;
|
|
633
|
-
alpha += sampleMask(v_uv + vec2(-stepSize.x, stepSize.y)) * 0.07;
|
|
634
|
-
}
|
|
635
|
-
alpha *= u_shadowColor.a;
|
|
636
|
-
if (alpha <= 0.001) discard;
|
|
637
|
-
gl_FragColor = vec4(u_shadowColor.rgb, alpha);
|
|
638
|
-
}
|
|
639
|
-
`;
|
|
640
|
-
}
|
|
641
|
-
function createShadowQuad(name, scene, bounds) {
|
|
642
|
-
const mesh = new Mesh(name, scene);
|
|
643
|
-
const vertexData = new VertexData();
|
|
644
|
-
vertexData.positions = [
|
|
645
|
-
bounds.minX, bounds.center.y, bounds.minZ,
|
|
646
|
-
bounds.maxX, bounds.center.y, bounds.minZ,
|
|
647
|
-
bounds.maxX, bounds.center.y, bounds.maxZ,
|
|
648
|
-
bounds.minX, bounds.center.y, bounds.maxZ,
|
|
649
|
-
];
|
|
650
|
-
vertexData.indices = [0, 1, 2, 0, 2, 3];
|
|
651
|
-
vertexData.normals = [
|
|
652
|
-
0, 1, 0,
|
|
653
|
-
0, 1, 0,
|
|
654
|
-
0, 1, 0,
|
|
655
|
-
0, 1, 0,
|
|
656
|
-
];
|
|
657
|
-
vertexData.uvs = [
|
|
658
|
-
0, 0,
|
|
659
|
-
1, 0,
|
|
660
|
-
1, 1,
|
|
661
|
-
0, 1,
|
|
662
|
-
];
|
|
663
|
-
vertexData.applyToMesh(mesh);
|
|
664
|
-
mesh.isPickable = false;
|
|
665
|
-
mesh.metadata = {
|
|
666
|
-
...(mesh.metadata && typeof mesh.metadata === 'object' ? mesh.metadata : {}),
|
|
667
|
-
disableStaticProjectedShadow: true,
|
|
668
|
-
staticProjectedShadowInternal: true,
|
|
669
|
-
};
|
|
670
|
-
return mesh;
|
|
671
|
-
}
|
|
672
134
|
function cloneResolvedOptions(options) {
|
|
673
135
|
return {
|
|
674
136
|
enabled: options.enabled,
|
|
@@ -706,12 +168,6 @@ function readPositiveNumber(value, fallback) {
|
|
|
706
168
|
return next > 0 ? next : fallback;
|
|
707
169
|
}
|
|
708
170
|
function readClampedNumber(value, fallback, min, max) {
|
|
709
|
-
return
|
|
710
|
-
}
|
|
711
|
-
function clamp01(value) {
|
|
712
|
-
return clamp(value, 0, 1);
|
|
713
|
-
}
|
|
714
|
-
function clamp(value, min, max) {
|
|
715
|
-
return Math.min(max, Math.max(min, value));
|
|
171
|
+
return Math.min(max, Math.max(min, readFiniteNumber(value, fallback)));
|
|
716
172
|
}
|
|
717
173
|
//# sourceMappingURL=static-projected-shadow-system.js.map
|