Commit 3d5b9027 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

fixed pointer and moving when browser zoom !=100%

parent 2477c561
......@@ -407,6 +407,10 @@ function x3d_events(){
var elem = Scene.element;
elem.addEventListener('mousemove',function(e){
//test
},true);
elem.addEventListener('keydown',function(e){
//console.log("scene keydown");
......@@ -425,7 +429,7 @@ function x3d_events(){
if (e.key=="Control"){
var x,y,z;
var dist = 1000;
var dist = 1111;
var mouse = x3dom_getXYPosOr(e.path[0].mouse_drag_x,e.path[0].mouse_drag_y,false);
......@@ -483,7 +487,14 @@ function x3d_events(){
// have to focus if want key events to work w/o extra click
Scene.focusOnCanvas();
var camera = x3dom_getCameraPosOr(e.clientX,e.clientY,false);
//1: old
//var camera = x3dom_getCameraPosOr(e.clientX,e.clientY,false);
//2: new
if (!e.target) e.target = Scene.element;
var mouse_position = Scene.element.runtime.mousePosition(e);
var camera = x3dom_getCameraPosOr(mouse_position[0],mouse_position[1],false);
Map.marker.setAltitude(camera.y);
Map.marker.setElevation(camera.e*Math.PI/180);
......@@ -500,8 +511,15 @@ function x3d_events(){
if ((Scene._ctrlKey)||(SETTINGS.pointer)){
// show shadow marker
var mouse = x3dom_getXYPosOr(e.clientX,e.clientY,false);
var dist = parseFloat(mouse.d_xz) || 1000;
//1: old
//var mouse = x3dom_getXYPosOr(e.clientX,e.clientY,false);
//2: new
//if (!e.target) e.target = Scene.element;
//var mouse_position = Scene.element.runtime.mousePosition(e);
var mouse = x3dom_getXYPosOr(mouse_position[0],mouse_position[1],false);
var dist = parseFloat(mouse.d_xz) || 1116;
Map.marker.placeSlidingMarker(mouse.a,dist);
......@@ -517,7 +535,6 @@ function x3d_events(){
x3dom_setUpRight();
}
// what is this?
//x3d_mouseMove();
......
......@@ -55,8 +55,11 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
var az,el,sk;
var id;
var dist_xyz = 1000;
var dist_xz = 1000;
var dist_xyz = 1112;
var dist_xz = 1113;
//console.log("That event:");
//console.log(Scene._stored_x3dom_event);
var shootRay = elem.runtime.shootRay(cnvx,cnvy);
......
......@@ -65,6 +65,7 @@ var X3DOMObject = function(element,data,options){
this._X3DOM_SCENE_INIT_DONE = false;
this._ctrlKey = false;
this._shiftKey = false;
this._stored_x3dom_event = null;
this.markInfoIndex = null;
......@@ -303,16 +304,24 @@ X3DOMObject.Shape.prototype._registerEvents = function(){
var y = e.originalEvent.worldY;
var z = e.originalEvent.worldZ;
// store x3dom event to use in normal events
self._stored_x3dom_event = e.originalEvent;
if (self._ctrlKey||SETTINGS.pointer){
// place pointer marker
$("#sliding_sphere").find('material').attr("diffuseColor",convert_color_l2x(SETTINGS.markercolor));
$("#sliding_sphere").find('Sphere').attr("radius",SETTINGS.markersize/2);
X3DOMObject.Marker.place(x,y,z,"sliding_sphere");
$("#sliding_sphere").find("switch").attr("whichChoice",0);
}else{
// place at 0,0,0 and hide
X3DOMObject.Marker.place(0,0,0,"sliding_sphere");
$("#sliding_sphere").find("switch").attr("whichChoice",-1);
}
/*
......@@ -844,7 +853,13 @@ X3DOMObject.Marker.mouseMove = function(event){
X3DOMObject.Marker.drag(event.offsetX - Scene.lastMouseX, event.offsetY - Scene.lastMouseY);
}else{
Scene.markerToDrag.isPickable=false;
var sr = Scene.element.runtime.shootRay(event.clientX,event.clientY);
//1: old
//var sr = Scene.element.runtime.shootRay(event.clientX,event.clientY);
//2: new
if (!event.target) event.target = Scene.element;
var mouse_position = Scene.element.runtime.mousePosition(event);
var sr = Scene.element.runtime.shootRay(mouse_position[0],mouse_position[1]);
Scene.markerToDrag.isPickable=true;
if (sr.pickObject != null){
if (!$(sr.pickObject).hasClass("shapemarker")){
......@@ -1152,13 +1167,19 @@ X3DOMObject.displayInfo = function(e){
var elem = Scene.element;
var mouse = x3dom_getXYPosOr(e.clientX,e.clientY,true);
// 1:old
//var mouse = x3dom_getXYPosOr(e.clientX,e.clientY,true);
// 2:new
if (!e.target) e.target = elem;
var mouse_position = elem.runtime.mousePosition(e);
var mouse = x3dom_getXYPosOr(mouse_position[0],mouse_position[1],true);
if (Data.markers[mouse.index]!=undefined){
X3DOMObject.displayMarkInfo(mouse.index);
}
var dist = 1000;
var dist = 1115;
$("#window-info").css({"font-size":"20px"});
......@@ -1222,7 +1243,12 @@ X3DOMObject.displayViewInfo = function(e){
e.clientY = $(window).height()/2;
}
var mouse = x3dom_getXYPosOr(e.clientX,e.clientY,true);
//1: old
//var mouse = x3dom_getXYPosOr(e.clientX,e.clientY,true);
//2: new
if (!e.target) e.target = Scene.element;
var mouse_position = Scene.element.runtime.mousePosition(e);
var mouse = x3dom_getXYPosOr(mouse_position[0],mouse_position[1],true);
mouse.s = "0";
/*
......
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