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 HaraMakoto's Text3Dが近づきすぎると消えるような
package {
	import flash.events.Event;
	
	import org.papervision3d.core.clipping.FrustumClipping;
	import org.papervision3d.core.effects.view.ReflectionView;
	import org.papervision3d.materials.WireframeMaterial;
	import org.papervision3d.materials.special.Letter3DMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.typography.Text3D;
	import org.papervision3d.typography.fonts.HelveticaBold;
	import org.papervision3d.view.Viewport3D;
	
	[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="40")]
	

	/**
        * マウスの左右でカメラ近づく/遠ざかる
        */
        public class vectorpaperTest extends ReflectionView
	{
		/**
		 * 3Dベース系の定義
		 */ 
		private var container:DisplayObject3D;
		private var camTarget:DisplayObject3D; //カメラターゲット
		
		/**
		 * 中央の球体
		 */
		private var spObj:Sphere;
		
		/**
		 * LetterMaterial
		 */
		 private var LetterMatArray:Array = new Array();
		
		//static private const CAMERA_POSITION :uint = 500;
		static private const CAMERA_POSITION :uint = 2000;
		
		
		/**
		 * コンストラクタ
		 */
		public function vectorpaperTest()
		{
			addEventListener( Event.ADDED_TO_STAGE, _addStage );
		}
		private function _addStage(e:Event):void
		{
			removeEventListener( Event.ADDED_TO_STAGE, _addStage );
			paperDisplaySetting(); //フィールド設定
			setLetters(); //ベクター表示
			setSphere(); //目印の球体
			addEventListener(Event.ENTER_FRAME, _onEnterFrame);
		}
		
		/**
		 * 3Dフィールド設定
		 */
		private function paperDisplaySetting():void
		{
			//ビューポート設定
			viewport = new Viewport3D(640,480,true); 
			addChild( viewport );
			//カメラ設定
			//camera = new Camera3D();
			camera.z = -300;
			camera.zoom = 1.5;
			camera.focus = 200;
			//カメラターゲット設定
			camTarget = new DisplayObject3D();
			camera.target = camTarget;
			camTarget.x = camTarget.y = 0;
			camTarget.z = 0;
			//シーン設定
			scene = new Scene3D;
			//ベース設定
			container = new DisplayObject3D();
			container.x = container.y = container.z = 0;
			scene.addChild( container );
			//レンダー設定
			renderer.clipping = new FrustumClipping(FrustumClipping.NEAR);
			viewportReflection.alpha = .25;
			
		}
		
		/**
		 * 球体配置
		 */
		private function setSphere():void
		{
			var _bigSphere:Sphere = new Sphere( new WireframeMaterial(0x666666, 10),5 );
			_bigSphere.useOwnContainer = true;
			container.addChild( _bigSphere );
		}
		
		private function setLetters():void
		{
			var lettermat:Letter3DMaterial = new Letter3DMaterial();
			lettermat.fillColor = 0xFF0000;
			lettermat.doubleSided = true;
			
			var char:String;
			for(var i:uint=0; i<10; i++)
			{
				char = String( i );
				var word:Text3D = new Text3D( char, new HelveticaBold(), lettermat );
				container.addChild( word );
				
				//うまくいく?組み合わせ
				
				word.x = -500 + 1000 * Math.random();
				word.y = -250 + 500 * Math.random();
				//word.z = 500 * Math.random() + 1000;
				word.z = 200 * Math.random() -200;
				word.rotationY = 360 * Math.random();
				word.scale = 5 * Math.random() + 0.5;
								
			}
		}
		
		/**
		 * レンダリング
		 */
		private function RenderingScene():void
		{
			//レンダリング
			singleRender();
		}
		
		/**
		 * 毎フレーム処理
		 */
		private function _onEnterFrame( e:Event ):void
		{
			if( mouseX > 0 && mouseX < stage.stageWidth && mouseY > 0 && mouseY < stage.stageHeight )
			{
				camera.z += ( mouseX  - 200 ) * 0.1;
			}
			/**
			 * レンダリング
			 */
			RenderingScene();
		}
		
	}
}