File size: 2,221 Bytes
e7b6ed2
d917c9b
5ca5f01
e7b6ed2
 
 
c60184e
e7b6ed2
 
 
d917c9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
title: 🧜‍♀️Streamlit🧠CV📚Scroller
emoji: 🧜‍♀️📚🧜‍♂️
colorFrom: gray
colorTo: pink
sdk: streamlit
sdk_version: 1.44.1
app_file: app.py
pinned: false
license: mit
short_description: 🧠CV Scroller🧜‍♀️🧜‍♂️🧜3D Graphs
---
- 🐍 **Python Startup**  
  - 📂 `load_plot_metadata()` → scan `saved_worlds/` for `plot_X…_Z…csv` (cached)  
  - 📑 `load_plot_objects()` → read CSV → build `ALL_INITIAL_OBJECTS`  
  - 🔒 `get_game_state()` → singleton `GameState` → load/hold `world_state.csv`  
  - 🚀 Inject → `ALL_INITIAL_OBJECTS`, `PLOTS_METADATA`, `GAME_STATE` into `index.html`

- 💾 **Save Flow**  
  - 🖱️ User clicks “💾 Save” → JS `getSaveDataAndPosition()` → returns JSON payload  
  - 🔄 Py parses → computes `plot_X…_Z….csv``save_plot_data()` writes per‑plot file  
  -`game_state.update_state()` merges into `world_state.csv`  
  - 🔁 `load_plot_metadata.clear()` + `st.rerun()` → refreshed state

- 🌐 **Three.js Init**  
  - 🌟 `init()` → scene, camera, lights  
  - 🛤️ `setupInitialGround()` → one plane per saved plot (or at 0,0)  
  - 👤 `setupPlayer()` → capsule mesh at center  
  - 📦 `loadInitialObjects()` → instantiate all persisted objects

- 🎮 **Interaction & Local State**  
  - 🖱️ `onDocumentClick()` → raycast → spawn `House/Tree/Rock…` → add to `newlyPlacedObjects`  
  - 💾 `saveUnsavedState()` → persist `newlyPlacedObjects` to `sessionStorage`  
  - 🔄 `restoreUnsavedState()` on reload → rehydrate unsaved objects  
  - 🗑️ `resetNewlyPlacedObjects()` → clear sessionStorage

-**Game Loop**  
  - 🔑 `onKeyDown`/`onKeyUp` → track WASD/Arrows  
  - 🚶 `updatePlayerMovement()` → camera‑relative walk + `checkAndExpandGround()`  
  - 🌱 `checkAndExpandGround()` → add placeholder planes around player  
  - 📽️ `animate()` → movement, camera lerp, `renderer.render()`

- 🔄 **Collab Sync**  
  - ⏲️ `setInterval(pollGameState, 5000)` → logs or applies updated `window.GAME_STATE`**All set!** This ultra‑condensed outline (with emojis 🎉) covers your end‑to‑end state protocol.