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

forked from: PV3Dその8 Pixels使ってみる

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

//forked from :   sake's  PV3Dその8 Pixels使ってみる

package
{
	import flash.events.Event;
	import flash.filters.BlurFilter;
	
	import org.papervision3d.core.effects.BitmapLayerEffect;
	import org.papervision3d.core.effects.utils.BitmapClearMode;
	import org.papervision3d.core.geom.Pixels;
	import org.papervision3d.core.geom.renderables.Pixel3D;
	import org.papervision3d.materials.special.ParticleMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.special.ParticleField;
	import org.papervision3d.view.BasicView;
	import org.papervision3d.view.layer.BitmapEffectLayer;

	[SWF(width="512", height="512", backgroundColor="0x000000", frameRate="40")]
	public class PapervisionEffect2 extends BasicView
	{
		private var ary:Array;
		private var layer:BitmapEffectLayer;
		
		public function PapervisionEffect2()
		{
			camera.zoom = 100;
			layer=new BitmapEffectLayer(viewport, 500, 500, true, 0x000000, BitmapClearMode.CLEAR_PRE, true);
			viewport.containerSprite.addLayer(layer);
			layer.addEffect(new BitmapLayerEffect(new BlurFilter(8, 8, 4), false));
			startRendering();
			
			ary = [];

			for(var i:uint = 0; i < 5; i++){
				createPixels();
			}
			
			addEventListener(Event.ENTER_FRAME, onFrame);
		}
		
		private function createPixels():void{
			var color:uint = (0xff << 24 | (0xff-0x99)*Math.random()+0x99 << 16  | 0x66*Math.random() << 8 | 0xff);
			var rX:Number;
			var rY:Number;
			for(var i:uint = 0; i < 10; i++){	
				var pixels:Particle = new Particle(layer);
				scene.addChild(pixels);
				for(var s:Number=0; s < Math.PI * 2; s+=0.02){
					var p:Pixel3D=new Pixel3D(color, Math.cos(s)*200, Math.sin(s)*200, 0);
					pixels.addPixel3D(p);
				}
				pixels.x = 0;
				pixels.y = 0;
				pixels.vrx = Math.random()*10-5;
				pixels.vry = Math.random()*10-5;
				
				ary.push(pixels);
			}
		}

		private function onFrame(e:Event):void
		{
			var pixels:Particle;
			var i:uint = ary.length;
			while(i--){
				pixels = ary[i];
				pixels.rotationX += pixels.vrx;
				pixels.rotationY += pixels.vry;
			}
			camera.x += (stage.stageWidth/2 - mouseX)/10;
			camera.y += (stage.stageHeight/2 - mouseY)/10;
			camera.z += (stage.stageHeight/2 - mouseY)/10;
		}
	}
}
	import org.papervision3d.core.geom.Pixels;
	import org.papervision3d.view.layer.BitmapEffectLayer;
	

class Particle extends Pixels{
	public var vrx:Number;
	public var vry:Number;
	
	public function Particle(effectLayer:BitmapEffectLayer, name:String = "pixels3D"):void{
		super(effectLayer, name);
	}
}