a4be0bab0a7db503de99dd0fd802097c2a105b7c7658d5373036a1364ebda9d5.json 8.3 KB

1
  1. {"ast":null,"code":"import { ThinEngine } from \"../../Engines/thinEngine.js\";\n// back-compat\nimport { allocateAndCopyTypedBuffer } from \"../../Engines/abstractEngine.functions.js\";\nexport { allocateAndCopyTypedBuffer };\nThinEngine.prototype._readTexturePixelsSync = function (texture, width, height, faceIndex = -1, level = 0, buffer = null, flushRenderer = true, noDataConversion = false, x = 0, y = 0) {\n const gl = this._gl;\n if (!gl) {\n throw new Error(\"Engine does not have gl rendering context.\");\n }\n if (!this._dummyFramebuffer) {\n const dummy = gl.createFramebuffer();\n if (!dummy) {\n throw new Error(\"Unable to create dummy framebuffer\");\n }\n this._dummyFramebuffer = dummy;\n }\n gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);\n if (faceIndex > -1) {\n var _texture$_hardwareTex;\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, (_texture$_hardwareTex = texture._hardwareTexture) === null || _texture$_hardwareTex === void 0 ? void 0 : _texture$_hardwareTex.underlyingResource, level);\n } else {\n var _texture$_hardwareTex2;\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, (_texture$_hardwareTex2 = texture._hardwareTexture) === null || _texture$_hardwareTex2 === void 0 ? void 0 : _texture$_hardwareTex2.underlyingResource, level);\n }\n let readType = texture.type !== undefined ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;\n if (!noDataConversion) {\n switch (readType) {\n case gl.UNSIGNED_BYTE:\n if (!buffer) {\n buffer = new Uint8Array(4 * width * height);\n }\n readType = gl.UNSIGNED_BYTE;\n break;\n default:\n if (!buffer) {\n buffer = new Float32Array(4 * width * height);\n }\n readType = gl.FLOAT;\n break;\n }\n } else if (!buffer) {\n buffer = allocateAndCopyTypedBuffer(texture.type, 4 * width * height);\n }\n if (flushRenderer) {\n this.flushFramebuffer();\n }\n gl.readPixels(x, y, width, height, gl.RGBA, readType, buffer);\n gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);\n return buffer;\n};\nThinEngine.prototype._readTexturePixels = function (texture, width, height, faceIndex = -1, level = 0, buffer = null, flushRenderer = true, noDataConversion = false, x = 0, y = 0) {\n return Promise.resolve(this._readTexturePixelsSync(texture, width, height, faceIndex, level, buffer, flushRenderer, noDataConversion, x, y));\n};","map":{"version":3,"names":["ThinEngine","allocateAndCopyTypedBuffer","prototype","_readTexturePixelsSync","texture","width","height","faceIndex","level","buffer","flushRenderer","noDataConversion","x","y","gl","_gl","Error","_dummyFramebuffer","dummy","createFramebuffer","bindFramebuffer","FRAMEBUFFER","_texture$_hardwareTex","framebufferTexture2D","COLOR_ATTACHMENT0","TEXTURE_CUBE_MAP_POSITIVE_X","_hardwareTexture","underlyingResource","_texture$_hardwareTex2","TEXTURE_2D","readType","type","undefined","_getWebGLTextureType","UNSIGNED_BYTE","Uint8Array","Float32Array","FLOAT","flushFramebuffer","readPixels","RGBA","_currentFramebuffer","_readTexturePixels","Promise","resolve"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/Extensions/engine.readTexture.js"],"sourcesContent":["import { ThinEngine } from \"../../Engines/thinEngine.js\";\n// back-compat\nimport { allocateAndCopyTypedBuffer } from \"../../Engines/abstractEngine.functions.js\";\nexport { allocateAndCopyTypedBuffer };\nThinEngine.prototype._readTexturePixelsSync = function (texture, width, height, faceIndex = -1, level = 0, buffer = null, flushRenderer = true, noDataConversion = false, x = 0, y = 0) {\n const gl = this._gl;\n if (!gl) {\n throw new Error(\"Engine does not have gl rendering context.\");\n }\n if (!this._dummyFramebuffer) {\n const dummy = gl.createFramebuffer();\n if (!dummy) {\n throw new Error(\"Unable to create dummy framebuffer\");\n }\n this._dummyFramebuffer = dummy;\n }\n gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);\n if (faceIndex > -1) {\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._hardwareTexture?.underlyingResource, level);\n }\n else {\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._hardwareTexture?.underlyingResource, level);\n }\n let readType = texture.type !== undefined ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;\n if (!noDataConversion) {\n switch (readType) {\n case gl.UNSIGNED_BYTE:\n if (!buffer) {\n buffer = new Uint8Array(4 * width * height);\n }\n readType = gl.UNSIGNED_BYTE;\n break;\n default:\n if (!buffer) {\n buffer = new Float32Array(4 * width * height);\n }\n readType = gl.FLOAT;\n break;\n }\n }\n else if (!buffer) {\n buffer = allocateAndCopyTypedBuffer(texture.type, 4 * width * height);\n }\n if (flushRenderer) {\n this.flushFramebuffer();\n }\n gl.readPixels(x, y, width, height, gl.RGBA, readType, buffer);\n gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);\n return buffer;\n};\nThinEngine.prototype._readTexturePixels = function (texture, width, height, faceIndex = -1, level = 0, buffer = null, flushRenderer = true, noDataConversion = false, x = 0, y = 0) {\n return Promise.resolve(this._readTexturePixelsSync(texture, width, height, faceIndex, level, buffer, flushRenderer, noDataConversion, x, y));\n};\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,6BAA6B;AACxD;AACA,SAASC,0BAA0B,QAAQ,2CAA2C;AACtF,SAASA,0BAA0B;AACnCD,UAAU,CAACE,SAAS,CAACC,sBAAsB,GAAG,UAAUC,OAAO,EAAEC,KAAK,EAAEC,MAAM,EAAEC,SAAS,GAAG,CAAC,CAAC,EAAEC,KAAK,GAAG,CAAC,EAAEC,MAAM,GAAG,IAAI,EAAEC,aAAa,GAAG,IAAI,EAAEC,gBAAgB,GAAG,KAAK,EAAEC,CAAC,GAAG,CAAC,EAAEC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