Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,4 +49,47 @@ if uploaded_file is not None:
|
|
| 49 |
|
| 50 |
for fn in functions:
|
| 51 |
elements.append(f"""
|
| 52 |
-
<a-box
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
for fn in functions:
|
| 51 |
elements.append(f"""
|
| 52 |
+
<a-box position="{x_pos} 1 -3" color="#FFC65D" depth="0.5" height="0.5" width="2"></a-box>
|
| 53 |
+
<a-text value="Function: {fn}" position="{x_pos} 1.7 -3" align="center" color="black"></a-text>
|
| 54 |
+
""")
|
| 55 |
+
x_pos += 3
|
| 56 |
+
|
| 57 |
+
for cls in classes:
|
| 58 |
+
elements.append(f"""
|
| 59 |
+
<a-box position="{x_pos} 1 -3" color="#F16775" depth="0.5" height="0.5" width="2"></a-box>
|
| 60 |
+
<a-text value="Class: {cls}" position="{x_pos} 1.7 -3" align="center" color="black"></a-text>
|
| 61 |
+
""")
|
| 62 |
+
x_pos += 3
|
| 63 |
+
|
| 64 |
+
html = f"""
|
| 65 |
+
<!DOCTYPE html>
|
| 66 |
+
<html>
|
| 67 |
+
<head>
|
| 68 |
+
<script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script>
|
| 69 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 70 |
+
</head>
|
| 71 |
+
<body>
|
| 72 |
+
<a-scene background="color: #ECECEC">
|
| 73 |
+
<a-entity position="0 1.6 3">
|
| 74 |
+
<a-camera wasd-controls-enabled="true" look-controls-enabled="true"></a-camera>
|
| 75 |
+
</a-entity>
|
| 76 |
+
<a-light type="ambient" color="#FFF"></a-light>
|
| 77 |
+
<a-plane rotation="-90 0 0" width="30" height="30" color="#7BC8A4"></a-plane>
|
| 78 |
+
{''.join(elements)}
|
| 79 |
+
</a-scene>
|
| 80 |
+
</body>
|
| 81 |
+
</html>
|
| 82 |
+
"""
|
| 83 |
+
return html
|
| 84 |
+
|
| 85 |
+
# Generate and encode A-Frame scene as base64
|
| 86 |
+
aframe_html = generate_aframe_html(functions, classes)
|
| 87 |
+
encoded_html = base64.b64encode(aframe_html.encode()).decode()
|
| 88 |
+
data_url = f"data:text/html;base64,{encoded_html}"
|
| 89 |
+
|
| 90 |
+
st.subheader("🌐 AR/VR Visualization")
|
| 91 |
+
st.info("Below is an interactive 3D visualization of your code structure (functions & classes).")
|
| 92 |
+
components.iframe(data_url, height=500, scrolling=True)
|
| 93 |
+
|
| 94 |
+
else:
|
| 95 |
+
st.info("Please upload a Python file to get started.")
|