diff options
| author | Elizabeth Hunt <elizabeth@simponic.xyz> | 2024-09-05 00:15:14 -0700 |
|---|---|---|
| committer | Elizabeth Hunt <elizabeth@simponic.xyz> | 2024-09-05 00:15:14 -0700 |
| commit | 45726367eee475a7717d7dcad78895de348f0b97 (patch) | |
| tree | 937abae9cd74d8f99f149cf3c3ee534169c723f8 /static/src/mouse_controller.ts | |
| parent | c39367ac7e163395ae726bd169926004d4d99d67 (diff) | |
| download | kennel.hatecomputers.club-45726367eee475a7717d7dcad78895de348f0b97.tar.gz kennel.hatecomputers.club-45726367eee475a7717d7dcad78895de348f0b97.zip | |
checkpoint; working position updates
Diffstat (limited to 'static/src/mouse_controller.ts')
| -rw-r--r-- | static/src/mouse_controller.ts | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/static/src/mouse_controller.ts b/static/src/mouse_controller.ts index c7ae304..bd8d51a 100644 --- a/static/src/mouse_controller.ts +++ b/static/src/mouse_controller.ts @@ -7,7 +7,6 @@ export class MouseController { constructor( private readonly publisher: (new_movement: Vec2) => void | Promise<void>, private readonly debounce_ms = 200, - private readonly l2_norm_threshold = 40, ) {} public start() { @@ -29,20 +28,14 @@ export class MouseController { } public move(x: number, y: number) { - const new_movement = new Vec2(x, y); - if ( - typeof this.last_movement !== "undefined" && - new_movement.distance_to(this.last_movement) >= this.l2_norm_threshold - ) { - this.publish_movement(); - } - this.last_movement = new_movement; + this.last_movement = new Vec2(x, y); + this.publish_movement(); } private publish_movement() { if ( - typeof this.last_movement === "undefined" || - Date.now() - this.last_event_time < this.debounce_ms + Date.now() - this.last_event_time < this.debounce_ms || + typeof this.last_movement === "undefined" ) { return; } |
