@aics/vole-core 3.15.3 → 3.15.4
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/es/ThreeJsPanel.js +4 -0
- package/es/View3d.js +20 -1
- package/es/Volume.js +21 -4
- package/es/types/ThreeJsPanel.d.ts +2 -0
- package/es/types/View3d.d.ts +13 -0
- package/es/types/Volume.d.ts +21 -4
- package/package.json +1 -1
package/es/ThreeJsPanel.js
CHANGED
|
@@ -594,6 +594,7 @@ export class ThreeJsPanel {
|
|
|
594
594
|
const delta = this.timer.lastFrameMs / 1000.0;
|
|
595
595
|
this.controls.update(delta);
|
|
596
596
|
this.render();
|
|
597
|
+
this.onRenderCallback?.();
|
|
597
598
|
}
|
|
598
599
|
startRenderLoop() {
|
|
599
600
|
this.inRenderLoop = true;
|
|
@@ -610,6 +611,9 @@ export class ThreeJsPanel {
|
|
|
610
611
|
}
|
|
611
612
|
this.timer.end();
|
|
612
613
|
}
|
|
614
|
+
setOnRenderCallback(callback) {
|
|
615
|
+
this.onRenderCallback = callback ?? undefined;
|
|
616
|
+
}
|
|
613
617
|
removeControlHandlers() {
|
|
614
618
|
if (this.controlStartHandler) {
|
|
615
619
|
this.controls.removeEventListener("start", this.controlStartHandler);
|
package/es/View3d.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AmbientLight, Vector3, Object3D, SpotLight, DirectionalLight, Euler, Scene, Color } from "three";
|
|
1
|
+
import { AmbientLight, Vector3, Object3D, SpotLight, DirectionalLight, Euler, Scene, Color, Matrix4 } from "three";
|
|
2
2
|
import { Pane } from "tweakpane";
|
|
3
3
|
import { MESH_LAYER, ThreeJsPanel } from "./ThreeJsPanel.js";
|
|
4
4
|
import lightSettings from "./constants/lights.js";
|
|
@@ -107,6 +107,18 @@ export class View3d {
|
|
|
107
107
|
this.redraw();
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Returns the view projection matrix, which transforms from world coordinates
|
|
112
|
+
* to clip space coordinates.
|
|
113
|
+
*
|
|
114
|
+
* 3D coordinates within the camera's view frustum will be transformed to a
|
|
115
|
+
* [-1, 1] range in the X and Y axes, and a [0, 1] range in the Z axis.
|
|
116
|
+
*/
|
|
117
|
+
getViewProjectionMatrix() {
|
|
118
|
+
const camera = this.canvas3d.camera;
|
|
119
|
+
return new Matrix4().multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
120
|
+
}
|
|
121
|
+
|
|
110
122
|
/**
|
|
111
123
|
* Force a redraw.
|
|
112
124
|
* @param synchronous If true, the redraw will be done synchronously. If false (default), the
|
|
@@ -120,6 +132,13 @@ export class View3d {
|
|
|
120
132
|
this.canvas3d.redraw();
|
|
121
133
|
}
|
|
122
134
|
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Sets a listener that will be called after the 3D canvas renders.
|
|
138
|
+
*/
|
|
139
|
+
setOnRenderCallback(callback) {
|
|
140
|
+
this.canvas3d.setOnRenderCallback(callback);
|
|
141
|
+
}
|
|
123
142
|
unsetImage() {
|
|
124
143
|
if (this.image) {
|
|
125
144
|
this.canvas3d.removeControlHandlers();
|
package/es/Volume.js
CHANGED
|
@@ -14,13 +14,30 @@ export default class Volume {
|
|
|
14
14
|
* Used to intelligently issue load requests whenever required by a state change. Modify with `updateRequiredData`.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* The maximum of the measurements of 3 axes in physical units.
|
|
19
|
+
*
|
|
20
|
+
* Equivalent to `Math.max(physicalSize.x, physicalSize.y, physicalSize.z)`.
|
|
21
|
+
*/
|
|
18
22
|
|
|
19
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* The size of a voxel in the original level 0 volume in real-world (physical)
|
|
25
|
+
* units (e.g. μm).
|
|
26
|
+
*/
|
|
20
27
|
|
|
21
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* The dimensions of the whole volume (not accounting for subregion) in
|
|
30
|
+
* real-world (physical) units. Equivalent to `imageInfo.originalSize *
|
|
31
|
+
* physicalPixelSize`.
|
|
32
|
+
*/
|
|
22
33
|
|
|
23
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Physical size of the whole volume (not accounting for subregion) normalized
|
|
36
|
+
* along the largest axis, so that all dimensions are `<= 1`.
|
|
37
|
+
*
|
|
38
|
+
* Example: If the physical size is `[100, 50, 25]` μm, then the
|
|
39
|
+
* normPhysicalSize will be `[1, 0.5, 0.25]`.
|
|
40
|
+
*/
|
|
24
41
|
|
|
25
42
|
constructor(imageInfo = defaultImageInfo(), loadSpec = new LoadSpec(), loader) {
|
|
26
43
|
this.loaded = false;
|
|
@@ -54,6 +54,7 @@ export declare class ThreeJsPanel {
|
|
|
54
54
|
private timestepIndicatorElement;
|
|
55
55
|
showTimestepIndicator: boolean;
|
|
56
56
|
private dataurlcallback?;
|
|
57
|
+
private onRenderCallback?;
|
|
57
58
|
constructor(parentElement: HTMLElement | undefined, _useWebGL2: boolean);
|
|
58
59
|
updateCameraFocus(fov: number, _focalDistance: number, _apertureSize: number): void;
|
|
59
60
|
resetPerspectiveCamera(): void;
|
|
@@ -103,6 +104,7 @@ export declare class ThreeJsPanel {
|
|
|
103
104
|
onAnimationLoop(): void;
|
|
104
105
|
startRenderLoop(): void;
|
|
105
106
|
stopRenderLoop(): void;
|
|
107
|
+
setOnRenderCallback(callback: (() => void) | null): void;
|
|
106
108
|
removeControlHandlers(): void;
|
|
107
109
|
setControlHandlers(onstart: EventListener<Event, "start", TrackballControls>, onchange: EventListener<Event, "change", TrackballControls>, onend: EventListener<Event, "end", TrackballControls>): void;
|
|
108
110
|
hitTest(offsetX: number, offsetY: number, pickBuffer: WebGLRenderTarget | undefined): number;
|
package/es/types/View3d.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Matrix4 } from "three";
|
|
1
2
|
import { CameraState } from "./ThreeJsPanel.js";
|
|
2
3
|
import VolumeDrawable from "./VolumeDrawable.js";
|
|
3
4
|
import { Light } from "./Light.js";
|
|
@@ -53,6 +54,14 @@ export declare class View3d {
|
|
|
53
54
|
getCanvasDOMElement(): HTMLCanvasElement;
|
|
54
55
|
getCameraState(): CameraState;
|
|
55
56
|
setCameraState(transform: Partial<CameraState>): void;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the view projection matrix, which transforms from world coordinates
|
|
59
|
+
* to clip space coordinates.
|
|
60
|
+
*
|
|
61
|
+
* 3D coordinates within the camera's view frustum will be transformed to a
|
|
62
|
+
* [-1, 1] range in the X and Y axes, and a [0, 1] range in the Z axis.
|
|
63
|
+
*/
|
|
64
|
+
getViewProjectionMatrix(): Matrix4;
|
|
56
65
|
/**
|
|
57
66
|
* Force a redraw.
|
|
58
67
|
* @param synchronous If true, the redraw will be done synchronously. If false (default), the
|
|
@@ -60,6 +69,10 @@ export declare class View3d {
|
|
|
60
69
|
* whenever possible for the best performance.
|
|
61
70
|
*/
|
|
62
71
|
redraw(synchronous?: boolean): void;
|
|
72
|
+
/**
|
|
73
|
+
* Sets a listener that will be called after the 3D canvas renders.
|
|
74
|
+
*/
|
|
75
|
+
setOnRenderCallback(callback: (() => void) | null): void;
|
|
63
76
|
unsetImage(): VolumeDrawable | undefined;
|
|
64
77
|
/**
|
|
65
78
|
* Add a new volume image to the viewer. (The viewer currently only supports a single image at a time - adding repeatedly, without removing in between, is a potential resource leak)
|
package/es/types/Volume.d.ts
CHANGED
|
@@ -30,13 +30,30 @@ export default class Volume {
|
|
|
30
30
|
numChannels: number;
|
|
31
31
|
channelNames: string[];
|
|
32
32
|
channelColorsDefault: [number, number, number][];
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* The maximum of the measurements of 3 axes in physical units.
|
|
35
|
+
*
|
|
36
|
+
* Equivalent to `Math.max(physicalSize.x, physicalSize.y, physicalSize.z)`.
|
|
37
|
+
*/
|
|
34
38
|
physicalScale: number;
|
|
35
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* The size of a voxel in the original level 0 volume in real-world (physical)
|
|
41
|
+
* units (e.g. μm).
|
|
42
|
+
*/
|
|
36
43
|
physicalPixelSize: Vector3;
|
|
37
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* The dimensions of the whole volume (not accounting for subregion) in
|
|
46
|
+
* real-world (physical) units. Equivalent to `imageInfo.originalSize *
|
|
47
|
+
* physicalPixelSize`.
|
|
48
|
+
*/
|
|
38
49
|
physicalSize: Vector3;
|
|
39
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Physical size of the whole volume (not accounting for subregion) normalized
|
|
52
|
+
* along the largest axis, so that all dimensions are `<= 1`.
|
|
53
|
+
*
|
|
54
|
+
* Example: If the physical size is `[100, 50, 25]` μm, then the
|
|
55
|
+
* normPhysicalSize will be `[1, 0.5, 0.25]`.
|
|
56
|
+
*/
|
|
40
57
|
normPhysicalSize: Vector3;
|
|
41
58
|
normRegionSize: Vector3;
|
|
42
59
|
normRegionOffset: Vector3;
|