HMDVRDevice: getEyeParameters() method
WebVR API
WebVR API
The **`getEyeParameters()`** method of the HMDVRDevice interface returns current parameters for the eye specified as its argument ("left" or "right") — stored in a VREyeParameters object.
This includes field of view information, and more.
## Syntax
```js-nolint
getEyeParameters(whichEye)
```
### Parameters
- `whichEye`
- : A string representing the eye you want to return information about. The value can be `left` or `right`.
### Return value
A VREyeParameters object.
## Examples
The following example is taken from the Mozilla VR Team's [threejs-vr-boilerplate](https://github.com/MozillaReality/vr-web-examples/tree/master/threejs-vr-boilerplate) code — to be precise, the [VREffect.js file](https://github.com/MozillaReality/vr-web-examples/blob/master/threejs-vr-boilerplate/js/VREffect.js). Early on in the code the `getEyeParameters()` method is used to access information about each eye, which is then used for rendering calculations later on.
```js
if (vrHMD.getEyeParameters !== undefined) {
const eyeParamsL = vrHMD.getEyeParameters("left");
const eyeParamsR = vrHMD.getEyeParameters("right");
eyeTranslationL = eyeParamsL.eyeTranslation;
eyeTranslationR = eyeParamsR.eyeTranslation;
eyeFOVL = eyeParamsL.recommendedFieldOfView;
eyeFOVR = eyeParamsR.recommendedFieldOfView;
} else {
// …
}
```
## Browser compatibility
## See also
- [WebVR API](/docs/Web/API/WebVR_API)
Cite this
"HMDVRDevice: getEyeParameters() method". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/HMDVRDevice/getEyeParameters JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy