mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 08:57:54 +00:00
only update camera when there's change
This commit is contained in:
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
|
||||
|
||||
Reference in new issue
Block a user