/* 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(); 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) { let eyeX = (event.data.leftEyeX + event.data.rightEyeX) / 2, eyeY = (event.data.leftEyeY + event.data.rightEyeY) / 2, createdAt = event.data.trackerTimeStamp, gazePoint = new GazePoint(eyeX, eyeY, createdAt); StarGazer.onGazeUpdate(gazePoint); } function onDisconnected(event) { console.log(event); } init();