Search code examples
pythonassimp

pyassimp how to export 3d model to gltf2.0


using pyassimp to convert a obj model to gltf2.0,

pyassimp.export(scene,'444.gltf','gltf')

but export gltf version is 1.0

"asset": {
    "version": "1",
    "generator": "Open Asset Import Library (assimp v4.0.0)"
},

how to export gltf to version 2.0? thanks


Solution

  • Citing the docstring for pyassimp's export function:

    >>> help(pyassimp.export)
    Help on function export in module pyassimp.core:
    
    export(scene, filename, file_type=None, processing=8)
        Export a scene. On failure throws AssimpError.
    
        Arguments
        ---------
        scene: scene to export.
        filename: Filename that the scene should be exported to.  
        file_type: string of file exporter to use. For example "collada".
        processing: assimp postprocessing parameters. Verbose keywords are imported
                    from postprocessing, and the parameters can be combined bitwise to
                    generate the final processing value. Note that the default value will
                    triangulate quad faces. Example of generating other possible values:
                    processing = (pyassimp.postprocess.aiProcess_Triangulate | 
                                  pyassimp.postprocess.aiProcess_OptimizeMeshes)
    

    In your case, this means you should call the function with the file_type gltf2, like so:

    pyassimp.export(scene,'444.gltf','gltf2')