@kitware/vtk.js 19.6.0 → 19.7.3

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.
@@ -154,15 +154,7 @@ export function extend(publicAPI: object, model: object, initialValues?: IPolyDa
154
154
  export function newInstance(initialValues?: IPolyDataInitialValues): vtkPolyData;
155
155
 
156
156
  /**
157
- * vtkPolyData creates an m x n array of quadrilaterals arranged as a regular
158
- * tiling in a plane. The plane is defined by specifying an origin point, and then
159
- * two other points that, together with the origin, define two axes for the plane.
160
- * These axes do not have to be orthogonal - so you can create a parallelogram.
161
- * (The axes must not be parallel.) The resolution of the plane (i.e., number of
162
- * subdivisions) is controlled by the ivars XResolution and YResolution.
163
- *
164
- * By default, the plane is centered at the origin and perpendicular to the z-axis,
165
- * with width and height of length 1 and resolutions set to 1.
157
+ * vtkPolyData is a dataset that represents a geometric structure consisting of vertices, lines, polygons, and/or strips.
166
158
  */
167
159
  export declare const vtkPolyData: {
168
160
  newInstance: typeof newInstance,
@@ -44,7 +44,7 @@ export interface vtkLineSource extends vtkLineSourceBase {
44
44
  getPoint2ByReference(): Vector3;
45
45
 
46
46
  /**
47
- * Get the x resolution of the line.
47
+ * Get the resolution of the line.
48
48
  * @default 6
49
49
  */
50
50
  getResolution(): number;
@@ -91,8 +91,8 @@ export interface vtkLineSource extends vtkLineSourceBase {
91
91
  setPoint2From(point2: Vector3): boolean;
92
92
 
93
93
  /**
94
- * Set the number of facets used to represent the cone.
95
- * @param {Number} resolution The number of facets.
94
+ * Set the number of segments used to represent the line.
95
+ * @param {Number} resolution The number of segments.
96
96
  */
97
97
  setResolution(resolution: number): boolean;
98
98
  }
@@ -113,11 +113,9 @@ export function extend(publicAPI: object, model: object, initialValues?: ILineSo
113
113
  export function newInstance(initialValues?: ILineSourceInitialValues): vtkLineSource;
114
114
 
115
115
  /**
116
- * vtkLineSource creates a polygonal cylinder centered at Center;
117
- * The axis of the cylinder is aligned along the global y-axis.
118
- * The height and radius of the cylinder can be specified, as well as the number of sides.
119
- * It is also possible to control whether the cylinder is open-ended or capped.
120
- * If you have the end points of the cylinder, you should use a vtkLineSource followed by a vtkTubeFilter instead of the vtkLineSource.
116
+ * vtkLineSource creates a line segment from point1 to point2;
117
+ * The resolution can be specified, which determines the number of points along the line.
118
+ * Following a vtkLineSource by a vtkTubeFilter is a convenient way to create a cylinder based on endpoints.
121
119
  *
122
120
  * @example
123
121
  * ```js
@@ -28,8 +28,8 @@ function vtkLineSource(publicAPI, model) {
28
28
  } // hand create a line with special scalars
29
29
 
30
30
 
31
- var xres = model.resolution;
32
- var numPts = xres + 1; // Points
31
+ var res = model.resolution;
32
+ var numPts = res + 1; // Points
33
33
 
34
34
  var points = macro.newTypedArray(pointDataType, numPts * 3);
35
35
  pd.getPoints().setData(points, 3); // Cells
@@ -39,8 +39,8 @@ function vtkLineSource(publicAPI, model) {
39
39
  var idx = 0;
40
40
  var t = 0.0;
41
41
 
42
- for (var i = 0; i < xres + 1; i++) {
43
- t = i / xres;
42
+ for (var i = 0; i < res + 1; i++) {
43
+ t = i / res;
44
44
  points[idx * 3] = model.point1[0] + t * v21[0];
45
45
  points[idx * 3 + 1] = model.point1[1] + t * v21[1];
46
46
  points[idx * 3 + 2] = model.point1[2] + t * v21[2];
@@ -5,20 +5,10 @@
5
5
  * expect proper Unicode or any other encoding.
6
6
  */
7
7
  function arrayBufferToString(arrayBuffer) {
8
- if ('TextDecoder' in window) {
8
+ {
9
9
  var decoder = new TextDecoder('latin1');
10
10
  return decoder.decode(arrayBuffer);
11
11
  } // fallback on platforms w/o TextDecoder
12
-
13
-
14
- var byteArray = new Uint8Array(arrayBuffer);
15
- var strArr = [];
16
-
17
- for (var i = 0; i < byteArray.length; ++i) {
18
- strArr[i] = String.fromCharCode(byteArray[i]);
19
- }
20
-
21
- return strArr.join('');
22
12
  }
23
13
  /**
24
14
  * Extracts binary data out of a file ArrayBuffer given a prefix/suffix.
@@ -1,4 +1,5 @@
1
1
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
+ import '../../vendor/xmlbuilder2/lib/xmlbuilder2.min.js';
2
3
  import { p as pako } from '../../vendor/pako/dist/pako.esm.mjs.js';
3
4
  import DataAccessHelper from '../Core/DataAccessHelper.js';
4
5
  import Base64 from '../../Common/Core/Base64.js';
@@ -6,6 +7,7 @@ import macro from '../../macros.js';
6
7
  import vtkDataArray from '../../Common/Core/DataArray.js';
7
8
  import BinaryHelper from '../Core/BinaryHelper.js';
8
9
  import '../Core/DataAccessHelper/LiteHttpDataAccessHelper.js';
10
+ import { x as xmlbuilder2_min } from '../../_vendor/xmlbuilder2/lib/xmlbuilder2.min.js_commonjs-module.js';
9
11
 
10
12
  // import 'vtk.js/Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper'; // HTTP + zip
11
13
  // import 'vtk.js/Sources/IO/Core/DataAccessHelper/HtmlDataAccessHelper'; // html + base64 + zip
@@ -14,14 +16,16 @@ import '../Core/DataAccessHelper/LiteHttpDataAccessHelper.js';
14
16
  // Global methods
15
17
  // ----------------------------------------------------------------------------
16
18
 
17
- function stringToXML(xmlStr) {
18
- if (window.ActiveXObject) {
19
- var oXML = new window.ActiveXObject('Microsoft.XMLDOM');
20
- oXML.loadXML(xmlStr);
21
- return oXML;
22
- }
19
+ function findAllTags(node, tagName) {
20
+ return _toConsumableArray(node.getElementsByTagName(tagName));
21
+ }
22
+ function findFirstTag(node, tagName) {
23
+ return findAllTags(node, tagName)[0];
24
+ }
23
25
 
24
- return new DOMParser().parseFromString(xmlStr, 'application/xml');
26
+ function parseXML(xmlStr) {
27
+ // see xmlbuilder2 docs on the object format
28
+ return xmlbuilder2_min.exports.create(xmlStr);
25
29
  }
26
30
 
27
31
  function extractAppendedData(buffer) {
@@ -335,8 +339,8 @@ function vtkXMLReader(publicAPI, model) {
335
339
  model.rawDataBuffer = arrayBuffer;
336
340
  model.binaryBuffer = binaryBuffer; // Parse data here...
337
341
 
338
- var doc = stringToXML(content);
339
- var rootElem = doc.firstChild;
342
+ var doc = parseXML(content);
343
+ var rootElem = doc.root().node;
340
344
  var type = rootElem.getAttribute('type');
341
345
  var compressor = rootElem.getAttribute('compressor');
342
346
  var byteOrder = rootElem.getAttribute('byte_order'); // default to UInt32. I think version 0.1 vtp/vti files default to UInt32.
@@ -359,10 +363,10 @@ function vtkXMLReader(publicAPI, model) {
359
363
  } // appended format
360
364
 
361
365
 
362
- if (rootElem.querySelector('AppendedData')) {
363
- var appendedDataElem = rootElem.querySelector('AppendedData');
366
+ if (findFirstTag(rootElem, 'AppendedData')) {
367
+ var appendedDataElem = findFirstTag(rootElem, 'AppendedData');
364
368
  var encoding = appendedDataElem.getAttribute('encoding');
365
- var arrayElems = rootElem.querySelectorAll('DataArray');
369
+ var arrayElems = findAllTags(rootElem, 'DataArray');
366
370
  var appendedBuffer = model.binaryBuffer;
367
371
 
368
372
  if (encoding === 'base64') {
@@ -514,4 +518,4 @@ var vtkXMLReader$1 = {
514
518
  processCells: processCells
515
519
  };
516
520
 
517
- export { vtkXMLReader$1 as default, extend };
521
+ export { vtkXMLReader$1 as default, extend, findAllTags, findFirstTag };
@@ -102,7 +102,7 @@ function extend(publicAPI, model) {
102
102
  macro.obj(publicAPI, model);
103
103
  vtkCompositeMouseManipulator.extend(publicAPI, model, initialValues);
104
104
  vtkCompositeCameraManipulator.extend(publicAPI, model, initialValues);
105
- macro.setGet(publicAPI, model, ['flipDirection']); // Object specific methods
105
+ macro.setGet(publicAPI, model, ['zoomScale', 'flipDirection']); // Object specific methods
106
106
 
107
107
  vtkMouseCameraTrackballZoomManipulator(publicAPI, model);
108
108
  } // ----------------------------------------------------------------------------
@@ -299,8 +299,7 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) {
299
299
 
300
300
 
301
301
  publicAPI.handleMouseWheel = function (callData) {
302
- var dyf = 1 - callData.spinY / 10; // divide by 10 to lower the zoom factor
303
-
302
+ var dyf = 1 - callData.spinY / model.zoomFactor;
304
303
  publicAPI.dollyByFactor(callData.pokedRenderer, dyf);
305
304
  }; //----------------------------------------------------------------------------
306
305
 
@@ -332,7 +331,8 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) {
332
331
 
333
332
 
334
333
  var DEFAULT_VALUES = {
335
- motionFactor: 10.0
334
+ motionFactor: 10.0,
335
+ zoomFactor: 10.0
336
336
  }; // ----------------------------------------------------------------------------
337
337
 
338
338
  function extend(publicAPI, model) {
@@ -341,7 +341,7 @@ function extend(publicAPI, model) {
341
341
 
342
342
  vtkInteractorStyle.extend(publicAPI, model, initialValues); // Create get-set macros
343
343
 
344
- macro.setGet(publicAPI, model, ['motionFactor']); // For more macro methods, see "Sources/macros.js"
344
+ macro.setGet(publicAPI, model, ['motionFactor', 'zoomFactor']); // For more macro methods, see "Sources/macros.js"
345
345
  // Object specific methods
346
346
 
347
347
  vtkInteractorStyleTrackballCamera(publicAPI, model);
@@ -41,7 +41,13 @@ function vtkOpenGLActor(publicAPI, model) {
41
41
  };
42
42
 
43
43
  publicAPI.traverseOpaqueZBufferPass = function (renderPass) {
44
- publicAPI.traverseOpaquePass(renderPass);
44
+ if (!model.renderable || !model.renderable.getNestedVisibility() || model.openGLRenderer.getSelector() && !model.renderable.getNestedPickable()) {
45
+ return;
46
+ }
47
+
48
+ publicAPI.apply(renderPass, true);
49
+ model.oglmapper.traverse(renderPass);
50
+ publicAPI.apply(renderPass, false);
45
51
  }; // we draw textures, then mapper, then post pass textures
46
52
 
47
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "19.6.0",
3
+ "version": "19.7.3",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",