AssetManager.d.ts 3.4 KB

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