@kitware/vtk.js 22.6.0 → 22.6.1

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 { mat4 } from 'gl-matrix';
2
- import { TypedArray } from '@kitware/vtk.js/types';
2
+ import { TypedArray, Vector3 } from '@kitware/vtk.js/types';
3
3
 
4
4
  declare interface Transform {
5
5
 
@@ -22,9 +22,9 @@ declare interface Transform {
22
22
  * Normalizes the axis of rotation then rotates the current matrix `angle`
23
23
  * degrees/radians around the provided axis.
24
24
  * @param {Number} angle
25
- * @param {Number} axis
25
+ * @param {Vector3} axis
26
26
  */
27
- rotate(angle: number, axis: number): Transform
27
+ rotate(angle: number, axis: Vector3): Transform
28
28
 
29
29
  /**
30
30
  * Rotates `angle` degrees/radians around the X axis.
@@ -201,17 +201,18 @@ export interface vtkImageData extends vtkDataSet {
201
201
  /**
202
202
  * this is the fast version, requires vec3 arguments
203
203
  * @param {ReadonlyVec3} vin
204
- * @param {vec3} vout
204
+ * @param {vec3} [vout]
205
205
  */
206
- indexToWorldVec3(vin: ReadonlyVec3, vout: vec3): vec3;
206
+ indexToWorldVec3(vin: ReadonlyVec3, vout?: vec3): vec3;
207
207
 
208
208
  /**
209
- * Converts the input index vector `[i,j,k]` to world values `[x,y,z]`.
210
- * Modifies the out vector array in place, but also returns it.
209
+ * Converts the input index vector `[i,j,k]` to world values `[x,y,z]`.
210
+ * If an out vector is not provided, a new one is created. If provided, it
211
+ * modifies the out vector array in place, but also returns it.
211
212
  * @param {ReadonlyVec3} ain
212
- * @param {vec3} aout
213
+ * @param {vec3} [aout]
213
214
  */
214
- indexToWorld(ain: ReadonlyVec3, aout: vec3): vec3;
215
+ indexToWorld(ain: ReadonlyVec3, aout?: vec3): vec3;
215
216
 
216
217
  /**
217
218
  * Calculate the corresponding world bounds for the given index bounds
@@ -308,18 +309,19 @@ export interface vtkImageData extends vtkDataSet {
308
309
  /**
309
310
  * this is the fast version, requires vec3 arguments
310
311
  * @param vin
311
- * @param vout
312
+ * @param [vout]
312
313
  */
313
- worldToIndexVec3(vin: ReadonlyVec3, vout: vec3): vec3;
314
+ worldToIndexVec3(vin: ReadonlyVec3, vout?: vec3): vec3;
314
315
 
315
316
  /**
316
317
  * Converts the input world vector `[x,y,z]` to approximate index values
317
318
  * `[i,j,k]`. Should be rounded to integers before attempting to access the
318
- * index. Modifies the out vector array in place, but also returns it.
319
+ * index. If an out vector is not provided, a new one is created. If provided, it
320
+ * modifies the out vector array in place, but also returns it.
319
321
  * @param ain
320
- * @param aout
322
+ * @param [aout]
321
323
  */
322
- worldToIndex(ain: ReadonlyVec3, aout: vec3): vec3;
324
+ worldToIndex(ain: ReadonlyVec3, aout?: vec3): vec3;
323
325
 
324
326
  /**
325
327
  * Calculate the corresponding index bounds for the given world bounds
package/LICENSE CHANGED
@@ -3,22 +3,25 @@ All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
5
5
  modification, are permitted provided that the following conditions are met:
6
- * Redistributions of source code must retain the above copyright
7
- notice, this list of conditions and the following disclaimer.
8
- * Redistributions in binary form must reproduce the above copyright
9
- notice, this list of conditions and the following disclaimer in the
10
- documentation and/or other materials provided with the distribution.
11
- * Neither the name of the <organization> nor the
12
- names of its contributors may be used to endorse or promote products
13
- derived from this software without specific prior written permission.
14
6
 
15
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
- DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7
+ - Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ - Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ - Neither the name of the copyright holder nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -325,7 +325,21 @@ function vtkRenderWindowInteractor(publicAPI, model) {
325
325
 
326
326
  animationRequesters.add(requestor);
327
327
 
328
- if (animationRequesters.size === 1 && !model.xrAnimation) {
328
+ if (!model.animationRequest && animationRequesters.size === 1 && !model.xrAnimation) {
329
+ model._animationStartTime = Date.now();
330
+ model._animationFrameCount = 0;
331
+ model.animationRequest = requestAnimationFrame(publicAPI.handleAnimation);
332
+ publicAPI.startAnimationEvent();
333
+ }
334
+ }; // continue animating for at least the specified duration of
335
+ // milliseconds.
336
+
337
+
338
+ publicAPI.extendAnimation = function (duration) {
339
+ var newEnd = Date.now() + duration;
340
+ model._animationExtendedEnd = Math.max(model._animationExtendedEnd, newEnd);
341
+
342
+ if (!model.animationRequest && animationRequesters.size === 0 && !model.xrAnimation) {
329
343
  model._animationStartTime = Date.now();
330
344
  model._animationFrameCount = 0;
331
345
  model.animationRequest = requestAnimationFrame(publicAPI.handleAnimation);
@@ -351,7 +365,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
351
365
 
352
366
  animationRequesters.delete(requestor);
353
367
 
354
- if (model.animationRequest && animationRequesters.size === 0) {
368
+ if (model.animationRequest && animationRequesters.size === 0 && Date.now() > model._animationExtendedEnd) {
355
369
  cancelAnimationFrame(model.animationRequest);
356
370
  model.animationRequest = null;
357
371
  publicAPI.endAnimationEvent();
@@ -462,7 +476,15 @@ function vtkRenderWindowInteractor(publicAPI, model) {
462
476
 
463
477
  publicAPI.animationEvent();
464
478
  forceRender();
465
- model.animationRequest = requestAnimationFrame(publicAPI.handleAnimation);
479
+
480
+ if (animationRequesters.size > 0 || Date.now() < model._animationExtendedEnd) {
481
+ model.animationRequest = requestAnimationFrame(publicAPI.handleAnimation);
482
+ } else {
483
+ cancelAnimationFrame(model.animationRequest);
484
+ model.animationRequest = null;
485
+ publicAPI.endAnimationEvent();
486
+ publicAPI.render();
487
+ }
466
488
  };
467
489
 
468
490
  publicAPI.handleWheel = function (event) {
@@ -497,9 +519,10 @@ function vtkRenderWindowInteractor(publicAPI, model) {
497
519
 
498
520
 
499
521
  model.wheelTimeoutID = setTimeout(function () {
522
+ publicAPI.extendAnimation(600);
500
523
  publicAPI.endMouseWheelEvent();
501
524
  model.wheelTimeoutID = 0;
502
- }, 800);
525
+ }, 200);
503
526
  };
504
527
 
505
528
  publicAPI.handleMouseEnter = function (event) {
@@ -987,7 +1010,9 @@ function extend(publicAPI, model) {
987
1010
  var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
988
1011
  Object.assign(model, DEFAULT_VALUES, initialValues); // Object methods
989
1012
 
990
- macro.obj(publicAPI, model);
1013
+ macro.obj(publicAPI, model); // run animation at least until this time
1014
+
1015
+ model._animationExtendedEnd = 0;
991
1016
  macro.event(publicAPI, model, 'RenderEvent');
992
1017
  handledEvents.forEach(function (eventName) {
993
1018
  return macro.event(publicAPI, model, eventName);
package/index.d.ts ADDED
@@ -0,0 +1,139 @@
1
+ /// <reference path="./types.d.ts" />
2
+ /// <reference path="./interfaces.d.ts" />
3
+ /// <reference path="./macros.d.ts" />
4
+ /// <reference path="./vtk.d.ts" />
5
+ /// <reference path="./Common/Core/Base64.d.ts" />
6
+ /// <reference path="./Common/Core/CellArray.d.ts" />
7
+ /// <reference path="./Common/Core/DataArray.d.ts" />
8
+ /// <reference path="./Common/Core/Endian.d.ts" />
9
+ /// <reference path="./Common/Core/HalfFloat.d.ts" />
10
+ /// <reference path="./Common/Core/ImageHelper.d.ts" />
11
+ /// <reference path="./Common/Core/LookupTable.d.ts" />
12
+ /// <reference path="./Common/Core/MatrixBuilder.d.ts" />
13
+ /// <reference path="./Common/Core/Points.d.ts" />
14
+ /// <reference path="./Common/Core/PriorityQueue.d.ts" />
15
+ /// <reference path="./Common/Core/ProgressHandler.d.ts" />
16
+ /// <reference path="./Common/Core/ScalarsToColors.d.ts" />
17
+ /// <reference path="./Common/Core/StringArray.d.ts" />
18
+ /// <reference path="./Common/Core/URLExtract.d.ts" />
19
+ /// <reference path="./Common/Core/VariantArray.d.ts" />
20
+ /// <reference path="./Common/DataModel/Box.d.ts" />
21
+ /// <reference path="./Common/DataModel/CardinalSpline1D.d.ts" />
22
+ /// <reference path="./Common/DataModel/Cell.d.ts" />
23
+ /// <reference path="./Common/DataModel/Cone.d.ts" />
24
+ /// <reference path="./Common/DataModel/Cylinder.d.ts" />
25
+ /// <reference path="./Common/DataModel/DataSet.d.ts" />
26
+ /// <reference path="./Common/DataModel/DataSetAttributes/FieldData.d.ts" />
27
+ /// <reference path="./Common/DataModel/DataSetAttributes.d.ts" />
28
+ /// <reference path="./Common/DataModel/ImageData.d.ts" />
29
+ /// <reference path="./Common/DataModel/KochanekSpline1D.d.ts" />
30
+ /// <reference path="./Common/DataModel/Line.d.ts" />
31
+ /// <reference path="./Common/DataModel/PiecewiseFunction.d.ts" />
32
+ /// <reference path="./Common/DataModel/Plane.d.ts" />
33
+ /// <reference path="./Common/DataModel/PointSet.d.ts" />
34
+ /// <reference path="./Common/DataModel/PolyData.d.ts" />
35
+ /// <reference path="./Common/DataModel/Polygon.d.ts" />
36
+ /// <reference path="./Common/DataModel/SelectionNode.d.ts" />
37
+ /// <reference path="./Common/DataModel/Sphere.d.ts" />
38
+ /// <reference path="./Common/DataModel/Spline1D.d.ts" />
39
+ /// <reference path="./Common/DataModel/Spline3D.d.ts" />
40
+ /// <reference path="./Common/DataModel/Triangle.d.ts" />
41
+ /// <reference path="./Common/Transform/LandmarkTransform.d.ts" />
42
+ /// <reference path="./Filters/General/AppendPolyData.d.ts" />
43
+ /// <reference path="./Filters/General/ImageCropFilter.d.ts" />
44
+ /// <reference path="./Filters/General/ImageOutlineFilter.d.ts" />
45
+ /// <reference path="./Filters/General/ImageSliceFilter.d.ts" />
46
+ /// <reference path="./Filters/General/LineFilter.d.ts" />
47
+ /// <reference path="./Filters/General/OutlineFilter.d.ts" />
48
+ /// <reference path="./Filters/General/TriangleFilter.d.ts" />
49
+ /// <reference path="./Filters/General/TubeFilter.d.ts" />
50
+ /// <reference path="./Filters/Sources/Arrow2DSource.d.ts" />
51
+ /// <reference path="./Filters/Sources/ArrowSource.d.ts" />
52
+ /// <reference path="./Filters/Sources/CircleSource.d.ts" />
53
+ /// <reference path="./Filters/Sources/ConeSource.d.ts" />
54
+ /// <reference path="./Filters/Sources/CubeSource.d.ts" />
55
+ /// <reference path="./Filters/Sources/Cursor3D.d.ts" />
56
+ /// <reference path="./Filters/Sources/CylinderSource.d.ts" />
57
+ /// <reference path="./Filters/Sources/LineSource.d.ts" />
58
+ /// <reference path="./Filters/Sources/PlaneSource.d.ts" />
59
+ /// <reference path="./Filters/Sources/PointSource.d.ts" />
60
+ /// <reference path="./Filters/Sources/SphereSource.d.ts" />
61
+ /// <reference path="./Filters/Texture/TextureMapToPlane.d.ts" />
62
+ /// <reference path="./Filters/Texture/TextureMapToSphere.d.ts" />
63
+ /// <reference path="./Interaction/Widgets/OrientationMarkerWidget.d.ts" />
64
+ /// <reference path="./IO/Core/HttpSceneLoader.d.ts" />
65
+ /// <reference path="./IO/Core/ImageStream/DefaultProtocol.d.ts" />
66
+ /// <reference path="./IO/Core/ImageStream.d.ts" />
67
+ /// <reference path="./IO/Core/ImageStream/ViewStream.d.ts" />
68
+ /// <reference path="./IO/Core/WSLinkClient.d.ts" />
69
+ /// <reference path="./IO/Geometry/DracoReader.d.ts" />
70
+ /// <reference path="./IO/Geometry/PLYReader.d.ts" />
71
+ /// <reference path="./IO/Geometry/PLYWriter.d.ts" />
72
+ /// <reference path="./IO/Geometry/STLReader.d.ts" />
73
+ /// <reference path="./IO/Geometry/STLWriter.d.ts" />
74
+ /// <reference path="./IO/Misc/ElevationReader.d.ts" />
75
+ /// <reference path="./IO/Misc/ITKImageReader.d.ts" />
76
+ /// <reference path="./IO/Misc/ITKPolyDataReader.d.ts" />
77
+ /// <reference path="./IO/Misc/JSONNucleoReader.d.ts" />
78
+ /// <reference path="./IO/Misc/JSONReader.d.ts" />
79
+ /// <reference path="./IO/Misc/MTLReader.d.ts" />
80
+ /// <reference path="./IO/Misc/OBJReader.d.ts" />
81
+ /// <reference path="./IO/Misc/PDBReader.d.ts" />
82
+ /// <reference path="./IO/XML/XMLImageDataReader.d.ts" />
83
+ /// <reference path="./IO/XML/XMLPolyDataReader.d.ts" />
84
+ /// <reference path="./IO/XML/XMLReader.d.ts" />
85
+ /// <reference path="./Rendering/Core/AbstractMapper.d.ts" />
86
+ /// <reference path="./Rendering/Core/AbstractMapper3D.d.ts" />
87
+ /// <reference path="./Rendering/Core/AbstractPicker.d.ts" />
88
+ /// <reference path="./Rendering/Core/Actor.d.ts" />
89
+ /// <reference path="./Rendering/Core/Actor2D.d.ts" />
90
+ /// <reference path="./Rendering/Core/AnnotatedCubeActor.d.ts" />
91
+ /// <reference path="./Rendering/Core/AxesActor.d.ts" />
92
+ /// <reference path="./Rendering/Core/Camera.d.ts" />
93
+ /// <reference path="./Rendering/Core/CellPicker.d.ts" />
94
+ /// <reference path="./Rendering/Core/ColorTransferFunction.d.ts" />
95
+ /// <reference path="./Rendering/Core/Coordinate.d.ts" />
96
+ /// <reference path="./Rendering/Core/Follower.d.ts" />
97
+ /// <reference path="./Rendering/Core/Glyph3DMapper.d.ts" />
98
+ /// <reference path="./Rendering/Core/ImageMapper.d.ts" />
99
+ /// <reference path="./Rendering/Core/ImageProperty.d.ts" />
100
+ /// <reference path="./Rendering/Core/ImageSlice.d.ts" />
101
+ /// <reference path="./Rendering/Core/Light.d.ts" />
102
+ /// <reference path="./Rendering/Core/Mapper.d.ts" />
103
+ /// <reference path="./Rendering/Core/Mapper2D.d.ts" />
104
+ /// <reference path="./Rendering/Core/Picker.d.ts" />
105
+ /// <reference path="./Rendering/Core/PixelSpaceCallbackMapper.d.ts" />
106
+ /// <reference path="./Rendering/Core/PointPicker.d.ts" />
107
+ /// <reference path="./Rendering/Core/Prop.d.ts" />
108
+ /// <reference path="./Rendering/Core/Prop3D.d.ts" />
109
+ /// <reference path="./Rendering/Core/Property.d.ts" />
110
+ /// <reference path="./Rendering/Core/Property2D.d.ts" />
111
+ /// <reference path="./Rendering/Core/Renderer.d.ts" />
112
+ /// <reference path="./Rendering/Core/RenderWindow.d.ts" />
113
+ /// <reference path="./Rendering/Core/RenderWindowInteractor.d.ts" />
114
+ /// <reference path="./Rendering/Core/ScalarBarActor.d.ts" />
115
+ /// <reference path="./Rendering/Core/Skybox.d.ts" />
116
+ /// <reference path="./Rendering/Core/SphereMapper.d.ts" />
117
+ /// <reference path="./Rendering/Core/StickMapper.d.ts" />
118
+ /// <reference path="./Rendering/Core/Texture.d.ts" />
119
+ /// <reference path="./Rendering/Core/Viewport.d.ts" />
120
+ /// <reference path="./Rendering/Core/Volume.d.ts" />
121
+ /// <reference path="./Rendering/Core/VolumeMapper.d.ts" />
122
+ /// <reference path="./Rendering/Core/VolumeProperty.d.ts" />
123
+ /// <reference path="./Rendering/Misc/CanvasView.d.ts" />
124
+ /// <reference path="./Rendering/Misc/FullScreenRenderWindow.d.ts" />
125
+ /// <reference path="./Rendering/Misc/GenericRenderWindow.d.ts" />
126
+ /// <reference path="./Rendering/Misc/RemoteView.d.ts" />
127
+ /// <reference path="./Rendering/Misc/RenderWindowWithControlBar.d.ts" />
128
+ /// <reference path="./Rendering/Misc/SynchronizableRenderWindow.d.ts" />
129
+ /// <reference path="./Rendering/Misc/TextureLODsDownloader.d.ts" />
130
+ /// <reference path="./Rendering/OpenGL/RenderWindow.d.ts" />
131
+ /// <reference path="./Rendering/SceneGraph/RenderPass.d.ts" />
132
+ /// <reference path="./Rendering/SceneGraph/ViewNode.d.ts" />
133
+ /// <reference path="./Rendering/SceneGraph/ViewNodeFactory.d.ts" />
134
+ /// <reference path="./Widgets/Manipulators/LineManipulator.d.ts" />
135
+ /// <reference path="./Widgets/Manipulators/PlaneManipulator.d.ts" />
136
+ /// <reference path="./Widgets/Manipulators/TrackballManipulator.d.ts" />
137
+ /// <reference path="./Widgets/Representations/ResliceCursorContextRepresentation.d.ts" />
138
+ /// <reference path="./Widgets/Representations/WidgetRepresentation.d.ts" />
139
+ /// <reference path="./Common/Core/Math.d.ts" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "22.6.0",
3
+ "version": "22.6.1",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",
@@ -223,5 +223,6 @@
223
223
  },
224
224
  "publishConfig": {
225
225
  "access": "public"
226
- }
226
+ },
227
+ "types": "./index.d.ts"
227
228
  }
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "include": ["Sources/**/*"],
3
+ "compilerOptions": {
4
+ "allowJs": true,
5
+ "declaration": true,
6
+ "emitDeclarationOnly": true
7
+ }
8
+ }
package/vtk.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ *
3
+ * @param obj
4
+ * @return
5
+ */
6
+ declare function vtk(obj: object): any;
7
+
8
+ /**
9
+ * Nest register method under the vtk function
10
+ * @param vtkClassName
11
+ * @param constructor
12
+ */
13
+ declare function register(vtkClassName: string, constructor: any): void;
14
+
15
+ export default vtk;