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

Pixel3D交錯ブロック

Get Adobe Flash player
by Nyarineko 19 Oct 2009
/**
 * Copyright Nyarineko ( http://wonderfl.net/user/Nyarineko )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/h9b2
 */

package
{
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filters.BlurFilter;
	import flash.geom.ColorTransform;
	import org.papervision3d.core.geom.Pixels;
	import org.papervision3d.core.geom.renderables.Pixel3D;
	import org.papervision3d.view.BasicView;
	import org.papervision3d.view.layer.BitmapEffectLayer;
	import org.papervision3d.core.effects.BitmapLayerEffect;
	import org.papervision3d.core.effects.utils.BitmapClearMode;
	import org.papervision3d.core.effects.utils.BitmapDrawCommand;

	[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="40")]
	public class Main extends BasicView
	{
		private var _pixels:Pixels;
		private var _pixels2:Pixels;

		public function Main()
		{
            Wonderfl.disable_capture();
			super(0, 0, true, true);
			camera.z=-400;
			camera.y=100;

			var layer:BitmapEffectLayer=new BitmapEffectLayer(viewport, 465, 465, true, 0, BitmapClearMode.CLEAR_PRE, true);
			layer.addEffect(new BitmapLayerEffect(new BlurFilter(4, 4, 2), false));
			layer.drawCommand = new BitmapDrawCommand();  
			viewport.containerSprite.addLayer(layer);
			_pixels=new Pixels(layer);
			_pixels2=new Pixels(layer);
			
			layer.addDisplayObject3D(_pixels);
			layer.addDisplayObject3D(_pixels2);
			
			scene.addChild(_pixels);
			scene.addChild(_pixels2);
			
            _iniset();
			addEventListener(Event.ENTER_FRAME, onFrame);
            stage.addEventListener(MouseEvent.MOUSE_MOVE, _move);
		}
		
        private function _iniset():void{
			var angle:Number;
			var radius:Number;
			var x:Number;
			var y:Number;
			var z:Number;
			var pn:Number;
			
			var r:Number;
			var g:Number;
			var b:Number;
			
            for (var i:int = -150; i <= 150; i += 20){
				y = i;
				r = (Math.abs(i) / 150) * 255;
				for(var j:Number = -150;j <= 150;j += 20){
					x=j;
					g = 0;
					for(var k:Number = -150;k <= 150;k += 20){
						z=k;
						b = 255 - r;
						_pixels.addPixel3D(new Pixel3D( (0xff << 24 | r/1.5 << 16 | g << 8 | b ), x, y, z));
						_pixels2.addPixel3D(new Pixel3D( (0xff << 24 | (255-r)/2 << 16 | (255-g)/2 << 8 | (255-b)/1.5 ), x, y, z));
					}
				}
            }
		}
		
        private function _move(e:MouseEvent = null):void{
			camera.x = (mouseX - 230) * 3;
			camera.y = (mouseY - 130) * 3;
		}
		
		private function onFrame(e:Event):void
		{
			_pixels.rotationY+=0.2;
			_pixels.rotationZ+=0.2;
			_pixels2.rotationX-=0.3;
			_pixels2.rotationZ-=0.3;
			startRendering();
		}
	}
}