obj2gltf/README.md

98 lines
3.3 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 options = {
2017-03-13 15:28:51 -04:00
separateTextures : true // Don't embed textures in the converted glTF
2016-07-20 14:48:49 -04:00
}
2017-04-10 17:57:56 -04:00
obj2gltf('model.obj', 'model.gltf', options)
2016-07-22 16:17:27 -04:00
.then(function() {
console.log('Converted model');
});
2016-07-20 14:48:49 -04:00
```
Using obj2gltf as a command-line tool:
2017-04-10 17:57:56 -04:00
`node bin/obj2gltf.js -i model.obj`
2016-07-20 14:48:49 -04:00
`node bin/obj2gltf.js -i model.obj -o model.gltf`
2015-10-19 17:38:55 -04:00
## Usage
2017-04-12 16:55:03 -04:00
### Command line flags:
2015-10-19 17:38:55 -04:00
|Flag|Description|Required|
|----|-----------|--------|
2017-04-10 17:57:56 -04:00
|`-h`, `--help`|Display help.|No|
|`-i`, `--input`|Path to the obj file.| :white_check_mark: Yes|
|`-o`, `--output`|Path of the converted glTF file.|No|
|`-b`, `--binary`|Save as binary glTF.|No, default `false`|
|`-s`, `--separate`|Writes out separate geometry data files, shader files, and textures instead of embedding them in the glTF file.|No, default `false`|
|`-t`, `--separateTextures`|Write out separate textures only.|No, default `false`|
|`-c`, `--compress`|Quantize positions, compress texture coordinates, and oct-encode normals.|No, default `false`|
|`-z`, `--optimize`|Use the optimization stages in the glTF pipeline.|No, default `false`|
|`-n`, `--generateNormals`|Generate normals if they are missing.|No, default `false`|
|`--optimizeForCesium`|Optimize the glTF for Cesium by using the sun as a default light source.|No, default `false`|
2016-07-20 14:48:49 -04:00
|`--ao`|Apply ambient occlusion to the converted model.|No, default `false`|
|`--bypassPipeline`|Bypass the gltf-pipeline for debugging purposes. This option overrides many of the options above.|No, default `false`|
2017-04-10 17:57:56 -04:00
|`--checkTransparency`|Do a more exhaustive check for texture transparency by looking at the alpha channel of each pixel. By default textures are considered to be opaque.|No, default `false`|
2017-04-04 16:45:21 -04:00
|`--secure`|Prevent the converter from reading image or mtl files outside of the input obj directory.|No, default `false`|
2015-10-19 17:38:55 -04:00
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
```
2017-04-12 16:55:03 -04:00
## Running Test Coverage
2017-01-06 11:36:44 -05:00
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.
2017-04-12 16:55:03 -04:00
## Debugging
2017-01-06 11:36:44 -05:00
* 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">
2017-03-13 15:28:51 -04:00
<a href="http://cesiumjs.org/"><img src="doc/cesium.png" onerror="this.src='cesium.png'"/></a>
2015-10-18 23:33:54 -04:00
</p>