copper3d 3.4.9 → 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 (89) hide show
  1. package/dist/Renderer/baseRenderer.d.ts +3 -0
  2. package/dist/Renderer/baseRenderer.js +20 -0
  3. package/dist/Renderer/baseRenderer.js.map +1 -1
  4. package/dist/Renderer/copperMSceneRenderer.d.ts +3 -0
  5. package/dist/Renderer/copperMSceneRenderer.js +22 -0
  6. package/dist/Renderer/copperMSceneRenderer.js.map +1 -1
  7. package/dist/Renderer/copperRenderer.d.ts +0 -2
  8. package/dist/Renderer/copperRenderer.js +0 -5
  9. package/dist/Renderer/copperRenderer.js.map +1 -1
  10. package/dist/Scene/copperScene.d.ts +12 -0
  11. package/dist/Scene/copperScene.js +38 -44
  12. package/dist/Scene/copperScene.js.map +1 -1
  13. package/dist/Utils/segmentation/DrawToolCore.d.ts +3 -0
  14. package/dist/Utils/segmentation/DrawToolCore.js +29 -1
  15. package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
  16. package/dist/Utils/segmentation/NrrdTools.d.ts +54 -0
  17. package/dist/Utils/segmentation/NrrdTools.js +119 -0
  18. package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
  19. package/dist/Utils/segmentation/core/index.d.ts +1 -1
  20. package/dist/Utils/segmentation/core/index.js +1 -1
  21. package/dist/Utils/segmentation/core/index.js.map +1 -1
  22. package/dist/Utils/segmentation/core/types.d.ts +11 -1
  23. package/dist/Utils/segmentation/core/types.js +30 -0
  24. package/dist/Utils/segmentation/core/types.js.map +1 -1
  25. package/dist/Utils/segmentation/eventRouter/EventRouter.d.ts +2 -0
  26. package/dist/Utils/segmentation/eventRouter/EventRouter.js +37 -6
  27. package/dist/Utils/segmentation/eventRouter/EventRouter.js.map +1 -1
  28. package/dist/Utils/segmentation/eventRouter/types.d.ts +3 -2
  29. package/dist/Utils/segmentation/tools/AiAssistTool.d.ts +146 -0
  30. package/dist/Utils/segmentation/tools/AiAssistTool.js +470 -0
  31. package/dist/Utils/segmentation/tools/AiAssistTool.js.map +1 -0
  32. package/dist/Utils/surfaceAnnotation/MeshGraph.d.ts +40 -0
  33. package/dist/Utils/surfaceAnnotation/MeshGraph.js +198 -0
  34. package/dist/Utils/surfaceAnnotation/MeshGraph.js.map +1 -0
  35. package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.d.ts +103 -0
  36. package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.js +402 -0
  37. package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.js.map +1 -0
  38. package/dist/Utils/surfaceAnnotation/annotationStore.d.ts +37 -0
  39. package/dist/Utils/surfaceAnnotation/annotationStore.js +105 -0
  40. package/dist/Utils/surfaceAnnotation/annotationStore.js.map +1 -0
  41. package/dist/Utils/surfaceAnnotation/contourRender.d.ts +7 -0
  42. package/dist/Utils/surfaceAnnotation/contourRender.js +57 -0
  43. package/dist/Utils/surfaceAnnotation/contourRender.js.map +1 -0
  44. package/dist/Utils/surfaceAnnotation/geodesicContour.d.ts +19 -0
  45. package/dist/Utils/surfaceAnnotation/geodesicContour.js +43 -0
  46. package/dist/Utils/surfaceAnnotation/geodesicContour.js.map +1 -0
  47. package/dist/Utils/surfaceAnnotation/index.d.ts +3 -0
  48. package/dist/Utils/surfaceAnnotation/index.js +2 -0
  49. package/dist/Utils/surfaceAnnotation/index.js.map +1 -0
  50. package/dist/Utils/surfaceAnnotation/pointMarkers.d.ts +7 -0
  51. package/dist/Utils/surfaceAnnotation/pointMarkers.js +16 -0
  52. package/dist/Utils/surfaceAnnotation/pointMarkers.js.map +1 -0
  53. package/dist/Utils/surfaceAnnotation/raycastSurface.d.ts +7 -0
  54. package/dist/Utils/surfaceAnnotation/raycastSurface.js +27 -0
  55. package/dist/Utils/surfaceAnnotation/raycastSurface.js.map +1 -0
  56. package/dist/Utils/surfaceAnnotation/strokeContour.d.ts +19 -0
  57. package/dist/Utils/surfaceAnnotation/strokeContour.js +35 -0
  58. package/dist/Utils/surfaceAnnotation/strokeContour.js.map +1 -0
  59. package/dist/Utils/surfaceAnnotation/types.d.ts +40 -0
  60. package/dist/Utils/surfaceAnnotation/types.js +26 -0
  61. package/dist/Utils/surfaceAnnotation/types.js.map +1 -0
  62. package/dist/bundle.esm.js +3701 -201
  63. package/dist/bundle.umd.js +3703 -200
  64. package/dist/index.d.ts +7 -4
  65. package/dist/index.js +4 -3
  66. package/dist/index.js.map +1 -1
  67. package/dist/types/Renderer/baseRenderer.d.ts +3 -0
  68. package/dist/types/Renderer/copperMSceneRenderer.d.ts +3 -0
  69. package/dist/types/Renderer/copperRenderer.d.ts +0 -2
  70. package/dist/types/Scene/copperScene.d.ts +12 -0
  71. package/dist/types/Utils/segmentation/DrawToolCore.d.ts +3 -0
  72. package/dist/types/Utils/segmentation/NrrdTools.d.ts +54 -0
  73. package/dist/types/Utils/segmentation/core/index.d.ts +1 -1
  74. package/dist/types/Utils/segmentation/core/types.d.ts +11 -1
  75. package/dist/types/Utils/segmentation/eventRouter/EventRouter.d.ts +2 -0
  76. package/dist/types/Utils/segmentation/eventRouter/types.d.ts +3 -2
  77. package/dist/types/Utils/segmentation/tools/AiAssistTool.d.ts +146 -0
  78. package/dist/types/Utils/surfaceAnnotation/MeshGraph.d.ts +40 -0
  79. package/dist/types/Utils/surfaceAnnotation/SurfaceAnnotator.d.ts +103 -0
  80. package/dist/types/Utils/surfaceAnnotation/annotationStore.d.ts +37 -0
  81. package/dist/types/Utils/surfaceAnnotation/contourRender.d.ts +7 -0
  82. package/dist/types/Utils/surfaceAnnotation/geodesicContour.d.ts +19 -0
  83. package/dist/types/Utils/surfaceAnnotation/index.d.ts +3 -0
  84. package/dist/types/Utils/surfaceAnnotation/pointMarkers.d.ts +7 -0
  85. package/dist/types/Utils/surfaceAnnotation/raycastSurface.d.ts +7 -0
  86. package/dist/types/Utils/surfaceAnnotation/strokeContour.d.ts +19 -0
  87. package/dist/types/Utils/surfaceAnnotation/types.d.ts +40 -0
  88. package/dist/types/index.d.ts +7 -4
  89. package/package.json +1 -1
@@ -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,14 +17,17 @@ 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";
23
25
  import { GuiState } from "./Utils/segmentation/coreTools/GuiState";
24
26
  import type { ToolMode, IAnnotationCallbacks } from "./Utils/segmentation/core/types";
25
- import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
27
+ import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
26
28
  import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
29
+ import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from "./Utils/segmentation/tools/AiAssistTool";
27
30
  import "./css/style.css";
28
- export declare const REVISION = "v3.4.9-beta";
29
- 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, rgbaToHex, rgbaToCss, GaussianSmoother, };
30
- 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, };
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.4.9",
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",