Repository

Texture

Texture are bitmap pictures loaded in the graphic card memory so they can be mapped on a geometry surface. Usually, texture are mapped through a Material. Keep in mind that WebGL, as an impletation of OpenGL, shares the same kind of limitations : textures sources should be power of 2 (even if here, Three.js is doing the job of resizing for you if they're not). Constants list for possible texture's mapping mode :

Texture.UVMapping Texture.CubeReflectionMapping Texture.CubeRefractionMapping Texture.EquirectangularReflectionMapping Texture.EquirectangularRefractionMapping Texture.CubeUVReflectionMapping

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

canvas: *

public
public

height: *

public

image: *

public

width: *

Private Members
private

Method Summary

Public Methods
public

Clears the underlying Three.js texture object

public

fromCanvas(canvas: canvas)

Create the texture from a Canvas DOM element (can be Mobilizing itself -> when we'll can catch a WebGL canvas pixels...)

public

fromImage(image: Image)

Create the texture from an image file

public
public

setMapping(mapping: Number)

How the image is applied to the object.

public

Set this to true to trigger an update next time the texture is used.

public

setOffset(val: Numbe)

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

public

False by default, which is the norm for PNG images.

public

setRepeat(u: float, v: float)

Define the repetition factor of this texture.

Public Constructors

public constructor(params: Object) source

Params:

NameTypeAttributeDescription
paramsObject

Parameters object, given by the constructor.

params.imageContext

the Image object.

params.canvasString

the canvas object.

Public Members

public canvas: * source

public cubeCamera: * source

public height: * source

public image: * source

public width: * source

Private Members

private _texture: * source

Public Methods

public erase() source

Clears the underlying Three.js texture object

public fromCanvas(canvas: canvas) source

Create the texture from a Canvas DOM element (can be Mobilizing itself -> when we'll can catch a WebGL canvas pixels...)

Params:

NameTypeAttributeDescription
canvascanvas

canvas

public fromImage(image: Image) source

Create the texture from an image file

Params:

NameTypeAttributeDescription
imageImage

tells if the loader should force the main process to wait for the end of

public getNativeObject(): * source

Return:

*

the Three.js native object used in this class

public setMapping(mapping: Number) source

How the image is applied to the object. An object type of Texture.UVMapping is the default, where the U,V coordinates are used to apply the map.

Params:

NameTypeAttributeDescription
mappingNumber

public setNeedsUpdate(val: Boolean) source

Set this to true to trigger an update next time the texture is used. Particularly important for setting the wrap mode.

Params:

NameTypeAttributeDescription
valBoolean

public setOffset(val: Numbe) source

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.

Params:

NameTypeAttributeDescription
valNumbe

offset between 0.0 to 1.0

public setPremultiplyAlpha(val: Boolean) source

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

Params:

NameTypeAttributeDescription
valBoolean

public setRepeat(u: float, v: float) source

Define the repetition factor of this texture. If the value is > 1, then the texture will be mapped twice on the surface and so on. NB: usage of this method automatically sets the wrapS and wrapT properties to RepeatWrapping

Params:

NameTypeAttributeDescription
ufloat

the new u texture coordinate repetition to use

vfloat

the new u texture coordinate repetition to use