Skip to main content

Python package for GLTF Draco transcoding with C++ backend

Project description

gltf_draco_transcoder

A high-performance Python package for compressing and decompressing glb files using the Draco 3D data compression library. This package provides both a Python API and a command-line interface for efficient 3D model compression.

Features

  • Compression: Compress glb files using Draco compression to reduce file sizes significantly
  • Decompression: Decompress Draco-compressed glb files back to standard glTF format
  • High Performance: C++ backend with Python bindings for maximum performance
  • Cross-platform: Supports Windows, macOS (ARM64), and Linux (x86_64 and ARM64)
  • Configurable: Fine-tune compression quality with quantization and compression level settings
  • Easy Integration: Simple Python API and command-line interface

Live Demo

Try the online demo to see Draco compression in action on glTF files. The demo uses the WebAssembly (WASM) port of the same C++ codebase as this Python package.

Installation

Install from PyPI:

pip install gltf_draco_transcoder

Usage

Python API

Basic Compression

from gltf_draco_transcoder import compress_gltf, decompress_gltf

# Compress a glTF/glb file
compressed_data = compress_gltf('input.glb')

# Save compressed data
with open('output_compressed.glb', 'wb') as f:
    f.write(compressed_data.getvalue())

# Decompress back to glTF/glb
decompressed_data = decompress_gltf('output_compressed.glb')
with open('output_decompressed.glb', 'wb') as f:
    f.write(decompressed_data.getvalue())

Advanced Compression with Custom Options

from gltf_draco_transcoder import compress_gltf

# Compress with custom quantization and compression level settings
# qp: quantization_position, qn: quantization_normal, cl: compression_level
compressed_data = compress_gltf('input.glb', qp=14, qn=10, cl=9)

Command Line Interface

Compress a glb file:

python -m gltf_draco_transcoder input.glb output_compressed.glb

This will display compression statistics including file sizes and compression ratio.

Compression Options

The compress_gltf function accepts the following parameters:

  • Quantization Bits (default values shown):

    • qp=11: Position quantization
    • qt=10: Texture coordinate quantization
    • qn=8: Normal vector quantization
    • qc=8: Color quantization
    • qtg=8: Tangent quantization
    • qw=8: Weight quantization
    • qg=8: Generic attribute quantization
  • Compression Level:

    • cl=7: Compression effort (0-10, higher = better compression but slower)

Higher quantization bits = better quality but larger file sizes. Higher compression levels = better compression ratios but slower processing.

Development

Building from Source

This project uses scikit-build-core with CMake and vcpkg for dependency management.

Prerequisites

  • Python 3.10+
  • CMake 3.15+
  • Git
  • vcpkg (automatically installed on Linux via CI scripts)

Build Steps

# Clone the repository
git clone https://github.com/gongfan99/gltf_draco_transcoder.git
cd gltf_draco_transcoder

# Install build dependencies
pip install scikit-build-core setuptools-scm

# Build the package
python -m build

Project Structure

src/gltf_draco_transcoder/
├── __init__.py          # Main API exports
├── loader.py            # Python wrapper and ctypes bindings
├── py.typed             # Type hints marker
└── _version.py          # Version information (auto-generated)

cpp/
├── draco_transcoder_c_api.*    # C API wrapper
└── draco_transcoder_lib.*      # Core C++ implementation

vcpkg-overlays/draco/           # Custom Draco build configuration
vcpkg-triplets/                 # Platform-specific build triplets

Platform Support

  • Linux: x86_64 and ARM64 (manylinux/musllinux wheels)
  • macOS: ARM64
  • Windows: x86_64 (win_amd64 wheels)

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues on GitHub.

License

This project is licensed under the Apache License Version 2.0 - see the LICENSE file for details.

Credits

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

gltf_draco_transcoder-0.2.8.tar.gz (33.2 kB view details)

Uploaded Source

Built Distributions

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

gltf_draco_transcoder-0.2.8-py3-none-win_amd64.whl (470.9 kB view details)

Uploaded Python 3Windows x86-64

gltf_draco_transcoder-0.2.8-py3-none-musllinux_1_2_x86_64.whl (3.8 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

gltf_draco_transcoder-0.2.8-py3-none-musllinux_1_2_aarch64.whl (3.6 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

gltf_draco_transcoder-0.2.8-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.7 MB view details)

Uploaded Python 3manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

gltf_draco_transcoder-0.2.8-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (2.5 MB view details)

Uploaded Python 3manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

gltf_draco_transcoder-0.2.8-py3-none-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file gltf_draco_transcoder-0.2.8.tar.gz.

File metadata

  • Download URL: gltf_draco_transcoder-0.2.8.tar.gz
  • Upload date:
  • Size: 33.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gltf_draco_transcoder-0.2.8.tar.gz
Algorithm Hash digest
SHA256 33941470b1b801eff0b4cbbf03b648ea4c93adea4157ee55859e6e43a5bfcf6a
MD5 5849015ffbe3b750660455f0b4055f5d
BLAKE2b-256 e71dcc3fc42c23e0651b25d17f5089b2381b3bf6de55501f391b5e77b3a9896e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.8.tar.gz:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gltf_draco_transcoder-0.2.8-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.8-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 092eab7de81e27d908f823303edd91d683f5155b7cf4e39af2a32613006d77fb
MD5 b9e1d21f1e56e9352a71211e06a28e38
BLAKE2b-256 576d771ff6412285deddacbf298deb7da21d72ebbdf106950adc646f05f9e81d

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.8-py3-none-win_amd64.whl:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gltf_draco_transcoder-0.2.8-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.8-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c93120731030221f77a7a24296b0531c02506380bf24e3a3f2cabeccbdcbe695
MD5 325446fb708d953e32436b9b20ac5bac
BLAKE2b-256 031fdf93a059c3db2635a3a01567d583e0c711bc6156dd032287ce0f4ddce145

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.8-py3-none-musllinux_1_2_x86_64.whl:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gltf_draco_transcoder-0.2.8-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.8-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 5636290ab96168ad795835d68fd71d8aa9f7327ae2b8676b64fb7d9dc55e5640
MD5 8444440392dbb653ea5a262415208f64
BLAKE2b-256 fb1f3eb01dcda8671255e41f8f721d968dbb8a53e29bffb273d279eb0c63be6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.8-py3-none-musllinux_1_2_aarch64.whl:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gltf_draco_transcoder-0.2.8-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.8-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 53f86b7e1b4716b076b513776caf1985aa98734ff7f978fbad487e4c6dc61f98
MD5 c07343a0d09ccde154fec7686452e4aa
BLAKE2b-256 84752d97df3be6f2e3064574bd93a5cb6d15a4a0895ccc9bc7e73ab9106886de

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.8-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gltf_draco_transcoder-0.2.8-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.8-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 54d000182c3c0395dcf4772a53bc2c4b3cf436353eaad33da9054582cd07fd84
MD5 6fc1222d4085283c5a4c6433b48e91ae
BLAKE2b-256 28dab5ec0ef72224b49d76dcb58984db1909ccec61e103afebf331fd8e3ca4f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.8-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gltf_draco_transcoder-0.2.8-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.8-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d9c8f99a91067c273c51600ff5c54fa93fe4a77f7d01897205e8aae73bd0c327
MD5 b55838818593ec59b3449e2b15e4db6c
BLAKE2b-256 fca6ea8cbb97cf73e266665ef905cc2e93379cefefa959ec50b367fb22a05718

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.8-py3-none-macosx_11_0_arm64.whl:

Publisher: build_wheels.yml on gongfan99/gltf_draco_transcoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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