Get object gltf

I load three objects in a scene with a gltf loader (3 birds), when I try to get one of them (using the GetObjectById method(ByName doesen’t work)), I get one object that contains all those three birds.
I tried to get a child from this object, but it doesn’t work.
The question is-how can I get a separate model of one bird?

I need this to change their location in the update method (to do something similar to flying).

Code:
const parrotPosition = new THREE.Vector3( 0, 0, 2.5 );
loader.load( ‘models/Parrot.glb’, gltf => onLoad( gltf, parrotPosition ), onProgress, onError );

const flamingoPosition = new THREE.Vector3( 7.5, 0, -10 );
loader.load( ‘models/Flamingo.glb’, gltf => onLoad( gltf, flamingoPosition ), onProgress, onError );

const storkPosition = new THREE.Vector3( 0, -2.5, -10 );
loader2.load( ‘models/Stork.glb’, gltf => onLoad( gltf, storkPosition ), onProgress, onError );

import * as THREE from 'three';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';

// renderer
// camera
scene = new THREE.Scene();


gltfLoader = new GLTFLoader();
// Save your model reference in a variable
model = new THREE.Object3D();

gltfLoader.load('path/to/model', (gltf)=> {

        model = gltf.scene;
        model.name = 'model';

        // Add gltf model to scene
        scene.add(model);

        model.position.set(x, y, z);
    }, 
    onProgress,
    onError
);

// Or get your model obj from scene
model = scene.getObjectById(model.id)
model = scene.getObjectByName(model.name)
3 Likes

Thank you very much, it works.!!! You’re the best.!!!