Skip to content

Commit eeb3a07

Browse files
authored
Package Cleanup, Z-Index fixes, Tool Switch Overlay (#170)
* remove node-fetch, pin @react-three/xr * settle down, z-index * settle down, z-index * remove body type css * add overlay for tool switching, add camera icon, add z index 0 to main container * small css fixes * don't allow tab for tool switch when paused
1 parent 0607f9e commit eeb3a07

File tree

14 files changed

+312
-86
lines changed

14 files changed

+312
-86
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@
6161
"@react-three/cannon": "6.4.0",
6262
"@react-three/drei": "9.65.3",
6363
"@react-three/fiber": "8.12.0",
64-
"@react-three/xr": "^5.4.1",
64+
"@react-three/xr": "5.4.1",
6565
"culori": "^0.18.2",
6666
"nipplejs": "0.8.1",
67-
"node-fetch": "^2.6.1",
6867
"peerjs": "^1.4.6",
6968
"react-device-detect": "^1.13.1",
7069
"react-error-boundary": "^3.1.4",

src/ideas/modifiers/Tool/index.tsx

+10-8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ToolPreload from "./components/ToolPreload";
1111
type ToolProps = {
1212
children: ReactNode;
1313
name: string;
14+
icon?: string;
1415
pos?: [number, number];
1516
face?: boolean;
1617
pinY?: boolean;
@@ -34,6 +35,7 @@ export function Tool(props: ToolProps) {
3435
const {
3536
children,
3637
name,
38+
icon,
3739
pos = [0, 0],
3840
face = true,
3941
pinY = false,
@@ -44,8 +46,8 @@ export function Tool(props: ToolProps) {
4446
onSwitch,
4547
} = props;
4648

47-
const toolbelt = useToolbelt();
48-
const ENABLED = toolbelt.activeTool?.name === name;
49+
const { grant, revoke, activeTool, hudScene } = useToolbelt();
50+
const ENABLED = activeTool?.name === name;
4951
const DISTANCE = 1;
5052

5153
const [preloadDone, setPreloadDone] = useState(false);
@@ -58,13 +60,13 @@ export function Tool(props: ToolProps) {
5860
const visible = useVisible(prog);
5961

6062
useEffect(() => {
61-
toolbelt.grant(name, orderIndex);
62-
return () => toolbelt.revoke(name);
63-
}, [name, toolbelt.grant, toolbelt.revoke, orderIndex]);
63+
grant(name, icon, orderIndex);
64+
return () => revoke(name);
65+
}, [name, icon, grant, revoke, orderIndex]);
6466

6567
useEffect(() => {
66-
if (onSwitch) onSwitch(toolbelt.activeTool?.name === name);
67-
}, [toolbelt.activeTool, onSwitch, name]);
68+
if (onSwitch) onSwitch(activeTool?.name === name);
69+
}, [activeTool, onSwitch, name]);
6870

6971
if (!preloadDone) {
7072
return (
@@ -97,7 +99,7 @@ export function Tool(props: ToolProps) {
9799
</OnScreen>
98100
</HUD>
99101
</group>,
100-
toolbelt.hudScene
102+
hudScene
101103
)}
102104
</>
103105
);

src/layers/Environment/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function Environment(props: EnvironmentLayerProps) {
4242
<>
4343
<GlobalStyles />
4444
<MuteOnHide />
45-
<Container ref={state.containerRef}>
45+
<Container id="__spacesvr" ref={state.containerRef}>
4646
<EnvironmentContext.Provider value={state}>
4747
{loadingScreen || <LoadingScreen />}
4848
{pauseMenu || <PauseMenu dev={dev} title={name} />}

src/layers/Environment/ui/Container.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const Container = styled.div`
55
width: 100%;
66
height: 100%;
77
overflow: hidden;
8+
z-index: 0;
89
910
canvas {
1011
position: absolute;

src/layers/Environment/ui/GlobalStyles.tsx

+1-10
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ const globalStyles = css`
2121
overflow: hidden;
2222
touch-action: none;
2323
-webkit-overflow-scrolling: touch;
24-
font-family: "Quicksand", sans-serif;
25-
font-size: 27px;
26-
@media screen and (max-width: 500px) {
27-
font-size: 24px;
28-
}
2924
}
3025
`;
3126

@@ -40,9 +35,5 @@ export default function GlobalStyles() {
4035
};
4136
}, []);
4237

43-
return (
44-
<>
45-
<Global styles={globalStyles} />
46-
</>
47-
);
38+
return <Global styles={globalStyles} />;
4839
}

src/layers/Environment/ui/LoadingScreen/index.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const Container = styled.div<{ finished: boolean }>`
3535
position: absolute;
3636
top: 0;
3737
left: 0;
38-
z-index: 200;
38+
z-index: 11;
3939
background: white;
4040
transition: opacity 0.75s ease-in;
4141
transition-delay: 0.5s;
@@ -45,6 +45,11 @@ const Container = styled.div<{ finished: boolean }>`
4545
justify-content: center;
4646
align-items: center;
4747
flex-direction: column;
48+
font-family: "Quicksand", sans-serif;
49+
font-size: 27px;
50+
@media screen and (max-width: 500px) {
51+
font-size: 24px;
52+
}
4853
`;
4954

5055
const Text = styled.div`

src/layers/Environment/ui/PauseMenu/components/components.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const Container = styled.div<{ paused: boolean; dev?: boolean }>`
66
position: absolute;
77
top: 0;
88
left: 0;
9-
z-index: 100;
9+
z-index: 10;
1010
transition: opacity 0.25s ease;
1111
background: rgba(0, 0, 0, ${(props) => (props.dev ? 0 : 0.25)});
1212
display: flex;
@@ -16,6 +16,10 @@ export const Container = styled.div<{ paused: boolean; dev?: boolean }>`
1616
opacity: ${(props) => (props.paused ? 1 : 0)};
1717
pointer-events: ${(props) => (props.paused ? "all" : "none")};
1818
font-family: "Quicksand", sans-serif;
19+
font-size: 27px;
20+
@media screen and (max-width: 500px) {
21+
font-size: 24px;
22+
}
1923
`;
2024

2125
export const ClickContainer = styled.div`

src/layers/Network/logic/signallers/MuseSignaller.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import nodeFetch, { Response } from "node-fetch";
21
import { Peer } from "peerjs";
32
import { Signaller, SignallerConfig } from "./";
43

@@ -36,7 +35,7 @@ export class MuseSignaller implements Signaller {
3635
}
3736

3837
async callBackend<T = any>(path: string, body: any): Promise<Response> {
39-
return await nodeFetch(`${this.host}/sessions/${path}`, {
38+
return await fetch(`${this.host}/sessions/${path}`, {
4039
method: "POST",
4140
body: JSON.stringify(body),
4241
headers: { "Content-Type": "application/json" },

0 commit comments

Comments
 (0)