awacke1 commited on
Commit
6a4d0e7
·
1 Parent(s): 3d8d416

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -0
app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NVidiaRaytraceMirrorAframeThreeJS
2
+
3
+ import streamlit as st
4
+ import random
5
+
6
+ # Import A-Frame and Three.js
7
+ from streamlit.components.v1 import ComponentBase
8
+ from streamlit.components.v1.iframe import IFrame
9
+ import streamlit.components.v1 as components
10
+
11
+ AFRAME_URL = "https://aframe.io/releases/1.2.0/aframe.min.js"
12
+ THREEJS_URL = "https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"
13
+
14
+ class AframeThreeJS(ComponentBase):
15
+ def __init__(self, html):
16
+ self.html = html
17
+ super().__init__(self)
18
+
19
+ def _get_frontend_deps(self):
20
+ return {
21
+ "js": [AFRAME_URL, THREEJS_URL],
22
+ }
23
+
24
+ def _get_html(self):
25
+ return self.html
26
+
27
+ def main():
28
+ st.set_page_config(page_title="NVidia Raytrace Mirror - A-Frame and Three.js", page_icon="🔥")
29
+
30
+ # Replace this with your HTML content generated from the query
31
+ html_content = f"""
32
+ <html>
33
+ <head>
34
+ <script src="{AFRAME_URL}"></script>
35
+ <script src="{THREEJS_URL}"></script>
36
+ </head>
37
+ <body>
38
+ <a-scene>
39
+ <a-assets>
40
+ <img id="sky" src="https://cdn.aframe.io/examples/boilerplate/sky.jpg">
41
+ </a-assets>
42
+
43
+ <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9" shadow></a-box>
44
+ <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E" shadow></a-sphere>
45
+ <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D" shadow></a-cylinder>
46
+ <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4" shadow></a-plane>
47
+ <a-sky src="#sky"></a-sky>
48
+ </a-scene>
49
+ </body>
50
+ </html>
51
+ """
52
+
53
+ # Render the A-Frame and Three.js scene
54
+ #components
55
+ aframe_threejs = AframeThreeJS(html_content)
56
+ st.markdown(aframe_threejs, unsafe_allow_html=True)
57
+
58
+
59
+ if name == "main":
60
+ main()
61
+