-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
6,594 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["@babel/preset-env"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
/lib | ||
/coverage | ||
|
||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org). | ||
|
||
## [Unreleased] | ||
|
||
[Unreleased]: https://github.com/andstor/voxelizer/compare/v0.0.1...HEAD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,102 @@ | ||
# voxelizer | ||
# Voxelizer | ||
|
||
[![Build Status](https://travis-ci.org/andstor/voxelizer.svg?branch=master)](https://travis-ci.org/andstor/voxelizer) | ||
[![Coverage Status](https://coveralls.io/repos/github/andstor/voxelizer/badge.svg?branch=master)](https://coveralls.io/github/andstor/voxelizer?branch=master) | ||
[![npm version](http://img.shields.io/npm/v/voxelizer.svg?style=flat)](https://npmjs.org/package/voxelizer "View this project on npm") | ||
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/andstor/voxelizer.svg?)](https://lgtm.com/projects/g/andstor/voxelizer/context:javascript) | ||
|
||
Voxelizer is a JavaScript library for conducting voxelization of 3D models. | ||
|
||
|
||
## Table of Contents | ||
* [Installation](#installation) | ||
* [Usage](#usage) | ||
* [3D file format support](#3d-file-format-support) | ||
* [Build instrictions](#build-instructions) | ||
* [License](#license) | ||
|
||
## Installation | ||
|
||
Using [npm](https://www.npmjs.com/): | ||
|
||
```sh | ||
$ npm install --save voxelizer | ||
``` | ||
|
||
## Usage | ||
### Syntax | ||
``` | ||
new Voxelizer() | ||
``` | ||
|
||
### Example | ||
```js | ||
const Voxelizer = require('voxelizer'); | ||
const vox = new Voxelizer(options); | ||
|
||
let path3DModel = './path/to/file.obj'; | ||
|
||
vox.loadOBJ(path3DModel).then((object) => { | ||
const resolution = 10; | ||
let matrix = vox.sample(object, resolution); | ||
console.log(matrix); | ||
}); | ||
|
||
``` | ||
|
||
## 3D file format support | ||
* OBJ | ||
|
||
[⬆ back to top](#voxelizer) | ||
|
||
## API | ||
The Voxelizer class also support multiple optional configurations. These should be passed as an object to the Voxelizer class object. If no manual configurations are set, default options are used. | ||
|
||
### voxelizer.loadOBJ(path) | ||
- **path**: | ||
- Type: `String` | ||
- Path to 3d model file. | ||
|
||
- (return value): | ||
- Type: `Promise` | ||
- Promise with the loaded [Object3D](https://threejs.org/docs/#api/en/core/Object3D) 3D model as an argument. | ||
|
||
Load 3D model. | ||
|
||
### voxelizer.sample(object, resolution) | ||
- **object**: | ||
- Type: `Object` | ||
- The 3D model to be sampled. Needs to be an [Object3D](https://threejs.org/docs/#api/en/core/Object3D). | ||
|
||
- **resolution**: | ||
- Type: `Number` | ||
- Default: `10` | ||
- The resolution of the sampling. | ||
|
||
- (return value): | ||
- Type: `Array` | ||
- Three dimensional array with `0`'s and `1`'s in the inner dimention. | ||
|
||
Voxelizes a 3D model, producing a 3D array representing the 3D model. | ||
Values of `1` represents the object's presence in space, while `0`'s represents the object's non-existence in space. | ||
|
||
## Build instructions | ||
|
||
Clone a copy of the main Voxelizer git repo by running: | ||
|
||
```bash | ||
git clone git://github.com/andstor/voxelizer.git | ||
``` | ||
|
||
Enter the Voxelizer directory and run the build script: | ||
```bash | ||
npm run build | ||
``` | ||
|
||
|
||
## License | ||
|
||
Voxelizer is licensed under the [MIT License](https://github.com/andstor/voxelizer/blob/master/LICENSE). | ||
Copyright © [André Storhaug](https://github.com/andstor) | ||
|
||
[⬆ back to top](#voxelizer) |
Oops, something went wrong.