package { import away3d.cameras.HoverCamera3D; import away3d.containers.View3D; import away3d.primitives.GeodesicSphere; import away3d.primitives.Sphere; import flash.display.Sprite; import flash.events.Event; import flash.events.KeyboardEvent; import flash.ui.Keyboard; [SWF(width="500", height="200", frameRate="50", backgroundColor="#FFFFFF")] public class Basic08_geodesicsphere_refine extends Sprite { private var cam:HoverCamera3D; private var lastKey:uint; private var keyIsDown:Boolean = false; private var View:View3D; private var cover:Cover; private var geoSphere1:GeodesicSphere; private var geoSphere2:GeodesicSphere; private var geoSphere3:GeodesicSphere; private var geoSphere4:GeodesicSphere; private var geoSphere5:GeodesicSphere; /** * The following 2 lines are how graphics are embedded using Flex. * If you are using the Flash IDE, simply remove the next two * lines of code, import the image to your library and set it to * export with the class name "texture". **/ [Embed(source="resources/panoramaSpherical.jpg")] private var texture:Class; public function Basic08_geodesicsphere_refine() { // create a "hovering" camera cam = new HoverCamera3D(); cam.z = -1000; // make sure the camera is positioned away from the default 0,0,0 coordinate cam.panangle = 0; cam.tiltangle = 0; cam.targetpanangle = 0; cam.targettiltangle = 0; cam.mintiltangle = -90; cam.zoom = 5; // create a viewport View = new View3D({camera:cam,x:250,y:100}); addChild(View); // add 4 spheres with varying amount of "fractures" geoSphere1 = new GeodesicSphere({radius:90,x:340}); geoSphere1.fractures = 0; geoSphere1.invertFaces(); View.scene.addChild(geoSphere1); geoSphere2 = new GeodesicSphere({radius:90,x:130}); geoSphere2.fractures = 1; geoSphere2.invertFaces(); View.scene.addChild(geoSphere2); geoSphere3 = new GeodesicSphere({radius:90,x:-80}); geoSphere3.fractures = 2; geoSphere3.invertFaces(); View.scene.addChild(geoSphere3); geoSphere4 = new GeodesicSphere({radius:90,x:-290}); geoSphere4.fractures = 3; geoSphere4.invertFaces(); View.scene.addChild(geoSphere4); // update the view cam.hover(); View.render(); // only run when user is above the SWF cover = new Cover(this,500,200,"Roll over and Click to activate. Use Space key to show both and arrow keys to toggle."); addChild(cover); // run every frame this.addEventListener(Event.ENTER_FRAME,onEnterFrame); } private function onEnterFrame(e:Event):void { if(!cover.visible) { geoSphere1.rotationX += 1; geoSphere2.rotationX += 1; geoSphere3.rotationX -= 1; geoSphere4.rotationX += 1; // render the view cam.hover(); View.render(); } } } }