Multiple models position

Hi guys if i am adding a scene using GLTFLoader which have like 30,40 models like a wedding hall setting, is there any way i can select a model (like any sofa and chair etc) and change its position and color.

Hi,

THREE.GLTFLoader returns a object with a THREE.Scene that contains every object of your gltf.
As THREE.Scene inherit from THREE.Object3D, you can use Object3D.getObjectByName( name ) to find the child you’re interested in, provided that you named it before export (in Blender for instance).

Example :

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

   myObject = gltf.scene.getObjectByName( 'nameOfMyObject' );

});
1 Like

Small update: Since R114, the loader returns an instance of THREE.Group.

1 Like

Hey thanks man. Is there any way like user can select any model on runtime and change the location of the model? :roll_eyes:

Unfortunately, your question is very broad. It’s unlikely that somebody will provide you a complete solution for your use case. I suggest you get familiar with raycasting first since this is the basic technique for interacting with 3D objects. The following example might be helpful in this context:

https://threejs.org/examples/webgl_interactive_cubes

2 Likes