copper3d 3.7.4 → 3.8.1

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 (53) hide show
  1. package/dist/Controls/cameraTransitions.d.ts +87 -0
  2. package/dist/Controls/cameraTransitions.js +285 -0
  3. package/dist/Controls/cameraTransitions.js.map +1 -0
  4. package/dist/Controls/fitView.d.ts +45 -0
  5. package/dist/Controls/fitView.js +40 -0
  6. package/dist/Controls/fitView.js.map +1 -0
  7. package/dist/Controls/orbitFraming.d.ts +39 -0
  8. package/dist/Controls/orbitFraming.js +39 -0
  9. package/dist/Controls/orbitFraming.js.map +1 -1
  10. package/dist/Loader/fastSliceRepaint.d.ts +56 -0
  11. package/dist/Loader/fastSliceRepaint.js +159 -0
  12. package/dist/Loader/fastSliceRepaint.js.map +1 -0
  13. package/dist/Renderer/copperRendererOnDemond.d.ts +10 -2
  14. package/dist/Renderer/copperRendererOnDemond.js +14 -0
  15. package/dist/Renderer/copperRendererOnDemond.js.map +1 -1
  16. package/dist/Renderer/disposeScene.d.ts +47 -0
  17. package/dist/Renderer/disposeScene.js +46 -0
  18. package/dist/Renderer/disposeScene.js.map +1 -0
  19. package/dist/Renderer/sceneBudget.d.ts +40 -0
  20. package/dist/Renderer/sceneBudget.js +86 -0
  21. package/dist/Renderer/sceneBudget.js.map +1 -0
  22. package/dist/Scene/copperSceneOnDemond.d.ts +12 -0
  23. package/dist/Scene/copperSceneOnDemond.js +18 -0
  24. package/dist/Scene/copperSceneOnDemond.js.map +1 -1
  25. package/dist/Utils/dispose.d.ts +48 -0
  26. package/dist/Utils/dispose.js +60 -0
  27. package/dist/Utils/dispose.js.map +1 -0
  28. package/dist/Utils/modelCrossfade.d.ts +36 -0
  29. package/dist/Utils/modelCrossfade.js +46 -0
  30. package/dist/Utils/modelCrossfade.js.map +1 -0
  31. package/dist/Utils/segmentation/coreTools/divControlTools.js +19 -0
  32. package/dist/Utils/segmentation/coreTools/divControlTools.js.map +1 -1
  33. package/dist/Utils/volumeExposure.d.ts +32 -0
  34. package/dist/Utils/volumeExposure.js +104 -0
  35. package/dist/Utils/volumeExposure.js.map +1 -0
  36. package/dist/bundle.esm.js +31521 -10006
  37. package/dist/bundle.umd.js +31549 -10012
  38. package/dist/index.d.ts +19 -2
  39. package/dist/index.js +10 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/types/Controls/cameraTransitions.d.ts +87 -0
  42. package/dist/types/Controls/fitView.d.ts +45 -0
  43. package/dist/types/Controls/orbitFraming.d.ts +39 -0
  44. package/dist/types/Loader/fastSliceRepaint.d.ts +56 -0
  45. package/dist/types/Renderer/copperRendererOnDemond.d.ts +10 -2
  46. package/dist/types/Renderer/disposeScene.d.ts +47 -0
  47. package/dist/types/Renderer/sceneBudget.d.ts +40 -0
  48. package/dist/types/Scene/copperSceneOnDemond.d.ts +12 -0
  49. package/dist/types/Utils/dispose.d.ts +48 -0
  50. package/dist/types/Utils/modelCrossfade.d.ts +36 -0
  51. package/dist/types/Utils/volumeExposure.d.ts +32 -0
  52. package/dist/types/index.d.ts +19 -2
  53. package/package.json +7 -3
package/dist/index.d.ts CHANGED
@@ -18,6 +18,23 @@ import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls"
18
18
  import { Copper3dOrbitControls } from "./Controls/Copper3dOrbitControls";
19
19
  import { MeshNodeTool } from "./Utils/MeshNodeTool";
20
20
  import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
21
+ import { exposureExponent, DEFAULT_TARGET_GREY } from "./Utils/volumeExposure";
22
+ import type { ExposureVolume } from "./Utils/volumeExposure";
23
+ import { disposeObject3D, disposeMaterial } from "./Utils/dispose";
24
+ import type { DisposableObject3D, DisposableMaterial } from "./Utils/dispose";
25
+ import { collectFadeTargets, setFade, restoreFade } from "./Utils/modelCrossfade";
26
+ import type { FadeTarget, FadeableMaterial } from "./Utils/modelCrossfade";
27
+ import { createSceneBudget, defaultBudgetBytes } from "./Renderer/sceneBudget";
28
+ import type { SceneBudget } from "./Renderer/sceneBudget";
29
+ import { disposeScene, removeSceneFromMap } from "./Renderer/disposeScene";
30
+ import type { DisposableScene, SceneDisposalHost } from "./Renderer/disposeScene";
31
+ import { fitDistance } from "./Controls/orbitFraming";
32
+ import type { FitBounds } from "./Controls/orbitFraming";
33
+ import { fitView } from "./Controls/fitView";
34
+ import type { FitViewScene } from "./Controls/fitView";
35
+ import { easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle } from "./Controls/cameraTransitions";
36
+ import type { Pose } from "./Controls/cameraTransitions";
37
+ import { installFastSliceRepaint } from "./Loader/fastSliceRepaint";
21
38
  import { SurfaceAnnotator } from "./Utils/surfaceAnnotation";
22
39
  import type { SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions } from "./Utils/surfaceAnnotation";
23
40
  import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController } from "./types/types";
@@ -30,6 +47,6 @@ import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
30
47
  import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from "./Utils/segmentation/tools/AiAssistTool";
31
48
  import "./css/style.css";
32
49
  export declare const REVISION: string;
33
- export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, 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, };
34
- export type { positionType, screenPosType, optsType, 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, };
50
+ export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, 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, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
51
+ export type { positionType, screenPosType, optsType, 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, Pose, };
35
52
  export type { CameraViewPreset } from "./Controls/orbitFraming";
package/dist/index.js CHANGED
@@ -20,6 +20,15 @@ import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls"
20
20
  import { Copper3dOrbitControls } from "./Controls/Copper3dOrbitControls";
21
21
  import { MeshNodeTool } from "./Utils/MeshNodeTool";
22
22
  import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
23
+ import { exposureExponent, DEFAULT_TARGET_GREY } from "./Utils/volumeExposure";
24
+ import { disposeObject3D, disposeMaterial } from "./Utils/dispose";
25
+ import { collectFadeTargets, setFade, restoreFade, } from "./Utils/modelCrossfade";
26
+ import { createSceneBudget, defaultBudgetBytes } from "./Renderer/sceneBudget";
27
+ import { disposeScene, removeSceneFromMap } from "./Renderer/disposeScene";
28
+ import { fitDistance } from "./Controls/orbitFraming";
29
+ import { fitView } from "./Controls/fitView";
30
+ import { easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, } from "./Controls/cameraTransitions";
31
+ import { installFastSliceRepaint } from "./Loader/fastSliceRepaint";
23
32
  import { SurfaceAnnotator } from "./Utils/surfaceAnnotation";
24
33
  import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
25
34
  import "./css/style.css";
@@ -41,5 +50,5 @@ if (typeof window !== "undefined") {
41
50
  if (typeof console !== "undefined") {
42
51
  console.log(`%cCopper3D Visualisation %c${REVISION}`, "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
43
52
  }
44
- export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, 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, };
53
+ export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, 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, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
45
54
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":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AAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,SAAS,EACT,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,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,eAAe,EACf,uBAAuB,GACxB,CAAC"}
@@ -0,0 +1,87 @@
1
+ import type { CameraViewPreset } from './orbitFraming';
2
+ /**
3
+ * Camera pose interpolation: the math behind flying a camera from one view
4
+ * preset to another, orbiting it a step at a time, and zooming it.
5
+ *
6
+ * Deliberately dependency-free -- plain numbers and `[x, y, z]` tuples, no
7
+ * `three` -- for two reasons. It is unit-testable with no WebGL, and a
8
+ * consumer that has its own copy of three (a bundler that did not dedupe, or
9
+ * an app importing three alongside a bundled build) can use it without any
10
+ * object crossing that boundary.
11
+ */
12
+ /** A camera pose. `target` is the look-at point -- the controls' orbit
13
+ * pivot, not the camera's own position. */
14
+ export interface Pose {
15
+ position: [number, number, number];
16
+ up: [number, number, number];
17
+ target: [number, number, number];
18
+ }
19
+ export declare function easeInOutCubic(t: number): number;
20
+ /** Reads a view preset as a `Pose`, so a flight's destination is built from
21
+ * the same data an instant `loadView` would apply. */
22
+ export declare function viewPointToPose(vp: CameraViewPreset): Pose;
23
+ type Vec3Tuple = [number, number, number];
24
+ /**
25
+ * Rodrigues' rotation formula: rotates `v` by `angleRad` around `axis` (which
26
+ * need not be pre-normalized). Unlike slerping between two vectors, this has
27
+ * no degeneracy at any angle including a half turn -- the axis is given, not
28
+ * derived from a dot product between vectors that might be antiparallel.
29
+ */
30
+ export declare function rotateAroundAxis(v: Vec3Tuple, axis: Vec3Tuple, angleRad: number): Vec3Tuple;
31
+ /**
32
+ * Interpolates a camera between two poses. `t` is expected already eased --
33
+ * this has no timing concerns of its own, which is what makes it testable
34
+ * without a clock.
35
+ *
36
+ * The pivot lerps from one target to the other, and the camera's ORIENTATION
37
+ * (both its direction from the pivot and its up vector) is carried by a
38
+ * single rotation built from the two poses' full orthonormal bases -- not by
39
+ * interpolating `dir` and `up` independently.
40
+ *
41
+ * That is a correctness requirement, not a style choice. Real preset data
42
+ * routinely contains antipodal up vectors on the same view axis (two views
43
+ * of the same volume authored from opposite conventions). A plain
44
+ * `lerp(upFrom, upTo, t)` passes through the zero vector at t=0.5, where
45
+ * `normalize` has no correct answer: the camera holds upside-down, then
46
+ * snaps 180 degrees in one frame. Composing the two bases into a relative
47
+ * rotation makes that case a well-defined 180-degree roll about the shared
48
+ * axis -- a smooth roll through the midpoint. The same construction covers
49
+ * two antipodal camera positions about one target.
50
+ *
51
+ * Reproduces `from.position` exactly at t=0 and `to.position` at t=1. `up` is
52
+ * likewise exact WHEN each pose's own `up` is already perpendicular to its
53
+ * own view direction; one that leans toward the view axis is silently
54
+ * squared up, which is by design -- it is not a meaningful camera roll.
55
+ */
56
+ export declare function interpolateFlightPose(from: Pose, to: Pose, t: number): Pose;
57
+ /** The camera's orbit radius: how far `pose.position` sits from the pivot it
58
+ * looks at. Lets a push-in be expressed as an absolute target distance
59
+ * (idempotent) rather than a repeated fractional step. */
60
+ export declare function poseDistance(pose: Pose): number;
61
+ /**
62
+ * Orbits the camera around its own pivot by `yawRad` about its up vector,
63
+ * then by `pitchRad` about the RESULTING right vector. The pivot and the
64
+ * orbit radius are both untouched, so a run of steps can never walk the
65
+ * camera away from what it is looking at.
66
+ *
67
+ * Pitch about the yawed right vector, not the original: rotating about a
68
+ * stale axis makes a diagonal (left+up) combination drift off the sphere
69
+ * instead of tracing it.
70
+ */
71
+ export declare function orbitStepPose(pose: Pose, yawRad: number, pitchRad: number): Pose;
72
+ /**
73
+ * Scales the camera's distance from its pivot by `factor` along the unchanged
74
+ * view direction. Clamped at `minDistance` because a zero radius has no
75
+ * direction to normalize -- a held zoom-in key would otherwise collapse the
76
+ * pose into NaN one frame after reaching the pivot.
77
+ */
78
+ export declare function zoomPose(pose: Pose, factor: number, minDistance?: number): Pose;
79
+ /**
80
+ * Swing angle for an entrance orbit. `turns` is a SWING AMPLITUDE, not a net
81
+ * rotation: `sin(t*pi)` goes out and comes back to zero, so the camera always
82
+ * ends exactly on the framed preset view (t=1 -> angle 0) however large
83
+ * `turns` is. Do not "fix" this into a net rotation; that ends the intro
84
+ * off-preset.
85
+ */
86
+ export declare function orbitSwingAngle(t: number, turns: number): number;
87
+ export {};
@@ -0,0 +1,45 @@
1
+ import type { CameraViewPreset, FitBounds } from './orbitFraming';
2
+ /**
3
+ * Re-frames a scene on its content, keeping the view preset's direction.
4
+ *
5
+ * A preset carries a hand-written `eyePosition`, which encodes both which way
6
+ * a reader should look at the data and how far away -- but only the direction
7
+ * is a decision. The distance has to follow the viewport: a fixed one cannot
8
+ * survive a viewport that is a third as wide as the one it was authored
9
+ * against, and hand-written values routinely leave the content filling a
10
+ * quarter of the frame.
11
+ *
12
+ * So the preset's view direction and up vector are kept exactly as authored
13
+ * and only the distance is recomputed.
14
+ *
15
+ * Written as a free function taking the scene as its first argument, so it
16
+ * can be called on an existing scene instance and unit-tested without a
17
+ * renderer. The scene class wraps it as a one-line method.
18
+ */
19
+ interface Vec3Like {
20
+ set: (x: number, y: number, z: number) => void;
21
+ }
22
+ export interface FitViewScene {
23
+ camera: {
24
+ fov: number;
25
+ position: Vec3Like;
26
+ lookAt: (x: number, y: number, z: number) => void;
27
+ updateProjectionMatrix: () => void;
28
+ };
29
+ controls: {
30
+ /** OrbitControls / TrackballControls' orbit pivot. */
31
+ target?: Vec3Like;
32
+ /** TrackballControls caches the canvas's page box and recomputes it only
33
+ * here; OrbitControls measures per event and does not define this. */
34
+ handleResize?: () => void;
35
+ };
36
+ }
37
+ /**
38
+ * Returns false when there is nothing to do -- a preset whose eye sits
39
+ * exactly on its target has no direction to preserve.
40
+ *
41
+ * Does NOT render. The caller decides when to draw, which matters under
42
+ * on-demand rendering where this may be one of several changes in a frame.
43
+ */
44
+ export declare function fitView(scene: FitViewScene, preset: CameraViewPreset, aspect: number, bounds: FitBounds, margin?: number): boolean;
45
+ export {};
@@ -69,3 +69,42 @@ export declare function resolveViewPose(preset: CameraViewPreset, pivot: THREE.V
69
69
  * frameBox, OrbitControls' maxDistance is still the default Infinity.
70
70
  */
71
71
  export declare function resolveFarPlane(presetFar: number, maxDistance: number, dist: number): number;
72
+ export interface FitBounds {
73
+ width: number;
74
+ height: number;
75
+ depth: number;
76
+ /** The box's centre in scene units. `[0, 0, 0]` for an NRRD volume, whose
77
+ * RAS dimensions describe a box centred on the origin; a GLB's is not,
78
+ * so framing one from the origin leaves part of it out of frame. Not read
79
+ * by `fitDistance`, which only needs the extents. */
80
+ center: [number, number, number];
81
+ }
82
+ /**
83
+ * How far a perspective camera must sit from an object's centre for the whole
84
+ * object to fit in frame.
85
+ *
86
+ * Unlike `computeFraming` above this takes the viewport's ASPECT into
87
+ * account: below aspect 1 the horizontal field is the narrower of the two,
88
+ * and it is the narrower one that has to contain the object. A camera framed
89
+ * on vertical FOV alone under-frames every tall, narrow viewport.
90
+ *
91
+ * It also fits the bounding SPHERE rather than the box. Fitting the facing
92
+ * box face plus half the depth frames each object by whichever dimension
93
+ * happens to point at the camera, so a thin slab and a near-cubic volume of
94
+ * similar overall extent come out at wildly different sizes on screen. A
95
+ * sphere has no orientation, so comparable objects get comparable screen
96
+ * size -- and orbiting can no longer push a corner out of frame.
97
+ *
98
+ * @param aspect Viewport width / height. Zero or non-finite is treated as 1:
99
+ * a viewport mid-collapse measures 0 for a frame, and NaN in a
100
+ * projection matrix is unrecoverable.
101
+ * @param fovDeg The camera's VERTICAL field of view, in degrees.
102
+ * @param margin Multiplier applied at the end, and deliberately BELOW 1. A
103
+ * bounding sphere circumscribes the object -- a cube's has
104
+ * 1.73x its half-side -- so fitting the sphere exactly leaves
105
+ * the object filling well under half the frame. Letting the
106
+ * sphere overflow is what makes the object read at a sensible
107
+ * size. A tuning knob, not a correctness threshold: smaller
108
+ * means larger on screen.
109
+ */
110
+ export declare function fitDistance(bounds: FitBounds, aspect: number, fovDeg: number, margin?: number): number;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Replaces a `VolumeSlice`'s `repaint` with an equivalent that does not
3
+ * rebuild the world on every scrub step, and can optionally lift its
4
+ * mid-tones.
5
+ *
6
+ * ## What the original does, per slice change
7
+ *
8
+ * Setting `slice.index` sets `geometryNeedsUpdate`, so the next `repaint()`
9
+ * runs `updateGeometry()` first. That method unconditionally:
10
+ *
11
+ * - assigns `canvas.width` / `canvas.height` and the same on `canvasBuffer`
12
+ * -- assigning either RESETS the whole 2D backing store even when the
13
+ * value is unchanged;
14
+ * - re-fetches both 2D contexts;
15
+ * - calls `geometry.dispose()` and builds a `new PlaneGeometry(...)`, i.e.
16
+ * deletes and recreates GPU buffers, every frame.
17
+ *
18
+ * Then `repaint()` calls `ctx.getImageData(...)`, a full canvas read-back
19
+ * that allocates a fresh `Uint8ClampedArray` -- every pixel of which is
20
+ * overwritten by the loop immediately below it, so the read is pure waste.
21
+ *
22
+ * Within one volume and one axis, `planeWidth`, `planeHeight`, `iLength` and
23
+ * `jLength` are the same for every slice; only `sliceAccess` and `matrix`
24
+ * differ. So all of the above is redundant on every scrub step but the first.
25
+ *
26
+ * Measured in a real browser while dragging a slice plane: 59 long tasks
27
+ * (>50ms) in ~2s and a p90 frame time of 61ms, against zero long tasks for
28
+ * the same drag on a scene that rotates but never repaints.
29
+ *
30
+ * `VolumeSlice` comes from three rather than from this library, and there is
31
+ * no option for any of this, so replacing the method per instance is the
32
+ * available lever.
33
+ *
34
+ * ## Fidelity
35
+ *
36
+ * The pixel loop is copied from the original, byte for byte in its
37
+ * arithmetic, threshold and window-level handling included. The differences
38
+ * are the ones above -- cached `ImageData`, geometry work skipped while the
39
+ * plane dimensions are unchanged -- plus the optional exposure LUT, which is
40
+ * the one thing here that changes what a pixel comes out as. `label` volumes
41
+ * are handed back to the original implementation.
42
+ */
43
+ /**
44
+ * Idempotent: patching an already-patched slice is a no-op.
45
+ *
46
+ * `exposure` is a gamma exponent, normally from `exposureExponent()`; 1
47
+ * leaves greyscale exactly as the original produced it.
48
+ *
49
+ * CALL THIS BEFORE THE FIRST PAINT. The LUT lives in the patched method, so
50
+ * painting first draws one un-lifted frame and corrects it on the reader's
51
+ * first scrub -- a visible colour change.
52
+ *
53
+ * Async only because `PlaneGeometry` is imported on demand, to keep three out
54
+ * of a consumer's initial chunk when nothing scrubs a slice.
55
+ */
56
+ export declare function installFastSliceRepaint(rawSlice: unknown, exposure?: number): Promise<void>;
@@ -1,10 +1,18 @@
1
1
  import { baseRenderer } from "./baseRenderer";
2
- import { ICopperRenderOpt } from "../types/types";
2
+ import { ICopperRenderOpt, SceneMapType } from "../types/types";
3
3
  import { copperSceneOnDemond } from "../Scene/copperSceneOnDemond";
4
4
  export declare class copperRendererOnDemond extends baseRenderer {
5
- private sceneMap;
5
+ /** Public so `disposeScene` can unregister an entry. Nothing else removes
6
+ * one, so a long-lived renderer otherwise accumulates every scene it has
7
+ * ever built, decoded volumes included. */
8
+ sceneMap: SceneMapType;
6
9
  constructor(container: HTMLDivElement, options?: ICopperRenderOpt);
7
10
  getSceneByName(name: string): import("..").copperScene | import("../Scene/baseScene").baseScene | import("..").copperMScene;
11
+ /**
12
+ * Unregisters a scene and frees its geometries, materials and textures.
13
+ * Returns the scene that was disposed, or undefined if there was none.
14
+ */
15
+ disposeScene(name: string): import("./disposeScene").DisposableScene | undefined;
8
16
  setCurrentScene(sceneIn: copperSceneOnDemond): void;
9
17
  createScene(name: string): copperSceneOnDemond | undefined;
10
18
  animate: () => void;
@@ -0,0 +1,47 @@
1
+ import type { DisposableObject3D } from '../Utils/dispose';
2
+ /**
3
+ * Removes a scene from a renderer's map and frees what it holds.
4
+ *
5
+ * There is otherwise no way out of `sceneMap` at all: nothing in copper3d
6
+ * removes an entry, so a long-lived renderer accumulates every scene it has
7
+ * ever built, decoded volumes included.
8
+ *
9
+ * Written as a free function so it can be called on a renderer instance the
10
+ * caller already has, and unit-tested against a plain object. The renderer
11
+ * class wraps it as a one-line method.
12
+ */
13
+ /** The parts of a scene this needs. Structural, so a test does not have to
14
+ * build a real one. */
15
+ export interface DisposableScene {
16
+ scene: {
17
+ children: DisposableObject3D[];
18
+ remove: (object: any) => void;
19
+ };
20
+ controls: {
21
+ enabled: boolean;
22
+ /** Narrowed to the one event this removes, so it accepts both a
23
+ * `string`-typed emitter and one already narrowed to its own events. */
24
+ removeEventListener?: (type: 'change', listener: () => void) => void;
25
+ };
26
+ requestRenderIfNotRequested: () => void;
27
+ }
28
+ export interface SceneDisposalHost<S extends DisposableScene = DisposableScene> {
29
+ sceneMap: Record<string, S>;
30
+ getSceneByName: (name: string) => S | undefined;
31
+ }
32
+ /**
33
+ * Unregisters a scene WITHOUT freeing anything, for callers re-registering it
34
+ * under a different name.
35
+ *
36
+ * Throws if the entry survives removal. `delete` on a missing property is a
37
+ * silent no-op, so restructuring `sceneMap` into a real `Map` would stop
38
+ * eviction working with no crash and no type error -- the map would grow
39
+ * without bound again, invisibly. Confirming through the host's own accessor
40
+ * fails loudly instead.
41
+ */
42
+ export declare function removeSceneFromMap(host: SceneDisposalHost<any>, name: string): void;
43
+ /**
44
+ * Unregisters a scene and frees everything in it. Returns the scene that was
45
+ * disposed, or `undefined` if there was none under that name.
46
+ */
47
+ export declare function disposeScene<S extends DisposableScene>(host: SceneDisposalHost<S>, name: string): S | undefined;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * How much decoded scene data may stay resident, as a byte budget with LRU
3
+ * eviction and pinning.
4
+ *
5
+ * Bytes rather than a scene count, because a count is not the thing at risk:
6
+ * an NRRD volume can be 51KB or 53MB on disk and decodes to a typed array
7
+ * larger still, so "three scenes" is anywhere from 150KB to 250MB.
8
+ *
9
+ * Whatever is on screen should be pinned and is never a victim, however far
10
+ * over the limit that puts the total. Blanking a view the reader is looking
11
+ * at is strictly worse than the memory it saves -- and with several viewports
12
+ * sharing one renderer, more than one scene is visible at a time.
13
+ */
14
+ export interface SceneBudget {
15
+ /** Records (or re-records) a resident scene's decoded size and marks it
16
+ * most-recently-used. */
17
+ register: (key: string, bytes: number) => void;
18
+ /** Marks an already-registered scene most-recently-used. No-op if absent. */
19
+ touch: (key: string) => void;
20
+ /** Protects a scene from eviction while it is on screen. */
21
+ pin: (key: string) => void;
22
+ unpin: (key: string) => void;
23
+ /** Forgets a scene entirely. Call after its GPU resources are freed. */
24
+ release: (key: string) => void;
25
+ /** Carries bytes, queue position and pin state to a new key, for callers
26
+ * that rename a scene in place. */
27
+ rename: (from: string, to: string) => void;
28
+ /** Keys to evict, least-recently-used first, never pinned. Empty when the
29
+ * total is within budget or nothing evictable is left. */
30
+ overflow: () => string[];
31
+ bytes: () => number;
32
+ }
33
+ /**
34
+ * `deviceMemory` is a Chromium-only hint in GiB, absent in Safari and every
35
+ * iOS browser. Absent must mean the SMALL budget: an iPad is both the device
36
+ * that omits the API and the one most likely to have its tab killed for using
37
+ * too much.
38
+ */
39
+ export declare function defaultBudgetBytes(deviceMemoryGiB?: number): number;
40
+ export declare function createSceneBudget(limitBytes: number): SceneBudget;
@@ -1,12 +1,24 @@
1
1
  import * as THREE from "three";
2
2
  import { baseScene } from "./baseScene";
3
3
  import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
4
+ import { CameraViewPoint } from "../Controls/copperControls";
5
+ import type { FitBounds } from "../Controls/orbitFraming";
4
6
  export declare class copperSceneOnDemond extends baseScene {
5
7
  controls: OrbitControls;
6
8
  renderRequested: boolean | undefined;
7
9
  isResize: boolean;
8
10
  constructor(container: HTMLDivElement, renderer: THREE.WebGLRenderer);
9
11
  loadGltf(url: string, callback?: (content: THREE.Group) => void): void;
12
+ /**
13
+ * Re-frames the camera on `bounds`, keeping the preset's view direction and
14
+ * up and replacing only its distance. Returns false when there is nothing
15
+ * to do -- an orthographic camera (no field of view to fit against), or a
16
+ * preset whose eye sits exactly on its target.
17
+ *
18
+ * Does not render: the caller decides when to draw, which matters here
19
+ * because this scene renders on demand.
20
+ */
21
+ fitView(preset: CameraViewPoint, aspect: number, bounds: FitBounds, margin?: number): boolean;
10
22
  confirmResize: () => void;
11
23
  render: () => void;
12
24
  requestRenderIfNotRequested: () => void;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Frees the GPU resources behind an object that is no longer displayed.
3
+ *
4
+ * `scene.remove()` only unlinks: three keeps the geometry's buffers and the
5
+ * material's textures uploaded until they are disposed explicitly. Nothing in
6
+ * copper3d disposes what it creates, so anything that swaps models or evicts
7
+ * scenes needs this or its footprint is unbounded.
8
+ *
9
+ * Typed structurally rather than against `THREE.Object3D` so it also accepts
10
+ * the minimal shapes callers and tests hand around; a real three object
11
+ * satisfies these interfaces.
12
+ */
13
+ interface Disposable {
14
+ dispose: () => void;
15
+ }
16
+ /** A material and the texture slots three's built-in materials use. All
17
+ * optional: any given material has only some of them. */
18
+ export interface DisposableMaterial extends Disposable {
19
+ map?: Disposable | null;
20
+ normalMap?: Disposable | null;
21
+ roughnessMap?: Disposable | null;
22
+ metalnessMap?: Disposable | null;
23
+ aoMap?: Disposable | null;
24
+ emissiveMap?: Disposable | null;
25
+ alphaMap?: Disposable | null;
26
+ bumpMap?: Disposable | null;
27
+ displacementMap?: Disposable | null;
28
+ envMap?: Disposable | null;
29
+ lightMap?: Disposable | null;
30
+ specularMap?: Disposable | null;
31
+ }
32
+ export interface DisposableObject3D {
33
+ traverse: (callback: (child: any) => void) => void;
34
+ }
35
+ /**
36
+ * `Material.dispose()` does NOT cascade into its textures, so a canvas-backed
37
+ * or image-backed map stays on the GPU without this. Handles the array form
38
+ * too: a multi-material mesh would otherwise reach `Array.prototype.dispose`,
39
+ * which does not exist.
40
+ */
41
+ export declare function disposeMaterial(material: DisposableMaterial | DisposableMaterial[] | null | undefined): void;
42
+ /**
43
+ * Works on a lone mesh as well as on a whole subtree -- `traverse` visits the
44
+ * root itself -- so a slice plane that was never added to a scene is freed by
45
+ * the same call.
46
+ */
47
+ export declare function disposeObject3D(root: DisposableObject3D): void;
48
+ export {};
@@ -0,0 +1,36 @@
1
+ import type { DisposableObject3D } from './dispose';
2
+ /**
3
+ * Crossfading one model into another in the same scene.
4
+ *
5
+ * Split into capture / apply / restore so the caller owns the timing: the
6
+ * fade is driven frame by frame from whatever animation loop it already has,
7
+ * rather than this starting a second one.
8
+ */
9
+ export interface FadeableMaterial {
10
+ opacity: number;
11
+ transparent: boolean;
12
+ depthWrite: boolean;
13
+ }
14
+ /** One mesh material enrolled in a crossfade, together with the appearance it
15
+ * had before the fade started. */
16
+ export interface FadeTarget {
17
+ material: FadeableMaterial;
18
+ opacity: number;
19
+ transparent: boolean;
20
+ depthWrite: boolean;
21
+ }
22
+ export declare function collectFadeTargets(root: DisposableObject3D): FadeTarget[];
23
+ /**
24
+ * Scales each material toward transparent by `factor`, RELATIVE to the
25
+ * opacity it already had. Scaling rather than assigning is what keeps an
26
+ * already-translucent material translucent: `opacity = factor` would end
27
+ * every crossfade with it fully opaque.
28
+ *
29
+ * `depthWrite` is suppressed for the whole fade and only restored at the
30
+ * fully-opaque end. A partially transparent mesh that still writes depth
31
+ * occludes everything drawn behind it, so a fade with depth writing left on
32
+ * shows the outgoing model punching holes in the incoming one.
33
+ */
34
+ export declare function setFade(targets: FadeTarget[], factor: number): void;
35
+ /** Puts each material back exactly as `collectFadeTargets` found it. */
36
+ export declare function restoreFade(targets: FadeTarget[]): void;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * How much to lift a volume's mid-tones so its tissue is actually readable.
3
+ *
4
+ * A slice is painted with `(raw - windowLow) * 255 / (windowHigh - windowLow)`
5
+ * and the NRRD loader sets that window to the volume's own min/max. When the
6
+ * max is a handful of bright outliers -- normal on a contrast-enhanced MRI --
7
+ * the tissue ends up in the bottom of the range and the image reads as dark.
8
+ *
9
+ * The answer here is a gamma curve, `out = 255 * (in / 255) ** exponent`,
10
+ * applied on top of that window rather than replacing it. Narrowing the window
11
+ * instead cannot work: any linear window bright enough to lift the tissue
12
+ * saturates the top of the range, and on a contrast-enhanced study the lesion
13
+ * IS the top of the range. Gamma is monotonic and fixes both ends, so nothing
14
+ * clips however far the middle is raised.
15
+ */
16
+ /** The parts of a loaded volume this reads. Structural rather than the
17
+ * loader's own type, so it is testable without building one. */
18
+ export interface ExposureVolume {
19
+ data: ArrayLike<number>;
20
+ min: number;
21
+ max: number;
22
+ }
23
+ /** Where the median tissue voxel should land on the 0-255 greyscale. */
24
+ export declare const DEFAULT_TARGET_GREY = 75;
25
+ /**
26
+ * The gamma exponent that puts `volume`'s median tissue voxel on
27
+ * `targetGrey`, or 1 when it needs no lift or cannot be measured.
28
+ *
29
+ * Solving per volume is what makes volumes with wildly different maxima come
30
+ * out looking alike.
31
+ */
32
+ export declare function exposureExponent(volume: ExposureVolume, targetGrey?: number): number;
@@ -18,6 +18,23 @@ import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls"
18
18
  import { Copper3dOrbitControls } from "./Controls/Copper3dOrbitControls";
19
19
  import { MeshNodeTool } from "./Utils/MeshNodeTool";
20
20
  import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
21
+ import { exposureExponent, DEFAULT_TARGET_GREY } from "./Utils/volumeExposure";
22
+ import type { ExposureVolume } from "./Utils/volumeExposure";
23
+ import { disposeObject3D, disposeMaterial } from "./Utils/dispose";
24
+ import type { DisposableObject3D, DisposableMaterial } from "./Utils/dispose";
25
+ import { collectFadeTargets, setFade, restoreFade } from "./Utils/modelCrossfade";
26
+ import type { FadeTarget, FadeableMaterial } from "./Utils/modelCrossfade";
27
+ import { createSceneBudget, defaultBudgetBytes } from "./Renderer/sceneBudget";
28
+ import type { SceneBudget } from "./Renderer/sceneBudget";
29
+ import { disposeScene, removeSceneFromMap } from "./Renderer/disposeScene";
30
+ import type { DisposableScene, SceneDisposalHost } from "./Renderer/disposeScene";
31
+ import { fitDistance } from "./Controls/orbitFraming";
32
+ import type { FitBounds } from "./Controls/orbitFraming";
33
+ import { fitView } from "./Controls/fitView";
34
+ import type { FitViewScene } from "./Controls/fitView";
35
+ import { easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle } from "./Controls/cameraTransitions";
36
+ import type { Pose } from "./Controls/cameraTransitions";
37
+ import { installFastSliceRepaint } from "./Loader/fastSliceRepaint";
21
38
  import { SurfaceAnnotator } from "./Utils/surfaceAnnotation";
22
39
  import type { SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions } from "./Utils/surfaceAnnotation";
23
40
  import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController } from "./types/types";
@@ -30,6 +47,6 @@ import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
30
47
  import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from "./Utils/segmentation/tools/AiAssistTool";
31
48
  import "./css/style.css";
32
49
  export declare const REVISION: string;
33
- export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, 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, };
34
- export type { positionType, screenPosType, optsType, 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, };
50
+ export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, 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, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
51
+ export type { positionType, screenPosType, optsType, 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, Pose, };
35
52
  export type { CameraViewPreset } from "./Controls/orbitFraming";
package/package.json CHANGED
@@ -1,14 +1,16 @@
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.7.4",
4
+ "version": "3.8.1",
5
5
  "main": "dist/bundle.umd.js",
6
6
  "moudle": "dist/bundle.esm.js",
7
7
  "types": "dist/types/index.d.ts",
8
8
  "scripts": {
9
9
  "build": "tsc && rollup -c rollup.config.js",
10
10
  "build:t": "rollup -c rollup.config.js",
11
- "test": "echo \"Error: no test specified\" && exit 1"
11
+ "test": "vitest run",
12
+ "test:watch": "vitest",
13
+ "bench": "vitest bench"
12
14
  },
13
15
  "files": [
14
16
  "dist"
@@ -35,6 +37,7 @@
35
37
  "@rollup/plugin-replace": "^4.0.0",
36
38
  "@rollup/plugin-typescript": "^8.3.2",
37
39
  "@types/file-saver": "^2.0.5",
40
+ "jsdom": "^29.1.1",
38
41
  "postcss": "^8.4.14",
39
42
  "rollup": "^2.74.1",
40
43
  "rollup-plugin-commonjs": "^10.1.0",
@@ -44,7 +47,8 @@
44
47
  "rollup-plugin-sourcemaps": "^0.6.3",
45
48
  "rollup-plugin-terser": "^7.0.2",
46
49
  "rollup-plugin-typescript2": "^0.31.2",
47
- "typescript": "^5.9.3"
50
+ "typescript": "^5.9.3",
51
+ "vitest": "^4.1.10"
48
52
  },
49
53
  "dependencies": {
50
54
  "@types/dat.gui": "^0.7.9",