bevyengine / bevyengine/bevy

Mouse wheel is too fast in wasm builds: unit Pixel vs Line confusion

Open
#21,140 7 comments 0 reactions 0 assignees View on GitHub
A-Input C-Bug C-Docs O-Web S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version and features

```
[dependencies.bevy]
version = "0.16.1"
```

## Relevant system information

I made two builds - one for Windows 11 and one for wasm, which I use with Edge.

## What you did

I was trying to work out how to zoom out camera. Here is the system that reproduces the issue:

```rust
fn zoom_camera(
mut scroll_evr: EventReader,
camera_query: Single<&mut Projection, With>,
) {
match *camera_query.into_inner() {
Projection::Orthographic(ref mut orthographic) => {
for event in scroll_evr.read() {
info!("Mouse wheel: {event:?}");
//Adding to scale zooms out (the -= is there since it is reversed -> adding to scale zooms out)
orthographic.scale = (orthographic.scale - event.y * 0.03).clamp(0.1, 3.0);
}
}
_ => (),
}
}
```

Note the log `info!("Mouse wheel: {event:?}");`

## What went wrong

Moving mouse wheel on windows build and on web build results in two very different changes and two different logs. Web build produces much bigger change for some reason.

Here is log from browser (after one minimal wheel rotation):

```
Mouse wheel: MouseWheel { unit: Pixel, x: 0.0, y: 100.0, window: 0v1#4294967296 }
```

and same for Windows build:

```
Mouse wheel: MouseWheel { unit: Line, x: 0.0, y: 1.0, window: 0v1#4294967296 }
```

As you can see the change in "y" is 100 times different!

## Additional information

Nothing I could find so far.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.