Skip to main content

TMB Codec

TMB1 (Triangle Mesh Binary) is a compact general-purpose triangle-mesh codec. The library provides one C ABI across Windows, macOS, Linux, and WebAssembly. Native CI builds use Clang (clang-cl on Windows and clang++ elsewhere).

Features

  • Float32 bit-exact lossless positions
  • Quantized positions from 1 through 31 bits
  • Optional restoration of vertex IDs, face IDs, and triangle corner rotation
  • Single-file C++17 implementation
  • No runtime dependency on Zstd; compress the completed TMB1 bundle once outside the codec when using tmb1-zstd-v1

Applications that require stable per-vertex data use TMB_VERTEX_IDS (flags=1). This restores vertex rows and triangle references to original vertex IDs while allowing face row order and cyclic starting corners to remain in traversal order.

Python

Install a prebuilt native wheel:

pip install tmb-codec
from tmb_codec import decode, encode

data = encode(vertices, faces, bits=14)
decoded_vertices, decoded_faces = decode(data)

lossless = encode(vertices, faces, bits=None)

Wheels contain the Python API, the platform-native shared library, and license notices. They do not contain src/tmb_codec.cpp or an sdist.

Native build

Windows:

cmake -S . -B build -G Ninja -DCMAKE_CXX_COMPILER=clang-cl -DTMB_BUILD_TESTS=ON
cmake --build build --parallel
ctest --test-dir build --output-on-failure

macOS and Linux:

cmake -S . -B build -G Ninja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -DTMB_BUILD_TESTS=ON
cmake --build build --parallel
ctest --test-dir build --output-on-failure

WebAssembly with Emscripten:

emcmake cmake -S . -B build-wasm -DCMAKE_BUILD_TYPE=Release -DTMB_BUILD_TESTS=OFF
cmake --build build-wasm --parallel
node tests/wasm_smoke.mjs build-wasm/tmb_codec.js

The WASM build emits tmb_codec.js and tmb_codec.wasm with memory growth enabled and exports the five public TMB functions plus malloc/free.

Every push and pull request builds and installs native wheels on Windows, macOS, and Linux and runs the Python tests against those installed wheels. WASM has a separate Node.js round-trip test. Pushing a v* tag publishes wheels to PyPI and then creates a GitHub Release only after every required job succeeds.

C API

#include <tmb_codec.h>

unsigned char* bytes = nullptr;
size_t byte_count = 0;
double timings[3] = {};
int result = tmb_encode_quantized(
    vertices, vertex_count,
    faces, face_count,
    TMB_VERTEX_IDS, 14,
    &bytes, &byte_count, timings);
if (result == TMB_OK) {
    // Send zstd(bytes[0:byte_count]) or store the raw TMB1 bundle.
    tmb_free(bytes);
}

Inputs are contiguous float[V][3] positions and uint32_t[F][3] triangle indices. Encoder output is allocated by the codec and must be released with tmb_free. Decoder output arrays are allocated by the caller.

Format

TMB1 starts with ten little-endian uint32 values:

  1. Magic TMB1
  2. Format version 1
  3. Flags
  4. Vertex count
  5. Face count
  6. Topology section size
  7. Position section size
  8. Vertex-ID section size
  9. Face-ID section size
  10. Corner-rotation section size

Quantized streams set flag bit 8 and store the coordinate bit count in flag bits 16 through 20. Their position section begins with four little-endian float64 values: origin x/y/z and a common extent. Coordinates from 1 through 16 bits use one integer component per axis. Coordinates from 17 through 31 bits use low/high 16-bit components to keep prediction residuals inside signed 32-bit range.

The topology and position entropy streams are defined by the reference source in src/tmb_codec.cpp. Consumers should use the provided encoder and decoder unless they also maintain compatibility tests against the reference implementation.

License

The codec incorporates and modifies MIT-licensed Corto code. Preserve licenses/CORTO_LICENSE.txt with source and binary distributions. Project-level terms are in LICENSE; third-party attribution is in THIRD_PARTY_NOTICES.md.

Metadata

Release files for tmb-codec 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for tmb-codec 0.2.0
File
tmb_codec-0.2.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
tmb_codec-0.2.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
tmb_codec-0.2.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
tmb_codec-0.2.0-py3-none-macosx_10_13_x86_64.whl Python 3 none macOS 10.13+ x86-64 Details

Total release size: 449.7 kB

Release files / tmb_codec-0.2.0-py3-none-win_amd64.whl

Download URL tmb_codec-0.2.0-py3-none-win_amd64.whl
Size 81.1 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
068d5ccbb4d28cc403fdee1675d418700b6a038f2facc09a93347d6150b47c97
BLAKE2b-256 checksum
How to use checksums
b96e75ffc2d66825a0b4ed9f5c272bc2e9f6fbc4b5afdd75b179b03ff0a56787
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / tmb_codec-0.2.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL tmb_codec-0.2.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 128.8 kB
Tags Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
aae013c471f48d097ad4898676bf0167fbce9ce2b0aa69b379c096afaccf53df
BLAKE2b-256 checksum
How to use checksums
b061fd815aeda8325dbcd8bfd5fd33661e10cd17bbfdaa17b767405a57fd6166
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / tmb_codec-0.2.0-py3-none-macosx_11_0_arm64.whl

Download URL tmb_codec-0.2.0-py3-none-macosx_11_0_arm64.whl
Size 117.0 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f221a74c4b20d2bba34ab4bae4b7c2b97302abc002cf157a209895ad46479317
BLAKE2b-256 checksum
How to use checksums
83224dbe845e18cc43f2049204ca04596f3dde32ad3f7f13a4bba9b0bc154b36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / tmb_codec-0.2.0-py3-none-macosx_10_13_x86_64.whl

Download URL tmb_codec-0.2.0-py3-none-macosx_10_13_x86_64.whl
Size 122.8 kB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
ee836dc1eb6c5a0b316c48aa43ce357a77a881d0f60971a49b451dcbceadbe07
BLAKE2b-256 checksum
How to use checksums
7e90fe2defcff6207c9285f8d61dd99edd89adbba7cad07e230729fdbd78010a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Security for tmb-codec 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for tmb_codec-0.2.0-py3-none-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.2.0 This release

4 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page