import { IAsset } from "../../core/asset"; import { ConstructorType } from "../../utils/util"; import { GLContext } from "../../core/global"; export class AssetsPack { mainAsset: IAsset | null = null; assets: Map = new Map(); add(name: string, asset: IAsset) { asset.name = name; this.assets.set(name, asset); } setMain(asset: IAsset) { this.mainAsset = asset; } get(Type: ConstructorType): T | null { for (const [name, asset] of this.assets) { if (asset instanceof Type) return asset as T; } return null; } getAll(Type: ConstructorType): T[] { return Array.from(this.assets.values()).filter(asset => asset instanceof Type) as T[]; } } export interface AssetImporterPlugin { import(buffer: ArrayBuffer, options?: TOption, ctx?: GLContext): Promise; } type SerializableValueType = number | string | boolean | { [key: string]: SerializableValueType } | SerializableValueType[]; export interface AssetImportOptions { [key: string]: SerializableValueType; }