Skip to main content

utility to read fbx file

Project description

FBXLoader for Python

[!WARNING] This library has very limited features and is only intended for reading mesh geometry from binary FBX files, it doesn't support:

  • Reading ASCII FBX files.
  • Reading textures and materials even if they are encoded in the file.
  • Reading skeletons and animations. Note that the geometry may also be incorrect if the mesh is skinned.
  • Writing FBX files. However, this can be a starting point to implement more features in the future. Welcome to contribute!

Install

# from pypi
pip install fbxloader

# from source
pip install git+https://github.com/ashawkey/fbxloader.git

Usage

Python API:

from fbxloader import FBXLoader

fbx = FBXLoader('model.fbx') # load from file or bytes

# similar to glb, fbx usually contains multiple meshes as a scene
# we provide a method to merge them into a single mesh and export as trimesh.Trimesh
mesh = fbx.export_trimesh()

# write to other formats (using trimesh API)
mesh.export('model.obj')

# meta: this is to provide some information on unimplemented features, you may inspect it to make sure if the model is expected to load correctly. e.g., hasDeformers=True usually means the model is skinned.
print(fbx.meta)
# {'hasImages': False, 'hasTextures': False, 'hasMaterials': True, 'hasDeformers': True, 'hasAnimations': True}

We also provide a CLI tool:

fbxconverter <input.fbx> <output.obj/ply/glb>

Lastly, we provide a testing script and also a fbx mesh as an example:

python tests/test.py examples/annulus.fbx

Reference

The code is basically translated from threejs's FBXLoader. Thanks to the threejs team and also copilot!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fbxloader-0.0.2.tar.gz (9.5 kB view hashes)

Uploaded Source

Built Distribution

fbxloader-0.0.2-py3-none-any.whl (9.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page