1
1
import { vtkAlgorithm } from '../../../interfaces' ;
2
+ import { Nullable } from '../../../types' ;
2
3
3
4
/**
4
5
*
@@ -15,67 +16,110 @@ export interface ITextureInitialValues {
15
16
16
17
export interface vtkTexture extends vtkAlgorithm {
17
18
/**
18
- *
19
+ * Returns the canvas used by the texture.
20
+ */
21
+ getCanvas ( ) : Nullable < HTMLCanvasElement > ;
22
+
23
+ /**
24
+ * Returns true if the texture is set to repeat at the edges.
19
25
*/
20
26
getRepeat ( ) : boolean ;
21
27
22
28
/**
23
- *
29
+ * Returns true if the texture is set to clamp at the edges.
24
30
*/
25
31
getEdgeClamp ( ) : boolean ;
26
32
27
33
/**
28
- *
34
+ * Returns true if the texture is set to interpolate between texels.
29
35
*/
30
36
getInterpolate ( ) : boolean ;
31
37
32
38
/**
33
- *
39
+ * Returns the image used by the texture.
40
+ */
41
+ getImage ( ) : Nullable < HTMLImageElement > ;
42
+
43
+ /**
44
+ * Returns an ImageBitmap object.
34
45
*/
35
- getImage ( ) : any ;
46
+ getImageBitmap ( ) : Nullable < ImageBitmap > ;
36
47
37
48
/**
38
- *
49
+ * Returns true if the image is loaded.
39
50
*/
40
51
getImageLoaded ( ) : boolean ;
41
52
42
53
/**
43
- *
54
+ * Returns the input image data object.
55
+ */
56
+ getInputAsJsImageData ( ) : Nullable <
57
+ ImageData | ImageBitmap | HTMLCanvasElement | HTMLImageElement
58
+ > ;
59
+
60
+ /**
61
+ * Returns the current mip level of the texture.
44
62
*/
45
63
getMipLevel ( ) : number ;
46
64
47
65
/**
48
- *
49
- * @param repeat
50
- * @default false
66
+ * Returns true if the texture can be resized at run time.
67
+ * This is useful for dynamic textures that may change size based on user
68
+ * interaction or other factors.
51
69
*/
52
- setRepeat ( repeat : boolean ) : boolean ;
70
+ getResizable ( ) : boolean ;
71
+
72
+ /**
73
+ * Returns the canvas used by the texture.
74
+ */
75
+ setCanvas ( canvas : HTMLCanvasElement ) : void ;
53
76
54
77
/**
55
- *
78
+ * Sets the texture to clamp at the edges.
56
79
* @param edgeClamp
57
80
* @default false
58
81
*/
59
82
setEdgeClamp ( edgeClamp : boolean ) : boolean ;
60
83
61
84
/**
62
- *
85
+ * Sets the texture to interpolate between texels.
63
86
* @param interpolate
64
87
* @default false
65
88
*/
66
89
setInterpolate ( interpolate : boolean ) : boolean ;
67
90
68
91
/**
69
- *
92
+ * Sets the image used by the texture.
70
93
* @param image
71
94
* @default null
72
95
*/
73
- setImage ( image : any ) : void ;
96
+ setImage ( image : HTMLImageElement ) : void ;
74
97
75
98
/**
99
+ * Sets the image as an ImageBitmap object.
100
+ * Supported in WebGPU only.
101
+ * @param imageBitmap
102
+ */
103
+ setImageBitmap ( imageBitmap : ImageBitmap ) : void ;
104
+
105
+ /**
106
+ * Sets the input image data as a JavaScript ImageData object.
107
+ * @param imageData
108
+ */
109
+ setJsImageData ( imageData : ImageData ) : void ;
110
+
111
+ /**
112
+ * Sets the current mip level of the texture.
76
113
* @param level
77
114
*/
78
115
setMipLevel ( level : number ) : boolean ;
116
+
117
+ /**
118
+ * Sets the texture to repeat at the edges.
119
+ * @param repeat
120
+ * @default false
121
+ */
122
+ setRepeat ( repeat : boolean ) : boolean ;
79
123
}
80
124
81
125
/**
@@ -98,26 +142,34 @@ export function extend(
98
142
export function newInstance ( initialValues ?: ITextureInitialValues ) : vtkTexture ;
99
143
100
144
/**
101
- * Method used to create mipmaps from given texture data. Works best with textures that have a
102
- * width and a height that are powers of two.
145
+ * Generates mipmaps for a given GPU texture using a compute shader.
146
+ *
147
+ * This function iteratively generates each mip level for the provided texture,
148
+ * using a bilinear downsampling compute shader implemented in WGSL. It creates
149
+ * the necessary pipeline, bind groups, and dispatches compute passes for each
150
+ * mip level.
103
151
*
104
- * @param nativeArray the array of data to create mipmaps from.
105
- * @param width the width of the data
106
- * @param height the height of the data
107
- * @param level the level to which additional mipmaps are generated.
152
+ * @param {GPUDevice } device - The WebGPU device used to create resources and submit commands.
153
+ * @param {GPUTexture } texture - The GPU texture for which mipmaps will be generated.
154
+ * @param {number } mipLevelCount - The total number of mip levels to generate (including the base level).
108
155
*/
109
156
export function generateMipmaps (
110
- nativeArray : any ,
111
- width : number ,
112
- height : number ,
113
- level : number
157
+ device : any ,
158
+ texture : any ,
159
+ mipLevelCount : number
114
160
) : Array < Uint8ClampedArray > ;
115
161
116
162
/**
117
- * vtkTexture is an image algorithm that handles loading and binding of texture maps.
118
- * It obtains its data from an input image data dataset type.
119
- * Thus you can create visualization pipelines to read, process, and construct textures.
120
- * Note that textures will only work if texture coordinates are also defined, and if the rendering system supports texture.
163
+ * vtkTexture is an image algorithm that handles loading and binding of texture
164
+ * maps. It obtains its data from an input image data dataset type. Thus you can
165
+ * create visualization pipelines to read, process, and construct textures. Note
166
+ * that textures will only work if texture coordinates are also defined, and if
167
+ * the rendering system supports texture.
168
+ *
169
+ * This class is used in both WebGL and WebGPU rendering backends, but the
170
+ * implementation details may vary. In WebGL, it uses HTMLImageElement and
171
+ * HTMLCanvasElement for textures, while in WebGPU, it uses HTMLImageElement,
172
+ * HTMLCanvasElement, and ImageBitmap.
121
173
*/
122
174
export declare const vtkTexture : {
123
175
newInstance : typeof newInstance ;
0 commit comments