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, DracoOptions

# Create custom compression options
options = DracoOptions()
options.quantization_position = 14  # Higher quality for positions
options.quantization_normal = 10    # Higher quality for normals
options.compression_level = 9       # Higher compression effort

# Compress with custom settings
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.4.tar.gz (31.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.4-py3-none-win_amd64.whl (473.0 kB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

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

File metadata

  • Download URL: gltf_draco_transcoder-0.2.4.tar.gz
  • Upload date:
  • Size: 31.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.4.tar.gz
Algorithm Hash digest
SHA256 c4012e229a65928b0c9116520594c8571ebb7e2c9d2ae9b6fdd8b9aef17d9b04
MD5 598311059f80c075d4fa9e93fc179cf3
BLAKE2b-256 25b77c1b4b8533c25b2d23cd6372dd8b0ee854d2ab70e5a8d5148cf6733c0c69

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 e0efab6d6db15a83649c4fe9fe1268ab999638aacebdaa03bbf028e938303a18
MD5 c1af7054fd9d0d104d0774873b7f819b
BLAKE2b-256 b854321b19d31754e38fd0160b18e9f7537ad548b1ab77c292face55cc2c2eb4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.4-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2c47eaa3364d731b40a18563cac2fb26011ba8afa745b837beb7993a11197cde
MD5 265435ea40d143d0b188115f8e2e2e8b
BLAKE2b-256 accc8fbdc59529a2d2e0ba8a6d17ad577b95285b731ef81cb045936ad49b58f0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.4-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 14693fc3c5674c551c127a8dd89b7c750f8068db72839c5a1e436cc1967bc2aa
MD5 3e3050bf735c4210a75133ff5ba32938
BLAKE2b-256 ef328bc6dd5cad113e236209cb024f4582444ada0930ea324d436824f7890494

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.4-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 db38a71a691b7f8a3b9850cf0526ae89b0afb4fa6d4ce5e5f01a727516f29535
MD5 d3723ff620cde1c6d6a329efca519d31
BLAKE2b-256 1f7fd2220e38e45a6cf518862d465e044b468bcadad50c5c33e5ec69da28c685

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.4-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 24b9a6417e5eb5440e2cc8375a819144dd08a29b096d998515d7e02438b4a248
MD5 ac7d400f3453c954b6bd779b4777e48f
BLAKE2b-256 5b1d27a39e8623dfcdd127df5075c10a75075ba26f2baa8056640f8831931bbb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for gltf_draco_transcoder-0.2.4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d914502e7336cce199d631ee630d08871f2b8636e0c97b8a4c432ee299e232df
MD5 a71c3335793e8ac7dc46494b799e0514
BLAKE2b-256 04422f44bb636a68dd0a2d7e63603b4249c1238e1f585017c82572d16ed55bff

See more details on using hashes here.

Provenance

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