@kitware/vtk.js 26.8.0 → 26.8.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.
@@ -0,0 +1,27 @@
1
+ export declare enum SelectionContent {
2
+ GLOBALIDS = 0,
3
+ PEDIGREEIDS = 1,
4
+ VALUES = 2,
5
+ INDICES = 3,
6
+ FRUSTUM = 4,
7
+ LOCATIONS = 5,
8
+ THRESHOLDS = 6,
9
+ BLOCKS = 7,
10
+ QUERY = 8,
11
+ }
12
+
13
+ export declare enum SelectionField {
14
+ CELL = 0,
15
+ POINT = 1,
16
+ FIELD = 2,
17
+ VERTEX = 3,
18
+ EDGE = 4,
19
+ ROW = 5,
20
+ }
21
+
22
+ declare const _default: {
23
+ SelectionContent: typeof SelectionContent;
24
+ SelectionField: typeof SelectionField;
25
+ }
26
+
27
+ export default _default;
@@ -1,35 +1,70 @@
1
1
  import { vtkObject } from './../../interfaces' ;
2
2
  import { Bounds } from './../../types';
3
+ import { SelectionContent, SelectionField } from './SelectionNode/Constants';
4
+ import vtkProp from './../../Rendering/Core/Prop';
3
5
 
4
- export enum SelectionContent {
5
- GLOBALIDS,
6
- PEDIGREEIDS,
7
- VALUES,
8
- INDICES,
9
- FRUSTUM,
10
- LOCATIONS,
11
- THRESHOLDS,
12
- BLOCKS,
13
- QUERY,
6
+ export interface ISelectionNodeInitialValues {
7
+ contentType?: SelectionContent;
8
+ fieldType?: SelectionField;
9
+ properties?: ISelectionNodeProperties;
10
+ selectionList?: number[];
14
11
  }
15
12
 
16
- export enum SelectionField {
17
- CELL,
18
- POINT,
19
- FIELD,
20
- VERTEX,
21
- EDGE,
22
- ROW,
13
+ export interface ISelectionNodeProperties {
14
+ propID?: number;
15
+ prop?: vtkProp;
16
+ compositeID?: number;
17
+ attributeID?: number;
18
+ pixelCount?: number;
19
+ displayPosition?: [number, number, number];
20
+ worldPosition?: [number, number, number];
23
21
  }
24
22
 
25
- export interface ISelectionNodeInitialValues {}
26
-
27
23
  export interface vtkSelectionNode extends vtkObject {
28
-
29
24
  /**
30
- *
25
+ * Get the bounds of the selection points.
31
26
  */
32
27
  getBounds(): Bounds;
28
+
29
+ /**
30
+ * Returns -1 if not initialized.
31
+ */
32
+ getContentType(): SelectionContent | -1;
33
+
34
+ /**
35
+ * This functions is called internally by VTK.js and is not intended for public use.
36
+ */
37
+ setContentType(contentType: SelectionContent): void;
38
+
39
+ /**
40
+ * Returns -1 if not initialized.
41
+ */
42
+ getFieldType(): SelectionField | -1;
43
+
44
+ /**
45
+ * This functions is called internally by VTK.js and is not intended for public use.
46
+ */
47
+ setFieldType(fieldType: SelectionField): void;
48
+
49
+ /**
50
+ * Get the selection properties.
51
+ */
52
+ getProperties(): ISelectionNodeProperties;
53
+
54
+ /**
55
+ * This functions is called internally by VTK.js and is not intended for public use.
56
+ */
57
+ setProperties(properties: ISelectionNodeProperties);
58
+
59
+ /**
60
+ * Get the list of the underlying selected attribute IDs.
61
+ */
62
+ getSelectionList(): number[];
63
+
64
+ /**
65
+ * This functions is called internally by VTK.js and is not intended for public use.
66
+ */
67
+ setSelectionList(selectionAttributeIDs: ISelectionNodeProperties);
33
68
  }
34
69
 
35
70
  /**
@@ -57,5 +92,7 @@ export function newInstance(initialValues?: ISelectionNodeInitialValues): vtkSel
57
92
  export declare const vtkSelectionNode: {
58
93
  newInstance: typeof newInstance,
59
94
  extend: typeof extend;
95
+ SelectionContent: typeof SelectionContent;
96
+ SelectionField: typeof SelectionField;
60
97
  };
61
98
  export default vtkSelectionNode;
@@ -19,6 +19,16 @@ function centerDataSet(ds) {
19
19
  var center = [-(bounds[0] + bounds[1]) * 0.5, -(bounds[2] + bounds[3]) * 0.5, -(bounds[4] + bounds[5]) * 0.5];
20
20
 
21
21
  (_vtkMatrixBuilder$bui = vtkMatrixBuilder.buildFromDegree()).translate.apply(_vtkMatrixBuilder$bui, center).apply(ds.getPoints().getData());
22
+ }
23
+
24
+ function shiftDataset(ds, axis) {
25
+ var _vtkMatrixBuilder$bui2;
26
+
27
+ var bounds = ds.getPoints().getBounds();
28
+ var center = [0, 0, 0];
29
+ center[axis] = -bounds[axis * 2];
30
+
31
+ (_vtkMatrixBuilder$bui2 = vtkMatrixBuilder.buildFromDegree()).translate.apply(_vtkMatrixBuilder$bui2, center).apply(ds.getPoints().getData());
22
32
  } // ----------------------------------------------------------------------------
23
33
 
24
34
 
@@ -47,33 +57,100 @@ function vtkAxesActor(publicAPI, model) {
47
57
  // Set our className
48
58
  model.classHierarchy.push('vtkAxesActor');
49
59
 
60
+ var _mapper = vtkMapper.newInstance();
61
+
62
+ publicAPI.setMapper(_mapper);
63
+
50
64
  publicAPI.update = function () {
51
65
  var xAxis = vtkArrowSource.newInstance(_objectSpread({
52
66
  direction: [1, 0, 0]
53
67
  }, model.config)).getOutputData();
54
- centerDataSet(xAxis);
68
+
69
+ if (model.config.recenter) {
70
+ centerDataSet(xAxis);
71
+ } else {
72
+ shiftDataset(xAxis, 0);
73
+ }
74
+
55
75
  addColor.apply(void 0, [xAxis].concat(_toConsumableArray(model.xAxisColor)));
56
76
  var yAxis = vtkArrowSource.newInstance(_objectSpread({
57
77
  direction: [0, 1, 0]
58
78
  }, model.config)).getOutputData();
59
- centerDataSet(yAxis);
79
+
80
+ if (model.config.recenter) {
81
+ centerDataSet(yAxis);
82
+ } else {
83
+ shiftDataset(yAxis, 1);
84
+ }
85
+
60
86
  addColor.apply(void 0, [yAxis].concat(_toConsumableArray(model.yAxisColor)));
61
87
  var zAxis = vtkArrowSource.newInstance(_objectSpread({
62
88
  direction: [0, 0, 1]
63
89
  }, model.config)).getOutputData();
64
- centerDataSet(zAxis);
90
+
91
+ if (model.config.recenter) {
92
+ centerDataSet(zAxis);
93
+ } else {
94
+ shiftDataset(zAxis, 2);
95
+ }
96
+
65
97
  addColor.apply(void 0, [zAxis].concat(_toConsumableArray(model.zAxisColor)));
66
98
  var source = vtkAppendPolyData.newInstance();
67
99
  source.setInputData(xAxis);
68
100
  source.addInputData(yAxis);
69
- source.addInputData(zAxis); // set mapper
101
+ source.addInputData(zAxis);
70
102
 
71
- var mapper = vtkMapper.newInstance();
72
- mapper.setInputConnection(source.getOutputPort());
73
- publicAPI.setMapper(mapper);
103
+ _mapper.setInputConnection(source.getOutputPort());
74
104
  };
75
105
 
76
106
  publicAPI.update();
107
+
108
+ var _debouncedUpdate = macro.debounce(publicAPI.update, 0);
109
+
110
+ var setConfig = publicAPI.setConfig,
111
+ setXAxisColor = publicAPI.setXAxisColor,
112
+ setYAxisColor = publicAPI.setYAxisColor,
113
+ setZAxisColor = publicAPI.setZAxisColor;
114
+
115
+ publicAPI.setConfig = function (c) {
116
+ if (setConfig(c)) {
117
+ _debouncedUpdate();
118
+
119
+ return true;
120
+ }
121
+
122
+ return false;
123
+ };
124
+
125
+ publicAPI.setXAxisColor = function (c) {
126
+ if (setXAxisColor(c)) {
127
+ _debouncedUpdate();
128
+
129
+ return true;
130
+ }
131
+
132
+ return false;
133
+ };
134
+
135
+ publicAPI.setYAxisColor = function (c) {
136
+ if (setYAxisColor(c)) {
137
+ _debouncedUpdate();
138
+
139
+ return true;
140
+ }
141
+
142
+ return false;
143
+ };
144
+
145
+ publicAPI.setZAxisColor = function (c) {
146
+ if (setZAxisColor(c)) {
147
+ _debouncedUpdate();
148
+
149
+ return true;
150
+ }
151
+
152
+ return false;
153
+ };
77
154
  } // ----------------------------------------------------------------------------
78
155
  // Object factory
79
156
  // ----------------------------------------------------------------------------
@@ -81,6 +158,7 @@ function vtkAxesActor(publicAPI, model) {
81
158
 
82
159
  var DEFAULT_VALUES = {
83
160
  config: {
161
+ recenter: true,
84
162
  tipResolution: 60,
85
163
  tipRadius: 0.1,
86
164
  tipLength: 0.2,
@@ -1,10 +1,9 @@
1
1
  import vtkDataArray from './../../Common/Core/DataArray';
2
- import { vtkObject } from './../../interfaces';
2
+ import vtkScalarsToColors from './../../Common/Core/ScalarsToColors'
3
3
  import { ColorSpace, Scale } from './ColorTransferFunction/Constants';
4
4
 
5
5
 
6
- /* TODO: use VtkScalarsToColors instead of VtkObject */
7
- export interface vtkColorTransferFunction extends vtkObject {
6
+ export interface vtkColorTransferFunction extends vtkScalarsToColors {
8
7
  /**
9
8
  * Add a point defined in RGB
10
9
  * @param {Number} x The index of the point.
@@ -270,13 +269,6 @@ export interface vtkColorTransferFunction extends vtkObject {
270
269
  */
271
270
  fillFromDataPointer(nb: number, ptr: any): void;
272
271
 
273
- /**
274
- * Set the range of scalars being mapped.
275
- * @param {Number} min
276
- * @param {Number} max
277
- */
278
- setMappingRange(min: number, max: number): void;
279
-
280
272
  /**
281
273
  * Remove all points out of the new range, and make sure there is a point at
282
274
  * each end of that range.
@@ -485,6 +485,10 @@ export interface vtkMapper extends vtkAbstractMapper3D {
485
485
  *
486
486
  */
487
487
  setInterpolateScalarsBeforeMapping(interpolateScalarsBeforeMapping: boolean): boolean;
488
+
489
+ setResolveCoincidentTopologyToPolygonOffset(): boolean;
490
+
491
+ setResolveCoincidentTopologyToOff(): boolean;
488
492
  }
489
493
 
490
494
  /**
@@ -628,6 +628,32 @@ export interface vtkRenderer extends vtkViewport {
628
628
  * Not Implemented yet
629
629
  */
630
630
  visibleVolumeCount(): any;
631
+
632
+ /**
633
+ * Set the viewport background.
634
+ *
635
+ * @param {Number} r Defines the red component (between 0 and 1).
636
+ * @param {Number} g Defines the green component (between 0 and 1).
637
+ * @param {Number} b Defines the blue component (between 0 and 1).
638
+ * @param {Number} b Defines the alpha component (between 0 and 1).
639
+ */
640
+ setBackground(r: number, g: number, b: number, a: number): boolean;
641
+
642
+ /**
643
+ * Set the viewport background.
644
+ *
645
+ * @param {Number} r Defines the red component (between 0 and 1).
646
+ * @param {Number} g Defines the green component (between 0 and 1).
647
+ * @param {Number} b Defines the blue component (between 0 and 1).
648
+ */
649
+ setBackground(r: number, g: number, b: number): boolean;
650
+
651
+ /**
652
+ * Set the viewport background.
653
+ *
654
+ * @param {Number[]} background The RGB color array.
655
+ */
656
+ setBackground(background: number[]): boolean;
631
657
  }
632
658
 
633
659
  /**
@@ -27,6 +27,7 @@ import vtkImageProperty from '../../Core/ImageProperty.js';
27
27
  import vtkPiecewiseFunction from '../../../Common/DataModel/PiecewiseFunction.js';
28
28
  import vtkCubeAxesActor from '../../Core/CubeAxesActor.js';
29
29
  import vtkScalarBarActor from '../../Core/ScalarBarActor.js';
30
+ import vtkAxesActor from '../../Core/AxesActor.js';
30
31
 
31
32
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
32
33
 
@@ -583,6 +584,10 @@ var DEFAULT_ALIASES = {
583
584
  }; // ----------------------------------------------------------------------------
584
585
 
585
586
  var DEFAULT_MAPPING = {
587
+ vtkAxesActor: {
588
+ build: vtkAxesActor.newInstance,
589
+ update: genericUpdater
590
+ },
586
591
  vtkRenderWindow: {
587
592
  build: vtkRenderWindow.newInstance,
588
593
  update: vtkRenderWindowUpdater
@@ -54,42 +54,42 @@ export interface IViewState {
54
54
  export interface vtkSynchronizableRenderWindow extends vtkRenderWindow {
55
55
 
56
56
  /**
57
- *
57
+ *
58
58
  */
59
59
  getSynchronizerContext(): ISynchronizerContext;
60
60
 
61
61
  // methods added by createSyncFunction
62
62
 
63
63
  /**
64
- *
65
- * @param {IViewState} state
64
+ *
65
+ * @param {IViewState} state
66
66
  */
67
67
  synchronize(state: IViewState): Promise<boolean>;
68
68
 
69
69
  /**
70
- *
71
- * @param {String} viewId
70
+ *
71
+ * @param {String} viewId
72
72
  */
73
73
  setSynchronizedViewId(viewId: string): void;
74
74
 
75
75
  /**
76
- *
76
+ *
77
77
  */
78
78
  getSynchronizedViewId(): string;
79
79
 
80
80
  /**
81
- *
82
- * @param {Number} v
81
+ *
82
+ * @param {Number} v
83
83
  */
84
84
  updateGarbageCollectorThreshold(v: number): void;
85
85
 
86
86
  /**
87
- *
87
+ *
88
88
  */
89
89
  getManagedInstanceIds(): string[];
90
90
 
91
91
  /**
92
- *
92
+ *
93
93
  */
94
94
  clearOneTimeUpdaters(): void;
95
95
  }
@@ -110,52 +110,60 @@ export function extend(publicAPI: object, model: object, initialValues?: ISynchr
110
110
  export function newInstance(initialValues?: ISynchronizableRenderWindowInitialValues): vtkSynchronizableRenderWindow;
111
111
 
112
112
  /**
113
- *
114
- * @param {String} [name]
113
+ *
114
+ * @param {String} [name]
115
115
  */
116
116
  export function getSynchronizerContext(name?: string): ISynchronizerContext;
117
117
 
118
118
  /**
119
- *
120
- * @param {String} name
121
- * @param {ISynchronizerContext} ctx
119
+ *
120
+ * @param {String} name
121
+ * @param {Nullable<ISynchronizerContext>} ctx
122
122
  */
123
- export function setSynchronizerContext(name: string, ctx: ISynchronizerContext): ISynchronizerContext;
123
+ export function setSynchronizerContext(name: string, ctx: Nullable<ISynchronizerContext>);
124
+
124
125
 
125
126
  /**
126
- *
127
- * @param {vtkRenderWindow} renderWindow
128
- * @param {String} [name]
127
+ *
128
+ * @param name of the context to remove and if nothing provided clear them all.
129
+ */
130
+ export function clearSynchronizerContext(name: Nullable<string>);
131
+
132
+ /**
133
+ *
134
+ * @param {vtkRenderWindow} renderWindow
135
+ * @param {String} [name]
129
136
  */
130
137
  export function decorate(renderWindow: vtkRenderWindow, name?: string): object;
131
138
 
132
139
  /**
133
- *
140
+ *
134
141
  */
135
142
  export function createInstanceMap(): object;
136
143
 
137
144
  /**
138
- *
145
+ *
139
146
  */
140
147
  export function createArrayHandler(): object;
141
148
 
142
149
  /**
143
- *
150
+ *
144
151
  */
145
152
  export function createProgressHandler(): object;
146
153
 
147
154
  /**
148
- *
155
+ *
149
156
  */
150
157
  export function createSceneMtimeHandler(): object;
151
158
 
152
159
  /**
153
- *
160
+ *
154
161
  */
155
162
  export declare const vtkSynchronizableRenderWindow: {
156
163
  newInstance: typeof newInstance;
157
164
  getSynchronizerContext: typeof getSynchronizerContext;
158
165
  setSynchronizerContext: typeof setSynchronizerContext;
166
+ clearSynchronizerContext: typeof clearSynchronizerContext;
159
167
  decorate: typeof decorate,
160
168
  createInstanceMap: typeof createInstanceMap,
161
169
  createArrayHandler: typeof createArrayHandler,
@@ -220,6 +220,20 @@ function getSynchronizerContext() {
220
220
 
221
221
  function setSynchronizerContext(name, ctx) {
222
222
  SYNCHRONIZER_CONTEXTS[name] = ctx;
223
+ }
224
+
225
+ function clearSynchronizerContext(name) {
226
+ if (name && SYNCHRONIZER_CONTEXTS[name]) {
227
+ delete SYNCHRONIZER_CONTEXTS[name];
228
+ }
229
+
230
+ if (!name) {
231
+ var keys = Object.keys(SYNCHRONIZER_CONTEXTS);
232
+
233
+ for (var i = 0; i < keys.length; i++) {
234
+ delete SYNCHRONIZER_CONTEXTS[keys[i]];
235
+ }
236
+ }
223
237
  } // ----------------------------------------------------------------------------
224
238
 
225
239
 
@@ -346,6 +360,7 @@ var vtkSynchronizableRenderWindow$1 = {
346
360
  extend: extend,
347
361
  getSynchronizerContext: getSynchronizerContext,
348
362
  setSynchronizerContext: setSynchronizerContext,
363
+ clearSynchronizerContext: clearSynchronizerContext,
349
364
  decorate: decorate,
350
365
  createInstanceMap: createInstanceMap,
351
366
  createArrayHandler: createArrayHandler,
@@ -151,7 +151,7 @@ function vtkOpenGLOrderIndependentTranslucentPass(publicAPI, model) {
151
151
  // have the forward pass use a texture backed zbuffer
152
152
 
153
153
  if (forwardPass.getOpaqueActorCount() > 0) {
154
- forwardPass.setCurrentOperation('opaquePass');
154
+ forwardPass.setCurrentOperation('opaqueZBufferPass');
155
155
  renNode.traverse(forwardPass);
156
156
  }
157
157
 
@@ -34,9 +34,9 @@ export interface IOpenGLRenderWindowInitialValues {
34
34
  }
35
35
 
36
36
  export interface ICaptureOptions {
37
- resetCamera: boolean;
38
- size: Size;
39
- scale: number
37
+ resetCamera?: boolean;
38
+ size?: Size;
39
+ scale?: number
40
40
  }
41
41
 
42
42
  export interface I3DContextOptions {
@@ -320,7 +320,7 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
320
320
  * @param {String} format
321
321
  * @param {ICaptureOptions} options
322
322
  */
323
- captureNextImage(format: string, options: ICaptureOptions): Nullable<Promise<string>>;
323
+ captureNextImage(format: string, options?: ICaptureOptions): Nullable<Promise<string>>;
324
324
 
325
325
  /**
326
326
  *
@@ -376,16 +376,19 @@ function vtkOpenGLSurfaceLICInterface(publicAPI, model) {
376
376
  fb.bind();
377
377
  model.geometryImage.activate();
378
378
  model.vectorImage.activate();
379
- model.maskVectorImage.activate();
379
+ model.maskVectorImage.activate(); // Don't use location 1 as it can be used by order independant translucent pass
380
+ // Translucent pass uses location 1 because of this line:
381
+ // gl_FragData[1].r = weight;
382
+
380
383
  fb.removeColorBuffer(0);
381
- fb.removeColorBuffer(1);
382
384
  fb.removeColorBuffer(2);
385
+ fb.removeColorBuffer(3);
383
386
  fb.setColorBuffer(model.geometryImage, 0);
384
- fb.setColorBuffer(model.vectorImage, 1);
385
- fb.setColorBuffer(model.maskVectorImage, 2);
387
+ fb.setColorBuffer(model.vectorImage, 2);
388
+ fb.setColorBuffer(model.maskVectorImage, 3);
386
389
  fb.setDepthBuffer(model.depthTexture);
387
390
  var gl = model.context;
388
- gl.drawBuffers([gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1, gl.COLOR_ATTACHMENT2]);
391
+ gl.drawBuffers([gl.COLOR_ATTACHMENT0, gl.NONE, gl.COLOR_ATTACHMENT2, gl.COLOR_ATTACHMENT3]);
389
392
  gl.viewport.apply(gl, [0, 0].concat(_toConsumableArray(model.size)));
390
393
  gl.scissor.apply(gl, [0, 0].concat(_toConsumableArray(model.size)));
391
394
  gl.disable(gl.BLEND);
@@ -30,7 +30,7 @@ function vtkOpenGLSurfaceLICMapper(publicAPI, model) {
30
30
  var array = model.renderable.getInputArrayToProcess(0);
31
31
 
32
32
  if (array && model.canDrawLIC) {
33
- FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Output::Dec', ['//VTK::Output::Dec', 'layout(location = 1) out vec4 vectorTexture;', 'layout(location = 2) out vec4 maskVectorTexture;']).result;
33
+ FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Output::Dec', ['//VTK::Output::Dec', 'layout(location = 2) out vec4 vectorTexture;', 'layout(location = 3) out vec4 maskVectorTexture;']).result;
34
34
  var arrayName = array.getName();
35
35
  var attributeName = "".concat(arrayName, "MC"); // We need normals even with no lighting
36
36
 
package/index.d.ts CHANGED
@@ -43,6 +43,7 @@
43
43
  /// <reference path="./Common/DataModel/PolyLine.d.ts" />
44
44
  /// <reference path="./Common/DataModel/Polygon.d.ts" />
45
45
  /// <reference path="./Common/DataModel/Quad.d.ts" />
46
+ /// <reference path="./Common/DataModel/SelectionNode/Constants.d.ts" />
46
47
  /// <reference path="./Common/DataModel/SelectionNode.d.ts" />
47
48
  /// <reference path="./Common/DataModel/Sphere.d.ts" />
48
49
  /// <reference path="./Common/DataModel/Spline1D.d.ts" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "26.8.0",
3
+ "version": "26.8.2",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",