It seems to work well.
But i have another problems.
this is my code :
CODE
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.*;
import flash.display.BitmapData;
//skins
var maTexture:BitmapData = BitmapData.loadBitmap("map.jpg");
var maTexture2:BitmapData = BitmapData.loadBitmap("soleil.jpg");
var maSkin:TextureSkin = new TextureSkin(maTexture);
var skinSoleil:TextureSkin = new TextureSkin(maTexture2);
function init( Void ):Void
{
// screen creation, the object where objects will be displayed.
var screen:ClipScreen = new ClipScreen( this.createEmptyMovieClip('screen', 1), 600, 600 );
// we create our camera
var cam:Camera3D = new Camera3D( 700, screen);
// we move the camera backward to be able to see the object placed at 0,0,0
cam.setPosition(0, 30, -200);
// we add the camera to the world
World3D.getInstance().addCamera( cam );
// 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 that everything is created, we can launch the world rendering.
World3D.getInstance().render();
//Ecouteur de clavier
unEcouteur = new Object();
unEcouteur.onKeyDown = worldRotate;
Key.addListener(unEcouteur);
}
function createScene( bg:Group ):Void
{
// We create our object. It is a cube of 50 pixels
var maSphere:Sphere = new Sphere( 5, 5, "tri" );
var monSoleil:Sphere = new Sphere( 10, 5, "tri" );
maSphere.setSkin(maSkin);
monSoleil.setSkin(skinSoleil);
var tg1:TransformGroup = new TransformGroup ();
var tg2:TransformGroup = new TransformGroup ();
var translation:Transform3D = new Transform3D ();
var translation2:Transform3D = new Transform3D ();
translation.translate (0, 45, 0);
tg1.addChild (maSphere);
tg1.setTransform (translation);
translation2.translate (38, 15, -17);
tg2.setTransform (translation2);
tg2.addChild (monSoleil);
// Now we simply link the Object leaf to the root node, and finish the tree creation
bg.addChild( tg1);
bg.addChild( tg2);
bg.addChild( createGrille());
}
function createGrille():TransformGroup{
var grilleSkin:MixedSkin = new MixedSkin(0x00FF00,20,0x00FF00,100,1);
var toto:TransformGroup = new TransformGroup ();
var tata:Plane3D = new Plane3D(100,100,4,"quad");
tata.setSkin(grilleSkin);
toto.addChild(tata);
return toto;
}
// We lauch the animation creation.
init();
//Animation au clavier
var circlePos:Number=0;
var distance:Number = 200;
var pi:Number = Math.PI;
function worldRotate():Void {
if(Key.isDown(Key.LEFT)) {
var CamY:Number = World3D.getInstance().getCurrentCamera().getPosition().y;
// On tourne vers la gauche
circlePos -=10;
World3D.getInstance().getCurrentCamera().setPosition(Math.cos(circlePos*pi/360)*distance,CamY,Math.sin(circlePos*pi/360)*distance);
World3D.getInstance().getCurrentCamera().lookAt(0,0,0);
World3D.getInstance().render();
}
if(Key.isDown(Key.RIGHT)) {
var CamY:Number = World3D.getInstance().getCurrentCamera().getPosition().y;
// On tourne vers la droite
trace(circlePos);
circlePos +=10;
World3D.getInstance().getCurrentCamera().setPosition(Math.cos(circlePos*pi/360)*distance,CamY,Math.sin(circlePos*pi/360)*distance);
World3D.getInstance().getCurrentCamera().lookAt(0,0,0);
World3D.getInstance().render();
}
}
I dont know why it's so slowly. In fact its more and more slowly after each seconds.
Any idea ?
Je sais pas pourquoi c'est aussi lent et surtout pourquoi c'est de plus en plus lent.