Learn R Programming

⚠️There's a newer version (1.3.18) 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 win32) OpenGL Library OpenGL Utility Library (GLU)

For WebGL display:

Browser with WebGL enabled.

Installation on Debian:

To install OpenGL support:

aptitude install libgl1-mesa-dev libglu1-mesa-dev

OPTIONS

libpng library version 1.2.9 or newer (pixmap import/export support) freetype library (optional on Unix for resizable anti-aliased fonts), required on Windows

BUILDING/INSTALLING FROM SOURCE PACKAGE

The R build tool is the primary tool to build the RGL package.

BUILDING ON MICROSOFT WINDOWS

Install Rtools40 or newer.

An Internet connection will be needed, as FreeType is automatically downloaded from https://github.com/rwinlib.

BUILDING ON UNIX-STYLE OS (macOS, Linux, FreeBSD, … )

The build is controlled by an autoconf configure script. You provide the options through the R CMD build/INSTALL command

e.g.  $ R CMD INSTALL –configure-args=“<configure args…>” rgl

COMMON UNIX-STYLE OS OPTIONS —————————-

–with-gl-includes= GL C header files include path

–with-gl-libraries= GL library linkage path

–with-gl-prefix= GL library prefix (e.g. Mesa)

–disable-libpng disable libpng support

–with-libpng-prefix= force LibPNG library install prefix (e.g. /usr/local)

–disable-libpng-config explicitly disable libpng-config

–disable-libpng-dynamic use static libpng library

–disable-opengl disable all OpenGL displays; WebGL is still available

You may find that your distro doesn’t have all necessary development libraries installed: read the error messages for hints! This line has been reported to be sufficient on FC 5 or 6:

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

X11 WINDOWING SYSTEM OPTIONS —————————-

The X11 windowing system is needed for OpenGL display in macOS and Unix-alikes.

–x-includes= X11 C header files include path

–x-libraries= X11 library linkage path

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.104.1.tar.gz

On Windows, OpenGL support cannot currently be disabled.

DEMOS: LOADING AND RUNNING DEMONSTRATIONS

library(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.

WEBSITE

https://github.com/dmurdoch/rgl

Copy Link

Version

Install

install.packages('rgl')

Monthly Downloads

78,983

Version

0.105.12

License

GPL

Issues

Pull Requests

Stars

Forks

Maintainer

Duncan Murdoch

Last Published

February 14th, 2021

Functions in rgl (0.105.12)

points3d

add primitive set shape
arrow3d

Draw an arrow in a scene.
ageControl

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

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

Draw arcs.
GramSchmidt

The Gram-Schmidt algorithm
as.mesh3d

Convert object to mesh object
abclines3d

Lines intersecting the bounding box
addNormals

Add normal vectors to objects so they render more smoothly.
asRow

Convenience functions for rgl HTML layouts
aspect3d

Set the aspect ratios of the current plot
rgl.attrib

Get information about shapes
elementId2Prefix

Use widget with old-style controls.
cylinder3d

Create cylindrical or "tube" plots.
axes3d

Draw boxes, axes and other text outside the data
contourLines3d

Draw contours on a surface.
bgplot3d

Use base graphics for RGL background
clipplaneControl

Sets attributes of a clipping plane.
rgl.setMouseCallbacks

User callbacks on mouse events
clipMesh3d

Clip mesh or rgl object to general region
.check3d

Check for an open rgl window.
rgl.bbox

Set up Bounding Box decoration
as.triangles3d

Convert an object to triangles.
ellipse3d

Make an ellipsoid
as.mesh3d.rglId

Convert object in plot to mesh3d object.
light

add light source
rgl.material

Generic Appearance setup
bg3d

Set up Background
observer3d

Set the observer location.
makeDependency

Process Javascript for HTML dependency.
matrices

Work with homogeneous coordinates
figWidth

Get R Markdown figure dimensions in pixels.
rgl.postscript

export screenshot
open3d

RGL Display Functions
identify3d

Identify points in plot.
extrude3d

Generate extrusion mesh
rgl.primitive

add primitive set shape
par3dinterpControl

Control rgl widget like par3dinterp().
pch3d

Plot symbols similar to base graphics.
grid3d

Add a grid to a 3D plot
plot3d.formula

Methods for formulas
par3dinterp

Interpolator for par3d parameters
par3d

Set or Query RGL Parameters
propertyControl

Controls to use with playwidget().
readSTL

Read and write STL (stereolithography) format files
r3d

Generic 3D interface
mfrow3d

Set up multiple figure layouts in rgl.
plot3d.lm

Method for plotting simple linear fit.
mesh3d

3D Mesh objects
playwidget

Add a widget to play animations.
merge.mesh3d

Merge "mesh3d" objects.
mergeVertices

Merge duplicate vertices in mesh object
setUserShaders

Set user-defined shaders for rgl objects.
rglToLattice

Convert rgl userMatrix to lattice or base angles
rglwidget

An htmlwidget to hold an rgl scene.
propertySetter

Obsolete function to write HTML/Javascript code to control a WebGL display.
import

Imported from magrittr
rgl.useNULL

Report default use of null device.
rgl.select

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

Plot a function of two variables
sceneChange

Make large change to a scene from Shiny
persp3d

Surface plots
plotmath3d

Generate sprites using base graphics math plotting.
polygon3d

Triangulate and draw a polygon in three dimensions.
persp3d.triSht

Plot an interp or tripack Delaunay triangulation.
subsceneInfo

Get information on subscenes
rgl-internal

Internal rgl functions and data
plot3d

3D Scatterplot
setupKnitr

Displaying rgl scenes in knitr documents.
select3d

Select a rectangle in an RGL scene
subscene3d

Create, select or modify a subscene.
rgl.bringtotop

Assign focus to an RGL window
persp3d.deldir

Plot a Delaunay triangulation.
subdivision3d

generic subdivision surface method
rgl.surface

add height-field surface shape
vertexControl

Set attributes of vertices.
show2d

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

tkrgl functions
shinyGetPar3d

Communicate rgl parameters between R and Javascript in Shiny.
tkspin3d

Create TCL/TK controller for rgl window
rgl.init

Initializing rgl
writeASY

Write Asymptote code for an rgl scene
webGLcontrols

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

Set up viewpoint
rgl.attrib.info

Get information about attributes of objects
rgl.pixels

Extract pixel information from window
rgl.Sweave

Integrating rgl with Sweave
scene

scene management
rgl.open

3D visualization device system
planes3d

add planes
play3d

Play animation of rgl scene
spin3d

Create a function to spin a scene at a fixed rate
scene3d

Saves the current scene to a variable, and displays such variables.
rgl-package

3D visualization device system
turn3d

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

Triangulate a two-dimensional polygon.
rglIds

rgl id values
setGraphicsDelay

Set a one-time slowdown on opening standard graphics
snapshot3d

export screenshot
selectpoints3d

Select points from a scene
rgl.user2window

Convert between rgl user and window coordinates
spheres3d

add sphere set shape
tkpar3dsave

Modal dialog for saving par3d settings
thigmophobe3d

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

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

add sprite set shape
tkspinControl

Create a spin control in a TCL/TK window
writeWebGL

Write scene to HTML.
shapelist3d

Create and plot a list of shapes
rglMouse

Generate HTML code to select mouse mode.
rglShared

Create shared data from an rgl object.
shiny

text3d

add text
surface3d

add height-field surface shape
writePLY

Write Stanford PLY format files
writeOBJ

Read and write Wavefront OBJ format files
ageSetter

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