自己旋转的地球---flex的3d

用了papervision3d 基于as的3d引擎
package {
    import flash.display.Sprite;
import flash.display.*;
import flash.events.*;

// Import Papervision3D
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;

[SWF(width="640", height="480", frameRate="25", backgroundColor="#000000")]
    public class Test3D extends Sprite
    {
        private var container :Sprite;
        private var scene     :Scene3D;
        private var camera    :Camera3D;
        private var sphere    :Sphere;
   
        public function Test3D()
        {
            this.init3D();

        // onEnterFrame
        this.addEventListener( Event.ENTER_FRAME, loop3D );
        }
       
        private function init3D():void
        {
            this.container = new Sprite();
            addChild( container );
            this.container.x = 320;
            this.container.y = 240;
            this.scene = new Scene3D( container );
            this.camera = new Camera3D();
            this.addEarth();
           
        }
        private function addEarth():void
        {
            var material:ColorMaterial = new ColorMaterial();
                material.fillColor = 0xFF0000;
                material.doubleSided = true;
                material.fillAlpha = 1.0;
                material.lineAlpha = 1;
                material.lineColor = 0x000000;
   
            this.sphere = new Sphere( new BitmapFileMaterial("world.png"),500,20,20);
            this.sphere.rotationX = 45;
            this.sphere.yaw( -30 );
            this.scene.addChild( sphere );
//            var sphere2:Sphere=new Sphere(material, 400)
//            sphere2.x=-200;
//            this.scene.addChild(sphere2 );
        }
       
        private function loop3D(event:Event):void
        {
            this.camera.x = -container.mouseX/2;
            this.camera.y = container.mouseY/3;
            this.sphere.yaw( .5 );
            this.scene.renderCamera( camera );
        }

    }
}

你可能感兴趣的:(flex)