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
  • Bounds-checked native decoding with malformed-input tests under ASan and UBSan

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. Security reports should follow SECURITY.md rather than public issues.

Metadata

Release files for tmb-codec 0.2.1

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.1
File
tmb_codec-0.2.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
tmb_codec-0.2.1-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.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
tmb_codec-0.2.1-py3-none-macosx_10_13_x86_64.whl Python 3 none macOS 10.13+ x86-64 Details

Total release size: 459.9 kB

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

Download URL tmb_codec-0.2.1-py3-none-win_amd64.whl
Size 84.2 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
115c0d090c1cbde84f3461b5d689170b54b04791f727cebf39b2cd1df0bd2269
BLAKE2b-256 checksum
How to use checksums
d69ca80324e1b940b2ea37d02cefbe4430c32cb632eb253331d208803eae6066
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.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL tmb_codec-0.2.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 131.6 kB
Tags Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
63bc1c9e4156bd50faf4a681d878e8fd465ad5265382f43cdebbdb86cc3f40b7
BLAKE2b-256 checksum
How to use checksums
b29ba7a43b92b78f69ca1b3b3f7a9e682b09a448018410a33845f58c4a9b4500
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.1-py3-none-macosx_11_0_arm64.whl

Download URL tmb_codec-0.2.1-py3-none-macosx_11_0_arm64.whl
Size 119.0 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7fd198036b6774c1e38f13b1199661ba63b50110d8efb3ac7c11d7a9312a005b
BLAKE2b-256 checksum
How to use checksums
d9c0a6a4f43165b4c2f73f561f61ae8fd38b5226fb6a99b5ea7d3396c8a6b8e3
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.1-py3-none-macosx_10_13_x86_64.whl

Download URL tmb_codec-0.2.1-py3-none-macosx_10_13_x86_64.whl
Size 125.1 kB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
2d548212a54119db27a2b7350072fcc5eda780d6a0121b020d3f344fbcfafb9d
BLAKE2b-256 checksum
How to use checksums
29cbbe167facce7811f3a5f4c6b66a5dd9e9f2f8d8a428c3d7bf68ba9ba2a365
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.1

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.1-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.1 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