away3D操纵三维物体之多边形载物旋转实例

/*在fb下新建as项目运行此实例*/

Basic07_group.as
package{
	import away3d.containers.ObjectContainer3D;
	import away3d.containers.View3D;
	import away3d.core.math.Number3D;
	import away3d.primitives.Cube;
	import away3d.primitives.RegularPolygon;
	import away3d.primitives.Sphere;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.*;
	
	[SWF(width="500", height="400", frameRate="60", backgroundColor="#FFFFFF")]
	
	public class Basic07_group extends Sprite{
		private var view:View3D;
		private var label:TextField;
		private var group:ObjectContainer3D;
		private var disc:RegularPolygon;  
		private var cube:Cube;
		private var sphere:Sphere;
		
		public function Basic07_group(){	
			view = new View3D({x:250, y:200});    // create a viewport
			addChild(view);
			view.camera.y = 300;    // Move camera up
			// Point it toward scene center again, so the target is right (setting y does not change where the camera is pointing)
			view.camera.lookAt(new Number3D(0, 0, 0)); 
			group = new ObjectContainer3D();
			view.scene.addChild(group);
			disc = new RegularPolygon({radius:250, y:-25, sides:20, pushback:true});    // attach objects to group(this is a polygon---多边形)
			group.addChild(disc);
			cube = new Cube({depth:50, width:50, height:50, z:200});
			group.addChild(cube);
			sphere = new Sphere({radius:25, z:-200});
			group.addChild(sphere);
			this.addEventListener(Event.ENTER_FRAME, update);    // render the view
		}
		
		private function update(e:Event):void{
			group.rotationY += 0.5;    // Rotate group
			cube.rotationY -= 0.5;    // Counter-rotate the cube so it always faces the viewer
			view.render();    // re-render the view
		}
		
	}
}

你可能感兴趣的:(Flash,UP)