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

Processingのアレっぽいやつ

Processing OpenGLサンプルのlightsGLっぽいやつ。
@author ish-xxxx
Get Adobe Flash player
by ish_xxxx 20 Apr 2009
package  {
	import flash.display.Sprite;
	import flash.events.Event;
	import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
	import org.papervision3d.materials.utils.MaterialsList;
	import org.papervision3d.view.Viewport3D;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.render.BasicRenderEngine;
	import org.papervision3d.render.QuadrantRenderEngine;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.cameras.Camera3D;
	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.objects.primitives.Cube;
	import net.hires.debug.Stats;
	/**
	 * Processing OpenGLサンプルのlightsGLっぽいやつ。
	 * @author ish-xxxx
	 */
    [SWF(backgroundColor="0x000000", frameRate="45")]
	public class App extends Sprite {
		private var viewport:Viewport3D;
		private var renderer:BasicRenderEngine;
		//private var renderer:QuadrantRenderEngine; //これ使うと死ぬ
		private var scene:Scene3D;
		private var world:DisplayObject3D;
		private var camera:Camera3D;
		private var container:Sprite;
		private var length:uint;
		public function App() {
			container = addChild( new Sprite ) as Sprite;
			viewport = container.addChild( new Viewport3D( 0, 0, true, true ) ) as Viewport3D;
			renderer = new BasicRenderEngine;
			scene = new Scene3D;
			world = scene.addChild( new DisplayObject3D ) as DisplayObject3D;
			camera = new Camera3D;
			camera.z = -270;
			setup();
		}
		
		private function setup() : void {
			var materialsList:MaterialsList = new MaterialsList;
			var material:FlatShadeMaterial = new FlatShadeMaterial( new PointLight3D );
			materialsList.addMaterial( material ,"front");
			materialsList.addMaterial( material ,"back");
			materialsList.addMaterial( material ,"left");
			materialsList.addMaterial( material ,"right");
			materialsList.addMaterial( material ,"top");
			materialsList.addMaterial( material ,"bottom");
			for ( var i:uint = 0, _x:int = -225, _y:int = 225; _y > -225 ; i++ ) {
				var cube:Cube = new Cube( materialsList, 25, 25, 25, 1, 1, 1 );
				cube.name = "c" + String( i );
				cube.x = _x;
				cube.y = _y;
				if( ( _x += 30 ) >= 225 ) { 
					_y -= 30;
					_x = -225;
				} else {
					_y = cube.y;
				}
				world.addChild( cube );
			}
			length = i;
			draw();
		}
		private function draw() : void {
			addEventListener( "enterFrame", render );
			addChild( new Stats );
		}
		private function render( ev:Event ) : void {
			var __len:uint = length;
			while ( __len-- ) {
				var cube:Cube = world.getChildByName( "c" + String( __len ) ) as Cube;
				cube.rotationX = mouseY;
				cube.rotationY = mouseX;
			}
			renderer.renderScene( scene, camera, viewport );
		}
	}
}