Namespace: vr

vr

Source:
  • vr.js, line 12

Namespaces

mat4f

Members

<static> ErrorCode :number

Error codes that may be set as the 'code' property on Error objects. These can be used for handing the errors without having to inspect their text.

Type:
  • number
Properties:
Name Type Default Description
PLUGIN_NOT_FOUND number 1

The plugin was not found and is most likely not installed.

PLUGIN_BLOCKED number 4

Plugin is present but was blocked from running by the browser. The user should enable the plugin for the page (from the page action in Chrome).

Source:
  • vr.js, line 26

<static> PostProcessingMode :number

The post processing mode to use when rendering each eye.

Type:
  • number
Properties:
Name Type Default Description
STRAIGHT number 0

Straight pass-through with no distortion.

WARP number 1

Distort for lens correction.

WARP_CHROMEAB number 2

Distort and also apply chromatic aberration correction.

Source:
  • vr.js, line 1749

<static> SixenseButton :number

Bitmask values for the sixense controller buttons field.

Type:
  • number
Properties:
Name Type Default Description
NONE number 0
BUTTON_START number LSH
BUTTON_1 number LSH
BUTTON_2 number LSH
BUTTON_3 number LSH
BUTTON_4 number LSH
BUMPER number LSH
JOYSTICK number LSH
Source:
  • vr.js, line 977

<static> SixenseHand :number

Possible values of the sixense controller hand.

Type:
  • number
Properties:
Name Type Default Description
UNKNOWN number 0

Hand has not yet been determined.

LEFT number 1

Controller is in the left hand.

RIGHT number 2

Controller is in the right hand.

Source:
  • vr.js, line 994

Methods

<static> enterFullScreen() → {boolean}

Enters full screen mode, moving the window to the Oculus display if present.

Source:
  • vr.js, line 680
Returns:

True if the window entered fullscreen.

Type
boolean

<static> exitFullScreen()

Exits fullscreen mode and moves the window back to its original position.

Source:
  • vr.js, line 713

<static> getError() → {Error|null}

Gets the error that occurred during initialization, if any.

Source:
  • vr.js, line 553
Returns:

Error object. May contain a 'code' property corresponding to a value from vr.ErrorCode.

Type
Error | null

<static> getHmdInfo() → {vr.HmdInfo}

Gets the information of the currently connected HMD device, if any. This is populated on demand by calling vr.pollState.

Source:
  • vr.js, line 607
Returns:

HMD info, if any.

Type
vr.HmdInfo

<static> getSixenseInfo() → {vr.SixenseInfo}

Gets the information of the currently connected Sixense device, if any. This is populated on demand by calling vr.pollState.

Source:
  • vr.js, line 630
Returns:

Sixense info, if any.

Type
vr.SixenseInfo

<static> isFullScreen() → {boolean}

Detects whether the window is currently fullscreen.

Source:
  • vr.js, line 665
Returns:

True if in full screen mode.

Type
boolean

<static> load(opt_callback, opt_scope)

Starts loading the plugin and queues a callback that will be called when the plugin is ready.

The callback will receive an error object if an error occurred. This error object may have a 'code' property corresponding to vr.ErrorCode.

If the plugin is already initialized the given callback will be called next tick, so it's always safe to use this and assume asynchronicity.

Parameters:
Name Type Argument Description
opt_callback function <optional>

Callback function.

opt_scope T <optional>

Optional callback scope.

Source:
  • vr.js, line 595
Example
vr.load(function(opt_error) {
  if (opt_error) {
    // Plugin failed to load for some reason.
    switch (opt_error.code) {
      case vr.ErrorCode.PLUGIN_NOT_FOUND:
        // Plugin was not installed.
        break;
      case vr.ErrorCode.PLUGIN_BLOCKED:
        // Plugin was blocked by the browser - user must enable.
        break;
      default:
        // Some other error?
        break;
    }
    return;
  } else {
    // Plugin found and ready to use!
  }
});

<static> log(var_args)

Logs to the console, if one is present. This should be used for critical debugging messages only, as it has a performance cost.

Parameters:
Name Type Argument Description
var_args * <repeatable>

Things to log.

Source:
  • vr.js, line 759

<static> pollState(state) → {boolean}

Polls active devices and fills in the state structure. This also takes care of dispatching device notifications/etc.

Parameters:
Name Type Description
state vr.State

State structure to fill in. This must be created by the caller and should be cached across calls to prevent extra garbage.

Source:
  • vr.js, line 655
Returns:

True if the state query was successful.

Type
boolean
Example
// Cache the state object to reduce garbage generation.
var state = new vr.State();
function frameTick() {
  // Poll state at the start of each frame, before rendering.
  if (vr.pollState(state)) {
    // VR plugin active and state was polled.
    // TODO: update camera/controls/etc.
  }
  // TODO: render with the latest data.
};

<static> requestAnimationFrame(callback, opt_scope)

Requests an animation frame.

Parameters:
Name Type Argument Description
callback function

Function to call on the next frame.

opt_scope T <optional>

Callback scope.

Source:
  • vr.js, line 735

<static> resetHmdOrientation()

Resets the current orientation of the headset to be zero. This should be used to compensate for drift when the user has likely come back after not using the HMD for awhile. For example, on page visibility change.

Source:
  • vr.js, line 619