@kitware/vtk.js 29.5.0 → 29.6.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.
@@ -544,7 +544,7 @@ function multiply3x3_mat3(a_3x3, b_3x3, out_3x3) {
544
544
  out_3x3[i + 6] = copyA[6] * copyB[i] + copyA[7] * copyB[i + 3] + copyA[8] * copyB[i + 6];
545
545
  }
546
546
  }
547
- function multiplyMatrix(a, b, rowA, colA, rowB, colB, out_rowXcol) {
547
+ function multiplyMatrix(a, b, rowA, colA, rowB, colB, outRowAColB) {
548
548
  // we need colA == rowB
549
549
  if (colA !== rowB) {
550
550
  vtkErrorMacro('Number of columns of A must match number of rows of B.');
@@ -558,10 +558,10 @@ function multiplyMatrix(a, b, rowA, colA, rowB, colB, out_rowXcol) {
558
558
  for (let i = 0; i < rowA; i++) {
559
559
  // output col
560
560
  for (let j = 0; j < colB; j++) {
561
- out_rowXcol[i * colB + j] = 0;
561
+ outRowAColB[i * colB + j] = 0;
562
562
  // sum for this point
563
563
  for (let k = 0; k < colA; k++) {
564
- out_rowXcol[i * colB + j] += copyA[i * colA + k] * copyB[j + colB * k];
564
+ outRowAColB[i * colB + j] += copyA[i * colA + k] * copyB[j + colB * k];
565
565
  }
566
566
  }
567
567
  }
@@ -2245,4 +2245,4 @@ var vtkMath$1 = /*#__PURE__*/Object.freeze({
2245
2245
  'default': vtkMath
2246
2246
  });
2247
2247
 
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 };
2248
+ export { max as $, degreesFromRadians as A, areEquals as B, clampValue as C, arrayRange as D, getMajorAxisIndex as E, createUninitializedBounds as F, isIdentity3x3 as G, identity as H, multiplyMatrix as I, floor as J, isInf as K, rgb2hsv as L, rgb2lab as M, lab2rgb as N, round as O, normalize2D as P, nearestPowerOfTwo as Q, multiply3x3_vect3 as R, getSparseOrthogonalMatrix as S, areBoundsInitialized as T, isPowerOfTwo as U, angleBetweenVectors as V, signedAngleBetweenVectors as W, createArray as X, Pi as Y, ceil as Z, min as _, areMatricesEqual as a, float2CssRGBA as a$, arrayMin as a0, arrayMax as a1, ceilLog2 as a2, factorial as a3, binomial as a4, beginCombination as a5, nextCombination as a6, randomSeed as a7, getSeed as a8, gaussian 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_, multiplyScalar2D as aa, multiplyAccumulate2D as ab, outer as ac, projectVector as ad, dot2D as ae, projectVector2D as af, gaussianAmplitude as ag, gaussianWeight as ah, outer2D as ai, norm2D as aj, rowsToMat4 as ak, columnsToMat4 as al, columnsToMat3 as am, LUFactor3x3 as an, LUSolve3x3 as ao, linearSolve3x3 as ap, multiply3x3_mat3 as aq, transpose3x3 as ar, invert3x3 as as, identity3x3 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 };
@@ -471,9 +471,9 @@ export function multiply3x3_mat3(a_3x3: Matrix3x3, b_3x3: Matrix3x3, out_3x3: Ma
471
471
  * @param {Number} colA
472
472
  * @param {Number} rowB
473
473
  * @param {Number} colB
474
- * @param {Matrix} out_rowXcol
474
+ * @param {Matrix} outRowAColB
475
475
  */
476
- export function multiplyMatrix(a: Matrix, b: Matrix, rowA: number, colA: number, rowB: number, colB: number, out_rowXcol: Matrix): void;
476
+ export function multiplyMatrix(a: Matrix, b: Matrix, rowA: number, colA: number, rowB: number, colB: number, outRowAColB: Matrix): void;
477
477
 
478
478
  /**
479
479
  * Transpose a 3x3 matrix.
@@ -1,4 +1,4 @@
1
1
  import 'seedrandom';
2
2
  import '../../macros2.js';
3
3
  import './Math/Constants.js';
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';
4
+ export { an as LUFactor3x3, ao as LUSolve3x3, Y as Pi, k as add, V as angleBetweenVectors, T as areBoundsInitialized, B as areEquals, a as areMatricesEqual, a1 as arrayMax, a0 as arrayMin, D as arrayRange, a5 as beginCombination, a4 as binomial, aS as boundsIsWithinOtherBounds, Z as ceil, a2 as ceilLog2, aO as clampAndNormalizeValue, C as clampValue, c as clampVector, am as columnsToMat3, al as columnsToMat4, aN as computeBoundsFromPoints, X 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, ae as dot2D, aF as estimateMatrixCondition, aR as extentIsWithinOtherExtent, a3 as factorial, a$ as float2CssRGBA, a_ as floatRGB2HexCode, aZ as floatToHex2, J as floor, a9 as gaussian, ag as gaussianAmplitude, ah as gaussianWeight, aQ as getAdjustedScalarRange, E as getMajorAxisIndex, aP as getScalarTypeFittingRange, a8 as getSeed, S as getSparseOrthogonalMatrix, aI as hex2float, h as hsv2rgb, H as identity, at as identity3x3, aV as inf, as as invert3x3, aE as invertMatrix, aX as isFinite, au as isIdentity, G as isIdentity3x3, K as isInf, aY as isNaN, i as isNan, U as isPowerOfTwo, t as jacobi, p as jacobiN, N as lab2rgb, aJ as lab2xyz, ap as linearSolve3x3, aC as luFactorLinearSystem, aD as luSolveLinearSystem, ax as matrix3x3ToQuaternion, $ as max, _ as min, aq as multiply3x3_mat3, R as multiply3x3_vect3, m as multiplyAccumulate, ab as multiplyAccumulate2D, I as multiplyMatrix, ay as multiplyQuaternion, w as multiplyScalar, aa as multiplyScalar2D, Q as nearestPowerOfTwo, aW as negInf, a6 as nextCombination, n as norm, aj as norm2D, l as normalize, P as normalize2D, az as orthogonalize3x3, ac as outer, ai as outer2D, q as perpendiculars, aT as pointIsWithinBounds, ad as projectVector, af as projectVector2D, av as quaternionToMatrix3x3, r as radiansFromDegrees, x as random, a7 as randomSeed, L as rgb2hsv, M as rgb2lab, aM as rgb2xyz, O as round, aw as roundNumber, b as roundVector, z as rowsToMat3, ak as rowsToMat4, W as signedAngleBetweenVectors, aB as singularValueDecomposition3x3, aU as solve3PointCircle, aG as solveHomogeneousLeastSquares, aH as solveLeastSquares, g as solveLinearSystem, s as subtract, ar as transpose3x3, u as uninitializeBounds, aK as xyz2lab, aL as xyz2rgb } from './Math/index.js';
@@ -35,7 +35,7 @@ function vtkScalarToRGBA(publicAPI, model) {
35
35
  }
36
36
  const rgba = [0, 0, 0, 0];
37
37
  const data = scalars.getData();
38
- const rgbaArray = new Uint8Array(data.length * 4);
38
+ const rgbaArray = new Uint8ClampedArray(data.length * 4);
39
39
  let offset = 0;
40
40
  for (let idx = 0; idx < data.length; idx++) {
41
41
  const x = data[idx];
@@ -24,7 +24,7 @@ function shiftDataset(ds, axis) {
24
24
 
25
25
  function addColor(ds, r, g, b) {
26
26
  const size = ds.getPoints().getData().length;
27
- const rgbArray = new Uint8Array(size);
27
+ const rgbArray = new Uint8ClampedArray(size);
28
28
  let offset = 0;
29
29
  while (offset < size) {
30
30
  rgbArray[offset++] = r;
@@ -0,0 +1,109 @@
1
+ /**
2
+ * A helper file to transform RGBA points using CSS filters equivalent
3
+ * The equivalents of CSS filters using SVG filters can be found here:
4
+ * https://www.w3.org/TR/filter-effects-1/#ShorthandEquivalents
5
+ * For each SVG filter, you can look for the maths behind it on the same page:
6
+ * https://www.w3.org/TR/filter-effects-1/#FilterPrimitivesOverview
7
+ *
8
+ * For example, the saturate filter equivalent is here:
9
+ * https://www.w3.org/TR/filter-effects-1/#saturateEquivalent
10
+ * And the maths behind the feColorMatrix of type saturate is here:
11
+ * https://www.w3.org/TR/filter-effects-1/#ref-for-attr-valuedef-type-saturate
12
+ *
13
+ * The transforms are done using matrices of size 5 by 5. They are row major
14
+ * as in vtkMath. The vectors representing the RGBA points uses
15
+ * [R, G, B, A, 1] vectors, with each channel between 0 and 1.
16
+ */
17
+
18
+ import { Matrix, Vector3 } from '../../../types';
19
+
20
+ export const luminanceWeights: Vector3;
21
+ export type FilterMatrix = Matrix;
22
+
23
+ /**
24
+ * Create a new filter matrix
25
+ * This is a 5x5 row major array
26
+ * Use applyFilter() function to use it
27
+ * It is NOT the identity
28
+ */
29
+ export function createCSSFilter(): FilterMatrix;
30
+
31
+ /**
32
+ * Convert a filter to an identity matrix or create a new identity filter
33
+ * @param outFilter If specified, the outFilter is converted to identity filter
34
+ */
35
+ export function createIdentityFilter(outFilter?: FilterMatrix): FilterMatrix;
36
+
37
+ /**
38
+ * Combine two filters into a single filter
39
+ * Warning: it is NOT an operation inspired by CSS filters
40
+ * For this, apply filters one by one using applyFilter
41
+ * The clamping step is not applied between each filter when the filters are combined
42
+ * The order of the filters matters
43
+ * @param baseFilter The first filter that will be applied
44
+ * @param newFilter The second filter that will be applied
45
+ * @param outFilter An optional filter that will contain the combined filter
46
+ */
47
+ export function combineFilters(baseFilter: FilterMatrix, newFilter: FilterMatrix, outFilter?: FilterMatrix): FilterMatrix;
48
+
49
+ /**
50
+ * Apply a filter to a rgb(a) point
51
+ * It is a multiplication by the matrix and a clamping
52
+ * @param filter The filter
53
+ * @param r The red channel (between 0 and 1)
54
+ * @param g The green channel (between 0 and 1)
55
+ * @param b The blue channel (between 0 and 1)
56
+ * @param a The optional alpha channel (between 0 and 1), defaults to 1
57
+ * @returns A vector of size 4 [r, g, b, a]
58
+ */
59
+ export function applyFilter(filter: FilterMatrix, r: number, g: number, b: number, a?: number): [number, number, number, number];
60
+
61
+ /**
62
+ * A generic linear filter
63
+ * See svg equivalent for parameters and a specification
64
+ * https://www.w3.org/TR/filter-effects-1/#attr-valuedef-type-linear
65
+ * @param slope
66
+ * @param intercept
67
+ * @param outFilter Optional output, a new filter is created if not specified
68
+ */
69
+ export function createLinearFilter(slope: number, intercept: number, outFilter?: FilterMatrix): FilterMatrix;
70
+
71
+ /**
72
+ * A contrast filter
73
+ * See css/svg equivalent for parameters and a specification
74
+ * https://www.w3.org/TR/filter-effects-1/#contrastEquivalent
75
+ * https://www.w3.org/TR/filter-effects-1/#attr-valuedef-type-linear
76
+ * @param contrast
77
+ * @param outFilter Optional output, a new filter is created if not specified
78
+ */
79
+ export function createContrastFilter(contrast: number, outFilter?: FilterMatrix): FilterMatrix;
80
+
81
+ /**
82
+ * A saturate filter
83
+ * See css/svg equivalent for parameters and a specification
84
+ * https://www.w3.org/TR/filter-effects-1/#saturateEquivalent
85
+ * https://www.w3.org/TR/filter-effects-1/#ref-for-attr-valuedef-type-saturate
86
+ * @param saturate
87
+ * @param outFilter Optional output, a new filter is created if not specified
88
+ */
89
+ export function createSaturateFilter(saturate: number, outFilter?: FilterMatrix): FilterMatrix;
90
+
91
+ /**
92
+ * A brightness filter
93
+ * See css/svg equivalent for parameters and a specification
94
+ * https://www.w3.org/TR/filter-effects-1/#brightnessEquivalent
95
+ * https://www.w3.org/TR/filter-effects-1/#attr-valuedef-type-linear
96
+ * @param brightness
97
+ * @param outFilter Optional output, a new filter is created if not specified
98
+ */
99
+ export function createBrightnessFilter(brightness: number, outFilter?: FilterMatrix): FilterMatrix;
100
+
101
+ /**
102
+ * An invert filter
103
+ * See css/svg equivalent for parameters and a specification
104
+ * https://www.w3.org/TR/filter-effects-1/#invertEquivalent
105
+ * https://www.w3.org/TR/filter-effects-1/#attr-valuedef-type-table
106
+ * @param invert
107
+ * @param outFilter Optional output, a new filter is created if not specified
108
+ */
109
+ export function createInvertFilter(invert: number, outFilter?: FilterMatrix): FilterMatrix;
@@ -0,0 +1,103 @@
1
+ import { H as identity, I as multiplyMatrix } from '../../../Common/Core/Math/index.js';
2
+
3
+ /**
4
+ * A helper file to transform RGBA points using CSS filters equivalent
5
+ * The equivalents of CSS filters using SVG filters can be found here:
6
+ * https://www.w3.org/TR/filter-effects-1/#ShorthandEquivalents
7
+ * For each SVG filter, you can look for the maths behind it on the same page:
8
+ * https://www.w3.org/TR/filter-effects-1/#FilterPrimitivesOverview
9
+ *
10
+ * For example, the saturate filter equivalent is here:
11
+ * https://www.w3.org/TR/filter-effects-1/#saturateEquivalent
12
+ * And the maths behind the feColorMatrix of type saturate is here:
13
+ * https://www.w3.org/TR/filter-effects-1/#ref-for-attr-valuedef-type-saturate
14
+ *
15
+ * The transforms are done using matrices of size 5 by 5. They are row major
16
+ * as in vtkMath. The vectors representing the RGBA points uses
17
+ * [R, G, B, A, 1] vectors, with each channel between 0 and 1.
18
+ */
19
+ const luminanceWeights = [0.213, 0.715, 0.072];
20
+ function createCSSFilter() {
21
+ return new Array(25);
22
+ }
23
+ function createIdentityFilter() {
24
+ let outFilter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : createCSSFilter();
25
+ return identity(5, outFilter);
26
+ }
27
+ function combineFilters(baseFilter, newFilter) {
28
+ let outFilter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createCSSFilter();
29
+ multiplyMatrix(newFilter, baseFilter, 5, 5, 5, 5, outFilter);
30
+ return outFilter;
31
+ }
32
+ function applyFilter(filter, r, g, b) {
33
+ let a = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
34
+ const vec = [r, g, b, a, 1];
35
+ multiplyMatrix(filter, vec, 5, 5, 5, 1, vec);
36
+ // Clamp R, G, B, A
37
+ const output = new Array(4);
38
+ for (let i = 0; i < 4; ++i) {
39
+ const value = vec[i];
40
+ if (value < 0) {
41
+ output[i] = 0;
42
+ } else if (value > 1) {
43
+ output[i] = 1;
44
+ } else {
45
+ output[i] = value;
46
+ }
47
+ }
48
+ return output;
49
+ }
50
+ function createLinearFilter(slope, intercept) {
51
+ let outFilter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createCSSFilter();
52
+ createIdentityFilter(outFilter);
53
+ for (let row = 0; row < 3; ++row) {
54
+ outFilter[row * 5 + row] = slope;
55
+ outFilter[row * 5 + 4] = intercept;
56
+ }
57
+ return outFilter;
58
+ }
59
+
60
+ // https://www.w3.org/TR/filter-effects-1/#contrastEquivalent
61
+ // https://www.w3.org/TR/filter-effects-1/#attr-valuedef-type-linear
62
+ function createContrastFilter(contrast) {
63
+ let outFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createCSSFilter();
64
+ const slope = contrast;
65
+ const intercept = -(0.5 * contrast) + 0.5;
66
+ return createLinearFilter(slope, intercept, outFilter);
67
+ }
68
+
69
+ // https://www.w3.org/TR/filter-effects-1/#saturateEquivalent
70
+ // https://www.w3.org/TR/filter-effects-1/#ref-for-attr-valuedef-type-saturate
71
+ function createSaturateFilter(saturate) {
72
+ let outFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createCSSFilter();
73
+ createIdentityFilter(outFilter);
74
+ for (let col = 0; col < 3; ++col) {
75
+ const columnLuminance = luminanceWeights[col];
76
+ const diagonalValue = columnLuminance + (1 - columnLuminance) * saturate;
77
+ const nonDiagonalValue = columnLuminance - columnLuminance * saturate;
78
+ for (let row = 0; row < 3; ++row) {
79
+ outFilter[row * 5 + col] = row === col ? diagonalValue : nonDiagonalValue;
80
+ }
81
+ }
82
+ return outFilter;
83
+ }
84
+
85
+ // https://www.w3.org/TR/filter-effects-1/#brightnessEquivalent
86
+ // https://www.w3.org/TR/filter-effects-1/#attr-valuedef-type-linear
87
+ function createBrightnessFilter(brightness) {
88
+ let outFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createCSSFilter();
89
+ const slope = brightness;
90
+ const intercept = 0;
91
+ return createLinearFilter(slope, intercept, outFilter);
92
+ }
93
+
94
+ // https://www.w3.org/TR/filter-effects-1/#invertEquivalent
95
+ // https://www.w3.org/TR/filter-effects-1/#attr-valuedef-type-table
96
+ function createInvertFilter(invert) {
97
+ let outFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createCSSFilter();
98
+ const slope = 1 - 2 * invert;
99
+ const intercept = invert;
100
+ return createLinearFilter(slope, intercept, outFilter);
101
+ }
102
+
103
+ export { applyFilter, combineFilters, createBrightnessFilter, createCSSFilter, createContrastFilter, createIdentityFilter, createInvertFilter, createLinearFilter, createSaturateFilter, luminanceWeights };
@@ -1,5 +1,5 @@
1
1
  import { m as macro } from '../../macros2.js';
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';
2
+ import { h as hsv2rgb, i as isNan, J as floor, K as isInf, L as rgb2hsv, M as rgb2lab, N 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 { M as round, H as floor } from '../../Common/Core/Math/index.js';
3
+ import { O as round, J 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 { N as normalize2D, O as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
3
+ import { P as normalize2D, Q 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, P as multiply3x3_vect3, F as createUninitializedBounds, Q as getSparseOrthogonalMatrix } from '../../Common/Core/Math/index.js';
5
+ import { C as clampValue, R as multiply3x3_vect3, F as createUninitializedBounds, S as getSparseOrthogonalMatrix } from '../../Common/Core/Math/index.js';
6
6
  import CoincidentTopologyHelper from './Mapper/CoincidentTopologyHelper.js';
7
7
 
8
8
  const {
@@ -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 { R as areBoundsInitialized, u as uninitializeBounds, r as radiansFromDegrees, d as dot, F as createUninitializedBounds } from '../../Common/Core/Math/index.js';
5
+ import { T 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 { O as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
2
+ import { Q 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, H as floor } from '../../Common/Core/Math/index.js';
2
+ import { F as createUninitializedBounds, C as clampValue, J 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';
@@ -188,7 +188,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
188
188
  if (model.colorTextureString !== cfunToString) {
189
189
  const cWidth = 1024;
190
190
  const cSize = cWidth * textureHeight * 3;
191
- const cTable = new Uint8Array(cSize);
191
+ const cTable = new Uint8ClampedArray(cSize);
192
192
  let cfun = ppty.getRGBTransferFunction();
193
193
  if (cfun) {
194
194
  const tmpTable = new Float32Array(cWidth * 3);
@@ -228,7 +228,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
228
228
  if (model.pwfTextureString !== pwfunToString) {
229
229
  const pwfWidth = 1024;
230
230
  const pwfSize = pwfWidth * textureHeight;
231
- const pwfTable = new Uint8Array(pwfSize);
231
+ const pwfTable = new Uint8ClampedArray(pwfSize);
232
232
  let pwfun = ppty.getPiecewiseFunction();
233
233
  // support case where pwfun is added/removed
234
234
  model.pwfTexture.releaseGraphicsResources(model._openGLRenderWindow);
@@ -582,7 +582,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
582
582
  if (reBuildC) {
583
583
  const cWidth = 1024;
584
584
  const cSize = cWidth * textureHeight * 3;
585
- const cTable = new Uint8Array(cSize);
585
+ const cTable = new Uint8ClampedArray(cSize);
586
586
  if (!model.colorTexture) {
587
587
  model.colorTexture = vtkOpenGLTexture.newInstance({
588
588
  resizable: true
@@ -645,7 +645,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
645
645
  if (reBuildPwf) {
646
646
  const pwfWidth = 1024;
647
647
  const pwfSize = pwfWidth * textureHeight;
648
- const pwfTable = new Uint8Array(pwfSize);
648
+ const pwfTable = new Uint8ClampedArray(pwfSize);
649
649
  if (!model.pwfTexture) {
650
650
  model.pwfTexture = vtkOpenGLTexture.newInstance({
651
651
  resizable: true
@@ -745,6 +745,8 @@ function vtkOpenGLImageMapper(publicAPI, model) {
745
745
  });
746
746
  model.openGLTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
747
747
  }
748
+ // Use norm16 for scalar texture if the extension is available
749
+ model.openGLTexture.setOglNorm16Ext(model.context.getExtension('EXT_texture_norm16'));
748
750
  if (iType === InterpolationType.NEAREST) {
749
751
  if (new Set([1, 3, 4]).has(numComp) && dataType === VtkDataTypes.UNSIGNED_CHAR && !iComps) {
750
752
  model.openGLTexture.setGenerateMipmap(true);
@@ -213,7 +213,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
213
213
  if (reBuildC) {
214
214
  const cWidth = 1024;
215
215
  const cSize = cWidth * textureHeight * 3;
216
- const cTable = new Uint8Array(cSize);
216
+ const cTable = new Uint8ClampedArray(cSize);
217
217
  if (!model.colorTexture) {
218
218
  model.colorTexture = vtkOpenGLTexture.newInstance();
219
219
  model.colorTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
@@ -268,7 +268,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
268
268
  if (reBuildPwf) {
269
269
  const pwfWidth = 1024;
270
270
  const pwfSize = pwfWidth * textureHeight;
271
- const pwfTable = new Uint8Array(pwfSize);
271
+ const pwfTable = new Uint8ClampedArray(pwfSize);
272
272
  if (!model.pwfTexture) {
273
273
  model.pwfTexture = vtkOpenGLTexture.newInstance();
274
274
  model.pwfTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
@@ -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 { M as round } from '../../Common/Core/Math/index.js';
11
+ import { O 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
 
@@ -319,18 +319,22 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
319
319
  default:
320
320
  return oglNorm16Ext.RGBA16_SNORM_EXT;
321
321
  }
322
+ case VtkDataTypes.UNSIGNED_SHORT:
323
+ case VtkDataTypes.SHORT:
322
324
  case VtkDataTypes.FLOAT:
323
325
  default:
326
+ // useHalfFloat tells us if the texture can be accurately
327
+ // rendered with 16 bits or not.
324
328
  switch (numComps) {
325
329
  case 1:
326
- return model.context.R16F;
330
+ return useHalfFloat ? model.context.R16F : model.context.R32F;
327
331
  case 2:
328
- return model.context.RG16F;
332
+ return useHalfFloat ? model.context.RG16F : model.context.RG32F;
329
333
  case 3:
330
- return model.context.RGB16F;
334
+ return useHalfFloat ? model.context.RGB16F : model.context.RGB32F;
331
335
  case 4:
332
336
  default:
333
- return model.context.RGBA16F;
337
+ return useHalfFloat ? model.context.RGBA16F : model.context.RGBA32F;
334
338
  }
335
339
  }
336
340
  }
@@ -2,7 +2,7 @@ import Constants from './Texture/Constants.js';
2
2
  import HalfFloat from '../../Common/Core/HalfFloat.js';
3
3
  import { n as newInstance$1, o as obj, s as set, e as setGet, g as get, i as moveToProtected, a as newTypedArray, c as macro } from '../../macros2.js';
4
4
  import vtkDataArray from '../../Common/Core/DataArray.js';
5
- import { S as isPowerOfTwo, O as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
5
+ import { U as isPowerOfTwo, Q as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
6
6
  import vtkViewNode from '../SceneGraph/ViewNode.js';
7
7
  import { registerOverride } from './ViewNodeFactory.js';
8
8
 
@@ -275,6 +275,9 @@ function vtkOpenGLTexture(publicAPI, model) {
275
275
  if (!model.internalFormat) {
276
276
  vtkDebugMacro(`Unable to find suitable internal format for T=${vtktype} NC= ${numComps}`);
277
277
  }
278
+ if ([model.context.R32F, model.context.RG32F, model.context.RGB32F, model.context.RGBA32F].includes(model.internalFormat) && !model.context.getExtension('OES_texture_float_linear')) {
279
+ vtkWarningMacro('Failed to load OES_texture_float_linear. Texture filtering is not available for *32F internal formats.');
280
+ }
278
281
  return model.internalFormat;
279
282
  };
280
283
 
@@ -1006,7 +1006,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
1006
1006
  if (model._openGLRenderWindow.getWebgl2() || model.context.getExtension('OES_texture_float') && model.context.getExtension('OES_texture_float_linear')) {
1007
1007
  model.opacityTexture.create2DFromRaw(oWidth, 2 * numIComps, 1, VtkDataTypes.FLOAT, ofTable);
1008
1008
  } else {
1009
- const oTable = new Uint8Array(oSize);
1009
+ const oTable = new Uint8ClampedArray(oSize);
1010
1010
  for (let i = 0; i < oSize; ++i) {
1011
1011
  oTable[i] = 255.0 * ofTable[i];
1012
1012
  }
@@ -1029,7 +1029,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
1029
1029
  if (reBuildC) {
1030
1030
  const cWidth = 1024;
1031
1031
  const cSize = cWidth * 2 * numIComps * 3;
1032
- const cTable = new Uint8Array(cSize);
1032
+ const cTable = new Uint8ClampedArray(cSize);
1033
1033
  const tmpTable = new Float32Array(cWidth * 3);
1034
1034
  for (let c = 0; c < numIComps; ++c) {
1035
1035
  const cfun = vprop.getRGBTransferFunction(c);
@@ -230,7 +230,7 @@ function vtkWebGPUImageMapper(publicAPI, model) {
230
230
  const cfunToString = computeFnToString(actorProperty, actorProperty.getRGBTransferFunction, numIComps);
231
231
  if (model.colorTextureString !== cfunToString) {
232
232
  model.numRows = numIComps;
233
- const colorArray = new Uint8Array(model.numRows * 2 * model.rowLength * 4);
233
+ const colorArray = new Uint8ClampedArray(model.numRows * 2 * model.rowLength * 4);
234
234
  let cfun = actorProperty.getRGBTransferFunction();
235
235
  if (cfun) {
236
236
  const tmpTable = new Float32Array(model.rowLength * 3);
@@ -245,7 +245,7 @@ function vtkWebGPUSphereMapper(publicAPI, model) {
245
245
  if (colorComponents !== 4) {
246
246
  vtkErrorMacro('this should be 4');
247
247
  }
248
- const tmpVBO = new Uint8Array(3 * numPoints * 4);
248
+ const tmpVBO = new Uint8ClampedArray(3 * numPoints * 4);
249
249
  let vboIdx = 0;
250
250
  const colorData = c.getData();
251
251
  for (let id = 0; id < numPoints; ++id) {
@@ -362,7 +362,7 @@ function vtkWebGPUStickMapper(publicAPI, model) {
362
362
  if (colorComponents !== 4) {
363
363
  vtkErrorMacro('this should be 4');
364
364
  }
365
- const tmpVBO = new Uint8Array(numPoints * 4);
365
+ const tmpVBO = new Uint8ClampedArray(numPoints * 4);
366
366
  let vboIdx = 0;
367
367
  const colorData = c.getData();
368
368
  for (let id = 0; id < numPoints; ++id) {
@@ -484,7 +484,7 @@ function vtkWebGPUVolumePassFSQ(publicAPI, model) {
484
484
  }
485
485
 
486
486
  // allocate the image array
487
- const colorArray = new Uint8Array(model.numRows * 2 * model.rowLength * 4);
487
+ const colorArray = new Uint8ClampedArray(model.numRows * 2 * model.rowLength * 4);
488
488
  const opacityArray = new Float32Array(model.numRows * 2 * model.rowLength);
489
489
  let imgRow = 0;
490
490
  const tmpTable = new Float32Array(model.rowLength * 3);
@@ -3,7 +3,7 @@ import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
3
3
  import vtkPlanePointManipulator from '../Manipulators/PlaneManipulator.js';
4
4
  import vtkPolyLineRepresentation from '../Representations/PolyLineRepresentation.js';
5
5
  import vtkSphereHandleRepresentation from '../Representations/SphereHandleRepresentation.js';
6
- import { s as subtract, T as angleBetweenVectors } from '../../Common/Core/Math/index.js';
6
+ import { s as subtract, V as angleBetweenVectors } from '../../Common/Core/Math/index.js';
7
7
  import widgetBehavior from './AngleWidget/behavior.js';
8
8
  import generateState from './AngleWidget/state.js';
9
9
  import { ViewTypes } from '../Core/WidgetManager/Constants.js';
@@ -1,7 +1,7 @@
1
1
  import { m as macro } from '../../../macros2.js';
2
2
  import vtkBoundingBox from '../../../Common/DataModel/BoundingBox.js';
3
3
  import vtkLine from '../../../Common/DataModel/Line.js';
4
- import { k as add, l as normalize, s as subtract, d as dot, j as cross, m as multiplyAccumulate, w as multiplyScalar, U as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
4
+ import { k as add, l as normalize, s as subtract, d as dot, j as cross, m as multiplyAccumulate, w as multiplyScalar, W as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
5
5
  import { getLineNames, getOtherLineName, updateState, boundPointOnPlane, getLinePlaneName, getLineInPlaneName, rotateVector } from './helpers.js';
6
6
  import { InteractionMethodsName, ScrollingMethods, planeNameToViewType } from './Constants.js';
7
7
 
@@ -2,7 +2,7 @@ import vtkBoundingBox, { STATIC } from '../../../Common/DataModel/BoundingBox.js
2
2
  import vtkCubeSource from '../../../Filters/Sources/CubeSource.js';
3
3
  import vtkCutter from '../../../Filters/Core/Cutter.js';
4
4
  import vtkPlane from '../../../Common/DataModel/Plane.js';
5
- import { s as subtract, l as normalize, j as cross, w as multiplyScalar, m as multiplyAccumulate, U as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
5
+ import { s as subtract, l as normalize, j as cross, w as multiplyScalar, m as multiplyAccumulate, W as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
6
6
  import vtkMatrixBuilder from '../../../Common/Core/MatrixBuilder.js';
7
7
  import { viewTypeToPlaneName, planeNameToViewType, planeNames } from './Constants.js';
8
8
 
package/index.d.ts CHANGED
@@ -150,6 +150,7 @@
150
150
  /// <reference path="./Rendering/Core/CellPicker.d.ts" />
151
151
  /// <reference path="./Rendering/Core/ColorTransferFunction/ColorMaps.d.ts" />
152
152
  /// <reference path="./Rendering/Core/ColorTransferFunction/Constants.d.ts" />
153
+ /// <reference path="./Rendering/Core/ColorTransferFunction/CssFilters.d.ts" />
153
154
  /// <reference path="./Rendering/Core/ColorTransferFunction.d.ts" />
154
155
  /// <reference path="./Rendering/Core/Coordinate/Constants.d.ts" />
155
156
  /// <reference path="./Rendering/Core/Coordinate.d.ts" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "29.5.0",
3
+ "version": "29.6.0",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",