@vitessce/gl 3.2.0 → 3.2.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.
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-68f84e2a.js";
2
- import { B as BaseDecoder } from "./index-2a7f1ae0.js";
2
+ import { B as BaseDecoder } from "./index-7bac69ff.js";
3
3
  import "react";
4
4
  class DeflateDecoder extends BaseDecoder {
5
5
  decodeBlock(buffer) {
@@ -103903,16 +103903,16 @@ async function getDecoder(fileDirectory) {
103903
103903
  const Decoder = await importFn();
103904
103904
  return new Decoder(fileDirectory);
103905
103905
  }
103906
- addDecoder([void 0, 1], () => import("./raw-b0ec4406.js").then((m) => m.default));
103907
- addDecoder(5, () => import("./lzw-8d3691e0.js").then((m) => m.default));
103906
+ addDecoder([void 0, 1], () => import("./raw-7701dc0d.js").then((m) => m.default));
103907
+ addDecoder(5, () => import("./lzw-e748554e.js").then((m) => m.default));
103908
103908
  addDecoder(6, () => {
103909
103909
  throw new Error("old style JPEG compression is not supported.");
103910
103910
  });
103911
- addDecoder(7, () => import("./jpeg-95f78026.js").then((m) => m.default));
103912
- addDecoder([8, 32946], () => import("./deflate-69c280fb.js").then((m) => m.default));
103913
- addDecoder(32773, () => import("./packbits-2846ed6b.js").then((m) => m.default));
103914
- addDecoder(34887, () => import("./lerc-5320d7fa.js").then((m) => m.default));
103915
- addDecoder(50001, () => import("./webimage-a17e81f9.js").then((m) => m.default));
103911
+ addDecoder(7, () => import("./jpeg-d84c376b.js").then((m) => m.default));
103912
+ addDecoder([8, 32946], () => import("./deflate-2292d6bb.js").then((m) => m.default));
103913
+ addDecoder(32773, () => import("./packbits-17d3eaf3.js").then((m) => m.default));
103914
+ addDecoder(34887, () => import("./lerc-abfff89b.js").then((m) => m.default));
103915
+ addDecoder(50001, () => import("./webimage-6b6fefe4.js").then((m) => m.default));
103916
103916
  function copyNewSize(array2, width, height, samplesPerPixel = 1) {
103917
103917
  return new (Object.getPrototypeOf(array2)).constructor(width * height * samplesPerPixel);
103918
103918
  }
@@ -118398,6 +118398,67 @@ function makeBoundingBox(viewState) {
118398
118398
  viewport.unproject([0, viewport.height])
118399
118399
  ];
118400
118400
  }
118401
+ const TARGETS = [1, 2, 3, 4, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1e3];
118402
+ const MIN_TARGET = TARGETS[0];
118403
+ const MAX_TARGET = TARGETS[TARGETS.length - 1];
118404
+ const SI_PREFIXES = [
118405
+ { symbol: "Y", exponent: 24 },
118406
+ { symbol: "Z", exponent: 21 },
118407
+ { symbol: "E", exponent: 18 },
118408
+ { symbol: "P", exponent: 15 },
118409
+ { symbol: "T", exponent: 12 },
118410
+ { symbol: "G", exponent: 9 },
118411
+ { symbol: "M", exponent: 6 },
118412
+ { symbol: "k", exponent: 3 },
118413
+ { symbol: "h", exponent: 2 },
118414
+ { symbol: "da", exponent: 1 },
118415
+ { symbol: "", exponent: 0 },
118416
+ { symbol: "d", exponent: -1 },
118417
+ { symbol: "c", exponent: -2 },
118418
+ { symbol: "m", exponent: -3 },
118419
+ { symbol: "µ", exponent: -6 },
118420
+ { symbol: "n", exponent: -9 },
118421
+ { symbol: "p", exponent: -12 },
118422
+ { symbol: "f", exponent: -15 },
118423
+ { symbol: "a", exponent: -18 },
118424
+ { symbol: "z", exponent: -21 },
118425
+ { symbol: "y", exponent: -24 }
118426
+ ];
118427
+ function sizeToMeters(size, unit) {
118428
+ if (!unit || unit === "m") {
118429
+ return size;
118430
+ }
118431
+ if (unit.length > 1) {
118432
+ let unitPrefix = unit.substring(0, unit.length - 1);
118433
+ if (unitPrefix === "u") {
118434
+ unitPrefix = "µ";
118435
+ }
118436
+ const unitObj = SI_PREFIXES.find((p) => p.symbol === unitPrefix);
118437
+ if (unitObj) {
118438
+ return size * 10 ** unitObj.exponent;
118439
+ }
118440
+ }
118441
+ throw new Error("Received unknown unit");
118442
+ }
118443
+ function snapValue(value) {
118444
+ let magnitude = 0;
118445
+ if (value < MIN_TARGET || value > MAX_TARGET) {
118446
+ magnitude = Math.floor(Math.log10(value));
118447
+ }
118448
+ let snappedUnit = SI_PREFIXES.find(
118449
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude
118450
+ );
118451
+ let adjustedValue = value / 10 ** snappedUnit.exponent;
118452
+ if (adjustedValue > 500 && adjustedValue <= 1e3) {
118453
+ snappedUnit = SI_PREFIXES.find(
118454
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude + 3
118455
+ );
118456
+ adjustedValue = value / 10 ** snappedUnit.exponent;
118457
+ }
118458
+ const targetNewUnits = TARGETS.find((t2) => t2 > adjustedValue);
118459
+ const targetOrigUnits = targetNewUnits * 10 ** snappedUnit.exponent;
118460
+ return [targetOrigUnits, targetNewUnits, snappedUnit.symbol];
118461
+ }
118401
118462
  const fs$1$1 = `#define SHADER_NAME xr-layer-fragment-shader
118402
118463
 
118403
118464
  precision highp float;
@@ -119165,26 +119226,27 @@ const OverviewLayer = class extends CompositeLayer {
119165
119226
  OverviewLayer.layerName = "OverviewLayer";
119166
119227
  OverviewLayer.defaultProps = defaultProps$3;
119167
119228
  function getPosition(boundingBox, position, length2) {
119168
- const viewLength = boundingBox[2][0] - boundingBox[0][0];
119229
+ const viewWidth = boundingBox[2][0] - boundingBox[0][0];
119230
+ const viewHeight = boundingBox[2][1] - boundingBox[0][1];
119169
119231
  switch (position) {
119170
119232
  case "bottom-right": {
119171
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
119172
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
119233
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
119234
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
119173
119235
  return [yCoord, xLeftCoord];
119174
119236
  }
119175
119237
  case "top-right": {
119176
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
119177
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
119238
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
119239
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
119178
119240
  return [yCoord, xLeftCoord];
119179
119241
  }
119180
119242
  case "top-left": {
119181
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
119182
- const xLeftCoord = viewLength * length2;
119243
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
119244
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
119183
119245
  return [yCoord, xLeftCoord];
119184
119246
  }
119185
119247
  case "bottom-left": {
119186
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
119187
- const xLeftCoord = viewLength * length2;
119248
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
119249
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
119188
119250
  return [yCoord, xLeftCoord];
119189
119251
  }
119190
119252
  default: {
@@ -119202,11 +119264,12 @@ const defaultProps$2 = {
119202
119264
  unit: { type: "string", value: "", compare: true },
119203
119265
  size: { type: "number", value: 1, compare: true },
119204
119266
  position: { type: "string", value: "bottom-right", compare: true },
119205
- length: { type: "number", value: 0.085, compare: true }
119267
+ length: { type: "number", value: 0.085, compare: true },
119268
+ snap: { type: "boolean", value: false, compare: true }
119206
119269
  };
119207
119270
  const ScaleBarLayer = class extends CompositeLayer {
119208
119271
  renderLayers() {
119209
- const { id, unit, size, position, viewState, length: length2 } = this.props;
119272
+ const { id, unit, size, position, viewState, length: length2, snap } = this.props;
119210
119273
  const boundingBox = makeBoundingBox(viewState);
119211
119274
  const { zoom } = viewState;
119212
119275
  const viewLength = boundingBox[2][0] - boundingBox[0][0];
@@ -119215,15 +119278,27 @@ const ScaleBarLayer = class extends CompositeLayer {
119215
119278
  2 ** (-zoom + 1.5),
119216
119279
  (boundingBox[2][1] - boundingBox[0][1]) * 7e-3
119217
119280
  );
119218
- const numUnits = barLength * size;
119281
+ let adjustedBarLength = barLength;
119282
+ let displayNumber = (barLength * size).toPrecision(5);
119283
+ let displayUnit = unit;
119284
+ if (snap) {
119285
+ const meterSize = sizeToMeters(size, unit);
119286
+ const numUnits = barLength * meterSize;
119287
+ const [snappedOrigUnits, snappedNewUnits, snappedUnitPrefix] = snapValue(numUnits);
119288
+ adjustedBarLength = snappedOrigUnits / meterSize;
119289
+ displayNumber = snappedNewUnits;
119290
+ displayUnit = `${snappedUnitPrefix}m`;
119291
+ }
119219
119292
  const [yCoord, xLeftCoord] = getPosition(boundingBox, position, length2);
119293
+ const xRightCoord = xLeftCoord + barLength;
119294
+ const isLeft = position.endsWith("-left");
119220
119295
  const lengthBar = new LineLayer({
119221
119296
  id: `scale-bar-length-${id}`,
119222
119297
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
119223
119298
  data: [
119224
119299
  [
119225
- [xLeftCoord, yCoord],
119226
- [xLeftCoord + barLength, yCoord]
119300
+ [isLeft ? xLeftCoord : xRightCoord - adjustedBarLength, yCoord],
119301
+ [isLeft ? xLeftCoord + adjustedBarLength : xRightCoord, yCoord]
119227
119302
  ]
119228
119303
  ],
119229
119304
  getSourcePosition: (d) => d[0],
@@ -119236,8 +119311,14 @@ const ScaleBarLayer = class extends CompositeLayer {
119236
119311
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
119237
119312
  data: [
119238
119313
  [
119239
- [xLeftCoord, yCoord - barHeight],
119240
- [xLeftCoord, yCoord + barHeight]
119314
+ [
119315
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
119316
+ yCoord - barHeight
119317
+ ],
119318
+ [
119319
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
119320
+ yCoord + barHeight
119321
+ ]
119241
119322
  ]
119242
119323
  ],
119243
119324
  getSourcePosition: (d) => d[0],
@@ -119250,8 +119331,14 @@ const ScaleBarLayer = class extends CompositeLayer {
119250
119331
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
119251
119332
  data: [
119252
119333
  [
119253
- [xLeftCoord + barLength, yCoord - barHeight],
119254
- [xLeftCoord + barLength, yCoord + barHeight]
119334
+ [
119335
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
119336
+ yCoord - barHeight
119337
+ ],
119338
+ [
119339
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
119340
+ yCoord + barHeight
119341
+ ]
119255
119342
  ]
119256
119343
  ],
119257
119344
  getSourcePosition: (d) => d[0],
@@ -119264,8 +119351,11 @@ const ScaleBarLayer = class extends CompositeLayer {
119264
119351
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
119265
119352
  data: [
119266
119353
  {
119267
- text: numUnits.toPrecision(5) + unit,
119268
- position: [xLeftCoord + barLength * 0.5, yCoord + barHeight * 4]
119354
+ text: `${displayNumber}${displayUnit}`,
119355
+ position: [
119356
+ isLeft ? xLeftCoord + barLength * 0.5 : xRightCoord - barLength * 0.5,
119357
+ yCoord + barHeight * 4
119358
+ ]
119269
119359
  }
119270
119360
  ],
119271
119361
  getColor: [220, 220, 220, 255],
@@ -119274,7 +119364,7 @@ const ScaleBarLayer = class extends CompositeLayer {
119274
119364
  sizeUnits: "meters",
119275
119365
  sizeScale: 2 ** -zoom,
119276
119366
  characterSet: [
119277
- ...unit.split(""),
119367
+ ...displayUnit.split(""),
119278
119368
  ...range$3(10).map((i2) => String(i2)),
119279
119369
  ".",
119280
119370
  "e",
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { f as distEs6 } from "./index-2a7f1ae0.js";
2
- import { o, n, A, r, q, p, i, j, C, l, D, G, e, H, c, M, k, m, d, P, S, h, T, t, b, s, v } from "./index-2a7f1ae0.js";
1
+ import { f as distEs6 } from "./index-7bac69ff.js";
2
+ import { o, n, A, r, q, p, i, j, C, l, D, G, e, H, c, M, k, m, d, P, S, h, T, t, b, s, v } from "./index-7bac69ff.js";
3
3
  import "react";
4
4
  const SELECTION_TYPE = distEs6.SELECTION_TYPE;
5
5
  export {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-2a7f1ae0.js";
1
+ import { B as BaseDecoder } from "./index-7bac69ff.js";
2
2
  import "react";
3
3
  const dctZigZag = new Int32Array([
4
4
  0,
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-68f84e2a.js";
2
- import { g as getDefaultExportFromCjs, B as BaseDecoder, L as LercParameters, a as LercAddCompression } from "./index-2a7f1ae0.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder, L as LercParameters, a as LercAddCompression } from "./index-7bac69ff.js";
3
3
  import "react";
4
4
  var LercDecode = { exports: {} };
5
5
  (function(module) {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-2a7f1ae0.js";
1
+ import { B as BaseDecoder } from "./index-7bac69ff.js";
2
2
  import "react";
3
3
  const MIN_BITS = 9;
4
4
  const CLEAR_CODE = 256;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-2a7f1ae0.js";
1
+ import { B as BaseDecoder } from "./index-7bac69ff.js";
2
2
  import "react";
3
3
  class PackbitsDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-2a7f1ae0.js";
1
+ import { B as BaseDecoder } from "./index-7bac69ff.js";
2
2
  import "react";
3
3
  class RawDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-2a7f1ae0.js";
1
+ import { B as BaseDecoder } from "./index-7bac69ff.js";
2
2
  import "react";
3
3
  class WebImageDecoder extends BaseDecoder {
4
4
  constructor() {
@@ -1,4 +1,4 @@
1
- declare const BitmaskLayer_base: new (...props: import(".pnpm/@vivjs+types@0.13.7/node_modules/@vivjs/types").Viv<{
1
+ declare const BitmaskLayer_base: new (...props: import(".pnpm/@vivjs+types@0.13.8/node_modules/@vivjs/types").Viv<{
2
2
  contrastLimits: number[][];
3
3
  channelsVisible: boolean[];
4
4
  dtype: string;
@@ -1,4 +1,4 @@
1
- declare const BitmaskLayer_base: new (...props: import(".pnpm/@vivjs+types@0.13.7/node_modules/@vivjs/types").Viv<{
1
+ declare const BitmaskLayer_base: new (...props: import(".pnpm/@vivjs+types@0.13.8/node_modules/@vivjs/types").Viv<{
2
2
  contrastLimits: number[][];
3
3
  channelsVisible: boolean[];
4
4
  dtype: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/gl",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -23,7 +23,7 @@
23
23
  "@deck.gl/layers": "~8.8.6",
24
24
  "@deck.gl/mesh-layers": "~8.8.6",
25
25
  "@deck.gl/react": "~8.8.6",
26
- "@hms-dbmi/viv": "~0.13.7",
26
+ "@hms-dbmi/viv": "~0.13.8",
27
27
  "@loaders.gl/3d-tiles": "^3.0.0",
28
28
  "@loaders.gl/core": "^3.0.0",
29
29
  "@loaders.gl/images": "^3.0.0",
@@ -52,7 +52,7 @@
52
52
  "mathjs": "^9.2.0",
53
53
  "nebula.gl": "0.23.8",
54
54
  "d3-array": "^2.4.0",
55
- "@vitessce/utils": "3.2.0"
55
+ "@vitessce/utils": "3.2.2"
56
56
  },
57
57
  "devDependencies": {
58
58
  "glsl-colormap": "^1.0.1"