Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sprites

Add sprites


Description

Adds a sprite set shape node to the scene.

Usage

sprites3d(x, y = NULL, z = NULL, radius = 1, 
          shapes = NULL, userMatrix, 
          fixedSize = FALSE, ...)
particles3d(x, y = NULL, z = NULL, radius = 1, ...)

Arguments

x, y, z

point coordinates. Any reasonable way of defining the coordinates is acceptable. See the function xyz.coords for details.

radius

vector or single value defining the sphere radius

shapes

NULL for a simple square, or a vector of identifiers of shapes in the scene

userMatrix

if shape is not NULL, the transformation matrix for the shapes

fixedSize

should sprites remain at a fixed size, or resize with the scene?

...

material properties when shapes = NULL, texture mapping is supported

Details

Simple sprites (used when shapes is NULL) are 1 by 1 squares that are directed towards the viewpoint. Their primary use is for fast (and faked) atmospherical effects, e.g. particles and clouds using alpha blended textures. Particles are sprites using an alpha-blended particle texture giving the illusion of clouds and gases. The centre of each square will be at the coordinates given by x, y, z.

When shapes is not NULL, it should be a vector of identifiers of objects to plot in the scene (e.g. as returned by plotting functions or by ids3d). These objects will be removed from the scene and duplicated as a sprite image in a constant orientation, as specified by userMatrix. The origin 0, 0, 0 will be plotted at the coordinates given by x, y, z.

The userMatrix argument is ignored for shapes = NULL. For shapes, sprites3d defaults the matrix to r3dDefaults$userMatrix.

If any coordinate is NA, the sprite is not plotted.

The id values of the shapes may be retrieved after plotting using rgl.attrib(id, "ids"); the user matrix is retrieved using rgl.attrib(id, "usermatrix").

Value

These functions are called for the side effect of displaying the sprites. The shape ID of the displayed object is returned.

See Also

Examples

open3d()
particles3d( rnorm(100), rnorm(100), rnorm(100), color = rainbow(100) )
# is the same as
sprites3d( rnorm(100), rnorm(100), rnorm(100), color = rainbow(100),
  lit = FALSE, alpha = .2,
  textype = "alpha", texture = system.file("textures/particle.png", package = "rgl") )
sprites3d( rnorm(10) + 6, rnorm(10), rnorm(10), shape = shade3d(tetrahedron3d(), col = "red") )

rgl

3D Visualization Using OpenGL

v0.106.8
GPL
Authors
Duncan Murdoch [aut, cre], Daniel Adler [aut], Oleg Nenadic [ctb], Simon Urbanek [ctb], Ming Chen [ctb], Albrecht Gebhardt [ctb], Ben Bolker [ctb], Gabor Csardi [ctb], Adam Strzelecki [ctb], Alexander Senger [ctb], The R Core Team [ctb, cph], Dirk Eddelbuettel [ctb], The authors of Shiny [cph], The authors of knitr [cph], Jeroen Ooms [ctb], Yohann Demont [ctb], Joshua Ulrich [ctb], Xavier Fernandez i Marin [ctb], George Helffrich [ctb], Ivan Krylov [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.