webgl: Opens a new WebGL HTML device for RGL-based graphics

Description Usage Arguments Value Generated file Defaults See Also

View source: R/webgl.R

Description

Opens a new WebGL HTML device for RGL-based graphics. The opened device, which is indeed an RGL device, must be closed using devDoneRGL(), otherwise the WebGL HTML file is not generated.

When the device is closed, the output is written to a WebGL HTML document, which can then be incorporated into a main HTML document, for instance, using RSP-embed HTML templates, cf. R.rsp.

Usage

1
2
webgl(filename="Rplot.WebGL.html", width=480L, height=480L, font=c("sans-serif", "Arial",
  "Helvetica"), useNULL=TRUE, snapshot=FALSE, header=TRUE, class=c("rglWebGL"), ...)

Arguments

filename

The pathname of the generated WebGL HTML file.

width, height

numeric scalars specifying the width and the height (in pixels) of the WebGL HTML canvas.

font

A character vector of the HTML font names used in the font-family attribute.

useNULL

A logical specifying whether to use the RGL null graphics device or not, cf. open3d.

snapshot

A logical specifying whether to include a static PNG snaphot to be displayed before the WebGL graphics is rendered. Snapshots are not supported if useNULL=TRUE.

header

A logical specifying whether the generated WebGL HTML document should include/define the global 'CanvasMatrix.js' Javascript or not. If FALSE, it must be manually added to the main HTML page. By using TRUE, each figure will include/define the same code, which slightly increases the output size, but is safe and valid to do.

class

A character vector specifying the CSS classes on the HTML canvas object that displays the WebGL graphics.

...

Additional arguments passed to writeWebGL upon closing the opened device.

Value

Returns (invisibly) the RGL device number, cf. rgl.dev.list. When done plotting, the device must be closed using devDoneRGL().

Generated file

If created, the generated file is saved in the directory specfied by argument path with a filename consisting of the name followed by optional comma-separated tags and a filename extension given by argument ext.

By default, the file is only created if the expr is evaluated completely. If it is, for instance, interrupted by the user or due to an error, then any incomplete/blank file that was created will be removed. This behavior can be turned of using argument onIncomplete.

Defaults

Whenever a default value is missing, the fallback is to use the corresponding value for the "png" device type according to R.devices, i.e. R.devices::devOptions("png"). Currently, this only applies to the width and the height arguments.

See Also

To close the device, use devDoneRGL(). A more convenient and robust function for generating WebGL HTML file is toWebGL() (recommended). See also devEvalRGL() and devNewRGL().


HenrikBengtsson/R.devices.rgl documentation built on May 6, 2019, 11:53 p.m.