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(){ ...@@ -586,7 +586,6 @@ function manualposor_rotate_glued(){
var AA = q.toAxisAngle(); var AA = q.toAxisAngle();
var new_rot = AA[0].toString()+" "+AA[1]; var new_rot = AA[0].toString()+" "+AA[1];
var tra1 = MPR_PO.translation.split(","); var tra1 = MPR_PO.translation.split(",");
tra1 = new x3dom.fields.SFVec3f(tra1[0],tra1[1],tra1[2]); tra1 = new x3dom.fields.SFVec3f(tra1[0],tra1[1],tra1[2]);
...@@ -595,12 +594,12 @@ function manualposor_rotate_glued(){ ...@@ -595,12 +594,12 @@ function manualposor_rotate_glued(){
var tra2 = rv2.add(dR.multMatrixVec(tra1.subtract(rv1))); 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); //var new_tra = dR.multMatrixVec(tra);
new_tra = [tra2.x,tra2.y,tra2.z].join(","); new_tra = [tra2.x,tra2.y,tra2.z].join(",");
console.log(new_tra); //console.log(new_tra);
tmptransform.attr("rotation",new_rot); tmptransform.attr("rotation",new_rot);
//tmptransform.attr("translation",new_tra); //tmptransform.attr("translation",new_tra);
...@@ -688,9 +687,62 @@ function manualposor_unblink(){ ...@@ -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; ...@@ -91,6 +91,13 @@ var AUTOCOLORS_COUNTER = 0;
var MARKER_PREFIX = "my-sph-"; var MARKER_PREFIX = "my-sph-";
// Manual Position & Orientation mode
var MPR = {
counter: 0,
x: null,
y: null
};
// no comments // no comments
function parseURL(){ function parseURL(){
var parameters=location.href.replace(/\?/ig,"&").split("&"); var parameters=location.href.replace(/\?/ig,"&").split("&");
...@@ -427,10 +434,16 @@ function deep_init(){ ...@@ -427,10 +434,16 @@ function deep_init(){
//x3dom_testbox(); //x3dom_testbox();
x3dom_setUpRight(); x3dom_setUpRight();
if (SETTINGS.manualposor){ if (SETTINGS.manualposor){
manualposor_shootrays();
manualposor_rotate_glued(); manualposor_rotate_glued();
} }
// shoot ray here
} }
if (!Scene._X3DOM_SCENE_INIT_DONE&&(cnt==0)){ if (!Scene._X3DOM_SCENE_INIT_DONE&&(cnt==0)){
...@@ -447,6 +460,11 @@ function deep_init(){ ...@@ -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,6 +589,8 @@ function x3d_events(){ ...@@ -571,6 +589,8 @@ function x3d_events(){
Scene._ctrlKey = true; Scene._ctrlKey = true;
if(!SETTINGS.manualposor){
var x,y,z; var x,y,z;
var dist = 1111; var dist = 1111;
...@@ -590,6 +610,13 @@ function x3d_events(){ ...@@ -590,6 +610,13 @@ function x3d_events(){
Map.marker.placeSlidingMarker(mouse.a,dist); Map.marker.placeSlidingMarker(mouse.a,dist);
}else{
// place align marker here
}
/* /*
// Debugging // Debugging
console.log("Canvas event:"); console.log("Canvas event:");
...@@ -642,11 +669,18 @@ function x3d_events(){ ...@@ -642,11 +669,18 @@ function x3d_events(){
Scene._ctrlKey = false; Scene._ctrlKey = false;
//remove on keydown? //remove on keydown?
if(!SETTINGS.manualposor){
X3DOMObject.Marker.place(0,0,0,"sliding_sphere"); X3DOMObject.Marker.place(0,0,0,"sliding_sphere");
$("#sliding_sphere").find("switch").attr("whichChoice",-1); $("#sliding_sphere").find("switch").attr("whichChoice",-1);
Map.marker.removeSlidingMarker(); Map.marker.removeSlidingMarker();
}else{
// place align marker disable here
}
} }
},true); },true);
......
...@@ -272,6 +272,8 @@ X3DOMObject.prototype.ShapeEvents = function(){ ...@@ -272,6 +272,8 @@ X3DOMObject.prototype.ShapeEvents = function(){
inlines.each(function(){ inlines.each(function(){
console.log("binding inline: "+$(this).attr("name"));
if ($(this).attr("name")!="back"){ if ($(this).attr("name")!="back"){
var shapes = $(this).find("Shape"); var shapes = $(this).find("Shape");
...@@ -295,16 +297,28 @@ X3DOMObject.prototype.ShapeEvents = function(){ ...@@ -295,16 +297,28 @@ X3DOMObject.prototype.ShapeEvents = function(){
X3DOMObject.Shape = function(element){ X3DOMObject.Shape = function(element){
this._elem = element this._elem = element
this._clearEvents();
this._registerEvents(); 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(){ X3DOMObject.Shape.prototype._registerEvents = function(){
var self = Scene; var self = Scene;
$(this._elem).on("mousemove",function(e){ $(this._elem).on("mousemove",function(e){
if(!SETTINGS.manualposor){
var x = e.originalEvent.worldX; var x = e.originalEvent.worldX;
var y = e.originalEvent.worldY; var y = e.originalEvent.worldY;
var z = e.originalEvent.worldZ; var z = e.originalEvent.worldZ;
...@@ -334,6 +348,12 @@ X3DOMObject.Shape.prototype._registerEvents = function(){ ...@@ -334,6 +348,12 @@ X3DOMObject.Shape.prototype._registerEvents = function(){
} }
}else{
// for align marker? do nothing
}
/* /*
if (!SETTINGS.verticaldrag&&Scene.draggedMarker){ if (!SETTINGS.verticaldrag&&Scene.draggedMarker){
...@@ -366,6 +386,8 @@ X3DOMObject.Shape.prototype._registerEvents = function(){ ...@@ -366,6 +386,8 @@ X3DOMObject.Shape.prototype._registerEvents = function(){
if (self._ctrlKey){ if (self._ctrlKey){
if(!SETTINGS.manualposor){
var x = e.originalEvent.worldX; var x = e.originalEvent.worldX;
var y = e.originalEvent.worldY; var y = e.originalEvent.worldY;
var z = e.originalEvent.worldZ; var z = e.originalEvent.worldZ;
...@@ -378,6 +400,16 @@ X3DOMObject.Shape.prototype._registerEvents = function(){ ...@@ -378,6 +400,16 @@ X3DOMObject.Shape.prototype._registerEvents = function(){
X3DOMObject.createNewMarker(x,y,z); X3DOMObject.createNewMarker(x,y,z);
}else{
// align marker
var lx = e.originalEvent.layerX;
var ly = e.originalEvent.layerY;
manualposor_init_shootrays(lx,ly);
}
} }
/* /*
......
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