rgl.surface and the AREA vs POINT distinction

When we provide the rgl package function with a grid of data, we get a POINT interpretation.

The object in the scene is a triangulated surface created directly on the points we give, an as per the common image() convention the points are the centres of the cell.

library(raster)
## Loading required package: sp
r <- aggregate(raster(volcano), fact = 4, fun = "median")
r <- setExtent(r, extent(0, nrow(r), 0, ncol(r)))
library(rgl)
## Warning in rgl.init(initValue, onlyNULL): RGL: unable to open X11 display
## Warning: 'rgl_init' failed, running with rgl.useNULL = TRUE
clear3d()
#l <- as.image.SpatialGridDataFrame(as(r, "SpatialGridDataFrame"))
rgl.surface(x = xFromCol(r), z = rev(yFromRow(r)),  y =  t(as.matrix(r)), col = "grey")
bg3d("darkgrey")
#material3d(specular = "black")
aspect3d(1, .5, 1)
light3d(viewpoint.rel = FALSE)
rglwidget()

But quadmesh is strict about the actual extent of the pixels.

To compare in the same scene we have to convert qm to the orientation used by rgl.surface (x, z, y).

Some times the triangles are above and sometimes below the wire frame of the quads, due to differences in the way that interpolation is applied. Is it clear how interpolation should be applied to an AREA cell of a raster to its edges?

qm <- quadmesh::quadmesh(flip(r, "y"))

z <- qm$vb[2, ]
qm$vb[2, ] <- qm$vb[3, ]
qm$vb[3, ] <- z

wire3d(qm)
rglwidget()

What quadmesh is not strict about is the interpolation applied from cell values.