Wait or know when is load the assets of entity completely

35 Views Asked by At

I would like to be able to identify when the object is already fully loaded in the engine

const box = new Entity()
box.getComponent(Transform).position.set(3, 1, 3)
var model=new GLTFShape()
box.addComponent(model)
engine.addEntity(box)

I mean something like this:

model.OnLoaded(()=>{/*The model load in Cache*/})

or

await engine.addEntity(box)

or

engine.addEntity(box,()=>{/*charging is complete*/})

I can't find a way to do this

any suggestions other than waiting without knowing what happens?

1

There are 1 best solutions below

0
On

Unfortunately, as it stands now, there is no real concrete way to know when an asset is loaded. This feature (onLoading, onLoadComplete, ect) may be included in a future update. I believe it's on the roadmap. In the meantime, you may want to put a delay of some kind with either a setInterval or otherwise and set it to a few seconds, and then call whatever code you want.

There are workarounds, but they are crazy and I wouldn't recommend it, for your own sanity sake.