2

I have 3D vertex coordinates (vb.xlsx) and face information (it.xlsx) for human face available here. I managed to plot 3D surface mesh with rgl package by providing both vertex and face information (see here). What surprised me is that with plotly package in R, I can get solid 3D surface mesh of human face only by providing vertex data, where face information is unnecessary. Below is my R code to generate the surface mesh:

library(plotly)
library(xlsx)

vb <- read.xlsx("E:\\Research\\GM\\3D started\\Spatially dense\\Point cloud to mesh\\vb.xlsx", sheetIndex = 1, header = F)

Sys.setenv("plotly_username"="<MY USER NAME>")
Sys.setenv("plotly_api_key"="<MY KEY>")

face <- plot_ly(
    x = vb[,1], y = vb[,2], z = vb[,3], # Note only vertex provided
    type = "mesh3d"
)

face

The resultant surface mesh is as follows: enter image description here

My question is how does plotly managed to generate 3D surface mesh without face information? Can anyone show me the magic code under the hood so that I could do the same thing outside plotly with some self-written code?

Thank you.

user2554330
  • 37,248
  • 4
  • 43
  • 90
Patrick
  • 1,057
  • 9
  • 23
  • 1
    This is documented on the plotly help page https://plot.ly/r/reference/#mesh3d: it can do Delaunay triangulation (like `rgl::persp3d.deldir`) or the "alpha-shape" algorithm (which isn't supported by `rgl`). – user2554330 Jan 01 '19 at 17:26
  • The `alphashape3d` package does the "alpha-shape" algorithm, and has a `plot` method using `rgl`. – user2554330 Jan 01 '19 at 17:48
  • If anyone's desperately trying to figure out how to add faces to plotly: https://stackoverflow.com/a/39175718/11738400 – mri Jun 27 '22 at 06:46

0 Answers0