From 3b0559efe21d33f15d0d4fb0ad2449f102715f56 Mon Sep 17 00:00:00 2001 From: Rob L Date: Tue, 2 Aug 2016 13:22:16 -0400 Subject: [PATCH] Add Intel section: Calculate possible destination of bogie --- js/GUI.Utils.js | 25 ++++++++++++++++++++++++- js/mapviewgl.js | 34 +++++++++++++++++++++++++++++++++- webviewgl.htm | 24 +++++++++++++++++++++++- 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/js/GUI.Utils.js b/js/GUI.Utils.js index 04d5f3e..42e23c2 100644 --- a/js/GUI.Utils.js +++ b/js/GUI.Utils.js @@ -21,7 +21,7 @@ $(document).ready(function() { removeEntity('arrow'); lastInputBox = null; $('#route_output').html("No route calculated"); - var speed = {'speed': $('#speed').val(), 'unit':$ ('#speedunit option:selected').val() }; + var speed = {'speed': $('#speed').val(), 'unit':$('#speedunit option:selected').val() }; populateRoutePlan( $('#pointa option:selected').text() , $('#pointb option:selected').text(),speed ); @@ -39,6 +39,18 @@ $(document).ready(function() { String.prototype.capitalize = function(lower) { return (lower ? this.toLowerCase() : this).replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); }); }; + $('.rpcoord').blur(function() { + if(!$(this).val()) { $(this).val( $(this).attr("id") ) } + + }); + $('.rpcoord').focus(function() { + if($(this).val() == $(this).attr("id")) { $(this).val("") } + }); + $('#calcpredict').click(function() { + $('#intel_predicted').html(""); + var predicted = predictDestination(new THREE.Vector3(Number($('#x').val()),Number($('#y').val()),Number($('#z').val())),new THREE.Vector2(Number($('#azmuth').val()),Number($('#inclination').val())),$('#intel_frame option:selected').val()); + $('#intel_predicted').html(predicted); + }); }); @@ -65,6 +77,17 @@ function populateUserFields() { $('#pointa').html(option); $('#pointb').html(option); + // Populate list of borders for intel frame selection + option = $('#intel_frame').html(); + var borderlist = listobjects("borders"); + + for (var border in borderlist) { + if(borderlist[border].radius > 10) { + option += ''; + } + } + $('#intel_frame').html(option); + } function populateFBSelect() { //Populate find by select dropdown diff --git a/js/mapviewgl.js b/js/mapviewgl.js index 95fa6ad..f7537c7 100644 --- a/js/mapviewgl.js +++ b/js/mapviewgl.js @@ -210,7 +210,7 @@ function listobjects(type) { function zoomfocus(name) { - var zoomto = grabPositionByName(name) + var zoomto = grabPositionByName(name); if (zoomto != null) { controls.target.x = zoomto.x; controls.target.y = zoomto.y; @@ -365,3 +365,35 @@ function calcBestRoute(pointa,pointb) { return route[route_keys_sorted[0]]; } + + +function predictDestination(loc,heading,frame) { + removeEntity('arrow'); + if(frame != "Galactic") { + var objFrame = grabPositionByName(frame); + } else { + var objFrame = new THREE.Vector3(0,0,0); + } + + console.log(frame) + var adjLoc = loc.clone(); + adjLoc = adjLoc.add(objFrame); + var headingvec = new THREE.Vector3(heading.x, heading.y, 300); + var farpoint = calcEndpointByHeading(headingvec,adjLoc); + drawline(adjLoc,farpoint); + var directionvector = farpoint.sub(adjLoc); + var ray = new THREE.Raycaster(adjLoc, directionvector.clone().normalize()); + scene.updateMatrixWorld(); + var intersects = ray.intersectObjects(scene.children,false); + var correctedintersections=[]; + if (intersects[0]) { + intersects.forEach(function(obj) { + if (obj.object.geometry.boundingSphere.radius != 'undefined' && obj.object.geometry.boundingSphere.radius < 2) { + correctedintersections.push(obj.object.name); + } + }); + return correctedintersections[0]; + } + return "Unable to predict" + +} diff --git a/webviewgl.htm b/webviewgl.htm index 365d6bc..f414d53 100644 --- a/webviewgl.htm +++ b/webviewgl.htm @@ -117,7 +117,8 @@
Find Object By Name @@ -164,6 +165,27 @@ Distance: Unknown
ETA @ Unknown : Unknown +
+
+ Route Prediction + + + +

+ +

+ + + +
+ + Perdicted Destination: + + + +
This tool was designed by Frey @ ATSMUSH. It is based on MapView for ATS with data used from the Navcomp MUSHClient plugin with permission.