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

一反木綿

modoki さんのエントリーを参考にテスト
http://modoki.org/blog/archives/124
Get Adobe Flash player
by a24 24 Mar 2009
// modoki さんのエントリーを参考にテスト
// http://modoki.org/blog/archives/124

package
{
	import flash.events.Event;
	import flash.events.MouseEvent;
	import org.papervision3d.cameras.CameraType;
	import org.papervision3d.core.proto.LightObject3D;
	import org.papervision3d.materials.shadematerials.GouraudMaterial;
	import org.papervision3d.materials.WireframeMaterial;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;

	public class Main extends BasicView
	{
		private var mainObj:Plane;
		private var si:Number = 0;
		private var material_a:GouraudMaterial;
		private var material_b:WireframeMaterial;

		public function Main():void
		{
			super(600, 600, true, true, CameraType.FREE);

			// カメラ設定初期化
			//camera.moveForward(200);
			//camera.moveUp(30000);
			//camera.rotationY = 60;
			camera.z = -1500;
			camera.x = 200;

			// ライト設定
			var light:LightObject3D = new LightObject3D();
			light.x = -200;
			light.y = 100;

			// Material
			material_a = new GouraudMaterial(light, 0xFFFFFF, 0x3399FF);
			material_b = new WireframeMaterial();
			material_a.doubleSided = true;
			material_b.doubleSided = true;

			// DisplayObject
			mainObj = new Plane(material_a, 1600, 500, 10, 5);
			mainObj.rotationX = 70;
			mainObj.rotationY = 60;
			scene.addChild(mainObj);

			// Handler
			stage.addEventListener(MouseEvent.MOUSE_UP, clickHandler);

			// レンダリング開始
			startRendering();
		}

		/**
		 *-------------------------------------------------------
		 * Click
		 *-------------------------------------------------------
		 */
		private function clickHandler(e:MouseEvent):void
		{
			if (mainObj.material == material_a) {
				mainObj.material = material_b;
			} else {
				mainObj.material = material_a;
			}
		}

		/**
		 *-------------------------------------------------------
		 * onRenderTick 
		 *-------------------------------------------------------
		 */
		private var _wave:Number = 8;
		private var _speed:Number = 30;
		override protected function onRenderTick(event:Event = null):void {
			// 回転
			//mainObj.roll(-((mouseX - stage.width * .5) / 400));

			// ゆらめき
			si += _speed;
			for ( var i:String in mainObj.geometry.vertices ) {
				mainObj.geometry.vertices[i].z = Math.cos((si + (Number(i) * _wave)) * Math.PI / 180) * 20 * _wave;
			}
			_wave  = (_wave  > 0)? _wave  - 8  / 120 : 8  ;
			_speed = (_speed > 0)? _speed - 30 / 120 : 30 ;
			super.onRenderTick(event);
		}
	}
}