Texture
Introduction
vtkTexture is an image algorithm that handles loading and binding of texture maps. It obtains its data from an input image data dataset type. Thus you can create visualization pipelines to read, process, and construct textures. Note that textures will only work if texture coordinates are also defined, and if the rendering system supports texture.
This class is used in both WebGL and WebGPU rendering backends, but the implementation details may vary. In WebGL, it uses HTMLImageElement and HTMLCanvasElement for textures, while in WebGPU, it uses HTMLImageElement, HTMLCanvasElement, and ImageBitmap.
Methods
canGenerateMipmaps
Return true when generateMipmaps can make the mip levels of a texture with this WebGPU format.
| Argument | Type | Required | Description |
|---|---|---|---|
format | String | Yes |
extend
Method use to decorate a given object (publicAPI+model) with vtkTexture characteristics.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | object on which methods will be bounds (public) | |
model | Yes | object on which data structure will be bounds (protected) | |
initialValues | ITextureInitialValues | No | (default: {}) |
getCanvas
Returns the canvas used by the texture.
getCubeMap
Returns true if the texture is a cube map.
getDimensionality
Return the number of non-singleton dimensions in the texture input.
getEdgeClamp
Returns true if the texture is set to clamp at the edges.
getImage
Returns the image used by the texture.
getImageBitmap
Returns an ImageBitmap object.
getImageLoaded
Returns true if the image is loaded.
getInputAsJsImageData
Returns the input image data object.
getInterpolate
Returns true if the texture is set to interpolate between texels.
getJsImageData
Returns the input image data as a JavaScript ImageData object.
getMagFilter
Get the magnification filter. null uses the interpolate flag.
getMaxAnisotropy
Get the maximum anisotropy of the sampler.
getMaxLOD
Get the highest mip level that the sampler uses. null gives the last level.
getMinFilter
Get the minification filter. null uses the interpolate flag.
getMinLOD
Get the lowest mip level that the sampler uses. null gives 0.
getMipLevel
Returns the current mip level of the texture.
getMipmapFilter
Get the filter between mip levels. null gives 'linear'.
getRepeat
Returns true if the texture is set to repeat at the edges.
getResizable
Returns true if the texture can be resized at run time. This is useful for dynamic textures that may change size based on user interaction or other factors.
getWrapR
Get the wrap mode of the R (third) texture coordinate. null uses the wrap mode of the S coordinate. WebGPU only.
getWrapS
Get the horizontal wrap mode, or null to use repeat and edgeClamp.
getWrapT
Get the vertical wrap mode, or null to use repeat and edgeClamp.
imageLoaded
Marks the image as loaded and notifies listeners. Called automatically once the image set with setImage() has loaded.
newInstance
Method use to create a new instance of vtkTexture.
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | ITextureInitialValues | No | for pre-setting some of its content |
setCanvas
Returns the canvas used by the texture.
setCubeMap
Set if the texture is a cube map. A cube map needs image data on each of the six input ports, one for each face, in the sequence +X, -X, +Y, -Y, +Z, -Z.
| Argument | Type | Required | Description |
|---|---|---|---|
cubeMap | Boolean | Yes |
setEdgeClamp
Sets the texture to clamp at the edges.
| Argument | Type | Required | Description |
|---|---|---|---|
edgeClamp | Yes |
setImage
Sets the image used by the texture.
| Argument | Type | Required | Description |
|---|---|---|---|
image | Yes |
setImageBitmap
Sets the image as an ImageBitmap object. Supported in WebGPU only.
| Argument | Type | Required | Description |
|---|---|---|---|
imageBitmap | Yes |
setInterpolate
Sets the texture to interpolate between texels.
| Argument | Type | Required | Description |
|---|---|---|---|
interpolate | Yes |
setJsImageData
Sets the input image data as a JavaScript ImageData object.
| Argument | Type | Required | Description |
|---|---|---|---|
imageData | Yes |
setMagFilter
Set the magnification filter: 'nearest' or 'linear'. WebGPU only.
| Argument | Type | Required | Description |
|---|---|---|---|
magFilter | String | Yes |
setMaxAnisotropy
Set the maximum anisotropy of the sampler, from 1 to 16. A value larger than 1 needs linear min, mag and mipmap filters. WebGPU only.
| Argument | Type | Required | Description |
|---|---|---|---|
maxAnisotropy | Number | Yes |
setMaxLOD
Set the highest mip level that the sampler uses. WebGPU only.
| Argument | Type | Required | Description |
|---|---|---|---|
maxLOD | Number | Yes |
setMinFilter
Set the minification filter: 'nearest' or 'linear'. WebGPU only.
| Argument | Type | Required | Description |
|---|---|---|---|
minFilter | String | Yes |
setMinLOD
Set the lowest mip level that the sampler uses. WebGPU only.
| Argument | Type | Required | Description |
|---|---|---|---|
minLOD | Number | Yes |
setMipLevel
Sets the current mip level of the texture.
| Argument | Type | Required | Description |
|---|---|---|---|
level | Yes |
setMipmapFilter
Set the filter between mip levels: 'nearest' or 'linear'. WebGPU only.
| Argument | Type | Required | Description |
|---|---|---|---|
mipmapFilter | String | Yes |
setRepeat
Sets the texture to repeat at the edges.
| Argument | Type | Required | Description |
|---|---|---|---|
repeat | Yes |
setWrapR
Set the wrap mode of the R (third) texture coordinate: 'repeat', 'clamp-to-edge' or 'mirror-repeat'. WebGPU only.
| Argument | Type | Required | Description |
|---|---|---|---|
wrapR | TextureWrap | Yes |
setWrapS
Set the horizontal wrap mode, or null to use repeat and edgeClamp.
setWrapT
Set the vertical wrap mode, or null to use repeat and edgeClamp.
useCubeMap
Return true when a render backend must upload the texture as a cube map. This is true when the cubeMap flag is set and the six input ports have image data with scalars. Six faces without the cubeMap flag also give a cube map, with a warning one time for each texture.
| Argument | Type | Required | Description |
|---|---|---|---|
texture | vtkTexture | Yes |