Class: Texture

Texture

new Texture(params)

纹理

Name Type Description
params object

初始化参数,所有params都会复制到实例上

Example
var loader = new Hilo3d.BasicLoader();
loader.load({
    src: '//img.alicdn.com/tfs/TB1aNxtQpXXXXX1XVXXXXXXXXXX-1024-1024.jpg',
    crossOrigin: true
}).then(img => {
    return new Hilo3d.Texture({
        image: img
    });
});

Members Show Inherited

Name Type Default Description
isTexture boolean true
className string Texture
image Image null

图片对象

mipmaps Array.<Image> | Array.<TypedArray> null

mipmaps

target GLenum gl.TEXTURE_2D

Texture Target

internalFormat GLenum gl.RGBA

Texture Internal Format

format GLenum gl.RGBA

图片 Format

type GLenum gl.UNSIGNED_BYTE

类型

width number 0
height number 0
border Number 0
magFilter GLenum gl.LINEAR

magFilter

minFilter GLenum gl.LINEAR

minFilter

wrapS GLenum gl.REPEAT

wrapS

wrapT GLenum gl.REPEAT

wrapT

name string
premultiplyAlpha boolean false
flipY boolean false

是否翻转Texture的Y轴

compressed Boolean false

是否压缩

needUpdate boolean true

是否需要更新Texture

needDestory boolean false

是否需要销毁之前的Texture,Texture参数变更之后需要销毁

autoUpdate boolean false

是否每次都更新Texture

uv Number 0

uv

anisotropic Number 1

anisotropic

origWidth Number 0

获取原始图像宽度。

origHeight Number 0

获取原始图像高度。

useMipmap Boolean

是否使用 mipmap

useRepeat Boolean

是否使用 repeat

mipmapCount Number

mipmapCount

Methods Show Inherited

isImgPowerOfTwo(img){Boolean}

是否是 2 的 n 次方

Name Type Description
img Image
Returns:
Type Description
Boolean

getSupportSize(img, needPowerOfTwo){Object}

获取支持的尺寸

Name Type Default Description
img Image
needPowerOfTwo Boolean false optional
Returns:
Type Description
Object { width, height }

resizeImgToPowerOfTwo(img){Canvas|Image}

更新图片大小成为 2 的 n 次方

Name Type Description
img Image
Returns:
Type Description
Canvas | Image

resizeImg(img, width, height){Canvas|Image}

更新图片大小

Name Type Description
img Image
width Number
height Number
Returns:
Type Description
Canvas | Image

updateTexture(state, glTexture){Texture}

更新 Texture

Name Type Description
state WebGLState
glTexture WebGLTexture
Returns:
Type Description
Texture this

updateSubTexture(xOffset, yOffset, image)

跟新局部贴图

Name Type Description
xOffset Number
yOffset Number
image Image | Canvas | ImageData

getGLTexture(state){WebGLTexture}

获取 GLTexture

Name Type Description
state WebGLState
Returns:
Type Description
WebGLTexture

setGLTexture(texture, needDestroy){Texture}

设置 GLTexture

Name Type Default Description
texture WebGLTexture
needDestroy Boolean false optional

是否销毁之前的 GLTexture

Returns:
Type Description
Texture this

销毁当前Texture

Returns:
Type Description
Texture this

clone

Returns:
Type Description
Texture