Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
186 commits
Select commit Hold shift + click to select a range
08687f5
(docs) Draft the scan restoration spec
nimerix Nov 20, 2026
5e9cfbb
(docs) Approve the scan restoration spec and add its plan
nimerix Nov 20, 2026
2398f25
(docs) Rename the tool to Refine and apply the product owner's answers
nimerix Nov 20, 2026
618dad9
(docs) Keep Sweep as an additional Refine region shape
nimerix Nov 20, 2026
bb572a6
(test) Add softened fixtures for Refine
nimerix Nov 20, 2026
f440204
(test) Triangulate fixture caps at scan density
nimerix Nov 20, 2026
d9d2b09
(feat) Add the Refine working mesh
nimerix Nov 20, 2026
f8c7a64
(test) Find fixture bounds without spreading into Math.min
nimerix Nov 20, 2026
d8b72ae
(fix) Write cut and untouched Refine vertices back exactly
nimerix Nov 20, 2026
fc2158d
(fix) Write Refine vertices into storage that can hold them
nimerix Nov 20, 2026
251fa3a
(feat) Cut Refine meshes along a field
nimerix Nov 20, 2026
014e897
(fix) Keep distinct Refine vertices distinct when storage is promoted
nimerix Nov 20, 2026
f06785c
(fix) Keep Refine cuts free of collapsed triangles
nimerix Nov 20, 2026
662b4d2
(fix) Keep an interleaved attribute's own classes on a Refine reorder
nimerix Nov 20, 2026
7aff22a
(feat) Fit planes, cylinders, cones and spheres for Refine
nimerix Nov 20, 2026
65214f6
(fix) Measure Refine noise at the scale of surface ripples
nimerix Nov 20, 2026
a5e8b5e
(fix) Keep Refine cut points off existing vertices
nimerix Nov 20, 2026
14d55f6
(feat) Fit and join Refine guide curves
nimerix Nov 20, 2026
9a79ca9
(fix) Hold Refine world positions in 64 bits
nimerix Nov 20, 2026
026d81b
(fix) Measure Refine cut clearance in the mesh's own scale
nimerix Nov 20, 2026
bf39d89
(fix) Make Refine shape fits hold against one-sided outliers
nimerix Nov 20, 2026
1288e09
(fix) Keep Refine guide curves on their samples and joints
nimerix Nov 20, 2026
b40b40b
(fix) Restore each Refine duplicate from its own source bits
nimerix Nov 20, 2026
ee17122
(fix) Require Refine shape fits to explain most of their points
nimerix Nov 20, 2026
ec31acb
(fix) Count Refine fit support against the noise, not the fit's own s…
nimerix Nov 20, 2026
7390856
(fix) Join Refine guide curves at their true closest approach
nimerix Nov 20, 2026
d3377fc
(fix) Seed Refine shape fits without depending on point order
nimerix Nov 20, 2026
ba21d4f
(fix) Score every Refine seed unless one explains nearly all points
nimerix Nov 20, 2026
f27f96c
(fix) Solve Refine guide joints exactly where curves cross
nimerix Nov 20, 2026
7d328d7
(feat) Read the softened band around a Refine guide
nimerix Nov 20, 2026
1fe6f43
(fix) Keep Refine circle joints exact far from the origin
nimerix Nov 20, 2026
01bc0aa
(fix) Break tied Refine seeds by support and read noise over a fixed …
nimerix Nov 20, 2026
5e6665e
(fix) Contain the Refine band to the surface under the guide
nimerix Nov 20, 2026
bb03a53
(fix) Classify the Refine band by signed distance along the surface
nimerix Nov 20, 2026
a432901
(fix) Find Refine edges where two flank surfaces meet
nimerix Nov 20, 2026
f017758
(feat) Rebuild a softened edge from a guide
nimerix Nov 20, 2026
167b7f9
(perf) Cut a Refine band without scanning the whole mesh
nimerix Nov 20, 2026
497eee6
(fix) Count Refine band evidence on its final zones and export its fl…
nimerix Nov 20, 2026
5f3e3b1
(fix) Refuse a Refine guide on a smooth surface
nimerix Nov 20, 2026
d3831f4
(fix) Blend a Refine edge into the scan from the boundary of what moves
nimerix Nov 20, 2026
7092c3d
(fix) Solve Refine edges from flank clear of the rounding and cut wit…
nimerix Nov 20, 2026
d035cd0
(fix) Judge Refine cut children against the surface they belong to
nimerix Nov 20, 2026
42ebb5a
(fix) Keep Refine flank vertices within tolerance of their surface
nimerix Nov 20, 2026
1bd7970
(fix) Hold a Refine edge to its corners and cut it along its whole guide
nimerix Nov 20, 2026
2a82e27
(feat) Join Refine guides into paths with corners and loops
nimerix Nov 20, 2026
d08a39f
(feat) Smooth, flatten and shape painted Refine regions
nimerix Nov 20, 2026
93fd1ba
(fix) Smooth Refine regions by local surface fits and ease kept detai…
nimerix Nov 20, 2026
2cd3cb6
(fix) Keep Refine detail from four times the region's roughness
nimerix Nov 20, 2026
2a6a120
(fix) Cut a Refine edge as one chain on the surfaces its vertices end on
nimerix Nov 20, 2026
3251716
(fix) Keep a Refine path's chain in one piece through its joints
nimerix Nov 20, 2026
a9a9913
(fix) Keep Refine regions from folding, shearing detail or mixing sep…
nimerix Nov 20, 2026
dd863f9
(test) Smooth the fixture sphere's long waves at a 2.2 mm reach
nimerix Nov 20, 2026
0f1354d
(fix) Check the positions a Refine region writes and refuse it whole
nimerix Nov 20, 2026
9a55008
(feat) Add crease, flatten and smooth brushes for Refine
nimerix Nov 20, 2026
67fd9c6
(fix) Count Refine fit points by their weights throughout
nimerix Nov 20, 2026
705ad93
(fix) Keep Refine brushes on the surface under them and flatten past …
nimerix Nov 20, 2026
e7d6b2b
(fix) Fade Refine brushes toward where the surface turns away
nimerix Nov 20, 2026
98fd623
(feat) Snap Refine regions to a sweep along an arc or spline
nimerix Nov 20, 2026
dd7bf40
(feat) Propose Refine guides and regions automatically
nimerix Nov 20, 2026
93f3c27
(feat) Build the Refine model and detect in a worker
nimerix Nov 20, 2026
5cf8c77
(feat) Add the Refine session to the store
nimerix Nov 20, 2026
ce5a897
(fix) End Refine job progress at 1, skip a cancelled build and keep d…
nimerix Nov 20, 2026
df8e6b5
(fix) Rebuild the patch round a Refine cut where splits collide
nimerix Nov 20, 2026
bb295ec
(fix) Carry a Refine path's cut through its joints
nimerix Nov 20, 2026
76af65b
(feat) Add guides, regions, brushes and detection to the Refine session
nimerix Nov 20, 2026
5a3fe28
(fix) Keep Refine previews pickable, cheap to patch and safe to cancel
nimerix Nov 20, 2026
9e18966
(fix) Make solving a Refine guide always finish
nimerix Nov 20, 2026
88230ea
(feat) Add the Refine tool button, shortcut and panel
nimerix Nov 20, 2026
af59458
(feat) Draw and drive Refine in the viewport
nimerix Nov 20, 2026
384fccc
(fix) Map each triangle of a rebuilt Refine cut patch to the triangle…
nimerix Nov 20, 2026
432c2a8
(fix) Join a smooth Refine path at the guide's own joints
nimerix Nov 20, 2026
12a1ec5
(docs) Describe Refine in the guide, changelog and design
nimerix Nov 20, 2026
02b0a6d
(fix) Carry a Refine cut through stretches the band leaves out
nimerix Nov 20, 2026
7637a29
(fix) Keep Refine panel edits on their own feature and its keys off t…
nimerix Nov 20, 2026
5eb43a9
(fix) Let Escape undo a Refine panel edit and keep each end, switch a…
nimerix Nov 20, 2026
5f394f1
(fix) Keep Refine strokes, drafts and detection from leaking into the…
nimerix Nov 20, 2026
88b7630
(fix) Index a Refine preview that was edited while its index was buil…
nimerix Nov 20, 2026
15ace83
(fix) Give each Refine handle drag its own undo step and drop a disca…
nimerix Nov 20, 2026
25a63bb
(fix) Use the automatic width when a Refine crease stroke is narrower…
nimerix Nov 20, 2026
2e45c07
(fix) Keep the toolbar on one row with the Refine button
nimerix Nov 20, 2026
e0cd6ca
(fix) Keep edited Refine proposals, cancelled drags and narrow crease…
nimerix Nov 20, 2026
9805750
(fix) Leave vertices a Refine cut only passes between exactly where t…
nimerix Nov 20, 2026
8ac099c
(fix) Keep a cancelled Refine slider drag cancelled and seed Width fr…
nimerix Nov 20, 2026
c9314bd
(fix) Propose Refine edges only between faces and keep regions inside…
nimerix Nov 20, 2026
91e4792
(fix) Keep Refine proposals' arcs true and let regions grow past fals…
nimerix Nov 20, 2026
468d330
(fix) Pick, paint and drag Refine only on what is visible and in the …
nimerix Nov 20, 2026
00ae2ae
(fix) Let a Refine handle drag be cancelled after the mode changes un…
nimerix Nov 20, 2026
1d75fd8
(fix) Refuse a Refine sweep its tube does not support and fit ovals
nimerix Nov 20, 2026
5674f7d
(fix) Refuse a Refine sweep whose section swells
nimerix Nov 20, 2026
8dfe541
(fix) Smooth a Refine sweep's path unless its stations show a real bend
nimerix Nov 20, 2026
4f12229
(fix) Keep Refine gestures and occlusion right while a picking index …
nimerix Nov 20, 2026
3b36217
(test) Give the Refine picking test room on a loaded machine
nimerix Nov 20, 2026
981f483
(fix) Join Refine proposals only across real edge and one real surface
nimerix Nov 20, 2026
694ac6a
(fix) Join Refine regions only when each fits the shared surface
nimerix Nov 20, 2026
d3fb2ce
(test) Cover Refine end to end
nimerix Nov 20, 2026
8b3a4c2
(fix) Choose a Refine sweep's path by what its stations support
nimerix Nov 20, 2026
90676f0
(docs) Correct the Refine guide and give it an illustration
nimerix Nov 20, 2026
71ae25b
(fix) Start no Refine gesture until the surface can be picked
nimerix Nov 20, 2026
70d6a8f
(fix) Ask again for a Refine picking index that was cancelled and cov…
nimerix Nov 20, 2026
e22924f
(fix) Keep Detect off edges already guided and accept a crease guide …
nimerix Nov 20, 2026
d9bbefa
(fix) Drop a Refine panel edit completely when it is cancelled or its…
nimerix Nov 20, 2026
e93907f
(fix) Seed a Refine region's manual settings from what its solve used
nimerix Nov 20, 2026
78e0e2d
(refactor) Remove the Refine region join that no scan needed
nimerix Nov 20, 2026
8111324
(fix) Fit the Refine Ends choices in their dropdowns
nimerix Nov 20, 2026
80abb84
(docs) Bring the Refine guide in line with the tool and recapture its…
nimerix Nov 20, 2026
41838ce
(perf) Reuse a guide's width classification when solving its band
nimerix Nov 20, 2026
a3708c6
(fix) Match Refine proposals guide to guide and say when pending work…
nimerix Nov 20, 2026
a0a31c1
(fix) Keep Escape from discarding Refine work and restore an abandone…
nimerix Nov 20, 2026
06a430c
(refactor) Keep one test of whether a Refine session holds work
nimerix Nov 20, 2026
5faa7c0
(docs) Record in the Refine spec what changed while building
nimerix Nov 20, 2026
bfb2c5b
(perf) Write a refined Refine geometry without a view per vertex
nimerix Nov 20, 2026
6705bfd
(perf) Rebuild a dragged Refine guide's draft when the pointer rests …
nimerix Nov 20, 2026
4c4e0c5
(fix) Bind Refine clicks and occlusion to what was pressed and what i…
nimerix Nov 20, 2026
62311fb
(docs) Say when leaving Refine shows the discard notice
nimerix Nov 20, 2026
a4a17b4
(test) Make Refine timing tests hold on a loaded machine
nimerix Nov 20, 2026
c4a781e
(test) Make the Refine end-to-end tests fail when what they name breaks
nimerix Nov 20, 2026
aba2b5d
(test) Time a Refine cut beside its reference pass so load falls on both
nimerix Nov 20, 2026
af7fa14
(perf) Keep a cut Refine model's arrays to the size they use
nimerix Nov 20, 2026
819d2e2
(fix) Pass a Refine selection to its exact replacement and restore a …
nimerix Nov 20, 2026
d0364e6
(test) Bound the preview change when a Refine region's Offset comes o…
nimerix Nov 20, 2026
630edec
(test) Benchmark Refine and render the reference parts
nimerix Nov 20, 2026
b84725a
(test) Strengthen Refine end-to-end regression coverage
nimerix Nov 20, 2026
e625905
(fix) Keep every Refine sample, dragged point and refused press true …
nimerix Nov 21, 2026
d4d6796
(fix) Read the current weld map when choosing cut diagonals
nimerix Nov 21, 2026
8872417
(perf) Sort long Refine neighbour rows with the typed array sort
nimerix Nov 21, 2026
d0ae932
(fix) Wait for a dragged Refine draft before allowing Accept
nimerix Nov 21, 2026
5f0cdf7
(perf) Reuse scratch data when updating a Refine preview
nimerix Nov 21, 2026
3cddb21
(test) Guard Refine cut locality and correct verification details
nimerix Nov 21, 2026
1ce3176
(docs) Record in the Refine spec where the build differs and falls short
nimerix Nov 21, 2026
0f7031a
(fix) Preserve erased paint through Refine cuts
nimerix Nov 21, 2026
2150525
(fix) Preserve sharp joint references during Refine cuts
nimerix Nov 21, 2026
d811c1b
(fix) Bound Refine spline sampling before allocation
nimerix Nov 21, 2026
ff5934a
(fix) Show the mesh edges and breaks of accepted Refine cuts
nimerix Nov 21, 2026
6b22dd3
(fix) Preserve detected proposals when cancelling a Refine drag
nimerix Nov 21, 2026
d7679f0
(fix) Leave no-change Refine features pending
nimerix Nov 21, 2026
bc5b6b2
(fix) Keep queued Refine samples with their original gesture
nimerix Nov 21, 2026
4195f4c
(fix) Choose and remove Refine guide points
nimerix Nov 21, 2026
92e80c0
(fix) Clarify which Refine gestures wait for indexing
nimerix Nov 21, 2026
866f160
(test) Check both Refine topology poles without a timer
nimerix Nov 21, 2026
9961cde
(docs) Bring the Refine guide in line with the final fixes
nimerix Nov 21, 2026
3399a81
(fix) Offer Remove point in Detect while a Refine guide point is chosen
nimerix Nov 21, 2026
fc2d452
(docs) Specify and plan how Refine reads narrow edges
nimerix Nov 21, 2026
733eb68
(fix) Measure a Refine edge's width from the solved edge
nimerix Nov 21, 2026
bdbfffe
(fix) Widen Refine's automatic width where an edge cannot be read wit…
nimerix Nov 21, 2026
b9678d6
(test) Require a cut in the window when measuring a Refine chain
nimerix Nov 21, 2026
5344763
(fix) Gather a Refine band as far as its solved edge strays from the …
nimerix Nov 21, 2026
7d2920d
(fix) Judge Refine's automatic width on a band that covers it
nimerix Nov 21, 2026
a80b38b
(fix) Hold a Refine band to the width its gather covers
nimerix Nov 21, 2026
536c408
(fix) Gather a Refine band no further than its solved edge strays
nimerix Nov 21, 2026
d321de8
(fix) Solve each Refine path segment at its own band width
nimerix Nov 21, 2026
7664066
(fix) Hold a Refine band's edge offsets within what its found slices …
nimerix Nov 21, 2026
f8f0125
(fix) Read a Refine band's geometry from the offsets its slices solved
nimerix Nov 21, 2026
87d51ab
(fix) Take Refine's joint and tied-end reach from each band's own width
nimerix Nov 21, 2026
9b3b8a0
(fix) Keep a Refine edge whole along a narrow flank
nimerix Nov 21, 2026
7aa077d
(test) Check a second Refine pass over a narrow wall
nimerix Nov 21, 2026
196c004
(fix) Fit and orient a Refine edge from the zones its slices found
nimerix Nov 21, 2026
b62cf9c
(test) Check every vertex standing on a Refine fixture's rivets
nimerix Nov 21, 2026
eb6c2e8
(test) Share one fillet sampler between the Refine profile fixtures
nimerix Nov 21, 2026
597e438
(fix) Follow a curved edge under a Refine line guide
nimerix Nov 21, 2026
5d348db
(fix) Read a zero gap clear of a Refine guide's tapers as measured
nimerix Nov 21, 2026
0d31775
(fix) Decide a Refine edge's kind again at each refit of its meet
nimerix Nov 21, 2026
0c482dd
(test) Check a Refine line stays straight where its meet scatters
nimerix Nov 21, 2026
dbe3db5
(test) Check a Refine line fitted as an arc between joints and at a t…
nimerix Nov 21, 2026
10739cf
(test) Check a Refine cut keeps to the crease it ties to
nimerix Nov 21, 2026
083cd37
(fix) Find a Refine edge across a rounding wider than the reach
nimerix Nov 21, 2026
bcc132d
(test) Pin the Refine seed reach with a fin guide past the reach
nimerix Nov 21, 2026
dc7633e
(fix) Try Refine seed pairs within reach before pairs with a seed pas…
nimerix Nov 21, 2026
fd04cad
(refactor) Bound Refine seeds by their window instead of an unused se…
nimerix Nov 21, 2026
a108856
(docs) Describe how Refine reads narrow edges
nimerix Nov 21, 2026
53e680e
(docs) Correct two Refine band comments
nimerix Nov 21, 2026
77c95e6
(docs) State what Refine's narrow-edge check measured, including what…
nimerix Nov 21, 2026
e71fe28
(docs) Add the outlet arc's refused second pass to the Refine spec
nimerix Nov 21, 2026
ef39ffc
(docs) Separate expected movement from faults in Refine's re-run results
nimerix Nov 21, 2026
add258d
(fix) Keep Refine's slice filling from moving rivets near the edge
nimerix Nov 21, 2026
5365ccd
(test) Guard Refine against edges on smooth walls and domes, and reco…
nimerix Nov 21, 2026
0a35b34
(fix) Keep Refine's first classification when a wider gather shows no…
nimerix Nov 21, 2026
db12fcd
(docs) Correct Refine's claims about re-runs and how a gather changes…
nimerix Nov 21, 2026
50afdaf
(fix) Let Refine solve again over a narrow wall it has already sharpened
nimerix Nov 21, 2026
d57a50d
(test) Pin the nearer edge for Refine guides across a belt
nimerix Nov 21, 2026
2e845ba
(refactor) Fill Refine's slices only once the evidence shows an edge
nimerix Nov 21, 2026
052f3fe
(test) Measure Refine's joint patch from the solved joint, and note w…
nimerix Nov 21, 2026
8f84181
(docs) State what Refine's rivet rule measured beside convex and conc…
nimerix Nov 21, 2026
6fc4283
(fix) Refuse a Refine edge where one smooth surface explains the band
nimerix Nov 21, 2026
39b8624
(docs) State Refine's one-surface rule
nimerix Nov 21, 2026
5b99904
(docs) Drop local paths from the narrow-edges plan
nimerix Nov 21, 2026
3bfdbdc
(docs) Date the Refine release note
nimerix Nov 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ top of the viewport, with Studio as the default. Smaller screens use collapsible
optional snap to neighbour, Close gap at an overlap depth, and a gap readout.
Apply bakes the warp as one undo step without modifying pins, anchors, joints,
or any other part. Cancel discards it.
- Offer a Refine tool (E) that rebuilds softened edges on a scanned part from
line, arc and spline guides, treats painted regions (smooth, flatten or snap
to a shape) while keeping detail, offers crease, flatten and smooth brushes,
and proposes guides and regions for review. Apply bakes the result as one
undo step without modifying pins, anchors, joints, or any other part. Cancel
discards it.
- Paint only edge-connected mesh patches; optional fixed seed-plane angle and
distance tolerances exclude adjacent bends and prevent plane drift across strokes.
- Fit painted planes with area-weighted moments. Offer mate with signed offset,
Expand Down
1,545 changes: 1,545 additions & 0 deletions docs/superpowers/plans/2026-11-19-scan-restoration.md

Large diffs are not rendered by default.

216 changes: 216 additions & 0 deletions docs/superpowers/plans/2026-11-20-refine-narrow-edges.md

Large diffs are not rendered by default.

728 changes: 728 additions & 0 deletions docs/superpowers/specs/2026-11-19-scan-restoration-design.md

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions docs/verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,32 @@ surfaces were drawn. The work is sliced, so the viewport keeps drawing throughou
| Unindexed scan | 1.2M | 0.26 to 0.31 s | 0.05 s |
| Unindexed scan | 10M | 0.67 to 0.68 s | 0.05 s |

Refine was timed with `KITBASHER_REFINE_BENCH=m4 npx vitest run tests/unit/refine-benchmark.test.ts`
on a 3-million-triangle unindexed sphere, cut by two planes and rippled, with a 40 mm line guide
along the rounded edge where the planes meet. The same operations were timed on scans with
861,910 and 827,970 triangles. Times are single runs on a machine shared with other work.

| Refine operation | 3M sphere | Two scans |
| ----------------------------------------- | --------- | -------------- |
| Build the model | 1.44 s | 0.69 s, 0.72 s |
| Preview update (solve plus uncut apply) | 0.93 s | 0.13 s, 0.10 s |
| Accept: solve, cut, topology, geometry | 2.0 s | 0.43 s, 0.38 s |
| Smooth region, 200,000 triangles | 1.37 s | 1.78 s, 2.06 s |
| Smooth region, 20,000 triangles | - | 0.17 s, 0.18 s |
| Flatten region on a plate | - | 0.17 s, 0.04 s |
| Shape region on a barrel or tank | - | 0.39 s, 0.34 s |
| Sweep region, 20,000 triangles of hose | - | 0.69 s |
| Smooth dab after the first, median | 2.5 ms | 20 ms, 9.4 ms |
| Flatten dab after the first, median | - | 8.2 ms, 4.3 ms |
| Crease stroke, end to end | - | 0.45 s |
| Detection over the whole part | 29.5 s | 8.6 s, 8.8 s |
| Detection job, with each proposal's check | - | 23.7 s, 24.2 s |

While a guide's handle is dragged, its draft is rebuilt once the pointer rests for 120 ms or is
released, so the guide follows the pointer at the frame rate: frames during a drag on a scan took
16.7 ms at the median and 18.1 ms at the 90th percentile, where each move had rebuilt the draft
in 93 ms before.

The GLB exporter's limit was located by bisection: 2,036 MiB of output works and 2,060 MiB does
not. Preparing a mesh for clicking took 19 s at 120 million triangles and failed at 150 million
with `Array buffer allocation failed`.
Expand Down
Binary file added public/docs/images/reference/refine.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 95 additions & 0 deletions scripts/capture-docs-reference.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,101 @@ try {
{ x: 760, y: 0, width: 680, height: 540 },
);
}
await capture('refine', async (page) => {
// A synthetic scan: the softened block of the Refine end-to-end tests.
await page.evaluate(async () => {
// The store module as the app loaded it, so the scene reaches the running editor.
const store = performance
.getEntriesByType('resource')
.map((entry) => entry.name)
.find((url) => /\/src\/core\/store\.ts(?:\?.*)?$/.test(url));
const { useEditor, refineSolved } = await import(store);
window.refineCapture = { useEditor, refineSolved };
const { softBox } = await import('/tests/helpers/soft-edges.ts');
const geometry = softBox([4, 3, 2], 0.6, { step: 0.2, ripple: 0.04, noise: 0.008 });
useEditor.getState().setScene({
name: 'Refine',
joints: [],
parts: [
{
id: 'block',
name: 'Scanned block',
geometry,
position: [0, 0, 0],
quaternion: [0, 0, 0, 1],
scale: [1, 1, 1],
color: '#d4a272',
visible: true,
locked: false,
source: 'Scanned block',
},
],
});
useEditor.getState().select('block');
});
await page.locator('.part-select[title="Scanned block"]').waitFor();
await page.keyboard.press('e');
await page.waitForFunction(
() => window.refineCapture.useEditor.getState().refine?.stage === 'ready',
null,
{ timeout: 60000 },
);
await expect(page.getByRole('radio', { name: 'Edge', exact: true })).toBeChecked();
// A fixed pose that keeps both guides and their handles clear of the camera overlay.
const ndcOf = (world) =>
page.evaluate(async (world) => {
const url = performance
.getEntriesByType('resource')
.map((entry) => entry.name)
.find((url) => url.includes('/@react-three_fiber.js'));
const root = (await import(url))._roots.get(document.querySelector('canvas')).store;
const { camera, controls, invalidate } = root.getState();
if (!world) {
camera.position.set(9, 6.6, 21);
camera.up.set(0, 1, 0);
controls.target.set(0, 0, 0);
controls.update();
invalidate();
await new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(done)));
return null;
}
return camera.position.clone().fromArray(world).project(camera).toArray();
}, world);
await ndcOf(null);
const canvas = await page.locator('canvas').first().boundingBox();
// The crest of a rounded edge of the block: 0.6 mm fillets on a block of half size 4, 3, 2.
const inset = 0.6 - 0.6 / Math.SQRT2;
const click = async (world) => {
const ndc = await ndcOf(world);
await page.mouse.click(
canvas.x + ((ndc[0] + 1) * canvas.width) / 2,
canvas.y + ((1 - ndc[1]) * canvas.height) / 2,
);
};
const features = () =>
page.evaluate(() => {
const { useEditor, refineSolved } = window.refineCapture;
const refine = useEditor.getState().refine;
return refine.features.map((f) => ({
state: f.state,
selected: refine.selected.includes(f.id),
solved: !!refineSolved(refine, f),
}));
});
await click([-3, 3 - inset, 2 - inset]);
await click([3, 3 - inset, 2 - inset]);
await expect(page.getByText('0 accepted · 1 proposed')).toBeVisible();
await page.getByRole('button', { name: 'Accept', exact: true }).click();
await expect
.poll(async () => (await features()).map((f) => f.state), { timeout: 30000 })
.toEqual(['accepted']);
await click([4 - inset, 2, 2 - inset]);
await click([4 - inset, -2, 2 - inset]);
await expect
.poll(async () => (await features())[1], { timeout: 30000 })
.toEqual({ state: 'pending', selected: true, solved: true });
await expect(page.getByText('1 accepted · 1 proposed')).toBeVisible();
});
await capture('exploded-view', async (page) => {
await page.getByRole('slider', { name: 'Exploded view amount' }).fill('65');
});
Expand Down
98 changes: 74 additions & 24 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
LoaderCircle,
Magnet,
Shield,
Sparkles,
Maximize,
MousePointer2,
Move3D,
Expand All @@ -48,7 +49,15 @@ import {
Undo2,
X,
} from 'lucide-react';
import { liveHost, liveSession, useEditor, type WarpGizmo } from './core/store';
import {
liveHost,
liveSession,
refineHoldsWork,
useEditor,
type RefineMode,
type WarpGizmo,
} from './core/store';
import { refineLeaveHint } from './components/refine-panel';
import {
chooseTransformTool,
downloadCurrentScene,
Expand Down Expand Up @@ -372,6 +381,7 @@ function Toolbar({
paint: useShortcut('paint'),
anchors: useShortcut('anchors'),
warp: useShortcut('warp'),
refine: useShortcut('refine'),
joint: useShortcut('joint'),
measure: useShortcut('measure'),
};
Expand Down Expand Up @@ -467,7 +477,7 @@ function Toolbar({
<span>Pin</span>
</button>
<button
className={`tool-button ${tool === 'anchors' ? 'active' : ''}`}
className={`tool-button compact-tool ${tool === 'anchors' ? 'active' : ''}`}
title={withShortcut('Rigid anchor fit', keys.anchors)}
onClick={() => useEditor.getState().setTool('anchors')}
>
Expand All @@ -484,6 +494,15 @@ function Toolbar({
<span>Warp</span>
{keys.warp ? <Keyboard>{keys.warp}</Keyboard> : null}
</button>
<button
className={`tool-button refine-tool ${tool === 'refine' ? 'active' : ''}`}
title={withShortcut('Refine edges and surfaces on a scan', keys.refine)}
onClick={() => useEditor.getState().setTool('refine')}
>
<Sparkles size={16} />
<span>Refine</span>
{keys.refine ? <Keyboard>{keys.refine}</Keyboard> : null}
</button>
<button
className={`tool-button compact-tool ${tool === 'joint' ? 'active' : ''}`}
title={withShortcut('Create joint', keys.joint)}
Expand Down Expand Up @@ -608,6 +627,22 @@ function Toolbar({
);
}

/** The status hint for each Refine mode, naming the brush size keys as bound. */
function refineHints(mode: RefineMode | 'building', smaller: string, larger: string) {
switch (mode) {
case 'building':
return 'Preparing the surface…';
case 'edge':
return 'Click along a rounded edge to place a guide. Enter accepts, Esc dismisses.';
case 'region':
return 'Paint the area to treat. Alt erases.';
case 'brush':
return `Drag across the surface.${smaller && larger ? ` ${smaller} and ${larger} change the brush size.` : ''}`;
case 'detect':
return 'Find edges and surfaces, then accept the proposals you want.';
}
}

function StatusBar() {
const freeMode = useEditor((s) => s.freeTransform?.mode);
const pivotPicking = useEditor((s) => s.pivotPicking),
Expand All @@ -618,7 +653,18 @@ function StatusBar() {
indexing = useEditor((s) => s.indexingMeshes > 0),
live = useEditor((s) => s.liveStatus),
warpStage = useEditor((s) => (s.tool === 'warp' ? s.warp?.stage : undefined)),
warpAdd = useEditor((s) => s.warpAdd);
warpAdd = useEditor((s) => s.warpAdd),
refineMode = useEditor((s) =>
s.tool === 'refine' && s.refine
? s.refine.stage === 'building'
? 'building'
: s.refine.mode
: undefined,
),
// Escape keeps the tool while leaving would lose work, so the hint says how to leave.
refineWork = useEditor(
(s) => s.tool === 'refine' && s.refine?.stage === 'ready' && refineHoldsWork(s.refine),
);
const hold = useShortcut('holdOrbit'),
cancel = useShortcut('cancel'),
pivot = useShortcut('pivot'),
Expand All @@ -643,32 +689,36 @@ function StatusBar() {
{freeMode
? 'Move pointer · X / Y / Z: axis · Enter / click: confirm · Esc / right-click: cancel'
: indexing
? 'Preparing a dense mesh · It can be clicked when this finishes'
? refineMode && refineMode !== 'building'
? 'Preparing a dense mesh. Strokes, paint and handle drags wait. Single clicks still work.'
: 'Preparing a dense mesh · It can be clicked when this finishes'
: navigationMode
? `${navigationMode === 'pan' ? 'Pan' : 'Orbit'} tool · Drag to navigate${cancel ? ` · ${cancel} to return` : ''}`
: pivotPicking
? `Click a model surface to set its pivot${[pivot, cancel].some(Boolean) ? ` · ${[pivot, cancel].filter(Boolean).join(' or ')} to cancel` : ''}`
: surfacePainting
? `Drag to paint · Alt erases${smaller || larger ? ` · ${[smaller, larger].filter(Boolean).join(' / ')} brush size` : ''} · ${orbitHint} orbits`
: warpStage === 'warp'
? warpAdd === 'line'
? `Drag on the surface to draw a line · Esc discards it · ${orbitHint} orbits`
: warpAdd === 'area'
? `Drag to paint an area${smaller || larger ? ` · ${[smaller, larger].filter(Boolean).join(' / ')} brush size` : ''} · Esc discards it · ${orbitHint} orbits`
: 'Click the surface to add a control point · Drag a handle to warp · Shift for fine adjustment'
: warpStage
? `Paint the area to warp, or choose Whole part · Alt erases · ${orbitHint} orbits`
: tool === 'align'
? `Pick source → target · ${orbitHint} orbits`
: tool === 'pins'
? 'Place hard or soft pins on the surface · Move or rotate to adjust the part'
: tool === 'anchors'
? 'Add surface anchors · Drag a target to fit · Shift for fine adjustment'
: tool === 'joint'
? 'Pick anchors to connect parts'
: ['translate', 'rotate', 'scale', 'transform'].includes(tool)
? 'Hold Shift while dragging for 10× finer adjustment'
: 'Shift + click to select multiple'}
: refineMode
? `${refineHints(refineMode, smaller, larger)}${refineWork ? ` ${refineLeaveHint}` : ''}`
: warpStage === 'warp'
? warpAdd === 'line'
? `Drag on the surface to draw a line · Esc discards it · ${orbitHint} orbits`
: warpAdd === 'area'
? `Drag to paint an area${smaller || larger ? ` · ${[smaller, larger].filter(Boolean).join(' / ')} brush size` : ''} · Esc discards it · ${orbitHint} orbits`
: 'Click the surface to add a control point · Drag a handle to warp · Shift for fine adjustment'
: warpStage
? `Paint the area to warp, or choose Whole part · Alt erases · ${orbitHint} orbits`
: tool === 'align'
? `Pick source → target · ${orbitHint} orbits`
: tool === 'pins'
? 'Place hard or soft pins on the surface · Move or rotate to adjust the part'
: tool === 'anchors'
? 'Add surface anchors · Drag a target to fit · Shift for fine adjustment'
: tool === 'joint'
? 'Pick anchors to connect parts'
: ['translate', 'rotate', 'scale', 'transform'].includes(tool)
? 'Hold Shift while dragging for 10× finer adjustment'
: 'Shift + click to select multiple'}
</span>
</div>
<div className="local-save-status">
Expand Down Expand Up @@ -794,7 +844,7 @@ export default function App() {
};
}, []);
useEffect(() => {
if (['align', 'joint', 'anchors', 'pins', 'warp'].includes(tool)) setRight(true);
if (['align', 'joint', 'anchors', 'pins', 'warp', 'refine'].includes(tool)) setRight(true);
}, [tool]);
useEffect(() => {
// Dropped files belong to one import dialog, not to the next one opened from a menu.
Expand Down
7 changes: 5 additions & 2 deletions src/components/CameraNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
viewDirections,
} from '../core/navigation';
import type { CameraDirection, CameraStep } from '../core/navigation';
import { paintingWarpRegion, useEditor } from '../core/store';
import { brushingRefine, paintingRefine, paintingWarpRegion, useEditor } from '../core/store';
import { usePreferences, useShortcut, withShortcut } from '../core/preferences';
import { clampPendingZoom, wheelZoom, zoomGlideStep } from '../core/zoom';
import { IconButton } from './ui';
Expand All @@ -30,7 +30,10 @@ const drawnSelection = (state: Editor) =>
const initialOrbitTarget: [number, number, number] = [0, 54, 0];
/** Whether a left drag paints with a surface brush rather than moving the camera. */
const brushOwnsLeftDrag = (state: Editor) =>
((state.tool === 'align' && state.operation.mode === 'surface') || paintingWarpRegion(state)) &&
((state.tool === 'align' && state.operation.mode === 'surface') ||
paintingWarpRegion(state) ||
paintingRefine(state) ||
brushingRefine(state)) &&
!state.navigationMode &&
!state.temporaryOrbit &&
!state.pivotPicking;
Expand Down
1 change: 1 addition & 0 deletions src/components/Dialogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ function HelpDialog() {
['Paint brush size / Erase', `${key('brushSmaller')} and ${key('brushLarger')} / hold Alt`],
['Rigid anchor fit', `${key('anchors')} · add surface anchors, then drag a target`],
['Warp a scanned surface', `${key('warp')} · lay a grid, then move control points`],
['Refine a scanned surface', `${key('refine')} · guide edges, treat regions, then Apply`],
['Pick pivot on model', `${key('pivot')} · click a surface`],
['Align / Joint / Measure', keys('align', 'joint', 'measure')],
['Front / Right / Top', keys('viewFront', 'viewRight', 'viewTop')],
Expand Down
15 changes: 10 additions & 5 deletions src/components/Inspector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AnchorControls } from './AnchorControls';
import { PinControls } from './PinControls';
import { TransformAdjustments } from './TransformAdjustments';
import { RefineControls } from './RefineControls';
import { WarpControls } from './WarpControls';
import { useEffect, useMemo, useRef, useState } from 'react';
import {
Expand Down Expand Up @@ -952,11 +953,13 @@ export function Inspector({ onClose }: { onClose: () => void }) {
? 'Anchors'
: tool === 'warp'
? 'Warp'
: tool === 'align'
? 'Alignment'
: tool === 'joint'
? 'Joint builder'
: 'Inspector'}
: tool === 'refine'
? 'Refine'
: tool === 'align'
? 'Alignment'
: tool === 'joint'
? 'Joint builder'
: 'Inspector'}
</span>
<div>
<IconButton label="Workbench help" onClick={() => useEditor.getState().setModal('help')}>
Expand All @@ -980,6 +983,8 @@ export function Inspector({ onClose }: { onClose: () => void }) {
<AnchorControls />
) : tool === 'warp' ? (
<WarpControls />
) : tool === 'refine' ? (
<RefineControls />
) : tool === 'align' || tool === 'joint' ? (
<AssemblyInspector />
) : selected.length > 1 ? (
Expand Down
Loading
Loading