Skip to content

Defined in: packages/three-flatland/src/loaders/TextureLoader.ts:39

Texture loader with hierarchical preset support.

Extends Three.js’s Loader class for compatibility with R3F’s useLoader. Automatically applies texture presets based on the hierarchy:

  1. TextureLoader.options (static loader default)
  2. TextureConfig.options (texture-specific default)
  3. FlatlandConfig.options (library-wide default)
  4. ‘pixel-art’ (system default)
// Three.js usage - static API
const texture = await TextureLoader.load('/sprites/player.png')
// R3F usage - works with useLoader
import { TextureLoader } from 'three-flatland/react'
const texture = useLoader(TextureLoader, '/sprite.png')
// Presets are automatically applied!
// Override presets for specific textures
const smoothTexture = await TextureLoader.load('/ui.png', { texture: 'smooth' })
// Set loader-level default
TextureLoader.options = 'smooth'

new TextureLoader(manager?): TextureLoader

Defined in: three.js/loaders/Loader:TextureLoader 

LoadingManager 

TextureLoader

Loader<Texture>.constructor

crossOrigin: string

Defined in: three.js/loaders/Loader:crossOrigin 

'anonymous'

Loader.crossOrigin


manager: LoadingManager 

Defined in: three.js/loaders/Loader:manager 

Loader.manager


path: string

Defined in: three.js/loaders/Loader:path 

''

Loader.path


preset: TexturePreset | TextureOptions | undefined = undefined

Defined in: packages/three-flatland/src/loaders/TextureLoader.ts:61

Instance-level preset override. Set via R3F’s useLoader extension callback.

// Override preset for specific textures via extension
const texture = useLoader(TextureLoader, '/ui.png', (loader) => {
loader.preset = 'smooth'
})

requestHeader: object

Defined in: three.js/loaders/Loader:requestHeader 

[header: string]: string

{}

Loader.requestHeader


resourcePath: string

Defined in: three.js/loaders/Loader:resourcePath 

''

Loader.resourcePath


withCredentials: boolean

Defined in: three.js/loaders/Loader:withCredentials 

false

Loader.withCredentials


static DEFAULT_MATERIAL_NAME: string

Defined in: three.js/loaders/Loader:DEFAULT_MATERIAL_NAME 

Loader.DEFAULT_MATERIAL_NAME


static options: TexturePreset | TextureOptions | undefined = undefined

Defined in: packages/three-flatland/src/loaders/TextureLoader.ts:47

Texture options for this loader class. When undefined, falls through to TextureConfig.options.

abort(): this

Defined in: three.js/loaders/Loader:abort 

this

Loader.abort


load(url, onLoad?, onProgress?, onError?): Texture 

Defined in: packages/three-flatland/src/loaders/TextureLoader.ts:67

Load a texture (callback style for R3F useLoader compatibility). Presets are automatically applied.

string

(texture) => void

(event) => void

(err) => void

Texture 

Loader.load


loadAsync(url, onProgress?): Promise<Texture <unknown, TextureEventMap >>

Defined in: packages/three-flatland/src/loaders/TextureLoader.ts:91

Load a texture asynchronously. Presets are automatically applied.

string

(event) => void

Promise<Texture <unknown, TextureEventMap >>

Loader.loadAsync


setCrossOrigin(crossOrigin): this

Defined in: three.js/loaders/Loader:setCrossOrigin 

string

this

Loader.setCrossOrigin


setPath(path): this

Defined in: three.js/loaders/Loader:setPath 

string

this

Loader.setPath


setRequestHeader(requestHeader): this

Defined in: three.js/loaders/Loader:setRequestHeader 

this

Loader.setRequestHeader


setResourcePath(resourcePath): this

Defined in: three.js/loaders/Loader:setResourcePath 

string

this

Loader.setResourcePath


setWithCredentials(value): this

Defined in: three.js/loaders/Loader:setWithCredentials 

boolean

this

Loader.setWithCredentials


static clearCache(): void

Defined in: packages/three-flatland/src/loaders/TextureLoader.ts:155

Clear the cache.

void


static load(url, options?): Promise<Texture <unknown, TextureEventMap >>

Defined in: packages/three-flatland/src/loaders/TextureLoader.ts:105

Load a texture from a URL (static method for Three.js usage). Results are cached by URL and resolved options.

string

TextureLoaderOptions

Promise<Texture <unknown, TextureEventMap >>


static preload(urls, options?): Promise<Texture <unknown, TextureEventMap >[]>

Defined in: packages/three-flatland/src/loaders/TextureLoader.ts:148

Preload multiple textures.

string[]

TextureLoaderOptions

Promise<Texture <unknown, TextureEventMap >[]>