@@ -6,6 +6,8 @@ | |||||
<meta charset="utf-8"> | <meta charset="utf-8"> | ||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1" /> | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1" /> | ||||
<link rel="stylesheet" href="main.css"> | <link rel="stylesheet" href="main.css"> | ||||
<script src="scripts/three.js"></script> | |||||
<script src="scripts/orbitcontrols.js"></script> | |||||
<script data-main="scripts/main" src="scripts/require.js"></script> | <script data-main="scripts/main" src="scripts/require.js"></script> | ||||
</head> | </head> | ||||
@@ -1,4 +1,4 @@ | |||||
define(["three", "anders_briegel", "websocket"], function(three, websocket) { | |||||
define(["anders_briegel", "websocket"], function(anders_briegel, websocket) { | |||||
return { | return { | ||||
colors: ["red", "green", "yellow", "blue", "pink", "orange", "purple"], | colors: ["red", "green", "yellow", "blue", "pink", "orange", "purple"], | ||||
@@ -1,4 +1,4 @@ | |||||
define(["three", "orbitcontrols", "message"], function() { | |||||
define(["message"], function() { | |||||
return { | return { | ||||
construct: function() { | construct: function() { | ||||
this.renderer = new THREE.WebGLRenderer(); | this.renderer = new THREE.WebGLRenderer(); | ||||
@@ -38,7 +38,5 @@ define(["three", "orbitcontrols", "message"], function() { | |||||
grid.setColors(0xdddddd, 0xeeeeee); | grid.setColors(0xdddddd, 0xeeeeee); | ||||
this.scene.add(grid); | this.scene.add(grid); | ||||
} | } | ||||
}; | }; | ||||
}); | }); |
@@ -1,10 +1,11 @@ | |||||
// Import modules | // Import modules | ||||
requirejs(["anders_briegel", "gui"], init); | |||||
requirejs(["anders_briegel", "gui", "graph"], init); | |||||
var ab; | var ab; | ||||
// Called on startup | // Called on startup | ||||
function init(anders_briegel, gui) { | |||||
function init(anders_briegel, gui, graph) { | |||||
ab = anders_briegel; | ab = anders_briegel; | ||||
graph.hookEvents(); | |||||
gui.construct(); | gui.construct(); | ||||
gui.render(); | gui.render(); | ||||
} | } |
@@ -1 +1,6 @@ | |||||
define({}); | |||||
define({ | |||||
serverMessage: function(msgtext){ | |||||
message.innerHTML = msgtext; | |||||
message.className = "visible"; | |||||
} | |||||
}); |
@@ -1,29 +1,25 @@ | |||||
define(["message"], function(message){ | define(["message"], function(message){ | ||||
return { | return { | ||||
bindEvents: function(update){ | |||||
connect: function(update){ | |||||
var ws = new WebSocket("ws://localhost:5000"); | var ws = new WebSocket("ws://localhost:5000"); | ||||
ws.onopen = function(evt) | ws.onopen = function(evt) | ||||
{ | { | ||||
message.innerHTML = "Connected to server."; | |||||
message.className = "visible"; | |||||
message.serverMessage("Connected to server."); | |||||
}; | }; | ||||
ws.onerror = function(err) | ws.onerror = function(err) | ||||
{ | { | ||||
message.innerHTML = "Could not connect to server."; | |||||
message.className = "visible"; | |||||
message.serverMessage("Could not connect to server."); | |||||
}; | }; | ||||
ws.onmessage = function (evt) | ws.onmessage = function (evt) | ||||
{ | { | ||||
console.log("Received update"); | |||||
update(JSON.parse(evt.data)); | update(JSON.parse(evt.data)); | ||||
}; | }; | ||||
ws.onclose = function(evt) | ws.onclose = function(evt) | ||||
{ | { | ||||
message.innerHTML = "Connection to server lost. <a href='#' onclick='javascript:connect_to_server()'>Reconnect</a>."; | |||||
message.className = "visible"; | |||||
message.serverMessage("Connection to server lost. <a href='#' onclick='javascript:connect_to_server()'>Reconnect</a>."); | |||||
}; | }; | ||||
} | } | ||||
}; | }; | ||||