Skip to content

Commit

Permalink
tutorial08: suppress redundant events
Browse files Browse the repository at this point in the history
  • Loading branch information
aranlunzer committed Feb 27, 2024
1 parent c01d5a5 commit 0374474
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tutorials/tutorial08/src/Views.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,15 @@ export class AvatarPawn extends mix(Pawn).with(PM_Smoothed, PM_ThreeVisible, PM_
update(time, delta) {
super.update(time,delta);
if (this.driving) {
const yaw = (this.right+this.left) * -3 * delta/1000;
const yawQ = q_axisAngle([0,1,0], yaw);
const rotation = q_multiply(this.rotation, yawQ);
const t = v3_scale([0, 0, (this.fore + this.back)], 5 * delta/1000);
const tt = v3_rotate(t, rotation);
const translation = v3_add(this.translation, tt);
this.positionTo(translation, rotation);
if ((this.right + this.left) || (this.fore + this.back)) {
const yaw = (this.right+this.left) * -3 * delta/1000;
const yawQ = q_axisAngle([0,1,0], yaw);
const rotation = q_multiply(this.rotation, yawQ);
const t = v3_scale([0, 0, (this.fore + this.back)], 5 * delta/1000);
const tt = v3_rotate(t, rotation);
const translation = v3_add(this.translation, tt);
this.positionTo(translation, rotation);
}
}
}

Expand Down

0 comments on commit 0374474

Please sign in to comment.