write WebGL from R

Take the ETOPO5 data set from the geomapdata package and turn it into a 3d plot, after resizing to reduce the amount of data.

#install.packages(c("rgl", 
#                   "quadmesh", 
#                   "raster", 
#                   "geomapdata"))
library(rgl)
library(quadmesh)
library(raster)
## Loading required package: sp
library(geomapdata)

## worldwide topographic data
data("ETOPO5")
etopo5 <- setExtent(raster(t(ETOPO5), crs = "+proj=longlat +ellps=WGS84"), extent(range(attr(ETOPO5, "lon")), range(attr(ETOPO5, "lat"))))


qm <- quadmesh(aggregate(etopo5, fact = 30, method = "ngb"))
shade3d(qm, col = "grey"); aspect3d(1,1,0.1)
rglwidget(elementId="Etopo150", width = 700, height = 700)

If I use fact = 10 then the output .html is 45Mb and the page doesn’t render anything at all. Is this a fundamental limitation of WebGL or is it the pathway from R via rgl::writeWebGL?

(Obviously in future we want some kind of hooks back into R or directly from the web application to the data source, however best done, so that not all the data is transferred in one big bulk step. )