[solved] How to animate the position of a gltf model

If you comment in your animation code, you get the following error:

pen.js:96 Uncaught ReferenceError: gltf is not defined

The problem is that you try to access a variable which is out of scope. gltf only exists in the onLoad() callback of GLTFLoader.load(). I have fixed your code my defining a global variable model and assigning gltf.scene to it. I use this variable in the animate() function like so:

if ( model && ( model.position.x >= targetPositionX5 ) ) {

    model.position.x -= 0.0032;

}

Updated codepen: https://codepen.io/anon/pen/mQVeKQ