dmurdoch / rgl

rgl is a 3D visualization system based on OpenGL. It provides a medium to high level interface for use in R, currently modelled on classic R graphics, with extensions to allow for interaction.
https://dmurdoch.github.io/rgl/
GNU General Public License v2.0
85 stars 20 forks source link

Embed rgl plots in vignette #316

Closed luca-scr closed 1 year ago

luca-scr commented 1 year ago

Hi Duncan, following the release of version 1.0.1 on CRAN I have updated successfully the spinplot() function in my msir package. So far so good. Unfortunately I have an issue with embedding a rgl plot in a vignette. Previously it worked fine, see the results at https://cran.r-project.org/web/packages/msir/vignettes/msir.html#general-usage-of-spinplot-function using code similar to the following

```{r, eval=requireNamespace("rgl", quietly = TRUE), echo=1}
spinplot(x1, y, x2)
rgl::rglwidget(width=500, height=450)
Full source code of vignette can be seen at https://github.com/luca-scr/msir/blob/master/vignettes/msir.Rmd
BTW, the following simple code embed the rgl graph with no problem:
rgl::plot3d(x1,y,x2)
rgl::rglwidget()


Do you have any hint on how to fix this?
Many thanks in advance.

LS
dmurdoch commented 1 year ago

Sorry for the delay on this -- somehow I missed noticing the issue.

This looks like a bug in rgl. I'll track it down and let you know when it is fixed.

dmurdoch commented 1 year ago

I have found the bug, and will soon be committing a fix. The issue was a bug in conversion of the pch3d() points to WebGL. If you want a short term workaround, avoid that function, e.g. use pointst3d() or text3d() instead.