If we need load a list of model, should use AssetLibrary to load all the models?

Software: Away3D 4.x

liuyi, Member
Posted: 13 September 2011 09:36 AM   Total Posts: 65

Because there are AssetLibrary, Loader3d, AssetsLoader,

I checked comments in these .as files, it looks like we should use AssetLibrary.

question 1:
But how to use AssetLibrary to load a list?
or only can load model one bye one?

question 2:

how to set model(asset)‘s id?
When we need get a asset from AssetLibrary, AssetLibrary.getAssets();

Where to set it?

the code snippet is very stranger: comment said param id, but where is this param?

/**
   * Retrieves an unloaded resource parsed from the given data.
   * @param data The data to be parsed.
   * @param id The id that will be assigned to the resource. This can later also be used by the getResource method.
   * @param ignoreDependencies Indicates whether or not dependencies should be ignored or loaded.
   * @param parser An optional parser object that will translate the data into a usable resource.
   * @return A handle to the retrieved resource.
   */
  
private function parseResource(data : *, parser ParserBase nullcontext AssetLoaderContext nullns String null) : AssetLoaderToken
  {
   
var loader AssetLoader = new AssetLoader();
   
_loadingSessions.push(loader);
   
loader.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceRetrieved);
   
loader.addEventListener(LoaderEvent.DEPENDENCY_COMPLETEonDependencyRetrieved);
   
loader.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
   
loader.addEventListener(AssetEvent.ANIMATION_COMPLETEonAssetComplete);
   
loader.addEventListener(AssetEvent.ANIMATOR_COMPLETEonAssetComplete);
   
loader.addEventListener(AssetEvent.BITMAP_COMPLETEonAssetComplete);
   
loader.addEventListener(AssetEvent.CONTAINER_COMPLETEonAssetComplete);
   
loader.addEventListener(AssetEvent.GEOMETRY_COMPLETEonAssetComplete);
   
loader.addEventListener(AssetEvent.MATERIAL_COMPLETEonAssetComplete);
   
loader.addEventListener(AssetEvent.MESH_COMPLETEonAssetComplete);
   
loader.addEventListener(AssetEvent.SKELETON_COMPLETEonAssetComplete);
   
loader.addEventListener(AssetEvent.SKELETON_POSE_COMPLETEonAssetComplete);
   return 
loader.parseData(data''parsercontextns);
  

 

   

liuyi, Member
Posted: 13 September 2011 10:14 AM   Total Posts: 65   [ # 1 ]

_model is a obj files, i just want set its name, don’t want set what it depend on.

package  modelLibs
{
 import away3d
.events.AssetEvent;
 
import away3d.events.LoaderEvent;
 
import away3d.library.AssetLibrary;
 
import away3d.loaders.misc.AssetLoaderContext;
 
import flash.display.Sprite;
 
import flash.events.Event;
 
import flash.events.EventDispatcher;
 
import obj3d.Obj3d;
 
import away3d.loaders.parsers.Parsers

 
 
/**
  * ...
  * @author liu yi
  */
 
public class ModelAssets extends EventDispatcher 
 {
  
  [Embed
(source='../../assets/moto/Harley_Davidson_Motorcycle.obj'mimeType='application/octet-stream')]
  
protected var _model:Class;
  
  protected var 
_models:Vector.<Obj3d>;
  protected var 
_assetsLib:AssetLibrary
  
public function ModelAssets() 
  
{
   
   init
();
  
}
  
  
protected function init():void {
   Parsers
.enableAllBundled();
   
_models = new Vector.<Obj3d>();
   
_assetsLib AssetLibrary.getInstance();
   
_assetsLib.parseData(_model);
   
_assetsLib.addEventListener(LoaderEvent.RESOURCE_COMPLETEmodelLoaded);
   
_assetsLib.addEventListener(AssetEvent.ASSET_COMPLETEassetLoaded);
  
}
  
  
private function assetLoaded(e:AssetEvent):void 
  {
   trace
("assets loaded"+e.asset.name)
  
}
  
  
private function modelLoaded(e:LoaderEvent):void 
  {
   dispatchEvent
(new Event("modelLoaded"));
  
}
  
  
  
  
  
  
 }

trace:
assets loadedobj0
assets loadedobj1
assets loadedobj2
assets loadedobj3
assets loadedobj4
assets loadedobj5
GRWorld model loaded

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X