Learn R Programming

textures (version 0.1.0)

quad: Quad mesh objects

Description

Create a simple quad mesh3d object. quad() is the eager convenience form of quad_mesh(quad_spec(...)).

Usage

quad(dimension = c(1L, 1L), extent = NULL, ydown = FALSE)

quad_texture(dimension = c(1L, 1L), extent = NULL, ydown = FALSE, texture = "")

segs(dimension = c(1L, 1L), extent = NULL, ydown = FALSE)

Value

mesh3d with quads and material texture settings as per inputs

Arguments

dimension

dimensions of mesh (using matrix() and image() orientation)

extent

optional extent of mesh xmin, xmax, ymin, ymax

ydown

should y-coordinate be counted from top (default FALSE)

texture

file path to PNG image (may not exist)

Details

Use quad() to create a mesh3d object with quad indexes to the vertices, this is defined in the rgl package by qmesh3d() and has elements vb (the homogeneous coordinates 4xn) and ib (the quad index 4xn).

Use segs() to create a mesh3d object with segment indexes, exactly analogous to the mesh created by quad() just only containing the quad edges/segments - note that segments are unique.

The meshColor is currently hardcoded as 'vertices'.

Use quad_texture() to create a mesh3d object additionally with texcoords and texture properties.

See Also

Other textures: break_mesh(), quad_spec()

Examples

Run this code
qm <- quad()
## orientation is low to high, x then y
qm <- quad(dim(volcano))
scl <- function(x) (x - min(x, na.rm = TRUE))/diff(range(x, na.rm = TRUE))
qm$meshColor <- "faces"
qm$material$color <- hcl.colors(12, "YlOrRd", rev = TRUE)[scl(volcano) * 11 + 1]
if (requireNamespace("rgl")) {
 rgl::plot3d(qm)
 }

Run the code above in your browser using DataLab