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 glTF/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 (including ARM64)
  • Configurable: Fine-tune compression quality with quantization and compression level settings
  • Easy Integration: Simple Python API and command-line interface

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 glTF/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.7.tar.gz (32.6 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.7-py3-none-win_amd64.whl (470.9 kB view details)

Uploaded Python 3Windows x86-64

gltf_draco_transcoder-0.2.7-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.7-py3-none-musllinux_1_2_aarch64.whl (3.6 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

gltf_draco_transcoder-0.2.7-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.7-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.7-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.7.tar.gz.

File metadata

  • Download URL: gltf_draco_transcoder-0.2.7.tar.gz
  • Upload date:
  • Size: 32.6 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.7.tar.gz
Algorithm Hash digest
SHA256 2b79e1da530723dd175341830240083be86cc39d7cb7cfb3955d52db39d9a46e
MD5 3589d1ef8697697e7b2a73404e356891
BLAKE2b-256 35632cc74ed721f0be799eb52b7622d005bf0c4344642419dcf3e23ccc1a1016

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.7.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.7-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.7-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 3c05c28dc3420468f5284b63d5affae8ec8f496084b8fb2dc4277c8f8f16dc96
MD5 5ec79435ae5222d7651664be9f75b2de
BLAKE2b-256 a11527376f36c7248da0182725601bae8baec40e933297b58857387928192a39

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.7-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.7-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.7-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b478efd826c0c45d8836f6931aae66d081c8dddef3c7713f30668c346a962148
MD5 8a9553d3051afef5128454576a1db413
BLAKE2b-256 c7c0d7cc989222f73ba72ce20b37b306927fb2619df6109615f09372122c6902

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.7-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.7-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.7-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 6937f0c1e503ab95b81eb64bc3e92409f00a7f8b3ca7b1aaa092f5a7671f6cf0
MD5 1ffe6bfd6508a3c19f082a0750e17dc9
BLAKE2b-256 e1415f11d30e8c896dadc7f42e291ab4aaa11f4555d4d79abbb771ba058cca29

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.7-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.7-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.7-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dbfc3b44c585f9ebee45d6702adb53e8d7949e9840c7d37fd009f72e0cdf9ec0
MD5 c1ab01dd42cdde70ffb6d8aaaf29be14
BLAKE2b-256 eacf019b80f5e4f37b58d4f0009e23c8e20f205861134c8e8a5ed4aaf5ea4294

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.7-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.7-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.7-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 698aaf508dc739f2e8c005ed84c5ebfbd9b0419c8e3ffeb3d3f01daa9a07279a
MD5 bc80079d697db8d1dcad30e1d23d11c3
BLAKE2b-256 be2bcb67b9954fa48d6410746587088dbad7829e8ccd30396f946831e0e5af8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.7-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.7-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.7-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e07a992cf8b6fff76f5fa7b2857848457783318e81b1f8f7db9a0050ebdc052a
MD5 9b9fe57b5e9a5f5db310329f11c5c82d
BLAKE2b-256 36771dbd772739cf3217daeb89d36cf9f861dce7e45fb042dbd1254cda804d9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for gltf_draco_transcoder-0.2.7-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