8000 GitHub - stefangolas/look · GitHub
[go: up one dir, main page]

Skip to content
stefangolasPublic

About

No description, website, or topics provided.

Resources

Stars

44 stars

Watchers

0 watching

Forks

Repository files navigation

look

look is a native Rust 3D renderer and constructive CAD kernel (truck123d / truck-shapeops) in one workspace:

  • Native renderer (look) — renders GLB/glTF, STL, and STEP models directly to PNGs, multi-view GPU atlases, or a self-contained offline HTML viewer via wgpu (DX12 / Vulkan / Metal). No browser, Electron shell, VTK layer, or external STEP converter.
  • Constructive CAD kernel (truck123d + truck-shapeops) — flat N-ary CSG Booleans, lazy procedural SurfaceDag / ImplicitArc geometry, variable-radius rolling-ball fillets, guided RMF lofts, analytic & self-intersecting shelling, and declarative morphology (morph_open / morph_close), driven either from Rust or from Python via build123d syntax (corpus/ttc/door.py).

Formula 1 concept car — 27 subsystems, 1.73M triangles built by truck123d in true color and rendered as a smooth 60-frame 90-degree dark-room showroom sweep by look

Side-by-side comparison of the complete 27-subsystem Formula 1 car: OCCT (build123d, 3.61M tris, 18m 36s) vs LOOK (truck123d, 1.73M tris, 1m 25s, 13.1x faster)

Headline end-to-end demo (Formula 1 concept car — 27 subsystems, 1.73M triangles, release builds on RTX 5050 DX12):

Stage OCCT / F3D 3.5 truck123d + look (release) Result
Full 27-subsystem Formula 1 car (build + tess, 1t vs. 1t) 1,115.6 s (18m 36s, 3.61M tris) 85.2 s (1m 25s, 1.73M tris, 0 invalid edges) 13.1× faster · 0.48× tris
Hardest F1 shells: monocoque / engine_cover / sidepods 175.9 s / 171.7 s / 258.1 s 0.41 s / 5.80 s / 7.76 s 30–429× faster
55-row 3-corpora census (f1 + falcon_heavy + hypercar, 1t) 472.85 s 111.4 s (55/55, 0 invalid edges) 4.24× faster
hypercar/body paired build + tess (1t vs. 1t) 154.31 s 8.29 s (8.10 s build + 0.19 s tess) 18.6× faster
60-frame 90° F1 showroom sweep (800×450, AA PBR, 1.73M tris) — 1.04–2.16 s total (~17–36 ms/frame in one look run) Native GPU pass
core_xy.step STEP → PNG (5,623 faces, 512×512) 6,442 ms (F3D/OCCT) 2,005 ms (look native STEP) 3.21× faster
12-blade centrifugal impeller (24 variable-radius root fillets) Full radii: FAILED; scaled: 114.2 s (9.46 s MakeFillet) 33.0 ms median fresh-process (full radii) ~287× vs. scaled MakeFillet

Formula 1 concept car — 1600x900 dark-room showroom spotlight render at 80% frame occupancy 12-blade centrifugal compressor impeller with 24 variable-radius root fillets built by truck123d in 33 ms and rendered by look

Left: 1600×900 dark-room showroom render of the complete F1 car (look --material-mode source --antialias). Right: 12-blade centrifugal impeller with 24 variable-radius root fillets (33.0 ms in truck123d, 2×2 PBR atlas).

Khronos Damaged Helmet rendered side by side by look and F3D 3.5


Install

Linux and macOS:

curl -fsSL https://raw.githubusercontent.com/stefangolas/look/main/install.sh | sh

Windows PowerShell:

irm https://raw.githubusercontent.com/stefangolas/look/main/install.ps1 | iex

Or build from source:

cargo build --release --locked

See docs/INSTALLATION.md for version pinning and release archives.


Usage at a glance

1. Render a PNG or multi-view GPU atlas (GLB, STL, STEP)

The render subcommand is implied when the first argument is a model path. STEP files are tessellated natively inside the binary:

# Quick smoke test using the included fixture
look tests/fixtures/triangle.stl --output triangle.png --json

# Single isometric view (GLB, STL, or STEP)
look model.glb --view iso --resolution 1024x1024 --output render.png --json
look part.step --view iso --output part.png --json

# 2x2 multi-view atlas in one GPU pass (--resolution is per tile)
look part.step --views front,right,top,iso --atlas 2 --resolution 512x512 --output views.png --json

# Full PBR source materials + antialiasing + orthographic camera
look model.glb --material-mode source --antialias \
  --views front,right,top,iso --camera orthographic \
  --resolution 512x512 --atlas 2 --output pbr_views.png --json

Use --material-mode technical (default) when only geometry matters — it skips texture decode and upload. Use --material-mode source for PBR materials and STEP styled-item colours. Use --preset f3d-match only when matching F3D 3.5 framing and lighting.

2. Inspect geometry metadata (no GPU required)

look inspect model.glb --json
look doctor --json

3. Open an interactive offline 3D viewer

Generate a single self-contained HTML viewer (drag to orbit, scroll to zoom, works offline with no server):

# Write and open in your default browser
look model.glb --gui --material-mode source --view iso --output model_viewer.html --json

# Write the viewer file without opening a browser
look ui part.step --output part_viewer.html --json

4. Reuse a GPU-resident scene across many renders

Avoid repeated parsing, texture decoding, and GPU upload during iterative inspection:

look persist assembly.glb --material-mode source --ttl 600 --json
look render --session SESSION_ID --views front,right,top,iso --atlas 2 --output views.png --json
look inspect --session SESSION_ID --json
look close SESSION_ID --json

Manage the local loopback server with look sessions --json, look server status --json, and look server stop --json.

5. Run repeatable YAML render jobs

look run examples/technical.yaml --json
version: 1
scene:
  source: assembly.glb
  up_axis: y
render:
  resolution: [1024, 1024]
  material_mode: technical
  background: "#252525"
  antialias: false
  atlas_columns: 2
lighting:
  preset: technical
  ambient: 0.35
  direction: [-1, -2, -3]
  intensity: 0.85
  color: "#ffffff"
views:
  - id: front
    type: orthographic
    direction: [0, 0, 1]
  - id: iso
    type: perspective
    direction: [1, 1, 1]
output:
  directory: renders
  naming: "{view}.png"

Unknown YAML fields fail validation. Every subcommand also exposes built-in help (look --help, look render --help, look persist --help).


Signature example: Formula 1 end to end (truck123d + look)

Existing build123d scripts run through the kernel via corpus/ttc/door.py — see docs/PYTHON_API.md for all 71 exported operations and truck123d PyO3 bindings, and docs/REFUSALS.md for the refusal schema.

The full 28-subsystem, 815-member Formula 1 concept car (corpus/ttc/trees/f1/src) is vendored in this repository and runs directly on our constructive kernel via corpus/ttc/door.py using unmodified build123d Python syntax — emitting both a colored indexed GLB and a fingerprint STL:

# 1. Build F1 subsystems directly on the truck123d kernel (no external CAD install needed)
python corpus/ttc/door.py --engine truck corpus/ttc/trees/f1/src \
  lib.front_wing build_front_wing "[]" front_wing.stl --glb front_wing.glb

python corpus/ttc/door.py --engine truck corpus/ttc/trees/f1/src \
  lib.monocoque build_monocoque "[]" monocoque.stl --glb monocoque.glb

python corpus/ttc/door.py --engine truck corpus/ttc/trees/f1/src \
  lib.power_unit build_power_unit "[]" power_unit.stl --glb power_unit.glb

# 2. Render a 2x2 PBR atlas PNG in a single GPU pass
look front_wing.glb --views front,right,top,iso --atlas 2 --resolution 512x512 \
  --material-mode source --output front_wing_atlas.png --json

# 3. Or open it in the self-contained interactive offline HTML viewer
look ui front_wing.glb --performance --json

All 28 F1 subsystems (front_wing, nose, monocoque, halo, cockpit, sidepod_{left,right}, engine_cover, airbox, floor, diffuser, power_unit, drivetrain, rear_wing, drs_{flap,actuator}, beam_wing, suspension_{front,rear}, corner_{fl,fr,rl,rr}, steering_rack, track_rod_{left,right}, details) construct cleanly on the release kernel with 0 invalid boundary edges.

To fetch the rest of the pinned upstream earthtojake/text-to-cad assemblies (hypercar, falcon_heavy, motorbike, f14d, qdd_actuator, etc.) into gitignored .cache/ttc/:

python scripts/fetch_ttc.py

Native Rust C3 example — 12-blade centrifugal impeller

To exercise the kernel directly from Rust (twisted bicubic RationalNet blades on a quarter-torus hub + 24 variable-radius root fillets solved in 33.0 ms via SurfaceDag + procedural rolling-ball canals):

cargo run --release --locked -p truck123d --example centrifugal_impeller -- impeller.glb
look impeller.glb --views front,right,top,iso --atlas 2 --resolution 512x512 \
  --material-mode source --output impeller.png --json

Writing your own build123d scripts for truck123d

corpus/ttc/door.py is a drop-in replacement for build123d. A script written against it runs unchanged on either kernel: --engine truck builds on truck123d, and --engine occ builds on the real build123d (OCCT). Use it as a differential oracle.

1. Build the Python extension

cargo build --release --locked -p truck123d
mkdir -p pyext && cp target/release/truck123d.dll pyext/truck123d.pyd   # .so on Linux/macOS
export PYTHONPATH="$PWD/pyext:$PWD/corpus/ttc"

maturin build --release --features wheel-abi3 -m truck123d/Cargo.toml builds an installable abi3 wheel instead.

2. Write the script

Import build123d through the cadgen alias. The door answers that import with the truck123d drop-in on the truck engine, and with real build123d on OCC. Expose a plain function that returns the part:

# my_parts/bracket.py
from cadgen import build123d as bd


def bracket(width=40.0, hole=8.0):
    plate = bd.Box(width, 20, 6)
    plate = bd.fillet(plate.edges().filter_by(bd.Axis.Z), radius=3)
    boss = bd.Pos(0, 0, 8) * bd.Cylinder(radius=7, height=10)
    part = plate + boss - bd.Cylinder(radius=hole / 2, height=40)
    part.label = "bracket"
    part.color = bd.Color(0.43, 0.49, 0.55)   # carried into the GLB
    return part

3. Build and render

import door

door.ENGINE = "truck"                          # or "occ" for the OCCT reference
part = door.run_entry("my_parts", "bracket", "bracket", [])   # tree dir, module, entry, args
print(door.geometry_facts(part))               # solid count, volume, bbox
door._truck_export_glb(part, "bracket.glb")
look bracket.glb --view iso --material-mode source --antialias --up-axis z --output bracket.png --json

The bracket builds to a single solid of 5,488.78 mm³, which matches its hand-computed volume. The corpus census uses the one-line CLI form, python corpus/ttc/door.py --engine truck TREE MODULE ENTRY "[]" out.stl --glb out.glb, which also writes an STL fingerprint and a JSON record. Its STL comes from an older fixed-resolution mesher that refuses some carriers, the filleted bracket among them (E_UNSUPPORTED_ENVELOPE). Use the GLB export above when the CLI refuses.

When the kernel cannot build something, it does not fall back to OCCT. It raises a typed truck123d.Refused with a refusal_code and payload (see docs/REFUSALS.md). Common fixes are reordering the operations (fillet a primitive before the Boolean, not after) or simplifying one feature. docs/PYTHON_API.md lists every exported name.

Beyond build123d: C3 variable-radius fillets (gas turbine excerpt)

The door also exports kernel operations that build123d lacks: variable_fillet, brep_solid, realize_accuracy, morph_open/morph_close and draft. The T700-GE-701D compressor tree (corpus/ttc/trees/gas_turbine/src) builds every blisk blade root with a rolling-ball canal whose radius varies along the chord. The following excerpt is condensed from lib/compressor.py and lib/blades.py:

from cadgen import build123d as bd
from lib.blades import START, END, cylinder, fit_bspline, taper

hub = cylinder(rh)                         # analytic support: {"kind": "cylinder", "radius": rh, ...}
blade = fit_bspline(lambda u, v: point(side, u, v))   # one blade face as a bicubic B-spline net

stations = [START + (END - START) * i / 18 for i in range(19)]   # 19 chordwise stations
law = taper(0.74, 0.38, 0.28)              # radius polynomial in chord u: 0.74 at the leading edge,
                                           # 0.38 at the trailing edge, bellied mid-chord, flat slope at both ends
canal = bd.variable_fillet(
    left=hub,
    right={k: blade[k] for k in ("kind", "degree_u", "degree_v", "knots_u", "knots_v", "grid")},
    signs=[1, -side],                      # which side of each support the ball rolls on
    fixed_idx=2,                           # each station pins state[2], the blade chord parameter u
    stations=stations,
    seed=[theta, z, START, v, 0.74],       # state = [hub u, hub v, blade u, blade v, radius]
    radius=law,
)
for s in canal["sections"]:                # one characteristic circle per station
    u, v = s["state"][2:4]                 # contact point on the blade
    center, r, sweep = s["center"], s["circle_radius"], s["angle"]   # ball centre, arc radius, arc angle

blades.py stitches the sections into a watertight boundary with exact B-spline face carriers, passed to bd.brep_solid(vertices, faces, nets, face_nets). One row builds on its own:

row = door.run_entry("corpus/ttc/trees/gas_turbine/src", "lib.compressor", "axial_row",
                     [72, 7.8, 15, False, "Axial blisk 3", [0.62, 0.67, 0.72]])
door._truck_export_glb(row, "blisk.glb")   # 15 filleted blades, ~39k triangles

For the impeller exducer, variable_fillet(..., corner=...) closes the canal where both terminal rolling balls meet the outlet lip plane. See solve_blade in lib/blades.py. The full cold section is assembly_701d.compressor_module(), and corpus/ttc/trees/gas_turbine/T700_701D.md describes it.


Measured performance (release builds)

All numbers below come from authoritative target/release thin-LTO builds on one physical Windows x64 machine (NVIDIA GeForce RTX 5050 Laptop GPU, DX12); see docs/BENCHMARKS.md for raw samples, hardware fingerprints, and methodology.

Workload Baseline look / truck123d (release) Result
6 glTF samples (fresh process) F3D 3.5 look 1.40× geomean faster (up to 5.94× on 10.8M-tri Sponza foliage)
core_xy.step (5,623 faces, 512×512) F3D 3.5 / OCCT (6,442 ms) look (2,005 ms) 3.21× faster
Resident 4-view 512 px atlas Three.js WebGL2 (22.5 ms) / WebGPU (27.3 ms) look persist (8.94 ms) 2.5–3.1× faster
55-row 3-corpora CAD census (1t vs. 1t) OCCT (472.85 s) truck123d (111.4–130.3 s, 55/55, 0 invalid edges) 3.6–4.2× faster
hypercar/body paired build + tess (1t vs. 1t) OCCT (154.31 s) truck123d (8.29 s) 18.6× faster
12-blade centrifugal impeller (24 variable fillets) OCCT: full radii FAILED; scaled radii 114.2 s (9.46 s MakeFillet) truck123d (33.0 ms median fresh-process, full radii) ~287× vs. scaled MakeFillet

Repository layout

src/            Native `look` CLI, scene compiler, STEP importer, wgpu renderer, HTML viewer
tests/          Renderer, STEP, assembly, geometry-fingerprint, and GPU smoke tests
truck123d/      Constructive CSG IR, leaf realization, ResultTable bridge, Python bindings & examples
vendor/truck/   Vendored geometric kernel (`truck-shapeops` N-ary Boolean/blend/shell core + STEP/mesh stack)
corpus/         `door.py` build123d adapter, vendored F1 scripts, manifests, and offline test pins
scripts/        Corpus fetcher (`fetch_ttc.py`), diagnostic log tools, and regression scripts
docs/           Installation, benchmarks, refusal schema, and active kernel specifications

Development

Two build profiles separate fast iteration from measured release builds:

# Fast inner loop (opt-level 2, incremental, artifacts in target/quick/)
cargo qcheck
cargo qbuild
cargo qtest

# Authoritative release (thin LTO, codegen-units=1, artifacts in target/release/)
cargo build --release --locked

Never quote target/quick/ builds for performance numbers. Before committing, run:

cargo fmt --all -- --check
cargo check --locked --all-targets
cargo test --locked --all-targets
cargo test --release --test gpu_smoke -- --ignored --nocapture --test-threads=1

See docs/CROSS_PLATFORM_TESTING.md, docs/CONSTRUCTIVE_CLOSURE_BUILD_SPEC.md, and AGENTS.md.

Licensed under MIT or Apache-2.0.

About

No description, website, or topics provided.

Resources

Stars

44 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0