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

tunnel

Get Adobe Flash player
by sinketu 24 Mar 2010
/**
 * Copyright sinketu ( http://wonderfl.net/user/sinketu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/i0rJ
 */

package {
	import flash.display.*;
	import flash.events.*;
	import flash.utils.*;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.*;
	import org.papervision3d.cameras.*;
	import org.papervision3d.view.Viewport3D;
	import org.papervision3d.render.BasicRenderEngine;
	import org.papervision3d.materials.*;
	import org.papervision3d.materials.utils.MaterialsList;


	public class Main extends Sprite
	{
		private var scene:Scene3D;
		private var camera:Camera3D;
		private var viewport:Viewport3D;
		private var renderer:BasicRenderEngine;
		
		private var stageW:Number;
		private var stageH:Number;
		private var vpX:Number;
		private var vpY:Number;

		
		private var time:Number = 0;
		private var secondTime:Number = 0;
		private var previousSecondTime:Number = 0;
		private var frameNum:Number = 0;
		private var fps:String = "...";
		private var list:Array=new Array();
		static private const CIRCLE_RANGE :int = 500;
		static private const OBJ_LENGTH   :int = 10;
		static private const size:uint = 300;
		
		public function Main():void 
		{
			setStage();
			setScene();
			setCamera();
			setDO3D();
			
			addEventListener(Event.ENTER_FRAME, onEnterFrameHundler);
			addEventListener(Event.RESIZE, onStageResizeHandler);
		}
		private function setStage():void {
			stage.quality = StageQuality.MEDIUM;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			vpX = stage.stageWidth / 2;
			vpY = stage.stageHeight / 2;
		}
		private function setScene():void {
			renderer = new BasicRenderEngine();
			scene = new Scene3D();
			viewport = new Viewport3D(0, 0, true, true);
			addChild(viewport);
		}
		private function setCamera():void {
			camera = new Camera3D;
			camera.x = 0;
			camera.y = 0;
			camera.z = 0;
			camera.zoom = 30;
			camera.focus = 30;
		}
		private function setDO3D():void {
			for (var j:uint = 0; j < 30; j++ ) {
				for (var i:uint= 0; i < OBJ_LENGTH; i++ ) {
					var rot:uint = 360 * i / OBJ_LENGTH ;
					var myMaterial2:ColorMaterial = new ColorMaterial(0x1000000*Math.random() );
					myMaterial2.doubleSided = true;
					var myPlane:Plane = new Plane(myMaterial2, size, size);
					scene.addChild(myPlane);
					myPlane.x = CIRCLE_RANGE * Math.sin(rot * Math.PI / 180);
					myPlane.y = j*size-30*size/2;
					myPlane.z = CIRCLE_RANGE * Math.cos(rot * Math.PI / 180);
					myPlane.rotationY = rot;
					list.push(myPlane);
				}
			}
		}
		
		private function onEnterFrameHundler(event:Event):void {
			var angleX:Number = (mouseX - vpX) * 0.0001;
			var angleY:Number = (mouseY - vpY) * 0.0001;
			camera.rotationX ++ ;
			renderer.renderScene(scene, camera, viewport);
			for (var i:uint = 0; i < list.length; i++ ) {
				list[i].y += 90;
				if (list[i].y > 30 * size/2) {
					list[i].y = -30*size/2;
				}
			}
		}

		
		private function onStageResizeHandler(event:Event):void {
			stageW = stage.stageWidth / 2;
			stageH = stage.stageHeight / 2;
			vpX = stageW / 2;
			vpY = stageH / 2;
		}
	}
}