mirror of
https://github.com/CesiumGS/obj2gltf.git
synced 2024-11-27 10:30:16 -05:00
Add sample code for saving gltf to readme
This commit is contained in:
parent
a1f5550c59
commit
56388cb2ab
@ -23,9 +23,11 @@ npm install --save obj2gltf
|
||||
|
||||
```javascript
|
||||
var obj2gltf = require('obj2gltf');
|
||||
var fs = require('fs');
|
||||
obj2gltf('model.obj')
|
||||
.then(function(gltf) {
|
||||
console.log(gltf.asset);
|
||||
var data = Buffer.from(JSON.stringify(gltf));
|
||||
fs.writeFileSync('model.gltf', data);
|
||||
});
|
||||
```
|
||||
|
||||
@ -33,12 +35,13 @@ obj2gltf('model.obj')
|
||||
|
||||
```javascript
|
||||
var obj2gltf = require('obj2gltf');
|
||||
var fs = require('fs');
|
||||
var options = {
|
||||
binary : true
|
||||
}
|
||||
obj2gltf('model.obj', options)
|
||||
.then(function(glb) {
|
||||
console.log(glb.length);
|
||||
fs.writeFileSync('model.glb', glb);
|
||||
});
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user