Class: shaka.ui.VRWebgl

Constructor

new VRWebgl(videonon-null, playernon-null, canvasnon-null, gl, projectionMode, hfovopt)

Parameters:
Name Type Attributes Default Description
video HTMLMediaElement
player shaka.Player
canvas HTMLCanvasElement
gl WebGLRenderingContext
projectionMode string
hfov number <optional>
180 Horizontal field of view of the content, in degrees. Only used by the fisheye projection.
Implements:
Source:

Members

ANIMATION_DURATION_ :number

Type:
  • number
Source:

IDENTITY_MATRIX_ :Float32Array

Never modified.
Type:
  • Float32Array
Source:

MAX_FIELD_OF_VIEW :number

The maximum field of view, in degrees.
Type:
  • number
Source:

MIN_FIELD_OF_VIEW :number

The minimum field of view, in degrees.
Type:
  • number
Source:

StereoLayout :string

How the views of each eye are stored in the video frames.
Type:
  • string
Properties:
Name Value Type Description
MONO mono string
TOP_BOTTOM top-bottom string
LEFT_RIGHT left-right string
Source:

animationFrameId_ :number

The animation frame that renders the video while it plays, when the browser does not support requestVideoFrameCallback.
Type:
  • number
Source:

canvas_ :HTMLCanvasElement

Type:
  • HTMLCanvasElement
Source:

cont_ :number

Type:
  • number
Source:

currentQuaternion_ :Float32Array

Type:
  • Float32Array
Source:

diff_ :Float32Array

Type:
  • Float32Array
Source:

eyeClampUniform_ :WebGLUniformLocation

Type:
  • WebGLUniformLocation
Source:

eyeRectUniform_ :WebGLUniformLocation

Type:
  • WebGLUniformLocation
Source:

fieldOfView_ :number

Type:
  • number
Source:

geometry_ :?{vertices: !Array<number>, textureCoords: !Array<number>, indices: !Array<number>}

Type:
  • ?{vertices: !Array<number>, textureCoords: !Array<number>, indices: !Array<number>}
Source:

gl_ :WebGLRenderingContext

Type:
  • WebGLRenderingContext
Source:

hfov_ :number

Type:
  • number
Source:

identityMatrix_ :Float32Array

Type:
  • Float32Array
Source:

initialForward_ :Array<number>

The direction of the initial view, used as the north.
Type:
  • Array<number>
Source:

lastFrameTime_ :number

The time of the last frame uploaded by the animation frame loop.
Type:
  • number
Source:

modelViewMatrixUniform_ :WebGLUniformLocation

Type:
  • WebGLUniformLocation
Source:

originalQuaternion_ :Float32Array

Type:
  • Float32Array
Source:

positionX_ :number

Type:
  • number
Source:

positionY_ :number

Type:
  • number
Source:

previousCanvasHeight_ :number

Type:
  • number
Source:

previousCanvasWidth_ :number

Type:
  • number
Source:

projectionMatrix_ :Float32Array

Type:
  • Float32Array
Source:

projectionMatrixUniform_ :WebGLUniformLocation

Type:
  • WebGLUniformLocation
Source:

projectionMode_ :string

Type:
  • string
Source:

rotationMatrix_ :Float32Array

Reused by rotateViewGlobal, which runs for every pointer move and device orientation event.
Type:
  • Float32Array
Source:

samplerUniform_ :WebGLUniformLocation

Type:
  • WebGLUniformLocation
Source:

shaderProgram_ :WebGLProgram

Type:
  • WebGLProgram
Source:

shaders_ :Array<!WebGLShader>

Type:
  • Array<!WebGLShader>
Source:

stereoLayout_ :shaka.ui.VRWebgl.StereoLayout

How the views of each eye are stored in the video frames.
Type:
Source:

stereoscopicMode_ :boolean

Type:
  • boolean
Source:

texture_ :WebGLTexture

Type:
  • WebGLTexture
Source:

textureCoordAttribute_ :number

Type:
  • number
Source:

vertexPositionAttribute_ :number

Type:
  • number
Source:

verticesBuffer_ :WebGLBuffer

Type:
  • WebGLBuffer
Source:

verticesIndexBuffer_ :WebGLBuffer

Type:
  • WebGLBuffer
Source:

verticesTextureCoordBuffer_ :WebGLBuffer

Type:
  • WebGLBuffer
Source:

video_ :HTMLVideoElement

Type:
  • HTMLVideoElement
Source:

viewMatrix_ :Float32Array

Type:
  • Float32Array
Source:

viewProjectionMatrix_ :Float32Array

Type:
  • Float32Array
Source:

vpMatrixUniform_ :WebGLUniformLocation

Type:
  • WebGLUniformLocation
Source:

Methods

getForward_(viewMatrixnon-null) → {Array<number>}

Parameters:
Name Type Description
viewMatrix Float32Array
Source:
Returns:
The direction the view looks at, in world coordinates.
Type
Array<number>

deleteGLResources_()

Source:

getAspectRatio_() → {number}

Returns the aspect ratio of the displayed viewport, so that the perspective projection does not stretch the image. The canvas is displayed at the size of the video container, so the client size is what the user sees. In stereoscopic mode each eye gets half of the width.
Source:
Returns:
Type
number

getCubeInsetU_() → {number}

Returns a horizontal inset of half a texel, so that the cube faces are not sampled at the exact edge they share with the adjacent face of the atlas. Otherwise the edges of the cube can become visible while moving the view.
Source:
Returns:
Type
number

getCubeInsetV_() → {number}

Returns a vertical inset of half a texel, see getCubeInsetU_.
Source:
Returns:
Type
number

getEyeRect_(eye) → {Array<number>}

Returns the part of the video frame that holds the view of an eye, as [x, y, width, height] in texture coordinates.
Parameters:
Name Type Description
eye number 0 for the left eye, 1 for the right eye.
Source:
Returns:
Type
Array<number>

getFieldOfView() → {number}

Source:
Returns:
Type
number

getGLShader_(glType) → {WebGLShader}

Read and generate WebGL shader
Parameters:
Name Type Description
glType number Type of shader requested.
Source:
Returns:
Type
WebGLShader

getHfov() → {number}

Source:
Returns:
Type
number

getMaxViewAngle_() → {number}

Content that does not cover the whole sphere only has an image around its center: a half-equirectangular frame covers the front hemisphere, and a fisheye frame a circle of its field of view. This returns the largest angle between the center of the view and the center of the content at which the whole view stays inside the image, so that the view never shows the area outside of it.
Source:
Returns:
In radians, or Infinity if the content covers the whole sphere.
Type
number

getNorth() → {number}

Source:
Returns:
Type
number

getProjectionMode() → {string}

Source:
Returns:
Type
string

init_()

Source:

initGL_()

Source:

initGLBuffers_()

Source:

initGLResources_()

Source:

initGLShaders_()

Source:

initGLTexture_()

Source:

initMatrices_()

Source:

isStereoscopicModeEnabled() → {boolean}

Returns true if stereoscopic mode is enabled.
Source:
Returns:
Type
boolean

release()

Request that this object release all internal references.
Implements:
Source:

renderGL_(textureUpdateopt)

Parameters:
Name Type Attributes Default Description
textureUpdate boolean <optional>
true
Source:

reset(firstTimeopt)

Parameters:
Name Type Attributes Default Description
firstTime boolean <optional>
true
Source:

restoreContext()

Recreates the WebGL resources after the context was restored. The view (orientation, field of view and stereoscopic mode) is kept.
Source:

rotateView_(yaw, pitch, roll)

Parameters:
Name Type Description
yaw number
pitch number
roll number
Source:

rotateViewGlobal(yawnon-null, pitchnon-null, rollnon-null)

Rotate the view matrix global
Parameters:
Name Type Description
yaw number Yaw.
pitch number Pitch.
roll number Roll.
Source:

setEyeUniforms_(eye)

Parameters:
Name Type Description
eye number 0 for the left eye, 1 for the right eye.
Source:

setFieldOfView(fieldOfView)

Parameters:
Name Type Description
fieldOfView number
Source:

setMatrixUniforms_()

Source:

setStereoLayout(stereoLayout)

Sets how the views of each eye are stored in the video frames. In the stereoscopic mode each eye displays its own view. Otherwise, the left eye view is displayed.
Parameters:
Name Type Description
stereoLayout shaka.ui.VRWebgl.StereoLayout
Source:

startAnimationFrames_()

Renders the video in sync with the display, uploading only new frames.
Source:

stopAnimationFrames_()

Source:

toggleStereoscopicMode()

Toggle stereoscopic mode
Source:

updateViewPort_()

Source:

zoom(amount)

Parameters:
Name Type Description
amount number
Source: