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: キラキラPixel3D!

悪乗りしてみた。
オリジナルの短く美しいコードは跡形もありません・・・

お手軽キラキラPixel3D!
キラキラ方法はこちらを使わせてもらいましたー:http://wonderfl.net/code/71344f9a655053d9f793a32c68f00921c67f1977
Get Adobe Flash player
by aomoriringo 06 Oct 2009
/**
 * Copyright aomoriringo ( http://wonderfl.net/user/aomoriringo )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/xfcIY
 */

// forked from sake's キラキラPixel3D!
/*
悪乗りしてみた。
オリジナルの短く美しいコードは跡形もありません・・・
*/
/*
     お手軽キラキラPixel3D!
     キラキラ方法はこちらを使わせてもらいましたー:http://wonderfl.net/code/71344f9a655053d9f793a32c68f00921c67f1977    
*/
package
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BlendMode;
    import flash.display.PixelSnapping;
    import flash.events.Event;
    import flash.geom.Matrix;
    
    import org.papervision3d.core.effects.utils.BitmapClearMode;
    import org.papervision3d.core.geom.Pixels;
    import org.papervision3d.core.geom.renderables.Pixel3D;
    import org.papervision3d.view.BasicView;
    import org.papervision3d.view.layer.BitmapEffectLayer;
    [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="40")]
    
    public class as0002_test2 extends BasicView
    {
        private var pixels:Pixels;
        private var canvas:BitmapData;
        private var mtx:Matrix;
        public function as0002_test2()
        {
            super(0, 0, true, true);
            var layer:BitmapEffectLayer=new BitmapEffectLayer(viewport, 465, 465, true, 0, BitmapClearMode.CLEAR_PRE, true);
            layer.clearBeforeRender=true;
            viewport.containerSprite.addLayer(layer);
            camera.z=-500;
            pixels=new Pixels(layer);
            scene.addChild(pixels);
            for(var i:int=0; i < 12000; i++)
            {
                var theta1:Number=360 * Math.random() * Math.PI / 180;
                var theta2:Number=360 * Math.random() * Math.PI / 180;
                var radius:Number=230;
                
                var xx:Number;
                var yy:Number;
                var zz:Number;
                var p:Pixel3D;
                var s:Number = 10;
                
                var tmp1:Number = Math.cos(theta1);
                var tmp2:Number = 6 * theta2/(2*Math.PI);
                var color:int;
                
                if(i < 3000){
                
 	                xx = Math.sin(theta1) * (3 + Math.cos(theta2)) - 1.5;
    	            yy = Math.cos(theta1) * (3 + Math.cos(theta2));
        	        zz = Math.sin(theta2);
                
             		color = 1;
                }
                else if(i>= 3000 && i < 6000){
                	xx = Math.cos(theta1) * (3 + Math.cos(theta2)) + 1.5;
                	yy = Math.sin(theta2);
                	zz = Math.sin(theta1) * (3 + Math.cos(theta2));
                
                	color = 0;
                }
                else if(i >= 6000 && i < 7000){
                	xx = 6 * theta2/(2*Math.PI) + 5;
                	yy = Math.cos(theta1);
                	zz = Math.sin(theta1);
                	color = 0;
                }
                else if(i >= 7000 && i < 8000){
                	xx = -6 * theta2/(2*Math.PI) - 5;
                	yy = Math.cos(theta1);
                	zz = Math.sin(theta1);
               		color = 1;
                }
                else if(i >= 8000 && i < 9000){
                	xx = Math.sin(45*Math.PI/180)*tmp1 + Math.cos(45*Math.PI/180)*tmp2 - 11;
                	yy = Math.cos(45*Math.PI/180)*tmp1 - Math.sin(45*Math.PI/180)*tmp2;
                	zz = Math.sin(theta1);
                	color = 1;
                }
                else if(i >= 9000 && i < 10000){
                	yy = Math.cos(-45*Math.PI/180)*tmp1 - Math.sin(-45*Math.PI/180)*tmp2;
                	xx = Math.sin(-45*Math.PI/180)*tmp1 + Math.cos(-45*Math.PI/180)*tmp2 - 11;
                	zz = Math.sin(theta1);
                	color = 1;
                }
                else if(i >= 10000 && i < 11000){
                	tmp2 /= 2;
                	
                	zz = (Math.cos(90*Math.PI/180)*tmp1 - Math.sin(90*Math.PI/180)*tmp2) + 4;
                	xx = (Math.sin(90*Math.PI/180)*tmp1 + Math.cos(90*Math.PI/180)*tmp2) + 8;
                	yy = Math.sin(theta1);
                	color = 0;
                }
                else if(i >= 11000 && i < 12000){
                	tmp2 /= 2;
                	
                	zz = (Math.cos(90*Math.PI/180)*tmp1 - Math.sin(90*Math.PI/180)*tmp2) - 1;
                	xx = (Math.sin(90*Math.PI/180)*tmp1 + Math.cos(90*Math.PI/180)*tmp2) + 8;
                	yy = Math.sin(theta1);
                	color = 0;
                }
                
                xx *= radius/s;
                yy *= radius/s;
                zz *= radius/s;
                
                // 0-> Red, 1->Blue
                if(color==0)       p=new Pixel3D((0xff << 24 | 0xff << 16 | 0xff * Math.random() << 8 | 0xff * Math.random()), xx, yy, zz);
                else if(color==1) p=new Pixel3D((0xff << 24 | 0xff * Math.random() << 16 | 0xff * Math.random() << 8 | 0xff), xx, yy, zz);
                
                pixels.addPixel3D(p);
            }
            
            
            
            canvas=new BitmapData(465 / 4, 465 / 4, false, 0x000000);
            var bmp:Bitmap=new Bitmap(canvas, PixelSnapping.NEVER, true);
            bmp.scaleX=bmp.scaleY=4;
            bmp.smoothing=true;
            bmp.blendMode=BlendMode.ADD;
            addChild(bmp);
            mtx = new Matrix(0.25, 0, 0, 0.25);
            startRendering();
            addEventListener(Event.ENTER_FRAME, onFrame);
        }
        private function onFrame(e:Event):void
        {
            canvas.fillRect(canvas.rect, 0x000000);
            canvas.draw(viewport, mtx);
            
            pixels.rotationY-=0.2;
            pixels.rotationX-=0.5;
        }
    }
}