@vitessce/comparative 4.0.0-test.3 → 4.0.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.
Files changed (45) hide show
  1. package/dist/{GeometryAndMeshXR-mG6LDGng.js → GeometryAndMeshXR-BDALKiGu.js} +39 -38
  2. package/dist/{ReactNeuroglancer-HSVAR9Hg.js → ReactNeuroglancer-DIEM_zJZ.js} +1 -1
  3. package/dist/{XREnterButton-BgKg9M2i.js → XREnterButton-CqJBXry_.js} +1 -1
  4. package/dist/{XRSceneComponents-BJhlm4Zh.js → XRSceneComponents-BI1xgf_W.js} +4 -4
  5. package/dist/XRWrapper-C5Rd9HYZ.js +9 -0
  6. package/dist/{deflate-CReLYg6P.js → deflate-CLiFaG0l.js} +1 -1
  7. package/dist/{higlass-DIU9q8Gs.js → higlass-D6CnhtOV.js} +1 -1
  8. package/dist/index-AcW1VLoM.js +999 -0
  9. package/dist/{index-CIvxlOK9.js → index-BK52HWA4.js} +109958 -133223
  10. package/dist/{index-Dfil7xa8.js → index-D1nv5RxH.js} +160 -157
  11. package/dist/index.min.js +32 -31
  12. package/dist/{jpeg-DT4ea8DJ.js → jpeg-Bnj3m5bk.js} +1 -1
  13. package/dist/{lerc-BwDTukKR.js → lerc-CxXz0epg.js} +1 -1
  14. package/dist/{lzw-8s8oN2TN.js → lzw-BAnqqsL7.js} +1 -1
  15. package/dist/{packbits-CaA4IVE4.js → packbits-CP79R_oC.js} +1 -1
  16. package/dist/{raw-BnIhTgXM.js → raw-Bt14dfGM.js} +1 -1
  17. package/dist/{webimage-D7cBoCP0.js → webimage-DzJeAmim.js} +1 -1
  18. package/dist/xrStore-BtX9iGzw.js +8 -0
  19. package/dist-tsc/BiomarkerSelect.js +2 -1
  20. package/dist-tsc/BiomarkerSelect.js.map +1 -0
  21. package/dist-tsc/ComparativeConfig.d.ts.map +1 -1
  22. package/dist-tsc/ComparativeConfig.js +41 -8
  23. package/dist-tsc/ComparativeConfig.js.map +1 -0
  24. package/dist-tsc/ControlledComparative.js +2 -1
  25. package/dist-tsc/ControlledComparative.js.map +1 -0
  26. package/dist-tsc/UncontrolledComparative.js +1 -0
  27. package/dist-tsc/UncontrolledComparative.js.map +1 -0
  28. package/dist-tsc/index.js +1 -0
  29. package/dist-tsc/index.js.map +1 -0
  30. package/package.json +31 -13
  31. package/src/BiomarkerSelect.jsx +1 -1
  32. package/src/ComparativeConfig.jsx +40 -8
  33. package/src/ControlledComparative.jsx +1 -1
  34. package/dist/OrbitControls-BBpo0Bmn.js +0 -7700
  35. package/dist/XRWrapper-DqbVnB5a.js +0 -10
  36. package/dist/emulate-DRDNyX-e.js +0 -28295
  37. package/dist/index-CvdoV01Q.js +0 -57
  38. package/dist/index-uxqqRrpE.js +0 -7737
  39. package/dist/living_room-uy_CEYZC.js +0 -11
  40. package/dist/meeting_room-BjXC3fLc.js +0 -11
  41. package/dist/music_room-AFchga9Y.js +0 -11
  42. package/dist/office_large-qDeoZNBo.js +0 -11
  43. package/dist/office_small-B_PLvrYC.js +0 -11
  44. package/dist/ray-grab-Cio1GXKX.js +0 -3714
  45. package/dist/xrStore-E6OMxK_W.js +0 -10
@@ -0,0 +1,999 @@
1
+ var pe = Object.defineProperty;
2
+ var xe = (t, e, a) => e in t ? pe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
3
+ var k = (t, e, a) => xe(t, typeof e != "symbol" ? e + "" : e, a);
4
+ import { jsxs as X, jsx as p, Fragment as ye } from "react/jsx-runtime";
5
+ import te, { useRef as Q, useState as G, useEffect as q, Suspense as ee, forwardRef as be } from "react";
6
+ import { Canvas as Se } from "@react-three/fiber";
7
+ import { Center as Ce, Text as de, Line as ze, Bvh as Te, OrbitControls as we } from "@react-three/drei";
8
+ import { Matrix3 as Me, Matrix4 as ne, Vector3 as L, Vector2 as j, UniformsUtils as Le, Data3DTexture as Pe, RedFormat as Ae, FloatType as De, LinearFilter as he, FrontSide as ve, Scene as Ie, Group as Fe, MeshPhysicalMaterial as Ee, MeshBasicMaterial as Ve, MeshStandardMaterial as Re, BackSide as Oe } from "three";
9
+ import { C as N, g as ke } from "./index-BK52HWA4.js";
10
+ function Ue({ currentLine: t, scale: e }) {
11
+ const a = Q(null);
12
+ return X("group", { children: [p(Ce, { bottom: !0, right: !0, position: [t.midPoint.x, t.midPoint.y, t.midPoint.z], rotation: [0, 0, 0], children: p(de, { color: "gray", scale: 0.05, ref: a, children: `${(t.startPoint.distanceTo(t.endPoint) * e).toFixed(2)} µm` }) }), p(ze, {
13
+ points: [t.startPoint, t.endPoint],
14
+ color: "white",
15
+ lineWidth: 2,
16
+ dashed: !1,
17
+ segments: !0
18
+ })] });
19
+ }
20
+ class Ne {
21
+ /**
22
+ * @param {number} xLength Width of the volume
23
+ * @param {number} yLength Length of the volume
24
+ * @param {number} zLength Depth of the volume
25
+ * @param {string} type The type of data (uint8, uint16, ...)
26
+ * @param {ArrayBuffer} arrayBuffer The buffer with volume data
27
+ */
28
+ constructor(e, a, o, i, l) {
29
+ k(this, "spacing", [1, 1, 1]);
30
+ // Offset of the volume in the RAS coordinate system
31
+ k(this, "offset", [0, 0, 0]);
32
+ // The IJK to RAS matrix
33
+ k(this, "matrix", new Me().identity());
34
+ // The list of all the slices associated to this volume
35
+ k(this, "sliceList", []);
36
+ /**
37
+ * The voxels with values under this
38
+ * threshold won't appear in the slices.
39
+ * If changed, geometryNeedsUpdate is automatically set to true on all
40
+ * the slices associated to this volume
41
+ */
42
+ k(this, "lowerThresholdValue", -1 / 0);
43
+ /**
44
+ * The voxels with values over this
45
+ * threshold won't appear in the slices.
46
+ * If changed, geometryNeedsUpdate is automatically set to true on all
47
+ * the slices associated to this volume
48
+ */
49
+ k(this, "upperThresholdValue", 1 / 0);
50
+ // Width of the volume in the IJK coordinate system
51
+ k(this, "xLength", 1);
52
+ // Height of the volume in the IJK coordinate system
53
+ k(this, "yLength", 1);
54
+ // Depth of the volume in the IJK coordinate system
55
+ k(this, "zLength", 1);
56
+ // Data of the volume
57
+ k(this, "data");
58
+ k(this, "RASDimensions");
59
+ k(this, "inverseMatrix");
60
+ k(this, "min");
61
+ k(this, "max");
62
+ if (e !== void 0) {
63
+ switch (this.xLength = Number(e) || 1, this.yLength = Number(a) || 1, this.zLength = Number(o) || 1, i) {
64
+ case "Uint8":
65
+ case "uint8":
66
+ case "uchar":
67
+ case "unsigned char":
68
+ case "uint8_t":
69
+ this.data = new Uint8Array(l);
70
+ break;
71
+ case "Int8":
72
+ case "int8":
73
+ case "signed char":
74
+ case "int8_t":
75
+ this.data = new Int8Array(l);
76
+ break;
77
+ case "Int16":
78
+ case "int16":
79
+ case "short":
80
+ case "short int":
81
+ case "signed short":
82
+ case "signed short int":
83
+ case "int16_t":
84
+ this.data = new Int16Array(l);
85
+ break;
86
+ case "Uint16":
87
+ case "uint16":
88
+ case "ushort":
89
+ case "unsigned short":
90
+ case "unsigned short int":
91
+ case "uint16_t":
92
+ this.data = new Uint16Array(l);
93
+ break;
94
+ case "Int32":
95
+ case "int32":
96
+ case "int":
97
+ case "signed int":
98
+ case "int32_t":
99
+ this.data = new Int32Array(l);
100
+ break;
101
+ case "Uint32":
102
+ case "uint32":
103
+ case "uint":
104
+ case "unsigned int":
105
+ case "uint32_t":
106
+ this.data = new Uint32Array(l);
107
+ break;
108
+ case "longlong":
109
+ case "long long":
110
+ case "long long int":
111
+ case "signed long long":
112
+ case "signed long long int":
113
+ case "int64":
114
+ case "int64_t":
115
+ case "ulonglong":
116
+ case "unsigned long long":
117
+ case "unsigned long long int":
118
+ case "uint64":
119
+ case "uint64_t":
120
+ throw new Error("uint64_t type is not supported in JavaScript");
121
+ case "Float32":
122
+ case "float32":
123
+ case "float":
124
+ this.data = new Float32Array(l);
125
+ break;
126
+ case "Float64":
127
+ case "float64":
128
+ case "double":
129
+ this.data = new Float64Array(l);
130
+ break;
131
+ default:
132
+ this.data = new Uint8Array(l);
133
+ }
134
+ if (this.data.length !== this.xLength * this.yLength * this.zLength)
135
+ throw new Error("lengths are not matching arrayBuffer size");
136
+ }
137
+ }
138
+ get lowerThreshold() {
139
+ return this.lowerThresholdValue;
140
+ }
141
+ set lowerThreshold(e) {
142
+ this.lowerThresholdValue = e, this.sliceList.forEach((a) => {
143
+ a.geometryNeedsUpdate = !0;
144
+ });
145
+ }
146
+ get upperThreshold() {
147
+ return this.upperThresholdValue;
148
+ }
149
+ set upperThreshold(e) {
150
+ this.upperThresholdValue = e, this.sliceList.forEach((a) => {
151
+ a.geometryNeedsUpdate = !0;
152
+ });
153
+ }
154
+ /**
155
+ * Shortcut for data[access(i,j,k)]
156
+ */
157
+ getData(e, a, o) {
158
+ return this.data[o * this.xLength * this.yLength + a * this.xLength + e];
159
+ }
160
+ /**
161
+ * Compute the index in the data
162
+ * array corresponding to the given coordinates in IJK system
163
+ */
164
+ access(e, a, o) {
165
+ return o * this.xLength * this.yLength + a * this.xLength + e;
166
+ }
167
+ /**
168
+ * Retrieve the IJK coordinates of the voxel
169
+ * corresponding of the given index in the data
170
+ */
171
+ reverseAccess(e) {
172
+ const a = Math.floor(e / (this.yLength * this.xLength)), o = Math.floor((e - a * this.yLength * this.xLength) / this.xLength);
173
+ return [e - a * this.yLength * this.xLength - o * this.xLength, o, a];
174
+ }
175
+ /**
176
+ * Apply a function to all the voxels, be careful,
177
+ * the value will be replaced
178
+ */
179
+ // eslint-disable-next-line max-len
180
+ map(e, a) {
181
+ const { length: o } = this.data, i = a || this;
182
+ for (let l = 0; l < o; l++)
183
+ this.data[l] = e.call(i, this.data[l], l, this.data);
184
+ return this;
185
+ }
186
+ /**
187
+ * Compute the orientation
188
+ * of the slice and returns all the information relative to the
189
+ * geometry such as sliceAccess,
190
+ * the plane matrix (orientation and position in RAS coordinate)
191
+ * and the dimensions of the plane in both coordinate system.
192
+ */
193
+ extractPerpendicularPlane(e, a) {
194
+ const o = new ne().identity(), i = this;
195
+ let l, n, m, x;
196
+ const g = new L(), r = new L(), c = new L(), T = new L(this.xLength, this.yLength, this.zLength);
197
+ switch (e) {
198
+ case "x":
199
+ g.set(1, 0, 0), r.set(0, 0, -1), c.set(0, -1, 0), l = this.spacing[2], n = this.spacing[1], x = new L(a, 0, 0), o.multiply(new ne().makeRotationY(Math.PI / 2)), m = (i.RASDimensions[0] - 1) / 2, o.setPosition(new L(a - m, 0, 0));
200
+ break;
201
+ case "y":
202
+ g.set(0, 1, 0), r.set(1, 0, 0), c.set(0, 0, 1), l = this.spacing[0], n = this.spacing[2], x = new L(0, a, 0), o.multiply(new ne().makeRotationX(-Math.PI / 2)), m = (i.RASDimensions[1] - 1) / 2, o.setPosition(new L(0, a - m, 0));
203
+ break;
204
+ case "z":
205
+ default:
206
+ g.set(0, 0, 1), r.set(1, 0, 0), c.set(0, -1, 0), l = this.spacing[0], n = this.spacing[1], x = new L(0, 0, a), m = (i.RASDimensions[2] - 1) / 2, o.setPosition(new L(0, 0, a - m));
207
+ break;
208
+ }
209
+ r.applyMatrix4(i.inverseMatrix).normalize(), r.argVar = "i", c.applyMatrix4(i.inverseMatrix).normalize(), c.argVar = "j", g.applyMatrix4(i.inverseMatrix).normalize();
210
+ const d = Math.floor(Math.abs(r.dot(T))), I = Math.floor(Math.abs(c.dot(T))), y = Math.abs(d * l), w = Math.abs(I * n);
211
+ x = Math.abs(Math.round(x.applyMatrix4(i.inverseMatrix).dot(g)));
212
+ const _ = [new L(1, 0, 0), new L(0, 1, 0), new L(0, 0, 1)], v = [r, c, g].find((P) => Math.abs(P.dot(_[0])) > 0.9), C = [r, c, g].find((P) => Math.abs(P.dot(_[1])) > 0.9), h = [r, c, g].find((P) => Math.abs(P.dot(_[2])) > 0.9);
213
+ function V(P, f) {
214
+ const z = v === g ? x : v.argVar === "i" ? P : f, U = C === g ? x : C.argVar === "i" ? P : f, F = h === g ? x : h.argVar === "i" ? P : f, H = v.dot(_[0]) > 0 ? z : i.xLength - 1 - z, W = C.dot(_[1]) > 0 ? U : i.yLength - 1 - U, Z = h.dot(_[2]) > 0 ? F : i.zLength - 1 - F;
215
+ return i.access(H, W, Z);
216
+ }
217
+ return {
218
+ iLength: d,
219
+ jLength: I,
220
+ sliceAccess: V,
221
+ matrix: o,
222
+ planeWidth: y,
223
+ planeHeight: w
224
+ };
225
+ }
226
+ /**
227
+ * Compute the minimum
228
+ * and the maximum of the data in the volume
229
+ * @returns {Array} [min,max]
230
+ */
231
+ computeMinMax() {
232
+ let e = 1 / 0, a = -1 / 0;
233
+ const o = this.data.length;
234
+ let i = 0;
235
+ for (i = 0; i < o; i++)
236
+ if (!Number.isNaN(this.data[i])) {
237
+ const l = this.data[i];
238
+ e = Math.min(e, l), a = Math.max(a, l);
239
+ }
240
+ return this.min = e, this.max = a, [e, a];
241
+ }
242
+ }
243
+ const je = {
244
+ uniforms: {
245
+ u_size: { value: new L(1, 1, 1) },
246
+ u_renderstyle: { value: 0 },
247
+ u_renderthreshold: { value: 0.5 },
248
+ u_opacity: { value: 0.5 },
249
+ u_clim: { value: new j(0.2, 0.8) },
250
+ u_clim2: { value: new j(0.2, 0.8) },
251
+ u_clim3: { value: new j(0.2, 0.8) },
252
+ u_clim4: { value: new j(0.2, 0.8) },
253
+ u_clim5: { value: new j(0.2, 0.8) },
254
+ u_clim6: { value: new j(0.2, 0.8) },
255
+ u_xClip: { value: new j(-1, 1e6) },
256
+ u_yClip: { value: new j(-1, 1e6) },
257
+ u_zClip: { value: new j(-1, 1e6) },
258
+ u_data: { value: null },
259
+ u_stop_geom: { value: null },
260
+ u_geo_color: { value: null },
261
+ u_window_size: { value: new j(1, 1) },
262
+ u_vol_scale: { value: new L(1, 1, 1) },
263
+ u_physical_Pixel: { value: 0.5 },
264
+ volumeTex: { value: null },
265
+ volumeTex2: { value: null },
266
+ volumeTex3: { value: null },
267
+ volumeTex4: { value: null },
268
+ volumeTex5: { value: null },
269
+ volumeTex6: { value: null },
270
+ u_color: { value: new L(0, 0, 0) },
271
+ u_color2: { value: new L(0, 0, 0) },
272
+ u_color3: { value: new L(0, 0, 0) },
273
+ u_color4: { value: new L(0, 0, 0) },
274
+ u_color5: { value: new L(0, 0, 0) },
275
+ u_color6: { value: new L(0, 0, 0) },
276
+ u_cmdata: { value: null },
277
+ near: { value: 0.1 },
278
+ far: { value: 1e4 },
279
+ alphaScale: { value: 0 },
280
+ dtScale: { value: 1 },
281
+ volumeCount: { value: 0 },
282
+ finalGamma: { value: 0 },
283
+ boxSize: { value: new L(1, 1, 1) }
284
+ },
285
+ vertexShader: [
286
+ "out vec3 rayDirUnnorm;",
287
+ "out vec3 cameraCorrected;",
288
+ "uniform vec3 u_vol_scale;",
289
+ "uniform vec3 u_size;",
290
+ "varying vec3 worldSpaceCoords;",
291
+ "varying vec2 vUv;",
292
+ "varying vec4 glPosition;",
293
+ "uniform highp vec3 boxSize;",
294
+ "void main()",
295
+ "{",
296
+ " worldSpaceCoords = position / boxSize + vec3(0.5, 0.5, 0.5); //move it from [-0.5;0.5] to [0,1]",
297
+ " cameraCorrected = (inverse(modelMatrix) * vec4(cameraPosition, 1.)).xyz;",
298
+ " rayDirUnnorm = position - cameraCorrected;",
299
+ " gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);",
300
+ " glPosition = gl_Position;",
301
+ " vUv = uv;",
302
+ "}"
303
+ ].join(`
304
+ `),
305
+ fragmentShader: [
306
+ "#include <packing>",
307
+ "precision highp float;",
308
+ " precision mediump sampler3D;",
309
+ "in vec3 rayDirUnnorm;",
310
+ "in vec3 cameraCorrected;",
311
+ "uniform sampler3D volumeTex;",
312
+ "uniform sampler3D volumeTex2;",
313
+ "uniform sampler3D volumeTex3;",
314
+ "uniform sampler3D volumeTex4;",
315
+ "uniform sampler3D volumeTex5;",
316
+ "uniform sampler3D volumeTex6;",
317
+ "uniform vec2 u_clim;",
318
+ "uniform vec2 u_clim2;",
319
+ "uniform vec2 u_clim3;",
320
+ "uniform vec2 u_clim4;",
321
+ "uniform vec2 u_clim5;",
322
+ "uniform vec2 u_clim6;",
323
+ "uniform vec2 u_window_size;",
324
+ "uniform vec2 u_xClip;",
325
+ "uniform vec2 u_yClip;",
326
+ "uniform vec2 u_zClip;",
327
+ "uniform sampler2D u_cmdata;",
328
+ "uniform sampler2D u_stop_geom;",
329
+ "uniform sampler2D u_geo_color;",
330
+ "uniform vec3 u_color;",
331
+ "uniform vec3 u_color2;",
332
+ "uniform vec3 u_color3;",
333
+ "uniform vec3 u_color4;",
334
+ "uniform vec3 u_color5;",
335
+ "uniform vec3 u_color6;",
336
+ "uniform float alphaScale;",
337
+ "uniform float dtScale;",
338
+ "uniform float finalGamma;",
339
+ "uniform float volumeCount;",
340
+ "uniform highp vec3 boxSize;",
341
+ "uniform vec3 u_size;",
342
+ "uniform int u_renderstyle;",
343
+ "uniform float u_opacity;",
344
+ "uniform vec3 u_vol_scale;",
345
+ "uniform float near;",
346
+ "uniform float u_physical_Pixel;",
347
+ "varying vec2 vUv;",
348
+ "varying vec4 glPosition;",
349
+ "uniform float far;",
350
+ "varying vec3 worldSpaceCoords;",
351
+ "float linearize_z(float z) {",
352
+ " return near * far / (far + z * (near - far));",
353
+ "}",
354
+ "vec2 intersect_hit(vec3 orig, vec3 dir) {",
355
+ " vec3 boxMin = vec3(-0.5) * boxSize;",
356
+ " vec3 boxMax = vec3( 0.5) * boxSize;",
357
+ " if(u_xClip.x > -1.0){ boxMin.x = u_xClip.x-(boxSize.x/2.0);",
358
+ " if(u_xClip.y < boxSize.x)",
359
+ " boxMax.x = u_xClip.y-(boxSize.x/2.0);",
360
+ " }",
361
+ " if(u_yClip.x > -1.0){ boxMin.y = u_yClip.x-(boxSize.y/2.0);",
362
+ " if(u_yClip.y < boxSize.y)",
363
+ " boxMax.y = u_yClip.y-(boxSize.y/2.0);",
364
+ " }",
365
+ " if(u_zClip.x > -1.0){ boxMin.z = u_zClip.x-(boxSize.z/2.0);",
366
+ " if(u_zClip.y < boxSize.z) boxMax.z = u_zClip.y-(boxSize.z/2.0);",
367
+ " }",
368
+ " vec3 invDir = 1.0 / dir;",
369
+ " vec3 tmin0 = (boxMin - orig) * invDir;",
370
+ " vec3 tmax0 = (boxMax - orig) * invDir;",
371
+ " vec3 tmin = min(tmin0, tmax0);",
372
+ " vec3 tmax = max(tmin0, tmax0);",
373
+ " float t0 = max(tmin.x, max(tmin.y, tmin.z));",
374
+ " float t1 = min(tmax.x, min(tmax.y, tmax.z));",
375
+ " return vec2(t0, t1);",
376
+ "}",
377
+ " // Pseudo-random number gen from",
378
+ " // http://www.reedbeta.com/blog/quick-and-easy-gpu-random-numbers-in-d3d11/",
379
+ " // with some tweaks for the range of values",
380
+ " float wang_hash(int seed) {",
381
+ " seed = (seed ^ 61) ^ (seed >> 16);",
382
+ " seed *= 9;",
383
+ " seed = seed ^ (seed >> 4);",
384
+ " seed *= 0x27d4eb2d;",
385
+ " seed = seed ^ (seed >> 15);",
386
+ " return float(seed % 2147483647) / float(2147483647);",
387
+ " }",
388
+ "float linear_to_srgb(float x) {",
389
+ " if (x <= 0.0031308f) {",
390
+ " return 12.92f * x;",
391
+ " }",
392
+ " return 1.055f * pow(x, 1.f / 2.4f) - 0.055f;",
393
+ "}",
394
+ "void main(void) {",
395
+ // For finding the settings for the MESH
396
+ // " gl_FragColor = vec4(worldSpaceCoords.x,worldSpaceCoords.y,worldSpaceCoords.z,0.5);",
397
+ // " return;",
398
+ //
399
+ " //STEP 1: Normalize the view Ray",
400
+ " vec3 rayDir = normalize(rayDirUnnorm);",
401
+ " //STEP 2: Intersect the ray with the volume bounds to find the interval along the ray overlapped by the volume",
402
+ " vec2 t_hit = intersect_hit(cameraCorrected, rayDir);",
403
+ " if (t_hit.x >= t_hit.y) {",
404
+ " discard;",
405
+ " }",
406
+ " //No sample behind the eye",
407
+ " t_hit.x = max(t_hit.x, 0.0);",
408
+ " //STEP 3: Compute the step size to march through the volume grid",
409
+ " ivec3 volumeTexSize = textureSize(volumeTex, 0);",
410
+ " vec3 dt_vec = 1.0 / (vec3(volumeTexSize) * abs(rayDir));",
411
+ " float dt = min(dt_vec.x, min(dt_vec.y, dt_vec.z));",
412
+ " dt = max(1.0, dt);",
413
+ " // Ray starting point, in the real space where the box may not be a cube.",
414
+ " // Prevents a lost WebGL context.",
415
+ // " if (dt < 0.0000001) {",
416
+ // " gl_FragColor = vec4(1.0);",
417
+ // " return;",
418
+ // " }",
419
+ " float offset = wang_hash(int(gl_FragCoord.x + 640.0 * gl_FragCoord.y));",
420
+ " vec3 p = cameraCorrected + (t_hit.x + offset + dt) * rayDir;",
421
+ " // Most browsers do not need this initialization, but add it to be safe.",
422
+ " gl_FragColor = vec4(0.0);",
423
+ " p = p / boxSize + vec3(0.5);",
424
+ " vec3 step = (rayDir * dt) / boxSize;",
425
+ " // ",
426
+ " // Initialization of some variables.",
427
+ " float max_val = 0.0;",
428
+ " float max_val2 = 0.0;",
429
+ " float max_val3 = 0.0;",
430
+ " float max_val4 = 0.0;",
431
+ " float max_val5 = 0.0;",
432
+ " float max_val6 = 0.0;",
433
+ " vec3 rgbCombo = vec3(0.0);",
434
+ " float total = 0.0;",
435
+ " int max_i = 30000;",
436
+ " int i = 0;",
437
+ " float x = gl_FragCoord.x/u_window_size.x;",
438
+ " float y = gl_FragCoord.y/u_window_size.y;",
439
+ " vec3 meshPos = texture2D(u_stop_geom, vec2(x,y)).xyz;",
440
+ // " vec3 meshPos = texture2D(u_stop_geom, vec2(gl_FragCoord.x,gl_FragCoord.y)).xyz;",
441
+ // " gl_FragColor = vec4(meshPos,1.0);",
442
+ // " return;",
443
+ " float dist = 1000.0;",
444
+ " for (float t = t_hit.x; t < t_hit.y; t += dt) {",
445
+ " if(meshPos != vec3(0.0)) dist = distance(p,meshPos);",
446
+ " float val = texture(volumeTex, p.xyz).r;",
447
+ " val = max(0.0, (val - u_clim[0]) / (u_clim[1] - u_clim[0]));",
448
+ " rgbCombo += max(0.0, min(1.0, val)) * u_color;",
449
+ " total += val;",
450
+ " if(volumeCount > 1.0){ float val2 = texture(volumeTex2, p.xyz).r;",
451
+ " val2 = max(0.0,(val2 - u_clim2[0]) / (u_clim2[1] - u_clim2[0]));",
452
+ " rgbCombo += max(0.0, min(1.0, val2)) * u_color2;",
453
+ " total += val2;",
454
+ " }",
455
+ " if(volumeCount > 2.0){ float val3 = texture(volumeTex3, p.xyz).r;",
456
+ " val3 = max(0.0,(val3 - u_clim3[0]) / (u_clim3[1] - u_clim3[0]));",
457
+ " rgbCombo += max(0.0, min(1.0, val3)) * u_color3;",
458
+ " total += val3;",
459
+ " }",
460
+ " if(volumeCount > 3.0){ float val4 = texture(volumeTex4, p.xyz).r;",
461
+ " val4 = max(0.0,(val4 - u_clim4[0]) / (u_clim4[1] - u_clim4[0]));",
462
+ " rgbCombo += max(0.0, min(1.0, val4)) * u_color4;",
463
+ " total += val4;",
464
+ " }",
465
+ " if(volumeCount > 4.0){ float val5 = texture(volumeTex5, p.xyz).r;",
466
+ " val5 = max(0.0,(val5 - u_clim5[0]) / (u_clim5[1] - u_clim5[0]));",
467
+ " rgbCombo += max(0.0, min(1.0, val5)) * u_color5;",
468
+ " total += val5;",
469
+ " }",
470
+ " if(volumeCount > 5.0){ float val6 = texture(volumeTex6, p.xyz).r;",
471
+ " val6 = max(0.0,(val6 - u_clim6[0]) / (u_clim6[1] - u_clim6[0]));",
472
+ " rgbCombo += max(0.0, min(1.0, val6)) * u_color6;",
473
+ " total += val6;",
474
+ " }",
475
+ // STOP the traversal if there has been data and the distance to the object is too small
476
+ " if(total > 0.0 && dist < 0.1){",
477
+ " break;",
478
+ " }else if(dist < 0.1){ gl_FragColor = vec4(0.0,0.0,0.0,0.0);",
479
+ " break;",
480
+ " }",
481
+ " if(u_renderstyle == 0 && (max_val > u_clim[1] && max_val2 >= u_clim2[1] && max_val3 >= u_clim3[1] && max_val4 >= u_clim4[1] && max_val5 >= u_clim5[1] && max_val6 >= u_clim6[1])) break;",
482
+ " if(u_renderstyle == 2){ total = min(total, 1.0);",
483
+ " vec4 val_color = vec4(rgbCombo, total);",
484
+ " val_color.a = 1.0 - pow(1.0 - val_color.a, 1.0);",
485
+ " gl_FragColor.rgb += (1.0 - gl_FragColor.a) * val_color.a * val_color.rgb;",
486
+ " gl_FragColor.a += (1.0 - gl_FragColor.a) * val_color.a * dtScale;",
487
+ " if (gl_FragColor.a >= 0.95) {",
488
+ " break;",
489
+ " }",
490
+ " }",
491
+ // " }",
492
+ " p += step;",
493
+ " }",
494
+ " gl_FragDepth = distance(worldSpaceCoords,p)*u_physical_Pixel;",
495
+ // " gl_FragColor = vec4(gl_FragDepth,gl_FragDepth,gl_FragDepth,1.0);",
496
+ // " return;",
497
+ " if(u_renderstyle == 0 && (max_val < u_clim[0] && max_val2 < u_clim2[0] && max_val3 < u_clim3[0] && max_val4 < u_clim4[0] && max_val5 < u_clim5[0] && max_val6 < u_clim6[0])){",
498
+ " gl_FragColor = vec4(0,0,0,0);",
499
+ " }else if(u_renderstyle == 0){",
500
+ " max_val = (max_val - u_clim[0]) / (u_clim[1] - u_clim[0]);",
501
+ " max_val2 = (max_val2 - u_clim2[0]) / (u_clim2[1] - u_clim2[0]);",
502
+ " max_val3 = (max_val3 - u_clim3[0]) / (u_clim3[1] - u_clim3[0]);",
503
+ " max_val4 = (max_val4 - u_clim4[0]) / (u_clim4[1] - u_clim4[0]);",
504
+ " max_val5 = (max_val5 - u_clim5[0]) / (u_clim5[1] - u_clim5[0]);",
505
+ " max_val6 = (max_val6 - u_clim6[0]) / (u_clim6[1] - u_clim6[0]);",
506
+ " vec3 color = u_color * max_val;",
507
+ " if(volumeCount > 1.0) color = color + u_color2 * max_val2;",
508
+ " if(volumeCount > 3.0) color = color + u_color4 * max_val4;",
509
+ " if(volumeCount > 2.0) color = color + u_color3 * max_val3;",
510
+ " if(volumeCount > 4.0) color = color + u_color5 * max_val5;",
511
+ " if(volumeCount > 5.0) color = color + u_color6 * max_val6;",
512
+ " vec3 colorCorrected = vec3(min(color[0], 1.0), min(color[1],1.0), min(color[2],1.0));",
513
+ " gl_FragColor = vec4(color,1.0);",
514
+ " }",
515
+ " gl_FragColor.r = linear_to_srgb(gl_FragColor.r);",
516
+ " gl_FragColor.g = linear_to_srgb(gl_FragColor.g);",
517
+ " gl_FragColor.b = linear_to_srgb(gl_FragColor.b);",
518
+ "}"
519
+ ].join(`
520
+ `)
521
+ }, Ge = {
522
+ maximumIntensityProjection: 0,
523
+ minimumIntensityProjection: 1,
524
+ additive: 2
525
+ };
526
+ function $e(t, e, a, o, i, l) {
527
+ const { spatialRenderingMode: n } = l, m = i?.image?.instance?.getData();
528
+ if (!m)
529
+ return {
530
+ channelsVisible: null,
531
+ resolution: null,
532
+ data: null,
533
+ colors: null,
534
+ contrastLimits: null,
535
+ allChannels: null,
536
+ channelTargetC: null,
537
+ is3dMode: !1,
538
+ renderingMode: null,
539
+ layerTransparency: 1,
540
+ xSlice: null,
541
+ ySlice: null,
542
+ zSlice: null
543
+ };
544
+ const x = i.image.instance, g = n === "3D", r = e[N.PHOTOMETRIC_INTERPRETATION] === "RGB", c = e[N.VOLUMETRIC_RENDERING_ALGORITHM], T = Ge[c], d = e[N.SPATIAL_LAYER_VISIBLE], I = e[N.SPATIAL_LAYER_OPACITY];
545
+ x.isInterleaved();
546
+ const y = r ? [
547
+ [255, 0, 0],
548
+ [0, 255, 0],
549
+ [0, 0, 255]
550
+ ] : a.map((F) => o[F][N.SPATIAL_CHANNEL_COLOR]), w = r ? [
551
+ [0, 255],
552
+ [0, 255],
553
+ [0, 255]
554
+ ] : a.map((F) => o[F][N.SPATIAL_CHANNEL_WINDOW] || [0, 255]), _ = r ? [
555
+ // Layer visible AND channel visible
556
+ d && !0,
557
+ d && !0,
558
+ d && !0
559
+ ] : a.map((F) => (
560
+ // Layer visible AND channel visible
561
+ d && o[F][N.SPATIAL_CHANNEL_VISIBLE]
562
+ )), v = r ? [
563
+ // Layer visible AND channel visible
564
+ d && !0,
565
+ d && !0,
566
+ d && !0
567
+ ] : a.map((F) => (
568
+ // Layer visible AND channel visible
569
+ d && x.getChannelIndex(o[F][N.SPATIAL_TARGET_C])
570
+ )), C = x.getAutoTargetResolution(), h = e[N.SPATIAL_TARGET_RESOLUTION], V = h === null || Number.isNaN(h) ? C : h, P = i.image.loaders[0].channels ?? [];
571
+ let f = e[N.SPATIAL_SLICE_X], z = e[N.SPATIAL_SLICE_Y], U = e[N.SPATIAL_SLICE_Z];
572
+ return f = f !== null ? f : [-1, 1e5], z = z !== null ? z : [-1, 1e5], U = U !== null ? U : [-1, 1e5], {
573
+ channelsVisible: _,
574
+ allChannels: P,
575
+ channelTargetC: v,
576
+ resolution: V,
577
+ data: m,
578
+ colors: y,
579
+ contrastLimits: w,
580
+ is3dMode: g,
581
+ renderingMode: T,
582
+ layerTransparency: I,
583
+ xSlice: f,
584
+ ySlice: z,
585
+ zSlice: U
586
+ };
587
+ }
588
+ function Xe(t, e, a, o, i) {
589
+ const { images: l = {}, imageLayerScopes: n, imageLayerCoordination: m, imageChannelScopesByLayer: x, imageChannelCoordination: g } = t, r = n[0], c = x[r], T = m[0][r], d = g[0][r], { channelsVisible: I, allChannels: y, channelTargetC: w, resolution: _, data: v, colors: C, contrastLimits: h, is3dMode: V, renderingMode: P, layerTransparency: f, xSlice: z, ySlice: U, zSlice: F } = $e(r, T, c, d, l[r], t);
590
+ return w !== null && (e.channelTargetC?.length !== 0 && (e.channelTargetC?.toString() !== w.toString() || e.resolution?.toString() !== _.toString()) ? o || i(!0) : (e.channelsVisible?.toString() !== I?.toString() || e.colors?.toString() !== C?.toString() || e.is3dMode !== V || e.contrastLimits?.toString() !== h?.toString() || e.renderingMode?.toString() !== P.toString() || e.layerTransparency.toString() !== f.toString() || e.xSlice?.toString() !== z.toString() || e.ySlice?.toString() !== U.toString() || e.zSlice?.toString() !== F.toString()) && (a({
591
+ channelsVisible: I,
592
+ allChannels: y,
593
+ channelTargetC: w,
594
+ resolution: _,
595
+ data: v,
596
+ colors: C,
597
+ contrastLimits: h,
598
+ is3dMode: V,
599
+ renderingMode: P,
600
+ layerTransparency: f,
601
+ xSlice: z,
602
+ ySlice: U,
603
+ zSlice: F
604
+ }), i(!1))), {
605
+ images: l,
606
+ layerScope: r,
607
+ imageLayerScopes: n,
608
+ imageLayerCoordination: m,
609
+ imageChannelScopesByLayer: x,
610
+ imageChannelCoordination: g,
611
+ channelsVisible: I,
612
+ allChannels: y,
613
+ channelTargetC: w,
614
+ resolution: _,
615
+ data: v,
616
+ colors: C,
617
+ contrastLimits: h,
618
+ is3dMode: V,
619
+ renderingMode: P,
620
+ layerTransparency: f,
621
+ xSlice: z,
622
+ ySlice: U,
623
+ zSlice: F
624
+ };
625
+ }
626
+ function K(t, e) {
627
+ const [a, o] = e;
628
+ return (t - a) / Math.sqrt(o ** 2 - a ** 2);
629
+ }
630
+ function He(t, e, a, o, i, l, n, m, x, g, r, c, T) {
631
+ t.boxSize.value.set(a.xLength, a.yLength, a.zLength), t.volumeTex.value = e.length > 0 ? e[0] : null, t.volumeTex2.value = e.length > 1 ? e[1] : null, t.volumeTex3.value = e.length > 2 ? e[2] : null, t.volumeTex4.value = e.length > 3 ? e[3] : null, t.volumeTex5.value = e.length > 4 ? e[4] : null, t.volumeTex6.value = e.length > 5 ? e[5] : null, t.near.value = 0.1, t.far.value = 3e3, t.alphaScale.value = 1, t.dtScale.value = m, t.finalGamma.value = 4.5, t.volumeCount.value = e.length, t.u_size.value.set(a.xLength, a.yLength, a.zLength), t.u_stop_geom.value = null, t.u_window_size.value.set(0, 0), t.u_vol_scale.value.set(1 / a.xLength, 1 / a.yLength, 1 / a.zLength * 2), t.u_renderstyle.value = i, t.u_clim.value.set(l.length > 0 ? l[0][0] : null, l.length > 0 ? l[0][1] : null), t.u_clim2.value.set(l.length > 1 ? l[1][0] : null, l.length > 1 ? l[1][1] : null), t.u_clim3.value.set(l.length > 2 ? l[2][0] : null, l.length > 2 ? l[2][1] : null), t.u_clim4.value.set(l.length > 3 ? l[3][0] : null, l.length > 3 ? l[3][1] : null), t.u_clim5.value.set(l.length > 4 ? l[4][0] : null, l.length > 4 ? l[4][1] : null), t.u_clim6.value.set(l.length > 5 ? l[5][0] : null, l.length > 5 ? l[5][1] : null), t.u_xClip.value.set(x[0] * (1 / c[0]) / T[0] * a.xLength, x[1] * (1 / c[0]) / T[0] * a.xLength), t.u_yClip.value.set(g[0] * (1 / c[1]) / T[1] * a.yLength, g[1] * (1 / c[1]) / T[1] * a.yLength), t.u_zClip.value.set(r[0] * (1 / c[2]) / T[2] * a.zLength, r[1] * (1 / c[1]) / T[2] * a.zLength), t.u_color.value.set(n.length > 0 ? n[0][0] : null, n.length > 0 ? n[0][1] : null, n.length > 0 ? n[0][2] : null), t.u_color2.value.set(n.length > 1 ? n[1][0] : null, n.length > 1 ? n[1][1] : null, n.length > 1 ? n[1][2] : null), t.u_color3.value.set(n.length > 2 ? n[2][0] : null, n.length > 2 ? n[2][1] : null, n.length > 2 ? n[2][2] : null), t.u_color4.value.set(n.length > 3 ? n[3][0] : null, n.length > 3 ? n[3][1] : null, n.length > 3 ? n[3][2] : null), t.u_color5.value.set(n.length > 4 ? n[4][0] : null, n.length > 4 ? n[4][1] : null, n.length > 4 ? n[4][2] : null), t.u_color6.value.set(n.length > 5 ? n[5][0] : null, n.length > 5 ? n[5][1] : null, n.length > 5 ? n[5][2] : null);
632
+ }
633
+ function ge(t, e, a, o, i, l, n, m, x, g, r, c, T, d) {
634
+ const I = [], y = [], w = [];
635
+ let _ = null, v = m;
636
+ if (v == null || !Array.isArray(v) || v.length < 3)
637
+ v = [
638
+ { size: v?.[0]?.size ?? 1 },
639
+ { size: v?.[1]?.size ?? 1 },
640
+ { size: v?.[2]?.size ?? 1 }
641
+ ];
642
+ else
643
+ for (let f = 0; f < v.length; f++)
644
+ (!v[f] || v[f].size === void 0 || v[f].size === null) && (v[f] = { size: 1 });
645
+ if (e.forEach((f, z) => {
646
+ a[z] && (_ = t.get(f), I.push(i.get(f)), y.push([o[z][0] / 255, o[z][1] / 255, o[z][2] / 255]), l[z][0] === 0 && l[z][1] === 255 ? w.push([
647
+ K(n.get(f)[0], n.get(f)),
648
+ K(n.get(f)[1], n.get(f))
649
+ ]) : w.push([
650
+ K(l[z][0], n.get(f)),
651
+ K(l[z][1], n.get(f))
652
+ ]));
653
+ }), _ === null)
654
+ return null;
655
+ const C = _, h = {}, V = je, P = Le.clone(V.uniforms);
656
+ return He(P, I, C, h, x, w, y, g, r, c, T, [v[0].size, v[1].size, v[2] ? v[2].size : 1], d), [
657
+ P,
658
+ V,
659
+ [1, v[1].size / v[0].size, v[2] ? v[2].size / v[0].size : 1],
660
+ [C.xLength, C.yLength, C.zLength],
661
+ [1, C.yLength / C.xLength, C.zLength / C.xLength]
662
+ ];
663
+ }
664
+ const Ye = {
665
+ Uint8: Uint8Array,
666
+ Uint16: Uint16Array,
667
+ Uint32: Uint32Array,
668
+ Int8: Int8Array,
669
+ Int16: Int16Array,
670
+ Int32: Int32Array,
671
+ Float32: Float32Array,
672
+ Float64: Float64Array
673
+ };
674
+ async function We({
675
+ source: t,
676
+ selection: e,
677
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
678
+ onUpdate: a = () => {
679
+ },
680
+ downsampleDepth: o = 1,
681
+ signal: i
682
+ }) {
683
+ const { shape: l, labels: n, dtype: m } = t, { height: x, width: g } = ke(t), r = l[n.indexOf("z")], c = Math.max(1, Math.floor(r / o)), T = x * g, d = Ye[m], I = new d(T * c);
684
+ return await Promise.all(new Array(c).fill(0).map(async (y, w) => {
685
+ const _ = {
686
+ ...e,
687
+ z: w * o
688
+ }, { data: v } = await t.getRaster({
689
+ selection: _,
690
+ signal: i
691
+ });
692
+ let C = 0;
693
+ for (a({ z: w, total: c, progress: 0.5 }); C < T; ) {
694
+ const h = w * T + (T - C - 1), V = (g - C - 1) % g + g * Math.floor(C / g);
695
+ I[h] = v[V], C += 1;
696
+ }
697
+ a({ z: w, total: c, progress: 1 });
698
+ })), {
699
+ data: I,
700
+ height: x,
701
+ width: g,
702
+ depth: c
703
+ };
704
+ }
705
+ function Ze(t, e, a) {
706
+ return We({
707
+ source: a[e],
708
+ selection: { t: 0, c: t },
709
+ // corresponds to the first channel of the first timepoint
710
+ downsampleDepth: 2 ** e
711
+ });
712
+ }
713
+ function Be(t) {
714
+ const e = new Ne();
715
+ return e.xLength = t.width, e.yLength = t.height, e.zLength = t.depth, e.data = t.data, e;
716
+ }
717
+ function Je(t) {
718
+ const e = new Pe(t.data, t.xLength, t.yLength, t.zLength);
719
+ return e.format = Ae, e.type = De, e.generateMipmaps = !1, e.minFilter = he, e.magFilter = he, e.needsUpdate = !0, e;
720
+ }
721
+ function Ke(t) {
722
+ const { x: e, y: a, z: o } = t?.meta?.physicalSizes ?? {};
723
+ return [
724
+ e ?? { size: 1 },
725
+ a ?? { size: 1 },
726
+ o ?? { size: 1 }
727
+ ];
728
+ }
729
+ function qe(t) {
730
+ const [e, a] = t.computeMinMax(), o = new Float32Array(t.data.length);
731
+ for (let i = 0; i < t.data.length; i++)
732
+ o[i] = (t.data[i] - e) / Math.sqrt(a ** 2 - e ** 2);
733
+ return o;
734
+ }
735
+ async function Qe(t, e, a, o, i, l, n) {
736
+ let m = null, x = null;
737
+ const { shape: g, labels: r } = a[0], c = t.filter((d) => !o.has(d) || e !== n), T = await Promise.all(c.map((d) => Ze(d, e, a)));
738
+ return c.forEach((d, I) => {
739
+ const y = T[I];
740
+ m = Be(y);
741
+ const w = m.computeMinMax();
742
+ m.data = qe(m), o.set(d, m), i.set(d, Je(m)), l.set(d, w), x = Ke(a[e]);
743
+ }), [
744
+ o,
745
+ i,
746
+ l,
747
+ x,
748
+ [g[r.indexOf("x")], g[r.indexOf("y")], g[r.indexOf("z")]]
749
+ ];
750
+ }
751
+ function et(t) {
752
+ return `${t.startPoint.x},${t.startPoint.y},${t.startPoint.z};${t.endPoint.x},${t.endPoint.y},${t.endPoint.z}`;
753
+ }
754
+ function vt(t) {
755
+ return !Array.isArray(t) || t.length !== 3 ? !1 : t.every((e) => typeof e == "number" && Number.isFinite(e));
756
+ }
757
+ function oe(t) {
758
+ const { segmentationGroup: e, segmentationSettings: a, segmentationSceneScale: o, renderingSettings: i, materialRef: l, highlightEntity: n, setObsHighlight: m } = t, x = Q(null), [g] = G([]);
759
+ return X("group", { children: [X("group", { children: [e?.visible ? X("group", { children: [p("hemisphereLight", { color: 8421504, groundColor: 6316128 }), p("directionalLight", { color: 16777215, position: [0, -800, 0] }), p("directionalLight", { color: 16777215, position: [0, 800, 0] }), p(Te, { firstHitOnly: !0, children: p("primitive", { ref: x, object: e, position: [0, 0, 0], onClick: (r) => {
760
+ r.object.parent?.userData.name === "finalPass" && n(r.object.name, r.object.userData.layerScope, r.object.userData.channelScope);
761
+ }, onPointerOver: (r) => {
762
+ m(r.object.name);
763
+ }, onPointerOut: () => m(null) }) })] }) : null, i.uniforms && i.shader && i.meshScale && i.geometrySize ? p("group", { children: X("mesh", { scale: i.meshScale, ref: l, children: [p("boxGeometry", { args: i.geometrySize }), p("shaderMaterial", { customProgramCacheKey: () => "1", side: ve, uniforms: i.uniforms, needsUpdate: !0, transparent: !0, vertexShader: i.shader.vertexShader, fragmentShader: i.shader.fragmentShader })] }) }) : null] }), p("group", { name: "lines", children: g.map((r) => p(Ue, { currentLine: r, scale: 1 }, et(r))) })] });
764
+ }
765
+ const tt = te.lazy(() => import("./GeometryAndMeshXR-BDALKiGu.js").catch(() => ({ default: oe }))), at = te.lazy(() => import("./XRSceneComponents-BI1xgf_W.js").catch(() => ({ default: () => null })));
766
+ function ie(t) {
767
+ const e = Q(null), a = Q(null), [o, i] = G(!1), [l, n] = G(!1), [m, x] = G(null), [g, r] = G([1, 1, 1]), [c, T] = G({
768
+ uniforms: null,
769
+ shader: null,
770
+ meshScale: null,
771
+ geometrySize: null,
772
+ boxSize: null
773
+ }), [d, I] = G({
774
+ volumes: /* @__PURE__ */ new Map(),
775
+ textures: /* @__PURE__ */ new Map(),
776
+ volumeMinMax: /* @__PURE__ */ new Map(),
777
+ scale: null,
778
+ resolution: null,
779
+ originalScale: null
780
+ }), [y, w] = G({
781
+ channelsVisible: [],
782
+ allChannels: [],
783
+ channelTargetC: [],
784
+ resolution: null,
785
+ data: null,
786
+ colors: [],
787
+ contrastLimits: [],
788
+ is3dMode: !1,
789
+ renderingMode: null,
790
+ layerTransparency: 1
791
+ }), [_, v] = G({
792
+ visible: !0,
793
+ color: [1, 1, 1],
794
+ opacity: 1,
795
+ multiVisible: "",
796
+ multiOpacity: "",
797
+ multiColor: "",
798
+ data: null,
799
+ obsSets: []
800
+ }), { images: C, layerScope: h, channelsVisible: V, allChannels: P, channelTargetC: f, resolution: z, data: U, colors: F, contrastLimits: H, is3dMode: W, renderingMode: Z, layerTransparency: re, xSlice: se, ySlice: ue, zSlice: ce } = Xe(t, y, w, l, n), { obsSegmentations: B, onEntitySelected: _e, segmentationLayerCoordination: ot, segmentationChannelCoordination: $, segmentationChannelScopesByLayer: J } = t;
801
+ let me = () => {
802
+ };
803
+ const Y = [];
804
+ if ($[0][h] !== void 0) {
805
+ const s = $[0][h][h];
806
+ me = $[1][h][h].setObsHighlight;
807
+ const { additionalObsSets: b } = s;
808
+ b !== null && s.obsSetSelection.forEach((D) => {
809
+ const S = D[1];
810
+ b.tree[0].children.forEach((R) => {
811
+ R.name === S && R.set.forEach(([A]) => {
812
+ const M = { name: "", id: "", color: [255, 255, 255] };
813
+ M.name = S, M.id = A, s.obsSetColor.forEach((E) => {
814
+ E.path[1] === S && (M.color = E.color);
815
+ }), Y.push(M);
816
+ });
817
+ });
818
+ }), s.obsHighlight !== null && Y.push({ name: "", id: s.obsHighlight, color: [255, 34, 0] });
819
+ }
820
+ if (B?.[h]?.obsSegmentations && m == null) {
821
+ const { scene: s, sceneOptions: u } = B[h].obsSegmentations;
822
+ if (s?.children) {
823
+ const b = new Ie(), D = new Fe();
824
+ D.userData.name = "finalPass", s.children.forEach((R) => {
825
+ const A = "material" in R ? R : R.children[0];
826
+ (A.material instanceof Ee || A.material instanceof Ve) && (A.material = new Re());
827
+ const M = A.material;
828
+ let E = A.name.replace("mesh_", "").replace("mesh", "").replace("glb", "").replace("_dec", "").replace("_Decobj", "").replace("obj", "").replace("_DEc", "").replace(".", "").replace("_Dec", "");
829
+ E.includes("_") && (E = E.split("_")[0]), A.name = E, A.userData.name = E, A.userData.layerScope = h, M.transparent = !0, M.depthTest = !0, M.depthWrite = !0, M.needsUpdate = !0, M.side = u?.materialSide === "back" ? Oe : ve;
830
+ const O = A.clone();
831
+ O.geometry = A.geometry.clone(), O.geometry.translate(u?.targetX ?? 0, u?.targetY ?? 0, u?.targetZ ?? 0), O.geometry.scale(u?.scaleX ?? 1, u?.scaleY ?? 1, u?.scaleZ ?? 1), O.geometry.rotateX(u?.rotationX ?? 0), O.geometry.rotateY(u?.rotationY ?? 0), O.geometry.rotateZ(u?.rotationZ ?? 0);
832
+ const le = A.clone();
833
+ le.material = M.clone(), le.geometry = O.geometry.clone(), D.add(le);
834
+ }), b.add(D), b.scale.set(u?.sceneScaleX ?? 1, u?.sceneScaleY ?? 1, u?.sceneScaleZ ?? 1);
835
+ const S = [
836
+ u?.sceneScaleX ?? 1,
837
+ u?.sceneScaleY ?? 1,
838
+ u?.sceneScaleZ ?? 1
839
+ ];
840
+ r(S), b.rotateX(u?.sceneRotationX ?? 0), b.rotateY(u?.sceneRotationY ?? 0), b.rotateZ(u?.sceneRotationZ ?? 0), x(b);
841
+ }
842
+ }
843
+ if ($[0] !== void 0 && $[0][h] !== void 0) {
844
+ const s = $[0][h][h];
845
+ let u = "";
846
+ Y.forEach((D) => {
847
+ u += `${D.id};${D.color.toString()};${D.name}`;
848
+ });
849
+ let b = "";
850
+ if (_.obsSets.forEach((D) => {
851
+ b += `${D.id};${D.color.toString()};${D.name}`;
852
+ }), J[h].length > 1) {
853
+ let D = "", S = "", R = "", A = !1, M = 0;
854
+ J[h].forEach((E) => {
855
+ const O = $[0][h][E];
856
+ D += `${O.spatialChannelColor.toString()};`, S += `${O.spatialChannelOpacity};`, R += `${O.spatialChannelVisible};`, A = A || O.spatialChannelVisible, M += O.spatialChannelOpacity;
857
+ }), (D !== _.multiColor || S !== _.multiOpacity || R !== _.multiVisible) && v({
858
+ color: s.spatialChannelColor,
859
+ opacity: M,
860
+ visible: A,
861
+ multiColor: D,
862
+ multiVisible: R,
863
+ multiOpacity: S,
864
+ data: B ?? null,
865
+ obsSets: Y
866
+ });
867
+ } else (s.spatialChannelColor.toString() !== _.color.toString() || s.spatialChannelVisible !== _.visible || s.spatialChannelOpacity !== _.opacity || u !== b) && v({
868
+ color: s.spatialChannelColor,
869
+ opacity: s.spatialChannelOpacity,
870
+ visible: s.spatialChannelVisible,
871
+ multiColor: "",
872
+ multiVisible: "",
873
+ multiOpacity: "",
874
+ data: B ?? null,
875
+ obsSets: Y
876
+ });
877
+ }
878
+ if (q(() => {
879
+ if (m !== null) {
880
+ let s = 0, u = 0;
881
+ for (let b = 0; b < m.children.length; b++)
882
+ m.children[b].userData.name === "finalPass" ? u = b : s = b;
883
+ m.children[u].children.forEach((b, D) => {
884
+ const S = b;
885
+ let { color: R } = _;
886
+ const A = S.userData.name;
887
+ if (_.obsSets.forEach((M) => {
888
+ M.id === A && (R = M.color);
889
+ }), J[h].length > 1)
890
+ J[h].forEach((M) => {
891
+ const E = $[0][h][M];
892
+ if (E.spatialTargetC === A) {
893
+ S.material.color.r = E.spatialChannelColor[0] / 255, S.material.color.g = E.spatialChannelColor[1] / 255, S.material.color.b = E.spatialChannelColor[2] / 255, S.material.opacity = E.spatialChannelOpacity, S.visible = E.spatialChannelVisible, S.material.needsUpdate = !0, S.userData.layerScope = h, S.userData.channelScope = M;
894
+ const O = m.children[s].children[D];
895
+ O.material.needsUpdate = !0;
896
+ }
897
+ });
898
+ else {
899
+ S.material.color.r = R[0] / 255, S.material.color.g = R[1] / 255, S.material.color.b = R[2] / 255, S.material.opacity = _.opacity, S.material.visible = _.visible, S.material.needsUpdate = !0, S.userData.layerScope = h;
900
+ const M = Object.keys($[0][h])?.[0];
901
+ S.userData.channelScope = M;
902
+ }
903
+ });
904
+ }
905
+ }, [_, m]), C[h]?.image?.instance?.getData() !== void 0 && !l && !o && H !== null && H[0][1] !== 255 && W && (n(!0), i(!0)), q(() => {
906
+ const s = async () => {
907
+ const u = await Qe(f, z, U, d.volumes, d.textures, d.volumeMinMax, d.resolution);
908
+ if (u[0] !== null)
909
+ if (I({
910
+ resolution: z,
911
+ volumes: u[0],
912
+ textures: u[1],
913
+ volumeMinMax: u[2],
914
+ scale: u[3] !== null ? u[3] : d.scale,
915
+ originalScale: u[4]
916
+ }), !c.uniforms || !c.shader) {
917
+ const b = ge(u[0], f, V, F, u[1], H, u[2], u[3], Z, re, se, ue, ce, u[4]);
918
+ b !== null && T({
919
+ uniforms: b[0],
920
+ shader: b[1],
921
+ meshScale: b[2],
922
+ geometrySize: b[3],
923
+ boxSize: b[4]
924
+ });
925
+ } else
926
+ w({
927
+ channelsVisible: V,
928
+ allChannels: P,
929
+ channelTargetC: f,
930
+ resolution: z,
931
+ data: U,
932
+ colors: F,
933
+ contrastLimits: H,
934
+ is3dMode: W,
935
+ renderingMode: Z,
936
+ layerTransparency: re,
937
+ xSlice: se,
938
+ ySlice: ue,
939
+ zSlice: ce
940
+ });
941
+ };
942
+ l && (z !== y.resolution && e.current && (e.current.material.uniforms.volumeCount.value = 0, e.current.material.uniforms.volumeTex.value = null), s(), n(!1));
943
+ }, [l]), q(() => {
944
+ if (c.uniforms && c.shader) {
945
+ const s = ge(d.volumes, y.channelTargetC, y.channelsVisible, y.colors, d.textures, y.contrastLimits, d.volumeMinMax, d.scale, y.renderingMode, y.layerTransparency, y.xSlice, y.ySlice, y.zSlice, d.originalScale);
946
+ if (s !== null) {
947
+ let u = 0;
948
+ y.channelsVisible?.forEach((b) => {
949
+ b && u++;
950
+ }), n(!1), e?.current?.material?.uniforms && (e.current.material.uniforms.u_clim.value = s[0].u_clim.value, e.current.material.uniforms.u_clim2.value = s[0].u_clim2.value, e.current.material.uniforms.u_clim3.value = s[0].u_clim3.value, e.current.material.uniforms.u_clim4.value = s[0].u_clim4.value, e.current.material.uniforms.u_clim5.value = s[0].u_clim5.value, e.current.material.uniforms.u_clim6.value = s[0].u_clim6.value, e.current.material.uniforms.u_xClip.value = s[0].u_xClip.value, e.current.material.uniforms.u_yClip.value = s[0].u_yClip.value, e.current.material.uniforms.u_zClip.value = s[0].u_zClip.value, e.current.material.uniforms.u_color.value = s[0].u_color.value, e.current.material.uniforms.u_color2.value = s[0].u_color2.value, e.current.material.uniforms.u_color3.value = s[0].u_color3.value, e.current.material.uniforms.u_color4.value = s[0].u_color4.value, e.current.material.uniforms.u_color5.value = s[0].u_color5.value, e.current.material.uniforms.u_color6.value = s[0].u_color6.value, e.current.material.uniforms.volumeTex.value = s[0].volumeTex.value, e.current.material.uniforms.volumeTex2.value = s[0].volumeTex2.value, e.current.material.uniforms.volumeTex3.value = s[0].volumeTex3.value, e.current.material.uniforms.volumeTex4.value = s[0].volumeTex4.value, e.current.material.uniforms.volumeTex5.value = s[0].volumeTex5.value, e.current.material.uniforms.volumeTex6.value = s[0].volumeTex6.value, e.current.material.uniforms.volumeCount.value = u, e.current.material.uniforms.u_renderstyle.value = y.renderingMode, e.current.material.uniforms.dtScale.value = y.layerTransparency);
951
+ } else e?.current?.material?.uniforms && (e.current.material.uniforms.volumeCount.value = 0, e.current.material.uniforms.volumeTex.value = null);
952
+ }
953
+ }, [y]), !y.is3dMode)
954
+ return null;
955
+ if (y.is3dMode && (!c.uniforms || !c.shader))
956
+ return X("group", { children: [p("ambientLight", {}), p("pointLight", { position: [10, 10, 10] }), p(de, { color: "white", scale: 20, fontWeight: 1e3, children: "Loading ..." })] });
957
+ const ae = {
958
+ segmentationGroup: m,
959
+ segmentationSettings: _,
960
+ segmentationSceneScale: g,
961
+ renderingSettings: c,
962
+ materialRef: e,
963
+ highlightEntity: _e,
964
+ setObsHighlight: me
965
+ }, { xrEnabled: fe } = t;
966
+ return X("group", { children: [fe ? X(ye, { children: [p(ee, { fallback: null, children: p(at, {}) }), p(ee, { fallback: p(oe, { ...ae }), children: p(tt, { ...ae }) })] }) : p(oe, { ...ae }), p(we, { ref: a, enableDamping: !1, dampingFactor: 0 })] });
967
+ }
968
+ const lt = te.lazy(
969
+ // eslint-disable-next-line implicit-arrow-linebreak, function-paren-newline
970
+ () => import("./XRWrapper-C5Rd9HYZ.js").catch(() => ({
971
+ default: ({ children: t }) => t
972
+ }))
973
+ ), nt = te.lazy(
974
+ // eslint-disable-next-line implicit-arrow-linebreak, function-paren-newline
975
+ () => import("./XREnterButton-CqJBXry_.js").catch(() => ({
976
+ default: () => null
977
+ }))
978
+ ), it = be((t, e) => {
979
+ const [a, o] = G(!1);
980
+ return q(() => {
981
+ import("@react-three/xr").then(() => o(!0)).catch(() => {
982
+ });
983
+ }, []), X("div", { style: { width: "100%", height: "100%" }, children: [a && p(ee, { fallback: null, children: p(nt, {}) }), p(Se, { style: { position: "absolute", top: 0, left: 0 }, camera: {
984
+ fov: 50,
985
+ up: [0, 1, 0],
986
+ position: [0, 0, 800],
987
+ near: 0.1,
988
+ far: 3e3
989
+ }, gl: { antialias: !0, logarithmicDepthBuffer: !1 }, ref: e, children: a ? p(ee, { fallback: p(ie, { ...t }), children: p(lt, { children: p(ie, { ...t, xrEnabled: !0 }) }) }) : p(ie, { ...t }) })] });
990
+ }), _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
991
+ __proto__: null,
992
+ SpatialWrapper: it
993
+ }, Symbol.toStringTag, { value: "Module" }));
994
+ export {
995
+ Ue as M,
996
+ _t as a,
997
+ vt as i,
998
+ et as s
999
+ };