Internally, rgl works with PNG files for textures. If a texture is requested using a different format, a temporary PNG file of the image will be saved. This function allows you to retrieve the original expression used to produce the texture.




The filename of a texture file. If missing, the directory where texture files are stored will be returned.


rgl creates a new file in the temporary directory whenever a non-PNG texture is used. It will delete them when it knows there are no references and at the end of the session, but conceivably there will be situations where you need to delete them earlier. Calling textureSource() with no arguments will give you the directory holding the textures so that they can be deleted sooner.


If texture is specified and it is the name of a temporary PNG texture file produced by rgl, the expression used to specify the texture will be returned. If it is the name of some other file, texture will be returned.

If no argument is given, the session-specific directory holding the temporary texture files will be returned.

See also


xyz <- cbind(c(0,1,1,0), c(0,0,1,1), c(0,0,0,0))
st <- xyz[,1:2]

id <- quads3d(xyz, texcoords = st, 
               texture = as.raster(matrix(colors()[1:120], ncol = 10)), 
#> Loading required namespace: png
material3d(id = id, "texture")
#> [1] "/tmp/RtmpjNi4y7/rgl217d30ff710e/file217d6ceba50.png"
textureSource(material3d(id = id, "texture"))
#> as.raster(matrix(colors()[1:120], ncol = 10))