Skip to main content

Composite texture loader

Describe a texture once. Resolve its image levels as a unit.

TextureLoader reads a JSON manifest for a single image or mip chain, resolves member URLs, and returns a normalized Texture object. It keeps file organization out of the rendering code.

The manifest path

Read the manifest. Resolve the members. Return one texture.

A composite texture can be a single image, an explicit list of mip levels, or a template-driven sequence. The loader turns each supported description into the same schema-level texture shape.

Input

JSON image-texture manifest

Resolve

Relative member URLs and optional base URL

Decode

Member images through ImageLoader

Output

Texture with ordered TextureLevel entries

From-v5.0

A loader for image-based composite textures described by a JSON manifest.

Detailed guide

Manifest and texture output details

The reference below covers manifest forms, URL resolution, member decoding, mip levels, options, and normalized output fields.

TextureLoader
File FormatJSON manifest
File Extension.json
File TypeText
Data FormatTexture
Supported APIsload, parse

Usage​

import {load} from '@loaders.gl/core';
import {TextureLoader} from '@loaders.gl/images/texture';

const image = await load('texture.image-texture.json', TextureLoader);

Member images are parsed with ImageLoader by default:

import {load} from '@loaders.gl/core';
import {TextureLoader} from '@loaders.gl/images/texture';

const texture = await load('texture.image-texture.json', TextureLoader);

Member images use the same runtime-dependent bitmap contract as ImageLoader: native ImageBitmap in browsers and the installed Node.js ImageBitmap polyfill when @loaders.gl/core/polyfills is present.

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​

OptionTypeDefaultDescription
core.baseUrlstring-Base URL used to resolve relative member paths when parsing an in-memory manifest.

Output​

Returns a Texture with:

  • shape: 'texture'
  • type: '2d'
  • data: one TextureLevel per mip level

For image-backed levels, TextureLevel.imageBitmap is populated when available and TextureLevel.data is an empty Uint8Array.