The text added can either be as an html text object, superimposed on the scene but moving relative to appear relative to the specified coordinqtes, or an actual geometry, which will appear in the scene, zoom and rotate with it etc.

text3js(
  data3js,
  x,
  y,
  z,
  text,
  size = NULL,
  col = "inherit",
  toggle = NULL,
  type = "geometry",
  alignment = "center",
  offset = c(0, 0),
  style = list(fontFamily = "sans-serif"),
  ...
)

Arguments

data3js

The data3js object

x

x coords

y

y coords

z

z coords

text

character vector of text

size

text size, if type is "geometry" this is interpreted in terms of text height within the plotting space (default 1), if type is "html" then this is interpreted as size in pts (default 16).

col

text color

toggle

associated text toggle button

type

text type, either "geometry" or "html"

alignment

text alignment, i.e. "left" "top" "topright"

offset

onscreen text offset for html text, x then y

style

named list of css style attributes to apply to the html text

...

Additional attributes to pass to material3js()

Value

Returns an updated data3js object

See also

Examples

# Set text parameters
x <- 1:4
y <- rep(0, 4)
z <- rep(0, 4)
labels <- LETTERS[1:4]
sizes <- c(0.4, 0.6, 0.8, 1)

# Create empty plot
p0 <- plot3js(
  xlim = c(0, 5),
  ylim = c(-1, 1),
  zlim = c(-1, 1),
  aspect = c(1, 1, 1),
  label_axes = FALSE
)

# Add text as a geometry
p <- text3js(
  data3js = p0,
  x = x,
  y = y,
  z = z,
  size = sizes,
  text = labels
)

r3js(p, rotation = c(0, 0, 0), zoom = 1)
# Add text as a html labels p <- text3js( data3js = p0, x = x, y = y, z = z, size = sizes*40, text = labels, type = "html" ) r3js(p, rotation = c(0, 0, 0), zoom = 1)