An .stl file as a 3D model
An .stl file (binary or ASCII) opens on its blob page as a part you can turn, with its facts above it:
Format, File size, Triangles and the Box (its size in the file's own units: an STL carries none, so it reads 20 × 20 × 20 units, not millimetres).
The first paint carries the triangle count and box, read by the server, so they show with JavaScript off.
src/web/render/stl.tsreads and checks the bytes (readStl);mesh.tsholds the shared parser;model3d.tsdraws the frame;model3d-client.tsis the viewer script (the vendored three.js, loaded only by this page).- Turn it with the pointer (drag to orbit, wheel or pinch to zoom, right-drag or two fingers to pan) or the arrow keys once the canvas has focus; it works by touch. Wireframe, Axes and Measure are buttons beside the facts.
- Measure: switch it on, pick two points on the part (tap it, or move the crosshair with the arrow keys, Shift
for bigger steps, and press Enter; the third pick starts again; a pinch or two-finger pan never picks), and the header reads the straight line between them,
d = √(Δx² + Δy² + Δz²), with each axis's run and the unit (mm;unitsfor an STL, which carries none). A drag is an orbit, never a pick. The markers take the page's--accent. In the terminal,mon a model asks for two points (x y z x y z) and answers with the same words. The arithmetic and the pick rules aremeasure.ts, checked by hand intest/model-measure.test.ts. - Volume and Area are rows beside the Box, in the same unit word cubed and squared (
8000 units³,2400 units²), read on the server so they show with JavaScript off. The terminal's file view carries them on its line:12 triangles · 20 × 20 × 20 units · Volume 8000 units³ · Area 2400 units². Volume is the divergence theorem,V = (1/6) Σ v0 · (v1 × v2)over the triangles; area isA = (1/2) Σ |(v1 − v0) × (v2 − v0)|(mesh_measure_solid.ts, checked by hand on a cube and a tetrahedron intest/mesh-solid.test.ts). A volume needs a closed mesh (every edge shared by two triangles) wound one way round (each edge walked once each way): an open mesh readsopen meshand one with mixed winding readsmixed winding, no volume, never a number; its area still shows. A mesh wound wholly inward reads as its magnitude. The unit is whatever the file's coordinates are in; an STL names none. - The Box row is the part's width × depth × height in that unit, shown for each format the viewer draws (STL, 3MF, OBJ, PLY, DAE, glTF).
- Edit (STL only, writers only): under the part, a form with Scale (a factor, or a target size for one axis,
which scales all three alike), Move (dx dy dz) and Turn (90° about x, y or z, right-hand rule). The order is
fixed: scale and turn about the origin, then move. Preview the new Box shows the triangle count and the new
Box and writes nothing; Commit saves the part as a binary STL (normals rewritten from the winding) in one commit
whose message names the change (
a.stl: scale ×2, turn 90° about z, move 1, 0, 0). On a protected default branch the commit goes to a new branch and a pull, as the subtitle shift does. Numbers are bounded (factor 0.001 to 1000, moves ±1,000,000); the post is same-origin and writer-only.src/web/render/mesh_edit.tsis the pure transform,src/actions/mesh_edit.tsthe preview-or-commit action, the route is the file edit route'smeshform. A tag or commit as the ref also goes to a new branch and a pull, forked from the default branch. In the terminal, with a repository open, the palette's "Scale, move or turn an STL" (src/tui/screens/mesh_edit.ts) asks for the path, a factor, a turn and a move, and commits through the same action. A commit holds 2 MB a file, so over that the form says so instead; the 20 MB limit still governs viewing. Other model formats, and STEP, are not editable here; the text editor's refusal says what opens them (opens_with.ts); STEP still shows its part card, not geometry (that needs a CAD kernel in WebAssembly, a later pull). - The header and triangle count are checked against the byte length before any triangle is read. A truncated or damaged file, one with no triangles or a coordinate that is not a number, is refused with a sentence and Download.
- Download as ASCII / binary (#15856): a link beside the facts saves the other form of the file,
part-ascii.stlorpart-binary.stl, fromGET /:owner/:name/stl/:ref/*path(stlConvertedinsrc/web/pages/repo.ts; same access as raw). Binary becomessolidtext with every coordinate written as the shortest text that reads back to the same float32, so the round trip loses nothing; ASCII becomes binary with normals computed from the corners (right-hand rule). The 80-byte header and attribute words are not carried; the solid is namedforge. Over 20 MB, unreadable or empty it answers 422 with a sentence. The terminal's file view (src/tui/screens/workspace.ts) prints the same address on anAs ASCII:/As binary:line underDownload:. The pure conversion issrc/web/render/stl_convert.ts; pinned bytest/stl-convert.test.tsandtest/tui-model3d.test.ts. - Over 20 MB: refused with a sentence and never fetched; Download still streams it.
- The server reads the whole file, up to 20 MB, for the first paint, so the facts show with JavaScript off at any size the page opens.
- Try it: commit a
.stlto a repository and open its file page.
Pinned by test/mesh-edit.test.ts (the transform, the form, the commit, the protected branch, the terminal), test/mcp-mesh-edit.test.ts (the MCP tool: preview, commit, the pull on a protected default, the refusals), test/render-stl.test.ts, test/model3d.test.ts, test/tui-model3d.test.ts (the m key) and
test/model-edit-refusal.test.ts (the edit page's sentence). The crosshair's keydown and the pointer wiring in
model3d-client.ts have no DOM test; the rules they call are pinned in test/model-measure.test.ts. The viewer's neighbours: mesh-files.md.
An agent does the same through the MCP write_file tool: mesh: { scale, move, turn } on an .stl path previews the new Box, and dryRun: false commits it with the page's commit subject and receipt words.