4

I am using R, with the misc3d and rpanel libraries, to create a 3d image in webGL. I then need to embed the image into a PDF via Latex.

The 3d image renders fine and looks great - but I'm thinking I need to convert the webGL HTML file into an SVG or some other kind of vector graphics file which can be embedded in Latex.

Any suggestions on how to accomplish this?

gagan
  • 115
  • 9

2 Answers2

2

Maybe I am wrong but this way doesn't make sense to me.

  • You have 3D coordinates
  • You render objects based on 3D coordinates to a 2D rasterized image using webGL
  • Then you want to extract 2D vector coordinates from the rendered image?

From the webGL framebuffer you can get the rasterized data (no vector information). So it is like converting a rasterized image (like png) to SVG. Since there is no way (I know) to get the vector information back from a rasterized image chances are high that the image will just be embedded in the SVG file. This wouldn't be a real benefit compared to a rasterized image.

Maybe you can use the vector informations (which you are using for drawing the webGL image) for drawing to a SVG image directly?

micha
  • 47,774
  • 16
  • 73
  • 80
1

Is there a reason you can't use the rgl package instead (I'm not really familiar with rpanel, but I'm pretty sure that misc3d was originally design to work in conjunction with rgl) and use rgl.postscript(...,fmt="pdf") to export directly to PDF? rgl.postscript also offers an SVG option. The results are admittedly a little wonky sometimes (the underlying package it uses isn't completely reliable), but it's definitely the past of least resistance.

Also, I haven't tried it out myself, but I think the following article gives some information about embedding rgl images in their full, rotatable glory into PDFs: Levine, Richard A., Luke Tierney, Hadley Wickham, Eric Sampson, Dianne Cook, and David A. van Dyk. 2010. “Editorial: Publishing Animations, 3D Visualizations, and Movies in JCGS.” Journal of Computational and Graphical Statistics 19 (1) (January): 1–2. doi:10.1198/jcgs.2010.191ed. http://amstat.tandfonline.com/doi/abs/10.1198/jcgs.2010.191ed.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • FWIW, I found a copy of (what I think is) the example PDF from that article, and couldn't get any rotation from it in Preview or Chrome's PDF viewer. – Ken Williams May 17 '13 at 02:20
  • That's not surprising. I would expect it to be viewer-specific, and very probably Adobat Reader-specific ... – Ben Bolker May 17 '13 at 02:31