More precise panning control

I’m trying to make panning in Babylon a bit better, the way I know it from Cinema4D (I think) is pretty good:
2019-03-03%2011_06_07

As you can see, while panning the camera, the object you’re panning it against always stays under your mouse cursor. This gives you very precise control over your operation.

In Babylon on the other hand your manipulation is not directly connected to your cursor. Your cursor movement basically defines a distance which is multiplied with a speed factor to move your camera.

The question is: If I want to implement a panning system like in Cinema4D, does anyone have ideas about how to realize this?

1 Like

Here’s a way:

  1. Pick a mesh
  2. Put a virtual plane at the picked point, facing the camera
  3. Use the cursor movement on the plane to pan the camera manually

https://playground.babylonjs.com/#GD4NPB#1

3 Likes

@Gijs Wow! Did… you… just… wrote me a complete functional example of my use case? That’s so awesome!

1 Like

That’s how we are :slight_smile: (…awesome :))
Thanks @gijs!

2 Likes

Another way to do it, simply using pickedPoint’s (assuming a ‘ground’ mesh is always behind the cursor), also disabled y-axis, https://playground.babylonjs.com/#GD4NPB#2

1 Like

Definitely!

Does not seem to work as good as @Gijs solution, when picking a point on the cube the point does not always end up under my cursor (it looks like it’s always picking the ground plane?)

Correct, as i wrote and the picking predicate indicates ( (m) =>{ return m.name === ‘ground’} )
It pans according to a pick on the ground mesh :slight_smile:
It’s a simple solution,
@Gijs solution is the way to go, if you must be able to click anywhere and have the cursor stay at the ~exact same spot of any mesh.

Thanks for your explanations @aWeirdo :slight_smile: