@kitware/vtk.js 25.3.0 → 25.6.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/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/Style/InteractorStyleTrackballCamera.js +16 -0
- package/README.md +2 -2
- package/Rendering/Core/Actor2D.d.ts +12 -6
- package/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts +24 -0
- package/Rendering/Core/Property2D.d.ts +1 -1
- package/Rendering/Core/Renderer.d.ts +43 -3
- package/Rendering/Core/Renderer.js +5 -1
- package/Rendering/Core/Texture.d.ts +22 -0
- package/Rendering/Core/Texture.js +159 -10
- package/Rendering/Core/VolumeProperty.d.ts +4 -4
- package/Rendering/Core/VolumeProperty.js +1 -1
- package/Rendering/OpenGL/RenderWindow/ContextProxy.js +65 -0
- package/Rendering/OpenGL/RenderWindow.js +3 -1
- package/Rendering/WebGPU/CellArrayMapper.js +43 -13
- package/Rendering/WebGPU/ForwardPass.js +93 -15
- package/Rendering/WebGPU/FullScreenQuad.js +2 -1
- 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/Renderer.js +77 -5
- package/Rendering/WebGPU/Sampler.js +4 -0
- package/Rendering/WebGPU/Texture.js +78 -46
- package/Rendering/WebGPU/TextureManager.js +5 -3
- package/Rendering/WebGPU/TextureView.js +15 -2
- package/Rendering/WebGPU/VolumePass.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +0 -2
- package/package.json +4 -5
- 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);
|
package/README.md
CHANGED
|
@@ -48,8 +48,8 @@ In general VTK tries to be as portable as possible; the specific configurations
|
|
|
48
48
|
|
|
49
49
|
vtk.js supports the following development environments:
|
|
50
50
|
|
|
51
|
-
- Node
|
|
52
|
-
- NPM
|
|
51
|
+
- Node 14+
|
|
52
|
+
- NPM 7+
|
|
53
53
|
|
|
54
54
|
and we use [@babel/preset-env](https://www.npmjs.com/package/@babel/preset-env) with the [defaults](https://github.com/Kitware/vtk-js/blob/master/.browserslistrc) set of [browsers target](https://browserl.ist/?q=defaults).
|
|
55
55
|
But when built from source this could be adjusted to support any browser as long they provide WebGL.
|
|
@@ -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,
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -35,6 +35,10 @@ export interface IRendererInitialValues extends IViewportInitialValues {
|
|
|
35
35
|
occlusionRatio?: number;
|
|
36
36
|
maximumNumberOfPeels?: number;
|
|
37
37
|
texturedBackground?: boolean;
|
|
38
|
+
environmentTexture?: vtkTexture;
|
|
39
|
+
environmentTextureDiffuseStrength?: number;
|
|
40
|
+
environmentTextureSpecularStrength?: number;
|
|
41
|
+
useEnvironmentTextureAsBackground?: boolean;
|
|
38
42
|
pass?: number;
|
|
39
43
|
}
|
|
40
44
|
|
|
@@ -115,7 +119,25 @@ export interface vtkRenderer extends vtkViewport {
|
|
|
115
119
|
*
|
|
116
120
|
* @default null
|
|
117
121
|
*/
|
|
118
|
-
|
|
122
|
+
getEnvironmentTexture(): vtkTexture;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Returns the diffuse strength of the set environment texture.
|
|
126
|
+
* @default 1
|
|
127
|
+
*/
|
|
128
|
+
getEnvironmentTextureDiffuseStrength(): number;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Returns the specular strength of the set environment texture.
|
|
132
|
+
* @default 1
|
|
133
|
+
*/
|
|
134
|
+
getEnvironmentTextureSpecularStrength(): number;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Gets whether or not the environment texture is being used as the background for the view.
|
|
138
|
+
* @default false
|
|
139
|
+
*/
|
|
140
|
+
getUseEnvironmentTextureAsBackground(): boolean;
|
|
119
141
|
|
|
120
142
|
/**
|
|
121
143
|
*
|
|
@@ -347,9 +369,27 @@ export interface vtkRenderer extends vtkViewport {
|
|
|
347
369
|
|
|
348
370
|
/**
|
|
349
371
|
*
|
|
350
|
-
* @param {vtkTexture}
|
|
372
|
+
* @param {vtkTexture} environmentTexture
|
|
373
|
+
*/
|
|
374
|
+
setEnvironmentTexture(environmentTexture: vtkTexture): boolean;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Sets the diffuse strength of the set environment texture.
|
|
378
|
+
* @param {number} diffuseStrength the new diffuse strength.
|
|
351
379
|
*/
|
|
352
|
-
|
|
380
|
+
setEnvironmentTextureDiffuseStrength(diffuseStrength: number): boolean;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Sets the specular strength of the set environment texture.
|
|
384
|
+
* @param {number} specularStrength the new specular strength.
|
|
385
|
+
*/
|
|
386
|
+
setEnvironmentTextureSpecularStrength(specularStrength: number): boolean;
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Sets whether or not to use the environment texture as the background for the view.
|
|
390
|
+
* @param {number} textureAsBackground
|
|
391
|
+
*/
|
|
392
|
+
setUseEnvironmentTextureAsBackground(textureAsBackground: boolean): boolean;
|
|
353
393
|
|
|
354
394
|
/**
|
|
355
395
|
*
|
|
@@ -593,6 +593,10 @@ var DEFAULT_VALUES = {
|
|
|
593
593
|
delegate: null,
|
|
594
594
|
texturedBackground: false,
|
|
595
595
|
backgroundTexture: null,
|
|
596
|
+
environmentTexture: null,
|
|
597
|
+
environmentTextureDiffuseStrength: 1,
|
|
598
|
+
environmentTextureSpecularStrength: 1,
|
|
599
|
+
useEnvironmentTextureAsBackground: false,
|
|
596
600
|
pass: 0
|
|
597
601
|
}; // ----------------------------------------------------------------------------
|
|
598
602
|
|
|
@@ -611,7 +615,7 @@ function extend(publicAPI, model) {
|
|
|
611
615
|
if (model.background.length === 3) model.background.push(1); // Build VTK API
|
|
612
616
|
|
|
613
617
|
get(publicAPI, model, ['_renderWindow', 'allocatedRenderTime', 'timeFactor', 'lastRenderTimeInSeconds', 'numberOfPropsRendered', 'lastRenderingUsedDepthPeeling', 'selector']);
|
|
614
|
-
setGet(publicAPI, model, ['twoSidedLighting', 'lightFollowCamera', 'automaticLightCreation', 'erase', 'draw', 'nearClippingPlaneTolerance', 'clippingRangeExpansion', 'backingStore', 'interactive', 'layer', 'preserveColorBuffer', 'preserveDepthBuffer', 'useDepthPeeling', 'occlusionRatio', 'maximumNumberOfPeels', 'delegate', 'backgroundTexture', 'texturedBackground', 'useShadows', 'pass']);
|
|
618
|
+
setGet(publicAPI, model, ['twoSidedLighting', 'lightFollowCamera', 'automaticLightCreation', 'erase', 'draw', 'nearClippingPlaneTolerance', 'clippingRangeExpansion', 'backingStore', 'interactive', 'layer', 'preserveColorBuffer', 'preserveDepthBuffer', 'useDepthPeeling', 'occlusionRatio', 'maximumNumberOfPeels', 'delegate', 'backgroundTexture', 'texturedBackground', 'environmentTexture', 'environmentTextureDiffuseStrength', 'environmentTextureSpecularStrength', 'useEnvironmentTextureAsBackground', 'useShadows', 'pass']);
|
|
615
619
|
getArray(publicAPI, model, ['actors', 'volumes', 'lights']);
|
|
616
620
|
setGetArray(publicAPI, model, ['background'], 4, 1.0);
|
|
617
621
|
moveToProtected(publicAPI, model, ['renderWindow']); // Object methods
|
|
@@ -5,6 +5,7 @@ export interface ITextureInitialValues {
|
|
|
5
5
|
interpolate?: boolean;
|
|
6
6
|
edgeClamp?: boolean;
|
|
7
7
|
imageLoaded?: boolean;
|
|
8
|
+
mipLevel?: number;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export interface vtkTexture extends vtkAlgorithm {
|
|
@@ -34,6 +35,11 @@ export interface vtkTexture extends vtkAlgorithm {
|
|
|
34
35
|
*/
|
|
35
36
|
getImageLoaded(): boolean;
|
|
36
37
|
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
getMipLevel(): number;
|
|
42
|
+
|
|
37
43
|
/**
|
|
38
44
|
*
|
|
39
45
|
* @param repeat
|
|
@@ -62,6 +68,11 @@ export interface vtkTexture extends vtkAlgorithm {
|
|
|
62
68
|
* @default null
|
|
63
69
|
*/
|
|
64
70
|
setImage(image: any): void;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param level
|
|
74
|
+
*/
|
|
75
|
+
setMipLevel(level: number): boolean;
|
|
65
76
|
}
|
|
66
77
|
|
|
67
78
|
/**
|
|
@@ -79,6 +90,17 @@ export function extend(publicAPI: object, model: object, initialValues?: ITextur
|
|
|
79
90
|
*/
|
|
80
91
|
export function newInstance(initialValues?: ITextureInitialValues): vtkTexture;
|
|
81
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Method used to create mipmaps from given texture data. Works best with textures that have a
|
|
95
|
+
* width and a height that are powers of two.
|
|
96
|
+
*
|
|
97
|
+
* @param nativeArray the array of data to create mipmaps from.
|
|
98
|
+
* @param width the width of the data
|
|
99
|
+
* @param height the height of the data
|
|
100
|
+
* @param level the level to which additional mipmaps are generated.
|
|
101
|
+
*/
|
|
102
|
+
export function generateMipmaps(nativeArray: any, width: number, height: number, level: number): Array<Uint8ClampedArray>;
|
|
103
|
+
|
|
82
104
|
/**
|
|
83
105
|
* vtkTexture is an image algorithm that handles loading and binding of texture maps.
|
|
84
106
|
* It obtains its data from an input image data dataset type.
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
1
3
|
import macro from '../../macros.js';
|
|
2
4
|
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3
8
|
// vtkTexture methods
|
|
4
9
|
// ----------------------------------------------------------------------------
|
|
5
10
|
|
|
@@ -103,19 +108,160 @@ function vtkTexture(publicAPI, model) {
|
|
|
103
108
|
var dimensionality = (width > 1) + (height > 1) + (depth > 1);
|
|
104
109
|
return dimensionality;
|
|
105
110
|
};
|
|
106
|
-
|
|
111
|
+
|
|
112
|
+
publicAPI.getInputAsJsImageData = function () {
|
|
113
|
+
if (!model.imageLoaded || publicAPI.getInputData()) return null;
|
|
114
|
+
|
|
115
|
+
if (model.jsImageData) {
|
|
116
|
+
return model.jsImageData();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (model.canvas) {
|
|
120
|
+
var context = model.canvas.getContext('2d');
|
|
121
|
+
var imageData = context.getImageData(0, 0, model.canvas.width, model.canvas.height);
|
|
122
|
+
return imageData;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (model.image) {
|
|
126
|
+
var canvas = document.createElement('canvas');
|
|
127
|
+
canvas.width = model.image.width;
|
|
128
|
+
canvas.height = model.image.height;
|
|
129
|
+
|
|
130
|
+
var _context = canvas.getContext('2d');
|
|
131
|
+
|
|
132
|
+
_context.translate(0, canvas.height);
|
|
133
|
+
|
|
134
|
+
_context.scale(1, -1);
|
|
135
|
+
|
|
136
|
+
_context.drawImage(model.image, 0, 0, model.image.width, model.image.height);
|
|
137
|
+
|
|
138
|
+
var _imageData = _context.getImageData(0, 0, canvas.width, canvas.height);
|
|
139
|
+
|
|
140
|
+
return _imageData;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return null;
|
|
144
|
+
};
|
|
145
|
+
} // Use nativeArray instead of self
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
var generateMipmaps = function generateMipmaps(nativeArray, width, height, level) {
|
|
149
|
+
// TODO: FIX UNEVEN TEXTURE MIP GENERATION:
|
|
150
|
+
// When textures don't have standard ratios, higher mip levels
|
|
151
|
+
// result in their color chanels getting messed up and shifting
|
|
152
|
+
// 3x3 gaussian kernel
|
|
153
|
+
var g3m = [1, 2, 1]; // eslint-disable-line
|
|
154
|
+
|
|
155
|
+
var g3w = 4; // eslint-disable-line
|
|
156
|
+
|
|
157
|
+
var kernel = g3m;
|
|
158
|
+
var kernelWeight = g3w;
|
|
159
|
+
var hs = nativeArray.length / (width * height); // TODO: support for textures with depth more than 1
|
|
160
|
+
|
|
161
|
+
var currentWidth = width;
|
|
162
|
+
var currentHeight = height;
|
|
163
|
+
var imageData = nativeArray;
|
|
164
|
+
var maps = [imageData];
|
|
165
|
+
|
|
166
|
+
for (var i = 0; i < level; i++) {
|
|
167
|
+
var oldData = _toConsumableArray(imageData);
|
|
168
|
+
|
|
169
|
+
currentWidth /= 2;
|
|
170
|
+
currentHeight /= 2;
|
|
171
|
+
imageData = new Uint8ClampedArray(currentWidth * currentHeight * hs);
|
|
172
|
+
var vs = hs * currentWidth; // Scale down
|
|
173
|
+
|
|
174
|
+
var shift = 0;
|
|
175
|
+
|
|
176
|
+
for (var p = 0; p < imageData.length; p += hs) {
|
|
177
|
+
if (p % vs === 0) {
|
|
178
|
+
shift += 2 * hs * currentWidth;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
for (var c = 0; c < hs; c++) {
|
|
182
|
+
var sample = oldData[shift + c];
|
|
183
|
+
sample += oldData[shift + hs + c];
|
|
184
|
+
sample += oldData[shift - 2 * vs + c];
|
|
185
|
+
sample += oldData[shift - 2 * vs + hs + c];
|
|
186
|
+
sample /= 4;
|
|
187
|
+
imageData[p + c] = sample;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
shift += 2 * hs;
|
|
191
|
+
} // Horizontal Pass
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
var dataCopy = _toConsumableArray(imageData);
|
|
195
|
+
|
|
196
|
+
for (var _p = 0; _p < imageData.length; _p += hs) {
|
|
197
|
+
for (var _c = 0; _c < hs; _c++) {
|
|
198
|
+
var x = -(kernel.length - 1) / 2;
|
|
199
|
+
var kw = kernelWeight;
|
|
200
|
+
var value = 0.0;
|
|
201
|
+
|
|
202
|
+
for (var k = 0; k < kernel.length; k++) {
|
|
203
|
+
var index = _p + _c + x * hs;
|
|
204
|
+
var lineShift = index % vs - (_p + _c) % vs;
|
|
205
|
+
if (lineShift > hs) index += vs;
|
|
206
|
+
if (lineShift < -hs) index -= vs;
|
|
207
|
+
|
|
208
|
+
if (dataCopy[index]) {
|
|
209
|
+
value += dataCopy[index] * kernel[k];
|
|
210
|
+
} else {
|
|
211
|
+
kw -= kernel[k];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
x += 1;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
imageData[_p + _c] = value / kw;
|
|
218
|
+
}
|
|
219
|
+
} // Vertical Pass
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
dataCopy = _toConsumableArray(imageData);
|
|
223
|
+
|
|
224
|
+
for (var _p2 = 0; _p2 < imageData.length; _p2 += hs) {
|
|
225
|
+
for (var _c2 = 0; _c2 < hs; _c2++) {
|
|
226
|
+
var _x = -(kernel.length - 1) / 2;
|
|
227
|
+
|
|
228
|
+
var _kw = kernelWeight;
|
|
229
|
+
var _value = 0.0;
|
|
230
|
+
|
|
231
|
+
for (var _k = 0; _k < kernel.length; _k++) {
|
|
232
|
+
var _index = _p2 + _c2 + _x * vs;
|
|
233
|
+
|
|
234
|
+
if (dataCopy[_index]) {
|
|
235
|
+
_value += dataCopy[_index] * kernel[_k];
|
|
236
|
+
} else {
|
|
237
|
+
_kw -= kernel[_k];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
_x += 1;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
imageData[_p2 + _c2] = _value / _kw;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
maps.push(imageData);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return maps;
|
|
251
|
+
}; // ----------------------------------------------------------------------------
|
|
107
252
|
// Object factory
|
|
108
253
|
// ----------------------------------------------------------------------------
|
|
109
254
|
|
|
110
255
|
|
|
111
256
|
var DEFAULT_VALUES = {
|
|
112
|
-
repeat: false,
|
|
113
|
-
interpolate: false,
|
|
114
|
-
edgeClamp: false,
|
|
115
257
|
image: null,
|
|
116
258
|
canvas: null,
|
|
259
|
+
jsImageData: null,
|
|
117
260
|
imageLoaded: false,
|
|
118
|
-
|
|
261
|
+
repeat: false,
|
|
262
|
+
interpolate: false,
|
|
263
|
+
edgeClamp: false,
|
|
264
|
+
mipLevel: 0
|
|
119
265
|
}; // ----------------------------------------------------------------------------
|
|
120
266
|
|
|
121
267
|
function extend(publicAPI, model) {
|
|
@@ -125,15 +271,18 @@ function extend(publicAPI, model) {
|
|
|
125
271
|
macro.obj(publicAPI, model);
|
|
126
272
|
macro.algo(publicAPI, model, 6, 0);
|
|
127
273
|
macro.get(publicAPI, model, ['canvas', 'image', 'jsImageData', 'imageLoaded']);
|
|
128
|
-
macro.setGet(publicAPI, model, ['repeat', 'edgeClamp', 'interpolate']);
|
|
274
|
+
macro.setGet(publicAPI, model, ['repeat', 'edgeClamp', 'interpolate', 'mipLevel']);
|
|
129
275
|
vtkTexture(publicAPI, model);
|
|
130
276
|
} // ----------------------------------------------------------------------------
|
|
131
277
|
|
|
132
|
-
var newInstance = macro.newInstance(extend, 'vtkTexture');
|
|
278
|
+
var newInstance = macro.newInstance(extend, 'vtkTexture');
|
|
279
|
+
var STATIC = {
|
|
280
|
+
generateMipmaps: generateMipmaps
|
|
281
|
+
}; // ----------------------------------------------------------------------------
|
|
133
282
|
|
|
134
|
-
var vtkTexture$1 = {
|
|
283
|
+
var vtkTexture$1 = _objectSpread({
|
|
135
284
|
newInstance: newInstance,
|
|
136
285
|
extend: extend
|
|
137
|
-
};
|
|
286
|
+
}, STATIC);
|
|
138
287
|
|
|
139
|
-
export { vtkTexture$1 as default, extend, newInstance };
|
|
288
|
+
export { STATIC, vtkTexture$1 as default, extend, newInstance };
|
|
@@ -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
|
*
|
|
@@ -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
|
|