GLTFLoader objects in main scene



Hi everyone,
When I export objects with GLTFExport and then I import them (GLTFLoader) in other scene, always it’s loading objects like children in Auxscene. Is it possible to load these objects in main level (principal scene) ?


When you load the gltf scene, you could traverse through it’s children and then add all of the children to the main scene.

    (gltf) => {

        gltf.scene.traverse( (child) => {
            if (child instanceof THREE.Mesh) {
                // add children to main scene
                scene.add( child );

        gltf.animations; // Array<THREE.AnimationClip>
        gltf.scene; // THREE.Scene
        gltf.scenes; // Array<THREE.Scene>
        gltf.cameras; // Array<THREE.Camera>
        gltf.asset; // Object

I would be careful doing this, however, if your GLTF scene requires particular grouping of meshes for positioning, rotation etc, you would be losing that relationship by adding them to the main scene individually.


Thank you very much and I will take account of your suggestion.