Adds text to the scene. The text is positioned in 3D space. Text is always oriented towards the camera.

text3d(x, y = NULL, z = NULL, texts, adj = 0.5, pos = NULL, offset = 0.5,
usePlotmath = is.language(texts), ...)
texts3d(x, y = NULL, z = NULL, texts, adj = 0.5, pos = NULL, offset = 0.5,
usePlotmath = is.language(texts), ...)

## Arguments

x, y, z point coordinates. Any reasonable way of defining the coordinates is acceptable. See the function xyz.coords for details. text character vector to draw one value specifying the horizontal adjustment, or two, specifying horizontal and vertical adjustment respectively, or three, specifying adjustment in all three directions. a position specifier for the text. If specified, this overrides any adj value given. Values of 0, 1, 2, 3, 4, 5, 6 respectively indicate positions at, below, to the left of, above, to the right of, in front of, and behind the specified coordinates. when pos is specified, this value gives the offset of the label from the specified coordinate in fractions of a character width. logical. Should plotmath3d be used for the text? In the other functions, additional parameters to pass to rgl.texts.

## Details

The adj parameter determines the position of the text relative to the specified coordinate. Use adj = c(0, 0) to place the left bottom corner at (x, y, z), adj = c(0.5, 0.5) to center the text there, and adj = c(1, 1) to put the right top corner there. The optional second coordinate for vertical adjustment defaults to 0.5. Placement is done using the "advance" of the string and the "ascent" of the font relative to the baseline, when these metrics are known.

text3d and texts3d draw text using the r3d conventions. These are synonyms; the former is singular to be consistent with the classic 2-D graphics functions, and the latter is plural to be consistent with all the other graphics primitives. Take your choice!

If any coordinate or text is NA, that text is not plotted.

If usePlotmath is TRUE, the work will be done by the plotmath3d function instead of rgl.texts. This is the default if the texts parameter is “language”, e.g. the result of a call to expression or quote.

## Value

The text drawing functions return the object ID of the text object (or sprites, in case of usePlotmath = TRUE) invisibly.

r3d, rgl.texts, plotmath3d, rglExtrafonts for adding fonts

## Examples

open3d()
famnum <- rep(1:3, 8)
family <- c("serif", "sans", "mono")[famnum]
font <- rep(rep(1:4, each = 3), 2)
cex <- rep(1:2, each = 12)
text3d(font, cex, famnum, text = paste(family, font), adj = 0.5,
color = "blue", family = family, font = font, cex = cex)

{"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},"rootSubscene":1686,"objects":{"1692":{"id":1692,"type":"text","material":{"lit":false},"vertices":[[1,1,1],[1,1,2],[1,1,3],[2,1,1],[2,1,2],[2,1,3],[3,1,1],[3,1,2],[3,1,3],[4,1,1],[4,1,2],[4,1,3],[1,2,1],[1,2,2],[1,2,3],[2,2,1],[2,2,2],[2,2,3],[3,2,1],[3,2,2],[3,2,3],[4,2,1],[4,2,2],[4,2,3]],"colors":[[0,0,1,1]],"texts":[["serif 1"],["sans 1"],["mono 1"],["serif 2"],["sans 2"],["mono 2"],["serif 3"],["sans 3"],["mono 3"],["serif 4"],["sans 4"],["mono 4"],["serif 1"],["sans 1"],["mono 1"],["serif 2"],["sans 2"],["mono 2"],["serif 3"],["sans 3"],["mono 3"],["serif 4"],["sans 4"],["mono 4"]],"cex":[[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2]],"adj":[[0.5,0.5,0.5]],"centers":[[1,1,1],[1,1,2],[1,1,3],[2,1,1],[2,1,2],[2,1,3],[3,1,1],[3,1,2],[3,1,3],[4,1,1],[4,1,2],[4,1,3],[1,2,1],[1,2,2],[1,2,3],[2,2,1],[2,2,2],[2,2,3],[3,2,1],[3,2,2],[3,2,3],[4,2,1],[4,2,2],[4,2,3]],"family":[["serif"],["sans"],["mono"],["serif"],["sans"],["mono"],["serif"],["sans"],["mono"],["serif"],["sans"],["mono"],["serif"],["sans"],["mono"],["serif"],["sans"],["mono"],["serif"],["sans"],["mono"],["serif"],["sans"],["mono"]],"font":[[1],[1],[1],[2],[2],[2],[3],[3],[3],[4],[4],[4],[1],[1],[1],[2],[2],[2],[3],[3],[3],[4],[4],[4]],"ignoreExtent":false,"flags":33808},"1690":{"id":1690,"type":"light","vertices":[[0,0,1]],"colors":[[1,1,1,1],[1,1,1,1],[1,1,1,1]],"viewpoint":true,"finite":false},"1689":{"id":1689,"type":"background","material":{},"colors":[[0.298039227724075,0.298039227724075,0.298039227724075,1]],"centers":[[0,0,0]],"sphere":false,"fogtype":"none","fogscale":1,"flags":32768},"1691":{"id":1691,"type":"background","material":{"lit":false,"back":"lines"},"colors":[[1,1,1,1]],"centers":[[0,0,0]],"sphere":false,"fogtype":"none","fogscale":1,"flags":32768},"1686":{"id":1686,"type":"subscene","par3d":{"antialias":8,"FOV":30,"ignoreExtent":false,"listeners":1686,"mouseMode":{"none":"none","left":"trackball","right":"zoom","middle":"fov","wheel":"pull"},"observer":[0,0,7.22832727432251],"modelMatrix":[[1,0,0,-2.5],[0,0.342020153999329,0.939692616462708,-2.39241552352905],[0,-0.939692616462708,0.342020153999329,-6.50282859802246],[0,0,0,1]],"projMatrix":[[3.73205065727234,0,0,0],[0,3.73205065727234,0,0],[0,0,-3.86370325088501,-26.0572834014893],[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":[1,4,1,2,1,3],"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":[1691,1692,1690],"subscenes":[],"flags":34064}},"crosstalk":{"key":[],"group":[],"id":[],"options":[]},"width":480,"height":480,"context":{"shiny":false,"rmarkdown":null},"players":[],"webGLoptions":{"preserveDrawingBuffer":true}},"evals":[],"jsHooks":[]}