import streamlit as st import os, base64, shutil, random from pathlib import Path @st.cache_data def load_aframe_and_extras(): return """ """ def create_environment(scene): sky = scene.entity( geometry="primitive: sphere; radius: 5000", material="color: #ADD8E6; shader: flat; side: back" # Light blue sky ) ground = scene.entity( geometry="primitive: plane; width: 100; height: 100", material="color: #7CFC00; side: double", # Lawn green ground rotation="-90 0 0" ) return sky, ground def create_drag_target(scene, x, y, z, color='blue'): target = scene.entity( geometry=f"primitive: box; width: 1; height: 1; depth: 1", material=f"color: {color}", position=f"{x} {y} {z}", draggable="" ) return target def main(): st.title("Interactive A-Frame Scene") html_string = f""" A-Frame Example {load_aframe_and_extras()} """ st.components.v1.html(html_string, height=600, scrolling=False) with st.sidebar: st.header("Scene Controls") num_targets = st.slider("Number of Drag Targets", min_value=1, max_value=10, value=3) scene = st.components.v1 # This won't work as expected for direct A-Frame manipulation environment = scene.get("environment") # This also won't work drag_targets = scene.get("drag-targets") # And this won't work if environment is not None: create_environment(environment) # This will likely cause errors if drag_targets is not None: for i in range(num_targets): x = random.uniform(-5, 5) y = 1 z = random.uniform(-5, -2) create_drag_target(drag_targets, x, y, z) # Potential error here too if __name__ == "__main__": main()