vitessce 3.9.4 → 3.9.6
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/{OrbitControls-_G9SyWG8.js → OrbitControls-gS0qAcAF.js} +1 -1
- package/dist/{ReactNeuroglancer-oMVeF9IH.js → ReactNeuroglancer-BUfn_iuv.js} +1 -1
- package/dist/{deflate-S9ZrYKMF.js → deflate-_PAyjIxQ.js} +1 -1
- package/dist/{higlass-BcoiRNsc.js → higlass-DKNFlOLu.js} +1 -1
- package/dist/{index-BqtRS06t.js → index-BMZKt_WD.js} +353 -326
- package/dist/{index-Cbd0exMF.js → index-CApj7rdC.js} +3 -3
- package/dist/{index-BLW9mi8V.js → index-CiwyZ_Wn.js} +61323 -60841
- package/dist/index.min.js +1 -1
- package/dist/{jpeg-EMOhexje.js → jpeg-D6QGAYrj.js} +1 -1
- package/dist/{lerc-CY4UFPrc.js → lerc-CpU83gFy.js} +1 -1
- package/dist/{lzw-CkU3Ript.js → lzw-IDKOxNdH.js} +1 -1
- package/dist/{packbits-DtV7dNq0.js → packbits-Dj8eDgHa.js} +1 -1
- package/dist/{raw-DZrieydT.js → raw-BBDtkWgc.js} +1 -1
- package/dist/{troika-three-text.esm-DyWGyi4J.js → troika-three-text.esm-DtEcqwS6.js} +1 -1
- package/dist/{webimage-B4ukY9Yr.js → webimage-zvGex_8D.js} +1 -1
- package/package.json +7 -7
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { aw as n, ax as we, ay as se, ar as ue, as as ze, az as _e, l as he, aA as ke, aB as Ie, m as re, aC as le, e as C, V as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { u as ve, a as Ge, O as me, C as qe } from "./OrbitControls-
|
|
4
|
-
const S = 32,
|
|
1
|
+
import { aw as n, ax as we, ay as se, ar as ue, as as ze, az as _e, l as he, aA as ke, aB as Ie, m as re, aC as le, e as C, V as _, ag as Z, ae as De, aq as M, aD as Me, aE as Pe, av as Ae, W as Be, ad as Ne, z as Ue, aF as Le, aG as j, ao as N, aH as Oe, am as Fe } from "./index-CiwyZ_Wn.js";
|
|
2
|
+
import { useRef as P, useState as fe, useMemo as de, useEffect as $, Suspense as Ve } from "react";
|
|
3
|
+
import { u as ve, a as Ge, O as me, C as qe } from "./OrbitControls-gS0qAcAF.js";
|
|
4
|
+
const S = 32, B = 64, G = 64, ce = 4, oe = B * G * ce, ge = B * S, xe = G * S, pe = ce * S, V = {
|
|
5
5
|
NOT_STARTED: "not_started",
|
|
6
6
|
IN_PROGRESS: "in_progress",
|
|
7
7
|
COMPLETE: "complete",
|
|
8
8
|
FAILED: "failed"
|
|
9
9
|
};
|
|
10
|
-
function z(
|
|
11
|
-
se(le.DEBUG) && console.warn(`%cDM: ${
|
|
10
|
+
function z(f) {
|
|
11
|
+
se(le.DEBUG) && console.warn(`%cDM: ${f}`, "background: blue; color: white; padding: 2px; border-radius: 3px;");
|
|
12
12
|
}
|
|
13
|
-
function Ze(
|
|
14
|
-
return
|
|
13
|
+
function Ze(f) {
|
|
14
|
+
return f.map((t) => {
|
|
15
15
|
const { dims: e } = t;
|
|
16
16
|
return [
|
|
17
17
|
// Other spatial-accelerated code assumes TCZYX dimension order
|
|
@@ -25,8 +25,8 @@ function Ze(h) {
|
|
|
25
25
|
];
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
function Xe(
|
|
29
|
-
return
|
|
28
|
+
function Xe(f) {
|
|
29
|
+
return f.map((t) => {
|
|
30
30
|
const e = [
|
|
31
31
|
t.depth,
|
|
32
32
|
// z
|
|
@@ -42,8 +42,8 @@ function Xe(h) {
|
|
|
42
42
|
];
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
function je(
|
|
46
|
-
n.debug("_initMRMCPT",
|
|
45
|
+
function je(f, t) {
|
|
46
|
+
n.debug("_initMRMCPT", f, t);
|
|
47
47
|
const e = {
|
|
48
48
|
channelOffsets: [
|
|
49
49
|
[0, 0, 1],
|
|
@@ -68,14 +68,14 @@ function je(h, t) {
|
|
|
68
68
|
// original z extent plus the l0 z extent times the channel count
|
|
69
69
|
};
|
|
70
70
|
e.xExtent = 1, e.yExtent = 1, e.zExtent = 1;
|
|
71
|
-
const i =
|
|
72
|
-
e.z0Extent = i, e.lowestDataRes =
|
|
73
|
-
for (let
|
|
71
|
+
const i = f[0][0];
|
|
72
|
+
e.z0Extent = i, e.lowestDataRes = f.length - 1;
|
|
73
|
+
for (let u = f.length - 1; u > 0; u--)
|
|
74
74
|
e.anchors.push([
|
|
75
75
|
e.xExtent,
|
|
76
76
|
e.yExtent,
|
|
77
77
|
e.zExtent
|
|
78
|
-
]), e.xExtent +=
|
|
78
|
+
]), e.xExtent += f[u][2], e.yExtent += f[u][1], e.zExtent += f[u][0];
|
|
79
79
|
e.anchors.push([0, 0, e.zExtent]), e.anchors.reverse(), e.zTotal = e.zExtent + t * i;
|
|
80
80
|
const a = new Uint8Array(ge * xe * pe);
|
|
81
81
|
a.fill(0);
|
|
@@ -90,51 +90,59 @@ function je(h, t) {
|
|
|
90
90
|
bcTHREE: o
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
function Ye(
|
|
93
|
+
function Ye(f, t, e, i, a) {
|
|
94
94
|
const r = (o) => Math.max(0, Math.min(127, Math.floor(o / 2)));
|
|
95
|
-
return (1 << 31 | 1 << 30 | r(
|
|
95
|
+
return (1 << 31 | 1 << 30 | r(f) << 23 | r(t) << 16 | (e & 63) << 10 | (i & 63) << 4 | a & 15) >>> 0;
|
|
96
96
|
}
|
|
97
|
-
function He(
|
|
97
|
+
function He(f, t, e, i) {
|
|
98
98
|
const { PT_zExtent: a, PT_z0Extent: r, PT_anchors: o } = i;
|
|
99
|
-
let l = -1,
|
|
99
|
+
let l = -1, u = -1, s = -1, v = -1, g = -1;
|
|
100
100
|
if (e >= a)
|
|
101
|
-
|
|
101
|
+
u = 0, s = f, v = t, g = (e - a) % r, l = Math.floor((e - a) / r);
|
|
102
102
|
else
|
|
103
|
-
for (let
|
|
104
|
-
if (!(
|
|
105
|
-
|
|
103
|
+
for (let c = 1; c < o.length; c++)
|
|
104
|
+
if (!(f < o[c][0] && t < o[c][1] && e < o[c][2])) {
|
|
105
|
+
u = c;
|
|
106
106
|
const d = [0, 0, 0];
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
l = Math.max(1, Math.min(7,
|
|
110
|
-
const
|
|
111
|
-
s =
|
|
107
|
+
f >= o[c][0] && (d[0] = 1), t >= o[c][1] && (d[1] = 1), e >= o[c][2] && (d[2] = 1);
|
|
108
|
+
const m = d[0] << 2 | d[1] << 1 | d[2];
|
|
109
|
+
l = Math.max(1, Math.min(7, m)) - 1;
|
|
110
|
+
const h = d.map((x, b) => x * o[c][b]);
|
|
111
|
+
s = f - h[0], v = t - h[1], g = e - h[2];
|
|
112
112
|
break;
|
|
113
113
|
}
|
|
114
114
|
return {
|
|
115
115
|
channel: l,
|
|
116
|
-
resolution:
|
|
116
|
+
resolution: u,
|
|
117
117
|
x: s,
|
|
118
|
-
y:
|
|
119
|
-
z:
|
|
118
|
+
y: v,
|
|
119
|
+
z: g
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
const Ke = 0.25;
|
|
123
|
+
function We(f, t, e) {
|
|
124
|
+
const i = /* @__PURE__ */ new Map(), { width: a, height: r, sigmaNormalized: o } = e, l = Number.isInteger(a) && Number.isInteger(r) && a > 0 && r > 0 && typeof o == "number";
|
|
125
|
+
l || n.warn("_requestBufferToRequestObjects: proceeding without weighting");
|
|
126
|
+
const u = Math.floor(f.length / 4);
|
|
127
|
+
for (let v = 0; v < u; v += 1) {
|
|
128
|
+
const g = v * 4, c = f[g], d = f[g + 1], m = f[g + 2], h = f[g + 3];
|
|
129
|
+
if ((c | d | m | h) === 0)
|
|
127
130
|
continue;
|
|
128
|
-
const
|
|
129
|
-
|
|
131
|
+
const x = (c << 24 | d << 16 | m << 8 | h) >>> 0;
|
|
132
|
+
let b = 1;
|
|
133
|
+
if (l) {
|
|
134
|
+
const R = v % a, E = Math.floor(v / a), k = R - a / 2, O = E - r / 2, T = Math.sqrt(k * k / (a * a) + O * O / (r * r)) / o;
|
|
135
|
+
b = Math.exp(-0.5 * T * T);
|
|
136
|
+
}
|
|
137
|
+
i.set(x, (i.get(x) || 0) + b);
|
|
130
138
|
}
|
|
131
|
-
return { requests: [...
|
|
132
|
-
x:
|
|
133
|
-
y:
|
|
134
|
-
z:
|
|
135
|
-
})), origRequestCount:
|
|
139
|
+
return { requests: [...i.entries()].sort((v, g) => g[1] - v[1]).slice(0, t).map(([v]) => ({
|
|
140
|
+
x: v >> 22 & 1023,
|
|
141
|
+
y: v >> 12 & 1023,
|
|
142
|
+
z: v & 4095
|
|
143
|
+
})), origRequestCount: i.size };
|
|
136
144
|
}
|
|
137
|
-
class
|
|
145
|
+
class $e {
|
|
138
146
|
constructor(t) {
|
|
139
147
|
z("CLASS INITIALIZING"), n.debug("VolumeDataManager constructor", { glParam: t, glParamContext: t.getContext?.() });
|
|
140
148
|
const e = t.getContext?.() || t, i = t;
|
|
@@ -213,7 +221,7 @@ class We {
|
|
|
213
221
|
// l0 z extent
|
|
214
222
|
zTotal: 0
|
|
215
223
|
// original z extent plus the l0 z extent times the channel count
|
|
216
|
-
}, this.bricksEverLoaded = /* @__PURE__ */ new Set(), this.isBusy = !1, this.BCTimeStamps = new Array(oe).fill(0), this.BCMinMax = new Array(oe).fill([0, 0]), this.BCFull = !1, this.BCUnusedIndex = 0, this.bc2pt = new Array(oe).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 =
|
|
224
|
+
}, this.bricksEverLoaded = /* @__PURE__ */ new Set(), this.isBusy = !1, this.BCTimeStamps = new Array(oe).fill(0), this.BCMinMax = new Array(oe).fill([0, 0]), this.BCFull = !1, this.BCUnusedIndex = 0, this.bc2pt = new Array(oe).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");
|
|
217
225
|
}
|
|
218
226
|
/**
|
|
219
227
|
* Get loading progress information
|
|
@@ -293,8 +301,8 @@ class We {
|
|
|
293
301
|
* @returns {Promise<Object>} Object with Zarr store details and device limits
|
|
294
302
|
*/
|
|
295
303
|
async init(t) {
|
|
296
|
-
if (z("INIT()"), this.initStatus !==
|
|
297
|
-
return n.debug("VolumeDataManager init() was called more than once!"), this.initStatus ===
|
|
304
|
+
if (z("INIT()"), this.initStatus !== V.NOT_STARTED)
|
|
305
|
+
return n.debug("VolumeDataManager init() was called more than once!"), this.initStatus === V.COMPLETE ? {
|
|
298
306
|
success: !0,
|
|
299
307
|
deviceLimits: this.deviceLimits,
|
|
300
308
|
zarrStore: this.zarrStore,
|
|
@@ -302,7 +310,7 @@ class We {
|
|
|
302
310
|
physicalSizeTotal: this.zarrStore.physicalSizeTotal,
|
|
303
311
|
physicalSizeVoxel: this.zarrStore.physicalSizeVoxel,
|
|
304
312
|
error: null
|
|
305
|
-
} : this.initStatus ===
|
|
313
|
+
} : this.initStatus === V.FAILED ? {
|
|
306
314
|
success: !1,
|
|
307
315
|
error: this.initError || "Unknown initialization error"
|
|
308
316
|
} : {
|
|
@@ -310,7 +318,7 @@ class We {
|
|
|
310
318
|
pending: !0,
|
|
311
319
|
error: "Initialization in progress"
|
|
312
320
|
};
|
|
313
|
-
this.initStatus =
|
|
321
|
+
this.initStatus = V.IN_PROGRESS, z("INIT() IN PROGRESS");
|
|
314
322
|
try {
|
|
315
323
|
const e = this.images?.[this.imageLayerScopes?.[0]]?.image?.instance;
|
|
316
324
|
if (this.ngffMetadata = e.vivLoader.metadata, n.debug("ngffMetadata", this.ngffMetadata), !e || e.getType() !== "ome-zarr")
|
|
@@ -323,7 +331,7 @@ class We {
|
|
|
323
331
|
if (!we(o[0].labels, ["t", "c", "z", "y", "x"]))
|
|
324
332
|
throw new Error("Expected OME-Zarr data with dimensions [t, c, z, y, x]");
|
|
325
333
|
n.debug("vivData", o);
|
|
326
|
-
const l = o.map((s) => s._data),
|
|
334
|
+
const l = o.map((s) => s._data), u = new Array(r).fill(null);
|
|
327
335
|
if (l.length > 0) {
|
|
328
336
|
const s = l[0];
|
|
329
337
|
if (this.zarrStore = {
|
|
@@ -341,13 +349,13 @@ class We {
|
|
|
341
349
|
// store: this.store,
|
|
342
350
|
// group: this.group,
|
|
343
351
|
channelCount: a[0][1],
|
|
344
|
-
scales:
|
|
352
|
+
scales: u
|
|
345
353
|
}, 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) {
|
|
346
|
-
const { x: d, y:
|
|
347
|
-
this.zarrStore.physicalSizeVoxel = [x,
|
|
354
|
+
const { x: d, y: m, z: h } = s.meta.physicalSizes, x = h?.size || 1, b = m?.size || 1, R = d?.size || 1;
|
|
355
|
+
this.zarrStore.physicalSizeVoxel = [x, b, R], s.shape && s.shape.length >= 5 && (this.zarrStore.physicalSizeTotal = [
|
|
348
356
|
(s.shape[2] || 1) * x,
|
|
349
|
-
(s.shape[3] || 1) *
|
|
350
|
-
(s.shape[4] || 1) *
|
|
357
|
+
(s.shape[3] || 1) * b,
|
|
358
|
+
(s.shape[4] || 1) * R
|
|
351
359
|
]);
|
|
352
360
|
} else
|
|
353
361
|
this.zarrStore.physicalSizeVoxel = [1, 1, 1], this.zarrStore.physicalSizeTotal = [
|
|
@@ -355,45 +363,45 @@ class We {
|
|
|
355
363
|
s.shape[3] || 1,
|
|
356
364
|
s.shape[4] || 1
|
|
357
365
|
];
|
|
358
|
-
const { multiscales:
|
|
359
|
-
if (!
|
|
366
|
+
const { multiscales: v } = this.ngffMetadata;
|
|
367
|
+
if (!v)
|
|
360
368
|
throw new Error("Expected multiscales metadata in group.attrs");
|
|
361
|
-
if (
|
|
369
|
+
if (v?.[0]?.datasets?.[0]?.coordinateTransformations) {
|
|
362
370
|
for (let d = 0; d < r; d++)
|
|
363
|
-
if (
|
|
364
|
-
const { scale:
|
|
365
|
-
|
|
371
|
+
if (v?.[0]?.datasets?.[d]?.coordinateTransformations?.[0]?.scale) {
|
|
372
|
+
const { scale: m } = v[0].datasets[d].coordinateTransformations[0];
|
|
373
|
+
u[d] = [m[4], m[3], m[2]];
|
|
366
374
|
}
|
|
367
375
|
} else {
|
|
368
376
|
n.error("no coordinateTransformations available, assuming downsampling ratio of 2 per dimension");
|
|
369
377
|
for (let d = 0; d < r; d++) {
|
|
370
|
-
const
|
|
371
|
-
|
|
378
|
+
const m = 2 ** d;
|
|
379
|
+
u[d] = [m, m, m];
|
|
372
380
|
}
|
|
373
381
|
}
|
|
374
|
-
this.zarrStore.scales =
|
|
375
|
-
const { coordinateTransformations:
|
|
376
|
-
if (
|
|
377
|
-
const { scale: d } =
|
|
378
|
-
if (
|
|
379
|
-
const
|
|
380
|
-
this.zarrStore.physicalSizeVoxel = [
|
|
381
|
-
(s.shape[2] || 1) *
|
|
382
|
+
this.zarrStore.scales = u;
|
|
383
|
+
const { coordinateTransformations: g } = this.ngffMetadata;
|
|
384
|
+
if (g?.[0]?.scale) {
|
|
385
|
+
const { scale: d } = g[0], m = d.length;
|
|
386
|
+
if (m >= 3) {
|
|
387
|
+
const h = d[m - 3], x = d[m - 2], b = d[m - 1];
|
|
388
|
+
this.zarrStore.physicalSizeVoxel = [h, x, b], s.shape && s.shape.length >= 5 && (this.zarrStore.physicalSizeTotal = [
|
|
389
|
+
(s.shape[2] || 1) * h,
|
|
382
390
|
(s.shape[3] || 1) * x,
|
|
383
|
-
(s.shape[4] || 1) *
|
|
391
|
+
(s.shape[4] || 1) * b
|
|
384
392
|
]);
|
|
385
393
|
}
|
|
386
394
|
}
|
|
387
395
|
this.zarrStore.brickLayout = Xe(e.getMultiResolutionStats()), n.debug("config", t);
|
|
388
|
-
const { omero:
|
|
389
|
-
if (!
|
|
396
|
+
const { omero: c } = this.ngffMetadata || {};
|
|
397
|
+
if (!c)
|
|
390
398
|
throw new Error("Expected omero metadata in ngffMetadata");
|
|
391
|
-
n.debug("omero",
|
|
392
|
-
const
|
|
393
|
-
this.channels.zarrMappings[
|
|
399
|
+
n.debug("omero", c), Object.keys(t).forEach((d, m) => {
|
|
400
|
+
const h = t[d].spatialTargetC;
|
|
401
|
+
this.channels.zarrMappings[m] = h, this.channels.colorMappings[m] = m, this.channels.downsampleMin[m] = c?.channels?.[h]?.window?.min || 0, this.channels.downsampleMax[m] = c?.channels?.[h]?.window?.max || 65535;
|
|
394
402
|
}), n.debug("zarrMappings after init", this.channels.zarrMappings), n.debug("colorMappings after init", this.channels.colorMappings), n.debug("downsampleMin after init", this.channels.downsampleMin), n.debug("downsampleMax after init", this.channels.downsampleMax), this.initMRMCPT();
|
|
395
403
|
}
|
|
396
|
-
return this.initStatus =
|
|
404
|
+
return this.initStatus = V.COMPLETE, z("INIT() COMPLETE"), {
|
|
397
405
|
success: !0,
|
|
398
406
|
deviceLimits: this.deviceLimits,
|
|
399
407
|
zarrStore: this.zarrStore,
|
|
@@ -403,7 +411,7 @@ class We {
|
|
|
403
411
|
error: null
|
|
404
412
|
};
|
|
405
413
|
} catch (e) {
|
|
406
|
-
return z("INIT() FAILED"), n.error("Error initializing VolumeDataManager:", e), this.initStatus =
|
|
414
|
+
return z("INIT() FAILED"), n.error("Error initializing VolumeDataManager:", e), this.initStatus = V.FAILED, this.initError = e.message || "Unknown error", {
|
|
407
415
|
success: !1,
|
|
408
416
|
error: this.initError
|
|
409
417
|
};
|
|
@@ -434,37 +442,37 @@ class We {
|
|
|
434
442
|
n.debug("channels not initialized yet");
|
|
435
443
|
return;
|
|
436
444
|
}
|
|
437
|
-
const e = Object.values(t).map((l) => l.spatialTargetC).filter((l) => l !== void 0), i = this.channels.zarrMappings.filter((l) => l !== void 0), a = [...new Set(e)].sort((l,
|
|
438
|
-
a.length === r.length && a.every((l,
|
|
445
|
+
const e = Object.values(t).map((l) => l.spatialTargetC).filter((l) => l !== void 0), i = this.channels.zarrMappings.filter((l) => l !== void 0), a = [...new Set(e)].sort((l, u) => l - u), r = [...new Set(i)].sort((l, u) => l - u);
|
|
446
|
+
a.length === r.length && a.every((l, u) => l === r[u]) && n.debug("Channel mappings unchanged, skipping update"), n.debug("Channel mappings changed:", {
|
|
439
447
|
current: r,
|
|
440
448
|
requested: a
|
|
441
|
-
}), Object.entries(t).forEach(([l,
|
|
442
|
-
const s =
|
|
449
|
+
}), Object.entries(t).forEach(([l, u]) => {
|
|
450
|
+
const s = u.spatialTargetC;
|
|
443
451
|
n.debug(`UI channel "${l}" wants zarr channel ${s}`);
|
|
444
|
-
const
|
|
445
|
-
if (
|
|
446
|
-
const
|
|
447
|
-
if (
|
|
448
|
-
this.channels.zarrMappings[
|
|
452
|
+
const v = this.channels.zarrMappings.indexOf(s);
|
|
453
|
+
if (v === -1) {
|
|
454
|
+
const g = this.channels.zarrMappings.findIndex((c) => c === void 0);
|
|
455
|
+
if (g !== -1)
|
|
456
|
+
this.channels.zarrMappings[g] = s, n.debug("channelData", u), n.debug("this.ngffMetadata?.omero?.channels", this.ngffMetadata?.omero?.channels), n.debug("targetZarrChannel", s), this.channels.downsampleMin[g] = this.ngffMetadata?.omero?.channels?.[s]?.window?.min || 0, this.channels.downsampleMax[g] = this.ngffMetadata?.omero?.channels?.[s]?.window?.max || 65535, n.debug(`Mapped zarr channel ${s} to slot ${g}`), n.debug("channels", this.channels);
|
|
449
457
|
else {
|
|
450
458
|
n.debug("No free slots found, looking for unused mapped channels");
|
|
451
|
-
const
|
|
452
|
-
if (n.debug("Currently mapped:",
|
|
453
|
-
const
|
|
454
|
-
if (
|
|
455
|
-
const x = this.channels.zarrMappings[
|
|
456
|
-
this.channels.zarrMappings[
|
|
459
|
+
const c = this.channels.zarrMappings.filter((h) => h !== void 0), d = e, m = c.filter((h) => !d.includes(h));
|
|
460
|
+
if (n.debug("Currently mapped:", c), n.debug("Still requested:", d), n.debug("Unused mapped channels:", m), m.length > 0) {
|
|
461
|
+
const h = this.channels.zarrMappings.findIndex((x) => m.includes(x));
|
|
462
|
+
if (h !== -1) {
|
|
463
|
+
const x = this.channels.zarrMappings[h];
|
|
464
|
+
this.channels.zarrMappings[h] = s, this.channels.downsampleMin[h] = this.ngffMetadata?.omero?.channels?.[s]?.window?.min || 0, this.channels.downsampleMax[h] = this.ngffMetadata?.omero?.channels?.[s]?.window?.max || 65535, n.debug(`Reused slot ${h}: ${x} -> ${s}`), this._purgeChannel(h);
|
|
457
465
|
} else
|
|
458
466
|
n.error("Could not find slot to reuse - this should not happen");
|
|
459
467
|
} else
|
|
460
468
|
n.error("All slots are full and all mapped channels are still in use");
|
|
461
469
|
}
|
|
462
470
|
} else
|
|
463
|
-
n.debug(`Zarr channel ${s} already mapped to slot ${
|
|
471
|
+
n.debug(`Zarr channel ${s} already mapped to slot ${v}`);
|
|
464
472
|
});
|
|
465
473
|
const o = Object.values(t).map((l) => {
|
|
466
|
-
const
|
|
467
|
-
return
|
|
474
|
+
const u = this.channels.zarrMappings.indexOf(l.spatialTargetC);
|
|
475
|
+
return u !== -1 ? u : -1;
|
|
468
476
|
});
|
|
469
477
|
for (; o.length < 7; )
|
|
470
478
|
o.push(-1);
|
|
@@ -567,14 +575,26 @@ class We {
|
|
|
567
575
|
if (!this.zarrStore || !this.zarrStore.arrays[o])
|
|
568
576
|
throw new Error("Zarr store or resolution not initialized");
|
|
569
577
|
n.debug("loadZarrChunk", { t, c: e, z: i, y: a, x: r, resolution: o });
|
|
570
|
-
const
|
|
571
|
-
if (!
|
|
578
|
+
const u = await this.zarrStore.arrays[o].getChunk([t, e, i, a, r]);
|
|
579
|
+
if (!u)
|
|
572
580
|
throw new Error(`No chunk found at coordinates [${t},${e},${i},${a},${r}]`);
|
|
573
|
-
if (
|
|
574
|
-
throw new Error(`Unexpected chunk size: ${
|
|
575
|
-
return
|
|
581
|
+
if (u.data.length !== S * S * S)
|
|
582
|
+
throw new Error(`Unexpected chunk size: ${u.data.length}`);
|
|
583
|
+
return u.data;
|
|
576
584
|
}
|
|
577
|
-
|
|
585
|
+
/**
|
|
586
|
+
* Process the buffer of brick requests from the shader, turning them into
|
|
587
|
+
* actual Promises for Zarr chunks on the JS side.
|
|
588
|
+
* @param {Uint8Array} buffer The bufRequest (of length width*height*4)
|
|
589
|
+
* containing the brick requests from the shader.
|
|
590
|
+
* @param {object} optsForWeighting
|
|
591
|
+
* @param {number} optsForWeighting.width The width of the render target.
|
|
592
|
+
* @param {number} optsForWeighting.height The height of the render target.
|
|
593
|
+
* @param {number} optsForWeighting.sigmaNormalized The normalized sigma value
|
|
594
|
+
* to use for weighting the brick requests based on their distance from
|
|
595
|
+
* the center of the render target.
|
|
596
|
+
*/
|
|
597
|
+
async processRequestData(t, e) {
|
|
578
598
|
if (this.isBusy) {
|
|
579
599
|
n.debug("processRequestData: already busy, skipping");
|
|
580
600
|
return;
|
|
@@ -588,8 +608,8 @@ class We {
|
|
|
588
608
|
return;
|
|
589
609
|
}
|
|
590
610
|
this.isBusy = !0, this.triggerRequest = !1;
|
|
591
|
-
const { requests:
|
|
592
|
-
|
|
611
|
+
const { requests: i, origRequestCount: a } = We(t, this.k, e);
|
|
612
|
+
i.length === 0 && (this.noNewRequests = !0), n.debug(`processRequestData: handling ${i.length} requests of ${a}`), await this.handleBrickRequests(i), this.triggerUsage = !0, this.isBusy = !1;
|
|
593
613
|
}
|
|
594
614
|
async processUsageData(t) {
|
|
595
615
|
if (this.isBusy) {
|
|
@@ -606,8 +626,8 @@ class We {
|
|
|
606
626
|
const r = t[a], o = t[a + 1], l = t[a + 2];
|
|
607
627
|
if ((r | o | l) === 0)
|
|
608
628
|
continue;
|
|
609
|
-
const
|
|
610
|
-
|
|
629
|
+
const u = l * B * G + o * B + r;
|
|
630
|
+
u < this.BCTimeStamps.length && i.add(u);
|
|
611
631
|
}
|
|
612
632
|
Array.from(i).forEach((a) => {
|
|
613
633
|
this.BCTimeStamps[a] = e;
|
|
@@ -642,8 +662,8 @@ class We {
|
|
|
642
662
|
this.PT.anchors[r][0] * e[0]
|
|
643
663
|
];
|
|
644
664
|
n.debug("anchor", o);
|
|
645
|
-
const l = this.zarrStore.brickLayout[r],
|
|
646
|
-
n.debug("extents", l), n.debug("size",
|
|
665
|
+
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, o[0], o[1], o[2], l[0], l[1], l[2], i.RED_INTEGER, i.UNSIGNED_INT, new Uint32Array(u));
|
|
647
667
|
}
|
|
648
668
|
i.bindTexture(i.TEXTURE_3D, null);
|
|
649
669
|
}
|
|
@@ -668,17 +688,17 @@ class We {
|
|
|
668
688
|
*/
|
|
669
689
|
_allocateBCSlots(t) {
|
|
670
690
|
let e = [];
|
|
671
|
-
const i =
|
|
691
|
+
const i = B * G * ce;
|
|
672
692
|
if (!this.BCFull && this.BCUnusedIndex + t > i && (this.BCFull = !0, n.debug("BRICK CACHE FULL")), this.BCFull)
|
|
673
693
|
this.LRUStack.length < t && this._buildLRU(), e = this.LRUStack.splice(0, t).map((a) => {
|
|
674
694
|
this._evictBrick(a);
|
|
675
|
-
const r = Math.floor(a / (
|
|
676
|
-
return { bcIndex: a, x:
|
|
695
|
+
const r = Math.floor(a / (B * G)), o = a - r * B * G, l = Math.floor(o / B), u = o % B;
|
|
696
|
+
return { bcIndex: a, x: u, y: l, z: r };
|
|
677
697
|
});
|
|
678
698
|
else {
|
|
679
699
|
for (let a = 0; a < t; ++a) {
|
|
680
|
-
const r = (this.BCUnusedIndex + a) % i, o = Math.floor(r / (
|
|
681
|
-
e.push({ bcIndex: r, x: s, y:
|
|
700
|
+
const r = (this.BCUnusedIndex + a) % i, o = Math.floor(r / (B * G)), l = r - o * B * G, u = Math.floor(l / B), s = l % B;
|
|
701
|
+
e.push({ bcIndex: r, x: s, y: u, z: o });
|
|
682
702
|
}
|
|
683
703
|
this.BCUnusedIndex += t;
|
|
684
704
|
}
|
|
@@ -705,18 +725,18 @@ class We {
|
|
|
705
725
|
n.error("Channel index out of bounds", { channel: i, mappingsLength: this.channels.zarrMappings.length });
|
|
706
726
|
return;
|
|
707
727
|
}
|
|
708
|
-
const
|
|
709
|
-
if (
|
|
728
|
+
const u = this.channels.zarrMappings[i];
|
|
729
|
+
if (u === void 0 || u === -1)
|
|
710
730
|
if (n.warn("zarrChannel is undefined or -1", {
|
|
711
|
-
zarrChannel:
|
|
731
|
+
zarrChannel: u,
|
|
712
732
|
channel: i,
|
|
713
733
|
ptCoord: t,
|
|
714
734
|
channelMappings: this.channels.zarrMappings,
|
|
715
735
|
contextLost: this.isContextLost()
|
|
716
736
|
}), this._lastChannelConfig && this._lastChannelConfig.zarrMappings[i] !== void 0) {
|
|
717
737
|
n.warn("Attempting to use last known channel config"), this.channels.zarrMappings = [...this._lastChannelConfig.zarrMappings], this.channels.colorMappings = [...this._lastChannelConfig.colorMappings], this.channels.downsampleMin = [...this._lastChannelConfig.downsampleMin], this.channels.downsampleMax = [...this._lastChannelConfig.downsampleMax];
|
|
718
|
-
const
|
|
719
|
-
if (
|
|
738
|
+
const R = this.channels.zarrMappings[i];
|
|
739
|
+
if (R !== void 0 && R !== -1)
|
|
720
740
|
n.debug("Successfully restored channel mapping, continuing with upload");
|
|
721
741
|
else {
|
|
722
742
|
n.error("Could not restore valid channel mapping, aborting brick upload");
|
|
@@ -726,35 +746,35 @@ class We {
|
|
|
726
746
|
n.error("No fallback channel config available, aborting brick upload");
|
|
727
747
|
return;
|
|
728
748
|
}
|
|
729
|
-
n.debug("starting to load zarr chunk", { resolution: a, z: l, y: o, x: r, zarrChannel:
|
|
730
|
-
let s = await this.loadZarrChunk(0,
|
|
749
|
+
n.debug("starting to load zarr chunk", { resolution: a, z: l, y: o, x: r, zarrChannel: u });
|
|
750
|
+
let s = await this.loadZarrChunk(0, u, l, o, r, a);
|
|
731
751
|
if (n.debug("chunk", s), s instanceof Uint16Array) {
|
|
732
752
|
if (n.debug("chunk is Uint16Array, converting to Uint8Array"), this.channels.downsampleMin[i] === void 0) {
|
|
733
753
|
const T = this.channels.zarrMappings[i];
|
|
734
754
|
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]);
|
|
735
755
|
}
|
|
736
|
-
const
|
|
737
|
-
for (let T = 0; T <
|
|
738
|
-
const
|
|
739
|
-
E[T] = (
|
|
756
|
+
const R = new Uint16Array(s.buffer), E = new Uint8Array(s.length), k = this.channels.downsampleMin[i], O = this.channels.downsampleMax[i], X = O - k;
|
|
757
|
+
for (let T = 0; T < R.length; T++) {
|
|
758
|
+
const L = R[T], U = Math.max(k, Math.min(O, L));
|
|
759
|
+
E[T] = (U - k) * 255 / X | 0;
|
|
740
760
|
}
|
|
741
761
|
s = E;
|
|
742
762
|
}
|
|
743
763
|
if (!(s instanceof Uint8Array))
|
|
744
764
|
throw new Error(`Unsupported chunk type: ${s.constructor.name}. Expected Uint8Array.`);
|
|
745
|
-
let
|
|
746
|
-
for (let
|
|
747
|
-
const E = s[
|
|
748
|
-
E <
|
|
765
|
+
let v = 255, g = 0;
|
|
766
|
+
for (let R = 0; R < s.length; ++R) {
|
|
767
|
+
const E = s[R];
|
|
768
|
+
E < v && (v = E), E > g && (g = E);
|
|
749
769
|
}
|
|
750
|
-
const { gl:
|
|
751
|
-
|
|
752
|
-
const
|
|
753
|
-
|
|
754
|
-
const
|
|
755
|
-
|
|
756
|
-
const
|
|
757
|
-
|
|
770
|
+
const { gl: c } = this, d = this.renderer.properties.get(this.bcTHREE).__webglTexture;
|
|
771
|
+
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
|
+
const m = c.getError();
|
|
773
|
+
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 = Ye(v, g, e.x, e.y, e.z), x = this.renderer.properties.get(this.ptTHREE).__webglTexture;
|
|
775
|
+
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
|
+
const b = c.getError();
|
|
777
|
+
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;
|
|
758
778
|
}
|
|
759
779
|
/* ------------------------------------------------------------- *
|
|
760
780
|
* 5. Public: handle a batch of PT requests (array of {x,y,z}) *
|
|
@@ -783,7 +803,7 @@ class We {
|
|
|
783
803
|
this.LRUStack = t.sort((e, i) => e.time - i.time).slice(0, this.k).map((e) => e.index);
|
|
784
804
|
}
|
|
785
805
|
}
|
|
786
|
-
const
|
|
806
|
+
const Qe = `//
|
|
787
807
|
// Output: Unnormalized ray direction from camera to each vertex
|
|
788
808
|
// Used by fragment shader for ray marching through the volume
|
|
789
809
|
out vec3 rayDirUnnorm;
|
|
@@ -842,7 +862,7 @@ void main()
|
|
|
842
862
|
// Pass through texture coordinates for volume sampling
|
|
843
863
|
vUv = uv;
|
|
844
864
|
}
|
|
845
|
-
`,
|
|
865
|
+
`, Je = `//
|
|
846
866
|
// #include <packing>
|
|
847
867
|
precision highp float;
|
|
848
868
|
precision highp int;
|
|
@@ -2407,21 +2427,21 @@ void main(void) {
|
|
|
2407
2427
|
outColor.a);
|
|
2408
2428
|
|
|
2409
2429
|
}
|
|
2410
|
-
`,
|
|
2430
|
+
`, et = {
|
|
2411
2431
|
uniforms: {
|
|
2412
2432
|
u_size: { value: new C(1, 1, 1) },
|
|
2413
|
-
clim0: { value: new
|
|
2414
|
-
clim1: { value: new
|
|
2415
|
-
clim2: { value: new
|
|
2416
|
-
clim3: { value: new
|
|
2417
|
-
clim4: { value: new
|
|
2418
|
-
clim5: { value: new
|
|
2419
|
-
clim6: { value: new
|
|
2420
|
-
clim7: { value: new
|
|
2421
|
-
xClip: { value: new
|
|
2422
|
-
yClip: { value: new
|
|
2423
|
-
zClip: { value: new
|
|
2424
|
-
u_window_size: { value: new
|
|
2433
|
+
clim0: { value: new _(0.2, 0.8) },
|
|
2434
|
+
clim1: { value: new _(0.2, 0.8) },
|
|
2435
|
+
clim2: { value: new _(0.2, 0.8) },
|
|
2436
|
+
clim3: { value: new _(0.2, 0.8) },
|
|
2437
|
+
clim4: { value: new _(0.2, 0.8) },
|
|
2438
|
+
clim5: { value: new _(0.2, 0.8) },
|
|
2439
|
+
clim6: { value: new _(0.2, 0.8) },
|
|
2440
|
+
clim7: { value: new _(0.2, 0.8) },
|
|
2441
|
+
xClip: { value: new _(0, 1e6) },
|
|
2442
|
+
yClip: { value: new _(0, 1e6) },
|
|
2443
|
+
zClip: { value: new _(0, 1e6) },
|
|
2444
|
+
u_window_size: { value: new _(1, 1) },
|
|
2425
2445
|
u_vol_scale: { value: new C(1, 1, 1) },
|
|
2426
2446
|
// Set renderstyle to 3 or 4 for debugging modes
|
|
2427
2447
|
u_renderstyle: { value: 2 },
|
|
@@ -2437,14 +2457,14 @@ void main(void) {
|
|
|
2437
2457
|
channelMapping: {
|
|
2438
2458
|
value: [-1, -1, -1, -1, -1, -1, -1]
|
|
2439
2459
|
},
|
|
2440
|
-
resGlobal: { value: new
|
|
2441
|
-
res0: { value: new
|
|
2442
|
-
res1: { value: new
|
|
2443
|
-
res2: { value: new
|
|
2444
|
-
res3: { value: new
|
|
2445
|
-
res4: { value: new
|
|
2446
|
-
res5: { value: new
|
|
2447
|
-
res6: { value: new
|
|
2460
|
+
resGlobal: { value: new _(0, 9) },
|
|
2461
|
+
res0: { value: new _(0, 9) },
|
|
2462
|
+
res1: { value: new _(0, 9) },
|
|
2463
|
+
res2: { value: new _(0, 9) },
|
|
2464
|
+
res3: { value: new _(0, 9) },
|
|
2465
|
+
res4: { value: new _(0, 9) },
|
|
2466
|
+
res5: { value: new _(0, 9) },
|
|
2467
|
+
res6: { value: new _(0, 9) },
|
|
2448
2468
|
maxChannels: { value: 0 },
|
|
2449
2469
|
lodFactor: { value: 1 },
|
|
2450
2470
|
near: { value: 0.1 },
|
|
@@ -2475,24 +2495,24 @@ void main(void) {
|
|
|
2475
2495
|
scale8: { value: new C(256, 256, 256) },
|
|
2476
2496
|
scale9: { value: new C(512, 512, 512) }
|
|
2477
2497
|
},
|
|
2478
|
-
vertexShader:
|
|
2479
|
-
fragmentShader:
|
|
2498
|
+
vertexShader: Qe,
|
|
2499
|
+
fragmentShader: Je
|
|
2480
2500
|
};
|
|
2481
|
-
function
|
|
2482
|
-
se(le.DEBUG) && console.warn(`%cRM: ${
|
|
2501
|
+
function A(f) {
|
|
2502
|
+
se(le.DEBUG) && console.warn(`%cRM: ${f}`, "background: orange; color: white; padding: 2px; border-radius: 3px;");
|
|
2483
2503
|
}
|
|
2484
|
-
function ne(
|
|
2485
|
-
return
|
|
2504
|
+
function ne(f, t) {
|
|
2505
|
+
return f / t[1];
|
|
2486
2506
|
}
|
|
2487
|
-
class
|
|
2507
|
+
class tt {
|
|
2488
2508
|
constructor() {
|
|
2489
|
-
|
|
2509
|
+
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();
|
|
2490
2510
|
}
|
|
2491
2511
|
/**
|
|
2492
2512
|
* Initialize shader and uniform objects
|
|
2493
2513
|
*/
|
|
2494
2514
|
initializeShader() {
|
|
2495
|
-
|
|
2515
|
+
A("Initializing shader"), this.shader = et, this.uniforms = De.clone(this.shader.uniforms);
|
|
2496
2516
|
}
|
|
2497
2517
|
/**
|
|
2498
2518
|
* Extract rendering settings from coordination props
|
|
@@ -2500,61 +2520,61 @@ class et {
|
|
|
2500
2520
|
* @returns {Object} Extracted rendering settings
|
|
2501
2521
|
*/
|
|
2502
2522
|
extractRenderingSettingsFromProps(t) {
|
|
2503
|
-
const { images: e = {}, imageLayerScopes: i = [], imageLayerCoordination: a = [{}], imageChannelScopesByLayer: r = {}, imageChannelCoordination: o = [{}], spatialRenderingMode: l } = t,
|
|
2504
|
-
if (!
|
|
2505
|
-
return
|
|
2523
|
+
const { images: e = {}, imageLayerScopes: i = [], imageLayerCoordination: a = [{}], imageChannelScopesByLayer: r = {}, imageChannelCoordination: o = [{}], spatialRenderingMode: l } = t, u = i[0];
|
|
2524
|
+
if (!u)
|
|
2525
|
+
return A("Extracting rendering settings from props - no layer scope"), {
|
|
2506
2526
|
valid: !1
|
|
2507
2527
|
};
|
|
2508
|
-
const s = r[
|
|
2509
|
-
if (!
|
|
2510
|
-
return
|
|
2528
|
+
const s = r[u], v = a[0][u], g = o[0][u], c = e[u]?.image?.instance?.getData();
|
|
2529
|
+
if (!c)
|
|
2530
|
+
return A("Extracting rendering settings from props - no image data"), {
|
|
2511
2531
|
valid: !1
|
|
2512
2532
|
};
|
|
2513
|
-
if (!
|
|
2514
|
-
return
|
|
2533
|
+
if (!g[s?.[0]][M.SPATIAL_CHANNEL_WINDOW])
|
|
2534
|
+
return A("Extracting rendering settings from props - no channel window set"), {
|
|
2515
2535
|
valid: !1
|
|
2516
2536
|
};
|
|
2517
|
-
const d = e[
|
|
2537
|
+
const d = e[u].image.instance, m = l === "3D", h = v[M.PHOTOMETRIC_INTERPRETATION] === "RGB", x = v[M.SPATIAL_LAYER_VISIBLE], b = v[M.SPATIAL_LAYER_OPACITY], R = h ? [
|
|
2518
2538
|
[255, 0, 0],
|
|
2519
2539
|
[0, 255, 0],
|
|
2520
2540
|
[0, 0, 255]
|
|
2521
|
-
] : s.map((
|
|
2541
|
+
] : s.map((I) => g[I][M.SPATIAL_CHANNEL_COLOR]), E = h ? [
|
|
2522
2542
|
[0, 255],
|
|
2523
2543
|
[0, 255],
|
|
2524
2544
|
[0, 255]
|
|
2525
|
-
] : s.map((
|
|
2526
|
-
this.maxRangeSet || (this.maxRange = Math.max(...E.map((
|
|
2527
|
-
const
|
|
2545
|
+
] : s.map((I) => g[I][M.SPATIAL_CHANNEL_WINDOW] || [0, 255]);
|
|
2546
|
+
this.maxRangeSet || (this.maxRange = Math.max(...E.map((I) => I[1])), this.maxRangeSet = !0);
|
|
2547
|
+
const k = h ? [
|
|
2528
2548
|
x && !0,
|
|
2529
2549
|
x && !0,
|
|
2530
2550
|
x && !0
|
|
2531
|
-
] : s.map((
|
|
2551
|
+
] : s.map((I) => x && g[I][M.SPATIAL_CHANNEL_VISIBLE]), O = h ? [
|
|
2532
2552
|
x && !0,
|
|
2533
2553
|
x && !0,
|
|
2534
2554
|
x && !0
|
|
2535
|
-
] : s.map((
|
|
2555
|
+
] : s.map((I) => x && d.getChannelIndex(g[I][M.SPATIAL_TARGET_C])), X = h ? [
|
|
2536
2556
|
x && null,
|
|
2537
2557
|
x && null,
|
|
2538
2558
|
x && null
|
|
2539
|
-
] : s.map((
|
|
2540
|
-
let T =
|
|
2541
|
-
const Y =
|
|
2542
|
-
T = T !== null ? T : new
|
|
2543
|
-
const ie = e[
|
|
2544
|
-
return
|
|
2559
|
+
] : s.map((I) => g[I][M.SPATIAL_MAX_RESOLUTION]);
|
|
2560
|
+
let T = v[M.SPATIAL_SLICE_X], L = v[M.SPATIAL_SLICE_Y], U = v[M.SPATIAL_SLICE_Z];
|
|
2561
|
+
const Y = v[M.SPATIAL_LOD_FACTOR] ?? 1;
|
|
2562
|
+
T = T !== null ? T : new _(-1, 1e5), L = L !== null ? L : new _(-1, 1e5), U = U !== null ? U : new _(-1, 1e5);
|
|
2563
|
+
const ie = e[u].image.loaders[0].channels;
|
|
2564
|
+
return A("Extracting rendering settings from props - success"), {
|
|
2545
2565
|
valid: !0,
|
|
2546
|
-
channelsVisible:
|
|
2566
|
+
channelsVisible: k,
|
|
2547
2567
|
allChannels: ie,
|
|
2548
|
-
channelTargetC:
|
|
2549
|
-
channelMaxResolutionIndex:
|
|
2550
|
-
data:
|
|
2551
|
-
colors:
|
|
2568
|
+
channelTargetC: O,
|
|
2569
|
+
channelMaxResolutionIndex: X,
|
|
2570
|
+
data: c,
|
|
2571
|
+
colors: R,
|
|
2552
2572
|
contrastLimits: E,
|
|
2553
|
-
is3dMode:
|
|
2554
|
-
layerTransparency:
|
|
2573
|
+
is3dMode: m,
|
|
2574
|
+
layerTransparency: b,
|
|
2555
2575
|
xSlice: T,
|
|
2556
|
-
ySlice:
|
|
2557
|
-
zSlice:
|
|
2576
|
+
ySlice: L,
|
|
2577
|
+
zSlice: U,
|
|
2558
2578
|
lodFactor: Y
|
|
2559
2579
|
};
|
|
2560
2580
|
}
|
|
@@ -2565,60 +2585,60 @@ class et {
|
|
|
2565
2585
|
*/
|
|
2566
2586
|
updateFromProps(t) {
|
|
2567
2587
|
const e = this.extractRenderingSettingsFromProps(t);
|
|
2568
|
-
return e.valid ? (this.channelsVisible = e.channelsVisible, this.channelTargetC = e.channelTargetC, this.channelMaxResolutionIndex = e.channelMaxResolutionIndex, this.colors = e.colors, this.contrastLimits = e.contrastLimits, this.renderingMode = e.renderingMode, this.layerTransparency = e.layerTransparency, this.xSlice = e.xSlice, this.ySlice = e.ySlice, this.zSlice = e.zSlice, this.uniforms.lodFactor.value = e.lodFactor,
|
|
2588
|
+
return e.valid ? (this.channelsVisible = e.channelsVisible, this.channelTargetC = e.channelTargetC, this.channelMaxResolutionIndex = e.channelMaxResolutionIndex, this.colors = e.colors, this.contrastLimits = e.contrastLimits, this.renderingMode = e.renderingMode, this.layerTransparency = e.layerTransparency, this.xSlice = e.xSlice, this.ySlice = e.ySlice, this.zSlice = e.zSlice, this.uniforms.lodFactor.value = e.lodFactor, A(`lodFactor ${e.lodFactor}`), this.shader.uniforms.lodFactor.value = e.lodFactor, A("Updating from props - success"), !0) : (A("Updating from props - invalid settings"), !1);
|
|
2569
2589
|
}
|
|
2570
2590
|
/**
|
|
2571
2591
|
* Update the rendering based on the current volume data from the data manager
|
|
2572
2592
|
* @param {object} volumeDataManagerProps - Params derived from the volume data manager
|
|
2573
2593
|
* @returns {Object|null} Updated rendering settings or null if rendering is not possible
|
|
2574
2594
|
*/
|
|
2575
|
-
updateRendering({ zarrStoreShapes: t, originalScaleXYZ: e, physicalDimensionsXYZ: i, maxResolutionXYZ: a, boxDimensionsXYZ: r, normalizedScaleXYZ: o, bcTHREE: l, ptTHREE:
|
|
2576
|
-
if (
|
|
2595
|
+
updateRendering({ zarrStoreShapes: t, originalScaleXYZ: e, physicalDimensionsXYZ: i, maxResolutionXYZ: a, boxDimensionsXYZ: r, normalizedScaleXYZ: o, bcTHREE: l, ptTHREE: u }) {
|
|
2596
|
+
if (A("Updating rendering"), this.channelTargetC.findIndex((m, h) => this.channelsVisible[h]), !Array.isArray(t) || t.length === 0)
|
|
2577
2597
|
return null;
|
|
2578
|
-
const s = t[0],
|
|
2598
|
+
const s = t[0], v = {
|
|
2579
2599
|
xLength: s[4] || 1,
|
|
2580
2600
|
yLength: s[3] || 1,
|
|
2581
2601
|
zLength: s[2] || 1
|
|
2582
|
-
},
|
|
2583
|
-
if (this.channelTargetC.forEach((
|
|
2584
|
-
this.channelsVisible[
|
|
2602
|
+
}, g = [], c = [], d = [];
|
|
2603
|
+
if (this.channelTargetC.forEach((m, h) => {
|
|
2604
|
+
this.channelsVisible[h];
|
|
2585
2605
|
{
|
|
2586
|
-
const
|
|
2587
|
-
|
|
2588
|
-
this.colors[
|
|
2589
|
-
this.colors[
|
|
2590
|
-
this.colors[
|
|
2591
|
-
this.channelsVisible[
|
|
2592
|
-
]), n.debug("colorsSave",
|
|
2593
|
-
ne(
|
|
2594
|
-
ne(
|
|
2606
|
+
const b = [0, this.maxRange ? this.maxRange : 255];
|
|
2607
|
+
c.push([
|
|
2608
|
+
this.colors[h][0] / 255,
|
|
2609
|
+
this.colors[h][1] / 255,
|
|
2610
|
+
this.colors[h][2] / 255,
|
|
2611
|
+
this.channelsVisible[h] ? 1 : 0
|
|
2612
|
+
]), n.debug("colorsSave", c), this.contrastLimits[h][0] === 0 && this.contrastLimits[h][1] === 255 ? d.push([
|
|
2613
|
+
ne(b[0], b),
|
|
2614
|
+
ne(b[1], b)
|
|
2595
2615
|
]) : d.push([
|
|
2596
|
-
ne(this.contrastLimits[
|
|
2597
|
-
ne(this.contrastLimits[
|
|
2616
|
+
ne(this.contrastLimits[h][0], b),
|
|
2617
|
+
ne(this.contrastLimits[h][1], b)
|
|
2598
2618
|
]);
|
|
2599
2619
|
}
|
|
2600
2620
|
}), !this.zarrInit) {
|
|
2601
2621
|
this.originalScale = e, this.physicalDimensions = i, this.maxResolution = a;
|
|
2602
|
-
const
|
|
2622
|
+
const m = r;
|
|
2603
2623
|
this.normalizedScale = o, this.meshScale = [
|
|
2604
2624
|
this.originalScale[0] / this.originalScale[0],
|
|
2605
2625
|
this.originalScale[1] / this.originalScale[0],
|
|
2606
2626
|
this.originalScale[2] / this.originalScale[0]
|
|
2607
|
-
], this.geometrySize =
|
|
2627
|
+
], this.geometrySize = m, this.boxSize = m, n.debug("this.boxSize", this.boxSize), n.debug("this.geometrySize", this.geometrySize), n.debug("this.meshScale", this.meshScale), n.debug("this.originalScale", this.originalScale), n.debug("this.physicalDimensions", this.physicalDimensions), n.debug("this.maxResolution", this.maxResolution), n.debug("scaledResolution", m), this.zarrInit = !0;
|
|
2608
2628
|
}
|
|
2609
2629
|
return this.updateUniforms(
|
|
2610
|
-
p,
|
|
2611
2630
|
g,
|
|
2631
|
+
v,
|
|
2612
2632
|
// Pass dimensions object instead of volume
|
|
2613
2633
|
this.renderingMode,
|
|
2614
2634
|
d,
|
|
2615
|
-
|
|
2635
|
+
c,
|
|
2616
2636
|
this.layerTransparency,
|
|
2617
2637
|
this.xSlice,
|
|
2618
2638
|
this.ySlice,
|
|
2619
2639
|
this.zSlice,
|
|
2620
2640
|
l,
|
|
2621
|
-
|
|
2641
|
+
u
|
|
2622
2642
|
), {
|
|
2623
2643
|
uniforms: this.uniforms,
|
|
2624
2644
|
shader: this.shader,
|
|
@@ -2639,10 +2659,10 @@ class et {
|
|
|
2639
2659
|
* @param {Vector2} ySlice - Y clipping plane
|
|
2640
2660
|
* @param {Vector2} zSlice - Z clipping plane
|
|
2641
2661
|
*/
|
|
2642
|
-
updateUniforms(t, e, i, a, r, o, l,
|
|
2643
|
-
|
|
2644
|
-
for (let
|
|
2645
|
-
typeof this.channelMaxResolutionIndex[
|
|
2662
|
+
updateUniforms(t, e, i, a, r, o, l, u, s, v, g) {
|
|
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 = o, 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(a.length > 0 ? a[0][0] : null, a.length > 0 ? a[0][1] : null), this.uniforms.clim1.value.set(a.length > 1 ? a[1][0] : null, a.length > 1 ? a[1][1] : null), this.uniforms.clim2.value.set(a.length > 2 ? a[2][0] : null, a.length > 2 ? a[2][1] : null), this.uniforms.clim3.value.set(a.length > 3 ? a[3][0] : null, a.length > 3 ? a[3][1] : null), this.uniforms.clim4.value.set(a.length > 4 ? a[4][0] : null, a.length > 4 ? a[4][1] : null), this.uniforms.clim5.value.set(a.length > 5 ? a[5][0] : null, a.length > 5 ? a[5][1] : null), this.uniforms.clim6.value.set(a.length > 6 ? a[6][0] : null, a.length > 6 ? a[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
|
+
for (let c = 0; c < 7; c++)
|
|
2665
|
+
typeof this.channelMaxResolutionIndex[c] == "number" && this.uniforms[`res${c}`].value.set(Math.max(1, this.channelMaxResolutionIndex[c]), this.zarrStoreNumResolutions - 1);
|
|
2646
2666
|
}
|
|
2647
2667
|
/**
|
|
2648
2668
|
* Sets the processing render target
|
|
@@ -2655,12 +2675,12 @@ class et {
|
|
|
2655
2675
|
}
|
|
2656
2676
|
*/
|
|
2657
2677
|
setChannelMapping(t) {
|
|
2658
|
-
|
|
2678
|
+
A("setting channel mapping"), n.debug("channelMapping", t), this.uniforms.channelMapping.value = t;
|
|
2659
2679
|
}
|
|
2660
2680
|
// Only called on initialization of the
|
|
2661
2681
|
// VolumeDataManager and VolumeRenderManager for a particular image.
|
|
2662
2682
|
setZarrUniforms(t, e) {
|
|
2663
|
-
|
|
2683
|
+
A("setting zarr uniforms"), n.debug("zarrStore", t), n.debug("PT", e);
|
|
2664
2684
|
for (let i = 0; i <= 9; i++)
|
|
2665
2685
|
e.anchors && e.anchors[i] ? this.uniforms[`anchor${i}`].value.set(e.anchors[i][0] || 0, e.anchors[i][1] || 0, e.anchors[i][2] || 0) : (n.debug("anchor", i, "does not exist"), this.uniforms[`anchor${i}`].value.set(0, 0, 0)), t.scales && t.scales[i] ? this.uniforms[`scale${i}`].value.set(t.scales[i][0] || 1, t.scales[i][1] || 1, t.scales[i][2] || 1) : n.debug("scale", i, "does not exist");
|
|
2666
2686
|
n.debug("zarrStore.brickLayout", t.brickLayout), this.zarrStoreNumResolutions = t.brickLayout.length;
|
|
@@ -2673,13 +2693,13 @@ class et {
|
|
|
2673
2693
|
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);
|
|
2674
2694
|
}
|
|
2675
2695
|
}
|
|
2676
|
-
const
|
|
2696
|
+
const nt = `//
|
|
2677
2697
|
varying vec2 vUv;
|
|
2678
2698
|
void main() {
|
|
2679
2699
|
vUv = uv;
|
|
2680
2700
|
gl_Position = vec4(position, 1.0);
|
|
2681
2701
|
}
|
|
2682
|
-
`,
|
|
2702
|
+
`, rt = `//
|
|
2683
2703
|
// Input texture to blur
|
|
2684
2704
|
uniform sampler2D tDiffuse;
|
|
2685
2705
|
// Resolution of the texture (width, height)
|
|
@@ -2865,50 +2885,57 @@ void main() {
|
|
|
2865
2885
|
gl_FragColor = color;
|
|
2866
2886
|
}
|
|
2867
2887
|
`;
|
|
2868
|
-
function be(
|
|
2869
|
-
const e =
|
|
2888
|
+
function be(f, t) {
|
|
2889
|
+
const e = f.properties?.get(t);
|
|
2870
2890
|
return e?.framebuffer || e?.__webglFramebuffer || t.__webglFramebuffer;
|
|
2871
2891
|
}
|
|
2872
|
-
function Q(
|
|
2873
|
-
se(le.DEBUG) && console.warn(`%cV: ${
|
|
2892
|
+
function Q(f) {
|
|
2893
|
+
se(le.DEBUG) && console.warn(`%cV: ${f}`, "background: deeppink; color: white; padding: 2px; border-radius: 3px;");
|
|
2874
2894
|
}
|
|
2875
|
-
function
|
|
2876
|
-
|
|
2895
|
+
function it(f, t, e, { mrtRef: i }) {
|
|
2896
|
+
f.setRenderTarget(i.current), f.clear(!0, !0, !0), f.render(e, t);
|
|
2877
2897
|
}
|
|
2878
|
-
function
|
|
2879
|
-
|
|
2898
|
+
function at(f, { screenSceneRef: t, screenCameraRef: e }) {
|
|
2899
|
+
f.setRenderTarget(null), f.clear(!0, !0, !0), f.render(t.current, e.current);
|
|
2880
2900
|
}
|
|
2881
|
-
function
|
|
2882
|
-
const o =
|
|
2883
|
-
e.noNewRequests === !0 && !e.manuallyStopped && l % 100 === 0 && l < 500 && (e.noNewRequests = !1), e.triggerRequest === !0 && e.noNewRequests === !1 ? (o.bindFramebuffer(o.READ_FRAMEBUFFER, be(
|
|
2901
|
+
function ot(f, { frameRef: t, dataManager: e, mrtRef: i, bufRequest: a, bufUsage: r }) {
|
|
2902
|
+
const o = f.getContext(), l = t.current;
|
|
2903
|
+
e.noNewRequests === !0 && !e.manuallyStopped && l % 100 === 0 && l < 500 && (e.noNewRequests = !1), e.triggerRequest === !0 && e.noNewRequests === !1 ? (o.bindFramebuffer(o.READ_FRAMEBUFFER, be(f, i.current)), o.readBuffer(o.COLOR_ATTACHMENT1), o.readPixels(0, 0, i.current.width, i.current.height, o.RGBA, o.UNSIGNED_BYTE, a.current), e.processRequestData(a.current, {
|
|
2904
|
+
// If width/height are not yet available,
|
|
2905
|
+
// processRequestData will proceed without weighting.
|
|
2906
|
+
width: i?.current?.width,
|
|
2907
|
+
height: i?.current?.height,
|
|
2908
|
+
// Default sigmaNormalized = 0.25; can be tuned
|
|
2909
|
+
sigmaNormalized: Ke
|
|
2910
|
+
})) : e.triggerUsage === !0 && e.noNewRequests === !1 && (o.bindFramebuffer(o.READ_FRAMEBUFFER, be(f, i.current)), o.readBuffer(o.COLOR_ATTACHMENT2), o.readPixels(0, 0, i.current.width, i.current.height, o.RGBA, o.UNSIGNED_BYTE, r.current), e.processUsageData(r.current));
|
|
2884
2911
|
}
|
|
2885
|
-
function
|
|
2886
|
-
const { invalidate: e, isInteracting: i, dataManager: a, spatialRenderingModeChanging: r, meshRef: o, stillRef: l, screenQuadRef:
|
|
2887
|
-
if (
|
|
2912
|
+
function st(f, t) {
|
|
2913
|
+
const { invalidate: e, isInteracting: i, dataManager: a, spatialRenderingModeChanging: r, meshRef: o, stillRef: l, screenQuadRef: u, lastSampleRef: s, frameRef: v, lastFrameCountRef: g } = t;
|
|
2914
|
+
if (u.current && (l.current ? u.current.material.uniforms.gaussian.value = 0 : u.current.material.uniforms.gaussian.value = 7), i) {
|
|
2888
2915
|
a.manuallyStopped || (a.noNewRequests = !1, a.triggerUsage = !0);
|
|
2889
2916
|
return;
|
|
2890
2917
|
}
|
|
2891
2918
|
if (r)
|
|
2892
2919
|
return;
|
|
2893
|
-
const
|
|
2920
|
+
const c = o.current?.material?.uniforms, d = c?.renderRes?.value ?? a?.PT?.lowestDataRes;
|
|
2894
2921
|
if (a.noNewRequests) {
|
|
2895
|
-
d !== 0 ? (
|
|
2922
|
+
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);
|
|
2896
2923
|
return;
|
|
2897
2924
|
}
|
|
2898
2925
|
l.current && (l.current = !1, e());
|
|
2899
|
-
const
|
|
2900
|
-
if (
|
|
2926
|
+
const m = f.getElapsedTime();
|
|
2927
|
+
if (m - s.current < 1)
|
|
2901
2928
|
return;
|
|
2902
|
-
const
|
|
2903
|
-
let
|
|
2904
|
-
|
|
2905
|
-
const
|
|
2906
|
-
if (
|
|
2907
|
-
const
|
|
2908
|
-
|
|
2929
|
+
const h = m - s.current, x = v.current - g.current;
|
|
2930
|
+
let b = 0;
|
|
2931
|
+
h > 0 && (b = x / h), s.current = m, g.current = v.current;
|
|
2932
|
+
const R = b > 100 && d > 0, E = b < 30 && d < a.PT.lowestDataRes;
|
|
2933
|
+
if (R || E) {
|
|
2934
|
+
const k = d + (E ? 1 : -1);
|
|
2935
|
+
c && (c.renderRes.value = k), e();
|
|
2909
2936
|
}
|
|
2910
2937
|
}
|
|
2911
|
-
function
|
|
2938
|
+
function lt(f) {
|
|
2912
2939
|
const {
|
|
2913
2940
|
images: t,
|
|
2914
2941
|
imageLayerScopes: e,
|
|
@@ -2918,37 +2945,37 @@ function st(h) {
|
|
|
2918
2945
|
// onInitComplete,
|
|
2919
2946
|
spatialRenderingMode: o,
|
|
2920
2947
|
spatialRenderingModeChanging: l,
|
|
2921
|
-
onVolumeLoadingUpdate:
|
|
2922
|
-
} =
|
|
2948
|
+
onVolumeLoadingUpdate: u
|
|
2949
|
+
} = f, {
|
|
2923
2950
|
gl: s
|
|
2924
2951
|
// scene,
|
|
2925
2952
|
// camera
|
|
2926
|
-
} = ve(),
|
|
2953
|
+
} = ve(), v = ve((y) => y.invalidate), g = P(null), c = P(null), d = P(null), m = P(null), h = P(null), [x, b] = fe({
|
|
2927
2954
|
uniforms: null,
|
|
2928
2955
|
shader: null,
|
|
2929
2956
|
meshScale: [1, 1, 1],
|
|
2930
2957
|
geometrySize: [1, 1, 1]
|
|
2931
|
-
}),
|
|
2958
|
+
}), R = o === "3D", E = P(null), k = P(null), O = P(null), [X, T] = fe(!1), L = P(null), U = P(!1), Y = P(0), ie = P(0), I = P(0), p = de(() => new $e(s), [s]), w = de(() => new tt(), []);
|
|
2932
2959
|
$(() => {
|
|
2933
2960
|
Q("useEffect MRT target matching canvas");
|
|
2934
|
-
const { width:
|
|
2961
|
+
const { width: y, height: D } = s.domElement, q = new Me(y, D, 3);
|
|
2935
2962
|
q.texture.forEach((W) => {
|
|
2936
2963
|
W.format = Pe, W.type = _e, W.minFilter = re, W.magFilter = re, W.generateMipmaps = !1;
|
|
2937
2964
|
});
|
|
2938
|
-
const
|
|
2965
|
+
const F = new Ae(), ee = new Be(-1, 1, 1, -1, 0.1, 10);
|
|
2939
2966
|
ee.position.z = 1;
|
|
2940
2967
|
const te = new Ne({
|
|
2941
2968
|
uniforms: {
|
|
2942
2969
|
// Bind the first render target texture as the input of the gaussian blur shader.
|
|
2943
2970
|
tDiffuse: { value: q.texture[0] },
|
|
2944
|
-
resolution: { value: new
|
|
2971
|
+
resolution: { value: new _(y, D) },
|
|
2945
2972
|
gaussian: { value: 7 }
|
|
2946
2973
|
},
|
|
2947
|
-
vertexShader:
|
|
2948
|
-
fragmentShader:
|
|
2974
|
+
vertexShader: nt,
|
|
2975
|
+
fragmentShader: rt,
|
|
2949
2976
|
transparent: !0
|
|
2950
2977
|
}), K = new Ue(new Le(2, 2), te);
|
|
2951
|
-
return
|
|
2978
|
+
return F.add(K), E.current = F, k.current = ee, O.current = K, d.current = new Uint8Array(y * D * 4), m.current = new Uint8Array(y * D * 4), h.current = q, () => {
|
|
2952
2979
|
q.dispose(), te.dispose(), K.geometry.dispose();
|
|
2953
2980
|
};
|
|
2954
2981
|
}, [s]);
|
|
@@ -2957,8 +2984,8 @@ function st(h) {
|
|
|
2957
2984
|
const J = r?.[0]?.[ae];
|
|
2958
2985
|
$(() => {
|
|
2959
2986
|
Q("useEffect INIT");
|
|
2960
|
-
let
|
|
2961
|
-
if (!
|
|
2987
|
+
let y = !1;
|
|
2988
|
+
if (!p || !w) {
|
|
2962
2989
|
n.debug("dataManager or renderManager not initialized yet");
|
|
2963
2990
|
return;
|
|
2964
2991
|
}
|
|
@@ -2971,22 +2998,22 @@ function st(h) {
|
|
|
2971
2998
|
return;
|
|
2972
2999
|
}
|
|
2973
3000
|
return (async () => {
|
|
2974
|
-
if (
|
|
3001
|
+
if (p.initStatus === V.COMPLETE) {
|
|
2975
3002
|
n.debug("dataManager already initialized, skipping");
|
|
2976
3003
|
return;
|
|
2977
3004
|
}
|
|
2978
|
-
if (
|
|
3005
|
+
if (p.initImages(t, e), await p.init(J), y) {
|
|
2979
3006
|
n.debug("Initialization useEffect has rerun, aborting remaining initialization");
|
|
2980
3007
|
return;
|
|
2981
3008
|
}
|
|
2982
|
-
n.debug("dataManager initialized"), w.setZarrUniforms(
|
|
3009
|
+
n.debug("dataManager initialized"), w.setZarrUniforms(p.zarrStore, p.PT), w.setChannelMapping(p.channels.colorMappings), n.debug("rm.uniforms", w.uniforms), v();
|
|
2983
3010
|
})(), () => {
|
|
2984
|
-
|
|
3011
|
+
y = !0;
|
|
2985
3012
|
};
|
|
2986
|
-
}, [
|
|
2987
|
-
if (o === "3D" &&
|
|
3013
|
+
}, [p, w, t, e]), $(() => {
|
|
3014
|
+
if (o === "3D" && p && w) {
|
|
2988
3015
|
Q("useEffect spatialRenderingMode");
|
|
2989
|
-
const
|
|
3016
|
+
const D = {
|
|
2990
3017
|
images: t,
|
|
2991
3018
|
imageLayerScopes: e,
|
|
2992
3019
|
imageLayerCoordination: i,
|
|
@@ -2994,75 +3021,75 @@ function st(h) {
|
|
|
2994
3021
|
imageChannelCoordination: r,
|
|
2995
3022
|
spatialRenderingMode: o
|
|
2996
3023
|
};
|
|
2997
|
-
if (w.updateFromProps(
|
|
3024
|
+
if (w.updateFromProps(D)) {
|
|
2998
3025
|
const { zarrInit: q } = w;
|
|
2999
|
-
q || (
|
|
3000
|
-
const
|
|
3001
|
-
zarrStoreShapes:
|
|
3002
|
-
originalScaleXYZ:
|
|
3003
|
-
physicalDimensionsXYZ:
|
|
3004
|
-
maxResolutionXYZ:
|
|
3005
|
-
boxDimensionsXYZ:
|
|
3006
|
-
normalizedScaleXYZ:
|
|
3007
|
-
bcTHREE:
|
|
3008
|
-
ptTHREE:
|
|
3026
|
+
q || (p.ptTHREE.needsUpdate = !1, p.bcTHREE.needsUpdate = !1, p.renderer.initTexture(p.bcTHREE), p.renderer.initTexture(p.ptTHREE), p.initTexture());
|
|
3027
|
+
const F = w.updateRendering({
|
|
3028
|
+
zarrStoreShapes: p.zarrStore.shapes,
|
|
3029
|
+
originalScaleXYZ: p.getOriginalScaleXYZ(),
|
|
3030
|
+
physicalDimensionsXYZ: p.getPhysicalDimensionsXYZ(),
|
|
3031
|
+
maxResolutionXYZ: p.getMaxResolutionXYZ(),
|
|
3032
|
+
boxDimensionsXYZ: p.getBoxDimensionsXYZ(),
|
|
3033
|
+
normalizedScaleXYZ: p.getNormalizedScaleXYZ(),
|
|
3034
|
+
bcTHREE: p.bcTHREE,
|
|
3035
|
+
ptTHREE: p.ptTHREE
|
|
3009
3036
|
});
|
|
3010
|
-
|
|
3037
|
+
F && b(F);
|
|
3011
3038
|
}
|
|
3012
3039
|
}
|
|
3013
|
-
}, [
|
|
3014
|
-
if (!
|
|
3040
|
+
}, [p, w, t, e, i, a, r, o]), Ge((y, D, q) => {
|
|
3041
|
+
if (!h.current || !p || !w || !x.shader)
|
|
3015
3042
|
return;
|
|
3016
|
-
const { gl:
|
|
3017
|
-
|
|
3018
|
-
invalidate:
|
|
3019
|
-
isInteracting:
|
|
3020
|
-
dataManager:
|
|
3043
|
+
const { gl: F, camera: ee, scene: te, clock: K } = y;
|
|
3044
|
+
U.current || it(F, ee, te, { mrtRef: h }), at(F, { screenSceneRef: E, screenCameraRef: k }), ot(F, { frameRef: Y, dataManager: p, mrtRef: h, bufRequest: d, bufUsage: m }), st(K, {
|
|
3045
|
+
invalidate: v,
|
|
3046
|
+
isInteracting: X,
|
|
3047
|
+
dataManager: p,
|
|
3021
3048
|
spatialRenderingModeChanging: l,
|
|
3022
|
-
meshRef:
|
|
3023
|
-
stillRef:
|
|
3024
|
-
screenQuadRef:
|
|
3049
|
+
meshRef: c,
|
|
3050
|
+
stillRef: U,
|
|
3051
|
+
screenQuadRef: O,
|
|
3025
3052
|
lastSampleRef: ie,
|
|
3026
3053
|
frameRef: Y,
|
|
3027
|
-
lastFrameCountRef:
|
|
3054
|
+
lastFrameCountRef: I
|
|
3028
3055
|
}), Y.current += 1;
|
|
3029
3056
|
}, 1);
|
|
3030
|
-
const H =
|
|
3031
|
-
if (Q("invalidateOnInteraction callback"), T(
|
|
3032
|
-
const
|
|
3033
|
-
|
|
3057
|
+
const H = j((y) => {
|
|
3058
|
+
if (Q("invalidateOnInteraction callback"), T(y), y) {
|
|
3059
|
+
const D = c.current?.material?.uniforms;
|
|
3060
|
+
D && (D.renderRes.value = p.PT.lowestDataRes), U.current = !1, v();
|
|
3034
3061
|
}
|
|
3035
|
-
}), Re =
|
|
3062
|
+
}), Re = j((y) => {
|
|
3036
3063
|
H(!0);
|
|
3037
|
-
}), ye =
|
|
3038
|
-
clearTimeout(
|
|
3064
|
+
}), ye = j((y) => {
|
|
3065
|
+
clearTimeout(L.current), L.current = setTimeout(() => {
|
|
3039
3066
|
H(!1);
|
|
3040
3067
|
}, 300);
|
|
3041
3068
|
});
|
|
3042
3069
|
$(() => {
|
|
3043
|
-
Q("useEffect firstImageLayerChannelCoordination"), H(!0), n.debug("something about channels changed"),
|
|
3070
|
+
Q("useEffect firstImageLayerChannelCoordination"), H(!0), n.debug("something about channels changed"), p.updateChannels(J), w.setChannelMapping(p.channels.colorMappings), clearTimeout(L.current), L.current = setTimeout(() => {
|
|
3044
3071
|
H(!1);
|
|
3045
3072
|
}, 300);
|
|
3046
|
-
}, [
|
|
3047
|
-
const Ee =
|
|
3048
|
-
|
|
3049
|
-
}), Te =
|
|
3050
|
-
|
|
3051
|
-
}), Se =
|
|
3073
|
+
}, [p, J, w, H]);
|
|
3074
|
+
const Ee = j(() => {
|
|
3075
|
+
p && p.stopLoading();
|
|
3076
|
+
}), Te = j(() => {
|
|
3077
|
+
p && p.restartLoading();
|
|
3078
|
+
}), Se = j(() => p ? p.getLoadingProgress() : null);
|
|
3052
3079
|
return $(() => {
|
|
3053
|
-
if (!
|
|
3080
|
+
if (!u)
|
|
3054
3081
|
return;
|
|
3055
|
-
const
|
|
3056
|
-
const
|
|
3057
|
-
|
|
3058
|
-
loadingProgress:
|
|
3059
|
-
stillRef:
|
|
3082
|
+
const y = setInterval(() => {
|
|
3083
|
+
const D = Se();
|
|
3084
|
+
u({
|
|
3085
|
+
loadingProgress: D,
|
|
3086
|
+
stillRef: U,
|
|
3060
3087
|
onStopLoading: Ee,
|
|
3061
3088
|
onRestartLoading: Te
|
|
3062
3089
|
});
|
|
3063
3090
|
}, 1e3);
|
|
3064
|
-
return () => clearInterval(
|
|
3065
|
-
}, [
|
|
3091
|
+
return () => clearInterval(y);
|
|
3092
|
+
}, [u, U]), !R || !p || !w ? null : x.shader ? N.jsxs("group", { children: [N.jsx(
|
|
3066
3093
|
me,
|
|
3067
3094
|
{
|
|
3068
3095
|
// ref={mainOrbitControlsRef}
|
|
@@ -3070,10 +3097,10 @@ function st(h) {
|
|
|
3070
3097
|
onStart: Re,
|
|
3071
3098
|
onEnd: ye
|
|
3072
3099
|
}
|
|
3073
|
-
),
|
|
3100
|
+
), N.jsxs("mesh", { ref: c, scale: x.meshScale, children: [N.jsx("boxGeometry", { args: x.geometrySize }), N.jsx("shaderMaterial", { uniforms: x.uniforms, vertexShader: x.shader.vertexShader, fragmentShader: x.shader.fragmentShader, side: Fe, transparent: !1, glslVersion: Oe })] })] }) : N.jsxs("group", { children: [N.jsxs("mesh", { children: [N.jsx("boxGeometry", { args: [1, 1, 1] }), N.jsx("meshBasicMaterial", { color: "#444", wireframe: !0 })] }), N.jsx(me, { ref: g })] });
|
|
3074
3101
|
}
|
|
3075
|
-
function
|
|
3076
|
-
return
|
|
3102
|
+
function dt(f) {
|
|
3103
|
+
return N.jsx(qe, { frameloop: "always", style: {
|
|
3077
3104
|
position: "absolute",
|
|
3078
3105
|
top: 0,
|
|
3079
3106
|
left: 0,
|
|
@@ -3093,8 +3120,8 @@ function ft(h) {
|
|
|
3093
3120
|
logarithmicDepthBuffer: !1,
|
|
3094
3121
|
preserveDrawingBuffer: !1,
|
|
3095
3122
|
autoClear: !1
|
|
3096
|
-
}, children:
|
|
3123
|
+
}, children: N.jsx(Ve, { fallback: "Initializing Volume View...", children: N.jsx(lt, { ...f }) }) });
|
|
3097
3124
|
}
|
|
3098
3125
|
export {
|
|
3099
|
-
|
|
3126
|
+
dt as SpatialWrapper
|
|
3100
3127
|
};
|