[name]

Create a texture to apply to a surface or as a reflection or refraction map.

Constructor

[name]( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy )

Example

// load a texture, set wrap mode to repeat var texture = THREE.ImageUtils.loadTexture( "textures/water.jpg" ); texture.wrapS = THREE.RepeatWrapping; texture.wrapT = THREE.RepeatWrapping; texture.repeat.set( 4, 4 );

Properties

.[page:Image image]

An Image object, typically created using the ImageUtils or [page:ImageLoader ImageLoader] classes. The Image object can include an image (e.g., PNG, JPG, GIF, DDS), video (e.g., MP4, OGG/OGV), or set of six images for a cube map.

.[page:object mapping]

How the image is applied to the object. An object type of THREE.UVMapping() is the default, where the U,V coordinates are used to apply the map, and a single texture is expected. The other types are THREE.CubeReflectionMapping, for cube maps used as a reflection map; THREE.CubeRefractionMapping, refraction mapping; THREE.SphericalReflectionMapping, a spherical reflection map projection; and THREE.SphericalRefractionMapping.

.[page:number wrapS]

The default is THREE.ClampToEdgeWrapping, where the edge is clamped to the outer edge texels. The other two choices are THREE.RepeatWrapping and THREE.MirroredRepeatWrapping.

.[page:number wrapT]

The default is THREE.ClampToEdgeWrapping, where the edge is clamped to the outer edge texels. The other two choices are THREE.RepeatWrapping and THREE.MirroredRepeatWrapping.

.[page:number magFilter]

How the texture is sampled when a texel covers more than one pixel. The default is THREE.LinearFilter, which takes the four closest texels and bilinearly interpolates among them. The other option is THREE.NearestFilter, which uses the value of the closest texel.

.[page:number minFilter]

How the texture is sampled when a texel covers less than one pixel. The default is THREE.LinearMipMapLinearFilter, which uses mipmapping and a trilinear filter. Other choices are THREE.NearestFilter, THREE.NearestMipMapNearestFilter, THREE.NearestMipMapLinearFilter, THREE.LinearFilter, and THREE.LinearMipMapNearestFilter. These vary whether the nearest texel or nearest four texels are retrieved on the nearest mipmap or nearest two mipmaps. Interpolation occurs among the samples retrieved.

.[page:number format]

The default is THREE.RGBAFormat for the texture. Other formats are: THREE.AlphaFormat, THREE.RGBFormat, THREE.LuminanceFormat, and THREE.LuminanceAlphaFormat. There are also compressed texture formats, if the S3TC extension is supported: THREE.RGB_S3TC_DXT1_Format, THREE.RGBA_S3TC_DXT1_Format, THREE.RGBA_S3TC_DXT3_Format, and THREE.RGBA_S3TC_DXT5_Format.

.[page:number type]

The default is THREE.UnsignedByteType. Other valid types (as WebGL allows) are THREE.ByteType, THREE.ShortType, THREE.UnsignedShortType, THREE.IntType, THREE.UnsignedIntType, THREE.FloatType, THREE.UnsignedShort4444Type, THREE.UnsignedShort5551Type, and THREE.UnsignedShort565Type.

.[page:number 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.

.[page:boolean needsUpdate]

If a texture is changed after creation, set this flag to true so that the texture is properly set up. Particularly important for setting the wrap mode.

.[page:Vector2 repeat]

How many times the texture is repeated across the surface, in each direction U and V.

.[page:Vector2 offset]

How much a single repetition of the texture is offset from the beginning, in each direction U and V. Typical range is 0.0 to 1.0.

.[page:string name]

Given name of the texture, empty string by default.

.[page:boolean generateMipmaps]

Whether to generate mipmaps (if possible) for a texture. True by default.

.[page:boolean flipY]

False by default, set this to true if the texture needs to be flipped vertically.

.[page:array mipmaps]

Array of mipmaps generated.

.[page:number unpackAlignment]

4 by default. Specifies the alignment requirements for the start of each pixel row in memory. The allowable values are 1 (byte-alignment), 2 (rows aligned to even-numbered bytes), 4 (word-alignment), and 8 (rows start on double-word boundaries). See glPixelStorei for more information.

.[page:boolean premultiplyAlpha]

False by default, which is the norm for PNG images. Set to true if the RGB values have been stored premultiplied by alpha.

.[page:object onUpdate]

A callback function, called when the texture is updated (e.g., when needsUpdate has been set to true and then the texture is used).

.[page:number id]

An internal ID number, starting from 0; should not be modified. THREE.TextureIdCount is the number of textures created so far.

Methods

[page:EventDispatcher EventDispatcher] methods are available on this class.

.clone([page:todo texture]) [page:todo]

Make copy of texture. Note this is not a "deep copy", the image is shared.
todo

.dispose() [page:todo]

Call [page:EventDispatcher EventDispatcher].dispatchEvent with a 'dispose' event type.

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]