-
new ShaderMaterialLoader()
-
ShaderMaterial加载类
Example
var loader = new Hilo3d.ShaderMaterialLoader(); loader.load({ fs: './test.frag', vs: './test.vert', attributes: { a_pos: { semantic: 'POSITION' }, a_uv: { semantic: 'TEXCOORD_0' } }, uniforms: { u_mat: { semantic:'MODELVIEWPROJECTION' }, u_diffuse: { semantic: 'DIFFUSE' } }, diffuse: new Hilo3d.LazyTexture({ crossOrigin: true, src: '//img.alicdn.com/tfs/TB1va2xQVXXXXaFapXXXXXXXXXX-1024-710.jpg' }) }).then(material => { var geometry = new Hilo3d.PlaneGeometry(); var plane = new Hilo3d.Mesh({ material: material, geometry: geometry }); stage.addChild(plane); });
Extends
Members Show Inherited
Name | Type | Default | Description |
---|---|---|---|
isShaderMaterialLoader
|
boolean | true | |
className
|
string | ShaderMaterialLoader | |
isBasicLoader
|
boolean | true | inherited |
Methods Show Inherited
-
load(params){Promise.<ShaderMaterial, Error>}
-
加载ShaderMaterial
Name Type Description params
object 加载参数,所有参数均会传递给 ShaderMaterial 的构造器
Name Type Description fs
string fragment shader 文件的地址
vs
string vertex shader 文件的地址
Returns:
Type Description Promise.<ShaderMaterial, Error> 返回加载完的ShaderMaterial实例 -
inherited isCrossOrigin(url){boolean}
-
判断链接是否跨域,无法处理二级域名,及修改 document.domain 的情况
Name Type Description url
string 需要判断的链接
Returns:
Type Description boolean 是否跨域 -
inherited loadImg(url, crossOrigin){Promise.<HTMLImageElement, Error>}
-
加载图片
Name Type Default Description url
string 图片地址
crossOrigin
boolean false optional 是否跨域
Returns:
Type Description Promise.<HTMLImageElement, Error> 返回加载完的图片 -
inherited loadRes(url, type){Promise.<any, Error>}
-
使用XHR加载其他资源
Name Type Default Description url
string 资源地址
type
string text optional 资源类型(json, buffer, text)
Returns:
Type Description Promise.<any, Error> 返回加载完的内容对象(Object, ArrayBuffer, String) -
inherited request(opt){Promise.<any, Error>}
-
XHR资源请求
Name Type Description opt
object 请求参数
Name Type Default Description url
string 资源地址
type
string text optional 资源类型(json, buffer, text)
method
string GET optional 请求类型(GET, POST ..)
headers
object optional 请求头参数
body
string optional POST请求发送的数据
Returns:
Type Description Promise.<any, Error> 返回加载完的内容对象(Object, ArrayBuffer, String)