How to change perspective in Rayshader RGL without a middle mouse button?

35 Views Asked by At

I am trying to move the perspective of the rendered 3D scene in RGL after calling plot_3d in rayshader. I don't have a middle click on my computer, just left and right. When I open RGL using for example plot(las) to plot a lidR point cloud, I can use Shift + Right Click and drag to change perspective. However, in the RGL spawned by plot_3d I can't figure out how to do this.

1

There are 1 best solutions below

0
On

rayshader::plot_3d sets rgl::par3d("mouseMode") to

   none    left   right  middle   wheel 
  "none" "polar"   "fov"  "zoom"  "pull" 

On my system (a Macbook Air with a trackpad and no mouse) I seem to have it configured so right and middle buttons are not available, but two finger drags on the trackpad are seen as mouse wheel rotation. I also hate the "polar" mouse control, so if I wanted to be able to rotate the scene and also change the field of view (but lose zoom), I could change it using

mm <- par3d("mouseMode")
mm["left"] <- "trackball"
mm["wheel"] <- "fov"
par3d(mouseMode = mm)

and then clicking and dragging rotates the scene, while a two finger drag (no click necessary) changes the FOV. Your system may map mouse modes differently, so experiment.

According to the ?rayshader::plot_3d help page, once you have it right and have the desired settings in mm, you can use them for a new plot with

rayshader::plot_3d(..., mouseMode = mm)

However, the line that would implement that appears to be commented out in the source code: https://github.com/tylermorganwall/rayshader/blob/81f95cf24973049f84f4a4250daa9b0b4659281d/R/plot_3d.R#L356