01 Shared field math for 3D worlds · CPU + Three.js TSL

The field you draw is the field you can touch.

Let CPU collision, buoyancy, forces, and hit tests evaluate the same procedural 3D field that Three.js TSL renders on the GPU—then measure the remaining float drift.

  • MIT
  • zero runtime dependencies
  • cross-runtime CI
  • public preview
Live 3D terrain instrument / dunesField sampling…

Drag or use arrow keys to move the probe.

CPU / f64
Assay / f32
Absolute drift

02 The split-world problem

GPU 3D displacement is invisible to CPU gameplay.

CPU physics, AI, servers, and hit tests cannot sample the vertex shader shaping a 3D world. Copying procedural math into JavaScript and shader code creates two authorities that can drift.

Matter Field makes the pure function authoritative and treats each backend as a materialization of it.

03 One expression tree

Write the field, not its copies.

terrain.jsone field
export function terrain(A, x, z) {
  const n = fbm(A, x, z, 0.0016, 2);
  return A.mul(
    A.sub(n, A.f(0.5)),
    A.f(24)
  );
}
01
numberAdapter

CPU oracle

Collision, AI, Workers, and Node servers evaluate the authoritative ECMAScript f64 tree.

02
makeTslAdapter

GPU graph

Pass the caller’s three/tsl namespace. The package never imports Three.js at runtime.

03
dualAdapter

Analytic gradients

Dual numbers derive normals and tangents from the exact same expression tree.

05 Measured, not asserted

Current hardware receipts

Absolute error in field units decides pass/fail. ULP counts remain diagnostic because they explode near zero crossings.

Recorded parity results by graphics hardware and browser backend
HardwareBackendMax observed absMax ULPu32 hashStatus

06 The honest contract

Three contract levels, no stronger.

  1. Tier 1

    CPU ↔ CPU

    tested bit-exact

    One committed golden agrees in browser, Worker, and supported Node CI.

  2. Tier 2

    Integer hash

    observed bit-exact

    Eleven raw u32 vectors agree in the current hardware receipts.

  3. Tier 3

    Float tree

    measured per field

    Restricted f32 operations tested against a declared absolute field-unit budget on each receipt.

07 Open fieldwork

Bring a GPU.
Add a receipt.

The parity claim gets stronger through public measurement, not louder marketing. Run the assay, inspect the JSON, and contribute a missing vendor cell.

Run on this hardware