A 'noob' question on importing multiple meshes in scene (mobile debug)

I’m experiencing my first issue with my early learning of mobile compatibility. I simply wanted to add a table to my scene. More precisely, the object is loaded on user click (of course after the scene is loaded). Though the table is made out of two assets (the structure and the parts). Anyways, the question is simple (and the answer probably also is):
Q: How to safely load two models (.obj) at once (and next act on the models/meshes and dispose of them).
I mean everything works perfectly on desktop (no matter if I make it a constructor or a simple var). I used import mesh, should I try append it? Use promise and load one after the other? Use asset Manager?
I have seen I guess most tutorials (BtW I love the video series tutorials, very dynamic and straight forward. Good speakers. Really nicely done) and I also collected many (too many) links and PGs… but then (sry) it’s just so much easier to quickly post my question here and soak-up some of your awesome big brains support. I will indeed try to offer a compensation, if the opportunity arises.

I would use loading screen and asset manger, once asset manager has given me finished event I am hiding the loading screen. There are details on asset manager docs page for how to hide loading screen.

Ok but just to make this clear, the scene is already loaded. So, the loading screen has already gone. And I don’t want to add a new one on mesh import. And both meshes weight nothing (250Kb max). It’s only that, for some reason, if I create a single function that loads one (creates some clones and stuff) and does this for the two assets (at once), the mobile version would attempt reload the scene, where on desktop (any browser) it wouldn’t complain.

If model are small, I would still load them before loading screen and just set its visibility to false, and when its required to display on the scene, I would make it visible by using isVisible or visibility key value. This way both model would appear at the same time.

Nah, this is a simulation for me to try understand how to build the requirements if I wanted to take/offer project mgmt on something like a 3D catalogue. There could be hundreds of objects potentially. I cannot have them all loaded on scene load and kept in the scene.

Edit: so yes, in this case I would indeed use asset manager (likely) but I’d still want to understand what is going on here…

in that case I would use state management by storing current state in a variable or by using asset manager, so for example if 5 objects are requested to be loaded in scene, I would show some loading indicator and load objects in invisible mood, once last object is loaded I would make all visible at same time.

1 Like

If I understand well, what you are saying is that I should await for a promise on both assets loads before handling them (because they are loaded async and one may not have finished as some of the other instructions kick-in, right?) This was my first thought. I was just looking for a confirmation.

Edit: Thanks, I had a look already on Promises. (kind of;) know what it does;) I must have been in an way, just too ‘lazy’ to test. Though meanwhile, I was wondering, do you think I can make use of ‘while’ and ‘then’ to make it a more seamless experience? Pretend we would have two (or up to three, max 5) assets forming a final object (we could call a prefab) each hosting a few submeshes (probably max 10 or 20) and these imported assets would have a weight say between 20kb and max 2mb (for a total load of max 5mb-8mb). In this case, I would think of adding a loader with a time-out only for the heavier objects/prefabs (say more than 2sec load i.e.). The others would load seamlessly. Here, I’m just wondering how (originally or in essence) I should (ideally) structure this part of such project?
No hurry though, this is rather a simple case study. Nobody is awaiting anything on this (except me of course;)

sort of but once first promise is completed I would hide the containing object and show all objects once all promises are done, otherwise it would still display one-by-one instead all-together, if you want to use Promise BJS already provide a way, check this Promises | Babylon.js Documentation

Thanks, I’m gonna put this topic as solved (as it is for now). Stupid me didn’t carefully look at the PGs provided for Promises (although they are supposed to be the most obvious part;) :zipper_mouth_face: I believe it will do for a start and for this step in the project. Later on, I will want to try as explained above with more complex assets and prefabs. I might make a new post at this time but for now and for me, I shall close this topic (and apologize to you for the disturbance). Have an amazing WE,

Not sure this will help, but maybe you can use AssetContainers and use SceneLoader.loadAssetContainer so that you can load the assets without adding them to the scene until you are ready to.

1 Like