Draw lines. Random lines.
This commit is contained in:
parent
1374f238d9
commit
87ad2552af
@ -13,6 +13,8 @@ $(document).ready(function() {
|
|||||||
zoomfocus(selected);
|
zoomfocus(selected);
|
||||||
});
|
});
|
||||||
$('#calctnd').click(function() {
|
$('#calctnd').click(function() {
|
||||||
|
removeEntity('arrow');
|
||||||
|
lastInputBox = null;
|
||||||
$('#cal_start').html( $('#pointa option:selected').text() );
|
$('#cal_start').html( $('#pointa option:selected').text() );
|
||||||
$('#cal_end').html( $('#pointb option:selected').text() );
|
$('#cal_end').html( $('#pointb option:selected').text() );
|
||||||
$('#cal_speed').html( $('#speed').val() +" " + $('#speedunit option:selected').val() );
|
$('#cal_speed').html( $('#speed').val() +" " + $('#speedunit option:selected').val() );
|
||||||
@ -20,7 +22,9 @@ $(document).ready(function() {
|
|||||||
var eta = calcETA({'speed': $('#speed').val(), 'unit': $('#speedunit option:selected').val()},dist)
|
var eta = calcETA({'speed': $('#speed').val(), 'unit': $('#speedunit option:selected').val()},dist)
|
||||||
$('#cal_eta').html( timeformat(eta) );
|
$('#cal_eta').html( timeformat(eta) );
|
||||||
$('#cal_dist').html( dist.toFixed(2) + " PC");
|
$('#cal_dist').html( dist.toFixed(2) + " PC");
|
||||||
|
if ( $('#pointa option:selected').text() != $('#pointb option:selected').text() ) {
|
||||||
|
drawline(grabPositionByName($('#pointa option:selected').text()),grabPositionByName($('#pointb option:selected').text()));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#pointa").focus(function() {
|
$("#pointa").focus(function() {
|
||||||
|
@ -235,13 +235,13 @@ function zoomfocus(name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function drawline(name,origin,dest) {
|
function drawline(origin,dest) {
|
||||||
var geometry = new THREE.Geometry();
|
var direction = dest.clone().sub(origin);
|
||||||
var material = new THREE.LineBasicMaterial( { color: '#FFF', });
|
var length = origin.distanceTo(dest);
|
||||||
geometry.vertices.push(origin, direction);
|
var arrowHelper = new THREE.ArrowHelper(direction.normalize(),origin,length,0xffffff,10,5);
|
||||||
var line = new THREE.Line( geometry, material );
|
arrowHelper.name = "arrow";
|
||||||
ray.name = "test";
|
scene.add( arrowHelper );
|
||||||
scene.add(ray);
|
|
||||||
animate();
|
animate();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -301,3 +301,26 @@ function calcDist(pointa, pointb) {
|
|||||||
var distance = obj_A.position.distanceTo(obj_B.position);
|
var distance = obj_A.position.distanceTo(obj_B.position);
|
||||||
return distance;
|
return distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function grabPositionByName(name) { return scene.getObjectByName(name).position; }
|
||||||
|
|
||||||
|
|
||||||
|
function calcEndpointByHeading(heading,startvec = new THREE.Vector3(0,0,0)) {
|
||||||
|
// heading.x = azimuth
|
||||||
|
// heading.y = inclination
|
||||||
|
// heading.z = radius (distance)
|
||||||
|
var calcvec = new THREE.Vector3();
|
||||||
|
calcvec.x = Math.cos(heading.x / 180 * Math.PI ) * Math.cos(heading.y / 180 * Math.PI ) * heading.z;
|
||||||
|
calcvec.x = Number(calcvec.x.toFixed(6));
|
||||||
|
if (Math.sign(calcvec.x) == -1 && calcvec.x == 0) { calcvec.x=0; } // A dirty hack to fix negative zero situations.
|
||||||
|
calcvec.y = Math.sin(heading.x / 180 * Math.PI ) * Math.cos(heading.y / 180 * Math.PI ) * heading.z;
|
||||||
|
calcvec.y = Number(calcvec.y.toFixed(6));
|
||||||
|
if (Math.sign(calcvec.y) == -1 && calcvec.y == 0) { calcvec.y=0; } // A dirty hack to fix negative zero situations.
|
||||||
|
calcvec.z = Math.sin(heading.y / 180 * Math.PI) * heading.z;
|
||||||
|
calcvec.z = Number(calcvec.z.toFixed(6));
|
||||||
|
if (Math.sign(calcvec.z) == -1 && calcvec.z == 0) { calcvec.z=0; } // A dirty hack to fix negative zero situations.
|
||||||
|
var finalvec = new THREE.Vector3();
|
||||||
|
calcvec.add(startvec);
|
||||||
|
return calcvec;
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user