engine
engine copied to clipboard
Render component with not-preloaded assets may have 0 mesh instances
Description
If an entity has a render
component referencing an asset
which has the preload
flag turned off, the render
component will have render.meshInstances.length
equals to 0 for an inconsistent amount of time - even though the asset itself is already loaded.
If the asset
is not loaded yet (because preload
is off), it makes sense that meshInstances
would not be configured yet - but in this case, the asset
is already loaded (or at least it says it is). Additionally, because the asset
is technically already loaded, it is not possible to "listen" to an event and know when the meshInstances
is actually set.
Is this an issue? Or is there a way of knowing when meshInstances
is set (without having to check every frame)?
Steps to Reproduce
- Launch https://playcanvas.com/editor/scene/1473173
- Check logs, you'll see it takes a few frames until the
meshInstance
count is larger than 0, even though the asset was already loaded - Refresh a few times, and there's a high chance every time the number of frames will be different
- Turn on
preload
for the render assetplay
(the main box) - Launch again, and
meshInstance
count will always be 1
Related #3638
There are two levels of assets at play here. The render component links to a render asset. When this loads, it internally triggers the referenced container to load. And when this is loaded, the mesh instances are set up. I have not investigated your repro specifically, but I suspect you're testing for the render asset to load, but not the container asset.
I'm closing this as I don't see any issue .. please reopen if you don't agree with further details.