Last few tweaks

This commit is contained in:
Robert Taglang 2016-07-22 16:17:27 -04:00
parent 68582967ac
commit dc1a1976db
4 changed files with 195 additions and 193 deletions

View File

@ -15,7 +15,8 @@ var convert = obj2gltf.convert;
var options = {
embedImage : false // Don't embed image in the converted glTF
}
convert('model.obj', 'model.gltf', options, function() {
convert('model.obj', 'model.gltf', options)
.then(function() {
console.log('Converted model');
});
```

View File

@ -37,7 +37,7 @@ function convert(objFile, outputPath, options) {
extension = binary ? '.glb' : '.gltf';
var gltfFile = path.join(outputPath, modelName + extension);
parseObj(objFile, inputPath)
return parseObj(objFile, inputPath)
.then(function(data) {
return createGltf(data, inputPath, modelName);
})

View File

@ -2,7 +2,6 @@
var Cesium = require('cesium');
var Promise = require('bluebird');
var async = require('async');
var byline = require('byline');
var fs = require('fs-extra');
var path = require('path');
@ -28,7 +27,8 @@ function parseObj(objFile, inputPath) {
});
}
function processObj(objFile, info, materials, images, done) {
function processObj(objFile, info, materials, images) {
return new Promise(function(resolve) {
// A vertex is specified by indexes into each of the attribute arrays,
// but these indexes may be different. This maps the separate indexes to a single index.
var vertexCache = {};
@ -232,7 +232,7 @@ function processObj(objFile, info, materials, images, done) {
});
stream.on('end', function () {
done({
resolve({
vertexCount: vertexCount,
vertexArray: vertexArray,
positionMin: positionMin,
@ -244,6 +244,7 @@ function processObj(objFile, info, materials, images, done) {
images: images
});
});
});
}
function getImages(inputPath, materials) {

View File

@ -10,7 +10,7 @@ var gltfFile = './specs/data/BoxTextured/BoxTextured.gltf';
describe('convert', function() {
it('converts an obj to gltf', function(done) {
var spy = spyOn(gltfPipeline, 'processJSONToDisk').and.callFake(function() {
var spy = spyOn(gltfPipeline, 'processJSONToDisk').and.callFake(function(gltf, outputPath, options, callback) {
return;
});
expect(convert(objFile, gltfFile, {})