diff --git a/public/static/img/compass.svg b/public/static/img/compass.svg new file mode 100644 index 0000000..5662d9e --- /dev/null +++ b/public/static/img/compass.svg @@ -0,0 +1,5 @@ + + + + Sorry, your browser does not support inline SVG. + \ No newline at end of file diff --git a/public/static/js/game.js b/public/static/js/game.js index a5ba86c..e8dce36 100644 --- a/public/static/js/game.js +++ b/public/static/js/game.js @@ -387,6 +387,10 @@ document.getElementById('currentRound').innerHTML = String(Game.rounds.length) + '/' + String(Game.NUMBER_OF_ROUNDS); Game.loadPano(Game.panoId, Game.pov); + + // update the compass + const heading = Game.panorama.getPov().heading; + document.getElementById("compass").style.transform = "translateY(-50%) rotate(" + heading + "deg)"; }, handleErrorResponse: function (error) { @@ -863,6 +867,9 @@ Game.panorama.addListener('pov_changed', function () { Game.rewriteGoogleLink(); + + const heading = Game.panorama.getPov().heading; + document.getElementById("compass").style.transform = "translateY(-50%) rotate(" + heading + "deg)"; }); if (COOKIES_CONSENT) { @@ -950,4 +957,8 @@ document.getElementById('returnToStart').onclick = function () { Game.loadPano(Game.panoId, Game.pov); } + + document.getElementById('compassContainer').onclick = function () { + Game.panorama.setPov({ heading: 0, pitch: Game.panorama.getPov().pitch }); + } })(); diff --git a/views/game.php b/views/game.php index e0f7b5d..ad3d107 100644 --- a/views/game.php +++ b/views/game.php @@ -60,6 +60,14 @@