Skip to content

Handle mobile touch gestures for scene controls#72

Merged
unkcpz merged 3 commits into
rs4rse:mainfrom
syzer:fix/mobile-swipe
Mar 4, 2026
Merged

Handle mobile touch gestures for scene controls#72
unkcpz merged 3 commits into
rs4rse:mainfrom
syzer:fix/mobile-swipe

Conversation

@syzer

@syzer syzer commented Mar 4, 2026

Copy link
Copy Markdown
Collaborator

It's mostly JS for handling touch gestures on canvas.
Rust change is tiny.
As always contains previous PR's

WARNING NEED TEST ON NATIVE IPHONE... for android the axis were inverted than web version .. as example

  • Add mobile touch gesture handling in web bootstrap (index.js): one-finger rotate, two-finger pan + pinch.
  • Add touch gesture bridge in WASM core and apply deltas in camera controls.
  • Lock page-level zoom/pan gestures so touch interaction stays inside the canvas.
  • Update startup hint text to include mobile controls.
  • Fix Android/Chrome pinch direction in camera scaling (sign normalization).

@unkcpz unkcpz force-pushed the fix/mobile-swipe branch from 7a8297e to 085b648 Compare March 4, 2026 20:14
Comment thread vizmat-app/index.js

@unkcpz unkcpz Mar 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it can or it should to have this also in rust through web-sys (or gloo)? That is what we did for the original drag and drop.

If you don't mind, I'll give it a try after merge this PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I see. If I understand it corretly, you collect the gestures by js and then send a payload to the rust side.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like your idea: but try to run it locally on your phone first to see if experience is good...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theres a big PR on top of it.. but maybe we can rebase that on top of oyur changes :D

@unkcpz

unkcpz commented Mar 4, 2026

Copy link
Copy Markdown
Member

I gave it a try and works well (on my iphone, with firefox). Only problem is when touch an atom it is not selected.

For the javascript part, you may notice that there is another index.js in wasm/ folder. I use that one for the github page deployment. There are only slightly different, the deployed one take care of the loader when wasm is initializing.

I think we can move the mobile gesture into a dedicated js file and load both, I'll give it a try and commit directly here.

@unkcpz unkcpz force-pushed the fix/mobile-swipe branch from b747e54 to ea38cd8 Compare March 4, 2026 22:28
@unkcpz unkcpz force-pushed the fix/mobile-swipe branch from ea38cd8 to 7038893 Compare March 4, 2026 22:32
@unkcpz

unkcpz commented Mar 4, 2026

Copy link
Copy Markdown
Member

Okay, I decide to keep the javascript part. It is a good example to show that there are two ways to communicate between bevy world and web api world.
I add a commit to separate the mobile gesture logic out, so if can be used in github page deployment, which copy another index.js from wasm/ folder.

@unkcpz unkcpz merged commit fc9d0c3 into rs4rse:main Mar 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants