Skip to main content

Convert FBX files to GLB format for web-based 3D applications

Project description

FBX2GLB

A versatile toolkit for converting FBX 3D models to GLB format for web applications.

Features

  • Multiple Conversion Methods:
    • Autodesk FBX SDK (if available)
    • Facebook's fbx2gltf command line tool
    • Blender (if installed)
  • Batch Processing: Convert multiple files at once with parallel processing
  • Component Generation: Generate React/Three.js components from 3D models
  • FBX Upgrading: Upgrade older FBX files to newer versions for better compatibility
  • Preserve Quality: Maintain animations, materials, textures, and skeletal data
  • Cross-Platform: Support for macOS, Windows, and Linux

Quick Start

Installation

# Clone the repository
git clone https://github.com/fortyfive-ai/fbx2glb.git
cd fbx2glb

# Install in development mode
pip install -e '.[dev]'

Basic Usage

# Convert a single FBX file to GLB
python -m fbx2glb.cli examples/XBot.fbx examples/XBot.glb

# Check available conversion methods
python -m fbx2glb.cli --check-dependencies

# Generate a React/Three.js component
python -m fbx2glb.component examples/XBot.fbx src/components/XBotModel.tsx

Installation

Basic Installation

pip install fbx2glb

Development Installation

git clone https://github.com/fortyfive-ai/fbx2glb.git
cd fbx2glb
pip install -e '.[dev]'

FBX SDK Installation (Recommended)

For the best results and FBX file upgrading capabilities, install the Autodesk FBX SDK:

macOS

# Using the included Makefile
make install-fbx-sdk

Manual Installation

  1. Download the FBX SDK from Autodesk
  2. Install the SDK for your platform
  3. The package will automatically detect the SDK installation

Project Structure

fbx2glb/
├── fbx2glb/              # Main Python package
│   ├── __init__.py       # Package initialization
│   ├── cli.py           # Command-line interface
│   ├── converter.py     # Core conversion logic
│   ├── batch.py         # Batch processing
│   ├── component.py     # React component generation
│   ├── utils.py         # Utility functions
│   ├── params.py        # Parameter structures
│   └── fbx_upgrader.py  # FBX file upgrading
├── tools/               # Build tools and utilities
│   ├── upgrade_fbx.cpp  # C++ source for FBX upgrade tool
│   ├── upgrade_fbx      # Compiled binary
│   └── README.md        # Tools documentation
├── examples/            # Example files and models
├── tests/              # Test suite
├── local/              # SDK installers (macOS)
├── sdk/                # SDK packages
├── Makefile            # Unified build system
└── FBX2glTF/           # Facebook's FBX2glTF (git submodule)

Usage

Command Line Interface

# Convert a single file
fbx2glb input.fbx [output.glb] [options]

# Batch conversion
fbx2glb-batch source_directory [output_directory] [options]

# Generate React/Three.js component
fbx2glb-component input.fbx [output_component.tsx] [options]

Common Options

# Specify conversion method
--method fbx-sdk|fbx2gltf|blender

# Force overwrite existing files
--force

# Enable verbose output
--verbose

# Upgrade FBX file before conversion
--upgrade-fbx

# Check dependencies
--check-dependencies

Python API

from fbx2glb import convert_file, batch_convert, generate_component

# Convert a single file
success = convert_file("input.fbx", "output.glb", method="fbx-sdk")

# Batch convert with parallel processing
successes, failures = batch_convert(
    "source_dir", 
    "output_dir", 
    recursive=True, 
    parallel=4
)

# Generate React component
success = generate_component(
    "input.fbx", 
    "MyModel.tsx", 
    component_name="MyModel"
)

Using the Makefile

The project includes a comprehensive Makefile for common tasks:

# Show all available commands
make help

# Install FBX SDK (macOS)
make install-fbx-sdk

# Build the FBX upgrade tool
make build-upgrade-tool

# Convert XBot example with FBX upgrading
make upgrade-xbot

# Convert XBot example (basic)
make convert-xbot

# Troubleshoot conversion issues
make troubleshoot

# Clean build artifacts
make clean

# Build Python package
make build-package

Configuration

Create a .fbx2glb.json file in your project root to customize conversion behavior:

{
  "defaultMethod": "fbx-sdk",
  "fallbackMethods": ["fbx2gltf", "blender"],
  "blenderPath": "/Applications/Blender.app/Contents/MacOS/Blender",
  "outputFormat": "glb",
  "preserveAnimations": true,
  "optimizeMeshes": true
}

Conversion Methods

1. Autodesk FBX SDK (Recommended)

  • Pros: Best quality, supports FBX upgrading, handles all FBX versions
  • Cons: Requires SDK installation, larger file sizes
  • Use when: You need the highest quality conversion or have old FBX files

2. Facebook's fbx2gltf

  • Pros: Fast, good compression, open source
  • Cons: Limited FBX version support
  • Use when: You need fast conversion of modern FBX files

3. Blender

  • Pros: Free, handles many formats, good for complex scenes
  • Cons: Slower, requires Blender installation
  • Use when: You need to process many different 3D formats

Examples

Basic Conversion

# Convert a single file
python -m fbx2glb.cli model.fbx model.glb

# Convert with specific method
python -m fbx2glb.cli model.fbx model.glb --method fbx2gltf

# Convert with FBX upgrading
python -m fbx2glb.cli old_model.fbx new_model.glb --upgrade-fbx

Batch Processing

# Convert all FBX files in a directory
python -m fbx2glb.batch models/ output/ --recursive

# Convert with parallel processing
python -m fbx2glb.batch models/ output/ --parallel 4 --force

Component Generation

# Generate a React component
python -m fbx2glb.component character.fbx CharacterModel.tsx

# Generate with custom name
python -m fbx2glb.component character.fbx CharacterModel.tsx --name CharacterModel

Troubleshooting

Common Issues

  1. FBX version too old:

    # Use FBX upgrading
    python -m fbx2glb.cli old_model.fbx new_model.glb --upgrade-fbx
    
  2. No conversion methods available:

    # Check what's available
    python -m fbx2glb.cli --check-dependencies
    
    # Install FBX SDK
    make install-fbx-sdk
    
  3. Blender not found:

    # Specify Blender path
    python -m fbx2glb.cli model.fbx model.glb --blender-path /path/to/blender
    

Getting Help

# Run the troubleshooting command
make troubleshoot

# Check system information
python -m fbx2glb.cli --check-dependencies

Development

Running Tests

# Run all tests
pytest

# Run specific test file
pytest tests/test_utils.py

# Run with coverage
pytest --cov=fbx2glb

Building the Package

# Build distribution
make build-package

# Publish to PyPI (requires credentials)
make publish-package

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please check the contributing guidelines for more information.

Development Setup

  1. Fork the repository
  2. Create a feature branch
  3. Install in development mode: pip install -e '.[dev]'
  4. Make your changes
  5. Add tests for new functionality
  6. Run the test suite: pytest
  7. Submit a pull request

Acknowledgments

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

fbx2glb-0.1.0.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fbx2glb-0.1.0-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file fbx2glb-0.1.0.tar.gz.

File metadata

  • Download URL: fbx2glb-0.1.0.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/44.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/2.2.3 tqdm/4.66.5 importlib-metadata/7.0.1 keyring/25.6.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.7

File hashes

Hashes for fbx2glb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 56dbd5eb22e79556ceab202f4401f4a96cabd8302d82198f759d8faa9b2964d5
MD5 4b1e47d2533eb5ea0795d1a7344e91d5
BLAKE2b-256 53340c36da1eed3980418c501357df61070af81e176091a76380fbd85fc4fe54

See more details on using hashes here.

File details

Details for the file fbx2glb-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fbx2glb-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/44.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/2.2.3 tqdm/4.66.5 importlib-metadata/7.0.1 keyring/25.6.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.7

File hashes

Hashes for fbx2glb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 beee07864c6ab33c9b5bb9faa2badd268e5a5f850d284f5d0d8b2c22f09e8aa2
MD5 0e26da0601f7a24c15a5711c2c343d6b
BLAKE2b-256 ca16a835b24e040faf4b9a94c611a26be8d0028459ff3b3a54280b4a194bb09b

See more details on using hashes here.

Supported by

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