Commit e2db714e authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

1. fixed errors when dragging over map by small distances

parent 65c3858d
...@@ -798,6 +798,8 @@ function leaf_mousemove_nohc(e){ ...@@ -798,6 +798,8 @@ function leaf_mousemove_nohc(e){
var p0 = new L.LatLng(Data.camera.latitude,Data.camera.longitude); var p0 = new L.LatLng(Data.camera.latitude,Data.camera.longitude);
var p1 = new L.LatLng(Camera._latlng.lat,Camera._latlng.lng); var p1 = new L.LatLng(Camera._latlng.lat,Camera._latlng.lng);
var p_origin = new L.LatLng(Data.camera.kml.latitude,Data.camera.kml.longitude);
var dh = Camera._heading - Math.PI/180*Data.camera.heading; var dh = Camera._heading - Math.PI/180*Data.camera.heading;
Data.camera.heading = Camera._heading*180/Math.PI; Data.camera.heading = Camera._heading*180/Math.PI;
...@@ -805,7 +807,9 @@ function leaf_mousemove_nohc(e){ ...@@ -805,7 +807,9 @@ function leaf_mousemove_nohc(e){
Data.camera.longitude = Camera._latlng.lng; Data.camera.longitude = Camera._latlng.lng;
if ((p0.lat!=p1.lat)||(p0.lng!=p1.lng)){ if ((p0.lat!=p1.lat)||(p0.lng!=p1.lng)){
leaf_translation_v1(p0,p1); // hypothesis: dragging by small distances introduces cumulative errors
//leaf_translation_v1(p0,p1);
leaf_translation_v1(p_origin,p1);
}else{ }else{
x3dom_rotation(dh); x3dom_rotation(dh);
} }
...@@ -856,6 +860,7 @@ function leaf_update_x3dom_marker(p1_ll,p2_ll,index){ ...@@ -856,6 +860,7 @@ function leaf_update_x3dom_marker(p1_ll,p2_ll,index){
var dp_w = x3dom_delta_map2scene(p1_ll,p2_ll); var dp_w = x3dom_delta_map2scene(p1_ll,p2_ll);
mark.x = dp_w.x; mark.x = dp_w.x;
mark.y = dp_w.y;
mark.z = dp_w.z; mark.z = dp_w.z;
if(!hecs){ if(!hecs){
...@@ -870,13 +875,15 @@ function leaf_translation_v1(p0,p1){ ...@@ -870,13 +875,15 @@ function leaf_translation_v1(p0,p1){
var dp_w = x3dom_delta_map2scene(p0,p1); var dp_w = x3dom_delta_map2scene(p0,p1);
x3dom_translation(dp_w.x,dp_w.y,dp_w.z); x3dom_translation_v2(dp_w.x,dp_w.y,dp_w.z);
// if not updated then moving in 3D scene will make it jump // if not updated then moving in 3D scene will make it jump
Scene.old_view_translation = x3dom_getViewTranslation(Scene.element); Scene.old_view_translation = x3dom_getViewTranslation(Scene.element);
} }
function x3d_mouseMove(){ function x3d_mouseMove(){
x3dom_update_map(); x3dom_update_map();
......
...@@ -299,6 +299,7 @@ function x3dom_rotation(dangle){ ...@@ -299,6 +299,7 @@ function x3dom_rotation(dangle){
/* /*
* translate camera in x3dom space * translate camera in x3dom space
* not in use
*/ */
function x3dom_translation(dx,dy,dz){ function x3dom_translation(dx,dy,dz){
...@@ -319,6 +320,28 @@ function x3dom_translation(dx,dy,dz){ ...@@ -319,6 +320,28 @@ function x3dom_translation(dx,dy,dz){
} }
/*
* set camera translation in x3dom space to x,y,z
*/
function x3dom_translation_v2(x,y,z){
var delta = new x3dom.fields.SFVec3f(x,y,z);
var mat = Scene.element.runtime.viewMatrix().inverse();
var from = mat.e3();
var at = from.subtract(mat.e2());
var up = mat.e1();
var newfrom = delta;
var newat = newfrom.subtract(mat.e2());
var newmat = x3dom.fields.SFMatrix4f.lookAt(newfrom, newat, up);
x3dom_setViewpoint(newmat);
}
function x3dom_altelev(alt,elev){ function x3dom_altelev(alt,elev){
//x3dom_matrix_test(); //x3dom_matrix_test();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment