TextureLoader
A loader for image-based composite textures described by a JSON manifest.
| Loader | Characteristic |
|---|---|
| File Format | JSON manifest |
| File Extension | .json |
| File Type | Text |
| Data Format | Texture |
| Supported APIs | load, parse |
Usage
import {load} from '@loaders.gl/core';
import {TextureLoader} from '@loaders.gl/textures';
const image = await load('texture.image-texture.json', TextureLoader);
Member images are parsed with ImageLoader by default. If you call load() with a loader array, those additional loaders are also available for manifest members:
import {load} from '@loaders.gl/core';
import {TextureLoader, CompressedTextureLoader, BasisLoader} from '@loaders.gl/textures';
const texture = await load('texture.image-texture.json', [
TextureLoader,
CompressedTextureLoader,
BasisLoader
]);
This allows manifest members to use image formats handled by ImageLoader as well as compressed member formats handled by the additional loaders.
Manifest
Single image:
{
"shape": "image-texture",
"image": "texture.png"
}
Mipmapped image:
{
"shape": "image-texture",
"mipmaps": ["texture-0.png", "texture-1.png", "texture-2.png"]
}
Template-driven mipmapped image:
{
"shape": "image-texture",
"mipLevels": "auto",
"template": "texture-{lod}.png"
}
Template placeholders are validated strictly. Supported placeholders for TextureLoader are {lod} only.
Use \\{ and \\} to include literal braces in filenames.
Options
| Option | Type | Default | Description |
|---|---|---|---|
core.baseUrl | string | - | Base URL used to resolve relative member paths when parsing an in-memory manifest. |
Output
Returns a Texture with:
shape: 'texture'type: '2d'data: oneTextureLevelper mip level
For image-backed levels, TextureLevel.imageBitmap is populated when available and TextureLevel.data is an empty Uint8Array.