@vitessce/dev 3.9.3 → 3.9.5

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.
@@ -1,7 +1,7 @@
1
- import { G as Group, M as Matrix4, T as TrianglesDrawMode, a as TriangleFanDrawMode, b as TriangleStripDrawMode, R as REVISION, L as Loader, c as LoaderUtils, F as FileLoader, d as MeshPhysicalMaterial, V as Vector2, C as Color, S as SpotLight, P as PointLight, D as DirectionalLight, e as Vector3, I as InstancedMesh, Q as Quaternion, O as Object3D, f as TextureLoader, g as ImageBitmapLoader, B as BufferAttribute, h as InterleavedBuffer, i as LinearMipmapLinearFilter, N as NearestMipmapLinearFilter, j as LinearMipmapNearestFilter, k as NearestMipmapNearestFilter, l as LinearFilter, m as NearestFilter, n as RepeatWrapping, o as MirroredRepeatWrapping, p as ClampToEdgeWrapping, q as PointsMaterial, r as Material, s as LineBasicMaterial, t as MeshStandardMaterial, u as DoubleSide, v as MeshBasicMaterial, w as PropertyBinding, x as BufferGeometry, y as SkinnedMesh, z as Mesh, A as LineSegments, E as Line$1, H as LineLoop, J as Points, K as PerspectiveCamera, U as MathUtils, W as OrthographicCamera, X as Skeleton, Y as InterpolateDiscrete, Z as InterpolateLinear, _ as AnimationClip, $ as Bone, a0 as InterleavedBufferAttribute, a1 as Texture, a2 as VectorKeyframeTrack, a3 as QuaternionKeyframeTrack, a4 as NumberKeyframeTrack, a5 as FrontSide, a6 as Interpolant, a7 as Box3, a8 as Sphere, a9 as InstancedBufferGeometry, aa as Float32BufferAttribute, ab as InstancedInterleavedBuffer, ac as WireframeGeometry, ad as ShaderMaterial, ae as UniformsUtils, af as UniformsLib, ag as Vector4, ah as Line3, ai as SphereGeometry, aj as _extends, ak as Plane, al as Triangle, am as BackSide, an as Ray$1, ao as jsxRuntimeExports, ap as Matrix3, aq as CoordinationType, ar as Data3DTexture, as as RedFormat, at as FloatType, au as getImageSize, av as Scene } from "./index-DpZSD_ri.js";
1
+ import { G as Group, M as Matrix4, T as TrianglesDrawMode, a as TriangleFanDrawMode, b as TriangleStripDrawMode, R as REVISION, L as Loader, c as LoaderUtils, F as FileLoader, d as MeshPhysicalMaterial, V as Vector2, C as Color, S as SpotLight, P as PointLight, D as DirectionalLight, e as Vector3, I as InstancedMesh, Q as Quaternion, O as Object3D, f as TextureLoader, g as ImageBitmapLoader, B as BufferAttribute, h as InterleavedBuffer, i as LinearMipmapLinearFilter, N as NearestMipmapLinearFilter, j as LinearMipmapNearestFilter, k as NearestMipmapNearestFilter, l as LinearFilter, m as NearestFilter, n as RepeatWrapping, o as MirroredRepeatWrapping, p as ClampToEdgeWrapping, q as PointsMaterial, r as Material, s as LineBasicMaterial, t as MeshStandardMaterial, u as DoubleSide, v as MeshBasicMaterial, w as PropertyBinding, x as BufferGeometry, y as SkinnedMesh, z as Mesh, A as LineSegments, E as Line$1, H as LineLoop, J as Points, K as PerspectiveCamera, U as MathUtils, W as OrthographicCamera, X as Skeleton, Y as InterpolateDiscrete, Z as InterpolateLinear, _ as AnimationClip, $ as Bone, a0 as InterleavedBufferAttribute, a1 as Texture, a2 as VectorKeyframeTrack, a3 as QuaternionKeyframeTrack, a4 as NumberKeyframeTrack, a5 as FrontSide, a6 as Interpolant, a7 as Box3, a8 as Sphere, a9 as InstancedBufferGeometry, aa as Float32BufferAttribute, ab as InstancedInterleavedBuffer, ac as WireframeGeometry, ad as ShaderMaterial, ae as UniformsUtils, af as UniformsLib, ag as Vector4, ah as Line3, ai as SphereGeometry, aj as _extends, ak as Plane, al as Triangle, am as BackSide, an as Ray$1, ao as jsxRuntimeExports, ap as Matrix3, aq as CoordinationType, ar as Data3DTexture, as as RedFormat, at as FloatType, au as getImageSize, av as Scene } from "./index-BOSHQFXK.js";
2
2
  import * as React from "react";
3
3
  import { useRef, useEffect, useState, forwardRef } from "react";
4
- import { u as useThree, a as useFrame, c as create, e as extend, b as createPortal, O as OrbitControls, C as Canvas } from "./OrbitControls-DFnU45i3.js";
4
+ import { u as useThree, a as useFrame, c as create, e as extend, b as createPortal, O as OrbitControls, C as Canvas } from "./OrbitControls-g3V6AQrL.js";
5
5
  const isPromise = (promise) => typeof promise === "object" && typeof promise.then === "function";
6
6
  const globalCache = [];
7
7
  function shallowEqualArrays(arrA, arrB, equal = (a, b) => a === b) {
@@ -5027,7 +5027,7 @@ const Text = /* @__PURE__ */ React.forwardRef(({
5027
5027
  const {
5028
5028
  Text: TextMeshImpl,
5029
5029
  preloadFont
5030
- } = suspend(async () => import("./troika-three-text.esm-BhymeUu1.js"), []);
5030
+ } = suspend(async () => import("./troika-three-text.esm-DwvolRZ3.js"), []);
5031
5031
  const invalidate = useThree(({
5032
5032
  invalidate: invalidate2
5033
5033
  }) => invalidate2);
@@ -1,6 +1,6 @@
1
- import { aw as log, ax as isEqual, ay as atLeastLogLevel, ar as Data3DTexture, as as RedFormat, az as UnsignedByteType, l as LinearFilter, aA as RedIntegerFormat, aB as UnsignedIntType, m as NearestFilter, aC as LogLevel, e as Vector3, V as Vector2, ag as Vector4, ae as UniformsUtils, aq as CoordinationType, aD as WebGLMultipleRenderTargets, aE as RGBAFormat, av as Scene, W as OrthographicCamera, ad as ShaderMaterial, z as Mesh, aF as PlaneGeometry, aG as useEventCallback, ao as jsxRuntimeExports, aH as GLSL3, am as BackSide } from "./index-DpZSD_ri.js";
1
+ import { aw as log, ax as isEqual, ay as atLeastLogLevel, ar as Data3DTexture, as as RedFormat, az as UnsignedByteType, l as LinearFilter, aA as RedIntegerFormat, aB as UnsignedIntType, m as NearestFilter, aC as LogLevel, e as Vector3, V as Vector2, ag as Vector4, ae as UniformsUtils, aq as CoordinationType, aD as WebGLMultipleRenderTargets, aE as RGBAFormat, av as Scene, W as OrthographicCamera, ad as ShaderMaterial, z as Mesh, aF as PlaneGeometry, aG as useEventCallback, ao as jsxRuntimeExports, aH as GLSL3, am as BackSide } from "./index-BOSHQFXK.js";
2
2
  import { useRef, useState, useMemo, useEffect, Suspense } from "react";
3
- import { u as useThree, a as useFrame, O as OrbitControls, C as Canvas } from "./OrbitControls-DFnU45i3.js";
3
+ import { u as useThree, a as useFrame, O as OrbitControls, C as Canvas } from "./OrbitControls-g3V6AQrL.js";
4
4
  const BRICK_SIZE = 32;
5
5
  const BRICK_CACHE_SIZE_X = 64;
6
6
  const BRICK_CACHE_SIZE_Y = 64;
@@ -174,9 +174,17 @@ function _ptToZarr(ptx, pty, ptz, ptInfo) {
174
174
  z
175
175
  };
176
176
  }
177
- function _requestBufferToRequestObjects(buffer, k) {
177
+ const DEFAULT_SIGMA_NORMALIZED = 0.25;
178
+ function _requestBufferToRequestObjects(buffer, k, optsForWeighting) {
178
179
  const counts = /* @__PURE__ */ new Map();
179
- for (let i = 0; i < buffer.length; i += 4) {
180
+ const { width, height, sigmaNormalized } = optsForWeighting;
181
+ const useWeighting = Number.isInteger(width) && Number.isInteger(height) && width > 0 && height > 0 && typeof sigmaNormalized === "number";
182
+ if (!useWeighting) {
183
+ log.warn("_requestBufferToRequestObjects: proceeding without weighting");
184
+ }
185
+ const maxPixels = Math.floor(buffer.length / 4);
186
+ for (let pix = 0; pix < maxPixels; pix += 1) {
187
+ const i = pix * 4;
180
188
  const r = buffer[i];
181
189
  const g = buffer[i + 1];
182
190
  const b = buffer[i + 2];
@@ -185,7 +193,17 @@ function _requestBufferToRequestObjects(buffer, k) {
185
193
  continue;
186
194
  }
187
195
  const packed = (r << 24 | g << 16 | b << 8 | a) >>> 0;
188
- counts.set(packed, (counts.get(packed) || 0) + 1);
196
+ let weight = 1;
197
+ if (useWeighting) {
198
+ const x = pix % width;
199
+ const y = Math.floor(pix / width);
200
+ const dx = x - width / 2;
201
+ const dy = y - height / 2;
202
+ const nd = Math.sqrt(dx * dx / (width * width) + dy * dy / (height * height));
203
+ const norm = nd / sigmaNormalized;
204
+ weight = Math.exp(-0.5 * norm * norm);
205
+ }
206
+ counts.set(packed, (counts.get(packed) || 0) + weight);
189
207
  }
190
208
  const requests = [...counts.entries()].sort((a, b) => b[1] - a[1]).slice(0, k).map(([packed]) => ({
191
209
  x: packed >> 22 & 1023,
@@ -842,7 +860,19 @@ class VolumeDataManager {
842
860
  }
843
861
  return chunkEntry.data;
844
862
  }
845
- async processRequestData(buffer) {
863
+ /**
864
+ * Process the buffer of brick requests from the shader, turning them into
865
+ * actual Promises for Zarr chunks on the JS side.
866
+ * @param {Uint8Array} buffer The bufRequest (of length width*height*4)
867
+ * containing the brick requests from the shader.
868
+ * @param {object} optsForWeighting
869
+ * @param {number} optsForWeighting.width The width of the render target.
870
+ * @param {number} optsForWeighting.height The height of the render target.
871
+ * @param {number} optsForWeighting.sigmaNormalized The normalized sigma value
872
+ * to use for weighting the brick requests based on their distance from
873
+ * the center of the render target.
874
+ */
875
+ async processRequestData(buffer, optsForWeighting) {
846
876
  if (this.isBusy) {
847
877
  log.debug("processRequestData: already busy, skipping");
848
878
  return;
@@ -857,7 +887,7 @@ class VolumeDataManager {
857
887
  }
858
888
  this.isBusy = true;
859
889
  this.triggerRequest = false;
860
- const { requests, origRequestCount } = _requestBufferToRequestObjects(buffer, this.k);
890
+ const { requests, origRequestCount } = _requestBufferToRequestObjects(buffer, this.k, optsForWeighting);
861
891
  if (requests.length === 0) {
862
892
  this.noNewRequests = true;
863
893
  }
@@ -3420,7 +3450,14 @@ function handleRequests(_gl, { frameRef, dataManager, mrtRef, bufRequest, bufUsa
3420
3450
  ctx.bindFramebuffer(ctx.READ_FRAMEBUFFER, framebufferFor(_gl, mrtRef.current));
3421
3451
  ctx.readBuffer(ctx.COLOR_ATTACHMENT1);
3422
3452
  ctx.readPixels(0, 0, mrtRef.current.width, mrtRef.current.height, ctx.RGBA, ctx.UNSIGNED_BYTE, bufRequest.current);
3423
- dataManager.processRequestData(bufRequest.current);
3453
+ dataManager.processRequestData(bufRequest.current, {
3454
+ // If width/height are not yet available,
3455
+ // processRequestData will proceed without weighting.
3456
+ width: mrtRef?.current?.width,
3457
+ height: mrtRef?.current?.height,
3458
+ // Default sigmaNormalized = 0.25; can be tuned
3459
+ sigmaNormalized: DEFAULT_SIGMA_NORMALIZED
3460
+ });
3424
3461
  } else if (dataManager.triggerUsage === true && dataManager.noNewRequests === false) {
3425
3462
  ctx.bindFramebuffer(ctx.READ_FRAMEBUFFER, framebufferFor(_gl, mrtRef.current));
3426
3463
  ctx.readBuffer(ctx.COLOR_ATTACHMENT2);
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c0, bX, bV, bW, c4, c5, bY, cg, ce, cc, cf, cd, bU, cb, bZ, bT, bS, c2, c8, c1, c3, c7, c6, b$, c9, ca, cl, co, ci, cp, cq, cj, cm, cn, ck, b_, ch } from "./index-DpZSD_ri.js";
1
+ import { c0, bX, bV, bW, c4, c5, bY, cg, ce, cc, cf, cd, bU, cb, bZ, bT, bS, c2, c8, c1, c3, c7, c6, b$, c9, ca, cl, co, ci, cp, cq, cj, cm, cn, ck, b_, ch } from "./index-BOSHQFXK.js";
2
2
  import "react";
3
3
  export {
4
4
  c0 as CoordinationLevel,
@@ -1,4 +1,4 @@
1
- import { aZ as BaseDecoder } from "./index-DpZSD_ri.js";
1
+ import { aZ as BaseDecoder } from "./index-BOSHQFXK.js";
2
2
  const dctZigZag = new Int32Array([
3
3
  0,
4
4
  1,
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { aI as getDefaultExportFromCjs, aZ as BaseDecoder, a_ as LercParameters, a$ as LercAddCompression } from "./index-DpZSD_ri.js";
2
+ import { aI as getDefaultExportFromCjs, aZ as BaseDecoder, a_ as LercParameters, a$ as LercAddCompression } from "./index-BOSHQFXK.js";
3
3
  var LercDecode = { exports: {} };
4
4
  var hasRequiredLercDecode;
5
5
  function requireLercDecode() {
@@ -1,4 +1,4 @@
1
- import { aZ as BaseDecoder } from "./index-DpZSD_ri.js";
1
+ import { aZ as BaseDecoder } from "./index-BOSHQFXK.js";
2
2
  const MIN_BITS = 9;
3
3
  const CLEAR_CODE = 256;
4
4
  const EOI_CODE = 257;
@@ -1,4 +1,4 @@
1
- import { aZ as BaseDecoder } from "./index-DpZSD_ri.js";
1
+ import { aZ as BaseDecoder } from "./index-BOSHQFXK.js";
2
2
  class PackbitsDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  const dataView = new DataView(buffer);
@@ -1,4 +1,4 @@
1
- import { aZ as BaseDecoder } from "./index-DpZSD_ri.js";
1
+ import { aZ as BaseDecoder } from "./index-BOSHQFXK.js";
2
2
  class RawDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  return buffer;
@@ -1,4 +1,4 @@
1
- import { bN as MeshDistanceMaterial, bO as MeshDepthMaterial, bP as RGBADepthPacking, ae as UniformsUtils, bQ as ShaderChunk, a9 as InstancedBufferGeometry, a8 as Sphere, a7 as Box3, am as BackSide, u as DoubleSide, z as Mesh, a5 as FrontSide, v as MeshBasicMaterial, C as Color, e as Vector3, M as Matrix4, V as Vector2, ap as Matrix3, ag as Vector4, a1 as Texture, l as LinearFilter, aF as PlaneGeometry, x as BufferGeometry, aa as Float32BufferAttribute, bR as InstancedBufferAttribute } from "./index-DpZSD_ri.js";
1
+ import { bN as MeshDistanceMaterial, bO as MeshDepthMaterial, bP as RGBADepthPacking, ae as UniformsUtils, bQ as ShaderChunk, a9 as InstancedBufferGeometry, a8 as Sphere, a7 as Box3, am as BackSide, u as DoubleSide, z as Mesh, a5 as FrontSide, v as MeshBasicMaterial, C as Color, e as Vector3, M as Matrix4, V as Vector2, ap as Matrix3, ag as Vector4, a1 as Texture, l as LinearFilter, aF as PlaneGeometry, x as BufferGeometry, aa as Float32BufferAttribute, bR as InstancedBufferAttribute } from "./index-BOSHQFXK.js";
2
2
  function workerBootstrap() {
3
3
  var modules = /* @__PURE__ */ Object.create(null);
4
4
  function registerModule(ref, callback) {
@@ -1,4 +1,4 @@
1
- import { aZ as BaseDecoder } from "./index-DpZSD_ri.js";
1
+ import { aZ as BaseDecoder } from "./index-BOSHQFXK.js";
2
2
  class WebImageDecoder extends BaseDecoder {
3
3
  constructor() {
4
4
  super();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/dev",
3
- "version": "3.9.3",
3
+ "version": "3.9.5",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -16,10 +16,10 @@
16
16
  "dist-tsc"
17
17
  ],
18
18
  "dependencies": {
19
- "@vitessce/constants": "3.9.3",
20
- "@vitessce/all": "3.9.3",
21
- "@vitessce/export-utils": "3.9.3",
22
- "@vitessce/config": "3.9.3"
19
+ "@vitessce/all": "3.9.5",
20
+ "@vitessce/config": "3.9.5",
21
+ "@vitessce/constants": "3.9.5",
22
+ "@vitessce/export-utils": "3.9.5"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@vitejs/plugin-react": "^4.5.0",