Loading thousands of entities(vehicles) as 3D models crashing browser

Hi,

I am trying to load one hundred thousand 3D models, but it making browser to crash because of huge memory allocation(each entity occupying dedicated memory of browser). As the same model need to be loaded in multiple instances I tried to make the model property of entity.js as static so that the memory will be occupied only once irrespective of how instances created. But it is not working. Can anyone please suggest where I am doing wrong or any other alternate approach for loading such huge number of 3D models.

Thanks.

Hitting limitations like this needs a bit more detail. For example, do all models have to be viewed at the same time? Are they roughly all in the same place, or scattered widely? Are they all detailed or simple? What sort of complexities are there? Usage? Etc.

Cheers,

Alex

1 Like

Hi Alexander,

All vehicles may not be viewed at the same time but for every second all vehicles positions will be updated from the server. Some are vehicle models(transportation carriers) and some are container models. Carriers positions and vehicle positions will be updated from the server. All will not be located at same place but they may be located within 1km radius.

In order to speed things up, here’s what I would do; I’d zoom to a level of a typical model size, and note what distance to camera that is. Then I’d write a quick routine that periodically with some randomness checks any models distance to camera, and switch the models view on and off accordingly (and you can get advanced with an interim distance where it fades with transparency, but that’s an excercise for the madly advanced). So, in pseudo code;

forEveryModel.setIntervalOf ( 2000 + random(0,2000), function ( model ) {
   if ( distanceToCamera < withinViewingDistance ) {
      model.view = true;
   } else {
      model.view = false;
   }
});

And, of course, here you experiment with whether view=true|false is good enough, or if viewer.add|remove is needed, what distance works well, what randomness values work (both for checking distance, but could also be for withinViewingDistance and other factors), and so on.

You can further this by having primitive icons for > withinViewingDistance (maybe with scaling or other view filters like transparency for distance to camera), etc.

As to live updates of coordinates, you a) don’t need to update a model’s coordinate if it’s out of view, and I’d probably add some code to also define a quicker update of a model, but only if its both withinViewingDistance as well as a withinNeedingQuickerUpdateDistance (so hook coord updates to the above pseudo code, and if the distance to camera is withinNeedingQuickerDistance you set a flag to update the coord quicker; this way at a further distance the update happens between 2 to 5 seconds, but if you’re closer than some value, the coord update happens quicker.

Let me know if any of that isn’t clear, and do tell us how the adventure plays out.

Cheers,

Alex

1 Like