@vitessce/comparative 4.0.0-test.1 → 4.0.0-test.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{GeometryAndMeshXR-CX1Dr7Lp.js → GeometryAndMeshXR-Rj8DuqKI.js} +4 -4
- package/dist/{OrbitControls-4708Bo-O.js → OrbitControls-CSK4x9Nb.js} +1 -1
- package/dist/{ReactNeuroglancer-D7gl_oXM.js → ReactNeuroglancer-BAmwPpri.js} +1 -1
- package/dist/{XREnterButton-Dp2xhwJb.js → XREnterButton-BTyk-JNM.js} +1 -1
- package/dist/{XRSceneComponents-Cp8t3pvt.js → XRSceneComponents-Bdj5nq7u.js} +2 -2
- package/dist/{XRWrapper-tyjCu0dQ.js → XRWrapper-C_ChUWmZ.js} +2 -2
- package/dist/{deflate-sQAuGjEg.js → deflate-CrBkHn3o.js} +1 -1
- package/dist/{emulate-BRbJviQW.js → emulate-BMuLpa2M.js} +2 -2
- package/dist/{higlass-BTDczObM.js → higlass-R4akpd_U.js} +1 -1
- package/dist/{index-Cor41Qpl.js → index-BvABCvu0.js} +59 -6
- package/dist/{index-Db7_bzrU.js → index-CaGs2wGk.js} +370 -366
- package/dist/{index-d-ezrYVn.js → index-ChP-N2-Q.js} +12 -12
- package/dist/{index-CjBUb32k.js → index-evkxJwCU.js} +1 -1
- package/dist/index.min.js +1 -1
- package/dist/{jpeg-B8XmXhIa.js → jpeg-CmFz2x7u.js} +1 -1
- package/dist/{lerc-De9HQWG7.js → lerc-D9Z1SChC.js} +1 -1
- package/dist/{lzw-Bhsi2mhO.js → lzw-BxcPIsd9.js} +1 -1
- package/dist/{packbits-D5ce5JVI.js → packbits-BvyhLVrx.js} +1 -1
- package/dist/{raw-C1PbNQtJ.js → raw-nQNg2593.js} +1 -1
- package/dist/{ray-grab-BbmztB1N.js → ray-grab-CunbRXU8.js} +3 -3
- package/dist/{webimage-BoWu99dN.js → webimage-CD0PiPO_.js} +1 -1
- package/dist/{xrStore-BIllgY4M.js → xrStore-BFuIULKr.js} +1 -1
- package/package.json +11 -11
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { u as de, a as
|
|
4
|
-
import { l as n, i as
|
|
5
|
-
const
|
|
1
|
+
import { jsxs as re, jsx as V } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as D, useState as se, useMemo as fe, useEffect as Q, Suspense as Ie } from "react";
|
|
3
|
+
import { u as de, a as De, O as ve, C as Me } from "./OrbitControls-CSK4x9Nb.js";
|
|
4
|
+
import { l as n, i as Pe, c as ce, D as me, R as Ae, U as Ce, d as ge, e as Be, f as Ne, N as oe, h as ue, V as C, j as _, k as j, m as Ue, C as M, W as Le, n as Oe, S as Fe, O as Ve, o as Ge, p as qe, P as Ze, u as H, G as Xe, q as je } from "./index-ChP-N2-Q.js";
|
|
5
|
+
const w = 32, A = 64, q = 64, he = 4, le = A * q * he, xe = A * w, pe = q * w, be = he * w, F = {
|
|
6
6
|
NOT_STARTED: "not_started",
|
|
7
7
|
IN_PROGRESS: "in_progress",
|
|
8
8
|
COMPLETE: "complete",
|
|
9
9
|
FAILED: "failed"
|
|
10
10
|
};
|
|
11
|
-
function
|
|
12
|
-
|
|
11
|
+
function k(f) {
|
|
12
|
+
ce(ue.DEBUG) && console.warn(`%cDM: ${f}`, "background: blue; color: white; padding: 2px; border-radius: 3px;");
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function Ye(f) {
|
|
15
15
|
return f.map((t) => {
|
|
16
16
|
const { dims: e } = t;
|
|
17
17
|
return [
|
|
@@ -26,7 +26,7 @@ function Xe(f) {
|
|
|
26
26
|
];
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function He(f) {
|
|
30
30
|
return f.map((t) => {
|
|
31
31
|
const e = [
|
|
32
32
|
t.depth,
|
|
@@ -37,13 +37,13 @@ function je(f) {
|
|
|
37
37
|
// x
|
|
38
38
|
];
|
|
39
39
|
return [
|
|
40
|
-
Math.ceil((e[0] || 1) /
|
|
41
|
-
Math.ceil((e[1] || 1) /
|
|
42
|
-
Math.ceil((e[2] || 1) /
|
|
40
|
+
Math.ceil((e[0] || 1) / w),
|
|
41
|
+
Math.ceil((e[1] || 1) / w),
|
|
42
|
+
Math.ceil((e[2] || 1) / w)
|
|
43
43
|
];
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function Ke(f, t) {
|
|
47
47
|
n.debug("_initMRMCPT", f, t);
|
|
48
48
|
const e = {
|
|
49
49
|
channelOffsets: [
|
|
@@ -83,69 +83,69 @@ function Ye(f, t) {
|
|
|
83
83
|
const r = new Uint32Array(e.xExtent * e.yExtent * e.zTotal);
|
|
84
84
|
r.fill(0);
|
|
85
85
|
const a = new me(o, xe, pe, be);
|
|
86
|
-
a.format =
|
|
87
|
-
const
|
|
88
|
-
return
|
|
86
|
+
a.format = Ae, a.type = Ce, a.internalFormat = "R8", a.minFilter = ge, a.magFilter = ge, a.generateMipmaps = !1, a.needsUpdate = !0;
|
|
87
|
+
const c = new me(r, e.xExtent, e.yExtent, e.zTotal);
|
|
88
|
+
return c.format = Be, c.type = Ne, c.internalFormat = "R32UI", c.minFilter = oe, c.magFilter = oe, c.generateMipmaps = !1, c.needsUpdate = !0, n.debug("_initMRMCPT", e, c, a), {
|
|
89
89
|
PT: e,
|
|
90
|
-
ptTHREE:
|
|
90
|
+
ptTHREE: c,
|
|
91
91
|
bcTHREE: a
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function We(f, t, e, i, o) {
|
|
95
95
|
const r = (a) => Math.max(0, Math.min(127, Math.floor(a / 2)));
|
|
96
96
|
return (1 << 31 | 1 << 30 | r(f) << 23 | r(t) << 16 | (e & 63) << 10 | (i & 63) << 4 | o & 15) >>> 0;
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function $e(f, t, e, i) {
|
|
99
99
|
const { PT_zExtent: o, PT_z0Extent: r, PT_anchors: a } = i;
|
|
100
|
-
let
|
|
100
|
+
let c = -1, u = -1, l = -1, p = -1, m = -1;
|
|
101
101
|
if (e >= o)
|
|
102
|
-
u = 0,
|
|
102
|
+
u = 0, l = f, p = t, m = (e - o) % r, c = Math.floor((e - o) / r);
|
|
103
103
|
else
|
|
104
|
-
for (let
|
|
105
|
-
if (!(f < a[
|
|
106
|
-
u =
|
|
104
|
+
for (let s = 1; s < a.length; s++)
|
|
105
|
+
if (!(f < a[s][0] && t < a[s][1] && e < a[s][2])) {
|
|
106
|
+
u = s;
|
|
107
107
|
const d = [0, 0, 0];
|
|
108
|
-
f >= a[
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
const h = d.map((
|
|
112
|
-
|
|
108
|
+
f >= a[s][0] && (d[0] = 1), t >= a[s][1] && (d[1] = 1), e >= a[s][2] && (d[2] = 1);
|
|
109
|
+
const v = d[0] << 2 | d[1] << 1 | d[2];
|
|
110
|
+
c = Math.max(1, Math.min(7, v)) - 1;
|
|
111
|
+
const h = d.map((g, b) => g * a[s][b]);
|
|
112
|
+
l = f - h[0], p = t - h[1], m = e - h[2];
|
|
113
113
|
break;
|
|
114
114
|
}
|
|
115
115
|
return {
|
|
116
|
-
channel:
|
|
116
|
+
channel: c,
|
|
117
117
|
resolution: u,
|
|
118
|
-
x:
|
|
119
|
-
y:
|
|
120
|
-
z:
|
|
118
|
+
x: l,
|
|
119
|
+
y: p,
|
|
120
|
+
z: m
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
const
|
|
124
|
-
function
|
|
125
|
-
const i = /* @__PURE__ */ new Map(), { width: o, height: r, sigmaNormalized: a } = e,
|
|
126
|
-
|
|
123
|
+
const Qe = 0.25;
|
|
124
|
+
function Je(f, t, e) {
|
|
125
|
+
const i = /* @__PURE__ */ new Map(), { width: o, height: r, sigmaNormalized: a } = e, c = Number.isInteger(o) && Number.isInteger(r) && o > 0 && r > 0 && typeof a == "number";
|
|
126
|
+
c || n.warn("_requestBufferToRequestObjects: proceeding without weighting");
|
|
127
127
|
const u = Math.floor(f.length / 4);
|
|
128
|
-
for (let
|
|
129
|
-
const
|
|
130
|
-
if ((
|
|
128
|
+
for (let m = 0; m < u; m += 1) {
|
|
129
|
+
const s = m * 4, d = f[s], v = f[s + 1], h = f[s + 2], g = f[s + 3];
|
|
130
|
+
if ((d | v | h | g) === 0)
|
|
131
131
|
continue;
|
|
132
|
-
const
|
|
133
|
-
let
|
|
134
|
-
if (
|
|
135
|
-
const
|
|
136
|
-
|
|
132
|
+
const b = (d << 24 | v << 16 | h << 8 | g) >>> 0;
|
|
133
|
+
let R = 1;
|
|
134
|
+
if (c) {
|
|
135
|
+
const y = m % o, B = Math.floor(m / o), U = y - o / 2, L = B - r / 2, N = Math.sqrt(U * U / (o * o) + L * L / (r * r)) / a;
|
|
136
|
+
R = Math.exp(-0.5 * N * N);
|
|
137
137
|
}
|
|
138
|
-
i.set(
|
|
138
|
+
i.set(b, (i.get(b) || 0) + R);
|
|
139
139
|
}
|
|
140
|
-
return { requests:
|
|
141
|
-
x:
|
|
142
|
-
y:
|
|
143
|
-
z:
|
|
140
|
+
return { requests: Array.from(i.entries()).toSorted((m, s) => s[1] - m[1]).slice(0, t).map(([m]) => ({
|
|
141
|
+
x: m >> 22 & 1023,
|
|
142
|
+
y: m >> 12 & 1023,
|
|
143
|
+
z: m & 4095
|
|
144
144
|
})), origRequestCount: i.size };
|
|
145
145
|
}
|
|
146
|
-
class
|
|
146
|
+
class et {
|
|
147
147
|
constructor(t) {
|
|
148
|
-
|
|
148
|
+
k("CLASS INITIALIZING"), n.debug("VolumeDataManager constructor", { glParam: t, glParamContext: t.getContext?.() });
|
|
149
149
|
const e = t.getContext?.() || t, i = t;
|
|
150
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 = {
|
|
151
151
|
getParameter: (o) => ({
|
|
@@ -222,7 +222,7 @@ class Qe {
|
|
|
222
222
|
// l0 z extent
|
|
223
223
|
zTotal: 0
|
|
224
224
|
// original z extent plus the l0 z extent times the channel count
|
|
225
|
-
}, 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(le).fill(0), this.BCMinMax = new Array(le).fill([0, 0]), this.BCFull = !1, this.BCUnusedIndex = 0, this.bc2pt = new Array(le).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 = F.NOT_STARTED, this.initError = null, this._lastChannelConfig = null, this.currentRequestCount = 0, this.totalBricksRequested = 0, k("VolumeDataManager constructor complete");
|
|
226
226
|
}
|
|
227
227
|
/**
|
|
228
228
|
* Get loading progress information
|
|
@@ -255,7 +255,7 @@ class Qe {
|
|
|
255
255
|
* Handle WebGL context loss
|
|
256
256
|
*/
|
|
257
257
|
_handleContextLost(t) {
|
|
258
|
-
|
|
258
|
+
k("CONTEXT LOST"), n.warn("WebGL context lost, preventing default and setting flag"), t.preventDefault(), this._isContextLost = !0, this.channels && this.channels.zarrMappings && (this._lastChannelConfig = {
|
|
259
259
|
zarrMappings: [...this.channels.zarrMappings],
|
|
260
260
|
colorMappings: [...this.channels.colorMappings],
|
|
261
261
|
downsampleMin: [...this.channels.downsampleMin],
|
|
@@ -266,7 +266,7 @@ class Qe {
|
|
|
266
266
|
* Handle WebGL context restoration
|
|
267
267
|
*/
|
|
268
268
|
_handleContextRestored(t) {
|
|
269
|
-
if (
|
|
269
|
+
if (k("CONTEXT RESTORED"), n.warn("WebGL context restored, reinitializing textures"), this._isContextLost = !1, this._originalGlParam && this._originalGlParam.getContext && (this.gl = this._originalGlParam.getContext()), this._lastChannelConfig && (this.channels.zarrMappings = [...this._lastChannelConfig.zarrMappings], this.channels.colorMappings = [...this._lastChannelConfig.colorMappings], this.channels.downsampleMin = [...this._lastChannelConfig.downsampleMin], this.channels.downsampleMax = [...this._lastChannelConfig.downsampleMax], n.debug("Restored channel configuration after context loss")), this.PT && this.zarrStore && this.zarrStore.brickLayout)
|
|
270
270
|
try {
|
|
271
271
|
this.initMRMCPT(), n.debug("Successfully reinitialized MRMCPT after context restoration");
|
|
272
272
|
} catch (e) {
|
|
@@ -293,7 +293,7 @@ class Qe {
|
|
|
293
293
|
typeof t == "function" && this._contextRestoredCallbacks.push(t);
|
|
294
294
|
}
|
|
295
295
|
initImages(t, e) {
|
|
296
|
-
|
|
296
|
+
k("INIT IMAGES"), this.images = t, this.imageLayerScopes = e;
|
|
297
297
|
}
|
|
298
298
|
/**
|
|
299
299
|
* Initialize the VolumeDataManager with Zarr store details and device limits
|
|
@@ -302,8 +302,8 @@ class Qe {
|
|
|
302
302
|
* @returns {Promise<Object>} Object with Zarr store details and device limits
|
|
303
303
|
*/
|
|
304
304
|
async init(t) {
|
|
305
|
-
if (
|
|
306
|
-
return n.debug("VolumeDataManager init() was called more than once!"), this.initStatus ===
|
|
305
|
+
if (k("INIT()"), this.initStatus !== F.NOT_STARTED)
|
|
306
|
+
return n.debug("VolumeDataManager init() was called more than once!"), this.initStatus === F.COMPLETE ? {
|
|
307
307
|
success: !0,
|
|
308
308
|
deviceLimits: this.deviceLimits,
|
|
309
309
|
zarrStore: this.zarrStore,
|
|
@@ -311,7 +311,7 @@ class Qe {
|
|
|
311
311
|
physicalSizeTotal: this.zarrStore.physicalSizeTotal,
|
|
312
312
|
physicalSizeVoxel: this.zarrStore.physicalSizeVoxel,
|
|
313
313
|
error: null
|
|
314
|
-
} : this.initStatus ===
|
|
314
|
+
} : this.initStatus === F.FAILED ? {
|
|
315
315
|
success: !1,
|
|
316
316
|
error: this.initError || "Unknown initialization error"
|
|
317
317
|
} : {
|
|
@@ -319,28 +319,28 @@ class Qe {
|
|
|
319
319
|
pending: !0,
|
|
320
320
|
error: "Initialization in progress"
|
|
321
321
|
};
|
|
322
|
-
this.initStatus =
|
|
322
|
+
this.initStatus = F.IN_PROGRESS, k("INIT() IN PROGRESS");
|
|
323
323
|
try {
|
|
324
324
|
const e = this.images?.[this.imageLayerScopes?.[0]]?.image?.instance;
|
|
325
325
|
if (this.ngffMetadata = e.vivLoader.metadata, n.debug("ngffMetadata", this.ngffMetadata), !e || e.getType() !== "ome-zarr")
|
|
326
326
|
throw new Error("Invalid imageWrapper or not an OME-Zarr image");
|
|
327
|
-
const i = e.getMultiResolutionStats(), o =
|
|
327
|
+
const i = e.getMultiResolutionStats(), o = Ye(i), r = i.length;
|
|
328
328
|
this.zarrStore.resolutions = r;
|
|
329
329
|
const a = e.getData();
|
|
330
330
|
if (!Array.isArray(a) || a.length < 1)
|
|
331
331
|
throw new Error("Not a multiresolution loader");
|
|
332
|
-
if (!
|
|
332
|
+
if (!Pe(a[0].labels, ["t", "c", "z", "y", "x"]))
|
|
333
333
|
throw new Error("Expected OME-Zarr data with dimensions [t, c, z, y, x]");
|
|
334
334
|
n.debug("vivData", a);
|
|
335
|
-
const
|
|
336
|
-
if (
|
|
337
|
-
const
|
|
335
|
+
const c = a.map((l) => l._data), u = new Array(r).fill(null);
|
|
336
|
+
if (c.length > 0) {
|
|
337
|
+
const l = c[0];
|
|
338
338
|
if (this.zarrStore = {
|
|
339
339
|
resolutions: r,
|
|
340
|
-
chunkSize:
|
|
340
|
+
chunkSize: l.chunks,
|
|
341
341
|
shapes: o,
|
|
342
|
-
arrays:
|
|
343
|
-
dtype:
|
|
342
|
+
arrays: c,
|
|
343
|
+
dtype: l.dtype,
|
|
344
344
|
physicalSizeTotal: [],
|
|
345
345
|
// Will be populated if metadata exists
|
|
346
346
|
physicalSizeVoxel: [],
|
|
@@ -351,58 +351,58 @@ class Qe {
|
|
|
351
351
|
// group: this.group,
|
|
352
352
|
channelCount: o[0][1],
|
|
353
353
|
scales: u
|
|
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),
|
|
355
|
-
const { x: d, y:
|
|
356
|
-
this.zarrStore.physicalSizeVoxel = [
|
|
357
|
-
(
|
|
358
|
-
(
|
|
359
|
-
(
|
|
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), l.meta && l.meta.physicalSizes) {
|
|
355
|
+
const { x: d, y: v, z: h } = l.meta.physicalSizes, g = h?.size || 1, b = v?.size || 1, R = d?.size || 1;
|
|
356
|
+
this.zarrStore.physicalSizeVoxel = [g, b, R], l.shape && l.shape.length >= 5 && (this.zarrStore.physicalSizeTotal = [
|
|
357
|
+
(l.shape[2] || 1) * g,
|
|
358
|
+
(l.shape[3] || 1) * b,
|
|
359
|
+
(l.shape[4] || 1) * R
|
|
360
360
|
]);
|
|
361
361
|
} else
|
|
362
362
|
this.zarrStore.physicalSizeVoxel = [1, 1, 1], this.zarrStore.physicalSizeTotal = [
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
363
|
+
l.shape[2] || 1,
|
|
364
|
+
l.shape[3] || 1,
|
|
365
|
+
l.shape[4] || 1
|
|
366
366
|
];
|
|
367
|
-
const { multiscales:
|
|
368
|
-
if (!
|
|
367
|
+
const { multiscales: p } = this.ngffMetadata;
|
|
368
|
+
if (!p)
|
|
369
369
|
throw new Error("Expected multiscales metadata in group.attrs");
|
|
370
|
-
if (
|
|
370
|
+
if (p?.[0]?.datasets?.[0]?.coordinateTransformations) {
|
|
371
371
|
for (let d = 0; d < r; d++)
|
|
372
|
-
if (
|
|
373
|
-
const { scale:
|
|
374
|
-
u[d] = [
|
|
372
|
+
if (p?.[0]?.datasets?.[d]?.coordinateTransformations?.[0]?.scale) {
|
|
373
|
+
const { scale: v } = p[0].datasets[d].coordinateTransformations[0];
|
|
374
|
+
u[d] = [v[4], v[3], v[2]];
|
|
375
375
|
}
|
|
376
376
|
} else {
|
|
377
377
|
n.error("no coordinateTransformations available, assuming downsampling ratio of 2 per dimension");
|
|
378
378
|
for (let d = 0; d < r; d++) {
|
|
379
|
-
const
|
|
380
|
-
u[d] = [
|
|
379
|
+
const v = 2 ** d;
|
|
380
|
+
u[d] = [v, v, v];
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
this.zarrStore.scales = u;
|
|
384
|
-
const { coordinateTransformations:
|
|
385
|
-
if (
|
|
386
|
-
const { scale: d } =
|
|
387
|
-
if (
|
|
388
|
-
const h = d[
|
|
389
|
-
this.zarrStore.physicalSizeVoxel = [h,
|
|
390
|
-
(
|
|
391
|
-
(
|
|
392
|
-
(
|
|
384
|
+
const { coordinateTransformations: m } = this.ngffMetadata;
|
|
385
|
+
if (m?.[0]?.scale) {
|
|
386
|
+
const { scale: d } = m[0], v = d.length;
|
|
387
|
+
if (v >= 3) {
|
|
388
|
+
const h = d[v - 3], g = d[v - 2], b = d[v - 1];
|
|
389
|
+
this.zarrStore.physicalSizeVoxel = [h, g, b], l.shape && l.shape.length >= 5 && (this.zarrStore.physicalSizeTotal = [
|
|
390
|
+
(l.shape[2] || 1) * h,
|
|
391
|
+
(l.shape[3] || 1) * g,
|
|
392
|
+
(l.shape[4] || 1) * b
|
|
393
393
|
]);
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
|
-
this.zarrStore.brickLayout =
|
|
397
|
-
const { omero:
|
|
398
|
-
if (!
|
|
396
|
+
this.zarrStore.brickLayout = He(e.getMultiResolutionStats()), n.debug("config", t);
|
|
397
|
+
const { omero: s } = this.ngffMetadata || {};
|
|
398
|
+
if (!s)
|
|
399
399
|
throw new Error("Expected omero metadata in ngffMetadata");
|
|
400
|
-
n.debug("omero",
|
|
400
|
+
n.debug("omero", s), Object.keys(t).forEach((d, v) => {
|
|
401
401
|
const h = t[d].spatialTargetC;
|
|
402
|
-
this.channels.zarrMappings[
|
|
402
|
+
this.channels.zarrMappings[v] = h, this.channels.colorMappings[v] = v, this.channels.downsampleMin[v] = s?.channels?.[h]?.window?.min || 0, this.channels.downsampleMax[v] = s?.channels?.[h]?.window?.max || 65535;
|
|
403
403
|
}), 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();
|
|
404
404
|
}
|
|
405
|
-
return this.initStatus =
|
|
405
|
+
return this.initStatus = F.COMPLETE, k("INIT() COMPLETE"), {
|
|
406
406
|
success: !0,
|
|
407
407
|
deviceLimits: this.deviceLimits,
|
|
408
408
|
zarrStore: this.zarrStore,
|
|
@@ -412,7 +412,7 @@ class Qe {
|
|
|
412
412
|
error: null
|
|
413
413
|
};
|
|
414
414
|
} catch (e) {
|
|
415
|
-
return
|
|
415
|
+
return k("INIT() FAILED"), n.error("Error initializing VolumeDataManager:", e), this.initStatus = F.FAILED, this.initError = e.message || "Unknown error", {
|
|
416
416
|
success: !1,
|
|
417
417
|
error: this.initError
|
|
418
418
|
};
|
|
@@ -428,51 +428,51 @@ class Qe {
|
|
|
428
428
|
* -
|
|
429
429
|
*/
|
|
430
430
|
initMRMCPT() {
|
|
431
|
-
|
|
432
|
-
const { PT: t, ptTHREE: e, bcTHREE: i } =
|
|
433
|
-
this.PT = t, this.ptTHREE = e, this.bcTHREE = i,
|
|
431
|
+
k("initMRMCPT");
|
|
432
|
+
const { PT: t, ptTHREE: e, bcTHREE: i } = Ke(this.zarrStore.brickLayout, this.channels.zarrMappings.length);
|
|
433
|
+
this.PT = t, this.ptTHREE = e, this.bcTHREE = i, k("initMRMCPT() COMPLETE");
|
|
434
434
|
}
|
|
435
435
|
async initTexture() {
|
|
436
436
|
const t = [
|
|
437
437
|
{ x: 0, y: 0, z: 1 }
|
|
438
438
|
];
|
|
439
|
-
|
|
439
|
+
k("initTexture - loading first brick"), await this.handleBrickRequests(t);
|
|
440
440
|
}
|
|
441
441
|
updateChannels(t) {
|
|
442
|
-
if (
|
|
442
|
+
if (k("updateChannels"), n.debug("channelProps", t), n.debug("this.channels.zarrMappings", this.channels.zarrMappings), n.debug("this.channels.colorMappings", this.channels.colorMappings), n.debug("this.channels.downsampleMin", this.channels.downsampleMin), n.debug("this.channels.downsampleMax", this.channels.downsampleMax), this.channels.zarrMappings.length === 0) {
|
|
443
443
|
n.debug("channels not initialized yet");
|
|
444
444
|
return;
|
|
445
445
|
}
|
|
446
|
-
const e = Object.values(t).map((
|
|
447
|
-
o.length === r.length && o.every((
|
|
446
|
+
const e = Object.values(t).map((c) => c.spatialTargetC).filter((c) => c !== void 0), i = this.channels.zarrMappings.filter((c) => c !== void 0), o = [...new Set(e)].sort((c, u) => c - u), r = [...new Set(i)].sort((c, u) => c - u);
|
|
447
|
+
o.length === r.length && o.every((c, u) => c === r[u]) && n.debug("Channel mappings unchanged, skipping update"), n.debug("Channel mappings changed:", {
|
|
448
448
|
current: r,
|
|
449
449
|
requested: o
|
|
450
|
-
}), Object.entries(t).forEach(([
|
|
451
|
-
const
|
|
452
|
-
n.debug(`UI channel "${
|
|
453
|
-
const
|
|
454
|
-
if (
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
457
|
-
this.channels.zarrMappings[
|
|
450
|
+
}), Object.entries(t).forEach(([c, u]) => {
|
|
451
|
+
const l = u.spatialTargetC;
|
|
452
|
+
n.debug(`UI channel "${c}" wants zarr channel ${l}`);
|
|
453
|
+
const p = this.channels.zarrMappings.indexOf(l);
|
|
454
|
+
if (p === -1) {
|
|
455
|
+
const m = this.channels.zarrMappings.findIndex((s) => s === void 0);
|
|
456
|
+
if (m !== -1)
|
|
457
|
+
this.channels.zarrMappings[m] = l, n.debug("channelData", u), n.debug("this.ngffMetadata?.omero?.channels", this.ngffMetadata?.omero?.channels), n.debug("targetZarrChannel", l), this.channels.downsampleMin[m] = this.ngffMetadata?.omero?.channels?.[l]?.window?.min || 0, this.channels.downsampleMax[m] = this.ngffMetadata?.omero?.channels?.[l]?.window?.max || 65535, n.debug(`Mapped zarr channel ${l} to slot ${m}`), n.debug("channels", this.channels);
|
|
458
458
|
else {
|
|
459
459
|
n.debug("No free slots found, looking for unused mapped channels");
|
|
460
|
-
const
|
|
461
|
-
if (n.debug("Currently mapped:",
|
|
462
|
-
const h = this.channels.zarrMappings.findIndex((
|
|
460
|
+
const s = this.channels.zarrMappings.filter((h) => h !== void 0), d = e, v = s.filter((h) => !d.includes(h));
|
|
461
|
+
if (n.debug("Currently mapped:", s), n.debug("Still requested:", d), n.debug("Unused mapped channels:", v), v.length > 0) {
|
|
462
|
+
const h = this.channels.zarrMappings.findIndex((g) => v.includes(g));
|
|
463
463
|
if (h !== -1) {
|
|
464
|
-
const
|
|
465
|
-
this.channels.zarrMappings[h] =
|
|
464
|
+
const g = this.channels.zarrMappings[h];
|
|
465
|
+
this.channels.zarrMappings[h] = l, this.channels.downsampleMin[h] = this.ngffMetadata?.omero?.channels?.[l]?.window?.min || 0, this.channels.downsampleMax[h] = this.ngffMetadata?.omero?.channels?.[l]?.window?.max || 65535, n.debug(`Reused slot ${h}: ${g} -> ${l}`), this._purgeChannel(h);
|
|
466
466
|
} else
|
|
467
467
|
n.error("Could not find slot to reuse - this should not happen");
|
|
468
468
|
} else
|
|
469
469
|
n.error("All slots are full and all mapped channels are still in use");
|
|
470
470
|
}
|
|
471
471
|
} else
|
|
472
|
-
n.debug(`Zarr channel ${
|
|
472
|
+
n.debug(`Zarr channel ${l} already mapped to slot ${p}`);
|
|
473
473
|
});
|
|
474
|
-
const a = Object.values(t).map((
|
|
475
|
-
const u = this.channels.zarrMappings.indexOf(
|
|
474
|
+
const a = Object.values(t).map((c) => {
|
|
475
|
+
const u = this.channels.zarrMappings.indexOf(c.spatialTargetC);
|
|
476
476
|
return u !== -1 ? u : -1;
|
|
477
477
|
});
|
|
478
478
|
for (; a.length < 7; )
|
|
@@ -536,7 +536,7 @@ class Qe {
|
|
|
536
536
|
return n.debug("out", t), t;
|
|
537
537
|
}
|
|
538
538
|
getOriginalScaleXYZ() {
|
|
539
|
-
|
|
539
|
+
k("getOriginalScaleXYZ"), n.debug("this.zarrStore.physicalSizeVoxel", this.zarrStore.physicalSizeVoxel);
|
|
540
540
|
const t = [
|
|
541
541
|
this.zarrStore.physicalSizeVoxel[2],
|
|
542
542
|
this.zarrStore.physicalSizeVoxel[1],
|
|
@@ -579,7 +579,7 @@ class Qe {
|
|
|
579
579
|
const u = await this.zarrStore.arrays[a].getChunk([t, e, i, o, r]);
|
|
580
580
|
if (!u)
|
|
581
581
|
throw new Error(`No chunk found at coordinates [${t},${e},${i},${o},${r}]`);
|
|
582
|
-
if (u.data.length !==
|
|
582
|
+
if (u.data.length !== w * w * w)
|
|
583
583
|
throw new Error(`Unexpected chunk size: ${u.data.length}`);
|
|
584
584
|
return u.data;
|
|
585
585
|
}
|
|
@@ -596,6 +596,10 @@ class Qe {
|
|
|
596
596
|
* the center of the render target.
|
|
597
597
|
*/
|
|
598
598
|
async processRequestData(t, e) {
|
|
599
|
+
if (this.initStatus !== F.COMPLETE) {
|
|
600
|
+
n.debug("processRequestData: not yet initialized, skipping");
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
599
603
|
if (this.isBusy) {
|
|
600
604
|
n.debug("processRequestData: already busy, skipping");
|
|
601
605
|
return;
|
|
@@ -609,7 +613,7 @@ class Qe {
|
|
|
609
613
|
return;
|
|
610
614
|
}
|
|
611
615
|
this.isBusy = !0, this.triggerRequest = !1;
|
|
612
|
-
const { requests: i, origRequestCount: o } =
|
|
616
|
+
const { requests: i, origRequestCount: o } = Je(t, this.k, e);
|
|
613
617
|
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;
|
|
614
618
|
}
|
|
615
619
|
async processUsageData(t) {
|
|
@@ -624,10 +628,10 @@ class Qe {
|
|
|
624
628
|
this.isBusy = !0, this.triggerUsage = !1;
|
|
625
629
|
const e = ++this.timeStamp, i = /* @__PURE__ */ new Set();
|
|
626
630
|
for (let o = 0; o < t.length; o += 4) {
|
|
627
|
-
const r = t[o], a = t[o + 1],
|
|
628
|
-
if ((r | a |
|
|
631
|
+
const r = t[o], a = t[o + 1], c = t[o + 2];
|
|
632
|
+
if ((r | a | c) === 0)
|
|
629
633
|
continue;
|
|
630
|
-
const u =
|
|
634
|
+
const u = c * A * q + a * A + r;
|
|
631
635
|
u < this.BCTimeStamps.length && i.add(u);
|
|
632
636
|
}
|
|
633
637
|
Array.from(i).forEach((o) => {
|
|
@@ -663,8 +667,8 @@ class Qe {
|
|
|
663
667
|
this.PT.anchors[r][0] * e[0]
|
|
664
668
|
];
|
|
665
669
|
n.debug("anchor", a);
|
|
666
|
-
const
|
|
667
|
-
n.debug("extents",
|
|
670
|
+
const c = this.zarrStore.brickLayout[r], u = c[0] * c[1] * c[2];
|
|
671
|
+
n.debug("extents", c), n.debug("size", u), i.texSubImage3D(i.TEXTURE_3D, 0, a[0], a[1], a[2], c[0], c[1], c[2], i.RED_INTEGER, i.UNSIGNED_INT, new Uint32Array(u));
|
|
668
672
|
}
|
|
669
673
|
i.bindTexture(i.TEXTURE_3D, null);
|
|
670
674
|
}
|
|
@@ -689,17 +693,17 @@ class Qe {
|
|
|
689
693
|
*/
|
|
690
694
|
_allocateBCSlots(t) {
|
|
691
695
|
let e = [];
|
|
692
|
-
const i =
|
|
696
|
+
const i = A * q * he;
|
|
693
697
|
if (!this.BCFull && this.BCUnusedIndex + t > i && (this.BCFull = !0, n.debug("BRICK CACHE FULL")), this.BCFull)
|
|
694
698
|
this.LRUStack.length < t && this._buildLRU(), e = this.LRUStack.splice(0, t).map((o) => {
|
|
695
699
|
this._evictBrick(o);
|
|
696
|
-
const r = Math.floor(o / (
|
|
697
|
-
return { bcIndex: o, x: u, y:
|
|
700
|
+
const r = Math.floor(o / (A * q)), a = o - r * A * q, c = Math.floor(a / A), u = a % A;
|
|
701
|
+
return { bcIndex: o, x: u, y: c, z: r };
|
|
698
702
|
});
|
|
699
703
|
else {
|
|
700
704
|
for (let o = 0; o < t; ++o) {
|
|
701
|
-
const r = (this.BCUnusedIndex + o) % i, a = Math.floor(r / (
|
|
702
|
-
e.push({ bcIndex: r, x:
|
|
705
|
+
const r = (this.BCUnusedIndex + o) % i, a = Math.floor(r / (A * q)), c = r - a * A * q, u = Math.floor(c / A), l = c % A;
|
|
706
|
+
e.push({ bcIndex: r, x: l, y: u, z: a });
|
|
703
707
|
}
|
|
704
708
|
this.BCUnusedIndex += t;
|
|
705
709
|
}
|
|
@@ -717,7 +721,7 @@ class Qe {
|
|
|
717
721
|
n.error("this.PT", this.PT), n.error("ptCoord out of bounds", t);
|
|
718
722
|
return;
|
|
719
723
|
}
|
|
720
|
-
const { channel: i, resolution: o, x: r, y: a, z:
|
|
724
|
+
const { channel: i, resolution: o, x: r, y: a, z: c } = $e(t.x, t.y, t.z, { PT_zExtent: this.PT.zExtent, PT_z0Extent: this.PT.z0Extent, PT_anchors: this.PT.anchors });
|
|
721
725
|
if (!this.channels || !this.channels.zarrMappings || this.channels.zarrMappings.length === 0) {
|
|
722
726
|
n.error("Channel mappings not initialized, skipping brick upload");
|
|
723
727
|
return;
|
|
@@ -747,35 +751,35 @@ class Qe {
|
|
|
747
751
|
n.error("No fallback channel config available, aborting brick upload");
|
|
748
752
|
return;
|
|
749
753
|
}
|
|
750
|
-
n.debug("starting to load zarr chunk", { resolution: o, z:
|
|
751
|
-
let
|
|
752
|
-
if (n.debug("chunk",
|
|
754
|
+
n.debug("starting to load zarr chunk", { resolution: o, z: c, y: a, x: r, zarrChannel: u });
|
|
755
|
+
let l = await this.loadZarrChunk(0, u, c, a, r, o);
|
|
756
|
+
if (n.debug("chunk", l), l instanceof Uint16Array) {
|
|
753
757
|
if (n.debug("chunk is Uint16Array, converting to Uint8Array"), this.channels.downsampleMin[i] === void 0) {
|
|
754
758
|
const T = this.channels.zarrMappings[i];
|
|
755
759
|
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]);
|
|
756
760
|
}
|
|
757
|
-
const R = new Uint16Array(
|
|
761
|
+
const R = new Uint16Array(l.buffer), y = new Uint8Array(l.length), B = this.channels.downsampleMin[i], U = this.channels.downsampleMax[i], L = U - B;
|
|
758
762
|
for (let T = 0; T < R.length; T++) {
|
|
759
|
-
const
|
|
760
|
-
|
|
763
|
+
const N = R[T], G = Math.max(B, Math.min(U, N));
|
|
764
|
+
y[T] = (G - B) * 255 / L | 0;
|
|
761
765
|
}
|
|
762
|
-
|
|
766
|
+
l = y;
|
|
763
767
|
}
|
|
764
|
-
if (!(
|
|
765
|
-
throw new Error(`Unsupported chunk type: ${
|
|
766
|
-
let
|
|
767
|
-
for (let R = 0; R <
|
|
768
|
-
const
|
|
769
|
-
|
|
768
|
+
if (!(l instanceof Uint8Array))
|
|
769
|
+
throw new Error(`Unsupported chunk type: ${l.constructor.name}. Expected Uint8Array.`);
|
|
770
|
+
let p = 255, m = 0;
|
|
771
|
+
for (let R = 0; R < l.length; ++R) {
|
|
772
|
+
const y = l[R];
|
|
773
|
+
y < p && (p = y), y > m && (m = y);
|
|
770
774
|
}
|
|
771
|
-
const { gl:
|
|
772
|
-
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
const h =
|
|
776
|
-
|
|
777
|
-
const b =
|
|
778
|
-
b !==
|
|
775
|
+
const { gl: s } = this, d = this.renderer.properties.get(this.bcTHREE).__webglTexture;
|
|
776
|
+
s.activeTexture(s.TEXTURE2), s.bindTexture(s.TEXTURE_3D, d), s.pixelStorei(s.UNPACK_ALIGNMENT, 1), s.texSubImage3D(s.TEXTURE_3D, 0, e.x * w, e.y * w, e.z * w, w, w, w, s.RED, s.UNSIGNED_BYTE, l), s.pixelStorei(s.UNPACK_ALIGNMENT, 4), s.bindTexture(s.TEXTURE_3D, null);
|
|
777
|
+
const v = s.getError();
|
|
778
|
+
v !== s.NO_ERROR && n.error("WebGL error during brick upload:", v, l), i >= this.channels.zarrMappings.length && (n.debug("channel is out of bounds", i), p = 255, m = 255);
|
|
779
|
+
const h = We(p, m, e.x, e.y, e.z), g = this.renderer.properties.get(this.ptTHREE).__webglTexture;
|
|
780
|
+
s.activeTexture(s.TEXTURE0), s.bindTexture(s.TEXTURE_3D, g), s.texSubImage3D(s.TEXTURE_3D, 0, t.x, t.y, t.z, 1, 1, 1, s.RED_INTEGER, s.UNSIGNED_INT, new Uint32Array([h])), s.bindTexture(s.TEXTURE_3D, null);
|
|
781
|
+
const b = s.getError();
|
|
782
|
+
b !== s.NO_ERROR && n.error("WebGL error during pagetable upload:", b, l), this.BCTimeStamps[e.bcIndex] = this.timeStamp, this.BCMinMax[e.bcIndex] = [p, m], this.bc2pt[e.bcIndex] = t;
|
|
779
783
|
}
|
|
780
784
|
/* ------------------------------------------------------------- *
|
|
781
785
|
* 5. Public: handle a batch of PT requests (array of {x,y,z}) *
|
|
@@ -804,7 +808,7 @@ class Qe {
|
|
|
804
808
|
this.LRUStack = t.sort((e, i) => e.time - i.time).slice(0, this.k).map((e) => e.index);
|
|
805
809
|
}
|
|
806
810
|
}
|
|
807
|
-
const
|
|
811
|
+
const tt = `//
|
|
808
812
|
// Output: Unnormalized ray direction from camera to each vertex
|
|
809
813
|
// Used by fragment shader for ray marching through the volume
|
|
810
814
|
out vec3 rayDirUnnorm;
|
|
@@ -863,7 +867,7 @@ void main()
|
|
|
863
867
|
// Pass through texture coordinates for volume sampling
|
|
864
868
|
vUv = uv;
|
|
865
869
|
}
|
|
866
|
-
`,
|
|
870
|
+
`, nt = `//
|
|
867
871
|
// #include <packing>
|
|
868
872
|
precision highp float;
|
|
869
873
|
precision highp int;
|
|
@@ -2428,7 +2432,7 @@ void main(void) {
|
|
|
2428
2432
|
outColor.a);
|
|
2429
2433
|
|
|
2430
2434
|
}
|
|
2431
|
-
`,
|
|
2435
|
+
`, rt = {
|
|
2432
2436
|
uniforms: {
|
|
2433
2437
|
u_size: { value: new C(1, 1, 1) },
|
|
2434
2438
|
clim0: { value: new _(0.2, 0.8) },
|
|
@@ -2448,13 +2452,13 @@ void main(void) {
|
|
|
2448
2452
|
u_renderstyle: { value: 2 },
|
|
2449
2453
|
brickCacheTex: { type: "sampler3D", value: null },
|
|
2450
2454
|
pageTableTex: { type: "usampler3D", value: null },
|
|
2451
|
-
color0: { value: new
|
|
2452
|
-
color1: { value: new
|
|
2453
|
-
color2: { value: new
|
|
2454
|
-
color3: { value: new
|
|
2455
|
-
color4: { value: new
|
|
2456
|
-
color5: { value: new
|
|
2457
|
-
color6: { value: new
|
|
2455
|
+
color0: { value: new j(0, 0, 0) },
|
|
2456
|
+
color1: { value: new j(0, 0, 0) },
|
|
2457
|
+
color2: { value: new j(0, 0, 0) },
|
|
2458
|
+
color3: { value: new j(0, 0, 0) },
|
|
2459
|
+
color4: { value: new j(0, 0, 0) },
|
|
2460
|
+
color5: { value: new j(0, 0, 0) },
|
|
2461
|
+
color6: { value: new j(0, 0, 0) },
|
|
2458
2462
|
channelMapping: {
|
|
2459
2463
|
value: [-1, -1, -1, -1, -1, -1, -1]
|
|
2460
2464
|
},
|
|
@@ -2496,24 +2500,24 @@ void main(void) {
|
|
|
2496
2500
|
scale8: { value: new C(256, 256, 256) },
|
|
2497
2501
|
scale9: { value: new C(512, 512, 512) }
|
|
2498
2502
|
},
|
|
2499
|
-
vertexShader:
|
|
2500
|
-
fragmentShader:
|
|
2503
|
+
vertexShader: tt,
|
|
2504
|
+
fragmentShader: nt
|
|
2501
2505
|
};
|
|
2502
|
-
function
|
|
2503
|
-
|
|
2506
|
+
function P(f) {
|
|
2507
|
+
ce(ue.DEBUG) && console.warn(`%cRM: ${f}`, "background: orange; color: white; padding: 2px; border-radius: 3px;");
|
|
2504
2508
|
}
|
|
2505
|
-
function
|
|
2509
|
+
function ie(f, t) {
|
|
2506
2510
|
return f / t[1];
|
|
2507
2511
|
}
|
|
2508
|
-
class
|
|
2512
|
+
class it {
|
|
2509
2513
|
constructor() {
|
|
2510
|
-
|
|
2514
|
+
P("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();
|
|
2511
2515
|
}
|
|
2512
2516
|
/**
|
|
2513
2517
|
* Initialize shader and uniform objects
|
|
2514
2518
|
*/
|
|
2515
2519
|
initializeShader() {
|
|
2516
|
-
|
|
2520
|
+
P("Initializing shader"), this.shader = rt, this.uniforms = Ue.clone(this.shader.uniforms);
|
|
2517
2521
|
}
|
|
2518
2522
|
/**
|
|
2519
2523
|
* Extract rendering settings from coordination props
|
|
@@ -2521,61 +2525,61 @@ class nt {
|
|
|
2521
2525
|
* @returns {Object} Extracted rendering settings
|
|
2522
2526
|
*/
|
|
2523
2527
|
extractRenderingSettingsFromProps(t) {
|
|
2524
|
-
const { images: e = {}, imageLayerScopes: i = [], imageLayerCoordination: o = [{}], imageChannelScopesByLayer: r = {}, imageChannelCoordination: a = [{}], spatialRenderingMode:
|
|
2528
|
+
const { images: e = {}, imageLayerScopes: i = [], imageLayerCoordination: o = [{}], imageChannelScopesByLayer: r = {}, imageChannelCoordination: a = [{}], spatialRenderingMode: c } = t, u = i[0];
|
|
2525
2529
|
if (!u)
|
|
2526
|
-
return
|
|
2530
|
+
return P("Extracting rendering settings from props - no layer scope"), {
|
|
2527
2531
|
valid: !1
|
|
2528
2532
|
};
|
|
2529
|
-
const
|
|
2530
|
-
if (!
|
|
2531
|
-
return
|
|
2533
|
+
const l = r[u], p = o[0][u], m = a[0][u], s = e[u]?.image?.instance?.getData();
|
|
2534
|
+
if (!s)
|
|
2535
|
+
return P("Extracting rendering settings from props - no image data"), {
|
|
2532
2536
|
valid: !1
|
|
2533
2537
|
};
|
|
2534
|
-
if (!
|
|
2535
|
-
return
|
|
2538
|
+
if (!m[l?.[0]][M.SPATIAL_CHANNEL_WINDOW])
|
|
2539
|
+
return P("Extracting rendering settings from props - no channel window set"), {
|
|
2536
2540
|
valid: !1
|
|
2537
2541
|
};
|
|
2538
|
-
const d = e[u].image.instance,
|
|
2542
|
+
const d = e[u].image.instance, v = c === "3D", h = p[M.PHOTOMETRIC_INTERPRETATION] === "RGB", g = p[M.SPATIAL_LAYER_VISIBLE], b = p[M.SPATIAL_LAYER_OPACITY], R = h ? [
|
|
2539
2543
|
[255, 0, 0],
|
|
2540
2544
|
[0, 255, 0],
|
|
2541
2545
|
[0, 0, 255]
|
|
2542
|
-
] :
|
|
2546
|
+
] : l.map((S) => m[S][M.SPATIAL_CHANNEL_COLOR]), y = h ? [
|
|
2543
2547
|
[0, 255],
|
|
2544
2548
|
[0, 255],
|
|
2545
2549
|
[0, 255]
|
|
2546
|
-
] :
|
|
2547
|
-
this.maxRangeSet || (this.maxRange = Math.max(...
|
|
2548
|
-
const
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
] :
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
] :
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
] :
|
|
2561
|
-
let T =
|
|
2562
|
-
const Y =
|
|
2563
|
-
T = T !== null ? T : new _(-1, 1e5),
|
|
2564
|
-
const
|
|
2565
|
-
return
|
|
2550
|
+
] : l.map((S) => m[S][M.SPATIAL_CHANNEL_WINDOW] || [0, 255]);
|
|
2551
|
+
this.maxRangeSet || (this.maxRange = Math.max(...y.map((S) => S[1])), this.maxRangeSet = !0);
|
|
2552
|
+
const B = h ? [
|
|
2553
|
+
g && !0,
|
|
2554
|
+
g && !0,
|
|
2555
|
+
g && !0
|
|
2556
|
+
] : l.map((S) => g && m[S][M.SPATIAL_CHANNEL_VISIBLE]), U = h ? [
|
|
2557
|
+
g && !0,
|
|
2558
|
+
g && !0,
|
|
2559
|
+
g && !0
|
|
2560
|
+
] : l.map((S) => g && d.getChannelIndex(m[S][M.SPATIAL_TARGET_C])), L = h ? [
|
|
2561
|
+
g && null,
|
|
2562
|
+
g && null,
|
|
2563
|
+
g && null
|
|
2564
|
+
] : l.map((S) => m[S][M.SPATIAL_MAX_RESOLUTION]);
|
|
2565
|
+
let T = p[M.SPATIAL_SLICE_X], N = p[M.SPATIAL_SLICE_Y], G = p[M.SPATIAL_SLICE_Z];
|
|
2566
|
+
const Y = p[M.SPATIAL_LOD_FACTOR] ?? 1;
|
|
2567
|
+
T = T !== null ? T : new _(-1, 1e5), N = N !== null ? N : new _(-1, 1e5), G = G !== null ? G : new _(-1, 1e5);
|
|
2568
|
+
const Z = e[u].image.loaders[0].channels;
|
|
2569
|
+
return P("Extracting rendering settings from props - success"), {
|
|
2566
2570
|
valid: !0,
|
|
2567
|
-
channelsVisible:
|
|
2568
|
-
allChannels:
|
|
2569
|
-
channelTargetC:
|
|
2570
|
-
channelMaxResolutionIndex:
|
|
2571
|
-
data:
|
|
2571
|
+
channelsVisible: B,
|
|
2572
|
+
allChannels: Z,
|
|
2573
|
+
channelTargetC: U,
|
|
2574
|
+
channelMaxResolutionIndex: L,
|
|
2575
|
+
data: s,
|
|
2572
2576
|
colors: R,
|
|
2573
|
-
contrastLimits:
|
|
2574
|
-
is3dMode:
|
|
2577
|
+
contrastLimits: y,
|
|
2578
|
+
is3dMode: v,
|
|
2575
2579
|
layerTransparency: b,
|
|
2576
2580
|
xSlice: T,
|
|
2577
|
-
ySlice:
|
|
2578
|
-
zSlice:
|
|
2581
|
+
ySlice: N,
|
|
2582
|
+
zSlice: G,
|
|
2579
2583
|
lodFactor: Y
|
|
2580
2584
|
};
|
|
2581
2585
|
}
|
|
@@ -2586,59 +2590,59 @@ class nt {
|
|
|
2586
2590
|
*/
|
|
2587
2591
|
updateFromProps(t) {
|
|
2588
2592
|
const e = this.extractRenderingSettingsFromProps(t);
|
|
2589
|
-
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,
|
|
2593
|
+
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, P(`lodFactor ${e.lodFactor}`), this.shader.uniforms.lodFactor.value = e.lodFactor, P("Updating from props - success"), !0) : (P("Updating from props - invalid settings"), !1);
|
|
2590
2594
|
}
|
|
2591
2595
|
/**
|
|
2592
2596
|
* Update the rendering based on the current volume data from the data manager
|
|
2593
2597
|
* @param {object} volumeDataManagerProps - Params derived from the volume data manager
|
|
2594
2598
|
* @returns {Object|null} Updated rendering settings or null if rendering is not possible
|
|
2595
2599
|
*/
|
|
2596
|
-
updateRendering({ zarrStoreShapes: t, originalScaleXYZ: e, physicalDimensionsXYZ: i, maxResolutionXYZ: o, boxDimensionsXYZ: r, normalizedScaleXYZ: a, bcTHREE:
|
|
2597
|
-
if (
|
|
2600
|
+
updateRendering({ zarrStoreShapes: t, originalScaleXYZ: e, physicalDimensionsXYZ: i, maxResolutionXYZ: o, boxDimensionsXYZ: r, normalizedScaleXYZ: a, bcTHREE: c, ptTHREE: u }) {
|
|
2601
|
+
if (P("Updating rendering"), this.channelTargetC.findIndex((v, h) => this.channelsVisible[h]), !Array.isArray(t) || t.length === 0)
|
|
2598
2602
|
return null;
|
|
2599
|
-
const
|
|
2600
|
-
xLength:
|
|
2601
|
-
yLength:
|
|
2602
|
-
zLength:
|
|
2603
|
-
},
|
|
2604
|
-
if (this.channelTargetC.forEach((
|
|
2603
|
+
const l = t[0], p = {
|
|
2604
|
+
xLength: l[4] || 1,
|
|
2605
|
+
yLength: l[3] || 1,
|
|
2606
|
+
zLength: l[2] || 1
|
|
2607
|
+
}, m = [], s = [], d = [];
|
|
2608
|
+
if (this.channelTargetC.forEach((v, h) => {
|
|
2605
2609
|
this.channelsVisible[h];
|
|
2606
2610
|
{
|
|
2607
2611
|
const b = [0, this.maxRange ? this.maxRange : 255];
|
|
2608
|
-
|
|
2612
|
+
s.push([
|
|
2609
2613
|
this.colors[h][0] / 255,
|
|
2610
2614
|
this.colors[h][1] / 255,
|
|
2611
2615
|
this.colors[h][2] / 255,
|
|
2612
2616
|
this.channelsVisible[h] ? 1 : 0
|
|
2613
|
-
]), n.debug("colorsSave",
|
|
2614
|
-
|
|
2615
|
-
|
|
2617
|
+
]), n.debug("colorsSave", s), this.contrastLimits[h][0] === 0 && this.contrastLimits[h][1] === 255 ? d.push([
|
|
2618
|
+
ie(b[0], b),
|
|
2619
|
+
ie(b[1], b)
|
|
2616
2620
|
]) : d.push([
|
|
2617
|
-
|
|
2618
|
-
|
|
2621
|
+
ie(this.contrastLimits[h][0], b),
|
|
2622
|
+
ie(this.contrastLimits[h][1], b)
|
|
2619
2623
|
]);
|
|
2620
2624
|
}
|
|
2621
2625
|
}), !this.zarrInit) {
|
|
2622
2626
|
this.originalScale = e, this.physicalDimensions = i, this.maxResolution = o;
|
|
2623
|
-
const
|
|
2627
|
+
const v = r;
|
|
2624
2628
|
this.normalizedScale = a, this.meshScale = [
|
|
2625
2629
|
this.originalScale[0] / this.originalScale[0],
|
|
2626
2630
|
this.originalScale[1] / this.originalScale[0],
|
|
2627
2631
|
this.originalScale[2] / this.originalScale[0]
|
|
2628
|
-
], this.geometrySize =
|
|
2632
|
+
], this.geometrySize = v, this.boxSize = v, 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", v), this.zarrInit = !0;
|
|
2629
2633
|
}
|
|
2630
2634
|
return this.updateUniforms(
|
|
2631
|
-
|
|
2632
|
-
|
|
2635
|
+
m,
|
|
2636
|
+
p,
|
|
2633
2637
|
// Pass dimensions object instead of volume
|
|
2634
2638
|
this.renderingMode,
|
|
2635
2639
|
d,
|
|
2636
|
-
|
|
2640
|
+
s,
|
|
2637
2641
|
this.layerTransparency,
|
|
2638
2642
|
this.xSlice,
|
|
2639
2643
|
this.ySlice,
|
|
2640
2644
|
this.zSlice,
|
|
2641
|
-
|
|
2645
|
+
c,
|
|
2642
2646
|
u
|
|
2643
2647
|
), {
|
|
2644
2648
|
uniforms: this.uniforms,
|
|
@@ -2660,10 +2664,10 @@ class nt {
|
|
|
2660
2664
|
* @param {Vector2} ySlice - Y clipping plane
|
|
2661
2665
|
* @param {Vector2} zSlice - Z clipping plane
|
|
2662
2666
|
*/
|
|
2663
|
-
updateUniforms(t, e, i, o, r, a,
|
|
2664
|
-
|
|
2665
|
-
for (let
|
|
2666
|
-
typeof this.channelMaxResolutionIndex[
|
|
2667
|
+
updateUniforms(t, e, i, o, r, a, c, u, l, p, m) {
|
|
2668
|
+
P("Updating uniforms"), this.uniforms.boxSize.value.set(this.boxSize[0], this.boxSize[1], this.boxSize[2]), this.uniforms.brickCacheTex.value = p, this.uniforms.pageTableTex.value = m, 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(c[0] * (1 / this.maxResolution[0]) * this.boxSize[0], c[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(l[0] * (1 / this.maxResolution[2]) * this.boxSize[2], l[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);
|
|
2669
|
+
for (let s = 0; s < 7; s++)
|
|
2670
|
+
typeof this.channelMaxResolutionIndex[s] == "number" && this.uniforms[`res${s}`].value.set(Math.max(1, this.channelMaxResolutionIndex[s]), this.zarrStoreNumResolutions - 1);
|
|
2667
2671
|
}
|
|
2668
2672
|
/**
|
|
2669
2673
|
* Sets the processing render target
|
|
@@ -2676,12 +2680,12 @@ class nt {
|
|
|
2676
2680
|
}
|
|
2677
2681
|
*/
|
|
2678
2682
|
setChannelMapping(t) {
|
|
2679
|
-
|
|
2683
|
+
P("setting channel mapping"), n.debug("channelMapping", t), this.uniforms.channelMapping.value = t;
|
|
2680
2684
|
}
|
|
2681
2685
|
// Only called on initialization of the
|
|
2682
2686
|
// VolumeDataManager and VolumeRenderManager for a particular image.
|
|
2683
2687
|
setZarrUniforms(t, e) {
|
|
2684
|
-
|
|
2688
|
+
P("setting zarr uniforms"), n.debug("zarrStore", t), n.debug("PT", e);
|
|
2685
2689
|
for (let i = 0; i <= 9; i++)
|
|
2686
2690
|
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");
|
|
2687
2691
|
n.debug("zarrStore.brickLayout", t.brickLayout), this.zarrStoreNumResolutions = t.brickLayout.length;
|
|
@@ -2694,13 +2698,13 @@ class nt {
|
|
|
2694
2698
|
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);
|
|
2695
2699
|
}
|
|
2696
2700
|
}
|
|
2697
|
-
const
|
|
2701
|
+
const ot = `//
|
|
2698
2702
|
varying vec2 vUv;
|
|
2699
2703
|
void main() {
|
|
2700
2704
|
vUv = uv;
|
|
2701
2705
|
gl_Position = vec4(position, 1.0);
|
|
2702
2706
|
}
|
|
2703
|
-
`,
|
|
2707
|
+
`, at = `//
|
|
2704
2708
|
// Input texture to blur
|
|
2705
2709
|
uniform sampler2D tDiffuse;
|
|
2706
2710
|
// Resolution of the texture (width, height)
|
|
@@ -2890,53 +2894,53 @@ function _e(f, t) {
|
|
|
2890
2894
|
const e = f.properties?.get(t);
|
|
2891
2895
|
return e?.framebuffer || e?.__webglFramebuffer || t.__webglFramebuffer;
|
|
2892
2896
|
}
|
|
2893
|
-
function
|
|
2894
|
-
|
|
2897
|
+
function J(f) {
|
|
2898
|
+
ce(ue.DEBUG) && console.warn(`%cV: ${f}`, "background: deeppink; color: white; padding: 2px; border-radius: 3px;");
|
|
2895
2899
|
}
|
|
2896
|
-
function
|
|
2900
|
+
function st(f, t, e, { mrtRef: i }) {
|
|
2897
2901
|
f.setRenderTarget(i.current), f.clear(!0, !0, !0), f.render(e, t);
|
|
2898
2902
|
}
|
|
2899
|
-
function
|
|
2903
|
+
function lt(f, { screenSceneRef: t, screenCameraRef: e }) {
|
|
2900
2904
|
f.setRenderTarget(null), f.clear(!0, !0, !0), f.render(t.current, e.current);
|
|
2901
2905
|
}
|
|
2902
|
-
function
|
|
2903
|
-
const a = f.getContext(),
|
|
2904
|
-
e.noNewRequests === !0 && !e.manuallyStopped &&
|
|
2906
|
+
function ct(f, { frameRef: t, dataManager: e, mrtRef: i, bufRequest: o, bufUsage: r }) {
|
|
2907
|
+
const a = f.getContext(), c = t.current;
|
|
2908
|
+
e.noNewRequests === !0 && !e.manuallyStopped && c % 100 === 0 && c < 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, {
|
|
2905
2909
|
// If width/height are not yet available,
|
|
2906
2910
|
// processRequestData will proceed without weighting.
|
|
2907
2911
|
width: i?.current?.width,
|
|
2908
2912
|
height: i?.current?.height,
|
|
2909
2913
|
// Default sigmaNormalized = 0.25; can be tuned
|
|
2910
|
-
sigmaNormalized:
|
|
2914
|
+
sigmaNormalized: Qe
|
|
2911
2915
|
})) : 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));
|
|
2912
2916
|
}
|
|
2913
|
-
function
|
|
2914
|
-
const { invalidate: e, isInteracting: i, dataManager: o, spatialRenderingModeChanging: r, meshRef: a, stillRef:
|
|
2915
|
-
if (u.current && (
|
|
2917
|
+
function ut(f, t) {
|
|
2918
|
+
const { invalidate: e, isInteracting: i, dataManager: o, spatialRenderingModeChanging: r, meshRef: a, stillRef: c, screenQuadRef: u, lastSampleRef: l, frameRef: p, lastFrameCountRef: m } = t;
|
|
2919
|
+
if (u.current && (c.current ? u.current.material.uniforms.gaussian.value = 0 : u.current.material.uniforms.gaussian.value = 7), i) {
|
|
2916
2920
|
o.manuallyStopped || (o.noNewRequests = !1, o.triggerUsage = !0);
|
|
2917
2921
|
return;
|
|
2918
2922
|
}
|
|
2919
2923
|
if (r)
|
|
2920
2924
|
return;
|
|
2921
|
-
const
|
|
2925
|
+
const s = a.current?.material?.uniforms, d = s?.renderRes?.value ?? o?.PT?.lowestDataRes;
|
|
2922
2926
|
if (o.noNewRequests) {
|
|
2923
|
-
d !== 0 ? (
|
|
2927
|
+
d !== 0 ? (s && (s.renderRes.value = 0), n.debug("Adaptive Quality: No new requests. Setting renderSpeed to 0 (best quality)."), c.current = !1, u.current.material.uniforms.gaussian.value = 7, e()) : c.current || (n.debug("Adaptive Quality: No new requests and already at best quality. Setting stillRef to true."), c.current = !0, u.current.material.uniforms.gaussian.value = 0);
|
|
2924
2928
|
return;
|
|
2925
2929
|
}
|
|
2926
|
-
|
|
2927
|
-
const
|
|
2928
|
-
if (
|
|
2930
|
+
c.current && (c.current = !1, e());
|
|
2931
|
+
const v = f.getElapsedTime();
|
|
2932
|
+
if (v - l.current < 1)
|
|
2929
2933
|
return;
|
|
2930
|
-
const h =
|
|
2934
|
+
const h = v - l.current, g = p.current - m.current;
|
|
2931
2935
|
let b = 0;
|
|
2932
|
-
h > 0 && (b =
|
|
2933
|
-
const R = b > 100 && d > 0,
|
|
2934
|
-
if (R ||
|
|
2935
|
-
const
|
|
2936
|
-
|
|
2936
|
+
h > 0 && (b = g / h), l.current = v, m.current = p.current;
|
|
2937
|
+
const R = b > 100 && d > 0, y = b < 30 && d < o.PT.lowestDataRes;
|
|
2938
|
+
if (R || y) {
|
|
2939
|
+
const B = d + (y ? 1 : -1);
|
|
2940
|
+
s && (s.renderRes.value = B), e();
|
|
2937
2941
|
}
|
|
2938
2942
|
}
|
|
2939
|
-
function
|
|
2943
|
+
function ht(f) {
|
|
2940
2944
|
const {
|
|
2941
2945
|
images: t,
|
|
2942
2946
|
imageLayerScopes: e,
|
|
@@ -2945,76 +2949,76 @@ function ct(f) {
|
|
|
2945
2949
|
imageChannelCoordination: r,
|
|
2946
2950
|
// onInitComplete,
|
|
2947
2951
|
spatialRenderingMode: a,
|
|
2948
|
-
spatialRenderingModeChanging:
|
|
2952
|
+
spatialRenderingModeChanging: c,
|
|
2949
2953
|
onVolumeLoadingUpdate: u
|
|
2950
2954
|
} = f, {
|
|
2951
|
-
gl:
|
|
2955
|
+
gl: l
|
|
2952
2956
|
// scene,
|
|
2953
2957
|
// camera
|
|
2954
|
-
} = de(),
|
|
2958
|
+
} = de(), p = de((E) => E.invalidate), m = D(null), s = D(null), d = D(null), v = D(null), h = D(null), [g, b] = se({
|
|
2955
2959
|
uniforms: null,
|
|
2956
2960
|
shader: null,
|
|
2957
2961
|
meshScale: [1, 1, 1],
|
|
2958
2962
|
geometrySize: [1, 1, 1]
|
|
2959
|
-
}), R = a === "3D",
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
const { width:
|
|
2963
|
-
|
|
2964
|
-
|
|
2963
|
+
}), R = a === "3D", [y, B] = se(!1), U = D(null), L = D(null), T = D(null), [N, G] = se(!1), Y = D(null), Z = D(!1), S = D(0), Re = D(0), ye = D(0), x = fe(() => new et(l), [l]), z = fe(() => new it(), []);
|
|
2964
|
+
Q(() => {
|
|
2965
|
+
J("useEffect MRT target matching canvas");
|
|
2966
|
+
const { width: E, height: I } = l.domElement, X = new Le(E, I, 3);
|
|
2967
|
+
X.texture.forEach(($) => {
|
|
2968
|
+
$.format = Oe, $.type = Ce, $.minFilter = oe, $.magFilter = oe, $.generateMipmaps = !1;
|
|
2965
2969
|
});
|
|
2966
|
-
const O = new
|
|
2967
|
-
|
|
2968
|
-
const
|
|
2970
|
+
const O = new Fe(), te = new Ve(-1, 1, 1, -1, 0.1, 10);
|
|
2971
|
+
te.position.z = 1;
|
|
2972
|
+
const ne = new Ge({
|
|
2969
2973
|
uniforms: {
|
|
2970
2974
|
// Bind the first render target texture as the input of the gaussian blur shader.
|
|
2971
|
-
tDiffuse: { value:
|
|
2972
|
-
resolution: { value: new _(
|
|
2975
|
+
tDiffuse: { value: X.texture[0] },
|
|
2976
|
+
resolution: { value: new _(E, I) },
|
|
2973
2977
|
gaussian: { value: 7 }
|
|
2974
2978
|
},
|
|
2975
|
-
vertexShader:
|
|
2976
|
-
fragmentShader:
|
|
2979
|
+
vertexShader: ot,
|
|
2980
|
+
fragmentShader: at,
|
|
2977
2981
|
transparent: !0
|
|
2978
|
-
}),
|
|
2979
|
-
return O.add(
|
|
2980
|
-
|
|
2982
|
+
}), W = new qe(new Ze(2, 2), ne);
|
|
2983
|
+
return O.add(W), U.current = O, L.current = te, T.current = W, d.current = new Uint8Array(E * I * 4), v.current = new Uint8Array(E * I * 4), h.current = X, () => {
|
|
2984
|
+
X.dispose(), ne.dispose(), W.geometry.dispose();
|
|
2981
2985
|
};
|
|
2982
|
-
}, [
|
|
2983
|
-
const ae = e?.[0],
|
|
2986
|
+
}, [l]);
|
|
2987
|
+
const ae = e?.[0], Ee = t?.[ae];
|
|
2984
2988
|
o?.[ae];
|
|
2985
|
-
const
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
let
|
|
2989
|
-
if (!
|
|
2989
|
+
const ee = r?.[0]?.[ae];
|
|
2990
|
+
Q(() => {
|
|
2991
|
+
J("useEffect INIT");
|
|
2992
|
+
let E = !1;
|
|
2993
|
+
if (!x || !z) {
|
|
2990
2994
|
n.debug("dataManager or renderManager not initialized yet");
|
|
2991
2995
|
return;
|
|
2992
2996
|
}
|
|
2993
|
-
if (!
|
|
2997
|
+
if (!Ee) {
|
|
2994
2998
|
n.debug("no first image layer yet");
|
|
2995
2999
|
return;
|
|
2996
3000
|
}
|
|
2997
|
-
if (!
|
|
3001
|
+
if (!ee) {
|
|
2998
3002
|
n.debug("no firstImageLayerChannelCoordination yet");
|
|
2999
3003
|
return;
|
|
3000
3004
|
}
|
|
3001
3005
|
return (async () => {
|
|
3002
|
-
if (
|
|
3003
|
-
n.debug("dataManager already initialized, skipping");
|
|
3006
|
+
if (x.initStatus === F.COMPLETE) {
|
|
3007
|
+
n.debug("dataManager already initialized, skipping"), B(!0);
|
|
3004
3008
|
return;
|
|
3005
3009
|
}
|
|
3006
|
-
if (
|
|
3010
|
+
if (x.initImages(t, e), await x.init(ee), E) {
|
|
3007
3011
|
n.debug("Initialization useEffect has rerun, aborting remaining initialization");
|
|
3008
3012
|
return;
|
|
3009
3013
|
}
|
|
3010
|
-
n.debug("dataManager initialized"),
|
|
3014
|
+
n.debug("dataManager initialized"), z.setZarrUniforms(x.zarrStore, x.PT), z.setChannelMapping(x.channels.colorMappings), n.debug("rm.uniforms", z.uniforms), B(!0), p();
|
|
3011
3015
|
})(), () => {
|
|
3012
|
-
|
|
3016
|
+
E = !0;
|
|
3013
3017
|
};
|
|
3014
|
-
}, [
|
|
3015
|
-
if (a === "3D" &&
|
|
3016
|
-
|
|
3017
|
-
const
|
|
3018
|
+
}, [x, z, t, e]), Q(() => {
|
|
3019
|
+
if (a === "3D" && x && z && y) {
|
|
3020
|
+
J("useEffect spatialRenderingMode");
|
|
3021
|
+
const I = {
|
|
3018
3022
|
images: t,
|
|
3019
3023
|
imageLayerScopes: e,
|
|
3020
3024
|
imageLayerCoordination: i,
|
|
@@ -3022,86 +3026,86 @@ function ct(f) {
|
|
|
3022
3026
|
imageChannelCoordination: r,
|
|
3023
3027
|
spatialRenderingMode: a
|
|
3024
3028
|
};
|
|
3025
|
-
if (
|
|
3026
|
-
const { zarrInit:
|
|
3027
|
-
|
|
3028
|
-
const O =
|
|
3029
|
-
zarrStoreShapes:
|
|
3030
|
-
originalScaleXYZ:
|
|
3031
|
-
physicalDimensionsXYZ:
|
|
3032
|
-
maxResolutionXYZ:
|
|
3033
|
-
boxDimensionsXYZ:
|
|
3034
|
-
normalizedScaleXYZ:
|
|
3035
|
-
bcTHREE:
|
|
3036
|
-
ptTHREE:
|
|
3029
|
+
if (z.updateFromProps(I)) {
|
|
3030
|
+
const { zarrInit: X } = z;
|
|
3031
|
+
X || (x.ptTHREE.needsUpdate = !1, x.bcTHREE.needsUpdate = !1, x.renderer.initTexture(x.bcTHREE), x.renderer.initTexture(x.ptTHREE), x.initTexture());
|
|
3032
|
+
const O = z.updateRendering({
|
|
3033
|
+
zarrStoreShapes: x.zarrStore.shapes,
|
|
3034
|
+
originalScaleXYZ: x.getOriginalScaleXYZ(),
|
|
3035
|
+
physicalDimensionsXYZ: x.getPhysicalDimensionsXYZ(),
|
|
3036
|
+
maxResolutionXYZ: x.getMaxResolutionXYZ(),
|
|
3037
|
+
boxDimensionsXYZ: x.getBoxDimensionsXYZ(),
|
|
3038
|
+
normalizedScaleXYZ: x.getNormalizedScaleXYZ(),
|
|
3039
|
+
bcTHREE: x.bcTHREE,
|
|
3040
|
+
ptTHREE: x.ptTHREE
|
|
3037
3041
|
});
|
|
3038
3042
|
O && b(O);
|
|
3039
3043
|
}
|
|
3040
3044
|
}
|
|
3041
|
-
}, [
|
|
3042
|
-
if (!h.current || !
|
|
3045
|
+
}, [x, z, t, e, i, o, r, a, y]), De((E, I, X) => {
|
|
3046
|
+
if (!h.current || !x || !z || !g.shader)
|
|
3043
3047
|
return;
|
|
3044
|
-
const { gl: O, camera:
|
|
3045
|
-
|
|
3046
|
-
invalidate:
|
|
3047
|
-
isInteracting:
|
|
3048
|
-
dataManager:
|
|
3049
|
-
spatialRenderingModeChanging:
|
|
3050
|
-
meshRef:
|
|
3051
|
-
stillRef:
|
|
3052
|
-
screenQuadRef:
|
|
3053
|
-
lastSampleRef:
|
|
3054
|
-
frameRef:
|
|
3055
|
-
lastFrameCountRef:
|
|
3056
|
-
}),
|
|
3048
|
+
const { gl: O, camera: te, scene: ne, clock: W } = E;
|
|
3049
|
+
Z.current || st(O, te, ne, { mrtRef: h }), lt(O, { screenSceneRef: U, screenCameraRef: L }), ct(O, { frameRef: S, dataManager: x, mrtRef: h, bufRequest: d, bufUsage: v }), ut(W, {
|
|
3050
|
+
invalidate: p,
|
|
3051
|
+
isInteracting: N,
|
|
3052
|
+
dataManager: x,
|
|
3053
|
+
spatialRenderingModeChanging: c,
|
|
3054
|
+
meshRef: s,
|
|
3055
|
+
stillRef: Z,
|
|
3056
|
+
screenQuadRef: T,
|
|
3057
|
+
lastSampleRef: Re,
|
|
3058
|
+
frameRef: S,
|
|
3059
|
+
lastFrameCountRef: ye
|
|
3060
|
+
}), S.current += 1;
|
|
3057
3061
|
}, 1);
|
|
3058
|
-
const
|
|
3059
|
-
if (
|
|
3060
|
-
const
|
|
3061
|
-
|
|
3062
|
+
const K = H((E) => {
|
|
3063
|
+
if (J("invalidateOnInteraction callback"), G(E), E) {
|
|
3064
|
+
const I = s.current?.material?.uniforms;
|
|
3065
|
+
I && (I.renderRes.value = x.PT.lowestDataRes), Z.current = !1, p();
|
|
3062
3066
|
}
|
|
3063
|
-
}),
|
|
3064
|
-
|
|
3065
|
-
}),
|
|
3066
|
-
clearTimeout(
|
|
3067
|
-
|
|
3067
|
+
}), Te = H((E) => {
|
|
3068
|
+
K(!0);
|
|
3069
|
+
}), Se = H((E) => {
|
|
3070
|
+
clearTimeout(Y.current), Y.current = setTimeout(() => {
|
|
3071
|
+
K(!1);
|
|
3068
3072
|
}, 300);
|
|
3069
3073
|
});
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
}, 300);
|
|
3074
|
-
}, [
|
|
3075
|
-
const
|
|
3076
|
-
|
|
3077
|
-
}),
|
|
3078
|
-
|
|
3079
|
-
}),
|
|
3080
|
-
return
|
|
3074
|
+
Q(() => {
|
|
3075
|
+
y && (J("useEffect firstImageLayerChannelCoordination"), K(!0), n.debug("something about channels changed"), x.updateChannels(ee), z.setChannelMapping(x.channels.colorMappings), clearTimeout(Y.current), Y.current = setTimeout(() => {
|
|
3076
|
+
K(!1);
|
|
3077
|
+
}, 300));
|
|
3078
|
+
}, [x, ee, z, K, y]);
|
|
3079
|
+
const we = H(() => {
|
|
3080
|
+
x && x.stopLoading();
|
|
3081
|
+
}), ze = H(() => {
|
|
3082
|
+
x && x.restartLoading();
|
|
3083
|
+
}), ke = H(() => x ? x.getLoadingProgress() : null);
|
|
3084
|
+
return Q(() => {
|
|
3081
3085
|
if (!u)
|
|
3082
3086
|
return;
|
|
3083
|
-
const
|
|
3084
|
-
const
|
|
3087
|
+
const E = setInterval(() => {
|
|
3088
|
+
const I = ke();
|
|
3085
3089
|
u({
|
|
3086
|
-
loadingProgress:
|
|
3087
|
-
stillRef:
|
|
3088
|
-
onStopLoading:
|
|
3089
|
-
onRestartLoading:
|
|
3090
|
+
loadingProgress: I,
|
|
3091
|
+
stillRef: Z,
|
|
3092
|
+
onStopLoading: we,
|
|
3093
|
+
onRestartLoading: ze
|
|
3090
3094
|
});
|
|
3091
3095
|
}, 1e3);
|
|
3092
|
-
return () => clearInterval(
|
|
3093
|
-
}, [u,
|
|
3096
|
+
return () => clearInterval(E);
|
|
3097
|
+
}, [u, Z]), !R || !x || !z ? null : g.shader ? re("group", { children: [V(
|
|
3094
3098
|
ve,
|
|
3095
3099
|
{
|
|
3096
3100
|
// ref={mainOrbitControlsRef}
|
|
3097
3101
|
enableDamping: !1,
|
|
3098
|
-
onStart:
|
|
3099
|
-
onEnd:
|
|
3102
|
+
onStart: Te,
|
|
3103
|
+
onEnd: Se
|
|
3100
3104
|
}
|
|
3101
|
-
),
|
|
3105
|
+
), re("mesh", { ref: s, scale: g.meshScale, children: [V("boxGeometry", { args: g.geometrySize }), V("shaderMaterial", { uniforms: g.uniforms, vertexShader: g.shader.vertexShader, fragmentShader: g.shader.fragmentShader, side: je, transparent: !1, glslVersion: Xe })] })] }) : re("group", { children: [re("mesh", { children: [V("boxGeometry", { args: [1, 1, 1] }), V("meshBasicMaterial", { color: "#444", wireframe: !0 })] }), V(ve, { ref: m })] });
|
|
3102
3106
|
}
|
|
3103
|
-
function
|
|
3104
|
-
return
|
|
3107
|
+
function xt(f) {
|
|
3108
|
+
return V(Me, { frameloop: "always", style: {
|
|
3105
3109
|
position: "absolute",
|
|
3106
3110
|
top: 0,
|
|
3107
3111
|
left: 0,
|
|
@@ -3121,8 +3125,8 @@ function mt(f) {
|
|
|
3121
3125
|
logarithmicDepthBuffer: !1,
|
|
3122
3126
|
preserveDrawingBuffer: !1,
|
|
3123
3127
|
autoClear: !1
|
|
3124
|
-
}, children:
|
|
3128
|
+
}, children: V(Ie, { fallback: "Initializing Volume View...", children: V(ht, { ...f }) }) });
|
|
3125
3129
|
}
|
|
3126
3130
|
export {
|
|
3127
|
-
|
|
3131
|
+
xt as SpatialWrapper
|
|
3128
3132
|
};
|