Converting webGL html to SVG

夙愿已清 提交于 2019-12-22 10:57:40

问题


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?


回答1:


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?




回答2:


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.



来源:https://stackoverflow.com/questions/14059669/converting-webgl-html-to-svg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!