only update camera when there's change

This commit is contained in:
bflatastic committed 2025-04-28 21:36:35 +07:00
1 parent 09d0ae263f
commit 5d5b782760
1 file changed
+9 -1
@@ -271,7 +271,10 @@ class FreeCam extends EventDispatcher {
}
isStationary() {
return this.moveVector.distanceTo(new Vector3(0, 0, 0)) === 0;
return (
this.moveVector.distanceTo(new Vector3(0, 0, 0)) === 0 &&
this.currentVelocity.distanceTo(new Vector3(0, 0, 0)) < 0.0001
);
}
update(delta: number) {
@@ -279,6 +282,11 @@ class FreeCam extends EventDispatcher {
return;
}
// Skip update if there's no movement and velocity
if (this.isStationary()) {
return;
}
const moveMulti = delta * this.movementSpeed;
// Apply WASD movement with smoothing