import streamlit as st
import os, base64, shutil, random
from pathlib import Path
@st.cache_data
def load_aframe_and_extras():
return """
"""
# ... (previous helper functions remain the same)
def main():
st.set_page_config(layout="wide")
with st.sidebar:
st.markdown("### đ¤ 3D AI Using Claude 3.5 Sonnet for AI Pair Programming")
st.markdown("[Open 3D Animation Toolkit](https://huggingface.co/spaces/awacke1/3d_animation_toolkit)", unsafe_allow_html=True)
st.markdown("### âŦī¸ Upload")
uploaded_files = st.file_uploader("Add files:", accept_multiple_files=True, key="file_uploader")
st.markdown("### đŽ Camera Controls")
col1, col2, col3 = st.columns(3)
with col1:
st.button("âŦ
ī¸", on_click=lambda: st.session_state.update({'camera_move': 'left'}))
st.button("đâē", on_click=lambda: st.session_state.update({'camera_move': 'rotateLeft'}))
st.button("đ", on_click=lambda: st.session_state.update({'camera_move': 'reset'}))
with col2:
st.button("âŦī¸", on_click=lambda: st.session_state.update({'camera_move': 'up'}))
st.button("đ", on_click=lambda: st.session_state.update({'camera_move': 'ground'}))
st.button("đĢ", on_click=lambda: st.session_state.update({'camera_move': 'fire'}))
with col3:
st.button("âĄī¸", on_click=lambda: st.session_state.update({'camera_move': 'right'}))
st.button("âŦī¸", on_click=lambda: st.session_state.update({'camera_move': 'down'}))
st.button("âŠ", on_click=lambda: st.session_state.update({'camera_move': 'forward'}))
st.markdown("### đēī¸ Grid Size")
grid_width = st.slider("Grid Width", 1, 8, 8)
grid_height = st.slider("Grid Height", 1, 5, 5)
st.markdown("### âšī¸ Instructions")
st.write("- W: Camera up\n- S: Move forward\n- X: Camera down\n- Q/E: Rotate camera left/right\n- Z: Reset camera to top view\n- C: Move camera to ground level\n- Spacebar: Fire raycast\n- Click and drag to move objects\n- Mouse wheel to zoom\n- Right-click and drag to rotate view")
st.markdown("### đ Directory")
directory = st.text_input("Enter path:", ".", key="directory_input")
# ... (rest of the main function remains mostly the same)
aframe_scene = f"""
"""
assets, entities = generate_tilemap(files, directory, grid_width, grid_height, max_unique_models=5)
aframe_scene += assets + entities + ""
camera_move = st.session_state.get('camera_move', None)
if camera_move:
if camera_move == 'fire':
aframe_scene += ""
else:
aframe_scene += f""
st.session_state.pop('camera_move')
st.components.v1.html(load_aframe_and_extras() + aframe_scene, height=600)
if __name__ == "__main__":
main()