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

forked from: 星と空間

//////////////////////////////////////////////////////////////////////////////
星と空間 [Papervision3D]
//////////////////////////////////////////////////////////////////////////////
Get Adobe Flash player
by twotree 20 May 2010
/**
 * Copyright twotree ( http://wonderfl.net/user/twotree )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6q1e
 */

// forked from ProjectNya's 星と空間
////////////////////////////////////////////////////////////////////////////////
// 星と空間 [Papervision3D]
////////////////////////////////////////////////////////////////////////////////

package {

	import flash.display.Sprite;
 	import flash.events.Event;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.cameras.Camera3D;
	import org.papervision3d.view.Viewport3D;
	import org.papervision3d.render.BasicRenderEngine;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.special.ParticleField;
	import org.papervision3d.materials.special.ParticleMaterial;

	[SWF(backgroundColor="#000000", width="465", height="465", frameRate="30")]

	public class Main extends Sprite {
		private var scene:Scene3D;
		private var camera:Camera3D;
		private var viewport:Viewport3D;
		private var renderer:BasicRenderEngine;
		private var particles:ParticleField;
		private static var colors:Array = [0xFFFFFF, 0xFFFF00, 0x00FFFF];
		private static var stars:Array = [400, 100, 100];
		private var angle:Number = 90;
		private static var radius:uint = 1000;

		public function Main() {
			//Wonderfl.capture_delay(8);
			init();
		}

		private function init():void {
			graphics.beginFill(0x000000);
			graphics.drawRect(0, 0, 465, 465);
			graphics.endFill();
			scene = new Scene3D();
			camera =new Camera3D();
			camera.z = -1000;
			camera.focus = 500;
			camera.zoom = 0.1;
			camera.target = DisplayObject3D.ZERO;
			viewport = new Viewport3D(0, 0, true, false);
			addChild(viewport);
			renderer = new BasicRenderEngine();
			addEventListener(Event.ENTER_FRAME, render, false, 0, true);
			for (var n:uint = 0; n < 3; n++) {
				var pm:ParticleMaterial = new ParticleMaterial(colors[n], 1, 1, 1);
				var particles:ParticleField = new ParticleField(pm, stars[n], 5, 2000, 2000, 2000);
				scene.addChild(particles);
			}
		}
		private function render(evt:Event):void {
			angle ++;
			var cp:Number = Math.sin(angle*Math.PI/180)*radius*0.4+ radius*0.6;
			camera.x = cp*Math.sin(angle*Math.PI/180);
			camera.y = cp*Math.sin(angle*Math.PI/180);
			camera.z = cp*Math.cos(angle*Math.PI/180);
			renderer.renderScene(scene, camera, viewport);
		}
		
	}

}