Commit f4dd1493 by Alexander Bazo

Add gaze client startup

parent f9bd9b08
/* global GazeClient */
import Logger from "./utils/Logger.js";
import StarGazer from "./game/StarGazer.js";
import GazePoint from "./game/GazePoint.js";
var gclient = new GazeClient();
function init() {
Logger.enable();
document.addEventListener("mousemove", onMouseMove);
StarGazer.init({
canvas: document.querySelector("canvas"),
fps: 60,
width: 800,
height: 800,
});
Logger.enable();
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({
canvas: document.querySelector("canvas"),
fps: 60,
width: 800,
height: 800,
});
}
function onConnected(event) {
console.log(event);
}
function onGazeDataAvailable(event) {
console.log(event);
}
function onMouseMove(event) {
StarGazer.onGazeUpdate({
target: new GazePoint(event.screenX, event.screenY),
});
function onDisconnected(event) {
console.log(event);
}
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