Archive for category Away3D

Away3D and Stage3D (Molehill)

I posted an article earlier this week about Away3D and the VideoMaterial and since I also made tests on Stage3D (Molehill) while doing that research, I thought I would post them here. My point with all this is to show that working with the new version of Away3D is going to be a little different. Here is the code to do mostly what the other post was doing, mostly mapping a texture to a sphere and having the camera in the middle (not a video here, just a bitmap).

public function Main(){
  stage.scaleMode = StageScaleMode.NO_SCALE;
  stage.align = StageAlign.TOP_LEFT;
 
  view = new View3D();
  addChild(view);
 
  view.camera.z=0;
  view.camera.y=0;
  view.camera.x=0;
  view.camera.lookAt(new Vector3D(0,0,1));
 
  light = new PointLight();
  light.radius = 200;
  light.color = 0xffffff;
  light.castsShadows = false;
  light.position=new Vector3D(0,0,0);
  view.scene.addChild(light); 			
 
  spherecontainer = new ObjectContainer3D();
  view.scene.addChild(spherecontainer);
 
  var material : BitmapMaterial = new BitmapMaterial(new Albedo().bitmapData);
  material.bothSides = true;
 
  sphere = new Sphere(material);
  sphere.radius = 500;
  spherecontainer.addChild(sphere);
 
  addEventListener(Event.ENTER_FRAME, _handleEnterFrame);
  stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
  stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
}

To get starting for Molehill I followed the simple instructions and used the FDT template found on the powerflasher’s site. As you can see if you compare the code, there are some differences. You don’t need to create a scene and a camera, they are already there for you. You need a light and you add that light as any 3D objects (no more using addLight). Lastly, which was my biggest problem, your texture need to be a square otherwise it won’t show. That was really bad for me cause I wasn’t seeing anything and the textures I was using were working fine in Away3D 3.6. But in the end I made it work. Anyway, Adobe needs to release that shiz fast cause it’s awesome!

, , ,

No Comments