Commit 1fdcdb59 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

picking multiple model by shooting ray and blinking

parent 93472912
......@@ -586,7 +586,6 @@ function manualposor_rotate_glued(){
var AA = q.toAxisAngle();
var new_rot = AA[0].toString()+" "+AA[1];
var tra1 = MPR_PO.translation.split(",");
tra1 = new x3dom.fields.SFVec3f(tra1[0],tra1[1],tra1[2]);
......@@ -595,12 +594,12 @@ function manualposor_rotate_glued(){
var tra2 = rv2.add(dR.multMatrixVec(tra1.subtract(rv1)));
console.log("check 2: "+tra2.toString());
//console.log("check 2: "+tra2.toString());
//var new_tra = dR.multMatrixVec(tra);
new_tra = [tra2.x,tra2.y,tra2.z].join(",");
console.log(new_tra);
//console.log(new_tra);
tmptransform.attr("rotation",new_rot);
//tmptransform.attr("translation",new_tra);
......@@ -688,9 +687,62 @@ function manualposor_unblink(){
}
function manualposor_init_shootrays(x,y){
MPR.counter = 1;
MPR.x = x;
MPR.y = y;
}
function manualposor_shootrays(){
var r1 = $(".mpr_r1[name=r1]:checked");
var r2 = $(".mpr_r2[name=r2]:checked");
if (MPR.counter==1){
if (r2.length!=0){
$("inline[name=x3d_"+r2.val()+"]").parent().parent().parent().attr("whichChoice",-1);
}
//Scene.element.runtime.enterFrame();
}else if (MPR.counter==2){
var ray1 = Scene.element.runtime.shootRay(MPR.x,MPR.y);
console.log(ray1);
if (r1.length!=0){
$("inline[name=x3d_"+r1.val()+"]").parent().parent().parent().attr("whichChoice",-1);
}
}else if(MPR.counter==3){
var ray2 = Scene.element.runtime.shootRay(MPR.x,MPR.y);
console.log(ray2);
MPR.counter = 0;
}
if (MPR.counter!=0){
console.log("Counter: "+MPR.counter);
MPR.counter++;
setTimeout(function(){
var r1 = $(".mpr_r1[name=r1]:checked");
if (r1.length!=0){
$("inline[name=x3d_"+r1.val()+"]").parent().parent().parent().attr("whichChoice",0);
}
if (r2.length!=0){
$("inline[name=x3d_"+r2.val()+"]").parent().parent().parent().attr("whichChoice",0);
}
},10);
}
}
......
......@@ -91,6 +91,13 @@ var AUTOCOLORS_COUNTER = 0;
var MARKER_PREFIX = "my-sph-";
// Manual Position & Orientation mode
var MPR = {
counter: 0,
x: null,
y: null
};
// no comments
function parseURL(){
var parameters=location.href.replace(/\?/ig,"&").split("&");
......@@ -427,10 +434,16 @@ function deep_init(){
//x3dom_testbox();
x3dom_setUpRight();
if (SETTINGS.manualposor){
manualposor_shootrays();
manualposor_rotate_glued();
}
// shoot ray here
}
if (!Scene._X3DOM_SCENE_INIT_DONE&&(cnt==0)){
......@@ -447,6 +460,11 @@ function deep_init(){
}
// loading extra models?
if (Scene._X3DOM_SCENE_INIT_DONE&&(cnt!=0)){
Scene._X3DOM_SCENE_INIT_DONE = false;
}
};
}
......@@ -571,24 +589,33 @@ function x3d_events(){
Scene._ctrlKey = true;
var x,y,z;
var dist = 1111;
if(!SETTINGS.manualposor){
var mouse = x3dom_getXYPosOr(e.path[0].mouse_drag_x,e.path[0].mouse_drag_y,false);
var x,y,z;
var dist = 1111;
if (mouse.d_xz != null){
var mouse = x3dom_getXYPosOr(e.path[0].mouse_drag_x,e.path[0].mouse_drag_y,false);
dist = parseFloat(mouse.d_xz);
if (mouse.d_xz != null){
X3DOMObject.Marker.place(mouse.x,mouse.y,mouse.z,"sliding_sphere");
dist = parseFloat(mouse.d_xz);
if (Scene.highlighted_marker_index==null) {
$("#sliding_sphere").find("switch").attr("whichChoice",0);
}
X3DOMObject.Marker.place(mouse.x,mouse.y,mouse.z,"sliding_sphere");
if (Scene.highlighted_marker_index==null) {
$("#sliding_sphere").find("switch").attr("whichChoice",0);
}
}
Map.marker.placeSlidingMarker(mouse.a,dist);
}else{
// place align marker here
}
Map.marker.placeSlidingMarker(mouse.a,dist);
/*
// Debugging
......@@ -642,10 +669,17 @@ function x3d_events(){
Scene._ctrlKey = false;
//remove on keydown?
X3DOMObject.Marker.place(0,0,0,"sliding_sphere");
$("#sliding_sphere").find("switch").attr("whichChoice",-1);
if(!SETTINGS.manualposor){
Map.marker.removeSlidingMarker();
X3DOMObject.Marker.place(0,0,0,"sliding_sphere");
$("#sliding_sphere").find("switch").attr("whichChoice",-1);
Map.marker.removeSlidingMarker();
}else{
// place align marker disable here
}
}
......
......@@ -272,6 +272,8 @@ X3DOMObject.prototype.ShapeEvents = function(){
inlines.each(function(){
console.log("binding inline: "+$(this).attr("name"));
if ($(this).attr("name")!="back"){
var shapes = $(this).find("Shape");
......@@ -295,42 +297,60 @@ X3DOMObject.prototype.ShapeEvents = function(){
X3DOMObject.Shape = function(element){
this._elem = element
this._clearEvents();
this._registerEvents();
}
X3DOMObject.Shape.prototype._clearEvents = function(){
$(this._elem).off("mousemove");
$(this._elem).off("click");
$(this._elem).off("mouseover");
$(this._elem).off("mouseout");
}
X3DOMObject.Shape.prototype._registerEvents = function(){
var self = Scene;
$(this._elem).on("mousemove",function(e){
var x = e.originalEvent.worldX;
var y = e.originalEvent.worldY;
var z = e.originalEvent.worldZ;
if(!SETTINGS.manualposor){
var x = e.originalEvent.worldX;
var y = e.originalEvent.worldY;
var z = e.originalEvent.worldZ;
var xyz = zNear_bug_correction([x,y,z]);
x = xyz[0];
y = xyz[1];
z = xyz[2];
// (not used atm) store x3dom event to use in normal events
self._stored_x3dom_event = e.originalEvent;
var xyz = zNear_bug_correction([x,y,z]);
if (self._ctrlKey||SETTINGS.pointer){
x = xyz[0];
y = xyz[1];
z = xyz[2];
// place pointer marker
X3DOMObject.PointerMarker.updatePars();
// (not used atm) store x3dom event to use in normal events
self._stored_x3dom_event = e.originalEvent;
X3DOMObject.Marker.place(x,y,z,"sliding_sphere");
$("#sliding_sphere").find("switch").attr("whichChoice",0);
if (self._ctrlKey||SETTINGS.pointer){
}else{
// place pointer marker
X3DOMObject.PointerMarker.updatePars();
// place at 0,0,0 and hide
X3DOMObject.Marker.place(0,0,0,"sliding_sphere");
$("#sliding_sphere").find("switch").attr("whichChoice",-1);
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);
// for align marker? do nothing
}
......@@ -366,17 +386,29 @@ X3DOMObject.Shape.prototype._registerEvents = function(){
if (self._ctrlKey){
var x = e.originalEvent.worldX;
var y = e.originalEvent.worldY;
var z = e.originalEvent.worldZ;
if(!SETTINGS.manualposor){
var xyz = zNear_bug_correction([x,y,z]);
var x = e.originalEvent.worldX;
var y = e.originalEvent.worldY;
var z = e.originalEvent.worldZ;
x = xyz[0];
y = xyz[1];
z = xyz[2];
var xyz = zNear_bug_correction([x,y,z]);
x = xyz[0];
y = xyz[1];
z = xyz[2];
X3DOMObject.createNewMarker(x,y,z);
}else{
// align marker
var lx = e.originalEvent.layerX;
var ly = e.originalEvent.layerY;
manualposor_init_shootrays(lx,ly);
X3DOMObject.createNewMarker(x,y,z);
}
}
......
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