Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render_shapelist3d function for visualizing arbitrary mesh objects. #314

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export(render_polygons)
export(render_raymesh)
export(render_resize_window)
export(render_scalebar)
export(render_shapelist3d)
export(render_snapshot)
export(render_tree)
export(render_water)
Expand Down
59 changes: 59 additions & 0 deletions R/render_shapelist3d.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#'@title Render a generic mesh3d
#'
#'@description Places a mesh shapelists to the current scene, using latitude/longitude or coordinates in the reference
#'
#
#'@param shapelist The shapelists RGL meshes generated with shapelist3d function
#'@param color Default NULL.
#'
#'@return Adds shapelists to current scene. No return value.
#'@export
#'@examples
#'#Add a North arrow to the map, by default in the bottom right (SE)
#'if(interactive()) {
#'\dontrun{
#'montereybay %>%
#' sphere_shade() %>%
#' plot_3d(montereybay,theta=-45, water=TRUE)
#'
#'render_shapelist3d(shapelist3d(icosahedron3d(),
#' x = rnorm(3, sd = shape.scale), y = rnorm(3, sd = shape.scale),
#' z = rnorm(3, mean = shape.scale, sd = shape.scale),
#' alpha = 0.3, col = 1:5, size = 10, plot = FALSE))
#'
#'render_snapshot()
#'
#'
#'#We can change the colors in the compass, and also set it a constant distance away with
#'#`position_circular = TRUE`:
#'
#'render_camera(theta=0,phi=45,zoom=0.75)
#'
#'render_shapelist3d(shapelist3d(icosahedron3d(),
#' x = rnorm(3, sd = shape.scale), y = rnorm(3, sd = shape.scale),
#' z = rnorm(3, mean = shape.scale, sd = shape.scale),
#' alpha = 0.3, col = 1:5, size = 10, plot = FALSE))
#'

#'render_snapshot(clear=TRUE)
#'}
#'}
#'
render_shapelist3d = function(shapelist = shapelist3d(icosahedron3d(), x = 0, y = 0,
z = 0, col = 1, size = 40, plot = FALSE),
color = NULL
) {
if(rgl::rgl.cur() == 0) {
stop("No rgl window currently open.")
}
change_color_shape = function(shapes, color, shape_index) {
color = convert_color(color, as_hex = TRUE)
shapes[[shape_index]]$material$color = color
shapes
}
if (!is.null(color)){
shapelist = change_color_shape(shapelist, color, 1)
}
#rgl::rgl.material(color = color, ambient = ambient, size = 1)
rgl::shade3d(shapelist, skipRedraw = FALSE)
}
54 changes: 54 additions & 0 deletions man/render_shapelist3d.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.