Hi I am using tween.js to tween the camera position. But it is not moving smoothly. There is a big shaking. I am giving my tween settings and my renderer settings below. Please help me to solve this.
this.tweencamera = function (xTarget, yTarget, zTarget, tweenDuration) {
TWEEN.removeAll();
console.log("tweening");
let camNewPosition = { x: xTarget, y: yTarget, z: zTarget };
let targetNewPos = { x: xTarget, y: yTarget, z: 0 };
var camTween = new TWEEN.Tween(camera.position)
.to(camNewPosition, tweenDuration)
.easing(TWEEN.Easing.Quadratic.InOut)
.onComplete(function () {
camera.position.copy(camNewPosition);
controls.enabled = true;
})
.start();
var targetTween = new TWEEN.Tween(controls.target)
.to(targetNewPos, tweenDuration)
.easing(TWEEN.Easing.Quadratic.InOut)
.onComplete(function () {
controls.target.copy(targetNewPos);
controls.enabled = true;
})
.start();
}
renderer settings
function render() {
renderer.render(scene, camera);
}
function animate() {
render();
if (orbitcontrol !== undefined) {
orbitcontrol.update();
}
TWEEN.update();
requestAnimationFrame(animate);
}