I'm venturing into the world of Tween JS and attempting to create a basic animation that moves objects to the right using Tween.
Here is the code snippet from my init function (utilizing Three JS):
var geometry = new THREE.CylinderGeometry(200, 200, 200, 4, 0);
var material = new THREE.MeshPhongMaterial({ambient: 0xf0f0f0, color: 0x006699, specular: 0x006699, shininess: 60, shading: THREE.FlatShading});
var mesh = new THREE.Mesh(geometry, material);
mesh.position.x = 0;
mesh.position.y = 0;
mesh.position.z = 0;
mesh.updateMatrix();
mesh.matrixAutoUpdate = false;
scene.add(mesh);
var tween = new TWEEN.Tween({ x: 0, y: 0 })
.to({ x: 400 }, 2000)
.easing(TWEEN.Easing.Elastic.InOut)
.onUpdate(function() {
mesh.position.x = Math.round(this.x);
}).start();
Below is my animate function:
requestAnimationFrame(animate);
renderer.render(scene, camera);
TWEEN.update();
update();
The cube renders but the tween effect doesn't seem to be functioning. Could there be something I've overlooked?