{"ast":null,"code":"import _asyncToGenerator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer.js\";\n\n/**\n * Conversion modes available when copying a texture into another one\n */\nexport var ConversionMode;\n(function (ConversionMode) {\n ConversionMode[ConversionMode[\"None\"] = 0] = \"None\";\n ConversionMode[ConversionMode[\"ToLinearSpace\"] = 1] = \"ToLinearSpace\";\n ConversionMode[ConversionMode[\"ToGammaSpace\"] = 2] = \"ToGammaSpace\";\n})(ConversionMode || (ConversionMode = {}));\n/**\n * Class used for fast copy from one texture to another\n */\nexport class CopyTextureToTexture {\n /**\n * Gets the shader language\n */\n get shaderLanguage() {\n return this._shaderLanguage;\n }\n _textureIsInternal(texture) {\n return texture.getInternalTexture === undefined;\n }\n /**\n * Constructs a new instance of the class\n * @param engine The engine to use for the copy\n * @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)\n */\n constructor(engine, isDepthTexture = false) {\n /** Shader language used */\n this._shaderLanguage = 0 /* ShaderLanguage.GLSL */;\n this._shadersLoaded = false;\n this._engine = engine;\n this._isDepthTexture = isDepthTexture;\n this._renderer = new EffectRenderer(engine);\n this._initShaderSourceAsync(isDepthTexture);\n }\n _initShaderSourceAsync(isDepthTexture) {\n var _this = this;\n return _asyncToGenerator(function* () {\n const engine = _this._engine;\n if (engine.isWebGPU) {\n _this._shaderLanguage = 1 /* ShaderLanguage.WGSL */;\n yield import(\"../ShadersWGSL/copyTextureToTexture.fragment.js\");\n } else {\n yield import(\"../Shaders/copyTextureToTexture.fragment.js\");\n }\n _this._shadersLoaded = true;\n _this._effectWrapper = new EffectWrapper({\n engine: engine,\n name: \"CopyTextureToTexture\",\n fragmentShader: \"copyTextureToTexture\",\n useShaderStore: true,\n uniformNames: [\"conversion\"],\n samplerNames: [\"textureSampler\"],\n defines: isDepthTexture ? [\"#define DEPTH_TEXTURE\"] : [],\n shaderLanguage: _this._shaderLanguage\n });\n _this._effectWrapper.onApplyObservable.add(() => {\n if (isDepthTexture) {\n engine.setState(false);\n engine.setDepthBuffer(true);\n engine.depthCullingState.depthMask = true;\n engine.depthCullingState.depthFunc = 519;\n } else {\n engine.depthCullingState.depthMask = false;\n // other states are already set by EffectRenderer.applyEffectWrapper\n }\n if (_this._textureIsInternal(_this._source)) {\n _this._effectWrapper.effect._bindTexture(\"textureSampler\", _this._source);\n } else {\n _this._effectWrapper.effect.setTexture(\"textureSampler\", _this._source);\n }\n _this._effectWrapper.effect.setFloat(\"conversion\", _this._conversion);\n });\n })();\n }\n /**\n * Indicates if the effect is ready to be used for the copy\n * @returns true if \"copy\" can be called without delay, else false\n */\n isReady() {\n return this._shadersLoaded && this._effectWrapper.effect.isReady();\n }\n /**\n * Copy one texture into another\n * @param source The source texture\n * @param destination The destination texture. If null, copy the source to the currently bound framebuffer\n * @param conversion The conversion mode that should be applied when copying\n * @returns\n */\n copy(source, destination = null, conversion = 0 /* ConversionMode.None */) {\n if (!this.isReady()) {\n return false;\n }\n this._source = source;\n this._conversion = conversion;\n const engineDepthFunc = this._engine.getDepthFunction();\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\n this._renderer.render(this._effectWrapper, destination);\n this._engine.setDepthWrite(engineDepthMask);\n if (this._isDepthTexture && engineDepthFunc) {\n this._engine.setDepthFunction(engineDepthFunc);\n }\n return true;\n }\n /**\n * Releases all the resources used by the class\n */\n dispose() {\n var _this$_effectWrapper;\n (_this$_effectWrapper = this._effectWrapper) === null || _this$_effectWrapper === void 0 || _this$_effectWrapper.dispose();\n this._renderer.dispose();\n }\n}","map":{"version":3,"names":["EffectRenderer","EffectWrapper","ConversionMode","CopyTextureToTexture","shaderLanguage","_shaderLanguage","_textureIsInternal","texture","getInternalTexture","undefined","constructor","engine","isDepthTexture","_shadersLoaded","_engine","_isDepthTexture","_renderer","_initShaderSourceAsync","_this","_asyncToGenerator","isWebGPU","_effectWrapper","name","fragmentShader","useShaderStore","uniformNames","samplerNames","defines","onApplyObservable","add","setState","setDepthBuffer","depthCullingState","depthMask","depthFunc","_source","effect","_bindTexture","setTexture","setFloat","_conversion","isReady","copy","source","destination","conversion","engineDepthFunc","getDepthFunction","engineDepthMask","getDepthWrite","render","setDepthWrite","setDepthFunction","dispose","_this$_effectWrapper"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Misc/copyTextureToTexture.js"],"sourcesContent":["import { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer.js\";\n\n/**\n * Conversion modes available when copying a texture into another one\n */\nexport var ConversionMode;\n(function (ConversionMode) {\n ConversionMode[ConversionMode[\"None\"] = 0] = \"None\";\n ConversionMode[ConversionMode[\"ToLinearSpace\"] = 1] = \"ToLinearSpace\";\n ConversionMode[ConversionMode[\"ToGammaSpace\"] = 2] = \"ToGammaSpace\";\n})(ConversionMode || (ConversionMode = {}));\n/**\n * Class used for fast copy from one texture to another\n */\nexport class CopyTextureToTexture {\n /**\n * Gets the shader language\n */\n get shaderLanguage() {\n return this._shaderLanguage;\n }\n _textureIsInternal(texture) {\n return texture.getInternalTexture === undefined;\n }\n /**\n * Constructs a new instance of the class\n * @param engine The engine to use for the copy\n * @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)\n */\n constructor(engine, isDepthTexture = false) {\n /** Shader language used */\n this._shaderLanguage = 0 /* ShaderLanguage.GLSL */;\n this._shadersLoaded = false;\n this._engine = engine;\n this._isDepthTexture = isDepthTexture;\n this._renderer = new EffectRenderer(engine);\n this._initShaderSourceAsync(isDepthTexture);\n }\n async _initShaderSourceAsync(isDepthTexture) {\n const engine = this._engine;\n if (engine.isWebGPU) {\n this._shaderLanguage = 1 /* ShaderLanguage.WGSL */;\n await import(\"../ShadersWGSL/copyTextureToTexture.fragment.js\");\n }\n else {\n await import(\"../Shaders/copyTextureToTexture.fragment.js\");\n }\n this._shadersLoaded = true;\n this._effectWrapper = new EffectWrapper({\n engine: engine,\n name: \"CopyTextureToTexture\",\n fragmentShader: \"copyTextureToTexture\",\n useShaderStore: true,\n uniformNames: [\"conversion\"],\n samplerNames: [\"textureSampler\"],\n defines: isDepthTexture ? [\"#define DEPTH_TEXTURE\"] : [],\n shaderLanguage: this._shaderLanguage,\n });\n this._effectWrapper.onApplyObservable.add(() => {\n if (isDepthTexture) {\n engine.setState(false);\n engine.setDepthBuffer(true);\n engine.depthCullingState.depthMask = true;\n engine.depthCullingState.depthFunc = 519;\n }\n else {\n engine.depthCullingState.depthMask = false;\n // other states are already set by EffectRenderer.applyEffectWrapper\n }\n if (this._textureIsInternal(this._source)) {\n this._effectWrapper.effect._bindTexture(\"textureSampler\", this._source);\n }\n else {\n this._effectWrapper.effect.setTexture(\"textureSampler\", this._source);\n }\n this._effectWrapper.effect.setFloat(\"conversion\", this._conversion);\n });\n }\n /**\n * Indicates if the effect is ready to be used for the copy\n * @returns true if \"copy\" can be called without delay, else false\n */\n isReady() {\n return this._shadersLoaded && this._effectWrapper.effect.isReady();\n }\n /**\n * Copy one texture into another\n * @param source The source texture\n * @param destination The destination texture. If null, copy the source to the currently bound framebuffer\n * @param conversion The conversion mode that should be applied when copying\n * @returns\n */\n copy(source, destination = null, conversion = 0 /* ConversionMode.None */) {\n if (!this.isReady()) {\n return false;\n }\n this._source = source;\n this._conversion = conversion;\n const engineDepthFunc = this._engine.getDepthFunction();\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\n this._renderer.render(this._effectWrapper, destination);\n this._engine.setDepthWrite(engineDepthMask);\n if (this._isDepthTexture && engineDepthFunc) {\n this._engine.setDepthFunction(engineDepthFunc);\n }\n return true;\n }\n /**\n * Releases all the resources used by the class\n */\n dispose() {\n this._effectWrapper?.dispose();\n this._renderer.dispose();\n }\n}\n"],"mappings":";AAAA,SAASA,cAAc,EAAEC,aAAa,QAAQ,gCAAgC;;AAE9E;AACA;AAC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