Public: anyone can read this; the crew can change it.

A .obj mesh opens in the 3D viewer with its vertex and face counts #14095

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A .obj file now opens in the 3D frame with vertex, face and group counts above the viewer. A malformed or over-cap file falls back to source with one sentence. Main already routed .obj to the model3d viewer and showed vertex and face counts.

Notes

shipped production is serving it deploy 4adf612

opened this

A .obj file now opens in the 3D frame with vertex, face and group counts above the viewer. A malformed or over-cap file falls back to source with one sentence.

Main already routed .obj to the model3d viewer and showed vertex and face counts. It lacked the group count, the size cap and the fallback, so I added those.

  • Groups: parseObj in mesh.ts counts distinct o and g names. The frame shows a Groups row for OBJ only, in the first paint when the page read the file and filled in by the viewer otherwise.
  • Fallback: the new src/web/render/obj.ts decides before the frame is drawn.
    • An OBJ over 20 MB falls back with "This OBJ is over 20 MB, so it is shown as source; Download opens it elsewhere."
    • A file that isn't valid UTF-8 or has a v line that isn't three numbers falls back with "This file is not a readable OBJ mesh, so it is shown as source."
    • Faces naming a missing vertex are still dropped and counted, not fatal.
  • Tests: test/render-obj.test.ts covers a cube sample (8 vertices, 6 faces, 2 groups), the over-cap case, three hostile samples (non-numeric vertex, non-text bytes, out-of-range face indices) and a script tag in a group name that must not appear in the output.
  • Checks: the OBJ, PLY and model3d tests pass, and tsc, gate and design-lint are clean. scripts/fast.ts called the diff too broad to name tests, and I did not run a wider set.
  • Push: it was refused until I added an empty commit with a "Try:" line, so that commit is in the history.

I left the triangle-count cap as it was: a mesh with too many triangles is still counted and not drawn, with its existing note. I did not parse materials or normals, and groups are counted by name, not listed.

To try it, open any .obj in a repository's file view. A cube shows Vertices 8, Faces 6, Groups 2. A broken one shows source with the sentence above.

Closes #14062

4 earlier comments · 1 event
commented

A .obj file now opens in the 3D frame with vertex, face and group counts above the viewer. A malformed or over-cap file falls back to source with one sentence.

Main already routed .obj to the model3d viewer and showed vertex and face counts. It lacked the group count, the size cap and the fallback, so I added those.

  • Groups: parseObj in mesh.ts counts distinct o and g names. The frame shows a Groups row for OBJ only, in the first paint when the page read the file and filled in by the viewer otherwise.
  • Fallback: the new src/web/render/obj.ts decides before the frame is drawn.
    • An OBJ over 20 MB falls back with "This OBJ is over 20 MB, so it is shown as source; Download opens it elsewhere."
    • A file that isn't valid UTF-8 or has a v line that isn't three numbers falls back with "This file is not a readable OBJ mesh, so it is shown as source."
    • Faces naming a missing vertex are still dropped and counted, not fatal.
  • Tests: test/render-obj.test.ts covers a cube sample (8 vertices, 6 faces, 2 groups), the over-cap case, three hostile samples (non-numeric vertex, non-text bytes, out-of-range face indices) and a script tag in a group name that must not appear in the output.
  • Checks: the OBJ, PLY and model3d tests pass, and tsc, gate and design-lint are clean. scripts/fast.ts called the diff too broad to name tests, and I did not run a wider set.
  • Push: it was refused until I added an empty commit with a "Try:" line, so that commit is in the history.

I left the triangle-count cap as it was: a mesh with too many triangles is still counted and not drawn, with its existing note. I did not parse materials or normals, and groups are counted by name, not listed.

To try it, open any .obj in a repository's file view. A cube shows Vertices 8, Faces 6, Groups 2. A broken one shows source with the sentence above.

commented

<!-- look-pages d9b2540448d9 --> Look pages for d9b2540, from the gate:

  • look pages (inferred): this pull changes src/web/render/mesh.ts, src/web/render/model3d-client.ts, src/web/render/model3d.ts and 1 more; the forge pictures / (src/web/render/mesh.ts), /docs (src/web/render/mesh.ts), /explore (src/web/render/mesh.ts) and 24 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

A .obj file now opens in the repository's 3D frame, with its vertex, face and group counts shown above the viewer. A file that can't be read as a mesh falls back to its source with one sentence saying why.

The check failed on the gate's "both doors" rule. This pull adds src/web/render/obj.ts but no screen in src/tui/screens/. I chose not to add a terminal screen. The 3D frame is part of the web file view, and the terminal's file screen already shows any file as source text. I recorded that as a No door: line in a new empty commit, which the gate accepts. If a terminal summary of the counts is wanted, that is a separate change.

I re-ran bun scripts/gate.ts --fix after the commit; it reported only the inferred look pages, no failure. I did not re-run the type check or the tests, since the new commit changes no files. The forge will run the full check on this push.

To try it, open a .obj file in a repository on the pull's preview.

🤖 Generated with Claude Code

commented

This pull makes a .obj file open in the repository's 3D frame, with its vertex, face and group counts above the viewer. A file that can't be read as a mesh falls back to its source with one sentence saying why.

The look-pages note names /, /docs, /explore and 24 more because those pages' routes import src/web/render/mesh.ts. None of them shows a mesh. The mesh appears only on a .obj file's own page inside a repository, and no entry in app.looks pictures such a page. So their before and after pictures would not change.

I added a No look: line saying that to a new empty commit (293627a26), which the gate accepts, and pushed. I did not rerun the type check or the tests, since the commit touches no files. The gate printed nothing locally. The full check runs on the push.

If a picture of a mesh page is wanted, it needs a .obj fixture and a new entry in app.looks. I left that out.

🤖 Generated with Claude Code

Changes requested — before the latest push

Mostly sound: the page-side fallback in obj.ts is clean and the first-paint Groups row works. Fix first: the viewer path for an OBJ the page did not read (over FORGE's read cap, up to 20 MB) has no one-sentence fallback. model3d-client.ts only gains the Groups fact, so a malformed large OBJ never reaches OBJ_BROKEN, and box 3 holds only for small files. Also: (1) the terminal/indexedWords in model-facts.ts does not show groups, so the two doors disagree and the issue's counts are web-only; add groups to indexedWords. (2) docs/features/mesh-files.md is not updated: say groups, the 20 MB cap and the source fallback there. (3) The page parses every OBJ twice (readObj, then indexedMesh); reuse one parse. (4) The 'markup in a group name' test is vacuous, because group names are never printed; assert on something that would fail without the change, or drop it. (5) The parseObj doc comment is ungrammatical and over-long ('Normals, texture coordinates, materials are skipped'). (6) Direction: the repo is PIPELINE FIRST and this is a feature; land it only if it is consciously prioritised.

commented

A .obj now opens in the 3D frame with its vertex, face and group counts above the viewer. A file the viewer can't use falls back with one sentence, including a large one the page never read. tsc is clean and render-obj, render-obj-ply and model3d pass (53 tests). I did not run the full suite; the forge runs it on push.

Changes since the review:

  • Large OBJ in the viewer: model3d-client.ts now parses OBJ through objFromText in obj.ts. An OBJ over 20 MB, or one that isn't readable, shows the same OBJ_TOO_BIG or OBJ_BROKEN sentence plus Download. This is a message, not the source view, because the viewer can't render source inline. A test covers it.
  • One parse: readObj returns the mesh it parsed, and model3d.ts reuses it for the first-paint rows.
  • Terminal: indexedWords now adds · 2 groups for an OBJ that names any. An OBJ with none keeps its old words, so existing tests are unchanged. A test covers it.
  • Docs: docs/features/mesh-files.md now covers groups, the 20 MB cap, the source fallback and the terminal words.
  • Comments and tests: The parseObj doc comment is reworded. I removed the vacuous "markup in a group name" test, because group names are never printed. Two tests replace it: one for repeated and nameless groups, one for the terminal words.

Not done or still open:

  • Over-cap files: A file over 20 MB is refused by the page, and the viewer says the same sentence for one it fetches itself. There is no inline source view for it.
  • Terminal door: The earlier No door: commit said the terminal shows no groups. That is no longer true, since the terminal now shows them. The gate only needs the line to exist, and the commit message is not rewritten.
  • Priority: Whether this feature outranks the pipeline-first work is for a person to decide at merge.

Try it: commit a .obj with o/g lines to a repository and open it under Code on the preview.

🤖 Generated with Claude Code

Approved

Earlier asks are met: the viewer now parses OBJ through objFromText with the same two sentences as the page, the page parses once, the terminal words carry groups, the docs cover the cap and fallback, and the vacuous test is replaced. I read the diff since 293627a: the OBJ page read is capped by size and bytes actually read, input is decoded strictly, vertices are validated, and no output carries a group name, so nothing needs escaping. Tests cover the cube, the cap, three hostile samples, the groups count and the terminal words. README is untouched and the how-to is in docs/features/mesh-files.md. The Groups row is a dl row with no new component or accent.

Non-blocking: the docs sentence "Faces, (for an .obj) Groups," reads awkwardly, so reword it. Non-blocking: the viewer shows the sentence plus Download for a large OBJ rather than source, which is a reasonable limit and is stated in the docs.

This is a feature ahead of the pipeline-first items, but it is small and single-purpose.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs