Learn R Programming

rgl2gltf (version 1.0.7)

writeglTF: Write a glTF or GLB file.

Description

GLB is the self-contained binary format of glTF files. These functions write a "gltf" object to one of these formats.

Usage

writeglTF(x, path, bin = TRUE)
writeGLB(x, con)

Value

writeglTF returns path invisibly. writeGLB returns NULL invisibly.

Arguments

x

A "gltf" object, e.g. from as.gltf.

path

A filename in which to write the JSON part of the file.

bin

logical; whether or not to write the binary part of the object.

con

A filename or connection to which to write the GLB file.

Author

Duncan Murdoch

Details

If bin = TRUE (the default), writeglTF will write the binary part of the object to one or more separate files with filename constructed by concatenating the main part of path, followed by a number and the extension .bin.

References

The specification of the glTF format: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html

See Also

readglTF

Examples

Run this code
filename <- tempfile(fileext = ".glb")
writeGLB(as.gltf(rgl::cube3d(col = "red")), filename)

Run the code above in your browser using DataLab