user2
December 8, 2021, 5:41am
#1
Hello.

I want to move and rotate the gltf model.

However, if I move the model first and then rotate it, it does not rotate around the center of model.
I think, the model rotates around the center before it moves.

How can I rotate the gltf model on the center after it moved?

my code is

```
loader.load(url, (gltf) => {
const model = gltf.scene;
...
model.position.setX(x);
model.position.setY(y);
model.position.setZ(z);
...
});
...
model.rotation.z += 0.01;
...
```

thanks.

mslitto
December 8, 2021, 4:52pm
#2
I found this in the forum

No problem at all.
Perhaps it would help to look at some basic examples.
There are a few that fit.
Collection of examples from discourse.threejs.org
With this enhancement the lady moves additionally sideways.
let model, c, size; // model center and size
let t = 0;
let x0 = xPosition;
let dx;
animate();
function animate( ) {
requestAnimationFrame( animate );
yRotation += 0.005;
t += 0.001;
dx = Math.sin( t )
xPosition = x0 + dx;
move( model );
rende…
3 Likes