Loading x3d_web_viewer/index.html +1 −5 Original line number Original line Diff line number Diff line Loading @@ -5,7 +5,7 @@ <link rel="stylesheet" href="x3dom-1.7.0/x3dom.css"> <link rel="stylesheet" href="x3dom-1.7.0/x3dom.css"> <link rel="stylesheet" href="viewmodel.css"> <link rel="stylesheet" href="viewmodel.css"> <script src="jquery-2.1.4.min.js"></script> <script src="jquery-2.1.4.min.js"></script> <script type='text/javascript' src='x3dom-1.7.0/x3dom.js'> </script> <!--<script type='text/javascript' src='x3dom-1.7.0/x3dom.js'> </script>--> <script src="bootstrap/js/bootstrap.min.js"></script> <script src="bootstrap/js/bootstrap.min.js"></script> <script src="viewmodel.js"></script> <script src="viewmodel.js"></script> </head> </head> Loading Loading @@ -35,10 +35,6 @@ </div> </div> <div id="test:5" secretvalue='-4'></div> <div id="test:5" secretvalue='-4'></div> <script> <script> x3dom.runtime.ready = function() { console.log("X3D Ready"); //run(); } prerun(); prerun(); resize(); resize(); </script> </script> Loading x3d_web_viewer/viewmodel.js +84 −93 Original line number Original line Diff line number Diff line Loading @@ -40,13 +40,8 @@ var moveTimeStamp; var showdefault = 0; var showdefault = 0; var load_counter = 0; var block_load_events = false; var load_limit = 1; /* $(function(){ prerun(); }); */ function prerun(){ function prerun(){ $(window).resize(function(){ $(window).resize(function(){ clearTimeout(resizeTimer); clearTimeout(resizeTimer); Loading @@ -72,15 +67,14 @@ function prerun(){ stop_animation(); stop_animation(); }); }); var x3d_cnv_ni = $("<NavigationInfo>",{id:"navi",type:"'examine' 'any'",speed:"15",headlight:"true"}); var x3d_cnv_ni = $("<navigationinfo>",{id:"navi",type:"'examine' 'any'",speed:"1"}); var x3d_cnv_vp = $("<Viewpoint>").attr("fieldOfView","0.202"); var x3d_cnv_vp = $("<Viewpoint>").attr("fieldOfView","0.200"); var x3d_cnv_in = $("<inline>",{ var x3d_cnv_in = $("<inline>",{ id:"topinline", id:"topinline", nameSpaceName:NSN, nameSpaceName:NSN, url: model url: model //onLoad:"document.getElementById('x3d_canvas').runtime.showAll()" }); }); var x3d_cnv_trans = $("<Transform id='anima' DEF='ball'>"); var x3d_cnv_trans = $("<Transform id='anima' DEF='ball'>"); Loading @@ -102,6 +96,9 @@ function prerun(){ scene.append(x3d_cnv_trans); scene.append(x3d_cnv_trans); x3d_cnv.append(scene); x3d_cnv.append(scene); //load x3dom.js $.getScript("x3dom-1.7.0/x3dom.js"); var settings = $("<div>").load(settings_file,function(response,status,xhr){ var settings = $("<div>").load(settings_file,function(response,status,xhr){ if (xhr.status==200){ if (xhr.status==200){ var xml = $.parseXML(response); var xml = $.parseXML(response); Loading @@ -118,22 +115,38 @@ function prerun(){ height: x3d_cnv.height()+"px" height: x3d_cnv.height()+"px" }); }); var element = document.getElementById('x3d_canvas'); //on load: showAll()?! //required minimum? var showall = 1; var showall = 1; var element = document.getElementById('x3d_canvas'); $(document).load(function(){ $(document).load(function(){ element.runtime.enterFrame = function() { element.runtime.enterFrame = function() { if (showall==1) { if (showall==1) { element.runtime.examine(); element.runtime.examine(); element.runtime.showAll("negY"); element.runtime.showAll("negY"); if (showdefault) element.runtime.resetView(); if (showdefault) element.runtime.resetView(); run(); showall=0; place_camera(); model_init(); }else{ //console.log("Loaded "+load_counter); if (showall>=0){ place_camera(); model_init(); showall--; } //the only <strong> var progress_element = $.find("strong"); var progress_counter = $(progress_element).html(); progress_counter = progress_counter.split(" "); //console.log("x3dom counter = "+progress_counter[1]); cnt = parseInt(progress_counter[1]); if (!block_load_events){ if (cnt==0){ place_camera(); model_init(); block_load_events = true; } } } } if (showall>0) showall--; }; }; }); }); Loading Loading @@ -303,61 +316,6 @@ function model_init(){ bindCanvas(); bindCanvas(); } } var block_load_events = false; function run(){ console.log("run()"); var inlines = $.find("Inline"); console.log("Found inlines: "+inlines.length); load_limit = inlines.length; load_counter = 0; if (load_limit==1){ tmp_inline = $(inlines[0]); tmp_inline.load(function(){ run2(); }); } } function run2(){ console.log("run2()"); var inlines = $.find("Inline"); console.log("Found new inlines: "+(inlines.length-1)); load_limit = inlines.length; for(var i=0;i<inlines.length;i++){ tmp_inline = $(inlines[i]); tmp_inline.load(function(){ load_counter++; console.log("Loaded "+load_counter); var progress_element = $.find("strong"); var progress_counter = $(progress_element).html(); progress_counter = progress_counter.split(" "); console.log("x3dom counter = "+progress_counter[1]); if (!block_load_events){ if (load_counter==1){ console.log("fire init (1)"); model_init(); //unbindCanvas(); //bindCanvas(); } if (load_counter==(load_limit-2)){ console.log("fire init (limit-2)"); model_init(); //unbindCanvas(); //bindCanvas(); } } }); } if (inlines.length==1) { //bindCanvas(); model_init(); } } function removeBOM(){ function removeBOM(){ var top = $("#topinline"); var top = $("#topinline"); top.find("Inline").off("click"); top.find("Inline").off("click"); Loading @@ -367,7 +325,7 @@ function removeBOM(){ } } function place_camera(){ function place_camera(){ console.log("place camera"); var top = $("#topinline"); var top = $("#topinline"); //get top boundary box position //get top boundary box position var top_groups = top.find("Group"); var top_groups = top.find("Group"); Loading Loading @@ -434,8 +392,9 @@ function showBOM(){ }); }); } } $("body").append(bom); var top = $("#topinline"); var top = $("#topinline"); place_camera(); //upper case was important //upper case was important var parts_unique = top.find("Inline"); var parts_unique = top.find("Inline"); Loading @@ -455,6 +414,9 @@ function showBOM(){ } } }); }); var bomtr_counter=0; var bomtr_subcounter=0; //console.log("Sorted"); //console.log("Sorted"); //console.log(parts_unique); //console.log(parts_unique); Loading Loading @@ -545,9 +507,25 @@ function showBOM(){ //var ele = $("<li>",{class:"list-group-item"}).append($(ele_sublist)); //var ele = $("<li>",{class:"list-group-item"}).append($(ele_sublist)); var ele = $("<td>").css({padding:"2px 5px 2px 0px"}).append($(ele_sublist)); var ele = $("<td>").css({padding:"2px 5px 2px 0px"}).append($(ele_sublist)); /* if(i%3==0){ if(i%3==0){ bomtr = $("<tr>"); bomtr = $("<tr>"); bom.append(bomtr); bom.append(bomtr); console.log(bom.height()+" vs "+$("#main").height()); } */ if (bom.height()<=($("#main").height()-30)){ bomtr_counter++; bomtr = $("<tr id='bomtr_"+bomtr_counter+"'>"); bomtr_subcounter=0; bom.append(bomtr); }else{ bomtr_subcounter++; bomtr = $("#bomtr_"+bomtr_subcounter); console.log("Adding to tr #"+bomtr_subcounter); if (bomtr_subcounter==bomtr_counter){ bomtr_subcounter=0; } } } bomtr.append(ele); bomtr.append(ele); Loading @@ -555,7 +533,6 @@ function showBOM(){ model_run_cmd(tmp_nsn,"click-ext"); model_run_cmd(tmp_nsn,"click-ext"); }); }); }); }); $("body").append(bom); } } var blockclick = false; var blockclick = false; Loading Loading @@ -597,11 +574,19 @@ function bindCanvas(){ canvas.addEventListener("touchmove",touchmoved,false); canvas.addEventListener("touchmove",touchmoved,false); //click //click $("Switch").click(function(event){ $("Switch").click(function(event){ if (!blockclick){ var hmm = $(this); var hmm = $(this); var id = hmm.attr("id"); var id = hmm.attr("id"); var pn_arr = id.split(/[_:]/); var pn_arr = id.split(/[_:]/); var pn = pn_arr[pn_arr.length-2]; var pn = pn_arr[pn_arr.length-2]; old_time = switch_click_time; switch_click_time = getTimeStamp(); if (!blockclick){ if ((switch_click_time-old_time)<400){ if (event.which==1){ model_run_cmd(pn,"normalize"); model_run_cmd(pn,"right-click"); } }else{ if (event.which==1){ if (event.which==1){ //fighting multiple click events //fighting multiple click events if (pn_arr[pn_arr.length-1]=="0") model_run_cmd(pn,"left-click"); if (pn_arr[pn_arr.length-1]=="0") model_run_cmd(pn,"left-click"); Loading @@ -612,9 +597,12 @@ function bindCanvas(){ } } console.log("The pointer is over "+hmm.attr("id")+", whichChoice="+hmm.attr("whichChoice")+" render="+hmm.attr("render")+" DEF="+hmm.attr("DEF")); console.log("The pointer is over "+hmm.attr("id")+", whichChoice="+hmm.attr("whichChoice")+" render="+hmm.attr("render")+" DEF="+hmm.attr("DEF")); } } } }); }); } } var switch_click_time = 0; function touchstarted(){ function touchstarted(){ stop_animation(); stop_animation(); blockclick = false; blockclick = false; Loading Loading @@ -665,7 +653,7 @@ function update_info(name,state,cmd){ $("#info").empty(); $("#info").empty(); switch(cmd){ switch(cmd){ case "left-click": case "left-click": if (state=="normal"){ if ((state=="normal")){ var pn = $("<span>").html(name); var pn = $("<span>").html(name); var open_btn = $("<a>",{ var open_btn = $("<a>",{ id:"info_open", id:"info_open", Loading Loading @@ -694,6 +682,9 @@ function update_info(name,state,cmd){ $("#info").append(pn).append($("<span>").append(open_btn)).append($("<span>").append(hide_btn)); $("#info").append(pn).append($("<span>").append(open_btn)).append($("<span>").append(hide_btn)); } } break; break; case "click-ext": update_info(name,"normal","left-click"); break; default: return false; default: return false; } } } } Loading Loading
x3d_web_viewer/index.html +1 −5 Original line number Original line Diff line number Diff line Loading @@ -5,7 +5,7 @@ <link rel="stylesheet" href="x3dom-1.7.0/x3dom.css"> <link rel="stylesheet" href="x3dom-1.7.0/x3dom.css"> <link rel="stylesheet" href="viewmodel.css"> <link rel="stylesheet" href="viewmodel.css"> <script src="jquery-2.1.4.min.js"></script> <script src="jquery-2.1.4.min.js"></script> <script type='text/javascript' src='x3dom-1.7.0/x3dom.js'> </script> <!--<script type='text/javascript' src='x3dom-1.7.0/x3dom.js'> </script>--> <script src="bootstrap/js/bootstrap.min.js"></script> <script src="bootstrap/js/bootstrap.min.js"></script> <script src="viewmodel.js"></script> <script src="viewmodel.js"></script> </head> </head> Loading Loading @@ -35,10 +35,6 @@ </div> </div> <div id="test:5" secretvalue='-4'></div> <div id="test:5" secretvalue='-4'></div> <script> <script> x3dom.runtime.ready = function() { console.log("X3D Ready"); //run(); } prerun(); prerun(); resize(); resize(); </script> </script> Loading
x3d_web_viewer/viewmodel.js +84 −93 Original line number Original line Diff line number Diff line Loading @@ -40,13 +40,8 @@ var moveTimeStamp; var showdefault = 0; var showdefault = 0; var load_counter = 0; var block_load_events = false; var load_limit = 1; /* $(function(){ prerun(); }); */ function prerun(){ function prerun(){ $(window).resize(function(){ $(window).resize(function(){ clearTimeout(resizeTimer); clearTimeout(resizeTimer); Loading @@ -72,15 +67,14 @@ function prerun(){ stop_animation(); stop_animation(); }); }); var x3d_cnv_ni = $("<NavigationInfo>",{id:"navi",type:"'examine' 'any'",speed:"15",headlight:"true"}); var x3d_cnv_ni = $("<navigationinfo>",{id:"navi",type:"'examine' 'any'",speed:"1"}); var x3d_cnv_vp = $("<Viewpoint>").attr("fieldOfView","0.202"); var x3d_cnv_vp = $("<Viewpoint>").attr("fieldOfView","0.200"); var x3d_cnv_in = $("<inline>",{ var x3d_cnv_in = $("<inline>",{ id:"topinline", id:"topinline", nameSpaceName:NSN, nameSpaceName:NSN, url: model url: model //onLoad:"document.getElementById('x3d_canvas').runtime.showAll()" }); }); var x3d_cnv_trans = $("<Transform id='anima' DEF='ball'>"); var x3d_cnv_trans = $("<Transform id='anima' DEF='ball'>"); Loading @@ -102,6 +96,9 @@ function prerun(){ scene.append(x3d_cnv_trans); scene.append(x3d_cnv_trans); x3d_cnv.append(scene); x3d_cnv.append(scene); //load x3dom.js $.getScript("x3dom-1.7.0/x3dom.js"); var settings = $("<div>").load(settings_file,function(response,status,xhr){ var settings = $("<div>").load(settings_file,function(response,status,xhr){ if (xhr.status==200){ if (xhr.status==200){ var xml = $.parseXML(response); var xml = $.parseXML(response); Loading @@ -118,22 +115,38 @@ function prerun(){ height: x3d_cnv.height()+"px" height: x3d_cnv.height()+"px" }); }); var element = document.getElementById('x3d_canvas'); //on load: showAll()?! //required minimum? var showall = 1; var showall = 1; var element = document.getElementById('x3d_canvas'); $(document).load(function(){ $(document).load(function(){ element.runtime.enterFrame = function() { element.runtime.enterFrame = function() { if (showall==1) { if (showall==1) { element.runtime.examine(); element.runtime.examine(); element.runtime.showAll("negY"); element.runtime.showAll("negY"); if (showdefault) element.runtime.resetView(); if (showdefault) element.runtime.resetView(); run(); showall=0; place_camera(); model_init(); }else{ //console.log("Loaded "+load_counter); if (showall>=0){ place_camera(); model_init(); showall--; } //the only <strong> var progress_element = $.find("strong"); var progress_counter = $(progress_element).html(); progress_counter = progress_counter.split(" "); //console.log("x3dom counter = "+progress_counter[1]); cnt = parseInt(progress_counter[1]); if (!block_load_events){ if (cnt==0){ place_camera(); model_init(); block_load_events = true; } } } } if (showall>0) showall--; }; }; }); }); Loading Loading @@ -303,61 +316,6 @@ function model_init(){ bindCanvas(); bindCanvas(); } } var block_load_events = false; function run(){ console.log("run()"); var inlines = $.find("Inline"); console.log("Found inlines: "+inlines.length); load_limit = inlines.length; load_counter = 0; if (load_limit==1){ tmp_inline = $(inlines[0]); tmp_inline.load(function(){ run2(); }); } } function run2(){ console.log("run2()"); var inlines = $.find("Inline"); console.log("Found new inlines: "+(inlines.length-1)); load_limit = inlines.length; for(var i=0;i<inlines.length;i++){ tmp_inline = $(inlines[i]); tmp_inline.load(function(){ load_counter++; console.log("Loaded "+load_counter); var progress_element = $.find("strong"); var progress_counter = $(progress_element).html(); progress_counter = progress_counter.split(" "); console.log("x3dom counter = "+progress_counter[1]); if (!block_load_events){ if (load_counter==1){ console.log("fire init (1)"); model_init(); //unbindCanvas(); //bindCanvas(); } if (load_counter==(load_limit-2)){ console.log("fire init (limit-2)"); model_init(); //unbindCanvas(); //bindCanvas(); } } }); } if (inlines.length==1) { //bindCanvas(); model_init(); } } function removeBOM(){ function removeBOM(){ var top = $("#topinline"); var top = $("#topinline"); top.find("Inline").off("click"); top.find("Inline").off("click"); Loading @@ -367,7 +325,7 @@ function removeBOM(){ } } function place_camera(){ function place_camera(){ console.log("place camera"); var top = $("#topinline"); var top = $("#topinline"); //get top boundary box position //get top boundary box position var top_groups = top.find("Group"); var top_groups = top.find("Group"); Loading Loading @@ -434,8 +392,9 @@ function showBOM(){ }); }); } } $("body").append(bom); var top = $("#topinline"); var top = $("#topinline"); place_camera(); //upper case was important //upper case was important var parts_unique = top.find("Inline"); var parts_unique = top.find("Inline"); Loading @@ -455,6 +414,9 @@ function showBOM(){ } } }); }); var bomtr_counter=0; var bomtr_subcounter=0; //console.log("Sorted"); //console.log("Sorted"); //console.log(parts_unique); //console.log(parts_unique); Loading Loading @@ -545,9 +507,25 @@ function showBOM(){ //var ele = $("<li>",{class:"list-group-item"}).append($(ele_sublist)); //var ele = $("<li>",{class:"list-group-item"}).append($(ele_sublist)); var ele = $("<td>").css({padding:"2px 5px 2px 0px"}).append($(ele_sublist)); var ele = $("<td>").css({padding:"2px 5px 2px 0px"}).append($(ele_sublist)); /* if(i%3==0){ if(i%3==0){ bomtr = $("<tr>"); bomtr = $("<tr>"); bom.append(bomtr); bom.append(bomtr); console.log(bom.height()+" vs "+$("#main").height()); } */ if (bom.height()<=($("#main").height()-30)){ bomtr_counter++; bomtr = $("<tr id='bomtr_"+bomtr_counter+"'>"); bomtr_subcounter=0; bom.append(bomtr); }else{ bomtr_subcounter++; bomtr = $("#bomtr_"+bomtr_subcounter); console.log("Adding to tr #"+bomtr_subcounter); if (bomtr_subcounter==bomtr_counter){ bomtr_subcounter=0; } } } bomtr.append(ele); bomtr.append(ele); Loading @@ -555,7 +533,6 @@ function showBOM(){ model_run_cmd(tmp_nsn,"click-ext"); model_run_cmd(tmp_nsn,"click-ext"); }); }); }); }); $("body").append(bom); } } var blockclick = false; var blockclick = false; Loading Loading @@ -597,11 +574,19 @@ function bindCanvas(){ canvas.addEventListener("touchmove",touchmoved,false); canvas.addEventListener("touchmove",touchmoved,false); //click //click $("Switch").click(function(event){ $("Switch").click(function(event){ if (!blockclick){ var hmm = $(this); var hmm = $(this); var id = hmm.attr("id"); var id = hmm.attr("id"); var pn_arr = id.split(/[_:]/); var pn_arr = id.split(/[_:]/); var pn = pn_arr[pn_arr.length-2]; var pn = pn_arr[pn_arr.length-2]; old_time = switch_click_time; switch_click_time = getTimeStamp(); if (!blockclick){ if ((switch_click_time-old_time)<400){ if (event.which==1){ model_run_cmd(pn,"normalize"); model_run_cmd(pn,"right-click"); } }else{ if (event.which==1){ if (event.which==1){ //fighting multiple click events //fighting multiple click events if (pn_arr[pn_arr.length-1]=="0") model_run_cmd(pn,"left-click"); if (pn_arr[pn_arr.length-1]=="0") model_run_cmd(pn,"left-click"); Loading @@ -612,9 +597,12 @@ function bindCanvas(){ } } console.log("The pointer is over "+hmm.attr("id")+", whichChoice="+hmm.attr("whichChoice")+" render="+hmm.attr("render")+" DEF="+hmm.attr("DEF")); console.log("The pointer is over "+hmm.attr("id")+", whichChoice="+hmm.attr("whichChoice")+" render="+hmm.attr("render")+" DEF="+hmm.attr("DEF")); } } } }); }); } } var switch_click_time = 0; function touchstarted(){ function touchstarted(){ stop_animation(); stop_animation(); blockclick = false; blockclick = false; Loading Loading @@ -665,7 +653,7 @@ function update_info(name,state,cmd){ $("#info").empty(); $("#info").empty(); switch(cmd){ switch(cmd){ case "left-click": case "left-click": if (state=="normal"){ if ((state=="normal")){ var pn = $("<span>").html(name); var pn = $("<span>").html(name); var open_btn = $("<a>",{ var open_btn = $("<a>",{ id:"info_open", id:"info_open", Loading Loading @@ -694,6 +682,9 @@ function update_info(name,state,cmd){ $("#info").append(pn).append($("<span>").append(open_btn)).append($("<span>").append(hide_btn)); $("#info").append(pn).append($("<span>").append(open_btn)).append($("<span>").append(hide_btn)); } } break; break; case "click-ext": update_info(name,"normal","left-click"); break; default: return false; default: return false; } } } } Loading