import streamlit as st import streamlit.components.v1 as components st.set_page_config(page_title="L-Grammar 3D Assembly Game", layout="wide") st.title("L-Grammar 3D Assembly Game") st.write("An interactive 3D game using L-Grammar to assemble primitive components") # Create a custom HTML component to embed Three.js html_code = """ L-Grammar 3D Assemblies

L-Grammar Controls

Parts: 0

Complexity: 0

""" # Display the Three.js application in an iframe components.html(html_code, height=800) st.sidebar.title("Game Instructions") st.sidebar.write(""" ## L-Grammar 3D Assembly Game This game uses L-system grammars to procedurally generate 3D assemblies of parts. ### How it works: 1. The system starts with a simple axiom and applies transformation rules iteratively 2. The resulting string of characters defines the 3D structure 3. Parts are created and connected based on these rules ### Controls: - **Left-click + drag**: Rotate the view - **Right-click + drag**: Pan the view - **Mouse wheel**: Zoom in/out - **Generate New Assembly**: Creates a new random structure - **Reset View**: Returns to the default camera position ### L-Grammar Commands: - F: Move forward and create a part - +/-: Rotate left/right - [: Push current state onto stack (branch) - ]: Pop state from stack (end branch) Have fun exploring the procedurally generated 3D structures! """) st.sidebar.markdown("---") st.sidebar.write("Made with Three.js and Streamlit")