@kitware/vtk.js 25.4.0 → 25.7.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.
- package/Common/Core/CellArray.d.ts +20 -8
- package/Common/Core/CellArray.js +25 -6
- package/Common/Core/DataArray.d.ts +159 -15
- package/Common/Core/DataArray.js +181 -26
- package/Common/Core/Math/index.js +1 -1
- package/Common/Core/Math.js +1 -1
- package/Common/Core/Points.d.ts +6 -5
- package/Common/Core/Points.js +8 -4
- package/Common/DataModel/AbstractPointLocator.d.ts +54 -0
- package/Common/DataModel/AbstractPointLocator.js +40 -0
- package/Common/DataModel/DataSetAttributes/FieldData.d.ts +33 -22
- package/Common/DataModel/DataSetAttributes/FieldData.js +91 -9
- package/Common/DataModel/DataSetAttributes.d.ts +44 -0
- package/Common/DataModel/DataSetAttributes.js +11 -0
- package/Common/DataModel/IncrementalOctreeNode.d.ts +282 -0
- package/Common/DataModel/IncrementalOctreeNode.js +621 -0
- package/Common/DataModel/IncrementalOctreePointLocator.d.ts +61 -0
- package/Common/DataModel/IncrementalOctreePointLocator.js +342 -0
- package/Common/DataModel/Line.js +1 -1
- package/Common/DataModel/Locator.d.ts +43 -0
- package/Common/DataModel/Locator.js +37 -0
- package/Common/DataModel/Plane.js +1 -1
- package/Common/DataModel/Polygon/Constants.js +12 -0
- package/Common/DataModel/Polygon.d.ts +38 -4
- package/Common/DataModel/Polygon.js +210 -6
- package/Common/DataModel/Quad/Constants.js +9 -0
- package/Common/DataModel/Quad.d.ts +91 -0
- package/Common/DataModel/Quad.js +235 -0
- package/Common/DataModel/Triangle.d.ts +106 -81
- package/Common/DataModel/Triangle.js +1 -1
- package/Common/Transform/LandmarkTransform.js +1 -1
- package/Filters/Core/PolyDataNormals.js +1 -1
- package/Filters/General/ClipClosedSurface/Constants.js +10 -0
- package/Filters/General/ClipClosedSurface/ccsEdgeLocator.js +40 -0
- package/Filters/General/ClipClosedSurface.d.ts +95 -0
- package/Filters/General/ClipClosedSurface.js +970 -0
- package/Filters/General/ContourTriangulator/Constants.js +6 -0
- package/Filters/General/ContourTriangulator/helper.js +1951 -0
- package/Filters/General/ContourTriangulator.d.ts +122 -0
- package/Filters/General/ContourTriangulator.js +200 -0
- package/Filters/General/ImageMarchingCubes.js +1 -1
- package/Filters/General/MoleculeToRepresentation.js +1 -1
- package/Filters/General/OBBTree.js +1 -1
- package/Filters/General/TubeFilter.js +1 -1
- package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
- package/Filters/Sources/PlaneSource.js +1 -1
- package/Filters/Texture/TextureMapToPlane.js +1 -1
- package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +4 -8
- package/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +6 -14
- package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +60 -57
- package/IO/Core/ZipMultiDataSetReader.js +19 -29
- package/IO/Core/ZipMultiDataSetWriter.js +7 -23
- package/IO/Misc/SkyboxReader.js +67 -75
- package/IO/XML/XMLReader.js +2 -2
- package/IO/XML/XMLWriter.js +2 -2
- package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
- package/Interaction/Style/InteractorStyleMPRSlice.js +1 -1
- package/Interaction/Style/InteractorStyleTrackballCamera.js +16 -0
- package/Proxy/Core/View2DProxy.js +1 -1
- package/Rendering/Core/Actor2D.d.ts +12 -6
- package/Rendering/Core/Camera.js +1 -1
- package/Rendering/Core/CellPicker.js +3 -2
- package/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts +24 -0
- package/Rendering/Core/Light.js +1 -1
- package/Rendering/Core/Picker.js +1 -1
- package/Rendering/Core/Property2D.d.ts +1 -1
- package/Rendering/Core/VolumeProperty.d.ts +4 -4
- package/Rendering/Core/VolumeProperty.js +1 -1
- package/Rendering/OpenGL/PolyDataMapper.js +1 -1
- package/Rendering/OpenGL/RenderWindow/ContextProxy.js +65 -0
- package/Rendering/OpenGL/RenderWindow.js +3 -1
- package/Rendering/WebGPU/BufferManager.js +1 -1
- package/Rendering/WebGPU/ForwardPass.js +93 -15
- package/Rendering/WebGPU/OpaquePass.js +1 -1
- package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +1 -1
- package/Rendering/WebGPU/RenderEncoder.js +9 -5
- package/Rendering/WebGPU/RenderWindow.js +15 -13
- package/Rendering/WebGPU/TextureView.js +15 -2
- package/Rendering/WebGPU/VolumePass.js +1 -1
- package/Widgets/Core/StateBuilder/orientationMixin.js +1 -1
- package/Widgets/Manipulators/LineManipulator.js +1 -1
- package/Widgets/Manipulators/TrackballManipulator.js +1 -1
- package/Widgets/Representations/ResliceCursorContextRepresentation.js +1 -1
- package/Widgets/Widgets3D/LineWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +1 -1
- package/index.d.ts +8 -0
- package/index.js +0 -2
- package/package.json +3 -4
- package/ThirdParty/index.js +0 -9
|
@@ -218,6 +218,10 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) {
|
|
|
218
218
|
|
|
219
219
|
|
|
220
220
|
publicAPI.handleMouseRotate = function (renderer, position) {
|
|
221
|
+
if (!model.previousPosition) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
221
225
|
var rwi = model._interactor;
|
|
222
226
|
var dx = position.x - model.previousPosition.x;
|
|
223
227
|
var dy = position.y - model.previousPosition.y;
|
|
@@ -251,6 +255,10 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) {
|
|
|
251
255
|
|
|
252
256
|
|
|
253
257
|
publicAPI.handleMouseSpin = function (renderer, position) {
|
|
258
|
+
if (!model.previousPosition) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
254
262
|
var rwi = model._interactor;
|
|
255
263
|
var camera = renderer.getActiveCamera();
|
|
256
264
|
var center = rwi.getView().getViewportCenter(renderer);
|
|
@@ -265,6 +273,10 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) {
|
|
|
265
273
|
|
|
266
274
|
|
|
267
275
|
publicAPI.handleMousePan = function (renderer, position) {
|
|
276
|
+
if (!model.previousPosition) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
268
280
|
var camera = renderer.getActiveCamera(); // Calculate the focal depth since we'll be using it a lot
|
|
269
281
|
|
|
270
282
|
var viewFocus = camera.getFocalPoint();
|
|
@@ -291,6 +303,10 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) {
|
|
|
291
303
|
|
|
292
304
|
|
|
293
305
|
publicAPI.handleMouseDolly = function (renderer, position) {
|
|
306
|
+
if (!model.previousPosition) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
294
310
|
var dy = position.y - model.previousPosition.y;
|
|
295
311
|
var rwi = model._interactor;
|
|
296
312
|
var center = rwi.getView().getViewportCenter(renderer);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import macro from '../../macros.js';
|
|
2
2
|
import vtkMouseRangeManipulator from '../../Interaction/Manipulators/MouseRangeManipulator.js';
|
|
3
3
|
import vtkViewProxy from './ViewProxy.js';
|
|
4
|
-
import {
|
|
4
|
+
import { k as cross, F as getMajorAxisIndex } from '../../Common/Core/Math/index.js';
|
|
5
5
|
|
|
6
6
|
var DEFAULT_STEP_WIDTH = 512;
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import vtkProp, { IPropInitialValues } from './Prop';
|
|
2
2
|
import vtkCoordinate from './Coordinate';
|
|
3
3
|
import vtkMapper from './Mapper';
|
|
4
|
-
import
|
|
4
|
+
import vtkProperty2D, { IProperty2DInitialValues } from './Property2D';
|
|
5
5
|
import { Bounds } from './../../types';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -9,7 +9,7 @@ import { Bounds } from './../../types';
|
|
|
9
9
|
*/
|
|
10
10
|
export interface IActor2DInitialValues extends IPropInitialValues {
|
|
11
11
|
mapper?: vtkMapper;
|
|
12
|
-
property?:
|
|
12
|
+
property?: vtkProperty2D;
|
|
13
13
|
layerNumber?: number;
|
|
14
14
|
positionCoordinate?: vtkCoordinate;
|
|
15
15
|
positionCoordinate2?: vtkCoordinate;
|
|
@@ -31,12 +31,18 @@ export interface vtkActor2D extends vtkProp {
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Return the property object that controls this actors surface
|
|
34
|
-
* properties. This should be an instance of a
|
|
34
|
+
* properties. This should be an instance of a vtkProperty2D object. Every
|
|
35
35
|
* actor must have a property associated with it. If one isn’t specified,
|
|
36
36
|
* then one will be generated automatically. Multiple actors can share one
|
|
37
37
|
* property object.
|
|
38
38
|
*/
|
|
39
|
-
getProperty():
|
|
39
|
+
getProperty(): vtkProperty2D;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Create a new property suitable for use with this type of Actor.
|
|
43
|
+
* @param {IProperty2DInitialValues} [initialValues] (default: {})
|
|
44
|
+
*/
|
|
45
|
+
makeProperty(initialValues?: IProperty2DInitialValues): vtkProperty2D;
|
|
40
46
|
|
|
41
47
|
/**
|
|
42
48
|
*
|
|
@@ -112,8 +118,8 @@ export function newInstance(initialValues?: IActor2DInitialValues): vtkActor2D;
|
|
|
112
118
|
* vtkProp. The actor also has scaling and maintains a reference to the
|
|
113
119
|
* defining geometry (i.e., the mapper), rendering properties, and possibly a
|
|
114
120
|
* texture map.
|
|
115
|
-
* @see [
|
|
116
|
-
* @see [
|
|
121
|
+
* @see [vtkMapper2D](./Rendering_Core_Mapper2D.html)
|
|
122
|
+
* @see [vtkProperty2D](./Rendering_Core_Property2D.html)
|
|
117
123
|
*/
|
|
118
124
|
export declare const vtkActor2D: {
|
|
119
125
|
newInstance: typeof newInstance,
|
package/Rendering/Core/Camera.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
2
|
import { mat4, vec4, vec3, quat } from 'gl-matrix';
|
|
3
3
|
import macro from '../../macros.js';
|
|
4
|
-
import { r as radiansFromDegrees,
|
|
4
|
+
import { r as radiansFromDegrees, l as add, k as cross } from '../../Common/Core/Math/index.js';
|
|
5
5
|
|
|
6
6
|
var vtkDebugMacro = macro.vtkDebugMacro;
|
|
7
7
|
/* eslint-disable new-cap */
|
|
@@ -5,7 +5,8 @@ import vtkLine from '../../Common/DataModel/Line.js';
|
|
|
5
5
|
import vtkPicker from './Picker.js';
|
|
6
6
|
import vtkPolyLine from '../../Common/DataModel/PolyLine.js';
|
|
7
7
|
import vtkTriangle from '../../Common/DataModel/Triangle.js';
|
|
8
|
-
import
|
|
8
|
+
import vtkQuad from '../../Common/DataModel/Quad.js';
|
|
9
|
+
import { m as normalize } from '../../Common/Core/Math/index.js';
|
|
9
10
|
import { CellType } from '../../Common/DataModel/CellTypes/Constants.js';
|
|
10
11
|
import { vec3 } from 'gl-matrix';
|
|
11
12
|
|
|
@@ -18,7 +19,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
18
19
|
function createCellMap() {
|
|
19
20
|
var _ref;
|
|
20
21
|
|
|
21
|
-
return _ref = {}, _defineProperty(_ref, CellType.VTK_LINE, vtkLine.newInstance()), _defineProperty(_ref, CellType.VTK_POLY_LINE, vtkPolyLine.newInstance()), _defineProperty(_ref, CellType.VTK_TRIANGLE, vtkTriangle.newInstance()), _ref;
|
|
22
|
+
return _ref = {}, _defineProperty(_ref, CellType.VTK_LINE, vtkLine.newInstance()), _defineProperty(_ref, CellType.VTK_POLY_LINE, vtkPolyLine.newInstance()), _defineProperty(_ref, CellType.VTK_TRIANGLE, vtkTriangle.newInstance()), _defineProperty(_ref, CellType.VTK_QUAD, vtkQuad.newInstance()), _ref;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
function clipLineWithPlane(mapper, matrix, p1, p2) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vtkColorMaps represents a global registry of preset color maps.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Vector3 } from '../../../types';
|
|
6
|
+
|
|
7
|
+
export interface IColorMapPreset {
|
|
8
|
+
Name: string;
|
|
9
|
+
Creator?: string;
|
|
10
|
+
ColorSpace?: string;
|
|
11
|
+
NanColor?: Vector3;
|
|
12
|
+
RGBPoints: number[];
|
|
13
|
+
IndexedColors?: number[];
|
|
14
|
+
Annotations?: (number | string)[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export declare const vtkColorMaps: {
|
|
18
|
+
addPreset(preset: IColorMapPreset): void;
|
|
19
|
+
removePresetByName(name: string): void;
|
|
20
|
+
getPresetByName(name: string): IColorMapPreset;
|
|
21
|
+
rgbPresetNames: string[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default vtkColorMaps;
|
package/Rendering/Core/Light.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import macro from '../../macros.js';
|
|
2
|
-
import {
|
|
2
|
+
import { m as normalize, r as radiansFromDegrees } from '../../Common/Core/Math/index.js';
|
|
3
3
|
import { vec3 } from 'gl-matrix';
|
|
4
4
|
|
|
5
5
|
var LIGHT_TYPES = ['HeadLight', 'CameraLight', 'SceneLight']; // ----------------------------------------------------------------------------
|
package/Rendering/Core/Picker.js
CHANGED
|
@@ -2,7 +2,7 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
2
2
|
import macro from '../../macros.js';
|
|
3
3
|
import vtkAbstractPicker from './AbstractPicker.js';
|
|
4
4
|
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
5
|
-
import { d as dot,
|
|
5
|
+
import { d as dot, m as normalize, n as norm, f as distance2BetweenPoints } from '../../Common/Core/Math/index.js';
|
|
6
6
|
import { mat4, vec4 } from 'gl-matrix';
|
|
7
7
|
|
|
8
8
|
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; }
|
|
@@ -2,7 +2,7 @@ import { vtkObject } from './../../interfaces';
|
|
|
2
2
|
import { RGBColor } from './../../types';
|
|
3
3
|
import { DisplayLocation } from './Property2D/Constants';
|
|
4
4
|
|
|
5
|
-
interface IProperty2DInitialValues{
|
|
5
|
+
export interface IProperty2DInitialValues{
|
|
6
6
|
color?: RGBColor;
|
|
7
7
|
opacity?: number;
|
|
8
8
|
pointSize?: number;
|
|
@@ -5,7 +5,7 @@ import { InterpolationType, OpacityMode } from './VolumeProperty/Constants';
|
|
|
5
5
|
|
|
6
6
|
export interface IVolumePropertyInitialValues {
|
|
7
7
|
independentComponents?: boolean;
|
|
8
|
-
shade?:
|
|
8
|
+
shade?: boolean;
|
|
9
9
|
ambient?: number;
|
|
10
10
|
diffuse?: number;
|
|
11
11
|
specular?: number;
|
|
@@ -111,7 +111,7 @@ export interface vtkVolumeProperty extends vtkObject {
|
|
|
111
111
|
/**
|
|
112
112
|
* Get the shading of a volume.
|
|
113
113
|
*/
|
|
114
|
-
getShade():
|
|
114
|
+
getShade(): boolean;
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
*
|
|
@@ -236,9 +236,9 @@ export interface vtkVolumeProperty extends vtkObject {
|
|
|
236
236
|
* turning shading off is generally the same as setting ambient=1,
|
|
237
237
|
* diffuse=0, specular=0. Shading can be independently turned on/off per
|
|
238
238
|
* component.
|
|
239
|
-
* @param {
|
|
239
|
+
* @param {Boolean} shade
|
|
240
240
|
*/
|
|
241
|
-
setShade(shade:
|
|
241
|
+
setShade(shade: boolean): boolean;
|
|
242
242
|
|
|
243
243
|
/**
|
|
244
244
|
*
|
|
@@ -3,7 +3,7 @@ import { mat3, mat4, vec3 } from 'gl-matrix';
|
|
|
3
3
|
import { newInstance as newInstance$1, setGet, obj, vtkErrorMacro as vtkErrorMacro$1 } from '../../macros.js';
|
|
4
4
|
import vtkHelper from './Helper.js';
|
|
5
5
|
import vtkMapper from '../Core/Mapper.js';
|
|
6
|
-
import {
|
|
6
|
+
import { m as normalize, u as uninitializeBounds } from '../../Common/Core/Math/index.js';
|
|
7
7
|
import vtkOpenGLTexture from './Texture.js';
|
|
8
8
|
import vtkProp from '../Core/Prop.js';
|
|
9
9
|
import vtkProperty from '../Core/Property.js';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
function createContextProxyHandler() {
|
|
2
|
+
var cache = new Map();
|
|
3
|
+
var getParameterHandler = {
|
|
4
|
+
apply: function apply(target, gl, args) {
|
|
5
|
+
if (cache.has(args[0])) {
|
|
6
|
+
return cache.get(args[0]);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return target.apply(gl, args);
|
|
10
|
+
}
|
|
11
|
+
}; // only supports single-value setters
|
|
12
|
+
|
|
13
|
+
function cachedSetterHandler(key) {
|
|
14
|
+
return {
|
|
15
|
+
apply: function apply(target, gl, args) {
|
|
16
|
+
cache.set(key, args[0]);
|
|
17
|
+
return target.apply(gl, args);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
} // When a property is accessed on the webgl context proxy,
|
|
21
|
+
// it's accessed is intercepted. If the property name matches
|
|
22
|
+
// any of the keys of `propHandlers`, then that handler is called
|
|
23
|
+
// with the following arguments: (gl, prop, receiver, propValue)
|
|
24
|
+
// - gl (WebGL2RenderingContext): the underlying webgl context
|
|
25
|
+
// - propName (string): the property name
|
|
26
|
+
// - receiver (Proxy): the webgl context proxy
|
|
27
|
+
// - propValue (unknown): the value of `gl[propName]`
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var propHandlers = Object.create(null); // Sets getParameter(property) as a cached getter proxy.
|
|
31
|
+
// propValue.bind(gl) is to avoid Illegal Invocation errors.
|
|
32
|
+
|
|
33
|
+
propHandlers.getParameter = function (gl, prop, receiver, propValue) {
|
|
34
|
+
return new Proxy(propValue.bind(gl), getParameterHandler);
|
|
35
|
+
}; // Sets depthMask(flag) as a cached setter proxy.
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
propHandlers.depthMask = function (gl, prop, receiver, propValue) {
|
|
39
|
+
return new Proxy(propValue.bind(gl), cachedSetterHandler(gl.DEPTH_WRITEMASK));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
get: function get(gl, prop, receiver) {
|
|
44
|
+
var value = Reflect.get(gl, prop, receiver);
|
|
45
|
+
|
|
46
|
+
if (value instanceof Function) {
|
|
47
|
+
// prevents Illegal Invocation errors
|
|
48
|
+
value = value.bind(gl);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var propHandler = propHandlers[prop];
|
|
52
|
+
|
|
53
|
+
if (propHandler) {
|
|
54
|
+
return propHandler(gl, prop, receiver, value);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
var ContextProxy = {
|
|
62
|
+
createContextProxyHandler: createContextProxyHandler
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export { createContextProxyHandler, ContextProxy as default };
|
|
@@ -12,6 +12,7 @@ import vtkTextureUnitManager from './TextureUnitManager.js';
|
|
|
12
12
|
import vtkViewNodeFactory from './ViewNodeFactory.js';
|
|
13
13
|
import vtkRenderPass from '../SceneGraph/RenderPass.js';
|
|
14
14
|
import vtkRenderWindowViewNode from '../SceneGraph/RenderWindowViewNode.js';
|
|
15
|
+
import { createContextProxyHandler } from './RenderWindow/ContextProxy.js';
|
|
15
16
|
|
|
16
17
|
var vtkDebugMacro = macro.vtkDebugMacro,
|
|
17
18
|
vtkErrorMacro = macro.vtkErrorMacro;
|
|
@@ -84,6 +85,7 @@ function popMonitorGLContextCount(cb) {
|
|
|
84
85
|
function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
85
86
|
// Set our className
|
|
86
87
|
model.classHierarchy.push('vtkOpenGLRenderWindow');
|
|
88
|
+
var cachingContextHandler = createContextProxyHandler();
|
|
87
89
|
|
|
88
90
|
publicAPI.getViewNodeFactory = function () {
|
|
89
91
|
return model.myFactory;
|
|
@@ -256,7 +258,7 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
|
256
258
|
result = model.canvas.getContext('webgl', options) || model.canvas.getContext('experimental-webgl', options);
|
|
257
259
|
}
|
|
258
260
|
|
|
259
|
-
return result;
|
|
261
|
+
return new Proxy(result, cachingContextHandler);
|
|
260
262
|
}; // Request an XR session on the user device with WebXR,
|
|
261
263
|
// typically in response to a user request such as a button press
|
|
262
264
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import { newInstance as newInstance$1, obj, setGet, vtkErrorMacro as vtkErrorMacro$1, newTypedArray } from '../../macros.js';
|
|
3
|
-
import {
|
|
3
|
+
import { k as cross, m as normalize } from '../../Common/Core/Math/index.js';
|
|
4
4
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
5
5
|
import vtkWebGPUBuffer from './Buffer.js';
|
|
6
6
|
import vtkWebGPUIndexBuffer from './IndexBuffer.js';
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import macro from '../../macros.js';
|
|
2
|
+
import vtkWebGPUFullScreenQuad from './FullScreenQuad.js';
|
|
2
3
|
import vtkWebGPUOpaquePass from './OpaquePass.js';
|
|
3
4
|
import vtkWebGPUOrderIndepenentTranslucentPass from './OrderIndependentTranslucentPass.js';
|
|
5
|
+
import vtkWebGPURenderEncoder from './RenderEncoder.js';
|
|
4
6
|
import vtkWebGPUVolumePass from './VolumePass.js';
|
|
5
7
|
import vtkRenderPass from '../SceneGraph/RenderPass.js';
|
|
8
|
+
import vtkWebGPUSampler from './Sampler.js';
|
|
9
|
+
import vtkWebGPUTextureView from './TextureView.js';
|
|
10
|
+
|
|
11
|
+
var finalBlitFragTemplate = "\n//VTK::Mapper::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::IOStructs::Dec\n\n@fragment\nfn main(\n//VTK::IOStructs::Input\n)\n//VTK::IOStructs::Output\n{\n var output: fragmentOutput;\n\n var computedColor: vec4<f32> = clamp(textureSampleLevel(opaquePassColorTexture, finalPassSampler, input.tcoordVS, 0),vec4<f32>(0.0),vec4<f32>(1.0));\n\n //VTK::RenderEncoder::Impl\n return output;\n}\n"; // ----------------------------------------------------------------------------
|
|
6
12
|
|
|
7
13
|
function vtkForwardPass(publicAPI, model) {
|
|
8
14
|
// Set our className
|
|
@@ -69,24 +75,96 @@ function vtkForwardPass(publicAPI, model) {
|
|
|
69
75
|
model.volumePass.setDepthTextureView(model.opaquePass.getDepthTextureView());
|
|
70
76
|
model.volumePass.setVolumes(model.volumes);
|
|
71
77
|
model.volumePass.traverse(renNode, viewNode);
|
|
72
|
-
}
|
|
78
|
+
} // blit the result into the swap chain
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
publicAPI.finalPass(viewNode, renNode);
|
|
73
82
|
}
|
|
74
83
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
publicAPI.finalPass = function (viewNode, renNode) {
|
|
88
|
+
if (!model._finalBlitEncoder) {
|
|
89
|
+
publicAPI.createFinalBlitEncoder(viewNode);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
model._finalBlitOutputTextureView.createFromTextureHandle(viewNode.getCurrentTexture(), {
|
|
93
|
+
depth: 1,
|
|
94
|
+
format: viewNode.getPresentationFormat()
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
model._finalBlitEncoder.attachTextureViews();
|
|
98
|
+
|
|
99
|
+
model._finalBlitEncoder.begin(viewNode.getCommandEncoder());
|
|
100
|
+
|
|
101
|
+
renNode.scissorAndViewport(model._finalBlitEncoder);
|
|
102
|
+
|
|
103
|
+
model._fullScreenQuad.prepareAndDraw(model._finalBlitEncoder);
|
|
104
|
+
|
|
105
|
+
model._finalBlitEncoder.end();
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
publicAPI.createFinalBlitEncoder = function (viewNode) {
|
|
109
|
+
model._finalBlitEncoder = vtkWebGPURenderEncoder.newInstance({
|
|
110
|
+
label: 'forwardPassBlit'
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
model._finalBlitEncoder.setDescription({
|
|
114
|
+
colorAttachments: [{
|
|
115
|
+
view: null,
|
|
116
|
+
loadOp: 'load',
|
|
117
|
+
storeOp: 'store'
|
|
118
|
+
}]
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
model._finalBlitEncoder.setPipelineHash('fpf');
|
|
122
|
+
|
|
123
|
+
model._finalBlitEncoder.setPipelineSettings({
|
|
124
|
+
primitive: {
|
|
125
|
+
cullMode: 'none'
|
|
126
|
+
},
|
|
127
|
+
fragment: {
|
|
128
|
+
targets: [{
|
|
129
|
+
format: viewNode.getPresentationFormat(),
|
|
130
|
+
blend: {
|
|
131
|
+
color: {
|
|
132
|
+
srcFactor: 'src-alpha',
|
|
133
|
+
dstFactor: 'one-minus-src-alpha'
|
|
134
|
+
},
|
|
135
|
+
alpha: {
|
|
136
|
+
srcfactor: 'one',
|
|
137
|
+
dstFactor: 'one-minus-src-alpha'
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}]
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
model._fsqSampler = vtkWebGPUSampler.newInstance({
|
|
145
|
+
label: 'finalPassSampler'
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
model._fsqSampler.create(viewNode.getDevice(), {
|
|
149
|
+
minFilter: 'linear',
|
|
150
|
+
magFilter: 'linear'
|
|
89
151
|
});
|
|
152
|
+
|
|
153
|
+
model._fullScreenQuad = vtkWebGPUFullScreenQuad.newInstance();
|
|
154
|
+
|
|
155
|
+
model._fullScreenQuad.setDevice(viewNode.getDevice());
|
|
156
|
+
|
|
157
|
+
model._fullScreenQuad.setPipelineHash('fpfsq');
|
|
158
|
+
|
|
159
|
+
model._fullScreenQuad.setTextureViews([model.opaquePass.getColorTextureView()]);
|
|
160
|
+
|
|
161
|
+
model._fullScreenQuad.setAdditionalBindables([model._fsqSampler]);
|
|
162
|
+
|
|
163
|
+
model._fullScreenQuad.setFragmentShaderTemplate(finalBlitFragTemplate);
|
|
164
|
+
|
|
165
|
+
model._finalBlitOutputTextureView = vtkWebGPUTextureView.newInstance();
|
|
166
|
+
|
|
167
|
+
model._finalBlitEncoder.setColorTextureView(0, model._finalBlitOutputTextureView);
|
|
90
168
|
};
|
|
91
169
|
|
|
92
170
|
publicAPI.incrementOpaqueActorCount = function () {
|
|
@@ -51,9 +51,11 @@ function vtkWebGPURenderEncoder(publicAPI, model) {
|
|
|
51
51
|
console.trace();
|
|
52
52
|
} else {
|
|
53
53
|
for (var i = 0; i < model.colorTextureViews.length; i++) {
|
|
54
|
-
var
|
|
54
|
+
var _model$colorTextureVi;
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
var fmt = (_model$colorTextureVi = model.colorTextureViews[i].getTexture()) === null || _model$colorTextureVi === void 0 ? void 0 : _model$colorTextureVi.getFormat();
|
|
57
|
+
|
|
58
|
+
if (fmt && fmt !== pd.fragment.targets[i].format) {
|
|
57
59
|
console.log("mismatched attachments for attachment ".concat(i, " on pipeline ").concat(pd.fragment.targets[i].format, " while encoder has ").concat(fmt));
|
|
58
60
|
console.trace();
|
|
59
61
|
}
|
|
@@ -65,9 +67,11 @@ function vtkWebGPURenderEncoder(publicAPI, model) {
|
|
|
65
67
|
console.log('mismatched depth attachments');
|
|
66
68
|
console.trace();
|
|
67
69
|
} else if (model.depthTextureView) {
|
|
68
|
-
var
|
|
70
|
+
var _model$depthTextureVi;
|
|
71
|
+
|
|
72
|
+
var dfmt = (_model$depthTextureVi = model.depthTextureView.getTexture()) === null || _model$depthTextureVi === void 0 ? void 0 : _model$depthTextureVi.getFormat();
|
|
69
73
|
|
|
70
|
-
if (dfmt !== pd.depthStencil.format) {
|
|
74
|
+
if (dfmt && dfmt !== pd.depthStencil.format) {
|
|
71
75
|
console.log("mismatched depth attachments on pipeline ".concat(pd.depthStencil.format, " while encoder has ").concat(dfmt));
|
|
72
76
|
console.trace();
|
|
73
77
|
}
|
|
@@ -202,7 +206,7 @@ function extend(publicAPI, model) {
|
|
|
202
206
|
},
|
|
203
207
|
fragment: {
|
|
204
208
|
targets: [{
|
|
205
|
-
format: '
|
|
209
|
+
format: 'rgba16float',
|
|
206
210
|
blend: {
|
|
207
211
|
color: {
|
|
208
212
|
srcFactor: 'src-alpha',
|
|
@@ -9,6 +9,7 @@ import vtkWebGPUHardwareSelector from './HardwareSelector.js';
|
|
|
9
9
|
import vtkWebGPUViewNodeFactory from './ViewNodeFactory.js';
|
|
10
10
|
import vtkRenderPass from '../SceneGraph/RenderPass.js';
|
|
11
11
|
import vtkRenderWindowViewNode from '../SceneGraph/RenderWindowViewNode.js';
|
|
12
|
+
import HalfFloat from '../../Common/Core/HalfFloat.js';
|
|
12
13
|
|
|
13
14
|
var vtkErrorMacro = macro.vtkErrorMacro; // const IS_CHROME = navigator.userAgent.indexOf('Chrome') !== -1;
|
|
14
15
|
|
|
@@ -67,14 +68,14 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
67
68
|
publicAPI.recreateSwapChain = function () {
|
|
68
69
|
if (model.context) {
|
|
69
70
|
model.context.unconfigure();
|
|
70
|
-
|
|
71
|
+
model.presentationFormat = navigator.gpu.getPreferredCanvasFormat(model.adapter);
|
|
71
72
|
/* eslint-disable no-undef */
|
|
72
73
|
|
|
73
74
|
/* eslint-disable no-bitwise */
|
|
74
75
|
|
|
75
76
|
model.context.configure({
|
|
76
77
|
device: model.device.getHandle(),
|
|
77
|
-
format: presentationFormat,
|
|
78
|
+
format: model.presentationFormat,
|
|
78
79
|
alphaMode: 'premultiplied',
|
|
79
80
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_DST,
|
|
80
81
|
width: model.size[0],
|
|
@@ -545,10 +546,10 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
545
546
|
result = {
|
|
546
547
|
width: texture.getWidth(),
|
|
547
548
|
height: texture.getHeight()
|
|
548
|
-
}; // must be a multiple of 256 bytes, so
|
|
549
|
+
}; // must be a multiple of 256 bytes, so 32 texels with rgba16
|
|
549
550
|
|
|
550
|
-
result.colorBufferWidth =
|
|
551
|
-
result.colorBufferSizeInBytes = result.colorBufferWidth * result.height *
|
|
551
|
+
result.colorBufferWidth = 32 * Math.floor((result.width + 31) / 32);
|
|
552
|
+
result.colorBufferSizeInBytes = result.colorBufferWidth * result.height * 8;
|
|
552
553
|
colorBuffer = vtkWebGPUBuffer.newInstance();
|
|
553
554
|
colorBuffer.setDevice(device);
|
|
554
555
|
/* eslint-disable no-bitwise */
|
|
@@ -565,7 +566,7 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
565
566
|
texture: texture.getHandle()
|
|
566
567
|
}, {
|
|
567
568
|
buffer: colorBuffer.getHandle(),
|
|
568
|
-
bytesPerRow:
|
|
569
|
+
bytesPerRow: 8 * result.colorBufferWidth,
|
|
569
570
|
rowsPerImage: result.height
|
|
570
571
|
}, {
|
|
571
572
|
width: result.width,
|
|
@@ -581,7 +582,7 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
581
582
|
|
|
582
583
|
case 14:
|
|
583
584
|
/* eslint-enable no-undef */
|
|
584
|
-
result.colorValues = new
|
|
585
|
+
result.colorValues = new Uint16Array(colorBuffer.getMappedRange().slice());
|
|
585
586
|
colorBuffer.unmap(); // repack the array
|
|
586
587
|
|
|
587
588
|
tmparray = new Uint8ClampedArray(result.height * result.width * 4);
|
|
@@ -590,10 +591,10 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
590
591
|
for (x = 0; x < result.width; x++) {
|
|
591
592
|
doffset = (y * result.width + x) * 4;
|
|
592
593
|
soffset = (y * result.colorBufferWidth + x) * 4;
|
|
593
|
-
tmparray[doffset] = result.colorValues[soffset
|
|
594
|
-
tmparray[doffset + 1] = result.colorValues[soffset + 1];
|
|
595
|
-
tmparray[doffset + 2] = result.colorValues[soffset];
|
|
596
|
-
tmparray[doffset + 3] = result.colorValues[soffset + 3];
|
|
594
|
+
tmparray[doffset] = 255.0 * HalfFloat.fromHalf(result.colorValues[soffset]);
|
|
595
|
+
tmparray[doffset + 1] = 255.0 * HalfFloat.fromHalf(result.colorValues[soffset + 1]);
|
|
596
|
+
tmparray[doffset + 2] = 255.0 * HalfFloat.fromHalf(result.colorValues[soffset + 2]);
|
|
597
|
+
tmparray[doffset + 3] = 255.0 * HalfFloat.fromHalf(result.colorValues[soffset + 3]);
|
|
597
598
|
}
|
|
598
599
|
}
|
|
599
600
|
|
|
@@ -635,7 +636,8 @@ var DEFAULT_VALUES = {
|
|
|
635
636
|
useOffScreen: false,
|
|
636
637
|
useBackgroundImage: false,
|
|
637
638
|
nextPropID: 1,
|
|
638
|
-
xrSupported: false
|
|
639
|
+
xrSupported: false,
|
|
640
|
+
presentationFormat: null
|
|
639
641
|
}; // ----------------------------------------------------------------------------
|
|
640
642
|
|
|
641
643
|
function extend(publicAPI, model) {
|
|
@@ -671,7 +673,7 @@ function extend(publicAPI, model) {
|
|
|
671
673
|
macro.event(publicAPI, model, 'imageReady');
|
|
672
674
|
macro.event(publicAPI, model, 'initialized'); // Build VTK API
|
|
673
675
|
|
|
674
|
-
macro.get(publicAPI, model, ['commandEncoder', 'device', 'useBackgroundImage', 'xrSupported']);
|
|
676
|
+
macro.get(publicAPI, model, ['commandEncoder', 'device', 'presentationFormat', 'useBackgroundImage', 'xrSupported']);
|
|
675
677
|
macro.setGet(publicAPI, model, ['initialized', 'context', 'canvas', 'device', 'renderPasses', 'notifyStartCaptureImage', 'cursor', 'useOffScreen']);
|
|
676
678
|
macro.setGetArray(publicAPI, model, ['size'], 2); // Object methods
|
|
677
679
|
|
|
@@ -23,6 +23,19 @@ function vtkWebGPUTextureView(publicAPI, model) {
|
|
|
23
23
|
model.bindGroupLayoutEntry.texture.sampleType = tDetails.sampleType;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
publicAPI.createFromTextureHandle = function (textureHandle, options) {
|
|
27
|
+
model.texture = null;
|
|
28
|
+
model.options = options;
|
|
29
|
+
model.options.dimension = model.options.dimension || '2d';
|
|
30
|
+
model.options.label = model.label;
|
|
31
|
+
model.textureHandle = textureHandle;
|
|
32
|
+
model.handle = model.textureHandle.createView(model.options);
|
|
33
|
+
model.bindGroupLayoutEntry.texture.viewDimension = model.options.dimension;
|
|
34
|
+
var tDetails = vtkWebGPUTypes.getDetailsFromTextureFormat(options.format);
|
|
35
|
+
model.bindGroupLayoutEntry.texture.sampleType = tDetails.sampleType;
|
|
36
|
+
model.bindGroupTime.modified();
|
|
37
|
+
};
|
|
38
|
+
|
|
26
39
|
publicAPI.getBindGroupEntry = function () {
|
|
27
40
|
var foo = {
|
|
28
41
|
resource: publicAPI.getHandle()
|
|
@@ -58,7 +71,7 @@ function vtkWebGPUTextureView(publicAPI, model) {
|
|
|
58
71
|
|
|
59
72
|
publicAPI.getBindGroupTime = function () {
|
|
60
73
|
// check if the handle changed
|
|
61
|
-
if (model.texture.getHandle() !== model.textureHandle) {
|
|
74
|
+
if (model.texture && model.texture.getHandle() !== model.textureHandle) {
|
|
62
75
|
model.textureHandle = model.texture.getHandle();
|
|
63
76
|
model.handle = model.textureHandle.createView(model.options);
|
|
64
77
|
model.bindGroupTime.modified();
|
|
@@ -69,7 +82,7 @@ function vtkWebGPUTextureView(publicAPI, model) {
|
|
|
69
82
|
|
|
70
83
|
|
|
71
84
|
publicAPI.getHandle = function () {
|
|
72
|
-
if (model.texture.getHandle() !== model.textureHandle) {
|
|
85
|
+
if (model.texture && model.texture.getHandle() !== model.textureHandle) {
|
|
73
86
|
model.textureHandle = model.texture.getHandle();
|
|
74
87
|
model.handle = model.textureHandle.createView(model.options);
|
|
75
88
|
model.bindGroupTime.modified();
|