import * as THREE from "three"; /** * Texture fields that carry sRGB color data. * * When a texture is used for one of these roles, its `colorSpace` must be set * to `SRGBColorSpace` so Three.js applies the sRGB-to-linear decode on * sampling. All other texture roles (normal, metallic-roughness, occlusion, * thickness, transmission, roughness maps) remain `LinearSRGBColorSpace`. */ declare const SRGB_TEXTURE_ROLES: Set; /** * Manages loading, caching, and lifecycle of all Studio mode textures. * * The TextureCache is the **sole owner** of all THREE.Texture objects used by * Studio mode. Materials reference textures but never dispose them directly. * Only TextureCache.dispose() / disposeFull() disposes GPU texture resources. * * Resolution order for texture reference strings: * 1. `data:` prefix -- treat as data URI, load directly * 2. Otherwise -- treat as URL, resolve relative to HTML page * * Features: * - In-flight promise deduplication (no duplicate loads for the same key) * - Correct colorSpace assignment per texture semantic role * - GPU resource tracking via gpuTracker */ declare class TextureCache { /** Textures cache (disposed on clear/dispose, rebuilt per shape data) */ private _cache; /** In-flight load promises keyed by cache key */ private _inflight; /** THREE.TextureLoader instance (created lazily) */ private _textureLoader; /** Whether this cache has been fully disposed */ private _disposed; /** Max anisotropic filtering level. * Default 16 covers most GPUs; clamped by the driver if unsupported. */ maxAnisotropy: number; /** * Resolve a texture reference string and return a cached or newly loaded * THREE.Texture with the correct colorSpace set. * * @param ref - Texture reference string (table key, data URI, or URL) * @param textureRole - The texture role name (MaterialAppearance field name or proxy role) * (e.g. "baseColorTexture", "normalTexture"). Used to determine colorSpace. * @returns The resolved THREE.Texture, or null if the reference is invalid * or loading fails */ get(ref: string, textureRole: string): Promise; /** * Dispose textures (called on viewer.clear() when shape data is replaced). * * Disposes all textures in the cache and clears in-flight promises. */ dispose(): void; /** * Dispose all textures. * * Called on viewer.dispose() when the viewer is fully torn down. * After this call, the TextureCache cannot be used again. */ disposeFull(): void; /** * Load a texture from a data URI string. */ private _getFromDataUri; /** * Load a texture from a URL (resolved relative to the HTML page). */ private _getFromUrl; /** * Load a texture from a source (URL or data URI), cache it, and return it. * * Deduplicates in-flight loads for the same cache key. * * @param cacheKey - Key for the user cache * @param source - URL or data URI to load from * @param colorSpace - Color space to assign to the loaded texture * @returns The loaded texture, or null on failure */ private _loadAndCache; /** * Perform the actual texture load via THREE.TextureLoader. * * THREE.TextureLoader handles both URLs and data URIs. */ private _doLoad; /** * Get or create the THREE.TextureLoader (lazy initialization). */ private _ensureTextureLoader; } /** * Get the correct color space for a Three.js material map property name. * * sRGB maps (color data): map, emissiveMap, sheenColorMap, specularColorMap * Linear maps (non-color data): everything else (normalMap, roughnessMap, etc.) * * @param mapName - Three.js material property name (e.g., "map", "normalMap") * @returns THREE.SRGBColorSpace or THREE.LinearSRGBColorSpace */ declare function getColorSpaceForMap(mapName: string): THREE.ColorSpace; export { TextureCache, SRGB_TEXTURE_ROLES, getColorSpaceForMap };