fixed typing/glow bug

This commit is contained in:
ad044 2020-09-23 15:07:34 +04:00
parent ca1358548d
commit 00d3829e30
2 changed files with 65 additions and 23 deletions

View file

@ -19,8 +19,8 @@ import level_y_values from "../../resources/level_y_values.json";
type BlueOrbContructorProps = {
sprite: string;
position: [number, number, number];
rotation: [number, number, number, (string | undefined)?];
position: number[];
rotation: number[];
active: boolean;
level: string;
};
@ -39,12 +39,13 @@ const BlueOrb = memo((props: BlueOrbContructorProps) => {
// so we import all of them here and then use this function to
// associate a sprite with the path
const spriteToPath = (sprite: string) => {
console.log(sprite);
if (sprite.startsWith("S")) {
if (sprite.includes("S")) {
return [SSkn, SSKnActive];
} else if (sprite.startsWith("P") || sprite.startsWith("G")) {
return [MULTI, MULTIActive];
} else if (sprite.includes("?")) {
} else if (
sprite.startsWith("P") ||
sprite.startsWith("G") ||
sprite.includes("?")
) {
return [MULTI, MULTIActive];
} else if (sprite.includes("Dc")) {
return [Dc, DcActive];
@ -117,9 +118,9 @@ const BlueOrb = memo((props: BlueOrbContructorProps) => {
return (
<group position={[0, (level_y_values as LevelYValues)[props.level], 0]}>
<mesh
position={props.position}
position={props.position as [number, number, number]}
scale={[0.25, 0.15, 0.25]}
rotation={props.rotation}
rotation={props.rotation as [number, number, number]}
renderOrder={1}
>
<planeBufferGeometry attach="geometry" />

View file

@ -7,6 +7,48 @@ import { currentBlueOrbAtom } from "./BlueOrb/CurrentBlueOrbAtom";
import Level from "./Level";
import level_y_values from "../resources/level_y_values.json";
type ImageTableIndices = {
1: string;
2: string;
3: string;
};
type ProtocolLines = {
1: string;
2: string;
3: string;
4: string;
};
type Words = {
1: string;
2: string;
3: string;
};
type BlueOrbData = {
"SLPS_016_0x offset": string;
image_table_indices: ImageTableIndices;
is_hidden: string;
media_file: string;
node_name: string;
protocol_lines: ProtocolLines;
site: string;
type: string;
unlocked_by: string;
upgrade_requirement: string;
words: Words;
};
type BlueOrbPositionData = {
position: number[];
rotation: number[];
};
type BlueOrbPositions = {
[orbPos: string]: BlueOrbPositionData;
};
const Site = memo(() => {
const currentBlueOrb = useRecoilValue(currentBlueOrbAtom);
@ -14,29 +56,28 @@ const Site = memo(() => {
<>
<Suspense fallback={<>loading...</>}>
{/* distance between LEVELS is 1.5 */}
{Object.values(level_y_values).map((yVal) => {
return <Level levelPosY={yVal} />;
return <Level levelPosY={yVal} key={yVal} />;
})}
{Object.entries(site_a).map((blueOrb) => {
if ((blueOrb as any)[1]["unlocked_by"] === "-1")
{Object.entries(site_a).map((blueOrb: [string, BlueOrbData]) => {
if (blueOrb[1]["unlocked_by"] === "-1")
return (
<BlueOrb
sprite={(blueOrb as any)[1]["node_name"]}
sprite={blueOrb[1]["node_name"]}
position={
(blue_orb_positions as any)[(blueOrb as any)[0].substr(2)][
"position"
]
(blue_orb_positions as BlueOrbPositions)[
blueOrb[0].substr(2)
]["position"]
}
rotation={
(blue_orb_positions as any)[(blueOrb as any)[0].substr(2)][
"rotation"
]
(blue_orb_positions as BlueOrbPositions)[
blueOrb[0].substr(2)
]["rotation"]
}
key={(blueOrb as any)[1]["node_name"]}
active={(blueOrb as any)[1] === currentBlueOrb}
level={(blueOrb as any)[0].substr(0, 2)}
key={blueOrb[1]["node_name"]}
active={blueOrb[0] === currentBlueOrb}
level={blueOrb[0].substr(0, 2)}
/>
);
})}