自己旋转的地球---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 );
        }

    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值