Adds a sphere set shape node to the scene

spheres3d(x, y = NULL, z = NULL, radius = 1, fastTransparency = TRUE, ...)

## Arguments

x, y, z

Numeric vector of point coordinates corresponding to the center of each sphere. 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/radii

fastTransparency

logical value indicating whether fast sorting should be used for transparency. See the Details.

...

Material properties. See material3d for details.

## Details

If a non-isometric aspect ratio is chosen, these functions will still draw objects that appear to the viewer to be spheres. Use ellipse3d to draw shapes that are spherical in the data scale.

When the scale is not isometric, the radius is measured in an average scale. In this case the bounding box calculation is iterative, since rescaling the plot changes the shape of the spheres in user-coordinates, which changes the bounding box. Versions of rgl prior to 0.92.802 did not do this iterative adjustment.

If any coordinate or radius is NA, the sphere is not plotted.

If a texture is used, its bitmap is wrapped around the sphere, with the top edge at the maximum y coordinate, and the left-right edges joined at the maximum in the z coordinate, centred in x.

If the alpha material value of the spheres is less than the default 1, they need to be drawn in order from back to front. When fastTransparency is TRUE, this is approximated by sorting the centers and drawing complete spheres in that order. This produces acceptable results in most cases, but artifacts may be visible, especially if the radius values vary, or they intersect other transparent objects. Setting fastTransparency = FALSE will cause the sorting to apply to each of the 480 facets of individual spheres. This is much slower, but may produce better output.

## Value

A shape ID of the spheres object is returned.

## See also

material3d, aspect3d for setting non-isometric scales

## Examples

open3d()
spheres3d(rnorm(10), rnorm(10), rnorm(10),
radius = runif(10), color = rainbow(10))

{"x":{"material":{"color":"#000000","alpha":1,"lit":true,"ambient":"#000000","specular":"#FFFFFF","emission":"#000000","shininess":50,"smooth":true,"front":"filled","back":"filled","size":3,"lwd":1,"fog":true,"point_antialias":false,"line_antialias":false,"texture":null,"textype":"rgb","texmipmap":false,"texminfilter":"linear","texmagfilter":"linear","texenvmap":false,"depth_mask":true,"depth_test":"less","isTransparent":false,"polygon_offset":[0,0],"margin":"","floating":false,"tag":""},"rootSubscene":1751,"objects":{"1757":{"id":1757,"type":"spheres","material":{},"vertices":"0","colors":"1","radii":[[0.589557349681854],[0.805778682231903],[0.940319538116455],[0.115671552717686],[0.00982612557709217],[0.406939387321472],[0.352733850479126],[0.593592643737793],[0.834443151950836],[0.400439471006393]],"centers":"2","ignoreExtent":false,"fastTransparency":true,"flags":32771},"1755":{"id":1755,"type":"light","vertices":[[0,0,1]],"colors":[[1,1,1,1],[1,1,1,1],[1,1,1,1]],"viewpoint":true,"finite":false},"1754":{"id":1754,"type":"background","material":{},"colors":"3","centers":"4","sphere":false,"fogtype":"none","fogscale":1,"flags":32768},"1756":{"id":1756,"type":"background","material":{"lit":false,"back":"lines"},"colors":"5","centers":"6","sphere":false,"fogtype":"none","fogscale":1,"flags":32768},"1751":{"id":1751,"type":"subscene","par3d":{"antialias":8,"FOV":30,"ignoreExtent":false,"listeners":1751,"mouseMode":{"none":"none","left":"trackball","right":"zoom","middle":"fov","wheel":"pull"},"observer":[0,0,15.1253232955933],"modelMatrix":[[1,0,0,-0.548823952674866],[0,0.342020153999329,0.939692616462708,0.165509164333344],[0,-0.939692616462708,0.342020153999329,-15.1210775375366],[0,0,0,1]],"projMatrix":[[3.73205089569092,0,0,0],[0,3.73205089569092,0,0],[0,0,-3.86370348930359,-54.5250434875488],[0,0,-1,0]],"skipRedraw":false,"userMatrix":[[1,0,0,0],[0,0.342020143325668,0.939692620785909,0],[0,-0.939692620785909,0.342020143325668,0],[0,0,0,1]],"userProjection":[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],"scale":[1,1,1],"viewport":{"x":0,"y":0,"width":1,"height":1},"zoom":1,"bbox":[-2.43578052520752,3.53342843055725,-1.90683650970459,1.80160021781921,-1.88297438621521,1.56901490688324],"windowRect":[0,0,256,256],"family":"sans","font":1,"cex":1,"useFreeType":true,"fontname":"NULL","maxClipPlanes":2147483647,"glVersion":"NA","activeSubscene":0},"embeddings":{"viewport":"replace","projection":"replace","model":"replace","mouse":"replace"},"objects":[1756,1757,1755],"subscenes":[],"flags":33027}},"crosstalk":{"key":[],"group":[],"id":[],"options":[]},"width":480,"height":480,"context":{"shiny":false,"rmarkdown":null},"buffer":{"accessors":[{"bufferView":0,"componentType":5126,"count":10,"type":"VEC3"},{"bufferView":1,"componentType":5126,"count":10,"type":"VEC4"},{"bufferView":2,"componentType":5126,"count":10,"type":"VEC3"},{"bufferView":3,"componentType":5126,"count":1,"type":"VEC4"},{"bufferView":4,"componentType":5121,"count":1,"type":"VEC3"},{"bufferView":5,"componentType":5121,"count":1,"type":"VEC4"},{"bufferView":6,"componentType":5121,"count":1,"type":"VEC3"}],"bufferViews":[{"buffer":0,"byteLength":120,"byteOffset":0},{"buffer":0,"byteLength":160,"byteOffset":120},{"buffer":0,"byteLength":120,"byteOffset":280},{"buffer":0,"byteLength":16,"byteOffset":400},{"buffer":0,"byteLength":3,"byteOffset":416},{"buffer":0,"byteLength":4,"byteOffset":419},{"buffer":0,"byteLength":3,"byteOffset":423}],"buffers":[{"byteLength":426,"bytes":"YLJxvzkkmz/Cfds+5qPQv+yYDT/Rgz++YSiYP/gYDb8UYH2+5TqYPus0+b4Sg4m/6TaDv7/w\n0j3tjhi/w1Evv9tyZT637ry/a3r4vnGFkD6Lvja/DLiIP2AYqL97Y5e/LbwsQDr+0L7lDDw/\nFCXivxj5bT9zSYC/AACAPwAAAAAAAAAAAACAPwAAgD+amRk/AAAAAAAAgD/NzEw/AACAPwAA\nAAAAAIA/zcxMPgAAgD8AAAAAAACAPwAAAAAAAIA/zczMPgAAgD8AAAAAAACAPwAAgD8AAIA/\nAAAAAM3MzD4AAIA/AACAP83MTD4AAAAAAACAPwAAgD/NzEw/AAAAAAAAgD8AAIA/AACAPwAA\nAACamRk/AACAP2Cycb85JJs/wn3bPuaj0L/smA0/0YM/vmEomD/4GA2/FGB9vuU6mD7rNPm+\nEoOJv+k2g7+/8NI97Y4Yv8NRL7/bcmU+t+68v2t6+L5xhZA+i742vwy4iD9gGKi/e2OXvy28\nLEA6/tC+5Qw8PxQl4r8Y+W0/c0mAv5mYmD6ZmJg+mZiYPgAAgD8AAAABAQEBAAAA"}]},"players":[],"webGLoptions":{"preserveDrawingBuffer":true}},"evals":[],"jsHooks":[]}