Title: | Decode Draco Format 3D Mesh Data |
---|---|
Description: | Decodes meshes and point cloud data encoded by the Draco mesh compression library from Google. Note that this is only designed for basic decoding and not intended as a full scale wrapping of the Draco library. |
Authors: | Gregory Jefferis [aut, cre] , Google Inc [aut, cph] (for the Draco library) |
Maintainer: | Gregory Jefferis <[email protected]> |
License: | Apache License (>= 2.0) |
Version: | 0.2.6 |
Built: | 2024-11-01 04:09:15 UTC |
Source: | https://github.com/natverse/dracor |
Decode Draco encoded raw bytes containing mesh or point cloud data
draco_decode(data, mesh3d = TRUE, ...)
draco_decode(data, mesh3d = TRUE, ...)
data |
|
mesh3d |
Whether to return |
... |
Additional arguments passed to |
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: carurl='https://github.com/google/draco/blob/master/testdata/car.drc?raw=true' ## Not run: car.m=draco_decode(carurl) ## End(Not run) # use cached version in package for example car.m=draco_decode(system.file('draco/car.drc', package = 'dracor')) str(car.m) ## 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) str(car.raw) car.m2 = rgl::tmesh3d( vertices = car.raw$points, indices = car.raw$faces + 1, homogeneous = FALSE) }
# fetch test data # originally downloaded from: carurl='https://github.com/google/draco/blob/master/testdata/car.drc?raw=true' ## Not run: car.m=draco_decode(carurl) ## End(Not run) # use cached version in package for example car.m=draco_decode(system.file('draco/car.drc', package = 'dracor')) str(car.m) ## 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) str(car.raw) car.m2 = rgl::tmesh3d( vertices = car.raw$points, indices = car.raw$faces + 1, homogeneous = FALSE) }