copper3d 3.6.2 → 3.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Loader/copperNrrdLoader.js +1 -1
- package/dist/Loader/copperNrrdLoader.js.map +1 -1
- package/dist/Scene/copperScene.d.ts +4 -4
- package/dist/Scene/copperScene.js +4 -4
- package/dist/Scene/copperScene.js.map +1 -1
- package/dist/Utils/segmentation/NrrdTools.d.ts +41 -2
- package/dist/Utils/segmentation/NrrdTools.js +30 -2
- package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
- package/dist/Utils/segmentation/tools/AiAssistTool.d.ts +108 -5
- package/dist/Utils/segmentation/tools/AiAssistTool.js +408 -25
- package/dist/Utils/segmentation/tools/AiAssistTool.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/MeshGraph.d.ts +12 -10
- package/dist/Utils/surfaceAnnotation/MeshGraph.js +14 -12
- package/dist/Utils/surfaceAnnotation/MeshGraph.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.d.ts +48 -28
- package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.js +76 -50
- package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/annotationStore.d.ts +4 -4
- package/dist/Utils/surfaceAnnotation/annotationStore.js +4 -4
- package/dist/Utils/surfaceAnnotation/annotationStore.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/contourRender.d.ts +1 -1
- package/dist/Utils/surfaceAnnotation/contourRender.js +16 -11
- package/dist/Utils/surfaceAnnotation/contourRender.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/geodesicContour.d.ts +11 -10
- package/dist/Utils/surfaceAnnotation/geodesicContour.js +16 -15
- package/dist/Utils/surfaceAnnotation/geodesicContour.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/pointMarkers.d.ts +3 -2
- package/dist/Utils/surfaceAnnotation/pointMarkers.js +6 -2
- package/dist/Utils/surfaceAnnotation/pointMarkers.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/raycastSurface.d.ts +3 -2
- package/dist/Utils/surfaceAnnotation/raycastSurface.js +71 -5
- package/dist/Utils/surfaceAnnotation/raycastSurface.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/strokeContour.d.ts +9 -6
- package/dist/Utils/surfaceAnnotation/strokeContour.js +15 -10
- package/dist/Utils/surfaceAnnotation/strokeContour.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/types.d.ts +5 -5
- package/dist/Utils/surfaceAnnotation/types.js +2 -2
- package/dist/Utils/surfaceAnnotation/types.js.map +1 -1
- package/dist/Utils/texture2d.js +4 -2
- package/dist/Utils/texture2d.js.map +1 -1
- package/dist/Utils/workers/reformatSaveDataWorker.js +2 -2
- package/dist/Utils/workers/reformatSaveDataWorker.js.map +1 -1
- package/dist/bundle.esm.js +684 -157
- package/dist/bundle.umd.js +684 -157
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/three-vignette.js +8 -2
- package/dist/lib/three-vignette.js.map +1 -1
- package/dist/types/Scene/copperScene.d.ts +4 -4
- package/dist/types/Utils/segmentation/NrrdTools.d.ts +41 -2
- package/dist/types/Utils/segmentation/tools/AiAssistTool.d.ts +108 -5
- package/dist/types/Utils/surfaceAnnotation/MeshGraph.d.ts +12 -10
- package/dist/types/Utils/surfaceAnnotation/SurfaceAnnotator.d.ts +48 -28
- package/dist/types/Utils/surfaceAnnotation/annotationStore.d.ts +4 -4
- package/dist/types/Utils/surfaceAnnotation/contourRender.d.ts +1 -1
- package/dist/types/Utils/surfaceAnnotation/geodesicContour.d.ts +11 -10
- package/dist/types/Utils/surfaceAnnotation/pointMarkers.d.ts +3 -2
- package/dist/types/Utils/surfaceAnnotation/raycastSurface.d.ts +3 -2
- package/dist/types/Utils/surfaceAnnotation/strokeContour.d.ts +9 -6
- package/dist/types/Utils/surfaceAnnotation/types.d.ts +5 -5
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -1
|
@@ -26,7 +26,7 @@ import type { SliceRenderHostDeps } from "./ToolHost";
|
|
|
26
26
|
/** Scratch volume key in maskData.volumes — kept OUT of image.layers so
|
|
27
27
|
* compositeAllLayers ignores it (we render it ourselves in start()). */
|
|
28
28
|
export declare const AI_SCRATCH_LAYER = "aiScratch";
|
|
29
|
-
export type AiPromptTool = "point" | "box" | "scribble";
|
|
29
|
+
export type AiPromptTool = "point" | "box" | "scribble" | "lasso";
|
|
30
30
|
export interface AiPromptPoint {
|
|
31
31
|
x: number;
|
|
32
32
|
y: number;
|
|
@@ -48,6 +48,9 @@ export interface AiPromptPayload {
|
|
|
48
48
|
};
|
|
49
49
|
scribble?: AiPromptPoint[];
|
|
50
50
|
scribbleRadius?: number;
|
|
51
|
+
/** Closed-contour lasso: ordered contour points (implicitly closed — the
|
|
52
|
+
* backend connects the last point back to the first). One contour per gesture. */
|
|
53
|
+
lasso?: AiPromptPoint[];
|
|
51
54
|
}
|
|
52
55
|
export interface AiMaskResult {
|
|
53
56
|
axis: "x" | "y" | "z";
|
|
@@ -73,29 +76,70 @@ export declare class AiAssistTool extends BaseTool {
|
|
|
73
76
|
private committedVol;
|
|
74
77
|
private promptTool;
|
|
75
78
|
private polarity;
|
|
76
|
-
/**
|
|
77
|
-
|
|
79
|
+
/** The label value (1-255) the AI currently paints into = the active Segmentation.
|
|
80
|
+
* Each Segmentation is a label value in the single-channel scratch volume; its
|
|
81
|
+
* colour lives in the volume's colorMap (set via setSegmentColor). */
|
|
82
|
+
private activeLabel;
|
|
78
83
|
/** Scribble brush radius (px), user-adjustable via slider. */
|
|
79
84
|
private scribbleSize;
|
|
80
85
|
/** Accumulated prompts for the CURRENT slice; reset on slice/axis change. */
|
|
81
86
|
private points;
|
|
82
87
|
private scribble;
|
|
88
|
+
/** Lasso contour sent to the backend (densified along the curve at finish). */
|
|
89
|
+
private lasso;
|
|
83
90
|
private box;
|
|
84
91
|
private activeSlice;
|
|
92
|
+
/** Placed lasso vertices (voxel + screen + polarity). Empty = not editing. */
|
|
93
|
+
private lassoVerts;
|
|
94
|
+
/** Undo / redo snapshot stacks of the vertex list (for Ctrl+Z / Ctrl+Y). */
|
|
95
|
+
private lassoUndo;
|
|
96
|
+
private lassoRedo;
|
|
97
|
+
/** Index of the vertex currently hovered (shows a red ✕; click removes it). −1 = none. */
|
|
98
|
+
private lassoHoverIdx;
|
|
99
|
+
/** Screen-pixel radius for hit-testing a hovered vertex. */
|
|
100
|
+
private static readonly LASSO_HIT_R;
|
|
101
|
+
/** Double-click detection (a dbl-click finishes the lasso). */
|
|
102
|
+
private lastLassoDownTime;
|
|
103
|
+
private lastLassoDownPos;
|
|
85
104
|
private dragging;
|
|
86
105
|
private dragStart;
|
|
87
106
|
private dragScreenStart;
|
|
88
107
|
private dragScreen;
|
|
89
108
|
private screenScribble;
|
|
90
109
|
private hoverScreen;
|
|
110
|
+
/** Hide the point seed markers once a prediction has painted (only the mask
|
|
111
|
+
* should remain). A new point click re-shows them until its mask returns. */
|
|
112
|
+
private hidePointMarkers;
|
|
91
113
|
/** Fired when a prompt gesture completes — app calls backend, then applyMask(). */
|
|
92
114
|
onPrompt: ((payload: AiPromptPayload) => void) | null;
|
|
115
|
+
/** Fired whenever the lasso vertex set changes (add/delete/undo/redo/finish/cancel),
|
|
116
|
+
* so the panel can reactively show the Finish button + vertex count. */
|
|
117
|
+
onLassoChange: ((count: number, editing: boolean) => void) | null;
|
|
93
118
|
constructor(ctx: ToolContext, host: AiAssistHostDeps);
|
|
94
119
|
setPromptTool(tool: AiPromptTool): void;
|
|
95
120
|
setPolarity(label: number): void;
|
|
96
121
|
setScribbleSize(size: number): void;
|
|
97
|
-
|
|
98
|
-
|
|
122
|
+
/** Select the active Segmentation by its label value (1-255). Switching starts a
|
|
123
|
+
* fresh prompt set — otherwise accumulated prompts would be re-predicted and
|
|
124
|
+
* repainted into the new label, recolouring the previous segmentation's region. */
|
|
125
|
+
setActiveSegment(label: number): void;
|
|
126
|
+
getActiveLabel(): number;
|
|
127
|
+
/** Set a Segmentation's colour (its label's entry in the scratch volume colorMap).
|
|
128
|
+
* The 2D overlay repaints next frame (copper3d's render loop re-reads the map). */
|
|
129
|
+
setSegmentColor(label: number, color: {
|
|
130
|
+
r: number;
|
|
131
|
+
g: number;
|
|
132
|
+
b: number;
|
|
133
|
+
a: number;
|
|
134
|
+
}): void;
|
|
135
|
+
/** "New segmentation": freeze the current regions (so they persist) and switch to
|
|
136
|
+
* a fresh label, exactly like the old "New region" but targeting a new label. */
|
|
137
|
+
newSegment(label: number): void;
|
|
138
|
+
/** Delete a Segmentation: erase every voxel painted with its label from BOTH the
|
|
139
|
+
* live scratch and the frozen (committed) volume, so the region disappears from
|
|
140
|
+
* the view (otherwise orphaned label voxels would render with the wrong colour).
|
|
141
|
+
* Goes via setRawData so the volume's version counter bumps (overlay repaints). */
|
|
142
|
+
clearSegment(label: number): void;
|
|
99
143
|
getScratchVolume(): MaskVolume | null;
|
|
100
144
|
/** Serialize the scratch volume as per-z-slice RLE (only NON-empty slices),
|
|
101
145
|
* for persisting to ai_generated_nii_LPS on the backend. Binary (any channel →
|
|
@@ -111,6 +155,22 @@ export declare class AiAssistTool extends BaseTool {
|
|
|
111
155
|
rle: number[];
|
|
112
156
|
}[];
|
|
113
157
|
} | null;
|
|
158
|
+
/** Per-SEGMENTATION serialization for the 3D build: one binary RLE per non-empty
|
|
159
|
+
* z-slice PER label (no binarize-merge), so the backend writes a multi-label
|
|
160
|
+
* NIfTI and colours the GLB per segmentation. Includes both live and frozen
|
|
161
|
+
* regions (both live in scratchVol). */
|
|
162
|
+
getScratchSegments(): {
|
|
163
|
+
axis: "z";
|
|
164
|
+
width: number;
|
|
165
|
+
height: number;
|
|
166
|
+
segments: {
|
|
167
|
+
label: number;
|
|
168
|
+
slices: {
|
|
169
|
+
sliceIndex: number;
|
|
170
|
+
rle: number[];
|
|
171
|
+
}[];
|
|
172
|
+
}[];
|
|
173
|
+
} | null;
|
|
114
174
|
/** Create (or reuse) the scratch volume sized to the layer grid and register
|
|
115
175
|
* it under maskData.volumes['aiScratch']. Snapshots the empty buffer. */
|
|
116
176
|
enter(): void;
|
|
@@ -126,21 +186,64 @@ export declare class AiAssistTool extends BaseTool {
|
|
|
126
186
|
/** Clear the in-progress prompt set (e.g. slice/axis change). Does NOT freeze —
|
|
127
187
|
* use commitRegion() for the "New region" action. */
|
|
128
188
|
resetPrompts(): void;
|
|
189
|
+
/** Drop the in-progress lasso vertices + undo/redo history (does not touch a
|
|
190
|
+
* prediction already painted from a finished lasso). */
|
|
191
|
+
private clearLassoEditing;
|
|
192
|
+
/** Tell the app layer the lasso vertex set changed (drives the Finish button). */
|
|
193
|
+
private notifyLasso;
|
|
129
194
|
/** Voxel-slice (width,height) for the current axis. */
|
|
130
195
|
private sliceDims;
|
|
131
196
|
/** Screen offset → voxel-slice (vx,vy) for the current axis. */
|
|
132
197
|
private toVoxel;
|
|
198
|
+
/** Voxel-slice (vx,vy) → screen offset (px). Exact inverse of toVoxel, so
|
|
199
|
+
* markers / lasso curves drawn from voxel coords track pan AND zoom each frame
|
|
200
|
+
* (the freehand previews store screen px directly; persistent overlays don't). */
|
|
201
|
+
private voxelToScreen;
|
|
133
202
|
onPointerDown(e: MouseEvent): void;
|
|
203
|
+
/** Lasso click: double-click finishes; click on a vertex deletes it; otherwise
|
|
204
|
+
* add a vertex. Nothing is sent to the backend until finishLasso(). */
|
|
205
|
+
private onLassoPointerDown;
|
|
134
206
|
onPointerMove(e: MouseEvent): void;
|
|
135
207
|
onPointerUp(_e: MouseEvent): void;
|
|
136
208
|
/** Reset the accumulated prompt set when the user scrubs to a new slice. */
|
|
137
209
|
private syncSlice;
|
|
138
210
|
private emit;
|
|
211
|
+
/** Index of the lasso vertex under (sx,sy) within the hit radius, else −1.
|
|
212
|
+
* Uses live voxel→screen so it tracks pan/zoom. Topmost (latest) wins. */
|
|
213
|
+
private lassoVertAt;
|
|
214
|
+
/** Snapshot the vertex list for undo (clears redo). */
|
|
215
|
+
private pushLassoUndo;
|
|
216
|
+
/** Public: undo the last add/delete of a lasso vertex (Ctrl+Z while editing). */
|
|
217
|
+
lassoUndoAction(): void;
|
|
218
|
+
/** Public: redo (Ctrl+Y / Ctrl+Shift+Z while editing). */
|
|
219
|
+
lassoRedoAction(): void;
|
|
220
|
+
/** Public: abandon the in-progress lasso (Esc). */
|
|
221
|
+
cancelLasso(): void;
|
|
222
|
+
/** Public: true while the user is placing lasso vertices (≥1 vertex). */
|
|
223
|
+
isLassoEditing(): boolean;
|
|
224
|
+
/** Public: number of placed lasso vertices (drives the Finish button label/enable). */
|
|
225
|
+
getLassoVertCount(): number;
|
|
226
|
+
/** Vertices ordered by polar angle around their centroid, so the closed curve is
|
|
227
|
+
* a SIMPLE (non-self-intersecting) loop regardless of click order — otherwise
|
|
228
|
+
* connecting points in click order + closing easily produces a bow-tie crossing.
|
|
229
|
+
* Trade-off: deep concavities collapse to their star-shaped hull, which is fine
|
|
230
|
+
* for a "rough loop around a blob". */
|
|
231
|
+
private orderedLassoVerts;
|
|
232
|
+
/** Public: close the curve, densify it, and send it to the backend as the lasso
|
|
233
|
+
* contour. Needs ≥3 vertices (a real area). Then clears the editing state. */
|
|
234
|
+
finishLasso(): void;
|
|
235
|
+
/** Sample a smooth CLOSED Catmull-Rom spline through `pts` → denser polyline.
|
|
236
|
+
* `segs` samples per control-point span. <3 pts → returns a copy unchanged. */
|
|
237
|
+
private sampleClosedSpline;
|
|
139
238
|
applyMask(result: AiMaskResult): void;
|
|
140
239
|
/** Merge one RLE-encoded predicted slice into the scratch volume at sliceIndex.
|
|
141
240
|
* Predicted pixels → current channel; stale current-channel pixels cleared
|
|
142
241
|
* UNLESS they belong to a frozen (committed) region; OTHER channels preserved. */
|
|
143
242
|
private applySliceRle;
|
|
144
243
|
renderOverlay(targetCtx: CanvasRenderingContext2D): void;
|
|
244
|
+
/** A seed marker (small filled dot + ring) for point prompts. */
|
|
245
|
+
private drawSeedMarker;
|
|
246
|
+
/** Render the lasso editing overlay (curve + fill + vertices + hover ✕). */
|
|
247
|
+
private renderLassoOverlay;
|
|
145
248
|
}
|
|
146
249
|
export {};
|