@niivue/niivue 1.0.0-rc.21 → 1.0.0-rc.210
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/README.md +134 -8
- package/dist/NVConstants.d.ts +41 -8
- package/dist/NVControlBase.d.ts +711 -68
- package/dist/NVDocument.d.ts +69 -28
- package/dist/NVEvents.d.ts +12 -2
- package/dist/NVLoader.d.ts +28 -1
- package/dist/NVModel.d.ts +35 -3
- package/dist/NVTypes.d.ts +474 -27
- package/dist/annotation/delta.d.ts +12 -0
- package/dist/annotation/index.d.ts +3 -3
- package/dist/annotation/multiClick.d.ts +5 -2
- package/dist/annotation/selection.d.ts +8 -1
- package/dist/annotation/shapes.d.ts +8 -1
- package/dist/assets/fonts/index.d.ts +1 -0
- package/dist/assets/fonts/index.js +1 -4
- package/dist/assets/matcaps/index.d.ts +1 -0
- package/dist/assets/matcaps/index.js +1 -6
- package/dist/byteLru.d.ts +89 -0
- package/dist/cmap/NVCmaps.d.ts +83 -5
- package/dist/cmap/luts/_registry.d.ts +563 -0
- package/dist/cmap/luts/actc.json.d.ts +10 -0
- package/dist/cmap/luts/afni_blues_inv.json.d.ts +12 -0
- package/dist/cmap/luts/afni_reds_inv.json.d.ts +10 -0
- package/dist/cmap/luts/batlow.json.d.ts +25 -0
- package/dist/cmap/luts/bcgwhw.json.d.ts +35 -0
- package/dist/cmap/luts/bcgwhw_dark.json.d.ts +35 -0
- package/dist/cmap/luts/blue.json.d.ts +10 -0
- package/dist/cmap/luts/blue2cyan.json.d.ts +10 -0
- package/dist/cmap/luts/blue2magenta.json.d.ts +10 -0
- package/dist/cmap/luts/blue2red.json.d.ts +10 -0
- package/dist/cmap/luts/bluegrn.json.d.ts +10 -0
- package/dist/cmap/luts/bone.json.d.ts +10 -0
- package/dist/cmap/luts/bronze.json.d.ts +10 -0
- package/dist/cmap/luts/cet_l17.json.d.ts +96 -0
- package/dist/cmap/luts/cividis.json.d.ts +10 -0
- package/dist/cmap/luts/cool.json.d.ts +10 -0
- package/dist/cmap/luts/copper.json.d.ts +10 -0
- package/dist/cmap/luts/copper2.json.d.ts +10 -0
- package/dist/cmap/luts/ct_airways.json.d.ts +12 -0
- package/dist/cmap/luts/ct_artery.json.d.ts +12 -0
- package/dist/cmap/luts/ct_bones.json.d.ts +12 -0
- package/dist/cmap/luts/ct_brain.json.d.ts +12 -0
- package/dist/cmap/luts/ct_brain_gray.json.d.ts +12 -0
- package/dist/cmap/luts/ct_cardiac.json.d.ts +12 -0
- package/dist/cmap/luts/ct_head.json.d.ts +12 -0
- package/dist/cmap/luts/ct_kidneys.json.d.ts +12 -0
- package/dist/cmap/luts/ct_liver.json.d.ts +12 -0
- package/dist/cmap/luts/ct_muscles.json.d.ts +12 -0
- package/dist/cmap/luts/ct_scalp.json.d.ts +12 -0
- package/dist/cmap/luts/ct_skull.json.d.ts +12 -0
- package/dist/cmap/luts/ct_soft.json.d.ts +12 -0
- package/dist/cmap/luts/ct_soft_tissue.json.d.ts +12 -0
- package/dist/cmap/luts/ct_surface.json.d.ts +12 -0
- package/dist/cmap/luts/ct_vessels.json.d.ts +12 -0
- package/dist/cmap/luts/ct_w_contrast.json.d.ts +12 -0
- package/dist/cmap/luts/cubehelix.json.d.ts +25 -0
- package/dist/cmap/luts/cyan.json.d.ts +10 -0
- package/dist/cmap/luts/draw.json.d.ts +20 -0
- package/dist/cmap/luts/electric_blue.json.d.ts +10 -0
- package/dist/cmap/luts/freesurfer.json.d.ts +32 -0
- package/dist/cmap/luts/ge_color.json.d.ts +10 -0
- package/dist/cmap/luts/gold.json.d.ts +10 -0
- package/dist/cmap/luts/gray.json.d.ts +10 -0
- package/dist/cmap/luts/green.json.d.ts +10 -0
- package/dist/cmap/luts/green2cyan.json.d.ts +10 -0
- package/dist/cmap/luts/green2orange.json.d.ts +10 -0
- package/dist/cmap/luts/hot.json.d.ts +10 -0
- package/dist/cmap/luts/hotiron.json.d.ts +10 -0
- package/dist/cmap/luts/hsv.json.d.ts +10 -0
- package/dist/cmap/luts/inferno.json.d.ts +10 -0
- package/dist/cmap/luts/itksnap.json.d.ts +59 -0
- package/dist/cmap/luts/jet.json.d.ts +10 -0
- package/dist/cmap/luts/kry.json.d.ts +10 -0
- package/dist/cmap/luts/linspecer.json.d.ts +10 -0
- package/dist/cmap/luts/lipari.json.d.ts +25 -0
- package/dist/cmap/luts/magma.json.d.ts +10 -0
- package/dist/cmap/luts/mako.json.d.ts +10 -0
- package/dist/cmap/luts/navia.json.d.ts +25 -0
- package/dist/cmap/luts/nih.json.d.ts +10 -0
- package/dist/cmap/luts/plasma.json.d.ts +10 -0
- package/dist/cmap/luts/red.json.d.ts +10 -0
- package/dist/cmap/luts/redyell.json.d.ts +10 -0
- package/dist/cmap/luts/rocket.json.d.ts +10 -0
- package/dist/cmap/luts/roi_i256.json.d.ts +100 -0
- package/dist/cmap/luts/slicer3d.json.d.ts +358 -0
- package/dist/cmap/luts/surface.json.d.ts +10 -0
- package/dist/cmap/luts/thermal.json.d.ts +25 -0
- package/dist/cmap/luts/turbo.json.d.ts +10 -0
- package/dist/cmap/luts/violet.json.d.ts +10 -0
- package/dist/cmap/luts/viridis.json.d.ts +10 -0
- package/dist/cmap/luts/warm.json.d.ts +10 -0
- package/dist/cmap/luts/winter.json.d.ts +10 -0
- package/dist/cmap/luts/x_rain.json.d.ts +10 -0
- package/dist/cmap/luts/yellow.json.d.ts +10 -0
- package/dist/control/NVCanvasViewportController.d.ts +3 -0
- package/dist/control/animate.d.ts +100 -0
- package/dist/control/canvasRegistry.d.ts +35 -0
- package/dist/control/instances.d.ts +13 -0
- package/dist/control/interactions.d.ts +1 -0
- package/dist/control/locationTracking.d.ts +5 -4
- package/dist/control/measurements.d.ts +0 -2
- package/dist/control/pinchZoom.d.ts +14 -2
- package/dist/control/viewBoth.d.ts +4 -29
- package/dist/control/viewLifecycle.d.ts +7 -0
- package/dist/control/viewSingle.d.ts +11 -0
- package/dist/control/viewWebGL2.d.ts +1 -11
- package/dist/control/viewWebGPU.d.ts +1 -11
- package/dist/control/wheelZoomAnchor.d.ts +1 -1
- package/dist/core-BANDcQC8.js +42839 -0
- package/dist/devicePixelRatio.d.ts +6 -0
- package/dist/documentBounds.d.ts +33 -0
- package/dist/documentColormaps.d.ts +43 -0
- package/dist/documentEvents.d.ts +24 -0
- package/dist/documentJson.d.ts +7 -2
- package/dist/documentLegend.d.ts +17 -0
- package/dist/documentLinkData.d.ts +1 -1
- package/dist/documentLinks.d.ts +24 -0
- package/dist/documentMatcap.d.ts +27 -0
- package/dist/documentMeshLayers.d.ts +2 -3
- package/dist/documentSources.d.ts +72 -0
- package/dist/documentVolumeOptions.d.ts +4 -4
- package/dist/drawing/drawingManager.d.ts +0 -20
- package/dist/drawing/penTool.d.ts +2 -2
- package/dist/fonts-DGsgW9tm.js +1741 -0
- package/dist/gl/NVViewGL.d.ts +24 -4
- package/dist/gl/bench.d.ts +1 -3
- package/dist/gl/blendOverlays.d.ts +11 -0
- package/dist/gl/boxLine.d.ts +17 -0
- package/dist/gl/boxLineShader.d.ts +2 -0
- package/dist/gl/cinematic.d.ts +95 -0
- package/dist/gl/cinematicShader.d.ts +31 -0
- package/dist/gl/colorLut.d.ts +9 -0
- package/dist/gl/colorbar.d.ts +8 -17
- package/dist/gl/crosshair.d.ts +1 -0
- package/dist/gl/depthPickShader.d.ts +1 -1
- package/dist/gl/font.d.ts +3 -7
- package/dist/gl/glUtil.d.ts +25 -0
- package/dist/gl/mesh.d.ts +4 -2
- package/dist/gl/meshShader.d.ts +2 -0
- package/dist/gl/orientChunked.d.ts +2 -2
- package/dist/gl/orientOverlay.d.ts +3 -2
- package/dist/gl/panelShader.d.ts +2 -2
- package/dist/gl/polygon.d.ts +1 -3
- package/dist/gl/polygon3d.d.ts +1 -3
- package/dist/gl/render.d.ts +70 -188
- package/dist/gl/renderShader.d.ts +1 -1
- package/dist/gl/slice.d.ts +2 -0
- package/dist/gl/sliceShader.d.ts +1 -1
- package/dist/gl/slide.d.ts +38 -8
- package/dist/gl/slidePlaneRender.d.ts +36 -3
- package/dist/gl/slideShader.d.ts +3 -2
- package/dist/gl/tileFuse.d.ts +38 -0
- package/dist/gl/tileGutter.d.ts +26 -0
- package/dist/index.d.ts +31 -19
- package/dist/index.webgl2.d.ts +31 -19
- package/dist/index.webgpu.d.ts +31 -19
- package/dist/matcaps-KEJitnW8.js +3 -0
- package/dist/math/NVTransforms.d.ts +18 -4
- package/dist/mesh/NVMesh.d.ts +9 -0
- package/dist/mesh/connectome/fileData.d.ts +21 -0
- package/dist/mesh/connectome/index.d.ts +1 -20
- package/dist/mesh/connectome/readers/_registry.d.ts +11 -0
- package/dist/mesh/connectome/readers/fsPointset.d.ts +10 -0
- package/dist/mesh/connectome/readers/jcon.d.ts +1 -1
- package/dist/mesh/layers/index.d.ts +8 -2
- package/dist/mesh/layers/readers/_registry.d.ts +15 -0
- package/dist/mesh/layers/readers/annot.d.ts +16 -0
- package/dist/mesh/layers/readers/curv.d.ts +2 -1
- package/dist/mesh/layers/readers/smp.d.ts +2 -1
- package/dist/mesh/layers/readers/stc.d.ts +2 -1
- package/dist/mesh/readers/_registry.d.ts +41 -0
- package/dist/mesh/readers/asc.d.ts +2 -0
- package/dist/mesh/shownIndices.d.ts +10 -0
- package/dist/mesh/tracts/readers/_registry.d.ts +17 -0
- package/dist/mesh/tracts/readers/tck.d.ts +6 -0
- package/dist/mesh/tracts/readers/tract.d.ts +4 -0
- package/dist/mesh/triangleClusters.d.ts +40 -0
- package/dist/mesh/vertexFormat.d.ts +16 -3
- package/dist/mesh/writers/_registry.d.ts +15 -0
- package/dist/mesh/writers/index.d.ts +1 -2
- package/dist/mesh/writers/mz3.d.ts +2 -1
- package/dist/niivue.js +109 -146
- package/dist/niivue.webgl2.js +18 -206
- package/dist/niivue.webgpu.js +18 -204
- package/dist/scene/NvSceneController.d.ts +145 -0
- package/dist/scene/layouts.d.ts +21 -0
- package/dist/scene/types.d.ts +18 -0
- package/dist/scene.js +557 -0
- package/dist/signal/readers/_registry.d.ts +11 -0
- package/dist/slide/NVSlide.d.ts +571 -111
- package/dist/slide/colorLutShader.d.ts +8 -0
- package/dist/slide/dziSource.d.ts +4 -3
- package/dist/slide/slideChannels.d.ts +29 -0
- package/dist/slide/slideController.d.ts +137 -0
- package/dist/slide/slideDrawing.d.ts +10 -0
- package/dist/slide/slideFuse.d.ts +198 -0
- package/dist/slide/slideLoadQueue.d.ts +36 -0
- package/dist/slide/slideLod.d.ts +86 -0
- package/dist/slide/slideOverlay.d.ts +50 -0
- package/dist/slide/slidePlacement.d.ts +88 -0
- package/dist/slide/slidePlane.d.ts +82 -24
- package/dist/slide/slideSource.d.ts +163 -0
- package/dist/slide/slideThumbnail.d.ts +12 -0
- package/dist/slide/slideTiles.d.ts +124 -0
- package/dist/slide/slideView.d.ts +108 -0
- package/dist/slide/slideViewBoth.d.ts +6 -0
- package/dist/slide/slideViewWebGL2.d.ts +5 -0
- package/dist/slide/slideViewWebGPU.d.ts +5 -0
- package/dist/slide/tileGutter.d.ts +121 -0
- package/dist/slide/tileTextureCache.d.ts +33 -5
- package/dist/slide/volumeSliceSource.d.ts +25 -19
- package/dist/slideViewWebGL2-DTV6c4AF.js +5547 -0
- package/dist/slideViewWebGPU-kkwLzgMY.js +5635 -0
- package/dist/standalone/assets/fonts/index.js +1 -0
- package/dist/standalone/assets/matcaps/index.js +1 -0
- package/dist/standalone/chunks/core-C_xNJ_6T.js +108 -0
- package/dist/standalone/chunks/fonts-CJneqA-R.js +3 -0
- package/dist/standalone/chunks/matcaps-BDC36G_o.js +1 -0
- package/dist/standalone/chunks/slideViewWebGL2-DABfVPYd.js +3380 -0
- package/dist/standalone/chunks/slideViewWebGPU-B6VxC89f.js +3916 -0
- package/dist/standalone/chunks/viewSingle-D05PH_w3.js +1 -0
- package/dist/standalone/niivue.js +1 -0
- package/dist/standalone/niivue.webgl2.js +1 -0
- package/dist/standalone/niivue.webgpu.js +1 -0
- package/dist/standalone/viewport.js +1 -0
- package/dist/testing/headless.d.ts +66 -0
- package/dist/testing/nimlTract.d.ts +2 -0
- package/dist/view/NVAnnotation.d.ts +5 -8
- package/dist/view/NVBench.d.ts +20 -0
- package/dist/view/NVBoxEdges.d.ts +22 -0
- package/dist/view/NVCinematic.d.ts +232 -0
- package/dist/view/NVColorbar.d.ts +3 -0
- package/dist/view/NVColorbarRenderer.d.ts +23 -0
- package/dist/view/NVCrosscut.d.ts +13 -0
- package/dist/view/NVCrosshair.d.ts +8 -0
- package/dist/view/NVDrawingTexture.d.ts +7 -0
- package/dist/view/NVFont.d.ts +11 -0
- package/dist/view/NVFontRenderer.d.ts +16 -0
- package/dist/view/NVGraph.d.ts +7 -4
- package/dist/view/NVLegend.d.ts +55 -6
- package/dist/view/NVLine.d.ts +0 -29
- package/dist/view/NVMeasurement.d.ts +36 -0
- package/dist/view/NVOrient.d.ts +14 -0
- package/dist/view/NVOverlayHook.d.ts +8 -0
- package/dist/view/NVPerfMarks.d.ts +9 -4
- package/dist/view/NVPlaneOutline.d.ts +19 -0
- package/dist/view/NVRuler.d.ts +31 -3
- package/dist/view/NVSliceLayout.d.ts +78 -9
- package/dist/view/NVVolumeVisibility.d.ts +46 -0
- package/dist/view/chunkStackFuse.d.ts +88 -0
- package/dist/view/matcapFallback.d.ts +7 -0
- package/dist/view/orientationLabels.d.ts +53 -0
- package/dist/view/sliceUtils.d.ts +9 -1
- package/dist/view/tickSpacing.d.ts +2 -0
- package/dist/view/volumeUpdateScope.d.ts +10 -3
- package/dist/viewSingle-DkMqnJku.js +65 -0
- package/dist/viewport.js +173 -161
- package/dist/volume/ChunkExplode.d.ts +20 -0
- package/dist/volume/ChunkResidency.d.ts +49 -35
- package/dist/volume/ChunkStreamRenderer.d.ts +354 -0
- package/dist/volume/ChunkVisibility.d.ts +20 -10
- package/dist/volume/ChunkedVolumeSource.d.ts +17 -1
- package/dist/volume/NVChunkedVolume.d.ts +187 -31
- package/dist/volume/allenAtlas.d.ts +1 -1
- package/dist/volume/allenAtlasLoader.d.ts +0 -6
- package/dist/volume/budgetPlans.d.ts +16 -1
- package/dist/volume/ccf.d.ts +41 -0
- package/dist/volume/channelColormaps.d.ts +32 -2
- package/dist/volume/channelVolumeFile.d.ts +6 -2
- package/dist/volume/chunkBudget.d.ts +21 -0
- package/dist/volume/chunkFetch.d.ts +45 -0
- package/dist/volume/chunkPlanMessage.d.ts +18 -0
- package/dist/volume/chunkPrediction.d.ts +19 -0
- package/dist/volume/chunkRender.d.ts +60 -0
- package/dist/volume/chunkTiming.d.ts +1 -1
- package/dist/volume/chunking.d.ts +23 -21
- package/dist/volume/decodedChunkCache.d.ts +11 -79
- package/dist/volume/imageDecode.d.ts +10 -0
- package/dist/volume/loadBridge.d.ts +0 -2
- package/dist/volume/omeTiff.d.ts +3 -1
- package/dist/volume/omeTiffLoader.d.ts +0 -6
- package/dist/volume/orientChunked.d.ts +31 -17
- package/dist/volume/overlayBlend.d.ts +10 -5
- package/dist/volume/pairedImage.d.ts +23 -0
- package/dist/volume/readers/_registry.d.ts +35 -0
- package/dist/volume/readers/fib.d.ts +3 -1
- package/dist/volume/readers/mgh.d.ts +1 -1
- package/dist/volume/readers/tiff.d.ts +1 -1
- package/dist/volume/regionDescriptives.d.ts +30 -0
- package/dist/volume/streamingVolume.d.ts +5 -6
- package/dist/volume/transforms/_registry.d.ts +2 -0
- package/dist/volume/transforms/index.d.ts +0 -12
- package/dist/volume/utils.d.ts +86 -3
- package/dist/volume/volumeIds.d.ts +16 -0
- package/dist/volume/writers/_registry.d.ts +11 -0
- package/dist/wgpu/NVViewGPU.d.ts +28 -4
- package/dist/wgpu/bench.d.ts +1 -3
- package/dist/wgpu/blendOverlays.d.ts +12 -0
- package/dist/wgpu/boxLine.d.ts +18 -0
- package/dist/wgpu/cinematic.d.ts +86 -0
- package/dist/wgpu/colorLut.d.ts +13 -0
- package/dist/wgpu/colorbar.d.ts +8 -17
- package/dist/wgpu/depthPick.d.ts +1 -1
- package/dist/wgpu/font.d.ts +5 -7
- package/dist/wgpu/line.d.ts +2 -1
- package/dist/wgpu/mesh.d.ts +13 -1
- package/dist/wgpu/orient.d.ts +13 -11
- package/dist/wgpu/orientChunked.d.ts +2 -2
- package/dist/wgpu/pipeline.d.ts +24 -0
- package/dist/wgpu/render.d.ts +58 -189
- package/dist/wgpu/sceneCapture.d.ts +18 -0
- package/dist/wgpu/slice.d.ts +1 -0
- package/dist/wgpu/slide.d.ts +60 -9
- package/dist/wgpu/slidePlaneRender.d.ts +33 -9
- package/dist/wgpu/tileFuse.d.ts +46 -0
- package/dist/wgpu/tileGutter.d.ts +27 -0
- package/dist/wgpu/volumeShaderLib.d.ts +1 -1
- package/dist/workers/pageWorker.d.ts +10 -0
- package/dist/workers/transform.worker.d.ts +2 -2
- package/dist/workers/workerPost.d.ts +1 -0
- package/package.json +35 -17
- package/dist/cortex-CBhDullr.js +0 -4
- package/dist/fetchOmeZarrChunkedSource-CIkXzcEM.js +0 -49358
- package/dist/index-Cbb_IM7q.js +0 -148
- package/dist/omeZarrChunkWorkerPool-DcJBdCFl.js +0 -179
- package/dist/slide-4q4P_FGk.js +0 -310
- package/dist/slide-oBdx2X1m.js +0 -234
- package/dist/volume/chunkWorkerRouting.d.ts +0 -42
- package/dist/volume/fetchOmeZarrChunkedSource.d.ts +0 -10
- package/dist/volume/omeZarr.d.ts +0 -114
- package/dist/volume/omeZarrChunkWorkerPool.d.ts +0 -51
- package/dist/volume/omeZarrChunkedSource.d.ts +0 -208
- package/dist/volume/omeZarrLoader.d.ts +0 -163
- package/dist/volume/persistentByteCache.d.ts +0 -241
- package/dist/workers/omeZarrChunk.worker.d.ts +0 -25
package/README.md
CHANGED
|
@@ -2,20 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
NiiVue is a tool for visualizing volumes, meshes, and tractography streamlines commonly used in neuroimaging. The original NiiVue project evolved organically, resulting in tightly coupled model, view, and controller components. This repository refactors the codebase to improve maintainability and to support emerging technologies such as WebGPU.
|
|
4
4
|
|
|
5
|
+
Documentation: https://niivue.github.io/mono/docs/guide/
|
|
6
|
+
|
|
5
7
|
## Getting Started
|
|
6
8
|
|
|
7
9
|
### Prerequisites
|
|
8
10
|
|
|
9
11
|
- [Bun](https://bun.sh/)
|
|
10
12
|
- A browser with WebGPU support (Chrome, Firefox). Safari works if you have a recent MacOS (version 26) or iOS. Older browsers will fall back to the WebGL2 renderer.
|
|
13
|
+
- Slides (`NVSlide`) need `AbortSignal.any` (Chrome 116, Firefox 124, Safari 17.4); `@niivue/nv-ext-tile` DICOM-WSI indexing also needs resizable `ArrayBuffer`s (Chrome 111, Firefox 128, Safari 16.4) and says so when they are missing.
|
|
11
14
|
|
|
12
15
|
### Build Commands
|
|
13
16
|
|
|
14
17
|
```bash
|
|
15
18
|
bun install # Install dependencies
|
|
16
19
|
bun run dev # Hot-reload dev server
|
|
17
|
-
bun run build # Library build to ./dist (published npm package)
|
|
18
|
-
bun run deploy # Production examples-site build to ./dist (GitHub Pages)
|
|
20
|
+
bun run build # Library build to ./dist (published npm package), incl. dist/standalone
|
|
21
|
+
bun run deploy # Production examples-site build to ./dist-examples (GitHub Pages)
|
|
19
22
|
bun run demo # Build examples site and serve locally
|
|
20
23
|
bun run lint # Biome check
|
|
21
24
|
bun run lint:fix # Biome auto-fix
|
|
@@ -35,7 +38,7 @@ The normal audit includes tests, examples (including their worker), and standalo
|
|
|
35
38
|
scripts. The production configuration checks library sources without treating
|
|
36
39
|
examples or test consumers as usage; it retains Vite support for `import.meta.glob`.
|
|
37
40
|
Both protect exports from all published package entry points. These targets scope
|
|
38
|
-
reporting to `packages/niivue`;
|
|
41
|
+
reporting to `packages/niivue`; `bun run knip` at the root audits the whole monorepo.
|
|
39
42
|
|
|
40
43
|
This is a manual review tool, not a CI gate. It exits with status 1 while findings
|
|
41
44
|
remain, including deliberately deferred exports. An unused export is a candidate,
|
|
@@ -67,8 +70,8 @@ in production is one well-predicted branch per call site. See
|
|
|
67
70
|
|
|
68
71
|
### Development Workflows
|
|
69
72
|
|
|
70
|
-
- **`bun run dev`** — Serves the `examples/` pages from source with hot reloading at `localhost:5273`. The pages `import '../src/index.ts'` directly, so dev and the deployed build run the same files. On-demand sample data (
|
|
71
|
-
- **`bun run demo`** — Builds the examples site to `dist/` and serves it with `
|
|
73
|
+
- **`bun run dev`** — Serves the `examples/` pages from source with hot reloading at `localhost:5273`. The pages `import '../src/index.ts'` directly, so dev and the deployed build run the same files. On-demand sample data (DICOM-WSI) is downloaded into `public/` if missing.
|
|
74
|
+
- **`bun run demo`** — Builds the examples site to `dist-examples/` and serves it with `vite preview`. Use this to test the actual built output or before deploying to GitHub Pages.
|
|
72
75
|
|
|
73
76
|
## Usage
|
|
74
77
|
|
|
@@ -87,10 +90,13 @@ Add a `<canvas>` to your page and attach NiiVue to it:
|
|
|
87
90
|
|
|
88
91
|
### Backend-specific distributions
|
|
89
92
|
|
|
90
|
-
By default, `@niivue/niivue` includes both backends
|
|
93
|
+
By default, `@niivue/niivue` includes both backends and renders with WebGL2. Opt in to WebGPU with the `backend` option; if WebGPU is unavailable or fails to initialize, it falls back to WebGL2:
|
|
91
94
|
|
|
92
95
|
```js
|
|
93
96
|
import NiiVue from '@niivue/niivue'
|
|
97
|
+
|
|
98
|
+
const nv = new NiiVue() // WebGL2
|
|
99
|
+
const nvGpu = new NiiVue({ backend: 'webgpu' }) // WebGPU, WebGL2 fallback
|
|
94
100
|
```
|
|
95
101
|
|
|
96
102
|
You can also import backend-only builds to reduce package size:
|
|
@@ -102,12 +108,122 @@ import NiiVueWebGL2 from '@niivue/niivue/webgl2' // WebGL2-only
|
|
|
102
108
|
|
|
103
109
|
In backend-only builds, selecting the missing backend throws an explicit error.
|
|
104
110
|
|
|
111
|
+
### Multi-viewer scenes
|
|
112
|
+
|
|
113
|
+
`@niivue/niivue/scene` exports `NvSceneController`, which lays out several NiiVue
|
|
114
|
+
instances in one container element (it creates their divs and canvases) and can
|
|
115
|
+
sync them. `@niivue/nvreact` and `@niivue/nv-web-component` are built on it.
|
|
116
|
+
The subpath is side-effect free, is not part of the root entry, and has no
|
|
117
|
+
standalone copy. Scene viewers use the universal `@niivue/niivue` build: in an
|
|
118
|
+
app built on `@niivue/niivue/webgpu` or `/webgl2` they are not `instanceof` that
|
|
119
|
+
backend-only `NiiVue` class, and they bring in the other backend's view code.
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
import { NvSceneController } from '@niivue/niivue/scene'
|
|
123
|
+
|
|
124
|
+
const scene = new NvSceneController()
|
|
125
|
+
scene.setContainerElement(document.getElementById('viewers'))
|
|
126
|
+
scene.setLayout('1x2') // two viewers side by side
|
|
127
|
+
await scene.loadVolume(0, { url: '/volumes/mni152.nii.gz' })
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Without a bundler (standalone ES modules)
|
|
131
|
+
|
|
132
|
+
The entry points above import `cbor-x`, `gl-matrix` and `nifti-reader-js` by
|
|
133
|
+
bare name, which only a bundler (or an import map listing every
|
|
134
|
+
dependency) can resolve. For pages with no JavaScript toolchain, such as static
|
|
135
|
+
HTML reports or pages served by a small Python server, the package also ships a
|
|
136
|
+
self-contained build in `dist/standalone/`:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
dist/standalone/
|
|
140
|
+
niivue.js # same API as @niivue/niivue (both backends)
|
|
141
|
+
niivue.webgl2.js # same API as @niivue/niivue/webgl2
|
|
142
|
+
niivue.webgpu.js # same API as @niivue/niivue/webgpu
|
|
143
|
+
viewport.js # same API as @niivue/niivue/viewport
|
|
144
|
+
assets/fonts/index.js
|
|
145
|
+
assets/matcaps/index.js
|
|
146
|
+
chunks/ # shared code and lazily loaded chunks
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Every dependency is bundled in, workers and images are inlined, and chunks
|
|
150
|
+
import each other by relative path, so the folder has no external references
|
|
151
|
+
and works from any base URL. Optional code stays in chunks that are fetched
|
|
152
|
+
only when used; a page showing a
|
|
153
|
+
NIfTI volume loads about 1.6 MB of JavaScript (about 0.5 MB gzipped). The build
|
|
154
|
+
fails if any bare import appears in the folder (`scripts/check-standalone.ts`).
|
|
155
|
+
|
|
156
|
+
`@niivue/nv-ext-tile` ships a matching `dist/standalone/` (`tiff.js`, `dicom.js`, `zarr.js`) that maps onto this folder with the same import map; see its README.
|
|
157
|
+
|
|
158
|
+
Copy the folder next to your page (here as `niivue/`) and map the package name
|
|
159
|
+
once:
|
|
160
|
+
|
|
161
|
+
```html
|
|
162
|
+
<script type="importmap">
|
|
163
|
+
{ "imports": { "@niivue/niivue": "./niivue/niivue.js" } }
|
|
164
|
+
</script>
|
|
165
|
+
<canvas id="gl1"></canvas>
|
|
166
|
+
<script type="module">
|
|
167
|
+
import NiiVue from '@niivue/niivue'
|
|
168
|
+
|
|
169
|
+
const nv = new NiiVue()
|
|
170
|
+
await nv.attachToCanvas(document.getElementById('gl1'))
|
|
171
|
+
await nv.loadVolumes([{ url: './mni152.nii.gz' }])
|
|
172
|
+
</script>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The import map is optional; `import NiiVue from './niivue/niivue.js'` works
|
|
176
|
+
too. Load only one copy of NiiVue per page: the standalone folder and a bundled
|
|
177
|
+
copy are separate module instances.
|
|
178
|
+
|
|
179
|
+
To vendor a pinned release without Node, download the npm tarball, check it
|
|
180
|
+
against the registry's `dist.integrity`, and copy the folder out:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
VERSION=1.0.0-rc.45
|
|
184
|
+
curl -sO "https://registry.npmjs.org/@niivue/niivue/-/niivue-$VERSION.tgz"
|
|
185
|
+
curl -s "https://registry.npmjs.org/@niivue/niivue/$VERSION" # read dist.integrity
|
|
186
|
+
echo "sha512-$(openssl dgst -sha512 -binary "niivue-$VERSION.tgz" | openssl base64 -A)"
|
|
187
|
+
tar -xzf "niivue-$VERSION.tgz" package/dist/standalone
|
|
188
|
+
cp -R package/dist/standalone ./niivue
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Or point the import map at a CDN copy of the same folder:
|
|
192
|
+
|
|
193
|
+
```html
|
|
194
|
+
<script type="importmap">
|
|
195
|
+
{
|
|
196
|
+
"imports": {
|
|
197
|
+
"@niivue/niivue": "https://cdn.jsdelivr.net/npm/@niivue/niivue@1.0.0-rc.45/dist/standalone/niivue.js"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
</script>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Node tools that need the folder's location can resolve it through the package
|
|
204
|
+
exports: `import.meta.resolve('@niivue/niivue/standalone')` returns the URL of
|
|
205
|
+
`dist/standalone/niivue.js`.
|
|
206
|
+
|
|
207
|
+
`bun run build` produces the folder (`bun run build:standalone` rebuilds just
|
|
208
|
+
this part). To try it locally, run `bun run examples:standalone` after a build
|
|
209
|
+
and open http://localhost:5403/. That serves `examples/standalone/index.html`
|
|
210
|
+
with a plain static server, the built folder as `niivue/`, and the sample
|
|
211
|
+
volumes, with no Vite in between.
|
|
212
|
+
|
|
105
213
|
### Load a mesh
|
|
106
214
|
|
|
107
215
|
```js
|
|
108
216
|
await nv.loadMeshes([{ url: '/meshes/brain.mz3' }])
|
|
109
217
|
```
|
|
110
218
|
|
|
219
|
+
### AFNI tractography
|
|
220
|
+
|
|
221
|
+
Binary `.niml.tract` files load through `loadMeshes` or by dropping them onto
|
|
222
|
+
any viewer with drag-and-drop enabled (for example `examples/tract.html`).
|
|
223
|
+
Little- and big-endian records are supported; text/base64 NIML is not.
|
|
224
|
+
Coordinates are converted from AFNI RAI to RAS mm. Bundle IDs are available
|
|
225
|
+
for coloring with `tractOptions: { colorBy: 'dps:tract' }`.
|
|
226
|
+
|
|
111
227
|
### Signals (physio and spectroscopy)
|
|
112
228
|
|
|
113
229
|
Alongside spatial volumes and meshes, NiiVue can load **signals** — a third,
|
|
@@ -200,9 +316,19 @@ const nv = new NiiVue({
|
|
|
200
316
|
})
|
|
201
317
|
```
|
|
202
318
|
|
|
319
|
+
### Migration (rc)
|
|
320
|
+
|
|
321
|
+
`DecodedChunkStats` (`ChunkStreamDetail.decoded`) is now `ByteLruStats`, which adds `evictedBytes`. `ByteLru<K, V>`, the byte-bounded LRU behind the decoded-chunk tier and the slide tile cache, is exported, and replaces nv-ext-tile's `ByteLruCache`.
|
|
322
|
+
|
|
323
|
+
Unused slide and streaming options were removed:
|
|
324
|
+
|
|
325
|
+
- `NVSlideSpatialTransform`, `NVSlideOptions.spatialTransform`, `NVSlide.spatialTransform` and `setSpatialTransform` are gone. Nothing read them; place a slide in world space with `setSlidePlane`'s `pixelToWorld`.
|
|
326
|
+
- `createSlideView` no longer takes `renderer`, `ownsSlide` or `signal`. The view makes and destroys its own renderer and always disposes the slide it releases (`setSlide`, `destroy`). To cancel a start, destroy the view once it resolves.
|
|
327
|
+
- `loadChunkedVolume` no longer takes `focusBounds` (pass them to `NVChunkedVolume.setFocus(frac, bounds)`), `retryAttempts` (always 3), `frameStagingBytes` (64 MiB) or `readoutBytes` (384 MiB).
|
|
328
|
+
|
|
203
329
|
### Testing
|
|
204
330
|
|
|
205
|
-
The package includes a unit test suite for non-rendering (
|
|
331
|
+
The package includes a unit test suite for non-rendering logic, including a headless controller (loading, documents, events), using the [Bun test runner](https://bun.sh/docs/cli/test). Tests are co-located with source files as `*.test.ts`. Rendering, Workers and pointer input are covered by Playwright specs in `e2e/` (see `notes/agents/testing.md`).
|
|
206
332
|
|
|
207
333
|
```bash
|
|
208
334
|
bun test # Run all tests with coverage
|
|
@@ -227,7 +353,7 @@ bunx nx test niivue
|
|
|
227
353
|
|
|
228
354
|
### Architecture
|
|
229
355
|
|
|
230
|
-
The codebase is written in **TypeScript** and follows an MVC pattern with dual rendering backends (WebGPU and WebGL2). See [AGENTS.md](AGENTS.md) for
|
|
356
|
+
The codebase is written in **TypeScript** and follows an MVC pattern with dual rendering backends (WebGPU and WebGL2). See [AGENTS.md](AGENTS.md) for the package's rules and code style, and [notes/agents/](notes/agents/) for architecture and the other areas in detail.
|
|
231
357
|
|
|
232
358
|
### Dependencies
|
|
233
359
|
|
package/dist/NVConstants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnnotationConfig, DrawConfig, InteractionConfig, LayoutConfig, MeshRenderConfig, UIConfig, VolumeRenderConfig } from './NVTypes';
|
|
1
|
+
import { AnnotationConfig, CinematicOptions, DrawConfig, InteractionConfig, LayoutConfig, MeshRenderConfig, Rotation2D, UIConfig, VolumeRenderConfig } from './NVTypes';
|
|
2
2
|
export declare const NUM_CLIP_PLANE = 6;
|
|
3
3
|
export declare const DEFAULT_CLIP_PLANE: readonly [0, 0, 0, 2];
|
|
4
4
|
export declare enum COLORMAP_TYPE {
|
|
@@ -47,6 +47,13 @@ export declare enum DRAG_MODE {
|
|
|
47
47
|
* lighting (illumination, gradient opacity, silhouette) are ignored: a plane
|
|
48
48
|
* has no surface to shade.
|
|
49
49
|
*
|
|
50
|
+
* CINEMATIC is a progressive path tracer for the background volume: a 2D
|
|
51
|
+
* (intensity x gradient) transfer function baked from the volume's colormap,
|
|
52
|
+
* soft shadows and ambient occlusion, refined over `cinematic.maxFrames`
|
|
53
|
+
* frames. A label volume on the same grid supplies per-label materials;
|
|
54
|
+
* without one, standard overlays draw unlit. A chunked background falls back
|
|
55
|
+
* to COMPOSITE. See `VolumeRenderConfig.cinematic`.
|
|
56
|
+
*
|
|
50
57
|
* Applies to the 3D render only; a 2D slice draws one plane, where the modes
|
|
51
58
|
* are identical.
|
|
52
59
|
*
|
|
@@ -62,28 +69,39 @@ export declare enum DRAG_MODE {
|
|
|
62
69
|
export declare enum VOLUME_RENDER_MODE {
|
|
63
70
|
COMPOSITE = 0,
|
|
64
71
|
MAXIMUM = 1,
|
|
65
|
-
SLICES = 2
|
|
72
|
+
SLICES = 2,
|
|
73
|
+
CINEMATIC = 3
|
|
66
74
|
}
|
|
67
75
|
/**
|
|
68
76
|
* How overlapping overlays combine their opacities before being drawn over the
|
|
69
77
|
* background. MAX suits independent thresholded maps (overlap is no more
|
|
70
78
|
* opaque than its parts); ADDITIVE suits fractions that sum to 1 (tissue or
|
|
71
|
-
* probability maps), so a voxel split between two maps is fully opaque;
|
|
72
|
-
* stacks them like transparencies, 1 - (1-a1)(1-a2)
|
|
79
|
+
* probability maps), so a voxel split between two maps is fully opaque; UNION
|
|
80
|
+
* stacks them like transparencies, 1 - (1-a1)(1-a2)..., in any order.
|
|
73
81
|
*/
|
|
74
82
|
export declare enum OVERLAY_ALPHA_BLEND {
|
|
75
83
|
MAX = 0,
|
|
76
84
|
ADDITIVE = 1,
|
|
77
|
-
|
|
85
|
+
UNION = 2
|
|
78
86
|
}
|
|
79
87
|
/**
|
|
80
88
|
* How overlapping overlays combine their colours. ADDITIVE sums the
|
|
81
89
|
* opacity-weighted colours (red + green = yellow, may clip); MEAN takes their
|
|
82
|
-
* opacity-weighted average (red + green = dark yellow, never clips)
|
|
90
|
+
* opacity-weighted average (red + green = dark yellow, never clips); OVER
|
|
91
|
+
* composites them in volume order, each overlay over the ones before it (an
|
|
92
|
+
* opaque green over red is green). Pair OVER with OVERLAY_ALPHA_BLEND.UNION for
|
|
93
|
+
* classic source-over stacking, e.g. segmentations; other alpha modes change
|
|
94
|
+
* only the opacity. MAX keeps each colour
|
|
95
|
+
* component's brightest opacity-weighted value (red + green = yellow, never
|
|
96
|
+
* clips, and a faint overlay never dims a bright one); with
|
|
97
|
+
* OVERLAY_ALPHA_BLEND.MAX it is the channel fusion of fluorescence viewers
|
|
98
|
+
* such as Allen's Vol-E.
|
|
83
99
|
*/
|
|
84
100
|
export declare enum OVERLAY_COLOR_BLEND {
|
|
85
101
|
ADDITIVE = 0,
|
|
86
|
-
MEAN = 1
|
|
102
|
+
MEAN = 1,
|
|
103
|
+
OVER = 2,
|
|
104
|
+
MAX = 3
|
|
87
105
|
}
|
|
88
106
|
/**
|
|
89
107
|
* The `VOLUME_RENDER_MODE` a caller-supplied `volumeRenderMode` means, or
|
|
@@ -285,7 +303,7 @@ export declare function lodOpacityScale(downsample: number, coefficient: number)
|
|
|
285
303
|
export declare function sliceTypeDim(sliceType: number): number;
|
|
286
304
|
/** Next view for the V hotkey: axial, coronal, sagittal, multiplanar, render, then wrap (as NiiVue 0.6). NONE restarts at axial. */
|
|
287
305
|
export declare function nextSliceType(sliceType: number): number;
|
|
288
|
-
export declare const NVD_DOCUMENT_VERSION =
|
|
306
|
+
export declare const NVD_DOCUMENT_VERSION = 11;
|
|
289
307
|
export declare const SCENE_DEFAULTS: {
|
|
290
308
|
azimuth: number;
|
|
291
309
|
elevation: number;
|
|
@@ -302,7 +320,22 @@ export declare const SCENE_DEFAULTS: {
|
|
|
302
320
|
export declare const LAYOUT_DEFAULTS: LayoutConfig;
|
|
303
321
|
export declare const UI_DEFAULTS: UIConfig;
|
|
304
322
|
export declare const VOLUME_DEFAULTS: VolumeRenderConfig;
|
|
323
|
+
/** Cinematic settings with bad values replaced by their defaults or bounds. */
|
|
324
|
+
export declare function clampCinematicOptions(o: Partial<CinematicOptions>): CinematicOptions;
|
|
325
|
+
/** `v` clamped to `range`; non-finite gives `fallback`. */
|
|
326
|
+
export declare function clampFinite(v: number, range: readonly [number, number], fallback: number): number;
|
|
327
|
+
/** A layout inset as four finite, non-negative CSS px; anything else side becomes 0. */
|
|
328
|
+
export declare function normalizeInset(v: unknown): [number, number, number, number];
|
|
329
|
+
/**
|
|
330
|
+
* `v` rounded to the nearest quarter turn, as 0, 90, 180 or 270 (-90 is 270).
|
|
331
|
+
* Non-finite or non-numeric gives 0.
|
|
332
|
+
*/
|
|
333
|
+
export declare function normalizeRotation2D(v: unknown): Rotation2D;
|
|
334
|
+
/** Ray-march samples per voxel, clamped to [1, 4]; non-finite gives the default. */
|
|
335
|
+
export declare function clampSampleRate(v: number): number;
|
|
305
336
|
export declare const MESH_DEFAULTS: MeshRenderConfig;
|
|
337
|
+
/** Crosscut line width, at least 0; non-finite gives the default. */
|
|
338
|
+
export declare function clampCrosscutWidth(v: number): number;
|
|
306
339
|
export declare const DRAW_DEFAULTS: DrawConfig;
|
|
307
340
|
export declare const INTERACTION_DEFAULTS: InteractionConfig;
|
|
308
341
|
export declare const ANNOTATION_DEFAULTS: AnnotationConfig;
|