MyNixOS website logo
Description

Decode Draco Format 3D Mesh Data.

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.

dracor

R-CMD-check Codecov test coverage GitHub CRAN status Downloads

The goal of dracor is to allow decoding of the Draco compressed meshes in R. This is done by wrapping the Draco C++ decoding library with the assistance of the Rcpp package.

The original motivation for dracor was decoding neuroglancer meshes of neurons for example as used by https://flywire.ai/.

Installation

dracor is available from CRAN:

install.packages('dracor')

but you can also install the development version like so:

remotes::install_github("natverse/dracor")

Example

This is a basic example using a sample from the draco repository

library(dracor)
# get sample file from draco repository
carurl='https://github.com/google/draco/blob/master/testdata/car.drc?raw=true'
car.m3d=dracor::draco_decode(carurl)
str(car.m3d)
#> List of 2
#>  $ vb: num [1:4, 1:1856] 1.54 1.65 -1.21 1 1.57 ...
#>  $ it: int [1:3, 1:1744] 1 2 3 3 2 4 4 2 5 5 ...
#>  - attr(*, "class")= chr [1:2] "mesh3d" "shape3d"

rgl is the most widely used R package for 3D visualisation. By default we return meshes as rgl mesh3d objects, which can then be displayed by rgl or manipulated by a range of R packages including Rvcg.

# install.packages("rgl")
# convert to rgl mesh3d format
# set a nice viewpoint
rgl::shade3d(car.m3d, col='red')
rgl::view3d(theta = 60, fov=0, zoom=.7)

Some details

dracor is deliberately intended as a minimal decoder package without any dependencies besides the Rcpp package. It accepts raw bytes, a file or a URL as input and can produce either an rglmesh3d object as output or a list containing points and 0-indexed faces. It essentially replicates the most basic decoding ability of the draco_decoder command line tool.

If you just want a result as close as possible to what the Draco library would give then set mesh3d=FALSE

car.m=dracor::draco_decode(carurl, mesh3d=FALSE)
str(car.m)
#> List of 2
#>  $ points: num [1:3, 1:1856] 1.54 1.65 -1.21 1.57 1.77 ...
#>  $ faces : int [1:3, 1:1744] 0 1 2 2 1 3 3 1 4 4 ...

Acknowledgements

Many thanks to the authors of:

Metadata

Version

0.2.6

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows