rgl-package: 3D visualization device system

Description Details See Also Examples

Description

3D real-time rendering system.

Details

RGL is a 3D real-time rendering system for R. Multiple windows are managed at a time. Windows may be divided into “subscenes”, where one has the current focus that receives instructions from the R command-line. The device design is oriented towards the R device metaphor. If you send scene management instructions, and there's no device open, it will be opened automatically. Opened devices automatically get the current device focus. The focus may be changed by using set3d() or useSubscene3d().

rgl provides medium to high level functions for 3D interactive graphics, including functions modelled on base graphics (plot3d(), etc.) as well as functions for constructing geometric objects (cube3d(), etc.). Output may be on screen using OpenGL, or to various standard 3D file formats including WebGL, PLY, OBJ, STL as well as 2D image formats, including PNG, Postscript, SVG, PGF.

The open3d() function attempts to open a new RGL window, using default settings specified by the user.

rgl also includes a lower level interface which is described in the rgl.open help topic. We recommend that you avoid mixing rgl.* and *3d calls.

See the first example below to display the ChangeLog.

See Also

r3d for a description of the *3d interface; par3d for a description of scene properties and the rendering pipeline; rgl.useNULL for a description of how to use rgl on a system with no graphics support.

Examples

1
2
3
file.show(system.file("NEWS", package = "rgl"))
example(surface3d)
example(plot3d)

Example output

Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'. 
/usr/lib/R/bin/pager: line 11: /usr/bin/pager: Permission denied
/usr/lib/R/bin/pager: line 11: /usr/bin/pager: Success

srfc3d> #
srfc3d> # volcano example taken from "persp"
srfc3d> #
srfc3d> 
srfc3d> data(volcano)

srfc3d> z <- 2 * volcano        # Exaggerate the relief

srfc3d> x <- 10 * (1:nrow(z))   # 10 meter spacing (S to N)

srfc3d> y <- 10 * (1:ncol(z))   # 10 meter spacing (E to W)

srfc3d> zlim <- range(z)

srfc3d> zlen <- zlim[2] - zlim[1] + 1

srfc3d> colorlut <- terrain.colors(zlen) # height color lookup table

srfc3d> col <- colorlut[ z - zlim[1] + 1 ] # assign colors to heights for each point

srfc3d> open3d()
null 
   1 

srfc3d> surface3d(x, y, z, color = col, back = "lines")

plot3d>   open3d()
null 
   2 

plot3d>   x <- sort(rnorm(1000))

plot3d>   y <- rnorm(1000)

plot3d>   z <- rnorm(1000) + atan2(x, y)

plot3d>   plot3d(x, y, z, col = rainbow(1000))

rgl documentation built on Feb. 1, 2021, 3:01 a.m.