I am currently trying to implement a system where placeholder images can be displayed while the actual images are being loaded. I would like to ask for some examples that have already done this using PIXIjs.
Structure I came up with:
export class ImageDefinition {
placeholder: PIXI.Texture
resource: PIXI.LoaderResource
callbacks: ((texture: PIXI.Texture) => void)[] = []
loaded: boolean = false
GetTexture(callback: (texture: PIXI.Texture) => void): void {
if(!this.resource.isComplete) {
callback(this.placeholder)
return
}
this.callbacks.push(callback)
}
// This function is called by the asset loader
LoadCompleted() {
// Run all callbacks here
}
}
How this would be used:
probabilityTexture.GetTexture((texture) => {
// this code will be run twice, for placeholder and later for real image
});
What do you think about the system above?