build_bricks: Build 3D brick model with 'rgl'

View source: R/build-bricks-rgl.R

build_bricksR Documentation

Build 3D brick model with 'rgl'

Description

Render the output of any of the bricks_from_* functions as a 3D model. Opens an 'rgl' window.

Usage

build_bricks(
  brick_list,
  background_color = "white",
  rgl_lit = TRUE,
  outline_bricks = FALSE,
  trans_alpha = 0.5,
  view_levels = NULL
)

Arguments

brick_list

List output from a bricks_from_* function. Contains an element Img_lego.

background_color

Default 'white'. Color of the background.

rgl_lit

Default 'TRUE'. Include RGL lighting features in rendering.

outline_bricks

Default 'FALSE'. Include black outlines around brick edges. Set to 'TRUE' and rgl_lit='FALSE' for cartoon-looking bricks.

trans_alpha

Default 0.5. Alpha level for transparent bricks.

view_levels

Numeric array of Levels/z values to display. Leave as 'NULL' to include all.

Value

3D brick model rendered in the 'rgl' package.

See Also

Other 3D Models: bricks_from_coords(), bricks_from_excel(), bricks_from_mosaic(), bricks_from_table()

Examples

#This is a brick
brick <- data.frame(
 Level="A",
 X1 = rep(3,4), #The number 3 is the brickrID for 'bright red'
 X2 = rep(3,4)
)

#Convert the dataframe to a list object that can be rendered
brick_object <- brick %>% 
 bricks_from_table() 
 
#Render it
brick_object %>% 
 build_bricks()

rgl::clear3d()
 
#Combine the option rgl_lit=FALSE & outline_bricks=TRUE 
# This makes the rendering look like a drawing
brick_object %>% 
 build_bricks(outline_bricks = TRUE, rgl_lit = FALSE,
              background_color = "#99e7ff")
rgl::clear3d()


ryantimpe/brickr documentation built on Jan. 15, 2024, 10:29 p.m.