Children mesh does not show

Dear Three.js-Community,

I am loading 3D-Objects into my project with the GLTF Loader and have the problem that some of the objects, when added to a parent object, do not show at all. It’s super contra intuitive to me, because it does show up sometimes if I use a different parent object.

In the minimal example I am including I have three objects. The “Talonbody” should be the parent object, “Talonrotor” and “VRuderlinks” should be children to it. The prblem is that “VRuderlinks” never shows up only when I load itself as the parent object. Furthermore, even if it does not show up, I can log the position and do not get any errors, and always get the position that I gave it. With the Rotor I never have any problems loading it in. Also, it is no problem to add “VRuderlinks” to the scene.

I hope I described the problem clear enough, otherwise let me know.

Thanks in advance for any attempt of help, I would be very grateful! (2.8 MB)

Composing objects that way in code is in general no good approach. It’s much better to author and compose the objects in a DCC tool like Blender and then just export a single glTF asset.

Notice that you can define names for your 3D objects. It’s then possible to select these objects like so:

var object = gltf.scene.getObjectByName( 'myObject' );

In this way, you can select individual components and manipulate them. But the big advantage is that the initial transformations and hierarchy of the objects are correct (since you author this in Blender).

When reading your code, I have noticed two things:

  • There is no need to create multiple instances of GLTFLoader. You can load all three assets with just one loader.
  • You trigger the loads without order. That means you will run into race conditions since sometimes the meshtalon object (the parent object) will be undefined since the other parts were loaded first. You can only fix this by loading the plane body first and then trigger the loading process of the other parts. This whole issue can be completely avoid if you just load a single asset like mentioned above.
1 Like