// Initialize components for Routine "initializeEyetracking"
initializeEyetrackingClock=newutil.Clock();
//initialize params of the webgazer package (used for eye tracking)
// Initialize x and y arrays; we use these to calculate running averages of
// current gaze position; the longer the window, the slower, but more fluent
// the updates
letaveragingWindow=10;
window.xGazes=newArray(averagingWindow).fill(0);
window.yGazes=newArray(averagingWindow).fill(0);
// Timestamp for last time eyes exited validation box
window.eyesExitedTimestamp=(newDate).getTime();
// No. of ms to keep webcam thumbnail visible after eyes returned into validation box
window.eyesReturnedDelay=3000;
// DEBUG
window.psychoJS=psychoJS;
loading_text=newvisual.TextStim({
webcamWarning=newvisual.TextStim({
win:psychoJS.window,
name:'loading_text',
text:'Downloading additional resources. \n\nOne moment please...',
name:'webcamWarning',
text:'This experiment uses eye tracking. \n\nYou should see your web-browser request access to your webcam. You might need to click on this text to make that happen. Please permit access, and wait a little while. Your webcam video should appear in the top-left of the screen.',
// Initialize components for Routine "webcam_trial"
webcam_trialClock=newutil.Clock();
intro_text=newvisual.TextStim({
// Initialize components for Routine "inst1"
inst1Clock=newutil.Clock();
instruction1Txt=newvisual.TextStim({
win:psychoJS.window,
name:'intro_text',
text:'demo_eye_tracking: starting webcam\n\nThis experiment demonstrates eye tracking via the webgazer library. \n\nYou should see your web-browser request access to your webcam. You might need to click on this text to make that happen. Please permit access, and wait a little while. Your webcam video should appear in the top-left of the screen.',
name:'instruction1Txt',
text:'Webgazer initialized. \nPress space to move on',
// Initialize components for Routine "calibrationIntro"
calibrationIntroClock=newutil.Clock();
calibrationTxt=newvisual.TextStim({
win:psychoJS.window,
name:'calibration_text',
text:"demo_eye_tracking: calibration\n\nNow we'll calibrate the eye tracker. Please try to keep your head still and within the rectangle you see in your webcam video. When you do so, the rectangle turns green.\n\nIn the next part of this experiment, the webcam video disappears. It will reappear when your head is too from the rectangle. If this happens, please move back into view. White squares appears at different locations on the screen. Please click each square with your mouse.\n\nClick anywhere to continue...",
name:'calibrationTxt',
text:"OK great! we are almost ready to get started. \n\nFirst we need to calibrate the eye tracker. Please try to keep your head still. If you move your head too far away, you'r webcam will appear in the top left corner. If this happens, please move back into view. \n\nWhite squares will appear at different locations on the screen. Please click each square with your mouse.\n\nClick anywhere with the mouse to continue...",
text:'Great! we are now tracking your eye movements! look around the screen to see how it works! \n\nPlease remember is important for you to keep your head still during the experiment. \n\nPress space to start',