awacke1 commited on
Commit
aaac327
1 Parent(s): f217a67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -19
app.py CHANGED
@@ -9,14 +9,14 @@ if "entities" not in st.session_state:
9
  st.session_state.entities = []
10
 
11
  # Function to get random 3D model file
12
- def get_random_3d_model(model_type):
13
- model_dir = f"models/{model_type}"
14
  model_files = [f for f in os.listdir(model_dir) if f.endswith(('.glb', '.obj'))]
15
  return os.path.join(model_dir, random.choice(model_files)) if model_files else None
16
 
17
  # Function to add a new entity to the scene
18
  def add_entity(entity_type):
19
- model_path = get_random_3d_model(entity_type)
20
  if model_path:
21
  new_entity = {
22
  'type': entity_type,
@@ -59,9 +59,8 @@ html_template = '''
59
  <body>
60
  <a-scene>
61
  <a-assets>
62
- <a-asset-item id="room" src="{room_model}"></a-asset-item>
63
- <a-asset-item id="player" src="{player_model}"></a-asset-item>
64
- <a-asset-item id="creature" src="{creature_model}"></a-asset-item>
65
  </a-assets>
66
 
67
  <a-sky color="#ECECEC"></a-sky>
@@ -82,14 +81,11 @@ def main():
82
  # Sidebar
83
  st.sidebar.title("Chofko's Ecosystem Controls")
84
 
85
- if st.sidebar.button("🏠 Add Room"):
86
- add_entity("room")
87
 
88
- if st.sidebar.button("🧍 Add Player"):
89
- add_entity("player")
90
-
91
- if st.sidebar.button("🐾 Add Creature"):
92
- add_entity("creature")
93
 
94
  if st.sidebar.button("🗑️ Clear All Entities"):
95
  st.session_state.entities = []
@@ -98,16 +94,14 @@ def main():
98
  st.sidebar.json(st.session_state.entities)
99
 
100
  # Main area - HTML5 canvas
101
- room_model = get_random_3d_model("room") or ""
102
- player_model = get_random_3d_model("player") or ""
103
- creature_model = get_random_3d_model("creature") or ""
104
 
105
  entities_html = generate_aframe_entities()
106
 
107
  html_content = html_template.format(
108
- room_model=room_model,
109
- player_model=player_model,
110
- creature_model=creature_model,
111
  entities=entities_html
112
  )
113
 
 
9
  st.session_state.entities = []
10
 
11
  # Function to get random 3D model file
12
+ def get_random_3d_model():
13
+ model_dir = "models"
14
  model_files = [f for f in os.listdir(model_dir) if f.endswith(('.glb', '.obj'))]
15
  return os.path.join(model_dir, random.choice(model_files)) if model_files else None
16
 
17
  # Function to add a new entity to the scene
18
  def add_entity(entity_type):
19
+ model_path = get_random_3d_model()
20
  if model_path:
21
  new_entity = {
22
  'type': entity_type,
 
59
  <body>
60
  <a-scene>
61
  <a-assets>
62
+ <a-asset-item id="skybike" src="{skybike_model}"></a-asset-item>
63
+ <a-asset-item id="heart" src="{heart_model}"></a-asset-item>
 
64
  </a-assets>
65
 
66
  <a-sky color="#ECECEC"></a-sky>
 
81
  # Sidebar
82
  st.sidebar.title("Chofko's Ecosystem Controls")
83
 
84
+ if st.sidebar.button("🚲 Add SkyBike"):
85
+ add_entity("skybike")
86
 
87
+ if st.sidebar.button("❤️ Add Heart"):
88
+ add_entity("heart")
 
 
 
89
 
90
  if st.sidebar.button("🗑️ Clear All Entities"):
91
  st.session_state.entities = []
 
94
  st.sidebar.json(st.session_state.entities)
95
 
96
  # Main area - HTML5 canvas
97
+ skybike_model = "models/SkyBike.glb"
98
+ heart_model = "models/Heart.obj"
 
99
 
100
  entities_html = generate_aframe_entities()
101
 
102
  html_content = html_template.format(
103
+ skybike_model=skybike_model,
104
+ heart_model=heart_model,
 
105
  entities=entities_html
106
  )
107