How to stack 3dmodels (glft) on top of eachother

I amtrying to load two GLTF models into the same scene. and i want the two models tied together so they move at the same time.

I have a 3D model loaded with gltf loader and I want to show a other 3d model on top when he has picked up a “package”

my code for loading the model the group is used to update the position of the robot

var group = new THREE.Group();
group.scale.set(0.3, 0.3, 0.3);
var loader = new THREE.GLTFLoader();
loader.load( 'models/robot.glb', function ( gltf ) {
gltf.scene.scale.set(0.3, 0.3, 0.3);
gltf.scene.position.set(1.5, 0.15, 0.3);
group.add( gltf.scene.children[0] );
}, undefined, function ( error ) {
console.error( error );
} );


i hope you guys can help

You just have to add the new model to the same group, thus every transform that you will apply to the group will apply to the new model as well. If you want your new model to be offset like on your drawing, you just change its position, which will be applied locally inside the group, then it will keep this relative offset whatever tranform you apply to the group. Also I see in your code that you apply transforms to gltf.scene, but right after you take out the first children from gltf.scene to put it in another group, and you don’t use gltf.scene. Therefore these transforms will have no effect.


thx Felix i will look in to it. I let you know if it worked.

Thx Felix
I think it works now but idk how to scale both. Because the package is to big now.
Can you help me with that? and also dont know how to change the position. You said that the transformations glft.scene doesnt have effect how can i change that?

If both your objects are children of the THREE.Group, then the transformations you apply to the group will be applied to your objects, as they are its children.
You can change position, rotation, and scale of THREE.Group, which inherit from THREE.Object3D, like this :

group.position.set( 1,1,1 );
group.rotation.set( 1,1,1 );
group.scale.set( 1,1,1 );

This kind of simple questions can be answered by reading the doc

1 Like

thx for helping :smiley:

1 Like