Adds a surface mesh to the current scene. The surface is defined by
the matrix of height values in y
, with rows corresponding
to the values in x
and columns corresponding to the values in
z
.
The coords
parameter can be used to change the geometric
interpretation of x
, y
, and z
. The first entry
of coords
indicates which coordinate (1 = X
,
2 = Y
, 3 = Z
) corresponds to the x
parameter.
Similarly the second entry corresponds to the y
parameter,
and the third entry to the z
parameter. In this way
surfaces may be defined over any coordinate plane.
If the normals are not supplied, they will be calculated automatically based
on neighbouring points.
Texture coordinates run from 0 to 1 over each dimension of the texture bitmap.
If texture coordinates are not supplied, they will be calculated to
render the texture exactly once over the grid. Values greater than 1 can be
used to repeat the texture over the surface.
rgl.surface
always draws the surface with the `front' upwards
(i.e. towards higher y
values). This can be used to render
the top and bottom differently; see rgl.material
and
the example below.
If the x
or z
argument is a matrix, then it must be of the same
dimension as y
, and the values in the matrix will be used for the corresponding
coordinates. This is used to plot shapes such as cylinders
where y is not a function of x and z.
NA
values in the height matrix are not drawn.