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

Ribon

Get Adobe Flash player
by hashimoto0623 18 Nov 2009
/**
 * Copyright hashimoto0623 ( http://wonderfl.net/user/hashimoto0623 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/lgUj
 */

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.text.TextField;
	
	import org.papervision3d.cameras.Camera3D;
	import org.papervision3d.core.render.sort.NullSorter;
	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.materials.WireframeMaterial;
	import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
	import org.papervision3d.materials.utils.MaterialsList;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Cube;
	import org.papervision3d.render.BasicRenderEngine;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.view.Viewport3D;

	public class Ribon extends Sprite{
		private var viewport:Viewport3D;
		private var scene:Scene3D;
		private var camera:Camera3D;
		private var renderer:BasicRenderEngine;
		private var rootNode:DisplayObject3D;
		private var light:PointLight3D;

		private var cube:Cube;
		private var fireFlag:Boolean=false;
		private var by_def:Number=170;
		private var bvy_def:Number=30;
		private var bva:Number=2;
		private var bvy:Number=bvy_def;
		private var brad:Number;
		private var tf:TextField;
		private var kstat:Array;
		private var spd:Number=0;
		private var maxspd:Number=40;
		private var cameraMode:Number=1;
		private var debug_mode:Boolean=false;
		private var parr:Array=new Array();
		private var pnum:Number=1;
		private var wfm:WireframeMaterial=new WireframeMaterial();
		private var fsm:FlatShadeMaterial;
		private var mls:MaterialsList;
		
		private var cube_rotY_targ:Number=30;
		private var cube_rotX_targ:Number=20;
		private var cube_scale:Number=500;
		
		private var dx:Number;
		private var dy:Number;
		private var dz:Number;
		private var px:Number=0;
		private var py:Number=3;
		private var pz:Number=1;
		
		public function Ribon(){
			this.init();	
		}
		
		public function init():void{
			this.init3D();
		}

		private function init3D():void{
			this.viewport=new Viewport3D(640,480,true,true);
			this.viewport.interactive=true;
			this.addChild(viewport);
			this.renderer=new BasicRenderEngine();
			this.scene=new Scene3D();
			rootNode=this.scene.addChild(new DisplayObject3D("rootNode"));
			
			light=new PointLight3D(true);
			light.x=1000;
			light.z=-1000;
			light.y=1000;
			light.rotationX=70;
			
			fsm=new FlatShadeMaterial(light);
			fsm.fillAlpha=1;
			mls=new MaterialsList({all:fsm});
			
			cube=new Cube(mls,50,200,50);
			cube.x=cube.y=cube.z=0;
			cube.x=0*cube_scale;
			cube.y=3*cube_scale;
			cube.z=1*cube_scale;
			cube.visible=false;
			rootNode.addChild(cube);
            
			camera=new Camera3D();
			camera.zoom=100;
            
			stage.addEventListener(Event.ENTER_FRAME,loop3d);
			
		}
		
		
		private function loop3d(e:Event):void{
			this.camera.y+=(this.mouseX-this.stage.width/2)/200;
			//this.rootNode.rotationX+=(this.mouseY-this.stage.height/2)/200;
			makeNextPlane(pnum);
			pnum++;
			renderer.renderScene(scene,camera,viewport);
		}
		
		private function makeNextPlane(pn:Number):void{
			//parr[1].rotationX=90;
			
			
    		var rad2:Number=(cube.rotationY-90) * Math.PI / 180;
    		var rad3:Number=(cube.rotationX-90) * Math.PI / 180;
			
			cubeMove();
			
			parr[pn]=new Cube(mls,500,150,100);
			parr[pn].visible=true;
			if(pn>1){
				parr[pn].x=cube.x;
				parr[pn].y=cube.y;
				parr[pn].z=cube.z;
				parr[pn].lookAt(parr[pn-1]);

			}
			rootNode.addChild(parr[pn]);
			if(pn>180){
				rootNode.removeChild(parr[pn-180]);
			}
			
			camera.x=cube.x;
			camera.y=2000;
			camera.z=cube.z;
			camera.lookAt(cube);
			camera.rotationX=90;
		}
		
		private function cubeMove():void{
			
			cube.moveForward(100);
			/*
			cube.rotationY+=10;
			cube.rotationX+=2;
			cube.rotationZ+=1;
			*/
			
			cube.rotationY+=1.66;
			cube.rotationX+=0.45;
			cube.rotationZ+=0.33;
			
		}
		
	}
}