Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cheat's texture #90

Closed
mdsumner opened this issue Mar 23, 2020 · 7 comments
Closed

cheat's texture #90

mdsumner opened this issue Mar 23, 2020 · 7 comments

Comments

@mdsumner
Copy link
Member

mdsumner commented Mar 23, 2020

With rgl device and rglwidget we can do real textures, but with deck.gl etc. we can resort to primitive colouring:

hypertidy/silicate#84 (comment)

Provide a "cheater's" texture so we can add this to a mesh3d.

See #140 for a potential copy_down() approach to this.

This is exactly like #88 for mesh_plot(), but support for that will be automatic when mesh_plot is updated.

@mdsumner
Copy link
Member Author

This is also a bit colour_values()-ey

@mdsumner
Copy link
Member Author

this will also be very nice for wire3d

@mdsumner
Copy link
Member Author

A straight fix for mesh_plot(), this is the situation:

tri_waters <- DEL(silicate::inlandwaters[c(3, 4, 6), ])
tri_waters$vertex <-   tri_waters$vertex %>%
  dplyr::mutate(x_ = scales::rescale(x_, c(0, ncol(volcano))),
                y_ = scales::rescale(y_, c(0, nrow(volcano))))

r <- palr::image_raster(volcano)
tri_mesh <- as.mesh3d(tri_waters, image_texture = r)
## todo test file path, clean up file, png sanity, range of texcoords, color of material (not black) etc
mesh_plot(tri_mesh)
Warning message:
  In mesh_plot.mesh3d(tri_mesh) :
  mesh object has a texture path, but cannot be displayed in 2D graphics (try plot3d)

@mdsumner
Copy link
Member Author

Not too bad

image

@mdsumner
Copy link
Member Author

better LOL

image

@mdsumner
Copy link
Member Author

mdsumner commented May 15, 2020

looks great takes ages, triangles = FALSE means we get every quad-pixel

cc <- ceramic::cc_location(cbind(131.037, -25.3456562), buffer = c(1800, 1200))
el <- ceramic::cc_elevation(cc)
library(anglr)
mesh <- as.mesh3d(el, image_texture = cc, triangles = F)
mesh_plot(mesh)

image

compare to terrainmeshr version, with triangles = TRUE we get adaptive density based on curvature

mesh <- as.mesh3d(el, image_texture = cc, triangles = TRUE)
mesh_plot(mesh)

image

and then we can up the triangles

mesh2 <- as.mesh3d(el, image_texture = cc, triangles = TRUE, 
                   max_triangles = ncol(mesh$it) * 4)
mesh_plot(mesh2)

image

@mdsumner
Copy link
Member Author

mdsumner commented May 15, 2020

@dcooley just FYI this is pretty nice for mapdeck now that we have terrainmeshr

(it's only done dynamically ATM, needs to be pulled out of mesh_plot.mesh3d as general function to colourize_mesh_from_texture or something)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant