// 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 velocity values for use in rendering
// curFramePose is a VRPose object
const curFramePose = frameData.pose;
const linVel = curFramePose.linearVelocity;
const lvx = linVel[0];
const lvy = linVel[1];
const lvz = linVel[2];
// render the scene
// …
// WebVR: submit the rendered frame to the VR display
vrDisplay.submitFrame();
}VRPose: linearVelocity property / notebook
VRPose: linearVelocity property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.