Hi there, I need an advice and some answered questions
Imagine a 1000x1000 world, placed with hundreds or thousands models that are loaded using loadFromUrlandFilename from external script file that is attached to player in game
So the first question is, does preload work with loadFromUrlandFilename?
First thoughts were to create ‘areas’, different plane entities around the world, and when player collides with the plane1 or plane2 for example, it would trigger script to load models that belong to that place, but it wouldn’t be a smooth experience I guess, is it possible to do it using vec3 distance, if yes, how?
As soon as you load the remote asset it will loaded and made available to the engine. Preload is used only for assets loaded during the app load time.
But yes you are thinking correctly on how to create zones on your world and load only what’s included in your active zone.
Another way to approach that is to have each zone as a separate scene. So you will load and unload scenes on demand, that will include not only assets but the entities hierarchy.
Alright, but what about serving models by players location? Is it doable?
Since every model is assinged to a different entity, I could create empty entities all over the map on game start (do empty entities take vram and other res, if there are thousand or more?), and load models to those entities that are near player (distance), but again, database should be needed to store each entity’s defined model urls, thoughts?
Yeah, even empty entities will not do, since creating thousand of entities on runtime will have a big performance hit.
You will have to write your own systems that batch/instance those entities to reduce the overhead from your app update cycle.
One way is to utilize hardware instancing: PlayCanvas Examples
I am doing something similar in this example here: https://twitter.com/PlayingInCanvas/status/1528478073250791424
You’re doing a nice job over there!
Just out of curiosity I’ve made a sample project
Pressing Enter will generate 1000 new entities and will add it to app’s root, couldn’t feel any differences on my 10 year old lap even with 5k of them