PositionSensorVRDevice: resetSensor() method
Deprecated
Avoid using this feature in new projects. Development of the WebVR API halted in favor of WebXR. This feature may be a candidate for removal from web standards or browsers.>
Consider using the following features instead: WebXR.>
Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.
The resetSensor() method of the VRDisplay interface can be used to reset the sensor if desired, returning the position and orientation values to zero.
Syntax
resetSensor()
Parameters
None.
Return value
None (undefined).
Examples
The following demo uses the WebVR API to update the view of a simple CanvasRenderingContext2D scene on each frame of a requestAnimationFrame loop. It features, among other things, a "Reset Sensor" button in the UI, which when pressed runs the resetSensor() function on the position sensor. The JavaScript looks like this:
document.querySelector("button").onclick = () => {
gPositionSensor.resetSensor();
};
When the button is pressed, the current position, orientation, etc. of the sensor/head mounted display is set to be 0 — this makes the method useful for calibration when an app is first loaded.