Skip to content

Commit

Permalink
Fix code samples in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Nov 29, 2018
1 parent 37537ad commit f277caf
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var gltf = fsExtra.readJsonSync('model.gltf');
gltfToGlb(gltf)
.then(function(results) {
fsExtra.writeFileSync('model.glb', results.glb);
}
});
```

#### Converting a glb to glTF
Expand All @@ -68,31 +68,33 @@ var glb = fsExtra.readFileSync('model.glb');
glbToGltf(glb)
.then(function(results) {
fsExtra.writeJsonSync('model.gltf', results.gltf);
}
});
```

#### Converting a glTF to Draco glTF

```javascript
var gltfPipeline = require('gltf-pipeline');
var fsExtra = require('fs-extra');
var processGltf = gltfPipeline.processGltf;
var gltf = fsExtra.readJsonSync('model.gltf');
var options = {
dracoOptions: {
compressionLevel: 10
}
}
};
processGltf(gltf, options)
.then(function(results) {
fsExtra.writeJsonSync('model.gltf', results.gltf);
}
});
```

#### Saving separate textures

```javascript
var gltfPipeline = require('gltf-pipeline');
var fsExtra = require('fs-extra');
var processGltf = gltfPipeline.processGltf;
var gltf = fsExtra.readJsonSync('model.gltf');
var options = {
separateTextures: true
Expand All @@ -105,10 +107,10 @@ processGltf(gltf, options)
for (var relativePath in separateResources) {
if (separateResources.hasOwnProperty(relativePath)) {
var resource = separateResources[relativePath];
fsExtra.writeFileSync(relativePath, resource));
fsExtra.writeFileSync(relativePath, resource);
}
}
}
});
```

### Command-Line Flags
Expand Down

0 comments on commit f277caf

Please sign in to comment.