PointLight3Dのメモ

勉強中〜

var light:PointLight3D = new PointLight3D(true);
light.x = 300;
light.y = 300;
light.z = 0;
scene.addChild(light);

new PointLight3D(true)ってするとライトのオブジェクトを表示してくれる。ふむふむ。

package 
{
	import flash.events.*;

	import org.papervision3d.view.*;
	import org.papervision3d.materials.shadematerials.*;
	import org.papervision3d.objects.primitives.*;
	import org.papervision3d.lights.*; 

	[SWF(width="480", height="480", frameRate="30",backgroundColor="0x000000")]
	public class Main extends BasicView 
	{
		private var obj:Sphere;
		private var light:PointLight3D;
		private var rot:Number = 0;
		
		public function Main():void 
		{
			var world:BasicView = new BasicView();
			addChild(world);
			world.startRendering();

			light = new PointLight3D(true);
			world.scene.addChild(light);
			
			var material:FlatShadeMaterial = new FlatShadeMaterial(light, 0xFFFF00);
			//material.doubleSided = true;

			obj = new Sphere(material, 100, 15, 15);
			world.scene.addChild(obj);

			addEventListener(Event.ENTER_FRAME, loop);
		}
		
		private function loop(e:Event):void
		{
			rot += 0.5;
			
			light.x = 500 * Math.sin(rot * Math.PI / 180);
			light.z = 500 * Math.cos(rot * Math.PI / 180);
			
		}
	}
}