feat(intro): play home intro once in the intro screen instead of having weird boolean in app store

This commit is contained in:
2026-01-14 11:59:13 +01:00
parent a044d87977
commit fd06c031d4
8 changed files with 23 additions and 33 deletions

View File

@@ -1,16 +1,8 @@
<script setup lang="ts">
const { onRender } = useScreen();
const app = useAppStore();
const store = useHomeStore();
const { assets } = useAssets();
onRender((ctx) => {
ctx.fillStyle = "#fbfbfb"
ctx.fillRect(0, 0, LOGICAL_WIDTH, LOGICAL_HEIGHT);
ctx.globalAlpha = store.isIntro && !app.homeIntroPlayed ? store.intro.stage1Opacity : 1;
assets.images.home.bottomScreen.background.draw(ctx, 0, 0);
});

View File

@@ -1,15 +1,8 @@
<script setup lang="ts">
const { onRender } = useScreen();
const app = useAppStore();
const store = useHomeStore();
const { assets } = useAssets();
onRender((ctx) => {
ctx.fillStyle = "#fbfbfb"
ctx.fillRect(0, 0, LOGICAL_WIDTH, LOGICAL_HEIGHT);
ctx.globalAlpha = store.isIntro && !app.homeIntroPlayed ? store.intro.stage1Opacity : 1;
assets.images.home.topScreen.background.draw(ctx, 0, 0);
});

View File

@@ -1,7 +1,6 @@
<script setup lang="ts">
import gsap from "gsap";
const app = useAppStore();
const store = useIntroStore();
const { onRender, onClick } = useScreen();
const { assets } = useAssets();
@@ -36,7 +35,9 @@ onRender((ctx) => {
ctx.font = "12px NDS12 Bold";
ctx.letterSpacing = "1px";
const { actualBoundingBoxRight: width } = ctx.measureText($t("intro.copyright"));
const { actualBoundingBoxRight: width } = ctx.measureText(
$t("intro.copyright"),
);
const logoWidth = assets.images.intro.warning.rect.width;
const logoX = Math.floor(LOGICAL_WIDTH / 2 - (width + logoWidth + 3) / 2);
@@ -65,13 +66,10 @@ onRender((ctx) => {
: store.isOutro
? store.outro.textOpacity
: hintTextOpacity.value;
fillTextHCentered(
ctx,
$t("intro.hint"),
0,
HINT_Y,
LOGICAL_WIDTH,
);
fillTextHCentered(ctx, $t("intro.hint"), 0, HINT_Y, LOGICAL_WIDTH);
ctx.globalAlpha = store.isOutro ? store.outro.backgroundOpacity : 0;
assets.images.home.topScreen.background.draw(ctx, 0, 0);
});
onClick(() => {

View File

@@ -27,6 +27,9 @@ onRender((ctx) => {
const frame = assets.images.intro.logoAnimated[frameKey];
frame.draw(ctx, 0, 0);
ctx.globalAlpha = store.isOutro ? store.outro.backgroundOpacity : 0;
assets.images.home.topScreen.background.draw(ctx, 0, 0);
});
</script>

View File

@@ -70,7 +70,8 @@ useKeyUp((key) => {
<div :style="{ visibility: ENABLE_3D ? 'hidden' : 'visible' }">
<div>
<Screen ref="topScreen">
<HomeTopScreen v-if="app.screen === 'home'" />
<IntroTopScreen v-if="!app.booted" />
<HomeTopScreen v-else-if="app.screen === 'home'" />
<ContactTopScreen v-else-if="app.screen === 'contact'" />
<ProjectsTopScreen v-else-if="app.screen === 'projects'" />
<SettingsTopScreen v-else-if="app.screen === 'settings'" />
@@ -79,7 +80,8 @@ useKeyUp((key) => {
</div>
<div>
<Screen ref="bottomScreen">
<HomeBottomScreen v-if="app.screen === 'home'" />
<IntroBottomScreen v-if="!app.booted" />
<HomeBottomScreen v-else-if="app.screen === 'home'" />
<ContactBottomScreen v-else-if="app.screen === 'contact'" />
<ProjectsBottomScreen v-else-if="app.screen === 'projects'" />
<SettingsBottomScreen v-else-if="app.screen === 'settings'" />

View File

@@ -28,8 +28,6 @@ export const useAppStore = defineStore("app", {
return {
booted: false,
// shitty but who cares
homeIntroPlayed: false,
settings,
screen: "home" as AppScreen,
camera: null as THREE.Camera | null,

View File

@@ -25,9 +25,6 @@ export const useHomeStore = defineStore("home", {
const timeline = gsap.timeline({
onComplete: () => {
this.isIntro = false;
const app = useAppStore();
app.homeIntroPlayed = true;
},
});
@@ -40,7 +37,7 @@ export const useHomeStore = defineStore("home", {
duration: 0.5,
ease: "none",
},
0.5,
0,
)
.fromTo(
this.intro,
@@ -50,7 +47,7 @@ export const useHomeStore = defineStore("home", {
duration: 0.15,
ease: "none",
},
0.85,
0.35,
);
},

View File

@@ -9,6 +9,7 @@ export const useIntroStore = defineStore("intro", {
outro: {
textOpacity: 1,
backgroundOpacity: 0,
},
isIntro: true,
@@ -59,6 +60,12 @@ export const useIntroStore = defineStore("intro", {
duration: 0.25,
ease: "none",
})
.to(this.outro, {
backgroundOpacity: 1,
duration: 0.5,
delay: 0.5,
ease: "none",
})
.call(() => {
const app = useAppStore();
app.booted = true;