Basic Tutorial


package
{
	import com.yogurt3d.Yogurt3D;
	import com.yogurt3d.core.cameras.Camera;
	import com.yogurt3d.core.events.Yogurt3DEvent;
	import com.yogurt3d.core.materials.MaterialFill;
	import com.yogurt3d.core.sceneobjects.SceneObjectContainer;
	import com.yogurt3d.presets.primitives.sceneobjects.BoxSceneObject;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Vector3D;
	
	import mx.containers.Box;

	[SWF(width="400", height="300", frameRate="60", wmode="direct")]
	public class Tutorial1 extends Sprite
	{
		public var container:SceneObjectContainer;
		
		public function Tutorial1()
		{
			// We initialize Out Engine
			Yogurt3D.instance.addEventListener( Yogurt3DEvent.READY , onEngineReady );
			Yogurt3D.instance.init( this.stage );
		}
		public function onEngineReady( _e:Event ):void{
			// We create our default scene
			Yogurt3D.instance.defaultSetup( 400, 300 );	
			
			// Set the background color to Red
			Yogurt3D.instance.defaultScene.sceneColor = 0xFF0000;
			
			// Create green box
			var box1:BoxSceneObject = new BoxSceneObject();
			box1.material = new MaterialFill(0x00FF00);
			box1.transformation.x = -10;
			
			// Create blue box
			var box2:BoxSceneObject = new BoxSceneObject();
			box2.material = new MaterialFill(0x0000FF);
			box2.transformation.x = 10;
			
			// Create container and put boxes inside it
			container = new SceneObjectContainer();
			container.addChild( box1 );
			container.addChild( box2 );
			
			// add container to scene
			Yogurt3D.instance.defaultScene.addChild( container );
			
			// Get the default camera
			var camera:Camera = Yogurt3D.instance.defaultCamera as Camera;
			
			// position and rotate the camera
			camera.transformation.z = 100;
			camera.transformation.y = 10;
			camera.transformation.lookAt( new Vector3D(0, 0, 0 ) );
			
			// start rendering
			Yogurt3D.instance.startAutoUpdate();
			
			// on enter frame rotate the container
			Yogurt3D.instance.enginePreUpdateCallback = function():void{
				container.transformation.rotationY++;
			};
		}
		
	}
}

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


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.