draco_decode {dracor}R Documentation

Decode Draco encoded raw bytes containing mesh or point cloud data


Decode Draco encoded raw bytes containing mesh or point cloud data


draco_decode(data, mesh3d = TRUE, ...)



raw bytes containing Draco data e.g. as read by readBin OR a character vector containing a URL or a path to a file on disk.


Whether to return rgl::mesh3d object (when TRUE, the default) or something as close as possible to what is provided by the Draco library (when FALSE).


Additional arguments passed to download.file when data is a URL (e.g. quiet=TRUE or method)


Note that the Draco library returns 0-based indices for the faces whereas R in general and rgl::mesh3d in particular expect 1-based indices. When mesh3d=FALSE, the result will have 0-based indices as returned by the Draco library.

If data is an http/https URL it will be downloaded to a temporary location on disk (using download.file). If data is a character vector that does not look like a URL then it is assumed to refer to a file on disk (which will be read with readBin.


a rgl::mesh3d object or a list containing elements points and (for meshes). faces.


# fetch test data
# originally downloaded from:
## Not run: 

## End(Not run)
# use cached version in package for example
car.m=draco_decode(system.file('draco/car.drc', package = 'dracor'))

## show the result
if(requireNamespace("rgl", quietly=TRUE)) {
rgl::shade3d(car.m, col='red')

## demonstrate conversion of raw form to rgl::mesh3d object
car.raw=draco_decode(carurl, mesh3d=FALSE)
car.m2 = rgl::tmesh3d(
  vertices = car.raw$points,
  indices = car.raw$faces + 1,
  homogeneous = FALSE)

[Package dracor version 0.2.6 Index]