# new Texture2D()
- Source:
Example
...
var mat = new clay.Material({
shader: clay.shader.library.get('clay.phong', 'diffuseMap')
});
var diffuseMap = new clay.Texture2D();
diffuseMap.load('assets/textures/diffuse.jpg');
mat.set('diffuseMap', diffuseMap);
...
diffuseMap.success(function () {
// Wait for the diffuse texture loaded
animation.on('frame', function (frameTime) {
renderer.render(scene, camera);
});
});
Extends
Members
# __uid__ :number
- Source:
- Inherited From:
Type:
- number
# anisotropic :number
- Source:
- Inherited From:
- See:
Anisotropic filtering, enabled if value is larger than 1
Type:
- number
# convertToPOT :boolean
- Source:
If convert texture to power-of-two
Type:
- boolean
# dynamic :boolean
- Source:
- Inherited From:
Dynamic option for texture like video
Type:
- boolean
# flipY :boolean
- Source:
- Inherited From:
- Default Value:
- true
If flip in y axis for given image source
Type:
- boolean
# format :number
- Source:
- Inherited From:
Format of texel data Possible values:
Type:
- number
# height :number
- Source:
- Inherited From:
Texture height, readonly when the texture source is image
Type:
- number
# image :HTMLImageElement|HTMLCanvasElemnet
- Source:
Type:
- HTMLImageElement | HTMLCanvasElemnet
# magFilter :number
- Source:
- Inherited From:
Possible values:
Type:
- number
# minFilter :number
- Source:
- Inherited From:
Possible values:
Type:
- number
# mipmaps :Array.<Object>
- Source:
Type:
- Array.<Object>
Example
[{
image: mipmap0,
pixels: null
}, {
image: mipmap1,
pixels: null
}, ....]
# pixels :Uint8Array|Float32Array
- Source:
Pixels data. Will be ignored if image is set.
Type:
- Uint8Array | Float32Array
# premultiplyAlpha :boolean
- Source:
- Inherited From:
- Default Value:
- false
Type:
- boolean
# sRGB
- Source:
- Inherited From:
A flag to indicate if texture source is sRGB
# type :number
- Source:
- Inherited From:
Texel data type. Possible values:
Type:
- number
# unpackAlignment :number
- Source:
- Inherited From:
- Default Value:
- 4
Type:
- number
# useMipmap :boolean
- Source:
- Inherited From:
If enable mimap.
Type:
- boolean
# width :number
- Source:
- Inherited From:
Texture width, readonly when the texture source is image
Type:
- number
# wrapS :number
- Source:
- Inherited From:
Texture wrap. Default to be REPEAT. Possible values:
Type:
- number
# wrapT :number
- Source:
- Inherited From:
Texture wrap. Default to be REPEAT. Possible values:
Type:
- number
Methods
# after(name, action, contextopt)
- Source:
- Inherited From:
- Mixes In:
Alias of once('after' + name)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | ||
action |
function | ||
context |
Object |
<optional> |
# before(name, action, contextopt)
- Source:
- Inherited From:
- Mixes In:
Alias of once('before' + name)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | ||
action |
function | ||
context |
Object |
<optional> |
# dirty()
- Source:
- Inherited From:
Mark texture is dirty and update in the next frame
# dispose(renderer)
- Source:
- Inherited From:
Parameters:
Name | Type | Description |
---|---|---|
renderer |
clay.Renderer |
# error(action, contextopt)
- Source:
- Inherited From:
- Mixes In:
Alias of on('error')
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
action |
function | ||
context |
Object |
<optional> |
# generateMipmap(renderer)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
renderer |
clay.Renderer |
# has(name, action) → {boolean}
- Source:
- Inherited From:
- Mixes In:
If registered the event handler
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
action |
function |
Returns:
- Type
- boolean
# isPowerOfTwo() → {boolean}
- Source:
- Inherited From:
Test if texture size is power of two
Returns:
- Type
- boolean
# isRenderable() → {boolean}
- Source:
- Inherited From:
Test if image of texture is valid and loaded.
Returns:
- Type
- boolean
# off(action, contextopt)
- Source:
- Inherited From:
- Mixes In:
Remove event listener
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
action |
function | ||
context |
Object |
<optional> |
# on(name, action, contextopt)
- Source:
- Inherited From:
- Mixes In:
Register event handler
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | ||
action |
function | ||
context |
Object |
<optional> |
# once(name, action, contextopt)
- Source:
- Inherited From:
- Mixes In:
Register event, event will only be triggered once and then removed
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | ||
action |
function | ||
context |
Object |
<optional> |
# success(action, contextopt)
- Source:
- Inherited From:
- Mixes In:
Alias of on('success')
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
action |
function | ||
context |
Object |
<optional> |
# trigger(name)
- Source:
- Inherited From:
- Mixes In:
Trigger event
Parameters:
Name | Type | Description |
---|---|---|
name |
string |