WebAR Build Error: Cannot Read Properties of Undefined (reading ‘FOV’)
If your Unity WebAR build fails to run and shows an error similar to:
TypeError: Cannot read properties of undefined (reading 'FOV')
or:
TypeError: undefined is not an object (evaluating 'window.iTracker.FOV')
the most likely cause is that the wrong WebGL template is selected for the tracker you are using.
The Solution
Select the correct WebGL template for your tracker before building your project.
In Unity, go to:
Project Settings
└── Player
└── Resolution and Presentation
└── WebGL Template
Then select the template that matches the tracker you are using:
- Image Tracker: select the
iTrackerWebGL template. - World Tracker: select the
wTrackerWebGL template.
Why This Error Happens
Each tracker uses its corresponding WebGL template to initialize the JavaScript components required by the tracker.
For example, Image Tracker expects window.iTracker to be available. If the incorrect template is used, window.iTracker may not be initialized, resulting in an error when the build tries to access properties such as FOV.
Quick Check
If you encounter an iTracker.FOV error, first confirm that:
WebGL Template = iTracker
Then rebuild your WebGL project.
Source: Imagine WebAR Developer Community
Originally discussed April 2024.
View original Discord discussion →
Join the Imagine WebAR Discord community →