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

papervision3d cube geometry.vertices

Get Adobe Flash player
by yoshimax 25 Feb 2009
    Embed
package {
    import flash.display.*;
    import flash.events.*;

    import org.papervision3d.view.*;
    import org.papervision3d.materials.*;
    import org.papervision3d.objects.*;
    import org.papervision3d.objects.primitives.*;
    
    import org.papervision3d.materials.utils.MaterialsList;
    import org.papervision3d.cameras.*;
    import org.papervision3d.materials.special.CompositeMaterial;

    import caurina.transitions.Tweener;
    import caurina.transitions.properties.*;
    
    import flash.text.TextField;

    public class Main extends BasicView {
	private var sphere:Sphere;
	private var cube:Cube;
	private var bitmapFileMaterial:BitmapFileMaterial;
	private var position_num:Number  = 0;
        private var text_1:TextField;	
        private var text_2:TextField;
        private var text_3:TextField;
        private var text_4:TextField;
        private var text_5:TextField;

	public function Main() {
	    //super(1440, 720, true, true, CameraType.FREE);
	    stage.scaleMode = StageScaleMode.NO_SCALE;
	    stage.quality   = StageQuality.LOW;
	    init();
	}

	public function init():void {
           text_1 = new TextField;
           text_1.x = 0;
           addChild( text_1 );
           text_2 = new TextField;
           text_2.x = 100;
           addChild( text_2 );
           text_3 = new TextField;
           text_3.x = 200;
           addChild( text_3 );
           text_4 = new TextField;
           text_4.x = 300;
           addChild( text_4 );
           text_5 = new TextField;
           text_5.x = 400;
           addChild( text_5 );

	    // material
	    var colorMaterial:ColorMaterial = new ColorMaterial( 0x666666, 0.3 ); 
	    var wireframeMaterial:WireframeMaterial = new WireframeMaterial( 0x333333, 1 ); 
	    var compositeMaterial:CompositeMaterial = new CompositeMaterial();
	    compositeMaterial.addMaterial(colorMaterial);
	    compositeMaterial.addMaterial(wireframeMaterial);
	    compositeMaterial.doubleSided = true;
	    
	    // cube
	    cube = new Cube(new MaterialsList({all:compositeMaterial}), 200, 200, 200, 5, 5, 5);
	    scene.addChild(cube);
	    
	    // sphere
	    sphere = new Sphere(new ColorMaterial(0xFF0000,1),5,10,10);
	    scene.addChild(sphere);

	    camera.x = 200;
	    camera.y = 200
	    camera.z = 300;
	    camera.focus = 350;
	    camera.zoom = 1;
	    addEventListener(Event.ENTER_FRAME, enterFrameHandler);
	    startRendering();
            moveSphare();
	}
	
	private function moveSphare():void{
	    if( position_num >= cube.geometry.vertices.length ) position_num = 0;
	    
            text_1.text = cube.geometry.vertices.length.toString();
	    text_2.text = position_num.toString();
	    text_3.text = cube.geometry.vertices[position_num].x;
	    text_4.text = cube.geometry.vertices[position_num].y;
	    text_5.text = cube.geometry.vertices[position_num].z;

		Tweener.addTween(sphere, {
	            x:cube.geometry.vertices[position_num].x,
		    y:cube.geometry.vertices[position_num].y,
		    z:cube.geometry.vertices[position_num].z,
		    time:0.2,
		    delay:0,
		    transition: "easeInOutQuart",
		    onComplete: moveSphare });
	    
            var v = cube.geometry.vertices[position_num];
		Tweener.addTween(v, {
		    x:cube.geometry.vertices[position_num].x * 0.5,
		    y:cube.geometry.vertices[position_num].y * 0.5 ,
		    z:cube.geometry.vertices[position_num].z * 0.5 ,
		    time:0.2,
		    delay:0.2,
		    transition: "easeInOutQuart" });
	    position_num++;
	    
	}
	
	private function enterFrameHandler(event:Event):void {
	}
    }

}