@kitware/vtk.js 34.9.1 → 34.11.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/Points.d.ts +8 -0
- package/Common/Core/Points.js +2 -2
- package/Common/DataModel/AbstractPointLocator.d.ts +2 -2
- package/Common/DataModel/BoundingBox.d.ts +42 -3
- package/Common/DataModel/BoundingBox.js +181 -1
- package/Common/DataModel/Locator.d.ts +97 -5
- package/Common/DataModel/MergePoints.d.ts +64 -0
- package/Common/DataModel/MergePoints.js +130 -0
- package/Common/DataModel/Planes.d.ts +120 -0
- package/Common/DataModel/Planes.js +281 -0
- package/Common/DataModel/PointLocator.d.ts +217 -0
- package/Common/DataModel/PointLocator.js +751 -0
- package/Common/DataModel.js +2 -0
- package/Filters/Sources/FrustumSource.d.ts +111 -0
- package/Filters/Sources/FrustumSource.js +248 -0
- package/Rendering/Core/Camera.d.ts +16 -2
- package/Rendering/Core/Camera.js +14 -1
- package/Rendering/OpenGL/Glyph3DMapper.js +16 -0
- package/Rendering/OpenGL/glsl/vtkVolumeVS.glsl.js +1 -1
- package/index.d.ts +4 -0
- package/package.json +1 -1
package/Common/DataModel.js
CHANGED
|
@@ -12,6 +12,7 @@ import vtkLine from './DataModel/Line.js';
|
|
|
12
12
|
import vtkMolecule from './DataModel/Molecule.js';
|
|
13
13
|
import vtkPiecewiseFunction from './DataModel/PiecewiseFunction.js';
|
|
14
14
|
import vtkPlane from './DataModel/Plane.js';
|
|
15
|
+
import vtkPlanes from './DataModel/Planes.js';
|
|
15
16
|
import vtkPointSet from './DataModel/PointSet.js';
|
|
16
17
|
import vtkPolyData from './DataModel/PolyData.js';
|
|
17
18
|
import vtkSelectionNode from './DataModel/SelectionNode.js';
|
|
@@ -35,6 +36,7 @@ var DataModel = {
|
|
|
35
36
|
vtkMolecule,
|
|
36
37
|
vtkPiecewiseFunction,
|
|
37
38
|
vtkPlane,
|
|
39
|
+
vtkPlanes,
|
|
38
40
|
vtkPointSet,
|
|
39
41
|
vtkPolyData,
|
|
40
42
|
vtkSelectionNode,
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { DesiredOutputPrecision } from './../../Common/DataModel/DataSetAttributes';
|
|
2
|
+
import { vtkAlgorithm, vtkObject } from './../../interfaces';
|
|
3
|
+
import vtkPlanes from './../../Common/DataModel/Planes';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export interface IFrustumSourceInitialValues {
|
|
9
|
+
planes?: vtkPlanes;
|
|
10
|
+
showLines?: boolean;
|
|
11
|
+
outputPointsPrecision?: DesiredOutputPrecision;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type vtkFrustumSourceBase = vtkObject &
|
|
15
|
+
Omit<
|
|
16
|
+
vtkAlgorithm,
|
|
17
|
+
| 'getInputData'
|
|
18
|
+
| 'setInputData'
|
|
19
|
+
| 'setInputConnection'
|
|
20
|
+
| 'getInputConnection'
|
|
21
|
+
| 'addInputConnection'
|
|
22
|
+
| 'addInputData'
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
export interface vtkFrustumSource extends vtkFrustumSourceBase {
|
|
26
|
+
/**
|
|
27
|
+
* Get the output points precision.
|
|
28
|
+
*/
|
|
29
|
+
getOutputPointsPrecision(): DesiredOutputPrecision;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the planes defining the frustum.
|
|
33
|
+
*/
|
|
34
|
+
getPlanes(): vtkPlanes;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get whether to show lines.
|
|
38
|
+
*/
|
|
39
|
+
getShowLines(): boolean;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param inData
|
|
44
|
+
* @param outData
|
|
45
|
+
*/
|
|
46
|
+
requestData(inData: any, outData: any): void;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Set the output points precision.
|
|
50
|
+
* @param {DesiredOutputPrecision} precision
|
|
51
|
+
*/
|
|
52
|
+
setOutputPointsPrecision(precision: DesiredOutputPrecision): boolean;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Set the planes defining the frustum.
|
|
56
|
+
* @param {vtkPlanes} planes
|
|
57
|
+
*/
|
|
58
|
+
setPlanes(planes: vtkPlanes): boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Set whether to show lines.
|
|
62
|
+
* @param {Boolean} showLines
|
|
63
|
+
*/
|
|
64
|
+
setShowLines(showLines: boolean): boolean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Method used to decorate a given object (publicAPI+model) with vtkFrustumSource characteristics.
|
|
69
|
+
*
|
|
70
|
+
* @param publicAPI object on which methods will be bounds (public)
|
|
71
|
+
* @param model object on which data structure will be bounds (protected)
|
|
72
|
+
* @param {IFrustumSourceInitialValues} [initialValues] (default: {})
|
|
73
|
+
*/
|
|
74
|
+
export function extend(
|
|
75
|
+
publicAPI: object,
|
|
76
|
+
model: object,
|
|
77
|
+
initialValues?: IFrustumSourceInitialValues
|
|
78
|
+
): void;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Method used to create a new instance of vtkFrustumSource.
|
|
82
|
+
* @param {IFrustumSourceInitialValues} [initialValues] for pre-setting some of its content
|
|
83
|
+
*/
|
|
84
|
+
export function newInstance(
|
|
85
|
+
initialValues?: IFrustumSourceInitialValues
|
|
86
|
+
): vtkFrustumSource;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* vtkFrustumSource creates a frustum defines by a set of planes. The frustum is
|
|
90
|
+
* represented with four-sided polygons. It is possible to specify extra lines
|
|
91
|
+
* to better visualize the field of view.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```js
|
|
95
|
+
* import vtkFrustumSource from '@kitware/vtk.js/Filters/Sources/FrustumSource';
|
|
96
|
+
*
|
|
97
|
+
* const frustum = vtkFrustumSource.newInstance();
|
|
98
|
+
* const camera = vtkCamera.newInstance();
|
|
99
|
+
* camera.setClippingRange(0.1, 0.4);
|
|
100
|
+
* const planesArray = camera.getFrustumPlanes(1.0);
|
|
101
|
+
* const planes = vtkPlanes.newInstance();
|
|
102
|
+
* planes.setFrustumPlanes(planesArray);
|
|
103
|
+
* frustum.setPlanes(planes);
|
|
104
|
+
* frustum.setShowLines(false);
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare const vtkFrustumSource: {
|
|
108
|
+
newInstance: typeof newInstance;
|
|
109
|
+
extend: typeof extend;
|
|
110
|
+
};
|
|
111
|
+
export default vtkFrustumSource;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { m as macro } from '../../macros2.js';
|
|
2
|
+
import { f as vtkMath } from '../../Common/Core/Math/index.js';
|
|
3
|
+
import vtkCellArray from '../../Common/Core/CellArray.js';
|
|
4
|
+
import vtkPoints from '../../Common/Core/Points.js';
|
|
5
|
+
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
6
|
+
import { DesiredOutputPrecision } from '../../Common/DataModel/DataSetAttributes/Constants.js';
|
|
7
|
+
import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
vtkErrorMacro
|
|
11
|
+
} = macro;
|
|
12
|
+
|
|
13
|
+
// ----------------------------------------------------------------------------
|
|
14
|
+
// vtkFrustumSource methods
|
|
15
|
+
// ----------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
function vtkFrustumSource(publicAPI, model) {
|
|
18
|
+
// Set our className
|
|
19
|
+
model.classHierarchy.push('vtkFrustumSource');
|
|
20
|
+
function computePoint(planeIndices, pt) {
|
|
21
|
+
// Get planes and their normals/origins
|
|
22
|
+
const plane0 = model.planes.getPlane(planeIndices[0]);
|
|
23
|
+
const n0 = plane0.getNormal();
|
|
24
|
+
const p0 = plane0.getOrigin();
|
|
25
|
+
const plane1 = model.planes.getPlane(planeIndices[1]);
|
|
26
|
+
const n1 = plane1.getNormal();
|
|
27
|
+
const p1 = plane1.getOrigin();
|
|
28
|
+
const plane2 = model.planes.getPlane(planeIndices[2]);
|
|
29
|
+
const n2 = plane2.getNormal();
|
|
30
|
+
const p2 = plane2.getOrigin();
|
|
31
|
+
|
|
32
|
+
// Dot products
|
|
33
|
+
const d0 = vtkMath.dot(p0, n0);
|
|
34
|
+
const d1 = vtkMath.dot(p1, n1);
|
|
35
|
+
const d2 = vtkMath.dot(p2, n2);
|
|
36
|
+
|
|
37
|
+
// Cross products
|
|
38
|
+
const c12 = [0, 0, 0];
|
|
39
|
+
vtkMath.cross(n1, n2, c12);
|
|
40
|
+
const c20 = [0, 0, 0];
|
|
41
|
+
vtkMath.cross(n2, n0, c20);
|
|
42
|
+
const c01 = [0, 0, 0];
|
|
43
|
+
vtkMath.cross(n0, n1, c01);
|
|
44
|
+
|
|
45
|
+
// Determinant
|
|
46
|
+
const d = vtkMath.determinant3x3([...n0, ...n1, ...n2]);
|
|
47
|
+
|
|
48
|
+
// Intersection point
|
|
49
|
+
for (let i = 0; i < 3; ++i) {
|
|
50
|
+
pt[i] = (d0 * c12[i] + d1 * c20[i] + d2 * c01[i]) / d;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
publicAPI.requestData = (inData, outData) => {
|
|
54
|
+
const output = outData[0] || vtkPolyData.newInstance();
|
|
55
|
+
if (!model.planes || model.planes.getNumberOfPlanes() !== 6) {
|
|
56
|
+
vtkErrorMacro('vtkFrustum requires 6 planes.');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
let nbPts = 8;
|
|
60
|
+
let leftRightNull = false;
|
|
61
|
+
let bottomTopNull = false;
|
|
62
|
+
let parallelFrustum = false;
|
|
63
|
+
|
|
64
|
+
// angle between left and right planes
|
|
65
|
+
const n0 = model.planes.getPlane(0).getNormal().slice();
|
|
66
|
+
const n1 = model.planes.getPlane(1).getNormal().slice();
|
|
67
|
+
const c = [0, 0, 0];
|
|
68
|
+
vtkMath.normalize(n0);
|
|
69
|
+
vtkMath.normalize(n1);
|
|
70
|
+
vtkMath.dot(n0, n1);
|
|
71
|
+
vtkMath.cross(n0, n1, c);
|
|
72
|
+
vtkMath.norm(c);
|
|
73
|
+
|
|
74
|
+
// angle between bottom and top planes
|
|
75
|
+
n0.splice(0, 3, ...model.planes.getPlane(2).getNormal());
|
|
76
|
+
n1.splice(0, 3, ...model.planes.getPlane(3).getNormal());
|
|
77
|
+
vtkMath.normalize(n0);
|
|
78
|
+
vtkMath.normalize(n1);
|
|
79
|
+
vtkMath.dot(n0, n1);
|
|
80
|
+
vtkMath.cross(n0, n1, c);
|
|
81
|
+
vtkMath.norm(c);
|
|
82
|
+
if (model.showLines) {
|
|
83
|
+
const left = model.planes.getPlane(0).getNormal();
|
|
84
|
+
const right = model.planes.getPlane(1).getNormal();
|
|
85
|
+
const bottom = model.planes.getPlane(2).getNormal();
|
|
86
|
+
const top = model.planes.getPlane(3).getNormal();
|
|
87
|
+
const leftRight = [0, 0, 0];
|
|
88
|
+
vtkMath.cross(left, right, leftRight);
|
|
89
|
+
leftRightNull = leftRight[0] === 0.0 && leftRight[1] === 0.0 && leftRight[2] === 0.0;
|
|
90
|
+
const bottomTop = [0, 0, 0];
|
|
91
|
+
vtkMath.cross(bottom, top, bottomTop);
|
|
92
|
+
bottomTopNull = bottomTop[0] === 0.0 && bottomTop[1] === 0.0 && bottomTop[2] === 0.0;
|
|
93
|
+
parallelFrustum = leftRightNull && bottomTopNull;
|
|
94
|
+
if (parallelFrustum) {
|
|
95
|
+
// start at near points, just add the 4 extra far points.
|
|
96
|
+
nbPts += 4;
|
|
97
|
+
} else if (leftRightNull || bottomTopNull) {
|
|
98
|
+
// two extra starting points, and 4 extra far points.
|
|
99
|
+
nbPts += 6;
|
|
100
|
+
} else {
|
|
101
|
+
// there is an apex, and 4 extra far points
|
|
102
|
+
nbPts += 5;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
let pointType = 0;
|
|
106
|
+
if (model.outputPointsPrecision === DesiredOutputPrecision.SINGLE) {
|
|
107
|
+
pointType = VtkDataTypes.FLOAT;
|
|
108
|
+
} else if (model.outputPointsPrecision === DesiredOutputPrecision.DOUBLE) {
|
|
109
|
+
pointType = VtkDataTypes.DOUBLE;
|
|
110
|
+
}
|
|
111
|
+
const newPoints = vtkPoints.newInstance({
|
|
112
|
+
dataType: pointType
|
|
113
|
+
});
|
|
114
|
+
newPoints.setNumberOfPoints(nbPts);
|
|
115
|
+
const pt = [0.0, 0.0, 0.0];
|
|
116
|
+
const planes = [0, 0, 0];
|
|
117
|
+
planes[0] = 0; // left
|
|
118
|
+
planes[1] = 2; // bottom
|
|
119
|
+
planes[2] = 5; // near
|
|
120
|
+
computePoint(planes, pt);
|
|
121
|
+
newPoints.setPoint(0, ...pt);
|
|
122
|
+
planes[0] = 1;
|
|
123
|
+
computePoint(planes, pt);
|
|
124
|
+
newPoints.setPoint(1, ...pt);
|
|
125
|
+
planes[1] = 3;
|
|
126
|
+
computePoint(planes, pt);
|
|
127
|
+
newPoints.setPoint(2, ...pt);
|
|
128
|
+
planes[0] = 0;
|
|
129
|
+
computePoint(planes, pt);
|
|
130
|
+
newPoints.setPoint(3, ...pt);
|
|
131
|
+
planes[1] = 2;
|
|
132
|
+
planes[2] = 4; // far
|
|
133
|
+
computePoint(planes, pt);
|
|
134
|
+
newPoints.setPoint(4, ...pt);
|
|
135
|
+
planes[0] = 1;
|
|
136
|
+
computePoint(planes, pt);
|
|
137
|
+
newPoints.setPoint(5, ...pt);
|
|
138
|
+
planes[1] = 3;
|
|
139
|
+
computePoint(planes, pt);
|
|
140
|
+
newPoints.setPoint(6, ...pt);
|
|
141
|
+
planes[0] = 0;
|
|
142
|
+
computePoint(planes, pt);
|
|
143
|
+
newPoints.setPoint(7, ...pt);
|
|
144
|
+
const numPolys = 6;
|
|
145
|
+
const newPolys = vtkCellArray.newInstance();
|
|
146
|
+
newPolys.allocate(numPolys * 5);
|
|
147
|
+
|
|
148
|
+
// left
|
|
149
|
+
newPolys.insertNextCell([4, 0, 3, 7]);
|
|
150
|
+
|
|
151
|
+
// right
|
|
152
|
+
newPolys.insertNextCell([1, 5, 6, 2]);
|
|
153
|
+
|
|
154
|
+
// bottom
|
|
155
|
+
newPolys.insertNextCell([0, 4, 5, 1]);
|
|
156
|
+
|
|
157
|
+
// top
|
|
158
|
+
newPolys.insertNextCell([3, 2, 6, 7]);
|
|
159
|
+
|
|
160
|
+
// near
|
|
161
|
+
newPolys.insertNextCell([0, 1, 2, 3]);
|
|
162
|
+
|
|
163
|
+
// far
|
|
164
|
+
newPolys.insertNextCell([4, 7, 6, 5]);
|
|
165
|
+
let newLines = null;
|
|
166
|
+
if (model.showLines) {
|
|
167
|
+
const numLines = 4;
|
|
168
|
+
newLines = vtkCellArray.newInstance();
|
|
169
|
+
newLines.allocate(numLines * 3);
|
|
170
|
+
const pts = [12, 8]; // apex, or first of the two extra near points.
|
|
171
|
+
|
|
172
|
+
// line from lower-left corner
|
|
173
|
+
if (parallelFrustum) {
|
|
174
|
+
pts[0] = 0;
|
|
175
|
+
}
|
|
176
|
+
newLines.insertNextCell(pts);
|
|
177
|
+
|
|
178
|
+
// line from lower-right corner
|
|
179
|
+
if (parallelFrustum) {
|
|
180
|
+
pts[0]++;
|
|
181
|
+
} else if (leftRightNull) {
|
|
182
|
+
pts[0] = 13;
|
|
183
|
+
}
|
|
184
|
+
pts[1]++;
|
|
185
|
+
newLines.insertNextCell(pts);
|
|
186
|
+
|
|
187
|
+
// line from upper-right corner
|
|
188
|
+
if (parallelFrustum) {
|
|
189
|
+
pts[0]++;
|
|
190
|
+
} else if (bottomTopNull) {
|
|
191
|
+
pts[0] = 13;
|
|
192
|
+
}
|
|
193
|
+
pts[1]++;
|
|
194
|
+
newLines.insertNextCell(pts);
|
|
195
|
+
|
|
196
|
+
// line from upper-left corner
|
|
197
|
+
if (parallelFrustum) {
|
|
198
|
+
pts[0]++;
|
|
199
|
+
} else if (leftRightNull) {
|
|
200
|
+
pts[0] = 12;
|
|
201
|
+
}
|
|
202
|
+
pts[1]++;
|
|
203
|
+
newLines.insertNextCell(pts);
|
|
204
|
+
output.setLines(newLines);
|
|
205
|
+
}
|
|
206
|
+
output.setPoints(newPoints);
|
|
207
|
+
output.setPolys(newPolys);
|
|
208
|
+
outData[0] = output;
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ----------------------------------------------------------------------------
|
|
213
|
+
// Object factory
|
|
214
|
+
// ----------------------------------------------------------------------------
|
|
215
|
+
|
|
216
|
+
const DEFAULT_VALUES = {
|
|
217
|
+
planes: null,
|
|
218
|
+
showLines: true,
|
|
219
|
+
outputPointsPrecision: DesiredOutputPrecision.DEFAULT
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// ----------------------------------------------------------------------------
|
|
223
|
+
|
|
224
|
+
function extend(publicAPI, model) {
|
|
225
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
226
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
227
|
+
|
|
228
|
+
// Build VTK API
|
|
229
|
+
macro.obj(publicAPI, model);
|
|
230
|
+
|
|
231
|
+
// Also make it an algorithm with no input and one output
|
|
232
|
+
macro.algo(publicAPI, model, 0, 1);
|
|
233
|
+
macro.setGet(publicAPI, model, ['showLines', 'outputPointsPrecision', 'planes']);
|
|
234
|
+
vtkFrustumSource(publicAPI, model);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// ----------------------------------------------------------------------------
|
|
238
|
+
|
|
239
|
+
const newInstance = macro.newInstance(extend, 'vtkFrustumSource');
|
|
240
|
+
|
|
241
|
+
// ----------------------------------------------------------------------------
|
|
242
|
+
|
|
243
|
+
var index = {
|
|
244
|
+
newInstance,
|
|
245
|
+
extend
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export { index as default, extend, newInstance };
|
|
@@ -301,10 +301,17 @@ export interface vtkCamera extends vtkObject {
|
|
|
301
301
|
getViewAngle(): number;
|
|
302
302
|
|
|
303
303
|
/**
|
|
304
|
-
*
|
|
304
|
+
* Get the view transform
|
|
305
305
|
*/
|
|
306
306
|
getViewMatrix(): mat4;
|
|
307
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Get the model transform matrix for the camera.
|
|
310
|
+
* This matrix could be used for model related transformations such as scale, shear, rotations and translations.
|
|
311
|
+
* @returns {mat4} mat The value of the model transform matrix.
|
|
312
|
+
*/
|
|
313
|
+
getModelTransformMatrix(): mat4;
|
|
314
|
+
|
|
308
315
|
/**
|
|
309
316
|
* Get the ViewPlaneNormal.
|
|
310
317
|
* This vector will point opposite to the direction of projection,
|
|
@@ -674,7 +681,14 @@ export interface vtkCamera extends vtkObject {
|
|
|
674
681
|
* Set the view matrix for the camera.
|
|
675
682
|
* @param {mat4} mat The value of the view matrix.
|
|
676
683
|
*/
|
|
677
|
-
setViewMatrix(mat: mat4):
|
|
684
|
+
setViewMatrix(mat: mat4): void;
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Set the model transform matrix for the camera.
|
|
688
|
+
* This matrix could be used for model related transformations such as scale, shear, rotations and translations.
|
|
689
|
+
* @param {mat4} mat The value of the model transform matrix.
|
|
690
|
+
*/
|
|
691
|
+
setModelTransformMatrixMatrix(mat: mat4): void;
|
|
678
692
|
|
|
679
693
|
/**
|
|
680
694
|
* Set the view up direction for the camera.
|
package/Rendering/Core/Camera.js
CHANGED
|
@@ -402,6 +402,10 @@ function vtkCamera(publicAPI, model) {
|
|
|
402
402
|
mat4.multiply(tmpMatrix, mat, tmpMatrix);
|
|
403
403
|
publicAPI.computeViewParametersFromViewMatrix(tmpMatrix);
|
|
404
404
|
};
|
|
405
|
+
publicAPI.setModelTransformMatrix = mat => {
|
|
406
|
+
model.modelTransformMatrix = mat;
|
|
407
|
+
};
|
|
408
|
+
publicAPI.getModelTransformMatrix = () => model.modelTransformMatrix;
|
|
405
409
|
publicAPI.setViewMatrix = mat => {
|
|
406
410
|
model.viewMatrix = mat;
|
|
407
411
|
if (model.viewMatrix) {
|
|
@@ -412,6 +416,10 @@ function vtkCamera(publicAPI, model) {
|
|
|
412
416
|
};
|
|
413
417
|
publicAPI.getViewMatrix = () => {
|
|
414
418
|
if (model.viewMatrix) {
|
|
419
|
+
if (model.modelTransformMatrix) {
|
|
420
|
+
mat4.multiply(tmpMatrix, model.viewMatrix, model.modelTransformMatrix);
|
|
421
|
+
return tmpMatrix;
|
|
422
|
+
}
|
|
415
423
|
return model.viewMatrix;
|
|
416
424
|
}
|
|
417
425
|
mat4.lookAt(tmpMatrix, model.position,
|
|
@@ -423,7 +431,11 @@ function vtkCamera(publicAPI, model) {
|
|
|
423
431
|
|
|
424
432
|
mat4.transpose(tmpMatrix, tmpMatrix);
|
|
425
433
|
const result = new Float64Array(16);
|
|
426
|
-
|
|
434
|
+
if (model.modelTransformMatrix) {
|
|
435
|
+
mat4.multiply(result, tmpMatrix, model.modelTransformMatrix);
|
|
436
|
+
} else {
|
|
437
|
+
mat4.copy(result, tmpMatrix);
|
|
438
|
+
}
|
|
427
439
|
return result;
|
|
428
440
|
};
|
|
429
441
|
publicAPI.setProjectionMatrix = mat => {
|
|
@@ -613,6 +625,7 @@ const DEFAULT_VALUES = {
|
|
|
613
625
|
freezeFocalPoint: false,
|
|
614
626
|
projectionMatrix: null,
|
|
615
627
|
viewMatrix: null,
|
|
628
|
+
modelTransformMatrix: null,
|
|
616
629
|
cameraLightTransform: mat4.create(),
|
|
617
630
|
// used for world to physical transformations
|
|
618
631
|
physicalTranslation: [0, 0, 0],
|
|
@@ -162,6 +162,22 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) {
|
|
|
162
162
|
}
|
|
163
163
|
superClass.replaceShaderNormal(shaders, ren, actor);
|
|
164
164
|
};
|
|
165
|
+
publicAPI.replaceShaderClip = (shaders, ren, actor) => {
|
|
166
|
+
if (model.hardwareSupport) {
|
|
167
|
+
let VSSource = shaders.Vertex;
|
|
168
|
+
let FSSource = shaders.Fragment;
|
|
169
|
+
if (model.renderable.getNumberOfClippingPlanes()) {
|
|
170
|
+
const numClipPlanes = model.renderable.getNumberOfClippingPlanes();
|
|
171
|
+
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;', `uniform vec4 clipPlanes[${numClipPlanes}];`, `varying float clipDistancesVSOutput[${numClipPlanes}];`]).result;
|
|
172
|
+
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Impl', [`for (int planeNum = 0; planeNum < ${numClipPlanes}; planeNum++)`, ' {', ' if (planeNum >= numClipPlanes)', ' {', ' break;', ' }', ' vec4 gVertex = gMatrix * vertexMC;', ' clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], gVertex);', ' }']).result;
|
|
173
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;', `varying float clipDistancesVSOutput[${numClipPlanes}];`]).result;
|
|
174
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Impl', [`for (int planeNum = 0; planeNum < ${numClipPlanes}; planeNum++)`, ' {', ' if (planeNum >= numClipPlanes)', ' {', ' break;', ' }', ' if (clipDistancesVSOutput[planeNum] < 0.0) discard;', ' }']).result;
|
|
175
|
+
}
|
|
176
|
+
shaders.Vertex = VSSource;
|
|
177
|
+
shaders.Fragment = FSSource;
|
|
178
|
+
}
|
|
179
|
+
superClass.replaceShaderClip(shaders, ren, actor);
|
|
180
|
+
};
|
|
165
181
|
publicAPI.replaceShaderColor = (shaders, ren, actor) => {
|
|
166
182
|
if (model.hardwareSupport && model.renderable.getColorArray()) {
|
|
167
183
|
let VSSource = shaders.Vertex;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var vtkVolumeVS = "//VTK::System::Dec\n\n/*=========================================================================\n\n Program: Visualization Toolkit\n Module:
|
|
1
|
+
var vtkVolumeVS = "//VTK::System::Dec\n\n/*=========================================================================\n\n Program: Visualization Toolkit\n Module: vtkVolumeVS.glsl\n\n Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n All rights reserved.\n See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n PURPOSE. See the above copyright notice for more information.\n\n=========================================================================*/\n\nattribute vec4 vertexDC;\n\nvarying vec3 vertexVCVSOutput;\nuniform mat4 PCVCMatrix;\n\nuniform float dcxmin;\nuniform float dcxmax;\nuniform float dcymin;\nuniform float dcymax;\n\nvoid main()\n{\n // dcsmall is the device coords reduced to the\n // x y area covered by the volume\n vec4 dcsmall = vec4(\n dcxmin + 0.5 * (vertexDC.x + 1.0) * (dcxmax - dcxmin),\n dcymin + 0.5 * (vertexDC.y + 1.0) * (dcymax - dcymin),\n vertexDC.z,\n vertexDC.w);\n vec4 vcpos = PCVCMatrix * dcsmall;\n vertexVCVSOutput = vcpos.xyz/vcpos.w;\n gl_Position = dcsmall;\n}\n";
|
|
2
2
|
|
|
3
3
|
export { vtkVolumeVS as v };
|
package/index.d.ts
CHANGED
|
@@ -37,8 +37,11 @@
|
|
|
37
37
|
/// <reference path="./Common/DataModel/KochanekSpline1D.d.ts" />
|
|
38
38
|
/// <reference path="./Common/DataModel/Line.d.ts" />
|
|
39
39
|
/// <reference path="./Common/DataModel/Locator.d.ts" />
|
|
40
|
+
/// <reference path="./Common/DataModel/MergePoints.d.ts" />
|
|
40
41
|
/// <reference path="./Common/DataModel/PiecewiseFunction.d.ts" />
|
|
41
42
|
/// <reference path="./Common/DataModel/Plane.d.ts" />
|
|
43
|
+
/// <reference path="./Common/DataModel/Planes.d.ts" />
|
|
44
|
+
/// <reference path="./Common/DataModel/PointLocator.d.ts" />
|
|
42
45
|
/// <reference path="./Common/DataModel/PointSet.d.ts" />
|
|
43
46
|
/// <reference path="./Common/DataModel/PolyData/Constants.d.ts" />
|
|
44
47
|
/// <reference path="./Common/DataModel/PolyData.d.ts" />
|
|
@@ -81,6 +84,7 @@
|
|
|
81
84
|
/// <reference path="./Filters/Sources/CylinderSource.d.ts" />
|
|
82
85
|
/// <reference path="./Filters/Sources/DiskSource.d.ts" />
|
|
83
86
|
/// <reference path="./Filters/Sources/EllipseArcSource.d.ts" />
|
|
87
|
+
/// <reference path="./Filters/Sources/FrustumSource.d.ts" />
|
|
84
88
|
/// <reference path="./Filters/Sources/LineSource.d.ts" />
|
|
85
89
|
/// <reference path="./Filters/Sources/PlaneSource.d.ts" />
|
|
86
90
|
/// <reference path="./Filters/Sources/PlatonicSolidSource/Constants.d.ts" />
|