engine icon indicating copy to clipboard operation
engine copied to clipboard

Render component with not-preloaded assets may have 0 mesh instances

Open jpauloruschel opened this issue 2 years ago • 2 comments

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.

chrome_7b6o7PNmdx

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

  1. Launch https://playcanvas.com/editor/scene/1473173
  2. 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
  3. Refresh a few times, and there's a high chance every time the number of frames will be different
  4. Turn on preload for the render asset play (the main box)
  5. Launch again, and meshInstance count will always be 1

jpauloruschel avatar Jul 14 '22 12:07 jpauloruschel

Related #3638

LeXXik avatar Jul 14 '22 17:07 LeXXik

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.

mvaligursky avatar Jul 16 '22 21:07 mvaligursky

I'm closing this as I don't see any issue .. please reopen if you don't agree with further details.

mvaligursky avatar Aug 10 '22 08:08 mvaligursky