Use Touchscreen InputEventScreenDrag to Scale a 3D node

Godot Version

v3.5.3.stable.official [6c814135b]

Question

I’m making a 3D object viewer for deployment in HTML5. In my scene a camera rotates around a central point on a node based ‘gimbal’, and zooms to the central point by scaling the top level Parent Gimbal node.

So far I can control the rotation of the gimbal and the zoom (scale) using:

  • Mouse click and drag, and mouse scroll
  • Keyboard
  • On Screen Buttons

As far as touch screen goes I’ve been able to rotate the camera around the scene using InputEventScreenTouch and InputEventScreenDrag when events.size() == 1, but I’m struggling to get events.size() == 2 pinch to work properly to scale/zoom.

The problem falls in 2 parts:

  1. Creating a clean break between single touch events.size() == 1 actions and pinch events.size() == 2 actions. At the moment the tail end of a pinch results in a drag action I don’t want, where it applies the value of the pinch to a rotation. I need to turn events.size() == 1 actions off totally and reset them if events.size() == 2 actions are happening.
  2. I need the pinch scale (zoom) to smoothly continue relative to the speed and size of the pinch, in realtime, while the pinch is happening, but I’m struggling to understand how to get the scale process to capture the pinch action and continually update it in realtime.

Any hints, tips and pointers gratefully received.