UNPKG

1.13 kBTypeScriptView Raw
1import { LoadingManager } from "./LoadingManager.js";
2
3/**
4 * Base class for implementing loaders.
5 */
6export class Loader<TData = unknown, TUrl = string> {
7 constructor(manager?: LoadingManager);
8
9 /**
10 * @default 'anonymous'
11 */
12 crossOrigin: string;
13
14 /**
15 * @default false
16 */
17 withCredentials: boolean;
18
19 /**
20 * @default ''
21 */
22 path: string;
23
24 /**
25 * @default ''
26 */
27 resourcePath: string;
28 manager: LoadingManager;
29
30 /**
31 * @default {}
32 */
33 requestHeader: { [header: string]: string };
34
35 load(
36 url: TUrl,
37 onLoad: (data: TData) => void,
38 onProgress?: (event: ProgressEvent) => void,
39 onError?: (err: unknown) => void,
40 ): void;
41 loadAsync(url: TUrl, onProgress?: (event: ProgressEvent) => void): Promise<TData>;
42
43 setCrossOrigin(crossOrigin: string): this;
44 setWithCredentials(value: boolean): this;
45 setPath(path: string): this;
46 setResourcePath(resourcePath: string): this;
47 setRequestHeader(requestHeader: { [header: string]: string }): this;
48
49 static DEFAULT_MATERIAL_NAME: string;
50}