I am currently building a solution for text-commands to a 3dmodel.stl. It is a way out, what i have here is super beta.....I use python to run flask and subprocess to run a script. viewer.py runs solidstl.py with visualization by Open3d. Open3d is to broadcast the part.stl with
so I have begun however cannot finish yet...
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import os
import subprocess
from subprocess import Popen, PIPE, STDOUT
from flask import Flask, Response, request, render_template, redirect, url_for
app = Flask(__name__, static_folder='fishvid')
app.url_map.strict_slashes = False
@app.route('/stl')
def out():
def output():
yield """<html><head>
<title>three.js webgl - STL</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<style>
body {background: #1339de;}
div#container {background: black; width: 50%;margin: 100px auto;color: white;border-radius: 1em;width: 1400px;height: 1125px;overflow:hidden; overflow-x:hidden;-webkit-resize:vertical;-moz-resize:v>
iframe#embed {width:1400px;height:1200px;margin-left:0px;margin-top:0px;overflow:hidden;-webkit-resize:none;-moz-resize:none;resize:none;}
body {margin: 0;}
</style>
<body style='color:MediumSeaGreen;'><h1><div id='data' style='text-align: center;'>nothing received yet...for </div></h1><script>var div = document.getElementById('data');</script><script type='text/javasc>
setInterval(refreshIframe, 12000);</script><section><div id="container"><iframe id="embed" scrolling="no" src="
http://lftr.biz:8087"></iframe></div></section>
</body></html>"""
p = subprocess.Popen('sudo python3 /var/www/cgi-bin/solidstl3.py', shell=True, stdout=subprocess.PIPE, stderr=STDOUT)
while True:
out = ((p.stdout.readline()).strip())
out = str(out)
if out != "b''":
print (out)
yield """<html><body><h1><script>div.innerHTML = "OUTPUT: """+out+""" "</script></h1></body></html>"""
else:
yield """<html><body></body></html>"""
return Response(output())
if __name__ == "__main__":
app.run(host='0.0.0.0', debug=True, ssl_context=('/var/security/lftr.biz.crt', '/var/security/lftr.biz.key'), port=8086)
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
from solid2 import *
from jupyterscad import view
import open3d as o3d
import os
print ('imports:done')
ip ='127.0.0.1'
port = '8087'
os.environ['EGL_PLATFORM'] = 'surfaceless'
os.environ['OPEN3D_CPU_RENDERING'] = 'true'
os.environ['LIBGL_ALWAYS_SOFTWARE'] = 'true'
os.environ['WEBRTC_IP'] = ip
os.environ['WEBRTC_PORT'] = port
os.environ['WEBRTC_STUN_SERVER'] = 'stun:
stun1.l.google.com:19302'
print ('Environment Set; webrtc ip: '+ip+':'+port)
command = cube(15) + sphere(5).right(10)
scad = (scad_render(command))
print (str(command)+' : scad rendering to .stl')
view(scad, outfile='/var/www/design.stl')
print ('Rendered to .stl')
mesh = o3d.io.read_triangle_mesh("../design.stl")
mesh = mesh.compute_vertex_normals()
#o3d.visualization.webrtc_server.disable_http_handshake() #### or us it
#o3d.visualization.webrtc_server.call_http_api(entry_point: str, query_string: str = '', data: str = '')
o3d.visualization.webrtc_server.enable_webrtc()
print ('webrtc started')
o3d.visualization.draw(mesh)
print ('output')