とりあえず3D第一歩

by Nowloading_
♥0 | Line 30 | Modified 2011-08-21 11:41:27 | MIT License
play

ActionScript3 source code

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

package{
    import org.papervision3d.core.geom.Lines3D;
    import org.papervision3d.materials.special.LineMaterial;
    import org.papervision3d.view.*;
    import flash.events.Event;
    
    [SWF(backgroundColor = 0x000000)]
    public class linebox extends BasicView{
        private var line:LineMaterial = new LineMaterial(0xffffff);
        private var lines:Lines3D = new Lines3D(line);
        private var i:int = 10;
        public function linebox(){
            init();
        }
        private function init():void{
            lines.addNewLine(3,-500,0,0,500,0,0);
            lines.addNewLine(3,0,-500,0,0,500,0);
            lines.addNewLine(3,0,0,-500,0,0,500);
            
            scene.addChild(lines);
            
            
            camera.x = -600;
            camera.y = 500;
            //camera.lookAt(lines);
            
            startRendering();
            
            addEventListener(Event.ENTER_FRAME,oEF);
        }
        private function oEF(e:Event):void{
            camera.x = 1000*Math.sin(Math.PI/360*i);
            camera.z = 1000*Math.cos(Math.PI/360*i);
            i+=10;
        }
        

    }    
}