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

Added optimisation guidelines for Templates Assets #422

Merged
merged 2 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions content/en/user-manual/optimization/load-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Here are some tips to achieve super-fast load times:
* Look for opportunities to downsample certain texture images. For example, a 2048x2048 texture that is used on a small graphical object may look almost exactly the same at 1024x1024 or even 512x512.
* Don't preload assets which can be loaded asynchronously. For example, it may not be necessary for your game music to play immediately at game start, so consider unchecking the Preload option for that asset in the Inspector panel.
* If you have a prefiltered cubemap and are not displaying the top-level mipmap for the skybox, you can uncheck preload for all the 6 face images.
* If you are not instantiating Templates at runtime, uncheck preload on the asset as they aren't needed. (See '[When do I need to load Template Assets?][2]' for more information).
* Ensure that imported models only have the vertex attributes that you need. For example, if your model has a second set of UVs but doesn't use them or if it has all-white vertex colors, go back to the modeling application and delete those attributes.
* Use the Networking panel in Chrome Dev Tools (or the equivalent in other browsers) to sort loaded assets by size and look for anything that stands out. Look for assets that are not used and could be deleted. Look for assets that are essentially duplicates and delete them.
* Using PlayCanvas' built-in physics engine incurs an additional download cost of 379KB. If you are using the physics engine to solve very simple problems, consider rolling an alternative solution that doesn't incur the download penalty.
Expand Down Expand Up @@ -53,3 +54,4 @@ An example below is using a silhouette of a character as the placeholder until i
<img loading="lazy" src="/images/user-manual/optimization/loading/character-load.gif" style="max-width: 360px;">

[1]: https://www.miniclip.com/games/virtual-voodoo/en/
[2]: /user-manual/templates/#when-do-i-need-to-load-template-assets?
8 changes: 8 additions & 0 deletions content/en/user-manual/templates/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ this.app.root.addChild(instance);

You can also use Script Attributes to pass Template Assets to your scripts instead of searching for them by ID.

## When do I need to load Template Assets?

Templates store the Entity hierarchy and data, similar to scenes. When a template instance is added to the scene in the Editor, the Entity hierarchy and data is included in the Scene data.

At runtime, the Template instance is not linked to the asset and you can reduce the download size by not preloading/loading the asset.

You only need Template assets to be loaded if you are instantiating instances at runtime.

[1]: /images/user-manual/templates/hierarchy.png
[2]: /images/user-manual/templates/inspector.png
[3]: /images/user-manual/templates/override.png
Expand Down