import { TextureOptions, TexturePreset } from "./texturePresets.js"; import { Loader, Texture } from "three"; //#region src/loaders/TextureLoader.d.ts /** * Options for loading a texture. */ interface TextureLoaderOptions { /** Texture preset or custom options. Overrides loader and global defaults. */ texture?: TexturePreset | TextureOptions; } /** * 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 (global default) * 3. 'pixel-art' (system default) * * @example * ```typescript * // 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' * ``` */ declare class TextureLoader extends Loader { private static internalLoader; private static cache; /** * Texture options for this loader class. * When undefined, falls through to TextureConfig.options. */ static options: TexturePreset | TextureOptions | undefined; /** * Instance-level preset override. * Set via R3F's useLoader extension callback. * * @example * ```tsx * // Override preset for specific textures via extension * const texture = useLoader(TextureLoader, '/ui.png', (loader) => { * loader.preset = 'smooth' * }) * ``` */ preset: TexturePreset | TextureOptions | undefined; /** * Load a texture (callback style for R3F useLoader compatibility). * Presets are automatically applied. */ load(url: string, onLoad?: (texture: Texture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): Texture; /** * Load a texture asynchronously. * Presets are automatically applied. */ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise; /** * Load a texture from a URL (static method for Three.js usage). * Results are cached by URL and resolved options. */ static load(url: string, options?: TextureLoaderOptions): Promise; /** * Get cache key including resolved options. */ private static getCacheKey; /** * Load without caching. */ private static loadUncached; /** * Preload multiple textures. */ static preload(urls: string[], options?: TextureLoaderOptions): Promise; /** * Clear the cache. */ static clearCache(): void; } /** * Apply hierarchical texture presets to a texture. * * Useful when you need to override presets after loading, or when * using Three's TextureLoader directly. * * Hierarchy (highest to lowest priority): * 1. instanceOptions (per-call override) * 2. loaderOptions (loader-level default) * 3. TextureConfig.options (global default) * 4. 'pixel-art' (system default) * * @example * ```typescript * // Override presets on an already-loaded texture * const texture = await TextureLoader.load('/sprite.png') * applyHierarchicalPresets(texture, 'smooth') // Override to smooth filtering * ``` */ declare function applyHierarchicalPresets(texture: Texture, instanceOptions?: TexturePreset | TextureOptions, loaderOptions?: TexturePreset | TextureOptions): void; //#endregion export { TextureLoader, TextureLoaderOptions, applyHierarchicalPresets }; //# sourceMappingURL=TextureLoader.d.ts.map