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
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,6 @@ import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_
|
|
|
28
28
|
import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
|
|
29
29
|
import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from "./Utils/segmentation/tools/AiAssistTool";
|
|
30
30
|
import "./css/style.css";
|
|
31
|
-
export declare const REVISION = "v3.6.
|
|
31
|
+
export declare const REVISION = "v3.6.5";
|
|
32
32
|
export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, };
|
|
33
33
|
export type { positionType, screenPosType, optsType, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, LayerId, ChannelValue, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, };
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,14 @@ import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
|
|
|
22
22
|
import { SurfaceAnnotator } from "./Utils/surfaceAnnotation";
|
|
23
23
|
import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
|
|
24
24
|
import "./css/style.css";
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
// __REVISION__ is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version
|
|
26
|
+
export const REVISION = __REVISION__;
|
|
27
|
+
// Expose on global so the version can be read in a production browser console via window.__COPPER3D_VERSION__
|
|
28
|
+
if (typeof window !== "undefined") {
|
|
29
|
+
window.__COPPER3D_VERSION__ = REVISION;
|
|
30
|
+
}
|
|
31
|
+
if (typeof console !== "undefined") {
|
|
32
|
+
console.log(`%cCopper3D Visualisation %c${REVISION}`, "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
|
|
33
|
+
}
|
|
27
34
|
export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, };
|
|
28
35
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,W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AiC,CAAC;AAS1J,OAAO,iBAAiB,CAAC;AAEzB,6GAA6G;AAC7G,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAErC,8GAA8G;AAC9G,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAChC,MAAc,CAAC,oBAAoB,GAAG,QAAQ,CAAC;CACjD;AAED,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;IAClC,OAAO,CAAC,GAAG,CACT,8BAA8B,QAAQ,EAAE,EACxC,8CAA8C,EAC9C,8CAA8C,CAC/C,CAAC;CACH;AAED,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,SAAS,EACT,OAAO,EACP,yBAAyB,EACzB,oBAAoB,EACpB,YAAY,EACZ,QAAQ,EACR,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,gBAAgB,GACjB,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Color, DoubleSide, Mesh, PlaneGeometry, RawShaderMaterial, Vector2, } from "three";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
// Loaded as raw strings (?raw). The original copper3d build compiled these via
|
|
3
|
+
// rollup-plugin-glslify; this app has no GLSL/glslify handler, so importing them as modules
|
|
4
|
+
// makes Vite try to parse GLSL as JS ("Unexpected identifier 'vec3'") and the bundle dies.
|
|
5
|
+
// The vignette background is only built for non-alpha scenes and this app always uses
|
|
6
|
+
// alpha:true, so these shaders are never compiled/used — loading them as inert strings is
|
|
7
|
+
// enough to keep the module importable.
|
|
8
|
+
import vert from "./three-vignette.vert?raw";
|
|
9
|
+
import frag from "./three-vignette.frag?raw";
|
|
4
10
|
function createBackground(opt) {
|
|
5
11
|
opt = opt || {};
|
|
6
12
|
let geometry = opt.geometry || new PlaneGeometry(2, 2, 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"three-vignette.js","sourceRoot":"","sources":["../../src/lib/three-vignette.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,UAAU,EACV,IAAI,EACJ,aAAa,EACb,iBAAiB,EACjB,OAAO,GACR,MAAM,OAAO,CAAC;AAEf,OAAO,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"three-vignette.js","sourceRoot":"","sources":["../../src/lib/three-vignette.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,UAAU,EACV,IAAI,EACJ,aAAa,EACb,iBAAiB,EACjB,OAAO,GACR,MAAM,OAAO,CAAC;AAEf,+EAA+E;AAC/E,4FAA4F;AAC5F,2FAA2F;AAC3F,sFAAsF;AACtF,0FAA0F;AAC1F,wCAAwC;AACxC,OAAO,IAAI,MAAM,2BAA2B,CAAC;AAC7C,OAAO,IAAI,MAAM,2BAA2B,CAAC;AAU7C,SAAS,gBAAgB,CAAC,GAAa;IACrC,GAAG,GAAG,GAAG,IAAI,EAAE,CAAC;IAChB,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAI,IAAI,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1D,IAAI,QAAQ,GAAG,IAAI,iBAAiB,CAAC;QACnC,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,IAAI;QACpB,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,gBAAgB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;YAClC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE;YACpB,UAAU,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;YAC5B,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE;YACvB,UAAU,EAAE,EAA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,KAAK,QAAQ,EAAE;gBAC7B,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;aAC7B;YACD,IAAI,SAAS,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;YACtC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC/C;QACD,IAAI,OAAO,GAAG,CAAC,gBAAgB,KAAK,WAAW,EAAE;YAC/C,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;SAC1E;IACH,CAAC,CAAC;IACF,SAAS,SAAS,CAAC,KAAY;QAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACxB,OAAO,IAAI,OAAO,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;SACvC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,GAAG,EAAE;QACP,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACvB;SAAM;QACL,UAAU,CAAC,KAAK,EAAE,CAAC;KACpB;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -24,13 +24,13 @@ export declare class copperScene extends baseScene {
|
|
|
24
24
|
}): void;
|
|
25
25
|
loadVtk(url: string): void;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
* target
|
|
29
|
-
*
|
|
27
|
+
* Create an annotator on the surface of a given model (draw contours / place points / export coordinates).
|
|
28
|
+
* target can be a single Mesh, or a Group/Object3D (the mesh with the most vertices is chosen automatically).
|
|
29
|
+
* Reuses this scene's camera / container / controls; non-indexed geometry is welded and indexed automatically.
|
|
30
30
|
*/
|
|
31
31
|
createSurfaceAnnotator(target: THREE.Mesh | THREE.Object3D, opts?: Omit<SurfaceAnnotatorOptions, "scene" | "camera" | "container" | "controls" | "mesh">): SurfaceAnnotator;
|
|
32
32
|
private pickAnnotatableMesh;
|
|
33
|
-
/**
|
|
33
|
+
/** Dispose all annotators created on this scene (removes event listeners and annotation objects). */
|
|
34
34
|
disposeSurfaceAnnotators(): void;
|
|
35
35
|
loadVtks(models: Array<vtkModels>): void;
|
|
36
36
|
/**
|
|
@@ -210,16 +210,41 @@ export declare class NrrdTools {
|
|
|
210
210
|
exitAiAssistMode(): void;
|
|
211
211
|
aiSetPromptTool(tool: AiPromptTool): void;
|
|
212
212
|
aiSetPolarity(label: number): void;
|
|
213
|
-
/**
|
|
214
|
-
|
|
213
|
+
/** Select the active Segmentation by its label value (the AI paints into it). */
|
|
214
|
+
aiSetActiveSegment(label: number): void;
|
|
215
|
+
/** Set a Segmentation's colour (its label's colorMap entry; 2D overlay repaints). */
|
|
216
|
+
aiSetSegmentColor(label: number, color: {
|
|
217
|
+
r: number;
|
|
218
|
+
g: number;
|
|
219
|
+
b: number;
|
|
220
|
+
a: number;
|
|
221
|
+
}): void;
|
|
222
|
+
/** "New segmentation": freeze current regions + switch to a new label. */
|
|
223
|
+
aiNewSegment(label: number): void;
|
|
224
|
+
/** Delete a Segmentation: erase all its label's voxels from scratch + committed. */
|
|
225
|
+
aiClearSegment(label: number): void;
|
|
215
226
|
/** Set the scribble brush radius (px). */
|
|
216
227
|
aiSetScribbleSize(size: number): void;
|
|
217
228
|
/** Register the callback invoked when a prompt gesture completes (app → backend). */
|
|
218
229
|
aiOnPrompt(cb: (payload: AiPromptPayload) => void): void;
|
|
230
|
+
/** Register the callback fired when the lasso vertex set changes (drives the Finish button). */
|
|
231
|
+
aiOnLassoChange(cb: (count: number, editing: boolean) => void): void;
|
|
219
232
|
/** Apply a backend mask result into the scratch volume (overlay repaints next frame). */
|
|
220
233
|
aiApplyMask(result: AiMaskResult): void;
|
|
221
234
|
/** Clear the in-progress prompt set (e.g. slice change). */
|
|
222
235
|
aiClearPrompts(): void;
|
|
236
|
+
/** Close + send the in-progress lasso to the backend (needs ≥3 vertices). */
|
|
237
|
+
aiFinishLasso(): void;
|
|
238
|
+
/** Undo the last lasso vertex add/delete. */
|
|
239
|
+
aiLassoUndo(): void;
|
|
240
|
+
/** Redo the last undone lasso vertex change. */
|
|
241
|
+
aiLassoRedo(): void;
|
|
242
|
+
/** Abandon the in-progress lasso (Esc). */
|
|
243
|
+
aiCancelLasso(): void;
|
|
244
|
+
/** True while the user is placing lasso vertices. */
|
|
245
|
+
aiIsLassoEditing(): boolean;
|
|
246
|
+
/** Number of placed lasso vertices (drives the Finish button). */
|
|
247
|
+
aiLassoVertCount(): number;
|
|
223
248
|
/** "New region": freeze current regions (they persist) + start a fresh prompt set. */
|
|
224
249
|
aiCommitRegion(): void;
|
|
225
250
|
/** Discard all AI scratch painting since enter (sandbox discard). */
|
|
@@ -236,6 +261,20 @@ export declare class NrrdTools {
|
|
|
236
261
|
rle: number[];
|
|
237
262
|
}[];
|
|
238
263
|
} | null;
|
|
264
|
+
/** Per-segmentation serialization (one binary RLE per label per z-slice) for the
|
|
265
|
+
* multi-label / per-colour 3D build. */
|
|
266
|
+
aiGetScratchSegments(): {
|
|
267
|
+
axis: "z";
|
|
268
|
+
width: number;
|
|
269
|
+
height: number;
|
|
270
|
+
segments: {
|
|
271
|
+
label: number;
|
|
272
|
+
slices: {
|
|
273
|
+
sliceIndex: number;
|
|
274
|
+
rle: number[];
|
|
275
|
+
}[];
|
|
276
|
+
}[];
|
|
277
|
+
} | null;
|
|
239
278
|
/**
|
|
240
279
|
* Merge the AI scratch into a target layer as a single undoable group (sandbox
|
|
241
280
|
* merge — best-practice: non-destructive + one Ctrl+Z). The scratch's channel
|
|
@@ -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 {};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Build a vertex adjacency graph from a BufferGeometry's index, used for the shortest path in
|
|
4
|
+
* mode B (geodesic). Vertex coordinates are stored in local space; query points must be converted
|
|
5
|
+
* to local first (mesh.worldToLocal).
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* Note: the geometry must be indexed. modelLoader welds duplicate vertices with mergeVertices so
|
|
8
|
+
* that vertices at the same surface position are shared, otherwise the adjacency graph won't be connected.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
10
|
+
* Performance: O(V²) Dijkstra + O(V) nearest-vertex lookup. Acceptable for a single click on tens
|
|
11
|
+
* of thousands of vertices; if too large it can later be sped up with a binary heap + spatial grid
|
|
12
|
+
* (left as a future upgrade).
|
|
11
13
|
*/
|
|
12
14
|
export declare class MeshGraph {
|
|
13
15
|
private positions;
|
|
@@ -18,16 +20,16 @@ export declare class MeshGraph {
|
|
|
18
20
|
private px;
|
|
19
21
|
private py;
|
|
20
22
|
private pz;
|
|
21
|
-
/**
|
|
23
|
+
/** Nearest vertex (pass in local coordinates). */
|
|
22
24
|
nearestVertex(localPoint: THREE.Vector3): number;
|
|
23
25
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
+
* Shortest path between two vertices (sequence of vertex indices including endpoints).
|
|
27
|
+
* Binary-heap Dijkstra, O(E log V). Falls back to [start,end] when disconnected.
|
|
26
28
|
*/
|
|
27
29
|
shortestPath(startV: number, endV: number): number[];
|
|
28
30
|
vertexWorld(i: number, matrixWorld: THREE.Matrix4): THREE.Vector3;
|
|
29
31
|
vertexNormalWorld(i: number, mesh: THREE.Mesh): THREE.Vector3;
|
|
30
|
-
/**
|
|
32
|
+
/** Vertex local coordinates + local normal (the graph geometry is already local space). */
|
|
31
33
|
vertexLocal(i: number): {
|
|
32
34
|
x: number;
|
|
33
35
|
y: number;
|
|
@@ -9,26 +9,34 @@ export interface SurfaceAnnotatorOptions {
|
|
|
9
9
|
enabled: boolean;
|
|
10
10
|
};
|
|
11
11
|
mesh: THREE.Mesh;
|
|
12
|
-
/**
|
|
12
|
+
/** Computed from the mesh geometry's bounding-box diagonal when omitted. */
|
|
13
13
|
bboxDiagonal?: number;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Outward offset of the annotation line from the surface (world units), defaults to bboxDiagonal*0.002.
|
|
16
|
+
* Providing it separately decouples it from the sampling spacing (minGap/maxJump, still derived from
|
|
17
|
+
* bboxDiagonal) — useful on bumpy/voxel surfaces where a larger offset is needed to float the line
|
|
18
|
+
* above the relief without also coarsening the sampling.
|
|
19
|
+
*/
|
|
20
|
+
epsilon?: number;
|
|
21
|
+
/** Freehand contour color, defaults to #e5006e. */
|
|
15
22
|
freehandColor?: string;
|
|
16
|
-
/**
|
|
23
|
+
/** Geodesic contour color, defaults to #ffa24e. */
|
|
17
24
|
geodesicColor?: string;
|
|
18
|
-
/**
|
|
25
|
+
/** Point-marker color, defaults to #ffd166. */
|
|
19
26
|
pointColor?: string;
|
|
20
|
-
/**
|
|
27
|
+
/** Line width (pixels), defaults to 3. */
|
|
21
28
|
lineWidth?: number;
|
|
22
|
-
/**
|
|
29
|
+
/** Marker sphere radius, defaults to bboxDiagonal*0.006. */
|
|
23
30
|
markerRadius?: number;
|
|
24
31
|
onModeChange?: (m: AnnotationMode) => void;
|
|
25
|
-
/**
|
|
32
|
+
/** Callback when the annotation list changes (add/remove/undo/clear). */
|
|
26
33
|
onChange?: (annotations: Annotation[]) => void;
|
|
27
34
|
}
|
|
28
35
|
/**
|
|
29
|
-
*
|
|
30
|
-
* Enter
|
|
31
|
-
*
|
|
36
|
+
* Main surface-annotation controller (Phase 4): four modes navigate / freehand / geodesic / point,
|
|
37
|
+
* Enter closes the loop, and data is managed by AnnotationStore (multiple color-labeled strips,
|
|
38
|
+
* undo/delete/clear, export).
|
|
39
|
+
* The render layer reconciles the scene against store.list(); undo/delete automatically add/remove three objects.
|
|
32
40
|
*/
|
|
33
41
|
export declare class SurfaceAnnotator {
|
|
34
42
|
private o;
|
|
@@ -56,7 +64,7 @@ export declare class SurfaceAnnotator {
|
|
|
56
64
|
private hoveredGeoMarker;
|
|
57
65
|
private _projV;
|
|
58
66
|
constructor(opts: SurfaceAnnotatorOptions);
|
|
59
|
-
/**
|
|
67
|
+
/** Update the pixel resolution of all fat lines on window resize, otherwise line width distorts. */
|
|
60
68
|
private onResize;
|
|
61
69
|
private get freehandColor();
|
|
62
70
|
private get geodesicColor();
|
|
@@ -64,13 +72,13 @@ export declare class SurfaceAnnotator {
|
|
|
64
72
|
getMode(): AnnotationMode;
|
|
65
73
|
setMode(m: AnnotationMode): void;
|
|
66
74
|
getStore(): AnnotationStore;
|
|
67
|
-
/**
|
|
75
|
+
/** Snapshot of the current annotation list. */
|
|
68
76
|
getAnnotations(): Annotation[];
|
|
69
77
|
undo(): void;
|
|
70
78
|
clearAll(): void;
|
|
71
79
|
deleteAnnotation(id: string): void;
|
|
72
80
|
selectAnnotation(id: string | null): void;
|
|
73
|
-
/**
|
|
81
|
+
/** Redraw the corresponding three object after a color change. */
|
|
74
82
|
refreshAnnotation(id: string): void;
|
|
75
83
|
exportJSON(modelName: string, opts?: ExportOptions): {
|
|
76
84
|
model: string;
|
|
@@ -87,42 +95,54 @@ export declare class SurfaceAnnotator {
|
|
|
87
95
|
}[];
|
|
88
96
|
};
|
|
89
97
|
private applyCameraGating;
|
|
90
|
-
/**
|
|
98
|
+
/** Reconcile the scene against store.list(): add missing objects, remove deleted ones (no dispose, kept for undo restore). */
|
|
91
99
|
private reconcile;
|
|
92
100
|
private applySelection;
|
|
93
101
|
private disposeObject;
|
|
94
102
|
private nextId;
|
|
95
103
|
private hit;
|
|
96
104
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
105
|
+
* Whether the event target is the WebGL canvas inside the container.
|
|
106
|
+
* Only accept the canvas: panels (GUIDE / control panel / the ✕ buttons in the annotation list)
|
|
107
|
+
* are all children of the container, so checking contains alone would treat clicks on the panels
|
|
108
|
+
* as drawing on the model — which "leaks through" the delete buttons and makes ✕ hard to click.
|
|
109
|
+
* Responding only to pointer events on the canvas fully isolates the UI from the drawing surface.
|
|
101
110
|
*/
|
|
102
111
|
private insideContainer;
|
|
103
112
|
private onPointerDown;
|
|
104
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Pick an in-progress anchor: return the index of the nearest anchor (screen pixel distance <
|
|
115
|
+
* tolerance), or -1 on a miss.
|
|
116
|
+
*
|
|
117
|
+
* Uses "screen-space pixel distance" instead of ray/sphere intersection: the anchor spheres are
|
|
118
|
+
* tiny, so strict ray/sphere hits require pixel-perfect aiming and most clicks miss — and a miss
|
|
119
|
+
* falls through to the "add anchor" branch, so trying to delete a point ends up adding one. That
|
|
120
|
+
* was the root cause of the old "deleting a point takes several clicks, must hit the sphere dead
|
|
121
|
+
* center" problem. Projecting each anchor to the screen and taking the nearest within tolerance
|
|
122
|
+
* makes deletion stable and reliable. The tolerance is enlarged relative to the sphere's screen
|
|
123
|
+
* radius to make it easy to hit.
|
|
124
|
+
*/
|
|
105
125
|
private pickGeoMarker;
|
|
106
|
-
/**
|
|
126
|
+
/** Set the currently hovered anchor (-1 = none): update highlight scale, cursor, and the "✕ (cancel)" floating badge. */
|
|
107
127
|
private setGeoHover;
|
|
108
|
-
/**
|
|
128
|
+
/** Lazily create the floating ✕ badge (appended inside the container, pointer-events:none so it doesn't block clicks). */
|
|
109
129
|
private ensureGeoBadge;
|
|
110
|
-
/**
|
|
130
|
+
/** Position the ✕ badge at the anchor's screen projection (dead center, i.e. where the cursor hovers, to avoid ambiguity). */
|
|
111
131
|
private positionGeoBadge;
|
|
112
|
-
/**
|
|
132
|
+
/** Rebuild the visible anchor spheres from the current anchors (slightly larger than placed points, so they're easy to see and click to cancel). */
|
|
113
133
|
private rebuildGeoMarkers;
|
|
114
|
-
/**
|
|
134
|
+
/** Redraw the in-progress geodesic from the current anchors (not closed); remove the line when fewer than two points. */
|
|
115
135
|
private redrawGeoLine;
|
|
116
|
-
/**
|
|
136
|
+
/** Discard the in-progress geodesic: remove and dispose the line and all anchors. */
|
|
117
137
|
private clearActiveGeo;
|
|
118
|
-
/**
|
|
138
|
+
/** Remove all anchor spheres of the in-progress geodesic (called after committing: only the line remains). */
|
|
119
139
|
private removeGeoMarkers;
|
|
120
140
|
private onPointerMove;
|
|
121
141
|
private onPointerUp;
|
|
122
142
|
private closeLastContour;
|
|
123
|
-
/**
|
|
143
|
+
/** Compute the geodesic path a→b along the mesh surface (local vertices), dropping the first point that coincides with a. a/b are already local. */
|
|
124
144
|
private surfacePathBetween;
|
|
125
|
-
/**
|
|
145
|
+
/** Finish the current geodesic: close it into a ring and commit it as one contour. */
|
|
126
146
|
private finishGeodesic;
|
|
127
147
|
private isTypingTarget;
|
|
128
148
|
private onKeyDown;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import type { Annotation, ExportOptions } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Annotation data model + undo stack + export. Pure data, no three / DOM dependencies.
|
|
5
|
+
* Undo only records two atomic operations, add / remove (enough for "undo last add / restore delete").
|
|
6
|
+
* Notifies the UI and render layer via subscribe (the latter reconciles the scene against list()).
|
|
7
7
|
*/
|
|
8
8
|
export declare class AnnotationStore {
|
|
9
9
|
private items;
|
|
@@ -14,7 +14,7 @@ export declare class AnnotationStore {
|
|
|
14
14
|
add(a: Annotation): void;
|
|
15
15
|
remove(id: string): Annotation | undefined;
|
|
16
16
|
undo(): void;
|
|
17
|
-
/**
|
|
17
|
+
/** Clear all, returning the removed items (so the render layer can dispose three objects). */
|
|
18
18
|
clear(): Annotation[];
|
|
19
19
|
list(): Annotation[];
|
|
20
20
|
get(id: string): Annotation | undefined;
|
|
@@ -3,5 +3,5 @@ import { Line2 } from "three/examples/jsm/lines/Line2";
|
|
|
3
3
|
import type { AnnotationVertex } from "./types";
|
|
4
4
|
export declare function makeContourLine(verts: AnnotationVertex[], color: string, closed: boolean, container: HTMLElement, epsilon: number, mesh: THREE.Mesh): Line2;
|
|
5
5
|
export declare function updateContourLine(line: Line2, verts: AnnotationVertex[], closed: boolean, epsilon: number, mesh: THREE.Mesh): void;
|
|
6
|
-
/**
|
|
6
|
+
/** Change the color of an existing contour line. */
|
|
7
7
|
export declare function setContourColor(line: Line2, color: string): void;
|
|
@@ -2,8 +2,9 @@ import * as THREE from "three";
|
|
|
2
2
|
import type { AnnotationVertex } from "./types";
|
|
3
3
|
import { MeshGraph } from "./MeshGraph";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* State machine for mode B (geodesic): click anchors one by one, find the shortest path between
|
|
6
|
+
* adjacent anchors with MeshGraph, and stitch them into a polyline that hugs the surface.
|
|
7
|
+
* Enter finishes and can close the loop (computing one more segment between first and last).
|
|
7
8
|
*/
|
|
8
9
|
export declare class GeodesicContour {
|
|
9
10
|
private graph;
|
|
@@ -12,21 +13,21 @@ export declare class GeodesicContour {
|
|
|
12
13
|
private segments;
|
|
13
14
|
private history;
|
|
14
15
|
constructor(graph: MeshGraph, mesh: THREE.Mesh);
|
|
15
|
-
/**
|
|
16
|
+
/** Save a snapshot before any anchor change (the vertex-index array is tiny, so snapshot cost is negligible). */
|
|
16
17
|
private snapshot;
|
|
17
|
-
/**
|
|
18
|
+
/** Given a local hit point, snap to the nearest vertex and compute the path to the previous anchor. */
|
|
18
19
|
addAnchor(localHitPoint: THREE.Vector3): void;
|
|
19
|
-
/**
|
|
20
|
+
/** Remove the anchor at the given index and recompute adjacent segments (allows canceling any middle point). */
|
|
20
21
|
removeAnchorAt(index: number): void;
|
|
21
|
-
/**
|
|
22
|
+
/** Whether there is still an editable change to undo (add/remove point). */
|
|
22
23
|
canUndo(): boolean;
|
|
23
|
-
/**
|
|
24
|
+
/** Undo the last anchor edit (add → remove it; remove → restore it). Returns false when no history. */
|
|
24
25
|
undoEdit(): boolean;
|
|
25
|
-
/**
|
|
26
|
+
/** Recompute all adjacent-segment paths from the current anchor sequence. */
|
|
26
27
|
private rebuildSegments;
|
|
27
|
-
/**
|
|
28
|
+
/** Local vertex of each anchor (used to draw visible anchor markers). */
|
|
28
29
|
getAnchorLocals(): AnnotationVertex[];
|
|
29
30
|
get anchorCount(): number;
|
|
30
|
-
/**
|
|
31
|
+
/** Stitch all path vertices (world) + normals into a polyline; when closed, add one first-to-last segment. */
|
|
31
32
|
buildVertices(closed: boolean): AnnotationVertex[];
|
|
32
33
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import type { AnnotationVertex } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Create a marker sphere (fiducial) at a local vertex. After local→world, nudge it
|
|
5
|
+
* outward along the world normal so it doesn't sink halfway into the surface.
|
|
6
|
+
* radius is passed in by the caller, scaled to the model bbox.
|
|
6
7
|
*/
|
|
7
8
|
export declare function makePointMarker(v: AnnotationVertex, mesh: THREE.Mesh, color: string, radius: number): THREE.Mesh;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import type { SurfaceHit } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Project screen coordinates (clientX/Y) onto the mesh surface, returning the hit point,
|
|
5
|
+
* world-space normal, and faceIndex. Returns null on a miss. Local implementation that does not
|
|
6
|
+
* depend on Copper3D's unexported raycast internals.
|
|
6
7
|
*/
|
|
7
8
|
export declare function raycastSurface(camera: THREE.PerspectiveCamera, container: HTMLElement, mesh: THREE.Mesh, clientX: number, clientY: number): SurfaceHit | null;
|