vitessce 3.8.10 → 3.9.0
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/README.md +3 -1
- package/dist/{OrbitControls-xNUUgDVE.js → OrbitControls-CtvT-R12.js} +1 -1
- package/dist/{ReactNeuroglancer--mD1bdS7.js → ReactNeuroglancer-BME9DhHJ.js} +1 -1
- package/dist/{deflate-CYATlzZL.js → deflate-CC4oIo6m.js} +1 -1
- package/dist/{higlass-CcAiyIy5.js → higlass-hAmvnPuk.js} +1 -1
- package/dist/{index-BzUhO-rB.js → index-Cbb_RKUg.js} +3 -3
- package/dist/{index-BVA_zjfe.js → index-CnZ7ozY_.js} +61976 -60998
- package/dist/{index-CtovJQdv.js → index-iGSvfZGA.js} +484 -417
- package/dist/index.min.js +5 -5
- package/dist/{jpeg-B6n79oMI.js → jpeg-DSKWQbUr.js} +7 -7
- package/dist/{lerc-DUT9e8y1.js → lerc-C9mMXzQn.js} +1 -1
- package/dist/{lzw-D7BObYDi.js → lzw-DmsqdUEX.js} +1 -1
- package/dist/{packbits-Dfww6Ajv.js → packbits-CSKGnaIF.js} +1 -1
- package/dist/{raw-LbSPC9mq.js → raw-Eea9jI_X.js} +1 -1
- package/dist/{troika-three-text.esm-Ds1p20i7.js → troika-three-text.esm-0ugzLsPz.js} +1 -1
- package/dist/{webimage-DvfbdmtZ.js → webimage-Bl7yrTT_.js} +1 -1
- package/package.json +7 -7
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { aw as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { u as
|
|
4
|
-
const
|
|
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 b, ag as Z, ae as De, aq as D, aD as Me, aE as Pe, av as Ae, W as Be, ad as Ne, z as Ue, aF as Le, aG as X, ao as B, aH as Oe, am as Fe } from "./index-CnZ7ozY_.js";
|
|
2
|
+
import { useRef as M, 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-CtvT-R12.js";
|
|
4
|
+
const S = 32, A = 64, V = 64, ce = 4, oe = A * V * ce, ge = A * S, xe = V * S, pe = ce * S, F = {
|
|
5
5
|
NOT_STARTED: "not_started",
|
|
6
6
|
IN_PROGRESS: "in_progress",
|
|
7
7
|
COMPLETE: "complete",
|
|
8
8
|
FAILED: "failed"
|
|
9
9
|
};
|
|
10
|
-
function
|
|
11
|
-
|
|
10
|
+
function z(h) {
|
|
11
|
+
se(le.DEBUG) && console.warn(`%cDM: ${h}`, "background: blue; color: white; padding: 2px; border-radius: 3px;");
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
13
|
+
function Ze(h) {
|
|
14
|
+
return h.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 Le(f) {
|
|
|
25
25
|
];
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
return
|
|
28
|
+
function Xe(h) {
|
|
29
|
+
return h.map((t) => {
|
|
30
30
|
const e = [
|
|
31
31
|
t.depth,
|
|
32
32
|
// z
|
|
@@ -36,14 +36,14 @@ function Fe(f) {
|
|
|
36
36
|
// x
|
|
37
37
|
];
|
|
38
38
|
return [
|
|
39
|
-
Math.ceil((e[0] || 1) /
|
|
40
|
-
Math.ceil((e[1] || 1) /
|
|
41
|
-
Math.ceil((e[2] || 1) /
|
|
39
|
+
Math.ceil((e[0] || 1) / S),
|
|
40
|
+
Math.ceil((e[1] || 1) / S),
|
|
41
|
+
Math.ceil((e[2] || 1) / S)
|
|
42
42
|
];
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
45
|
+
function je(h, t) {
|
|
46
|
+
n.debug("_initMRMCPT", h, t);
|
|
47
47
|
const e = {
|
|
48
48
|
channelOffsets: [
|
|
49
49
|
[0, 0, 1],
|
|
@@ -68,77 +68,77 @@ function Ve(f, 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 c =
|
|
71
|
+
const i = h[0][0];
|
|
72
|
+
e.z0Extent = i, e.lowestDataRes = h.length - 1;
|
|
73
|
+
for (let c = h.length - 1; c > 0; c--)
|
|
74
74
|
e.anchors.push([
|
|
75
75
|
e.xExtent,
|
|
76
76
|
e.yExtent,
|
|
77
77
|
e.zExtent
|
|
78
|
-
]), e.xExtent +=
|
|
78
|
+
]), e.xExtent += h[c][2], e.yExtent += h[c][1], e.zExtent += h[c][0];
|
|
79
79
|
e.anchors.push([0, 0, e.zExtent]), e.anchors.reverse(), e.zTotal = e.zExtent + t * i;
|
|
80
|
-
const a = new Uint8Array(
|
|
80
|
+
const a = new Uint8Array(ge * xe * pe);
|
|
81
81
|
a.fill(0);
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
const o = new
|
|
85
|
-
o.format =
|
|
86
|
-
const l = new
|
|
87
|
-
return l.format =
|
|
82
|
+
const r = new Uint32Array(e.xExtent * e.yExtent * e.zTotal);
|
|
83
|
+
r.fill(0);
|
|
84
|
+
const o = new ue(a, ge, xe, pe);
|
|
85
|
+
o.format = ze, o.type = _e, o.internalFormat = "R8", o.minFilter = he, o.magFilter = he, o.generateMipmaps = !1, o.needsUpdate = !0;
|
|
86
|
+
const l = new ue(r, e.xExtent, e.yExtent, e.zTotal);
|
|
87
|
+
return l.format = ke, l.type = Ie, l.internalFormat = "R32UI", l.minFilter = re, l.magFilter = re, l.generateMipmaps = !1, l.needsUpdate = !0, n.debug("_initMRMCPT", e, l, o), {
|
|
88
88
|
PT: e,
|
|
89
89
|
ptTHREE: l,
|
|
90
90
|
bcTHREE: o
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
const
|
|
95
|
-
return (1 << 31 | 1 << 30 |
|
|
93
|
+
function Ye(h, t, e, i, a) {
|
|
94
|
+
const r = (o) => Math.max(0, Math.min(127, Math.floor(o / 2)));
|
|
95
|
+
return (1 << 31 | 1 << 30 | r(h) << 23 | r(t) << 16 | (e & 63) << 10 | (i & 63) << 4 | a & 15) >>> 0;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
const { PT_zExtent: a, PT_z0Extent:
|
|
99
|
-
let l = -1, c = -1, s = -1,
|
|
97
|
+
function He(h, t, e, i) {
|
|
98
|
+
const { PT_zExtent: a, PT_z0Extent: r, PT_anchors: o } = i;
|
|
99
|
+
let l = -1, c = -1, s = -1, g = -1, p = -1;
|
|
100
100
|
if (e >= a)
|
|
101
|
-
c = 0, s =
|
|
101
|
+
c = 0, s = h, g = t, p = (e - a) % r, l = Math.floor((e - a) / r);
|
|
102
102
|
else
|
|
103
103
|
for (let u = 1; u < o.length; u++)
|
|
104
|
-
if (!(
|
|
104
|
+
if (!(h < o[u][0] && t < o[u][1] && e < o[u][2])) {
|
|
105
105
|
c = u;
|
|
106
106
|
const d = [0, 0, 0];
|
|
107
|
-
|
|
107
|
+
h >= o[u][0] && (d[0] = 1), t >= o[u][1] && (d[1] = 1), e >= o[u][2] && (d[2] = 1);
|
|
108
108
|
const v = d[0] << 2 | d[1] << 1 | d[2];
|
|
109
109
|
l = Math.max(1, Math.min(7, v)) - 1;
|
|
110
|
-
const
|
|
111
|
-
s =
|
|
110
|
+
const f = d.map((x, _) => x * o[u][_]);
|
|
111
|
+
s = h - f[0], g = t - f[1], p = e - f[2];
|
|
112
112
|
break;
|
|
113
113
|
}
|
|
114
114
|
return {
|
|
115
115
|
channel: l,
|
|
116
116
|
resolution: c,
|
|
117
117
|
x: s,
|
|
118
|
-
y:
|
|
119
|
-
z:
|
|
118
|
+
y: g,
|
|
119
|
+
z: p
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function Ke(h, t) {
|
|
123
123
|
const e = /* @__PURE__ */ new Map();
|
|
124
|
-
for (let a = 0; a <
|
|
125
|
-
const
|
|
126
|
-
if ((
|
|
124
|
+
for (let a = 0; a < h.length; a += 4) {
|
|
125
|
+
const r = h[a], o = h[a + 1], l = h[a + 2], c = h[a + 3];
|
|
126
|
+
if ((r | o | l | c) === 0)
|
|
127
127
|
continue;
|
|
128
|
-
const s = (
|
|
128
|
+
const s = (r << 24 | o << 16 | l << 8 | c) >>> 0;
|
|
129
129
|
e.set(s, (e.get(s) || 0) + 1);
|
|
130
130
|
}
|
|
131
|
-
return { requests: [...e.entries()].sort((a,
|
|
131
|
+
return { requests: [...e.entries()].sort((a, r) => r[1] - a[1]).slice(0, t).map(([a]) => ({
|
|
132
132
|
x: a >> 22 & 1023,
|
|
133
133
|
y: a >> 12 & 1023,
|
|
134
134
|
z: a & 4095
|
|
135
135
|
})), origRequestCount: e.size };
|
|
136
136
|
}
|
|
137
|
-
class
|
|
137
|
+
class We {
|
|
138
138
|
constructor(t) {
|
|
139
|
-
|
|
139
|
+
z("CLASS INITIALIZING"), n.debug("VolumeDataManager constructor", { glParam: t, glParamContext: t.getContext?.() });
|
|
140
140
|
const e = t.getContext?.() || t, i = t;
|
|
141
|
-
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") && (
|
|
141
|
+
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 = {
|
|
142
142
|
getParameter: (a) => ({
|
|
143
143
|
MAX_TEXTURE_SIZE: 4096,
|
|
144
144
|
MAX_3D_TEXTURE_SIZE: 256,
|
|
@@ -150,7 +150,7 @@ class je {
|
|
|
150
150
|
MAX_3D_TEXTURE_SIZE: "MAX_3D_TEXTURE_SIZE",
|
|
151
151
|
MAX_RENDERBUFFER_SIZE: "MAX_RENDERBUFFER_SIZE",
|
|
152
152
|
MAX_UNIFORM_BUFFER_BINDINGS: "MAX_UNIFORM_BUFFER_BINDINGS"
|
|
153
|
-
}), this._originalGlParam = t, this._isContextLost = !1, this._contextRestoredCallbacks = [], this.gl && this.gl.canvas && (this.gl.canvas.addEventListener("webglcontextlost", this._handleContextLost.bind(this)), this.gl.canvas.addEventListener("webglcontextrestored", this._handleContextRestored.bind(this))),
|
|
153
|
+
}), this._originalGlParam = t, this._isContextLost = !1, this._contextRestoredCallbacks = [], this.gl && this.gl.canvas && (this.gl.canvas.addEventListener("webglcontextlost", this._handleContextLost.bind(this)), this.gl.canvas.addEventListener("webglcontextrestored", this._handleContextRestored.bind(this))), n.debug("GL CONSTANTS"), n.debug(this.gl), n.debug(this.gl.TEXTURE0), n.debug(this.gl.textures), n.debug("RENDERER"), n.debug(this.renderer), this.deviceLimits = {
|
|
154
154
|
maxTextureSize: this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE),
|
|
155
155
|
max3DTextureSize: this.gl.getParameter(this.gl.MAX_3D_TEXTURE_SIZE),
|
|
156
156
|
maxRenderbufferSize: this.gl.getParameter(this.gl.MAX_RENDERBUFFER_SIZE),
|
|
@@ -213,13 +213,40 @@ class je {
|
|
|
213
213
|
// l0 z extent
|
|
214
214
|
zTotal: 0
|
|
215
215
|
// 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(
|
|
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 = F.NOT_STARTED, this.initError = null, this._lastChannelConfig = null, this.currentRequestCount = 0, this.totalBricksRequested = 0, z("VolumeDataManager constructor complete");
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Get loading progress information
|
|
220
|
+
* @returns {Object} Loading progress with bricksLoaded, totalBricks, isLoading, and percentage
|
|
221
|
+
*/
|
|
222
|
+
getLoadingProgress() {
|
|
223
|
+
const t = this.bricksEverLoaded.size, e = !this.noNewRequests && this.currentRequestCount > 0, i = this.totalBricksRequested > 0 ? (this.totalBricksRequested - this.currentRequestCount) / this.totalBricksRequested * 100 : 0;
|
|
224
|
+
return {
|
|
225
|
+
bricksLoaded: t,
|
|
226
|
+
currentRequestCount: this.currentRequestCount,
|
|
227
|
+
totalBricksRequested: this.totalBricksRequested,
|
|
228
|
+
isLoading: e,
|
|
229
|
+
percentage: i,
|
|
230
|
+
noNewRequests: this.noNewRequests
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Manually stop loading and render at highest resolution
|
|
235
|
+
*/
|
|
236
|
+
stopLoading() {
|
|
237
|
+
n.debug("Manually stopping data loading"), this.noNewRequests = !0, this.manuallyStopped = !0, this.needsBailout = !0, this.currentRequestCount = 0, this.totalBricksRequested = 0;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Manually restart loading
|
|
241
|
+
*/
|
|
242
|
+
restartLoading() {
|
|
243
|
+
n.debug("Manually restarting data loading"), this.noNewRequests = !1, this.manuallyStopped = !1, this.needsBailout = !1, this.triggerUsage = !0, this.currentRequestCount = 0, this.totalBricksRequested = 0;
|
|
217
244
|
}
|
|
218
245
|
/**
|
|
219
246
|
* Handle WebGL context loss
|
|
220
247
|
*/
|
|
221
248
|
_handleContextLost(t) {
|
|
222
|
-
|
|
249
|
+
z("CONTEXT LOST"), n.warn("WebGL context lost, preventing default and setting flag"), t.preventDefault(), this._isContextLost = !0, this.channels && this.channels.zarrMappings && (this._lastChannelConfig = {
|
|
223
250
|
zarrMappings: [...this.channels.zarrMappings],
|
|
224
251
|
colorMappings: [...this.channels.colorMappings],
|
|
225
252
|
downsampleMin: [...this.channels.downsampleMin],
|
|
@@ -230,17 +257,17 @@ class je {
|
|
|
230
257
|
* Handle WebGL context restoration
|
|
231
258
|
*/
|
|
232
259
|
_handleContextRestored(t) {
|
|
233
|
-
if (
|
|
260
|
+
if (z("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)
|
|
234
261
|
try {
|
|
235
|
-
this.initMRMCPT(),
|
|
262
|
+
this.initMRMCPT(), n.debug("Successfully reinitialized MRMCPT after context restoration");
|
|
236
263
|
} catch (e) {
|
|
237
|
-
|
|
264
|
+
n.error("Failed to reinitialize MRMCPT after context restoration:", e);
|
|
238
265
|
}
|
|
239
266
|
this._contextRestoredCallbacks.forEach((e) => {
|
|
240
267
|
try {
|
|
241
268
|
e();
|
|
242
269
|
} catch (i) {
|
|
243
|
-
|
|
270
|
+
n.error("Error in context restored callback:", i);
|
|
244
271
|
}
|
|
245
272
|
});
|
|
246
273
|
}
|
|
@@ -257,7 +284,7 @@ class je {
|
|
|
257
284
|
typeof t == "function" && this._contextRestoredCallbacks.push(t);
|
|
258
285
|
}
|
|
259
286
|
initImages(t, e) {
|
|
260
|
-
|
|
287
|
+
z("INIT IMAGES"), this.images = t, this.imageLayerScopes = e;
|
|
261
288
|
}
|
|
262
289
|
/**
|
|
263
290
|
* Initialize the VolumeDataManager with Zarr store details and device limits
|
|
@@ -266,8 +293,8 @@ class je {
|
|
|
266
293
|
* @returns {Promise<Object>} Object with Zarr store details and device limits
|
|
267
294
|
*/
|
|
268
295
|
async init(t) {
|
|
269
|
-
if (
|
|
270
|
-
return
|
|
296
|
+
if (z("INIT()"), this.initStatus !== F.NOT_STARTED)
|
|
297
|
+
return n.debug("VolumeDataManager init() was called more than once!"), this.initStatus === F.COMPLETE ? {
|
|
271
298
|
success: !0,
|
|
272
299
|
deviceLimits: this.deviceLimits,
|
|
273
300
|
zarrStore: this.zarrStore,
|
|
@@ -275,7 +302,7 @@ class je {
|
|
|
275
302
|
physicalSizeTotal: this.zarrStore.physicalSizeTotal,
|
|
276
303
|
physicalSizeVoxel: this.zarrStore.physicalSizeVoxel,
|
|
277
304
|
error: null
|
|
278
|
-
} : this.initStatus ===
|
|
305
|
+
} : this.initStatus === F.FAILED ? {
|
|
279
306
|
success: !1,
|
|
280
307
|
error: this.initError || "Unknown initialization error"
|
|
281
308
|
} : {
|
|
@@ -283,24 +310,24 @@ class je {
|
|
|
283
310
|
pending: !0,
|
|
284
311
|
error: "Initialization in progress"
|
|
285
312
|
};
|
|
286
|
-
this.initStatus =
|
|
313
|
+
this.initStatus = F.IN_PROGRESS, z("INIT() IN PROGRESS");
|
|
287
314
|
try {
|
|
288
315
|
const e = this.images?.[this.imageLayerScopes?.[0]]?.image?.instance;
|
|
289
|
-
if (this.ngffMetadata = e.vivLoader.metadata,
|
|
316
|
+
if (this.ngffMetadata = e.vivLoader.metadata, n.debug("ngffMetadata", this.ngffMetadata), !e || e.getType() !== "ome-zarr")
|
|
290
317
|
throw new Error("Invalid imageWrapper or not an OME-Zarr image");
|
|
291
|
-
const i = e.getMultiResolutionStats(), a =
|
|
292
|
-
this.zarrStore.resolutions =
|
|
318
|
+
const i = e.getMultiResolutionStats(), a = Ze(i), r = i.length;
|
|
319
|
+
this.zarrStore.resolutions = r;
|
|
293
320
|
const o = e.getData();
|
|
294
321
|
if (!Array.isArray(o) || o.length < 1)
|
|
295
322
|
throw new Error("Not a multiresolution loader");
|
|
296
|
-
if (!
|
|
323
|
+
if (!we(o[0].labels, ["t", "c", "z", "y", "x"]))
|
|
297
324
|
throw new Error("Expected OME-Zarr data with dimensions [t, c, z, y, x]");
|
|
298
|
-
|
|
299
|
-
const l = o.map((s) => s._data), c = new Array(
|
|
325
|
+
n.debug("vivData", o);
|
|
326
|
+
const l = o.map((s) => s._data), c = new Array(r).fill(null);
|
|
300
327
|
if (l.length > 0) {
|
|
301
328
|
const s = l[0];
|
|
302
329
|
if (this.zarrStore = {
|
|
303
|
-
resolutions:
|
|
330
|
+
resolutions: r,
|
|
304
331
|
chunkSize: s.chunks,
|
|
305
332
|
shapes: a,
|
|
306
333
|
arrays: l,
|
|
@@ -316,9 +343,9 @@ class je {
|
|
|
316
343
|
channelCount: a[0][1],
|
|
317
344
|
scales: c
|
|
318
345
|
}, 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) {
|
|
319
|
-
const { x: d, y: v, z:
|
|
320
|
-
this.zarrStore.physicalSizeVoxel = [
|
|
321
|
-
(s.shape[2] || 1) *
|
|
346
|
+
const { x: d, y: v, z: f } = s.meta.physicalSizes, x = f?.size || 1, _ = v?.size || 1, y = d?.size || 1;
|
|
347
|
+
this.zarrStore.physicalSizeVoxel = [x, _, y], s.shape && s.shape.length >= 5 && (this.zarrStore.physicalSizeTotal = [
|
|
348
|
+
(s.shape[2] || 1) * x,
|
|
322
349
|
(s.shape[3] || 1) * _,
|
|
323
350
|
(s.shape[4] || 1) * y
|
|
324
351
|
]);
|
|
@@ -328,45 +355,45 @@ class je {
|
|
|
328
355
|
s.shape[3] || 1,
|
|
329
356
|
s.shape[4] || 1
|
|
330
357
|
];
|
|
331
|
-
const { multiscales:
|
|
332
|
-
if (!
|
|
358
|
+
const { multiscales: g } = this.ngffMetadata;
|
|
359
|
+
if (!g)
|
|
333
360
|
throw new Error("Expected multiscales metadata in group.attrs");
|
|
334
|
-
if (
|
|
335
|
-
for (let d = 0; d <
|
|
336
|
-
if (
|
|
337
|
-
const { scale: v } =
|
|
361
|
+
if (g?.[0]?.datasets?.[0]?.coordinateTransformations) {
|
|
362
|
+
for (let d = 0; d < r; d++)
|
|
363
|
+
if (g?.[0]?.datasets?.[d]?.coordinateTransformations?.[0]?.scale) {
|
|
364
|
+
const { scale: v } = g[0].datasets[d].coordinateTransformations[0];
|
|
338
365
|
c[d] = [v[4], v[3], v[2]];
|
|
339
366
|
}
|
|
340
367
|
} else {
|
|
341
|
-
|
|
342
|
-
for (let d = 0; d <
|
|
368
|
+
n.error("no coordinateTransformations available, assuming downsampling ratio of 2 per dimension");
|
|
369
|
+
for (let d = 0; d < r; d++) {
|
|
343
370
|
const v = 2 ** d;
|
|
344
371
|
c[d] = [v, v, v];
|
|
345
372
|
}
|
|
346
373
|
}
|
|
347
374
|
this.zarrStore.scales = c;
|
|
348
|
-
const { coordinateTransformations:
|
|
349
|
-
if (
|
|
350
|
-
const { scale: d } =
|
|
375
|
+
const { coordinateTransformations: p } = this.ngffMetadata;
|
|
376
|
+
if (p?.[0]?.scale) {
|
|
377
|
+
const { scale: d } = p[0], v = d.length;
|
|
351
378
|
if (v >= 3) {
|
|
352
|
-
const
|
|
353
|
-
this.zarrStore.physicalSizeVoxel = [
|
|
354
|
-
(s.shape[2] || 1) *
|
|
355
|
-
(s.shape[3] || 1) *
|
|
379
|
+
const f = d[v - 3], x = d[v - 2], _ = d[v - 1];
|
|
380
|
+
this.zarrStore.physicalSizeVoxel = [f, x, _], s.shape && s.shape.length >= 5 && (this.zarrStore.physicalSizeTotal = [
|
|
381
|
+
(s.shape[2] || 1) * f,
|
|
382
|
+
(s.shape[3] || 1) * x,
|
|
356
383
|
(s.shape[4] || 1) * _
|
|
357
384
|
]);
|
|
358
385
|
}
|
|
359
386
|
}
|
|
360
|
-
this.zarrStore.brickLayout =
|
|
387
|
+
this.zarrStore.brickLayout = Xe(e.getMultiResolutionStats()), n.debug("config", t);
|
|
361
388
|
const { omero: u } = this.ngffMetadata || {};
|
|
362
389
|
if (!u)
|
|
363
390
|
throw new Error("Expected omero metadata in ngffMetadata");
|
|
364
|
-
|
|
365
|
-
const
|
|
366
|
-
this.channels.zarrMappings[v] =
|
|
367
|
-
}),
|
|
391
|
+
n.debug("omero", u), Object.keys(t).forEach((d, v) => {
|
|
392
|
+
const f = t[d].spatialTargetC;
|
|
393
|
+
this.channels.zarrMappings[v] = f, this.channels.colorMappings[v] = v, this.channels.downsampleMin[v] = u?.channels?.[f]?.window?.min || 0, this.channels.downsampleMax[v] = u?.channels?.[f]?.window?.max || 65535;
|
|
394
|
+
}), 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();
|
|
368
395
|
}
|
|
369
|
-
return this.initStatus =
|
|
396
|
+
return this.initStatus = F.COMPLETE, z("INIT() COMPLETE"), {
|
|
370
397
|
success: !0,
|
|
371
398
|
deviceLimits: this.deviceLimits,
|
|
372
399
|
zarrStore: this.zarrStore,
|
|
@@ -376,7 +403,7 @@ class je {
|
|
|
376
403
|
error: null
|
|
377
404
|
};
|
|
378
405
|
} catch (e) {
|
|
379
|
-
return
|
|
406
|
+
return z("INIT() FAILED"), n.error("Error initializing VolumeDataManager:", e), this.initStatus = F.FAILED, this.initError = e.message || "Unknown error", {
|
|
380
407
|
success: !1,
|
|
381
408
|
error: this.initError
|
|
382
409
|
};
|
|
@@ -392,54 +419,48 @@ class je {
|
|
|
392
419
|
* -
|
|
393
420
|
*/
|
|
394
421
|
initMRMCPT() {
|
|
395
|
-
|
|
396
|
-
const { PT: t, ptTHREE: e, bcTHREE: i } =
|
|
397
|
-
this.PT = t, this.ptTHREE = e, this.bcTHREE = i,
|
|
398
|
-
}
|
|
399
|
-
/*
|
|
400
|
-
testTexture() {
|
|
401
|
-
log.debug('testTexture pt', this.ptTHREE);
|
|
402
|
-
log.debug('testTexture bc', this.bcTHREE);
|
|
422
|
+
z("initMRMCPT");
|
|
423
|
+
const { PT: t, ptTHREE: e, bcTHREE: i } = je(this.zarrStore.brickLayout, this.channels.zarrMappings.length);
|
|
424
|
+
this.PT = t, this.ptTHREE = e, this.bcTHREE = i, z("initMRMCPT() COMPLETE");
|
|
403
425
|
}
|
|
404
|
-
*/
|
|
405
426
|
async initTexture() {
|
|
406
427
|
const t = [
|
|
407
428
|
{ x: 0, y: 0, z: 1 }
|
|
408
429
|
];
|
|
409
|
-
await this.handleBrickRequests(t);
|
|
430
|
+
z("initTexture - loading first brick"), await this.handleBrickRequests(t);
|
|
410
431
|
}
|
|
411
432
|
updateChannels(t) {
|
|
412
|
-
if (
|
|
413
|
-
|
|
433
|
+
if (z("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) {
|
|
434
|
+
n.debug("channels not initialized yet");
|
|
414
435
|
return;
|
|
415
436
|
}
|
|
416
|
-
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, c) => l - c),
|
|
417
|
-
a.length ===
|
|
418
|
-
current:
|
|
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, c) => l - c), r = [...new Set(i)].sort((l, c) => l - c);
|
|
438
|
+
a.length === r.length && a.every((l, c) => l === r[c]) && n.debug("Channel mappings unchanged, skipping update"), n.debug("Channel mappings changed:", {
|
|
439
|
+
current: r,
|
|
419
440
|
requested: a
|
|
420
441
|
}), Object.entries(t).forEach(([l, c]) => {
|
|
421
442
|
const s = c.spatialTargetC;
|
|
422
|
-
|
|
423
|
-
const
|
|
424
|
-
if (
|
|
425
|
-
const
|
|
426
|
-
if (
|
|
427
|
-
this.channels.zarrMappings[
|
|
443
|
+
n.debug(`UI channel "${l}" wants zarr channel ${s}`);
|
|
444
|
+
const g = this.channels.zarrMappings.indexOf(s);
|
|
445
|
+
if (g === -1) {
|
|
446
|
+
const p = this.channels.zarrMappings.findIndex((u) => u === void 0);
|
|
447
|
+
if (p !== -1)
|
|
448
|
+
this.channels.zarrMappings[p] = s, n.debug("channelData", c), n.debug("this.ngffMetadata?.omero?.channels", this.ngffMetadata?.omero?.channels), n.debug("targetZarrChannel", s), this.channels.downsampleMin[p] = this.ngffMetadata?.omero?.channels?.[s]?.window?.min || 0, this.channels.downsampleMax[p] = this.ngffMetadata?.omero?.channels?.[s]?.window?.max || 65535, n.debug(`Mapped zarr channel ${s} to slot ${p}`), n.debug("channels", this.channels);
|
|
428
449
|
else {
|
|
429
|
-
|
|
430
|
-
const u = this.channels.zarrMappings.filter((
|
|
431
|
-
if (
|
|
432
|
-
const
|
|
433
|
-
if (
|
|
434
|
-
const
|
|
435
|
-
this.channels.zarrMappings[
|
|
450
|
+
n.debug("No free slots found, looking for unused mapped channels");
|
|
451
|
+
const u = this.channels.zarrMappings.filter((f) => f !== void 0), d = e, v = u.filter((f) => !d.includes(f));
|
|
452
|
+
if (n.debug("Currently mapped:", u), n.debug("Still requested:", d), n.debug("Unused mapped channels:", v), v.length > 0) {
|
|
453
|
+
const f = this.channels.zarrMappings.findIndex((x) => v.includes(x));
|
|
454
|
+
if (f !== -1) {
|
|
455
|
+
const x = this.channels.zarrMappings[f];
|
|
456
|
+
this.channels.zarrMappings[f] = s, this.channels.downsampleMin[f] = this.ngffMetadata?.omero?.channels?.[s]?.window?.min || 0, this.channels.downsampleMax[f] = this.ngffMetadata?.omero?.channels?.[s]?.window?.max || 65535, n.debug(`Reused slot ${f}: ${x} -> ${s}`), this._purgeChannel(f);
|
|
436
457
|
} else
|
|
437
|
-
|
|
458
|
+
n.error("Could not find slot to reuse - this should not happen");
|
|
438
459
|
} else
|
|
439
|
-
|
|
460
|
+
n.error("All slots are full and all mapped channels are still in use");
|
|
440
461
|
}
|
|
441
462
|
} else
|
|
442
|
-
|
|
463
|
+
n.debug(`Zarr channel ${s} already mapped to slot ${g}`);
|
|
443
464
|
});
|
|
444
465
|
const o = Object.values(t).map((l) => {
|
|
445
466
|
const c = this.channels.zarrMappings.indexOf(l.spatialTargetC);
|
|
@@ -447,7 +468,7 @@ class je {
|
|
|
447
468
|
});
|
|
448
469
|
for (; o.length < 7; )
|
|
449
470
|
o.push(-1);
|
|
450
|
-
|
|
471
|
+
n.debug("newColorMappings", o), this.channels.colorMappings = o, n.debug("updatedChannels", this.channels), this._lastChannelConfig = {
|
|
451
472
|
zarrMappings: [...this.channels.zarrMappings],
|
|
452
473
|
colorMappings: [...this.channels.colorMappings],
|
|
453
474
|
downsampleMin: [...this.channels.downsampleMin],
|
|
@@ -484,53 +505,53 @@ class je {
|
|
|
484
505
|
* @returns {Array} Physical dimensions [X, Y, Z]
|
|
485
506
|
*/
|
|
486
507
|
getPhysicalDimensionsXYZ() {
|
|
487
|
-
|
|
508
|
+
n.debug("getPhysicalDimensionsXYZ"), n.debug("this.zarrStore.physicalSizeTotal", this.zarrStore.physicalSizeTotal);
|
|
488
509
|
const t = [
|
|
489
510
|
this.zarrStore.physicalSizeTotal[2],
|
|
490
511
|
this.zarrStore.physicalSizeTotal[1],
|
|
491
512
|
this.zarrStore.physicalSizeTotal[0]
|
|
492
513
|
];
|
|
493
|
-
return
|
|
514
|
+
return n.debug("out", t), t;
|
|
494
515
|
}
|
|
495
516
|
/**
|
|
496
517
|
* Get the maximum resolution
|
|
497
518
|
* @returns {number} Maximum resolution
|
|
498
519
|
*/
|
|
499
520
|
getMaxResolutionXYZ() {
|
|
500
|
-
|
|
521
|
+
n.debug("getMaxResolutionXYZ"), n.debug("this.zarrStore.shapes", this.zarrStore.shapes);
|
|
501
522
|
const t = [
|
|
502
523
|
this.zarrStore.shapes[0][4],
|
|
503
524
|
this.zarrStore.shapes[0][3],
|
|
504
525
|
this.zarrStore.shapes[0][2]
|
|
505
526
|
];
|
|
506
|
-
return
|
|
527
|
+
return n.debug("out", t), t;
|
|
507
528
|
}
|
|
508
529
|
getOriginalScaleXYZ() {
|
|
509
|
-
|
|
530
|
+
z("getOriginalScaleXYZ"), n.debug("this.zarrStore.physicalSizeVoxel", this.zarrStore.physicalSizeVoxel);
|
|
510
531
|
const t = [
|
|
511
532
|
this.zarrStore.physicalSizeVoxel[2],
|
|
512
533
|
this.zarrStore.physicalSizeVoxel[1],
|
|
513
534
|
this.zarrStore.physicalSizeVoxel[0]
|
|
514
535
|
];
|
|
515
|
-
return
|
|
536
|
+
return n.debug("out", t), t;
|
|
516
537
|
}
|
|
517
538
|
getNormalizedScaleXYZ() {
|
|
518
|
-
|
|
539
|
+
n.debug("getNormalizedScaleXYZ");
|
|
519
540
|
const t = [
|
|
520
541
|
1,
|
|
521
542
|
this.zarrStore.physicalSizeVoxel[1] / this.zarrStore.physicalSizeVoxel[2],
|
|
522
543
|
this.zarrStore.physicalSizeVoxel[0] / this.zarrStore.physicalSizeVoxel[0]
|
|
523
544
|
];
|
|
524
|
-
return
|
|
545
|
+
return n.debug("out", t), t;
|
|
525
546
|
}
|
|
526
547
|
getBoxDimensionsXYZ() {
|
|
527
|
-
|
|
548
|
+
n.debug("getBoxDimensionsXYZ"), n.debug("this.zarrStore.shapes", this.zarrStore.shapes);
|
|
528
549
|
const t = [
|
|
529
550
|
1,
|
|
530
551
|
this.zarrStore.shapes[0][3] / this.zarrStore.shapes[0][4],
|
|
531
552
|
this.zarrStore.shapes[0][2] / this.zarrStore.shapes[0][4]
|
|
532
553
|
];
|
|
533
|
-
return
|
|
554
|
+
return n.debug("out", t), t;
|
|
534
555
|
}
|
|
535
556
|
/**
|
|
536
557
|
* Load a specific Zarr chunk based on [t,c,z,y,x] coordinates
|
|
@@ -542,45 +563,50 @@ class je {
|
|
|
542
563
|
* @param {number} resolution - Resolution level
|
|
543
564
|
* @returns {Promise<Uint8Array>} 32x32x32 chunk data
|
|
544
565
|
*/
|
|
545
|
-
async loadZarrChunk(t = 0, e = 0, i, a,
|
|
566
|
+
async loadZarrChunk(t = 0, e = 0, i, a, r, o) {
|
|
546
567
|
if (!this.zarrStore || !this.zarrStore.arrays[o])
|
|
547
568
|
throw new Error("Zarr store or resolution not initialized");
|
|
548
|
-
|
|
569
|
+
n.debug("loadZarrChunk", { t, c: e, z: i, y: a, x: r, resolution: o });
|
|
570
|
+
const c = await this.zarrStore.arrays[o].getChunk([t, e, i, a, r]);
|
|
549
571
|
if (!c)
|
|
550
|
-
throw new Error(`No chunk found at coordinates [${t},${e},${i},${a},${
|
|
551
|
-
if (c.data.length !==
|
|
572
|
+
throw new Error(`No chunk found at coordinates [${t},${e},${i},${a},${r}]`);
|
|
573
|
+
if (c.data.length !== S * S * S)
|
|
552
574
|
throw new Error(`Unexpected chunk size: ${c.data.length}`);
|
|
553
575
|
return c.data;
|
|
554
576
|
}
|
|
555
577
|
async processRequestData(t) {
|
|
556
578
|
if (this.isBusy) {
|
|
557
|
-
|
|
579
|
+
n.debug("processRequestData: already busy, skipping");
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
if (this.noNewRequests) {
|
|
583
|
+
n.debug("processRequestData: loading stopped by user, skipping");
|
|
558
584
|
return;
|
|
559
585
|
}
|
|
560
586
|
if (this.isContextLost()) {
|
|
561
|
-
|
|
587
|
+
n.debug("processRequestData: WebGL context is lost, skipping");
|
|
562
588
|
return;
|
|
563
589
|
}
|
|
564
590
|
this.isBusy = !0, this.triggerRequest = !1;
|
|
565
|
-
const { requests: e, origRequestCount: i } =
|
|
566
|
-
e.length === 0 && (this.noNewRequests = !0),
|
|
591
|
+
const { requests: e, origRequestCount: i } = Ke(t, this.k);
|
|
592
|
+
e.length === 0 && (this.noNewRequests = !0), n.debug(`processRequestData: handling ${e.length} requests of ${i}`), await this.handleBrickRequests(e), this.triggerUsage = !0, this.isBusy = !1;
|
|
567
593
|
}
|
|
568
594
|
async processUsageData(t) {
|
|
569
595
|
if (this.isBusy) {
|
|
570
|
-
|
|
596
|
+
n.debug("processUsageData: already busy, skipping"), this.needsBailout = !0;
|
|
571
597
|
return;
|
|
572
598
|
}
|
|
573
599
|
if (this.isContextLost()) {
|
|
574
|
-
|
|
600
|
+
n.debug("processUsageData: WebGL context is lost, skipping");
|
|
575
601
|
return;
|
|
576
602
|
}
|
|
577
603
|
this.isBusy = !0, this.triggerUsage = !1;
|
|
578
604
|
const e = ++this.timeStamp, i = /* @__PURE__ */ new Set();
|
|
579
605
|
for (let a = 0; a < t.length; a += 4) {
|
|
580
|
-
const
|
|
581
|
-
if ((
|
|
606
|
+
const r = t[a], o = t[a + 1], l = t[a + 2];
|
|
607
|
+
if ((r | o | l) === 0)
|
|
582
608
|
continue;
|
|
583
|
-
const c = l *
|
|
609
|
+
const c = l * A * V + o * A + r;
|
|
584
610
|
c < this.BCTimeStamps.length && i.add(c);
|
|
585
611
|
}
|
|
586
612
|
Array.from(i).forEach((a) => {
|
|
@@ -592,32 +618,32 @@ class je {
|
|
|
592
618
|
const e = this.bc2pt[t];
|
|
593
619
|
if (!e)
|
|
594
620
|
return;
|
|
595
|
-
const [i, a] = this.BCMinMax[t] || [0, 0],
|
|
596
|
-
this._updatePTEntry(e.x, e.y, e.z,
|
|
621
|
+
const [i, a] = this.BCMinMax[t] || [0, 0], r = (0 | 1 << 30 | Math.min(127, i >> 1) << 23 | Math.min(127, a >> 1) << 16) >>> 0;
|
|
622
|
+
this._updatePTEntry(e.x, e.y, e.z, r), this.bc2pt[t] = null;
|
|
597
623
|
}
|
|
598
624
|
_purgeChannel(t) {
|
|
599
|
-
if (
|
|
600
|
-
|
|
625
|
+
if (n.debug("purging channel", t), n.debug("corresponding zarr channel", this.channels.zarrMappings[t]), !this.ptTHREE) {
|
|
626
|
+
n.error("pagetable texture not initialized");
|
|
601
627
|
return;
|
|
602
628
|
}
|
|
603
629
|
if (this.isContextLost()) {
|
|
604
|
-
|
|
630
|
+
n.warn("WebGL context is lost, skipping channel purge");
|
|
605
631
|
return;
|
|
606
632
|
}
|
|
607
633
|
this.channels.downsampleMin[t] = void 0, this.channels.downsampleMax[t] = void 0, this.channels.zarrMappings[t] = void 0;
|
|
608
634
|
const e = this.PT.channelOffsets[t];
|
|
609
|
-
|
|
635
|
+
n.debug("channelMask", e), n.error("TODO: not tested yet");
|
|
610
636
|
const { gl: i } = this, a = this.renderer.properties.get(this.ptTHREE).__webglTexture;
|
|
611
637
|
i.activeTexture(i.TEXTURE0), i.bindTexture(i.TEXTURE_3D, a);
|
|
612
|
-
for (let
|
|
638
|
+
for (let r = 0; r < this.zarrStore.resolutions; r++) {
|
|
613
639
|
const o = [
|
|
614
|
-
this.PT.anchors[
|
|
615
|
-
this.PT.anchors[
|
|
616
|
-
this.PT.anchors[
|
|
640
|
+
this.PT.anchors[r][2] * e[2],
|
|
641
|
+
this.PT.anchors[r][1] * e[1],
|
|
642
|
+
this.PT.anchors[r][0] * e[0]
|
|
617
643
|
];
|
|
618
|
-
|
|
619
|
-
const l = this.zarrStore.brickLayout[
|
|
620
|
-
|
|
644
|
+
n.debug("anchor", o);
|
|
645
|
+
const l = this.zarrStore.brickLayout[r], c = l[0] * l[1] * l[2];
|
|
646
|
+
n.debug("extents", l), n.debug("size", c), 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(c));
|
|
621
647
|
}
|
|
622
648
|
i.bindTexture(i.TEXTURE_3D, null);
|
|
623
649
|
}
|
|
@@ -626,11 +652,11 @@ class je {
|
|
|
626
652
|
if (!this.ptTHREE)
|
|
627
653
|
return;
|
|
628
654
|
if (this.isContextLost()) {
|
|
629
|
-
|
|
655
|
+
n.warn("WebGL context is lost, skipping PT entry update");
|
|
630
656
|
return;
|
|
631
657
|
}
|
|
632
|
-
const { gl:
|
|
633
|
-
|
|
658
|
+
const { gl: r } = this, o = this.renderer.properties.get(this.ptTHREE).__webglTexture;
|
|
659
|
+
r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_3D, o), r.texSubImage3D(r.TEXTURE_3D, 0, t, e, i, 1, 1, 1, r.RED_INTEGER, r.UNSIGNED_INT, new Uint32Array([a])), r.bindTexture(r.TEXTURE_3D, null);
|
|
634
660
|
}
|
|
635
661
|
/* ------------------------------------------------------------- *
|
|
636
662
|
* 2. Allocate the next n free bricks in the brick cache *
|
|
@@ -642,17 +668,17 @@ class je {
|
|
|
642
668
|
*/
|
|
643
669
|
_allocateBCSlots(t) {
|
|
644
670
|
let e = [];
|
|
645
|
-
const i =
|
|
646
|
-
if (!this.BCFull && this.BCUnusedIndex + t > i && (this.BCFull = !0,
|
|
671
|
+
const i = A * V * ce;
|
|
672
|
+
if (!this.BCFull && this.BCUnusedIndex + t > i && (this.BCFull = !0, n.debug("BRICK CACHE FULL")), this.BCFull)
|
|
647
673
|
this.LRUStack.length < t && this._buildLRU(), e = this.LRUStack.splice(0, t).map((a) => {
|
|
648
674
|
this._evictBrick(a);
|
|
649
|
-
const
|
|
650
|
-
return { bcIndex: a, x: c, y: l, z:
|
|
675
|
+
const r = Math.floor(a / (A * V)), o = a - r * A * V, l = Math.floor(o / A), c = o % A;
|
|
676
|
+
return { bcIndex: a, x: c, y: l, z: r };
|
|
651
677
|
});
|
|
652
678
|
else {
|
|
653
679
|
for (let a = 0; a < t; ++a) {
|
|
654
|
-
const
|
|
655
|
-
e.push({ bcIndex:
|
|
680
|
+
const r = (this.BCUnusedIndex + a) % i, o = Math.floor(r / (A * V)), l = r - o * A * V, c = Math.floor(l / A), s = l % A;
|
|
681
|
+
e.push({ bcIndex: r, x: s, y: c, z: o });
|
|
656
682
|
}
|
|
657
683
|
this.BCUnusedIndex += t;
|
|
658
684
|
}
|
|
@@ -662,71 +688,73 @@ class je {
|
|
|
662
688
|
* 4. Upload one brick + PT entry *
|
|
663
689
|
* ------------------------------------------------------------- */
|
|
664
690
|
async _uploadBrick(t, e) {
|
|
665
|
-
if (
|
|
666
|
-
|
|
691
|
+
if (n.debug("uploading brick", t, e), this.isContextLost()) {
|
|
692
|
+
n.warn("WebGL context is lost, skipping brick upload");
|
|
667
693
|
return;
|
|
668
694
|
}
|
|
669
695
|
if (t.x >= this.PT.xExtent || t.y >= this.PT.yExtent || t.z >= this.PT.zTotal || t.x < 0 || t.y < 0 || t.z < 0) {
|
|
670
|
-
|
|
696
|
+
n.error("this.PT", this.PT), n.error("ptCoord out of bounds", t);
|
|
671
697
|
return;
|
|
672
698
|
}
|
|
673
|
-
const { channel: i, resolution: a, x:
|
|
699
|
+
const { channel: i, resolution: a, x: r, y: o, z: l } = He(t.x, t.y, t.z, { PT_zExtent: this.PT.zExtent, PT_z0Extent: this.PT.z0Extent, PT_anchors: this.PT.anchors });
|
|
674
700
|
if (!this.channels || !this.channels.zarrMappings || this.channels.zarrMappings.length === 0) {
|
|
675
|
-
|
|
701
|
+
n.error("Channel mappings not initialized, skipping brick upload");
|
|
676
702
|
return;
|
|
677
703
|
}
|
|
678
704
|
if (i < 0 || i >= this.channels.zarrMappings.length) {
|
|
679
|
-
|
|
705
|
+
n.error("Channel index out of bounds", { channel: i, mappingsLength: this.channels.zarrMappings.length });
|
|
680
706
|
return;
|
|
681
707
|
}
|
|
682
708
|
const c = this.channels.zarrMappings[i];
|
|
683
709
|
if (c === void 0 || c === -1)
|
|
684
|
-
if (
|
|
710
|
+
if (n.warn("zarrChannel is undefined or -1", {
|
|
685
711
|
zarrChannel: c,
|
|
686
712
|
channel: i,
|
|
687
713
|
ptCoord: t,
|
|
688
714
|
channelMappings: this.channels.zarrMappings,
|
|
689
715
|
contextLost: this.isContextLost()
|
|
690
716
|
}), this._lastChannelConfig && this._lastChannelConfig.zarrMappings[i] !== void 0) {
|
|
691
|
-
|
|
717
|
+
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];
|
|
692
718
|
const y = this.channels.zarrMappings[i];
|
|
693
719
|
if (y !== void 0 && y !== -1)
|
|
694
|
-
|
|
720
|
+
n.debug("Successfully restored channel mapping, continuing with upload");
|
|
695
721
|
else {
|
|
696
|
-
|
|
722
|
+
n.error("Could not restore valid channel mapping, aborting brick upload");
|
|
697
723
|
return;
|
|
698
724
|
}
|
|
699
725
|
} else {
|
|
700
|
-
|
|
726
|
+
n.error("No fallback channel config available, aborting brick upload");
|
|
701
727
|
return;
|
|
702
728
|
}
|
|
703
|
-
|
|
704
|
-
let s = await this.loadZarrChunk(0, c, l, o,
|
|
705
|
-
if (s instanceof Uint16Array) {
|
|
706
|
-
if (
|
|
707
|
-
const
|
|
708
|
-
|
|
729
|
+
n.debug("starting to load zarr chunk", { resolution: a, z: l, y: o, x: r, zarrChannel: c });
|
|
730
|
+
let s = await this.loadZarrChunk(0, c, l, o, r, a);
|
|
731
|
+
if (n.debug("chunk", s), s instanceof Uint16Array) {
|
|
732
|
+
if (n.debug("chunk is Uint16Array, converting to Uint8Array"), this.channels.downsampleMin[i] === void 0) {
|
|
733
|
+
const T = this.channels.zarrMappings[i];
|
|
734
|
+
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
|
+
}
|
|
736
|
+
const y = new Uint16Array(s.buffer), E = new Uint8Array(s.length), L = this.channels.downsampleMin[i], G = this.channels.downsampleMax[i], j = G - L;
|
|
737
|
+
for (let T = 0; T < y.length; T++) {
|
|
738
|
+
const U = y[T], N = Math.max(L, Math.min(G, U));
|
|
739
|
+
E[T] = (N - L) * 255 / j | 0;
|
|
709
740
|
}
|
|
710
|
-
|
|
711
|
-
for (let R = 0; R < s.length; R++)
|
|
712
|
-
y[R] = Math.floor((s[R] - this.channels.downsampleMin[i]) / (this.channels.downsampleMax[i] - this.channels.downsampleMin[i]) * 255);
|
|
713
|
-
s = y;
|
|
741
|
+
s = E;
|
|
714
742
|
}
|
|
715
743
|
if (!(s instanceof Uint8Array))
|
|
716
744
|
throw new Error(`Unsupported chunk type: ${s.constructor.name}. Expected Uint8Array.`);
|
|
717
|
-
let
|
|
745
|
+
let g = 255, p = 0;
|
|
718
746
|
for (let y = 0; y < s.length; ++y) {
|
|
719
|
-
const
|
|
720
|
-
|
|
747
|
+
const E = s[y];
|
|
748
|
+
E < g && (g = E), E > p && (p = E);
|
|
721
749
|
}
|
|
722
750
|
const { gl: u } = this, d = this.renderer.properties.get(this.bcTHREE).__webglTexture;
|
|
723
|
-
u.activeTexture(u.TEXTURE2), u.bindTexture(u.TEXTURE_3D, d), u.pixelStorei(u.UNPACK_ALIGNMENT, 1), u.texSubImage3D(u.TEXTURE_3D, 0, e.x *
|
|
751
|
+
u.activeTexture(u.TEXTURE2), u.bindTexture(u.TEXTURE_3D, d), u.pixelStorei(u.UNPACK_ALIGNMENT, 1), u.texSubImage3D(u.TEXTURE_3D, 0, e.x * S, e.y * S, e.z * S, S, S, S, u.RED, u.UNSIGNED_BYTE, s), u.pixelStorei(u.UNPACK_ALIGNMENT, 4), u.bindTexture(u.TEXTURE_3D, null);
|
|
724
752
|
const v = u.getError();
|
|
725
|
-
v !== u.NO_ERROR &&
|
|
726
|
-
const
|
|
727
|
-
u.activeTexture(u.TEXTURE0), u.bindTexture(u.TEXTURE_3D,
|
|
753
|
+
v !== u.NO_ERROR && n.error("WebGL error during brick upload:", v, s), i >= this.channels.zarrMappings.length && (n.debug("channel is out of bounds", i), g = 255, p = 255);
|
|
754
|
+
const f = Ye(g, p, e.x, e.y, e.z), x = this.renderer.properties.get(this.ptTHREE).__webglTexture;
|
|
755
|
+
u.activeTexture(u.TEXTURE0), u.bindTexture(u.TEXTURE_3D, x), u.texSubImage3D(u.TEXTURE_3D, 0, t.x, t.y, t.z, 1, 1, 1, u.RED_INTEGER, u.UNSIGNED_INT, new Uint32Array([f])), u.bindTexture(u.TEXTURE_3D, null);
|
|
728
756
|
const _ = u.getError();
|
|
729
|
-
_ !== u.NO_ERROR &&
|
|
757
|
+
_ !== u.NO_ERROR && n.error("WebGL error during pagetable upload:", _, s), this.BCTimeStamps[e.bcIndex] = this.timeStamp, this.BCMinMax[e.bcIndex] = [g, p], this.bc2pt[e.bcIndex] = t;
|
|
730
758
|
}
|
|
731
759
|
/* ------------------------------------------------------------- *
|
|
732
760
|
* 5. Public: handle a batch of PT requests (array of {x,y,z}) *
|
|
@@ -734,17 +762,18 @@ class je {
|
|
|
734
762
|
async handleBrickRequests(t) {
|
|
735
763
|
if (t.length === 0)
|
|
736
764
|
return;
|
|
765
|
+
this.totalBricksRequested = t.length, this.currentRequestCount = t.length;
|
|
737
766
|
const e = this._allocateBCSlots(t.length);
|
|
738
|
-
|
|
767
|
+
n.debug("Handling brick requests:", { requestCount: t.length, slotCount: e.length }), n.debug("handleBrickRequests: starting for loop");
|
|
739
768
|
for (let i = 0; i < t.length; ++i) {
|
|
740
|
-
|
|
769
|
+
await this._uploadBrick(t[i], e[i]), this.currentRequestCount = t.length - i - 1;
|
|
741
770
|
const a = this.bricksEverLoaded.size;
|
|
742
|
-
if (this.bricksEverLoaded.add(`${t[i].x},${t[i].y},${t[i].z}`), a === this.bricksEverLoaded.size &&
|
|
743
|
-
|
|
771
|
+
if (this.bricksEverLoaded.add(`${t[i].x},${t[i].y},${t[i].z}`), a === this.bricksEverLoaded.size && n.debug("DUPLICATE BRICK LOADED", t[i]), this.needsBailout) {
|
|
772
|
+
n.debug("Bailing out of handleBrickRequests early due to needsBailout flag"), this.needsBailout = !1, this.currentRequestCount = 0;
|
|
744
773
|
break;
|
|
745
774
|
}
|
|
746
775
|
}
|
|
747
|
-
|
|
776
|
+
this.currentRequestCount = 0, n.debug("this.bricksEverLoaded", this.bricksEverLoaded);
|
|
748
777
|
}
|
|
749
778
|
/* --------------------------------------------------------- *
|
|
750
779
|
* Rebuild the LRUStack with the k least-recently-used bricks *
|
|
@@ -754,7 +783,7 @@ class je {
|
|
|
754
783
|
this.LRUStack = t.sort((e, i) => e.time - i.time).slice(0, this.k).map((e) => e.index);
|
|
755
784
|
}
|
|
756
785
|
}
|
|
757
|
-
const
|
|
786
|
+
const $e = `//
|
|
758
787
|
// Output: Unnormalized ray direction from camera to each vertex
|
|
759
788
|
// Used by fragment shader for ray marching through the volume
|
|
760
789
|
out vec3 rayDirUnnorm;
|
|
@@ -813,7 +842,7 @@ void main()
|
|
|
813
842
|
// Pass through texture coordinates for volume sampling
|
|
814
843
|
vUv = uv;
|
|
815
844
|
}
|
|
816
|
-
`,
|
|
845
|
+
`, Qe = `//
|
|
817
846
|
// #include <packing>
|
|
818
847
|
precision highp float;
|
|
819
848
|
precision highp int;
|
|
@@ -840,7 +869,7 @@ uniform usampler3D pageTableTex;
|
|
|
840
869
|
// ========================================
|
|
841
870
|
// RENDERING PARAMETERS/CONSTANTS
|
|
842
871
|
// ========================================
|
|
843
|
-
// Rendering style: 0=MIP, 1=MinIP, 2=standard volume rendering
|
|
872
|
+
// Rendering style: 0=MIP, 1=MinIP, 2=standard volume rendering, 3=DEBUG
|
|
844
873
|
uniform int u_renderstyle;
|
|
845
874
|
// Global opacity multiplier for volume rendering
|
|
846
875
|
uniform float opacity;
|
|
@@ -1852,7 +1881,19 @@ void main(void) {
|
|
|
1852
1881
|
// TODO: figure out how to hook it up with frontend
|
|
1853
1882
|
int [] c_res_min = int[7](getRes(0).x, getRes(1).x, getRes(2).x, getRes(3).x, getRes(4).x, getRes(5).x, getRes(6).x);
|
|
1854
1883
|
int [] c_res_max = int[7](getRes(0).y, getRes(1).y, getRes(2).y, getRes(3).y, getRes(4).y, getRes(5).y, getRes(6).y);
|
|
1855
|
-
|
|
1884
|
+
vec3 [] res_color = vec3[10](
|
|
1885
|
+
vec3(1.0, 0.0, 0.0),
|
|
1886
|
+
vec3(0.0, 0.0, 1.0),
|
|
1887
|
+
vec3(0.0, 1.0, 0.0),
|
|
1888
|
+
vec3(1.0, 0.0, 1.0),
|
|
1889
|
+
vec3(0.0, 1.0, 1.0),
|
|
1890
|
+
vec3(1.0, 1.0, 0.0),
|
|
1891
|
+
vec3(1.0, 0.5, 0.5),
|
|
1892
|
+
vec3(0.5, 0.5, 1.0),
|
|
1893
|
+
vec3(0.5, 1.0, 0.5),
|
|
1894
|
+
vec3(0.5, 0.5, 0.5)
|
|
1895
|
+
);
|
|
1896
|
+
|
|
1856
1897
|
// ========================================
|
|
1857
1898
|
// PER-CHANNEL STATE ARRAYS
|
|
1858
1899
|
// ========================================
|
|
@@ -2290,7 +2331,13 @@ void main(void) {
|
|
|
2290
2331
|
// Accumulate this channel's contribution.
|
|
2291
2332
|
// sum up the values onto the slice values
|
|
2292
2333
|
total += c_val_current[c];
|
|
2293
|
-
|
|
2334
|
+
if (u_renderstyle == 3) {
|
|
2335
|
+
rgbCombo += c_val_current[c] * res_color[targetRes];
|
|
2336
|
+
} else if (u_renderstyle == 4) {
|
|
2337
|
+
rgbCombo += c_val_current[c] * res_color[c_res_current[c]];
|
|
2338
|
+
} else {
|
|
2339
|
+
rgbCombo += c_val_current[c] * c_color[c];
|
|
2340
|
+
}
|
|
2294
2341
|
|
|
2295
2342
|
}
|
|
2296
2343
|
|
|
@@ -2360,7 +2407,7 @@ void main(void) {
|
|
|
2360
2407
|
outColor.a);
|
|
2361
2408
|
|
|
2362
2409
|
}
|
|
2363
|
-
`,
|
|
2410
|
+
`, Je = {
|
|
2364
2411
|
uniforms: {
|
|
2365
2412
|
u_size: { value: new C(1, 1, 1) },
|
|
2366
2413
|
clim0: { value: new b(0.2, 0.8) },
|
|
@@ -2376,16 +2423,17 @@ void main(void) {
|
|
|
2376
2423
|
zClip: { value: new b(0, 1e6) },
|
|
2377
2424
|
u_window_size: { value: new b(1, 1) },
|
|
2378
2425
|
u_vol_scale: { value: new C(1, 1, 1) },
|
|
2426
|
+
// Set renderstyle to 3 or 4 for debugging modes
|
|
2379
2427
|
u_renderstyle: { value: 2 },
|
|
2380
2428
|
brickCacheTex: { type: "sampler3D", value: null },
|
|
2381
2429
|
pageTableTex: { type: "usampler3D", value: null },
|
|
2382
|
-
color0: { value: new
|
|
2383
|
-
color1: { value: new
|
|
2384
|
-
color2: { value: new
|
|
2385
|
-
color3: { value: new
|
|
2386
|
-
color4: { value: new
|
|
2387
|
-
color5: { value: new
|
|
2388
|
-
color6: { value: new
|
|
2430
|
+
color0: { value: new Z(0, 0, 0) },
|
|
2431
|
+
color1: { value: new Z(0, 0, 0) },
|
|
2432
|
+
color2: { value: new Z(0, 0, 0) },
|
|
2433
|
+
color3: { value: new Z(0, 0, 0) },
|
|
2434
|
+
color4: { value: new Z(0, 0, 0) },
|
|
2435
|
+
color5: { value: new Z(0, 0, 0) },
|
|
2436
|
+
color6: { value: new Z(0, 0, 0) },
|
|
2389
2437
|
channelMapping: {
|
|
2390
2438
|
value: [-1, -1, -1, -1, -1, -1, -1]
|
|
2391
2439
|
},
|
|
@@ -2427,24 +2475,24 @@ void main(void) {
|
|
|
2427
2475
|
scale8: { value: new C(256, 256, 256) },
|
|
2428
2476
|
scale9: { value: new C(512, 512, 512) }
|
|
2429
2477
|
},
|
|
2430
|
-
vertexShader:
|
|
2431
|
-
fragmentShader:
|
|
2478
|
+
vertexShader: $e,
|
|
2479
|
+
fragmentShader: Qe
|
|
2432
2480
|
};
|
|
2433
|
-
function
|
|
2434
|
-
|
|
2481
|
+
function P(h) {
|
|
2482
|
+
se(le.DEBUG) && console.warn(`%cRM: ${h}`, "background: orange; color: white; padding: 2px; border-radius: 3px;");
|
|
2435
2483
|
}
|
|
2436
|
-
function
|
|
2437
|
-
return
|
|
2484
|
+
function ne(h, t) {
|
|
2485
|
+
return h / t[1];
|
|
2438
2486
|
}
|
|
2439
|
-
class
|
|
2487
|
+
class et {
|
|
2440
2488
|
constructor() {
|
|
2441
|
-
|
|
2489
|
+
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 b(-1, 1e5), this.ySlice = new b(-1, 1e5), this.zSlice = new b(-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();
|
|
2442
2490
|
}
|
|
2443
2491
|
/**
|
|
2444
2492
|
* Initialize shader and uniform objects
|
|
2445
2493
|
*/
|
|
2446
2494
|
initializeShader() {
|
|
2447
|
-
|
|
2495
|
+
P("Initializing shader"), this.shader = Je, this.uniforms = De.clone(this.shader.uniforms);
|
|
2448
2496
|
}
|
|
2449
2497
|
/**
|
|
2450
2498
|
* Extract rendering settings from coordination props
|
|
@@ -2452,61 +2500,62 @@ class Ke {
|
|
|
2452
2500
|
* @returns {Object} Extracted rendering settings
|
|
2453
2501
|
*/
|
|
2454
2502
|
extractRenderingSettingsFromProps(t) {
|
|
2455
|
-
|
|
2456
|
-
const { images: e = {}, imageLayerScopes: i = [], imageLayerCoordination: a = [{}], imageChannelScopesByLayer: n = {}, imageChannelCoordination: o = [{}], spatialRenderingMode: l } = t, c = i[0];
|
|
2503
|
+
const { images: e = {}, imageLayerScopes: i = [], imageLayerCoordination: a = [{}], imageChannelScopesByLayer: r = {}, imageChannelCoordination: o = [{}], spatialRenderingMode: l } = t, c = i[0];
|
|
2457
2504
|
if (!c)
|
|
2458
|
-
return {
|
|
2505
|
+
return P("Extracting rendering settings from props - no layer scope"), {
|
|
2459
2506
|
valid: !1
|
|
2460
2507
|
};
|
|
2461
|
-
const s =
|
|
2508
|
+
const s = r[c], g = a[0][c], p = o[0][c], u = e[c]?.image?.instance?.getData();
|
|
2462
2509
|
if (!u)
|
|
2463
|
-
return {
|
|
2510
|
+
return P("Extracting rendering settings from props - no image data"), {
|
|
2464
2511
|
valid: !1
|
|
2465
2512
|
};
|
|
2466
|
-
if (!
|
|
2467
|
-
return {
|
|
2513
|
+
if (!p[s?.[0]][D.SPATIAL_CHANNEL_WINDOW])
|
|
2514
|
+
return P("Extracting rendering settings from props - no channel window set"), {
|
|
2468
2515
|
valid: !1
|
|
2469
2516
|
};
|
|
2470
|
-
const d = e[c].image.instance, v = l === "3D",
|
|
2517
|
+
const d = e[c].image.instance, v = l === "3D", f = g[D.PHOTOMETRIC_INTERPRETATION] === "RGB", x = g[D.SPATIAL_LAYER_VISIBLE], _ = g[D.SPATIAL_LAYER_OPACITY], y = f ? [
|
|
2471
2518
|
[255, 0, 0],
|
|
2472
2519
|
[0, 255, 0],
|
|
2473
2520
|
[0, 0, 255]
|
|
2474
|
-
] : s.map((
|
|
2521
|
+
] : s.map((k) => p[k][D.SPATIAL_CHANNEL_COLOR]), E = f ? [
|
|
2475
2522
|
[0, 255],
|
|
2476
2523
|
[0, 255],
|
|
2477
2524
|
[0, 255]
|
|
2478
|
-
] : s.map((
|
|
2479
|
-
this.maxRangeSet || (this.maxRange = Math.max(...
|
|
2480
|
-
const
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
] : s.map((
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
] : s.map((
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
] : s.map((
|
|
2493
|
-
let
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2525
|
+
] : s.map((k) => p[k][D.SPATIAL_CHANNEL_WINDOW] || [0, 255]);
|
|
2526
|
+
this.maxRangeSet || (this.maxRange = Math.max(...E.map((k) => k[1])), this.maxRangeSet = !0);
|
|
2527
|
+
const L = f ? [
|
|
2528
|
+
x && !0,
|
|
2529
|
+
x && !0,
|
|
2530
|
+
x && !0
|
|
2531
|
+
] : s.map((k) => x && p[k][D.SPATIAL_CHANNEL_VISIBLE]), G = f ? [
|
|
2532
|
+
x && !0,
|
|
2533
|
+
x && !0,
|
|
2534
|
+
x && !0
|
|
2535
|
+
] : s.map((k) => x && d.getChannelIndex(p[k][D.SPATIAL_TARGET_C])), j = f ? [
|
|
2536
|
+
x && null,
|
|
2537
|
+
x && null,
|
|
2538
|
+
x && null
|
|
2539
|
+
] : s.map((k) => p[k][D.SPATIAL_MAX_RESOLUTION]);
|
|
2540
|
+
let T = g[D.SPATIAL_SLICE_X], U = g[D.SPATIAL_SLICE_Y], N = g[D.SPATIAL_SLICE_Z];
|
|
2541
|
+
const Y = g[D.SPATIAL_LOD_FACTOR] ?? 1;
|
|
2542
|
+
T = T !== null ? T : new b(-1, 1e5), U = U !== null ? U : new b(-1, 1e5), N = N !== null ? N : new b(-1, 1e5);
|
|
2543
|
+
const ie = e[c].image.loaders[0].channels;
|
|
2544
|
+
return P("Extracting rendering settings from props - success"), {
|
|
2497
2545
|
valid: !0,
|
|
2498
|
-
channelsVisible:
|
|
2499
|
-
allChannels:
|
|
2500
|
-
channelTargetC:
|
|
2501
|
-
channelMaxResolutionIndex:
|
|
2546
|
+
channelsVisible: L,
|
|
2547
|
+
allChannels: ie,
|
|
2548
|
+
channelTargetC: G,
|
|
2549
|
+
channelMaxResolutionIndex: j,
|
|
2502
2550
|
data: u,
|
|
2503
2551
|
colors: y,
|
|
2504
|
-
contrastLimits:
|
|
2552
|
+
contrastLimits: E,
|
|
2505
2553
|
is3dMode: v,
|
|
2506
2554
|
layerTransparency: _,
|
|
2507
|
-
xSlice:
|
|
2508
|
-
ySlice:
|
|
2509
|
-
zSlice: N
|
|
2555
|
+
xSlice: T,
|
|
2556
|
+
ySlice: U,
|
|
2557
|
+
zSlice: N,
|
|
2558
|
+
lodFactor: Y
|
|
2510
2559
|
};
|
|
2511
2560
|
}
|
|
2512
2561
|
/**
|
|
@@ -2515,52 +2564,51 @@ class Ke {
|
|
|
2515
2564
|
* @returns {boolean} True if settings were successfully updated
|
|
2516
2565
|
*/
|
|
2517
2566
|
updateFromProps(t) {
|
|
2518
|
-
U("Updating from props");
|
|
2519
2567
|
const e = this.extractRenderingSettingsFromProps(t);
|
|
2520
|
-
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, !0) : !1;
|
|
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, P(`lodFactor ${e.lodFactor}`), this.shader.uniforms.lodFactor.value = e.lodFactor, P("Updating from props - success"), !0) : (P("Updating from props - invalid settings"), !1);
|
|
2521
2569
|
}
|
|
2522
2570
|
/**
|
|
2523
2571
|
* Update the rendering based on the current volume data from the data manager
|
|
2524
2572
|
* @param {object} volumeDataManagerProps - Params derived from the volume data manager
|
|
2525
2573
|
* @returns {Object|null} Updated rendering settings or null if rendering is not possible
|
|
2526
2574
|
*/
|
|
2527
|
-
updateRendering({ zarrStoreShapes: t, originalScaleXYZ: e, physicalDimensionsXYZ: i, maxResolutionXYZ: a, boxDimensionsXYZ:
|
|
2528
|
-
if (
|
|
2575
|
+
updateRendering({ zarrStoreShapes: t, originalScaleXYZ: e, physicalDimensionsXYZ: i, maxResolutionXYZ: a, boxDimensionsXYZ: r, normalizedScaleXYZ: o, bcTHREE: l, ptTHREE: c }) {
|
|
2576
|
+
if (P("Updating rendering"), this.channelTargetC.findIndex((v, f) => this.channelsVisible[f]), !Array.isArray(t) || t.length === 0)
|
|
2529
2577
|
return null;
|
|
2530
|
-
const s = t[0],
|
|
2578
|
+
const s = t[0], g = {
|
|
2531
2579
|
xLength: s[4] || 1,
|
|
2532
2580
|
yLength: s[3] || 1,
|
|
2533
2581
|
zLength: s[2] || 1
|
|
2534
|
-
},
|
|
2535
|
-
if (this.channelTargetC.forEach((v,
|
|
2536
|
-
this.channelsVisible[
|
|
2582
|
+
}, p = [], u = [], d = [];
|
|
2583
|
+
if (this.channelTargetC.forEach((v, f) => {
|
|
2584
|
+
this.channelsVisible[f];
|
|
2537
2585
|
{
|
|
2538
2586
|
const _ = [0, this.maxRange ? this.maxRange : 255];
|
|
2539
2587
|
u.push([
|
|
2540
|
-
this.colors[
|
|
2541
|
-
this.colors[
|
|
2542
|
-
this.colors[
|
|
2543
|
-
this.channelsVisible[
|
|
2544
|
-
]),
|
|
2545
|
-
|
|
2546
|
-
|
|
2588
|
+
this.colors[f][0] / 255,
|
|
2589
|
+
this.colors[f][1] / 255,
|
|
2590
|
+
this.colors[f][2] / 255,
|
|
2591
|
+
this.channelsVisible[f] ? 1 : 0
|
|
2592
|
+
]), n.debug("colorsSave", u), this.contrastLimits[f][0] === 0 && this.contrastLimits[f][1] === 255 ? d.push([
|
|
2593
|
+
ne(_[0], _),
|
|
2594
|
+
ne(_[1], _)
|
|
2547
2595
|
]) : d.push([
|
|
2548
|
-
|
|
2549
|
-
|
|
2596
|
+
ne(this.contrastLimits[f][0], _),
|
|
2597
|
+
ne(this.contrastLimits[f][1], _)
|
|
2550
2598
|
]);
|
|
2551
2599
|
}
|
|
2552
2600
|
}), !this.zarrInit) {
|
|
2553
2601
|
this.originalScale = e, this.physicalDimensions = i, this.maxResolution = a;
|
|
2554
|
-
const v =
|
|
2602
|
+
const v = r;
|
|
2555
2603
|
this.normalizedScale = o, this.meshScale = [
|
|
2556
2604
|
this.originalScale[0] / this.originalScale[0],
|
|
2557
2605
|
this.originalScale[1] / this.originalScale[0],
|
|
2558
2606
|
this.originalScale[2] / this.originalScale[0]
|
|
2559
|
-
], this.geometrySize = v, this.boxSize = v,
|
|
2607
|
+
], 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;
|
|
2560
2608
|
}
|
|
2561
2609
|
return this.updateUniforms(
|
|
2562
|
-
|
|
2563
|
-
|
|
2610
|
+
p,
|
|
2611
|
+
g,
|
|
2564
2612
|
// Pass dimensions object instead of volume
|
|
2565
2613
|
this.renderingMode,
|
|
2566
2614
|
d,
|
|
@@ -2591,8 +2639,8 @@ class Ke {
|
|
|
2591
2639
|
* @param {Vector2} ySlice - Y clipping plane
|
|
2592
2640
|
* @param {Vector2} zSlice - Z clipping plane
|
|
2593
2641
|
*/
|
|
2594
|
-
updateUniforms(t, e, i, a,
|
|
2595
|
-
|
|
2642
|
+
updateUniforms(t, e, i, a, r, o, l, c, s, g, p) {
|
|
2643
|
+
P("Updating uniforms"), this.uniforms.boxSize.value.set(this.boxSize[0], this.boxSize[1], this.boxSize[2]), this.uniforms.brickCacheTex.value = g, this.uniforms.pageTableTex.value = p, 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(c[0] * (1 / this.maxResolution[1]) * this.boxSize[1], c[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);
|
|
2596
2644
|
for (let u = 0; u < 7; u++)
|
|
2597
2645
|
typeof this.channelMaxResolutionIndex[u] == "number" && this.uniforms[`res${u}`].value.set(Math.max(1, this.channelMaxResolutionIndex[u]), this.zarrStoreNumResolutions - 1);
|
|
2598
2646
|
}
|
|
@@ -2607,31 +2655,31 @@ class Ke {
|
|
|
2607
2655
|
}
|
|
2608
2656
|
*/
|
|
2609
2657
|
setChannelMapping(t) {
|
|
2610
|
-
|
|
2658
|
+
P("setting channel mapping"), n.debug("channelMapping", t), this.uniforms.channelMapping.value = t;
|
|
2611
2659
|
}
|
|
2612
2660
|
// Only called on initialization of the
|
|
2613
2661
|
// VolumeDataManager and VolumeRenderManager for a particular image.
|
|
2614
2662
|
setZarrUniforms(t, e) {
|
|
2615
|
-
|
|
2663
|
+
P("setting zarr uniforms"), n.debug("zarrStore", t), n.debug("PT", e);
|
|
2616
2664
|
for (let i = 0; i <= 9; i++)
|
|
2617
|
-
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) : (
|
|
2618
|
-
|
|
2665
|
+
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
|
+
n.debug("zarrStore.brickLayout", t.brickLayout), this.zarrStoreNumResolutions = t.brickLayout.length;
|
|
2619
2667
|
for (let i = 0; i < 7; i++)
|
|
2620
2668
|
this.uniforms[`res${i}`].value.set(
|
|
2621
2669
|
// TODO(mark) make this dependent on the per-channel maxResolution slider value.
|
|
2622
2670
|
1,
|
|
2623
2671
|
t.brickLayout.length - 1
|
|
2624
2672
|
);
|
|
2625
|
-
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),
|
|
2673
|
+
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);
|
|
2626
2674
|
}
|
|
2627
2675
|
}
|
|
2628
|
-
const
|
|
2676
|
+
const tt = `//
|
|
2629
2677
|
varying vec2 vUv;
|
|
2630
2678
|
void main() {
|
|
2631
2679
|
vUv = uv;
|
|
2632
2680
|
gl_Position = vec4(position, 1.0);
|
|
2633
2681
|
}
|
|
2634
|
-
`,
|
|
2682
|
+
`, nt = `//
|
|
2635
2683
|
// Input texture to blur
|
|
2636
2684
|
uniform sampler2D tDiffuse;
|
|
2637
2685
|
// Resolution of the texture (width, height)
|
|
@@ -2817,196 +2865,215 @@ void main() {
|
|
|
2817
2865
|
gl_FragColor = color;
|
|
2818
2866
|
}
|
|
2819
2867
|
`;
|
|
2820
|
-
function
|
|
2821
|
-
const e =
|
|
2868
|
+
function be(h, t) {
|
|
2869
|
+
const e = h.properties?.get(t);
|
|
2822
2870
|
return e?.framebuffer || e?.__webglFramebuffer || t.__webglFramebuffer;
|
|
2823
2871
|
}
|
|
2824
|
-
function
|
|
2825
|
-
|
|
2872
|
+
function Q(h) {
|
|
2873
|
+
se(le.DEBUG) && console.warn(`%cV: ${h}`, "background: deeppink; color: white; padding: 2px; border-radius: 3px;");
|
|
2826
2874
|
}
|
|
2827
|
-
function
|
|
2828
|
-
|
|
2875
|
+
function rt(h, t, e, { mrtRef: i }) {
|
|
2876
|
+
h.setRenderTarget(i.current), h.clear(!0, !0, !0), h.render(e, t);
|
|
2829
2877
|
}
|
|
2830
|
-
function
|
|
2831
|
-
|
|
2878
|
+
function it(h, { screenSceneRef: t, screenCameraRef: e }) {
|
|
2879
|
+
h.setRenderTarget(null), h.clear(!0, !0, !0), h.render(t.current, e.current);
|
|
2832
2880
|
}
|
|
2833
|
-
function
|
|
2834
|
-
const o =
|
|
2835
|
-
e.noNewRequests === !0 && l % 100 === 0 && l < 500 && (e.noNewRequests = !1), e.triggerRequest === !0 && e.noNewRequests === !1 ? (o.bindFramebuffer(o.READ_FRAMEBUFFER,
|
|
2881
|
+
function at(h, { frameRef: t, dataManager: e, mrtRef: i, bufRequest: a, bufUsage: r }) {
|
|
2882
|
+
const o = h.getContext(), l = t.current;
|
|
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(h, 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)) : e.triggerUsage === !0 && e.noNewRequests === !1 && (o.bindFramebuffer(o.READ_FRAMEBUFFER, be(h, 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));
|
|
2836
2884
|
}
|
|
2837
|
-
function
|
|
2838
|
-
const { invalidate: e, isInteracting: i, dataManager: a, spatialRenderingModeChanging:
|
|
2885
|
+
function ot(h, t) {
|
|
2886
|
+
const { invalidate: e, isInteracting: i, dataManager: a, spatialRenderingModeChanging: r, meshRef: o, stillRef: l, screenQuadRef: c, lastSampleRef: s, frameRef: g, lastFrameCountRef: p } = t;
|
|
2839
2887
|
if (c.current && (l.current ? c.current.material.uniforms.gaussian.value = 0 : c.current.material.uniforms.gaussian.value = 7), i) {
|
|
2840
|
-
a.noNewRequests = !1, a.triggerUsage = !0;
|
|
2888
|
+
a.manuallyStopped || (a.noNewRequests = !1, a.triggerUsage = !0);
|
|
2841
2889
|
return;
|
|
2842
2890
|
}
|
|
2843
|
-
if (
|
|
2891
|
+
if (r)
|
|
2844
2892
|
return;
|
|
2845
2893
|
const u = o.current?.material?.uniforms, d = u?.renderRes?.value ?? a?.PT?.lowestDataRes;
|
|
2846
2894
|
if (a.noNewRequests) {
|
|
2847
|
-
d !== 0 ? (u && (u.renderRes.value = 0),
|
|
2895
|
+
d !== 0 ? (u && (u.renderRes.value = 0), n.debug("Adaptive Quality: No new requests. Setting renderSpeed to 0 (best quality)."), l.current = !1, c.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, c.current.material.uniforms.gaussian.value = 0);
|
|
2848
2896
|
return;
|
|
2849
2897
|
}
|
|
2850
2898
|
l.current && (l.current = !1, e());
|
|
2851
|
-
const v =
|
|
2899
|
+
const v = h.getElapsedTime();
|
|
2852
2900
|
if (v - s.current < 1)
|
|
2853
2901
|
return;
|
|
2854
|
-
const
|
|
2902
|
+
const f = v - s.current, x = g.current - p.current;
|
|
2855
2903
|
let _ = 0;
|
|
2856
|
-
|
|
2857
|
-
const y = _ > 100 && d > 0,
|
|
2858
|
-
if (y ||
|
|
2859
|
-
const
|
|
2860
|
-
u && (u.renderRes.value =
|
|
2904
|
+
f > 0 && (_ = x / f), s.current = v, p.current = g.current;
|
|
2905
|
+
const y = _ > 100 && d > 0, E = _ < 30 && d < a.PT.lowestDataRes;
|
|
2906
|
+
if (y || E) {
|
|
2907
|
+
const L = d + (E ? 1 : -1);
|
|
2908
|
+
u && (u.renderRes.value = L), e();
|
|
2861
2909
|
}
|
|
2862
2910
|
}
|
|
2863
|
-
function
|
|
2911
|
+
function st(h) {
|
|
2864
2912
|
const {
|
|
2865
2913
|
images: t,
|
|
2866
2914
|
imageLayerScopes: e,
|
|
2867
2915
|
imageLayerCoordination: i,
|
|
2868
2916
|
imageChannelScopesByLayer: a,
|
|
2869
|
-
imageChannelCoordination:
|
|
2917
|
+
imageChannelCoordination: r,
|
|
2870
2918
|
// onInitComplete,
|
|
2871
2919
|
spatialRenderingMode: o,
|
|
2872
|
-
spatialRenderingModeChanging: l
|
|
2873
|
-
|
|
2874
|
-
|
|
2920
|
+
spatialRenderingModeChanging: l,
|
|
2921
|
+
onVolumeLoadingUpdate: c
|
|
2922
|
+
} = h, {
|
|
2923
|
+
gl: s
|
|
2875
2924
|
// scene,
|
|
2876
2925
|
// camera
|
|
2877
|
-
} =
|
|
2926
|
+
} = ve(), g = ve((R) => R.invalidate), p = M(null), u = M(null), d = M(null), v = M(null), f = M(null), [x, _] = fe({
|
|
2878
2927
|
uniforms: null,
|
|
2879
2928
|
shader: null,
|
|
2880
2929
|
meshScale: [1, 1, 1],
|
|
2881
2930
|
geometrySize: [1, 1, 1]
|
|
2882
|
-
}),
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
const { width:
|
|
2886
|
-
|
|
2887
|
-
|
|
2931
|
+
}), y = o === "3D", E = M(null), L = M(null), G = M(null), [j, T] = fe(!1), U = M(null), N = M(!1), Y = M(0), ie = M(0), k = M(0), m = de(() => new We(s), [s]), w = de(() => new et(), []);
|
|
2932
|
+
$(() => {
|
|
2933
|
+
Q("useEffect MRT target matching canvas");
|
|
2934
|
+
const { width: R, height: I } = s.domElement, q = new Me(R, I, 3);
|
|
2935
|
+
q.texture.forEach((W) => {
|
|
2936
|
+
W.format = Pe, W.type = _e, W.minFilter = re, W.magFilter = re, W.generateMipmaps = !1;
|
|
2888
2937
|
});
|
|
2889
|
-
const
|
|
2890
|
-
|
|
2891
|
-
const
|
|
2938
|
+
const O = new Ae(), ee = new Be(-1, 1, 1, -1, 0.1, 10);
|
|
2939
|
+
ee.position.z = 1;
|
|
2940
|
+
const te = new Ne({
|
|
2892
2941
|
uniforms: {
|
|
2893
2942
|
// Bind the first render target texture as the input of the gaussian blur shader.
|
|
2894
|
-
tDiffuse: { value:
|
|
2895
|
-
resolution: { value: new b(
|
|
2943
|
+
tDiffuse: { value: q.texture[0] },
|
|
2944
|
+
resolution: { value: new b(R, I) },
|
|
2896
2945
|
gaussian: { value: 7 }
|
|
2897
2946
|
},
|
|
2898
|
-
vertexShader:
|
|
2899
|
-
fragmentShader:
|
|
2947
|
+
vertexShader: tt,
|
|
2948
|
+
fragmentShader: nt,
|
|
2900
2949
|
transparent: !0
|
|
2901
|
-
}),
|
|
2902
|
-
return
|
|
2903
|
-
|
|
2950
|
+
}), K = new Ue(new Le(2, 2), te);
|
|
2951
|
+
return O.add(K), E.current = O, L.current = ee, G.current = K, d.current = new Uint8Array(R * I * 4), v.current = new Uint8Array(R * I * 4), f.current = q, () => {
|
|
2952
|
+
q.dispose(), te.dispose(), K.geometry.dispose();
|
|
2904
2953
|
};
|
|
2905
|
-
}, [
|
|
2906
|
-
const
|
|
2907
|
-
a?.[
|
|
2908
|
-
const
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2954
|
+
}, [s]);
|
|
2955
|
+
const ae = e?.[0], Ce = t?.[ae];
|
|
2956
|
+
a?.[ae];
|
|
2957
|
+
const J = r?.[0]?.[ae];
|
|
2958
|
+
$(() => {
|
|
2959
|
+
Q("useEffect INIT");
|
|
2960
|
+
let R = !1;
|
|
2961
|
+
if (!m || !w) {
|
|
2962
|
+
n.debug("dataManager or renderManager not initialized yet");
|
|
2912
2963
|
return;
|
|
2913
2964
|
}
|
|
2914
|
-
if (!
|
|
2915
|
-
|
|
2965
|
+
if (!Ce) {
|
|
2966
|
+
n.debug("no first image layer yet");
|
|
2916
2967
|
return;
|
|
2917
2968
|
}
|
|
2918
|
-
if (
|
|
2919
|
-
|
|
2969
|
+
if (!J) {
|
|
2970
|
+
n.debug("no firstImageLayerChannelCoordination yet");
|
|
2920
2971
|
return;
|
|
2921
2972
|
}
|
|
2922
|
-
(async () =>
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2973
|
+
return (async () => {
|
|
2974
|
+
if (m.initStatus === F.COMPLETE) {
|
|
2975
|
+
n.debug("dataManager already initialized, skipping");
|
|
2976
|
+
return;
|
|
2977
|
+
}
|
|
2978
|
+
if (m.initImages(t, e), await m.init(J), R) {
|
|
2979
|
+
n.debug("Initialization useEffect has rerun, aborting remaining initialization");
|
|
2980
|
+
return;
|
|
2981
|
+
}
|
|
2982
|
+
n.debug("dataManager initialized"), w.setZarrUniforms(m.zarrStore, m.PT), w.setChannelMapping(m.channels.colorMappings), n.debug("rm.uniforms", w.uniforms), g();
|
|
2983
|
+
})(), () => {
|
|
2984
|
+
R = !0;
|
|
2985
|
+
};
|
|
2986
|
+
}, [m, w, t, e]), $(() => {
|
|
2987
|
+
if (o === "3D" && m && w) {
|
|
2988
|
+
Q("useEffect spatialRenderingMode");
|
|
2989
|
+
const I = {
|
|
2933
2990
|
images: t,
|
|
2934
2991
|
imageLayerScopes: e,
|
|
2935
2992
|
imageLayerCoordination: i,
|
|
2936
2993
|
imageChannelScopesByLayer: a,
|
|
2937
|
-
imageChannelCoordination:
|
|
2994
|
+
imageChannelCoordination: r,
|
|
2938
2995
|
spatialRenderingMode: o
|
|
2939
2996
|
};
|
|
2940
|
-
if (w.updateFromProps(
|
|
2941
|
-
const { zarrInit:
|
|
2942
|
-
|
|
2943
|
-
const
|
|
2944
|
-
zarrStoreShapes:
|
|
2945
|
-
originalScaleXYZ:
|
|
2946
|
-
physicalDimensionsXYZ:
|
|
2947
|
-
maxResolutionXYZ:
|
|
2948
|
-
boxDimensionsXYZ:
|
|
2949
|
-
normalizedScaleXYZ:
|
|
2950
|
-
bcTHREE:
|
|
2951
|
-
ptTHREE:
|
|
2997
|
+
if (w.updateFromProps(I)) {
|
|
2998
|
+
const { zarrInit: q } = w;
|
|
2999
|
+
q || (m.ptTHREE.needsUpdate = !1, m.bcTHREE.needsUpdate = !1, m.renderer.initTexture(m.bcTHREE), m.renderer.initTexture(m.ptTHREE), m.initTexture());
|
|
3000
|
+
const O = w.updateRendering({
|
|
3001
|
+
zarrStoreShapes: m.zarrStore.shapes,
|
|
3002
|
+
originalScaleXYZ: m.getOriginalScaleXYZ(),
|
|
3003
|
+
physicalDimensionsXYZ: m.getPhysicalDimensionsXYZ(),
|
|
3004
|
+
maxResolutionXYZ: m.getMaxResolutionXYZ(),
|
|
3005
|
+
boxDimensionsXYZ: m.getBoxDimensionsXYZ(),
|
|
3006
|
+
normalizedScaleXYZ: m.getNormalizedScaleXYZ(),
|
|
3007
|
+
bcTHREE: m.bcTHREE,
|
|
3008
|
+
ptTHREE: m.ptTHREE
|
|
2952
3009
|
});
|
|
2953
|
-
|
|
3010
|
+
O && _(O);
|
|
2954
3011
|
}
|
|
2955
3012
|
}
|
|
2956
|
-
}, [
|
|
2957
|
-
|
|
2958
|
-
w,
|
|
2959
|
-
t,
|
|
2960
|
-
e,
|
|
2961
|
-
i,
|
|
2962
|
-
a,
|
|
2963
|
-
n,
|
|
2964
|
-
o
|
|
2965
|
-
]), H(() => {
|
|
2966
|
-
if (K("useEffect isInteracting"), X) {
|
|
2967
|
-
const T = m.current?.material?.uniforms;
|
|
2968
|
-
T && (T.renderRes.value = g.PT.lowestDataRes), N.current = !1, s();
|
|
2969
|
-
}
|
|
2970
|
-
}, [s, X]), Ue((T, L, F) => {
|
|
2971
|
-
if (!v.current || !g || !w || !h.shader)
|
|
3013
|
+
}, [m, w, t, e, i, a, r, o]), Ge((R, I, q) => {
|
|
3014
|
+
if (!f.current || !m || !w || !x.shader)
|
|
2972
3015
|
return;
|
|
2973
|
-
const { gl:
|
|
2974
|
-
N.current ||
|
|
2975
|
-
invalidate:
|
|
2976
|
-
isInteracting:
|
|
2977
|
-
dataManager:
|
|
3016
|
+
const { gl: O, camera: ee, scene: te, clock: K } = R;
|
|
3017
|
+
N.current || rt(O, ee, te, { mrtRef: f }), it(O, { screenSceneRef: E, screenCameraRef: L }), at(O, { frameRef: Y, dataManager: m, mrtRef: f, bufRequest: d, bufUsage: v }), ot(K, {
|
|
3018
|
+
invalidate: g,
|
|
3019
|
+
isInteracting: j,
|
|
3020
|
+
dataManager: m,
|
|
2978
3021
|
spatialRenderingModeChanging: l,
|
|
2979
|
-
meshRef:
|
|
3022
|
+
meshRef: u,
|
|
2980
3023
|
stillRef: N,
|
|
2981
|
-
screenQuadRef:
|
|
2982
|
-
lastSampleRef:
|
|
2983
|
-
frameRef:
|
|
2984
|
-
lastFrameCountRef:
|
|
2985
|
-
}),
|
|
3024
|
+
screenQuadRef: G,
|
|
3025
|
+
lastSampleRef: ie,
|
|
3026
|
+
frameRef: Y,
|
|
3027
|
+
lastFrameCountRef: k
|
|
3028
|
+
}), Y.current += 1;
|
|
2986
3029
|
}, 1);
|
|
2987
|
-
const
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
3030
|
+
const H = X((R) => {
|
|
3031
|
+
if (Q("invalidateOnInteraction callback"), T(R), R) {
|
|
3032
|
+
const I = u.current?.material?.uniforms;
|
|
3033
|
+
I && (I.renderRes.value = m.PT.lowestDataRes), N.current = !1, g();
|
|
3034
|
+
}
|
|
3035
|
+
}), Re = X((R) => {
|
|
3036
|
+
H(!0);
|
|
3037
|
+
}), ye = X((R) => {
|
|
3038
|
+
clearTimeout(U.current), U.current = setTimeout(() => {
|
|
3039
|
+
H(!1);
|
|
2992
3040
|
}, 300);
|
|
2993
|
-
}
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
3041
|
+
});
|
|
3042
|
+
$(() => {
|
|
3043
|
+
Q("useEffect firstImageLayerChannelCoordination"), H(!0), n.debug("something about channels changed"), m.updateChannels(J), w.setChannelMapping(m.channels.colorMappings), clearTimeout(U.current), U.current = setTimeout(() => {
|
|
3044
|
+
H(!1);
|
|
2997
3045
|
}, 300);
|
|
2998
|
-
}, [
|
|
2999
|
-
|
|
3046
|
+
}, [m, J, w, H]);
|
|
3047
|
+
const Ee = X(() => {
|
|
3048
|
+
m && m.stopLoading();
|
|
3049
|
+
}), Te = X(() => {
|
|
3050
|
+
m && m.restartLoading();
|
|
3051
|
+
}), Se = X(() => m ? m.getLoadingProgress() : null);
|
|
3052
|
+
return $(() => {
|
|
3053
|
+
if (!c)
|
|
3054
|
+
return;
|
|
3055
|
+
const R = setInterval(() => {
|
|
3056
|
+
const I = Se();
|
|
3057
|
+
c({
|
|
3058
|
+
loadingProgress: I,
|
|
3059
|
+
stillRef: N,
|
|
3060
|
+
onStopLoading: Ee,
|
|
3061
|
+
onRestartLoading: Te
|
|
3062
|
+
});
|
|
3063
|
+
}, 1e3);
|
|
3064
|
+
return () => clearInterval(R);
|
|
3065
|
+
}, [c, N]), !y || !m || !w ? null : x.shader ? B.jsxs("group", { children: [B.jsx(
|
|
3066
|
+
me,
|
|
3000
3067
|
{
|
|
3001
3068
|
// ref={mainOrbitControlsRef}
|
|
3002
3069
|
enableDamping: !1,
|
|
3003
|
-
onStart:
|
|
3004
|
-
onEnd:
|
|
3070
|
+
onStart: Re,
|
|
3071
|
+
onEnd: ye
|
|
3005
3072
|
}
|
|
3006
|
-
),
|
|
3073
|
+
), B.jsxs("mesh", { ref: u, scale: x.meshScale, children: [B.jsx("boxGeometry", { args: x.geometrySize }), B.jsx("shaderMaterial", { uniforms: x.uniforms, vertexShader: x.shader.vertexShader, fragmentShader: x.shader.fragmentShader, side: Fe, transparent: !1, glslVersion: Oe })] })] }) : B.jsxs("group", { children: [B.jsxs("mesh", { children: [B.jsx("boxGeometry", { args: [1, 1, 1] }), B.jsx("meshBasicMaterial", { color: "#444", wireframe: !0 })] }), B.jsx(me, { ref: p })] });
|
|
3007
3074
|
}
|
|
3008
|
-
function
|
|
3009
|
-
return
|
|
3075
|
+
function ft(h) {
|
|
3076
|
+
return B.jsx(qe, { frameloop: "always", style: {
|
|
3010
3077
|
position: "absolute",
|
|
3011
3078
|
top: 0,
|
|
3012
3079
|
left: 0,
|
|
@@ -3026,8 +3093,8 @@ function st(f) {
|
|
|
3026
3093
|
logarithmicDepthBuffer: !1,
|
|
3027
3094
|
preserveDrawingBuffer: !1,
|
|
3028
3095
|
autoClear: !1
|
|
3029
|
-
}, children:
|
|
3096
|
+
}, children: B.jsx(Ve, { fallback: "Initializing Volume View...", children: B.jsx(st, { ...h }) }) });
|
|
3030
3097
|
}
|
|
3031
3098
|
export {
|
|
3032
|
-
|
|
3099
|
+
ft as SpatialWrapper
|
|
3033
3100
|
};
|