Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close issue #19 #75

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ hr.top-bottom-divider {
#webgl-controls {
position: absolute;
right: 0;
width: 325px;
width: 380px;
height: 23px;
background-color: #ccc;
color: #000;
Expand Down
66 changes: 51 additions & 15 deletions static/js/3d/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
, locked_object_size = -1
, locked_object_color = -1

var full_name_temp = null
// David Bowie special case.
// Note: If you're updating a featured case here, make sure you update in the
// full3d.html tempalte too.
Expand Down Expand Up @@ -392,16 +393,27 @@
setAttributeNeedsUpdateFlags();
}

// camera locking fns
function clearLock(set_default_camera) {
if (!locked_object) return;
// camera locking and releasing fns

function resetView(set_default_camera, clear_lock) {
locked_object = null;

// setDefaultCameraPosition();
if (set_default_camera) {
setDefaultCameraPosition();
}

cameraControls.target = new THREE.Vector3(0,0,0);

if (clear_lock){
dropLock()
}

// reset camera pos
setNeutralCameraPosition();
}

function dropLock(){
// restore color and size
attributes.value_color.value[locked_object_idx] = locked_object_color;
attributes.size.value[locked_object_idx] = locked_object_size;
Expand All @@ -417,10 +429,12 @@
locked_object_idx = -1;
locked_object_size = -1;
locked_object_color = null;
}

// reset camera pos so subsequent locks don't get into crazy positions
setNeutralCameraPosition();
} // end clearLock
function clearLock(set_default_camera) {
if (!locked_object) return;
resetView(set_default_camera, true);
}

function setLock(full_name) {
if (locked_object) {
Expand Down Expand Up @@ -721,6 +735,16 @@
return THREE.ImageUtils.loadTexture(path);
}

function resetColors(blacken) {

if (blacken) {
$('#objects-of-interest tr').css('background-color', '#000');
}

$('#sun-selector').css('background-color', '#0DDD3B'); // 00D32F
$('#reset-selector').css('background-color', '#365A3E');
}

/** Public functions **/

me.clearRankings = function() {
Expand All @@ -739,11 +763,16 @@
}
};

me.resetView = function(clear_lock) {
return resetView(true, clear_lock);
};

me.clearLock = function() {
return clearLock(true);
};

me.setLock = function(full_name) {
dropLock();
return setLock(full_name);
};

Expand Down Expand Up @@ -826,29 +855,35 @@
$('#objects-of-interest tr:gt(2)').remove();
setTimeout(function() {
setLock('342843 Davidbowie');
$('#sun-selector').css('background-color', 'black');
$('#earth-selector').css('background-color', 'green');
resetColors()
}, 0);

} else {
$('#objects-of-interest tr:gt(1)').remove();
}
else {
$('#objects-of-interest tr:gt(2)').remove();
}
$('#objects-of-interest').append(featured_html).on('click', 'tr', function() {
$('#objects-of-interest tr').css('background-color', '#000');
var $e = $(this);
var full_name = $e.data('full-name');
$('#sun-selector').css('background-color', 'green');
resetColors()
switch (full_name) {
// special case full names

case 'reset':
resetView(true, true);
resetColors(true);
return false;

case 'sun':
clearLock(true);
resetView(true, false);
return false;
}
clearLock();

resetColors(true)
resetView(false, true);

// set new lock
$e.css('background-color', 'green');
$('#sun-selector').css('background-color', '#000');
setLock(full_name);

return false;
Expand Down Expand Up @@ -879,3 +914,4 @@
object_movement_on = true;
};
}

22 changes: 21 additions & 1 deletion static/js/main/controllers/asterank_3d.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function Asterank3DCtrl($scope, pubsub) {
$scope.running = true;
var selected_object = null
var initial_object = null

$scope.Init = function() {
asterank3d = new Asterank3D({
Expand All @@ -19,14 +21,23 @@ function Asterank3DCtrl($scope, pubsub) {
$ls.height($ls.height() + 250);
},
top_object_color: 0xffffff
// top_object_color: 0xdda0dd
});
}

$scope.ResetView = function() {
if (selected_object) {
pubsub.publish('DeselectAsteroid', [selected_object]);
}
asterank3d.resetView(true);
}

$scope.SunView = function() {
asterank3d.clearLock();
asterank3d.resetView(false);
}

$scope.EarthView = function() {
pubsub.publish('DeselectAsteroid', [selected_object]);
asterank3d.setLock('earth');
}

Expand All @@ -44,6 +55,15 @@ function Asterank3DCtrl($scope, pubsub) {
window.location.href="http://asterank.com/3d";
}

pubsub.subscribe('AsteroidDetailsClick', function(asteroid) {
if (selected_object == asteroid) {
selected_object = null;
}
else {
selected_object = asteroid;
}
});

pubsub.subscribe('Lock3DView', function(asteroid) {
if (asterank3d.isWebGLSupported()) {
asterank3d.setLock(asteroid.full_name);
Expand Down
6 changes: 6 additions & 0 deletions static/js/main/controllers/asteroid_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ function AsteroidTableCtrl($scope, $http, pubsub) {

} // end UpdateRankings

// Reset asteroid selection in table and hide asteroid details
pubsub.subscribe('DeselectAsteroid', function(obj) {
$scope.selected = null;
pubsub.publish('AsteroidDetailsClick', [obj]);
});

$scope.AsteroidClick = function(obj) {
if (obj === $scope.selected) {
// deselect
Expand Down
1 change: 1 addition & 0 deletions templates/blocks/webgl.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div class="" ng-controller="Asterank3DCtrl" ng-init="Init()">
<div id="webgl-controls">
<ul>
<li><span ng-click="ResetView()"><i class="icon-refresh"></i> Reset</span></li>
<li><span ng-click="SunView()"><i class="icon-star-empty"></i> Sun</span></li>
<li><span ng-click="EarthView()"><i class="icon-home"></i> Earth</span></li>
<li ng-show="running"><span ng-click="Pause()"><i class="icon-pause"></i> Pause</span></li>
Expand Down
10 changes: 7 additions & 3 deletions templates/full3d.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@
<div id="objects-of-interest-container" style="text-align:center;display:none;opacity:.7;">
<span>Significant objects<br>&amp; estimated value</span>
<table id="objects-of-interest">
<tr id="sun-selector" data-full-name="sun" style="background-color:green;">
<td colspan="2"><a href="#">Sun</a> (default view)</td>
<tr id="reset-selector" data-full-name="reset" style="background-color:#365A3E; font-weight: bold">
<td colspan="2"><a href="#">Reset</a> (default view)</td>
</tr>
<tr id="earth-selector" data-full-name="earth">
<tr id="sun-selector" data-full-name="sun" style="background-color:#0DDD3B; font-weight: bold">
<td colspan="2"><a href="#">Sun</a></td>
</tr>
<tr id="earth-selector" data-full-name="earth"> <!-- style="background-color:lightseagreen;" -->

<td colspan="2"><a href="#">Earth</a></td>
</tr>
<tr id="342843-Davidbowie-selector" data-full-name="342843 Davidbowie">
Expand Down