Skip to content

Reset button puts you back at the Sun #75

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

Open
wants to merge 3 commits into
base: main
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
17 changes: 14 additions & 3 deletions src/PlanetParade.vue
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,16 @@
:maxSpeed="10000"
show-text
@reset="() => {
selectedTime = Date.now();
const altTime = getTimeforSunAlt(2).setting;
if (altTime) {
selectedTime = altTime;
nextTick(() => {
resetCamera(new Date(altTime));
});
} else {
// reasonable fallback
selectedTime = Date.now();
}
wwtStats.timeResetCount += 1;
}"
@update:reverse="(_reverse: boolean) => {
Expand Down Expand Up @@ -1091,8 +1100,10 @@ async function updateUserData() {
});
}

async function resetCamera(): Promise<void> {
const time = store.currentTime;
async function resetCamera(time?: Date): Promise<void> {
if (time === undefined) {
time = store.currentTime;
}

const latRad = selectedLocation.value.latitudeDeg * D2R;
const lonRad = selectedLocation.value.longitudeDeg * D2R;
Expand Down
40 changes: 20 additions & 20 deletions src/components/SpeedControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,27 +154,7 @@
:show-tooltip="!mobile"
></icon-button>



<icon-button
id="reset"
:fa-icon="'rotate'"
@activate="
() => {
playbackRate = 100;
timePlaying = false;
forceRate = false;
emit('reset');
}
"
:color="color"
:focus-color="color"
tooltip-text="Reset"
tooltip-location="top"
tooltip-offset="5px"
faSize="1x"
:show-tooltip="!mobile"
></icon-button>

<v-dialog
v-if="!useInline"
Expand Down Expand Up @@ -279,6 +259,26 @@
"
/>
</div>

<icon-button
id="reset"
:fa-icon="'home'"
@activate="
() => {
playbackRate = 100;
timePlaying = false;
forceRate = false;
emit('reset');
}
"
:color="color"
:focus-color="color"
tooltip-text="Reset"
tooltip-location="top"
tooltip-offset="5px"
faSize="1x"
:show-tooltip="!mobile"
></icon-button>
</div>

<div v-if="showText" id="speed-text">{{ Math.round(playbackRate) }}x {{ timePlaying ? '' : '(Paused)' }}</div>
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
faAnglesUp,
faAnglesDown,
faRotate,
faHouse,
} from "@fortawesome/free-solid-svg-icons";

library.add(faBookOpen);
Expand All @@ -59,6 +60,7 @@ library.add(faAnglesRight);
library.add(faAnglesUp);
library.add(faAnglesDown);
library.add(faRotate);
library.add(faHouse);

/** v-hide directive taken from https://www.ryansouthgate.com/2020/01/30/vue-js-v-hide-element-whilst-keeping-occupied-space/ */
// Extract the function out, up here, so I'm not writing it twice
Expand Down