as.gltf.Rd
The glTF file is the JSON part of a glTF representation of a 3D scene. This function creates the R structure corresponding to one, and writes the binary buffer file for it.
as.gltf(x, ...)
# S3 method for default
as.gltf(x, y = NULL, z = NULL, vertices,
material = NULL,
normals = NULL,
texcoords = NULL,
points = NULL, segments = NULL,
triangles = NULL,
quads = NULL,
transform = diag(4),
extras = NULL,
...,
rglscene = list(),
previous = Gltf$new(),
newScene = FALSE,
parentNode = NULL,
dir = tempdir(),
scale = c(1,1,1))
# S3 method for rglscene
as.gltf(x, ..., previous = Gltf$new(),
newScene = FALSE)
# S3 method for mesh3d
as.gltf(x, ...)
An object to convert to a "gltf"
object.
In the default method, combined with x
to make coordinates. Any reasonable way of defining the coordinates is acceptable. See the function xyz.coords
for details.
A 3 or 4 row matrix of Euclidean or homogeneous coordinates; takes
precedence over x, y, z
.
material properties for rendering
normals at each vertex as a 3 or 4 column matrix
texture coordinates at each vertex as a 2 column matrix
vector of indices of vertices to draw as points
2 x n matrix of indices of vertices to draw as segments
3 x n matrix of indices of vertices to draw as triangles
4 x n matrix of indices of vertices to draw as quads
4 x 4 matrix associated with this object (e.g. a subscene)
A list to attach as extras
component to
the result
Other parameters passed to the default method.
The RGL scene this came from, e.g. to look up defaults
Optionally a previously produced "gltf"
object;
the new geometry will be added to it.
logical; if TRUE
, add a new
scene to previous
, otherwise try to add to the existing
scene.
If not NULL
, add the new object
as a child of this node, otherwise add to the first node of the
default scene.
Where to write the binary buffer file.
Rescaling in the enclosing subscene.
as.gltf
is a generic function.
The method for "rglscene"
objects can handle most
objects produced by scene3d
, but not all
objects will be handled. In particular:
Lights, text, bounding box decorations and backgrounds are saved in “extra” fields, so they can be read by rgl2gltf, but most other software will ignore them or only display some parts.
Most material properties are also stored in “extra” fields.
There are methods for many individual types of "rglobject"
, but these are intended for internal
use.
A "gltf"
object.
The specification of the glTF format: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html