Closed tomauer closed 5 years ago
See https://github.com/tylermorganwall/rayshader/issues/32 to see if that fixes the issue for you.
Unfortunately, that doesn't fix it for me.
I can use writeWebGL() successfully with and XQuartz open:
options(rgl.useNULL = FALSE)
library(rayshader)
library(rgl)
#Here, I load a map with the raster package.
loadzip = tempfile()
download.file("https://tylermw.com/data/dem_01.tif.zip", loadzip)
localtif = raster::raster(unzip(loadzip, "dem_01.tif"))
unlink(loadzip)
#And convert it to a matrix:
elmat = matrix(raster::extract(localtif,raster::extent(localtif),buffer=1000),
nrow=ncol(localtif),ncol=nrow(localtif))
ambmat = ambient_shade(elmat)
elmat %>%
sphere_shade(texture = "desert") %>%
add_water(detect_water(elmat), color="desert") %>%
add_shadow(ray_shade(elmat,zscale=3,maxsearch = 300),0.5) %>%
add_shadow(ambmat,0.5) %>%
plot_3d(elmat,zscale=10,fov=0,theta=135,zoom=0.75,phi=45, background = 'white')
writeWebGL(dir = "~/Downloads/test")
Are you using RStudio Server or RStudio Desktop?
RStudio Desktop.
I was finally able to get it to work, but I have to manually open XQuartz application before I open RStudio, otherwise, it gives me a black screen.
Sounds like there just might be an issue with your R installation (I recommend reinstalling R and see if that helps). I develop on Mojave and haven't had any issues, so it's likely a local installation problem. Feel free to comment on this thread if you have any more related issues.
For the record, I'm on Catalina, and I had this same problem. Opening XQuartz before RStudio worked.
I am on Catalina 10.15.6. I have the same problem. I don't have RStudio but am using R Console.
I get below error message upon loading rayshader library and black page upon rendering the plot using plot_3d().
options(rgl.useNULL = FALSE)
library(ggplot2)
library(whitebox)
library(raster)
library(spatstat)
library(spatstat.utils)
library(suncalc)
library(sp)
library(lubridate)
library(rgdal)
> library(rayshader)
Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'.
> library(rayrender)
I'm having trouble getting plot_3d to work correctly on Mac Mojave. I'm using this example from the demo.
It produces a black square, either in RStudio or R opened from command line and if I try to save it instead of rendering it. My sessionInfo():
I thought I might have been having problems with
rgl
, so I made sure these examples worked (https://cran.r-project.org/web/packages/rgl/vignettes/rgl.html), which did after I installedrgl
withXQuartz
open.Any help is appreciated.