# Allow the user to select some points, and then redraw them
# in a different color
if (interactive() && !in_pkgdown_example()) {
x <- rnorm(1000)
y <- rnorm(1000)
z <- rnorm(1000)
open3d()
points3d(x, y, z)
f <- select3d()
if (!is.null(f)) {
keep <- f(x, y, z)
pop3d()
points3d(x[keep], y[keep], z[keep], color = 'red')
points3d(x[!keep], y[!keep], z[!keep])
}
}
Run the code above in your browser using DataLab