I stumbled across the Experimental GeospatialCamera and incorporated it into my work-in-progress Tile Map Server client using Babylon. It’s showing promise.
I wanted to add Touch and Pinch support so I used the ArcRotateCameraPointersInput as a starting point.
ArcRotateCameraPointersInput is already almost generic enough to be usable with other cameras, if a few tweaks were added.
Most of the code is supporting internal state information and not application specific.
A big question relating to abstracting/separating camera from inputs: why are some properties available on the camera (e.g. pinchToPanMaxDistance, ) and some are available on the input (e.g. angularSensibilityX, pinchPrecision, static MinimumRadiusForPinch)? It looks like for the ArcRotateCamera, properties on the ArcRotateCameraPointersInput are given accessors on the camera. Is that really necessary? It seems to unnecessarily tie the ArcRotateCamera to specifically-coded PointersInput.
It seems plausible to adapt a generic TouchInput class to work with a variety of cameras so that adding specific input controls is less tedious.
For the touch control at the end of the playground, I am simply outputting the parameters to a popup box to play around with the control to see how it works.
The primary functions that a user would need to define are:
- _computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition)
- _computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance)
- getClassName
- getSimpleName
The list of properties that control this input method include
- panningSensibility
- pinchInwards
- multiTouchPanAndZoom
- multiTouchPanning
- pinchZoom
- useNaturalPinchZoom
- pinchDeltaPercentage
- pinchPrecision
- angularSensibilityX
- angularSensibilityY
- static MinimumRadiusForPinch
- (super?) _ctrlKey
- camera._useCtrlForPanning
- _isPanClick
The PointersInput does a pretty good job of isolating the functionality within the class and keeping track of its own state with respect to multi-touch pinch vs zoom. I’ve renamed it to GeospatialTouchInput, but it could be adapted so touch-based pinch/zoom could then easily be incorporated into other cameras. I’m not sure if it should be adapted as an inherited class or with a constructor that takes the customized methods, or an instance to which the user assigns custom methods.
I have some recommendations on improving GeospatialCamera, but I’ll save those for another post.