away3D案例1
package { import away3d.containers.*; import away3d.entities.*; import away3d.materials.*; import away3d.primitives.*; import away3d.utils.*; import flash.display.*; import flash.events.*; import flash.geom.Vector3D; [SWF(backgroundColor="#000000", frameRate="60", quality="LOW")] public class Basic_View extends Sprite { //一个平面材质 [Embed(source="/../embeds/floor_diffuse.jpg")] public static var FloorDiffuse:Class; //创建三维视图 private var _view:View3D; //创建一个平板 private var _plane:Mesh; /** * 构造函数 */ public function Basic_View() { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; //创建三维视图 _view = new View3D(); addChild(_view); //设定当前的相机信息 _view.camera.z = -600; _view.camera.y = 500; _view.camera.lookAt(new Vector3D()); //设置平面,并且给定材质 _plane = new Mesh(new PlaneGeometry(700, 700), new TextureMaterial(Cast.bitmapTexture(FloorDiffuse))); _view.scene.addChild(_plane); //添加zhen动画 addEventListener(Event.ENTER_FRAME, _onEnterFrame); stage.addEventListener(Event.RESIZE, onResize); onResize(); } /** * 循环渲染 */ private function _onEnterFrame(e:Event):void { _plane.rotationY += 1; _view.render(); } /** * 当前的尺寸改变事件 */ private function onResize(event:Event = null):void { _view.width = stage.stageWidth; _view.height = stage.stageHeight; } } }