Class: Texture2D

zen3d.Texture2D()

new Texture2D()

Creates a cube texture made up of single image.
Source:

Extends

Members

anisotropy :number

The number of samples taken along the axis through the pixel that has the highest density of texels. A higher value gives a less blurry result than a basic mipmap, at the cost of more texture samples being used. Use WebGLcapabilities#maxAnisotropy to find the maximum valid anisotropy value for the GPU; this value is usually a power of 2.
Type:
  • number
Inherited From:
Default Value:
  • 1
Source:

border :number

WebGLTexture border. See WebGLTexture texImage2D(). Must be zero.
Type:
  • number
Inherited From:
Source:

center :zen3d.Vector2

The point around which rotation occurs. A value of (0.5, 0.5) corresponds to the center of the texture. Default is (0, 0), the lower left.
Type:
Default Value:
  • zen3d.Vector2(0, 0)
Source:

compare :zen3d.WEBGL_COMPARE_FUNC|undefined

Use for shadow sampler (WebGL 2.0 Only).
Type:
Inherited From:
Default Value:
  • undefined
Source:

encoding :zen3d.TEXEL_ENCODING_TYPE

texture pixel encoding.
Type:
Inherited From:
Default Value:
  • zen3d.TEXEL_ENCODING_TYPE.LINEAR
Source:

flipY :boolean

Flips the image's Y axis to match the WebGL texture coordinate space.
Type:
  • boolean
Inherited From:
Default Value:
  • true
Source:

format :zen3d.WEBGL_PIXEL_FORMAT

WebGLTexture texel data format.
Type:
Inherited From:
Default Value:
  • zen3d.WEBGL_PIXEL_FORMAT.RGBA
Source:

generateMipmaps :boolean

Whether to generate mipmaps (if possible) for a texture. Set this to false if you are creating mipmaps manually.
Type:
  • boolean
Inherited From:
Default Value:
  • true
Source:

image :null|HTMLImageElement|Object

Image data for this texture.
Type:
  • null | HTMLImageElement | Object
Default Value:
  • null
Source:

internalformat :null|zen3d.WEBGL_PIXEL_FORMAT

WebGLTexture texel data internal format. If null, internalformat is set to be same as format. This must be null in WebGL 1.0.
Type:
Inherited From:
Default Value:
  • null
Source:

magFilter :zen3d.WEBGL_TEXTURE_FILTER

How the texture is sampled when a texel covers more than one pixel.
Type:
Inherited From:
Default Value:
  • zen3d.WEBGL_TEXTURE_FILTER.LINEAR
Source:

matrix :zen3d.Matrix3

The uv-transform matrix for the texture. Updated by the renderer from the texture properties zen3d.Texture2D#offset, zen3d.Texture2D#repeat, zen3d.Texture2D#rotation, and zen3d.Texture2D#center when the texture's zen3d.Texture2D#matrixAutoUpdate property is true. When zen3d.Texture2D#matrixAutoUpdate property is false, this matrix may be set manually. Default is the identity matrix.
Type:
Default Value:
  • Matrix3()
Source:

matrixAutoUpdate :boolean

Whether to update the texture's uv-transform zen3d.Texture2D#matrix from the texture properties zen3d.Texture2D#offset, zen3d.Texture2D#repeat, zen3d.Texture2D#rotation, and zen3d.Texture2D#center. Set this to false if you are specifying the uv-transform matrix directly.
Type:
  • boolean
Default Value:
  • true
Source:

minFilter :zen3d.WEBGL_TEXTURE_FILTER

How the texture is sampled when a texel covers less than one pixel.
Type:
Inherited From:
Default Value:
  • zen3d.WEBGL_TEXTURE_FILTER.LINEAR_MIPMAP_LINEAR
Source:

mipmaps :Array.<HTMLImageElement>|Array.<Object>

Array of user-specified mipmaps (optional).
Type:
  • Array.<HTMLImageElement> | Array.<Object>
Overrides:
Default Value:
  • []
Source:

offset :zen3d.Vector2

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. _Note:_ The offset property is a convenience modifier and only affects the Texture's application to the first set of UVs on a model. If the Texture is used as a map requiring additional UV sets (e.g. the aoMap or lightMap of most stock materials), those UVs must be manually assigned to achieve the desired offset..
Type:
Default Value:
  • zen3d.Vector2(0, 0)
Source:

repeat :zen3d.Vector2

How many times the texture is repeated across the surface, in each direction U and V. If repeat is set greater than 1 in either direction, the corresponding Wrap parameter should also be set to zen3d.WEBGL_TEXTURE_WRAP.REPEAT or zen3d.WEBGL_TEXTURE_WRAP.MIRRORED_REPEAT to achieve the desired tiling effect. _Note:_ The repeat property is a convenience modifier and only affects the Texture's application to the first set of UVs on a model. If the Texture is used as a map requiring additional UV sets (e.g. the aoMap or lightMap of most stock materials), those UVs must be manually assigned to achieve the desired repetiton.
Type:
Default Value:
  • zen3d.Vector2(1, 1)
Source:

rotation :number

How much the texture is rotated around the center point, in radians. Postive values are counter-clockwise.
Type:
  • number
Default Value:
  • 0
Source:

type :zen3d.WEBGL_PIXEL_TYPE

WebGLTexture texel data type.
Type:
Inherited From:
Default Value:
  • zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_BYTE
Source:

useUVTransform :boolean

Whether to use the texture's uv-transform zen3d.Texture2D#matrix from the texture properties zen3d.Texture2D#offset, zen3d.Texture2D#repeat, zen3d.Texture2D#rotation, and zen3d.Texture2D#center. This is only useful when the texture is an alphaMap for Now. Other material map will use a same uv-transform by default.
Type:
  • boolean
Default Value:
  • true
Source:

(readonly) uuid :string

UUID of this texture instance. This gets automatically assigned, so this shouldn't be edited.
Type:
  • string
Inherited From:
Source:

version :number

version code increse if texture changed. if version is still 0, this texture will be skiped.
Type:
  • number
Inherited From:
Default Value:
  • 0
Source:

wrapS :zen3d.WEBGL_TEXTURE_WRAP

This defines how the texture is wrapped horizontally and corresponds to U in UV mapping.
Type:
Inherited From:
Default Value:
  • zen3d.WEBGL_TEXTURE_WRAP.CLAMP_TO_EDGE
Source:

wrapT :zen3d.WEBGL_TEXTURE_WRAP

This defines how the texture is wrapped vertically and corresponds to V in UV mapping.
Type:
Inherited From:
Default Value:
  • zen3d.WEBGL_TEXTURE_WRAP.CLAMP_TO_EDGE
Source:

Methods

(static) fromImage(image) → {TextureCube}

Create Texture2D from image.
Parameters:
Name Type Description
image HTMLImageElement
Source:
Returns:
- The result Texture.
Type
TextureCube

(static) fromSrc(src) → {TextureCube}

Create Texture2D from src.
Parameters:
Name Type Description
src string
Source:
Returns:
- The result Texture.
Type
TextureCube

addEventListener(type, listener, thisObjectopt)

Adds a listener to an event type.
Parameters:
Name Type Attributes Default Description
type string The type of event to listen to.
listener function The function that gets called when the event is fired.
thisObject Object <optional>
this The Object of calling listener method.
Inherited From:
Source:

clone() → {zen3d.TextureBase}

Returns a clone of this texture.
Inherited From:
Source:
Returns:
Type
zen3d.TextureBase

copy(source) → {zen3d.TextureBase}

Copy the given texture into this texture.
Parameters:
Name Type Description
source zen3d.TextureBase The texture to be copied.
Overrides:
Source:
Returns:
Type
zen3d.TextureBase

dispatchEvent(event)

Fire an event type.
Parameters:
Name Type Description
event Object The event that gets fired.
Inherited From:
Source:

dispose()

Dispatches a dispose event.
Inherited From:
Source:

removeEventListener(type, listener, thisObjectopt)

Removes a listener from an event type.
Parameters:
Name Type Attributes Default Description
type string The type of the listener that gets removed.
listener function The listener function that gets removed.
thisObject Object <optional>
this thisObject - The Object of calling listener method.
Inherited From:
Source:

updateMatrix()

Update the texture's uv-transform zen3d.Texture2D#matrix from the texture properties zen3d.Texture2D#offset, zen3d.Texture2D#repeat, zen3d.Texture2D#rotation, and zen3d.Texture2D#center.
Source: