CameraInputManager support for FollowCamera

Ok,
Pointers done: https://github.com/BabylonJS/Babylon.js/pull/5798/

And the Playground which (demonstrates some features: https://www.babylonjs-playground.com/ts.html#P9RQJW#9 (Or it will when the changes make it upstream.)

For this one I’ve actually split the code into a Base class BaseCameraPointersInput that can be used for any Camera
and a derived FollowCameraPointersInput for the FollowCamera.

I probably should have been doing that for my previous commits as well…
There’s quite a bit of duplicated code around these classes.
On the other hand, i’m a frontend noob so not sure what accepted design patterns are.
Interested to hear opinions on this.

dunk.

@QuintusHegie

Haha.
Well it looks like i’ve implemented exactly the opposite direction for every single one of these…
I was thinking “move the camera” rather than “move the scene”.
Happily though they can all be reversed: Set a negative number in the relevant field.
eg: camera.inputs.attached.pointers.angularSensibilityX = -1;.

I’ll read up a little on touch UI tomorrow and see what the internet consensus is on the matter.
If it makes sense, i’ll reverse the default direction.
Sensible default options are sensible.

dunk.

Actually, it’s easier than that; let’s just go with what ArcRotateCamera does… which is the opposite of what i originally have here.

I’ve submitted a change to correct that.

1 Like

Ok, it took a while as i ended up completely re-factoring ArcRotateCameraPointersInput to use my new BaseCameraPointersInput as well. (Somewhat outside the scope of my original work but i was having fun…)
Here for prosperity: https://github.com/BabylonJS/Babylon.js/pull/5798

All this has been pushed to dev and should start working in playground soon.
Mouse drags should alter camera positions. Pinch-es on mobile devices should work too.
Watch here for evidence of the merge: https://www.babylonjs-playground.com/ts.html#P9RQJW#9

I think i’m close to done with this.
It would be nice to see Base classes for other input methods like BaseCameraPointersInput to prevent code duplication but my brain is itching to move on to another project (my CNC router needs more work) so i think it’s unlikely i’ll do that…

That said, i’m more than happy to tweak things in the code i’ve written if they aren’t working right.
(I also owe @Deltakosh some unit tests for ArcRotateCameraPointersInput. Going to start on those now.)

2 Likes

Excellent PR! thanks a lot for this contribution!

Hrm,
Changes are live but https://www.babylonjs-playground.com/ts.html#P9RQJW#10 shows “pinch” events on touch screens are not working for the FollowCamera.
I’ll fix this tonight.

1 Like

Fixed: Fix pinch action on FollowCameraPreviewInputs. by mrdunk · Pull Request #5879 · BabylonJS/Babylon.js · GitHub
It was caused when i renamed the onMultiTouch() method in the base class but not FollowCameraPreviewInputs.

2 Likes