Skip to content
Snippets Groups Projects
Commit f04c8bc2 authored by Xavier Gibert's avatar Xavier Gibert
Browse files

Angle of orbital plane (inclination) works but has a bug where it turns in a...

Angle of orbital plane (inclination) works but has a bug where it turns in a discontinutity over the negative axis
parent f6d91401
No related branches found
No related tags found
No related merge requests found
......@@ -262,3 +262,46 @@ function showAndroidToast(toast) {
render();
}
/*var lookat = function(vecstart,vecEnd,vecUp){
var temp = new THREE.Matrix4()
temp.lookAt(vecEnd,vecstart,vecUp);
var m00 = temp.n11, m10 = temp.n21, m20 = temp.n31,
m01 = temp.n12, m11 = temp.n22, m21 = temp.n32,
m02 = temp.n13, m12 = temp.n23, m22 = temp.n33;
var t = m00 + m11 + m22,s,x,y,z,w;
if (t > 0) {
s = Math.sqrt(t+1)*2;
w = 0.25 * s;
x = (m21 - m12) / s;
y = (m02 - m20) / s;
z = (m10 - m01) / s;
} else if ((m00 > m11) && (m00 > m22)) {
s = Math.sqrt(1.0 + m00 - m11 - m22)*2;
x = s * 0.25;
y = (m10 + m01) / s;
z = (m02 + m20) / s;
w = (m21 - m12) / s;
} else if (m11 > m22) {
s = Math.sqrt(1.0 + m11 - m00 - m22) *2;
y = s * 0.25;
x = (m10 + m01) / s;
z = (m21 + m12) / s;
w = (m02 - m20) / s;
} else {
s = Math.sqrt(1.0 + m22 - m00 - m11) *2;
z = s * 0.25;
x = (m02 + m20) / s;
y = (m21 + m12) / s;
w = (m10 - m01) / s;
}
var rotation = new THREE.Quaternion(x,y,z,w);
rotation.normalize();
return rotation;
};*/
......@@ -66,9 +66,9 @@ This three.js demo is part of a collection at
var container, scene, camera, renderer, controls, stats, light, sunLight, lineSun, spriteSun, contextSun, contextEarth, lineEarth, spriteEarth;
//var keyboard = new THREEx.KeyboardState();
var clock = new THREE.Clock();
var sun, sunGlow, earth, spacecraft, arrow_vel, arrow_accel, arrow_momentum, target_a, vector_a, direction_a;
var sun, sunGlow, earth, spacecraft, arrow_vel, arrow_accel, arrow_momentum, target_a, vector_a, direction_a, plane_orb, incl_arc;
var origin = new THREE.Vector3(0,0,0);
var fontsizeSun, borderColorSun, borderThicknessSun, backgroundColorSun, fontColorSun;
var fontsizeSun, borderColorSun, borderThicknessSun, backgroundColorSun, fontColorSun, mat_arc;
var fontsizeEarth, borderColorEarth, borderThicknessEarth, backgroundColorEarth, fontColorEarth;
var fps_update_counter = 0;
var miniSphereX,miniSphereXX,miniSphereY,miniSphereYY,miniSphereZ,miniSphereZZ;
......@@ -88,6 +88,12 @@ This three.js demo is part of a collection at
var miniSphere_margin = 4;
var torus_radius = sphere_radius;
var torus_tube = 0.5;
var arc_radius = sphere_radius+3;
var arc_tube = 0.9;
var planes_width = sphere_radius-(sphere_radius/5);
var plane_theta_seg = 30;
var plane_phi_seg = 10;
var sc_scale = 1.5;
......@@ -143,13 +149,17 @@ This three.js demo is part of a collection at
var show_fps = true;//Show FPS stats in Android
var fps_update_skips = 60;
var show_sky = true;
var show_sky = false;//REVERT
var show_sphere = true;
var show_mini_spheres = true;
var show_circles = true;
var show_axis = true;
var show_axis_labels = true;
var show_planes = true;
var plane_xy_color = 0xFF0000;
var plane_orb_color = 0x00FF00;
var show_inclination = true;//XGGDEBUG: add these preferences in android
var show_spacecraft = true;//If set to false, instead of a S/C it will be a miniSphere in the reference position.
var show_sc_axis = true;
......@@ -158,7 +168,7 @@ This three.js demo is part of a collection at
var show_sun = true;
var sun_rotates = true;
var sun_rotation_speed = 5;//Rotation speed multiplier [0->9]
var show_sun_texture = true;
var show_sun_texture = false;//REVERT
var sun_simple_glow = true;//Recomended to not use the shader glow, problems in android
var sun_show_line = true;
var sun_show_dist = true;
......@@ -166,7 +176,7 @@ This three.js demo is part of a collection at
var show_earth = true;
var earth_rotates = true;
var earth_rotation_speed = 2;//Rotation speed multiplier [0->9]
var show_earth_texture = true;
var show_earth_texture = false;//REVERT
var earth_show_line = true;
var earth_show_dist = true;
......@@ -184,10 +194,10 @@ This three.js demo is part of a collection at
var color_vector_a = 0x00fffa;
var limit_vector_a = 25; //In the same units as the provided values
var show_direction_a = false;
var color_direction_a = 0xffff00;
var color_direction_a = 0xffff00;Math.asin
var performance_level = 3;//1: VeryLow, 2: Low, 3: Normal, 4: High, 5: VeryHigh, 6: Ultra ...;
//REVERT to 3
var performance_level = 1;//1: VeryLow, 2: Low, 3: Normal, 4: High, 5: VeryHigh, 6: Ultra ...;
getInitialization();//If used in Android, update the init params with the Android configuration
......@@ -205,6 +215,8 @@ This three.js demo is part of a collection at
var miniSphere_seg = 7 * segments_scale;
var torus_seg_r = 4 * segments_scale;
var torus_seg_t = 32 * segments_scale;
var arc_seg_r = 4 * segments_scale;
var arc_seg_t = 32 * segments_scale;
var arrow_segments = 4 * segments_scale;
var momentum_segments = 4 * segments_scale;
var target_segments = 8 * segments_scale;
......@@ -214,7 +226,7 @@ This three.js demo is part of a collection at
var value_attitude = new THREE.Quaternion(0,0,0,1);
var value_sun = new THREE.Vector3(87000000,87000000,87000000); //Km
var value_earth = new THREE.Vector3(36000,12000,5); //Km
var value_earth = new THREE.Vector3(36000,12000,2500); //Km
var value_velocity = new THREE.Vector3(0,0,-15); //Km/s
var value_acceleration = new THREE.Vector3(-5,0,0); //Km/s2
var value_momentum = new THREE.Vector3(-5,0,-5); // direction --> will be normalized
......
......@@ -280,14 +280,6 @@ function init()
//-----------------------------------------------------------------------------------------------------------------------
// REFERENCE PLANES
//-----------------------------------------------------------------------------------------------------------------------
var plane_orb;
var planes_width = sphere_radius-(sphere_radius/5);
var plane_xy_color = 0xFF0000;
var plane_orb_color = 0x00FF00;
var plane_theta_seg = 30;
var plane_phi_seg = 10;
// IMPLEMENT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if(show_planes){
//XY plane
......@@ -301,11 +293,37 @@ function init()
var material_plane_orb = new THREE.MeshPhongMaterial({color: plane_orb_color, transparent: true, depthWrite: false, depthTest: false, alphaTest: 0.1, opacity: 0.2, side: THREE.DoubleSide });
plane_orb = new THREE.Mesh( new THREE.RingGeometry( planes_width, sphere_radius, plane_theta_seg, plane_phi_seg, 0, Math.PI * 2 ), material_plane_orb );
plane_orb.position.set( 0, 0, 0 );
plane_orb.rotation.x += 0.3;
scene.add( plane_orb );
//Compute inclination quaternion
var norm_orbital_plane = value_velocity.clone().normalize().cross(value_earth.clone().normalize());
var norm_rotation_earth = new THREE.Vector3(0,0,1);
var incl_quat = new THREE.Quaternion().setFromUnitVectors( norm_rotation_earth, norm_orbital_plane );
//Rotate orbital plane
plane_orb.quaternion.copy(incl_quat);
plane_orb.matrixWorldNeedsUpdate = true;
plane_orb.updateMatrix();
if(show_inclination){
//Compute instant inclination angle
var inclination = Math.asin(value_earth.z/value_earth.length());
//console.debug(inclination);
//Compute arc angle clip points
//var clip1 = value_earth.clone().normalize().multiplyScalar(sphere_radius);
//var clip2 = value_earth.clone().setZ(0).normalize().multiplyScalar(sphere_radius);
//Draw Arc
mat_arc = new THREE.MeshPhongMaterial( { color: 0xFFFF00, metal: true, transparent: false, opacity: 1.0, side: THREE.BackSide } );
incl_arc = new THREE.Mesh( new THREE.TorusGeometry( arc_radius, arc_tube, arc_seg_r, arc_seg_t, inclination ), mat_arc );
incl_arc.position.set( 0, 0, 0 );
//incl_arc.rotation.y = Math.PI/2;
scene.add( incl_arc );
}
//plane_orb.rotation.x += 0.3;
scene.add( plane_orb );
}
//-----------------------------------------------------------------------------------------------------------------------
......
......@@ -30,8 +30,7 @@ this.staticMoving = false;
this.dynamicDampingFactor = 0.2;
this.minDistance = 0;
//this.maxDistance = Infinity;
this.maxDistance = 2000;//XGGDEBUG: changed to limit zoom
this.maxDistance = Infinity;
this.keys = [ 65 /*A*/, 83 /*S*/, 68 /*D*/ ];
......
......@@ -80,6 +80,47 @@ function update()
}
//}
//-----------------------------------------------------------------------------------------------------------------------
// PLANES UPDATE
//-----------------------------------------------------------------------------------------------------------------------
if(show_planes){
//Compute inclination quaternion
var norm_orbital_plane = value_velocity.clone().normalize().cross(value_earth.clone().normalize());
var norm_rotation_earth = new THREE.Vector3(0,0,1);
var incl_quat = new THREE.Quaternion().setFromUnitVectors( norm_rotation_earth, norm_orbital_plane );
//Rotate orbital plane
plane_orb.quaternion.copy(incl_quat);
plane_orb.matrixWorldNeedsUpdate = true;
plane_orb.updateMatrix();
if(show_inclination){
//Compute instant inclination angle
var inclination = Math.asin(value_earth.z/value_earth.length());
//console.debug(inclination);
//Compute arc angle clip points
//var clip1 = value_earth.clone().normalize().multiplyScalar(sphere_radius);
//var clip2 = value_earth.clone().setZ(0).normalize().multiplyScalar(sphere_radius);
//Draw Arc
//incl_arc.rotation.x = Math.PI/2;
scene.remove(incl_arc);
incl_arc = new THREE.Mesh( new THREE.TorusGeometry( arc_radius, arc_tube, arc_seg_r, arc_seg_t, inclination ), mat_arc );
incl_arc.position.set( 0, 0, 0 );
scene.add(incl_arc);
var incl_offset = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3( -1, 0, 0 ),Math.PI/2);
var axis_z = new THREE.Vector3(1,0,0);
var incl_inst_rot = new THREE.Quaternion().setFromUnitVectors( axis_z, value_earth.clone().normalize() );
incl_arc.quaternion.copy(incl_inst_rot.multiply(incl_offset));
incl_arc.matrixWorldNeedsUpdate = true;
incl_arc.updateMatrix();
}
}
//-----------------------------------------------------------------------------------------------------------------------
// SUN UPDATE
//-----------------------------------------------------------------------------------------------------------------------
if(show_sun){
......
......@@ -175,7 +175,7 @@ public class Installer {
mission.description="GEO mission example";
mission.initial_orbit.a=4.2164E7;
mission.initial_orbit.e=0.0;
mission.initial_orbit.i=0.0;
mission.initial_orbit.i=0.4;
values = new ContentValues();
values.put(MissionEntry.COLUMN_NAME_NAME, mission.name);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment