Skip to content

Commit

Permalink
Add initial working version
Browse files Browse the repository at this point in the history
  • Loading branch information
andstor committed Apr 4, 2019
1 parent 14a35b0 commit 6e45283
Show file tree
Hide file tree
Showing 11 changed files with 6,594 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
13 changes: 13 additions & 0 deletions .editorconfig
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
/lib
/coverage

/.idea
9 changes: 9 additions & 0 deletions CHANGELOG.md
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
103 changes: 102 additions & 1 deletion README.md
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)
Loading

0 comments on commit 6e45283

Please sign in to comment.