@loaders.gl/textures module contains loaders for compressed textures. More specifically it contains loaders and writers for compressed texture container formats, including KTX, DDS and PVR. It also supports supercompressed Basis textures.
Note that a texture is more complex than an image. A texture typically has many subimages. A texture can represent a single logical image but can also be a texture cube, a texture array etc representing many logical images. In addition, each "image" typically has many mipmap levels.
In addition, in compressed textures each mipmap image is compressed opaquely into a format that can only be understood by certain GPUs.
Basis encoded textures are super compressed. A more recent addition, they can be efficiently transcoded on the client into actual compressed texture formats appropriate for each device and are therefore quite convenient to use.
npm install @loaders.gl/textures
npm install @loaders.gl/core
BasisLoader returns Array of Array of ArrayBuffer
BasisLoader for more details on options etc.
The textures API offers functions to load "composite" images for WebGL textures, cube textures and image mip levels.
These functions take a
getUrl parameter that enables the app to supply the url for each "sub-image", and return a single promise enabling applications to for instance load all the faces of a cube texture, with one image for each mip level for each face in a single async operation.
|Load a single image|
|Load an array of images, e.g. for a |
|Load a map of 6 images for the faces of a cube map, or a map of 6 arrays of images for the mip levels of the 6 faces.|
As with all loaders.gl functions, while these functions are intended for use in WebGL applications, they do not call any WebGL functions, and do not actually create any WebGL textures..