copper3d 3.7.5 → 3.9.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.
- package/dist/Controls/Copper3dTrackballControls.d.ts +25 -1
- package/dist/Controls/Copper3dTrackballControls.js +20 -0
- package/dist/Controls/Copper3dTrackballControls.js.map +1 -1
- package/dist/Controls/cameraTransitions.d.ts +87 -0
- package/dist/Controls/cameraTransitions.js +285 -0
- package/dist/Controls/cameraTransitions.js.map +1 -0
- package/dist/Controls/controlsAxes.d.ts +31 -0
- package/dist/Controls/controlsAxes.js +63 -0
- package/dist/Controls/controlsAxes.js.map +1 -0
- package/dist/Controls/fitView.d.ts +45 -0
- package/dist/Controls/fitView.js +40 -0
- package/dist/Controls/fitView.js.map +1 -0
- package/dist/Controls/gestureGate.d.ts +48 -0
- package/dist/Controls/gestureGate.js +67 -0
- package/dist/Controls/gestureGate.js.map +1 -0
- package/dist/Controls/orbitFraming.d.ts +39 -0
- package/dist/Controls/orbitFraming.js +39 -0
- package/dist/Controls/orbitFraming.js.map +1 -1
- package/dist/Controls/setCameraPose.d.ts +50 -0
- package/dist/Controls/setCameraPose.js +20 -0
- package/dist/Controls/setCameraPose.js.map +1 -0
- package/dist/Loader/copperGltfLoader.d.ts +35 -0
- package/dist/Loader/copperGltfLoader.js +43 -2
- package/dist/Loader/copperGltfLoader.js.map +1 -1
- package/dist/Loader/copperNrrdLoader.d.ts +47 -0
- package/dist/Loader/copperNrrdLoader.js +88 -42
- package/dist/Loader/copperNrrdLoader.js.map +1 -1
- package/dist/Loader/fastSliceRepaint.d.ts +56 -0
- package/dist/Loader/fastSliceRepaint.js +159 -0
- package/dist/Loader/fastSliceRepaint.js.map +1 -0
- package/dist/Loader/volumeBoundingBox.d.ts +44 -0
- package/dist/Loader/volumeBoundingBox.js +32 -0
- package/dist/Loader/volumeBoundingBox.js.map +1 -0
- package/dist/Renderer/copperRendererOnDemond.d.ts +21 -3
- package/dist/Renderer/copperRendererOnDemond.js +26 -2
- package/dist/Renderer/copperRendererOnDemond.js.map +1 -1
- package/dist/Renderer/disposeScene.d.ts +51 -0
- package/dist/Renderer/disposeScene.js +51 -0
- package/dist/Renderer/disposeScene.js.map +1 -0
- package/dist/Renderer/sceneBudget.d.ts +40 -0
- package/dist/Renderer/sceneBudget.js +86 -0
- package/dist/Renderer/sceneBudget.js.map +1 -0
- package/dist/Scene/copperMScene.d.ts +2 -1
- package/dist/Scene/copperMScene.js +4 -4
- package/dist/Scene/copperMScene.js.map +1 -1
- package/dist/Scene/copperScene.d.ts +2 -1
- package/dist/Scene/copperScene.js +6 -4
- package/dist/Scene/copperScene.js.map +1 -1
- package/dist/Scene/copperSceneOnDemond.d.ts +66 -3
- package/dist/Scene/copperSceneOnDemond.js +103 -7
- package/dist/Scene/copperSceneOnDemond.js.map +1 -1
- package/dist/Utils/dispose.d.ts +48 -0
- package/dist/Utils/dispose.js +60 -0
- package/dist/Utils/dispose.js.map +1 -0
- package/dist/Utils/kiwrious/configKiwrious.d.ts +23 -1
- package/dist/Utils/kiwrious/configKiwrious.js +154 -42
- package/dist/Utils/kiwrious/configKiwrious.js.map +1 -1
- package/dist/Utils/modelCrossfade.d.ts +36 -0
- package/dist/Utils/modelCrossfade.js +46 -0
- package/dist/Utils/modelCrossfade.js.map +1 -0
- package/dist/Utils/volumeExposure.d.ts +32 -0
- package/dist/Utils/volumeExposure.js +104 -0
- package/dist/Utils/volumeExposure.js.map +1 -0
- package/dist/bundle.esm.js +63653 -51923
- package/dist/bundle.umd.js +63701 -51933
- package/dist/index.d.ts +32 -3
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/dist/types/Controls/Copper3dTrackballControls.d.ts +25 -1
- package/dist/types/Controls/cameraTransitions.d.ts +87 -0
- package/dist/types/Controls/controlsAxes.d.ts +31 -0
- package/dist/types/Controls/fitView.d.ts +45 -0
- package/dist/types/Controls/gestureGate.d.ts +48 -0
- package/dist/types/Controls/orbitFraming.d.ts +39 -0
- package/dist/types/Controls/setCameraPose.d.ts +50 -0
- package/dist/types/Loader/copperGltfLoader.d.ts +35 -0
- package/dist/types/Loader/copperNrrdLoader.d.ts +47 -0
- package/dist/types/Loader/fastSliceRepaint.d.ts +56 -0
- package/dist/types/Loader/volumeBoundingBox.d.ts +44 -0
- package/dist/types/Renderer/copperRendererOnDemond.d.ts +21 -3
- package/dist/types/Renderer/disposeScene.d.ts +51 -0
- package/dist/types/Renderer/sceneBudget.d.ts +40 -0
- package/dist/types/Scene/copperMScene.d.ts +2 -1
- package/dist/types/Scene/copperScene.d.ts +2 -1
- package/dist/types/Scene/copperSceneOnDemond.d.ts +66 -3
- package/dist/types/Utils/dispose.d.ts +48 -0
- package/dist/types/Utils/kiwrious/configKiwrious.d.ts +23 -1
- package/dist/types/Utils/modelCrossfade.d.ts +36 -0
- package/dist/types/Utils/volumeExposure.d.ts +32 -0
- package/dist/types/index.d.ts +32 -3
- package/package.json +7 -3
package/dist/index.d.ts
CHANGED
|
@@ -4,13 +4,15 @@ import { copperScene } from "./Scene/copperScene";
|
|
|
4
4
|
import { CameraViewPoint } from "./Controls/copperControls";
|
|
5
5
|
import { addLabelToScene, positionType, screenPosType, convert3DPostoScreenPos, convertScreenPosto3DPos } from "./Utils/add3DLabel";
|
|
6
6
|
import { addBoxHelper, optsType } from "./Loader/copperNrrdLoader";
|
|
7
|
+
import { copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath } from "./Loader/copperGltfLoader";
|
|
8
|
+
import type { GltfLoadOpts } from "./Loader/copperGltfLoader";
|
|
7
9
|
import { fullScreenListenner, loading, throttle } from "./Utils/utils";
|
|
8
10
|
import { copperRendererOnDemond } from "./Renderer/copperRendererOnDemond";
|
|
9
11
|
import { copperSceneOnDemond } from "./Scene/copperSceneOnDemond";
|
|
10
12
|
import { copperMSceneRenderer } from "./Renderer/copperMSceneRenderer";
|
|
11
13
|
import { copperMScene } from "./Scene/copperMScene";
|
|
12
14
|
import { createTexture2D_NRRD } from "./Utils/texture2d";
|
|
13
|
-
import { configKiwriousHeart } from "./Utils/kiwrious/configKiwrious";
|
|
15
|
+
import { configKiwriousHeart, loadKiwrious } from "./Utils/kiwrious/configKiwrious";
|
|
14
16
|
import kiwrious from "./Utils/kiwrious/configKiwrious";
|
|
15
17
|
import { NrrdTools } from "./Utils/segmentation/NrrdTools";
|
|
16
18
|
import { GaussianSmoother } from "./Utils/segmentation/core/GaussianSmoother";
|
|
@@ -18,6 +20,33 @@ import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls"
|
|
|
18
20
|
import { Copper3dOrbitControls } from "./Controls/Copper3dOrbitControls";
|
|
19
21
|
import { MeshNodeTool } from "./Utils/MeshNodeTool";
|
|
20
22
|
import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
|
|
23
|
+
import { exposureExponent, DEFAULT_TARGET_GREY } from "./Utils/volumeExposure";
|
|
24
|
+
import type { ExposureVolume } from "./Utils/volumeExposure";
|
|
25
|
+
import { disposeObject3D, disposeMaterial } from "./Utils/dispose";
|
|
26
|
+
import type { DisposableObject3D, DisposableMaterial } from "./Utils/dispose";
|
|
27
|
+
import { collectFadeTargets, setFade, restoreFade } from "./Utils/modelCrossfade";
|
|
28
|
+
import type { FadeTarget, FadeableMaterial } from "./Utils/modelCrossfade";
|
|
29
|
+
import { createSceneBudget, defaultBudgetBytes } from "./Renderer/sceneBudget";
|
|
30
|
+
import type { SceneBudget } from "./Renderer/sceneBudget";
|
|
31
|
+
import { disposeScene, removeSceneFromMap } from "./Renderer/disposeScene";
|
|
32
|
+
import type { DisposableScene, SceneDisposalHost } from "./Renderer/disposeScene";
|
|
33
|
+
import { fitDistance } from "./Controls/orbitFraming";
|
|
34
|
+
import type { FitBounds } from "./Controls/orbitFraming";
|
|
35
|
+
import { fitView } from "./Controls/fitView";
|
|
36
|
+
import type { FitViewScene } from "./Controls/fitView";
|
|
37
|
+
import { isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled } from "./Controls/controlsAxes";
|
|
38
|
+
import type { AxisGatedControls } from "./Controls/controlsAxes";
|
|
39
|
+
import { beginGesture, isGestureActive } from "./Controls/gestureGate";
|
|
40
|
+
import type { GestureAxes } from "./Controls/gestureGate";
|
|
41
|
+
import { setCameraPose } from "./Controls/setCameraPose";
|
|
42
|
+
import type { PosableScene } from "./Controls/setCameraPose";
|
|
43
|
+
import { addVolumeBoundingBox, VOLUME_BOUNDS_NAME } from "./Loader/volumeBoundingBox";
|
|
44
|
+
import type { BoundingBoxHost, VolumeBoundingBoxOpts } from "./Loader/volumeBoundingBox";
|
|
45
|
+
import { DEFAULT_AXES } from "./Loader/copperNrrdLoader";
|
|
46
|
+
import type { NrrdAxis } from "./Loader/copperNrrdLoader";
|
|
47
|
+
import { easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle } from "./Controls/cameraTransitions";
|
|
48
|
+
import type { Pose } from "./Controls/cameraTransitions";
|
|
49
|
+
import { installFastSliceRepaint } from "./Loader/fastSliceRepaint";
|
|
21
50
|
import { SurfaceAnnotator } from "./Utils/surfaceAnnotation";
|
|
22
51
|
import type { SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions } from "./Utils/surfaceAnnotation";
|
|
23
52
|
import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController } from "./types/types";
|
|
@@ -30,6 +59,6 @@ import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
|
|
|
30
59
|
import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from "./Utils/segmentation/tools/AiAssistTool";
|
|
31
60
|
import "./css/style.css";
|
|
32
61
|
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, };
|
|
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, };
|
|
35
64
|
export type { CameraViewPreset } from "./Controls/orbitFraming";
|
package/dist/index.js
CHANGED
|
@@ -5,13 +5,14 @@ import { copperScene } from "./Scene/copperScene";
|
|
|
5
5
|
import { CameraViewPoint } from "./Controls/copperControls";
|
|
6
6
|
import { addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, } from "./Utils/add3DLabel";
|
|
7
7
|
import { addBoxHelper } from "./Loader/copperNrrdLoader";
|
|
8
|
+
import { copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, } from "./Loader/copperGltfLoader";
|
|
8
9
|
import { fullScreenListenner, loading, throttle } from "./Utils/utils";
|
|
9
10
|
import { copperRendererOnDemond } from "./Renderer/copperRendererOnDemond";
|
|
10
11
|
import { copperSceneOnDemond } from "./Scene/copperSceneOnDemond";
|
|
11
12
|
import { copperMSceneRenderer } from "./Renderer/copperMSceneRenderer";
|
|
12
13
|
import { copperMScene } from "./Scene/copperMScene";
|
|
13
14
|
import { createTexture2D_NRRD } from "./Utils/texture2d";
|
|
14
|
-
import { configKiwriousHeart } from "./Utils/kiwrious/configKiwrious";
|
|
15
|
+
import { configKiwriousHeart, loadKiwrious, } from "./Utils/kiwrious/configKiwrious";
|
|
15
16
|
import kiwrious from "./Utils/kiwrious/configKiwrious";
|
|
16
17
|
import { NrrdTools } from "./Utils/segmentation/NrrdTools";
|
|
17
18
|
import { GaussianSmoother } from "./Utils/segmentation/core/GaussianSmoother";
|
|
@@ -20,6 +21,20 @@ import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls"
|
|
|
20
21
|
import { Copper3dOrbitControls } from "./Controls/Copper3dOrbitControls";
|
|
21
22
|
import { MeshNodeTool } from "./Utils/MeshNodeTool";
|
|
22
23
|
import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
|
|
24
|
+
import { exposureExponent, DEFAULT_TARGET_GREY } from "./Utils/volumeExposure";
|
|
25
|
+
import { disposeObject3D, disposeMaterial } from "./Utils/dispose";
|
|
26
|
+
import { collectFadeTargets, setFade, restoreFade, } from "./Utils/modelCrossfade";
|
|
27
|
+
import { createSceneBudget, defaultBudgetBytes } from "./Renderer/sceneBudget";
|
|
28
|
+
import { disposeScene, removeSceneFromMap } from "./Renderer/disposeScene";
|
|
29
|
+
import { fitDistance } from "./Controls/orbitFraming";
|
|
30
|
+
import { fitView } from "./Controls/fitView";
|
|
31
|
+
import { isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, } from "./Controls/controlsAxes";
|
|
32
|
+
import { beginGesture, isGestureActive } from "./Controls/gestureGate";
|
|
33
|
+
import { setCameraPose } from "./Controls/setCameraPose";
|
|
34
|
+
import { addVolumeBoundingBox, VOLUME_BOUNDS_NAME, } from "./Loader/volumeBoundingBox";
|
|
35
|
+
import { DEFAULT_AXES } from "./Loader/copperNrrdLoader";
|
|
36
|
+
import { easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, } from "./Controls/cameraTransitions";
|
|
37
|
+
import { installFastSliceRepaint } from "./Loader/fastSliceRepaint";
|
|
23
38
|
import { SurfaceAnnotator } from "./Utils/surfaceAnnotation";
|
|
24
39
|
import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
|
|
25
40
|
import "./css/style.css";
|
|
@@ -41,5 +56,5 @@ if (typeof window !== "undefined") {
|
|
|
41
56
|
if (typeof console !== "undefined") {
|
|
42
57
|
console.log(`%cCopper3D Visualisation %c${REVISION}`, "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
|
|
43
58
|
}
|
|
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, };
|
|
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, };
|
|
45
60
|
//# 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;A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,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,5 +1,16 @@
|
|
|
1
1
|
import { EventDispatcher, MOUSE, Vector3, PerspectiveCamera, OrthographicCamera } from "three";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The events this class dispatches. Without it `EventDispatcher` defaults to an
|
|
4
|
+
* empty map, so `keyof` it is `never` and `addEventListener("change", ...)` is a
|
|
5
|
+
* type error for every caller -- which is why the dispatches below still need
|
|
6
|
+
* their `as never` casts.
|
|
7
|
+
*/
|
|
8
|
+
export interface Copper3dTrackballControlsEventMap {
|
|
9
|
+
change: {};
|
|
10
|
+
start: {};
|
|
11
|
+
end: {};
|
|
12
|
+
}
|
|
13
|
+
declare class Copper3dTrackballControls extends EventDispatcher<Copper3dTrackballControlsEventMap> {
|
|
3
14
|
object: PerspectiveCamera | OrthographicCamera;
|
|
4
15
|
domElement: HTMLElement;
|
|
5
16
|
enabled: boolean;
|
|
@@ -17,6 +28,19 @@ declare class Copper3dTrackballControls extends EventDispatcher {
|
|
|
17
28
|
noPan: boolean;
|
|
18
29
|
staticMoving: boolean;
|
|
19
30
|
dynamicDampingFactor: number;
|
|
31
|
+
/**
|
|
32
|
+
* Drive the camera from the input handlers as well as from `update()`.
|
|
33
|
+
*
|
|
34
|
+
* Off by default, which is the historical behaviour: input handlers only
|
|
35
|
+
* record positions, and nothing moves until something calls `update()`.
|
|
36
|
+
* That is fine under a continuous `requestAnimationFrame` loop and a
|
|
37
|
+
* deadlock without one -- see the note on `update()`.
|
|
38
|
+
*
|
|
39
|
+
* Turn it on for on-demand rendering. Leave it off with
|
|
40
|
+
* `staticMoving = false`: each extra `update()` advances the damping decay
|
|
41
|
+
* by one step, so input-driven updates make the glide shorter.
|
|
42
|
+
*/
|
|
43
|
+
updateOnInput: boolean;
|
|
20
44
|
minDistance: number;
|
|
21
45
|
maxDistance: number;
|
|
22
46
|
minZoom: number;
|
|
@@ -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,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One way to ask about, and set, whether a controls instance may rotate, pan
|
|
3
|
+
* or zoom.
|
|
4
|
+
*
|
|
5
|
+
* There are two spellings in play and they are opposites. `OrbitControls` (and
|
|
6
|
+
* `Copper3dOrbitControls`) use positive `enableRotate` / `enablePan` /
|
|
7
|
+
* `enableZoom`; `TrackballControls` and `Copper3dTrackballControls` use
|
|
8
|
+
* negative `noRotate` / `noPan` / `noZoom`. Neither class complains about the
|
|
9
|
+
* other's property name -- it lands as an unread extra field -- so writing the
|
|
10
|
+
* wrong one is a SILENT no-op, and code that has to work with whatever
|
|
11
|
+
* controls a scene happens to be carrying gets it wrong sooner or later.
|
|
12
|
+
*
|
|
13
|
+
* Deliberately structural and free of `three`: a caller holding a controls
|
|
14
|
+
* instance out of a published bundle can still pass it here.
|
|
15
|
+
*/
|
|
16
|
+
export interface AxisGatedControls {
|
|
17
|
+
/** Trackball spelling. */
|
|
18
|
+
noRotate?: boolean;
|
|
19
|
+
noPan?: boolean;
|
|
20
|
+
noZoom?: boolean;
|
|
21
|
+
/** Orbit spelling. */
|
|
22
|
+
enableRotate?: boolean;
|
|
23
|
+
enablePan?: boolean;
|
|
24
|
+
enableZoom?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function isRotateEnabled(controls: AxisGatedControls): boolean;
|
|
27
|
+
export declare function setRotateEnabled(controls: AxisGatedControls, enabled: boolean): void;
|
|
28
|
+
export declare function isPanEnabled(controls: AxisGatedControls): boolean;
|
|
29
|
+
export declare function setPanEnabled(controls: AxisGatedControls, enabled: boolean): void;
|
|
30
|
+
export declare function isZoomEnabled(controls: AxisGatedControls): boolean;
|
|
31
|
+
export declare function setZoomEnabled(controls: AxisGatedControls, enabled: boolean): void;
|
|
@@ -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 {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AxisGatedControls } from "./controlsAxes";
|
|
2
|
+
/**
|
|
3
|
+
* Suppresses camera axes for the duration of a gesture that means something
|
|
4
|
+
* else -- scrubbing a slice plane, dragging an annotation anchor, painting on
|
|
5
|
+
* a mesh -- and puts back exactly what was there before.
|
|
6
|
+
*
|
|
7
|
+
* ## Restore what was there, never `true`
|
|
8
|
+
*
|
|
9
|
+
* This is the whole reason to have a helper rather than two assignments. The
|
|
10
|
+
* obvious hand-rolled version disables the axis on pointerdown and re-enables
|
|
11
|
+
* it on pointerup, and it is wrong on any view that was ALREADY locked: a 2D
|
|
12
|
+
* modality with rotation deliberately turned off silently becomes orbitable
|
|
13
|
+
* the first time the reader scrubs it, and nothing ever turns it back off.
|
|
14
|
+
*
|
|
15
|
+
* ## Attach the listener in the CAPTURE phase
|
|
16
|
+
*
|
|
17
|
+
* The gate cannot do this for you, and getting it wrong costs a whole
|
|
18
|
+
* gesture. `Copper3dTrackballControls` listens on the canvas in the bubble
|
|
19
|
+
* phase and latches its rotate state inside its own `pointerdown` handler
|
|
20
|
+
* (`onMouseDown` reads `noRotate` there and copies the pointer position). A
|
|
21
|
+
* listener that opens the gate in the bubble phase runs after that, so the
|
|
22
|
+
* first gesture both scrubs AND orbits:
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* el.addEventListener("pointerdown", onDown, true); // <- the `true`
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ## Nesting
|
|
29
|
+
*
|
|
30
|
+
* Gates on the same controls object refcount. The first one captures and
|
|
31
|
+
* suppresses; the last one released restores. Each releaser is idempotent, so
|
|
32
|
+
* calling it from both `pointerup` and `pointercancel` is safe.
|
|
33
|
+
*/
|
|
34
|
+
export interface GestureAxes {
|
|
35
|
+
/** Default `true` -- rotation is what a drag gesture collides with. */
|
|
36
|
+
rotate?: boolean;
|
|
37
|
+
pan?: boolean;
|
|
38
|
+
zoom?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Suppresses the requested axes and returns the function that restores them.
|
|
42
|
+
*
|
|
43
|
+
* @param controls the scene's controls; trackball or orbit, either spelling
|
|
44
|
+
* @param axes which axes the gesture needs; rotate only by default
|
|
45
|
+
*/
|
|
46
|
+
export declare function beginGesture(controls: AxisGatedControls, axes?: GestureAxes): () => void;
|
|
47
|
+
/** Whether a gesture currently holds this controls object. Mainly for tests. */
|
|
48
|
+
export declare function isGestureActive(controls: AxisGatedControls): boolean;
|
|
@@ -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,50 @@
|
|
|
1
|
+
import type { Pose } from "./cameraTransitions";
|
|
2
|
+
/**
|
|
3
|
+
* Writes a camera pose onto a scene, including the one line everybody forgets.
|
|
4
|
+
*
|
|
5
|
+
* Moving a camera programmatically is three obvious assignments and one
|
|
6
|
+
* non-obvious one:
|
|
7
|
+
*
|
|
8
|
+
* camera.position.set(...)
|
|
9
|
+
* camera.up.set(...)
|
|
10
|
+
* camera.lookAt(...)
|
|
11
|
+
* controls.target.set(...) // <- this one
|
|
12
|
+
*
|
|
13
|
+
* Nothing in copper3d syncs the controls' orbit pivot with `camera.lookAt()`.
|
|
14
|
+
* Leave that last line out and everything appears to work until the user
|
|
15
|
+
* touches the mouse: the first drag calls `controls.update()`, which re-aims
|
|
16
|
+
* the camera at whatever `target` still held, silently undoing the move. The
|
|
17
|
+
* symptom -- "the camera jumps back the moment I drag" -- points at the
|
|
18
|
+
* controls rather than at the code that actually caused it.
|
|
19
|
+
*
|
|
20
|
+
* A free function taking the scene first, so it works on a scene instance from
|
|
21
|
+
* a published bundle and is unit-testable without a renderer. The scene class
|
|
22
|
+
* wraps it as a one-line method.
|
|
23
|
+
*
|
|
24
|
+
* `fitView` does the same thing for the specific case of re-framing on
|
|
25
|
+
* content; this is the general one, for a pose you already have.
|
|
26
|
+
*/
|
|
27
|
+
interface Vec3Like {
|
|
28
|
+
set: (x: number, y: number, z: number) => void;
|
|
29
|
+
}
|
|
30
|
+
export interface PosableScene {
|
|
31
|
+
camera: {
|
|
32
|
+
position: Vec3Like;
|
|
33
|
+
up: Vec3Like;
|
|
34
|
+
lookAt: (x: number, y: number, z: number) => void;
|
|
35
|
+
updateProjectionMatrix?: () => void;
|
|
36
|
+
};
|
|
37
|
+
controls?: {
|
|
38
|
+
/** OrbitControls / TrackballControls' orbit pivot. */
|
|
39
|
+
target?: Vec3Like;
|
|
40
|
+
/** TrackballControls caches the canvas's page box and recomputes it only
|
|
41
|
+
* here; OrbitControls measures per event and does not define this. */
|
|
42
|
+
handleResize?: () => void;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Does NOT render. The caller decides when to draw, which matters under
|
|
47
|
+
* on-demand rendering where this may be one of several changes in a frame.
|
|
48
|
+
*/
|
|
49
|
+
export declare function setCameraPose(scene: PosableScene, pose: Pose): void;
|
|
50
|
+
export {};
|
|
@@ -1,3 +1,38 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
|
3
|
+
/**
|
|
4
|
+
* Points the Draco decoder at `path`, which must end in a slash -- three
|
|
5
|
+
* appends `draco_wasm_wrapper.js` and `draco_decoder.wasm` to it directly.
|
|
6
|
+
*
|
|
7
|
+
* On a subpath deploy the base URL has to be included: a decoder served from
|
|
8
|
+
* `/te-uma/draco/` is not found at `/draco/`.
|
|
9
|
+
*
|
|
10
|
+
* Call once at startup. The decoder module is fetched on first use and cached
|
|
11
|
+
* inside `DRACOLoader`, so a later change does not re-fetch it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function setDracoDecoderPath(path: string): void;
|
|
14
|
+
/** The same, for the Basis/KTX2 transcoder. Also expects a trailing slash. */
|
|
15
|
+
export declare function setKTX2TranscoderPath(path: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Optional callbacks for `scene.loadGltf`.
|
|
18
|
+
*
|
|
19
|
+
* Until 3.9.0 there were none, and the third argument every `loadGltf` passed
|
|
20
|
+
* to `GLTFLoader.load` was an empty function NAMED `error` sitting in the
|
|
21
|
+
* *onProgress* slot -- so a failed fetch or a corrupt file invoked nothing at
|
|
22
|
+
* all, and the caller's `callback` simply never fired. A load that fails and a
|
|
23
|
+
* load that is merely slow were indistinguishable from outside.
|
|
24
|
+
*/
|
|
25
|
+
export interface GltfLoadOpts {
|
|
26
|
+
/** Download progress. Fires only when the server sends a Content-Length. */
|
|
27
|
+
onProgress?: (event: ProgressEvent) => void;
|
|
28
|
+
/** Fetch or parse failure. The one signal that a load is never coming. */
|
|
29
|
+
onError?: (error: unknown) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A GLTFLoader wired to the shared Draco and KTX2 loaders.
|
|
33
|
+
*
|
|
34
|
+
* Exported so callers who need their own loader -- their own
|
|
35
|
+
* `LoadingManager`, `onError`, or a load not going through a copper3d scene --
|
|
36
|
+
* do not have to rebuild the decoder wiring and get the paths right again.
|
|
37
|
+
*/
|
|
3
38
|
export declare function copperGltfLoader(renderer: THREE.WebGLRenderer): GLTFLoader;
|
|
@@ -3,11 +3,58 @@ import { copperScene } from "../Scene/copperScene";
|
|
|
3
3
|
import { GUI } from "dat.gui";
|
|
4
4
|
import { nrrdMeshesType, nrrdSliceType, loadingBarType } from "../types/types";
|
|
5
5
|
import { Copper3dTrackballControls } from "../Controls/Copper3dTrackballControls";
|
|
6
|
+
/** A slice axis, in the sense `Volume.extractSlice` uses. */
|
|
7
|
+
export type NrrdAxis = "x" | "y" | "z";
|
|
8
|
+
/** All three, which is what `loadNrrd` has always extracted. */
|
|
9
|
+
export declare const DEFAULT_AXES: readonly NrrdAxis[];
|
|
6
10
|
export interface optsType {
|
|
7
11
|
openGui: boolean;
|
|
8
12
|
container?: HTMLDivElement;
|
|
13
|
+
/**
|
|
14
|
+
* Which slice planes to extract. Defaults to all three, i.e. exactly what
|
|
15
|
+
* previous versions did.
|
|
16
|
+
*
|
|
17
|
+
* Narrow it when you display fewer. `extractSlice` walks the whole volume
|
|
18
|
+
* per call and the result is retained on `volume.sliceList` for the volume's
|
|
19
|
+
* lifetime, so an axis you never show costs a full pass over a 50MB buffer
|
|
20
|
+
* plus a geometry, a material and a canvas-backed texture that nothing ever
|
|
21
|
+
* frees.
|
|
22
|
+
*
|
|
23
|
+
* ::: warning
|
|
24
|
+
* The omitted axes are `undefined` on the `nrrdMeshes` / `nrrdSlices` the
|
|
25
|
+
* callback receives. Their types still declare all three present -- widening
|
|
26
|
+
* them to optional would break every existing caller's compile -- so a
|
|
27
|
+
* caller that narrows `axes` is responsible for only reading what it asked
|
|
28
|
+
* for.
|
|
29
|
+
* :::
|
|
30
|
+
*/
|
|
31
|
+
axes?: readonly NrrdAxis[];
|
|
32
|
+
/**
|
|
33
|
+
* Download progress, in ADDITION to the built-in loading bar -- that keeps
|
|
34
|
+
* writing its percentage into `loadingBar.progress` exactly as before.
|
|
35
|
+
*
|
|
36
|
+
* New in 3.9.0. Until then the loading bar's text was the only progress
|
|
37
|
+
* signal copper3d exposed, so a caller that needed to know a large download
|
|
38
|
+
* was still alive had to watch that DOM node for mutations.
|
|
39
|
+
*/
|
|
40
|
+
onProgress?: (event: ProgressEvent) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Fetch or parse failure. New in 3.9.0; there was no error channel at all
|
|
43
|
+
* before, so a failed volume was indistinguishable from a slow one and the
|
|
44
|
+
* `callback` simply never fired.
|
|
45
|
+
*/
|
|
46
|
+
onError?: (error: unknown) => void;
|
|
9
47
|
}
|
|
10
48
|
export declare function copperNrrdLoader(url: string, loadingBar: loadingBarType, segmentation: boolean, callback?: (volume: any, nrrdMeshes: nrrdMeshesType, nrrdSlices: nrrdSliceType, gui?: GUI) => void, opts?: optsType): void;
|
|
11
49
|
export declare function copperNrrdTexture3dLoader(url: string, scene: THREE.Scene, container: HTMLDivElement, callback?: (volume: any, gui?: GUI) => void): void;
|
|
12
50
|
export declare function getWholeSlices(nrrdSlices: nrrdSliceType, scene: THREE.Scene, gui: GUI, controls: Copper3dTrackballControls): void;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated Since 3.9.0, use `addVolumeBoundingBox(scene, rasDimensions)`.
|
|
53
|
+
*
|
|
54
|
+
* Kept unchanged for callers passing their own `boxCube`, which works. The
|
|
55
|
+
* two-argument form does not: `cube` is declared in this module and never
|
|
56
|
+
* assigned, so it reaches `new THREE.BoxHelper(undefined)`. This also cannot
|
|
57
|
+
* take a `copperSceneOnDemond` -- a sibling of `copperScene`, not a descendant
|
|
58
|
+
* -- and sizes the box from `volume.matrix` rather than its RAS dimensions.
|
|
59
|
+
*/
|
|
13
60
|
export declare function addBoxHelper(scene: copperScene, volume: any, boxCube?: THREE.Object3D<THREE.Object3DEventMap>): void;
|
|
@@ -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>;
|