@idetik/core 0.36.0 → 0.36.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/README.md +63 -119
- package/dist/index.d.ts +135 -144
- package/dist/index.js +912 -906
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +29 -29
- package/dist/index.umd.cjs.map +1 -1
- package/dist/types/src/idetik.d.ts +2 -3
- package/dist/types/src/idetik.d.ts.map +1 -1
- package/dist/types/src/layers/image_layer.d.ts +1 -1
- package/dist/types/src/layers/image_layer.d.ts.map +1 -1
- package/dist/types/src/layers/label_layer.d.ts +1 -1
- package/dist/types/src/layers/label_layer.d.ts.map +1 -1
- package/dist/types/src/layers/volume_layer.d.ts +1 -1
- package/dist/types/src/layers/volume_layer.d.ts.map +1 -1
- package/dist/types/src/objects/cameras/camera.d.ts +5 -2
- package/dist/types/src/objects/cameras/camera.d.ts.map +1 -1
- package/dist/types/src/objects/cameras/orthographic_camera.d.ts +12 -9
- package/dist/types/src/objects/cameras/orthographic_camera.d.ts.map +1 -1
- package/dist/types/src/objects/cameras/perspective_camera.d.ts +1 -1
- package/dist/types/src/objects/cameras/perspective_camera.d.ts.map +1 -1
- package/dist/types/src/objects/renderable/image_renderable.d.ts +7 -1
- package/dist/types/src/objects/renderable/image_renderable.d.ts.map +1 -1
- package/dist/types/src/objects/renderable/volume_renderable.d.ts +5 -1
- package/dist/types/src/objects/renderable/volume_renderable.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,149 +1,93 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">Idetik</h1>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">Build interactive viewers for massive bioimaging data in the browser</p>
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
This project is under active development and not yet stable. We welcome bug reports and new ideas, but are not prepared to review or accept major contributions at this time.
|
|
8
|
-
|
|
9
|
-
## Reporting Security Issues
|
|
10
|
-
|
|
11
|
-
If you believe you have found a security issue, please responsibly disclose via the process in our [Security Policy](SECURITY.md).
|
|
12
|
-
|
|
13
|
-
## Getting started (development)
|
|
14
|
-
|
|
15
|
-
1. Install the development version of node.
|
|
16
|
-
|
|
17
|
-
If you use `nvm` to manage node versions, you can run:
|
|
18
|
-
|
|
19
|
-
`nvm use`
|
|
20
|
-
|
|
21
|
-
Otherwise, manually install the version of node specified in `.nvmrc`.
|
|
22
|
-
|
|
23
|
-
2. Install the dependencies required by this project (from within this directory):
|
|
24
|
-
|
|
25
|
-
`npm install`
|
|
26
|
-
|
|
27
|
-
Re-run this command any time the dependencies listed in [package.json](package.json) change, such
|
|
28
|
-
as after checking out a different revision or pulling changes.
|
|
5
|
+
<div align="center">
|
|
29
6
|
|
|
30
|
-
|
|
7
|
+

|
|
8
|
+
[](https://www.npmjs.com/package/@idetik/core)
|
|
9
|
+
[](https://chanzuckerberg.github.io/idetik/)
|
|
31
10
|
|
|
32
|
-
|
|
11
|
+
</div>
|
|
33
12
|
|
|
34
|
-
|
|
35
|
-
are for local development and testing only; they are not deployed.
|
|
13
|
+
## Overview
|
|
36
14
|
|
|
37
|
-
|
|
15
|
+
Idetik is a high-performance library for exploring multi-dimensional OME-Zarr datasets right in the browser. It is not a viewer but a framework for building viewers. Define viewports with your own cameras, controls, and layers, and point them at any local or remote store with no conversion step. Chunks are streamed based on what the camera needs at the current zoom and nothing more, with preconfigured policies for smooth temporal playback. When the built-in pieces aren't enough, subclass layers to render your own data, add custom input handlers, or plug in your own data loader.
|
|
38
16
|
|
|
39
|
-
|
|
17
|
+
#### Documentation
|
|
40
18
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
`npm run test -- --run`.
|
|
19
|
+
- Guide: https://chanzuckerberg.github.io/idetik/guide/getting-started
|
|
20
|
+
- API reference: https://chanzuckerberg.github.io/idetik/api/
|
|
44
21
|
|
|
45
|
-
|
|
22
|
+
## Installation
|
|
46
23
|
|
|
47
|
-
|
|
24
|
+
Idetik is published to npm as [@idetik/core](https://www.npmjs.com/package/@idetik/core):
|
|
48
25
|
|
|
49
|
-
|
|
50
|
-
|
|
26
|
+
```bash
|
|
27
|
+
npm install @idetik/core
|
|
28
|
+
```
|
|
51
29
|
|
|
52
|
-
|
|
30
|
+
## Minimal Example
|
|
53
31
|
|
|
54
|
-
|
|
32
|
+
This example displays a single slice from [Zebrahub](https://zebrahub.sf.czbiohub.org/), a terabyte-scale light-sheet time-lapse of a developing zebrafish, hosted as OME-Zarr on a public server. Idetik fetches only the chunks the view needs so you can pan and zoom through the full-resolution image without downloading the dataset.
|
|
55
33
|
|
|
56
|
-
|
|
34
|
+
```typescript
|
|
35
|
+
import {
|
|
36
|
+
Idetik,
|
|
37
|
+
ImageLayer,
|
|
38
|
+
OmeZarrImageSource,
|
|
39
|
+
OrthographicCamera,
|
|
40
|
+
PanZoomControls,
|
|
41
|
+
} from '@idetik/core'
|
|
57
42
|
|
|
58
|
-
|
|
43
|
+
const url = 'https://public.czbiohub.org/royerlab/zebrahub/imaging/single-objective/ZSNS001.ome.zarr/';
|
|
44
|
+
const source = await OmeZarrImageSource.fromHttp({url});
|
|
59
45
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
46
|
+
const layer = new ImageLayer({
|
|
47
|
+
source,
|
|
48
|
+
sliceCoords: { t: 400, z: 278, c: [0] }, // one slice: mid time-lapse, mid-stack
|
|
49
|
+
channelProps: [{ visible: true, contrastLimits: [0, 60] }],
|
|
50
|
+
});
|
|
64
51
|
|
|
65
|
-
|
|
52
|
+
// frame the camera to the image's physical extent.
|
|
53
|
+
const { x, y } = source.getDimensions()
|
|
54
|
+
const camera = new OrthographicCamera({
|
|
55
|
+
left: 0, right: x.lods[0].size * x.lods[0].scale,
|
|
56
|
+
top: 0, bottom: y.lods[0].size * y.lods[0].scale
|
|
57
|
+
});
|
|
66
58
|
|
|
67
|
-
|
|
59
|
+
const idetik = new Idetik({
|
|
60
|
+
canvas: document.querySelector('canvas')!,
|
|
61
|
+
viewports: [{
|
|
62
|
+
camera,
|
|
63
|
+
layers: [layer],
|
|
64
|
+
cameraControls: new PanZoomControls(camera)
|
|
65
|
+
}],
|
|
66
|
+
});
|
|
68
67
|
|
|
69
|
-
|
|
68
|
+
idetik.start();
|
|
69
|
+
```
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
### Automatic Release Process (Recommended)
|
|
74
|
-
|
|
75
|
-
We use [semantic-release](https://github.com/semantic-release/semantic-release) to automatically handle versioning, changelog generation, npm publishing, and GitHub releases.
|
|
76
|
-
|
|
77
|
-
#### How It Works
|
|
78
|
-
|
|
79
|
-
1. **Use Conventional Commits**: When creating PRs, ensure your PR title follows the [Conventional Commits](https://www.conventionalcommits.org/) format:
|
|
80
|
-
- `feat: add new feature` → triggers a **minor** version bump (e.g., 0.1.0 → 0.2.0)
|
|
81
|
-
- `fix: resolve bug` → triggers a **patch** version bump (e.g., 0.1.0 → 0.1.1)
|
|
82
|
-
- `feat!: breaking change` or `BREAKING CHANGE:` in commit footer → triggers a **minor** version bump while in `0.x` (e.g., 0.1.0 → 0.2.0)
|
|
83
|
-
- `refactor:`, `perf:`, `chore:`, `revert:` → triggers a **patch** version bump
|
|
84
|
-
- `docs:`, `style:`, `test:`, `ci:`, `build:` → no release
|
|
85
|
-
|
|
86
|
-
While the project is in `0.x`, breaking changes bump the **minor** version (see [.releaserc.json](.releaserc.json)); `1.0.0` will be cut deliberately.
|
|
87
|
-
|
|
88
|
-
2. **PR Title Validation**: Our CI automatically validates PR titles to ensure they follow the conventional commit format.
|
|
89
|
-
|
|
90
|
-
3. **Merge to Main**: When your PR is merged to `main`, the release workflow automatically:
|
|
91
|
-
- Analyzes commits since the last release
|
|
92
|
-
- Determines the version bump
|
|
93
|
-
- Updates the version in `package.json`
|
|
94
|
-
- Generates/updates `CHANGELOG.md`
|
|
95
|
-
- Publishes to npm as `@idetik/core`
|
|
96
|
-
- Creates a GitHub release with release notes
|
|
97
|
-
- Tags the release (e.g., `v0.2.0`)
|
|
98
|
-
|
|
99
|
-
4. **No Manual Intervention Required**: The entire process is automatic once merged to `main`.
|
|
100
|
-
|
|
101
|
-
#### Pre-requirements
|
|
71
|
+
## Project Status
|
|
102
72
|
|
|
103
|
-
|
|
104
|
-
- Set up "trusted publishing" for the repo/package pair on npm (uses OIDC to authenticate when publishing)
|
|
105
|
-
- Use `actions/create-github-app-token` to generate a GH token so `semantic-release` can comment
|
|
106
|
-
on the PR after release
|
|
107
|
-
- For manual releases:
|
|
108
|
-
- Set `NPM_TOKEN` env var with an npm token with publish access to `@idetik` scope
|
|
109
|
-
- You must be a member of the [idetik developer team](https://www.npmjs.com/settings/idetik/teams/team/developers/users) on NPM
|
|
73
|
+
This project is under active development. We welcome bug reports and new ideas but are not prepared to review or accept major contributions at this time.
|
|
110
74
|
|
|
111
|
-
|
|
75
|
+
## Getting Help
|
|
112
76
|
|
|
113
|
-
If you
|
|
77
|
+
If you run into problems, please [open an issue on GitHub](https://github.com/chanzuckerberg/idetik/issues). If possible include:
|
|
114
78
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
npm version [major|minor|patch] # Choose appropriate bump
|
|
119
|
-
npm install # Updates package-lock.json
|
|
120
|
-
npm run build
|
|
121
|
-
```
|
|
79
|
+
- A clear description of the problem and steps to reproduce
|
|
80
|
+
- Expected vs. actual behavior
|
|
81
|
+
- Your environment (OS, browser, version)
|
|
122
82
|
|
|
123
|
-
|
|
124
|
-
- Create a PR with your changes
|
|
125
|
-
- Get it approved and merge to `main`
|
|
83
|
+
If you believe you have found a security issue, we would appreciate notification. Please email security@biohub.org.
|
|
126
84
|
|
|
127
|
-
|
|
128
|
-
```shell
|
|
129
|
-
git checkout main
|
|
130
|
-
git pull
|
|
131
|
-
npm login
|
|
132
|
-
npm run pub
|
|
133
|
-
```
|
|
85
|
+
## Code of Conduct
|
|
134
86
|
|
|
135
|
-
|
|
136
|
-
```shell
|
|
137
|
-
git tag vX.Y.Z # Use the version number from package.json
|
|
138
|
-
git push origin --tags
|
|
139
|
-
```
|
|
87
|
+
This project adheres to the Contributor Covenant [code of conduct](https://www.contributor-covenant.org/version/3/0/code_of_conduct/). By participating you are expected to uphold this code. Please report unacceptable behavior to opensource@biohub.org.
|
|
140
88
|
|
|
141
|
-
|
|
142
|
-
- Go to the [Releases page](https://github.com/chanzuckerberg/idetik/releases)
|
|
143
|
-
- Click "Create a new release"
|
|
144
|
-
- Select the tag you just created
|
|
145
|
-
- Add release notes describing the changes
|
|
89
|
+
## License
|
|
146
90
|
|
|
147
|
-
|
|
91
|
+
Licensed under the [MIT License](LICENSE).
|
|
148
92
|
|
|
149
|
-
|
|
93
|
+
Copyright (c) 2026-present Chan Zuckerberg Biohub, Inc.
|
package/dist/index.d.ts
CHANGED
|
@@ -313,6 +313,57 @@ declare class Box3 {
|
|
|
313
313
|
applyTransform(matrix: mat4): void;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
declare class Frustum {
|
|
317
|
+
private readonly planes_;
|
|
318
|
+
constructor(m: mat4);
|
|
319
|
+
setWithViewProjection(m: mat4): void;
|
|
320
|
+
intersectsWithBox3(box: Box3): boolean;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare class TrsTransform {
|
|
324
|
+
private dirty_;
|
|
325
|
+
private matrix_;
|
|
326
|
+
private rotation_;
|
|
327
|
+
private translation_;
|
|
328
|
+
private scale_;
|
|
329
|
+
addRotation(q: quat): void;
|
|
330
|
+
setRotation(q: quat): void;
|
|
331
|
+
get rotation(): gl_matrix.vec4;
|
|
332
|
+
addTranslation(vec: vec3): void;
|
|
333
|
+
setTranslation(vec: vec3): void;
|
|
334
|
+
get translation(): vec3;
|
|
335
|
+
addScale(vec: vec3): void;
|
|
336
|
+
setScale(vec: vec3): void;
|
|
337
|
+
targetTo(target: vec3): void;
|
|
338
|
+
get scale(): vec3;
|
|
339
|
+
get matrix(): mat4;
|
|
340
|
+
get inverse(): mat4;
|
|
341
|
+
private computeMatrix;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
type CameraType = "OrthographicCamera" | "PerspectiveCamera";
|
|
345
|
+
declare abstract class Camera extends Node {
|
|
346
|
+
private readonly transform_;
|
|
347
|
+
protected projectionMatrix_: mat4;
|
|
348
|
+
protected near_: number;
|
|
349
|
+
protected far_: number;
|
|
350
|
+
protected abstract updateProjectionMatrix(): void;
|
|
351
|
+
abstract get type(): CameraType;
|
|
352
|
+
update(): void;
|
|
353
|
+
get projectionMatrix(): mat4;
|
|
354
|
+
get transform(): TrsTransform;
|
|
355
|
+
get viewMatrix(): mat4;
|
|
356
|
+
get right(): vec3;
|
|
357
|
+
get up(): vec3;
|
|
358
|
+
getViewProjection(): mat4;
|
|
359
|
+
get frustum(): Frustum;
|
|
360
|
+
abstract setAspectRatio(aspectRatio: number): void;
|
|
361
|
+
abstract zoom(factor: number): void;
|
|
362
|
+
pan(vec: vec3): void;
|
|
363
|
+
get position(): vec3;
|
|
364
|
+
clipToWorld(position: vec3): vec3;
|
|
365
|
+
}
|
|
366
|
+
|
|
316
367
|
type Primitive = "triangles" | "points" | "lines";
|
|
317
368
|
type GeometryAttributeType = "position" | "normal" | "uv" | "next_position" | "previous_position" | "direction" | "color" | "size" | "marker";
|
|
318
369
|
type GeometryAttribute = {
|
|
@@ -344,27 +395,6 @@ declare class WireframeGeometry extends Geometry {
|
|
|
344
395
|
constructor(geometry: Geometry);
|
|
345
396
|
}
|
|
346
397
|
|
|
347
|
-
declare class TrsTransform {
|
|
348
|
-
private dirty_;
|
|
349
|
-
private matrix_;
|
|
350
|
-
private rotation_;
|
|
351
|
-
private translation_;
|
|
352
|
-
private scale_;
|
|
353
|
-
addRotation(q: quat): void;
|
|
354
|
-
setRotation(q: quat): void;
|
|
355
|
-
get rotation(): gl_matrix.vec4;
|
|
356
|
-
addTranslation(vec: vec3): void;
|
|
357
|
-
setTranslation(vec: vec3): void;
|
|
358
|
-
get translation(): vec3;
|
|
359
|
-
addScale(vec: vec3): void;
|
|
360
|
-
setScale(vec: vec3): void;
|
|
361
|
-
targetTo(target: vec3): void;
|
|
362
|
-
get scale(): vec3;
|
|
363
|
-
get matrix(): mat4;
|
|
364
|
-
get inverse(): mat4;
|
|
365
|
-
private computeMatrix;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
398
|
type Shader = "floatScalarImage" | "floatVolume" | "intLabelImage" | "intScalarImage" | "intVolume" | "labelImage" | "points" | "projectedLine" | "uintScalarImage" | "uintVolume" | "wireframe";
|
|
369
399
|
|
|
370
400
|
/** @group Layer Configuration */
|
|
@@ -429,34 +459,6 @@ declare abstract class RenderableObject extends Node {
|
|
|
429
459
|
getUniforms(): Record<string, unknown>;
|
|
430
460
|
}
|
|
431
461
|
|
|
432
|
-
declare class Frustum {
|
|
433
|
-
private readonly planes_;
|
|
434
|
-
constructor(m: mat4);
|
|
435
|
-
setWithViewProjection(m: mat4): void;
|
|
436
|
-
intersectsWithBox3(box: Box3): boolean;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
type CameraType = "OrthographicCamera" | "PerspectiveCamera";
|
|
440
|
-
declare abstract class Camera extends RenderableObject {
|
|
441
|
-
protected projectionMatrix_: mat4;
|
|
442
|
-
protected near_: number;
|
|
443
|
-
protected far_: number;
|
|
444
|
-
protected abstract updateProjectionMatrix(): void;
|
|
445
|
-
abstract get type(): CameraType;
|
|
446
|
-
update(): void;
|
|
447
|
-
get projectionMatrix(): mat4;
|
|
448
|
-
get viewMatrix(): mat4;
|
|
449
|
-
get right(): vec3;
|
|
450
|
-
get up(): vec3;
|
|
451
|
-
getViewProjection(): mat4;
|
|
452
|
-
get frustum(): Frustum;
|
|
453
|
-
abstract setAspectRatio(aspectRatio: number): void;
|
|
454
|
-
abstract zoom(factor: number): void;
|
|
455
|
-
pan(vec: vec3): void;
|
|
456
|
-
get position(): vec3;
|
|
457
|
-
clipToWorld(position: vec3): vec3;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
462
|
declare class Plane {
|
|
461
463
|
normal: vec3;
|
|
462
464
|
signedDistance: number;
|
|
@@ -500,7 +502,68 @@ declare class EventDispatcher {
|
|
|
500
502
|
private readonly handleEvent;
|
|
501
503
|
}
|
|
502
504
|
|
|
503
|
-
|
|
505
|
+
/** @group Layers */
|
|
506
|
+
type LayerState = "initialized" | "loading" | "ready";
|
|
507
|
+
type BlendMode = "none" | "normal" | "additive" | "subtractive" | "multiply" | "premultiplied";
|
|
508
|
+
type StateChangeCallback = (newState: LayerState, prevState?: LayerState) => void;
|
|
509
|
+
interface LayerProps {
|
|
510
|
+
opacity?: number;
|
|
511
|
+
blendMode?: BlendMode;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Abstract base class for everything that can be added to a viewport.
|
|
515
|
+
*
|
|
516
|
+
* A `Layer` owns a set of renderable objects and contributes them to the scene
|
|
517
|
+
* each frame. Subclasses (e.g. {@link ImageLayer}, {@link VolumeLayer},
|
|
518
|
+
* {@link LabelLayer}) implement {@link Layer.update} to build or refresh those
|
|
519
|
+
* objects for the current view, and may override the `attach`/`detach` hooks to
|
|
520
|
+
* acquire and release resources when the layer joins or leaves a viewport.
|
|
521
|
+
*
|
|
522
|
+
* Layers carry shared presentation state — {@link Layer.opacity} and blend mode —
|
|
523
|
+
* and expose a lifecycle {@link LayerState} (`initialized` → `loading` → `ready`)
|
|
524
|
+
* that observers can subscribe to. A layer instance may be attached to only one
|
|
525
|
+
* viewport at a time.
|
|
526
|
+
*
|
|
527
|
+
* @group Layers
|
|
528
|
+
*/
|
|
529
|
+
declare abstract class Layer {
|
|
530
|
+
abstract readonly type: string;
|
|
531
|
+
private readonly coverageGroups_;
|
|
532
|
+
private state_;
|
|
533
|
+
private attached_;
|
|
534
|
+
private readonly callbacks_;
|
|
535
|
+
private opacity_;
|
|
536
|
+
blendMode: BlendMode;
|
|
537
|
+
constructor({ opacity, blendMode }?: LayerProps);
|
|
538
|
+
get opacity(): number;
|
|
539
|
+
set opacity(value: number);
|
|
540
|
+
abstract update(viewport?: Viewport): void;
|
|
541
|
+
onEvent(_: EventContext): void;
|
|
542
|
+
onAttached(context: IdetikContext): void;
|
|
543
|
+
onDetached(context: IdetikContext): void;
|
|
544
|
+
protected attach(_context: IdetikContext): void;
|
|
545
|
+
protected detach(_context: IdetikContext): void;
|
|
546
|
+
get coverageGroups(): ReadonlyMap<number | null, readonly RenderableObject[]>;
|
|
547
|
+
get state(): LayerState;
|
|
548
|
+
addStateChangeCallback(callback: StateChangeCallback): void;
|
|
549
|
+
removeStateChangeCallback(callback: StateChangeCallback): void;
|
|
550
|
+
protected setState(newState: LayerState): void;
|
|
551
|
+
protected addObject(object: RenderableObject, coverageGroup?: number | null): void;
|
|
552
|
+
protected clearObjects(): void;
|
|
553
|
+
/**
|
|
554
|
+
* Get uniforms for shader program. Override in derived classes that need custom uniforms.
|
|
555
|
+
* @returns Object containing uniform name-value pairs
|
|
556
|
+
*/
|
|
557
|
+
getUniforms(): Record<string, unknown>;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
type OrthographicCameraFrame = {
|
|
561
|
+
left: number;
|
|
562
|
+
right: number;
|
|
563
|
+
top: number;
|
|
564
|
+
bottom: number;
|
|
565
|
+
};
|
|
566
|
+
type OrthographicCameraProps = OrthographicCameraFrame & {
|
|
504
567
|
near?: number;
|
|
505
568
|
far?: number;
|
|
506
569
|
orientation?: SliceOrientation;
|
|
@@ -529,17 +592,14 @@ declare class OrthographicCamera extends Camera {
|
|
|
529
592
|
/**
|
|
530
593
|
* Creates an orthographic camera framing the given world-space rectangle.
|
|
531
594
|
*
|
|
532
|
-
* @param
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
* @param bottom - Bottom edge of the view frame, in world units.
|
|
536
|
-
* @param options - Near/far clipping plane distances (default `-1e6` and
|
|
537
|
-
* `1e6`) and the slice orientation the camera faces (default `"XY"`).
|
|
595
|
+
* @param props - The view frame edges in world units, near/far clipping
|
|
596
|
+
* plane distances (default `-1e6` and `1e6`), and the slice orientation
|
|
597
|
+
* the camera faces (default `"XY"`).
|
|
538
598
|
*/
|
|
539
|
-
constructor(
|
|
599
|
+
constructor(props: OrthographicCameraProps);
|
|
540
600
|
get viewportSize(): [number, number];
|
|
541
601
|
setAspectRatio(aspectRatio: number): void;
|
|
542
|
-
setFrame(left
|
|
602
|
+
setFrame({ left, right, top, bottom }: OrthographicCameraFrame): void;
|
|
543
603
|
get type(): CameraType;
|
|
544
604
|
get orientation(): SliceOrientation;
|
|
545
605
|
/**
|
|
@@ -612,84 +672,6 @@ declare class Viewport {
|
|
|
612
672
|
private updateAspectRatio;
|
|
613
673
|
}
|
|
614
674
|
|
|
615
|
-
/** @group Layers */
|
|
616
|
-
type LayerState = "initialized" | "loading" | "ready";
|
|
617
|
-
type BlendMode = "none" | "normal" | "additive" | "subtractive" | "multiply" | "premultiplied";
|
|
618
|
-
type StateChangeCallback = (newState: LayerState, prevState?: LayerState) => void;
|
|
619
|
-
interface LayerProps {
|
|
620
|
-
opacity?: number;
|
|
621
|
-
blendMode?: BlendMode;
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* Abstract base class for everything that can be added to a viewport.
|
|
625
|
-
*
|
|
626
|
-
* A `Layer` owns a set of renderable objects and contributes them to the scene
|
|
627
|
-
* each frame. Subclasses (e.g. {@link ImageLayer}, {@link VolumeLayer},
|
|
628
|
-
* {@link LabelLayer}) implement {@link Layer.update} to build or refresh those
|
|
629
|
-
* objects for the current view, and may override the `attach`/`detach` hooks to
|
|
630
|
-
* acquire and release resources when the layer joins or leaves a viewport.
|
|
631
|
-
*
|
|
632
|
-
* Layers carry shared presentation state — {@link Layer.opacity} and blend mode —
|
|
633
|
-
* and expose a lifecycle {@link LayerState} (`initialized` → `loading` → `ready`)
|
|
634
|
-
* that observers can subscribe to. A layer instance may be attached to only one
|
|
635
|
-
* viewport at a time.
|
|
636
|
-
*
|
|
637
|
-
* @group Layers
|
|
638
|
-
*/
|
|
639
|
-
declare abstract class Layer {
|
|
640
|
-
abstract readonly type: string;
|
|
641
|
-
private readonly coverageGroups_;
|
|
642
|
-
private state_;
|
|
643
|
-
private attached_;
|
|
644
|
-
private readonly callbacks_;
|
|
645
|
-
private opacity_;
|
|
646
|
-
blendMode: BlendMode;
|
|
647
|
-
constructor({ opacity, blendMode }?: LayerProps);
|
|
648
|
-
get opacity(): number;
|
|
649
|
-
set opacity(value: number);
|
|
650
|
-
abstract update(viewport?: Viewport): void;
|
|
651
|
-
onEvent(_: EventContext): void;
|
|
652
|
-
onAttached(context: IdetikContext): void;
|
|
653
|
-
onDetached(context: IdetikContext): void;
|
|
654
|
-
protected attach(_context: IdetikContext): void;
|
|
655
|
-
protected detach(_context: IdetikContext): void;
|
|
656
|
-
get coverageGroups(): ReadonlyMap<number | null, readonly RenderableObject[]>;
|
|
657
|
-
get state(): LayerState;
|
|
658
|
-
addStateChangeCallback(callback: StateChangeCallback): void;
|
|
659
|
-
removeStateChangeCallback(callback: StateChangeCallback): void;
|
|
660
|
-
protected setState(newState: LayerState): void;
|
|
661
|
-
protected addObject(object: RenderableObject, coverageGroup?: number | null): void;
|
|
662
|
-
protected clearObjects(): void;
|
|
663
|
-
/**
|
|
664
|
-
* Get uniforms for shader program. Override in derived classes that need custom uniforms.
|
|
665
|
-
* @returns Object containing uniform name-value pairs
|
|
666
|
-
*/
|
|
667
|
-
getUniforms(): Record<string, unknown>;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
declare abstract class Renderer {
|
|
671
|
-
private readonly canvas_;
|
|
672
|
-
private width_;
|
|
673
|
-
private height_;
|
|
674
|
-
protected renderedObjects_: number;
|
|
675
|
-
protected abstract resize(width: number, height: number): void;
|
|
676
|
-
protected abstract renderObject(layer: Layer, object: RenderableObject, camera: Camera): void;
|
|
677
|
-
protected abstract clear(): void;
|
|
678
|
-
constructor(canvas: HTMLCanvasElement);
|
|
679
|
-
beginFrame(): void;
|
|
680
|
-
abstract render(viewport: Viewport): void;
|
|
681
|
-
updateSize(): void;
|
|
682
|
-
private updateRendererSize;
|
|
683
|
-
protected get canvas(): HTMLCanvasElement;
|
|
684
|
-
get width(): number;
|
|
685
|
-
get height(): number;
|
|
686
|
-
get renderedObjects(): number;
|
|
687
|
-
abstract get gpuTextureBytes(): number;
|
|
688
|
-
abstract get gpuTextureCount(): number;
|
|
689
|
-
abstract uploadTexture(texture: Texture): void;
|
|
690
|
-
abstract disposeTexture(texture: Texture): void;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
675
|
/** @group Runtime */
|
|
694
676
|
type Overlay = {
|
|
695
677
|
update(idetik: Idetik): void;
|
|
@@ -754,7 +736,7 @@ declare class Idetik {
|
|
|
754
736
|
*
|
|
755
737
|
* @example
|
|
756
738
|
* // Single viewport (element defaults to canvas)
|
|
757
|
-
* const camera = new OrthographicCamera(0, 1024, 0, 1024);
|
|
739
|
+
* const camera = new OrthographicCamera({ left: 0, right: 1024, top: 0, bottom: 1024 });
|
|
758
740
|
* const idetik = new Idetik({
|
|
759
741
|
* canvas: document.querySelector('canvas')!,
|
|
760
742
|
* viewports: [{
|
|
@@ -786,7 +768,7 @@ declare class Idetik {
|
|
|
786
768
|
*
|
|
787
769
|
* @throws {Error} If viewports have duplicate IDs or shared elements
|
|
788
770
|
*/
|
|
789
|
-
constructor(params: IdetikProps
|
|
771
|
+
constructor(params: IdetikProps);
|
|
790
772
|
get chunkQueueStats(): QueueStats;
|
|
791
773
|
get memoryStats(): MemoryStats;
|
|
792
774
|
get renderedObjects(): number;
|
|
@@ -1497,7 +1479,7 @@ interface PointPickingResult {
|
|
|
1497
1479
|
type ImageLayerProps = LayerProps & {
|
|
1498
1480
|
source: ChunkSource;
|
|
1499
1481
|
sliceCoords: SliceCoordinates;
|
|
1500
|
-
policy
|
|
1482
|
+
policy?: ImageSourcePolicy;
|
|
1501
1483
|
orientation?: SliceOrientation;
|
|
1502
1484
|
channelProps?: ChannelProps[];
|
|
1503
1485
|
onPickValue?: (info: PointPickingResult) => void;
|
|
@@ -1581,7 +1563,7 @@ declare class ImageLayer extends Layer implements ChannelsEnabled {
|
|
|
1581
1563
|
type VolumeLayerProps = {
|
|
1582
1564
|
source: ChunkSource;
|
|
1583
1565
|
sliceCoords: SliceCoordinates;
|
|
1584
|
-
policy
|
|
1566
|
+
policy?: ImageSourcePolicy;
|
|
1585
1567
|
channelProps?: ChannelProps[];
|
|
1586
1568
|
};
|
|
1587
1569
|
/** @group Layers */
|
|
@@ -1666,7 +1648,7 @@ declare class LabelImageRenderable extends RenderableObject {
|
|
|
1666
1648
|
type LabelLayerProps = LayerProps & {
|
|
1667
1649
|
source: ChunkSource;
|
|
1668
1650
|
sliceCoords: SliceCoordinates;
|
|
1669
|
-
policy
|
|
1651
|
+
policy?: ImageSourcePolicy;
|
|
1670
1652
|
orientation?: SliceOrientation;
|
|
1671
1653
|
colorMap?: LabelColorMapProps;
|
|
1672
1654
|
onPickValue?: (info: PointPickingResult) => void;
|
|
@@ -1726,6 +1708,12 @@ declare class LabelLayer extends Layer {
|
|
|
1726
1708
|
private releaseAndRemoveChunks;
|
|
1727
1709
|
}
|
|
1728
1710
|
|
|
1711
|
+
type ImageRenderableProps = {
|
|
1712
|
+
width: number;
|
|
1713
|
+
height: number;
|
|
1714
|
+
texture: Texture;
|
|
1715
|
+
channelProps?: ChannelProps[];
|
|
1716
|
+
};
|
|
1729
1717
|
type UniformValues = {
|
|
1730
1718
|
u_color: vec3;
|
|
1731
1719
|
u_imageSampler: number;
|
|
@@ -1738,7 +1726,7 @@ type UniformValues = {
|
|
|
1738
1726
|
declare class ImageRenderable extends RenderableObject {
|
|
1739
1727
|
private channels_;
|
|
1740
1728
|
worldToTexCoord: mat4;
|
|
1741
|
-
constructor(width
|
|
1729
|
+
constructor({ width, height, texture, channelProps, }: ImageRenderableProps);
|
|
1742
1730
|
get type(): string;
|
|
1743
1731
|
setChannelProps(channels: ChannelProps[]): void;
|
|
1744
1732
|
setChannelProperty<K extends keyof ChannelProps>(channelIndex: number, property: K, value: Required<ChannelProps>[K]): void;
|
|
@@ -1785,13 +1773,16 @@ declare class ProjectedLineRenderable extends RenderableObject {
|
|
|
1785
1773
|
};
|
|
1786
1774
|
}
|
|
1787
1775
|
|
|
1776
|
+
type VolumeRenderableProps = {
|
|
1777
|
+
channelProps?: ChannelProps[];
|
|
1778
|
+
};
|
|
1788
1779
|
/** @group Renderable Objects */
|
|
1789
1780
|
declare class VolumeRenderable extends RenderableObject {
|
|
1790
1781
|
voxelScale: vec3;
|
|
1791
1782
|
private channels_;
|
|
1792
1783
|
private loadedChannels_;
|
|
1793
1784
|
private readonly channelToTextureIndex_;
|
|
1794
|
-
constructor();
|
|
1785
|
+
constructor({ channelProps }?: VolumeRenderableProps);
|
|
1795
1786
|
get type(): string;
|
|
1796
1787
|
updateVolumeWithChunk(chunk: Chunk): void;
|
|
1797
1788
|
private addChannelTexture;
|
|
@@ -1818,7 +1809,7 @@ type PerspectiveCameraProps = {
|
|
|
1818
1809
|
declare class PerspectiveCamera extends Camera {
|
|
1819
1810
|
private fov_;
|
|
1820
1811
|
private aspectRatio_;
|
|
1821
|
-
constructor(
|
|
1812
|
+
constructor(props?: PerspectiveCameraProps);
|
|
1822
1813
|
setAspectRatio(aspectRatio: number): void;
|
|
1823
1814
|
get type(): CameraType;
|
|
1824
1815
|
get fov(): number;
|