Commit d656f5dc authored by Rurik Bugdanov's avatar Rurik Bugdanov

fix #3

parent 81dac4c0
......@@ -711,6 +711,7 @@ X3DOMObject.Marker.prototype._registerEvents = function(){
marker.on('mousedown',function(e){
var self = this;
var elem = $(this).parent().parent().parent();
var index = parseInt($(elem).attr("id").substr(PREFIX.length));
......@@ -727,6 +728,13 @@ X3DOMObject.Marker.prototype._registerEvents = function(){
Scene.element.addEventListener('mousemove',X3DOMObject.Marker.mouseMove,true);
Scene.element.addEventListener('mouseup',X3DOMObject.Marker.mouseUp,true);
// check for button released outside the window
$(window).on('mouseover.drag_marker',function(e) {
if (e && e.buttons===0 && Scene.markerToDrag) {
X3DOMObject.Marker.mouseUp.apply(self,[event]);
}
});
});
marker.on('mouseup',function(e){
......@@ -752,8 +760,10 @@ X3DOMObject.Marker.mouseUp = function(){
}
*/
Scene.markerToDrag=null;
Scene.element.removeEventListener('mouseup',X3DOMObject.Marker.mouseUp,true);
Scene.element.removeEventListener('mousemove',X3DOMObject.Marker.mouseMove,true);
$(window).off('.drag_marker');
Scene.draggedTransformNode = null;
Scene.draggingUpVec = null;
......@@ -768,6 +778,8 @@ X3DOMObject.Marker.mouseUp = function(){
// from https://x3dom.org/x3dom/example/MovingObjectsWithDOMEvents.html
X3DOMObject.Marker.dragStart = function(elem){
Scene.markerToDrag=elem;
// move up from <shape> to <transform>
var transformNode = $(elem).parent();
var tr0 = $(transformNode).attr("translation");
......@@ -825,7 +837,9 @@ X3DOMObject.Marker.mouseMove = function(event){
if (!SETTINGS.slidingdrag){
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);
Scene.markerToDrag.isPickable=true;
if (sr.pickObject != null){
if (!$(sr.pickObject).hasClass("shapemarker")){
var sphere = Scene.draggedTransformNode.parent().parent();
......
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