# Animations slow down when the camera is moving?

I have what I believe is a fairly common setup for a ThreeJS scene that emulates a first person shooter world. I have this block of code in my animate loop, which came from one of the ThreeJS “controls” example. I can’t remember which one since it’s been a while.

``````               const onObject = userIsLookingAtObjects.length > 0;

let delta = (currentTime - prevTime) / 1000;

// Limit long delay gaps, which indicate
//  a background task interfered with us and
//  we don't want the camera/user
const limitDelta = 0.2;

if (delta > limitDelta) {
delta = Math.min(limitDelta, delta);
console.warn(`\${errPrefix}Capping delta time at: \${limitDelta}`);
}

velocity.x -= velocity.x * 10.0 * delta;
velocity.z -= velocity.z * 10.0 * delta;

velocity.y -= 9.8 * 100.0 * delta; // 100.0 = mass

// ROS: The Number() constructor is simply being used
//  to convert the TRUE/FALSE move<direction> values
//  to a number in the following set of values: [-1, 0, 1]
direction.z = Number(moveForward) - Number(moveBackward);
direction.x = Number(moveRight) - Number(moveLeft);
direction.normalize(); // this ensures consistent movements in all directions

if (moveForward || moveBackward)
velocity.z -= direction.z * 400.0 * delta;
if (moveLeft || moveRight)
velocity.x -= direction.x * 400.0 * delta;

if (onObject === true) {
// ROS: This appears to be part of a check to allow jumping or
//  not.  See the raycast intersection code above involving
//  onObject.
velocity.y = Math.max(0, velocity.y);
canJump = true;

// This aids tracing using Chrome DevTools.  See pointerlock.js
//  for the keystroke that sets g_BreakHerePlease to TRUE.
console.info(`\${errPrefix}Set DevTools breakpoint here.`);
}

g_ThreeJsControls.moveRight(-velocity.x * delta);
g_ThreeJsControls.moveForward(-velocity.z * delta);

g_ThreeJsControls.getObject().position.y += (velocity.y * delta); // new behavior

if (g_ThreeJsControls.getObject().position.y < 10) {
velocity.y = 0;
g_ThreeJsControls.getObject().position.y = 10;

canJump = true;
}
``````

Everything works fine, but I noticed something today. If one of my animation models is LERP’ing and I move the camera continuously, like when you “strafe” around an object in an FPS game, the object that is LERP’ing slows way down. So slow, that at first I thought that moving the camera actually stopped other animations. It doesn’t, it just brings them to a snail’s crawl.

What could be causing this? I’m hoping it’s not inherent to moving the camera around a lot because “players” in my world will be moving constantly. Can I fix thi?