This is the simplest code to add a geometry into a scene and render it.
This is the modifed version of Basic_view tutorial from away gold src lesson.
package
{
import flash.display.Sprite;
import flash.events.Event;
import away3d.containers.*;
import away3d.primitives.*;
import away3d.entities.*;
import away3d.materials.*;
public class SimpleGeometry extends Sprite
{
private var _view:View3D;
private var _sphere:SphereGeometry;
private var _mesh:Mesh;
public function SimpleGeometry()
{
_view = new View3D();
_mesh = new Mesh(new SphereGeometry(100), new ColorMaterial(0x6666FF,1))
_view.scene.addChild(_mesh);
addChild(_view);
addEventListener(Event.ENTER_FRAME, _onEnterFrame);
}
private function _onEnterFrame(e:Event):void
{
_view.render();
}
}
}
—————————————————-
When I add mesh into the scene and render it, it works. But when I add geometry directly to the scene and render it , it throws error. Do I need mesh always to render a scene, cant I add geometry directly?
_view.scene.addChild(_mesh); // works
_view.scene.addChild(_sphere);// does not work