mirror of
https://github.com/ad044/lainTSX.git
synced 2024-10-22 23:19:06 +00:00
semantics and bugfixes
This commit is contained in:
parent
e63772f4a0
commit
4465fbf8ae
43 changed files with 304 additions and 346 deletions
|
@ -4,7 +4,6 @@ import BlueOne from "./GateMiddleObject/BlueOne";
|
|||
import { a, useSpring, useSprings } from "@react-spring/three";
|
||||
import blue_digit_positions from "../../resources/blue_digit_positions.json";
|
||||
import Mirror from "./GateMiddleObject/Mirror";
|
||||
import sleep from "../../utils/sleep";
|
||||
|
||||
type GateMiddleObjectProps = {
|
||||
intro: boolean;
|
||||
|
@ -30,26 +29,22 @@ const GateMiddleObject = (props: GateMiddleObjectProps) => {
|
|||
});
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
set((intIdx) => {
|
||||
const idx = intIdx.toString();
|
||||
return {
|
||||
posX:
|
||||
blue_digit_positions[idx as keyof typeof blue_digit_positions]
|
||||
.final_x,
|
||||
posY:
|
||||
blue_digit_positions[idx as keyof typeof blue_digit_positions]
|
||||
.final_y,
|
||||
delay:
|
||||
blue_digit_positions[idx as keyof typeof blue_digit_positions]
|
||||
.delay,
|
||||
visibility: true,
|
||||
};
|
||||
});
|
||||
set((intIdx) => {
|
||||
const idx = intIdx.toString();
|
||||
return {
|
||||
posX:
|
||||
blue_digit_positions[idx as keyof typeof blue_digit_positions]
|
||||
.final_x,
|
||||
posY:
|
||||
blue_digit_positions[idx as keyof typeof blue_digit_positions]
|
||||
.final_y,
|
||||
delay:
|
||||
blue_digit_positions[idx as keyof typeof blue_digit_positions].delay,
|
||||
visibility: true,
|
||||
};
|
||||
});
|
||||
|
||||
await sleep(1400);
|
||||
setMiddleGroupPos([-0.15, -0.2, -0.1]);
|
||||
})();
|
||||
setTimeout(() => setMiddleGroupPos([-0.15, -0.2, -0.1]), 1400);
|
||||
}, [set]);
|
||||
|
||||
const middleObjectGroupState = useSpring({
|
||||
|
|
|
@ -47,12 +47,10 @@ const BlueOne = (props: BlueOneProps) => {
|
|||
`;
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
await sleep(1400);
|
||||
if (matRef.current) {
|
||||
setTimeout(() => {
|
||||
if (matRef.current)
|
||||
matRef.current.uniforms.brightnessMultiplier.value = 3.5;
|
||||
}
|
||||
})();
|
||||
}, 1400);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
|
|
@ -48,12 +48,11 @@ const BlueZero = (props: BlueZeroProps) => {
|
|||
`;
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
await sleep(1400);
|
||||
setTimeout(() => {
|
||||
if (matRef.current) {
|
||||
matRef.current.uniforms.brightnessMultiplier.value = 3.5;
|
||||
}
|
||||
})();
|
||||
}, 1400);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
|
|
@ -64,21 +64,22 @@ const Images = () => {
|
|||
}, [currentScene, currentSite, idleNodeImages, nodeImages]);
|
||||
|
||||
useEffect(() => {
|
||||
const loadNewImage = (imgIdx: number) => {
|
||||
setImageScaleY(0);
|
||||
|
||||
setTimeout(() => {
|
||||
textureLoader.load(sceneImages[imgIdx].default, setActiveImage);
|
||||
setImageScaleY(3.75);
|
||||
}, 300);
|
||||
};
|
||||
|
||||
(async () => {
|
||||
if (mediaPercentageElapsed === 0 && sceneImages[0]) {
|
||||
textureLoader.load(sceneImages[0].default, setActiveImage);
|
||||
} else if (mediaPercentageElapsed === 35 && sceneImages[1]) {
|
||||
setImageScaleY(0);
|
||||
|
||||
await sleep(300);
|
||||
textureLoader.load(sceneImages[1].default, setActiveImage);
|
||||
setImageScaleY(3.75);
|
||||
loadNewImage(1);
|
||||
} else if (mediaPercentageElapsed === 70 && sceneImages[2]) {
|
||||
setImageScaleY(0);
|
||||
|
||||
await sleep(300);
|
||||
textureLoader.load(sceneImages[2].default, setActiveImage);
|
||||
setImageScaleY(3.75);
|
||||
loadNewImage(2);
|
||||
}
|
||||
})();
|
||||
}, [mediaPercentageElapsed, sceneImages, textureLoader]);
|
||||
|
|
|
@ -113,18 +113,18 @@ const KeyPressHandler = () => {
|
|||
lainIdleCounter.current = now - 2500;
|
||||
}
|
||||
if (now > idleSceneCounter.current + 30000) {
|
||||
(async () => {
|
||||
idleManager(getRandomIdleMedia());
|
||||
playAudio(audio.sound32);
|
||||
await sleep(1200);
|
||||
// put it on lock until the next action, since while the idle media plays, the
|
||||
// Date.now() value keeps increasing, which can result in another idle media playing right after one finishes
|
||||
// one way to work around this would be to modify the value depending on the last played idle media's duration
|
||||
// but i'm way too lazy for that
|
||||
idleSceneCounter.current = -1;
|
||||
|
||||
idleManager(getRandomIdleMedia());
|
||||
playAudio(audio.sound32);
|
||||
|
||||
setTimeout(() => {
|
||||
sceneManager({ event: "play_idle_media" });
|
||||
// put it on lock until the next action, since while the idle media plays, the
|
||||
// Date.now() value keeps increasing, which can result in another idle media playing right after one finishes
|
||||
// one way to work around this would be to modify the value depending on the last played idle media's duration
|
||||
// but i'm way too lazy for that
|
||||
idleSceneCounter.current = -1;
|
||||
})();
|
||||
}, 1200);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -409,12 +409,11 @@ const Lain = (props: LainProps) => {
|
|||
const regularColor = useMemo(() => new THREE.Color(1, 1, 1), []);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (wordSelected) {
|
||||
await sleep(3100);
|
||||
if (wordSelected) {
|
||||
setTimeout(() => {
|
||||
if (lainRef.current) lainRef.current.material.color = glowColor;
|
||||
}
|
||||
})();
|
||||
}, 3100);
|
||||
}
|
||||
}, [glowColor, wordSelected]);
|
||||
|
||||
useFrame(() => {
|
||||
|
|
|
@ -49,72 +49,68 @@ const LevelSelection = () => {
|
|||
const downArrowRef = useRef<THREE.Sprite>();
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const generateGeom = (number: number) => {
|
||||
const geometry = new THREE.PlaneBufferGeometry();
|
||||
const generateGeom = (number: number) => {
|
||||
const geometry = new THREE.PlaneBufferGeometry();
|
||||
|
||||
const uvAttribute = geometry.attributes.uv;
|
||||
const uvAttribute = geometry.attributes.uv;
|
||||
|
||||
for (let i = 0; i < uvAttribute.count; i++) {
|
||||
let u = uvAttribute.getX(i);
|
||||
let v = uvAttribute.getY(i);
|
||||
for (let i = 0; i < uvAttribute.count; i++) {
|
||||
let u = uvAttribute.getX(i);
|
||||
let v = uvAttribute.getY(i);
|
||||
|
||||
u = (u * 22) / 240 + number / 10;
|
||||
u = (u * 22) / 240 + number / 10;
|
||||
|
||||
uvAttribute.setXY(i, u, v);
|
||||
}
|
||||
return geometry;
|
||||
};
|
||||
|
||||
if (subscene === "level_selection") {
|
||||
set({ vertPosY: 0, horizPosX: -0.6 });
|
||||
if (fstNumberRef.current && sndNumberRef.current) {
|
||||
fstNumberRef.current.geometry = generateGeom(
|
||||
parseInt(activeLevel[0])
|
||||
);
|
||||
sndNumberRef.current.geometry = generateGeom(
|
||||
parseInt(activeLevel[1])
|
||||
);
|
||||
}
|
||||
} else if (
|
||||
subscene === "site" &&
|
||||
prevData?.subscene === "level_selection"
|
||||
) {
|
||||
set({ vertPosY: -2.5, horizPosX: -4 });
|
||||
uvAttribute.setXY(i, u, v);
|
||||
}
|
||||
if (selectedLevel !== prevData?.selectedLevel) {
|
||||
if (fstNumberRef.current && sndNumberRef.current) {
|
||||
fstNumberRef.current.geometry = generateGeom(
|
||||
parseInt(selectedLevel[0])
|
||||
);
|
||||
sndNumberRef.current.geometry = generateGeom(
|
||||
parseInt(selectedLevel[1])
|
||||
);
|
||||
return geometry;
|
||||
};
|
||||
|
||||
if (
|
||||
prevData?.selectedLevel &&
|
||||
upArrowRef.current &&
|
||||
downArrowRef.current
|
||||
) {
|
||||
if (selectedLevel > prevData?.selectedLevel) {
|
||||
upArrowRef.current.material.map = upArrowActiveTex;
|
||||
upArrowRef.current.material.needsUpdate = true;
|
||||
if (subscene === "level_selection") {
|
||||
set({ vertPosY: 0, horizPosX: -0.6 });
|
||||
if (fstNumberRef.current && sndNumberRef.current) {
|
||||
fstNumberRef.current.geometry = generateGeom(parseInt(activeLevel[0]));
|
||||
sndNumberRef.current.geometry = generateGeom(parseInt(activeLevel[1]));
|
||||
}
|
||||
} else if (
|
||||
subscene === "site" &&
|
||||
prevData?.subscene === "level_selection"
|
||||
) {
|
||||
set({ vertPosY: -2.5, horizPosX: -4 });
|
||||
}
|
||||
if (selectedLevel !== prevData?.selectedLevel) {
|
||||
if (fstNumberRef.current && sndNumberRef.current) {
|
||||
fstNumberRef.current.geometry = generateGeom(
|
||||
parseInt(selectedLevel[0])
|
||||
);
|
||||
sndNumberRef.current.geometry = generateGeom(
|
||||
parseInt(selectedLevel[1])
|
||||
);
|
||||
|
||||
await sleep(100);
|
||||
if (
|
||||
prevData?.selectedLevel &&
|
||||
upArrowRef.current &&
|
||||
downArrowRef.current
|
||||
) {
|
||||
if (selectedLevel > prevData?.selectedLevel) {
|
||||
upArrowRef.current.material.map = upArrowActiveTex;
|
||||
upArrowRef.current.material.needsUpdate = true;
|
||||
|
||||
setTimeout(() => {
|
||||
upArrowRef.current!.material.map = upArrowTex;
|
||||
upArrowRef.current!.material.needsUpdate = true;
|
||||
} else if (selectedLevel < prevData?.selectedLevel) {
|
||||
downArrowRef.current.material.map = downArrowActiveTex;
|
||||
downArrowRef.current.material.needsUpdate = true;
|
||||
}, 100);
|
||||
} else if (selectedLevel < prevData?.selectedLevel) {
|
||||
downArrowRef.current.material.map = downArrowActiveTex;
|
||||
downArrowRef.current.material.needsUpdate = true;
|
||||
|
||||
await sleep(100);
|
||||
setTimeout(() => {
|
||||
downArrowRef.current!.material.map = downArrowTex;
|
||||
downArrowRef.current!.material.needsUpdate = true;
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
}, [
|
||||
activeLevel,
|
||||
downArrowActiveTex,
|
||||
|
|
|
@ -216,6 +216,8 @@ const MiddleRing = () => {
|
|||
const subscene = useStore((state) => state.mainSubscene);
|
||||
const prevData = usePrevious({ siteRotY, activeLevel, subscene });
|
||||
|
||||
const isAnimatingRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
const rotate = async (rotValues: [number, number]) => {
|
||||
await sleep(2300);
|
||||
|
@ -224,6 +226,8 @@ const MiddleRing = () => {
|
|||
await sleep(1200);
|
||||
setRot({ rotZ: rotValues[1] });
|
||||
|
||||
isAnimatingRef.current = false;
|
||||
|
||||
await sleep(1000);
|
||||
setRot({ rotZ: 0 });
|
||||
};
|
||||
|
@ -256,6 +260,8 @@ const MiddleRing = () => {
|
|||
setRot({ rotX: 0, rotZ: 0 });
|
||||
setRotating(true);
|
||||
|
||||
isAnimatingRef.current = false;
|
||||
|
||||
await sleep(6000);
|
||||
setNoiseAmp(0.03);
|
||||
};
|
||||
|
@ -285,6 +291,8 @@ const MiddleRing = () => {
|
|||
setRot({ rotX: 0, rotZ: 0 });
|
||||
setPos({ posY: -0.11 });
|
||||
|
||||
isAnimatingRef.current = false;
|
||||
|
||||
await sleep(3000);
|
||||
setNoiseAmp(0.03);
|
||||
};
|
||||
|
@ -302,6 +310,7 @@ const MiddleRing = () => {
|
|||
|
||||
await sleep(2700);
|
||||
setFakeRingVisible(false);
|
||||
isAnimatingRef.current = false;
|
||||
};
|
||||
|
||||
const unpause = async () => {
|
||||
|
@ -315,6 +324,7 @@ const MiddleRing = () => {
|
|||
await sleep(250);
|
||||
setRot({ rotZ: 0, rotX: 0 });
|
||||
setPos({ posY: -0.11 });
|
||||
isAnimatingRef.current = false;
|
||||
};
|
||||
|
||||
const afterWordSelection = async () => {
|
||||
|
@ -324,25 +334,39 @@ const MiddleRing = () => {
|
|||
// reset the rotation value to 0
|
||||
await sleep(3100);
|
||||
setRot({ rotZ: 0, rotX: 0 });
|
||||
isAnimatingRef.current = false;
|
||||
};
|
||||
|
||||
if (prevData?.siteRotY !== undefined && prevData?.siteRotY !== siteRotY) {
|
||||
rotate(prevData?.siteRotY > siteRotY ? [-0.07, 0.03] : [0.07, -0.03]);
|
||||
} else if (
|
||||
prevData?.activeLevel !== undefined &&
|
||||
prevData.activeLevel !== activeLevel
|
||||
) {
|
||||
if (prevData?.activeLevel > activeLevel) {
|
||||
moveDown();
|
||||
} else if (prevData?.activeLevel < activeLevel) {
|
||||
moveUp();
|
||||
if (!isAnimatingRef.current) {
|
||||
if (wordSelected) {
|
||||
isAnimatingRef.current = true;
|
||||
afterWordSelection();
|
||||
} else if (
|
||||
prevData?.siteRotY !== undefined &&
|
||||
prevData?.siteRotY !== siteRotY
|
||||
) {
|
||||
isAnimatingRef.current = true;
|
||||
|
||||
rotate(prevData?.siteRotY > siteRotY ? [-0.07, 0.03] : [0.07, -0.03]);
|
||||
} else if (
|
||||
prevData?.activeLevel !== undefined &&
|
||||
prevData.activeLevel !== activeLevel
|
||||
) {
|
||||
isAnimatingRef.current = true;
|
||||
if (prevData?.activeLevel > activeLevel) {
|
||||
moveDown();
|
||||
} else if (prevData?.activeLevel < activeLevel) {
|
||||
moveUp();
|
||||
}
|
||||
} else if (subscene === "pause") {
|
||||
isAnimatingRef.current = true;
|
||||
|
||||
pause();
|
||||
} else if (subscene === "site" && prevData?.subscene === "pause") {
|
||||
isAnimatingRef.current = true;
|
||||
|
||||
unpause();
|
||||
}
|
||||
} else if (subscene === "pause") {
|
||||
pause();
|
||||
} else if (subscene === "site" && prevData?.subscene === "pause") {
|
||||
unpause();
|
||||
} else if (wordSelected) {
|
||||
afterWordSelection();
|
||||
}
|
||||
}, [
|
||||
activeLevel,
|
||||
|
|
|
@ -20,25 +20,26 @@ const ActiveLevelNodes = memo((props: ActiveLevelNodesProps) => {
|
|||
);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (
|
||||
prevData?.activeLevel !== activeLevel &&
|
||||
prevData?.activeLevel !== undefined
|
||||
) {
|
||||
const prevLevel = parseInt(prevData?.activeLevel);
|
||||
const newLevel = parseInt(activeLevel);
|
||||
if (prevLevel - 1 === newLevel || prevLevel + 1 === newLevel) {
|
||||
setVisibleNodes(
|
||||
props.visibleNodes[activeLevel as keyof typeof props.visibleNodes]
|
||||
);
|
||||
} else {
|
||||
await sleep(1500);
|
||||
setVisibleNodes(
|
||||
props.visibleNodes[activeLevel as keyof typeof props.visibleNodes]
|
||||
);
|
||||
}
|
||||
if (
|
||||
prevData?.activeLevel !== activeLevel &&
|
||||
prevData?.activeLevel !== undefined
|
||||
) {
|
||||
const prevLevel = parseInt(prevData?.activeLevel);
|
||||
const newLevel = parseInt(activeLevel);
|
||||
if (prevLevel - 1 === newLevel || prevLevel + 1 === newLevel) {
|
||||
setVisibleNodes(
|
||||
props.visibleNodes[activeLevel as keyof typeof props.visibleNodes]
|
||||
);
|
||||
} else {
|
||||
setTimeout(
|
||||
() =>
|
||||
setVisibleNodes(
|
||||
props.visibleNodes[activeLevel as keyof typeof props.visibleNodes]
|
||||
),
|
||||
1500
|
||||
);
|
||||
}
|
||||
})();
|
||||
}
|
||||
}, [activeLevel, prevData?.activeLevel, props, props.visibleNodes]);
|
||||
|
||||
return (
|
||||
|
|
|
@ -20,25 +20,24 @@ const InactiveLevelNodes = memo((props: ActiveLevelNodesProps) => {
|
|||
);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (
|
||||
prevData?.activeLevel !== activeLevel &&
|
||||
prevData?.activeLevel !== undefined
|
||||
) {
|
||||
const prevLevel = parseInt(prevData?.activeLevel);
|
||||
const newLevel = parseInt(activeLevel);
|
||||
if (prevLevel - 1 === newLevel || prevLevel + 1 === newLevel) {
|
||||
setVisibleNodes(
|
||||
generateInactiveNodes(props.visibleNodes, activeLevel)
|
||||
);
|
||||
} else {
|
||||
await sleep(1500);
|
||||
setVisibleNodes(
|
||||
generateInactiveNodes(props.visibleNodes, activeLevel)
|
||||
);
|
||||
}
|
||||
if (
|
||||
prevData?.activeLevel !== activeLevel &&
|
||||
prevData?.activeLevel !== undefined
|
||||
) {
|
||||
const prevLevel = parseInt(prevData?.activeLevel);
|
||||
const newLevel = parseInt(activeLevel);
|
||||
if (prevLevel - 1 === newLevel || prevLevel + 1 === newLevel) {
|
||||
setVisibleNodes(generateInactiveNodes(props.visibleNodes, activeLevel));
|
||||
} else {
|
||||
setTimeout(
|
||||
() =>
|
||||
setVisibleNodes(
|
||||
generateInactiveNodes(props.visibleNodes, activeLevel)
|
||||
),
|
||||
1500
|
||||
);
|
||||
}
|
||||
})();
|
||||
}
|
||||
}, [activeLevel, prevData?.activeLevel, props.visibleNodes]);
|
||||
|
||||
return (
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||
import ExplosionLine from "./NodeExplosion/ExplosionLine";
|
||||
import node_explosion_line_positions from "../../../../resources/node_explosion_line_positions.json";
|
||||
|
||||
import { useFrame } from "react-three-fiber";
|
||||
import GoldNode from "./NodeExplosion/GoldNode";
|
||||
import { useStore } from "../../../../store";
|
||||
import sleep from "../../../../utils/sleep";
|
||||
|
||||
const NodeExplosion = () => {
|
||||
const explosionVisible = useStore(
|
||||
|
@ -39,18 +37,14 @@ const NodeExplosion = () => {
|
|||
});
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (explosionVisible) {
|
||||
setShouldRotate(true);
|
||||
|
||||
await sleep(1100);
|
||||
setShouldAnimate(true);
|
||||
} else {
|
||||
setShouldAnimate(false);
|
||||
setShouldRotate(false);
|
||||
setCurrentFrame(1);
|
||||
}
|
||||
})();
|
||||
if (explosionVisible) {
|
||||
setShouldRotate(true);
|
||||
setTimeout(() => setShouldAnimate(true), 1100);
|
||||
} else {
|
||||
setShouldAnimate(false);
|
||||
setShouldRotate(false);
|
||||
setCurrentFrame(1);
|
||||
}
|
||||
}, [explosionVisible]);
|
||||
|
||||
return explosionVisible ? (
|
||||
|
|
|
@ -3,7 +3,6 @@ import TriangleNode from "./NodeRip/TriangleNode";
|
|||
import { useStore } from "../../../../store";
|
||||
import RipLine from "./NodeRip/RipLine";
|
||||
import { useFrame } from "react-three-fiber";
|
||||
import sleep from "../../../../utils/sleep";
|
||||
|
||||
const NodeRip = () => {
|
||||
const nodeShrinking = useStore(
|
||||
|
@ -53,15 +52,11 @@ const NodeRip = () => {
|
|||
});
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (nodeShrinking) {
|
||||
await sleep(1150);
|
||||
setShouldAnimate(true);
|
||||
} else {
|
||||
setShouldAnimate(false);
|
||||
setCurrentFrame(1);
|
||||
}
|
||||
})();
|
||||
if (nodeShrinking) setTimeout(() => setShouldAnimate(true), 1150);
|
||||
else {
|
||||
setShouldAnimate(false);
|
||||
setCurrentFrame(1);
|
||||
}
|
||||
}, [nodeShrinking]);
|
||||
|
||||
return (
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import React, { useEffect, useState, memo, useMemo } from "react";
|
||||
import React, { memo, useEffect, useMemo, useState } from "react";
|
||||
import Star from "./Starfield/Star";
|
||||
import sleep from "../../utils/sleep";
|
||||
|
||||
type StarfieldProps = {
|
||||
shouldIntro: boolean;
|
||||
|
@ -43,10 +42,7 @@ const Starfield = memo((props: StarfieldProps) => {
|
|||
const [introVisible, setIntroVisible] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
await sleep(3200);
|
||||
setIntroVisible(false);
|
||||
})();
|
||||
setTimeout(() => setIntroVisible(false), 3200);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
|
|
@ -22,23 +22,18 @@ const MainYellowTextAnimator = (props: { visible?: boolean }) => {
|
|||
}));
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const hud = getNodeHud(activeNode.matrixIndices!);
|
||||
const hud = getNodeHud(activeNode.matrixIndices!);
|
||||
|
||||
if (subscene === "level_selection") {
|
||||
await sleep(400);
|
||||
set({ posX: -0.02, posY: 0.005 });
|
||||
|
||||
await sleep(600);
|
||||
setText("JumpTo".split(""));
|
||||
} else {
|
||||
await sleep(400);
|
||||
set({ posX: hud.big_text[0], posY: hud.big_text[1] });
|
||||
|
||||
await sleep(600);
|
||||
setText(activeNode.node_name.split(""));
|
||||
}
|
||||
})();
|
||||
if (subscene === "level_selection") {
|
||||
setTimeout(() => set({ posX: -0.02, posY: 0.005 }), 400);
|
||||
setTimeout(() => setText("JumpTo".split("")), 1000);
|
||||
} else {
|
||||
setTimeout(
|
||||
() => set({ posX: hud.big_text[0], posY: hud.big_text[1] }),
|
||||
400
|
||||
);
|
||||
setTimeout(() => setText(activeNode.node_name.split("")), 1000);
|
||||
}
|
||||
}, [activeNode, prevData?.subscene, set, subscene]);
|
||||
|
||||
return (
|
||||
|
|
|
@ -24,28 +24,31 @@ const MediaYellowTextAnimator = memo(() => {
|
|||
);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (
|
||||
(activeMediaComponent === "play" || activeMediaComponent === "exit") &&
|
||||
activeMediaComponent !== lastLeftComponent
|
||||
) {
|
||||
setLastLeftComponent(activeMediaComponent);
|
||||
await sleep(400);
|
||||
if (
|
||||
(activeMediaComponent === "play" || activeMediaComponent === "exit") &&
|
||||
activeMediaComponent !== lastLeftComponent
|
||||
) {
|
||||
setLastLeftComponent(activeMediaComponent);
|
||||
|
||||
setTimeout(() => {
|
||||
if (activeMediaComponent === "play") {
|
||||
setPosY(0.05);
|
||||
} else {
|
||||
setPosY(-0.08);
|
||||
}
|
||||
}, 400);
|
||||
|
||||
await sleep(600);
|
||||
setTextArr(
|
||||
(
|
||||
activeMediaComponent.charAt(0).toUpperCase() +
|
||||
activeMediaComponent.slice(1)
|
||||
).split("")
|
||||
);
|
||||
}
|
||||
})();
|
||||
setTimeout(
|
||||
() =>
|
||||
setTextArr(
|
||||
(
|
||||
activeMediaComponent.charAt(0).toUpperCase() +
|
||||
activeMediaComponent.slice(1)
|
||||
).split("")
|
||||
),
|
||||
1000
|
||||
);
|
||||
}
|
||||
}, [activeMediaComponent, lastLeftComponent]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -7,7 +7,6 @@ import { a, useSpring } from "@react-spring/three";
|
|||
import React, { memo, useEffect, useMemo, useState } from "react";
|
||||
import { useStore } from "../../store";
|
||||
import usePrevious from "../../hooks/usePrevious";
|
||||
import sleep from "../../utils/sleep";
|
||||
|
||||
const SiteBigLetter = memo((props: { letter: string; letterIdx: number }) => {
|
||||
const [color, setColor] = useState("yellow");
|
||||
|
@ -97,39 +96,30 @@ const SiteBigLetter = memo((props: { letter: string; letterIdx: number }) => {
|
|||
}));
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (
|
||||
subscene === "pause" ||
|
||||
(subscene === "site" && prevData?.subscene === "not_found") ||
|
||||
(subscene === "site" && prevData?.subscene === "pause")
|
||||
)
|
||||
return;
|
||||
if (scene === "main" && prevData?.scene === "main") {
|
||||
set({ x: 0 });
|
||||
|
||||
if (subscene === "level_selection") setColor("orange");
|
||||
else if (color === "orange") setColor("yellow");
|
||||
|
||||
setTimeout(() => set({ x: props.letterIdx + 0.3 }), 1200);
|
||||
} else if (scene === "media") {
|
||||
if (
|
||||
subscene === "pause" ||
|
||||
(subscene === "site" && prevData?.subscene === "not_found") ||
|
||||
(subscene === "site" && prevData?.subscene === "pause")
|
||||
)
|
||||
return;
|
||||
if (scene === "main" && prevData?.scene === "main") {
|
||||
(activeMediaComponent === "play" || activeMediaComponent === "exit") &&
|
||||
activeMediaComponent !== lastMediaLeftComponent
|
||||
) {
|
||||
setLastMediaLeftComponent(activeMediaComponent);
|
||||
set({ x: 0 });
|
||||
if (subscene === "level_selection") {
|
||||
setColor("orange");
|
||||
} else {
|
||||
if (color === "orange") {
|
||||
setColor("yellow");
|
||||
}
|
||||
}
|
||||
await sleep(1200);
|
||||
|
||||
set({ x: props.letterIdx + 0.3 });
|
||||
} else if (scene === "media") {
|
||||
if (
|
||||
(activeMediaComponent === "play" ||
|
||||
activeMediaComponent === "exit") &&
|
||||
activeMediaComponent !== lastMediaLeftComponent
|
||||
) {
|
||||
setLastMediaLeftComponent(activeMediaComponent);
|
||||
set({ x: 0 });
|
||||
|
||||
await sleep(1200);
|
||||
set({ x: props.letterIdx + 0.3 });
|
||||
}
|
||||
setTimeout(() => set({ x: props.letterIdx + 0.3 }), 1200);
|
||||
}
|
||||
})();
|
||||
}
|
||||
}, [
|
||||
activeNode,
|
||||
props.letterIdx,
|
||||
|
|
|
@ -50,7 +50,7 @@ const bootManager = (eventState: any) => {
|
|||
|
||||
const { action } = { ...dispatchAction(eventState) };
|
||||
|
||||
action && action();
|
||||
if (action) action();
|
||||
};
|
||||
|
||||
export default bootManager;
|
||||
|
|
|
@ -21,7 +21,7 @@ const bootSubsceneManager = (eventState: any) => {
|
|||
|
||||
const { action } = { ...dispatchAction(eventState) };
|
||||
|
||||
action && action();
|
||||
if (action) action();
|
||||
};
|
||||
|
||||
export default bootSubsceneManager;
|
||||
|
|
|
@ -18,7 +18,7 @@ const endManager = (eventState: any) => {
|
|||
|
||||
const { action } = { ...dispatchAction(eventState) };
|
||||
|
||||
action && action();
|
||||
if (action) action();
|
||||
};
|
||||
|
||||
export default endManager;
|
||||
|
|
|
@ -28,7 +28,7 @@ const gameLoader = (eventState: any) => {
|
|||
|
||||
const { action } = { ...dispatchAction(eventState) };
|
||||
|
||||
action && action();
|
||||
if (action) action();
|
||||
};
|
||||
|
||||
export default gameLoader;
|
||||
|
|
|
@ -27,7 +27,7 @@ const gameSaver = (eventState: any) => {
|
|||
|
||||
const { action } = { ...dispatchAction(eventState) };
|
||||
|
||||
action && action();
|
||||
if (action) action();
|
||||
};
|
||||
|
||||
export default gameSaver;
|
||||
|
|
|
@ -17,7 +17,7 @@ const idleManager = (eventState: any) => {
|
|||
|
||||
const { action } = { ...dispatchAction(eventState) };
|
||||
|
||||
action && action();
|
||||
if (action) action();
|
||||
};
|
||||
|
||||
export default idleManager;
|
||||
|
|
|
@ -18,7 +18,7 @@ const levelSelectionManager = (eventState: any) => {
|
|||
};
|
||||
const { action } = { ...dispatchAction(eventState) };
|
||||
|
||||
action && action();
|
||||
if (action) action();
|
||||
};
|
||||
|
||||
export default levelSelectionManager;
|
||||
|
|
|
@ -38,10 +38,11 @@ const mainSubsceneManager = (eventState: any) => {
|
|||
|
||||
const { action, delay } = { ...dispatchAction(eventState) };
|
||||
|
||||
(async () => {
|
||||
delay && (await sleep(delay));
|
||||
action && action();
|
||||
})();
|
||||
if (action)
|
||||
(async () => {
|
||||
if (delay) await sleep(delay);
|
||||
action();
|
||||
})();
|
||||
};
|
||||
|
||||
export default mainSubsceneManager;
|
||||
|
|
|
@ -46,7 +46,7 @@ const pauseManager = (eventState: any) => {
|
|||
};
|
||||
const { action } = { ...dispatchAction(eventState) };
|
||||
|
||||
action && action();
|
||||
if (action) action();
|
||||
};
|
||||
|
||||
export default pauseManager;
|
||||
|
|
|
@ -59,12 +59,10 @@ const lainManager = (eventState: any) => {
|
|||
|
||||
const { action, duration } = { ...dispatchAction(eventState) };
|
||||
|
||||
(async () => {
|
||||
action && action();
|
||||
|
||||
duration && (await sleep(duration));
|
||||
setLainMoveState("standing");
|
||||
})();
|
||||
if (action) {
|
||||
action();
|
||||
setTimeout(() => setLainMoveState("standing"), duration);
|
||||
}
|
||||
};
|
||||
|
||||
export default lainManager;
|
||||
|
|
|
@ -24,7 +24,7 @@ const levelManager = (eventState: any) => {
|
|||
|
||||
const { action } = { ...dispatchAction(eventState) };
|
||||
|
||||
action && action();
|
||||
if (action) action();
|
||||
};
|
||||
|
||||
export default levelManager;
|
||||
|
|
|
@ -183,8 +183,8 @@ const nodeManager = (eventState: any) => {
|
|||
const { action, delay } = { ...dispatchAction(eventState) };
|
||||
|
||||
(async () => {
|
||||
delay && (await sleep(delay));
|
||||
action && action();
|
||||
if (delay) await sleep(delay);
|
||||
if (action) action();
|
||||
})();
|
||||
};
|
||||
|
||||
|
|
|
@ -41,10 +41,11 @@ const siteManager = (eventState: any) => {
|
|||
|
||||
const { action, delay } = { ...dispatchAction(eventState) };
|
||||
|
||||
(async () => {
|
||||
delay && (await sleep(delay));
|
||||
action && action();
|
||||
})();
|
||||
if (action)
|
||||
(async () => {
|
||||
if (delay) await sleep(delay);
|
||||
action();
|
||||
})();
|
||||
};
|
||||
|
||||
export default siteManager;
|
||||
|
|
|
@ -74,7 +74,7 @@ const mediaManager = (eventState: any) => {
|
|||
|
||||
const { action } = { ...dispatchAction(eventState) };
|
||||
|
||||
action && action();
|
||||
if (action) action();
|
||||
};
|
||||
|
||||
export default mediaManager;
|
||||
|
|
|
@ -91,10 +91,11 @@ const progressManager = (eventState: any) => {
|
|||
|
||||
const { action, delay } = { ...dispatchAction(eventState) };
|
||||
|
||||
(async () => {
|
||||
delay && (await sleep(delay));
|
||||
action && action();
|
||||
})();
|
||||
if (action)
|
||||
(async () => {
|
||||
if (delay) await sleep(delay);
|
||||
action();
|
||||
})();
|
||||
};
|
||||
|
||||
export default progressManager;
|
||||
|
|
|
@ -38,7 +38,7 @@ const promptManager = (eventState: any) => {
|
|||
|
||||
const { action } = { ...dispatchAction(eventState) };
|
||||
|
||||
action && action()
|
||||
if (action) action();
|
||||
};
|
||||
|
||||
export default promptManager;
|
||||
|
|
|
@ -93,11 +93,11 @@ const sceneManager = (eventState: any) => {
|
|||
|
||||
const { action, delay } = { ...dispatchAction(eventState) };
|
||||
|
||||
(async () => {
|
||||
delay && (await sleep(delay));
|
||||
|
||||
action && action();
|
||||
})();
|
||||
if (action)
|
||||
(async () => {
|
||||
if (delay) await sleep(delay);
|
||||
action();
|
||||
})();
|
||||
};
|
||||
|
||||
export default sceneManager;
|
||||
|
|
|
@ -173,7 +173,7 @@ const soundManager = (eventState: any) => {
|
|||
|
||||
const { action } = { ...dispatchAction(eventState) };
|
||||
|
||||
action && action();
|
||||
if (action) action();
|
||||
};
|
||||
|
||||
export default soundManager;
|
||||
|
|
|
@ -25,7 +25,7 @@ const ssknManager = (eventState: any) => {
|
|||
|
||||
const { action } = { ...dispatchAction(eventState) };
|
||||
|
||||
action && action();
|
||||
if (action) action();
|
||||
};
|
||||
|
||||
export default ssknManager;
|
||||
|
|
|
@ -5,7 +5,6 @@ import BootMainMenuComponents from "../components/BootScene/BootMainMenuComponen
|
|||
import { useStore } from "../store";
|
||||
import BootAuthorizeUser from "../components/BootScene/BootAuthorizeUser";
|
||||
import BootLoadData from "../components/BootScene/BootLoadData";
|
||||
import sleep from "../utils/sleep";
|
||||
|
||||
const BootScene = () => {
|
||||
const activeSubscene = useStore((state) => state.bootSubscene);
|
||||
|
@ -14,13 +13,8 @@ const BootScene = () => {
|
|||
const [mainMenuVisible, setMainMenuVisible] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
await sleep(2000);
|
||||
setAccelaVisible(false);
|
||||
|
||||
await sleep(4200);
|
||||
setMainMenuVisible(true);
|
||||
})();
|
||||
setTimeout(() => setAccelaVisible(false), 2000);
|
||||
setTimeout(() => setMainMenuVisible(true), 6200);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
|
|
@ -1,29 +1,25 @@
|
|||
import React, { useEffect } from "react";
|
||||
import { useStore } from "../store";
|
||||
import sleep from "../utils/sleep";
|
||||
|
||||
const ChangeDiscScene = () => {
|
||||
const setScene = useStore((state) => state.setScene);
|
||||
const currentSite = useStore((state) => state.activeSite);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (currentSite === "a") {
|
||||
document.getElementsByTagName("canvas")[0].className =
|
||||
"change-disc-scene-a-background";
|
||||
} else if (currentSite === "b") {
|
||||
document.getElementsByTagName("canvas")[0].className =
|
||||
"change-disc-scene-b-background";
|
||||
}
|
||||
if (currentSite === "a") {
|
||||
document.getElementsByTagName("canvas")[0].className =
|
||||
"change-disc-scene-a-background";
|
||||
} else if (currentSite === "b") {
|
||||
document.getElementsByTagName("canvas")[0].className =
|
||||
"change-disc-scene-b-background";
|
||||
}
|
||||
|
||||
await sleep(3500);
|
||||
setScene("main");
|
||||
setTimeout(() => setScene("main"), 3500);
|
||||
|
||||
return () => {
|
||||
document.getElementsByTagName("canvas")[0].className =
|
||||
"main-scene-background";
|
||||
};
|
||||
})();
|
||||
return () => {
|
||||
document.getElementsByTagName("canvas")[0].className =
|
||||
"main-scene-background";
|
||||
};
|
||||
}, [currentSite, setScene]);
|
||||
|
||||
return <></>;
|
||||
|
|
|
@ -108,7 +108,6 @@ const EndScene = () => {
|
|||
const trackElement = document.getElementById("track") as HTMLTrackElement;
|
||||
|
||||
if (mediaElement) {
|
||||
setAudioAnalyser(createAudioAnalyser());
|
||||
mediaElement.currentTime = 0;
|
||||
|
||||
trackElement.src = endrollVtt;
|
||||
|
|
|
@ -4,18 +4,13 @@ import { OrbitControls } from "@react-three/drei";
|
|||
import GateHUD from "../components/GateScene/GateHUD";
|
||||
import GateMiddleObject from "../components/GateScene/GateMiddleObject";
|
||||
import { useStore } from "../store";
|
||||
import sleep from "../utils/sleep";
|
||||
|
||||
const GateScene = () => {
|
||||
const gateLvl = useStore((state) => state.gateLvl);
|
||||
const [introAnim, setIntroAnim] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
await sleep(2500);
|
||||
|
||||
setIntroAnim(false);
|
||||
})();
|
||||
setTimeout(() => setIntroAnim(false), 2500);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
|
|
@ -28,23 +28,17 @@ const MainScene = () => {
|
|||
const setWordSelected = useStore((state) => state.setWordSelected);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (subscene === "pause") {
|
||||
await sleep(3400);
|
||||
setPaused(true);
|
||||
} else {
|
||||
setPaused(false);
|
||||
}
|
||||
})();
|
||||
if (subscene === "pause") {
|
||||
setTimeout(() => setPaused(true), 3400);
|
||||
} else {
|
||||
setPaused(false);
|
||||
}
|
||||
}, [subscene]);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (wordSelected) {
|
||||
await sleep(3100);
|
||||
setWordSelected(false);
|
||||
}
|
||||
})();
|
||||
if (wordSelected) {
|
||||
setTimeout(() => setWordSelected(false), 3100);
|
||||
}
|
||||
}, [setWordSelected, wordSelected]);
|
||||
|
||||
const introWrapperRef = useRef<THREE.Group>();
|
||||
|
|
|
@ -28,10 +28,9 @@ const MediaScene = () => {
|
|||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (percentageElapsed === 100) {
|
||||
if (percentageElapsed === 100 && activeNode.triggers_final_video)
|
||||
setScene("end");
|
||||
}
|
||||
}, [percentageElapsed, setScene]);
|
||||
}, [activeNode.triggers_final_video, percentageElapsed, setScene]);
|
||||
|
||||
useEffect(() => {
|
||||
const mediaElement = document.getElementById("media") as HTMLMediaElement;
|
||||
|
|
|
@ -16,20 +16,15 @@ const TaKScene = () => {
|
|||
const percentageElapsed = useStore((state) => state.mediaPercentageElapsed);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (percentageElapsed === 100) {
|
||||
setIsOutro(true);
|
||||
if (percentageElapsed === 100) {
|
||||
setIsOutro(true);
|
||||
|
||||
await sleep(4600);
|
||||
setScene("main");
|
||||
}
|
||||
})();
|
||||
setTimeout(() => setScene("main"), 4600);
|
||||
}
|
||||
}, [percentageElapsed, setScene]);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
await sleep(3800);
|
||||
|
||||
setTimeout(() => {
|
||||
const mediaElement = document.getElementById("media") as HTMLMediaElement;
|
||||
const trackElement = document.getElementById("track") as HTMLTrackElement;
|
||||
|
||||
|
@ -58,7 +53,7 @@ const TaKScene = () => {
|
|||
}
|
||||
setIsIntro(false);
|
||||
}
|
||||
})();
|
||||
}, 3800);
|
||||
}, [nodeMedia, nodeName, setAudioAnalyser]);
|
||||
|
||||
return <LainSpeak intro={isIntro} outro={isOutro} />;
|
||||
|
|
|
@ -126,7 +126,7 @@ export const useStore = create(
|
|||
combine(
|
||||
{
|
||||
// scene data
|
||||
currentScene: "boot",
|
||||
currentScene: "main",
|
||||
|
||||
// game progress
|
||||
gameProgress: game_progress,
|
||||
|
|
Loading…
Reference in a new issue