/** * ... * @author ever5u */ public class fuxi extends Sprite { private var scene:Scene3D; private var camera:Camera3D; public function fuxi() { //創(chuàng)建一個攝像機 camera = new Camera3D(300, 300); camera.z = -300; //創(chuàng)建一個 Group var root:Group = createScene(); //創(chuàng)建場景 scene = new Scene3D( "scene", this, camera, root ); //創(chuàng)建實時偵聽 addEventListener( Event.ENTER_FRAME, enterFrameHandler ); } var box = new Box("box", 100, 100, 100); public function createScene() { var g:Group = new Group(); //設(shè)置立方體的貼圖 var bitmap:BitmapData = new MyPalm(0, 0); var material:Material = new BitmapMaterial( bitmap ); var app:Appearance = new Appearance( material );
box.appearance = app;
g.addChild( box ); return g; } public function enterFrameHandler(_evt:Event) { box.rotateX = mouseX; box.rotateY = mouseY; scene.render(); } }