plotly / plotly.R

An interactive graphing library for R
https://plotly-r.com
Other
2.55k stars 625 forks source link

Large mesh3d plot is not displayed with R-4.4.0 #2352

Open stla opened 5 months ago

stla commented 5 months ago

Hello,

Since I upgraded R to version 4.4.0, my mesh3d plot no longer appears. The viewer renders a blank page. This mesh is large and if I reduce it then it appears.

library(plotly)
library(rmarchingcubes)

R <- 2
f1 <- function(x, y, z){
  x^2 + y^2 + z^2 - R^2
}
f2 <- function(x, y, z){
  (x-2)^2 + (y-2)^2 + (z-2)^2 - R^2
}
g <- function(x, y, z) {
  pmax(f1(x, y, z), f2(x, y, z))
}

n <- 100
x_ <- y_ <- z_ <- seq(-R, R, length.out = n) 
Grid <- expand.grid(X = x_, Y = y_, Z = z_)
voxel <- with(Grid, array(g(X, Y, Z), dim = c(n, n, n)))
surf <- contour3d(voxel, level = 0, x_, y_, z_)
vertices <- surf$vertices
indices  <- surf$triangles - 1L

plot_ly(
  x = vertices[, 1], y = vertices[, 2], z = vertices[, 3],
  i = indices[, 1], j = indices[, 2], k = indices[, 3],
  type = "mesh3d"
) %>% layout(scene = list(aspectmode = "data"))

If you replace n <- 100 with n <- 50 then the expected plot appears.

asadow commented 4 months ago

Not an issue on my side. Try upgrading RStudio or their viewer hotfix.

cpsievert commented 4 months ago

This is probably the same thing as https://github.com/plotly/plotly.R/issues/2353#issuecomment-2124953001