GazePoint.js 636 Bytes
Newer Older
Alexander Bazo committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/* eslint-env node */

const schema = require("@colyseus/schema"),
  Schema = schema.Schema;

class GazePoint extends Schema {

  constructor(screenX, screenY, createdAt, source) {
    super();
    this.screenX = screenX;
    this.screenY = screenY;
    this.createdAt = createdAt;
    this.source = source;
    this.relativeAge = 0;
  }

  static fromClientData(data) {
    return new GazePoint(data.screenX, data.screenY, data.createdAt, data.source);
  }

}

schema.defineTypes(GazePoint, {
  screenX: "number",
  screenY: "number",
  createdAt: "number",
  relativeAge: "number",
  source: "string",
});

module.exports = GazePoint;