@kitware/vtk.js 34.6.0 → 34.7.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/Common/Core/Math/index.js +12 -1
- package/Common/Core/Math.d.ts +24 -18
- package/Common/Core/Math.js +1 -1
- package/Common/DataModel/Triangle.js +8 -13
- package/Filters/Core/Cutter.js +1 -0
- package/IO/Misc/OBJWriter.d.ts +103 -0
- package/IO/Misc/OBJWriter.js +235 -0
- package/IO/Misc.js +2 -0
- package/Interaction/Style/InteractorStyleManipulator.js +75 -2
- package/Rendering/Core/Camera.d.ts +3 -3
- package/Rendering/Core/Camera.js +33 -3
- package/Rendering/Core/ColorTransferFunction/CssFilters.js +1 -1
- 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/Renderer.js +1 -1
- package/Rendering/Core/ScalarBarActor.js +1 -1
- package/Rendering/Core/TextActor.js +1 -1
- package/Rendering/Core/VolumeProperty.js +1 -1
- package/Rendering/OpenGL/PolyDataMapper2D.js +1 -1
- package/Rendering/OpenGL/Texture.js +1 -1
- package/Widgets/Widgets3D/AngleWidget.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
- package/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -258,6 +258,16 @@ function normalize(x) {
|
|
|
258
258
|
}
|
|
259
259
|
return den;
|
|
260
260
|
}
|
|
261
|
+
function normalize4D(x) {
|
|
262
|
+
const den = norm(x, 3);
|
|
263
|
+
if (den !== 0.0) {
|
|
264
|
+
x[0] /= den;
|
|
265
|
+
x[1] /= den;
|
|
266
|
+
x[2] /= den;
|
|
267
|
+
x[3] /= den;
|
|
268
|
+
}
|
|
269
|
+
return den;
|
|
270
|
+
}
|
|
261
271
|
function perpendiculars(x, y, z, theta) {
|
|
262
272
|
const x2 = x[0] * x[0];
|
|
263
273
|
const y2 = x[1] * x[1];
|
|
@@ -2171,6 +2181,7 @@ var vtkMath$1 = /*#__PURE__*/Object.freeze({
|
|
|
2171
2181
|
cross: cross,
|
|
2172
2182
|
norm: norm,
|
|
2173
2183
|
normalize: normalize,
|
|
2184
|
+
normalize4D: normalize4D,
|
|
2174
2185
|
perpendiculars: perpendiculars,
|
|
2175
2186
|
projectVector: projectVector,
|
|
2176
2187
|
dot2D: dot2D,
|
|
@@ -2256,4 +2267,4 @@ var vtkMath$1 = /*#__PURE__*/Object.freeze({
|
|
|
2256
2267
|
'default': vtkMath
|
|
2257
2268
|
});
|
|
2258
2269
|
|
|
2259
|
-
export {
|
|
2270
|
+
export { createArray as $, rowsToMat3 as A, degreesFromRadians as B, ldexp as C, xyz2rgb as D, areEquals as E, clampValue as F, arrayRange as G, getMajorAxisIndex as H, createUninitializedBounds as I, normalize4D as J, identity as K, multiplyMatrix as L, floor as M, isInf as N, rgb2hsv as O, rgb2lab as P, lab2rgb as Q, round as R, normalize2D as S, nearestPowerOfTwo as T, multiply3x3_vect3 as U, getSparseOrthogonalMatrix as V, areBoundsInitialized as W, floatRGB2HexCode as X, isPowerOfTwo as Y, angleBetweenVectors as Z, signedAngleBetweenVectors as _, areMatricesEqual as a, isNaN as a$, Pi as a0, ceil as a1, min as a2, max as a3, arrayMin as a4, arrayMax as a5, ceilLog2 as a6, factorial as a7, binomial as a8, beginCombination as a9, quaternionToMatrix3x3 as aA, roundNumber as aB, matrix3x3ToQuaternion as aC, multiplyQuaternion as aD, orthogonalize3x3 as aE, diagonalize3x3 as aF, singularValueDecomposition3x3 as aG, luFactorLinearSystem as aH, luSolveLinearSystem as aI, estimateMatrixCondition as aJ, solveHomogeneousLeastSquares as aK, solveLeastSquares as aL, hex2float as aM, lab2xyz as aN, xyz2lab as aO, rgb2xyz as aP, computeBoundsFromPoints as aQ, clampAndNormalizeValue as aR, getScalarTypeFittingRange as aS, getAdjustedScalarRange as aT, extentIsWithinOtherExtent as aU, boundsIsWithinOtherBounds as aV, pointIsWithinBounds as aW, solve3PointCircle as aX, inf as aY, negInf as aZ, isFinite as a_, nextCombination as aa, randomSeed as ab, getSeed as ac, gaussian as ad, multiplyScalar2D as ae, multiplyAccumulate2D as af, outer as ag, projectVector as ah, dot2D as ai, projectVector2D as aj, gaussianAmplitude as ak, gaussianWeight as al, outer2D as am, norm2D as an, rowsToMat4 as ao, columnsToMat4 as ap, columnsToMat3 as aq, LUFactor3x3 as ar, LUSolve3x3 as as, linearSolve3x3 as at, multiply3x3_mat3 as au, transpose3x3 as av, invert3x3 as aw, identity3x3 as ax, isIdentity as ay, isIdentity3x3 as az, roundVector as b, floatToHex2 as b0, float2CssRGBA as b1, 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, invertMatrix as p, jacobiN as q, radiansFromDegrees as r, subtract as s, perpendiculars as t, uninitializeBounds as u, vtkMath$1 as v, jacobi as w, multiplyScalar as x, random as y, determinant3x3 as z };
|
package/Common/Core/Math.d.ts
CHANGED
|
@@ -203,7 +203,7 @@ export function getSeed(): number;
|
|
|
203
203
|
export function random(minValue: number, maxValue: number): number;
|
|
204
204
|
|
|
205
205
|
/**
|
|
206
|
-
*
|
|
206
|
+
* Add two 3-vectors.
|
|
207
207
|
* @param {Vector3} a The first 3D vector.
|
|
208
208
|
* @param {Vector3} b The second 3D vector.
|
|
209
209
|
* @param {Vector3} out The output 3D vector.
|
|
@@ -215,7 +215,7 @@ export function random(minValue: number, maxValue: number): number;
|
|
|
215
215
|
export function add(a: Vector3, b: Vector3, out: Vector3): Vector3;
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
|
-
*
|
|
218
|
+
* Substract two 3-vectors.
|
|
219
219
|
* @param {Vector3} a The first 3D vector.
|
|
220
220
|
* @param {Vector3} b The second 3D vector.
|
|
221
221
|
* @param {Vector3} out The output 3D vector.
|
|
@@ -227,7 +227,7 @@ export function add(a: Vector3, b: Vector3, out: Vector3): Vector3;
|
|
|
227
227
|
export function subtract(a: Vector3, b: Vector3, out: Vector3): Vector3;
|
|
228
228
|
|
|
229
229
|
/**
|
|
230
|
-
*
|
|
230
|
+
* Multiply a 3-vector by a scalar.
|
|
231
231
|
* @param {Vector3} vec
|
|
232
232
|
* @param {Number} scalar
|
|
233
233
|
* @example
|
|
@@ -238,7 +238,7 @@ export function subtract(a: Vector3, b: Vector3, out: Vector3): Vector3;
|
|
|
238
238
|
export function multiplyScalar(vec: Vector3, scalar: number): Vector3;
|
|
239
239
|
|
|
240
240
|
/**
|
|
241
|
-
*
|
|
241
|
+
* Multiply a 3-vector by a scalar.
|
|
242
242
|
* @param {Vector2} vec
|
|
243
243
|
* @param {Number} scalar
|
|
244
244
|
* @example
|
|
@@ -249,7 +249,7 @@ export function multiplyScalar(vec: Vector3, scalar: number): Vector3;
|
|
|
249
249
|
export function multiplyScalar2D(vec: Vector2, scalar: number): Vector2;
|
|
250
250
|
|
|
251
251
|
/**
|
|
252
|
-
*
|
|
252
|
+
* Multiply two 3-vectors.
|
|
253
253
|
* @param {Vector3} a
|
|
254
254
|
* @param {Vector3} b
|
|
255
255
|
* @param {Number} scalar
|
|
@@ -267,7 +267,7 @@ export function multiplyAccumulate(
|
|
|
267
267
|
): Vector3;
|
|
268
268
|
|
|
269
269
|
/**
|
|
270
|
-
*
|
|
270
|
+
* Multiply two 2-vectors.
|
|
271
271
|
* @param {Vector2} a
|
|
272
272
|
* @param {Vector2} b
|
|
273
273
|
* @param {Number} scalar
|
|
@@ -285,7 +285,7 @@ export function multiplyAccumulate2D(
|
|
|
285
285
|
): Vector2;
|
|
286
286
|
|
|
287
287
|
/**
|
|
288
|
-
*
|
|
288
|
+
* Dot product of two 3-vectors.
|
|
289
289
|
* @param {Vector3} x
|
|
290
290
|
* @param {Vector3} y
|
|
291
291
|
* @example
|
|
@@ -312,17 +312,23 @@ export function outer(x: Vector3, y: Vector3, out_3x3: Matrix3x3): void;
|
|
|
312
312
|
export function cross(x: Vector3, y: Vector3, out: Vector3): Vector3;
|
|
313
313
|
|
|
314
314
|
/**
|
|
315
|
-
*
|
|
316
|
-
* @param {Number[]} x
|
|
317
|
-
* @param {Number} n
|
|
315
|
+
* Compute the norm of a vector.
|
|
316
|
+
* @param {Number[]} x The vector to compute the norm of.
|
|
317
|
+
* @param {Number} [n] The number of components to consider (default is 3).
|
|
318
318
|
*/
|
|
319
|
-
export function norm(x: number[], n
|
|
319
|
+
export function norm(x: number[], n?: number): number;
|
|
320
320
|
|
|
321
321
|
/**
|
|
322
322
|
* Normalize in place. Returns norm.
|
|
323
|
-
* @param {
|
|
323
|
+
* @param {Number[]} x The vector to normalize.
|
|
324
324
|
*/
|
|
325
|
-
export function normalize(x:
|
|
325
|
+
export function normalize(x: number[]): number;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Normalize in place. Returns norm.
|
|
329
|
+
* @param {Number[]} x The vector to normalize.
|
|
330
|
+
*/
|
|
331
|
+
export function normalize4D(x: number[]): number;
|
|
326
332
|
|
|
327
333
|
/**
|
|
328
334
|
* Given a unit vector v1, find two unit vectors v2 and v3 such that v1 cross v2 = v3
|
|
@@ -339,10 +345,10 @@ export function perpendiculars(
|
|
|
339
345
|
): void;
|
|
340
346
|
|
|
341
347
|
/**
|
|
342
|
-
*
|
|
343
|
-
* @param {Vector3} a
|
|
344
|
-
* @param {Vector3} b
|
|
345
|
-
* @param {Vector3} projection
|
|
348
|
+
* Project vector `a` onto vector `b` and returns the result in projection vector.
|
|
349
|
+
* @param {Vector3} a The first 3D vector.
|
|
350
|
+
* @param {Vector3} b The second 3D vector.
|
|
351
|
+
* @param {Vector3} projection The projection 3D vector.
|
|
346
352
|
*/
|
|
347
353
|
export function projectVector(
|
|
348
354
|
a: Vector3,
|
|
@@ -351,7 +357,7 @@ export function projectVector(
|
|
|
351
357
|
): boolean;
|
|
352
358
|
|
|
353
359
|
/**
|
|
354
|
-
*
|
|
360
|
+
* Compute the dot product of two 2D vectors.
|
|
355
361
|
* @param {Vector2} x
|
|
356
362
|
* @param {Vector2} y
|
|
357
363
|
*/
|
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 { ar as LUFactor3x3, as as LUSolve3x3, a0 as Pi, k as add, Z as angleBetweenVectors, W as areBoundsInitialized, E as areEquals, a as areMatricesEqual, a5 as arrayMax, a4 as arrayMin, G as arrayRange, a9 as beginCombination, a8 as binomial, aV as boundsIsWithinOtherBounds, a1 as ceil, a6 as ceilLog2, aR as clampAndNormalizeValue, F as clampValue, c as clampVector, aq as columnsToMat3, ap as columnsToMat4, aQ as computeBoundsFromPoints, $ as createArray, I as createUninitializedBounds, j as cross, f as default, B as degreesFromRadians, o as determinant2x2, z as determinant3x3, aF as diagonalize3x3, e as distance2BetweenPoints, d as dot, ai as dot2D, aJ as estimateMatrixCondition, aU as extentIsWithinOtherExtent, a7 as factorial, b1 as float2CssRGBA, X as floatRGB2HexCode, b0 as floatToHex2, M as floor, ad as gaussian, ak as gaussianAmplitude, al as gaussianWeight, aT as getAdjustedScalarRange, H as getMajorAxisIndex, aS as getScalarTypeFittingRange, ac as getSeed, V as getSparseOrthogonalMatrix, aM as hex2float, h as hsv2rgb, K as identity, ax as identity3x3, aY as inf, aw as invert3x3, p as invertMatrix, a_ as isFinite, ay as isIdentity, az as isIdentity3x3, N as isInf, a$ as isNaN, i as isNan, Y as isPowerOfTwo, w as jacobi, q as jacobiN, Q as lab2rgb, aN as lab2xyz, C as ldexp, at as linearSolve3x3, aH as luFactorLinearSystem, aI as luSolveLinearSystem, aC as matrix3x3ToQuaternion, a3 as max, a2 as min, au as multiply3x3_mat3, U as multiply3x3_vect3, m as multiplyAccumulate, af as multiplyAccumulate2D, L as multiplyMatrix, aD as multiplyQuaternion, x as multiplyScalar, ae as multiplyScalar2D, T as nearestPowerOfTwo, aZ as negInf, aa as nextCombination, n as norm, an as norm2D, l as normalize, S as normalize2D, J as normalize4D, aE as orthogonalize3x3, ag as outer, am as outer2D, t as perpendiculars, aW as pointIsWithinBounds, ah as projectVector, aj as projectVector2D, aA as quaternionToMatrix3x3, r as radiansFromDegrees, y as random, ab as randomSeed, O as rgb2hsv, P as rgb2lab, aP as rgb2xyz, R as round, aB as roundNumber, b as roundVector, A as rowsToMat3, ao as rowsToMat4, _ as signedAngleBetweenVectors, aG as singularValueDecomposition3x3, aX as solve3PointCircle, aK as solveHomogeneousLeastSquares, aL as solveLeastSquares, g as solveLinearSystem, s as subtract, av as transpose3x3, u as uninitializeBounds, aO as xyz2lab, D as xyz2rgb } from './Math/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as macro } from '../../macros2.js';
|
|
1
|
+
import { m as macro, T as TYPED_ARRAYS } from '../../macros2.js';
|
|
2
2
|
import vtkCell from './Cell.js';
|
|
3
|
-
import { d as dot, j as cross, l as normalize, m as multiplyAccumulate, e as distance2BetweenPoints, o as determinant2x2, p as invertMatrix } from '../Core/Math/index.js';
|
|
3
|
+
import { d as dot, j as cross, l as normalize, m as multiplyAccumulate, e as distance2BetweenPoints, o as determinant2x2, s as subtract, p as invertMatrix } from '../Core/Math/index.js';
|
|
4
4
|
import vtkLine from './Line.js';
|
|
5
5
|
import vtkPlane from './Plane.js';
|
|
6
6
|
|
|
@@ -590,21 +590,16 @@ function vtkTriangle(publicAPI, model) {
|
|
|
590
590
|
* @param {Number[]} derivs - The derivatives.
|
|
591
591
|
*/
|
|
592
592
|
publicAPI.derivatives = (subId, pcoords, values, dim, derivs) => {
|
|
593
|
-
const x0 =
|
|
594
|
-
const x1 =
|
|
595
|
-
const x2 =
|
|
596
|
-
model.points.getPoint(0, x0);
|
|
597
|
-
model.points.getPoint(1, x1);
|
|
598
|
-
model.points.getPoint(2, x2);
|
|
593
|
+
const x0 = model.points.getPoint(0);
|
|
594
|
+
const x1 = model.points.getPoint(1);
|
|
595
|
+
const x2 = model.points.getPoint(2);
|
|
599
596
|
const n = [];
|
|
600
597
|
const v10 = [];
|
|
601
598
|
const v20 = [];
|
|
602
599
|
const v = [];
|
|
603
600
|
computeNormal(x0, x1, x2, n);
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
v[i] = x2[i] - x0[i];
|
|
607
|
-
}
|
|
601
|
+
subtract(x1, x0, v10);
|
|
602
|
+
subtract(x2, x0, v);
|
|
608
603
|
cross(n, v10, v20);
|
|
609
604
|
const lenX = normalize(v10); // check for degenerate triangle
|
|
610
605
|
|
|
@@ -629,7 +624,7 @@ function vtkTriangle(publicAPI, model) {
|
|
|
629
624
|
const J = [v1[0] - v0[0], v1[1] - v0[1], v2[0] - v0[0], v2[1] - v0[1]];
|
|
630
625
|
|
|
631
626
|
// Compute inverse Jacobian (expects flat array)
|
|
632
|
-
const JI =
|
|
627
|
+
const JI = macro.newTypedArray(TYPED_ARRAYS.Float64Array, 4);
|
|
633
628
|
invertMatrix(J, JI, 2); // returns flat array [JI00, JI01, JI10, JI11]
|
|
634
629
|
|
|
635
630
|
// Compute derivatives
|
package/Filters/Core/Cutter.js
CHANGED
|
@@ -257,6 +257,7 @@ function vtkCutter(publicAPI, model) {
|
|
|
257
257
|
const name = pointData.getArrayName(arrayIdx);
|
|
258
258
|
const array = vtkDataArray.newInstance({
|
|
259
259
|
name,
|
|
260
|
+
dataType: pointData.getArrayByIndex(arrayIdx).getDataType(),
|
|
260
261
|
values: newPointData[name],
|
|
261
262
|
numberOfComponents: pointData.getArrayByIndex(arrayIdx).getNumberOfComponents()
|
|
262
263
|
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import vtkPolyData from './../../Common/DataModel/PolyData';
|
|
2
|
+
import vtkTexture from './../../Rendering/Core/Texture';
|
|
3
|
+
import { vtkAlgorithm, vtkObject } from './../../interfaces';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export interface IOBJWriterInitialValues {
|
|
9
|
+
modelFilename?: string;
|
|
10
|
+
materialFilename?: string;
|
|
11
|
+
texture?: vtkTexture;
|
|
12
|
+
textureFileName?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type vtkOBJWriterBase = vtkObject & vtkAlgorithm;
|
|
16
|
+
|
|
17
|
+
export interface vtkOBJWriter extends vtkOBJWriterBase {
|
|
18
|
+
/**
|
|
19
|
+
* Get the zip file containing the OBJ and MTL files.
|
|
20
|
+
*/
|
|
21
|
+
exportAsZip(): Promise<Uint8Array>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get the MTL file as a string.
|
|
25
|
+
*/
|
|
26
|
+
getMtl(): string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param inData
|
|
31
|
+
* @param outData
|
|
32
|
+
*/
|
|
33
|
+
requestData(inData: any, outData: any): void;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Set the material filename.
|
|
37
|
+
* @param materialFilename
|
|
38
|
+
* @returns {boolean} true if the material file name was set successfully
|
|
39
|
+
*/
|
|
40
|
+
setMaterialFilename(materialFilename: string): boolean;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Set the model filename.
|
|
44
|
+
* @param modelFilename
|
|
45
|
+
*/
|
|
46
|
+
setModelFilename(modelFilename: string): boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Set the texture instance.
|
|
50
|
+
* @param {vtkTexture} texture
|
|
51
|
+
* @returns {boolean} true if the texture was set successfully
|
|
52
|
+
*/
|
|
53
|
+
setTexture(texture: vtkTexture): boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Set the texture file name.
|
|
57
|
+
* @param {string} textureFileName
|
|
58
|
+
* @returns {boolean} true if the texture file name was set successfully
|
|
59
|
+
*/
|
|
60
|
+
setTextureFileName(textureFileName: string): boolean;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Method used to decorate a given object (publicAPI+model) with vtkOBJWriter characteristics.
|
|
65
|
+
*
|
|
66
|
+
* @param publicAPI object on which methods will be bounds (public)
|
|
67
|
+
* @param model object on which data structure will be bounds (protected)
|
|
68
|
+
* @param {IOBJWriterInitialValues} [initialValues] (default: {})
|
|
69
|
+
*/
|
|
70
|
+
export function extend(
|
|
71
|
+
publicAPI: object,
|
|
72
|
+
model: object,
|
|
73
|
+
initialValues?: IOBJWriterInitialValues
|
|
74
|
+
): void;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Method used to create a new instance of vtkOBJWriter
|
|
78
|
+
* @param {IOBJWriterInitialValues} [initialValues] for pre-setting some of its content
|
|
79
|
+
*/
|
|
80
|
+
export function newInstance(
|
|
81
|
+
initialValues?: IOBJWriterInitialValues
|
|
82
|
+
): vtkOBJWriter;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
* @param {vktPolyData} polyData
|
|
87
|
+
*/
|
|
88
|
+
export function writeOBJ(polyData: vtkPolyData): vtkPolyData;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* vtkOBJWriter writes wavefront obj (.obj) files in ASCII form. OBJ files
|
|
92
|
+
* contain the geometry including lines, triangles and polygons. Normals and
|
|
93
|
+
* texture coordinates on points are also written if they exist.
|
|
94
|
+
*
|
|
95
|
+
* One can specify a texture passing a vtkTexture using `setTexture`. If a texture is
|
|
96
|
+
* set, additional .mtl and .png files are generated.
|
|
97
|
+
*/
|
|
98
|
+
export declare const vtkOBJWriter: {
|
|
99
|
+
newInstance: typeof newInstance;
|
|
100
|
+
extend: typeof extend;
|
|
101
|
+
writeOBJ: typeof writeOBJ;
|
|
102
|
+
};
|
|
103
|
+
export default vtkOBJWriter;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { strToU8, zipSync } from 'fflate';
|
|
2
|
+
import { m as macro } from '../../macros2.js';
|
|
3
|
+
import vtkCellArray from '../../Common/Core/CellArray.js';
|
|
4
|
+
import vtkTriangleStrip from '../../Common/DataModel/TriangleStrip.js';
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
vtkErrorMacro
|
|
8
|
+
} = macro;
|
|
9
|
+
|
|
10
|
+
// ----------------------------------------------------------------------------
|
|
11
|
+
// Global methods
|
|
12
|
+
// ----------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
// ----------------------------------------------------------------------------
|
|
15
|
+
// vtkOBJWriter methods
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
const writeFaces = (faces, withNormals, withTCoords) => {
|
|
19
|
+
let outputData = '';
|
|
20
|
+
const fd = faces.getData();
|
|
21
|
+
let offset = 0;
|
|
22
|
+
while (offset < fd.length) {
|
|
23
|
+
const faceSize = fd[offset++];
|
|
24
|
+
outputData += 'f';
|
|
25
|
+
for (let i = 0; i < faceSize; i++) {
|
|
26
|
+
outputData += ` ${fd[offset + i] + 1}`;
|
|
27
|
+
if (withTCoords) {
|
|
28
|
+
outputData += `/${fd[offset + i] + 1}`;
|
|
29
|
+
if (withNormals) {
|
|
30
|
+
outputData += `//${fd[offset + i] + 1}`;
|
|
31
|
+
}
|
|
32
|
+
} else if (withNormals) {
|
|
33
|
+
outputData += `//${fd[offset + i] + 1}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
offset += faceSize;
|
|
37
|
+
outputData += '\n';
|
|
38
|
+
}
|
|
39
|
+
return outputData;
|
|
40
|
+
};
|
|
41
|
+
const writeLines = lines => {
|
|
42
|
+
let outputData = '';
|
|
43
|
+
const ld = lines.getData();
|
|
44
|
+
let offset = 0;
|
|
45
|
+
while (offset < ld.length) {
|
|
46
|
+
const lineSize = ld[offset++];
|
|
47
|
+
outputData += 'l';
|
|
48
|
+
for (let i = 0; i < lineSize; i++) {
|
|
49
|
+
outputData += ` ${ld[offset + i] + 1}`;
|
|
50
|
+
}
|
|
51
|
+
offset += lineSize;
|
|
52
|
+
outputData += '\n';
|
|
53
|
+
}
|
|
54
|
+
return outputData;
|
|
55
|
+
};
|
|
56
|
+
const writePoints = (pts, normals, tcoords) => {
|
|
57
|
+
const outputData = [];
|
|
58
|
+
const nbPts = pts.getNumberOfPoints();
|
|
59
|
+
let p;
|
|
60
|
+
|
|
61
|
+
// Positions
|
|
62
|
+
for (let i = 0; i < nbPts; i++) {
|
|
63
|
+
p = pts.getPoint(i);
|
|
64
|
+
outputData.push(`v ${p[0]} ${p[1]} ${p[2]}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Normals
|
|
68
|
+
if (normals) {
|
|
69
|
+
for (let i = 0; i < nbPts; i++) {
|
|
70
|
+
p = normals.getTuple(i);
|
|
71
|
+
outputData.push(`vn ${p[0]} ${p[1]} ${p[2]}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Textures
|
|
76
|
+
if (tcoords) {
|
|
77
|
+
for (let i = 0; i < nbPts; i++) {
|
|
78
|
+
p = tcoords.getTuple(i);
|
|
79
|
+
if (p[0] !== -1.0) {
|
|
80
|
+
outputData.push(`vt ${p[0]} ${p[1]}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return `${outputData.join('\n')}\n`;
|
|
85
|
+
};
|
|
86
|
+
const writeMTL = (materialName, textureFileName) => {
|
|
87
|
+
const outputData = [];
|
|
88
|
+
outputData.push(`newmtl ${materialName}`);
|
|
89
|
+
outputData.push(`map_Kd ${textureFileName}`);
|
|
90
|
+
return outputData.join('\n');
|
|
91
|
+
};
|
|
92
|
+
const writeOBJ = (polyData, materialFilename, materialName) => {
|
|
93
|
+
let outputData = '# VTK.js generated OBJ File\n';
|
|
94
|
+
const pts = polyData.getPoints();
|
|
95
|
+
const polys = polyData.getPolys();
|
|
96
|
+
const strips = polyData.getStrips() ? polyData.getStrips().getData() : null;
|
|
97
|
+
const lines = polyData.getLines();
|
|
98
|
+
const normals = polyData.getPointData().getNormals();
|
|
99
|
+
const tcoords = polyData.getPointData().getTCoords();
|
|
100
|
+
const hasPtNormals = normals !== null;
|
|
101
|
+
const hasPtTCoords = tcoords !== null;
|
|
102
|
+
if (!pts) {
|
|
103
|
+
vtkErrorMacro('No data to write!');
|
|
104
|
+
return outputData;
|
|
105
|
+
}
|
|
106
|
+
if (materialFilename) {
|
|
107
|
+
// Write material library
|
|
108
|
+
outputData += `mtllib ${materialFilename}\n`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Write material if a texture is specified
|
|
112
|
+
if (materialName) {
|
|
113
|
+
// declare material in obj file
|
|
114
|
+
outputData += `usemtl ${materialName}\n`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Write points
|
|
118
|
+
outputData += writePoints(pts, normals, tcoords);
|
|
119
|
+
|
|
120
|
+
// Decompose any triangle strips into triangles
|
|
121
|
+
const polyStrips = vtkCellArray.newInstance();
|
|
122
|
+
if (strips && strips.length > 0) {
|
|
123
|
+
vtkTriangleStrip.decomposeStrip(pts, polyStrips);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Write triangle strips
|
|
127
|
+
if (polyStrips.getNumberOfCells() > 0) {
|
|
128
|
+
outputData += writeFaces(polyStrips, hasPtNormals, hasPtTCoords);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Write polygons.
|
|
132
|
+
if (polys) {
|
|
133
|
+
outputData += writeFaces(polys, hasPtNormals, hasPtTCoords);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Write lines.
|
|
137
|
+
if (lines) {
|
|
138
|
+
outputData += writeLines(lines);
|
|
139
|
+
}
|
|
140
|
+
return outputData;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// ----------------------------------------------------------------------------
|
|
144
|
+
// Static API
|
|
145
|
+
// ----------------------------------------------------------------------------
|
|
146
|
+
|
|
147
|
+
const STATIC = {
|
|
148
|
+
writeOBJ
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// ----------------------------------------------------------------------------
|
|
152
|
+
// vtkOBJWriter methods
|
|
153
|
+
// ----------------------------------------------------------------------------
|
|
154
|
+
|
|
155
|
+
function vtkOBJWriter(publicAPI, model) {
|
|
156
|
+
// Set our className
|
|
157
|
+
model.classHierarchy.push('vtkOBJWriter');
|
|
158
|
+
publicAPI.exportAsZip = () => {
|
|
159
|
+
publicAPI.update();
|
|
160
|
+
const modelFilename = model.modelFilename;
|
|
161
|
+
const materialFilename = model.materialFilename;
|
|
162
|
+
const textureFileName = model.textureFileName;
|
|
163
|
+
const imageData = model.texture.getInputAsJsImageData?.();
|
|
164
|
+
const zipContent = {};
|
|
165
|
+
zipContent[`${modelFilename}.obj`] = strToU8(model.output[0]);
|
|
166
|
+
zipContent[`${materialFilename}.mtl`] = strToU8(model.mtl);
|
|
167
|
+
const canvas = new OffscreenCanvas(imageData.width, imageData.height);
|
|
168
|
+
const ctx = canvas.getContext('2d');
|
|
169
|
+
ctx.putImageData(imageData, 0, 0);
|
|
170
|
+
return new Promise(resolve => {
|
|
171
|
+
canvas.toBlob(async blob => {
|
|
172
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
173
|
+
zipContent[`${textureFileName}.png`] = new Uint8Array(arrayBuffer);
|
|
174
|
+
resolve(zipSync(zipContent));
|
|
175
|
+
}, 'image/png');
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
publicAPI.requestData = (inData, outData) => {
|
|
179
|
+
const input = inData[0];
|
|
180
|
+
if (!input || !input.isA('vtkPolyData')) {
|
|
181
|
+
vtkErrorMacro('Invalid or missing vtkPolyData input');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Update output
|
|
186
|
+
const materialFilename = `${model.materialFilename}.mtl`;
|
|
187
|
+
const textureFileName = `${model.textureFileName}.png`;
|
|
188
|
+
outData[0] = writeOBJ(input, materialFilename, model.materialName);
|
|
189
|
+
model.mtl = writeMTL(model.materialName, textureFileName);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// ----------------------------------------------------------------------------
|
|
194
|
+
// Object factory
|
|
195
|
+
// ----------------------------------------------------------------------------
|
|
196
|
+
|
|
197
|
+
const DEFAULT_VALUES = {
|
|
198
|
+
modelFilename: 'model',
|
|
199
|
+
materialName: 'mat_01',
|
|
200
|
+
materialFilename: 'material',
|
|
201
|
+
texture: null,
|
|
202
|
+
textureFileName: 'texture'
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// ----------------------------------------------------------------------------
|
|
206
|
+
|
|
207
|
+
function extend(publicAPI, model) {
|
|
208
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
209
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
210
|
+
|
|
211
|
+
// Make this a VTK object
|
|
212
|
+
macro.obj(publicAPI, model);
|
|
213
|
+
|
|
214
|
+
// Also make it an algorithm with one input and one output
|
|
215
|
+
macro.algo(publicAPI, model, 1, 1);
|
|
216
|
+
macro.get(publicAPI, model, ['mtl']);
|
|
217
|
+
macro.set(publicAPI, model, ['modelFilename', 'materialFilename', 'texture', 'textureFileName']);
|
|
218
|
+
|
|
219
|
+
// Object specific methods
|
|
220
|
+
vtkOBJWriter(publicAPI, model);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// ----------------------------------------------------------------------------
|
|
224
|
+
|
|
225
|
+
const newInstance = macro.newInstance(extend, 'vtkOBJWriter');
|
|
226
|
+
|
|
227
|
+
// ----------------------------------------------------------------------------
|
|
228
|
+
|
|
229
|
+
var vtkOBJWriter$1 = {
|
|
230
|
+
newInstance,
|
|
231
|
+
extend,
|
|
232
|
+
...STATIC
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
export { STATIC, vtkOBJWriter$1 as default, extend, newInstance };
|
package/IO/Misc.js
CHANGED
|
@@ -5,6 +5,7 @@ import vtkJSONNucleoReader from './Misc/JSONNucleoReader.js';
|
|
|
5
5
|
import vtkJSONReader from './Misc/JSONReader.js';
|
|
6
6
|
import vtkMTLReader from './Misc/MTLReader.js';
|
|
7
7
|
import vtkOBJReader from './Misc/OBJReader.js';
|
|
8
|
+
import vtkOBJWriter from './Misc/OBJWriter.js';
|
|
8
9
|
import vtkPDBReader from './Misc/PDBReader.js';
|
|
9
10
|
import vtkSkyboxReader from './Misc/SkyboxReader.js';
|
|
10
11
|
import vtkGCodeReader from './Misc/GCodeReader.js';
|
|
@@ -17,6 +18,7 @@ var Misc = {
|
|
|
17
18
|
vtkJSONReader,
|
|
18
19
|
vtkMTLReader,
|
|
19
20
|
vtkOBJReader,
|
|
21
|
+
vtkOBJWriter,
|
|
20
22
|
vtkPDBReader,
|
|
21
23
|
vtkSkyboxReader,
|
|
22
24
|
vtkGCodeReader
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import { MouseButton } from '../../Rendering/Core/RenderWindowInteractor/Constants.js';
|
|
3
3
|
import vtkInteractorStyle from '../../Rendering/Core/InteractorStyle.js';
|
|
4
|
+
import { mat4, vec3 } from 'gl-matrix';
|
|
4
5
|
|
|
5
6
|
const {
|
|
6
7
|
vtkDebugMacro
|
|
@@ -101,6 +102,62 @@ function dollyByFactor(interactor, renderer, factor) {
|
|
|
101
102
|
renderer.updateLightsGeometryToFollowCamera();
|
|
102
103
|
}
|
|
103
104
|
}
|
|
105
|
+
function getCameraMatrix(renderer, tempMatrix) {
|
|
106
|
+
const cam = renderer.getActiveCamera();
|
|
107
|
+
if (cam) {
|
|
108
|
+
mat4.copy(tempMatrix, cam.getViewMatrix());
|
|
109
|
+
return tempMatrix;
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Transforms a vector by the transformation delta between two matrices.
|
|
116
|
+
*
|
|
117
|
+
* @param {Object} tempObjects - Temporary matrices/vectors for computation
|
|
118
|
+
* @param {mat4} beforeMatrix - Matrix before transformation
|
|
119
|
+
* @param {mat4} afterMatrix - Matrix after transformation
|
|
120
|
+
* @param {Array} vector - Vector to transform [x, y, z]
|
|
121
|
+
* @returns {Array} Transformed vector [x, y, z]
|
|
122
|
+
*/
|
|
123
|
+
function transformVectorByTransformation(tempObjects, beforeMatrix, afterMatrix, vector) {
|
|
124
|
+
const {
|
|
125
|
+
matrixA,
|
|
126
|
+
matrixB,
|
|
127
|
+
newCenter
|
|
128
|
+
} = tempObjects;
|
|
129
|
+
|
|
130
|
+
// The view matrix from vtk.js is row-major, but gl-matrix expects column-major.
|
|
131
|
+
// We need to transpose them before use.
|
|
132
|
+
mat4.transpose(matrixA, beforeMatrix);
|
|
133
|
+
mat4.transpose(matrixB, afterMatrix);
|
|
134
|
+
mat4.invert(matrixB, matrixB);
|
|
135
|
+
|
|
136
|
+
// Compute delta transformation matrix
|
|
137
|
+
mat4.multiply(matrixA, matrixB, matrixA);
|
|
138
|
+
vec3.transformMat4(newCenter, vector, matrixA);
|
|
139
|
+
return newCenter;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Computes the new center of rotation based on camera movement.
|
|
144
|
+
* When the camera moves (pan), the center of rotation should move
|
|
145
|
+
* by the same transformation to maintain consistent rotation behavior.
|
|
146
|
+
*
|
|
147
|
+
* @param {Object} tempObjects - Temporary matrices/vectors for computation
|
|
148
|
+
* @param {Object} renderer - VTK renderer
|
|
149
|
+
* @param {mat4} beforeCameraMatrix - Camera view matrix before movement
|
|
150
|
+
* @param {Array} oldCenterOfRotation - Previous center of rotation [x, y, z]
|
|
151
|
+
* @returns {Array} New center of rotation [x, y, z]
|
|
152
|
+
*/
|
|
153
|
+
function computeNewCenterOfRotation(tempObjects, renderer, beforeCameraMatrix, oldCenterOfRotation) {
|
|
154
|
+
const cam = renderer.getActiveCamera();
|
|
155
|
+
if (!cam || !beforeCameraMatrix) {
|
|
156
|
+
return oldCenterOfRotation;
|
|
157
|
+
}
|
|
158
|
+
const afterMatrixRowMajor = cam.getViewMatrix();
|
|
159
|
+
return transformVectorByTransformation(tempObjects, beforeCameraMatrix, afterMatrixRowMajor, oldCenterOfRotation);
|
|
160
|
+
}
|
|
104
161
|
|
|
105
162
|
// ----------------------------------------------------------------------------
|
|
106
163
|
// Static API
|
|
@@ -119,6 +176,14 @@ const STATIC = {
|
|
|
119
176
|
function vtkInteractorStyleManipulator(publicAPI, model) {
|
|
120
177
|
// Set our className
|
|
121
178
|
model.classHierarchy.push('vtkInteractorStyleManipulator');
|
|
179
|
+
|
|
180
|
+
// Initialize temporary objects to reduce garbage collection
|
|
181
|
+
const tempCameraMatrix = mat4.create();
|
|
182
|
+
const tempComputeObjects = {
|
|
183
|
+
matrixA: mat4.create(),
|
|
184
|
+
matrixB: mat4.create(),
|
|
185
|
+
newCenter: vec3.create()
|
|
186
|
+
};
|
|
122
187
|
model.currentVRManipulators = new Map();
|
|
123
188
|
model.mouseManipulators = [];
|
|
124
189
|
model.keyboardManipulators = [];
|
|
@@ -415,7 +480,11 @@ function vtkInteractorStyleManipulator(publicAPI, model) {
|
|
|
415
480
|
publicAPI.handleMouseMove = callData => {
|
|
416
481
|
model.cachedMousePosition = callData.position;
|
|
417
482
|
if (model.currentManipulator && model.currentManipulator.onMouseMove) {
|
|
418
|
-
|
|
483
|
+
const renderer = model.getRenderer(callData);
|
|
484
|
+
const beforeCameraMatrix = getCameraMatrix(renderer, tempCameraMatrix);
|
|
485
|
+
model.currentManipulator.onMouseMove(model._interactor, renderer, callData.position);
|
|
486
|
+
const newCenter = computeNewCenterOfRotation(tempComputeObjects, renderer, beforeCameraMatrix, model.centerOfRotation);
|
|
487
|
+
publicAPI.setCenterOfRotation(newCenter);
|
|
419
488
|
publicAPI.invokeInteractionEvent(INTERACTION_EVENT);
|
|
420
489
|
}
|
|
421
490
|
};
|
|
@@ -557,16 +626,20 @@ function vtkInteractorStyleManipulator(publicAPI, model) {
|
|
|
557
626
|
|
|
558
627
|
//----------------------------------------------------------------------------
|
|
559
628
|
publicAPI.handlePan = callData => {
|
|
629
|
+
const renderer = model.getRenderer(callData);
|
|
630
|
+
const beforeCameraMatrix = getCameraMatrix(renderer, tempCameraMatrix);
|
|
560
631
|
let count = model.gestureManipulators.length;
|
|
561
632
|
let actionCount = 0;
|
|
562
633
|
while (count--) {
|
|
563
634
|
const manipulator = model.gestureManipulators[count];
|
|
564
635
|
if (manipulator && manipulator.isPanEnabled()) {
|
|
565
|
-
manipulator.onPan(model._interactor,
|
|
636
|
+
manipulator.onPan(model._interactor, renderer, callData.translation);
|
|
566
637
|
actionCount++;
|
|
567
638
|
}
|
|
568
639
|
}
|
|
569
640
|
if (actionCount) {
|
|
641
|
+
const newCenter = computeNewCenterOfRotation(tempComputeObjects, renderer, beforeCameraMatrix, model.centerOfRotation);
|
|
642
|
+
publicAPI.setCenterOfRotation(newCenter);
|
|
570
643
|
publicAPI.invokeInteractionEvent(INTERACTION_EVENT);
|
|
571
644
|
}
|
|
572
645
|
};
|
|
@@ -156,11 +156,11 @@ export interface vtkCamera extends vtkObject {
|
|
|
156
156
|
getFreezeFocalPoint(): boolean;
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
|
-
* Not implemented yet
|
|
160
159
|
* Get the plane equations that bound the view frustum.
|
|
161
|
-
* @param {Number} aspect Camera frustum aspect ratio.
|
|
160
|
+
* @param {Number} [aspect] Camera frustum aspect ratio (default: 1.0).
|
|
161
|
+
* @param {Float64Array} [planes] Optional array to fill with the plane equations.
|
|
162
162
|
*/
|
|
163
|
-
getFrustumPlanes(aspect
|
|
163
|
+
getFrustumPlanes(aspect?: number, planes?: Float64Array): Float64Array;
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
166
|
* Not implemented yet
|
package/Rendering/Core/Camera.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mat4, vec4, vec3, quat } from 'gl-matrix';
|
|
2
2
|
import { m as macro } from '../../macros2.js';
|
|
3
|
-
import { r as radiansFromDegrees, k as add, j as cross } from '../../Common/Core/Math/index.js';
|
|
3
|
+
import { r as radiansFromDegrees, k as add, J as normalize4D, j as cross } from '../../Common/Core/Math/index.js';
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
vtkDebugMacro
|
|
@@ -274,8 +274,38 @@ function vtkCamera(publicAPI, model) {
|
|
|
274
274
|
publicAPI.setObliqueAngles = (alpha, beta) => {};
|
|
275
275
|
publicAPI.getOrientation = () => {};
|
|
276
276
|
publicAPI.getOrientationWXYZ = () => {};
|
|
277
|
-
publicAPI.getFrustumPlanes =
|
|
278
|
-
|
|
277
|
+
publicAPI.getFrustumPlanes = function () {
|
|
278
|
+
let aspect = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1.0;
|
|
279
|
+
let planes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Float64Array(24);
|
|
280
|
+
const normals = [
|
|
281
|
+
// Left
|
|
282
|
+
[1, 0, 0, 1],
|
|
283
|
+
// Right
|
|
284
|
+
[-1, 0, 0, 1],
|
|
285
|
+
// Bottom
|
|
286
|
+
[0, 1, 0, 1],
|
|
287
|
+
// Top
|
|
288
|
+
[0, -1, 0, 1],
|
|
289
|
+
// Near
|
|
290
|
+
[0, 0, 1, 1],
|
|
291
|
+
// Far
|
|
292
|
+
[0, 0, -1, 1]];
|
|
293
|
+
|
|
294
|
+
// Get the composite projection matrix
|
|
295
|
+
const matrix = publicAPI.getCompositeProjectionMatrix(aspect, -1, 1);
|
|
296
|
+
|
|
297
|
+
// Transform the normals to world coordinates
|
|
298
|
+
for (let i = 0; i < 6; i++) {
|
|
299
|
+
vec4.transformMat4(normals[i], normals[i], matrix);
|
|
300
|
+
|
|
301
|
+
// Normalize the plane normal
|
|
302
|
+
normalize4D(normals[i]);
|
|
303
|
+
planes[4 * i + 0] = normals[i][0];
|
|
304
|
+
planes[4 * i + 1] = normals[i][1];
|
|
305
|
+
planes[4 * i + 2] = normals[i][2];
|
|
306
|
+
planes[4 * i + 3] = normals[i][3];
|
|
307
|
+
}
|
|
308
|
+
return planes;
|
|
279
309
|
};
|
|
280
310
|
publicAPI.getCameraLightTransformMatrix = matrix => {
|
|
281
311
|
mat4.copy(matrix, model.cameraLightTransform);
|
|
@@ -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, M as floor, N as isInf, O as rgb2hsv, P as rgb2lab, Q 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 { R as round, M 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 { S as normalize2D, T 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 { F as clampValue,
|
|
5
|
+
import { F as clampValue, U as multiply3x3_vect3, I as createUninitializedBounds, V 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 {
|
|
5
|
+
import { W as areBoundsInitialized, u as uninitializeBounds, r as radiansFromDegrees, d as dot, I 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 { T 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';
|
|
@@ -5,7 +5,7 @@ import vtkActor2D from './Actor2D.js';
|
|
|
5
5
|
import vtkMapper2D from './Mapper2D.js';
|
|
6
6
|
import vtkTextProperty from './TextProperty.js';
|
|
7
7
|
import ImageHelper from '../../Common/Core/ImageHelper.js';
|
|
8
|
-
import {
|
|
8
|
+
import { X as floatRGB2HexCode } from '../../Common/Core/Math/index.js';
|
|
9
9
|
|
|
10
10
|
// ----------------------------------------------------------------------------
|
|
11
11
|
// vtkTextActor methods
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
|
-
import { F as clampValue,
|
|
2
|
+
import { F as clampValue, M as floor } from '../../Common/Core/Math/index.js';
|
|
3
3
|
import vtkColorTransferFunction from './ColorTransferFunction.js';
|
|
4
4
|
import vtkPiecewiseFunction from '../../Common/DataModel/PiecewiseFunction.js';
|
|
5
5
|
import Constants from './VolumeProperty/Constants.js';
|
|
@@ -8,7 +8,7 @@ import vtkReplacementShaderMapper from './ReplacementShaderMapper.js';
|
|
|
8
8
|
import vtkShaderProgram from './ShaderProgram.js';
|
|
9
9
|
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
10
10
|
import vtkOpenGLTexture from './Texture.js';
|
|
11
|
-
import {
|
|
11
|
+
import { R 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
|
|
|
@@ -3,7 +3,7 @@ import Constants from './Texture/Constants.js';
|
|
|
3
3
|
import HalfFloat from '../../Common/Core/HalfFloat.js';
|
|
4
4
|
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';
|
|
5
5
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
6
|
-
import {
|
|
6
|
+
import { Y as isPowerOfTwo, T as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
|
|
7
7
|
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
8
8
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
9
9
|
import supportsNorm16LinearCached from './Texture/supportsNorm16Linear.js';
|
|
@@ -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,
|
|
6
|
+
import { s as subtract, Z 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, x as multiplyScalar,
|
|
4
|
+
import { k as add, l as normalize, s as subtract, d as dot, j as cross, m as multiplyAccumulate, x as multiplyScalar, _ 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, x as multiplyScalar, m as multiplyAccumulate,
|
|
5
|
+
import { s as subtract, l as normalize, j as cross, x as multiplyScalar, m as multiplyAccumulate, _ 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
|
@@ -113,6 +113,7 @@
|
|
|
113
113
|
/// <reference path="./IO/Misc/JSONReader.d.ts" />
|
|
114
114
|
/// <reference path="./IO/Misc/MTLReader.d.ts" />
|
|
115
115
|
/// <reference path="./IO/Misc/OBJReader.d.ts" />
|
|
116
|
+
/// <reference path="./IO/Misc/OBJWriter.d.ts" />
|
|
116
117
|
/// <reference path="./IO/Misc/PDBReader.d.ts" />
|
|
117
118
|
/// <reference path="./IO/XML/XMLImageDataReader.d.ts" />
|
|
118
119
|
/// <reference path="./IO/XML/XMLPolyDataReader.d.ts" />
|