Point Light Tutorial

To view this page ensure that Adobe Flash Player version 11.0.0 or greater is installed.


package
{
	import com.yogurt3d.Yogurt3D;
	import com.yogurt3d.core.events.Yogurt3DEvent;
	import com.yogurt3d.core.lights.Light;
	import com.yogurt3d.core.managers.tickmanager.TickManager;
	import com.yogurt3d.core.managers.tickmanager.TimeInfo;
	import com.yogurt3d.core.materials.MaterialSpecularFill;
	import com.yogurt3d.core.objects.interfaces.ITickedObject;
	import com.yogurt3d.core.sceneobjects.SkyBox;
	import com.yogurt3d.core.texture.CubeTextureMap;
	import com.yogurt3d.presets.primitives.sceneobjects.PlaneSceneObject;
	
	import flash.display.Sprite;
	import flash.geom.Vector3D;
	
	[SWF(width="400", height="300")]
	public class PointLightTutorial extends Sprite implements ITickedObject
	{
		var light:Light;
		
		public function PointLightTutorial()
		{
			super();
			Yogurt3D.instance.addEventListener( Yogurt3DEvent.READY, onContextReady );
			Yogurt3D.instance.init( this.stage );
		}
		public function onContextReady( _e:Yogurt3DEvent ):void{
			Yogurt3D.instance.defaultSetup( 400,300 );
			Yogurt3D.instance.defaultScene.sceneColor = 0xEFEFEF;
			
			light = new Light();
			light.transformation.y = 5;
			Yogurt3D.instance.defaultScene.addChild( light );
			
			var plane:PlaneSceneObject = new PlaneSceneObject( 350, 350 );
			plane.material = new MaterialSpecularFill( 0xEFEFEF );
			Yogurt3D.instance.defaultScene.addChild( plane );
			
			Yogurt3D.instance.defaultCamera.setProjectionPerspective( 55, 400/300, 1, 1000 );
			Yogurt3D.instance.defaultCamera.transformation.position = new Vector3D(0,250,350);
			Yogurt3D.instance.defaultCamera.transformation.lookAt( new Vector3D );
			
			Yogurt3D.instance.startAutoUpdate();
			
			TickManager.registerObject( this );
		}
		public function updateWithTimeInfo(_timeInfo:TimeInfo):void{
			light.attenuation = Vector.([.1, (_timeInfo.objectTime %1000) / 1000 / 8, 0, 1]);
			light.transformation.position = new Vector3D(
				Math.sin( _timeInfo.objectTime / 1000 ) * 100,
				5,
				Math.cos( _timeInfo.objectTime / 1000 ) * 100 
				);
		}
	}
}


New Version with Stage3D

Yogurt3D v2.1

About Yogurt3D

Yogurt3D Game Engine is a state of the art Actionscript 3.0 library for developing 3D applications on Adobe Flash Platform. We claim it is possible to create in-browser 3D games without any plug-in installation. Its animation system, model formats, exporter plug-ins for modelling tools, scene hierarchy and scene management structure, and that it is developed with a game developer perspective, makes Yogurt3D a powerful tool for 3D game developers.

If you wish to target both casual and seasoned players with browser-based real-time 3D games on the web, Yogurt 3D Game Engine is the ultimate tool to choose.

About Yogurt Technologies

Yoğurt Technologies was founded in 1997 by a group of artists and computer engineers.

For 10 years the group worked as a new media agency producing technology for other companies.

In 2007, the decision to focus on its own products was taken as Yoğurt members foresaw that 3D would be the next big thing on the web. Thus, the company now produces 3D tools that will be available to anyone who wants to try a hand on 3D content.

Yogurt3D on Social Networks

Follow Us on Facebook, Twitter and FriendFeed.