This function writes out a web page containing Javascript that reconstructs the scene in WebGL.
Use the template
argument to give the filename of a web page that is to contain the
code for the new scene. It should contain a single line containing paste0("%", prefix, "WebGL%")
, e.g.
%WebGL%
with the default empty prefix. That line will be replaced by the Javascript and other
code necessary to reproduce the current scene. The template may also contain the string "%rglVersion%"
which will be replaced with the current rgl version number. If
template
is NULL
, the output will simply be written directly
to the main file.
To put more than one scene into a web page, use different values of prefix
for each. The prefix
will be used in identifiers in both Javascript and HTML, so it is safest to start with a letter and
only use alphanumeric characters.
WebGL is a fairly new technology for displaying 3D scenes in browsers. Most current browsers support it
to some extent, though it may not be enabled by default; see http://get.webgl.org for details. A major
exception currently is Microsoft's Internet Explorer, though plugins are available.
Currently writeWebGL
has a number of known limitations, some of which will be gradually eliminated as
development progresses:
The bounding box decorations are fixed; labels do not move as they do within R.
User-defined mouse controls are not supported.
Missing values are not handled properly.
WebGL browsers generally do not support more than 65535 vertices per
object. writeWebGL
will print a warning if this limit is exceeded, but it is up to the user
to break his scene into smaller objects. (And 65535 vertices may not be small enough!)