obj2gltf/README.md

97 lines
2.5 KiB
Markdown
Raw Normal View History

2015-10-14 17:21:45 -04:00
# OBJ2GLTF
2015-10-18 23:33:54 -04:00
2015-10-20 09:44:21 -04:00
Convert OBJ assets to [glTF](https://www.khronos.org/gltf) 1.0.
2015-10-18 23:33:54 -04:00
## Getting Started
2016-07-20 14:48:49 -04:00
Install [Node.js](https://nodejs.org/en/) if you don't already have it, and then:
2015-10-18 23:33:54 -04:00
```
2016-07-20 14:48:49 -04:00
npm install --save obj2gltf
2015-10-18 23:33:54 -04:00
```
2016-07-20 14:48:49 -04:00
Using obj2gltf as a library:
```javascript
var obj2gltf = require('obj2gltf');
var convert = obj2gltf.convert;
var options = {
embedImage : false // Don't embed image in the converted glTF
}
2016-07-22 16:17:27 -04:00
convert('model.obj', 'model.gltf', options)
.then(function() {
console.log('Converted model');
});
2016-07-20 14:48:49 -04:00
```
Using obj2gltf as a command-line tool:
`node bin/obj2gltf.js model.obj`
`node bin/obj2gltf.js model.obj model.gltf`
`node bin/obj2gltf.js -i model.obj -o model.gltf`
`node bin/obj2gltf.js -i model.obj -o model.gltf -s`
2015-10-18 23:33:54 -04:00
2015-10-19 17:38:55 -04:00
## Usage
###Command line flags:
|Flag|Description|Required|
|----|-----------|--------|
|`-i`|Path to the input OBJ file.| :white_check_mark: Yes|
|`-o`|Directory or filename for the exported glTF file.|No|
2016-07-20 14:48:49 -04:00
|`-b`|Output binary glTF.|No, default `false`|
|`-s`|Writes out separate geometry/animation data files, shader files, and textures instead of embedding them in the glTF file.|No, default `false`|
|`-t`|Write out separate textures only.|No, default `false`|
|`--ao`|Apply ambient occlusion to the converted model.|No, default `false`|
2015-10-19 17:38:55 -04:00
|`-h`|Display help|No|
2017-01-06 11:36:44 -05:00
## Build Instructions
Run the tests:
```
npm run test
```
To run JSHint on the entire codebase, run:
```
npm run jsHint
```
To run JSHint automatically when a file is saved, run the following and leave it open in a console window:
```
npm run jsHint-watch
```
### Running Test Coverage
Coverage uses [istanbul](https://github.com/gotwarlost/istanbul). Run:
```
npm run coverage
```
For complete coverage details, open `coverage/lcov-report/index.html`.
The tests and coverage covers the Node.js module; it does not cover the command-line interface, which is tiny.
## Generating Documentation
To generate the documentation:
```
npm run jsdoc
```
The documentation will be placed in the `doc` folder.
### Debugging
* To debug the tests in Webstorm, open the Gulp tab, right click the `test` task, and click `Debug 'test'`.
* To run a single test, change the test function from `it` to `fit`.
2015-10-20 09:50:37 -04:00
## Contributions
2015-10-18 23:33:54 -04:00
Pull requests are appreciated. Please use the same [Contributor License Agreement (CLA)](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md) used for [Cesium](http://cesiumjs.org/).
---
Developed by the Cesium team.
<p align="center">
<a href="http://cesiumjs.org/"><img src="doc/cesium.png" /></a>
</p>