The following R code generates an HTML file and opens it in the browser:
library(rgl)
M <- rbind(
c(0,0,0),
c(-1,4,0),
c(4,9,0),
c(6,3,0)
)
quads3d(M,col='red')
browseURL(paste("file://", writeWebGL(dir=file.path(tempdir(), "webGL"),
width=500), sep=""))
The rendering is an interactive planar polyhedron in the 3D space.
With the latest version of the rgl
package (0.93.935), the HTML rendering does not work for Windows users (as well as iOS users, I think) with default configuration browser. With the older version 0.93.928, it works.
I have posted the html output of rgl 0.93.928 and the html output of rgl 0.93.935.
I have reported this issue to Duncan Murdoch (author of rgl
) and he has given me the following solution for Firefox: type and run "about: config" in the address bar, and turn the parameters webgl.prefer-native-gl
and webgl.force-enabled
to true. Then the HTML rendering works.
My questions:
How to do with Google Chrome?
Is it possible to change something in the HTML code in order that the HTML rendering works with the default configuration? (as for the 0.93.928 version).
As difficult as the getting to the problem was as easy is the solution to it.
As of latest version of rgl I could acquire the problem resides inside the fragment shader of the html output:
it defines variables outside on the main function which skips value assignments and thus fails to compile with division-by-zero failures. The solution is to move the start of the main function above the definition block directly after the varying values:
This will show the object as desired.
You may want to contact Duncan Murdoch again and send him a link to this post if as you said you're not versed in html and webgl.