@vitessce/all 4.1.1 → 4.1.3

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.
@@ -3,7 +3,7 @@ import { useRef, useEffect, useState } from "react";
3
3
  import { useThree, useFrame } from "@react-three/fiber";
4
4
  import { Bvh } from "@react-three/drei";
5
5
  import { Matrix4, Vector3, Box3, FrontSide } from "three";
6
- import { g as getXRModule, i as isValidGeometrySize, M as MeasureLine, s as stringifyLineData } from "./index-Vg2it-xm.js";
6
+ import { g as getXRModule, i as isValidGeometrySize, M as MeasureLine, s as stringifyLineData } from "./index-4JZT6bFU.js";
7
7
  function getHandJoint(hand, jointName) {
8
8
  return hand.get(jointName);
9
9
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import React__default from "react";
3
- import { g as getDefaultExportFromCjs, d as requireAssign, f as require_export, h as require_core, j as require_fails, k as require_toObject, m as require_objectKeys, n as require_cof, o as require_wks, p as require_iterators, q as requireWeb_dom_iterable, s as requireEs6_string_iterator, t as require_anObject, v as require_hide, w as require_ctx, x as require_toLength, y as require_global, z as require_objectDp, A as require_descriptors, D as require_isObject, E as require_objectCreate, F as require_iterDefine, G as require_iterStep, H as require_meta, I as require_isArray, J as require_iobject, K as require_setToStringTag, M as require_aFunction, N as requireIterator, O as require_propertyDesc, c as commonjsGlobal, P as requireEs6_symbol, Q as requireDefineProperty, R as require_toIobject, S as require_objectGopd, T as require_html, U as require_domCreate, V as require_library, W as requireSymbol, X as require_objectPie, Y as require_has, Z as require_redefine, _ as require_objectAssign, $ as GREY_HEX, a0 as diffCameraState } from "./index-uF7T9QQ9.js";
3
+ import { g as getDefaultExportFromCjs, d as requireAssign, f as require_export, h as require_core, j as require_fails, k as require_toObject, m as require_objectKeys, n as require_cof, o as require_wks, p as require_iterators, q as requireWeb_dom_iterable, s as requireEs6_string_iterator, t as require_anObject, v as require_hide, w as require_ctx, x as require_toLength, y as require_global, z as require_objectDp, A as require_descriptors, D as require_isObject, E as require_objectCreate, F as require_iterDefine, G as require_iterStep, H as require_meta, I as require_isArray, J as require_iobject, K as require_setToStringTag, M as require_aFunction, N as requireIterator, O as require_propertyDesc, c as commonjsGlobal, P as requireEs6_symbol, Q as requireDefineProperty, R as require_toIobject, S as require_objectGopd, T as require_html, U as require_domCreate, V as require_library, W as requireSymbol, X as require_objectPie, Y as require_has, Z as require_redefine, _ as require_objectAssign, $ as GREY_HEX, a0 as diffCameraState, a1 as applyQuat } from "./index-D7sxxfGG.js";
4
4
  var assignExports = requireAssign();
5
5
  const _Object$assign = /* @__PURE__ */ getDefaultExportFromCjs(assignExports);
6
6
  var es6_object_keys = {};
@@ -65185,6 +65185,9 @@ function setupDefaultViewer(options) {
65185
65185
  }
65186
65186
  const viewersKeyed = {};
65187
65187
  let viewerNoKey;
65188
+ const MIN_PROJECTION_SCALE_M = 1e-9;
65189
+ const FOV_F = 1 / Math.tan(Math.PI / 8);
65190
+ const MIN_RELATIVE_DEPTH = 50;
65188
65191
  function parseUrlHash(url) {
65189
65192
  let state = null;
65190
65193
  let s = url.replace(/^[^#]+/, "");
@@ -65498,6 +65501,29 @@ class Neuroglancer extends React__default.Component {
65498
65501
  });
65499
65502
  }
65500
65503
  };
65504
+ // Viewer-level toggles. Applied directly (not via restoreState) because updates
65505
+ // after mount only re-apply camera and layers.
65506
+ applyViewerToggles = () => {
65507
+ const { viewer } = this;
65508
+ if (!viewer)
65509
+ return;
65510
+ const { axisLinesVisible, boundsVisible, orthographic, scaleBarVisible } = this.props;
65511
+ this.withoutEmitting(() => {
65512
+ if (typeof axisLinesVisible === "boolean" && viewer.showAxisLines.value !== axisLinesVisible) {
65513
+ viewer.showAxisLines.value = axisLinesVisible;
65514
+ }
65515
+ if (typeof boundsVisible === "boolean" && viewer.showDefaultAnnotations.value !== boundsVisible) {
65516
+ viewer.showDefaultAnnotations.value = boundsVisible;
65517
+ }
65518
+ const layoutSpec = viewer.layout?.container?.component?.layerGroupViewer?.layout?.specification;
65519
+ if (typeof orthographic === "boolean" && layoutSpec?.orthographicProjection && layoutSpec.orthographicProjection.value !== orthographic) {
65520
+ layoutSpec.orthographicProjection.value = orthographic;
65521
+ }
65522
+ if (typeof scaleBarVisible === "boolean" && viewer.showScaleBar.value !== scaleBarVisible) {
65523
+ viewer.showScaleBar.value = scaleBarVisible;
65524
+ }
65525
+ });
65526
+ };
65501
65527
  // Only consider actual changes in camera settings, i.e., position/rotation/zoom
65502
65528
  didLayersChange = (prevVS, nextVS) => {
65503
65529
  const stripColors = (layers) => (layers || []).map((l) => {
@@ -65528,6 +65554,13 @@ class Neuroglancer extends React__default.Component {
65528
65554
  const b = parseInt(hex.slice(5, 7), 16);
65529
65555
  return b * 65536 + g * 256 + r;
65530
65556
  };
65557
+ // Neuroglancer paints its own 3D canvas; match it to the view's background.
65558
+ applyBackgroundTheme = () => {
65559
+ if (!this.viewer)
65560
+ return;
65561
+ const hex = this.props.backgroundTheme === "light" ? "#ffffff" : "#000000";
65562
+ this.viewer.perspectiveViewBackgroundColor.restoreState(hex);
65563
+ };
65531
65564
  /* To add colors to the segments, turning unselected to grey */
65532
65565
  applyColorsAndVisibility = (cellColorMappingByLayer) => {
65533
65566
  if (!this.viewer)
@@ -65626,10 +65659,70 @@ class Neuroglancer extends React__default.Component {
65626
65659
  this.disposers.push(this.viewer.projectionScale.changed.add(emit));
65627
65660
  this.disposers.push(this.viewer.projectionOrientation.changed.add(emit));
65628
65661
  this.disposers.push(this.viewer.position.changed.add(emit));
65662
+ let clampRaf = null;
65663
+ const clampZoom = () => {
65664
+ if (clampRaf !== null)
65665
+ return;
65666
+ clampRaf = requestAnimationFrame(() => {
65667
+ clampRaf = null;
65668
+ const ps = this.viewer?.projectionScale;
65669
+ if (!ps)
65670
+ return;
65671
+ const minScale = MIN_PROJECTION_SCALE_M / ps.canonicalVoxelPhysicalSize;
65672
+ if (Number.isFinite(minScale) && ps.value < minScale) {
65673
+ console.trace("[NG] clamp projectionScale", ps.value, "→", minScale);
65674
+ ps.value = minScale;
65675
+ }
65676
+ });
65677
+ };
65678
+ this.disposers.push(this.viewer.projectionScale.changed.add(clampZoom));
65679
+ this.disposers.push(() => {
65680
+ if (clampRaf !== null)
65681
+ cancelAnimationFrame(clampRaf);
65682
+ });
65629
65683
  if (viewerState) {
65630
65684
  this.withoutEmitting(() => {
65631
65685
  this.viewer.state.restoreState(viewerState);
65632
65686
  });
65687
+ const s = this.viewer.state.toJSON();
65688
+ this.homeCamera = {
65689
+ position: s.position,
65690
+ projectionScale: s.projectionScale,
65691
+ projectionOrientation: s.projectionOrientation
65692
+ };
65693
+ let depthRaf = null;
65694
+ const fitDepthToData = () => {
65695
+ if (depthRaf !== null)
65696
+ return;
65697
+ depthRaf = requestAnimationFrame(() => {
65698
+ depthRaf = null;
65699
+ const v = this.viewer;
65700
+ const bounds = v?.coordinateSpace.value?.bounds;
65701
+ const pos = v?.position.value;
65702
+ const ps = v?.projectionScale.value;
65703
+ if (!bounds || !pos || pos.length < 3 || !(ps > 0))
65704
+ return;
65705
+ const { lowerBounds: lo, upperBounds: hi } = bounds;
65706
+ const axis = applyQuat(Array.from(v.projectionOrientation.orientation), [0, 0, 1]);
65707
+ let reach = 0;
65708
+ for (let i = 0; i < 3; i += 1) {
65709
+ reach += Math.abs(axis[i]) * Math.max(Math.abs(lo[i] - pos[i]), Math.abs(hi[i] - pos[i]));
65710
+ }
65711
+ const d = ps * FOV_F / 2;
65712
+ const r = Number.isFinite(reach) ? FOV_F * ((d + reach) * 1.05 / d - 1) : 0;
65713
+ v.projectionDepthRange.value = -Math.max(MIN_RELATIVE_DEPTH, r);
65714
+ });
65715
+ };
65716
+ this.disposers.push(this.viewer.position.changed.add(fitDepthToData));
65717
+ this.disposers.push(this.viewer.projectionScale.changed.add(fitDepthToData));
65718
+ this.disposers.push(this.viewer.projectionOrientation.changed.add(fitDepthToData));
65719
+ this.disposers.push(this.viewer.coordinateSpace.changed.add(fitDepthToData));
65720
+ this.disposers.push(() => {
65721
+ if (depthRaf !== null)
65722
+ cancelAnimationFrame(depthRaf);
65723
+ });
65724
+ fitDepthToData();
65725
+ this.applyViewerToggles();
65633
65726
  }
65634
65727
  if (key) {
65635
65728
  viewersKeyed[key] = this.viewer;
@@ -65638,7 +65731,33 @@ class Neuroglancer extends React__default.Component {
65638
65731
  }
65639
65732
  const { visibleChunksChanged } = this.viewer.chunkQueueManager;
65640
65733
  let firstChunkLoaded = false;
65734
+ const reportedAnnotationLayers = /* @__PURE__ */ new Set();
65735
+ const reportAnnotationSources = () => {
65736
+ if (!this.viewer)
65737
+ return;
65738
+ for (const layer of this.viewer.layerManager.managedLayers) {
65739
+ if (layer.layer instanceof AnnotationUserLayer && !reportedAnnotationLayers.has(layer.name)) {
65740
+ const annotState = layer.layer.annotationStates?.states[0];
65741
+ const t = annotState?.chunkTransform?.value?.layerToChunkTransform;
65742
+ const serializers = annotState?.source?.annotationPropertySerializers;
65743
+ if (t && serializers) {
65744
+ reportedAnnotationLayers.add(layer.name);
65745
+ this.props.onAnnotationSourceReady?.({
65746
+ layerName: layer.name,
65747
+ x: t[0],
65748
+ y: t[5],
65749
+ z: t[10],
65750
+ serializers,
65751
+ // pass all serializers
65752
+ serializer: serializers[0]
65753
+ // keep default for backward compat
65754
+ });
65755
+ }
65756
+ }
65757
+ }
65758
+ };
65641
65759
  const checkAndMarkLoaded = () => {
65760
+ reportAnnotationSources();
65642
65761
  if (firstChunkLoaded || !this.viewer)
65643
65762
  return false;
65644
65763
  for (const layer of this.viewer.layerManager.managedLayers) {
@@ -65667,20 +65786,6 @@ class Neuroglancer extends React__default.Component {
65667
65786
  requestAnimationFrame(() => requestAnimationFrame(() => {
65668
65787
  this.props.onLayerLoadingChange?.(true);
65669
65788
  }));
65670
- const annotState = layer.layer.annotationStates?.states[0];
65671
- const t = annotState?.chunkTransform?.value?.layerToChunkTransform;
65672
- const serializers = annotState?.source?.annotationPropertySerializers;
65673
- if (t && serializers) {
65674
- this.props.onAnnotationSourceReady?.({
65675
- x: t[0],
65676
- y: t[5],
65677
- z: t[10],
65678
- serializers,
65679
- // pass all serializers
65680
- serializer: serializers[0]
65681
- // keep default for backward compat
65682
- });
65683
- }
65684
65789
  return true;
65685
65790
  }
65686
65791
  }
@@ -65688,14 +65793,8 @@ class Neuroglancer extends React__default.Component {
65688
65793
  return false;
65689
65794
  };
65690
65795
  this.disposers.push(visibleChunksChanged.add(checkAndMarkLoaded));
65691
- const timeoutId1 = setTimeout(() => {
65692
- if (!firstChunkLoaded)
65693
- checkAndMarkLoaded();
65694
- }, 100);
65695
- const timeoutId2 = setTimeout(() => {
65696
- if (!firstChunkLoaded)
65697
- checkAndMarkLoaded();
65698
- }, 1e3);
65796
+ const timeoutId1 = setTimeout(checkAndMarkLoaded, 100);
65797
+ const timeoutId2 = setTimeout(checkAndMarkLoaded, 1e3);
65699
65798
  this.disposers.push(() => clearTimeout(timeoutId1));
65700
65799
  this.disposers.push(() => clearTimeout(timeoutId2));
65701
65800
  document.addEventListener("wheel", (e) => {
@@ -65713,10 +65812,17 @@ class Neuroglancer extends React__default.Component {
65713
65812
  this.applyColorsAndVisibility(this.props.cellColorMapping);
65714
65813
  }
65715
65814
  }));
65815
+ this.applyBackgroundTheme();
65716
65816
  window.viewer = this.viewer;
65717
65817
  }
65718
65818
  componentDidUpdate(prevProps, prevState) {
65719
65819
  const { viewerState, cellColorMapping: cellColorMappingByLayer } = this.props;
65820
+ if (prevProps.backgroundTheme !== this.props.backgroundTheme) {
65821
+ this.applyBackgroundTheme();
65822
+ }
65823
+ if (prevProps.axisLinesVisible !== this.props.axisLinesVisible || prevProps.boundsVisible !== this.props.boundsVisible || prevProps.orthographic !== this.props.orthographic || prevProps.scaleBarVisible !== this.props.scaleBarVisible) {
65824
+ this.applyViewerToggles();
65825
+ }
65720
65826
  const selectedSegments = {};
65721
65827
  for (const layer of this.viewer.layerManager.managedLayers) {
65722
65828
  if (layer.layer instanceof SegmentationUserLayer) {
@@ -65736,8 +65842,7 @@ class Neuroglancer extends React__default.Component {
65736
65842
  segmentSelectionState.set(selectedSegments[layer.name]);
65737
65843
  const layerScope = Object.keys(cellColorMappingByLayer).find((scope) => layer.name?.includes(scope));
65738
65844
  if (layerScope) {
65739
- const opacity = this.props.meshOpacity !== void 0 ? this.props.meshOpacity : cellColorMappingByLayer[layerScope]?.opacity ?? 1;
65740
- layer.layer.displayState.objectAlpha.value = opacity;
65845
+ layer.layer.displayState.objectAlpha.value = cellColorMappingByLayer[layerScope]?.opacity ?? 1;
65741
65846
  }
65742
65847
  }
65743
65848
  if (layer.layer instanceof AnnotationUserLayer) {
@@ -65817,6 +65922,9 @@ class Neuroglancer extends React__default.Component {
65817
65922
  });
65818
65923
  this.applyColorsAndVisibility(cellColorMappingByLayer);
65819
65924
  }
65925
+ if (prevProps.cameraResetRequest !== this.props.cameraResetRequest && this.homeCamera) {
65926
+ this.viewer.state.restoreState(this.homeCamera);
65927
+ }
65820
65928
  }
65821
65929
  componentWillUnmount() {
65822
65930
  this.disposers.forEach((off) => {
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useState, useEffect } from "react";
3
- import { g as getXrStore } from "./xrStore-2FzrFs3o.js";
3
+ import { g as getXrStore } from "./xrStore-Dt0n9R6Z.js";
4
4
  function XREnterButton() {
5
5
  const [supported, setSupported] = useState(false);
6
6
  const [entered, setEntered] = useState(false);
@@ -1,7 +1,7 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { useRef } from "react";
3
3
  import { useThree, useFrame } from "@react-three/fiber";
4
- import { g as getXRModule } from "./index-Vg2it-xm.js";
4
+ import { g as getXRModule } from "./index-4JZT6bFU.js";
5
5
  function getHandJoint(hand, jointName) {
6
6
  return hand.get(jointName);
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { g as getXRModule } from "./index-Vg2it-xm.js";
3
- import { g as getXrStore } from "./xrStore-2FzrFs3o.js";
2
+ import { g as getXRModule } from "./index-4JZT6bFU.js";
3
+ import { g as getXrStore } from "./xrStore-Dt0n9R6Z.js";
4
4
  function XRWrapper({ children }) {
5
5
  const { XR } = getXRModule();
6
6
  return jsx(XR, { store: getXrStore(), children });
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { B as BaseDecoder } from "./index-uF7T9QQ9.js";
2
+ import { B as BaseDecoder } from "./index-D7sxxfGG.js";
3
3
  class DeflateDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
5
5
  return inflate_1(new Uint8Array(buffer)).buffer;
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import React__default, { createContext, isValidElement, PureComponent, Component, useMemo, useState, useRef, useEffect, useCallback, memo, useContext, useReducer, useLayoutEffect } from "react";
3
- import { r as requireObjectAssign, g as getDefaultExportFromCjs$1, c as commonjsGlobal, e as earcut } from "./index-uF7T9QQ9.js";
3
+ import { r as requireObjectAssign, g as getDefaultExportFromCjs$1, c as commonjsGlobal, e as earcut } from "./index-D7sxxfGG.js";
4
4
  import ReactDOM__default, { unstable_batchedUpdates, createPortal } from "react-dom";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  function finallyConstructor(callback) {
@@ -3,7 +3,7 @@ import React__default, { useRef, useState, useEffect, Suspense, forwardRef } fro
3
3
  import { Canvas } from "@react-three/fiber";
4
4
  import { Center, Text, Line, Bvh, OrbitControls } from "@react-three/drei";
5
5
  import { Matrix3, Matrix4, Vector3, Vector2, UniformsUtils, Data3DTexture, RedFormat, FloatType, LinearFilter, FrontSide, Scene, Group, MeshPhysicalMaterial, MeshBasicMaterial, MeshStandardMaterial, BackSide } from "three";
6
- import { C as CoordinationType, b as getImageSize } from "./index-uF7T9QQ9.js";
6
+ import { C as CoordinationType, b as getImageSize } from "./index-D7sxxfGG.js";
7
7
  function MeasureLine({ currentLine, scale }) {
8
8
  const textRef = useRef(null);
9
9
  return jsxs("group", { children: [jsx(Center, { bottom: true, right: true, position: [currentLine.midPoint.x, currentLine.midPoint.y, currentLine.midPoint.z], rotation: [0, 0, 0], children: jsx(Text, { color: "gray", scale: 0.05, ref: textRef, children: `${(currentLine.startPoint.distanceTo(currentLine.endPoint) * scale).toFixed(2)} µm` }) }), jsx(Line, {
@@ -945,8 +945,8 @@ function GeometryAndMesh(props) {
945
945
  setObsHighlight(e.object.name);
946
946
  }, onPointerOut: () => setObsHighlight(null) }) })] }) : null, renderingSettings.uniforms && renderingSettings.shader && renderingSettings.meshScale && renderingSettings.geometrySize ? jsx("group", { children: jsxs("mesh", { scale: renderingSettings.meshScale, ref: materialRef, children: [jsx("boxGeometry", { args: renderingSettings.geometrySize }), jsx("shaderMaterial", { customProgramCacheKey: () => "1", side: FrontSide, uniforms: renderingSettings.uniforms, needsUpdate: true, transparent: true, vertexShader: renderingSettings.shader.vertexShader, fragmentShader: renderingSettings.shader.fragmentShader })] }) }) : null] }), jsx("group", { name: "lines", children: lines.map((object) => jsx(MeasureLine, { currentLine: object, scale: 1 }, stringifyLineData(object))) })] });
947
947
  }
948
- const LazyGeometryAndMeshXR = React__default.lazy(() => import("./GeometryAndMeshXR-BSJ2rBtK.js").catch(() => ({ default: GeometryAndMesh })));
949
- const LazyXRSceneComponents = React__default.lazy(() => import("./XRSceneComponents-KvBqtraG.js").catch(() => ({ default: () => null })));
948
+ const LazyGeometryAndMeshXR = React__default.lazy(() => import("./GeometryAndMeshXR-BO4cB8Py.js").catch(() => ({ default: GeometryAndMesh })));
949
+ const LazyXRSceneComponents = React__default.lazy(() => import("./XRSceneComponents-CXXeqxgE.js").catch(() => ({ default: () => null })));
950
950
  function SpatialThree(props) {
951
951
  const materialRef = useRef(null);
952
952
  const orbitRef = useRef(null);
@@ -1303,13 +1303,13 @@ function getXRModule() {
1303
1303
  }
1304
1304
  const LazyXRWrapper = React__default.lazy(
1305
1305
  // eslint-disable-next-line implicit-arrow-linebreak, function-paren-newline
1306
- () => import("./XRWrapper-BNdj_qnt.js").catch(() => ({
1306
+ () => import("./XRWrapper-ChEnDQOC.js").catch(() => ({
1307
1307
  default: ({ children }) => children
1308
1308
  }))
1309
1309
  );
1310
1310
  const LazyXREnterButton = React__default.lazy(
1311
1311
  // eslint-disable-next-line implicit-arrow-linebreak, function-paren-newline
1312
- () => import("./XREnterButton-D-MyjNiM.js").catch(() => ({
1312
+ () => import("./XREnterButton-DePbBRY6.js").catch(() => ({
1313
1313
  default: () => null
1314
1314
  }))
1315
1315
  );