forked from: forked from: 【PV3D】Line3Dで遊んでみた

by bradsedito forked from forked from: 【PV3D】Line3Dで遊んでみた (diff: 20)
勉強中。tweenは分からないのでとりあえず今はPV3D部分をば。by max
♥0 | Line 69 | Modified 2011-09-18 12:32:09 | MIT License
play

ActionScript3 source code

/**
 * Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wX2b
 */

// forked from maxcaffy's forked from: 【PV3D】Line3Dで遊んでみた
// forked from Nyarineko's 【PV3D】Line3Dで遊んでみた
//勉強中。tweenは分からないのでとりあえず今はPV3D部分をば。by max
package
{
    import flash.events.*;
    import flash.filters.*;
    
    import org.papervision3d.view.BasicView;
    import org.papervision3d.view.*;
    import org.papervision3d.objects.*;
    import org.papervision3d.core.geom.Lines3D;
    import org.papervision3d.core.geom.renderables.Line3D;
    import org.papervision3d.core.geom.renderables.Vertex3D;
    import org.papervision3d.materials.special.LineMaterial;
    import org.papervision3d.core.effects.*;
    import org.papervision3d.view.layer.BitmapEffectLayer;
    import org.papervision3d.core.effects.BitmapLayerEffect;
    
    
    [SWF(width="465",height="465",backgroundColor="0x000000")]
    public class myLine3D extends BasicView
    {
        public const OBJ_MAX:int = 6;
        public const SW:Number = new Number( stage.stageWidth  );
        public const SH:Number = new Number( stage.stageHeight );
        public const DEPTH:Number =  new Number( 1000 );
        private  var lines3Ds:Vector.<DisplayObject3D>;
        private  var _bfx:BitmapEffectLayer;
        
        function myLine3D():void
        {
            viewport.opaqueBackground = 0x0;
            var line:Line3D;
            var startV3d:Vertex3D;
            var endV3d:Vertex3D;
            
            _bfx = new BitmapEffectLayer(viewport, stage.stageWidth, stage.stageHeight);
            _bfx.addEffect(new BitmapLayerEffect(new BlurFilter(4, 4, 8)));
            viewport.containerSprite.addLayer(_bfx);
            
            lines3Ds =  new Vector.<DisplayObject3D>(OBJ_MAX, true);
            
            var posX:Number;
            var posY:Number;
            var posZ:Number;
            
            for(var i:uint = 1; i < OBJ_MAX; i++)
            {
                addEventListener(Event.ENTER_FRAME, loop);
                var lines3D:Lines3D;
                lines3D = new Lines3D();
                lines3Ds[i] = scene.addChild(lines3D);
                _bfx.addDisplayObject3D( lines3Ds[i] );
                
                posX = Math.random() * SW;
                posY = Math.random() * SH;
                posZ = Math.random() * DEPTH;
                startV3d = new Vertex3D(posX, posY, posZ);
                endV3d = new Vertex3D(posX + 100, posY, posZ);
                
                function loop(event:Event):void
                {
                    lines3D[i].rotationY = rotationY++;  //  90 * Math.floor(Math.random() * 4);
                    lines3D[i].rotationX = rotationX++;  //  90 * Math.floor(Math.random() * 4);
                }
                
                var lm:LineMaterial = new LineMaterial(Math.random()*0xff <<16 | Math.random()*0xff << 8 | Math.random()*0xff);
                line = new Line3D(lines3D, lm, 2, startV3d, endV3d);
                lines3D.addLine(line);
                for each(var obj:* in lines3D.geometry.vertices){
                    obj.x -= 200;
                    obj.y -= 200;
                }
            }
            
            startRendering();
        }
        
        override protected function onRenderTick(event:Event=null):void
        {
            super.onRenderTick(event);  
        }
    }
}