On 10/06/2021 4:42 a.m., David Waterman wrote:
Hi all,

I tried subscribing to the list yesterday, but this does not appear to
have been successful. Therefore I am hoping this message meets
volunteer moderator approval.

I have problems using snapshot3d from rgl while trying to render an R
Markdown page. I want to do this to capture static snapshots of an
interactive widget on the page. I had this working with an earlier
version of R (sorry, forgot which), but this now hangs indefinitely at
the snapshot3d call.

Should I expect this to work? I can successfully create a snapshot
from an interactive R session with either webshot=TRUE or FALSE, just
not from within my R Markdown build.

I have created a simple reproducer, which I attempt to build using:

library(rmarkdown)
rmarkdown::render("reproducer.Rmd")

where the contents of reproducer.Rmd are:

$ cat reproducer.Rmd
---
title: "rgl test"
output:
   html_document:
     toc: true
     toc_float:
       toc_collapsed: true
---

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

### Insert rgl figure

Test

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

One suggestion I forgot: try snapshot3d("foo.png", webshot = FALSE). This should fall back to the internal snapshot code in rgl. You generally don't get as good quality of a result, but if you are not running on a headless system it will generally work.

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to