copper3d 3.6.2 → 3.6.4
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/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 +238 -129
- package/dist/bundle.umd.js +238 -129
- package/dist/index.d.ts +1 -1
- package/dist/index.js +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/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 +1 -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.4-beta";
|
|
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,7 @@ 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
|
-
export const REVISION = "v3.6.
|
|
25
|
+
export const REVISION = "v3.6.4-beta";
|
|
26
26
|
console.log(`%cCopper3D Visualisation %cBeta:${REVISION}`, "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
|
|
27
27
|
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
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -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
|
+
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,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
|
/**
|
|
@@ -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;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import type { AnnotationVertex, SurfaceHit } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* pointermove
|
|
6
|
-
*
|
|
4
|
+
* State machine for one stroke in mode A (freehand).
|
|
5
|
+
* On pointermove it keeps calling addSample; samples whose world distance from the previous
|
|
6
|
+
* sample is < minGap are dropped to avoid over-density.
|
|
7
|
+
* Vertices are stored in local space (the mesh converts the world hit point to local).
|
|
7
8
|
*/
|
|
8
9
|
export declare class StrokeContour {
|
|
9
10
|
private minGap;
|
|
@@ -14,9 +15,11 @@ export declare class StrokeContour {
|
|
|
14
15
|
private lastNormal;
|
|
15
16
|
private has;
|
|
16
17
|
/**
|
|
17
|
-
* @param minGap
|
|
18
|
-
* @param maxJump
|
|
19
|
-
*
|
|
18
|
+
* @param minGap minimum sample spacing (world space), debounce
|
|
19
|
+
* @param maxJump jump threshold (world space): drop the sample when distance > maxJump and the
|
|
20
|
+
* normal flips sharply, to prevent adjacent points landing at different depths
|
|
21
|
+
* (and the straight segment cutting through the model) when the stroke grazes a
|
|
22
|
+
* groove or contour edge.
|
|
20
23
|
*/
|
|
21
24
|
constructor(minGap: number, maxJump: number, mesh: THREE.Mesh);
|
|
22
25
|
begin(): void;
|
|
@@ -5,7 +5,7 @@ export interface SurfaceHit {
|
|
|
5
5
|
normal: THREE.Vector3;
|
|
6
6
|
faceIndex: number;
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
8
|
+
/** Annotation vertex: position and normal are both in **model local space** (single source of truth, unaffected by camera/placement). */
|
|
9
9
|
export interface AnnotationVertex {
|
|
10
10
|
x: number;
|
|
11
11
|
y: number;
|
|
@@ -26,14 +26,14 @@ export interface Annotation {
|
|
|
26
26
|
object3D: THREE.Object3D | null;
|
|
27
27
|
}
|
|
28
28
|
export interface ExportOptions {
|
|
29
|
-
/**
|
|
29
|
+
/** Export coordinate space, defaults to "local" (model space, reproducible and unaffected by camera/placement). */
|
|
30
30
|
space?: "local" | "world";
|
|
31
|
-
/**
|
|
31
|
+
/** Whether to attach a normal to each point [x,y,z,nx,ny,nz]. */
|
|
32
32
|
includeNormals?: boolean;
|
|
33
33
|
}
|
|
34
|
-
/**
|
|
34
|
+
/** World-space hit point → local vertex (position via worldToLocal, normal via inverse transform). */
|
|
35
35
|
export declare function worldHitToLocalVertex(h: SurfaceHit, mesh: THREE.Mesh): AnnotationVertex;
|
|
36
|
-
/**
|
|
36
|
+
/** Local vertex → world position + world normal (for rendering). */
|
|
37
37
|
export declare function localVertexToWorld(v: AnnotationVertex, mesh: THREE.Mesh): {
|
|
38
38
|
p: THREE.Vector3;
|
|
39
39
|
n: THREE.Vector3;
|
package/dist/types/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.4-beta";
|
|
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "copper3d",
|
|
3
3
|
"description": "A 3d visualisation package base on threejs provides multiple scenes and Nrrd image load funtion.",
|
|
4
|
-
"version": "3.6.
|
|
4
|
+
"version": "3.6.4",
|
|
5
5
|
"main": "dist/bundle.umd.js",
|
|
6
6
|
"moudle": "dist/bundle.esm.js",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|