球体组成的球体,入门PV3D

package {
	import flash.display.Sprite;
	import flash.events.Event;
	
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.view.BasicView;

	public class VerticesExample extends BasicView
	{
		
		/**
		 * 声明一个实例
		 * */
		private var pivotDO3D:DisplayObject3D;
		
		public function VerticesExample()
		{
			
			this.init();
			this.startRendering();
		}
		
		/**
		 * 初始化方法
		 * */
		private function init():void
		{
			
			pivotDO3D = new DisplayObject3D();
			
			scene.addChild(pivotDO3D);
			
			var bigSphere:Sphere = new Sphere(null,700,12,8);
			
			/**
			 * 循环变量大球体的顶点数组
			 * */
			var numberOfVerts:uint = bigSphere.geometry.vertices.length;
			for(var i:uint = 0;i<numberOfVerts;i++)
			{
				var smallSphere:Sphere = new Sphere(null,Math.random()*30,2,2);
				
				smallSphere.x = bigSphere.geometry.vertices[i].x;
				smallSphere.y = bigSphere.geometry.vertices[i].y;
				smallSphere.z = bigSphere.geometry.vertices[i].z;
				
				pivotDO3D.addChild(smallSphere);
			}
			
			pivotDO3D.addChild(bigSphere);
		}
		/**
		 * 重写渲染功能
		 * */
		override protected function onRenderTick(event:Event=null):void
		{
			pivotDO3D.localRotationY--;
			super.onRenderTick();
		}
	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值