forked from: flash on 2010-3-30

by mitien forked from flash on 2010-3-30 (diff: 1)
♥0 | Line 97 | Modified 2011-03-11 19:58:55 | MIT License
play

ActionScript3 source code

/**
 * Copyright mitien ( http://wonderfl.net/user/mitien )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6OOO
 */

// forked from aaharu's flash on 2010-3-30
/*
http://www.youtube.com/watch?v=daLvkZqsVR8
↑を再現しようとしたけど重すぎて諦めた超劣化版
ごめんなさい
*/
package {
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import flash.filters.GlowFilter;
	
	import org.libspark.betweenas3.BetweenAS3;
	import org.papervision3d.cameras.Camera3D;
	import org.papervision3d.cameras.CameraType;
	import org.papervision3d.core.geom.Lines3D;
	import org.papervision3d.core.geom.Particles;
	import org.papervision3d.core.geom.renderables.Line3D;
	import org.papervision3d.core.geom.renderables.Particle;
	import org.papervision3d.core.geom.renderables.Vertex3D;
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.materials.special.LineMaterial;
	import org.papervision3d.materials.special.ParticleMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.objects.special.ParticleField;
	import org.papervision3d.view.BasicView;
	
	[SWF(backgroundColor=0x000000)]
	public class Pv3D_halo extends BasicView {
		private var lines_UP_RIGHT:Lines3D;
		private var lines_UP_LEFT:Lines3D;
		private var lines_DOWN_RIGHT:Lines3D;
		private var lines_DOWN_LEFT:Lines3D;
		private var from:Vertex3D = new Vertex3D(0, 0, 500);
		private var to:Vertex3D = new Vertex3D();
		
		private var target:Plane = new Plane();
		
		public function Pv3D_halo() {
			super(640, 480, true, false, CameraType.TARGET);
			
			lines_UP_RIGHT = new Lines3D(new LineMaterial(0x3333EF));
			lines_UP_LEFT = new Lines3D(new LineMaterial(0x3333EF));
			lines_DOWN_RIGHT = new Lines3D(new LineMaterial(0x3333EF));
			lines_DOWN_LEFT = new Lines3D(new LineMaterial(0x3333EF));
			
			lines_UP_RIGHT.useOwnContainer = true;
			var filter:GlowFilter = new GlowFilter(0x3333DD, 1, 10, 10, 5, 2);
			lines_UP_RIGHT.filters = [filter];
			lines_UP_LEFT.useOwnContainer = true;
			lines_UP_LEFT.filters = [filter];
			lines_DOWN_RIGHT.useOwnContainer = true;
			lines_DOWN_RIGHT.filters = [filter];
			lines_DOWN_LEFT.useOwnContainer = true;
			lines_DOWN_LEFT.filters = [filter];
			
			scene.addChild(lines_DOWN_RIGHT);
			scene.addChild(lines_DOWN_LEFT);
			scene.addChild(lines_UP_RIGHT);
			scene.addChild(lines_UP_LEFT);
			var particles:ParticleField = new ParticleField(new ParticleMaterial(0xCCCCFF, 0.5, 1, 2), 200, 2, 1000, 1000, 1000);
			scene.addChild(particles);
			camera.target = target;
			camera.x = -520;
			camera.y = -50;
			camera.z = -50;
			
			startRendering();
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
		
		private var count:int = 0;
		private var w:Number = 5 / 2 * Math.PI;
		private function onEnterFrame(e:Event):void {
			if(count <= 200) {
				to.x = 500 * Math.sin(Math.PI / 200 * count);
				to.z = 500 * Math.cos(Math.PI / 200 * count);
				lines_UP_RIGHT.addNewLine(2, -from.x, 50, from.z, -to.x, 50, to.z);
				lines_UP_LEFT.addNewLine(2, from.x, 50, from.z, to.x, 50, to.z);
				lines_DOWN_RIGHT.addNewLine(2, -from.x, -50, from.z, -to.x, -50, to.z);
				lines_DOWN_LEFT.addNewLine(2, from.x, -50, from.z, to.x, -50, to.z);
				from = to.clone();
				
				target.x = -to.x;
				target.z = to.z;
				
				var plane1:Plane = new Plane(new ColorMaterial(0x3333EE), w, 100);
				plane1.material.doubleSided = true;
				plane1.x = to.x * 1.3;
				plane1.z = to.z * 1.3;
				plane1.lookAt(DisplayObject3D.ZERO);
				BetweenAS3.to(plane1, {x: to.x, z: to.z}, 1.2).play();
				scene.addChild(plane1);
				
				if(count % 200) {
					var plane2:Plane = new Plane(new ColorMaterial(0x3333EE), w, 100);
					plane2.material.doubleSided = true;
					plane2.x = -to.x * 1.3;
					plane2.z = to.z * 1.3;
					plane2.lookAt(DisplayObject3D.ZERO);
					BetweenAS3.to(plane2, {x: -to.x, z: to.z}, 1.2).play();
					scene.addChild(plane2);
				}
				if(count >= 120) {
					camera.x += 2;
				}
				camera.y += 0.7;
				camera.z--;
				count++;
			} else {
				removeEventListener(Event.ENTER_FRAME, onEnterFrame);
			}
		}
	}
}