Load several 3d models in order

how can i load several 3d models by gltf loader setting priority?

In regards priority do you mean that you want them to load in a certain order?

If so you can hook into the return function to trigger the next load.

eg.

gltf.load( 'model1.glb' , (object) => {
  scene.add( object.scene );
  gltf.load( 'model2.glb' , (object) => {
    scene.add( object.scene );
  });
});

You can then abstract that out to a function which loads from a list.

eg.

let loadThese = ['object1.glb','object2.glb'];
const loadNextObject = () => {
  const loadThis = loadThese.pop();
  gltf.load( loadThis , (object) => {
    scene.add( object );
    if( loadThese.length > 0 ) loadNextObject();
  });
}
4 Likes

Using Promise chain is also an option.

Best,

2 Likes

Thanks for the help, I actually want to create a virtual tour and I have a 3d model of an entrance hall that link to the other 3d hall of fame or booths models(.gltf) , now can I use this code?
Note: I want to use sprites to link 3d models to each other.

Are you working on an exhibition hall configurator?

yea exactly.a Virtual Tour with Halls and 3D booth Models

2 Likes

OWW great! me too
If you don’t mind send me your e-mail or your facebook account to help each other if we have problems :slight_smile:

2 Likes

hamidrezashahnazari.99@gmail.com