diff --git a/static/css/main.css b/static/css/main.css index fab4030..851773f 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -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; diff --git a/static/js/3d/main.js b/static/js/3d/main.js index ede63a7..33fb537 100644 --- a/static/js/3d/main.js +++ b/static/js/3d/main.js @@ -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. @@ -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; @@ -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) { @@ -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() { @@ -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); }; @@ -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; @@ -879,3 +914,4 @@ object_movement_on = true; }; } + diff --git a/static/js/main/controllers/asterank_3d.js b/static/js/main/controllers/asterank_3d.js index af1263d..ff32ed6 100644 --- a/static/js/main/controllers/asterank_3d.js +++ b/static/js/main/controllers/asterank_3d.js @@ -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({ @@ -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'); } @@ -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); diff --git a/static/js/main/controllers/asteroid_table.js b/static/js/main/controllers/asteroid_table.js index 1066a9d..f5ccb7b 100644 --- a/static/js/main/controllers/asteroid_table.js +++ b/static/js/main/controllers/asteroid_table.js @@ -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 diff --git a/templates/blocks/webgl.html b/templates/blocks/webgl.html index f3f7227..8a13ed8 100644 --- a/templates/blocks/webgl.html +++ b/templates/blocks/webgl.html @@ -1,6 +1,7 @@