Extracts a texture from a glTF object, and writes it to a file.

extractTexture(gltf, index = 0,
               outfile = tempfile(),
               verbose = TRUE)

Arguments

gltf

The glTF object.

index

The texture number (starting from 0).

outfile

The filename to write to. If outfile has no file extension, one will be added based on the MIME type of the texture.

verbose

Whether to report on success.

Details

Since rgl doesn't support any texture format except PNG, this function will attempt to convert JPEG textures to PNG. To do that it needs to have the jpeg and png packages available.

Value

Returns the filename that was written, or NULLif the request failed. If closeConnections = FALSE, the filename will have attribute "gltf" containing the gltfobject which might now contain a new open connection. If the texture has a recorded MIME type in gltf, that will be returned in attribute "mimeType".