Skip to content

Commit

Permalink
Fix camera update jitter
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusLongmuir committed Jan 30, 2024
1 parent 6fa3428 commit aa5a12e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/3d-web-client-core/src/character/CharacterManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,18 @@ export class CharacterManager {
this.localCharacter.speakingIndicator?.setSpeaking(this.speakingCharacters.get(this.id)!);
}

this.localController.update();
if (this.timeManager.frame % 2 === 0) {
this.sendUpdate(this.localController.networkState);
}

this.cameraOffsetTarget = this.cameraManager.targetDistance <= 0.4 ? 0.13 : 0;
this.cameraOffset += ease(this.cameraOffsetTarget, this.cameraOffset, 0.1);
const targetOffset = new Vector3(0, 0, this.cameraOffset);
targetOffset.add(this.headTargetOffset);
targetOffset.applyQuaternion(this.localCharacter.quaternion);
this.cameraManager.setTarget(targetOffset.add(this.localCharacter.position));

this.localController.update();
if (this.timeManager.frame % 2 === 0) {
this.sendUpdate(this.localController.networkState);
}

for (const [id, update] of this.clientStates) {
if (this.remoteCharacters.has(id) && this.speakingCharacters.has(id)) {
const character = this.remoteCharacters.get(id);
Expand Down

0 comments on commit aa5a12e

Please sign in to comment.