f99a4ea96a4678edbd41f5aa39cb4c4f5f2ea6acaefbc42b4f684c9695e6d703.json 442 KB

1
  1. {"ast":null,"code":"import { createPipelineContext, createRawShaderProgram, createShaderProgram, _finalizePipelineContext, _preparePipelineContext, _setProgram, _executeWhenRenderingStateIsCompiled, getStateObject, _createShaderProgram, deleteStateObject, _isRenderingStateCompiled } from \"./thinEngine.functions.js\";\nimport { IsWrapper } from \"../Materials/drawWrapper.functions.js\";\nimport { Logger } from \"../Misc/logger.js\";\nimport { IsWindowObjectExist } from \"../Misc/domManagement.js\";\nimport { WebGLShaderProcessor } from \"./WebGL/webGLShaderProcessors.js\";\nimport { WebGL2ShaderProcessor } from \"./WebGL/webGL2ShaderProcessors.js\";\nimport { WebGLDataBuffer } from \"../Meshes/WebGL/webGLDataBuffer.js\";\nimport { GetExponentOfTwo } from \"../Misc/tools.functions.js\";\nimport { AbstractEngine } from \"./abstractEngine.js\";\nimport { WebGLHardwareTexture } from \"./WebGL/webGLHardwareTexture.js\";\nimport { InternalTexture, IsDepthTexture, HasStencilAspect } from \"../Materials/Textures/internalTexture.js\";\nimport { Effect } from \"../Materials/effect.js\";\nimport { _ConcatenateShader, _getGlobalDefines } from \"./abstractEngine.functions.js\";\nimport { resetCachedPipeline } from \"../Materials/effect.functions.js\";\n/**\n * Keeps track of all the buffer info used in engine.\n */\nclass BufferPointer {}\n/**\n * The base engine class (root of all engines)\n */\nexport class ThinEngine extends AbstractEngine {\n /**\n * Gets or sets the name of the engine\n */\n get name() {\n return this._name;\n }\n set name(value) {\n this._name = value;\n }\n /**\n * Returns the version of the engine\n */\n get version() {\n return this._webGLVersion;\n }\n /**\n * Gets or sets the relative url used to load shaders if using the engine in non-minified mode\n */\n static get ShadersRepository() {\n return Effect.ShadersRepository;\n }\n static set ShadersRepository(value) {\n Effect.ShadersRepository = value;\n }\n /**\n * Gets a boolean indicating that the engine supports uniform buffers\n * @see https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets\n */\n get supportsUniformBuffers() {\n return this.webGLVersion > 1 && !this.disableUniformBuffers;\n }\n /**\n * Gets a boolean indicating that only power of 2 textures are supported\n * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them\n */\n get needPOTTextures() {\n return this._webGLVersion < 2 || this.forcePOTTextures;\n }\n get _supportsHardwareTextureRescaling() {\n return false;\n }\n /**\n * sets the object from which width and height will be taken from when getting render width and height\n * Will fallback to the gl object\n * @param dimensions the framebuffer width and height that will be used.\n */\n set framebufferDimensionsObject(dimensions) {\n this._framebufferDimensionsObject = dimensions;\n }\n /**\n * Creates a new snapshot at the next frame using the current snapshotRenderingMode\n */\n snapshotRenderingReset() {\n this.snapshotRendering = false;\n }\n /**\n * Creates a new engine\n * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which already used the WebGL context\n * @param antialias defines whether anti-aliasing should be enabled (default value is \"undefined\", meaning that the browser may or may not enable it)\n * @param options defines further options to be sent to the getContext() function\n * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)\n */\n constructor(canvasOrContext, antialias, options, adaptToDeviceRatio) {\n options = options || {};\n super(antialias !== null && antialias !== void 0 ? antialias : options.antialias, options, adaptToDeviceRatio);\n /** @internal */\n this._name = \"WebGL\";\n /**\n * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required\n */\n this.forcePOTTextures = false;\n /** Gets or sets a boolean indicating if the engine should validate programs after compilation */\n this.validateShaderPrograms = false;\n /**\n * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported\n */\n this.disableUniformBuffers = false;\n /** @internal */\n this._webGLVersion = 1.0;\n this._vertexAttribArraysEnabled = [];\n this._uintIndicesCurrentlySet = false;\n this._currentBoundBuffer = new Array();\n /** @internal */\n this._currentFramebuffer = null;\n /** @internal */\n this._dummyFramebuffer = null;\n this._currentBufferPointers = new Array();\n this._currentInstanceLocations = new Array();\n this._currentInstanceBuffers = new Array();\n this._vaoRecordInProgress = false;\n this._mustWipeVertexAttributes = false;\n this._nextFreeTextureSlots = new Array();\n this._maxSimultaneousTextures = 0;\n this._maxMSAASamplesOverride = null;\n this._unpackFlipYCached = null;\n /**\n * In case you are sharing the context with other applications, it might\n * be interested to not cache the unpack flip y state to ensure a consistent\n * value would be set.\n */\n this.enableUnpackFlipYCached = true;\n /**\n * @internal\n */\n this._boundUniforms = {};\n if (!canvasOrContext) {\n return;\n }\n let canvas = null;\n if (canvasOrContext.getContext) {\n canvas = canvasOrContext;\n this._renderingCanvas = canvas;\n if (options.preserveDrawingBuffer === undefined) {\n options.preserveDrawingBuffer = false;\n }\n if (options.xrCompatible === undefined) {\n options.xrCompatible = false;\n }\n // Exceptions\n if (navigator && navigator.userAgent) {\n this._setupMobileChecks();\n const ua = navigator.userAgent;\n for (const exception of ThinEngine.ExceptionList) {\n const key = exception.key;\n const targets = exception.targets;\n const check = new RegExp(key);\n if (check.test(ua)) {\n if (exception.capture && exception.captureConstraint) {\n const capture = exception.capture;\n const constraint = exception.captureConstraint;\n const regex = new RegExp(capture);\n const matches = regex.exec(ua);\n if (matches && matches.length > 0) {\n const capturedValue = parseInt(matches[matches.length - 1]);\n if (capturedValue >= constraint) {\n continue;\n }\n }\n }\n for (const target of targets) {\n switch (target) {\n case \"uniformBuffer\":\n this.disableUniformBuffers = true;\n break;\n case \"vao\":\n this.disableVertexArrayObjects = true;\n break;\n case \"antialias\":\n options.antialias = false;\n break;\n case \"maxMSAASamples\":\n this._maxMSAASamplesOverride = 1;\n break;\n }\n }\n }\n }\n }\n // Context lost\n if (!this._doNotHandleContextLost) {\n this._onContextLost = evt => {\n evt.preventDefault();\n this._contextWasLost = true;\n Logger.Warn(\"WebGL context lost.\");\n this.onContextLostObservable.notifyObservers(this);\n };\n this._onContextRestored = () => {\n this._restoreEngineAfterContextLost(() => this._initGLContext());\n };\n canvas.addEventListener(\"webglcontextlost\", this._onContextLost, false);\n canvas.addEventListener(\"webglcontextrestored\", this._onContextRestored, false);\n options.powerPreference = options.powerPreference || \"high-performance\";\n }\n if (this._badDesktopOS) {\n options.xrCompatible = false;\n }\n // GL\n if (!options.disableWebGL2Support) {\n try {\n this._gl = canvas.getContext(\"webgl2\", options) || canvas.getContext(\"experimental-webgl2\", options);\n if (this._gl) {\n this._webGLVersion = 2.0;\n this._shaderPlatformName = \"WEBGL2\";\n // Prevent weird browsers to lie (yeah that happens!)\n if (!this._gl.deleteQuery) {\n this._webGLVersion = 1.0;\n this._shaderPlatformName = \"WEBGL1\";\n }\n }\n } catch (e) {\n // Do nothing\n }\n }\n if (!this._gl) {\n if (!canvas) {\n throw new Error(\"The provided canvas is null or undefined.\");\n }\n try {\n this._gl = canvas.getContext(\"webgl\", options) || canvas.getContext(\"experimental-webgl\", options);\n } catch (e) {\n throw new Error(\"WebGL not supported\");\n }\n }\n if (!this._gl) {\n throw new Error(\"WebGL not supported\");\n }\n } else {\n this._gl = canvasOrContext;\n this._renderingCanvas = this._gl.canvas;\n if (this._gl.renderbufferStorageMultisample) {\n this._webGLVersion = 2.0;\n this._shaderPlatformName = \"WEBGL2\";\n } else {\n this._shaderPlatformName = \"WEBGL1\";\n }\n const attributes = this._gl.getContextAttributes();\n if (attributes) {\n options.stencil = attributes.stencil;\n }\n }\n // Ensures a consistent color space unpacking of textures cross browser.\n this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);\n if (options.useHighPrecisionFloats !== undefined) {\n this._highPrecisionShadersAllowed = options.useHighPrecisionFloats;\n }\n this.resize();\n this._initGLContext();\n this._initFeatures();\n // Prepare buffer pointers\n for (let i = 0; i < this._caps.maxVertexAttribs; i++) {\n this._currentBufferPointers[i] = new BufferPointer();\n }\n // Shader processor\n this._shaderProcessor = this.webGLVersion > 1 ? new WebGL2ShaderProcessor() : new WebGLShaderProcessor();\n // Starting with iOS 14, we can trust the browser\n // let matches = navigator.userAgent.match(/Version\\/(\\d+)/);\n // if (matches && matches.length === 2) {\n // if (parseInt(matches[1]) >= 14) {\n // this._badOS = false;\n // }\n // }\n const versionToLog = `Babylon.js v${ThinEngine.Version}`;\n Logger.Log(versionToLog + ` - ${this.description}`);\n // Check setAttribute in case of workers\n if (this._renderingCanvas && this._renderingCanvas.setAttribute) {\n this._renderingCanvas.setAttribute(\"data-engine\", versionToLog);\n }\n const stateObject = getStateObject(this._gl);\n // update state object with the current engine state\n stateObject.validateShaderPrograms = this.validateShaderPrograms;\n stateObject.parallelShaderCompile = this._caps.parallelShaderCompile;\n }\n _clearEmptyResources() {\n this._dummyFramebuffer = null;\n super._clearEmptyResources();\n }\n /**\n * @internal\n */\n _getShaderProcessingContext(shaderLanguage) {\n return null;\n }\n /**\n * Gets a boolean indicating if all created effects are ready\n * @returns true if all effects are ready\n */\n areAllEffectsReady() {\n for (const key in this._compiledEffects) {\n const effect = this._compiledEffects[key];\n if (!effect.isReady()) {\n return false;\n }\n }\n return true;\n }\n _initGLContext() {\n // Caps\n this._caps = {\n maxTexturesImageUnits: this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),\n maxCombinedTexturesImageUnits: this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),\n maxVertexTextureImageUnits: this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),\n maxTextureSize: this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),\n maxSamples: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_SAMPLES) : 1,\n maxCubemapTextureSize: this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),\n maxRenderTextureSize: this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),\n maxVertexAttribs: this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),\n maxVaryingVectors: this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),\n maxFragmentUniformVectors: this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),\n maxVertexUniformVectors: this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),\n parallelShaderCompile: this._gl.getExtension(\"KHR_parallel_shader_compile\") || undefined,\n standardDerivatives: this._webGLVersion > 1 || this._gl.getExtension(\"OES_standard_derivatives\") !== null,\n maxAnisotropy: 1,\n astc: this._gl.getExtension(\"WEBGL_compressed_texture_astc\") || this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_astc\"),\n bptc: this._gl.getExtension(\"EXT_texture_compression_bptc\") || this._gl.getExtension(\"WEBKIT_EXT_texture_compression_bptc\"),\n s3tc: this._gl.getExtension(\"WEBGL_compressed_texture_s3tc\") || this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_s3tc\"),\n // eslint-disable-next-line @typescript-eslint/naming-convention\n s3tc_srgb: this._gl.getExtension(\"WEBGL_compressed_texture_s3tc_srgb\") || this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_s3tc_srgb\"),\n pvrtc: this._gl.getExtension(\"WEBGL_compressed_texture_pvrtc\") || this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_pvrtc\"),\n etc1: this._gl.getExtension(\"WEBGL_compressed_texture_etc1\") || this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_etc1\"),\n etc2: this._gl.getExtension(\"WEBGL_compressed_texture_etc\") || this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_etc\") || this._gl.getExtension(\"WEBGL_compressed_texture_es3_0\"),\n // also a requirement of OpenGL ES 3\n textureAnisotropicFilterExtension: this._gl.getExtension(\"EXT_texture_filter_anisotropic\") || this._gl.getExtension(\"WEBKIT_EXT_texture_filter_anisotropic\") || this._gl.getExtension(\"MOZ_EXT_texture_filter_anisotropic\"),\n uintIndices: this._webGLVersion > 1 || this._gl.getExtension(\"OES_element_index_uint\") !== null,\n fragmentDepthSupported: this._webGLVersion > 1 || this._gl.getExtension(\"EXT_frag_depth\") !== null,\n highPrecisionShaderSupported: false,\n timerQuery: this._gl.getExtension(\"EXT_disjoint_timer_query_webgl2\") || this._gl.getExtension(\"EXT_disjoint_timer_query\"),\n supportOcclusionQuery: this._webGLVersion > 1,\n canUseTimestampForTimerQuery: false,\n drawBuffersExtension: false,\n maxMSAASamples: 1,\n colorBufferFloat: !!(this._webGLVersion > 1 && this._gl.getExtension(\"EXT_color_buffer_float\")),\n supportFloatTexturesResolve: false,\n rg11b10ufColorRenderable: false,\n colorBufferHalfFloat: !!(this._webGLVersion > 1 && this._gl.getExtension(\"EXT_color_buffer_half_float\")),\n textureFloat: this._webGLVersion > 1 || this._gl.getExtension(\"OES_texture_float\") ? true : false,\n textureHalfFloat: this._webGLVersion > 1 || this._gl.getExtension(\"OES_texture_half_float\") ? true : false,\n textureHalfFloatRender: false,\n textureFloatLinearFiltering: false,\n textureFloatRender: false,\n textureHalfFloatLinearFiltering: false,\n vertexArrayObject: false,\n instancedArrays: false,\n textureLOD: this._webGLVersion > 1 || this._gl.getExtension(\"EXT_shader_texture_lod\") ? true : false,\n texelFetch: this._webGLVersion !== 1,\n blendMinMax: false,\n multiview: this._gl.getExtension(\"OVR_multiview2\"),\n oculusMultiview: this._gl.getExtension(\"OCULUS_multiview\"),\n depthTextureExtension: false,\n canUseGLInstanceID: this._webGLVersion > 1,\n canUseGLVertexID: this._webGLVersion > 1,\n supportComputeShaders: false,\n supportSRGBBuffers: false,\n supportTransformFeedbacks: this._webGLVersion > 1,\n textureMaxLevel: this._webGLVersion > 1,\n texture2DArrayMaxLayerCount: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_ARRAY_TEXTURE_LAYERS) : 128,\n disableMorphTargetTexture: false,\n textureNorm16: this._gl.getExtension(\"EXT_texture_norm16\") ? true : false\n };\n this._caps.supportFloatTexturesResolve = this._caps.colorBufferFloat;\n this._caps.rg11b10ufColorRenderable = this._caps.colorBufferFloat;\n // Infos\n this._glVersion = this._gl.getParameter(this._gl.VERSION);\n const rendererInfo = this._gl.getExtension(\"WEBGL_debug_renderer_info\");\n if (rendererInfo != null) {\n this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);\n this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);\n }\n if (!this._glVendor) {\n this._glVendor = this._gl.getParameter(this._gl.VENDOR) || \"Unknown vendor\";\n }\n if (!this._glRenderer) {\n this._glRenderer = this._gl.getParameter(this._gl.RENDERER) || \"Unknown renderer\";\n }\n // Constants\n if (this._gl.HALF_FLOAT_OES !== 0x8d61) {\n this._gl.HALF_FLOAT_OES = 0x8d61; // Half floating-point type (16-bit).\n }\n if (this._gl.RGBA16F !== 0x881a) {\n this._gl.RGBA16F = 0x881a; // RGBA 16-bit floating-point color-renderable internal sized format.\n }\n if (this._gl.RGBA32F !== 0x8814) {\n this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.\n }\n if (this._gl.DEPTH24_STENCIL8 !== 35056) {\n this._gl.DEPTH24_STENCIL8 = 35056;\n }\n // Extensions\n if (this._caps.timerQuery) {\n var _this$_gl$getQuery;\n if (this._webGLVersion === 1) {\n this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);\n }\n // WebGLQuery casted to number to avoid TS error\n this._caps.canUseTimestampForTimerQuery = ((_this$_gl$getQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)) !== null && _this$_gl$getQuery !== void 0 ? _this$_gl$getQuery : 0) > 0;\n }\n this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;\n this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension(\"OES_texture_float_linear\") ? true : false;\n this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;\n this._caps.textureHalfFloatLinearFiltering = this._webGLVersion > 1 || this._caps.textureHalfFloat && this._gl.getExtension(\"OES_texture_half_float_linear\") ? true : false;\n if (this._caps.textureNorm16) {\n this._gl.R16_EXT = 0x822a;\n this._gl.RG16_EXT = 0x822c;\n this._gl.RGB16_EXT = 0x8054;\n this._gl.RGBA16_EXT = 0x805b;\n this._gl.R16_SNORM_EXT = 0x8f98;\n this._gl.RG16_SNORM_EXT = 0x8f99;\n this._gl.RGB16_SNORM_EXT = 0x8f9a;\n this._gl.RGBA16_SNORM_EXT = 0x8f9b;\n }\n // Compressed formats\n if (this._caps.astc) {\n this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;\n }\n if (this._caps.bptc) {\n this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;\n }\n if (this._caps.s3tc_srgb) {\n this._gl.COMPRESSED_SRGB_S3TC_DXT1_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_S3TC_DXT1_EXT;\n this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;\n this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;\n }\n if (this._caps.etc2) {\n this._gl.COMPRESSED_SRGB8_ETC2 = this._caps.etc2.COMPRESSED_SRGB8_ETC2;\n this._gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = this._caps.etc2.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;\n }\n // Checks if some of the format renders first to allow the use of webgl inspector.\n if (this._webGLVersion > 1) {\n if (this._gl.HALF_FLOAT_OES !== 0x140b) {\n this._gl.HALF_FLOAT_OES = 0x140b;\n }\n }\n this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();\n // Draw buffers\n if (this._webGLVersion > 1) {\n this._caps.drawBuffersExtension = true;\n this._caps.maxMSAASamples = this._maxMSAASamplesOverride !== null ? this._maxMSAASamplesOverride : this._gl.getParameter(this._gl.MAX_SAMPLES);\n this._caps.maxDrawBuffers = this._gl.getParameter(this._gl.MAX_DRAW_BUFFERS);\n } else {\n const drawBuffersExtension = this._gl.getExtension(\"WEBGL_draw_buffers\");\n if (drawBuffersExtension !== null) {\n this._caps.drawBuffersExtension = true;\n this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);\n this._caps.maxDrawBuffers = this._gl.getParameter(drawBuffersExtension.MAX_DRAW_BUFFERS_WEBGL);\n this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;\n for (let i = 0; i < 16; i++) {\n this._gl[\"COLOR_ATTACHMENT\" + i + \"_WEBGL\"] = drawBuffersExtension[\"COLOR_ATTACHMENT\" + i + \"_WEBGL\"];\n }\n }\n }\n // Depth Texture\n if (this._webGLVersion > 1) {\n this._caps.depthTextureExtension = true;\n } else {\n const depthTextureExtension = this._gl.getExtension(\"WEBGL_depth_texture\");\n if (depthTextureExtension != null) {\n this._caps.depthTextureExtension = true;\n this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;\n }\n }\n // Vertex array object\n if (this.disableVertexArrayObjects) {\n this._caps.vertexArrayObject = false;\n } else if (this._webGLVersion > 1) {\n this._caps.vertexArrayObject = true;\n } else {\n const vertexArrayObjectExtension = this._gl.getExtension(\"OES_vertex_array_object\");\n if (vertexArrayObjectExtension != null) {\n this._caps.vertexArrayObject = true;\n this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);\n this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);\n this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);\n }\n }\n // Instances count\n if (this._webGLVersion > 1) {\n this._caps.instancedArrays = true;\n } else {\n const instanceExtension = this._gl.getExtension(\"ANGLE_instanced_arrays\");\n if (instanceExtension != null) {\n this._caps.instancedArrays = true;\n this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);\n this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);\n this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);\n } else {\n this._caps.instancedArrays = false;\n }\n }\n if (this._gl.getShaderPrecisionFormat) {\n const vertexhighp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);\n const fragmenthighp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);\n if (vertexhighp && fragmenthighp) {\n this._caps.highPrecisionShaderSupported = vertexhighp.precision !== 0 && fragmenthighp.precision !== 0;\n }\n }\n if (this._webGLVersion > 1) {\n this._caps.blendMinMax = true;\n } else {\n const blendMinMaxExtension = this._gl.getExtension(\"EXT_blend_minmax\");\n if (blendMinMaxExtension != null) {\n this._caps.blendMinMax = true;\n this._gl.MAX = blendMinMaxExtension.MAX_EXT;\n this._gl.MIN = blendMinMaxExtension.MIN_EXT;\n }\n }\n // sRGB buffers\n // only run this if not already set to true (in the constructor, for example)\n if (!this._caps.supportSRGBBuffers) {\n if (this._webGLVersion > 1) {\n this._caps.supportSRGBBuffers = true;\n this._glSRGBExtensionValues = {\n SRGB: WebGL2RenderingContext.SRGB,\n SRGB8: WebGL2RenderingContext.SRGB8,\n SRGB8_ALPHA8: WebGL2RenderingContext.SRGB8_ALPHA8\n };\n } else {\n const sRGBExtension = this._gl.getExtension(\"EXT_sRGB\");\n if (sRGBExtension != null) {\n this._caps.supportSRGBBuffers = true;\n this._glSRGBExtensionValues = {\n SRGB: sRGBExtension.SRGB_EXT,\n SRGB8: sRGBExtension.SRGB_ALPHA_EXT,\n SRGB8_ALPHA8: sRGBExtension.SRGB_ALPHA_EXT\n };\n }\n }\n // take into account the forced state that was provided in options\n if (this._creationOptions) {\n const forceSRGBBufferSupportState = this._creationOptions.forceSRGBBufferSupportState;\n if (forceSRGBBufferSupportState !== undefined) {\n this._caps.supportSRGBBuffers = this._caps.supportSRGBBuffers && forceSRGBBufferSupportState;\n }\n }\n }\n // Depth buffer\n this._depthCullingState.depthTest = true;\n this._depthCullingState.depthFunc = this._gl.LEQUAL;\n this._depthCullingState.depthMask = true;\n // Texture maps\n this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;\n for (let slot = 0; slot < this._maxSimultaneousTextures; slot++) {\n this._nextFreeTextureSlots.push(slot);\n }\n if (this._glRenderer === \"Mali-G72\") {\n // Overcome a bug when using a texture to store morph targets on Mali-G72\n this._caps.disableMorphTargetTexture = true;\n }\n }\n _initFeatures() {\n this._features = {\n forceBitmapOverHTMLImageElement: typeof HTMLImageElement === \"undefined\",\n supportRenderAndCopyToLodForFloatTextures: this._webGLVersion !== 1,\n supportDepthStencilTexture: this._webGLVersion !== 1,\n supportShadowSamplers: this._webGLVersion !== 1,\n uniformBufferHardCheckMatrix: false,\n allowTexturePrefiltering: this._webGLVersion !== 1,\n trackUbosInFrame: false,\n checkUbosContentBeforeUpload: false,\n supportCSM: this._webGLVersion !== 1,\n basisNeedsPOT: this._webGLVersion === 1,\n support3DTextures: this._webGLVersion !== 1,\n needTypeSuffixInShaderConstants: this._webGLVersion !== 1,\n supportMSAA: this._webGLVersion !== 1,\n supportSSAO2: this._webGLVersion !== 1,\n supportIBLShadows: this._webGLVersion !== 1,\n supportExtendedTextureFormats: this._webGLVersion !== 1,\n supportSwitchCaseInShader: this._webGLVersion !== 1,\n supportSyncTextureRead: true,\n needsInvertingBitmap: true,\n useUBOBindingCache: true,\n needShaderCodeInlining: false,\n needToAlwaysBindUniformBuffers: false,\n supportRenderPasses: false,\n supportSpriteInstancing: true,\n forceVertexBufferStrideAndOffsetMultiple4Bytes: false,\n _checkNonFloatVertexBuffersDontRecreatePipelineContext: false,\n _collectUbosUpdatedInFrame: false\n };\n }\n /**\n * Gets version of the current webGL context\n * Keep it for back compat - use version instead\n */\n get webGLVersion() {\n return this._webGLVersion;\n }\n /**\n * Gets a string identifying the name of the class\n * @returns \"Engine\" string\n */\n getClassName() {\n return \"ThinEngine\";\n }\n /** @internal */\n _prepareWorkingCanvas() {\n if (this._workingCanvas) {\n return;\n }\n this._workingCanvas = this.createCanvas(1, 1);\n const context = this._workingCanvas.getContext(\"2d\");\n if (context) {\n this._workingContext = context;\n }\n }\n /**\n * Gets an object containing information about the current engine context\n * @returns an object containing the vendor, the renderer and the version of the current engine context\n */\n getInfo() {\n return this.getGlInfo();\n }\n /**\n * Gets an object containing information about the current webGL context\n * @returns an object containing the vendor, the renderer and the version of the current webGL context\n */\n getGlInfo() {\n return {\n vendor: this._glVendor,\n renderer: this._glRenderer,\n version: this._glVersion\n };\n }\n /**Gets driver info if available */\n extractDriverInfo() {\n const glInfo = this.getGlInfo();\n if (glInfo && glInfo.renderer) {\n return glInfo.renderer;\n }\n return \"\";\n }\n /**\n * Gets the current render width\n * @param useScreen defines if screen size must be used (or the current render target if any)\n * @returns a number defining the current render width\n */\n getRenderWidth(useScreen = false) {\n if (!useScreen && this._currentRenderTarget) {\n return this._currentRenderTarget.width;\n }\n return this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferWidth : this._gl.drawingBufferWidth;\n }\n /**\n * Gets the current render height\n * @param useScreen defines if screen size must be used (or the current render target if any)\n * @returns a number defining the current render height\n */\n getRenderHeight(useScreen = false) {\n if (!useScreen && this._currentRenderTarget) {\n return this._currentRenderTarget.height;\n }\n return this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferHeight : this._gl.drawingBufferHeight;\n }\n /**\n * Clear the current render buffer or the current render target (if any is set up)\n * @param color defines the color to use\n * @param backBuffer defines if the back buffer must be cleared\n * @param depth defines if the depth buffer must be cleared\n * @param stencil defines if the stencil buffer must be cleared\n */\n clear(color, backBuffer, depth, stencil = false) {\n const useStencilGlobalOnly = this.stencilStateComposer.useStencilGlobalOnly;\n this.stencilStateComposer.useStencilGlobalOnly = true; // make sure the stencil mask is coming from the global stencil and not from a material (effect) which would currently be in effect\n this.applyStates();\n this.stencilStateComposer.useStencilGlobalOnly = useStencilGlobalOnly;\n let mode = 0;\n if (backBuffer && color) {\n let setBackBufferColor = true;\n if (this._currentRenderTarget) {\n var _this$_currentRenderT;\n const textureFormat = (_this$_currentRenderT = this._currentRenderTarget.texture) === null || _this$_currentRenderT === void 0 ? void 0 : _this$_currentRenderT.format;\n if (textureFormat === 8 || textureFormat === 9 || textureFormat === 10 || textureFormat === 11) {\n var _this$_currentRenderT2;\n const textureType = (_this$_currentRenderT2 = this._currentRenderTarget.texture) === null || _this$_currentRenderT2 === void 0 ? void 0 : _this$_currentRenderT2.type;\n if (textureType === 7 || textureType === 5) {\n ThinEngine._TempClearColorUint32[0] = color.r * 255;\n ThinEngine._TempClearColorUint32[1] = color.g * 255;\n ThinEngine._TempClearColorUint32[2] = color.b * 255;\n ThinEngine._TempClearColorUint32[3] = color.a * 255;\n this._gl.clearBufferuiv(this._gl.COLOR, 0, ThinEngine._TempClearColorUint32);\n setBackBufferColor = false;\n } else {\n ThinEngine._TempClearColorInt32[0] = color.r * 255;\n ThinEngine._TempClearColorInt32[1] = color.g * 255;\n ThinEngine._TempClearColorInt32[2] = color.b * 255;\n ThinEngine._TempClearColorInt32[3] = color.a * 255;\n this._gl.clearBufferiv(this._gl.COLOR, 0, ThinEngine._TempClearColorInt32);\n setBackBufferColor = false;\n }\n }\n }\n if (setBackBufferColor) {\n this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);\n mode |= this._gl.COLOR_BUFFER_BIT;\n }\n }\n if (depth) {\n if (this.useReverseDepthBuffer) {\n this._depthCullingState.depthFunc = this._gl.GEQUAL;\n this._gl.clearDepth(0.0);\n } else {\n this._gl.clearDepth(1.0);\n }\n mode |= this._gl.DEPTH_BUFFER_BIT;\n }\n if (stencil) {\n this._gl.clearStencil(0);\n mode |= this._gl.STENCIL_BUFFER_BIT;\n }\n this._gl.clear(mode);\n }\n /**\n * @internal\n */\n _viewport(x, y, width, height) {\n if (x !== this._viewportCached.x || y !== this._viewportCached.y || width !== this._viewportCached.z || height !== this._viewportCached.w) {\n this._viewportCached.x = x;\n this._viewportCached.y = y;\n this._viewportCached.z = width;\n this._viewportCached.w = height;\n this._gl.viewport(x, y, width, height);\n }\n }\n /**\n * End the current frame\n */\n endFrame() {\n super.endFrame();\n // Force a flush in case we are using a bad OS.\n if (this._badOS) {\n this.flushFramebuffer();\n }\n }\n /**\n * Gets the performance monitor attached to this engine\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#engineinstrumentation\n */\n get performanceMonitor() {\n throw new Error(\"Not Supported by ThinEngine\");\n }\n /**\n * Binds the frame buffer to the specified texture.\n * @param rtWrapper The render target wrapper to render to\n * @param faceIndex The face of the texture to render to in case of cube texture and if the render target wrapper is not a multi render target\n * @param requiredWidth The width of the target to render to\n * @param requiredHeight The height of the target to render to\n * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true\n * @param lodLevel Defines the lod level to bind to the frame buffer\n * @param layer Defines the 2d array index to bind to the frame buffer if the render target wrapper is not a multi render target\n */\n bindFramebuffer(rtWrapper, faceIndex = 0, requiredWidth, requiredHeight, forceFullscreenViewport, lodLevel = 0, layer = 0) {\n const webglRTWrapper = rtWrapper;\n if (this._currentRenderTarget) {\n this.unBindFramebuffer(this._currentRenderTarget);\n }\n this._currentRenderTarget = rtWrapper;\n this._bindUnboundFramebuffer(webglRTWrapper._framebuffer);\n const gl = this._gl;\n if (!rtWrapper.isMulti) {\n if (rtWrapper.is2DArray || rtWrapper.is3D) {\n var _rtWrapper$texture$_h;\n gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, (_rtWrapper$texture$_h = rtWrapper.texture._hardwareTexture) === null || _rtWrapper$texture$_h === void 0 ? void 0 : _rtWrapper$texture$_h.underlyingResource, lodLevel, layer);\n webglRTWrapper._currentLOD = lodLevel;\n } else if (rtWrapper.isCube) {\n var _rtWrapper$texture$_h2;\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, (_rtWrapper$texture$_h2 = rtWrapper.texture._hardwareTexture) === null || _rtWrapper$texture$_h2 === void 0 ? void 0 : _rtWrapper$texture$_h2.underlyingResource, lodLevel);\n } else if (webglRTWrapper._currentLOD !== lodLevel) {\n var _rtWrapper$texture$_h3;\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, (_rtWrapper$texture$_h3 = rtWrapper.texture._hardwareTexture) === null || _rtWrapper$texture$_h3 === void 0 ? void 0 : _rtWrapper$texture$_h3.underlyingResource, lodLevel);\n webglRTWrapper._currentLOD = lodLevel;\n }\n }\n const depthStencilTexture = rtWrapper._depthStencilTexture;\n if (depthStencilTexture) {\n if (rtWrapper.is3D) {\n if (rtWrapper.texture.width !== depthStencilTexture.width || rtWrapper.texture.height !== depthStencilTexture.height || rtWrapper.texture.depth !== depthStencilTexture.depth) {\n Logger.Warn(\"Depth/Stencil attachment for 3D target must have same dimensions as color attachment\");\n }\n }\n const attachment = rtWrapper._depthStencilTextureWithStencil ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;\n if (rtWrapper.is2DArray || rtWrapper.is3D) {\n var _depthStencilTexture$;\n gl.framebufferTextureLayer(gl.FRAMEBUFFER, attachment, (_depthStencilTexture$ = depthStencilTexture._hardwareTexture) === null || _depthStencilTexture$ === void 0 ? void 0 : _depthStencilTexture$.underlyingResource, lodLevel, layer);\n } else if (rtWrapper.isCube) {\n var _depthStencilTexture$2;\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, (_depthStencilTexture$2 = depthStencilTexture._hardwareTexture) === null || _depthStencilTexture$2 === void 0 ? void 0 : _depthStencilTexture$2.underlyingResource, lodLevel);\n } else {\n var _depthStencilTexture$3;\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, (_depthStencilTexture$3 = depthStencilTexture._hardwareTexture) === null || _depthStencilTexture$3 === void 0 ? void 0 : _depthStencilTexture$3.underlyingResource, lodLevel);\n }\n }\n if (webglRTWrapper._MSAAFramebuffer) {\n this._bindUnboundFramebuffer(webglRTWrapper._MSAAFramebuffer);\n }\n if (this._cachedViewport && !forceFullscreenViewport) {\n this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);\n } else {\n if (!requiredWidth) {\n requiredWidth = rtWrapper.width;\n if (lodLevel) {\n requiredWidth = requiredWidth / Math.pow(2, lodLevel);\n }\n }\n if (!requiredHeight) {\n requiredHeight = rtWrapper.height;\n if (lodLevel) {\n requiredHeight = requiredHeight / Math.pow(2, lodLevel);\n }\n }\n this._viewport(0, 0, requiredWidth, requiredHeight);\n }\n this.wipeCaches();\n }\n /**\n * Set various states to the webGL context\n * @param culling defines culling state: true to enable culling, false to disable it\n * @param zOffset defines the value to apply to zOffset (0 by default)\n * @param force defines if states must be applied even if cache is up to date\n * @param reverseSide defines if culling must be reversed (CCW if false, CW if true)\n * @param cullBackFaces true to cull back faces, false to cull front faces (if culling is enabled)\n * @param stencil stencil states to set\n * @param zOffsetUnits defines the value to apply to zOffsetUnits (0 by default)\n */\n setState(culling, zOffset = 0, force, reverseSide = false, cullBackFaces, stencil, zOffsetUnits = 0) {\n var _ref, _this$cullBackFaces;\n // Culling\n if (this._depthCullingState.cull !== culling || force) {\n this._depthCullingState.cull = culling;\n }\n // Cull face\n const cullFace = ((_ref = (_this$cullBackFaces = this.cullBackFaces) !== null && _this$cullBackFaces !== void 0 ? _this$cullBackFaces : cullBackFaces) !== null && _ref !== void 0 ? _ref : true) ? this._gl.BACK : this._gl.FRONT;\n if (this._depthCullingState.cullFace !== cullFace || force) {\n this._depthCullingState.cullFace = cullFace;\n }\n // Z offset\n this.setZOffset(zOffset);\n this.setZOffsetUnits(zOffsetUnits);\n // Front face\n const frontFace = reverseSide ? this._gl.CW : this._gl.CCW;\n if (this._depthCullingState.frontFace !== frontFace || force) {\n this._depthCullingState.frontFace = frontFace;\n }\n this._stencilStateComposer.stencilMaterial = stencil;\n }\n /**\n * @internal\n */\n _bindUnboundFramebuffer(framebuffer) {\n if (this._currentFramebuffer !== framebuffer) {\n this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);\n this._currentFramebuffer = framebuffer;\n }\n }\n /** @internal */\n _currentFrameBufferIsDefaultFrameBuffer() {\n return this._currentFramebuffer === null;\n }\n /**\n * Generates the mipmaps for a texture\n * @param texture texture to generate the mipmaps for\n */\n generateMipmaps(texture) {\n const target = this._getTextureTarget(texture);\n this._bindTextureDirectly(target, texture, true);\n this._gl.generateMipmap(target);\n this._bindTextureDirectly(target, null);\n }\n /**\n * Unbind the current render target texture from the webGL context\n * @param texture defines the render target wrapper to unbind\n * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated\n * @param onBeforeUnbind defines a function which will be called before the effective unbind\n */\n unBindFramebuffer(texture, disableGenerateMipMaps = false, onBeforeUnbind) {\n const webglRTWrapper = texture;\n this._currentRenderTarget = null;\n if (!webglRTWrapper.disableAutomaticMSAAResolve) {\n if (texture.isMulti) {\n this.resolveMultiFramebuffer(texture);\n } else {\n this.resolveFramebuffer(texture);\n }\n }\n if (!disableGenerateMipMaps) {\n if (texture.isMulti) {\n this.generateMipMapsMultiFramebuffer(texture);\n } else {\n this.generateMipMapsFramebuffer(texture);\n }\n }\n if (onBeforeUnbind) {\n if (webglRTWrapper._MSAAFramebuffer) {\n // Bind the correct framebuffer\n this._bindUnboundFramebuffer(webglRTWrapper._framebuffer);\n }\n onBeforeUnbind();\n }\n this._bindUnboundFramebuffer(null);\n }\n /**\n * Generates mipmaps for the texture of the (single) render target\n * @param texture The render target containing the texture to generate the mipmaps for\n */\n generateMipMapsFramebuffer(texture) {\n var _texture$texture;\n if (!texture.isMulti && (_texture$texture = texture.texture) !== null && _texture$texture !== void 0 && _texture$texture.generateMipMaps && !texture.isCube) {\n this.generateMipmaps(texture.texture);\n }\n }\n /**\n * Resolves the MSAA texture of the (single) render target into its non-MSAA version.\n * Note that if \"texture\" is not a MSAA render target, no resolve is performed.\n * @param texture The render target texture containing the MSAA textures to resolve\n */\n resolveFramebuffer(texture) {\n const rtWrapper = texture;\n const gl = this._gl;\n if (!rtWrapper._MSAAFramebuffer || rtWrapper.isMulti) {\n return;\n }\n let bufferBits = rtWrapper.resolveMSAAColors ? gl.COLOR_BUFFER_BIT : 0;\n bufferBits |= rtWrapper._generateDepthBuffer && rtWrapper.resolveMSAADepth ? gl.DEPTH_BUFFER_BIT : 0;\n bufferBits |= rtWrapper._generateStencilBuffer && rtWrapper.resolveMSAAStencil ? gl.STENCIL_BUFFER_BIT : 0;\n gl.bindFramebuffer(gl.READ_FRAMEBUFFER, rtWrapper._MSAAFramebuffer);\n gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, rtWrapper._framebuffer);\n gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, bufferBits, gl.NEAREST);\n }\n /**\n * Force a webGL flush (ie. a flush of all waiting webGL commands)\n */\n flushFramebuffer() {\n this._gl.flush();\n }\n /**\n * Unbind the current render target and bind the default framebuffer\n */\n restoreDefaultFramebuffer() {\n if (this._currentRenderTarget) {\n this.unBindFramebuffer(this._currentRenderTarget);\n } else {\n this._bindUnboundFramebuffer(null);\n }\n if (this._cachedViewport) {\n this.setViewport(this._cachedViewport);\n }\n this.wipeCaches();\n }\n // VBOs\n /** @internal */\n _resetVertexBufferBinding() {\n this.bindArrayBuffer(null);\n this._cachedVertexBuffers = null;\n }\n /**\n * Creates a vertex buffer\n * @param data the data or size for the vertex buffer\n * @param _updatable whether the buffer should be created as updatable\n * @param _label defines the label of the buffer (for debug purpose)\n * @returns the new WebGL static buffer\n */\n createVertexBuffer(data, _updatable, _label) {\n return this._createVertexBuffer(data, this._gl.STATIC_DRAW);\n }\n _createVertexBuffer(data, usage) {\n const vbo = this._gl.createBuffer();\n if (!vbo) {\n throw new Error(\"Unable to create vertex buffer\");\n }\n const dataBuffer = new WebGLDataBuffer(vbo);\n this.bindArrayBuffer(dataBuffer);\n if (typeof data !== \"number\") {\n if (data instanceof Array) {\n this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), usage);\n dataBuffer.capacity = data.length * 4;\n } else {\n this._gl.bufferData(this._gl.ARRAY_BUFFER, data, usage);\n dataBuffer.capacity = data.byteLength;\n }\n } else {\n this._gl.bufferData(this._gl.ARRAY_BUFFER, new Uint8Array(data), usage);\n dataBuffer.capacity = data;\n }\n this._resetVertexBufferBinding();\n dataBuffer.references = 1;\n return dataBuffer;\n }\n /**\n * Creates a dynamic vertex buffer\n * @param data the data for the dynamic vertex buffer\n * @param _label defines the label of the buffer (for debug purpose)\n * @returns the new WebGL dynamic buffer\n */\n createDynamicVertexBuffer(data, _label) {\n return this._createVertexBuffer(data, this._gl.DYNAMIC_DRAW);\n }\n _resetIndexBufferBinding() {\n this.bindIndexBuffer(null);\n this._cachedIndexBuffer = null;\n }\n /**\n * Creates a new index buffer\n * @param indices defines the content of the index buffer\n * @param updatable defines if the index buffer must be updatable\n * @param _label defines the label of the buffer (for debug purpose)\n * @returns a new webGL buffer\n */\n createIndexBuffer(indices, updatable, _label) {\n const vbo = this._gl.createBuffer();\n const dataBuffer = new WebGLDataBuffer(vbo);\n if (!vbo) {\n throw new Error(\"Unable to create index buffer\");\n }\n this.bindIndexBuffer(dataBuffer);\n const data = this._normalizeIndexData(indices);\n this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, data, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);\n this._resetIndexBufferBinding();\n dataBuffer.references = 1;\n dataBuffer.is32Bits = data.BYTES_PER_ELEMENT === 4;\n return dataBuffer;\n }\n _normalizeIndexData(indices) {\n const bytesPerElement = indices.BYTES_PER_ELEMENT;\n if (bytesPerElement === 2) {\n return indices;\n }\n // Check 32 bit support\n if (this._caps.uintIndices) {\n if (indices instanceof Uint32Array) {\n return indices;\n } else {\n // number[] or Int32Array, check if 32 bit is necessary\n for (let index = 0; index < indices.length; index++) {\n if (indices[index] >= 65535) {\n return new Uint32Array(indices);\n }\n }\n return new Uint16Array(indices);\n }\n }\n // No 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)\n return new Uint16Array(indices);\n }\n /**\n * Bind a webGL buffer to the webGL context\n * @param buffer defines the buffer to bind\n */\n bindArrayBuffer(buffer) {\n if (!this._vaoRecordInProgress) {\n this._unbindVertexArrayObject();\n }\n this._bindBuffer(buffer, this._gl.ARRAY_BUFFER);\n }\n /**\n * Bind a specific block at a given index in a specific shader program\n * @param pipelineContext defines the pipeline context to use\n * @param blockName defines the block name\n * @param index defines the index where to bind the block\n */\n bindUniformBlock(pipelineContext, blockName, index) {\n const program = pipelineContext.program;\n const uniformLocation = this._gl.getUniformBlockIndex(program, blockName);\n this._gl.uniformBlockBinding(program, uniformLocation, index);\n }\n // eslint-disable-next-line @typescript-eslint/naming-convention\n bindIndexBuffer(buffer) {\n if (!this._vaoRecordInProgress) {\n this._unbindVertexArrayObject();\n }\n this._bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);\n }\n _bindBuffer(buffer, target) {\n if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {\n this._gl.bindBuffer(target, buffer ? buffer.underlyingResource : null);\n this._currentBoundBuffer[target] = buffer;\n }\n }\n /**\n * update the bound buffer with the given data\n * @param data defines the data to update\n */\n updateArrayBuffer(data) {\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);\n }\n _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset) {\n const pointer = this._currentBufferPointers[indx];\n if (!pointer) {\n return;\n }\n let changed = false;\n if (!pointer.active) {\n changed = true;\n pointer.active = true;\n pointer.index = indx;\n pointer.size = size;\n pointer.type = type;\n pointer.normalized = normalized;\n pointer.stride = stride;\n pointer.offset = offset;\n pointer.buffer = buffer;\n } else {\n if (pointer.buffer !== buffer) {\n pointer.buffer = buffer;\n changed = true;\n }\n if (pointer.size !== size) {\n pointer.size = size;\n changed = true;\n }\n if (pointer.type !== type) {\n pointer.type = type;\n changed = true;\n }\n if (pointer.normalized !== normalized) {\n pointer.normalized = normalized;\n changed = true;\n }\n if (pointer.stride !== stride) {\n pointer.stride = stride;\n changed = true;\n }\n if (pointer.offset !== offset) {\n pointer.offset = offset;\n changed = true;\n }\n }\n if (changed || this._vaoRecordInProgress) {\n this.bindArrayBuffer(buffer);\n if (type === this._gl.UNSIGNED_INT || type === this._gl.INT) {\n this._gl.vertexAttribIPointer(indx, size, type, stride, offset);\n } else {\n this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);\n }\n }\n }\n /**\n * @internal\n */\n _bindIndexBufferWithCache(indexBuffer) {\n if (indexBuffer == null) {\n return;\n }\n if (this._cachedIndexBuffer !== indexBuffer) {\n this._cachedIndexBuffer = indexBuffer;\n this.bindIndexBuffer(indexBuffer);\n this._uintIndicesCurrentlySet = indexBuffer.is32Bits;\n }\n }\n _bindVertexBuffersAttributes(vertexBuffers, effect, overrideVertexBuffers) {\n const attributes = effect.getAttributesNames();\n if (!this._vaoRecordInProgress) {\n this._unbindVertexArrayObject();\n }\n this.unbindAllAttributes();\n for (let index = 0; index < attributes.length; index++) {\n const order = effect.getAttributeLocation(index);\n if (order >= 0) {\n const ai = attributes[index];\n let vertexBuffer = null;\n if (overrideVertexBuffers) {\n vertexBuffer = overrideVertexBuffers[ai];\n }\n if (!vertexBuffer) {\n vertexBuffer = vertexBuffers[ai];\n }\n if (!vertexBuffer) {\n continue;\n }\n this._gl.enableVertexAttribArray(order);\n if (!this._vaoRecordInProgress) {\n this._vertexAttribArraysEnabled[order] = true;\n }\n const buffer = vertexBuffer.getBuffer();\n if (buffer) {\n this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);\n if (vertexBuffer.getIsInstanced()) {\n this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());\n if (!this._vaoRecordInProgress) {\n this._currentInstanceLocations.push(order);\n this._currentInstanceBuffers.push(buffer);\n }\n }\n }\n }\n }\n }\n /**\n * Records a vertex array object\n * @see https://doc.babylonjs.com/setup/support/webGL2#vertex-array-objects\n * @param vertexBuffers defines the list of vertex buffers to store\n * @param indexBuffer defines the index buffer to store\n * @param effect defines the effect to store\n * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers\n * @returns the new vertex array object\n */\n recordVertexArrayObject(vertexBuffers, indexBuffer, effect, overrideVertexBuffers) {\n const vao = this._gl.createVertexArray();\n if (!vao) {\n throw new Error(\"Unable to create VAO\");\n }\n this._vaoRecordInProgress = true;\n this._gl.bindVertexArray(vao);\n this._mustWipeVertexAttributes = true;\n this._bindVertexBuffersAttributes(vertexBuffers, effect, overrideVertexBuffers);\n this.bindIndexBuffer(indexBuffer);\n this._vaoRecordInProgress = false;\n this._gl.bindVertexArray(null);\n return vao;\n }\n /**\n * Bind a specific vertex array object\n * @see https://doc.babylonjs.com/setup/support/webGL2#vertex-array-objects\n * @param vertexArrayObject defines the vertex array object to bind\n * @param indexBuffer defines the index buffer to bind\n */\n bindVertexArrayObject(vertexArrayObject, indexBuffer) {\n if (this._cachedVertexArrayObject !== vertexArrayObject) {\n this._cachedVertexArrayObject = vertexArrayObject;\n this._gl.bindVertexArray(vertexArrayObject);\n this._cachedVertexBuffers = null;\n this._cachedIndexBuffer = null;\n this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;\n this._mustWipeVertexAttributes = true;\n }\n }\n /**\n * Bind webGl buffers directly to the webGL context\n * @param vertexBuffer defines the vertex buffer to bind\n * @param indexBuffer defines the index buffer to bind\n * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer\n * @param vertexStrideSize defines the vertex stride of the vertex buffer\n * @param effect defines the effect associated with the vertex buffer\n */\n bindBuffersDirectly(vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {\n if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {\n this._cachedVertexBuffers = vertexBuffer;\n this._cachedEffectForVertexBuffers = effect;\n const attributesCount = effect.getAttributesCount();\n this._unbindVertexArrayObject();\n this.unbindAllAttributes();\n let offset = 0;\n for (let index = 0; index < attributesCount; index++) {\n if (index < vertexDeclaration.length) {\n const order = effect.getAttributeLocation(index);\n if (order >= 0) {\n this._gl.enableVertexAttribArray(order);\n this._vertexAttribArraysEnabled[order] = true;\n this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);\n }\n offset += vertexDeclaration[index] * 4;\n }\n }\n }\n this._bindIndexBufferWithCache(indexBuffer);\n }\n _unbindVertexArrayObject() {\n if (!this._cachedVertexArrayObject) {\n return;\n }\n this._cachedVertexArrayObject = null;\n this._gl.bindVertexArray(null);\n }\n /**\n * Bind a list of vertex buffers to the webGL context\n * @param vertexBuffers defines the list of vertex buffers to bind\n * @param indexBuffer defines the index buffer to bind\n * @param effect defines the effect associated with the vertex buffers\n * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers\n */\n bindBuffers(vertexBuffers, indexBuffer, effect, overrideVertexBuffers) {\n if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {\n this._cachedVertexBuffers = vertexBuffers;\n this._cachedEffectForVertexBuffers = effect;\n this._bindVertexBuffersAttributes(vertexBuffers, effect, overrideVertexBuffers);\n }\n this._bindIndexBufferWithCache(indexBuffer);\n }\n /**\n * Unbind all instance attributes\n */\n unbindInstanceAttributes() {\n let boundBuffer;\n for (let i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {\n const instancesBuffer = this._currentInstanceBuffers[i];\n if (boundBuffer != instancesBuffer && instancesBuffer.references) {\n boundBuffer = instancesBuffer;\n this.bindArrayBuffer(instancesBuffer);\n }\n const offsetLocation = this._currentInstanceLocations[i];\n this._gl.vertexAttribDivisor(offsetLocation, 0);\n }\n this._currentInstanceBuffers.length = 0;\n this._currentInstanceLocations.length = 0;\n }\n /**\n * Release and free the memory of a vertex array object\n * @param vao defines the vertex array object to delete\n */\n releaseVertexArrayObject(vao) {\n this._gl.deleteVertexArray(vao);\n }\n /**\n * @internal\n */\n _releaseBuffer(buffer) {\n buffer.references--;\n if (buffer.references === 0) {\n this._deleteBuffer(buffer);\n return true;\n }\n return false;\n }\n _deleteBuffer(buffer) {\n this._gl.deleteBuffer(buffer.underlyingResource);\n }\n /**\n * Update the content of a webGL buffer used with instantiation and bind it to the webGL context\n * @param instancesBuffer defines the webGL buffer to update and bind\n * @param data defines the data to store in the buffer\n * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer\n */\n updateAndBindInstancesBuffer(instancesBuffer, data, offsetLocations) {\n this.bindArrayBuffer(instancesBuffer);\n if (data) {\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);\n }\n if (offsetLocations[0].index !== undefined) {\n this.bindInstancesBuffer(instancesBuffer, offsetLocations, true);\n } else {\n for (let index = 0; index < 4; index++) {\n const offsetLocation = offsetLocations[index];\n if (!this._vertexAttribArraysEnabled[offsetLocation]) {\n this._gl.enableVertexAttribArray(offsetLocation);\n this._vertexAttribArraysEnabled[offsetLocation] = true;\n }\n this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);\n this._gl.vertexAttribDivisor(offsetLocation, 1);\n this._currentInstanceLocations.push(offsetLocation);\n this._currentInstanceBuffers.push(instancesBuffer);\n }\n }\n }\n /**\n * Bind the content of a webGL buffer used with instantiation\n * @param instancesBuffer defines the webGL buffer to bind\n * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer\n * @param computeStride defines Whether to compute the strides from the info or use the default 0\n */\n bindInstancesBuffer(instancesBuffer, attributesInfo, computeStride = true) {\n this.bindArrayBuffer(instancesBuffer);\n let stride = 0;\n if (computeStride) {\n for (let i = 0; i < attributesInfo.length; i++) {\n const ai = attributesInfo[i];\n stride += ai.attributeSize * 4;\n }\n }\n for (let i = 0; i < attributesInfo.length; i++) {\n const ai = attributesInfo[i];\n if (ai.index === undefined) {\n ai.index = this._currentEffect.getAttributeLocationByName(ai.attributeName);\n }\n if (ai.index < 0) {\n continue;\n }\n if (!this._vertexAttribArraysEnabled[ai.index]) {\n this._gl.enableVertexAttribArray(ai.index);\n this._vertexAttribArraysEnabled[ai.index] = true;\n }\n this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attributeType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);\n this._gl.vertexAttribDivisor(ai.index, ai.divisor === undefined ? 1 : ai.divisor);\n this._currentInstanceLocations.push(ai.index);\n this._currentInstanceBuffers.push(instancesBuffer);\n }\n }\n /**\n * Disable the instance attribute corresponding to the name in parameter\n * @param name defines the name of the attribute to disable\n */\n disableInstanceAttributeByName(name) {\n if (!this._currentEffect) {\n return;\n }\n const attributeLocation = this._currentEffect.getAttributeLocationByName(name);\n this.disableInstanceAttribute(attributeLocation);\n }\n /**\n * Disable the instance attribute corresponding to the location in parameter\n * @param attributeLocation defines the attribute location of the attribute to disable\n */\n disableInstanceAttribute(attributeLocation) {\n let shouldClean = false;\n let index;\n while ((index = this._currentInstanceLocations.indexOf(attributeLocation)) !== -1) {\n this._currentInstanceLocations.splice(index, 1);\n this._currentInstanceBuffers.splice(index, 1);\n shouldClean = true;\n index = this._currentInstanceLocations.indexOf(attributeLocation);\n }\n if (shouldClean) {\n this._gl.vertexAttribDivisor(attributeLocation, 0);\n this.disableAttributeByIndex(attributeLocation);\n }\n }\n /**\n * Disable the attribute corresponding to the location in parameter\n * @param attributeLocation defines the attribute location of the attribute to disable\n */\n disableAttributeByIndex(attributeLocation) {\n this._gl.disableVertexAttribArray(attributeLocation);\n this._vertexAttribArraysEnabled[attributeLocation] = false;\n this._currentBufferPointers[attributeLocation].active = false;\n }\n /**\n * Send a draw order\n * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)\n * @param indexStart defines the starting index\n * @param indexCount defines the number of index to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n draw(useTriangles, indexStart, indexCount, instancesCount) {\n this.drawElementsType(useTriangles ? 0 : 1, indexStart, indexCount, instancesCount);\n }\n /**\n * Draw a list of points\n * @param verticesStart defines the index of first vertex to draw\n * @param verticesCount defines the count of vertices to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n drawPointClouds(verticesStart, verticesCount, instancesCount) {\n this.drawArraysType(2, verticesStart, verticesCount, instancesCount);\n }\n /**\n * Draw a list of unindexed primitives\n * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)\n * @param verticesStart defines the index of first vertex to draw\n * @param verticesCount defines the count of vertices to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n drawUnIndexed(useTriangles, verticesStart, verticesCount, instancesCount) {\n this.drawArraysType(useTriangles ? 0 : 1, verticesStart, verticesCount, instancesCount);\n }\n /**\n * Draw a list of indexed primitives\n * @param fillMode defines the primitive to use\n * @param indexStart defines the starting index\n * @param indexCount defines the number of index to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n drawElementsType(fillMode, indexStart, indexCount, instancesCount) {\n // Apply states\n this.applyStates();\n this._reportDrawCall();\n // Render\n const drawMode = this._drawMode(fillMode);\n const indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;\n const mult = this._uintIndicesCurrentlySet ? 4 : 2;\n if (instancesCount) {\n this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);\n } else {\n this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);\n }\n }\n /**\n * Draw a list of unindexed primitives\n * @param fillMode defines the primitive to use\n * @param verticesStart defines the index of first vertex to draw\n * @param verticesCount defines the count of vertices to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n drawArraysType(fillMode, verticesStart, verticesCount, instancesCount) {\n // Apply states\n this.applyStates();\n this._reportDrawCall();\n const drawMode = this._drawMode(fillMode);\n if (instancesCount) {\n this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);\n } else {\n this._gl.drawArrays(drawMode, verticesStart, verticesCount);\n }\n }\n _drawMode(fillMode) {\n switch (fillMode) {\n // Triangle views\n case 0:\n return this._gl.TRIANGLES;\n case 2:\n return this._gl.POINTS;\n case 1:\n return this._gl.LINES;\n // Draw modes\n case 3:\n return this._gl.POINTS;\n case 4:\n return this._gl.LINES;\n case 5:\n return this._gl.LINE_LOOP;\n case 6:\n return this._gl.LINE_STRIP;\n case 7:\n return this._gl.TRIANGLE_STRIP;\n case 8:\n return this._gl.TRIANGLE_FAN;\n default:\n return this._gl.TRIANGLES;\n }\n }\n // Shaders\n /**\n * @internal\n */\n _releaseEffect(effect) {\n if (this._compiledEffects[effect._key]) {\n delete this._compiledEffects[effect._key];\n }\n const pipelineContext = effect.getPipelineContext();\n if (pipelineContext) {\n this._deletePipelineContext(pipelineContext);\n }\n }\n /**\n * @internal\n */\n _deletePipelineContext(pipelineContext) {\n const webGLPipelineContext = pipelineContext;\n if (webGLPipelineContext && webGLPipelineContext.program) {\n webGLPipelineContext.program.__SPECTOR_rebuildProgram = null;\n resetCachedPipeline(webGLPipelineContext);\n if (this._gl) {\n this._gl.deleteProgram(webGLPipelineContext.program);\n }\n }\n }\n /**\n * @internal\n */\n _getGlobalDefines(defines) {\n return _getGlobalDefines(defines, this.isNDCHalfZRange, this.useReverseDepthBuffer, this.useExactSrgbConversions);\n }\n /**\n * Create a new effect (used to store vertex/fragment shaders)\n * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)\n * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object\n * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use\n * @param samplers defines an array of string used to represent textures\n * @param defines defines the string containing the defines to use to compile the shaders\n * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails\n * @param onCompiled defines a function to call when the effect creation is successful\n * @param onError defines a function to call when the effect creation has failed\n * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)\n * @param shaderLanguage the language the shader is written in (default: GLSL)\n * @param extraInitializationsAsync additional async code to run before preparing the effect\n * @returns the new Effect\n */\n createEffect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters, shaderLanguage = 0 /* ShaderLanguage.GLSL */, extraInitializationsAsync) {\n var _ref2, _attributesNamesOrOpt, _attributesNamesOrOpt2;\n const vertex = typeof baseName === \"string\" ? baseName : baseName.vertexToken || baseName.vertexSource || baseName.vertexElement || baseName.vertex;\n const fragment = typeof baseName === \"string\" ? baseName : baseName.fragmentToken || baseName.fragmentSource || baseName.fragmentElement || baseName.fragment;\n const globalDefines = this._getGlobalDefines();\n let fullDefines = (_ref2 = defines !== null && defines !== void 0 ? defines : attributesNamesOrOptions.defines) !== null && _ref2 !== void 0 ? _ref2 : \"\";\n if (globalDefines) {\n fullDefines += globalDefines;\n }\n const name = vertex + \"+\" + fragment + \"@\" + fullDefines;\n if (this._compiledEffects[name]) {\n const compiledEffect = this._compiledEffects[name];\n if (onCompiled && compiledEffect.isReady()) {\n onCompiled(compiledEffect);\n }\n compiledEffect._refCount++;\n return compiledEffect;\n }\n if (this._gl) {\n getStateObject(this._gl);\n }\n const effect = new Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters, name, (_attributesNamesOrOpt = attributesNamesOrOptions.shaderLanguage) !== null && _attributesNamesOrOpt !== void 0 ? _attributesNamesOrOpt : shaderLanguage, (_attributesNamesOrOpt2 = attributesNamesOrOptions.extraInitializationsAsync) !== null && _attributesNamesOrOpt2 !== void 0 ? _attributesNamesOrOpt2 : extraInitializationsAsync);\n this._compiledEffects[name] = effect;\n return effect;\n }\n /**\n * @internal\n */\n _getShaderSource(shader) {\n return this._gl.getShaderSource(shader);\n }\n /**\n * Directly creates a webGL program\n * @param pipelineContext defines the pipeline context to attach to\n * @param vertexCode defines the vertex shader code to use\n * @param fragmentCode defines the fragment shader code to use\n * @param context defines the webGL context to use (if not set, the current one will be used)\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\n * @returns the new webGL program\n */\n createRawShaderProgram(pipelineContext, vertexCode, fragmentCode, context, transformFeedbackVaryings = null) {\n const stateObject = getStateObject(this._gl);\n stateObject._contextWasLost = this._contextWasLost;\n stateObject.validateShaderPrograms = this.validateShaderPrograms;\n return createRawShaderProgram(pipelineContext, vertexCode, fragmentCode, context || this._gl, transformFeedbackVaryings);\n }\n /**\n * Creates a webGL program\n * @param pipelineContext defines the pipeline context to attach to\n * @param vertexCode defines the vertex shader code to use\n * @param fragmentCode defines the fragment shader code to use\n * @param defines defines the string containing the defines to use to compile the shaders\n * @param context defines the webGL context to use (if not set, the current one will be used)\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\n * @returns the new webGL program\n */\n createShaderProgram(pipelineContext, vertexCode, fragmentCode, defines, context, transformFeedbackVaryings = null) {\n const stateObject = getStateObject(this._gl);\n // assure the state object is correct\n stateObject._contextWasLost = this._contextWasLost;\n stateObject.validateShaderPrograms = this.validateShaderPrograms;\n return createShaderProgram(pipelineContext, vertexCode, fragmentCode, defines, context || this._gl, transformFeedbackVaryings);\n }\n /**\n * Inline functions in shader code that are marked to be inlined\n * @param code code to inline\n * @returns inlined code\n */\n inlineShaderCode(code) {\n // no inlining needed in the WebGL engine\n return code;\n }\n /**\n * Creates a new pipeline context\n * @param shaderProcessingContext defines the shader processing context used during the processing if available\n * @returns the new pipeline\n */\n createPipelineContext(shaderProcessingContext) {\n if (this._gl) {\n const stateObject = getStateObject(this._gl);\n stateObject.parallelShaderCompile = this._caps.parallelShaderCompile;\n }\n const context = createPipelineContext(this._gl, shaderProcessingContext);\n context.engine = this;\n return context;\n }\n /**\n * Creates a new material context\n * @returns the new context\n */\n createMaterialContext() {\n return undefined;\n }\n /**\n * Creates a new draw context\n * @returns the new context\n */\n createDrawContext() {\n return undefined;\n }\n _finalizePipelineContext(pipelineContext) {\n return _finalizePipelineContext(pipelineContext, this._gl, this.validateShaderPrograms);\n }\n /**\n * @internal\n */\n _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rawVertexSourceCode, rawFragmentSourceCode, rebuildRebind, defines, transformFeedbackVaryings, key, onReady) {\n const stateObject = getStateObject(this._gl);\n stateObject._contextWasLost = this._contextWasLost;\n stateObject.validateShaderPrograms = this.validateShaderPrograms;\n stateObject._createShaderProgramInjection = this._createShaderProgram.bind(this);\n stateObject.createRawShaderProgramInjection = this.createRawShaderProgram.bind(this);\n stateObject.createShaderProgramInjection = this.createShaderProgram.bind(this);\n stateObject.loadFileInjection = this._loadFile.bind(this);\n return _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rawVertexSourceCode, rawFragmentSourceCode, rebuildRebind, defines, transformFeedbackVaryings, key, onReady);\n }\n _createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings = null) {\n return _createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings);\n }\n /**\n * @internal\n */\n _isRenderingStateCompiled(pipelineContext) {\n if (this._isDisposed) {\n return false;\n }\n return _isRenderingStateCompiled(pipelineContext, this._gl, this.validateShaderPrograms);\n }\n /**\n * @internal\n */\n _executeWhenRenderingStateIsCompiled(pipelineContext, action) {\n _executeWhenRenderingStateIsCompiled(pipelineContext, action);\n }\n /**\n * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names\n * @param pipelineContext defines the pipeline context to use\n * @param uniformsNames defines the list of uniform names\n * @returns an array of webGL uniform locations\n */\n getUniforms(pipelineContext, uniformsNames) {\n const results = new Array();\n const webGLPipelineContext = pipelineContext;\n for (let index = 0; index < uniformsNames.length; index++) {\n results.push(this._gl.getUniformLocation(webGLPipelineContext.program, uniformsNames[index]));\n }\n return results;\n }\n /**\n * Gets the list of active attributes for a given webGL program\n * @param pipelineContext defines the pipeline context to use\n * @param attributesNames defines the list of attribute names to get\n * @returns an array of indices indicating the offset of each attribute\n */\n getAttributes(pipelineContext, attributesNames) {\n const results = [];\n const webGLPipelineContext = pipelineContext;\n for (let index = 0; index < attributesNames.length; index++) {\n try {\n results.push(this._gl.getAttribLocation(webGLPipelineContext.program, attributesNames[index]));\n } catch (e) {\n results.push(-1);\n }\n }\n return results;\n }\n /**\n * Activates an effect, making it the current one (ie. the one used for rendering)\n * @param effect defines the effect to activate\n */\n enableEffect(effect) {\n effect = effect !== null && IsWrapper(effect) ? effect.effect : effect; // get only the effect, we don't need a Wrapper in the WebGL engine\n if (!effect || effect === this._currentEffect) {\n return;\n }\n this._stencilStateComposer.stencilMaterial = undefined;\n effect = effect;\n // Use program\n this.bindSamplers(effect);\n this._currentEffect = effect;\n if (effect.onBind) {\n effect.onBind(effect);\n }\n if (effect._onBindObservable) {\n effect._onBindObservable.notifyObservers(effect);\n }\n }\n /**\n * Set the value of an uniform to a number (int)\n * @param uniform defines the webGL uniform location where to store the value\n * @param value defines the int number to store\n * @returns true if the value was set\n */\n setInt(uniform, value) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform1i(uniform, value);\n return true;\n }\n /**\n * Set the value of an uniform to a int2\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @returns true if the value was set\n */\n setInt2(uniform, x, y) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform2i(uniform, x, y);\n return true;\n }\n /**\n * Set the value of an uniform to a int3\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @param z defines the 3rd component of the value\n * @returns true if the value was set\n */\n setInt3(uniform, x, y, z) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform3i(uniform, x, y, z);\n return true;\n }\n /**\n * Set the value of an uniform to a int4\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @param z defines the 3rd component of the value\n * @param w defines the 4th component of the value\n * @returns true if the value was set\n */\n setInt4(uniform, x, y, z, w) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform4i(uniform, x, y, z, w);\n return true;\n }\n /**\n * Set the value of an uniform to an array of int32\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of int32 to store\n * @returns true if the value was set\n */\n setIntArray(uniform, array) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform1iv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of int32 (stored as vec2)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of int32 to store\n * @returns true if the value was set\n */\n setIntArray2(uniform, array) {\n if (!uniform || array.length % 2 !== 0) {\n return false;\n }\n this._gl.uniform2iv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of int32 (stored as vec3)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of int32 to store\n * @returns true if the value was set\n */\n setIntArray3(uniform, array) {\n if (!uniform || array.length % 3 !== 0) {\n return false;\n }\n this._gl.uniform3iv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of int32 (stored as vec4)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of int32 to store\n * @returns true if the value was set\n */\n setIntArray4(uniform, array) {\n if (!uniform || array.length % 4 !== 0) {\n return false;\n }\n this._gl.uniform4iv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to a number (unsigned int)\n * @param uniform defines the webGL uniform location where to store the value\n * @param value defines the unsigned int number to store\n * @returns true if the value was set\n */\n setUInt(uniform, value) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform1ui(uniform, value);\n return true;\n }\n /**\n * Set the value of an uniform to a unsigned int2\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @returns true if the value was set\n */\n setUInt2(uniform, x, y) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform2ui(uniform, x, y);\n return true;\n }\n /**\n * Set the value of an uniform to a unsigned int3\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @param z defines the 3rd component of the value\n * @returns true if the value was set\n */\n setUInt3(uniform, x, y, z) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform3ui(uniform, x, y, z);\n return true;\n }\n /**\n * Set the value of an uniform to a unsigned int4\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @param z defines the 3rd component of the value\n * @param w defines the 4th component of the value\n * @returns true if the value was set\n */\n setUInt4(uniform, x, y, z, w) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform4ui(uniform, x, y, z, w);\n return true;\n }\n /**\n * Set the value of an uniform to an array of unsigned int32\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of unsigned int32 to store\n * @returns true if the value was set\n */\n setUIntArray(uniform, array) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform1uiv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of unsigned int32 (stored as vec2)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of unsigned int32 to store\n * @returns true if the value was set\n */\n setUIntArray2(uniform, array) {\n if (!uniform || array.length % 2 !== 0) {\n return false;\n }\n this._gl.uniform2uiv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of unsigned int32 (stored as vec3)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of unsigned int32 to store\n * @returns true if the value was set\n */\n setUIntArray3(uniform, array) {\n if (!uniform || array.length % 3 !== 0) {\n return false;\n }\n this._gl.uniform3uiv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of unsigned int32 (stored as vec4)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of unsigned int32 to store\n * @returns true if the value was set\n */\n setUIntArray4(uniform, array) {\n if (!uniform || array.length % 4 !== 0) {\n return false;\n }\n this._gl.uniform4uiv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of number\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of number to store\n * @returns true if the value was set\n */\n setArray(uniform, array) {\n if (!uniform) {\n return false;\n }\n if (array.length < 1) {\n return false;\n }\n this._gl.uniform1fv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of number (stored as vec2)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of number to store\n * @returns true if the value was set\n */\n setArray2(uniform, array) {\n if (!uniform || array.length % 2 !== 0) {\n return false;\n }\n this._gl.uniform2fv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of number (stored as vec3)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of number to store\n * @returns true if the value was set\n */\n setArray3(uniform, array) {\n if (!uniform || array.length % 3 !== 0) {\n return false;\n }\n this._gl.uniform3fv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of number (stored as vec4)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of number to store\n * @returns true if the value was set\n */\n setArray4(uniform, array) {\n if (!uniform || array.length % 4 !== 0) {\n return false;\n }\n this._gl.uniform4fv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of float32 (stored as matrices)\n * @param uniform defines the webGL uniform location where to store the value\n * @param matrices defines the array of float32 to store\n * @returns true if the value was set\n */\n setMatrices(uniform, matrices) {\n if (!uniform) {\n return false;\n }\n this._gl.uniformMatrix4fv(uniform, false, matrices);\n return true;\n }\n /**\n * Set the value of an uniform to a matrix (3x3)\n * @param uniform defines the webGL uniform location where to store the value\n * @param matrix defines the Float32Array representing the 3x3 matrix to store\n * @returns true if the value was set\n */\n setMatrix3x3(uniform, matrix) {\n if (!uniform) {\n return false;\n }\n this._gl.uniformMatrix3fv(uniform, false, matrix);\n return true;\n }\n /**\n * Set the value of an uniform to a matrix (2x2)\n * @param uniform defines the webGL uniform location where to store the value\n * @param matrix defines the Float32Array representing the 2x2 matrix to store\n * @returns true if the value was set\n */\n setMatrix2x2(uniform, matrix) {\n if (!uniform) {\n return false;\n }\n this._gl.uniformMatrix2fv(uniform, false, matrix);\n return true;\n }\n /**\n * Set the value of an uniform to a number (float)\n * @param uniform defines the webGL uniform location where to store the value\n * @param value defines the float number to store\n * @returns true if the value was transferred\n */\n setFloat(uniform, value) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform1f(uniform, value);\n return true;\n }\n /**\n * Set the value of an uniform to a vec2\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @returns true if the value was set\n */\n setFloat2(uniform, x, y) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform2f(uniform, x, y);\n return true;\n }\n /**\n * Set the value of an uniform to a vec3\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @param z defines the 3rd component of the value\n * @returns true if the value was set\n */\n setFloat3(uniform, x, y, z) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform3f(uniform, x, y, z);\n return true;\n }\n /**\n * Set the value of an uniform to a vec4\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @param z defines the 3rd component of the value\n * @param w defines the 4th component of the value\n * @returns true if the value was set\n */\n setFloat4(uniform, x, y, z, w) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform4f(uniform, x, y, z, w);\n return true;\n }\n // States\n /**\n * Apply all cached states (depth, culling, stencil and alpha)\n */\n applyStates() {\n this._depthCullingState.apply(this._gl);\n this._stencilStateComposer.apply(this._gl);\n this._alphaState.apply(this._gl);\n if (this._colorWriteChanged) {\n this._colorWriteChanged = false;\n const enable = this._colorWrite;\n this._gl.colorMask(enable, enable, enable, enable);\n }\n }\n // Textures\n /**\n * Force the entire cache to be cleared\n * You should not have to use this function unless your engine needs to share the webGL context with another engine\n * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)\n */\n wipeCaches(bruteForce) {\n if (this.preventCacheWipeBetweenFrames && !bruteForce) {\n return;\n }\n this._currentEffect = null;\n this._viewportCached.x = 0;\n this._viewportCached.y = 0;\n this._viewportCached.z = 0;\n this._viewportCached.w = 0;\n // Done before in case we clean the attributes\n this._unbindVertexArrayObject();\n if (bruteForce) {\n this._currentProgram = null;\n this.resetTextureCache();\n this._stencilStateComposer.reset();\n this._depthCullingState.reset();\n this._depthCullingState.depthFunc = this._gl.LEQUAL;\n this._alphaState.reset();\n this._alphaMode = 1;\n this._alphaEquation = 0;\n this._colorWrite = true;\n this._colorWriteChanged = true;\n this._unpackFlipYCached = null;\n this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);\n this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);\n this._mustWipeVertexAttributes = true;\n this.unbindAllAttributes();\n }\n this._resetVertexBufferBinding();\n this._cachedIndexBuffer = null;\n this._cachedEffectForVertexBuffers = null;\n this.bindIndexBuffer(null);\n }\n /**\n * @internal\n */\n _getSamplingParameters(samplingMode, generateMipMaps) {\n const gl = this._gl;\n let magFilter = gl.NEAREST;\n let minFilter = gl.NEAREST;\n switch (samplingMode) {\n case 11:\n magFilter = gl.LINEAR;\n if (generateMipMaps) {\n minFilter = gl.LINEAR_MIPMAP_NEAREST;\n } else {\n minFilter = gl.LINEAR;\n }\n break;\n case 3:\n magFilter = gl.LINEAR;\n if (generateMipMaps) {\n minFilter = gl.LINEAR_MIPMAP_LINEAR;\n } else {\n minFilter = gl.LINEAR;\n }\n break;\n case 8:\n magFilter = gl.NEAREST;\n if (generateMipMaps) {\n minFilter = gl.NEAREST_MIPMAP_LINEAR;\n } else {\n minFilter = gl.NEAREST;\n }\n break;\n case 4:\n magFilter = gl.NEAREST;\n if (generateMipMaps) {\n minFilter = gl.NEAREST_MIPMAP_NEAREST;\n } else {\n minFilter = gl.NEAREST;\n }\n break;\n case 5:\n magFilter = gl.NEAREST;\n if (generateMipMaps) {\n minFilter = gl.LINEAR_MIPMAP_NEAREST;\n } else {\n minFilter = gl.LINEAR;\n }\n break;\n case 6:\n magFilter = gl.NEAREST;\n if (generateMipMaps) {\n minFilter = gl.LINEAR_MIPMAP_LINEAR;\n } else {\n minFilter = gl.LINEAR;\n }\n break;\n case 7:\n magFilter = gl.NEAREST;\n minFilter = gl.LINEAR;\n break;\n case 1:\n magFilter = gl.NEAREST;\n minFilter = gl.NEAREST;\n break;\n case 9:\n magFilter = gl.LINEAR;\n if (generateMipMaps) {\n minFilter = gl.NEAREST_MIPMAP_NEAREST;\n } else {\n minFilter = gl.NEAREST;\n }\n break;\n case 10:\n magFilter = gl.LINEAR;\n if (generateMipMaps) {\n minFilter = gl.NEAREST_MIPMAP_LINEAR;\n } else {\n minFilter = gl.NEAREST;\n }\n break;\n case 2:\n magFilter = gl.LINEAR;\n minFilter = gl.LINEAR;\n break;\n case 12:\n magFilter = gl.LINEAR;\n minFilter = gl.NEAREST;\n break;\n }\n return {\n min: minFilter,\n mag: magFilter\n };\n }\n /** @internal */\n _createTexture() {\n const texture = this._gl.createTexture();\n if (!texture) {\n throw new Error(\"Unable to create texture\");\n }\n return texture;\n }\n /** @internal */\n _createHardwareTexture() {\n return new WebGLHardwareTexture(this._createTexture(), this._gl);\n }\n /**\n * Creates an internal texture without binding it to a framebuffer\n * @internal\n * @param size defines the size of the texture\n * @param options defines the options used to create the texture\n * @param delayGPUTextureCreation true to delay the texture creation the first time it is really needed. false to create it right away\n * @param source source type of the texture\n * @returns a new internal texture\n */\n _createInternalTexture(size, options, delayGPUTextureCreation = true, source = 0 /* InternalTextureSource.Unknown */) {\n let generateMipMaps = false;\n let createMipMaps = false;\n let type = 0;\n let samplingMode = 3;\n let format = 5;\n let useSRGBBuffer = false;\n let samples = 1;\n let label;\n let createMSAATexture = false;\n let comparisonFunction = 0;\n if (options !== undefined && typeof options === \"object\") {\n var _options$samples;\n generateMipMaps = !!options.generateMipMaps;\n createMipMaps = !!options.createMipMaps;\n type = options.type === undefined ? 0 : options.type;\n samplingMode = options.samplingMode === undefined ? 3 : options.samplingMode;\n format = options.format === undefined ? 5 : options.format;\n useSRGBBuffer = options.useSRGBBuffer === undefined ? false : options.useSRGBBuffer;\n samples = (_options$samples = options.samples) !== null && _options$samples !== void 0 ? _options$samples : 1;\n label = options.label;\n createMSAATexture = !!options.createMSAATexture;\n comparisonFunction = options.comparisonFunction || 0;\n } else {\n generateMipMaps = !!options;\n }\n useSRGBBuffer && (useSRGBBuffer = this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU));\n if (type === 1 && !this._caps.textureFloatLinearFiltering) {\n // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE\n samplingMode = 1;\n } else if (type === 2 && !this._caps.textureHalfFloatLinearFiltering) {\n // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE\n samplingMode = 1;\n }\n if (type === 1 && !this._caps.textureFloat) {\n type = 0;\n Logger.Warn(\"Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE\");\n }\n const isDepthTexture = IsDepthTexture(format);\n const hasStencil = HasStencilAspect(format);\n const gl = this._gl;\n const texture = new InternalTexture(this, source);\n const width = size.width || size;\n const height = size.height || size;\n const depth = size.depth || 0;\n const layers = size.layers || 0;\n const filters = this._getSamplingParameters(samplingMode, (generateMipMaps || createMipMaps) && !isDepthTexture);\n const target = layers !== 0 ? gl.TEXTURE_2D_ARRAY : depth !== 0 ? gl.TEXTURE_3D : gl.TEXTURE_2D;\n const sizedFormat = isDepthTexture ? this._getInternalFormatFromDepthTextureFormat(format, true, hasStencil) : this._getRGBABufferInternalSizedFormat(type, format, useSRGBBuffer);\n const internalFormat = isDepthTexture ? hasStencil ? gl.DEPTH_STENCIL : gl.DEPTH_COMPONENT : this._getInternalFormat(format);\n const textureType = isDepthTexture ? this._getWebGLTextureTypeFromDepthTextureFormat(format) : this._getWebGLTextureType(type);\n // Bind\n this._bindTextureDirectly(target, texture);\n if (layers !== 0) {\n texture.is2DArray = true;\n gl.texImage3D(target, 0, sizedFormat, width, height, layers, 0, internalFormat, textureType, null);\n } else if (depth !== 0) {\n texture.is3D = true;\n gl.texImage3D(target, 0, sizedFormat, width, height, depth, 0, internalFormat, textureType, null);\n } else {\n gl.texImage2D(target, 0, sizedFormat, width, height, 0, internalFormat, textureType, null);\n }\n gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, filters.mag);\n gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, filters.min);\n gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n if (isDepthTexture && this.webGLVersion > 1) {\n if (comparisonFunction === 0) {\n gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, 515);\n gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);\n } else {\n gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);\n gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);\n }\n }\n // MipMaps\n if (generateMipMaps || createMipMaps) {\n this._gl.generateMipmap(target);\n }\n this._bindTextureDirectly(target, null);\n texture._useSRGBBuffer = useSRGBBuffer;\n texture.baseWidth = width;\n texture.baseHeight = height;\n texture.width = width;\n texture.height = height;\n texture.depth = layers || depth;\n texture.isReady = true;\n texture.samples = samples;\n texture.generateMipMaps = generateMipMaps;\n texture.samplingMode = samplingMode;\n texture.type = type;\n texture.format = format;\n texture.label = label;\n texture.comparisonFunction = comparisonFunction;\n this._internalTexturesCache.push(texture);\n if (createMSAATexture) {\n let renderBuffer = null;\n if (IsDepthTexture(texture.format)) {\n renderBuffer = this._setupFramebufferDepthAttachments(HasStencilAspect(texture.format), texture.format !== 19, texture.width, texture.height, samples, texture.format, true);\n } else {\n renderBuffer = this._createRenderBuffer(texture.width, texture.height, samples, -1 /* not used */, this._getRGBABufferInternalSizedFormat(texture.type, texture.format, texture._useSRGBBuffer), -1 /* attachment */);\n }\n if (!renderBuffer) {\n throw new Error(\"Unable to create render buffer\");\n }\n texture._autoMSAAManagement = true;\n let hardwareTexture = texture._hardwareTexture;\n if (!hardwareTexture) {\n hardwareTexture = texture._hardwareTexture = this._createHardwareTexture();\n }\n hardwareTexture.addMSAARenderBuffer(renderBuffer);\n }\n return texture;\n }\n /**\n * @internal\n */\n _getUseSRGBBuffer(useSRGBBuffer, noMipmap) {\n // Generating mipmaps for sRGB textures is not supported in WebGL1 so we must disable the support if mipmaps is enabled\n return useSRGBBuffer && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || noMipmap);\n }\n /**\n * Usually called from Texture.ts.\n * Passed information to create a WebGLTexture\n * @param url defines a value which contains one of the following:\n * * A conventional http URL, e.g. 'http://...' or 'file://...'\n * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'\n * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'\n * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file\n * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)\n * @param scene needed for loading to the correct scene\n * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)\n * @param onLoad optional callback to be called upon successful completion\n * @param onError optional callback to be called upon failure\n * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob\n * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities\n * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures\n * @param forcedExtension defines the extension to use to pick the right loader\n * @param mimeType defines an optional mime type\n * @param loaderOptions options to be passed to the loader\n * @param creationFlags specific flags to use when creating the texture (1 for storage textures, for eg)\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\n * @returns a InternalTexture for assignment back into BABYLON.Texture\n */\n createTexture(url, noMipmap, invertY, scene, samplingMode = 3, onLoad = null, onError = null, buffer = null, fallback = null, format = null, forcedExtension = null, mimeType, loaderOptions, creationFlags, useSRGBBuffer) {\n return this._createTextureBase(url, noMipmap, invertY, scene, samplingMode, onLoad, onError, (...args) => this._prepareWebGLTexture(...args, format), (potWidth, potHeight, img, extension, texture, continuationCallback) => {\n const gl = this._gl;\n const isPot = img.width === potWidth && img.height === potHeight;\n texture._creationFlags = creationFlags !== null && creationFlags !== void 0 ? creationFlags : 0;\n const tip = this._getTexImageParametersForCreateTexture(texture.format, texture._useSRGBBuffer);\n if (isPot) {\n gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, img);\n return false;\n }\n const maxTextureSize = this._caps.maxTextureSize;\n if (img.width > maxTextureSize || img.height > maxTextureSize || !this._supportsHardwareTextureRescaling) {\n this._prepareWorkingCanvas();\n if (!this._workingCanvas || !this._workingContext) {\n return false;\n }\n this._workingCanvas.width = potWidth;\n this._workingCanvas.height = potHeight;\n this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);\n gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, this._workingCanvas);\n texture.width = potWidth;\n texture.height = potHeight;\n return false;\n } else {\n // Using shaders when possible to rescale because canvas.drawImage is lossy\n const source = new InternalTexture(this, 2 /* InternalTextureSource.Temp */);\n this._bindTextureDirectly(gl.TEXTURE_2D, source, true);\n gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, img);\n this._rescaleTexture(source, texture, scene, tip.format, () => {\n this._releaseTexture(source);\n this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);\n continuationCallback();\n });\n }\n return true;\n }, buffer, fallback, format, forcedExtension, mimeType, loaderOptions, useSRGBBuffer);\n }\n /**\n * Calls to the GL texImage2D and texImage3D functions require three arguments describing the pixel format of the texture.\n * createTexture derives these from the babylonFormat and useSRGBBuffer arguments and also the file extension of the URL it's working with.\n * This function encapsulates that derivation for easy unit testing.\n * @param babylonFormat Babylon's format enum, as specified in ITextureCreationOptions.\n * @param fileExtension The file extension including the dot, e.g. .jpg.\n * @param useSRGBBuffer Use SRGB not linear.\n * @returns The options to pass to texImage2D or texImage3D calls.\n * @internal\n */\n _getTexImageParametersForCreateTexture(babylonFormat, useSRGBBuffer) {\n let format, internalFormat;\n if (this.webGLVersion === 1) {\n // In WebGL 1, format and internalFormat must be the same and taken from a limited set of values, see https://docs.gl/es2/glTexImage2D.\n // The SRGB extension (https://developer.mozilla.org/en-US/docs/Web/API/EXT_sRGB) adds some extra values, hence passing useSRGBBuffer\n // to getInternalFormat.\n format = this._getInternalFormat(babylonFormat, useSRGBBuffer);\n internalFormat = format;\n } else {\n // In WebGL 2, format has a wider range of values and internal format can be one of the sized formats, see\n // https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml.\n // SRGB is included in the sized format and should not be passed in \"format\", hence always passing useSRGBBuffer as false.\n format = this._getInternalFormat(babylonFormat, false);\n internalFormat = this._getRGBABufferInternalSizedFormat(0, babylonFormat, useSRGBBuffer);\n }\n return {\n internalFormat,\n format,\n type: this._gl.UNSIGNED_BYTE\n };\n }\n /**\n * @internal\n */\n _rescaleTexture(source, destination, scene, internalFormat, onComplete) {}\n /**\n * @internal\n */\n _unpackFlipY(value) {\n if (this._unpackFlipYCached !== value) {\n this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);\n if (this.enableUnpackFlipYCached) {\n this._unpackFlipYCached = value;\n }\n }\n }\n /** @internal */\n _getUnpackAlignement() {\n return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);\n }\n /** @internal */\n _getTextureTarget(texture) {\n if (texture.isCube) {\n return this._gl.TEXTURE_CUBE_MAP;\n } else if (texture.is3D) {\n return this._gl.TEXTURE_3D;\n } else if (texture.is2DArray || texture.isMultiview) {\n return this._gl.TEXTURE_2D_ARRAY;\n }\n return this._gl.TEXTURE_2D;\n }\n /**\n * Update the sampling mode of a given texture\n * @param samplingMode defines the required sampling mode\n * @param texture defines the texture to update\n * @param generateMipMaps defines whether to generate mipmaps for the texture\n */\n updateTextureSamplingMode(samplingMode, texture, generateMipMaps = false) {\n const target = this._getTextureTarget(texture);\n const filters = this._getSamplingParameters(samplingMode, texture.useMipMaps || generateMipMaps);\n this._setTextureParameterInteger(target, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);\n this._setTextureParameterInteger(target, this._gl.TEXTURE_MIN_FILTER, filters.min);\n if (generateMipMaps) {\n texture.generateMipMaps = true;\n this._gl.generateMipmap(target);\n }\n this._bindTextureDirectly(target, null);\n texture.samplingMode = samplingMode;\n }\n /**\n * Update the dimensions of a texture\n * @param texture texture to update\n * @param width new width of the texture\n * @param height new height of the texture\n * @param depth new depth of the texture\n */\n updateTextureDimensions(texture, width, height, depth = 1) {}\n /**\n * Update the sampling mode of a given texture\n * @param texture defines the texture to update\n * @param wrapU defines the texture wrap mode of the u coordinates\n * @param wrapV defines the texture wrap mode of the v coordinates\n * @param wrapR defines the texture wrap mode of the r coordinates\n */\n updateTextureWrappingMode(texture, wrapU, wrapV = null, wrapR = null) {\n const target = this._getTextureTarget(texture);\n if (wrapU !== null) {\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(wrapU), texture);\n texture._cachedWrapU = wrapU;\n }\n if (wrapV !== null) {\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(wrapV), texture);\n texture._cachedWrapV = wrapV;\n }\n if ((texture.is2DArray || texture.is3D) && wrapR !== null) {\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(wrapR), texture);\n texture._cachedWrapR = wrapR;\n }\n this._bindTextureDirectly(target, null);\n }\n /**\n * @internal\n */\n _uploadCompressedDataToTextureDirectly(texture, internalFormat, width, height, data, faceIndex = 0, lod = 0) {\n const gl = this._gl;\n let target = gl.TEXTURE_2D;\n if (texture.isCube) {\n target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;\n }\n if (texture._useSRGBBuffer) {\n switch (internalFormat) {\n case 37492:\n case 36196:\n // Note, if using ETC1 and sRGB is requested, this will use ETC2 if available.\n if (this._caps.etc2) {\n internalFormat = gl.COMPRESSED_SRGB8_ETC2;\n } else {\n texture._useSRGBBuffer = false;\n }\n break;\n case 37496:\n if (this._caps.etc2) {\n internalFormat = gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;\n } else {\n texture._useSRGBBuffer = false;\n }\n break;\n case 36492:\n internalFormat = gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;\n break;\n case 37808:\n internalFormat = gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;\n break;\n case 33776:\n if (this._caps.s3tc_srgb) {\n internalFormat = gl.COMPRESSED_SRGB_S3TC_DXT1_EXT;\n } else {\n // S3TC sRGB extension not supported\n texture._useSRGBBuffer = false;\n }\n break;\n case 33777:\n if (this._caps.s3tc_srgb) {\n internalFormat = gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;\n } else {\n // S3TC sRGB extension not supported\n texture._useSRGBBuffer = false;\n }\n break;\n case 33779:\n if (this._caps.s3tc_srgb) {\n internalFormat = gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;\n } else {\n // S3TC sRGB extension not supported\n texture._useSRGBBuffer = false;\n }\n break;\n default:\n // We don't support a sRGB format corresponding to internalFormat, so revert to non sRGB format\n texture._useSRGBBuffer = false;\n break;\n }\n }\n this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);\n }\n /**\n * @internal\n */\n _uploadDataToTextureDirectly(texture, imageData, faceIndex = 0, lod = 0, babylonInternalFormat, useTextureWidthAndHeight = false) {\n const gl = this._gl;\n const textureType = this._getWebGLTextureType(texture.type);\n const format = this._getInternalFormat(texture.format);\n const internalFormat = babylonInternalFormat === undefined ? this._getRGBABufferInternalSizedFormat(texture.type, texture.format, texture._useSRGBBuffer) : this._getInternalFormat(babylonInternalFormat, texture._useSRGBBuffer);\n this._unpackFlipY(texture.invertY);\n let target = gl.TEXTURE_2D;\n if (texture.isCube) {\n target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;\n }\n const lodMaxWidth = Math.round(Math.log(texture.width) * Math.LOG2E);\n const lodMaxHeight = Math.round(Math.log(texture.height) * Math.LOG2E);\n const width = useTextureWidthAndHeight ? texture.width : Math.pow(2, Math.max(lodMaxWidth - lod, 0));\n const height = useTextureWidthAndHeight ? texture.height : Math.pow(2, Math.max(lodMaxHeight - lod, 0));\n gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);\n }\n /**\n * Update a portion of an internal texture\n * @param texture defines the texture to update\n * @param imageData defines the data to store into the texture\n * @param xOffset defines the x coordinates of the update rectangle\n * @param yOffset defines the y coordinates of the update rectangle\n * @param width defines the width of the update rectangle\n * @param height defines the height of the update rectangle\n * @param faceIndex defines the face index if texture is a cube (0 by default)\n * @param lod defines the lod level to update (0 by default)\n * @param generateMipMaps defines whether to generate mipmaps or not\n */\n updateTextureData(texture, imageData, xOffset, yOffset, width, height, faceIndex = 0, lod = 0, generateMipMaps = false) {\n const gl = this._gl;\n const textureType = this._getWebGLTextureType(texture.type);\n const format = this._getInternalFormat(texture.format);\n this._unpackFlipY(texture.invertY);\n let targetForBinding = gl.TEXTURE_2D;\n let target = gl.TEXTURE_2D;\n if (texture.isCube) {\n target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;\n targetForBinding = gl.TEXTURE_CUBE_MAP;\n }\n this._bindTextureDirectly(targetForBinding, texture, true);\n gl.texSubImage2D(target, lod, xOffset, yOffset, width, height, format, textureType, imageData);\n if (generateMipMaps) {\n this._gl.generateMipmap(target);\n }\n this._bindTextureDirectly(targetForBinding, null);\n }\n /**\n * @internal\n */\n _uploadArrayBufferViewToTexture(texture, imageData, faceIndex = 0, lod = 0) {\n const gl = this._gl;\n const bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;\n this._bindTextureDirectly(bindTarget, texture, true);\n this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);\n this._bindTextureDirectly(bindTarget, null, true);\n }\n _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode) {\n const gl = this._gl;\n if (!gl) {\n return;\n }\n const filters = this._getSamplingParameters(samplingMode, !noMipmap);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);\n if (!noMipmap && !isCompressed) {\n gl.generateMipmap(gl.TEXTURE_2D);\n }\n this._bindTextureDirectly(gl.TEXTURE_2D, null);\n // this.resetTextureCache();\n if (scene) {\n scene.removePendingData(texture);\n }\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n }\n _prepareWebGLTexture(texture, extension, scene, img, invertY, noMipmap, isCompressed, processFunction, samplingMode, format) {\n const maxTextureSize = this.getCaps().maxTextureSize;\n const potWidth = Math.min(maxTextureSize, this.needPOTTextures ? GetExponentOfTwo(img.width, maxTextureSize) : img.width);\n const potHeight = Math.min(maxTextureSize, this.needPOTTextures ? GetExponentOfTwo(img.height, maxTextureSize) : img.height);\n const gl = this._gl;\n if (!gl) {\n return;\n }\n if (!texture._hardwareTexture) {\n // this.resetTextureCache();\n if (scene) {\n scene.removePendingData(texture);\n }\n return;\n }\n this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);\n this._unpackFlipY(invertY === undefined ? true : invertY ? true : false);\n texture.baseWidth = img.width;\n texture.baseHeight = img.height;\n texture.width = potWidth;\n texture.height = potHeight;\n texture.isReady = true;\n texture.type = texture.type !== -1 ? texture.type : 0;\n texture.format = texture.format !== -1 ? texture.format : format !== null && format !== void 0 ? format : extension === \".jpg\" && !texture._useSRGBBuffer ? 4 : 5;\n if (processFunction(potWidth, potHeight, img, extension, texture, () => {\n this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);\n })) {\n // Returning as texture needs extra async steps\n return;\n }\n this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);\n }\n _getInternalFormatFromDepthTextureFormat(textureFormat, hasDepth, hasStencil) {\n const gl = this._gl;\n if (!hasDepth) {\n return gl.STENCIL_INDEX8;\n }\n const format = hasStencil ? gl.DEPTH_STENCIL : gl.DEPTH_COMPONENT;\n let internalFormat = format;\n if (this.webGLVersion > 1) {\n if (textureFormat === 15) {\n internalFormat = gl.DEPTH_COMPONENT16;\n } else if (textureFormat === 16) {\n internalFormat = gl.DEPTH_COMPONENT24;\n } else if (textureFormat === 17 || textureFormat === 13) {\n internalFormat = hasStencil ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT24;\n } else if (textureFormat === 14) {\n internalFormat = gl.DEPTH_COMPONENT32F;\n } else if (textureFormat === 18) {\n internalFormat = hasStencil ? gl.DEPTH32F_STENCIL8 : gl.DEPTH_COMPONENT32F;\n }\n } else {\n internalFormat = gl.DEPTH_COMPONENT16;\n }\n return internalFormat;\n }\n _getWebGLTextureTypeFromDepthTextureFormat(textureFormat) {\n const gl = this._gl;\n let type = gl.UNSIGNED_INT;\n if (textureFormat === 15) {\n type = gl.UNSIGNED_SHORT;\n } else if (textureFormat === 17 || textureFormat === 13) {\n type = gl.UNSIGNED_INT_24_8;\n } else if (textureFormat === 14) {\n type = gl.FLOAT;\n } else if (textureFormat === 18) {\n type = gl.FLOAT_32_UNSIGNED_INT_24_8_REV;\n } else if (textureFormat === 19) {\n type = gl.UNSIGNED_BYTE;\n }\n return type;\n }\n /**\n * @internal\n */\n _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples = 1, depthTextureFormat, dontBindRenderBufferToFrameBuffer = false) {\n var _depthTextureFormat;\n const gl = this._gl;\n depthTextureFormat = (_depthTextureFormat = depthTextureFormat) !== null && _depthTextureFormat !== void 0 ? _depthTextureFormat : generateStencilBuffer ? 13 : 14;\n const internalFormat = this._getInternalFormatFromDepthTextureFormat(depthTextureFormat, generateDepthBuffer, generateStencilBuffer);\n // Create the depth/stencil buffer\n if (generateStencilBuffer && generateDepthBuffer) {\n return this._createRenderBuffer(width, height, samples, gl.DEPTH_STENCIL, internalFormat, dontBindRenderBufferToFrameBuffer ? -1 : gl.DEPTH_STENCIL_ATTACHMENT);\n }\n if (generateDepthBuffer) {\n return this._createRenderBuffer(width, height, samples, internalFormat, internalFormat, dontBindRenderBufferToFrameBuffer ? -1 : gl.DEPTH_ATTACHMENT);\n }\n if (generateStencilBuffer) {\n return this._createRenderBuffer(width, height, samples, internalFormat, internalFormat, dontBindRenderBufferToFrameBuffer ? -1 : gl.STENCIL_ATTACHMENT);\n }\n return null;\n }\n /**\n * @internal\n */\n _createRenderBuffer(width, height, samples, internalFormat, msInternalFormat, attachment, unbindBuffer = true) {\n const gl = this._gl;\n const renderBuffer = gl.createRenderbuffer();\n return this._updateRenderBuffer(renderBuffer, width, height, samples, internalFormat, msInternalFormat, attachment, unbindBuffer);\n }\n _updateRenderBuffer(renderBuffer, width, height, samples, internalFormat, msInternalFormat, attachment, unbindBuffer = true) {\n const gl = this._gl;\n gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer);\n if (samples > 1 && gl.renderbufferStorageMultisample) {\n gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, msInternalFormat, width, height);\n } else {\n gl.renderbufferStorage(gl.RENDERBUFFER, internalFormat, width, height);\n }\n if (attachment !== -1) {\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, renderBuffer);\n }\n if (unbindBuffer) {\n gl.bindRenderbuffer(gl.RENDERBUFFER, null);\n }\n return renderBuffer;\n }\n /**\n * @internal\n */\n _releaseTexture(texture) {\n this._deleteTexture(texture._hardwareTexture);\n // Unbind channels\n this.unbindAllTextures();\n const index = this._internalTexturesCache.indexOf(texture);\n if (index !== -1) {\n this._internalTexturesCache.splice(index, 1);\n }\n // Integrated fixed lod samplers.\n if (texture._lodTextureHigh) {\n texture._lodTextureHigh.dispose();\n }\n if (texture._lodTextureMid) {\n texture._lodTextureMid.dispose();\n }\n if (texture._lodTextureLow) {\n texture._lodTextureLow.dispose();\n }\n // Integrated irradiance map.\n if (texture._irradianceTexture) {\n texture._irradianceTexture.dispose();\n }\n }\n _deleteTexture(texture) {\n texture === null || texture === void 0 || texture.release();\n }\n _setProgram(program) {\n if (this._currentProgram !== program) {\n _setProgram(program, this._gl);\n this._currentProgram = program;\n }\n }\n /**\n * Binds an effect to the webGL context\n * @param effect defines the effect to bind\n */\n bindSamplers(effect) {\n const webGLPipelineContext = effect.getPipelineContext();\n this._setProgram(webGLPipelineContext.program);\n const samplers = effect.getSamplers();\n for (let index = 0; index < samplers.length; index++) {\n const uniform = effect.getUniform(samplers[index]);\n if (uniform) {\n this._boundUniforms[index] = uniform;\n }\n }\n this._currentEffect = null;\n }\n _activateCurrentTexture() {\n if (this._currentTextureChannel !== this._activeChannel) {\n this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);\n this._currentTextureChannel = this._activeChannel;\n }\n }\n /**\n * @internal\n */\n _bindTextureDirectly(target, texture, forTextureDataUpdate = false, force = false) {\n let wasPreviouslyBound = false;\n const isTextureForRendering = texture && texture._associatedChannel > -1;\n if (forTextureDataUpdate && isTextureForRendering) {\n this._activeChannel = texture._associatedChannel;\n }\n const currentTextureBound = this._boundTexturesCache[this._activeChannel];\n if (currentTextureBound !== texture || force) {\n this._activateCurrentTexture();\n if (texture && texture.isMultiview) {\n //this._gl.bindTexture(target, texture ? texture._colorTextureArray : null);\n Logger.Error([\"_bindTextureDirectly called with a multiview texture!\", target, texture]);\n // eslint-disable-next-line no-throw-literal\n throw \"_bindTextureDirectly called with a multiview texture!\";\n } else {\n var _texture$_hardwareTex, _texture$_hardwareTex2;\n this._gl.bindTexture(target, (_texture$_hardwareTex = texture === null || texture === void 0 || (_texture$_hardwareTex2 = texture._hardwareTexture) === null || _texture$_hardwareTex2 === void 0 ? void 0 : _texture$_hardwareTex2.underlyingResource) !== null && _texture$_hardwareTex !== void 0 ? _texture$_hardwareTex : null);\n }\n this._boundTexturesCache[this._activeChannel] = texture;\n if (texture) {\n texture._associatedChannel = this._activeChannel;\n }\n } else if (forTextureDataUpdate) {\n wasPreviouslyBound = true;\n this._activateCurrentTexture();\n }\n if (isTextureForRendering && !forTextureDataUpdate) {\n this._bindSamplerUniformToChannel(texture._associatedChannel, this._activeChannel);\n }\n return wasPreviouslyBound;\n }\n /**\n * @internal\n */\n _bindTexture(channel, texture, name) {\n if (channel === undefined) {\n return;\n }\n if (texture) {\n texture._associatedChannel = channel;\n }\n this._activeChannel = channel;\n const target = texture ? this._getTextureTarget(texture) : this._gl.TEXTURE_2D;\n this._bindTextureDirectly(target, texture);\n }\n /**\n * Unbind all textures from the webGL context\n */\n unbindAllTextures() {\n for (let channel = 0; channel < this._maxSimultaneousTextures; channel++) {\n this._activeChannel = channel;\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);\n if (this.webGLVersion > 1) {\n this._bindTextureDirectly(this._gl.TEXTURE_3D, null);\n this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null);\n }\n }\n }\n /**\n * Sets a texture to the according uniform.\n * @param channel The texture channel\n * @param uniform The uniform to set\n * @param texture The texture to apply\n * @param name The name of the uniform in the effect\n */\n setTexture(channel, uniform, texture, name) {\n if (channel === undefined) {\n return;\n }\n if (uniform) {\n this._boundUniforms[channel] = uniform;\n }\n this._setTexture(channel, texture);\n }\n _bindSamplerUniformToChannel(sourceSlot, destination) {\n const uniform = this._boundUniforms[sourceSlot];\n if (!uniform || uniform._currentState === destination) {\n return;\n }\n this._gl.uniform1i(uniform, destination);\n uniform._currentState = destination;\n }\n _getTextureWrapMode(mode) {\n switch (mode) {\n case 1:\n return this._gl.REPEAT;\n case 0:\n return this._gl.CLAMP_TO_EDGE;\n case 2:\n return this._gl.MIRRORED_REPEAT;\n }\n return this._gl.REPEAT;\n }\n _setTexture(channel, texture, isPartOfTextureArray = false, depthStencilTexture = false, name = \"\") {\n // Not ready?\n if (!texture) {\n if (this._boundTexturesCache[channel] != null) {\n this._activeChannel = channel;\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);\n if (this.webGLVersion > 1) {\n this._bindTextureDirectly(this._gl.TEXTURE_3D, null);\n this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null);\n }\n }\n return false;\n }\n // Video\n if (texture.video) {\n this._activeChannel = channel;\n const videoInternalTexture = texture.getInternalTexture();\n if (videoInternalTexture) {\n videoInternalTexture._associatedChannel = channel;\n }\n texture.update();\n } else if (texture.delayLoadState === 4) {\n // Delay loading\n texture.delayLoad();\n return false;\n }\n let internalTexture;\n if (depthStencilTexture) {\n internalTexture = texture.depthStencilTexture;\n } else if (texture.isReady()) {\n internalTexture = texture.getInternalTexture();\n } else if (texture.isCube) {\n internalTexture = this.emptyCubeTexture;\n } else if (texture.is3D) {\n internalTexture = this.emptyTexture3D;\n } else if (texture.is2DArray) {\n internalTexture = this.emptyTexture2DArray;\n } else {\n internalTexture = this.emptyTexture;\n }\n if (!isPartOfTextureArray && internalTexture) {\n internalTexture._associatedChannel = channel;\n }\n let needToBind = true;\n if (this._boundTexturesCache[channel] === internalTexture) {\n if (!isPartOfTextureArray) {\n this._bindSamplerUniformToChannel(internalTexture._associatedChannel, channel);\n }\n needToBind = false;\n }\n this._activeChannel = channel;\n const target = this._getTextureTarget(internalTexture);\n if (needToBind) {\n this._bindTextureDirectly(target, internalTexture, isPartOfTextureArray);\n }\n if (internalTexture && !internalTexture.isMultiview) {\n // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.\n if (internalTexture.isCube && internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {\n internalTexture._cachedCoordinatesMode = texture.coordinatesMode;\n const textureWrapMode = texture.coordinatesMode !== 3 && texture.coordinatesMode !== 5 ? 1 : 0;\n texture.wrapU = textureWrapMode;\n texture.wrapV = textureWrapMode;\n }\n if (internalTexture._cachedWrapU !== texture.wrapU) {\n internalTexture._cachedWrapU = texture.wrapU;\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);\n }\n if (internalTexture._cachedWrapV !== texture.wrapV) {\n internalTexture._cachedWrapV = texture.wrapV;\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);\n }\n if (internalTexture.is3D && internalTexture._cachedWrapR !== texture.wrapR) {\n internalTexture._cachedWrapR = texture.wrapR;\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);\n }\n this._setAnisotropicLevel(target, internalTexture, texture.anisotropicFilteringLevel);\n }\n return true;\n }\n /**\n * Sets an array of texture to the webGL context\n * @param channel defines the channel where the texture array must be set\n * @param uniform defines the associated uniform location\n * @param textures defines the array of textures to bind\n * @param name name of the channel\n */\n setTextureArray(channel, uniform, textures, name) {\n if (channel === undefined || !uniform) {\n return;\n }\n if (!this._textureUnits || this._textureUnits.length !== textures.length) {\n this._textureUnits = new Int32Array(textures.length);\n }\n for (let i = 0; i < textures.length; i++) {\n const texture = textures[i].getInternalTexture();\n if (texture) {\n this._textureUnits[i] = channel + i;\n texture._associatedChannel = channel + i;\n } else {\n this._textureUnits[i] = -1;\n }\n }\n this._gl.uniform1iv(uniform, this._textureUnits);\n for (let index = 0; index < textures.length; index++) {\n this._setTexture(this._textureUnits[index], textures[index], true);\n }\n }\n /**\n * @internal\n */\n _setAnisotropicLevel(target, internalTexture, anisotropicFilteringLevel) {\n const anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;\n if (internalTexture.samplingMode !== 11 && internalTexture.samplingMode !== 3 && internalTexture.samplingMode !== 2) {\n anisotropicFilteringLevel = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear\n }\n if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== anisotropicFilteringLevel) {\n this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(anisotropicFilteringLevel, this._caps.maxAnisotropy), internalTexture);\n internalTexture._cachedAnisotropicFilteringLevel = anisotropicFilteringLevel;\n }\n }\n _setTextureParameterFloat(target, parameter, value, texture) {\n this._bindTextureDirectly(target, texture, true, true);\n this._gl.texParameterf(target, parameter, value);\n }\n _setTextureParameterInteger(target, parameter, value, texture) {\n if (texture) {\n this._bindTextureDirectly(target, texture, true, true);\n }\n this._gl.texParameteri(target, parameter, value);\n }\n /**\n * Unbind all vertex attributes from the webGL context\n */\n unbindAllAttributes() {\n if (this._mustWipeVertexAttributes) {\n this._mustWipeVertexAttributes = false;\n for (let i = 0; i < this._caps.maxVertexAttribs; i++) {\n this.disableAttributeByIndex(i);\n }\n return;\n }\n for (let i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {\n if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {\n continue;\n }\n this.disableAttributeByIndex(i);\n }\n }\n /**\n * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled\n */\n releaseEffects() {\n const keys = Object.keys(this._compiledEffects);\n for (const name of keys) {\n const effect = this._compiledEffects[name];\n effect.dispose(true);\n }\n this._compiledEffects = {};\n }\n /**\n * Dispose and release all associated resources\n */\n dispose() {\n // Events\n if (IsWindowObjectExist()) {\n if (this._renderingCanvas) {\n if (!this._doNotHandleContextLost) {\n this._renderingCanvas.removeEventListener(\"webglcontextlost\", this._onContextLost);\n this._renderingCanvas.removeEventListener(\"webglcontextrestored\", this._onContextRestored);\n }\n }\n }\n // Should not be moved up of renderingCanvas will be null.\n super.dispose();\n if (this._dummyFramebuffer) {\n this._gl.deleteFramebuffer(this._dummyFramebuffer);\n }\n // Unbind\n this.unbindAllAttributes();\n this._boundUniforms = {};\n this._workingCanvas = null;\n this._workingContext = null;\n this._currentBufferPointers.length = 0;\n this._currentProgram = null;\n if (this._creationOptions.loseContextOnDispose) {\n var _this$_gl$getExtensio;\n (_this$_gl$getExtensio = this._gl.getExtension(\"WEBGL_lose_context\")) === null || _this$_gl$getExtensio === void 0 || _this$_gl$getExtensio.loseContext();\n }\n // clear the state object\n deleteStateObject(this._gl);\n }\n /**\n * Attach a new callback raised when context lost event is fired\n * @param callback defines the callback to call\n */\n attachContextLostEvent(callback) {\n if (this._renderingCanvas) {\n this._renderingCanvas.addEventListener(\"webglcontextlost\", callback, false);\n }\n }\n /**\n * Attach a new callback raised when context restored event is fired\n * @param callback defines the callback to call\n */\n attachContextRestoredEvent(callback) {\n if (this._renderingCanvas) {\n this._renderingCanvas.addEventListener(\"webglcontextrestored\", callback, false);\n }\n }\n /**\n * Get the current error code of the webGL context\n * @returns the error code\n * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError\n */\n getError() {\n return this._gl.getError();\n }\n _canRenderToFloatFramebuffer() {\n if (this._webGLVersion > 1) {\n return this._caps.colorBufferFloat;\n }\n return this._canRenderToFramebuffer(1);\n }\n _canRenderToHalfFloatFramebuffer() {\n if (this._webGLVersion > 1) {\n return this._caps.colorBufferFloat;\n }\n return this._canRenderToFramebuffer(2);\n }\n // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n _canRenderToFramebuffer(type) {\n const gl = this._gl;\n //clear existing errors\n // eslint-disable-next-line no-empty\n while (gl.getError() !== gl.NO_ERROR) {}\n let successful = true;\n const texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n const fb = gl.createFramebuffer();\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb);\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);\n successful = successful && status === gl.FRAMEBUFFER_COMPLETE;\n successful = successful && gl.getError() === gl.NO_ERROR;\n //try render by clearing frame buffer's color buffer\n if (successful) {\n gl.clear(gl.COLOR_BUFFER_BIT);\n successful = successful && gl.getError() === gl.NO_ERROR;\n }\n //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)\n if (successful) {\n //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n const readFormat = gl.RGBA;\n const readType = gl.UNSIGNED_BYTE;\n const buffer = new Uint8Array(4);\n gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);\n successful = successful && gl.getError() === gl.NO_ERROR;\n }\n //clean up\n gl.deleteTexture(texture);\n gl.deleteFramebuffer(fb);\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n //clear accumulated errors\n // eslint-disable-next-line no-empty\n while (!successful && gl.getError() !== gl.NO_ERROR) {}\n return successful;\n }\n /**\n * @internal\n */\n _getWebGLTextureType(type) {\n if (this._webGLVersion === 1) {\n switch (type) {\n case 1:\n return this._gl.FLOAT;\n case 2:\n return this._gl.HALF_FLOAT_OES;\n case 0:\n return this._gl.UNSIGNED_BYTE;\n case 8:\n return this._gl.UNSIGNED_SHORT_4_4_4_4;\n case 9:\n return this._gl.UNSIGNED_SHORT_5_5_5_1;\n case 10:\n return this._gl.UNSIGNED_SHORT_5_6_5;\n }\n return this._gl.UNSIGNED_BYTE;\n }\n switch (type) {\n case 3:\n return this._gl.BYTE;\n case 0:\n return this._gl.UNSIGNED_BYTE;\n case 4:\n return this._gl.SHORT;\n case 5:\n return this._gl.UNSIGNED_SHORT;\n case 6:\n return this._gl.INT;\n case 7:\n // Refers to UNSIGNED_INT\n return this._gl.UNSIGNED_INT;\n case 1:\n return this._gl.FLOAT;\n case 2:\n return this._gl.HALF_FLOAT;\n case 8:\n return this._gl.UNSIGNED_SHORT_4_4_4_4;\n case 9:\n return this._gl.UNSIGNED_SHORT_5_5_5_1;\n case 10:\n return this._gl.UNSIGNED_SHORT_5_6_5;\n case 11:\n return this._gl.UNSIGNED_INT_2_10_10_10_REV;\n case 12:\n return this._gl.UNSIGNED_INT_24_8;\n case 13:\n return this._gl.UNSIGNED_INT_10F_11F_11F_REV;\n case 14:\n return this._gl.UNSIGNED_INT_5_9_9_9_REV;\n case 15:\n return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;\n }\n return this._gl.UNSIGNED_BYTE;\n }\n /**\n * @internal\n */\n _getInternalFormat(format, useSRGBBuffer = false) {\n let internalFormat = useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA;\n switch (format) {\n case 0:\n internalFormat = this._gl.ALPHA;\n break;\n case 1:\n internalFormat = this._gl.LUMINANCE;\n break;\n case 2:\n internalFormat = this._gl.LUMINANCE_ALPHA;\n break;\n case 6:\n case 33322:\n case 36760:\n internalFormat = this._gl.RED;\n break;\n case 7:\n case 33324:\n case 36761:\n internalFormat = this._gl.RG;\n break;\n case 4:\n case 32852:\n case 36762:\n internalFormat = useSRGBBuffer ? this._glSRGBExtensionValues.SRGB : this._gl.RGB;\n break;\n case 5:\n case 32859:\n case 36763:\n internalFormat = useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA;\n break;\n }\n if (this._webGLVersion > 1) {\n switch (format) {\n case 8:\n internalFormat = this._gl.RED_INTEGER;\n break;\n case 9:\n internalFormat = this._gl.RG_INTEGER;\n break;\n case 10:\n internalFormat = this._gl.RGB_INTEGER;\n break;\n case 11:\n internalFormat = this._gl.RGBA_INTEGER;\n break;\n }\n }\n return internalFormat;\n }\n /**\n * @internal\n */\n _getRGBABufferInternalSizedFormat(type, format, useSRGBBuffer = false) {\n if (this._webGLVersion === 1) {\n if (format !== undefined) {\n switch (format) {\n case 0:\n return this._gl.ALPHA;\n case 1:\n return this._gl.LUMINANCE;\n case 2:\n return this._gl.LUMINANCE_ALPHA;\n case 4:\n return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB : this._gl.RGB;\n }\n }\n return this._gl.RGBA;\n }\n switch (type) {\n case 3:\n switch (format) {\n case 6:\n return this._gl.R8_SNORM;\n case 7:\n return this._gl.RG8_SNORM;\n case 4:\n return this._gl.RGB8_SNORM;\n case 8:\n return this._gl.R8I;\n case 9:\n return this._gl.RG8I;\n case 10:\n return this._gl.RGB8I;\n case 11:\n return this._gl.RGBA8I;\n default:\n return this._gl.RGBA8_SNORM;\n }\n case 0:\n switch (format) {\n case 6:\n return this._gl.R8;\n case 7:\n return this._gl.RG8;\n case 4:\n return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8 : this._gl.RGB8;\n // By default. Other possibilities are RGB565, SRGB8.\n case 5:\n return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA8;\n // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.\n case 8:\n return this._gl.R8UI;\n case 9:\n return this._gl.RG8UI;\n case 10:\n return this._gl.RGB8UI;\n case 11:\n return this._gl.RGBA8UI;\n case 0:\n return this._gl.ALPHA;\n case 1:\n return this._gl.LUMINANCE;\n case 2:\n return this._gl.LUMINANCE_ALPHA;\n default:\n return this._gl.RGBA8;\n }\n case 4:\n switch (format) {\n case 8:\n return this._gl.R16I;\n case 36760:\n return this._gl.R16_SNORM_EXT;\n case 36761:\n return this._gl.RG16_SNORM_EXT;\n case 36762:\n return this._gl.RGB16_SNORM_EXT;\n case 36763:\n return this._gl.RGBA16_SNORM_EXT;\n case 9:\n return this._gl.RG16I;\n case 10:\n return this._gl.RGB16I;\n case 11:\n return this._gl.RGBA16I;\n default:\n return this._gl.RGBA16I;\n }\n case 5:\n switch (format) {\n case 8:\n return this._gl.R16UI;\n case 33322:\n return this._gl.R16_EXT;\n case 33324:\n return this._gl.RG16_EXT;\n case 32852:\n return this._gl.RGB16_EXT;\n case 32859:\n return this._gl.RGBA16_EXT;\n case 9:\n return this._gl.RG16UI;\n case 10:\n return this._gl.RGB16UI;\n case 11:\n return this._gl.RGBA16UI;\n default:\n return this._gl.RGBA16UI;\n }\n case 6:\n switch (format) {\n case 8:\n return this._gl.R32I;\n case 9:\n return this._gl.RG32I;\n case 10:\n return this._gl.RGB32I;\n case 11:\n return this._gl.RGBA32I;\n default:\n return this._gl.RGBA32I;\n }\n case 7:\n // Refers to UNSIGNED_INT\n switch (format) {\n case 8:\n return this._gl.R32UI;\n case 9:\n return this._gl.RG32UI;\n case 10:\n return this._gl.RGB32UI;\n case 11:\n return this._gl.RGBA32UI;\n default:\n return this._gl.RGBA32UI;\n }\n case 1:\n switch (format) {\n case 6:\n return this._gl.R32F;\n // By default. Other possibility is R16F.\n case 7:\n return this._gl.RG32F;\n // By default. Other possibility is RG16F.\n case 4:\n return this._gl.RGB32F;\n // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.\n case 5:\n return this._gl.RGBA32F;\n // By default. Other possibility is RGBA16F.\n default:\n return this._gl.RGBA32F;\n }\n case 2:\n switch (format) {\n case 6:\n return this._gl.R16F;\n case 7:\n return this._gl.RG16F;\n case 4:\n return this._gl.RGB16F;\n // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.\n case 5:\n return this._gl.RGBA16F;\n default:\n return this._gl.RGBA16F;\n }\n case 10:\n return this._gl.RGB565;\n case 13:\n return this._gl.R11F_G11F_B10F;\n case 14:\n return this._gl.RGB9_E5;\n case 8:\n return this._gl.RGBA4;\n case 9:\n return this._gl.RGB5_A1;\n case 11:\n switch (format) {\n case 5:\n return this._gl.RGB10_A2;\n // By default. Other possibility is RGB5_A1.\n case 11:\n return this._gl.RGB10_A2UI;\n default:\n return this._gl.RGB10_A2;\n }\n }\n return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA8;\n }\n /**\n * Reads pixels from the current frame buffer. Please note that this function can be slow\n * @param x defines the x coordinate of the rectangle where pixels must be read\n * @param y defines the y coordinate of the rectangle where pixels must be read\n * @param width defines the width of the rectangle where pixels must be read\n * @param height defines the height of the rectangle where pixels must be read\n * @param hasAlpha defines whether the output should have alpha or not (defaults to true)\n * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels\n * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors\n */\n readPixels(x, y, width, height, hasAlpha = true, flushRenderer = true) {\n const numChannels = hasAlpha ? 4 : 3;\n const format = hasAlpha ? this._gl.RGBA : this._gl.RGB;\n const data = new Uint8Array(height * width * numChannels);\n if (flushRenderer) {\n this.flushFramebuffer();\n }\n this._gl.readPixels(x, y, width, height, format, this._gl.UNSIGNED_BYTE, data);\n return Promise.resolve(data);\n }\n /**\n * Gets a Promise<boolean> indicating if the engine can be instantiated (ie. if a webGL context can be found)\n */\n static get IsSupportedAsync() {\n return Promise.resolve(this.isSupported());\n }\n /**\n * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)\n */\n static get IsSupported() {\n return this.isSupported(); // Backward compat\n }\n /**\n * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)\n * @returns true if the engine can be created\n * @ignorenaming\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n static isSupported() {\n if (this._HasMajorPerformanceCaveat !== null) {\n return !this._HasMajorPerformanceCaveat; // We know it is performant so WebGL is supported\n }\n if (this._IsSupported === null) {\n try {\n const tempcanvas = AbstractEngine._CreateCanvas(1, 1);\n const gl = tempcanvas.getContext(\"webgl\") || tempcanvas.getContext(\"experimental-webgl\");\n this._IsSupported = gl != null && !!window.WebGLRenderingContext;\n } catch (e) {\n this._IsSupported = false;\n }\n }\n return this._IsSupported;\n }\n /**\n * Gets a boolean indicating if the engine can be instantiated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)\n */\n static get HasMajorPerformanceCaveat() {\n if (this._HasMajorPerformanceCaveat === null) {\n try {\n const tempcanvas = AbstractEngine._CreateCanvas(1, 1);\n const gl = tempcanvas.getContext(\"webgl\", {\n failIfMajorPerformanceCaveat: true\n }) || tempcanvas.getContext(\"experimental-webgl\", {\n failIfMajorPerformanceCaveat: true\n });\n this._HasMajorPerformanceCaveat = !gl;\n } catch (e) {\n this._HasMajorPerformanceCaveat = false;\n }\n }\n return this._HasMajorPerformanceCaveat;\n }\n}\nThinEngine._TempClearColorUint32 = new Uint32Array(4);\nThinEngine._TempClearColorInt32 = new Int32Array(4);\n/** Use this array to turn off some WebGL2 features on known buggy browsers version */\nThinEngine.ExceptionList = [{\n key: \"Chrome/63.0\",\n capture: \"63\\\\.0\\\\.3239\\\\.(\\\\d+)\",\n captureConstraint: 108,\n targets: [\"uniformBuffer\"]\n}, {\n key: \"Firefox/58\",\n capture: null,\n captureConstraint: null,\n targets: [\"uniformBuffer\"]\n}, {\n key: \"Firefox/59\",\n capture: null,\n captureConstraint: null,\n targets: [\"uniformBuffer\"]\n}, {\n key: \"Chrome/72.+?Mobile\",\n capture: null,\n captureConstraint: null,\n targets: [\"vao\"]\n}, {\n key: \"Chrome/73.+?Mobile\",\n capture: null,\n captureConstraint: null,\n targets: [\"vao\"]\n}, {\n key: \"Chrome/74.+?Mobile\",\n capture: null,\n captureConstraint: null,\n targets: [\"vao\"]\n}, {\n key: \"Mac OS.+Chrome/71\",\n capture: null,\n captureConstraint: null,\n targets: [\"vao\"]\n}, {\n key: \"Mac OS.+Chrome/72\",\n capture: null,\n captureConstraint: null,\n targets: [\"vao\"]\n}, {\n key: \"Mac OS.+Chrome\",\n capture: null,\n captureConstraint: null,\n targets: [\"uniformBuffer\"]\n}, {\n key: \"Chrome/12\\\\d\\\\..+?Mobile\",\n capture: null,\n captureConstraint: null,\n targets: [\"uniformBuffer\"]\n},\n// desktop osx safari 15.4\n{\n key: \".*AppleWebKit.*(15.4).*Safari\",\n capture: null,\n captureConstraint: null,\n targets: [\"antialias\", \"maxMSAASamples\"]\n},\n// mobile browsers using safari 15.4 on ios\n{\n key: \".*(15.4).*AppleWebKit.*Safari\",\n capture: null,\n captureConstraint: null,\n targets: [\"antialias\", \"maxMSAASamples\"]\n}];\n// eslint-disable-next-line @typescript-eslint/naming-convention\nThinEngine._ConcatenateShader = _ConcatenateShader;\n// Statics\nThinEngine._IsSupported = null;\nThinEngine._HasMajorPerformanceCaveat = null;","map":{"version":3,"names":["createPipelineContext","createRawShaderProgram","createShaderProgram","_finalizePipelineContext","_preparePipelineContext","_setProgram","_executeWhenRenderingStateIsCompiled","getStateObject","_createShaderProgram","deleteStateObject","_isRenderingStateCompiled","IsWrapper","Logger","IsWindowObjectExist","WebGLShaderProcessor","WebGL2ShaderProcessor","WebGLDataBuffer","GetExponentOfTwo","AbstractEngine","WebGLHardwareTexture","InternalTexture","IsDepthTexture","HasStencilAspect","Effect","_ConcatenateShader","_getGlobalDefines","resetCachedPipeline","BufferPointer","ThinEngine","name","_name","value","version","_webGLVersion","ShadersRepository","supportsUniformBuffers","webGLVersion","disableUniformBuffers","needPOTTextures","forcePOTTextures","_supportsHardwareTextureRescaling","framebufferDimensionsObject","dimensions","_framebufferDimensionsObject","snapshotRenderingReset","snapshotRendering","constructor","canvasOrContext","antialias","options","adaptToDeviceRatio","validateShaderPrograms","_vertexAttribArraysEnabled","_uintIndicesCurrentlySet","_currentBoundBuffer","Array","_currentFramebuffer","_dummyFramebuffer","_currentBufferPointers","_currentInstanceLocations","_currentInstanceBuffers","_vaoRecordInProgress","_mustWipeVertexAttributes","_nextFreeTextureSlots","_maxSimultaneousTextures","_maxMSAASamplesOverride","_unpackFlipYCached","enableUnpackFlipYCached","_boundUniforms","canvas","getContext","_renderingCanvas","preserveDrawingBuffer","undefined","xrCompatible","navigator","userAgent","_setupMobileChecks","ua","exception","ExceptionList","key","targets","check","RegExp","test","capture","captureConstraint","constraint","regex","matches","exec","length","capturedValue","parseInt","target","disableVertexArrayObjects","_doNotHandleContextLost","_onContextLost","evt","preventDefault","_contextWasLost","Warn","onContextLostObservable","notifyObservers","_onContextRestored","_restoreEngineAfterContextLost","_initGLContext","addEventListener","powerPreference","_badDesktopOS","disableWebGL2Support","_gl","_shaderPlatformName","deleteQuery","e","Error","renderbufferStorageMultisample","attributes","getContextAttributes","stencil","pixelStorei","UNPACK_COLORSPACE_CONVERSION_WEBGL","NONE","useHighPrecisionFloats","_highPrecisionShadersAllowed","resize","_initFeatures","i","_caps","maxVertexAttribs","_shaderProcessor","versionToLog","Version","Log","description","setAttribute","stateObject","parallelShaderCompile","_clearEmptyResources","_getShaderProcessingContext","shaderLanguage","areAllEffectsReady","_compiledEffects","effect","isReady","maxTexturesImageUnits","getParameter","MAX_TEXTURE_IMAGE_UNITS","maxCombinedTexturesImageUnits","MAX_COMBINED_TEXTURE_IMAGE_UNITS","maxVertexTextureImageUnits","MAX_VERTEX_TEXTURE_IMAGE_UNITS","maxTextureSize","MAX_TEXTURE_SIZE","maxSamples","MAX_SAMPLES","maxCubemapTextureSize","MAX_CUBE_MAP_TEXTURE_SIZE","maxRenderTextureSize","MAX_RENDERBUFFER_SIZE","MAX_VERTEX_ATTRIBS","maxVaryingVectors","MAX_VARYING_VECTORS","maxFragmentUniformVectors","MAX_FRAGMENT_UNIFORM_VECTORS","maxVertexUniformVectors","MAX_VERTEX_UNIFORM_VECTORS","getExtension","standardDerivatives","maxAnisotropy","astc","bptc","s3tc","s3tc_srgb","pvrtc","etc1","etc2","textureAnisotropicFilterExtension","uintIndices","fragmentDepthSupported","highPrecisionShaderSupported","timerQuery","supportOcclusionQuery","canUseTimestampForTimerQuery","drawBuffersExtension","maxMSAASamples","colorBufferFloat","supportFloatTexturesResolve","rg11b10ufColorRenderable","colorBufferHalfFloat","textureFloat","textureHalfFloat","textureHalfFloatRender","textureFloatLinearFiltering","textureFloatRender","textureHalfFloatLinearFiltering","vertexArrayObject","instancedArrays","textureLOD","texelFetch","blendMinMax","multiview","oculusMultiview","depthTextureExtension","canUseGLInstanceID","canUseGLVertexID","supportComputeShaders","supportSRGBBuffers","supportTransformFeedbacks","textureMaxLevel","texture2DArrayMaxLayerCount","MAX_ARRAY_TEXTURE_LAYERS","disableMorphTargetTexture","textureNorm16","_glVersion","VERSION","rendererInfo","_glRenderer","UNMASKED_RENDERER_WEBGL","_glVendor","UNMASKED_VENDOR_WEBGL","VENDOR","RENDERER","HALF_FLOAT_OES","RGBA16F","RGBA32F","DEPTH24_STENCIL8","_this$_gl$getQuery","getQuery","getQueryEXT","bind","TIMESTAMP_EXT","QUERY_COUNTER_BITS_EXT","MAX_TEXTURE_MAX_ANISOTROPY_EXT","_canRenderToFloatFramebuffer","R16_EXT","RG16_EXT","RGB16_EXT","RGBA16_EXT","R16_SNORM_EXT","RG16_SNORM_EXT","RGB16_SNORM_EXT","RGBA16_SNORM_EXT","COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR","COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT","COMPRESSED_SRGB_S3TC_DXT1_EXT","COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT","COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT","COMPRESSED_SRGB8_ETC2","COMPRESSED_SRGB8_ALPHA8_ETC2_EAC","_canRenderToHalfFloatFramebuffer","maxDrawBuffers","MAX_DRAW_BUFFERS","drawBuffers","drawBuffersWEBGL","MAX_DRAW_BUFFERS_WEBGL","DRAW_FRAMEBUFFER","FRAMEBUFFER","UNSIGNED_INT_24_8","UNSIGNED_INT_24_8_WEBGL","vertexArrayObjectExtension","createVertexArray","createVertexArrayOES","bindVertexArray","bindVertexArrayOES","deleteVertexArray","deleteVertexArrayOES","instanceExtension","drawArraysInstanced","drawArraysInstancedANGLE","drawElementsInstanced","drawElementsInstancedANGLE","vertexAttribDivisor","vertexAttribDivisorANGLE","getShaderPrecisionFormat","vertexhighp","VERTEX_SHADER","HIGH_FLOAT","fragmenthighp","FRAGMENT_SHADER","precision","blendMinMaxExtension","MAX","MAX_EXT","MIN","MIN_EXT","_glSRGBExtensionValues","SRGB","WebGL2RenderingContext","SRGB8","SRGB8_ALPHA8","sRGBExtension","SRGB_EXT","SRGB_ALPHA_EXT","_creationOptions","forceSRGBBufferSupportState","_depthCullingState","depthTest","depthFunc","LEQUAL","depthMask","slot","push","_features","forceBitmapOverHTMLImageElement","HTMLImageElement","supportRenderAndCopyToLodForFloatTextures","supportDepthStencilTexture","supportShadowSamplers","uniformBufferHardCheckMatrix","allowTexturePrefiltering","trackUbosInFrame","checkUbosContentBeforeUpload","supportCSM","basisNeedsPOT","support3DTextures","needTypeSuffixInShaderConstants","supportMSAA","supportSSAO2","supportIBLShadows","supportExtendedTextureFormats","supportSwitchCaseInShader","supportSyncTextureRead","needsInvertingBitmap","useUBOBindingCache","needShaderCodeInlining","needToAlwaysBindUniformBuffers","supportRenderPasses","supportSpriteInstancing","forceVertexBufferStrideAndOffsetMultiple4Bytes","_checkNonFloatVertexBuffersDontRecreatePipelineContext","_collectUbosUpdatedInFrame","getClassName","_prepareWorkingCanvas","_workingCanvas","createCanvas","context","_workingContext","getInfo","getGlInfo","vendor","renderer","extractDriverInfo","glInfo","getRenderWidth","useScreen","_currentRenderTarget","width","framebufferWidth","drawingBufferWidth","getRenderHeight","height","framebufferHeight","drawingBufferHeight","clear","color","backBuffer","depth","useStencilGlobalOnly","stencilStateComposer","applyStates","mode","setBackBufferColor","_this$_currentRenderT","textureFormat","texture","format","_this$_currentRenderT2","textureType","type","_TempClearColorUint32","r","g","b","a","clearBufferuiv","COLOR","_TempClearColorInt32","clearBufferiv","clearColor","COLOR_BUFFER_BIT","useReverseDepthBuffer","GEQUAL","clearDepth","DEPTH_BUFFER_BIT","clearStencil","STENCIL_BUFFER_BIT","_viewport","x","y","_viewportCached","z","w","viewport","endFrame","_badOS","flushFramebuffer","performanceMonitor","bindFramebuffer","rtWrapper","faceIndex","requiredWidth","requiredHeight","forceFullscreenViewport","lodLevel","layer","webglRTWrapper","unBindFramebuffer","_bindUnboundFramebuffer","_framebuffer","gl","isMulti","is2DArray","is3D","_rtWrapper$texture$_h","framebufferTextureLayer","COLOR_ATTACHMENT0","_hardwareTexture","underlyingResource","_currentLOD","isCube","_rtWrapper$texture$_h2","framebufferTexture2D","TEXTURE_CUBE_MAP_POSITIVE_X","_rtWrapper$texture$_h3","TEXTURE_2D","depthStencilTexture","_depthStencilTexture","attachment","_depthStencilTextureWithStencil","DEPTH_STENCIL_ATTACHMENT","DEPTH_ATTACHMENT","_depthStencilTexture$","_depthStencilTexture$2","_depthStencilTexture$3","_MSAAFramebuffer","_cachedViewport","setViewport","Math","pow","wipeCaches","setState","culling","zOffset","force","reverseSide","cullBackFaces","zOffsetUnits","_ref","_this$cullBackFaces","cull","cullFace","BACK","FRONT","setZOffset","setZOffsetUnits","frontFace","CW","CCW","_stencilStateComposer","stencilMaterial","framebuffer","_currentFrameBufferIsDefaultFrameBuffer","generateMipmaps","_getTextureTarget","_bindTextureDirectly","generateMipmap","disableGenerateMipMaps","onBeforeUnbind","disableAutomaticMSAAResolve","resolveMultiFramebuffer","resolveFramebuffer","generateMipMapsMultiFramebuffer","generateMipMapsFramebuffer","_texture$texture","generateMipMaps","bufferBits","resolveMSAAColors","_generateDepthBuffer","resolveMSAADepth","_generateStencilBuffer","resolveMSAAStencil","READ_FRAMEBUFFER","blitFramebuffer","NEAREST","flush","restoreDefaultFramebuffer","_resetVertexBufferBinding","bindArrayBuffer","_cachedVertexBuffers","createVertexBuffer","data","_updatable","_label","_createVertexBuffer","STATIC_DRAW","usage","vbo","createBuffer","dataBuffer","bufferData","ARRAY_BUFFER","Float32Array","capacity","byteLength","Uint8Array","references","createDynamicVertexBuffer","DYNAMIC_DRAW","_resetIndexBufferBinding","bindIndexBuffer","_cachedIndexBuffer","createIndexBuffer","indices","updatable","_normalizeIndexData","ELEMENT_ARRAY_BUFFER","is32Bits","BYTES_PER_ELEMENT","bytesPerElement","Uint32Array","index","Uint16Array","buffer","_unbindVertexArrayObject","_bindBuffer","bindUniformBlock","pipelineContext","blockName","program","uniformLocation","getUniformBlockIndex","uniformBlockBinding","bindBuffer","updateArrayBuffer","bufferSubData","_vertexAttribPointer","indx","size","normalized","stride","offset","pointer","changed","active","UNSIGNED_INT","INT","vertexAttribIPointer","vertexAttribPointer","_bindIndexBufferWithCache","indexBuffer","_bindVertexBuffersAttributes","vertexBuffers","overrideVertexBuffers","getAttributesNames","unbindAllAttributes","order","getAttributeLocation","ai","vertexBuffer","enableVertexAttribArray","getBuffer","getSize","byteStride","byteOffset","getIsInstanced","getInstanceDivisor","recordVertexArrayObject","vao","bindVertexArrayObject","_cachedVertexArrayObject","bindBuffersDirectly","vertexDeclaration","vertexStrideSize","_cachedEffectForVertexBuffers","attributesCount","getAttributesCount","FLOAT","bindBuffers","unbindInstanceAttributes","boundBuffer","ul","instancesBuffer","offsetLocation","releaseVertexArrayObject","_releaseBuffer","_deleteBuffer","deleteBuffer","updateAndBindInstancesBuffer","offsetLocations","bindInstancesBuffer","attributesInfo","computeStride","attributeSize","_currentEffect","getAttributeLocationByName","attributeName","attributeType","divisor","disableInstanceAttributeByName","attributeLocation","disableInstanceAttribute","shouldClean","indexOf","splice","disableAttributeByIndex","disableVertexAttribArray","draw","useTriangles","indexStart","indexCount","instancesCount","drawElementsType","drawPointClouds","verticesStart","verticesCount","drawArraysType","drawUnIndexed","fillMode","_reportDrawCall","drawMode","_drawMode","indexFormat","UNSIGNED_SHORT","mult","drawElements","drawArrays","TRIANGLES","POINTS","LINES","LINE_LOOP","LINE_STRIP","TRIANGLE_STRIP","TRIANGLE_FAN","_releaseEffect","_key","getPipelineContext","_deletePipelineContext","webGLPipelineContext","__SPECTOR_rebuildProgram","deleteProgram","defines","isNDCHalfZRange","useExactSrgbConversions","createEffect","baseName","attributesNamesOrOptions","uniformsNamesOrEngine","samplers","fallbacks","onCompiled","onError","indexParameters","extraInitializationsAsync","_ref2","_attributesNamesOrOpt","_attributesNamesOrOpt2","vertex","vertexToken","vertexSource","vertexElement","fragment","fragmentToken","fragmentSource","fragmentElement","globalDefines","fullDefines","compiledEffect","_refCount","_getShaderSource","shader","getShaderSource","vertexCode","fragmentCode","transformFeedbackVaryings","inlineShaderCode","code","shaderProcessingContext","engine","createMaterialContext","createDrawContext","vertexSourceCode","fragmentSourceCode","createAsRaw","rawVertexSourceCode","rawFragmentSourceCode","rebuildRebind","onReady","_createShaderProgramInjection","createRawShaderProgramInjection","createShaderProgramInjection","loadFileInjection","_loadFile","vertexShader","fragmentShader","_isDisposed","action","getUniforms","uniformsNames","results","getUniformLocation","getAttributes","attributesNames","getAttribLocation","enableEffect","bindSamplers","onBind","_onBindObservable","setInt","uniform","uniform1i","setInt2","uniform2i","setInt3","uniform3i","setInt4","uniform4i","setIntArray","array","uniform1iv","setIntArray2","uniform2iv","setIntArray3","uniform3iv","setIntArray4","uniform4iv","setUInt","uniform1ui","setUInt2","uniform2ui","setUInt3","uniform3ui","setUInt4","uniform4ui","setUIntArray","uniform1uiv","setUIntArray2","uniform2uiv","setUIntArray3","uniform3uiv","setUIntArray4","uniform4uiv","setArray","uniform1fv","setArray2","uniform2fv","setArray3","uniform3fv","setArray4","uniform4fv","setMatrices","matrices","uniformMatrix4fv","setMatrix3x3","matrix","uniformMatrix3fv","setMatrix2x2","uniformMatrix2fv","setFloat","uniform1f","setFloat2","uniform2f","setFloat3","uniform3f","setFloat4","uniform4f","apply","_alphaState","_colorWriteChanged","enable","_colorWrite","colorMask","bruteForce","preventCacheWipeBetweenFrames","_currentProgram","resetTextureCache","reset","_alphaMode","_alphaEquation","UNPACK_PREMULTIPLY_ALPHA_WEBGL","_getSamplingParameters","samplingMode","magFilter","minFilter","LINEAR","LINEAR_MIPMAP_NEAREST","LINEAR_MIPMAP_LINEAR","NEAREST_MIPMAP_LINEAR","NEAREST_MIPMAP_NEAREST","min","mag","_createTexture","createTexture","_createHardwareTexture","_createInternalTexture","delayGPUTextureCreation","source","createMipMaps","useSRGBBuffer","samples","label","createMSAATexture","comparisonFunction","_options$samples","isWebGPU","isDepthTexture","hasStencil","layers","filters","TEXTURE_2D_ARRAY","TEXTURE_3D","sizedFormat","_getInternalFormatFromDepthTextureFormat","_getRGBABufferInternalSizedFormat","internalFormat","DEPTH_STENCIL","DEPTH_COMPONENT","_getInternalFormat","_getWebGLTextureTypeFromDepthTextureFormat","_getWebGLTextureType","texImage3D","texImage2D","texParameteri","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","CLAMP_TO_EDGE","TEXTURE_WRAP_T","TEXTURE_COMPARE_FUNC","TEXTURE_COMPARE_MODE","COMPARE_REF_TO_TEXTURE","_useSRGBBuffer","baseWidth","baseHeight","_internalTexturesCache","renderBuffer","_setupFramebufferDepthAttachments","_createRenderBuffer","_autoMSAAManagement","hardwareTexture","addMSAARenderBuffer","_getUseSRGBBuffer","noMipmap","url","invertY","scene","onLoad","fallback","forcedExtension","mimeType","loaderOptions","creationFlags","_createTextureBase","args","_prepareWebGLTexture","potWidth","potHeight","img","extension","continuationCallback","isPot","_creationFlags","tip","_getTexImageParametersForCreateTexture","drawImage","_rescaleTexture","_releaseTexture","babylonFormat","UNSIGNED_BYTE","destination","onComplete","_unpackFlipY","UNPACK_FLIP_Y_WEBGL","_getUnpackAlignement","UNPACK_ALIGNMENT","TEXTURE_CUBE_MAP","isMultiview","updateTextureSamplingMode","useMipMaps","_setTextureParameterInteger","updateTextureDimensions","updateTextureWrappingMode","wrapU","wrapV","wrapR","_getTextureWrapMode","_cachedWrapU","_cachedWrapV","TEXTURE_WRAP_R","_cachedWrapR","_uploadCompressedDataToTextureDirectly","lod","compressedTexImage2D","_uploadDataToTextureDirectly","imageData","babylonInternalFormat","useTextureWidthAndHeight","lodMaxWidth","round","log","LOG2E","lodMaxHeight","max","updateTextureData","xOffset","yOffset","targetForBinding","texSubImage2D","_uploadArrayBufferViewToTexture","bindTarget","_prepareWebGLTextureContinuation","isCompressed","removePendingData","onLoadedObservable","processFunction","getCaps","hasDepth","STENCIL_INDEX8","DEPTH_COMPONENT16","DEPTH_COMPONENT24","DEPTH_COMPONENT32F","DEPTH32F_STENCIL8","FLOAT_32_UNSIGNED_INT_24_8_REV","generateStencilBuffer","generateDepthBuffer","depthTextureFormat","dontBindRenderBufferToFrameBuffer","_depthTextureFormat","STENCIL_ATTACHMENT","msInternalFormat","unbindBuffer","createRenderbuffer","_updateRenderBuffer","bindRenderbuffer","RENDERBUFFER","renderbufferStorage","framebufferRenderbuffer","_deleteTexture","unbindAllTextures","_lodTextureHigh","dispose","_lodTextureMid","_lodTextureLow","_irradianceTexture","release","getSamplers","getUniform","_activateCurrentTexture","_currentTextureChannel","_activeChannel","activeTexture","TEXTURE0","forTextureDataUpdate","wasPreviouslyBound","isTextureForRendering","_associatedChannel","currentTextureBound","_boundTexturesCache","_texture$_hardwareTex","_texture$_hardwareTex2","bindTexture","_bindSamplerUniformToChannel","_bindTexture","channel","setTexture","_setTexture","sourceSlot","_currentState","REPEAT","MIRRORED_REPEAT","isPartOfTextureArray","video","videoInternalTexture","getInternalTexture","update","delayLoadState","delayLoad","internalTexture","emptyCubeTexture","emptyTexture3D","emptyTexture2DArray","emptyTexture","needToBind","_cachedCoordinatesMode","coordinatesMode","textureWrapMode","_setAnisotropicLevel","anisotropicFilteringLevel","setTextureArray","textures","_textureUnits","Int32Array","anisotropicFilterExtension","_cachedAnisotropicFilteringLevel","_setTextureParameterFloat","TEXTURE_MAX_ANISOTROPY_EXT","parameter","texParameterf","releaseEffects","keys","Object","removeEventListener","deleteFramebuffer","loseContextOnDispose","_this$_gl$getExtensio","loseContext","attachContextLostEvent","callback","attachContextRestoredEvent","getError","_canRenderToFramebuffer","NO_ERROR","successful","RGBA","fb","createFramebuffer","status","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","readFormat","readType","readPixels","deleteTexture","UNSIGNED_SHORT_4_4_4_4","UNSIGNED_SHORT_5_5_5_1","UNSIGNED_SHORT_5_6_5","BYTE","SHORT","HALF_FLOAT","UNSIGNED_INT_2_10_10_10_REV","UNSIGNED_INT_10F_11F_11F_REV","UNSIGNED_INT_5_9_9_9_REV","ALPHA","LUMINANCE","LUMINANCE_ALPHA","RED","RG","RGB","RED_INTEGER","RG_INTEGER","RGB_INTEGER","RGBA_INTEGER","R8_SNORM","RG8_SNORM","RGB8_SNORM","R8I","RG8I","RGB8I","RGBA8I","RGBA8_SNORM","R8","RG8","RGB8","RGBA8","R8UI","RG8UI","RGB8UI","RGBA8UI","R16I","RG16I","RGB16I","RGBA16I","R16UI","RG16UI","RGB16UI","RGBA16UI","R32I","RG32I","RGB32I","RGBA32I","R32UI","RG32UI","RGB32UI","RGBA32UI","R32F","RG32F","RGB32F","R16F","RG16F","RGB16F","RGB565","R11F_G11F_B10F","RGB9_E5","RGBA4","RGB5_A1","RGB10_A2","RGB10_A2UI","hasAlpha","flushRenderer","numChannels","Promise","resolve","IsSupportedAsync","isSupported","IsSupported","_HasMajorPerformanceCaveat","_IsSupported","tempcanvas","_CreateCanvas","window","WebGLRenderingContext","HasMajorPerformanceCaveat","failIfMajorPerformanceCaveat"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/thinEngine.js"],"sourcesContent":["import { createPipelineContext, createRawShaderProgram, createShaderProgram, _finalizePipelineContext, _preparePipelineContext, _setProgram, _executeWhenRenderingStateIsCompiled, getStateObject, _createShaderProgram, deleteStateObject, _isRenderingStateCompiled, } from \"./thinEngine.functions.js\";\nimport { IsWrapper } from \"../Materials/drawWrapper.functions.js\";\nimport { Logger } from \"../Misc/logger.js\";\nimport { IsWindowObjectExist } from \"../Misc/domManagement.js\";\nimport { WebGLShaderProcessor } from \"./WebGL/webGLShaderProcessors.js\";\nimport { WebGL2ShaderProcessor } from \"./WebGL/webGL2ShaderProcessors.js\";\nimport { WebGLDataBuffer } from \"../Meshes/WebGL/webGLDataBuffer.js\";\nimport { GetExponentOfTwo } from \"../Misc/tools.functions.js\";\nimport { AbstractEngine } from \"./abstractEngine.js\";\n\nimport { WebGLHardwareTexture } from \"./WebGL/webGLHardwareTexture.js\";\nimport { InternalTexture, IsDepthTexture, HasStencilAspect } from \"../Materials/Textures/internalTexture.js\";\nimport { Effect } from \"../Materials/effect.js\";\nimport { _ConcatenateShader, _getGlobalDefines } from \"./abstractEngine.functions.js\";\nimport { resetCachedPipeline } from \"../Materials/effect.functions.js\";\n/**\n * Keeps track of all the buffer info used in engine.\n */\nclass BufferPointer {\n}\n/**\n * The base engine class (root of all engines)\n */\nexport class ThinEngine extends AbstractEngine {\n /**\n * Gets or sets the name of the engine\n */\n get name() {\n return this._name;\n }\n set name(value) {\n this._name = value;\n }\n /**\n * Returns the version of the engine\n */\n get version() {\n return this._webGLVersion;\n }\n /**\n * Gets or sets the relative url used to load shaders if using the engine in non-minified mode\n */\n static get ShadersRepository() {\n return Effect.ShadersRepository;\n }\n static set ShadersRepository(value) {\n Effect.ShadersRepository = value;\n }\n /**\n * Gets a boolean indicating that the engine supports uniform buffers\n * @see https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets\n */\n get supportsUniformBuffers() {\n return this.webGLVersion > 1 && !this.disableUniformBuffers;\n }\n /**\n * Gets a boolean indicating that only power of 2 textures are supported\n * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them\n */\n get needPOTTextures() {\n return this._webGLVersion < 2 || this.forcePOTTextures;\n }\n get _supportsHardwareTextureRescaling() {\n return false;\n }\n /**\n * sets the object from which width and height will be taken from when getting render width and height\n * Will fallback to the gl object\n * @param dimensions the framebuffer width and height that will be used.\n */\n set framebufferDimensionsObject(dimensions) {\n this._framebufferDimensionsObject = dimensions;\n }\n /**\n * Creates a new snapshot at the next frame using the current snapshotRenderingMode\n */\n snapshotRenderingReset() {\n this.snapshotRendering = false;\n }\n /**\n * Creates a new engine\n * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which already used the WebGL context\n * @param antialias defines whether anti-aliasing should be enabled (default value is \"undefined\", meaning that the browser may or may not enable it)\n * @param options defines further options to be sent to the getContext() function\n * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)\n */\n constructor(canvasOrContext, antialias, options, adaptToDeviceRatio) {\n options = options || {};\n super(antialias ?? options.antialias, options, adaptToDeviceRatio);\n /** @internal */\n this._name = \"WebGL\";\n /**\n * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required\n */\n this.forcePOTTextures = false;\n /** Gets or sets a boolean indicating if the engine should validate programs after compilation */\n this.validateShaderPrograms = false;\n /**\n * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported\n */\n this.disableUniformBuffers = false;\n /** @internal */\n this._webGLVersion = 1.0;\n this._vertexAttribArraysEnabled = [];\n this._uintIndicesCurrentlySet = false;\n this._currentBoundBuffer = new Array();\n /** @internal */\n this._currentFramebuffer = null;\n /** @internal */\n this._dummyFramebuffer = null;\n this._currentBufferPointers = new Array();\n this._currentInstanceLocations = new Array();\n this._currentInstanceBuffers = new Array();\n this._vaoRecordInProgress = false;\n this._mustWipeVertexAttributes = false;\n this._nextFreeTextureSlots = new Array();\n this._maxSimultaneousTextures = 0;\n this._maxMSAASamplesOverride = null;\n this._unpackFlipYCached = null;\n /**\n * In case you are sharing the context with other applications, it might\n * be interested to not cache the unpack flip y state to ensure a consistent\n * value would be set.\n */\n this.enableUnpackFlipYCached = true;\n /**\n * @internal\n */\n this._boundUniforms = {};\n if (!canvasOrContext) {\n return;\n }\n let canvas = null;\n if (canvasOrContext.getContext) {\n canvas = canvasOrContext;\n this._renderingCanvas = canvas;\n if (options.preserveDrawingBuffer === undefined) {\n options.preserveDrawingBuffer = false;\n }\n if (options.xrCompatible === undefined) {\n options.xrCompatible = false;\n }\n // Exceptions\n if (navigator && navigator.userAgent) {\n this._setupMobileChecks();\n const ua = navigator.userAgent;\n for (const exception of ThinEngine.ExceptionList) {\n const key = exception.key;\n const targets = exception.targets;\n const check = new RegExp(key);\n if (check.test(ua)) {\n if (exception.capture && exception.captureConstraint) {\n const capture = exception.capture;\n const constraint = exception.captureConstraint;\n const regex = new RegExp(capture);\n const matches = regex.exec(ua);\n if (matches && matches.length > 0) {\n const capturedValue = parseInt(matches[matches.length - 1]);\n if (capturedValue >= constraint) {\n continue;\n }\n }\n }\n for (const target of targets) {\n switch (target) {\n case \"uniformBuffer\":\n this.disableUniformBuffers = true;\n break;\n case \"vao\":\n this.disableVertexArrayObjects = true;\n break;\n case \"antialias\":\n options.antialias = false;\n break;\n case \"maxMSAASamples\":\n this._maxMSAASamplesOverride = 1;\n break;\n }\n }\n }\n }\n }\n // Context lost\n if (!this._doNotHandleContextLost) {\n this._onContextLost = (evt) => {\n evt.preventDefault();\n this._contextWasLost = true;\n Logger.Warn(\"WebGL context lost.\");\n this.onContextLostObservable.notifyObservers(this);\n };\n this._onContextRestored = () => {\n this._restoreEngineAfterContextLost(() => this._initGLContext());\n };\n canvas.addEventListener(\"webglcontextlost\", this._onContextLost, false);\n canvas.addEventListener(\"webglcontextrestored\", this._onContextRestored, false);\n options.powerPreference = options.powerPreference || \"high-performance\";\n }\n if (this._badDesktopOS) {\n options.xrCompatible = false;\n }\n // GL\n if (!options.disableWebGL2Support) {\n try {\n this._gl = (canvas.getContext(\"webgl2\", options) || canvas.getContext(\"experimental-webgl2\", options));\n if (this._gl) {\n this._webGLVersion = 2.0;\n this._shaderPlatformName = \"WEBGL2\";\n // Prevent weird browsers to lie (yeah that happens!)\n if (!this._gl.deleteQuery) {\n this._webGLVersion = 1.0;\n this._shaderPlatformName = \"WEBGL1\";\n }\n }\n }\n catch (e) {\n // Do nothing\n }\n }\n if (!this._gl) {\n if (!canvas) {\n throw new Error(\"The provided canvas is null or undefined.\");\n }\n try {\n this._gl = (canvas.getContext(\"webgl\", options) || canvas.getContext(\"experimental-webgl\", options));\n }\n catch (e) {\n throw new Error(\"WebGL not supported\");\n }\n }\n if (!this._gl) {\n throw new Error(\"WebGL not supported\");\n }\n }\n else {\n this._gl = canvasOrContext;\n this._renderingCanvas = this._gl.canvas;\n if (this._gl.renderbufferStorageMultisample) {\n this._webGLVersion = 2.0;\n this._shaderPlatformName = \"WEBGL2\";\n }\n else {\n this._shaderPlatformName = \"WEBGL1\";\n }\n const attributes = this._gl.getContextAttributes();\n if (attributes) {\n options.stencil = attributes.stencil;\n }\n }\n // Ensures a consistent color space unpacking of textures cross browser.\n this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);\n if (options.useHighPrecisionFloats !== undefined) {\n this._highPrecisionShadersAllowed = options.useHighPrecisionFloats;\n }\n this.resize();\n this._initGLContext();\n this._initFeatures();\n // Prepare buffer pointers\n for (let i = 0; i < this._caps.maxVertexAttribs; i++) {\n this._currentBufferPointers[i] = new BufferPointer();\n }\n // Shader processor\n this._shaderProcessor = this.webGLVersion > 1 ? new WebGL2ShaderProcessor() : new WebGLShaderProcessor();\n // Starting with iOS 14, we can trust the browser\n // let matches = navigator.userAgent.match(/Version\\/(\\d+)/);\n // if (matches && matches.length === 2) {\n // if (parseInt(matches[1]) >= 14) {\n // this._badOS = false;\n // }\n // }\n const versionToLog = `Babylon.js v${ThinEngine.Version}`;\n Logger.Log(versionToLog + ` - ${this.description}`);\n // Check setAttribute in case of workers\n if (this._renderingCanvas && this._renderingCanvas.setAttribute) {\n this._renderingCanvas.setAttribute(\"data-engine\", versionToLog);\n }\n const stateObject = getStateObject(this._gl);\n // update state object with the current engine state\n stateObject.validateShaderPrograms = this.validateShaderPrograms;\n stateObject.parallelShaderCompile = this._caps.parallelShaderCompile;\n }\n _clearEmptyResources() {\n this._dummyFramebuffer = null;\n super._clearEmptyResources();\n }\n /**\n * @internal\n */\n _getShaderProcessingContext(shaderLanguage) {\n return null;\n }\n /**\n * Gets a boolean indicating if all created effects are ready\n * @returns true if all effects are ready\n */\n areAllEffectsReady() {\n for (const key in this._compiledEffects) {\n const effect = this._compiledEffects[key];\n if (!effect.isReady()) {\n return false;\n }\n }\n return true;\n }\n _initGLContext() {\n // Caps\n this._caps = {\n maxTexturesImageUnits: this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),\n maxCombinedTexturesImageUnits: this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),\n maxVertexTextureImageUnits: this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),\n maxTextureSize: this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),\n maxSamples: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_SAMPLES) : 1,\n maxCubemapTextureSize: this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),\n maxRenderTextureSize: this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),\n maxVertexAttribs: this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),\n maxVaryingVectors: this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),\n maxFragmentUniformVectors: this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),\n maxVertexUniformVectors: this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),\n parallelShaderCompile: this._gl.getExtension(\"KHR_parallel_shader_compile\") || undefined,\n standardDerivatives: this._webGLVersion > 1 || this._gl.getExtension(\"OES_standard_derivatives\") !== null,\n maxAnisotropy: 1,\n astc: this._gl.getExtension(\"WEBGL_compressed_texture_astc\") || this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_astc\"),\n bptc: this._gl.getExtension(\"EXT_texture_compression_bptc\") || this._gl.getExtension(\"WEBKIT_EXT_texture_compression_bptc\"),\n s3tc: this._gl.getExtension(\"WEBGL_compressed_texture_s3tc\") || this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_s3tc\"),\n // eslint-disable-next-line @typescript-eslint/naming-convention\n s3tc_srgb: this._gl.getExtension(\"WEBGL_compressed_texture_s3tc_srgb\") || this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_s3tc_srgb\"),\n pvrtc: this._gl.getExtension(\"WEBGL_compressed_texture_pvrtc\") || this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_pvrtc\"),\n etc1: this._gl.getExtension(\"WEBGL_compressed_texture_etc1\") || this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_etc1\"),\n etc2: this._gl.getExtension(\"WEBGL_compressed_texture_etc\") ||\n this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_etc\") ||\n this._gl.getExtension(\"WEBGL_compressed_texture_es3_0\"), // also a requirement of OpenGL ES 3\n textureAnisotropicFilterExtension: this._gl.getExtension(\"EXT_texture_filter_anisotropic\") ||\n this._gl.getExtension(\"WEBKIT_EXT_texture_filter_anisotropic\") ||\n this._gl.getExtension(\"MOZ_EXT_texture_filter_anisotropic\"),\n uintIndices: this._webGLVersion > 1 || this._gl.getExtension(\"OES_element_index_uint\") !== null,\n fragmentDepthSupported: this._webGLVersion > 1 || this._gl.getExtension(\"EXT_frag_depth\") !== null,\n highPrecisionShaderSupported: false,\n timerQuery: this._gl.getExtension(\"EXT_disjoint_timer_query_webgl2\") || this._gl.getExtension(\"EXT_disjoint_timer_query\"),\n supportOcclusionQuery: this._webGLVersion > 1,\n canUseTimestampForTimerQuery: false,\n drawBuffersExtension: false,\n maxMSAASamples: 1,\n colorBufferFloat: !!(this._webGLVersion > 1 && this._gl.getExtension(\"EXT_color_buffer_float\")),\n supportFloatTexturesResolve: false,\n rg11b10ufColorRenderable: false,\n colorBufferHalfFloat: !!(this._webGLVersion > 1 && this._gl.getExtension(\"EXT_color_buffer_half_float\")),\n textureFloat: this._webGLVersion > 1 || this._gl.getExtension(\"OES_texture_float\") ? true : false,\n textureHalfFloat: this._webGLVersion > 1 || this._gl.getExtension(\"OES_texture_half_float\") ? true : false,\n textureHalfFloatRender: false,\n textureFloatLinearFiltering: false,\n textureFloatRender: false,\n textureHalfFloatLinearFiltering: false,\n vertexArrayObject: false,\n instancedArrays: false,\n textureLOD: this._webGLVersion > 1 || this._gl.getExtension(\"EXT_shader_texture_lod\") ? true : false,\n texelFetch: this._webGLVersion !== 1,\n blendMinMax: false,\n multiview: this._gl.getExtension(\"OVR_multiview2\"),\n oculusMultiview: this._gl.getExtension(\"OCULUS_multiview\"),\n depthTextureExtension: false,\n canUseGLInstanceID: this._webGLVersion > 1,\n canUseGLVertexID: this._webGLVersion > 1,\n supportComputeShaders: false,\n supportSRGBBuffers: false,\n supportTransformFeedbacks: this._webGLVersion > 1,\n textureMaxLevel: this._webGLVersion > 1,\n texture2DArrayMaxLayerCount: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_ARRAY_TEXTURE_LAYERS) : 128,\n disableMorphTargetTexture: false,\n textureNorm16: this._gl.getExtension(\"EXT_texture_norm16\") ? true : false,\n };\n this._caps.supportFloatTexturesResolve = this._caps.colorBufferFloat;\n this._caps.rg11b10ufColorRenderable = this._caps.colorBufferFloat;\n // Infos\n this._glVersion = this._gl.getParameter(this._gl.VERSION);\n const rendererInfo = this._gl.getExtension(\"WEBGL_debug_renderer_info\");\n if (rendererInfo != null) {\n this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);\n this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);\n }\n if (!this._glVendor) {\n this._glVendor = this._gl.getParameter(this._gl.VENDOR) || \"Unknown vendor\";\n }\n if (!this._glRenderer) {\n this._glRenderer = this._gl.getParameter(this._gl.RENDERER) || \"Unknown renderer\";\n }\n // Constants\n if (this._gl.HALF_FLOAT_OES !== 0x8d61) {\n this._gl.HALF_FLOAT_OES = 0x8d61; // Half floating-point type (16-bit).\n }\n if (this._gl.RGBA16F !== 0x881a) {\n this._gl.RGBA16F = 0x881a; // RGBA 16-bit floating-point color-renderable internal sized format.\n }\n if (this._gl.RGBA32F !== 0x8814) {\n this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.\n }\n if (this._gl.DEPTH24_STENCIL8 !== 35056) {\n this._gl.DEPTH24_STENCIL8 = 35056;\n }\n // Extensions\n if (this._caps.timerQuery) {\n if (this._webGLVersion === 1) {\n this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);\n }\n // WebGLQuery casted to number to avoid TS error\n this._caps.canUseTimestampForTimerQuery = (this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) ?? 0) > 0;\n }\n this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension\n ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT)\n : 0;\n this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension(\"OES_texture_float_linear\") ? true : false;\n this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;\n this._caps.textureHalfFloatLinearFiltering =\n this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension(\"OES_texture_half_float_linear\")) ? true : false;\n if (this._caps.textureNorm16) {\n this._gl.R16_EXT = 0x822a;\n this._gl.RG16_EXT = 0x822c;\n this._gl.RGB16_EXT = 0x8054;\n this._gl.RGBA16_EXT = 0x805b;\n this._gl.R16_SNORM_EXT = 0x8f98;\n this._gl.RG16_SNORM_EXT = 0x8f99;\n this._gl.RGB16_SNORM_EXT = 0x8f9a;\n this._gl.RGBA16_SNORM_EXT = 0x8f9b;\n }\n // Compressed formats\n if (this._caps.astc) {\n this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;\n }\n if (this._caps.bptc) {\n this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;\n }\n if (this._caps.s3tc_srgb) {\n this._gl.COMPRESSED_SRGB_S3TC_DXT1_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_S3TC_DXT1_EXT;\n this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;\n this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;\n }\n if (this._caps.etc2) {\n this._gl.COMPRESSED_SRGB8_ETC2 = this._caps.etc2.COMPRESSED_SRGB8_ETC2;\n this._gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = this._caps.etc2.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;\n }\n // Checks if some of the format renders first to allow the use of webgl inspector.\n if (this._webGLVersion > 1) {\n if (this._gl.HALF_FLOAT_OES !== 0x140b) {\n this._gl.HALF_FLOAT_OES = 0x140b;\n }\n }\n this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();\n // Draw buffers\n if (this._webGLVersion > 1) {\n this._caps.drawBuffersExtension = true;\n this._caps.maxMSAASamples = this._maxMSAASamplesOverride !== null ? this._maxMSAASamplesOverride : this._gl.getParameter(this._gl.MAX_SAMPLES);\n this._caps.maxDrawBuffers = this._gl.getParameter(this._gl.MAX_DRAW_BUFFERS);\n }\n else {\n const drawBuffersExtension = this._gl.getExtension(\"WEBGL_draw_buffers\");\n if (drawBuffersExtension !== null) {\n this._caps.drawBuffersExtension = true;\n this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);\n this._caps.maxDrawBuffers = this._gl.getParameter(drawBuffersExtension.MAX_DRAW_BUFFERS_WEBGL);\n this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;\n for (let i = 0; i < 16; i++) {\n this._gl[\"COLOR_ATTACHMENT\" + i + \"_WEBGL\"] = drawBuffersExtension[\"COLOR_ATTACHMENT\" + i + \"_WEBGL\"];\n }\n }\n }\n // Depth Texture\n if (this._webGLVersion > 1) {\n this._caps.depthTextureExtension = true;\n }\n else {\n const depthTextureExtension = this._gl.getExtension(\"WEBGL_depth_texture\");\n if (depthTextureExtension != null) {\n this._caps.depthTextureExtension = true;\n this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;\n }\n }\n // Vertex array object\n if (this.disableVertexArrayObjects) {\n this._caps.vertexArrayObject = false;\n }\n else if (this._webGLVersion > 1) {\n this._caps.vertexArrayObject = true;\n }\n else {\n const vertexArrayObjectExtension = this._gl.getExtension(\"OES_vertex_array_object\");\n if (vertexArrayObjectExtension != null) {\n this._caps.vertexArrayObject = true;\n this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);\n this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);\n this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);\n }\n }\n // Instances count\n if (this._webGLVersion > 1) {\n this._caps.instancedArrays = true;\n }\n else {\n const instanceExtension = this._gl.getExtension(\"ANGLE_instanced_arrays\");\n if (instanceExtension != null) {\n this._caps.instancedArrays = true;\n this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);\n this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);\n this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);\n }\n else {\n this._caps.instancedArrays = false;\n }\n }\n if (this._gl.getShaderPrecisionFormat) {\n const vertexhighp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);\n const fragmenthighp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);\n if (vertexhighp && fragmenthighp) {\n this._caps.highPrecisionShaderSupported = vertexhighp.precision !== 0 && fragmenthighp.precision !== 0;\n }\n }\n if (this._webGLVersion > 1) {\n this._caps.blendMinMax = true;\n }\n else {\n const blendMinMaxExtension = this._gl.getExtension(\"EXT_blend_minmax\");\n if (blendMinMaxExtension != null) {\n this._caps.blendMinMax = true;\n this._gl.MAX = blendMinMaxExtension.MAX_EXT;\n this._gl.MIN = blendMinMaxExtension.MIN_EXT;\n }\n }\n // sRGB buffers\n // only run this if not already set to true (in the constructor, for example)\n if (!this._caps.supportSRGBBuffers) {\n if (this._webGLVersion > 1) {\n this._caps.supportSRGBBuffers = true;\n this._glSRGBExtensionValues = {\n SRGB: WebGL2RenderingContext.SRGB,\n SRGB8: WebGL2RenderingContext.SRGB8,\n SRGB8_ALPHA8: WebGL2RenderingContext.SRGB8_ALPHA8,\n };\n }\n else {\n const sRGBExtension = this._gl.getExtension(\"EXT_sRGB\");\n if (sRGBExtension != null) {\n this._caps.supportSRGBBuffers = true;\n this._glSRGBExtensionValues = {\n SRGB: sRGBExtension.SRGB_EXT,\n SRGB8: sRGBExtension.SRGB_ALPHA_EXT,\n SRGB8_ALPHA8: sRGBExtension.SRGB_ALPHA_EXT,\n };\n }\n }\n // take into account the forced state that was provided in options\n if (this._creationOptions) {\n const forceSRGBBufferSupportState = this._creationOptions.forceSRGBBufferSupportState;\n if (forceSRGBBufferSupportState !== undefined) {\n this._caps.supportSRGBBuffers = this._caps.supportSRGBBuffers && forceSRGBBufferSupportState;\n }\n }\n }\n // Depth buffer\n this._depthCullingState.depthTest = true;\n this._depthCullingState.depthFunc = this._gl.LEQUAL;\n this._depthCullingState.depthMask = true;\n // Texture maps\n this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;\n for (let slot = 0; slot < this._maxSimultaneousTextures; slot++) {\n this._nextFreeTextureSlots.push(slot);\n }\n if (this._glRenderer === \"Mali-G72\") {\n // Overcome a bug when using a texture to store morph targets on Mali-G72\n this._caps.disableMorphTargetTexture = true;\n }\n }\n _initFeatures() {\n this._features = {\n forceBitmapOverHTMLImageElement: typeof HTMLImageElement === \"undefined\",\n supportRenderAndCopyToLodForFloatTextures: this._webGLVersion !== 1,\n supportDepthStencilTexture: this._webGLVersion !== 1,\n supportShadowSamplers: this._webGLVersion !== 1,\n uniformBufferHardCheckMatrix: false,\n allowTexturePrefiltering: this._webGLVersion !== 1,\n trackUbosInFrame: false,\n checkUbosContentBeforeUpload: false,\n supportCSM: this._webGLVersion !== 1,\n basisNeedsPOT: this._webGLVersion === 1,\n support3DTextures: this._webGLVersion !== 1,\n needTypeSuffixInShaderConstants: this._webGLVersion !== 1,\n supportMSAA: this._webGLVersion !== 1,\n supportSSAO2: this._webGLVersion !== 1,\n supportIBLShadows: this._webGLVersion !== 1,\n supportExtendedTextureFormats: this._webGLVersion !== 1,\n supportSwitchCaseInShader: this._webGLVersion !== 1,\n supportSyncTextureRead: true,\n needsInvertingBitmap: true,\n useUBOBindingCache: true,\n needShaderCodeInlining: false,\n needToAlwaysBindUniformBuffers: false,\n supportRenderPasses: false,\n supportSpriteInstancing: true,\n forceVertexBufferStrideAndOffsetMultiple4Bytes: false,\n _checkNonFloatVertexBuffersDontRecreatePipelineContext: false,\n _collectUbosUpdatedInFrame: false,\n };\n }\n /**\n * Gets version of the current webGL context\n * Keep it for back compat - use version instead\n */\n get webGLVersion() {\n return this._webGLVersion;\n }\n /**\n * Gets a string identifying the name of the class\n * @returns \"Engine\" string\n */\n getClassName() {\n return \"ThinEngine\";\n }\n /** @internal */\n _prepareWorkingCanvas() {\n if (this._workingCanvas) {\n return;\n }\n this._workingCanvas = this.createCanvas(1, 1);\n const context = this._workingCanvas.getContext(\"2d\");\n if (context) {\n this._workingContext = context;\n }\n }\n /**\n * Gets an object containing information about the current engine context\n * @returns an object containing the vendor, the renderer and the version of the current engine context\n */\n getInfo() {\n return this.getGlInfo();\n }\n /**\n * Gets an object containing information about the current webGL context\n * @returns an object containing the vendor, the renderer and the version of the current webGL context\n */\n getGlInfo() {\n return {\n vendor: this._glVendor,\n renderer: this._glRenderer,\n version: this._glVersion,\n };\n }\n /**Gets driver info if available */\n extractDriverInfo() {\n const glInfo = this.getGlInfo();\n if (glInfo && glInfo.renderer) {\n return glInfo.renderer;\n }\n return \"\";\n }\n /**\n * Gets the current render width\n * @param useScreen defines if screen size must be used (or the current render target if any)\n * @returns a number defining the current render width\n */\n getRenderWidth(useScreen = false) {\n if (!useScreen && this._currentRenderTarget) {\n return this._currentRenderTarget.width;\n }\n return this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferWidth : this._gl.drawingBufferWidth;\n }\n /**\n * Gets the current render height\n * @param useScreen defines if screen size must be used (or the current render target if any)\n * @returns a number defining the current render height\n */\n getRenderHeight(useScreen = false) {\n if (!useScreen && this._currentRenderTarget) {\n return this._currentRenderTarget.height;\n }\n return this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferHeight : this._gl.drawingBufferHeight;\n }\n /**\n * Clear the current render buffer or the current render target (if any is set up)\n * @param color defines the color to use\n * @param backBuffer defines if the back buffer must be cleared\n * @param depth defines if the depth buffer must be cleared\n * @param stencil defines if the stencil buffer must be cleared\n */\n clear(color, backBuffer, depth, stencil = false) {\n const useStencilGlobalOnly = this.stencilStateComposer.useStencilGlobalOnly;\n this.stencilStateComposer.useStencilGlobalOnly = true; // make sure the stencil mask is coming from the global stencil and not from a material (effect) which would currently be in effect\n this.applyStates();\n this.stencilStateComposer.useStencilGlobalOnly = useStencilGlobalOnly;\n let mode = 0;\n if (backBuffer && color) {\n let setBackBufferColor = true;\n if (this._currentRenderTarget) {\n const textureFormat = this._currentRenderTarget.texture?.format;\n if (textureFormat === 8 ||\n textureFormat === 9 ||\n textureFormat === 10 ||\n textureFormat === 11) {\n const textureType = this._currentRenderTarget.texture?.type;\n if (textureType === 7 || textureType === 5) {\n ThinEngine._TempClearColorUint32[0] = color.r * 255;\n ThinEngine._TempClearColorUint32[1] = color.g * 255;\n ThinEngine._TempClearColorUint32[2] = color.b * 255;\n ThinEngine._TempClearColorUint32[3] = color.a * 255;\n this._gl.clearBufferuiv(this._gl.COLOR, 0, ThinEngine._TempClearColorUint32);\n setBackBufferColor = false;\n }\n else {\n ThinEngine._TempClearColorInt32[0] = color.r * 255;\n ThinEngine._TempClearColorInt32[1] = color.g * 255;\n ThinEngine._TempClearColorInt32[2] = color.b * 255;\n ThinEngine._TempClearColorInt32[3] = color.a * 255;\n this._gl.clearBufferiv(this._gl.COLOR, 0, ThinEngine._TempClearColorInt32);\n setBackBufferColor = false;\n }\n }\n }\n if (setBackBufferColor) {\n this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);\n mode |= this._gl.COLOR_BUFFER_BIT;\n }\n }\n if (depth) {\n if (this.useReverseDepthBuffer) {\n this._depthCullingState.depthFunc = this._gl.GEQUAL;\n this._gl.clearDepth(0.0);\n }\n else {\n this._gl.clearDepth(1.0);\n }\n mode |= this._gl.DEPTH_BUFFER_BIT;\n }\n if (stencil) {\n this._gl.clearStencil(0);\n mode |= this._gl.STENCIL_BUFFER_BIT;\n }\n this._gl.clear(mode);\n }\n /**\n * @internal\n */\n _viewport(x, y, width, height) {\n if (x !== this._viewportCached.x || y !== this._viewportCached.y || width !== this._viewportCached.z || height !== this._viewportCached.w) {\n this._viewportCached.x = x;\n this._viewportCached.y = y;\n this._viewportCached.z = width;\n this._viewportCached.w = height;\n this._gl.viewport(x, y, width, height);\n }\n }\n /**\n * End the current frame\n */\n endFrame() {\n super.endFrame();\n // Force a flush in case we are using a bad OS.\n if (this._badOS) {\n this.flushFramebuffer();\n }\n }\n /**\n * Gets the performance monitor attached to this engine\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#engineinstrumentation\n */\n get performanceMonitor() {\n throw new Error(\"Not Supported by ThinEngine\");\n }\n /**\n * Binds the frame buffer to the specified texture.\n * @param rtWrapper The render target wrapper to render to\n * @param faceIndex The face of the texture to render to in case of cube texture and if the render target wrapper is not a multi render target\n * @param requiredWidth The width of the target to render to\n * @param requiredHeight The height of the target to render to\n * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true\n * @param lodLevel Defines the lod level to bind to the frame buffer\n * @param layer Defines the 2d array index to bind to the frame buffer if the render target wrapper is not a multi render target\n */\n bindFramebuffer(rtWrapper, faceIndex = 0, requiredWidth, requiredHeight, forceFullscreenViewport, lodLevel = 0, layer = 0) {\n const webglRTWrapper = rtWrapper;\n if (this._currentRenderTarget) {\n this.unBindFramebuffer(this._currentRenderTarget);\n }\n this._currentRenderTarget = rtWrapper;\n this._bindUnboundFramebuffer(webglRTWrapper._framebuffer);\n const gl = this._gl;\n if (!rtWrapper.isMulti) {\n if (rtWrapper.is2DArray || rtWrapper.is3D) {\n gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, rtWrapper.texture._hardwareTexture?.underlyingResource, lodLevel, layer);\n webglRTWrapper._currentLOD = lodLevel;\n }\n else if (rtWrapper.isCube) {\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, rtWrapper.texture._hardwareTexture?.underlyingResource, lodLevel);\n }\n else if (webglRTWrapper._currentLOD !== lodLevel) {\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, rtWrapper.texture._hardwareTexture?.underlyingResource, lodLevel);\n webglRTWrapper._currentLOD = lodLevel;\n }\n }\n const depthStencilTexture = rtWrapper._depthStencilTexture;\n if (depthStencilTexture) {\n if (rtWrapper.is3D) {\n if (rtWrapper.texture.width !== depthStencilTexture.width ||\n rtWrapper.texture.height !== depthStencilTexture.height ||\n rtWrapper.texture.depth !== depthStencilTexture.depth) {\n Logger.Warn(\"Depth/Stencil attachment for 3D target must have same dimensions as color attachment\");\n }\n }\n const attachment = rtWrapper._depthStencilTextureWithStencil ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;\n if (rtWrapper.is2DArray || rtWrapper.is3D) {\n gl.framebufferTextureLayer(gl.FRAMEBUFFER, attachment, depthStencilTexture._hardwareTexture?.underlyingResource, lodLevel, layer);\n }\n else if (rtWrapper.isCube) {\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._hardwareTexture?.underlyingResource, lodLevel);\n }\n else {\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, depthStencilTexture._hardwareTexture?.underlyingResource, lodLevel);\n }\n }\n if (webglRTWrapper._MSAAFramebuffer) {\n this._bindUnboundFramebuffer(webglRTWrapper._MSAAFramebuffer);\n }\n if (this._cachedViewport && !forceFullscreenViewport) {\n this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);\n }\n else {\n if (!requiredWidth) {\n requiredWidth = rtWrapper.width;\n if (lodLevel) {\n requiredWidth = requiredWidth / Math.pow(2, lodLevel);\n }\n }\n if (!requiredHeight) {\n requiredHeight = rtWrapper.height;\n if (lodLevel) {\n requiredHeight = requiredHeight / Math.pow(2, lodLevel);\n }\n }\n this._viewport(0, 0, requiredWidth, requiredHeight);\n }\n this.wipeCaches();\n }\n /**\n * Set various states to the webGL context\n * @param culling defines culling state: true to enable culling, false to disable it\n * @param zOffset defines the value to apply to zOffset (0 by default)\n * @param force defines if states must be applied even if cache is up to date\n * @param reverseSide defines if culling must be reversed (CCW if false, CW if true)\n * @param cullBackFaces true to cull back faces, false to cull front faces (if culling is enabled)\n * @param stencil stencil states to set\n * @param zOffsetUnits defines the value to apply to zOffsetUnits (0 by default)\n */\n setState(culling, zOffset = 0, force, reverseSide = false, cullBackFaces, stencil, zOffsetUnits = 0) {\n // Culling\n if (this._depthCullingState.cull !== culling || force) {\n this._depthCullingState.cull = culling;\n }\n // Cull face\n const cullFace = (this.cullBackFaces ?? cullBackFaces ?? true) ? this._gl.BACK : this._gl.FRONT;\n if (this._depthCullingState.cullFace !== cullFace || force) {\n this._depthCullingState.cullFace = cullFace;\n }\n // Z offset\n this.setZOffset(zOffset);\n this.setZOffsetUnits(zOffsetUnits);\n // Front face\n const frontFace = reverseSide ? this._gl.CW : this._gl.CCW;\n if (this._depthCullingState.frontFace !== frontFace || force) {\n this._depthCullingState.frontFace = frontFace;\n }\n this._stencilStateComposer.stencilMaterial = stencil;\n }\n /**\n * @internal\n */\n _bindUnboundFramebuffer(framebuffer) {\n if (this._currentFramebuffer !== framebuffer) {\n this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);\n this._currentFramebuffer = framebuffer;\n }\n }\n /** @internal */\n _currentFrameBufferIsDefaultFrameBuffer() {\n return this._currentFramebuffer === null;\n }\n /**\n * Generates the mipmaps for a texture\n * @param texture texture to generate the mipmaps for\n */\n generateMipmaps(texture) {\n const target = this._getTextureTarget(texture);\n this._bindTextureDirectly(target, texture, true);\n this._gl.generateMipmap(target);\n this._bindTextureDirectly(target, null);\n }\n /**\n * Unbind the current render target texture from the webGL context\n * @param texture defines the render target wrapper to unbind\n * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated\n * @param onBeforeUnbind defines a function which will be called before the effective unbind\n */\n unBindFramebuffer(texture, disableGenerateMipMaps = false, onBeforeUnbind) {\n const webglRTWrapper = texture;\n this._currentRenderTarget = null;\n if (!webglRTWrapper.disableAutomaticMSAAResolve) {\n if (texture.isMulti) {\n this.resolveMultiFramebuffer(texture);\n }\n else {\n this.resolveFramebuffer(texture);\n }\n }\n if (!disableGenerateMipMaps) {\n if (texture.isMulti) {\n this.generateMipMapsMultiFramebuffer(texture);\n }\n else {\n this.generateMipMapsFramebuffer(texture);\n }\n }\n if (onBeforeUnbind) {\n if (webglRTWrapper._MSAAFramebuffer) {\n // Bind the correct framebuffer\n this._bindUnboundFramebuffer(webglRTWrapper._framebuffer);\n }\n onBeforeUnbind();\n }\n this._bindUnboundFramebuffer(null);\n }\n /**\n * Generates mipmaps for the texture of the (single) render target\n * @param texture The render target containing the texture to generate the mipmaps for\n */\n generateMipMapsFramebuffer(texture) {\n if (!texture.isMulti && texture.texture?.generateMipMaps && !texture.isCube) {\n this.generateMipmaps(texture.texture);\n }\n }\n /**\n * Resolves the MSAA texture of the (single) render target into its non-MSAA version.\n * Note that if \"texture\" is not a MSAA render target, no resolve is performed.\n * @param texture The render target texture containing the MSAA textures to resolve\n */\n resolveFramebuffer(texture) {\n const rtWrapper = texture;\n const gl = this._gl;\n if (!rtWrapper._MSAAFramebuffer || rtWrapper.isMulti) {\n return;\n }\n let bufferBits = rtWrapper.resolveMSAAColors ? gl.COLOR_BUFFER_BIT : 0;\n bufferBits |= rtWrapper._generateDepthBuffer && rtWrapper.resolveMSAADepth ? gl.DEPTH_BUFFER_BIT : 0;\n bufferBits |= rtWrapper._generateStencilBuffer && rtWrapper.resolveMSAAStencil ? gl.STENCIL_BUFFER_BIT : 0;\n gl.bindFramebuffer(gl.READ_FRAMEBUFFER, rtWrapper._MSAAFramebuffer);\n gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, rtWrapper._framebuffer);\n gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, bufferBits, gl.NEAREST);\n }\n /**\n * Force a webGL flush (ie. a flush of all waiting webGL commands)\n */\n flushFramebuffer() {\n this._gl.flush();\n }\n /**\n * Unbind the current render target and bind the default framebuffer\n */\n restoreDefaultFramebuffer() {\n if (this._currentRenderTarget) {\n this.unBindFramebuffer(this._currentRenderTarget);\n }\n else {\n this._bindUnboundFramebuffer(null);\n }\n if (this._cachedViewport) {\n this.setViewport(this._cachedViewport);\n }\n this.wipeCaches();\n }\n // VBOs\n /** @internal */\n _resetVertexBufferBinding() {\n this.bindArrayBuffer(null);\n this._cachedVertexBuffers = null;\n }\n /**\n * Creates a vertex buffer\n * @param data the data or size for the vertex buffer\n * @param _updatable whether the buffer should be created as updatable\n * @param _label defines the label of the buffer (for debug purpose)\n * @returns the new WebGL static buffer\n */\n createVertexBuffer(data, _updatable, _label) {\n return this._createVertexBuffer(data, this._gl.STATIC_DRAW);\n }\n _createVertexBuffer(data, usage) {\n const vbo = this._gl.createBuffer();\n if (!vbo) {\n throw new Error(\"Unable to create vertex buffer\");\n }\n const dataBuffer = new WebGLDataBuffer(vbo);\n this.bindArrayBuffer(dataBuffer);\n if (typeof data !== \"number\") {\n if (data instanceof Array) {\n this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), usage);\n dataBuffer.capacity = data.length * 4;\n }\n else {\n this._gl.bufferData(this._gl.ARRAY_BUFFER, data, usage);\n dataBuffer.capacity = data.byteLength;\n }\n }\n else {\n this._gl.bufferData(this._gl.ARRAY_BUFFER, new Uint8Array(data), usage);\n dataBuffer.capacity = data;\n }\n this._resetVertexBufferBinding();\n dataBuffer.references = 1;\n return dataBuffer;\n }\n /**\n * Creates a dynamic vertex buffer\n * @param data the data for the dynamic vertex buffer\n * @param _label defines the label of the buffer (for debug purpose)\n * @returns the new WebGL dynamic buffer\n */\n createDynamicVertexBuffer(data, _label) {\n return this._createVertexBuffer(data, this._gl.DYNAMIC_DRAW);\n }\n _resetIndexBufferBinding() {\n this.bindIndexBuffer(null);\n this._cachedIndexBuffer = null;\n }\n /**\n * Creates a new index buffer\n * @param indices defines the content of the index buffer\n * @param updatable defines if the index buffer must be updatable\n * @param _label defines the label of the buffer (for debug purpose)\n * @returns a new webGL buffer\n */\n createIndexBuffer(indices, updatable, _label) {\n const vbo = this._gl.createBuffer();\n const dataBuffer = new WebGLDataBuffer(vbo);\n if (!vbo) {\n throw new Error(\"Unable to create index buffer\");\n }\n this.bindIndexBuffer(dataBuffer);\n const data = this._normalizeIndexData(indices);\n this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, data, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);\n this._resetIndexBufferBinding();\n dataBuffer.references = 1;\n dataBuffer.is32Bits = data.BYTES_PER_ELEMENT === 4;\n return dataBuffer;\n }\n _normalizeIndexData(indices) {\n const bytesPerElement = indices.BYTES_PER_ELEMENT;\n if (bytesPerElement === 2) {\n return indices;\n }\n // Check 32 bit support\n if (this._caps.uintIndices) {\n if (indices instanceof Uint32Array) {\n return indices;\n }\n else {\n // number[] or Int32Array, check if 32 bit is necessary\n for (let index = 0; index < indices.length; index++) {\n if (indices[index] >= 65535) {\n return new Uint32Array(indices);\n }\n }\n return new Uint16Array(indices);\n }\n }\n // No 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)\n return new Uint16Array(indices);\n }\n /**\n * Bind a webGL buffer to the webGL context\n * @param buffer defines the buffer to bind\n */\n bindArrayBuffer(buffer) {\n if (!this._vaoRecordInProgress) {\n this._unbindVertexArrayObject();\n }\n this._bindBuffer(buffer, this._gl.ARRAY_BUFFER);\n }\n /**\n * Bind a specific block at a given index in a specific shader program\n * @param pipelineContext defines the pipeline context to use\n * @param blockName defines the block name\n * @param index defines the index where to bind the block\n */\n bindUniformBlock(pipelineContext, blockName, index) {\n const program = pipelineContext.program;\n const uniformLocation = this._gl.getUniformBlockIndex(program, blockName);\n this._gl.uniformBlockBinding(program, uniformLocation, index);\n }\n // eslint-disable-next-line @typescript-eslint/naming-convention\n bindIndexBuffer(buffer) {\n if (!this._vaoRecordInProgress) {\n this._unbindVertexArrayObject();\n }\n this._bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);\n }\n _bindBuffer(buffer, target) {\n if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {\n this._gl.bindBuffer(target, buffer ? buffer.underlyingResource : null);\n this._currentBoundBuffer[target] = buffer;\n }\n }\n /**\n * update the bound buffer with the given data\n * @param data defines the data to update\n */\n updateArrayBuffer(data) {\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);\n }\n _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset) {\n const pointer = this._currentBufferPointers[indx];\n if (!pointer) {\n return;\n }\n let changed = false;\n if (!pointer.active) {\n changed = true;\n pointer.active = true;\n pointer.index = indx;\n pointer.size = size;\n pointer.type = type;\n pointer.normalized = normalized;\n pointer.stride = stride;\n pointer.offset = offset;\n pointer.buffer = buffer;\n }\n else {\n if (pointer.buffer !== buffer) {\n pointer.buffer = buffer;\n changed = true;\n }\n if (pointer.size !== size) {\n pointer.size = size;\n changed = true;\n }\n if (pointer.type !== type) {\n pointer.type = type;\n changed = true;\n }\n if (pointer.normalized !== normalized) {\n pointer.normalized = normalized;\n changed = true;\n }\n if (pointer.stride !== stride) {\n pointer.stride = stride;\n changed = true;\n }\n if (pointer.offset !== offset) {\n pointer.offset = offset;\n changed = true;\n }\n }\n if (changed || this._vaoRecordInProgress) {\n this.bindArrayBuffer(buffer);\n if (type === this._gl.UNSIGNED_INT || type === this._gl.INT) {\n this._gl.vertexAttribIPointer(indx, size, type, stride, offset);\n }\n else {\n this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);\n }\n }\n }\n /**\n * @internal\n */\n _bindIndexBufferWithCache(indexBuffer) {\n if (indexBuffer == null) {\n return;\n }\n if (this._cachedIndexBuffer !== indexBuffer) {\n this._cachedIndexBuffer = indexBuffer;\n this.bindIndexBuffer(indexBuffer);\n this._uintIndicesCurrentlySet = indexBuffer.is32Bits;\n }\n }\n _bindVertexBuffersAttributes(vertexBuffers, effect, overrideVertexBuffers) {\n const attributes = effect.getAttributesNames();\n if (!this._vaoRecordInProgress) {\n this._unbindVertexArrayObject();\n }\n this.unbindAllAttributes();\n for (let index = 0; index < attributes.length; index++) {\n const order = effect.getAttributeLocation(index);\n if (order >= 0) {\n const ai = attributes[index];\n let vertexBuffer = null;\n if (overrideVertexBuffers) {\n vertexBuffer = overrideVertexBuffers[ai];\n }\n if (!vertexBuffer) {\n vertexBuffer = vertexBuffers[ai];\n }\n if (!vertexBuffer) {\n continue;\n }\n this._gl.enableVertexAttribArray(order);\n if (!this._vaoRecordInProgress) {\n this._vertexAttribArraysEnabled[order] = true;\n }\n const buffer = vertexBuffer.getBuffer();\n if (buffer) {\n this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);\n if (vertexBuffer.getIsInstanced()) {\n this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());\n if (!this._vaoRecordInProgress) {\n this._currentInstanceLocations.push(order);\n this._currentInstanceBuffers.push(buffer);\n }\n }\n }\n }\n }\n }\n /**\n * Records a vertex array object\n * @see https://doc.babylonjs.com/setup/support/webGL2#vertex-array-objects\n * @param vertexBuffers defines the list of vertex buffers to store\n * @param indexBuffer defines the index buffer to store\n * @param effect defines the effect to store\n * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers\n * @returns the new vertex array object\n */\n recordVertexArrayObject(vertexBuffers, indexBuffer, effect, overrideVertexBuffers) {\n const vao = this._gl.createVertexArray();\n if (!vao) {\n throw new Error(\"Unable to create VAO\");\n }\n this._vaoRecordInProgress = true;\n this._gl.bindVertexArray(vao);\n this._mustWipeVertexAttributes = true;\n this._bindVertexBuffersAttributes(vertexBuffers, effect, overrideVertexBuffers);\n this.bindIndexBuffer(indexBuffer);\n this._vaoRecordInProgress = false;\n this._gl.bindVertexArray(null);\n return vao;\n }\n /**\n * Bind a specific vertex array object\n * @see https://doc.babylonjs.com/setup/support/webGL2#vertex-array-objects\n * @param vertexArrayObject defines the vertex array object to bind\n * @param indexBuffer defines the index buffer to bind\n */\n bindVertexArrayObject(vertexArrayObject, indexBuffer) {\n if (this._cachedVertexArrayObject !== vertexArrayObject) {\n this._cachedVertexArrayObject = vertexArrayObject;\n this._gl.bindVertexArray(vertexArrayObject);\n this._cachedVertexBuffers = null;\n this._cachedIndexBuffer = null;\n this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;\n this._mustWipeVertexAttributes = true;\n }\n }\n /**\n * Bind webGl buffers directly to the webGL context\n * @param vertexBuffer defines the vertex buffer to bind\n * @param indexBuffer defines the index buffer to bind\n * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer\n * @param vertexStrideSize defines the vertex stride of the vertex buffer\n * @param effect defines the effect associated with the vertex buffer\n */\n bindBuffersDirectly(vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {\n if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {\n this._cachedVertexBuffers = vertexBuffer;\n this._cachedEffectForVertexBuffers = effect;\n const attributesCount = effect.getAttributesCount();\n this._unbindVertexArrayObject();\n this.unbindAllAttributes();\n let offset = 0;\n for (let index = 0; index < attributesCount; index++) {\n if (index < vertexDeclaration.length) {\n const order = effect.getAttributeLocation(index);\n if (order >= 0) {\n this._gl.enableVertexAttribArray(order);\n this._vertexAttribArraysEnabled[order] = true;\n this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);\n }\n offset += vertexDeclaration[index] * 4;\n }\n }\n }\n this._bindIndexBufferWithCache(indexBuffer);\n }\n _unbindVertexArrayObject() {\n if (!this._cachedVertexArrayObject) {\n return;\n }\n this._cachedVertexArrayObject = null;\n this._gl.bindVertexArray(null);\n }\n /**\n * Bind a list of vertex buffers to the webGL context\n * @param vertexBuffers defines the list of vertex buffers to bind\n * @param indexBuffer defines the index buffer to bind\n * @param effect defines the effect associated with the vertex buffers\n * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers\n */\n bindBuffers(vertexBuffers, indexBuffer, effect, overrideVertexBuffers) {\n if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {\n this._cachedVertexBuffers = vertexBuffers;\n this._cachedEffectForVertexBuffers = effect;\n this._bindVertexBuffersAttributes(vertexBuffers, effect, overrideVertexBuffers);\n }\n this._bindIndexBufferWithCache(indexBuffer);\n }\n /**\n * Unbind all instance attributes\n */\n unbindInstanceAttributes() {\n let boundBuffer;\n for (let i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {\n const instancesBuffer = this._currentInstanceBuffers[i];\n if (boundBuffer != instancesBuffer && instancesBuffer.references) {\n boundBuffer = instancesBuffer;\n this.bindArrayBuffer(instancesBuffer);\n }\n const offsetLocation = this._currentInstanceLocations[i];\n this._gl.vertexAttribDivisor(offsetLocation, 0);\n }\n this._currentInstanceBuffers.length = 0;\n this._currentInstanceLocations.length = 0;\n }\n /**\n * Release and free the memory of a vertex array object\n * @param vao defines the vertex array object to delete\n */\n releaseVertexArrayObject(vao) {\n this._gl.deleteVertexArray(vao);\n }\n /**\n * @internal\n */\n _releaseBuffer(buffer) {\n buffer.references--;\n if (buffer.references === 0) {\n this._deleteBuffer(buffer);\n return true;\n }\n return false;\n }\n _deleteBuffer(buffer) {\n this._gl.deleteBuffer(buffer.underlyingResource);\n }\n /**\n * Update the content of a webGL buffer used with instantiation and bind it to the webGL context\n * @param instancesBuffer defines the webGL buffer to update and bind\n * @param data defines the data to store in the buffer\n * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer\n */\n updateAndBindInstancesBuffer(instancesBuffer, data, offsetLocations) {\n this.bindArrayBuffer(instancesBuffer);\n if (data) {\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);\n }\n if (offsetLocations[0].index !== undefined) {\n this.bindInstancesBuffer(instancesBuffer, offsetLocations, true);\n }\n else {\n for (let index = 0; index < 4; index++) {\n const offsetLocation = offsetLocations[index];\n if (!this._vertexAttribArraysEnabled[offsetLocation]) {\n this._gl.enableVertexAttribArray(offsetLocation);\n this._vertexAttribArraysEnabled[offsetLocation] = true;\n }\n this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);\n this._gl.vertexAttribDivisor(offsetLocation, 1);\n this._currentInstanceLocations.push(offsetLocation);\n this._currentInstanceBuffers.push(instancesBuffer);\n }\n }\n }\n /**\n * Bind the content of a webGL buffer used with instantiation\n * @param instancesBuffer defines the webGL buffer to bind\n * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer\n * @param computeStride defines Whether to compute the strides from the info or use the default 0\n */\n bindInstancesBuffer(instancesBuffer, attributesInfo, computeStride = true) {\n this.bindArrayBuffer(instancesBuffer);\n let stride = 0;\n if (computeStride) {\n for (let i = 0; i < attributesInfo.length; i++) {\n const ai = attributesInfo[i];\n stride += ai.attributeSize * 4;\n }\n }\n for (let i = 0; i < attributesInfo.length; i++) {\n const ai = attributesInfo[i];\n if (ai.index === undefined) {\n ai.index = this._currentEffect.getAttributeLocationByName(ai.attributeName);\n }\n if (ai.index < 0) {\n continue;\n }\n if (!this._vertexAttribArraysEnabled[ai.index]) {\n this._gl.enableVertexAttribArray(ai.index);\n this._vertexAttribArraysEnabled[ai.index] = true;\n }\n this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attributeType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);\n this._gl.vertexAttribDivisor(ai.index, ai.divisor === undefined ? 1 : ai.divisor);\n this._currentInstanceLocations.push(ai.index);\n this._currentInstanceBuffers.push(instancesBuffer);\n }\n }\n /**\n * Disable the instance attribute corresponding to the name in parameter\n * @param name defines the name of the attribute to disable\n */\n disableInstanceAttributeByName(name) {\n if (!this._currentEffect) {\n return;\n }\n const attributeLocation = this._currentEffect.getAttributeLocationByName(name);\n this.disableInstanceAttribute(attributeLocation);\n }\n /**\n * Disable the instance attribute corresponding to the location in parameter\n * @param attributeLocation defines the attribute location of the attribute to disable\n */\n disableInstanceAttribute(attributeLocation) {\n let shouldClean = false;\n let index;\n while ((index = this._currentInstanceLocations.indexOf(attributeLocation)) !== -1) {\n this._currentInstanceLocations.splice(index, 1);\n this._currentInstanceBuffers.splice(index, 1);\n shouldClean = true;\n index = this._currentInstanceLocations.indexOf(attributeLocation);\n }\n if (shouldClean) {\n this._gl.vertexAttribDivisor(attributeLocation, 0);\n this.disableAttributeByIndex(attributeLocation);\n }\n }\n /**\n * Disable the attribute corresponding to the location in parameter\n * @param attributeLocation defines the attribute location of the attribute to disable\n */\n disableAttributeByIndex(attributeLocation) {\n this._gl.disableVertexAttribArray(attributeLocation);\n this._vertexAttribArraysEnabled[attributeLocation] = false;\n this._currentBufferPointers[attributeLocation].active = false;\n }\n /**\n * Send a draw order\n * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)\n * @param indexStart defines the starting index\n * @param indexCount defines the number of index to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n draw(useTriangles, indexStart, indexCount, instancesCount) {\n this.drawElementsType(useTriangles ? 0 : 1, indexStart, indexCount, instancesCount);\n }\n /**\n * Draw a list of points\n * @param verticesStart defines the index of first vertex to draw\n * @param verticesCount defines the count of vertices to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n drawPointClouds(verticesStart, verticesCount, instancesCount) {\n this.drawArraysType(2, verticesStart, verticesCount, instancesCount);\n }\n /**\n * Draw a list of unindexed primitives\n * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)\n * @param verticesStart defines the index of first vertex to draw\n * @param verticesCount defines the count of vertices to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n drawUnIndexed(useTriangles, verticesStart, verticesCount, instancesCount) {\n this.drawArraysType(useTriangles ? 0 : 1, verticesStart, verticesCount, instancesCount);\n }\n /**\n * Draw a list of indexed primitives\n * @param fillMode defines the primitive to use\n * @param indexStart defines the starting index\n * @param indexCount defines the number of index to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n drawElementsType(fillMode, indexStart, indexCount, instancesCount) {\n // Apply states\n this.applyStates();\n this._reportDrawCall();\n // Render\n const drawMode = this._drawMode(fillMode);\n const indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;\n const mult = this._uintIndicesCurrentlySet ? 4 : 2;\n if (instancesCount) {\n this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);\n }\n else {\n this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);\n }\n }\n /**\n * Draw a list of unindexed primitives\n * @param fillMode defines the primitive to use\n * @param verticesStart defines the index of first vertex to draw\n * @param verticesCount defines the count of vertices to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n drawArraysType(fillMode, verticesStart, verticesCount, instancesCount) {\n // Apply states\n this.applyStates();\n this._reportDrawCall();\n const drawMode = this._drawMode(fillMode);\n if (instancesCount) {\n this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);\n }\n else {\n this._gl.drawArrays(drawMode, verticesStart, verticesCount);\n }\n }\n _drawMode(fillMode) {\n switch (fillMode) {\n // Triangle views\n case 0:\n return this._gl.TRIANGLES;\n case 2:\n return this._gl.POINTS;\n case 1:\n return this._gl.LINES;\n // Draw modes\n case 3:\n return this._gl.POINTS;\n case 4:\n return this._gl.LINES;\n case 5:\n return this._gl.LINE_LOOP;\n case 6:\n return this._gl.LINE_STRIP;\n case 7:\n return this._gl.TRIANGLE_STRIP;\n case 8:\n return this._gl.TRIANGLE_FAN;\n default:\n return this._gl.TRIANGLES;\n }\n }\n // Shaders\n /**\n * @internal\n */\n _releaseEffect(effect) {\n if (this._compiledEffects[effect._key]) {\n delete this._compiledEffects[effect._key];\n }\n const pipelineContext = effect.getPipelineContext();\n if (pipelineContext) {\n this._deletePipelineContext(pipelineContext);\n }\n }\n /**\n * @internal\n */\n _deletePipelineContext(pipelineContext) {\n const webGLPipelineContext = pipelineContext;\n if (webGLPipelineContext && webGLPipelineContext.program) {\n webGLPipelineContext.program.__SPECTOR_rebuildProgram = null;\n resetCachedPipeline(webGLPipelineContext);\n if (this._gl) {\n this._gl.deleteProgram(webGLPipelineContext.program);\n }\n }\n }\n /**\n * @internal\n */\n _getGlobalDefines(defines) {\n return _getGlobalDefines(defines, this.isNDCHalfZRange, this.useReverseDepthBuffer, this.useExactSrgbConversions);\n }\n /**\n * Create a new effect (used to store vertex/fragment shaders)\n * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)\n * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object\n * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use\n * @param samplers defines an array of string used to represent textures\n * @param defines defines the string containing the defines to use to compile the shaders\n * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails\n * @param onCompiled defines a function to call when the effect creation is successful\n * @param onError defines a function to call when the effect creation has failed\n * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)\n * @param shaderLanguage the language the shader is written in (default: GLSL)\n * @param extraInitializationsAsync additional async code to run before preparing the effect\n * @returns the new Effect\n */\n createEffect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters, shaderLanguage = 0 /* ShaderLanguage.GLSL */, extraInitializationsAsync) {\n const vertex = typeof baseName === \"string\" ? baseName : baseName.vertexToken || baseName.vertexSource || baseName.vertexElement || baseName.vertex;\n const fragment = typeof baseName === \"string\" ? baseName : baseName.fragmentToken || baseName.fragmentSource || baseName.fragmentElement || baseName.fragment;\n const globalDefines = this._getGlobalDefines();\n let fullDefines = defines ?? attributesNamesOrOptions.defines ?? \"\";\n if (globalDefines) {\n fullDefines += globalDefines;\n }\n const name = vertex + \"+\" + fragment + \"@\" + fullDefines;\n if (this._compiledEffects[name]) {\n const compiledEffect = this._compiledEffects[name];\n if (onCompiled && compiledEffect.isReady()) {\n onCompiled(compiledEffect);\n }\n compiledEffect._refCount++;\n return compiledEffect;\n }\n if (this._gl) {\n getStateObject(this._gl);\n }\n const effect = new Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters, name, attributesNamesOrOptions.shaderLanguage ?? shaderLanguage, attributesNamesOrOptions.extraInitializationsAsync ?? extraInitializationsAsync);\n this._compiledEffects[name] = effect;\n return effect;\n }\n /**\n * @internal\n */\n _getShaderSource(shader) {\n return this._gl.getShaderSource(shader);\n }\n /**\n * Directly creates a webGL program\n * @param pipelineContext defines the pipeline context to attach to\n * @param vertexCode defines the vertex shader code to use\n * @param fragmentCode defines the fragment shader code to use\n * @param context defines the webGL context to use (if not set, the current one will be used)\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\n * @returns the new webGL program\n */\n createRawShaderProgram(pipelineContext, vertexCode, fragmentCode, context, transformFeedbackVaryings = null) {\n const stateObject = getStateObject(this._gl);\n stateObject._contextWasLost = this._contextWasLost;\n stateObject.validateShaderPrograms = this.validateShaderPrograms;\n return createRawShaderProgram(pipelineContext, vertexCode, fragmentCode, context || this._gl, transformFeedbackVaryings);\n }\n /**\n * Creates a webGL program\n * @param pipelineContext defines the pipeline context to attach to\n * @param vertexCode defines the vertex shader code to use\n * @param fragmentCode defines the fragment shader code to use\n * @param defines defines the string containing the defines to use to compile the shaders\n * @param context defines the webGL context to use (if not set, the current one will be used)\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\n * @returns the new webGL program\n */\n createShaderProgram(pipelineContext, vertexCode, fragmentCode, defines, context, transformFeedbackVaryings = null) {\n const stateObject = getStateObject(this._gl);\n // assure the state object is correct\n stateObject._contextWasLost = this._contextWasLost;\n stateObject.validateShaderPrograms = this.validateShaderPrograms;\n return createShaderProgram(pipelineContext, vertexCode, fragmentCode, defines, context || this._gl, transformFeedbackVaryings);\n }\n /**\n * Inline functions in shader code that are marked to be inlined\n * @param code code to inline\n * @returns inlined code\n */\n inlineShaderCode(code) {\n // no inlining needed in the WebGL engine\n return code;\n }\n /**\n * Creates a new pipeline context\n * @param shaderProcessingContext defines the shader processing context used during the processing if available\n * @returns the new pipeline\n */\n createPipelineContext(shaderProcessingContext) {\n if (this._gl) {\n const stateObject = getStateObject(this._gl);\n stateObject.parallelShaderCompile = this._caps.parallelShaderCompile;\n }\n const context = createPipelineContext(this._gl, shaderProcessingContext);\n context.engine = this;\n return context;\n }\n /**\n * Creates a new material context\n * @returns the new context\n */\n createMaterialContext() {\n return undefined;\n }\n /**\n * Creates a new draw context\n * @returns the new context\n */\n createDrawContext() {\n return undefined;\n }\n _finalizePipelineContext(pipelineContext) {\n return _finalizePipelineContext(pipelineContext, this._gl, this.validateShaderPrograms);\n }\n /**\n * @internal\n */\n _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rawVertexSourceCode, rawFragmentSourceCode, rebuildRebind, defines, transformFeedbackVaryings, key, onReady) {\n const stateObject = getStateObject(this._gl);\n stateObject._contextWasLost = this._contextWasLost;\n stateObject.validateShaderPrograms = this.validateShaderPrograms;\n stateObject._createShaderProgramInjection = this._createShaderProgram.bind(this);\n stateObject.createRawShaderProgramInjection = this.createRawShaderProgram.bind(this);\n stateObject.createShaderProgramInjection = this.createShaderProgram.bind(this);\n stateObject.loadFileInjection = this._loadFile.bind(this);\n return _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rawVertexSourceCode, rawFragmentSourceCode, rebuildRebind, defines, transformFeedbackVaryings, key, onReady);\n }\n _createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings = null) {\n return _createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings);\n }\n /**\n * @internal\n */\n _isRenderingStateCompiled(pipelineContext) {\n if (this._isDisposed) {\n return false;\n }\n return _isRenderingStateCompiled(pipelineContext, this._gl, this.validateShaderPrograms);\n }\n /**\n * @internal\n */\n _executeWhenRenderingStateIsCompiled(pipelineContext, action) {\n _executeWhenRenderingStateIsCompiled(pipelineContext, action);\n }\n /**\n * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names\n * @param pipelineContext defines the pipeline context to use\n * @param uniformsNames defines the list of uniform names\n * @returns an array of webGL uniform locations\n */\n getUniforms(pipelineContext, uniformsNames) {\n const results = new Array();\n const webGLPipelineContext = pipelineContext;\n for (let index = 0; index < uniformsNames.length; index++) {\n results.push(this._gl.getUniformLocation(webGLPipelineContext.program, uniformsNames[index]));\n }\n return results;\n }\n /**\n * Gets the list of active attributes for a given webGL program\n * @param pipelineContext defines the pipeline context to use\n * @param attributesNames defines the list of attribute names to get\n * @returns an array of indices indicating the offset of each attribute\n */\n getAttributes(pipelineContext, attributesNames) {\n const results = [];\n const webGLPipelineContext = pipelineContext;\n for (let index = 0; index < attributesNames.length; index++) {\n try {\n results.push(this._gl.getAttribLocation(webGLPipelineContext.program, attributesNames[index]));\n }\n catch (e) {\n results.push(-1);\n }\n }\n return results;\n }\n /**\n * Activates an effect, making it the current one (ie. the one used for rendering)\n * @param effect defines the effect to activate\n */\n enableEffect(effect) {\n effect = effect !== null && IsWrapper(effect) ? effect.effect : effect; // get only the effect, we don't need a Wrapper in the WebGL engine\n if (!effect || effect === this._currentEffect) {\n return;\n }\n this._stencilStateComposer.stencilMaterial = undefined;\n effect = effect;\n // Use program\n this.bindSamplers(effect);\n this._currentEffect = effect;\n if (effect.onBind) {\n effect.onBind(effect);\n }\n if (effect._onBindObservable) {\n effect._onBindObservable.notifyObservers(effect);\n }\n }\n /**\n * Set the value of an uniform to a number (int)\n * @param uniform defines the webGL uniform location where to store the value\n * @param value defines the int number to store\n * @returns true if the value was set\n */\n setInt(uniform, value) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform1i(uniform, value);\n return true;\n }\n /**\n * Set the value of an uniform to a int2\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @returns true if the value was set\n */\n setInt2(uniform, x, y) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform2i(uniform, x, y);\n return true;\n }\n /**\n * Set the value of an uniform to a int3\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @param z defines the 3rd component of the value\n * @returns true if the value was set\n */\n setInt3(uniform, x, y, z) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform3i(uniform, x, y, z);\n return true;\n }\n /**\n * Set the value of an uniform to a int4\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @param z defines the 3rd component of the value\n * @param w defines the 4th component of the value\n * @returns true if the value was set\n */\n setInt4(uniform, x, y, z, w) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform4i(uniform, x, y, z, w);\n return true;\n }\n /**\n * Set the value of an uniform to an array of int32\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of int32 to store\n * @returns true if the value was set\n */\n setIntArray(uniform, array) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform1iv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of int32 (stored as vec2)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of int32 to store\n * @returns true if the value was set\n */\n setIntArray2(uniform, array) {\n if (!uniform || array.length % 2 !== 0) {\n return false;\n }\n this._gl.uniform2iv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of int32 (stored as vec3)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of int32 to store\n * @returns true if the value was set\n */\n setIntArray3(uniform, array) {\n if (!uniform || array.length % 3 !== 0) {\n return false;\n }\n this._gl.uniform3iv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of int32 (stored as vec4)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of int32 to store\n * @returns true if the value was set\n */\n setIntArray4(uniform, array) {\n if (!uniform || array.length % 4 !== 0) {\n return false;\n }\n this._gl.uniform4iv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to a number (unsigned int)\n * @param uniform defines the webGL uniform location where to store the value\n * @param value defines the unsigned int number to store\n * @returns true if the value was set\n */\n setUInt(uniform, value) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform1ui(uniform, value);\n return true;\n }\n /**\n * Set the value of an uniform to a unsigned int2\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @returns true if the value was set\n */\n setUInt2(uniform, x, y) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform2ui(uniform, x, y);\n return true;\n }\n /**\n * Set the value of an uniform to a unsigned int3\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @param z defines the 3rd component of the value\n * @returns true if the value was set\n */\n setUInt3(uniform, x, y, z) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform3ui(uniform, x, y, z);\n return true;\n }\n /**\n * Set the value of an uniform to a unsigned int4\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @param z defines the 3rd component of the value\n * @param w defines the 4th component of the value\n * @returns true if the value was set\n */\n setUInt4(uniform, x, y, z, w) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform4ui(uniform, x, y, z, w);\n return true;\n }\n /**\n * Set the value of an uniform to an array of unsigned int32\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of unsigned int32 to store\n * @returns true if the value was set\n */\n setUIntArray(uniform, array) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform1uiv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of unsigned int32 (stored as vec2)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of unsigned int32 to store\n * @returns true if the value was set\n */\n setUIntArray2(uniform, array) {\n if (!uniform || array.length % 2 !== 0) {\n return false;\n }\n this._gl.uniform2uiv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of unsigned int32 (stored as vec3)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of unsigned int32 to store\n * @returns true if the value was set\n */\n setUIntArray3(uniform, array) {\n if (!uniform || array.length % 3 !== 0) {\n return false;\n }\n this._gl.uniform3uiv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of unsigned int32 (stored as vec4)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of unsigned int32 to store\n * @returns true if the value was set\n */\n setUIntArray4(uniform, array) {\n if (!uniform || array.length % 4 !== 0) {\n return false;\n }\n this._gl.uniform4uiv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of number\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of number to store\n * @returns true if the value was set\n */\n setArray(uniform, array) {\n if (!uniform) {\n return false;\n }\n if (array.length < 1) {\n return false;\n }\n this._gl.uniform1fv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of number (stored as vec2)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of number to store\n * @returns true if the value was set\n */\n setArray2(uniform, array) {\n if (!uniform || array.length % 2 !== 0) {\n return false;\n }\n this._gl.uniform2fv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of number (stored as vec3)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of number to store\n * @returns true if the value was set\n */\n setArray3(uniform, array) {\n if (!uniform || array.length % 3 !== 0) {\n return false;\n }\n this._gl.uniform3fv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of number (stored as vec4)\n * @param uniform defines the webGL uniform location where to store the value\n * @param array defines the array of number to store\n * @returns true if the value was set\n */\n setArray4(uniform, array) {\n if (!uniform || array.length % 4 !== 0) {\n return false;\n }\n this._gl.uniform4fv(uniform, array);\n return true;\n }\n /**\n * Set the value of an uniform to an array of float32 (stored as matrices)\n * @param uniform defines the webGL uniform location where to store the value\n * @param matrices defines the array of float32 to store\n * @returns true if the value was set\n */\n setMatrices(uniform, matrices) {\n if (!uniform) {\n return false;\n }\n this._gl.uniformMatrix4fv(uniform, false, matrices);\n return true;\n }\n /**\n * Set the value of an uniform to a matrix (3x3)\n * @param uniform defines the webGL uniform location where to store the value\n * @param matrix defines the Float32Array representing the 3x3 matrix to store\n * @returns true if the value was set\n */\n setMatrix3x3(uniform, matrix) {\n if (!uniform) {\n return false;\n }\n this._gl.uniformMatrix3fv(uniform, false, matrix);\n return true;\n }\n /**\n * Set the value of an uniform to a matrix (2x2)\n * @param uniform defines the webGL uniform location where to store the value\n * @param matrix defines the Float32Array representing the 2x2 matrix to store\n * @returns true if the value was set\n */\n setMatrix2x2(uniform, matrix) {\n if (!uniform) {\n return false;\n }\n this._gl.uniformMatrix2fv(uniform, false, matrix);\n return true;\n }\n /**\n * Set the value of an uniform to a number (float)\n * @param uniform defines the webGL uniform location where to store the value\n * @param value defines the float number to store\n * @returns true if the value was transferred\n */\n setFloat(uniform, value) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform1f(uniform, value);\n return true;\n }\n /**\n * Set the value of an uniform to a vec2\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @returns true if the value was set\n */\n setFloat2(uniform, x, y) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform2f(uniform, x, y);\n return true;\n }\n /**\n * Set the value of an uniform to a vec3\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @param z defines the 3rd component of the value\n * @returns true if the value was set\n */\n setFloat3(uniform, x, y, z) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform3f(uniform, x, y, z);\n return true;\n }\n /**\n * Set the value of an uniform to a vec4\n * @param uniform defines the webGL uniform location where to store the value\n * @param x defines the 1st component of the value\n * @param y defines the 2nd component of the value\n * @param z defines the 3rd component of the value\n * @param w defines the 4th component of the value\n * @returns true if the value was set\n */\n setFloat4(uniform, x, y, z, w) {\n if (!uniform) {\n return false;\n }\n this._gl.uniform4f(uniform, x, y, z, w);\n return true;\n }\n // States\n /**\n * Apply all cached states (depth, culling, stencil and alpha)\n */\n applyStates() {\n this._depthCullingState.apply(this._gl);\n this._stencilStateComposer.apply(this._gl);\n this._alphaState.apply(this._gl);\n if (this._colorWriteChanged) {\n this._colorWriteChanged = false;\n const enable = this._colorWrite;\n this._gl.colorMask(enable, enable, enable, enable);\n }\n }\n // Textures\n /**\n * Force the entire cache to be cleared\n * You should not have to use this function unless your engine needs to share the webGL context with another engine\n * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)\n */\n wipeCaches(bruteForce) {\n if (this.preventCacheWipeBetweenFrames && !bruteForce) {\n return;\n }\n this._currentEffect = null;\n this._viewportCached.x = 0;\n this._viewportCached.y = 0;\n this._viewportCached.z = 0;\n this._viewportCached.w = 0;\n // Done before in case we clean the attributes\n this._unbindVertexArrayObject();\n if (bruteForce) {\n this._currentProgram = null;\n this.resetTextureCache();\n this._stencilStateComposer.reset();\n this._depthCullingState.reset();\n this._depthCullingState.depthFunc = this._gl.LEQUAL;\n this._alphaState.reset();\n this._alphaMode = 1;\n this._alphaEquation = 0;\n this._colorWrite = true;\n this._colorWriteChanged = true;\n this._unpackFlipYCached = null;\n this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);\n this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);\n this._mustWipeVertexAttributes = true;\n this.unbindAllAttributes();\n }\n this._resetVertexBufferBinding();\n this._cachedIndexBuffer = null;\n this._cachedEffectForVertexBuffers = null;\n this.bindIndexBuffer(null);\n }\n /**\n * @internal\n */\n _getSamplingParameters(samplingMode, generateMipMaps) {\n const gl = this._gl;\n let magFilter = gl.NEAREST;\n let minFilter = gl.NEAREST;\n switch (samplingMode) {\n case 11:\n magFilter = gl.LINEAR;\n if (generateMipMaps) {\n minFilter = gl.LINEAR_MIPMAP_NEAREST;\n }\n else {\n minFilter = gl.LINEAR;\n }\n break;\n case 3:\n magFilter = gl.LINEAR;\n if (generateMipMaps) {\n minFilter = gl.LINEAR_MIPMAP_LINEAR;\n }\n else {\n minFilter = gl.LINEAR;\n }\n break;\n case 8:\n magFilter = gl.NEAREST;\n if (generateMipMaps) {\n minFilter = gl.NEAREST_MIPMAP_LINEAR;\n }\n else {\n minFilter = gl.NEAREST;\n }\n break;\n case 4:\n magFilter = gl.NEAREST;\n if (generateMipMaps) {\n minFilter = gl.NEAREST_MIPMAP_NEAREST;\n }\n else {\n minFilter = gl.NEAREST;\n }\n break;\n case 5:\n magFilter = gl.NEAREST;\n if (generateMipMaps) {\n minFilter = gl.LINEAR_MIPMAP_NEAREST;\n }\n else {\n minFilter = gl.LINEAR;\n }\n break;\n case 6:\n magFilter = gl.NEAREST;\n if (generateMipMaps) {\n minFilter = gl.LINEAR_MIPMAP_LINEAR;\n }\n else {\n minFilter = gl.LINEAR;\n }\n break;\n case 7:\n magFilter = gl.NEAREST;\n minFilter = gl.LINEAR;\n break;\n case 1:\n magFilter = gl.NEAREST;\n minFilter = gl.NEAREST;\n break;\n case 9:\n magFilter = gl.LINEAR;\n if (generateMipMaps) {\n minFilter = gl.NEAREST_MIPMAP_NEAREST;\n }\n else {\n minFilter = gl.NEAREST;\n }\n break;\n case 10:\n magFilter = gl.LINEAR;\n if (generateMipMaps) {\n minFilter = gl.NEAREST_MIPMAP_LINEAR;\n }\n else {\n minFilter = gl.NEAREST;\n }\n break;\n case 2:\n magFilter = gl.LINEAR;\n minFilter = gl.LINEAR;\n break;\n case 12:\n magFilter = gl.LINEAR;\n minFilter = gl.NEAREST;\n break;\n }\n return {\n min: minFilter,\n mag: magFilter,\n };\n }\n /** @internal */\n _createTexture() {\n const texture = this._gl.createTexture();\n if (!texture) {\n throw new Error(\"Unable to create texture\");\n }\n return texture;\n }\n /** @internal */\n _createHardwareTexture() {\n return new WebGLHardwareTexture(this._createTexture(), this._gl);\n }\n /**\n * Creates an internal texture without binding it to a framebuffer\n * @internal\n * @param size defines the size of the texture\n * @param options defines the options used to create the texture\n * @param delayGPUTextureCreation true to delay the texture creation the first time it is really needed. false to create it right away\n * @param source source type of the texture\n * @returns a new internal texture\n */\n _createInternalTexture(size, options, delayGPUTextureCreation = true, source = 0 /* InternalTextureSource.Unknown */) {\n let generateMipMaps = false;\n let createMipMaps = false;\n let type = 0;\n let samplingMode = 3;\n let format = 5;\n let useSRGBBuffer = false;\n let samples = 1;\n let label;\n let createMSAATexture = false;\n let comparisonFunction = 0;\n if (options !== undefined && typeof options === \"object\") {\n generateMipMaps = !!options.generateMipMaps;\n createMipMaps = !!options.createMipMaps;\n type = options.type === undefined ? 0 : options.type;\n samplingMode = options.samplingMode === undefined ? 3 : options.samplingMode;\n format = options.format === undefined ? 5 : options.format;\n useSRGBBuffer = options.useSRGBBuffer === undefined ? false : options.useSRGBBuffer;\n samples = options.samples ?? 1;\n label = options.label;\n createMSAATexture = !!options.createMSAATexture;\n comparisonFunction = options.comparisonFunction || 0;\n }\n else {\n generateMipMaps = !!options;\n }\n useSRGBBuffer && (useSRGBBuffer = this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU));\n if (type === 1 && !this._caps.textureFloatLinearFiltering) {\n // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE\n samplingMode = 1;\n }\n else if (type === 2 && !this._caps.textureHalfFloatLinearFiltering) {\n // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE\n samplingMode = 1;\n }\n if (type === 1 && !this._caps.textureFloat) {\n type = 0;\n Logger.Warn(\"Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE\");\n }\n const isDepthTexture = IsDepthTexture(format);\n const hasStencil = HasStencilAspect(format);\n const gl = this._gl;\n const texture = new InternalTexture(this, source);\n const width = size.width || size;\n const height = size.height || size;\n const depth = size.depth || 0;\n const layers = size.layers || 0;\n const filters = this._getSamplingParameters(samplingMode, (generateMipMaps || createMipMaps) && !isDepthTexture);\n const target = layers !== 0 ? gl.TEXTURE_2D_ARRAY : depth !== 0 ? gl.TEXTURE_3D : gl.TEXTURE_2D;\n const sizedFormat = isDepthTexture\n ? this._getInternalFormatFromDepthTextureFormat(format, true, hasStencil)\n : this._getRGBABufferInternalSizedFormat(type, format, useSRGBBuffer);\n const internalFormat = isDepthTexture ? (hasStencil ? gl.DEPTH_STENCIL : gl.DEPTH_COMPONENT) : this._getInternalFormat(format);\n const textureType = isDepthTexture ? this._getWebGLTextureTypeFromDepthTextureFormat(format) : this._getWebGLTextureType(type);\n // Bind\n this._bindTextureDirectly(target, texture);\n if (layers !== 0) {\n texture.is2DArray = true;\n gl.texImage3D(target, 0, sizedFormat, width, height, layers, 0, internalFormat, textureType, null);\n }\n else if (depth !== 0) {\n texture.is3D = true;\n gl.texImage3D(target, 0, sizedFormat, width, height, depth, 0, internalFormat, textureType, null);\n }\n else {\n gl.texImage2D(target, 0, sizedFormat, width, height, 0, internalFormat, textureType, null);\n }\n gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, filters.mag);\n gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, filters.min);\n gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n if (isDepthTexture && this.webGLVersion > 1) {\n if (comparisonFunction === 0) {\n gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, 515);\n gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);\n }\n else {\n gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);\n gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);\n }\n }\n // MipMaps\n if (generateMipMaps || createMipMaps) {\n this._gl.generateMipmap(target);\n }\n this._bindTextureDirectly(target, null);\n texture._useSRGBBuffer = useSRGBBuffer;\n texture.baseWidth = width;\n texture.baseHeight = height;\n texture.width = width;\n texture.height = height;\n texture.depth = layers || depth;\n texture.isReady = true;\n texture.samples = samples;\n texture.generateMipMaps = generateMipMaps;\n texture.samplingMode = samplingMode;\n texture.type = type;\n texture.format = format;\n texture.label = label;\n texture.comparisonFunction = comparisonFunction;\n this._internalTexturesCache.push(texture);\n if (createMSAATexture) {\n let renderBuffer = null;\n if (IsDepthTexture(texture.format)) {\n renderBuffer = this._setupFramebufferDepthAttachments(HasStencilAspect(texture.format), texture.format !== 19, texture.width, texture.height, samples, texture.format, true);\n }\n else {\n renderBuffer = this._createRenderBuffer(texture.width, texture.height, samples, -1 /* not used */, this._getRGBABufferInternalSizedFormat(texture.type, texture.format, texture._useSRGBBuffer), -1 /* attachment */);\n }\n if (!renderBuffer) {\n throw new Error(\"Unable to create render buffer\");\n }\n texture._autoMSAAManagement = true;\n let hardwareTexture = texture._hardwareTexture;\n if (!hardwareTexture) {\n hardwareTexture = texture._hardwareTexture = this._createHardwareTexture();\n }\n hardwareTexture.addMSAARenderBuffer(renderBuffer);\n }\n return texture;\n }\n /**\n * @internal\n */\n _getUseSRGBBuffer(useSRGBBuffer, noMipmap) {\n // Generating mipmaps for sRGB textures is not supported in WebGL1 so we must disable the support if mipmaps is enabled\n return useSRGBBuffer && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || noMipmap);\n }\n /**\n * Usually called from Texture.ts.\n * Passed information to create a WebGLTexture\n * @param url defines a value which contains one of the following:\n * * A conventional http URL, e.g. 'http://...' or 'file://...'\n * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'\n * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'\n * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file\n * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)\n * @param scene needed for loading to the correct scene\n * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)\n * @param onLoad optional callback to be called upon successful completion\n * @param onError optional callback to be called upon failure\n * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob\n * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities\n * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures\n * @param forcedExtension defines the extension to use to pick the right loader\n * @param mimeType defines an optional mime type\n * @param loaderOptions options to be passed to the loader\n * @param creationFlags specific flags to use when creating the texture (1 for storage textures, for eg)\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\n * @returns a InternalTexture for assignment back into BABYLON.Texture\n */\n createTexture(url, noMipmap, invertY, scene, samplingMode = 3, onLoad = null, onError = null, buffer = null, fallback = null, format = null, forcedExtension = null, mimeType, loaderOptions, creationFlags, useSRGBBuffer) {\n return this._createTextureBase(url, noMipmap, invertY, scene, samplingMode, onLoad, onError, (...args) => this._prepareWebGLTexture(...args, format), (potWidth, potHeight, img, extension, texture, continuationCallback) => {\n const gl = this._gl;\n const isPot = img.width === potWidth && img.height === potHeight;\n texture._creationFlags = creationFlags ?? 0;\n const tip = this._getTexImageParametersForCreateTexture(texture.format, texture._useSRGBBuffer);\n if (isPot) {\n gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, img);\n return false;\n }\n const maxTextureSize = this._caps.maxTextureSize;\n if (img.width > maxTextureSize || img.height > maxTextureSize || !this._supportsHardwareTextureRescaling) {\n this._prepareWorkingCanvas();\n if (!this._workingCanvas || !this._workingContext) {\n return false;\n }\n this._workingCanvas.width = potWidth;\n this._workingCanvas.height = potHeight;\n this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);\n gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, this._workingCanvas);\n texture.width = potWidth;\n texture.height = potHeight;\n return false;\n }\n else {\n // Using shaders when possible to rescale because canvas.drawImage is lossy\n const source = new InternalTexture(this, 2 /* InternalTextureSource.Temp */);\n this._bindTextureDirectly(gl.TEXTURE_2D, source, true);\n gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, img);\n this._rescaleTexture(source, texture, scene, tip.format, () => {\n this._releaseTexture(source);\n this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);\n continuationCallback();\n });\n }\n return true;\n }, buffer, fallback, format, forcedExtension, mimeType, loaderOptions, useSRGBBuffer);\n }\n /**\n * Calls to the GL texImage2D and texImage3D functions require three arguments describing the pixel format of the texture.\n * createTexture derives these from the babylonFormat and useSRGBBuffer arguments and also the file extension of the URL it's working with.\n * This function encapsulates that derivation for easy unit testing.\n * @param babylonFormat Babylon's format enum, as specified in ITextureCreationOptions.\n * @param fileExtension The file extension including the dot, e.g. .jpg.\n * @param useSRGBBuffer Use SRGB not linear.\n * @returns The options to pass to texImage2D or texImage3D calls.\n * @internal\n */\n _getTexImageParametersForCreateTexture(babylonFormat, useSRGBBuffer) {\n let format, internalFormat;\n if (this.webGLVersion === 1) {\n // In WebGL 1, format and internalFormat must be the same and taken from a limited set of values, see https://docs.gl/es2/glTexImage2D.\n // The SRGB extension (https://developer.mozilla.org/en-US/docs/Web/API/EXT_sRGB) adds some extra values, hence passing useSRGBBuffer\n // to getInternalFormat.\n format = this._getInternalFormat(babylonFormat, useSRGBBuffer);\n internalFormat = format;\n }\n else {\n // In WebGL 2, format has a wider range of values and internal format can be one of the sized formats, see\n // https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml.\n // SRGB is included in the sized format and should not be passed in \"format\", hence always passing useSRGBBuffer as false.\n format = this._getInternalFormat(babylonFormat, false);\n internalFormat = this._getRGBABufferInternalSizedFormat(0, babylonFormat, useSRGBBuffer);\n }\n return {\n internalFormat,\n format,\n type: this._gl.UNSIGNED_BYTE,\n };\n }\n /**\n * @internal\n */\n _rescaleTexture(source, destination, scene, internalFormat, onComplete) { }\n /**\n * @internal\n */\n _unpackFlipY(value) {\n if (this._unpackFlipYCached !== value) {\n this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);\n if (this.enableUnpackFlipYCached) {\n this._unpackFlipYCached = value;\n }\n }\n }\n /** @internal */\n _getUnpackAlignement() {\n return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);\n }\n /** @internal */\n _getTextureTarget(texture) {\n if (texture.isCube) {\n return this._gl.TEXTURE_CUBE_MAP;\n }\n else if (texture.is3D) {\n return this._gl.TEXTURE_3D;\n }\n else if (texture.is2DArray || texture.isMultiview) {\n return this._gl.TEXTURE_2D_ARRAY;\n }\n return this._gl.TEXTURE_2D;\n }\n /**\n * Update the sampling mode of a given texture\n * @param samplingMode defines the required sampling mode\n * @param texture defines the texture to update\n * @param generateMipMaps defines whether to generate mipmaps for the texture\n */\n updateTextureSamplingMode(samplingMode, texture, generateMipMaps = false) {\n const target = this._getTextureTarget(texture);\n const filters = this._getSamplingParameters(samplingMode, texture.useMipMaps || generateMipMaps);\n this._setTextureParameterInteger(target, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);\n this._setTextureParameterInteger(target, this._gl.TEXTURE_MIN_FILTER, filters.min);\n if (generateMipMaps) {\n texture.generateMipMaps = true;\n this._gl.generateMipmap(target);\n }\n this._bindTextureDirectly(target, null);\n texture.samplingMode = samplingMode;\n }\n /**\n * Update the dimensions of a texture\n * @param texture texture to update\n * @param width new width of the texture\n * @param height new height of the texture\n * @param depth new depth of the texture\n */\n updateTextureDimensions(texture, width, height, depth = 1) { }\n /**\n * Update the sampling mode of a given texture\n * @param texture defines the texture to update\n * @param wrapU defines the texture wrap mode of the u coordinates\n * @param wrapV defines the texture wrap mode of the v coordinates\n * @param wrapR defines the texture wrap mode of the r coordinates\n */\n updateTextureWrappingMode(texture, wrapU, wrapV = null, wrapR = null) {\n const target = this._getTextureTarget(texture);\n if (wrapU !== null) {\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(wrapU), texture);\n texture._cachedWrapU = wrapU;\n }\n if (wrapV !== null) {\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(wrapV), texture);\n texture._cachedWrapV = wrapV;\n }\n if ((texture.is2DArray || texture.is3D) && wrapR !== null) {\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(wrapR), texture);\n texture._cachedWrapR = wrapR;\n }\n this._bindTextureDirectly(target, null);\n }\n /**\n * @internal\n */\n _uploadCompressedDataToTextureDirectly(texture, internalFormat, width, height, data, faceIndex = 0, lod = 0) {\n const gl = this._gl;\n let target = gl.TEXTURE_2D;\n if (texture.isCube) {\n target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;\n }\n if (texture._useSRGBBuffer) {\n switch (internalFormat) {\n case 37492:\n case 36196:\n // Note, if using ETC1 and sRGB is requested, this will use ETC2 if available.\n if (this._caps.etc2) {\n internalFormat = gl.COMPRESSED_SRGB8_ETC2;\n }\n else {\n texture._useSRGBBuffer = false;\n }\n break;\n case 37496:\n if (this._caps.etc2) {\n internalFormat = gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;\n }\n else {\n texture._useSRGBBuffer = false;\n }\n break;\n case 36492:\n internalFormat = gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;\n break;\n case 37808:\n internalFormat = gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;\n break;\n case 33776:\n if (this._caps.s3tc_srgb) {\n internalFormat = gl.COMPRESSED_SRGB_S3TC_DXT1_EXT;\n }\n else {\n // S3TC sRGB extension not supported\n texture._useSRGBBuffer = false;\n }\n break;\n case 33777:\n if (this._caps.s3tc_srgb) {\n internalFormat = gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;\n }\n else {\n // S3TC sRGB extension not supported\n texture._useSRGBBuffer = false;\n }\n break;\n case 33779:\n if (this._caps.s3tc_srgb) {\n internalFormat = gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;\n }\n else {\n // S3TC sRGB extension not supported\n texture._useSRGBBuffer = false;\n }\n break;\n default:\n // We don't support a sRGB format corresponding to internalFormat, so revert to non sRGB format\n texture._useSRGBBuffer = false;\n break;\n }\n }\n this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);\n }\n /**\n * @internal\n */\n _uploadDataToTextureDirectly(texture, imageData, faceIndex = 0, lod = 0, babylonInternalFormat, useTextureWidthAndHeight = false) {\n const gl = this._gl;\n const textureType = this._getWebGLTextureType(texture.type);\n const format = this._getInternalFormat(texture.format);\n const internalFormat = babylonInternalFormat === undefined\n ? this._getRGBABufferInternalSizedFormat(texture.type, texture.format, texture._useSRGBBuffer)\n : this._getInternalFormat(babylonInternalFormat, texture._useSRGBBuffer);\n this._unpackFlipY(texture.invertY);\n let target = gl.TEXTURE_2D;\n if (texture.isCube) {\n target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;\n }\n const lodMaxWidth = Math.round(Math.log(texture.width) * Math.LOG2E);\n const lodMaxHeight = Math.round(Math.log(texture.height) * Math.LOG2E);\n const width = useTextureWidthAndHeight ? texture.width : Math.pow(2, Math.max(lodMaxWidth - lod, 0));\n const height = useTextureWidthAndHeight ? texture.height : Math.pow(2, Math.max(lodMaxHeight - lod, 0));\n gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);\n }\n /**\n * Update a portion of an internal texture\n * @param texture defines the texture to update\n * @param imageData defines the data to store into the texture\n * @param xOffset defines the x coordinates of the update rectangle\n * @param yOffset defines the y coordinates of the update rectangle\n * @param width defines the width of the update rectangle\n * @param height defines the height of the update rectangle\n * @param faceIndex defines the face index if texture is a cube (0 by default)\n * @param lod defines the lod level to update (0 by default)\n * @param generateMipMaps defines whether to generate mipmaps or not\n */\n updateTextureData(texture, imageData, xOffset, yOffset, width, height, faceIndex = 0, lod = 0, generateMipMaps = false) {\n const gl = this._gl;\n const textureType = this._getWebGLTextureType(texture.type);\n const format = this._getInternalFormat(texture.format);\n this._unpackFlipY(texture.invertY);\n let targetForBinding = gl.TEXTURE_2D;\n let target = gl.TEXTURE_2D;\n if (texture.isCube) {\n target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;\n targetForBinding = gl.TEXTURE_CUBE_MAP;\n }\n this._bindTextureDirectly(targetForBinding, texture, true);\n gl.texSubImage2D(target, lod, xOffset, yOffset, width, height, format, textureType, imageData);\n if (generateMipMaps) {\n this._gl.generateMipmap(target);\n }\n this._bindTextureDirectly(targetForBinding, null);\n }\n /**\n * @internal\n */\n _uploadArrayBufferViewToTexture(texture, imageData, faceIndex = 0, lod = 0) {\n const gl = this._gl;\n const bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;\n this._bindTextureDirectly(bindTarget, texture, true);\n this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);\n this._bindTextureDirectly(bindTarget, null, true);\n }\n _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode) {\n const gl = this._gl;\n if (!gl) {\n return;\n }\n const filters = this._getSamplingParameters(samplingMode, !noMipmap);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);\n if (!noMipmap && !isCompressed) {\n gl.generateMipmap(gl.TEXTURE_2D);\n }\n this._bindTextureDirectly(gl.TEXTURE_2D, null);\n // this.resetTextureCache();\n if (scene) {\n scene.removePendingData(texture);\n }\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n }\n _prepareWebGLTexture(texture, extension, scene, img, invertY, noMipmap, isCompressed, processFunction, samplingMode, format) {\n const maxTextureSize = this.getCaps().maxTextureSize;\n const potWidth = Math.min(maxTextureSize, this.needPOTTextures ? GetExponentOfTwo(img.width, maxTextureSize) : img.width);\n const potHeight = Math.min(maxTextureSize, this.needPOTTextures ? GetExponentOfTwo(img.height, maxTextureSize) : img.height);\n const gl = this._gl;\n if (!gl) {\n return;\n }\n if (!texture._hardwareTexture) {\n // this.resetTextureCache();\n if (scene) {\n scene.removePendingData(texture);\n }\n return;\n }\n this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);\n this._unpackFlipY(invertY === undefined ? true : invertY ? true : false);\n texture.baseWidth = img.width;\n texture.baseHeight = img.height;\n texture.width = potWidth;\n texture.height = potHeight;\n texture.isReady = true;\n texture.type = texture.type !== -1 ? texture.type : 0;\n texture.format =\n texture.format !== -1 ? texture.format : (format ?? (extension === \".jpg\" && !texture._useSRGBBuffer ? 4 : 5));\n if (processFunction(potWidth, potHeight, img, extension, texture, () => {\n this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);\n })) {\n // Returning as texture needs extra async steps\n return;\n }\n this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);\n }\n _getInternalFormatFromDepthTextureFormat(textureFormat, hasDepth, hasStencil) {\n const gl = this._gl;\n if (!hasDepth) {\n return gl.STENCIL_INDEX8;\n }\n const format = hasStencil ? gl.DEPTH_STENCIL : gl.DEPTH_COMPONENT;\n let internalFormat = format;\n if (this.webGLVersion > 1) {\n if (textureFormat === 15) {\n internalFormat = gl.DEPTH_COMPONENT16;\n }\n else if (textureFormat === 16) {\n internalFormat = gl.DEPTH_COMPONENT24;\n }\n else if (textureFormat === 17 || textureFormat === 13) {\n internalFormat = hasStencil ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT24;\n }\n else if (textureFormat === 14) {\n internalFormat = gl.DEPTH_COMPONENT32F;\n }\n else if (textureFormat === 18) {\n internalFormat = hasStencil ? gl.DEPTH32F_STENCIL8 : gl.DEPTH_COMPONENT32F;\n }\n }\n else {\n internalFormat = gl.DEPTH_COMPONENT16;\n }\n return internalFormat;\n }\n _getWebGLTextureTypeFromDepthTextureFormat(textureFormat) {\n const gl = this._gl;\n let type = gl.UNSIGNED_INT;\n if (textureFormat === 15) {\n type = gl.UNSIGNED_SHORT;\n }\n else if (textureFormat === 17 || textureFormat === 13) {\n type = gl.UNSIGNED_INT_24_8;\n }\n else if (textureFormat === 14) {\n type = gl.FLOAT;\n }\n else if (textureFormat === 18) {\n type = gl.FLOAT_32_UNSIGNED_INT_24_8_REV;\n }\n else if (textureFormat === 19) {\n type = gl.UNSIGNED_BYTE;\n }\n return type;\n }\n /**\n * @internal\n */\n _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples = 1, depthTextureFormat, dontBindRenderBufferToFrameBuffer = false) {\n const gl = this._gl;\n depthTextureFormat = depthTextureFormat ?? (generateStencilBuffer ? 13 : 14);\n const internalFormat = this._getInternalFormatFromDepthTextureFormat(depthTextureFormat, generateDepthBuffer, generateStencilBuffer);\n // Create the depth/stencil buffer\n if (generateStencilBuffer && generateDepthBuffer) {\n return this._createRenderBuffer(width, height, samples, gl.DEPTH_STENCIL, internalFormat, dontBindRenderBufferToFrameBuffer ? -1 : gl.DEPTH_STENCIL_ATTACHMENT);\n }\n if (generateDepthBuffer) {\n return this._createRenderBuffer(width, height, samples, internalFormat, internalFormat, dontBindRenderBufferToFrameBuffer ? -1 : gl.DEPTH_ATTACHMENT);\n }\n if (generateStencilBuffer) {\n return this._createRenderBuffer(width, height, samples, internalFormat, internalFormat, dontBindRenderBufferToFrameBuffer ? -1 : gl.STENCIL_ATTACHMENT);\n }\n return null;\n }\n /**\n * @internal\n */\n _createRenderBuffer(width, height, samples, internalFormat, msInternalFormat, attachment, unbindBuffer = true) {\n const gl = this._gl;\n const renderBuffer = gl.createRenderbuffer();\n return this._updateRenderBuffer(renderBuffer, width, height, samples, internalFormat, msInternalFormat, attachment, unbindBuffer);\n }\n _updateRenderBuffer(renderBuffer, width, height, samples, internalFormat, msInternalFormat, attachment, unbindBuffer = true) {\n const gl = this._gl;\n gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer);\n if (samples > 1 && gl.renderbufferStorageMultisample) {\n gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, msInternalFormat, width, height);\n }\n else {\n gl.renderbufferStorage(gl.RENDERBUFFER, internalFormat, width, height);\n }\n if (attachment !== -1) {\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, renderBuffer);\n }\n if (unbindBuffer) {\n gl.bindRenderbuffer(gl.RENDERBUFFER, null);\n }\n return renderBuffer;\n }\n /**\n * @internal\n */\n _releaseTexture(texture) {\n this._deleteTexture(texture._hardwareTexture);\n // Unbind channels\n this.unbindAllTextures();\n const index = this._internalTexturesCache.indexOf(texture);\n if (index !== -1) {\n this._internalTexturesCache.splice(index, 1);\n }\n // Integrated fixed lod samplers.\n if (texture._lodTextureHigh) {\n texture._lodTextureHigh.dispose();\n }\n if (texture._lodTextureMid) {\n texture._lodTextureMid.dispose();\n }\n if (texture._lodTextureLow) {\n texture._lodTextureLow.dispose();\n }\n // Integrated irradiance map.\n if (texture._irradianceTexture) {\n texture._irradianceTexture.dispose();\n }\n }\n _deleteTexture(texture) {\n texture?.release();\n }\n _setProgram(program) {\n if (this._currentProgram !== program) {\n _setProgram(program, this._gl);\n this._currentProgram = program;\n }\n }\n /**\n * Binds an effect to the webGL context\n * @param effect defines the effect to bind\n */\n bindSamplers(effect) {\n const webGLPipelineContext = effect.getPipelineContext();\n this._setProgram(webGLPipelineContext.program);\n const samplers = effect.getSamplers();\n for (let index = 0; index < samplers.length; index++) {\n const uniform = effect.getUniform(samplers[index]);\n if (uniform) {\n this._boundUniforms[index] = uniform;\n }\n }\n this._currentEffect = null;\n }\n _activateCurrentTexture() {\n if (this._currentTextureChannel !== this._activeChannel) {\n this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);\n this._currentTextureChannel = this._activeChannel;\n }\n }\n /**\n * @internal\n */\n _bindTextureDirectly(target, texture, forTextureDataUpdate = false, force = false) {\n let wasPreviouslyBound = false;\n const isTextureForRendering = texture && texture._associatedChannel > -1;\n if (forTextureDataUpdate && isTextureForRendering) {\n this._activeChannel = texture._associatedChannel;\n }\n const currentTextureBound = this._boundTexturesCache[this._activeChannel];\n if (currentTextureBound !== texture || force) {\n this._activateCurrentTexture();\n if (texture && texture.isMultiview) {\n //this._gl.bindTexture(target, texture ? texture._colorTextureArray : null);\n Logger.Error([\"_bindTextureDirectly called with a multiview texture!\", target, texture]);\n // eslint-disable-next-line no-throw-literal\n throw \"_bindTextureDirectly called with a multiview texture!\";\n }\n else {\n this._gl.bindTexture(target, texture?._hardwareTexture?.underlyingResource ?? null);\n }\n this._boundTexturesCache[this._activeChannel] = texture;\n if (texture) {\n texture._associatedChannel = this._activeChannel;\n }\n }\n else if (forTextureDataUpdate) {\n wasPreviouslyBound = true;\n this._activateCurrentTexture();\n }\n if (isTextureForRendering && !forTextureDataUpdate) {\n this._bindSamplerUniformToChannel(texture._associatedChannel, this._activeChannel);\n }\n return wasPreviouslyBound;\n }\n /**\n * @internal\n */\n _bindTexture(channel, texture, name) {\n if (channel === undefined) {\n return;\n }\n if (texture) {\n texture._associatedChannel = channel;\n }\n this._activeChannel = channel;\n const target = texture ? this._getTextureTarget(texture) : this._gl.TEXTURE_2D;\n this._bindTextureDirectly(target, texture);\n }\n /**\n * Unbind all textures from the webGL context\n */\n unbindAllTextures() {\n for (let channel = 0; channel < this._maxSimultaneousTextures; channel++) {\n this._activeChannel = channel;\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);\n if (this.webGLVersion > 1) {\n this._bindTextureDirectly(this._gl.TEXTURE_3D, null);\n this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null);\n }\n }\n }\n /**\n * Sets a texture to the according uniform.\n * @param channel The texture channel\n * @param uniform The uniform to set\n * @param texture The texture to apply\n * @param name The name of the uniform in the effect\n */\n setTexture(channel, uniform, texture, name) {\n if (channel === undefined) {\n return;\n }\n if (uniform) {\n this._boundUniforms[channel] = uniform;\n }\n this._setTexture(channel, texture);\n }\n _bindSamplerUniformToChannel(sourceSlot, destination) {\n const uniform = this._boundUniforms[sourceSlot];\n if (!uniform || uniform._currentState === destination) {\n return;\n }\n this._gl.uniform1i(uniform, destination);\n uniform._currentState = destination;\n }\n _getTextureWrapMode(mode) {\n switch (mode) {\n case 1:\n return this._gl.REPEAT;\n case 0:\n return this._gl.CLAMP_TO_EDGE;\n case 2:\n return this._gl.MIRRORED_REPEAT;\n }\n return this._gl.REPEAT;\n }\n _setTexture(channel, texture, isPartOfTextureArray = false, depthStencilTexture = false, name = \"\") {\n // Not ready?\n if (!texture) {\n if (this._boundTexturesCache[channel] != null) {\n this._activeChannel = channel;\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);\n if (this.webGLVersion > 1) {\n this._bindTextureDirectly(this._gl.TEXTURE_3D, null);\n this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null);\n }\n }\n return false;\n }\n // Video\n if (texture.video) {\n this._activeChannel = channel;\n const videoInternalTexture = texture.getInternalTexture();\n if (videoInternalTexture) {\n videoInternalTexture._associatedChannel = channel;\n }\n texture.update();\n }\n else if (texture.delayLoadState === 4) {\n // Delay loading\n texture.delayLoad();\n return false;\n }\n let internalTexture;\n if (depthStencilTexture) {\n internalTexture = texture.depthStencilTexture;\n }\n else if (texture.isReady()) {\n internalTexture = texture.getInternalTexture();\n }\n else if (texture.isCube) {\n internalTexture = this.emptyCubeTexture;\n }\n else if (texture.is3D) {\n internalTexture = this.emptyTexture3D;\n }\n else if (texture.is2DArray) {\n internalTexture = this.emptyTexture2DArray;\n }\n else {\n internalTexture = this.emptyTexture;\n }\n if (!isPartOfTextureArray && internalTexture) {\n internalTexture._associatedChannel = channel;\n }\n let needToBind = true;\n if (this._boundTexturesCache[channel] === internalTexture) {\n if (!isPartOfTextureArray) {\n this._bindSamplerUniformToChannel(internalTexture._associatedChannel, channel);\n }\n needToBind = false;\n }\n this._activeChannel = channel;\n const target = this._getTextureTarget(internalTexture);\n if (needToBind) {\n this._bindTextureDirectly(target, internalTexture, isPartOfTextureArray);\n }\n if (internalTexture && !internalTexture.isMultiview) {\n // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.\n if (internalTexture.isCube && internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {\n internalTexture._cachedCoordinatesMode = texture.coordinatesMode;\n const textureWrapMode = texture.coordinatesMode !== 3 && texture.coordinatesMode !== 5\n ? 1\n : 0;\n texture.wrapU = textureWrapMode;\n texture.wrapV = textureWrapMode;\n }\n if (internalTexture._cachedWrapU !== texture.wrapU) {\n internalTexture._cachedWrapU = texture.wrapU;\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);\n }\n if (internalTexture._cachedWrapV !== texture.wrapV) {\n internalTexture._cachedWrapV = texture.wrapV;\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);\n }\n if (internalTexture.is3D && internalTexture._cachedWrapR !== texture.wrapR) {\n internalTexture._cachedWrapR = texture.wrapR;\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);\n }\n this._setAnisotropicLevel(target, internalTexture, texture.anisotropicFilteringLevel);\n }\n return true;\n }\n /**\n * Sets an array of texture to the webGL context\n * @param channel defines the channel where the texture array must be set\n * @param uniform defines the associated uniform location\n * @param textures defines the array of textures to bind\n * @param name name of the channel\n */\n setTextureArray(channel, uniform, textures, name) {\n if (channel === undefined || !uniform) {\n return;\n }\n if (!this._textureUnits || this._textureUnits.length !== textures.length) {\n this._textureUnits = new Int32Array(textures.length);\n }\n for (let i = 0; i < textures.length; i++) {\n const texture = textures[i].getInternalTexture();\n if (texture) {\n this._textureUnits[i] = channel + i;\n texture._associatedChannel = channel + i;\n }\n else {\n this._textureUnits[i] = -1;\n }\n }\n this._gl.uniform1iv(uniform, this._textureUnits);\n for (let index = 0; index < textures.length; index++) {\n this._setTexture(this._textureUnits[index], textures[index], true);\n }\n }\n /**\n * @internal\n */\n _setAnisotropicLevel(target, internalTexture, anisotropicFilteringLevel) {\n const anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;\n if (internalTexture.samplingMode !== 11 &&\n internalTexture.samplingMode !== 3 &&\n internalTexture.samplingMode !== 2) {\n anisotropicFilteringLevel = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear\n }\n if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== anisotropicFilteringLevel) {\n this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(anisotropicFilteringLevel, this._caps.maxAnisotropy), internalTexture);\n internalTexture._cachedAnisotropicFilteringLevel = anisotropicFilteringLevel;\n }\n }\n _setTextureParameterFloat(target, parameter, value, texture) {\n this._bindTextureDirectly(target, texture, true, true);\n this._gl.texParameterf(target, parameter, value);\n }\n _setTextureParameterInteger(target, parameter, value, texture) {\n if (texture) {\n this._bindTextureDirectly(target, texture, true, true);\n }\n this._gl.texParameteri(target, parameter, value);\n }\n /**\n * Unbind all vertex attributes from the webGL context\n */\n unbindAllAttributes() {\n if (this._mustWipeVertexAttributes) {\n this._mustWipeVertexAttributes = false;\n for (let i = 0; i < this._caps.maxVertexAttribs; i++) {\n this.disableAttributeByIndex(i);\n }\n return;\n }\n for (let i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {\n if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {\n continue;\n }\n this.disableAttributeByIndex(i);\n }\n }\n /**\n * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled\n */\n releaseEffects() {\n const keys = Object.keys(this._compiledEffects);\n for (const name of keys) {\n const effect = this._compiledEffects[name];\n effect.dispose(true);\n }\n this._compiledEffects = {};\n }\n /**\n * Dispose and release all associated resources\n */\n dispose() {\n // Events\n if (IsWindowObjectExist()) {\n if (this._renderingCanvas) {\n if (!this._doNotHandleContextLost) {\n this._renderingCanvas.removeEventListener(\"webglcontextlost\", this._onContextLost);\n this._renderingCanvas.removeEventListener(\"webglcontextrestored\", this._onContextRestored);\n }\n }\n }\n // Should not be moved up of renderingCanvas will be null.\n super.dispose();\n if (this._dummyFramebuffer) {\n this._gl.deleteFramebuffer(this._dummyFramebuffer);\n }\n // Unbind\n this.unbindAllAttributes();\n this._boundUniforms = {};\n this._workingCanvas = null;\n this._workingContext = null;\n this._currentBufferPointers.length = 0;\n this._currentProgram = null;\n if (this._creationOptions.loseContextOnDispose) {\n this._gl.getExtension(\"WEBGL_lose_context\")?.loseContext();\n }\n // clear the state object\n deleteStateObject(this._gl);\n }\n /**\n * Attach a new callback raised when context lost event is fired\n * @param callback defines the callback to call\n */\n attachContextLostEvent(callback) {\n if (this._renderingCanvas) {\n this._renderingCanvas.addEventListener(\"webglcontextlost\", callback, false);\n }\n }\n /**\n * Attach a new callback raised when context restored event is fired\n * @param callback defines the callback to call\n */\n attachContextRestoredEvent(callback) {\n if (this._renderingCanvas) {\n this._renderingCanvas.addEventListener(\"webglcontextrestored\", callback, false);\n }\n }\n /**\n * Get the current error code of the webGL context\n * @returns the error code\n * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError\n */\n getError() {\n return this._gl.getError();\n }\n _canRenderToFloatFramebuffer() {\n if (this._webGLVersion > 1) {\n return this._caps.colorBufferFloat;\n }\n return this._canRenderToFramebuffer(1);\n }\n _canRenderToHalfFloatFramebuffer() {\n if (this._webGLVersion > 1) {\n return this._caps.colorBufferFloat;\n }\n return this._canRenderToFramebuffer(2);\n }\n // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n _canRenderToFramebuffer(type) {\n const gl = this._gl;\n //clear existing errors\n // eslint-disable-next-line no-empty\n while (gl.getError() !== gl.NO_ERROR) { }\n let successful = true;\n const texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n const fb = gl.createFramebuffer();\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb);\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);\n successful = successful && status === gl.FRAMEBUFFER_COMPLETE;\n successful = successful && gl.getError() === gl.NO_ERROR;\n //try render by clearing frame buffer's color buffer\n if (successful) {\n gl.clear(gl.COLOR_BUFFER_BIT);\n successful = successful && gl.getError() === gl.NO_ERROR;\n }\n //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)\n if (successful) {\n //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n const readFormat = gl.RGBA;\n const readType = gl.UNSIGNED_BYTE;\n const buffer = new Uint8Array(4);\n gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);\n successful = successful && gl.getError() === gl.NO_ERROR;\n }\n //clean up\n gl.deleteTexture(texture);\n gl.deleteFramebuffer(fb);\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n //clear accumulated errors\n // eslint-disable-next-line no-empty\n while (!successful && gl.getError() !== gl.NO_ERROR) { }\n return successful;\n }\n /**\n * @internal\n */\n _getWebGLTextureType(type) {\n if (this._webGLVersion === 1) {\n switch (type) {\n case 1:\n return this._gl.FLOAT;\n case 2:\n return this._gl.HALF_FLOAT_OES;\n case 0:\n return this._gl.UNSIGNED_BYTE;\n case 8:\n return this._gl.UNSIGNED_SHORT_4_4_4_4;\n case 9:\n return this._gl.UNSIGNED_SHORT_5_5_5_1;\n case 10:\n return this._gl.UNSIGNED_SHORT_5_6_5;\n }\n return this._gl.UNSIGNED_BYTE;\n }\n switch (type) {\n case 3:\n return this._gl.BYTE;\n case 0:\n return this._gl.UNSIGNED_BYTE;\n case 4:\n return this._gl.SHORT;\n case 5:\n return this._gl.UNSIGNED_SHORT;\n case 6:\n return this._gl.INT;\n case 7: // Refers to UNSIGNED_INT\n return this._gl.UNSIGNED_INT;\n case 1:\n return this._gl.FLOAT;\n case 2:\n return this._gl.HALF_FLOAT;\n case 8:\n return this._gl.UNSIGNED_SHORT_4_4_4_4;\n case 9:\n return this._gl.UNSIGNED_SHORT_5_5_5_1;\n case 10:\n return this._gl.UNSIGNED_SHORT_5_6_5;\n case 11:\n return this._gl.UNSIGNED_INT_2_10_10_10_REV;\n case 12:\n return this._gl.UNSIGNED_INT_24_8;\n case 13:\n return this._gl.UNSIGNED_INT_10F_11F_11F_REV;\n case 14:\n return this._gl.UNSIGNED_INT_5_9_9_9_REV;\n case 15:\n return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;\n }\n return this._gl.UNSIGNED_BYTE;\n }\n /**\n * @internal\n */\n _getInternalFormat(format, useSRGBBuffer = false) {\n let internalFormat = useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA;\n switch (format) {\n case 0:\n internalFormat = this._gl.ALPHA;\n break;\n case 1:\n internalFormat = this._gl.LUMINANCE;\n break;\n case 2:\n internalFormat = this._gl.LUMINANCE_ALPHA;\n break;\n case 6:\n case 33322:\n case 36760:\n internalFormat = this._gl.RED;\n break;\n case 7:\n case 33324:\n case 36761:\n internalFormat = this._gl.RG;\n break;\n case 4:\n case 32852:\n case 36762:\n internalFormat = useSRGBBuffer ? this._glSRGBExtensionValues.SRGB : this._gl.RGB;\n break;\n case 5:\n case 32859:\n case 36763:\n internalFormat = useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA;\n break;\n }\n if (this._webGLVersion > 1) {\n switch (format) {\n case 8:\n internalFormat = this._gl.RED_INTEGER;\n break;\n case 9:\n internalFormat = this._gl.RG_INTEGER;\n break;\n case 10:\n internalFormat = this._gl.RGB_INTEGER;\n break;\n case 11:\n internalFormat = this._gl.RGBA_INTEGER;\n break;\n }\n }\n return internalFormat;\n }\n /**\n * @internal\n */\n _getRGBABufferInternalSizedFormat(type, format, useSRGBBuffer = false) {\n if (this._webGLVersion === 1) {\n if (format !== undefined) {\n switch (format) {\n case 0:\n return this._gl.ALPHA;\n case 1:\n return this._gl.LUMINANCE;\n case 2:\n return this._gl.LUMINANCE_ALPHA;\n case 4:\n return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB : this._gl.RGB;\n }\n }\n return this._gl.RGBA;\n }\n switch (type) {\n case 3:\n switch (format) {\n case 6:\n return this._gl.R8_SNORM;\n case 7:\n return this._gl.RG8_SNORM;\n case 4:\n return this._gl.RGB8_SNORM;\n case 8:\n return this._gl.R8I;\n case 9:\n return this._gl.RG8I;\n case 10:\n return this._gl.RGB8I;\n case 11:\n return this._gl.RGBA8I;\n default:\n return this._gl.RGBA8_SNORM;\n }\n case 0:\n switch (format) {\n case 6:\n return this._gl.R8;\n case 7:\n return this._gl.RG8;\n case 4:\n return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8 : this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.\n case 5:\n return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.\n case 8:\n return this._gl.R8UI;\n case 9:\n return this._gl.RG8UI;\n case 10:\n return this._gl.RGB8UI;\n case 11:\n return this._gl.RGBA8UI;\n case 0:\n return this._gl.ALPHA;\n case 1:\n return this._gl.LUMINANCE;\n case 2:\n return this._gl.LUMINANCE_ALPHA;\n default:\n return this._gl.RGBA8;\n }\n case 4:\n switch (format) {\n case 8:\n return this._gl.R16I;\n case 36760:\n return this._gl.R16_SNORM_EXT;\n case 36761:\n return this._gl.RG16_SNORM_EXT;\n case 36762:\n return this._gl.RGB16_SNORM_EXT;\n case 36763:\n return this._gl.RGBA16_SNORM_EXT;\n case 9:\n return this._gl.RG16I;\n case 10:\n return this._gl.RGB16I;\n case 11:\n return this._gl.RGBA16I;\n default:\n return this._gl.RGBA16I;\n }\n case 5:\n switch (format) {\n case 8:\n return this._gl.R16UI;\n case 33322:\n return this._gl.R16_EXT;\n case 33324:\n return this._gl.RG16_EXT;\n case 32852:\n return this._gl.RGB16_EXT;\n case 32859:\n return this._gl.RGBA16_EXT;\n case 9:\n return this._gl.RG16UI;\n case 10:\n return this._gl.RGB16UI;\n case 11:\n return this._gl.RGBA16UI;\n default:\n return this._gl.RGBA16UI;\n }\n case 6:\n switch (format) {\n case 8:\n return this._gl.R32I;\n case 9:\n return this._gl.RG32I;\n case 10:\n return this._gl.RGB32I;\n case 11:\n return this._gl.RGBA32I;\n default:\n return this._gl.RGBA32I;\n }\n case 7: // Refers to UNSIGNED_INT\n switch (format) {\n case 8:\n return this._gl.R32UI;\n case 9:\n return this._gl.RG32UI;\n case 10:\n return this._gl.RGB32UI;\n case 11:\n return this._gl.RGBA32UI;\n default:\n return this._gl.RGBA32UI;\n }\n case 1:\n switch (format) {\n case 6:\n return this._gl.R32F; // By default. Other possibility is R16F.\n case 7:\n return this._gl.RG32F; // By default. Other possibility is RG16F.\n case 4:\n return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.\n case 5:\n return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.\n default:\n return this._gl.RGBA32F;\n }\n case 2:\n switch (format) {\n case 6:\n return this._gl.R16F;\n case 7:\n return this._gl.RG16F;\n case 4:\n return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.\n case 5:\n return this._gl.RGBA16F;\n default:\n return this._gl.RGBA16F;\n }\n case 10:\n return this._gl.RGB565;\n case 13:\n return this._gl.R11F_G11F_B10F;\n case 14:\n return this._gl.RGB9_E5;\n case 8:\n return this._gl.RGBA4;\n case 9:\n return this._gl.RGB5_A1;\n case 11:\n switch (format) {\n case 5:\n return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.\n case 11:\n return this._gl.RGB10_A2UI;\n default:\n return this._gl.RGB10_A2;\n }\n }\n return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA8;\n }\n /**\n * Reads pixels from the current frame buffer. Please note that this function can be slow\n * @param x defines the x coordinate of the rectangle where pixels must be read\n * @param y defines the y coordinate of the rectangle where pixels must be read\n * @param width defines the width of the rectangle where pixels must be read\n * @param height defines the height of the rectangle where pixels must be read\n * @param hasAlpha defines whether the output should have alpha or not (defaults to true)\n * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels\n * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors\n */\n readPixels(x, y, width, height, hasAlpha = true, flushRenderer = true) {\n const numChannels = hasAlpha ? 4 : 3;\n const format = hasAlpha ? this._gl.RGBA : this._gl.RGB;\n const data = new Uint8Array(height * width * numChannels);\n if (flushRenderer) {\n this.flushFramebuffer();\n }\n this._gl.readPixels(x, y, width, height, format, this._gl.UNSIGNED_BYTE, data);\n return Promise.resolve(data);\n }\n /**\n * Gets a Promise<boolean> indicating if the engine can be instantiated (ie. if a webGL context can be found)\n */\n static get IsSupportedAsync() {\n return Promise.resolve(this.isSupported());\n }\n /**\n * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)\n */\n static get IsSupported() {\n return this.isSupported(); // Backward compat\n }\n /**\n * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)\n * @returns true if the engine can be created\n * @ignorenaming\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n static isSupported() {\n if (this._HasMajorPerformanceCaveat !== null) {\n return !this._HasMajorPerformanceCaveat; // We know it is performant so WebGL is supported\n }\n if (this._IsSupported === null) {\n try {\n const tempcanvas = AbstractEngine._CreateCanvas(1, 1);\n const gl = tempcanvas.getContext(\"webgl\") || tempcanvas.getContext(\"experimental-webgl\");\n this._IsSupported = gl != null && !!window.WebGLRenderingContext;\n }\n catch (e) {\n this._IsSupported = false;\n }\n }\n return this._IsSupported;\n }\n /**\n * Gets a boolean indicating if the engine can be instantiated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)\n */\n static get HasMajorPerformanceCaveat() {\n if (this._HasMajorPerformanceCaveat === null) {\n try {\n const tempcanvas = AbstractEngine._CreateCanvas(1, 1);\n const gl = tempcanvas.getContext(\"webgl\", { failIfMajorPerformanceCaveat: true }) ||\n tempcanvas.getContext(\"experimental-webgl\", { failIfMajorPerformanceCaveat: true });\n this._HasMajorPerformanceCaveat = !gl;\n }\n catch (e) {\n this._HasMajorPerformanceCaveat = false;\n }\n }\n return this._HasMajorPerformanceCaveat;\n }\n}\nThinEngine._TempClearColorUint32 = new Uint32Array(4);\nThinEngine._TempClearColorInt32 = new Int32Array(4);\n/** Use this array to turn off some WebGL2 features on known buggy browsers version */\nThinEngine.ExceptionList = [\n { key: \"Chrome/63.0\", capture: \"63\\\\.0\\\\.3239\\\\.(\\\\d+)\", captureConstraint: 108, targets: [\"uniformBuffer\"] },\n { key: \"Firefox/58\", capture: null, captureConstraint: null, targets: [\"uniformBuffer\"] },\n { key: \"Firefox/59\", capture: null, captureConstraint: null, targets: [\"uniformBuffer\"] },\n { key: \"Chrome/72.+?Mobile\", capture: null, captureConstraint: null, targets: [\"vao\"] },\n { key: \"Chrome/73.+?Mobile\", capture: null, captureConstraint: null, targets: [\"vao\"] },\n { key: \"Chrome/74.+?Mobile\", capture: null, captureConstraint: null, targets: [\"vao\"] },\n { key: \"Mac OS.+Chrome/71\", capture: null, captureConstraint: null, targets: [\"vao\"] },\n { key: \"Mac OS.+Chrome/72\", capture: null, captureConstraint: null, targets: [\"vao\"] },\n { key: \"Mac OS.+Chrome\", capture: null, captureConstraint: null, targets: [\"uniformBuffer\"] },\n { key: \"Chrome/12\\\\d\\\\..+?Mobile\", capture: null, captureConstraint: null, targets: [\"uniformBuffer\"] },\n // desktop osx safari 15.4\n { key: \".*AppleWebKit.*(15.4).*Safari\", capture: null, captureConstraint: null, targets: [\"antialias\", \"maxMSAASamples\"] },\n // mobile browsers using safari 15.4 on ios\n { key: \".*(15.4).*AppleWebKit.*Safari\", capture: null, captureConstraint: null, targets: [\"antialias\", \"maxMSAASamples\"] },\n];\n// eslint-disable-next-line @typescript-eslint/naming-convention\nThinEngine._ConcatenateShader = _ConcatenateShader;\n// Statics\nThinEngine._IsSupported = null;\nThinEngine._HasMajorPerformanceCaveat = null;\n"],"mappings":"AAAA,SAASA,qBAAqB,EAAEC,sBAAsB,EAAEC,mBAAmB,EAAEC,wBAAwB,EAAEC,uBAAuB,EAAEC,WAAW,EAAEC,oCAAoC,EAAEC,cAAc,EAAEC,oBAAoB,EAAEC,iBAAiB,EAAEC,yBAAyB,QAAS,2BAA2B;AACzS,SAASC,SAAS,QAAQ,uCAAuC;AACjE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,oBAAoB,QAAQ,kCAAkC;AACvE,SAASC,qBAAqB,QAAQ,mCAAmC;AACzE,SAASC,eAAe,QAAQ,oCAAoC;AACpE,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,cAAc,QAAQ,qBAAqB;AAEpD,SAASC,oBAAoB,QAAQ,iCAAiC;AACtE,SAASC,eAAe,EAAEC,cAAc,EAAEC,gBAAgB,QAAQ,0CAA0C;AAC5G,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