Text Object
text3d(
label,
x = 0,
y = 0,
z = 0,
text_height = 1,
orientation = "xy",
material = diffuse(),
font = "sans",
font_style = "plain",
font_color = "black",
font_lineheight = 1,
font_size = 100,
background_color = "white",
background_alpha = 0,
angle = c(0, 0, 0),
order_rotation = c(1, 2, 3),
flipped = FALSE,
scale = c(1, 1, 1)
)
Text string.
Default `0`. x-coordinate of the center of the label.
Default `0`. y-coordinate of the center of the label.
Default `0`. z-coordinate of the center of the label.
Default `1`. Height of the text.
Default `xy`. Orientation of the plane. Other options are `yz` and `xz`.
Default diffuse
. The material, called from one of the material
functions diffuse
, metal
, or dielectric
.
Default `"sans"`. A character string specifying the font family (e.g., `"Arial"`, `"Times"`, `"Helvetica"`).
A character string specifying the font style, such as `"plain"`, `"italic"`, or `"bold"`. Default is `"plain"`.
Default `"black"`. The font color.
Default `12`. The lineheight for strings with newlines.
Default `100`. The size of the font. Note that this does not control the size of the text, just the resolution as rendered in the texture.
Default `"white"`. The background color.
Default `0`. The background opacity. `1` is fully opaque.
Default `c(0, 0, 0)`. Angle of rotation around the x, y, and z axes, applied in the order specified in `order_rotation`.
Default `c(1, 2, 3)`. The order to apply the rotations, referring to "x", "y", and "z".
Default `FALSE`. Whether to flip the normals.
Default `c(1, 1, 1)`. Scale transformation in the x, y, and z directions. If this is a single value, number, the object will be scaled uniformly. Note: emissive objects may not currently function correctly when scaled.
Single row of a tibble describing the text in the scene.
#Generate a label in the cornell box.
if(run_documentation()) {
generate_cornell() %>%
add_object(text3d(label="Cornell Box", x=555/2,y=555/2,z=555/2,text_height=60,
material=diffuse(color="grey10"), angle=c(0,180,0))) %>%
render_scene(samples=16)
}
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,555/2)` fov `40` .
if(run_documentation()) {
#Change the orientation
generate_cornell() %>%
add_object(text3d(label="YZ Plane", x=550,y=555/2,z=555/2,text_height=150,
orientation = "yz",
material=diffuse(color="grey10"), angle=c(0,180,0))) %>%
add_object(text3d(label="XY Plane", z=550,y=555/2,x=555/2,text_height=150,
orientation = "xy",
material=diffuse(color="grey10"), angle=c(0,180,0))) %>%
add_object(text3d(label="XZ Plane", z=555/2,y=5,x=555/2,text_height=150,
orientation = "xz",
material=diffuse(color="grey10"))) %>%
render_scene(samples=16)
}
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,555/2)` fov `40` .
if(run_documentation()) {
#Add an label in front of a sphere
generate_cornell() %>%
add_object(text3d(label="Cornell Box", x=555/2,y=555/2,z=555/2,text_height=90,
material=diffuse(color="grey10"), angle=c(0,180,0))) %>%
add_object(text3d(label="Sphere", x=555/2,y=100,z=100,text_height=60,
material=diffuse(color="white"), angle=c(0,180,0))) %>%
add_object(sphere(y=100,radius=100,z=555/2,x=555/2,
material=glossy(color="purple"))) %>%
add_object(sphere(y=555,radius=100,z=-1000,x=555/2,
material=light(intensity=100,
spotlight_focus=c(555/2,100,100)))) %>%
render_scene(samples=16)
}
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,555/2)` fov `40` .
if(run_documentation()) {
#A room full of bees
bee_list = list()
for(i in 1:100) {
bee_list[[i]] = text3d("B", x=20+runif(1)*525, y=20+runif(1)*525, z=20+runif(1)*525,
text_height = 50, angle=c(0,180,0))
}
bees = do.call(rbind,bee_list)
generate_cornell() %>%
add_object(bees) %>%
render_scene(samples=16)
}
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,555/2)` fov `40` .
if(run_documentation()) {
# If you have ragg installed, you can also use color emojis.
library(rayrender)
generate_cornell(light_position = c(555/2,554,10),
lightwidth = 10, lightdepth = 100,
lightintensity = 800) |>
add_object(text3d(label="🌊",font_size = 500,angle=c(0,180,0),
x=555/2,y=555/2,z=260,text_height=1000)) |>
add_object(text3d(label="🚣", x=180,y=140,z=260-50,
text_height=400, font_size = 500,
material=diffuse(color="black"),
angle=c(0,0,30))) |>
add_object(text3d(label="🗻", x=180,y=230,z=260+50,text_height=300,
font_size = 500,material=diffuse(color="black"),
angle=c(0,0,0))) |>
render_scene(samples=16)
}
#> Warning: font metrics unknown for Unicode character U+1F5FB
#> Warning: font metrics unknown for Unicode character U+1F5FB
#> Warning: font metrics unknown for Unicode character U+1F6A3
#> Warning: font metrics unknown for Unicode character U+1F6A3
#> Warning: font metrics unknown for Unicode character U+1F30A
#> Warning: font metrics unknown for Unicode character U+1F30A
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,555/2)` fov `40` .