# new TextureCube()
- Source:
Example
...
var mat = new clay.Material({
shader: clay.shader.library.get('clay.phong', 'environmentMap')
});
var envMap = new clay.TextureCube();
envMap.load({
'px': 'assets/textures/sky/px.jpg',
'nx': 'assets/textures/sky/nx.jpg'
'py': 'assets/textures/sky/py.jpg'
'ny': 'assets/textures/sky/ny.jpg'
'pz': 'assets/textures/sky/pz.jpg'
'nz': 'assets/textures/sky/nz.jpg'
});
mat.set('environmentMap', envMap);
...
envMap.success(function () {
// Wait for the sky 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
# 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 :Object
- Source:
Properties:
Name | Type | Description |
---|---|---|
px |
HTMLImageElement | HTMLCanvasElemnet | |
nx |
HTMLImageElement | HTMLCanvasElemnet | |
py |
HTMLImageElement | HTMLCanvasElemnet | |
ny |
HTMLImageElement | HTMLCanvasElemnet | |
pz |
HTMLImageElement | HTMLCanvasElemnet | |
nz |
HTMLImageElement | HTMLCanvasElemnet |
Type:
- Object
# 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>
# pixels :Object
- Source:
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
px |
Uint8Array |
<nullable> |
|
nx |
Uint8Array |
<nullable> |
|
py |
Uint8Array |
<nullable> |
|
ny |
Uint8Array |
<nullable> |
|
pz |
Uint8Array |
<nullable> |
|
nz |
Uint8Array |
<nullable> |
Pixels data of each side. Will be ignored if images are set.
Type:
- Object
# 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 |