@babylonjs/core 8.44.0 → 8.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js +6 -10
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -1
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Limits/geospatialLimits.d.ts +4 -22
- package/Cameras/Limits/geospatialLimits.js +4 -36
- package/Cameras/Limits/geospatialLimits.js.map +1 -1
- package/Cameras/geospatialCamera.d.ts +15 -4
- package/Cameras/geospatialCamera.js +90 -37
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Cameras/geospatialCameraMovement.d.ts +1 -3
- package/Cameras/geospatialCameraMovement.js +15 -51
- package/Cameras/geospatialCameraMovement.js.map +1 -1
- package/Collisions/collisionCoordinator.d.ts +2 -2
- package/Collisions/collisionCoordinator.js +1 -0
- package/Collisions/collisionCoordinator.js.map +1 -1
- package/Engines/Extensions/engine.debugging.d.ts +3 -5
- package/Engines/Extensions/engine.debugging.js +3 -4
- package/Engines/Extensions/engine.debugging.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.debugging.js +15 -65
- package/Engines/WebGPU/Extensions/engine.debugging.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +9 -9
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.d.ts +2 -0
- package/Engines/abstractEngine.js +4 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/thinWebGPUEngine.d.ts +0 -2
- package/Engines/thinWebGPUEngine.js +0 -8
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +1 -3
- package/Engines/webgpuEngine.js +4 -10
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Passes/renderPass.js +4 -9
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +4 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +2 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +31 -7
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/frameGraph.js +2 -2
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphContext.d.ts +9 -0
- package/FrameGraph/frameGraphContext.js +13 -2
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/FrameGraph/frameGraphObjectList.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +9 -8
- package/FrameGraph/frameGraphRenderContext.js +23 -20
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +2 -0
- package/FrameGraph/frameGraphTask.js +14 -4
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +4 -1
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +8 -3
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/areaLight.d.ts +2 -1
- package/Lights/areaLight.js +3 -2
- package/Lights/areaLight.js.map +1 -1
- package/Lights/directionalLight.d.ts +2 -1
- package/Lights/directionalLight.js +3 -2
- package/Lights/directionalLight.js.map +1 -1
- package/Lights/hemisphericLight.d.ts +2 -1
- package/Lights/hemisphericLight.js +3 -2
- package/Lights/hemisphericLight.js.map +1 -1
- package/Lights/light.d.ts +2 -1
- package/Lights/light.js +8 -3
- package/Lights/light.js.map +1 -1
- package/Lights/lightingVolume.js +11 -6
- package/Lights/lightingVolume.js.map +1 -1
- package/Lights/pointLight.d.ts +2 -1
- package/Lights/pointLight.js +3 -2
- package/Lights/pointLight.js.map +1 -1
- package/Lights/rectAreaLight.d.ts +2 -1
- package/Lights/rectAreaLight.js +3 -2
- package/Lights/rectAreaLight.js.map +1 -1
- package/Lights/spotLight.d.ts +2 -1
- package/Lights/spotLight.js +3 -2
- package/Lights/spotLight.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js +3 -0
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +1 -0
- package/Materials/Node/nodeMaterial.js +4 -0
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildStateSharedData.d.ts +6 -0
- package/Materials/Node/nodeMaterialBuildStateSharedData.js +4 -0
- package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
- package/Materials/Textures/Loaders/iesTextureLoader.js +1 -1
- package/Materials/Textures/Loaders/iesTextureLoader.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +7 -2
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/dynamicTexture.d.ts +2 -2
- package/Materials/Textures/dynamicTexture.js +1 -1
- package/Materials/Textures/dynamicTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.d.ts +6 -4
- package/Materials/Textures/internalTexture.js +6 -4
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +2 -2
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/textureSampler.d.ts +3 -3
- package/Materials/Textures/textureSampler.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +4 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Misc/minMaxReducer.js +2 -2
- package/Misc/minMaxReducer.js.map +1 -1
- package/Misc/screenshotTools.d.ts +3 -1
- package/Misc/screenshotTools.js +5 -2
- package/Misc/screenshotTools.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.js +3 -0
- package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.js.map +1 -1
- package/Particles/Node/Blocks/index.d.ts +1 -0
- package/Particles/Node/Blocks/index.js +1 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleModuloBlock.d.ts +37 -0
- package/Particles/Node/Blocks/particleModuloBlock.js +98 -0
- package/Particles/Node/Blocks/particleModuloBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleSourceTextureBlock.d.ts +22 -1
- package/Particles/Node/Blocks/particleSourceTextureBlock.js +83 -9
- package/Particles/Node/Blocks/particleSourceTextureBlock.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +94 -66
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.js +4 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.js.map +1 -1
- package/Probes/reflectionProbe.js +9 -2
- package/Probes/reflectionProbe.js.map +1 -1
- package/Rendering/depthRenderer.js +7 -2
- package/Rendering/depthRenderer.js.map +1 -1
- package/Shaders/particles.vertex.js +8 -1
- package/Shaders/particles.vertex.js.map +1 -1
- package/ShadersWGSL/particles.vertex.js +6 -0
- package/ShadersWGSL/particles.vertex.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +10 -0
- package/scene.js +30 -5
- package/scene.js.map +1 -1
|
@@ -78,6 +78,12 @@ export declare class NodeMaterialBuildStateSharedData {
|
|
|
78
78
|
* Gets the list of animated inputs
|
|
79
79
|
*/
|
|
80
80
|
animatedInputs: InputBlock[];
|
|
81
|
+
/**
|
|
82
|
+
* Defines to inject in the vertex and fragment shaders
|
|
83
|
+
*/
|
|
84
|
+
defines: {
|
|
85
|
+
[key: string]: string;
|
|
86
|
+
};
|
|
81
87
|
/**
|
|
82
88
|
* Configurations used to format the generated code
|
|
83
89
|
*/
|
|
@@ -67,6 +67,10 @@ export class NodeMaterialBuildStateSharedData {
|
|
|
67
67
|
* Gets the list of animated inputs
|
|
68
68
|
*/
|
|
69
69
|
this.animatedInputs = [];
|
|
70
|
+
/**
|
|
71
|
+
* Defines to inject in the vertex and fragment shaders
|
|
72
|
+
*/
|
|
73
|
+
this.defines = {};
|
|
70
74
|
/**
|
|
71
75
|
* Configurations used to format the generated code
|
|
72
76
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeMaterialBuildStateSharedData.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Node/nodeMaterialBuildStateSharedData.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,6BAAyB;AAE1C;;GAEG;AACH,MAAM,OAAO,gCAAgC;IA6IzC,gCAAgC;IAChC;QAxIA;;WAEG;QACI,UAAK,GAAa,EAAE,CAAC;QAE5B;;WAEG;QACI,aAAQ,GAAa,EAAE,CAAC;QAE/B;;WAEG;QACI,uBAAkB,GAAG,EAAE,CAAC;QAE/B;;;WAGG;QACI,+BAA0B,GAAG,EAAE,CAAC;QAEvC;;;WAGG;QACI,mCAA8B,GAAG,EAAE,CAAC;QAO3C;;WAEG;QACI,gBAAW,GAAiB,EAAE,CAAC;QAEtC;;WAEG;QACI,kBAAa,GAAgC,EAAE,CAAC;QAEvD;;WAEG;QACI,mBAAc,GAAwB,EAAE,CAAC;QAEhD;;WAEG;QACI,yBAAoB,GAAwB,EAAE,CAAC;QAEtD;;WAEG;QACI,wBAAmB,GAAwB,EAAE,CAAC;QAErD;;WAEG;QACI,sBAAiB,GAAwB,EAAE,CAAC;QAEnD;;WAEG;QACI,4BAAuB,GAAwB,EAAE,CAAC;QAEzD;;WAEG;QACI,yBAAoB,GAAwB,EAAE,CAAC;QAEtD;;WAEG;QACI,mBAAc,GAAwB,EAAE,CAAC;QAEhD;;WAEG;QACI,mBAAc,GAAiB,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,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,UAAU;QACb,IAAI,YAAY,GAAG,EAAE,CAAC;QAEtB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC3D,YAAY,IAAI,iHAAiH,CAAC;QACtI,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC5B,YAAY,IAAI,gHAAgH,CAAC;QACrI,CAAC;QACD,KAAK,MAAM,iBAAiB,IAAI,IAAI,CAAC,MAAM,CAAC,6BAA6B,EAAE,CAAC;YACxE,YAAY,IAAI,SAAS,iBAAiB,CAAC,IAAI,eAC3C,iBAAiB,CAAC,UAAU,CAAC,IACjC,IAAI,iBAAiB,CAAC,UAAU,CAAC,YAAY,EAAE,2CAA2C,CAAC;QAC/F,CAAC;QACD,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YACjD,YAAY,IAAI,WAAW,GAAG,IAAI,CAAC;QACvC,CAAC;QAED,IAAI,YAAY,EAAE,CAAC;YACf,YAAY,GAAG,gCAAgC,GAAG,YAAY,CAAC;YAC/D,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YAC3B,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { NodeMaterialConnectionPoint } from \"./nodeMaterialBlockConnectionPoint\";\r\nimport type { NodeMaterialBlock } from \"./nodeMaterialBlock\";\r\nimport type { InputBlock } from \"./Blocks/Input/inputBlock\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Immutable, Nullable } from \"../../types\";\r\nimport type { NodeMaterial, NodeMaterialTextureBlocks } from \"./nodeMaterial\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Class used to store shared data between 2 NodeMaterialBuildState\r\n */\r\nexport class NodeMaterialBuildStateSharedData {\r\n /**\r\n * The node material we are currently building\r\n */\r\n public nodeMaterial: NodeMaterial;\r\n\r\n /**\r\n * Gets the list of emitted varyings\r\n */\r\n public temps: string[] = [];\r\n\r\n /**\r\n * Gets the list of emitted varyings\r\n */\r\n public varyings: string[] = [];\r\n\r\n /**\r\n * Gets the varying declaration string (for vertex shader)\r\n */\r\n public varyingDeclaration = \"\";\r\n\r\n /**\r\n * Gets the varying declaration string (for fragment shader)\r\n * This is potentially different from varyingDeclaration only in WebGPU\r\n */\r\n public varyingDeclarationFragment = \"\";\r\n\r\n /**\r\n * Gets the varying initialization string (for fragment shader)\r\n * Only used in WebGPU, to reconstruct the varying values from the vertex shader if their types is mat4x4f\r\n */\r\n public varyingInitializationsFragment = \"\";\r\n\r\n /**\r\n * List of the fragment output nodes\r\n */\r\n public fragmentOutputNodes: Immutable<Array<NodeMaterialBlock>>;\r\n\r\n /**\r\n * Input blocks\r\n */\r\n public inputBlocks: InputBlock[] = [];\r\n\r\n /**\r\n * Input blocks\r\n */\r\n public textureBlocks: NodeMaterialTextureBlocks[] = [];\r\n\r\n /**\r\n * Bindable blocks (Blocks that need to set data to the effect)\r\n */\r\n public bindableBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * Bindable blocks (Blocks that need to set data to the effect) that will always be called (by bindForSubMesh), contrary to bindableBlocks that won't be called if _mustRebind() returns false\r\n */\r\n public forcedBindableBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a compilation fallback\r\n */\r\n public blocksWithFallbacks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a define update\r\n */\r\n public blocksWithDefines: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a repeatable content\r\n */\r\n public repeatableContentBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a dynamic list of uniforms\r\n */\r\n public dynamicUniformBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can block the isReady function for the material\r\n */\r\n public blockingBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * Gets the list of animated inputs\r\n */\r\n public animatedInputs: InputBlock[] = [];\r\n\r\n /**\r\n * Configurations used to format the generated code\r\n */\r\n public formatConfig = {\r\n getUniformAnnotation: null as Nullable<(name: string) => string>,\r\n formatVariablename: (name: string) => name.replace(/[^a-zA-Z_]+/g, \"\"),\r\n };\r\n\r\n /**\r\n * Build Id used to avoid multiple recompilations\r\n */\r\n public buildId: number;\r\n\r\n /** List of emitted variables */\r\n public variableNames: { [key: string]: number } = {};\r\n\r\n /** List of emitted defines */\r\n public defineNames: { [key: string]: number } = {};\r\n\r\n /** Should emit comments? */\r\n public emitComments: boolean;\r\n\r\n /** Emit build activity */\r\n public verbose: boolean;\r\n\r\n /** Gets or sets the hosting scene */\r\n public scene: Scene;\r\n\r\n /**\r\n * Gets the compilation hints emitted at compilation time\r\n */\r\n public hints = {\r\n needWorldViewMatrix: false,\r\n needWorldViewProjectionMatrix: false,\r\n needAlphaBlending: false,\r\n needAlphaTesting: false,\r\n };\r\n\r\n /**\r\n * List of compilation checks\r\n */\r\n public checks = {\r\n emitVertex: false,\r\n emitFragment: false,\r\n notConnectedNonOptionalInputs: new Array<NodeMaterialConnectionPoint>(),\r\n customErrors: new Array<string>(),\r\n };\r\n\r\n /**\r\n * Is vertex program allowed to be empty?\r\n */\r\n public allowEmptyVertexProgram: boolean = false;\r\n\r\n /** Creates a new shared data */\r\n public constructor() {\r\n // Exclude usual attributes from free variable names\r\n this.variableNames[\"position\"] = 0;\r\n this.variableNames[\"normal\"] = 0;\r\n this.variableNames[\"tangent\"] = 0;\r\n this.variableNames[\"uv\"] = 0;\r\n this.variableNames[\"uv2\"] = 0;\r\n this.variableNames[\"uv3\"] = 0;\r\n this.variableNames[\"uv4\"] = 0;\r\n this.variableNames[\"uv5\"] = 0;\r\n this.variableNames[\"uv6\"] = 0;\r\n this.variableNames[\"color\"] = 0;\r\n this.variableNames[\"matricesIndices\"] = 0;\r\n this.variableNames[\"matricesWeights\"] = 0;\r\n this.variableNames[\"matricesIndicesExtra\"] = 0;\r\n this.variableNames[\"matricesWeightsExtra\"] = 0;\r\n this.variableNames[\"diffuseBase\"] = 0;\r\n this.variableNames[\"specularBase\"] = 0;\r\n this.variableNames[\"worldPos\"] = 0;\r\n this.variableNames[\"shadow\"] = 0;\r\n this.variableNames[\"view\"] = 0;\r\n\r\n // Exclude known varyings\r\n this.variableNames[\"vTBN\"] = 0;\r\n\r\n // Exclude defines\r\n this.defineNames[\"MAINUV0\"] = 0;\r\n this.defineNames[\"MAINUV1\"] = 0;\r\n this.defineNames[\"MAINUV2\"] = 0;\r\n this.defineNames[\"MAINUV3\"] = 0;\r\n this.defineNames[\"MAINUV4\"] = 0;\r\n this.defineNames[\"MAINUV5\"] = 0;\r\n this.defineNames[\"MAINUV6\"] = 0;\r\n this.defineNames[\"MAINUV7\"] = 0;\r\n }\r\n\r\n /**\r\n * Push a new error to the build state, avoiding exceptions that can break the build process\r\n * @param message defines the error message to push\r\n */\r\n public raiseBuildError(message: string) {\r\n if (this.checks.customErrors.indexOf(message) !== -1) {\r\n this.checks.customErrors.push(message);\r\n }\r\n }\r\n\r\n /**\r\n * Emits console errors and exceptions if there is a failing check\r\n * @returns true if all checks pass\r\n */\r\n public emitErrors() {\r\n let errorMessage = \"\";\r\n\r\n if (!this.checks.emitVertex && !this.allowEmptyVertexProgram) {\r\n errorMessage += \"NodeMaterial does not have a vertex output. You need to at least add a block that generates a position value.\\n\";\r\n }\r\n if (!this.checks.emitFragment) {\r\n errorMessage += \"NodeMaterial does not have a fragment output. You need to at least add a block that generates a color value.\\n\";\r\n }\r\n for (const notConnectedInput of this.checks.notConnectedNonOptionalInputs) {\r\n errorMessage += `input ${notConnectedInput.name} from block ${\r\n notConnectedInput.ownerBlock.name\r\n }[${notConnectedInput.ownerBlock.getClassName()}] is not connected and is not optional.\\n`;\r\n }\r\n for (const customError of this.checks.customErrors) {\r\n errorMessage += customError + \"\\n\";\r\n }\r\n\r\n if (errorMessage) {\r\n errorMessage = \"Node material build failed: \\n\" + errorMessage;\r\n Logger.Error(errorMessage);\r\n this.nodeMaterial.onBuildErrorObservable.notifyObservers(errorMessage);\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"nodeMaterialBuildStateSharedData.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Node/nodeMaterialBuildStateSharedData.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,6BAAyB;AAE1C;;GAEG;AACH,MAAM,OAAO,gCAAgC;IAkJzC,gCAAgC;IAChC;QA7IA;;WAEG;QACI,UAAK,GAAa,EAAE,CAAC;QAE5B;;WAEG;QACI,aAAQ,GAAa,EAAE,CAAC;QAE/B;;WAEG;QACI,uBAAkB,GAAG,EAAE,CAAC;QAE/B;;;WAGG;QACI,+BAA0B,GAAG,EAAE,CAAC;QAEvC;;;WAGG;QACI,mCAA8B,GAAG,EAAE,CAAC;QAO3C;;WAEG;QACI,gBAAW,GAAiB,EAAE,CAAC;QAEtC;;WAEG;QACI,kBAAa,GAAgC,EAAE,CAAC;QAEvD;;WAEG;QACI,mBAAc,GAAwB,EAAE,CAAC;QAEhD;;WAEG;QACI,yBAAoB,GAAwB,EAAE,CAAC;QAEtD;;WAEG;QACI,wBAAmB,GAAwB,EAAE,CAAC;QAErD;;WAEG;QACI,sBAAiB,GAAwB,EAAE,CAAC;QAEnD;;WAEG;QACI,4BAAuB,GAAwB,EAAE,CAAC;QAEzD;;WAEG;QACI,y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AAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { NodeMaterialConnectionPoint } from \"./nodeMaterialBlockConnectionPoint\";\r\nimport type { NodeMaterialBlock } from \"./nodeMaterialBlock\";\r\nimport type { InputBlock } from \"./Blocks/Input/inputBlock\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Immutable, Nullable } from \"../../types\";\r\nimport type { NodeMaterial, NodeMaterialTextureBlocks } from \"./nodeMaterial\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Class used to store shared data between 2 NodeMaterialBuildState\r\n */\r\nexport class NodeMaterialBuildStateSharedData {\r\n /**\r\n * The node material we are currently building\r\n */\r\n public nodeMaterial: NodeMaterial;\r\n\r\n /**\r\n * Gets the list of emitted varyings\r\n */\r\n public temps: string[] = [];\r\n\r\n /**\r\n * Gets the list of emitted varyings\r\n */\r\n public varyings: string[] = [];\r\n\r\n /**\r\n * Gets the varying declaration string (for vertex shader)\r\n */\r\n public varyingDeclaration = \"\";\r\n\r\n /**\r\n * Gets the varying declaration string (for fragment shader)\r\n * This is potentially different from varyingDeclaration only in WebGPU\r\n */\r\n public varyingDeclarationFragment = \"\";\r\n\r\n /**\r\n * Gets the varying initialization string (for fragment shader)\r\n * Only used in WebGPU, to reconstruct the varying values from the vertex shader if their types is mat4x4f\r\n */\r\n public varyingInitializationsFragment = \"\";\r\n\r\n /**\r\n * List of the fragment output nodes\r\n */\r\n public fragmentOutputNodes: Immutable<Array<NodeMaterialBlock>>;\r\n\r\n /**\r\n * Input blocks\r\n */\r\n public inputBlocks: InputBlock[] = [];\r\n\r\n /**\r\n * Input blocks\r\n */\r\n public textureBlocks: NodeMaterialTextureBlocks[] = [];\r\n\r\n /**\r\n * Bindable blocks (Blocks that need to set data to the effect)\r\n */\r\n public bindableBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * Bindable blocks (Blocks that need to set data to the effect) that will always be called (by bindForSubMesh), contrary to bindableBlocks that won't be called if _mustRebind() returns false\r\n */\r\n public forcedBindableBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a compilation fallback\r\n */\r\n public blocksWithFallbacks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a define update\r\n */\r\n public blocksWithDefines: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a repeatable content\r\n */\r\n public repeatableContentBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a dynamic list of uniforms\r\n */\r\n public dynamicUniformBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can block the isReady function for the material\r\n */\r\n public blockingBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * Gets the list of animated inputs\r\n */\r\n public animatedInputs: InputBlock[] = [];\r\n\r\n /**\r\n * Defines to inject in the vertex and fragment shaders\r\n */\r\n public defines: { [key: string]: string } = {};\r\n\r\n /**\r\n * Configurations used to format the generated code\r\n */\r\n public formatConfig = {\r\n getUniformAnnotation: null as Nullable<(name: string) => string>,\r\n formatVariablename: (name: string) => name.replace(/[^a-zA-Z_]+/g, \"\"),\r\n };\r\n\r\n /**\r\n * Build Id used to avoid multiple recompilations\r\n */\r\n public buildId: number;\r\n\r\n /** List of emitted variables */\r\n public variableNames: { [key: string]: number } = {};\r\n\r\n /** List of emitted defines */\r\n public defineNames: { [key: string]: number } = {};\r\n\r\n /** Should emit comments? */\r\n public emitComments: boolean;\r\n\r\n /** Emit build activity */\r\n public verbose: boolean;\r\n\r\n /** Gets or sets the hosting scene */\r\n public scene: Scene;\r\n\r\n /**\r\n * Gets the compilation hints emitted at compilation time\r\n */\r\n public hints = {\r\n needWorldViewMatrix: false,\r\n needWorldViewProjectionMatrix: false,\r\n needAlphaBlending: false,\r\n needAlphaTesting: false,\r\n };\r\n\r\n /**\r\n * List of compilation checks\r\n */\r\n public checks = {\r\n emitVertex: false,\r\n emitFragment: false,\r\n notConnectedNonOptionalInputs: new Array<NodeMaterialConnectionPoint>(),\r\n customErrors: new Array<string>(),\r\n };\r\n\r\n /**\r\n * Is vertex program allowed to be empty?\r\n */\r\n public allowEmptyVertexProgram: boolean = false;\r\n\r\n /** Creates a new shared data */\r\n public constructor() {\r\n // Exclude usual attributes from free variable names\r\n this.variableNames[\"position\"] = 0;\r\n this.variableNames[\"normal\"] = 0;\r\n this.variableNames[\"tangent\"] = 0;\r\n this.variableNames[\"uv\"] = 0;\r\n this.variableNames[\"uv2\"] = 0;\r\n this.variableNames[\"uv3\"] = 0;\r\n this.variableNames[\"uv4\"] = 0;\r\n this.variableNames[\"uv5\"] = 0;\r\n this.variableNames[\"uv6\"] = 0;\r\n this.variableNames[\"color\"] = 0;\r\n this.variableNames[\"matricesIndices\"] = 0;\r\n this.variableNames[\"matricesWeights\"] = 0;\r\n this.variableNames[\"matricesIndicesExtra\"] = 0;\r\n this.variableNames[\"matricesWeightsExtra\"] = 0;\r\n this.variableNames[\"diffuseBase\"] = 0;\r\n this.variableNames[\"specularBase\"] = 0;\r\n this.variableNames[\"worldPos\"] = 0;\r\n this.variableNames[\"shadow\"] = 0;\r\n this.variableNames[\"view\"] = 0;\r\n\r\n // Exclude known varyings\r\n this.variableNames[\"vTBN\"] = 0;\r\n\r\n // Exclude defines\r\n this.defineNames[\"MAINUV0\"] = 0;\r\n this.defineNames[\"MAINUV1\"] = 0;\r\n this.defineNames[\"MAINUV2\"] = 0;\r\n this.defineNames[\"MAINUV3\"] = 0;\r\n this.defineNames[\"MAINUV4\"] = 0;\r\n this.defineNames[\"MAINUV5\"] = 0;\r\n this.defineNames[\"MAINUV6\"] = 0;\r\n this.defineNames[\"MAINUV7\"] = 0;\r\n }\r\n\r\n /**\r\n * Push a new error to the build state, avoiding exceptions that can break the build process\r\n * @param message defines the error message to push\r\n */\r\n public raiseBuildError(message: string) {\r\n if (this.checks.customErrors.indexOf(message) !== -1) {\r\n this.checks.customErrors.push(message);\r\n }\r\n }\r\n\r\n /**\r\n * Emits console errors and exceptions if there is a failing check\r\n * @returns true if all checks pass\r\n */\r\n public emitErrors() {\r\n let errorMessage = \"\";\r\n\r\n if (!this.checks.emitVertex && !this.allowEmptyVertexProgram) {\r\n errorMessage += \"NodeMaterial does not have a vertex output. You need to at least add a block that generates a position value.\\n\";\r\n }\r\n if (!this.checks.emitFragment) {\r\n errorMessage += \"NodeMaterial does not have a fragment output. You need to at least add a block that generates a color value.\\n\";\r\n }\r\n for (const notConnectedInput of this.checks.notConnectedNonOptionalInputs) {\r\n errorMessage += `input ${notConnectedInput.name} from block ${\r\n notConnectedInput.ownerBlock.name\r\n }[${notConnectedInput.ownerBlock.getClassName()}] is not connected and is not optional.\\n`;\r\n }\r\n for (const customError of this.checks.customErrors) {\r\n errorMessage += customError + \"\\n\";\r\n }\r\n\r\n if (errorMessage) {\r\n errorMessage = \"Node material build failed: \\n\" + errorMessage;\r\n Logger.Error(errorMessage);\r\n this.nodeMaterial.onBuildErrorObservable.notifyObservers(errorMessage);\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n"]}
|
|
@@ -28,7 +28,7 @@ export class _IESTextureLoader {
|
|
|
28
28
|
loadData(data, texture, callback) {
|
|
29
29
|
const uint8array = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
30
30
|
const textureData = LoadIESData(uint8array);
|
|
31
|
-
callback(textureData.width, textureData.height, texture.useMipMaps, false, () => {
|
|
31
|
+
callback(textureData.width, textureData.height, !!texture.useMipMaps, false, () => {
|
|
32
32
|
const engine = texture.getEngine();
|
|
33
33
|
texture.type = 1;
|
|
34
34
|
texture.format = 6;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iesTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/iesTextureLoader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,yCAAkC;AAExD;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,iBAAiB;IAA9B;QACI;;WAEG;QACa,oBAAe,GAAG,KAAK,CAAC;IAiC5C,CAAC;IA/BG;;OAEG;IACI,YAAY;QACf,4CAA4C;QAC5C,MAAM,6BAA6B,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CACX,IAAqB,EACrB,OAAwB,EACxB,QAA+G;QAE/G,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAEjF,MAAM,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;QAE5C,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE;
|
|
1
|
+
{"version":3,"file":"iesTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/iesTextureLoader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,yCAAkC;AAExD;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,iBAAiB;IAA9B;QACI;;WAEG;QACa,oBAAe,GAAG,KAAK,CAAC;IAiC5C,CAAC;IA/BG;;OAEG;IACI,YAAY;QACf,4CAA4C;QAC5C,MAAM,6BAA6B,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CACX,IAAqB,EACrB,OAAwB,EACxB,QAA+G;QAE/G,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAEjF,MAAM,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;QAE5C,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE;YAC9E,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,iBAAiB,CAAC;YAC3C,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,eAAe,CAAC;YAC3C,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC;YAC5B,MAAM,CAAC,4BAA4B,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"../internalTexture\";\r\nimport type { IInternalTextureLoader } from \"./internalTextureLoader\";\r\nimport { Constants } from \"../../../Engines/constants\";\r\nimport { LoadIESData } from \"core/Lights/IES/iesLoader\";\r\n\r\n/**\r\n * Implementation of the IES Texture Loader.\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class _IESTextureLoader implements IInternalTextureLoader {\r\n /**\r\n * Defines whether the loader supports cascade loading the different faces.\r\n */\r\n public readonly supportCascades = false;\r\n\r\n /**\r\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\r\n */\r\n public loadCubeData(): void {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \".ies not supported in Cube.\";\r\n }\r\n\r\n /**\r\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param callback defines the method to call once ready to upload\r\n */\r\n public loadData(\r\n data: ArrayBufferView,\r\n texture: InternalTexture,\r\n callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void\r\n ): void {\r\n const uint8array = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\r\n\r\n const textureData = LoadIESData(uint8array);\r\n\r\n callback(textureData.width, textureData.height, !!texture.useMipMaps, false, () => {\r\n const engine = texture.getEngine();\r\n texture.type = Constants.TEXTURETYPE_FLOAT;\r\n texture.format = Constants.TEXTUREFORMAT_R;\r\n texture._gammaSpace = false;\r\n engine._uploadDataToTextureDirectly(texture, textureData.data);\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -546,7 +546,10 @@ export class ProceduralTexture extends Texture {
|
|
|
546
546
|
if (!this._texture || !this._rtWrapper) {
|
|
547
547
|
return;
|
|
548
548
|
}
|
|
549
|
-
engine.
|
|
549
|
+
if (engine._enableGPUDebugMarkers) {
|
|
550
|
+
engine.restoreDefaultFramebuffer();
|
|
551
|
+
engine._debugPushGroup(`procedural texture generation for ${this.name}`);
|
|
552
|
+
}
|
|
550
553
|
const viewPort = engine.currentViewport;
|
|
551
554
|
if (this.isCube) {
|
|
552
555
|
for (let face = 0; face < 6; face++) {
|
|
@@ -600,7 +603,9 @@ export class ProceduralTexture extends Texture {
|
|
|
600
603
|
if (this.isCube) {
|
|
601
604
|
engine.generateMipMapsForCubemap(this._texture, true);
|
|
602
605
|
}
|
|
603
|
-
engine.
|
|
606
|
+
if (engine._enableGPUDebugMarkers) {
|
|
607
|
+
engine._debugPopGroup();
|
|
608
|
+
}
|
|
604
609
|
if (this.onGenerated) {
|
|
605
610
|
this.onGenerated();
|
|
606
611
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proceduralTexture.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Procedurals/proceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAMtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,qCA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,CAAC;QAElD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;OAEG;IACa,OAAO;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAE9B,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,OAAO;QACX,CAAC;QAED,MAAM,KAAK,GAAG,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAErD,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACb,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC9C,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACpE,IAAI,YAAY,EAAE,CAAC;YACf,YAAY,CAAC,OAAO,EAAE,CAAC;YACvB,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;QAC1D,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YAC1E,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC7B,CAAC;QAED,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,4BAA4B,CAAC,KAAK,EAAE,CAAC;QAE1C,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ;AA5xBU;IADN,SAAS,EAAE;oDACY;AAMjB;IADN,SAAS,EAAE;oDACY;AA6BjB;IADN,SAAS,EAAE;2DACqB;AAqBzB;IADP,SAAS,EAAE;gDACe;AAgV3B;IADC,SAAS,EAAE;oDAGX;AAoZL,aAAa,CAAC,2BAA2B,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import { serialize } from \"../../../Misc/decorators\";\r\nimport { Observable } from \"../../../Misc/observable\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport type { Scene } from \"../../../scene\";\r\nimport type { Matrix, Vector4, Vector3, Vector2 } from \"../../../Maths/math.vector\";\r\nimport type { Color4, Color3 } from \"../../../Maths/math.color\";\r\nimport type { AbstractEngine } from \"../../../Engines/abstractEngine\";\r\nimport { VertexBuffer } from \"../../../Buffers/buffer\";\r\nimport { SceneComponentConstants } from \"../../../sceneComponent\";\r\n\r\nimport { Material } from \"../../../Materials/material\";\r\nimport type { Effect } from \"../../../Materials/effect\";\r\nimport { Texture } from \"../../../Materials/Textures/texture\";\r\nimport type { RenderTargetTextureOptions } from \"../../../Materials/Textures/renderTargetTexture\";\r\nimport { RenderTargetTexture } from \"../../../Materials/Textures/renderTargetTexture\";\r\nimport { ProceduralTextureSceneComponent } from \"./proceduralTextureSceneComponent\";\r\n\r\nimport type { DataBuffer } from \"../../../Buffers/dataBuffer\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport type { NodeMaterial } from \"../../Node/nodeMaterial\";\r\nimport type { TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport { EngineStore } from \"../../../Engines/engineStore\";\r\nimport { Constants } from \"../../../Engines/constants\";\r\nimport { DrawWrapper } from \"../../drawWrapper\";\r\nimport type { RenderTargetWrapper } from \"../../../Engines/renderTargetWrapper\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport type { ThinTexture } from \"core/Materials/Textures/thinTexture\";\r\n\r\n/**\r\n * Options to create a procedural texture\r\n */\r\nexport interface IProceduralTextureCreationOptions extends RenderTargetTextureOptions {\r\n /**\r\n * Defines a fallback texture in case there were issues to create the custom texture\r\n */\r\n fallbackTexture?: Nullable<Texture>;\r\n /**\r\n * The shader language of the shader. (default: GLSL)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n /**\r\n * Additional async code to run before preparing the effect\r\n */\r\n extraInitializationsAsync?: () => Promise<void>;\r\n}\r\n\r\n/**\r\n * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.\r\n * This is the base class of any Procedural texture and contains most of the shareable code.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/proceduralTextures\r\n */\r\nexport class ProceduralTexture extends Texture {\r\n /**\r\n * Define if the texture is enabled or not (disabled texture will not render)\r\n */\r\n @serialize()\r\n public isEnabled = true;\r\n\r\n /**\r\n * Define if the texture must be cleared before rendering (default is true)\r\n */\r\n @serialize()\r\n public autoClear = true;\r\n\r\n /**\r\n * Callback called when the texture is generated\r\n */\r\n public onGenerated: () => void;\r\n\r\n /**\r\n * Event raised when the texture is generated\r\n */\r\n public onGeneratedObservable = new Observable<ProceduralTexture>();\r\n\r\n /**\r\n * Event raised before the texture is generated\r\n */\r\n public onBeforeGenerationObservable = new Observable<ProceduralTexture>();\r\n\r\n /**\r\n * Gets or sets the node material used to create this texture (null if the texture was manually created)\r\n */\r\n public nodeMaterialSource: Nullable<NodeMaterial> = null;\r\n\r\n /**\r\n * Define the list of custom preprocessor defines used in the shader\r\n */\r\n public defines: string = \"\";\r\n\r\n /** @internal */\r\n @serialize()\r\n public _generateMipMaps: boolean;\r\n\r\n private _drawWrapper: DrawWrapper;\r\n\r\n /** @internal */\r\n public _textures: { [key: string]: ThinTexture } = {};\r\n\r\n /** @internal */\r\n protected _fallbackTexture: Nullable<Texture>;\r\n\r\n /** @internal */\r\n private _shaderLanguage: ShaderLanguage;\r\n\r\n /**\r\n * Gets the shader language type used to generate vertex and fragment source code.\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n @serialize()\r\n private _size: TextureSize;\r\n private _textureType: number;\r\n private _currentRefreshId = -1;\r\n private _frameId = -1;\r\n private _refreshRate = 1;\r\n private _vertexBuffers: { [key: string]: Nullable<VertexBuffer> } = {};\r\n private _indexBuffer: Nullable<DataBuffer>;\r\n private _uniforms = new Array<string>();\r\n private _samplers = new Array<string>();\r\n private _fragment: any;\r\n\r\n private _floats: { [key: string]: number } = {};\r\n private _ints: { [key: string]: number } = {};\r\n private _floatsArrays: { [key: string]: number[] } = {};\r\n private _colors3: { [key: string]: Color3 } = {};\r\n private _colors4: { [key: string]: Color4 } = {};\r\n private _vectors2: { [key: string]: Vector2 } = {};\r\n private _vectors3: { [key: string]: Vector3 } = {};\r\n private _vectors4: { [key: string]: Vector4 } = {};\r\n private _matrices: { [key: string]: Matrix } = {};\r\n\r\n private _fallbackTextureUsed = false;\r\n private _fullEngine: AbstractEngine;\r\n\r\n private _cachedDefines: Nullable<string> = null;\r\n\r\n private _contentUpdateId = -1;\r\n private _contentData: Nullable<Promise<ArrayBufferView>>;\r\n\r\n private _rtWrapper: Nullable<RenderTargetWrapper> = null;\r\n private _options: IProceduralTextureCreationOptions;\r\n\r\n /**\r\n * Instantiates a new procedural texture.\r\n * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.\r\n * This is the base class of any Procedural texture and contains most of the shareable code.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/proceduralTextures\r\n * @param name Define the name of the texture\r\n * @param size Define the size of the texture to create\r\n * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later:\r\n * * object: \\{ fragmentElement: \"fragmentShaderCode\" \\}, used with shader code in script tags\r\n * * object: \\{ fragmentSource: \"fragment shader code string\" \\}, the string contains the shader code\r\n * * string: the string contains a name \"XXX\" to lookup in Effect.ShadersStore[\"XXXFragmentShader\"]\r\n * @param scene Define the scene the texture belongs to\r\n * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture\r\n * @param generateMipMaps Define if the texture should creates mip maps or not\r\n * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)\r\n * @param textureType The FBO internal texture type\r\n */\r\n constructor(\r\n name: string,\r\n size: TextureSize,\r\n fragment: any,\r\n scene: Nullable<Scene>,\r\n fallbackTexture: Nullable<Texture> | IProceduralTextureCreationOptions = null,\r\n generateMipMaps = true,\r\n isCube = false,\r\n textureType = Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n ) {\r\n super(null, scene, !generateMipMaps);\r\n\r\n if (fallbackTexture !== null && !(fallbackTexture instanceof Texture)) {\r\n this._options = fallbackTexture;\r\n this._fallbackTexture = fallbackTexture.fallbackTexture ?? null;\r\n } else {\r\n this._options = {};\r\n this._fallbackTexture = fallbackTexture;\r\n }\r\n\r\n this._shaderLanguage = this._options.shaderLanguage ?? ShaderLanguage.GLSL;\r\n\r\n scene = this.getScene() || EngineStore.LastCreatedScene!;\r\n let component = scene._getComponent(SceneComponentConstants.NAME_PROCEDURALTEXTURE);\r\n if (!component) {\r\n component = new ProceduralTextureSceneComponent(scene);\r\n scene._addComponent(component);\r\n }\r\n scene.proceduralTextures.push(this);\r\n\r\n this._fullEngine = scene.getEngine();\r\n\r\n this.name = name;\r\n this.isRenderTarget = true;\r\n this._size = size;\r\n this._textureType = textureType;\r\n this._generateMipMaps = generateMipMaps;\r\n this._drawWrapper = new DrawWrapper(this._fullEngine);\r\n\r\n this.setFragment(fragment);\r\n\r\n const rtWrapper = this._createRtWrapper(isCube, size, generateMipMaps, textureType);\r\n this._texture = rtWrapper.texture;\r\n\r\n // VBO\r\n const vertices = [];\r\n vertices.push(1, 1);\r\n vertices.push(-1, 1);\r\n vertices.push(-1, -1);\r\n vertices.push(1, -1);\r\n\r\n this._vertexBuffers[VertexBuffer.PositionKind] = new VertexBuffer(this._fullEngine, vertices, VertexBuffer.PositionKind, false, false, 2);\r\n\r\n this._createIndexBuffer();\r\n }\r\n\r\n private _createRtWrapper(isCube: boolean, size: TextureSize, generateMipMaps: boolean, textureType: number) {\r\n if (isCube) {\r\n this._rtWrapper = this._fullEngine.createRenderTargetCubeTexture(size as number, {\r\n generateMipMaps: generateMipMaps,\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n type: textureType,\r\n ...this._options,\r\n });\r\n this.setFloat(\"face\", 0);\r\n } else {\r\n this._rtWrapper = this._fullEngine.createRenderTargetTexture(size, {\r\n generateMipMaps: generateMipMaps,\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n type: textureType,\r\n ...this._options,\r\n });\r\n if (this._rtWrapper.is3D) {\r\n this.setFloat(\"layer\", 0);\r\n this.setInt(\"layerNum\", 0);\r\n }\r\n }\r\n return this._rtWrapper;\r\n }\r\n\r\n /**\r\n * The effect that is created when initializing the post process.\r\n * @returns The created effect corresponding the postprocess.\r\n */\r\n public getEffect(): Effect {\r\n return this._drawWrapper.effect!;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _setEffect(effect: Effect) {\r\n this._drawWrapper.effect = effect;\r\n }\r\n\r\n /**\r\n * Gets texture content (Use this function wisely as reading from a texture can be slow)\r\n * @returns an ArrayBufferView promise (Uint8Array or Float32Array)\r\n */\r\n public getContent(): Nullable<Promise<ArrayBufferView>> {\r\n if (this._contentData && this._frameId === this._contentUpdateId) {\r\n return this._contentData;\r\n }\r\n\r\n if (this._contentData) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this._contentData.then((buffer) => {\r\n this._contentData = this.readPixels(0, 0, buffer);\r\n this._contentUpdateId = this._frameId;\r\n });\r\n } else {\r\n this._contentData = this.readPixels(0, 0);\r\n this._contentUpdateId = this._frameId;\r\n }\r\n\r\n return this._contentData;\r\n }\r\n\r\n private _createIndexBuffer(): void {\r\n const engine = this._fullEngine;\r\n\r\n // Indices\r\n const indices = [];\r\n indices.push(0);\r\n indices.push(1);\r\n indices.push(2);\r\n\r\n indices.push(0);\r\n indices.push(2);\r\n indices.push(3);\r\n\r\n this._indexBuffer = engine.createIndexBuffer(indices);\r\n }\r\n\r\n /** @internal */\r\n public override _rebuild(): void {\r\n const vb = this._vertexBuffers[VertexBuffer.PositionKind];\r\n\r\n if (vb) {\r\n vb._rebuild();\r\n }\r\n\r\n this._createIndexBuffer();\r\n\r\n if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {\r\n this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;\r\n }\r\n }\r\n\r\n /**\r\n * Resets the texture in order to recreate its associated resources.\r\n * This can be called in case of context loss or if you change the shader code and need to regenerate the texture with the new code\r\n */\r\n public reset(): void {\r\n this._drawWrapper.effect?.dispose();\r\n this._drawWrapper.effect = null;\r\n this._cachedDefines = null;\r\n }\r\n\r\n protected _getDefines(): string {\r\n return this.defines;\r\n }\r\n\r\n /**\r\n * Executes a function when the texture will be ready to be drawn.\r\n * @param func The callback to be used.\r\n */\r\n public executeWhenReady(func: (texture: ProceduralTexture) => void): void {\r\n if (this.isReady()) {\r\n func(this);\r\n return;\r\n }\r\n\r\n const effect = this.getEffect();\r\n if (effect) {\r\n effect.executeWhenCompiled(() => {\r\n func(this);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Is the texture ready to be used ? (rendered at least once)\r\n * @returns true if ready, otherwise, false.\r\n */\r\n public override isReady(): boolean {\r\n const engine = this._fullEngine;\r\n\r\n if (this.nodeMaterialSource) {\r\n return this._drawWrapper.effect!.isReady();\r\n }\r\n\r\n if (!this._fragment) {\r\n return false;\r\n }\r\n\r\n if (this._fallbackTextureUsed) {\r\n return true;\r\n }\r\n\r\n if (!this._texture) {\r\n return false;\r\n }\r\n\r\n const defines = this._getDefines();\r\n if (this._drawWrapper.effect && defines === this._cachedDefines && this._drawWrapper.effect.isReady()) {\r\n return true;\r\n }\r\n\r\n const shaders = {\r\n vertex: \"procedural\",\r\n fragmentElement: this._fragment.fragmentElement,\r\n fragmentSource: this._fragment.fragmentSource,\r\n fragment: typeof this._fragment === \"string\" ? this._fragment : undefined,\r\n };\r\n\r\n if (this._cachedDefines !== defines) {\r\n this._cachedDefines = defines;\r\n\r\n this._drawWrapper.effect = engine.createEffect(\r\n shaders,\r\n [VertexBuffer.PositionKind],\r\n this._uniforms,\r\n this._samplers,\r\n defines,\r\n undefined,\r\n undefined,\r\n () => {\r\n this._rtWrapper?.dispose();\r\n this._rtWrapper = this._texture = null;\r\n\r\n if (this._fallbackTexture) {\r\n this._texture = this._fallbackTexture._texture;\r\n\r\n if (this._texture) {\r\n this._texture.incrementReferences();\r\n }\r\n }\r\n\r\n this._fallbackTextureUsed = true;\r\n },\r\n undefined,\r\n this._shaderLanguage,\r\n async () => {\r\n if (this._options.extraInitializationsAsync) {\r\n if (this.shaderLanguage === ShaderLanguage.WGSL) {\r\n await Promise.all([import(\"../../../ShadersWGSL/procedural.vertex\"), this._options.extraInitializationsAsync()]);\r\n } else {\r\n await Promise.all([import(\"../../../Shaders/procedural.vertex\"), this._options.extraInitializationsAsync()]);\r\n }\r\n } else {\r\n if (this.shaderLanguage === ShaderLanguage.WGSL) {\r\n await import(\"../../../ShadersWGSL/procedural.vertex\");\r\n } else {\r\n await import(\"../../../Shaders/procedural.vertex\");\r\n }\r\n }\r\n }\r\n );\r\n }\r\n\r\n return this._drawWrapper.effect!.isReady();\r\n }\r\n\r\n /**\r\n * Resets the refresh counter of the texture and start bak from scratch.\r\n * Could be useful to regenerate the texture if it is setup to render only once.\r\n */\r\n public resetRefreshCounter(): void {\r\n this._currentRefreshId = -1;\r\n }\r\n\r\n /**\r\n * Set the fragment shader to use in order to render the texture.\r\n * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.\r\n */\r\n public setFragment(fragment: any) {\r\n this._fragment = fragment;\r\n }\r\n\r\n /**\r\n * Define the refresh rate of the texture or the rendering frequency.\r\n * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...\r\n */\r\n @serialize()\r\n public get refreshRate(): number {\r\n return this._refreshRate;\r\n }\r\n\r\n public set refreshRate(value: number) {\r\n this._refreshRate = value;\r\n this.resetRefreshCounter();\r\n }\r\n\r\n /** @internal */\r\n public _shouldRender(): boolean {\r\n if (!this.isEnabled || !this.isReady() || !this._texture) {\r\n if (this._texture) {\r\n this._texture.isReady = false;\r\n }\r\n return false;\r\n }\r\n\r\n if (this._fallbackTextureUsed) {\r\n return false;\r\n }\r\n\r\n if (this._currentRefreshId === -1) {\r\n // At least render once\r\n this._currentRefreshId = 1;\r\n this._frameId++;\r\n return true;\r\n }\r\n\r\n if (this.refreshRate === this._currentRefreshId) {\r\n this._currentRefreshId = 1;\r\n this._frameId++;\r\n return true;\r\n }\r\n\r\n this._currentRefreshId++;\r\n return false;\r\n }\r\n\r\n /**\r\n * Get the size the texture is rendering at.\r\n * @returns the size (on cube texture it is always squared)\r\n */\r\n public getRenderSize(): TextureSize {\r\n return this._size;\r\n }\r\n\r\n /**\r\n * Resize the texture to new value.\r\n * @param size Define the new size the texture should have\r\n * @param generateMipMaps Define whether the new texture should create mip maps\r\n */\r\n public resize(size: TextureSize, generateMipMaps: boolean): void {\r\n if (this._fallbackTextureUsed || !this._rtWrapper || !this._texture) {\r\n return;\r\n }\r\n\r\n const isCube = this._texture.isCube;\r\n this._rtWrapper.dispose();\r\n\r\n const rtWrapper = this._createRtWrapper(isCube, size, generateMipMaps, this._textureType);\r\n this._texture = rtWrapper.texture;\r\n\r\n // Update properties\r\n this._size = size;\r\n this._generateMipMaps = generateMipMaps;\r\n }\r\n\r\n private _checkUniform(uniformName: string): void {\r\n if (this._uniforms.indexOf(uniformName) === -1) {\r\n this._uniforms.push(uniformName);\r\n }\r\n }\r\n\r\n /**\r\n * Set a texture in the shader program used to render.\r\n * @param name Define the name of the uniform samplers as defined in the shader\r\n * @param texture Define the texture to bind to this sampler\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setTexture(name: string, texture: ThinTexture): ProceduralTexture {\r\n if (this._samplers.indexOf(name) === -1) {\r\n this._samplers.push(name);\r\n }\r\n this._textures[name] = texture;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a float in the shader.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setFloat(name: string, value: number): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._floats[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a int in the shader.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setInt(name: string, value: number): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._ints[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set an array of floats in the shader.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setFloats(name: string, value: number[]): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._floatsArrays[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a vec3 in the shader from a Color3.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setColor3(name: string, value: Color3): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._colors3[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a vec4 in the shader from a Color4.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setColor4(name: string, value: Color4): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._colors4[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a vec2 in the shader from a Vector2.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setVector2(name: string, value: Vector2): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._vectors2[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a vec3 in the shader from a Vector3.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setVector3(name: string, value: Vector3): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._vectors3[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a vec4 in the shader from a Vector4.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setVector4(name: string, value: Vector4): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._vectors4[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a mat4 in the shader from a MAtrix.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setMatrix(name: string, value: Matrix): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._matrices[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Render the texture to its associated render target.\r\n * @param useCameraPostProcess Define if camera post process should be applied to the texture\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public render(useCameraPostProcess?: boolean): void {\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return;\r\n }\r\n\r\n const engine = this._fullEngine;\r\n\r\n // Render\r\n engine.enableEffect(this._drawWrapper);\r\n this.onBeforeGenerationObservable.notifyObservers(this);\r\n engine.setState(false);\r\n\r\n if (!this.nodeMaterialSource) {\r\n // Texture\r\n for (const name in this._textures) {\r\n this._drawWrapper.effect!.setTexture(name, this._textures[name]);\r\n }\r\n\r\n // Float\r\n for (const name in this._ints) {\r\n this._drawWrapper.effect!.setInt(name, this._ints[name]);\r\n }\r\n\r\n // Float\r\n for (const name in this._floats) {\r\n this._drawWrapper.effect!.setFloat(name, this._floats[name]);\r\n }\r\n\r\n // Floats\r\n for (const name in this._floatsArrays) {\r\n this._drawWrapper.effect!.setArray(name, this._floatsArrays[name]);\r\n }\r\n\r\n // Color3\r\n for (const name in this._colors3) {\r\n this._drawWrapper.effect!.setColor3(name, this._colors3[name]);\r\n }\r\n\r\n // Color4\r\n for (const name in this._colors4) {\r\n const color = this._colors4[name];\r\n this._drawWrapper.effect!.setFloat4(name, color.r, color.g, color.b, color.a);\r\n }\r\n\r\n // Vector2\r\n for (const name in this._vectors2) {\r\n this._drawWrapper.effect!.setVector2(name, this._vectors2[name]);\r\n }\r\n\r\n // Vector3\r\n for (const name in this._vectors3) {\r\n this._drawWrapper.effect!.setVector3(name, this._vectors3[name]);\r\n }\r\n\r\n // Vector4\r\n for (const name in this._vectors4) {\r\n this._drawWrapper.effect!.setVector4(name, this._vectors4[name]);\r\n }\r\n\r\n // Matrix\r\n for (const name in this._matrices) {\r\n this._drawWrapper.effect!.setMatrix(name, this._matrices[name]);\r\n }\r\n }\r\n\r\n if (!this._texture || !this._rtWrapper) {\r\n return;\r\n }\r\n\r\n engine._debugPushGroup?.(`procedural texture generation for ${this.name}`, 1);\r\n\r\n const viewPort = engine.currentViewport;\r\n if (this.isCube) {\r\n for (let face = 0; face < 6; face++) {\r\n engine.bindFramebuffer(this._rtWrapper, face, undefined, undefined, true);\r\n\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect!);\r\n\r\n this._drawWrapper.effect!.setFloat(\"face\", face);\r\n\r\n // Clear\r\n if (this.autoClear) {\r\n engine.clear(scene.clearColor, true, false, false);\r\n }\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.TriangleFillMode, 0, 6);\r\n // Unbind and restore viewport\r\n engine.unBindFramebuffer(this._rtWrapper, true);\r\n }\r\n } else {\r\n let numLayers = 1;\r\n if (this._rtWrapper.is3D) {\r\n numLayers = this._rtWrapper.depth;\r\n } else if (this._rtWrapper.is2DArray) {\r\n numLayers = this._rtWrapper.layers;\r\n }\r\n for (let layer = 0; layer < numLayers; layer++) {\r\n engine.bindFramebuffer(this._rtWrapper, 0, undefined, undefined, true, 0, layer);\r\n\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect!);\r\n\r\n if (this._rtWrapper.is3D || this._rtWrapper.is2DArray) {\r\n this._drawWrapper.effect?.setFloat(\"layer\", numLayers !== 1 ? layer / (numLayers - 1) : 0);\r\n this._drawWrapper.effect?.setInt(\"layerNum\", layer);\r\n for (const name in this._textures) {\r\n this._drawWrapper.effect!.setTexture(name, this._textures[name]);\r\n }\r\n }\r\n\r\n // Clear\r\n if (this.autoClear) {\r\n engine.clear(scene.clearColor, true, false, false);\r\n }\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.TriangleFillMode, 0, 6);\r\n // Unbind and restore viewport\r\n engine.unBindFramebuffer(this._rtWrapper, !this._generateMipMaps);\r\n }\r\n }\r\n\r\n if (viewPort) {\r\n engine.setViewport(viewPort);\r\n }\r\n\r\n // Mipmaps\r\n if (this.isCube) {\r\n engine.generateMipMapsForCubemap(this._texture, true);\r\n }\r\n\r\n engine._debugPopGroup?.(1);\r\n\r\n if (this.onGenerated) {\r\n this.onGenerated();\r\n }\r\n\r\n this.onGeneratedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Clone the texture.\r\n * @returns the cloned texture\r\n */\r\n public override clone(): ProceduralTexture {\r\n const textureSize = this.getSize();\r\n const newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, <Scene>this.getScene(), this._fallbackTexture, this._generateMipMaps);\r\n\r\n // Base texture\r\n newTexture.hasAlpha = this.hasAlpha;\r\n newTexture.level = this.level;\r\n\r\n // RenderTarget Texture\r\n newTexture.coordinatesMode = this.coordinatesMode;\r\n\r\n return newTexture;\r\n }\r\n\r\n /**\r\n * Dispose the texture and release its associated resources.\r\n */\r\n public override dispose(): void {\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return;\r\n }\r\n\r\n const index = scene.proceduralTextures.indexOf(this);\r\n\r\n if (index >= 0) {\r\n scene.proceduralTextures.splice(index, 1);\r\n }\r\n\r\n const vertexBuffer = this._vertexBuffers[VertexBuffer.PositionKind];\r\n if (vertexBuffer) {\r\n vertexBuffer.dispose();\r\n this._vertexBuffers[VertexBuffer.PositionKind] = null;\r\n }\r\n\r\n if (this._indexBuffer && this._fullEngine._releaseBuffer(this._indexBuffer)) {\r\n this._indexBuffer = null;\r\n }\r\n\r\n this.onGeneratedObservable.clear();\r\n this.onBeforeGenerationObservable.clear();\r\n\r\n super.dispose();\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ProceduralTexture\", ProceduralTexture);\r\n"]}
|
|
1
|
+
{"version":3,"file":"proceduralTexture.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Procedurals/proceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAMtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AACtF,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAGpF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAuBhD;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,OAAO;IAqD1C;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAmCD;;;;;;;;;;;;;;;;OAgBG;IACH,YACI,IAA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MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACpE,IAAI,YAAY,EAAE,CAAC;YACf,YAAY,CAAC,OAAO,EAAE,CAAC;YACvB,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;QAC1D,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YAC1E,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC7B,CAAC;QAED,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,4BAA4B,CAAC,KAAK,EAAE,CAAC;QAE1C,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ;AAjyBU;IADN,SAAS,EAAE;oDACY;AAMjB;IADN,SAAS,EAAE;oDACY;AA6BjB;IADN,SAAS,EAAE;2DACqB;AAqBzB;IADP,SAAS,EAAE;gDACe;AAgV3B;IADC,SAAS,EAAE;oDAGX;AAyZL,aAAa,CAAC,2BAA2B,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import { serialize } from \"../../../Misc/decorators\";\r\nimport { Observable } from \"../../../Misc/observable\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport type { Scene } from \"../../../scene\";\r\nimport type { Matrix, Vector4, Vector3, Vector2 } from \"../../../Maths/math.vector\";\r\nimport type { Color4, Color3 } from \"../../../Maths/math.color\";\r\nimport type { AbstractEngine } from \"../../../Engines/abstractEngine\";\r\nimport { VertexBuffer } from \"../../../Buffers/buffer\";\r\nimport { SceneComponentConstants } from \"../../../sceneComponent\";\r\n\r\nimport { Material } from \"../../../Materials/material\";\r\nimport type { Effect } from \"../../../Materials/effect\";\r\nimport { Texture } from \"../../../Materials/Textures/texture\";\r\nimport type { RenderTargetTextureOptions } from \"../../../Materials/Textures/renderTargetTexture\";\r\nimport { RenderTargetTexture } from \"../../../Materials/Textures/renderTargetTexture\";\r\nimport { ProceduralTextureSceneComponent } from \"./proceduralTextureSceneComponent\";\r\n\r\nimport type { DataBuffer } from \"../../../Buffers/dataBuffer\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport type { NodeMaterial } from \"../../Node/nodeMaterial\";\r\nimport type { TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport { EngineStore } from \"../../../Engines/engineStore\";\r\nimport { Constants } from \"../../../Engines/constants\";\r\nimport { DrawWrapper } from \"../../drawWrapper\";\r\nimport type { RenderTargetWrapper } from \"../../../Engines/renderTargetWrapper\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport type { ThinTexture } from \"core/Materials/Textures/thinTexture\";\r\n\r\n/**\r\n * Options to create a procedural texture\r\n */\r\nexport interface IProceduralTextureCreationOptions extends RenderTargetTextureOptions {\r\n /**\r\n * Defines a fallback texture in case there were issues to create the custom texture\r\n */\r\n fallbackTexture?: Nullable<Texture>;\r\n /**\r\n * The shader language of the shader. (default: GLSL)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n /**\r\n * Additional async code to run before preparing the effect\r\n */\r\n extraInitializationsAsync?: () => Promise<void>;\r\n}\r\n\r\n/**\r\n * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.\r\n * This is the base class of any Procedural texture and contains most of the shareable code.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/proceduralTextures\r\n */\r\nexport class ProceduralTexture extends Texture {\r\n /**\r\n * Define if the texture is enabled or not (disabled texture will not render)\r\n */\r\n @serialize()\r\n public isEnabled = true;\r\n\r\n /**\r\n * Define if the texture must be cleared before rendering (default is true)\r\n */\r\n @serialize()\r\n public autoClear = true;\r\n\r\n /**\r\n * Callback called when the texture is generated\r\n */\r\n public onGenerated: () => void;\r\n\r\n /**\r\n * Event raised when the texture is generated\r\n */\r\n public onGeneratedObservable = new Observable<ProceduralTexture>();\r\n\r\n /**\r\n * Event raised before the texture is generated\r\n */\r\n public onBeforeGenerationObservable = new Observable<ProceduralTexture>();\r\n\r\n /**\r\n * Gets or sets the node material used to create this texture (null if the texture was manually created)\r\n */\r\n public nodeMaterialSource: Nullable<NodeMaterial> = null;\r\n\r\n /**\r\n * Define the list of custom preprocessor defines used in the shader\r\n */\r\n public defines: string = \"\";\r\n\r\n /** @internal */\r\n @serialize()\r\n public _generateMipMaps: boolean;\r\n\r\n private _drawWrapper: DrawWrapper;\r\n\r\n /** @internal */\r\n public _textures: { [key: string]: ThinTexture } = {};\r\n\r\n /** @internal */\r\n protected _fallbackTexture: Nullable<Texture>;\r\n\r\n /** @internal */\r\n private _shaderLanguage: ShaderLanguage;\r\n\r\n /**\r\n * Gets the shader language type used to generate vertex and fragment source code.\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n @serialize()\r\n private _size: TextureSize;\r\n private _textureType: number;\r\n private _currentRefreshId = -1;\r\n private _frameId = -1;\r\n private _refreshRate = 1;\r\n private _vertexBuffers: { [key: string]: Nullable<VertexBuffer> } = {};\r\n private _indexBuffer: Nullable<DataBuffer>;\r\n private _uniforms = new Array<string>();\r\n private _samplers = new Array<string>();\r\n private _fragment: any;\r\n\r\n private _floats: { [key: string]: number } = {};\r\n private _ints: { [key: string]: number } = {};\r\n private _floatsArrays: { [key: string]: number[] } = {};\r\n private _colors3: { [key: string]: Color3 } = {};\r\n private _colors4: { [key: string]: Color4 } = {};\r\n private _vectors2: { [key: string]: Vector2 } = {};\r\n private _vectors3: { [key: string]: Vector3 } = {};\r\n private _vectors4: { [key: string]: Vector4 } = {};\r\n private _matrices: { [key: string]: Matrix } = {};\r\n\r\n private _fallbackTextureUsed = false;\r\n private _fullEngine: AbstractEngine;\r\n\r\n private _cachedDefines: Nullable<string> = null;\r\n\r\n private _contentUpdateId = -1;\r\n private _contentData: Nullable<Promise<ArrayBufferView>>;\r\n\r\n private _rtWrapper: Nullable<RenderTargetWrapper> = null;\r\n private _options: IProceduralTextureCreationOptions;\r\n\r\n /**\r\n * Instantiates a new procedural texture.\r\n * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.\r\n * This is the base class of any Procedural texture and contains most of the shareable code.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/proceduralTextures\r\n * @param name Define the name of the texture\r\n * @param size Define the size of the texture to create\r\n * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later:\r\n * * object: \\{ fragmentElement: \"fragmentShaderCode\" \\}, used with shader code in script tags\r\n * * object: \\{ fragmentSource: \"fragment shader code string\" \\}, the string contains the shader code\r\n * * string: the string contains a name \"XXX\" to lookup in Effect.ShadersStore[\"XXXFragmentShader\"]\r\n * @param scene Define the scene the texture belongs to\r\n * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture\r\n * @param generateMipMaps Define if the texture should creates mip maps or not\r\n * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)\r\n * @param textureType The FBO internal texture type\r\n */\r\n constructor(\r\n name: string,\r\n size: TextureSize,\r\n fragment: any,\r\n scene: Nullable<Scene>,\r\n fallbackTexture: Nullable<Texture> | IProceduralTextureCreationOptions = null,\r\n generateMipMaps = true,\r\n isCube = false,\r\n textureType = Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n ) {\r\n super(null, scene, !generateMipMaps);\r\n\r\n if (fallbackTexture !== null && !(fallbackTexture instanceof Texture)) {\r\n this._options = fallbackTexture;\r\n this._fallbackTexture = fallbackTexture.fallbackTexture ?? null;\r\n } else {\r\n this._options = {};\r\n this._fallbackTexture = fallbackTexture;\r\n }\r\n\r\n this._shaderLanguage = this._options.shaderLanguage ?? ShaderLanguage.GLSL;\r\n\r\n scene = this.getScene() || EngineStore.LastCreatedScene!;\r\n let component = scene._getComponent(SceneComponentConstants.NAME_PROCEDURALTEXTURE);\r\n if (!component) {\r\n component = new ProceduralTextureSceneComponent(scene);\r\n scene._addComponent(component);\r\n }\r\n scene.proceduralTextures.push(this);\r\n\r\n this._fullEngine = scene.getEngine();\r\n\r\n this.name = name;\r\n this.isRenderTarget = true;\r\n this._size = size;\r\n this._textureType = textureType;\r\n this._generateMipMaps = generateMipMaps;\r\n this._drawWrapper = new DrawWrapper(this._fullEngine);\r\n\r\n this.setFragment(fragment);\r\n\r\n const rtWrapper = this._createRtWrapper(isCube, size, generateMipMaps, textureType);\r\n this._texture = rtWrapper.texture;\r\n\r\n // VBO\r\n const vertices = [];\r\n vertices.push(1, 1);\r\n vertices.push(-1, 1);\r\n vertices.push(-1, -1);\r\n vertices.push(1, -1);\r\n\r\n this._vertexBuffers[VertexBuffer.PositionKind] = new VertexBuffer(this._fullEngine, vertices, VertexBuffer.PositionKind, false, false, 2);\r\n\r\n this._createIndexBuffer();\r\n }\r\n\r\n private _createRtWrapper(isCube: boolean, size: TextureSize, generateMipMaps: boolean, textureType: number) {\r\n if (isCube) {\r\n this._rtWrapper = this._fullEngine.createRenderTargetCubeTexture(size as number, {\r\n generateMipMaps: generateMipMaps,\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n type: textureType,\r\n ...this._options,\r\n });\r\n this.setFloat(\"face\", 0);\r\n } else {\r\n this._rtWrapper = this._fullEngine.createRenderTargetTexture(size, {\r\n generateMipMaps: generateMipMaps,\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n type: textureType,\r\n ...this._options,\r\n });\r\n if (this._rtWrapper.is3D) {\r\n this.setFloat(\"layer\", 0);\r\n this.setInt(\"layerNum\", 0);\r\n }\r\n }\r\n return this._rtWrapper;\r\n }\r\n\r\n /**\r\n * The effect that is created when initializing the post process.\r\n * @returns The created effect corresponding the postprocess.\r\n */\r\n public getEffect(): Effect {\r\n return this._drawWrapper.effect!;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _setEffect(effect: Effect) {\r\n this._drawWrapper.effect = effect;\r\n }\r\n\r\n /**\r\n * Gets texture content (Use this function wisely as reading from a texture can be slow)\r\n * @returns an ArrayBufferView promise (Uint8Array or Float32Array)\r\n */\r\n public getContent(): Nullable<Promise<ArrayBufferView>> {\r\n if (this._contentData && this._frameId === this._contentUpdateId) {\r\n return this._contentData;\r\n }\r\n\r\n if (this._contentData) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this._contentData.then((buffer) => {\r\n this._contentData = this.readPixels(0, 0, buffer);\r\n this._contentUpdateId = this._frameId;\r\n });\r\n } else {\r\n this._contentData = this.readPixels(0, 0);\r\n this._contentUpdateId = this._frameId;\r\n }\r\n\r\n return this._contentData;\r\n }\r\n\r\n private _createIndexBuffer(): void {\r\n const engine = this._fullEngine;\r\n\r\n // Indices\r\n const indices = [];\r\n indices.push(0);\r\n indices.push(1);\r\n indices.push(2);\r\n\r\n indices.push(0);\r\n indices.push(2);\r\n indices.push(3);\r\n\r\n this._indexBuffer = engine.createIndexBuffer(indices);\r\n }\r\n\r\n /** @internal */\r\n public override _rebuild(): void {\r\n const vb = this._vertexBuffers[VertexBuffer.PositionKind];\r\n\r\n if (vb) {\r\n vb._rebuild();\r\n }\r\n\r\n this._createIndexBuffer();\r\n\r\n if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {\r\n this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;\r\n }\r\n }\r\n\r\n /**\r\n * Resets the texture in order to recreate its associated resources.\r\n * This can be called in case of context loss or if you change the shader code and need to regenerate the texture with the new code\r\n */\r\n public reset(): void {\r\n this._drawWrapper.effect?.dispose();\r\n this._drawWrapper.effect = null;\r\n this._cachedDefines = null;\r\n }\r\n\r\n protected _getDefines(): string {\r\n return this.defines;\r\n }\r\n\r\n /**\r\n * Executes a function when the texture will be ready to be drawn.\r\n * @param func The callback to be used.\r\n */\r\n public executeWhenReady(func: (texture: ProceduralTexture) => void): void {\r\n if (this.isReady()) {\r\n func(this);\r\n return;\r\n }\r\n\r\n const effect = this.getEffect();\r\n if (effect) {\r\n effect.executeWhenCompiled(() => {\r\n func(this);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Is the texture ready to be used ? (rendered at least once)\r\n * @returns true if ready, otherwise, false.\r\n */\r\n public override isReady(): boolean {\r\n const engine = this._fullEngine;\r\n\r\n if (this.nodeMaterialSource) {\r\n return this._drawWrapper.effect!.isReady();\r\n }\r\n\r\n if (!this._fragment) {\r\n return false;\r\n }\r\n\r\n if (this._fallbackTextureUsed) {\r\n return true;\r\n }\r\n\r\n if (!this._texture) {\r\n return false;\r\n }\r\n\r\n const defines = this._getDefines();\r\n if (this._drawWrapper.effect && defines === this._cachedDefines && this._drawWrapper.effect.isReady()) {\r\n return true;\r\n }\r\n\r\n const shaders = {\r\n vertex: \"procedural\",\r\n fragmentElement: this._fragment.fragmentElement,\r\n fragmentSource: this._fragment.fragmentSource,\r\n fragment: typeof this._fragment === \"string\" ? this._fragment : undefined,\r\n };\r\n\r\n if (this._cachedDefines !== defines) {\r\n this._cachedDefines = defines;\r\n\r\n this._drawWrapper.effect = engine.createEffect(\r\n shaders,\r\n [VertexBuffer.PositionKind],\r\n this._uniforms,\r\n this._samplers,\r\n defines,\r\n undefined,\r\n undefined,\r\n () => {\r\n this._rtWrapper?.dispose();\r\n this._rtWrapper = this._texture = null;\r\n\r\n if (this._fallbackTexture) {\r\n this._texture = this._fallbackTexture._texture;\r\n\r\n if (this._texture) {\r\n this._texture.incrementReferences();\r\n }\r\n }\r\n\r\n this._fallbackTextureUsed = true;\r\n },\r\n undefined,\r\n this._shaderLanguage,\r\n async () => {\r\n if (this._options.extraInitializationsAsync) {\r\n if (this.shaderLanguage === ShaderLanguage.WGSL) {\r\n await Promise.all([import(\"../../../ShadersWGSL/procedural.vertex\"), this._options.extraInitializationsAsync()]);\r\n } else {\r\n await Promise.all([import(\"../../../Shaders/procedural.vertex\"), this._options.extraInitializationsAsync()]);\r\n }\r\n } else {\r\n if (this.shaderLanguage === ShaderLanguage.WGSL) {\r\n await import(\"../../../ShadersWGSL/procedural.vertex\");\r\n } else {\r\n await import(\"../../../Shaders/procedural.vertex\");\r\n }\r\n }\r\n }\r\n );\r\n }\r\n\r\n return this._drawWrapper.effect!.isReady();\r\n }\r\n\r\n /**\r\n * Resets the refresh counter of the texture and start bak from scratch.\r\n * Could be useful to regenerate the texture if it is setup to render only once.\r\n */\r\n public resetRefreshCounter(): void {\r\n this._currentRefreshId = -1;\r\n }\r\n\r\n /**\r\n * Set the fragment shader to use in order to render the texture.\r\n * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.\r\n */\r\n public setFragment(fragment: any) {\r\n this._fragment = fragment;\r\n }\r\n\r\n /**\r\n * Define the refresh rate of the texture or the rendering frequency.\r\n * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...\r\n */\r\n @serialize()\r\n public get refreshRate(): number {\r\n return this._refreshRate;\r\n }\r\n\r\n public set refreshRate(value: number) {\r\n this._refreshRate = value;\r\n this.resetRefreshCounter();\r\n }\r\n\r\n /** @internal */\r\n public _shouldRender(): boolean {\r\n if (!this.isEnabled || !this.isReady() || !this._texture) {\r\n if (this._texture) {\r\n this._texture.isReady = false;\r\n }\r\n return false;\r\n }\r\n\r\n if (this._fallbackTextureUsed) {\r\n return false;\r\n }\r\n\r\n if (this._currentRefreshId === -1) {\r\n // At least render once\r\n this._currentRefreshId = 1;\r\n this._frameId++;\r\n return true;\r\n }\r\n\r\n if (this.refreshRate === this._currentRefreshId) {\r\n this._currentRefreshId = 1;\r\n this._frameId++;\r\n return true;\r\n }\r\n\r\n this._currentRefreshId++;\r\n return false;\r\n }\r\n\r\n /**\r\n * Get the size the texture is rendering at.\r\n * @returns the size (on cube texture it is always squared)\r\n */\r\n public getRenderSize(): TextureSize {\r\n return this._size;\r\n }\r\n\r\n /**\r\n * Resize the texture to new value.\r\n * @param size Define the new size the texture should have\r\n * @param generateMipMaps Define whether the new texture should create mip maps\r\n */\r\n public resize(size: TextureSize, generateMipMaps: boolean): void {\r\n if (this._fallbackTextureUsed || !this._rtWrapper || !this._texture) {\r\n return;\r\n }\r\n\r\n const isCube = this._texture.isCube;\r\n this._rtWrapper.dispose();\r\n\r\n const rtWrapper = this._createRtWrapper(isCube, size, generateMipMaps, this._textureType);\r\n this._texture = rtWrapper.texture;\r\n\r\n // Update properties\r\n this._size = size;\r\n this._generateMipMaps = generateMipMaps;\r\n }\r\n\r\n private _checkUniform(uniformName: string): void {\r\n if (this._uniforms.indexOf(uniformName) === -1) {\r\n this._uniforms.push(uniformName);\r\n }\r\n }\r\n\r\n /**\r\n * Set a texture in the shader program used to render.\r\n * @param name Define the name of the uniform samplers as defined in the shader\r\n * @param texture Define the texture to bind to this sampler\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setTexture(name: string, texture: ThinTexture): ProceduralTexture {\r\n if (this._samplers.indexOf(name) === -1) {\r\n this._samplers.push(name);\r\n }\r\n this._textures[name] = texture;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a float in the shader.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setFloat(name: string, value: number): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._floats[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a int in the shader.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setInt(name: string, value: number): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._ints[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set an array of floats in the shader.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setFloats(name: string, value: number[]): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._floatsArrays[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a vec3 in the shader from a Color3.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setColor3(name: string, value: Color3): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._colors3[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a vec4 in the shader from a Color4.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setColor4(name: string, value: Color4): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._colors4[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a vec2 in the shader from a Vector2.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setVector2(name: string, value: Vector2): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._vectors2[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a vec3 in the shader from a Vector3.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setVector3(name: string, value: Vector3): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._vectors3[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a vec4 in the shader from a Vector4.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setVector4(name: string, value: Vector4): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._vectors4[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Set a mat4 in the shader from a MAtrix.\r\n * @param name Define the name of the uniform as defined in the shader\r\n * @param value Define the value to give to the uniform\r\n * @returns the texture itself allowing \"fluent\" like uniform updates\r\n */\r\n public setMatrix(name: string, value: Matrix): ProceduralTexture {\r\n this._checkUniform(name);\r\n this._matrices[name] = value;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Render the texture to its associated render target.\r\n * @param useCameraPostProcess Define if camera post process should be applied to the texture\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public render(useCameraPostProcess?: boolean): void {\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return;\r\n }\r\n\r\n const engine = this._fullEngine;\r\n\r\n // Render\r\n engine.enableEffect(this._drawWrapper);\r\n this.onBeforeGenerationObservable.notifyObservers(this);\r\n engine.setState(false);\r\n\r\n if (!this.nodeMaterialSource) {\r\n // Texture\r\n for (const name in this._textures) {\r\n this._drawWrapper.effect!.setTexture(name, this._textures[name]);\r\n }\r\n\r\n // Float\r\n for (const name in this._ints) {\r\n this._drawWrapper.effect!.setInt(name, this._ints[name]);\r\n }\r\n\r\n // Float\r\n for (const name in this._floats) {\r\n this._drawWrapper.effect!.setFloat(name, this._floats[name]);\r\n }\r\n\r\n // Floats\r\n for (const name in this._floatsArrays) {\r\n this._drawWrapper.effect!.setArray(name, this._floatsArrays[name]);\r\n }\r\n\r\n // Color3\r\n for (const name in this._colors3) {\r\n this._drawWrapper.effect!.setColor3(name, this._colors3[name]);\r\n }\r\n\r\n // Color4\r\n for (const name in this._colors4) {\r\n const color = this._colors4[name];\r\n this._drawWrapper.effect!.setFloat4(name, color.r, color.g, color.b, color.a);\r\n }\r\n\r\n // Vector2\r\n for (const name in this._vectors2) {\r\n this._drawWrapper.effect!.setVector2(name, this._vectors2[name]);\r\n }\r\n\r\n // Vector3\r\n for (const name in this._vectors3) {\r\n this._drawWrapper.effect!.setVector3(name, this._vectors3[name]);\r\n }\r\n\r\n // Vector4\r\n for (const name in this._vectors4) {\r\n this._drawWrapper.effect!.setVector4(name, this._vectors4[name]);\r\n }\r\n\r\n // Matrix\r\n for (const name in this._matrices) {\r\n this._drawWrapper.effect!.setMatrix(name, this._matrices[name]);\r\n }\r\n }\r\n\r\n if (!this._texture || !this._rtWrapper) {\r\n return;\r\n }\r\n\r\n if (engine._enableGPUDebugMarkers) {\r\n engine.restoreDefaultFramebuffer();\r\n engine._debugPushGroup(`procedural texture generation for ${this.name}`);\r\n }\r\n\r\n const viewPort = engine.currentViewport;\r\n if (this.isCube) {\r\n for (let face = 0; face < 6; face++) {\r\n engine.bindFramebuffer(this._rtWrapper, face, undefined, undefined, true);\r\n\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect!);\r\n\r\n this._drawWrapper.effect!.setFloat(\"face\", face);\r\n\r\n // Clear\r\n if (this.autoClear) {\r\n engine.clear(scene.clearColor, true, false, false);\r\n }\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.TriangleFillMode, 0, 6);\r\n // Unbind and restore viewport\r\n engine.unBindFramebuffer(this._rtWrapper, true);\r\n }\r\n } else {\r\n let numLayers = 1;\r\n if (this._rtWrapper.is3D) {\r\n numLayers = this._rtWrapper.depth;\r\n } else if (this._rtWrapper.is2DArray) {\r\n numLayers = this._rtWrapper.layers;\r\n }\r\n for (let layer = 0; layer < numLayers; layer++) {\r\n engine.bindFramebuffer(this._rtWrapper, 0, undefined, undefined, true, 0, layer);\r\n\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect!);\r\n\r\n if (this._rtWrapper.is3D || this._rtWrapper.is2DArray) {\r\n this._drawWrapper.effect?.setFloat(\"layer\", numLayers !== 1 ? layer / (numLayers - 1) : 0);\r\n this._drawWrapper.effect?.setInt(\"layerNum\", layer);\r\n for (const name in this._textures) {\r\n this._drawWrapper.effect!.setTexture(name, this._textures[name]);\r\n }\r\n }\r\n\r\n // Clear\r\n if (this.autoClear) {\r\n engine.clear(scene.clearColor, true, false, false);\r\n }\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.TriangleFillMode, 0, 6);\r\n // Unbind and restore viewport\r\n engine.unBindFramebuffer(this._rtWrapper, !this._generateMipMaps);\r\n }\r\n }\r\n\r\n if (viewPort) {\r\n engine.setViewport(viewPort);\r\n }\r\n\r\n // Mipmaps\r\n if (this.isCube) {\r\n engine.generateMipMapsForCubemap(this._texture, true);\r\n }\r\n\r\n if (engine._enableGPUDebugMarkers) {\r\n engine._debugPopGroup();\r\n }\r\n\r\n if (this.onGenerated) {\r\n this.onGenerated();\r\n }\r\n\r\n this.onGeneratedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Clone the texture.\r\n * @returns the cloned texture\r\n */\r\n public override clone(): ProceduralTexture {\r\n const textureSize = this.getSize();\r\n const newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, <Scene>this.getScene(), this._fallbackTexture, this._generateMipMaps);\r\n\r\n // Base texture\r\n newTexture.hasAlpha = this.hasAlpha;\r\n newTexture.level = this.level;\r\n\r\n // RenderTarget Texture\r\n newTexture.coordinatesMode = this.coordinatesMode;\r\n\r\n return newTexture;\r\n }\r\n\r\n /**\r\n * Dispose the texture and release its associated resources.\r\n */\r\n public override dispose(): void {\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return;\r\n }\r\n\r\n const index = scene.proceduralTextures.indexOf(this);\r\n\r\n if (index >= 0) {\r\n scene.proceduralTextures.splice(index, 1);\r\n }\r\n\r\n const vertexBuffer = this._vertexBuffers[VertexBuffer.PositionKind];\r\n if (vertexBuffer) {\r\n vertexBuffer.dispose();\r\n this._vertexBuffers[VertexBuffer.PositionKind] = null;\r\n }\r\n\r\n if (this._indexBuffer && this._fullEngine._releaseBuffer(this._indexBuffer)) {\r\n this._indexBuffer = null;\r\n }\r\n\r\n this.onGeneratedObservable.clear();\r\n this.onBeforeGenerationObservable.clear();\r\n\r\n super.dispose();\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ProceduralTexture\", ProceduralTexture);\r\n"]}
|
|
@@ -39,7 +39,7 @@ export declare class DynamicTexture extends Texture {
|
|
|
39
39
|
* @param name defines the name of the texture
|
|
40
40
|
* @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
|
|
41
41
|
* @param scene defines the scene where you want the texture
|
|
42
|
-
* @param generateMipMaps defines the use of
|
|
42
|
+
* @param generateMipMaps defines the use of MipMaps or not (default is false)
|
|
43
43
|
* @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
|
|
44
44
|
* @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
|
|
45
45
|
* @param invertY defines if the texture needs to be inverted on the y axis during loading
|
|
@@ -98,7 +98,7 @@ export declare class DynamicTexture extends Texture {
|
|
|
98
98
|
* @param y defines the placement of the text from the top when invertY is true and from the bottom when false
|
|
99
99
|
* @param font defines the font to be used with font-style, font-size, font-name
|
|
100
100
|
* @param color defines the color used for the text
|
|
101
|
-
* @param fillColor defines the color for the canvas, use null to not overwrite canvas (this
|
|
101
|
+
* @param fillColor defines the color for the canvas, use null to not overwrite canvas (this blends with the background to replace, use the clear function)
|
|
102
102
|
* @param invertY defines the direction for the Y axis (default is true - y increases downwards)
|
|
103
103
|
* @param update defines whether texture is immediately update (default is true)
|
|
104
104
|
*/
|
|
@@ -124,7 +124,7 @@ export class DynamicTexture extends Texture {
|
|
|
124
124
|
* @param y defines the placement of the text from the top when invertY is true and from the bottom when false
|
|
125
125
|
* @param font defines the font to be used with font-style, font-size, font-name
|
|
126
126
|
* @param color defines the color used for the text
|
|
127
|
-
* @param fillColor defines the color for the canvas, use null to not overwrite canvas (this
|
|
127
|
+
* @param fillColor defines the color for the canvas, use null to not overwrite canvas (this blends with the background to replace, use the clear function)
|
|
128
128
|
* @param invertY defines the direction for the Y axis (default is true - y increases downwards)
|
|
129
129
|
* @param update defines whether texture is immediately update (default is true)
|
|
130
130
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic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AAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAE5F,eAAe;QACf,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QACpC,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAE9B,kBAAkB;QAClB,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAE9B,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;OAGG;IACa,SAAS;QACrB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;QAClF,CAAC;QAED,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAC9C,IAAI,cAAc,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAChD,mBAAmB,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QAChE,CAAC;QAED,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC5C,mBAAmB,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QAErD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,MAAqD;QACjF,OAAQ,MAA4B,CAAC,SAAS,KAAK,SAAS,CAAC;IACjE,CAAC;IAED,gBAAgB;IACA,QAAQ;QACpB,IAAI,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import { Logger } from \"../../Misc/logger\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { ISize } from \"../../Maths/math.size\";\r\nimport type { ITextureCreationOptions } from \"../../Materials/Textures/texture\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { ICanvas, ICanvasRenderingContext } from \"../../Engines/ICanvas\";\r\n\r\nimport \"../../Engines/Extensions/engine.dynamicTexture\";\r\n\r\n/**\r\n * Interface defining options used to create a dynamic texture\r\n */\r\nexport interface IDynamicTextureOptions extends ITextureCreationOptions {\r\n /** defines the width of the texture (default: 0) */\r\n width?: number;\r\n /** defines the height of the texture (default: 0) */\r\n height?: number;\r\n /** defines the hosting scene (default: null) */\r\n scene?: Nullable<Scene>;\r\n}\r\n\r\n/**\r\n * A class extending Texture allowing drawing on a texture\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/dynamicTexture\r\n */\r\nexport class DynamicTexture extends Texture {\r\n private _generateMipMaps: boolean;\r\n private _canvas: ICanvas;\r\n private _ownCanvas: boolean;\r\n private _context: ICanvasRenderingContext;\r\n\r\n /**\r\n * Creates a DynamicTexture\r\n * @param name defines the name of the texture\r\n * @param canvasOrSize provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height\r\n * @param options The options to be used when constructing the dynamic texture\r\n */\r\n constructor(name: string, canvasOrSize: ICanvas | { width: number; height: number } | number, options?: IDynamicTextureOptions);\r\n\r\n /**\r\n * Creates a DynamicTexture\r\n * @param name defines the name of the texture\r\n * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height\r\n * @param scene defines the scene where you want the texture\r\n * @param generateMipMaps defines the use of MinMaps or not (default is false)\r\n * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)\r\n * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)\r\n * @param invertY defines if the texture needs to be inverted on the y axis during loading\r\n */\r\n constructor(\r\n name: string,\r\n options: ICanvas | { width: number; height: number } | number,\r\n scene?: Nullable<Scene>,\r\n generateMipMaps?: boolean,\r\n samplingMode?: number,\r\n format?: number,\r\n invertY?: boolean\r\n );\r\n\r\n /** @internal */\r\n constructor(\r\n name: string,\r\n canvasOrSize: ICanvas | { width: number; height: number } | number,\r\n sceneOrOptions?: Nullable<Scene> | IDynamicTextureOptions,\r\n generateMipMaps?: boolean,\r\n samplingMode?: number,\r\n format?: number,\r\n invertY?: boolean\r\n );\r\n\r\n /** @internal */\r\n constructor(\r\n name: string,\r\n canvasOrSize: ICanvas | { width: number; height: number } | number,\r\n sceneOrOptions?: Nullable<Scene> | IDynamicTextureOptions,\r\n generateMipMaps: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n format: number = Constants.TEXTUREFORMAT_RGBA,\r\n invertY?: boolean\r\n ) {\r\n const isScene = !sceneOrOptions || (sceneOrOptions as Scene)._isScene;\r\n const scene = isScene ? (sceneOrOptions as Scene) : (sceneOrOptions as IDynamicTextureOptions)?.scene;\r\n const noMipmap = isScene ? !generateMipMaps : (sceneOrOptions as IDynamicTextureOptions);\r\n\r\n super(null, scene, noMipmap, invertY, samplingMode, undefined, undefined, undefined, undefined, format);\r\n\r\n this.name = name;\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n\r\n this._generateMipMaps = generateMipMaps;\r\n\r\n const engine = this._getEngine();\r\n if (!engine) {\r\n return;\r\n }\r\n\r\n if ((canvasOrSize as ICanvas).getContext) {\r\n this._canvas = canvasOrSize as ICanvas;\r\n this._ownCanvas = false;\r\n this._texture = engine.createDynamicTexture(this._canvas.width, this._canvas.height, generateMipMaps, samplingMode);\r\n } else {\r\n this._canvas = engine.createCanvas(1, 1);\r\n this._ownCanvas = true;\r\n\r\n const optionsAsSize = canvasOrSize as ISize;\r\n if (optionsAsSize.width || optionsAsSize.width === 0) {\r\n this._texture = engine.createDynamicTexture(optionsAsSize.width, optionsAsSize.height, generateMipMaps, samplingMode);\r\n } else {\r\n this._texture = engine.createDynamicTexture(canvasOrSize as number, canvasOrSize as number, generateMipMaps, samplingMode);\r\n }\r\n }\r\n\r\n const textureSize = this.getSize();\r\n\r\n if (this._canvas.width !== textureSize.width) {\r\n this._canvas.width = textureSize.width;\r\n }\r\n if (this._canvas.height !== textureSize.height) {\r\n this._canvas.height = textureSize.height;\r\n }\r\n this._context = this._canvas.getContext(\"2d\");\r\n }\r\n\r\n /**\r\n * Get the current class name of the texture useful for serialization or dynamic coding.\r\n * @returns \"DynamicTexture\"\r\n */\r\n public override getClassName(): string {\r\n return \"DynamicTexture\";\r\n }\r\n\r\n /**\r\n * Gets the current state of canRescale\r\n */\r\n public override get canRescale(): boolean {\r\n return true;\r\n }\r\n\r\n private _recreate(textureSize: ISize): void {\r\n this._canvas.width = textureSize.width;\r\n this._canvas.height = textureSize.height;\r\n\r\n this.releaseInternalTexture();\r\n\r\n this._texture = this._getEngine()!.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);\r\n }\r\n\r\n /**\r\n * Scales the texture\r\n * @param ratio the scale factor to apply to both width and height\r\n */\r\n public override scale(ratio: number): void {\r\n const textureSize = this.getSize();\r\n\r\n textureSize.width *= ratio;\r\n textureSize.height *= ratio;\r\n\r\n this._recreate(textureSize);\r\n }\r\n\r\n /**\r\n * Resizes the texture\r\n * @param width the new width\r\n * @param height the new height\r\n */\r\n public scaleTo(width: number, height: number): void {\r\n const textureSize = this.getSize();\r\n\r\n textureSize.width = width;\r\n textureSize.height = height;\r\n\r\n this._recreate(textureSize);\r\n }\r\n\r\n /**\r\n * Gets the context of the canvas used by the texture\r\n * @returns the canvas context of the dynamic texture\r\n */\r\n public getContext(): ICanvasRenderingContext {\r\n return this._context;\r\n }\r\n\r\n /**\r\n * Clears the texture\r\n * @param clearColor Defines the clear color to use\r\n */\r\n public clear(clearColor?: string): void {\r\n const size = this.getSize();\r\n if (clearColor) {\r\n this._context.fillStyle = clearColor;\r\n }\r\n this._context.clearRect(0, 0, size.width, size.height);\r\n }\r\n\r\n /**\r\n * Updates the texture\r\n * @param invertY defines the direction for the Y axis (default is true - y increases downwards)\r\n * @param premulAlpha defines if alpha is stored as premultiplied (default is false)\r\n * @param allowGPUOptimization true to allow some specific GPU optimizations (subject to engine feature \"allowGPUOptimizationsForGUI\" being true)\r\n */\r\n public update(invertY?: boolean, premulAlpha = false, allowGPUOptimization = false): void {\r\n // When disposed, this._texture will be null.\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._getEngine()!.updateDynamicTexture(\r\n this._texture,\r\n this._canvas,\r\n invertY === undefined ? true : invertY,\r\n premulAlpha,\r\n this._format || undefined,\r\n undefined,\r\n allowGPUOptimization\r\n );\r\n }\r\n\r\n /**\r\n * Draws text onto the texture\r\n * @param text defines the text to be drawn\r\n * @param x defines the placement of the text from the left\r\n * @param y defines the placement of the text from the top when invertY is true and from the bottom when false\r\n * @param font defines the font to be used with font-style, font-size, font-name\r\n * @param color defines the color used for the text\r\n * @param fillColor defines the color for the canvas, use null to not overwrite canvas (this bleands with the background to replace, use the clear function)\r\n * @param invertY defines the direction for the Y axis (default is true - y increases downwards)\r\n * @param update defines whether texture is immediately update (default is true)\r\n */\r\n public drawText(\r\n text: string,\r\n x: number | null | undefined,\r\n y: number | null | undefined,\r\n font: string,\r\n color: string | null,\r\n fillColor: string | null,\r\n invertY?: boolean,\r\n update = true\r\n ) {\r\n const size = this.getSize();\r\n if (fillColor) {\r\n this._context.fillStyle = fillColor;\r\n this._context.fillRect(0, 0, size.width, size.height);\r\n }\r\n\r\n this._context.font = font;\r\n if (x === null || x === undefined) {\r\n const textSize = this._context.measureText(text);\r\n x = (size.width - textSize.width) / 2;\r\n }\r\n if (y === null || y === undefined) {\r\n const fontSize = parseInt(font.replace(/\\D/g, \"\"));\r\n y = size.height / 2 + fontSize / 3.65;\r\n }\r\n\r\n this._context.fillStyle = color || \"\";\r\n this._context.fillText(text, x, y);\r\n\r\n if (update) {\r\n this.update(invertY);\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the dynamic texture.\r\n */\r\n public override dispose(): void {\r\n super.dispose();\r\n\r\n if (this._ownCanvas) {\r\n this._canvas?.remove?.();\r\n }\r\n (this._canvas as any) = null;\r\n (this._context as any) = null;\r\n }\r\n\r\n /**\r\n * Clones the texture\r\n * @returns the clone of the texture.\r\n */\r\n public override clone(): DynamicTexture {\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return this;\r\n }\r\n\r\n const textureSize = this.getSize();\r\n const newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);\r\n\r\n // Base texture\r\n newTexture.hasAlpha = this.hasAlpha;\r\n newTexture.level = this.level;\r\n\r\n // Dynamic Texture\r\n newTexture.wrapU = this.wrapU;\r\n newTexture.wrapV = this.wrapV;\r\n\r\n return newTexture;\r\n }\r\n\r\n /**\r\n * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized\r\n * @returns a serialized dynamic texture object\r\n */\r\n public override serialize(): any {\r\n const scene = this.getScene();\r\n if (scene && !scene.isReady()) {\r\n Logger.Warn(\"The scene must be ready before serializing the dynamic texture\");\r\n }\r\n\r\n const serializationObject = super.serialize();\r\n if (DynamicTexture._IsCanvasElement(this._canvas)) {\r\n serializationObject.base64String = this._canvas.toDataURL();\r\n }\r\n\r\n serializationObject.invertY = this._invertY;\r\n serializationObject.samplingMode = this.samplingMode;\r\n\r\n return serializationObject;\r\n }\r\n\r\n private static _IsCanvasElement(canvas: HTMLCanvasElement | OffscreenCanvas | ICanvas): canvas is HTMLCanvasElement {\r\n return (canvas as HTMLCanvasElement).toDataURL !== undefined;\r\n }\r\n\r\n /** @internal */\r\n public override _rebuild(): void {\r\n this.update();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"dynamicTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/dynamicTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAK3C,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;A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kB;QAClB,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAE9B,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;OAGG;IACa,SAAS;QACrB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;QAClF,CAAC;QAED,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAC9C,IAAI,cAAc,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAChD,mBAAmB,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QAChE,CAAC;QAED,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC5C,mBAAmB,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QAErD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,MAAqD;QACjF,OAAQ,MAA4B,CAAC,SAAS,KAAK,SAAS,CAAC;IACjE,CAAC;IAED,gBAAgB;IACA,QAAQ;QACpB,IAAI,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import { Logger } from \"../../Misc/logger\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { ISize } from \"../../Maths/math.size\";\r\nimport type { ITextureCreationOptions } from \"../../Materials/Textures/texture\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { ICanvas, ICanvasRenderingContext } from \"../../Engines/ICanvas\";\r\n\r\nimport \"../../Engines/Extensions/engine.dynamicTexture\";\r\n\r\n/**\r\n * Interface defining options used to create a dynamic texture\r\n */\r\nexport interface IDynamicTextureOptions extends ITextureCreationOptions {\r\n /** defines the width of the texture (default: 0) */\r\n width?: number;\r\n /** defines the height of the texture (default: 0) */\r\n height?: number;\r\n /** defines the hosting scene (default: null) */\r\n scene?: Nullable<Scene>;\r\n}\r\n\r\n/**\r\n * A class extending Texture allowing drawing on a texture\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/dynamicTexture\r\n */\r\nexport class DynamicTexture extends Texture {\r\n private _generateMipMaps: boolean;\r\n private _canvas: ICanvas;\r\n private _ownCanvas: boolean;\r\n private _context: ICanvasRenderingContext;\r\n\r\n /**\r\n * Creates a DynamicTexture\r\n * @param name defines the name of the texture\r\n * @param canvasOrSize provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height\r\n * @param options The options to be used when constructing the dynamic texture\r\n */\r\n constructor(name: string, canvasOrSize: ICanvas | { width: number; height: number } | number, options?: IDynamicTextureOptions);\r\n\r\n /**\r\n * Creates a DynamicTexture\r\n * @param name defines the name of the texture\r\n * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height\r\n * @param scene defines the scene where you want the texture\r\n * @param generateMipMaps defines the use of MipMaps or not (default is false)\r\n * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)\r\n * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)\r\n * @param invertY defines if the texture needs to be inverted on the y axis during loading\r\n */\r\n constructor(\r\n name: string,\r\n options: ICanvas | { width: number; height: number } | number,\r\n scene?: Nullable<Scene>,\r\n generateMipMaps?: boolean,\r\n samplingMode?: number,\r\n format?: number,\r\n invertY?: boolean\r\n );\r\n\r\n /** @internal */\r\n constructor(\r\n name: string,\r\n canvasOrSize: ICanvas | { width: number; height: number } | number,\r\n sceneOrOptions?: Nullable<Scene> | IDynamicTextureOptions,\r\n generateMipMaps?: boolean,\r\n samplingMode?: number,\r\n format?: number,\r\n invertY?: boolean\r\n );\r\n\r\n /** @internal */\r\n constructor(\r\n name: string,\r\n canvasOrSize: ICanvas | { width: number; height: number } | number,\r\n sceneOrOptions?: Nullable<Scene> | IDynamicTextureOptions,\r\n generateMipMaps: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n format: number = Constants.TEXTUREFORMAT_RGBA,\r\n invertY?: boolean\r\n ) {\r\n const isScene = !sceneOrOptions || (sceneOrOptions as Scene)._isScene;\r\n const scene = isScene ? (sceneOrOptions as Scene) : (sceneOrOptions as IDynamicTextureOptions)?.scene;\r\n const noMipmap = isScene ? !generateMipMaps : (sceneOrOptions as IDynamicTextureOptions);\r\n\r\n super(null, scene, noMipmap, invertY, samplingMode, undefined, undefined, undefined, undefined, format);\r\n\r\n this.name = name;\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n\r\n this._generateMipMaps = generateMipMaps;\r\n\r\n const engine = this._getEngine();\r\n if (!engine) {\r\n return;\r\n }\r\n\r\n if ((canvasOrSize as ICanvas).getContext) {\r\n this._canvas = canvasOrSize as ICanvas;\r\n this._ownCanvas = false;\r\n this._texture = engine.createDynamicTexture(this._canvas.width, this._canvas.height, generateMipMaps, samplingMode);\r\n } else {\r\n this._canvas = engine.createCanvas(1, 1);\r\n this._ownCanvas = true;\r\n\r\n const optionsAsSize = canvasOrSize as ISize;\r\n if (optionsAsSize.width || optionsAsSize.width === 0) {\r\n this._texture = engine.createDynamicTexture(optionsAsSize.width, optionsAsSize.height, generateMipMaps, samplingMode);\r\n } else {\r\n this._texture = engine.createDynamicTexture(canvasOrSize as number, canvasOrSize as number, generateMipMaps, samplingMode);\r\n }\r\n }\r\n\r\n const textureSize = this.getSize();\r\n\r\n if (this._canvas.width !== textureSize.width) {\r\n this._canvas.width = textureSize.width;\r\n }\r\n if (this._canvas.height !== textureSize.height) {\r\n this._canvas.height = textureSize.height;\r\n }\r\n this._context = this._canvas.getContext(\"2d\");\r\n }\r\n\r\n /**\r\n * Get the current class name of the texture useful for serialization or dynamic coding.\r\n * @returns \"DynamicTexture\"\r\n */\r\n public override getClassName(): string {\r\n return \"DynamicTexture\";\r\n }\r\n\r\n /**\r\n * Gets the current state of canRescale\r\n */\r\n public override get canRescale(): boolean {\r\n return true;\r\n }\r\n\r\n private _recreate(textureSize: ISize): void {\r\n this._canvas.width = textureSize.width;\r\n this._canvas.height = textureSize.height;\r\n\r\n this.releaseInternalTexture();\r\n\r\n this._texture = this._getEngine()!.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);\r\n }\r\n\r\n /**\r\n * Scales the texture\r\n * @param ratio the scale factor to apply to both width and height\r\n */\r\n public override scale(ratio: number): void {\r\n const textureSize = this.getSize();\r\n\r\n textureSize.width *= ratio;\r\n textureSize.height *= ratio;\r\n\r\n this._recreate(textureSize);\r\n }\r\n\r\n /**\r\n * Resizes the texture\r\n * @param width the new width\r\n * @param height the new height\r\n */\r\n public scaleTo(width: number, height: number): void {\r\n const textureSize = this.getSize();\r\n\r\n textureSize.width = width;\r\n textureSize.height = height;\r\n\r\n this._recreate(textureSize);\r\n }\r\n\r\n /**\r\n * Gets the context of the canvas used by the texture\r\n * @returns the canvas context of the dynamic texture\r\n */\r\n public getContext(): ICanvasRenderingContext {\r\n return this._context;\r\n }\r\n\r\n /**\r\n * Clears the texture\r\n * @param clearColor Defines the clear color to use\r\n */\r\n public clear(clearColor?: string): void {\r\n const size = this.getSize();\r\n if (clearColor) {\r\n this._context.fillStyle = clearColor;\r\n }\r\n this._context.clearRect(0, 0, size.width, size.height);\r\n }\r\n\r\n /**\r\n * Updates the texture\r\n * @param invertY defines the direction for the Y axis (default is true - y increases downwards)\r\n * @param premulAlpha defines if alpha is stored as premultiplied (default is false)\r\n * @param allowGPUOptimization true to allow some specific GPU optimizations (subject to engine feature \"allowGPUOptimizationsForGUI\" being true)\r\n */\r\n public update(invertY?: boolean, premulAlpha = false, allowGPUOptimization = false): void {\r\n // When disposed, this._texture will be null.\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._getEngine()!.updateDynamicTexture(\r\n this._texture,\r\n this._canvas,\r\n invertY === undefined ? true : invertY,\r\n premulAlpha,\r\n this._format || undefined,\r\n undefined,\r\n allowGPUOptimization\r\n );\r\n }\r\n\r\n /**\r\n * Draws text onto the texture\r\n * @param text defines the text to be drawn\r\n * @param x defines the placement of the text from the left\r\n * @param y defines the placement of the text from the top when invertY is true and from the bottom when false\r\n * @param font defines the font to be used with font-style, font-size, font-name\r\n * @param color defines the color used for the text\r\n * @param fillColor defines the color for the canvas, use null to not overwrite canvas (this blends with the background to replace, use the clear function)\r\n * @param invertY defines the direction for the Y axis (default is true - y increases downwards)\r\n * @param update defines whether texture is immediately update (default is true)\r\n */\r\n public drawText(\r\n text: string,\r\n x: number | null | undefined,\r\n y: number | null | undefined,\r\n font: string,\r\n color: string | null,\r\n fillColor: string | null,\r\n invertY?: boolean,\r\n update = true\r\n ) {\r\n const size = this.getSize();\r\n if (fillColor) {\r\n this._context.fillStyle = fillColor;\r\n this._context.fillRect(0, 0, size.width, size.height);\r\n }\r\n\r\n this._context.font = font;\r\n if (x === null || x === undefined) {\r\n const textSize = this._context.measureText(text);\r\n x = (size.width - textSize.width) / 2;\r\n }\r\n if (y === null || y === undefined) {\r\n const fontSize = parseInt(font.replace(/\\D/g, \"\"));\r\n y = size.height / 2 + fontSize / 3.65;\r\n }\r\n\r\n this._context.fillStyle = color || \"\";\r\n this._context.fillText(text, x, y);\r\n\r\n if (update) {\r\n this.update(invertY);\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the dynamic texture.\r\n */\r\n public override dispose(): void {\r\n super.dispose();\r\n\r\n if (this._ownCanvas) {\r\n this._canvas?.remove?.();\r\n }\r\n (this._canvas as any) = null;\r\n (this._context as any) = null;\r\n }\r\n\r\n /**\r\n * Clones the texture\r\n * @returns the clone of the texture.\r\n */\r\n public override clone(): DynamicTexture {\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return this;\r\n }\r\n\r\n const textureSize = this.getSize();\r\n const newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);\r\n\r\n // Base texture\r\n newTexture.hasAlpha = this.hasAlpha;\r\n newTexture.level = this.level;\r\n\r\n // Dynamic Texture\r\n newTexture.wrapU = this.wrapU;\r\n newTexture.wrapV = this.wrapV;\r\n\r\n return newTexture;\r\n }\r\n\r\n /**\r\n * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized\r\n * @returns a serialized dynamic texture object\r\n */\r\n public override serialize(): any {\r\n const scene = this.getScene();\r\n if (scene && !scene.isReady()) {\r\n Logger.Warn(\"The scene must be ready before serializing the dynamic texture\");\r\n }\r\n\r\n const serializationObject = super.serialize();\r\n if (DynamicTexture._IsCanvasElement(this._canvas)) {\r\n serializationObject.base64String = this._canvas.toDataURL();\r\n }\r\n\r\n serializationObject.invertY = this._invertY;\r\n serializationObject.samplingMode = this.samplingMode;\r\n\r\n return serializationObject;\r\n }\r\n\r\n private static _IsCanvasElement(canvas: HTMLCanvasElement | OffscreenCanvas | ICanvas): canvas is HTMLCanvasElement {\r\n return (canvas as HTMLCanvasElement).toDataURL !== undefined;\r\n }\r\n\r\n /** @internal */\r\n public override _rebuild(): void {\r\n this.update();\r\n }\r\n}\r\n"]}
|
|
@@ -106,12 +106,14 @@ export declare class InternalTexture extends TextureSampler {
|
|
|
106
106
|
* Gets a boolean indicating if the texture needs mipmaps generation
|
|
107
107
|
*/
|
|
108
108
|
generateMipMaps: boolean;
|
|
109
|
+
protected _useMipMaps: Nullable<boolean>;
|
|
109
110
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
111
|
+
* Indicates to use the mip maps (if available on the texture).
|
|
112
|
+
* Thanks to this flag, you can instruct the sampler to not sample the mipmaps even if they exist (and if the sampling mode is set to a value that normally samples the mipmaps!)
|
|
113
|
+
* If useMipMaps is null, the value of generateMipMaps is returned by the getter (for backward compatibility)
|
|
112
114
|
*/
|
|
113
|
-
get useMipMaps(): boolean
|
|
114
|
-
set useMipMaps(value: boolean);
|
|
115
|
+
get useMipMaps(): Nullable<boolean>;
|
|
116
|
+
set useMipMaps(value: Nullable<boolean>);
|
|
115
117
|
/**
|
|
116
118
|
* Gets the number of samples used by the texture (WebGL2+ only)
|
|
117
119
|
*/
|
|
@@ -72,14 +72,15 @@ export var InternalTextureSource;
|
|
|
72
72
|
*/
|
|
73
73
|
export class InternalTexture extends TextureSampler {
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
75
|
+
* Indicates to use the mip maps (if available on the texture).
|
|
76
|
+
* Thanks to this flag, you can instruct the sampler to not sample the mipmaps even if they exist (and if the sampling mode is set to a value that normally samples the mipmaps!)
|
|
77
|
+
* If useMipMaps is null, the value of generateMipMaps is returned by the getter (for backward compatibility)
|
|
77
78
|
*/
|
|
78
79
|
get useMipMaps() {
|
|
79
|
-
return this.generateMipMaps;
|
|
80
|
+
return this._useMipMaps === null ? this.generateMipMaps : this._useMipMaps;
|
|
80
81
|
}
|
|
81
82
|
set useMipMaps(value) {
|
|
82
|
-
this.
|
|
83
|
+
this._useMipMaps = value;
|
|
83
84
|
}
|
|
84
85
|
/** Gets the unique id of the internal texture */
|
|
85
86
|
get uniqueId() {
|
|
@@ -138,6 +139,7 @@ export class InternalTexture extends TextureSampler {
|
|
|
138
139
|
* Gets a boolean indicating if the texture needs mipmaps generation
|
|
139
140
|
*/
|
|
140
141
|
this.generateMipMaps = false;
|
|
142
|
+
this._useMipMaps = null;
|
|
141
143
|
/**
|
|
142
144
|
* Gets the number of samples used by the texture (WebGL2+ only)
|
|
143
145
|
*/
|