Add Intel section: Calculate possible destination of bogie

This commit is contained in:
Rob L 2016-08-02 13:22:16 -04:00
parent 8d2788b318
commit 3b0559efe2
3 changed files with 80 additions and 3 deletions

View File

@ -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 += '<option value="'+ escapeHTML(border) + '">' + escapeHTML(border) + '</option>';
}
}
$('#intel_frame').html(option);
}
function populateFBSelect() {
//Populate find by select dropdown

View File

@ -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"
}

View File

@ -117,7 +117,8 @@
<ul class="wvg-navbar">
<li class="wvg-tablink wvg-tab-active" onclick="openTab(event,'Find');">Find</li>
<li class="wvg-tablink" onclick="openTab(event,'Plan');">Plan</li>
<li class="wvg-tablink" onclick="openTab(event,'Info');">Info</li>
<li class="wvg-tablink" onclick="openTab(event,'Intel');">Intel</li>
<li class="wvg-tablink" onclick="openTab(event,'Info');">Info</li>
</ul>
<div class="wvg-tools wvg-first" id="Find">
<span class="tool-header"> Find Object By Name </span>
@ -164,6 +165,27 @@
Distance: <b id="cal_dist">Unknown</b><br />
ETA @ <b id="cal_speed">Unknown</b> : <b id="cal_eta">Unknown</b>
</span>
</div>
<div class="wvg-tools" id="Intel">
<span class="tool-header"> Route Prediction </span>
<span>
<input type="text" class="rpcoord" id="x" value="x" style="width:3vw;">
<input type="text" class="rpcoord" id="y" value="y" style="width:3vw;">
<input type="text" class="rpcoord" id="z" value="z" style="width:3vw;"><br /><br />
<input type="text" class="rpcoord" id="azmuth" value="azmuth" style="width:3.1vw;"><label for='inclination'> mark </label>
<input type="text" class="rpcoord" id="inclination" value="inclination" style="width:3.5vw;"> <br /><br />
<label for="intel_frame">Coordinate Frame</label>
<select id="intel_frame">
<option val="Galactic"> Galactic </option>
</select>
</span>
<span>
Perdicted Destination: <b id="intel_predicted"></b>
<button id="calcpredict" class="btn">Predict</button>
</span>
</div>
<div class="wvg-tools" id="Info">
<span> This tool was designed by Frey @ ATSMUSH. It is based on MapView for ATS with data used from the Navcomp MUSHClient plugin with permission. </span>