Class: LazyTexture

LazyTexture

new LazyTexture(params)

懒加载纹理

Name Type Description
params object

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

Name Type Default Description
crossOrigin boolean false optional

是否跨域

placeHolder Image optional

占位图片,默认为1像素的透明图片

autoLoad boolean true optional

是否自动加载

src string optional

图片地址

Fires:
  • event:load 加载成功事件
  • event:error 加载失败事件
Example
var material = new Hilo3d.BasicMaterial({
    diffuse: new Hilo3d.LazyTexture({
        crossOrigin: true,
        src: '//img.alicdn.com/tfs/TB1aNxtQpXXXXX1XVXXXXXXXXXX-1024-1024.jpg'
    });
});

Extends

Members Show Inherited

Name Type Default Description
isLazyTexture boolean true
className string LazyTexture
crossOrigin boolean false

图片是否跨域

autoLoad boolean true

是否在设置src后立即加载图片

src string

图片地址

isTexture boolean true inherited
image Image null inherited

图片对象

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

mipmaps

target GLenum gl.TEXTURE_2D inherited

Texture Target

internalFormat GLenum gl.RGBA inherited

Texture Internal Format

format GLenum gl.RGBA inherited

图片 Format

type GLenum gl.UNSIGNED_BYTE inherited

类型

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

magFilter

minFilter GLenum gl.LINEAR inherited

minFilter

wrapS GLenum gl.REPEAT inherited

wrapS

wrapT GLenum gl.REPEAT inherited

wrapT

name string inherited
premultiplyAlpha boolean false inherited
flipY boolean false inherited

是否翻转Texture的Y轴

compressed Boolean false inherited

是否压缩

needUpdate boolean true inherited

是否需要更新Texture

needDestory boolean false inherited

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

autoUpdate boolean false inherited

是否每次都更新Texture

uv Number 0 inherited

uv

anisotropic Number 1 inherited

anisotropic

origWidth Number 0 inherited

获取原始图像宽度。

origHeight Number 0 inherited

获取原始图像高度。

useMipmap Boolean inherited

是否使用 mipmap

useRepeat Boolean inherited

是否使用 repeat

mipmapCount Number inherited

mipmapCount

Methods Show Inherited

load(throwError){Promise}

加载图片

Name Type Default Description
throwError boolean false optional

是否 throw error

Returns:
Type Description
Promise 返回加载的Promise

inherited isImgPowerOfTwo(img){Boolean}

是否是 2 的 n 次方

Name Type Description
img Image
Returns:
Type Description
Boolean

inherited getSupportSize(img, needPowerOfTwo){Object}

获取支持的尺寸

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

inherited resizeImgToPowerOfTwo(img){Canvas|Image}

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

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

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

更新图片大小

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

inherited updateTexture(state, glTexture){Texture}

更新 Texture

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

inherited updateSubTexture(xOffset, yOffset, image)

跟新局部贴图

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

inherited getGLTexture(state){WebGLTexture}

获取 GLTexture

Name Type Description
state WebGLState
Returns:
Type Description
WebGLTexture

inherited 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