LoadingManager.d.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { Geometry } from './../core/Geometry';
  2. import { Material } from './../materials/Material';
  3. import { Loader } from './Loader';
  4. /**
  5. * A loader for loading objects in JSON format.
  6. */
  7. export class JSONLoader extends Loader {
  8. constructor(manager?: LoadingManager);
  9. manager: LoadingManager;
  10. withCredentials: boolean;
  11. load(
  12. url: string,
  13. onLoad?: (geometry: Geometry, materials: Material[]) => void,
  14. onProgress?: (event: ProgressEvent) => void,
  15. onError?: (event: ErrorEvent) => void
  16. ): void;
  17. setTexturePath(value: string): void;
  18. parse(
  19. json: any,
  20. texturePath?: string
  21. ): { geometry: Geometry; materials?: Material[] };
  22. }
  23. export const DefaultLoadingManager: LoadingManager;
  24. /**
  25. * Handles and keeps track of loaded and pending data.
  26. */
  27. export class LoadingManager {
  28. constructor(
  29. onLoad?: () => void,
  30. onProgress?: (url: string, loaded: number, total: number) => void,
  31. onError?: () => void
  32. );
  33. onStart?: (url: string, loaded: number, total: number) => void;
  34. /**
  35. * Will be called when load starts.
  36. * The default is a function with empty body.
  37. */
  38. onLoad: () => void;
  39. /**
  40. * Will be called while load progresses.
  41. * The default is a function with empty body.
  42. */
  43. onProgress: (item: any, loaded: number, total: number) => void;
  44. /**
  45. * Will be called when each element in the scene completes loading.
  46. * The default is a function with empty body.
  47. */
  48. onError: (url: string) => void;
  49. /**
  50. * If provided, the callback will be passed each resource URL before a request is sent.
  51. * The callback may return the original URL, or a new URL to override loading behavior.
  52. * This behavior can be used to load assets from .ZIP files, drag-and-drop APIs, and Data URIs.
  53. * @param callback URL modifier callback. Called with url argument, and must return resolvedURL.
  54. */
  55. setURLModifier(callback?: (url: string) => string): void;
  56. /**
  57. * Given a URL, uses the URL modifier callback (if any) and returns a resolved URL.
  58. * If no URL modifier is set, returns the original URL.
  59. * @param url the url to load
  60. */
  61. resolveURL(url: string): string;
  62. itemStart(url: string): void;
  63. itemEnd(url: string): void;
  64. itemError(url: string): void;
  65. }
粤ICP备19079148号