In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

PV3D_Spirals

Forkされている方へ
* 元をちょっといじってしまいました。ごめんなさい!
Get Adobe Flash player
by logicalyze 08 Jun 2009
/**
 * Copyright logicalyze ( http://wonderfl.net/user/logicalyze )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7hGp
 */

/**
* Forkされている方へ
* 元をちょっといじってしまいました。ごめんなさい!
*/
package  
{
	import flash.events.Event;
	import org.papervision3d.materials.WireframeMaterial;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;


	[SWF(backgroundColor = "#000000", frameRate = "30")]
	public class PV3DSpiral extends BasicView
	{

		private var angle:Number = 0;
		private var num_spirals:int = 8;
                private var diffY:int = 30;

		
		public function PV3DSpiral(viewportWidth:Number=400, viewportHeight:Number=400, scaleToStage:Boolean=true, interactive:Boolean=false, cameraType:String="Target") 
		{
			super(viewportWidth, viewportHeight, scaleToStage, interactive,cameraType);
			init();
			startRendering();
		}
		
		private function init():void
		{	

			var total:int = 80;
			var one_angle:Number = ((Math.PI*2) * num_spirals) / total;

			for (var i:int = 0; i < total; i++)
			{
				var material:WireframeMaterial = new WireframeMaterial(0xFF0000);
				material.doubleSided = true;
				var plane:Plane = new Plane(material, 200, 200, 2, 2);
				scene.addChild(plane);
				plane.x = Math.cos(i * one_angle) * 400;
				plane.z = Math.sin(i * one_angle) * 400;
				plane.y = diffY*i;
				plane.rotationY = (-i*one_angle) * (180/Math.PI) + 270;
			}
		}
		
		override protected function onRenderTick(event:Event = null):void 
		{
			super.onRenderTick(event);
			var distX:Number = (stage.mouseX - stage.stageWidth * 0.5) * 0.0004;
			var distY:Number = (stage.mouseY - stage.stageHeight * 0.5) * -0.2;
			angle += distX;
			camera.x = Math.cos(angle) * 800;
			camera.z = Math.sin(angle) * 800;
		        if ((camera.y + distY) < -1500 || (camera.y + distY) > 3500)
			{
				distY = 0;
			}
			camera.y += distY;

		}
		
	}
	
}