论坛首页 入门技术论坛

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

浏览 8236 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-08-31  
用了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 );
        }

    }
}
  • 描述: 效果
  • 大小: 360.6 KB
  • earth.rar (237.8 KB)
  • 描述: 运行
  • 下载次数: 1467
   发表时间:2007-08-31  
欢迎来flex圈子一起讨论学习
0 请登录后投票
   发表时间:2007-08-31  
nice啊
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics