30May
Away 3D - Constructing A Torus
No comments
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import away3d.containers.*;
import away3d.core.base.*;
import away3d.primitives.*;
import away3d.core.math.*;
public class TorusDemo extends Sprite
{
private var torus:Object3D;
private var view:View3D;
public function TorusDemo()
{
// create a 3D-viewport
// our movie is 700 x 700
view = new View3D({x:350, y:350});
// add viewport to the stage
addChild(view);
// create a plane
torus = new Torus({material:"yellow#", name:"torus", x:-250, y:160, z:-250, radius:350, tube:80, segmentsR:8, segmentsT:6});
// add the plane to the scene
view.scene.addChild(torus);
// point camera at the plane
view.camera.position = new Number3D(1000, 1000, 1000);
view.camera.lookAt(torus.position);
// create motion
addEventListener(Event.ENTER_FRAME, Timeline);
}
private function Timeline(e:Event):void
{
torus.rotationY = mouseX / 2;
torus.rotationX = mouseY / 2;
// re render
view.render();
}
}
}
Categories: Actionscript 3, Away 3D
Friday, May 30th, 2008 at 8:27 am and is filed under Actionscript 3, Away 3D. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.