@babylonjs/core 7.36.0 → 7.37.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/Cameras/arcRotateCamera.d.ts +3 -1
- package/Cameras/arcRotateCamera.js +14 -3
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Collisions/gpuPicker.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.rawTexture.d.ts +8 -8
- package/Engines/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/Extensions/engine.renderTargetCube.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.d.ts +9 -9
- package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTargetCube.js.map +1 -1
- package/Engines/WebGPU/webgpuConstants.d.ts +6 -0
- package/Engines/WebGPU/webgpuConstants.js +6 -0
- package/Engines/WebGPU/webgpuConstants.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +18 -0
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +6 -0
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.d.ts +1 -1
- package/Engines/abstractEngine.js +4 -4
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/constants.d.ts +17 -1
- package/Engines/constants.js +17 -1
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.d.ts +31 -1
- package/Engines/engine.js +17 -1
- package/Engines/engine.js.map +1 -1
- package/Engines/engineCapabilities.d.ts +2 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/nativeEngine.js +1 -0
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.d.ts +2 -2
- package/Engines/nullEngine.js +3 -2
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.functions.d.ts +4 -0
- package/Engines/thinEngine.functions.js +17 -0
- package/Engines/thinEngine.functions.js.map +1 -1
- package/Engines/thinEngine.js +39 -9
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/Helpers/environmentHelper.js.map +1 -1
- package/Layers/effectLayer.d.ts +1 -1
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.d.ts +1 -1
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.d.ts +1 -1
- package/Layers/highlightLayer.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +12 -2
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLineMaterialInterfaces.d.ts +5 -0
- package/Materials/GreasedLine/greasedLineMaterialInterfaces.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterial.d.ts +21 -5
- package/Materials/GreasedLine/greasedLinePluginMaterial.js +52 -176
- package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.d.ts +11 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js +158 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js.map +1 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.d.ts +11 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js +177 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js.map +1 -0
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +6 -0
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/index.d.ts +1 -0
- package/Materials/Node/Blocks/index.js +1 -0
- package/Materials/Node/Blocks/index.js.map +1 -1
- package/Materials/Node/Blocks/matrixSplitterBlock.d.ts +56 -0
- package/Materials/Node/Blocks/matrixSplitterBlock.js +130 -0
- package/Materials/Node/Blocks/matrixSplitterBlock.js.map +1 -0
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
- package/Materials/PBR/pbrBaseMaterial.js +12 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/MultiviewRenderTarget.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/colorGradingTexture.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/Textures/rawCubeTexture.d.ts +2 -2
- package/Materials/Textures/rawCubeTexture.js +2 -2
- package/Materials/Textures/rawCubeTexture.js.map +1 -1
- package/Materials/Textures/rawTexture.js.map +1 -1
- package/Materials/Textures/rawTexture2DArray.d.ts +1 -1
- package/Materials/Textures/rawTexture2DArray.js +1 -1
- package/Materials/Textures/rawTexture2DArray.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/renderTargetTexture.js.map +1 -1
- package/Materials/drawWrapper.d.ts +6 -1
- package/Materials/drawWrapper.js +18 -2
- package/Materials/drawWrapper.js.map +1 -1
- package/Materials/effect.d.ts +6 -1
- package/Materials/effect.functions.d.ts +5 -0
- package/Materials/effect.functions.js +19 -0
- package/Materials/effect.functions.js.map +1 -1
- package/Materials/effect.js +22 -20
- package/Materials/effect.js.map +1 -1
- package/Materials/effect.webgl.functions.js +12 -4
- package/Materials/effect.webgl.functions.js.map +1 -1
- package/Materials/effectRenderer.js +1 -1
- package/Materials/effectRenderer.js.map +1 -1
- package/Maths/math.scalar.d.ts +0 -1
- package/Maths/math.scalar.js +1 -2
- package/Maths/math.scalar.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.js +2 -2
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +17 -3
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +69 -20
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +5 -3
- package/Meshes/abstractMesh.hotSpot.d.ts +8 -1
- package/Meshes/abstractMesh.hotSpot.js +17 -0
- package/Meshes/abstractMesh.hotSpot.js.map +1 -1
- package/Meshes/abstractMesh.js +9 -7
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/linesMesh.js +1 -1
- package/Meshes/linesMesh.js.map +1 -1
- package/Meshes/subMesh.d.ts +5 -3
- package/Meshes/subMesh.js +9 -7
- package/Meshes/subMesh.js.map +1 -1
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
- package/Misc/dds.d.ts +1 -1
- package/Misc/dds.js.map +1 -1
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/observable.d.ts +1 -3
- package/Misc/observable.js +7 -7
- package/Misc/observable.js.map +1 -1
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/snapshotRenderingHelper.js +3 -0
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Misc/textureTools.js.map +1 -1
- package/Misc/virtualJoystick.js +2 -0
- package/Misc/virtualJoystick.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.d.ts +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
- package/PostProcesses/bloomMergePostProcess.js.map +1 -1
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/chromaticAberrationPostProcess.js.map +1 -1
- package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
- package/PostProcesses/convolutionPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
- package/PostProcesses/extractHighlightsPostProcess.js.map +1 -1
- package/PostProcesses/fxaaPostProcess.js.map +1 -1
- package/PostProcesses/grainPostProcess.js.map +1 -1
- package/PostProcesses/highlightsPostProcess.d.ts +1 -1
- package/PostProcesses/highlightsPostProcess.js +1 -1
- package/PostProcesses/highlightsPostProcess.js.map +1 -1
- package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
- package/PostProcesses/motionBlurPostProcess.js.map +1 -1
- package/PostProcesses/passPostProcess.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +1 -1
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
- package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
- package/PostProcesses/sharpenPostProcess.js.map +1 -1
- package/PostProcesses/subSurfaceScatteringPostProcess.js.map +1 -1
- package/PostProcesses/tonemapPostProcess.d.ts +1 -1
- package/PostProcesses/tonemapPostProcess.js +1 -1
- package/PostProcesses/tonemapPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +3 -23
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +30 -67
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +8 -4
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Rendering/{IBLShadows/iblShadowsImportanceSamplingRenderer.d.ts → iblCdfGenerator.d.ts} +15 -12
- package/Rendering/{IBLShadows/iblShadowsImportanceSamplingRenderer.js → iblCdfGenerator.js} +37 -27
- package/Rendering/iblCdfGenerator.js.map +1 -0
- package/Rendering/iblCdfGeneratorSceneComponent.d.ts +59 -0
- package/Rendering/iblCdfGeneratorSceneComponent.js +83 -0
- package/Rendering/iblCdfGeneratorSceneComponent.js.map +1 -0
- package/Rendering/index.d.ts +12 -10
- package/Rendering/index.js +12 -10
- package/Rendering/index.js.map +1 -1
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +72 -2
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +29 -4
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js +9 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +9 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +3 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +16 -2
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/{iblShadowsCdfy.fragment.d.ts → iblCdfx.fragment.d.ts} +1 -1
- package/Shaders/{iblShadowsCdfx.fragment.js → iblCdfx.fragment.js} +3 -3
- package/Shaders/iblCdfx.fragment.js.map +1 -0
- package/Shaders/{iblShadowsCdfx.fragment.d.ts → iblCdfy.fragment.d.ts} +1 -1
- package/Shaders/{iblShadowsCdfy.fragment.js → iblCdfy.fragment.js} +3 -3
- package/Shaders/iblCdfy.fragment.js.map +1 -0
- package/Shaders/{iblShadowsIcdfx.fragment.d.ts → iblIcdfx.fragment.d.ts} +1 -1
- package/Shaders/{iblShadowsIcdfx.fragment.js → iblIcdfx.fragment.js} +3 -3
- package/Shaders/iblIcdfx.fragment.js.map +1 -0
- package/Shaders/{iblShadowsIcdfy.fragment.d.ts → iblIcdfy.fragment.d.ts} +1 -1
- package/Shaders/{iblShadowsIcdfy.fragment.js → iblIcdfy.fragment.js} +3 -3
- package/Shaders/iblIcdfy.fragment.js.map +1 -0
- package/Shaders/importanceSamplingDebug.fragment.d.ts +5 -0
- package/Shaders/{iblShadowsImportanceSamplingDebug.fragment.js → importanceSamplingDebug.fragment.js} +3 -3
- package/Shaders/importanceSamplingDebug.fragment.js.map +1 -0
- package/Shaders/pbr.fragment.js +8 -0
- package/Shaders/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +77 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +28 -4
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/oitFragment.js +1 -1
- package/ShadersWGSL/ShadersInclude/oitFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js +14 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js +14 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +18 -2
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/iblCdfx.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsCdfx.fragment.js → iblCdfx.fragment.js} +3 -3
- package/ShadersWGSL/iblCdfx.fragment.js.map +1 -0
- package/ShadersWGSL/iblCdfy.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsCdfy.fragment.js → iblCdfy.fragment.js} +3 -3
- package/ShadersWGSL/iblCdfy.fragment.js.map +1 -0
- package/ShadersWGSL/iblIcdfx.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsIcdfx.fragment.js → iblIcdfx.fragment.js} +3 -3
- package/ShadersWGSL/iblIcdfx.fragment.js.map +1 -0
- package/ShadersWGSL/iblIcdfy.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsIcdfy.fragment.js → iblIcdfy.fragment.js} +3 -3
- package/ShadersWGSL/iblIcdfy.fragment.js.map +1 -0
- package/ShadersWGSL/importanceSamplingDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsImportanceSamplingDebug.fragment.js → importanceSamplingDebug.fragment.js} +3 -3
- package/ShadersWGSL/importanceSamplingDebug.fragment.js.map +1 -0
- package/ShadersWGSL/pbr.fragment.js +12 -0
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +4 -0
- package/scene.js +6 -0
- package/scene.js.map +1 -1
- package/sceneComponent.d.ts +1 -1
- package/sceneComponent.js +1 -1
- package/sceneComponent.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.js.map +0 -1
- package/Shaders/iblShadowsCdfx.fragment.js.map +0 -1
- package/Shaders/iblShadowsCdfy.fragment.js.map +0 -1
- package/Shaders/iblShadowsIcdfx.fragment.js.map +0 -1
- package/Shaders/iblShadowsIcdfy.fragment.js.map +0 -1
- package/Shaders/iblShadowsImportanceSamplingDebug.fragment.d.ts +0 -5
- package/Shaders/iblShadowsImportanceSamplingDebug.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsCdfx.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsCdfx.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsCdfy.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsCdfy.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsIcdfx.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsIcdfx.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsIcdfy.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsIcdfy.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { _processShaderCode, createAndPreparePipelineContext } from "./effect.functions.js";
|
|
2
|
-
import { _executeWhenRenderingStateIsCompiled, _preparePipelineContext, createPipelineContext, getStateObject } from "../Engines/thinEngine.functions.js";
|
|
1
|
+
import { _processShaderCode, _retryWithInterval, createAndPreparePipelineContext } from "./effect.functions.js";
|
|
2
|
+
import { _executeWhenRenderingStateIsCompiled, _isRenderingStateCompiled, _preparePipelineContext, createPipelineContext, getStateObject } from "../Engines/thinEngine.functions.js";
|
|
3
3
|
import { _getGlobalDefines } from "../Engines/abstractEngine.functions.js";
|
|
4
4
|
import { ShaderStore } from "../Engines/shaderStore.js";
|
|
5
|
+
import { WebGL2ShaderProcessor } from "../Engines/WebGL/webGL2ShaderProcessors.js";
|
|
5
6
|
/**
|
|
6
7
|
* Generate a pipeline context from the provided options
|
|
7
8
|
* Note - at the moment only WebGL is supported
|
|
@@ -26,7 +27,8 @@ export async function generatePipelineContext(options, context, createPipelineCo
|
|
|
26
27
|
break;
|
|
27
28
|
case "WEBGL2":
|
|
28
29
|
default:
|
|
29
|
-
|
|
30
|
+
// default to WebGL2, which is included in the package. Avoid async-load the default.
|
|
31
|
+
processor = new WebGL2ShaderProcessor();
|
|
30
32
|
break;
|
|
31
33
|
}
|
|
32
34
|
}
|
|
@@ -67,7 +69,13 @@ export async function generatePipelineContext(options, context, createPipelineCo
|
|
|
67
69
|
transformFeedbackVaryings: null,
|
|
68
70
|
...options.extendedCreatePipelineOptions,
|
|
69
71
|
}, createPipelineContextInjection, _preparePipelineContext, _executeWhenRenderingStateIsCompiled);
|
|
70
|
-
resolve
|
|
72
|
+
// the default behavior so far. If not async or no request to wait for isReady, resolve immediately
|
|
73
|
+
if (!options.waitForIsReady || !pipeline.isAsync) {
|
|
74
|
+
resolve(pipeline);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
_retryWithInterval(() => _isRenderingStateCompiled(pipeline, context), () => resolve(pipeline), () => reject(new Error("Timeout while waiting for pipeline to be ready")));
|
|
78
|
+
}
|
|
71
79
|
}
|
|
72
80
|
catch (e) {
|
|
73
81
|
reject(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.webgl.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/effect.webgl.functions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"effect.webgl.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/effect.webgl.functions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AAE7G,OAAO,EAAE,oCAAoC,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,cAAc,EAAE,2CAA0C;AAE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C,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;wBACnD,uBAAuB,EAAE,OAAO,CAAC,yBAAyB,EAAE,iBAAiB,IAAI,IAAI;wBACrF,yBAAyB,EAAE,IAAI;wBAC/B,GAAG,OAAO,CAAC,6BAA6B;qBAC3C,EACD,8BAA8B,EAC9B,uBAAuB,EACvB,oCAAoC,CACvC,CAAC;oBACF,mGAAmG;oBACnG,IAAI,CAAC,OAAO,CAAC,cAAc,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;wBAC/C,OAAO,CAAC,QAAQ,CAAC,CAAC;oBACtB,CAAC;yBAAM,CAAC;wBACJ,kBAAkB,CACd,GAAG,EAAE,CAAC,yBAAyB,CAAC,QAAQ,EAAE,OAAO,CAAC,EAClD,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,EACvB,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC,CAC5E,CAAC;oBACN,CAAC;gBACL,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACT,MAAM,CAAC,CAAC,CAAC,CAAC;gBACd,CAAC;YACL,CAAC,EACD,QAAQ,CACX,CAAC;QACN,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,MAAM,CAAC,CAAC,CAAC,CAAC;QACd,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { IPipelineGenerationOptions } from \"./effect.functions\";\r\nimport { _processShaderCode, _retryWithInterval, createAndPreparePipelineContext } from \"./effect.functions\";\r\nimport type { IPipelineContext } from \"core/Engines/IPipelineContext\";\r\nimport { _executeWhenRenderingStateIsCompiled, _isRenderingStateCompiled, _preparePipelineContext, createPipelineContext, getStateObject } from \"core/Engines/thinEngine.functions\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\nimport { _getGlobalDefines } from \"core/Engines/abstractEngine.functions\";\r\nimport type { ProcessingOptions } from \"core/Engines/Processors/shaderProcessingOptions\";\r\nimport { ShaderStore } from \"core/Engines/shaderStore\";\r\nimport { WebGL2ShaderProcessor } from \"core/Engines/WebGL/webGL2ShaderProcessors\";\r\n\r\n/**\r\n * Generate a pipeline context from the provided options\r\n * Note - at the moment only WebGL is supported\r\n * @param options the options to be used when generating the pipeline\r\n * @param context the context to be used when creating the pipeline\r\n * @param createPipelineContextInjection the function to create the pipeline context\r\n * @param _preparePipelineContextInjection the function to prepare the pipeline context\r\n * @returns a promise that resolves to the pipeline context\r\n */\r\nexport async function generatePipelineContext(\r\n options: IPipelineGenerationOptions,\r\n context: WebGL2RenderingContext | WebGLRenderingContext,\r\n createPipelineContextInjection: typeof AbstractEngine.prototype.createPipelineContext = createPipelineContext.bind(null, context),\r\n _preparePipelineContextInjection: typeof AbstractEngine.prototype._preparePipelineContext = _preparePipelineContext\r\n): Promise<IPipelineContext> {\r\n // make sure the state object exists\r\n getStateObject(context);\r\n const platformName = options.platformName || \"WEBGL2\";\r\n let processor = options.extendedProcessingOptions?.processor;\r\n const language = options.shaderLanguage || ShaderLanguage.GLSL;\r\n // auto-populate the processor if not provided\r\n // Note - async but can be synchronous if we load all dependencies at the start\r\n if (!processor) {\r\n switch (platformName) {\r\n case \"WEBGL1\":\r\n processor = new (await import(\"core/Engines/WebGL/webGLShaderProcessors\")).WebGLShaderProcessor();\r\n break;\r\n case \"WEBGL2\":\r\n default:\r\n // default to WebGL2, which is included in the package. Avoid async-load the default.\r\n processor = new WebGL2ShaderProcessor();\r\n break;\r\n }\r\n }\r\n const shaderDef: any = options.shaderNameOrContent;\r\n const vertex = shaderDef.vertex || shaderDef.vertexSource || shaderDef;\r\n const fragment = shaderDef.fragment || shaderDef.fragmentSource || shaderDef;\r\n const globalDefines = _getGlobalDefines()?.split(\"\\n\") || [];\r\n const defines = [...(options.defines || []), ...(options.addGlobalDefines ? globalDefines : [])];\r\n const key = options.key?.replace(/\\r/g, \"\").replace(/\\n/g, \"|\") || vertex + \"+\" + fragment + \"@\" + defines.join(\"|\");\r\n // defaults, extended with optionally provided options\r\n const processorOptions: ProcessingOptions = {\r\n defines,\r\n indexParameters: undefined,\r\n isFragment: false,\r\n shouldUseHighPrecisionShader: true,\r\n processor,\r\n supportsUniformBuffers: false,\r\n shadersRepository: ShaderStore.GetShadersRepository(language),\r\n includesShadersStore: ShaderStore.GetIncludesShadersStore(language),\r\n version: platformName === \"WEBGL2\" ? \"200\" : \"100\",\r\n platformName,\r\n processingContext: null,\r\n isNDCHalfZRange: false,\r\n useReverseDepthBuffer: false,\r\n ...options.extendedProcessingOptions,\r\n };\r\n return new Promise((resolve, reject) => {\r\n try {\r\n _processShaderCode(\r\n processorOptions,\r\n shaderDef,\r\n undefined,\r\n function (vertexCode, fragmentCode) {\r\n try {\r\n const pipeline = createAndPreparePipelineContext(\r\n {\r\n name: key,\r\n vertex: vertexCode,\r\n fragment: fragmentCode,\r\n context,\r\n defines: defines.length ? defines.join(\"\\n\") : null,\r\n shaderProcessingContext: options.extendedProcessingOptions?.processingContext || null,\r\n transformFeedbackVaryings: null,\r\n ...options.extendedCreatePipelineOptions,\r\n },\r\n createPipelineContextInjection,\r\n _preparePipelineContext,\r\n _executeWhenRenderingStateIsCompiled\r\n );\r\n // the default behavior so far. If not async or no request to wait for isReady, resolve immediately\r\n if (!options.waitForIsReady || !pipeline.isAsync) {\r\n resolve(pipeline);\r\n } else {\r\n _retryWithInterval(\r\n () => _isRenderingStateCompiled(pipeline, context),\r\n () => resolve(pipeline),\r\n () => reject(new Error(\"Timeout while waiting for pipeline to be ready\"))\r\n );\r\n }\r\n } catch (e) {\r\n reject(e);\r\n }\r\n },\r\n language\r\n );\r\n } catch (e) {\r\n reject(e);\r\n }\r\n });\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effectRenderer.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/effectRenderer.ts"],"names":[],"mappings":"AA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AI,CAAC,0BAA0B,GAAG,IAAI,CAAC;QAC3C,CAAC;QACD,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;;AA/VD;;;GAGG;AACW,uBAAS,GAAG,KAAK,AAAR,CAAS;AAEjB,yCAA2B,GAA6E,EAAE,AAA/E,CAAgF","sourcesContent":["import type { NonNullableFields, Nullable } from \"../types\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Viewport } from \"../Maths/math.viewport\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { IShaderPath } from \"./effect\";\r\nimport { Effect } from \"./effect\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { DrawWrapper } from \"./drawWrapper\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\n\r\n// Prevents ES6 issue if not imported.\r\nimport \"../Shaders/postprocess.vertex\";\r\n\r\n/**\r\n * Effect Render Options\r\n */\r\nexport interface IEffectRendererOptions {\r\n /**\r\n * Defines the vertices positions.\r\n */\r\n positions?: number[];\r\n /**\r\n * Defines the indices.\r\n */\r\n indices?: number[];\r\n}\r\n\r\n// Fullscreen quad buffers by default.\r\nconst defaultOptions = {\r\n positions: [1, 1, -1, 1, -1, -1, 1, -1],\r\n indices: [0, 1, 2, 0, 2, 3],\r\n};\r\n\r\n/**\r\n * Helper class to render one or more effects.\r\n * You can access the previous rendering in your shader by declaring a sampler named textureSampler\r\n */\r\nexport class EffectRenderer {\r\n /**\r\n * The engine the effect renderer has been created for.\r\n */\r\n public readonly engine: AbstractEngine;\r\n\r\n private _vertexBuffers: { [key: string]: VertexBuffer };\r\n private _indexBuffer: DataBuffer;\r\n\r\n private _fullscreenViewport = new Viewport(0, 0, 1, 1);\r\n private _onContextRestoredObserver: Nullable<Observer<AbstractEngine>>;\r\n\r\n private _savedStateDepthTest: boolean;\r\n private _savedStateStencilTest: boolean;\r\n\r\n /**\r\n * Creates an effect renderer\r\n * @param engine the engine to use for rendering\r\n * @param options defines the options of the effect renderer\r\n */\r\n constructor(engine: AbstractEngine, options: IEffectRendererOptions = defaultOptions) {\r\n const positions = options.positions ?? defaultOptions.positions;\r\n const indices = options.indices ?? defaultOptions.indices;\r\n\r\n this.engine = engine;\r\n this._vertexBuffers = {\r\n [VertexBuffer.PositionKind]: new VertexBuffer(engine, positions, VertexBuffer.PositionKind, false, false, 2),\r\n };\r\n this._indexBuffer = engine.createIndexBuffer(indices);\r\n\r\n this._onContextRestoredObserver = engine.onContextRestoredObservable.add(() => {\r\n this._indexBuffer = engine.createIndexBuffer(indices);\r\n\r\n for (const key in this._vertexBuffers) {\r\n const vertexBuffer = this._vertexBuffers[key];\r\n vertexBuffer._rebuild();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Sets the current viewport in normalized coordinates 0-1\r\n * @param viewport Defines the viewport to set (defaults to 0 0 1 1)\r\n */\r\n public setViewport(viewport = this._fullscreenViewport): void {\r\n this.engine.setViewport(viewport);\r\n }\r\n\r\n /**\r\n * Binds the embedded attributes buffer to the effect.\r\n * @param effect Defines the effect to bind the attributes for\r\n */\r\n public bindBuffers(effect: Effect): void {\r\n this.engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);\r\n }\r\n\r\n /**\r\n * Sets the current effect wrapper to use during draw.\r\n * The effect needs to be ready before calling this api.\r\n * This also sets the default full screen position attribute.\r\n * @param effectWrapper Defines the effect to draw with\r\n */\r\n public applyEffectWrapper(effectWrapper: EffectWrapper): void {\r\n this.engine.setState(true);\r\n this.engine.depthCullingState.depthTest = false;\r\n this.engine.stencilState.stencilTest = false;\r\n this.engine.enableEffect(effectWrapper.drawWrapper);\r\n this.bindBuffers(effectWrapper.effect);\r\n effectWrapper.onApplyObservable.notifyObservers({});\r\n }\r\n\r\n /**\r\n * Saves engine states\r\n */\r\n public saveStates(): void {\r\n this._savedStateDepthTest = this.engine.depthCullingState.depthTest;\r\n this._savedStateStencilTest = this.engine.stencilState.stencilTest;\r\n }\r\n\r\n /**\r\n * Restores engine states\r\n */\r\n public restoreStates(): void {\r\n this.engine.depthCullingState.depthTest = this._savedStateDepthTest;\r\n this.engine.stencilState.stencilTest = this._savedStateStencilTest;\r\n }\r\n\r\n /**\r\n * Draws a full screen quad.\r\n */\r\n public draw(): void {\r\n this.engine.drawElementsType(Constants.MATERIAL_TriangleFillMode, 0, 6);\r\n }\r\n\r\n private _isRenderTargetTexture(texture: RenderTargetWrapper | IRenderTargetTexture): texture is IRenderTargetTexture {\r\n return (texture as IRenderTargetTexture).renderTarget !== undefined;\r\n }\r\n\r\n /**\r\n * renders one or more effects to a specified texture\r\n * @param effectWrapper the effect to renderer\r\n * @param outputTexture texture to draw to, if null it will render to the currently bound frame buffer\r\n */\r\n public render(effectWrapper: EffectWrapper, outputTexture: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null) {\r\n // Ensure effect is ready\r\n if (!effectWrapper.effect.isReady()) {\r\n return;\r\n }\r\n\r\n this.saveStates();\r\n\r\n // Reset state\r\n this.setViewport();\r\n\r\n const out = outputTexture === null ? null : this._isRenderTargetTexture(outputTexture) ? outputTexture.renderTarget! : outputTexture;\r\n\r\n if (out) {\r\n this.engine.bindFramebuffer(out);\r\n }\r\n\r\n this.applyEffectWrapper(effectWrapper);\r\n\r\n this.draw();\r\n\r\n if (out) {\r\n this.engine.unBindFramebuffer(out);\r\n }\r\n\r\n this.restoreStates();\r\n }\r\n\r\n /**\r\n * Disposes of the effect renderer\r\n */\r\n dispose() {\r\n const vertexBuffer = this._vertexBuffers[VertexBuffer.PositionKind];\r\n if (vertexBuffer) {\r\n vertexBuffer.dispose();\r\n delete this._vertexBuffers[VertexBuffer.PositionKind];\r\n }\r\n\r\n if (this._indexBuffer) {\r\n this.engine._releaseBuffer(this._indexBuffer);\r\n }\r\n\r\n if (this._onContextRestoredObserver) {\r\n this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Allows for custom processing of the shader code used by an effect wrapper\r\n */\r\nexport type EffectWrapperCustomShaderCodeProcessing = {\r\n /**\r\n * If provided, will be called two times with the vertex and fragment code so that this code can be updated after the #include have been processed\r\n */\r\n processCodeAfterIncludes?: (postProcessName: string, shaderType: string, code: string) => string;\r\n /**\r\n * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU\r\n */\r\n processFinalCode?: (postProcessName: string, shaderType: string, code: string) => string;\r\n /**\r\n * If provided, will be called before creating the effect to collect additional custom bindings (defines, uniforms, samplers)\r\n */\r\n defineCustomBindings?: (postProcessName: string, defines: Nullable<string>, uniforms: string[], samplers: string[]) => Nullable<string>;\r\n /**\r\n * If provided, will be called when binding inputs to the shader code to allow the user to add custom bindings\r\n */\r\n bindCustomBindings?: (postProcessName: string, effect: Effect) => void;\r\n};\r\n\r\n/**\r\n * Options to create an EffectWrapper\r\n */\r\nexport interface EffectWrapperCreationOptions {\r\n /**\r\n * Engine to use to create the effect\r\n */\r\n engine?: AbstractEngine;\r\n /**\r\n * Fragment shader for the effect\r\n */\r\n fragmentShader?: string;\r\n /**\r\n * Use the shader store instead of direct source code\r\n */\r\n useShaderStore?: boolean;\r\n /**\r\n * Vertex shader for the effect (default: \"postprocess\")\r\n */\r\n vertexShader?: string;\r\n /**\r\n * Alias for vertexShader\r\n */\r\n vertexUrl?: string;\r\n /**\r\n * Attributes to use in the shader (default: [\"position\"])\r\n */\r\n attributeNames?: Array<string>;\r\n /**\r\n * Uniforms to use in the shader\r\n */\r\n uniformNames?: Array<string>;\r\n /**\r\n * Alias for uniformNames. Note that if it is provided, it takes precedence over uniformNames.\r\n */\r\n uniforms?: Nullable<string[]>;\r\n /**\r\n * Texture sampler names to use in the shader\r\n */\r\n samplerNames?: Array<string>;\r\n /**\r\n * Alias for samplerNames. Note that if it is provided, it takes precedence over samplerNames.\r\n */\r\n samplers?: Nullable<string[]>;\r\n /**\r\n * The list of uniform buffers used in the shader (if any)\r\n */\r\n uniformBuffers?: Nullable<string[]>;\r\n /**\r\n * Defines to use in the shader\r\n */\r\n defines?: Nullable<string | Array<string>>;\r\n /**\r\n * The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined)\r\n * See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n */\r\n indexParameters?: any;\r\n /**\r\n * If the shader should not be compiled immediately. (default: false)\r\n */\r\n blockCompilation?: boolean;\r\n /**\r\n * Callback when effect is compiled\r\n */\r\n onCompiled?: Nullable<(effect: Effect) => void>;\r\n /**\r\n * The friendly name of the effect (default: \"effectWrapper\")\r\n */\r\n name?: string;\r\n /**\r\n * The language the shader is written in (default: GLSL)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n /**\r\n * Defines additional code to call to prepare the shader code\r\n */\r\n extraInitializations?: (useWebGPU: boolean, list: Promise<any>[]) => void;\r\n /**\r\n * Additional async code to run before preparing the effect\r\n */\r\n extraInitializationsAsync?: () => Promise<void>;\r\n /**\r\n * If the effect should be used as a post process (default: false). If true, the effect will be created with a \"scale\" uniform and a \"textureSampler\" sampler\r\n */\r\n useAsPostProcess?: boolean;\r\n}\r\n\r\n/**\r\n * Wraps an effect to be used for rendering\r\n */\r\nexport class EffectWrapper {\r\n /**\r\n * Force code to compile to glsl even on WebGPU engines.\r\n * False by default. This is mostly meant for backward compatibility.\r\n */\r\n public static ForceGLSL = false;\r\n\r\n private static _CustomShaderCodeProcessing: { [effectWrapperName: string]: EffectWrapperCustomShaderCodeProcessing } = {};\r\n\r\n /**\r\n * Registers a shader code processing with an effect wrapper name.\r\n * @param effectWrapperName name of the effect wrapper. Use null for the fallback shader code processing. This is the shader code processing that will be used in case no specific shader code processing has been associated to an effect wrapper name\r\n * @param customShaderCodeProcessing shader code processing to associate to the effect wrapper name\r\n */\r\n public static RegisterShaderCodeProcessing(effectWrapperName: Nullable<string>, customShaderCodeProcessing?: EffectWrapperCustomShaderCodeProcessing) {\r\n if (!customShaderCodeProcessing) {\r\n delete EffectWrapper._CustomShaderCodeProcessing[effectWrapperName ?? \"\"];\r\n return;\r\n }\r\n\r\n EffectWrapper._CustomShaderCodeProcessing[effectWrapperName ?? \"\"] = customShaderCodeProcessing;\r\n }\r\n\r\n private static _GetShaderCodeProcessing(effectWrapperName: string) {\r\n return EffectWrapper._CustomShaderCodeProcessing[effectWrapperName] ?? EffectWrapper._CustomShaderCodeProcessing[\"\"];\r\n }\r\n\r\n /**\r\n * Gets or sets the name of the effect wrapper\r\n */\r\n public get name() {\r\n return this.options.name;\r\n }\r\n\r\n public set name(value: string) {\r\n this.options.name = value;\r\n }\r\n\r\n /**\r\n * Type of alpha mode to use when applying the effect (default: Engine.ALPHA_DISABLE). Used only if useAsPostProcess is true.\r\n */\r\n public alphaMode = Constants.ALPHA_DISABLE;\r\n\r\n /**\r\n * Executed when the effect is created\r\n * @returns effect that was created for this effect wrapper\r\n */\r\n public onEffectCreatedObservable = new Observable<Effect>(undefined, true);\r\n\r\n /**\r\n * Options used to create the effect wrapper\r\n */\r\n public readonly options: Required<NonNullableFields<EffectWrapperCreationOptions>>;\r\n\r\n /**\r\n * Get a value indicating if the effect is ready to be used\r\n * @returns true if the post-process is ready (shader is compiled)\r\n */\r\n public isReady() {\r\n return this._drawWrapper.effect?.isReady() ?? false;\r\n }\r\n\r\n /**\r\n * Get the draw wrapper associated with the effect wrapper\r\n * @returns the draw wrapper associated with the effect wrapper\r\n */\r\n public get drawWrapper() {\r\n return this._drawWrapper;\r\n }\r\n\r\n /**\r\n * Event that is fired (only when the EffectWrapper is used with an EffectRenderer) right before the effect is drawn (should be used to update uniforms)\r\n */\r\n public onApplyObservable = new Observable<{}>();\r\n\r\n /**\r\n * The underlying effect\r\n */\r\n public get effect(): Effect {\r\n return this._drawWrapper.effect!;\r\n }\r\n\r\n public set effect(effect: Effect) {\r\n this._drawWrapper.effect = effect;\r\n }\r\n\r\n protected readonly _drawWrapper: DrawWrapper;\r\n protected _shadersLoaded = false;\r\n protected readonly _shaderPath: IShaderPath;\r\n /** @internal */\r\n public _webGPUReady = false;\r\n\r\n private _onContextRestoredObserver: Nullable<Observer<AbstractEngine>>;\r\n\r\n /**\r\n * Creates an effect to be rendered\r\n * @param creationOptions options to create the effect\r\n */\r\n constructor(creationOptions: EffectWrapperCreationOptions) {\r\n this.options = {\r\n ...creationOptions,\r\n name: creationOptions.name || \"effectWrapper\",\r\n engine: creationOptions.engine!,\r\n uniforms: creationOptions.uniforms || creationOptions.uniformNames || [],\r\n uniformNames: undefined as any,\r\n samplers: creationOptions.samplers || creationOptions.samplerNames || [],\r\n samplerNames: undefined as any,\r\n attributeNames: creationOptions.attributeNames || [\"position\"],\r\n uniformBuffers: creationOptions.uniformBuffers || [],\r\n defines: creationOptions.defines || \"\",\r\n useShaderStore: creationOptions.useShaderStore || false,\r\n vertexUrl: creationOptions.vertexUrl || creationOptions.vertexShader || \"postprocess\",\r\n vertexShader: undefined as any,\r\n fragmentShader: creationOptions.fragmentShader || \"pass\",\r\n indexParameters: creationOptions.indexParameters,\r\n blockCompilation: creationOptions.blockCompilation || false,\r\n shaderLanguage: creationOptions.shaderLanguage || ShaderLanguage.GLSL,\r\n onCompiled: creationOptions.onCompiled || (undefined as any),\r\n extraInitializations: creationOptions.extraInitializations || (undefined as any),\r\n extraInitializationsAsync: creationOptions.extraInitializationsAsync || (undefined as any),\r\n useAsPostProcess: creationOptions.useAsPostProcess ?? false,\r\n };\r\n\r\n this.options.uniformNames = this.options.uniforms;\r\n this.options.samplerNames = this.options.samplers;\r\n this.options.vertexShader = this.options.vertexUrl;\r\n\r\n if (this.options.useAsPostProcess) {\r\n if (this.options.samplers.indexOf(\"textureSampler\") === -1) {\r\n this.options.samplers.push(\"textureSampler\");\r\n }\r\n if (this.options.uniforms.indexOf(\"scale\") === -1) {\r\n this.options.uniforms.push(\"scale\");\r\n }\r\n }\r\n\r\n if (creationOptions.vertexUrl || creationOptions.vertexShader) {\r\n this._shaderPath = {\r\n vertexSource: this.options.vertexShader,\r\n };\r\n } else {\r\n if (!this.options.useAsPostProcess) {\r\n this.options.uniforms.push(\"scale\");\r\n\r\n this.onApplyObservable.add(() => {\r\n this.effect.setFloat2(\"scale\", 1, 1);\r\n });\r\n }\r\n\r\n this._shaderPath = {\r\n vertex: this.options.vertexShader,\r\n };\r\n }\r\n\r\n this._shaderPath.fragmentSource = this.options.fragmentShader;\r\n this._shaderPath.spectorName = this.options.name;\r\n\r\n if (this.options.useShaderStore) {\r\n this._shaderPath.fragment = this._shaderPath.fragmentSource;\r\n if (!this._shaderPath.vertex) {\r\n this._shaderPath.vertex = this._shaderPath.vertexSource;\r\n }\r\n\r\n delete this._shaderPath.fragmentSource;\r\n delete this._shaderPath.vertexSource;\r\n }\r\n\r\n this.onApplyObservable.add(() => {\r\n this.bind();\r\n });\r\n\r\n if (!this.options.useShaderStore) {\r\n this._onContextRestoredObserver = this.options.engine.onContextRestoredObservable.add(() => {\r\n this.effect._pipelineContext = null; // because _prepareEffect will try to dispose this pipeline before recreating it and that would lead to webgl errors\r\n this.effect._prepareEffect();\r\n });\r\n }\r\n\r\n this._drawWrapper = new DrawWrapper(this.options.engine);\r\n this._webGPUReady = this.options.shaderLanguage === ShaderLanguage.WGSL;\r\n\r\n const defines = Array.isArray(this.options.defines) ? this.options.defines.join(\"\\n\") : this.options.defines;\r\n\r\n this._postConstructor(this.options.blockCompilation, defines, this.options.extraInitializations);\r\n }\r\n\r\n protected _gatherImports(useWebGPU = false, list: Promise<any>[]) {\r\n if (!this.options.useAsPostProcess) {\r\n return;\r\n }\r\n\r\n // this._webGPUReady is used to detect when an effect wrapper is intended to be used with WebGPU\r\n if (useWebGPU && this._webGPUReady) {\r\n list.push(Promise.all([import(\"../ShadersWGSL/postprocess.vertex\")]));\r\n } else {\r\n list.push(Promise.all([import(\"../Shaders/postprocess.vertex\")]));\r\n }\r\n }\r\n\r\n private _importPromises: Array<Promise<any>> = [];\r\n\r\n /** @internal */\r\n public _postConstructor(\r\n blockCompilation: boolean,\r\n defines: Nullable<string> = null,\r\n extraInitializations?: (useWebGPU: boolean, list: Promise<any>[]) => void,\r\n importPromises?: Array<Promise<any>>\r\n ) {\r\n this._importPromises.length = 0;\r\n\r\n if (importPromises) {\r\n this._importPromises.push(...importPromises);\r\n }\r\n\r\n const useWebGPU = this.options.engine.isWebGPU && !EffectWrapper.ForceGLSL;\r\n\r\n this._gatherImports(useWebGPU, this._importPromises);\r\n if (extraInitializations !== undefined) {\r\n extraInitializations(useWebGPU, this._importPromises);\r\n }\r\n\r\n if (useWebGPU && this._webGPUReady) {\r\n this.options.shaderLanguage = ShaderLanguage.WGSL;\r\n }\r\n\r\n if (!blockCompilation) {\r\n this.updateEffect(defines);\r\n }\r\n }\r\n\r\n /**\r\n * Updates the effect with the current effect wrapper compile time values and recompiles the shader.\r\n * @param defines Define statements that should be added at the beginning of the shader. (default: null)\r\n * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)\r\n * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)\r\n * @param indexParameters The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n * @param onCompiled Called when the shader has been compiled.\r\n * @param onError Called if there is an error when compiling a shader.\r\n * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)\r\n * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)\r\n */\r\n public updateEffect(\r\n defines: Nullable<string> = null,\r\n uniforms: Nullable<string[]> = null,\r\n samplers: Nullable<string[]> = null,\r\n indexParameters?: any,\r\n onCompiled?: (effect: Effect) => void,\r\n onError?: (effect: Effect, errors: string) => void,\r\n vertexUrl?: string,\r\n fragmentUrl?: string\r\n ) {\r\n const customShaderCodeProcessing = EffectWrapper._GetShaderCodeProcessing(this.name);\r\n if (customShaderCodeProcessing?.defineCustomBindings) {\r\n const newUniforms = uniforms?.slice() ?? [];\r\n newUniforms.push(...this.options.uniforms);\r\n\r\n const newSamplers = samplers?.slice() ?? [];\r\n newSamplers.push(...this.options.samplers);\r\n\r\n defines = customShaderCodeProcessing.defineCustomBindings(this.name, defines, newUniforms, newSamplers);\r\n uniforms = newUniforms;\r\n samplers = newSamplers;\r\n }\r\n\r\n this.options.defines = defines || \"\";\r\n\r\n const waitImportsLoaded =\r\n this._shadersLoaded || this._importPromises.length === 0\r\n ? undefined\r\n : async () => {\r\n await Promise.all(this._importPromises);\r\n this._shadersLoaded = true;\r\n };\r\n\r\n let extraInitializationsAsync: (() => Promise<void>) | undefined;\r\n if (this.options.extraInitializationsAsync) {\r\n extraInitializationsAsync = async () => {\r\n waitImportsLoaded?.();\r\n await this.options.extraInitializationsAsync;\r\n };\r\n } else {\r\n extraInitializationsAsync = waitImportsLoaded;\r\n }\r\n\r\n if (this.options.useShaderStore) {\r\n this._drawWrapper.effect = this.options.engine.createEffect(\r\n { vertex: vertexUrl ?? this._shaderPath.vertex, fragment: fragmentUrl ?? this._shaderPath.fragment },\r\n {\r\n attributes: this.options.attributeNames,\r\n uniformsNames: uniforms || this.options.uniforms,\r\n uniformBuffersNames: this.options.uniformBuffers,\r\n samplers: samplers || this.options.samplers,\r\n defines: defines !== null ? defines : \"\",\r\n fallbacks: null,\r\n onCompiled: onCompiled ?? this.options.onCompiled,\r\n onError: onError ?? null,\r\n indexParameters: indexParameters || this.options.indexParameters,\r\n processCodeAfterIncludes: customShaderCodeProcessing?.processCodeAfterIncludes\r\n ? (shaderType: string, code: string) => customShaderCodeProcessing!.processCodeAfterIncludes!(this.name, shaderType, code)\r\n : null,\r\n processFinalCode: customShaderCodeProcessing?.processFinalCode\r\n ? (shaderType: string, code: string) => customShaderCodeProcessing!.processFinalCode!(this.name, shaderType, code)\r\n : null,\r\n shaderLanguage: this.options.shaderLanguage,\r\n extraInitializationsAsync,\r\n },\r\n this.options.engine\r\n );\r\n } else {\r\n this._drawWrapper.effect = new Effect(\r\n this._shaderPath,\r\n this.options.attributeNames,\r\n uniforms || this.options.uniforms,\r\n samplers || this.options.samplerNames,\r\n this.options.engine,\r\n defines,\r\n undefined,\r\n onCompiled || this.options.onCompiled,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this.options.shaderLanguage,\r\n extraInitializationsAsync\r\n );\r\n }\r\n\r\n this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect);\r\n }\r\n\r\n /**\r\n * Binds the data to the effect.\r\n */\r\n public bind() {\r\n if (this.options.useAsPostProcess) {\r\n this.options.engine.setAlphaMode(this.alphaMode);\r\n this.drawWrapper.effect!.setFloat2(\"scale\", 1, 1);\r\n }\r\n\r\n EffectWrapper._GetShaderCodeProcessing(this.name)?.bindCustomBindings?.(this.name, this._drawWrapper.effect!);\r\n }\r\n\r\n /**\r\n * Disposes of the effect wrapper\r\n * @param _ignored kept for backward compatibility\r\n */\r\n public dispose(_ignored: boolean = false) {\r\n if (this._onContextRestoredObserver) {\r\n this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n this.onEffectCreatedObservable.clear();\r\n this.effect.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"effectRenderer.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/effectRenderer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAA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6E,EAAE,AAA/E,CAAgF","sourcesContent":["import type { NonNullableFields, Nullable } from \"../types\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Viewport } from \"../Maths/math.viewport\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { IShaderPath } from \"./effect\";\r\nimport { Effect } from \"./effect\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { DrawWrapper } from \"./drawWrapper\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\n\r\n// Prevents ES6 issue if not imported.\r\nimport \"../Shaders/postprocess.vertex\";\r\n\r\n/**\r\n * Effect Render Options\r\n */\r\nexport interface IEffectRendererOptions {\r\n /**\r\n * Defines the vertices positions.\r\n */\r\n positions?: number[];\r\n /**\r\n * Defines the indices.\r\n */\r\n indices?: number[];\r\n}\r\n\r\n// Fullscreen quad buffers by default.\r\nconst defaultOptions = {\r\n positions: [1, 1, -1, 1, -1, -1, 1, -1],\r\n indices: [0, 1, 2, 0, 2, 3],\r\n};\r\n\r\n/**\r\n * Helper class to render one or more effects.\r\n * You can access the previous rendering in your shader by declaring a sampler named textureSampler\r\n */\r\nexport class EffectRenderer {\r\n /**\r\n * The engine the effect renderer has been created for.\r\n */\r\n public readonly engine: AbstractEngine;\r\n\r\n private _vertexBuffers: { [key: string]: VertexBuffer };\r\n private _indexBuffer: DataBuffer;\r\n\r\n private _fullscreenViewport = new Viewport(0, 0, 1, 1);\r\n private _onContextRestoredObserver: Nullable<Observer<AbstractEngine>>;\r\n\r\n private _savedStateDepthTest: boolean;\r\n private _savedStateStencilTest: boolean;\r\n\r\n /**\r\n * Creates an effect renderer\r\n * @param engine the engine to use for rendering\r\n * @param options defines the options of the effect renderer\r\n */\r\n constructor(engine: AbstractEngine, options: IEffectRendererOptions = defaultOptions) {\r\n const positions = options.positions ?? defaultOptions.positions;\r\n const indices = options.indices ?? defaultOptions.indices;\r\n\r\n this.engine = engine;\r\n this._vertexBuffers = {\r\n [VertexBuffer.PositionKind]: new VertexBuffer(engine, positions, VertexBuffer.PositionKind, false, false, 2),\r\n };\r\n this._indexBuffer = engine.createIndexBuffer(indices);\r\n\r\n this._onContextRestoredObserver = engine.onContextRestoredObservable.add(() => {\r\n this._indexBuffer = engine.createIndexBuffer(indices);\r\n\r\n for (const key in this._vertexBuffers) {\r\n const vertexBuffer = this._vertexBuffers[key];\r\n vertexBuffer._rebuild();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Sets the current viewport in normalized coordinates 0-1\r\n * @param viewport Defines the viewport to set (defaults to 0 0 1 1)\r\n */\r\n public setViewport(viewport = this._fullscreenViewport): void {\r\n this.engine.setViewport(viewport);\r\n }\r\n\r\n /**\r\n * Binds the embedded attributes buffer to the effect.\r\n * @param effect Defines the effect to bind the attributes for\r\n */\r\n public bindBuffers(effect: Effect): void {\r\n this.engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);\r\n }\r\n\r\n /**\r\n * Sets the current effect wrapper to use during draw.\r\n * The effect needs to be ready before calling this api.\r\n * This also sets the default full screen position attribute.\r\n * @param effectWrapper Defines the effect to draw with\r\n */\r\n public applyEffectWrapper(effectWrapper: EffectWrapper): void {\r\n this.engine.setState(true);\r\n this.engine.depthCullingState.depthTest = false;\r\n this.engine.stencilState.stencilTest = false;\r\n this.engine.enableEffect(effectWrapper.drawWrapper);\r\n this.bindBuffers(effectWrapper.effect);\r\n effectWrapper.onApplyObservable.notifyObservers({});\r\n }\r\n\r\n /**\r\n * Saves engine states\r\n */\r\n public saveStates(): void {\r\n this._savedStateDepthTest = this.engine.depthCullingState.depthTest;\r\n this._savedStateStencilTest = this.engine.stencilState.stencilTest;\r\n }\r\n\r\n /**\r\n * Restores engine states\r\n */\r\n public restoreStates(): void {\r\n this.engine.depthCullingState.depthTest = this._savedStateDepthTest;\r\n this.engine.stencilState.stencilTest = this._savedStateStencilTest;\r\n }\r\n\r\n /**\r\n * Draws a full screen quad.\r\n */\r\n public draw(): void {\r\n this.engine.drawElementsType(Constants.MATERIAL_TriangleFillMode, 0, 6);\r\n }\r\n\r\n private _isRenderTargetTexture(texture: RenderTargetWrapper | IRenderTargetTexture): texture is IRenderTargetTexture {\r\n return (texture as IRenderTargetTexture).renderTarget !== undefined;\r\n }\r\n\r\n /**\r\n * renders one or more effects to a specified texture\r\n * @param effectWrapper the effect to renderer\r\n * @param outputTexture texture to draw to, if null it will render to the currently bound frame buffer\r\n */\r\n public render(effectWrapper: EffectWrapper, outputTexture: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null) {\r\n // Ensure effect is ready\r\n if (!effectWrapper.effect.isReady()) {\r\n return;\r\n }\r\n\r\n this.saveStates();\r\n\r\n // Reset state\r\n this.setViewport();\r\n\r\n const out = outputTexture === null ? null : this._isRenderTargetTexture(outputTexture) ? outputTexture.renderTarget! : outputTexture;\r\n\r\n if (out) {\r\n this.engine.bindFramebuffer(out);\r\n }\r\n\r\n this.applyEffectWrapper(effectWrapper);\r\n\r\n this.draw();\r\n\r\n if (out) {\r\n this.engine.unBindFramebuffer(out);\r\n }\r\n\r\n this.restoreStates();\r\n }\r\n\r\n /**\r\n * Disposes of the effect renderer\r\n */\r\n dispose() {\r\n const vertexBuffer = this._vertexBuffers[VertexBuffer.PositionKind];\r\n if (vertexBuffer) {\r\n vertexBuffer.dispose();\r\n delete this._vertexBuffers[VertexBuffer.PositionKind];\r\n }\r\n\r\n if (this._indexBuffer) {\r\n this.engine._releaseBuffer(this._indexBuffer);\r\n }\r\n\r\n if (this._onContextRestoredObserver) {\r\n this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Allows for custom processing of the shader code used by an effect wrapper\r\n */\r\nexport type EffectWrapperCustomShaderCodeProcessing = {\r\n /**\r\n * If provided, will be called two times with the vertex and fragment code so that this code can be updated after the #include have been processed\r\n */\r\n processCodeAfterIncludes?: (postProcessName: string, shaderType: string, code: string) => string;\r\n /**\r\n * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU\r\n */\r\n processFinalCode?: (postProcessName: string, shaderType: string, code: string) => string;\r\n /**\r\n * If provided, will be called before creating the effect to collect additional custom bindings (defines, uniforms, samplers)\r\n */\r\n defineCustomBindings?: (postProcessName: string, defines: Nullable<string>, uniforms: string[], samplers: string[]) => Nullable<string>;\r\n /**\r\n * If provided, will be called when binding inputs to the shader code to allow the user to add custom bindings\r\n */\r\n bindCustomBindings?: (postProcessName: string, effect: Effect) => void;\r\n};\r\n\r\n/**\r\n * Options to create an EffectWrapper\r\n */\r\nexport interface EffectWrapperCreationOptions {\r\n /**\r\n * Engine to use to create the effect\r\n */\r\n engine?: AbstractEngine;\r\n /**\r\n * Fragment shader for the effect\r\n */\r\n fragmentShader?: string;\r\n /**\r\n * Use the shader store instead of direct source code\r\n */\r\n useShaderStore?: boolean;\r\n /**\r\n * Vertex shader for the effect (default: \"postprocess\")\r\n */\r\n vertexShader?: string;\r\n /**\r\n * Alias for vertexShader\r\n */\r\n vertexUrl?: string;\r\n /**\r\n * Attributes to use in the shader (default: [\"position\"])\r\n */\r\n attributeNames?: Array<string>;\r\n /**\r\n * Uniforms to use in the shader\r\n */\r\n uniformNames?: Array<string>;\r\n /**\r\n * Alias for uniformNames. Note that if it is provided, it takes precedence over uniformNames.\r\n */\r\n uniforms?: Nullable<string[]>;\r\n /**\r\n * Texture sampler names to use in the shader\r\n */\r\n samplerNames?: Array<string>;\r\n /**\r\n * Alias for samplerNames. Note that if it is provided, it takes precedence over samplerNames.\r\n */\r\n samplers?: Nullable<string[]>;\r\n /**\r\n * The list of uniform buffers used in the shader (if any)\r\n */\r\n uniformBuffers?: Nullable<string[]>;\r\n /**\r\n * Defines to use in the shader\r\n */\r\n defines?: Nullable<string | Array<string>>;\r\n /**\r\n * The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined)\r\n * See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n */\r\n indexParameters?: any;\r\n /**\r\n * If the shader should not be compiled immediately. (default: false)\r\n */\r\n blockCompilation?: boolean;\r\n /**\r\n * Callback when effect is compiled\r\n */\r\n onCompiled?: Nullable<(effect: Effect) => void>;\r\n /**\r\n * The friendly name of the effect (default: \"effectWrapper\")\r\n */\r\n name?: string;\r\n /**\r\n * The language the shader is written in (default: GLSL)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n /**\r\n * Defines additional code to call to prepare the shader code\r\n */\r\n extraInitializations?: (useWebGPU: boolean, list: Promise<any>[]) => void;\r\n /**\r\n * Additional async code to run before preparing the effect\r\n */\r\n extraInitializationsAsync?: () => Promise<void>;\r\n /**\r\n * If the effect should be used as a post process (default: false). If true, the effect will be created with a \"scale\" uniform and a \"textureSampler\" sampler\r\n */\r\n useAsPostProcess?: boolean;\r\n}\r\n\r\n/**\r\n * Wraps an effect to be used for rendering\r\n */\r\nexport class EffectWrapper {\r\n /**\r\n * Force code to compile to glsl even on WebGPU engines.\r\n * False by default. This is mostly meant for backward compatibility.\r\n */\r\n public static ForceGLSL = false;\r\n\r\n private static _CustomShaderCodeProcessing: { [effectWrapperName: string]: EffectWrapperCustomShaderCodeProcessing } = {};\r\n\r\n /**\r\n * Registers a shader code processing with an effect wrapper name.\r\n * @param effectWrapperName name of the effect wrapper. Use null for the fallback shader code processing. This is the shader code processing that will be used in case no specific shader code processing has been associated to an effect wrapper name\r\n * @param customShaderCodeProcessing shader code processing to associate to the effect wrapper name\r\n */\r\n public static RegisterShaderCodeProcessing(effectWrapperName: Nullable<string>, customShaderCodeProcessing?: EffectWrapperCustomShaderCodeProcessing) {\r\n if (!customShaderCodeProcessing) {\r\n delete EffectWrapper._CustomShaderCodeProcessing[effectWrapperName ?? \"\"];\r\n return;\r\n }\r\n\r\n EffectWrapper._CustomShaderCodeProcessing[effectWrapperName ?? \"\"] = customShaderCodeProcessing;\r\n }\r\n\r\n private static _GetShaderCodeProcessing(effectWrapperName: string) {\r\n return EffectWrapper._CustomShaderCodeProcessing[effectWrapperName] ?? EffectWrapper._CustomShaderCodeProcessing[\"\"];\r\n }\r\n\r\n /**\r\n * Gets or sets the name of the effect wrapper\r\n */\r\n public get name() {\r\n return this.options.name;\r\n }\r\n\r\n public set name(value: string) {\r\n this.options.name = value;\r\n }\r\n\r\n /**\r\n * Type of alpha mode to use when applying the effect (default: Engine.ALPHA_DISABLE). Used only if useAsPostProcess is true.\r\n */\r\n public alphaMode = Constants.ALPHA_DISABLE;\r\n\r\n /**\r\n * Executed when the effect is created\r\n * @returns effect that was created for this effect wrapper\r\n */\r\n public onEffectCreatedObservable = new Observable<Effect>(undefined, true);\r\n\r\n /**\r\n * Options used to create the effect wrapper\r\n */\r\n public readonly options: Required<NonNullableFields<EffectWrapperCreationOptions>>;\r\n\r\n /**\r\n * Get a value indicating if the effect is ready to be used\r\n * @returns true if the post-process is ready (shader is compiled)\r\n */\r\n public isReady() {\r\n return this._drawWrapper.effect?.isReady() ?? false;\r\n }\r\n\r\n /**\r\n * Get the draw wrapper associated with the effect wrapper\r\n * @returns the draw wrapper associated with the effect wrapper\r\n */\r\n public get drawWrapper() {\r\n return this._drawWrapper;\r\n }\r\n\r\n /**\r\n * Event that is fired (only when the EffectWrapper is used with an EffectRenderer) right before the effect is drawn (should be used to update uniforms)\r\n */\r\n public onApplyObservable = new Observable<{}>();\r\n\r\n /**\r\n * The underlying effect\r\n */\r\n public get effect(): Effect {\r\n return this._drawWrapper.effect!;\r\n }\r\n\r\n public set effect(effect: Effect) {\r\n this._drawWrapper.effect = effect;\r\n }\r\n\r\n protected readonly _drawWrapper: DrawWrapper;\r\n protected _shadersLoaded = false;\r\n protected readonly _shaderPath: IShaderPath;\r\n /** @internal */\r\n public _webGPUReady = false;\r\n\r\n private _onContextRestoredObserver: Nullable<Observer<AbstractEngine>>;\r\n\r\n /**\r\n * Creates an effect to be rendered\r\n * @param creationOptions options to create the effect\r\n */\r\n constructor(creationOptions: EffectWrapperCreationOptions) {\r\n this.options = {\r\n ...creationOptions,\r\n name: creationOptions.name || \"effectWrapper\",\r\n engine: creationOptions.engine!,\r\n uniforms: creationOptions.uniforms || creationOptions.uniformNames || [],\r\n uniformNames: undefined as any,\r\n samplers: creationOptions.samplers || creationOptions.samplerNames || [],\r\n samplerNames: undefined as any,\r\n attributeNames: creationOptions.attributeNames || [\"position\"],\r\n uniformBuffers: creationOptions.uniformBuffers || [],\r\n defines: creationOptions.defines || \"\",\r\n useShaderStore: creationOptions.useShaderStore || false,\r\n vertexUrl: creationOptions.vertexUrl || creationOptions.vertexShader || \"postprocess\",\r\n vertexShader: undefined as any,\r\n fragmentShader: creationOptions.fragmentShader || \"pass\",\r\n indexParameters: creationOptions.indexParameters,\r\n blockCompilation: creationOptions.blockCompilation || false,\r\n shaderLanguage: creationOptions.shaderLanguage || ShaderLanguage.GLSL,\r\n onCompiled: creationOptions.onCompiled || (undefined as any),\r\n extraInitializations: creationOptions.extraInitializations || (undefined as any),\r\n extraInitializationsAsync: creationOptions.extraInitializationsAsync || (undefined as any),\r\n useAsPostProcess: creationOptions.useAsPostProcess ?? false,\r\n };\r\n\r\n this.options.uniformNames = this.options.uniforms;\r\n this.options.samplerNames = this.options.samplers;\r\n this.options.vertexShader = this.options.vertexUrl;\r\n\r\n if (this.options.useAsPostProcess) {\r\n if (this.options.samplers.indexOf(\"textureSampler\") === -1) {\r\n this.options.samplers.push(\"textureSampler\");\r\n }\r\n if (this.options.uniforms.indexOf(\"scale\") === -1) {\r\n this.options.uniforms.push(\"scale\");\r\n }\r\n }\r\n\r\n if (creationOptions.vertexUrl || creationOptions.vertexShader) {\r\n this._shaderPath = {\r\n vertexSource: this.options.vertexShader,\r\n };\r\n } else {\r\n if (!this.options.useAsPostProcess) {\r\n this.options.uniforms.push(\"scale\");\r\n\r\n this.onApplyObservable.add(() => {\r\n this.effect.setFloat2(\"scale\", 1, 1);\r\n });\r\n }\r\n\r\n this._shaderPath = {\r\n vertex: this.options.vertexShader,\r\n };\r\n }\r\n\r\n this._shaderPath.fragmentSource = this.options.fragmentShader;\r\n this._shaderPath.spectorName = this.options.name;\r\n\r\n if (this.options.useShaderStore) {\r\n this._shaderPath.fragment = this._shaderPath.fragmentSource;\r\n if (!this._shaderPath.vertex) {\r\n this._shaderPath.vertex = this._shaderPath.vertexSource;\r\n }\r\n\r\n delete this._shaderPath.fragmentSource;\r\n delete this._shaderPath.vertexSource;\r\n }\r\n\r\n this.onApplyObservable.add(() => {\r\n this.bind();\r\n });\r\n\r\n if (!this.options.useShaderStore) {\r\n this._onContextRestoredObserver = this.options.engine.onContextRestoredObservable.add(() => {\r\n this.effect._pipelineContext = null; // because _prepareEffect will try to dispose this pipeline before recreating it and that would lead to webgl errors\r\n this.effect._prepareEffect();\r\n });\r\n }\r\n\r\n this._drawWrapper = new DrawWrapper(this.options.engine);\r\n this._webGPUReady = this.options.shaderLanguage === ShaderLanguage.WGSL;\r\n\r\n const defines = Array.isArray(this.options.defines) ? this.options.defines.join(\"\\n\") : this.options.defines;\r\n\r\n this._postConstructor(this.options.blockCompilation, defines, this.options.extraInitializations);\r\n }\r\n\r\n protected _gatherImports(useWebGPU = false, list: Promise<any>[]) {\r\n if (!this.options.useAsPostProcess) {\r\n return;\r\n }\r\n\r\n // this._webGPUReady is used to detect when an effect wrapper is intended to be used with WebGPU\r\n if (useWebGPU && this._webGPUReady) {\r\n list.push(Promise.all([import(\"../ShadersWGSL/postprocess.vertex\")]));\r\n } else {\r\n list.push(Promise.all([import(\"../Shaders/postprocess.vertex\")]));\r\n }\r\n }\r\n\r\n private _importPromises: Array<Promise<any>> = [];\r\n\r\n /** @internal */\r\n public _postConstructor(\r\n blockCompilation: boolean,\r\n defines: Nullable<string> = null,\r\n extraInitializations?: (useWebGPU: boolean, list: Promise<any>[]) => void,\r\n importPromises?: Array<Promise<any>>\r\n ) {\r\n this._importPromises.length = 0;\r\n\r\n if (importPromises) {\r\n this._importPromises.push(...importPromises);\r\n }\r\n\r\n const useWebGPU = this.options.engine.isWebGPU && !EffectWrapper.ForceGLSL;\r\n\r\n this._gatherImports(useWebGPU, this._importPromises);\r\n if (extraInitializations !== undefined) {\r\n extraInitializations(useWebGPU, this._importPromises);\r\n }\r\n\r\n if (useWebGPU && this._webGPUReady) {\r\n this.options.shaderLanguage = ShaderLanguage.WGSL;\r\n }\r\n\r\n if (!blockCompilation) {\r\n this.updateEffect(defines);\r\n }\r\n }\r\n\r\n /**\r\n * Updates the effect with the current effect wrapper compile time values and recompiles the shader.\r\n * @param defines Define statements that should be added at the beginning of the shader. (default: null)\r\n * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)\r\n * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)\r\n * @param indexParameters The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n * @param onCompiled Called when the shader has been compiled.\r\n * @param onError Called if there is an error when compiling a shader.\r\n * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)\r\n * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)\r\n */\r\n public updateEffect(\r\n defines: Nullable<string> = null,\r\n uniforms: Nullable<string[]> = null,\r\n samplers: Nullable<string[]> = null,\r\n indexParameters?: any,\r\n onCompiled?: (effect: Effect) => void,\r\n onError?: (effect: Effect, errors: string) => void,\r\n vertexUrl?: string,\r\n fragmentUrl?: string\r\n ) {\r\n const customShaderCodeProcessing = EffectWrapper._GetShaderCodeProcessing(this.name);\r\n if (customShaderCodeProcessing?.defineCustomBindings) {\r\n const newUniforms = uniforms?.slice() ?? [];\r\n newUniforms.push(...this.options.uniforms);\r\n\r\n const newSamplers = samplers?.slice() ?? [];\r\n newSamplers.push(...this.options.samplers);\r\n\r\n defines = customShaderCodeProcessing.defineCustomBindings(this.name, defines, newUniforms, newSamplers);\r\n uniforms = newUniforms;\r\n samplers = newSamplers;\r\n }\r\n\r\n this.options.defines = defines || \"\";\r\n\r\n const waitImportsLoaded =\r\n this._shadersLoaded || this._importPromises.length === 0\r\n ? undefined\r\n : async () => {\r\n await Promise.all(this._importPromises);\r\n this._shadersLoaded = true;\r\n };\r\n\r\n let extraInitializationsAsync: (() => Promise<void>) | undefined;\r\n if (this.options.extraInitializationsAsync) {\r\n extraInitializationsAsync = async () => {\r\n waitImportsLoaded?.();\r\n await this.options.extraInitializationsAsync;\r\n };\r\n } else {\r\n extraInitializationsAsync = waitImportsLoaded;\r\n }\r\n\r\n if (this.options.useShaderStore) {\r\n this._drawWrapper.effect = this.options.engine.createEffect(\r\n { vertex: vertexUrl ?? this._shaderPath.vertex, fragment: fragmentUrl ?? this._shaderPath.fragment },\r\n {\r\n attributes: this.options.attributeNames,\r\n uniformsNames: uniforms || this.options.uniforms,\r\n uniformBuffersNames: this.options.uniformBuffers,\r\n samplers: samplers || this.options.samplers,\r\n defines: defines !== null ? defines : \"\",\r\n fallbacks: null,\r\n onCompiled: onCompiled ?? this.options.onCompiled,\r\n onError: onError ?? null,\r\n indexParameters: indexParameters || this.options.indexParameters,\r\n processCodeAfterIncludes: customShaderCodeProcessing?.processCodeAfterIncludes\r\n ? (shaderType: string, code: string) => customShaderCodeProcessing!.processCodeAfterIncludes!(this.name, shaderType, code)\r\n : null,\r\n processFinalCode: customShaderCodeProcessing?.processFinalCode\r\n ? (shaderType: string, code: string) => customShaderCodeProcessing!.processFinalCode!(this.name, shaderType, code)\r\n : null,\r\n shaderLanguage: this.options.shaderLanguage,\r\n extraInitializationsAsync,\r\n },\r\n this.options.engine\r\n );\r\n } else {\r\n this._drawWrapper.effect = new Effect(\r\n this._shaderPath,\r\n this.options.attributeNames,\r\n uniforms || this.options.uniforms,\r\n samplers || this.options.samplerNames,\r\n this.options.engine,\r\n defines,\r\n undefined,\r\n onCompiled || this.options.onCompiled,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this.options.shaderLanguage,\r\n extraInitializationsAsync\r\n );\r\n }\r\n\r\n this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect);\r\n }\r\n\r\n /**\r\n * Binds the data to the effect.\r\n */\r\n public bind() {\r\n if (this.options.useAsPostProcess) {\r\n this.options.engine.setAlphaMode(this.alphaMode);\r\n this.drawWrapper.effect!.setFloat2(\"scale\", 1, 1);\r\n }\r\n\r\n EffectWrapper._GetShaderCodeProcessing(this.name)?.bindCustomBindings?.(this.name, this._drawWrapper.effect!);\r\n }\r\n\r\n /**\r\n * Disposes of the effect wrapper\r\n * @param _ignored kept for backward compatibility\r\n */\r\n public dispose(_ignored: boolean = false) {\r\n if (this._onContextRestoredObserver) {\r\n this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n this.onEffectCreatedObservable.clear();\r\n this._drawWrapper.dispose(true);\r\n }\r\n}\r\n"]}
|
package/Maths/math.scalar.d.ts
CHANGED
package/Maths/math.scalar.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1
2
|
import * as functions from "./math.scalar.functions.js";
|
|
2
3
|
const HCF = functions.HighestCommonFactor;
|
|
3
4
|
/**
|
|
4
5
|
* Scalar computation library
|
|
5
|
-
* @deprecated Please use the scalar functions
|
|
6
6
|
*/
|
|
7
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
8
7
|
export const Scalar = {
|
|
9
8
|
...functions,
|
|
10
9
|
/**
|
package/Maths/math.scalar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.scalar.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.scalar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAC;AAErD,MAAM,GAAG,GAAqC,SAAS,CAAC,mBAAmB,CAAC;AAE5E
|
|
1
|
+
{"version":3,"file":"math.scalar.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.scalar.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAC;AAErD,MAAM,GAAG,GAAqC,SAAS,CAAC,mBAAmB,CAAC;AAE5E;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,GAAG,SAAS;IAEZ;;OAEG;IACH,KAAK,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC;IAElB;;;;OAIG;IACH,IAAI,EAAE,IAAI,CAAC,IAAI;IAEf;;;;OAIG;IACH,IAAI,EAAE,IAAI,CAAC,IAAI;IAEf;;;;;OAKG;IACH,GAAG;CACN,CAAC;AACF,wDAAwD","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport * as functions from \"./math.scalar.functions\";\r\n\r\nconst HCF: (a: number, b: number) => number = functions.HighestCommonFactor;\r\n\r\n/**\r\n * Scalar computation library\r\n */\r\nexport const Scalar = {\r\n ...functions,\r\n\r\n /**\r\n * Two pi constants convenient for computation.\r\n */\r\n TwoPi: Math.PI * 2,\r\n\r\n /**\r\n * Returns -1 if value is negative and +1 is value is positive.\r\n * @param value the value\r\n * @returns the value itself if it's equal to zero.\r\n */\r\n Sign: Math.sign,\r\n\r\n /**\r\n * the log2 of value.\r\n * @param value the value to compute log2 of\r\n * @returns the log2 of value.\r\n */\r\n Log2: Math.log2,\r\n\r\n /**\r\n * Returns the highest common factor of two integers.\r\n * @param a first parameter\r\n * @param b second parameter\r\n * @returns HCF of a and b\r\n */\r\n HCF,\r\n};\r\n/* eslint-enable @typescript-eslint/naming-convention */\r\n"]}
|
|
@@ -84,14 +84,14 @@ export function CreateGreasedLineMaterial(name, options, scene) {
|
|
|
84
84
|
let material;
|
|
85
85
|
switch (options.materialType) {
|
|
86
86
|
case 1 /* GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR */:
|
|
87
|
-
material = new PBRMaterial(name, scene,
|
|
87
|
+
material = new PBRMaterial(name, scene, options.forceGLSL);
|
|
88
88
|
new GreasedLinePluginMaterial(material, scene, options);
|
|
89
89
|
break;
|
|
90
90
|
case 2 /* GreasedLineMeshMaterialType.MATERIAL_TYPE_SIMPLE */:
|
|
91
91
|
material = new GreasedLineSimpleMaterial(name, scene, options);
|
|
92
92
|
break;
|
|
93
93
|
default:
|
|
94
|
-
material = new StandardMaterial(name, scene,
|
|
94
|
+
material = new StandardMaterial(name, scene, options.forceGLSL);
|
|
95
95
|
new GreasedLinePluginMaterial(material, scene, options);
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greasedLineBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/greasedLineBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAG7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,2BAA2B,EAAE,MAAM,yDAAyD,CAAC;AAEtG;;;GAGG;AACH,MAAM,CAAN,IAAkB,gCAyBjB;AAzBD,WAAkB,gCAAgC;IAC9C;;OAEG;IACH,6HAA2B,CAAA;IAC3B;;OAEG;IACH,iIAA6B,CAAA;IAC7B;;OAEG;IACH,6HAA2B,CAAA;IAC3B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,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import { StandardMaterial } from \"./../../Materials/standardMaterial\";\r\nimport { PBRMaterial } from \"../../Materials/PBR/pbrMaterial\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { GreasedLineMesh } from \"../GreasedLine/greasedLineMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\nimport type { Color3 } from \"../../Maths/math.color\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport type { GreasedLineMeshOptions } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonAutoDirectionMode, GreasedLineRibbonFacesMode, GreasedLineRibbonPointsMode } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonMesh } from \"../GreasedLine/greasedLineRibbonMesh\";\r\nimport type { GreasedLineMaterialOptions } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLineMeshMaterialType } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { GreasedLineMaterialDefaults } from \"../../Materials/GreasedLine/greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * How are the colors distributed along the color table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}\r\n */\r\nexport const enum GreasedLineMeshColorDistribution {\r\n /**\r\n * Do no modify the color table\r\n */\r\n COLOR_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the colors until the color table is full\r\n */\r\n COLOR_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the colors evenly through the color table\r\n */\r\n COLOR_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the colors to start of the color table a fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the colors to the end of the color table and fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the colors to start and to the end of the color table and fill the gap between with the default color\r\n */\r\n COLOR_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * How are the widths distributed along the width table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}\r\n */\r\nexport const enum GreasedLineMeshWidthDistribution {\r\n /**\r\n * Do no modify the width table\r\n */\r\n WIDTH_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the widths until the width table is full\r\n */\r\n WIDTH_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the widths evenly through the width table\r\n */\r\n WIDTH_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the widths to start of the width table a fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the widths to the end of the width table and fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the widths to start and to the end of the width table and fill the gap between with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * Material options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMaterialBuilderOptions extends GreasedLineMaterialOptions {\r\n /**\r\n * If set to true a new material will be created and a new material plugin will be attached\r\n * to the material. The material will be set on the mesh. If the instance option is specified in the mesh options,\r\n * no material will be created/assigned. Defaults to true.\r\n */\r\n createAndAssignMaterial?: boolean;\r\n /**\r\n * Distribution of the colors if the color table contains fewer entries than needed. Defaults to GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START\r\n * @see CompleteGreasedLineColorTable\r\n */\r\n colorDistribution?: GreasedLineMeshColorDistribution;\r\n}\r\n\r\n/**\r\n * Line mesh options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMeshBuilderOptions extends GreasedLineMeshOptions {\r\n /**\r\n * Distribution of the widths if the width table contains fewer entries than needed. Defaults to GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START\r\n * @see CompleteGreasedLineWidthTable\r\n */\r\n widthDistribution?: GreasedLineMeshWidthDistribution;\r\n}\r\n\r\n/**\r\n * Builder functions for creating GreasedLineMeshes\r\n */\r\n\r\n/**\r\n * Creates a new @see GreasedLinePluginMaterial\r\n * @param name name of the material\r\n * @param options material options @see GreasedLineMaterialOptions\r\n * @param scene scene or null to use the last scene\r\n * @returns StandardMaterial or PBRMaterial with the @see GreasedLinePluginMaterial attached to it\r\n */\r\nexport function CreateGreasedLineMaterial(name: string, options: GreasedLineMaterialOptions, scene: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let material;\r\n switch (options.materialType) {\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR:\r\n material = new PBRMaterial(name, scene, true); // Forcing glsl for now\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_SIMPLE:\r\n material = new GreasedLineSimpleMaterial(name, scene, options);\r\n break;\r\n default:\r\n material = new StandardMaterial(name, scene, true); // Forcing glsl for now\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n }\r\n\r\n return material;\r\n}\r\n\r\n/**\r\n * Creates a GreasedLine mesh\r\n * @param name name of the mesh\r\n * @param options options for the mesh\r\n * @param materialOptions material options for the mesh\r\n * @param scene scene where the mesh will be created\r\n * @returns instance of GreasedLineMesh\r\n */\r\nexport function CreateGreasedLine(name: string, options: GreasedLineMeshBuilderOptions, materialOptions?: Nullable<GreasedLineMaterialBuilderOptions>, scene?: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let instance;\r\n const allPoints = GreasedLineTools.ConvertPoints(options.points, options.pointsOptions);\r\n\r\n options.widthDistribution = options.widthDistribution ?? GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START;\r\n if (options.ribbonOptions) {\r\n options.ribbonOptions.facesMode = options.ribbonOptions.facesMode ?? GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING;\r\n options.ribbonOptions.pointsMode = options.ribbonOptions.pointsMode ?? GreasedLineRibbonPointsMode.POINTS_MODE_POINTS;\r\n options.ribbonOptions.directionsAutoMode =\r\n options.ribbonOptions.directionsAutoMode ??\r\n (options.ribbonOptions.directions ? GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_NONE : GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_FROM_FIRST_SEGMENT);\r\n }\r\n\r\n materialOptions = materialOptions ?? {\r\n color: GreasedLineMaterialDefaults.DEFAULT_COLOR,\r\n };\r\n materialOptions.createAndAssignMaterial = materialOptions.createAndAssignMaterial ?? true;\r\n materialOptions.colorDistribution = materialOptions?.colorDistribution ?? GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START;\r\n materialOptions.materialType = materialOptions.materialType ?? GreasedLineMeshMaterialType.MATERIAL_TYPE_STANDARD;\r\n\r\n const pointsCount = GetPointsCount(allPoints);\r\n const widths = CompleteGreasedLineWidthTable(pointsCount, options.widths ?? [], options.widthDistribution);\r\n\r\n const colors = materialOptions?.colors\r\n ? CompleteGreasedLineColorTable(pointsCount, materialOptions.colors, materialOptions.colorDistribution, materialOptions.color ?? GreasedLineMaterialDefaults.DEFAULT_COLOR)\r\n : undefined;\r\n\r\n // create new mesh if instance is not defined\r\n const initialGreasedLineOptions: GreasedLineMeshOptions = {\r\n points: allPoints,\r\n updatable: options.updatable,\r\n widths,\r\n lazy: options.lazy,\r\n ribbonOptions: options.ribbonOptions,\r\n uvs: options.uvs,\r\n colorPointers: options.colorPointers,\r\n };\r\n\r\n if (initialGreasedLineOptions.ribbonOptions) {\r\n if (initialGreasedLineOptions.ribbonOptions.pointsMode === GreasedLineRibbonPointsMode.POINTS_MODE_POINTS) {\r\n initialGreasedLineOptions.ribbonOptions.width = materialOptions.width ?? initialGreasedLineOptions.ribbonOptions.width ?? GreasedLineMaterialDefaults.DEFAULT_WIDTH;\r\n }\r\n }\r\n\r\n if (!options.instance) {\r\n instance = initialGreasedLineOptions.ribbonOptions\r\n ? new GreasedLineRibbonMesh(name, scene, initialGreasedLineOptions)\r\n : new GreasedLineMesh(name, scene, initialGreasedLineOptions);\r\n\r\n if (materialOptions) {\r\n const initialMaterialOptions: GreasedLineMaterialOptions = {\r\n materialType: materialOptions.materialType,\r\n dashCount: materialOptions.dashCount,\r\n dashOffset: materialOptions.dashOffset,\r\n dashRatio: materialOptions.dashRatio,\r\n resolution: materialOptions.resolution,\r\n sizeAttenuation: materialOptions.sizeAttenuation,\r\n useColors: materialOptions.useColors,\r\n useDash: materialOptions.useDash,\r\n visibility: materialOptions.visibility,\r\n width: materialOptions.width,\r\n color: materialOptions.color,\r\n colorMode: materialOptions.colorMode,\r\n colorsSampling: materialOptions.colorsSampling,\r\n colorDistributionType: materialOptions.colorDistributionType,\r\n colors,\r\n cameraFacing: !options.ribbonOptions,\r\n colorsTexture: materialOptions.colorsTexture,\r\n };\r\n\r\n if (materialOptions.createAndAssignMaterial) {\r\n const material = CreateGreasedLineMaterial(name, initialMaterialOptions, scene);\r\n instance.material = material;\r\n\r\n if (options.ribbonOptions?.facesMode === GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING) {\r\n material.backFaceCulling = false;\r\n }\r\n }\r\n }\r\n } else {\r\n // update the data on the mesh instance\r\n instance = options.instance;\r\n if (instance instanceof GreasedLineRibbonMesh) {\r\n instance.addPoints(allPoints, initialGreasedLineOptions);\r\n } else {\r\n // add widths\r\n const currentWidths = instance.widths;\r\n if (currentWidths) {\r\n const newWidths = currentWidths.slice();\r\n for (const w of widths) {\r\n newWidths.push(w);\r\n }\r\n instance.widths = newWidths;\r\n } else {\r\n instance.widths = widths;\r\n }\r\n\r\n instance.addPoints(allPoints);\r\n\r\n // add UVs\r\n if (options.uvs) {\r\n const currentUVs = instance.uvs;\r\n if (currentUVs) {\r\n const newUVs = new Float32Array(currentUVs.length + options.uvs.length);\r\n newUVs.set(currentUVs, 0);\r\n newUVs.set(options.uvs, currentUVs.length);\r\n instance.uvs = newUVs;\r\n } else {\r\n instance.uvs = options.uvs;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // add colors\r\n // it will merge if any colors already on the instance\r\n if (colors && options.instance) {\r\n if (options.instance.greasedLineMaterial) {\r\n const currentColors = options.instance.greasedLineMaterial.colors;\r\n if (currentColors) {\r\n const newColors = currentColors.concat(colors);\r\n options.instance.greasedLineMaterial.setColors(newColors, instance.isLazy());\r\n }\r\n }\r\n }\r\n\r\n return instance;\r\n}\r\n\r\n/**\r\n * Counts the number of points\r\n * @param allPoints Array of points [[x, y, z], [x, y, z], ...] or Array of points [x, y, z, x, y, z, ...]\r\n * @returns total number of points\r\n */\r\nexport function GetPointsCount(allPoints: number[][]) {\r\n let pointCount = 0;\r\n for (const points of allPoints) {\r\n pointCount += (<number[]>points).length / 3;\r\n }\r\n return pointCount;\r\n}\r\n\r\n/**\r\n * Completes the width table/fills the missing entries. It means it creates a width entry for every point of the line mesh.\r\n * You can provide more points the widths when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMeshWidthDistribution.REPEAT - the width table will be repeatedly copied to the empty values [wL, wU] = [wL, wU, wL, wU, wL, wU, wL, wU, ...]\r\n * GreasedLineMeshWidthDistribution.EVEN - the width table will be evenly copied to the empty values [wL, wU] = [wL, wL, wL, wL, wU, wU, wU, wU]\r\n * GreasedLineMeshWidthDistribution.START - the width table will be copied at the start of the empty values\r\n * and rest will be filled width the default width upper and default width lower values [wU, wL] = [wL, wU, dwL, dwU, dwL, dwU, dwL, dwU]\r\n * GreasedLineMeshWidthDistribution.END - the width table will be copied at the end of the empty values\r\n * and rest will be filled width the default values [wL, wU] = [wL, wU, dwL, dwU, dwL, dwU, wL, wU]\r\n * @param pointCount number of points of the line mesh\r\n * @param widths array of widths [widhtLower, widthUpper, widthLower, widthUpper ...]. Two widths (lower/upper) per point.\r\n * @param widthsDistribution how to distribute widths if the widths array has fewer entries than pointCount\r\n * @param defaultWidthUpper the default value which will be used to fill empty width entries - upper width\r\n * @param defaultWidthLower the default value which will be used to fill empty width entries - lower width\r\n * @returns completed width table.\r\n */\r\nexport function CompleteGreasedLineWidthTable(\r\n pointCount: number,\r\n widths: number[],\r\n widthsDistribution: GreasedLineMeshWidthDistribution,\r\n defaultWidthUpper = 1,\r\n defaultWidthLower = 1\r\n): number[] {\r\n const missingCount = pointCount - widths.length / 2;\r\n\r\n const widthsData: number[] = [];\r\n if (missingCount < 0) {\r\n return widths.slice(0, pointCount * 2);\r\n }\r\n\r\n // is the width table shorter than the point table?\r\n if (missingCount > 0) {\r\n if (widths.length % 2 != 0) {\r\n widths.push(defaultWidthUpper);\r\n }\r\n // it is, fill in the missing elements\r\n if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(widths.length / 2);\r\n\r\n // start sector\r\n for (let i = 0, j = 0; i < halfCount - 1; i++) {\r\n widthsData.push(widths[j++]);\r\n widthsData.push(widths[j++]);\r\n }\r\n\r\n // middle sector\r\n const widthL = widths[halfCount / 2];\r\n const widthU = widths[halfCount / 2 + 1];\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(widthU);\r\n widthsData.push(widthL);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n widthsData.push(widths[i++]);\r\n widthsData.push(widths[i++]);\r\n\r\n if (i === widths.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const widthsectorLength = widths.length / ((pointCount - 1) * 2);\r\n for (let x = 0; x < pointCount; x++) {\r\n const i = Math.floor(j);\r\n\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n\r\n j += widthsectorLength;\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < widths.length; i++) {\r\n widthsData.push(widths[i]);\r\n }\r\n }\r\n\r\n return widthsData;\r\n}\r\n\r\n/**\r\n * Completes the color table/fill the missing color entries. It means it creates a color entry for every point of the line mesh.\r\n * You can provide more points the colors when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMesColorhDistribution.REPEAT - the color table will be repeatedly copied to the empty values [c1, c2] = [c1, c2, c1, c2, c1, c2, c1, c2]\r\n * GreasedLineMesColorhDistribution.EVEN - the color table will be evenly copied to the empty values [c1, c2] = [c1, c1, c1, c1, c2, c2, c2, c2]\r\n * GreasedLineMesColorhDistribution.START - the color table will be copied at the start of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, dc, dc]\r\n * GreasedLineMesColorhDistribution.START_END - the color table will be copied at the start and the end of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, c1, c2]\r\n * @param pointCount number of points of the line mesh\r\n * @param colors array of Color3 for the color table\r\n * @param colorDistribution how to distribute colors if the colors array has fewer entries than pointCount\r\n * @param defaultColor default color to be used to fill empty entries in the color table\r\n * @returns completed array of Color3s\r\n */\r\nexport function CompleteGreasedLineColorTable(pointCount: number, colors: Color3[], colorDistribution: GreasedLineMeshColorDistribution, defaultColor: Color3): Color3[] {\r\n pointCount = Math.max(colors.length, pointCount);\r\n const missingCount = pointCount - colors.length;\r\n if (missingCount < 0) {\r\n return colors.slice(0, pointCount);\r\n }\r\n\r\n const colorsData: Color3[] = [];\r\n // is the color table shorter than the point table?\r\n if (missingCount > 0) {\r\n // it is, fill in the missing elements\r\n if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(colors.length / 2);\r\n\r\n // start sector\r\n for (let i = 0; i < halfCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // middle sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n colorsData.push(colors[i]);\r\n\r\n i++;\r\n\r\n if (i === colors.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const colorSectorLength = colors.length / (pointCount - 1);\r\n for (let x = 0; x < pointCount - 1; x++) {\r\n const i = Math.floor(j);\r\n\r\n colorsData.push(colors[i]);\r\n\r\n j += colorSectorLength;\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_NONE) {\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < pointCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n\r\n return colorsData;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"greasedLineBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/greasedLineBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CA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,qEAA6D,EAAE,CAAC;YACxF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACrC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/B,CAAC;QACL,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import { StandardMaterial } from \"./../../Materials/standardMaterial\";\r\nimport { PBRMaterial } from \"../../Materials/PBR/pbrMaterial\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { GreasedLineMesh } from \"../GreasedLine/greasedLineMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\nimport type { Color3 } from \"../../Maths/math.color\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport type { GreasedLineMeshOptions } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonAutoDirectionMode, GreasedLineRibbonFacesMode, GreasedLineRibbonPointsMode } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonMesh } from \"../GreasedLine/greasedLineRibbonMesh\";\r\nimport type { GreasedLineMaterialOptions } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLineMeshMaterialType } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { GreasedLineMaterialDefaults } from \"../../Materials/GreasedLine/greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * How are the colors distributed along the color table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}\r\n */\r\nexport const enum GreasedLineMeshColorDistribution {\r\n /**\r\n * Do no modify the color table\r\n */\r\n COLOR_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the colors until the color table is full\r\n */\r\n COLOR_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the colors evenly through the color table\r\n */\r\n COLOR_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the colors to start of the color table a fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the colors to the end of the color table and fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the colors to start and to the end of the color table and fill the gap between with the default color\r\n */\r\n COLOR_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * How are the widths distributed along the width table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}\r\n */\r\nexport const enum GreasedLineMeshWidthDistribution {\r\n /**\r\n * Do no modify the width table\r\n */\r\n WIDTH_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the widths until the width table is full\r\n */\r\n WIDTH_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the widths evenly through the width table\r\n */\r\n WIDTH_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the widths to start of the width table a fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the widths to the end of the width table and fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the widths to start and to the end of the width table and fill the gap between with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * Material options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMaterialBuilderOptions extends GreasedLineMaterialOptions {\r\n /**\r\n * If set to true a new material will be created and a new material plugin will be attached\r\n * to the material. The material will be set on the mesh. If the instance option is specified in the mesh options,\r\n * no material will be created/assigned. Defaults to true.\r\n */\r\n createAndAssignMaterial?: boolean;\r\n /**\r\n * Distribution of the colors if the color table contains fewer entries than needed. Defaults to GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START\r\n * @see CompleteGreasedLineColorTable\r\n */\r\n colorDistribution?: GreasedLineMeshColorDistribution;\r\n}\r\n\r\n/**\r\n * Line mesh options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMeshBuilderOptions extends GreasedLineMeshOptions {\r\n /**\r\n * Distribution of the widths if the width table contains fewer entries than needed. Defaults to GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START\r\n * @see CompleteGreasedLineWidthTable\r\n */\r\n widthDistribution?: GreasedLineMeshWidthDistribution;\r\n}\r\n\r\n/**\r\n * Builder functions for creating GreasedLineMeshes\r\n */\r\n\r\n/**\r\n * Creates a new @see GreasedLinePluginMaterial\r\n * @param name name of the material\r\n * @param options material options @see GreasedLineMaterialOptions\r\n * @param scene scene or null to use the last scene\r\n * @returns StandardMaterial or PBRMaterial with the @see GreasedLinePluginMaterial attached to it\r\n */\r\nexport function CreateGreasedLineMaterial(name: string, options: GreasedLineMaterialOptions, scene: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let material;\r\n switch (options.materialType) {\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR:\r\n material = new PBRMaterial(name, scene, options.forceGLSL);\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_SIMPLE:\r\n material = new GreasedLineSimpleMaterial(name, scene, options);\r\n break;\r\n default:\r\n material = new StandardMaterial(name, scene, options.forceGLSL);\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n }\r\n\r\n return material;\r\n}\r\n\r\n/**\r\n * Creates a GreasedLine mesh\r\n * @param name name of the mesh\r\n * @param options options for the mesh\r\n * @param materialOptions material options for the mesh\r\n * @param scene scene where the mesh will be created\r\n * @returns instance of GreasedLineMesh\r\n */\r\nexport function CreateGreasedLine(name: string, options: GreasedLineMeshBuilderOptions, materialOptions?: Nullable<GreasedLineMaterialBuilderOptions>, scene?: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let instance;\r\n const allPoints = GreasedLineTools.ConvertPoints(options.points, options.pointsOptions);\r\n\r\n options.widthDistribution = options.widthDistribution ?? GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START;\r\n if (options.ribbonOptions) {\r\n options.ribbonOptions.facesMode = options.ribbonOptions.facesMode ?? GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING;\r\n options.ribbonOptions.pointsMode = options.ribbonOptions.pointsMode ?? GreasedLineRibbonPointsMode.POINTS_MODE_POINTS;\r\n options.ribbonOptions.directionsAutoMode =\r\n options.ribbonOptions.directionsAutoMode ??\r\n (options.ribbonOptions.directions ? GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_NONE : GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_FROM_FIRST_SEGMENT);\r\n }\r\n\r\n materialOptions = materialOptions ?? {\r\n color: GreasedLineMaterialDefaults.DEFAULT_COLOR,\r\n };\r\n materialOptions.createAndAssignMaterial = materialOptions.createAndAssignMaterial ?? true;\r\n materialOptions.colorDistribution = materialOptions?.colorDistribution ?? GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START;\r\n materialOptions.materialType = materialOptions.materialType ?? GreasedLineMeshMaterialType.MATERIAL_TYPE_STANDARD;\r\n\r\n const pointsCount = GetPointsCount(allPoints);\r\n const widths = CompleteGreasedLineWidthTable(pointsCount, options.widths ?? [], options.widthDistribution);\r\n\r\n const colors = materialOptions?.colors\r\n ? CompleteGreasedLineColorTable(pointsCount, materialOptions.colors, materialOptions.colorDistribution, materialOptions.color ?? GreasedLineMaterialDefaults.DEFAULT_COLOR)\r\n : undefined;\r\n\r\n // create new mesh if instance is not defined\r\n const initialGreasedLineOptions: GreasedLineMeshOptions = {\r\n points: allPoints,\r\n updatable: options.updatable,\r\n widths,\r\n lazy: options.lazy,\r\n ribbonOptions: options.ribbonOptions,\r\n uvs: options.uvs,\r\n colorPointers: options.colorPointers,\r\n };\r\n\r\n if (initialGreasedLineOptions.ribbonOptions) {\r\n if (initialGreasedLineOptions.ribbonOptions.pointsMode === GreasedLineRibbonPointsMode.POINTS_MODE_POINTS) {\r\n initialGreasedLineOptions.ribbonOptions.width = materialOptions.width ?? initialGreasedLineOptions.ribbonOptions.width ?? GreasedLineMaterialDefaults.DEFAULT_WIDTH;\r\n }\r\n }\r\n\r\n if (!options.instance) {\r\n instance = initialGreasedLineOptions.ribbonOptions\r\n ? new GreasedLineRibbonMesh(name, scene, initialGreasedLineOptions)\r\n : new GreasedLineMesh(name, scene, initialGreasedLineOptions);\r\n\r\n if (materialOptions) {\r\n const initialMaterialOptions: GreasedLineMaterialOptions = {\r\n materialType: materialOptions.materialType,\r\n dashCount: materialOptions.dashCount,\r\n dashOffset: materialOptions.dashOffset,\r\n dashRatio: materialOptions.dashRatio,\r\n resolution: materialOptions.resolution,\r\n sizeAttenuation: materialOptions.sizeAttenuation,\r\n useColors: materialOptions.useColors,\r\n useDash: materialOptions.useDash,\r\n visibility: materialOptions.visibility,\r\n width: materialOptions.width,\r\n color: materialOptions.color,\r\n colorMode: materialOptions.colorMode,\r\n colorsSampling: materialOptions.colorsSampling,\r\n colorDistributionType: materialOptions.colorDistributionType,\r\n colors,\r\n cameraFacing: !options.ribbonOptions,\r\n colorsTexture: materialOptions.colorsTexture,\r\n };\r\n\r\n if (materialOptions.createAndAssignMaterial) {\r\n const material = CreateGreasedLineMaterial(name, initialMaterialOptions, scene);\r\n instance.material = material;\r\n\r\n if (options.ribbonOptions?.facesMode === GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING) {\r\n material.backFaceCulling = false;\r\n }\r\n }\r\n }\r\n } else {\r\n // update the data on the mesh instance\r\n instance = options.instance;\r\n if (instance instanceof GreasedLineRibbonMesh) {\r\n instance.addPoints(allPoints, initialGreasedLineOptions);\r\n } else {\r\n // add widths\r\n const currentWidths = instance.widths;\r\n if (currentWidths) {\r\n const newWidths = currentWidths.slice();\r\n for (const w of widths) {\r\n newWidths.push(w);\r\n }\r\n instance.widths = newWidths;\r\n } else {\r\n instance.widths = widths;\r\n }\r\n\r\n instance.addPoints(allPoints);\r\n\r\n // add UVs\r\n if (options.uvs) {\r\n const currentUVs = instance.uvs;\r\n if (currentUVs) {\r\n const newUVs = new Float32Array(currentUVs.length + options.uvs.length);\r\n newUVs.set(currentUVs, 0);\r\n newUVs.set(options.uvs, currentUVs.length);\r\n instance.uvs = newUVs;\r\n } else {\r\n instance.uvs = options.uvs;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // add colors\r\n // it will merge if any colors already on the instance\r\n if (colors && options.instance) {\r\n if (options.instance.greasedLineMaterial) {\r\n const currentColors = options.instance.greasedLineMaterial.colors;\r\n if (currentColors) {\r\n const newColors = currentColors.concat(colors);\r\n options.instance.greasedLineMaterial.setColors(newColors, instance.isLazy());\r\n }\r\n }\r\n }\r\n\r\n return instance;\r\n}\r\n\r\n/**\r\n * Counts the number of points\r\n * @param allPoints Array of points [[x, y, z], [x, y, z], ...] or Array of points [x, y, z, x, y, z, ...]\r\n * @returns total number of points\r\n */\r\nexport function GetPointsCount(allPoints: number[][]) {\r\n let pointCount = 0;\r\n for (const points of allPoints) {\r\n pointCount += (<number[]>points).length / 3;\r\n }\r\n return pointCount;\r\n}\r\n\r\n/**\r\n * Completes the width table/fills the missing entries. It means it creates a width entry for every point of the line mesh.\r\n * You can provide more points the widths when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMeshWidthDistribution.REPEAT - the width table will be repeatedly copied to the empty values [wL, wU] = [wL, wU, wL, wU, wL, wU, wL, wU, ...]\r\n * GreasedLineMeshWidthDistribution.EVEN - the width table will be evenly copied to the empty values [wL, wU] = [wL, wL, wL, wL, wU, wU, wU, wU]\r\n * GreasedLineMeshWidthDistribution.START - the width table will be copied at the start of the empty values\r\n * and rest will be filled width the default width upper and default width lower values [wU, wL] = [wL, wU, dwL, dwU, dwL, dwU, dwL, dwU]\r\n * GreasedLineMeshWidthDistribution.END - the width table will be copied at the end of the empty values\r\n * and rest will be filled width the default values [wL, wU] = [wL, wU, dwL, dwU, dwL, dwU, wL, wU]\r\n * @param pointCount number of points of the line mesh\r\n * @param widths array of widths [widhtLower, widthUpper, widthLower, widthUpper ...]. Two widths (lower/upper) per point.\r\n * @param widthsDistribution how to distribute widths if the widths array has fewer entries than pointCount\r\n * @param defaultWidthUpper the default value which will be used to fill empty width entries - upper width\r\n * @param defaultWidthLower the default value which will be used to fill empty width entries - lower width\r\n * @returns completed width table.\r\n */\r\nexport function CompleteGreasedLineWidthTable(\r\n pointCount: number,\r\n widths: number[],\r\n widthsDistribution: GreasedLineMeshWidthDistribution,\r\n defaultWidthUpper = 1,\r\n defaultWidthLower = 1\r\n): number[] {\r\n const missingCount = pointCount - widths.length / 2;\r\n\r\n const widthsData: number[] = [];\r\n if (missingCount < 0) {\r\n return widths.slice(0, pointCount * 2);\r\n }\r\n\r\n // is the width table shorter than the point table?\r\n if (missingCount > 0) {\r\n if (widths.length % 2 != 0) {\r\n widths.push(defaultWidthUpper);\r\n }\r\n // it is, fill in the missing elements\r\n if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(widths.length / 2);\r\n\r\n // start sector\r\n for (let i = 0, j = 0; i < halfCount - 1; i++) {\r\n widthsData.push(widths[j++]);\r\n widthsData.push(widths[j++]);\r\n }\r\n\r\n // middle sector\r\n const widthL = widths[halfCount / 2];\r\n const widthU = widths[halfCount / 2 + 1];\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(widthU);\r\n widthsData.push(widthL);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n widthsData.push(widths[i++]);\r\n widthsData.push(widths[i++]);\r\n\r\n if (i === widths.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const widthsectorLength = widths.length / ((pointCount - 1) * 2);\r\n for (let x = 0; x < pointCount; x++) {\r\n const i = Math.floor(j);\r\n\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n\r\n j += widthsectorLength;\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < widths.length; i++) {\r\n widthsData.push(widths[i]);\r\n }\r\n }\r\n\r\n return widthsData;\r\n}\r\n\r\n/**\r\n * Completes the color table/fill the missing color entries. It means it creates a color entry for every point of the line mesh.\r\n * You can provide more points the colors when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMesColorhDistribution.REPEAT - the color table will be repeatedly copied to the empty values [c1, c2] = [c1, c2, c1, c2, c1, c2, c1, c2]\r\n * GreasedLineMesColorhDistribution.EVEN - the color table will be evenly copied to the empty values [c1, c2] = [c1, c1, c1, c1, c2, c2, c2, c2]\r\n * GreasedLineMesColorhDistribution.START - the color table will be copied at the start of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, dc, dc]\r\n * GreasedLineMesColorhDistribution.START_END - the color table will be copied at the start and the end of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, c1, c2]\r\n * @param pointCount number of points of the line mesh\r\n * @param colors array of Color3 for the color table\r\n * @param colorDistribution how to distribute colors if the colors array has fewer entries than pointCount\r\n * @param defaultColor default color to be used to fill empty entries in the color table\r\n * @returns completed array of Color3s\r\n */\r\nexport function CompleteGreasedLineColorTable(pointCount: number, colors: Color3[], colorDistribution: GreasedLineMeshColorDistribution, defaultColor: Color3): Color3[] {\r\n pointCount = Math.max(colors.length, pointCount);\r\n const missingCount = pointCount - colors.length;\r\n if (missingCount < 0) {\r\n return colors.slice(0, pointCount);\r\n }\r\n\r\n const colorsData: Color3[] = [];\r\n // is the color table shorter than the point table?\r\n if (missingCount > 0) {\r\n // it is, fill in the missing elements\r\n if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(colors.length / 2);\r\n\r\n // start sector\r\n for (let i = 0; i < halfCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // middle sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n colorsData.push(colors[i]);\r\n\r\n i++;\r\n\r\n if (i === colors.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const colorSectorLength = colors.length / (pointCount - 1);\r\n for (let x = 0; x < pointCount - 1; x++) {\r\n const i = Math.floor(j);\r\n\r\n colorsData.push(colors[i]);\r\n\r\n j += colorSectorLength;\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_NONE) {\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < pointCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n\r\n return colorsData;\r\n}\r\n"]}
|
|
@@ -128,9 +128,11 @@ export declare class GaussianSplattingMesh extends Mesh {
|
|
|
128
128
|
private _colorsTexture;
|
|
129
129
|
private _splatPositions;
|
|
130
130
|
private _splatIndex;
|
|
131
|
+
private _shTextures;
|
|
131
132
|
private _covariancesA;
|
|
132
133
|
private _covariancesB;
|
|
133
134
|
private _colors;
|
|
135
|
+
private _sh;
|
|
134
136
|
private readonly _keepInRam;
|
|
135
137
|
private _delayedTextureUpdate;
|
|
136
138
|
private _oldDirection;
|
|
@@ -142,6 +144,11 @@ export declare class GaussianSplattingMesh extends Mesh {
|
|
|
142
144
|
private static _SH_C0;
|
|
143
145
|
private static _SplatBatchSize;
|
|
144
146
|
private static _PlyConversionBatchSize;
|
|
147
|
+
private _shDegree;
|
|
148
|
+
/**
|
|
149
|
+
* SH degree. 0 = no sh (default). 1 = 3 parameters. 2 = 8 parameters. 3 = 15 parameters.
|
|
150
|
+
*/
|
|
151
|
+
get shDegree(): number;
|
|
145
152
|
/**
|
|
146
153
|
* Set the number of batch (a batch is 16384 splats) after which a display update is performed
|
|
147
154
|
* A value of 0 (default) means display update will not happens before splat is ready.
|
|
@@ -163,6 +170,10 @@ export declare class GaussianSplattingMesh extends Mesh {
|
|
|
163
170
|
* Gets the colors texture
|
|
164
171
|
*/
|
|
165
172
|
get colorsTexture(): Nullable<BaseTexture>;
|
|
173
|
+
/**
|
|
174
|
+
* Gets the SH textures
|
|
175
|
+
*/
|
|
176
|
+
get shTextures(): Nullable<BaseTexture[]>;
|
|
166
177
|
/**
|
|
167
178
|
* set rendering material
|
|
168
179
|
*/
|
|
@@ -195,7 +206,8 @@ export declare class GaussianSplattingMesh extends Mesh {
|
|
|
195
206
|
* @returns true when ready
|
|
196
207
|
*/
|
|
197
208
|
isReady(completeCheck?: boolean): boolean;
|
|
198
|
-
|
|
209
|
+
/** @internal */
|
|
210
|
+
_postToWorker(forced?: boolean): void;
|
|
199
211
|
/**
|
|
200
212
|
* Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
|
|
201
213
|
* @param subMesh defines the subMesh to render
|
|
@@ -261,15 +273,17 @@ export declare class GaussianSplattingMesh extends Mesh {
|
|
|
261
273
|
/**
|
|
262
274
|
* Update asynchronously the buffer
|
|
263
275
|
* @param data array buffer containing center, color, orientation and scale of splats
|
|
276
|
+
* @param sh optional array of uint8 array for SH data
|
|
264
277
|
* @returns a promise
|
|
265
278
|
*/
|
|
266
|
-
updateDataAsync(data: ArrayBuffer): Promise<void>;
|
|
279
|
+
updateDataAsync(data: ArrayBuffer, sh?: Uint8Array[]): Promise<void>;
|
|
267
280
|
/**
|
|
268
281
|
* @experimental
|
|
269
282
|
* Update data from GS (position, orientation, color, scaling)
|
|
270
283
|
* @param data array that contain all the datas
|
|
284
|
+
* @param sh optional array of uint8 array for SH data
|
|
271
285
|
*/
|
|
272
|
-
updateData(data: ArrayBuffer): void;
|
|
286
|
+
updateData(data: ArrayBuffer, sh?: Uint8Array[]): void;
|
|
273
287
|
private _updateSplatIndexBuffer;
|
|
274
288
|
private _updateSubTextures;
|
|
275
289
|
private _instanciateWorker;
|