-
new LoadQueue(source)
-
队列加载器,用于批量加载
Name Type Description source
Array optional 需要加载的资源列表
Fires:
- event:complete 完成事件
- event:load 加载事件
- event:error 错误事件
Example
var loadQueue = new Hilo3d.LoadQueue([{ type: 'CubeTexture', images: [ '//gw.alicdn.com/tfs/TB1Ss.ORpXXXXcNXVXXXXXXXXXX-2048-2048.jpg_960x960.jpg', '//gw.alicdn.com/tfs/TB1YhUDRpXXXXcyaXXXXXXXXXXX-2048-2048.jpg_960x960.jpg', '//gw.alicdn.com/tfs/TB1Y1MORpXXXXcpXVXXXXXXXXXX-2048-2048.jpg_960x960.jpg', '//gw.alicdn.com/tfs/TB1ZgAqRpXXXXa0aFXXXXXXXXXX-2048-2048.jpg_960x960.jpg', '//gw.alicdn.com/tfs/TB1IVZNRpXXXXaNXFXXXXXXXXXX-2048-2048.jpg_960x960.jpg', '//gw.alicdn.com/tfs/TB1M3gyRpXXXXb9apXXXXXXXXXX-2048-2048.jpg_960x960.jpg' ] }, { src: '//ossgw.alicdn.com/tmall-c3/tmx/0356679fd543809bba95dfaea32e1d45.gltf' }]).on('complete', function () { var result = loadQueue.getAllContent(); var box = new Hilo3d.Mesh({ geometry: geometry, material: new Hilo3d.BasicMaterial({ lightType: 'NONE', cullFaceType: Hilo3d.constants.FRONT, diffuse: result[0] }) }).addTo(stage); box.setScale(20); var material = new Hilo3d.BasicMaterial({ diffuse: new Hilo3d.Color(0, 0, 0), skyboxMap: result[0], refractRatio: 1/1.5, refractivity: 0.8, reflectivity: 0.2 }); var model = result[1]; model.node.setScale(0.001); model.meshes.forEach(function (m) { m.material = material; }); stage.addChild(model.node); }).start();
Mixes In
Members Show Inherited
Name | Type | Default | Description |
---|---|---|---|
isLoadQueue
|
boolean | true | |
className
|
string | LoadQueue | |
maxConnections
|
number | 2 |
最大并发连接数 |
Methods Show Inherited
-
staticLoadQueue.addLoader(ext, LoaderClass)
-
给LoadQueue类添加扩展Loader
Name Type Description ext
string 资源扩展,如gltf, png 等
LoaderClass
BasicLoader 用于加载的类,需要继承BasicLoader
-
add(source)
-
添加需要加载的资源
Name Type Description source
object 资源信息
Name Type Description src
string 资源地址
id
string optional 资源id
type
string optional 资源类型,对应ext,不传的话自动根据src来获取
size
number optional 资源大小,用于精确计算当前加载进度
-
get(id){object}
-
获取指定id的资源
Name Type Description id
string id
Returns:
Type Description object 返回对应的资源信息 -
getContent(id){object}
-
获取指定id加载完后的数据
Name Type Description id
string id
Returns:
Type Description object 加载完的结果 -
getLoaded(){number}
-
获取当前已经加载完的资源数量
Returns:
Type Description number -
getTotal(){number}
-
获取需要加载的资源总数
Returns:
Type Description number -
getAllContent(){Array}
-
获取加载的所有资源结果
Returns:
Type Description Array 加载的所有资源结果