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

JigLibFlash Test

JigLibFlash が Papervision 以外の 3D エンジンに対応して、書き方が変わっていたので新 JigLibFlash をいじってみた。

...
@author tkinjo
Get Adobe Flash player
by tkinjo 09 Jun 2009
/**
 * Copyright tkinjo ( http://wonderfl.net/user/tkinjo )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/d53C
 */

package  
{
	/**
	 * JigLibFlash が Papervision 以外の 3D エンジンに対応して、書き方が変わっていたので新 JigLibFlash をいじってみた。
	 */
	
	import flash.display.Sprite;
	import flash.events.Event;
	import jiglib.physics.RigidBody;
	import jiglib.plugin.papervision3d.Papervision3DPhysics;
	import org.papervision3d.core.proto.CameraObject3D;
	import org.papervision3d.materials.utils.MaterialsList;
	import org.papervision3d.materials.WireframeMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.view.AbstractView;
	import org.papervision3d.view.BasicView;
	
	[SWF(width = "465", height = "465", frameRate = "60", backgroundColor = "#ffffff")]
	
	/**
	 * ...
	 * @author tkinjo
	 */
	public class Main extends Sprite
	{
		private const speed:Number = 10;
		
		private var view:AbstractView;
		private var scene:Scene3D;
		private var camera:CameraObject3D;
		private var cameraTarget:DisplayObject3D;
		
		private var physics:Papervision3DPhysics;
		
		/**
		* 
		*/
		public function Main() 
		{
			view = new BasicView( stage.stageWidth, stage.stageHeight );
			addChild( view );
			
			scene = view.scene;
			camera = view.camera;
			
			
			
			/** --------------------------------------------------
			 * カメラ設定
			 */
			camera.x = 1000
			camera.y = 1000;
			
			cameraTarget = new DisplayObject3D();
			camera.lookAt( cameraTarget );
			
			
			
			/** --------------------------------------------------
			 * jiglib 設定
			 */
			physics = new Papervision3DPhysics( scene, speed );
			
			// 地面の作成
			var wireframeMaterial:WireframeMaterial = new WireframeMaterial( 0 );
			var ground:RigidBody = physics.createGround( wireframeMaterial, 1000, 0 );
			
			// ボックスの作成
			var materials:MaterialsList = new MaterialsList();
			materials.addMaterial( new WireframeMaterial( 0 ), "all" );
			
			var box:RigidBody;
			for (var i:int = 0; i < 5; i++) {
				box = physics.createCube( materials, 100, 100, 100 );
				box.y = 300 * ( i + 1 );
			}
			
			/** --------------------------------------------------
			 * レンダリングとか
			 */
			addEventListener( Event.ENTER_FRAME, enterFrameHandler );
			view.startRendering();
		}
		
		/**
		 * 
		 * @param	event
		 */
		private function enterFrameHandler( event:Event ):void {
			
			physics.step();
		}
	}
}