@vitessce/comparative 3.9.9 → 4.0.0-test.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/GeometryAndMeshXR-CX1Dr7Lp.js +137 -0
- package/dist/OrbitControls-4708Bo-O.js +7700 -0
- package/dist/{ReactNeuroglancer-DVTouLdy.js → ReactNeuroglancer-D7gl_oXM.js} +3458 -3457
- package/dist/XREnterButton-Dp2xhwJb.js +37 -0
- package/dist/XRSceneComponents-Cp8t3pvt.js +48 -0
- package/dist/XRWrapper-tyjCu0dQ.js +10 -0
- package/dist/{deflate-dpVUbWzG.js → deflate-sQAuGjEg.js} +1 -1
- package/dist/emulate-BRbJviQW.js +28295 -0
- package/dist/{higlass-DA6D2z7x.js → higlass-BTDczObM.js} +52945 -49808
- package/dist/index-CjBUb32k.js +57 -0
- package/dist/index-Cor41Qpl.js +7684 -0
- package/dist/{index-CtfYbkUc.js → index-Db7_bzrU.js} +190 -189
- package/dist/{index-D10X079V.js → index-d-ezrYVn.js} +72540 -72295
- package/dist/index.min.js +40 -39
- package/dist/{jpeg-B-udBgEy.js → jpeg-B8XmXhIa.js} +14 -14
- package/dist/{lerc-C__sKrTH.js → lerc-De9HQWG7.js} +1 -1
- package/dist/living_room-uy_CEYZC.js +11 -0
- package/dist/{lzw-CtJXYMNt.js → lzw-Bhsi2mhO.js} +10 -10
- package/dist/meeting_room-BjXC3fLc.js +11 -0
- package/dist/music_room-AFchga9Y.js +11 -0
- package/dist/office_large-qDeoZNBo.js +11 -0
- package/dist/office_small-B_PLvrYC.js +11 -0
- package/dist/packbits-D5ce5JVI.js +24 -0
- package/dist/raw-C1PbNQtJ.js +9 -0
- package/dist/ray-grab-BbmztB1N.js +3714 -0
- package/dist/{webimage-CXsNm_Gt.js → webimage-BoWu99dN.js} +1 -1
- package/dist/xrStore-BIllgY4M.js +10 -0
- package/dist-tsc/BiomarkerSelect.d.ts +1 -1
- package/dist-tsc/BiomarkerSelect.d.ts.map +1 -1
- package/dist-tsc/ComparativeConfig.d.ts +2 -2
- package/dist-tsc/ComparativeConfig.d.ts.map +1 -1
- package/dist-tsc/UncontrolledComparative.d.ts +1 -1
- package/dist-tsc/UncontrolledComparative.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/OrbitControls-CTwuQBHm.js +0 -6202
- package/dist/index-Cl09bGJd.js +0 -6178
- package/dist/packbits-DapYEvYC.js +0 -24
- package/dist/raw-DacX-0Ky.js +0 -9
- package/dist/troika-three-text.esm-CDlWralX.js +0 -4192
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { u as
|
|
4
|
-
|
|
1
|
+
import { jsxs as ne, jsx as F } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as M, useState as he, useMemo as fe, useEffect as $, Suspense as ze } from "react";
|
|
3
|
+
import { u as de, a as ke, O as ve, C as Ie } from "./OrbitControls-4708Bo-O.js";
|
|
4
|
+
import { l as n, i as De, c as le, D as me, R as Me, U as Ce, d as ge, e as Pe, f as Ae, N as ie, h as ce, V as C, j as _, k as Z, m as Be, C as P, W as Ne, n as Ue, S as Le, O as Oe, o as Fe, p as Ve, P as Ge, u as j, G as qe, q as Ze } from "./index-d-ezrYVn.js";
|
|
5
|
+
const S = 32, B = 64, G = 64, ue = 4, se = B * G * ue, xe = B * S, pe = G * S, be = ue * S, V = {
|
|
5
6
|
NOT_STARTED: "not_started",
|
|
6
7
|
IN_PROGRESS: "in_progress",
|
|
7
8
|
COMPLETE: "complete",
|
|
8
9
|
FAILED: "failed"
|
|
9
10
|
};
|
|
10
11
|
function z(f) {
|
|
11
|
-
|
|
12
|
+
le(ce.DEBUG) && console.warn(`%cDM: ${f}`, "background: blue; color: white; padding: 2px; border-radius: 3px;");
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
+
function Xe(f) {
|
|
14
15
|
return f.map((t) => {
|
|
15
16
|
const { dims: e } = t;
|
|
16
17
|
return [
|
|
@@ -25,7 +26,7 @@ function Ze(f) {
|
|
|
25
26
|
];
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
+
function je(f) {
|
|
29
30
|
return f.map((t) => {
|
|
30
31
|
const e = [
|
|
31
32
|
t.depth,
|
|
@@ -42,7 +43,7 @@ function Xe(f) {
|
|
|
42
43
|
];
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function Ye(f, t) {
|
|
46
47
|
n.debug("_initMRMCPT", f, t);
|
|
47
48
|
const e = {
|
|
48
49
|
channelOffsets: [
|
|
@@ -77,37 +78,37 @@ function je(f, t) {
|
|
|
77
78
|
e.zExtent
|
|
78
79
|
]), e.xExtent += f[u][2], e.yExtent += f[u][1], e.zExtent += f[u][0];
|
|
79
80
|
e.anchors.push([0, 0, e.zExtent]), e.anchors.reverse(), e.zTotal = e.zExtent + t * i;
|
|
80
|
-
const
|
|
81
|
-
|
|
81
|
+
const o = new Uint8Array(xe * pe * be);
|
|
82
|
+
o.fill(0);
|
|
82
83
|
const r = new Uint32Array(e.xExtent * e.yExtent * e.zTotal);
|
|
83
84
|
r.fill(0);
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
const l = new
|
|
87
|
-
return l.format =
|
|
85
|
+
const a = new me(o, xe, pe, be);
|
|
86
|
+
a.format = Me, a.type = Ce, a.internalFormat = "R8", a.minFilter = ge, a.magFilter = ge, a.generateMipmaps = !1, a.needsUpdate = !0;
|
|
87
|
+
const l = new me(r, e.xExtent, e.yExtent, e.zTotal);
|
|
88
|
+
return l.format = Pe, l.type = Ae, l.internalFormat = "R32UI", l.minFilter = ie, l.magFilter = ie, l.generateMipmaps = !1, l.needsUpdate = !0, n.debug("_initMRMCPT", e, l, a), {
|
|
88
89
|
PT: e,
|
|
89
90
|
ptTHREE: l,
|
|
90
|
-
bcTHREE:
|
|
91
|
+
bcTHREE: a
|
|
91
92
|
};
|
|
92
93
|
}
|
|
93
|
-
function
|
|
94
|
-
const r = (
|
|
95
|
-
return (1 << 31 | 1 << 30 | r(f) << 23 | r(t) << 16 | (e & 63) << 10 | (i & 63) << 4 |
|
|
94
|
+
function He(f, t, e, i, o) {
|
|
95
|
+
const r = (a) => Math.max(0, Math.min(127, Math.floor(a / 2)));
|
|
96
|
+
return (1 << 31 | 1 << 30 | r(f) << 23 | r(t) << 16 | (e & 63) << 10 | (i & 63) << 4 | o & 15) >>> 0;
|
|
96
97
|
}
|
|
97
|
-
function
|
|
98
|
-
const { PT_zExtent:
|
|
98
|
+
function Ke(f, t, e, i) {
|
|
99
|
+
const { PT_zExtent: o, PT_z0Extent: r, PT_anchors: a } = i;
|
|
99
100
|
let l = -1, u = -1, s = -1, v = -1, g = -1;
|
|
100
|
-
if (e >=
|
|
101
|
-
u = 0, s = f, v = t, g = (e -
|
|
101
|
+
if (e >= o)
|
|
102
|
+
u = 0, s = f, v = t, g = (e - o) % r, l = Math.floor((e - o) / r);
|
|
102
103
|
else
|
|
103
|
-
for (let c = 1; c <
|
|
104
|
-
if (!(f <
|
|
104
|
+
for (let c = 1; c < a.length; c++)
|
|
105
|
+
if (!(f < a[c][0] && t < a[c][1] && e < a[c][2])) {
|
|
105
106
|
u = c;
|
|
106
107
|
const d = [0, 0, 0];
|
|
107
|
-
f >=
|
|
108
|
+
f >= a[c][0] && (d[0] = 1), t >= a[c][1] && (d[1] = 1), e >= a[c][2] && (d[2] = 1);
|
|
108
109
|
const m = d[0] << 2 | d[1] << 1 | d[2];
|
|
109
110
|
l = Math.max(1, Math.min(7, m)) - 1;
|
|
110
|
-
const h = d.map((x, b) => x *
|
|
111
|
+
const h = d.map((x, b) => x * a[c][b]);
|
|
111
112
|
s = f - h[0], v = t - h[1], g = e - h[2];
|
|
112
113
|
break;
|
|
113
114
|
}
|
|
@@ -119,9 +120,9 @@ function He(f, t, e, i) {
|
|
|
119
120
|
z: g
|
|
120
121
|
};
|
|
121
122
|
}
|
|
122
|
-
const
|
|
123
|
-
function
|
|
124
|
-
const i = /* @__PURE__ */ new Map(), { width:
|
|
123
|
+
const We = 0.25;
|
|
124
|
+
function $e(f, t, e) {
|
|
125
|
+
const i = /* @__PURE__ */ new Map(), { width: o, height: r, sigmaNormalized: a } = e, l = Number.isInteger(o) && Number.isInteger(r) && o > 0 && r > 0 && typeof a == "number";
|
|
125
126
|
l || n.warn("_requestBufferToRequestObjects: proceeding without weighting");
|
|
126
127
|
const u = Math.floor(f.length / 4);
|
|
127
128
|
for (let v = 0; v < u; v += 1) {
|
|
@@ -131,7 +132,7 @@ function We(f, t, e) {
|
|
|
131
132
|
const x = (c << 24 | d << 16 | m << 8 | h) >>> 0;
|
|
132
133
|
let b = 1;
|
|
133
134
|
if (l) {
|
|
134
|
-
const R = v %
|
|
135
|
+
const R = v % o, E = Math.floor(v / o), k = R - o / 2, L = E - r / 2, T = Math.sqrt(k * k / (o * o) + L * L / (r * r)) / a;
|
|
135
136
|
b = Math.exp(-0.5 * T * T);
|
|
136
137
|
}
|
|
137
138
|
i.set(x, (i.get(x) || 0) + b);
|
|
@@ -142,17 +143,17 @@ function We(f, t, e) {
|
|
|
142
143
|
z: v & 4095
|
|
143
144
|
})), origRequestCount: i.size };
|
|
144
145
|
}
|
|
145
|
-
class
|
|
146
|
+
class Qe {
|
|
146
147
|
constructor(t) {
|
|
147
148
|
z("CLASS INITIALIZING"), n.debug("VolumeDataManager constructor", { glParam: t, glParamContext: t.getContext?.() });
|
|
148
149
|
const e = t.getContext?.() || t, i = t;
|
|
149
150
|
e.domElement && e.getContext ? this.gl = e.getContext() : e.isWebGLRenderer ? this.gl = e.getContext() : this.gl = e, this.renderer = i, (!this.gl || typeof this.gl.getParameter != "function") && (n.debug("Unable to get WebGL context, using mock context"), this.gl = {
|
|
150
|
-
getParameter: (
|
|
151
|
+
getParameter: (o) => ({
|
|
151
152
|
MAX_TEXTURE_SIZE: 4096,
|
|
152
153
|
MAX_3D_TEXTURE_SIZE: 256,
|
|
153
154
|
MAX_RENDERBUFFER_SIZE: 4096,
|
|
154
155
|
MAX_UNIFORM_BUFFER_BINDINGS: 16
|
|
155
|
-
})[
|
|
156
|
+
})[o] || 0,
|
|
156
157
|
isContextLost: () => !1,
|
|
157
158
|
MAX_TEXTURE_SIZE: "MAX_TEXTURE_SIZE",
|
|
158
159
|
MAX_3D_TEXTURE_SIZE: "MAX_3D_TEXTURE_SIZE",
|
|
@@ -221,7 +222,7 @@ class $e {
|
|
|
221
222
|
// l0 z extent
|
|
222
223
|
zTotal: 0
|
|
223
224
|
// original z extent plus the l0 z extent times the channel count
|
|
224
|
-
}, this.bricksEverLoaded = /* @__PURE__ */ new Set(), this.isBusy = !1, this.BCTimeStamps = new Array(
|
|
225
|
+
}, this.bricksEverLoaded = /* @__PURE__ */ new Set(), this.isBusy = !1, this.BCTimeStamps = new Array(se).fill(0), this.BCMinMax = new Array(se).fill([0, 0]), this.BCFull = !1, this.BCUnusedIndex = 0, this.bc2pt = new Array(se).fill(null), this.LRUStack = [], this.triggerUsage = !0, this.triggerRequest = !1, this.timeStamp = 0, this.k = 40, this.noNewRequests = !1, this.manuallyStopped = !1, this.needsBailout = !1, this.initStatus = V.NOT_STARTED, this.initError = null, this._lastChannelConfig = null, this.currentRequestCount = 0, this.totalBricksRequested = 0, z("VolumeDataManager constructor complete");
|
|
225
226
|
}
|
|
226
227
|
/**
|
|
227
228
|
* Get loading progress information
|
|
@@ -323,21 +324,21 @@ class $e {
|
|
|
323
324
|
const e = this.images?.[this.imageLayerScopes?.[0]]?.image?.instance;
|
|
324
325
|
if (this.ngffMetadata = e.vivLoader.metadata, n.debug("ngffMetadata", this.ngffMetadata), !e || e.getType() !== "ome-zarr")
|
|
325
326
|
throw new Error("Invalid imageWrapper or not an OME-Zarr image");
|
|
326
|
-
const i = e.getMultiResolutionStats(),
|
|
327
|
+
const i = e.getMultiResolutionStats(), o = Xe(i), r = i.length;
|
|
327
328
|
this.zarrStore.resolutions = r;
|
|
328
|
-
const
|
|
329
|
-
if (!Array.isArray(
|
|
329
|
+
const a = e.getData();
|
|
330
|
+
if (!Array.isArray(a) || a.length < 1)
|
|
330
331
|
throw new Error("Not a multiresolution loader");
|
|
331
|
-
if (!
|
|
332
|
+
if (!De(a[0].labels, ["t", "c", "z", "y", "x"]))
|
|
332
333
|
throw new Error("Expected OME-Zarr data with dimensions [t, c, z, y, x]");
|
|
333
|
-
n.debug("vivData",
|
|
334
|
-
const l =
|
|
334
|
+
n.debug("vivData", a);
|
|
335
|
+
const l = a.map((s) => s._data), u = new Array(r).fill(null);
|
|
335
336
|
if (l.length > 0) {
|
|
336
337
|
const s = l[0];
|
|
337
338
|
if (this.zarrStore = {
|
|
338
339
|
resolutions: r,
|
|
339
340
|
chunkSize: s.chunks,
|
|
340
|
-
shapes:
|
|
341
|
+
shapes: o,
|
|
341
342
|
arrays: l,
|
|
342
343
|
dtype: s.dtype,
|
|
343
344
|
physicalSizeTotal: [],
|
|
@@ -348,7 +349,7 @@ class $e {
|
|
|
348
349
|
// Calculate from shapes and chunk sizes
|
|
349
350
|
// store: this.store,
|
|
350
351
|
// group: this.group,
|
|
351
|
-
channelCount:
|
|
352
|
+
channelCount: o[0][1],
|
|
352
353
|
scales: u
|
|
353
354
|
}, this.channels.colorMappings = new Array(Math.min(this.zarrStore.channelCount, 7)).fill(-1), this.channels.zarrMappings = new Array(Math.min(this.zarrStore.channelCount, 7)).fill(void 0), this.channels.downsampleMin = new Array(Math.min(this.zarrStore.channelCount, 7)).fill(void 0), this.channels.downsampleMax = new Array(Math.min(this.zarrStore.channelCount, 7)).fill(void 0), s.meta && s.meta.physicalSizes) {
|
|
354
355
|
const { x: d, y: m, z: h } = s.meta.physicalSizes, x = h?.size || 1, b = m?.size || 1, R = d?.size || 1;
|
|
@@ -392,7 +393,7 @@ class $e {
|
|
|
392
393
|
]);
|
|
393
394
|
}
|
|
394
395
|
}
|
|
395
|
-
this.zarrStore.brickLayout =
|
|
396
|
+
this.zarrStore.brickLayout = je(e.getMultiResolutionStats()), n.debug("config", t);
|
|
396
397
|
const { omero: c } = this.ngffMetadata || {};
|
|
397
398
|
if (!c)
|
|
398
399
|
throw new Error("Expected omero metadata in ngffMetadata");
|
|
@@ -428,7 +429,7 @@ class $e {
|
|
|
428
429
|
*/
|
|
429
430
|
initMRMCPT() {
|
|
430
431
|
z("initMRMCPT");
|
|
431
|
-
const { PT: t, ptTHREE: e, bcTHREE: i } =
|
|
432
|
+
const { PT: t, ptTHREE: e, bcTHREE: i } = Ye(this.zarrStore.brickLayout, this.channels.zarrMappings.length);
|
|
432
433
|
this.PT = t, this.ptTHREE = e, this.bcTHREE = i, z("initMRMCPT() COMPLETE");
|
|
433
434
|
}
|
|
434
435
|
async initTexture() {
|
|
@@ -442,10 +443,10 @@ class $e {
|
|
|
442
443
|
n.debug("channels not initialized yet");
|
|
443
444
|
return;
|
|
444
445
|
}
|
|
445
|
-
const e = Object.values(t).map((l) => l.spatialTargetC).filter((l) => l !== void 0), i = this.channels.zarrMappings.filter((l) => l !== void 0),
|
|
446
|
-
|
|
446
|
+
const e = Object.values(t).map((l) => l.spatialTargetC).filter((l) => l !== void 0), i = this.channels.zarrMappings.filter((l) => l !== void 0), o = [...new Set(e)].sort((l, u) => l - u), r = [...new Set(i)].sort((l, u) => l - u);
|
|
447
|
+
o.length === r.length && o.every((l, u) => l === r[u]) && n.debug("Channel mappings unchanged, skipping update"), n.debug("Channel mappings changed:", {
|
|
447
448
|
current: r,
|
|
448
|
-
requested:
|
|
449
|
+
requested: o
|
|
449
450
|
}), Object.entries(t).forEach(([l, u]) => {
|
|
450
451
|
const s = u.spatialTargetC;
|
|
451
452
|
n.debug(`UI channel "${l}" wants zarr channel ${s}`);
|
|
@@ -470,13 +471,13 @@ class $e {
|
|
|
470
471
|
} else
|
|
471
472
|
n.debug(`Zarr channel ${s} already mapped to slot ${v}`);
|
|
472
473
|
});
|
|
473
|
-
const
|
|
474
|
+
const a = Object.values(t).map((l) => {
|
|
474
475
|
const u = this.channels.zarrMappings.indexOf(l.spatialTargetC);
|
|
475
476
|
return u !== -1 ? u : -1;
|
|
476
477
|
});
|
|
477
|
-
for (;
|
|
478
|
-
|
|
479
|
-
n.debug("newColorMappings",
|
|
478
|
+
for (; a.length < 7; )
|
|
479
|
+
a.push(-1);
|
|
480
|
+
n.debug("newColorMappings", a), this.channels.colorMappings = a, n.debug("updatedChannels", this.channels), this._lastChannelConfig = {
|
|
480
481
|
zarrMappings: [...this.channels.zarrMappings],
|
|
481
482
|
colorMappings: [...this.channels.colorMappings],
|
|
482
483
|
downsampleMin: [...this.channels.downsampleMin],
|
|
@@ -571,13 +572,13 @@ class $e {
|
|
|
571
572
|
* @param {number} resolution - Resolution level
|
|
572
573
|
* @returns {Promise<Uint8Array>} 32x32x32 chunk data
|
|
573
574
|
*/
|
|
574
|
-
async loadZarrChunk(t = 0, e = 0, i,
|
|
575
|
-
if (!this.zarrStore || !this.zarrStore.arrays[
|
|
575
|
+
async loadZarrChunk(t = 0, e = 0, i, o, r, a) {
|
|
576
|
+
if (!this.zarrStore || !this.zarrStore.arrays[a])
|
|
576
577
|
throw new Error("Zarr store or resolution not initialized");
|
|
577
|
-
n.debug("loadZarrChunk", { t, c: e, z: i, y:
|
|
578
|
-
const u = await this.zarrStore.arrays[
|
|
578
|
+
n.debug("loadZarrChunk", { t, c: e, z: i, y: o, x: r, resolution: a });
|
|
579
|
+
const u = await this.zarrStore.arrays[a].getChunk([t, e, i, o, r]);
|
|
579
580
|
if (!u)
|
|
580
|
-
throw new Error(`No chunk found at coordinates [${t},${e},${i},${
|
|
581
|
+
throw new Error(`No chunk found at coordinates [${t},${e},${i},${o},${r}]`);
|
|
581
582
|
if (u.data.length !== S * S * S)
|
|
582
583
|
throw new Error(`Unexpected chunk size: ${u.data.length}`);
|
|
583
584
|
return u.data;
|
|
@@ -608,8 +609,8 @@ class $e {
|
|
|
608
609
|
return;
|
|
609
610
|
}
|
|
610
611
|
this.isBusy = !0, this.triggerRequest = !1;
|
|
611
|
-
const { requests: i, origRequestCount:
|
|
612
|
-
i.length === 0 && (this.noNewRequests = !0), n.debug(`processRequestData: handling ${i.length} requests of ${
|
|
612
|
+
const { requests: i, origRequestCount: o } = $e(t, this.k, e);
|
|
613
|
+
i.length === 0 && (this.noNewRequests = !0), n.debug(`processRequestData: handling ${i.length} requests of ${o}`), await this.handleBrickRequests(i), this.triggerUsage = !0, this.isBusy = !1;
|
|
613
614
|
}
|
|
614
615
|
async processUsageData(t) {
|
|
615
616
|
if (this.isBusy) {
|
|
@@ -622,15 +623,15 @@ class $e {
|
|
|
622
623
|
}
|
|
623
624
|
this.isBusy = !0, this.triggerUsage = !1;
|
|
624
625
|
const e = ++this.timeStamp, i = /* @__PURE__ */ new Set();
|
|
625
|
-
for (let
|
|
626
|
-
const r = t[
|
|
627
|
-
if ((r |
|
|
626
|
+
for (let o = 0; o < t.length; o += 4) {
|
|
627
|
+
const r = t[o], a = t[o + 1], l = t[o + 2];
|
|
628
|
+
if ((r | a | l) === 0)
|
|
628
629
|
continue;
|
|
629
|
-
const u = l * B * G +
|
|
630
|
+
const u = l * B * G + a * B + r;
|
|
630
631
|
u < this.BCTimeStamps.length && i.add(u);
|
|
631
632
|
}
|
|
632
|
-
Array.from(i).forEach((
|
|
633
|
-
this.BCTimeStamps[
|
|
633
|
+
Array.from(i).forEach((o) => {
|
|
634
|
+
this.BCTimeStamps[o] = e;
|
|
634
635
|
}), this.BCFull && this._buildLRU(), this.triggerRequest = !0, this.isBusy = !1;
|
|
635
636
|
}
|
|
636
637
|
// Helper method to update PT entries for evicted bricks
|
|
@@ -638,7 +639,7 @@ class $e {
|
|
|
638
639
|
const e = this.bc2pt[t];
|
|
639
640
|
if (!e)
|
|
640
641
|
return;
|
|
641
|
-
const [i,
|
|
642
|
+
const [i, o] = this.BCMinMax[t] || [0, 0], r = (0 | 1 << 30 | Math.min(127, i >> 1) << 23 | Math.min(127, o >> 1) << 16) >>> 0;
|
|
642
643
|
this._updatePTEntry(e.x, e.y, e.z, r), this.bc2pt[t] = null;
|
|
643
644
|
}
|
|
644
645
|
_purgeChannel(t) {
|
|
@@ -653,30 +654,30 @@ class $e {
|
|
|
653
654
|
this.channels.downsampleMin[t] = void 0, this.channels.downsampleMax[t] = void 0, this.channels.zarrMappings[t] = void 0;
|
|
654
655
|
const e = this.PT.channelOffsets[t];
|
|
655
656
|
n.debug("channelMask", e), n.error("TODO: not tested yet");
|
|
656
|
-
const { gl: i } = this,
|
|
657
|
-
i.activeTexture(i.TEXTURE0), i.bindTexture(i.TEXTURE_3D,
|
|
657
|
+
const { gl: i } = this, o = this.renderer.properties.get(this.ptTHREE).__webglTexture;
|
|
658
|
+
i.activeTexture(i.TEXTURE0), i.bindTexture(i.TEXTURE_3D, o);
|
|
658
659
|
for (let r = 0; r < this.zarrStore.resolutions; r++) {
|
|
659
|
-
const
|
|
660
|
+
const a = [
|
|
660
661
|
this.PT.anchors[r][2] * e[2],
|
|
661
662
|
this.PT.anchors[r][1] * e[1],
|
|
662
663
|
this.PT.anchors[r][0] * e[0]
|
|
663
664
|
];
|
|
664
|
-
n.debug("anchor",
|
|
665
|
+
n.debug("anchor", a);
|
|
665
666
|
const l = this.zarrStore.brickLayout[r], u = l[0] * l[1] * l[2];
|
|
666
|
-
n.debug("extents", l), n.debug("size", u), i.texSubImage3D(i.TEXTURE_3D, 0,
|
|
667
|
+
n.debug("extents", l), n.debug("size", u), i.texSubImage3D(i.TEXTURE_3D, 0, a[0], a[1], a[2], l[0], l[1], l[2], i.RED_INTEGER, i.UNSIGNED_INT, new Uint32Array(u));
|
|
667
668
|
}
|
|
668
669
|
i.bindTexture(i.TEXTURE_3D, null);
|
|
669
670
|
}
|
|
670
671
|
// Update a PT entry
|
|
671
|
-
_updatePTEntry(t, e, i,
|
|
672
|
+
_updatePTEntry(t, e, i, o) {
|
|
672
673
|
if (!this.ptTHREE)
|
|
673
674
|
return;
|
|
674
675
|
if (this.isContextLost()) {
|
|
675
676
|
n.warn("WebGL context is lost, skipping PT entry update");
|
|
676
677
|
return;
|
|
677
678
|
}
|
|
678
|
-
const { gl: r } = this,
|
|
679
|
-
r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_3D,
|
|
679
|
+
const { gl: r } = this, a = this.renderer.properties.get(this.ptTHREE).__webglTexture;
|
|
680
|
+
r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_3D, a), r.texSubImage3D(r.TEXTURE_3D, 0, t, e, i, 1, 1, 1, r.RED_INTEGER, r.UNSIGNED_INT, new Uint32Array([o])), r.bindTexture(r.TEXTURE_3D, null);
|
|
680
681
|
}
|
|
681
682
|
/* ------------------------------------------------------------- *
|
|
682
683
|
* 2. Allocate the next n free bricks in the brick cache *
|
|
@@ -688,17 +689,17 @@ class $e {
|
|
|
688
689
|
*/
|
|
689
690
|
_allocateBCSlots(t) {
|
|
690
691
|
let e = [];
|
|
691
|
-
const i = B * G *
|
|
692
|
+
const i = B * G * ue;
|
|
692
693
|
if (!this.BCFull && this.BCUnusedIndex + t > i && (this.BCFull = !0, n.debug("BRICK CACHE FULL")), this.BCFull)
|
|
693
|
-
this.LRUStack.length < t && this._buildLRU(), e = this.LRUStack.splice(0, t).map((
|
|
694
|
-
this._evictBrick(
|
|
695
|
-
const r = Math.floor(
|
|
696
|
-
return { bcIndex:
|
|
694
|
+
this.LRUStack.length < t && this._buildLRU(), e = this.LRUStack.splice(0, t).map((o) => {
|
|
695
|
+
this._evictBrick(o);
|
|
696
|
+
const r = Math.floor(o / (B * G)), a = o - r * B * G, l = Math.floor(a / B), u = a % B;
|
|
697
|
+
return { bcIndex: o, x: u, y: l, z: r };
|
|
697
698
|
});
|
|
698
699
|
else {
|
|
699
|
-
for (let
|
|
700
|
-
const r = (this.BCUnusedIndex +
|
|
701
|
-
e.push({ bcIndex: r, x: s, y: u, z:
|
|
700
|
+
for (let o = 0; o < t; ++o) {
|
|
701
|
+
const r = (this.BCUnusedIndex + o) % i, a = Math.floor(r / (B * G)), l = r - a * B * G, u = Math.floor(l / B), s = l % B;
|
|
702
|
+
e.push({ bcIndex: r, x: s, y: u, z: a });
|
|
702
703
|
}
|
|
703
704
|
this.BCUnusedIndex += t;
|
|
704
705
|
}
|
|
@@ -716,7 +717,7 @@ class $e {
|
|
|
716
717
|
n.error("this.PT", this.PT), n.error("ptCoord out of bounds", t);
|
|
717
718
|
return;
|
|
718
719
|
}
|
|
719
|
-
const { channel: i, resolution:
|
|
720
|
+
const { channel: i, resolution: o, x: r, y: a, z: l } = Ke(t.x, t.y, t.z, { PT_zExtent: this.PT.zExtent, PT_z0Extent: this.PT.z0Extent, PT_anchors: this.PT.anchors });
|
|
720
721
|
if (!this.channels || !this.channels.zarrMappings || this.channels.zarrMappings.length === 0) {
|
|
721
722
|
n.error("Channel mappings not initialized, skipping brick upload");
|
|
722
723
|
return;
|
|
@@ -746,17 +747,17 @@ class $e {
|
|
|
746
747
|
n.error("No fallback channel config available, aborting brick upload");
|
|
747
748
|
return;
|
|
748
749
|
}
|
|
749
|
-
n.debug("starting to load zarr chunk", { resolution:
|
|
750
|
-
let s = await this.loadZarrChunk(0, u, l,
|
|
750
|
+
n.debug("starting to load zarr chunk", { resolution: o, z: l, y: a, x: r, zarrChannel: u });
|
|
751
|
+
let s = await this.loadZarrChunk(0, u, l, a, r, o);
|
|
751
752
|
if (n.debug("chunk", s), s instanceof Uint16Array) {
|
|
752
753
|
if (n.debug("chunk is Uint16Array, converting to Uint8Array"), this.channels.downsampleMin[i] === void 0) {
|
|
753
754
|
const T = this.channels.zarrMappings[i];
|
|
754
755
|
n.debug("channelId was not found in this.channels.downsampleMin[channel]", T), this.channels.downsampleMin[i] = this.ngffMetadata?.omero?.channels?.[T]?.window?.min || 0, this.channels.downsampleMax[i] = this.ngffMetadata?.omero?.channels?.[T]?.window?.max || 65535, n.debug("this.channels.downsampleMin[channel]", this.channels.downsampleMin[i]), n.debug("this.channels.downsampleMax[channel]", this.channels.downsampleMax[i]);
|
|
755
756
|
}
|
|
756
|
-
const R = new Uint16Array(s.buffer), E = new Uint8Array(s.length), k = this.channels.downsampleMin[i],
|
|
757
|
+
const R = new Uint16Array(s.buffer), E = new Uint8Array(s.length), k = this.channels.downsampleMin[i], L = this.channels.downsampleMax[i], X = L - k;
|
|
757
758
|
for (let T = 0; T < R.length; T++) {
|
|
758
|
-
const
|
|
759
|
-
E[T] = (
|
|
759
|
+
const U = R[T], N = Math.max(k, Math.min(L, U));
|
|
760
|
+
E[T] = (N - k) * 255 / X | 0;
|
|
760
761
|
}
|
|
761
762
|
s = E;
|
|
762
763
|
}
|
|
@@ -771,7 +772,7 @@ class $e {
|
|
|
771
772
|
c.activeTexture(c.TEXTURE2), c.bindTexture(c.TEXTURE_3D, d), c.pixelStorei(c.UNPACK_ALIGNMENT, 1), c.texSubImage3D(c.TEXTURE_3D, 0, e.x * S, e.y * S, e.z * S, S, S, S, c.RED, c.UNSIGNED_BYTE, s), c.pixelStorei(c.UNPACK_ALIGNMENT, 4), c.bindTexture(c.TEXTURE_3D, null);
|
|
772
773
|
const m = c.getError();
|
|
773
774
|
m !== c.NO_ERROR && n.error("WebGL error during brick upload:", m, s), i >= this.channels.zarrMappings.length && (n.debug("channel is out of bounds", i), v = 255, g = 255);
|
|
774
|
-
const h =
|
|
775
|
+
const h = He(v, g, e.x, e.y, e.z), x = this.renderer.properties.get(this.ptTHREE).__webglTexture;
|
|
775
776
|
c.activeTexture(c.TEXTURE0), c.bindTexture(c.TEXTURE_3D, x), c.texSubImage3D(c.TEXTURE_3D, 0, t.x, t.y, t.z, 1, 1, 1, c.RED_INTEGER, c.UNSIGNED_INT, new Uint32Array([h])), c.bindTexture(c.TEXTURE_3D, null);
|
|
776
777
|
const b = c.getError();
|
|
777
778
|
b !== c.NO_ERROR && n.error("WebGL error during pagetable upload:", b, s), this.BCTimeStamps[e.bcIndex] = this.timeStamp, this.BCMinMax[e.bcIndex] = [v, g], this.bc2pt[e.bcIndex] = t;
|
|
@@ -787,8 +788,8 @@ class $e {
|
|
|
787
788
|
n.debug("Handling brick requests:", { requestCount: t.length, slotCount: e.length }), n.debug("handleBrickRequests: starting for loop");
|
|
788
789
|
for (let i = 0; i < t.length; ++i) {
|
|
789
790
|
await this._uploadBrick(t[i], e[i]), this.currentRequestCount = t.length - i - 1;
|
|
790
|
-
const
|
|
791
|
-
if (this.bricksEverLoaded.add(`${t[i].x},${t[i].y},${t[i].z}`),
|
|
791
|
+
const o = this.bricksEverLoaded.size;
|
|
792
|
+
if (this.bricksEverLoaded.add(`${t[i].x},${t[i].y},${t[i].z}`), o === this.bricksEverLoaded.size && n.debug("DUPLICATE BRICK LOADED", t[i]), this.needsBailout) {
|
|
792
793
|
n.debug("Bailing out of handleBrickRequests early due to needsBailout flag"), this.needsBailout = !1, this.currentRequestCount = 0;
|
|
793
794
|
break;
|
|
794
795
|
}
|
|
@@ -803,7 +804,7 @@ class $e {
|
|
|
803
804
|
this.LRUStack = t.sort((e, i) => e.time - i.time).slice(0, this.k).map((e) => e.index);
|
|
804
805
|
}
|
|
805
806
|
}
|
|
806
|
-
const
|
|
807
|
+
const Je = `//
|
|
807
808
|
// Output: Unnormalized ray direction from camera to each vertex
|
|
808
809
|
// Used by fragment shader for ray marching through the volume
|
|
809
810
|
out vec3 rayDirUnnorm;
|
|
@@ -862,7 +863,7 @@ void main()
|
|
|
862
863
|
// Pass through texture coordinates for volume sampling
|
|
863
864
|
vUv = uv;
|
|
864
865
|
}
|
|
865
|
-
`,
|
|
866
|
+
`, et = `//
|
|
866
867
|
// #include <packing>
|
|
867
868
|
precision highp float;
|
|
868
869
|
precision highp int;
|
|
@@ -2427,7 +2428,7 @@ void main(void) {
|
|
|
2427
2428
|
outColor.a);
|
|
2428
2429
|
|
|
2429
2430
|
}
|
|
2430
|
-
`,
|
|
2431
|
+
`, tt = {
|
|
2431
2432
|
uniforms: {
|
|
2432
2433
|
u_size: { value: new C(1, 1, 1) },
|
|
2433
2434
|
clim0: { value: new _(0.2, 0.8) },
|
|
@@ -2495,16 +2496,16 @@ void main(void) {
|
|
|
2495
2496
|
scale8: { value: new C(256, 256, 256) },
|
|
2496
2497
|
scale9: { value: new C(512, 512, 512) }
|
|
2497
2498
|
},
|
|
2498
|
-
vertexShader:
|
|
2499
|
-
fragmentShader:
|
|
2499
|
+
vertexShader: Je,
|
|
2500
|
+
fragmentShader: et
|
|
2500
2501
|
};
|
|
2501
2502
|
function A(f) {
|
|
2502
|
-
|
|
2503
|
+
le(ce.DEBUG) && console.warn(`%cRM: ${f}`, "background: orange; color: white; padding: 2px; border-radius: 3px;");
|
|
2503
2504
|
}
|
|
2504
|
-
function
|
|
2505
|
+
function re(f, t) {
|
|
2505
2506
|
return f / t[1];
|
|
2506
2507
|
}
|
|
2507
|
-
class
|
|
2508
|
+
class nt {
|
|
2508
2509
|
constructor() {
|
|
2509
2510
|
A("Initializing VolumeRenderManager"), this.uniforms = null, this.shader = null, this.meshScale = [1, 1, 1], this.geometrySize = [1, 1, 1], this.boxSize = [1, 1, 1], this.zarrInit = !1, this.channelsVisible = [], this.channelTargetC = [], this.zarrStoreNumResolutions = null, this.channelMaxResolutionIndex = [], this.colors = [], this.contrastLimits = [], this.layerTransparency = 1, this.xSlice = new _(-1, 1e5), this.ySlice = new _(-1, 1e5), this.zSlice = new _(-1, 1e5), this.originalScale = [1, 1, 1], this.physicalDimensions = [1, 1, 1], this.maxResolution = [1, 1, 1], this.maxRange = 255, this.maxRangeSet = !1, this.initializeShader();
|
|
2510
2511
|
}
|
|
@@ -2512,7 +2513,7 @@ class tt {
|
|
|
2512
2513
|
* Initialize shader and uniform objects
|
|
2513
2514
|
*/
|
|
2514
2515
|
initializeShader() {
|
|
2515
|
-
A("Initializing shader"), this.shader =
|
|
2516
|
+
A("Initializing shader"), this.shader = tt, this.uniforms = Be.clone(this.shader.uniforms);
|
|
2516
2517
|
}
|
|
2517
2518
|
/**
|
|
2518
2519
|
* Extract rendering settings from coordination props
|
|
@@ -2520,52 +2521,52 @@ class tt {
|
|
|
2520
2521
|
* @returns {Object} Extracted rendering settings
|
|
2521
2522
|
*/
|
|
2522
2523
|
extractRenderingSettingsFromProps(t) {
|
|
2523
|
-
const { images: e = {}, imageLayerScopes: i = [], imageLayerCoordination:
|
|
2524
|
+
const { images: e = {}, imageLayerScopes: i = [], imageLayerCoordination: o = [{}], imageChannelScopesByLayer: r = {}, imageChannelCoordination: a = [{}], spatialRenderingMode: l } = t, u = i[0];
|
|
2524
2525
|
if (!u)
|
|
2525
2526
|
return A("Extracting rendering settings from props - no layer scope"), {
|
|
2526
2527
|
valid: !1
|
|
2527
2528
|
};
|
|
2528
|
-
const s = r[u], v =
|
|
2529
|
+
const s = r[u], v = o[0][u], g = a[0][u], c = e[u]?.image?.instance?.getData();
|
|
2529
2530
|
if (!c)
|
|
2530
2531
|
return A("Extracting rendering settings from props - no image data"), {
|
|
2531
2532
|
valid: !1
|
|
2532
2533
|
};
|
|
2533
|
-
if (!g[s?.[0]][
|
|
2534
|
+
if (!g[s?.[0]][P.SPATIAL_CHANNEL_WINDOW])
|
|
2534
2535
|
return A("Extracting rendering settings from props - no channel window set"), {
|
|
2535
2536
|
valid: !1
|
|
2536
2537
|
};
|
|
2537
|
-
const d = e[u].image.instance, m = l === "3D", h = v[
|
|
2538
|
+
const d = e[u].image.instance, m = l === "3D", h = v[P.PHOTOMETRIC_INTERPRETATION] === "RGB", x = v[P.SPATIAL_LAYER_VISIBLE], b = v[P.SPATIAL_LAYER_OPACITY], R = h ? [
|
|
2538
2539
|
[255, 0, 0],
|
|
2539
2540
|
[0, 255, 0],
|
|
2540
2541
|
[0, 0, 255]
|
|
2541
|
-
] : s.map((I) => g[I][
|
|
2542
|
+
] : s.map((I) => g[I][P.SPATIAL_CHANNEL_COLOR]), E = h ? [
|
|
2542
2543
|
[0, 255],
|
|
2543
2544
|
[0, 255],
|
|
2544
2545
|
[0, 255]
|
|
2545
|
-
] : s.map((I) => g[I][
|
|
2546
|
+
] : s.map((I) => g[I][P.SPATIAL_CHANNEL_WINDOW] || [0, 255]);
|
|
2546
2547
|
this.maxRangeSet || (this.maxRange = Math.max(...E.map((I) => I[1])), this.maxRangeSet = !0);
|
|
2547
2548
|
const k = h ? [
|
|
2548
2549
|
x && !0,
|
|
2549
2550
|
x && !0,
|
|
2550
2551
|
x && !0
|
|
2551
|
-
] : s.map((I) => x && g[I][
|
|
2552
|
+
] : s.map((I) => x && g[I][P.SPATIAL_CHANNEL_VISIBLE]), L = h ? [
|
|
2552
2553
|
x && !0,
|
|
2553
2554
|
x && !0,
|
|
2554
2555
|
x && !0
|
|
2555
|
-
] : s.map((I) => x && d.getChannelIndex(g[I][
|
|
2556
|
+
] : s.map((I) => x && d.getChannelIndex(g[I][P.SPATIAL_TARGET_C])), X = h ? [
|
|
2556
2557
|
x && null,
|
|
2557
2558
|
x && null,
|
|
2558
2559
|
x && null
|
|
2559
|
-
] : s.map((I) => g[I][
|
|
2560
|
-
let T = v[
|
|
2561
|
-
const Y = v[
|
|
2562
|
-
T = T !== null ? T : new _(-1, 1e5),
|
|
2563
|
-
const
|
|
2560
|
+
] : s.map((I) => g[I][P.SPATIAL_MAX_RESOLUTION]);
|
|
2561
|
+
let T = v[P.SPATIAL_SLICE_X], U = v[P.SPATIAL_SLICE_Y], N = v[P.SPATIAL_SLICE_Z];
|
|
2562
|
+
const Y = v[P.SPATIAL_LOD_FACTOR] ?? 1;
|
|
2563
|
+
T = T !== null ? T : new _(-1, 1e5), U = U !== null ? U : new _(-1, 1e5), N = N !== null ? N : new _(-1, 1e5);
|
|
2564
|
+
const oe = e[u].image.loaders[0].channels;
|
|
2564
2565
|
return A("Extracting rendering settings from props - success"), {
|
|
2565
2566
|
valid: !0,
|
|
2566
2567
|
channelsVisible: k,
|
|
2567
|
-
allChannels:
|
|
2568
|
-
channelTargetC:
|
|
2568
|
+
allChannels: oe,
|
|
2569
|
+
channelTargetC: L,
|
|
2569
2570
|
channelMaxResolutionIndex: X,
|
|
2570
2571
|
data: c,
|
|
2571
2572
|
colors: R,
|
|
@@ -2573,8 +2574,8 @@ class tt {
|
|
|
2573
2574
|
is3dMode: m,
|
|
2574
2575
|
layerTransparency: b,
|
|
2575
2576
|
xSlice: T,
|
|
2576
|
-
ySlice:
|
|
2577
|
-
zSlice:
|
|
2577
|
+
ySlice: U,
|
|
2578
|
+
zSlice: N,
|
|
2578
2579
|
lodFactor: Y
|
|
2579
2580
|
};
|
|
2580
2581
|
}
|
|
@@ -2592,7 +2593,7 @@ class tt {
|
|
|
2592
2593
|
* @param {object} volumeDataManagerProps - Params derived from the volume data manager
|
|
2593
2594
|
* @returns {Object|null} Updated rendering settings or null if rendering is not possible
|
|
2594
2595
|
*/
|
|
2595
|
-
updateRendering({ zarrStoreShapes: t, originalScaleXYZ: e, physicalDimensionsXYZ: i, maxResolutionXYZ:
|
|
2596
|
+
updateRendering({ zarrStoreShapes: t, originalScaleXYZ: e, physicalDimensionsXYZ: i, maxResolutionXYZ: o, boxDimensionsXYZ: r, normalizedScaleXYZ: a, bcTHREE: l, ptTHREE: u }) {
|
|
2596
2597
|
if (A("Updating rendering"), this.channelTargetC.findIndex((m, h) => this.channelsVisible[h]), !Array.isArray(t) || t.length === 0)
|
|
2597
2598
|
return null;
|
|
2598
2599
|
const s = t[0], v = {
|
|
@@ -2610,17 +2611,17 @@ class tt {
|
|
|
2610
2611
|
this.colors[h][2] / 255,
|
|
2611
2612
|
this.channelsVisible[h] ? 1 : 0
|
|
2612
2613
|
]), n.debug("colorsSave", c), this.contrastLimits[h][0] === 0 && this.contrastLimits[h][1] === 255 ? d.push([
|
|
2613
|
-
|
|
2614
|
-
|
|
2614
|
+
re(b[0], b),
|
|
2615
|
+
re(b[1], b)
|
|
2615
2616
|
]) : d.push([
|
|
2616
|
-
|
|
2617
|
-
|
|
2617
|
+
re(this.contrastLimits[h][0], b),
|
|
2618
|
+
re(this.contrastLimits[h][1], b)
|
|
2618
2619
|
]);
|
|
2619
2620
|
}
|
|
2620
2621
|
}), !this.zarrInit) {
|
|
2621
|
-
this.originalScale = e, this.physicalDimensions = i, this.maxResolution =
|
|
2622
|
+
this.originalScale = e, this.physicalDimensions = i, this.maxResolution = o;
|
|
2622
2623
|
const m = r;
|
|
2623
|
-
this.normalizedScale =
|
|
2624
|
+
this.normalizedScale = a, this.meshScale = [
|
|
2624
2625
|
this.originalScale[0] / this.originalScale[0],
|
|
2625
2626
|
this.originalScale[1] / this.originalScale[0],
|
|
2626
2627
|
this.originalScale[2] / this.originalScale[0]
|
|
@@ -2659,8 +2660,8 @@ class tt {
|
|
|
2659
2660
|
* @param {Vector2} ySlice - Y clipping plane
|
|
2660
2661
|
* @param {Vector2} zSlice - Z clipping plane
|
|
2661
2662
|
*/
|
|
2662
|
-
updateUniforms(t, e, i,
|
|
2663
|
-
A("Updating uniforms"), this.uniforms.boxSize.value.set(this.boxSize[0], this.boxSize[1], this.boxSize[2]), this.uniforms.brickCacheTex.value = v, this.uniforms.pageTableTex.value = g, this.uniforms.near.value = 0.1, this.uniforms.far.value = 3e3, this.uniforms.opacity.value =
|
|
2663
|
+
updateUniforms(t, e, i, o, r, a, l, u, s, v, g) {
|
|
2664
|
+
A("Updating uniforms"), this.uniforms.boxSize.value.set(this.boxSize[0], this.boxSize[1], this.boxSize[2]), this.uniforms.brickCacheTex.value = v, this.uniforms.pageTableTex.value = g, this.uniforms.near.value = 0.1, this.uniforms.far.value = 3e3, this.uniforms.opacity.value = a, this.uniforms.volumeCount.value = t.length, this.uniforms.u_size.value.set(e.xLength, e.yLength, e.zLength), this.uniforms.u_window_size.value.set(0, 0), this.uniforms.u_vol_scale.value.set(1 / e.xLength, 1 / e.yLength, 1 / e.zLength * 2), this.uniforms.clim0.value.set(o.length > 0 ? o[0][0] : null, o.length > 0 ? o[0][1] : null), this.uniforms.clim1.value.set(o.length > 1 ? o[1][0] : null, o.length > 1 ? o[1][1] : null), this.uniforms.clim2.value.set(o.length > 2 ? o[2][0] : null, o.length > 2 ? o[2][1] : null), this.uniforms.clim3.value.set(o.length > 3 ? o[3][0] : null, o.length > 3 ? o[3][1] : null), this.uniforms.clim4.value.set(o.length > 4 ? o[4][0] : null, o.length > 4 ? o[4][1] : null), this.uniforms.clim5.value.set(o.length > 5 ? o[5][0] : null, o.length > 5 ? o[5][1] : null), this.uniforms.clim6.value.set(o.length > 6 ? o[6][0] : null, o.length > 6 ? o[6][1] : null), this.uniforms.xClip.value.set(l[0] * (1 / this.maxResolution[0]) * this.boxSize[0], l[1] * (1 / this.maxResolution[0]) * this.boxSize[0]), this.uniforms.yClip.value.set(u[0] * (1 / this.maxResolution[1]) * this.boxSize[1], u[1] * (1 / this.maxResolution[1]) * this.boxSize[1]), this.uniforms.zClip.value.set(s[0] * (1 / this.maxResolution[2]) * this.boxSize[2], s[1] * (1 / this.maxResolution[2]) * this.boxSize[2]), this.uniforms.color0.value.set(r.length > 0 ? r[0][0] : null, r.length > 0 ? r[0][1] : null, r.length > 0 ? r[0][2] : null, r.length > 0 ? r[0][3] : null), this.uniforms.color1.value.set(r.length > 1 ? r[1][0] : null, r.length > 1 ? r[1][1] : null, r.length > 1 ? r[1][2] : null, r.length > 1 ? r[1][3] : null), this.uniforms.color2.value.set(r.length > 2 ? r[2][0] : null, r.length > 2 ? r[2][1] : null, r.length > 2 ? r[2][2] : null, r.length > 2 ? r[2][3] : null), this.uniforms.color3.value.set(r.length > 3 ? r[3][0] : null, r.length > 3 ? r[3][1] : null, r.length > 3 ? r[3][2] : null, r.length > 3 ? r[3][3] : null), this.uniforms.color4.value.set(r.length > 4 ? r[4][0] : null, r.length > 4 ? r[4][1] : null, r.length > 4 ? r[4][2] : null, r.length > 4 ? r[4][3] : null), this.uniforms.color5.value.set(r.length > 5 ? r[5][0] : null, r.length > 5 ? r[5][1] : null, r.length > 5 ? r[5][2] : null, r.length > 5 ? r[5][3] : null), this.uniforms.color6.value.set(r.length > 6 ? r[6][0] : null, r.length > 6 ? r[6][1] : null, r.length > 6 ? r[6][2] : null, r.length > 6 ? r[6][3] : null);
|
|
2664
2665
|
for (let c = 0; c < 7; c++)
|
|
2665
2666
|
typeof this.channelMaxResolutionIndex[c] == "number" && this.uniforms[`res${c}`].value.set(Math.max(1, this.channelMaxResolutionIndex[c]), this.zarrStoreNumResolutions - 1);
|
|
2666
2667
|
}
|
|
@@ -2693,13 +2694,13 @@ class tt {
|
|
|
2693
2694
|
this.uniforms.resGlobal.value.set(1, t.brickLayout.length - 1), this.uniforms.voxelExtents.value.set(t.shapes[0][4], t.shapes[0][3], t.shapes[0][2]), this.uniforms.maxChannels.value = Math.min(t.channelCount, 7), n.debug("this.channelsVisible", this.channelsVisible), n.debug("zarrStore.shapes[0]", t.shapes[0]), n.debug("PT", e), n.debug("uniforms", this.uniforms);
|
|
2694
2695
|
}
|
|
2695
2696
|
}
|
|
2696
|
-
const
|
|
2697
|
+
const rt = `//
|
|
2697
2698
|
varying vec2 vUv;
|
|
2698
2699
|
void main() {
|
|
2699
2700
|
vUv = uv;
|
|
2700
2701
|
gl_Position = vec4(position, 1.0);
|
|
2701
2702
|
}
|
|
2702
|
-
`,
|
|
2703
|
+
`, it = `//
|
|
2703
2704
|
// Input texture to blur
|
|
2704
2705
|
uniform sampler2D tDiffuse;
|
|
2705
2706
|
// Resolution of the texture (width, height)
|
|
@@ -2885,40 +2886,40 @@ void main() {
|
|
|
2885
2886
|
gl_FragColor = color;
|
|
2886
2887
|
}
|
|
2887
2888
|
`;
|
|
2888
|
-
function
|
|
2889
|
+
function _e(f, t) {
|
|
2889
2890
|
const e = f.properties?.get(t);
|
|
2890
2891
|
return e?.framebuffer || e?.__webglFramebuffer || t.__webglFramebuffer;
|
|
2891
2892
|
}
|
|
2892
2893
|
function Q(f) {
|
|
2893
|
-
|
|
2894
|
+
le(ce.DEBUG) && console.warn(`%cV: ${f}`, "background: deeppink; color: white; padding: 2px; border-radius: 3px;");
|
|
2894
2895
|
}
|
|
2895
|
-
function
|
|
2896
|
+
function ot(f, t, e, { mrtRef: i }) {
|
|
2896
2897
|
f.setRenderTarget(i.current), f.clear(!0, !0, !0), f.render(e, t);
|
|
2897
2898
|
}
|
|
2898
2899
|
function at(f, { screenSceneRef: t, screenCameraRef: e }) {
|
|
2899
2900
|
f.setRenderTarget(null), f.clear(!0, !0, !0), f.render(t.current, e.current);
|
|
2900
2901
|
}
|
|
2901
|
-
function
|
|
2902
|
-
const
|
|
2903
|
-
e.noNewRequests === !0 && !e.manuallyStopped && l % 100 === 0 && l < 500 && (e.noNewRequests = !1), e.triggerRequest === !0 && e.noNewRequests === !1 ? (
|
|
2902
|
+
function st(f, { frameRef: t, dataManager: e, mrtRef: i, bufRequest: o, bufUsage: r }) {
|
|
2903
|
+
const a = f.getContext(), l = t.current;
|
|
2904
|
+
e.noNewRequests === !0 && !e.manuallyStopped && l % 100 === 0 && l < 500 && (e.noNewRequests = !1), e.triggerRequest === !0 && e.noNewRequests === !1 ? (a.bindFramebuffer(a.READ_FRAMEBUFFER, _e(f, i.current)), a.readBuffer(a.COLOR_ATTACHMENT1), a.readPixels(0, 0, i.current.width, i.current.height, a.RGBA, a.UNSIGNED_BYTE, o.current), e.processRequestData(o.current, {
|
|
2904
2905
|
// If width/height are not yet available,
|
|
2905
2906
|
// processRequestData will proceed without weighting.
|
|
2906
2907
|
width: i?.current?.width,
|
|
2907
2908
|
height: i?.current?.height,
|
|
2908
2909
|
// Default sigmaNormalized = 0.25; can be tuned
|
|
2909
|
-
sigmaNormalized:
|
|
2910
|
-
})) : e.triggerUsage === !0 && e.noNewRequests === !1 && (
|
|
2910
|
+
sigmaNormalized: We
|
|
2911
|
+
})) : e.triggerUsage === !0 && e.noNewRequests === !1 && (a.bindFramebuffer(a.READ_FRAMEBUFFER, _e(f, i.current)), a.readBuffer(a.COLOR_ATTACHMENT2), a.readPixels(0, 0, i.current.width, i.current.height, a.RGBA, a.UNSIGNED_BYTE, r.current), e.processUsageData(r.current));
|
|
2911
2912
|
}
|
|
2912
|
-
function
|
|
2913
|
-
const { invalidate: e, isInteracting: i, dataManager:
|
|
2913
|
+
function lt(f, t) {
|
|
2914
|
+
const { invalidate: e, isInteracting: i, dataManager: o, spatialRenderingModeChanging: r, meshRef: a, stillRef: l, screenQuadRef: u, lastSampleRef: s, frameRef: v, lastFrameCountRef: g } = t;
|
|
2914
2915
|
if (u.current && (l.current ? u.current.material.uniforms.gaussian.value = 0 : u.current.material.uniforms.gaussian.value = 7), i) {
|
|
2915
|
-
|
|
2916
|
+
o.manuallyStopped || (o.noNewRequests = !1, o.triggerUsage = !0);
|
|
2916
2917
|
return;
|
|
2917
2918
|
}
|
|
2918
2919
|
if (r)
|
|
2919
2920
|
return;
|
|
2920
|
-
const c =
|
|
2921
|
-
if (
|
|
2921
|
+
const c = a.current?.material?.uniforms, d = c?.renderRes?.value ?? o?.PT?.lowestDataRes;
|
|
2922
|
+
if (o.noNewRequests) {
|
|
2922
2923
|
d !== 0 ? (c && (c.renderRes.value = 0), n.debug("Adaptive Quality: No new requests. Setting renderSpeed to 0 (best quality)."), l.current = !1, u.current.material.uniforms.gaussian.value = 7, e()) : l.current || (n.debug("Adaptive Quality: No new requests and already at best quality. Setting stillRef to true."), l.current = !0, u.current.material.uniforms.gaussian.value = 0);
|
|
2923
2924
|
return;
|
|
2924
2925
|
}
|
|
@@ -2929,58 +2930,58 @@ function st(f, t) {
|
|
|
2929
2930
|
const h = m - s.current, x = v.current - g.current;
|
|
2930
2931
|
let b = 0;
|
|
2931
2932
|
h > 0 && (b = x / h), s.current = m, g.current = v.current;
|
|
2932
|
-
const R = b > 100 && d > 0, E = b < 30 && d <
|
|
2933
|
+
const R = b > 100 && d > 0, E = b < 30 && d < o.PT.lowestDataRes;
|
|
2933
2934
|
if (R || E) {
|
|
2934
2935
|
const k = d + (E ? 1 : -1);
|
|
2935
2936
|
c && (c.renderRes.value = k), e();
|
|
2936
2937
|
}
|
|
2937
2938
|
}
|
|
2938
|
-
function
|
|
2939
|
+
function ct(f) {
|
|
2939
2940
|
const {
|
|
2940
2941
|
images: t,
|
|
2941
2942
|
imageLayerScopes: e,
|
|
2942
2943
|
imageLayerCoordination: i,
|
|
2943
|
-
imageChannelScopesByLayer:
|
|
2944
|
+
imageChannelScopesByLayer: o,
|
|
2944
2945
|
imageChannelCoordination: r,
|
|
2945
2946
|
// onInitComplete,
|
|
2946
|
-
spatialRenderingMode:
|
|
2947
|
+
spatialRenderingMode: a,
|
|
2947
2948
|
spatialRenderingModeChanging: l,
|
|
2948
2949
|
onVolumeLoadingUpdate: u
|
|
2949
2950
|
} = f, {
|
|
2950
2951
|
gl: s
|
|
2951
2952
|
// scene,
|
|
2952
2953
|
// camera
|
|
2953
|
-
} =
|
|
2954
|
+
} = de(), v = de((y) => y.invalidate), g = M(null), c = M(null), d = M(null), m = M(null), h = M(null), [x, b] = he({
|
|
2954
2955
|
uniforms: null,
|
|
2955
2956
|
shader: null,
|
|
2956
2957
|
meshScale: [1, 1, 1],
|
|
2957
2958
|
geometrySize: [1, 1, 1]
|
|
2958
|
-
}), R =
|
|
2959
|
+
}), R = a === "3D", E = M(null), k = M(null), L = M(null), [X, T] = he(!1), U = M(null), N = M(!1), Y = M(0), oe = M(0), I = M(0), p = fe(() => new Qe(s), [s]), w = fe(() => new nt(), []);
|
|
2959
2960
|
$(() => {
|
|
2960
2961
|
Q("useEffect MRT target matching canvas");
|
|
2961
|
-
const { width: y, height: D } = s.domElement, q = new
|
|
2962
|
+
const { width: y, height: D } = s.domElement, q = new Ne(y, D, 3);
|
|
2962
2963
|
q.texture.forEach((W) => {
|
|
2963
|
-
W.format =
|
|
2964
|
+
W.format = Ue, W.type = Ce, W.minFilter = ie, W.magFilter = ie, W.generateMipmaps = !1;
|
|
2964
2965
|
});
|
|
2965
|
-
const
|
|
2966
|
+
const O = new Le(), ee = new Oe(-1, 1, 1, -1, 0.1, 10);
|
|
2966
2967
|
ee.position.z = 1;
|
|
2967
|
-
const te = new
|
|
2968
|
+
const te = new Fe({
|
|
2968
2969
|
uniforms: {
|
|
2969
2970
|
// Bind the first render target texture as the input of the gaussian blur shader.
|
|
2970
2971
|
tDiffuse: { value: q.texture[0] },
|
|
2971
2972
|
resolution: { value: new _(y, D) },
|
|
2972
2973
|
gaussian: { value: 7 }
|
|
2973
2974
|
},
|
|
2974
|
-
vertexShader:
|
|
2975
|
-
fragmentShader:
|
|
2975
|
+
vertexShader: rt,
|
|
2976
|
+
fragmentShader: it,
|
|
2976
2977
|
transparent: !0
|
|
2977
|
-
}), K = new
|
|
2978
|
-
return
|
|
2978
|
+
}), K = new Ve(new Ge(2, 2), te);
|
|
2979
|
+
return O.add(K), E.current = O, k.current = ee, L.current = K, d.current = new Uint8Array(y * D * 4), m.current = new Uint8Array(y * D * 4), h.current = q, () => {
|
|
2979
2980
|
q.dispose(), te.dispose(), K.geometry.dispose();
|
|
2980
2981
|
};
|
|
2981
2982
|
}, [s]);
|
|
2982
|
-
const ae = e?.[0],
|
|
2983
|
-
|
|
2983
|
+
const ae = e?.[0], Re = t?.[ae];
|
|
2984
|
+
o?.[ae];
|
|
2984
2985
|
const J = r?.[0]?.[ae];
|
|
2985
2986
|
$(() => {
|
|
2986
2987
|
Q("useEffect INIT");
|
|
@@ -2989,7 +2990,7 @@ function lt(f) {
|
|
|
2989
2990
|
n.debug("dataManager or renderManager not initialized yet");
|
|
2990
2991
|
return;
|
|
2991
2992
|
}
|
|
2992
|
-
if (!
|
|
2993
|
+
if (!Re) {
|
|
2993
2994
|
n.debug("no first image layer yet");
|
|
2994
2995
|
return;
|
|
2995
2996
|
}
|
|
@@ -3011,20 +3012,20 @@ function lt(f) {
|
|
|
3011
3012
|
y = !0;
|
|
3012
3013
|
};
|
|
3013
3014
|
}, [p, w, t, e]), $(() => {
|
|
3014
|
-
if (
|
|
3015
|
+
if (a === "3D" && p && w) {
|
|
3015
3016
|
Q("useEffect spatialRenderingMode");
|
|
3016
3017
|
const D = {
|
|
3017
3018
|
images: t,
|
|
3018
3019
|
imageLayerScopes: e,
|
|
3019
3020
|
imageLayerCoordination: i,
|
|
3020
|
-
imageChannelScopesByLayer:
|
|
3021
|
+
imageChannelScopesByLayer: o,
|
|
3021
3022
|
imageChannelCoordination: r,
|
|
3022
|
-
spatialRenderingMode:
|
|
3023
|
+
spatialRenderingMode: a
|
|
3023
3024
|
};
|
|
3024
3025
|
if (w.updateFromProps(D)) {
|
|
3025
3026
|
const { zarrInit: q } = w;
|
|
3026
3027
|
q || (p.ptTHREE.needsUpdate = !1, p.bcTHREE.needsUpdate = !1, p.renderer.initTexture(p.bcTHREE), p.renderer.initTexture(p.ptTHREE), p.initTexture());
|
|
3027
|
-
const
|
|
3028
|
+
const O = w.updateRendering({
|
|
3028
3029
|
zarrStoreShapes: p.zarrStore.shapes,
|
|
3029
3030
|
originalScaleXYZ: p.getOriginalScaleXYZ(),
|
|
3030
3031
|
physicalDimensionsXYZ: p.getPhysicalDimensionsXYZ(),
|
|
@@ -3034,22 +3035,22 @@ function lt(f) {
|
|
|
3034
3035
|
bcTHREE: p.bcTHREE,
|
|
3035
3036
|
ptTHREE: p.ptTHREE
|
|
3036
3037
|
});
|
|
3037
|
-
|
|
3038
|
+
O && b(O);
|
|
3038
3039
|
}
|
|
3039
3040
|
}
|
|
3040
|
-
}, [p, w, t, e, i,
|
|
3041
|
+
}, [p, w, t, e, i, o, r, a]), ke((y, D, q) => {
|
|
3041
3042
|
if (!h.current || !p || !w || !x.shader)
|
|
3042
3043
|
return;
|
|
3043
|
-
const { gl:
|
|
3044
|
-
|
|
3044
|
+
const { gl: O, camera: ee, scene: te, clock: K } = y;
|
|
3045
|
+
N.current || ot(O, ee, te, { mrtRef: h }), at(O, { screenSceneRef: E, screenCameraRef: k }), st(O, { frameRef: Y, dataManager: p, mrtRef: h, bufRequest: d, bufUsage: m }), lt(K, {
|
|
3045
3046
|
invalidate: v,
|
|
3046
3047
|
isInteracting: X,
|
|
3047
3048
|
dataManager: p,
|
|
3048
3049
|
spatialRenderingModeChanging: l,
|
|
3049
3050
|
meshRef: c,
|
|
3050
|
-
stillRef:
|
|
3051
|
-
screenQuadRef:
|
|
3052
|
-
lastSampleRef:
|
|
3051
|
+
stillRef: N,
|
|
3052
|
+
screenQuadRef: L,
|
|
3053
|
+
lastSampleRef: oe,
|
|
3053
3054
|
frameRef: Y,
|
|
3054
3055
|
lastFrameCountRef: I
|
|
3055
3056
|
}), Y.current += 1;
|
|
@@ -3057,50 +3058,50 @@ function lt(f) {
|
|
|
3057
3058
|
const H = j((y) => {
|
|
3058
3059
|
if (Q("invalidateOnInteraction callback"), T(y), y) {
|
|
3059
3060
|
const D = c.current?.material?.uniforms;
|
|
3060
|
-
D && (D.renderRes.value = p.PT.lowestDataRes),
|
|
3061
|
+
D && (D.renderRes.value = p.PT.lowestDataRes), N.current = !1, v();
|
|
3061
3062
|
}
|
|
3062
|
-
}), Re = j((y) => {
|
|
3063
|
-
H(!0);
|
|
3064
3063
|
}), ye = j((y) => {
|
|
3065
|
-
|
|
3064
|
+
H(!0);
|
|
3065
|
+
}), Ee = j((y) => {
|
|
3066
|
+
clearTimeout(U.current), U.current = setTimeout(() => {
|
|
3066
3067
|
H(!1);
|
|
3067
3068
|
}, 300);
|
|
3068
3069
|
});
|
|
3069
3070
|
$(() => {
|
|
3070
|
-
Q("useEffect firstImageLayerChannelCoordination"), H(!0), n.debug("something about channels changed"), p.updateChannels(J), w.setChannelMapping(p.channels.colorMappings), clearTimeout(
|
|
3071
|
+
Q("useEffect firstImageLayerChannelCoordination"), H(!0), n.debug("something about channels changed"), p.updateChannels(J), w.setChannelMapping(p.channels.colorMappings), clearTimeout(U.current), U.current = setTimeout(() => {
|
|
3071
3072
|
H(!1);
|
|
3072
3073
|
}, 300);
|
|
3073
3074
|
}, [p, J, w, H]);
|
|
3074
|
-
const
|
|
3075
|
+
const Te = j(() => {
|
|
3075
3076
|
p && p.stopLoading();
|
|
3076
|
-
}),
|
|
3077
|
+
}), Se = j(() => {
|
|
3077
3078
|
p && p.restartLoading();
|
|
3078
|
-
}),
|
|
3079
|
+
}), we = j(() => p ? p.getLoadingProgress() : null);
|
|
3079
3080
|
return $(() => {
|
|
3080
3081
|
if (!u)
|
|
3081
3082
|
return;
|
|
3082
3083
|
const y = setInterval(() => {
|
|
3083
|
-
const D =
|
|
3084
|
+
const D = we();
|
|
3084
3085
|
u({
|
|
3085
3086
|
loadingProgress: D,
|
|
3086
|
-
stillRef:
|
|
3087
|
-
onStopLoading:
|
|
3088
|
-
onRestartLoading:
|
|
3087
|
+
stillRef: N,
|
|
3088
|
+
onStopLoading: Te,
|
|
3089
|
+
onRestartLoading: Se
|
|
3089
3090
|
});
|
|
3090
3091
|
}, 1e3);
|
|
3091
3092
|
return () => clearInterval(y);
|
|
3092
|
-
}, [u,
|
|
3093
|
-
|
|
3093
|
+
}, [u, N]), !R || !p || !w ? null : x.shader ? ne("group", { children: [F(
|
|
3094
|
+
ve,
|
|
3094
3095
|
{
|
|
3095
3096
|
// ref={mainOrbitControlsRef}
|
|
3096
3097
|
enableDamping: !1,
|
|
3097
|
-
onStart:
|
|
3098
|
-
onEnd:
|
|
3098
|
+
onStart: ye,
|
|
3099
|
+
onEnd: Ee
|
|
3099
3100
|
}
|
|
3100
|
-
),
|
|
3101
|
+
), ne("mesh", { ref: c, scale: x.meshScale, children: [F("boxGeometry", { args: x.geometrySize }), F("shaderMaterial", { uniforms: x.uniforms, vertexShader: x.shader.vertexShader, fragmentShader: x.shader.fragmentShader, side: Ze, transparent: !1, glslVersion: qe })] })] }) : ne("group", { children: [ne("mesh", { children: [F("boxGeometry", { args: [1, 1, 1] }), F("meshBasicMaterial", { color: "#444", wireframe: !0 })] }), F(ve, { ref: g })] });
|
|
3101
3102
|
}
|
|
3102
|
-
function
|
|
3103
|
-
return
|
|
3103
|
+
function mt(f) {
|
|
3104
|
+
return F(Ie, { frameloop: "always", style: {
|
|
3104
3105
|
position: "absolute",
|
|
3105
3106
|
top: 0,
|
|
3106
3107
|
left: 0,
|
|
@@ -3120,8 +3121,8 @@ function dt(f) {
|
|
|
3120
3121
|
logarithmicDepthBuffer: !1,
|
|
3121
3122
|
preserveDrawingBuffer: !1,
|
|
3122
3123
|
autoClear: !1
|
|
3123
|
-
}, children:
|
|
3124
|
+
}, children: F(ze, { fallback: "Initializing Volume View...", children: F(ct, { ...f }) }) });
|
|
3124
3125
|
}
|
|
3125
3126
|
export {
|
|
3126
|
-
|
|
3127
|
+
mt as SpatialWrapper
|
|
3127
3128
|
};
|