@kitware/vtk.js 25.1.3 → 25.2.2

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
  /**
@@ -5,7 +5,7 @@ import { RGBColor, Vector3 } from './../../types';
5
5
  export enum LIGHT_TYPES {
6
6
  'HeadLight',
7
7
  'CameraLight',
8
- 'SceneLight'
8
+ 'SceneLight',
9
9
  }
10
10
 
11
11
  export interface ILightInitialValues {
@@ -17,6 +17,7 @@ export interface ILightInitialValues {
17
17
  positional?: boolean;
18
18
  exponent?: number;
19
19
  coneAngle?: number;
20
+ coneFalloff?: number;
20
21
  attenuationValues?: number[];
21
22
  lightType?: LIGHT_TYPES;
22
23
  shadowAttenuation?: number;
@@ -54,6 +55,15 @@ export interface vtkLight extends vtkObject {
54
55
  */
55
56
  getConeAngle(): number;
56
57
 
58
+ /**
59
+ * Get the lighting falloff angle of a positional light in degrees.
60
+ * This is the angle that sets how much the cone will be extended to
61
+ * smooth the border. A value of 0 indicates that the spot light will
62
+ * have a completely sharp edge (this does not mean completely sharp
63
+ * lighting, just that the border will be sharp).
64
+ */
65
+ getConeFalloff(): number;
66
+
57
67
  /**
58
68
  * Set the position and focal point of a light based on elevation and azimuth.
59
69
  * The light is moved so it is shining from the given angle. Angles are
@@ -174,6 +184,16 @@ export interface vtkLight extends vtkObject {
174
184
  */
175
185
  setConeAngle(coneAngle: number): boolean;
176
186
 
187
+ /**
188
+ * Set the lighting falloff angle of a positional light in degrees.
189
+ * This is the angle that sets how much the cone will be extended to
190
+ * smooth the border. A value of 0 indicates that the spot light will
191
+ * have a completely sharp edge (this does not mean completely sharp
192
+ * lighting, just that the border will be sharp).
193
+ * @param {Number} coneFalloff The cone falloff angle.
194
+ */
195
+ setConeFalloff(coneFalloff: number): boolean;
196
+
177
197
  /**
178
198
  * Set the position and focal point of a light based on elevation and
179
199
  * azimuth. The light is moved so it is shining from the given angle. Angles
@@ -184,6 +204,20 @@ export interface vtkLight extends vtkObject {
184
204
  */
185
205
  setDirectionAngle(elevation: number, azimuth: number): boolean;
186
206
 
207
+ /**
208
+ * Set the direction vector of the light from X, Y, and Z values
209
+ * @param {Number} x The x coordinate.
210
+ * @param {Number} y The y coordinate.
211
+ * @param {Number} z The z coordinate.
212
+ */
213
+ setDirection(x: number, y: number, z: number): boolean;
214
+
215
+ /**
216
+ * Set the direction vector of the light from X, Y, and Z values
217
+ * @param {Vector3} direction
218
+ */
219
+ setDirection(direction: Vector3): boolean;
220
+
187
221
  /**
188
222
  * Set the exponent of the cosine used in positional lighting.
189
223
  * @param {Number} exponent The exponent of the cosine.
@@ -299,7 +333,7 @@ export function extend(publicAPI: object, model: object, initialValues?: ILightI
299
333
  /**
300
334
  * Method use to create a new instance of vtkLight with the focal point at the origin and its position
301
335
  * set to [0, 0, 1]. The light is a SceneLight, its color is white, intensity=1, the light is turned on,
302
- * positional lighting is off, coneAngle=30, AttenuationValues=[1, 0, 0], exponent=1 and the transformMatrix is null.
336
+ * positional lighting is off, coneAngle=30, coneFalloff=5, AttenuationValues=[1, 0, 0], exponent=1 and the transformMatrix is null.
303
337
  * @param {ILightInitialValues} [initialValues] for pre-setting some of its content
304
338
  */
305
339
  export function newInstance(initialValues?: ILightInitialValues): vtkLight;
@@ -33,14 +33,19 @@ function vtkLight(publicAPI, model) {
33
33
 
34
34
  publicAPI.getDirection = function () {
35
35
  if (model.directionMTime < model.mtime) {
36
- model.direction[0] = model.focalPoint[0] - model.position[0];
37
- model.direction[1] = model.focalPoint[1] - model.position[1];
38
- model.direction[2] = model.focalPoint[2] - model.position[2];
36
+ vec3.sub(model.direction, model.focalPoint, model.position);
39
37
  normalize(model.direction);
40
38
  model.directionMTime = model.mtime;
41
39
  }
42
40
 
43
41
  return model.direction;
42
+ }; // Sets the direction from a vec3 instead of a focal point
43
+
44
+
45
+ publicAPI.setDirection = function (directionVector) {
46
+ var newFocalPoint = new Float64Array(3);
47
+ vec3.sub(newFocalPoint, model.position, directionVector);
48
+ model.focalPoint = newFocalPoint;
44
49
  };
45
50
 
46
51
  publicAPI.setDirectionAngle = function (elevation, azimuth) {
@@ -89,6 +94,7 @@ var DEFAULT_VALUES = {
89
94
  positional: false,
90
95
  exponent: 1,
91
96
  coneAngle: 30,
97
+ coneFalloff: 5,
92
98
  attenuationValues: [1, 0, 0],
93
99
  transformMatrix: null,
94
100
  lightType: 'SceneLight',
@@ -102,7 +108,7 @@ function extend(publicAPI, model) {
102
108
  Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API
103
109
 
104
110
  macro.obj(publicAPI, model);
105
- macro.setGet(publicAPI, model, ['intensity', 'switch', 'positional', 'exponent', 'coneAngle', 'transformMatrix', 'lightType', 'shadowAttenuation', 'attenuationValues']);
111
+ macro.setGet(publicAPI, model, ['intensity', 'switch', 'positional', 'exponent', 'coneAngle', 'coneFalloff', 'transformMatrix', 'lightType', 'shadowAttenuation', 'attenuationValues']);
106
112
  macro.setGetArray(publicAPI, model, ['color', 'position', 'focalPoint', 'attenuationValues'], 3); // Object methods
107
113
 
108
114
  vtkLight(publicAPI, model);
@@ -1,15 +1,27 @@
1
1
  import { vtkObject } from './../../interfaces';
2
2
  import { RGBColor } from './../../types';
3
3
  import { Interpolation, Representation, Shading } from './Property/Constants';
4
+ import { vtkTexture } from './Texture';
4
5
 
5
6
  export interface IPropertyInitialValues {
6
7
  color?: RGBColor;
7
8
  ambientColor?: RGBColor;
8
9
  diffuseColor?: RGBColor;
9
10
  specularColor?: RGBColor;
11
+ diffuseTexture?: vtkTexture;
12
+ metallicTexture?: vtkTexture;
13
+ roughnessTexture?: vtkTexture;
14
+ normalTexture?: vtkTexture;
15
+ ambientOcclusionTexture?: vtkTexture;
16
+ emissionTexture?: vtkTexture;
10
17
  edgeColor?: RGBColor;
11
18
  ambient?: number;
12
19
  diffuse?: number;
20
+ metallic?: number;
21
+ roughness?: number;
22
+ normalStrength?: number;
23
+ emission?: number;
24
+ baseIOR?: number;
13
25
  specular?: number;
14
26
  specularPower?: number;
15
27
  opacity?: number;
@@ -161,6 +173,36 @@ export interface vtkProperty extends vtkObject {
161
173
  */
162
174
  getSpecular(): number;
163
175
 
176
+ /**
177
+ * Get the roughness coefficient.
178
+ * @default 1
179
+ */
180
+ getRoughness(): number;
181
+
182
+ /**
183
+ * Get the metallic coefficient.
184
+ * @default 0
185
+ */
186
+ getMetallic(): number;
187
+
188
+ /**
189
+ * Get the index of refraction.
190
+ * @default 0
191
+ */
192
+ getBaseIOR(): number;
193
+
194
+ /**
195
+ * Get the strength of the normal map.
196
+ * @default 1
197
+ */
198
+ getNormalStrength(): number;
199
+
200
+ /**
201
+ * Get the emission coefficient.
202
+ * @default 0
203
+ */
204
+ getEmission(): number;
205
+
164
206
  /**
165
207
  * Get the specular surface color.
166
208
  * @return {RGBColor} Array of RGB color.
@@ -178,6 +220,36 @@ export interface vtkProperty extends vtkObject {
178
220
  */
179
221
  getSpecularPower(): number;
180
222
 
223
+ /**
224
+ * Get the diffuse texture.
225
+ */
226
+ getDiffuseTexture(): vtkTexture;
227
+
228
+ /**
229
+ * Get the metallic texture.
230
+ */
231
+ getMetallicTexture(): vtkTexture;
232
+
233
+ /**
234
+ * Get the roughness texture.
235
+ */
236
+ getRoughnessTexture(): vtkTexture;
237
+
238
+ /**
239
+ * Get the normal texture.
240
+ */
241
+ getNormalTexture(): vtkTexture;
242
+
243
+ /**
244
+ * Get the ambient occlusion texture.
245
+ */
246
+ getAmbientOcclusionTexture(): vtkTexture;
247
+
248
+ /**
249
+ * Get the emission texture.
250
+ */
251
+ getEmissionTexture(): vtkTexture;
252
+
181
253
  /**
182
254
  * Set the ambient lighting coefficient.
183
255
  * @param {Number} ambient The ambient lighting coefficient.
@@ -385,6 +457,18 @@ export interface vtkProperty extends vtkObject {
385
457
  */
386
458
  setSpecular(specular: number): boolean;
387
459
 
460
+ /**
461
+ * Set the normal map strength.
462
+ * @param {Boolean} normal
463
+ */
464
+ setNormalStrength(normalStrength: number): boolean;
465
+
466
+ /**
467
+ * Set the ambient occlusion map strength.
468
+ * @param {Boolean} emission
469
+ */
470
+ setEmission(emission: number): boolean;
471
+
388
472
  /**
389
473
  * Set the specular surface color.
390
474
  * @param {Number} r Defines the red component (between 0 and 1)
@@ -410,6 +494,42 @@ export interface vtkProperty extends vtkObject {
410
494
  * @param {Number} specularPower
411
495
  */
412
496
  setSpecularPower(specularPower: number): boolean;
497
+
498
+ /**
499
+ * Set the diffuse texture.
500
+ * @param {vtkTexture} diffuseTexture
501
+ */
502
+ setDiffuseTexture(diffuseTexture: vtkTexture): boolean;
503
+
504
+ /**
505
+ * Set the metallic texture.
506
+ * @param {vtkTexture} metallicTexture
507
+ */
508
+ setMetallicTexture(metallicTexture: vtkTexture): boolean;
509
+
510
+ /**
511
+ * Set the roughness texture.
512
+ * @param {vtkTexture} roughnessTexture
513
+ */
514
+ setRoughnessTexture(roughnessTexture: vtkTexture): boolean;
515
+
516
+ /**
517
+ * Set the normal texture.
518
+ * @param {vtkTexture} normalTexture
519
+ */
520
+ setNormalTexture(normalTexture: vtkTexture): boolean;
521
+
522
+ /**
523
+ * Set the ambient occlusion texture.
524
+ * @param {vtkTexture} ambientOcclusionTexture
525
+ */
526
+ setAmbientOcclusionTexture(ambientOcclusionTexture: vtkTexture): boolean;
527
+
528
+ /**
529
+ * Set the emission texture.
530
+ * @param {vtkTexture} emissionTexture
531
+ */
532
+ setEmissionTexture(emissionTexture: vtkTexture): boolean;
413
533
  }
414
534
 
415
535
  /**
@@ -58,6 +58,17 @@ function vtkProperty(publicAPI, model) {
58
58
  return [].concat(model.color);
59
59
  };
60
60
 
61
+ publicAPI.setSpecularPower = function (specularPower) {
62
+ var roughness = 1 / Math.max(1.0, specularPower);
63
+
64
+ if (model.roughness !== roughness || model.specularPower !== specularPower) {
65
+ model.specularPower = specularPower; // Specular power still needs to be set as long as webgl is using it (otherwise testShaderReplacementsClear fails)
66
+
67
+ model.roughness = roughness;
68
+ publicAPI.modified();
69
+ }
70
+ };
71
+
61
72
  publicAPI.addShaderVariable = notImplemented('AddShaderVariable');
62
73
 
63
74
  publicAPI.setInterpolationToFlat = function () {
@@ -104,6 +115,11 @@ var DEFAULT_VALUES = {
104
115
  edgeColor: [0, 0, 0],
105
116
  ambient: 0,
106
117
  diffuse: 1,
118
+ metallic: 0,
119
+ roughness: 0.6,
120
+ normalStrength: 1,
121
+ emission: 1,
122
+ baseIOR: 1.45,
107
123
  specular: 0,
108
124
  specularPower: 1,
109
125
  opacity: 1,
@@ -124,7 +140,7 @@ function extend(publicAPI, model) {
124
140
  Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API
125
141
 
126
142
  macro.obj(publicAPI, model);
127
- macro.setGet(publicAPI, model, ['lighting', 'interpolation', 'ambient', 'diffuse', 'specular', 'specularPower', 'opacity', 'edgeVisibility', 'lineWidth', 'pointSize', 'backfaceCulling', 'frontfaceCulling', 'representation']);
143
+ macro.setGet(publicAPI, model, ['lighting', 'interpolation', 'ambient', 'diffuse', 'metallic', 'roughness', 'normalStrength', 'emission', 'baseIOR', 'specular', 'specularPower', 'opacity', 'edgeVisibility', 'lineWidth', 'pointSize', 'backfaceCulling', 'frontfaceCulling', 'representation', 'diffuseTexture', 'metallicTexture', 'roughnessTexture', 'normalTexture', 'ambientOcclusionTexture', 'emissionTexture']);
128
144
  macro.setGetArray(publicAPI, model, ['ambientColor', 'specularColor', 'diffuseColor', 'edgeColor'], 3); // Object methods
129
145
 
130
146
  vtkProperty(publicAPI, model);
@@ -518,6 +518,9 @@ function vtkRenderWindowInteractor(publicAPI, model) {
518
518
  },
519
519
  right: {
520
520
  buttons: {}
521
+ },
522
+ none: {
523
+ buttons: {}
521
524
  }
522
525
  };
523
526
  }
@@ -712,7 +715,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
712
715
  // No more fingers down
713
716
  if (pointers.length === 0) {
714
717
  var callData = _objectSpread(_objectSpread({}, getModifierKeysFor(EMPTY_MOUSE_EVENT)), {}, {
715
- position: pointers[0].position,
718
+ position: getScreenEventPositionFor(event),
716
719
  deviceType: getDeviceTypeFor(event)
717
720
  });
718
721
 
@@ -72,6 +72,37 @@ function vtkTexture(publicAPI, model) {
72
72
 
73
73
  publicAPI.modified();
74
74
  };
75
+
76
+ publicAPI.getDimensionality = function () {
77
+ var width = 0;
78
+ var height = 0;
79
+ var depth = 1;
80
+
81
+ if (publicAPI.getInputData()) {
82
+ var data = publicAPI.getInputData();
83
+ width = data.getDimensions()[0];
84
+ height = data.getDimensions()[1];
85
+ depth = data.getDimensions()[2];
86
+ }
87
+
88
+ if (model.jsImageData) {
89
+ width = model.jsImageData.width;
90
+ height = model.jsImageData.height;
91
+ }
92
+
93
+ if (model.canvas) {
94
+ width = model.canvas.width;
95
+ height = model.canvas.height;
96
+ }
97
+
98
+ if (model.image) {
99
+ width = model.image.width;
100
+ height = model.image.height;
101
+ }
102
+
103
+ var dimensionality = (width > 1) + (height > 1) + (depth > 1);
104
+ return dimensionality;
105
+ };
75
106
  } // ----------------------------------------------------------------------------
76
107
  // Object factory
77
108
  // ----------------------------------------------------------------------------
@@ -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;