CesiumGS / obj2gltf

Convert OBJ assets to glTF
Apache License 2.0
1.71k stars 307 forks source link

Not working when used as a library inside an existing Node.js app #29

Closed triceam closed 7 years ago

triceam commented 8 years ago

I have a project that generates models using OpenDroneMap, and I'm trying to convert those .obj models to be viewable on the web. I can view the .obj models using meshlab without any issues. When I try to use obj2gltf to convert them as part of my workflow inside of a Node.js app, it does nothing. I never get any response from the promise (no success, no error), and no console output. It just hangs. I left it running for about 20 minutes to see if it was just taking a really long time, but finally killed it when nothing happened.

My code looks like this:

var filePrefix = __dirname + "/" + rootDirName + "/" + currentDocument.id + '/odm_texturing/odm_textured_model_geo';
var options = {
    embedImage : false // Don't embed image in the converted glTF
}
var objFile = filePrefix +'.obj';
var gltfFile = filePrefix +'.gltf';
console.log(objFile);
console.log(gltfFile);

convert(objFile, gltfFile, options)
    .then(function() {
        console.log('Converted model');
        callback();
    })
    .catch(function(err){
        console.log("ERROR:" + err.toString());
        callback(err);
    });

My output only shows the file names, nothing else:

/root/analysis-baremetal/temp/6f5ddb39312feefc5e37bad7baf71cdd/odm_texturing/odm_textured_model_geo.obj
/root/analysis-baremetal/temp/6f5ddb39312feefc5e37bad7baf71cdd/odm_texturing/odm_textured_model_geo.gltf

I assume this is just failing silently - there are no other indications of an error, and no stack trace. The .obj file is about 25 MB, which isn't tiny, but again, it also is not huge so I wouldn't expect it to take this long.

lilleyse commented 8 years ago

Can you try it out with a smaller obj? I totally agree that 25MB should be quick, but we have some optimization issues in https://github.com/AnalyticalGraphicsInc/gltf-pipeline which this project uses.

pjcozzi commented 7 years ago

@triceam any update here?

Can you try it out with a smaller obj? I totally agree that 25MB should be quick, but we have some optimization issues in https://github.com/AnalyticalGraphicsInc/gltf-pipeline which this project uses.

lilleyse commented 7 years ago

The speed should be significantly faster once I finish the obj2gltf cleanup and use the preserve flag in gltf-pipeline.

triceam commented 7 years ago

I have not had an opportunity to try with the latest... I'll have to revist this once I'm done updating the photogrammetry rendering server to the latest.

lilleyse commented 7 years ago

Fixed in #49

Speeds should improve since gltf-pipeline optimizations are disabled be default. Also --bypassPipeline is an available option for the fastest conversion, however this will export the gltf with the KHR_materials_common extension.