Learn R Programming

⚠️There's a newer version (1.3.1) of this package.Take me there.

RGL - 3D visualization device system for R using OpenGL

INTRODUCTION

The RGL package is a visualization device system for R, using OpenGL or WebGL as the rendering backend. An OpenGL rgl device at its core is a real-time 3D engine written in C++. It provides an interactive viewpoint navigation facility (mouse + wheel support) and an R programming interface. WebGL, on the other hand, is rendered in a web browser; rgl produces the input file, and the browser shows the images.

LICENSE

The software is released under the GNU Public License. See “COPYING” for details.

FEATURES

  • portable R package using OpenGL (if available) on macOS, Win32 and X11
  • can produce 3D graphics in web pages using WebGL
  • R programming interface
  • interactive viewpoint navigation
  • automatic data focus
  • geometry primitives: points, lines, triangles, quads, texts, point sprites
  • high-level geometry: surface, spheres
  • up to 8 light sources
  • alpha-blending (transparency)
  • side-dependent fill-mode rendering (dots, wired and filled)
  • texture-mapping with mipmapping and environment mapping support
  • environmental effects: fogging, background sphere
  • bounding box with axis ticks marks
  • undo operation: shapes and light-sources are managed on type stacks, where the top-most objects can be popped, or any item specified by an identifier can be removed

PLATFORMS

macOS Windows 7/10 Unix-derivatives

BUILD TOOLS

R recommended tools (gcc toolchain) On Windows, Rtools40 (or earlier versions for pre-R-4.0.0)

REQUIREMENTS

For OpenGL display:

Windowing System (unix/x11 or Windows)
OpenGL Library
OpenGL Utility Library (GLU)

For WebGL display:

A browser with WebGL enabled. See https://get.webgl.org.

Installing OpenGL support

Debian:
aptitude install libgl1-mesa-dev libglu1-mesa-dev

Fedora:
yum install mesa-libGL-devel mesa-libGLU-devel libpng-devel

macOS:
Install XQuartz.
rgl should work with either XQuartz 2.7.11 or 2.8.0, but it will probably need rebuilding if the XQuartz version changes. XQuartz normally needs re-installation whenever the macOS version changes.

Windows:
Windows normally includes OpenGL support, but to get the appropriate include files etc., you will need the appropriate version of Rtools matched to your R version.

Options

The libpng library version 1.2.9 or newer is needed for pixmap import/export support.

The freetype library is needed for resizable anti-aliased fonts. On Windows, it will be downloaded from https://github.com/rwinlib during the install.

BUILDING/INSTALLING

Binary builds of rgl are available for some platforms on CRAN.

For source builds, install the prerequisites as described above, download the tarball and at the command line run

R CMD INSTALL rgl_0.105.22.tar.gz

(with the appropriate version of the tarball). The build uses an autoconf configure script; to see the options, expand the tarball and run ./configure --help.

Alternatively, in R run

install.packages("rgl")

to install from CRAN, or

remotes::install_github("dmurdoch/rgl")

to install the development version from Github.

BUILDING WITHOUT OPENGL

As of version 0.104.1, it is possible to build the package without OpenGL support on Unix-alikes (including macOS) with the configure option –disable-opengl For example,

R CMD INSTALL --configure-args="--disable-opengl" rgl_0.105.22.tar.gz 

On Windows, OpenGL support cannot currently be disabled.

DOCUMENTATION and DEMOS:

library(rgl)
browseVignettes("rgl")
demo(rgl)

CREDITS

Daniel Adler dadler@uni-goettingen.de
Duncan Murdoch murdoch@stats.uwo.ca
Oleg Nenadic onenadi@uni-goettingen.de
Simon Urbanek simon.urbanek@math.uni-augsburg.de
Ming Chen mchen34@uwo.ca
Albrecht Gebhardt albrecht.gebhardt@uni-klu.ac.at
Ben Bolker bolker@zoo.ufl.edu
Gabor Csardi csardi@rmki.kfki.hu
Adam Strzelecki ono@java.pl
Alexander Senger senger@physik.hu-berlin.de
The R Core Team for some code from R.
Dirk Eddelbuettel edd@debian.org
The authors of Shiny for their private RNG code.
Jeroen Ooms for Rtools40 and FreeType help.
Yohann Demont for Shiny code, suggestions, and testing.
Joshua Ulrich for a lot of help with the Github migration.
Xavier Fernandez i Marin for help debugging the build.

WEBSITE

https://github.com/dmurdoch/rgl

Copy Link

Version

Install

install.packages('rgl')

Monthly Downloads

77,621

Version

0.105.22

License

GPL

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

March 4th, 2021

Functions in rgl (0.105.22)

arrow3d

Draw an arrow in a scene.
GramSchmidt

The Gram-Schmidt algorithm
arc3d

Draw arcs.
addNormals

Add normal vectors to objects so they render more smoothly.
as.mesh3d.ashape3d

Convert alpha-shape surface of a cloud of points to mesh3d object.
ageControl

Set attributes of vertices based on their age.
as.mesh3d

Convert object to mesh object
ageSetter

Set WebGL scene properties based on the age of components of objects.
points3d

add primitive set shape
abclines3d

Lines intersecting the bounding box
bgplot3d

Use base graphics for RGL background
clipplaneControl

Sets attributes of a clipping plane.
identify3d

Identify points in plot.
contourLines3d

Draw contours on a surface.
import

Imported from magrittr
.check3d

Check for an open rgl window.
bg3d

Set up Background
rgl.setMouseCallbacks

User callbacks on mouse events
mfrow3d

Set up multiple figure layouts in rgl.
rgl.bbox

Set up Bounding Box decoration
ellipse3d

Make an ellipsoid
par3d

Set or Query RGL Parameters
asRow

Convenience functions for rgl HTML layouts
clipMesh3d

Clip mesh or rgl object to general region
aspect3d

Set the aspect ratios of the current plot
plot3d.lm

Method for plotting simple linear fit.
makeDependency

Process Javascript for HTML dependency.
plot3d.formula

Methods for formulas
light

add light source
extrude3d

Generate extrusion mesh
rgl.attrib

Get information about shapes
merge.mesh3d

Merge "mesh3d" objects.
par3dinterp

Interpolator for par3d parameters
planes3d

add planes
rgl.material

Generic Appearance setup
rgl.postscript

export screenshot
cylinder3d

Create cylindrical or "tube" plots.
axes3d

Draw boxes, axes and other text outside the data
as.triangles3d

Convert an object to triangles.
rgl-internal

Internal rgl functions and data
figWidth

Get R Markdown figure dimensions in pixels.
as.mesh3d.rglId

Convert object in plot to mesh3d object.
propertyControl

Controls to use with playwidget().
elementId2Prefix

Use widget with old-style controls.
play3d

Play animation of rgl scene
par3dinterpControl

Control rgl widget like par3dinterp().
mergeVertices

Merge duplicate vertices in mesh object
rgl-package

3D visualization device system
pch3d

Plot symbols similar to base graphics.
rgl.bringtotop

Assign focus to an RGL window
rgl.init

Initializing rgl
spin3d

Create a function to spin a scene at a fixed rate
rgl.primitive

add primitive set shape
scene

scene management
mesh3d

3D Mesh objects
tkspin3d

Create TCL/TK controller for rgl window
playwidget

Add a widget to play animations.
persp3d.triSht

Plot an interp or tripack Delaunay triangulation.
persp3d.function

Plot a function of two variables
rgl.select

Switch to select mode, and return the mouse position selected.
rglToLattice

Convert rgl userMatrix to lattice or base angles
rgl.useNULL

Report default use of null device.
tkrgl

tkrgl functions
plot3d

3D Scatterplot
matrices

Work with homogeneous coordinates
readSTL

Read and write STL (stereolithography) format files
scene3d

Saves the current scene to a variable, and displays such variables.
grid3d

Add a grid to a 3D plot
observer3d

Set the observer location.
plotmath3d

Generate sprites using base graphics math plotting.
persp3d

Surface plots
rglwidget

An htmlwidget to hold an rgl scene.
rgl.user2window

Convert between rgl user and window coordinates
persp3d.deldir

Plot a Delaunay triangulation.
r3d

Generic 3D interface
rglIds

rgl id values
shiny

polygon3d

Triangulate and draw a polygon in three dimensions.
shapelist3d

Create and plot a list of shapes
tkspinControl

Create a spin control in a TCL/TK window
sprites

add sprite set shape
rgl.Sweave

Integrating rgl with Sweave
toggleWidget

An HTML widget to toggle display of elements of a scene.
setGraphicsDelay

Set a one-time slowdown on opening standard graphics
shinyGetPar3d

Communicate rgl parameters between R and Javascript in Shiny.
show2d

Draw a 2D plot on a rectangle in a 3D scene.
selectpoints3d

Select points from a scene
spheres3d

add sphere set shape
snapshot3d

export screenshot
propertySetter

Obsolete function to write HTML/Javascript code to control a WebGL display.
rgl.attrib.info

Get information about attributes of objects
subdivision3d

generic subdivision surface method
triangulate

Triangulate a two-dimensional polygon.
writeOBJ

Read and write Wavefront OBJ format files
writePLY

Write Stanford PLY format files
rglMouse

Generate HTML code to select mouse mode.
thigmophobe3d

Find the direction away from the closest point in a 3d projection.
tkpar3dsave

Modal dialog for saving par3d settings
open3d

RGL Display Functions
rgl.open

3D visualization device system
writeWebGL

Write scene to HTML.
turn3d

Create a solid of rotation from a two-dimensional curve.
webGLcontrols

Obsolete functions to write HTML/Javascript code to control a WebGL display.
writeASY

Write Asymptote code for an rgl scene
sceneChange

Make large change to a scene from Shiny
subscene3d

Create, select or modify a subscene.
rgl.pixels

Extract pixel information from window
surface3d

add height-field surface shape
select3d

Select a rectangle in an RGL scene
text3d

add text
rglShared

Create shared data from an rgl object.
setUserShaders

Set user-defined shaders for rgl objects.
setupKnitr

Displaying rgl scenes in knitr documents.
viewpoint

Set up viewpoint
vertexControl

Set attributes of vertices.
rgl.surface

add height-field surface shape
subsceneInfo

Get information on subscenes