tylermorganwall / rayshader

R Package for 2D and 3D mapping and data visualization
https://www.rayshader.com/
2.05k stars 211 forks source link

render_snapshot() showing only part of image #96

Closed RvV1979 closed 4 years ago

RvV1979 commented 4 years ago

I am on Ubuntu 18.04.3 LTS using R version 3.6.2. When I call '''plot_3d()''' an R-X11 window opens to show the RGL device and renders the rayshaded image. Then, when I call render_snapshot() an image is rendered in the R plot window. However, this only shows a small part of the image.

This is true with my usual setup running R from Rstudio Version 1.1.463, either with or without first calling options(rgl.useNULL = TRUE). It is also true when running R directly from the terminal.

Below is a minimal example showing this issue on my system:

library(rayshader)
montereybay %>%
  sphere_shade(texture="desert") %>%
  plot_3d(montereybay,zscale=50)
render_snapshot()

The rendered image is below: plot How can I ensure the whole image is being rendered? Thanks.

tylermorganwall commented 4 years ago

Does the whole 3D model appear in the X11 window, or just this portion? I also have a machine that runs 18.04.3 LTS, but haven't had this issue. What happens when you manually resize the window and then take a screenshot?

RvV1979 commented 4 years ago

The R_X11 window shows the entire 3D model. Manually resizing the R plot window does not resolve the issue: it still shows the same portion only.

Below is a screenshot of Rstudio after running the minimal example. (but via terminal I have the same issue).

Screenshot 2020-02-05 at 22 53 59
tylermorganwall commented 4 years ago

What happens when you use rgl::rgl.snapshot()?

e.g.

library(rayshader)
montereybay %>%
  sphere_shade(texture="desert") %>%
  plot_3d(montereybay,zscale=50)
rgl::rgl.snapshot("test.png")
RvV1979 commented 4 years ago

same issue

tylermorganwall commented 4 years ago

This is then likely a problem with rgl. What results when you run the following?

x <- sort(rnorm(1000))
y <- rnorm(1000)
z <- rnorm(1000) + atan2(x, y)
plot3d(x, y, z, col = rainbow(1000))
par3d(windowRect = c(0,0,600,600))
rgl::rgl.snapshot("test.png")
RvV1979 commented 4 years ago

Yep. I can confirm it is an rgl issue. See output below. I had never used rgl before so did not know how to check this. Do you have an idea how to resolve this or who best to contact for help with rgl? Thanks test

tylermorganwall commented 4 years ago

You can submit a bug report to Duncan Murdoch on the r-forge (see this link: https://r-forge.r-project.org/projects/rgl/). You will need to create an account, and then you can submit the bug report here: https://r-forge.r-project.org/tracker/?atid=946&group_id=234&func=browse, which has a Submit New link when you're logged in. I recommend using the above plot3d() example in your reproducible example.

RvV1979 commented 4 years ago

Thanks so much for helping me out and for your advice!