From 604ff41008dda3a7deac71f67ed6622eb7eaca53 Mon Sep 17 00:00:00 2001 From: ad044 Date: Fri, 12 Mar 2021 16:17:36 +0400 Subject: [PATCH] bugfixes --- src/components/MainScene/Lain.tsx | 23 +++++++++++++++++-- src/components/MainScene/LevelSelection.tsx | 4 ++++ src/components/MainScene/Popups/About.tsx | 4 ++-- src/components/MainScene/Site/Node.tsx | 4 +++- src/components/MediaPlayer.tsx | 19 ++++++++------- .../TextRenderer/MainYellowTextAnimator.tsx | 12 +++++++--- src/core/eventTemplates.ts | 16 ++++++++++++- .../input-handlers/handleMainSceneInput.ts | 2 +- src/store.ts | 2 ++ src/types/types.ts | 1 + 10 files changed, 69 insertions(+), 18 deletions(-) diff --git a/src/components/MainScene/Lain.tsx b/src/components/MainScene/Lain.tsx index c21f7ec..b7ff65a 100644 --- a/src/components/MainScene/Lain.tsx +++ b/src/components/MainScene/Lain.tsx @@ -33,6 +33,7 @@ import lookAroundSpriteSheet from "../../static/sprites/lain/look_around.png"; import playWithHairSpriteSheet from "../../static/sprites/lain/play_with_hair.png"; import { useStore } from "../../store"; +import usePrevious from "../../hooks/usePrevious"; type LainConstructorProps = { sprite: string; @@ -416,11 +417,29 @@ const Lain = (props: LainProps) => { }, [glowColor, wordSelected]); useFrame(() => { - if (lainRef.current) { + if (lainRef.current) lainRef.current.material.color.lerp(regularColor, 0.07); - } }); + const subscene = useStore((state) => state.mainSubscene); + const prevData = usePrevious({ subscene }); + + useEffect(() => { + if (subscene === "pause") { + setTimeout(() => { + if (lainRef.current) { + lainRef.current.material.depthTest = false; + lainRef.current.renderOrder = 2; + } + }, 3400); + } else if (prevData?.subscene === "pause" && subscene === "site") { + if (lainRef.current) { + lainRef.current.material.depthTest = true; + lainRef.current.renderOrder = 0; + } + } + }, [prevData?.subscene, subscene]); + return ( diff --git a/src/components/MainScene/LevelSelection.tsx b/src/components/MainScene/LevelSelection.tsx index 7deb89e..db91e50 100644 --- a/src/components/MainScene/LevelSelection.tsx +++ b/src/components/MainScene/LevelSelection.tsx @@ -47,6 +47,8 @@ const LevelSelection = () => { const upArrowRef = useRef(); const downArrowRef = useRef(); + const upperLimit = useStore((state) => (state.activeSite === "a" ? 22 : 13)); + useEffect(() => { const generateGeom = (number: number) => { const geometry = new THREE.PlaneBufferGeometry(); @@ -173,6 +175,7 @@ const LevelSelection = () => { scale={[0.3, 0.15, 0]} position={[1.1, -0.35, 0]} renderOrder={4} + visible={parseInt(selectedLevel) !== 1} ref={downArrowRef} > { diff --git a/src/components/MainScene/Popups/About.tsx b/src/components/MainScene/Popups/About.tsx index 479ce15..42ba88a 100644 --- a/src/components/MainScene/Popups/About.tsx +++ b/src/components/MainScene/Popups/About.tsx @@ -14,7 +14,7 @@ const About = () => { useFrame(() => { if (bgRef.current) { - bgRef.current.position.y += 0.03; + bgRef.current.position.y += 0.01; if (Math.round(bgRef.current.position.y) === 14) { setShowingAbout(false); } @@ -50,7 +50,7 @@ const About = () => { { } }, [props.nodeName]); + const paused = useStore((state) => state.mainSubscene === "pause"); + const materialRef = useRef(); const nonActiveTexture = useLoader( @@ -172,7 +174,7 @@ const Node = memo((props: NodeContructorProps) => { 0, ]} > - {props.active ? ( + {props.active && !paused ? ( { ) { setPercentageElapsed(percentageElapsed); lastSetPercentageRef.current = percentageElapsed; + + if (subtitleRef.current) { + if (percentageElapsed === 0) { + subtitleRef.current.style.visibility = "visible"; + } else if (percentageElapsed === 100) { + subtitleRef.current.style.visibility = "hidden"; + } + } } } - }, [setPercentageElapsed, videoRef]); + }, [setPercentageElapsed, videoRef, subtitleRef]); useEffect(() => { (requestRef.current as any) = requestAnimationFrame(updateTime); @@ -59,13 +67,8 @@ const MediaPlayer = () => { return ( <> -