copper3d 3.5.0 → 3.6.0

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.
Files changed (51) hide show
  1. package/dist/Scene/copperScene.d.ts +12 -0
  2. package/dist/Scene/copperScene.js +38 -44
  3. package/dist/Scene/copperScene.js.map +1 -1
  4. package/dist/Utils/surfaceAnnotation/MeshGraph.d.ts +40 -0
  5. package/dist/Utils/surfaceAnnotation/MeshGraph.js +198 -0
  6. package/dist/Utils/surfaceAnnotation/MeshGraph.js.map +1 -0
  7. package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.d.ts +103 -0
  8. package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.js +402 -0
  9. package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.js.map +1 -0
  10. package/dist/Utils/surfaceAnnotation/annotationStore.d.ts +37 -0
  11. package/dist/Utils/surfaceAnnotation/annotationStore.js +105 -0
  12. package/dist/Utils/surfaceAnnotation/annotationStore.js.map +1 -0
  13. package/dist/Utils/surfaceAnnotation/contourRender.d.ts +7 -0
  14. package/dist/Utils/surfaceAnnotation/contourRender.js +57 -0
  15. package/dist/Utils/surfaceAnnotation/contourRender.js.map +1 -0
  16. package/dist/Utils/surfaceAnnotation/geodesicContour.d.ts +19 -0
  17. package/dist/Utils/surfaceAnnotation/geodesicContour.js +43 -0
  18. package/dist/Utils/surfaceAnnotation/geodesicContour.js.map +1 -0
  19. package/dist/Utils/surfaceAnnotation/index.d.ts +3 -0
  20. package/dist/Utils/surfaceAnnotation/index.js +2 -0
  21. package/dist/Utils/surfaceAnnotation/index.js.map +1 -0
  22. package/dist/Utils/surfaceAnnotation/pointMarkers.d.ts +7 -0
  23. package/dist/Utils/surfaceAnnotation/pointMarkers.js +16 -0
  24. package/dist/Utils/surfaceAnnotation/pointMarkers.js.map +1 -0
  25. package/dist/Utils/surfaceAnnotation/raycastSurface.d.ts +7 -0
  26. package/dist/Utils/surfaceAnnotation/raycastSurface.js +27 -0
  27. package/dist/Utils/surfaceAnnotation/raycastSurface.js.map +1 -0
  28. package/dist/Utils/surfaceAnnotation/strokeContour.d.ts +19 -0
  29. package/dist/Utils/surfaceAnnotation/strokeContour.js +35 -0
  30. package/dist/Utils/surfaceAnnotation/strokeContour.js.map +1 -0
  31. package/dist/Utils/surfaceAnnotation/types.d.ts +40 -0
  32. package/dist/Utils/surfaceAnnotation/types.js +26 -0
  33. package/dist/Utils/surfaceAnnotation/types.js.map +1 -0
  34. package/dist/bundle.esm.js +2867 -79
  35. package/dist/bundle.umd.js +2867 -78
  36. package/dist/index.d.ts +5 -3
  37. package/dist/index.js +3 -2
  38. package/dist/index.js.map +1 -1
  39. package/dist/types/Scene/copperScene.d.ts +12 -0
  40. package/dist/types/Utils/surfaceAnnotation/MeshGraph.d.ts +40 -0
  41. package/dist/types/Utils/surfaceAnnotation/SurfaceAnnotator.d.ts +103 -0
  42. package/dist/types/Utils/surfaceAnnotation/annotationStore.d.ts +37 -0
  43. package/dist/types/Utils/surfaceAnnotation/contourRender.d.ts +7 -0
  44. package/dist/types/Utils/surfaceAnnotation/geodesicContour.d.ts +19 -0
  45. package/dist/types/Utils/surfaceAnnotation/index.d.ts +3 -0
  46. package/dist/types/Utils/surfaceAnnotation/pointMarkers.d.ts +7 -0
  47. package/dist/types/Utils/surfaceAnnotation/raycastSurface.d.ts +7 -0
  48. package/dist/types/Utils/surfaceAnnotation/strokeContour.d.ts +19 -0
  49. package/dist/types/Utils/surfaceAnnotation/types.d.ts +40 -0
  50. package/dist/types/index.d.ts +5 -3
  51. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -17,6 +17,8 @@ import { GaussianSmoother } from "./Utils/segmentation/core/GaussianSmoother";
17
17
  import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls";
18
18
  import { MeshNodeTool } from "./Utils/MeshNodeTool";
19
19
  import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
20
+ import { SurfaceAnnotator } from "./Utils/surfaceAnnotation";
21
+ import type { SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions } from "./Utils/surfaceAnnotation";
20
22
  import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController } from "./types/types";
21
23
  import { IPaintImage, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, IGuiMeta } from "./Utils/segmentation/core/types";
22
24
  import { NrrdState } from "./Utils/segmentation/coreTools/NrrdState";
@@ -26,6 +28,6 @@ import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_
26
28
  import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
27
29
  import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from "./Utils/segmentation/tools/AiAssistTool";
28
30
  import "./css/style.css";
29
- export declare const REVISION = "v3.5.0-beta";
30
- 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, };
31
- 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, };
31
+ export declare const REVISION = "v3.6.0-beta";
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
+ 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
@@ -19,9 +19,10 @@ import { GaussianSmoother } from "./Utils/segmentation/core/GaussianSmoother";
19
19
  import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls";
20
20
  import { MeshNodeTool } from "./Utils/MeshNodeTool";
21
21
  import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
22
+ import { SurfaceAnnotator } from "./Utils/surfaceAnnotation";
22
23
  import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
23
24
  import "./css/style.css";
24
- export const REVISION = "v3.5.0-beta";
25
+ export const REVISION = "v3.6.0-beta";
25
26
  console.log(`%cCopper3D Visualisation %cBeta:${REVISION}`, "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
26
- 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, };
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, };
27
28
  //# 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,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,eAAe,E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9E,iDAAiD;AAEjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AA0B7D,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAS1J,OAAO,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,QAAQ,GAAG,aAAa,CAAC;AAEtC,OAAO,CAAC,GAAG,CACT,mCAAmC,QAAQ,EAAE,EAC7C,8CAA8C,EAC9C,8CAA8C,CAC/C,CAAC;AAEF,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"}
@@ -6,6 +6,8 @@ import { baseScene } from "./baseScene";
6
6
  import { vtkModels } from "../types/types";
7
7
  import { TrackballControls } from "three/examples/jsm/controls/TrackballControls";
8
8
  import { ICopperSceneOpts, aligned4DOptsType, Aligned4DController } from "../types/types";
9
+ import { SurfaceAnnotator } from "../Utils/surfaceAnnotation";
10
+ import type { SurfaceAnnotatorOptions } from "../Utils/surfaceAnnotation";
9
11
  export declare class copperScene extends baseScene {
10
12
  clock: THREE.Clock;
11
13
  controls: Copper3dTrackballControls | OrbitControls | TrackballControls;
@@ -13,6 +15,7 @@ export declare class copperScene extends baseScene {
13
15
  private playRate;
14
16
  private modelReady;
15
17
  private clipAction;
18
+ private surfaceAnnotators;
16
19
  constructor(container: HTMLDivElement, renderer: THREE.WebGLRenderer, opt?: ICopperSceneOpts);
17
20
  loadGltf(url: string, callback?: (content: THREE.Group) => void): void;
18
21
  loadPureGLB(url: string, callback?: (mesh: THREE.Group) => void, opts?: {
@@ -20,6 +23,15 @@ export declare class copperScene extends baseScene {
20
23
  enhanceMaterial?: boolean;
21
24
  }): void;
22
25
  loadVtk(url: string): void;
26
+ /**
27
+ * 在给定模型表面创建标注器(画 contour / 放点 / 导出坐标)。
28
+ * target 可为单个 Mesh,或 Group/Object3D(自动选顶点数最多的 mesh)。
29
+ * 复用本 scene 的 camera / container / controls;几何非索引时内部自动焊接索引化。
30
+ */
31
+ createSurfaceAnnotator(target: THREE.Mesh | THREE.Object3D, opts?: Omit<SurfaceAnnotatorOptions, "scene" | "camera" | "container" | "controls" | "mesh">): SurfaceAnnotator;
32
+ private pickAnnotatableMesh;
33
+ /** 释放本 scene 创建的所有标注器(移除事件监听与标注对象)。 */
34
+ disposeSurfaceAnnotators(): void;
23
35
  loadVtks(models: Array<vtkModels>): void;
24
36
  /**
25
37
  * Load an aligned 4D scene: a cine MRI (one slice, N cardiac phases) rendered as a
@@ -0,0 +1,40 @@
1
+ import * as THREE from "three";
2
+ /**
3
+ * 从 BufferGeometry 的索引构建顶点邻接图,用于模式 B(测地线)的最短路径。
4
+ * 顶点坐标按 local 存;传入的查询点需先转为 local(mesh.worldToLocal)。
5
+ *
6
+ * 说明:几何须为已索引(indexed)。modelLoader 用 mergeVertices 焊接重复顶点,
7
+ * 保证同一表面位置共享顶点,邻接图才连通。
8
+ *
9
+ * 性能:O(V²) Dijkstra + O(V) 最近顶点查找。对几万顶点单次点击可接受;
10
+ * 若过大可后续换二叉堆 + 空间网格加速(留作升级)。
11
+ */
12
+ export declare class MeshGraph {
13
+ private positions;
14
+ private normals;
15
+ private adj;
16
+ readonly vertexCount: number;
17
+ constructor(geometry: THREE.BufferGeometry);
18
+ private px;
19
+ private py;
20
+ private pz;
21
+ /** 最近顶点(传入 local 坐标)。 */
22
+ nearestVertex(localPoint: THREE.Vector3): number;
23
+ /**
24
+ * 两顶点间最短路径(含端点的顶点索引序列)。二叉堆 Dijkstra,O(E log V)。
25
+ * 不连通时返回 [start,end] 兜底。
26
+ */
27
+ shortestPath(startV: number, endV: number): number[];
28
+ vertexWorld(i: number, matrixWorld: THREE.Matrix4): THREE.Vector3;
29
+ vertexNormalWorld(i: number, mesh: THREE.Mesh): THREE.Vector3;
30
+ /** 顶点的 local 坐标 + local 法线(图几何即 local 空间)。 */
31
+ vertexLocal(i: number): {
32
+ x: number;
33
+ y: number;
34
+ z: number;
35
+ nx: number;
36
+ ny: number;
37
+ nz: number;
38
+ faceIndex: number;
39
+ };
40
+ }
@@ -0,0 +1,103 @@
1
+ import * as THREE from "three";
2
+ import type { Annotation, AnnotationMode, ExportOptions } from "./types";
3
+ import { AnnotationStore } from "./annotationStore";
4
+ export interface SurfaceAnnotatorOptions {
5
+ scene: THREE.Scene;
6
+ camera: THREE.PerspectiveCamera;
7
+ container: HTMLElement;
8
+ controls: {
9
+ enabled: boolean;
10
+ };
11
+ mesh: THREE.Mesh;
12
+ /** 缺省时从 mesh 几何包围盒对角线自算。 */
13
+ bboxDiagonal?: number;
14
+ /** 自由手绘 contour 颜色,默认 #e5006e。 */
15
+ freehandColor?: string;
16
+ /** 测地线 contour 颜色,默认 #ffa24e。 */
17
+ geodesicColor?: string;
18
+ /** 放点标记颜色,默认 #ffd166。 */
19
+ pointColor?: string;
20
+ /** 线宽(像素),默认 3。 */
21
+ lineWidth?: number;
22
+ /** 标记小球半径,默认 bboxDiagonal*0.006。 */
23
+ markerRadius?: number;
24
+ onModeChange?: (m: AnnotationMode) => void;
25
+ /** 标注列表变化回调(增删/撤销/清空)。 */
26
+ onChange?: (annotations: Annotation[]) => void;
27
+ }
28
+ /**
29
+ * 表面标注主控制器(Phase 4):navigate / freehand / geodesic / point 四模式,
30
+ * Enter 闭合,数据交给 AnnotationStore 管理(多条带颜色标签、撤销/删除/清空、导出)。
31
+ * 渲染层据 store.list() 做场景对账(reconcile),撤销/删除自动加/移 three 对象。
32
+ */
33
+ export declare class SurfaceAnnotator {
34
+ private o;
35
+ private mode;
36
+ private spaceHeld;
37
+ private pointerDown;
38
+ private readonly markerRadius;
39
+ private readonly epsilon;
40
+ private readonly minGap;
41
+ private graph;
42
+ private store;
43
+ private managed;
44
+ private seq;
45
+ private selectedId;
46
+ private activeStroke?;
47
+ private activeLine?;
48
+ private lastFreehand?;
49
+ private activeGeo?;
50
+ private activeGeoLine?;
51
+ constructor(opts: SurfaceAnnotatorOptions);
52
+ /** 窗口尺寸变化时更新所有 fat line 的像素分辨率,否则线宽会失真。 */
53
+ private onResize;
54
+ private get freehandColor();
55
+ private get geodesicColor();
56
+ private get pointColorVal();
57
+ getMode(): AnnotationMode;
58
+ setMode(m: AnnotationMode): void;
59
+ getStore(): AnnotationStore;
60
+ /** 当前标注列表快照。 */
61
+ getAnnotations(): Annotation[];
62
+ undo(): void;
63
+ clearAll(): void;
64
+ deleteAnnotation(id: string): void;
65
+ selectAnnotation(id: string | null): void;
66
+ /** 颜色变更后重画对应 three 对象。 */
67
+ refreshAnnotation(id: string): void;
68
+ exportJSON(modelName: string, opts?: ExportOptions): {
69
+ model: string;
70
+ exportedAt: string;
71
+ space: "local" | "world";
72
+ annotations: {
73
+ id: string;
74
+ type: "contour" | "points";
75
+ mode: "freehand" | "geodesic" | null;
76
+ label: string;
77
+ color: string;
78
+ closed: boolean;
79
+ points: number[][];
80
+ }[];
81
+ };
82
+ private applyCameraGating;
83
+ /** 据 store.list() 对账场景:补齐缺失对象、移除已删对象(不 dispose,留给撤销恢复)。 */
84
+ private reconcile;
85
+ private applySelection;
86
+ private disposeObject;
87
+ private nextId;
88
+ private hit;
89
+ /** 事件目标是否落在标注容器内(排除面板/页面其它区域的点击)。 */
90
+ private insideContainer;
91
+ private onPointerDown;
92
+ private onPointerMove;
93
+ private onPointerUp;
94
+ private closeLastContour;
95
+ /** 沿网格表面求 a→b 的测地路径(local 顶点),去掉与 a 重合的首点。a/b 已是 local。 */
96
+ private surfacePathBetween;
97
+ /** 结束当前测地线:闭合成环并落定为一条 contour。 */
98
+ private finishGeodesic;
99
+ private isTypingTarget;
100
+ private onKeyDown;
101
+ private onKeyUp;
102
+ dispose(): void;
103
+ }
@@ -0,0 +1,37 @@
1
+ import * as THREE from "three";
2
+ import type { Annotation, ExportOptions } from "./types";
3
+ /**
4
+ * 标注数据模型 + 撤销栈 + 导出。纯数据,无 three / DOM 依赖。
5
+ * 撤销只记录 add / remove 两类原子操作(满足"撤销最近添加 / 恢复删除")。
6
+ * 通过 subscribe 通知 UI 与渲染层(后者据 list() 做场景对账)。
7
+ */
8
+ export declare class AnnotationStore {
9
+ private items;
10
+ private undoStack;
11
+ private subs;
12
+ private notify;
13
+ subscribe(cb: () => void): () => void;
14
+ add(a: Annotation): void;
15
+ remove(id: string): Annotation | undefined;
16
+ undo(): void;
17
+ /** 清空,返回被清掉的项(供渲染层 dispose three 对象)。 */
18
+ clear(): Annotation[];
19
+ list(): Annotation[];
20
+ get(id: string): Annotation | undefined;
21
+ setLabel(id: string, label: string): void;
22
+ setColor(id: string, color: string): void;
23
+ toJSON(modelName: string, mesh: THREE.Mesh, opts?: ExportOptions): {
24
+ model: string;
25
+ exportedAt: string;
26
+ space: "local" | "world";
27
+ annotations: {
28
+ id: string;
29
+ type: "contour" | "points";
30
+ mode: "freehand" | "geodesic" | null;
31
+ label: string;
32
+ color: string;
33
+ closed: boolean;
34
+ points: number[][];
35
+ }[];
36
+ };
37
+ }
@@ -0,0 +1,7 @@
1
+ import * as THREE from "three";
2
+ import { Line2 } from "three/examples/jsm/lines/Line2";
3
+ import type { AnnotationVertex } from "./types";
4
+ export declare function makeContourLine(verts: AnnotationVertex[], color: string, closed: boolean, container: HTMLElement, epsilon: number, mesh: THREE.Mesh): Line2;
5
+ export declare function updateContourLine(line: Line2, verts: AnnotationVertex[], closed: boolean, epsilon: number, mesh: THREE.Mesh): void;
6
+ /** 改变已有 contour 线的颜色。 */
7
+ export declare function setContourColor(line: Line2, color: string): void;
@@ -0,0 +1,19 @@
1
+ import * as THREE from "three";
2
+ import type { AnnotationVertex } from "./types";
3
+ import { MeshGraph } from "./MeshGraph";
4
+ /**
5
+ * 模式 B(测地线)状态机:逐次点击锚点,相邻锚点之间用 MeshGraph 求最短路径,
6
+ * 拼成一条贴合表面的折线。Enter 结束并可闭合(首尾再求一段)。
7
+ */
8
+ export declare class GeodesicContour {
9
+ private graph;
10
+ private mesh;
11
+ private anchors;
12
+ private segments;
13
+ constructor(graph: MeshGraph, mesh: THREE.Mesh);
14
+ /** 传入 local 命中点,snap 到最近顶点并对上一锚点求路径。 */
15
+ addAnchor(localHitPoint: THREE.Vector3): void;
16
+ get anchorCount(): number;
17
+ /** 把所有路径顶点(world)+ 法线 拼成折线;closed 时补一段首尾路径。 */
18
+ buildVertices(closed: boolean): AnnotationVertex[];
19
+ }
@@ -0,0 +1,3 @@
1
+ export { SurfaceAnnotator } from "./SurfaceAnnotator";
2
+ export type { SurfaceAnnotatorOptions } from "./SurfaceAnnotator";
3
+ export type { Annotation, AnnotationMode, AnnotationVertex, SurfaceHit, ExportOptions, } from "./types";
@@ -0,0 +1,7 @@
1
+ import * as THREE from "three";
2
+ import type { AnnotationVertex } from "./types";
3
+ /**
4
+ * 在 local 顶点处生成一个标记小球(fiducial)。local→world 后沿 world 法线略外移,
5
+ * 避免一半埋进表面。radius 由调用方按模型 bbox 缩放传入。
6
+ */
7
+ export declare function makePointMarker(v: AnnotationVertex, mesh: THREE.Mesh, color: string, radius: number): THREE.Mesh;
@@ -0,0 +1,7 @@
1
+ import * as THREE from "three";
2
+ import type { SurfaceHit } from "./types";
3
+ /**
4
+ * 把屏幕坐标(clientX/Y)投射到 mesh 表面,返回命中点、world-space 法线与 faceIndex。
5
+ * 未命中返回 null。本地实现,不依赖 Copper3D 未导出的 raycast 内部函数。
6
+ */
7
+ export declare function raycastSurface(camera: THREE.PerspectiveCamera, container: HTMLElement, mesh: THREE.Mesh, clientX: number, clientY: number): SurfaceHit | null;
@@ -0,0 +1,19 @@
1
+ import * as THREE from "three";
2
+ import type { AnnotationVertex, SurfaceHit } from "./types";
3
+ /**
4
+ * 模式 A(自由手绘)一笔的状态机。
5
+ * pointermove 时不断 addSample;与上一采样点世界距离 < minGap 的样本丢弃,避免过密。
6
+ * 顶点以 local 存(由 mesh 把世界命中点转 local)。
7
+ */
8
+ export declare class StrokeContour {
9
+ private minGap;
10
+ private mesh;
11
+ private verts;
12
+ private last;
13
+ private has;
14
+ constructor(minGap: number, mesh: THREE.Mesh);
15
+ begin(): void;
16
+ addSample(hit: SurfaceHit): void;
17
+ get vertices(): AnnotationVertex[];
18
+ end(): AnnotationVertex[];
19
+ }
@@ -0,0 +1,40 @@
1
+ import * as THREE from "three";
2
+ export type AnnotationMode = "navigate" | "freehand" | "geodesic" | "point";
3
+ export interface SurfaceHit {
4
+ point: THREE.Vector3;
5
+ normal: THREE.Vector3;
6
+ faceIndex: number;
7
+ }
8
+ /** 标注顶点:位置与法线均为 **模型 local 空间**(单一真源,不受相机/摆放影响)。 */
9
+ export interface AnnotationVertex {
10
+ x: number;
11
+ y: number;
12
+ z: number;
13
+ nx: number;
14
+ ny: number;
15
+ nz: number;
16
+ faceIndex: number;
17
+ }
18
+ export interface Annotation {
19
+ id: string;
20
+ type: "contour" | "points";
21
+ mode: "freehand" | "geodesic" | null;
22
+ label: string;
23
+ color: string;
24
+ closed: boolean;
25
+ vertices: AnnotationVertex[];
26
+ object3D: THREE.Object3D | null;
27
+ }
28
+ export interface ExportOptions {
29
+ /** 导出坐标空间,默认 "local"(模型空间,可复现、不受相机/摆放影响)。 */
30
+ space?: "local" | "world";
31
+ /** 是否在每个点附带法线 [x,y,z,nx,ny,nz]。 */
32
+ includeNormals?: boolean;
33
+ }
34
+ /** 世界系命中点 → local 顶点(位置 worldToLocal,法线用逆变换)。 */
35
+ export declare function worldHitToLocalVertex(h: SurfaceHit, mesh: THREE.Mesh): AnnotationVertex;
36
+ /** local 顶点 → world 位置 + world 法线(供渲染)。 */
37
+ export declare function localVertexToWorld(v: AnnotationVertex, mesh: THREE.Mesh): {
38
+ p: THREE.Vector3;
39
+ n: THREE.Vector3;
40
+ };
@@ -17,6 +17,8 @@ import { GaussianSmoother } from "./Utils/segmentation/core/GaussianSmoother";
17
17
  import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls";
18
18
  import { MeshNodeTool } from "./Utils/MeshNodeTool";
19
19
  import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
20
+ import { SurfaceAnnotator } from "./Utils/surfaceAnnotation";
21
+ import type { SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions } from "./Utils/surfaceAnnotation";
20
22
  import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController } from "./types/types";
21
23
  import { IPaintImage, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, IGuiMeta } from "./Utils/segmentation/core/types";
22
24
  import { NrrdState } from "./Utils/segmentation/coreTools/NrrdState";
@@ -26,6 +28,6 @@ import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_
26
28
  import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
27
29
  import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from "./Utils/segmentation/tools/AiAssistTool";
28
30
  import "./css/style.css";
29
- export declare const REVISION = "v3.5.0-beta";
30
- 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, };
31
- 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, };
31
+ export declare const REVISION = "v3.6.0-beta";
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
+ 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.5.0",
4
+ "version": "3.6.0",
5
5
  "main": "dist/bundle.umd.js",
6
6
  "moudle": "dist/bundle.esm.js",
7
7
  "types": "dist/types/index.d.ts",