vitessce 4.0.0-test.3 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.temp.md +2 -288
- package/dist/{GeometryAndMeshXR-5GREHHDl.js → GeometryAndMeshXR-DhL415aR.js} +37 -36
- package/dist/{ReactNeuroglancer-Sf6JqU5x.js → ReactNeuroglancer-BBJJpq73.js} +1 -1
- package/dist/{XREnterButton-BjrGpTiW.js → XREnterButton-CLRf7k6e.js} +1 -1
- package/dist/{XRSceneComponents-DpHb68RX.js → XRSceneComponents-CpuAUm3S.js} +8 -6
- package/dist/XRWrapper-B9IIMYL-.js +10 -0
- package/dist/{deflate-Z3kRa5zU.js → deflate-CYVx5gI8.js} +1 -1
- package/dist/{higlass-B-aJnbpu.js → higlass-e9_JY6_6.js} +1 -1
- package/dist/index-C04NjukO.js +1009 -0
- package/dist/{index-CuKIB_WF.js → index-CDVgyDq2.js} +109330 -132607
- package/dist/{index-Vfi4mcGP.js → index-CM_UtbDW.js} +160 -157
- package/dist/index.min.js +29 -28
- package/dist/{jpeg-B_HY7d6K.js → jpeg-f5LgOrOW.js} +1 -1
- package/dist/{lerc-B_aE35RP.js → lerc-CROxlfHv.js} +1 -1
- package/dist/{lzw-ZSO5PJmy.js → lzw-BdRDgMbg.js} +1 -1
- package/dist/{packbits-9_G6pOSa.js → packbits-rgkGAV4R.js} +1 -1
- package/dist/{raw-BhnJDLGV.js → raw-DHM7Wj2Y.js} +1 -1
- package/dist/{webimage-ntUHXCcF.js → webimage-BilIOhkt.js} +1 -1
- package/dist/xrStore-BC7o4upD.js +8 -0
- package/dist-tsc/index.js +1 -0
- package/dist-tsc/index.js.map +1 -0
- package/package.json +27 -9
- package/dist/OrbitControls-7C5xFO9S.js +0 -7700
- package/dist/XRWrapper-DrziwTvI.js +0 -10
- package/dist/emulate-DRW2PHb9.js +0 -28295
- package/dist/index-BMYzAwjE.js +0 -57
- package/dist/index-CzfRePsw.js +0 -7737
- package/dist/living_room-uy_CEYZC.js +0 -11
- package/dist/meeting_room-BjXC3fLc.js +0 -11
- package/dist/music_room-AFchga9Y.js +0 -11
- package/dist/office_large-qDeoZNBo.js +0 -11
- package/dist/office_small-B_PLvrYC.js +0 -11
- package/dist/ray-grab-DyqcVH_Y.js +0 -3714
- package/dist/xrStore-BVaRwXZy.js +0 -10
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as D, useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { jsxs as ie, jsx as G } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as D, useState as le, useMemo as de, useEffect as Q, Suspense as De } from "react";
|
|
3
|
+
import { useThree as ve, useFrame as Me, Canvas as Pe } from "@react-three/fiber";
|
|
4
|
+
import { OrbitControls as me } from "@react-three/drei";
|
|
5
|
+
import * as M from "three";
|
|
6
|
+
import { Data3DTexture as ge, RedFormat as Ae, UnsignedByteType as Be, LinearFilter as xe, RedIntegerFormat as Ne, UnsignedIntType as Ue, NearestFilter as pe, Vector3 as C, Vector2 as _, Vector4 as j, UniformsUtils as Le } from "three";
|
|
7
|
+
import { l as n, i as Oe, a as ue, L as he, C as P, u as K } from "./index-CDVgyDq2.js";
|
|
8
|
+
const w = 32, B = 64, Z = 64, fe = 4, ce = B * Z * fe, be = B * w, _e = Z * w, Ce = fe * w, V = {
|
|
6
9
|
NOT_STARTED: "not_started",
|
|
7
10
|
IN_PROGRESS: "in_progress",
|
|
8
11
|
COMPLETE: "complete",
|
|
9
12
|
FAILED: "failed"
|
|
10
13
|
};
|
|
11
14
|
function k(f) {
|
|
12
|
-
|
|
15
|
+
ue(he.DEBUG) && console.warn(`%cDM: ${f}`, "background: blue; color: white; padding: 2px; border-radius: 3px;");
|
|
13
16
|
}
|
|
14
|
-
function
|
|
17
|
+
function Fe(f) {
|
|
15
18
|
return f.map((t) => {
|
|
16
19
|
const { dims: e } = t;
|
|
17
20
|
return [
|
|
@@ -26,7 +29,7 @@ function Ye(f) {
|
|
|
26
29
|
];
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
|
-
function
|
|
32
|
+
function Ve(f) {
|
|
30
33
|
return f.map((t) => {
|
|
31
34
|
const e = [
|
|
32
35
|
t.depth,
|
|
@@ -43,7 +46,7 @@ function He(f) {
|
|
|
43
46
|
];
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
|
-
function
|
|
49
|
+
function Ge(f, t) {
|
|
47
50
|
n.debug("_initMRMCPT", f, t);
|
|
48
51
|
const e = {
|
|
49
52
|
channelOffsets: [
|
|
@@ -78,24 +81,24 @@ function Ke(f, t) {
|
|
|
78
81
|
e.zExtent
|
|
79
82
|
]), e.xExtent += f[u][2], e.yExtent += f[u][1], e.zExtent += f[u][0];
|
|
80
83
|
e.anchors.push([0, 0, e.zExtent]), e.anchors.reverse(), e.zTotal = e.zExtent + t * i;
|
|
81
|
-
const o = new Uint8Array(
|
|
84
|
+
const o = new Uint8Array(be * _e * Ce);
|
|
82
85
|
o.fill(0);
|
|
83
86
|
const r = new Uint32Array(e.xExtent * e.yExtent * e.zTotal);
|
|
84
87
|
r.fill(0);
|
|
85
|
-
const a = new
|
|
86
|
-
a.format = Ae, a.type =
|
|
87
|
-
const c = new
|
|
88
|
-
return c.format =
|
|
88
|
+
const a = new ge(o, be, _e, Ce);
|
|
89
|
+
a.format = Ae, a.type = Be, a.internalFormat = "R8", a.minFilter = xe, a.magFilter = xe, a.generateMipmaps = !1, a.needsUpdate = !0;
|
|
90
|
+
const c = new ge(r, e.xExtent, e.yExtent, e.zTotal);
|
|
91
|
+
return c.format = Ne, c.type = Ue, c.internalFormat = "R32UI", c.minFilter = pe, c.magFilter = pe, c.generateMipmaps = !1, c.needsUpdate = !0, n.debug("_initMRMCPT", e, c, a), {
|
|
89
92
|
PT: e,
|
|
90
93
|
ptTHREE: c,
|
|
91
94
|
bcTHREE: a
|
|
92
95
|
};
|
|
93
96
|
}
|
|
94
|
-
function
|
|
97
|
+
function qe(f, t, e, i, o) {
|
|
95
98
|
const r = (a) => Math.max(0, Math.min(127, Math.floor(a / 2)));
|
|
96
99
|
return (1 << 31 | 1 << 30 | r(f) << 23 | r(t) << 16 | (e & 63) << 10 | (i & 63) << 4 | o & 15) >>> 0;
|
|
97
100
|
}
|
|
98
|
-
function
|
|
101
|
+
function Ze(f, t, e, i) {
|
|
99
102
|
const { PT_zExtent: o, PT_z0Extent: r, PT_anchors: a } = i;
|
|
100
103
|
let c = -1, u = -1, l = -1, p = -1, m = -1;
|
|
101
104
|
if (e >= o)
|
|
@@ -120,8 +123,8 @@ function $e(f, t, e, i) {
|
|
|
120
123
|
z: m
|
|
121
124
|
};
|
|
122
125
|
}
|
|
123
|
-
const
|
|
124
|
-
function
|
|
126
|
+
const Xe = 0.25;
|
|
127
|
+
function je(f, t, e) {
|
|
125
128
|
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
129
|
c || n.warn("_requestBufferToRequestObjects: proceeding without weighting");
|
|
127
130
|
const u = Math.floor(f.length / 4);
|
|
@@ -132,8 +135,8 @@ function Je(f, t, e) {
|
|
|
132
135
|
const b = (d << 24 | v << 16 | h << 8 | g) >>> 0;
|
|
133
136
|
let R = 1;
|
|
134
137
|
if (c) {
|
|
135
|
-
const y = m % o,
|
|
136
|
-
R = Math.exp(-0.5 *
|
|
138
|
+
const y = m % o, N = Math.floor(m / o), L = y - o / 2, O = N - r / 2, U = Math.sqrt(L * L / (o * o) + O * O / (r * r)) / a;
|
|
139
|
+
R = Math.exp(-0.5 * U * U);
|
|
137
140
|
}
|
|
138
141
|
i.set(b, (i.get(b) || 0) + R);
|
|
139
142
|
}
|
|
@@ -143,7 +146,7 @@ function Je(f, t, e) {
|
|
|
143
146
|
z: m & 4095
|
|
144
147
|
})), origRequestCount: i.size };
|
|
145
148
|
}
|
|
146
|
-
class
|
|
149
|
+
class Ye {
|
|
147
150
|
constructor(t) {
|
|
148
151
|
k("CLASS INITIALIZING"), n.debug("VolumeDataManager constructor", { glParam: t, glParamContext: t.getContext?.() });
|
|
149
152
|
const e = t.getContext?.() || t, i = t;
|
|
@@ -222,7 +225,7 @@ class et {
|
|
|
222
225
|
// l0 z extent
|
|
223
226
|
zTotal: 0
|
|
224
227
|
// 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(
|
|
228
|
+
}, this.bricksEverLoaded = /* @__PURE__ */ new Set(), this.isBusy = !1, this.BCTimeStamps = new Array(ce).fill(0), this.BCMinMax = new Array(ce).fill([0, 0]), this.BCFull = !1, this.BCUnusedIndex = 0, this.bc2pt = new Array(ce).fill(null), this.LRUStack = [], this.triggerUsage = !0, this.triggerRequest = !1, this.timeStamp = 0, this.k = 40, this.noNewRequests = !1, this.manuallyStopped = !1, this.needsBailout = !1, this.initStatus = V.NOT_STARTED, this.initError = null, this._lastChannelConfig = null, this.currentRequestCount = 0, this.totalBricksRequested = 0, k("VolumeDataManager constructor complete");
|
|
226
229
|
}
|
|
227
230
|
/**
|
|
228
231
|
* Get loading progress information
|
|
@@ -302,8 +305,8 @@ class et {
|
|
|
302
305
|
* @returns {Promise<Object>} Object with Zarr store details and device limits
|
|
303
306
|
*/
|
|
304
307
|
async init(t) {
|
|
305
|
-
if (k("INIT()"), this.initStatus !==
|
|
306
|
-
return n.debug("VolumeDataManager init() was called more than once!"), this.initStatus ===
|
|
308
|
+
if (k("INIT()"), this.initStatus !== V.NOT_STARTED)
|
|
309
|
+
return n.debug("VolumeDataManager init() was called more than once!"), this.initStatus === V.COMPLETE ? {
|
|
307
310
|
success: !0,
|
|
308
311
|
deviceLimits: this.deviceLimits,
|
|
309
312
|
zarrStore: this.zarrStore,
|
|
@@ -311,7 +314,7 @@ class et {
|
|
|
311
314
|
physicalSizeTotal: this.zarrStore.physicalSizeTotal,
|
|
312
315
|
physicalSizeVoxel: this.zarrStore.physicalSizeVoxel,
|
|
313
316
|
error: null
|
|
314
|
-
} : this.initStatus ===
|
|
317
|
+
} : this.initStatus === V.FAILED ? {
|
|
315
318
|
success: !1,
|
|
316
319
|
error: this.initError || "Unknown initialization error"
|
|
317
320
|
} : {
|
|
@@ -319,17 +322,17 @@ class et {
|
|
|
319
322
|
pending: !0,
|
|
320
323
|
error: "Initialization in progress"
|
|
321
324
|
};
|
|
322
|
-
this.initStatus =
|
|
325
|
+
this.initStatus = V.IN_PROGRESS, k("INIT() IN PROGRESS");
|
|
323
326
|
try {
|
|
324
327
|
const e = this.images?.[this.imageLayerScopes?.[0]]?.image?.instance;
|
|
325
328
|
if (this.ngffMetadata = e.vivLoader.metadata, n.debug("ngffMetadata", this.ngffMetadata), !e || e.getType() !== "ome-zarr")
|
|
326
329
|
throw new Error("Invalid imageWrapper or not an OME-Zarr image");
|
|
327
|
-
const i = e.getMultiResolutionStats(), o =
|
|
330
|
+
const i = e.getMultiResolutionStats(), o = Fe(i), r = i.length;
|
|
328
331
|
this.zarrStore.resolutions = r;
|
|
329
332
|
const a = e.getData();
|
|
330
333
|
if (!Array.isArray(a) || a.length < 1)
|
|
331
334
|
throw new Error("Not a multiresolution loader");
|
|
332
|
-
if (!
|
|
335
|
+
if (!Oe(a[0].labels, ["t", "c", "z", "y", "x"]))
|
|
333
336
|
throw new Error("Expected OME-Zarr data with dimensions [t, c, z, y, x]");
|
|
334
337
|
n.debug("vivData", a);
|
|
335
338
|
const c = a.map((l) => l._data), u = new Array(r).fill(null);
|
|
@@ -393,7 +396,7 @@ class et {
|
|
|
393
396
|
]);
|
|
394
397
|
}
|
|
395
398
|
}
|
|
396
|
-
this.zarrStore.brickLayout =
|
|
399
|
+
this.zarrStore.brickLayout = Ve(e.getMultiResolutionStats()), n.debug("config", t);
|
|
397
400
|
const { omero: s } = this.ngffMetadata || {};
|
|
398
401
|
if (!s)
|
|
399
402
|
throw new Error("Expected omero metadata in ngffMetadata");
|
|
@@ -402,7 +405,7 @@ class et {
|
|
|
402
405
|
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
406
|
}), 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
407
|
}
|
|
405
|
-
return this.initStatus =
|
|
408
|
+
return this.initStatus = V.COMPLETE, k("INIT() COMPLETE"), {
|
|
406
409
|
success: !0,
|
|
407
410
|
deviceLimits: this.deviceLimits,
|
|
408
411
|
zarrStore: this.zarrStore,
|
|
@@ -412,7 +415,7 @@ class et {
|
|
|
412
415
|
error: null
|
|
413
416
|
};
|
|
414
417
|
} catch (e) {
|
|
415
|
-
return k("INIT() FAILED"), n.error("Error initializing VolumeDataManager:", e), this.initStatus =
|
|
418
|
+
return k("INIT() FAILED"), n.error("Error initializing VolumeDataManager:", e), this.initStatus = V.FAILED, this.initError = e.message || "Unknown error", {
|
|
416
419
|
success: !1,
|
|
417
420
|
error: this.initError
|
|
418
421
|
};
|
|
@@ -429,7 +432,7 @@ class et {
|
|
|
429
432
|
*/
|
|
430
433
|
initMRMCPT() {
|
|
431
434
|
k("initMRMCPT");
|
|
432
|
-
const { PT: t, ptTHREE: e, bcTHREE: i } =
|
|
435
|
+
const { PT: t, ptTHREE: e, bcTHREE: i } = Ge(this.zarrStore.brickLayout, this.channels.zarrMappings.length);
|
|
433
436
|
this.PT = t, this.ptTHREE = e, this.bcTHREE = i, k("initMRMCPT() COMPLETE");
|
|
434
437
|
}
|
|
435
438
|
async initTexture() {
|
|
@@ -596,7 +599,7 @@ class et {
|
|
|
596
599
|
* the center of the render target.
|
|
597
600
|
*/
|
|
598
601
|
async processRequestData(t, e) {
|
|
599
|
-
if (this.initStatus !==
|
|
602
|
+
if (this.initStatus !== V.COMPLETE) {
|
|
600
603
|
n.debug("processRequestData: not yet initialized, skipping");
|
|
601
604
|
return;
|
|
602
605
|
}
|
|
@@ -613,7 +616,7 @@ class et {
|
|
|
613
616
|
return;
|
|
614
617
|
}
|
|
615
618
|
this.isBusy = !0, this.triggerRequest = !1;
|
|
616
|
-
const { requests: i, origRequestCount: o } =
|
|
619
|
+
const { requests: i, origRequestCount: o } = je(t, this.k, e);
|
|
617
620
|
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;
|
|
618
621
|
}
|
|
619
622
|
async processUsageData(t) {
|
|
@@ -631,7 +634,7 @@ class et {
|
|
|
631
634
|
const r = t[o], a = t[o + 1], c = t[o + 2];
|
|
632
635
|
if ((r | a | c) === 0)
|
|
633
636
|
continue;
|
|
634
|
-
const u = c *
|
|
637
|
+
const u = c * B * Z + a * B + r;
|
|
635
638
|
u < this.BCTimeStamps.length && i.add(u);
|
|
636
639
|
}
|
|
637
640
|
Array.from(i).forEach((o) => {
|
|
@@ -693,16 +696,16 @@ class et {
|
|
|
693
696
|
*/
|
|
694
697
|
_allocateBCSlots(t) {
|
|
695
698
|
let e = [];
|
|
696
|
-
const i =
|
|
699
|
+
const i = B * Z * fe;
|
|
697
700
|
if (!this.BCFull && this.BCUnusedIndex + t > i && (this.BCFull = !0, n.debug("BRICK CACHE FULL")), this.BCFull)
|
|
698
701
|
this.LRUStack.length < t && this._buildLRU(), e = this.LRUStack.splice(0, t).map((o) => {
|
|
699
702
|
this._evictBrick(o);
|
|
700
|
-
const r = Math.floor(o / (
|
|
703
|
+
const r = Math.floor(o / (B * Z)), a = o - r * B * Z, c = Math.floor(a / B), u = a % B;
|
|
701
704
|
return { bcIndex: o, x: u, y: c, z: r };
|
|
702
705
|
});
|
|
703
706
|
else {
|
|
704
707
|
for (let o = 0; o < t; ++o) {
|
|
705
|
-
const r = (this.BCUnusedIndex + o) % i, a = Math.floor(r / (
|
|
708
|
+
const r = (this.BCUnusedIndex + o) % i, a = Math.floor(r / (B * Z)), c = r - a * B * Z, u = Math.floor(c / B), l = c % B;
|
|
706
709
|
e.push({ bcIndex: r, x: l, y: u, z: a });
|
|
707
710
|
}
|
|
708
711
|
this.BCUnusedIndex += t;
|
|
@@ -721,7 +724,7 @@ class et {
|
|
|
721
724
|
n.error("this.PT", this.PT), n.error("ptCoord out of bounds", t);
|
|
722
725
|
return;
|
|
723
726
|
}
|
|
724
|
-
const { channel: i, resolution: o, x: r, y: a, z: c } =
|
|
727
|
+
const { channel: i, resolution: o, x: r, y: a, z: c } = Ze(t.x, t.y, t.z, { PT_zExtent: this.PT.zExtent, PT_z0Extent: this.PT.z0Extent, PT_anchors: this.PT.anchors });
|
|
725
728
|
if (!this.channels || !this.channels.zarrMappings || this.channels.zarrMappings.length === 0) {
|
|
726
729
|
n.error("Channel mappings not initialized, skipping brick upload");
|
|
727
730
|
return;
|
|
@@ -758,10 +761,10 @@ class et {
|
|
|
758
761
|
const T = this.channels.zarrMappings[i];
|
|
759
762
|
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]);
|
|
760
763
|
}
|
|
761
|
-
const R = new Uint16Array(l.buffer), y = new Uint8Array(l.length),
|
|
764
|
+
const R = new Uint16Array(l.buffer), y = new Uint8Array(l.length), N = this.channels.downsampleMin[i], L = this.channels.downsampleMax[i], O = L - N;
|
|
762
765
|
for (let T = 0; T < R.length; T++) {
|
|
763
|
-
const
|
|
764
|
-
y[T] = (
|
|
766
|
+
const U = R[T], q = Math.max(N, Math.min(L, U));
|
|
767
|
+
y[T] = (q - N) * 255 / O | 0;
|
|
765
768
|
}
|
|
766
769
|
l = y;
|
|
767
770
|
}
|
|
@@ -776,7 +779,7 @@ class et {
|
|
|
776
779
|
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
780
|
const v = s.getError();
|
|
778
781
|
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 =
|
|
782
|
+
const h = qe(p, m, e.x, e.y, e.z), g = this.renderer.properties.get(this.ptTHREE).__webglTexture;
|
|
780
783
|
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
784
|
const b = s.getError();
|
|
782
785
|
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;
|
|
@@ -808,7 +811,7 @@ class et {
|
|
|
808
811
|
this.LRUStack = t.sort((e, i) => e.time - i.time).slice(0, this.k).map((e) => e.index);
|
|
809
812
|
}
|
|
810
813
|
}
|
|
811
|
-
const
|
|
814
|
+
const He = `//
|
|
812
815
|
// Output: Unnormalized ray direction from camera to each vertex
|
|
813
816
|
// Used by fragment shader for ray marching through the volume
|
|
814
817
|
out vec3 rayDirUnnorm;
|
|
@@ -867,7 +870,7 @@ void main()
|
|
|
867
870
|
// Pass through texture coordinates for volume sampling
|
|
868
871
|
vUv = uv;
|
|
869
872
|
}
|
|
870
|
-
`,
|
|
873
|
+
`, Ke = `//
|
|
871
874
|
// #include <packing>
|
|
872
875
|
precision highp float;
|
|
873
876
|
precision highp int;
|
|
@@ -2432,7 +2435,7 @@ void main(void) {
|
|
|
2432
2435
|
outColor.a);
|
|
2433
2436
|
|
|
2434
2437
|
}
|
|
2435
|
-
`,
|
|
2438
|
+
`, We = {
|
|
2436
2439
|
uniforms: {
|
|
2437
2440
|
u_size: { value: new C(1, 1, 1) },
|
|
2438
2441
|
clim0: { value: new _(0.2, 0.8) },
|
|
@@ -2500,24 +2503,24 @@ void main(void) {
|
|
|
2500
2503
|
scale8: { value: new C(256, 256, 256) },
|
|
2501
2504
|
scale9: { value: new C(512, 512, 512) }
|
|
2502
2505
|
},
|
|
2503
|
-
vertexShader:
|
|
2504
|
-
fragmentShader:
|
|
2506
|
+
vertexShader: He,
|
|
2507
|
+
fragmentShader: Ke
|
|
2505
2508
|
};
|
|
2506
|
-
function
|
|
2507
|
-
|
|
2509
|
+
function A(f) {
|
|
2510
|
+
ue(he.DEBUG) && console.warn(`%cRM: ${f}`, "background: orange; color: white; padding: 2px; border-radius: 3px;");
|
|
2508
2511
|
}
|
|
2509
|
-
function
|
|
2512
|
+
function oe(f, t) {
|
|
2510
2513
|
return f / t[1];
|
|
2511
2514
|
}
|
|
2512
|
-
class
|
|
2515
|
+
class $e {
|
|
2513
2516
|
constructor() {
|
|
2514
|
-
|
|
2517
|
+
A("Initializing VolumeRenderManager"), this.uniforms = null, this.shader = null, this.meshScale = [1, 1, 1], this.geometrySize = [1, 1, 1], this.boxSize = [1, 1, 1], this.zarrInit = !1, this.channelsVisible = [], this.channelTargetC = [], this.zarrStoreNumResolutions = null, this.channelMaxResolutionIndex = [], this.colors = [], this.contrastLimits = [], this.layerTransparency = 1, this.xSlice = new _(-1, 1e5), this.ySlice = new _(-1, 1e5), this.zSlice = new _(-1, 1e5), this.originalScale = [1, 1, 1], this.physicalDimensions = [1, 1, 1], this.maxResolution = [1, 1, 1], this.maxRange = 255, this.maxRangeSet = !1, this.initializeShader();
|
|
2515
2518
|
}
|
|
2516
2519
|
/**
|
|
2517
2520
|
* Initialize shader and uniform objects
|
|
2518
2521
|
*/
|
|
2519
2522
|
initializeShader() {
|
|
2520
|
-
|
|
2523
|
+
A("Initializing shader"), this.shader = We, this.uniforms = Le.clone(this.shader.uniforms);
|
|
2521
2524
|
}
|
|
2522
2525
|
/**
|
|
2523
2526
|
* Extract rendering settings from coordination props
|
|
@@ -2527,59 +2530,59 @@ class it {
|
|
|
2527
2530
|
extractRenderingSettingsFromProps(t) {
|
|
2528
2531
|
const { images: e = {}, imageLayerScopes: i = [], imageLayerCoordination: o = [{}], imageChannelScopesByLayer: r = {}, imageChannelCoordination: a = [{}], spatialRenderingMode: c } = t, u = i[0];
|
|
2529
2532
|
if (!u)
|
|
2530
|
-
return
|
|
2533
|
+
return A("Extracting rendering settings from props - no layer scope"), {
|
|
2531
2534
|
valid: !1
|
|
2532
2535
|
};
|
|
2533
2536
|
const l = r[u], p = o[0][u], m = a[0][u], s = e[u]?.image?.instance?.getData();
|
|
2534
2537
|
if (!s)
|
|
2535
|
-
return
|
|
2538
|
+
return A("Extracting rendering settings from props - no image data"), {
|
|
2536
2539
|
valid: !1
|
|
2537
2540
|
};
|
|
2538
|
-
if (!m[l?.[0]][
|
|
2539
|
-
return
|
|
2541
|
+
if (!m[l?.[0]][P.SPATIAL_CHANNEL_WINDOW])
|
|
2542
|
+
return A("Extracting rendering settings from props - no channel window set"), {
|
|
2540
2543
|
valid: !1
|
|
2541
2544
|
};
|
|
2542
|
-
const d = e[u].image.instance, v = c === "3D", h = p[
|
|
2545
|
+
const d = e[u].image.instance, v = c === "3D", h = p[P.PHOTOMETRIC_INTERPRETATION] === "RGB", g = p[P.SPATIAL_LAYER_VISIBLE], b = p[P.SPATIAL_LAYER_OPACITY], R = h ? [
|
|
2543
2546
|
[255, 0, 0],
|
|
2544
2547
|
[0, 255, 0],
|
|
2545
2548
|
[0, 0, 255]
|
|
2546
|
-
] : l.map((S) => m[S][
|
|
2549
|
+
] : l.map((S) => m[S][P.SPATIAL_CHANNEL_COLOR]), y = h ? [
|
|
2547
2550
|
[0, 255],
|
|
2548
2551
|
[0, 255],
|
|
2549
2552
|
[0, 255]
|
|
2550
|
-
] : l.map((S) => m[S][
|
|
2553
|
+
] : l.map((S) => m[S][P.SPATIAL_CHANNEL_WINDOW] || [0, 255]);
|
|
2551
2554
|
this.maxRangeSet || (this.maxRange = Math.max(...y.map((S) => S[1])), this.maxRangeSet = !0);
|
|
2552
|
-
const
|
|
2555
|
+
const N = h ? [
|
|
2553
2556
|
g && !0,
|
|
2554
2557
|
g && !0,
|
|
2555
2558
|
g && !0
|
|
2556
|
-
] : l.map((S) => g && m[S][
|
|
2559
|
+
] : l.map((S) => g && m[S][P.SPATIAL_CHANNEL_VISIBLE]), L = h ? [
|
|
2557
2560
|
g && !0,
|
|
2558
2561
|
g && !0,
|
|
2559
2562
|
g && !0
|
|
2560
|
-
] : l.map((S) => g && d.getChannelIndex(m[S][
|
|
2563
|
+
] : l.map((S) => g && d.getChannelIndex(m[S][P.SPATIAL_TARGET_C])), O = h ? [
|
|
2561
2564
|
g && null,
|
|
2562
2565
|
g && null,
|
|
2563
2566
|
g && null
|
|
2564
|
-
] : l.map((S) => m[S][
|
|
2565
|
-
let T = p[
|
|
2566
|
-
const Y = p[
|
|
2567
|
-
T = T !== null ? T : new _(-1, 1e5),
|
|
2568
|
-
const
|
|
2569
|
-
return
|
|
2567
|
+
] : l.map((S) => m[S][P.SPATIAL_MAX_RESOLUTION]);
|
|
2568
|
+
let T = p[P.SPATIAL_SLICE_X], U = p[P.SPATIAL_SLICE_Y], q = p[P.SPATIAL_SLICE_Z];
|
|
2569
|
+
const Y = p[P.SPATIAL_LOD_FACTOR] ?? 1;
|
|
2570
|
+
T = T !== null ? T : new _(-1, 1e5), U = U !== null ? U : new _(-1, 1e5), q = q !== null ? q : new _(-1, 1e5);
|
|
2571
|
+
const X = e[u].image.loaders[0].channels;
|
|
2572
|
+
return A("Extracting rendering settings from props - success"), {
|
|
2570
2573
|
valid: !0,
|
|
2571
|
-
channelsVisible:
|
|
2572
|
-
allChannels:
|
|
2573
|
-
channelTargetC:
|
|
2574
|
-
channelMaxResolutionIndex:
|
|
2574
|
+
channelsVisible: N,
|
|
2575
|
+
allChannels: X,
|
|
2576
|
+
channelTargetC: L,
|
|
2577
|
+
channelMaxResolutionIndex: O,
|
|
2575
2578
|
data: s,
|
|
2576
2579
|
colors: R,
|
|
2577
2580
|
contrastLimits: y,
|
|
2578
2581
|
is3dMode: v,
|
|
2579
2582
|
layerTransparency: b,
|
|
2580
2583
|
xSlice: T,
|
|
2581
|
-
ySlice:
|
|
2582
|
-
zSlice:
|
|
2584
|
+
ySlice: U,
|
|
2585
|
+
zSlice: q,
|
|
2583
2586
|
lodFactor: Y
|
|
2584
2587
|
};
|
|
2585
2588
|
}
|
|
@@ -2590,7 +2593,7 @@ class it {
|
|
|
2590
2593
|
*/
|
|
2591
2594
|
updateFromProps(t) {
|
|
2592
2595
|
const e = this.extractRenderingSettingsFromProps(t);
|
|
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,
|
|
2596
|
+
return e.valid ? (this.channelsVisible = e.channelsVisible, this.channelTargetC = e.channelTargetC, this.channelMaxResolutionIndex = e.channelMaxResolutionIndex, this.colors = e.colors, this.contrastLimits = e.contrastLimits, this.renderingMode = e.renderingMode, this.layerTransparency = e.layerTransparency, this.xSlice = e.xSlice, this.ySlice = e.ySlice, this.zSlice = e.zSlice, this.uniforms.lodFactor.value = e.lodFactor, A(`lodFactor ${e.lodFactor}`), this.shader.uniforms.lodFactor.value = e.lodFactor, A("Updating from props - success"), !0) : (A("Updating from props - invalid settings"), !1);
|
|
2594
2597
|
}
|
|
2595
2598
|
/**
|
|
2596
2599
|
* Update the rendering based on the current volume data from the data manager
|
|
@@ -2598,7 +2601,7 @@ class it {
|
|
|
2598
2601
|
* @returns {Object|null} Updated rendering settings or null if rendering is not possible
|
|
2599
2602
|
*/
|
|
2600
2603
|
updateRendering({ zarrStoreShapes: t, originalScaleXYZ: e, physicalDimensionsXYZ: i, maxResolutionXYZ: o, boxDimensionsXYZ: r, normalizedScaleXYZ: a, bcTHREE: c, ptTHREE: u }) {
|
|
2601
|
-
if (
|
|
2604
|
+
if (A("Updating rendering"), this.channelTargetC.findIndex((v, h) => this.channelsVisible[h]), !Array.isArray(t) || t.length === 0)
|
|
2602
2605
|
return null;
|
|
2603
2606
|
const l = t[0], p = {
|
|
2604
2607
|
xLength: l[4] || 1,
|
|
@@ -2615,11 +2618,11 @@ class it {
|
|
|
2615
2618
|
this.colors[h][2] / 255,
|
|
2616
2619
|
this.channelsVisible[h] ? 1 : 0
|
|
2617
2620
|
]), n.debug("colorsSave", s), this.contrastLimits[h][0] === 0 && this.contrastLimits[h][1] === 255 ? d.push([
|
|
2618
|
-
|
|
2619
|
-
|
|
2621
|
+
oe(b[0], b),
|
|
2622
|
+
oe(b[1], b)
|
|
2620
2623
|
]) : d.push([
|
|
2621
|
-
|
|
2622
|
-
|
|
2624
|
+
oe(this.contrastLimits[h][0], b),
|
|
2625
|
+
oe(this.contrastLimits[h][1], b)
|
|
2623
2626
|
]);
|
|
2624
2627
|
}
|
|
2625
2628
|
}), !this.zarrInit) {
|
|
@@ -2665,13 +2668,13 @@ class it {
|
|
|
2665
2668
|
* @param {Vector2} zSlice - Z clipping plane
|
|
2666
2669
|
*/
|
|
2667
2670
|
updateUniforms(t, e, i, o, r, a, c, u, l, p, m) {
|
|
2668
|
-
|
|
2671
|
+
A("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
2672
|
for (let s = 0; s < 7; s++)
|
|
2670
2673
|
typeof this.channelMaxResolutionIndex[s] == "number" && this.uniforms[`res${s}`].value.set(Math.max(1, this.channelMaxResolutionIndex[s]), this.zarrStoreNumResolutions - 1);
|
|
2671
2674
|
}
|
|
2672
2675
|
/**
|
|
2673
2676
|
* Sets the processing render target
|
|
2674
|
-
* @param {
|
|
2677
|
+
* @param {import('three').WebGLRenderTarget} mrt - Render target with 3 attachments
|
|
2675
2678
|
*/
|
|
2676
2679
|
/*
|
|
2677
2680
|
setProcessingTargets(mrt) {
|
|
@@ -2680,12 +2683,12 @@ class it {
|
|
|
2680
2683
|
}
|
|
2681
2684
|
*/
|
|
2682
2685
|
setChannelMapping(t) {
|
|
2683
|
-
|
|
2686
|
+
A("setting channel mapping"), n.debug("channelMapping", t), this.uniforms.channelMapping.value = t;
|
|
2684
2687
|
}
|
|
2685
2688
|
// Only called on initialization of the
|
|
2686
2689
|
// VolumeDataManager and VolumeRenderManager for a particular image.
|
|
2687
2690
|
setZarrUniforms(t, e) {
|
|
2688
|
-
|
|
2691
|
+
A("setting zarr uniforms"), n.debug("zarrStore", t), n.debug("PT", e);
|
|
2689
2692
|
for (let i = 0; i <= 9; i++)
|
|
2690
2693
|
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");
|
|
2691
2694
|
n.debug("zarrStore.brickLayout", t.brickLayout), this.zarrStoreNumResolutions = t.brickLayout.length;
|
|
@@ -2698,13 +2701,13 @@ class it {
|
|
|
2698
2701
|
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);
|
|
2699
2702
|
}
|
|
2700
2703
|
}
|
|
2701
|
-
const
|
|
2704
|
+
const Qe = `//
|
|
2702
2705
|
varying vec2 vUv;
|
|
2703
2706
|
void main() {
|
|
2704
2707
|
vUv = uv;
|
|
2705
2708
|
gl_Position = vec4(position, 1.0);
|
|
2706
2709
|
}
|
|
2707
|
-
`,
|
|
2710
|
+
`, Je = `//
|
|
2708
2711
|
// Input texture to blur
|
|
2709
2712
|
uniform sampler2D tDiffuse;
|
|
2710
2713
|
// Resolution of the texture (width, height)
|
|
@@ -2890,31 +2893,31 @@ void main() {
|
|
|
2890
2893
|
gl_FragColor = color;
|
|
2891
2894
|
}
|
|
2892
2895
|
`;
|
|
2893
|
-
function
|
|
2896
|
+
function Re(f, t) {
|
|
2894
2897
|
const e = f.properties?.get(t);
|
|
2895
2898
|
return e?.framebuffer || e?.__webglFramebuffer || t.__webglFramebuffer;
|
|
2896
2899
|
}
|
|
2897
2900
|
function J(f) {
|
|
2898
|
-
|
|
2901
|
+
ue(he.DEBUG) && console.warn(`%cV: ${f}`, "background: deeppink; color: white; padding: 2px; border-radius: 3px;");
|
|
2899
2902
|
}
|
|
2900
|
-
function
|
|
2903
|
+
function et(f, t, e, { mrtRef: i }) {
|
|
2901
2904
|
f.setRenderTarget(i.current), f.clear(!0, !0, !0), f.render(e, t);
|
|
2902
2905
|
}
|
|
2903
|
-
function
|
|
2906
|
+
function tt(f, { screenSceneRef: t, screenCameraRef: e }) {
|
|
2904
2907
|
f.setRenderTarget(null), f.clear(!0, !0, !0), f.render(t.current, e.current);
|
|
2905
2908
|
}
|
|
2906
|
-
function
|
|
2909
|
+
function nt(f, { frameRef: t, dataManager: e, mrtRef: i, bufRequest: o, bufUsage: r }) {
|
|
2907
2910
|
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,
|
|
2911
|
+
e.noNewRequests === !0 && !e.manuallyStopped && c % 100 === 0 && c < 500 && (e.noNewRequests = !1), e.triggerRequest === !0 && e.noNewRequests === !1 ? (a.bindFramebuffer(a.READ_FRAMEBUFFER, Re(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, {
|
|
2909
2912
|
// If width/height are not yet available,
|
|
2910
2913
|
// processRequestData will proceed without weighting.
|
|
2911
2914
|
width: i?.current?.width,
|
|
2912
2915
|
height: i?.current?.height,
|
|
2913
2916
|
// Default sigmaNormalized = 0.25; can be tuned
|
|
2914
|
-
sigmaNormalized:
|
|
2915
|
-
})) : e.triggerUsage === !0 && e.noNewRequests === !1 && (a.bindFramebuffer(a.READ_FRAMEBUFFER,
|
|
2917
|
+
sigmaNormalized: Xe
|
|
2918
|
+
})) : e.triggerUsage === !0 && e.noNewRequests === !1 && (a.bindFramebuffer(a.READ_FRAMEBUFFER, Re(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));
|
|
2916
2919
|
}
|
|
2917
|
-
function
|
|
2920
|
+
function rt(f, t) {
|
|
2918
2921
|
const { invalidate: e, isInteracting: i, dataManager: o, spatialRenderingModeChanging: r, meshRef: a, stillRef: c, screenQuadRef: u, lastSampleRef: l, frameRef: p, lastFrameCountRef: m } = t;
|
|
2919
2922
|
if (u.current && (c.current ? u.current.material.uniforms.gaussian.value = 0 : u.current.material.uniforms.gaussian.value = 7), i) {
|
|
2920
2923
|
o.manuallyStopped || (o.noNewRequests = !1, o.triggerUsage = !0);
|
|
@@ -2936,11 +2939,11 @@ function ut(f, t) {
|
|
|
2936
2939
|
h > 0 && (b = g / h), l.current = v, m.current = p.current;
|
|
2937
2940
|
const R = b > 100 && d > 0, y = b < 30 && d < o.PT.lowestDataRes;
|
|
2938
2941
|
if (R || y) {
|
|
2939
|
-
const
|
|
2940
|
-
s && (s.renderRes.value =
|
|
2942
|
+
const N = d + (y ? 1 : -1);
|
|
2943
|
+
s && (s.renderRes.value = N), e();
|
|
2941
2944
|
}
|
|
2942
2945
|
}
|
|
2943
|
-
function
|
|
2946
|
+
function it(f) {
|
|
2944
2947
|
const {
|
|
2945
2948
|
images: t,
|
|
2946
2949
|
imageLayerScopes: e,
|
|
@@ -2955,36 +2958,36 @@ function ht(f) {
|
|
|
2955
2958
|
gl: l
|
|
2956
2959
|
// scene,
|
|
2957
2960
|
// camera
|
|
2958
|
-
} =
|
|
2961
|
+
} = ve(), p = ve((E) => E.invalidate), m = D(null), s = D(null), d = D(null), v = D(null), h = D(null), [g, b] = le({
|
|
2959
2962
|
uniforms: null,
|
|
2960
2963
|
shader: null,
|
|
2961
2964
|
meshScale: [1, 1, 1],
|
|
2962
2965
|
geometrySize: [1, 1, 1]
|
|
2963
|
-
}), R = a === "3D", [y,
|
|
2966
|
+
}), R = a === "3D", [y, N] = le(!1), L = D(null), O = D(null), T = D(null), [U, q] = le(!1), Y = D(null), X = D(!1), S = D(0), ye = D(0), Ee = D(0), x = de(() => new Ye(l), [l]), z = de(() => new $e(), []);
|
|
2964
2967
|
Q(() => {
|
|
2965
2968
|
J("useEffect MRT target matching canvas");
|
|
2966
|
-
const { width: E, height: I } = l.domElement,
|
|
2967
|
-
|
|
2968
|
-
$.format =
|
|
2969
|
+
const { width: E, height: I } = l.domElement, H = new M.WebGLRenderTarget(E, I, { count: 3 }), F = H.textures;
|
|
2970
|
+
F.forEach(($) => {
|
|
2971
|
+
$.format = M.RGBAFormat, $.type = M.UnsignedByteType, $.minFilter = M.NearestFilter, $.magFilter = M.NearestFilter, $.generateMipmaps = !1;
|
|
2969
2972
|
});
|
|
2970
|
-
const
|
|
2971
|
-
|
|
2972
|
-
const
|
|
2973
|
+
const te = new M.Scene(), ne = new M.OrthographicCamera(-1, 1, 1, -1, 0.1, 10);
|
|
2974
|
+
ne.position.z = 1;
|
|
2975
|
+
const re = new M.ShaderMaterial({
|
|
2973
2976
|
uniforms: {
|
|
2974
2977
|
// Bind the first render target texture as the input of the gaussian blur shader.
|
|
2975
|
-
tDiffuse: { value:
|
|
2976
|
-
resolution: { value: new
|
|
2978
|
+
tDiffuse: { value: F[0] },
|
|
2979
|
+
resolution: { value: new M.Vector2(E, I) },
|
|
2977
2980
|
gaussian: { value: 7 }
|
|
2978
2981
|
},
|
|
2979
|
-
vertexShader:
|
|
2980
|
-
fragmentShader:
|
|
2982
|
+
vertexShader: Qe,
|
|
2983
|
+
fragmentShader: Je,
|
|
2981
2984
|
transparent: !0
|
|
2982
|
-
}),
|
|
2983
|
-
return
|
|
2984
|
-
|
|
2985
|
+
}), se = new M.Mesh(new M.PlaneGeometry(2, 2), re);
|
|
2986
|
+
return te.add(se), L.current = te, O.current = ne, T.current = se, d.current = new Uint8Array(E * I * 4), v.current = new Uint8Array(E * I * 4), h.current = H, () => {
|
|
2987
|
+
H.dispose(), re.dispose(), se.geometry.dispose();
|
|
2985
2988
|
};
|
|
2986
2989
|
}, [l]);
|
|
2987
|
-
const ae = e?.[0],
|
|
2990
|
+
const ae = e?.[0], Te = t?.[ae];
|
|
2988
2991
|
o?.[ae];
|
|
2989
2992
|
const ee = r?.[0]?.[ae];
|
|
2990
2993
|
Q(() => {
|
|
@@ -2994,7 +2997,7 @@ function ht(f) {
|
|
|
2994
2997
|
n.debug("dataManager or renderManager not initialized yet");
|
|
2995
2998
|
return;
|
|
2996
2999
|
}
|
|
2997
|
-
if (!
|
|
3000
|
+
if (!Te) {
|
|
2998
3001
|
n.debug("no first image layer yet");
|
|
2999
3002
|
return;
|
|
3000
3003
|
}
|
|
@@ -3003,15 +3006,15 @@ function ht(f) {
|
|
|
3003
3006
|
return;
|
|
3004
3007
|
}
|
|
3005
3008
|
return (async () => {
|
|
3006
|
-
if (x.initStatus ===
|
|
3007
|
-
n.debug("dataManager already initialized, skipping"),
|
|
3009
|
+
if (x.initStatus === V.COMPLETE) {
|
|
3010
|
+
n.debug("dataManager already initialized, skipping"), N(!0);
|
|
3008
3011
|
return;
|
|
3009
3012
|
}
|
|
3010
3013
|
if (x.initImages(t, e), await x.init(ee), E) {
|
|
3011
3014
|
n.debug("Initialization useEffect has rerun, aborting remaining initialization");
|
|
3012
3015
|
return;
|
|
3013
3016
|
}
|
|
3014
|
-
n.debug("dataManager initialized"), z.setZarrUniforms(x.zarrStore, x.PT), z.setChannelMapping(x.channels.colorMappings), n.debug("rm.uniforms", z.uniforms),
|
|
3017
|
+
n.debug("dataManager initialized"), z.setZarrUniforms(x.zarrStore, x.PT), z.setChannelMapping(x.channels.colorMappings), n.debug("rm.uniforms", z.uniforms), N(!0), p();
|
|
3015
3018
|
})(), () => {
|
|
3016
3019
|
E = !0;
|
|
3017
3020
|
};
|
|
@@ -3027,9 +3030,9 @@ function ht(f) {
|
|
|
3027
3030
|
spatialRenderingMode: a
|
|
3028
3031
|
};
|
|
3029
3032
|
if (z.updateFromProps(I)) {
|
|
3030
|
-
const { zarrInit:
|
|
3031
|
-
|
|
3032
|
-
const
|
|
3033
|
+
const { zarrInit: H } = z;
|
|
3034
|
+
H || (x.ptTHREE.needsUpdate = !1, x.bcTHREE.needsUpdate = !1, x.renderer.initTexture(x.bcTHREE), x.renderer.initTexture(x.ptTHREE), x.initTexture());
|
|
3035
|
+
const F = z.updateRendering({
|
|
3033
3036
|
zarrStoreShapes: x.zarrStore.shapes,
|
|
3034
3037
|
originalScaleXYZ: x.getOriginalScaleXYZ(),
|
|
3035
3038
|
physicalDimensionsXYZ: x.getPhysicalDimensionsXYZ(),
|
|
@@ -3039,73 +3042,73 @@ function ht(f) {
|
|
|
3039
3042
|
bcTHREE: x.bcTHREE,
|
|
3040
3043
|
ptTHREE: x.ptTHREE
|
|
3041
3044
|
});
|
|
3042
|
-
|
|
3045
|
+
F && b(F);
|
|
3043
3046
|
}
|
|
3044
3047
|
}
|
|
3045
|
-
}, [x, z, t, e, i, o, r, a, y]),
|
|
3048
|
+
}, [x, z, t, e, i, o, r, a, y]), Me((E, I, H) => {
|
|
3046
3049
|
if (!h.current || !x || !z || !g.shader)
|
|
3047
3050
|
return;
|
|
3048
|
-
const { gl:
|
|
3049
|
-
|
|
3051
|
+
const { gl: F, camera: te, scene: ne, clock: re } = E;
|
|
3052
|
+
X.current || et(F, te, ne, { mrtRef: h }), tt(F, { screenSceneRef: L, screenCameraRef: O }), nt(F, { frameRef: S, dataManager: x, mrtRef: h, bufRequest: d, bufUsage: v }), rt(re, {
|
|
3050
3053
|
invalidate: p,
|
|
3051
|
-
isInteracting:
|
|
3054
|
+
isInteracting: U,
|
|
3052
3055
|
dataManager: x,
|
|
3053
3056
|
spatialRenderingModeChanging: c,
|
|
3054
3057
|
meshRef: s,
|
|
3055
|
-
stillRef:
|
|
3058
|
+
stillRef: X,
|
|
3056
3059
|
screenQuadRef: T,
|
|
3057
|
-
lastSampleRef:
|
|
3060
|
+
lastSampleRef: ye,
|
|
3058
3061
|
frameRef: S,
|
|
3059
|
-
lastFrameCountRef:
|
|
3062
|
+
lastFrameCountRef: Ee
|
|
3060
3063
|
}), S.current += 1;
|
|
3061
3064
|
}, 1);
|
|
3062
|
-
const
|
|
3063
|
-
if (J("invalidateOnInteraction callback"),
|
|
3065
|
+
const W = K((E) => {
|
|
3066
|
+
if (J("invalidateOnInteraction callback"), q(E), E) {
|
|
3064
3067
|
const I = s.current?.material?.uniforms;
|
|
3065
|
-
I && (I.renderRes.value = x.PT.lowestDataRes),
|
|
3068
|
+
I && (I.renderRes.value = x.PT.lowestDataRes), X.current = !1, p();
|
|
3066
3069
|
}
|
|
3067
|
-
}),
|
|
3068
|
-
|
|
3069
|
-
}),
|
|
3070
|
+
}), Se = K((E) => {
|
|
3071
|
+
W(!0);
|
|
3072
|
+
}), we = K((E) => {
|
|
3070
3073
|
clearTimeout(Y.current), Y.current = setTimeout(() => {
|
|
3071
|
-
|
|
3074
|
+
W(!1);
|
|
3072
3075
|
}, 300);
|
|
3073
3076
|
});
|
|
3074
3077
|
Q(() => {
|
|
3075
|
-
y && (J("useEffect firstImageLayerChannelCoordination"),
|
|
3076
|
-
|
|
3078
|
+
y && (J("useEffect firstImageLayerChannelCoordination"), W(!0), n.debug("something about channels changed"), x.updateChannels(ee), z.setChannelMapping(x.channels.colorMappings), clearTimeout(Y.current), Y.current = setTimeout(() => {
|
|
3079
|
+
W(!1);
|
|
3077
3080
|
}, 300));
|
|
3078
|
-
}, [x, ee, z,
|
|
3079
|
-
const
|
|
3081
|
+
}, [x, ee, z, W, y]);
|
|
3082
|
+
const ze = K(() => {
|
|
3080
3083
|
x && x.stopLoading();
|
|
3081
|
-
}),
|
|
3084
|
+
}), ke = K(() => {
|
|
3082
3085
|
x && x.restartLoading();
|
|
3083
|
-
}),
|
|
3086
|
+
}), Ie = K(() => x ? x.getLoadingProgress() : null);
|
|
3084
3087
|
return Q(() => {
|
|
3085
3088
|
if (!u)
|
|
3086
3089
|
return;
|
|
3087
3090
|
const E = setInterval(() => {
|
|
3088
|
-
const I =
|
|
3091
|
+
const I = Ie();
|
|
3089
3092
|
u({
|
|
3090
3093
|
loadingProgress: I,
|
|
3091
|
-
stillRef:
|
|
3092
|
-
onStopLoading:
|
|
3093
|
-
onRestartLoading:
|
|
3094
|
+
stillRef: X,
|
|
3095
|
+
onStopLoading: ze,
|
|
3096
|
+
onRestartLoading: ke
|
|
3094
3097
|
});
|
|
3095
3098
|
}, 1e3);
|
|
3096
3099
|
return () => clearInterval(E);
|
|
3097
|
-
}, [u,
|
|
3098
|
-
|
|
3100
|
+
}, [u, X]), !R || !x || !z ? null : g.shader ? ie("group", { children: [G(
|
|
3101
|
+
me,
|
|
3099
3102
|
{
|
|
3100
3103
|
// ref={mainOrbitControlsRef}
|
|
3101
3104
|
enableDamping: !1,
|
|
3102
|
-
onStart:
|
|
3103
|
-
onEnd:
|
|
3105
|
+
onStart: Se,
|
|
3106
|
+
onEnd: we
|
|
3104
3107
|
}
|
|
3105
|
-
),
|
|
3108
|
+
), ie("mesh", { ref: s, scale: g.meshScale, children: [G("boxGeometry", { args: g.geometrySize }), G("shaderMaterial", { uniforms: g.uniforms, vertexShader: g.shader.vertexShader, fragmentShader: g.shader.fragmentShader, side: M.BackSide, transparent: !1, glslVersion: M.GLSL3 })] })] }) : ie("group", { children: [ie("mesh", { children: [G("boxGeometry", { args: [1, 1, 1] }), G("meshBasicMaterial", { color: "#444", wireframe: !0 })] }), G(me, { ref: m })] });
|
|
3106
3109
|
}
|
|
3107
|
-
function
|
|
3108
|
-
return
|
|
3110
|
+
function ft(f) {
|
|
3111
|
+
return G(Pe, { frameloop: "always", style: {
|
|
3109
3112
|
position: "absolute",
|
|
3110
3113
|
top: 0,
|
|
3111
3114
|
left: 0,
|
|
@@ -3125,8 +3128,8 @@ function xt(f) {
|
|
|
3125
3128
|
logarithmicDepthBuffer: !1,
|
|
3126
3129
|
preserveDrawingBuffer: !1,
|
|
3127
3130
|
autoClear: !1
|
|
3128
|
-
}, children:
|
|
3131
|
+
}, children: G(De, { fallback: "Initializing Volume View...", children: G(it, { ...f }) }) });
|
|
3129
3132
|
}
|
|
3130
3133
|
export {
|
|
3131
|
-
|
|
3134
|
+
ft as SpatialWrapper
|
|
3132
3135
|
};
|