@idetik/core 0.40.0 → 0.40.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/worker_kernel-CBlE4MBI.js.map +1 -1
- package/dist/index.d.ts +1717 -381
- package/dist/index.js +981 -193
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +32 -32
- package/dist/index.umd.cjs.map +1 -1
- package/dist/types/src/core/channel.d.ts +7 -1
- package/dist/types/src/core/channel.d.ts.map +1 -1
- package/dist/types/src/core/image_source_policy.d.ts +4 -4
- package/dist/types/src/core/image_source_policy.d.ts.map +1 -1
- package/dist/types/src/core/layer.d.ts +136 -21
- package/dist/types/src/core/layer.d.ts.map +1 -1
- package/dist/types/src/core/renderable_object.d.ts +108 -3
- package/dist/types/src/core/renderable_object.d.ts.map +1 -1
- package/dist/types/src/core/viewport.d.ts +82 -2
- package/dist/types/src/core/viewport.d.ts.map +1 -1
- package/dist/types/src/data/chunk.d.ts +37 -2
- package/dist/types/src/data/chunk.d.ts.map +1 -1
- package/dist/types/src/data/chunk_manager.d.ts +5 -0
- package/dist/types/src/data/chunk_manager.d.ts.map +1 -1
- package/dist/types/src/data/ome_zarr/image_source.d.ts +56 -13
- package/dist/types/src/data/ome_zarr/image_source.d.ts.map +1 -1
- package/dist/types/src/data/ome_zarr/metadata_loaders.d.ts +4 -4
- package/dist/types/src/data/ome_zarr/metadata_loaders.d.ts.map +1 -1
- package/dist/types/src/idetik.d.ts +129 -59
- package/dist/types/src/idetik.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +29 -8
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/layers/axes_layer.d.ts +30 -5
- package/dist/types/src/layers/axes_layer.d.ts.map +1 -1
- package/dist/types/src/layers/image_layer.d.ts +106 -12
- package/dist/types/src/layers/image_layer.d.ts.map +1 -1
- package/dist/types/src/layers/label_layer.d.ts +106 -5
- package/dist/types/src/layers/label_layer.d.ts.map +1 -1
- package/dist/types/src/layers/point_picking.d.ts +7 -2
- package/dist/types/src/layers/point_picking.d.ts.map +1 -1
- package/dist/types/src/layers/volume_layer.d.ts +87 -5
- package/dist/types/src/layers/volume_layer.d.ts.map +1 -1
- package/dist/types/src/math/axes.d.ts +3 -0
- package/dist/types/src/math/axes.d.ts.map +1 -1
- package/dist/types/src/math/box2.d.ts +34 -4
- package/dist/types/src/math/box2.d.ts.map +1 -1
- package/dist/types/src/math/box3.d.ts +38 -4
- package/dist/types/src/math/box3.d.ts.map +1 -1
- package/dist/types/src/math/color.d.ts +49 -2
- package/dist/types/src/math/color.d.ts.map +1 -1
- package/dist/types/src/math/frustum.d.ts +28 -0
- package/dist/types/src/math/frustum.d.ts.map +1 -1
- package/dist/types/src/math/transforms.d.ts +57 -0
- package/dist/types/src/math/transforms.d.ts.map +1 -1
- package/dist/types/src/objects/cameras/camera.d.ts +55 -0
- package/dist/types/src/objects/cameras/camera.d.ts.map +1 -1
- package/dist/types/src/objects/cameras/controls.d.ts +88 -1
- package/dist/types/src/objects/cameras/controls.d.ts.map +1 -1
- package/dist/types/src/objects/cameras/orbit_controls.d.ts +56 -1
- package/dist/types/src/objects/cameras/orbit_controls.d.ts.map +1 -1
- package/dist/types/src/objects/cameras/orthographic_camera.d.ts +90 -13
- package/dist/types/src/objects/cameras/orthographic_camera.d.ts.map +1 -1
- package/dist/types/src/objects/cameras/perspective_camera.d.ts +65 -3
- package/dist/types/src/objects/cameras/perspective_camera.d.ts.map +1 -1
- package/dist/types/src/objects/renderable/image_renderable.d.ts +48 -3
- package/dist/types/src/objects/renderable/image_renderable.d.ts.map +1 -1
- package/dist/types/src/objects/renderable/label_image_renderable.d.ts +66 -4
- package/dist/types/src/objects/renderable/label_image_renderable.d.ts.map +1 -1
- package/dist/types/src/objects/renderable/points_renderable.d.ts +47 -2
- package/dist/types/src/objects/renderable/points_renderable.d.ts.map +1 -1
- package/dist/types/src/objects/renderable/projected_line_renderable.d.ts +27 -3
- package/dist/types/src/objects/renderable/projected_line_renderable.d.ts.map +1 -1
- package/dist/types/src/objects/renderable/volume_renderable.d.ts +63 -3
- package/dist/types/src/objects/renderable/volume_renderable.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -43,6 +43,9 @@ type SliceAxes = {
|
|
|
43
43
|
v: SpatialAxis;
|
|
44
44
|
w: SpatialAxis;
|
|
45
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* The plane a 2D slice lies on, named by its in-plane axes.
|
|
48
|
+
*/
|
|
46
49
|
type SliceOrientation = "XY" | "XZ" | "YZ";
|
|
47
50
|
|
|
48
51
|
declare const chunkDataTypes: readonly [Int8ArrayConstructor, Int16ArrayConstructor, Int32ArrayConstructor, Uint8ArrayConstructor, Uint16ArrayConstructor, Uint32ArrayConstructor, Float32ArrayConstructor];
|
|
@@ -85,32 +88,67 @@ type Chunk = {
|
|
|
85
88
|
z: number;
|
|
86
89
|
};
|
|
87
90
|
} & ChunkViewState;
|
|
91
|
+
/**
|
|
92
|
+
* Per-axis dimension metadata for a multiscale image source.
|
|
93
|
+
*
|
|
94
|
+
* Maps the spatial axes `x`, `y`, `z` and the non-spatial axes `c` and
|
|
95
|
+
* `t` onto the source's stored dimensions.
|
|
96
|
+
*/
|
|
88
97
|
type SourceDimensionMap = {
|
|
98
|
+
/** The `x` spatial dimension. */
|
|
89
99
|
x: SourceDimension;
|
|
100
|
+
/** The `y` spatial dimension. */
|
|
90
101
|
y: SourceDimension;
|
|
102
|
+
/** The `z` spatial dimension if present. */
|
|
91
103
|
z?: SourceDimension;
|
|
104
|
+
/** The channel dimension if present. */
|
|
92
105
|
c?: SourceDimension;
|
|
106
|
+
/** The time dimension if present. */
|
|
93
107
|
t?: SourceDimension;
|
|
108
|
+
/** Number of levels of detail in the pyramid. */
|
|
94
109
|
numLods: number;
|
|
95
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* One dimension of a multiscale image source.
|
|
113
|
+
*/
|
|
96
114
|
type SourceDimension = {
|
|
115
|
+
/** Axis name from the source metadata. */
|
|
97
116
|
name: string;
|
|
117
|
+
/** Position of the axis in the stored arrays. */
|
|
98
118
|
index: number;
|
|
119
|
+
/** Physical unit if declared in the metadata. */
|
|
99
120
|
unit?: string;
|
|
121
|
+
/** Per-LOD metadata ordered finest first. */
|
|
100
122
|
lods: SourceDimensionLod[];
|
|
101
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* Metadata for one dimension at one level of detail.
|
|
126
|
+
*
|
|
127
|
+
* Combines array metadata with the OME-Zarr coordinate transform.
|
|
128
|
+
*/
|
|
102
129
|
type SourceDimensionLod = {
|
|
130
|
+
/** Extent of the dimension in array elements. */
|
|
103
131
|
size: number;
|
|
132
|
+
/** Chunk extent along the dimension in elements. */
|
|
104
133
|
chunkSize: number;
|
|
134
|
+
/** World units per array element. */
|
|
105
135
|
scale: number;
|
|
136
|
+
/** World coordinate of the first element. */
|
|
106
137
|
translation: number;
|
|
107
138
|
};
|
|
108
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* World-space coordinates selecting the data to display.
|
|
141
|
+
*/
|
|
109
142
|
type SliceCoordinates = {
|
|
143
|
+
/** Position on the `x` axis in world units. */
|
|
110
144
|
x?: number;
|
|
145
|
+
/** Position on the `y` axis in world units. */
|
|
111
146
|
y?: number;
|
|
147
|
+
/** Position on the `z` axis in world units. */
|
|
112
148
|
z?: number;
|
|
149
|
+
/** Channel indices to load. Defaults to all channels. */
|
|
113
150
|
c?: number[];
|
|
151
|
+
/** The time point to display. */
|
|
114
152
|
t?: number;
|
|
115
153
|
};
|
|
116
154
|
type ChunkSource = {
|
|
@@ -155,13 +193,13 @@ type ImageSourcePolicy = Readonly<{
|
|
|
155
193
|
bias: number;
|
|
156
194
|
};
|
|
157
195
|
}>;
|
|
158
|
-
/** @
|
|
196
|
+
/** @hidden */
|
|
159
197
|
declare function createImageSourcePolicy(config: ImageSourcePolicyProps): ImageSourcePolicy;
|
|
160
|
-
/** @
|
|
198
|
+
/** @hidden */
|
|
161
199
|
declare function createExplorationPolicy(overrides?: Partial<ImageSourcePolicyProps>): ImageSourcePolicy;
|
|
162
|
-
/** @
|
|
200
|
+
/** @hidden */
|
|
163
201
|
declare function createPlaybackPolicy(overrides?: Partial<ImageSourcePolicyProps>): ImageSourcePolicy;
|
|
164
|
-
/** @
|
|
202
|
+
/** @hidden */
|
|
165
203
|
declare function createNoPrefetchPolicy(overrides?: Partial<ImageSourcePolicyProps>): ImageSourcePolicy;
|
|
166
204
|
|
|
167
205
|
declare class ChunkStore {
|
|
@@ -188,21 +226,51 @@ declare class ChunkStore {
|
|
|
188
226
|
private getAndValidateChannelDimension;
|
|
189
227
|
}
|
|
190
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Axis-aligned bounding box defined by minimum and maximum corners.
|
|
231
|
+
*
|
|
232
|
+
* Box2 represents a 2D region bounded by two corners: `min` and `max`. It
|
|
233
|
+
* is used for view rectangles, viewport regions, and intersection checks.
|
|
234
|
+
* A default-constructed box is empty and intersection treats boxes
|
|
235
|
+
* as half-open intervals.
|
|
236
|
+
*
|
|
237
|
+
* @group Math
|
|
238
|
+
*/
|
|
191
239
|
declare class Box2 {
|
|
240
|
+
/** Minimum corner of the box. */
|
|
192
241
|
min: vec2;
|
|
242
|
+
/** Maximum corner of the box. */
|
|
193
243
|
max: vec2;
|
|
194
244
|
/**
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
245
|
+
* Creates a box from optional corner points. The corners are cloned.
|
|
246
|
+
* When a corner is omitted the box starts empty.
|
|
247
|
+
*
|
|
248
|
+
* @param min - The minimum corner.
|
|
249
|
+
* @param max - The maximum corner.
|
|
199
250
|
*/
|
|
200
251
|
constructor(min?: vec2, max?: vec2);
|
|
252
|
+
/** Returns a deep copy of the box. */
|
|
201
253
|
clone(): Box2;
|
|
254
|
+
/** Returns `true` when the box encloses no area. */
|
|
202
255
|
isEmpty(): boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Tests whether two boxes overlap. Boxes are treated as half-open
|
|
258
|
+
* intervals so touching edges do not count as overlap.
|
|
259
|
+
*
|
|
260
|
+
* @param a - The first box.
|
|
261
|
+
* @param b - The second box.
|
|
262
|
+
*/
|
|
203
263
|
static intersects(a: Box2, b: Box2): boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Tests whether two boxes have exactly equal corners.
|
|
266
|
+
*
|
|
267
|
+
* @param a - The first box.
|
|
268
|
+
* @param b - The second box.
|
|
269
|
+
*/
|
|
204
270
|
static equals(a: Box2, b: Box2): boolean;
|
|
271
|
+
/** Returns a copy with both corners floored componentwise. */
|
|
205
272
|
floor(): Box2;
|
|
273
|
+
/** Converts the box to an `x, y, width, height` rectangle. */
|
|
206
274
|
toRect(): {
|
|
207
275
|
x: number;
|
|
208
276
|
y: number;
|
|
@@ -264,8 +332,13 @@ declare class ChunkStoreView {
|
|
|
264
332
|
private squareDistance2D;
|
|
265
333
|
}
|
|
266
334
|
|
|
335
|
+
/**
|
|
336
|
+
* A snapshot of the chunk request queue.
|
|
337
|
+
*/
|
|
267
338
|
type QueueStats = {
|
|
339
|
+
/** Number of requests waiting to start. */
|
|
268
340
|
pending: number;
|
|
341
|
+
/** Number of requests currently in flight. */
|
|
269
342
|
running: number;
|
|
270
343
|
};
|
|
271
344
|
declare class ChunkManager {
|
|
@@ -296,71 +369,245 @@ declare class ChunkManager {
|
|
|
296
369
|
private disposeChunkTexture;
|
|
297
370
|
}
|
|
298
371
|
|
|
372
|
+
/**
|
|
373
|
+
* Axis-aligned bounding box defined by minimum and maximum corners.
|
|
374
|
+
*
|
|
375
|
+
* Box3 represents a 3D region bounded by two corners: `min` and `max`. It
|
|
376
|
+
* is used for spatial queries, culling tests, intersection checks, and
|
|
377
|
+
* computing bounding volumes. A default-constructed box is empty and
|
|
378
|
+
* intersection treats boxes as half-open intervals.
|
|
379
|
+
*
|
|
380
|
+
* @group Math
|
|
381
|
+
*/
|
|
299
382
|
declare class Box3 {
|
|
383
|
+
/** Minimum corner of the box. */
|
|
300
384
|
min: vec3;
|
|
385
|
+
/** Maximum corner of the box. */
|
|
301
386
|
max: vec3;
|
|
302
387
|
/**
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
388
|
+
* Creates a box from optional corner points. The corners are cloned.
|
|
389
|
+
* When a corner is omitted the box starts empty.
|
|
390
|
+
*
|
|
391
|
+
* @param min - The minimum corner.
|
|
392
|
+
* @param max - The maximum corner.
|
|
307
393
|
*/
|
|
308
394
|
constructor(min?: vec3, max?: vec3);
|
|
395
|
+
/** Returns a deep copy of the box. */
|
|
309
396
|
clone(): Box3;
|
|
397
|
+
/** Returns `true` when the box encloses no volume. */
|
|
310
398
|
isEmpty(): boolean;
|
|
399
|
+
/**
|
|
400
|
+
* Tests whether two boxes overlap. Boxes are treated as half-open
|
|
401
|
+
* intervals so touching faces do not count as overlap.
|
|
402
|
+
*
|
|
403
|
+
* @param a - The first box.
|
|
404
|
+
* @param b - The second box.
|
|
405
|
+
*/
|
|
311
406
|
static intersects(a: Box3, b: Box3): boolean;
|
|
407
|
+
/**
|
|
408
|
+
* Grows the box in place to contain the given point.
|
|
409
|
+
*
|
|
410
|
+
* @param p - The point to include.
|
|
411
|
+
*/
|
|
312
412
|
expandWithPoint(p: vec3): void;
|
|
413
|
+
/**
|
|
414
|
+
* Transforms the box in place by the given matrix. The result is the
|
|
415
|
+
* axis-aligned box of the eight transformed corners so the box can grow
|
|
416
|
+
* under rotation.
|
|
417
|
+
*
|
|
418
|
+
* @param matrix - The transform to apply.
|
|
419
|
+
*/
|
|
313
420
|
applyTransform(matrix: mat4): void;
|
|
314
421
|
}
|
|
315
422
|
|
|
423
|
+
/**
|
|
424
|
+
* Camera view frustum defined by six world-space planes.
|
|
425
|
+
*
|
|
426
|
+
* Frustum represents the visible region of a camera as six bounding
|
|
427
|
+
* planes. It is used for culling tests and visibility checks against
|
|
428
|
+
* bounding boxes. The planes are extracted from a view-projection matrix
|
|
429
|
+
* and normalized so distances are in world units.
|
|
430
|
+
*
|
|
431
|
+
* @group Math
|
|
432
|
+
*/
|
|
316
433
|
declare class Frustum {
|
|
317
434
|
private readonly planes_;
|
|
435
|
+
/**
|
|
436
|
+
* Creates a frustum from a view-projection matrix.
|
|
437
|
+
*
|
|
438
|
+
* @param m - The combined view-projection matrix.
|
|
439
|
+
*/
|
|
318
440
|
constructor(m: mat4);
|
|
441
|
+
/**
|
|
442
|
+
* Re-extracts the six planes from a view-projection matrix.
|
|
443
|
+
*
|
|
444
|
+
* @param m - The combined view-projection matrix.
|
|
445
|
+
*/
|
|
319
446
|
setWithViewProjection(m: mat4): void;
|
|
447
|
+
/**
|
|
448
|
+
* Tests whether a box is at least partly inside the frustum. The test
|
|
449
|
+
* is conservative. A box outside the frustum but near a corner can be
|
|
450
|
+
* reported as intersecting, which only costs a draw of an offscreen
|
|
451
|
+
* object.
|
|
452
|
+
*
|
|
453
|
+
* @param box - The world-space box to test.
|
|
454
|
+
*/
|
|
320
455
|
intersectsWithBox3(box: Box3): boolean;
|
|
321
456
|
}
|
|
322
457
|
|
|
458
|
+
/**
|
|
459
|
+
* Transform defined by translation, rotation, and scale components.
|
|
460
|
+
*
|
|
461
|
+
* TRS transform represents a placement in world space composed as
|
|
462
|
+
* translation times rotation times scale. It is used to position cameras
|
|
463
|
+
* and renderable objects through their `transform` property. The matrix
|
|
464
|
+
* is computed lazily and cached.
|
|
465
|
+
*
|
|
466
|
+
* ```ts
|
|
467
|
+
* const transform = camera.transform;
|
|
468
|
+
* transform.setTranslation([0, 0, radius]);
|
|
469
|
+
* transform.targetTo([0, 0, 0]);
|
|
470
|
+
* ```
|
|
471
|
+
*
|
|
472
|
+
* @group Math
|
|
473
|
+
*/
|
|
323
474
|
declare class TrsTransform {
|
|
324
475
|
private dirty_;
|
|
325
476
|
private matrix_;
|
|
326
477
|
private rotation_;
|
|
327
478
|
private translation_;
|
|
328
479
|
private scale_;
|
|
480
|
+
/**
|
|
481
|
+
* Composes the given rotation onto the current rotation.
|
|
482
|
+
*
|
|
483
|
+
* @param q - The rotation to apply.
|
|
484
|
+
*/
|
|
329
485
|
addRotation(q: quat): void;
|
|
486
|
+
/**
|
|
487
|
+
* Replaces the rotation with the given quaternion.
|
|
488
|
+
*
|
|
489
|
+
* @param q - The new rotation.
|
|
490
|
+
*/
|
|
330
491
|
setRotation(q: quat): void;
|
|
492
|
+
/** A copy of the rotation quaternion. */
|
|
331
493
|
get rotation(): gl_matrix.vec4;
|
|
494
|
+
/**
|
|
495
|
+
* Adds the given offset to the translation.
|
|
496
|
+
*
|
|
497
|
+
* @param vec - The offset to add.
|
|
498
|
+
*/
|
|
332
499
|
addTranslation(vec: vec3): void;
|
|
500
|
+
/**
|
|
501
|
+
* Replaces the translation with the given vector.
|
|
502
|
+
*
|
|
503
|
+
* @param vec - The new translation.
|
|
504
|
+
*/
|
|
333
505
|
setTranslation(vec: vec3): void;
|
|
506
|
+
/** A copy of the translation vector. */
|
|
334
507
|
get translation(): vec3;
|
|
508
|
+
/**
|
|
509
|
+
* Multiplies the scale componentwise by the given vector.
|
|
510
|
+
*
|
|
511
|
+
* @param vec - The scale factors to apply.
|
|
512
|
+
*/
|
|
335
513
|
addScale(vec: vec3): void;
|
|
514
|
+
/**
|
|
515
|
+
* Replaces the scale with the given vector.
|
|
516
|
+
*
|
|
517
|
+
* @param vec - The new scale.
|
|
518
|
+
*/
|
|
336
519
|
setScale(vec: vec3): void;
|
|
520
|
+
/**
|
|
521
|
+
* Rotates the transform to face the given target point. Uses `+Y` as
|
|
522
|
+
* world up.
|
|
523
|
+
*
|
|
524
|
+
* @param target - The world-space point to face.
|
|
525
|
+
*/
|
|
337
526
|
targetTo(target: vec3): void;
|
|
527
|
+
/** A copy of the scale vector. */
|
|
338
528
|
get scale(): vec3;
|
|
529
|
+
/** The composed transform matrix. Recomputed when stale. */
|
|
339
530
|
get matrix(): mat4;
|
|
531
|
+
/** The inverse of the composed transform matrix. */
|
|
340
532
|
get inverse(): mat4;
|
|
341
533
|
private computeMatrix;
|
|
342
534
|
}
|
|
343
535
|
|
|
536
|
+
/** Identifies a concrete camera implementation. */
|
|
344
537
|
type CameraType = "OrthographicCamera" | "PerspectiveCamera";
|
|
538
|
+
/**
|
|
539
|
+
* Abstract base class for cameras.
|
|
540
|
+
*
|
|
541
|
+
* A camera pairs a world-space transform with a projection, producing the
|
|
542
|
+
* view and projection matrices used to render a viewport. The concrete
|
|
543
|
+
* cameras, {@link OrthographicCamera} and {@link PerspectiveCamera}, define
|
|
544
|
+
* the projection. This class provides the shared transform, derived
|
|
545
|
+
* matrices, and navigation helpers.
|
|
546
|
+
*
|
|
547
|
+
* @group Cameras
|
|
548
|
+
*/
|
|
345
549
|
declare abstract class Camera extends Node {
|
|
346
550
|
private readonly transform_;
|
|
551
|
+
/** @hidden */
|
|
347
552
|
protected projectionMatrix_: mat4;
|
|
553
|
+
/** @hidden */
|
|
348
554
|
protected near_: number;
|
|
555
|
+
/** @hidden */
|
|
349
556
|
protected far_: number;
|
|
557
|
+
/** @hidden */
|
|
350
558
|
protected abstract updateProjectionMatrix(): void;
|
|
559
|
+
/** Identifies the camera type. */
|
|
351
560
|
abstract get type(): CameraType;
|
|
561
|
+
/** Recomputes the camera's projection matrix. */
|
|
352
562
|
update(): void;
|
|
563
|
+
/** The camera's projection matrix. */
|
|
353
564
|
get projectionMatrix(): mat4;
|
|
565
|
+
/** The camera's world-space transform. */
|
|
354
566
|
get transform(): TrsTransform;
|
|
567
|
+
/** The view matrix: the inverse of the camera's world transform. */
|
|
355
568
|
get viewMatrix(): mat4;
|
|
569
|
+
/** The camera's local right axis in world space. */
|
|
356
570
|
get right(): vec3;
|
|
571
|
+
/** The camera's local up axis in world space. */
|
|
357
572
|
get up(): vec3;
|
|
573
|
+
/**
|
|
574
|
+
* Computes the combined view-projection matrix.
|
|
575
|
+
*
|
|
576
|
+
* @returns The projection matrix multiplied by the view matrix.
|
|
577
|
+
*/
|
|
358
578
|
getViewProjection(): mat4;
|
|
579
|
+
/** The view frustum derived from the current view-projection. */
|
|
359
580
|
get frustum(): Frustum;
|
|
581
|
+
/**
|
|
582
|
+
* Sets the aspect ratio (width / height) of the viewport the camera
|
|
583
|
+
* renders into. Called automatically by the owning viewport when it
|
|
584
|
+
* resizes.
|
|
585
|
+
*
|
|
586
|
+
* @param aspectRatio - The viewport's width divided by its height.
|
|
587
|
+
*/
|
|
360
588
|
abstract setAspectRatio(aspectRatio: number): void;
|
|
589
|
+
/**
|
|
590
|
+
* Zooms the view by the given factor relative to the current zoom level.
|
|
591
|
+
* Factors greater than `1` zoom in and factors between `0` and `1` zoom
|
|
592
|
+
* out.
|
|
593
|
+
*
|
|
594
|
+
* @param factor - The magnification factor to apply.
|
|
595
|
+
*/
|
|
361
596
|
abstract zoom(factor: number): void;
|
|
597
|
+
/**
|
|
598
|
+
* Moves the camera by the given world-space offset.
|
|
599
|
+
*
|
|
600
|
+
* @param vec - The translation to add to the camera's position.
|
|
601
|
+
*/
|
|
362
602
|
pan(vec: vec3): void;
|
|
603
|
+
/** The camera's world-space position. */
|
|
363
604
|
get position(): vec3;
|
|
605
|
+
/**
|
|
606
|
+
* Transforms a position from clip space to world space.
|
|
607
|
+
*
|
|
608
|
+
* @param position - The clip-space position to transform.
|
|
609
|
+
* @returns The corresponding world-space position.
|
|
610
|
+
*/
|
|
364
611
|
clipToWorld(position: vec3): vec3;
|
|
365
612
|
}
|
|
366
613
|
|
|
@@ -397,39 +644,126 @@ declare class WireframeGeometry extends Geometry {
|
|
|
397
644
|
|
|
398
645
|
type Shader = "floatScalarImage" | "floatVolume" | "intLabelImage" | "intScalarImage" | "intVolume" | "labelImage" | "points" | "projectedLine" | "uintScalarImage" | "uintVolume" | "wireframe" | "meshDepth" | "pointsDepth" | "projectedLineDepth";
|
|
399
646
|
|
|
400
|
-
/**
|
|
647
|
+
/**
|
|
648
|
+
* A value convertible to {@link Color}.
|
|
649
|
+
*/
|
|
401
650
|
type ColorLike = Color | vec3 | vec4 | string;
|
|
402
|
-
/**
|
|
651
|
+
/**
|
|
652
|
+
* Immutable RGBA color with components in `[0, 1]`.
|
|
653
|
+
*
|
|
654
|
+
* Color represents an RGBA value with four components. It is used for channel
|
|
655
|
+
* tints, label color maps, and wireframe overlays. Components are validated
|
|
656
|
+
* at construction and never change. Every API that takes a color accepts a
|
|
657
|
+
* {@link ColorLike} so hex strings and component arrays coerce automatically
|
|
658
|
+
* through {@link from}. Common colors are available as static presets.
|
|
659
|
+
*
|
|
660
|
+
* @group Math
|
|
661
|
+
*/
|
|
403
662
|
declare class Color {
|
|
663
|
+
/** Opaque red `#ff0000`. */
|
|
404
664
|
static readonly RED: Color;
|
|
665
|
+
/** Opaque green `#00ff00`. */
|
|
405
666
|
static readonly GREEN: Color;
|
|
667
|
+
/** Opaque blue `#0000ff`. */
|
|
406
668
|
static readonly BLUE: Color;
|
|
669
|
+
/** Opaque yellow `#ffff00`. */
|
|
407
670
|
static readonly YELLOW: Color;
|
|
671
|
+
/** Opaque magenta `#ff00ff`. */
|
|
408
672
|
static readonly MAGENTA: Color;
|
|
673
|
+
/** Opaque cyan `#00ffff`. */
|
|
409
674
|
static readonly CYAN: Color;
|
|
675
|
+
/** Opaque black `#000000`. */
|
|
410
676
|
static readonly BLACK: Color;
|
|
677
|
+
/** Opaque white `#ffffff`. */
|
|
411
678
|
static readonly WHITE: Color;
|
|
679
|
+
/** Fully transparent black. */
|
|
412
680
|
static readonly TRANSPARENT: Color;
|
|
413
681
|
private readonly rgba_;
|
|
682
|
+
/**
|
|
683
|
+
* Creates a color from RGBA components in `[0, 1]`.
|
|
684
|
+
*
|
|
685
|
+
* @param r - The red component.
|
|
686
|
+
* @param g - The green component.
|
|
687
|
+
* @param b - The blue component.
|
|
688
|
+
* @param a - The alpha component. Defaults to `1`.
|
|
689
|
+
*/
|
|
414
690
|
constructor(r: number, g: number, b: number, a?: number);
|
|
691
|
+
/** The RGB components as a three-element array. */
|
|
415
692
|
get rgb(): [number, number, number];
|
|
693
|
+
/** The RGBA components as a four-element array. */
|
|
416
694
|
get rgba(): readonly [number, number, number, number];
|
|
695
|
+
/** The red component. */
|
|
417
696
|
get r(): number;
|
|
697
|
+
/** The green component. */
|
|
418
698
|
get g(): number;
|
|
699
|
+
/** The blue component. */
|
|
419
700
|
get b(): number;
|
|
701
|
+
/** The alpha component. */
|
|
420
702
|
get a(): number;
|
|
703
|
+
/** The color as a `#rrggbb` hex string. Alpha is dropped. */
|
|
421
704
|
get rgbHex(): string;
|
|
705
|
+
/** The color packed into a 32-bit integer as RGBA bytes. */
|
|
422
706
|
get packed(): number;
|
|
707
|
+
/**
|
|
708
|
+
* Converts a {@link ColorLike} value to a `Color`.
|
|
709
|
+
*
|
|
710
|
+
* @param colorLike - The value to convert.
|
|
711
|
+
*/
|
|
423
712
|
static from(colorLike: ColorLike): Color;
|
|
713
|
+
/**
|
|
714
|
+
* Parses a `#rrggbb` hex string into an opaque color.
|
|
715
|
+
*
|
|
716
|
+
* @param hex - The hex string with or without the leading `#`.
|
|
717
|
+
*/
|
|
424
718
|
static fromRgbHex(hex: string): Color;
|
|
425
719
|
private toHexComponent;
|
|
426
720
|
}
|
|
427
721
|
|
|
428
722
|
type CullingMode = "none" | "front" | "back" | "both";
|
|
429
723
|
|
|
724
|
+
/**
|
|
725
|
+
* Abstract base class representing a {@link Layer}-renderable object.
|
|
726
|
+
*
|
|
727
|
+
* Renderables pair a geometry with a shader program, textures, uniform
|
|
728
|
+
* values, and a world transform. Subclasses assign a geometry, select one
|
|
729
|
+
* of the built-in shader programs through {@link programName} or provide
|
|
730
|
+
* a new one, bind textures with {@link setTexture}, and override {@link getUniforms} to
|
|
731
|
+
* feed values to the shader.
|
|
732
|
+
*
|
|
733
|
+
* ```ts
|
|
734
|
+
* class MyRenderable extends RenderableObject {
|
|
735
|
+
* constructor(texture: Texture) {
|
|
736
|
+
* super();
|
|
737
|
+
* this.geometry = new PlaneGeometry(512, 512, 1, 1);
|
|
738
|
+
* this.programName = "floatScalarImage";
|
|
739
|
+
*
|
|
740
|
+
* this.setTexture(0, texture);
|
|
741
|
+
* }
|
|
742
|
+
*
|
|
743
|
+
* public get type() {
|
|
744
|
+
* return "MyRenderable";
|
|
745
|
+
* }
|
|
746
|
+
*
|
|
747
|
+
* public override getUniforms() {
|
|
748
|
+
* return { u_imageSampler: 0 };
|
|
749
|
+
* }
|
|
750
|
+
* }
|
|
751
|
+
* ```
|
|
752
|
+
*
|
|
753
|
+
* @group Renderables
|
|
754
|
+
*/
|
|
430
755
|
declare abstract class RenderableObject extends Node {
|
|
756
|
+
/**
|
|
757
|
+
* Draws the geometry's wireframe on top of the normal pass. Layers use
|
|
758
|
+
* this as a chunk debugging aid. Defaults to `false`.
|
|
759
|
+
*/
|
|
431
760
|
wireframeEnabled: boolean;
|
|
761
|
+
/** The color of the wireframe overlay. Defaults to `Color.WHITE`. */
|
|
432
762
|
wireframeColor: Color;
|
|
763
|
+
/**
|
|
764
|
+
* Whether the object is depth tested when drawn. Objects that opt out
|
|
765
|
+
* are also left out of the depth prepass. Defaults to `true`.
|
|
766
|
+
*/
|
|
433
767
|
depthTest: boolean;
|
|
434
768
|
private readonly textures_;
|
|
435
769
|
private staleTextures_;
|
|
@@ -439,25 +773,90 @@ declare abstract class RenderableObject extends Node {
|
|
|
439
773
|
private programName_;
|
|
440
774
|
private depthProgramName_;
|
|
441
775
|
private cullFaceMode_;
|
|
776
|
+
/**
|
|
777
|
+
* Assigns a texture to the given texture unit. The renderer binds each
|
|
778
|
+
* entry of {@link textures} to its matching unit before drawing.
|
|
779
|
+
*
|
|
780
|
+
* @param index - The texture unit to bind to.
|
|
781
|
+
* @param texture - The texture to assign.
|
|
782
|
+
*/
|
|
442
783
|
setTexture(index: number, texture: Texture): void;
|
|
784
|
+
/**
|
|
785
|
+
* Removes all assigned textures.
|
|
786
|
+
*/
|
|
443
787
|
protected clearTextures(): void;
|
|
788
|
+
/**
|
|
789
|
+
* Queues a replaced texture for GPU disposal. Subclasses call this when
|
|
790
|
+
* swapping out a texture they own. The renderer drains the queue
|
|
791
|
+
* through {@link popStaleTextures} before the next draw. Passing
|
|
792
|
+
* `undefined` is a no-op.
|
|
793
|
+
*
|
|
794
|
+
* @param texture - The texture that is no longer in use.
|
|
795
|
+
*/
|
|
444
796
|
protected markStaleTexture(texture: Texture | undefined): void;
|
|
797
|
+
/**
|
|
798
|
+
* Drains the queue of textures marked stale. Called automatically by
|
|
799
|
+
* the renderer, which disposes the GPU resources of each returned
|
|
800
|
+
* texture.
|
|
801
|
+
*
|
|
802
|
+
* @returns The textures queued since the last call.
|
|
803
|
+
*/
|
|
445
804
|
popStaleTextures(): Texture[];
|
|
805
|
+
/**
|
|
806
|
+
* The geometry drawn for this object.
|
|
807
|
+
*/
|
|
446
808
|
get geometry(): Geometry;
|
|
809
|
+
/**
|
|
810
|
+
* A line-segment version of {@link geometry} used for the wireframe
|
|
811
|
+
* overlay. Built lazily on first access and cached until the geometry
|
|
812
|
+
* changes.
|
|
813
|
+
*/
|
|
447
814
|
get wireframeGeometry(): WireframeGeometry;
|
|
815
|
+
/** The assigned textures indexed by texture unit. */
|
|
448
816
|
get textures(): Texture[];
|
|
817
|
+
/**
|
|
818
|
+
* The object's world transform as translation, rotation, and scale.
|
|
819
|
+
* Layers position, orient, and size renderables through it.
|
|
820
|
+
*/
|
|
449
821
|
get transform(): TrsTransform;
|
|
822
|
+
/** @param geometry - The geometry to draw. */
|
|
450
823
|
set geometry(geometry: Geometry);
|
|
824
|
+
/**
|
|
825
|
+
* The name of a shader program that draws the object. The
|
|
826
|
+
* renderer skips objects whose program name is `null`.
|
|
827
|
+
*/
|
|
451
828
|
get programName(): Shader | null;
|
|
829
|
+
/**
|
|
830
|
+
* The name of the shader program used in the depth prepass or `null`
|
|
831
|
+
* to stay out of it. Objects without one never occlude other layers.
|
|
832
|
+
*/
|
|
452
833
|
get depthProgramName(): Shader | null;
|
|
834
|
+
/**
|
|
835
|
+
* The geometry's bounding box transformed to world space. The renderer
|
|
836
|
+
* culls objects whose box falls outside the view frustum.
|
|
837
|
+
*/
|
|
453
838
|
get boundingBox(): Box3;
|
|
839
|
+
/**
|
|
840
|
+
* @param programName - The shader program name.
|
|
841
|
+
*/
|
|
454
842
|
protected set programName(programName: Shader);
|
|
843
|
+
/**
|
|
844
|
+
* Selects the shader program for the depth prepass. Subclasses set
|
|
845
|
+
* this so the object writes depth and occludes content in other
|
|
846
|
+
* layers.
|
|
847
|
+
*
|
|
848
|
+
* @param programName - The shader program name.
|
|
849
|
+
*/
|
|
455
850
|
protected set depthProgramName(programName: Shader);
|
|
851
|
+
/** Which triangle faces are culled when drawing. Defaults to `"none"`. */
|
|
456
852
|
get cullFaceMode(): CullingMode;
|
|
853
|
+
/** @param mode - The culling mode to apply. */
|
|
457
854
|
set cullFaceMode(mode: CullingMode);
|
|
458
855
|
/**
|
|
459
|
-
*
|
|
460
|
-
*
|
|
856
|
+
* Returns the uniform values to upload before drawing. Override in
|
|
857
|
+
* subclasses that need custom uniforms. Values are matched to shader
|
|
858
|
+
* uniforms by name and take precedence over the owning layer's
|
|
859
|
+
* uniforms.
|
|
461
860
|
*/
|
|
462
861
|
getUniforms(): Record<string, unknown>;
|
|
463
862
|
}
|
|
@@ -505,88 +904,245 @@ declare class EventDispatcher {
|
|
|
505
904
|
private readonly handleEvent;
|
|
506
905
|
}
|
|
507
906
|
|
|
508
|
-
/**
|
|
907
|
+
/**
|
|
908
|
+
* The loading lifecycle state of a layer.
|
|
909
|
+
*/
|
|
509
910
|
type LayerState = "initialized" | "loading" | "ready";
|
|
911
|
+
/**
|
|
912
|
+
* How a layer's output blends with previously drawn content.
|
|
913
|
+
*/
|
|
510
914
|
type BlendMode = "none" | "normal" | "additive" | "subtractive" | "multiply" | "premultipliedOver";
|
|
915
|
+
/**
|
|
916
|
+
* A callback invoked after a layer's state changes.
|
|
917
|
+
*/
|
|
511
918
|
type StateChangeCallback = (newState: LayerState, prevState?: LayerState) => void;
|
|
512
|
-
|
|
919
|
+
/**
|
|
920
|
+
* Initialization properties for constructing a layer.
|
|
921
|
+
*/
|
|
922
|
+
type LayerProps = {
|
|
923
|
+
/** Layer opacity in `[0, 1]`. Defaults to `1`. */
|
|
513
924
|
opacity?: number;
|
|
925
|
+
/** How the layer blends. Defaults to `"none"`. */
|
|
514
926
|
blendMode?: BlendMode;
|
|
927
|
+
/** Hides content behind. Inferred from `blendMode`. */
|
|
515
928
|
occludes?: boolean;
|
|
516
|
-
}
|
|
929
|
+
};
|
|
517
930
|
/**
|
|
518
|
-
* Abstract base class for
|
|
931
|
+
* Abstract base class for any layer that can be added to a viewport.
|
|
932
|
+
*
|
|
933
|
+
* A layer owns a set of renderable objects and contributes them to the
|
|
934
|
+
* scene each frame. Subclasses such as {@link ImageLayer},
|
|
935
|
+
* {@link VolumeLayer}, and {@link LabelLayer} implement {@link update} to
|
|
936
|
+
* build or refresh those objects for the current view. Custom layers
|
|
937
|
+
* register objects with {@link addObject} and report readiness through
|
|
938
|
+
* {@link setState}.
|
|
939
|
+
*
|
|
940
|
+
* Layers carry shared presentation state in {@link opacity},
|
|
941
|
+
* {@link blendMode}, and {@link occludes}, and expose a lifecycle
|
|
942
|
+
* {@link LayerState} that observers can subscribe to. A layer instance may
|
|
943
|
+
* be attached to only one viewport at a time.
|
|
519
944
|
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
* objects for the current view, and may override the `attach`/`detach` hooks to
|
|
524
|
-
* acquire and release resources when the layer joins or leaves a viewport.
|
|
945
|
+
* ```ts
|
|
946
|
+
* class Particles extends Layer {
|
|
947
|
+
* public readonly type = "Particles";
|
|
525
948
|
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
949
|
+
* constructor(points: PointProps[]) {
|
|
950
|
+
* super();
|
|
951
|
+
* this.addObject(new PointsRenderable(points));
|
|
952
|
+
* this.setState("ready");
|
|
953
|
+
* }
|
|
954
|
+
*
|
|
955
|
+
* public update() {}
|
|
956
|
+
* }
|
|
957
|
+
*
|
|
958
|
+
* viewport.addLayer(new Particles(points));
|
|
959
|
+
* ```
|
|
530
960
|
*
|
|
531
961
|
* @group Layers
|
|
532
962
|
*/
|
|
533
963
|
declare abstract class Layer {
|
|
964
|
+
/** A string identifying the concrete layer type. */
|
|
534
965
|
abstract readonly type: string;
|
|
966
|
+
/**
|
|
967
|
+
* How the layer's output blends with previously drawn content. Also
|
|
968
|
+
* applies to blending between objects within the layer.
|
|
969
|
+
*/
|
|
970
|
+
blendMode: BlendMode;
|
|
971
|
+
/**
|
|
972
|
+
* Whether the layer writes depth and hides content drawn behind it.
|
|
973
|
+
*
|
|
974
|
+
* Occluding layers render a depth pass and always draw before
|
|
975
|
+
* non-occluding layers regardless of their order in the viewport. When
|
|
976
|
+
* not set explicitly this value is inferred from `blendMode` at
|
|
977
|
+
* construction only. Reassigning {@link blendMode} later does not update
|
|
978
|
+
* it.
|
|
979
|
+
*/
|
|
980
|
+
occludes: boolean;
|
|
981
|
+
/** Set to `true` by subclasses whose shaders read scene depth. */
|
|
982
|
+
protected requiresSceneDepth_: boolean;
|
|
535
983
|
private readonly coverageGroups_;
|
|
536
984
|
private state_;
|
|
537
985
|
private attached_;
|
|
538
986
|
private readonly callbacks_;
|
|
539
987
|
private opacity_;
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
988
|
+
/**
|
|
989
|
+
* Creates a layer with the given presentation state.
|
|
990
|
+
*
|
|
991
|
+
* @param props - Initialization properties.
|
|
992
|
+
*/
|
|
543
993
|
constructor({ opacity, blendMode, occludes, }?: LayerProps);
|
|
994
|
+
/**
|
|
995
|
+
* Whether the layer's shaders read scene depth. When `true` the renderer
|
|
996
|
+
* draws occluding layers to a depth texture the layer's shaders can
|
|
997
|
+
* sample. A layer cannot both occlude and read scene depth.
|
|
998
|
+
*/
|
|
544
999
|
get requiresSceneDepth(): boolean;
|
|
1000
|
+
/** The layer's opacity in `[0, 1]`. Values outside are clamped. */
|
|
545
1001
|
get opacity(): number;
|
|
1002
|
+
/** @param value - The new opacity in `[0, 1]`. */
|
|
546
1003
|
set opacity(value: number);
|
|
1004
|
+
/**
|
|
1005
|
+
* Builds or refreshes the layer's renderable objects for the current
|
|
1006
|
+
* view. Called automatically once per frame for every layer in a
|
|
1007
|
+
* viewport.
|
|
1008
|
+
*
|
|
1009
|
+
* @param viewport - The viewport being rendered.
|
|
1010
|
+
*/
|
|
547
1011
|
abstract update(viewport?: Viewport): void;
|
|
548
|
-
|
|
1012
|
+
/**
|
|
1013
|
+
* Handles a pointer or wheel event from the owning viewport. Called
|
|
1014
|
+
* automatically for each event before the camera controls. The default
|
|
1015
|
+
* implementation does nothing.
|
|
1016
|
+
*
|
|
1017
|
+
* @param _event - The event with clip and world coordinates attached.
|
|
1018
|
+
*/
|
|
1019
|
+
onEvent(_event: EventContext): void;
|
|
1020
|
+
/**
|
|
1021
|
+
* Lifecycle hook that is called automatically when a layer is
|
|
1022
|
+
* is attached to a viewport. A layer can only be attached to one viewport
|
|
1023
|
+
* at a time.
|
|
1024
|
+
*
|
|
1025
|
+
* @param context - The shared runtime context.
|
|
1026
|
+
*/
|
|
549
1027
|
onAttached(context: IdetikContext): void;
|
|
1028
|
+
/**
|
|
1029
|
+
* Lifecycle hook that is called automatically when a layer is detached
|
|
1030
|
+
* from a viewport.
|
|
1031
|
+
*
|
|
1032
|
+
* @param context - The shared runtime context.
|
|
1033
|
+
*/
|
|
550
1034
|
onDetached(context: IdetikContext): void;
|
|
1035
|
+
/** @hidden */
|
|
551
1036
|
protected attach(_context: IdetikContext): void;
|
|
1037
|
+
/** @hidden */
|
|
552
1038
|
protected detach(_context: IdetikContext): void;
|
|
1039
|
+
/**
|
|
1040
|
+
* The layer's renderable objects grouped by coverage group. Objects in
|
|
1041
|
+
* a group draw each pixel at most once, letting chunks at multiple
|
|
1042
|
+
* levels of detail overlap correctly.
|
|
1043
|
+
*/
|
|
553
1044
|
get coverageGroups(): ReadonlyMap<number | null, readonly RenderableObject[]>;
|
|
1045
|
+
/** The layer's current lifecycle state. */
|
|
554
1046
|
get state(): LayerState;
|
|
1047
|
+
/**
|
|
1048
|
+
* Registers a callback invoked after every state change.
|
|
1049
|
+
*
|
|
1050
|
+
* @param callback - Receives the new and previous states.
|
|
1051
|
+
*/
|
|
555
1052
|
addStateChangeCallback(callback: StateChangeCallback): void;
|
|
1053
|
+
/**
|
|
1054
|
+
* Removes a previously registered state change callback.
|
|
1055
|
+
*
|
|
1056
|
+
* @param callback - The callback to remove.
|
|
1057
|
+
*/
|
|
556
1058
|
removeStateChangeCallback(callback: StateChangeCallback): void;
|
|
1059
|
+
/**
|
|
1060
|
+
* Sets the lifecycle state and notifies state change callbacks.
|
|
1061
|
+
*
|
|
1062
|
+
* @param newState - The state to enter.
|
|
1063
|
+
*/
|
|
557
1064
|
protected setState(newState: LayerState): void;
|
|
1065
|
+
/**
|
|
1066
|
+
* Registers a renderable object for drawing. Objects in the same
|
|
1067
|
+
* coverage group draw each pixel at most once.
|
|
1068
|
+
*
|
|
1069
|
+
* @param object - The object to add.
|
|
1070
|
+
* @param coverageGroup - The group key.
|
|
1071
|
+
*/
|
|
558
1072
|
protected addObject(object: RenderableObject, coverageGroup?: number | null): void;
|
|
1073
|
+
/** Removes all registered renderable objects. */
|
|
559
1074
|
protected clearObjects(): void;
|
|
560
1075
|
/**
|
|
561
|
-
*
|
|
562
|
-
*
|
|
1076
|
+
* Returns uniform name-value pairs applied to every object drawn by
|
|
1077
|
+
* this layer. Override in subclasses that need custom shader uniforms.
|
|
563
1078
|
*/
|
|
564
1079
|
getUniforms(): Record<string, unknown>;
|
|
565
1080
|
}
|
|
566
1081
|
|
|
1082
|
+
/**
|
|
1083
|
+
* A world-space rectangle for the camera to frame.
|
|
1084
|
+
*/
|
|
567
1085
|
type OrthographicCameraFrame = {
|
|
1086
|
+
/** Left edge of the view frame in world units. */
|
|
568
1087
|
left: number;
|
|
1088
|
+
/** Right edge of the view frame in world units. */
|
|
569
1089
|
right: number;
|
|
1090
|
+
/** Top edge of the view frame in world units. */
|
|
570
1091
|
top: number;
|
|
1092
|
+
/** Bottom edge of the view frame in world units. */
|
|
571
1093
|
bottom: number;
|
|
572
1094
|
};
|
|
573
|
-
|
|
1095
|
+
/**
|
|
1096
|
+
* Initialization properties for constructing an orthographic camera.
|
|
1097
|
+
*/
|
|
1098
|
+
type OrthographicCameraProps = {
|
|
1099
|
+
/** Left edge of the view frame in world units. */
|
|
1100
|
+
left: number;
|
|
1101
|
+
/** Right edge of the view frame in world units. */
|
|
1102
|
+
right: number;
|
|
1103
|
+
/** Top edge of the view frame in world units. */
|
|
1104
|
+
top: number;
|
|
1105
|
+
/** Bottom edge of the view frame in world units. */
|
|
1106
|
+
bottom: number;
|
|
1107
|
+
/** Near clipping plane distance. Defaults to `-1e6`. */
|
|
574
1108
|
near?: number;
|
|
1109
|
+
/** Far clipping plane distance. Defaults to `1e6`. */
|
|
575
1110
|
far?: number;
|
|
1111
|
+
/** Slice orientation. Defaults to `"XY"`. */
|
|
576
1112
|
orientation?: SliceOrientation;
|
|
577
1113
|
};
|
|
578
1114
|
/**
|
|
579
1115
|
* A camera using an orthographic (parallel) projection.
|
|
580
1116
|
*
|
|
581
|
-
* Orthographic projection has no perspective foreshortening
|
|
582
|
-
*
|
|
583
|
-
* image viewing
|
|
584
|
-
*
|
|
585
|
-
* scale and translation on top of that frame.
|
|
1117
|
+
* Orthographic projection has no perspective foreshortening: objects render at
|
|
1118
|
+
* the same size regardless of their distance from the camera, which makes this
|
|
1119
|
+
* the camera to use for 2D image viewing. It pairs naturally with
|
|
1120
|
+
* {@link PanZoomControls}.
|
|
586
1121
|
*
|
|
587
|
-
*
|
|
1122
|
+
* The constructor frames a world-space rectangle, typically the physical
|
|
1123
|
+
* extent of the image being viewed. Zoom and pan are then applied as scale and
|
|
1124
|
+
* translation on top of that frame, and {@link setFrame} resets them. When the
|
|
1125
|
+
* viewport's aspect ratio differs from the frame's, the frame is padded rather
|
|
1126
|
+
* than stretched, so image pixels always stay square.
|
|
588
1127
|
*
|
|
589
|
-
*
|
|
1128
|
+
* ```ts
|
|
1129
|
+
* const camera = new OrthographicCamera({
|
|
1130
|
+
* left: 0,
|
|
1131
|
+
* right: 1024,
|
|
1132
|
+
* top: 0,
|
|
1133
|
+
* bottom: 1024
|
|
1134
|
+
* });
|
|
1135
|
+
*
|
|
1136
|
+
* const idetik = new Idetik({
|
|
1137
|
+
* canvas: document.querySelector('canvas')!,
|
|
1138
|
+
* viewports: [{
|
|
1139
|
+
* camera,
|
|
1140
|
+
* layers: [imageLayer],
|
|
1141
|
+
* cameraControls: new PanZoomControls(camera),
|
|
1142
|
+
* }],
|
|
1143
|
+
* });
|
|
1144
|
+
* ```
|
|
1145
|
+
* @group Cameras
|
|
590
1146
|
*/
|
|
591
1147
|
declare class OrthographicCamera extends Camera {
|
|
592
1148
|
private width_;
|
|
@@ -599,40 +1155,164 @@ declare class OrthographicCamera extends Camera {
|
|
|
599
1155
|
/**
|
|
600
1156
|
* Creates an orthographic camera framing the given world-space rectangle.
|
|
601
1157
|
*
|
|
602
|
-
* @param props -
|
|
603
|
-
* plane distances (default `-1e6` and `1e6`), and the slice orientation
|
|
604
|
-
* the camera faces (default `"XY"`).
|
|
1158
|
+
* @param props - Initialization properties.
|
|
605
1159
|
*/
|
|
606
1160
|
constructor(props: OrthographicCameraProps);
|
|
1161
|
+
/**
|
|
1162
|
+
* The world-space size of the rendered view as `[width, height]`.
|
|
1163
|
+
*
|
|
1164
|
+
* This is the camera frame padded to match the viewport's aspect ratio, so
|
|
1165
|
+
* it reflects what is actually visible rather than the frame that was set.
|
|
1166
|
+
*/
|
|
607
1167
|
get viewportSize(): [number, number];
|
|
1168
|
+
/**
|
|
1169
|
+
* Sets the aspect ratio (width / height) of the viewport the camera renders
|
|
1170
|
+
* into. Called automatically by the owning viewport when it resizes.
|
|
1171
|
+
*
|
|
1172
|
+
* @param aspectRatio - The viewport's width divided by its height.
|
|
1173
|
+
*/
|
|
608
1174
|
setAspectRatio(aspectRatio: number): void;
|
|
1175
|
+
/**
|
|
1176
|
+
* Reframes the camera to the given world-space rectangle, resetting any
|
|
1177
|
+
* accumulated zoom and pan.
|
|
1178
|
+
*
|
|
1179
|
+
* The frame may be padded horizontally or vertically at render time to
|
|
1180
|
+
* match the viewport's aspect ratio (see {@link viewportSize}).
|
|
1181
|
+
*
|
|
1182
|
+
* @param frame - The view frame edges in world units.
|
|
1183
|
+
*/
|
|
609
1184
|
setFrame({ left, right, top, bottom }: OrthographicCameraFrame): void;
|
|
1185
|
+
/** Identifies the camera type as `OrthographicCamera`. */
|
|
610
1186
|
get type(): CameraType;
|
|
1187
|
+
/** The slice orientation the camera faces. */
|
|
611
1188
|
get orientation(): SliceOrientation;
|
|
612
1189
|
/**
|
|
613
1190
|
* Changes the slice orientation the camera faces. The current frame and
|
|
614
1191
|
* zoom carry over numerically to the new plane axes. Call {@link setFrame}
|
|
615
1192
|
* to reframe the view for the new plane.
|
|
1193
|
+
*
|
|
1194
|
+
* @param orientation - The slice plane for the camera to face.
|
|
616
1195
|
*/
|
|
617
1196
|
setOrientation(orientation: SliceOrientation): void;
|
|
1197
|
+
/**
|
|
1198
|
+
* Zooms the view by the given factor relative to the current zoom level.
|
|
1199
|
+
* Factors greater than `1` zoom in and factors between `0` and `1` zoom
|
|
1200
|
+
* out.
|
|
1201
|
+
*
|
|
1202
|
+
* @param factor - The magnification factor to apply.
|
|
1203
|
+
*/
|
|
618
1204
|
zoom(factor: number): void;
|
|
1205
|
+
/**
|
|
1206
|
+
* Computes the world-space rectangle currently visible in the viewport,
|
|
1207
|
+
* accounting for zoom, pan, and aspect-ratio padding.
|
|
1208
|
+
*
|
|
1209
|
+
* @returns The visible rectangle on the camera's slice plane.
|
|
1210
|
+
*/
|
|
619
1211
|
getWorldViewRect(): Box2;
|
|
1212
|
+
/** @hidden */
|
|
620
1213
|
protected updateProjectionMatrix(): void;
|
|
621
1214
|
}
|
|
622
1215
|
|
|
1216
|
+
/**
|
|
1217
|
+
* The contract between a viewport and its camera controls.
|
|
1218
|
+
*
|
|
1219
|
+
* Implement this interface to drive a camera with custom input logic and
|
|
1220
|
+
* assign it to a viewport through its `cameraControls` property. The
|
|
1221
|
+
* viewport passes pointer and wheel events to `onEvent` unless a layer
|
|
1222
|
+
* stops propagation.
|
|
1223
|
+
*
|
|
1224
|
+
* ```ts
|
|
1225
|
+
* class ClickToZoomControls implements CameraControls {
|
|
1226
|
+
* constructor(private camera: OrthographicCamera) {}
|
|
1227
|
+
*
|
|
1228
|
+
* get isMoving() {
|
|
1229
|
+
* return false;
|
|
1230
|
+
* }
|
|
1231
|
+
*
|
|
1232
|
+
* onUpdate(dt: number) {}
|
|
1233
|
+
*
|
|
1234
|
+
* onEvent(event: EventContext) {
|
|
1235
|
+
* if (event.type === "pointerdown") this.camera.zoom(2);
|
|
1236
|
+
* }
|
|
1237
|
+
* }
|
|
1238
|
+
*
|
|
1239
|
+
* viewport.cameraControls = new ClickToZoomControls(camera);
|
|
1240
|
+
* ```
|
|
1241
|
+
*
|
|
1242
|
+
* @group Controls
|
|
1243
|
+
*/
|
|
623
1244
|
interface CameraControls {
|
|
1245
|
+
/**
|
|
1246
|
+
* Whether the camera is in motion from user interaction. Layers may
|
|
1247
|
+
* read this to reduce rendering quality while the view changes.
|
|
1248
|
+
*/
|
|
624
1249
|
readonly isMoving: boolean;
|
|
1250
|
+
/**
|
|
1251
|
+
* Advances time-based motion such as damping. Called automatically by
|
|
1252
|
+
* the render loop.
|
|
1253
|
+
*
|
|
1254
|
+
* @param dt - Time since the last frame in seconds.
|
|
1255
|
+
*/
|
|
625
1256
|
onUpdate(dt: number): void;
|
|
1257
|
+
/**
|
|
1258
|
+
* Handles a pointer or wheel event. Called automatically by the owning
|
|
1259
|
+
* viewport unless a layer stops propagation.
|
|
1260
|
+
*
|
|
1261
|
+
* @param event - The event with clip and world coordinates attached.
|
|
1262
|
+
*/
|
|
626
1263
|
onEvent(event: EventContext): void;
|
|
627
1264
|
}
|
|
628
|
-
/**
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
1265
|
+
/**
|
|
1266
|
+
* Camera controls for 2D pan and zoom with an orthographic camera.
|
|
1267
|
+
*
|
|
1268
|
+
* Dragging with the left mouse button pans the view and the scroll wheel
|
|
1269
|
+
* zooms around the cursor, keeping the point under the pointer fixed.
|
|
1270
|
+
* Movement applies immediately with no inertia or damping.
|
|
1271
|
+
*
|
|
1272
|
+
* ```ts
|
|
1273
|
+
* const camera = new OrthographicCamera({
|
|
1274
|
+
* left: 0,
|
|
1275
|
+
* right: 1024,
|
|
1276
|
+
* top: 0,
|
|
1277
|
+
* bottom: 1024,
|
|
1278
|
+
* });
|
|
1279
|
+
*
|
|
1280
|
+
* const idetik = new Idetik({
|
|
1281
|
+
* canvas,
|
|
1282
|
+
* viewports: [{
|
|
1283
|
+
* camera,
|
|
1284
|
+
* layers: [imageLayer],
|
|
1285
|
+
* cameraControls: new PanZoomControls(camera),
|
|
1286
|
+
* }],
|
|
1287
|
+
* });
|
|
1288
|
+
* ```
|
|
1289
|
+
*
|
|
1290
|
+
* @group Controls
|
|
1291
|
+
*/
|
|
1292
|
+
declare class PanZoomControls implements CameraControls {
|
|
1293
|
+
private readonly camera_;
|
|
1294
|
+
private dragActive_;
|
|
1295
|
+
private dragStart_;
|
|
1296
|
+
/**
|
|
1297
|
+
* Creates pan and zoom controls for the given camera.
|
|
1298
|
+
*
|
|
1299
|
+
* @param camera - The orthographic camera to control.
|
|
1300
|
+
*/
|
|
1301
|
+
constructor(camera: OrthographicCamera);
|
|
1302
|
+
/** Whether a pan drag is in progress. */
|
|
634
1303
|
get isMoving(): boolean;
|
|
1304
|
+
/**
|
|
1305
|
+
* Handles a pointer or wheel event. Called automatically by the owning
|
|
1306
|
+
* viewport unless a layer stops propagation.
|
|
1307
|
+
*
|
|
1308
|
+
* @param event - The event with clip and world coordinates attached.
|
|
1309
|
+
*/
|
|
635
1310
|
onEvent(event: EventContext): void;
|
|
1311
|
+
/**
|
|
1312
|
+
* Does nothing. Pan and zoom apply immediately with no inertia.
|
|
1313
|
+
*
|
|
1314
|
+
* @param _delta - Time since the last frame in seconds. Unused.
|
|
1315
|
+
*/
|
|
636
1316
|
onUpdate(_delta: number): void;
|
|
637
1317
|
private onWheel;
|
|
638
1318
|
private onPointerDown;
|
|
@@ -640,162 +1320,313 @@ declare class PanZoomControls implements CameraControls {
|
|
|
640
1320
|
private onPointerEnd;
|
|
641
1321
|
}
|
|
642
1322
|
|
|
643
|
-
|
|
1323
|
+
/**
|
|
1324
|
+
* Initialization properties for constructing a viewport.
|
|
1325
|
+
*/
|
|
1326
|
+
type ViewportProps = {
|
|
1327
|
+
/** Unique id. Defaults to the element id or a generated id. */
|
|
644
1328
|
id?: string;
|
|
1329
|
+
/** Host element. Defaults to the Idetik canvas. */
|
|
645
1330
|
element?: HTMLElement;
|
|
1331
|
+
/** The camera the viewport renders with. */
|
|
646
1332
|
camera: Camera;
|
|
1333
|
+
/** Layers to render in order. */
|
|
647
1334
|
layers?: Layer[];
|
|
1335
|
+
/** Input controls driving the camera. */
|
|
648
1336
|
cameraControls?: CameraControls;
|
|
649
|
-
}
|
|
1337
|
+
};
|
|
650
1338
|
interface ResolvedViewportProps extends ViewportProps {
|
|
651
1339
|
id: string;
|
|
652
1340
|
element: HTMLElement;
|
|
653
1341
|
context: IdetikContext;
|
|
654
1342
|
}
|
|
1343
|
+
/**
|
|
1344
|
+
* A region of the canvas that renders a stack of layers through a camera.
|
|
1345
|
+
*
|
|
1346
|
+
* Every viewport draws into the shared canvas through the area of its host
|
|
1347
|
+
* element. The element defaults to the canvas itself and must be unique
|
|
1348
|
+
* across viewports.
|
|
1349
|
+
*
|
|
1350
|
+
* Viewports also route input. Pointer and wheel events on the host element
|
|
1351
|
+
* are enriched with clip and world coordinates and a picking ray, sent to
|
|
1352
|
+
* each layer in order and passed to the camera controls unless a layer stops
|
|
1353
|
+
* propagation.
|
|
1354
|
+
*
|
|
1355
|
+
* ```ts
|
|
1356
|
+
* const idetik = new Idetik({
|
|
1357
|
+
* canvas,
|
|
1358
|
+
* viewports: [{ id: 'main', camera, layers: [imageLayer] }],
|
|
1359
|
+
* });
|
|
1360
|
+
*
|
|
1361
|
+
* const viewport = idetik.getViewport('main')!;
|
|
1362
|
+
* viewport.addLayer(labelLayer);
|
|
1363
|
+
* ```
|
|
1364
|
+
*
|
|
1365
|
+
* @group Core
|
|
1366
|
+
*/
|
|
655
1367
|
declare class Viewport {
|
|
1368
|
+
/** The viewport's unique identifier. */
|
|
656
1369
|
readonly id: string;
|
|
1370
|
+
/** The host element defining the viewport's area. */
|
|
657
1371
|
readonly element: HTMLElement;
|
|
1372
|
+
/** The camera the viewport renders with. */
|
|
658
1373
|
readonly camera: Camera;
|
|
1374
|
+
/** The pointer and wheel event dispatcher for the host element. */
|
|
659
1375
|
readonly events: EventDispatcher;
|
|
1376
|
+
/** Input controls driving the camera. */
|
|
660
1377
|
cameraControls?: CameraControls;
|
|
661
1378
|
private readonly context_;
|
|
662
1379
|
private layers_;
|
|
1380
|
+
/** @hidden */
|
|
663
1381
|
constructor(props: ResolvedViewportProps);
|
|
1382
|
+
/**
|
|
1383
|
+
* The layers rendered by this viewport in order. Layers with `occludes`
|
|
1384
|
+
* set draw before non-occluding layers regardless of stack order.
|
|
1385
|
+
*/
|
|
664
1386
|
get layers(): readonly Layer[];
|
|
1387
|
+
/**
|
|
1388
|
+
* Adds a layer to the top of the stack.
|
|
1389
|
+
*
|
|
1390
|
+
* @param layer - The layer to add.
|
|
1391
|
+
*/
|
|
665
1392
|
addLayer(layer: Layer): void;
|
|
1393
|
+
/**
|
|
1394
|
+
* Removes a previously added layer.
|
|
1395
|
+
*
|
|
1396
|
+
* @param layer - The layer to remove.
|
|
1397
|
+
*/
|
|
666
1398
|
removeLayer(layer: Layer): void;
|
|
1399
|
+
/** Removes all layers from the viewport. */
|
|
667
1400
|
removeAllLayers(): void;
|
|
1401
|
+
/**
|
|
1402
|
+
* Syncs the camera's aspect ratio to the host element's size. Called
|
|
1403
|
+
* automatically when the host element resizes.
|
|
1404
|
+
*/
|
|
668
1405
|
updateSize(): void;
|
|
1406
|
+
/**
|
|
1407
|
+
* Computes the viewport's box relative to the given canvas in device pixels.
|
|
1408
|
+
*
|
|
1409
|
+
* @param canvas - The canvas to compute the box against.
|
|
1410
|
+
* @returns The viewport's box in the canvas's coordinate space.
|
|
1411
|
+
*/
|
|
669
1412
|
getBoxRelativeTo(canvas: HTMLCanvasElement): Box2;
|
|
1413
|
+
/**
|
|
1414
|
+
* The viewport's rectangle in the drawing buffer in device pixels.
|
|
1415
|
+
*/
|
|
670
1416
|
getBufferRect(): {
|
|
671
1417
|
x: number;
|
|
672
1418
|
y: number;
|
|
673
1419
|
width: number;
|
|
674
1420
|
height: number;
|
|
675
1421
|
};
|
|
1422
|
+
/**
|
|
1423
|
+
* Converts a client-space position to clip space. The `y` axis points
|
|
1424
|
+
* down, matching the renderer's mirrored projection.
|
|
1425
|
+
*
|
|
1426
|
+
* @param position - The client-space position to convert.
|
|
1427
|
+
* @param depth - The clip-space z value.
|
|
1428
|
+
*/
|
|
676
1429
|
clientToClip(position: vec2, depth?: number): vec3;
|
|
1430
|
+
/**
|
|
1431
|
+
* Converts a client-space position such as a pointer location to world
|
|
1432
|
+
* space.
|
|
1433
|
+
*
|
|
1434
|
+
* @param position - The client-space position to convert.
|
|
1435
|
+
* @param depth - The clip-space z value.
|
|
1436
|
+
*/
|
|
677
1437
|
clientToWorld(position: vec2, depth?: number): vec3;
|
|
678
1438
|
private getBox;
|
|
679
1439
|
private updateAspectRatio;
|
|
680
1440
|
}
|
|
681
1441
|
|
|
682
|
-
/**
|
|
1442
|
+
/**
|
|
1443
|
+
* An object updated once per frame after all viewports have rendered.
|
|
1444
|
+
*
|
|
1445
|
+
* Overlays drive HUD elements that live outside the canvas such as scale
|
|
1446
|
+
* bars, time indicators, or memory readouts.
|
|
1447
|
+
*
|
|
1448
|
+
* ```ts
|
|
1449
|
+
* const chunkReadout: Overlay = {
|
|
1450
|
+
* update(idetik) {
|
|
1451
|
+
* div.textContent = `${idetik.memoryStats.cpuChunkCount} chunks`;
|
|
1452
|
+
* },
|
|
1453
|
+
* };
|
|
1454
|
+
*
|
|
1455
|
+
* idetik.addOverlay(chunkReadout);
|
|
1456
|
+
* ```
|
|
1457
|
+
*/
|
|
683
1458
|
type Overlay = {
|
|
684
|
-
|
|
1459
|
+
/** Called once per rendered frame. */
|
|
1460
|
+
update: (idetik: Idetik) => void;
|
|
685
1461
|
};
|
|
686
|
-
/**
|
|
1462
|
+
/**
|
|
1463
|
+
* Initialization properties for constructing an Idetik instance.
|
|
1464
|
+
*/
|
|
687
1465
|
type IdetikProps = {
|
|
1466
|
+
/** The canvas element to render into. */
|
|
688
1467
|
canvas: HTMLCanvasElement;
|
|
1468
|
+
/** Viewport definitions to create at startup. */
|
|
689
1469
|
viewports?: ViewportProps[];
|
|
1470
|
+
/** Overlays to run each frame. */
|
|
690
1471
|
overlays?: Overlay[];
|
|
1472
|
+
/** Shows an FPS meter. Defaults to `false`. */
|
|
691
1473
|
showStats?: boolean;
|
|
1474
|
+
/** Memory budget for chunk data. Defaults to `2048`. */
|
|
692
1475
|
memoryLimitMB?: number;
|
|
1476
|
+
/** Max in-flight chunk requests. Defaults to `8`. */
|
|
693
1477
|
maxConcurrentRequests?: number;
|
|
1478
|
+
/** Max GPU texture uploads per frame. Defaults to `4`. */
|
|
694
1479
|
maxGpuUploadsPerUpdate?: number;
|
|
695
1480
|
};
|
|
696
1481
|
type IdetikContext = {
|
|
697
1482
|
chunkManager: ChunkManager;
|
|
698
1483
|
};
|
|
699
|
-
/**
|
|
1484
|
+
/**
|
|
1485
|
+
* A snapshot of the runtime's memory usage.
|
|
1486
|
+
*/
|
|
700
1487
|
type MemoryStats = {
|
|
1488
|
+
/** Bytes of chunk data held in CPU memory. */
|
|
701
1489
|
cpuChunkBytes: number;
|
|
1490
|
+
/** Number of chunks held in CPU memory. */
|
|
702
1491
|
cpuChunkCount: number;
|
|
1492
|
+
/** Bytes of texture data resident on the GPU. */
|
|
703
1493
|
gpuTextureBytes: number;
|
|
1494
|
+
/** Number of textures resident on the GPU. */
|
|
704
1495
|
gpuTextureCount: number;
|
|
1496
|
+
/** Used JS heap in bytes. */
|
|
705
1497
|
jsHeapUsedBytes?: number;
|
|
1498
|
+
/** JS heap size limit in bytes. */
|
|
706
1499
|
jsHeapLimitBytes?: number;
|
|
707
1500
|
};
|
|
708
1501
|
/**
|
|
709
|
-
* The
|
|
1502
|
+
* The entry point of an Idetik application.
|
|
1503
|
+
*
|
|
1504
|
+
* An Idetik instance owns the renderer and the chunk manager and drives the
|
|
1505
|
+
* render loop for the viewports it is given. Each viewport pairs a camera
|
|
1506
|
+
* and its controls with a stack of layers and draws into a region of the
|
|
1507
|
+
* shared canvas. Layers in all viewports stream chunks through the same
|
|
1508
|
+
* manager under a single memory budget.
|
|
1509
|
+
*
|
|
1510
|
+
* ```ts
|
|
1511
|
+
* const source = await OmeZarrImageSource.fromHttp({ url });
|
|
1512
|
+
*
|
|
1513
|
+
* const layer = new ImageLayer({
|
|
1514
|
+
* source,
|
|
1515
|
+
* sliceCoords: { t: 0, z: 0, c: [0] },
|
|
1516
|
+
* });
|
|
1517
|
+
*
|
|
1518
|
+
* const camera = new OrthographicCamera({
|
|
1519
|
+
* left: 0,
|
|
1520
|
+
* right: 1024,
|
|
1521
|
+
* top: 0,
|
|
1522
|
+
* bottom: 1024,
|
|
1523
|
+
* });
|
|
710
1524
|
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
1525
|
+
* const idetik = new Idetik({
|
|
1526
|
+
* canvas: document.querySelector('canvas')!,
|
|
1527
|
+
* viewports: [{
|
|
1528
|
+
* camera,
|
|
1529
|
+
* layers: [layer],
|
|
1530
|
+
* cameraControls: new PanZoomControls(camera),
|
|
1531
|
+
* }],
|
|
1532
|
+
* });
|
|
1533
|
+
*
|
|
1534
|
+
* idetik.start();
|
|
1535
|
+
* ```
|
|
715
1536
|
*
|
|
716
1537
|
* @see {@link Layer} for the data layers rendered within a viewport.
|
|
717
1538
|
*
|
|
718
|
-
* @group
|
|
1539
|
+
* @group Core
|
|
719
1540
|
*/
|
|
720
1541
|
declare class Idetik {
|
|
1542
|
+
/** The canvas element the renderer draws into. */
|
|
1543
|
+
readonly canvas: HTMLCanvasElement;
|
|
1544
|
+
/** The registered overlays that update once per frame in order. */
|
|
1545
|
+
readonly overlays: Overlay[];
|
|
721
1546
|
private readonly chunkManager_;
|
|
722
1547
|
private readonly context_;
|
|
723
1548
|
private readonly renderer_;
|
|
724
1549
|
private readonly viewports_;
|
|
725
|
-
readonly canvas: HTMLCanvasElement;
|
|
726
|
-
readonly overlays: Overlay[];
|
|
727
1550
|
private readonly stats_?;
|
|
728
1551
|
private readonly sizeObserver_;
|
|
729
1552
|
private lastAnimationId_?;
|
|
730
1553
|
private lastTimestamp_;
|
|
731
1554
|
/**
|
|
732
|
-
* Creates
|
|
733
|
-
*
|
|
734
|
-
* @param params -
|
|
735
|
-
* @param params.canvas - HTMLCanvasElement to render to
|
|
736
|
-
* @param params.viewports - Optional array of viewport configurations.
|
|
737
|
-
* Each viewport renders with its own camera, layers, and controls.
|
|
738
|
-
* The `element` property is optional and defaults to the canvas if not provided.
|
|
739
|
-
* Elements must be unique across viewports.
|
|
740
|
-
* The `id` property is optional but useful for referencing specific viewports later.
|
|
741
|
-
* @param params.overlays - Optional array of overlay objects that update each frame (e.g., for HUD elements)
|
|
742
|
-
* @param params.showStats - Optional flag to display performance statistics
|
|
743
|
-
*
|
|
744
|
-
* @example
|
|
745
|
-
* // Single viewport (element defaults to canvas)
|
|
746
|
-
* const camera = new OrthographicCamera({ left: 0, right: 1024, top: 0, bottom: 1024 });
|
|
747
|
-
* const idetik = new Idetik({
|
|
748
|
-
* canvas: document.querySelector('canvas')!,
|
|
749
|
-
* viewports: [{
|
|
750
|
-
* camera: camera,
|
|
751
|
-
* layers: [imageLayer],
|
|
752
|
-
* cameraControls: new PanZoomControls(camera)
|
|
753
|
-
* }]
|
|
754
|
-
* });
|
|
755
|
-
*
|
|
756
|
-
* @example
|
|
757
|
-
* // Multiple viewports - one defaults to canvas, others use separate elements
|
|
758
|
-
* const idetik = new Idetik({
|
|
759
|
-
* canvas: document.querySelector('canvas')!,
|
|
760
|
-
* viewports: [
|
|
761
|
-
* {
|
|
762
|
-
* id: 'main',
|
|
763
|
-
* // element omitted - defaults to canvas
|
|
764
|
-
* camera: camera1,
|
|
765
|
-
* layers: [layer1]
|
|
766
|
-
* },
|
|
767
|
-
* {
|
|
768
|
-
* id: 'minimap',
|
|
769
|
-
* element: document.querySelector('#minimap')!,
|
|
770
|
-
* camera: camera2,
|
|
771
|
-
* layers: [layer2]
|
|
772
|
-
* }
|
|
773
|
-
* ]
|
|
774
|
-
* });
|
|
775
|
-
*
|
|
776
|
-
* @throws {Error} If viewports have duplicate IDs or shared elements
|
|
1555
|
+
* Creates an Idetik runtime for the given canvas.
|
|
1556
|
+
*
|
|
1557
|
+
* @param params - Initialization properties.
|
|
777
1558
|
*/
|
|
778
1559
|
constructor(params: IdetikProps);
|
|
1560
|
+
/** Counts of queued and in-flight chunk requests. */
|
|
779
1561
|
get chunkQueueStats(): QueueStats;
|
|
1562
|
+
/** A snapshot of current CPU/GPU/JS heap memory usage. */
|
|
780
1563
|
get memoryStats(): MemoryStats;
|
|
1564
|
+
/** The number of objects drawn in the last rendered frame. */
|
|
781
1565
|
get renderedObjects(): number;
|
|
1566
|
+
/** The width of the rendering surface in pixels. */
|
|
782
1567
|
get width(): number;
|
|
1568
|
+
/** The height of the rendering surface in pixels. */
|
|
783
1569
|
get height(): number;
|
|
1570
|
+
/** The viewports in render order. */
|
|
784
1571
|
get viewports(): readonly Viewport[];
|
|
1572
|
+
/** Whether the render loop is running. */
|
|
785
1573
|
get running(): boolean;
|
|
1574
|
+
/**
|
|
1575
|
+
* Finds a viewport by its id.
|
|
1576
|
+
*
|
|
1577
|
+
* @param id - The id given in the viewport's definition.
|
|
1578
|
+
* @returns The matching viewport or `undefined` if none matches.
|
|
1579
|
+
*/
|
|
786
1580
|
getViewport(id: string): Viewport | undefined;
|
|
1581
|
+
/**
|
|
1582
|
+
* Adds a viewport at runtime.
|
|
1583
|
+
*
|
|
1584
|
+
* @param props - The viewport definition. The `element` defaults to the
|
|
1585
|
+
* canvas and must be unique across viewports.
|
|
1586
|
+
* @returns The created viewport.
|
|
1587
|
+
*/
|
|
787
1588
|
addViewport(props: ViewportProps): Viewport;
|
|
1589
|
+
/**
|
|
1590
|
+
* Removes a previously added viewport.
|
|
1591
|
+
*
|
|
1592
|
+
* @param viewport - The viewport to remove.
|
|
1593
|
+
* @returns `true` if the viewport was found and removed.
|
|
1594
|
+
*/
|
|
788
1595
|
removeViewport(viewport: Viewport): boolean;
|
|
1596
|
+
/**
|
|
1597
|
+
* Registers an overlay that updates once per frame.
|
|
1598
|
+
*
|
|
1599
|
+
* @param overlay - The overlay to add.
|
|
1600
|
+
*/
|
|
789
1601
|
addOverlay(overlay: Overlay): void;
|
|
1602
|
+
/**
|
|
1603
|
+
* Removes a previously added overlay.
|
|
1604
|
+
*
|
|
1605
|
+
* @param overlay - The overlay to remove.
|
|
1606
|
+
* @returns `true` if the overlay was found and removed.
|
|
1607
|
+
*/
|
|
790
1608
|
removeOverlay(overlay: Overlay): boolean;
|
|
1609
|
+
/**
|
|
1610
|
+
* Sets the memory budget for chunk data at runtime.
|
|
1611
|
+
*
|
|
1612
|
+
* @param memoryLimitMB - The new budget in megabytes.
|
|
1613
|
+
*/
|
|
791
1614
|
setMemoryLimitMB(memoryLimitMB: number): void;
|
|
1615
|
+
/**
|
|
1616
|
+
* Starts the render loop and connects input handlers.
|
|
1617
|
+
*
|
|
1618
|
+
* @returns The instance, for chaining.
|
|
1619
|
+
*/
|
|
792
1620
|
start(): this;
|
|
793
1621
|
private animate;
|
|
1622
|
+
/**
|
|
1623
|
+
* Stops the render loop and disconnects input handlers.
|
|
1624
|
+
*/
|
|
794
1625
|
stop(): void;
|
|
795
1626
|
}
|
|
796
1627
|
|
|
797
1628
|
/**The zarr.json attributes key*/
|
|
798
|
-
declare const Image
|
|
1629
|
+
declare const Image: z.ZodObject<{
|
|
799
1630
|
/**The versioned OME-Zarr Metadata namespace*/
|
|
800
1631
|
ome: z.ZodObject<{
|
|
801
1632
|
/**The multiscale datasets for this image*/
|
|
@@ -1062,7 +1893,7 @@ declare const Image$1: z.ZodObject<{
|
|
|
1062
1893
|
} | undefined;
|
|
1063
1894
|
};
|
|
1064
1895
|
}>;
|
|
1065
|
-
type Image
|
|
1896
|
+
type Image = z.infer<typeof Image>;
|
|
1066
1897
|
|
|
1067
1898
|
type Version$1 = "v2" | "v3";
|
|
1068
1899
|
type ZarrArrayParams = {
|
|
@@ -1078,7 +1909,7 @@ type ZarrArrayParams = {
|
|
|
1078
1909
|
});
|
|
1079
1910
|
|
|
1080
1911
|
type OmeZarrImageLoaderProps = {
|
|
1081
|
-
metadata: Image
|
|
1912
|
+
metadata: Image["ome"]["multiscales"][number];
|
|
1082
1913
|
arrays: zarr.Array<zarr.DataType, zarr.Readable>[];
|
|
1083
1914
|
arrayParams: ZarrArrayParams[];
|
|
1084
1915
|
};
|
|
@@ -1398,74 +2229,159 @@ type Version = (typeof versions)[number];
|
|
|
1398
2229
|
type AdaptedOme<T> = T & {
|
|
1399
2230
|
originalVersion: Version;
|
|
1400
2231
|
};
|
|
1401
|
-
/** @
|
|
2232
|
+
/** @hidden */
|
|
1402
2233
|
declare function loadOmeZarrPlate(url: string, version?: Version): Promise<AdaptedOme<Plate["ome"]>>;
|
|
1403
|
-
/** @
|
|
2234
|
+
/** @hidden */
|
|
1404
2235
|
declare function loadOmeZarrWell(url: string, path: string, version?: Version): Promise<AdaptedOme<Well["ome"]>>;
|
|
1405
|
-
type OmeroMetadata = NonNullable<Image
|
|
2236
|
+
type OmeroMetadata = NonNullable<Image["ome"]["omero"]>;
|
|
1406
2237
|
type OmeroChannel = OmeroMetadata["channels"][number];
|
|
1407
|
-
/** @
|
|
2238
|
+
/** @hidden */
|
|
1408
2239
|
declare function loadOmeroChannels(source: OmeZarrImageSource): Promise<OmeroChannel[]>;
|
|
1409
|
-
/** @
|
|
2240
|
+
/** @hidden */
|
|
1410
2241
|
declare function loadOmeroDefaults(source: OmeZarrImageSource): Promise<OmeroMetadata["rdefs"]>;
|
|
1411
2242
|
|
|
2243
|
+
/**
|
|
2244
|
+
* Input to {@link OmeZarrImageSource.fromHttp}.
|
|
2245
|
+
*/
|
|
1412
2246
|
type HttpOmeZarrImageSourceProps = {
|
|
2247
|
+
/** URL of the OME-Zarr root group. */
|
|
1413
2248
|
url: string;
|
|
2249
|
+
/** OME-Zarr version. Detected from metadata when omitted. */
|
|
1414
2250
|
version?: Version;
|
|
1415
2251
|
};
|
|
2252
|
+
/**
|
|
2253
|
+
* Input to {@link OmeZarrImageSource.fromFileSystem}.
|
|
2254
|
+
*/
|
|
1416
2255
|
type FileSystemOmeZarrImageSourceProps = {
|
|
2256
|
+
/** Directory handle with read permission. */
|
|
1417
2257
|
directory: FileSystemDirectoryHandle;
|
|
2258
|
+
/** OME-Zarr version. Detected from metadata when omitted. */
|
|
1418
2259
|
version?: Version;
|
|
2260
|
+
/** Image path within the directory. Defaults to the root. */
|
|
1419
2261
|
path?: `/${string}`;
|
|
1420
2262
|
};
|
|
1421
2263
|
/**
|
|
1422
|
-
*
|
|
2264
|
+
* A multiscale image opened from an OME-Zarr store.
|
|
2265
|
+
*
|
|
2266
|
+
* Instances are created with {@link fromHttp} or {@link fromFileSystem}
|
|
2267
|
+
* rather than the constructor. Both factories read the store's metadata up
|
|
2268
|
+
* front so the returned source already knows its axes, resolution levels,
|
|
2269
|
+
* and channel count. OME-Zarr versions `0.4` and `0.5` are supported and
|
|
2270
|
+
* the version is detected from metadata when not given.
|
|
2271
|
+
*
|
|
2272
|
+
* A source is handed to a layer which streams chunks from it on demand.
|
|
2273
|
+
*
|
|
2274
|
+
* ```ts
|
|
2275
|
+
* const source = await OmeZarrImageSource.fromHttp({
|
|
2276
|
+
* url: "https://example.com/image.ome.zarr",
|
|
2277
|
+
* });
|
|
2278
|
+
*
|
|
2279
|
+
* const layer = new ImageLayer({
|
|
2280
|
+
* source,
|
|
2281
|
+
* sliceCoords: { t: 0, z: 0, c: [0] },
|
|
2282
|
+
* });
|
|
2283
|
+
* ```
|
|
1423
2284
|
*
|
|
1424
2285
|
* @group Data Loading
|
|
1425
2286
|
*/
|
|
1426
2287
|
declare class OmeZarrImageSource {
|
|
2288
|
+
/** The zarr store location the image was opened from. */
|
|
1427
2289
|
readonly location: Location<Readable>;
|
|
2290
|
+
/** The OME-Zarr version passed at creation if any. */
|
|
1428
2291
|
readonly version?: Version;
|
|
1429
2292
|
private readonly loader_;
|
|
1430
2293
|
private constructor();
|
|
1431
2294
|
private static openLoader;
|
|
2295
|
+
/**
|
|
2296
|
+
* Returns per-axis dimension metadata for the image.
|
|
2297
|
+
*
|
|
2298
|
+
* Each axis entry lists one record per level of detail with its size,
|
|
2299
|
+
* chunk size, scale, and translation. Use these to convert between
|
|
2300
|
+
* array indices and world coordinates, pick slice coordinates, and
|
|
2301
|
+
* frame cameras around the image extent.
|
|
2302
|
+
*/
|
|
1432
2303
|
getDimensions(): SourceDimensionMap;
|
|
2304
|
+
/**
|
|
2305
|
+
* Returns the number of channels in the image.
|
|
2306
|
+
*/
|
|
1433
2307
|
getChannelCount(): number;
|
|
2308
|
+
/** The chunk loader that streams this image's data. */
|
|
1434
2309
|
get loader(): OmeZarrImageLoader;
|
|
1435
2310
|
/**
|
|
1436
|
-
*
|
|
2311
|
+
* Opens an OME-Zarr image over HTTP(S).
|
|
1437
2312
|
*
|
|
1438
|
-
* @param props
|
|
1439
|
-
* @param props.version OME-Zarr version
|
|
2313
|
+
* @param props - The store url and optional version.
|
|
1440
2314
|
*/
|
|
1441
2315
|
static fromHttp(props: HttpOmeZarrImageSourceProps): Promise<OmeZarrImageSource>;
|
|
1442
2316
|
/**
|
|
1443
|
-
*
|
|
2317
|
+
* Opens an OME-Zarr image from a local directory.
|
|
2318
|
+
*
|
|
2319
|
+
* Uses the File System Access API so it only works in Chromium-based
|
|
2320
|
+
* browsers. Pass the handle returned by `window.showDirectoryPicker()`.
|
|
2321
|
+
* The optional path lets an application ask once for root permission
|
|
2322
|
+
* and open many images.
|
|
1444
2323
|
*
|
|
1445
|
-
* @param
|
|
1446
|
-
* permission to access a directory (only works in Chrome/Edge)
|
|
1447
|
-
* @param version OME-Zarr version
|
|
1448
|
-
* @param path path to image, beginning with "/". This argument allows the application to only
|
|
1449
|
-
* ask the user once for permission to the root directory
|
|
2324
|
+
* @param props - The directory handle, optional version, and path.
|
|
1450
2325
|
*/
|
|
1451
2326
|
static fromFileSystem(props: FileSystemOmeZarrImageSourceProps): Promise<OmeZarrImageSource>;
|
|
1452
2327
|
}
|
|
1453
2328
|
|
|
1454
|
-
/**
|
|
2329
|
+
/**
|
|
2330
|
+
* The result of picking a value from a layer with a click.
|
|
2331
|
+
*/
|
|
2332
|
+
type PointPickingResult = {
|
|
2333
|
+
/** The picked position in world units. */
|
|
2334
|
+
world: vec3;
|
|
2335
|
+
/** The data value sampled at the position. */
|
|
2336
|
+
value: number;
|
|
2337
|
+
};
|
|
2338
|
+
|
|
2339
|
+
/**
|
|
2340
|
+
* Initialization properties for constructing an axes layer.
|
|
2341
|
+
*/
|
|
2342
|
+
type AxesLayerProps = {
|
|
2343
|
+
/** Axis length in world units. */
|
|
2344
|
+
length: number;
|
|
2345
|
+
/** Line width in pixels. */
|
|
2346
|
+
width: number;
|
|
2347
|
+
};
|
|
2348
|
+
/**
|
|
2349
|
+
* A layer that draws the world coordinate axes as colored lines.
|
|
2350
|
+
*
|
|
2351
|
+
* Three lines start at the world origin: `x` in red, `y` in green, and
|
|
2352
|
+
* `z` in blue, each with the given length and width. The layer is static
|
|
2353
|
+
* and ready as soon as it is constructed.
|
|
2354
|
+
*
|
|
2355
|
+
* ```ts
|
|
2356
|
+
* viewport.addLayer(new AxesLayer({ length: 100, width: 2 }));
|
|
2357
|
+
* ```
|
|
2358
|
+
*
|
|
2359
|
+
* @group Layers
|
|
2360
|
+
*/
|
|
1455
2361
|
declare class AxesLayer extends Layer {
|
|
2362
|
+
/** Identifies the layer type as `AxesLayer`. */
|
|
1456
2363
|
readonly type = "AxesLayer";
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
2364
|
+
/**
|
|
2365
|
+
* Creates an axes layer with the given dimensions.
|
|
2366
|
+
*
|
|
2367
|
+
* @param props - Initialization properties.
|
|
2368
|
+
*/
|
|
2369
|
+
constructor(props: AxesLayerProps);
|
|
2370
|
+
/** Performs no per-frame work. The axes are built at construction. */
|
|
1461
2371
|
update(): void;
|
|
1462
2372
|
}
|
|
1463
2373
|
|
|
1464
|
-
/**
|
|
2374
|
+
/**
|
|
2375
|
+
* Appearance settings for a single image channel.
|
|
2376
|
+
*/
|
|
1465
2377
|
type ChannelProps = {
|
|
2378
|
+
/** Whether the channel is drawn. Defaults to `true`. */
|
|
1466
2379
|
visible?: boolean;
|
|
2380
|
+
/** The channel's tint color. Defaults to white. */
|
|
1467
2381
|
color?: ColorLike;
|
|
2382
|
+
/** Intensity range shown. Defaults to the data range. */
|
|
1468
2383
|
contrastLimits?: [number, number];
|
|
2384
|
+
/** Channel opacity in `[0, 1]`. Defaults to `1`. */
|
|
1469
2385
|
opacity?: number;
|
|
1470
2386
|
};
|
|
1471
2387
|
/** Layer that exposes channel controls. */
|
|
@@ -1477,35 +2393,61 @@ interface ChannelsEnabled {
|
|
|
1477
2393
|
removeChannelChangeCallback(callback: () => void): void;
|
|
1478
2394
|
}
|
|
1479
2395
|
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
/** @inline */
|
|
1486
|
-
type ImageLayerProps = LayerProps & {
|
|
2396
|
+
/**
|
|
2397
|
+
* Initialization properties for constructing an image layer.
|
|
2398
|
+
*/
|
|
2399
|
+
type ImageLayerProps = {
|
|
2400
|
+
/** The chunked image source to stream from. */
|
|
1487
2401
|
source: ChunkSource;
|
|
2402
|
+
/** The slice to display in world units. */
|
|
1488
2403
|
sliceCoords: SliceCoordinates;
|
|
2404
|
+
/** Streaming policy. Defaults to the exploration policy. */
|
|
1489
2405
|
policy?: ImageSourcePolicy;
|
|
2406
|
+
/** Slice plane orientation. Defaults to `"XY"`. */
|
|
1490
2407
|
orientation?: SliceOrientation;
|
|
2408
|
+
/** Per-channel appearance. Length must match the source. */
|
|
1491
2409
|
channelProps?: ChannelProps[];
|
|
2410
|
+
/** Called with the picked value when the layer is clicked. */
|
|
1492
2411
|
onPickValue?: (info: PointPickingResult) => void;
|
|
2412
|
+
/** Layer opacity in `[0, 1]`. Defaults to `1`. */
|
|
2413
|
+
opacity?: number;
|
|
2414
|
+
/** How the layer blends. Defaults to `"additive"`. */
|
|
2415
|
+
blendMode?: BlendMode;
|
|
2416
|
+
/** Hides content behind. Defaults to `true`. */
|
|
2417
|
+
occludes?: boolean;
|
|
1493
2418
|
};
|
|
1494
2419
|
/**
|
|
1495
|
-
* A layer that renders a 2D slice of a chunked
|
|
2420
|
+
* A layer that renders a 2D slice of a chunked multi-channel image source.
|
|
2421
|
+
*
|
|
2422
|
+
* Image layer streams chunks from a source such as
|
|
2423
|
+
* {@link OmeZarrImageSource} according to its streaming policy, which
|
|
2424
|
+
* decides which resolution levels and chunks to load for the current view.
|
|
2425
|
+
* Per-channel appearance is controlled with {@link ChannelProps} and the
|
|
2426
|
+
* visible slice is selected with {@link SliceCoordinates}. The layer holds
|
|
2427
|
+
* `sliceCoords` by reference, so mutating the object it was constructed
|
|
2428
|
+
* with moves through the data.
|
|
2429
|
+
*
|
|
2430
|
+
* ```ts
|
|
2431
|
+
* const source = await OmeZarrImageSource.fromHttp({ url });
|
|
1496
2432
|
*
|
|
1497
|
-
*
|
|
1498
|
-
*
|
|
1499
|
-
*
|
|
1500
|
-
*
|
|
1501
|
-
* color,
|
|
1502
|
-
*
|
|
2433
|
+
* const layer = new ImageLayer({
|
|
2434
|
+
* source,
|
|
2435
|
+
* sliceCoords: { t: 0, z: 0, c: [0, 1] },
|
|
2436
|
+
* channelProps: [
|
|
2437
|
+
* { color: Color.GREEN, contrastLimits: [0, 1024] },
|
|
2438
|
+
* { color: Color.MAGENTA, contrastLimits: [0, 1024] },
|
|
2439
|
+
* ],
|
|
2440
|
+
* });
|
|
2441
|
+
*
|
|
2442
|
+
* viewport.addLayer(layer);
|
|
2443
|
+
* ```
|
|
1503
2444
|
*
|
|
1504
2445
|
* @see {@link VolumeLayer} for 3D volume rendering of the same data.
|
|
1505
2446
|
*
|
|
1506
2447
|
* @group Layers
|
|
1507
2448
|
*/
|
|
1508
2449
|
declare class ImageLayer extends Layer implements ChannelsEnabled {
|
|
2450
|
+
/** Identifies the layer type as `ImageLayer`. */
|
|
1509
2451
|
readonly type = "ImageLayer";
|
|
1510
2452
|
private readonly source_;
|
|
1511
2453
|
private readonly sliceCoords_;
|
|
@@ -1528,26 +2470,61 @@ declare class ImageLayer extends Layer implements ChannelsEnabled {
|
|
|
1528
2470
|
private lastPresentationTimeStamp_?;
|
|
1529
2471
|
private lastPresentationTimeCoord_?;
|
|
1530
2472
|
private readonly wireframeColors_;
|
|
2473
|
+
/**
|
|
2474
|
+
* Creates an image layer for the given source and slice.
|
|
2475
|
+
*
|
|
2476
|
+
* @param props - Initialization properties.
|
|
2477
|
+
*/
|
|
1531
2478
|
constructor({ source, sliceCoords, policy, orientation, channelProps, onPickValue, ...layerOptions }: ImageLayerProps);
|
|
2479
|
+
/** @hidden */
|
|
1532
2480
|
protected attach(context: IdetikContext): void;
|
|
2481
|
+
/** @hidden */
|
|
1533
2482
|
protected detach(_context: IdetikContext): void;
|
|
2483
|
+
/**
|
|
2484
|
+
* Streams chunks for the current view and refreshes the visible slice.
|
|
2485
|
+
*
|
|
2486
|
+
* @param viewport - The viewport being rendered.
|
|
2487
|
+
*/
|
|
1534
2488
|
update(viewport?: Viewport): void;
|
|
2489
|
+
/** The slice plane the layer displays. */
|
|
1535
2490
|
get orientation(): SliceOrientation;
|
|
1536
2491
|
/**
|
|
1537
|
-
* Changes the slice orientation at runtime. Visible renderables are
|
|
1538
|
-
* for the new plane
|
|
2492
|
+
* Changes the slice orientation at runtime. Visible renderables are
|
|
2493
|
+
* rebuilt for the new plane and chunks already resident in the shared
|
|
2494
|
+
* cache are reused.
|
|
2495
|
+
*
|
|
2496
|
+
* @param orientation - The new slice plane.
|
|
1539
2497
|
*/
|
|
1540
2498
|
setOrientation(orientation: SliceOrientation): void;
|
|
1541
2499
|
private updateChunks;
|
|
1542
2500
|
private rebuildRenderGroups;
|
|
2501
|
+
/** The `t` coordinate of the most recently presented slice. */
|
|
1543
2502
|
get lastPresentationTimeCoord(): number | undefined;
|
|
1544
2503
|
private isPresentationStale;
|
|
2504
|
+
/**
|
|
2505
|
+
* Handles click picking for `onPickValue`. Called automatically for
|
|
2506
|
+
* each pointer event.
|
|
2507
|
+
*
|
|
2508
|
+
* @param event - The event with clip and world coordinates attached.
|
|
2509
|
+
*/
|
|
1545
2510
|
onEvent(event: EventContext): void;
|
|
1546
2511
|
private pickAtRay;
|
|
2512
|
+
/** The layer's chunk store view for diagnostic overlays. */
|
|
1547
2513
|
get chunkStoreView(): ChunkStoreView | undefined;
|
|
2514
|
+
/**
|
|
2515
|
+
* The slice coordinates the layer displays. This is the object passed
|
|
2516
|
+
* at construction and may be mutated to move through the data.
|
|
2517
|
+
*/
|
|
1548
2518
|
get sliceCoords(): SliceCoordinates;
|
|
2519
|
+
/** The chunked image source the layer streams from. */
|
|
1549
2520
|
get source(): ChunkSource;
|
|
2521
|
+
/**
|
|
2522
|
+
* The streaming policy in effect. Assign a new policy to reschedule
|
|
2523
|
+
* loading at runtime, for example when switching between exploration
|
|
2524
|
+
* and playback.
|
|
2525
|
+
*/
|
|
1550
2526
|
get imageSourcePolicy(): Readonly<ImageSourcePolicy>;
|
|
2527
|
+
/** @param newPolicy - The policy to apply. */
|
|
1551
2528
|
set imageSourcePolicy(newPolicy: ImageSourcePolicy);
|
|
1552
2529
|
private getImageForChunk;
|
|
1553
2530
|
private getChannelPropsForChunk;
|
|
@@ -1555,27 +2532,101 @@ declare class ImageLayer extends Layer implements ChannelsEnabled {
|
|
|
1555
2532
|
private updateSlicePosition;
|
|
1556
2533
|
private sliceIndexForChunk;
|
|
1557
2534
|
private updateImageChunk;
|
|
2535
|
+
/**
|
|
2536
|
+
* Reads the data value at a world position from the resident chunks.
|
|
2537
|
+
* Prefers the current level of detail and falls back to other resident
|
|
2538
|
+
* levels.
|
|
2539
|
+
*
|
|
2540
|
+
* @param world - The world-space position to sample.
|
|
2541
|
+
* @returns The sampled value or `null` if no resident chunk covers it.
|
|
2542
|
+
*/
|
|
1558
2543
|
getValueAtWorld(world: vec3): Promise<number | null>;
|
|
1559
2544
|
private readValueFromChunk;
|
|
2545
|
+
/** Whether chunk wireframes are drawn colored by level of detail. */
|
|
1560
2546
|
get debugMode(): boolean;
|
|
2547
|
+
/** @param debug - Whether to draw chunk wireframes. */
|
|
1561
2548
|
set debugMode(debug: boolean);
|
|
2549
|
+
/** The current per-channel appearance settings. */
|
|
1562
2550
|
get channelProps(): ChannelProps[] | undefined;
|
|
2551
|
+
/**
|
|
2552
|
+
* Applies new per-channel appearance settings to all visible chunks
|
|
2553
|
+
* and notifies channel change callbacks.
|
|
2554
|
+
*
|
|
2555
|
+
* @param channelProps - One entry per source channel.
|
|
2556
|
+
*/
|
|
1563
2557
|
setChannelProps(channelProps: ChannelProps[]): void;
|
|
2558
|
+
/** Restores the channel settings passed at construction. */
|
|
1564
2559
|
resetChannelProps(): void;
|
|
2560
|
+
/**
|
|
2561
|
+
* Registers a callback invoked after every channel settings change.
|
|
2562
|
+
*
|
|
2563
|
+
* @param callback - The callback to add.
|
|
2564
|
+
*/
|
|
1565
2565
|
addChannelChangeCallback(callback: () => void): void;
|
|
2566
|
+
/**
|
|
2567
|
+
* Removes a previously registered channel change callback.
|
|
2568
|
+
*
|
|
2569
|
+
* @param callback - The callback to remove.
|
|
2570
|
+
*/
|
|
1566
2571
|
removeChannelChangeCallback(callback: () => void): void;
|
|
1567
2572
|
private releaseAndRemoveChunks;
|
|
1568
2573
|
}
|
|
1569
2574
|
|
|
2575
|
+
/**
|
|
2576
|
+
* Initialization properties for constructing a volume layer.
|
|
2577
|
+
*/
|
|
1570
2578
|
type VolumeLayerProps = {
|
|
2579
|
+
/** The chunked image source to stream from. */
|
|
1571
2580
|
source: ChunkSource;
|
|
2581
|
+
/** Selects `t` and `c`. Spatial axes are ignored. */
|
|
1572
2582
|
sliceCoords: SliceCoordinates;
|
|
2583
|
+
/** Streaming policy. Defaults to the exploration policy. */
|
|
1573
2584
|
policy?: ImageSourcePolicy;
|
|
2585
|
+
/** Per-channel appearance. Length must match the source. */
|
|
1574
2586
|
channelProps?: ChannelProps[];
|
|
1575
2587
|
};
|
|
1576
|
-
/**
|
|
2588
|
+
/**
|
|
2589
|
+
* A layer that renders a chunked multi-channel image source as a 3D
|
|
2590
|
+
* volume.
|
|
2591
|
+
*
|
|
2592
|
+
* Volume layer ray marches the loaded chunks with premultiplied blending
|
|
2593
|
+
* and composites all visible channels in a single pass. The volume renders
|
|
2594
|
+
* at a single level of detail taken from the policy's `lod.min`, so pin
|
|
2595
|
+
* one with the policy when constructing the layer. While the camera moves
|
|
2596
|
+
* the ray march step size is doubled to keep interaction responsive.
|
|
2597
|
+
*
|
|
2598
|
+
* ```ts
|
|
2599
|
+
* const source = await OmeZarrImageSource.fromHttp({ url });
|
|
2600
|
+
*
|
|
2601
|
+
* const layer = new VolumeLayer({
|
|
2602
|
+
* source,
|
|
2603
|
+
* sliceCoords: { t: 0, c: undefined },
|
|
2604
|
+
* policy: createExplorationPolicy({ lod: { min: 2, max: 2 } }),
|
|
2605
|
+
* channelProps: [
|
|
2606
|
+
* { color: "#00ffff", contrastLimits: [300, 1500] },
|
|
2607
|
+
* { color: "#ff00ff", contrastLimits: [75, 500] },
|
|
2608
|
+
* ],
|
|
2609
|
+
* });
|
|
2610
|
+
*
|
|
2611
|
+
* viewport.addLayer(layer);
|
|
2612
|
+
* ```
|
|
2613
|
+
*
|
|
2614
|
+
* @see {@link ImageLayer} for 2D slicing of the same data.
|
|
2615
|
+
*
|
|
2616
|
+
* @group Layers
|
|
2617
|
+
*/
|
|
1577
2618
|
declare class VolumeLayer extends Layer implements ChannelsEnabled {
|
|
2619
|
+
/** Identifies the layer type as `VolumeLayer`. */
|
|
1578
2620
|
readonly type = "VolumeLayer";
|
|
2621
|
+
/** Highlights rays of zero length for debugging. Defaults to `false`. */
|
|
2622
|
+
debugShowDegenerateRays: boolean;
|
|
2623
|
+
/** Ray march step size relative to voxel size. Defaults to `1`. */
|
|
2624
|
+
relativeStepSize: number;
|
|
2625
|
+
/** Scales sample opacity during compositing. Defaults to `1`. */
|
|
2626
|
+
opacityMultiplier: number;
|
|
2627
|
+
/** Alpha where a ray stops early. Defaults to `0.99`. */
|
|
2628
|
+
earlyTerminationAlpha: number;
|
|
2629
|
+
/** Volume ray marching reads scene depth to composite with occluding layers. */
|
|
1579
2630
|
protected requiresSceneDepth_: boolean;
|
|
1580
2631
|
private readonly source_;
|
|
1581
2632
|
private readonly sliceCoords_;
|
|
@@ -1591,53 +2642,139 @@ declare class VolumeLayer extends Layer implements ChannelsEnabled {
|
|
|
1591
2642
|
private lastNumRenderedChannelChunks_;
|
|
1592
2643
|
private interactiveStepSizeScale_;
|
|
1593
2644
|
private debugShowWireframes_;
|
|
1594
|
-
|
|
1595
|
-
relativeStepSize: number;
|
|
1596
|
-
opacityMultiplier: number;
|
|
1597
|
-
earlyTerminationAlpha: number;
|
|
2645
|
+
/** Whether chunk bounding wireframes are drawn for debugging. */
|
|
1598
2646
|
get debugShowWireframes(): boolean;
|
|
2647
|
+
/** @param value - Whether to draw chunk wireframes. */
|
|
1599
2648
|
set debugShowWireframes(value: boolean);
|
|
2649
|
+
/**
|
|
2650
|
+
* Sets the streaming policy at runtime and reschedules loading. The
|
|
2651
|
+
* volume renders the level of detail given by the policy's `lod.min`.
|
|
2652
|
+
*
|
|
2653
|
+
* @param newPolicy - The policy to apply.
|
|
2654
|
+
*/
|
|
1600
2655
|
set imageSourcePolicy(newPolicy: ImageSourcePolicy);
|
|
2656
|
+
/**
|
|
2657
|
+
* Applies new per-channel appearance settings to all visible volumes
|
|
2658
|
+
* and notifies channel change callbacks.
|
|
2659
|
+
*
|
|
2660
|
+
* @param channelProps - One entry per source channel.
|
|
2661
|
+
*/
|
|
1601
2662
|
setChannelProps(channelProps: ChannelProps[]): void;
|
|
2663
|
+
/** The current per-channel appearance settings. */
|
|
1602
2664
|
get channelProps(): ChannelProps[] | undefined;
|
|
2665
|
+
/** Restores the channel settings passed at construction. */
|
|
1603
2666
|
resetChannelProps(): void;
|
|
2667
|
+
/**
|
|
2668
|
+
* Registers a callback invoked after every channel settings change.
|
|
2669
|
+
*
|
|
2670
|
+
* @param callback - The callback to add.
|
|
2671
|
+
*/
|
|
1604
2672
|
addChannelChangeCallback(callback: () => void): void;
|
|
2673
|
+
/**
|
|
2674
|
+
* Removes a previously registered channel change callback.
|
|
2675
|
+
*
|
|
2676
|
+
* @param callback - The callback to remove.
|
|
2677
|
+
*/
|
|
1605
2678
|
removeChannelChangeCallback(callback: () => void): void;
|
|
2679
|
+
/**
|
|
2680
|
+
* Creates a volume layer for the given source.
|
|
2681
|
+
*
|
|
2682
|
+
* @param props - Initialization properties.
|
|
2683
|
+
*/
|
|
1606
2684
|
constructor({ source, sliceCoords, policy, channelProps }: VolumeLayerProps);
|
|
1607
2685
|
private getOrCreateVolume;
|
|
2686
|
+
/** @hidden */
|
|
1608
2687
|
protected attach(context: IdetikContext): void;
|
|
2688
|
+
/** @hidden */
|
|
1609
2689
|
protected detach(_context: IdetikContext): void;
|
|
1610
2690
|
private updateChunks;
|
|
1611
2691
|
private updateVolumeTransform;
|
|
1612
2692
|
private releaseAndRemoveVolume;
|
|
2693
|
+
/**
|
|
2694
|
+
* Streams chunks for the current view and rebuilds the volume set
|
|
2695
|
+
* sorted front to back. Called automatically once per frame.
|
|
2696
|
+
*
|
|
2697
|
+
* @param viewport - The viewport being rendered.
|
|
2698
|
+
*/
|
|
1613
2699
|
update(viewport?: Viewport): void;
|
|
1614
2700
|
private rebuildObjects;
|
|
2701
|
+
/** Returns the ray marching uniforms for this layer. */
|
|
1615
2702
|
getUniforms(): Record<string, unknown>;
|
|
1616
2703
|
}
|
|
1617
2704
|
|
|
2705
|
+
/**
|
|
2706
|
+
* Color assignments for label values.
|
|
2707
|
+
*
|
|
2708
|
+
* Values present in `lookupTable` use its color. Any other value takes a
|
|
2709
|
+
* color from `cycle` by index. Value `0` renders transparent unless the
|
|
2710
|
+
* lookup table assigns it a color.
|
|
2711
|
+
*/
|
|
1618
2712
|
type LabelColorMapProps = {
|
|
2713
|
+
/** Exact colors for specific label values. */
|
|
1619
2714
|
lookupTable?: ReadonlyMap<number, ColorLike>;
|
|
2715
|
+
/** Colors cycled by value. Defaults to 6 built-ins. */
|
|
1620
2716
|
cycle?: ReadonlyArray<ColorLike>;
|
|
1621
2717
|
};
|
|
2718
|
+
/**
|
|
2719
|
+
* A validated color map with every entry resolved to a {@link Color}.
|
|
2720
|
+
* Returned by {@link LabelLayer.colorMap}.
|
|
2721
|
+
*/
|
|
1622
2722
|
type LabelColorMap = {
|
|
2723
|
+
/** Exact colors for specific label values. */
|
|
1623
2724
|
readonly lookupTable: ReadonlyMap<number, Color>;
|
|
2725
|
+
/** Colors cycled by value. */
|
|
1624
2726
|
readonly cycle: ReadonlyArray<Color>;
|
|
1625
2727
|
};
|
|
2728
|
+
/**
|
|
2729
|
+
* Initialization properties for constructing a label image renderable.
|
|
2730
|
+
*/
|
|
1626
2731
|
type LabelImageRenderableProps = {
|
|
2732
|
+
/** Width of the label image in texels. */
|
|
1627
2733
|
width: number;
|
|
2734
|
+
/** Height of the label image in texels. */
|
|
1628
2735
|
height: number;
|
|
2736
|
+
/** Scalar integer texture of label values. */
|
|
1629
2737
|
imageData: Texture;
|
|
2738
|
+
/** Colors to apply to label values. */
|
|
1630
2739
|
colorMap: LabelColorMapProps;
|
|
2740
|
+
/** Outlines the selected value. Defaults to `false`. */
|
|
1631
2741
|
outlineSelected?: boolean;
|
|
2742
|
+
/** The selected label value. Defaults to `null`. */
|
|
1632
2743
|
selectedValue?: number | null;
|
|
1633
2744
|
};
|
|
1634
|
-
/**
|
|
2745
|
+
/**
|
|
2746
|
+
* A textured plane that draws one 2D slice of integer label data.
|
|
2747
|
+
*
|
|
2748
|
+
* Each label value is colored through a {@link LabelColorMap}. Values in
|
|
2749
|
+
* the lookup table use its color, other values take a color from the
|
|
2750
|
+
* cycle, and value `0` renders transparent unless the lookup table covers
|
|
2751
|
+
* it. The image texture must hold scalar integer data. {@link LabelLayer}
|
|
2752
|
+
* constructs and pools one instance per visible chunk, so most
|
|
2753
|
+
* applications configure labels through the layer instead.
|
|
2754
|
+
*
|
|
2755
|
+
* @group Renderables
|
|
2756
|
+
*/
|
|
1635
2757
|
declare class LabelImageRenderable extends RenderableObject {
|
|
2758
|
+
/**
|
|
2759
|
+
* A matrix mapping world space to the texture's normalized coordinate
|
|
2760
|
+
* space. Layers derive it from the chunk's offset, scale, and shape.
|
|
2761
|
+
*/
|
|
2762
|
+
worldToTexCoord: mat4;
|
|
1636
2763
|
private outlineSelected_;
|
|
1637
2764
|
private selectedValue_;
|
|
1638
|
-
|
|
2765
|
+
/**
|
|
2766
|
+
* Creates a label renderable drawing the given label texture. The
|
|
2767
|
+
* texture's data type selects the matching label shader.
|
|
2768
|
+
*
|
|
2769
|
+
* @param props - Initialization properties.
|
|
2770
|
+
*/
|
|
1639
2771
|
constructor(props: LabelImageRenderableProps);
|
|
2772
|
+
/** Identifies the renderable type as `LabelImageRenderable`. */
|
|
1640
2773
|
get type(): string;
|
|
2774
|
+
/**
|
|
2775
|
+
* Returns the sampler, color map, and selection uniforms for the label
|
|
2776
|
+
* image shaders.
|
|
2777
|
+
*/
|
|
1641
2778
|
getUniforms(): {
|
|
1642
2779
|
u_imageSampler: number;
|
|
1643
2780
|
u_colorCycleSampler: number;
|
|
@@ -1646,23 +2783,80 @@ declare class LabelImageRenderable extends RenderableObject {
|
|
|
1646
2783
|
u_selectedValue: number;
|
|
1647
2784
|
u_worldToTexCoord: mat4;
|
|
1648
2785
|
};
|
|
2786
|
+
/**
|
|
2787
|
+
* Replaces the label color map. The previous color map textures are
|
|
2788
|
+
* marked stale for GPU disposal.
|
|
2789
|
+
*
|
|
2790
|
+
* @param colorMap - The new color map.
|
|
2791
|
+
*/
|
|
1649
2792
|
setColorMap(colorMap: LabelColorMapProps): void;
|
|
2793
|
+
/**
|
|
2794
|
+
* Sets the label value drawn as selected or `null` to clear the
|
|
2795
|
+
* selection. The selected region is outlined when the renderable was
|
|
2796
|
+
* constructed with `outlineSelected`.
|
|
2797
|
+
*
|
|
2798
|
+
* @param value - The label value to select.
|
|
2799
|
+
*/
|
|
1650
2800
|
setSelectedValue(value: number | null): void;
|
|
1651
2801
|
private makeColorCycleTexture;
|
|
1652
2802
|
private makeColorLookupTableTexture;
|
|
1653
2803
|
}
|
|
1654
2804
|
|
|
1655
|
-
|
|
2805
|
+
/**
|
|
2806
|
+
* Initialization properties for constructing a label layer.
|
|
2807
|
+
*/
|
|
2808
|
+
type LabelLayerProps = {
|
|
2809
|
+
/** The single-channel label source to stream from. */
|
|
1656
2810
|
source: ChunkSource;
|
|
2811
|
+
/** The slice to display in world units. */
|
|
1657
2812
|
sliceCoords: SliceCoordinates;
|
|
2813
|
+
/** Streaming policy. Defaults to the exploration policy. */
|
|
1658
2814
|
policy?: ImageSourcePolicy;
|
|
2815
|
+
/** Slice plane orientation. Defaults to `"XY"`. */
|
|
1659
2816
|
orientation?: SliceOrientation;
|
|
2817
|
+
/** Colors for label values. Defaults to a built-in cycle. */
|
|
1660
2818
|
colorMap?: LabelColorMapProps;
|
|
2819
|
+
/** Called with the picked label when the layer is clicked. */
|
|
1661
2820
|
onPickValue?: (info: PointPickingResult) => void;
|
|
2821
|
+
/** Outlines the picked label. Defaults to `false`. */
|
|
1662
2822
|
outlineSelected?: boolean;
|
|
2823
|
+
/** Layer opacity in `[0, 1]`. Defaults to `1`. */
|
|
2824
|
+
opacity?: number;
|
|
2825
|
+
/** How the layer blends. Defaults to `"none"`. */
|
|
2826
|
+
blendMode?: BlendMode;
|
|
2827
|
+
/** Hides content behind. Inferred from `blendMode`. */
|
|
2828
|
+
occludes?: boolean;
|
|
1663
2829
|
};
|
|
1664
|
-
/**
|
|
2830
|
+
/**
|
|
2831
|
+
* A layer that renders a 2D slice of a single-channel label image.
|
|
2832
|
+
*
|
|
2833
|
+
* Label layer displays segmentation data where each pixel holds an
|
|
2834
|
+
* integer label. Labels are colored by cycling through the color map's
|
|
2835
|
+
* `cycle` with exact-value overrides in its `lookupTable`. Chunks stream
|
|
2836
|
+
* through the same policy machinery as {@link ImageLayer} and the source
|
|
2837
|
+
* must be single channel.
|
|
2838
|
+
*
|
|
2839
|
+
* Clicking the layer picks the label under the pointer. With
|
|
2840
|
+
* `outlineSelected` the picked label is outlined, and `onPickValue`
|
|
2841
|
+
* receives the world position and label value for custom handling such as
|
|
2842
|
+
* highlighting through {@link setColorMap}.
|
|
2843
|
+
*
|
|
2844
|
+
* ```ts
|
|
2845
|
+
* const labels = new LabelLayer({
|
|
2846
|
+
* source: labelSource,
|
|
2847
|
+
* sliceCoords: { z: 12, c: [0] },
|
|
2848
|
+
* opacity: 0.55,
|
|
2849
|
+
* blendMode: "normal",
|
|
2850
|
+
* onPickValue: ({ value }) => console.log(`label ${value}`),
|
|
2851
|
+
* });
|
|
2852
|
+
*
|
|
2853
|
+
* viewport.addLayer(labels);
|
|
2854
|
+
* ```
|
|
2855
|
+
*
|
|
2856
|
+
* @group Layers
|
|
2857
|
+
*/
|
|
1665
2858
|
declare class LabelLayer extends Layer {
|
|
2859
|
+
/** Identifies the layer type as `LabelLayer`. */
|
|
1666
2860
|
readonly type = "LabelLayer";
|
|
1667
2861
|
private readonly source_;
|
|
1668
2862
|
private readonly sliceCoords_;
|
|
@@ -1682,29 +2876,86 @@ declare class LabelLayer extends Layer {
|
|
|
1682
2876
|
private static readonly STALE_PRESENTATION_MS_;
|
|
1683
2877
|
private lastPresentationTimeStamp_?;
|
|
1684
2878
|
private lastPresentationTimeCoord_?;
|
|
2879
|
+
/**
|
|
2880
|
+
* Creates a label layer for the given source and slice.
|
|
2881
|
+
*
|
|
2882
|
+
* @param props - Initialization properties.
|
|
2883
|
+
*/
|
|
1685
2884
|
constructor({ source, sliceCoords, policy, orientation, colorMap, onPickValue, outlineSelected, ...layerOptions }: LabelLayerProps);
|
|
2885
|
+
/** @hidden */
|
|
1686
2886
|
protected attach(context: IdetikContext): void;
|
|
2887
|
+
/** @hidden */
|
|
1687
2888
|
protected detach(_context: IdetikContext): void;
|
|
2889
|
+
/**
|
|
2890
|
+
* Streams chunks for the current view and refreshes the visible slice.
|
|
2891
|
+
* Called automatically once per frame.
|
|
2892
|
+
*
|
|
2893
|
+
* @param viewport - The viewport being rendered.
|
|
2894
|
+
*/
|
|
1688
2895
|
update(viewport?: Viewport): void;
|
|
2896
|
+
/** The slice plane the layer displays. */
|
|
1689
2897
|
get orientation(): SliceOrientation;
|
|
1690
2898
|
/**
|
|
1691
|
-
* Changes the slice orientation at runtime. Visible renderables are
|
|
1692
|
-
* for the new plane
|
|
2899
|
+
* Changes the slice orientation at runtime. Visible renderables are
|
|
2900
|
+
* rebuilt for the new plane and chunks already resident in the shared
|
|
2901
|
+
* cache are reused.
|
|
2902
|
+
*
|
|
2903
|
+
* @param orientation - The new slice plane.
|
|
1693
2904
|
*/
|
|
1694
2905
|
setOrientation(orientation: SliceOrientation): void;
|
|
1695
2906
|
private updateChunks;
|
|
1696
2907
|
private isPresentationStale;
|
|
2908
|
+
/**
|
|
2909
|
+
* Handles click picking and selection outlining. Called automatically
|
|
2910
|
+
* for each pointer event on the owning viewport.
|
|
2911
|
+
*
|
|
2912
|
+
* @param event - The event with clip and world coordinates attached.
|
|
2913
|
+
*/
|
|
1697
2914
|
onEvent(event: EventContext): void;
|
|
1698
2915
|
private pickAtRay;
|
|
2916
|
+
/** The validated color map currently in effect. */
|
|
1699
2917
|
get colorMap(): LabelColorMap;
|
|
2918
|
+
/**
|
|
2919
|
+
* Replaces the color map and recolors all visible chunks.
|
|
2920
|
+
*
|
|
2921
|
+
* @param colorMap - Colors for label values. Omitted fields fall back
|
|
2922
|
+
* to defaults.
|
|
2923
|
+
*/
|
|
1700
2924
|
setColorMap(colorMap: LabelColorMapProps): void;
|
|
2925
|
+
/**
|
|
2926
|
+
* Sets the label value drawn as selected or `null` to clear the
|
|
2927
|
+
* selection.
|
|
2928
|
+
*
|
|
2929
|
+
* @param value - The label value to select.
|
|
2930
|
+
*/
|
|
1701
2931
|
setSelectedValue(value: number | null): void;
|
|
2932
|
+
/**
|
|
2933
|
+
* The slice coordinates the layer displays. This is the object passed
|
|
2934
|
+
* at construction and may be mutated to move through the data.
|
|
2935
|
+
*/
|
|
1702
2936
|
get sliceCoords(): SliceCoordinates;
|
|
2937
|
+
/** The chunked label source the layer streams from. */
|
|
1703
2938
|
get source(): ChunkSource;
|
|
2939
|
+
/**
|
|
2940
|
+
* The streaming policy in effect. Assign a new policy to reschedule
|
|
2941
|
+
* loading at runtime, for example when switching between exploration
|
|
2942
|
+
* and playback.
|
|
2943
|
+
*/
|
|
1704
2944
|
get imageSourcePolicy(): Readonly<ImageSourcePolicy>;
|
|
2945
|
+
/** @param newPolicy - The policy to apply. */
|
|
1705
2946
|
set imageSourcePolicy(newPolicy: ImageSourcePolicy);
|
|
2947
|
+
/** The layer's chunk store view for diagnostic overlays. */
|
|
1706
2948
|
get chunkStoreView(): ChunkStoreView | undefined;
|
|
2949
|
+
/** The `t` coordinate of the most recently presented slice. */
|
|
1707
2950
|
get lastPresentationTimeCoord(): number | undefined;
|
|
2951
|
+
/**
|
|
2952
|
+
* Reads the label value at a world position from the resident chunks.
|
|
2953
|
+
* Prefers the current level of detail and falls back to other resident
|
|
2954
|
+
* levels.
|
|
2955
|
+
*
|
|
2956
|
+
* @param world - The world-space position to sample.
|
|
2957
|
+
* @returns The label value or `null` if no resident chunk covers it.
|
|
2958
|
+
*/
|
|
1708
2959
|
getValueAtWorld(world: vec3): Promise<number | null>;
|
|
1709
2960
|
private readValueFromChunk;
|
|
1710
2961
|
private getLabelForChunk;
|
|
@@ -1715,10 +2966,17 @@ declare class LabelLayer extends Layer {
|
|
|
1715
2966
|
private releaseAndRemoveChunks;
|
|
1716
2967
|
}
|
|
1717
2968
|
|
|
2969
|
+
/**
|
|
2970
|
+
* Initialization properties for constructing an image renderable.
|
|
2971
|
+
*/
|
|
1718
2972
|
type ImageRenderableProps = {
|
|
2973
|
+
/** Width of the image in texels. */
|
|
1719
2974
|
width: number;
|
|
2975
|
+
/** Height of the image in texels. */
|
|
1720
2976
|
height: number;
|
|
2977
|
+
/** The scalar image texture to draw. */
|
|
1721
2978
|
texture: Texture;
|
|
2979
|
+
/** Channel appearance settings. Defaults to `[]`. */
|
|
1722
2980
|
channelProps?: ChannelProps[];
|
|
1723
2981
|
};
|
|
1724
2982
|
type UniformValues = {
|
|
@@ -1729,27 +2987,110 @@ type UniformValues = {
|
|
|
1729
2987
|
u_valueScale: number;
|
|
1730
2988
|
u_worldToTexCoord: mat4;
|
|
1731
2989
|
};
|
|
1732
|
-
/**
|
|
2990
|
+
/**
|
|
2991
|
+
* A textured plane that draws one 2D slice of scalar image data.
|
|
2992
|
+
*
|
|
2993
|
+
* Image renderable maps a scalar texture through a single channel's
|
|
2994
|
+
* color, contrast limits, and opacity. {@link ImageLayer} constructs and
|
|
2995
|
+
* pools one instance per visible chunk, so most applications never create
|
|
2996
|
+
* these directly.
|
|
2997
|
+
*
|
|
2998
|
+
* @group Renderables
|
|
2999
|
+
*/
|
|
1733
3000
|
declare class ImageRenderable extends RenderableObject {
|
|
1734
|
-
|
|
3001
|
+
/**
|
|
3002
|
+
* A matrix mapping world space to the texture's normalized coordinate
|
|
3003
|
+
* space. Layers derive it from the chunk's offset, scale, and shape.
|
|
3004
|
+
*/
|
|
1735
3005
|
worldToTexCoord: mat4;
|
|
3006
|
+
private channels_;
|
|
3007
|
+
/**
|
|
3008
|
+
* Creates an image renderable drawing the given texture. The texture's
|
|
3009
|
+
* data type selects the matching scalar image shader.
|
|
3010
|
+
*
|
|
3011
|
+
* @param props - Initialization properties.
|
|
3012
|
+
*/
|
|
1736
3013
|
constructor({ width, height, texture, channelProps, }: ImageRenderableProps);
|
|
3014
|
+
/** Identifies the renderable type as `ImageRenderable`. */
|
|
1737
3015
|
get type(): string;
|
|
3016
|
+
/**
|
|
3017
|
+
* Replaces the channel appearance settings and revalidates them
|
|
3018
|
+
* against the current texture. Only the first entry affects rendering.
|
|
3019
|
+
*
|
|
3020
|
+
* @param channels - The new channel settings.
|
|
3021
|
+
*/
|
|
1738
3022
|
setChannelProps(channels: ChannelProps[]): void;
|
|
3023
|
+
/**
|
|
3024
|
+
* Updates one property of the channel at the given index and
|
|
3025
|
+
* revalidates the channel against the current texture.
|
|
3026
|
+
*
|
|
3027
|
+
* @param channelIndex - The channel to update.
|
|
3028
|
+
* @param property - The property name to set.
|
|
3029
|
+
* @param value - The new value.
|
|
3030
|
+
*/
|
|
1739
3031
|
setChannelProperty<K extends keyof ChannelProps>(channelIndex: number, property: K, value: Required<ChannelProps>[K]): void;
|
|
3032
|
+
/**
|
|
3033
|
+
* Returns the sampler, contrast, color, opacity, and world-to-texture
|
|
3034
|
+
* uniforms for the scalar image shaders.
|
|
3035
|
+
*/
|
|
1740
3036
|
getUniforms(): UniformValues;
|
|
1741
3037
|
}
|
|
1742
3038
|
|
|
1743
3039
|
type Marker = "circle" | "square" | "triangle";
|
|
3040
|
+
/**
|
|
3041
|
+
* Initialization properties for a point in {@link PointsRenderable}.
|
|
3042
|
+
*/
|
|
1744
3043
|
type PointProps = {
|
|
3044
|
+
/** World-space position of the point. */
|
|
1745
3045
|
position: vec3;
|
|
3046
|
+
/** Fill color of the marker. */
|
|
1746
3047
|
color: ColorLike;
|
|
3048
|
+
/** Marker size in pixels. */
|
|
1747
3049
|
size: number;
|
|
3050
|
+
/** Marker shape. */
|
|
1748
3051
|
marker: Marker;
|
|
1749
3052
|
};
|
|
1750
|
-
/**
|
|
3053
|
+
/**
|
|
3054
|
+
* A set of point markers drawn as screen-space sprites.
|
|
3055
|
+
*
|
|
3056
|
+
* Each point has a world-space position, a color, a size in pixels, and a
|
|
3057
|
+
* marker shape. All instances share a single marker sprite atlas. The
|
|
3058
|
+
* point set is fixed at construction, so build a new instance to change
|
|
3059
|
+
* it. Construct these directly inside a custom {@link Layer}.
|
|
3060
|
+
*
|
|
3061
|
+
* ```ts
|
|
3062
|
+
* class Particles extends Layer {
|
|
3063
|
+
* public readonly type = "Particles";
|
|
3064
|
+
*
|
|
3065
|
+
* constructor(positions: vec3[]) {
|
|
3066
|
+
* super();
|
|
3067
|
+
* this.addObject(
|
|
3068
|
+
* new PointsRenderable(
|
|
3069
|
+
* positions.map((position) => ({
|
|
3070
|
+
* position,
|
|
3071
|
+
* color: Color.RED,
|
|
3072
|
+
* size: 20,
|
|
3073
|
+
* marker: "circle" as const,
|
|
3074
|
+
* }))
|
|
3075
|
+
* )
|
|
3076
|
+
* );
|
|
3077
|
+
* this.setState("ready");
|
|
3078
|
+
* }
|
|
3079
|
+
*
|
|
3080
|
+
* public update() {}
|
|
3081
|
+
* }
|
|
3082
|
+
* ```
|
|
3083
|
+
*
|
|
3084
|
+
* @group Renderables
|
|
3085
|
+
*/
|
|
1751
3086
|
declare class PointsRenderable extends RenderableObject {
|
|
3087
|
+
/**
|
|
3088
|
+
* Creates a renderable drawing one marker per entry.
|
|
3089
|
+
*
|
|
3090
|
+
* @param points - The points to draw.
|
|
3091
|
+
*/
|
|
1752
3092
|
constructor(points: PointProps[]);
|
|
3093
|
+
/** Identifies the renderable type as `PointsRenderable`. */
|
|
1753
3094
|
get type(): string;
|
|
1754
3095
|
}
|
|
1755
3096
|
|
|
@@ -1759,79 +3100,260 @@ declare class ProjectedLineGeometry extends Geometry {
|
|
|
1759
3100
|
private createIndex;
|
|
1760
3101
|
}
|
|
1761
3102
|
|
|
3103
|
+
/**
|
|
3104
|
+
* Initialization properties for constructing a projected line renderable.
|
|
3105
|
+
*/
|
|
1762
3106
|
type ProjectedLineRenderableProps = {
|
|
3107
|
+
/** The line path geometry to draw. */
|
|
1763
3108
|
geometry: ProjectedLineGeometry;
|
|
3109
|
+
/** The line color. */
|
|
1764
3110
|
color: ColorLike;
|
|
3111
|
+
/** Line width in pixels. */
|
|
1765
3112
|
width: number;
|
|
1766
3113
|
};
|
|
1767
|
-
/**
|
|
3114
|
+
/**
|
|
3115
|
+
* A polyline drawn with a constant screen-space width.
|
|
3116
|
+
*
|
|
3117
|
+
* The line is extruded in the vertex shader so its width stays fixed in
|
|
3118
|
+
* pixels at any zoom level. Custom layers can construct it directly for
|
|
3119
|
+
* paths and outlines.
|
|
3120
|
+
*
|
|
3121
|
+
* @group Renderables
|
|
3122
|
+
*/
|
|
1768
3123
|
declare class ProjectedLineRenderable extends RenderableObject {
|
|
1769
3124
|
private color_;
|
|
1770
3125
|
private width_;
|
|
3126
|
+
/**
|
|
3127
|
+
* Creates a projected line renderable for the given path geometry.
|
|
3128
|
+
*
|
|
3129
|
+
* @param props - Initialization properties.
|
|
3130
|
+
*/
|
|
1771
3131
|
constructor({ geometry, color, width }: ProjectedLineRenderableProps);
|
|
3132
|
+
/** Identifies the renderable type as `ProjectedLineRenderable`. */
|
|
1772
3133
|
get type(): string;
|
|
3134
|
+
/** The line color. Assignable from any {@link ColorLike} value. */
|
|
1773
3135
|
get color(): Color;
|
|
3136
|
+
/** @param value - The new line color. */
|
|
1774
3137
|
set color(value: ColorLike);
|
|
3138
|
+
/** The line width in pixels. */
|
|
1775
3139
|
get width(): number;
|
|
3140
|
+
/** @param value - The new width in pixels. */
|
|
1776
3141
|
set width(value: number);
|
|
3142
|
+
/** Returns the color and width uniforms for the line shader. */
|
|
1777
3143
|
getUniforms(): {
|
|
1778
3144
|
u_lineColor: [number, number, number];
|
|
1779
3145
|
u_lineWidth: number;
|
|
1780
3146
|
};
|
|
1781
3147
|
}
|
|
1782
3148
|
|
|
3149
|
+
/**
|
|
3150
|
+
* Initialization properties for constructing a volume renderable.
|
|
3151
|
+
*/
|
|
1783
3152
|
type VolumeRenderableProps = {
|
|
3153
|
+
/** Channel appearance settings. Defaults to `[]`. */
|
|
1784
3154
|
channelProps?: ChannelProps[];
|
|
1785
3155
|
};
|
|
1786
|
-
/**
|
|
3156
|
+
/**
|
|
3157
|
+
* A ray-marched box that draws multi-channel volumetric data.
|
|
3158
|
+
*
|
|
3159
|
+
* The renderable draws a unit box and ray marches through 3D chunk
|
|
3160
|
+
* textures in the fragment shader. Up to 4 channels blend in a single
|
|
3161
|
+
* pass and all loaded channels must share one texture data type. Front
|
|
3162
|
+
* faces are culled and depth testing is off by default.
|
|
3163
|
+
* {@link VolumeLayer} constructs and pools one instance per spatial chunk
|
|
3164
|
+
* group, streams chunk textures in with {@link updateVolumeWithChunk},
|
|
3165
|
+
* and sizes the box through the transform.
|
|
3166
|
+
*
|
|
3167
|
+
* @group Renderables
|
|
3168
|
+
*/
|
|
1787
3169
|
declare class VolumeRenderable extends RenderableObject {
|
|
3170
|
+
/**
|
|
3171
|
+
* World size of a voxel along each axis. Layers set it from the chunk
|
|
3172
|
+
* scale so ray march steps account for anisotropic voxels. Defaults to
|
|
3173
|
+
* `[1, 1, 1]`.
|
|
3174
|
+
*/
|
|
1788
3175
|
voxelScale: vec3;
|
|
1789
3176
|
private channels_;
|
|
1790
3177
|
private loadedChannels_;
|
|
1791
3178
|
private readonly channelToTextureIndex_;
|
|
3179
|
+
/**
|
|
3180
|
+
* Creates an empty volume renderable.
|
|
3181
|
+
*
|
|
3182
|
+
* @param props - Initialization properties.
|
|
3183
|
+
*/
|
|
1792
3184
|
constructor({ channelProps }?: VolumeRenderableProps);
|
|
3185
|
+
/** Identifies the renderable type as `VolumeRenderable`. */
|
|
1793
3186
|
get type(): string;
|
|
3187
|
+
/**
|
|
3188
|
+
* Loads or refreshes the texture for the chunk's channel. The channel
|
|
3189
|
+
* index comes from the chunk and the texture's data type selects the
|
|
3190
|
+
* volume shader, so every channel must share one data type. Chunks
|
|
3191
|
+
* without a texture are ignored.
|
|
3192
|
+
*
|
|
3193
|
+
* @param chunk - The chunk holding the channel texture.
|
|
3194
|
+
*/
|
|
1794
3195
|
updateVolumeWithChunk(chunk: Chunk): void;
|
|
1795
3196
|
private addChannelTexture;
|
|
1796
3197
|
private updateChannelTexture;
|
|
3198
|
+
/**
|
|
3199
|
+
* Marks all channels as not loaded so they stop rendering until the
|
|
3200
|
+
* next chunk update. The textures themselves are kept.
|
|
3201
|
+
*/
|
|
1797
3202
|
clearLoadedChannels(): void;
|
|
3203
|
+
/**
|
|
3204
|
+
* Clears all textures and channel state so the renderable can be
|
|
3205
|
+
* pooled and reused for another chunk.
|
|
3206
|
+
*/
|
|
1798
3207
|
reset(): void;
|
|
3208
|
+
/**
|
|
3209
|
+
* Returns per-channel sampler, color, contrast, opacity, and
|
|
3210
|
+
* visibility uniforms for up to 4 loaded channels plus the voxel
|
|
3211
|
+
* scale.
|
|
3212
|
+
*/
|
|
1799
3213
|
getUniforms(): Record<string, number[] | number>;
|
|
1800
3214
|
/**
|
|
1801
3215
|
* Get an available texture for a channel. If desiredChannelIndex is provided, it will try to return the texture for that channel index. If that texture is not available, or no desiredChannelIndex is passed, return the first available channel texture. This is used to determine which texture to use when updating channel properties, since channel properties can be updated even if the channel's texture hasn't been loaded yet. If no textures are available, it returns null, which signals that default contrast limits should be used when validating the channel properties.
|
|
1802
3216
|
*/
|
|
1803
3217
|
private getAvailableChannelTexture;
|
|
3218
|
+
/**
|
|
3219
|
+
* Replaces the appearance settings for all channels.
|
|
3220
|
+
*
|
|
3221
|
+
* @param channels - The new channel settings.
|
|
3222
|
+
*/
|
|
1804
3223
|
setChannelProps(channels: ChannelProps[]): void;
|
|
3224
|
+
/**
|
|
3225
|
+
* Updates one property of the channel at the given index and
|
|
3226
|
+
* revalidates it against the channel's texture when available.
|
|
3227
|
+
*
|
|
3228
|
+
* @param channelIndex - The channel to update.
|
|
3229
|
+
* @param property - The property name to set.
|
|
3230
|
+
* @param value - The new value.
|
|
3231
|
+
*/
|
|
1805
3232
|
setChannelProperty<K extends keyof ChannelProps>(channelIndex: number, property: K, value: Required<ChannelProps>[K]): void;
|
|
1806
3233
|
}
|
|
1807
3234
|
|
|
3235
|
+
/**
|
|
3236
|
+
* Initialization properties for constructing a perspective camera.
|
|
3237
|
+
*/
|
|
1808
3238
|
type PerspectiveCameraProps = {
|
|
3239
|
+
/** Vertical field of view in degrees. Defaults to `60`. */
|
|
1809
3240
|
fov?: number;
|
|
3241
|
+
/** Aspect ratio (width / height). Defaults to `1.77`. */
|
|
1810
3242
|
aspectRatio?: number;
|
|
3243
|
+
/** Near clipping plane distance. Defaults to `0.1`. */
|
|
1811
3244
|
near?: number;
|
|
3245
|
+
/** Far clipping plane distance. Defaults to `10000`. */
|
|
1812
3246
|
far?: number;
|
|
3247
|
+
/** World-space camera position. Defaults to the origin. */
|
|
1813
3248
|
position?: vec3;
|
|
1814
3249
|
};
|
|
1815
|
-
/**
|
|
3250
|
+
/**
|
|
3251
|
+
* A camera using a perspective projection.
|
|
3252
|
+
*
|
|
3253
|
+
* Perspective projection applies foreshortening: objects appear smaller the
|
|
3254
|
+
* farther they are from the camera, which makes this the camera to use for
|
|
3255
|
+
* 3D scenes such as volume rendering. It pairs naturally with
|
|
3256
|
+
* {@link OrbitControls}.
|
|
3257
|
+
*
|
|
3258
|
+
* The projection is defined by a vertical field of view, an aspect ratio,
|
|
3259
|
+
* and near/far clipping planes. Zooming narrows or widens the field of view
|
|
3260
|
+
* rather than moving the camera.
|
|
3261
|
+
*
|
|
3262
|
+
* ```ts
|
|
3263
|
+
* const camera = new PerspectiveCamera({ fov: 45 });
|
|
3264
|
+
*
|
|
3265
|
+
* const controls = new OrbitControls(camera, {
|
|
3266
|
+
* radius: 1200,
|
|
3267
|
+
* target: [0, 0, 0],
|
|
3268
|
+
* });
|
|
3269
|
+
*
|
|
3270
|
+
* const idetik = new Idetik({
|
|
3271
|
+
* canvas: document.querySelector('canvas')!,
|
|
3272
|
+
* viewports: [{ camera, layers: [volumeLayer], cameraControls: controls }],
|
|
3273
|
+
* });
|
|
3274
|
+
* ```
|
|
3275
|
+
*
|
|
3276
|
+
* @see {@link OrthographicCamera} for 2D image viewing with parallel
|
|
3277
|
+
* projection.
|
|
3278
|
+
*
|
|
3279
|
+
* @group Cameras
|
|
3280
|
+
*/
|
|
1816
3281
|
declare class PerspectiveCamera extends Camera {
|
|
1817
3282
|
private fov_;
|
|
1818
3283
|
private aspectRatio_;
|
|
3284
|
+
/**
|
|
3285
|
+
* Creates a perspective camera from the given projection settings.
|
|
3286
|
+
*
|
|
3287
|
+
* @param props - Initialization properties.
|
|
3288
|
+
*/
|
|
1819
3289
|
constructor(props?: PerspectiveCameraProps);
|
|
3290
|
+
/**
|
|
3291
|
+
* Sets the aspect ratio (width / height) of the viewport the camera
|
|
3292
|
+
* renders into. Called automatically by the owning viewport when it
|
|
3293
|
+
* resizes.
|
|
3294
|
+
*
|
|
3295
|
+
* @param aspectRatio - The viewport's width divided by its height.
|
|
3296
|
+
*/
|
|
1820
3297
|
setAspectRatio(aspectRatio: number): void;
|
|
3298
|
+
/** Identifies the camera type as `PerspectiveCamera`. */
|
|
1821
3299
|
get type(): CameraType;
|
|
3300
|
+
/** The vertical field of view in degrees. */
|
|
1822
3301
|
get fov(): number;
|
|
3302
|
+
/**
|
|
3303
|
+
* Zooms the view by the given factor relative to the current zoom level.
|
|
3304
|
+
* Factors greater than `1` zoom in and factors between `0` and `1` zoom
|
|
3305
|
+
* out.
|
|
3306
|
+
*
|
|
3307
|
+
* Zooming narrows or widens the field of view rather than moving the
|
|
3308
|
+
* camera, and the result is clamped to valid angles.
|
|
3309
|
+
*
|
|
3310
|
+
* @param factor - The magnification factor to apply.
|
|
3311
|
+
*/
|
|
1823
3312
|
zoom(factor: number): void;
|
|
3313
|
+
/** @hidden */
|
|
1824
3314
|
protected updateProjectionMatrix(): void;
|
|
1825
3315
|
}
|
|
1826
3316
|
|
|
3317
|
+
/**
|
|
3318
|
+
* Initialization properties for constructing orbit controls.
|
|
3319
|
+
*/
|
|
1827
3320
|
type OrbitControlsProps = {
|
|
3321
|
+
/** Distance from the target in world units. Defaults to `1`. */
|
|
1828
3322
|
radius?: number;
|
|
3323
|
+
/** Initial azimuth angle in radians. Defaults to `0`. */
|
|
1829
3324
|
yaw?: number;
|
|
3325
|
+
/** Initial elevation angle in radians. Defaults to `0`. */
|
|
1830
3326
|
pitch?: number;
|
|
3327
|
+
/** The point the camera orbits. Defaults to the origin. */
|
|
1831
3328
|
target?: vec3;
|
|
3329
|
+
/** Velocity decay rate between `0` and `1`. Defaults to `0.5`. */
|
|
1832
3330
|
dampingFactor?: number;
|
|
1833
3331
|
};
|
|
1834
|
-
/**
|
|
3332
|
+
/**
|
|
3333
|
+
* Camera controls for orbiting a perspective camera around a target.
|
|
3334
|
+
*
|
|
3335
|
+
* Dragging with the left mouse button orbits, dragging with `Shift` held
|
|
3336
|
+
* or with the middle button pans the target, and the scroll wheel zooms by
|
|
3337
|
+
* changing the orbit radius. Input adds velocity that damping decays over time.
|
|
3338
|
+
*
|
|
3339
|
+
* ```ts
|
|
3340
|
+
* const camera = new PerspectiveCamera({ near: 1.0 });
|
|
3341
|
+
*
|
|
3342
|
+
* const idetik = new Idetik({
|
|
3343
|
+
* canvas,
|
|
3344
|
+
* viewports: [{
|
|
3345
|
+
* camera,
|
|
3346
|
+
* layers: [volumeLayer],
|
|
3347
|
+
* cameraControls: new OrbitControls(camera, {
|
|
3348
|
+
* radius: 100,
|
|
3349
|
+
* target: [40, 40, 10],
|
|
3350
|
+
* }),
|
|
3351
|
+
* }],
|
|
3352
|
+
* });
|
|
3353
|
+
* ```
|
|
3354
|
+
*
|
|
3355
|
+
* @group Controls
|
|
3356
|
+
*/
|
|
1835
3357
|
declare class OrbitControls implements CameraControls {
|
|
1836
3358
|
private readonly camera_;
|
|
1837
3359
|
private readonly orbitVelocity_;
|
|
@@ -1840,13 +3362,36 @@ declare class OrbitControls implements CameraControls {
|
|
|
1840
3362
|
private readonly currCenter_;
|
|
1841
3363
|
private readonly dampingFactor_;
|
|
1842
3364
|
private currMouseButton_;
|
|
3365
|
+
/**
|
|
3366
|
+
* Creates orbit controls and moves the camera to the initial pose.
|
|
3367
|
+
*
|
|
3368
|
+
* @param camera - The perspective camera to control.
|
|
3369
|
+
* @param params - Initialization properties.
|
|
3370
|
+
*/
|
|
1843
3371
|
constructor(camera: PerspectiveCamera, params?: OrbitControlsProps);
|
|
3372
|
+
/** The current distance from the target in world units. */
|
|
1844
3373
|
get radius(): number;
|
|
3374
|
+
/** The current azimuth angle in radians. */
|
|
1845
3375
|
get yaw(): number;
|
|
3376
|
+
/** The current elevation angle in radians. */
|
|
1846
3377
|
get pitch(): number;
|
|
3378
|
+
/** A copy of the point the camera orbits. */
|
|
1847
3379
|
get target(): vec3;
|
|
3380
|
+
/** Whether any orbit, pan, or zoom velocity remains. */
|
|
1848
3381
|
get isMoving(): boolean;
|
|
3382
|
+
/**
|
|
3383
|
+
* Handles a pointer or wheel event. Called automatically by the owning
|
|
3384
|
+
* viewport unless a layer stops propagation.
|
|
3385
|
+
*
|
|
3386
|
+
* @param event - The event with clip and world coordinates attached.
|
|
3387
|
+
*/
|
|
1849
3388
|
onEvent(event: EventContext): void;
|
|
3389
|
+
/**
|
|
3390
|
+
* Applies pending velocities to the camera and decays them toward zero.
|
|
3391
|
+
* Called automatically by the render loop once per frame.
|
|
3392
|
+
*
|
|
3393
|
+
* @param dt - Time since the last frame in seconds.
|
|
3394
|
+
*/
|
|
1850
3395
|
onUpdate(dt: number): void;
|
|
1851
3396
|
private onPointerDown;
|
|
1852
3397
|
private onPointerMove;
|
|
@@ -1859,214 +3404,5 @@ declare class OrbitControls implements CameraControls {
|
|
|
1859
3404
|
private cutoffLowVelocity;
|
|
1860
3405
|
}
|
|
1861
3406
|
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
/**The multiscale datasets for this image*/
|
|
1865
|
-
multiscales: z.ZodArray<z.ZodObject<{
|
|
1866
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1867
|
-
datasets: z.ZodArray<z.ZodObject<{
|
|
1868
|
-
path: z.ZodString;
|
|
1869
|
-
coordinateTransformations: z.ZodArray<z.ZodEffects<z.ZodAny, any, any>, "many">;
|
|
1870
|
-
}, "strip", z.ZodTypeAny, {
|
|
1871
|
-
path: string;
|
|
1872
|
-
coordinateTransformations: any[];
|
|
1873
|
-
}, {
|
|
1874
|
-
path: string;
|
|
1875
|
-
coordinateTransformations: any[];
|
|
1876
|
-
}>, "many">;
|
|
1877
|
-
version: z.ZodOptional<z.ZodLiteral<"0.4">>;
|
|
1878
|
-
axes: z.ZodArray<z.ZodEffects<z.ZodAny, any, any>, "many">;
|
|
1879
|
-
coordinateTransformations: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodAny, any, any>, "many">>;
|
|
1880
|
-
}, "strip", z.ZodTypeAny, {
|
|
1881
|
-
datasets: {
|
|
1882
|
-
path: string;
|
|
1883
|
-
coordinateTransformations: any[];
|
|
1884
|
-
}[];
|
|
1885
|
-
axes: any[];
|
|
1886
|
-
name?: string | undefined;
|
|
1887
|
-
coordinateTransformations?: any[] | undefined;
|
|
1888
|
-
version?: "0.4" | undefined;
|
|
1889
|
-
}, {
|
|
1890
|
-
datasets: {
|
|
1891
|
-
path: string;
|
|
1892
|
-
coordinateTransformations: any[];
|
|
1893
|
-
}[];
|
|
1894
|
-
axes: any[];
|
|
1895
|
-
name?: string | undefined;
|
|
1896
|
-
coordinateTransformations?: any[] | undefined;
|
|
1897
|
-
version?: "0.4" | undefined;
|
|
1898
|
-
}>, "many">;
|
|
1899
|
-
omero: z.ZodOptional<z.ZodObject<{
|
|
1900
|
-
channels: z.ZodArray<z.ZodObject<{
|
|
1901
|
-
window: z.ZodObject<{
|
|
1902
|
-
end: z.ZodNumber;
|
|
1903
|
-
max: z.ZodNumber;
|
|
1904
|
-
min: z.ZodNumber;
|
|
1905
|
-
start: z.ZodNumber;
|
|
1906
|
-
}, "strip", z.ZodTypeAny, {
|
|
1907
|
-
min: number;
|
|
1908
|
-
max: number;
|
|
1909
|
-
end: number;
|
|
1910
|
-
start: number;
|
|
1911
|
-
}, {
|
|
1912
|
-
min: number;
|
|
1913
|
-
max: number;
|
|
1914
|
-
end: number;
|
|
1915
|
-
start: number;
|
|
1916
|
-
}>;
|
|
1917
|
-
label: z.ZodOptional<z.ZodString>;
|
|
1918
|
-
family: z.ZodOptional<z.ZodString>;
|
|
1919
|
-
color: z.ZodString;
|
|
1920
|
-
active: z.ZodOptional<z.ZodBoolean>;
|
|
1921
|
-
}, "strip", z.ZodTypeAny, {
|
|
1922
|
-
color: string;
|
|
1923
|
-
window: {
|
|
1924
|
-
min: number;
|
|
1925
|
-
max: number;
|
|
1926
|
-
end: number;
|
|
1927
|
-
start: number;
|
|
1928
|
-
};
|
|
1929
|
-
label?: string | undefined;
|
|
1930
|
-
family?: string | undefined;
|
|
1931
|
-
active?: boolean | undefined;
|
|
1932
|
-
}, {
|
|
1933
|
-
color: string;
|
|
1934
|
-
window: {
|
|
1935
|
-
min: number;
|
|
1936
|
-
max: number;
|
|
1937
|
-
end: number;
|
|
1938
|
-
start: number;
|
|
1939
|
-
};
|
|
1940
|
-
label?: string | undefined;
|
|
1941
|
-
family?: string | undefined;
|
|
1942
|
-
active?: boolean | undefined;
|
|
1943
|
-
}>, "many">;
|
|
1944
|
-
rdefs: z.ZodOptional<z.ZodObject<{
|
|
1945
|
-
defaultT: z.ZodOptional<z.ZodNumber>;
|
|
1946
|
-
defaultZ: z.ZodOptional<z.ZodNumber>;
|
|
1947
|
-
color: z.ZodOptional<z.ZodEnum<["color", "greyscale"]>>;
|
|
1948
|
-
projection: z.ZodOptional<z.ZodString>;
|
|
1949
|
-
}, "strip", z.ZodTypeAny, {
|
|
1950
|
-
color?: "color" | "greyscale" | undefined;
|
|
1951
|
-
defaultT?: number | undefined;
|
|
1952
|
-
defaultZ?: number | undefined;
|
|
1953
|
-
projection?: string | undefined;
|
|
1954
|
-
}, {
|
|
1955
|
-
color?: "color" | "greyscale" | undefined;
|
|
1956
|
-
defaultT?: number | undefined;
|
|
1957
|
-
defaultZ?: number | undefined;
|
|
1958
|
-
projection?: string | undefined;
|
|
1959
|
-
}>>;
|
|
1960
|
-
}, "strip", z.ZodTypeAny, {
|
|
1961
|
-
channels: {
|
|
1962
|
-
color: string;
|
|
1963
|
-
window: {
|
|
1964
|
-
min: number;
|
|
1965
|
-
max: number;
|
|
1966
|
-
end: number;
|
|
1967
|
-
start: number;
|
|
1968
|
-
};
|
|
1969
|
-
label?: string | undefined;
|
|
1970
|
-
family?: string | undefined;
|
|
1971
|
-
active?: boolean | undefined;
|
|
1972
|
-
}[];
|
|
1973
|
-
rdefs?: {
|
|
1974
|
-
color?: "color" | "greyscale" | undefined;
|
|
1975
|
-
defaultT?: number | undefined;
|
|
1976
|
-
defaultZ?: number | undefined;
|
|
1977
|
-
projection?: string | undefined;
|
|
1978
|
-
} | undefined;
|
|
1979
|
-
}, {
|
|
1980
|
-
channels: {
|
|
1981
|
-
color: string;
|
|
1982
|
-
window: {
|
|
1983
|
-
min: number;
|
|
1984
|
-
max: number;
|
|
1985
|
-
end: number;
|
|
1986
|
-
start: number;
|
|
1987
|
-
};
|
|
1988
|
-
label?: string | undefined;
|
|
1989
|
-
family?: string | undefined;
|
|
1990
|
-
active?: boolean | undefined;
|
|
1991
|
-
}[];
|
|
1992
|
-
rdefs?: {
|
|
1993
|
-
color?: "color" | "greyscale" | undefined;
|
|
1994
|
-
defaultT?: number | undefined;
|
|
1995
|
-
defaultZ?: number | undefined;
|
|
1996
|
-
projection?: string | undefined;
|
|
1997
|
-
} | undefined;
|
|
1998
|
-
}>>;
|
|
1999
|
-
}, "strip", z.ZodTypeAny, {
|
|
2000
|
-
multiscales: {
|
|
2001
|
-
datasets: {
|
|
2002
|
-
path: string;
|
|
2003
|
-
coordinateTransformations: any[];
|
|
2004
|
-
}[];
|
|
2005
|
-
axes: any[];
|
|
2006
|
-
name?: string | undefined;
|
|
2007
|
-
coordinateTransformations?: any[] | undefined;
|
|
2008
|
-
version?: "0.4" | undefined;
|
|
2009
|
-
}[];
|
|
2010
|
-
omero?: {
|
|
2011
|
-
channels: {
|
|
2012
|
-
color: string;
|
|
2013
|
-
window: {
|
|
2014
|
-
min: number;
|
|
2015
|
-
max: number;
|
|
2016
|
-
end: number;
|
|
2017
|
-
start: number;
|
|
2018
|
-
};
|
|
2019
|
-
label?: string | undefined;
|
|
2020
|
-
family?: string | undefined;
|
|
2021
|
-
active?: boolean | undefined;
|
|
2022
|
-
}[];
|
|
2023
|
-
rdefs?: {
|
|
2024
|
-
color?: "color" | "greyscale" | undefined;
|
|
2025
|
-
defaultT?: number | undefined;
|
|
2026
|
-
defaultZ?: number | undefined;
|
|
2027
|
-
projection?: string | undefined;
|
|
2028
|
-
} | undefined;
|
|
2029
|
-
} | undefined;
|
|
2030
|
-
}, {
|
|
2031
|
-
multiscales: {
|
|
2032
|
-
datasets: {
|
|
2033
|
-
path: string;
|
|
2034
|
-
coordinateTransformations: any[];
|
|
2035
|
-
}[];
|
|
2036
|
-
axes: any[];
|
|
2037
|
-
name?: string | undefined;
|
|
2038
|
-
coordinateTransformations?: any[] | undefined;
|
|
2039
|
-
version?: "0.4" | undefined;
|
|
2040
|
-
}[];
|
|
2041
|
-
omero?: {
|
|
2042
|
-
channels: {
|
|
2043
|
-
color: string;
|
|
2044
|
-
window: {
|
|
2045
|
-
min: number;
|
|
2046
|
-
max: number;
|
|
2047
|
-
end: number;
|
|
2048
|
-
start: number;
|
|
2049
|
-
};
|
|
2050
|
-
label?: string | undefined;
|
|
2051
|
-
family?: string | undefined;
|
|
2052
|
-
active?: boolean | undefined;
|
|
2053
|
-
}[];
|
|
2054
|
-
rdefs?: {
|
|
2055
|
-
color?: "color" | "greyscale" | undefined;
|
|
2056
|
-
defaultT?: number | undefined;
|
|
2057
|
-
defaultZ?: number | undefined;
|
|
2058
|
-
projection?: string | undefined;
|
|
2059
|
-
} | undefined;
|
|
2060
|
-
} | undefined;
|
|
2061
|
-
}>;
|
|
2062
|
-
type Image = z.infer<typeof Image>;
|
|
2063
|
-
|
|
2064
|
-
/**
|
|
2065
|
-
* Parsed OME-Zarr (OME-NGFF 0.4) image metadata.
|
|
2066
|
-
*
|
|
2067
|
-
* @group Data Loading
|
|
2068
|
-
*/
|
|
2069
|
-
type OmeZarrImage = Image;
|
|
2070
|
-
|
|
2071
|
-
export { AxesLayer, Color, Idetik, ImageLayer, ImageRenderable, LabelImageRenderable, LabelLayer, Layer, OmeZarrImageSource, OrbitControls, OrthographicCamera, PanZoomControls, PerspectiveCamera, PointsRenderable, ProjectedLineRenderable, VolumeLayer, VolumeRenderable, createExplorationPolicy, createImageSourcePolicy, createNoPrefetchPolicy, createPlaybackPolicy, loadOmeZarrPlate, loadOmeZarrWell, loadOmeroChannels, loadOmeroDefaults };
|
|
2072
|
-
export type { ChannelProps, ColorLike, LayerState, MemoryStats, OmeZarrImage, Overlay, SliceCoordinates, SliceOrientation };
|
|
3407
|
+
export { AxesLayer, Box2, Box3, Camera, Color, Frustum, Idetik, ImageLayer, ImageRenderable, LabelImageRenderable, LabelLayer, Layer, OmeZarrImageSource, OrbitControls, OrthographicCamera, PanZoomControls, PerspectiveCamera, PointsRenderable, ProjectedLineRenderable, RenderableObject, TrsTransform, Viewport, VolumeLayer, VolumeRenderable, createExplorationPolicy, createImageSourcePolicy, createNoPrefetchPolicy, createPlaybackPolicy, loadOmeZarrPlate, loadOmeZarrWell, loadOmeroChannels, loadOmeroDefaults };
|
|
3408
|
+
export type { AxesLayerProps, BlendMode, CameraControls, CameraType, ChannelProps, ColorLike, FileSystemOmeZarrImageSourceProps, HttpOmeZarrImageSourceProps, IdetikProps, ImageLayerProps, ImageRenderableProps, LabelColorMap, LabelColorMapProps, LabelImageRenderableProps, LabelLayerProps, LayerProps, LayerState, MemoryStats, OrbitControlsProps, OrthographicCameraFrame, OrthographicCameraProps, Overlay, PerspectiveCameraProps, PointPickingResult, PointProps, ProjectedLineRenderableProps, QueueStats, SliceCoordinates, SliceOrientation, SourceDimension, SourceDimensionLod, SourceDimensionMap, StateChangeCallback, ViewportProps, VolumeLayerProps, VolumeRenderableProps };
|