LoadingManager.d.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { Loader } from './Loader';
  2. export const DefaultLoadingManager: LoadingManager;
  3. /**
  4. * Handles and keeps track of loaded and pending data.
  5. */
  6. export class LoadingManager {
  7. constructor(
  8. onLoad?: () => void,
  9. onProgress?: ( url: string, loaded: number, total: number ) => void,
  10. onError?: ( url: string ) => void
  11. );
  12. onStart?: ( url: string, loaded: number, total: number ) => void;
  13. /**
  14. * Will be called when load starts.
  15. * The default is a function with empty body.
  16. */
  17. onLoad: () => void;
  18. /**
  19. * Will be called while load progresses.
  20. * The default is a function with empty body.
  21. */
  22. onProgress: ( item: any, loaded: number, total: number ) => void;
  23. /**
  24. * Will be called when each element in the scene completes loading.
  25. * The default is a function with empty body.
  26. */
  27. onError: ( url: string ) => void;
  28. /**
  29. * If provided, the callback will be passed each resource URL before a request is sent.
  30. * The callback may return the original URL, or a new URL to override loading behavior.
  31. * This behavior can be used to load assets from .ZIP files, drag-and-drop APIs, and Data URIs.
  32. * @param callback URL modifier callback. Called with url argument, and must return resolvedURL.
  33. */
  34. setURLModifier( callback?: ( url: string ) => string ): this;
  35. /**
  36. * Given a URL, uses the URL modifier callback (if any) and returns a resolved URL.
  37. * If no URL modifier is set, returns the original URL.
  38. * @param url the url to load
  39. */
  40. resolveURL( url: string ): string;
  41. itemStart( url: string ): void;
  42. itemEnd( url: string ): void;
  43. itemError( url: string ): void;
  44. // handlers
  45. addHandler( regex: RegExp, loader: Loader ): this;
  46. removeHandler( regex: RegExp ): this;
  47. getHandler( file: string ): Loader | null;
  48. }