@onerjs/core 8.56.4 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animatable.core.js +36 -0
- package/Animations/animatable.core.js.map +1 -1
- package/Animations/animationGroup.pure.d.ts +61 -1
- package/Animations/animationGroup.pure.js +191 -2
- package/Animations/animationGroup.pure.js.map +1 -1
- package/Animations/index.d.ts +1 -0
- package/Animations/index.js +1 -0
- package/Animations/index.js.map +1 -1
- package/Animations/pure.d.ts +1 -0
- package/Animations/pure.js +1 -0
- package/Animations/pure.js.map +1 -1
- package/Animations/rootMotion.d.ts +560 -0
- package/Animations/rootMotion.js +1709 -0
- package/Animations/rootMotion.js.map +1 -0
- package/Animations/runtimeAnimation.d.ts +57 -0
- package/Animations/runtimeAnimation.js +127 -3
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Cameras/arcRotateCamera.pure.d.ts +2 -0
- package/Cameras/arcRotateCamera.pure.js +2 -0
- package/Cameras/arcRotateCamera.pure.js.map +1 -1
- package/Cameras/targetCamera.pure.d.ts +2 -0
- package/Cameras/targetCamera.pure.js +7 -1
- package/Cameras/targetCamera.pure.js.map +1 -1
- package/Collisions/gpuPicker.js +5 -5
- package/Collisions/gpuPicker.js.map +1 -1
- package/Engines/AbstractEngine/abstractEngine.query.pure.js +4 -2
- package/Engines/AbstractEngine/abstractEngine.query.pure.js.map +1 -1
- package/Engines/AbstractEngine/abstractEngine.query.types.d.ts +11 -2
- package/Engines/AbstractEngine/abstractEngine.query.types.js.map +1 -1
- package/Engines/AbstractEngine/abstractEngine.renderPass.pure.js +1 -0
- package/Engines/AbstractEngine/abstractEngine.renderPass.pure.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.pure.js +63 -0
- package/Engines/Extensions/engine.multiRender.pure.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.types.d.ts +13 -0
- package/Engines/Extensions/engine.multiRender.types.js.map +1 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.pure.js +2 -2
- package/Engines/Extensions/engine.prefilteredCubeTexture.pure.js.map +1 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.types.d.ts +2 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.types.js.map +1 -1
- package/Engines/Extensions/index.d.ts +1 -0
- package/Engines/Extensions/index.js +1 -0
- package/Engines/Extensions/index.js.map +1 -1
- package/Engines/Extensions/pure.d.ts +1 -1
- package/Engines/Extensions/pure.js +1 -1
- package/Engines/Extensions/pure.js.map +1 -1
- package/Engines/Native/Extensions/nativeEngine.cubeTexture.pure.js +88 -39
- package/Engines/Native/Extensions/nativeEngine.cubeTexture.pure.js.map +1 -1
- package/Engines/Native/Extensions/nativeEngine.cubeTexture.types.d.ts +20 -2
- package/Engines/Native/Extensions/nativeEngine.cubeTexture.types.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.pure.js +4 -0
- package/Engines/WebGPU/Extensions/engine.multiRender.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.types.d.ts +13 -0
- package/Engines/WebGPU/Extensions/engine.multiRender.types.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.query.pure.js +11 -3
- package/Engines/WebGPU/Extensions/engine.query.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/index.d.ts +1 -0
- package/Engines/WebGPU/Extensions/index.js +1 -0
- package/Engines/WebGPU/Extensions/index.js.map +1 -1
- package/Engines/WebGPU/Extensions/pure.d.ts +1 -1
- package/Engines/WebGPU/Extensions/pure.js +1 -1
- package/Engines/WebGPU/Extensions/pure.js.map +1 -1
- package/Engines/WebGPU/webgpuBundleList.d.ts +2 -0
- package/Engines/WebGPU/webgpuBundleList.js +4 -0
- package/Engines/WebGPU/webgpuBundleList.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +5 -2
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js +3 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuOcclusionQuery.js +1 -1
- package/Engines/WebGPU/webgpuOcclusionQuery.js.map +1 -1
- package/Engines/WebGPU/webgpuSnapshotRendering.d.ts +4 -0
- package/Engines/WebGPU/webgpuSnapshotRendering.js +40 -7
- package/Engines/WebGPU/webgpuSnapshotRendering.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +2 -2
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +2 -0
- package/Engines/WebGPU/webgpuTextureManager.js +286 -13
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.pure.d.ts +2 -0
- package/Engines/abstractEngine.pure.js +7 -3
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/constants.d.ts +4 -0
- package/Engines/constants.js +4 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/thinEngine.pure.d.ts +14 -0
- package/Engines/thinEngine.pure.js +48 -12
- package/Engines/thinEngine.pure.js.map +1 -1
- package/Engines/thinNativeEngine.pure.d.ts +1 -0
- package/Engines/thinNativeEngine.pure.js +7 -1
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/Engines/thinWebGPUEngine.d.ts +4 -0
- package/Engines/thinWebGPUEngine.js +10 -1
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.pure.d.ts +5 -2
- package/Engines/webgpuEngine.pure.js +48 -13
- package/Engines/webgpuEngine.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.js +2 -2
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.pure.d.ts +11 -2
- package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.pure.js +1 -1
- package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.pure.d.ts +9 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.pure.js +6 -8
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphPointerOutEventBlock.pure.d.ts +2 -0
- package/FlowGraph/Blocks/Event/flowGraphPointerOutEventBlock.pure.js +5 -1
- package/FlowGraph/Blocks/Event/flowGraphPointerOutEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphPointerOverEventBlock.pure.d.ts +2 -0
- package/FlowGraph/Blocks/Event/flowGraphPointerOverEventBlock.pure.js +5 -1
- package/FlowGraph/Blocks/Event/flowGraphPointerOverEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.d.ts +9 -0
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.js +34 -9
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.d.ts +2 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.js +4 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.d.ts +2 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js +4 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.pure.js +19 -7
- package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.d.ts +20 -2
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js +53 -10
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.pure.d.ts +16 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.pure.js +64 -14
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.pure.js +64 -16
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.pure.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +4 -0
- package/FlowGraph/flowGraph.js +38 -7
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphBlock.js +3 -0
- package/FlowGraph/flowGraphBlock.js.map +1 -1
- package/FlowGraph/flowGraphConnection.d.ts +7 -0
- package/FlowGraph/flowGraphConnection.js +7 -0
- package/FlowGraph/flowGraphConnection.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +2 -1
- package/FlowGraph/flowGraphContext.js +4 -3
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.d.ts +15 -1
- package/FlowGraph/flowGraphCoordinator.js +47 -16
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphEventBlock.d.ts +5 -0
- package/FlowGraph/flowGraphEventBlock.js +7 -0
- package/FlowGraph/flowGraphEventBlock.js.map +1 -1
- package/FlowGraph/flowGraphHostResolver.d.ts +2 -1
- package/FlowGraph/flowGraphHostResolver.js.map +1 -1
- package/FlowGraph/flowGraphParser.js +60 -2
- package/FlowGraph/flowGraphParser.js.map +1 -1
- package/FlowGraph/serialization.d.ts +2 -0
- package/FlowGraph/serialization.js +10 -22
- package/FlowGraph/serialization.js.map +1 -1
- package/FlowGraph/typeDefinitions.d.ts +8 -0
- package/FlowGraph/typeDefinitions.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/meshBlendingPostProcessBlock.d.ts +5 -0
- package/FrameGraph/Node/Blocks/PostProcesses/meshBlendingPostProcessBlock.js +8 -0
- package/FrameGraph/Node/Blocks/PostProcesses/meshBlendingPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/meshBlendingPostProcessBlock.pure.d.ts +87 -0
- package/FrameGraph/Node/Blocks/PostProcesses/meshBlendingPostProcessBlock.pure.js +295 -0
- package/FrameGraph/Node/Blocks/PostProcesses/meshBlendingPostProcessBlock.pure.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/pure.d.ts +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/pure.js +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/pure.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +4 -4
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.d.ts +5 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js +13 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js.map +1 -1
- package/FrameGraph/Node/Blocks/allBlocks.pure.js +2 -0
- package/FrameGraph/Node/Blocks/allBlocks.pure.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.pure.js +20 -1
- package/FrameGraph/Node/Blocks/inputBlock.pure.js.map +1 -1
- package/FrameGraph/Node/Blocks/pure.d.ts +1 -0
- package/FrameGraph/Node/Blocks/pure.js +1 -0
- package/FrameGraph/Node/Blocks/pure.js.map +1 -1
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.d.ts +4 -2
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js +4 -2
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Tasks/Layers/selectionOutlineTask.js +1 -0
- package/FrameGraph/Tasks/Layers/selectionOutlineTask.js.map +1 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js +5 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.js +1 -0
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/meshBlendingTask.d.ts +69 -0
- package/FrameGraph/Tasks/PostProcesses/meshBlendingTask.js +223 -0
- package/FrameGraph/Tasks/PostProcesses/meshBlendingTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +25 -3
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +69 -33
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/frameGraphObjectList.d.ts +6 -1
- package/FrameGraph/frameGraphObjectList.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +3 -1
- package/FrameGraph/frameGraphRenderContext.js +5 -5
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -0
- package/FrameGraph/index.js +1 -0
- package/FrameGraph/index.js.map +1 -1
- package/FrameGraph/pure.d.ts +1 -0
- package/FrameGraph/pure.js +1 -0
- package/FrameGraph/pure.js.map +1 -1
- package/Inputs/scene.inputManager.d.ts +4 -0
- package/Inputs/scene.inputManager.js +50 -8
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.pure.js +5 -5
- package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js +5 -5
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.d.ts +26 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +151 -47
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.js +5 -5
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js +11 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.pure.js +17 -2
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js +2 -2
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js.map +1 -1
- package/Materials/Node/nodeMaterial.pure.d.ts +4 -0
- package/Materials/Node/nodeMaterial.pure.js +4 -0
- package/Materials/Node/nodeMaterial.pure.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.d.ts +1 -1
- package/Materials/Node/nodeMaterialBuildState.js +25 -3
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.pure.d.ts +2 -0
- package/Materials/PBR/pbrBaseMaterial.pure.d.ts +2 -0
- package/Materials/Textures/Procedurals/proceduralTexture.pure.d.ts +13 -14
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js +6 -6
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
- package/Materials/Textures/baseTexture.pure.js +3 -0
- package/Materials/Textures/baseTexture.pure.js.map +1 -1
- package/Materials/Textures/cubeTexture.pure.js +1 -1
- package/Materials/Textures/cubeTexture.pure.js.map +1 -1
- package/Materials/Textures/internalTexture.d.ts +8 -1
- package/Materials/Textures/internalTexture.js +9 -2
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/rawTexture2DArray.functions.d.ts +3 -3
- package/Materials/Textures/rawTexture2DArray.functions.js.map +1 -1
- package/Materials/Textures/rawTexture3D.d.ts +1 -1
- package/Materials/Textures/rawTexture3D.js +1 -1
- package/Materials/Textures/rawTexture3D.js.map +1 -1
- package/Materials/Textures/textureHelper.functions.d.ts +14 -0
- package/Materials/Textures/textureHelper.functions.js +24 -0
- package/Materials/Textures/textureHelper.functions.js.map +1 -1
- package/Materials/ditheredTileFadeMaterialPlugin.d.ts +210 -0
- package/Materials/ditheredTileFadeMaterialPlugin.js +509 -0
- package/Materials/ditheredTileFadeMaterialPlugin.js.map +1 -0
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Materials/materialHelper.geometryrendering.d.ts +46 -1
- package/Materials/materialHelper.geometryrendering.js +105 -8
- package/Materials/materialHelper.geometryrendering.js.map +1 -1
- package/Materials/prepass.defines.d.ts +2 -0
- package/Materials/prepass.defines.js +2 -0
- package/Materials/prepass.defines.js.map +1 -1
- package/Materials/pure.d.ts +1 -0
- package/Materials/pure.js +1 -0
- package/Materials/pure.js.map +1 -1
- package/Materials/standardMaterial.pure.d.ts +2 -0
- package/Materials/standardMaterial.pure.js +6 -3
- package/Materials/standardMaterial.pure.js.map +1 -1
- package/Meshes/Builders/polygonBuilder.pure.d.ts +4 -0
- package/Meshes/Builders/polygonBuilder.pure.js +4 -1
- package/Meshes/Builders/polygonBuilder.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplatting.functions.d.ts +19 -0
- package/Meshes/GaussianSplatting/gaussianSplatting.functions.js +23 -0
- package/Meshes/GaussianSplatting/gaussianSplatting.functions.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +3 -14
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +20 -24
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +2 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +11 -4
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/abstractMesh.pure.d.ts +18 -0
- package/Meshes/abstractMesh.pure.js +22 -0
- package/Meshes/abstractMesh.pure.js.map +1 -1
- package/Meshes/index.d.ts +1 -0
- package/Meshes/index.js +1 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/instancedMesh.pure.d.ts +5 -0
- package/Meshes/instancedMesh.pure.js +12 -0
- package/Meshes/instancedMesh.pure.js.map +1 -1
- package/Meshes/mesh.pure.js +23 -8
- package/Meshes/mesh.pure.js.map +1 -1
- package/Meshes/meshBlendingTag.d.ts +47 -0
- package/Meshes/meshBlendingTag.js +64 -0
- package/Meshes/meshBlendingTag.js.map +1 -0
- package/Meshes/polygonMesh.js +2 -2
- package/Meshes/polygonMesh.js.map +1 -1
- package/Meshes/pure.d.ts +1 -0
- package/Meshes/pure.js +1 -0
- package/Meshes/pure.js.map +1 -1
- package/Misc/fileTools.pure.js +21 -0
- package/Misc/fileTools.pure.js.map +1 -1
- package/Misc/snapshotRenderingHelper.js +2 -2
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Particles/gpuParticleSystem.pure.d.ts +2 -0
- package/Particles/gpuParticleSystem.pure.js +89 -28
- package/Particles/gpuParticleSystem.pure.js.map +1 -1
- package/Particles/thinParticleSystem.pure.d.ts +2 -0
- package/Particles/thinParticleSystem.pure.js +84 -19
- package/Particles/thinParticleSystem.pure.js.map +1 -1
- package/Particles/webgl2ParticleSystem.pure.d.ts +1 -0
- package/Particles/webgl2ParticleSystem.pure.js +12 -4
- package/Particles/webgl2ParticleSystem.pure.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.pure.js +7 -0
- package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.pure.js.map +1 -1
- package/PostProcesses/index.d.ts +2 -0
- package/PostProcesses/index.js +2 -0
- package/PostProcesses/index.js.map +1 -1
- package/PostProcesses/meshBlendingBlueNoise.d.ts +15 -0
- package/PostProcesses/meshBlendingBlueNoise.js +77 -0
- package/PostProcesses/meshBlendingBlueNoise.js.map +1 -0
- package/PostProcesses/meshBlendingPostProcess.d.ts +131 -0
- package/PostProcesses/meshBlendingPostProcess.js +315 -0
- package/PostProcesses/meshBlendingPostProcess.js.map +1 -0
- package/PostProcesses/pure.d.ts +2 -0
- package/PostProcesses/pure.js +2 -0
- package/PostProcesses/pure.js.map +1 -1
- package/PostProcesses/thinMeshBlendingPostProcess.d.ts +339 -0
- package/PostProcesses/thinMeshBlendingPostProcess.js +771 -0
- package/PostProcesses/thinMeshBlendingPostProcess.js.map +1 -0
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js +6 -6
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +8 -8
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
- package/Rendering/boundingBoxRenderer.pure.js +2 -1
- package/Rendering/boundingBoxRenderer.pure.js.map +1 -1
- package/Rendering/depthRenderer.pure.js +3 -4
- package/Rendering/depthRenderer.pure.js.map +1 -1
- package/Rendering/edgesRenderer.pure.d.ts +4 -2
- package/Rendering/edgesRenderer.pure.js +11 -2
- package/Rendering/edgesRenderer.pure.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObject.d.ts +10 -0
- package/Rendering/fluidRenderer/fluidRenderingObject.js +20 -0
- package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.d.ts +9 -3
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js +14 -9
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js.map +1 -1
- package/Rendering/geometryBufferRenderer.pure.d.ts +38 -4
- package/Rendering/geometryBufferRenderer.pure.js +126 -17
- package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +7 -1
- package/Rendering/objectRenderer.js +45 -7
- package/Rendering/objectRenderer.js.map +1 -1
- package/Rendering/outlineRenderer.pure.js +6 -2
- package/Rendering/outlineRenderer.pure.js.map +1 -1
- package/Rendering/renderingManager.d.ts +1 -1
- package/Rendering/renderingManager.js +5 -4
- package/Rendering/renderingManager.js.map +1 -1
- package/Shaders/ShadersInclude/defaultFragmentAlpha.d.ts +5 -0
- package/Shaders/ShadersInclude/defaultFragmentAlpha.js +34 -0
- package/Shaders/ShadersInclude/defaultFragmentAlpha.js.map +1 -0
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +5 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/geometryRenderingFragment.d.ts +5 -0
- package/Shaders/ShadersInclude/geometryRenderingFragment.js +74 -0
- package/Shaders/ShadersInclude/geometryRenderingFragment.js.map +1 -0
- package/Shaders/ShadersInclude/mrtFragmentDeclaration.js +89 -0
- package/Shaders/ShadersInclude/mrtFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrBlockPrePass.js +24 -17
- package/Shaders/ShadersInclude/openpbrBlockPrePass.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockPrePass.js +27 -20
- package/Shaders/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDebug.js +6 -2
- package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
- package/Shaders/ShadersInclude/prePassDeclaration.js +95 -2
- package/Shaders/ShadersInclude/prePassDeclaration.js.map +1 -1
- package/Shaders/default.fragment.js +31 -40
- package/Shaders/default.fragment.js.map +1 -1
- package/Shaders/depthOfField.fragment.js +13 -9
- package/Shaders/depthOfField.fragment.js.map +1 -1
- package/Shaders/fluidRenderingParticleDepth.vertex.js +16 -1
- package/Shaders/fluidRenderingParticleDepth.vertex.js.map +1 -1
- package/Shaders/fluidRenderingParticleThickness.vertex.js +16 -1
- package/Shaders/fluidRenderingParticleThickness.vertex.js.map +1 -1
- package/Shaders/gaussianSplatting.fragment.js +63 -3
- package/Shaders/gaussianSplatting.fragment.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +80 -0
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/geometry.fragment.js +17 -11
- package/Shaders/geometry.fragment.js.map +1 -1
- package/Shaders/gpuRenderParticles.fragment.js +43 -1
- package/Shaders/gpuRenderParticles.fragment.js.map +1 -1
- package/Shaders/gpuRenderParticles.vertex.js +96 -16
- package/Shaders/gpuRenderParticles.vertex.js.map +1 -1
- package/Shaders/meshBlending.fragment.d.ts +5 -0
- package/Shaders/meshBlending.fragment.js +519 -0
- package/Shaders/meshBlending.fragment.js.map +1 -0
- package/Shaders/particles.fragment.js +43 -1
- package/Shaders/particles.fragment.js.map +1 -1
- package/Shaders/particles.vertex.js +84 -3
- package/Shaders/particles.vertex.js.map +1 -1
- package/Shaders/sprites.fragment.js +52 -2
- package/Shaders/sprites.fragment.js.map +1 -1
- package/Shaders/sprites.vertex.js +62 -1
- package/Shaders/sprites.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/defaultFragmentAlpha.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/defaultFragmentAlpha.js +33 -0
- package/ShadersWGSL/ShadersInclude/defaultFragmentAlpha.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/geometryRenderingFragment.d.ts +6 -0
- package/ShadersWGSL/ShadersInclude/geometryRenderingFragment.js +76 -0
- package/ShadersWGSL/ShadersInclude/geometryRenderingFragment.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/lightFragment.js +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/meshBlendTagFragmentOutput.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/meshBlendTagFragmentOutput.js +18 -0
- package/ShadersWGSL/ShadersInclude/meshBlendTagFragmentOutput.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockPrePass.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockPrePass.js +11 -25
- package/ShadersWGSL/ShadersInclude/openpbrBlockPrePass.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js +11 -25
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDebug.js +5 -1
- package/ShadersWGSL/ShadersInclude/pbrDebug.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassDeclaration.js +6 -1
- package/ShadersWGSL/ShadersInclude/prePassDeclaration.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +17 -48
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/fluidRenderingParticleDepth.vertex.js +15 -2
- package/ShadersWGSL/fluidRenderingParticleDepth.vertex.js.map +1 -1
- package/ShadersWGSL/fluidRenderingParticleThickness.vertex.js +15 -2
- package/ShadersWGSL/fluidRenderingParticleThickness.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.fragment.js +63 -2
- package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +80 -0
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/geometry.fragment.js +37 -2
- package/ShadersWGSL/geometry.fragment.js.map +1 -1
- package/ShadersWGSL/gpuRenderParticles.fragment.js +47 -2
- package/ShadersWGSL/gpuRenderParticles.fragment.js.map +1 -1
- package/ShadersWGSL/gpuRenderParticles.vertex.js +110 -7
- package/ShadersWGSL/gpuRenderParticles.vertex.js.map +1 -1
- package/ShadersWGSL/meshBlending.fragment.d.ts +5 -0
- package/ShadersWGSL/meshBlending.fragment.js +576 -0
- package/ShadersWGSL/meshBlending.fragment.js.map +1 -0
- package/ShadersWGSL/openpbr.fragment.js +2 -1
- package/ShadersWGSL/openpbr.fragment.js.map +1 -1
- package/ShadersWGSL/particles.fragment.js +45 -1
- package/ShadersWGSL/particles.fragment.js.map +1 -1
- package/ShadersWGSL/particles.vertex.js +86 -4
- package/ShadersWGSL/particles.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +2 -1
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/sprites.fragment.js +56 -2
- package/ShadersWGSL/sprites.fragment.js.map +1 -1
- package/ShadersWGSL/sprites.vertex.js +62 -1
- package/ShadersWGSL/sprites.vertex.js.map +1 -1
- package/Sprites/spriteManager.d.ts +13 -0
- package/Sprites/spriteManager.js +15 -0
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteRenderer.d.ts +24 -1
- package/Sprites/spriteRenderer.js +368 -50
- package/Sprites/spriteRenderer.js.map +1 -1
- package/Sprites/thinSprite.d.ts +4 -0
- package/Sprites/thinSprite.js +4 -0
- package/Sprites/thinSprite.js.map +1 -1
- package/States/alphaCullingState.d.ts +3 -1
- package/States/alphaCullingState.js +18 -3
- package/States/alphaCullingState.js.map +1 -1
- package/XR/webXRDefaultExperience.d.ts +5 -1
- package/XR/webXRDefaultExperience.js.map +1 -1
- package/XR/webXREnterExitUI.d.ts +2 -1
- package/XR/webXREnterExitUI.js.map +1 -1
- package/package.json +1 -1
- package/scene.pure.d.ts +23 -0
- package/scene.pure.js +35 -0
- package/scene.pure.js.map +1 -1
|
@@ -0,0 +1,771 @@
|
|
|
1
|
+
import { EffectWrapper } from "../Materials/effectRenderer.pure.js";
|
|
2
|
+
import { EngineStore } from "../Engines/engineStore.js";
|
|
3
|
+
|
|
4
|
+
import { Matrix } from "../Maths/math.vector.pure.js";
|
|
5
|
+
import { _IsMeshBlendingSupported } from "../Meshes/meshBlendingTag.js";
|
|
6
|
+
import { _CreateMeshBlendBlueNoiseTexture } from "./meshBlendingBlueNoise.js";
|
|
7
|
+
/**
|
|
8
|
+
* Quality level used by mesh blending.
|
|
9
|
+
*
|
|
10
|
+
* Each value selects a separate compile-time shader variant. Medium is the default.
|
|
11
|
+
*/
|
|
12
|
+
export var MeshBlendQuality;
|
|
13
|
+
(function (MeshBlendQuality) {
|
|
14
|
+
/** Three search directions with the lowest refinement and exact-boundary sample counts, using sRGB color interpolation. */
|
|
15
|
+
MeshBlendQuality[MeshBlendQuality["Low"] = 0] = "Low";
|
|
16
|
+
/** Three search directions with balanced refinement and exact-boundary sample counts, using OKLab color interpolation. */
|
|
17
|
+
MeshBlendQuality[MeshBlendQuality["Medium"] = 1] = "Medium";
|
|
18
|
+
/** Three search directions with OKLab interpolation, full rotation, close-neighbor fallback, tiny-object protection, and multi-target blending. */
|
|
19
|
+
MeshBlendQuality[MeshBlendQuality["High"] = 2] = "High";
|
|
20
|
+
/** Eight search directions with OKLab interpolation and the largest radial and exact-boundary sample counts. */
|
|
21
|
+
MeshBlendQuality[MeshBlendQuality["Cinematic"] = 3] = "Cinematic";
|
|
22
|
+
})(MeshBlendQuality || (MeshBlendQuality = {}));
|
|
23
|
+
/**
|
|
24
|
+
* Debug visualization produced by mesh blending.
|
|
25
|
+
*/
|
|
26
|
+
export var MeshBlendDebugMode;
|
|
27
|
+
(function (MeshBlendDebugMode) {
|
|
28
|
+
/** Render the blended scene color. */
|
|
29
|
+
MeshBlendDebugMode[MeshBlendDebugMode["Off"] = 0] = "Off";
|
|
30
|
+
/** Visualize the packed group and radius-class tag. */
|
|
31
|
+
MeshBlendDebugMode[MeshBlendDebugMode["PackedTag"] = 1] = "PackedTag";
|
|
32
|
+
/** Visualize the refined candidate direction and normalized boundary distance. */
|
|
33
|
+
MeshBlendDebugMode[MeshBlendDebugMode["CandidateDirectionDistance"] = 2] = "CandidateDirectionDistance";
|
|
34
|
+
/** Visualize the selected radius class and the resulting seam fade. */
|
|
35
|
+
MeshBlendDebugMode[MeshBlendDebugMode["SeamFade"] = 3] = "SeamFade";
|
|
36
|
+
/** Visualize why a candidate was accepted or rejected by contact validation. */
|
|
37
|
+
MeshBlendDebugMode[MeshBlendDebugMode["RejectionReason"] = 4] = "RejectionReason";
|
|
38
|
+
/** Visualize the approximate amount of shader work performed by each pixel. */
|
|
39
|
+
MeshBlendDebugMode[MeshBlendDebugMode["StageWork"] = 5] = "StageWork";
|
|
40
|
+
/** Visualize target continuation success, fallback use, and rejection. */
|
|
41
|
+
MeshBlendDebugMode[MeshBlendDebugMode["Continuation"] = 6] = "Continuation";
|
|
42
|
+
/** Visualize the effective-radius reduction applied to thin projected objects. */
|
|
43
|
+
MeshBlendDebugMode[MeshBlendDebugMode["TinyObject"] = 7] = "TinyObject";
|
|
44
|
+
/** Visualize primary-only and secondary-target selections at multi-mesh junctions. */
|
|
45
|
+
MeshBlendDebugMode[MeshBlendDebugMode["MultiTarget"] = 8] = "MultiTarget";
|
|
46
|
+
/** Visualize the farther, boundary-plus-one, boundary-plus-two, and constructed target-color samples. */
|
|
47
|
+
MeshBlendDebugMode[MeshBlendDebugMode["TargetColor"] = 9] = "TargetColor";
|
|
48
|
+
/** Visualize the fade attenuation applied by the base-color shadow-transfer heuristic. Neutral when no base-color texture is provided. */
|
|
49
|
+
MeshBlendDebugMode[MeshBlendDebugMode["ShadowAttenuation"] = 10] = "ShadowAttenuation";
|
|
50
|
+
/** Visualize the active color-interpolation mode after target-color construction. */
|
|
51
|
+
MeshBlendDebugMode[MeshBlendDebugMode["ColorInterpolation"] = 11] = "ColorInterpolation";
|
|
52
|
+
/** Visualize the reconstructed world position. */
|
|
53
|
+
MeshBlendDebugMode[MeshBlendDebugMode["WorldPosition"] = 12] = "WorldPosition";
|
|
54
|
+
})(MeshBlendDebugMode || (MeshBlendDebugMode = {}));
|
|
55
|
+
/**
|
|
56
|
+
* Depth representation consumed by mesh blending.
|
|
57
|
+
*/
|
|
58
|
+
export var MeshBlendDepthType;
|
|
59
|
+
(function (MeshBlendDepthType) {
|
|
60
|
+
/** Signed camera-space Z written by the geometry renderer's view-depth output. */
|
|
61
|
+
MeshBlendDepthType[MeshBlendDepthType["View"] = 0] = "View";
|
|
62
|
+
/** Hardware depth in the normalized screen-depth range. */
|
|
63
|
+
MeshBlendDepthType[MeshBlendDepthType["Screen"] = 1] = "Screen";
|
|
64
|
+
})(MeshBlendDepthType || (MeshBlendDepthType = {}));
|
|
65
|
+
const _MeshBlendingEffectWrapperOwners = new WeakMap();
|
|
66
|
+
/**
|
|
67
|
+
* Checks whether a thin mesh-blending wrapper is already exclusively owned.
|
|
68
|
+
* @param wrapper Wrapper to check.
|
|
69
|
+
* @returns Whether the wrapper already has an owner.
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
export function _IsMeshBlendingEffectWrapperOwned(wrapper) {
|
|
73
|
+
return _MeshBlendingEffectWrapperOwners.has(wrapper);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Claims exclusive ownership of a thin mesh-blending wrapper.
|
|
77
|
+
* @param wrapper Wrapper to claim.
|
|
78
|
+
* @param owner Owner claiming the wrapper.
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
export function _ClaimMeshBlendingEffectWrapper(wrapper, owner) {
|
|
82
|
+
if (_MeshBlendingEffectWrapperOwners.has(wrapper)) {
|
|
83
|
+
throw new Error("ThinMeshBlendingPostProcess is already attached to another owner");
|
|
84
|
+
}
|
|
85
|
+
_MeshBlendingEffectWrapperOwners.set(wrapper, owner);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Releases exclusive ownership of a thin mesh-blending wrapper.
|
|
89
|
+
* @param wrapper Wrapper to release.
|
|
90
|
+
* @param owner Owner releasing the wrapper.
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
export function _ReleaseMeshBlendingEffectWrapper(wrapper, owner) {
|
|
94
|
+
if (_MeshBlendingEffectWrapperOwners.get(wrapper) === owner) {
|
|
95
|
+
_MeshBlendingEffectWrapperOwners.delete(wrapper);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function _ValidateWorldRadius(value) {
|
|
99
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
100
|
+
throw new RangeError("Mesh-blending world radii must be finite non-negative numbers.");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function _ValidateMinimumProjectedRadius(value) {
|
|
104
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
105
|
+
throw new RangeError("Mesh-blending minimum projected radii must be finite non-negative numbers.");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function _CreateValidatedRadiusDefinition(worldRadius, minimumProjectedRadius) {
|
|
109
|
+
let validatedWorldRadius = 0;
|
|
110
|
+
let validatedMinimumProjectedRadius = 0;
|
|
111
|
+
const definition = {};
|
|
112
|
+
Object.defineProperties(definition, {
|
|
113
|
+
worldRadius: {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: () => validatedWorldRadius,
|
|
116
|
+
set: (value) => {
|
|
117
|
+
_ValidateWorldRadius(value);
|
|
118
|
+
validatedWorldRadius = value;
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
minimumProjectedRadius: {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
get: () => validatedMinimumProjectedRadius,
|
|
124
|
+
set: (value) => {
|
|
125
|
+
_ValidateMinimumProjectedRadius(value);
|
|
126
|
+
validatedMinimumProjectedRadius = value;
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
definition.worldRadius = worldRadius;
|
|
131
|
+
definition.minimumProjectedRadius = minimumProjectedRadius;
|
|
132
|
+
return definition;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Creates a new set of default mesh-blending radius definitions.
|
|
136
|
+
* @returns Four independently mutable radius definitions ordered from small to extra large.
|
|
137
|
+
*/
|
|
138
|
+
export function CreateDefaultMeshBlendRadiusDefinitions() {
|
|
139
|
+
return Object.freeze([
|
|
140
|
+
_CreateValidatedRadiusDefinition(0.06, 1.5),
|
|
141
|
+
_CreateValidatedRadiusDefinition(0.1, 3),
|
|
142
|
+
_CreateValidatedRadiusDefinition(0.2, 3),
|
|
143
|
+
_CreateValidatedRadiusDefinition(0.3, 5),
|
|
144
|
+
]);
|
|
145
|
+
}
|
|
146
|
+
function _MeshBlendLinearToSrgbChannel(value) {
|
|
147
|
+
return value <= 0.0031308 ? value * 12.92 : 1.055 * Math.pow(value, 1 / 2.4) - 0.055;
|
|
148
|
+
}
|
|
149
|
+
function _MeshBlendSrgbToLinearChannel(value) {
|
|
150
|
+
return value <= 0.04045 ? value / 12.92 : Math.pow((value + 0.055) / 1.055, 2.4);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Converts linear sRGB to Babylon mesh-blending OKLab coordinates.
|
|
154
|
+
* @param color Linear sRGB color. HDR components are preserved.
|
|
155
|
+
* @returns OKLab coordinates.
|
|
156
|
+
* @see https://bottosson.github.io/posts/oklab/
|
|
157
|
+
* @internal
|
|
158
|
+
*/
|
|
159
|
+
export function _LinearSrgbToMeshBlendOklab(color) {
|
|
160
|
+
const long = 0.4122214708 * color[0] + 0.5363325363 * color[1] + 0.0514459929 * color[2];
|
|
161
|
+
const medium = 0.2119034982 * color[0] + 0.6806995451 * color[1] + 0.1073969566 * color[2];
|
|
162
|
+
const short = 0.0883024619 * color[0] + 0.2817188376 * color[1] + 0.6299787005 * color[2];
|
|
163
|
+
const longRoot = Math.cbrt(long);
|
|
164
|
+
const mediumRoot = Math.cbrt(medium);
|
|
165
|
+
const shortRoot = Math.cbrt(short);
|
|
166
|
+
return [
|
|
167
|
+
0.2104542553 * longRoot + 0.793617785 * mediumRoot - 0.0040720468 * shortRoot,
|
|
168
|
+
1.9779984951 * longRoot - 2.428592205 * mediumRoot + 0.4505937099 * shortRoot,
|
|
169
|
+
0.0259040371 * longRoot + 0.7827717662 * mediumRoot - 0.808675766 * shortRoot,
|
|
170
|
+
];
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Converts Babylon mesh-blending OKLab coordinates to linear sRGB.
|
|
174
|
+
* @param color OKLab coordinates.
|
|
175
|
+
* @returns Linear sRGB color without gamut or HDR clamping.
|
|
176
|
+
* @see https://bottosson.github.io/posts/oklab/
|
|
177
|
+
* @internal
|
|
178
|
+
*/
|
|
179
|
+
export function _MeshBlendOklabToLinearSrgb(color) {
|
|
180
|
+
const longRoot = color[0] + 0.3963377774 * color[1] + 0.2158037573 * color[2];
|
|
181
|
+
const mediumRoot = color[0] - 0.1055613458 * color[1] - 0.0638541728 * color[2];
|
|
182
|
+
const shortRoot = color[0] - 0.0894841775 * color[1] - 1.291485548 * color[2];
|
|
183
|
+
const long = longRoot * longRoot * longRoot;
|
|
184
|
+
const medium = mediumRoot * mediumRoot * mediumRoot;
|
|
185
|
+
const short = shortRoot * shortRoot * shortRoot;
|
|
186
|
+
return [
|
|
187
|
+
4.0767416621 * long - 3.3077115913 * medium + 0.2309699292 * short,
|
|
188
|
+
-1.2684380046 * long + 2.6097574011 * medium - 0.3413193965 * short,
|
|
189
|
+
-0.0041960863 * long - 0.7034186147 * medium + 1.707614701 * short,
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Interpolates two linear SceneColor values using the selected mesh-blending quality policy.
|
|
194
|
+
* @param current Current linear SceneColor.
|
|
195
|
+
* @param target Target linear SceneColor.
|
|
196
|
+
* @param amount Interpolation amount.
|
|
197
|
+
* @param quality Mesh-blending quality that selects sRGB or OKLab interpolation.
|
|
198
|
+
* @returns Interpolated linear SceneColor without HDR clamping.
|
|
199
|
+
* @internal
|
|
200
|
+
*/
|
|
201
|
+
export function _InterpolateMeshBlendColor(current, target, amount, quality) {
|
|
202
|
+
const settings = _GetMeshBlendQualitySettings(quality);
|
|
203
|
+
let currentColor;
|
|
204
|
+
let targetColor;
|
|
205
|
+
if (settings.colorInterpolation === "sRGB") {
|
|
206
|
+
currentColor = [_MeshBlendLinearToSrgbChannel(current[0]), _MeshBlendLinearToSrgbChannel(current[1]), _MeshBlendLinearToSrgbChannel(current[2])];
|
|
207
|
+
targetColor = [_MeshBlendLinearToSrgbChannel(target[0]), _MeshBlendLinearToSrgbChannel(target[1]), _MeshBlendLinearToSrgbChannel(target[2])];
|
|
208
|
+
return [
|
|
209
|
+
_MeshBlendSrgbToLinearChannel(currentColor[0] + (targetColor[0] - currentColor[0]) * amount),
|
|
210
|
+
_MeshBlendSrgbToLinearChannel(currentColor[1] + (targetColor[1] - currentColor[1]) * amount),
|
|
211
|
+
_MeshBlendSrgbToLinearChannel(currentColor[2] + (targetColor[2] - currentColor[2]) * amount),
|
|
212
|
+
];
|
|
213
|
+
}
|
|
214
|
+
currentColor = _LinearSrgbToMeshBlendOklab(current);
|
|
215
|
+
targetColor = _LinearSrgbToMeshBlendOklab(target);
|
|
216
|
+
return _MeshBlendOklabToLinearSrgb([
|
|
217
|
+
currentColor[0] + (targetColor[0] - currentColor[0]) * amount,
|
|
218
|
+
currentColor[1] + (targetColor[1] - currentColor[1]) * amount,
|
|
219
|
+
currentColor[2] + (targetColor[2] - currentColor[2]) * amount,
|
|
220
|
+
]);
|
|
221
|
+
}
|
|
222
|
+
const _MeshBlendQualitySettings = [
|
|
223
|
+
{
|
|
224
|
+
directionCount: 3,
|
|
225
|
+
radialSampleCount: 2,
|
|
226
|
+
directionRefinementSampleCount: 1,
|
|
227
|
+
directionRefinementStepCount: 2,
|
|
228
|
+
exactEdgeSampleCount: 5,
|
|
229
|
+
radiusScale: 0.5,
|
|
230
|
+
fullRandomRotation: false,
|
|
231
|
+
searchJitterFactor: 0.5,
|
|
232
|
+
immediateFourNeighborFallback: false,
|
|
233
|
+
tinyObjectSafeguard: false,
|
|
234
|
+
multiTargetSecondaryBlend: false,
|
|
235
|
+
colorInterpolation: "sRGB",
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
directionCount: 3,
|
|
239
|
+
radialSampleCount: 3,
|
|
240
|
+
directionRefinementSampleCount: 2,
|
|
241
|
+
directionRefinementStepCount: 4,
|
|
242
|
+
exactEdgeSampleCount: 8,
|
|
243
|
+
radiusScale: 0.9,
|
|
244
|
+
fullRandomRotation: false,
|
|
245
|
+
searchJitterFactor: 0.5,
|
|
246
|
+
immediateFourNeighborFallback: false,
|
|
247
|
+
tinyObjectSafeguard: false,
|
|
248
|
+
multiTargetSecondaryBlend: false,
|
|
249
|
+
colorInterpolation: "OKLab",
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
directionCount: 3,
|
|
253
|
+
radialSampleCount: 3,
|
|
254
|
+
directionRefinementSampleCount: 3,
|
|
255
|
+
directionRefinementStepCount: 5,
|
|
256
|
+
exactEdgeSampleCount: 10,
|
|
257
|
+
radiusScale: 1,
|
|
258
|
+
fullRandomRotation: true,
|
|
259
|
+
searchJitterFactor: 0.5,
|
|
260
|
+
immediateFourNeighborFallback: true,
|
|
261
|
+
tinyObjectSafeguard: true,
|
|
262
|
+
multiTargetSecondaryBlend: true,
|
|
263
|
+
colorInterpolation: "OKLab",
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
directionCount: 8,
|
|
267
|
+
radialSampleCount: 6,
|
|
268
|
+
directionRefinementSampleCount: 4,
|
|
269
|
+
directionRefinementStepCount: 5,
|
|
270
|
+
exactEdgeSampleCount: 50,
|
|
271
|
+
radiusScale: 0.95,
|
|
272
|
+
fullRandomRotation: true,
|
|
273
|
+
searchJitterFactor: 1,
|
|
274
|
+
immediateFourNeighborFallback: true,
|
|
275
|
+
tinyObjectSafeguard: true,
|
|
276
|
+
multiTargetSecondaryBlend: true,
|
|
277
|
+
colorInterpolation: "OKLab",
|
|
278
|
+
},
|
|
279
|
+
];
|
|
280
|
+
/**
|
|
281
|
+
* Gets the complete quality settings used to compile a mesh-blending shader variant.
|
|
282
|
+
* @param quality Quality to inspect.
|
|
283
|
+
* @returns The immutable settings for the quality.
|
|
284
|
+
* @internal
|
|
285
|
+
*/
|
|
286
|
+
export function _GetMeshBlendQualitySettings(quality) {
|
|
287
|
+
const settings = _MeshBlendQualitySettings[quality];
|
|
288
|
+
if (!settings || !Number.isInteger(quality)) {
|
|
289
|
+
throw new RangeError("Mesh-blending quality must be Low, Medium, High, or Cinematic.");
|
|
290
|
+
}
|
|
291
|
+
return settings;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Gets the radius scale used by a mesh-blending quality level.
|
|
295
|
+
* @param quality Quality to convert.
|
|
296
|
+
* @returns The radius scale applied after projection and the minimum-pixel floor.
|
|
297
|
+
* @internal
|
|
298
|
+
*/
|
|
299
|
+
export function _GetMeshBlendQualityRadiusScale(quality) {
|
|
300
|
+
return _GetMeshBlendQualitySettings(quality).radiusScale;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Projects a world-space mesh-blending radius to physical render-target pixels.
|
|
304
|
+
* @param worldRadius Radius in Babylon world units.
|
|
305
|
+
* @param viewDepth Positive distance from the camera.
|
|
306
|
+
* @param renderTargetHeight Physical render-target height.
|
|
307
|
+
* @param projectionYScale Absolute Y scale from the projection matrix.
|
|
308
|
+
* @param isOrthographic Whether the projection is orthographic.
|
|
309
|
+
* @returns The projected radius in physical pixels.
|
|
310
|
+
* @internal
|
|
311
|
+
*/
|
|
312
|
+
export function _ProjectMeshBlendWorldRadiusToPixels(worldRadius, viewDepth, renderTargetHeight, projectionYScale, isOrthographic) {
|
|
313
|
+
const projectionScale = 0.5 * renderTargetHeight * Math.abs(projectionYScale);
|
|
314
|
+
return worldRadius * (isOrthographic ? projectionScale : projectionScale / Math.max(Math.abs(viewDepth), 1e-5));
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Calculates the final mesh-blending search radius.
|
|
318
|
+
* @param definition Radius-class definition.
|
|
319
|
+
* @param viewDepth Positive distance from the camera.
|
|
320
|
+
* @param renderTargetHeight Physical render-target height.
|
|
321
|
+
* @param projectionYScale Absolute Y scale from the projection matrix.
|
|
322
|
+
* @param isOrthographic Whether the projection is orthographic.
|
|
323
|
+
* @param quality Quality whose radius scale is applied.
|
|
324
|
+
* @returns The final radius in physical pixels.
|
|
325
|
+
* @internal
|
|
326
|
+
*/
|
|
327
|
+
export function _CalculateMeshBlendSearchRadius(definition, viewDepth, renderTargetHeight, projectionYScale, isOrthographic, quality) {
|
|
328
|
+
const projectedRadius = _ProjectMeshBlendWorldRadiusToPixels(definition.worldRadius, viewDepth, renderTargetHeight, projectionYScale, isOrthographic);
|
|
329
|
+
const scaledRadius = Math.max(projectedRadius, definition.minimumProjectedRadius) * _GetMeshBlendQualityRadiusScale(quality);
|
|
330
|
+
return scaledRadius > 0 ? Math.max(1, scaledRadius) : 0;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Calculates the mesh-blending fade for a candidate boundary.
|
|
334
|
+
* @param distancePixels Distance from the current pixel center to the target pixel center.
|
|
335
|
+
* @param searchRadiusPixels Effective search radius in physical pixels.
|
|
336
|
+
* @returns Blend weight in the range 0 through 0.5.
|
|
337
|
+
* @internal
|
|
338
|
+
*/
|
|
339
|
+
export function _CalculateMeshBlendFade(distancePixels, searchRadiusPixels) {
|
|
340
|
+
const boundaryDistance = Math.max(distancePixels - 0.5, 0);
|
|
341
|
+
const normalizedDistance = Math.min(Math.max(boundaryDistance / Math.max(searchRadiusPixels, 0.00001), 0), 1);
|
|
342
|
+
const inverseDistance = 1 - normalizedDistance;
|
|
343
|
+
const fade = inverseDistance * inverseDistance + (inverseDistance - inverseDistance * inverseDistance) * Math.min(Math.max(inverseDistance - 0.75, 0), 1);
|
|
344
|
+
return fade * 0.5;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Converts a physical-pixel radius back to the represented world-space radius.
|
|
348
|
+
* @param radiusPixels Radius in physical render-target pixels.
|
|
349
|
+
* @param viewDepth Positive distance from the camera.
|
|
350
|
+
* @param renderTargetHeight Physical render-target height.
|
|
351
|
+
* @param projectionYScale Absolute Y scale from the projection matrix.
|
|
352
|
+
* @param isOrthographic Whether the projection is orthographic.
|
|
353
|
+
* @returns The represented radius in Babylon world units.
|
|
354
|
+
* @internal
|
|
355
|
+
*/
|
|
356
|
+
export function _CalculateMeshBlendEffectiveWorldRadius(radiusPixels, viewDepth, renderTargetHeight, projectionYScale, isOrthographic) {
|
|
357
|
+
const projectionScale = Math.max(0.5 * renderTargetHeight * Math.abs(projectionYScale), 1e-5);
|
|
358
|
+
return radiusPixels * (isOrthographic ? 1 / projectionScale : Math.max(Math.abs(viewDepth), 1e-5) / projectionScale);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Calculates the contact-slope radius multiplier.
|
|
362
|
+
* @param oppositeFacing Cosine-domain alignment of the two surface spans.
|
|
363
|
+
* @param slopeFactor User-configurable narrowing factor.
|
|
364
|
+
* @returns A multiplier in the range [0.25, 1].
|
|
365
|
+
* @internal
|
|
366
|
+
*/
|
|
367
|
+
export function _CalculateMeshBlendSlopeScale(oppositeFacing, slopeFactor) {
|
|
368
|
+
if (slopeFactor <= 1) {
|
|
369
|
+
return 1;
|
|
370
|
+
}
|
|
371
|
+
return 0.25 + 0.75 * Math.pow(Math.max(0, Math.min(oppositeFacing, 1)), slopeFactor - 1);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Gets the compile-time shader define for a mesh-blending quality.
|
|
375
|
+
* @param quality Quality to convert.
|
|
376
|
+
* @returns The quality define.
|
|
377
|
+
* @internal
|
|
378
|
+
*/
|
|
379
|
+
export function _GetMeshBlendQualityDefine(quality) {
|
|
380
|
+
switch (quality) {
|
|
381
|
+
case MeshBlendQuality.Low:
|
|
382
|
+
return "#define MESH_BLEND_QUALITY_LOW";
|
|
383
|
+
case MeshBlendQuality.Medium:
|
|
384
|
+
return "#define MESH_BLEND_QUALITY_MEDIUM";
|
|
385
|
+
case MeshBlendQuality.High:
|
|
386
|
+
return "#define MESH_BLEND_QUALITY_HIGH";
|
|
387
|
+
case MeshBlendQuality.Cinematic:
|
|
388
|
+
return "#define MESH_BLEND_QUALITY_CINEMATIC";
|
|
389
|
+
default:
|
|
390
|
+
throw new RangeError("Mesh-blending quality must be Low, Medium, High, or Cinematic.");
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Gets all compile-time defines for a mesh-blending quality variant.
|
|
395
|
+
* @param quality Quality to convert.
|
|
396
|
+
* @returns Newline-separated shader defines containing all quality-specific constants and feature switches.
|
|
397
|
+
* @internal
|
|
398
|
+
*/
|
|
399
|
+
export function _GetMeshBlendQualityDefines(quality) {
|
|
400
|
+
const settings = _GetMeshBlendQualitySettings(quality);
|
|
401
|
+
const defines = [
|
|
402
|
+
_GetMeshBlendQualityDefine(quality),
|
|
403
|
+
`#define MESH_BLEND_DIRECTION_COUNT ${settings.directionCount}`,
|
|
404
|
+
`#define MESH_BLEND_RADIAL_SAMPLE_COUNT ${settings.radialSampleCount}`,
|
|
405
|
+
`#define MESH_BLEND_DIRECTION_REFINEMENT_SAMPLE_COUNT ${settings.directionRefinementSampleCount}`,
|
|
406
|
+
`#define MESH_BLEND_DIRECTION_REFINEMENT_STEP_COUNT ${settings.directionRefinementStepCount}`,
|
|
407
|
+
`#define MESH_BLEND_EXACT_EDGE_SAMPLE_COUNT ${settings.exactEdgeSampleCount}`,
|
|
408
|
+
`#define MESH_BLEND_RADIUS_SCALE ${settings.radiusScale.toFixed(2)}`,
|
|
409
|
+
`#define MESH_BLEND_JITTER_FACTOR ${settings.searchJitterFactor.toFixed(2)}`,
|
|
410
|
+
];
|
|
411
|
+
if (settings.fullRandomRotation) {
|
|
412
|
+
defines.push("#define MESH_BLEND_FULL_RANDOM_ROTATION");
|
|
413
|
+
}
|
|
414
|
+
if (settings.immediateFourNeighborFallback) {
|
|
415
|
+
defines.push("#define MESH_BLEND_FOUR_NEIGHBOR_FALLBACK");
|
|
416
|
+
}
|
|
417
|
+
if (settings.tinyObjectSafeguard) {
|
|
418
|
+
defines.push("#define MESH_BLEND_TINY_OBJECT_SAFEGUARD");
|
|
419
|
+
}
|
|
420
|
+
if (settings.multiTargetSecondaryBlend) {
|
|
421
|
+
defines.push("#define MESH_BLEND_MULTI_TARGET_SECONDARY_BLEND");
|
|
422
|
+
}
|
|
423
|
+
defines.push(settings.colorInterpolation === "sRGB" ? "#define MESH_BLEND_COLOR_INTERPOLATION_SRGB" : "#define MESH_BLEND_COLOR_INTERPOLATION_OKLAB");
|
|
424
|
+
return defines.join("\n");
|
|
425
|
+
}
|
|
426
|
+
function _ValidateDebugMode(value) {
|
|
427
|
+
if (value < MeshBlendDebugMode.Off || value > MeshBlendDebugMode.WorldPosition || !Number.isInteger(value)) {
|
|
428
|
+
throw new RangeError("Mesh-blending debug mode must be Off, PackedTag, CandidateDirectionDistance, SeamFade, RejectionReason, StageWork, Continuation, TinyObject, MultiTarget, TargetColor, ShadowAttenuation, ColorInterpolation, or WorldPosition.");
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function _ValidateDepthType(value) {
|
|
432
|
+
if (value !== MeshBlendDepthType.View && value !== MeshBlendDepthType.Screen) {
|
|
433
|
+
throw new RangeError("Mesh-blending depthType must be View or Screen.");
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function _NormalizeDefines(defines) {
|
|
437
|
+
return Array.isArray(defines) ? defines.join("\n") : (defines ?? "");
|
|
438
|
+
}
|
|
439
|
+
function _BuildMeshBlendDefines(quality, debugMode, depthType, hasBaseColorTexture, customDefines = "") {
|
|
440
|
+
_ValidateDebugMode(debugMode);
|
|
441
|
+
_ValidateDepthType(depthType);
|
|
442
|
+
const defines = customDefines ? [customDefines, _GetMeshBlendQualityDefines(quality)] : [_GetMeshBlendQualityDefines(quality)];
|
|
443
|
+
if (debugMode !== MeshBlendDebugMode.Off) {
|
|
444
|
+
defines.push("#define MESH_BLEND_DEBUG_ENABLED");
|
|
445
|
+
}
|
|
446
|
+
if (debugMode === MeshBlendDebugMode.PackedTag) {
|
|
447
|
+
defines.push("#define MESH_BLEND_DEBUG_PACKED_TAG");
|
|
448
|
+
}
|
|
449
|
+
else if (debugMode === MeshBlendDebugMode.CandidateDirectionDistance) {
|
|
450
|
+
defines.push("#define MESH_BLEND_DEBUG_CANDIDATE_DIRECTION_DISTANCE");
|
|
451
|
+
}
|
|
452
|
+
else if (debugMode === MeshBlendDebugMode.SeamFade) {
|
|
453
|
+
defines.push("#define MESH_BLEND_DEBUG_SEAM_FADE");
|
|
454
|
+
}
|
|
455
|
+
else if (debugMode === MeshBlendDebugMode.RejectionReason) {
|
|
456
|
+
defines.push("#define MESH_BLEND_DEBUG_REJECTION_REASON");
|
|
457
|
+
}
|
|
458
|
+
else if (debugMode === MeshBlendDebugMode.StageWork) {
|
|
459
|
+
defines.push("#define MESH_BLEND_DEBUG_STAGE_WORK");
|
|
460
|
+
}
|
|
461
|
+
else if (debugMode === MeshBlendDebugMode.Continuation) {
|
|
462
|
+
defines.push("#define MESH_BLEND_DEBUG_CONTINUATION");
|
|
463
|
+
}
|
|
464
|
+
else if (debugMode === MeshBlendDebugMode.TinyObject) {
|
|
465
|
+
defines.push("#define MESH_BLEND_DEBUG_TINY_OBJECT");
|
|
466
|
+
}
|
|
467
|
+
else if (debugMode === MeshBlendDebugMode.MultiTarget) {
|
|
468
|
+
defines.push("#define MESH_BLEND_DEBUG_MULTI_TARGET");
|
|
469
|
+
}
|
|
470
|
+
else if (debugMode === MeshBlendDebugMode.TargetColor) {
|
|
471
|
+
defines.push("#define MESH_BLEND_DEBUG_TARGET_COLOR");
|
|
472
|
+
}
|
|
473
|
+
else if (debugMode === MeshBlendDebugMode.ShadowAttenuation) {
|
|
474
|
+
defines.push("#define MESH_BLEND_DEBUG_SHADOW_ATTENUATION");
|
|
475
|
+
}
|
|
476
|
+
else if (debugMode === MeshBlendDebugMode.ColorInterpolation) {
|
|
477
|
+
defines.push("#define MESH_BLEND_DEBUG_COLOR_INTERPOLATION");
|
|
478
|
+
}
|
|
479
|
+
else if (debugMode === MeshBlendDebugMode.WorldPosition) {
|
|
480
|
+
defines.push("#define MESH_BLEND_DEBUG_WORLD_POSITION");
|
|
481
|
+
}
|
|
482
|
+
if (depthType === MeshBlendDepthType.Screen) {
|
|
483
|
+
defines.push("#define MESH_BLEND_DEPTH_SCREEN");
|
|
484
|
+
}
|
|
485
|
+
if (hasBaseColorTexture) {
|
|
486
|
+
defines.push("#define MESH_BLEND_SHADOW_ESTIMATION");
|
|
487
|
+
}
|
|
488
|
+
return defines.join("\n");
|
|
489
|
+
}
|
|
490
|
+
function _ValidateRadiusDefinition(definition) {
|
|
491
|
+
_ValidateWorldRadius(definition.worldRadius);
|
|
492
|
+
_ValidateMinimumProjectedRadius(definition.minimumProjectedRadius);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Validates mesh-blending configuration without mutating an effect.
|
|
496
|
+
* @param options Configuration to validate.
|
|
497
|
+
* @internal
|
|
498
|
+
*/
|
|
499
|
+
export function _ValidateMeshBlendConfiguration(options) {
|
|
500
|
+
if (!options) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
if (options.quality !== undefined) {
|
|
504
|
+
_GetMeshBlendQualitySettings(options.quality);
|
|
505
|
+
}
|
|
506
|
+
if (options.debugMode !== undefined) {
|
|
507
|
+
_ValidateDebugMode(options.debugMode);
|
|
508
|
+
}
|
|
509
|
+
if (options.depthType !== undefined) {
|
|
510
|
+
_ValidateDepthType(options.depthType);
|
|
511
|
+
}
|
|
512
|
+
if (options.radiusClasses) {
|
|
513
|
+
if (options.radiusClasses.length !== 4) {
|
|
514
|
+
throw new RangeError("Mesh-blending radiusClasses must contain exactly four radius definitions.");
|
|
515
|
+
}
|
|
516
|
+
for (const definition of options.radiusClasses) {
|
|
517
|
+
_ValidateRadiusDefinition(definition);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
if (options.slopeFactor !== undefined && (!Number.isFinite(options.slopeFactor) || options.slopeFactor < 1)) {
|
|
521
|
+
throw new RangeError("Mesh-blending slopeFactor must be a finite number greater than or equal to 1.");
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
function _CopyRadiusDefinitions(target, source) {
|
|
525
|
+
if (!source || source.length !== 4) {
|
|
526
|
+
throw new RangeError("Mesh blending requires exactly four radius definitions.");
|
|
527
|
+
}
|
|
528
|
+
for (const definition of source) {
|
|
529
|
+
_ValidateRadiusDefinition(definition);
|
|
530
|
+
}
|
|
531
|
+
for (let index = 0; index < 4; index++) {
|
|
532
|
+
target[index].worldRadius = source[index].worldRadius;
|
|
533
|
+
target[index].minimumProjectedRadius = source[index].minimumProjectedRadius;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Shared WebGL2 and WebGPU effect wrapper used to visually blend SceneColor across validated contacts between opaque or alpha-tested meshes.
|
|
538
|
+
*
|
|
539
|
+
* The effect does not modify geometry, depth, normals, collisions, or shadows. Transparent rendering is caller-controlled;
|
|
540
|
+
* overlapping transparent surfaces can make SceneColor inconsistent with the single-layer geometry inputs. Meshes opt in
|
|
541
|
+
* with a packed tag whose group is in the range 1..63; group 0 disables blending. Surfaces in the same nonzero group are
|
|
542
|
+
* treated as one logical object and do not blend with one another. The four radius classes combine an authored world-space
|
|
543
|
+
* radius with a minimum radius measured in physical render-target pixels.
|
|
544
|
+
*
|
|
545
|
+
* Perspective and orthographic cameras are supported. Search noise is spatially stable and never varies by frame.
|
|
546
|
+
* Optional base-color input enables shadow estimation; without it, the related sampler and shader work are compiled out.
|
|
547
|
+
* The effect does not require or implement TAA.
|
|
548
|
+
*/
|
|
549
|
+
export class ThinMeshBlendingPostProcess extends EffectWrapper {
|
|
550
|
+
_gatherImports(useWebGPU, list) {
|
|
551
|
+
if (useWebGPU) {
|
|
552
|
+
this._webGPUReady = true;
|
|
553
|
+
list.push(import("../ShadersWGSL/meshBlending.fragment.js"));
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
list.push(import("../Shaders/meshBlending.fragment.js"));
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Contact-slope narrowing factor. A value of 1 disables narrowing.
|
|
561
|
+
*/
|
|
562
|
+
get slopeFactor() {
|
|
563
|
+
return this._slopeFactor;
|
|
564
|
+
}
|
|
565
|
+
set slopeFactor(value) {
|
|
566
|
+
if (!Number.isFinite(value) || value < 1) {
|
|
567
|
+
throw new RangeError("Mesh-blending slopeFactor must be a finite number greater than or equal to 1.");
|
|
568
|
+
}
|
|
569
|
+
this._slopeFactor = value;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Gets the compile-time quality variant.
|
|
573
|
+
*/
|
|
574
|
+
get quality() {
|
|
575
|
+
return this._quality;
|
|
576
|
+
}
|
|
577
|
+
set quality(value) {
|
|
578
|
+
if (this._quality === value) {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
_GetMeshBlendQualitySettings(value);
|
|
582
|
+
this._quality = value;
|
|
583
|
+
this._updateEffectDefines();
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Gets the compiled debug visualization.
|
|
587
|
+
*/
|
|
588
|
+
get debugMode() {
|
|
589
|
+
return this._debugMode;
|
|
590
|
+
}
|
|
591
|
+
set debugMode(value) {
|
|
592
|
+
if (this._debugMode === value) {
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
_ValidateDebugMode(value);
|
|
596
|
+
this._debugMode = value;
|
|
597
|
+
this._updateEffectDefines();
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Gets the representation stored in the bound depth texture.
|
|
601
|
+
*/
|
|
602
|
+
get depthType() {
|
|
603
|
+
return this._depthType;
|
|
604
|
+
}
|
|
605
|
+
set depthType(value) {
|
|
606
|
+
_ValidateDepthType(value);
|
|
607
|
+
if (this._depthType === value) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
this._depthType = value;
|
|
611
|
+
this._updateEffectDefines();
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Whether a base-color texture is bound and shadow estimation should be compiled.
|
|
615
|
+
* @internal
|
|
616
|
+
*/
|
|
617
|
+
get hasBaseColorTexture() {
|
|
618
|
+
return this._hasBaseColorTexture;
|
|
619
|
+
}
|
|
620
|
+
set hasBaseColorTexture(value) {
|
|
621
|
+
if (this._hasBaseColorTexture === value) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
this._hasBaseColorTexture = value;
|
|
625
|
+
this._updateEffectDefines();
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Constructs a mesh-blending post process.
|
|
629
|
+
* @param name Name of the effect.
|
|
630
|
+
* @param engine Engine used to render the effect.
|
|
631
|
+
* @param options Options used to configure the effect.
|
|
632
|
+
*/
|
|
633
|
+
constructor(name, engine = null, options) {
|
|
634
|
+
const resolvedEngine = engine || EngineStore.LastCreatedEngine;
|
|
635
|
+
if (!_IsMeshBlendingSupported(resolvedEngine)) {
|
|
636
|
+
throw new Error("ThinMeshBlendingPostProcess requires WebGL2 or WebGPU");
|
|
637
|
+
}
|
|
638
|
+
const quality = options?.quality ?? MeshBlendQuality.Medium;
|
|
639
|
+
const debugMode = options?.debugMode ?? MeshBlendDebugMode.Off;
|
|
640
|
+
const depthType = options?.depthType ?? MeshBlendDepthType.View;
|
|
641
|
+
const customDefines = _NormalizeDefines(options?.defines ?? null);
|
|
642
|
+
_ValidateMeshBlendConfiguration(options);
|
|
643
|
+
super({
|
|
644
|
+
...options,
|
|
645
|
+
name,
|
|
646
|
+
engine: resolvedEngine,
|
|
647
|
+
useShaderStore: true,
|
|
648
|
+
useAsPostProcess: true,
|
|
649
|
+
fragmentShader: ThinMeshBlendingPostProcess.FragmentUrl,
|
|
650
|
+
uniforms: ThinMeshBlendingPostProcess.Uniforms,
|
|
651
|
+
samplers: ThinMeshBlendingPostProcess.Samplers,
|
|
652
|
+
defines: _BuildMeshBlendDefines(quality, debugMode, depthType, false, customDefines),
|
|
653
|
+
});
|
|
654
|
+
/**
|
|
655
|
+
* The four configurable radius definitions indexed by packed radius class.
|
|
656
|
+
*
|
|
657
|
+
* Both values are projected against the active camera and the physical depth-texture height.
|
|
658
|
+
*/
|
|
659
|
+
this.radiusClasses = CreateDefaultMeshBlendRadiusDefinitions();
|
|
660
|
+
/**
|
|
661
|
+
* Camera used to project radii and reconstruct view-space positions.
|
|
662
|
+
*/
|
|
663
|
+
this.camera = null;
|
|
664
|
+
this._slopeFactor = 2;
|
|
665
|
+
this._quality = MeshBlendQuality.Medium;
|
|
666
|
+
this._debugMode = MeshBlendDebugMode.Off;
|
|
667
|
+
this._depthType = MeshBlendDepthType.View;
|
|
668
|
+
this._hasBaseColorTexture = false;
|
|
669
|
+
this._inverseProjection = new Matrix();
|
|
670
|
+
this._inverseView = new Matrix();
|
|
671
|
+
this._cachedProjection = null;
|
|
672
|
+
this._cachedView = null;
|
|
673
|
+
this._projectionUpdateFlag = -1;
|
|
674
|
+
this._viewUpdateFlag = -1;
|
|
675
|
+
this._customDefines = customDefines;
|
|
676
|
+
this._applyConfiguration(options);
|
|
677
|
+
this._stableBlueNoiseTexture = _CreateMeshBlendBlueNoiseTexture(resolvedEngine);
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Applies shared mesh-blending configuration.
|
|
681
|
+
* @param options Values to apply. Omitted values retain their current settings.
|
|
682
|
+
*/
|
|
683
|
+
configure(options) {
|
|
684
|
+
const definesChanged = this._applyConfiguration(options);
|
|
685
|
+
if (definesChanged) {
|
|
686
|
+
this._updateEffectDefines();
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
_applyConfiguration(options) {
|
|
690
|
+
if (!options) {
|
|
691
|
+
return false;
|
|
692
|
+
}
|
|
693
|
+
_ValidateMeshBlendConfiguration(options);
|
|
694
|
+
const previousQuality = this._quality;
|
|
695
|
+
const previousDebugMode = this._debugMode;
|
|
696
|
+
const previousDepthType = this._depthType;
|
|
697
|
+
if (options.radiusClasses) {
|
|
698
|
+
_CopyRadiusDefinitions(this.radiusClasses, options.radiusClasses);
|
|
699
|
+
}
|
|
700
|
+
if (options.slopeFactor !== undefined) {
|
|
701
|
+
this.slopeFactor = options.slopeFactor;
|
|
702
|
+
}
|
|
703
|
+
if (options.depthType !== undefined) {
|
|
704
|
+
_ValidateDepthType(options.depthType);
|
|
705
|
+
this._depthType = options.depthType;
|
|
706
|
+
}
|
|
707
|
+
const quality = options.quality ?? this._quality;
|
|
708
|
+
const debugMode = options.debugMode ?? this._debugMode;
|
|
709
|
+
_GetMeshBlendQualitySettings(quality);
|
|
710
|
+
_ValidateDebugMode(debugMode);
|
|
711
|
+
this._quality = quality;
|
|
712
|
+
this._debugMode = debugMode;
|
|
713
|
+
return previousQuality !== quality || previousDebugMode !== debugMode || previousDepthType !== this._depthType;
|
|
714
|
+
}
|
|
715
|
+
bind(noDefaultBindings = false) {
|
|
716
|
+
super.bind(noDefaultBindings);
|
|
717
|
+
if (!this.camera) {
|
|
718
|
+
throw new Error("ThinMeshBlendingPostProcess: camera is required before binding.");
|
|
719
|
+
}
|
|
720
|
+
const effect = this._drawWrapper.effect;
|
|
721
|
+
const projection = this._updateInverseProjection();
|
|
722
|
+
for (const definition of this.radiusClasses) {
|
|
723
|
+
_ValidateRadiusDefinition(definition);
|
|
724
|
+
}
|
|
725
|
+
effect.setMatrix("projection", projection);
|
|
726
|
+
effect.setMatrix("inverseProjection", this._inverseProjection);
|
|
727
|
+
if (this._debugMode === MeshBlendDebugMode.WorldPosition) {
|
|
728
|
+
const view = this.camera.getViewMatrix();
|
|
729
|
+
if (this._cachedView !== view || this._viewUpdateFlag !== view.updateFlag) {
|
|
730
|
+
view.invertToRef(this._inverseView);
|
|
731
|
+
this._cachedView = view;
|
|
732
|
+
this._viewUpdateFlag = view.updateFlag;
|
|
733
|
+
}
|
|
734
|
+
effect.setMatrix("inverseView", this._inverseView);
|
|
735
|
+
}
|
|
736
|
+
effect.setFloat4("blendWorldRadii", this.radiusClasses[0].worldRadius, this.radiusClasses[1].worldRadius, this.radiusClasses[2].worldRadius, this.radiusClasses[3].worldRadius);
|
|
737
|
+
effect.setFloat4("minimumProjectedRadii", this.radiusClasses[0].minimumProjectedRadius, this.radiusClasses[1].minimumProjectedRadius, this.radiusClasses[2].minimumProjectedRadius, this.radiusClasses[3].minimumProjectedRadius);
|
|
738
|
+
effect.setFloat("meshBlendIsOrthographic", this.camera.mode === 1 ? 1 : 0);
|
|
739
|
+
effect.setFloat("slopeFactor", this._slopeFactor);
|
|
740
|
+
effect.setTexture("meshBlendBlueNoiseSampler", this._stableBlueNoiseTexture);
|
|
741
|
+
}
|
|
742
|
+
_updateInverseProjection() {
|
|
743
|
+
const projection = this.camera.getProjectionMatrix();
|
|
744
|
+
if (this._cachedProjection !== projection || this._projectionUpdateFlag !== projection.updateFlag) {
|
|
745
|
+
projection.invertToRef(this._inverseProjection);
|
|
746
|
+
this._cachedProjection = projection;
|
|
747
|
+
this._projectionUpdateFlag = projection.updateFlag;
|
|
748
|
+
}
|
|
749
|
+
return projection;
|
|
750
|
+
}
|
|
751
|
+
dispose() {
|
|
752
|
+
this._stableBlueNoiseTexture.dispose();
|
|
753
|
+
super.dispose();
|
|
754
|
+
}
|
|
755
|
+
_updateEffectDefines() {
|
|
756
|
+
this.updateEffect(_BuildMeshBlendDefines(this._quality, this._debugMode, this._depthType, this._hasBaseColorTexture, this._customDefines));
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* The fragment shader URL.
|
|
761
|
+
*/
|
|
762
|
+
ThinMeshBlendingPostProcess.FragmentUrl = "meshBlending";
|
|
763
|
+
/**
|
|
764
|
+
* The list of uniforms used by the effect.
|
|
765
|
+
*/
|
|
766
|
+
ThinMeshBlendingPostProcess.Uniforms = ["projection", "inverseProjection", "inverseView", "blendWorldRadii", "minimumProjectedRadii", "meshBlendIsOrthographic", "slopeFactor"];
|
|
767
|
+
/**
|
|
768
|
+
* The list of samplers used by the effect.
|
|
769
|
+
*/
|
|
770
|
+
ThinMeshBlendingPostProcess.Samplers = ["meshBlendTagSampler", "meshBlendDepthSampler", "meshBlendBaseColorSampler", "meshBlendBlueNoiseSampler"];
|
|
771
|
+
//# sourceMappingURL=thinMeshBlendingPostProcess.js.map
|