Away3D 3.6 Load 3D Object

Software: Away3D 3.x

Sellew, Newbie
Posted: 09 September 2012 05:51 PM   Total Posts: 7

Hi all,

I am pretty new to Away3D. I am wondering how to load object model (awd or obj) in Away3d 3.6. I’ve searched the web and couldn’t find any working sample. For example, I use Flash Professional CS5 to build the following code for Flash Player 10 and it gives an error. Can someone help me with this simple loading?

package
{
 import away3d
.containers.View3D;
 
import away3d.events.Loader3DEvent;
 
import away3d.loaders.Loader3D;
 
import away3d.loaders.AWData;
 
import away3d.primitives.Cube;
 
 
import flash.display.Sprite;
 
import flash.events.Event;
 
import flash.net.URLRequest;
 
 public class 
Main extends Sprite
 {
  
private var _view View3D;
  private var 
_loader Loader3D;

  private var 
cube:Cube;
  
  private var 
_awDataAWData;
    
  public function 
Main()
  
{
   _view 
= new View3D();
   
   
this.addChild(_view);
   
this.addEventListener(Event.ENTER_FRAMEonEnterFrame);
   
   
//I draw a cube to see know the code is still run well when the awd object doesn't appear
   
cube = new Cube({width:75height:75depth:75});
   
_view.scene.addChild(cube);
   
            
//loader doesn't work
            
_loader AWData.load("Building_awd1.awd"{x:200y:-200z0}) ;
            
_view.scene.addChild_loader );
  
}
  
  
private function onEnterFrame(ev Event) : void
  {
   _view
.render();
  
}
 }

 

   

Avatar
Fabrice Closier, Administrator
Posted: 09 September 2012 08:39 PM   Total Posts: 1265   [ # 1 ]

Take a look at the svn
http://away3d.googlecode.com/svn/trunk/fp10/Examples/

On the pict you have the loaderCube, this was the loader3D 3.x default way to tell you that an url wasn’t found or busy to load.

If you are busy in flash 10, use Prefab 1.x and look at the as3 exports. Many of your questions may be answered in there.

   

Sellew, Newbie
Posted: 10 September 2012 05:36 AM   Total Posts: 7   [ # 2 ]

Thanks for your help. In the SVN, I found a Basic_LoadModel.as and hoped it can help to solve my problem.

http://away3d.googlecode.com/svn/trunk/fp10/Examples/Away3D/as/src/Basic_LoadModel.as

   

Sellew, Newbie
Posted: 10 September 2012 08:48 AM   Total Posts: 7   [ # 3 ]

I am almost there. I run the following code and there is an error in Loader3D/notifySuccess(). I traced the error and it was happened in _result.transform = transform;.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at away3d.loaders::Loader3D/notifySuccess()
at away3d.loaders::Loader3D/notifyMaterialLibrary()
at away3d.loaders::Loader3D/onParserComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at away3d.loaders::AbstractParser/notifySuccess()
at away3d.loaders::AbstractParser/parseNext()
at away3d.loaders::AbstractParser/parseGeometry()
at away3d.loaders::Loader3D/loadTextures()
at away3d.loaders::Loader3D/onGeometryComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()


Can anyone please help me to solve this problem? I really want to get the loading started. Many thanks!

I am using Flash Professional CS5 and Away3D 3.6.0

package
{
 import away3d
.containers.View3D;
 
import away3d.loaders.Loader3D;
 
import away3d.loaders.AWData;
 
import away3d.events.Loader3DEvent;
 
 
import flash.display.Sprite;
 
import flash.events.Event;
 
import flash.net.URLRequest;
 
 public class 
LoaderAWDTest extends Sprite
 {
  
private var _view View3D;
  private var 
_loader Loader3D;
  
  public function 
LoaderAWDTest()
  
{
   _view 
= new View3D();
   
_view.camera.= -2000;
   
addChild(_view);
   
   
_loader = new Loader3D();
   
_loader.loadGeometry('assets/Building8.awd', new AWData());
   
_loader.addEventListener(Loader3DEvent.LOAD_SUCCESSonLoadSuccess);

   
this.addEventListener(Event.ENTER_FRAMEhandleEnterFrame);
  
}
  
  
private function onLoadSuccess(Event) : void{
   _view
.scene.addChild(_loader);
  
}
  
  
private function handleEnterFrame(Event) : void
  {
   _view
.render();
  
}
 }
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X