copper3d 3.9.3 → 3.10.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 (32) hide show
  1. package/README.md +95 -5
  2. package/dist/Loader/copperNrrdLoader.d.ts +74 -0
  3. package/dist/Loader/copperNrrdLoader.js +182 -8
  4. package/dist/Loader/copperNrrdLoader.js.map +1 -1
  5. package/dist/Loader/nrrdWorker.d.ts +1 -0
  6. package/dist/Loader/nrrdWorker.js +29 -0
  7. package/dist/Loader/nrrdWorker.js.map +1 -0
  8. package/dist/Loader/nrrdWorkerCore.d.ts +87 -0
  9. package/dist/Loader/nrrdWorkerCore.js +223 -0
  10. package/dist/Loader/nrrdWorkerCore.js.map +1 -0
  11. package/dist/Utils/segmentation/NrrdTools.d.ts +54 -0
  12. package/dist/Utils/segmentation/NrrdTools.js +94 -0
  13. package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
  14. package/dist/Utils/segmentation/tools/DataLoader.d.ts +48 -1
  15. package/dist/Utils/segmentation/tools/DataLoader.js +128 -30
  16. package/dist/Utils/segmentation/tools/DataLoader.js.map +1 -1
  17. package/dist/Utils/segmentation/tools/DragSliceTool.js +10 -3
  18. package/dist/Utils/segmentation/tools/DragSliceTool.js.map +1 -1
  19. package/dist/Utils/segmentation/tools/ToolHost.d.ts +9 -1
  20. package/dist/bundle.esm.js +424 -47
  21. package/dist/bundle.umd.js +425 -46
  22. package/dist/index.d.ts +5 -3
  23. package/dist/index.js +3 -2
  24. package/dist/index.js.map +1 -1
  25. package/dist/types/Loader/copperNrrdLoader.d.ts +74 -0
  26. package/dist/types/Loader/nrrdWorker.d.ts +1 -0
  27. package/dist/types/Loader/nrrdWorkerCore.d.ts +87 -0
  28. package/dist/types/Utils/segmentation/NrrdTools.d.ts +54 -0
  29. package/dist/types/Utils/segmentation/tools/DataLoader.d.ts +48 -1
  30. package/dist/types/Utils/segmentation/tools/ToolHost.d.ts +9 -1
  31. package/dist/types/index.d.ts +5 -3
  32. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -15,6 +15,8 @@ import { createTexture2D_NRRD } from "./Utils/texture2d";
15
15
  import { configKiwriousHeart, loadKiwrious } from "./Utils/kiwrious/configKiwrious";
16
16
  import kiwrious from "./Utils/kiwrious/configKiwrious";
17
17
  import { NrrdTools } from "./Utils/segmentation/NrrdTools";
18
+ import { registerNiftiMaskGrid } from "./Utils/segmentation/tools/DataLoader";
19
+ import type { NrrdHeaderLike } from "./Utils/segmentation/tools/DataLoader";
18
20
  import { GaussianSmoother } from "./Utils/segmentation/core/GaussianSmoother";
19
21
  import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls";
20
22
  import { Copper3dOrbitControls } from "./Controls/Copper3dOrbitControls";
@@ -42,7 +44,7 @@ import { setCameraPose } from "./Controls/setCameraPose";
42
44
  import type { PosableScene } from "./Controls/setCameraPose";
43
45
  import { addVolumeBoundingBox, VOLUME_BOUNDS_NAME } from "./Loader/volumeBoundingBox";
44
46
  import type { BoundingBoxHost, VolumeBoundingBoxOpts } from "./Loader/volumeBoundingBox";
45
- import { DEFAULT_AXES } from "./Loader/copperNrrdLoader";
47
+ import { DEFAULT_AXES, ensureAxisExtracted } from "./Loader/copperNrrdLoader";
46
48
  import type { NrrdAxis } from "./Loader/copperNrrdLoader";
47
49
  import { easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle } from "./Controls/cameraTransitions";
48
50
  import type { Pose } from "./Controls/cameraTransitions";
@@ -59,6 +61,6 @@ import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
59
61
  import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from "./Utils/segmentation/tools/AiAssistTool";
60
62
  import "./css/style.css";
61
63
  export declare const REVISION: string;
62
- export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, DEFAULT_AXES, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
63
- export type { positionType, screenPosType, optsType, GltfLoadOpts, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, LayerId, ChannelValue, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, ExposureVolume, DisposableObject3D, DisposableMaterial, FadeTarget, FadeableMaterial, SceneBudget, DisposableScene, SceneDisposalHost, FitBounds, FitViewScene, AxisGatedControls, GestureAxes, PosableScene, BoundingBoxHost, VolumeBoundingBoxOpts, NrrdAxis, Pose, };
64
+ export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, registerNiftiMaskGrid, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, DEFAULT_AXES, ensureAxisExtracted, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
65
+ export type { positionType, screenPosType, optsType, NrrdHeaderLike, GltfLoadOpts, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, LayerId, ChannelValue, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, ExposureVolume, DisposableObject3D, DisposableMaterial, FadeTarget, FadeableMaterial, SceneBudget, DisposableScene, SceneDisposalHost, FitBounds, FitViewScene, AxisGatedControls, GestureAxes, PosableScene, BoundingBoxHost, VolumeBoundingBoxOpts, NrrdAxis, Pose, };
64
66
  export type { CameraViewPreset } from "./Controls/orbitFraming";
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ import { createTexture2D_NRRD } from "./Utils/texture2d";
15
15
  import { configKiwriousHeart, loadKiwrious, } from "./Utils/kiwrious/configKiwrious";
16
16
  import kiwrious from "./Utils/kiwrious/configKiwrious";
17
17
  import { NrrdTools } from "./Utils/segmentation/NrrdTools";
18
+ import { registerNiftiMaskGrid } from "./Utils/segmentation/tools/DataLoader";
18
19
  import { GaussianSmoother } from "./Utils/segmentation/core/GaussianSmoother";
19
20
  // Phase 7: Segmentation Module - Unified exports
20
21
  import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls";
@@ -32,7 +33,7 @@ import { isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomE
32
33
  import { beginGesture, isGestureActive } from "./Controls/gestureGate";
33
34
  import { setCameraPose } from "./Controls/setCameraPose";
34
35
  import { addVolumeBoundingBox, VOLUME_BOUNDS_NAME, } from "./Loader/volumeBoundingBox";
35
- import { DEFAULT_AXES } from "./Loader/copperNrrdLoader";
36
+ import { DEFAULT_AXES, ensureAxisExtracted } from "./Loader/copperNrrdLoader";
36
37
  import { easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, } from "./Controls/cameraTransitions";
37
38
  import { installFastSliceRepaint } from "./Loader/fastSliceRepaint";
38
39
  import { SurfaceAnnotator } from "./Utils/surfaceAnnotation";
@@ -56,5 +57,5 @@ if (typeof window !== "undefined") {
56
57
  if (typeof console !== "undefined") {
57
58
  console.log(`%cCopper3D Visualisation %c${REVISION}`, "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
58
59
  }
59
- export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, DEFAULT_AXES, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
60
+ export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, registerNiftiMaskGrid, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, DEFAULT_AXES, ensureAxisExtracted, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
60
61
  //# 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,EAGf,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAY,MAAM,2BAA2B,CAAC;AACnE,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,YAAY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BAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,QAAQ,EACR,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,OAAO,EACP,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,eAAe,EACf,uBAAuB,GACxB,CAAC"}
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,EAGf,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAY,MAAM,2BAA2B,CAAC;AACnE,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,sBA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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,YAAY,EACZ,SAAS,EACT,qBAAqB,EACrB,OAAO,EACP,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,QAAQ,EACR,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,OAAO,EACP,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,eAAe,EACf,uBAAuB,GACxB,CAAC"}
@@ -1,8 +1,52 @@
1
1
  import * as THREE from "three";
2
+ import { Volume } from "three/examples/jsm/misc/Volume.js";
2
3
  import { copperScene } from "../Scene/copperScene";
3
4
  import { GUI } from "dat.gui";
4
5
  import { nrrdMeshesType, nrrdSliceType, loadingBarType } from "../types/types";
5
6
  import { Copper3dTrackballControls } from "../Controls/Copper3dTrackballControls";
7
+ /**
8
+ * Real worker in production; a test double can be substituted via
9
+ * `__setNrrdWorkerFactoryForTests` (see that function's doc comment).
10
+ */
11
+ type NrrdWorkerLike = {
12
+ postMessage(message: unknown, transfer?: Transferable[]): void;
13
+ onmessage: ((event: MessageEvent) => void) | null;
14
+ };
15
+ /**
16
+ * Test-only seam. Production code always goes through `createRealNrrdWorker`, which
17
+ * constructs a real `Worker` (`?worker&inline`, so the plugin build never needs a second
18
+ * asset file at an unpredictable base path). jsdom (this repo's test environment) has no
19
+ * `Worker` implementation at all, so tests substitute an in-process double that drives the
20
+ * exact same `nrrdWorkerCore.ts` logic the real worker entry uses -- see
21
+ * `__tests__/helpers/fakeNrrdWorker.ts`. Passing `null` restores the real worker factory.
22
+ */
23
+ export declare function __setNrrdWorkerFactoryForTests(factory: (() => NrrdWorkerLike) | null): void;
24
+ /**
25
+ * Reconstructs a real `Volume` (real `Matrix4`s, a real typed-array view over the
26
+ * transferred buffer) from the worker's payload. Every value was already computed by the
27
+ * real `NRRDLoader.parse()` inside the worker (see `nrrdWorkerCore.ts`'s `buildPayload`) --
28
+ * this only puts real class instances back around values that cannot cross a `postMessage`
29
+ * boundary as-is (a `Volume`/`Matrix4` instance loses its prototype in structured clone).
30
+ * `new Volume(xLength, yLength, zLength, type, buffer)` wraps `buffer` in a typed-array view
31
+ * without copying, so this is microseconds regardless of volume size.
32
+ */
33
+ /**
34
+ * The NRRD volume this engine passes around: three.js's `Volume` plus the fields
35
+ * `NRRDLoader.parse()` attaches to it, with `matrix` widened to the 4x4 affine an NRRD
36
+ * actually carries -- three declares that member as a `Matrix3`.
37
+ */
38
+ export interface NrrdVolume extends Omit<Volume, "matrix"> {
39
+ header: any;
40
+ segmentation: boolean;
41
+ dimensions: number[];
42
+ matrix: THREE.Matrix4;
43
+ inverseMatrix: THREE.Matrix4;
44
+ RASDimensions: number[];
45
+ min: number;
46
+ max: number;
47
+ windowLow: number;
48
+ windowHigh: number;
49
+ }
6
50
  /** A slice axis, in the sense `Volume.extractSlice` uses. */
7
51
  export type NrrdAxis = "x" | "y" | "z";
8
52
  /** All three, which is what `loadNrrd` has always extracted. */
@@ -44,7 +88,36 @@ export interface optsType {
44
88
  * `callback` simply never fired.
45
89
  */
46
90
  onError?: (error: unknown) => void;
91
+ /**
92
+ * The volume's whole-intensity `[min, max]`, already known (e.g. from the backend's
93
+ * `/files/{case_id}/headers`, which reads it once from the same bytes the backend already
94
+ * decompresses). When supplied, `Volume.computeMinMax()` uses it instead of scanning every
95
+ * voxel in the browser -- the single largest function in a case-load CPU profile. Omit it
96
+ * (or pass a stale/wrong-looking one) and behaviour is exactly as before: three's own scan
97
+ * runs and the image comes out identical, just slower.
98
+ */
99
+ knownMinMax?: [number, number];
100
+ /**
101
+ * Aborts the in-flight fetch. A superseded load (case switch, series switch) can now stop
102
+ * its transfer instead of only having its eventual result discarded -- see `abandonLoad` in
103
+ * `LeftPanelCore.vue`. `onError` still fires for an aborted fetch (the browser rejects it
104
+ * like any other failed fetch); callers that already ignore errors from a stale load need no
105
+ * further change.
106
+ */
107
+ signal?: AbortSignal;
47
108
  }
109
+ /**
110
+ * Extracts a slice plane a narrower `axes` load skipped, the first time something asks for
111
+ * it (see `NrrdTools.setSliceOrientation`). Mutates `slices` (and `meshes`, if given) in
112
+ * place so every existing reference to the same object -- there is exactly one per volume --
113
+ * picks up the new plane; callers do not need to replace anything. A no-op if the axis is
114
+ * already present.
115
+ *
116
+ * All three axes' slices share one `Volume` instance (see `onLoad` below), so whichever axis
117
+ * IS already extracted is where the volume, dimensions, spacing and RAS dimensions are read
118
+ * from -- there is no separate "the volume" reference kept around for this.
119
+ */
120
+ export declare function ensureAxisExtracted(slices: nrrdSliceType, axis: NrrdAxis, meshes?: nrrdMeshesType): any;
48
121
  export declare function copperNrrdLoader(url: string, loadingBar: loadingBarType, segmentation: boolean, callback?: (volume: any, nrrdMeshes: nrrdMeshesType, nrrdSlices: nrrdSliceType, gui?: GUI) => void, opts?: optsType): void;
49
122
  export declare function copperNrrdTexture3dLoader(url: string, scene: THREE.Scene, container: HTMLDivElement, callback?: (volume: any, gui?: GUI) => void): void;
50
123
  export declare function getWholeSlices(nrrdSlices: nrrdSliceType, scene: THREE.Scene, gui: GUI, controls: Copper3dTrackballControls): void;
@@ -58,3 +131,4 @@ export declare function getWholeSlices(nrrdSlices: nrrdSliceType, scene: THREE.S
58
131
  * -- and sizes the box from `volume.matrix` rather than its RAS dimensions.
59
132
  */
60
133
  export declare function addBoxHelper(scene: copperScene, volume: any, boxCube?: THREE.Object3D<THREE.Object3DEventMap>): void;
134
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,87 @@
1
+ /** A message this module hands back to the caller, in the exact shape `postMessage` expects
2
+ * (payload + a transfer list containing every `Transferable` inside it). */
3
+ export type WorkerEmit = (message: NrrdWorkerMessage, transfer?: Transferable[]) => void;
4
+ export interface NrrdLoadCommand {
5
+ cmd: "load";
6
+ id: string;
7
+ url: string;
8
+ segmentation: boolean;
9
+ knownMinMax?: [number, number];
10
+ }
11
+ export interface NrrdAbortCommand {
12
+ cmd: "abort";
13
+ id: string;
14
+ }
15
+ export type NrrdWorkerCommand = NrrdLoadCommand | NrrdAbortCommand;
16
+ /** Everything `rehydrateVolume` (main thread, `copperNrrdLoader.ts`) needs to reconstruct a
17
+ * real `Volume` -- values already computed by the real `NRRDLoader.parse()` above, copied
18
+ * out verbatim, never re-derived. `buffer` is the volume's own pixel data, transferable. */
19
+ export interface NrrdWorkerPayload {
20
+ xLength: number;
21
+ yLength: number;
22
+ zLength: number;
23
+ /** `headerObject.type`, e.g. "short" -- accepted by `Volume`'s own constructor switch. */
24
+ type: string;
25
+ header: Record<string, unknown>;
26
+ spacing: [number, number, number];
27
+ axisOrder: string[];
28
+ RASDimensions: [number, number, number];
29
+ segmentation: boolean;
30
+ min: number;
31
+ max: number;
32
+ windowLow: number;
33
+ windowHigh: number;
34
+ lowerThreshold: number;
35
+ upperThreshold: number;
36
+ matrixElements: number[];
37
+ inverseMatrixElements: number[];
38
+ buffer: ArrayBuffer;
39
+ }
40
+ export type NrrdWorkerMessage = {
41
+ id: string;
42
+ type: "progress";
43
+ loaded: number;
44
+ total: number;
45
+ } | {
46
+ id: string;
47
+ type: "loaded";
48
+ payload: NrrdWorkerPayload;
49
+ } | {
50
+ id: string;
51
+ type: "error";
52
+ name: string;
53
+ message: string;
54
+ };
55
+ interface PendingUrlFetch {
56
+ bufferPromise: Promise<ArrayBuffer>;
57
+ controller: AbortController;
58
+ attached: number;
59
+ }
60
+ export interface NrrdWorkerState {
61
+ pendingByUrl: Map<string, PendingUrlFetch>;
62
+ /** Which URL each still-attached caller id belongs to, so `handleAbortMessage` can find its
63
+ * shared entry, and so a load whose buffer arrives after the caller already detached can
64
+ * tell it has nothing left to do. */
65
+ callerToUrl: Map<string, string>;
66
+ }
67
+ export declare function createNrrdWorkerState(): NrrdWorkerState;
68
+ /**
69
+ * Handles one `{cmd: "load"}` command. Dedupes the underlying fetch by URL exactly like
70
+ * `copperNrrdLoader.ts`'s old `sharedFetchNrrdArrayBuffer` did (one real request per URL,
71
+ * shared by every attached caller) -- only the transport moved, not the sharing rule. Once
72
+ * the shared bytes arrive, this caller runs its OWN `loader.parse()` with its OWN
73
+ * `knownMinMax`, independently of every other attached caller -- parsing is cheap relative to
74
+ * fetch+gunzip and was never shared even before this change (see `copperNrrdLoader.ts`'s doc
75
+ * comment on `sharedFetchNrrdArrayBuffer`), so a second caller's different `knownMinMax` can
76
+ * never be silently handed the first caller's window.
77
+ */
78
+ export declare function handleLoadMessage(state: NrrdWorkerState, msg: NrrdLoadCommand, emit: WorkerEmit): Promise<void>;
79
+ /**
80
+ * Handles one `{cmd: "abort"}` command. The caller's own promise on the main thread is
81
+ * already rejected by the time this arrives (see `copperNrrdLoader.ts`'s `loadViaWorker` --
82
+ * it rejects locally the instant the caller's `AbortSignal` fires, exactly like the old
83
+ * `sharedFetchNrrdArrayBuffer` did). This only updates the shared bookkeeping: the real
84
+ * network transfer stops only once every attached caller has dropped off.
85
+ */
86
+ export declare function handleAbortMessage(state: NrrdWorkerState, msg: NrrdAbortCommand): void;
87
+ export {};
@@ -46,6 +46,12 @@ export declare class NrrdTools {
46
46
  private sliceRenderPipeline;
47
47
  /** Data loading (extracted module) */
48
48
  private dataLoader;
49
+ /**
50
+ * How a message reaches the reader. Defaults to the console: this package ships without
51
+ * a UI and must not import the host application's, or it cannot be built on its own.
52
+ * A host that has a toast or a banner assigns this after construction.
53
+ */
54
+ notifyUser: (message: string, level: "error" | "warning" | "info") => void;
49
55
  /** Stored closure callbacks from gui.ts setupGui() */
50
56
  private guiCallbacks;
51
57
  constructor(container: HTMLDivElement, options?: {
@@ -118,6 +124,23 @@ export declare class NrrdTools {
118
124
  setSliceOrientation(axisTo: "x" | "y" | "z"): void;
119
125
  addSkip(index: number): void;
120
126
  removeSkip(index: number): void;
127
+ /**
128
+ * Batched form of `addSkip`/`removeSkip` for reconciling many positions at once (e.g. a
129
+ * case load's initial phase selection, see `useCaseManagement.reconcileSkips`) without
130
+ * paying `resetDisplaySlicesStatus()`'s full display/canvas/mask refresh once per position.
131
+ *
132
+ * Calling `addSkip`/`removeSkip` in a loop is correct but wasteful here: every entry but
133
+ * the last is immediately superseded (this always runs synchronously, with nothing reading
134
+ * the display in between, and the caller's own follow-up -- `landOn`'s `setContrastIndex`
135
+ * -- overwrites `contrastNum` again right after). Measured at over 1 second of main-thread
136
+ * time for a 5-phase series once per-volume extraction stopped dominating the case-load
137
+ * block (narrower `axes`, see copperNrrdLoader) -- this was always there, just smaller than
138
+ * the cost it used to sit next to.
139
+ */
140
+ setSkips(entries: Array<{
141
+ index: number;
142
+ skip: boolean;
143
+ }>): void;
121
144
  /**
122
145
  * Move to a specific contrast without moving the slice.
123
146
  *
@@ -129,6 +152,37 @@ export declare class NrrdTools {
129
152
  setSliceMoving(step: number): void;
130
153
  setMainAreaSize(factor: number): void;
131
154
  switchAllSlicesArrayData(allSlices: Array<nrrdSliceType>): void;
155
+ /**
156
+ * Batched form of `setSkips` + `setContrastIndex` for a load that ends by reconciling skip
157
+ * state and landing on a phase in the same turn (see
158
+ * `useCaseManagement.handleAllImagesLoaded`). Calling them separately is correct but
159
+ * wasteful: each pays `resetDisplaySlicesStatus()`'s full display/canvas/mask refresh, and
160
+ * with nothing reading the display in between, only the second call's paint was ever
161
+ * visible -- measured at two ~300ms refreshes back-to-back once `setSkips` had already
162
+ * absorbed the earlier per-phase `addSkip`/`removeSkip` loop cost.
163
+ *
164
+ * `contrastIndex` is set before the single `resetDisplaySlicesStatus()` call, not after:
165
+ * the resulting `displaySlices` length/order depends only on `skipSlicesDic`, which is
166
+ * already written by the time it runs, so the callbacks inside that one refresh
167
+ * (`repraintCurrentContrastSlice` etc.) paint the target contrast directly. The clamp
168
+ * below still runs after, against the freshly rebuilt `displaySlices`, for parity with
169
+ * `setContrastIndex`'s own bounds check.
170
+ */
171
+ commitSkipsAndContrast(skipEntries: Array<{
172
+ index: number;
173
+ skip: boolean;
174
+ }>, contrastIndex: number): void;
175
+ /**
176
+ * Case-load completion, fully batched: swap in the acquisition-ordered slice array,
177
+ * reconcile skip state, and land on the target contrast -- one `resetDisplaySlicesStatus()`
178
+ * instead of three (`switchAllSlicesArrayData` + `setSkips` + `setContrastIndex` used to
179
+ * each pay their own full refresh here; see `commitSkipsAndContrast` above for why only
180
+ * the batched form's single refresh is needed).
181
+ */
182
+ commitSeriesLoad(allSlices: Array<nrrdSliceType>, skipEntries: Array<{
183
+ index: number;
184
+ skip: boolean;
185
+ }>, contrastIndex: number): void;
132
186
  /**
133
187
  * Swap slice data while preserving current slice index, zoom, and pan position.
134
188
  * Used for register/origin image switching where the view state should persist.
@@ -2,6 +2,29 @@ import { BaseTool } from "./BaseTool";
2
2
  import type { ToolContext } from "./BaseTool";
3
3
  import type { nrrdSliceType, storeExportPaintImageType, loadingBarType } from "../../../types/types";
4
4
  import type { DataLoaderHostDeps } from "./ToolHost";
5
+ /**
6
+ * Records the NIfTI header's voxel grid [x, y, z] for a mask buffer that will be
7
+ * passed to `setMasksFromNIfTI`. Call this before that call for every buffer whose
8
+ * origin file's grid should be checked against the loaded NRRD's -- a buffer with
9
+ * no registered grid is refused rather than assumed to match (see
10
+ * `setMasksFromNIfTI`).
11
+ */
12
+ export declare function registerNiftiMaskGrid(data: Uint8Array, dims: number[]): void;
13
+ /**
14
+ * Volume geometry needed to size mask storage and image-metadata state before
15
+ * any slice pixel data has arrived. Produced either from a loaded slice's
16
+ * `.volume` (bulk load, see `headerFromSlice`) or, in the progressive-loading
17
+ * path, from a backend headers response (dimensions/spacing/space_origin as
18
+ * JSON) — both sources fill this same shape.
19
+ */
20
+ export interface NrrdHeaderLike {
21
+ /** Voxel counts per axis, [x, y, z]. */
22
+ dimensions: number[];
23
+ /** Voxel spacing in mm per axis, [x, y, z]. */
24
+ spacing: number[];
25
+ /** Physical origin of the volume, [x, y, z]. */
26
+ space_origin: number[];
27
+ }
5
28
  /**
6
29
  * Handles data loading for NRRD slices and mask volumes.
7
30
  *
@@ -12,6 +35,25 @@ export declare class DataLoader extends BaseTool {
12
35
  private callbacks;
13
36
  constructor(ctx: ToolContext, callbacks: DataLoaderHostDeps);
14
37
  /****************************Slice Loading****************************************************/
38
+ /**
39
+ * Size image-metadata state and MaskVolumes from volume geometry alone,
40
+ * before any slice pixel data has arrived. `allSlicesArray` is untouched.
41
+ */
42
+ initFromHeader(header: NrrdHeaderLike): void;
43
+ /**
44
+ * Records a slice's position in the contrast series. Does not refresh the
45
+ * display slices/undo-history side effects — see `appendSlice` for that.
46
+ */
47
+ private setContrastOrder;
48
+ /**
49
+ * Appends one already-loaded slice to the contrast series and refreshes the
50
+ * display slices / undo state for it. For loading N slices at once, prefer
51
+ * `setAllSlices`: calling this once per slice would rebuild the display-slice
52
+ * list from a still-growing `allSlicesArray` on every call, and
53
+ * `setDisplaySlicesBaseOnAxis`'s skip-list bookkeeping (`skipSlicesDic`)
54
+ * assumes each call sees the final array, not an intermediate one.
55
+ */
56
+ appendSlice(slice: nrrdSliceType, order: number): void;
15
57
  /**
16
58
  * Load all NRRD contrast slices and initialize MaskVolumes with real dimensions.
17
59
  */
@@ -23,7 +65,12 @@ export declare class DataLoader extends BaseTool {
23
65
  /**
24
66
  * Load raw voxel data into MaskVolume layers.
25
67
  *
26
- * Expects pre-extracted voxel bytes (e.g. from useNiftiVoxelData).
68
+ * Expects pre-extracted voxel bytes (e.g. from useNiftiVoxelData). A buffer is
69
+ * refused -- not truncated or zero-padded -- when its own NIfTI grid (registered
70
+ * via `registerNiftiMaskGrid`) does not match the loaded NRRD's grid. Truncating
71
+ * a longer buffer or zero-padding a shorter one used to render it silently
72
+ * offset onto the wrong voxels with no error; a refused mask is recoverable,
73
+ * a misplaced one is not.
27
74
  *
28
75
  * @param layerVoxels Map of layer ID to raw voxel Uint8Array
29
76
  * Keys should be 'layer1', 'layer2', 'layer3'
@@ -23,6 +23,14 @@ export interface ToolHost {
23
23
  redrawDisplayCanvas(): void;
24
24
  refreshSphereOverlay(): void;
25
25
  reloadMasksFromVolume(): void;
26
+ /**
27
+ * Surfaces a message to the reader.
28
+ *
29
+ * This engine has no UI of its own and must not reach for the host application's --
30
+ * importing an app toast here is what makes the package unbuildable on its own. The
31
+ * host decides how a message is shown; the default is a console write.
32
+ */
33
+ notifyUser(message: string, level: "error" | "warning" | "info"): void;
26
34
  getVolumeForLayer(layer: string): MaskVolume;
27
35
  setIsDrawFalse(target: number): void;
28
36
  setSyncsliceNum(): void;
@@ -71,6 +79,6 @@ export type LayerChannelHostDeps = Pick<ToolHost, 'reloadMasksFromVolume' | 'get
71
79
  /** SliceRenderPipeline host dependencies */
72
80
  export type SliceRenderHostDeps = Pick<ToolHost, 'compositeAllLayers' | 'getOrCreateSliceBuffer' | 'renderSliceToCanvas' | 'getVolumeForLayer' | 'refreshSphereOverlay' | 'syncGuiParameterSettings' | 'repraintCurrentContrastSlice' | 'clearUndoHistory' | 'updateShowNumDiv' | 'updateCurrentContrastSlice'>;
73
81
  /** DataLoader host dependencies */
74
- export type DataLoaderHostDeps = Pick<ToolHost, 'invalidateSliceBuffer' | 'setDisplaySlicesBaseOnAxis' | 'afterLoadSlice' | 'setEmptyCanvasSize' | 'syncLayerSliceData' | 'reloadMasksFromVolume' | 'resetZoom'>;
82
+ export type DataLoaderHostDeps = Pick<ToolHost, 'invalidateSliceBuffer' | 'setDisplaySlicesBaseOnAxis' | 'afterLoadSlice' | 'setEmptyCanvasSize' | 'syncLayerSliceData' | 'reloadMasksFromVolume' | 'resetZoom' | 'notifyUser'>;
75
83
  /** SphereBrushTool host dependencies */
76
84
  export type SphereBrushHostDeps = Pick<ToolHost, 'getVolumeForLayer' | 'compositeAllLayers' | 'pushUndoGroup' | 'renderSliceToCanvas' | 'getOrCreateSliceBuffer' | 'setEmptyCanvasSize' | 'reloadMasksFromVolume'>;
@@ -15,6 +15,8 @@ import { createTexture2D_NRRD } from "./Utils/texture2d";
15
15
  import { configKiwriousHeart, loadKiwrious } from "./Utils/kiwrious/configKiwrious";
16
16
  import kiwrious from "./Utils/kiwrious/configKiwrious";
17
17
  import { NrrdTools } from "./Utils/segmentation/NrrdTools";
18
+ import { registerNiftiMaskGrid } from "./Utils/segmentation/tools/DataLoader";
19
+ import type { NrrdHeaderLike } from "./Utils/segmentation/tools/DataLoader";
18
20
  import { GaussianSmoother } from "./Utils/segmentation/core/GaussianSmoother";
19
21
  import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls";
20
22
  import { Copper3dOrbitControls } from "./Controls/Copper3dOrbitControls";
@@ -42,7 +44,7 @@ import { setCameraPose } from "./Controls/setCameraPose";
42
44
  import type { PosableScene } from "./Controls/setCameraPose";
43
45
  import { addVolumeBoundingBox, VOLUME_BOUNDS_NAME } from "./Loader/volumeBoundingBox";
44
46
  import type { BoundingBoxHost, VolumeBoundingBoxOpts } from "./Loader/volumeBoundingBox";
45
- import { DEFAULT_AXES } from "./Loader/copperNrrdLoader";
47
+ import { DEFAULT_AXES, ensureAxisExtracted } from "./Loader/copperNrrdLoader";
46
48
  import type { NrrdAxis } from "./Loader/copperNrrdLoader";
47
49
  import { easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle } from "./Controls/cameraTransitions";
48
50
  import type { Pose } from "./Controls/cameraTransitions";
@@ -59,6 +61,6 @@ import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
59
61
  import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from "./Utils/segmentation/tools/AiAssistTool";
60
62
  import "./css/style.css";
61
63
  export declare const REVISION: string;
62
- export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, DEFAULT_AXES, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
63
- export type { positionType, screenPosType, optsType, GltfLoadOpts, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, LayerId, ChannelValue, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, ExposureVolume, DisposableObject3D, DisposableMaterial, FadeTarget, FadeableMaterial, SceneBudget, DisposableScene, SceneDisposalHost, FitBounds, FitViewScene, AxisGatedControls, GestureAxes, PosableScene, BoundingBoxHost, VolumeBoundingBoxOpts, NrrdAxis, Pose, };
64
+ export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, registerNiftiMaskGrid, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, DEFAULT_AXES, ensureAxisExtracted, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
65
+ export type { positionType, screenPosType, optsType, NrrdHeaderLike, GltfLoadOpts, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, LayerId, ChannelValue, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, ExposureVolume, DisposableObject3D, DisposableMaterial, FadeTarget, FadeableMaterial, SceneBudget, DisposableScene, SceneDisposalHost, FitBounds, FitViewScene, AxisGatedControls, GestureAxes, PosableScene, BoundingBoxHost, VolumeBoundingBoxOpts, NrrdAxis, Pose, };
64
66
  export type { CameraViewPreset } from "./Controls/orbitFraming";
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.9.3",
4
+ "version": "3.10.0",
5
5
  "main": "dist/bundle.umd.js",
6
6
  "moudle": "dist/bundle.esm.js",
7
7
  "types": "dist/types/index.d.ts",