@kitware/vtk.js 25.11.0 → 25.12.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.
@@ -105,10 +105,8 @@ export interface vtkScalarsToColors extends vtkObject {
105
105
 
106
106
  /**
107
107
  *
108
- * @param {Number} min
109
- * @param {Number} max
110
108
  */
111
- getRange(min: number, max: number): Range;
109
+ getRange(): Range;
112
110
 
113
111
  /**
114
112
  * Get which component of a vector to map to colors.
@@ -501,7 +501,7 @@ function vtkScalarsToColors(publicAPI, model) {
501
501
  return publicAPI.setMappingRange(min, max);
502
502
  };
503
503
 
504
- publicAPI.getRange = function (min, max) {
504
+ publicAPI.getRange = function () {
505
505
  return publicAPI.getMappingRange();
506
506
  };
507
507
  } // ----------------------------------------------------------------------------
@@ -1,3 +1,5 @@
1
+ import { Nullable } from './../../types';
2
+
1
3
  /**
2
4
  *
3
5
  */
@@ -5,6 +7,12 @@ export interface IEdgeLocatorInitialValues {
5
7
  oriented?: boolean;
6
8
  }
7
9
 
10
+ export interface IEdge<T = unknown> {
11
+ key: number;
12
+ edgeId: number;
13
+ value?: T;
14
+ }
15
+
8
16
  export interface vtkEdgeLocator {
9
17
  /**
10
18
  * Remove all the edges previously added.
@@ -15,9 +23,9 @@ export interface vtkEdgeLocator {
15
23
  * Returns the inserted edge or null if no edge was inserted.
16
24
  * @param {Number} pointId0 Edge first point id
17
25
  * @param {Number} pointId1 Edge last point id
18
- * @return {key, edgeId, value} or null
26
+ * @return {IEdge|null} an edge object ({ key, edgeId, value }) or null
19
27
  */
20
- isInsertedEdge(pointId0: number, pointId1: number): { key: any; edgeId: number; value?: any } | null;
28
+ isInsertedEdge<T = unknown>(pointId0: number, pointId1: number): Nullable<IEdge<T>>;
21
29
 
22
30
  /**
23
31
  * Insert edge if it does not already exist.
@@ -25,16 +33,12 @@ export interface vtkEdgeLocator {
25
33
  *
26
34
  * @param {Number} pointId0 Edge first point id
27
35
  * @param {Number} pointId1 Edge last point id
28
- * @param {any} value Optional value option
29
- * @return {key, edgeId, value}
36
+ * @param {unknown} value Optional value option
37
+ * @return {IEdge|null} an edge object ({ key, edgeId, value }) or null
30
38
  * @see insertEdge()
31
39
  * @see isInsertedEdge()
32
40
  */
33
- insertUniqueEdge(
34
- pointId0: number,
35
- pointId1: number,
36
- value?: any
37
- ): { key: any; edgeId: number; value?: any };
41
+ insertUniqueEdge<T>(pointId0: number, pointId1: number, value?: T): IEdge<T>;
38
42
 
39
43
  /**
40
44
  * Insert edge. If the edge already exists, it is overwritten by this
@@ -43,15 +47,12 @@ export interface vtkEdgeLocator {
43
47
  * Returns the newly inserted edge.
44
48
  * @param {Number} pointId0 Edge first point id
45
49
  * @param {Number} pointId1 Edge last point id
46
- * @param {any} value Optional value option
47
- * @return {key, edgeId, value} or null
50
+ * @param {unknown} value Optional value option
51
+ * @return {Edge|null} an edge object ({ key, edgeId, value }) or null
48
52
  * @see isInsertedEdge
49
53
  * @see insertUniqueEdge
50
54
  */
51
- insertEdge(pointId0: number,
52
- pointId1: number,
53
- value?: any
54
- ): { key: any; edgeId: number; value?: any };
55
+ insertEdge<T>(pointId0: number, pointId1: number, value?: T): IEdge<T>;
55
56
  }
56
57
 
57
58
  // ----------------------------------------------------------------------------
@@ -45,8 +45,7 @@ var EdgeLocator = /*#__PURE__*/function () {
45
45
  key: "insertEdge",
46
46
  value: function insertEdge(pointId0, pointId1, newEdgeValue) {
47
47
  // Generate a unique key
48
- var key = this.computeEdgeKey(pointId0, pointId1); // Didn't find key, so add a new edge entry
49
-
48
+ var key = this.computeEdgeKey(pointId0, pointId1);
50
49
  var node = {
51
50
  key: key,
52
51
  edgeId: this.edgeMap.size,
@@ -327,7 +327,18 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
327
327
  setViewStream(stream: vtkViewStream): boolean;
328
328
 
329
329
  /**
330
- *
330
+ * Sets the pixel width and height of the rendered image.
331
+ *
332
+ * WebGL and WebGPU render windows apply these values to
333
+ * the width and height attribute of the canvas element.
334
+ *
335
+ * To match the device resolution in browser environments,
336
+ * multiply the container size by `window.devicePixelRatio`
337
+ * `apiSpecificRenderWindow.setSize(Math.floor(containerWidth * devicePixelRatio), Math.floor(containerHeight * devicePixelRatio));
338
+ * See the VTK.js FullscreenRenderWindow class for an example.
339
+ *
340
+ * @see getComputedDevicePixelRatio()
341
+ *
331
342
  * @param {Vector2} size
332
343
  */
333
344
  setSize(size: Vector2): void;
@@ -361,6 +372,19 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
361
372
  *
362
373
  */
363
374
  getVrResolution(): Vector2;
375
+
376
+ /**
377
+ * Scales the size of a browser CSS pixel to a rendered canvas pixel.
378
+ * `const renderedPixelWidth = cssPixelWidth * apiRenderWindow.getComputedDevicePixelRatio()`
379
+ * Use to scale rendered objects to a consistent perceived size or DOM pixel position.
380
+ *
381
+ * Rather than using window.devicePixelRatio directly, the device pixel ratio is inferred
382
+ * from the container CSS pixel size and rendered image pixel size. The user directly sets the rendered pixel size.
383
+ *
384
+ * @see setSize()
385
+ * @see getContainerSize()
386
+ */
387
+ getComputedDevicePixelRatio(): number;
364
388
  }
365
389
 
366
390
  /**
@@ -298,7 +298,7 @@ function vtkOpenGLTexture(publicAPI, model) {
298
298
 
299
299
 
300
300
  publicAPI.getInternalFormat = function (vtktype, numComps) {
301
- if (!model.internalFormat) {
301
+ if (!model._forceInternalFormat) {
302
302
  model.internalFormat = publicAPI.getDefaultInternalFormat(vtktype, numComps);
303
303
  }
304
304
 
@@ -332,6 +332,8 @@ function vtkOpenGLTexture(publicAPI, model) {
332
332
 
333
333
 
334
334
  publicAPI.setInternalFormat = function (iFormat) {
335
+ model._forceInternalFormat = true;
336
+
335
337
  if (iFormat !== model.internalFormat) {
336
338
  model.internalFormat = iFormat;
337
339
  publicAPI.modified();
@@ -388,6 +390,7 @@ function vtkOpenGLTexture(publicAPI, model) {
388
390
  publicAPI.resetFormatAndType = function () {
389
391
  model.format = 0;
390
392
  model.internalFormat = 0;
393
+ model._forceInternalFormat = false;
391
394
  model.openGLDataType = 0;
392
395
  }; //----------------------------------------------------------------------------
393
396
 
@@ -1288,6 +1291,7 @@ function vtkOpenGLTexture(publicAPI, model) {
1288
1291
 
1289
1292
  var DEFAULT_VALUES = {
1290
1293
  _openGLRenderWindow: null,
1294
+ _forceInternalFormat: false,
1291
1295
  context: null,
1292
1296
  handle: 0,
1293
1297
  sendParametersTime: null,
@@ -119,14 +119,20 @@ function vtkRenderWindowViewNode(publicAPI, model) {
119
119
  return publicAPI.displayToNormalizedDisplay(x2, y2, z);
120
120
  };
121
121
 
122
+ publicAPI.getComputedDevicePixelRatio = function () {
123
+ return model.size[0] / publicAPI.getContainerSize()[0];
124
+ };
125
+
126
+ publicAPI.getContainerSize = function () {
127
+ macro.vtkErrorMacro('not implemented');
128
+ };
129
+
122
130
  publicAPI.getPixelData = function (x1, y1, x2, y2) {
123
131
  macro.vtkErrorMacro('not implemented');
124
- return undefined;
125
132
  };
126
133
 
127
134
  publicAPI.createSelector = function () {
128
135
  macro.vtkErrorMacro('not implemented');
129
- return undefined;
130
136
  };
131
137
  } // ----------------------------------------------------------------------------
132
138
  // Object factory
@@ -181,6 +181,7 @@ function vtkViewNode(publicAPI, model) {
181
181
  }
182
182
 
183
183
  deleted.push(child);
184
+ child.delete();
184
185
  } else {
185
186
  child.setVisited(false);
186
187
  }
@@ -208,6 +209,16 @@ function vtkViewNode(publicAPI, model) {
208
209
 
209
210
  return ret;
210
211
  };
212
+
213
+ var parentDelete = publicAPI.delete;
214
+
215
+ publicAPI.delete = function () {
216
+ for (var i = 0; i < model.children.length; i++) {
217
+ model.children[i].delete();
218
+ }
219
+
220
+ parentDelete();
221
+ };
211
222
  } // ----------------------------------------------------------------------------
212
223
  // Object factory
213
224
  // ----------------------------------------------------------------------------
@@ -126,7 +126,8 @@ function vtkWidgetManager(publicAPI, model) {
126
126
  cwidth = _model$_apiSpecificRe2[0],
127
127
  cheight = _model$_apiSpecificRe2[1];
128
128
 
129
- var ratio = window.devicePixelRatio || 1;
129
+ var ratio = model._apiSpecificRenderWindow.getComputedDevicePixelRatio();
130
+
130
131
  var bwidth = String(cwidth / ratio);
131
132
  var bheight = String(cheight / ratio);
132
133
  var viewBox = "0 0 ".concat(cwidth, " ").concat(cheight);
@@ -243,7 +244,9 @@ function vtkWidgetManager(publicAPI, model) {
243
244
  vxmax = _renderer$getViewport2[2],
244
245
  vymax = _renderer$getViewport2[3];
245
246
 
246
- var rendererPixelDims = [rwW * (vxmax - vxmin), rwH * (vymax - vymin)];
247
+ var pixelRatio = _apiSpecificRenderWindow.getComputedDevicePixelRatio();
248
+
249
+ var rendererPixelDims = [rwW * (vxmax - vxmin) / pixelRatio, rwH * (vymax - vymin) / pixelRatio];
247
250
 
248
251
  var cameraPosition = _camera.getPosition();
249
252
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "25.11.0",
3
+ "version": "25.12.0",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",