@niivue/niivue 0.58.0 → 0.60.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/build/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { mat4, vec3, vec4, vec2 } from 'gl-matrix';
2
- import { NIFTI1, NIFTI2 } from 'nifti-reader-js';
2
+ import { NIFTI1, NIFTI2, NIFTIEXTENSION } from 'nifti-reader-js';
3
3
 
4
4
  type ColorMap = {
5
5
  R: number[];
@@ -52,8 +52,9 @@ type Geometry = {
52
52
  vao: WebGLVertexArrayObject | null;
53
53
  };
54
54
  /**
55
- * Object rendered with WebGL
56
- **/
55
+ * Represents a 3D object rendered with WebGL, including geometry, transformations, and rendering state.
56
+ * Used internally by Niivue for rendering meshes and crosshairs.
57
+ */
57
58
  declare class NiivueObject3D {
58
59
  static BLEND: number;
59
60
  static CULL_FACE: number;
@@ -295,7 +296,7 @@ declare const NVImageFromUrlOptions: (url: string, urlImageData?: string, name?:
295
296
 
296
297
  type TypedVoxelArray = Float32Array | Uint8Array | Int16Array | Float64Array | Uint16Array;
297
298
  /**
298
- * a NVImage encapsulates some images data and provides methods to query and operate on images
299
+ * a NVImage encapsulates some image data and provides methods to query and operate on images
299
300
  */
300
301
  declare class NVImage {
301
302
  name: string;
@@ -340,6 +341,7 @@ declare class NVImage {
340
341
  extentsMaxOrtho?: number[];
341
342
  mm2ortho?: mat4;
342
343
  hdr: NIFTI1 | NIFTI2 | null;
344
+ extensions?: NIFTIEXTENSION[];
343
345
  imageType?: ImageType;
344
346
  img?: TypedVoxelArray;
345
347
  imaginary?: Float32Array;
@@ -361,33 +363,6 @@ declare class NVImage {
361
363
  urlImgData?: string;
362
364
  isManifest?: boolean;
363
365
  limitFrames4D?: number;
364
- /**
365
- *
366
- * @param dataBuffer - an array buffer of image data to load (there are also methods that abstract this more. See loadFromUrl, and loadFromFile)
367
- * @param name - a name for this image. Default is an empty string
368
- * @param colormap - a color map to use. default is gray
369
- * @param opacity - the opacity for this image. default is 1
370
- * @param pairedImgData - Allows loading formats where header and image are separate files (e.g. nifti.hdr, nifti.img)
371
- * @param cal_min - minimum intensity for color brightness/contrast
372
- * @param cal_max - maximum intensity for color brightness/contrast
373
- * @param trustCalMinMax - whether or not to trust cal_min and cal_max from the nifti header (trusting results in faster loading)
374
- * @param percentileFrac - the percentile to use for setting the robust range of the display values (smart intensity setting for images with large ranges)
375
- * @param ignoreZeroVoxels - whether or not to ignore zero voxels in setting the robust range of display values
376
- * @param useQFormNotSForm - give precedence to QForm (Quaternion) or SForm (Matrix)
377
- * @param colormapNegative - a color map to use for symmetrical negative intensities
378
- * @param frame4D - volume displayed, 0 indexed, must be less than nFrame4D
379
- *
380
- * FIXME the following params are documented but not included in the actual constructor
381
- * @param onColormapChange - callback for color map change
382
- * @param onOpacityChange -callback for color map change
383
- *
384
- * TODO the following parameters were not documented
385
- * @param imageType - TODO
386
- * @param cal_minNeg - TODO
387
- * @param cal_maxNeg - TODO
388
- * @param colorbarVisible - TODO
389
- * @param colormapLabel - TODO
390
- */
391
366
  constructor(dataBuffer?: ArrayBuffer | ArrayBuffer[] | ArrayBufferLike | null, name?: string, colormap?: string, opacity?: number, pairedImgData?: ArrayBuffer | null, cal_min?: number, cal_max?: number, trustCalMinMax?: boolean, percentileFrac?: number, ignoreZeroVoxels?: boolean, useQFormNotSForm?: boolean, colormapNegative?: string, frame4D?: number, imageType?: ImageType, cal_minNeg?: number, cal_maxNeg?: number, colorbarVisible?: boolean, colormapLabel?: LUT | null, colormapType?: number);
392
367
  init(dataBuffer?: ArrayBuffer | ArrayBuffer[] | ArrayBufferLike | null, name?: string, colormap?: string, opacity?: number, _pairedImgData?: ArrayBuffer | null, cal_min?: number, cal_max?: number, trustCalMinMax?: boolean, percentileFrac?: number, ignoreZeroVoxels?: boolean, useQFormNotSForm?: boolean, colormapNegative?: string, frame4D?: number, imageType?: ImageType, cal_minNeg?: number, cal_maxNeg?: number, colorbarVisible?: boolean, colormapLabel?: LUT | null, colormapType?: number, imgRaw?: ArrayBuffer | ArrayBufferLike | null): void;
393
368
  static new(dataBuffer: ArrayBuffer | ArrayBuffer[] | ArrayBufferLike | null, name: string, colormap: string, opacity: number, pairedImgData: ArrayBuffer | null, cal_min: number, cal_max: number, trustCalMinMax: boolean, percentileFrac: number, ignoreZeroVoxels: boolean, useQFormNotSForm: boolean, colormapNegative: string, frame4D: number, imageType: ImageType, cal_minNeg: number, cal_maxNeg: number, colorbarVisible: boolean, colormapLabel: LUT | null, colormapType: number, zarrData: null | unknown): Promise<NVImage>;
@@ -430,7 +405,7 @@ declare class NVImage {
430
405
  * @param vol - volume for estimate (use -1 to use estimate on all loaded volumes; use INFINITY for current volume)
431
406
  * @param isBorder - if true (default) only center of volume used for estimate
432
407
  * @returns volume brightness and returns array [pct2, pct98, mnScale, mxScale]
433
- * @see {@link https://niivue.github.io/niivue/features/timeseries2.html | live demo usage}
408
+ * @see {@link https://niivue.com/demos/features/timeseries2.html | live demo usage}
434
409
  */
435
410
  calMinMax(vol?: number, isBorder?: boolean): number[];
436
411
  intensityRaw2Scaled(raw: number): number;
@@ -438,17 +413,11 @@ declare class NVImage {
438
413
  /**
439
414
  * Converts NVImage to NIfTI compliant byte array, potentially compressed.
440
415
  * Delegates to ImageWriter.saveToUint8Array.
441
- * @param fnm - Filename (determines if compression is needed via .gz suffix)
442
- * @param drawing8 - Optional Uint8Array drawing overlay
443
- * @returns Promise<Uint8Array>
444
416
  */
445
417
  saveToUint8Array(fnm: string, drawing8?: Uint8Array | null): Promise<Uint8Array>;
446
418
  /**
447
419
  * save image as NIfTI volume and trigger download.
448
420
  * Delegates to ImageWriter.saveToDisk.
449
- * @param fnm - Filename for download. If empty, returns data without download.
450
- * @param drawing8 - Optional Uint8Array drawing overlay
451
- * @returns Promise<Uint8Array>
452
421
  */
453
422
  saveToDisk(fnm?: string, drawing8?: Uint8Array | null): Promise<Uint8Array>;
454
423
  static fetchDicomData(url: string, headers?: Record<string, string>): Promise<Array<{
@@ -461,7 +430,6 @@ declare class NVImage {
461
430
  static loadInitialVolumes(url?: string, headers?: {}, limitFrames4D?: number): Promise<ArrayBuffer | null>;
462
431
  /**
463
432
  * factory function to load and return a new NVImage instance from a given URL
464
- * @returns NVImage instance
465
433
  */
466
434
  static loadFromUrl({ url, urlImgData, headers, name, colormap, opacity, cal_min, cal_max, trustCalMinMax, percentileFrac, ignoreZeroVoxels, useQFormNotSForm, colormapNegative, frame4D, isManifest, limitFrames4D, imageType, colorbarVisible, buffer }?: Partial<Omit<ImageFromUrlOptions, 'url'>> & {
467
435
  url?: string | Uint8Array | ArrayBuffer;
@@ -484,48 +452,31 @@ declare class NVImage {
484
452
  static createNiftiHeader(dims?: number[], pixDims?: number[], affine?: number[], datatypeCode?: NiiDataType): NIFTI1;
485
453
  /**
486
454
  * read a 3D slab of voxels from a volume
487
- * @param voxStart - first row, column and slice (RAS order) for selection
488
- * @param voxEnd - final row, column and slice (RAS order) for selection
489
- * @param dataType - array data type. Options: 'same' (default), 'uint8', 'float32', 'scaled', 'normalized', 'windowed'
490
- * @returns the an array where ret[0] is the voxel values and ret[1] is dimension of selection
491
- * @see {@link https://niivue.github.io/niivue/features/slab_selection.html | live demo usage}
455
+ * @see {@link https://niivue.com/demos/features/slab_selection.html | live demo usage}
492
456
  */
493
457
  /**
494
458
  * read a 3D slab of voxels from a volume, specified in RAS coordinates.
495
459
  * Delegates to VolumeUtils.getVolumeData.
496
- * @param voxStart - first row, column and slice (RAS order) for selection
497
- * @param voxEnd - final row, column and slice (RAS order) for selection
498
- * @param dataType - array data type. Options: 'same' (default), 'uint8', 'float32', 'scaled', 'normalized', 'windowed'
499
- * @returns the an array where ret[0] is the voxel values and ret[1] is dimension of selection
500
460
  */
501
461
  getVolumeData(voxStart?: number[], voxEnd?: number[], dataType?: string): [TypedVoxelArray, number[]];
502
462
  /**
503
463
  * write a 3D slab of voxels from a volume
504
- * @param voxStart - first row, column and slice (RAS order) for selection
505
- * @param voxEnd - final row, column and slice (RAS order) for selection
506
- * @param img - array of voxel values to insert (RAS order)
507
- * @see {@link https://niivue.github.io/niivue/features/slab_selection.html | live demo usage}
464
+ * @see {@link https://niivue.com/demos/features/slab_selection.html | live demo usage}
508
465
  */
509
466
  /**
510
467
  * write a 3D slab of voxels from a volume, specified in RAS coordinates.
511
468
  * Delegates to VolumeUtils.setVolumeData.
512
469
  * Input slabData is assumed to be in the correct raw data type for the target image.
513
- * @param voxStart - first row, column and slice (RAS order) for selection
514
- * @param voxEnd - final row, column and slice (RAS order) for selection
515
- * @param img - array of voxel values to insert (RAS order, raw data type)
516
470
  */
517
471
  setVolumeData(voxStart?: number[], voxEnd?: number[], img?: TypedVoxelArray): void;
518
472
  /**
519
473
  * factory function to load and return a new NVImage instance from a base64 encoded string
520
- *
521
- * @returns NVImage instance
522
474
  * @example
523
475
  * myImage = NVImage.loadFromBase64('SomeBase64String')
524
476
  */
525
477
  static loadFromBase64({ base64, name, colormap, opacity, cal_min, cal_max, trustCalMinMax, percentileFrac, ignoreZeroVoxels, useQFormNotSForm, colormapNegative, frame4D, imageType, cal_minNeg, cal_maxNeg, colorbarVisible, colormapLabel }: ImageFromBase64): Promise<NVImage>;
526
478
  /**
527
479
  * make a clone of a NVImage instance and return a new NVImage
528
- * @returns NVImage instance
529
480
  * @example
530
481
  * myImage = NVImage.loadFromFile(SomeFileObject) // files can be from dialogs or drag and drop
531
482
  * clonedImage = myImage.clone()
@@ -544,9 +495,6 @@ declare class NVImage {
544
495
  getImageMetadata(): ImageMetadata;
545
496
  /**
546
497
  * a factory function to make a zero filled image given a NVImage as a reference
547
- * @param nvImage - an existing NVImage as a reference
548
- * @param dataType - the output data type. Options: 'same', 'uint8'
549
- * @returns new NVImage filled with zeros for the image data
550
498
  * @example
551
499
  * myImage = NVImage.loadFromFile(SomeFileObject) // files can be from dialogs or drag and drop
552
500
  * newZeroImage = NVImage.zerosLike(myImage)
@@ -555,12 +503,6 @@ declare class NVImage {
555
503
  /**
556
504
  * Returns voxel intensity at specific native coordinates.
557
505
  * Delegates to VolumeUtils.getValue.
558
- * @param x - Native X coordinate (0-indexed)
559
- * @param y - Native Y coordinate (0-indexed)
560
- * @param z - Native Z coordinate (0-indexed)
561
- * @param frame4D - 4D frame index (0-indexed)
562
- * @param isReadImaginary - Flag to read from imaginary data array
563
- * @returns Scaled voxel intensity
564
506
  */
565
507
  getValue(x: number, y: number, z: number, frame4D?: number, isReadImaginary?: boolean): number;
566
508
  /**
@@ -572,8 +514,6 @@ declare class NVImage {
572
514
  * Converts NVImage to NIfTI compliant byte array.
573
515
  * Handles potential re-orientation of drawing data.
574
516
  * Delegates to ImageWriter.toUint8Array.
575
- * @param drawingBytes - Optional Uint8Array drawing overlay
576
- * @returns Uint8Array
577
517
  */
578
518
  toUint8Array(drawingBytes?: Uint8Array | null): Uint8Array;
579
519
  convertVox2Frac(vox: vec3): vec3;
@@ -658,7 +598,8 @@ declare enum DRAG_MODE {
658
598
  pan = 3,
659
599
  slicer3D = 4,
660
600
  callbackOnly = 5,
661
- roiSelection = 6
601
+ roiSelection = 6,
602
+ angle = 7
662
603
  }
663
604
  declare enum DRAG_MODE_SECONDARY {
664
605
  none = 0,
@@ -667,7 +608,8 @@ declare enum DRAG_MODE_SECONDARY {
667
608
  pan = 3,
668
609
  slicer3D = 4,
669
610
  callbackOnly = 5,
670
- roiSelection = 6
611
+ roiSelection = 6,
612
+ angle = 7
671
613
  }
672
614
  declare enum DRAG_MODE_PRIMARY {
673
615
  crosshair = 0,
@@ -683,6 +625,8 @@ declare enum COLORMAP_TYPE {
683
625
  */
684
626
  type NVConfigOptions = {
685
627
  textHeight: number;
628
+ fontSizeScaling: number;
629
+ fontMinPx: number;
686
630
  colorbarHeight: number;
687
631
  colorbarWidth: number;
688
632
  showColorbarBorder: boolean;
@@ -709,6 +653,7 @@ type NVConfigOptions = {
709
653
  keyDebounceTime: number;
710
654
  isNearestInterpolation: boolean;
711
655
  atlasOutline: number;
656
+ atlasActiveIndex: number;
712
657
  isRuler: boolean;
713
658
  isColorbar: boolean;
714
659
  isOrientCube: boolean;
@@ -863,6 +808,8 @@ declare class NVDocument {
863
808
  drawBitmap: Uint8Array | null;
864
809
  imageOptionsMap: Map<any, any>;
865
810
  meshOptionsMap: Map<any, any>;
811
+ private _optsProxy;
812
+ private _optsChangeCallback;
866
813
  constructor();
867
814
  /**
868
815
  * Title of the document
@@ -973,6 +920,18 @@ declare class NVDocument {
973
920
  * Factory method to return an instance of NVDocument from JSON
974
921
  */
975
922
  static oldloadFromJSON(data: DocumentData): NVDocument;
923
+ /**
924
+ * Sets the callback function to be called when opts properties change
925
+ */
926
+ setOptsChangeCallback(callback: (propertyName: keyof NVConfigOptions, newValue: NVConfigOptions[keyof NVConfigOptions], oldValue: NVConfigOptions[keyof NVConfigOptions]) => void): void;
927
+ /**
928
+ * Removes the opts change callback
929
+ */
930
+ removeOptsChangeCallback(): void;
931
+ /**
932
+ * Creates a Proxy wrapper around the opts object to detect changes
933
+ */
934
+ private _createOptsProxy;
976
935
  }
977
936
 
978
937
  type NiftiHeader = {
@@ -1257,12 +1216,21 @@ declare class NVMeshFromUrlOptions {
1257
1216
  colorbarVisible: boolean;
1258
1217
  constructor(url?: string, gl?: any, name?: string, opacity?: number, rgba255?: Uint8Array, visible?: boolean, layers?: any[], colorbarVisible?: boolean);
1259
1218
  }
1219
+ /**
1220
+ * Parameters for loading a base mesh or volume.
1221
+ */
1260
1222
  type BaseLoadParams = {
1223
+ /** WebGL rendering context. */
1261
1224
  gl: WebGL2RenderingContext;
1225
+ /** Name for this image. Default is an empty string. */
1262
1226
  name: string;
1227
+ /** Opacity for this image. Default is 1. */
1263
1228
  opacity: number;
1229
+ /** Base color of the mesh in RGBA [0-255]. Default is white. */
1264
1230
  rgba255: number[] | Uint8Array;
1231
+ /** Whether this image is visible. */
1265
1232
  visible: boolean;
1233
+ /** Layers of the mesh to load. */
1266
1234
  layers: NVMeshLayer[];
1267
1235
  };
1268
1236
  type LoadFromUrlParams = Partial<BaseLoadParams> & {
@@ -1507,6 +1475,9 @@ declare class NVMeshUtilities {
1507
1475
  static generateNormals(pts: number[] | Float32Array, tris: number[] | Uint32Array): Float32Array;
1508
1476
  }
1509
1477
 
1478
+ /**
1479
+ * Entry representing a single colormap with display properties.
1480
+ */
1510
1481
  type ColormapListEntry = {
1511
1482
  name: string;
1512
1483
  min: number;
@@ -1600,6 +1571,8 @@ type UIData = {
1600
1571
  max3D?: number;
1601
1572
  windowX: number;
1602
1573
  windowY: number;
1574
+ angleFirstLine: number[];
1575
+ angleState: 'none' | 'drawing_first_line' | 'drawing_second_line' | 'complete';
1603
1576
  };
1604
1577
  type SaveImageOptions = {
1605
1578
  filename: string;
@@ -1633,6 +1606,7 @@ declare class Niivue {
1633
1606
  volumeTexture: WebGLTexture | null;
1634
1607
  gradientTexture: WebGLTexture | null;
1635
1608
  gradientTextureAmount: number;
1609
+ useCustomGradientTexture: boolean;
1636
1610
  renderGradientValues: boolean;
1637
1611
  drawTexture: WebGLTexture | null;
1638
1612
  drawUndoBitmaps: Uint8Array[];
@@ -1695,6 +1669,8 @@ declare class Niivue {
1695
1669
  private DEFAULT_FONT_METRICS;
1696
1670
  private fontMetrics?;
1697
1671
  private fontMets;
1672
+ private fontPx;
1673
+ private legendFontScaling;
1698
1674
  backgroundMasksOverlays: number;
1699
1675
  overlayOutlineWidth: number;
1700
1676
  overlayAlphaShader: number;
@@ -1749,6 +1725,7 @@ declare class Niivue {
1749
1725
  dragModes: {
1750
1726
  contrast: DRAG_MODE;
1751
1727
  measurement: DRAG_MODE;
1728
+ angle: DRAG_MODE;
1752
1729
  none: DRAG_MODE;
1753
1730
  pan: DRAG_MODE;
1754
1731
  slicer3D: DRAG_MODE;
@@ -1931,12 +1908,32 @@ declare class Niivue {
1931
1908
  * }
1932
1909
  */
1933
1910
  onDocumentLoaded: (document: NVDocument) => void;
1911
+ /**
1912
+ * Callback for when any configuration option changes.
1913
+ * @param propertyName - The name of the option that changed.
1914
+ * @param newValue - The new value of the option.
1915
+ * @param oldValue - The previous value of the option.
1916
+ */
1917
+ onOptsChange: (propertyName: keyof NVConfigOptions, newValue: NVConfigOptions[keyof NVConfigOptions], oldValue: NVConfigOptions[keyof NVConfigOptions]) => void;
1934
1918
  document: NVDocument;
1919
+ /** Get the current scene configuration. */
1935
1920
  get scene(): Scene;
1921
+ /** Get the current visualization options. */
1936
1922
  get opts(): NVConfigOptions;
1923
+ /** Get the slice mosaic layout string. */
1937
1924
  get sliceMosaicString(): string;
1925
+ /** Set the slice mosaic layout string. */
1938
1926
  set sliceMosaicString(newSliceMosaicString: string);
1927
+ /**
1928
+ * Get whether voxels below minimum intensity are drawn as dark or transparent.
1929
+ * @returns {boolean} True if dark voxels are opaque, false if transparent.
1930
+ */
1939
1931
  get isAlphaClipDark(): boolean;
1932
+ /**
1933
+ * Set whether voxels below minimum intensity are drawn as dark or transparent.
1934
+ * @param {boolean} newVal - True to make dark voxels opaque, false for transparent.
1935
+ * @see {@link https://niivue.com/demos/features/segment.html | live demo usage}
1936
+ */
1940
1937
  set isAlphaClipDark(newVal: boolean);
1941
1938
  mediaUrlMap: Map<NVImage | NVMesh, string>;
1942
1939
  initialized: boolean;
@@ -1964,7 +1961,7 @@ declare class Niivue {
1964
1961
  * save webgl2 canvas as png format bitmap
1965
1962
  * @param filename - filename for screen capture
1966
1963
  * @example niivue.saveScene('test.png');
1967
- * @see {@link https://niivue.github.io/niivue/features/ui.html | live demo usage}
1964
+ * @see {@link https://niivue.com/demos/features/ui.html | live demo usage}
1968
1965
  */
1969
1966
  saveScene(filename?: string): Promise<void>;
1970
1967
  /**
@@ -1973,7 +1970,7 @@ declare class Niivue {
1973
1970
  * @param isAntiAlias - determines if anti-aliasing is requested (if not specified, AA usage depends on hardware)
1974
1971
  * @example niivue = new Niivue().attachTo('gl')
1975
1972
  * @example await niivue.attachTo('gl')
1976
- * @see {@link https://niivue.github.io/niivue/features/basic.multiplanar.html | live demo usage}
1973
+ * @see {@link https://niivue.com/demos/features/basic.multiplanar.html | live demo usage}
1977
1974
  */
1978
1975
  attachTo(id: string, isAntiAlias?: any): Promise<this>;
1979
1976
  /**
@@ -1982,6 +1979,7 @@ declare class Niivue {
1982
1979
  * @example
1983
1980
  * niivue = new Niivue()
1984
1981
  * await niivue.attachToCanvas(document.getElementById(id))
1982
+ * @see {@link https://niivue.com/demos/features/dsistudio.html | live demo usage}
1985
1983
  */
1986
1984
  attachToCanvas(canvas: HTMLCanvasElement, isAntiAlias?: boolean | null): Promise<this>;
1987
1985
  /**
@@ -1992,7 +1990,7 @@ declare class Niivue {
1992
1990
  * niivue2 = new Niivue()
1993
1991
  * niivue2.syncWith(niivue1)
1994
1992
  * @deprecated use broadcastTo instead
1995
- * @see {@link https://niivue.github.io/niivue/features/sync.mesh.html | live demo usage}
1993
+ * @see {@link https://niivue.com/demos/features/sync.mesh.html | live demo usage}
1996
1994
  */
1997
1995
  syncWith(otherNV: Niivue | Niivue[], syncOpts?: {
1998
1996
  '2d': boolean;
@@ -2007,20 +2005,52 @@ declare class Niivue {
2007
2005
  * niivue3 = new Niivue()
2008
2006
  * niivue1.broadcastTo(niivue2)
2009
2007
  * niivue1.broadcastTo([niivue2, niivue3])
2010
- * @see {@link https://niivue.github.io/niivue/features/sync.mesh.html | live demo usage}
2008
+ * @see {@link https://niivue.com/demos/features/sync.mesh.html | live demo usage}
2011
2009
  */
2012
2010
  broadcastTo(otherNV: Niivue | Niivue[], syncOpts?: {
2013
2011
  '2d': boolean;
2014
2012
  '3d': boolean;
2015
2013
  }): void;
2014
+ /**
2015
+ * Synchronizes 3D view settings (azimuth, elevation, scale) with another Niivue instance.
2016
+ * @internal
2017
+ */
2016
2018
  doSync3d(otherNV: Niivue): void;
2019
+ /**
2020
+ * Synchronizes 2D crosshair position and pan settings with another Niivue instance.
2021
+ * @internal
2022
+ */
2017
2023
  doSync2d(otherNV: Niivue): void;
2018
2024
  doSyncGamma(otherNV: Niivue): void;
2025
+ /**
2026
+ * Synchronizes gamma correction setting with another Niivue instance.
2027
+ * @internal
2028
+ */
2019
2029
  doSyncZoomPan(otherNV: Niivue): void;
2030
+ /**
2031
+ * Synchronizes crosshair position with another Niivue instance.
2032
+ * @internal
2033
+ */
2020
2034
  doSyncCrosshair(otherNV: Niivue): void;
2035
+ /**
2036
+ * Synchronizes cal_min with another Niivue instance, updating GPU volume only if needed.
2037
+ * @internal
2038
+ */
2021
2039
  doSyncCalMin(otherNV: Niivue): void;
2040
+ /**
2041
+ * Synchronizes cal_max with another Niivue instance, updating GPU volume only if needed.
2042
+ * @internal
2043
+ */
2022
2044
  doSyncCalMax(otherNV: Niivue): void;
2045
+ /**
2046
+ * Synchronizes slice view type with another Niivue instance.
2047
+ * @internal
2048
+ */
2023
2049
  doSyncSliceType(otherNV: Niivue): void;
2050
+ /**
2051
+ * Synchronizes clip plane settings with another Niivue instance.
2052
+ * @internal
2053
+ */
2024
2054
  doSyncClipPlane(otherNV: Niivue): void;
2025
2055
  /**
2026
2056
  * Sync the scene controls (orientation, crosshair location, etc.) from one Niivue instance to another. useful for using one canvas to drive another.
@@ -2033,6 +2063,7 @@ declare class Niivue {
2033
2063
  */
2034
2064
  sync(): void;
2035
2065
  /** Not documented publicly for now
2066
+ * @internal
2036
2067
  * test if two arrays have equal values for each element
2037
2068
  * @param a - the first array
2038
2069
  * @param b - the second array
@@ -2041,6 +2072,13 @@ declare class Niivue {
2041
2072
  * TODO this should maybe just use array-equal from NPM
2042
2073
  */
2043
2074
  arrayEquals(a: unknown[], b: unknown[]): boolean;
2075
+ /**
2076
+ * @internal
2077
+ * Compute point size for screen text that scales with resolution and screen size.
2078
+ * - Keeps physical font size consistent across different DPIs.
2079
+ * - Uses fontSizeScaling to scale with canvas size above a reference threshold.
2080
+ */
2081
+ textSizePoints(): void;
2044
2082
  /**
2045
2083
  * callback function to handle resize window events, redraws the scene.
2046
2084
  * @internal
@@ -2055,65 +2093,189 @@ declare class Niivue {
2055
2093
  x: number;
2056
2094
  y: number;
2057
2095
  } | undefined;
2096
+ /**
2097
+ * Returns mouse position relative to the canvas, excluding padding and borders.
2098
+ * @internal
2099
+ */
2058
2100
  getNoPaddingNoBorderCanvasRelativeMousePosition(event: MouseEvent, target: EventTarget): {
2059
2101
  x: number;
2060
2102
  y: number;
2061
2103
  } | undefined;
2104
+ /**
2105
+ * Disables the default context menu to allow custom right-click behavior.
2106
+ * @internal
2107
+ */
2062
2108
  mouseContextMenuListener(e: MouseEvent): void;
2109
+ /**
2110
+ * Handles mouse down events for interaction, segmentation, and connectome label selection.
2111
+ * Routes to appropriate button handler based on click type.
2112
+ * @internal
2113
+ */
2063
2114
  mouseDownListener(e: MouseEvent): void;
2115
+ /**
2116
+ * Handles left mouse button actions for crosshair or windowing mode.
2117
+ * @internal
2118
+ */
2064
2119
  mouseLeftButtonHandler(e: MouseEvent): void;
2120
+ /**
2121
+ * Handles center mouse button drag to initiate 2D panning or clip plane adjustment.
2122
+ * @internal
2123
+ */
2065
2124
  mouseCenterButtonHandler(e: MouseEvent): void;
2125
+ /**
2126
+ * Handles right mouse button drag to enable 2D panning or clip plane control.
2127
+ * @internal
2128
+ */
2066
2129
  mouseRightButtonHandler(e: MouseEvent): void;
2067
2130
  /**
2068
2131
  * calculate the the min and max voxel indices from an array of two values (used in selecting intensities with the selection box)
2132
+ * @internal
2069
2133
  * @param array - an array of two values
2070
2134
  * @returns an array of two values representing the min and max voxel indices
2071
2135
  */
2072
2136
  calculateMinMaxVoxIdx(array: number[]): number[];
2137
+ /**
2138
+ * Updates cal_min and cal_max based on intensity range within the drag-selected voxel region.
2139
+ * Skips if no drag occurred, volume is missing, or selection has no variation.
2140
+ * @internal
2141
+ */
2073
2142
  calculateNewRange({ volIdx }?: {
2074
2143
  volIdx?: number;
2075
2144
  }): void;
2145
+ /**
2146
+ * Triggers a drag-release callback with voxel, mm, and tile info from the drag gesture.
2147
+ * @internal
2148
+ */
2076
2149
  generateMouseUpCallback(fracStart: vec3, fracEnd: vec3): void;
2150
+ /**
2151
+ * Handles mouse up events, finalizing drag actions, invoking callbacks, and updating contrast if needed.
2152
+ * @internal
2153
+ */
2077
2154
  mouseUpListener(): void;
2155
+ /**
2156
+ * Handles initial touch event to simulate mouse click if not in a multi-touch gesture.
2157
+ * @internal
2158
+ */
2078
2159
  checkMultitouch(e: TouchEvent): void;
2160
+ /**
2161
+ * Handles touch start events, detecting double taps and preparing for gesture or contrast reset.
2162
+ * @internal
2163
+ */
2079
2164
  touchStartListener(e: TouchEvent): void;
2165
+ /**
2166
+ * Handles touch end events, finalizing gestures and contrast adjustments, then triggers mouse up logic.
2167
+ * @internal
2168
+ */
2080
2169
  touchEndListener(e: TouchEvent): void;
2170
+ /**
2171
+ * Adjusts window/level (cal_min and cal_max) based on mouse or touch drag direction.
2172
+ * @internal
2173
+ */
2081
2174
  windowingHandler(x: number, y: number, volIdx?: number): void;
2175
+ /**
2176
+ * Handles mouse leaving the canvas, resetting segmentation, drawing, and drag states.
2177
+ * @internal
2178
+ */
2082
2179
  mouseLeaveListener(): void;
2180
+ /**
2181
+ * Handles mouse move events for dragging, crosshair movement, windowing, and click-to-segment preview.
2182
+ * @internal
2183
+ */
2083
2184
  mouseMoveListener(e: MouseEvent): void;
2185
+ /**
2186
+ * Resets brightness and contrast to robust min/max unless in render mode or during interaction.
2187
+ * @internal
2188
+ */
2084
2189
  resetBriCon(msg?: TouchEvent | MouseEvent | null): void;
2190
+ /**
2191
+ * Sets the drag start position in canvas coordinates.
2192
+ * @internal
2193
+ */
2085
2194
  setDragStart(x: number, y: number): void;
2195
+ /**
2196
+ * Sets the drag end position in canvas coordinates.
2197
+ * @internal
2198
+ */
2086
2199
  setDragEnd(x: number, y: number): void;
2200
+ /**
2201
+ * Handles touch movement for crosshair, windowing, and pinch-to-zoom interactions.
2202
+ * @internal
2203
+ */
2087
2204
  touchMoveListener(e: TouchEvent): void;
2205
+ /**
2206
+ * Handles pinch-to-zoom gestures for scrolling 2D slices.
2207
+ * @internal
2208
+ */
2088
2209
  handlePinchZoom(e: TouchEvent): void;
2210
+ /**
2211
+ * Handles keyboard shortcuts for toggling clip planes and slice view modes with debounce logic.
2212
+ * @internal
2213
+ */
2089
2214
  keyUpListener(e: KeyboardEvent): void;
2215
+ /**
2216
+ * Handles key down events for navigation, rendering controls, slice movement, and mode switching.
2217
+ * @internal
2218
+ */
2090
2219
  keyDownListener(e: KeyboardEvent): void;
2220
+ /**
2221
+ * Handles scroll wheel events for slice scrolling, ROI box resizing, zooming, or segmentation thresholding.
2222
+ * @internal
2223
+ */
2091
2224
  wheelListener(e: WheelEvent): void;
2225
+ /**
2226
+ * Registers all mouse, touch, keyboard, and drag event listeners for canvas interaction.
2227
+ * n.b. any event listeners registered here should also be removed in `cleanup()`
2228
+ * @internal
2229
+ */
2092
2230
  registerInteractions(): void;
2231
+ /**
2232
+ * Prevents default behavior when a dragged item enters the canvas.
2233
+ * @internal
2234
+ */
2093
2235
  dragEnterListener(e: MouseEvent): void;
2236
+ /**
2237
+ * Prevents default behavior when a dragged item is over the canvas.
2238
+ * @internal
2239
+ */
2094
2240
  dragOverListener(e: MouseEvent): void;
2241
+ /**
2242
+ * Extracts and normalizes the file extension, handling special cases like .gz and .cbor.
2243
+ * @internal
2244
+ */
2095
2245
  getFileExt(fullname: string, upperCase?: boolean): string;
2096
2246
  /**
2097
2247
  * Add an image and notify subscribers
2098
- * @see {@link https://niivue.github.io/niivue/features/document.3d.html | live demo usage}
2248
+ * @see {@link https://niivue.com/demos/features/document.3d.html | live demo usage}
2099
2249
  */
2100
2250
  addVolumeFromUrl(imageOptions: ImageFromUrlOptions): Promise<NVImage>;
2101
2251
  addVolumesFromUrl(imageOptionsArray: ImageFromUrlOptions[]): Promise<NVImage[]>;
2102
2252
  /**
2103
- * Find media by url
2253
+ * Returns the media object associated with the given URL, if any.
2254
+ * @internal
2104
2255
  */
2105
2256
  getMediaByUrl(url: string): NVImage | NVMesh | undefined;
2106
2257
  /**
2107
2258
  * Remove volume by url
2108
2259
  * @param url - Volume added by url to remove
2109
- * @see {@link https://niivue.github.io/niivue/features/document.3d.html | live demo usage}
2260
+ * @see {@link https://niivue.com/demos/features/document.3d.html | live demo usage}
2110
2261
  */
2111
2262
  removeVolumeByUrl(url: string): void;
2263
+ /**
2264
+ * Recursively traverses a file tree, populating file paths for directory uploads.
2265
+ * Adds `_webkitRelativePath` to each file for compatibility with tools like dcm2niix.
2266
+ * @internal
2267
+ */
2112
2268
  traverseFileTree(item: any, path: string, fileArray: any): Promise<File[]>;
2269
+ /**
2270
+ * Recursively reads a directory and logs the File objects contained within.
2271
+ * Used for processing dropped folders via drag-and-drop.
2272
+ * @internal
2273
+ */
2113
2274
  readDirectory(directory: FileSystemDirectoryEntry): FileSystemEntry[];
2114
2275
  /**
2115
2276
  * Returns boolean: true if filename ends with mesh extension (TRK, pial, etc)
2116
2277
  * @param url - filename
2278
+ * @internal
2117
2279
  */
2118
2280
  isMeshExt(url: string): boolean;
2119
2281
  /**
@@ -2124,46 +2286,87 @@ declare class Niivue {
2124
2286
  */
2125
2287
  loadFromArrayBuffer(buffer: ArrayBuffer, name: string): Promise<void>;
2126
2288
  /**
2127
- * Load a mesh or image from a file object
2128
- * @param file - File object
2289
+ * Load a mesh or image volume from a File object
2290
+ * @param file - File object selected by the user (e.g. from an HTML input element)
2291
+ * @returns a Promise that resolves when the file has been loaded and added to the scene
2292
+ * @see {@link https://niivue.com/demos/features/selectfont.html | live demo usage}
2129
2293
  */
2130
2294
  loadFromFile(file: File): Promise<void>;
2295
+ /**
2296
+ * Registers a custom external file loader for handling specific file types in Niivue.
2297
+ *
2298
+ * This method allows you to define how certain file extensions are handled when loaded into Niivue.
2299
+ * The provided `loader` function should return an object containing an `ArrayBuffer` of the file's contents
2300
+ * and the file extension (used for inferring how Niivue should process the data).
2301
+ *
2302
+ * Optionally, `positions` and `indices` can be returned to support loading mesh data (e.g. `.mz3` format).
2303
+ *
2304
+ * @example
2305
+ * const myCustomLoader = async (file) => {
2306
+ * const arrayBuffer = await file.arrayBuffer()
2307
+ * return {
2308
+ * arrayBuffer,
2309
+ * fileExt: 'iwi.cbor',
2310
+ * positions: new Float32Array(...),
2311
+ * indices: new Uint32Array(...)
2312
+ * }
2313
+ * }
2314
+ *
2315
+ * nv.useLoader(myCustomLoader, 'iwi.cbor', 'nii')
2316
+ *
2317
+ * @param loader - A function that accepts a `File` or `ArrayBuffer` and returns an object with `arrayBuffer` and `fileExt` properties. May also return `positions` and `indices` for meshes.
2318
+ * @param fileExt - The original file extension (e.g. 'iwi.cbor') to associate with this loader.
2319
+ * @param toExt - The target file extension Niivue should treat the file as (e.g. 'nii' or 'mz3').
2320
+ */
2131
2321
  useLoader(loader: unknown, fileExt: string, toExt: string): void;
2322
+ /**
2323
+ * Set a custom loader for handling DICOM files.
2324
+ */
2132
2325
  useDicomLoader(loader: DicomLoader): void;
2326
+ /**
2327
+ * Get the currently assigned DICOM loader.
2328
+ */
2133
2329
  getDicomLoader(): DicomLoader;
2330
+ /**
2331
+ * Handles file and URL drag-and-drop events on the canvas.
2332
+ * Supports loading of volumes, meshes, NVD documents, and DICOM directories.
2333
+ * Honors modifier keys (e.g., Shift to replace, Alt for drawing overlays).
2334
+ * @internal
2335
+ */
2134
2336
  dropListener(e: DragEvent): Promise<void>;
2135
2337
  /**
2136
2338
  * insert a gap between slices of a mutliplanar view.
2137
2339
  * @param pixels - spacing between tiles of multiplanar view
2138
2340
  * @example niivue.setMultiplanarPadPixels(4)
2139
- * @see {@link https://niivue.github.io/niivue/features/atlas.html | live demo usage}
2341
+ * @see {@link https://niivue.com/demos/features/atlas.html | live demo usage}
2140
2342
  */
2141
2343
  setMultiplanarPadPixels(pixels: number): void;
2142
2344
  /**
2143
2345
  * control placement of 2D slices.
2144
2346
  * @param layout - AUTO: 0, COLUMN: 1, GRID: 2, ROW: 3,
2145
2347
  * @example niivue.setMultiplanarLayout(2)
2146
- * @see {@link https://niivue.github.io/niivue/features/layout.html | live demo usage}
2348
+ * @see {@link https://niivue.com/demos/features/layout.html | live demo usage}
2147
2349
  */
2148
2350
  setMultiplanarLayout(layout: number): void;
2149
2351
  /**
2150
2352
  * determine if text appears at corner (true) or sides of 2D slice.
2151
2353
  * @param isCornerOrientationText - controls position of text
2152
2354
  * @example niivue.setCornerOrientationText(true)
2153
- * @see {@link https://niivue.github.io/niivue/features/worldspace2.html | live demo usage}
2355
+ * @see {@link https://niivue.com/demos/features/worldspace2.html | live demo usage}
2154
2356
  */
2155
2357
  setCornerOrientationText(isCornerOrientationText: boolean): void;
2156
2358
  /**
2157
- * determine if orientation text appears in 2D slice view.
2158
- * @param isOrientationTextVisible - controls position of text
2359
+ * Show or hide orientation labels (e.g., L/R, A/P) in 2D slice views
2360
+ * @param isOrientationTextVisible - whether orientation text should be displayed
2159
2361
  * @example niivue.setIsOrientationTextVisible(false)
2362
+ * @see {@link https://niivue.com/demos/features/basic.multiplanar.html | live demo usage}
2160
2363
  */
2161
2364
  setIsOrientationTextVisible(isOrientationTextVisible: boolean): void;
2162
2365
  /**
2163
2366
  * determine proportion of screen real estate devoted to rendering in multiplanar view.
2164
2367
  * @param fraction - proportion of screen devoted to primary (hero) image (0 to disable)
2165
2368
  * @example niivue.setHeroImage(0.5)
2166
- * @see {@link https://niivue.github.io/niivue/features/layout.html | live demo usage}
2369
+ * @see {@link https://niivue.com/demos/features/layout.html | live demo usage}
2167
2370
  */
2168
2371
  setHeroImage(fraction: number): void;
2169
2372
  /**
@@ -2214,7 +2417,7 @@ declare class Niivue {
2214
2417
  * control whether 2D slices use radiological or neurological convention.
2215
2418
  * @param isRadiologicalConvention - new display convention
2216
2419
  * @example niivue.setRadiologicalConvention(true)
2217
- * @see {@link https://niivue.github.io/niivue/features/worldspace.html | live demo usage}
2420
+ * @see {@link https://niivue.com/demos/features/worldspace.html | live demo usage}
2218
2421
  */
2219
2422
  setRadiologicalConvention(isRadiologicalConvention: boolean): void;
2220
2423
  /**
@@ -2222,35 +2425,35 @@ declare class Niivue {
2222
2425
  * @param options - @see NiiVueOptions
2223
2426
  * @param resetBriCon - also reset contrast (default false).
2224
2427
  * @example niivue.nv1.setDefaults(opts, true);
2225
- * @see {@link https://niivue.github.io/niivue/features/connectome.html | live demo usage}
2428
+ * @see {@link https://niivue.com/demos/features/connectome.html | live demo usage}
2226
2429
  */
2227
2430
  setDefaults(options?: Partial<NVConfigOptions>, resetBriCon?: boolean): void;
2228
2431
  /**
2229
2432
  * Limit visibility of mesh in front of a 2D image. Requires world-space mode.
2230
2433
  * @param meshThicknessOn2D - distance from voxels for clipping mesh. Use Infinity to show entire mesh or 0.0 to hide mesh.
2231
2434
  * @example niivue.setMeshThicknessOn2D(42)
2232
- * @see {@link https://niivue.github.io/niivue/features/worldspace2.html | live demo usage}
2435
+ * @see {@link https://niivue.com/demos/features/worldspace2.html | live demo usage}
2233
2436
  */
2234
2437
  setMeshThicknessOn2D(meshThicknessOn2D: number): void;
2235
2438
  /**
2236
2439
  * Create a custom multi-slice mosaic (aka lightbox, montage) view.
2237
2440
  * @param str - description of mosaic.
2238
2441
  * @example niivue.setSliceMosaicString("A 0 20 C 30 S 42")
2239
- * @see {@link https://niivue.github.io/niivue/features/mosaics.html | live demo usage}
2442
+ * @see {@link https://niivue.com/demos/features/mosaics.html | live demo usage}
2240
2443
  */
2241
2444
  setSliceMosaicString(str: string): void;
2242
2445
  /**
2243
2446
  * control 2D slice view mode.
2244
2447
  * @param isSliceMM - control whether 2D slices use world space (true) or voxel space (false). Beware that voxel space mode limits properties like panning, zooming and mesh visibility.
2245
2448
  * @example niivue.setSliceMM(true)
2246
- * @see {@link https://niivue.github.io/niivue/features/worldspace2.html | live demo usage}
2449
+ * @see {@link https://niivue.com/demos/features/worldspace2.html | live demo usage}
2247
2450
  */
2248
2451
  setSliceMM(isSliceMM: boolean): void;
2249
2452
  /**
2250
2453
  * control whether voxel overlays are combined using additive (emission) or traditional (transmission) blending.
2251
2454
  * @param isAdditiveBlend - emission (true) or transmission (false) mixing
2252
2455
  * @example niivue.isAdditiveBlend(true)
2253
- * @see {@link https://niivue.github.io/niivue/features/additive.voxels.html | live demo usage}
2456
+ * @see {@link https://niivue.com/demos/features/additive.voxels.html | live demo usage}
2254
2457
  */
2255
2458
  setAdditiveBlend(isAdditiveBlend: boolean): void;
2256
2459
  /**
@@ -2263,16 +2466,34 @@ declare class Niivue {
2263
2466
  * Force WebGL canvas to use high resolution display, regardless of browser defaults.
2264
2467
  * @param forceDevicePixelRatio - -1: block high DPI; 0= allow high DPI: >0 use specified pixel ratio
2265
2468
  * @example niivue.setHighResolutionCapable(true);
2266
- * @see {@link https://niivue.github.io/niivue/features/sync.mesh.html | live demo usage}
2469
+ * @see {@link https://niivue.com/demos/features/sync.mesh.html | live demo usage}
2267
2470
  */
2268
2471
  setHighResolutionCapable(forceDevicePixelRatio: number | boolean): void;
2472
+ /**
2473
+ * Start watching for changes to configuration options.
2474
+ * This is a convenience method that sets up the onOptsChange callback.
2475
+ * @param callback - Function to call when any option changes
2476
+ * @example
2477
+ * niivue.watchOptsChanges((propertyName, newValue, oldValue) => {
2478
+ * console.log(`Option ${propertyName} changed from ${oldValue} to ${newValue}`)
2479
+ * })
2480
+ * @see {@link https://niivue.com/demos/ | live demo usage}
2481
+ */
2482
+ watchOptsChanges(callback: (propertyName: keyof NVConfigOptions, newValue: NVConfigOptions[keyof NVConfigOptions], oldValue: NVConfigOptions[keyof NVConfigOptions]) => void): void;
2483
+ /**
2484
+ * Stop watching for changes to configuration options.
2485
+ * This removes the current onOptsChange callback.
2486
+ * @example niivue.unwatchOptsChanges()
2487
+ * @see {@link https://niivue.com/demos/ | live demo usage}
2488
+ */
2489
+ unwatchOptsChanges(): void;
2269
2490
  /**
2270
2491
  * add a new volume to the canvas
2271
2492
  * @param volume - the new volume to add to the canvas
2272
2493
  * @example
2273
2494
  * niivue = new Niivue()
2274
2495
  * niivue.addVolume(NVImage.loadFromUrl({url:'../someURL.nii.gz'}))
2275
- * @see {@link https://niivue.github.io/niivue/features/document.3d.html | live demo usage}
2496
+ * @see {@link https://niivue.com/demos/features/conform.html | live demo usage}
2276
2497
  */
2277
2498
  addVolume(volume: NVImage): void;
2278
2499
  /**
@@ -2281,7 +2502,7 @@ declare class Niivue {
2281
2502
  * @example
2282
2503
  * niivue = new Niivue()
2283
2504
  * niivue.addMesh(NVMesh.loadFromUrl({url:'../someURL.gii'}))
2284
- * @see {@link https://niivue.github.io/niivue/features/document.3d.html | live demo usage}
2505
+ * @see {@link https://niivue.com/demos/features/document.3d.html | live demo usage}
2285
2506
  */
2286
2507
  addMesh(mesh: NVMesh): void;
2287
2508
  /**
@@ -2292,30 +2513,57 @@ declare class Niivue {
2292
2513
  * niivue.getVolumeIndexByID(someVolume.id)
2293
2514
  */
2294
2515
  getVolumeIndexByID(id: string): number;
2516
+ /**
2517
+ * Saves the current drawing state as an RLE-compressed bitmap for undo history.
2518
+ * Uses a circular buffer to limit undo memory usage.
2519
+ * @internal
2520
+ */
2295
2521
  drawAddUndoBitmap(): void;
2522
+ /**
2523
+ * Clears all stored drawing undo bitmaps and resets the undo index.
2524
+ * @internal
2525
+ */
2296
2526
  drawClearAllUndoBitmaps(): void;
2297
2527
  /**
2298
2528
  * Restore drawing to previous state
2299
2529
  * @example niivue.drawUndo();
2300
- * @see {@link https://niivue.github.io/niivue/features/draw.ui.html | live demo usage}
2530
+ * @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
2301
2531
  */
2302
2532
  drawUndo(): void;
2533
+ /**
2534
+ * Loads a drawing overlay and aligns it with the current background image.
2535
+ * Converts the input image to match the background's orientation and stores it as a drawable bitmap.
2536
+ * Initializes the undo history and prepares the drawing texture.
2537
+ *
2538
+ * @param drawingBitmap - A `NVImage` object representing the drawing to load. Must match the dimensions of the background image.
2539
+ * @returns `true` if the drawing was successfully loaded and aligned; `false` if dimensions are incompatible.
2540
+ */
2303
2541
  loadDrawing(drawingBitmap: NVImage): boolean;
2542
+ /**
2543
+ * Binarize a volume by converting all non-zero voxels to 1
2544
+ * @param volume - the image volume to modify in place
2545
+ * @see {@link https://niivue.com/demos/features/clusterize.html | live demo usage}
2546
+ */
2304
2547
  binarize(volume: NVImage): void;
2305
2548
  /**
2306
2549
  * Open drawing
2307
2550
  * @param fnm - filename of NIfTI format drawing
2308
2551
  * @param isBinarize - if true will force drawing voxels to be either 0 or 1.
2309
2552
  * @example niivue.loadDrawingFromUrl("../images/lesion.nii.gz");
2310
- * @see {@link https://niivue.github.io/niivue/features/draw.ui.html | live demo usage}
2553
+ * @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
2311
2554
  */
2312
2555
  loadDrawingFromUrl(fnm: string, isBinarize?: boolean): Promise<boolean>;
2556
+ /**
2557
+ * Computes one or more Otsu threshold levels for the primary volume.
2558
+ * Returns raw intensity values corresponding to bin-based thresholds.
2559
+ * @internal
2560
+ */
2313
2561
  findOtsu(mlevel?: number): number[];
2314
2562
  /**
2315
2563
  * remove dark voxels in air
2316
2564
  * @param levels - (2-4) segment brain into this many types. For example drawOtsu(2) will create a binary drawing where bright voxels are colored and dark voxels are clear.
2317
2565
  * @example niivue.drawOtsu(3);
2318
- * @see {@link https://niivue.github.io/niivue/features/draw.ui.html | live demo usage}
2566
+ * @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
2319
2567
  */
2320
2568
  drawOtsu(levels?: number): void;
2321
2569
  /**
@@ -2323,7 +2571,7 @@ declare class Niivue {
2323
2571
  * @param level - (1-5) larger values for more preserved voxels
2324
2572
  * @param volIndex - volume to dehaze
2325
2573
  * @example niivue.removeHaze(3, 0);
2326
- * @see {@link https://niivue.github.io/niivue/features/draw.ui.html | live demo usage}
2574
+ * @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
2327
2575
  */
2328
2576
  removeHaze(level?: number, volIndex?: number): void;
2329
2577
  /**
@@ -2338,9 +2586,15 @@ declare class Niivue {
2338
2586
  * @example
2339
2587
  * niivue.saveImage({ filename: "myimage.nii.gz", isSaveDrawing: true });
2340
2588
  * niivue.saveImage({ filename: "myimage.nii.gz", isSaveDrawing: true });
2341
- * @see {@link https://niivue.github.io/niivue/features/draw.ui.html | live demo usage}
2589
+ * @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
2342
2590
  */
2343
2591
  saveImage(options?: SaveImageOptions): Promise<boolean | Uint8Array>;
2592
+ /**
2593
+ * Returns the index of a mesh given its ID or index.
2594
+ *
2595
+ * @param id - The mesh ID as a string, or an index number.
2596
+ * @returns The mesh index, or -1 if not found or out of range.
2597
+ */
2344
2598
  getMeshIndexByID(id: string | number): number;
2345
2599
  /**
2346
2600
  * change property of mesh, tractogram or connectome
@@ -2348,7 +2602,7 @@ declare class Niivue {
2348
2602
  * @param key - attribute to change
2349
2603
  * @param val - for attribute
2350
2604
  * @example niivue.setMeshProperty(niivue.meshes[0].id, 'fiberLength', 42)
2351
- * @see {@link https://niivue.github.io/niivue/features/meshes.html | live demo usage}
2605
+ * @see {@link https://niivue.com/demos/features/meshes.html | live demo usage}
2352
2606
  */
2353
2607
  setMeshProperty(id: number, key: keyof NVMesh, val: number | string | boolean | Uint8Array | number[] | ColorMap | LegacyConnectome | Float32Array): void;
2354
2608
  /**
@@ -2359,7 +2613,7 @@ declare class Niivue {
2359
2613
  * @param Zmm - location in foot/head dimension
2360
2614
  * @returns the an array where ret[0] is the mesh index and ret[1] is distance from vertex to coordinates
2361
2615
  * @example niivue.indexNearestXYZmm(niivue.meshes[0].id, -22, 42, 13)
2362
- * @see {@link https://niivue.github.io/niivue/features/clipplanes.html | live demo usage}
2616
+ * @see {@link https://niivue.com/demos/features/clipplanes.html | live demo usage}
2363
2617
  */
2364
2618
  indexNearestXYZmm(mesh: number, Xmm: number, Ymm: number, Zmm: number): number[];
2365
2619
  /**
@@ -2368,14 +2622,14 @@ declare class Niivue {
2368
2622
  * @param order - decimation order 0..6
2369
2623
  * @example niivue.decimateHierarchicalMesh(niivue.meshes[0].id, 4)
2370
2624
  * @returns boolean false if mesh is not hierarchical or of lower order
2371
- * @see {@link https://niivue.github.io/niivue/features/meshes.html | live demo usage}
2625
+ * @see {@link https://niivue.com/demos/features/meshes.html | live demo usage}
2372
2626
  */
2373
2627
  decimateHierarchicalMesh(mesh: number, order?: number): boolean;
2374
2628
  /**
2375
2629
  * reverse triangle winding of mesh (swap front and back faces)
2376
2630
  * @param mesh - identity of mesh to change
2377
2631
  * @example niivue.reverseFaces(niivue.meshes[0].id)
2378
- * @see {@link https://niivue.github.io/niivue/features/meshes.html | live demo usage}
2632
+ * @see {@link https://niivue.com/demos/features/meshes.html | live demo usage}
2379
2633
  */
2380
2634
  reverseFaces(mesh: number): void;
2381
2635
  /**
@@ -2385,7 +2639,7 @@ declare class Niivue {
2385
2639
  * @param key - attribute to change
2386
2640
  * @param val - value for attribute
2387
2641
  * @example niivue.setMeshLayerProperty(niivue.meshes[0].id, 0, 'frame4D', 22)
2388
- * @see {@link https://niivue.github.io/niivue/features/mesh.4D.html | live demo usage}
2642
+ * @see {@link https://niivue.com/demos/features/mesh.4D.html | live demo usage}
2389
2643
  */
2390
2644
  setMeshLayerProperty(mesh: number, layer: number, key: keyof NVMeshLayer, val: number): Promise<void>;
2391
2645
  /**
@@ -2397,7 +2651,7 @@ declare class Niivue {
2397
2651
  /**
2398
2652
  * set rotation of 3D render view
2399
2653
  * @example niivue.setRenderAzimuthElevation(45, 15)
2400
- * @see {@link https://niivue.github.io/niivue/features/mask.html | live demo usage}
2654
+ * @see {@link https://niivue.com/demos/features/mask.html | live demo usage}
2401
2655
  */
2402
2656
  setRenderAzimuthElevation(a: number, e: number): void;
2403
2657
  /**
@@ -2418,6 +2672,15 @@ declare class Niivue {
2418
2672
  * niivue.setVolume(someVolume, 1) // move it to the second position in the array of loaded volumes (0 is the first position)
2419
2673
  */
2420
2674
  setVolume(volume: NVImage, toIndex?: number): void;
2675
+ /**
2676
+ * Reorders a mesh within the internal mesh list.
2677
+ *
2678
+ * @param mesh - The `NVMesh` instance to reposition.
2679
+ * @param toIndex - Target index to move the mesh to.
2680
+ * - If `0`, moves mesh to the front.
2681
+ * - If `< 0`, removes the mesh.
2682
+ * - If within bounds, inserts mesh at the specified index.
2683
+ */
2421
2684
  setMesh(mesh: NVMesh, toIndex?: number): void;
2422
2685
  /**
2423
2686
  * Remove a volume
@@ -2425,12 +2688,14 @@ declare class Niivue {
2425
2688
  * @example
2426
2689
  * niivue = new Niivue()
2427
2690
  * niivue.removeVolume(this.volumes[3])
2428
- * @see {@link https://niivue.github.io/niivue/features/document.3d.html | live demo usage}
2691
+ * @see {@link https://niivue.com/demos/features/document.3d.html | live demo usage}
2429
2692
  */
2430
2693
  removeVolume(volume: NVImage): void;
2431
2694
  /**
2432
- * Remove a volume by index
2433
- * @param index - of volume to remove
2695
+ * Remove a volume from the scene by its index
2696
+ * @param index - index of the volume to remove
2697
+ * @throws if the index is out of bounds
2698
+ * @see {@link https://niivue.com/demos/features/clusterize.html | live demo usage}
2434
2699
  */
2435
2700
  removeVolumeByIndex(index: number): void;
2436
2701
  /**
@@ -2439,7 +2704,7 @@ declare class Niivue {
2439
2704
  * @example
2440
2705
  * niivue = new Niivue()
2441
2706
  * niivue.removeMesh(this.meshes[3])
2442
- * @see {@link https://niivue.github.io/niivue/features/connectome.html | live demo usage}
2707
+ * @see {@link https://niivue.com/demos/features/connectome.html | live demo usage}
2443
2708
  */
2444
2709
  removeMesh(mesh: NVMesh): void;
2445
2710
  /**
@@ -2481,7 +2746,16 @@ declare class Niivue {
2481
2746
  * niivue.moveVolumeToTop(this.volumes[0]) // move the background image to the top layer position
2482
2747
  */
2483
2748
  moveVolumeToTop(volume: NVImage): void;
2749
+ /**
2750
+ * Records the current mouse position in screen space (adjusted for device pixel ratio).
2751
+ * @internal
2752
+ */
2484
2753
  mouseDown(x: number, y: number): void;
2754
+ /**
2755
+ * Updates mouse position and modifies 3D render view if the pointer is in the render tile.
2756
+ *
2757
+ * @internal
2758
+ */
2485
2759
  mouseMove(x: number, y: number): void;
2486
2760
  /**
2487
2761
  * convert spherical AZIMUTH, ELEVATION to Cartesian
@@ -2502,7 +2776,7 @@ declare class Niivue {
2502
2776
  * @example
2503
2777
  * niivue = new Niivue()
2504
2778
  * niivue.setClipPlane([42, 42])
2505
- * @see {@link https://niivue.github.io/niivue/features/mask.html | live demo usage}
2779
+ * @see {@link https://niivue.com/demos/features/mask.html | live demo usage}
2506
2780
  */
2507
2781
  setClipPlane(depthAzimuthElevation: number[]): void;
2508
2782
  /**
@@ -2511,13 +2785,13 @@ declare class Niivue {
2511
2785
  * @example
2512
2786
  * niivue = new Niivue()
2513
2787
  * niivue.setCrosshairColor([0, 1, 0, 0.5]) // set crosshair to transparent green
2514
- * @see {@link https://niivue.github.io/niivue/features/colormaps.html | live demo usage}
2788
+ * @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
2515
2789
  */
2516
2790
  setCrosshairColor(color: number[]): void;
2517
2791
  /**
2518
2792
  * set thickness of crosshair
2519
2793
  * @example niivue.crosshairWidth(2)
2520
- * @see {@link https://niivue.github.io/niivue/features/colormaps.html | live demo usage}
2794
+ * @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
2521
2795
  */
2522
2796
  setCrosshairWidth(crosshairWidth: number): void;
2523
2797
  setDrawColormap(name: string): void;
@@ -2525,7 +2799,7 @@ declare class Niivue {
2525
2799
  * does dragging over a 2D slice create a drawing?
2526
2800
  * @param trueOrFalse - enabled (true) or not (false)
2527
2801
  * @example niivue.setDrawingEnabled(true)
2528
- * @see {@link https://niivue.github.io/niivue/features/draw.ui.html | live demo usage}
2802
+ * @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
2529
2803
  */
2530
2804
  setDrawingEnabled(trueOrFalse: boolean): void;
2531
2805
  /**
@@ -2533,14 +2807,14 @@ declare class Niivue {
2533
2807
  * @param penValue - sets the color of the pen
2534
2808
  * @param isFilledPen - determines if dragging creates flood-filled shape
2535
2809
  * @example niivue.setPenValue(1, true)
2536
- * @see {@link https://niivue.github.io/niivue/features/draw.ui.html | live demo usage}
2810
+ * @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
2537
2811
  */
2538
2812
  setPenValue(penValue: number, isFilledPen?: boolean): void;
2539
2813
  /**
2540
2814
  * control whether drawing is transparent (0), opaque (1) or translucent (between 0 and 1).
2541
2815
  * @param opacity - translucency of drawing
2542
2816
  * @example niivue.setDrawOpacity(0.7)
2543
- * @see {@link https://niivue.github.io/niivue/features/draw.ui.html | live demo usage}
2817
+ * @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
2544
2818
  */
2545
2819
  setDrawOpacity(opacity: number): void;
2546
2820
  /**
@@ -2549,9 +2823,13 @@ declare class Niivue {
2549
2823
  * @example
2550
2824
  * niivue = new Niivue()
2551
2825
  * niivue.setSelectionBoxColor([0, 1, 0, 0.5]) // set to transparent green
2552
- * @see {@link https://niivue.github.io/niivue/features/colormaps.html | live demo usage}
2826
+ * @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
2553
2827
  */
2554
2828
  setSelectionBoxColor(color: number[]): void;
2829
+ /**
2830
+ * Handles mouse wheel or trackpad scroll to change slices, zoom, or frame depending on context.
2831
+ * @internal
2832
+ */
2555
2833
  sliceScroll2D(posChange: number, x: number, y: number, isDelta?: boolean): void;
2556
2834
  /**
2557
2835
  * set the slice type. This changes the view mode
@@ -2559,7 +2837,7 @@ declare class Niivue {
2559
2837
  * @example
2560
2838
  * niivue = new Niivue()
2561
2839
  * niivue.setSliceType(Niivue.sliceTypeMultiplanar)
2562
- * @see {@link https://niivue.github.io/niivue/features/basic.multiplanar.html | live demo usage}
2840
+ * @see {@link https://niivue.com/demos/features/basic.multiplanar.html | live demo usage}
2563
2841
  */
2564
2842
  setSliceType(st: SLICE_TYPE): this;
2565
2843
  /**
@@ -2569,7 +2847,7 @@ declare class Niivue {
2569
2847
  * @example
2570
2848
  * niivue = new Niivue()
2571
2849
  * niivue.setOpacity(0, 0.5) // make the first volume transparent
2572
- * @see {@link https://niivue.github.io/niivue/features/atlas.html | live demo usage}
2850
+ * @see {@link https://niivue.com/demos/features/atlas.html | live demo usage}
2573
2851
  */
2574
2852
  setOpacity(volIdx: number, newOpacity: number): void;
2575
2853
  /**
@@ -2577,7 +2855,7 @@ declare class Niivue {
2577
2855
  * @param scale - the new scale value
2578
2856
  * @example
2579
2857
  * niivue.setScale(2) // zoom some
2580
- * @see {@link https://niivue.github.io/niivue/features/shiny.volumes.html | live demo usage}
2858
+ * @see {@link https://niivue.com/demos/features/shiny.volumes.html | live demo usage}
2581
2859
  */
2582
2860
  setScale(scale: number): void;
2583
2861
  /**
@@ -2585,7 +2863,7 @@ declare class Niivue {
2585
2863
  * @param color - the new color. expects an array of RGBA values. values can range from 0 to 1
2586
2864
  * @example
2587
2865
  * niivue.setClipPlaneColor([1, 1, 1, 0.5]) // white, transparent
2588
- * @see {@link https://niivue.github.io/niivue/features/clipplanes.html | live demo usage}
2866
+ * @see {@link https://niivue.com/demos/features/clipplanes.html | live demo usage}
2589
2867
  */
2590
2868
  setClipPlaneColor(color: number[]): void;
2591
2869
  /**
@@ -2593,7 +2871,7 @@ declare class Niivue {
2593
2871
  * @param thick - thickness of slab. Value 0..1.73 (cube opposite corner length is sqrt(3)).
2594
2872
  * @example
2595
2873
  * niivue.setClipPlaneThick(0.3) // thin slab
2596
- * @see {@link https://niivue.github.io/niivue/features/clipplanes.html | live demo usage}
2874
+ * @see {@link https://niivue.com/demos/features/clipplanes.html | live demo usage}
2597
2875
  */
2598
2876
  setClipPlaneThick(thick: number): void;
2599
2877
  /**
@@ -2602,7 +2880,7 @@ declare class Niivue {
2602
2880
  * @param high - 3-component array specifying the upper bound of the clipping region along the X, Y, and Z axes. Values range from 0 to 1.
2603
2881
  * @example
2604
2882
  * niivue.setClipPlaneColor([0.0, 0.0, 0.2], [1.0, 1.0, 0.7]) // remove inferior 20% and superior 30%
2605
- * @see {@link https://niivue.github.io/niivue/features/clipplanes.html | live demo usage}
2883
+ * @see {@link https://niivue.com/demos/features/clipplanes.html | live demo usage}
2606
2884
  */
2607
2885
  setClipVolume(low: number[], high: number[]): void;
2608
2886
  /**
@@ -2610,8 +2888,8 @@ declare class Niivue {
2610
2888
  * @param gradientAmount - amount of matcap (NaN or 0..1), default 0 (matte, surface normal does not influence color). NaN renders the gradients.
2611
2889
  * @example
2612
2890
  * niivue.setVolumeRenderIllumination(0.6);
2613
- * @see {@link https://niivue.github.io/niivue/features/shiny.volumes.html | live demo usage}
2614
- * @see {@link https://niivue.github.io/niivue/features/gradient.order.html | live demo usage}
2891
+ * @see {@link https://niivue.com/demos/features/shiny.volumes.html | live demo usage}
2892
+ * @see {@link https://niivue.com/demos/features/gradient.order.html | live demo usage}
2615
2893
  */
2616
2894
  setVolumeRenderIllumination(gradientAmount?: number): Promise<void>;
2617
2895
  /**
@@ -2620,10 +2898,19 @@ declare class Niivue {
2620
2898
  * @param renderSilhouette - make core transparent to enhance rims (0..1), default 0 (no-influence)
2621
2899
  * @example
2622
2900
  * niivue.setGradientOpacity(0.6);
2623
- * @see {@link https://niivue.github.io/niivue/features/gradient.opacity.html | live demo usage}
2901
+ * @see {@link https://niivue.com/demos/features/gradient.opacity.html | live demo usage}
2624
2902
  */
2625
2903
  setGradientOpacity(gradientOpacity?: number, renderSilhouette?: number): Promise<void>;
2904
+ /**
2905
+ * Generates a placeholder RGBA overlay of a green sphere for testing purposes only.
2906
+ * @internal
2907
+ * @remarks Marked for future removal — creates a test sphere, not intended for production use.
2908
+ */
2626
2909
  overlayRGBA(volume: NVImage): Uint8ClampedArray;
2910
+ /**
2911
+ * Convert voxel coordinates to millimeters using a transformation matrix.
2912
+ * @internal
2913
+ */
2627
2914
  vox2mm(XYZ: number[], mtx: mat4): vec3;
2628
2915
  /**
2629
2916
  * clone a volume and return a new volume
@@ -2635,14 +2922,13 @@ declare class Niivue {
2635
2922
  */
2636
2923
  cloneVolume(index: number): NVImage;
2637
2924
  /**
2638
- *
2639
- * @param url - URL of NVDocument
2925
+ * Loads an NVDocument from a URL and integrates it into the scene.
2640
2926
  */
2641
2927
  loadDocumentFromUrl(url: string): Promise<void>;
2642
2928
  /**
2643
2929
  * Loads an NVDocument
2644
2930
  * @returns Niivue instance
2645
- * @see {@link https://niivue.github.io/niivue/features/document.load.html | live demo usage}
2931
+ * @see {@link https://niivue.com/demos/features/document.load.html | live demo usage}
2646
2932
  */
2647
2933
  loadDocument(document: NVDocument): Promise<this>;
2648
2934
  /**
@@ -2653,6 +2939,7 @@ declare class Niivue {
2653
2939
  * const javascript = this.generateLoadDocumentJavaScript("gl1");
2654
2940
  * const html = `<html><body><canvas id="gl1"></canvas><script type="module" async>
2655
2941
  ${javascript}</script></body></html>`;
2942
+ * @see {@link https://niivue.com/demos/features/save.custom.html.html | live demo usage}
2656
2943
  */
2657
2944
  generateLoadDocumentJavaScript(canvasId: string, esm: string): Promise<string>;
2658
2945
  /**
@@ -2667,10 +2954,12 @@ declare class Niivue {
2667
2954
  */
2668
2955
  generateHTML(canvasId: string, esm: string): Promise<string>;
2669
2956
  /**
2670
- * save current scene as HTML
2671
- * @param fileName - the name of the HTML file
2672
- * @param canvasId - id of canvas NiiVue will be attached to
2673
- * @param esm - bundled version of NiiVue
2957
+ * Save the current scene as a standalone HTML file
2958
+ * @param fileName - name of the HTML file to save (default: "untitled.html")
2959
+ * @param canvasId - ID of the canvas element NiiVue will attach to
2960
+ * @param esm - bundled ES module source for NiiVue
2961
+ * @returns a Promise that resolves when the file is downloaded
2962
+ * @see {@link https://niivue.com/demos/features/save.html.html | live demo usage}
2674
2963
  */
2675
2964
  saveHTML(fileName: string, canvasId: string, esm: string): Promise<void>;
2676
2965
  /**
@@ -2689,11 +2978,19 @@ declare class Niivue {
2689
2978
  * @example
2690
2979
  * // smallest possible file – no preview, just metadata
2691
2980
  * await nv.saveDocument('scene.nvd', true, { embedImages:false, embedPreview:false });
2981
+ * @see {@link https://niivue.com/demos/features/document.3d.html | live demo usage}
2692
2982
  */
2693
2983
  saveDocument(fileName?: string, compress?: boolean, options?: {
2694
2984
  embedImages?: boolean;
2695
2985
  embedPreview?: boolean;
2696
2986
  }): Promise<void>;
2987
+ /**
2988
+ * Load an array of image or mesh URLs using appropriate handlers
2989
+ * @param images - array of image or mesh descriptors (with URL and optional name)
2990
+ * @returns a Promise resolving to the current NiiVue instance after loading completes
2991
+ * @remarks Automatically dispatches each item to either volume or mesh loader based on file extension or registered custom loader
2992
+ * @see {@link https://niivue.com/demos/features/timeseries2.html | live demo usage}
2993
+ */
2697
2994
  loadImages(images: Array<ImageFromUrlOptions | LoadFromUrlParams>): Promise<this>;
2698
2995
  loadDicoms(dicomList: ImageFromUrlOptions[]): Promise<this>;
2699
2996
  /**
@@ -2703,7 +3000,7 @@ declare class Niivue {
2703
3000
  * @example
2704
3001
  * niivue = new Niivue()
2705
3002
  * niivue.loadVolumes([{url: 'someImage.nii.gz}, {url: 'anotherImage.nii.gz'}])
2706
- * @see {@link https://niivue.github.io/niivue/features/mask.html | live demo usage}
3003
+ * @see {@link https://niivue.com/demos/features/mask.html | live demo usage}
2707
3004
  */
2708
3005
  loadVolumes(volumeList: ImageFromUrlOptions[]): Promise<this>;
2709
3006
  /**
@@ -2721,7 +3018,7 @@ declare class Niivue {
2721
3018
  * @example
2722
3019
  * niivue = new Niivue()
2723
3020
  * niivue.loadMeshes([{url: 'someMesh.gii'}])
2724
- * @see {@link https://niivue.github.io/niivue/features/meshes.html | live demo usage}
3021
+ * @see {@link https://niivue.com/demos/features/meshes.html | live demo usage}
2725
3022
  */
2726
3023
  loadMeshes(meshList: LoadFromUrlParams[]): Promise<this>;
2727
3024
  /**
@@ -2730,7 +3027,7 @@ declare class Niivue {
2730
3027
  * @param url - the URL to a JSON-formatted connectome definition
2731
3028
  * @param headers - optional HTTP headers to include with the request (e.g. for authorization)
2732
3029
  * @returns the `Niivue` instance (for method chaining)
2733
- * @see {@link https://niivue.github.io/niivue/features/connectome.html | live demo usage}
3030
+ * @see {@link https://niivue.com/demos/features/connectome.html | live demo usage}
2734
3031
  */
2735
3032
  loadConnectomeFromUrl(url: string, headers?: {}): Promise<this>;
2736
3033
  /**
@@ -2738,44 +3035,67 @@ declare class Niivue {
2738
3035
  * @param url - the URL of the JSON-formatted connectome file
2739
3036
  * @param headers - optional HTTP headers to include in the fetch request (e.g. for authorization)
2740
3037
  * @returns the `Niivue` instance (for method chaining)
2741
- * @see {@link https://niivue.github.io/niivue/features/connectome.html | live demo usage}
3038
+ * @see {@link https://niivue.com/demos/features/connectome.html | live demo usage}
2742
3039
  */
2743
3040
  loadFreeSurferConnectomeFromUrl(url: string, headers?: {}): Promise<this>;
2744
3041
  /**
2745
3042
  * load a connectome specified by json
2746
3043
  * @param json - freesurfer model
2747
3044
  * @returns Niivue instance
2748
- * @see {@link https://niivue.github.io/niivue/features/connectome.html | live demo usage}
3045
+ * @see {@link https://niivue.com/demos/features/connectome.html | live demo usage}
2749
3046
  */
2750
3047
  loadFreeSurferConnectome(json: FreeSurferConnectome): Promise<this>;
3048
+ /**
3049
+ * Handles addition of a connectome node by adding a corresponding label and redrawing.
3050
+ * @internal
3051
+ */
2751
3052
  handleNodeAdded(event: {
2752
3053
  detail: {
2753
3054
  node: NVConnectomeNode;
2754
3055
  };
2755
3056
  }): void;
3057
+ /**
3058
+ * Converts various connectome JSON formats to a standardized mesh representation.
3059
+ *
3060
+ * @param json - Connectome data in current or legacy format.
3061
+ * @returns The connectome as an `NVMesh`.
3062
+ * @internal
3063
+ */
2756
3064
  loadConnectomeAsMesh(json: Connectome | LegacyConnectome | FreeSurferConnectome): NVMesh;
2757
3065
  /**
2758
3066
  * load a connectome specified by json
2759
3067
  * @param json - connectome model
2760
3068
  * @returns Niivue instance
2761
- * @see {@link https://niivue.github.io/niivue/features/connectome.html | live demo usage}
3069
+ * @see {@link https://niivue.com/demos/features/connectome.html | live demo usage}
2762
3070
  */
2763
3071
  loadConnectome(json: Connectome | LegacyConnectome): this;
2764
3072
  /**
2765
3073
  * generate a blank canvas for the pen tool
2766
3074
  * @example niivue.createEmptyDrawing()
2767
- * @see {@link https://niivue.github.io/niivue/features/cactus.html | live demo usage}
3075
+ * @see {@link https://niivue.com/demos/features/cactus.html | live demo usage}
2768
3076
  */
2769
3077
  createEmptyDrawing(): void;
3078
+ /**
3079
+ * Creates or updates a 1-component 16-bit signed integer 3D texture on the GPU.
3080
+ * @internal
3081
+ */
2770
3082
  r16Tex(texID: WebGLTexture | null, activeID: number, dims: number[], img16: Int16Array): WebGLTexture;
2771
3083
  /**
2772
3084
  * dilate drawing so all voxels are colored.
2773
3085
  * works on drawing with multiple colors
2774
3086
  * @example niivue.drawGrowCut();
2775
- * @see {@link https://niivue.github.io/niivue/features/draw2.html | live demo usage}
3087
+ * @see {@link https://niivue.com/demos/features/draw2.html | live demo usage}
2776
3088
  */
2777
3089
  drawGrowCut(): void;
3090
+ /**
3091
+ * Sets the color value of a voxel and its neighbors in the drawing bitmap.
3092
+ * @internal
3093
+ */
2778
3094
  drawPt(x: number, y: number, z: number, penValue: number, drawBitmap?: Uint8Array | null): void;
3095
+ /**
3096
+ * Draws a 3D line between two voxels in the drawing bitmap using Bresenham's algorithm.
3097
+ * @internal
3098
+ */
2779
3099
  drawPenLine(ptA: number[], ptB: number[], penValue: number): void;
2780
3100
  /**
2781
3101
  * Performs a 1-voxel binary dilation on a connected cluster within the drawing mask using the drawFloodFillCore function.
@@ -2785,39 +3105,100 @@ declare class Niivue {
2785
3105
  */
2786
3106
  drawingBinaryDilationWithSeed(seedXYZ: number[], // seed voxel x,y,z
2787
3107
  neighbors?: 6 | 18 | 26): void;
3108
+ /**
3109
+ * Flood fill to cluster connected voxels based on neighbor connectivity (6, 18, or 26 neighbors).
3110
+ * Voxels with value 1 are included in the cluster and set to 2.
3111
+ * Uses a queue-based breadth-first search.
3112
+ *
3113
+ * @internal
3114
+ */
2788
3115
  drawFloodFillCore(img: Uint8Array, seedVx: number, neighbors?: number): void;
3116
+ /**
3117
+ * Performs a flood fill on the drawing bitmap starting from a seed voxel, recoloring all connected voxels
3118
+ * based on spatial connectivity, intensity constraints, and other parameters.
3119
+ * Supports 2D or 3D fills, cluster growing, distance constraints, and preview mode for clickToSegment.
3120
+ *
3121
+ * @internal
3122
+ */
2789
3123
  drawFloodFill(seedXYZ: number[], newColor?: number, growSelectedCluster?: number, forceMin?: number, forceMax?: number, neighbors?: number, maxDistanceMM?: number, is2D?: boolean, targetBitmap?: Uint8Array | null, isGrowClusterTool?: boolean): void;
3124
+ /**
3125
+ * Connects and fills the interior of drawn line segments in 2D slice space.
3126
+ * @internal
3127
+ */
2790
3128
  drawPenFilled(): void;
2791
3129
  /**
2792
3130
  * close drawing: make sure you have saved any changes before calling this!
2793
3131
  * @example niivue.closeDrawing();
2794
- * @see {@link https://niivue.github.io/niivue/features/draw.ui.html | live demo usage}
3132
+ * @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
2795
3133
  */
2796
3134
  closeDrawing(): void;
2797
3135
  /**
2798
3136
  * copy drawing bitmap from CPU to GPU storage and redraw the screen
2799
3137
  * @param isForceRedraw - refreshes scene immediately (default true)
2800
3138
  * @example niivue.refreshDrawing();
2801
- * @see {@link https://niivue.github.io/niivue/features/cactus.html | live demo usage}
3139
+ * @see {@link https://niivue.com/demos/features/cactus.html | live demo usage}
2802
3140
  */
2803
3141
  refreshDrawing(isForceRedraw?: boolean, useClickToSegmentBitmap?: boolean): void;
3142
+ /**
3143
+ * Creates a 2D 1-component uint8 texture on the GPU with given dimensions.
3144
+ * @internal
3145
+ */
2804
3146
  r8Tex2D(texID: WebGLTexture | null, activeID: number, dims: number[], isInit?: boolean): WebGLTexture | null;
3147
+ /**
3148
+ * Creates a 3D 1-component uint8 texture on the GPU with given dimensions.
3149
+ * @internal
3150
+ */
2805
3151
  r8Tex(texID: WebGLTexture | null, activeID: number, dims: number[], isInit?: boolean): WebGLTexture | null;
3152
+ /**
3153
+ * Creates a 2D 4-component (RGBA) uint8 texture on the GPU with optional vertical flip.
3154
+ * @internal
3155
+ */
2806
3156
  rgbaTex2D(texID: WebGLTexture | null, activeID: number, dims: number[], data?: Uint8Array | null, isFlipVertical?: boolean): WebGLTexture | null;
3157
+ /**
3158
+ * Creates a 3D 4-component (RGBA) uint8 texture on the GPU, optionally initializing with empty data.
3159
+ * @internal
3160
+ */
2807
3161
  rgbaTex(texID: WebGLTexture | null, activeID: number, dims: number[], isInit?: boolean): WebGLTexture | null;
3162
+ /**
3163
+ * Create or recreate a 3D RGBA16UI texture on the GPU with given dimensions.
3164
+ * Deletes existing texture if provided, then allocates storage and optionally initializes with zeros.
3165
+ * @internal
3166
+ */
2808
3167
  rgba16Tex(texID: WebGLTexture | null, activeID: number, dims: number[], isInit?: boolean): WebGLTexture | null;
3168
+ /**
3169
+ * Remove cross-origin attribute from image if its URL is not from the same origin as the current page.
3170
+ * @internal
3171
+ */
2809
3172
  requestCORSIfNotSameOrigin(img: HTMLImageElement, url: string): void;
3173
+ /**
3174
+ * Loads a PNG image from a URL and creates a 4-component (RGBA) uint8 WebGL texture.
3175
+ * Binds texture to a specific texture unit depending on textureNum and sets texture parameters.
3176
+ * Automatically handles CORS and draws scene if needed.
3177
+ * @internal
3178
+ */
2810
3179
  loadPngAsTexture(pngUrl: string, textureNum: number): Promise<WebGLTexture | null>;
3180
+ /**
3181
+ * Loads a font stored as a PNG bitmap into texture unit 3.
3182
+ * @internal
3183
+ */
2811
3184
  loadFontTexture(fontUrl: string): Promise<WebGLTexture | null>;
2812
- loadBmpTexture(bmpUrl: string): Promise<WebGLTexture | null>;
3185
+ /**
3186
+ * Loads a PNG bitmap into texture unit 4.
3187
+ * @internal
3188
+ */
3189
+ loadBmpTexture(bmpUrl: string): Promise<WebGLTexture | null>;
2813
3190
  /**
2814
3191
  * Load matcap for illumination model.
2815
3192
  * @param bmpUrl - name of matcap to load ("Shiny", "Cortex", "Cream")
2816
3193
  * @example
2817
3194
  * niivue.loadMatCapTexture("Cortex");
2818
- * @see {@link https://niivue.github.io/niivue/features/shiny.volumes.html | live demo usage}
3195
+ * @see {@link https://niivue.com/demos/features/shiny.volumes.html | live demo usage}
2819
3196
  */
2820
3197
  loadMatCapTexture(bmpUrl: string): Promise<WebGLTexture | null>;
3198
+ /**
3199
+ * Initializes font metrics from loaded font data.
3200
+ * @internal
3201
+ */
2821
3202
  initFontMets(): void;
2822
3203
  /**
2823
3204
  * Load typeface for colorbars, measurements and orientation text.
@@ -2825,8 +3206,8 @@ declare class Niivue {
2825
3206
  * @param metricsUrl - URL to the corresponding font metrics JSON (defines character bounds and spacing)
2826
3207
  * @returns a Promise that resolves when the font is loaded
2827
3208
  * @example
2828
- * niivue.loadMatCapTexture("Cortex");
2829
- * @see {@link https://niivue.github.io/niivue/features/selectfont.html | live demo usage}
3209
+ * niivue.loadFont("./Roboto.png","./Roboto.json")
3210
+ * @see {@link https://niivue.com/demos/features/selectfont.html | live demo usage}
2830
3211
  */
2831
3212
  loadFont(fontSheetUrl?: any, metricsUrl?: {
2832
3213
  atlas: {
@@ -2868,16 +3249,33 @@ declare class Niivue {
2868
3249
  })[];
2869
3250
  kerning: any[];
2870
3251
  }): Promise<void>;
3252
+ /**
3253
+ * Loads the default MatCap texture.
3254
+ * @internal
3255
+ */
2871
3256
  loadDefaultMatCap(): Promise<WebGLTexture | null>;
3257
+ /**
3258
+ * Loads the default font texture and initializes font metrics.
3259
+ * @internal
3260
+ */
2872
3261
  loadDefaultFont(): Promise<void>;
3262
+ /**
3263
+ * Initializes text rendering by setting up font shader, loading default font and matcap texture,
3264
+ * and drawing the loading text.
3265
+ * @internal
3266
+ */
2873
3267
  initText(): Promise<void>;
3268
+ /**
3269
+ * Maps a mesh shader name to its corresponding index number.
3270
+ * @internal
3271
+ */
2874
3272
  meshShaderNameToNumber(meshShaderName?: string): number | undefined;
2875
3273
  /**
2876
3274
  * select new shader for triangulated meshes and connectomes. Note that this function requires the mesh is fully loaded: you may want use `await` with loadMeshes (as seen in live demo).
2877
3275
  * @param id - id of mesh to change
2878
3276
  * @param meshShaderNameOrNumber - identify shader for usage
2879
3277
  * @example niivue.setMeshShader('toon');
2880
- * @see {@link https://niivue.github.io/niivue/features/meshes.html | live demo usage}
3278
+ * @see {@link https://niivue.com/demos/features/meshes.html | live demo usage}
2881
3279
  */
2882
3280
  setMeshShader(id: number, meshShaderNameOrNumber?: number): void;
2883
3281
  /**
@@ -2896,7 +3294,7 @@ declare class Niivue {
2896
3294
  * @param fragmentShaderText - the GLSL source code for the custom fragment shader
2897
3295
  * @param name - a descriptive label for the shader (used in menus or debugging)
2898
3296
  * @returns the index of the new shader (use with {@link setMeshShader})
2899
- * @see {@link https://niivue.github.io/niivue/features/mesh.atlas.html | live demo usage}
3297
+ * @see {@link https://niivue.com/demos/features/mesh.atlas.html | live demo usage}
2900
3298
  */
2901
3299
  setCustomMeshShader(fragmentShaderText?: string, name?: string): number;
2902
3300
  /**
@@ -2904,18 +3302,65 @@ declare class Niivue {
2904
3302
  * @param sort - sort output alphabetically
2905
3303
  * @returns list of available mesh shader names
2906
3304
  * @example niivue.meshShaderNames();
2907
- * @see {@link https://niivue.github.io/niivue/features/meshes.html | live demo usage}
3305
+ * @see {@link https://niivue.com/demos/features/meshes.html | live demo usage}
2908
3306
  */
2909
3307
  meshShaderNames(sort?: boolean): string[];
3308
+ /**
3309
+ * Initializes a rendering shader with texture units and uniforms.
3310
+ * @internal
3311
+ */
2910
3312
  initRenderShader(shader: Shader, gradientAmount?: number): void;
3313
+ /**
3314
+ * Initializes WebGL state, shaders, textures, buffers, and sets up the rendering pipeline.
3315
+ * Also loads default fonts, matcap textures, and thumbnail if specified.
3316
+ * @internal
3317
+ * @returns {Promise<this>} Resolves to this instance after initialization completes.
3318
+ */
2911
3319
  init(): Promise<this>;
3320
+ /**
3321
+ * Generates gradient texture from volume data using GPU shaders and framebuffers.
3322
+ * @internal
3323
+ */
2912
3324
  gradientGL(hdr: NiftiHeader): void;
3325
+ /**
3326
+ * Get the gradient texture produced by gradientGL as a TypedArray
3327
+ * @returns Float32Array containing the gradient texture data, or null if no gradient texture exists
3328
+ * @example
3329
+ * niivue = new Niivue()
3330
+ * niivue.loadVolumes([{url: './someImage.nii'}])
3331
+ * // ... after volume is loaded and gradient is computed
3332
+ * const gradientData = niivue.getGradientTextureData()
3333
+ * if (gradientData) {
3334
+ * console.log('Gradient texture dimensions:', gradientData.length)
3335
+ * }
3336
+ * @see {@link https://niivue.com/demos/features/gradient.custom.html | live demo usage}
3337
+ */
3338
+ getGradientTextureData(): Float32Array | null;
3339
+ /**
3340
+ * Set a custom gradient texture to use instead of the one produced by gradientGL
3341
+ * When a custom gradient texture is set, the useCustomGradientTexture flag is set to true
3342
+ * to prevent gradientGL from overwriting the custom texture during volume updates.
3343
+ * @param data - Float32Array or Uint8Array containing RGBA gradient data, or null to revert to auto-generated gradient
3344
+ * @param dims - Optional dimensions array [width, height, depth]. If not provided, uses current volume dimensions
3345
+ * @example
3346
+ * niivue = new Niivue()
3347
+ * niivue.loadVolumes([{url: './someImage.nii'}])
3348
+ * // Create custom gradient data
3349
+ * const customGradient = new Float32Array(256 * 256 * 256 * 4) // example dimensions
3350
+ * // ... fill customGradient with desired values
3351
+ * niivue.setCustomGradientTexture(customGradient, [256, 256, 256])
3352
+ *
3353
+ * // To revert to auto-generated gradient:
3354
+ * niivue.setCustomGradientTexture(null)
3355
+ * @see {@link https://niivue.com/demos/features/gradient.custom.html | live demo usage}
3356
+ */
3357
+ setCustomGradientTexture(data: Float32Array | Uint8Array | null, dims?: number[]): void;
2913
3358
  /**
2914
3359
  * update the webGL 2.0 scene after making changes to the array of volumes. It's always good to call this method after altering one or more volumes manually (outside of Niivue setter methods)
2915
3360
  * @example
2916
3361
  * niivue = new Niivue()
2917
3362
  * niivue.updateGLVolume()
2918
- * @see {@link https://niivue.github.io/niivue/features/colormaps.html | live demo usage}
3363
+ * @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
2919
3364
  */
2920
3365
  updateGLVolume(): void;
2921
3366
  /**
@@ -2937,7 +3382,7 @@ declare class Niivue {
2937
3382
  * startVox: [10, 20, 30], // ignored if roiIsMask is false
2938
3383
  * endVox: [40, 50, 60] // ignored if roiIsMask is false
2939
3384
  * });
2940
- * @see {@link https://niivue.github.io/niivue/features/draw2.html | live demo usage}
3385
+ * @see {@link https://niivue.com/demos/features/draw2.html | live demo usage}
2941
3386
  */
2942
3387
  getDescriptives(options: {
2943
3388
  layer?: number;
@@ -2947,6 +3392,10 @@ declare class Niivue {
2947
3392
  startVox?: number[];
2948
3393
  endVox?: number[];
2949
3394
  }): Descriptive;
3395
+ /**
3396
+ * Updates textures, shaders, and GPU state for a given overlay layer based on image properties and rendering options.
3397
+ * @internal
3398
+ */
2950
3399
  refreshLayers(overlayItem: NVImage, layer: number): void;
2951
3400
  /**
2952
3401
  * query all available color maps that can be applied to volumes
@@ -2954,14 +3403,14 @@ declare class Niivue {
2954
3403
  * @example
2955
3404
  * niivue = new Niivue()
2956
3405
  * colormaps = niivue.colormaps()
2957
- * @see {@link https://niivue.github.io/niivue/features/colormaps.html | live demo usage}
3406
+ * @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
2958
3407
  */
2959
3408
  colormaps(): string[];
2960
3409
  /**
2961
3410
  * create a new colormap
2962
3411
  * @param key - name of new colormap
2963
3412
  * @param cmap - colormap properties (Red, Green, Blue, Alpha and Indices)
2964
- * @see {@link https://niivue.github.io/niivue/features/colormaps.html | live demo usage}
3413
+ * @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
2965
3414
  */
2966
3415
  addColormap(key: string, cmap: ColorMap): void;
2967
3416
  /**
@@ -2970,23 +3419,97 @@ declare class Niivue {
2970
3419
  * @param colormap - the name of the colormap to use
2971
3420
  * @example
2972
3421
  * niivue.setColormap(niivue.volumes[0].id,, 'red')
2973
- * @see {@link https://niivue.github.io/niivue/features/colormaps.html | live demo usage}
3422
+ * @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
2974
3423
  */
2975
3424
  setColormap(id: string, colormap: string): void;
3425
+ /**
3426
+ * Computes the linear voxel index from 3D coordinates using image dimensions.
3427
+ * @internal
3428
+ */
2976
3429
  idx(A: number, B: number, C: number, DIM: Uint32Array): number;
3430
+ /**
3431
+ * Checks if voxels below the given voxel have labels matching its value, returning the first matching label or 0.
3432
+ * @internal
3433
+ */
2977
3434
  check_previous_slice(bw: Uint32Array, il: Uint32Array, r: number, c: number, sl: number, dim: Uint32Array, conn: number, tt: Uint32Array): number;
3435
+ /**
3436
+ * Performs provisional labeling of connected voxels in a volume using specified connectivity.
3437
+ * @internal
3438
+ */
2978
3439
  do_initial_labelling(bw: Uint32Array, dim: Uint32Array, conn: number): [number, Uint32Array, Uint32Array];
3440
+ /**
3441
+ * Merges multiple provisional labels into a unified class using a translation table.
3442
+ * @internal
3443
+ */
2979
3444
  fill_tratab(tt: Uint32Array, nabo: Uint32Array, nr_set: number): void;
3445
+ /**
3446
+ * Removes gaps in label indices to produce a dense labeling.
3447
+ * @internal
3448
+ */
2980
3449
  translate_labels(il: Uint32Array, dim: Uint32Array, tt: Uint32Array, ttn: number): [number, Uint32Array];
3450
+ /**
3451
+ * Retains only the largest cluster for each region in a labeled volume.
3452
+ * @internal
3453
+ */
2981
3454
  largest_original_cluster_labels(bw: Uint32Array, cl: number, ls: Uint32Array): [number, Uint32Array];
3455
+ /**
3456
+ * Computes connected components labeling on a 3D image.
3457
+ * @internal
3458
+ */
2982
3459
  bwlabel(img: Uint32Array, dim: Uint32Array, conn?: number, binarize?: boolean, onlyLargestClusterPerClass?: boolean): [number, Uint32Array];
3460
+ /**
3461
+ * Create a connected component label map from a volume
3462
+ * @param id - ID of the input volume
3463
+ * @param conn - connectivity for clustering (6 = faces, 18 = faces + edges, 26 = faces + edges + corners)
3464
+ * @param binarize - whether to binarize the volume before labeling
3465
+ * @param onlyLargestClusterPerClass - retain only the largest cluster for each label
3466
+ * @returns a new NVImage with labeled clusters, using random colormap
3467
+ * @see {@link https://niivue.com/demos/features/clusterize.html | live demo usage}
3468
+ */
2983
3469
  createConnectedLabelImage(id: string, conn?: number, binarize?: boolean, onlyLargestClusterPerClass?: boolean): Promise<NVImage>;
3470
+ /**
3471
+ * Scales and crops a Float32 image to Uint8 range.
3472
+ * @internal
3473
+ */
2984
3474
  scalecropUint8(img32: Float32Array, dst_min: number, dst_max: number, src_min: number, scale: number): Promise<Uint8Array>;
3475
+ /**
3476
+ * Scales and crops a Float32 image to a specified range.
3477
+ * @internal
3478
+ */
2985
3479
  scalecropFloat32(img32: Float32Array, dst_min: number, dst_max: number, src_min: number, scale: number): Promise<Float32Array>;
3480
+ /**
3481
+ * Computes offset and scale to robustly rescale image intensities to a target range.
3482
+ * @internal
3483
+ */
2986
3484
  getScale(volume: NVImage, dst_min?: number, dst_max?: number, f_low?: number, f_high?: number): [number, number];
3485
+ /**
3486
+ * Computes output affine, voxel-to-voxel transform, and its inverse for resampling.
3487
+ * @internal
3488
+ */
2987
3489
  conformVox2Vox(inDims: number[], inAffine: number[], outDim?: number, outMM?: number, toRAS?: boolean): [mat4, mat4, mat4];
3490
+ /**
3491
+ * Create a binary NIfTI file as a Uint8Array, including header and image data
3492
+ * @param dims - image dimensions [x, y, z]
3493
+ * @param pixDims - voxel dimensions in mm [x, y, z]
3494
+ * @param affine - 4×4 affine transformation matrix in row-major order
3495
+ * @param datatypeCode - NIfTI datatype code (e.g., DT_UINT8, DT_FLOAT32)
3496
+ * @param img - image data buffer (optional)
3497
+ * @returns a Uint8Array representing a complete NIfTI file
3498
+ * @see {@link https://niivue.com/demos/features/conform.html | live demo usage}
3499
+ */
2988
3500
  createNiftiArray(dims?: number[], pixDims?: number[], affine?: number[], datatypeCode?: NiiDataType, img?: Uint8Array): Promise<Uint8Array>;
2989
- niftiArray2NVImage(bytes?: Uint8Array): Promise<NVImage>;
3501
+ /**
3502
+ * Convert a binary NIfTI file (as a Uint8Array) to an NVImage object
3503
+ * @param bytes - binary contents of a NIfTI file
3504
+ * @returns a Promise resolving to an NVImage object
3505
+ * @see {@link https://niivue.com/demos/features/conform.html | live demo usage}
3506
+ */ niftiArray2NVImage(bytes?: Uint8Array): Promise<NVImage>;
3507
+ /**
3508
+ * Load a NIfTI image from a URL and convert it to an NVImage object
3509
+ * @param fnm - URL of the NIfTI file to load
3510
+ * @returns a Promise resolving to an NVImage (not yet added to GPU or scene)
3511
+ * @see {@link https://niivue.com/demos/features/conform.html | live demo usage}
3512
+ */
2990
3513
  loadFromUrl(fnm: string): Promise<NVImage>;
2991
3514
  /**
2992
3515
  * FreeSurfer-style conform reslices any image to a 256x256x256 volume with 1mm voxels
@@ -2995,15 +3518,20 @@ declare class Niivue {
2995
3518
  * @param isLinear - reslice with linear rather than nearest-neighbor interpolation (default true).
2996
3519
  * @param asFloat32 - use Float32 datatype rather than Uint8 (default false).
2997
3520
  * @param isRobustMinMax - clamp intensity with robust min max (~2%..98%) instead of FreeSurfer (0%..99.99%) (default false).
2998
- * @see {@link https://niivue.github.io/niivue/features/torso.html | live demo usage}
3521
+ * @see {@link https://niivue.com/demos/features/torso.html | live demo usage}
2999
3522
  */
3000
3523
  conform(volume: NVImage, toRAS?: boolean, isLinear?: boolean, asFloat32?: boolean, isRobustMinMax?: boolean): Promise<NVImage>;
3001
3524
  /**
3002
3525
  * darken crevices and brighten corners when 3D rendering drawings.
3003
3526
  * @param ao - amount of ambient occlusion (default 0.4)
3004
- * @see {@link https://niivue.github.io/niivue/features/torso.html | live demo usage}
3527
+ * @see {@link https://niivue.com/demos/features/torso.html | live demo usage}
3005
3528
  */
3006
3529
  setRenderDrawAmbientOcclusion(ao: number): void;
3530
+ /**
3531
+ * @deprecated Use {@link setColormap} instead. This alias is retained for compatibility with NiiVue < 0.35.
3532
+ * @param id - ID of the volume
3533
+ * @param colormap - name of the colormap to apply
3534
+ */
3007
3535
  setColorMap(id: string, colormap: string): void;
3008
3536
  /**
3009
3537
  * use given color map for negative voxels in image
@@ -3012,7 +3540,7 @@ declare class Niivue {
3012
3540
  * @example
3013
3541
  * niivue = new Niivue()
3014
3542
  * niivue.setColormapNegative(niivue.volumes[1].id,"winter");
3015
- * @see {@link https://niivue.github.io/niivue/features/mosaics2.html | live demo usage}
3543
+ * @see {@link https://niivue.com/demos/features/mosaics2.html | live demo usage}
3016
3544
  */
3017
3545
  setColormapNegative(id: string, colormapNegative: string): void;
3018
3546
  /**
@@ -3021,15 +3549,15 @@ declare class Niivue {
3021
3549
  * @param idModulation - the ID of the NVImage that controls bias (empty string to disable modulation)
3022
3550
  * @param modulateAlpha - does the modulation influence alpha transparency (values greater than 1).
3023
3551
  * @example niivue.setModulationImage(niivue.volumes[0].id, niivue.volumes[1].id);
3024
- * @see {@link https://niivue.github.io/niivue/features/modulate.html | live demo scalar usage}
3025
- * @see {@link https://niivue.github.io/niivue/features/modulateAfni.html | live demo usage}
3552
+ * @see {@link https://niivue.com/demos/features/modulate.html | live demo scalar usage}
3553
+ * @see {@link https://niivue.com/demos/features/modulateAfni.html | live demo usage}
3026
3554
  */
3027
3555
  setModulationImage(idTarget: string, idModulation: string, modulateAlpha?: number): void;
3028
3556
  /**
3029
3557
  * adjust screen gamma. Low values emphasize shadows but can appear flat, high gamma hides shadow details.
3030
3558
  * @param gamma - selects luminance, default is 1
3031
3559
  * @example niivue.setGamma(1.0);
3032
- * @see {@link https://niivue.github.io/niivue/features/colormaps.html | live demo usage}
3560
+ * @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
3033
3561
  */
3034
3562
  setGamma(gamma?: number): void;
3035
3563
  /** Load all volumes for image opened with `limitFrames4D`, the user can also click the `...` on a 4D timeline to load deferred volumes
@@ -3041,7 +3569,7 @@ declare class Niivue {
3041
3569
  * @param id - the ID of the 4D NVImage
3042
3570
  * @param frame4D - frame to display (indexed from zero)
3043
3571
  * @example nv1.setFrame4D(nv1.volumes[0].id, 42);
3044
- * @see {@link https://niivue.github.io/niivue/features/timeseries.html | live demo usage}
3572
+ * @see {@link https://niivue.com/demos/features/timeseries.html | live demo usage}
3045
3573
  */
3046
3574
  setFrame4D(id: string, frame4D: number): void;
3047
3575
  /**
@@ -3049,88 +3577,408 @@ declare class Niivue {
3049
3577
  * @param id - the ID of the 4D NVImage
3050
3578
  * @returns currently selected volume (indexed from 0)
3051
3579
  * @example nv1.getFrame4D(nv1.volumes[0].id);
3052
- * @see {@link https://niivue.github.io/niivue/features/timeseries.html | live demo usage}
3580
+ * @see {@link https://niivue.com/demos/features/timeseries.html | live demo usage}
3053
3581
  */
3054
3582
  getFrame4D(id: string): number;
3583
+ /**
3584
+ * Returns a colormap by its name key.
3585
+ * @internal
3586
+ */
3055
3587
  colormapFromKey(name: string): ColorMap;
3588
+ /**
3589
+ * Retrieve a colormap with optional inversion
3590
+ * @param lutName - name of the lookup table (LUT) colormap
3591
+ * @param isInvert - whether to invert the colormap
3592
+ * @returns the RGBA colormap as a Uint8ClampedArray
3593
+ * @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
3594
+ */
3056
3595
  colormap(lutName?: string, isInvert?: boolean): Uint8ClampedArray;
3596
+ /**
3597
+ * Creates or recreates a 2D RGBA colormap texture with specified rows and columns.
3598
+ * @internal
3599
+ */
3057
3600
  createColormapTexture(texture?: WebGLTexture | null, nRow?: number, nCol?: number): WebGLTexture | null;
3601
+ /**
3602
+ * Adds a colormap configuration to the internal list with given parameters.
3603
+ * @internal
3604
+ */
3058
3605
  addColormapList(nm?: string, mn?: number, mx?: number, alpha?: boolean, neg?: boolean, vis?: boolean, inv?: boolean): void;
3606
+ /**
3607
+ * Rebuild and upload all colormap textures for volumes and meshes
3608
+ * @returns the current NiiVue instance, or undefined if no colormaps are used
3609
+ * @see {@link https://niivue.com/demos/features/mesh.stats.html | live demo usage}
3610
+ */
3059
3611
  refreshColormaps(): this | undefined;
3612
+ /**
3613
+ * Calculates volume scaling factors and voxel dimensions for rendering.
3614
+ * @internal
3615
+ */
3060
3616
  sliceScale(forceVox?: boolean): SliceScale;
3617
+ /**
3618
+ * Returns the index of the tile containing the given (x, y) screen coordinates.
3619
+ * Returns -1 if the coordinates are outside all tiles.
3620
+ * @internal
3621
+ */
3061
3622
  tileIndex(x: number, y: number): number;
3623
+ /**
3624
+ * Returns the index of the render tile containing (x, y) screen coordinates, or -1 if none.
3625
+ * @internal
3626
+ */
3062
3627
  inRenderTile(x: number, y: number): number;
3628
+ /**
3629
+ * Adjusts clip plane depth if active, else zooms render size.
3630
+ * @internal
3631
+ */
3063
3632
  sliceScroll3D(posChange?: number): void;
3633
+ /**
3634
+ * Deletes loaded thumbnail texture and frees memory.
3635
+ * @internal
3636
+ */
3064
3637
  deleteThumbnail(): void;
3638
+ /**
3639
+ * Checks if (x,y) is within the visible graph plotting area.
3640
+ * @internal
3641
+ */
3065
3642
  inGraphTile(x: number, y: number): boolean;
3643
+ /**
3644
+ * Updates drawBitmap to match clickToSegmentGrowingBitmap if they differ in content and size.
3645
+ * @internal
3646
+ */
3066
3647
  updateBitmapFromClickToSegment(): void;
3648
+ /**
3649
+ * Calculates the sum of all voxel values in the given bitmap.
3650
+ * @internal
3651
+ */
3067
3652
  sumBitmap(img: Uint8Array): number;
3653
+ /**
3654
+ * Performs click-to-segment operation based on user click within a specified tile.
3655
+ * Validates input, computes voxel coordinates from screen position, and applies flood fill
3656
+ * with intensity-based thresholding and optional growing mask.
3657
+ * Updates drawing bitmaps and triggers redraw and descriptive stats calculation.
3658
+ * @internal
3659
+ */
3068
3660
  doClickToSegment(options: {
3069
3661
  x: number;
3070
3662
  y: number;
3071
3663
  tileIndex: number;
3072
3664
  }): void;
3665
+ /**
3666
+ * Handles mouse click on canvas by updating crosshair position, drawing, or segmenting based on current mode and location.
3667
+ * Supports thumbnail loading, graph interaction, 3D slice scrolling, and click-to-segment with flood fill.
3668
+ * @internal
3669
+ */
3073
3670
  mouseClick(x: number, y: number, posChange?: number, isDelta?: boolean): void;
3671
+ /**
3672
+ * Draws a 10cm ruler on a 2D slice tile based on screen FOV and slice dimensions.
3673
+ * @internal
3674
+ */
3074
3675
  drawRuler(): void;
3676
+ /**
3677
+ * Draws a 10cm ruler at specified coordinates with given color and width.
3678
+ * @internal
3679
+ */
3075
3680
  drawRuler10cm(startXYendXY: number[], rulerColor: number[], rulerWidth?: number): void;
3681
+ /**
3682
+ * Returns vec4 with XYZ millimeter coordinates and tile index for given screen XY.
3683
+ * @internal
3684
+ */
3076
3685
  screenXY2mm(x: number, y: number, forceSlice?: number): vec4;
3686
+ /**
3687
+ * Update scene pan position during drag based on start and end screen coordinates.
3688
+ * @internal
3689
+ */
3077
3690
  dragForPanZoom(startXYendXY: number[]): void;
3691
+ /**
3692
+ * Handle center-button drag as pan and zoom.
3693
+ * @internal
3694
+ */
3078
3695
  dragForCenterButton(startXYendXY: number[]): void;
3696
+ /**
3697
+ * Update 3D slicer zoom and pan based on drag movement.
3698
+ * @internal
3699
+ */
3079
3700
  dragForSlicer3D(startXYendXY: number[]): void;
3080
- drawMeasurementTool(startXYendXY: number[]): void;
3701
+ /**
3702
+ * Draw a measurement line with end caps and length text on a 2D tile.
3703
+ * @internal
3704
+ */
3705
+ drawMeasurementTool(startXYendXY: number[], isDrawText?: boolean): void;
3706
+ /**
3707
+ * Draw angle measurement tool with two lines and angle display.
3708
+ * @internal
3709
+ */
3710
+ drawAngleMeasurementTool(): void;
3711
+ /**
3712
+ * Calculate and draw angle text at the intersection of two lines.
3713
+ * @internal
3714
+ */
3715
+ drawAngleText(): void;
3716
+ /**
3717
+ * Calculate angle between two lines in degrees.
3718
+ * @internal
3719
+ */
3720
+ calculateAngleBetweenLines(line1: number[], line2: number[]): number;
3721
+ /**
3722
+ * Reset the angle measurement state.
3723
+ * @internal
3724
+ */
3725
+ resetAngleMeasurement(): void;
3726
+ /**
3727
+ * Set the drag mode for mouse interactions.
3728
+ * @param mode - The drag mode to set ('none', 'contrast', 'measurement', 'angle', 'pan', 'slicer3D', 'callbackOnly', 'roiSelection')
3729
+ */
3730
+ setDragMode(mode: string | DRAG_MODE): void;
3731
+ /**
3732
+ * Draw a rectangle or outline at given position with specified color or default crosshair color.
3733
+ * @internal
3734
+ */
3081
3735
  drawRect(leftTopWidthHeight: number[], lineColor?: number[]): void;
3736
+ /**
3737
+ * Draw a circle or outline at given position with specified color or default crosshair color.
3738
+ * @internal
3739
+ */
3082
3740
  drawCircle(leftTopWidthHeight: number[], circleColor?: Float32List, fillPercent?: number): void;
3741
+ /**
3742
+ * Draw selection box: circle if ROI selection mode, else rectangle.
3743
+ * @internal
3744
+ */
3083
3745
  drawSelectionBox(leftTopWidthHeight: number[]): void;
3746
+ /**
3747
+ * Get canvas height available for tiles (excludes colorbar).
3748
+ * @internal
3749
+ */
3084
3750
  effectiveCanvasHeight(): number;
3751
+ /**
3752
+ * Get canvas width available for tiles (excludes legend panel).
3753
+ * @internal
3754
+ */
3085
3755
  effectiveCanvasWidth(): number;
3756
+ /**
3757
+ * Get all 3D labels from document and connectome meshes.
3758
+ * @internal
3759
+ */
3086
3760
  getAllLabels(): NVLabel3D[];
3761
+ /**
3762
+ * Get all visible connectome and non-anchored mesh labels.
3763
+ * @internal
3764
+ */
3087
3765
  getConnectomeLabels(): NVLabel3D[];
3766
+ /**
3767
+ * Calculate bullet margin width based on widest bullet scale and tallest label height.
3768
+ * @internal
3769
+ */
3088
3770
  getBulletMarginWidth(): number;
3771
+ /**
3772
+ * Calculate width of legend panel based on labels and bullet margin.
3773
+ * Returns 0 if legend is hidden or too wide for canvas.
3774
+ * @internal
3775
+ */
3089
3776
  getLegendPanelWidth(): number;
3090
- getLegendPanelHeight(): number;
3777
+ /**
3778
+ * Calculate legend panel height based on labels and scale.
3779
+ * @internal
3780
+ */
3781
+ getLegendPanelHeight(panelScale?: number): number;
3782
+ /**
3783
+ * Calculate and reserve canvas area for colorbar panel.
3784
+ * @internal
3785
+ */
3091
3786
  reserveColorbarPanel(): number[];
3787
+ /**
3788
+ * Render a single colorbar with optional negative coloring and alpha threshold ticks.
3789
+ * @internal
3790
+ */
3092
3791
  drawColorbarCore(layer: number, leftTopWidthHeight: number[], isNegativeColor: boolean, min: number, max: number, isAlphaThreshold: boolean): void;
3792
+ /**
3793
+ * Draw all visible colorbars side by side in the reserved colorbar panel area.
3794
+ * @internal
3795
+ */
3093
3796
  drawColorbar(): void;
3797
+ /**
3798
+ * Calculate pixel width of text string based on glyph advances at given scale.
3799
+ * @internal
3800
+ */
3094
3801
  textWidth(scale: number, str: string): number;
3802
+ /**
3803
+ * Calculate pixel height of text based on tallest glyph at given scale.
3804
+ * @internal
3805
+ */
3095
3806
  textHeight(scale: number, str: string): number;
3807
+ /**
3808
+ * Render a single character glyph at specified position and scale; returns advance width.
3809
+ * @internal
3810
+ */
3096
3811
  drawChar(xy: number[], scale: number, char: number): number;
3812
+ /**
3813
+ * Render loading text centered on the canvas.
3814
+ * @internal
3815
+ */
3097
3816
  drawLoadingText(text: string): void;
3817
+ /**
3818
+ * Render a string of text at specified canvas coordinates with scaling and optional color.
3819
+ * @internal
3820
+ */
3098
3821
  drawText(xy: number[], str: string, scale?: number, color?: Float32List | null): void;
3822
+ /**
3823
+ * Draw text right-aligned to the given coordinates, vertically centered on y.
3824
+ * @internal
3825
+ */
3099
3826
  drawTextRight(xy: number[], str: string, scale?: number, color?: number[] | null): void;
3827
+ /**
3828
+ * Draw text left-aligned to the given coordinates, vertically centered on y.
3829
+ * @internal
3830
+ */
3100
3831
  drawTextLeft(xy: number[], str: string, scale?: number, color?: number[] | null): void;
3832
+ /**
3833
+ * Draw text right-aligned and below the given coordinates.
3834
+ * @internal
3835
+ */
3101
3836
  drawTextRightBelow(xy: number[], str: string, scale?: number, color?: number[] | null): void;
3837
+ /**
3838
+ * Draw text horizontally centered between start and end points with a semi-transparent background.
3839
+ * @internal
3840
+ */
3102
3841
  drawTextBetween(startXYendXY: number[], str: string, scale?: number, color?: number[] | null): void;
3842
+ /**
3843
+ * Draw text horizontally centered below a specified (x,y) position with canvas boundary clamping.
3844
+ * @internal
3845
+ */
3103
3846
  drawTextBelow(xy: number[], str: string, scale?: number, color?: number[] | null): void;
3847
+ /**
3848
+ * Update texture interpolation mode (nearest or linear) for background or overlay layer.
3849
+ * @internal
3850
+ */
3104
3851
  updateInterpolation(layer: number, isForceLinear?: boolean): void;
3852
+ /**
3853
+ * Enable or disable atlas outline overlay
3854
+ * @param isOutline - number 0 to 1 for outline opacity
3855
+ * @see {@link https://niivue.com/demos/features/atlas.sparse.html | live demo usage}
3856
+ */
3105
3857
  setAtlasOutline(isOutline: number): void;
3106
3858
  /**
3107
3859
  * select between nearest and linear interpolation for voxel based images
3108
3860
  * @param isNearest - whether nearest neighbor interpolation is used, else linear interpolation
3109
3861
  * @example niivue.setInterpolation(true);
3110
- * @see {@link https://niivue.github.io/niivue/features/draw2.html | live demo usage}
3862
+ * @see {@link https://niivue.com/demos/features/draw2.html | live demo usage}
3111
3863
  */
3112
3864
  setInterpolation(isNearest: boolean): void;
3865
+ /**
3866
+ * Computes 2D model-view-projection and related matrices for rendering a slice of a 3D volume.
3867
+ * Configures viewport and accounts for radiological orientation, depth clipping, and camera rotation.
3868
+ * @internal
3869
+ */
3113
3870
  calculateMvpMatrix2D(leftTopWidthHeight: number[], mn: vec3, mx: vec3, clipTolerance: number, clipDepth: number, azimuth: number, elevation: number, isRadiolgical: boolean): MvpMatrix2D;
3871
+ /**
3872
+ * Reorders the components of a 3D vector based on the slice orientation (axial, coronal, or sagittal).
3873
+ * @internal
3874
+ */
3114
3875
  swizzleVec3MM(v3: vec3, axCorSag: SLICE_TYPE): vec3;
3876
+ /**
3877
+ * Returns the swizzled field of view for the given slice orientation.
3878
+ * @internal
3879
+ */
3115
3880
  screenFieldOfViewVox(axCorSag?: number): vec3;
3881
+ /**
3882
+ * Returns the field of view in millimeters for the given slice orientation.
3883
+ * @internal
3884
+ */
3116
3885
  screenFieldOfViewMM(axCorSag?: number, forceSliceMM?: boolean): vec3;
3886
+ /**
3887
+ * Returns extended voxel-aligned field of view and bounds for the given slice orientation.
3888
+ * @internal
3889
+ */
3117
3890
  screenFieldOfViewExtendedVox(axCorSag?: number): MM;
3891
+ /**
3892
+ * Returns extended millimeter-aligned field of view and bounds for the given slice orientation.
3893
+ * @internal
3894
+ */
3118
3895
  screenFieldOfViewExtendedMM(axCorSag?: number): MM;
3896
+ /**
3897
+ * Draws anatomical orientation labels (e.g., A/P/L/R) for the given slice view.
3898
+ * @internal
3899
+ */
3119
3900
  drawSliceOrientationText(leftTopWidthHeight: number[], axCorSag: SLICE_TYPE, padLeftTop?: number[]): void;
3901
+ /**
3902
+ * Computes a plane in mm space for a given slice orientation and depth.
3903
+ * @internal
3904
+ */
3120
3905
  xyMM2xyzMM(axCorSag: SLICE_TYPE, sliceFrac: number): number[];
3906
+ /**
3907
+ * Draw a 2D slice tile with appropriate orientation, zoom, pan, and optional mesh overlay.
3908
+ * @internal
3909
+ */
3121
3910
  draw2DMain(leftTopWidthHeight: number[], axCorSag: SLICE_TYPE, customMM?: number): void;
3911
+ /**
3912
+ * Draw a 2D slice tile with optional custom size and orientation text.
3913
+ * @internal
3914
+ */
3122
3915
  draw2D(leftTopWidthHeight: number[], axCorSag: SLICE_TYPE, customMM?: number, imageWidthHeight?: number[]): void;
3916
+ /**
3917
+ * Computes 3D model-view-projection matrices based on view angles and canvas size.
3918
+ * @internal
3919
+ */
3123
3920
  calculateMvpMatrix(_unused: unknown, leftTopWidthHeight: number[], azimuth: number, elevation: number): mat4[];
3921
+ /**
3922
+ * Computes the model transformation matrix for the given azimuth and elevation.
3923
+ * Applies optional oblique RAS rotation if available.
3924
+ * @internal
3925
+ */
3124
3926
  calculateModelMatrix(azimuth: number, elevation: number): mat4;
3927
+ /**
3928
+ * Returns the normalized near-to-far ray direction for the given view angles.
3929
+ * Ensures components are nonzero to avoid divide-by-zero errors.
3930
+ * @internal
3931
+ */
3125
3932
  calculateRayDirection(azimuth: number, elevation: number): vec3;
3933
+ /**
3934
+ * Returns the scene's min, max, and range extents in mm or voxel space.
3935
+ * Includes both volume and mesh geometry.
3936
+ * @internal
3937
+ */
3126
3938
  sceneExtentsMinMax(isSliceMM?: boolean): vec3[];
3939
+ /**
3940
+ * Sets the 3D pivot point and scene scale based on volume and mesh extents.
3941
+ * @internal
3942
+ */
3127
3943
  setPivot3D(): void;
3944
+ /**
3945
+ * Returns the maximum number of 4D volumes across all loaded images.
3946
+ * @internal
3947
+ */
3128
3948
  getMaxVols(): number;
3949
+ /**
3950
+ * Returns true if any loaded 4D volume is missing frames.
3951
+ * @internal
3952
+ */
3129
3953
  detectPartialllyLoaded4D(): boolean;
3954
+ /**
3955
+ * Draws a graph of 4D volume intensity over time at the current crosshair position.
3956
+ * Skips if volume is 3D, region is too small, or graph opacity is zero.
3957
+ * @internal
3958
+ */
3130
3959
  drawGraph(): void;
3960
+ /**
3961
+ * Updates crosshair position using depth-based mouse picking from screen pixel color.
3962
+ * Only active when depth picking is enabled.
3963
+ * @internal
3964
+ */
3131
3965
  depthPicker(leftTopWidthHeight: number[], mvpMatrix: mat4): void;
3966
+ /**
3967
+ * Render a 3D volume visualization of the current NVImage using provided transformation matrices and angles.
3968
+ * @internal
3969
+ */
3132
3970
  drawImage3D(mvpMatrix: mat4, azimuth: number, elevation: number): void;
3971
+ /**
3972
+ * Draw a small orientation cube indicating L/R, A/P, I/S directions in the given tile area with specified azimuth and elevation.
3973
+ * @internal
3974
+ */
3133
3975
  drawOrientationCube(leftTopWidthHeight: number[], azimuth?: number, elevation?: number): void;
3976
+ /**
3977
+ * Internal utility to generate human-readable location strings for the onLocationChange callback
3978
+ * @param axCorSag - optional axis index for coordinate interpretation (NaN by default)
3979
+ * @remarks Computes string representation of current crosshair position in mm (and frame if 4D).
3980
+ * @see {@link https://niivue.com/demos/features/modulateAfni.html | live demo usage}
3981
+ */
3134
3982
  createOnLocationChange(axCorSag?: number): void;
3135
3983
  /**
3136
3984
  * Add a 3D Label
@@ -3140,20 +3988,68 @@ declare class Niivue {
3140
3988
  * @param anchor - optional label anchor position (e.g., top-left, center, etc.)
3141
3989
  * @param onClick - optional callback function to invoke when the label is clicked
3142
3990
  * @returns the created `NVLabel3D` instance
3143
- * @see {@link https://niivue.github.io/niivue/features/labels.html | live demo usage}
3991
+ * @see {@link https://niivue.com/demos/features/labels.html | live demo usage}
3144
3992
  */
3145
3993
  addLabel(text: string, style: NVLabel3DStyle, points?: number[] | number[][], anchor?: LabelAnchorPoint, onClick?: (label: NVLabel3D) => void): NVLabel3D;
3994
+ /**
3995
+ * Calculate the 2D screen coordinates of a 3D point using the provided MVP matrix and tile position/size.
3996
+ * @internal
3997
+ */
3146
3998
  calculateScreenPoint(point: [number, number, number], mvpMatrix: mat4, leftTopWidthHeight: number[]): vec4;
3999
+ /**
4000
+ * Return the label located at the given screen coordinates, or null if none found.
4001
+ * @internal
4002
+ */
3147
4003
  getLabelAtPoint(screenPoint: [number, number]): NVLabel3D | null;
4004
+ /**
4005
+ * Draw lines from a 2D label position to its associated 3D points; supports solid and dotted lines.
4006
+ * @internal
4007
+ */
3148
4008
  drawLabelLine(label: NVLabel3D, pos: vec2, mvpMatrix: mat4, leftTopWidthHeight: number[], secondPass?: boolean): void;
3149
- draw3DLabel(label: NVLabel3D, pos: vec2, mvpMatrix?: mat4, leftTopWidthHeight?: number[], bulletMargin?: number, legendWidth?: number, secondPass?: boolean): void;
4009
+ /**
4010
+ * Render a 3D label with optional leader lines, bullet markers, and text alignment within a legend.
4011
+ * @internal
4012
+ */
4013
+ draw3DLabel(label: NVLabel3D, pos: vec2, mvpMatrix?: mat4, leftTopWidthHeight?: number[], bulletMargin?: number, legendWidth?: number, secondPass?: boolean, scaling?: number): void;
4014
+ /**
4015
+ * Render all visible 3D labels in the legend panel, handling font scaling and layering.
4016
+ * @internal
4017
+ */
3150
4018
  draw3DLabels(mvpMatrix: mat4, leftTopWidthHeight: number[], secondPass?: boolean): void;
4019
+ /**
4020
+ * Draw all labels anchored to screen edges or corners with background rectangles.
4021
+ * @internal
4022
+ */
3151
4023
  drawAnchoredLabels(): void;
4024
+ /**
4025
+ * Render the 3D scene including volume, meshes, labels, crosshairs, and orientation cube.
4026
+ * @internal
4027
+ */
3152
4028
  draw3D(leftTopWidthHeight?: number[], mvpMatrix?: mat4 | null, modelMatrix?: mat4 | null, normalMatrix?: mat4 | null, azimuth?: number | null, elevation?: number): string | undefined;
4029
+ /**
4030
+ * Render all visible 3D meshes with proper blending, depth, and shader settings.
4031
+ * @internal
4032
+ */
3153
4033
  drawMesh3D(isDepthTest?: boolean, alpha?: number, m?: mat4, modelMtx?: mat4, normMtx?: mat4): void;
4034
+ /**
4035
+ * Render 3D crosshairs at the current crosshair position with optional depth testing and transparency.
4036
+ * @internal
4037
+ */
3154
4038
  drawCrosshairs3D(isDepthTest?: boolean, alpha?: number, mvpMtx?: mat4 | null, is2DView?: boolean, isSliceMM?: boolean): void;
4039
+ /**
4040
+ * Convert millimeter coordinates to fractional volume coordinates for the specified volume.
4041
+ * @internal
4042
+ */
3155
4043
  mm2frac(mm: vec3 | vec4, volIdx?: number, isForceSliceMM?: boolean): vec3;
4044
+ /**
4045
+ * Convert voxel coordinates to fractional volume coordinates for the specified volume.
4046
+ * @internal
4047
+ */
3156
4048
  vox2frac(vox: vec3, volIdx?: number): vec3;
4049
+ /**
4050
+ * Convert fractional volume coordinates to voxel coordinates for the specified volume.
4051
+ * @internal
4052
+ */
3157
4053
  frac2vox(frac: vec3, volIdx?: number): vec3;
3158
4054
  /**
3159
4055
  * move crosshair a fixed number of voxels (not mm)
@@ -3161,31 +4057,99 @@ declare class Niivue {
3161
4057
  * @param y - translate posterior (-) or +anterior (+)
3162
4058
  * @param z - translate inferior (-) or superior (+)
3163
4059
  * @example niivue.moveCrosshairInVox(1, 0, 0)
3164
- * @see {@link https://niivue.github.io/niivue/features/draw2.html | live demo usage}
4060
+ * @see {@link https://niivue.com/demos/features/draw2.html | live demo usage}
3165
4061
  */
3166
4062
  moveCrosshairInVox(x: number, y: number, z: number): void;
4063
+ /**
4064
+ * Convert fractional volume coordinates to millimeter space for the specified volume.
4065
+ * @internal
4066
+ */
3167
4067
  frac2mm(frac: vec3, volIdx?: number, isForceSliceMM?: boolean): vec4;
4068
+ /**
4069
+ * Convert screen pixel coordinates to texture fractional coordinates for the given slice index.
4070
+ * @internal
4071
+ */
3168
4072
  screenXY2TextureFrac(x: number, y: number, i: number, restrict0to1?: boolean): vec3;
4073
+ /**
4074
+ * Converts a canvas position to fractional texture coordinates.
4075
+ * @internal
4076
+ */
3169
4077
  canvasPos2frac(canvasPos: number[]): vec3;
4078
+ /**
4079
+ * Calculates scaled slice dimensions and position within the canvas.
4080
+ * n.b. beware of similarly named `sliceScale` method.
4081
+ * @internal
4082
+ */
3170
4083
  scaleSlice(w: number, h: number, padPixelsWH?: [number, number], canvasWH?: [number, number]): number[];
4084
+ /**
4085
+ * Renders a centered thumbnail image using the bitmap shader.
4086
+ * @internal
4087
+ */
3171
4088
  drawThumbnail(): void;
4089
+ /**
4090
+ * Draws a 2D line with specified thickness and color on the canvas.
4091
+ * If alpha < 0, uses the default crosshair color.
4092
+ * @internal
4093
+ */
3172
4094
  drawLine(startXYendXY: number[], thickness?: number, lineColor?: number[]): void;
4095
+ /**
4096
+ * Draws a 3D line from screen to world space with specified thickness and color.
4097
+ * If alpha < 0, uses the default crosshair color.
4098
+ * @internal
4099
+ */
3173
4100
  draw3DLine(startXY: vec2, endXYZ: vec3, thickness?: number, lineColor?: number[]): void;
4101
+ /**
4102
+ * Draws a dotted 2D line with specified thickness and color.
4103
+ * If alpha < 0, uses the default crosshair color with reduced opacity.
4104
+ * @internal
4105
+ */
3174
4106
  drawDottedLine(startXYendXY: number[], thickness?: number, lineColor?: number[]): void;
4107
+ /**
4108
+ * Draw a colored line on the graph using given coordinates, color, and thickness.
4109
+ * @internal
4110
+ */
3175
4111
  drawGraphLine(LTRB: number[], color?: number[], thickness?: number): void;
4112
+ /**
4113
+ * Draw crosshair lines in millimeters on a given 2D slice tile.
4114
+ * @internal
4115
+ */
3176
4116
  drawCrossLinesMM(sliceIndex: number, axCorSag: SLICE_TYPE, axiMM: number[], corMM: number[], sagMM: number[]): void;
4117
+ /**
4118
+ * Draw crosshair lines on 2D slice tile, delegating to mm-based drawing if appropriate.
4119
+ * @internal
4120
+ */
3177
4121
  drawCrossLines(sliceIndex: number, axCorSag: SLICE_TYPE, axiMM: number[], corMM: number[], sagMM: number[]): void;
3178
4122
  /**
3179
4123
  * display a lightbox or montage view
3180
4124
  * @param mosaicStr - specifies orientation (A,C,S) and location of slices.
3181
4125
  * @example niivue.setSliceMosaicString("A -10 0 20");
3182
- * @see {@link https://niivue.github.io/niivue/features/mosaics.html | live demo usage}
4126
+ * @see {@link https://niivue.com/demos/features/mosaics.html | live demo usage}
3183
4127
  */
3184
4128
  drawMosaic(mosaicStr: string): void;
4129
+ /**
4130
+ * Calculate width and height to fit a slice within a container, preserving aspect ratio based on slice type and volume scaling.
4131
+ * @internal
4132
+ */
3185
4133
  calculateWidthHeight(sliceType: number, volScale: number[], containerWidth: number, containerHeight: number): [number, number];
4134
+ /**
4135
+ * Core function to draw the entire scene including volumes, meshes, slices, overlays, colorbars, graphs, and handle user interaction like dragging.
4136
+ * @internal
4137
+ */
3186
4138
  drawSceneCore(): string | void;
4139
+ /**
4140
+ * Manage draw calls to prevent concurrency issues, calling drawSceneCore and handling refresh flags.
4141
+ * @internal
4142
+ */
3187
4143
  drawScene(): string | void;
4144
+ /**
4145
+ * Getter for WebGL2 rendering context; throws error if context is unavailable.
4146
+ * @internal
4147
+ */
3188
4148
  get gl(): WebGL2RenderingContext;
4149
+ /**
4150
+ * Setter for WebGL2 rendering context.
4151
+ * @internal
4152
+ */
3189
4153
  set gl(gl: WebGL2RenderingContext | null);
3190
4154
  }
3191
4155