package { import away3d.containers.View3D; import away3d.lights.DirectionalLight3D; import away3d.materials.PhongColorMaterial; import away3d.primitives.Cylinder; import flash.display.Sprite; import flash.events.Event; import flash.geom.Vector3D; [SWF(width="500", height="220", frameRate="60", backgroundColor="#FFFFFF")] public class ExCylinder extends Sprite { public var view:View3D; private var cone1:Cylinder; private var cone2:Cylinder; private var cone3:Cylinder; private var light:DirectionalLight3D; public function ExCylinder() { // create a viewport view = new View3D({x:250,y:110}); addChild(view); // create a cube and put it on stage cone1 = new Cylinder({material:"red#black",segmentsH:1,segmentsW:15,heigth:70,radius:30,x:-170}); view.scene.addChild(cone1); cone2 = new Cylinder({material:"orange#black",segmentsH:1,segmentsW:15,heigth:70,radius:30,x:0,openEnded:true,bothsides:true}); view.scene.addChild(cone2); var mat:PhongColorMaterial = new PhongColorMaterial(0x7777ff); cone3 = new Cylinder({material:mat,segmentsH:1,segmentsW:15,heigth:70,radius:30,x:170}); view.scene.addChild(cone3); // Add a light to make the Phong material visible light = new DirectionalLight3D(); light.color = 0xffffff; light.specular = 1; light.diffuse = .75; light.direction = new Vector3D(100,300,500); view.scene.addLight(light); this.addEventListener(Event.ENTER_FRAME,update); } public function update(e:Event):void { // Rotate the cube cone1.rotationX += 1; cone1.rotationY += .5; cone2.rotationX += 1; cone2.rotationY += .5; cone3.rotationX += 1; cone3.rotationY += .5; // Render the view view.render(); } } }