I write this code in flash professional,I use HoverController to control the camera,but I found this HoverController not working as I think.It seems that the change of titleangle will influence the locaton of camera.So the earth looks smaller than normal when I rotate it and watch from the north pole.
we can see detail from the below picture.
import away3d.containers.View3D;
import away3d.primitives.SphereGeometry;
import away3d.textures.BitmapTexture;
import away3d.materials.TextureMaterial;
import away3d.entities.Mesh;
import away3d.controllers.HoverController;
import away3d.cameras.Camera3D;
var _startX:Number;
var _startY:Number;
var _mouseX:Number;
var _mouseY:Number;
var view:View3D=new View3D();
var camera=new Camera3D();
view.camera.lens.far=5000;
view.camera=camera;
addChild(view);
var _camerController:HoverController =new HoverController(view.camera, null, 0, 0, 1200, -90, 90);
var loader:Loader=new Loader();
var bitmapData:quanjing=new quanjing();//this is texture picture
var sphere:SphereGeometry = new SphereGeometry(1000);
var bitmapTexture:BitmapTexture = new BitmapTexture(bitmapData);
var textureMaterial:TextureMaterial = new TextureMaterial(bitmapTexture);
var mesh:Mesh = new Mesh(sphere,textureMaterial);
view.scene.addChild(mesh);
stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownFunction);
stage.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel);
function mouseDownFunction(evt:MouseEvent):void
{
_startX = _camerController.panAngle;
_startY = _camerController.tiltAngle;
_mouseX = mouseX;
_mouseY = mouseY;
stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveFunction);
stage.addEventListener(MouseEvent.MOUSE_UP,mouseUpFunction);
}
function mouseMoveFunction(evt:MouseEvent):void
{
_camerController.panAngle = (mouseX - _mouseX) * .3 + _startX;
_camerController.tiltAngle = (mouseY - _mouseY) * .3 + _startY;
}
function mouseUpFunction(evt:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE,mouseMoveFunction);
stage.removeEventListener(MouseEvent.MOUSE_UP,mouseUpFunction);
stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownFunction);
trace(view.camera.x+","+view.camera.y+","+view.camera.z+","+_camerController.tiltAngle);
}
addEventListener(Event.ENTER_FRAME,enterFrameFunction);
function enterFrameFunction(evt:Event):void
{
view.render();
}
function onMouseWheel(event:MouseEvent) : void
{
_camerController.distance -= event.delta*5;
}