bwlewis / rthreejs

Three.js widgets for R and shiny
http://bwlewis.github.io/rthreejs
Other
303 stars 64 forks source link

stuff.camera.aspect is not updated when the window size is changed #82

Closed kwunlyou closed 4 years ago

kwunlyou commented 6 years ago

Hi @bwlewis,

I had an issue when using globejs(). The rendered object is rendered in a wrong scale once the browser window size is changed. It is due to stuff.camera.aspect wasn't updated in resize().

Kun

lintr-bot commented 6 years ago

R/graph.R:191:5: style: Place a space before left parenthesis, except in a function call.

​  if(! missing(g) && is.list(g) && is.data.frame(g[[1]]) && "edges" %in% names(g))
    ^

R/graph.R:197:5: style: Place a space before left parenthesis, except in a function call.

​  if(! missing(g) && is.data.frame(g))
    ^

R/graph.R:202:5: style: Place a space before left parenthesis, except in a function call.

​  if(! missing(layout) && is.data.frame(layout))
    ^

R/graph.R:208:5: style: Place a space before left parenthesis, except in a function call.

​  if(! is.null(edges))
    ^

R/graph.R:211:7: style: Place a space before left parenthesis, except in a function call.

​    if(! missing(g) && "color" %in% names(g)) edge.color <- g$color
      ^

R/graph.R:215:5: style: Place a space before left parenthesis, except in a function call.

​  if(! is.null(nodes))
    ^

R/graph.R:225:5: style: Place a space before left parenthesis, except in a function call.

​  if(warn_upgrade)
    ^

R/render.R:41:1: style: Lines should not be more than 130 characters.

​  x <- list(datauri=jsuri(scene), bg=bg, camera_position=camera_position, camera_lookat=camera_lookat, ambient=ambient, lights=lights)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/scatterplot.R:19:94: style: Trailing whitespace is superfluous.

​#' for the axis with the smallest \code{axis.scale}, and the number of ticks on the remaining 
                                                                                             ^

R/scatterplot.R:20:101: style: Trailing whitespace is superfluous.

​#' axes will be increased proportionally to the \code{axis.scale} values. Set to NULL to not display 
                                                                                                    ^

R/scatterplot.R:63:92: style: Trailing whitespace is superfluous.

​#' you instead need to maintain the relative distances between points in the original data, 
                                                                                           ^

R/scatterplot.R:228:20: style: Commas should always have a space after.

​  axis.scale = c(1,1,1),
                   ^

R/scatterplot.R:228:22: style: Commas should always have a space after.

​  axis.scale = c(1,1,1),
                     ^

R/scatterplot.R:255:5: style: Place a space before left parenthesis, except in a function call.

​  if(renderer == "canvas")
    ^

R/scatterplot.R:274:1: style: Trailing whitespace is superfluous.

​  
^~

R/scatterplot.R:303:5: style: Place a space before left parenthesis, except in a function call.

​  if(any(is.na(axis.scale))) {
    ^

R/scatterplot.R:306:7: style: Place a space before left parenthesis, except in a function call.

​    if(length(axis.scale)!=3) {
      ^

R/scatterplot.R:310:34: style: Commas should always have a space after.

​    axis.scale <- axis.scale[c(1,3,2)]
                                 ^

R/scatterplot.R:310:36: style: Commas should always have a space after.

​    axis.scale <- axis.scale[c(1,3,2)]
                                   ^

R/scatterplot.R:315:30: style: Remove spaces before the left parenthesis in a function call.

​  x <- lapply(x, function(x) ((x[, 1:3, drop=FALSE] - rep(mn, each = n)) / rep((mx - mn)/axis.scale, each = n)))
                             ^

R/scatterplot.R:342:9: style: Place a space before left parenthesis, except in a function call.

​      if(length(num.ticks) != 1) {
        ^

R/scatterplot.R:345:32: style: Commas should always have a space after.

​      num.ticks <- round(max(1,num.ticks) * axis.scale)
                               ^

R/scatterplot.R:380:1: style: Trailing whitespace is superfluous.

​  
^~

R/scatterplot.R:383:1: style: Trailing whitespace is superfluous.

​  
^~

R/scatterplot.R:422:29: style: Use <-, not =, for assignment.

​    names(options$vertices) = NULL
                            ^

R/scatterplot.R:423:26: style: Use <-, not =, for assignment.

​    names(options$color) = NULL
                         ^

R/scatterplot.R:424:26: style: Use <-, not =, for assignment.

​    names(options$alpha) = NULL
                         ^

R/scatterplot.R:425:25: style: Use <-, not =, for assignment.

​    names(options$from) = NULL
                        ^

R/scatterplot.R:426:23: style: Use <-, not =, for assignment.

​    names(options$to) = NULL
                      ^

R/scatterplot.R:427:25: style: Use <-, not =, for assignment.

​    names(options$main) = NULL
                        ^

R/scatterplot.R:441:7: style: Place a space before left parenthesis, except in a function call.

​    if(!is.null(options$from))
      ^

R/scatterplot.R:510:3: style: Trailing whitespace is superfluous.

​#' 
  ^

R/scatterplot.R:549:5: style: Place a space before left parenthesis, except in a function call.

​  if(is.list(s$vcache)) x <- rbind(s$vcache[[N]], x)
    ^

R/scatterplot.R:622:5: style: Place a space before left parenthesis, except in a function call.

​  if(lf != length(to)) stop("`from` and `to` must be the same length")
    ^

R/scatterplot.R:640:7: style: Place a space before left parenthesis, except in a function call.

​    if(is.list(options$from[[N]])) options$from[[N]] <- c(unlist(options$from[[N]]), unlist(from))
      ^

R/scatterplot.R:642:7: style: Place a space before left parenthesis, except in a function call.

​    if(is.list(options$to[[N]])) options$to[[N]] <- c(unlist(options$to[[N]]), unlist(to))
      ^

R/utilities.R:130:5: style: Place a space before left parenthesis, except in a function call.

​  if(is.character(x) && file.exists(x)) return(dataURI(file=x, encoding=NULL, mime="application/javascript"))
    ^
lintr-bot commented 6 years ago

R/graph.R:191:5: style: Place a space before left parenthesis, except in a function call.

​  if(! missing(g) && is.list(g) && is.data.frame(g[[1]]) && "edges" %in% names(g))
    ^

R/graph.R:197:5: style: Place a space before left parenthesis, except in a function call.

​  if(! missing(g) && is.data.frame(g))
    ^

R/graph.R:202:5: style: Place a space before left parenthesis, except in a function call.

​  if(! missing(layout) && is.data.frame(layout))
    ^

R/graph.R:208:5: style: Place a space before left parenthesis, except in a function call.

​  if(! is.null(edges))
    ^

R/graph.R:211:7: style: Place a space before left parenthesis, except in a function call.

​    if(! missing(g) && "color" %in% names(g)) edge.color <- g$color
      ^

R/graph.R:215:5: style: Place a space before left parenthesis, except in a function call.

​  if(! is.null(nodes))
    ^

R/graph.R:225:5: style: Place a space before left parenthesis, except in a function call.

​  if(warn_upgrade)
    ^

R/render.R:41:1: style: Lines should not be more than 130 characters.

​  x <- list(datauri=jsuri(scene), bg=bg, camera_position=camera_position, camera_lookat=camera_lookat, ambient=ambient, lights=lights)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/scatterplot.R:19:94: style: Trailing whitespace is superfluous.

​#' for the axis with the smallest \code{axis.scale}, and the number of ticks on the remaining 
                                                                                             ^

R/scatterplot.R:20:101: style: Trailing whitespace is superfluous.

​#' axes will be increased proportionally to the \code{axis.scale} values. Set to NULL to not display 
                                                                                                    ^

R/scatterplot.R:63:92: style: Trailing whitespace is superfluous.

​#' you instead need to maintain the relative distances between points in the original data, 
                                                                                           ^

R/scatterplot.R:228:20: style: Commas should always have a space after.

​  axis.scale = c(1,1,1),
                   ^

R/scatterplot.R:228:22: style: Commas should always have a space after.

​  axis.scale = c(1,1,1),
                     ^

R/scatterplot.R:255:5: style: Place a space before left parenthesis, except in a function call.

​  if(renderer == "canvas")
    ^

R/scatterplot.R:274:1: style: Trailing whitespace is superfluous.

​  
^~

R/scatterplot.R:303:5: style: Place a space before left parenthesis, except in a function call.

​  if(any(is.na(axis.scale))) {
    ^

R/scatterplot.R:306:7: style: Place a space before left parenthesis, except in a function call.

​    if(length(axis.scale)!=3) {
      ^

R/scatterplot.R:310:34: style: Commas should always have a space after.

​    axis.scale <- axis.scale[c(1,3,2)]
                                 ^

R/scatterplot.R:310:36: style: Commas should always have a space after.

​    axis.scale <- axis.scale[c(1,3,2)]
                                   ^

R/scatterplot.R:315:30: style: Remove spaces before the left parenthesis in a function call.

​  x <- lapply(x, function(x) ((x[, 1:3, drop=FALSE] - rep(mn, each = n)) / rep((mx - mn)/axis.scale, each = n)))
                             ^

R/scatterplot.R:342:9: style: Place a space before left parenthesis, except in a function call.

​      if(length(num.ticks) != 1) {
        ^

R/scatterplot.R:345:32: style: Commas should always have a space after.

​      num.ticks <- round(max(1,num.ticks) * axis.scale)
                               ^

R/scatterplot.R:380:1: style: Trailing whitespace is superfluous.

​  
^~

R/scatterplot.R:383:1: style: Trailing whitespace is superfluous.

​  
^~

R/scatterplot.R:422:29: style: Use <-, not =, for assignment.

​    names(options$vertices) = NULL
                            ^

R/scatterplot.R:423:26: style: Use <-, not =, for assignment.

​    names(options$color) = NULL
                         ^

R/scatterplot.R:424:26: style: Use <-, not =, for assignment.

​    names(options$alpha) = NULL
                         ^

R/scatterplot.R:425:25: style: Use <-, not =, for assignment.

​    names(options$from) = NULL
                        ^

R/scatterplot.R:426:23: style: Use <-, not =, for assignment.

​    names(options$to) = NULL
                      ^

R/scatterplot.R:427:25: style: Use <-, not =, for assignment.

​    names(options$main) = NULL
                        ^

R/scatterplot.R:441:7: style: Place a space before left parenthesis, except in a function call.

​    if(!is.null(options$from))
      ^

R/scatterplot.R:510:3: style: Trailing whitespace is superfluous.

​#' 
  ^

R/scatterplot.R:549:5: style: Place a space before left parenthesis, except in a function call.

​  if(is.list(s$vcache)) x <- rbind(s$vcache[[N]], x)
    ^

R/scatterplot.R:622:5: style: Place a space before left parenthesis, except in a function call.

​  if(lf != length(to)) stop("`from` and `to` must be the same length")
    ^

R/scatterplot.R:640:7: style: Place a space before left parenthesis, except in a function call.

​    if(is.list(options$from[[N]])) options$from[[N]] <- c(unlist(options$from[[N]]), unlist(from))
      ^

R/scatterplot.R:642:7: style: Place a space before left parenthesis, except in a function call.

​    if(is.list(options$to[[N]])) options$to[[N]] <- c(unlist(options$to[[N]]), unlist(to))
      ^

R/utilities.R:130:5: style: Place a space before left parenthesis, except in a function call.

​  if(is.character(x) && file.exists(x)) return(dataURI(file=x, encoding=NULL, mime="application/javascript"))
    ^
codecov-io commented 6 years ago

Codecov Report

Merging #82 into master will decrease coverage by 11.57%. The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #82       +/-   ##
===========================================
- Coverage    53.4%   41.82%   -11.58%     
===========================================
  Files           5        5               
  Lines         558      471       -87     
===========================================
- Hits          298      197      -101     
- Misses        260      274       +14
Impacted Files Coverage Δ
R/graph.R 49.48% <0%> (-20.27%) :arrow_down:
R/globe.R 65.3% <0%> (-11.51%) :arrow_down:
R/scatterplot.R 41.44% <0%> (-8.56%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 84e42da...517b8b9. Read the comment docs.

bwlewis commented 4 years ago

Hi @kwunlyou I wanted to (very late, sorry) thank you for this. This idea ended up incorporated in a larger redo of the render function.

There will be a CRAN update of this package before the end of the year, finally.

Best,

Bryan