mirror of
https://github.com/CesiumGS/obj2gltf.git
synced 2025-03-01 05:53:48 -05:00
OBJ2GLTF
Convert OBJ assets to glTF 1.0.
Getting Started
Install Node.js if you don't already have it, and then:
npm install --save obj2gltf
Using obj2gltf as a library:
var obj2gltf = require('obj2gltf');
var convert = obj2gltf.convert;
var options = {
separateTextures : true // Don't embed textures in the converted glTF
}
convert('model.obj', 'model.gltf', options)
.then(function() {
console.log('Converted model');
});
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
Usage
###Command line flags:
Flag | Description | Required |
---|---|---|
-h |
Display help. | No |
-i |
Path to the obj file. | ✅ Yes |
-o |
Path of the converted glTF file. | No |
-b |
Save as 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 |
-c |
Quantize positions, compress texture coordinates, and oct-encode normals. | No, default false |
-z |
Use the optimization stages in the glTF pipeline. | No, default false |
-n |
Generate normals if they are missing. | No, default false |
--cesium |
Optimize the glTF for Cesium by using the sun as a default light source. | No, default false |
--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 and will save the glTF with the KHR_materials_common extension. | No, default false |
Contributions
Pull requests are appreciated. Please use the same Contributor License Agreement (CLA) used for Cesium.
Developed by the Cesium team.
Description
Languages
JavaScript
100%