Inserting rgl as webgl in an Rmarkdown document - Part 2

How to insert rgl as webgl in an Rmarkdown document - Part 2

This post is really a mini-reminder to myself on how to insert an rgl render as webgl within an Rmarkdown document.

library(rgl)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Draw a 3D cube! Woo!
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shade3d(cube3d(color = rep(rainbow(6), rep(4, 6))))

Use your mouse, mouse buttons and scrollwheel to manipulate the 3d plot

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Display the last render 
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (!interactive()) rgl::rglwidget()