import Texture from '@mobilizing/library/js/Mobilizing/renderer/3D/three/texture/Texture.js'
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 | constructor(params: Object) |
Member Summary
Public Members | ||
public | canvas: * | |
public | cubeCamera: * | |
public | height: * | |
public | image: * | |
public | width: * |
Private Members | ||
private | _texture: * |
Method Summary
Public Methods | ||
public | erase() 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 | getNativeObject(): * | |
public | setMapping(mapping: Number) How the image is applied to the object. | |
public | setNeedsUpdate(val: Boolean) 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 | setPremultiplyAlpha(val: Boolean) 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 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:
Name | Type | Attribute | Description |
canvas | canvas | canvas |
public fromImage(image: Image) source
Create the texture from an image file
Params:
Name | Type | Attribute | Description |
image | Image | 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:
Name | Type | Attribute | Description |
mapping | Number |
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:
Name | Type | Attribute | Description |
val | Boolean |
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:
Name | Type | Attribute | Description |
val | Numbe | 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:
Name | Type | Attribute | Description |
val | Boolean |
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:
Name | Type | Attribute | Description |
u | float | the new u texture coordinate repetition to use | |
v | float | the new u texture coordinate repetition to use |