@babylonjs/core 7.2.3 → 7.3.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/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +2 -0
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +2 -0
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/abstractEngine.d.ts +7 -0
- package/Engines/abstractEngine.js +10 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +0 -7
- package/Engines/thinEngine.js +1 -9
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +4 -2
- package/Engines/webgpuEngine.js +5 -2
- package/Engines/webgpuEngine.js.map +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +6 -6
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.d.ts +2 -3
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js +5 -5
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/fogBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Dual/fogBlock.js +4 -4
- package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js +4 -4
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +8 -7
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +9 -5
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.d.ts +4 -2
- package/Materials/Node/Blocks/Dual/textureBlock.js +43 -21
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.js +3 -3
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/derivativeBlock.js +9 -2
- package/Materials/Node/Blocks/Fragment/derivativeBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragCoordBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/fragCoordBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +16 -8
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/frontFacingBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/frontFacingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +2 -2
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +3 -3
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +4 -4
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js +2 -2
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js +3 -3
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js +4 -4
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/twirlBlock.js +9 -9
- package/Materials/Node/Blocks/Fragment/twirlBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.d.ts +6 -1
- package/Materials/Node/Blocks/Input/inputBlock.js +36 -12
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.d.ts +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.d.ts +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +3 -3
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.d.ts +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +9 -9
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.d.ts +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +21 -21
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.d.ts +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js +6 -6
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +5 -0
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock.js +2 -2
- package/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleRampGradientBlock.js +3 -3
- package/Materials/Node/Blocks/Particle/particleRampGradientBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js +1 -1
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +1 -1
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/bonesBlock.js +2 -2
- package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/instancesBlock.js +5 -5
- package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +12 -12
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +7 -7
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/vertexOutputBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Vertex/vertexOutputBlock.js +10 -3
- package/Materials/Node/Blocks/Vertex/vertexOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/addBlock.js +2 -1
- package/Materials/Node/Blocks/addBlock.js.map +1 -1
- package/Materials/Node/Blocks/arcTan2Block.js +3 -1
- package/Materials/Node/Blocks/arcTan2Block.js.map +1 -1
- package/Materials/Node/Blocks/clampBlock.js +1 -1
- package/Materials/Node/Blocks/clampBlock.js.map +1 -1
- package/Materials/Node/Blocks/cloudBlock.js +1 -1
- package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.js +9 -7
- package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorSplitterBlock.js +5 -5
- package/Materials/Node/Blocks/colorSplitterBlock.js.map +1 -1
- package/Materials/Node/Blocks/conditionalBlock.js +18 -12
- package/Materials/Node/Blocks/conditionalBlock.js.map +1 -1
- package/Materials/Node/Blocks/crossBlock.js +1 -1
- package/Materials/Node/Blocks/crossBlock.js.map +1 -1
- package/Materials/Node/Blocks/curveBlock.js +48 -53
- package/Materials/Node/Blocks/curveBlock.js.map +1 -1
- package/Materials/Node/Blocks/customBlock.js +1 -1
- package/Materials/Node/Blocks/customBlock.js.map +1 -1
- package/Materials/Node/Blocks/desaturateBlock.js +5 -4
- package/Materials/Node/Blocks/desaturateBlock.js.map +1 -1
- package/Materials/Node/Blocks/distanceBlock.js +1 -1
- package/Materials/Node/Blocks/distanceBlock.js.map +1 -1
- package/Materials/Node/Blocks/divideBlock.js +2 -1
- package/Materials/Node/Blocks/divideBlock.js.map +1 -1
- package/Materials/Node/Blocks/dotBlock.js +1 -1
- package/Materials/Node/Blocks/dotBlock.js.map +1 -1
- package/Materials/Node/Blocks/elbowBlock.js +1 -1
- package/Materials/Node/Blocks/elbowBlock.js.map +1 -1
- package/Materials/Node/Blocks/fresnelBlock.js +1 -1
- package/Materials/Node/Blocks/fresnelBlock.js.map +1 -1
- package/Materials/Node/Blocks/gradientBlock.js +8 -7
- package/Materials/Node/Blocks/gradientBlock.js.map +1 -1
- package/Materials/Node/Blocks/lengthBlock.js +1 -1
- package/Materials/Node/Blocks/lengthBlock.js.map +1 -1
- package/Materials/Node/Blocks/lerpBlock.js +1 -1
- package/Materials/Node/Blocks/lerpBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixBuilderBlock.js +1 -1
- package/Materials/Node/Blocks/matrixBuilderBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixDeterminantBlock.js +1 -1
- package/Materials/Node/Blocks/matrixDeterminantBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixTransposeBlock.js +1 -1
- package/Materials/Node/Blocks/matrixTransposeBlock.js.map +1 -1
- package/Materials/Node/Blocks/maxBlock.js +1 -1
- package/Materials/Node/Blocks/maxBlock.js.map +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
- package/Materials/Node/Blocks/minBlock.js +1 -1
- package/Materials/Node/Blocks/minBlock.js.map +1 -1
- package/Materials/Node/Blocks/modBlock.js +1 -1
- package/Materials/Node/Blocks/modBlock.js.map +1 -1
- package/Materials/Node/Blocks/multiplyBlock.js +2 -1
- package/Materials/Node/Blocks/multiplyBlock.js.map +1 -1
- package/Materials/Node/Blocks/nLerpBlock.js +1 -1
- package/Materials/Node/Blocks/nLerpBlock.js.map +1 -1
- package/Materials/Node/Blocks/negateBlock.js +1 -1
- package/Materials/Node/Blocks/negateBlock.js.map +1 -1
- package/Materials/Node/Blocks/normalBlendBlock.js +1 -1
- package/Materials/Node/Blocks/normalBlendBlock.js.map +1 -1
- package/Materials/Node/Blocks/normalizeBlock.js +1 -1
- package/Materials/Node/Blocks/normalizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/oneMinusBlock.js +1 -1
- package/Materials/Node/Blocks/oneMinusBlock.js.map +1 -1
- package/Materials/Node/Blocks/posterizeBlock.js +1 -1
- package/Materials/Node/Blocks/posterizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/powBlock.js +1 -1
- package/Materials/Node/Blocks/powBlock.js.map +1 -1
- package/Materials/Node/Blocks/randomNumberBlock.js +1 -1
- package/Materials/Node/Blocks/randomNumberBlock.js.map +1 -1
- package/Materials/Node/Blocks/reciprocalBlock.js +2 -2
- package/Materials/Node/Blocks/reciprocalBlock.js.map +1 -1
- package/Materials/Node/Blocks/reflectBlock.js +1 -1
- package/Materials/Node/Blocks/reflectBlock.js.map +1 -1
- package/Materials/Node/Blocks/refractBlock.js +1 -1
- package/Materials/Node/Blocks/refractBlock.js.map +1 -1
- package/Materials/Node/Blocks/remapBlock.js +1 -1
- package/Materials/Node/Blocks/remapBlock.js.map +1 -1
- package/Materials/Node/Blocks/replaceColorBlock.js +1 -1
- package/Materials/Node/Blocks/replaceColorBlock.js.map +1 -1
- package/Materials/Node/Blocks/rotate2dBlock.js +1 -1
- package/Materials/Node/Blocks/rotate2dBlock.js.map +1 -1
- package/Materials/Node/Blocks/scaleBlock.js +1 -1
- package/Materials/Node/Blocks/scaleBlock.js.map +1 -1
- package/Materials/Node/Blocks/simplexPerlin3DBlock.js +1 -1
- package/Materials/Node/Blocks/simplexPerlin3DBlock.js.map +1 -1
- package/Materials/Node/Blocks/smoothStepBlock.js +3 -2
- package/Materials/Node/Blocks/smoothStepBlock.js.map +1 -1
- package/Materials/Node/Blocks/stepBlock.js +1 -1
- package/Materials/Node/Blocks/stepBlock.js.map +1 -1
- package/Materials/Node/Blocks/subtractBlock.js +2 -1
- package/Materials/Node/Blocks/subtractBlock.js.map +1 -1
- package/Materials/Node/Blocks/transformBlock.js +18 -10
- package/Materials/Node/Blocks/transformBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.d.ts +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.js +2 -2
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/trigonometryBlock.js +1 -1
- package/Materials/Node/Blocks/trigonometryBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.js +30 -27
- package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorSplitterBlock.js +9 -8
- package/Materials/Node/Blocks/vectorSplitterBlock.js.map +1 -1
- package/Materials/Node/Blocks/viewDirectionBlock.js +1 -1
- package/Materials/Node/Blocks/viewDirectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/voronoiNoiseBlock.js +19 -8
- package/Materials/Node/Blocks/voronoiNoiseBlock.js.map +1 -1
- package/Materials/Node/Blocks/waveBlock.js +3 -3
- package/Materials/Node/Blocks/waveBlock.js.map +1 -1
- package/Materials/Node/Blocks/worleyNoise3DBlock.js +3 -3
- package/Materials/Node/Blocks/worleyNoise3DBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +9 -3
- package/Materials/Node/nodeMaterial.js +29 -4
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.d.ts +0 -1
- package/Materials/Node/nodeMaterialBlock.js +6 -6
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.d.ts +4 -0
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js +12 -0
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.d.ts +35 -3
- package/Materials/Node/nodeMaterialBuildState.js +169 -16
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +18 -4
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +60 -9
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/materialFlags.d.ts +6 -0
- package/Materials/materialFlags.js +15 -1
- package/Materials/materialFlags.js.map +1 -1
- package/Materials/materialHelper.d.ts +2 -2
- package/Materials/materialHelper.js.map +1 -1
- package/Meshes/Compression/meshoptCompression.js +4 -3
- package/Meshes/Compression/meshoptCompression.js.map +1 -1
- package/Misc/filesInput.d.ts +2 -2
- package/Misc/filesInput.js.map +1 -1
- package/Misc/screenshotTools.d.ts +6 -6
- package/Misc/screenshotTools.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +0 -1
- package/PostProcesses/postProcess.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +19 -3
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js +4 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js +3 -0
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
- package/Shaders/pbr.fragment.js +7 -0
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +2 -0
- package/Shaders/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/fresnelFunction.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/fresnelFunction.js +13 -0
- package/ShadersWGSL/ShadersInclude/fresnelFunction.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/helperFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/helperFunctions.js +68 -0
- package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"materialHelper.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/materialHelper.ts"],"names":[],"mappings":"AAaA,OAAO,EACH,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,yBAAyB,EACzB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,wCAAwC,EACxC,yBAAyB,EACzB,6BAA6B,EAC7B,gCAAgC,EAChC,2CAA2C,EAC3C,2BAA2B,EAC3B,qCAAqC,EACrC,sBAAsB,EACtB,uBAAuB,EACvB,iCAAiC,EACjC,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,qBAAqB,EACrB,6BAA6B,EAC7B,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,kCAAkC,EAClC,8BAA8B,EAC9B,0BAA0B,GAC7B,MAAM,4BAA4B,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,OAAO,cAAc;;AACvB;;;;GAIG;AACW,qCAAsB,GAAsD,sBAAsB,CAAC;AAEjH;;;;;;GAMG;AACW,wCAAyB,GAA8D,yBAAyB,CAAC;AAE/H;;;;;GAKG;AACW,gCAAiB,GAA8E,iBAAiB,CAAC;AAE/H;;;;;GAKG;AACW,0BA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GAQG;AACW,wBAAS,GAA6H,SAAS,CAAC;AAE9J;;;;;;;GAOG;AACW,yBAAU,GAA6G,UAAU,CAAC;AAEhJ;;;;;;GAMG;AACW,gCAAiB,GAAwF,iBAAiB,CAAC;AAEzI;;;;;GAKG;AACW,kCAAmB,GAAgG,mBAAmB,CAAC;AAErJ;;;;GAIG;AACW,wCAAyB,GAAyD,yBAAyB,CAAC;AAE1H;;;;;GAKG;AACW,2BAAY,GAAyD,YAAY,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Light } from \"../Lights/light\";\r\nimport type { PrePassConfiguration } from \"../Materials/prePassConfiguration\";\r\n\r\nimport type { UniformBuffer } from \"./uniformBuffer\";\r\nimport type { Effect, IEffectCreationOptions } from \"./effect\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport type { MaterialDefines } from \"./materialDefines\";\r\nimport type { EffectFallbacks } from \"./effectFallbacks\";\r\nimport type { Material } from \"./material\";\r\nimport {\r\n BindBonesParameters,\r\n BindFogParameters,\r\n BindLight,\r\n BindLightProperties,\r\n BindLights,\r\n BindLogDepth,\r\n BindMorphTargetParameters,\r\n BindSceneUniformBuffer,\r\n BindTextureMatrix,\r\n GetFogState,\r\n HandleFallbacksForShadows,\r\n PrepareAttributesForBakedVertexAnimation,\r\n PrepareAttributesForBones,\r\n PrepareAttributesForInstances,\r\n PrepareAttributesForMorphTargets,\r\n PrepareAttributesForMorphTargetsInfluencers,\r\n PrepareDefinesForAttributes,\r\n PrepareDefinesForBakedVertexAnimation,\r\n PrepareDefinesForBones,\r\n PrepareDefinesForCamera,\r\n PrepareDefinesForFrameBoundValues,\r\n PrepareDefinesForLight,\r\n PrepareDefinesForLights,\r\n PrepareDefinesForMergedUV,\r\n PrepareDefinesForMisc,\r\n PrepareDefinesForMorphTargets,\r\n PrepareDefinesForMultiview,\r\n PrepareDefinesForOIT,\r\n PrepareDefinesForPrePass,\r\n PrepareUniformsAndSamplersForLight,\r\n PrepareUniformsAndSamplersList,\r\n PushAttributesForInstances,\r\n} from \"./materialHelper.functions\";\r\n\r\n/**\r\n * \"Static Class\" containing the most commonly used helper while dealing with material for rendering purpose.\r\n *\r\n * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.\r\n *\r\n * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.\r\n */\r\nexport class MaterialHelper {\r\n /**\r\n * Binds the scene's uniform buffer to the effect.\r\n * @param effect defines the effect to bind to the scene uniform buffer\r\n * @param sceneUbo defines the uniform buffer storing scene data\r\n */\r\n public static BindSceneUniformBuffer: (effect: Effect, sceneUbo: UniformBuffer) => void = BindSceneUniformBuffer;\r\n\r\n /**\r\n * Helps preparing the defines values about the UVs in used in the effect.\r\n * UVs are shared as much as we can across channels in the shaders.\r\n * @param texture The texture we are preparing the UVs for\r\n * @param defines The defines to update\r\n * @param key The channel key \"diffuse\", \"specular\"... used in the shader\r\n */\r\n public static PrepareDefinesForMergedUV: (texture: BaseTexture, defines: any, key: string) => void = PrepareDefinesForMergedUV;\r\n\r\n /**\r\n * Binds a texture matrix value to its corresponding uniform\r\n * @param texture The texture to bind the matrix for\r\n * @param uniformBuffer The uniform buffer receiving the data\r\n * @param key The channel key \"diffuse\", \"specular\"... used in the shader\r\n */\r\n public static BindTextureMatrix: (texture: BaseTexture, uniformBuffer: UniformBuffer, key: string) => void = BindTextureMatrix;\r\n\r\n /**\r\n * Gets the current status of the fog (should it be enabled?)\r\n * @param mesh defines the mesh to evaluate for fog support\r\n * @param scene defines the hosting scene\r\n * @returns true if fog must be enabled\r\n */\r\n public static GetFogState: (mesh: AbstractMesh, scene: Scene) => boolean = GetFogState;\r\n\r\n /**\r\n * Helper used to prepare the list of defines associated with misc. values for shader compilation\r\n * @param mesh defines the current mesh\r\n * @param scene defines the current scene\r\n * @param useLogarithmicDepth defines if logarithmic depth has to be turned on\r\n * @param pointsCloud defines if point cloud rendering has to be turned on\r\n * @param fogEnabled defines if fog has to be turned on\r\n * @param alphaTest defines if alpha testing has to be turned on\r\n * @param defines defines the current list of defines\r\n * @param applyDecalAfterDetail Defines if the decal is applied after or before the detail\r\n */\r\n public static PrepareDefinesForMisc: (\r\n mesh: AbstractMesh,\r\n scene: Scene,\r\n useLogarithmicDepth: boolean,\r\n pointsCloud: boolean,\r\n fogEnabled: boolean,\r\n alphaTest: boolean,\r\n defines: any,\r\n applyDecalAfterDetail?: boolean\r\n ) => void = PrepareDefinesForMisc;\r\n\r\n /**\r\n * Helper used to prepare the defines relative to the active camera\r\n * @param scene defines the current scene\r\n * @param defines specifies the list of active defines\r\n * @returns true if the defines have been updated, else false\r\n */\r\n public static PrepareDefinesForCamera: (scene: Scene, defines: any) => boolean = PrepareDefinesForCamera;\r\n\r\n /**\r\n * Helper used to prepare the list of defines associated with frame values for shader compilation\r\n * @param scene defines the current scene\r\n * @param engine defines the current engine\r\n * @param material defines the material we are compiling the shader for\r\n * @param defines specifies the list of active defines\r\n * @param useInstances defines if instances have to be turned on\r\n * @param useClipPlane defines if clip plane have to be turned on\r\n * @param useThinInstances defines if thin instances have to be turned on\r\n */\r\n public static PrepareDefinesForFrameBoundValues: (\r\n scene: Scene,\r\n engine: Engine,\r\n material: Material,\r\n defines: any,\r\n useInstances: boolean,\r\n useClipPlane?: Nullable<boolean>,\r\n useThinInstances?: boolean\r\n ) => void = PrepareDefinesForFrameBoundValues;\r\n\r\n /**\r\n * Prepares the defines for bones\r\n * @param mesh The mesh containing the geometry data we will draw\r\n * @param defines The defines to update\r\n */\r\n public static PrepareDefinesForBones: (mesh: AbstractMesh, defines: any) => void = PrepareDefinesForBones;\r\n\r\n /**\r\n * Prepares the defines for morph targets\r\n * @param mesh The mesh containing the geometry data we will draw\r\n * @param defines The defines to update\r\n */\r\n public static PrepareDefinesForMorphTargets: (mesh: AbstractMesh, defines: any) => void = PrepareDefinesForMorphTargets;\r\n\r\n /**\r\n * Prepares the defines for baked vertex animation\r\n * @param mesh The mesh containing the geometry data we will draw\r\n * @param defines The defines to update\r\n */\r\n public static PrepareDefinesForBakedVertexAnimation: (mesh: AbstractMesh, defines: any) => void = PrepareDefinesForBakedVertexAnimation;\r\n\r\n /**\r\n * Prepares the defines used in the shader depending on the attributes data available in the mesh\r\n * @param mesh The mesh containing the geometry data we will draw\r\n * @param defines The defines to update\r\n * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)\r\n * @param useBones Precise whether bones should be used or not (override mesh info)\r\n * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)\r\n * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)\r\n * @param useBakedVertexAnimation Precise whether baked vertex animation should be used or not (override mesh info)\r\n * @returns false if defines are considered not dirty and have not been checked\r\n */\r\n public static PrepareDefinesForAttributes: (\r\n mesh: AbstractMesh,\r\n defines: any,\r\n useVertexColor: boolean,\r\n useBones: boolean,\r\n useMorphTargets?: boolean,\r\n useVertexAlpha?: boolean,\r\n useBakedVertexAnimation?: boolean\r\n ) => boolean = PrepareDefinesForAttributes;\r\n\r\n /**\r\n * Prepares the defines related to multiview\r\n * @param scene The scene we are intending to draw\r\n * @param defines The defines to update\r\n */\r\n public static PrepareDefinesForMultiview: (scene: Scene, defines: any) => void = PrepareDefinesForMultiview;\r\n\r\n /**\r\n * Prepares the defines related to order independant transparency\r\n * @param scene The scene we are intending to draw\r\n * @param defines The defines to update\r\n * @param needAlphaBlending Determines if the material needs alpha blending\r\n */\r\n public static PrepareDefinesForOIT: (scene: Scene, defines: any, needAlphaBlending: boolean) => void = PrepareDefinesForOIT;\r\n\r\n /**\r\n * Prepares the defines related to the prepass\r\n * @param scene The scene we are intending to draw\r\n * @param defines The defines to update\r\n * @param canRenderToMRT Indicates if this material renders to several textures in the prepass\r\n */\r\n public static PrepareDefinesForPrePass: (scene: Scene, defines: any, canRenderToMRT: boolean) => void = PrepareDefinesForPrePass;\r\n\r\n /**\r\n * Prepares the defines related to the light information passed in parameter\r\n * @param scene The scene we are intending to draw\r\n * @param mesh The mesh the effect is compiling for\r\n * @param light The light the effect is compiling for\r\n * @param lightIndex The index of the light\r\n * @param defines The defines to update\r\n * @param specularSupported Specifies whether specular is supported or not (override lights data)\r\n * @param state Defines the current state regarding what is needed (normals, etc...)\r\n * @param state.needNormals\r\n * @param state.needRebuild\r\n * @param state.shadowEnabled\r\n * @param state.specularEnabled\r\n * @param state.lightmapMode\r\n */\r\n public static PrepareDefinesForLight: (\r\n scene: Scene,\r\n mesh: AbstractMesh,\r\n light: Light,\r\n lightIndex: number,\r\n defines: any,\r\n specularSupported: boolean,\r\n state: {\r\n needNormals: boolean;\r\n needRebuild: boolean;\r\n shadowEnabled: boolean;\r\n specularEnabled: boolean;\r\n lightmapMode: boolean;\r\n }\r\n ) => void = PrepareDefinesForLight;\r\n\r\n /**\r\n * Prepares the defines related to the light information passed in parameter\r\n * @param scene The scene we are intending to draw\r\n * @param mesh The mesh the effect is compiling for\r\n * @param defines The defines to update\r\n * @param specularSupported Specifies whether specular is supported or not (override lights data)\r\n * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max\r\n * @param disableLighting Specifies whether the lighting is disabled (override scene and light)\r\n * @returns true if normals will be required for the rest of the effect\r\n */\r\n public static PrepareDefinesForLights: (\r\n scene: Scene,\r\n mesh: AbstractMesh,\r\n defines: any,\r\n specularSupported: boolean,\r\n maxSimultaneousLights?: number,\r\n disableLighting?: boolean\r\n ) => boolean = PrepareDefinesForLights;\r\n\r\n /**\r\n * Prepares the uniforms and samplers list to be used in the effect (for a specific light)\r\n * @param lightIndex defines the light index\r\n * @param uniformsList The uniform list\r\n * @param samplersList The sampler list\r\n * @param projectedLightTexture defines if projected texture must be used\r\n * @param uniformBuffersList defines an optional list of uniform buffers\r\n * @param updateOnlyBuffersList True to only update the uniformBuffersList array\r\n */\r\n public static PrepareUniformsAndSamplersForLight: (\r\n lightIndex: number,\r\n uniformsList: string[],\r\n samplersList: string[],\r\n projectedLightTexture?: any,\r\n uniformBuffersList?: Nullable<string[]>,\r\n updateOnlyBuffersList?: boolean\r\n ) => void = PrepareUniformsAndSamplersForLight;\r\n\r\n /**\r\n * Prepares the uniforms and samplers list to be used in the effect\r\n * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information\r\n * @param samplersList The sampler list\r\n * @param defines The defines helping in the list generation\r\n * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect\r\n */\r\n public static PrepareUniformsAndSamplersList: (\r\n uniformsListOrOptions: string[] | IEffectCreationOptions,\r\n samplersList?: string[],\r\n defines?: any,\r\n maxSimultaneousLights?: number\r\n ) => void = PrepareUniformsAndSamplersList;\r\n\r\n /**\r\n * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)\r\n * @param defines The defines to update while falling back\r\n * @param fallbacks The authorized effect fallbacks\r\n * @param maxSimultaneousLights The maximum number of lights allowed\r\n * @param rank the current rank of the Effect\r\n * @returns The newly affected rank\r\n */\r\n public static HandleFallbacksForShadows: (defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number) => number = HandleFallbacksForShadows;\r\n\r\n /**\r\n * Prepares the list of attributes required for morph targets according to the effect defines.\r\n * @param attribs The current list of supported attribs\r\n * @param mesh The mesh to prepare the morph targets attributes for\r\n * @param influencers The number of influencers\r\n */\r\n public static PrepareAttributesForMorphTargetsInfluencers: (attribs: string[], mesh: AbstractMesh, influencers: number) => void = PrepareAttributesForMorphTargetsInfluencers;\r\n\r\n /**\r\n * Prepares the list of attributes required for morph targets according to the effect defines.\r\n * @param attribs The current list of supported attribs\r\n * @param mesh The mesh to prepare the morph targets attributes for\r\n * @param defines The current Defines of the effect\r\n */\r\n public static PrepareAttributesForMorphTargets: (attribs: string[], mesh: AbstractMesh, defines: any) => void = PrepareAttributesForMorphTargets;\r\n\r\n /**\r\n * Prepares the list of attributes required for baked vertex animations according to the effect defines.\r\n * @param attribs The current list of supported attribs\r\n * @param mesh The mesh to prepare for baked vertex animations\r\n * @param defines The current Defines of the effect\r\n */\r\n public static PrepareAttributesForBakedVertexAnimation: (attribs: string[], mesh: AbstractMesh, defines: any) => void = PrepareAttributesForBakedVertexAnimation;\r\n\r\n /**\r\n * Prepares the list of attributes required for bones according to the effect defines.\r\n * @param attribs The current list of supported attribs\r\n * @param mesh The mesh to prepare the bones attributes for\r\n * @param defines The current Defines of the effect\r\n * @param fallbacks The current effect fallback strategy\r\n */\r\n public static PrepareAttributesForBones: (attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks) => void = PrepareAttributesForBones;\r\n\r\n /**\r\n * Check and prepare the list of attributes required for instances according to the effect defines.\r\n * @param attribs The current list of supported attribs\r\n * @param defines The current MaterialDefines of the effect\r\n */\r\n public static PrepareAttributesForInstances: (attribs: string[], defines: MaterialDefines) => void = PrepareAttributesForInstances;\r\n\r\n /**\r\n * Add the list of attributes required for instances to the attribs array.\r\n * @param attribs The current list of supported attribs\r\n * @param needsPreviousMatrices If the shader needs previous matrices\r\n */\r\n public static PushAttributesForInstances: (attribs: string[], needsPreviousMatrices?: boolean) => void = PushAttributesForInstances;\r\n\r\n /**\r\n * Binds the light information to the effect.\r\n * @param light The light containing the generator\r\n * @param effect The effect we are binding the data to\r\n * @param lightIndex The light index in the effect used to render\r\n */\r\n public static BindLightProperties: (light: Light, effect: Effect, lightIndex: number) => void = BindLightProperties;\r\n\r\n /**\r\n * Binds the lights information from the scene to the effect for the given mesh.\r\n * @param light Light to bind\r\n * @param lightIndex Light index\r\n * @param scene The scene where the light belongs to\r\n * @param effect The effect we are binding the data to\r\n * @param useSpecular Defines if specular is supported\r\n * @param receiveShadows Defines if the effect (mesh) we bind the light for receives shadows\r\n */\r\n public static BindLight: (light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, receiveShadows?: boolean) => void = BindLight;\r\n\r\n /**\r\n * Binds the lights information from the scene to the effect for the given mesh.\r\n * @param scene The scene the lights belongs to\r\n * @param mesh The mesh we are binding the information to render\r\n * @param effect The effect we are binding the data to\r\n * @param defines The generated defines for the effect\r\n * @param maxSimultaneousLights The maximum number of light that can be bound to the effect\r\n */\r\n public static BindLights: (scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number) => void = BindLights;\r\n\r\n /**\r\n * Binds the fog information from the scene to the effect for the given mesh.\r\n * @param scene The scene the lights belongs to\r\n * @param mesh The mesh we are binding the information to render\r\n * @param effect The effect we are binding the data to\r\n * @param linearSpace Defines if the fog effect is applied in linear space\r\n */\r\n public static BindFogParameters: (scene: Scene, mesh?: AbstractMesh, effect?: Effect, linearSpace?: boolean) => void = BindFogParameters;\r\n\r\n /**\r\n * Binds the bones information from the mesh to the effect.\r\n * @param mesh The mesh we are binding the information to render\r\n * @param effect The effect we are binding the data to\r\n * @param prePassConfiguration Configuration for the prepass, in case prepass is activated\r\n */\r\n public static BindBonesParameters: (mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration) => void = BindBonesParameters;\r\n\r\n /**\r\n * Binds the morph targets information from the mesh to the effect.\r\n * @param abstractMesh The mesh we are binding the information to render\r\n * @param effect The effect we are binding the data to\r\n */\r\n public static BindMorphTargetParameters: (abstractMesh: AbstractMesh, effect: Effect) => void = BindMorphTargetParameters;\r\n\r\n /**\r\n * Binds the logarithmic depth information from the scene to the effect for the given defines.\r\n * @param defines The generated defines used in the effect\r\n * @param effect The effect we are binding the data to\r\n * @param scene The scene we are willing to render with logarithmic scale for\r\n */\r\n public static BindLogDepth: (defines: any, effect: Effect, scene: Scene) => void = BindLogDepth;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"materialHelper.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/materialHelper.ts"],"names":[],"mappings":"AAaA,OAAO,EACH,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,yBAAyB,EACzB,sBAAsB,E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C;;;;;;;;;GASG;AACW,sCAAuB,GAOtB,uBAAuB,CAAC;AAEvC;;;;;;;;GAQG;AACW,iDAAkC,GAOpC,kCAAkC,CAAC;AAE/C;;;;;;GAMG;AACW,6CAA8B,GAKhC,8BAA8B,CAAC;AAE3C;;;;;;;GAOG;AACW,wCAAyB,GAAwG,yBAAyB,CAAC;AAEzK;;;;;GAKG;AACW,0DAA2C,GAAyE,2CAA2C,CAAC;AAE9K;;;;;GAKG;AACW,+CAAgC,GAAkE,gCAAgC,CAAC;AAEjJ;;;;;GAKG;AACW,uDAAwC,GAAkE,wCAAwC,CAAC;AAEjK;;;;;;GAMG;AACW,wCAAyB,GAA8F,yBAAyB,CAAC;AAE/J;;;;GAIG;AACW,4CAA6B,GAA0D,6BAA6B,CAAC;AAEnI;;;;GAIG;AACW,yCAA0B,GAAiE,0BAA0B,CAAC;AAEpI;;;;;GAKG;AACW,kCAAmB,GAA+D,mBAAmB,CAAC;AAEpH;;;;;;;;GAQG;AACW,wBAAS,GAA6H,SAAS,CAAC;AAE9J;;;;;;;GAOG;AACW,yBAAU,GAA6G,UAAU,CAAC;AAEhJ;;;;;;GAMG;AACW,gCAAiB,GAAwF,iBAAiB,CAAC;AAEzI;;;;;GAKG;AACW,kCAAmB,GAAgG,mBAAmB,CAAC;AAErJ;;;;GAIG;AACW,wCAAyB,GAAyD,yBAAyB,CAAC;AAE1H;;;;;GAKG;AACW,2BAAY,GAAyD,YAAY,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Light } from \"../Lights/light\";\r\nimport type { PrePassConfiguration } from \"../Materials/prePassConfiguration\";\r\n\r\nimport type { UniformBuffer } from \"./uniformBuffer\";\r\nimport type { Effect, IEffectCreationOptions } from \"./effect\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport type { MaterialDefines } from \"./materialDefines\";\r\nimport type { EffectFallbacks } from \"./effectFallbacks\";\r\nimport type { Material } from \"./material\";\r\nimport {\r\n BindBonesParameters,\r\n BindFogParameters,\r\n BindLight,\r\n BindLightProperties,\r\n BindLights,\r\n BindLogDepth,\r\n BindMorphTargetParameters,\r\n BindSceneUniformBuffer,\r\n BindTextureMatrix,\r\n GetFogState,\r\n HandleFallbacksForShadows,\r\n PrepareAttributesForBakedVertexAnimation,\r\n PrepareAttributesForBones,\r\n PrepareAttributesForInstances,\r\n PrepareAttributesForMorphTargets,\r\n PrepareAttributesForMorphTargetsInfluencers,\r\n PrepareDefinesForAttributes,\r\n PrepareDefinesForBakedVertexAnimation,\r\n PrepareDefinesForBones,\r\n PrepareDefinesForCamera,\r\n PrepareDefinesForFrameBoundValues,\r\n PrepareDefinesForLight,\r\n PrepareDefinesForLights,\r\n PrepareDefinesForMergedUV,\r\n PrepareDefinesForMisc,\r\n PrepareDefinesForMorphTargets,\r\n PrepareDefinesForMultiview,\r\n PrepareDefinesForOIT,\r\n PrepareDefinesForPrePass,\r\n PrepareUniformsAndSamplersForLight,\r\n PrepareUniformsAndSamplersList,\r\n PushAttributesForInstances,\r\n} from \"./materialHelper.functions\";\r\n\r\n/**\r\n * \"Static Class\" containing the most commonly used helper while dealing with material for rendering purpose.\r\n *\r\n * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.\r\n *\r\n * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.\r\n */\r\nexport class MaterialHelper {\r\n /**\r\n * Binds the scene's uniform buffer to the effect.\r\n * @param effect defines the effect to bind to the scene uniform buffer\r\n * @param sceneUbo defines the uniform buffer storing scene data\r\n */\r\n public static BindSceneUniformBuffer: (effect: Effect, sceneUbo: UniformBuffer) => void = BindSceneUniformBuffer;\r\n\r\n /**\r\n * Helps preparing the defines values about the UVs in used in the effect.\r\n * UVs are shared as much as we can across channels in the shaders.\r\n * @param texture The texture we are preparing the UVs for\r\n * @param defines The defines to update\r\n * @param key The channel key \"diffuse\", \"specular\"... used in the shader\r\n */\r\n public static PrepareDefinesForMergedUV: (texture: BaseTexture, defines: any, key: string) => void = PrepareDefinesForMergedUV;\r\n\r\n /**\r\n * Binds a texture matrix value to its corresponding uniform\r\n * @param texture The texture to bind the matrix for\r\n * @param uniformBuffer The uniform buffer receiving the data\r\n * @param key The channel key \"diffuse\", \"specular\"... used in the shader\r\n */\r\n public static BindTextureMatrix: (texture: BaseTexture, uniformBuffer: UniformBuffer, key: string) => void = BindTextureMatrix;\r\n\r\n /**\r\n * Gets the current status of the fog (should it be enabled?)\r\n * @param mesh defines the mesh to evaluate for fog support\r\n * @param scene defines the hosting scene\r\n * @returns true if fog must be enabled\r\n */\r\n public static GetFogState: (mesh: AbstractMesh, scene: Scene) => boolean = GetFogState;\r\n\r\n /**\r\n * Helper used to prepare the list of defines associated with misc. values for shader compilation\r\n * @param mesh defines the current mesh\r\n * @param scene defines the current scene\r\n * @param useLogarithmicDepth defines if logarithmic depth has to be turned on\r\n * @param pointsCloud defines if point cloud rendering has to be turned on\r\n * @param fogEnabled defines if fog has to be turned on\r\n * @param alphaTest defines if alpha testing has to be turned on\r\n * @param defines defines the current list of defines\r\n * @param applyDecalAfterDetail Defines if the decal is applied after or before the detail\r\n */\r\n public static PrepareDefinesForMisc: (\r\n mesh: AbstractMesh,\r\n scene: Scene,\r\n useLogarithmicDepth: boolean,\r\n pointsCloud: boolean,\r\n fogEnabled: boolean,\r\n alphaTest: boolean,\r\n defines: any,\r\n applyDecalAfterDetail?: boolean\r\n ) => void = PrepareDefinesForMisc;\r\n\r\n /**\r\n * Helper used to prepare the defines relative to the active camera\r\n * @param scene defines the current scene\r\n * @param defines specifies the list of active defines\r\n * @returns true if the defines have been updated, else false\r\n */\r\n public static PrepareDefinesForCamera: (scene: Scene, defines: any) => boolean = PrepareDefinesForCamera;\r\n\r\n /**\r\n * Helper used to prepare the list of defines associated with frame values for shader compilation\r\n * @param scene defines the current scene\r\n * @param engine defines the current engine\r\n * @param material defines the material we are compiling the shader for\r\n * @param defines specifies the list of active defines\r\n * @param useInstances defines if instances have to be turned on\r\n * @param useClipPlane defines if clip plane have to be turned on\r\n * @param useThinInstances defines if thin instances have to be turned on\r\n */\r\n public static PrepareDefinesForFrameBoundValues: (\r\n scene: Scene,\r\n engine: AbstractEngine,\r\n material: Material,\r\n defines: any,\r\n useInstances: boolean,\r\n useClipPlane?: Nullable<boolean>,\r\n useThinInstances?: boolean\r\n ) => void = PrepareDefinesForFrameBoundValues;\r\n\r\n /**\r\n * Prepares the defines for bones\r\n * @param mesh The mesh containing the geometry data we will draw\r\n * @param defines The defines to update\r\n */\r\n public static PrepareDefinesForBones: (mesh: AbstractMesh, defines: any) => void = PrepareDefinesForBones;\r\n\r\n /**\r\n * Prepares the defines for morph targets\r\n * @param mesh The mesh containing the geometry data we will draw\r\n * @param defines The defines to update\r\n */\r\n public static PrepareDefinesForMorphTargets: (mesh: AbstractMesh, defines: any) => void = PrepareDefinesForMorphTargets;\r\n\r\n /**\r\n * Prepares the defines for baked vertex animation\r\n * @param mesh The mesh containing the geometry data we will draw\r\n * @param defines The defines to update\r\n */\r\n public static PrepareDefinesForBakedVertexAnimation: (mesh: AbstractMesh, defines: any) => void = PrepareDefinesForBakedVertexAnimation;\r\n\r\n /**\r\n * Prepares the defines used in the shader depending on the attributes data available in the mesh\r\n * @param mesh The mesh containing the geometry data we will draw\r\n * @param defines The defines to update\r\n * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)\r\n * @param useBones Precise whether bones should be used or not (override mesh info)\r\n * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)\r\n * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)\r\n * @param useBakedVertexAnimation Precise whether baked vertex animation should be used or not (override mesh info)\r\n * @returns false if defines are considered not dirty and have not been checked\r\n */\r\n public static PrepareDefinesForAttributes: (\r\n mesh: AbstractMesh,\r\n defines: any,\r\n useVertexColor: boolean,\r\n useBones: boolean,\r\n useMorphTargets?: boolean,\r\n useVertexAlpha?: boolean,\r\n useBakedVertexAnimation?: boolean\r\n ) => boolean = PrepareDefinesForAttributes;\r\n\r\n /**\r\n * Prepares the defines related to multiview\r\n * @param scene The scene we are intending to draw\r\n * @param defines The defines to update\r\n */\r\n public static PrepareDefinesForMultiview: (scene: Scene, defines: any) => void = PrepareDefinesForMultiview;\r\n\r\n /**\r\n * Prepares the defines related to order independant transparency\r\n * @param scene The scene we are intending to draw\r\n * @param defines The defines to update\r\n * @param needAlphaBlending Determines if the material needs alpha blending\r\n */\r\n public static PrepareDefinesForOIT: (scene: Scene, defines: any, needAlphaBlending: boolean) => void = PrepareDefinesForOIT;\r\n\r\n /**\r\n * Prepares the defines related to the prepass\r\n * @param scene The scene we are intending to draw\r\n * @param defines The defines to update\r\n * @param canRenderToMRT Indicates if this material renders to several textures in the prepass\r\n */\r\n public static PrepareDefinesForPrePass: (scene: Scene, defines: any, canRenderToMRT: boolean) => void = PrepareDefinesForPrePass;\r\n\r\n /**\r\n * Prepares the defines related to the light information passed in parameter\r\n * @param scene The scene we are intending to draw\r\n * @param mesh The mesh the effect is compiling for\r\n * @param light The light the effect is compiling for\r\n * @param lightIndex The index of the light\r\n * @param defines The defines to update\r\n * @param specularSupported Specifies whether specular is supported or not (override lights data)\r\n * @param state Defines the current state regarding what is needed (normals, etc...)\r\n * @param state.needNormals\r\n * @param state.needRebuild\r\n * @param state.shadowEnabled\r\n * @param state.specularEnabled\r\n * @param state.lightmapMode\r\n */\r\n public static PrepareDefinesForLight: (\r\n scene: Scene,\r\n mesh: AbstractMesh,\r\n light: Light,\r\n lightIndex: number,\r\n defines: any,\r\n specularSupported: boolean,\r\n state: {\r\n needNormals: boolean;\r\n needRebuild: boolean;\r\n shadowEnabled: boolean;\r\n specularEnabled: boolean;\r\n lightmapMode: boolean;\r\n }\r\n ) => void = PrepareDefinesForLight;\r\n\r\n /**\r\n * Prepares the defines related to the light information passed in parameter\r\n * @param scene The scene we are intending to draw\r\n * @param mesh The mesh the effect is compiling for\r\n * @param defines The defines to update\r\n * @param specularSupported Specifies whether specular is supported or not (override lights data)\r\n * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max\r\n * @param disableLighting Specifies whether the lighting is disabled (override scene and light)\r\n * @returns true if normals will be required for the rest of the effect\r\n */\r\n public static PrepareDefinesForLights: (\r\n scene: Scene,\r\n mesh: AbstractMesh,\r\n defines: any,\r\n specularSupported: boolean,\r\n maxSimultaneousLights?: number,\r\n disableLighting?: boolean\r\n ) => boolean = PrepareDefinesForLights;\r\n\r\n /**\r\n * Prepares the uniforms and samplers list to be used in the effect (for a specific light)\r\n * @param lightIndex defines the light index\r\n * @param uniformsList The uniform list\r\n * @param samplersList The sampler list\r\n * @param projectedLightTexture defines if projected texture must be used\r\n * @param uniformBuffersList defines an optional list of uniform buffers\r\n * @param updateOnlyBuffersList True to only update the uniformBuffersList array\r\n */\r\n public static PrepareUniformsAndSamplersForLight: (\r\n lightIndex: number,\r\n uniformsList: string[],\r\n samplersList: string[],\r\n projectedLightTexture?: any,\r\n uniformBuffersList?: Nullable<string[]>,\r\n updateOnlyBuffersList?: boolean\r\n ) => void = PrepareUniformsAndSamplersForLight;\r\n\r\n /**\r\n * Prepares the uniforms and samplers list to be used in the effect\r\n * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information\r\n * @param samplersList The sampler list\r\n * @param defines The defines helping in the list generation\r\n * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect\r\n */\r\n public static PrepareUniformsAndSamplersList: (\r\n uniformsListOrOptions: string[] | IEffectCreationOptions,\r\n samplersList?: string[],\r\n defines?: any,\r\n maxSimultaneousLights?: number\r\n ) => void = PrepareUniformsAndSamplersList;\r\n\r\n /**\r\n * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)\r\n * @param defines The defines to update while falling back\r\n * @param fallbacks The authorized effect fallbacks\r\n * @param maxSimultaneousLights The maximum number of lights allowed\r\n * @param rank the current rank of the Effect\r\n * @returns The newly affected rank\r\n */\r\n public static HandleFallbacksForShadows: (defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number) => number = HandleFallbacksForShadows;\r\n\r\n /**\r\n * Prepares the list of attributes required for morph targets according to the effect defines.\r\n * @param attribs The current list of supported attribs\r\n * @param mesh The mesh to prepare the morph targets attributes for\r\n * @param influencers The number of influencers\r\n */\r\n public static PrepareAttributesForMorphTargetsInfluencers: (attribs: string[], mesh: AbstractMesh, influencers: number) => void = PrepareAttributesForMorphTargetsInfluencers;\r\n\r\n /**\r\n * Prepares the list of attributes required for morph targets according to the effect defines.\r\n * @param attribs The current list of supported attribs\r\n * @param mesh The mesh to prepare the morph targets attributes for\r\n * @param defines The current Defines of the effect\r\n */\r\n public static PrepareAttributesForMorphTargets: (attribs: string[], mesh: AbstractMesh, defines: any) => void = PrepareAttributesForMorphTargets;\r\n\r\n /**\r\n * Prepares the list of attributes required for baked vertex animations according to the effect defines.\r\n * @param attribs The current list of supported attribs\r\n * @param mesh The mesh to prepare for baked vertex animations\r\n * @param defines The current Defines of the effect\r\n */\r\n public static PrepareAttributesForBakedVertexAnimation: (attribs: string[], mesh: AbstractMesh, defines: any) => void = PrepareAttributesForBakedVertexAnimation;\r\n\r\n /**\r\n * Prepares the list of attributes required for bones according to the effect defines.\r\n * @param attribs The current list of supported attribs\r\n * @param mesh The mesh to prepare the bones attributes for\r\n * @param defines The current Defines of the effect\r\n * @param fallbacks The current effect fallback strategy\r\n */\r\n public static PrepareAttributesForBones: (attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks) => void = PrepareAttributesForBones;\r\n\r\n /**\r\n * Check and prepare the list of attributes required for instances according to the effect defines.\r\n * @param attribs The current list of supported attribs\r\n * @param defines The current MaterialDefines of the effect\r\n */\r\n public static PrepareAttributesForInstances: (attribs: string[], defines: MaterialDefines) => void = PrepareAttributesForInstances;\r\n\r\n /**\r\n * Add the list of attributes required for instances to the attribs array.\r\n * @param attribs The current list of supported attribs\r\n * @param needsPreviousMatrices If the shader needs previous matrices\r\n */\r\n public static PushAttributesForInstances: (attribs: string[], needsPreviousMatrices?: boolean) => void = PushAttributesForInstances;\r\n\r\n /**\r\n * Binds the light information to the effect.\r\n * @param light The light containing the generator\r\n * @param effect The effect we are binding the data to\r\n * @param lightIndex The light index in the effect used to render\r\n */\r\n public static BindLightProperties: (light: Light, effect: Effect, lightIndex: number) => void = BindLightProperties;\r\n\r\n /**\r\n * Binds the lights information from the scene to the effect for the given mesh.\r\n * @param light Light to bind\r\n * @param lightIndex Light index\r\n * @param scene The scene where the light belongs to\r\n * @param effect The effect we are binding the data to\r\n * @param useSpecular Defines if specular is supported\r\n * @param receiveShadows Defines if the effect (mesh) we bind the light for receives shadows\r\n */\r\n public static BindLight: (light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, receiveShadows?: boolean) => void = BindLight;\r\n\r\n /**\r\n * Binds the lights information from the scene to the effect for the given mesh.\r\n * @param scene The scene the lights belongs to\r\n * @param mesh The mesh we are binding the information to render\r\n * @param effect The effect we are binding the data to\r\n * @param defines The generated defines for the effect\r\n * @param maxSimultaneousLights The maximum number of light that can be bound to the effect\r\n */\r\n public static BindLights: (scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number) => void = BindLights;\r\n\r\n /**\r\n * Binds the fog information from the scene to the effect for the given mesh.\r\n * @param scene The scene the lights belongs to\r\n * @param mesh The mesh we are binding the information to render\r\n * @param effect The effect we are binding the data to\r\n * @param linearSpace Defines if the fog effect is applied in linear space\r\n */\r\n public static BindFogParameters: (scene: Scene, mesh?: AbstractMesh, effect?: Effect, linearSpace?: boolean) => void = BindFogParameters;\r\n\r\n /**\r\n * Binds the bones information from the mesh to the effect.\r\n * @param mesh The mesh we are binding the information to render\r\n * @param effect The effect we are binding the data to\r\n * @param prePassConfiguration Configuration for the prepass, in case prepass is activated\r\n */\r\n public static BindBonesParameters: (mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration) => void = BindBonesParameters;\r\n\r\n /**\r\n * Binds the morph targets information from the mesh to the effect.\r\n * @param abstractMesh The mesh we are binding the information to render\r\n * @param effect The effect we are binding the data to\r\n */\r\n public static BindMorphTargetParameters: (abstractMesh: AbstractMesh, effect: Effect) => void = BindMorphTargetParameters;\r\n\r\n /**\r\n * Binds the logarithmic depth information from the scene to the effect for the given defines.\r\n * @param defines The generated defines used in the effect\r\n * @param effect The effect we are binding the data to\r\n * @param scene The scene we are willing to render with logarithmic scale for\r\n */\r\n public static BindLogDepth: (defines: any, effect: Effect, scene: Scene) => void = BindLogDepth;\r\n}\r\n"]}
|
|
@@ -58,9 +58,10 @@ export class MeshoptCompression {
|
|
|
58
58
|
* @returns a Promise<Uint8Array> that resolves to the decoded data
|
|
59
59
|
*/
|
|
60
60
|
decodeGltfBufferAsync(source, count, stride, mode, filter) {
|
|
61
|
-
return this._decoderModulePromise.then(() => {
|
|
62
|
-
|
|
63
|
-
MeshoptDecoder.
|
|
61
|
+
return this._decoderModulePromise.then(async () => {
|
|
62
|
+
MeshoptDecoder.useWorkers(1);
|
|
63
|
+
const result = await MeshoptDecoder.decodeGltfBufferAsync(count, stride, source, mode, filter);
|
|
64
|
+
MeshoptDecoder.useWorkers(0);
|
|
64
65
|
return result;
|
|
65
66
|
});
|
|
66
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meshoptCompression.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/meshoptCompression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAsBzC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,kBAAkB;IAmB3B;;OAEG;IACI,MAAM,KAAK,OAAO;QACrB,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE;YAC9B,kBAAkB,CAAC,QAAQ,GAAG,IAAI,kBAAkB,EAAE,CAAC;SAC1D;QAED,OAAO,kBAAkB,CAAC,QAAQ,CAAC;IACvC,CAAC;IAED;;OAEG;IACH;QACI,MAAM,OAAO,GAAG,kBAAkB,CAAC,aAAa,CAAC,OAAO,CAAC;QAEzD,IAAI,CAAC,qBAAqB,GAAG,KAAK,CAAC,sBAAsB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YAC7E,4DAA4D;YAC5D,OAAO,cAAc,CAAC,KAAK,CAAC;QAChC,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACI,OAAO;QACV,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACtC,CAAC;IAED;;;;;;;;;OASG;IACI,qBAAqB,CAAC,MAAkB,EAAE,KAAa,EAAE,MAAc,EAAE,IAA4C,EAAE,MAAe;QACzI,OAAO,IAAI,CAAC,qBAAsB,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"meshoptCompression.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/meshoptCompression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAsBzC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,kBAAkB;IAmB3B;;OAEG;IACI,MAAM,KAAK,OAAO;QACrB,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE;YAC9B,kBAAkB,CAAC,QAAQ,GAAG,IAAI,kBAAkB,EAAE,CAAC;SAC1D;QAED,OAAO,kBAAkB,CAAC,QAAQ,CAAC;IACvC,CAAC;IAED;;OAEG;IACH;QACI,MAAM,OAAO,GAAG,kBAAkB,CAAC,aAAa,CAAC,OAAO,CAAC;QAEzD,IAAI,CAAC,qBAAqB,GAAG,KAAK,CAAC,sBAAsB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YAC7E,4DAA4D;YAC5D,OAAO,cAAc,CAAC,KAAK,CAAC;QAChC,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACI,OAAO;QACV,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACtC,CAAC;IAED;;;;;;;;;OASG;IACI,qBAAqB,CAAC,MAAkB,EAAE,KAAa,EAAE,MAAc,EAAE,IAA4C,EAAE,MAAe;QACzI,OAAO,IAAI,CAAC,qBAAsB,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;YAC/C,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC7B,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YAC/F,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC7B,OAAO,MAAM,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;;AA/DD;;;;;;;GAOG;AACW,gCAAa,GAAqC;IAC5D,OAAO,EAAE;QACL,GAAG,EAAE,GAAG,KAAK,CAAC,cAAc,qBAAqB;KACpD;CACJ,CAAC;AAEa,2BAAQ,GAAiC,IAAI,CAAC","sourcesContent":["import { Tools } from \"../../Misc/tools\";\r\nimport type { IDisposable } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let MeshoptDecoder: any;\r\n\r\n/**\r\n * Configuration for meshoptimizer compression\r\n */\r\nexport interface IMeshoptCompressionConfiguration {\r\n /**\r\n * Configuration for the decoder.\r\n */\r\n decoder: {\r\n /**\r\n * The url to the meshopt decoder library.\r\n */\r\n url: string;\r\n };\r\n}\r\n\r\n/**\r\n * Meshopt compression (https://github.com/zeux/meshoptimizer)\r\n *\r\n * This class wraps the meshopt library from https://github.com/zeux/meshoptimizer/tree/master/js.\r\n *\r\n * **Encoder**\r\n *\r\n * The encoder is not currently implemented.\r\n *\r\n * **Decoder**\r\n *\r\n * By default, the configuration points to a copy of the meshopt files on the Babylon.js preview CDN (e.g. https://preview.babylonjs.com/meshopt_decoder.js).\r\n *\r\n * To update the configuration, use the following code:\r\n * ```javascript\r\n * MeshoptCompression.Configuration = {\r\n * decoder: {\r\n * url: \"<url to the meshopt decoder library>\"\r\n * }\r\n * };\r\n * ```\r\n */\r\nexport class MeshoptCompression implements IDisposable {\r\n private _decoderModulePromise?: Promise<any>;\r\n\r\n /**\r\n * The configuration. Defaults to the following:\r\n * ```javascript\r\n * decoder: {\r\n * url: \"https://cdn.babylonjs.com/meshopt_decoder.js\"\r\n * }\r\n * ```\r\n */\r\n public static Configuration: IMeshoptCompressionConfiguration = {\r\n decoder: {\r\n url: `${Tools._DefaultCdnUrl}/meshopt_decoder.js`,\r\n },\r\n };\r\n\r\n private static _Default: Nullable<MeshoptCompression> = null;\r\n\r\n /**\r\n * Default instance for the meshoptimizer object.\r\n */\r\n public static get Default(): MeshoptCompression {\r\n if (!MeshoptCompression._Default) {\r\n MeshoptCompression._Default = new MeshoptCompression();\r\n }\r\n\r\n return MeshoptCompression._Default;\r\n }\r\n\r\n /**\r\n * Constructor\r\n */\r\n constructor() {\r\n const decoder = MeshoptCompression.Configuration.decoder;\r\n\r\n this._decoderModulePromise = Tools.LoadBabylonScriptAsync(decoder.url).then(() => {\r\n // Wait for WebAssembly compilation before resolving promise\r\n return MeshoptDecoder.ready;\r\n });\r\n }\r\n\r\n /**\r\n * Stop all async operations and release resources.\r\n */\r\n public dispose(): void {\r\n delete this._decoderModulePromise;\r\n }\r\n\r\n /**\r\n * Decode meshopt data.\r\n * @see https://github.com/zeux/meshoptimizer/tree/master/js#decoder\r\n * @param source The input data.\r\n * @param count The number of elements.\r\n * @param stride The stride in bytes.\r\n * @param mode The compression mode.\r\n * @param filter The compression filter.\r\n * @returns a Promise<Uint8Array> that resolves to the decoded data\r\n */\r\n public decodeGltfBufferAsync(source: Uint8Array, count: number, stride: number, mode: \"ATTRIBUTES\" | \"TRIANGLES\" | \"INDICES\", filter?: string): Promise<Uint8Array> {\r\n return this._decoderModulePromise!.then(async () => {\r\n MeshoptDecoder.useWorkers(1);\r\n const result = await MeshoptDecoder.decodeGltfBufferAsync(count, stride, source, mode, filter);\r\n MeshoptDecoder.useWorkers(0);\r\n return result;\r\n });\r\n }\r\n}\r\n"]}
|
package/Misc/filesInput.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AbstractEngine } from "../Engines/abstractEngine";
|
|
2
2
|
import type { Scene } from "../scene";
|
|
3
3
|
import type { ISceneLoaderProgressEvent } from "../Loading/sceneLoader";
|
|
4
4
|
import type { Nullable } from "../types";
|
|
@@ -54,7 +54,7 @@ export declare class FilesInput {
|
|
|
54
54
|
* @param errorCallback callback call if an error occurs
|
|
55
55
|
* @param useAppend defines if the file loaded must be appended (true) or have the scene replaced (false, default behavior)
|
|
56
56
|
*/
|
|
57
|
-
constructor(engine:
|
|
57
|
+
constructor(engine: AbstractEngine, scene: Nullable<Scene>, sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>, progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>, additionalRenderLoopLogicCallback: Nullable<() => void>, textureLoadingCallback: Nullable<(remaining: number) => void>, startingProcessingFilesCallback: Nullable<(files?: File[]) => void>, onReloadCallback: Nullable<(sceneFile: File) => void>, errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>, useAppend?: boolean);
|
|
58
58
|
private _dragEnterHandler;
|
|
59
59
|
private _dragOverHandler;
|
|
60
60
|
private _dropHandler;
|
package/Misc/filesInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesInput.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/filesInput.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM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,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;iBACxE;YACL,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACb,IAAI,IAAI,CAAC,gBAAgB,EAAE;oBACvB,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;iBAChC;gBACD,IAAI,IAAI,CAAC,cAAc,EAAE;oBACrB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;iBACjF;YACL,CAAC,CAAC,CAAC;SACV;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;SACzD;IACL,CAAC;CACJ","sourcesContent":["import type { Engine } from \"../Engines/engine\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { ISceneLoaderProgressEvent } from \"../Loading/sceneLoader\";\r\nimport { SceneLoader } from \"../Loading/sceneLoader\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { FilesInputStore } from \"./filesInputStore\";\r\nimport type { Nullable } from \"../types\";\r\n\r\n/**\r\n * Class used to help managing file picking and drag-n-drop\r\n */\r\nexport class FilesInput {\r\n /**\r\n * List of files ready to be loaded\r\n */\r\n public static get FilesToLoad() {\r\n return FilesInputStore.FilesToLoad;\r\n }\r\n\r\n /**\r\n * Callback called when a file is processed\r\n * @returns false to abort the process\r\n */\r\n public onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean = () => {\r\n return true;\r\n };\r\n\r\n /**\r\n * If a loading UI should be displayed while loading a file\r\n */\r\n public displayLoadingUI: boolean = true;\r\n\r\n /**\r\n * Function used when loading the scene file\r\n * @param sceneFile defines the file to load\r\n * @param onProgress onProgress callback called while loading the file\r\n * @returns a promise completing when the load is complete\r\n */\r\n public loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene> = (sceneFile, onProgress) =>\r\n this.useAppend ? SceneLoader.AppendAsync(\"file:\", sceneFile, this._currentScene, onProgress) : SceneLoader.LoadAsync(\"file:\", sceneFile, this._engine, onProgress);\r\n\r\n private _engine: Engine;\r\n private _currentScene: Nullable<Scene>;\r\n private _sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>;\r\n private _progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>;\r\n private _additionalRenderLoopLogicCallback: Nullable<() => void>;\r\n private _textureLoadingCallback: Nullable<(remaining: number) => void>;\r\n private _startingProcessingFilesCallback: Nullable<(files?: File[]) => void>;\r\n private _onReloadCallback: Nullable<(sceneFile: File) => void>;\r\n private _errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>;\r\n private _elementToMonitor: HTMLElement;\r\n\r\n private _sceneFileToLoad: File;\r\n private _filesToLoad: File[];\r\n\r\n /**\r\n * Creates a new FilesInput\r\n * @param engine defines the rendering engine\r\n * @param scene defines the hosting scene\r\n * @param sceneLoadedCallback callback called when scene (files provided) is loaded\r\n * @param progressCallback callback called to track progress\r\n * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop\r\n * @param textureLoadingCallback callback called when a texture is loading\r\n * @param startingProcessingFilesCallback callback called when the system is about to process all files\r\n * @param onReloadCallback callback called when a reload is requested\r\n * @param errorCallback callback call if an error occurs\r\n * @param useAppend defines if the file loaded must be appended (true) or have the scene replaced (false, default behavior)\r\n */\r\n constructor(\r\n engine: Engine,\r\n scene: Nullable<Scene>,\r\n sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>,\r\n progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>,\r\n additionalRenderLoopLogicCallback: Nullable<() => void>,\r\n textureLoadingCallback: Nullable<(remaining: number) => void>,\r\n startingProcessingFilesCallback: Nullable<(files?: File[]) => void>,\r\n onReloadCallback: Nullable<(sceneFile: File) => void>,\r\n errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>,\r\n public readonly useAppend = false\r\n ) {\r\n this._engine = engine;\r\n this._currentScene = scene;\r\n\r\n this._sceneLoadedCallback = sceneLoadedCallback;\r\n this._progressCallback = progressCallback;\r\n this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;\r\n this._textureLoadingCallback = textureLoadingCallback;\r\n this._startingProcessingFilesCallback = startingProcessingFilesCallback;\r\n this._onReloadCallback = onReloadCallback;\r\n this._errorCallback = errorCallback;\r\n }\r\n\r\n private _dragEnterHandler: (e: any) => void;\r\n private _dragOverHandler: (e: any) => void;\r\n private _dropHandler: (e: any) => void;\r\n\r\n /**\r\n * Calls this function to listen to drag'n'drop events on a specific DOM element\r\n * @param elementToMonitor defines the DOM element to track\r\n */\r\n public monitorElementForDragNDrop(elementToMonitor: HTMLElement): void {\r\n if (elementToMonitor) {\r\n this._elementToMonitor = elementToMonitor;\r\n\r\n this._dragEnterHandler = (e) => {\r\n this._drag(e);\r\n };\r\n this._dragOverHandler = (e) => {\r\n this._drag(e);\r\n };\r\n this._dropHandler = (e) => {\r\n this._drop(e);\r\n };\r\n\r\n this._elementToMonitor.addEventListener(\"dragenter\", this._dragEnterHandler, false);\r\n this._elementToMonitor.addEventListener(\"dragover\", this._dragOverHandler, false);\r\n this._elementToMonitor.addEventListener(\"drop\", this._dropHandler, false);\r\n }\r\n }\r\n\r\n /** Gets the current list of files to load */\r\n public get filesToLoad() {\r\n return this._filesToLoad;\r\n }\r\n\r\n /**\r\n * Release all associated resources\r\n */\r\n public dispose() {\r\n if (!this._elementToMonitor) {\r\n return;\r\n }\r\n\r\n this._elementToMonitor.removeEventListener(\"dragenter\", this._dragEnterHandler);\r\n this._elementToMonitor.removeEventListener(\"dragover\", this._dragOverHandler);\r\n this._elementToMonitor.removeEventListener(\"drop\", this._dropHandler);\r\n }\r\n\r\n private _renderFunction(): void {\r\n if (this._additionalRenderLoopLogicCallback) {\r\n this._additionalRenderLoopLogicCallback();\r\n }\r\n\r\n if (this._currentScene) {\r\n if (this._textureLoadingCallback) {\r\n const remaining = this._currentScene.getWaitingItemsCount();\r\n\r\n if (remaining > 0) {\r\n this._textureLoadingCallback(remaining);\r\n }\r\n }\r\n this._currentScene.render();\r\n }\r\n }\r\n\r\n private _drag(e: DragEvent): void {\r\n e.stopPropagation();\r\n e.preventDefault();\r\n }\r\n\r\n private _drop(eventDrop: DragEvent): void {\r\n eventDrop.stopPropagation();\r\n eventDrop.preventDefault();\r\n\r\n this.loadFiles(eventDrop);\r\n }\r\n\r\n private _traverseFolder(folder: any, files: Array<any>, remaining: { count: number }, callback: () => void) {\r\n const reader = folder.createReader();\r\n const relativePath = folder.fullPath.replace(/^\\//, \"\").replace(/(.+?)\\/?$/, \"$1/\");\r\n reader.readEntries((entries: any) => {\r\n remaining.count += entries.length;\r\n for (const entry of entries) {\r\n if (entry.isFile) {\r\n entry.file((file: any) => {\r\n file.correctName = relativePath + file.name;\r\n files.push(file);\r\n\r\n if (--remaining.count === 0) {\r\n callback();\r\n }\r\n });\r\n } else if (entry.isDirectory) {\r\n this._traverseFolder(entry, files, remaining, callback);\r\n }\r\n }\r\n\r\n if (--remaining.count === 0) {\r\n callback();\r\n }\r\n });\r\n }\r\n\r\n private _processFiles(files: Array<any>): void {\r\n for (let i = 0; i < files.length; i++) {\r\n const name = files[i].correctName.toLowerCase();\r\n const extension = name.split(\".\").pop();\r\n\r\n if (!this.onProcessFileCallback(files[i], name, extension, (sceneFile) => (this._sceneFileToLoad = sceneFile))) {\r\n continue;\r\n }\r\n\r\n if (SceneLoader.IsPluginForExtensionAvailable(\".\" + extension)) {\r\n this._sceneFileToLoad = files[i];\r\n }\r\n\r\n FilesInput.FilesToLoad[name] = files[i];\r\n }\r\n }\r\n\r\n /**\r\n * Load files from a drop event\r\n * @param event defines the drop event to use as source\r\n */\r\n public loadFiles(event: any): void {\r\n // Handling data transfer via drag'n'drop\r\n if (event && event.dataTransfer && event.dataTransfer.files) {\r\n this._filesToLoad = event.dataTransfer.files;\r\n }\r\n\r\n // Handling files from input files\r\n if (event && event.target && event.target.files) {\r\n this._filesToLoad = event.target.files;\r\n }\r\n\r\n if (!this._filesToLoad || this._filesToLoad.length === 0) {\r\n return;\r\n }\r\n\r\n if (this._startingProcessingFilesCallback) {\r\n this._startingProcessingFilesCallback(this._filesToLoad);\r\n }\r\n\r\n if (this._filesToLoad && this._filesToLoad.length > 0) {\r\n const files: File[] = [];\r\n const folders = [];\r\n const items = event.dataTransfer ? event.dataTransfer.items : null;\r\n\r\n for (let i = 0; i < this._filesToLoad.length; i++) {\r\n const fileToLoad: any = this._filesToLoad[i];\r\n const name = fileToLoad.name.toLowerCase();\r\n let entry;\r\n\r\n fileToLoad.correctName = name;\r\n\r\n if (items) {\r\n const item = items[i];\r\n if (item.getAsEntry) {\r\n entry = item.getAsEntry();\r\n } else if (item.webkitGetAsEntry) {\r\n entry = item.webkitGetAsEntry();\r\n }\r\n }\r\n\r\n if (!entry) {\r\n files.push(fileToLoad);\r\n } else {\r\n if (entry.isDirectory) {\r\n folders.push(entry);\r\n } else {\r\n files.push(fileToLoad);\r\n }\r\n }\r\n }\r\n\r\n if (folders.length === 0) {\r\n this._processFiles(files);\r\n this._processReload();\r\n } else {\r\n const remaining = { count: folders.length };\r\n for (const folder of folders) {\r\n this._traverseFolder(folder, files, remaining, () => {\r\n this._processFiles(files);\r\n\r\n if (remaining.count === 0) {\r\n this._processReload();\r\n }\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _processReload() {\r\n if (this._onReloadCallback) {\r\n this._onReloadCallback(this._sceneFileToLoad);\r\n } else {\r\n this.reload();\r\n }\r\n }\r\n\r\n /**\r\n * Reload the current scene from the loaded files\r\n */\r\n public reload() {\r\n // If a scene file has been provided\r\n if (this._sceneFileToLoad) {\r\n if (!this.useAppend) {\r\n if (this._currentScene) {\r\n if (Logger.errorsCount > 0) {\r\n Logger.ClearLogCache();\r\n }\r\n this._engine.stopRenderLoop();\r\n }\r\n }\r\n\r\n SceneLoader.ShowLoadingScreen = false;\r\n if (this.displayLoadingUI) {\r\n this._engine.displayLoadingUI();\r\n }\r\n\r\n this.loadAsync(this._sceneFileToLoad, this._progressCallback)\r\n .then((scene) => {\r\n // if appending do nothing\r\n if (!this.useAppend) {\r\n if (this._currentScene) {\r\n this._currentScene.dispose();\r\n }\r\n\r\n this._currentScene = scene;\r\n\r\n // Wait for textures and shaders to be ready\r\n this._currentScene.executeWhenReady(() => {\r\n if (this.displayLoadingUI) {\r\n this._engine.hideLoadingUI();\r\n }\r\n this._engine.runRenderLoop(() => {\r\n this._renderFunction();\r\n });\r\n });\r\n } else {\r\n if (this.displayLoadingUI) {\r\n this._engine.hideLoadingUI();\r\n }\r\n }\r\n if (this._sceneLoadedCallback && this._currentScene) {\r\n this._sceneLoadedCallback(this._sceneFileToLoad, this._currentScene);\r\n }\r\n })\r\n .catch((error) => {\r\n if (this.displayLoadingUI) {\r\n this._engine.hideLoadingUI();\r\n }\r\n if (this._errorCallback) {\r\n this._errorCallback(this._sceneFileToLoad, this._currentScene, error.message);\r\n }\r\n });\r\n } else {\r\n Logger.Error(\"Please provide a valid .babylon file.\");\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"filesInput.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/filesInput.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;GAEG;AACH,MAAM,OAAO,UAAU;IACnB;;OAEG;IACI,MAAM,KAAK,WAAW;QACzB,OAAO,eAAe,CAAC,WAAW,CAAC;IACvC,CAAC;IAsCD;;;;;;;;;;;;OAYG;IACH,YACI,MAAsB,EACtB,KAAsB,EACtB,mBAAsE,EACtE,gBAAyE,EACzE,iCAAuD,EACvD,sBAA6D,EAC7D,+BAAmE,EACn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CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;iBACjF;YACL,CAAC,CAAC,CAAC;SACV;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;SACzD;IACL,CAAC;CACJ","sourcesContent":["import type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { ISceneLoaderProgressEvent } from \"../Loading/sceneLoader\";\r\nimport { SceneLoader } from \"../Loading/sceneLoader\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { FilesInputStore } from \"./filesInputStore\";\r\nimport type { Nullable } from \"../types\";\r\n\r\n/**\r\n * Class used to help managing file picking and drag-n-drop\r\n */\r\nexport class FilesInput {\r\n /**\r\n * List of files ready to be loaded\r\n */\r\n public static get FilesToLoad() {\r\n return FilesInputStore.FilesToLoad;\r\n }\r\n\r\n /**\r\n * Callback called when a file is processed\r\n * @returns false to abort the process\r\n */\r\n public onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean = () => {\r\n return true;\r\n };\r\n\r\n /**\r\n * If a loading UI should be displayed while loading a file\r\n */\r\n public displayLoadingUI: boolean = true;\r\n\r\n /**\r\n * Function used when loading the scene file\r\n * @param sceneFile defines the file to load\r\n * @param onProgress onProgress callback called while loading the file\r\n * @returns a promise completing when the load is complete\r\n */\r\n public loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene> = (sceneFile, onProgress) =>\r\n this.useAppend ? SceneLoader.AppendAsync(\"file:\", sceneFile, this._currentScene, onProgress) : SceneLoader.LoadAsync(\"file:\", sceneFile, this._engine, onProgress);\r\n\r\n private _engine: AbstractEngine;\r\n private _currentScene: Nullable<Scene>;\r\n private _sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>;\r\n private _progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>;\r\n private _additionalRenderLoopLogicCallback: Nullable<() => void>;\r\n private _textureLoadingCallback: Nullable<(remaining: number) => void>;\r\n private _startingProcessingFilesCallback: Nullable<(files?: File[]) => void>;\r\n private _onReloadCallback: Nullable<(sceneFile: File) => void>;\r\n private _errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>;\r\n private _elementToMonitor: HTMLElement;\r\n\r\n private _sceneFileToLoad: File;\r\n private _filesToLoad: File[];\r\n\r\n /**\r\n * Creates a new FilesInput\r\n * @param engine defines the rendering engine\r\n * @param scene defines the hosting scene\r\n * @param sceneLoadedCallback callback called when scene (files provided) is loaded\r\n * @param progressCallback callback called to track progress\r\n * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop\r\n * @param textureLoadingCallback callback called when a texture is loading\r\n * @param startingProcessingFilesCallback callback called when the system is about to process all files\r\n * @param onReloadCallback callback called when a reload is requested\r\n * @param errorCallback callback call if an error occurs\r\n * @param useAppend defines if the file loaded must be appended (true) or have the scene replaced (false, default behavior)\r\n */\r\n constructor(\r\n engine: AbstractEngine,\r\n scene: Nullable<Scene>,\r\n sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>,\r\n progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>,\r\n additionalRenderLoopLogicCallback: Nullable<() => void>,\r\n textureLoadingCallback: Nullable<(remaining: number) => void>,\r\n startingProcessingFilesCallback: Nullable<(files?: File[]) => void>,\r\n onReloadCallback: Nullable<(sceneFile: File) => void>,\r\n errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>,\r\n public readonly useAppend = false\r\n ) {\r\n this._engine = engine;\r\n this._currentScene = scene;\r\n\r\n this._sceneLoadedCallback = sceneLoadedCallback;\r\n this._progressCallback = progressCallback;\r\n this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;\r\n this._textureLoadingCallback = textureLoadingCallback;\r\n this._startingProcessingFilesCallback = startingProcessingFilesCallback;\r\n this._onReloadCallback = onReloadCallback;\r\n this._errorCallback = errorCallback;\r\n }\r\n\r\n private _dragEnterHandler: (e: any) => void;\r\n private _dragOverHandler: (e: any) => void;\r\n private _dropHandler: (e: any) => void;\r\n\r\n /**\r\n * Calls this function to listen to drag'n'drop events on a specific DOM element\r\n * @param elementToMonitor defines the DOM element to track\r\n */\r\n public monitorElementForDragNDrop(elementToMonitor: HTMLElement): void {\r\n if (elementToMonitor) {\r\n this._elementToMonitor = elementToMonitor;\r\n\r\n this._dragEnterHandler = (e) => {\r\n this._drag(e);\r\n };\r\n this._dragOverHandler = (e) => {\r\n this._drag(e);\r\n };\r\n this._dropHandler = (e) => {\r\n this._drop(e);\r\n };\r\n\r\n this._elementToMonitor.addEventListener(\"dragenter\", this._dragEnterHandler, false);\r\n this._elementToMonitor.addEventListener(\"dragover\", this._dragOverHandler, false);\r\n this._elementToMonitor.addEventListener(\"drop\", this._dropHandler, false);\r\n }\r\n }\r\n\r\n /** Gets the current list of files to load */\r\n public get filesToLoad() {\r\n return this._filesToLoad;\r\n }\r\n\r\n /**\r\n * Release all associated resources\r\n */\r\n public dispose() {\r\n if (!this._elementToMonitor) {\r\n return;\r\n }\r\n\r\n this._elementToMonitor.removeEventListener(\"dragenter\", this._dragEnterHandler);\r\n this._elementToMonitor.removeEventListener(\"dragover\", this._dragOverHandler);\r\n this._elementToMonitor.removeEventListener(\"drop\", this._dropHandler);\r\n }\r\n\r\n private _renderFunction(): void {\r\n if (this._additionalRenderLoopLogicCallback) {\r\n this._additionalRenderLoopLogicCallback();\r\n }\r\n\r\n if (this._currentScene) {\r\n if (this._textureLoadingCallback) {\r\n const remaining = this._currentScene.getWaitingItemsCount();\r\n\r\n if (remaining > 0) {\r\n this._textureLoadingCallback(remaining);\r\n }\r\n }\r\n this._currentScene.render();\r\n }\r\n }\r\n\r\n private _drag(e: DragEvent): void {\r\n e.stopPropagation();\r\n e.preventDefault();\r\n }\r\n\r\n private _drop(eventDrop: DragEvent): void {\r\n eventDrop.stopPropagation();\r\n eventDrop.preventDefault();\r\n\r\n this.loadFiles(eventDrop);\r\n }\r\n\r\n private _traverseFolder(folder: any, files: Array<any>, remaining: { count: number }, callback: () => void) {\r\n const reader = folder.createReader();\r\n const relativePath = folder.fullPath.replace(/^\\//, \"\").replace(/(.+?)\\/?$/, \"$1/\");\r\n reader.readEntries((entries: any) => {\r\n remaining.count += entries.length;\r\n for (const entry of entries) {\r\n if (entry.isFile) {\r\n entry.file((file: any) => {\r\n file.correctName = relativePath + file.name;\r\n files.push(file);\r\n\r\n if (--remaining.count === 0) {\r\n callback();\r\n }\r\n });\r\n } else if (entry.isDirectory) {\r\n this._traverseFolder(entry, files, remaining, callback);\r\n }\r\n }\r\n\r\n if (--remaining.count === 0) {\r\n callback();\r\n }\r\n });\r\n }\r\n\r\n private _processFiles(files: Array<any>): void {\r\n for (let i = 0; i < files.length; i++) {\r\n const name = files[i].correctName.toLowerCase();\r\n const extension = name.split(\".\").pop();\r\n\r\n if (!this.onProcessFileCallback(files[i], name, extension, (sceneFile) => (this._sceneFileToLoad = sceneFile))) {\r\n continue;\r\n }\r\n\r\n if (SceneLoader.IsPluginForExtensionAvailable(\".\" + extension)) {\r\n this._sceneFileToLoad = files[i];\r\n }\r\n\r\n FilesInput.FilesToLoad[name] = files[i];\r\n }\r\n }\r\n\r\n /**\r\n * Load files from a drop event\r\n * @param event defines the drop event to use as source\r\n */\r\n public loadFiles(event: any): void {\r\n // Handling data transfer via drag'n'drop\r\n if (event && event.dataTransfer && event.dataTransfer.files) {\r\n this._filesToLoad = event.dataTransfer.files;\r\n }\r\n\r\n // Handling files from input files\r\n if (event && event.target && event.target.files) {\r\n this._filesToLoad = event.target.files;\r\n }\r\n\r\n if (!this._filesToLoad || this._filesToLoad.length === 0) {\r\n return;\r\n }\r\n\r\n if (this._startingProcessingFilesCallback) {\r\n this._startingProcessingFilesCallback(this._filesToLoad);\r\n }\r\n\r\n if (this._filesToLoad && this._filesToLoad.length > 0) {\r\n const files: File[] = [];\r\n const folders = [];\r\n const items = event.dataTransfer ? event.dataTransfer.items : null;\r\n\r\n for (let i = 0; i < this._filesToLoad.length; i++) {\r\n const fileToLoad: any = this._filesToLoad[i];\r\n const name = fileToLoad.name.toLowerCase();\r\n let entry;\r\n\r\n fileToLoad.correctName = name;\r\n\r\n if (items) {\r\n const item = items[i];\r\n if (item.getAsEntry) {\r\n entry = item.getAsEntry();\r\n } else if (item.webkitGetAsEntry) {\r\n entry = item.webkitGetAsEntry();\r\n }\r\n }\r\n\r\n if (!entry) {\r\n files.push(fileToLoad);\r\n } else {\r\n if (entry.isDirectory) {\r\n folders.push(entry);\r\n } else {\r\n files.push(fileToLoad);\r\n }\r\n }\r\n }\r\n\r\n if (folders.length === 0) {\r\n this._processFiles(files);\r\n this._processReload();\r\n } else {\r\n const remaining = { count: folders.length };\r\n for (const folder of folders) {\r\n this._traverseFolder(folder, files, remaining, () => {\r\n this._processFiles(files);\r\n\r\n if (remaining.count === 0) {\r\n this._processReload();\r\n }\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _processReload() {\r\n if (this._onReloadCallback) {\r\n this._onReloadCallback(this._sceneFileToLoad);\r\n } else {\r\n this.reload();\r\n }\r\n }\r\n\r\n /**\r\n * Reload the current scene from the loaded files\r\n */\r\n public reload() {\r\n // If a scene file has been provided\r\n if (this._sceneFileToLoad) {\r\n if (!this.useAppend) {\r\n if (this._currentScene) {\r\n if (Logger.errorsCount > 0) {\r\n Logger.ClearLogCache();\r\n }\r\n this._engine.stopRenderLoop();\r\n }\r\n }\r\n\r\n SceneLoader.ShowLoadingScreen = false;\r\n if (this.displayLoadingUI) {\r\n this._engine.displayLoadingUI();\r\n }\r\n\r\n this.loadAsync(this._sceneFileToLoad, this._progressCallback)\r\n .then((scene) => {\r\n // if appending do nothing\r\n if (!this.useAppend) {\r\n if (this._currentScene) {\r\n this._currentScene.dispose();\r\n }\r\n\r\n this._currentScene = scene;\r\n\r\n // Wait for textures and shaders to be ready\r\n this._currentScene.executeWhenReady(() => {\r\n if (this.displayLoadingUI) {\r\n this._engine.hideLoadingUI();\r\n }\r\n this._engine.runRenderLoop(() => {\r\n this._renderFunction();\r\n });\r\n });\r\n } else {\r\n if (this.displayLoadingUI) {\r\n this._engine.hideLoadingUI();\r\n }\r\n }\r\n if (this._sceneLoadedCallback && this._currentScene) {\r\n this._sceneLoadedCallback(this._sceneFileToLoad, this._currentScene);\r\n }\r\n })\r\n .catch((error) => {\r\n if (this.displayLoadingUI) {\r\n this._engine.hideLoadingUI();\r\n }\r\n if (this._errorCallback) {\r\n this._errorCallback(this._sceneFileToLoad, this._currentScene, error.message);\r\n }\r\n });\r\n } else {\r\n Logger.Error(\"Please provide a valid .babylon file.\");\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Camera } from "../Cameras/camera";
|
|
2
2
|
import { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture";
|
|
3
3
|
import type { IScreenshotSize } from "./interfaces/screenshotSize";
|
|
4
|
-
import type {
|
|
4
|
+
import type { AbstractEngine } from "../Engines/abstractEngine";
|
|
5
5
|
/**
|
|
6
6
|
* Captures a screenshot of the current rendering
|
|
7
7
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG
|
|
@@ -20,7 +20,7 @@ import type { Engine } from "../Engines/engine";
|
|
|
20
20
|
* @param forceDownload force the system to download the image even if a successCallback is provided
|
|
21
21
|
* @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.
|
|
22
22
|
*/
|
|
23
|
-
export declare function CreateScreenshot(engine:
|
|
23
|
+
export declare function CreateScreenshot(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean, quality?: number): void;
|
|
24
24
|
/**
|
|
25
25
|
* Captures a screenshot of the current rendering
|
|
26
26
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG
|
|
@@ -37,7 +37,7 @@ export declare function CreateScreenshot(engine: Engine, camera: Camera, size: I
|
|
|
37
37
|
* @returns screenshot as a string of base64-encoded characters. This string can be assigned
|
|
38
38
|
* to the src parameter of an <img> to display it
|
|
39
39
|
*/
|
|
40
|
-
export declare function CreateScreenshotAsync(engine:
|
|
40
|
+
export declare function CreateScreenshotAsync(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, quality?: number): Promise<string>;
|
|
41
41
|
/**
|
|
42
42
|
* Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)
|
|
43
43
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG
|
|
@@ -51,7 +51,7 @@ export declare function CreateScreenshotAsync(engine: Engine, camera: Camera, si
|
|
|
51
51
|
* @returns screenshot as a string of base64-encoded characters. This string can be assigned
|
|
52
52
|
* to the src parameter of an <img> to display it
|
|
53
53
|
*/
|
|
54
|
-
export declare function CreateScreenshotWithResizeAsync(engine:
|
|
54
|
+
export declare function CreateScreenshotWithResizeAsync(engine: AbstractEngine, camera: Camera, width: number, height: number, mimeType?: string, quality?: number): Promise<void>;
|
|
55
55
|
/**
|
|
56
56
|
* Generates an image screenshot from the specified camera.
|
|
57
57
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG
|
|
@@ -76,7 +76,7 @@ export declare function CreateScreenshotWithResizeAsync(engine: Engine, camera:
|
|
|
76
76
|
* @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.
|
|
77
77
|
* @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.
|
|
78
78
|
*/
|
|
79
|
-
export declare function CreateScreenshotUsingRenderTarget(engine:
|
|
79
|
+
export declare function CreateScreenshotUsingRenderTarget(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean, useLayerMask?: boolean, quality?: number, customizeTexture?: (texture: RenderTargetTexture) => void): void;
|
|
80
80
|
/**
|
|
81
81
|
* Generates an image screenshot from the specified camera.
|
|
82
82
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG
|
|
@@ -99,7 +99,7 @@ export declare function CreateScreenshotUsingRenderTarget(engine: Engine, camera
|
|
|
99
99
|
* @returns screenshot as a string of base64-encoded characters. This string can be assigned
|
|
100
100
|
* to the src parameter of an <img> to display it
|
|
101
101
|
*/
|
|
102
|
-
export declare function CreateScreenshotUsingRenderTargetAsync(engine:
|
|
102
|
+
export declare function CreateScreenshotUsingRenderTargetAsync(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean, useLayerMask?: boolean, quality?: number): Promise<string>;
|
|
103
103
|
/**
|
|
104
104
|
* Class containing a set of static utilities functions for screenshots
|
|
105
105
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/screenshotTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AA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AAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACpD,KAAK,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\nimport { DumpTools } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\nlet screenshotCanvas: Nullable<HTMLCanvasElement> = null;\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\nexport function CreateScreenshot(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n forceDownload = false,\r\n quality?: number\r\n): void {\r\n const { height, width } = _GetScreenshotSize(engine, camera, size);\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n if (!screenshotCanvas) {\r\n screenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n\r\n screenshotCanvas.width = width;\r\n screenshotCanvas.height = height;\r\n\r\n const renderContext = screenshotCanvas.getContext(\"2d\");\r\n\r\n const ratio = engine.getRenderWidth() / engine.getRenderHeight();\r\n let newWidth = width;\r\n let newHeight = newWidth / ratio;\r\n if (newHeight > height) {\r\n newHeight = height;\r\n newWidth = newHeight * ratio;\r\n }\r\n\r\n const offsetX = Math.max(0, width - newWidth) / 2;\r\n const offsetY = Math.max(0, height - newHeight) / 2;\r\n\r\n const scene = camera.getScene();\r\n if (scene.activeCamera !== camera) {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (forceDownload) {\r\n const blob = new Blob([data]);\r\n Tools.DownloadBlob(blob);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else if (successCallback) {\r\n successCallback(data);\r\n }\r\n },\r\n mimeType,\r\n 1.0,\r\n engine.getCreationOptions().antialias,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n quality\r\n );\r\n } else {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (renderContext && renderingCanvas) {\r\n renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);\r\n }\r\n\r\n if (screenshotCanvas) {\r\n if (forceDownload) {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, undefined, mimeType, undefined, quality);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, successCallback, mimeType, undefined, quality);\r\n }\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType = \"image/png\", quality?: number): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n undefined,\r\n quality\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType = \"image/png\", quality?: number): Promise<void> {\r\n return new Promise((resolve) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n { width: width, height: height },\r\n () => {\r\n resolve();\r\n },\r\n mimeType,\r\n true,\r\n quality\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height, finalWidth, finalHeight. If a single number is passed,\r\n * it will be used for both width and height, as well as finalWidth, finalHeight. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void\r\n): void {\r\n const { height, width, finalWidth, finalHeight } = _GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n const originalSize = { width: engine.getRenderWidth(), height: engine.getRenderHeight() };\r\n engine.setSize(width, height); // we need this call to trigger onResizeObservable with the screenshot width/height on all the subsystems that are observing this event and that needs to (re)create some resources with the right dimensions\r\n\r\n const scene = camera.getScene();\r\n\r\n // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)\r\n const texture = new RenderTargetTexture(\r\n \"screenShot\",\r\n targetTextureSize,\r\n scene,\r\n false,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT,\r\n false,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = scene.meshes.slice();\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n texture.activeCamera = camera;\r\n texture.forceLayerMaskCheck = useLayerMask;\r\n customizeTexture?.(texture);\r\n\r\n const renderWhenReady = () => {\r\n if (texture.isReadyForRendering() && camera.isReady(true)) {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (finalWidth === width && finalHeight === height) {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n DumpTools.DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n texture.dispose();\r\n });\r\n } else {\r\n ApplyPostProcess(\"pass\", texture.getInternalTexture()!, scene, undefined, undefined, undefined, finalWidth, finalHeight).then((texture) => {\r\n engine._readTexturePixels(texture, finalWidth, finalHeight, -1, 0, null, true, false, 0, 0).then((data) => {\r\n DumpTools.DumpData(\r\n finalWidth,\r\n finalHeight,\r\n data,\r\n successCallback as (data: string | ArrayBuffer) => void,\r\n mimeType,\r\n fileName,\r\n true,\r\n undefined,\r\n quality\r\n );\r\n texture.dispose();\r\n });\r\n });\r\n }\r\n });\r\n\r\n texture.render(true);\r\n\r\n // re-render the scene after the camera has been reset to the original camera to avoid a flicker that could occur\r\n // if the camera used for the RTT rendering stays in effect for the next frame (and if that camera was different from the original camera)\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n engine.setSize(originalSize.width, originalSize.height);\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n scene.render();\r\n } else {\r\n setTimeout(renderWhenReady, 16);\r\n }\r\n };\r\n\r\n const renderToTexture = () => {\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n renderWhenReady();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n if (!fxaaPostProcess.getEffect().isReady()) {\r\n fxaaPostProcess.getEffect().onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotUsingRenderTargetAsync(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites,\r\n enableStencilBuffer,\r\n useLayerMask,\r\n quality\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\r\n * @param engine\r\n * @param camera\r\n * @param size\r\n * @private\r\n */\r\nfunction _GetScreenshotSize(engine: Engine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number; finalWidth: number; finalHeight: number } {\r\n let height = 0;\r\n let width = 0;\r\n let finalWidth = 0;\r\n let finalHeight = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n\r\n //If a finalWidth and finalHeight values is specified\r\n if (size.finalWidth && size.finalHeight) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = size.finalWidth;\r\n }\r\n //If passing only finalWidth, computing finalHeight to keep display canvas ratio.\r\n else if (size.finalWidth && !size.finalHeight) {\r\n finalWidth = size.finalWidth;\r\n finalHeight = Math.round(finalWidth / engine.getAspectRatio(camera));\r\n }\r\n //If passing only finalHeight, computing finalWidth to keep display canvas ratio.\r\n else if (size.finalHeight && !size.finalWidth) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = Math.round(finalHeight * engine.getAspectRatio(camera));\r\n } else {\r\n finalWidth = width;\r\n finalHeight = height;\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n finalWidth = size;\r\n finalHeight = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n if (finalWidth) {\r\n finalWidth = Math.floor(finalWidth);\r\n }\r\n if (finalHeight) {\r\n finalHeight = Math.floor(finalHeight);\r\n }\r\n\r\n return { height: height | 0, width: width | 0, finalWidth: finalWidth | 0, finalHeight: finalHeight | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n CreateScreenshot,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotAsync,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotWithResizeAsync,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n CreateScreenshotUsingRenderTarget,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotUsingRenderTargetAsync,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.CreateScreenshot = CreateScreenshot;\r\n Tools.CreateScreenshotAsync = CreateScreenshotAsync;\r\n Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget;\r\n Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
|
|
1
|
+
{"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/screenshotTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIlD,IAAI,gBAAgB,GAAgC,IAAI,CAAC;AAEzD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAsB,EACtB,MAAc,EACd,IAA8B,EAC9B,eAAwC,EACxC,QAAQ,GAAG,WAAW,EACtB,aAAa,GAAG,KAAK,EACrB,OAAgB;IAEhB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAEnE,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE;QACpB,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC3C,OAAO;KACV;IAED,IAAI,CAAC,gBAAgB,EAAE;QACnB,gBAAgB,GAAG,QAAQ,C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AAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;KACvC;IACD,IAAI,WAAW,EAAE;QACb,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;KACzC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,UAAU,EAAE,UAAU,GAAG,CAAC,EAAE,WAAW,EAAE,WAAW,GAAG,CAAC,EAAE,CAAC;AAC9G,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B;;;;;;;;;;;;;;;;;OAiBG;IACH,gBAAgB;IAEhB;;;;;;;;;;;;;;;OAeG;IACH,qBAAqB;IAErB;;;;;;;;;;;;OAYG;IACH,+BAA+B;IAE/B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,iCAAiC;IAEjC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,sCAAsC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACpD,KAAK,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\nimport { DumpTools } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\n\r\nlet screenshotCanvas: Nullable<HTMLCanvasElement> = null;\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\nexport function CreateScreenshot(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n forceDownload = false,\r\n quality?: number\r\n): void {\r\n const { height, width } = _GetScreenshotSize(engine, camera, size);\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n if (!screenshotCanvas) {\r\n screenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n\r\n screenshotCanvas.width = width;\r\n screenshotCanvas.height = height;\r\n\r\n const renderContext = screenshotCanvas.getContext(\"2d\");\r\n\r\n const ratio = engine.getRenderWidth() / engine.getRenderHeight();\r\n let newWidth = width;\r\n let newHeight = newWidth / ratio;\r\n if (newHeight > height) {\r\n newHeight = height;\r\n newWidth = newHeight * ratio;\r\n }\r\n\r\n const offsetX = Math.max(0, width - newWidth) / 2;\r\n const offsetY = Math.max(0, height - newHeight) / 2;\r\n\r\n const scene = camera.getScene();\r\n if (scene.activeCamera !== camera) {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (forceDownload) {\r\n const blob = new Blob([data]);\r\n Tools.DownloadBlob(blob);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else if (successCallback) {\r\n successCallback(data);\r\n }\r\n },\r\n mimeType,\r\n 1.0,\r\n engine.getCreationOptions().antialias,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n quality\r\n );\r\n } else {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (renderContext && renderingCanvas) {\r\n renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);\r\n }\r\n\r\n if (screenshotCanvas) {\r\n if (forceDownload) {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, undefined, mimeType, undefined, quality);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, successCallback, mimeType, undefined, quality);\r\n }\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotAsync(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, mimeType = \"image/png\", quality?: number): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n undefined,\r\n quality\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotWithResizeAsync(engine: AbstractEngine, camera: Camera, width: number, height: number, mimeType = \"image/png\", quality?: number): Promise<void> {\r\n return new Promise((resolve) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n { width: width, height: height },\r\n () => {\r\n resolve();\r\n },\r\n mimeType,\r\n true,\r\n quality\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height, finalWidth, finalHeight. If a single number is passed,\r\n * it will be used for both width and height, as well as finalWidth, finalHeight. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void\r\n): void {\r\n const { height, width, finalWidth, finalHeight } = _GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n const originalSize = { width: engine.getRenderWidth(), height: engine.getRenderHeight() };\r\n engine.setSize(width, height); // we need this call to trigger onResizeObservable with the screenshot width/height on all the subsystems that are observing this event and that needs to (re)create some resources with the right dimensions\r\n\r\n const scene = camera.getScene();\r\n\r\n // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)\r\n const texture = new RenderTargetTexture(\r\n \"screenShot\",\r\n targetTextureSize,\r\n scene,\r\n false,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT,\r\n false,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = scene.meshes.slice();\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n texture.activeCamera = camera;\r\n texture.forceLayerMaskCheck = useLayerMask;\r\n customizeTexture?.(texture);\r\n\r\n const renderWhenReady = () => {\r\n if (texture.isReadyForRendering() && camera.isReady(true)) {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (finalWidth === width && finalHeight === height) {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n DumpTools.DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n texture.dispose();\r\n });\r\n } else {\r\n ApplyPostProcess(\"pass\", texture.getInternalTexture()!, scene, undefined, undefined, undefined, finalWidth, finalHeight).then((texture) => {\r\n engine._readTexturePixels(texture, finalWidth, finalHeight, -1, 0, null, true, false, 0, 0).then((data) => {\r\n DumpTools.DumpData(\r\n finalWidth,\r\n finalHeight,\r\n data,\r\n successCallback as (data: string | ArrayBuffer) => void,\r\n mimeType,\r\n fileName,\r\n true,\r\n undefined,\r\n quality\r\n );\r\n texture.dispose();\r\n });\r\n });\r\n }\r\n });\r\n\r\n texture.render(true);\r\n\r\n // re-render the scene after the camera has been reset to the original camera to avoid a flicker that could occur\r\n // if the camera used for the RTT rendering stays in effect for the next frame (and if that camera was different from the original camera)\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n engine.setSize(originalSize.width, originalSize.height);\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n scene.render();\r\n } else {\r\n setTimeout(renderWhenReady, 16);\r\n }\r\n };\r\n\r\n const renderToTexture = () => {\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n renderWhenReady();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n if (!fxaaPostProcess.getEffect().isReady()) {\r\n fxaaPostProcess.getEffect().onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotUsingRenderTargetAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites,\r\n enableStencilBuffer,\r\n useLayerMask,\r\n quality\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\r\n * @param engine\r\n * @param camera\r\n * @param size\r\n * @private\r\n */\r\nfunction _GetScreenshotSize(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number; finalWidth: number; finalHeight: number } {\r\n let height = 0;\r\n let width = 0;\r\n let finalWidth = 0;\r\n let finalHeight = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n\r\n //If a finalWidth and finalHeight values is specified\r\n if (size.finalWidth && size.finalHeight) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = size.finalWidth;\r\n }\r\n //If passing only finalWidth, computing finalHeight to keep display canvas ratio.\r\n else if (size.finalWidth && !size.finalHeight) {\r\n finalWidth = size.finalWidth;\r\n finalHeight = Math.round(finalWidth / engine.getAspectRatio(camera));\r\n }\r\n //If passing only finalHeight, computing finalWidth to keep display canvas ratio.\r\n else if (size.finalHeight && !size.finalWidth) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = Math.round(finalHeight * engine.getAspectRatio(camera));\r\n } else {\r\n finalWidth = width;\r\n finalHeight = height;\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n finalWidth = size;\r\n finalHeight = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n if (finalWidth) {\r\n finalWidth = Math.floor(finalWidth);\r\n }\r\n if (finalHeight) {\r\n finalHeight = Math.floor(finalHeight);\r\n }\r\n\r\n return { height: height | 0, width: width | 0, finalWidth: finalWidth | 0, finalHeight: finalHeight | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n CreateScreenshot,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotAsync,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotWithResizeAsync,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n CreateScreenshotUsingRenderTarget,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotUsingRenderTargetAsync,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.CreateScreenshot = CreateScreenshot;\r\n Tools.CreateScreenshotAsync = CreateScreenshotAsync;\r\n Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget;\r\n Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
|