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
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:
geometry_ :?{vertices: !Array<number>, textureCoords: !Array<number>, indices: !Array<number>}
Type:
- ?{vertices: !Array<number>, textureCoords: !Array<number>, indices: !Array<number>}
- 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:
projectionMatrixUniform_ :WebGLUniformLocation
Type:
- WebGLUniformLocation
- Source:
rotationMatrix_ :Float32Array
Reused by rotateViewGlobal, which runs for every pointer move and
device orientation event.
Type:
- Float32Array
- Source:
stereoLayout_ :shaka.ui.VRWebgl.StereoLayout
How the views of each eye are stored in the video frames.
Type:
- 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>
getGLShader_(glType) → {WebGLShader}
Read and generate WebGL shader
Parameters:
| Name | Type | Description |
|---|---|---|
glType |
number | Type of shader requested. |
- Source:
Returns:
- Type
- WebGLShader
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
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:
updateViewPort_()
- Source: