library(MeshesOperations)
library(rgl)
# parabola ####
x <- seq(-1, 1, length.out = 30)
parabola <- cylinder3d(cbind(x, x^2, 0), radius = 0.2, closed = -2)
vertices <- t(parabola$vb[-4L, ])
faces <- c(
split(t(parabola$it), 1L:ncol(parabola$it)),
split(t(parabola$ib), 1L:ncol(parabola$ib))
)
sparabola <- smoothShape(
vertices, faces, time = 0.0005, iterations = 10
)
sparabola <- toRGL(sparabola)
open3d(windowRect = c(50, 50, 950, 500))
mfrow3d(1, 2)
view3d(0, 0, zoom = 0.9)
shade3d(parabola, color = "orange")
wire3d(parabola)
next3d()
view3d(0, 0)
shade3d(sparabola, color = "green")
wire3d(sparabola)
# Stanford bunny (light version)
vf <- readMeshFile(
system.file("extdata", "bunny.off", package = "MeshesOperations")
)
mesh <- Mesh(
vf[["vertices"]], vf[["faces"]], normals = TRUE
)
rglmesh <- toRGL(mesh)
smesh <- smoothShape(
mesh = mesh,
time = 0.00001, iterations = 1, normals = TRUE
)
srglmesh <- toRGL(smesh)
open3d(windowRect = c(50, 50, 900, 500))
mfrow3d(1, 2)
view3d(0, 0, zoom = 0.8)
shade3d(rglmesh, color = "purple")
next3d()
view3d(0, 0, zoom = 0.8)
shade3d(srglmesh, color = "violetred")
Run the code above in your browser using DataLab