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

チルトシフトの新しい使い方3

@author Shunsuke Ohba
@version 1.0
@see http://reinit.info/blog/
Get Adobe Flash player
by shunsuke_ohba 08 Mar 2011
/**
 * Copyright shunsuke_ohba ( http://wonderfl.net/user/shunsuke_ohba )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/mB23
 */

package
{
    import flash.system.LoaderContext;
    import flash.display.*;
    import flash.events.Event;
    import flash.filters.*;
    import flash.geom.Point;
    import flash.net.URLRequest;
    /**
     * 
     * @author Shunsuke Ohba
     * @version 1.0
     * @see http://reinit.info/blog/
     */
    public class Tiltshift3 extends MovieClip
    {
        private var _viewport:View1;
        private var _canvas:Bitmap;
        private var _canvas2:Bitmap;
        private var _stgW:int=475;
        private var _stgH:int=475;
        
        public function Tiltshift3() 
        {
            var loader:Loader = new Loader;
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, _onInit);
            loader.load(new URLRequest("http://wonderfl.reinit.info/green2.png"),new LoaderContext(true));
        }
        
        private function _onInit(e:Event):void 
        {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            stage.frameRate = 60;
            
            var photoBmd:BitmapData = Bitmap(e.target.content).bitmapData.clone();
            
            _bgBmd = photoBmd;
            _viewport = new View1(_stgW, _stgH, _bgBmd);
            _canvas = new Bitmap;
            _canvas2 = new Bitmap;
            addChild(_canvas);
            addChild(_canvas2);    //msk
            
            _canvas2.filters = [getSaturationFilter(1.8)];
            _canvas.filters = [new BlurFilter(6, 6), getSaturationFilter(4)];
            
            var msk:Sprite = new Sprite();
            var g:Graphics = msk.graphics;
            g.beginFill(0);
            g.drawCircle(_stgW >> 1, _stgH >> 1, 160);
            g.endFill();
            msk.filters = [new BlurFilter(160, 160)];
            addChild(msk);
            _canvas2.cacheAsBitmap = true;
            msk.cacheAsBitmap = true;
            
            _canvas2.mask = msk;
            filters = [new GlowFilter(0, 0.3, 160, 160, 1, 1, true)];
            addEventListener(Event.ENTER_FRAME, _onEnterFrame);
        }
        
        private function _onEnterFrame(e:Event):void 
        {
            var bmd:BitmapData = new BitmapData(500, 500,true,0x00ffffff);
            var bmd2:BitmapData = new BitmapData(500, 500, true, 0x00ffffff);
            
            bmd.draw(_bgBmd);
            bmd.draw(_viewport);
            bmd2.copyPixels(bmd, bmd.rect, new Point);
            
            _canvas.bitmapData = bmd;
            _canvas2.bitmapData = bmd2;
            
            _viewport.update();
        }
        
        private static var LUMINANCE_R:Number = 0.212671;
        private static var LUMINANCE_G:Number = 0.715160;
        private static var LUMINANCE_B:Number = 0.072169;
        private var _bgBmd:BitmapData;

        private function getSaturationFilter(saturation:Number):BitmapFilter
        {
            var sf:Number = saturation;
            var nf:Number = 1-sf;
            var nr:Number = LUMINANCE_R * nf;
            var ng:Number = LUMINANCE_G * nf;
            var nb:Number = LUMINANCE_B * nf;
            
            return new ColorMatrixFilter([
                nr+sf,  ng,     nb,     0,  0,
                nr,     ng+sf,  nb,     0,  0,
                nr,     ng,     nb+sf,  0,  0,
                0,      0,      0,      1,  0
            ]);
        }
    }
}

import flash.display.BitmapData;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.BitmapMaterial;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.shadematerials.GouraudMaterial;
import org.papervision3d.materials.special.CompositeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.BasicView;

class View1 extends BasicView
{
    private var _containter:DisplayObject3D;
    private var _containter2:DisplayObject3D;
    private var _light:PointLight3D;
    private var _matBmd:BitmapData;
    
    function View1(w:int,h:int,bmd:BitmapData)
    {
        _matBmd = bmd;
        super(w, h, true);
        camera.focus = 2;
        camera.zoom = 500;
        camera.z = -1000;
        init3d();
    }
    
    public function update():void
    {
        singleRender();
        _containter.roll(1);
        _containter.yaw(1);
        _containter.pitch(1);
    }
    
    private function init3d():void 
    {
        var material2:BitmapMaterial = new BitmapMaterial(_matBmd);
        _containter = new DisplayObject3D;
        var cube0:Cube = new Cube(new MaterialsList( { all:material2 } ), 300, 300, 300, 1, 1, 1);
        material2.precise = true;
        scene.addChild(_containter);
        _containter.addChild(cube0);
    }
}