-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
95 lines (73 loc) · 3.19 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
title: "README"
author: "Gregory Jefferis"
output:
html_document:
keep_md: yes
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
rgl::setupKnitr(autoprint = F)
```
# dracor
<!-- badges: start -->
[![R-CMD-check](https://github.com/natverse/dracor/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/natverse/dracor/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/natverse/dracor/branch/master/graph/badge.svg)](https://app.codecov.io/gh/natverse/dracor?branch=master)
[![GitHub](https://img.shields.io/github/v/release/natverse/dracor)](https://github.com/natverse/dracor/releases/)
[![CRAN status](https://www.r-pkg.org/badges/version/dracor)](https://CRAN.R-project.org/package=dracor)
[![Downloads](http://cranlogs.r-pkg.org/badges/dracor?color=brightgreen)](https://www.r-pkg.org/pkg/dracor)
<!-- badges: end -->
The goal of **dracor** is to allow decoding of the Draco compressed meshes in R.
This is done by wrapping the [Draco](https://github.com/google/draco) C++
decoding library with the assistance of the [Rcpp package](https://cran.r-project.org/package=Rcpp).
The original motivation for **dracor** was decoding [neuroglancer](https://github.com/google/neuroglancer) meshes of neurons for
example as used by https://flywire.ai/.
## Installation
**dracor** is available from [CRAN](https://cran.r-project.org/package=dracor):
```{r, eval=FALSE}
install.packages('dracor')
```
but you can also install the development version like so:
```{r, eval=FALSE}
remotes::install_github("natverse/dracor")
```
## Example
This is a basic example using a sample from the draco repository
```{r}
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)
```
[rgl](https://cran.r-project.org/package=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](https://cran.r-project.org/package=Rvcg).
```{r, rgl=T}
# 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 [rgl](https://cran.r-project.org/package=rgl) `mesh3d` 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`
```{r}
car.m=dracor::draco_decode(carurl, mesh3d=FALSE)
str(car.m)
```
## Acknowledgements
Many thanks to the authors of:
* [Draco library](https://github.com/google/draco)
* [Rcpp package](https://cran.r-project.org/package=Rcpp)