homeへのリンクです。

Sandy 2

2007年07月08日

ここに次のステップのチュートリアルがある。
前回のサンプルコードに追加する形で、カメラの位置を調整し、ボックスを1つ追加するというもの。
例のごとくまた、クラスファイルがロードできないとのアラートが出るが、前回の記事のように対応して回避する。
screenはいらないようなので、サンプルコードからはずした。
コードは以下のようになる。

import sandy.core.data.*;
import sandy.core.group.*;
import sandy.primitive.*;
import sandy.view.*;
import sandy.core.*;
import sandy.skin.*;
import sandy.util.*;
import sandy.core.transform.*;
import sandy.events.*;
 
function init( Void ):Void
{
   // we create our camera
   var cam:Camera3D = new Camera3D( 600, 600 );
   // we add the camera to the world
   World3D.getInstance().addCamera( cam );
   // we move the camera backward to be able to see the object placed at 0,0,0
	cam.setPosition(0, 0, -500);
   // we create the root node.
   var bg:Group = new Group();
   // and set it as the root node of the world.
   World3D.getInstance().setRootGroup( bg );
   // and we lauch the scene creation
   createScene( bg );
   // and now everything is created, we can launch the world rendering.
   World3D.getInstance().render();
}
 
function createScene( bg:Group ):Void
{
   // We create our object. It is a cube of 50 pixels
	var o:Object3D = new Box( 50, 50, 50 );
	// Now we simply link the Object leaf to the root node, and finish the tree creation
	bg.addChild( o);
}
 
// We lauch the animation creation.
init();

出来上がりのswfはボックスを真横からみたワイヤーフレームが出てくるだけでつまらないものなのでアップしない。
サイトのページの方には載っている。