浏览 8242 次
锁定老帖子 主题:自己旋转的地球---flex的3d
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-08-31
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 ); } } } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-08-31
欢迎来flex圈子一起讨论学习
|
|
返回顶楼 | |
发表时间:2007-08-31
nice啊
|
|
返回顶楼 | |