@babylonjs/core 8.44.1 → 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.
Files changed (121) hide show
  1. package/Cameras/Inputs/geospatialCameraKeyboardInput.js +6 -10
  2. package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -1
  3. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -1
  4. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
  5. package/Cameras/Limits/geospatialLimits.d.ts +4 -22
  6. package/Cameras/Limits/geospatialLimits.js +4 -36
  7. package/Cameras/Limits/geospatialLimits.js.map +1 -1
  8. package/Cameras/geospatialCamera.d.ts +15 -4
  9. package/Cameras/geospatialCamera.js +90 -37
  10. package/Cameras/geospatialCamera.js.map +1 -1
  11. package/Cameras/geospatialCameraMovement.d.ts +1 -3
  12. package/Cameras/geospatialCameraMovement.js +15 -51
  13. package/Cameras/geospatialCameraMovement.js.map +1 -1
  14. package/Collisions/collisionCoordinator.d.ts +2 -2
  15. package/Collisions/collisionCoordinator.js +1 -0
  16. package/Collisions/collisionCoordinator.js.map +1 -1
  17. package/Engines/Extensions/engine.debugging.d.ts +3 -5
  18. package/Engines/Extensions/engine.debugging.js +3 -4
  19. package/Engines/Extensions/engine.debugging.js.map +1 -1
  20. package/Engines/WebGPU/Extensions/engine.debugging.js +15 -65
  21. package/Engines/WebGPU/Extensions/engine.debugging.js.map +1 -1
  22. package/Engines/WebGPU/webgpuTextureManager.js +9 -9
  23. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  24. package/Engines/abstractEngine.d.ts +2 -0
  25. package/Engines/abstractEngine.js +4 -2
  26. package/Engines/abstractEngine.js.map +1 -1
  27. package/Engines/thinWebGPUEngine.d.ts +0 -2
  28. package/Engines/thinWebGPUEngine.js +0 -8
  29. package/Engines/thinWebGPUEngine.js.map +1 -1
  30. package/Engines/webgpuEngine.d.ts +1 -3
  31. package/Engines/webgpuEngine.js +4 -10
  32. package/Engines/webgpuEngine.js.map +1 -1
  33. package/FrameGraph/Passes/renderPass.js +4 -9
  34. package/FrameGraph/Passes/renderPass.js.map +1 -1
  35. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +3 -0
  36. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  37. package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +1 -1
  38. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +4 -1
  39. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  40. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +2 -1
  41. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +31 -7
  42. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  43. package/FrameGraph/frameGraph.js +2 -2
  44. package/FrameGraph/frameGraph.js.map +1 -1
  45. package/FrameGraph/frameGraphContext.d.ts +9 -0
  46. package/FrameGraph/frameGraphContext.js +13 -2
  47. package/FrameGraph/frameGraphContext.js.map +1 -1
  48. package/FrameGraph/frameGraphObjectList.js.map +1 -1
  49. package/FrameGraph/frameGraphRenderContext.d.ts +9 -8
  50. package/FrameGraph/frameGraphRenderContext.js +23 -20
  51. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  52. package/FrameGraph/frameGraphTask.d.ts +2 -0
  53. package/FrameGraph/frameGraphTask.js +14 -4
  54. package/FrameGraph/frameGraphTask.js.map +1 -1
  55. package/Lights/Shadows/cascadedShadowGenerator.js +4 -1
  56. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  57. package/Lights/Shadows/shadowGenerator.js +8 -3
  58. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  59. package/Lights/areaLight.d.ts +2 -1
  60. package/Lights/areaLight.js +3 -2
  61. package/Lights/areaLight.js.map +1 -1
  62. package/Lights/directionalLight.d.ts +2 -1
  63. package/Lights/directionalLight.js +3 -2
  64. package/Lights/directionalLight.js.map +1 -1
  65. package/Lights/hemisphericLight.d.ts +2 -1
  66. package/Lights/hemisphericLight.js +3 -2
  67. package/Lights/hemisphericLight.js.map +1 -1
  68. package/Lights/light.d.ts +2 -1
  69. package/Lights/light.js +8 -3
  70. package/Lights/light.js.map +1 -1
  71. package/Lights/lightingVolume.js +11 -6
  72. package/Lights/lightingVolume.js.map +1 -1
  73. package/Lights/pointLight.d.ts +2 -1
  74. package/Lights/pointLight.js +3 -2
  75. package/Lights/pointLight.js.map +1 -1
  76. package/Lights/rectAreaLight.d.ts +2 -1
  77. package/Lights/rectAreaLight.js +3 -2
  78. package/Lights/rectAreaLight.js.map +1 -1
  79. package/Lights/spotLight.d.ts +2 -1
  80. package/Lights/spotLight.js +3 -2
  81. package/Lights/spotLight.js.map +1 -1
  82. package/Materials/Node/Blocks/Input/inputBlock.js +3 -0
  83. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  84. package/Materials/Node/nodeMaterial.d.ts +1 -0
  85. package/Materials/Node/nodeMaterial.js +4 -0
  86. package/Materials/Node/nodeMaterial.js.map +1 -1
  87. package/Materials/Node/nodeMaterialBuildStateSharedData.d.ts +6 -0
  88. package/Materials/Node/nodeMaterialBuildStateSharedData.js +4 -0
  89. package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
  90. package/Materials/Textures/Loaders/iesTextureLoader.js +1 -1
  91. package/Materials/Textures/Loaders/iesTextureLoader.js.map +1 -1
  92. package/Materials/Textures/Procedurals/proceduralTexture.js +7 -2
  93. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  94. package/Materials/Textures/internalTexture.d.ts +6 -4
  95. package/Materials/Textures/internalTexture.js +6 -4
  96. package/Materials/Textures/internalTexture.js.map +1 -1
  97. package/Materials/Textures/renderTargetTexture.js +2 -2
  98. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  99. package/Materials/Textures/textureSampler.d.ts +3 -3
  100. package/Materials/Textures/textureSampler.js.map +1 -1
  101. package/Misc/minMaxReducer.js +2 -2
  102. package/Misc/minMaxReducer.js.map +1 -1
  103. package/Misc/screenshotTools.d.ts +3 -1
  104. package/Misc/screenshotTools.js +5 -2
  105. package/Misc/screenshotTools.js.map +1 -1
  106. package/Particles/Node/nodeParticleSystemSet.helper.js +47 -46
  107. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  108. package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.js +4 -1
  109. package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.js.map +1 -1
  110. package/Probes/reflectionProbe.js +9 -2
  111. package/Probes/reflectionProbe.js.map +1 -1
  112. package/Rendering/depthRenderer.js +7 -2
  113. package/Rendering/depthRenderer.js.map +1 -1
  114. package/Shaders/particles.vertex.js +8 -1
  115. package/Shaders/particles.vertex.js.map +1 -1
  116. package/ShadersWGSL/particles.vertex.js +6 -0
  117. package/ShadersWGSL/particles.vertex.js.map +1 -1
  118. package/package.json +1 -1
  119. package/scene.d.ts +10 -0
  120. package/scene.js +30 -5
  121. 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;;G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B,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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AC;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 * 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;YAC5E,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"]}
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._debugPushGroup?.(`procedural texture generation for ${this.name}`, 1);
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._debugPopGroup?.(1);
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,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,IAAY,EACZ,IAAiB,EACjB,QAAa,EACb,KAAsB,EACtB,kBAAyE,IAAI,EAC7E,eAAe,GAAG,IAAI,EACtB,MAAM,GAAG,KAAK,EACd,WAA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I,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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qB;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"]}
@@ -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
- * Gets a boolean indicating if the texture uses mipmaps
111
- * TODO implements useMipMaps as a separate setting from generateMipMaps
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
- * Gets a boolean indicating if the texture uses mipmaps
76
- * TODO implements useMipMaps as a separate setting from generateMipMaps
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.generateMipMaps = value;
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
  */
@@ -1 +1 @@
1
- {"version":3,"file":"internalTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/internalTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMlD;;GAEG;AACH,MAAM,CAAN,IAAkB,qBA6DjB;AA7DD,WAAkB,qBAAqB;IACnC;;OAEG;IACH,uEAAO,CAAA;IACP;;OAEG;IACH,+DAAG,CAAA;IACH;;OAEG;IACH,iEAAI,CAAA;IACJ;;OAEG;IACH,+DAAG,CAAA;IACH;;OAEG;IACH,uEAAO,CAAA;IACP;;OAEG;IACH,iFAAY,CAAA;IACZ;;OAEG;IACH,2FAAiB,CAAA;IACjB;;OAEG;IACH,iEAAI,CAAA;IACJ;;OAEG;IACH,uEAAO,CAAA;IACP;;OAEG;IACH,uFAAe,CAAA;IACf;;OAEG;IACH,oEAAK,CAAA;IACL;;OAE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AAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAC7B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QACtC,CAAC;IACL,CAAC;;AAtUD,gBAAgB;AACF,wBAAQ,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import { Observable } from \"../../Misc/observable\";\r\nimport type { ImageSource, Nullable, int } from \"../../types\";\r\nimport type { ICanvas, ICanvasRenderingContext } from \"../../Engines/ICanvas\";\r\nimport type { IHardwareTextureWrapper } from \"./hardwareTextureWrapper\";\r\nimport { TextureSampler } from \"./textureSampler\";\r\n\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport type { SphericalPolynomial } from \"../../Maths/sphericalPolynomial\";\r\n\r\n/**\r\n * Defines the source of the internal texture\r\n */\r\nexport const enum InternalTextureSource {\r\n /**\r\n * The source of the texture data is unknown\r\n */\r\n Unknown,\r\n /**\r\n * Texture data comes from an URL\r\n */\r\n Url,\r\n /**\r\n * Texture data is only used for temporary storage\r\n */\r\n Temp,\r\n /**\r\n * Texture data comes from raw data (ArrayBuffer)\r\n */\r\n Raw,\r\n /**\r\n * Texture content is dynamic (video or dynamic texture)\r\n */\r\n Dynamic,\r\n /**\r\n * Texture content is generated by rendering to it\r\n */\r\n RenderTarget,\r\n /**\r\n * Texture content is part of a multi render target process\r\n */\r\n MultiRenderTarget,\r\n /**\r\n * Texture data comes from a cube data file\r\n */\r\n Cube,\r\n /**\r\n * Texture data comes from a raw cube data\r\n */\r\n CubeRaw,\r\n /**\r\n * Texture data come from a prefiltered cube data file\r\n */\r\n CubePrefiltered,\r\n /**\r\n * Texture content is raw 3D data\r\n */\r\n Raw3D,\r\n /**\r\n * Texture content is raw 2D array data\r\n */\r\n Raw2DArray,\r\n /**\r\n * Texture content is a depth/stencil texture\r\n */\r\n DepthStencil,\r\n /**\r\n * Texture data comes from a raw cube data encoded with RGBD\r\n */\r\n CubeRawRGBD,\r\n /**\r\n * Texture content is a depth texture\r\n */\r\n Depth,\r\n}\r\n\r\n/**\r\n * Class used to store data associated with WebGL texture data for the engine\r\n * This class should not be used directly\r\n */\r\nexport class InternalTexture extends TextureSampler {\r\n /**\r\n * Defines if the texture is ready\r\n */\r\n public isReady: boolean = false;\r\n /**\r\n * Defines if the texture is a cube texture\r\n */\r\n public isCube: boolean = false;\r\n /**\r\n * Defines if the texture contains 3D data\r\n */\r\n public is3D: boolean = false;\r\n /**\r\n * Defines if the texture contains 2D array data\r\n */\r\n public is2DArray: boolean = false;\r\n /**\r\n * Defines if the texture contains multiview data\r\n */\r\n public isMultiview: boolean = false;\r\n /**\r\n * Gets the URL used to load this texture\r\n */\r\n public url: string = \"\";\r\n /** @internal */\r\n public _originalUrl: string; // not empty only if different from url\r\n /**\r\n * Gets a boolean indicating if the texture needs mipmaps generation\r\n */\r\n public generateMipMaps: boolean = false;\r\n /**\r\n * Gets a boolean indicating if the texture uses mipmaps\r\n * TODO implements useMipMaps as a separate setting from generateMipMaps\r\n */\r\n public override get useMipMaps() {\r\n return this.generateMipMaps;\r\n }\r\n public override set useMipMaps(value: boolean) {\r\n this.generateMipMaps = value;\r\n }\r\n /**\r\n * Gets the number of samples used by the texture (WebGL2+ only)\r\n */\r\n public samples: number = 0;\r\n /**\r\n * Gets the type of the texture (int, float...)\r\n */\r\n public type: number = -1;\r\n /**\r\n * Gets the format of the texture (RGB, RGBA...)\r\n */\r\n public format: number = -1;\r\n /**\r\n * Observable called when the texture is loaded\r\n */\r\n public onLoadedObservable = new Observable<InternalTexture>();\r\n /**\r\n * Observable called when the texture load is raising an error\r\n */\r\n public onErrorObservable = new Observable<Partial<{ message: string; exception: any }>>();\r\n /**\r\n * If this callback is defined it will be called instead of the default _rebuild function\r\n */\r\n public onRebuildCallback: Nullable<\r\n (internalTexture: InternalTexture) => {\r\n proxy: Nullable<InternalTexture | Promise<InternalTexture>>;\r\n isReady: boolean;\r\n isAsync: boolean;\r\n }\r\n > = null;\r\n /**\r\n * Gets the width of the texture\r\n */\r\n public width: number = 0;\r\n /**\r\n * Gets the height of the texture\r\n */\r\n public height: number = 0;\r\n /**\r\n * Gets the depth of the texture\r\n */\r\n public depth: number = 0;\r\n /**\r\n * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseWidth: number = 0;\r\n /**\r\n * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseHeight: number = 0;\r\n /**\r\n * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseDepth: number = 0;\r\n /**\r\n * Gets a boolean indicating if the texture is inverted on Y axis\r\n */\r\n public invertY: boolean = false;\r\n\r\n // Private\r\n /** @internal */\r\n public _invertVScale = false;\r\n /** @internal */\r\n public _associatedChannel = -1;\r\n /** @internal */\r\n public _source = InternalTextureSource.Unknown;\r\n /** @internal */\r\n public _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap> = null;\r\n /** @internal */\r\n public _bufferView: Nullable<ArrayBufferView> = null;\r\n /** @internal */\r\n public _bufferViewArray: Nullable<ArrayBufferView[]> = null;\r\n /** @internal */\r\n public _bufferViewArrayArray: Nullable<ArrayBufferView[][]> = null;\r\n /** @internal */\r\n public _size: number = 0;\r\n /** @internal */\r\n public _extension: string = \"\";\r\n /** @internal */\r\n public _files: Nullable<string[]> = null;\r\n /** @internal */\r\n public _workingCanvas: Nullable<ICanvas> = null;\r\n /** @internal */\r\n public _workingContext: Nullable<ICanvasRenderingContext> = null;\r\n /** @internal */\r\n public _cachedCoordinatesMode: Nullable<number> = null;\r\n /** @internal */\r\n public _isDisabled: boolean = false;\r\n /** @internal */\r\n public _compression: Nullable<string> = null;\r\n /** @internal */\r\n public _sphericalPolynomial: Nullable<SphericalPolynomial> = null;\r\n /** @internal */\r\n public _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>> = null;\r\n /** @internal */\r\n public _sphericalPolynomialComputed = false;\r\n /** @internal */\r\n public _lodGenerationScale: number = 0;\r\n /** @internal */\r\n public _lodGenerationOffset: number = 0;\r\n /** @internal */\r\n public _useSRGBBuffer: boolean = false;\r\n /** @internal */\r\n public _creationFlags: number = 0;\r\n /** @internal */\r\n public _originalFormat?: number;\r\n\r\n // The following three fields helps sharing generated fixed LODs for texture filtering\r\n // In environment not supporting the textureLOD extension like EDGE. They are for internal use only.\r\n // They are at the level of the gl texture to benefit from the cache.\r\n /** @internal */\r\n public _lodTextureHigh: Nullable<BaseTexture> = null;\r\n /** @internal */\r\n public _lodTextureMid: Nullable<BaseTexture> = null;\r\n /** @internal */\r\n public _lodTextureLow: Nullable<BaseTexture> = null;\r\n /** @internal */\r\n public _isRGBD: boolean = false;\r\n\r\n /** @internal */\r\n public _linearSpecularLOD: boolean = false;\r\n /** @internal */\r\n public _irradianceTexture: Nullable<BaseTexture> = null;\r\n\r\n /** @internal */\r\n public _hardwareTexture: Nullable<IHardwareTextureWrapper> = null;\r\n\r\n /** @internal */\r\n public _maxLodLevel: Nullable<number> = null;\r\n\r\n /** @internal */\r\n public _references: number = 1;\r\n\r\n /** @internal */\r\n public _gammaSpace: Nullable<boolean> = null;\r\n\r\n /** @internal */\r\n public _premulAlpha = false;\r\n\r\n /** @internal */\r\n public _dynamicTextureSource: Nullable<ImageSource> = null;\r\n\r\n /** @internal */\r\n public _autoMSAAManagement = false;\r\n\r\n private _engine: AbstractEngine;\r\n private _uniqueId: number;\r\n\r\n /** @internal */\r\n public static _Counter = 0;\r\n\r\n /** Gets the unique id of the internal texture */\r\n public get uniqueId() {\r\n return this._uniqueId;\r\n }\r\n\r\n /** @internal */\r\n public _setUniqueId(id: number) {\r\n this._uniqueId = id;\r\n }\r\n\r\n /**\r\n * Gets the Engine the texture belongs to.\r\n * @returns The babylon engine\r\n */\r\n public getEngine(): AbstractEngine {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the data source type of the texture\r\n */\r\n public get source(): InternalTextureSource {\r\n return this._source;\r\n }\r\n\r\n /**\r\n * Creates a new InternalTexture\r\n * @param engine defines the engine to use\r\n * @param source defines the type of data that will be used\r\n * @param delayAllocation if the texture allocation should be delayed (default: false)\r\n */\r\n constructor(engine: AbstractEngine, source: InternalTextureSource, delayAllocation = false) {\r\n super();\r\n\r\n this._engine = engine;\r\n this._source = source;\r\n this._uniqueId = InternalTexture._Counter++;\r\n\r\n if (!delayAllocation) {\r\n this._hardwareTexture = engine._createHardwareTexture();\r\n }\r\n }\r\n\r\n /**\r\n * Increments the number of references (ie. the number of Texture that point to it)\r\n */\r\n public incrementReferences(): void {\r\n this._references++;\r\n }\r\n\r\n /**\r\n * Change the size of the texture (not the size of the content)\r\n * @param width defines the new width\r\n * @param height defines the new height\r\n * @param depth defines the new depth (1 by default)\r\n */\r\n public updateSize(width: int, height: int, depth: int = 1): void {\r\n this._engine.updateTextureDimensions(this, width, height, depth);\r\n\r\n this.width = width;\r\n this.height = height;\r\n this.depth = depth;\r\n\r\n this.baseWidth = width;\r\n this.baseHeight = height;\r\n this.baseDepth = depth;\r\n\r\n this._size = width * height * depth;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n this.isReady = false;\r\n this._cachedCoordinatesMode = null;\r\n this._cachedWrapU = null;\r\n this._cachedWrapV = null;\r\n this._cachedWrapR = null;\r\n this._cachedAnisotropicFilteringLevel = null;\r\n if (this.onRebuildCallback) {\r\n const data = this.onRebuildCallback(this);\r\n const swapAndSetIsReady = (proxyInternalTexture: InternalTexture) => {\r\n proxyInternalTexture._swapAndDie(this, false);\r\n this.isReady = data.isReady;\r\n };\r\n if (data.isAsync) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n (data.proxy as Promise<InternalTexture>).then(swapAndSetIsReady);\r\n } else {\r\n swapAndSetIsReady(data.proxy as InternalTexture);\r\n }\r\n return;\r\n }\r\n\r\n let proxy: InternalTexture;\r\n switch (this.source) {\r\n case InternalTextureSource.Temp:\r\n break;\r\n\r\n case InternalTextureSource.Url:\r\n proxy = this._engine.createTexture(\r\n this._originalUrl ?? this.url,\r\n !this.generateMipMaps,\r\n this.invertY,\r\n null,\r\n this.samplingMode,\r\n // Do not use Proxy here as it could be fully synchronous\r\n // and proxy would be undefined.\r\n (temp) => {\r\n temp._swapAndDie(this, false);\r\n this.isReady = true;\r\n },\r\n null,\r\n this._buffer,\r\n undefined,\r\n this.format,\r\n this._extension,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this._useSRGBBuffer\r\n );\r\n return;\r\n\r\n case InternalTextureSource.Raw:\r\n proxy = this._engine.createRawTexture(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type,\r\n this._creationFlags,\r\n this._useSRGBBuffer\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Raw3D:\r\n proxy = this._engine.createRawTexture3D(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.baseDepth,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Raw2DArray:\r\n proxy = this._engine.createRawTexture2DArray(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.baseDepth,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Dynamic:\r\n proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);\r\n proxy._swapAndDie(this, false);\r\n if (this._dynamicTextureSource) {\r\n this._engine.updateDynamicTexture(this, this._dynamicTextureSource, this.invertY, this._premulAlpha, this.format, true);\r\n }\r\n\r\n // The engine will make sure to update content so no need to flag it as isReady = true\r\n break;\r\n\r\n case InternalTextureSource.Cube:\r\n proxy = this._engine.createCubeTexture(\r\n this.url,\r\n null,\r\n this._files,\r\n !this.generateMipMaps,\r\n () => {\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n },\r\n null,\r\n this.format,\r\n this._extension,\r\n false,\r\n 0,\r\n 0,\r\n null,\r\n undefined,\r\n this._useSRGBBuffer,\r\n ArrayBuffer.isView(this._buffer) ? this._buffer : null\r\n );\r\n return;\r\n\r\n case InternalTextureSource.CubeRaw:\r\n proxy = this._engine.createRawCubeTexture(\r\n this._bufferViewArray,\r\n this.width,\r\n this._originalFormat ?? this.format,\r\n this.type,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression\r\n );\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.CubeRawRGBD:\r\n // This case is being handeled by the environment texture tools and is not a part of the rebuild process.\r\n // To use CubeRawRGBD use updateRGBDAsync on the cube texture.\r\n return;\r\n\r\n case InternalTextureSource.CubePrefiltered:\r\n proxy = this._engine.createPrefilteredCubeTexture(\r\n this.url,\r\n null,\r\n this._lodGenerationScale,\r\n this._lodGenerationOffset,\r\n (proxy) => {\r\n if (proxy) {\r\n proxy._swapAndDie(this, false);\r\n }\r\n this.isReady = true;\r\n },\r\n null,\r\n this.format,\r\n this._extension\r\n );\r\n proxy._sphericalPolynomial = this._sphericalPolynomial;\r\n return;\r\n\r\n case InternalTextureSource.DepthStencil:\r\n case InternalTextureSource.Depth: {\r\n // Will be handled at the RenderTargetWrapper level\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _swapAndDie(target: InternalTexture, swapAll = true): void {\r\n // TODO what about refcount on target?\r\n\r\n this._hardwareTexture?.setUsage(target._source, this.generateMipMaps, this.is2DArray, this.isCube, this.is3D, this.width, this.height, this.depth);\r\n\r\n target._hardwareTexture = this._hardwareTexture;\r\n if (swapAll) {\r\n target._isRGBD = this._isRGBD;\r\n }\r\n\r\n if (this._lodTextureHigh) {\r\n if (target._lodTextureHigh) {\r\n target._lodTextureHigh.dispose();\r\n }\r\n target._lodTextureHigh = this._lodTextureHigh;\r\n }\r\n\r\n if (this._lodTextureMid) {\r\n if (target._lodTextureMid) {\r\n target._lodTextureMid.dispose();\r\n }\r\n target._lodTextureMid = this._lodTextureMid;\r\n }\r\n\r\n if (this._lodTextureLow) {\r\n if (target._lodTextureLow) {\r\n target._lodTextureLow.dispose();\r\n }\r\n target._lodTextureLow = this._lodTextureLow;\r\n }\r\n\r\n if (this._irradianceTexture) {\r\n if (target._irradianceTexture) {\r\n target._irradianceTexture.dispose();\r\n }\r\n target._irradianceTexture = this._irradianceTexture;\r\n }\r\n\r\n const cache = this._engine.getLoadedTexturesCache();\r\n let index = cache.indexOf(this);\r\n if (index !== -1) {\r\n cache.splice(index, 1);\r\n }\r\n\r\n index = cache.indexOf(target);\r\n if (index === -1) {\r\n cache.push(target);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the current allocated resources\r\n */\r\n public dispose(): void {\r\n this._references--;\r\n if (this._references === 0) {\r\n this.onLoadedObservable.clear();\r\n this.onErrorObservable.clear();\r\n this._engine._releaseTexture(this);\r\n this._hardwareTexture = null;\r\n this._dynamicTextureSource = null;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"internalTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/internalTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMlD;;GAEG;AACH,MAAM,CAAN,IAAkB,qBA6DjB;AA7DD,WAAkB,qBAAqB;IACnC;;OAEG;IACH,uEAAO,CAAA;IACP;;OAEG;IACH,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C,MAAM,CAAC,CAAC;QAC9B,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,IAAI,CAAC,WAAW,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;YAChC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;YAC/B,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAC7B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QACtC,CAAC;IACL,CAAC;;AAtUD,gBAAgB;AACF,wBAAQ,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import { Observable } from \"../../Misc/observable\";\r\nimport type { ImageSource, Nullable, int } from \"../../types\";\r\nimport type { ICanvas, ICanvasRenderingContext } from \"../../Engines/ICanvas\";\r\nimport type { IHardwareTextureWrapper } from \"./hardwareTextureWrapper\";\r\nimport { TextureSampler } from \"./textureSampler\";\r\n\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport type { SphericalPolynomial } from \"../../Maths/sphericalPolynomial\";\r\n\r\n/**\r\n * Defines the source of the internal texture\r\n */\r\nexport const enum InternalTextureSource {\r\n /**\r\n * The source of the texture data is unknown\r\n */\r\n Unknown,\r\n /**\r\n * Texture data comes from an URL\r\n */\r\n Url,\r\n /**\r\n * Texture data is only used for temporary storage\r\n */\r\n Temp,\r\n /**\r\n * Texture data comes from raw data (ArrayBuffer)\r\n */\r\n Raw,\r\n /**\r\n * Texture content is dynamic (video or dynamic texture)\r\n */\r\n Dynamic,\r\n /**\r\n * Texture content is generated by rendering to it\r\n */\r\n RenderTarget,\r\n /**\r\n * Texture content is part of a multi render target process\r\n */\r\n MultiRenderTarget,\r\n /**\r\n * Texture data comes from a cube data file\r\n */\r\n Cube,\r\n /**\r\n * Texture data comes from a raw cube data\r\n */\r\n CubeRaw,\r\n /**\r\n * Texture data come from a prefiltered cube data file\r\n */\r\n CubePrefiltered,\r\n /**\r\n * Texture content is raw 3D data\r\n */\r\n Raw3D,\r\n /**\r\n * Texture content is raw 2D array data\r\n */\r\n Raw2DArray,\r\n /**\r\n * Texture content is a depth/stencil texture\r\n */\r\n DepthStencil,\r\n /**\r\n * Texture data comes from a raw cube data encoded with RGBD\r\n */\r\n CubeRawRGBD,\r\n /**\r\n * Texture content is a depth texture\r\n */\r\n Depth,\r\n}\r\n\r\n/**\r\n * Class used to store data associated with WebGL texture data for the engine\r\n * This class should not be used directly\r\n */\r\nexport class InternalTexture extends TextureSampler {\r\n /**\r\n * Defines if the texture is ready\r\n */\r\n public isReady: boolean = false;\r\n /**\r\n * Defines if the texture is a cube texture\r\n */\r\n public isCube: boolean = false;\r\n /**\r\n * Defines if the texture contains 3D data\r\n */\r\n public is3D: boolean = false;\r\n /**\r\n * Defines if the texture contains 2D array data\r\n */\r\n public is2DArray: boolean = false;\r\n /**\r\n * Defines if the texture contains multiview data\r\n */\r\n public isMultiview: boolean = false;\r\n /**\r\n * Gets the URL used to load this texture\r\n */\r\n public url: string = \"\";\r\n /** @internal */\r\n public _originalUrl: string; // not empty only if different from url\r\n /**\r\n * Gets a boolean indicating if the texture needs mipmaps generation\r\n */\r\n public generateMipMaps: boolean = false;\r\n\r\n protected override _useMipMaps: Nullable<boolean> = null;\r\n /**\r\n * Indicates to use the mip maps (if available on the texture).\r\n * 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!)\r\n * If useMipMaps is null, the value of generateMipMaps is returned by the getter (for backward compatibility)\r\n */\r\n public override get useMipMaps() {\r\n return this._useMipMaps === null ? this.generateMipMaps : this._useMipMaps;\r\n }\r\n public override set useMipMaps(value: Nullable<boolean>) {\r\n this._useMipMaps = value;\r\n }\r\n /**\r\n * Gets the number of samples used by the texture (WebGL2+ only)\r\n */\r\n public samples: number = 0;\r\n /**\r\n * Gets the type of the texture (int, float...)\r\n */\r\n public type: number = -1;\r\n /**\r\n * Gets the format of the texture (RGB, RGBA...)\r\n */\r\n public format: number = -1;\r\n /**\r\n * Observable called when the texture is loaded\r\n */\r\n public onLoadedObservable = new Observable<InternalTexture>();\r\n /**\r\n * Observable called when the texture load is raising an error\r\n */\r\n public onErrorObservable = new Observable<Partial<{ message: string; exception: any }>>();\r\n /**\r\n * If this callback is defined it will be called instead of the default _rebuild function\r\n */\r\n public onRebuildCallback: Nullable<\r\n (internalTexture: InternalTexture) => {\r\n proxy: Nullable<InternalTexture | Promise<InternalTexture>>;\r\n isReady: boolean;\r\n isAsync: boolean;\r\n }\r\n > = null;\r\n /**\r\n * Gets the width of the texture\r\n */\r\n public width: number = 0;\r\n /**\r\n * Gets the height of the texture\r\n */\r\n public height: number = 0;\r\n /**\r\n * Gets the depth of the texture\r\n */\r\n public depth: number = 0;\r\n /**\r\n * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseWidth: number = 0;\r\n /**\r\n * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseHeight: number = 0;\r\n /**\r\n * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseDepth: number = 0;\r\n /**\r\n * Gets a boolean indicating if the texture is inverted on Y axis\r\n */\r\n public invertY: boolean = false;\r\n\r\n // Private\r\n /** @internal */\r\n public _invertVScale = false;\r\n /** @internal */\r\n public _associatedChannel = -1;\r\n /** @internal */\r\n public _source = InternalTextureSource.Unknown;\r\n /** @internal */\r\n public _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap> = null;\r\n /** @internal */\r\n public _bufferView: Nullable<ArrayBufferView> = null;\r\n /** @internal */\r\n public _bufferViewArray: Nullable<ArrayBufferView[]> = null;\r\n /** @internal */\r\n public _bufferViewArrayArray: Nullable<ArrayBufferView[][]> = null;\r\n /** @internal */\r\n public _size: number = 0;\r\n /** @internal */\r\n public _extension: string = \"\";\r\n /** @internal */\r\n public _files: Nullable<string[]> = null;\r\n /** @internal */\r\n public _workingCanvas: Nullable<ICanvas> = null;\r\n /** @internal */\r\n public _workingContext: Nullable<ICanvasRenderingContext> = null;\r\n /** @internal */\r\n public _cachedCoordinatesMode: Nullable<number> = null;\r\n /** @internal */\r\n public _isDisabled: boolean = false;\r\n /** @internal */\r\n public _compression: Nullable<string> = null;\r\n /** @internal */\r\n public _sphericalPolynomial: Nullable<SphericalPolynomial> = null;\r\n /** @internal */\r\n public _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>> = null;\r\n /** @internal */\r\n public _sphericalPolynomialComputed = false;\r\n /** @internal */\r\n public _lodGenerationScale: number = 0;\r\n /** @internal */\r\n public _lodGenerationOffset: number = 0;\r\n /** @internal */\r\n public _useSRGBBuffer: boolean = false;\r\n /** @internal */\r\n public _creationFlags: number = 0;\r\n /** @internal */\r\n public _originalFormat?: number;\r\n\r\n // The following three fields helps sharing generated fixed LODs for texture filtering\r\n // In environment not supporting the textureLOD extension like EDGE. They are for internal use only.\r\n // They are at the level of the gl texture to benefit from the cache.\r\n /** @internal */\r\n public _lodTextureHigh: Nullable<BaseTexture> = null;\r\n /** @internal */\r\n public _lodTextureMid: Nullable<BaseTexture> = null;\r\n /** @internal */\r\n public _lodTextureLow: Nullable<BaseTexture> = null;\r\n /** @internal */\r\n public _isRGBD: boolean = false;\r\n\r\n /** @internal */\r\n public _linearSpecularLOD: boolean = false;\r\n /** @internal */\r\n public _irradianceTexture: Nullable<BaseTexture> = null;\r\n\r\n /** @internal */\r\n public _hardwareTexture: Nullable<IHardwareTextureWrapper> = null;\r\n\r\n /** @internal */\r\n public _maxLodLevel: Nullable<number> = null;\r\n\r\n /** @internal */\r\n public _references: number = 1;\r\n\r\n /** @internal */\r\n public _gammaSpace: Nullable<boolean> = null;\r\n\r\n /** @internal */\r\n public _premulAlpha = false;\r\n\r\n /** @internal */\r\n public _dynamicTextureSource: Nullable<ImageSource> = null;\r\n\r\n /** @internal */\r\n public _autoMSAAManagement = false;\r\n\r\n private _engine: AbstractEngine;\r\n private _uniqueId: number;\r\n\r\n /** @internal */\r\n public static _Counter = 0;\r\n\r\n /** Gets the unique id of the internal texture */\r\n public get uniqueId() {\r\n return this._uniqueId;\r\n }\r\n\r\n /** @internal */\r\n public _setUniqueId(id: number) {\r\n this._uniqueId = id;\r\n }\r\n\r\n /**\r\n * Gets the Engine the texture belongs to.\r\n * @returns The babylon engine\r\n */\r\n public getEngine(): AbstractEngine {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the data source type of the texture\r\n */\r\n public get source(): InternalTextureSource {\r\n return this._source;\r\n }\r\n\r\n /**\r\n * Creates a new InternalTexture\r\n * @param engine defines the engine to use\r\n * @param source defines the type of data that will be used\r\n * @param delayAllocation if the texture allocation should be delayed (default: false)\r\n */\r\n constructor(engine: AbstractEngine, source: InternalTextureSource, delayAllocation = false) {\r\n super();\r\n\r\n this._engine = engine;\r\n this._source = source;\r\n this._uniqueId = InternalTexture._Counter++;\r\n\r\n if (!delayAllocation) {\r\n this._hardwareTexture = engine._createHardwareTexture();\r\n }\r\n }\r\n\r\n /**\r\n * Increments the number of references (ie. the number of Texture that point to it)\r\n */\r\n public incrementReferences(): void {\r\n this._references++;\r\n }\r\n\r\n /**\r\n * Change the size of the texture (not the size of the content)\r\n * @param width defines the new width\r\n * @param height defines the new height\r\n * @param depth defines the new depth (1 by default)\r\n */\r\n public updateSize(width: int, height: int, depth: int = 1): void {\r\n this._engine.updateTextureDimensions(this, width, height, depth);\r\n\r\n this.width = width;\r\n this.height = height;\r\n this.depth = depth;\r\n\r\n this.baseWidth = width;\r\n this.baseHeight = height;\r\n this.baseDepth = depth;\r\n\r\n this._size = width * height * depth;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n this.isReady = false;\r\n this._cachedCoordinatesMode = null;\r\n this._cachedWrapU = null;\r\n this._cachedWrapV = null;\r\n this._cachedWrapR = null;\r\n this._cachedAnisotropicFilteringLevel = null;\r\n if (this.onRebuildCallback) {\r\n const data = this.onRebuildCallback(this);\r\n const swapAndSetIsReady = (proxyInternalTexture: InternalTexture) => {\r\n proxyInternalTexture._swapAndDie(this, false);\r\n this.isReady = data.isReady;\r\n };\r\n if (data.isAsync) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n (data.proxy as Promise<InternalTexture>).then(swapAndSetIsReady);\r\n } else {\r\n swapAndSetIsReady(data.proxy as InternalTexture);\r\n }\r\n return;\r\n }\r\n\r\n let proxy: InternalTexture;\r\n switch (this.source) {\r\n case InternalTextureSource.Temp:\r\n break;\r\n\r\n case InternalTextureSource.Url:\r\n proxy = this._engine.createTexture(\r\n this._originalUrl ?? this.url,\r\n !this.generateMipMaps,\r\n this.invertY,\r\n null,\r\n this.samplingMode,\r\n // Do not use Proxy here as it could be fully synchronous\r\n // and proxy would be undefined.\r\n (temp) => {\r\n temp._swapAndDie(this, false);\r\n this.isReady = true;\r\n },\r\n null,\r\n this._buffer,\r\n undefined,\r\n this.format,\r\n this._extension,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this._useSRGBBuffer\r\n );\r\n return;\r\n\r\n case InternalTextureSource.Raw:\r\n proxy = this._engine.createRawTexture(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type,\r\n this._creationFlags,\r\n this._useSRGBBuffer\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Raw3D:\r\n proxy = this._engine.createRawTexture3D(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.baseDepth,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Raw2DArray:\r\n proxy = this._engine.createRawTexture2DArray(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.baseDepth,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Dynamic:\r\n proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);\r\n proxy._swapAndDie(this, false);\r\n if (this._dynamicTextureSource) {\r\n this._engine.updateDynamicTexture(this, this._dynamicTextureSource, this.invertY, this._premulAlpha, this.format, true);\r\n }\r\n\r\n // The engine will make sure to update content so no need to flag it as isReady = true\r\n break;\r\n\r\n case InternalTextureSource.Cube:\r\n proxy = this._engine.createCubeTexture(\r\n this.url,\r\n null,\r\n this._files,\r\n !this.generateMipMaps,\r\n () => {\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n },\r\n null,\r\n this.format,\r\n this._extension,\r\n false,\r\n 0,\r\n 0,\r\n null,\r\n undefined,\r\n this._useSRGBBuffer,\r\n ArrayBuffer.isView(this._buffer) ? this._buffer : null\r\n );\r\n return;\r\n\r\n case InternalTextureSource.CubeRaw:\r\n proxy = this._engine.createRawCubeTexture(\r\n this._bufferViewArray,\r\n this.width,\r\n this._originalFormat ?? this.format,\r\n this.type,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression\r\n );\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.CubeRawRGBD:\r\n // This case is being handeled by the environment texture tools and is not a part of the rebuild process.\r\n // To use CubeRawRGBD use updateRGBDAsync on the cube texture.\r\n return;\r\n\r\n case InternalTextureSource.CubePrefiltered:\r\n proxy = this._engine.createPrefilteredCubeTexture(\r\n this.url,\r\n null,\r\n this._lodGenerationScale,\r\n this._lodGenerationOffset,\r\n (proxy) => {\r\n if (proxy) {\r\n proxy._swapAndDie(this, false);\r\n }\r\n this.isReady = true;\r\n },\r\n null,\r\n this.format,\r\n this._extension\r\n );\r\n proxy._sphericalPolynomial = this._sphericalPolynomial;\r\n return;\r\n\r\n case InternalTextureSource.DepthStencil:\r\n case InternalTextureSource.Depth: {\r\n // Will be handled at the RenderTargetWrapper level\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _swapAndDie(target: InternalTexture, swapAll = true): void {\r\n // TODO what about refcount on target?\r\n\r\n this._hardwareTexture?.setUsage(target._source, this.generateMipMaps, this.is2DArray, this.isCube, this.is3D, this.width, this.height, this.depth);\r\n\r\n target._hardwareTexture = this._hardwareTexture;\r\n if (swapAll) {\r\n target._isRGBD = this._isRGBD;\r\n }\r\n\r\n if (this._lodTextureHigh) {\r\n if (target._lodTextureHigh) {\r\n target._lodTextureHigh.dispose();\r\n }\r\n target._lodTextureHigh = this._lodTextureHigh;\r\n }\r\n\r\n if (this._lodTextureMid) {\r\n if (target._lodTextureMid) {\r\n target._lodTextureMid.dispose();\r\n }\r\n target._lodTextureMid = this._lodTextureMid;\r\n }\r\n\r\n if (this._lodTextureLow) {\r\n if (target._lodTextureLow) {\r\n target._lodTextureLow.dispose();\r\n }\r\n target._lodTextureLow = this._lodTextureLow;\r\n }\r\n\r\n if (this._irradianceTexture) {\r\n if (target._irradianceTexture) {\r\n target._irradianceTexture.dispose();\r\n }\r\n target._irradianceTexture = this._irradianceTexture;\r\n }\r\n\r\n const cache = this._engine.getLoadedTexturesCache();\r\n let index = cache.indexOf(this);\r\n if (index !== -1) {\r\n cache.splice(index, 1);\r\n }\r\n\r\n index = cache.indexOf(target);\r\n if (index === -1) {\r\n cache.push(target);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the current allocated resources\r\n */\r\n public dispose(): void {\r\n this._references--;\r\n if (this._references === 0) {\r\n this.onLoadedObservable.clear();\r\n this.onErrorObservable.clear();\r\n this._engine._releaseTexture(this);\r\n this._hardwareTexture = null;\r\n this._dynamicTextureSource = null;\r\n }\r\n }\r\n}\r\n"]}