@kitware/vtk.js 30.10.0 → 31.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -104,17 +104,18 @@ function vtkFullScreenRenderWindow(publicAPI, model) {
|
|
|
104
104
|
publicAPI.toggleControllerVisibility = () => {
|
|
105
105
|
publicAPI.setControllerVisibility(!model.controllerVisibility);
|
|
106
106
|
};
|
|
107
|
+
function handleKeypress(e) {
|
|
108
|
+
if (String.fromCharCode(e.charCode) === 'c') {
|
|
109
|
+
publicAPI.toggleControllerVisibility();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
107
112
|
publicAPI.addController = html => {
|
|
108
113
|
model.controlContainer = document.createElement('div');
|
|
109
114
|
applyStyle(model.controlContainer, model.controlPanelStyle || STYLE_CONTROL_PANEL);
|
|
110
115
|
model.rootContainer.appendChild(model.controlContainer);
|
|
111
116
|
model.controlContainer.innerHTML = html;
|
|
112
117
|
publicAPI.setControllerVisibility(model.controllerVisibility);
|
|
113
|
-
model.rootContainer.addEventListener('keypress',
|
|
114
|
-
if (String.fromCharCode(e.charCode) === 'c') {
|
|
115
|
-
publicAPI.toggleControllerVisibility();
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
+
model.rootContainer.addEventListener('keypress', handleKeypress);
|
|
118
119
|
};
|
|
119
120
|
|
|
120
121
|
// Update BG color
|
|
@@ -131,7 +132,10 @@ function vtkFullScreenRenderWindow(publicAPI, model) {
|
|
|
131
132
|
};
|
|
132
133
|
|
|
133
134
|
// Properly release GL context
|
|
134
|
-
publicAPI.delete = macro.chain(publicAPI.setContainer, model.apiSpecificRenderWindow.delete,
|
|
135
|
+
publicAPI.delete = macro.chain(publicAPI.setContainer, model.apiSpecificRenderWindow.delete, () => {
|
|
136
|
+
model.rootContainer?.removeEventListener('keypress', handleKeypress);
|
|
137
|
+
window.removeEventListener('resize', publicAPI.resize);
|
|
138
|
+
}, publicAPI.delete);
|
|
135
139
|
|
|
136
140
|
// Handle window resize
|
|
137
141
|
publicAPI.resize = () => {
|
|
@@ -68,7 +68,9 @@ function vtkGenericRenderWindow(publicAPI, model) {
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
// Properly release GL context
|
|
71
|
-
publicAPI.delete = macro.chain(publicAPI.setContainer, model._apiSpecificRenderWindow.delete,
|
|
71
|
+
publicAPI.delete = macro.chain(publicAPI.setContainer, model._apiSpecificRenderWindow.delete, () => {
|
|
72
|
+
window.removeEventListener('resize', publicAPI.resize);
|
|
73
|
+
}, publicAPI.delete);
|
|
72
74
|
|
|
73
75
|
// Handle size
|
|
74
76
|
if (model.listenWindowResize) {
|
|
@@ -113,7 +113,7 @@ function vtkOpenGLActor(publicAPI, model) {
|
|
|
113
113
|
// Renders myself
|
|
114
114
|
publicAPI.translucentPass = (prepass, renderPass) => {
|
|
115
115
|
if (prepass) {
|
|
116
|
-
model.context.depthMask(
|
|
116
|
+
model.context.depthMask(model._openGLRenderer.getSelector() && model.renderable.getNestedPickable());
|
|
117
117
|
publicAPI.activateTextures();
|
|
118
118
|
} else if (model.activeTextures) {
|
|
119
119
|
for (let index = 0; index < model.activeTextures.length; index++) {
|
|
@@ -419,6 +419,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
419
419
|
const image = model.currentInput;
|
|
420
420
|
const dim = image.getDimensions();
|
|
421
421
|
mat4.copy(model.tmpMat4, image.getIndexToWorld());
|
|
422
|
+
mat4.translate(model.tmpMat4, model.tmpMat4, [-0.5, -0.5, -0.5]);
|
|
422
423
|
mat4.scale(model.tmpMat4, model.tmpMat4, dim);
|
|
423
424
|
mat4.invert(model.tmpMat4, model.tmpMat4);
|
|
424
425
|
if (inverseShiftScaleMatrix) {
|
|
@@ -427,7 +428,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
427
428
|
program.setUniformMatrix('WCTCMatrix', model.tmpMat4);
|
|
428
429
|
}
|
|
429
430
|
if (program.isUniformUsed('vboScaling')) {
|
|
430
|
-
program.setUniform3fv('vboScaling', cellBO.getCABO().getCoordScale());
|
|
431
|
+
program.setUniform3fv('vboScaling', cellBO.getCABO().getCoordScale() ?? [1, 1, 1]);
|
|
431
432
|
}
|
|
432
433
|
cellBO.getAttributeUpdateTime().modified();
|
|
433
434
|
}
|
|
@@ -730,15 +731,16 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
730
731
|
resGeomString = resGeomString.concat(`PolyData${slicePD.getMTime()}`);
|
|
731
732
|
} else if (slicePlane) {
|
|
732
733
|
resGeomString = resGeomString.concat(`Plane${slicePlane.getMTime()}`);
|
|
734
|
+
// Compute a world-to-image-orientation matrix.
|
|
735
|
+
const w2io = mat3.create();
|
|
733
736
|
if (image) {
|
|
734
737
|
resGeomString = resGeomString.concat(`Image${image.getMTime()}`);
|
|
738
|
+
// Ignore the translation component since we are
|
|
739
|
+
// using it on vectors rather than positions.
|
|
740
|
+
mat3.set(w2io, ...image.getDirection());
|
|
741
|
+
mat3.invert(w2io, w2io);
|
|
735
742
|
}
|
|
736
743
|
// Check to see if we can bypass oblique slicing related bounds computation
|
|
737
|
-
// Compute a world-to-image-orientation matrix.
|
|
738
|
-
// Ignore the translation component since we are
|
|
739
|
-
// using it on vectors rather than positions.
|
|
740
|
-
const w2io = mat3.fromValues(image?.getDirection());
|
|
741
|
-
mat3.invert(w2io, w2io);
|
|
742
744
|
// transform the cutting plane normal to image local coords
|
|
743
745
|
const imageLocalNormal = [...slicePlane.getNormal()];
|
|
744
746
|
vec3.transformMat3(imageLocalNormal, imageLocalNormal, w2io);
|
|
@@ -803,8 +805,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
803
805
|
const ptsArray = new Float32Array(12);
|
|
804
806
|
const indexSpacePlaneOrigin = image.worldToIndex(slicePlane.getOrigin(), [0, 0, 0]);
|
|
805
807
|
const otherAxes = [(orthoAxis + 1) % 3, (orthoAxis + 2) % 3].sort();
|
|
806
|
-
const
|
|
807
|
-
const ext = [0, dim[0] - 1, 0, dim[1] - 1, 0, dim[2] - 1];
|
|
808
|
+
const ext = image.getSpatialExtent();
|
|
808
809
|
let ptIdx = 0;
|
|
809
810
|
for (let i = 0; i < 2; ++i) {
|
|
810
811
|
for (let j = 0; j < 2; ++j) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Nullable, Size, Vector2, Vector3 } from './../../types';
|
|
2
|
+
import { vtkAlgorithm } from './../../interfaces';
|
|
2
3
|
import { VtkDataTypes } from './../../Common/Core/DataArray';
|
|
3
|
-
import { vtkAlgorithm, vtkObject } from './../../interfaces';
|
|
4
4
|
import vtkBufferObject from './BufferObject';
|
|
5
5
|
import vtkCellArray from './../../Common/Core/CellArray';
|
|
6
6
|
import vtkDataArray from './../../Common/Core/DataArray';
|
|
@@ -8,6 +8,7 @@ import vtkOpenGLTexture from './Texture';
|
|
|
8
8
|
import vtkPoints from './../../Common/Core/Points';
|
|
9
9
|
import vtkRenderer from './../Core/Renderer';
|
|
10
10
|
import vtkTexture from './../Core/Texture';
|
|
11
|
+
import vtkViewNode from './../SceneGraph/ViewNode';
|
|
11
12
|
import vtkViewStream from './../../IO/Core/ImageStream/ViewStream';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -41,18 +42,7 @@ export interface ICaptureOptions {
|
|
|
41
42
|
scale?: number;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
Omit<
|
|
46
|
-
vtkAlgorithm,
|
|
47
|
-
| 'getInputData'
|
|
48
|
-
| 'setInputData'
|
|
49
|
-
| 'setInputConnection'
|
|
50
|
-
| 'getInputConnection'
|
|
51
|
-
| 'addInputConnection'
|
|
52
|
-
| 'addInputData'
|
|
53
|
-
>;
|
|
54
|
-
|
|
55
|
-
export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
|
|
45
|
+
export interface vtkOpenGLRenderWindow extends vtkViewNode {
|
|
56
46
|
/**
|
|
57
47
|
* Builds myself.
|
|
58
48
|
* @param {Boolean} prepass
|
|
@@ -98,6 +88,11 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
|
|
|
98
88
|
*/
|
|
99
89
|
getCanvas(): Nullable<HTMLCanvasElement>;
|
|
100
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Set the webgl canvas.
|
|
93
|
+
*/
|
|
94
|
+
setCanvas(canvas: Nullable<HTMLCanvasElement>): boolean;
|
|
95
|
+
|
|
101
96
|
/**
|
|
102
97
|
* Check if a point is in the viewport.
|
|
103
98
|
* @param {Number} x The x coordinate.
|