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

sphere by cube

Get Adobe Flash player
by randomizer 26 Apr 2011

    Tags

    3d
    Embed
/**
 * Copyright randomizer ( http://wonderfl.net/user/randomizer )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4JlN
 */

package{
    import flash.events.Event;
    import org.papervision3d.lights.PointLight3D;
    import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
    import org.papervision3d.materials.utils.*;
    import org.papervision3d.objects.primitives.Cube;
    import org.papervision3d.view.BasicView;
    import org.papervision3d.objects.*;

    public class test extends BasicView {
        public var cnt:int;
        public var cubeArray:Array;
        public var cubes:DisplayObject3D;
        public var division:int = 5;

        public function test() : void {
            var light:PointLight3D = new PointLight3D();
            var material:FlatShadeMaterial = new FlatShadeMaterial( light , 0xFFFFFF , 0x000000 );
            var mList:MaterialsList;
            var i:int;
            var px:Number,py:Number,pz:Number;
            var ix:int,iy:int,iz:int;

            cubes = new DisplayObject3D();
            
            mList = new MaterialsList();
            mList.addMaterial( material , "all" );
            cubeArray = new Array();

            for( ix = -division ; ix < division-1 ; ix++ ) {
                cubeArray[ix+division] = new Array();
                for( iy = -division ; iy < division-1 ; iy++ ) {
                    cubeArray[ix+division][iy+division] = new Array();
                    for( iz = -division ; iz < division-1 ; iz++ ) {
                        if( Math.pow(ix*80.0+40.0,2.0) + Math.pow(iy*80.0+40.0,2.0) + Math.pow(iz*80.0+40.0,2.0) >
                            Math.pow( 80.0*(division-1-1) , 2.0 ) &&
                            Math.pow(ix*80.0+40.0,2.0) + Math.pow(iy*80.0+40.0,2.0) + Math.pow(iz*80.0+40.0,2.0) <
                            Math.pow( 80.0*(division-1) , 2.0 ) ) {
                            var cube:Cube = new Cube( mList , 80 , 80 , 80 , 1 , 1 , 1 , 0 , 0 );
                            cubeArray[ix+division][iy+division][iz+division] = cube;
                            cube.x = ix*80;
                            cube.y = iy*80;
                            cube.z = iz*80;
                            cubes.addChild( cube );
                        }
                    }
                }
            }

            scene.addChild( cubes );

            startRendering();
            addEventListener( Event.ENTER_FRAME , onIdle );
        }

        public function onIdle( e:Event ) : void {
            cubes.rotationX += 1;
            cubes.rotationY += 1;
            cubes.rotationZ += 1;
        }
    }
}