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

flash on 2012-7-13

途中 ネタが思いついたら後日修正
papervision3d練習その4
Get Adobe Flash player
by hacker_cobulht0 13 Jul 2012
    Embed
/**
 * Copyright hacker_cobulht0 ( http://wonderfl.net/user/hacker_cobulht0 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/lDhw
 */

//途中 ネタが思いついたら後日修正
package {//papervision3d練習その4
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import org.papervision3d.materials.*;
    import org.papervision3d.objects.*;
    import org.papervision3d.materials.utils.*;
    import org.papervision3d.objects.primitives.*;
    import org.papervision3d.view.*;
    
    import org.papervision3d.events.InteractiveScene3DEvent;
    import org.papervision3d.core.utils.InteractiveSceneManager;
    import org.papervision3d.core.utils.Mouse3D;
    
    import org.papervision3d.typography.*;
    import org.papervision3d.typography.fonts.*;
    import org.papervision3d.materials.special.*;

    import org.papervision3d.core.geom.*;
    
    //Twitter
    import caurina.transitions.Tweener; 

    [SWF(width = "465", height = "465", backgroundColor = 0xFFFFFF, frameRate = "30")]

    public class Main extends BasicView {

        private var bg:dotPattern=new dotPattern(0xECEABE,0xC5E384);
        private var rootNode  : DisplayObject3D;
        private var msP:Point = new Point();
        
        //Material
        private var mat1: BitmapMaterial;//-外面
        private var mat2: BitmapMaterial;//-水面
        private var mat3: BitmapMaterial;//-内面
        private var mat4: BitmapMaterial;//-内面-暗い
        private var mat5: BitmapMaterial;//-水面-暗い
        private var mat6: BitmapMaterial;//-噴水面-水たまり
        
        private var matPipe: BitmapMaterial;//-パイプ
        private var matDack: BitmapMaterial;//-あひる
        
        //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        private var cube_Back:Cube//-奥基本面
        private var _Dack:Plane;//-あひる
        private var splashList:Array=new Array();//-水飛沫
        
        //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        public function Main() {
            super(0,0,true,true);
            
            init();
        }
        
        public function init() {
            //背景----------------------------------------------------------------------------------------------------
            addChildAt(bg,0);
            //----------------------------------------------------------------------------------------------------
            rootNode = new DisplayObject3D();
            scene.addChild( rootNode );    
            
            //Material----------------------------------------------------------------------------------------------------
            //mat1-外面
            var bD:BitmapData = new BitmapData(100,100,true,0x00000000);
            var sh:diceDesign1=new diceDesign1();
            bD.draw(sh);
            mat1 = new BitmapMaterial(bD);
            mat1.smooth = true;
            
            //mat2-水面
            var bD2:BitmapData = new BitmapData(300,200,true,0x00000000);
            var sh2:dotPattern=new dotPattern(0x9FE2BF,0x1FCECB);
            bD2.draw(sh2);
            mat2 = new BitmapMaterial(bD2);
            mat2.smooth = true;
            
            
            //mat5-水面-暗い
            var bD5:BitmapData = new BitmapData(300,200,true,0x00000000);
            var sh5:dotPattern=new dotPattern(0x7BCDC2,0x9FE2BF);
            bD5.draw(sh5);
            mat5 = new BitmapMaterial(bD5);
            mat5.smooth = true;            
            
            
            //mat3-内面
            var bD3:BitmapData = new BitmapData(200,200,true,0x00000000);
            var sh3:dotPattern=new dotPattern(0xDEBBAF,0xEFCDB8);
            bD3.draw(sh3);
            mat3 = new BitmapMaterial(bD3);
            mat3.smooth = true;
            
            //mat4-内面-暗い
            var bD4:BitmapData = new BitmapData(200,200,true,0x00000000);
            var sh4:dotPattern=new dotPattern(0xd7ac9d,0xEFCDB8);
            bD4.draw(sh4);
            mat4 = new BitmapMaterial(bD4);
            mat4.smooth = true;
            
            //mat6-噴水面-水たまり
            var bD6:BitmapData = new BitmapData(100,100,true,0x00000000);
            var sh6:Sprite=new Sprite();
            var sh61:diceDesign1=new diceDesign1();
            sh6.addChild(sh61);
            var sh62:Puddle=new Puddle();
            sh6.addChild(sh62);
            
            bD6.draw(sh6);
            mat6 = new BitmapMaterial(bD6);
            mat6.smooth = true;
            
            //筐体作成----------------------------------------------------------------------------------------------------    
            var mL_Back:MaterialsList = new MaterialsList({
            front: mat1,
            back: mat3,
            right: mat1,
            left: mat1,
            top: mat1,
            bottom: mat1
            });
            
            var mL_Top:MaterialsList = new MaterialsList({
            front: mat1,
            back: mat1,
            right: mat1,
            left: mat1,
            top: mat6,
            bottom: mat4
            });
            
            var mL_Bottom:MaterialsList = new MaterialsList({
            front: mat1,
            back: mat2,
            right: mat1,
            left: mat1,
            top: mat5,
            bottom: mat2
            });
            
            var mL_Left:MaterialsList = new MaterialsList({
            front: mat1,
            back: mat1,
            right: mat4,
            left: mat1,
            top: mat1,
            bottom: mat1
            });
            
            var mL_Right:MaterialsList = new MaterialsList({
            front: mat1,
            back: mat1,
            right: mat1,
            left: mat4,
            top: mat1,
            bottom: mat1
            });
            
            
            cube_Back = new Cube(mL_Back, 200, 20, 100, 1, 1, 1);
            cube_Back.name="cube_Back";
            rootNode.addChild(cube_Back);
            cube_Back.x=0;
            cube_Back.y=-50;
            cube_Back.z=+100;
            
            var cube_Top = new Cube(mL_Top, 200, 120, 20, 1, 1, 1);
            cube_Top.name="cube_Top";
            rootNode.addChild(cube_Top);
            cube_Top.x=cube_Back.x;
            cube_Top.y=cube_Back.y+40;
            cube_Top.z=cube_Back.z-50;
            
            var cube_Bottom = new Cube(mL_Bottom, 200, 120, 30, 1, 1, 1);
            cube_Bottom.name="cube_Bottom";
            rootNode.addChild(cube_Bottom);
            cube_Bottom.x=cube_Back.x;
            cube_Bottom.y=cube_Back.y-35;
            cube_Bottom.z=cube_Back.z-50;
            
            var cube_Left = new Cube(mL_Left, 20, 120, 100, 1, 1, 1);
            cube_Left.name="cube_Left";
            rootNode.addChild(cube_Left);
            cube_Left.x=cube_Back.x-100;
            cube_Left.y=cube_Back.y;
            cube_Left.z=cube_Back.z-50;
            
            var cube_Right = new Cube(mL_Right, 20, 120, 100, 1, 1, 1);
            cube_Right.name="cube_Right";
            rootNode.addChild(cube_Right);
            cube_Right.x=cube_Back.x+100;
            cube_Right.y=cube_Back.y;
            cube_Right.z=cube_Back.z-50;
            
            
            
            
            //円柱作成----------------------------------------------------------------------------------------------------
            var bDPipe:BitmapData = new BitmapData(30,30,true,0x00000000);
            var shPipe:pipeDesign=new pipeDesign();
            bDPipe.draw(shPipe);
            matPipe = new BitmapMaterial(bDPipe);
            matPipe.smooth = true;
            
            var pipe = new Cylinder(matPipe, 40, 30);
            rootNode.addChild(pipe);
            pipe.x=cube_Back.x-25;
            pipe.y=cube_Back.y+65;
            pipe.z=cube_Back.z-50;
            
            var pipe2 = new Cylinder(matPipe, 20, 20);
            rootNode.addChild(pipe2);
            pipe2.x=cube_Back.x-25;
            pipe2.y=cube_Back.y+85;
            pipe2.z=cube_Back.z-50;
            
            var matPipe2: ColorMaterial = new ColorMaterial(0x45CEA2,0.25);
            var pipe3 = new Cylinder(matPipe2, 10, 100);
            rootNode.addChild(pipe3);
            pipe3.x=cube_Back.x-25;
            pipe3.y=cube_Back.y+10;
            pipe3.z=cube_Back.z-50;
            
            
            //あひる----------------------------------------------------------------------------------------------------
            var bDDack:BitmapData = new BitmapData(45,45,true,0x00000000);
            var shDack:callDack=new callDack();
            bDDack.draw(shDack);
            matDack = new BitmapMaterial(bDDack);
            matDack.smooth = true;
            matDack.oneSide = true;
            
            _Dack = new Plane(matDack);
            rootNode.addChild(_Dack);
            _Dack.x=cube_Back.x+80;
            _Dack.y=cube_Back.y+65;
            _Dack.z=cube_Back.z-50;
            
            fCD1();
            
            //水飛沫----------------------------------------------------------------------------------------------------
            
            for (var q:int=0; q < 20; q++) {
                    var matS: ColorMaterial = new ColorMaterial(0x9FE2BF);
                    var spl:Sphere = new Sphere(matS,2,10,10);
                    rootNode.addChild( spl );
                    spl.x=cube_Back.x-25;
                    spl.y=cube_Back.y+100;
                    spl.z=cube_Back.z-50;
                    splashList.push({_obj:spl,_velX:Math.random() * 10 - 5,_velY:Math.random() * -10,_velZ:Math.random() * 10 - 5});
                }
            var splE:Sphere = new Sphere(matS,5,10,10);
            rootNode.addChild( splE );
            splE.x=cube_Back.x-25;
            splE.y=cube_Back.y+95;
            splE.z=cube_Back.z-50;        
            
            
            camera.z = -500;
            camera.zoom = 50;
            camera.focus = 15;
            
            stage.addEventListener(Event.ENTER_FRAME, loop);
            bg.addEventListener(MouseEvent.MOUSE_DOWN, startRotation);
        }
        
        
        
        
        
        
        private function startRotation(ev):void{
            bg.addEventListener(MouseEvent.MOUSE_UP, endDrag);
            bg.addEventListener(Event.MOUSE_LEAVE, endDrag);
            bg.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
            
            msP.x = mouseX;
            msP.y = mouseY;
        }
        private function endDrag(ev):void{
            bg.removeEventListener(MouseEvent.MOUSE_UP, endDrag);
            bg.removeEventListener(Event.MOUSE_LEAVE, endDrag);
            bg.removeEventListener(MouseEvent.MOUSE_MOVE, onMove);
        }
        private function onMove(ev):void{            
            rootNode.rotationX -= (ev.stageY - msP.y);
            rootNode.rotationY -= (ev.stageX - msP.x);
            
            msP.x = mouseX;
            msP.y = mouseY;
        }
        
        
        private function fCD1():void{
            Tweener.addTween(_Dack, {rotationY:0,time:5,transition:"easeOutQuad"});
            Tweener.addTween(_Dack, {x:cube_Back.x+60,z:cube_Back.z-100,time:5,transition:"easeOutQuad", onComplete:fCD2});
        }
        private function fCD2():void{
            Tweener.addTween(_Dack, {x:cube_Back.x+20,z:cube_Back.z-80,time:5,delay:2,transition:"easeOutQuad", onComplete:fCD3});
        }
        private function fCD3():void{
            Tweener.addTween(_Dack, {rotationY:180,time:5,transition:"easeOutQuad"});
            Tweener.addTween(_Dack, {x:cube_Back.x+80,z:cube_Back.z-50,time:5,delay:5,transition:"easeOutQuad", onComplete:fCD1});
        }
        //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        private function loop( event:Event ):void {
            singleRender();
            var _grav=0.8;
            for (var q:int=0; q < splashList.length; q++) {
                var spl = splashList[q];
                
                spl._obj.x += spl._velX;
                spl._obj.y += spl._velY;
                spl._obj.z += spl._velZ;        
                spl._velY -= _grav;
                
                if (spl._obj.y <20){saiSet(spl);}
                
            }
            
        }
        private function saiSet(arg){
            arg._obj.x=cube_Back.x-25;
            arg._obj.y=cube_Back.y+115;
            arg._obj.z=cube_Back.z-50;
            arg._velX=Math.random() * 8-4;
            arg._velY=Math.random() * 10;
            arg._velZ=Math.random() * 4-2;
        }
        //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    }
}










import flash.display.*;
import flash.filters.GlowFilter;

//箱--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//外面
class diceDesign1 extends Sprite{
public function diceDesign1( ){
    var arr:Array=[0xFCDC6B,0xFCE983,0xF0E991,0xEDEABF,0xC5E285,0xA8E39F];
    var bmp:BitmapData = new BitmapData(465, 465, false, 0xffffff);
    var sh:Sprite = new Sprite();
    for(var j:int=0; j < 31; j++){
        var cl=j % arr.length;
        sh.graphics.beginFill(arr[cl]);
        sh.graphics.drawRect(0,j*15,465,15);
        sh.graphics.endFill();
        
        var sh2:Shape=new Shape();
        sh.addChild(sh2);
        sh2.graphics.beginFill(arr[cl],0.5);
        sh2.graphics.drawRect(j*15,0,15,465);
        sh2.graphics.endFill();
    }
    bmp.draw(sh);
    addChild(new Bitmap(bmp))
}
}
//水面
class dotPattern extends Sprite{    
public function dotPattern(arg1,arg2){
    var bg:Sprite=new Sprite();
    bg.graphics.beginFill(arg1,1);
    bg.graphics.drawRect(0,0,465,465);
    bg.graphics.endFill();
    for(var j:int=0; j < 2304; j++){
        var dot:Sprite=new Sprite();
        dot.graphics.beginFill(arg2,0.5);
        dot.graphics.drawCircle(0,0,2.5);
        dot.graphics.endFill();
        dot.x=j%48*10;
        if(j%2==0){dot.y=Math.floor(j / 48)*20+10;}else{dot.y=Math.floor(j / 48)*20;}        
        bg.addChild(dot);
    }
    addChild(bg);    
}
}
//内面
class diceDesign2 extends Sprite{
public function diceDesign2(arr){
    for(var j:int=0; j < 20; j++){
        this.graphics.beginFill(arr[j%2],1);
        this.graphics.drawRect(j*10,0,10,200);
        this.graphics.endFill();        
    }
}
}

//パイプ
class pipeDesign extends Sprite{
public function pipeDesign(){
    var arr:Array=[0xE7FFCD,0xC2F3FF,0x9FE2BF];
    var bmp:BitmapData = new BitmapData(200, 200, false, 0xffffff);
    var sh:Sprite = new Sprite();
    for(var j:int=0; j < 20; j++){
        var cl=j % arr.length;
        sh.graphics.beginFill(arr[cl]);
        sh.graphics.drawRect(0,j*10,200,15);
        sh.graphics.endFill();
        
        var sh2:Shape=new Shape();
        sh.addChild(sh2);
        sh2.graphics.beginFill(arr[cl],0.5);
        sh2.graphics.drawRect(j*10,0,15,200);
        sh2.graphics.endFill();
    }
    bmp.draw(sh);
    addChild(new Bitmap(bmp))
}
}
//装飾--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//水たまり
class Puddle extends Sprite{
public function Puddle(){
        this.graphics.beginFill(0x9FE2BF);
        this.graphics.drawEllipse(10,15,65,80);
        this.graphics.drawEllipse(80,30,15,20);
        this.graphics.endFill();
        filters = [ new GlowFilter( 0x1FCECB, 1, 10, 10, 1,2,true ) ] ;
}
}
//Chick
class callDack extends Sprite{
    public var pic:drawDack=new drawDack();
public function callDack(){
    addChild(pic);
    pic.scaleX=pic.scaleY=0.8;
    pic.x=15;
    pic.y=15;
}
}
class drawDack extends Sprite{
    private var head:Sprite=new Sprite();
    private var body:Sprite=new Sprite();
    private var scarf:Sprite=new Sprite();
    public var foot:Sprite=new Sprite();
    
public function drawDack(){
        head.graphics.beginFill(0xEDEDED);
        head.graphics.drawCircle(0,0,9);//head
        head.graphics.endFill();
        var head_1:Sprite = new Sprite();
        head_1.graphics.beginFill(0x414A4C);//eye
        head_1.graphics.drawCircle(-1,-1,2);
        head_1.graphics.endFill();
        head_1.graphics.beginFill(0xFFB653);//mouse
        head_1.graphics.drawEllipse(-15,-2,7,5);        
        head_1.graphics.endFill();
        head.addChild(head_1);
        addChild(head);
        
        body.graphics.beginFill(0xEDEDED);//body
        body.graphics.drawEllipse(-2,0,32,22);
        body.graphics.endFill();
        var body_1:Sprite = new Sprite();
        body_1.graphics.beginFill(0xEDEDED);//teil
        body_1.graphics.moveTo(20,2);
        body_1.graphics.lineTo(35,2);
        body_1.graphics.lineTo(28,14);
        body_1.graphics.endFill();
        body.addChild(body_1);
        addChild(body);    
        
        foot.graphics.lineStyle(2,0xFFB653);//foot
        foot.graphics.moveTo(18,23);
        foot.graphics.lineTo(18,25);
        foot.graphics.moveTo(18,25);
        foot.graphics.lineTo(15,30);
        foot.graphics.moveTo(18,25);
        foot.graphics.lineTo(12,28);
        foot.graphics.moveTo(18,25);
        foot.graphics.lineTo(10,25);        
        foot.graphics.endFill();
        
        addChild(foot);    
        
        /*scarf.graphics.beginFill(0xFD7C6E);
        scarf.graphics.drawEllipse(-5,8,14,3);
        scarf.graphics.endFill();    
        scarf.rotation=-40;        
        var scarf_1:Sprite = new Sprite();    
        scarf_1.graphics.beginFill(0xFD7C6E);
        scarf_1.graphics.drawEllipse(0,0,15,5);
        scarf_1.graphics.endFill();    
        scarf_1.rotation=-60;
        scarf_1.x=5;scarf_1.y=8;        
        var scarf_2:Sprite = new Sprite();    
        
        scarf_2.graphics.beginFill(0xFD7C6E);
        scarf_2.graphics.drawEllipse(0,0,15,5);
        scarf_2.graphics.endFill();    
        scarf_2.rotation=-20;
        scarf_2.x=5;scarf_2.y=8;        
        scarf.addChild(scarf_2);
        scarf.addChild(scarf_1);
        addChild(scarf);*/
    }
}