away3D案例3

package {
 import away3d.entities.Mesh;
 import away3d.materials.ColorMaterial;
 import away3d.primitives.CubeGeometry;
 import away3d.stereo.StereoCamera3D;
 import away3d.stereo.StereoView3D;
 import away3d.stereo.methods.AnaglyphStereoRenderMethod;

 import flash.display.Sprite;
 import flash.events.Event;
 
 [SWF(width="960", height="540")]
 public class Basic_Stereo extends Sprite
 {
  private var _view : StereoView3D;
  private var _camera : StereoCamera3D;
  
  private var _cube : Mesh;
  
  public function Basic_Stereo()
  {
   super();
   
   //定义立体相机
   _camera = new StereoCamera3D();
   _camera.stereoOffset = 50;
   
   //定义立体视图
   _view = new StereoView3D();
   _view.antiAlias = 4;
   _view.camera = _camera;
   _view.stereoEnabled = true;
   //定义当前的立体渲染方法
   _view.stereoRenderMethod = new AnaglyphStereoRenderMethod();
   //_view.stereoRenderMethod = new InterleavedStereoRenderMethod();
   addChild(_view);
   //定义当前的正方形
   _cube = new Mesh(new CubeGeometry(), new ColorMaterial(0xffcc00));
   _cube.scale(5);
   _view.scene.addChild(_cube);
   
   addEventListener(Event.ENTER_FRAME, onEnterFrame);
  }
  
  //不停的渲染当前
  private function onEnterFrame(ev : Event) : void
  {
   _cube.rotationY += 2;
   _view.render();
  }
 }
}

posted @ 2017-12-16 20:34  Min.Xiaoshuang  阅读(466)  评论(0编辑  收藏  举报