@kitware/vtk.js 21.1.5 → 21.2.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.
@@ -1,5 +1,5 @@
1
1
  import { vtkObject } from '@kitware/vtk.js/interfaces';
2
- import { Color } from '@kitware/vtk.js/types';
2
+ import { RGBColor } from '@kitware/vtk.js/types';
3
3
 
4
4
  export enum Shading {
5
5
  FLAT,
@@ -19,12 +19,12 @@ export enum Interpolation {
19
19
  PHONG,
20
20
  }
21
21
 
22
- interface IPropertyValues {
23
- color?: Color;
24
- ambientColor?: Color;
25
- diffuseColor?: Color;
26
- specularColor?: Color;
27
- edgeColor?: Color;
22
+ export interface IPropertyInitialValues {
23
+ color?: RGBColor;
24
+ ambientColor?: RGBColor;
25
+ diffuseColor?: RGBColor;
26
+ specularColor?: RGBColor;
27
+ edgeColor?: RGBColor;
28
28
  ambient?: number;
29
29
  diffuse?: number;
30
30
  specular?: number;
@@ -63,14 +63,14 @@ export interface vtkProperty extends vtkObject {
63
63
  * and diffuse colors. From a physical standpoint it really doesn't make too
64
64
  * much sense to have both. For the rendering libraries that don't support
65
65
  * both, the diffuse color is used.
66
- * @return {Color} Array of RGB color.
66
+ * @return {RGBColor} Array of RGB color.
67
67
  */
68
- getAmbientColor(): Color;
68
+ getAmbientColor(): RGBColor;
69
69
 
70
70
  /**
71
- *
71
+ * Get the ambient surface color.
72
72
  */
73
- getAmbientColorByReference(): Color;
73
+ getAmbientColorByReference(): RGBColor;
74
74
 
75
75
  /**
76
76
  *
@@ -80,7 +80,7 @@ export interface vtkProperty extends vtkObject {
80
80
  /**
81
81
  * Get the color of the object.the color of the object
82
82
  */
83
- getColor(): Color;
83
+ getColor(): RGBColor;
84
84
 
85
85
  /**
86
86
  * Get the diffuse lighting coefficient.
@@ -90,23 +90,23 @@ export interface vtkProperty extends vtkObject {
90
90
 
91
91
  /**
92
92
  * Get the diffuse surface color.
93
- * @return {Color} Array of RGB color.
93
+ * @return {RGBColor} Array of RGB color.
94
94
  */
95
- getDiffuseColor(): Color;
95
+ getDiffuseColor(): RGBColor;
96
96
  /**
97
97
  *
98
98
  */
99
- getDiffuseColorByReference(): Color;
99
+ getDiffuseColorByReference(): RGBColor;
100
100
 
101
101
  /**
102
102
  *
103
103
  */
104
- getEdgeColor(): Color;
104
+ getEdgeColor(): RGBColor;
105
105
 
106
106
  /**
107
107
  *
108
108
  */
109
- getEdgeColorByReference(): Color;
109
+ getEdgeColorByReference(): RGBColor;
110
110
 
111
111
  /**
112
112
  *
@@ -180,14 +180,14 @@ export interface vtkProperty extends vtkObject {
180
180
 
181
181
  /**
182
182
  * Get the specular surface color.
183
- * @return {Color} Array of RGB color.
183
+ * @return {RGBColor} Array of RGB color.
184
184
  */
185
- getSpecularColor(): Color;
185
+ getSpecularColor(): RGBColor;
186
186
 
187
187
  /**
188
- *
188
+ * Get the specular surface color.
189
189
  */
190
- getSpecularColorByReference(): Color;
190
+ getSpecularColorByReference(): RGBColor;
191
191
 
192
192
  /**
193
193
  * Get the specular power.
@@ -218,15 +218,15 @@ export interface vtkProperty extends vtkObject {
218
218
  * ambient and diffuse colors. From a physical standpoint it really
219
219
  * doesn't make too much sense to have both. For the rendering
220
220
  * libraries that don’t support both, the diffuse color is used.
221
- * @param {Color} ambientColor An Array of the RGB color.
221
+ * @param {RGBColor} ambientColor An Array of the RGB color.
222
222
  */
223
- setAmbientColor(ambientColor: Color): boolean;
223
+ setAmbientColor(ambientColor: RGBColor): boolean;
224
224
 
225
225
  /**
226
226
  * Set the ambient surface color from an RGB array
227
- * @param {Color} ambientColor An Array of the RGB color.
227
+ * @param {RGBColor} ambientColor An Array of the RGB color.
228
228
  */
229
- setAmbientColorFrom(ambientColor: Color): boolean;
229
+ setAmbientColorFrom(ambientColor: RGBColor): boolean;
230
230
 
231
231
  /**
232
232
  * Turn on/off fast culling of polygons based on orientation of normal
@@ -250,9 +250,9 @@ export interface vtkProperty extends vtkObject {
250
250
  * Set the color of the object. Has the side effect of setting the
251
251
  * ambient diffuse and specular colors as well. This is basically
252
252
  * a quick overall color setting method.
253
- * @param {Color} color An Array of the RGB color.
253
+ * @param {RGBColor} color An Array of the RGB color.
254
254
  */
255
- setColor(color: Color): boolean;
255
+ setColor(color: RGBColor): boolean;
256
256
 
257
257
  /**
258
258
  * Set the diffuse lighting coefficient.
@@ -270,15 +270,15 @@ export interface vtkProperty extends vtkObject {
270
270
 
271
271
  /**
272
272
  * Set the diffuse surface color.
273
- * @param {Color} diffuseColor An Array of the RGB color.
273
+ * @param {RGBColor} diffuseColor An Array of the RGB color.
274
274
  */
275
- setDiffuseColor(diffuseColor: Color): boolean;
275
+ setDiffuseColor(diffuseColor: RGBColor): boolean;
276
276
 
277
277
  /**
278
278
  * Set the diffuse surface color from an RGB array
279
- * @param {Color} diffuseColor An Array of the RGB color.
279
+ * @param {RGBColor} diffuseColor An Array of the RGB color.
280
280
  */
281
- setDiffuseColorFrom(diffuseColor: Color): boolean;
281
+ setDiffuseColorFrom(diffuseColor: RGBColor): boolean;
282
282
 
283
283
  /**
284
284
  * Set the color of primitive edges (if edge visibility is enabled).
@@ -290,15 +290,15 @@ export interface vtkProperty extends vtkObject {
290
290
 
291
291
  /**
292
292
  * Set the color of primitive edges (if edge visibility is enabled).
293
- * @param {Color} edgeColor An Array of the RGB color.
293
+ * @param {RGBColor} edgeColor An Array of the RGB color.
294
294
  */
295
- setEdgeColor(edgeColor: Color): boolean;
295
+ setEdgeColor(edgeColor: RGBColor): boolean;
296
296
 
297
297
  /**
298
298
  * Set the color of primitive edges from an RGB array.
299
- * @param {Color} edgeColor An Array of the RGB color.
299
+ * @param {RGBColor} edgeColor An Array of the RGB color.
300
300
  */
301
- setEdgeColorFrom(edgeColor: Color): boolean;
301
+ setEdgeColorFrom(edgeColor: RGBColor): boolean;
302
302
 
303
303
  /**
304
304
  * Turn on/off the visibility of edges. On some renderers it is
@@ -412,15 +412,15 @@ export interface vtkProperty extends vtkObject {
412
412
 
413
413
  /**
414
414
  * Set the specular surface color from an RGB array
415
- * @param {Color} specularColor An Array of the RGB color.
415
+ * @param {RGBColor} specularColor An Array of the RGB color.
416
416
  */
417
- setSpecularColor(specularColor: Color): boolean;
417
+ setSpecularColor(specularColor: RGBColor): boolean;
418
418
 
419
419
  /**
420
420
  * Set the specular surface color from an RGB array
421
- * @param {Color} specularColor An Array of the RGB color.
421
+ * @param {RGBColor} specularColor An Array of the RGB color.
422
422
  */
423
- setSpecularColorFrom(specularColor: Color): boolean;
423
+ setSpecularColorFrom(specularColor: RGBColor): boolean;
424
424
 
425
425
  /**
426
426
  * Set the specular power.
@@ -434,18 +434,18 @@ export interface vtkProperty extends vtkObject {
434
434
  *
435
435
  * @param publicAPI object on which methods will be bounds (public)
436
436
  * @param model object on which data structure will be bounds (protected)
437
- * @param {IPropertyValues} [initialValues] (default: {})
437
+ * @param {IPropertyInitialValues} [initialValues] (default: {})
438
438
  */
439
- export function extend(publicAPI: object, model: object, initialValues?: IPropertyValues): void;
439
+ export function extend(publicAPI: object, model: object, initialValues?: IPropertyInitialValues): void;
440
440
 
441
441
  /**
442
442
  * Method use to create a new instance of vtkProperty with object color, ambient color, diffuse color,
443
443
  * specular color, and edge color white; ambient coefficient=0; diffuse
444
444
  * coefficient=0; specular coefficient=0; specular power=1; Gouraud shading;
445
445
  * and surface representation. Backface and frontface culling are off.
446
- * @param {IPropertyValues} [initialValues] for pre-setting some of its content
446
+ * @param {IPropertyInitialValues} [initialValues] for pre-setting some of its content
447
447
  */
448
- export function newInstance(initialValues?: IPropertyValues): vtkProperty;
448
+ export function newInstance(initialValues?: IPropertyInitialValues): vtkProperty;
449
449
 
450
450
  /**
451
451
  * vtkProperty is an object that represents lighting and other surface
@@ -1,8 +1,8 @@
1
1
  import { vtkObject } from '@kitware/vtk.js/interfaces';
2
- import { Color } from '@kitware/vtk.js/types';
2
+ import { RGBColor } from '@kitware/vtk.js/types';
3
3
 
4
4
  interface IProperty2DInitialValues{
5
- color?: number[];
5
+ color?: RGBColor;
6
6
  opacity?: number;
7
7
  pointSize?: number;
8
8
  lineWidth?: number;
@@ -14,12 +14,12 @@ export interface vtkProperty2D extends vtkObject {
14
14
  /**
15
15
  * Get the color of the object.
16
16
  */
17
- getColor(): Color;
17
+ getColor(): RGBColor;
18
18
 
19
19
  /**
20
20
  * Get the color of the object.
21
21
  */
22
- getColorByReference(): Color;
22
+ getColorByReference(): RGBColor;
23
23
 
24
24
  /**
25
25
  * Get the display location of the object.
@@ -54,6 +54,14 @@ export interface vtkProperty2D extends vtkObject {
54
54
  */
55
55
  setColor(r: number, g: number, b: number): boolean;
56
56
 
57
+ /**
58
+ * Set the color of the object. Has the side effect of setting the
59
+ * ambient diffuse and specular colors as well. This is basically
60
+ * a quick overall color setting method.
61
+ * @param {RGBColor} color Defines the RGB color array..
62
+ */
63
+ setColor(color: RGBColor): boolean;
64
+
57
65
  /**
58
66
  * Set the color of the object. Has the side effect of setting the
59
67
  * ambient diffuse and specular colors as well. This is basically
@@ -62,7 +70,15 @@ export interface vtkProperty2D extends vtkObject {
62
70
  * @param {Number} g Defines the green component (between 0 and 1).
63
71
  * @param {Number} b Defines the blue component (between 0 and 1).
64
72
  */
65
- setColorFrom(color: number[]): boolean;
73
+ setColorFrom(r: number, g: number, b: number): boolean;
74
+
75
+ /**
76
+ * Set the color of the object. Has the side effect of setting the
77
+ * ambient diffuse and specular colors as well. This is basically
78
+ * a quick overall color setting method.
79
+ * @param {RGBColor} color Defines the RGB color array..
80
+ */
81
+ setColorFrom(color: RGBColor): boolean;
66
82
 
67
83
  /**
68
84
  * Set the display location of the object.
@@ -325,7 +325,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
325
325
 
326
326
  animationRequesters.add(requestor);
327
327
 
328
- if (animationRequesters.size === 1) {
328
+ if (animationRequesters.size === 1 && !model.xrAnimation) {
329
329
  model.lastFrameTime = 0.1;
330
330
  model.lastFrameStart = Date.now();
331
331
  model.animationRequest = requestAnimationFrame(publicAPI.handleAnimation);
@@ -334,7 +334,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
334
334
  };
335
335
 
336
336
  publicAPI.isAnimating = function () {
337
- return model.vrAnimation || model.animationRequest !== null;
337
+ return model.xrAnimation || model.animationRequest !== null;
338
338
  };
339
339
 
340
340
  publicAPI.cancelAnimation = function (requestor) {
@@ -359,18 +359,18 @@ function vtkRenderWindowInteractor(publicAPI, model) {
359
359
  }
360
360
  };
361
361
 
362
- publicAPI.switchToVRAnimation = function () {
362
+ publicAPI.switchToXRAnimation = function () {
363
363
  // cancel existing animation if any
364
364
  if (model.animationRequest) {
365
365
  cancelAnimationFrame(model.animationRequest);
366
366
  model.animationRequest = null;
367
367
  }
368
368
 
369
- model.vrAnimation = true;
369
+ model.xrAnimation = true;
370
370
  };
371
371
 
372
- publicAPI.returnFromVRAnimation = function () {
373
- model.vrAnimation = false;
372
+ publicAPI.returnFromXRAnimation = function () {
373
+ model.xrAnimation = false;
374
374
 
375
375
  if (animationRequesters.size !== 0) {
376
376
  model.FrameTime = -1;
@@ -723,7 +723,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
723
723
 
724
724
 
725
725
  publicAPI.render = function () {
726
- if (model.animationRequest === null && !model.inRender) {
726
+ if (!publicAPI.isAnimating() && !model.inRender) {
727
727
  forceRender();
728
728
  }
729
729
  }; // create the generic Event methods
@@ -121,6 +121,15 @@ export function newInstance(initialValues?: IVolumeInitialValues): vtkVolume;
121
121
  *
122
122
  * @example
123
123
  * ```js
124
+ * // Load the rendering pieces we want to use (for both WebGL and WebGPU)
125
+ * import 'vtk.js/Sources/Rendering/Profiles/Volume';
126
+ *
127
+ * import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction';
128
+ * import vtkHttpDataSetReader from '@kitware/vtk.js/IO/Core/HttpDataSetReader';
129
+ *
130
+ * import vtkVolume from '@kitware/vtk.js/Rendering/Core/Volume';
131
+ * import vtkVolumeMapper from '@kitware/vtk.js/Rendering/Core/VolumeMapper';
132
+
124
133
  * const vol = vtkVolume.newInstance();
125
134
  * const mapper = vtkVolumeMapper.newInstance();
126
135
  * mapper.setSampleDistance(2.0);
@@ -396,7 +396,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
396
396
  }
397
397
 
398
398
  cellBO.getProgram().setUniformi('numClipPlanes', numClipPlanes);
399
- cellBO.getProgram().setUniform4fv('clipPlanes', 6, planeEquations);
399
+ cellBO.getProgram().setUniform4fv('clipPlanes', planeEquations);
400
400
  }
401
401
  };
402
402
 
@@ -467,16 +467,10 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
467
467
 
468
468
  if (model.renderable.getNumberOfClippingPlanes()) {
469
469
  var numClipPlanes = model.renderable.getNumberOfClippingPlanes();
470
-
471
- if (numClipPlanes > 6) {
472
- vtkErrorMacro$1('OpenGL has a limit of 6 clipping planes');
473
- numClipPlanes = 6;
474
- }
475
-
476
- VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;', 'uniform vec4 clipPlanes[6];', 'varying float clipDistancesVSOutput[6];']).result;
477
- VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Impl', ['for (int planeNum = 0; planeNum < 6; planeNum++)', ' {', ' if (planeNum >= numClipPlanes)', ' {', ' break;', ' }', ' clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], vertexMC);', ' }']).result;
478
- FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;', 'varying float clipDistancesVSOutput[6];']).result;
479
- FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Impl', ['for (int planeNum = 0; planeNum < 6; planeNum++)', ' {', ' if (planeNum >= numClipPlanes)', ' {', ' break;', ' }', ' if (clipDistancesVSOutput[planeNum] < 0.0) discard;', ' }']).result;
470
+ VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;', "uniform vec4 clipPlanes[".concat(numClipPlanes, "];"), "varying float clipDistancesVSOutput[".concat(numClipPlanes, "];")]).result;
471
+ VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Impl', ["for (int planeNum = 0; planeNum < ".concat(numClipPlanes, "; planeNum++)"), ' {', ' if (planeNum >= numClipPlanes)', ' {', ' break;', ' }', ' clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], vertexMC);', ' }']).result;
472
+ FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;', "varying float clipDistancesVSOutput[".concat(numClipPlanes, "];")]).result;
473
+ FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Impl', ["for (int planeNum = 0; planeNum < ".concat(numClipPlanes, "; planeNum++)"), ' {', ' if (planeNum >= numClipPlanes)', ' {', ' break;', ' }', ' if (clipDistancesVSOutput[planeNum] < 0.0) discard;', ' }']).result;
480
474
  }
481
475
 
482
476
  shaders.Vertex = VSSource;
@@ -715,12 +709,6 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
715
709
  if (model.renderable.getNumberOfClippingPlanes()) {
716
710
  // add all the clipping planes
717
711
  var numClipPlanes = model.renderable.getNumberOfClippingPlanes();
718
-
719
- if (numClipPlanes > 6) {
720
- vtkErrorMacro$1('OpenGL has a limit of 6 clipping planes');
721
- numClipPlanes = 6;
722
- }
723
-
724
712
  var planeEquations = [];
725
713
 
726
714
  for (var i = 0; i < numClipPlanes; i++) {
@@ -733,7 +721,7 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
733
721
  }
734
722
 
735
723
  cellBO.getProgram().setUniformi('numClipPlanes', numClipPlanes);
736
- cellBO.getProgram().setUniform4fv('clipPlanes', 6, planeEquations);
724
+ cellBO.getProgram().setUniform4fv('clipPlanes', planeEquations);
737
725
  }
738
726
 
739
727
  if (model.internalColorTexture && cellBO.getProgram().isUniformUsed('texture1')) {