So I decided to play around with Away 3D and after a brief review it seems very cool. Looking through the Lessons that they provide I decided to take the lesson’s code out of the timeline and place them in a class file. Here is the first demo of the sphere.
Here is the document class – note that I originally was using a Mouse Event instead of the ENTER_FRAME event, but it would not work, so once I used the ENTER_FRAME event everything seemed fine. :
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 SphereDemo extends Sprite
{
private var sphere:Object3D;
private var view:View3D;
public function SphereDemo()
{
// 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 sphere
sphere = new Sphere({material:"red#cyan", radius:500, segmentsW:12, segmentsH:9, y:50, x:10, z:10});
// add the sphere to the scene
view.scene.addChild(sphere);
// point camera at the sphere
view.camera.position = new Number3D(1000, 1000, 1000);
view.camera.lookAt(sphere.position);
// create motion
addEventListener(Event.ENTER_FRAME, Timeline);
}
private function Timeline(e:Event):void
{
sphere.rotationY = mouseX / 2;
sphere.rotationX = mouseY / 2;
// re render
view.render();
}
}
}
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.