AssetManager.d.ts 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import { Object3D, Material, Texture, AnimationClip } from 'three';
  2. import { AudioAsset } from '../Model/AudioAsset';
  3. declare type AssetConfig = {
  4. preload?: boolean;
  5. keepLoaded?: boolean;
  6. override?: boolean;
  7. };
  8. declare class AssetManagerClass {
  9. private _assets;
  10. private _assetConfigs;
  11. private _assetPaths;
  12. private _loadingAssets;
  13. get assets(): {
  14. [uuid: string]: Object3D<import("three").Event> | Texture | Material | AnimationClip | AudioAsset;
  15. };
  16. get assetConfigs(): {
  17. [uuid: string]: AssetConfig;
  18. };
  19. get assetPaths(): {
  20. [uuid: string]: string;
  21. };
  22. onRegisterAsset(callback: (asset: Object3D | AudioAsset | Material | Texture | AnimationClip) => void): {
  23. stop: () => void;
  24. };
  25. onRemoveAsset(callback: (asset: Object3D | AudioAsset | Material | Texture | AnimationClip) => void): {
  26. stop: () => void;
  27. };
  28. onClearAssets(callback: (asset: Object3D | AudioAsset | Material | Texture | AnimationClip) => void): {
  29. stop: () => void;
  30. };
  31. onSetAssetConfig(callback: (uuid: string, config: AssetConfig) => void): {
  32. stop: () => void;
  33. };
  34. onRemoveAssetConfig(callback: (uuid: string, config: AssetConfig) => void): {
  35. stop: () => void;
  36. };
  37. onLoadAssetConfigs(callback: (uuid: string, config: AssetConfig) => void): {
  38. stop: () => void;
  39. };
  40. onSetAssetPath(callback: (uuid: string, assetPath: string) => void): {
  41. stop: () => void;
  42. };
  43. onSetAssetPaths(callback: (paths: {
  44. [uuid: string]: string;
  45. }) => void): {
  46. stop: () => void;
  47. };
  48. onRemoveAssetPath(callback: (uuid: string, assetPath: string) => void): {
  49. stop: () => void;
  50. };
  51. setAssetConfig(uuid: string, config: {
  52. preload?: boolean;
  53. keepLoaded?: boolean;
  54. override?: boolean;
  55. }): void;
  56. getAssetConfig(uuid: string): AssetConfig;
  57. removeAssetConfig(uuid: string): void;
  58. setAssetPath(uuid: string, assetPath: string): void;
  59. removeAssetPath(uuid: string): void;
  60. setAssetPaths(paths: {
  61. [uuid: string]: string;
  62. }): void;
  63. getAssetPath(uuid: string): string | undefined;
  64. registerAsset(asset: Object3D | AudioAsset | Material | Texture | AnimationClip): void;
  65. loadAsset(uuid: string): Promise<Object3D<import("three").Event> | Texture | Material | AnimationClip | AudioAsset | undefined>;
  66. private getExtension;
  67. getAsset(uuid: string): Object3D<import("three").Event> | Texture | Material | AnimationClip | AudioAsset;
  68. private loadObject;
  69. private loadObjectFunction;
  70. private loadNestedPrefabs;
  71. private loadAudio;
  72. private loadAudioFunction;
  73. private loadAnimation;
  74. private loadAnimationFunction;
  75. private loadMaterial;
  76. private loadMaterialFunction;
  77. private loadTexture;
  78. private loadTextureFunction;
  79. private loadTextureFile;
  80. removeAsset(uuid: string): void;
  81. clear(): void;
  82. assetIsOrphan(uuid: string): boolean;
  83. loadAssetConfigs(configs?: {
  84. [uuid: string]: AssetConfig;
  85. }): void;
  86. /**
  87. * Load all assets set to preload if not loaded already
  88. */
  89. preloadAssets(): Promise<void>;
  90. }
  91. export declare let AssetManager: AssetManagerClass;
  92. export {};