open3d()
obj <- translate3d(scale3d(oh3d(), 0.3, 0.3, 0.3), 0,0,2)
shade3d(obj, col = "red")
target <- icosahedron3d()
# We offset the target using polygon_offset = 1 so that the
# shadow on its surface will appear clearly.
shade3d(target, col = "white", polygon_offset = 1)
# minVertices = 1000 leaves noticeable artifacts on the edges
# of the shadow. A larger value gives a better result, but is
# slower.
# We use facing3d(target) so the shadow and outside part only
# appear on the upper side of the target
shadow3d(facing3d(target), obj, minVertices = 1000, plot=TRUE,
col = c("yellow", "blue"), outside = TRUE)
Run the code above in your browser using DataLab