import type { DataTexture, Group, Loader, LoadingManager, Texture } from 'three'; import type { GLTF } from 'three/examples/jsm/loaders/GLTFLoader'; type BaseOptions = { url: string; onProgress?: (event: ProgressEvent) => void; onError?: (event: ErrorEvent) => void; customLoadingManager?: LoadingManager; }; type LoadGLTFOptions = { isCache?: boolean; isBackward?: boolean; autoBackward?: boolean; onLoad?: (gltf: GLTF) => void; draco?: boolean; dracoPath?: string; simplifierRatio?: number; } & BaseOptions; type loadGLTFToBuffer = { isBackward?: boolean; autoBackward?: boolean; draco?: boolean; dracoPath?: string; simplifierRatio?: number; url: string; }; type LoadTextureOptions = { onLoad?: (texture: Texture) => void; } & BaseOptions; type LoadFBXOptions = { isCache?: boolean; onLoad?: (scene: Group) => void; } & BaseOptions; /** * @file LoaderModule * main solve * 1. 统一load使用 * 2. gltf load资源缓存 「1.资源可以通过http缓存 2.gltf解析结果缓存」 * 3. load进度规范管理 * 4. 批量glb 多线程预加载 todo */ declare class LoaderModule { private gltfLoader; private dracoLoader; constructor(); cleanCache(): void; /** * load GLTF To Buffer * @param args * @returns */ loadGLTFToBuffer(args: loadGLTFToBuffer): Promise; /** * 初始化或更新DRACO解码器 * @param decoderPath DRACO解码器路径 */ private setupDracoLoader; /** * load gltf * note: isBackward = true , onProgress is not work * TODO 资源缓存保持和http缓存具有一致的清除机制 「但是单方面目前做不到,库项目使用Service Worker目前不太友好」 * @param args * @returns */ loadGLTF(args: LoadGLTFOptions): Promise; /** * load fbx * @param args * @returns */ loadFbx(args: LoadFBXOptions): Promise; /** * load texture * @param args * @returns */ loadTexture(args: LoadTextureOptions): Promise; /** * loadRgbe * @param args * @returns */ loadRgbe(args: LoadTextureOptions): Promise; extend(load: Loader): Loader; } export default LoaderModule;