from x3d import x3d
x3d.py package loaded, have fun with X3D Graphics!
class Scene(x3d.Scene):
js_source = 'https://www.x3dom.org/download/x3dom.js'
css_source = 'https://www.x3dom.org/download/x3dom.css'
dimension_px = (600, 400)
def _repr_html_(self):
return(f"""
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<script type='text/javascript' src='{self.js_source}'> </script>
<link rel='stylesheet' type='text/css' href='{self.css_source}'></link>
</head>
<body>
<x3d width='{self.dimension_px[0]}px' height='{self.dimension_px[1]}px'>
{self.XML()}
</x3d>
</body>
</html>
""")
myscene = Scene(children=[
x3d.Shape(appearance=x3d.Appearance(material=x3d.Material(diffuseColor=(.5, .2, .7))),
geometry=x3d.Box())
]
)
print(myscene.XML())
<Scene> <Shape> <Appearance> <Material diffuseColor='0.5 0.2 0.7'/> </Appearance> <Box/> </Shape> </Scene>
myscene