rgl scene not showing in knitted html document under Rstudio 1.2.5001

Hi

Using Windows 10, Rstudio 1.2.5001, R 3.6.1 , htmlwidgets 1.5.1, rgl 0.100.30, knitr 1.25

I am having the same problem as this user - i.e. if I knit an RGL plot it just leaves a white gap and does not display (their issue was closed recently but I dont think a solution was presented??)

Rstudio 1.2 not knitting rgl object in rglwidget

e.g. even for the simple example out of the online manual:

https://cran.r-project.org/web/packages/rgl/vignettes/WebGL.html

library(rgl)
plotids <- with(iris, plot3d(Sepal.Length, Sepal.Width, Petal.Length, 
                  type="s", col=as.numeric(Species)))
rglwidget(elementId = "plot3drgl")

Can anyone see this plot in a knitted html file?

Thanks in advance

Alex

Hi,
I am the user in your referred post. I eventually made it work with Rstudio 1.1,
I have tried couple of weeks trying to find solution to Rstudio 1.2 but with no luck, I wish you can find the solution.

Same problem here, rgl not rendering in the html output under Rstudio 1.2.1335

But the following still works for me:

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(rgl)
knitr::knit_hooks$set(webgl = hook_webgl)


```{r echo=FALSE, webgl=TRUE}
with(iris, plot3d(Sepal.Length, Sepal.Width, Petal.Length, 
                  type="s", col=as.numeric(Species)))

I think there are two issues:

  1. On some systems, RStudio doesn't enable WebGL, so it can't display rgl scenes in the internal browser. See https://github.com/rstudio/rstudio/issues/5678. If you look at those HTML files in an external browser like Firefox or Chrome, you'll see the rgl output. I have a system like that, and can't see output from @lepovas's suggested fix in RStudio, but I can in Firefox.
  2. As well, sometimes it is producing files where the rgl output isn't visible anywhere. I'm trying to track down what's going wrong with these. A workaround that seems to fix this is to run options(rgl.useNULL=TRUE) before library(rgl). That's usually a good idea to include because it prevents lots of popup windows during knitting, but it shouldn't be necessary.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.