Skip to content

Commit

Permalink
Quick bugfix to ray_shade and plot_3d
Browse files Browse the repository at this point in the history
  • Loading branch information
tylermorganwall committed Aug 10, 2018
1 parent ddd841d commit b72c3e4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions R/plot_3d.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
#'#Plotting a spherical texture map of the built-in `montereybay` dataset.
#'montereybay %>%
#' sphere_shade(texture="desert") %>%
#' plot_3d(montereybay,waterdepth=0)
#' plot_3d(montereybay,zscale=50)
#'
#'#With a water layer
#'montereybay %>%
#' sphere_shade(texture="imhof2") %>%
#' plot_3d(montereybay, zscale=50, water = TRUE, watercolor="imhof2",
#' waterlinecolor="white", waterlinealpha=0.5, windowsize=c(1000,1000))
#' waterlinecolor="white", waterlinealpha=0.5)
plot_3d = function(hillshade, heightmap, zscale=1,
solid = TRUE, soliddepth="auto", solidcolor="grey20",solidlinecolor="grey40",
shadow = TRUE, shadowdepth = "auto", shadowwidth = "auto", shadowalpha=1,
Expand All @@ -52,7 +52,7 @@ plot_3d = function(hillshade, heightmap, zscale=1,
#setting default zscale if montereybay is used and tell user about zscale
argnameschar = unlist(lapply(as.list(sys.call()),as.character))[-1]
argnames = as.list(sys.call())
if(argnameschar[2] == "montereybay" || argnameschar["heightmap"] == "montereybay") {
if(argnameschar[2] == "montereybay" || (!is.na(argnameschar["heightmap"]) && argnameschar["heightmap"] == "montereybay")) {
if (!("zscale" %in% as.character(names(argnames)))) {
if(length(argnames) <= 3) {
zscale = 200
Expand Down
2 changes: 1 addition & 1 deletion R/ray_shade.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ ray_shade = function(heightmap, anglebreaks=seq(40,50,1), sunangle=315, maxsearc
doParallel::registerDoParallel(cl, cores = numbercores)
shadowmatrixlist = tryCatch({
foreach::foreach(i=1:nrow(heightmap), .packages = c("rayshader")) %dopar% {
rayshade_multicore(sunangle = sunangle_rad, anglebreaks = anglebreaks_rad,
rayshader:::rayshade_multicore(sunangle = sunangle_rad, anglebreaks = anglebreaks_rad,
heightmap = flipud(heightmap), zscale = zscale,
maxsearch = maxsearch, row = i-1, cache_mask = cache_mask[i,])
}
Expand Down
6 changes: 3 additions & 3 deletions man/plot_3d.Rd

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

0 comments on commit b72c3e4

Please sign in to comment.