@kitware/vtk.js 33.0.0-beta.1 → 33.0.0-beta.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.
- package/Common/Core/DataArray.d.ts +4 -0
- package/Common/Core/DataArray.js +3 -0
- package/Common/Core/Math/index.js +1 -1
- package/Common/Core/Math.js +1 -1
- package/Common/Core/URLExtract.js +2 -6
- package/Common/DataModel/Line.js +1 -0
- package/Common/DataModel/PolyLine.js +4 -0
- package/Filters/Core/ThresholdPoints.d.ts +72 -0
- package/Filters/Core/ThresholdPoints.js +219 -0
- package/Filters/General/ContourTriangulator/helper.js +1 -1
- package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +1 -1
- package/IO/Geometry/DracoReader.d.ts +4 -4
- package/IO/Geometry/DracoReader.js +154 -105
- package/IO/Geometry/GLTFImporter/Animations.js +239 -0
- package/IO/Geometry/GLTFImporter/Constants.js +87 -0
- package/IO/Geometry/GLTFImporter/Decoder.js +69 -0
- package/IO/Geometry/GLTFImporter/Extensions.js +110 -0
- package/IO/Geometry/GLTFImporter/ORMTexture.worker.js +42 -0
- package/IO/Geometry/GLTFImporter/Parser.js +359 -0
- package/IO/Geometry/GLTFImporter/Reader.js +518 -0
- package/IO/Geometry/GLTFImporter/Utils.js +165 -0
- package/IO/Geometry/GLTFImporter.d.ts +266 -0
- package/IO/Geometry/GLTFImporter.js +245 -0
- package/IO/Geometry/IFCImporter.d.ts +163 -0
- package/IO/Geometry/IFCImporter.js +270 -0
- package/IO/Geometry/STLReader.d.ts +14 -0
- package/IO/Geometry/STLReader.js +57 -1
- package/IO/Geometry.js +5 -1
- package/IO/Image/HDRReader/Utils.js +1 -1
- package/IO/Image/HDRReader.js +1 -1
- package/IO/Image/TGAReader/Constants.js +28 -0
- package/IO/Image/TGAReader.d.ts +121 -0
- package/IO/Image/TGAReader.js +418 -0
- package/IO/Image/TIFFReader.d.ts +133 -0
- package/IO/Image/TIFFReader.js +144 -0
- package/IO/Image.js +5 -1
- package/IO/XML/XMLPolyDataWriter.js +1 -0
- package/Interaction/Manipulators/KeyboardCameraManipulator.d.ts +113 -0
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
- package/Interaction/Style/InteractorStyleTrackballCamera.js +1 -1
- package/Rendering/Core/Glyph3DMapper.d.ts +45 -29
- package/Rendering/Core/ImageCPRMapper.js +1 -1
- package/Rendering/Core/ImageProperty.d.ts +22 -0
- package/Rendering/Core/PointPicker.js +10 -1
- package/Rendering/Core/Prop3D.js +1 -1
- package/Rendering/Core/RenderWindowInteractor.d.ts +1 -1
- package/Rendering/Core/RenderWindowInteractor.js +1 -1
- package/Rendering/Misc/CanvasView.js +4 -2
- package/Rendering/Misc/RemoteView.d.ts +9 -3
- package/Rendering/Misc/RemoteView.js +7 -3
- package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.d.ts +1 -1
- package/Rendering/OpenGL/ImageMapper.js +14 -7
- package/Rendering/OpenGL/Texture/supportsNorm16Linear.js +97 -0
- package/Rendering/OpenGL/Texture.js +18 -11
- package/Widgets/Widgets3D/AngleWidget/behavior.js +2 -0
- package/Widgets/Widgets3D/InteractiveOrientationWidget.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +17 -0
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -0
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +3 -0
- package/_virtual/rollup-plugin-worker-loader__module_Sources/IO/Geometry/GLTFImporter/ORMTexture.worker.js +296 -0
- package/index.d.ts +6 -0
- package/package.json +12 -10
|
@@ -5,6 +5,7 @@ import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
|
5
5
|
import { V as isPowerOfTwo, R as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
|
|
6
6
|
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
7
7
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
8
|
+
import supportsNorm16LinearCached from './Texture/supportsNorm16Linear.js';
|
|
8
9
|
|
|
9
10
|
const {
|
|
10
11
|
Wrap,
|
|
@@ -133,6 +134,12 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
133
134
|
publicAPI.activate();
|
|
134
135
|
}
|
|
135
136
|
};
|
|
137
|
+
const getNorm16Ext = () => {
|
|
138
|
+
if ((model.minificationFilter === Filter.LINEAR || model.magnificationFilter === Filter.LINEAR) && !supportsNorm16LinearCached()) {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
return model.oglNorm16Ext;
|
|
142
|
+
};
|
|
136
143
|
|
|
137
144
|
//----------------------------------------------------------------------------
|
|
138
145
|
publicAPI.destroyTexture = () => {
|
|
@@ -285,7 +292,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
285
292
|
publicAPI.getDefaultInternalFormat = (vtktype, numComps) => {
|
|
286
293
|
let result = 0;
|
|
287
294
|
// try default next
|
|
288
|
-
result = model._openGLRenderWindow.getDefaultTextureInternalFormat(vtktype, numComps,
|
|
295
|
+
result = model._openGLRenderWindow.getDefaultTextureInternalFormat(vtktype, numComps, getNorm16Ext(), publicAPI.useHalfFloat());
|
|
289
296
|
if (result) {
|
|
290
297
|
return result;
|
|
291
298
|
}
|
|
@@ -364,9 +371,9 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
364
371
|
return model.context.UNSIGNED_BYTE;
|
|
365
372
|
// prefer norm16 since that is accurate compared to
|
|
366
373
|
// half float which is not
|
|
367
|
-
case
|
|
374
|
+
case getNorm16Ext() && !useHalfFloat && VtkDataTypes.SHORT:
|
|
368
375
|
return model.context.SHORT;
|
|
369
|
-
case
|
|
376
|
+
case getNorm16Ext() && !useHalfFloat && VtkDataTypes.UNSIGNED_SHORT:
|
|
370
377
|
return model.context.UNSIGNED_SHORT;
|
|
371
378
|
// use half float type
|
|
372
379
|
case useHalfFloat && VtkDataTypes.SHORT:
|
|
@@ -659,7 +666,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
659
666
|
}
|
|
660
667
|
if (model._openGLRenderWindow.getWebgl2()) {
|
|
661
668
|
const webGLInfo = model._openGLRenderWindow.getGLInformations();
|
|
662
|
-
if (webGLInfo.RENDERER.value.match(/WebKit/gi) && navigator.platform.match(/Mac/gi) &&
|
|
669
|
+
if (webGLInfo.RENDERER.value.match(/WebKit/gi) && navigator.platform.match(/Mac/gi) && getNorm16Ext() && (dataType === VtkDataTypes.UNSIGNED_SHORT || dataType === VtkDataTypes.SHORT)) {
|
|
663
670
|
// Cannot use texStorage with EXT_texture_norm16 textures on Mac M1 GPU.
|
|
664
671
|
// No errors reported but the texture is unusable.
|
|
665
672
|
return false;
|
|
@@ -717,7 +724,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
717
724
|
if (flip) {
|
|
718
725
|
model.context.pixelStorei(model.context.UNPACK_FLIP_Y_WEBGL, false);
|
|
719
726
|
}
|
|
720
|
-
model.allocatedGPUMemoryInBytes = model.width * model.height * model.depth * numComps * model._openGLRenderWindow.getDefaultTextureByteSize(dataType,
|
|
727
|
+
model.allocatedGPUMemoryInBytes = model.width * model.height * model.depth * numComps * model._openGLRenderWindow.getDefaultTextureByteSize(dataType, getNorm16Ext(), publicAPI.useHalfFloat());
|
|
721
728
|
publicAPI.deactivate();
|
|
722
729
|
return true;
|
|
723
730
|
};
|
|
@@ -795,7 +802,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
795
802
|
h /= 2;
|
|
796
803
|
}
|
|
797
804
|
}
|
|
798
|
-
model.allocatedGPUMemoryInBytes = model.width * model.height * model.depth * numComps * model._openGLRenderWindow.getDefaultTextureByteSize(dataType,
|
|
805
|
+
model.allocatedGPUMemoryInBytes = model.width * model.height * model.depth * numComps * model._openGLRenderWindow.getDefaultTextureByteSize(dataType, getNorm16Ext(), publicAPI.useHalfFloat());
|
|
799
806
|
// generateMipmap must not be called here because we manually upload all levels
|
|
800
807
|
// if it is called, all levels will be overwritten
|
|
801
808
|
|
|
@@ -845,7 +852,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
845
852
|
if (model.generateMipmap) {
|
|
846
853
|
model.context.generateMipmap(model.target);
|
|
847
854
|
}
|
|
848
|
-
model.allocatedGPUMemoryInBytes = model.width * model.height * model.depth * model.components * model._openGLRenderWindow.getDefaultTextureByteSize(dataType,
|
|
855
|
+
model.allocatedGPUMemoryInBytes = model.width * model.height * model.depth * model.components * model._openGLRenderWindow.getDefaultTextureByteSize(dataType, getNorm16Ext(), publicAPI.useHalfFloat());
|
|
849
856
|
publicAPI.deactivate();
|
|
850
857
|
return true;
|
|
851
858
|
};
|
|
@@ -895,7 +902,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
895
902
|
if (model.generateMipmap) {
|
|
896
903
|
model.context.generateMipmap(model.target);
|
|
897
904
|
}
|
|
898
|
-
model.allocatedGPUMemoryInBytes = model.width * model.height * model.depth * model.components * model._openGLRenderWindow.getDefaultTextureByteSize(VtkDataTypes.UNSIGNED_CHAR,
|
|
905
|
+
model.allocatedGPUMemoryInBytes = model.width * model.height * model.depth * model.components * model._openGLRenderWindow.getDefaultTextureByteSize(VtkDataTypes.UNSIGNED_CHAR, getNorm16Ext(), publicAPI.useHalfFloat());
|
|
899
906
|
publicAPI.deactivate();
|
|
900
907
|
return true;
|
|
901
908
|
};
|
|
@@ -1013,7 +1020,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
1013
1020
|
}
|
|
1014
1021
|
|
|
1015
1022
|
// Handle SHORT data type with EXT_texture_norm16 extension
|
|
1016
|
-
if (
|
|
1023
|
+
if (getNorm16Ext() && !useHalfFloat && dataType === VtkDataTypes.SHORT) {
|
|
1017
1024
|
for (let c = 0; c < numComps; ++c) {
|
|
1018
1025
|
model.volumeInfo.scale[c] = 32767.0; // Scale to [-1, 1] range
|
|
1019
1026
|
}
|
|
@@ -1022,7 +1029,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
1022
1029
|
}
|
|
1023
1030
|
|
|
1024
1031
|
// Handle UNSIGNED_SHORT data type with EXT_texture_norm16 extension
|
|
1025
|
-
if (
|
|
1032
|
+
if (getNorm16Ext() && !useHalfFloat && dataType === VtkDataTypes.UNSIGNED_SHORT) {
|
|
1026
1033
|
for (let c = 0; c < numComps; ++c) {
|
|
1027
1034
|
model.volumeInfo.scale[c] = 65535.0; // Scale to [0, 1] range
|
|
1028
1035
|
}
|
|
@@ -1112,7 +1119,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
1112
1119
|
if (model.generateMipmap) {
|
|
1113
1120
|
model.context.generateMipmap(model.target);
|
|
1114
1121
|
}
|
|
1115
|
-
model.allocatedGPUMemoryInBytes = model.width * model.height * model.depth * model.components * model._openGLRenderWindow.getDefaultTextureByteSize(dataTypeToUse,
|
|
1122
|
+
model.allocatedGPUMemoryInBytes = model.width * model.height * model.depth * model.components * model._openGLRenderWindow.getDefaultTextureByteSize(dataTypeToUse, getNorm16Ext(), publicAPI.useHalfFloat());
|
|
1116
1123
|
publicAPI.deactivate();
|
|
1117
1124
|
return true;
|
|
1118
1125
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../../macros2.js';
|
|
2
2
|
import { k as add } from '../../../Common/Core/Math/index.js';
|
|
3
|
+
import vtkBoundingBox from '../../../Common/DataModel/BoundingBox.js';
|
|
3
4
|
import vtkPointPicker from '../../../Rendering/Core/PointPicker.js';
|
|
4
5
|
|
|
5
6
|
const MAX_POINTS = 3;
|
|
@@ -8,6 +9,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
8
9
|
model._isDragging = false;
|
|
9
10
|
const picker = vtkPointPicker.newInstance();
|
|
10
11
|
picker.setPickFromList(1);
|
|
12
|
+
publicAPI.getBounds = () => model.widgetState.getHandleList().reduce((bounds, handle) => vtkBoundingBox.inflate(vtkBoundingBox.addPoint(bounds, ...handle.getOrigin()), publicAPI.getScaleInPixels() ? 0 : handle.getScale1() / 2), [...vtkBoundingBox.INIT_BOUNDS]);
|
|
11
13
|
|
|
12
14
|
// --------------------------------------------------------------------------
|
|
13
15
|
// Display 2D
|
|
@@ -2,7 +2,7 @@ import { m as macro } from '../../macros2.js';
|
|
|
2
2
|
import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
3
3
|
import vtkConvexFaceContextRepresentation from '../Representations/ConvexFaceContextRepresentation.js';
|
|
4
4
|
import widgetBehavior from './InteractiveOrientationWidget/behavior.js';
|
|
5
|
-
import {
|
|
5
|
+
import { INITIAL_POINTS, generateState } from './InteractiveOrientationWidget/state.js';
|
|
6
6
|
import { Behavior } from '../Representations/WidgetRepresentation/Constants.js';
|
|
7
7
|
import { ViewTypes } from '../Core/WidgetManager/Constants.js';
|
|
8
8
|
|
|
@@ -342,6 +342,23 @@ function widgetBehavior(publicAPI, model) {
|
|
|
342
342
|
};
|
|
343
343
|
};
|
|
344
344
|
|
|
345
|
+
/**
|
|
346
|
+
* Rotate a line by a specified angle
|
|
347
|
+
* @param {string} lineName The line name to rotate (e.g. YinX, ZinX, XinY, ZinY, XinZ, YinZ)
|
|
348
|
+
* @param {Number} radianAngle Applied angle in radian
|
|
349
|
+
*/
|
|
350
|
+
publicAPI.setViewPlane = (viewType, normal, viewUp) => {
|
|
351
|
+
let newViewUp = viewUp;
|
|
352
|
+
if (newViewUp == null) {
|
|
353
|
+
newViewUp = model.widgetState.getPlanes()[viewType].viewUp;
|
|
354
|
+
}
|
|
355
|
+
model.widgetState.getPlanes()[viewType] = {
|
|
356
|
+
normal,
|
|
357
|
+
viewUp: newViewUp
|
|
358
|
+
};
|
|
359
|
+
updateState(model.widgetState, model._factory.getScaleInPixels(), model._factory.getRotationHandlePosition());
|
|
360
|
+
};
|
|
361
|
+
|
|
345
362
|
// --------------------------------------------------------------------------
|
|
346
363
|
// initialization
|
|
347
364
|
// --------------------------------------------------------------------------
|
|
@@ -113,6 +113,7 @@ function rotateVector(vectorToBeRotated, axis, angle) {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
|
+
* Return ['X'] if there are only 1 plane defined in the widget state.
|
|
116
117
|
* Return ['X', 'Y'] if there are only 2 planes defined in the widget state.
|
|
117
118
|
* Return ['X', 'Y', 'Z'] if there are 3 planes defined in the widget state.
|
|
118
119
|
* @param {object} widgetState the state of the widget
|
|
@@ -290,6 +290,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
290
290
|
const up = model._camera.getViewUp();
|
|
291
291
|
const right = [];
|
|
292
292
|
vec3.cross(right, up, normal);
|
|
293
|
+
vtkMath.normalize(right);
|
|
294
|
+
vec3.cross(up, normal, right);
|
|
295
|
+
vtkMath.normalize(up);
|
|
293
296
|
model.shapeHandle.setUp(up);
|
|
294
297
|
model.shapeHandle.setRight(right);
|
|
295
298
|
model.shapeHandle.setDirection(normal);
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { c as createInlineWorkerFactory } from '../../../../rollup-plugin-web-worker-loader__helper__browser__createInlineWorkerFactory.js';
|
|
2
|
+
|
|
3
|
+
var WorkerFactory = createInlineWorkerFactory(/* rollup-plugin-web-worker-loader */function () {
|
|
4
|
+
(function () {
|
|
5
|
+
'__worker_loader_strict__';
|
|
6
|
+
|
|
7
|
+
var register = {exports: {}};
|
|
8
|
+
|
|
9
|
+
var _createClass$1 = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
10
|
+
|
|
11
|
+
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
|
|
13
|
+
var TinyEmitter$1 = function () {
|
|
14
|
+
function TinyEmitter() {
|
|
15
|
+
_classCallCheck$1(this, TinyEmitter);
|
|
16
|
+
|
|
17
|
+
Object.defineProperty(this, '__listeners', {
|
|
18
|
+
value: {},
|
|
19
|
+
enumerable: false,
|
|
20
|
+
writable: false
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_createClass$1(TinyEmitter, [{
|
|
25
|
+
key: 'emit',
|
|
26
|
+
value: function emit(eventName) {
|
|
27
|
+
if (!this.__listeners[eventName]) return this;
|
|
28
|
+
|
|
29
|
+
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
30
|
+
args[_key - 1] = arguments[_key];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var _iteratorNormalCompletion = true;
|
|
34
|
+
var _didIteratorError = false;
|
|
35
|
+
var _iteratorError = undefined;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
for (var _iterator = this.__listeners[eventName][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
39
|
+
var handler = _step.value;
|
|
40
|
+
|
|
41
|
+
handler.apply(undefined, args);
|
|
42
|
+
}
|
|
43
|
+
} catch (err) {
|
|
44
|
+
_didIteratorError = true;
|
|
45
|
+
_iteratorError = err;
|
|
46
|
+
} finally {
|
|
47
|
+
try {
|
|
48
|
+
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
49
|
+
_iterator.return();
|
|
50
|
+
}
|
|
51
|
+
} finally {
|
|
52
|
+
if (_didIteratorError) {
|
|
53
|
+
throw _iteratorError;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: 'once',
|
|
62
|
+
value: function once(eventName, handler) {
|
|
63
|
+
var _this = this;
|
|
64
|
+
|
|
65
|
+
var once = function once() {
|
|
66
|
+
_this.off(eventName, once);
|
|
67
|
+
handler.apply(undefined, arguments);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return this.on(eventName, once);
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
key: 'on',
|
|
74
|
+
value: function on(eventName, handler) {
|
|
75
|
+
if (!this.__listeners[eventName]) this.__listeners[eventName] = [];
|
|
76
|
+
|
|
77
|
+
this.__listeners[eventName].push(handler);
|
|
78
|
+
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
key: 'off',
|
|
83
|
+
value: function off(eventName, handler) {
|
|
84
|
+
if (handler) this.__listeners[eventName] = this.__listeners[eventName].filter(function (h) {
|
|
85
|
+
return h !== handler;
|
|
86
|
+
});else this.__listeners[eventName] = [];
|
|
87
|
+
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
}]);
|
|
91
|
+
|
|
92
|
+
return TinyEmitter;
|
|
93
|
+
}();
|
|
94
|
+
|
|
95
|
+
var tinyEmitter = TinyEmitter$1;
|
|
96
|
+
|
|
97
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
98
|
+
|
|
99
|
+
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
100
|
+
|
|
101
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
102
|
+
|
|
103
|
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
104
|
+
|
|
105
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
106
|
+
|
|
107
|
+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
108
|
+
|
|
109
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
110
|
+
|
|
111
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
112
|
+
|
|
113
|
+
var TinyEmitter = tinyEmitter;
|
|
114
|
+
|
|
115
|
+
var MESSAGE_RESULT = 0;
|
|
116
|
+
var MESSAGE_EVENT = 1;
|
|
117
|
+
|
|
118
|
+
var RESULT_ERROR = 0;
|
|
119
|
+
var RESULT_SUCCESS = 1;
|
|
120
|
+
|
|
121
|
+
var DEFAULT_HANDLER = 'main';
|
|
122
|
+
|
|
123
|
+
var isPromise = function isPromise(o) {
|
|
124
|
+
return (typeof o === 'undefined' ? 'undefined' : _typeof(o)) === 'object' && o !== null && typeof o.then === 'function' && typeof o.catch === 'function';
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
function RegisterPromise(fn) {
|
|
128
|
+
var handlers = _defineProperty({}, DEFAULT_HANDLER, fn);
|
|
129
|
+
var sendPostMessage = self.postMessage.bind(self);
|
|
130
|
+
|
|
131
|
+
var server = new (function (_TinyEmitter) {
|
|
132
|
+
_inherits(WorkerRegister, _TinyEmitter);
|
|
133
|
+
|
|
134
|
+
function WorkerRegister() {
|
|
135
|
+
_classCallCheck(this, WorkerRegister);
|
|
136
|
+
|
|
137
|
+
return _possibleConstructorReturn(this, (WorkerRegister.__proto__ || Object.getPrototypeOf(WorkerRegister)).apply(this, arguments));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
_createClass(WorkerRegister, [{
|
|
141
|
+
key: 'emit',
|
|
142
|
+
value: function emit(eventName) {
|
|
143
|
+
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
144
|
+
args[_key - 1] = arguments[_key];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (args.length == 1 && args[0] instanceof TransferableResponse) {
|
|
148
|
+
sendPostMessage({ eventName: eventName, args: args }, args[0].transferable);
|
|
149
|
+
} else {
|
|
150
|
+
sendPostMessage({ eventName: eventName, args: args });
|
|
151
|
+
}
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
}, {
|
|
155
|
+
key: 'emitLocally',
|
|
156
|
+
value: function emitLocally(eventName) {
|
|
157
|
+
var _get2;
|
|
158
|
+
|
|
159
|
+
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
160
|
+
args[_key2 - 1] = arguments[_key2];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
(_get2 = _get(WorkerRegister.prototype.__proto__ || Object.getPrototypeOf(WorkerRegister.prototype), 'emit', this)).call.apply(_get2, [this, eventName].concat(args));
|
|
164
|
+
}
|
|
165
|
+
}, {
|
|
166
|
+
key: 'operation',
|
|
167
|
+
value: function operation(name, handler) {
|
|
168
|
+
handlers[name] = handler;
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
}]);
|
|
172
|
+
|
|
173
|
+
return WorkerRegister;
|
|
174
|
+
}(TinyEmitter))();
|
|
175
|
+
|
|
176
|
+
var run = function run(messageId, payload, handlerName) {
|
|
177
|
+
|
|
178
|
+
var onSuccess = function onSuccess(result) {
|
|
179
|
+
if (result && result instanceof TransferableResponse) {
|
|
180
|
+
sendResult(messageId, RESULT_SUCCESS, result.payload, result.transferable);
|
|
181
|
+
} else {
|
|
182
|
+
sendResult(messageId, RESULT_SUCCESS, result);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
var onError = function onError(e) {
|
|
187
|
+
sendResult(messageId, RESULT_ERROR, {
|
|
188
|
+
message: e.message,
|
|
189
|
+
stack: e.stack
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
var result = runFn(messageId, payload, handlerName);
|
|
195
|
+
if (isPromise(result)) {
|
|
196
|
+
result.then(onSuccess).catch(onError);
|
|
197
|
+
} else {
|
|
198
|
+
onSuccess(result);
|
|
199
|
+
}
|
|
200
|
+
} catch (e) {
|
|
201
|
+
onError(e);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
var runFn = function runFn(messageId, payload, handlerName) {
|
|
206
|
+
var handler = handlers[handlerName || DEFAULT_HANDLER];
|
|
207
|
+
if (!handler) throw new Error('Not found handler for this request');
|
|
208
|
+
|
|
209
|
+
return handler(payload, sendEvent.bind(null, messageId));
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
var sendResult = function sendResult(messageId, success, payload) {
|
|
213
|
+
var transferable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
214
|
+
|
|
215
|
+
sendPostMessage([MESSAGE_RESULT, messageId, success, payload], transferable);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
var sendEvent = function sendEvent(messageId, eventName, payload) {
|
|
219
|
+
if (!eventName) throw new Error('eventName is required');
|
|
220
|
+
|
|
221
|
+
if (typeof eventName !== 'string') throw new Error('eventName should be string');
|
|
222
|
+
|
|
223
|
+
sendPostMessage([MESSAGE_EVENT, messageId, eventName, payload]);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
self.addEventListener('message', function (_ref) {
|
|
227
|
+
var data = _ref.data;
|
|
228
|
+
|
|
229
|
+
if (Array.isArray(data)) {
|
|
230
|
+
run.apply(undefined, _toConsumableArray(data));
|
|
231
|
+
} else if (data && data.eventName) {
|
|
232
|
+
server.emitLocally.apply(server, [data.eventName].concat(_toConsumableArray(data.args)));
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
return server;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
var TransferableResponse = function TransferableResponse(payload, transferable) {
|
|
240
|
+
_classCallCheck(this, TransferableResponse);
|
|
241
|
+
|
|
242
|
+
this.payload = payload;
|
|
243
|
+
this.transferable = transferable;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
register.exports = RegisterPromise;
|
|
247
|
+
register.exports.TransferableResponse = TransferableResponse;
|
|
248
|
+
|
|
249
|
+
var registerWebworker = register.exports;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
*
|
|
253
|
+
* @param {ArrayBuffer} imageBuffer
|
|
254
|
+
* @param {string} mimeType
|
|
255
|
+
* @param {string} channel
|
|
256
|
+
* @returns {Promise<ImageData>}
|
|
257
|
+
*/
|
|
258
|
+
registerWebworker(async _ref => {
|
|
259
|
+
let {
|
|
260
|
+
imageBuffer,
|
|
261
|
+
mimeType,
|
|
262
|
+
channel
|
|
263
|
+
} = _ref;
|
|
264
|
+
const channelsMap = {
|
|
265
|
+
r: 0,
|
|
266
|
+
g: 1,
|
|
267
|
+
b: 2
|
|
268
|
+
};
|
|
269
|
+
const blob = new Blob([imageBuffer], {
|
|
270
|
+
type: mimeType
|
|
271
|
+
});
|
|
272
|
+
const img = await createImageBitmap(blob);
|
|
273
|
+
const canvas = new OffscreenCanvas(img.width, img.height);
|
|
274
|
+
const ctx = canvas.getContext('2d');
|
|
275
|
+
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
276
|
+
const bitmap = ctx.getImageData(0, 0, img.width, img.height);
|
|
277
|
+
if (channel) {
|
|
278
|
+
const idx = channelsMap[channel];
|
|
279
|
+
for (let i = 0; i < bitmap.data.length; i += 4) {
|
|
280
|
+
const channelValue = bitmap.data[i + idx];
|
|
281
|
+
bitmap.data[i] = channelValue; // red channel
|
|
282
|
+
bitmap.data[i + 1] = channelValue; // green channel
|
|
283
|
+
bitmap.data[i + 2] = channelValue; // blue channel
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return {
|
|
288
|
+
bitmap
|
|
289
|
+
};
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
})();
|
|
293
|
+
}, null);
|
|
294
|
+
/* eslint-enable */
|
|
295
|
+
|
|
296
|
+
export { WorkerFactory as W };
|
package/index.d.ts
CHANGED
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
/// <reference path="./Common/DataModel/Triangle.d.ts" />
|
|
55
55
|
/// <reference path="./Common/Transform/LandmarkTransform.d.ts" />
|
|
56
56
|
/// <reference path="./Common/Transform/Transform.d.ts" />
|
|
57
|
+
/// <reference path="./Filters/Core/ThresholdPoints.d.ts" />
|
|
57
58
|
/// <reference path="./Filters/General/AppendPolyData.d.ts" />
|
|
58
59
|
/// <reference path="./Filters/General/ClipClosedSurface.d.ts" />
|
|
59
60
|
/// <reference path="./Filters/General/ContourLoopExtraction.d.ts" />
|
|
@@ -92,11 +93,15 @@
|
|
|
92
93
|
/// <reference path="./IO/Core/ImageStream.d.ts" />
|
|
93
94
|
/// <reference path="./IO/Core/WSLinkClient.d.ts" />
|
|
94
95
|
/// <reference path="./IO/Geometry/DracoReader.d.ts" />
|
|
96
|
+
/// <reference path="./IO/Geometry/GLTFImporter.d.ts" />
|
|
97
|
+
/// <reference path="./IO/Geometry/IFCImporter.d.ts" />
|
|
95
98
|
/// <reference path="./IO/Geometry/PLYReader.d.ts" />
|
|
96
99
|
/// <reference path="./IO/Geometry/PLYWriter.d.ts" />
|
|
97
100
|
/// <reference path="./IO/Geometry/STLReader.d.ts" />
|
|
98
101
|
/// <reference path="./IO/Geometry/STLWriter.d.ts" />
|
|
99
102
|
/// <reference path="./IO/Image/HDRReader.d.ts" />
|
|
103
|
+
/// <reference path="./IO/Image/TGAReader.d.ts" />
|
|
104
|
+
/// <reference path="./IO/Image/TIFFReader.d.ts" />
|
|
100
105
|
/// <reference path="./IO/Misc/ElevationReader.d.ts" />
|
|
101
106
|
/// <reference path="./IO/Misc/GCodeReader.d.ts" />
|
|
102
107
|
/// <reference path="./IO/Misc/ITKImageReader.d.ts" />
|
|
@@ -118,6 +123,7 @@
|
|
|
118
123
|
/// <reference path="./Interaction/Manipulators/CompositeMouseManipulator.d.ts" />
|
|
119
124
|
/// <reference path="./Interaction/Manipulators/CompositeVRManipulator.d.ts" />
|
|
120
125
|
/// <reference path="./Interaction/Manipulators/GestureCameraManipulator.d.ts" />
|
|
126
|
+
/// <reference path="./Interaction/Manipulators/KeyboardCameraManipulator.d.ts" />
|
|
121
127
|
/// <reference path="./Interaction/Manipulators/MouseBoxSelectorManipulator.d.ts" />
|
|
122
128
|
/// <reference path="./Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.d.ts" />
|
|
123
129
|
/// <reference path="./Interaction/Manipulators/MouseCameraTrackballPanManipulator.d.ts" />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitware/vtk.js",
|
|
3
|
-
"version": "33.0.0-beta.
|
|
3
|
+
"version": "33.0.0-beta.3",
|
|
4
4
|
"description": "Visualization Toolkit for the Web",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"3d",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"shelljs": "0.8.5",
|
|
44
44
|
"spark-md5": "3.0.2",
|
|
45
45
|
"stream-browserify": "3.0.0",
|
|
46
|
+
"utif": "3.1.0",
|
|
46
47
|
"webworker-promise": "0.5.0",
|
|
47
48
|
"worker-loader": "3.0.8",
|
|
48
49
|
"xmlbuilder2": "3.0.2"
|
|
@@ -52,8 +53,8 @@
|
|
|
52
53
|
"@babel/eslint-parser": "7.22.11",
|
|
53
54
|
"@babel/plugin-transform-runtime": "7.22.10",
|
|
54
55
|
"@babel/preset-env": "7.22.10",
|
|
55
|
-
"@commitlint/cli": "
|
|
56
|
-
"@commitlint/config-conventional": "
|
|
56
|
+
"@commitlint/cli": "19.7.1",
|
|
57
|
+
"@commitlint/config-conventional": "19.7.1",
|
|
57
58
|
"@mapbox/node-pre-gyp": "1.0.9",
|
|
58
59
|
"@rollup/plugin-alias": "3.1.9",
|
|
59
60
|
"@rollup/plugin-babel": "5.3.1",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"@rollup/plugin-eslint": "8.0.2",
|
|
62
63
|
"@rollup/plugin-json": "4.1.0",
|
|
63
64
|
"@rollup/plugin-node-resolve": "13.1.3",
|
|
65
|
+
"@types/node": "^22.13.1",
|
|
64
66
|
"autoprefixer": "10.4.7",
|
|
65
67
|
"babel-loader": "8.2.5",
|
|
66
68
|
"babel-plugin-istanbul": "6.1.1",
|
|
@@ -71,7 +73,7 @@
|
|
|
71
73
|
"cross-env": "7.0.3",
|
|
72
74
|
"css-loader": "6.7.1",
|
|
73
75
|
"dotenv": "16.0.1",
|
|
74
|
-
"dox": "0.
|
|
76
|
+
"dox": "1.0.0",
|
|
75
77
|
"eslint": "8.15.0",
|
|
76
78
|
"eslint-config-airbnb": "19.0.4",
|
|
77
79
|
"eslint-config-prettier": "8.5.0",
|
|
@@ -104,7 +106,7 @@
|
|
|
104
106
|
"prettier": "2.6.2",
|
|
105
107
|
"process": "0.11.10",
|
|
106
108
|
"regenerator-runtime": "0.13.9",
|
|
107
|
-
"rollup": "2.
|
|
109
|
+
"rollup": "2.79.2",
|
|
108
110
|
"rollup-plugin-auto-external": "2.0.0",
|
|
109
111
|
"rollup-plugin-copy": "3.4.0",
|
|
110
112
|
"rollup-plugin-ignore": "1.0.10",
|
|
@@ -118,14 +120,14 @@
|
|
|
118
120
|
"string-replace-loader": "3.1.0",
|
|
119
121
|
"style-loader": "3.3.1",
|
|
120
122
|
"tape": "5.5.3",
|
|
121
|
-
"webpack": "5.
|
|
123
|
+
"webpack": "5.97.1",
|
|
122
124
|
"webpack-bundle-analyzer": "4.5.0",
|
|
123
125
|
"webpack-cli": "4.9.2",
|
|
124
126
|
"webpack-dashboard": "3.3.7",
|
|
125
127
|
"webpack-dev-server": "4.9.0",
|
|
126
128
|
"webpack-merge": "5.8.0",
|
|
127
129
|
"webpack-notifier": "1.15.0",
|
|
128
|
-
"wslink": "1.
|
|
130
|
+
"wslink": "1.12.4",
|
|
129
131
|
"xml2js": "0.5.0"
|
|
130
132
|
},
|
|
131
133
|
"peerDependencies": {
|
|
@@ -141,7 +143,7 @@
|
|
|
141
143
|
"lint": "eslint Sources Examples",
|
|
142
144
|
"doc": "kw-doc -c ./Documentation/config.js",
|
|
143
145
|
"doc:www": "npm t -- --single-run && kw-doc -c ./Documentation/config.js -s",
|
|
144
|
-
"doc:
|
|
146
|
+
"doc:minified": "kw-doc -c ./Documentation/config.js -m",
|
|
145
147
|
"doc:generate-api": "node ./Documentation/generate-api-docs.js",
|
|
146
148
|
"example": "node ./Utilities/ExampleRunner/example-runner-cli.js -c ./Documentation/config.js",
|
|
147
149
|
"example:https": "node ./Utilities/ExampleRunner/example-runner-cli.js --server-type https -c ./Documentation/config.js",
|
|
@@ -149,7 +151,7 @@
|
|
|
149
151
|
"dev:esm": "npm run build:esm -- -w",
|
|
150
152
|
"dev:umd": "webpack --watch --config webpack.dev.js --progress",
|
|
151
153
|
"build": "npm run build:release",
|
|
152
|
-
"build:esm": "
|
|
154
|
+
"build:esm": "rollup -c rollup.config.js",
|
|
153
155
|
"build:umd": "webpack --config webpack.prod.js --progress",
|
|
154
156
|
"build:release": "npm run lint && concurrently \"cross-env NOLINT=1 npm run build:esm\" \"cross-env NOLINT=1 npm run build:umd\"",
|
|
155
157
|
"release:create-packages": "node ./Utilities/ci/build-npm-package.js",
|
|
@@ -162,7 +164,7 @@
|
|
|
162
164
|
"commit": "git cz",
|
|
163
165
|
"semantic-release": "semantic-release",
|
|
164
166
|
"prepare": "node ./Utilities/prepare.js",
|
|
165
|
-
"
|
|
167
|
+
"postinstall": "patch-package"
|
|
166
168
|
},
|
|
167
169
|
"config": {
|
|
168
170
|
"commitizen": {
|