@kitware/vtk.js 25.2.0 → 25.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- import { Bounds } from './../../types';
1
+ import { Bounds, Nullable } from './../../types';
2
2
  import vtkMapper from './Mapper';
3
3
  import vtkProp3D, { IProp3DInitialValues } from './Prop3D';
4
- import vtkProperty from './Property';
4
+ import vtkProperty, { IPropertyInitialValues } from './Property';
5
5
 
6
6
  /**
7
7
  *
@@ -62,7 +62,7 @@ export interface vtkActor extends vtkProp3D {
62
62
  /**
63
63
  * Get the Mapper that this actor is getting its data from.
64
64
  */
65
- getMapper(): null | vtkMapper;
65
+ getMapper(): Nullable<vtkMapper>;
66
66
 
67
67
  /**
68
68
  * Get the property object that controls this actors surface
@@ -82,8 +82,9 @@ export interface vtkActor extends vtkProp3D {
82
82
 
83
83
  /**
84
84
  * Create a new property suitable for use with this type of Actor.
85
+ * @param {IPropertyInitialValues} [initialValues] (default: {})
85
86
  */
86
- makeProperty(): vtkProperty;
87
+ makeProperty(initialValues?: IPropertyInitialValues): vtkProperty;
87
88
 
88
89
  /**
89
90
  * Set the property object that controls this actors backface surface
@@ -1,5 +1,5 @@
1
1
  import { Bounds } from './../../types';
2
- import vtkImageProperty from './ImageProperty';
2
+ import vtkImageProperty, { IImagePropertyInitialValues } from './ImageProperty';
3
3
  import vtkImageMapper from './ImageMapper';
4
4
  import vtkProp3D, { IProp3DInitialValues } from './Prop3D';
5
5
 
@@ -23,6 +23,12 @@ export interface vtkImageSlice extends vtkProp3D {
23
23
  */
24
24
  getBounds(): Bounds;
25
25
 
26
+ /**
27
+ * Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].
28
+ * @return {Bounds} The bounds for the mapper.
29
+ */
30
+ getBoundsByReference(): Bounds;
31
+
26
32
  /**
27
33
  * Get the bounds for a given slice as [xmin, xmax, ymin, ymax,zmin, zmax].
28
34
  * @param {Number} slice The slice index.
@@ -111,6 +117,24 @@ export interface vtkImageSlice extends vtkProp3D {
111
117
  * and the Renderer will do the images in their own pass.
112
118
  */
113
119
  hasTranslucentPolygonalGeometry(): boolean;
120
+
121
+ /**
122
+ * Create a new property suitable for use with this type of Actor.
123
+ * @param {IImageSliceInitialValues} [initialValues] (default: {})
124
+ */
125
+ makeProperty(initialValues?: IImagePropertyInitialValues): vtkImageProperty;
126
+
127
+ /**
128
+ *
129
+ * @param {vtkImageMapper} mapper The vtkImageMapper instance.
130
+ */
131
+ setMapper(mapper: vtkImageMapper): boolean;
132
+
133
+ /**
134
+ *
135
+ * @param {vtkImageProperty} property The vtkImageProperty instance.
136
+ */
137
+ setProperty(property: vtkImageProperty): boolean;
114
138
  }
115
139
 
116
140
  /**
@@ -1,7 +1,7 @@
1
- import { Bounds } from './../../types';
1
+ import { Bounds, Nullable } from './../../types';
2
2
  import vtkProp3D, { IProp3DInitialValues } from './Prop3D';
3
3
  import vtkVolumeMapper from './VolumeMapper';
4
- import vtkVolumeProperty from './VolumeProperty';
4
+ import vtkVolumeProperty, { IVolumePropertyInitialValues } from './VolumeProperty';
5
5
 
6
6
  /**
7
7
  *
@@ -20,7 +20,7 @@ export interface vtkVolume extends vtkProp3D {
20
20
  /**
21
21
  * Get the volume mapper
22
22
  */
23
- getMapper(): vtkVolumeMapper;
23
+ getMapper(): Nullable<vtkVolumeMapper>;
24
24
 
25
25
  /**
26
26
  * For some exporters and other other operations we must be able to collect
@@ -63,9 +63,10 @@ export interface vtkVolume extends vtkProp3D {
63
63
  getRedrawMTime(): number;
64
64
 
65
65
  /**
66
- *
66
+ * Create a new property suitable for use with this type of Actor.
67
+ * @param {IVolumePropertyInitialValues} [initialValues] (default: {})
67
68
  */
68
- makeProperty(): void;
69
+ makeProperty(initialValues?: IVolumePropertyInitialValues): vtkVolumeProperty;
69
70
 
70
71
  /**
71
72
  * Set the volume mapper
@@ -5,7 +5,7 @@ import { BlendMode, FilterMode } from './VolumeMapper/Constants';
5
5
  /**
6
6
  *
7
7
  */
8
- interface IVolumeMapperInitialValues extends IAbstractMapperInitialValues {
8
+ export interface IVolumeMapperInitialValues extends IAbstractMapperInitialValues {
9
9
  bounds?: Bounds;
10
10
  blendMode?: BlendMode;
11
11
  sampleDistance?: number;
@@ -1,7 +1,9 @@
1
+ import vtkPiecewiseFunction from './../../Common/DataModel/PiecewiseFunction';
1
2
  import { vtkObject } from './../../interfaces';
3
+ import vtkColorTransferFunction from './ColorTransferFunction';
2
4
  import { InterpolationType, OpacityMode } from './VolumeProperty/Constants';
3
5
 
4
- interface IVolumePropertyInitialValues {
6
+ export interface IVolumePropertyInitialValues {
5
7
  independentComponents?: boolean;
6
8
  shade?: number;
7
9
  ambient?: number;
@@ -33,7 +35,7 @@ export interface vtkVolumeProperty extends vtkObject {
33
35
 
34
36
  /**
35
37
  *
36
- * @param {Number} index
38
+ * @param {Number} index
37
39
  */
38
40
  getColorChannels(index: number): number;
39
41
 
@@ -44,25 +46,25 @@ export interface vtkVolumeProperty extends vtkObject {
44
46
 
45
47
  /**
46
48
  *
47
- * @param {Number} index
49
+ * @param {Number} index
48
50
  */
49
51
  getGradientOpacityMaximumOpacity(index: number): number;
50
52
 
51
53
  /**
52
54
  *
53
- * @param {Number} index
55
+ * @param {Number} index
54
56
  */
55
57
  getGradientOpacityMaximumValue(index: number): number;
56
58
 
57
59
  /**
58
60
  *
59
- * @param {Number} index
61
+ * @param {Number} index
60
62
  */
61
63
  getGradientOpacityMinimumOpacity(index: number): number;
62
64
 
63
65
  /**
64
66
  *
65
- * @param {Number} index
67
+ * @param {Number} index
66
68
  */
67
69
  getGradientOpacityMinimumValue(index: number): number;
68
70
 
@@ -73,15 +75,15 @@ export interface vtkVolumeProperty extends vtkObject {
73
75
 
74
76
  /**
75
77
  * Get the unit distance on which the scalar opacity transfer function is defined.
76
- * @param {Number} index
78
+ * @param {Number} index
77
79
  */
78
80
  getScalarOpacityUnitDistance(index: number): number;
79
81
 
80
82
  /**
81
83
  * Get the currently set gray transfer function. Create one if none set.
82
- * @param {Number} index
84
+ * @param {Number} index
83
85
  */
84
- getGrayTransferFunction(index: number): any;
86
+ getGrayTransferFunction(index: number): vtkPiecewiseFunction;
85
87
 
86
88
  /**
87
89
  *
@@ -98,13 +100,13 @@ export interface vtkVolumeProperty extends vtkObject {
98
100
  * Get the currently set RGB transfer function. Create one if none set.
99
101
  * @param {Number} index
100
102
  */
101
- getRGBTransferFunction(index: number): any;
103
+ getRGBTransferFunction(index: number): vtkColorTransferFunction;
102
104
 
103
105
  /**
104
106
  * Get the scalar opacity transfer function. Create one if none set.
105
107
  * @param {Number} index
106
108
  */
107
- getScalarOpacity(index: number): any;
109
+ getScalarOpacity(index: number): vtkPiecewiseFunction;
108
110
 
109
111
  /**
110
112
  * Get the shading of a volume.
@@ -147,37 +149,37 @@ export interface vtkVolumeProperty extends vtkObject {
147
149
  /**
148
150
  *
149
151
  * @param {Number} index
150
- * @param {Number} value
152
+ * @param {Number} value
151
153
  */
152
154
  setGradientOpacityMaximumOpacity(index: number, value: number): boolean;
153
155
 
154
156
  /**
155
157
  *
156
158
  * @param {Number} index
157
- * @param {Number} value
159
+ * @param {Number} value
158
160
  */
159
161
  setGradientOpacityMaximumValue(index: number, value: number): boolean;
160
162
 
161
163
  /**
162
164
  *
163
165
  * @param {Number} index
164
- * @param {Number} value
166
+ * @param {Number} value
165
167
  */
166
168
  setGradientOpacityMinimumOpacity(index: number, value: number): boolean;
167
169
 
168
170
  /**
169
171
  *
170
172
  * @param {Number} index
171
- * @param {Number} value
173
+ * @param {Number} value
172
174
  */
173
175
  setGradientOpacityMinimumValue(index: number, value: number): boolean;
174
176
 
175
177
  /**
176
178
  * Set the color of a volume to a gray transfer function
177
179
  * @param {Number} index
178
- * @param func
180
+ * @param {vtkPiecewiseFunction} func
179
181
  */
180
- setGrayTransferFunction(index: number, func: any): boolean;
182
+ setGrayTransferFunction(index: number, func: vtkPiecewiseFunction): boolean;
181
183
 
182
184
  /**
183
185
  * Does the data have independent components, or do some define color only?
@@ -204,14 +206,14 @@ export interface vtkVolumeProperty extends vtkObject {
204
206
 
205
207
  /**
206
208
  *
207
- * @param {Number} labelOutlineThickness
209
+ * @param {Number} labelOutlineThickness
208
210
  */
209
211
  setLabelOutlineThickness(labelOutlineThickness: number): boolean;
210
212
 
211
213
  /**
212
214
  *
213
215
  * @param {Number} index
214
- * @param {Number} value
216
+ * @param {Number} value
215
217
  */
216
218
  setOpacityMode(index: number, value: number): boolean;
217
219
 
@@ -219,7 +221,7 @@ export interface vtkVolumeProperty extends vtkObject {
219
221
  * Set the unit distance on which the scalar opacity transfer function is
220
222
  * defined.
221
223
  * @param {Number} index
222
- * @param {Number} value
224
+ * @param {Number} value
223
225
  */
224
226
  setScalarOpacityUnitDistance(index: number, value: number): boolean;
225
227
 
@@ -234,7 +236,7 @@ export interface vtkVolumeProperty extends vtkObject {
234
236
  * turning shading off is generally the same as setting ambient=1,
235
237
  * diffuse=0, specular=0. Shading can be independently turned on/off per
236
238
  * component.
237
- * @param {Number} shade
239
+ * @param {Number} shade
238
240
  */
239
241
  setShade(shade: number): boolean;
240
242
 
@@ -252,35 +254,35 @@ export interface vtkVolumeProperty extends vtkObject {
252
254
 
253
255
  /**
254
256
  *
255
- * @param {Boolean} index
256
- * @param {Number} value
257
+ * @param {Number} index
258
+ * @param {Boolean} value
257
259
  */
258
260
  setUseGradientOpacity(index: number, value: boolean): boolean;
259
261
 
260
262
  /**
261
263
  *
262
- * @param {Boolean} useLabelOutline
264
+ * @param {Boolean} useLabelOutline
263
265
  */
264
266
  setUseLabelOutline(useLabelOutline: boolean): boolean;
265
267
 
266
268
  /**
267
269
  * Set the color of a volume to an RGB transfer function
268
270
  * @param {Number} index
269
- * @param func
271
+ * @param {vtkColorTransferFunction} func
270
272
  */
271
- setRGBTransferFunction(index: number, func: any): boolean;
273
+ setRGBTransferFunction(index: number, func: vtkColorTransferFunction): boolean;
272
274
 
273
275
  /**
274
276
  * Set the scalar opacity of a volume to a transfer function
275
277
  * @param {Number} index
276
- * @param func
278
+ * @param {vtkPiecewiseFunction} func
277
279
  */
278
- setScalarOpacity(index: number, func: any): boolean;
280
+ setScalarOpacity(index: number, func: vtkPiecewiseFunction): boolean;
279
281
 
280
282
  /**
281
283
  * Set the scalar component weights.
282
284
  * @param {Number} index
283
- * @param {Number} value
285
+ * @param {Number} value
284
286
  */
285
287
  setComponentWeight(index: number, value: number): boolean;
286
288
 
@@ -292,7 +294,7 @@ export interface vtkVolumeProperty extends vtkObject {
292
294
 
293
295
  /**
294
296
  * Set the interpolation type for sampling a volume.
295
- * @param {InterpolationType} interpolationType
297
+ * @param {InterpolationType} interpolationType
296
298
  */
297
299
  setInterpolationType(interpolationType: InterpolationType): boolean;
298
300
 
@@ -106,7 +106,10 @@ function vtkWebGPUImageMapper(publicAPI, model) {
106
106
  var modelToIndex = image.getWorldToIndex();
107
107
  mat4.multiply(tmpMat4, modelToIndex, tmpMat4); // tmpMat4 is now SC -> Index, save this as we need it later
108
108
 
109
- mat4.invert(tmp3Mat4, tmpMat4);
109
+ mat4.invert(tmp3Mat4, tmpMat4); // need translation and scale
110
+
111
+ mat4.fromTranslation(tmp2Mat4, [0.5, 0.5, 0.5]);
112
+ mat4.multiply(tmpMat4, tmp2Mat4, tmpMat4);
110
113
  var dims = image.getDimensions();
111
114
  mat4.identity(tmp2Mat4);
112
115
  mat4.scale(tmp2Mat4, tmp2Mat4, [1.0 / dims[0], 1.0 / dims[1], 1.0 / dims[2]]);
@@ -143,22 +146,22 @@ function vtkWebGPUImageMapper(publicAPI, model) {
143
146
  }
144
147
 
145
148
  ptsArray1[axis0] = nSlice;
146
- ptsArray1[axis1] = ext[axis1 * 2];
147
- ptsArray1[axis2] = ext[axis2 * 2];
149
+ ptsArray1[axis1] = ext[axis1 * 2] - 0.5;
150
+ ptsArray1[axis2] = ext[axis2 * 2] - 0.5;
148
151
  ptsArray1[3] = 1.0;
149
152
  vec4.transformMat4(ptsArray1, ptsArray1, tmp3Mat4);
150
153
  model.UBO.setArray('Origin', ptsArray1);
151
154
  ptsArray2[axis0] = nSlice;
152
- ptsArray2[axis1] = ext[axis1 * 2 + 1];
153
- ptsArray2[axis2] = ext[axis2 * 2];
155
+ ptsArray2[axis1] = ext[axis1 * 2 + 1] + 0.5;
156
+ ptsArray2[axis2] = ext[axis2 * 2] - 0.5;
154
157
  ptsArray2[3] = 1.0;
155
158
  vec4.transformMat4(ptsArray2, ptsArray2, tmp3Mat4);
156
159
  vec4.subtract(ptsArray2, ptsArray2, ptsArray1);
157
160
  ptsArray2[3] = 1.0;
158
161
  model.UBO.setArray('Axis1', ptsArray2);
159
162
  ptsArray2[axis0] = nSlice;
160
- ptsArray2[axis1] = ext[axis1 * 2];
161
- ptsArray2[axis2] = ext[axis2 * 2 + 1];
163
+ ptsArray2[axis1] = ext[axis1 * 2] - 0.5;
164
+ ptsArray2[axis2] = ext[axis2 * 2 + 1] + 0.5;
162
165
  ptsArray2[3] = 1.0;
163
166
  vec4.transformMat4(ptsArray2, ptsArray2, tmp3Mat4);
164
167
  vec4.subtract(ptsArray2, ptsArray2, ptsArray1);
@@ -179,7 +182,7 @@ function vtkWebGPUImageMapper(publicAPI, model) {
179
182
  var target = iComps ? i : 0;
180
183
  var cfun = actor.getProperty().getRGBTransferFunction(target);
181
184
 
182
- if (cfun && actor.getProperty().getUseLookupTableScalarRange()) {
185
+ if (cfun) {
183
186
  var cRange = cfun.getRange();
184
187
  cw = cRange[1] - cRange[0];
185
188
  cl = 0.5 * (cRange[1] + cRange[0]);
@@ -83,17 +83,6 @@ function vtkWebGPUPipeline(publicAPI, model) {
83
83
  publicAPI.bindVertexInput = function (renderEncoder, vInput) {
84
84
  vInput.bindBuffers(renderEncoder);
85
85
  };
86
-
87
- publicAPI.addDrawCallback = function (cb) {
88
- model._drawCallbacks.push(cb);
89
- }; // handle anything that needs to be done when drawing
90
-
91
-
92
- publicAPI.draw = function (encoder) {
93
- for (var cb = 0; cb < model._drawCallbacks.length; cb++) {
94
- model._drawCallbacks[cb](encoder, publicAPI);
95
- }
96
- };
97
86
  } // ----------------------------------------------------------------------------
98
87
  // Object factory
99
88
  // ----------------------------------------------------------------------------
@@ -116,7 +105,6 @@ function extend(publicAPI, model) {
116
105
  obj(publicAPI, model);
117
106
  model.layouts = [];
118
107
  model.shaderDescriptions = [];
119
- model._drawCallbacks = [];
120
108
  get(publicAPI, model, ['handle', 'pipelineDescription']);
121
109
  setGet(publicAPI, model, ['device', 'renderEncoder', 'topology', 'vertexState']); // For more macro methods, see "Sources/macros.js"
122
110
  // Object specific methods
@@ -74,7 +74,6 @@ function vtkWebGPURenderEncoder(publicAPI, model) {
74
74
  }
75
75
 
76
76
  model.boundPipeline = pl;
77
- pl.draw(publicAPI);
78
77
  };
79
78
 
80
79
  publicAPI.replaceShaderCode = function (pipeline) {
@@ -176,7 +176,12 @@ function vtkWebGPUSimpleMapper(publicAPI, model) {
176
176
  publicAPI.draw = function (renderEncoder) {
177
177
  var pipeline = renderEncoder.getBoundPipeline(); // bind the mapper bind group
178
178
 
179
- renderEncoder.activateBindGroup(model.bindGroup); // bind the vertex input
179
+ renderEncoder.activateBindGroup(model.bindGroup);
180
+
181
+ if (model.WebGPURenderer) {
182
+ model.WebGPURenderer.bindUBO(renderEncoder);
183
+ } // bind the vertex input
184
+
180
185
 
181
186
  pipeline.bindVertexInput(renderEncoder, model.vertexInput);
182
187
  var indexBuffer = model.vertexInput.getIndexBuffer();
@@ -222,7 +227,6 @@ function vtkWebGPUSimpleMapper(publicAPI, model) {
222
227
 
223
228
  if (model.WebGPURenderer) {
224
229
  model.pipeline.addBindGroupLayout(model.WebGPURenderer.getBindGroup());
225
- model.pipeline.addDrawCallback(model.WebGPURenderer.bindUBO);
226
230
  }
227
231
 
228
232
  model.pipeline.addBindGroupLayout(model.bindGroup);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "25.2.0",
3
+ "version": "25.2.1",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",