@kitware/vtk.js 28.13.1 → 29.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BREAKING_CHANGES.md +7 -0
- package/Common/Core/Math/index.js +1 -1
- package/Common/Core/Math.js +1 -1
- package/Proxy/Core/ViewProxy.d.ts +2 -1
- package/Rendering/Core/CellPicker.d.ts +11 -0
- package/Rendering/Core/CellPicker.js +112 -4
- package/Rendering/Core/ColorTransferFunction.js +1 -1
- package/Rendering/Core/Coordinate.js +1 -1
- package/Rendering/Core/CubeAxesActor.js +1 -1
- package/Rendering/Core/ImageMapper.js +1 -1
- package/Rendering/Core/Picker.js +26 -2
- package/Rendering/Core/PointPicker.js +1 -1
- package/Rendering/Core/RenderWindow.d.ts +1 -0
- package/Rendering/Core/Renderer.js +1 -1
- package/Rendering/Core/ScalarBarActor.js +1 -1
- package/Rendering/Core/VolumeMapper.js +1 -1
- package/Rendering/Misc/FullScreenRenderWindow.d.ts +4 -1
- package/Rendering/Misc/FullScreenRenderWindow.js +2 -1
- package/Rendering/Misc/GenericRenderWindow.d.ts +3 -2
- package/Rendering/Misc/GenericRenderWindow.js +11 -9
- package/Rendering/OpenGL/PolyDataMapper2D.js +1 -1
- package/Rendering/OpenGL/RenderWindow.d.ts +0 -34
- package/Rendering/OpenGL/RenderWindow.js +2 -177
- package/Rendering/OpenGL/Texture.js +1 -1
- package/Rendering/OpenGL/VolumeMapper.js +4 -4
- package/Rendering/WebGPU/RenderWindow.js +12 -0
- package/Rendering/{OpenGL/RenderWindow → WebXR/RenderWindowHelper}/Constants.d.ts +2 -1
- package/Rendering/WebXR/RenderWindowHelper.d.ts +90 -0
- package/Rendering/WebXR/RenderWindowHelper.js +242 -0
- package/Widgets/Core/WidgetManager.d.ts +0 -24
- package/Widgets/Core/WidgetManager.js +5 -29
- package/Widgets/Widgets3D/AngleWidget.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
- package/Widgets/Widgets3D.js +0 -2
- package/index.d.ts +2 -1
- package/package.json +2 -1
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +0 -133
- package/Widgets/Widgets3D/DistanceWidget/state.js +0 -22
- package/Widgets/Widgets3D/DistanceWidget.js +0 -109
- /package/Rendering/{OpenGL/RenderWindow → WebXR/RenderWindowHelper}/Constants.js +0 -0
package/BREAKING_CHANGES.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## From 28.x to 29
|
|
2
|
+
|
|
3
|
+
- **getOpenGLRenderWindow**: `getOpenGLRenderWindow` has been renamed to `getApiSpecificRenderWindow` in `vtkFullScreenRenderWindow`, `vtkGenericRenderWindow` and `vtkViewProxy` to support WebGL and WebGPU backend. ([#2816](https://github.com/Kitware/vtk-js/pull/2816))
|
|
4
|
+
- **WidgetManager**: Deprecated APIs have been fully removed. ([#2910](https://github.com/Kitware/vtk-js/pull/2910))
|
|
5
|
+
- **OpenGLRenderWindow**: WebXR API has been moved into a WebXR RenderWindowHelper. ([#2924](https://github.com/Kitware/vtk-js/pull/2924))
|
|
6
|
+
- **DistanceWidget**: Removed from vtk.js in favor of vtkLineWidget ([#2945](https://github.com/Kitware/vtk-js/pull/2945))
|
|
7
|
+
|
|
1
8
|
## From 27.x to 28
|
|
2
9
|
|
|
3
10
|
- **vtkManipulator.handleEvent**: Change all `handleEvent` signatures of manipulators. Used to be `handleEvent(callData, glRenderWindow): vec3`, it is now `handleEvent(callData, glRenderWindow): { worldCoords: Nullable<vec3>, worldDirection?: mat3 }`.
|
|
@@ -2245,4 +2245,4 @@ var vtkMath$1 = /*#__PURE__*/Object.freeze({
|
|
|
2245
2245
|
'default': vtkMath
|
|
2246
2246
|
});
|
|
2247
2247
|
|
|
2248
|
-
export {
|
|
2248
|
+
export { arrayMax as $, degreesFromRadians as A, areEquals as B, clampValue as C, arrayRange as D, getMajorAxisIndex as E, createUninitializedBounds as F, isIdentity3x3 as G, floor as H, isInf as I, rgb2hsv as J, rgb2lab as K, lab2rgb as L, round as M, normalize2D as N, nearestPowerOfTwo as O, multiply3x3_vect3 as P, getSparseOrthogonalMatrix as Q, areBoundsInitialized as R, isPowerOfTwo as S, angleBetweenVectors as T, signedAngleBetweenVectors as U, createArray as V, Pi as W, ceil as X, min as Y, max as Z, arrayMin as _, areMatricesEqual as a, float2CssRGBA as a$, ceilLog2 as a0, factorial as a1, binomial as a2, beginCombination as a3, nextCombination as a4, randomSeed as a5, getSeed as a6, gaussian as a7, multiplyScalar2D as a8, multiplyAccumulate2D as a9, diagonalize3x3 as aA, singularValueDecomposition3x3 as aB, luFactorLinearSystem as aC, luSolveLinearSystem as aD, invertMatrix as aE, estimateMatrixCondition as aF, solveHomogeneousLeastSquares as aG, solveLeastSquares as aH, hex2float as aI, lab2xyz as aJ, xyz2lab as aK, xyz2rgb as aL, rgb2xyz as aM, computeBoundsFromPoints as aN, clampAndNormalizeValue as aO, getScalarTypeFittingRange as aP, getAdjustedScalarRange as aQ, extentIsWithinOtherExtent as aR, boundsIsWithinOtherBounds as aS, pointIsWithinBounds as aT, solve3PointCircle as aU, inf as aV, negInf as aW, isFinite as aX, isNaN as aY, floatToHex2 as aZ, floatRGB2HexCode as a_, outer as aa, projectVector as ab, dot2D as ac, projectVector2D as ad, gaussianAmplitude as ae, gaussianWeight as af, outer2D as ag, norm2D as ah, rowsToMat4 as ai, columnsToMat4 as aj, columnsToMat3 as ak, LUFactor3x3 as al, LUSolve3x3 as am, linearSolve3x3 as an, multiply3x3_mat3 as ao, multiplyMatrix as ap, transpose3x3 as aq, invert3x3 as ar, identity3x3 as as, identity as at, isIdentity as au, quaternionToMatrix3x3 as av, roundNumber as aw, matrix3x3ToQuaternion as ax, multiplyQuaternion as ay, orthogonalize3x3 as az, roundVector as b, clampVector as c, dot as d, distance2BetweenPoints as e, vtkMath as f, solveLinearSystem as g, hsv2rgb as h, isNan as i, cross as j, add as k, normalize as l, multiplyAccumulate as m, norm as n, determinant2x2 as o, jacobiN as p, perpendiculars as q, radiansFromDegrees as r, subtract as s, jacobi as t, uninitializeBounds as u, vtkMath$1 as v, multiplyScalar as w, random as x, determinant3x3 as y, rowsToMat3 as z };
|
package/Common/Core/Math.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'seedrandom';
|
|
2
2
|
import '../../macros2.js';
|
|
3
3
|
import './Math/Constants.js';
|
|
4
|
-
export {
|
|
4
|
+
export { al as LUFactor3x3, am as LUSolve3x3, W as Pi, k as add, T as angleBetweenVectors, R as areBoundsInitialized, B as areEquals, a as areMatricesEqual, $ as arrayMax, _ as arrayMin, D as arrayRange, a3 as beginCombination, a2 as binomial, aS as boundsIsWithinOtherBounds, X as ceil, a0 as ceilLog2, aO as clampAndNormalizeValue, C as clampValue, c as clampVector, ak as columnsToMat3, aj as columnsToMat4, aN as computeBoundsFromPoints, V as createArray, F as createUninitializedBounds, j as cross, f as default, A as degreesFromRadians, o as determinant2x2, y as determinant3x3, aA as diagonalize3x3, e as distance2BetweenPoints, d as dot, ac as dot2D, aF as estimateMatrixCondition, aR as extentIsWithinOtherExtent, a1 as factorial, a$ as float2CssRGBA, a_ as floatRGB2HexCode, aZ as floatToHex2, H as floor, a7 as gaussian, ae as gaussianAmplitude, af as gaussianWeight, aQ as getAdjustedScalarRange, E as getMajorAxisIndex, aP as getScalarTypeFittingRange, a6 as getSeed, Q as getSparseOrthogonalMatrix, aI as hex2float, h as hsv2rgb, at as identity, as as identity3x3, aV as inf, ar as invert3x3, aE as invertMatrix, aX as isFinite, au as isIdentity, G as isIdentity3x3, I as isInf, aY as isNaN, i as isNan, S as isPowerOfTwo, t as jacobi, p as jacobiN, L as lab2rgb, aJ as lab2xyz, an as linearSolve3x3, aC as luFactorLinearSystem, aD as luSolveLinearSystem, ax as matrix3x3ToQuaternion, Z as max, Y as min, ao as multiply3x3_mat3, P as multiply3x3_vect3, m as multiplyAccumulate, a9 as multiplyAccumulate2D, ap as multiplyMatrix, ay as multiplyQuaternion, w as multiplyScalar, a8 as multiplyScalar2D, O as nearestPowerOfTwo, aW as negInf, a4 as nextCombination, n as norm, ah as norm2D, l as normalize, N as normalize2D, az as orthogonalize3x3, aa as outer, ag as outer2D, q as perpendiculars, aT as pointIsWithinBounds, ab as projectVector, ad as projectVector2D, av as quaternionToMatrix3x3, r as radiansFromDegrees, x as random, a5 as randomSeed, J as rgb2hsv, K as rgb2lab, aM as rgb2xyz, M as round, aw as roundNumber, b as roundVector, z as rowsToMat3, ai as rowsToMat4, U as signedAngleBetweenVectors, aB as singularValueDecomposition3x3, aU as solve3PointCircle, aG as solveHomogeneousLeastSquares, aH as solveLeastSquares, g as solveLinearSystem, s as subtract, aq as transpose3x3, u as uninitializeBounds, aK as xyz2lab, aL as xyz2rgb } from './Math/index.js';
|
|
@@ -8,6 +8,7 @@ import { vtkSubscription, vtkObject } from './../../interfaces';
|
|
|
8
8
|
import vtkRenderer from './../../Rendering/Core/Renderer';
|
|
9
9
|
import vtkRenderWindow from './../../Rendering/Core/RenderWindow';
|
|
10
10
|
import vtkOpenGLRenderWindow from './../../Rendering/OpenGL/RenderWindow';
|
|
11
|
+
import vtkWebGPURenderWindow from './../../Rendering/WebGPU/RenderWindow';
|
|
11
12
|
import { VtkProxy } from './../../macros';
|
|
12
13
|
|
|
13
14
|
export interface vtkViewProxy extends VtkProxy {
|
|
@@ -66,7 +67,7 @@ export interface vtkViewProxy extends VtkProxy {
|
|
|
66
67
|
getInteractor(): vtkRenderWindowInteractor;
|
|
67
68
|
getInteractorStyle2D(): vtkInteractorStyle;
|
|
68
69
|
getInteractorStyle3D(): vtkInteractorStyle;
|
|
69
|
-
|
|
70
|
+
getApiSpecificRenderWindow(): vtkOpenGLRenderWindow|vtkWebGPURenderWindow;
|
|
70
71
|
getOrientationAxesType(): string;
|
|
71
72
|
getPresetToOrientationAxes(): any;
|
|
72
73
|
getRenderer(): vtkRenderer;
|
|
@@ -13,6 +13,7 @@ export interface ICellPickerInitialValues extends IPickerInitialValues {
|
|
|
13
13
|
cellIJK?: number[];
|
|
14
14
|
pickNormal?: number[];
|
|
15
15
|
mapperNormal?: number[];
|
|
16
|
+
opacityThreshold?:number;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export interface vtkCellPicker extends vtkPicker {
|
|
@@ -42,6 +43,16 @@ export interface vtkCellPicker extends vtkPicker {
|
|
|
42
43
|
*/
|
|
43
44
|
getMapperNormalByReference(): number[];
|
|
44
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Get the opacity threshold for volume picking
|
|
48
|
+
*/
|
|
49
|
+
getOpacityThreshold(): number;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get the opacity threshold for volume picking
|
|
53
|
+
*/
|
|
54
|
+
setOpacityThreshold(value: number);
|
|
55
|
+
|
|
45
56
|
/**
|
|
46
57
|
* Get the parametric coordinates of the picked cell.
|
|
47
58
|
*/
|
|
@@ -5,9 +5,10 @@ import vtkPicker from './Picker.js';
|
|
|
5
5
|
import vtkPolyLine from '../../Common/DataModel/PolyLine.js';
|
|
6
6
|
import vtkTriangle from '../../Common/DataModel/Triangle.js';
|
|
7
7
|
import vtkQuad from '../../Common/DataModel/Quad.js';
|
|
8
|
-
import { l as normalize } from '../../Common/Core/Math/index.js';
|
|
8
|
+
import { l as normalize, G as isIdentity3x3 } from '../../Common/Core/Math/index.js';
|
|
9
9
|
import { CellType } from '../../Common/DataModel/CellTypes/Constants.js';
|
|
10
|
-
import { vec3 } from 'gl-matrix';
|
|
10
|
+
import { vec3, vec4 } from 'gl-matrix';
|
|
11
|
+
import vtkMatrixBuilder from '../../Common/Core/MatrixBuilder.js';
|
|
11
12
|
|
|
12
13
|
// ----------------------------------------------------------------------------
|
|
13
14
|
// Global methods
|
|
@@ -156,7 +157,7 @@ function vtkCellPicker(publicAPI, model) {
|
|
|
156
157
|
}
|
|
157
158
|
return pickResult;
|
|
158
159
|
};
|
|
159
|
-
publicAPI.intersectWithLine = (p1, p2, tol, mapper) => {
|
|
160
|
+
publicAPI.intersectWithLine = (p1, p2, tol, actor, mapper) => {
|
|
160
161
|
let tMin = Number.MAX_VALUE;
|
|
161
162
|
const t1 = 0.0;
|
|
162
163
|
const t2 = 1.0;
|
|
@@ -172,6 +173,8 @@ function vtkCellPicker(publicAPI, model) {
|
|
|
172
173
|
model.cellIJK = pickData.ijk;
|
|
173
174
|
model.pCoords = pickData.pCoords;
|
|
174
175
|
}
|
|
176
|
+
} else if (mapper.isA('vtkVolumeMapper')) {
|
|
177
|
+
tMin = publicAPI.intersectVolumeWithLine(p1, p2, clipLine.t1, clipLine.t2, tol, actor);
|
|
175
178
|
} else if (mapper.isA('vtkMapper')) {
|
|
176
179
|
tMin = publicAPI.intersectActorWithLine(p1, p2, t1, t2, tol, mapper);
|
|
177
180
|
}
|
|
@@ -198,6 +201,109 @@ function vtkCellPicker(publicAPI, model) {
|
|
|
198
201
|
}
|
|
199
202
|
return tMin;
|
|
200
203
|
};
|
|
204
|
+
publicAPI.intersectVolumeWithLine = (p1, p2, t1, t2, tol, volume) => {
|
|
205
|
+
let tMin = Number.MAX_VALUE;
|
|
206
|
+
const mapper = volume.getMapper();
|
|
207
|
+
const imageData = mapper.getInputData();
|
|
208
|
+
const origin = imageData.getOrigin();
|
|
209
|
+
const spacing = imageData.getSpacing();
|
|
210
|
+
const dims = imageData.getDimensions();
|
|
211
|
+
const scalars = imageData.getPointData().getScalars().getData();
|
|
212
|
+
const extent = imageData.getExtent();
|
|
213
|
+
const direction = imageData.getDirection();
|
|
214
|
+
let imageTransform;
|
|
215
|
+
if (!isIdentity3x3(direction)) {
|
|
216
|
+
imageTransform = vtkMatrixBuilder.buildFromRadian().translate(origin[0], origin[1], origin[2]).multiply3x3(direction).translate(-origin[0], -origin[1], -origin[2]).invert().getMatrix();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// calculate opacity table
|
|
220
|
+
const numIComps = 1;
|
|
221
|
+
const oWidth = 1024;
|
|
222
|
+
const tmpTable = new Float32Array(oWidth);
|
|
223
|
+
const opacityArray = new Float32Array(oWidth);
|
|
224
|
+
let ofun;
|
|
225
|
+
let oRange;
|
|
226
|
+
const sampleDist = volume.getMapper().getSampleDistance();
|
|
227
|
+
for (let c = 0; c < numIComps; ++c) {
|
|
228
|
+
ofun = volume.getProperty().getScalarOpacity(c);
|
|
229
|
+
oRange = ofun.getRange();
|
|
230
|
+
ofun.getTable(oRange[0], oRange[1], oWidth, tmpTable, 1);
|
|
231
|
+
const opacityFactor = sampleDist / volume.getProperty().getScalarOpacityUnitDistance(c);
|
|
232
|
+
|
|
233
|
+
// adjust for sample distance etc
|
|
234
|
+
for (let i = 0; i < oWidth; ++i) {
|
|
235
|
+
opacityArray[i] = 1.0 - (1.0 - tmpTable[i]) ** opacityFactor;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const scale = oWidth / (oRange[1] - oRange[0] + 1);
|
|
239
|
+
|
|
240
|
+
// Make a new p1 and p2 using the clipped t1 and t2
|
|
241
|
+
const q1 = [0, 0, 0];
|
|
242
|
+
const q2 = [0, 0, 0];
|
|
243
|
+
q1[0] = p1[0];
|
|
244
|
+
q1[1] = p1[1];
|
|
245
|
+
q1[2] = p1[2];
|
|
246
|
+
q2[0] = p2[0];
|
|
247
|
+
q2[1] = p2[1];
|
|
248
|
+
q2[2] = p2[2];
|
|
249
|
+
if (t1 !== 0.0 || t2 !== 1.0) {
|
|
250
|
+
for (let j = 0; j < 3; j++) {
|
|
251
|
+
q1[j] = p1[j] * (1.0 - t1) + p2[j] * t1;
|
|
252
|
+
q2[j] = p1[j] * (1.0 - t2) + p2[j] * t2;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const x1 = [0, 0, 0];
|
|
256
|
+
const x2 = [0, 0, 0];
|
|
257
|
+
for (let i = 0; i < 3; i++) {
|
|
258
|
+
x1[i] = (p1[i] - origin[i]) / spacing[i];
|
|
259
|
+
x2[i] = (p2[i] - origin[i]) / spacing[i];
|
|
260
|
+
}
|
|
261
|
+
const x = [0, 0, 0, 0];
|
|
262
|
+
const xi = [0, 0, 0];
|
|
263
|
+
const sliceSize = dims[1] * dims[0];
|
|
264
|
+
const rowSize = dims[0];
|
|
265
|
+
const nSteps = 100;
|
|
266
|
+
let insideVolume;
|
|
267
|
+
for (let t = t1; t < t2; t += 1 / nSteps) {
|
|
268
|
+
// calculate the location of the point
|
|
269
|
+
insideVolume = true;
|
|
270
|
+
for (let j = 0; j < 3; j++) {
|
|
271
|
+
// "t" is the fractional distance between endpoints x1 and x2
|
|
272
|
+
x[j] = x1[j] * (1.0 - t) + x2[j] * t;
|
|
273
|
+
}
|
|
274
|
+
x[3] = 1.0;
|
|
275
|
+
if (imageTransform) {
|
|
276
|
+
vec4.transformMat4(x, x, imageTransform);
|
|
277
|
+
}
|
|
278
|
+
for (let j = 0; j < 3; j++) {
|
|
279
|
+
// Bounds check
|
|
280
|
+
if (x[j] < extent[2 * j]) {
|
|
281
|
+
x[j] = extent[2 * j];
|
|
282
|
+
insideVolume = false;
|
|
283
|
+
} else if (x[j] > extent[2 * j + 1]) {
|
|
284
|
+
x[j] = extent[2 * j + 1];
|
|
285
|
+
insideVolume = false;
|
|
286
|
+
}
|
|
287
|
+
xi[j] = Math.round(x[j]);
|
|
288
|
+
}
|
|
289
|
+
if (insideVolume) {
|
|
290
|
+
const index = xi[2] * sliceSize + xi[1] * rowSize + xi[0];
|
|
291
|
+
let value = scalars[index];
|
|
292
|
+
if (value < oRange[0]) {
|
|
293
|
+
value = oRange[0];
|
|
294
|
+
} else if (value > oRange[1]) {
|
|
295
|
+
value = oRange[1];
|
|
296
|
+
}
|
|
297
|
+
value = Math.floor((value - oRange[0]) * scale);
|
|
298
|
+
const opacity = tmpTable[value];
|
|
299
|
+
if (opacity > model.opacityThreshold) {
|
|
300
|
+
tMin = t;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return tMin;
|
|
306
|
+
};
|
|
201
307
|
publicAPI.intersectActorWithLine = (p1, p2, t1, t2, tol, mapper) => {
|
|
202
308
|
let tMin = Number.MAX_VALUE;
|
|
203
309
|
const minXYZ = [0, 0, 0];
|
|
@@ -337,7 +443,8 @@ const DEFAULT_VALUES = {
|
|
|
337
443
|
pCoords: [],
|
|
338
444
|
cellIJK: [],
|
|
339
445
|
pickNormal: [],
|
|
340
|
-
mapperNormal: []
|
|
446
|
+
mapperNormal: [],
|
|
447
|
+
opacityThreshold: 0.2
|
|
341
448
|
};
|
|
342
449
|
|
|
343
450
|
// ----------------------------------------------------------------------------
|
|
@@ -349,6 +456,7 @@ function extend(publicAPI, model) {
|
|
|
349
456
|
// Inheritance
|
|
350
457
|
vtkPicker.extend(publicAPI, model, initialValues);
|
|
351
458
|
macro.getArray(publicAPI, model, ['pickNormal', 'mapperNormal', 'pCoords', 'cellIJK']);
|
|
459
|
+
macro.setGet(publicAPI, model, ['opacityThreshold']);
|
|
352
460
|
macro.get(publicAPI, model, ['cellId']);
|
|
353
461
|
|
|
354
462
|
// Object methods
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
|
-
import { h as hsv2rgb, i as isNan,
|
|
2
|
+
import { h as hsv2rgb, i as isNan, H as floor, I as isInf, J as rgb2hsv, K as rgb2lab, L as lab2rgb } from '../../Common/Core/Math/index.js';
|
|
3
3
|
import vtkScalarsToColors from '../../Common/Core/ScalarsToColors.js';
|
|
4
4
|
import Constants from './ColorTransferFunction/Constants.js';
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import Constants from './Coordinate/Constants.js';
|
|
3
|
-
import {
|
|
3
|
+
import { M as round, H as floor } from '../../Common/Core/Math/index.js';
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
Coordinate
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { vec3, mat4 } from 'gl-matrix';
|
|
2
2
|
import * as d3 from 'd3-scale';
|
|
3
|
-
import {
|
|
3
|
+
import { N as normalize2D, O as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
|
|
4
4
|
import { m as macro } from '../../macros2.js';
|
|
5
5
|
import vtkActor from './Actor.js';
|
|
6
6
|
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
@@ -2,7 +2,7 @@ import Constants from './ImageMapper/Constants.js';
|
|
|
2
2
|
import { m as macro } from '../../macros2.js';
|
|
3
3
|
import vtkAbstractImageMapper from './AbstractImageMapper.js';
|
|
4
4
|
import { intersectWithLineForPointPicking, intersectWithLineForCellPicking } from './AbstractImageMapper/helper.js';
|
|
5
|
-
import { C as clampValue,
|
|
5
|
+
import { C as clampValue, P as multiply3x3_vect3, F as createUninitializedBounds, Q as getSparseOrthogonalMatrix } from '../../Common/Core/Math/index.js';
|
|
6
6
|
import CoincidentTopologyHelper from './Mapper/CoincidentTopologyHelper.js';
|
|
7
7
|
|
|
8
8
|
const {
|
package/Rendering/Core/Picker.js
CHANGED
|
@@ -180,7 +180,7 @@ function vtkPicker(publicAPI, model) {
|
|
|
180
180
|
props.forEach(prop => {
|
|
181
181
|
const mapper = prop.getMapper();
|
|
182
182
|
pickable = prop.getNestedPickable() && prop.getNestedVisibility();
|
|
183
|
-
if (prop.getProperty().getOpacity() <= 0.0) {
|
|
183
|
+
if (prop.getProperty().getOpacity?.() <= 0.0) {
|
|
184
184
|
pickable = false;
|
|
185
185
|
}
|
|
186
186
|
if (pickable) {
|
|
@@ -214,7 +214,7 @@ function vtkPicker(publicAPI, model) {
|
|
|
214
214
|
bbox.reset();
|
|
215
215
|
}
|
|
216
216
|
if (bbox.intersectBox(p1Mapper, ray, hitPosition, t)) {
|
|
217
|
-
t[0] = publicAPI.intersectWithLine(p1Mapper, p2Mapper, tol * 0.333 * (scale[0] + scale[1] + scale[2]), mapper);
|
|
217
|
+
t[0] = publicAPI.intersectWithLine(p1Mapper, p2Mapper, tol * 0.333 * (scale[0] + scale[1] + scale[2]), prop, mapper);
|
|
218
218
|
if (t[0] < Number.MAX_VALUE) {
|
|
219
219
|
const p = [];
|
|
220
220
|
p[0] = (1.0 - t[0]) * p1World[0] + t[0] * p2World[0];
|
|
@@ -246,6 +246,30 @@ function vtkPicker(publicAPI, model) {
|
|
|
246
246
|
publicAPI.invokePickChange(model.pickedPositions);
|
|
247
247
|
return 1;
|
|
248
248
|
});
|
|
249
|
+
// sort array by distance
|
|
250
|
+
const tempArray = [];
|
|
251
|
+
for (let i = 0; i < model.pickedPositions.length; i++) {
|
|
252
|
+
tempArray.push({
|
|
253
|
+
actor: model.actors[i],
|
|
254
|
+
pickedPosition: model.pickedPositions[i],
|
|
255
|
+
distance2: distance2BetweenPoints(p1World, model.pickedPositions[i])
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
tempArray.sort((a, b) => {
|
|
259
|
+
const keyA = a.distance2;
|
|
260
|
+
const keyB = b.distance2;
|
|
261
|
+
// order the actors based on the distance2 attribute, so the near actors comes
|
|
262
|
+
// first in the list
|
|
263
|
+
if (keyA < keyB) return -1;
|
|
264
|
+
if (keyA > keyB) return 1;
|
|
265
|
+
return 0;
|
|
266
|
+
});
|
|
267
|
+
model.pickedPositions = [];
|
|
268
|
+
model.actors = [];
|
|
269
|
+
tempArray.forEach(obj => {
|
|
270
|
+
model.pickedPositions.push(obj.pickedPosition);
|
|
271
|
+
model.actors.push(obj.actor);
|
|
272
|
+
});
|
|
249
273
|
};
|
|
250
274
|
}
|
|
251
275
|
|
|
@@ -13,7 +13,7 @@ const {
|
|
|
13
13
|
function vtkPointPicker(publicAPI, model) {
|
|
14
14
|
// Set our className
|
|
15
15
|
model.classHierarchy.push('vtkPointPicker');
|
|
16
|
-
publicAPI.intersectWithLine = (p1, p2, tol, mapper) => {
|
|
16
|
+
publicAPI.intersectWithLine = (p1, p2, tol, actor, mapper) => {
|
|
17
17
|
let tMin = Number.MAX_VALUE;
|
|
18
18
|
if (mapper.isA('vtkImageMapper') || mapper.isA('vtkImageArrayMapper')) {
|
|
19
19
|
const pickData = mapper.intersectWithLineForPointPicking(p1, p2);
|
|
@@ -148,6 +148,7 @@ export interface vtkRenderWindow extends vtkObject {
|
|
|
148
148
|
* Switch the rendering backend between WebGL and WebGPU.
|
|
149
149
|
* By default, the WebGL backend is used. To switch, to WebGPU call
|
|
150
150
|
* `renderWindow.setDefaultViewAPI('WebGPU')` before calling `render`.
|
|
151
|
+
* Must be called before `newAPISpecificView()` is called.
|
|
151
152
|
* @param defaultViewAPI (default: 'WebGL')
|
|
152
153
|
*/
|
|
153
154
|
setDefaultViewAPI(defaultViewAPI: DEFAULT_VIEW_API): boolean;
|
|
@@ -2,7 +2,7 @@ import { mat4, vec3 } from 'gl-matrix';
|
|
|
2
2
|
import { n as newInstance$1, g as get, e as setGet, k as getArray, l as setGetArray, i as moveToProtected, c as macro } from '../../macros2.js';
|
|
3
3
|
import vtkCamera from './Camera.js';
|
|
4
4
|
import vtkLight from './Light.js';
|
|
5
|
-
import {
|
|
5
|
+
import { R as areBoundsInitialized, u as uninitializeBounds, r as radiansFromDegrees, d as dot, F as createUninitializedBounds } from '../../Common/Core/Math/index.js';
|
|
6
6
|
import vtkViewport from './Viewport.js';
|
|
7
7
|
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as d3 from 'd3-scale';
|
|
2
|
-
import {
|
|
2
|
+
import { O as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
|
|
3
3
|
import { m as macro } from '../../macros2.js';
|
|
4
4
|
import vtkActor from './Actor.js';
|
|
5
5
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
|
-
import { F as createUninitializedBounds, C as clampValue,
|
|
2
|
+
import { F as createUninitializedBounds, C as clampValue, H as floor } from '../../Common/Core/Math/index.js';
|
|
3
3
|
import Constants from './VolumeMapper/Constants.js';
|
|
4
4
|
import vtkAbstractMapper from './AbstractMapper.js';
|
|
5
5
|
import vtkPiecewiseFunction from '../../Common/DataModel/PiecewiseFunction.js';
|
|
@@ -17,6 +17,7 @@ export interface IFullScreenRenderWindowInitialValues {
|
|
|
17
17
|
containerStyle?: object;
|
|
18
18
|
controlPanelStyle?: object;
|
|
19
19
|
controllerVisibility?: boolean;
|
|
20
|
+
defaultViewAPI?: boolean;
|
|
20
21
|
listenWindowResize?: boolean;
|
|
21
22
|
resizeCallback?: any;
|
|
22
23
|
}
|
|
@@ -42,7 +43,9 @@ export interface vtkFullScreenRenderWindow extends vtkObject {
|
|
|
42
43
|
delete(): void;
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
|
-
*
|
|
46
|
+
* Returns vtkWebGPURenderWindow if ?viewAPI='WebGPU' is in URL, or if
|
|
47
|
+
* vtkFullScreenRenderWindow has been created with "defaultViewAPI: 'WebGPU",
|
|
48
|
+
* otherwise vtkOpenGLRenderWindow is returned.
|
|
46
49
|
*/
|
|
47
50
|
getApiSpecificRenderWindow(): any; // vtkOpenGLRenderWindow || vtkWebGPURenderWindow
|
|
48
51
|
|
|
@@ -72,7 +72,7 @@ function vtkFullScreenRenderWindow(publicAPI, model) {
|
|
|
72
72
|
model.renderWindow.addRenderer(model.renderer);
|
|
73
73
|
|
|
74
74
|
// apiSpecificRenderWindow
|
|
75
|
-
model.apiSpecificRenderWindow = model.renderWindow.newAPISpecificView(userParams.viewAPI);
|
|
75
|
+
model.apiSpecificRenderWindow = model.renderWindow.newAPISpecificView(userParams.viewAPI ?? model.defaultViewAPI);
|
|
76
76
|
model.apiSpecificRenderWindow.setContainer(model.container);
|
|
77
77
|
model.renderWindow.addView(model.apiSpecificRenderWindow);
|
|
78
78
|
|
|
@@ -161,6 +161,7 @@ const DEFAULT_VALUES = {
|
|
|
161
161
|
background: [0.32, 0.34, 0.43],
|
|
162
162
|
containerStyle: null,
|
|
163
163
|
controlPanelStyle: null,
|
|
164
|
+
// defaultViewAPI: undefined,
|
|
164
165
|
listenWindowResize: true,
|
|
165
166
|
resizeCallback: null,
|
|
166
167
|
controllerVisibility: true
|
|
@@ -4,6 +4,7 @@ import vtkRenderer from './../Core/Renderer';
|
|
|
4
4
|
import vtkRenderWindow from './../Core/RenderWindow';
|
|
5
5
|
import vtkRenderWindowInteractor from './../Core/RenderWindowInteractor';
|
|
6
6
|
import vtkOpenGLRenderWindow from './../OpenGL/RenderWindow';
|
|
7
|
+
import vtkWebGPURenderWindow from './../WebGPU/RenderWindow';
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -33,9 +34,9 @@ export interface vtkGenericRenderWindow extends vtkObject {
|
|
|
33
34
|
getInteractor(): vtkRenderWindowInteractor;
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
|
-
*
|
|
37
|
+
* Get the render back-end specific render window.
|
|
37
38
|
*/
|
|
38
|
-
|
|
39
|
+
getApiSpecificRenderWindow(): vtkOpenGLRenderWindow|vtkWebGPURenderWindow;
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
*
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
|
-
import vtkRenderWindow$1 from '../OpenGL/RenderWindow.js';
|
|
3
2
|
import vtkRenderer from '../Core/Renderer.js';
|
|
4
3
|
import vtkRenderWindow from '../Core/RenderWindow.js';
|
|
5
4
|
import vtkRenderWindowInteractor from '../Core/RenderWindowInteractor.js';
|
|
6
5
|
import vtkInteractorStyleTrackballCamera from '../../Interaction/Style/InteractorStyleTrackballCamera.js';
|
|
6
|
+
import vtkURLExtract from '../../Common/Core/URLExtract.js';
|
|
7
7
|
import '../../Common/Core/Points.js';
|
|
8
8
|
import '../../Common/Core/DataArray.js';
|
|
9
9
|
import '../../Common/DataModel/PolyData.js';
|
|
10
10
|
import '../Core/Actor.js';
|
|
11
11
|
import '../Core/Mapper.js';
|
|
12
12
|
|
|
13
|
+
// Process arguments from URL
|
|
14
|
+
const userParams = vtkURLExtract.extractURLParameters();
|
|
13
15
|
function vtkGenericRenderWindow(publicAPI, model) {
|
|
14
16
|
// Capture resize trigger method to remove from publicAPI
|
|
15
17
|
const invokeResize = publicAPI.invokeResize;
|
|
@@ -21,13 +23,13 @@ function vtkGenericRenderWindow(publicAPI, model) {
|
|
|
21
23
|
model.renderWindow.addRenderer(model.renderer);
|
|
22
24
|
|
|
23
25
|
// OpenGLRenderWindow
|
|
24
|
-
model.
|
|
25
|
-
model.renderWindow.addView(model.
|
|
26
|
+
model._apiSpecificRenderWindow = model.renderWindow.newAPISpecificView(userParams.viewAPI ?? model.defaultViewAPI);
|
|
27
|
+
model.renderWindow.addView(model._apiSpecificRenderWindow);
|
|
26
28
|
|
|
27
29
|
// Interactor
|
|
28
30
|
model.interactor = vtkRenderWindowInteractor.newInstance();
|
|
29
31
|
model.interactor.setInteractorStyle(vtkInteractorStyleTrackballCamera.newInstance());
|
|
30
|
-
model.interactor.setView(model.
|
|
32
|
+
model.interactor.setView(model._apiSpecificRenderWindow);
|
|
31
33
|
model.interactor.initialize();
|
|
32
34
|
|
|
33
35
|
// Expose background
|
|
@@ -41,7 +43,7 @@ function vtkGenericRenderWindow(publicAPI, model) {
|
|
|
41
43
|
if (model.container) {
|
|
42
44
|
const dims = model.container.getBoundingClientRect();
|
|
43
45
|
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
44
|
-
model.
|
|
46
|
+
model._apiSpecificRenderWindow.setSize(Math.floor(dims.width * devicePixelRatio), Math.floor(dims.height * devicePixelRatio));
|
|
45
47
|
invokeResize();
|
|
46
48
|
model.renderWindow.render();
|
|
47
49
|
}
|
|
@@ -55,7 +57,7 @@ function vtkGenericRenderWindow(publicAPI, model) {
|
|
|
55
57
|
|
|
56
58
|
// Switch container
|
|
57
59
|
model.container = el;
|
|
58
|
-
model.
|
|
60
|
+
model._apiSpecificRenderWindow.setContainer(model.container);
|
|
59
61
|
|
|
60
62
|
// Bind to new container
|
|
61
63
|
if (model.container) {
|
|
@@ -64,7 +66,7 @@ function vtkGenericRenderWindow(publicAPI, model) {
|
|
|
64
66
|
};
|
|
65
67
|
|
|
66
68
|
// Properly release GL context
|
|
67
|
-
publicAPI.delete = macro.chain(publicAPI.setContainer, model.
|
|
69
|
+
publicAPI.delete = macro.chain(publicAPI.setContainer, model._apiSpecificRenderWindow.delete, publicAPI.delete);
|
|
68
70
|
|
|
69
71
|
// Handle size
|
|
70
72
|
if (model.listenWindowResize) {
|
|
@@ -91,8 +93,8 @@ function extend(publicAPI, model) {
|
|
|
91
93
|
|
|
92
94
|
// Object methods
|
|
93
95
|
macro.obj(publicAPI, model);
|
|
94
|
-
macro.get(publicAPI, model, ['renderWindow', 'renderer', '
|
|
95
|
-
macro.moveToProtected(publicAPI, model, ['
|
|
96
|
+
macro.get(publicAPI, model, ['renderWindow', 'renderer', '_apiSpecificRenderWindow', 'interactor', 'container']);
|
|
97
|
+
macro.moveToProtected(publicAPI, model, ['_apiSpecificRenderWindow']);
|
|
96
98
|
macro.event(publicAPI, model, 'resize');
|
|
97
99
|
|
|
98
100
|
// Object specific methods
|
|
@@ -8,7 +8,7 @@ import { v as vtkPolyData2DVS } from './glsl/vtkPolyData2DVS.glsl.js';
|
|
|
8
8
|
import vtkReplacementShaderMapper from './ReplacementShaderMapper.js';
|
|
9
9
|
import vtkShaderProgram from './ShaderProgram.js';
|
|
10
10
|
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
11
|
-
import {
|
|
11
|
+
import { M as round } from '../../Common/Core/Math/index.js';
|
|
12
12
|
import { DisplayLocation } from '../Core/Property2D/Constants.js';
|
|
13
13
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
14
14
|
|
|
@@ -29,10 +29,6 @@ export interface IOpenGLRenderWindowInitialValues {
|
|
|
29
29
|
webgl2?: boolean;
|
|
30
30
|
defaultToWebgl2?: boolean;
|
|
31
31
|
activeFramebuffer?: any;
|
|
32
|
-
xrSession?: any;
|
|
33
|
-
xrSessionIsAR?: boolean;
|
|
34
|
-
xrReferenceSpace?: any;
|
|
35
|
-
xrSupported?: boolean;
|
|
36
32
|
imageFormat?: 'image/png';
|
|
37
33
|
useOffScreen?: boolean;
|
|
38
34
|
useBackgroundImage?: boolean;
|
|
@@ -236,36 +232,6 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
|
|
|
236
232
|
*/
|
|
237
233
|
get3DContext(options: I3DContextOptions): Nullable<WebGLRenderingContext>;
|
|
238
234
|
|
|
239
|
-
/**
|
|
240
|
-
* Request an XR session on the user device with WebXR,
|
|
241
|
-
* typically in response to a user request such as a button press.
|
|
242
|
-
*/
|
|
243
|
-
startXR(): void;
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* When an XR session is available, set up the XRWebGLLayer
|
|
247
|
-
* and request the first animation frame for the device
|
|
248
|
-
*/
|
|
249
|
-
enterXR(): void,
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Adjust world-to-physical parameters for different viewing modalities
|
|
253
|
-
*
|
|
254
|
-
* @param {Number} inputRescaleFactor
|
|
255
|
-
* @param {Number} inputTranslateZ
|
|
256
|
-
*/
|
|
257
|
-
resetXRScene(inputRescaleFactor: number, inputTranslateZ: number): void,
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Request to stop the current XR session
|
|
261
|
-
*/
|
|
262
|
-
stopXR(): void;
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
*
|
|
266
|
-
*/
|
|
267
|
-
xrRender(): void;
|
|
268
|
-
|
|
269
235
|
/**
|
|
270
236
|
*
|
|
271
237
|
*/
|