CanvasTexture - Verge3D User Manual - Soft8Soft
Description: Learn how to use CanvasTexture in your interactive 3D apps made with Verge3D

Texture →

# CanvasTexture

Creates a texture from a `<canvas>` element.

This is almost the same as the base Texture class, except that it sets needsUpdate to `true` immediately.

## Constructor

### CanvasTexture(canvas : HTMLElement, mapping : Constant, wrapS : Constant, wrapT : Constant, magFilter : Constant, minFilter : Constant, format : Constant, type : Constant, anisotropy : Integer)

- canvas — the HTML canvas element from which to load the texture.
- mapping — how the image is applied to the object. An object type of v3d.UVMapping. See mapping constants for other choices.
- wrapS — the default is v3d.ClampToEdgeWrapping. See wrap mode constants for other choices.
- wrapT — the default is v3d.ClampToEdgeWrapping. See wrap mode constants for other choices.
- magFilter — how the texture is sampled when a texel covers more than one pixel. The default is v3d.LinearFilter. See magnification filter constants for other choices.
- minFilter — how the texture is sampled when a texel covers less than one pixel. The default is v3d.LinearMipmapLinearFilter. See minification filter constants for other choices.
- format — the format used in the texture. See format constants for other choices.
- type — default is v3d.UnsignedByteType. See type constants for other choices.
- anisotropy — the number of samples taken along the axis through the pixel that has the highest density of texels. By default, this value is `1`. A higher value gives a less blurry result than a basic mipmap, at the cost of more texture samples being used. Use renderer.getMaxAnisotropy() to find the maximum valid anisotropy value for the GPU; this value is usually a power of 2.

## Properties

See the base Texture class for inherited properties.

### # .isCanvasTexture : Boolean

Read-only flag to check if a given object is of type CanvasTexture.

### # .needsUpdate : Boolean

True by default. This is required so that the canvas data is loaded.

## Methods

See the base Texture class for inherited methods.

## Puzzles

Check out the create canvas elem and replace texture puzzles to manage canvas textures in a code-less manner.

## Source

For more info on how to obtain the source code of this module see this page.