From fb5a063276f18e3238b13577358e811aa5f9ee31 Mon Sep 17 00:00:00 2001
From: Silas Bartha <silas@exvacuum.dev>
Date: Tue, 11 Feb 2025 19:28:40 -0500
Subject: functionality implemented

---
 src/App.jsx | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

(limited to 'src/App.jsx')

diff --git a/src/App.jsx b/src/App.jsx
index 81436a8..fb72f6e 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -6,8 +6,10 @@ import Ground from './components/ground';
 import React, { Suspense, useContext, useEffect, useRef, useState } from 'react';
 import { Physics } from '@react-three/rapier';
 import Sun from './components/sun';
-import { Fog } from 'three';
 import * as everforest from './_everforest.module.scss'
+import { Bloom, EffectComposer, GodRays, LensFlare, Noise, Vignette } from '@react-three/postprocessing';
+import { AdditiveBlending } from 'three';
+import { useGLTF } from '@react-three/drei';
 
 export const AppContext = React.createContext(null);
 
@@ -21,6 +23,7 @@ function App() {
     const keys = useRef([]);
     const keysPressed = useRef([]);
     const [messages, setMessages] = useState();
+    const apiToken = useRef();
     const playerKeyDown = (event) => {
         if (!keys.current.includes(event.code)) {
             keysPressed.current.push(event.code);
@@ -39,23 +42,36 @@ function App() {
         };
     }, []);
     useEffect(() => {
+        const token = window.localStorage.getItem("token");
+        if (token == null) {
+            fetch('/api/gen_token').then((res) => res.json()).then((data) => {
+                window.localStorage.setItem("token", data.token);
+                apiToken.current = data.token;
+            });
+        } else {
+            console.log("setting token");
+            apiToken.current = token;
+        }
         fetch('/api/message').then((res) => res.json()).then((data) => {
             console.log(data);
             setMessages(data);
         });
-    }, []);
+    },[]);
+    useGLTF.preload('../assets/terrain.glb');
+    useGLTF.preload('../assets/message-bubble.glb');
     return (
         <>
             <div className='dot' />
             <p className='unselectable hint'>
-                E - read<br/>
-                LMB - write
+                E - read<br />
+                LMB - write<br />
+                X - delete
             </p>
-            <AppContext.Provider value={{ keys: keys, keysPressed: keysPressed, messages: messages, setMessages: setMessages }}>
+            <AppContext.Provider value={{ apiToken: apiToken, keys: keys, keysPressed: keysPressed, messages: messages, setMessages: setMessages }}>
                 <Canvas shadows>
                     <KeyPressedClearer />
                     <Suspense>
-                        <fog color={everforest.bg0} attach="fog" far={500}/>
+                        <fog color={everforest.bg0} attach="fog" far={500} />
                         <Sun />
                         <Notes />
                         <Physics timeStep={1 / 60}>
-- 
cgit v1.2.3

