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

【PV3D】BitamapEffectLayer

Get Adobe Flash player
by _ryotaros 17 Jan 2010
    Embed
/**
 * Copyright _ryotaros ( http://wonderfl.net/user/_ryotaros )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/36OY
 */

package {
     import flash.display.*;
     import flash.events.*;
     import flash.filters.*;
     import flash.geom.*;
     import flash.media.*;
     import flash.net.*;
     import org.papervision3d.core.effects.*;
     import org.papervision3d.core.effects.utils.*;
     import org.papervision3d.view.layer.*;
     import org.papervision3d.objects.*;
     import org.papervision3d.view.*;
     import org.papervision3d.materials.*;
     import org.papervision3d.objects.primitives.*;
    
    [SWF(width=465,height=465,backgroundColor =0)]
    public class FlashTest extends BasicView{
        
        public var sphere:Sphere;
        public var material:WireframeMaterial;
        public var material2:ColorMaterial;
        public var num:int = 0;
        
        public function FlashTest():void {
        	
        		var bfx:BitmapEffectLayer = new BitmapEffectLayer(this.viewport);
            bfx.addEffect(new BitmapLayerEffect(new BlurFilter(16, 16, 5)));
            bfx.drawCommand = new BitmapDrawCommand(null, new ColorTransform(1, 1, 0.15), BlendMode.ADD );
            bfx.clippingPoint = new Point (0, 0);
       	    viewport.containerSprite.addLayer(bfx); 
        		
        			
        		material = new WireframeMaterial(0xFF0000);
        		material2 = new ColorMaterial(0xFF0000);
        		sphere = new Sphere(material, 300 ,15 ,15);
        		scene.addChild(sphere);
        		
        		startRendering();
            
            addEventListener(Event.ENTER_FRAME, loop );
            addEventListener(MouseEvent.CLICK, clickHandler);
              
            bfx.addDisplayObject3D(sphere); 
            
        }
        
        public function clickHandler(e:MouseEvent):void {
        		switch(num%2){
        			case 0:
        				sphere.material = material2;
        				break;
        			case 1:
        				sphere.material = material;
        				break;
        		}
        		num++;
        }
        
        private function loop(e:Event):void {
        		sphere.rotationY += 1;
        		sphere.rotationX += 1;
        		
        		var rateX:Number = mouseX / stage.width;
        		var targetX:Number = -5000 * (rateX - 0.5 );
        		camera.x += (targetX - camera.x) * 0.2;
        		        		
        		var rateY:Number = mouseY / stage.height;
        		var targetY:Number = 5000 * ( rateY - 0.5 );
        		camera.y += (targetY - camera.y) * 0.2;
        }
    }
}