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

flash on 2009-12-26

Get Adobe Flash player
by tokufxug 26 Dec 2009
    Embed
package
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFieldType;
    
    import org.papervision3d.objects.DisplayObject3D;
    import org.papervision3d.objects.primitives.PaperPlane;
    import org.papervision3d.objects.primitives.Plane;
    import org.papervision3d.view.BasicView;
    import org.papervision3d.materials.shadematerials.*
	import org.papervision3d.materials.*;
	
    import org.papervision3d.lights.PointLight3D;
    import org.papervision3d.objects.primitives.Sphere;
	
	[SWF(backgroundColor='0x000000')]
    public class MathAndPhysics extends BasicView
    {
        private var wrap:DisplayObject3D;
		
		//private var zoom:Number;
        //private var timer:Timer;
        
        public function MathAndPhysics()
        {
			
			wrap = new DisplayObject3D();
			
			// 親をシーンに追加
			scene.addChild(wrap);
			
			// マテリアルを作成
			//var material:WireframeMaterial = new WireframeMaterial(0x3399FF);
			//material.doubleSided = true;
			const light:PointLight3D = new PointLight3D(true, false);
			
			const max:int = 4;
			var mArray = 
				[new FlatShadeMaterial(light, 0xFFFFFF, 0x000000, 0),
				 new GouraudMaterial(light, 0xFFFFFF, 0x000000, 0),
				 new PhongMaterial(light, 0xFFFFFF, 0x000000, 0),
				 new WireframeMaterial(0xFFFFFF)
																];
			
			for (var i:int = 0; i < max; i++) {
				// 平面を2つ作成
				//var obj:Plane = new Plane(material, 300, 300);
				var obj:Sphere = new Sphere(mArray[i % max], 30 << 2, 10, 10);
				
				// 配置すべき角度を計算
				var rot:Number = 360 * (i / max);
				
				// 平面を円周上に配置
				obj.x = 300 * Math.sin(rot * Math.PI / 180);
				obj.z = 300 * Math.cos(rot * Math.PI / 180);
				obj.lookAt(DisplayObject3D.ZERO); // 原点方向を向かせる
				wrap.addChild(obj);
			}
			//this.cacheAsSurface = true;
			this.startRendering();
			addEventListener(Event.ENTER_FRAME, onLoop);
			
//			var tf:TextField = new TextField();
//			tf.cacheAsSurface = true;
//            tf.type = TextFieldType.INPUT;
//            tf.autoSize = TextFieldAutoSize.LEFT;
//            tf.backgroundColor = 0xff0000;
//            tf.x = 100;
//            tf.y = 200;
//            var sp:Sprite = new Sprite();
//            sp.addChild(tf)
//            addChild(sp);
        }
		
		private function onLoop(event:Event):void {
			wrap.rotationY += 1;
			wrap.rotationZ += 1;
			wrap.rotationX += 1;
		}
     }
}