-
away3d mouseX and mouseY translated to pan/tilt
It is my first post here, though I visited this forum several times
Now I need help, the solution is somewhere in a sphere maths, but I can't find
ok, I render s sphere, the camera is at 0,0,0 so the sphere is around the camera and the camera is inside, in the center of the sphere,
what I need is to drag the sphere or other words have the mouse x and y coordinates translated into degrees of pan and tilt movement
here is what I have:
var hfov = Math.atan2(view.mouseX*2, camera.zoom*camera.zoom + (-view.mouseX*view.mouseX)/(camera.zoom*camera.zoom))*(180/Math.PI);
var vfov = Math.atan2(view.mouseY*2, camera.zoom*camera.zoom + (-view.mouseY*view.mouseY)/(camera.zoom*camera.zoom) )*(180/Math.PI);
view is the main container for the sphere
hfov returns horizontal fov
vfov returns vertical fov
var hAngle = hfov/2;
var vAngle = vfov/2;
hAngle and vAngle are the pan and tilt I am looking for and they work perfect but...
hAngle - works perfect without any but
vAngle - works perfect only if the mouseX = 0, if the mouseX != 0, if we move the mouse from the left to the right the vAngle is too large for the sides, objects dragged with hAngle and vAngle seem to be moved like on a circle where the top of the circle is at mouseX = 0, the objects looks as if we needed vAngle/2 but if I do so mouseX=0 doesn't return the right tilt angle
anyway vfov needs some sort of correction, I tried:
var vfov22 = vfov2*Math.cos(hfov2*Math.PI/180);
it helped a bit but the solution isn't good
could anyone help?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|