Texture

Texture

Texture defines a texture object to be used to display an image on a piece of geometry. The image to be displayed is
defined by the Image class. All attributes required for texture mapping are contained within this class. This includes
mipmapping if desired, magnificationFilter options, apply options and correction options. Default values are as follows:
minificationFilter - NearestNeighborNoMipMaps, magnificationFilter - NearestNeighbor, wrap - EdgeClamp on S, T and R, apply - Modulate,
environment - None.

Constructor

new Texture(image, settings, width, height)

Parameters:
Name Type Description
image Image

Image to use as base for texture

settings Object

Texturing settings

Properties
Name Type Attributes Default Description
wrapS string <optional>
'Repeat'

possible values:


  • 'Repeat' = Repeat texture (ignore integer part of texture coords)
  • 'MirroredRepeat' = Repeat with reversed direction on odd integer part of texture coords
  • 'EdgeClamp' = Clamp texture coord range to 0..1 and use edge color

wrapT string <optional>
'Repeat'

possible values:


  • 'Repeat' = Repeat texture (ignore integer part of texture coords)
  • 'MirroredRepeat' = Repeat with reversed direction on odd integer part of texture coords
  • 'EdgeClamp' = Clamp texture coord range to 0..1 and use edge color

magFilter string <optional>
'Bilinear'

possible values:


  • 'NearestNeighbor' =
  • 'Bilinear' =

minFilter string <optional>
'TriLinear'

possible values:


  • 'NearestNeighborNoMipMaps' =
  • 'NearestNeighborNearestMipMap' =
  • 'NearestNeighborLinearMipMap' =
  • 'BilinearNoMipMaps' =
  • 'BilinearNearestMipMap' =
  • 'Trilinear' =

anisotropy number <optional>
1

Amount of anisotropic filtering (1=1x, 4=4x etc, max usually 4 or 16. Card max in Capabilities.maxAnisotropy)

format string <optional>
'RGBA'

possible values:


  • 'RGBA' =
  • 'RGB' =
  • 'Alpha' =
  • 'Luminance' =
  • 'LuminanceAlpha' =

type string <optional>
'UnsignedByte'

possible values:


  • 'UnsignedByte' =
  • 'UnsignedShort565' =
  • 'UnsignedShort4444' =
  • 'UnsignedShort5551' =
  • 'Float' =

offset Array <optional>
(0, 0)

Texture offset

repeat Array <optional>
(1, 1)

Texture repeat/scale

generateMipmaps boolean <optional>
'true'

Automatically generate mipmaps

premultiplyAlpha boolean <optional>
'false'

Premultiply alpha

unpackAlignment number <optional>
1

Unpack alignment setting

flipY boolean <optional>
'true'

Flip texture in y-axis

hdr boolean <optional>
false

true if the texture contains hdr images

encoding number <optional>
Texture.ENCODING.LINEAR

possible values:


  • Texture.ENCODING.LINEAR = 0
  • Texture.ENCODING.RGBE = 1
  • Texture.ENCODING.RGBM = 2

mipLevel number <optional>
0

The miplevel of the texture. if generateMipMaps is true, mipLevel will be ignored

texCoord number <optional>
0

The UV of the texture. If the number is set, The UV TEXCOORD${settings.texCoord} will be used. Only support 0 or 1 at this moment.

width number

Width of the texture

height number

Height of the texture

Members

anisotropy :number

The anisotropic filtering level.

loadImage :function

If the Texture was set to load lazily in the TextureHandler, then this method can be used to load the image at a later point. This function returns a promise that resolves when the image was loaded.

publicAsset

Gets the public api Texture object for this internal api Texture object.

Methods

(static) forPublicAsset(publicAsset) → {Texture}

Gets the internal api Asset object for a specified public api Texture object.

Parameters:
Name Type Description
publicAsset Asset

The public api Texture object.

checkDataReady() → {boolean}

Checks if the texture's data is ready.

checkNeedsUpdate() → {boolean}

Checks if the texture needs an update.

clone() → {Texture}

Returns a clone of this plane

destroy(context)

Releases the allocated texture

Parameters:
Name Type Description
context WebGLRenderingContext

getSizeInMemory() → {number}

Returns the number of bytes this texture occupies in memory

setImage(image, widthopt, heightopt, settingsopt)

Sets an image on the texture object.

Parameters:
Name Type Attributes Description
image Image

The image to set. Can be an Image, TypedArray or an array of Images (for cubemaps)

width number <optional>
height number <optional>
settings Object <optional>

setNeedsUpdate()

Marks the texture as needing to be updated by the engine.