// rendering loop for a VR scene
function drawVRScene() {
// WebVR: Request the next frame of the animation
vrSceneFrame = vrDisplay.requestAnimationFrame(drawVRScene);
// Populate frameData with the data of the next frame to display
vrDisplay.getFrameData(frameData);
// Retrieve the linear acceleration values for use in rendering
// curFramePose is a VRPose object
const curFramePose = frameData.pose;
const linAcc = curFramePose.linearAcceleration;
const lax = linAcc[0];
const lay = linAcc[1];
const laz = linAcc[2];
// render the scene
// …
// WebVR: submit the rendered frame to the VR display
vrDisplay.submitFrame();
}VRPose: linearAcceleration property / notebook
VRPose: linearAcceleration property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.