Load a 3d Object without embedding?

Software: Away3D 4.x

dubletar, Member
Posted: 09 May 2012 05:56 PM   Total Posts: 73

Hi,

The code for the class is below.

My question is two-fold: (1) Is it absolutely necessary to load a 3d Object by embedding it? (2) Is there a way to load a 3d object without Embedding it?

package  
{
 import away3d
.cameras.*;
 
import away3d.containers.*;
 
import away3d.controllers.*;
 
import away3d.core.base.*;
 
import away3d.core.managers.*;
 
import away3d.debug.*;
 
import away3d.entities.*;
 
import away3d.events.*;
 
import away3d.library.*;
 
import away3d.library.assets.*;
 
import away3d.loaders.*;
 
import away3d.loaders.misc.*;
 
import away3d.loaders.parsers.*;
 
import away3d.materials.*;
 
import away3d.materials.lightpickers.*;
 
import away3d.materials.methods.*;
 
import away3d.primitives.*;
 
import away3d.textures.*;
 
import away3d.lights.*;
 
import away3d.tools.helpers.LightsHelper;
 
 
 
import flash.display.*;
 
import flash.events.*;
 
import flash.geom.*;
 
import flash.text.*;
 
import flash.utils.*;
 
import flash.external.ExternalInterface;
 
import flash.net.URLRequest;
 
/**
  * ...
  * @author SimNations
  */
 
[SWF(backgroundColor="#FFFFFF"frameRate="60"quality="HIGH")]
 
public class demoGlobe extends Sprite
 {
  
//Embed
  
[Embed(source "../bin/orionsea.OBJ"mimeType "application/octet-stream")]
  
private var orionSea:Class;
  
    
//engine variables
    
private var scene:Scene3D;
    private var 
camera:Camera3D;
    private var 
view:View3D;
    private var 
cameraController:HoverController;
    private var 
camController:LookAtController;
    
    private var 
loader:Loader3D;
    
/**
     * Constructor
     */
    
     //navigation variables
   
private var move:Boolean false;
   private var 
lastPanAngle:Number;
   private var 
lastTiltAngle:Number;
   private var 
lastMouseX:Number;
   private var 
lastMouseY:Number;

   private var 
tiltIncrement:Number 0;
   private var 
panIncrement:Number 0;
   private var 
distanceIncrement:Number 0;
   public const 
tiltSpeed:Number 2;
   public const 
panSpeed:Number 2;
   public const 
distanceSpeed:Number 2;
  
  public function 
demoGlobe() 
  
{
   
//trace('test');
   
init();
  
}
   
/**
  * Global initialise function
  */
  
private function init():void {
   initEngine
();
   
initObjects();
   
initListeners();
  
}
   
   
  
/**
  * Initialise the engine
  */
  
private function initEngine():void {
    
   stage
.scaleMode StageScaleMode.NO_SCALE;
   
stage.align StageAlign.TOP_LEFT;
    
   
scene = new Scene3D();
    
   
camera = new Camera3D();
    
   
view = new View3D();
   
view.scene scene;
   
view.camera camera;
    
   
addChild(view);
  
}
   
   
  
/**
  * Initialise the scene objects
  */
  
private function initObjects():void {
    
    Parsers
.enableAllBundled();
    
     
loader = new Loader3D();
     
loader.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
     
loader.addEventListener(LoaderEvent.RESOURCE_COMPLETEonFullyLoaded);
     
loader.loadData(new orionSea()); 
     
scene.addChild(loader);
     
     
cameraController = new HoverControllercameraloader0);
    
  
}
   
   
  
/**
  * Initialise the listeners
  */
  
private function initListeners():void
  {
   addEventListener
(Event.ENTER_FRAMEonEnterFrame);
   
view.addEventListener(MouseEvent.MOUSE_DOWNonMouseDown);
   
view.addEventListener(MouseEvent.MOUSE_UPonMouseUp);
  
}
   
   
  
/**
  * Navigation and render loop
  */
  
private function onEnterFrame(event:Event):void
  {
   
if (move{
    cameraController
.panAngle 0.3*(stage.mouseX lastMouseX) + lastPanAngle;
    
cameraController.tiltAngle 0.3*(stage.mouseY lastMouseY) + lastTiltAngle;
   
}

   cameraController
.panAngle += panIncrement;
   
cameraController.tiltAngle += tiltIncrement;
   
cameraController.distance += distanceIncrement;
    
   
view.render();
  
}
   
   
  
/**
  * Listener function for asset complete event on loader
  */
  
private function onAssetComplete(event:AssetEvent):void
  {
    
  }
   
   
  
/**
  * Completely loaded
  */
  
private function onFullyLoaded (event:LoaderEvent):void
  {
   trace
('test');   
  
}
  
  
private function onMouseDown(event:MouseEvent):void
  {
   move 
true;
   
lastPanAngle cameraController.panAngle;
   
lastTiltAngle cameraController.tiltAngle;
   
lastMouseX stage.mouseX;
   
lastMouseY stage.mouseY;
   
stage.addEventListener(Event.MOUSE_LEAVEonStageMouseLeave);
  
}
 
  
private function onMouseUp(event:MouseEvent):void
  {
   move 
false;
   
stage.removeEventListener(Event.MOUSE_LEAVEonStageMouseLeave);
  
}
 
  
private function onStageMouseLeave(event:Event):void
  {
   move 
false;
   
stage.removeEventListener(Event.MOUSE_LEAVEonStageMouseLeave);
  
}
 
  
 }
 
 
   

dubletar, Member
Posted: 09 May 2012 08:06 PM   Total Posts: 73   [ # 1 ]

Nevermind.

I found a working example on another thread.

@away3d/forum/viewthread/737/

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X