Hi everyone!
I have a scene where I have a catmullromcurve spiral, and if the user scrolls down the camera should move on the curve using tween.js. I tried to implement the camera movement from this example:
I setup a listener for the scroll with 2 direction (up and down). It looks like this:
window.addEventListener(‘wheel’, function(event) {
if (event.deltaY < 0){} else if (event.deltaY > 0) { var camPos = curve.getPoint(camPosIndex / 50); var camRot = curve.getTangent(camPosIndex / 50); var tween = new TWEEN.Tween(camPosIndex).to(camPosIndex++, 2000); tween.onUpdate(function(){ camera.position.x = camPos.x; camera.position.y = camPos.y; camera.position.z = camPos.z; camera.rotation.x = camRot.x; camera.rotation.y = camRot.y; camera.rotation.z = camRot.z; camera.lookAt(curve.getPoint((camPosIndex+1) / 50)); }); tween.easing(TWEEN.Easing.Quadratic.Out); tween.start(); TWEEN.update() } });
For some reason when the scroll event is happening it just jumps to the next step, without easing. I know I’m doing something wrong, but cannot figure out, how to define the next “step” in the curve.
You guys can see the live example here:
http://thebarghest.com/odd/tweenoncurve
Any help is well appreciated.