najadojo / gltf-import-export

Convert between GLB and GLTF files.
MIT License
204 stars 31 forks source link

TypeError: Cannot read property 'length' of undefined #5

Closed apptaro closed 6 years ago

apptaro commented 6 years ago

Converting some GLTF file to GLB results in an error. The GLTF file is the output of COLLADA2GLTF. The original DAE file is the output of Maya.

See below:

D:\projectDir> COLLADA2GLTF-bin.exe -i "D:\projectDir\coco-low-sofa-ottoman.dae" -o "D:\projectDir\coco-low-sofa-ottoman.gltf" -v 2.0
Converting D:\projectDir\coco-low-sofa-ottoman.dae -> D:\projectDir\coco-low-sofa-ottoman.gltf
Time: 87 ms

D:\projectDir> gltf-import-export D:\projectDir\coco-low-sofa-ottoman.gltf

D:\projectDir\node_modules\gltf-import-export\dist\exportProvider.js:130
    for (; bufferIndex < gltf.buffers.length; bufferIndex++) {
                                      ^

TypeError: Cannot read property 'length' of undefined
    at ConvertToGLB (D:\projectDir\node_modules\gltf-import-export\dist\exportProvider.js:130:39)
    at Object.ConvertGltfToGLB (D:\projectDir\node_modules\gltf-import-export\dist\exportProvider.js:109:5)
    at Object.<anonymous> (D:\projectDir\node_modules\gltf-import-export\dist\tool.js:31:13)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)

D:\projectDir>

Versions:

emackey commented 6 years ago

@apptaro Can you share the .gltf file and/or the .dae file? GitHub allows .zip uploads of < 10 MB just by drag-and-drop on the issue here. Thanks!

najadojo commented 6 years ago

Even so it looks as though your .gltf didn't export correctly as its missing the buffers object.

apptaro commented 6 years ago

@emackey here's the data. data.zip

emackey commented 6 years ago

Thanks for the sample, @apptaro. I notice that the converted glTF file is basically empty. Are you using a recent version of the COLLADA2GLTF converter? This is the complete contents of that glTF file:

{
    "asset": {
        "generator": "COLLADA2GLTF",
        "version": "2.0"
    },
    "scenes": [
        {
            "nodes": []
        }
    ],
    "scene": 0
}

It's the right outer structure, but there's no data here, no buffers or meshes etc. Try exporting with a newer version of the COLLADA2GLTF exporter, and if that doesn't fix the glTF file being empty, file a new issue with the COLLADA2GLTF project. Thanks!

apptaro commented 6 years ago

@emackey Thank you very much. I will file a new issue with them. Closing.