copper3d 3.10.1 → 3.10.2

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.
@@ -106326,7 +106326,65 @@ void main() {
106326
106326
  * | 7 | Auxiliary annotation | Orange |
106327
106327
  * | 8 | Extended annotation | Purple |
106328
106328
  */
106329
- const MASK_CHANNEL_COLORS = {
106329
+ /**
106330
+ * The largest label a mask voxel can carry. `MaskVolume` stores one byte per voxel and the
106331
+ * value IS the label, so 0 is empty and 1-255 are annotation channels.
106332
+ */
106333
+ const MAX_ENGINE_CHANNEL = 255;
106334
+ /** Highest channel whose colour is delivered rather than generated. */
106335
+ const SEEDED_CHANNELS = 8;
106336
+ /**
106337
+ * Successive hues this far apart never revisit an earlier one, which is the whole reason to
106338
+ * use it: any prefix of the sequence is about as spread out as that many hues can be.
106339
+ */
106340
+ const GOLDEN_ANGLE_DEGREES = 137.508;
106341
+ /**
106342
+ * The colour for a channel past the delivered eight.
106343
+ *
106344
+ * Saturation and lightness are fixed so the only thing that varies is hue: these sit on
106345
+ * greyscale MRI, where a mask that changes brightness between channels reads as a difference
106346
+ * in the image rather than in the annotation.
106347
+ *
106348
+ * Distinct is not the same as distinguishable. Past roughly twenty, neighbouring hues stop
106349
+ * being tellable apart by eye on a greyscale background; that is a limit on how many findings
106350
+ * a product should offer at once, not on what this function will return.
106351
+ */
106352
+ function generatedChannelColor(channel) {
106353
+ const hue = ((channel - SEEDED_CHANNELS - 1) * GOLDEN_ANGLE_DEGREES) % 360;
106354
+ return hslToRgba(hue, 0.68, 0.55);
106355
+ }
106356
+ /** HSL (h in degrees, s and l in 0-1) to the 0-255 RGBA this module stores. */
106357
+ function hslToRgba(h, s, l) {
106358
+ const c = (1 - Math.abs(2 * l - 1)) * s;
106359
+ const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
106360
+ const m = l - c / 2;
106361
+ const [r, g, b] = h < 60 ? [c, x, 0] :
106362
+ h < 120 ? [x, c, 0] :
106363
+ h < 180 ? [0, c, x] :
106364
+ h < 240 ? [0, x, c] :
106365
+ h < 300 ? [x, 0, c] :
106366
+ [c, 0, x];
106367
+ const to255 = (v) => Math.round((v + m) * 255);
106368
+ return { r: to255(r), g: to255(g), b: to255(b), a: 255 };
106369
+ }
106370
+ /**
106371
+ * A delivered 0-8 table, continued to 255 with generated colours.
106372
+ *
106373
+ * The seeds are kept verbatim rather than regenerated: every delivered case's chips, 3D
106374
+ * overlay tints and printed report outlines are keyed on them, so a formula that happened to
106375
+ * produce different values would silently recolour work already read and signed off.
106376
+ *
106377
+ * Built eagerly rather than behind a Proxy. `applyLayerChannelColors` walks these with
106378
+ * `Object.entries`, which a Proxy's `get` trap would not serve.
106379
+ */
106380
+ function extendPalette(seed, from) {
106381
+ const table = Object.assign({}, seed);
106382
+ for (let channel = SEEDED_CHANNELS + 1; channel <= MAX_ENGINE_CHANNEL; channel++) {
106383
+ table[channel] = from(generatedChannelColor(channel));
106384
+ }
106385
+ return table;
106386
+ }
106387
+ const MASK_CHANNEL_COLORS_SEED = {
106330
106388
  0: { r: 0, g: 0, b: 0, a: 0 }, // Background (transparent)
106331
106389
  1: { r: 16, g: 185, b: 129, a: 255 }, // Emerald / Soft Green — Primary / Tumor
106332
106390
  2: { r: 244, g: 63, b: 94, a: 255 }, // Rose / Soft Red — Secondary / Edema
@@ -106340,7 +106398,7 @@ void main() {
106340
106398
  /**
106341
106399
  * CSS color strings for the default channel palette (for reference / UI).
106342
106400
  */
106343
- const MASK_CHANNEL_CSS_COLORS = {
106401
+ const MASK_CHANNEL_CSS_COLORS_SEED = {
106344
106402
  0: 'rgba(0,0,0,0)',
106345
106403
  1: 'rgba(16,185,129,1)', // Emerald
106346
106404
  2: 'rgba(244,63,94,1)', // Rose
@@ -106351,15 +106409,10 @@ void main() {
106351
106409
  7: 'rgba(249,115,22,1)', // Orange
106352
106410
  8: 'rgba(139,92,246,1)', // Violet
106353
106411
  };
106354
- /**
106355
- * Convenience alias for MASK_CHANNEL_CSS_COLORS.
106356
- * Used by Vue components via `Copper.CHANNEL_COLORS[channel]`.
106357
- */
106358
- const CHANNEL_COLORS = MASK_CHANNEL_CSS_COLORS;
106359
106412
  /**
106360
106413
  * Hex color strings for each channel (no alpha), used for fillColor/brushColor.
106361
106414
  */
106362
- const CHANNEL_HEX_COLORS = {
106415
+ const CHANNEL_HEX_COLORS_SEED = {
106363
106416
  0: '#000000',
106364
106417
  1: '#10b981', // Emerald
106365
106418
  2: '#f43f5e', // Rose
@@ -106378,7 +106431,7 @@ void main() {
106378
106431
  * Applied ONLY to the AI scratch layer (set per-volume in AiAssistTool.enter) —
106379
106432
  * the global palette above is untouched, so the clinician mask stays emerald.
106380
106433
  */
106381
- const AI_MASK_CHANNEL_COLORS = {
106434
+ const AI_MASK_CHANNEL_COLORS_SEED = {
106382
106435
  0: { r: 0, g: 0, b: 0, a: 0 },
106383
106436
  1: { r: 94, g: 200, b: 255, a: 255 }, // Cyan (#5ec8ff) — AI accent (was emerald)
106384
106437
  2: { r: 244, g: 63, b: 94, a: 255 }, // Rose
@@ -106389,7 +106442,7 @@ void main() {
106389
106442
  7: { r: 249, g: 115, b: 22, a: 255 }, // Orange
106390
106443
  8: { r: 139, g: 92, b: 246, a: 255 }, // Violet
106391
106444
  };
106392
- const AI_CHANNEL_HEX_COLORS = {
106445
+ const AI_CHANNEL_HEX_COLORS_SEED = {
106393
106446
  0: '#000000',
106394
106447
  1: '#5ec8ff', // Cyan — AI accent
106395
106448
  2: '#f43f5e', // Rose
@@ -106400,6 +106453,20 @@ void main() {
106400
106453
  7: '#f97316', // Orange
106401
106454
  8: '#8b5cf6', // Violet
106402
106455
  };
106456
+ // ── The four palettes, delivered through channel 8 and generated past it ──────
106457
+ const MASK_CHANNEL_COLORS = extendPalette(MASK_CHANNEL_COLORS_SEED, (c) => c);
106458
+ const MASK_CHANNEL_CSS_COLORS = extendPalette(MASK_CHANNEL_CSS_COLORS_SEED, rgbaToCss);
106459
+ const CHANNEL_HEX_COLORS = extendPalette(CHANNEL_HEX_COLORS_SEED, rgbaToHex);
106460
+ const AI_MASK_CHANNEL_COLORS = extendPalette(AI_MASK_CHANNEL_COLORS_SEED, (c) => c);
106461
+ const AI_CHANNEL_HEX_COLORS = extendPalette(AI_CHANNEL_HEX_COLORS_SEED, rgbaToHex);
106462
+ /**
106463
+ * Convenience alias for MASK_CHANNEL_CSS_COLORS.
106464
+ * Used by Vue components via `Copper.CHANNEL_COLORS[channel]`.
106465
+ *
106466
+ * Declared here, with the tables it aliases. It used to sit further up, which was fine while
106467
+ * those were object literals and is a temporal-dead-zone error now that they are built.
106468
+ */
106469
+ const CHANNEL_COLORS = MASK_CHANNEL_CSS_COLORS;
106403
106470
  // ── Color Conversion Utilities ──────────────────────────────────────────
106404
106471
  /**
106405
106472
  * Convert an RGBAColor to a hex string (no alpha), e.g. '#ff0000'.
@@ -106581,16 +106648,16 @@ void main() {
106581
106648
  * Update the color for a specific label/channel in the color map.
106582
106649
  *
106583
106650
  * For label-based volumes (1-channel), the channel parameter refers to
106584
- * the label value (0-8), not the storage channel index.
106651
+ * the label value, not the storage channel index.
106585
106652
  *
106586
- * @param channel Label/channel index to update (0-8).
106653
+ * @param channel Label/channel index to update (0-`MAX_ENGINE_CHANNEL`).
106587
106654
  * @param color New RGBA color.
106588
106655
  *
106589
- * @throws {RangeError} If channel is outside valid label range [0, 8].
106656
+ * @throws {RangeError} If channel is outside the storable label range.
106590
106657
  */
106591
106658
  setChannelColor(channel, color) {
106592
- if (channel < 0 || channel > 8) {
106593
- throw new RangeError(`Invalid channel/label: ${channel} (valid range: 0-8)`);
106659
+ if (channel < 0 || channel > MAX_ENGINE_CHANNEL) {
106660
+ throw new RangeError(`Invalid channel/label: ${channel} (valid range: 0-${MAX_ENGINE_CHANNEL})`);
106594
106661
  }
106595
106662
  this.colorMap[channel] = { r: color.r, g: color.g, b: color.b, a: color.a };
106596
106663
  }
@@ -106820,7 +106887,8 @@ void main() {
106820
106887
  * @param sliceIndex Index along the specified axis.
106821
106888
  * @param imageData Canvas ImageData (RGBA) to convert.
106822
106889
  * @param axis `'x'`, `'y'`, or `'z'`.
106823
- * @param activeChannel Fallback label for pixels whose RGB doesn't match any channel (1-8).
106890
+ * @param activeChannel Fallback label for pixels whose RGB matches no channel exactly,
106891
+ * and one of the candidates the nearest-colour search considers.
106824
106892
  * @param channelVisible Optional map of visible channels (true=visible, false=hidden).
106825
106893
  * If provided, data for hidden channels will be preserved
106826
106894
  * when the canvas pixel is transparent.
@@ -106867,6 +106935,29 @@ void main() {
106867
106935
  iStride = this.bytesPerSlice; // i → z
106868
106936
  break;
106869
106937
  }
106938
+ // Candidates for the nearest-colour fallback below: the labels already on this slice,
106939
+ // plus the one being committed. One cheap pass to collect them, in place of running the
106940
+ // fallback over the whole palette.
106941
+ //
106942
+ // Widening it to all 255 would not just be 255 distance computations per anti-aliased
106943
+ // edge pixel. It would be wrong: the more colours the guess can choose from, the more
106944
+ // readily a fringe resolves to a label that is nowhere on the slice, which puts voxels
106945
+ // into another finding's mask with nothing to show for it.
106946
+ const candidates = [activeChannel];
106947
+ {
106948
+ const seen = new Set([activeChannel]);
106949
+ for (let j = 0; j < expectedH; j++) {
106950
+ let idx = baseIndex + j * jStride;
106951
+ for (let i = 0; i < expectedW; i++) {
106952
+ const label = volData[idx];
106953
+ if (label !== 0 && !seen.has(label)) {
106954
+ seen.add(label);
106955
+ candidates.push(label);
106956
+ }
106957
+ idx += iStride;
106958
+ }
106959
+ }
106960
+ }
106870
106961
  let px = 0;
106871
106962
  for (let j = 0; j < expectedH; j++) {
106872
106963
  let idx = baseIndex + j * jStride;
@@ -106895,8 +106986,10 @@ void main() {
106895
106986
  if (matchedChannel === undefined) {
106896
106987
  let minDist = Infinity;
106897
106988
  let bestChannel = activeChannel;
106898
- // Find the nearest channel color (1-8) to handle Canvas anti-aliased edge pixels
106899
- for (let ch = 1; ch <= 8; ch++) {
106989
+ // Nearest among the labels that can legitimately be here (see `candidates`),
106990
+ // to handle Canvas anti-aliased edge pixels.
106991
+ for (let ci = 0; ci < candidates.length; ci++) {
106992
+ const ch = candidates[ci];
106900
106993
  const c = (_a = this.colorMap[ch]) !== null && _a !== void 0 ? _a : MASK_CHANNEL_COLORS[ch];
106901
106994
  if (!c)
106902
106995
  continue;
@@ -106920,19 +107013,25 @@ void main() {
106920
107013
  }
106921
107014
  /**
106922
107015
  * Build a Map from RGB packed integer to channel label for reverse lookup.
106923
- * Uses this instance's colorMap (channels 1-8, skips 0 = transparent).
107016
+ * Covers every label this instance has a colour for, skipping 0 (transparent).
106924
107017
  *
106925
107018
  * Instance method ensures custom per-layer colors are correctly reverse-mapped.
106926
107019
  */
106927
107020
  buildRgbToChannelMap() {
106928
- var _a;
106929
107021
  const map = new Map();
106930
- for (let ch = 1; ch <= 8; ch++) {
106931
- const color = (_a = this.colorMap[ch]) !== null && _a !== void 0 ? _a : MASK_CHANNEL_COLORS[ch];
106932
- if (color) {
106933
- const key = (color.r << 16) | (color.g << 8) | color.b;
106934
- map.set(key, ch);
106935
- }
107022
+ // Every label this volume has a colour for, not a fixed 1-8. A pixel painted in
107023
+ // channel 12's colour used to miss this table entirely and fall through to the
107024
+ // nearest-colour guess, which could only ever answer 1-8 -- so the channel could be
107025
+ // drawn and could never be read back. Size is not a cost here: it is built once per
107026
+ // readback and every lookup against it is O(1).
107027
+ for (const key of Object.keys(this.colorMap)) {
107028
+ const ch = Number(key);
107029
+ if (ch < 1)
107030
+ continue; // 0 is "empty", and it is transparent rather than a colour
107031
+ const color = this.colorMap[ch];
107032
+ if (!color)
107033
+ continue;
107034
+ map.set((color.r << 16) | (color.g << 8) | color.b, ch);
106936
107035
  }
106937
107036
  return map;
106938
107037
  }
@@ -106997,8 +107096,11 @@ void main() {
106997
107096
  pixels[px + 1] = 0;
106998
107097
  pixels[px + 2] = 0;
106999
107098
  pixels[px + 3] = 0;
107099
+ // `=== false`, not falsy: the map records what has been HIDDEN and never covers
107100
+ // every label. `setSliceLabelsFromImageData` already reads it this way; reading it
107101
+ // as falsy here made any label the map did not mention render as invisible.
107000
107102
  }
107001
- else if (channelVisible && !channelVisible[label]) {
107103
+ else if ((channelVisible === null || channelVisible === void 0 ? void 0 : channelVisible[label]) === false) {
107002
107104
  pixels[px] = 0;
107003
107105
  pixels[px + 1] = 0;
107004
107106
  pixels[px + 2] = 0;
@@ -107140,6 +107242,48 @@ void main() {
107140
107242
  this.data.fill(0);
107141
107243
  this.version++;
107142
107244
  }
107245
+ /**
107246
+ * Zero every voxel carrying one label, leaving every other label in place.
107247
+ *
107248
+ * The third member of the clear family: `clear()` takes the whole volume and
107249
+ * `clearSlice()` takes one slice, both regardless of label. Deleting a single
107250
+ * annotation needs neither — its mask is one label inside a volume it shares with
107251
+ * every other annotation on that layer, so anything coarser takes the neighbours
107252
+ * with it.
107253
+ *
107254
+ * Label-based volumes only, which is what `numChannels === 1` means here: the voxel
107255
+ * value IS the label. A multi-plane volume stores channels as separate planes and
107256
+ * would need a different sweep.
107257
+ *
107258
+ * The version is bumped only when a voxel actually changed. Every derived cache keyed
107259
+ * on it — the contour cache above all — is invalidated by a bump, so bumping for a
107260
+ * clear that found nothing would redraw the layer for no reason.
107261
+ *
107262
+ * @param channel Label to erase, 1-255. Zero is "empty", not a channel.
107263
+ * @throws {RangeError} If `channel` is outside [1, 255].
107264
+ *
107265
+ * @example
107266
+ * ```ts
107267
+ * vol.clearChannel(3); // finding 3's voxels go; 1, 2 and 4 stay
107268
+ * ```
107269
+ */
107270
+ clearChannel(channel) {
107271
+ // Upper bound is what a Uint8 label can hold. Task 5 of the channel-cap work
107272
+ // replaces both this and setChannelColor's guard with one MAX_ENGINE_CHANNEL.
107273
+ if (!Number.isInteger(channel) || channel < 1 || channel > 255) {
107274
+ throw new RangeError(`Invalid channel to clear: ${channel} (valid range: 1-255; 0 is empty)`);
107275
+ }
107276
+ const data = this.data;
107277
+ let changed = false;
107278
+ for (let i = 0; i < data.length; i++) {
107279
+ if (data[i] === channel) {
107280
+ data[i] = 0;
107281
+ changed = true;
107282
+ }
107283
+ }
107284
+ if (changed)
107285
+ this.version++;
107286
+ }
107143
107287
  /**
107144
107288
  * Check if the volume contains any non-zero voxel data.
107145
107289
  *
@@ -115631,6 +115775,67 @@ void main() {
115631
115775
  }
115632
115776
  }
115633
115777
  }
115778
+ /**
115779
+ * Erase one channel's mask on one layer, undoably.
115780
+ *
115781
+ * The missing third of the clear family that `executeAction` exposes:
115782
+ * `clearActiveSliceMask` takes one slice, `clearActiveLayerMask` takes a whole layer,
115783
+ * and neither can take a single label. Deleting one annotation needs exactly that —
115784
+ * its mask is one label inside a volume shared with every other annotation on the
115785
+ * layer.
115786
+ *
115787
+ * Not folded into `executeAction`: that signature is an action name plus an options
115788
+ * bag, and this needs two required arguments.
115789
+ *
115790
+ * Deltas go onto the engine's own undo stack, so a mistaken clear is recoverable for
115791
+ * as long as the case stays open. That is the whole reason this lives here rather
115792
+ * than in the app: writing zeros from outside and forcing a repaint by stepping the
115793
+ * slice would bypass the stack, and an accidental clear would be permanent.
115794
+ *
115795
+ * Only slices that actually carry the label are touched, so a small annotation in a
115796
+ * deep volume costs a scan and a handful of callbacks rather than one per slice.
115797
+ *
115798
+ * @param layerId Layer whose mask to edit.
115799
+ * @param channel Label to erase, 1-255.
115800
+ * @throws {Error} If `layerId` names no layer. Deliberately NOT routed through
115801
+ * `getVolumeForLayer`, which warns and falls back to the first layer — for a
115802
+ * destructive call that would quietly erase a different layer's annotation.
115803
+ * @throws {RangeError} If `channel` is outside [1, 255] (from `MaskVolume`).
115804
+ */
115805
+ clearChannel(layerId, channel) {
115806
+ const volume = this.state.protectedData.maskData.volumes[layerId];
115807
+ if (!volume) {
115808
+ const known = this.state.nrrd_states.image.layers.join(", ");
115809
+ throw new Error(`clearChannel: unknown layer "${layerId}" (known layers: ${known})`);
115810
+ }
115811
+ const { depth } = volume.getDimensions();
115812
+ // Snapshot before mutating: `oldSlice` is what undo restores.
115813
+ const deltas = [];
115814
+ for (let z = 0; z < depth; z++) {
115815
+ const slice = volume.getSliceUint8(z, "z").data;
115816
+ if (!slice.some((v) => v === channel))
115817
+ continue;
115818
+ deltas.push({
115819
+ layerId,
115820
+ axis: "z",
115821
+ sliceIndex: z,
115822
+ oldSlice: slice.slice(),
115823
+ newSlice: new Uint8Array(0), // filled below, once the clear has run
115824
+ });
115825
+ }
115826
+ if (deltas.length === 0)
115827
+ return; // nothing drawn on this channel
115828
+ volume.clearChannel(channel);
115829
+ for (const delta of deltas) {
115830
+ delta.newSlice = volume.getSliceUint8(delta.sliceIndex, "z").data.slice();
115831
+ }
115832
+ this.drawCore.undoManager.pushGroup(deltas);
115833
+ for (const delta of deltas) {
115834
+ const { data, width, height } = volume.getSliceUint8(delta.sliceIndex, "z");
115835
+ this.state.annotationCallbacks.onMaskChanged(data, layerId, channel, delta.sliceIndex, "z", width, height, false);
115836
+ }
115837
+ this.reloadMasksFromVolume();
115838
+ }
115634
115839
  // ═══════════════════════════════════════════════════════════════════════════
115635
115840
  // 4. Public API — Keyboard & History
115636
115841
  // ═══════════════════════════════════════════════════════════════════════════
@@ -117638,15 +117843,15 @@ void main() {
117638
117843
  }
117639
117844
 
117640
117845
  // import * as kiwrious from "copper3d_plugin_heart_k";
117641
- // "v3.10.1" is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
117846
+ // "v3.10.2" is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
117642
117847
  // When copper3d is consumed from local source (no rollup replace step), the identifier is undefined and
117643
117848
  // referencing it throws a ReferenceError — guard it so local loading still works.
117644
117849
  let _revision = "unknown";
117645
117850
  try {
117646
- _revision = "v3.10.1";
117851
+ _revision = "v3.10.2";
117647
117852
  }
117648
117853
  catch (_a) {
117649
- /* "v3.10.1" not injected (local source build) */
117854
+ /* "v3.10.2" not injected (local source build) */
117650
117855
  }
117651
117856
  const REVISION = _revision;
117652
117857
  // Expose on global so the version can be read in a production browser console via window.__COPPER3D_VERSION__
@@ -117667,6 +117872,7 @@ void main() {
117667
117872
  exports.DEFAULT_AXES = DEFAULT_AXES;
117668
117873
  exports.DEFAULT_TARGET_GREY = DEFAULT_TARGET_GREY;
117669
117874
  exports.GaussianSmoother = GaussianSmoother;
117875
+ exports.MAX_ENGINE_CHANNEL = MAX_ENGINE_CHANNEL;
117670
117876
  exports.MeshNodeTool = MeshNodeTool;
117671
117877
  exports.NrrdTools = NrrdTools;
117672
117878
  exports.REVISION = REVISION;
package/dist/index.d.ts CHANGED
@@ -58,9 +58,10 @@ import { GuiState } from "./Utils/segmentation/coreTools/GuiState";
58
58
  import type { ToolMode, IAnnotationCallbacks } from "./Utils/segmentation/core/types";
59
59
  import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
60
60
  import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
61
+ import { MAX_ENGINE_CHANNEL } from "./Utils/segmentation/core/index";
61
62
  import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from "./Utils/segmentation/tools/AiAssistTool";
62
63
  import "./css/style.css";
63
64
  export declare const REVISION: string;
64
- export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, registerNiftiMaskGrid, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, DEFAULT_AXES, ensureAxisExtracted, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
65
+ export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, registerNiftiMaskGrid, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, MAX_ENGINE_CHANNEL, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, DEFAULT_AXES, ensureAxisExtracted, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
65
66
  export type { positionType, screenPosType, optsType, NrrdHeaderLike, GltfLoadOpts, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, LayerId, ChannelValue, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, ExposureVolume, DisposableObject3D, DisposableMaterial, FadeTarget, FadeableMaterial, SceneBudget, DisposableScene, SceneDisposalHost, FitBounds, FitViewScene, AxisGatedControls, GestureAxes, PosableScene, BoundingBoxHost, VolumeBoundingBoxOpts, NrrdAxis, Pose, };
66
67
  export type { CameraViewPreset } from "./Controls/orbitFraming";
package/dist/index.js CHANGED
@@ -38,6 +38,7 @@ import { easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPos
38
38
  import { installFastSliceRepaint } from "./Loader/fastSliceRepaint";
39
39
  import { SurfaceAnnotator } from "./Utils/surfaceAnnotation";
40
40
  import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
41
+ import { MAX_ENGINE_CHANNEL } from "./Utils/segmentation/core/index";
41
42
  import "./css/style.css";
42
43
  // __REVISION__ is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
43
44
  // When copper3d is consumed from local source (no rollup replace step), the identifier is undefined and
@@ -57,5 +58,5 @@ if (typeof window !== "undefined") {
57
58
  if (typeof console !== "undefined") {
58
59
  console.log(`%cCopper3D Visualisation %c${REVISION}`, "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
59
60
  }
60
- export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, registerNiftiMaskGrid, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, DEFAULT_AXES, ensureAxisExtracted, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
61
+ export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, registerNiftiMaskGrid, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, MAX_ENGINE_CHANNEL, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, DEFAULT_AXES, ensureAxisExtracted, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
61
62
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,eAAe,EAGf,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAY,MAAM,2BAA2B,CAAC;AACnE,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAC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BAAoB,EACpB,YAAY,EACZ,QAAQ,EACR,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,OAAO,EACP,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,eAAe,EACf,uBAAuB,GACxB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,eAAe,EAGf,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAY,MAAM,2BAA2B,CAAC;AACnE,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,sBA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,CAC/C,CAAC;AACJ,CAAC;AAED,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,qBAAqB,EACrB,OAAO,EACP,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,QAAQ,EACR,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,OAAO,EACP,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,eAAe,EACf,uBAAuB,GACxB,CAAC"}
@@ -98,6 +98,34 @@ export declare class NrrdTools {
98
98
  executeAction(action: "undo" | "redo" | "clearActiveSliceMask" | "clearActiveLayerMask" | "resetZoom" | "downloadCurrentMask" | "gaussianSmooth", opts?: {
99
99
  sigma?: number;
100
100
  }): void;
101
+ /**
102
+ * Erase one channel's mask on one layer, undoably.
103
+ *
104
+ * The missing third of the clear family that `executeAction` exposes:
105
+ * `clearActiveSliceMask` takes one slice, `clearActiveLayerMask` takes a whole layer,
106
+ * and neither can take a single label. Deleting one annotation needs exactly that —
107
+ * its mask is one label inside a volume shared with every other annotation on the
108
+ * layer.
109
+ *
110
+ * Not folded into `executeAction`: that signature is an action name plus an options
111
+ * bag, and this needs two required arguments.
112
+ *
113
+ * Deltas go onto the engine's own undo stack, so a mistaken clear is recoverable for
114
+ * as long as the case stays open. That is the whole reason this lives here rather
115
+ * than in the app: writing zeros from outside and forcing a repaint by stepping the
116
+ * slice would bypass the stack, and an accidental clear would be permanent.
117
+ *
118
+ * Only slices that actually carry the label are touched, so a small annotation in a
119
+ * deep volume costs a scan and a handful of callbacks rather than one per slice.
120
+ *
121
+ * @param layerId Layer whose mask to edit.
122
+ * @param channel Label to erase, 1-255.
123
+ * @throws {Error} If `layerId` names no layer. Deliberately NOT routed through
124
+ * `getVolumeForLayer`, which warns and falls back to the first layer — for a
125
+ * destructive call that would quietly erase a different layer's annotation.
126
+ * @throws {RangeError} If `channel` is outside [1, 255] (from `MaskVolume`).
127
+ */
128
+ clearChannel(layerId: string, channel: number): void;
101
129
  undo(): void;
102
130
  redo(): void;
103
131
  enterKeyboardConfig(): void;
@@ -127,12 +127,12 @@ export declare class MaskVolume {
127
127
  * Update the color for a specific label/channel in the color map.
128
128
  *
129
129
  * For label-based volumes (1-channel), the channel parameter refers to
130
- * the label value (0-8), not the storage channel index.
130
+ * the label value, not the storage channel index.
131
131
  *
132
- * @param channel Label/channel index to update (0-8).
132
+ * @param channel Label/channel index to update (0-`MAX_ENGINE_CHANNEL`).
133
133
  * @param color New RGBA color.
134
134
  *
135
- * @throws {RangeError} If channel is outside valid label range [0, 8].
135
+ * @throws {RangeError} If channel is outside the storable label range.
136
136
  */
137
137
  setChannelColor(channel: number, color: RGBAColor): void;
138
138
  /**
@@ -228,7 +228,8 @@ export declare class MaskVolume {
228
228
  * @param sliceIndex Index along the specified axis.
229
229
  * @param imageData Canvas ImageData (RGBA) to convert.
230
230
  * @param axis `'x'`, `'y'`, or `'z'`.
231
- * @param activeChannel Fallback label for pixels whose RGB doesn't match any channel (1-8).
231
+ * @param activeChannel Fallback label for pixels whose RGB matches no channel exactly,
232
+ * and one of the candidates the nearest-colour search considers.
232
233
  * @param channelVisible Optional map of visible channels (true=visible, false=hidden).
233
234
  * If provided, data for hidden channels will be preserved
234
235
  * when the canvas pixel is transparent.
@@ -236,7 +237,7 @@ export declare class MaskVolume {
236
237
  setSliceLabelsFromImageData(sliceIndex: number, imageData: ImageData, axis?: 'x' | 'y' | 'z', activeChannel?: number, channelVisible?: Record<number, boolean>): void;
237
238
  /**
238
239
  * Build a Map from RGB packed integer to channel label for reverse lookup.
239
- * Uses this instance's colorMap (channels 1-8, skips 0 = transparent).
240
+ * Covers every label this instance has a colour for, skipping 0 (transparent).
240
241
  *
241
242
  * Instance method ensures custom per-layer colors are correctly reverse-mapped.
242
243
  */
@@ -349,6 +350,32 @@ export declare class MaskVolume {
349
350
  * ```
350
351
  */
351
352
  clear(): void;
353
+ /**
354
+ * Zero every voxel carrying one label, leaving every other label in place.
355
+ *
356
+ * The third member of the clear family: `clear()` takes the whole volume and
357
+ * `clearSlice()` takes one slice, both regardless of label. Deleting a single
358
+ * annotation needs neither — its mask is one label inside a volume it shares with
359
+ * every other annotation on that layer, so anything coarser takes the neighbours
360
+ * with it.
361
+ *
362
+ * Label-based volumes only, which is what `numChannels === 1` means here: the voxel
363
+ * value IS the label. A multi-plane volume stores channels as separate planes and
364
+ * would need a different sweep.
365
+ *
366
+ * The version is bumped only when a voxel actually changed. Every derived cache keyed
367
+ * on it — the contour cache above all — is invalidated by a bump, so bumping for a
368
+ * clear that found nothing would redraw the layer for no reason.
369
+ *
370
+ * @param channel Label to erase, 1-255. Zero is "empty", not a channel.
371
+ * @throws {RangeError} If `channel` is outside [1, 255].
372
+ *
373
+ * @example
374
+ * ```ts
375
+ * vol.clearChannel(3); // finding 3's voxels go; 1, 2 and 4 stay
376
+ * ```
377
+ */
378
+ clearChannel(channel: number): void;
352
379
  /**
353
380
  * Check if the volume contains any non-zero voxel data.
354
381
  *
@@ -68,7 +68,7 @@
68
68
  * ```
69
69
  */
70
70
  export type { Dimensions, RGBAColor, ChannelColorMap, SliceRenderOptions, LayerId, ChannelValue, ICommXYZ, ICommXY, ISkipSlicesDictType, ToolMode, IDragPrameters, IDrawingEvents, IContrastEvents, IPaintImages, IPaintImage, ILayerRenderTarget, IDownloadImageConfig, INewMaskData, IMaskData, IProtected, IToolModeState, IDrawingConfig, IViewConfig, ILayerChannelState, IGUIStates, IGuiMeta, IGuiParameterSettings, IImageMetadata, IViewState, IInteractionState, ISphereState, IInternalFlags, INrrdStates, IAnnotationCallbacks, IConvertObjType, ICursorPage, IDragOpts, IDrawOpts, IKeyBoardSettings, } from './types';
71
- export { RenderMode, MASK_CHANNEL_COLORS, MASK_CHANNEL_CSS_COLORS, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, } from './types';
71
+ export { RenderMode, MAX_ENGINE_CHANNEL, MASK_CHANNEL_COLORS, MASK_CHANNEL_CSS_COLORS, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, } from './types';
72
72
  export { MaskVolume } from './MaskVolume';
73
73
  export type { MaskDelta, UndoEntry } from './UndoManager';
74
74
  export { UndoManager } from './UndoManager';
@@ -74,38 +74,39 @@ export interface SliceRenderOptions {
74
74
  * | 7 | Auxiliary annotation | Orange |
75
75
  * | 8 | Extended annotation | Purple |
76
76
  */
77
- export declare const MASK_CHANNEL_COLORS: Readonly<ChannelColorMap>;
78
77
  /**
79
- * CSS color strings for the default channel palette (for reference / UI).
78
+ * The largest label a mask voxel can carry. `MaskVolume` stores one byte per voxel and the
79
+ * value IS the label, so 0 is empty and 1-255 are annotation channels.
80
80
  */
81
- export declare const MASK_CHANNEL_CSS_COLORS: Readonly<Record<number, string>>;
81
+ export declare const MAX_ENGINE_CHANNEL = 255;
82
82
  /**
83
83
  * Layer identifier. Any string key is valid — layers are dynamically defined.
84
84
  */
85
85
  export type LayerId = string;
86
86
  /**
87
- * Channel value (0 = transparent/erased, 1-8 = annotation channels).
87
+ * Channel value: 0 is transparent/erased, 1..`MAX_ENGINE_CHANNEL` are annotation channels.
88
+ *
89
+ * A bare `number`, not a union. The union held while there were eight of them and cannot be
90
+ * written for 255; what it bought — a compile error on a bad literal — is now a runtime
91
+ * `RangeError` from `MaskVolume` instead. That is a real loss, and it is the price of the
92
+ * range: the storage is one byte per voxel whose value IS the label, so the engine has no
93
+ * standing to cap it lower than the byte does. A product's own limit is the product's
94
+ * business.
88
95
  */
89
- export type ChannelValue = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
96
+ export type ChannelValue = number;
97
+ export declare const MASK_CHANNEL_COLORS: Readonly<Record<number, RGBAColor>>;
98
+ export declare const MASK_CHANNEL_CSS_COLORS: Readonly<Record<number, string>>;
99
+ export declare const CHANNEL_HEX_COLORS: Readonly<Record<number, string>>;
100
+ export declare const AI_MASK_CHANNEL_COLORS: Readonly<Record<number, RGBAColor>>;
101
+ export declare const AI_CHANNEL_HEX_COLORS: Readonly<Record<number, string>>;
90
102
  /**
91
103
  * Convenience alias for MASK_CHANNEL_CSS_COLORS.
92
104
  * Used by Vue components via `Copper.CHANNEL_COLORS[channel]`.
105
+ *
106
+ * Declared here, with the tables it aliases. It used to sit further up, which was fine while
107
+ * those were object literals and is a temporal-dead-zone error now that they are built.
93
108
  */
94
109
  export declare const CHANNEL_COLORS: Readonly<Record<number, string>>;
95
- /**
96
- * Hex color strings for each channel (no alpha), used for fillColor/brushColor.
97
- */
98
- export declare const CHANNEL_HEX_COLORS: Readonly<Record<number, string>>;
99
- /**
100
- * AI-Assist channel palette. Identical to the default palette EXCEPT:
101
- * - channel 1 = cyan (the AI-Assist accent #5ec8ff), so the 2D AI overlay aligns
102
- * with the cyan ai_generated GLB in the 3D panel;
103
- * - channel 6 takes the emerald that channel 1 vacated, so cyan isn't duplicated.
104
- * Applied ONLY to the AI scratch layer (set per-volume in AiAssistTool.enter) —
105
- * the global palette above is untouched, so the clinician mask stays emerald.
106
- */
107
- export declare const AI_MASK_CHANNEL_COLORS: Readonly<ChannelColorMap>;
108
- export declare const AI_CHANNEL_HEX_COLORS: Readonly<Record<number, string>>;
109
110
  /**
110
111
  * Convert an RGBAColor to a hex string (no alpha), e.g. '#ff0000'.
111
112
  */
@@ -259,11 +260,11 @@ export interface IViewConfig {
259
260
  /** Layer/channel state — active layer, channel, and visibility */
260
261
  export interface ILayerChannelState {
261
262
  layer: string;
262
- /** Currently active channel (1-8). Channel 0 is transparent/erased. */
263
+ /** Currently active channel. 0 is transparent/erased. */
263
264
  activeChannel: number;
264
265
  /** Layer visibility state: { layer1: true, layer2: true, layer3: true } */
265
266
  layerVisibility: Record<string, boolean>;
266
- /** Per-layer channel visibility: { layer1: { 1: true, ..., 8: true }, ... } */
267
+ /** Per-layer channel visibility: { layer1: { 1: true, 2: false, ... }, ... } */
267
268
  channelVisibility: Record<string, Record<number, boolean>>;
268
269
  /** Per-layer opacity: { layer1: 1.0, layer2: 0.6, ... }. Range [0.1, 1.0]. */
269
270
  layerOpacity: Record<string, number>;