@kitware/vtk.js 29.4.6 → 29.5.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.
@@ -62,6 +62,15 @@ export interface vtkDataArray extends vtkObject {
62
62
  */
63
63
  getData(): number[]|TypedArray;
64
64
 
65
+ /**
66
+ * Call this method when the underlying data has changed
67
+ * This method calls `modified()`
68
+ * For example, when you need to modify chunks of the array, it is faster
69
+ * to get the underlying array with `getData()`, modify it, and then call
70
+ * `dataChange()`.
71
+ */
72
+ dataChange(): void;
73
+
65
74
  /**
66
75
  * Get the range of the given component.
67
76
  *
@@ -54,7 +54,7 @@ export interface vtkSelectionNode extends vtkObject {
54
54
  /**
55
55
  * This functions is called internally by VTK.js and is not intended for public use.
56
56
  */
57
- setProperties(properties: ISelectionNodeProperties);
57
+ setProperties(properties: ISelectionNodeProperties): boolean;
58
58
 
59
59
  /**
60
60
  * Get the list of the underlying selected attribute IDs.
@@ -64,7 +64,7 @@ export interface vtkSelectionNode extends vtkObject {
64
64
  /**
65
65
  * This functions is called internally by VTK.js and is not intended for public use.
66
66
  */
67
- setSelectionList(selectionAttributeIDs: ISelectionNodeProperties);
67
+ setSelectionList(selectionAttributeIDs: ISelectionNodeProperties): boolean;
68
68
  }
69
69
 
70
70
  /**
@@ -148,6 +148,46 @@ export interface vtkHttpDataSetReader extends vtkHttpDataSetReaderBase {
148
148
  */
149
149
  getUrl(): string;
150
150
 
151
+ /**
152
+ * Gets an array of all cached array ids.
153
+ */
154
+ getCachedArrayIds(): string[];
155
+
156
+
157
+ /**
158
+ * Gets the maximum size cached arrays are allowed to occupy.
159
+ * Size is given in MiB.
160
+ * If cache size is exceeded, the arrays that where not accessed
161
+ * the longest are removed.
162
+ *
163
+ * Special settings:
164
+ * -1 -> Cache unlimited
165
+ * 0 -> Cache disabled
166
+ * null -> Cache disabled
167
+ * undefined -> Cache disabled
168
+ */
169
+ getMaxCacheSize(): number | null | undefined;
170
+
171
+ /**
172
+ * Sets the maximum size cached arrays are allowed to occupy.
173
+ * Size is given in MiB.
174
+ * If cache size is exceeded, the arrays that where not accessed
175
+ * the longest are removed.
176
+ * If set to "undefined" the cache is unlimited.
177
+ *
178
+ * Special settings:
179
+ * -1 -> Cache unlimited
180
+ * 0 -> Cache disabled
181
+ * null -> Cache disabled
182
+ * undefined -> Cache disabled
183
+ */
184
+ setMaxCacheSize(value: number | null | undefined): void;
185
+
186
+ /**
187
+ * Clears all cached entries.
188
+ */
189
+ clearCache(): void;
190
+
151
191
  /**
152
192
  *
153
193
  * @param {Boolean} busy
@@ -22,7 +22,9 @@ const ARRAY_BUILDERS = {
22
22
  // Global methods
23
23
  // ----------------------------------------------------------------------------
24
24
 
25
- const cachedArrays = {};
25
+ const cachedArraysAndPromises = {};
26
+ const cachedArraysMetaData = {};
27
+ const MiB = 1024 * 1024;
26
28
  const GEOMETRY_ARRAYS = {
27
29
  vtkPolyData(dataset) {
28
30
  const arrayToDownload = [];
@@ -131,23 +133,68 @@ function vtkHttpDataSetReader(publicAPI, model) {
131
133
  function fetchArray(array) {
132
134
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
133
135
  const arrayId = `${array.ref.id}|${array.vtkClass}`;
134
- if (!cachedArrays[arrayId]) {
136
+ if (!cachedArraysAndPromises[arrayId]) {
135
137
  // Cache the promise while fetching
136
- cachedArrays[arrayId] = model.dataAccessHelper.fetchArray(publicAPI, model.baseURL, array, options).then(newArray => {
138
+ cachedArraysAndPromises[arrayId] = model.dataAccessHelper.fetchArray(publicAPI, model.baseURL, array, options).then(newArray => {
139
+ // Remove promise and return here if caching is disabled
140
+ if (!model.maxCacheSize) {
141
+ delete cachedArraysAndPromises[arrayId];
142
+ return newArray;
143
+ }
144
+
137
145
  // Replace the promise with the array in cache once downloaded
138
- cachedArrays[arrayId] = newArray;
146
+ cachedArraysAndPromises[arrayId] = newArray;
147
+ cachedArraysMetaData[arrayId] = {
148
+ lastAccess: new Date()
149
+ };
150
+
151
+ // If maxCacheSize is set to -1 the cache is unlimited
152
+ if (model.maxCacheSize < 0) {
153
+ return newArray;
154
+ }
155
+
156
+ // sort cache according to access times (potentially needed for creating space)
157
+ const cachedArrays = {};
158
+ Object.keys(cachedArraysMetaData).forEach(arrId => {
159
+ cachedArrays[arrId] = {
160
+ array: cachedArraysAndPromises[arrId],
161
+ lastAccess: cachedArraysMetaData[arrId].lastAccess
162
+ };
163
+ });
164
+ const sortedArrayCache = Object.entries(cachedArrays).sort((a, b) => Math.sign(b[1].lastAccess - a[1].lastAccess));
165
+
166
+ // Check cache size
167
+ const cacheSizeLimit = model.maxCacheSize * MiB;
168
+ let cacheSize = Object.values(cachedArrays).reduce((accSize, entry) => accSize + entry.array.values.byteLength, 0);
169
+
170
+ // Delete cache entries until size is below the limit
171
+ while (cacheSize > cacheSizeLimit && sortedArrayCache.length > 0) {
172
+ const [oldId, entry] = sortedArrayCache.pop();
173
+ delete cachedArraysAndPromises[oldId];
174
+ delete cachedArraysMetaData[oldId];
175
+ cacheSize -= entry.array.values.byteLength;
176
+ }
177
+
178
+ // Edge case: If the new entry is bigger than the cache limit
179
+ if (!cachedArraysMetaData[arrayId]) {
180
+ macro.vtkWarningMacro('Cache size is too small for the dataset');
181
+ }
139
182
  return newArray;
140
183
  });
141
184
  } else {
142
185
  // cacheArrays[arrayId] can be a promise or value
143
- Promise.resolve(cachedArrays[arrayId]).then(cachedArray => {
186
+ Promise.resolve(cachedArraysAndPromises[arrayId]).then(cachedArray => {
144
187
  if (array !== cachedArray) {
188
+ // Update last access for cache retention rules
189
+ cachedArraysMetaData[arrayId].lastAccess = new Date();
190
+
191
+ // Assign cached array as result
145
192
  Object.assign(array, cachedArray);
146
193
  delete array.ref;
147
194
  }
148
195
  });
149
196
  }
150
- return Promise.resolve(cachedArrays[arrayId]);
197
+ return Promise.resolve(cachedArraysAndPromises[arrayId]);
151
198
  }
152
199
 
153
200
  // Fetch dataset (metadata)
@@ -268,6 +315,15 @@ function vtkHttpDataSetReader(publicAPI, model) {
268
315
  }
269
316
  };
270
317
 
318
+ // return id's of cached arrays
319
+ publicAPI.getCachedArrayIds = () => Object.keys(cachedArraysMetaData);
320
+
321
+ // clear global array cache
322
+ publicAPI.clearCache = () => Object.keys(cachedArraysMetaData).forEach(k => {
323
+ delete cachedArraysAndPromises[k];
324
+ delete cachedArraysMetaData[k];
325
+ });
326
+
271
327
  // return Busy state
272
328
  publicAPI.isBusy = () => !!model.requestCount;
273
329
  }
@@ -282,7 +338,9 @@ const DEFAULT_VALUES = {
282
338
  arrays: [],
283
339
  url: null,
284
340
  baseURL: null,
285
- requestCount: 0
341
+ requestCount: 0,
342
+ arrayCachingEnabled: true,
343
+ maxCacheSize: 2048
286
344
  // dataAccessHelper: null,
287
345
  };
288
346
 
@@ -294,8 +352,8 @@ function extend(publicAPI, model) {
294
352
 
295
353
  // Build VTK API
296
354
  macro.obj(publicAPI, model);
297
- macro.get(publicAPI, model, ['enableArray', 'fetchGzip', 'url', 'baseURL', 'dataAccessHelper']);
298
- macro.set(publicAPI, model, ['dataAccessHelper', 'progressCallback']);
355
+ macro.get(publicAPI, model, ['enableArray', 'fetchGzip', 'url', 'baseURL', 'dataAccessHelper', 'maxCacheSize']);
356
+ macro.set(publicAPI, model, ['dataAccessHelper', 'progressCallback', 'maxCacheSize']);
299
357
  macro.getArray(publicAPI, model, ['arrays']);
300
358
  macro.algo(publicAPI, model, 0, 1);
301
359
  macro.event(publicAPI, model, 'busy');
@@ -1,3 +1,4 @@
1
+ import { Vector3 } from './../../types';
1
2
  import vtkCamera from './Camera';
2
3
  import vtkMapper, { IMapperInitialValues } from './Mapper';
3
4
 
@@ -65,9 +66,30 @@ export interface vtkPixelSpaceCallbackMapper extends vtkMapper {
65
66
  *
66
67
  * depthBuffer: Uint8Array
67
68
  *
68
- * @param callback
69
+ * @example
70
+ * ```js
71
+ * // there is some text canvas and label data
72
+ * const textCtx = textCanvas.getContext('2d');
73
+ * const psMapper = vtkPixelSpaceCallbackMapper.newInstance();
74
+ * psMapper.setInputData(pointPoly);
75
+ * psMapper.setCallback((coords, camera, aspect, depthBuffer) => {
76
+ * textCtx.clearRect(0, 0, oglCtx.drawingBufferWidth, oglCtx.drawingBufferHeight);
77
+ * coords.forEach((xy, idx) => {
78
+ * let label = data.labels[idx]
79
+ * textCtx.fillStyle = "white";
80
+ * textCtx.font = "12px Arial";
81
+ * textCtx.fillText(label, xy[0], oglCtx.drawingBufferHeight - xy[1]);
82
+ * })
83
+ * })
84
+ *
85
+ * const textActor = vtkActor.newInstance();
86
+ * textActor.setMapper(psMapper);
87
+ * renderer.addActor(textActor);
88
+ * ```
89
+ *
90
+ * @param callback called with coords, camera, aspect and depthBuffer
69
91
  */
70
- setCallback(callback: () => any): boolean
92
+ setCallback(callback: (coords: Vector3[], camera: vtkCamera, aspect: number, depthBuffer: Uint8Array) => any): boolean
71
93
 
72
94
 
73
95
  /**
@@ -98,7 +98,7 @@ function vtkRenderWindow(publicAPI, model) {
98
98
  gpuMemoryMB: 0
99
99
  };
100
100
  model._views.forEach(v => {
101
- results.gpuMemoryMB += v.getGraphicsMemoryInfo() / 1e6;
101
+ if (v.getGraphicsMemoryInfo) results.gpuMemoryMB += v.getGraphicsMemoryInfo() / 1e6;
102
102
  });
103
103
  model.renderers.forEach(ren => {
104
104
  const props = ren.getViewProps();
@@ -110,7 +110,9 @@ function vtkRenderWindow(publicAPI, model) {
110
110
  if (mpr && mpr.getPrimitiveCount) {
111
111
  const gmpr = gren.getViewNodeFor(mpr);
112
112
  if (gmpr) {
113
- results.gpuMemoryMB += gmpr.getAllocatedGPUMemoryInBytes() / 1e6;
113
+ if (gmpr.getAllocatedGPUMemoryInBytes) {
114
+ results.gpuMemoryMB += gmpr.getAllocatedGPUMemoryInBytes() / 1e6;
115
+ }
114
116
  const pcount = mpr.getPrimitiveCount();
115
117
  Object.keys(pcount).forEach(keyName => {
116
118
  if (!results[keyName]) {
@@ -0,0 +1,11 @@
1
+ export declare enum ObjectType {
2
+ ARRAY_BUFFER = 0,
3
+ ELEMENT_ARRAY_BUFFER = 1,
4
+ TEXTURE_BUFFER = 2,
5
+ }
6
+
7
+ declare const _default: {
8
+ ObjectType: typeof ObjectType;
9
+ };
10
+
11
+ export default _default;
@@ -0,0 +1,82 @@
1
+ import { ObjectType } from './BufferObject/Constants';
2
+ import { vtkAlgorithm, vtkObject } from './../../interfaces';
3
+
4
+ /**
5
+ * Interface for initial values of BufferObject
6
+ */
7
+ export interface IBufferObjectInitialValues {
8
+ objectType?: ObjectType;
9
+ context?: WebGLRenderingContext | WebGL2RenderingContext;
10
+ allocatedGPUMemoryInBytes?: number;
11
+ }
12
+
13
+ /**
14
+ * Interface for OpenGL Buffer Object
15
+ */
16
+ export interface vtkOpenGLBufferObject extends vtkObject {
17
+ /**
18
+ * Uploads data to the buffer object.
19
+ * @param data The data to be uploaded.
20
+ * @param type The type of the data.
21
+ * @returns {boolean} Whether the upload was successful.
22
+ */
23
+ upload(data: any, type: any): boolean;
24
+
25
+ /**
26
+ * Binds the buffer object.
27
+ * @returns {boolean} Whether the binding was successful.
28
+ */
29
+ bind(): boolean;
30
+
31
+ /**
32
+ * Releases the buffer object.
33
+ * @returns {boolean} Whether the release was successful.
34
+ */
35
+ release(): boolean;
36
+
37
+ /**
38
+ * Releases graphics resources associated with the buffer object.
39
+ */
40
+ releaseGraphicsResources(): void;
41
+
42
+ /**
43
+ * Sets the OpenGL render window.
44
+ * @param renWin The render window to set.
45
+ */
46
+ setOpenGLRenderWindow(renWin: any): void;
47
+
48
+ /**
49
+ * Retrieves the error message, if any.
50
+ * @returns {string} The error message.
51
+ */
52
+ getError(): string;
53
+
54
+ }
55
+
56
+ /**
57
+ * Extends the given object with the properties and methods of vtkOpenGLBufferObject.
58
+ * @param publicAPI The public API to extend.
59
+ * @param model The model to extend.
60
+ * @param initialValues The initial values to apply.
61
+ */
62
+ export function extend(
63
+ publicAPI: object,
64
+ model: object,
65
+ initialValues?: IBufferObjectInitialValues
66
+ ): void;
67
+
68
+ /**
69
+ * Creates a new instance of vtkOpenGLBufferObject with the given initial values.
70
+ * @param initialValues The initial values to use.
71
+ * @returns {vtkOpenGLBufferObject} The new instance.
72
+ */
73
+ export function newInstance(initialValues?: IBufferObjectInitialValues): vtkOpenGLBufferObject;
74
+
75
+ /**
76
+ * Object containing the newInstance and extend functions for vtkOpenGLBufferObject.
77
+ */
78
+ export declare const vtkOpenGLBufferObject: {
79
+ newInstance: typeof newInstance;
80
+ extend: typeof extend;
81
+ };
82
+ export default vtkOpenGLBufferObject;
@@ -0,0 +1,21 @@
1
+ export declare enum Wrap {
2
+ CLAMP_TO_EDGE = 0,
3
+ REPEAT = 1,
4
+ MIRRORED_REPEAT = 2,
5
+ }
6
+
7
+ export declare enum Filter {
8
+ NEAREST = 0,
9
+ LINEAR = 1,
10
+ NEAREST_MIPMAP_NEAREST = 2,
11
+ NEAREST_MIPMAP_LINEAR = 3,
12
+ LINEAR_MIPMAP_NEAREST = 4,
13
+ LINEAR_MIPMAP_LINEAR = 5,
14
+ }
15
+
16
+ declare const _default: {
17
+ Wrap: typeof Wrap;
18
+ Filter: typeof Filter;
19
+ };
20
+
21
+ export default _default;
@@ -0,0 +1,305 @@
1
+ import { Wrap, Filter } from './Texture/Constants';
2
+ import vtkOpenGLRenderWindow from './RenderWindow';
3
+ import { Nullable } from './../../types';
4
+ import { VtkDataTypes } from './../../Common/Core/DataArray';
5
+ import { vtkViewNode } from './../SceneGraph/ViewNode';
6
+ import { vtkObject } from './../../interfaces' ;
7
+
8
+ /**
9
+ * Initial values for creating a new instance of vtkOpenGLTexture.
10
+ */
11
+ export interface ITextureInitialValues {
12
+ _openGLRenderWindow?: Nullable<vtkOpenGLRenderWindow>;
13
+ _forceInternalFormat?: boolean;
14
+ context?: WebGLRenderingContext | WebGL2RenderingContext;
15
+ handle?: number;
16
+ sendParametersTime?: vtkObject;
17
+ textureBuildTime?: vtkObject;
18
+ numberOfDimensions?: number;
19
+ target?: number;
20
+ format?: number;
21
+ openGLDataType?: number;
22
+ components?: number;
23
+ width?: number;
24
+ height?: number;
25
+ depth?: number;
26
+ autoParameters?: boolean;
27
+ wrapS?: Wrap;
28
+ wrapT?: Wrap;
29
+ wrapR?: Wrap;
30
+ minificationFilter?: Filter;
31
+ magnificationFilter?: Filter;
32
+ minLOD?: number;
33
+ maxLOD?: number;
34
+ baseLevel?: number;
35
+ maxLevel?: number;
36
+ generateMipmap?: boolean;
37
+ useHalfFloat?: boolean;
38
+ oglNorm16Ext?: any;
39
+ allocatedGPUMemoryInBytes?: number;
40
+ }
41
+
42
+ /**
43
+ * Interface for OpenGL Texture.
44
+ */
45
+ export interface vtkOpenGLTexture extends vtkViewNode {
46
+ /**
47
+ * Renders the texture within the given render window.
48
+ * @param renWin The render window in which to render the texture.
49
+ */
50
+ render(renWin: vtkOpenGLRenderWindow): void;
51
+
52
+ /**
53
+ * Destroys the texture and frees up any resources it's using.
54
+ */
55
+ destroyTexture(): void;
56
+
57
+ /**
58
+ * Creates the texture in the OpenGL context.
59
+ */
60
+ createTexture(): void;
61
+
62
+ /**
63
+ * Gets the texture unit number that this texture is bound to.
64
+ * @returns {number} The texture unit number.
65
+ */
66
+ getTextureUnit(): number;
67
+
68
+ /**
69
+ * Activates the texture, making it the current texture for subsequent OpenGL operations.
70
+ */
71
+ activate(): void;
72
+
73
+ /**
74
+ * Deactivates the texture, making it no longer the current texture for subsequent OpenGL operations.
75
+ */
76
+ deactivate(): void;
77
+
78
+ /**
79
+ * Releases the graphics resources used by the texture within the given render window.
80
+ * @param renWin The render window whose resources should be released.
81
+ */
82
+ releaseGraphicsResources(renWin: vtkOpenGLRenderWindow): void;
83
+
84
+ /**
85
+ * Binds the texture to the current OpenGL context.
86
+ */
87
+ bind(): void;
88
+
89
+ /**
90
+ * Checks if the texture is currently bound to the OpenGL context.
91
+ * @returns {boolean} True if the texture is bound, false otherwise.
92
+ */
93
+ isBound(): boolean;
94
+
95
+ /**
96
+ * Sends the texture parameters to the OpenGL context.
97
+ */
98
+ sendParameters(): void;
99
+
100
+ /**
101
+ * Gets the internal format for the texture based on the VTK data type and number of components.
102
+ * @param vtktype The VTK data type.
103
+ * @param numComps The number of components in the texture.
104
+ * @returns The internal format.
105
+ */
106
+ getInternalFormat(vtktype: VtkDataTypes, numComps: number): any;
107
+
108
+ /**
109
+ * Gets the default internal format for the texture based on the VTK data type and number of components.
110
+ * @param vtktype The VTK data type.
111
+ * @param numComps The number of components in the texture.
112
+ * @returns The default internal format.
113
+ */
114
+ getDefaultInternalFormat(vtktype: VtkDataTypes, numComps: number): any;
115
+
116
+ /**
117
+ * Sets the internal format for the texture.
118
+ * @param iformat The internal format to set.
119
+ */
120
+ setInternalFormat(iformat: any): void;
121
+
122
+ /**
123
+ * Gets the format for the texture based on the VTK data type and number of components.
124
+ * @param vtktype The VTK data type.
125
+ * @param numComps The number of components in the texture.
126
+ * @returns The format.
127
+ */
128
+ getFormat(vtktype: VtkDataTypes, numComps: number): any;
129
+
130
+ /**
131
+ * Gets the default format for the texture based on the VTK data type and number of components.
132
+ * @param vtktype The VTK data type.
133
+ * @param numComps The number of components in the texture.
134
+ * @returns The default format.
135
+ */
136
+ getDefaultFormat(vtktype: VtkDataTypes, numComps: number): any;
137
+
138
+ /**
139
+ * Resets the texture format and type to their default values.
140
+ */
141
+ resetFormatAndType(): void;
142
+
143
+ /**
144
+ * Gets the default data type for the texture based on the VTK scalar type.
145
+ * @param vtkScalarType The VTK scalar type.
146
+ * @returns The default data type.
147
+ */
148
+ getDefaultDataType(vtkScalarType: VtkDataTypes): any;
149
+
150
+ /**
151
+ * Gets the OpenGL data type for the texture based on the VTK scalar type and whether to force an update.
152
+ * @param vtkScalarType The VTK scalar type.
153
+ * @param forceUpdate Whether to force the update of the data type.
154
+ * @returns The OpenGL data type.
155
+ */
156
+ getOpenGLDataType(vtkScalarType: VtkDataTypes, forceUpdate: boolean): any;
157
+
158
+ /**
159
+ * Gets the shift and scale values for the texture.
160
+ * @returns The shift and scale values.
161
+ */
162
+ getShiftAndScale(): any;
163
+
164
+ /**
165
+ * Gets the OpenGL filter mode for the texture.
166
+ * @param emode The filter mode.
167
+ * @returns The OpenGL filter mode.
168
+ */
169
+ getOpenGLFilterMode(emode: Filter): any;
170
+
171
+ /**
172
+ * Gets the OpenGL wrap mode for the texture.
173
+ * @param vtktype The wrap type.
174
+ * @returns The OpenGL wrap mode.
175
+ */
176
+ getOpenGLWrapMode(vtktype: Wrap): any;
177
+
178
+ /**
179
+ * Creates a 2D texture from raw data.
180
+ * @param width The width of the texture.
181
+ * @param height The height of the texture.
182
+ * @param numComps The number of components in the texture.
183
+ * @param dataType The data type of the texture.
184
+ * @param data The raw data for the texture.
185
+ * @param flip Whether to flip the texture vertically.
186
+ * @returns {boolean} True if the texture was successfully created, false otherwise.
187
+ */
188
+ create2DFromRaw(width: number, height: number, numComps: number, dataType: VtkDataTypes, data: any, flip: boolean): boolean;
189
+
190
+ /**
191
+ * Creates a cube texture from raw data.
192
+ * @param width The width of each face of the cube texture.
193
+ * @param height The height of each face of the cube texture.
194
+ * @param numComps The number of components in the texture.
195
+ * @param dataType The data type of the texture.
196
+ * @param data The raw data for the texture.
197
+ * @param flip Whether to flip the texture vertically.
198
+ * @returns {boolean} True if the cube texture was successfully created, false otherwise.
199
+ */
200
+ createCubeFromRaw(width: number, height: number, numComps: number, dataType: VtkDataTypes, data: any, flip: boolean): boolean;
201
+
202
+ /**
203
+ * Creates a 2D texture from an image.
204
+ * @param image The image to use for the texture.
205
+ * @returns {boolean} True if the texture was successfully created, false otherwise.
206
+ */
207
+ create2DFromImage(image: any): boolean;
208
+
209
+ /**
210
+ * Creates a 2D filterable texture from raw data, with a preference for size over accuracy if necessary.
211
+ * @param width The width of the texture.
212
+ * @param height The height of the texture.
213
+ * @param numComps The number of components in the texture.
214
+ * @param dataType The data type of the texture.
215
+ * @param data The raw data for the texture.
216
+ * @param preferSizeOverAccuracy Whether to prefer texture size over accuracy.
217
+ * @returns {boolean} True if the texture was successfully created, false otherwise.
218
+ */
219
+ create2DFilterableFromRaw(width: number, height: number, numComps: number, dataType: VtkDataTypes, data: any, preferSizeOverAccuracy: boolean): boolean;
220
+
221
+ /**
222
+ * Creates a 2D filterable texture from a data array, with a preference for size over accuracy if necessary.
223
+ * @param width The width of the texture.
224
+ * @param height The height of the texture.
225
+ * @param dataArray The data array to use for the texture.
226
+ * @param preferSizeOverAccuracy Whether to prefer texture size over accuracy.
227
+ * @returns {boolean} True if the texture was successfully created, false otherwise.
228
+ */
229
+ create2DFilterableFromDataArray(width: number, height: number, dataArray: any, preferSizeOverAccuracy: boolean): boolean;
230
+
231
+ /**
232
+ * Creates a 3D texture from raw data.
233
+ * @param width The width of the texture.
234
+ * @param height The height of the texture.
235
+ * @param depth The depth of the texture.
236
+ * @param numComps The number of components in the texture.
237
+ * @param dataType The data type of the texture.
238
+ * @param data The raw data for the texture.
239
+ * @returns {boolean} True if the texture was successfully created, false otherwise.
240
+ */
241
+ create3DFromRaw(width: number, height: number, depth: number, numComps: number, dataType: VtkDataTypes, data: any): boolean;
242
+
243
+ /**
244
+ * Creates a 3D filterable texture from raw data, with a preference for size over accuracy if necessary.
245
+ * @param width The width of the texture.
246
+ * @param height The height of the texture.
247
+ * @param depth The depth of the texture.
248
+ * @param numComps The number of components in the texture.
249
+ * @param dataType The data type of the texture.
250
+ * @param values The raw data for the texture.
251
+ * @param preferSizeOverAccuracy Whether to prefer texture size over accuracy.
252
+ * @returns {boolean} True if the texture was successfully created, false otherwise.
253
+ */
254
+ create3DFilterableFromRaw(width: number, height: number, depth: number, numComps: number, dataType: VtkDataTypes, values: any, preferSizeOverAccuracy: boolean): boolean;
255
+
256
+ /**
257
+ * Creates a 3D filterable texture from a data array, with a preference for size over accuracy if necessary.
258
+ * @param width The width of the texture.
259
+ * @param height The height of the texture.
260
+ * @param depth The depth of the texture.
261
+ * @param dataArray The data array to use for the texture.
262
+ * @param preferSizeOverAccuracy Whether to prefer texture size over accuracy.
263
+ * @returns {boolean} True if the texture was successfully created, false otherwise.
264
+ */
265
+ create3DFilterableFromDataArray(width: number, height: number, depth: number, dataArray: any, preferSizeOverAccuracy: boolean): boolean;
266
+
267
+ /**
268
+ * Sets the OpenGL render window in which the texture will be used.
269
+ * @param renWin The render window to set.
270
+ */
271
+ setOpenGLRenderWindow(renWin: any): void;
272
+
273
+ /**
274
+ * Gets the maximum texture size supported by the OpenGL context.
275
+ * @param ctx The OpenGL context.
276
+ * @returns {number} The maximum texture size.
277
+ */
278
+ getMaximumTextureSize(ctx: any): number;
279
+
280
+ }
281
+
282
+ /**
283
+ * Extends the publicAPI with the given model and initial values.
284
+ * @param publicAPI The API to extend.
285
+ * @param model The model to use.
286
+ * @param initialValues The initial values to apply.
287
+ */
288
+ export function extend(publicAPI: object, model: object, initialValues?: ITextureInitialValues): void;
289
+
290
+ /**
291
+ * Creates a new instance of vtkOpenGLTexture with the given initial values.
292
+ * @param initialValues The initial values to use.
293
+ * @returns The new instance.
294
+ */
295
+ export function newInstance(initialValues?: ITextureInitialValues): vtkOpenGLTexture;
296
+
297
+ /**
298
+ * vtkOpenGLTexture static API.
299
+ */
300
+ export declare const vtkOpenGLTexture: {
301
+ newInstance: typeof newInstance,
302
+ extend: typeof extend,
303
+ };
304
+
305
+ export default vtkOpenGLTexture;
@@ -83,7 +83,7 @@ fn mdot(a: vec3<f32>, b: vec3<f32>) -> f32 {
83
83
  // zero and one while still maintaining a good amount of accuracy.
84
84
  fn cdot(a: vec3<f32>, b: vec3<f32>) -> f32 {
85
85
  var d: f32 = max(0.0, dot(a, b));
86
- d = pow((d + 1) / 2.0, 2.6);
86
+ d = pow((d + 1.0) / 2.0, 2.6);
87
87
  return d;
88
88
  }
89
89
 
@@ -109,7 +109,7 @@ fn fujiiOrenNayar(p: vec3<f32>, o: f32, N: vec3<f32>, L: vec3<f32>, V: vec3<f32>
109
109
  var LdotV: f32 = mdot(L, V);
110
110
 
111
111
  var s: f32 = LdotV - NdotL*NdotV;
112
- var t: f32 = mix(1, max(NdotL, NdotV), step(0, s)); // Mix with step is the equivalent of an if statement
112
+ var t: f32 = mix(1.0, max(NdotL, NdotV), step(0.0, s)); // Mix with step is the equivalent of an if statement
113
113
  var A: vec3<f32> = 0.5*(o2 / (o2 + 0.33)) + 0.17*p*(o2 / (o2 + 0.13));
114
114
  A = invpi*(1 - A);
115
115
  var B: f32 = 0.45*(o2 / (o2 + 0.09));
@@ -121,14 +121,14 @@ fn fujiiOrenNayar(p: vec3<f32>, o: f32, N: vec3<f32>, L: vec3<f32>, V: vec3<f32>
121
121
  // Fresnel portion of BRDF (IOR only, simplified)
122
122
  fn schlickFresnelIOR(V: vec3<f32>, N: vec3<f32>, ior: f32, k: f32) -> f32 {
123
123
  var NdotV: f32 = mdot(V, N);
124
- var F0: f32 = (pow((ior - 1.0), 2) + k*k) / (pow((ior + 1.0), 2) + k*k); // This takes into account the roughness, which the other one does not
125
- return F0 + (1 - F0) * pow((1-NdotV), 5);
124
+ var F0: f32 = (pow((ior - 1.0), 2.0) + k*k) / (pow((ior + 1.0), 2.0) + k*k); // This takes into account the roughness, which the other one does not
125
+ return F0 + (1.0 - F0) * pow((1.0-NdotV), 5.0);
126
126
  }
127
127
 
128
128
  // Fresnel portion of BRDF (Color ior, better)
129
129
  fn schlickFresnelRGB(V: vec3<f32>, N: vec3<f32>, F0: vec3<f32>) -> vec3<f32> {
130
130
  var NdotV: f32 = mdot(V, N);
131
- return F0 + (1 - F0) * pow((1-NdotV), 5);
131
+ return F0 + (1.0 - F0) * pow((1-NdotV), 5.0);
132
132
  }
133
133
 
134
134
  // Normal portion of BRDF
@@ -158,12 +158,12 @@ fn anisotrophicTrGGX(N: vec3<f32>, H: vec3<f32>, O: vec3<f32>, s: f32, a: f32) -
158
158
  // Geometry portion of BRDF
159
159
  fn schlickGGX(N: vec3<f32>, X: vec3<f32>, k: f32) -> f32 {
160
160
  var NdotX = cdot(N, X);
161
- return NdotX / max(0.000001, (NdotX*(1-k) + k));
161
+ return NdotX / max(0.000001, (NdotX*(1.0-k) + k));
162
162
  }
163
163
 
164
164
  fn smithSurfaceRoughness(N: vec3<f32>, V: vec3<f32>, L: vec3<f32>, k: f32) -> f32 {
165
- var ggx1: f32 = min(1, schlickGGX(N, V, k));
166
- var ggx2: f32 = min(1, schlickGGX(N, L, k));
165
+ var ggx1: f32 = min(1.0, schlickGGX(N, V, k));
166
+ var ggx2: f32 = min(1.0, schlickGGX(N, L, k));
167
167
  return ggx1*ggx2;
168
168
  }
169
169
 
@@ -187,7 +187,7 @@ fn calcDirectionalLight(N: vec3<f32>, V: vec3<f32>, ior: f32, roughness: f32, me
187
187
  // var F: f32 = schlickFresnelIOR(V, N, ior, k); // Fresnel
188
188
  var G: f32 = smithSurfaceRoughness(N, V, L, k); // Geometry
189
189
 
190
- var brdf: f32 = cookTorrance(D, 1, G, N, V, L); // Fresnel term is replaced with 1 because it is added later
190
+ var brdf: f32 = cookTorrance(D, 1.0, G, N, V, L); // Fresnel term is replaced with 1 because it is added later
191
191
  var incoming: vec3<f32> = color;
192
192
  var angle: f32 = mdot(L, N);
193
193
  angle = pow(angle, 1.5);
@@ -209,14 +209,14 @@ fn calcPointLight(N: vec3<f32>, V: vec3<f32>, fragPos: vec3<f32>, ior: f32, roug
209
209
  var dist = distance(position, fragPos);
210
210
 
211
211
  var alpha = roughness*roughness;
212
- var k: f32 = alpha*alpha / 2; // could also be pow(alpha + 1.0, 2) / 8
212
+ var k: f32 = alpha*alpha / 2.0; // could also be pow(alpha + 1.0, 2) / 8
213
213
 
214
214
  var D: f32 = trGGX(N, H, alpha); // Distribution
215
215
  // var F: f32 = schlickFresnelIOR(V, N, ior, k); // Fresnel
216
216
  var G: f32 = smithSurfaceRoughness(N, V, L, k); // Geometry
217
217
 
218
- var brdf: f32 = cookTorrance(D, 1, G, N, V, L);
219
- var incoming: vec3<f32> = color * (1. / (dist*dist));
218
+ var brdf: f32 = cookTorrance(D, 1.0, G, N, V, L);
219
+ var incoming: vec3<f32> = color * (1.0 / (dist*dist));
220
220
  var angle: f32 = mdot(L, N);
221
221
  angle = pow(angle, 1.5); // Smoothing factor makes it less accurate, but reduces ugly "seams" bewteen light sources
222
222
 
@@ -237,13 +237,13 @@ fn calcSpotLight(N: vec3<f32>, V: vec3<f32>, fragPos: vec3<f32>, ior: f32, rough
237
237
  var dist = distance(position, fragPos);
238
238
 
239
239
  var alpha = roughness*roughness;
240
- var k: f32 = alpha*alpha / 2; // could also be pow(alpha + 1.0, 2) / 8
240
+ var k: f32 = alpha*alpha / 2.0; // could also be pow(alpha + 1.0, 2) / 8
241
241
 
242
242
  var D: f32 = trGGX(N, H, alpha); // Distribution
243
243
  // var F: f32 = schlickFresnelIOR(V, N, ior, k); // Fresnel
244
244
  var G: f32 = smithSurfaceRoughness(N, V, L, k); // Geometry
245
245
 
246
- var brdf: f32 = cookTorrance(D, 1, G, N, V, L);
246
+ var brdf: f32 = cookTorrance(D, 1.0, G, N, V, L);
247
247
 
248
248
  // Cones.x is the inner phi and cones.y is the outer phi
249
249
  var theta: f32 = mdot(normalize(direction), L);
@@ -314,12 +314,12 @@ fn main(
314
314
  var opacity: f32 = mapperUBO.Opacity;
315
315
 
316
316
  // This should be declared somewhere else
317
- var _diffuseMap: vec4<f32> = vec4<f32>(1);
318
- var _roughnessMap: vec4<f32> = vec4<f32>(1);
319
- var _metallicMap: vec4<f32> = vec4<f32>(1);
320
- var _normalMap: vec4<f32> = vec4<f32>(0, 0, 1, 0); // normal map was setting off the normal vector detection in fragment
321
- var _ambientOcclusionMap: vec4<f32> = vec4<f32>(1);
322
- var _emissionMap: vec4<f32> = vec4<f32>(0);
317
+ var _diffuseMap: vec4<f32> = vec4<f32>(1.0);
318
+ var _roughnessMap: vec4<f32> = vec4<f32>(1.0);
319
+ var _metallicMap: vec4<f32> = vec4<f32>(1.0);
320
+ var _normalMap: vec4<f32> = vec4<f32>(0.0, 0.0, 1.0, 0.0); // normal map was setting off the normal vector detection in fragment
321
+ var _ambientOcclusionMap: vec4<f32> = vec4<f32>(1.);
322
+ var _emissionMap: vec4<f32> = vec4<f32>(0.);
323
323
 
324
324
  //VTK::Color::Impl
325
325
 
@@ -536,7 +536,7 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
536
536
  // Summing diffuse and specular components of directional lights
537
537
  ' {', ' var i: i32 = 0;', ' loop {', ' if !(i < rendererUBO.LightCount) { break; }', ' switch (i32(rendererLightSSBO.values[i].LightData.x)) {', ' // Point Light', ' case 0 {', ' var color: vec3<f32> = rendererLightSSBO.values[i].LightColor.rgb * rendererLightSSBO.values[i].LightColor.w;', ' var pos: vec3<f32> = (rendererLightSSBO.values[i].LightPos).xyz;', ' var calculated: PBRData = calcPointLight(normal, V, fragPos, ior, roughness, metallic, pos, color, baseColor);', ' diffuse += max(vec3<f32>(0), calculated.diffuse);', ' specular += max(vec3<f32>(0), calculated.specular);', ' }', ' // Directional light', ' case 1 {', ' var dir: vec3<f32> = (rendererUBO.WCVCNormals * vec4<f32>(normalize(rendererLightSSBO.values[i].LightDir.xyz), 0.)).xyz;', ' dir = normalize(dir);', ' var color: vec3<f32> = rendererLightSSBO.values[i].LightColor.rgb * rendererLightSSBO.values[i].LightColor.w;', ' var calculated: PBRData = calcDirectionalLight(normal, V, ior, roughness, metallic, dir, color, baseColor); // diffuseColor.rgb needs to be fixed with a more dynamic diffuse color', ' diffuse += max(vec3<f32>(0), calculated.diffuse);', ' specular += max(vec3<f32>(0), calculated.specular);', ' }', ' // Spot Light', ' case 2 {', ' var color: vec3<f32> = rendererLightSSBO.values[i].LightColor.rgb * rendererLightSSBO.values[i].LightColor.w;', ' var pos: vec3<f32> = (rendererLightSSBO.values[i].LightPos).xyz;', ' var dir: vec3<f32> = (rendererUBO.WCVCNormals * vec4<f32>(normalize(rendererLightSSBO.values[i].LightDir.xyz), 0.)).xyz;', ' dir = normalize(dir);', ' var cones: vec2<f32> = vec2<f32>(rendererLightSSBO.values[i].LightData.y, rendererLightSSBO.values[i].LightData.z);', ' var calculated: PBRData = calcSpotLight(normal, V, fragPos, ior, roughness, metallic, pos, dir, cones, color, baseColor);', ' diffuse += max(vec3<f32>(0), calculated.diffuse);', ' specular += max(vec3<f32>(0), calculated.specular);', ' }', ' default { continue; }', ' }', ' continuing { i++; }', ' }', ' }',
538
538
  // Final variables for combining specular and diffuse
539
- ' var fresnel: f32 = schlickFresnelIOR(V, normal, ior, k); // Fresnel', ' fresnel = min(1, fresnel);', ' // This could be controlled with its own variable (that isnt base color) for better artistic control', ' var fresnelMetallic: vec3<f32> = schlickFresnelRGB(V, normal, baseColor); // Fresnel for metal, takes color into account', ' var kS: vec3<f32> = mix(vec3<f32>(fresnel), fresnelMetallic, metallic);', ' kS = min(vec3<f32>(1), kS);', ' var kD: vec3<f32> = (1.0 - kS) * (1.0 - metallic);', ' var PBR: vec3<f32> = mapperUBO.DiffuseIntensity*kD*diffuse + kS*specular;', ' PBR += emission;', ' computedColor = vec4<f32>(PBR, mapperUBO.Opacity);'];
539
+ ' var fresnel: f32 = schlickFresnelIOR(V, normal, ior, k); // Fresnel', ' fresnel = min(1.0, fresnel);', ' // This could be controlled with its own variable (that isnt base color) for better artistic control', ' var fresnelMetallic: vec3<f32> = schlickFresnelRGB(V, normal, baseColor); // Fresnel for metal, takes color into account', ' var kS: vec3<f32> = mix(vec3<f32>(fresnel), fresnelMetallic, metallic);', ' kS = min(vec3<f32>(1.0), kS);', ' var kD: vec3<f32> = (1.0 - kS) * (1.0 - metallic);', ' var PBR: vec3<f32> = mapperUBO.DiffuseIntensity*kD*diffuse + kS*specular;', ' PBR += emission;', ' computedColor = vec4<f32>(PBR, mapperUBO.Opacity);'];
540
540
  if (renderer.getEnvironmentTexture()?.getImageLoaded()) {
541
541
  lightingCode.push(' // To get diffuse IBL, the texture is sampled with normals in worldspace', ' var diffuseIBLCoords: vec3<f32> = (transpose(rendererUBO.WCVCNormals) * vec4<f32>(normal, 1.)).xyz;', ' var diffuseCoords: vec2<f32> = vecToRectCoord(diffuseIBLCoords);', ' // To get specular IBL, the texture is sampled as the worldspace reflection between the normal and view vectors', ' // Reflections are first calculated in viewspace, then converted to worldspace to sample the environment', ' var VreflN: vec3<f32> = normalize(reflect(-V, normal));', ' var reflectionIBLCoords = (transpose(rendererUBO.WCVCNormals) * vec4<f32>(VreflN, 1.)).xyz;', ' var specularCoords: vec2<f32> = vecToRectCoord(reflectionIBLCoords);', ' var diffuseIBL = textureSampleLevel(EnvironmentTexture, EnvironmentTextureSampler, diffuseCoords, rendererUBO.MaxEnvironmentMipLevel);',
542
542
  // Level multiplier should be set by UBO
@@ -25,7 +25,7 @@ fn main(
25
25
  {
26
26
  var output: fragmentOutput;
27
27
 
28
- var computedColor: vec4<f32> = clamp(textureSampleLevel(opaquePassColorTexture, finalPassSampler, input.tcoordVS, 0),vec4<f32>(0.0),vec4<f32>(1.0));
28
+ var computedColor: vec4<f32> = clamp(textureSampleLevel(opaquePassColorTexture, finalPassSampler, input.tcoordVS, 0.0),vec4<f32>(0.0),vec4<f32>(1.0));
29
29
 
30
30
  //VTK::RenderEncoder::Impl
31
31
  return output;
@@ -72,7 +72,7 @@ fn main(
72
72
  var tcoord: vec4<f32> = vec4<f32>(input.vertexVC.xy, -1, 1);
73
73
  var V: vec4<f32> = normalize(mapperUBO.FSQMatrix * tcoord); // vec2<f32>((input.tcoordVS.x - 0.5) * 2, -(input.tcoordVS.y - 0.5) * 2);
74
74
  // textureSampleLevel gets rid of some ugly artifacts
75
- var background = textureSampleLevel(EnvironmentTexture, EnvironmentTextureSampler, vecToRectCoord(V.xyz), 0);
75
+ var background = textureSampleLevel(EnvironmentTexture, EnvironmentTextureSampler, vecToRectCoord(V.xyz), 0.0);
76
76
  var computedColor: vec4<f32> = vec4<f32>(background.rgb, 1);
77
77
 
78
78
  //VTK::RenderEncoder::Impl
@@ -12,7 +12,7 @@ export interface IGetWidgetForViewParams {
12
12
  initialValues?: object;
13
13
  }
14
14
 
15
- export interface vtkAbstractWidgetFactory extends vtkObject {
15
+ export interface vtkAbstractWidgetFactory<WidgetInstance extends vtkAbstractWidget> extends vtkObject {
16
16
  /**
17
17
  * Will return the widget associated with the view with Id id `locator.viewId`.
18
18
  * If there is no widget associated with the view, a new widget will be constructed, provided
@@ -20,7 +20,7 @@ export interface vtkAbstractWidgetFactory extends vtkObject {
20
20
  *
21
21
  * @param {IGetWidgetForViewParams} locator
22
22
  */
23
- getWidgetForView(locator: IGetWidgetForViewParams): Nullable<vtkAbstractWidget>;
23
+ getWidgetForView(locator: IGetWidgetForViewParams): Nullable<WidgetInstance>;
24
24
 
25
25
  /**
26
26
  * Get a list of all the view ids.
@@ -72,7 +72,7 @@ export interface vtkAbstractWidgetFactory extends vtkObject {
72
72
  *
73
73
  * @param {Bounds} bounds
74
74
  */
75
- placeWidget(bounds: Bounds);
75
+ placeWidget(bounds: Bounds): void;
76
76
 
77
77
  /**
78
78
  * Get the place factor.
@@ -107,6 +107,28 @@ export interface vtkAbstractWidgetFactory extends vtkObject {
107
107
  invokeWidgetChangeEvent(...args: unknown[]): void;
108
108
  }
109
109
 
110
+ /**
111
+ * This hack is to "remember" the generic type T that this function turn publicAPI into
112
+ * This is because typescript is completely "structural" and doesn't have any way to declare "nominal" types
113
+ * See: https://github.com/microsoft/TypeScript/issues/202
114
+ * For example, in this code, widgetInstance is a vtkResliceCursorWidgetCPRInstance:
115
+ *
116
+ * import vtkResliceCursorWidget from '@kitware/vtk.js/Widgets/Widgets3D/ResliceCursorWidget';
117
+ * import widgetBehavior from '@kitware/vtk.js/Widgets/Widgets3D/ResliceCursorWidget/cprBehavior';
118
+ *
119
+ * const widget = vtkResliceCursorWidget.newInstance({
120
+ * planes: ['Y', 'Z'],
121
+ * behavior: widgetBehavior,
122
+ * });
123
+ * const widgetInstance = widgetManager.addWidget(widget);
124
+ */
125
+ declare const ExtendSymbol: unique symbol;
126
+ export type ExtendWidgetBehavior<WidgetInstance> = ((publicAPI: object, model: object) => void) & { [ExtendSymbol]: WidgetInstance };
127
+
128
+ export interface IAbstractWidgetFactoryInitialValues<WidgetInstance extends vtkAbstractWidget = vtkAbstractWidget> {
129
+ behavior?: ExtendWidgetBehavior<WidgetInstance>;
130
+ }
131
+
110
132
  /**
111
133
  * Method used to decorate a given object (publicAPI+model) with vtkAbstractWidgetFactory characteristics.
112
134
  *
@@ -114,14 +136,14 @@ export interface vtkAbstractWidgetFactory extends vtkObject {
114
136
  * @param model object on which data structure will be bounds (protected)
115
137
  * @param initialValues (default: {})
116
138
  */
117
- export function extend(publicAPI: object, model: object, initialValues? : object): void;
139
+ export function extend<WidgetInstance extends vtkAbstractWidget = vtkAbstractWidget>(publicAPI: object, model: object, initialValues?: IAbstractWidgetFactoryInitialValues<WidgetInstance>): void;
118
140
 
119
141
  /**
120
142
  * Method used to create a new instance of vtkAbstractWidgetFactory
121
143
  *
122
144
  * @param initialValues for pre-setting some of its content
123
145
  */
124
- export function newInstance(initialValues?: object): vtkAbstractWidgetFactory;
146
+ export function newInstance<WidgetInstance extends vtkAbstractWidget = vtkAbstractWidget>(initialValues?: IAbstractWidgetFactoryInitialValues<WidgetInstance>): vtkAbstractWidgetFactory<WidgetInstance>;
125
147
 
126
148
  export declare const vtkAbstractWidgetFactory: {
127
149
  newInstance: typeof newInstance,
@@ -129,11 +129,11 @@ export interface vtkWidgetManager extends vtkObject {
129
129
  * @param {ViewTypes} [viewType]
130
130
  * @param {Object} [initialValues]
131
131
  */
132
- addWidget(
133
- widget: vtkAbstractWidgetFactory,
132
+ addWidget<WidgetFactory extends vtkAbstractWidgetFactory<any>>(
133
+ widget: WidgetFactory,
134
134
  viewType?: ViewTypes,
135
135
  initialValues?: object
136
- ): Nullable<vtkAbstractWidget>;
136
+ ): WidgetFactory extends vtkAbstractWidgetFactory<infer WidgetInstance> ? WidgetInstance : never;
137
137
 
138
138
  /**
139
139
  * Unregister all widgets from the widget manager.
@@ -145,7 +145,7 @@ export interface vtkWidgetManager extends vtkObject {
145
145
  *
146
146
  * @param {vtkAbstractWidget | vtkAbstractWidgetFactory} widget The widget to remove
147
147
  */
148
- removeWidget(widget: vtkAbstractWidget | vtkAbstractWidgetFactory): void;
148
+ removeWidget(widget: vtkAbstractWidget | vtkAbstractWidgetFactory<any>): void;
149
149
 
150
150
  /**
151
151
  * Given x and y parameter, get selected data.
@@ -165,7 +165,7 @@ export interface vtkWidgetManager extends vtkObject {
165
165
  *
166
166
  * @param {vtkAbstractWidget | vtkAbstractWidgetFactory} widget The widget instance which should get the focus.
167
167
  */
168
- grabFocus(widget: vtkAbstractWidget | vtkAbstractWidgetFactory): void;
168
+ grabFocus(widget: vtkAbstractWidget | vtkAbstractWidgetFactory<any>): void;
169
169
 
170
170
  /**
171
171
  * Release the focus.
@@ -1,8 +1,9 @@
1
- import vtkAbstractWidgetFactory from './../Core/AbstractWidgetFactory';
1
+ import { vtkAbstractWidgetFactory, IAbstractWidgetFactoryInitialValues } from './../Core/AbstractWidgetFactory';
2
+ import vtkAbstractWidget from './../Core/AbstractWidget'
2
3
  import { Bounds } from './../../types';
3
4
  import { ViewTypes } from './../Core/WidgetManager/Constants';
4
5
 
5
- export interface vtkInteractiveOrientationWidget extends vtkAbstractWidgetFactory {
6
+ export interface vtkInteractiveOrientationWidget<WidgetInstance extends vtkAbstractWidget = vtkAbstractWidget> extends vtkAbstractWidgetFactory<WidgetInstance> {
6
7
  /**
7
8
  * Set the widget bounds
8
9
  *
@@ -16,6 +17,8 @@ export interface vtkInteractiveOrientationWidget extends vtkAbstractWidgetFactor
16
17
  getRepresentationForViewType(viewType: ViewTypes): unknown;
17
18
  }
18
19
 
20
+ export interface IInteractiveOrientationWidgetInitialValues<WidgetInstance extends vtkAbstractWidget> extends IAbstractWidgetFactoryInitialValues<WidgetInstance> {}
21
+
19
22
  /**
20
23
  * Method use to decorate a given object (publicAPI+model) with vtkInteractiveOrientationWidget characteristics.
21
24
  *
@@ -23,14 +26,14 @@ export interface vtkInteractiveOrientationWidget extends vtkAbstractWidgetFactor
23
26
  * @param model object on which data structure will be bounds (protected)
24
27
  * @param {object} [initialValues] (default: {})
25
28
  */
26
- export function extend(publicAPI: object, model: object, initialValues? : Record<string, unknown>): void;
29
+ export function extend<WidgetInstance extends vtkAbstractWidget>(publicAPI: object, model: object, initialValues? : IInteractiveOrientationWidgetInitialValues<WidgetInstance>): void;
27
30
 
28
31
  /**
29
32
  * Creates a new instance of vtkInteractiveOrientationWidget
30
33
  *
31
34
  * @param {object} [initialValues] for pre-setting some of its content
32
35
  */
33
- export function newInstance(initialValues? : Record<string, unknown>): vtkInteractiveOrientationWidget;
36
+ export function newInstance<WidgetInstance extends vtkAbstractWidget = vtkAbstractWidget>(initialValues? : IInteractiveOrientationWidgetInitialValues<WidgetInstance>): vtkInteractiveOrientationWidget<WidgetInstance>;
34
37
 
35
38
  export declare const vtkInteractiveOrientationWidget: {
36
39
  newInstance: typeof newInstance,
@@ -0,0 +1,5 @@
1
+ import vtkAbstractWidget from '../../Core/AbstractWidget';
2
+
3
+ export default interface vtkResliceCursorWidgetDefaultInstance extends vtkAbstractWidget {
4
+ invokeInternalInteractionEvent: () => void;
5
+ }
@@ -1,5 +1,7 @@
1
1
  import { mat4 } from 'gl-matrix';
2
- import vtkAbstractWidgetFactory from './../Core/AbstractWidgetFactory';
2
+ import { vtkAbstractWidgetFactory, IAbstractWidgetFactoryInitialValues } from './../Core/AbstractWidgetFactory';
3
+ import vtkResliceCursorWidgetDefaultInstance from './ResliceCursorWidget/behavior';
4
+ import vtkAbstractWidget from './../Core/AbstractWidget'
3
5
  import vtkImageData from './../../Common/DataModel/ImageData';
4
6
  import vtkImageReslice from './../../Imaging/Core/ImageReslice';
5
7
  import vtkPlaneSource from './../../Filters/Sources/PlaneSource';
@@ -16,7 +18,7 @@ export interface IDisplayScaleParams {
16
18
  rendererPixelDims: Vector2
17
19
  }
18
20
 
19
- export interface vtkResliceCursorWidget extends vtkAbstractWidgetFactory {
21
+ export interface vtkResliceCursorWidget<WidgetInstance extends vtkAbstractWidget = vtkResliceCursorWidgetDefaultInstance> extends vtkAbstractWidgetFactory<WidgetInstance> {
20
22
 
21
23
  /**
22
24
  * @param {ViewTypes} viewType
@@ -81,7 +83,7 @@ export interface vtkResliceCursorWidget extends vtkAbstractWidgetFactory {
81
83
 
82
84
  }
83
85
 
84
- export interface IResliceCursorWidgetInitialValues {}
86
+ export interface IResliceCursorWidgetInitialValues<WidgetInstance extends vtkAbstractWidget> extends IAbstractWidgetFactoryInitialValues<WidgetInstance> {}
85
87
 
86
88
  /**
87
89
  * Method used to decorate a given object (publicAPI+model) with vtkResliceCursorWidget characteristics.
@@ -90,18 +92,18 @@ export interface IResliceCursorWidgetInitialValues {}
90
92
  * @param model object on which data structure will be bounds (protected)
91
93
  * @param initialValues (default: {})
92
94
  */
93
- export function extend(
95
+ export function extend<WidgetInstance extends vtkAbstractWidget>(
94
96
  publicAPI: object,
95
97
  model: object,
96
- initialValues?: IResliceCursorWidgetInitialValues
97
- ): vtkResliceCursorWidget;
98
+ initialValues?: IResliceCursorWidgetInitialValues<WidgetInstance>
99
+ ): void;
98
100
 
99
101
  /**
100
102
  * Method used to create a new instance of vtkResliceCursorWidget
101
103
  *
102
104
  * @param initialValues for pre-setting some of its content
103
105
  */
104
- export function newInstance(initialValues?: IResliceCursorWidgetInitialValues): vtkResliceCursorWidget;
106
+ export function newInstance<WidgetInstance extends vtkAbstractWidget = vtkResliceCursorWidgetDefaultInstance>(initialValues?: IResliceCursorWidgetInitialValues<WidgetInstance>): vtkResliceCursorWidget<WidgetInstance>;
105
107
 
106
108
  export declare const vtkResliceCursorWidget: {
107
109
  newInstance: typeof newInstance;
package/index.d.ts CHANGED
@@ -206,9 +206,13 @@
206
206
  /// <reference path="./Rendering/Misc/SynchronizableRenderWindow/ObjectManager.d.ts" />
207
207
  /// <reference path="./Rendering/Misc/SynchronizableRenderWindow.d.ts" />
208
208
  /// <reference path="./Rendering/Misc/TextureLODsDownloader.d.ts" />
209
+ /// <reference path="./Rendering/OpenGL/BufferObject/Constants.d.ts" />
210
+ /// <reference path="./Rendering/OpenGL/BufferObject.d.ts" />
209
211
  /// <reference path="./Rendering/OpenGL/HardwareSelector/Constants.d.ts" />
210
212
  /// <reference path="./Rendering/OpenGL/HardwareSelector.d.ts" />
211
213
  /// <reference path="./Rendering/OpenGL/RenderWindow.d.ts" />
214
+ /// <reference path="./Rendering/OpenGL/Texture/Constants.d.ts" />
215
+ /// <reference path="./Rendering/OpenGL/Texture.d.ts" />
212
216
  /// <reference path="./Rendering/SceneGraph/RenderPass.d.ts" />
213
217
  /// <reference path="./Rendering/SceneGraph/ViewNode.d.ts" />
214
218
  /// <reference path="./Rendering/SceneGraph/ViewNodeFactory.d.ts" />
@@ -228,6 +232,7 @@
228
232
  /// <reference path="./Widgets/Representations/WidgetRepresentation.d.ts" />
229
233
  /// <reference path="./Widgets/Widgets3D/InteractiveOrientationWidget.d.ts" />
230
234
  /// <reference path="./Widgets/Widgets3D/ResliceCursorWidget/Constants.d.ts" />
235
+ /// <reference path="./Widgets/Widgets3D/ResliceCursorWidget/behavior.d.ts" />
231
236
  /// <reference path="./Widgets/Widgets3D/ResliceCursorWidget.d.ts" />
232
237
  /// <reference path="./Widgets/Widgets3D/SeedWidget.d.ts" />
233
238
  /// <reference path="./Widgets/Widgets3D/SphereWidget.d.ts" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "29.4.6",
3
+ "version": "29.5.0",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",