text3js.Rd
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.
The data3js object
x coords
y coords
z coords
character vector of text
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).
text color
associated text toggle button
text type, either "geometry" or "html"
text alignment, i.e. "left" "top" "topright"
onscreen text offset for html text, x then y
named list of css style attributes to apply to the html text
Additional attributes to pass to material3js()
Returns an updated data3js object
Other plot components:
arrows3js()
,
axis3js()
,
box3js()
,
grid3js()
,
legend3js()
,
light3js()
,
lines3js()
,
mtext3js()
,
points3js()
,
segments3js()
,
shape3js()
,
sphere3js()
,
surface3js()
,
triangle3js()
# 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)