@@ -146,8 +146,6 @@ try: | |||||
with open(temp("by_name.json")) as f: | with open(temp("by_name.json")) as f: | ||||
by_name = json.load(f) | by_name = json.load(f) | ||||
print "Loaded tables from cache" | |||||
except IOError: | except IOError: | ||||
# Spend time building the tables | # Spend time building the tables | ||||
unitaries = get_unitaries() | unitaries = get_unitaries() | ||||
@@ -31,6 +31,7 @@ function startMainLoop() { | |||||
scene = makeScene(); | scene = makeScene(); | ||||
controls.addEventListener("change", render); | controls.addEventListener("change", render); | ||||
poll(); | poll(); | ||||
render(); | |||||
} | } | ||||
// Someone resized the window | // Someone resized the window | ||||
@@ -63,12 +64,12 @@ function init() { | |||||
controls = new THREE.OrbitControls(camera); | controls = new THREE.OrbitControls(camera); | ||||
// Center the camera | // Center the camera | ||||
// TODO: frustrum | |||||
controls.center.set(0, 0, 0); | controls.center.set(0, 0, 0); | ||||
controls.rotateSpeed = 0.2; | controls.rotateSpeed = 0.2; | ||||
camera.position.set(0, 0, 20); | |||||
camera.position.set(0, 0, 40); | |||||
// Start polling | // Start polling | ||||
setInterval(poll, 1000); | |||||
// Run | // Run | ||||
startMainLoop(); | startMainLoop(); | ||||
@@ -1,19 +1,25 @@ | |||||
function poll() { | function poll() { | ||||
var xhr = new XMLHttpRequest(); | |||||
xhr.onload = function() { | |||||
var state = JSON.parse(xhr.responseText); | |||||
updateScene(state); | |||||
var ws = new WebSocket("ws://localhost:5000/echo"); | |||||
ws.onopen = function() | |||||
{ | |||||
// Web Socket is connected, send data using send() | |||||
ws.send("Hello from the browser! I connected okay"); | |||||
console.log("Sent a message to the server"); | |||||
}; | }; | ||||
xhr.onerror = function(e){ | |||||
//soft_console.innerHTML = "\n" + "Lost connection to server"; | |||||
ws.onmessage = function (evt) | |||||
{ | |||||
var received_msg = evt.data; | |||||
console.log("I got a message from the server:"); | |||||
console.log(evt.data); | |||||
}; | |||||
ws.onclose = function() | |||||
{ | |||||
ws.send("Bye by from the browser"); | |||||
console.log("Connection is closed..."); | |||||
}; | }; | ||||
xhr.open("GET", "/state", true); | |||||
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); | |||||
xhr.send(); | |||||
} | } | ||||
function updateScene(state) { | function updateScene(state) { | ||||