new StereoRenderer(gl, opt_attributes)
Stereo rendering controller. Responsible for setting up stereo rendering and drawing the scene each frame.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
gl |
WebGLRenderingContext | GL context. |
|
opt_attributes |
vr.StereoRenderer.Attributes |
<optional> |
Render target attributes. |
- Source:
- vr.js, line 1793
Example
// Create a renderer with just a depth channel.
var stereoRenderer = new vr.StereoRenderer(gl, {
alpha: false,
depth: true,
stencil: false
});
var state = new vr.State();
function renderScene() {
vr.pollState(state);
// TODO: process camera/controls/etc.
stereoRenderer.render(state, function(eye) {
// Compute the model-view matrix from the camera and the eye view adjust.
var modelViewMatrix = mat4.clone(camera.modelViewMatrix);
mat4.multiply(modelViewMatrix, eye.viewAdjustMatrix, modelViewMatrix);
// Render using the eye projection matrix and the new model-view matrix.
renderMyScene(eye.projectionMatrix, modelViewMatrix);
});
};
Methods
-
dispose()
-
Disposes the object.
- Source:
- vr.js, line 2015
-
getInterpupillaryDistance() → {number}
-
Gets the current interpupillary distance value.
- Source:
- vr.js, line 2187
Returns:
IPD value.
- Type
- number
-
getParams() → {vr.StereoParams}
-
Gets the parameters used for stereo rendering.
- Source:
- vr.js, line 2039
Returns:
Stereo params.
- Type
- vr.StereoParams
-
getPostProcessingMode() → {vr.PostProcessingMode}
-
Gets the current post-processing mode.
- Source:
- vr.js, line 2048
Returns:
Post-processing mode.
-
render(callback, opt_scope)
-
Updates the stereo data and renders the scene. The given callback is used to perform the render and may be called more than once. It receives the eye to render and the width and height of the render target.
Parameters:
Name Type Argument Description callback
function Callback.
opt_scope
T <optional>
Scope.
- Source:
- vr.js, line 2212
-
setInterpupillaryDistance(value)
-
Sets a new interpupillary distance value.
Parameters:
Name Type Description value
number New IPD value.
- Source:
- vr.js, line 2198
-
setPostProcessingMode(value)
-
Switches the post-processing mode.
Parameters:
Name Type Description value
vr.PostProcessingMode New mode.
- Source:
- vr.js, line 2057
Type Definitions
-
Attributes
-
Render target attributes.
Type:
- Object
- Source:
- vr.js, line 1998
Properties:
Name Type Description alpha
boolean | undefined Whether an alpha channel is required.
depth
boolean | undefined Whether an depth channel is required.
stencil
boolean | undefined Whether an stencil channel is required.