hypertidy / quadmesh

raster grid as indexed quad mesh
https://hypertidy.github.io/quadmesh/
25 stars 2 forks source link

whaat is causing this rgl problem #10

Closed mdsumner closed 5 years ago

mdsumner commented 5 years ago

image

library(ceramic)
library(raster)
r <- raster::raster('../r2vr3_shading/data/ELVIS_CLIP.tif')
e <- new("Extent", xmin = -399385.062565881, xmax = -395571.828168234, 
         ymin = -44988.0566170369, ymax = -42439.9607344968)
r <- crop(r, e)
projr <- raster::projectExtent(r, "+proj=longlat")

im <- cc_location(cbind(mean(c(xmin(projr), xmax(projr))), mean(c(ymin(projr), ymax(projr)))), type = "mapbox.satellite")
projection(im) <- "+proj=merc +a=6378137 +b=6378137"
## image is all right
plotRGB(im)                 

## texture onto mesh
library(quadmesh)
qm <- quadmesh(r, texture = im)

## add triangles and drop quads
qm$it <- triangulate_quads(qm$ib)
qm$ib <- NULL
qm$primitivetype <- "triangle"

library(rgl)
qm <- addNormals(qm)
rgl.clear()
shade3d(qm); 
light3d(viewpoint.rel = FALSE); rglwidget()
mdsumner commented 5 years ago

It's the default white material:

qm$material$col <- NULL

But I also think it's somehow transient as it wasn't happening earlier, the white (or non-black) was needed in order for the texture to appear, but no maybe it's unnecessary.

mdsumner commented 5 years ago

It's just overplotting, failure to clear the scene.