@babylonjs/core 6.34.3 → 6.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Compute/computeShader.d.ts +2 -2
- package/Compute/computeShader.js.map +1 -1
- package/Engines/Extensions/engine.cubeTexture.js +2 -2
- package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/ICanvas.d.ts +4 -0
- package/Engines/ICanvas.js.map +1 -1
- package/Engines/WebGPU/Extensions/index.d.ts +0 -2
- package/Engines/WebGPU/Extensions/index.js +0 -2
- package/Engines/WebGPU/Extensions/index.js.map +1 -1
- package/Engines/engineCapabilities.d.ts +2 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/nativeEngine.js +2 -1
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +1 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.js +4 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +52 -1
- package/Engines/webgpuEngine.js +133 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +6 -0
- package/Gizmos/boundingBoxGizmo.js +28 -3
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.js +1 -5
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.js +1 -5
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.js +1 -5
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +2 -2
- package/Materials/Node/nodeMaterial.js +2 -2
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Textures/Procedurals/customProceduralTexture.d.ts +11 -1
- package/Materials/Textures/Procedurals/customProceduralTexture.js +3 -0
- package/Materials/Textures/Procedurals/customProceduralTexture.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.d.ts +13 -2
- package/Materials/Textures/Procedurals/proceduralTexture.js +12 -14
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/dynamicTexture.d.ts +5 -0
- package/Materials/Textures/dynamicTexture.js +13 -0
- package/Materials/Textures/dynamicTexture.js.map +1 -1
- package/Materials/Textures/videoTexture.js +5 -2
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Meshes/abstractMesh.js +1 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Misc/environmentTextureTools.js +1 -1
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/fileTools.js +4 -5
- package/Misc/fileTools.js.map +1 -1
- package/Physics/v2/ragdoll.d.ts +0 -1
- package/Physics/v2/ragdoll.js +9 -3
- package/Physics/v2/ragdoll.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +10 -11
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
- package/Rendering/geometryBufferRenderer.d.ts +14 -2
- package/Rendering/geometryBufferRenderer.js +40 -6
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/geometryBufferRendererSceneComponent.d.ts +9 -3
- package/Rendering/geometryBufferRendererSceneComponent.js +2 -2
- package/Rendering/geometryBufferRendererSceneComponent.js.map +1 -1
- package/Shaders/geometry.fragment.js +3 -0
- package/Shaders/geometry.fragment.js.map +1 -1
- package/Shaders/screenSpaceReflection2.fragment.js +6 -0
- package/Shaders/screenSpaceReflection2.fragment.js.map +1 -1
- package/package.json +1 -1
- package/Engines/WebGPU/Extensions/engine.dynamicBuffer.d.ts +0 -1
- package/Engines/WebGPU/Extensions/engine.dynamicBuffer.js +0 -44
- package/Engines/WebGPU/Extensions/engine.dynamicBuffer.js.map +0 -1
- package/Engines/WebGPU/Extensions/engine.uniformBuffer.d.ts +0 -1
- package/Engines/WebGPU/Extensions/engine.uniformBuffer.js +0 -46
- package/Engines/WebGPU/Extensions/engine.uniformBuffer.js.map +0 -1
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import type { Scene } from "../../../scene";
|
|
2
2
|
import { Texture } from "../../../Materials/Textures/texture";
|
|
3
|
+
import type { IProceduralTextureCreationOptions } from "./proceduralTexture";
|
|
3
4
|
import { ProceduralTexture } from "./proceduralTexture";
|
|
4
5
|
import type { TextureSize } from "../../../Materials/Textures/textureCreationOptions";
|
|
6
|
+
/**
|
|
7
|
+
* Options to create a Custom Procedural Texture.
|
|
8
|
+
*/
|
|
9
|
+
export interface ICustomProceduralTextureCreationOptions extends IProceduralTextureCreationOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Define a boolena indicating that there is no json config file to load
|
|
12
|
+
*/
|
|
13
|
+
skipJson?: boolean;
|
|
14
|
+
}
|
|
5
15
|
/**
|
|
6
16
|
* 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.
|
|
7
17
|
* Custom Procedural textures are the easiest way to create your own procedural in your application.
|
|
@@ -25,7 +35,7 @@ export declare class CustomProceduralTexture extends ProceduralTexture {
|
|
|
25
35
|
* @param generateMipMaps Define if the texture should creates mip maps or not
|
|
26
36
|
* @param skipJson Define a boolena indicating that there is no json config file to load
|
|
27
37
|
*/
|
|
28
|
-
constructor(name: string, texturePath: string, size: TextureSize, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean, skipJson?: boolean);
|
|
38
|
+
constructor(name: string, texturePath: string, size: TextureSize, scene: Scene, fallbackTexture?: Texture | ICustomProceduralTextureCreationOptions, generateMipMaps?: boolean, skipJson?: boolean);
|
|
29
39
|
private _loadJson;
|
|
30
40
|
/**
|
|
31
41
|
* Is the texture ready to be used ? (rendered at least once)
|
|
@@ -28,6 +28,9 @@ export class CustomProceduralTexture extends ProceduralTexture {
|
|
|
28
28
|
this._animate = true;
|
|
29
29
|
this._time = 0;
|
|
30
30
|
this._texturePath = texturePath;
|
|
31
|
+
if (fallbackTexture && !(fallbackTexture instanceof Texture)) {
|
|
32
|
+
skipJson = !!fallbackTexture.skipJson;
|
|
33
|
+
}
|
|
31
34
|
if (!skipJson) {
|
|
32
35
|
//Try to load json
|
|
33
36
|
this._loadJson(texturePath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customProceduralTexture.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Procedurals/customProceduralTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,iBAAiB;IAM1D;;;;;;;;;;;;OAYG;IACH,YAAY,IAAY,EAAE,WAAmB,EAAE,IAAiB,EAAE,KAAY,EAAE,eAAyB,EAAE,eAAyB,EAAE,QAAkB;QACpJ,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;QAnB7D,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;QAmBtB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAEhC,IAAI,CAAC,QAAQ,EAAE;YACX,kBAAkB;YAClB,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;SAC/B;aAAM;YACH,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SACvC;QACD,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;IACzB,CAAC;IAEO,SAAS,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AK,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,IAAW,OAAO,CAAC,KAAc;QAC7B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IAC1B,CAAC;CACJ","sourcesContent":["import { Logger } from \"../../../Misc/logger\";\r\nimport type { Scene } from \"../../../scene\";\r\nimport { Vector3, Vector2 } from \"../../../Maths/math.vector\";\r\nimport { Color4, Color3 } from \"../../../Maths/math.color\";\r\nimport { Texture } from \"../../../Materials/Textures/texture\";\r\nimport { ProceduralTexture } from \"./proceduralTexture\";\r\nimport { WebRequest } from \"../../../Misc/webRequest\";\r\nimport type { TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\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 called 'refMaps' or 'sampler' images.\r\n * Custom Procedural textures are the easiest way to create your own procedural in your application.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/proceduralTextures#creating-custom-procedural-textures\r\n */\r\nexport class CustomProceduralTexture extends ProceduralTexture {\r\n private _animate: boolean = true;\r\n private _time: number = 0;\r\n private _config: any;\r\n private _texturePath: string;\r\n\r\n /**\r\n * Instantiates a new Custom 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 * Custom Procedural textures are the easiest way to create your own procedural in your application.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/proceduralTextures#creating-custom-procedural-textures\r\n * @param name Define the name of the texture\r\n * @param texturePath Define the folder path containing all the custom texture related files (config, shaders...)\r\n * @param size Define the size of the texture to create\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 skipJson Define a boolena indicating that there is no json config file to load\r\n */\r\n constructor(name: string, texturePath: string, size: TextureSize, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean, skipJson?: boolean) {\r\n super(name, size, null, scene, fallbackTexture, generateMipMaps);\r\n this._texturePath = texturePath;\r\n\r\n if (!skipJson) {\r\n //Try to load json\r\n this._loadJson(texturePath);\r\n } else {\r\n this.setFragment(this._texturePath);\r\n }\r\n this.refreshRate = 1;\r\n }\r\n\r\n private _loadJson(jsonUrl: string): void {\r\n const noConfigFile = () => {\r\n try {\r\n this.setFragment(this._texturePath);\r\n } catch (ex) {\r\n Logger.Log(\"No json or ShaderStore or DOM element found for CustomProceduralTexture\");\r\n }\r\n };\r\n\r\n const configFileUrl = jsonUrl + \"/config.json\";\r\n const xhr = new WebRequest();\r\n\r\n xhr.open(\"GET\", configFileUrl);\r\n xhr.addEventListener(\r\n \"load\",\r\n () => {\r\n if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {\r\n try {\r\n this._config = JSON.parse(xhr.response);\r\n\r\n this.updateShaderUniforms();\r\n this.updateTextures();\r\n this.setFragment(this._texturePath + \"/custom\");\r\n\r\n this._animate = this._config.animate;\r\n this.refreshRate = this._config.refreshrate;\r\n } catch (ex) {\r\n noConfigFile();\r\n }\r\n } else {\r\n noConfigFile();\r\n }\r\n },\r\n false\r\n );\r\n\r\n xhr.addEventListener(\r\n \"error\",\r\n () => {\r\n noConfigFile();\r\n },\r\n false\r\n );\r\n\r\n try {\r\n xhr.send();\r\n } catch (ex) {\r\n Logger.Error(\"CustomProceduralTexture: Error on XHR send request.\");\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 isReady(): boolean {\r\n if (!super.isReady()) {\r\n return false;\r\n }\r\n\r\n for (const name in this._textures) {\r\n const texture = this._textures[name];\r\n\r\n if (!texture.isReady()) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\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 public render(useCameraPostProcess?: boolean): void {\r\n const scene = this.getScene();\r\n if (this._animate && scene) {\r\n this._time += scene.getAnimationRatio() * 0.03;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n super.render(useCameraPostProcess);\r\n }\r\n\r\n /**\r\n * Update the list of dependant textures samplers in the shader.\r\n */\r\n public updateTextures(): void {\r\n for (let i = 0; i < this._config.sampler2Ds.length; i++) {\r\n this.setTexture(this._config.sampler2Ds[i].sample2Dname, new Texture(this._texturePath + \"/\" + this._config.sampler2Ds[i].textureRelativeUrl, this.getScene()));\r\n }\r\n }\r\n\r\n /**\r\n * Update the uniform values of the procedural texture in the shader.\r\n */\r\n public updateShaderUniforms(): void {\r\n if (this._config) {\r\n for (let j = 0; j < this._config.uniforms.length; j++) {\r\n const uniform = this._config.uniforms[j];\r\n\r\n switch (uniform.type) {\r\n case \"float\":\r\n this.setFloat(uniform.name, uniform.value);\r\n break;\r\n case \"color3\":\r\n this.setColor3(uniform.name, new Color3(uniform.r, uniform.g, uniform.b));\r\n break;\r\n case \"color4\":\r\n this.setColor4(uniform.name, new Color4(uniform.r, uniform.g, uniform.b, uniform.a));\r\n break;\r\n case \"vector2\":\r\n this.setVector2(uniform.name, new Vector2(uniform.x, uniform.y));\r\n break;\r\n case \"vector3\":\r\n this.setVector3(uniform.name, new Vector3(uniform.x, uniform.y, uniform.z));\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this.setFloat(\"time\", this._time);\r\n }\r\n\r\n /**\r\n * Define if the texture animates or not.\r\n */\r\n public get animate(): boolean {\r\n return this._animate;\r\n }\r\n\r\n public set animate(value: boolean) {\r\n this._animate = value;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"customProceduralTexture.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Procedurals/customProceduralTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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AAK,CAAC;IAC1B,CAAC;CACJ","sourcesContent":["import { Logger } from \"../../../Misc/logger\";\r\nimport type { Scene } from \"../../../scene\";\r\nimport { Vector3, Vector2 } from \"../../../Maths/math.vector\";\r\nimport { Color4, Color3 } from \"../../../Maths/math.color\";\r\nimport { Texture } from \"../../../Materials/Textures/texture\";\r\nimport type { IProceduralTextureCreationOptions } from \"./proceduralTexture\";\r\nimport { ProceduralTexture } from \"./proceduralTexture\";\r\nimport { WebRequest } from \"../../../Misc/webRequest\";\r\nimport type { TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\n\r\n/**\r\n * Options to create a Custom Procedural Texture.\r\n */\r\nexport interface ICustomProceduralTextureCreationOptions extends IProceduralTextureCreationOptions {\r\n /**\r\n * Define a boolena indicating that there is no json config file to load\r\n */\r\n skipJson?: boolean;\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 called 'refMaps' or 'sampler' images.\r\n * Custom Procedural textures are the easiest way to create your own procedural in your application.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/proceduralTextures#creating-custom-procedural-textures\r\n */\r\nexport class CustomProceduralTexture extends ProceduralTexture {\r\n private _animate: boolean = true;\r\n private _time: number = 0;\r\n private _config: any;\r\n private _texturePath: string;\r\n\r\n /**\r\n * Instantiates a new Custom 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 * Custom Procedural textures are the easiest way to create your own procedural in your application.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/proceduralTextures#creating-custom-procedural-textures\r\n * @param name Define the name of the texture\r\n * @param texturePath Define the folder path containing all the custom texture related files (config, shaders...)\r\n * @param size Define the size of the texture to create\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 skipJson Define a boolena indicating that there is no json config file to load\r\n */\r\n constructor(\r\n name: string,\r\n texturePath: string,\r\n size: TextureSize,\r\n scene: Scene,\r\n fallbackTexture?: Texture | ICustomProceduralTextureCreationOptions,\r\n generateMipMaps?: boolean,\r\n skipJson?: boolean\r\n ) {\r\n super(name, size, null, scene, fallbackTexture, generateMipMaps);\r\n this._texturePath = texturePath;\r\n\r\n if (fallbackTexture && !(fallbackTexture instanceof Texture)) {\r\n skipJson = !!fallbackTexture.skipJson;\r\n }\r\n\r\n if (!skipJson) {\r\n //Try to load json\r\n this._loadJson(texturePath);\r\n } else {\r\n this.setFragment(this._texturePath);\r\n }\r\n this.refreshRate = 1;\r\n }\r\n\r\n private _loadJson(jsonUrl: string): void {\r\n const noConfigFile = () => {\r\n try {\r\n this.setFragment(this._texturePath);\r\n } catch (ex) {\r\n Logger.Log(\"No json or ShaderStore or DOM element found for CustomProceduralTexture\");\r\n }\r\n };\r\n\r\n const configFileUrl = jsonUrl + \"/config.json\";\r\n const xhr = new WebRequest();\r\n\r\n xhr.open(\"GET\", configFileUrl);\r\n xhr.addEventListener(\r\n \"load\",\r\n () => {\r\n if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {\r\n try {\r\n this._config = JSON.parse(xhr.response);\r\n\r\n this.updateShaderUniforms();\r\n this.updateTextures();\r\n this.setFragment(this._texturePath + \"/custom\");\r\n\r\n this._animate = this._config.animate;\r\n this.refreshRate = this._config.refreshrate;\r\n } catch (ex) {\r\n noConfigFile();\r\n }\r\n } else {\r\n noConfigFile();\r\n }\r\n },\r\n false\r\n );\r\n\r\n xhr.addEventListener(\r\n \"error\",\r\n () => {\r\n noConfigFile();\r\n },\r\n false\r\n );\r\n\r\n try {\r\n xhr.send();\r\n } catch (ex) {\r\n Logger.Error(\"CustomProceduralTexture: Error on XHR send request.\");\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 isReady(): boolean {\r\n if (!super.isReady()) {\r\n return false;\r\n }\r\n\r\n for (const name in this._textures) {\r\n const texture = this._textures[name];\r\n\r\n if (!texture.isReady()) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\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 public render(useCameraPostProcess?: boolean): void {\r\n const scene = this.getScene();\r\n if (this._animate && scene) {\r\n this._time += scene.getAnimationRatio() * 0.03;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n super.render(useCameraPostProcess);\r\n }\r\n\r\n /**\r\n * Update the list of dependant textures samplers in the shader.\r\n */\r\n public updateTextures(): void {\r\n for (let i = 0; i < this._config.sampler2Ds.length; i++) {\r\n this.setTexture(this._config.sampler2Ds[i].sample2Dname, new Texture(this._texturePath + \"/\" + this._config.sampler2Ds[i].textureRelativeUrl, this.getScene()));\r\n }\r\n }\r\n\r\n /**\r\n * Update the uniform values of the procedural texture in the shader.\r\n */\r\n public updateShaderUniforms(): void {\r\n if (this._config) {\r\n for (let j = 0; j < this._config.uniforms.length; j++) {\r\n const uniform = this._config.uniforms[j];\r\n\r\n switch (uniform.type) {\r\n case \"float\":\r\n this.setFloat(uniform.name, uniform.value);\r\n break;\r\n case \"color3\":\r\n this.setColor3(uniform.name, new Color3(uniform.r, uniform.g, uniform.b));\r\n break;\r\n case \"color4\":\r\n this.setColor4(uniform.name, new Color4(uniform.r, uniform.g, uniform.b, uniform.a));\r\n break;\r\n case \"vector2\":\r\n this.setVector2(uniform.name, new Vector2(uniform.x, uniform.y));\r\n break;\r\n case \"vector3\":\r\n this.setVector3(uniform.name, new Vector3(uniform.x, uniform.y, uniform.z));\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this.setFloat(\"time\", this._time);\r\n }\r\n\r\n /**\r\n * Define if the texture animates or not.\r\n */\r\n public get animate(): boolean {\r\n return this._animate;\r\n }\r\n\r\n public set animate(value: boolean) {\r\n this._animate = value;\r\n }\r\n}\r\n"]}
|
|
@@ -5,11 +5,21 @@ import type { Matrix, Vector3, Vector2 } from "../../../Maths/math.vector";
|
|
|
5
5
|
import type { Color4, Color3 } from "../../../Maths/math.color";
|
|
6
6
|
import type { Effect } from "../../../Materials/effect";
|
|
7
7
|
import { Texture } from "../../../Materials/Textures/texture";
|
|
8
|
+
import type { RenderTargetTextureOptions } from "../../../Materials/Textures/renderTargetTexture";
|
|
8
9
|
import "../../../Engines/Extensions/engine.renderTarget";
|
|
9
10
|
import "../../../Engines/Extensions/engine.renderTargetCube";
|
|
10
11
|
import "../../../Shaders/procedural.vertex";
|
|
11
12
|
import type { NodeMaterial } from "../../Node/nodeMaterial";
|
|
12
13
|
import type { TextureSize } from "../../../Materials/Textures/textureCreationOptions";
|
|
14
|
+
/**
|
|
15
|
+
* Options to create a procedural texture
|
|
16
|
+
*/
|
|
17
|
+
export interface IProceduralTextureCreationOptions extends RenderTargetTextureOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Defines a fallback texture in case there were issues to create the custom texture
|
|
20
|
+
*/
|
|
21
|
+
fallbackTexture?: Nullable<Texture>;
|
|
22
|
+
}
|
|
13
23
|
/**
|
|
14
24
|
* 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.
|
|
15
25
|
* This is the base class of any Procedural texture and contains most of the shareable code.
|
|
@@ -73,6 +83,7 @@ export declare class ProceduralTexture extends Texture {
|
|
|
73
83
|
private _contentUpdateId;
|
|
74
84
|
private _contentData;
|
|
75
85
|
private _rtWrapper;
|
|
86
|
+
private _options;
|
|
76
87
|
/**
|
|
77
88
|
* Instantiates a new procedural texture.
|
|
78
89
|
* 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.
|
|
@@ -90,7 +101,7 @@ export declare class ProceduralTexture extends Texture {
|
|
|
90
101
|
* @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
|
|
91
102
|
* @param textureType The FBO internal texture type
|
|
92
103
|
*/
|
|
93
|
-
constructor(name: string, size: TextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture
|
|
104
|
+
constructor(name: string, size: TextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture> | IProceduralTextureCreationOptions, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
|
|
94
105
|
private _createRtWrapper;
|
|
95
106
|
/**
|
|
96
107
|
* The effect that is created when initializing the post process.
|
|
@@ -98,7 +109,7 @@ export declare class ProceduralTexture extends Texture {
|
|
|
98
109
|
*/
|
|
99
110
|
getEffect(): Effect;
|
|
100
111
|
/**
|
|
101
|
-
* @internal
|
|
112
|
+
* @internal
|
|
102
113
|
*/
|
|
103
114
|
_setEffect(effect: Effect): void;
|
|
104
115
|
/**
|
|
@@ -38,6 +38,7 @@ export class ProceduralTexture extends Texture {
|
|
|
38
38
|
* @param textureType The FBO internal texture type
|
|
39
39
|
*/
|
|
40
40
|
constructor(name, size, fragment, scene, fallbackTexture = null, generateMipMaps = true, isCube = false, textureType = 0) {
|
|
41
|
+
var _a;
|
|
41
42
|
super(null, scene, !generateMipMaps);
|
|
42
43
|
/**
|
|
43
44
|
* Define if the texture is enabled or not (disabled texture will not render)
|
|
@@ -79,6 +80,14 @@ export class ProceduralTexture extends Texture {
|
|
|
79
80
|
this._cachedDefines = null;
|
|
80
81
|
this._contentUpdateId = -1;
|
|
81
82
|
this._rtWrapper = null;
|
|
83
|
+
if (fallbackTexture !== null && !(fallbackTexture instanceof Texture)) {
|
|
84
|
+
this._options = fallbackTexture;
|
|
85
|
+
this._fallbackTexture = (_a = fallbackTexture.fallbackTexture) !== null && _a !== void 0 ? _a : null;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this._options = {};
|
|
89
|
+
this._fallbackTexture = fallbackTexture;
|
|
90
|
+
}
|
|
82
91
|
scene = this.getScene() || EngineStore.LastCreatedScene;
|
|
83
92
|
let component = scene._getComponent(SceneComponentConstants.NAME_PROCEDURALTEXTURE);
|
|
84
93
|
if (!component) {
|
|
@@ -94,7 +103,6 @@ export class ProceduralTexture extends Texture {
|
|
|
94
103
|
this._generateMipMaps = generateMipMaps;
|
|
95
104
|
this._drawWrapper = new DrawWrapper(this._fullEngine);
|
|
96
105
|
this.setFragment(fragment);
|
|
97
|
-
this._fallbackTexture = fallbackTexture;
|
|
98
106
|
const rtWrapper = this._createRtWrapper(isCube, size, generateMipMaps, textureType);
|
|
99
107
|
this._texture = rtWrapper.texture;
|
|
100
108
|
// VBO
|
|
@@ -108,21 +116,11 @@ export class ProceduralTexture extends Texture {
|
|
|
108
116
|
}
|
|
109
117
|
_createRtWrapper(isCube, size, generateMipMaps, textureType) {
|
|
110
118
|
if (isCube) {
|
|
111
|
-
this._rtWrapper = this._fullEngine.createRenderTargetCubeTexture(size, {
|
|
112
|
-
generateMipMaps: generateMipMaps,
|
|
113
|
-
generateDepthBuffer: false,
|
|
114
|
-
generateStencilBuffer: false,
|
|
115
|
-
type: textureType,
|
|
116
|
-
});
|
|
119
|
+
this._rtWrapper = this._fullEngine.createRenderTargetCubeTexture(size, Object.assign({ generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false, type: textureType }, this._options));
|
|
117
120
|
this.setFloat("face", 0);
|
|
118
121
|
}
|
|
119
122
|
else {
|
|
120
|
-
this._rtWrapper = this._fullEngine.createRenderTargetTexture(size, {
|
|
121
|
-
generateMipMaps: generateMipMaps,
|
|
122
|
-
generateDepthBuffer: false,
|
|
123
|
-
generateStencilBuffer: false,
|
|
124
|
-
type: textureType,
|
|
125
|
-
});
|
|
123
|
+
this._rtWrapper = this._fullEngine.createRenderTargetTexture(size, Object.assign({ generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false, type: textureType }, this._options));
|
|
126
124
|
}
|
|
127
125
|
return this._rtWrapper;
|
|
128
126
|
}
|
|
@@ -134,7 +132,7 @@ export class ProceduralTexture extends Texture {
|
|
|
134
132
|
return this._drawWrapper.effect;
|
|
135
133
|
}
|
|
136
134
|
/**
|
|
137
|
-
* @internal
|
|
135
|
+
* @internal
|
|
138
136
|
*/
|
|
139
137
|
_setEffect(effect) {
|
|
140
138
|
this._drawWrapper.effect = effect;
|
|
@@ -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;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AACtF,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAEpF,OAAO,iDAAiD,CAAC;AACzD,OAAO,qDAAqD,CAAC;AAC7D,OAAO,oCAAoC,CAAC;AAE5C,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;AAGhD;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,OAAO;IA4E1C;;;;;;;;;;;;;;;;OAgBG;IACH,YACI,IAAY,EACZ,IAAiB,EACjB,QAAa,EACb,KAAsB,EACtB,kBAAqC,IAAI,EACzC,eAAe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CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SAC7C;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACpE,IAAI,YAAY,EAAE;YACd,YAAY,CAAC,OAAO,EAAE,CAAC;YACvB,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;SACzD;QAED,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;YACzE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC5B;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;AA9rBU;IADN,SAAS,EAAE;oDACY;AAMjB;IADN,SAAS,EAAE;oDACY;AAwBjB;IADN,SAAS,EAAE;2DACqB;AAWzB;IADP,SAAS,EAAE;gDACe;AAqS3B;IADC,SAAS,EAAE;oDAGX;AAgXL,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, Vector3, Vector2 } from \"../../../Maths/math.vector\";\r\nimport type { Color4, Color3 } from \"../../../Maths/math.color\";\r\nimport type { Engine } from \"../../../Engines/engine\";\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 { RenderTargetTexture } from \"../../../Materials/Textures/renderTargetTexture\";\r\nimport { ProceduralTextureSceneComponent } from \"./proceduralTextureSceneComponent\";\r\n\r\nimport \"../../../Engines/Extensions/engine.renderTarget\";\r\nimport \"../../../Engines/Extensions/engine.renderTargetCube\";\r\nimport \"../../../Shaders/procedural.vertex\";\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\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 /** @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]: Texture } = {};\r\n\r\n /** @internal */\r\n protected _fallbackTexture: Nullable<Texture>;\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 _matrices: { [key: string]: Matrix } = {};\r\n\r\n private _fallbackTextureUsed = false;\r\n private _fullEngine: Engine;\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\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> = null,\r\n generateMipMaps = true,\r\n isCube = false,\r\n textureType = Constants.TEXTURETYPE_UNSIGNED_INT\r\n ) {\r\n super(null, scene, !generateMipMaps);\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 this._fallbackTexture = fallbackTexture;\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 });\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 });\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 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 _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 \"\";\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 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(shaders, [VertexBuffer.PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, () => {\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 }\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: Texture): 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 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 // 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 }\r\n } else {\r\n engine.bindFramebuffer(this._rtWrapper, 0, undefined, undefined, true);\r\n\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect!);\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 }\r\n\r\n // Unbind and restore viewport\r\n engine.unBindFramebuffer(this._rtWrapper, this.isCube);\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);\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 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 dispose(): void {\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return;\r\n }\r\n\r\n const index = scene.proceduralTextures.indexOf(this);\r\n\r\n if (index >= 0) {\r\n scene.proceduralTextures.splice(index, 1);\r\n }\r\n\r\n const vertexBuffer = this._vertexBuffers[VertexBuffer.PositionKind];\r\n if (vertexBuffer) {\r\n vertexBuffer.dispose();\r\n this._vertexBuffers[VertexBuffer.PositionKind] = null;\r\n }\r\n\r\n if (this._indexBuffer && this._fullEngine._releaseBuffer(this._indexBuffer)) {\r\n this._indexBuffer = null;\r\n }\r\n\r\n this.onGeneratedObservable.clear();\r\n this.onBeforeGenerationObservable.clear();\r\n\r\n super.dispose();\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ProceduralTexture\", ProceduralTexture);\r\n"]}
|
|
1
|
+
{"version":3,"file":"proceduralTexture.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Procedurals/proceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAMtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AACtF,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAEpF,OAAO,iDAAiD,CAAC;AACzD,OAAO,qDAAqD,CAAC;AAC7D,OAAO,oCAAoC,CAAC;AAE5C,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;AAahD;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,OAAO;IA6E1C;;;;;;;;;;;;;;;;OAgBG;IACH,YACI,IAAY,EACZ,IAAiB,EACjB,QAAa,EACb,KAAsB,EACtB,kBAAyE,IAAI,EAC7E,eAAe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ED;;OAEG;IACI,OAAO;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAE9B,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QAED,MAAM,KAAK,GAAG,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAErD,IAAI,KAAK,IAAI,CAAC,EAAE;YACZ,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SAC7C;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACpE,IAAI,YAAY,EAAE;YACd,YAAY,CAAC,OAAO,EAAE,CAAC;YACvB,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;SACzD;QAED,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;YACzE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC5B;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;AAvsBU;IADN,SAAS,EAAE;oDACY;AAMjB;IADN,SAAS,EAAE;oDACY;AAwBjB;IADN,SAAS,EAAE;2DACqB;AAWzB;IADP,SAAS,EAAE;gDACe;AA8S3B;IADC,SAAS,EAAE;oDAGX;AAgXL,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, Vector3, Vector2 } from \"../../../Maths/math.vector\";\r\nimport type { Color4, Color3 } from \"../../../Maths/math.color\";\r\nimport type { Engine } from \"../../../Engines/engine\";\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 \"../../../Engines/Extensions/engine.renderTarget\";\r\nimport \"../../../Engines/Extensions/engine.renderTargetCube\";\r\nimport \"../../../Shaders/procedural.vertex\";\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\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\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 /** @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]: Texture } = {};\r\n\r\n /** @internal */\r\n protected _fallbackTexture: Nullable<Texture>;\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 _matrices: { [key: string]: Matrix } = {};\r\n\r\n private _fallbackTextureUsed = false;\r\n private _fullEngine: Engine;\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_INT\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 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 }\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 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 _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 \"\";\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 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(shaders, [VertexBuffer.PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, () => {\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 }\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: Texture): 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 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 // 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 }\r\n } else {\r\n engine.bindFramebuffer(this._rtWrapper, 0, undefined, undefined, true);\r\n\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect!);\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 }\r\n\r\n // Unbind and restore viewport\r\n engine.unBindFramebuffer(this._rtWrapper, this.isCube);\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);\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 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 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"]}
|
|
@@ -10,6 +10,7 @@ import type { ICanvasRenderingContext } from "../../Engines/ICanvas";
|
|
|
10
10
|
export declare class DynamicTexture extends Texture {
|
|
11
11
|
private _generateMipMaps;
|
|
12
12
|
private _canvas;
|
|
13
|
+
private _ownCanvas;
|
|
13
14
|
private _context;
|
|
14
15
|
/**
|
|
15
16
|
* Creates a DynamicTexture
|
|
@@ -72,6 +73,10 @@ export declare class DynamicTexture extends Texture {
|
|
|
72
73
|
* @param update defines whether texture is immediately update (default is true)
|
|
73
74
|
*/
|
|
74
75
|
drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, fillColor: string | null, invertY?: boolean, update?: boolean): void;
|
|
76
|
+
/**
|
|
77
|
+
* Disposes the dynamic texture.
|
|
78
|
+
*/
|
|
79
|
+
dispose(): void;
|
|
75
80
|
/**
|
|
76
81
|
* Clones the texture
|
|
77
82
|
* @returns the clone of the texture.
|
|
@@ -29,10 +29,12 @@ export class DynamicTexture extends Texture {
|
|
|
29
29
|
}
|
|
30
30
|
if (options.getContext) {
|
|
31
31
|
this._canvas = options;
|
|
32
|
+
this._ownCanvas = false;
|
|
32
33
|
this._texture = engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
36
|
this._canvas = engine.createCanvas(1, 1);
|
|
37
|
+
this._ownCanvas = true;
|
|
36
38
|
if (options.width || options.width === 0) {
|
|
37
39
|
this._texture = engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
|
|
38
40
|
}
|
|
@@ -148,6 +150,17 @@ export class DynamicTexture extends Texture {
|
|
|
148
150
|
this.update(invertY);
|
|
149
151
|
}
|
|
150
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Disposes the dynamic texture.
|
|
155
|
+
*/
|
|
156
|
+
dispose() {
|
|
157
|
+
super.dispose();
|
|
158
|
+
if (this._ownCanvas) {
|
|
159
|
+
this._canvas.remove();
|
|
160
|
+
}
|
|
161
|
+
this._canvas = null;
|
|
162
|
+
this._context = null;
|
|
163
|
+
}
|
|
151
164
|
/**
|
|
152
165
|
* Clones the texture
|
|
153
166
|
* @returns the clone of the texture.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamicTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/dynamicTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C,OAAO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ClB,CAAC;CACJ","sourcesContent":["import { Logger } from \"../../Misc/logger\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { ISize } from \"../../Maths/math.size\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport \"../../Engines/Extensions/engine.dynamicTexture\";\r\nimport type { ICanvas, ICanvasRenderingContext } from \"../../Engines/ICanvas\";\r\n\r\n/**\r\n * A class extending Texture allowing drawing on a texture\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/dynamicTexture\r\n */\r\nexport class DynamicTexture extends Texture {\r\n private _generateMipMaps: boolean;\r\n private _canvas: ICanvas;\r\n private _context: ICanvasRenderingContext;\r\n\r\n /**\r\n * Creates a DynamicTexture\r\n * @param name defines the name of the texture\r\n * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height\r\n * @param scene defines the scene where you want the texture\r\n * @param generateMipMaps defines the use of MinMaps or not (default is false)\r\n * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)\r\n * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)\r\n * @param invertY defines if the texture needs to be inverted on the y axis during loading\r\n */\r\n\r\n constructor(\r\n name: string,\r\n options: any,\r\n scene: Nullable<Scene> = null,\r\n generateMipMaps: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n format: number = Constants.TEXTUREFORMAT_RGBA,\r\n invertY?: boolean\r\n ) {\r\n super(null, scene, !generateMipMaps, invertY, samplingMode, undefined, undefined, undefined, undefined, format);\r\n\r\n this.name = name;\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n\r\n this._generateMipMaps = generateMipMaps;\r\n\r\n const engine = this._getEngine();\r\n if (!engine) {\r\n return;\r\n }\r\n\r\n if (options.getContext) {\r\n this._canvas = options;\r\n this._texture = engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);\r\n } else {\r\n this._canvas = engine.createCanvas(1, 1);\r\n\r\n if (options.width || options.width === 0) {\r\n this._texture = engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);\r\n } else {\r\n this._texture = engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);\r\n }\r\n }\r\n\r\n const textureSize = this.getSize();\r\n\r\n if (this._canvas.width !== textureSize.width) {\r\n this._canvas.width = textureSize.width;\r\n }\r\n if (this._canvas.height !== textureSize.height) {\r\n this._canvas.height = textureSize.height;\r\n }\r\n this._context = this._canvas.getContext(\"2d\");\r\n }\r\n\r\n /**\r\n * Get the current class name of the texture useful for serialization or dynamic coding.\r\n * @returns \"DynamicTexture\"\r\n */\r\n public getClassName(): string {\r\n return \"DynamicTexture\";\r\n }\r\n\r\n /**\r\n * Gets the current state of canRescale\r\n */\r\n public get canRescale(): boolean {\r\n return true;\r\n }\r\n\r\n private _recreate(textureSize: ISize): void {\r\n this._canvas.width = textureSize.width;\r\n this._canvas.height = textureSize.height;\r\n\r\n this.releaseInternalTexture();\r\n\r\n this._texture = this._getEngine()!.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);\r\n }\r\n\r\n /**\r\n * Scales the texture\r\n * @param ratio the scale factor to apply to both width and height\r\n */\r\n public scale(ratio: number): void {\r\n const textureSize = this.getSize();\r\n\r\n textureSize.width *= ratio;\r\n textureSize.height *= ratio;\r\n\r\n this._recreate(textureSize);\r\n }\r\n\r\n /**\r\n * Resizes the texture\r\n * @param width the new width\r\n * @param height the new height\r\n */\r\n public scaleTo(width: number, height: number): void {\r\n const textureSize = this.getSize();\r\n\r\n textureSize.width = width;\r\n textureSize.height = height;\r\n\r\n this._recreate(textureSize);\r\n }\r\n\r\n /**\r\n * Gets the context of the canvas used by the texture\r\n * @returns the canvas context of the dynamic texture\r\n */\r\n public getContext(): ICanvasRenderingContext {\r\n return this._context;\r\n }\r\n\r\n /**\r\n * Clears the texture\r\n * @param clearColor Defines the clear color to use\r\n */\r\n public clear(clearColor?: string): void {\r\n const size = this.getSize();\r\n if (clearColor) {\r\n this._context.fillStyle = clearColor;\r\n }\r\n this._context.clearRect(0, 0, size.width, size.height);\r\n }\r\n\r\n /**\r\n * Updates the texture\r\n * @param invertY defines the direction for the Y axis (default is true - y increases downwards)\r\n * @param premulAlpha defines if alpha is stored as premultiplied (default is false)\r\n * @param allowGPUOptimization true to allow some specific GPU optimizations (subject to engine feature \"allowGPUOptimizationsForGUI\" being true)\r\n */\r\n public update(invertY?: boolean, premulAlpha = false, allowGPUOptimization = false): void {\r\n this._getEngine()!.updateDynamicTexture(\r\n this._texture,\r\n this._canvas,\r\n invertY === undefined ? true : invertY,\r\n premulAlpha,\r\n this._format || undefined,\r\n undefined,\r\n allowGPUOptimization\r\n );\r\n }\r\n\r\n /**\r\n * Draws text onto the texture\r\n * @param text defines the text to be drawn\r\n * @param x defines the placement of the text from the left\r\n * @param y defines the placement of the text from the top when invertY is true and from the bottom when false\r\n * @param font defines the font to be used with font-style, font-size, font-name\r\n * @param color defines the color used for the text\r\n * @param fillColor defines the color for the canvas, use null to not overwrite canvas (this bleands with the background to replace, use the clear function)\r\n * @param invertY defines the direction for the Y axis (default is true - y increases downwards)\r\n * @param update defines whether texture is immediately update (default is true)\r\n */\r\n public drawText(\r\n text: string,\r\n x: number | null | undefined,\r\n y: number | null | undefined,\r\n font: string,\r\n color: string | null,\r\n fillColor: string | null,\r\n invertY?: boolean,\r\n update = true\r\n ) {\r\n const size = this.getSize();\r\n if (fillColor) {\r\n this._context.fillStyle = fillColor;\r\n this._context.fillRect(0, 0, size.width, size.height);\r\n }\r\n\r\n this._context.font = font;\r\n if (x === null || x === undefined) {\r\n const textSize = this._context.measureText(text);\r\n x = (size.width - textSize.width) / 2;\r\n }\r\n if (y === null || y === undefined) {\r\n const fontSize = parseInt(font.replace(/\\D/g, \"\"));\r\n y = size.height / 2 + fontSize / 3.65;\r\n }\r\n\r\n this._context.fillStyle = color || \"\";\r\n this._context.fillText(text, x, y);\r\n\r\n if (update) {\r\n this.update(invertY);\r\n }\r\n }\r\n\r\n /**\r\n * Clones the texture\r\n * @returns the clone of the texture.\r\n */\r\n public clone(): DynamicTexture {\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return this;\r\n }\r\n\r\n const textureSize = this.getSize();\r\n const newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);\r\n\r\n // Base texture\r\n newTexture.hasAlpha = this.hasAlpha;\r\n newTexture.level = this.level;\r\n\r\n // Dynamic Texture\r\n newTexture.wrapU = this.wrapU;\r\n newTexture.wrapV = this.wrapV;\r\n\r\n return newTexture;\r\n }\r\n\r\n /**\r\n * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized\r\n * @returns a serialized dynamic texture object\r\n */\r\n public serialize(): any {\r\n const scene = this.getScene();\r\n if (scene && !scene.isReady()) {\r\n Logger.Warn(\"The scene must be ready before serializing the dynamic texture\");\r\n }\r\n\r\n const serializationObject = super.serialize();\r\n if (DynamicTexture._IsCanvasElement(this._canvas)) {\r\n serializationObject.base64String = this._canvas.toDataURL();\r\n }\r\n\r\n serializationObject.invertY = this._invertY;\r\n serializationObject.samplingMode = this.samplingMode;\r\n\r\n return serializationObject;\r\n }\r\n\r\n private static _IsCanvasElement(canvas: HTMLCanvasElement | OffscreenCanvas | ICanvas): canvas is HTMLCanvasElement {\r\n return (canvas as HTMLCanvasElement).toDataURL !== undefined;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n this.update();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"dynamicTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/dynamicTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,S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,CAAC;QAC5C,mBAAmB,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QAErD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,MAAqD;QACjF,OAAQ,MAA4B,CAAC,SAAS,KAAK,SAAS,CAAC;IACjE,CAAC;IAED,gBAAgB;IACT,QAAQ;QACX,IAAI,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import { Logger } from \"../../Misc/logger\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { ISize } from \"../../Maths/math.size\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport \"../../Engines/Extensions/engine.dynamicTexture\";\r\nimport type { ICanvas, ICanvasRenderingContext } from \"../../Engines/ICanvas\";\r\n\r\n/**\r\n * A class extending Texture allowing drawing on a texture\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/dynamicTexture\r\n */\r\nexport class DynamicTexture extends Texture {\r\n private _generateMipMaps: boolean;\r\n private _canvas: ICanvas;\r\n private _ownCanvas: boolean;\r\n private _context: ICanvasRenderingContext;\r\n\r\n /**\r\n * Creates a DynamicTexture\r\n * @param name defines the name of the texture\r\n * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height\r\n * @param scene defines the scene where you want the texture\r\n * @param generateMipMaps defines the use of MinMaps or not (default is false)\r\n * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)\r\n * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)\r\n * @param invertY defines if the texture needs to be inverted on the y axis during loading\r\n */\r\n\r\n constructor(\r\n name: string,\r\n options: any,\r\n scene: Nullable<Scene> = null,\r\n generateMipMaps: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n format: number = Constants.TEXTUREFORMAT_RGBA,\r\n invertY?: boolean\r\n ) {\r\n super(null, scene, !generateMipMaps, invertY, samplingMode, undefined, undefined, undefined, undefined, format);\r\n\r\n this.name = name;\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n\r\n this._generateMipMaps = generateMipMaps;\r\n\r\n const engine = this._getEngine();\r\n if (!engine) {\r\n return;\r\n }\r\n\r\n if (options.getContext) {\r\n this._canvas = options;\r\n this._ownCanvas = false;\r\n this._texture = engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);\r\n } else {\r\n this._canvas = engine.createCanvas(1, 1);\r\n this._ownCanvas = true;\r\n\r\n if (options.width || options.width === 0) {\r\n this._texture = engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);\r\n } else {\r\n this._texture = engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);\r\n }\r\n }\r\n\r\n const textureSize = this.getSize();\r\n\r\n if (this._canvas.width !== textureSize.width) {\r\n this._canvas.width = textureSize.width;\r\n }\r\n if (this._canvas.height !== textureSize.height) {\r\n this._canvas.height = textureSize.height;\r\n }\r\n this._context = this._canvas.getContext(\"2d\");\r\n }\r\n\r\n /**\r\n * Get the current class name of the texture useful for serialization or dynamic coding.\r\n * @returns \"DynamicTexture\"\r\n */\r\n public getClassName(): string {\r\n return \"DynamicTexture\";\r\n }\r\n\r\n /**\r\n * Gets the current state of canRescale\r\n */\r\n public get canRescale(): boolean {\r\n return true;\r\n }\r\n\r\n private _recreate(textureSize: ISize): void {\r\n this._canvas.width = textureSize.width;\r\n this._canvas.height = textureSize.height;\r\n\r\n this.releaseInternalTexture();\r\n\r\n this._texture = this._getEngine()!.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);\r\n }\r\n\r\n /**\r\n * Scales the texture\r\n * @param ratio the scale factor to apply to both width and height\r\n */\r\n public scale(ratio: number): void {\r\n const textureSize = this.getSize();\r\n\r\n textureSize.width *= ratio;\r\n textureSize.height *= ratio;\r\n\r\n this._recreate(textureSize);\r\n }\r\n\r\n /**\r\n * Resizes the texture\r\n * @param width the new width\r\n * @param height the new height\r\n */\r\n public scaleTo(width: number, height: number): void {\r\n const textureSize = this.getSize();\r\n\r\n textureSize.width = width;\r\n textureSize.height = height;\r\n\r\n this._recreate(textureSize);\r\n }\r\n\r\n /**\r\n * Gets the context of the canvas used by the texture\r\n * @returns the canvas context of the dynamic texture\r\n */\r\n public getContext(): ICanvasRenderingContext {\r\n return this._context;\r\n }\r\n\r\n /**\r\n * Clears the texture\r\n * @param clearColor Defines the clear color to use\r\n */\r\n public clear(clearColor?: string): void {\r\n const size = this.getSize();\r\n if (clearColor) {\r\n this._context.fillStyle = clearColor;\r\n }\r\n this._context.clearRect(0, 0, size.width, size.height);\r\n }\r\n\r\n /**\r\n * Updates the texture\r\n * @param invertY defines the direction for the Y axis (default is true - y increases downwards)\r\n * @param premulAlpha defines if alpha is stored as premultiplied (default is false)\r\n * @param allowGPUOptimization true to allow some specific GPU optimizations (subject to engine feature \"allowGPUOptimizationsForGUI\" being true)\r\n */\r\n public update(invertY?: boolean, premulAlpha = false, allowGPUOptimization = false): void {\r\n this._getEngine()!.updateDynamicTexture(\r\n this._texture,\r\n this._canvas,\r\n invertY === undefined ? true : invertY,\r\n premulAlpha,\r\n this._format || undefined,\r\n undefined,\r\n allowGPUOptimization\r\n );\r\n }\r\n\r\n /**\r\n * Draws text onto the texture\r\n * @param text defines the text to be drawn\r\n * @param x defines the placement of the text from the left\r\n * @param y defines the placement of the text from the top when invertY is true and from the bottom when false\r\n * @param font defines the font to be used with font-style, font-size, font-name\r\n * @param color defines the color used for the text\r\n * @param fillColor defines the color for the canvas, use null to not overwrite canvas (this bleands with the background to replace, use the clear function)\r\n * @param invertY defines the direction for the Y axis (default is true - y increases downwards)\r\n * @param update defines whether texture is immediately update (default is true)\r\n */\r\n public drawText(\r\n text: string,\r\n x: number | null | undefined,\r\n y: number | null | undefined,\r\n font: string,\r\n color: string | null,\r\n fillColor: string | null,\r\n invertY?: boolean,\r\n update = true\r\n ) {\r\n const size = this.getSize();\r\n if (fillColor) {\r\n this._context.fillStyle = fillColor;\r\n this._context.fillRect(0, 0, size.width, size.height);\r\n }\r\n\r\n this._context.font = font;\r\n if (x === null || x === undefined) {\r\n const textSize = this._context.measureText(text);\r\n x = (size.width - textSize.width) / 2;\r\n }\r\n if (y === null || y === undefined) {\r\n const fontSize = parseInt(font.replace(/\\D/g, \"\"));\r\n y = size.height / 2 + fontSize / 3.65;\r\n }\r\n\r\n this._context.fillStyle = color || \"\";\r\n this._context.fillText(text, x, y);\r\n\r\n if (update) {\r\n this.update(invertY);\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the dynamic texture.\r\n */\r\n public dispose(): void {\r\n super.dispose();\r\n\r\n if (this._ownCanvas) {\r\n this._canvas.remove();\r\n }\r\n (this._canvas as any) = null;\r\n (this._context as any) = null;\r\n }\r\n\r\n /**\r\n * Clones the texture\r\n * @returns the clone of the texture.\r\n */\r\n public clone(): DynamicTexture {\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return this;\r\n }\r\n\r\n const textureSize = this.getSize();\r\n const newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);\r\n\r\n // Base texture\r\n newTexture.hasAlpha = this.hasAlpha;\r\n newTexture.level = this.level;\r\n\r\n // Dynamic Texture\r\n newTexture.wrapU = this.wrapU;\r\n newTexture.wrapV = this.wrapV;\r\n\r\n return newTexture;\r\n }\r\n\r\n /**\r\n * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized\r\n * @returns a serialized dynamic texture object\r\n */\r\n public serialize(): any {\r\n const scene = this.getScene();\r\n if (scene && !scene.isReady()) {\r\n Logger.Warn(\"The scene must be ready before serializing the dynamic texture\");\r\n }\r\n\r\n const serializationObject = super.serialize();\r\n if (DynamicTexture._IsCanvasElement(this._canvas)) {\r\n serializationObject.base64String = this._canvas.toDataURL();\r\n }\r\n\r\n serializationObject.invertY = this._invertY;\r\n serializationObject.samplingMode = this.samplingMode;\r\n\r\n return serializationObject;\r\n }\r\n\r\n private static _IsCanvasElement(canvas: HTMLCanvasElement | OffscreenCanvas | ICanvas): canvas is HTMLCanvasElement {\r\n return (canvas as HTMLCanvasElement).toDataURL !== undefined;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n this.update();\r\n }\r\n}\r\n"]}
|
|
@@ -82,8 +82,9 @@ export class VideoTexture extends Texture {
|
|
|
82
82
|
* @param format defines the texture format to use (Engine.TEXTUREFORMAT_RGBA by default)
|
|
83
83
|
*/
|
|
84
84
|
constructor(name, src, scene, generateMipMaps = false, invertY = false, samplingMode = Texture.TRILINEAR_SAMPLINGMODE, settings = {}, onError, format = 5) {
|
|
85
|
-
var _a
|
|
85
|
+
var _a;
|
|
86
86
|
super(null, scene, !generateMipMaps, invertY);
|
|
87
|
+
this._externalTexture = null;
|
|
87
88
|
this._onUserActionRequestedObservable = null;
|
|
88
89
|
this._stillImageCaptured = false;
|
|
89
90
|
this._displayingPosterTexture = false;
|
|
@@ -184,7 +185,9 @@ export class VideoTexture extends Texture {
|
|
|
184
185
|
this._currentSrc = src;
|
|
185
186
|
this.name = name || this._getName(src);
|
|
186
187
|
this.video = this._getVideo(src);
|
|
187
|
-
|
|
188
|
+
if ((_a = this._engine) === null || _a === void 0 ? void 0 : _a.createExternalTexture) {
|
|
189
|
+
this._externalTexture = this._engine.createExternalTexture(this.video);
|
|
190
|
+
}
|
|
188
191
|
if (!this._settings.independentVideoSource) {
|
|
189
192
|
if (this._settings.poster) {
|
|
190
193
|
this.video.poster = this._settings.poster;
|