1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| import com.bourre.commands.Delegate;
import com.bourre.data.libs.GraphicLib;
import com.bourre.data.libs.GraphicLibLocator;
import com.bourre.data.libs.LibEvent;
import com.bourre.data.libs.LibStack;
import com.bourre.log.Logger;
import com.bourre.utils.LuminicTracer;
import flash.display.BitmapData;
import sandy.core.scenegraph.Camera3D;
import sandy.core.scenegraph.Group;
import sandy.core.World3D;
import sandy.materials.Appearance;
import sandy.materials.BitmapMaterial;
import sandy.primitive.Box;
import sandy.util.BitmapUtil;
var myContainer:MovieClip = _root.createEmptyMovieClip("sandyScene", 0 );
World3D.getInstance().container = myContainer;
// Initialize the world
function init( Void ):Void
{
World3D.getInstance().root = _createScene();
// we create the camera. It is very important to pass correct values as viewport dimension. Usually your swf dimension for a simple demo.
var myCamera:Camera3D = new Camera3D( 500, 500 );
World3D.getInstance().camera = oCam;
World3D.getInstance().root.addChild( myCamera );
// we need to call ourself now the render method.
// Here we use the enterframe event, using a Delegate command.
myContainer.onEnterFrame = Delegate.create( this, onRender );
}
// Create the object tree
function createScene( Void ):Group
{
var g:Group = new Group("root");
// we create the box
var myBox:Box = new Box( "myBox", 100, 100, 100 );
// we set its position, lot simpler isn't it?
myBox.x = 10;
myBox.y = -20;
myBox.z = 300;
// we apply the bitmap appearance
myBox.appearance = new Appearance( new ColorMaterial( 0xFF0000, 0 ) );
// link the object to the group to make it displayable.
g.addChild( myBox );
return g;
}
// we render the world
function _onRender( Void ):Void
{
World3D.getInstance().render();
} |
Partager