Saving rgl 3D scene to u3d (for .pdf integration) Saving rgl 3D scene to u3d (for .pdf integration) r r

Saving rgl 3D scene to u3d (for .pdf integration)


You should try writeASY(). It writes for Asymptote, which can produce PRC rather than U3D, but may be good enough. I tried your sample scene, and it takes about 5 minutes to load the result in Acrobat Reader, but it eventually loads and works.

writeASY() is a recent addition to rgl; you'll need to get it from the R-Forge or Github copies.


You can use rgl.postscript, which allows to export to various formats, including pdf. Well, the result is not terrific, but that should depend on the type of plot.

> x <- y <- seq(-10, 10, length = 20)> z <- outer(x, y, function(x, y) x^2 + y^2)> persp3d(x, y, z, col = 'lightblue')> rgl.postscript("persp3d.pdf", "pdf")

enter image description here

You can also export to tex, allowing to do some manual modifications.