A problem about HoverController

Software: Away3D 4.x

zyb, Newbie
Posted: 27 November 2014 10:56 AM   Total Posts: 3

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.cameranull001200, -9090);
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_WHEELonMouseWheel);
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;

 

   

Avatar
Fabrice Closier, Administrator
Posted: 27 November 2014 11:48 AM   Total Posts: 1265   [ # 1 ]

try _cameraController.yFactor = 1; after you declare it.

   

zyb, Newbie
Posted: 27 November 2014 02:10 PM   Total Posts: 3   [ # 2 ]
Fabrice Closier - 27 November 2014 11:48 AM

try _cameraController.yFactor = 1; after you declare it.

oh! thanks,help me much.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X