Simple fix request:  Please make away3d (as3 comiled swc) haxe friendly

Software: Away3D 4.x

Avatar
Huck, Jr. Member
Posted: 21 January 2012 01:34 PM   Total Posts: 45

[note: the forum engine detects my code as possible spam, so i have to send it in multiple posts. sorry]

Hi Guys,

first, thanks for away3d, the more i discover it the more amazing it is.

I would like to ask if the devs could take a few minutes to fix a few small issues in the code base that make using away3d compiled as a swc difficult in haxe. At the moment that i write this, the list of fixes is very simple to change, here are the detailed changes. Once the changes done, away3d 4 works like a charm in a haxe project.

rename the “update” function in the following files:

away3d.materials.AnimatedBitmapMaterial.as
away3d.materials.VideoMaterial.as
away3d.audio.Sound3D.as 

 

 

   

Avatar
Huck, Jr. Member
Posted: 21 January 2012 01:35 PM   Total Posts: 45   [ # 1 ]

rename SingletonEnforcer to a different name in each file. (each file has this SingletonEnforcer in the same package which haxe doesnt like. naems can be like “MaterialLibrarySingletonEnforcer”, “Stage3DManagerSingletonEnforcer”, etc.)

away3d.materials.MaterialLibrary.as
away3d.core.managers.Stage3DManager.as
away3d.core.managers.AGALProgram3DCache.as
away3d.core.managers.BitmapDataTextureCache.as
away3d.library.AssetLibrary.as 

 

   

Avatar
Huck, Jr. Member
Posted: 21 January 2012 01:36 PM   Total Posts: 45   [ # 2 ]

rename static methods to a different name than the non static counterparts in:

away3d.library.AssetLibrary.as 
   

Avatar
Huck, Jr. Member
Posted: 21 January 2012 01:36 PM   Total Posts: 45   [ # 3 ]

in the file the set functions for
public function set frustumCorners
public function set matrix
need to be in the parent class (the get method is in the parent class, haxe doesnt like the sepatation).

away3d.cameras.lenses.FreeMatrixLens

thats it! once all this is done, away3d plays nicely with haxe and with stub generation.

many thanks!

 

   

Avatar
Huck, Jr. Member
Posted: 21 January 2012 01:36 PM   Total Posts: 45   [ # 4 ]

for users and or the record, here is how to use away3d in haxe:

first, compile away3d as a swc (you can use export swc plugin in flash develop) asuming that you either do the above fixes manually or the dev team merge these fixes i the code base.

extract the swc and add the swf to you haxe project using the compiler command -swc-lib library.swf.

note: you can also make stub classes if you wish to link the haxe proejct into another as3 project that uses its own away3d later on.

class Main extends Sprite
{
 
 
private var camera:Camera3D;
 private var 
view:View3D;
 private var 
ground:Sphere;
 private var 
cameraController:HoverController;
 public var 
light:DirectionalLight;
  
 public function 
init()
 
{
  move
false;
  
  
//this is important or it wont work
  
var boot:Boot = new Boot();
  
flash.Lib.current.stage.scaleMode flash.display.StageScaleMode.NO_SCALE;
  
flash.Lib.current.stage.align flash.display.StageAlign.TOP_LEFT;
  
  
camera = new Camera3D();
  
camera.lens.far 2100;
  
  
view = new View3D();
  
  
view.scene = new Scene3D();
  
view.camera camera;
  
  
//setup controller to be used on the camera
  
cameraController = new HoverController(cameranull4520100010);
  
  
light = new DirectionalLight();
  
light.position = new Vector3D(3,3,3);
  
light.direction = new Vector3D( -1, -1, -1);
  
  
view.scene.addChild(light);
  
  
//view.addSourceURL("srcview/index.html");
  
Lib.current.addChild(view);
  
  
Lib.current.addEventListener(Event.ENTER_FRAMEonEnterFrame);
  
  var 
ctr:ObjectContainer3D = new ObjectContainer3D();
  

  var 
green ColorMaterial = new ColorMaterial(0x00FF00);
  
green.lights [light];
  
//ctr.addChild(new Sphere(green, 3));
  //ground.material = green;
  
  
ground = new Sphere(green3);
  
  
ctr.addChild(ground);
  
  
ctr.scale(80);
  
  
view.scene.addChild(ctr);
   
 
}
 
 
private var move:Bool;
 private var 
lastPanAngle:Float;
 private var 
lastTiltAngle:Float;
 private var 
lastMouseX:Int;
 private var 
lastMouseY:Int;
 function 
onEnterFrame(event:Event):Void
 {
  
if (move{
   cameraController
.panAngle 0.3 * (stage.mouseX lastMouseX) + lastPanAngle;
   
cameraController.tiltAngle 0.3 * (stage.mouseY lastMouseY) + lastTiltAngle;
  
}

  view
.render();
 
}
 
 
static var run Bool false;
 static function 
addedevent flash.events.Event )
 
{
  
if( run )
    return;
      
  if( 
event.target != flash.Lib.current || flash.Lib.current.stage == null )
    return;
  
run true;
  
go();
 

 
 
static function go( )
    
{
  
var main:Main = new Main();
  
main.init();
 
}
  
 
static function main() 
 
{
  flash
.Lib.current.addEventListenerflash.events.Event.ADDEDadded); 
 
}

hope this helps,

   

deep, Newbie
Posted: 28 January 2012 06:04 PM   Total Posts: 1   [ # 5 ]

Hello. I forked dev branch and fixed haxe suport. All source and demo here
https://github.com/profelis/away3d-core-fp11/tree/haxe

library.swf and hxclasses and demo project here https://github.com/profelis/away3d-core-fp11/tree/haxe/bin

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X