Skip to content

Commit b7f9c1e

Browse files
committed
Merge remote-tracking branch 'origin/master' into beta
2 parents c9d363a + 345f25c commit b7f9c1e

File tree

5 files changed

+608
-491
lines changed

5 files changed

+608
-491
lines changed

Sources/Rendering/Core/Texture/index.d.ts

Lines changed: 81 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { vtkAlgorithm } from '../../../interfaces';
2+
import { Nullable } from '../../../types';
23

34
/**
45
*
@@ -15,67 +16,110 @@ export interface ITextureInitialValues {
1516

1617
export interface vtkTexture extends vtkAlgorithm {
1718
/**
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.
1925
*/
2026
getRepeat(): boolean;
2127

2228
/**
23-
*
29+
* Returns true if the texture is set to clamp at the edges.
2430
*/
2531
getEdgeClamp(): boolean;
2632

2733
/**
28-
*
34+
* Returns true if the texture is set to interpolate between texels.
2935
*/
3036
getInterpolate(): boolean;
3137

3238
/**
33-
*
39+
* Returns the image used by the texture.
40+
*/
41+
getImage(): Nullable<HTMLImageElement>;
42+
43+
/**
44+
* Returns an ImageBitmap object.
3445
*/
35-
getImage(): any;
46+
getImageBitmap(): Nullable<ImageBitmap>;
3647

3748
/**
38-
*
49+
* Returns true if the image is loaded.
3950
*/
4051
getImageLoaded(): boolean;
4152

4253
/**
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.
4462
*/
4563
getMipLevel(): number;
4664

4765
/**
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.
5169
*/
52-
setRepeat(repeat: boolean): boolean;
70+
getResizable(): boolean;
71+
72+
/**
73+
* Returns the canvas used by the texture.
74+
*/
75+
setCanvas(canvas: HTMLCanvasElement): void;
5376

5477
/**
55-
*
78+
* Sets the texture to clamp at the edges.
5679
* @param edgeClamp
5780
* @default false
5881
*/
5982
setEdgeClamp(edgeClamp: boolean): boolean;
6083

6184
/**
62-
*
85+
* Sets the texture to interpolate between texels.
6386
* @param interpolate
6487
* @default false
6588
*/
6689
setInterpolate(interpolate: boolean): boolean;
6790

6891
/**
69-
*
92+
* Sets the image used by the texture.
7093
* @param image
7194
* @default null
7295
*/
73-
setImage(image: any): void;
96+
setImage(image: HTMLImageElement): void;
7497

7598
/**
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.
76113
* @param level
77114
*/
78115
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;
79123
}
80124

81125
/**
@@ -98,26 +142,34 @@ export function extend(
98142
export function newInstance(initialValues?: ITextureInitialValues): vtkTexture;
99143

100144
/**
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.
103151
*
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).
108155
*/
109156
export function generateMipmaps(
110-
nativeArray: any,
111-
width: number,
112-
height: number,
113-
level: number
157+
device: any,
158+
texture: any,
159+
mipLevelCount: number
114160
): Array<Uint8ClampedArray>;
115161

116162
/**
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.
121173
*/
122174
export declare const vtkTexture: {
123175
newInstance: typeof newInstance;

0 commit comments

Comments
 (0)