Added asset manager.
This commit is contained in:
@ -0,0 +1,39 @@
|
||||
export interface IAssetOwner {
|
||||
|
||||
}
|
||||
|
||||
export class AssetManager {
|
||||
private owners:{ [key:string]:IAssetOwner[] };
|
||||
private textures:{ [key:string]:Texture };
|
||||
private shaders:{ [key:string]:Shader };
|
||||
|
||||
constructor() {
|
||||
this.owners = {};
|
||||
this.textures = {};
|
||||
this.shaders = {};
|
||||
}
|
||||
|
||||
private addOwner(name:string, owner:IAssetOwner) {
|
||||
this.owners[name] = this.owners[name] || [];
|
||||
this.owners[name].push(owner);
|
||||
}
|
||||
|
||||
public textureLoad(name:string, owner:IAssetOwner):Texture {
|
||||
this.addOwner(name, owner);
|
||||
if(this.textures[name]) return this.textures[name];
|
||||
this.textures[name] = textureCreate();
|
||||
assetTextureLoad(this.textures[name], name);
|
||||
return this.textures[name];
|
||||
}
|
||||
|
||||
public shaderLoad(vert:string, frag:string, owner:IAssetOwner):Shader {
|
||||
this.addOwner(vert, owner);
|
||||
if(this.shaders[vert]) return this.shaders[vert];
|
||||
this.shaders[vert] = shaderCreate();
|
||||
assetShaderLoad(this.shaders[vert], vert, frag);
|
||||
return this.shaders[vert];
|
||||
}
|
||||
|
||||
public releaseOwner(owner:IAssetOwner) {
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user