Cutomize camera input not working properly on mac's trackpad

Hi Gens,

I was following the document https://doc.babylonjs.com/divingDeeper/cameras/customizingCameraInputs and this playground demo
https://playground.babylonjs.com/#KHQBRL and getting some weird behavior when using mac trackpad. I think the behavior should be the camera only rotate if you click hold and rotate, but on the trackpad sometimes you click and drag for a bit then release, the camera will keep rotating with your cursor even you are not pressing the trackpad. I only have a mac so not sure if that happens to all the trackpads or just mac. (one small tip I found out, try to click the middle area of the trackpad and drag). I wonder if that’s a bug or just triggered some gestures for apple trackpad

Adding @PolygonalSun to help with this part.

I can only get this to repro on wonderful Safari, Chrome seems fine on Mac

Oh yes I forgot to say it’s safari only

Lemme take a look and see what’s going on.

1 Like

Based on what I’m seeing, it looks like there a flaky response from event listeners for pointerup. I was able to repro this with a mouse so I don’t think that it’s exclusive to trackpads but I think that it’s safe to say that this is an issue on Safari/MacOS. I’m gonna keep digging and update this thread when I find the root cause.

2 Likes

Update:
So I’ve found the root cause. The issue is inside of our move code. When you let go of the mouse button while moving, our code treats the button up as part of a pointermove event (Safari only) and also sends out a pointerup event with the button release. This is exclusively in Safari because of how they handle pointer events. When any other browser has a move event with a button already pressed (dragging), the event’s button value will be -1, while the buttons value will be a number that represents which buttons are pressed (none is 0). In Safari, the default value isn’t -1 but 0. In addition, the button value will always be the first button pressed while dragging. I am working on a fix now.

3 Likes

thanks! Keep me updated

Hi,

Wish you had a great weekend! Could you please let me know if you have some updates on the fix? Thanks in advance!

Hey @xtxz, I initially had a fix but it is breaking something in other camera movements so I’m just quickly fixing that up and finishing up my testing. Fix should be up in the next day or so. I’ll post when the PR is live.

that’s awesome, thanks for the update!

Hey @PolygonalSun , not sure if it’s related but it seems arc camera also have some weird behavior on safari see https://www.babylonjs-playground.com/#12WBC#69. Let me know if I should open a new thread for this

Hi @PolygonalSun – sorry to bug you… did you get a chance to get that fix up for camera input on mac trackpad?

1 Like

Sorry about the delay, I am still working on the issue as it appears to be more complex than I originally thought.

2 Likes

Safari :disappointed_relieved: no pressure let me know!

Change is in a draft PR: DeviceInputSystem: Fix Safari compatibility and remove “FakeMove” by PolygonalSun · Pull Request #11312 · BabylonJS/Babylon.js (github.com)
I still have some devices left to test my changes because there were a few systems that this affected. Once the PR is published, I’ll update this post.

3 Likes

Thank you very much! Also I wonder if this PR will also fix the problem with Arcrotate camera on safari. See https://playground.babylonjs.com/#SRZRWV#1 It has a different behavior with trackpad control(hasn’t test mouse but I assume it will be the same) using chrome vs safari

1 Like

Based on my testing, this PR will trackpad for Safari as well.

3 Likes

PR is live

1 Like