Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra information about templates preload effects #286

Closed
2 tasks done
yaustar opened this issue Jul 2, 2021 · 5 comments · Fixed by #422
Closed
2 tasks done

Add extra information about templates preload effects #286

yaustar opened this issue Jul 2, 2021 · 5 comments · Fixed by #422

Comments

@yaustar
Copy link
Contributor

yaustar commented Jul 2, 2021

  • Templates can now be loaded async
  • Templates that don't need to be instantiated at runtime, don't need to be preloaded and saves space / size in config.json
@Maksims
Copy link
Contributor

Maksims commented Jul 2, 2021

Question:
If template asset is set to preload, will it lead to related assets to be preloaded too? Or they will load in async if unchecked preload on them?

@yaustar
Copy link
Contributor Author

yaustar commented Jul 2, 2021

That's a good question. @zachpeterpaul, can you help out here please?

@zachpeterpaul
Copy link

I think when you are dynamically loading something (eg a template asset) that's not preloaded, you need to first manually/dynamically load all dependencies whose 'preload' is unchecked, make sure they all finished loading (using their "on load" callback), and only then load the template asset. I believe this is how PlayCanvas game code is written in other similar cases too.

@zachpeterpaul
Copy link

zachpeterpaul commented Jul 2, 2021

Another way to describe this: a template asset only contains entity data, like a PC scene document in mongo. They may have e.g. texture references, but not textures themselves. A dynamically instantiated template allows you to quickly create multiple entities at run time, but you have to make sure yourself that all prerequisites for those entities are already available at that point.

@Maksims
Copy link
Contributor

Maksims commented Jul 3, 2021

Thank you @zachpeterpaul, just to answer on my own question:

  1. Template does not keep separate list of referenced assets, and is basically same as a scene - just a hierarchy data.
  2. When parsed, it does not do any special logic, and does not trigger preload for related assets.

Means, template, will not trigger load event on related assets, which I believe as a default behaviour - is good! As we want to be able to instantiate template without need to async load it, but we don't want to preload assets, and make engine load them in async when instance of a template becomes used in render.
And developer is free to find referenced assets within template hierarchy and implement own loading behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants