Skip to content

Commit

Permalink
version 0.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bwlewis authored and cran-robot committed Jan 21, 2020
1 parent 20a3a3d commit 2e19a72
Show file tree
Hide file tree
Showing 34 changed files with 1,436 additions and 1,086 deletions.
23 changes: 13 additions & 10 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ Type: Package
Title: Interactive 3D Scatter Plots, Networks and Globes
Description: Create interactive 3D scatter plots, network plots, and
globes using the 'three.js' visualization library (<https://threejs.org>).
Version: 0.3.1
Date: 2017-08-11
Version: 0.3.3
Date: 2020-01-19
Authors@R: c(
person("B. W.", "Lewis", role=c("aut","cre"), email="blewis@illposed.net"),
person(given="Three.js authors", role="cph", comment="three.js JavaScript library"),
person("B. W.", "Lewis", role=c("aut","cre","cph"), email="blewis@illposed.net"),
person(given="Three.js authors", role="cph", comment="three.js library"),
person(given="jQuery Foundation", role="cph", comment="jQuery library"),
person("Alexey", "Stukalov", role=("ctb"), email="astukalov@gmail.com"),
person("Yihui","Xie", role=("ctb"), email="xie@yihui.name"),
person("Andreas", "Briese", role=("ctb"), email="ab@edutoolbox.de"),
person("B.", "Thieurmel", role=("ctb"), email="bthieurmel@gmail.com")
person("B.", "Thieurmel", role=("ctb"), email="bthieurmel@gmail.com")
)
URL: https://bwlewis.github.io/rthreejs
BugReports: https://github.com/bwlewis/rthreejs/issues
Expand All @@ -20,15 +21,17 @@ Depends: R (>= 3.0.0), igraph (>= 1.0.0)
Imports: htmlwidgets (>= 0.3.2), base64enc, crosstalk, methods, stats
Suggests: maps
Enhances: knitr, shiny
RoxygenNote: 5.0.1
Encoding: UTF-8
RoxygenNote: 7.0.2
NeedsCompilation: no
Packaged: 2017-08-12 13:04:06 UTC; blewis
Author: B. W. Lewis [aut, cre],
Three.js authors [cph] (three.js JavaScript library),
Packaged: 2020-01-21 15:03:57 UTC; blewis
Author: B. W. Lewis [aut, cre, cph],
Three.js authors [cph] (three.js library),
jQuery Foundation [cph] (jQuery library),
Alexey Stukalov [ctb],
Yihui Xie [ctb],
Andreas Briese [ctb],
B. Thieurmel [ctb]
Maintainer: B. W. Lewis <blewis@illposed.net>
Repository: CRAN
Date/Publication: 2017-08-13 05:42:40 UTC
Date/Publication: 2020-01-21 15:50:03 UTC
10 changes: 5 additions & 5 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
YEAR: 2015
YEAR: 2020
COPYRIGHT HOLDER: Bryan W. Lewis

YEAR: 2010-2015
COPYRIGHT HOLDER: Three.js authors
YEAR: 2020
COPYRIGHT HOLDER: The three.js authors

YEAR: 2011
COPYRIGHT HOLDER: David Piegza
YEAR: 2020
COPYRIGHT HOLDER: JS Foundataion, see https://js.foundation
62 changes: 32 additions & 30 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
0f6e8dc56177a8b82773808d34154a8c *DESCRIPTION
cf10c42a5f44bb5be7752319145d170e *LICENSE
f57e2e35750065a5f27dcc9649045b72 *NAMESPACE
ffd2ad564f7f6e3b39fba3065bb1f191 *DESCRIPTION
b4a3c262dc0850deac687a32926df298 *LICENSE
cbdc96e427820cbf849ac023aec43144 *NAMESPACE
aabdd587021e2651067d5f6d4e26f0ad *R/data-definitions.R
bfca02c5ef1eca857029b8a11d882397 *R/globe.R
76a17a10ee5b03d29009fe88f11445a0 *R/graph.R
2336e7a8522dfb8e82e5045fb6e12623 *R/scatterplot.R
2708cf710ee23757fa666435bf19babc *R/globe.R
ea8f98cee1aee4288d3c8595aaf62a9b *R/graph.R
a67b74b6ddb93e1873e4cdb35a0909ed *R/scatterplot.R
eb67eb1125c66ae48a40773169bf72f0 *R/threejs.R
c7028b0bd176491e7beb74cff1c485f7 *R/utilities.R
c3071533d659a11d51cf025b7953dcab *R/utilities.R
d4330e129937f1105ce48424d0117385 *README.md
15066af4ebda663340bdf26099646bea *data/LeMis.RData
848df314cedd9e8ac0f17b19279956fc *data/ego.RData
Expand All @@ -21,33 +21,35 @@ fc021e944acd156f96bfdf7757514206 *inst/examples/globe/ui.R
1d3d39b62a9d59ce120e99fca38ac7a3 *inst/examples/graph/ui.R
a5e274183bd0674770b74388f730c96a *inst/examples/scatterplot/server.R
0d9ce37a789d8f0cac06f1729527619f *inst/examples/scatterplot/ui.R
80c7ff166537c9e803db2f8f8e9d4f84 *inst/htmlwidgets/globe.js
ac95888633db4f5b03c79ce6564a11b7 *inst/htmlwidgets/globe.yaml
1959139cfe26d0db813de2f429c40be8 *inst/htmlwidgets/globe.js
95bee895d6c4c014b0220d3b181af0e5 *inst/htmlwidgets/globe.yaml
4f252523d4af0b478c810c2547a63e19 *inst/htmlwidgets/lib/jquery/jquery.min.js
90caa1488a37a14eebc22fc37396077a *inst/htmlwidgets/lib/threejs-85/CanvasRenderer.js
4d6dd2e03e067d5e949f2316f24fafe7 *inst/htmlwidgets/lib/threejs-85/Detector.js
0552b0aca46b57eaec735f14481957d6 *inst/htmlwidgets/lib/threejs-85/Projector.js
d407a71bcc14f06baeaa3b92aa0896c0 *inst/htmlwidgets/lib/threejs-85/StateOrbitControls.js
05422e3cc842a9160cd06f94bfc1a81e *inst/htmlwidgets/lib/threejs-85/TrackballControls.js
6edb4af52e4734d4a6fb4a7d96b86aef *inst/htmlwidgets/lib/threejs-85/three.min.js
fc74c0c97c7c9315996e12efc06d0fdb *inst/htmlwidgets/scatterplotThree.js
08559f00ca87882cf71bb48538d57965 *inst/htmlwidgets/scatterplotThree.yaml
90caa1488a37a14eebc22fc37396077a *inst/htmlwidgets/lib/threejs-111/CanvasRenderer.js
4d6dd2e03e067d5e949f2316f24fafe7 *inst/htmlwidgets/lib/threejs-111/Detector.js
0552b0aca46b57eaec735f14481957d6 *inst/htmlwidgets/lib/threejs-111/Projector.js
d407a71bcc14f06baeaa3b92aa0896c0 *inst/htmlwidgets/lib/threejs-111/StateOrbitControls.js
05422e3cc842a9160cd06f94bfc1a81e *inst/htmlwidgets/lib/threejs-111/TrackballControls.js
daf1a794272fc7d9234980320460cb71 *inst/htmlwidgets/lib/threejs-111/three.min.js
23e7213c0366e6495d4e907ca1a71d96 *inst/htmlwidgets/scatterplotThree.js
39849dbc756e0a29e51a7990b2a0f130 *inst/htmlwidgets/scatterplotThree.yaml
79b9e9384834cbb8f90dd8833cbeeb26 *inst/images/circle.png
708d01dffedb283c365c8c67aa36c04f *inst/images/disc.png
e03d6618d840119bbf1b6fdbac1f23a1 *inst/images/moon.jpg
41dc495690510741c61bbeda8107c947 *inst/images/plus.png
8e3ccdd0a25ef777c31a54410e2a654c *inst/images/world.jpg
f57fc618d6cdf9e4aed8ec25667bef3c *man/LeMis.Rd
c6aa315a52de452b09bf2d649914355d *man/ego.Rd
d9d9585929cd471c40964218c4e7b0f8 *man/flights.Rd
db576355308b19d00e8f4f06c796be9f *man/gcol.Rd
c1e85efa942b3d98e929e77dc4ff4612 *man/globejs.Rd
65b2fee20c7c19cdb3bf8006448cad45 *man/graphjs.Rd
5beb356237e4a8a1fd3b0b51d7b40258 *man/lines3d.Rd
929bb2c16607e9216b460f80d4674c22 *man/points3d.Rd
73da166e64438241cd98b25c17f4cdb0 *man/scatterplot3js.Rd
f078e7cb750d1feb5da359a8e8d170b2 *man/texture.Rd
bff19dc7a00ddf8f3e992b9a02b2a486 *man/threejs-package.Rd
05daa4dd13ac5ebc6299537e162d7934 *man/threejs-shiny.Rd
7b85fd4da5a18e42009a996f019040f0 *man/vertices-scatterplotThree-method.Rd
6627e5683e300fe96f43228a6156bfff *man/LeMis.Rd
0723ea57aa77ef9e86c6d320ec706445 *man/ego.Rd
a29d9fc8812b5d937cb1c34c167afa4b *man/flights.Rd
08d3a69e1701ef8d33990938e136931d *man/gcol.Rd
397b958b17e5b5802e24f312a7a832c5 *man/globejs.Rd
cc0cc22381324d648948dd546f83a0a1 *man/graphjs.Rd
c4ab794228ffdaeea22e66a2d6994ea9 *man/light_ambient.Rd
e2ff55f8ce2eedb9f97ef93c0b626256 *man/light_directional.Rd
6efbb8ad87cde286c3826089259e8092 *man/lines3d.Rd
872418d12ff7231577655f488a7a6a9d *man/points3d.Rd
1918e5df18f8b2d1bd02c8ec1dc48c6d *man/scatterplot3js.Rd
74b9b0266cbc7222ffee57a8cc03fe7e *man/texture.Rd
42f9fbff0bb6dfb0b19d5a4e917b9d49 *man/threejs-package.Rd
ffc6d21f384ba55b1ba3cc357fccadda *man/threejs-shiny.Rd
e3fa7ae55e9d24803cd038f36e145a71 *man/vertices-scatterplotThree-method.Rd
4c14459a35d8fab0a92a82c867317f26 *tests/threejs.R
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
export(globeOutput)
export(globejs)
export(graphjs)
export(light_ambient)
export(light_directional)
export(lines3d)
export(points3d)
export(renderGlobe)
Expand Down
17 changes: 13 additions & 4 deletions R/globe.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#' @param bg Plot background color.
#' @param width The container div width.
#' @param height The container div height.
#' @param elementId Use an explicit element ID for the widget (rather than an automatically generated one). Useful if you have other JavaScript that needs to explicitly discover and interact with a specific widget instance.
#' @param ... Additional arguments to pass to the three.js renderer (see
#' below for more information on these options).
#'
Expand Down Expand Up @@ -89,8 +90,9 @@
#' ll <- unique(frequent_flights[,3:4])
#' # Plot frequent destinations as bars, and the flights to and from
#' # them as arcs. Adjust arc width and color by frequency.
#' globejs(lat=ll[,1], long=ll[,2], arcs=frequent_flights, bodycolor="#aaaaff",
#' arcsHeight=0.3, arcsLwd=2, arcsColor="#ffff00", arcsOpacity=0.15,
#' globejs(lat=ll[, 1], long=ll[, 2], arcs=frequent_flights,
#' bodycolor="#aaaaff", arcsHeight=0.3, arcsLwd=2,
#' arcsColor="#ffff00", arcsOpacity=0.15,
#' atmosphere=TRUE, color="#00aaff", pointsize=0.5)
#'
#' \dontrun{
Expand Down Expand Up @@ -155,8 +157,14 @@ globejs <- function(
atmosphere=FALSE,
bg="black",
height = NULL,
width = NULL, ...)
width = NULL,
elementId=NULL,
...)
{
if(is.null(elementId))
{
elementId <- paste0(sample(c(letters, LETTERS, 0:9), 10, replace=TRUE), collapse="")
}
if (missing(lat) || missing(long))
{
lat <- NULL
Expand Down Expand Up @@ -224,7 +232,8 @@ globejs <- function(
width = width,
height = height,
htmlwidgets::sizingPolicy(padding = 0, browser.fill = TRUE),
package = "threejs")
package = "threejs",
elementId=elementId)
}

#' @rdname threejs-shiny
Expand Down
64 changes: 18 additions & 46 deletions R/graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#' @param bg plot background color
#' @param width the widget container \code{div} width in pixels
#' @param height the widget container \code{div} height in pixels
#' @param elementId Use an explicit element ID for the widget (rather than an automatically generated one). Useful if you have other JavaScript that needs to explicitly discover and interact with a specific widget instance.
#' @param ... optional additional arguments passed to \code{\link{scatterplot3js}}
#'
#' @section Interacting with the plot:
Expand Down Expand Up @@ -123,9 +124,15 @@
#' @examples
#' set.seed(1)
#' g <- sample_islands(3, 10, 5/10, 1)
#' i <- cluster_optimal(g)
#' i <- cluster_louvain(g)
#' (graphjs(g, vertex.color=c("orange", "green", "blue")[i$membership], vertex.shape="sphere"))
#'
#' # similar example with user-defined directional lighting
#' l1 = light_directional(color = "red", position = c(0, -0.8, 0.5))
#' l2 = light_directional(color = "yellow", position = c(0, 0.8, -0.5))
#' l3 = light_ambient(color = "#555555")
#' (graphjs(g, vertex.color="gray", vertex.shape="sphere", lights=list(l1, l2, l3)))
#'
#' # Les Miserables Character Co-appearance Data
#' data("LeMis")
#' (graphjs(LeMis))
Expand Down Expand Up @@ -182,53 +189,17 @@ graphjs <- function(g, layout,
vertex.color, vertex.size, vertex.shape, vertex.label,
edge.color, edge.width, edge.alpha,
main="", bg="white",
width=NULL, height=NULL, ...)
width=NULL, height=NULL,
elementId=NULL,
...)
{
# Check for package version < 0.3.0 options
warn_upgrade <- FALSE
nodes <- list(...)$nodes
edges <- list(...)$edges
if(! missing(g) && is.list(g) && is.data.frame(g[[1]]) && "edges" %in% names(g))
{
warn_upgrade <- TRUE
edges <- g$edges
nodes <- g$nodes
}
if(! missing(g) && is.data.frame(g))
{
warn_upgrade <- TRUE
edges <- g
}
if(! missing(layout) && is.data.frame(layout))
{
warn_upgrade <- TRUE
nodes <- layout
layout <- function(x) layout_with_fr(x, dim=3)
}
if(! is.null(edges))
{
warn_upgrade <- TRUE
if(! missing(g) && "color" %in% names(g)) edge.color <- g$color
g <- igraph::graph_from_data_frame(edges[, 1:2])
igraph::V(g)$color <- "orange"
}
if(! is.null(nodes))
{
warn_upgrade <- TRUE
nodes <- nodes[order(nodes$id), ]
igraph::V(g)$name <- nodes$label
vertex.label <- nodes$label
vertex.size <- nodes$size
vertex.color <- nodes$color
}
tryCatch(rm(list=c("nodes", "edges")), warning=invisible)
if(warn_upgrade)
if(is.null(elementId))
{
warning("Please upgrade to the new graphjs() interface in version >= 0.3.0 of the threejs package.\n See ?graphjs for help.")
elementId <- paste0(sample(c(letters, LETTERS, 0:9), 10, replace=TRUE), collapse="")
}

# check for list of graphs (edge animation)
if (is.list(g) && "igraph" %in% class(g[[1]]))
if (is.list(g) && inherits(g[[1]], "igraph"))
{
from <- lapply(g, as_edgelist, names=FALSE)
to <- lapply(from, function(x) x[, 2])
Expand All @@ -245,7 +216,7 @@ graphjs <- function(g, layout,
g <- g[[1]]
} else # single plot
{
if (!("igraph" %in% class(g))) stop("g must be an igraph object")
if (!(inherits(g, "igraph"))) stop("g must be an igraph object")
from <- as_edgelist(g, names=FALSE)
to <- from[, 2]
from <- from[, 1]
Expand Down Expand Up @@ -299,7 +270,7 @@ graphjs <- function(g, layout,

options <- c(list(x=layout, pch=pch, size=vertex.size, color=vertex.color, from=from, to=to,
lwd=edge.width, linealpha=edge.alpha, axis=FALSE, grid=FALSE, center=TRUE,
bg=bg, main=main, xlim=c(-1, 1), ylim=c(-1, 1), zlim=c(-1, 1)), opts)
bg=bg, main=main, xlim=c(-1, 1), ylim=c(-1, 1), zlim=c(-1, 1)), elementId=elementId, opts)
if (!all(unlist(Map(is.na, edge.color)))) options$lcol <- edge.color
if (!(length(vertex.label) == 1 && is.na(vertex.label))) options$labels <- vertex.label
options$options <- TRUE
Expand All @@ -311,7 +282,8 @@ graphjs <- function(g, layout,
height = height,
htmlwidgets::sizingPolicy(padding = 0, browser.fill = TRUE),
dependencies = crosstalk::crosstalkLibs(),
package = "threejs")
package = "threejs",
elementId = elementId)
ans$call <- match.call()
ans$vcache <- layout
ans
Expand Down
Loading

0 comments on commit 2e19a72

Please sign in to comment.