Uh oh!
There was an error while loading. Please reload this page.
feat(viewer): report which faces touch which, and steady the zoom - #51
Conversation
32ab171 to
58e46b3Comparepclauss123
commented
Aug 26, 2026
Updated after running it against a real part — worth a re-read rather than a re-skim, since two things changed substantively. The The double-click gestures were rebound. Double left click used to re-frame. It now brings the clicked point to the middle and orbits about it from then on; re-framing moved to a double middle click. This matches 214 tests, types and build clean. |
`regionAdjacency` reads the mesh and returns, for each region, the regions sharing an edge with it. That is what lets a feature be drawn by clicking one face and following the surface, rather than picking every face by hand. `PartMesh` takes an `onAdjacency` callback and computes it once per mesh. `Viewer` gains `zoomTo` — cursor or centre — and re-frames the part on a double middle click. On the middle button because double left click is where a viewer usually puts 'orbit about this from now on', which is still to come; putting re-framing there would only have to move again. It is paired from single presses by `trackDoubleTaps`, because `dblclick` fires for the primary button only and there is no middle-button double-click event to listen to. `DirectionArrows` takes a list as well as a single index, so more than one way up can be shown at once. Two behaviour changes come with it. A part rebuilt on the same geometry used to blank the new one: a report changing identity rebuilds against the same cached mesh, and React builds the new part during render before disposing the old, so the old part's dispose deleted the attribute the new one had just set. Every vertex fell back to texel 0 and the part went one flat colour, with hover, selection and every wash gone with it. Dispose now removes the attribute only if it is still the one that part set. And five of the nine direction colours are retuned so neighbouring directions stay apart when the part is washed by direction.
58e46b3 to
5a79cedComparepclauss123
commented
Aug 26, 2026
One more update, and this one makes the PR smaller. The double-left-click orbit-centre gesture I mentioned in the last comment is out. Two implementations were tried against a real part — Double middle click still re-frames the part, which does work, and that is the only gesture this PR adds. It stays on the middle button because the left one is where the orbit-centre gesture belongs when it lands. Net effect on the review: one fewer public prop ( |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Three viewer changes the DFM app needs before its directions/mapping work can land
in
toolpath-template. They are separated from that work deliberately — this is thepackage half, and it is the half that has to publish first.
regionAdjacency(model, geometry)— new export. Reads the mesh and returns, foreach region, the regions sharing an edge with it. That is what lets a feature be
drawn by clicking one face and following the surface, instead of picking every face
by hand.
PartMeshtakes anonAdjacencycallback and computes it once per meshrather than per query.
Steadier zoom.
ViewergainszoomTo: 'cursor' | 'centre', and re-frames thepart on a double middle click (
recentreOnDoubleClick) — the way back from havingzoomed into a corner, which zooming to the cursor makes easy to do.
On the middle button because double left click is where a viewer usually puts "orbit
about this from now on". That gesture is not in this PR: two implementations of it
were tried against a real part and neither took effect in the app, and rather than
guess at the cause a third time it is left for a later pass. Putting re-framing on the
left button meanwhile would only have to move again.
The middle gesture is paired from single presses by
trackDoubleTaps, also exported,because
dblclickfires for the primary button only — there is no such event for themiddle button however many times it is pressed.
DirectionArrows'sshownDirectionwidens to accept a list as well as a singleindex, so more than one way up can be shown at once.
Two behaviour changes worth reading, neither an API break
A part rebuilt on the same geometry used to blank the new one. A consumer whose
report changes identity — a feature added, a re-fetch — rebuilds the part against the
same cached mesh, and React builds the new part during render before disposing the
old. The old part's
disposedeleted the region attribute unconditionally, includingthe one the new part had just set, so every vertex fell back to texel 0: the whole
part in one flat colour, with hover, selection and every wash gone with it.
disposenow removes the attribute only if it is still the one that part set. Covered by
part.test.ts— "leaves a newer part on the same geometry alone".Five of the nine
DIRECTION_COLORSare retuned so neighbouring directions stayapart when the part is washed by direction. Same export, same length, same type — but
anything hard-coding a hex or screenshot-testing the part will see a difference.
Called out in the changeset for that reason.
Why
minorChecked name by name, because it decides the bump. Every symbol the consuming app
imports is already in
0.3.1exceptregionAdjacency. The surface change is onenew export, three new optional props, one widened prop type — no removals, no
signature changes, no peer-dep changes.
Note
mainalready carries an unreleasedsquared-view-cubechangeset, also minor,so
0.4.0will contain both this and the view cube fix. Rebased onto that work;squaredUpandregionAdjacencycoexist in the built entry point.Public package release
pnpm changesetand committed the generated Changeset.no-release-neededlabel and explained why below.Validation
Confirmed
regionAdjacency,zoomTo,recentreOnDoubleClickand the widenedshownDirectionall reachdist/index.d.ts— the consuming app type-checks againstthe published types, not against source, so that mattered to check.