LoadingManager.d.ts 1.5 KB

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