Creates an instance of Texture.
Optionalgl: WebGL2RenderingContextThe WebGL2 rendering context.
OptionaltextureUri: stringThe URI of the image to load.
Protected_Protected_The WebGL texture object.
Protected_The height of the texture in pixels.
Protected_A flag to indicate if the texture is currently in a bound state.
Protected_A promise that resolves when the texture is fully loaded.
Protected_Protected_Protected_The width of the texture in pixels.
Protected OptionalglThe WebGL2 rendering context.
ProtectedimageThe HTML image element that contains the texture data.
ProtectedisIndicates whether the image data has been loaded.
ProtectedisIndicates whether the texture is currently in the process of loading.
The magnification filter.
The minification filter.
OptionaltextureThe URI of the image to load.
The texture wrap mode for the S (horizontal) axis.
The texture wrap mode for the T (vertical) axis.
Gets the WebGLTexture object.
Gets the height of the texture.
Checks if the image data has been successfully loaded into the HTMLImageElement.
Gets the width of the texture.
Binds the texture to the TEXTURE_2D target if it is not already bound.
ProtectedcreateProtectedCreates the WebGLTexture object from the loaded image data.
The WebGL2 rendering context.
ProtecteddeserializeDestroys the WebGL texture to free up GPU memory.
Populates the texture object from a JSON serializable object.
ProtectedgetReads the pixels from the texture and returns them as a Uint8Array. NOTE: This function requires the texture to be attached to a framebuffer object (FBO). A more complete implementation would handle FBO creation and binding.
The width of the texture to read.
The height of the texture to read.
A Uint8Array containing the pixel data, or null if an error occurred.
Loads an image from the provided URI and creates the WebGL texture.
A Promise that resolves when the image is fully loaded and the WebGL texture is created.
Re-uploads the texture data to the GPU. This is useful if the underlying image or data has changed.
ProtectedserializeSets the WebGL2 rendering context for the texture.
The WebGL2 rendering context.
Sets the magnification filter for the texture.
The magnification filter to apply.
Sets the minification filter for the texture.
The minification filter to apply.
Sets a sub-region of the texture's pixels.
The x-coordinate of the sub-region to update.
The y-coordinate of the sub-region to update.
The width of the sub-region.
The height of the sub-region.
The pixel data to upload.
Sets the texture filtering and wrapping parameters for the texture. This method applies the values stored in the class properties to the GPU.
Sets the texture wrapping mode for the S axis.
The wrapping mode to apply.
Sets the texture wrapping mode for the T axis.
The wrapping mode to apply.
Converts the texture object to a JSON serializable format.
Unbinds the texture from the TEXTURE_2D target if it is currently bound.
StaticcreateCreates and returns a texture with a specified color and size. This is useful for creating fallback textures or solid colors.
The WebGL2 rendering context.
The width of the texture.
The height of the texture.
Optionalcolor: null | Uint8Array<ArrayBufferLike> = nullAn optional array of color data. If not provided, a single white pixel is used.
A new Texture instance.
StaticcreateCreates a new texture specifically for depth information (e.g., for shadow mapping).
The WebGL2 rendering context.
The width of the texture.
The height of the texture.
A new Texture instance configured as a depth texture.
A class to manage the loading, creation, and binding of 2D textures for use in WebGL.