Commit f4dd1493 by Alexander Bazo

Add gaze client startup

parent f9bd9b08
/* global GazeClient */
import Logger from "./utils/Logger.js"; import Logger from "./utils/Logger.js";
import StarGazer from "./game/StarGazer.js"; import StarGazer from "./game/StarGazer.js";
import GazePoint from "./game/GazePoint.js"; import GazePoint from "./game/GazePoint.js";
var gclient = new GazeClient();
function init() { function init() {
Logger.enable(); Logger.enable();
document.addEventListener("mousemove", onMouseMove); initGazeClient();
initStarGazer();
}
function initGazeClient() {
gclient.connect("ws://localhost:8001/gaze");
gclient.addEventListener("connectionopened", onConnected);
gclient.addEventListener("dataAvailable", onGazeDataAvailable);
gclient.addEventListener("connectionclosed", onDisconnected);
}
function initStarGazer() {
StarGazer.init({ StarGazer.init({
canvas: document.querySelector("canvas"), canvas: document.querySelector("canvas"),
fps: 60, fps: 60,
...@@ -13,10 +28,16 @@ function init() { ...@@ -13,10 +28,16 @@ function init() {
}); });
} }
function onMouseMove(event) { function onConnected(event) {
StarGazer.onGazeUpdate({ console.log(event);
target: new GazePoint(event.screenX, event.screenY), }
});
function onGazeDataAvailable(event) {
console.log(event);
}
function onDisconnected(event) {
console.log(event);
} }
init(); init();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment