UNPKG

@motion-core/motion-gpu

Version:

Framework-agnostic WebGPU runtime for fullscreen WGSL shaders with explicit Svelte, React, and Vue adapter entrypoints.

130 lines 3.51 kB
import type { TextureUpdateMode } from './types.js'; /** * Options controlling bitmap decode behavior. */ export interface TextureDecodeOptions { /** * Controls color-space conversion during decode. */ colorSpaceConversion?: 'default' | 'none'; /** * Controls alpha premultiplication during decode. */ premultiplyAlpha?: 'default' | 'none' | 'premultiply'; /** * Controls bitmap orientation during decode. */ imageOrientation?: 'none' | 'flipY'; } /** * Options controlling URL-based texture loading and decode behavior. */ export interface TextureLoadOptions { /** * Desired texture color space. */ colorSpace?: 'srgb' | 'linear'; /** * Fetch options forwarded to `fetch`. */ requestInit?: RequestInit; /** * Decode options forwarded to `createImageBitmap`. */ decode?: TextureDecodeOptions; /** * Optional cancellation signal for this request. */ signal?: AbortSignal; /** * Optional runtime update strategy metadata attached to loaded textures. */ update?: TextureUpdateMode; /** * Optional runtime flip-y metadata attached to loaded textures. */ flipY?: boolean; /** * Optional runtime premultiplied-alpha metadata attached to loaded textures. */ premultipliedAlpha?: boolean; /** * Optional runtime mipmap metadata attached to loaded textures. */ generateMipmaps?: boolean; } /** * Loaded texture payload returned by URL loaders. */ export interface LoadedTexture { /** * Source URL. */ url: string; /** * Decoded bitmap source. */ source: ImageBitmap; /** * Bitmap width in pixels. */ width: number; /** * Bitmap height in pixels. */ height: number; /** * Effective color space. */ colorSpace: 'srgb' | 'linear'; /** * Effective runtime update strategy. */ update?: TextureUpdateMode; /** * Effective runtime flip-y metadata. */ flipY?: boolean; /** * Effective runtime premultiplied-alpha metadata. */ premultipliedAlpha?: boolean; /** * Effective runtime mipmap metadata. */ generateMipmaps?: boolean; /** * Releases bitmap resources. */ dispose: () => void; } /** * Checks whether error represents abort cancellation. */ export declare function isAbortError(error: unknown): boolean; /** * Builds deterministic resource cache key from full URL IO config. */ export declare function buildTextureResourceCacheKey(url: string, options?: TextureLoadOptions): string; /** * Clears the internal texture resource cache. */ export declare function clearTextureBlobCache(): void; /** * Loads a single texture from URL and converts it to an `ImageBitmap`. * * @param url - Texture URL. * @param options - Loading options. * @returns Loaded texture object. * @throws {Error} When runtime does not support `createImageBitmap` or request fails. */ export declare function loadTextureFromUrl(url: string, options?: TextureLoadOptions): Promise<LoadedTexture>; /** * Loads many textures in parallel from URLs. * * @param urls - Texture URLs. * @param options - Shared loading options. * @returns Promise resolving to loaded textures in input order. */ export declare function loadTexturesFromUrls(urls: string[], options?: TextureLoadOptions): Promise<LoadedTexture[]>; //# sourceMappingURL=texture-loader.d.ts.map