Constructor
new SkyProgram(gl)
Constructs a new program.
Initializes, compiles and links this GLSL program with the source code for its vertex and fragment shaders.
This method creates WebGL shaders for the program's shader sources and attaches them to a new GLSL program.
This method then compiles the shaders and then links the program if compilation is successful. Use the bind
method to make the program current during rendering.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
- Source:
Throws:
-
If the shaders cannot be compiled, or linking of
the compiled shaders into a program fails.
-
-
Type
-
ArgumentError
Extends
Members
(static, readonly) key :string
A string that uniquely identifies this program.
Type:
- Source:
altitude :Number
The globe's atmosphere altitude.
Type:
- Inherited From:
- Default Value:
- Source:
(readonly) atmosphereRadius2Location :WebGLUniformLocation
The WebGL location for this program's 'atmosphereRadius2' uniform.
Type:
- Inherited From:
- Source:
(readonly) atmosphereRadiusLocation :WebGLUniformLocation
The WebGL location for this program's 'atmosphereRadius' uniform.
Type:
- Inherited From:
- Source:
(readonly) eyeMagnitude2Location :WebGLUniformLocation
The WebGL location for this program's 'eyeMagnitude2' uniform.
Type:
- Inherited From:
- Source:
(readonly) eyeMagnitudeLocation :WebGLUniformLocation
The WebGL location for this program's 'eyeMagnitude' uniform.
Type:
- Inherited From:
- Source:
(readonly) eyePointLocation :WebGLUniformLocation
The WebGL location for this program's 'eyePoint' uniform.
Type:
- Inherited From:
- Source:
(readonly) fragModeLocation :WebGLUniformLocation
The WebGL location for this program's 'fragMode' uniform.
Type:
- Inherited From:
- Source:
(readonly) globeRadiusLocation :WebGLUniformLocation
The WebGL location for this program's 'globeRadius' uniform.
Type:
- Inherited From:
- Source:
(readonly) lightDirectionLocation :WebGLUniformLocation
The WebGL location for this program's 'lightDirection' uniform.
Type:
- Inherited From:
- Source:
(readonly) mvpMatrixLocation :WebGLUniformLocation
The WebGL location for this program's 'mvpMatrix' uniform.
Type:
- Inherited From:
- Source:
(readonly) programId :WebGLProgram
Indicates the WebGL program object associated with this GPU program.
Type:
- Inherited From:
- Source:
rayleighScaleDepth :Number
This atmosphere's Rayleigh scale depth.
Type:
- Inherited From:
- Default Value:
- Source:
(readonly) scaleDepthLocation :WebGLUniformLocation
The WebGL location for this program's 'scaleDepth' uniform.
Type:
- Inherited From:
- Source:
(readonly) scaleLocation :WebGLUniformLocation
The WebGL location for this program's 'scale' uniform.
Type:
- Inherited From:
- Source:
(readonly) scaleOverScaleDepthLocation :WebGLUniformLocation
The WebGL location for this program's 'scaleOverScaleDepth' uniform.
Type:
- Inherited From:
- Source:
(readonly) texCoordMatrixLocation :WebGLUniformLocation
The WebGL location for this program's 'texCoordMatrix' uniform.
Type:
- Inherited From:
- Source:
(readonly) vertexOriginLocation :WebGLUniformLocation
The WebGL location for this program's 'vertexOrigin' uniform.
Type:
- Inherited From:
- Source:
Methods
attributeLocation(gl, attributeName) → {Number}
Returns the GLSL attribute location of a specified attribute name.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
attributeName |
String
|
The name of the attribute whose location is determined. |
- Inherited From:
- Source:
Throws:
-
If the specified attribute name is null, empty or undefined.
-
-
Type
-
ArgumentError
Returns:
The WebGL attribute location of the specified attribute, or -1 if the attribute is not
found.
-
Type
-
Number
dispose(gl)
Releases this GPU program's WebGL program and associated shaders. Upon return this GPU program's WebGL
program ID is 0 as is that of the associated shaders.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
- Inherited From:
- Source:
getAltitude() → {Number}
Returns the atmosphere's altitude.
- Inherited From:
- Source:
Returns:
The atmosphere's altitude in meters.
-
Type
-
Number
(protected) link(gl, program) → {Boolean}
Links a specified GLSL program. This method is not meant to be called by applications. It is called
internally as needed.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
program |
WebGLProgram
|
The WebGL program. |
- Inherited From:
- Source:
Returns:
true if linking was successful, otherwise false.
-
Type
-
Boolean
loadEyePoint(gl, vector)
Loads the specified vector as the value of this program's 'lightDirection' uniform variable,
the magnitude's specified vector as the value of this program's 'eyeMagnitude' uniform variable and
the squared magnitude's specified vector as the value of this program's 'eyeMagnitude2' uniform variable.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
vector |
Vec3
|
The vector to load. |
- Inherited From:
- Source:
Throws:
-
If the specified vector is null or undefined.
-
-
Type
-
ArgumentError
loadFragMode(gl, fragMode)
Loads the specified number as the value of this program's 'fragMode' uniform variable.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
fragMode |
Number
|
The frag mode value. |
- Inherited From:
- Source:
Throws:
-
If the specified number is null or undefined.
-
-
Type
-
ArgumentError
loadGlobeRadius(gl, globeRadius)
Loads the specified number as the value of this program's 'globeRadius' uniform variable and the specified
number which add the altitude value as the value of this program's 'atmosphereRadius' uniform variable.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
globeRadius |
Number
|
The globe radius value. |
- Inherited From:
- Source:
Throws:
-
If the specified number is null or undefined.
-
-
Type
-
ArgumentError
loadLightDirection(gl, vector)
Loads the specified vector as the value of this program's 'lightDirection' uniform variable.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
vector |
Vec3
|
The vector to load. |
- Inherited From:
- Source:
Throws:
-
If the specified vector is null or undefined.
-
-
Type
-
ArgumentError
loadModelviewProjection(gl, matrix)
Loads the specified matrix as the value of this program's 'mvpMatrix' uniform variable.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
matrix |
Matrix
|
The matrix to load. |
- Inherited From:
- Source:
Throws:
-
If the specified matrix is null or undefined.
-
-
Type
-
ArgumentError
loadTexMatrix(gl, matrix)
Loads the specified matrix as the value of this program's 'texCoordMatrix' uniform variable.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
matrix |
Matrix3
|
The texture coordinate matrix. |
- Inherited From:
- Source:
Loads a specified color as the value of a GLSL vec4 uniform variable with the specified location.
This function multiplies the red, green and blue components by the alpha component prior to loading the color
in the GLSL uniform variable, but does not modify the specified color.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
color |
Color
|
The color to load. |
location |
WebGLUniformLocation
|
The location of the uniform variable in the currently bound GLSL program. |
- Inherited From:
- Source:
Throws:
-
If the specified color is null or undefined.
-
-
Type
-
ArgumentError
Loads the specified RGBA color components as the value of a GLSL vec4 uniform variable with the specified
location.
This function multiplies the red, green and blue components by the alpha component prior to loading the color
in the GLSL uniform variable.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
red |
Number
|
The red component, a number between 0 and 1. |
green |
Number
|
The green component, a number between 0 and 1. |
blue |
Number
|
The blue component, a number between 0 and 1. |
alpha |
Number
|
The alpha component, a number between 0 and 1. |
location |
WebGLUniformLocation
|
The location of the uniform variable in the currently bound GLSL program. |
- Inherited From:
- Source:
Loads a specified matrix as the value of a GLSL 4x4 matrix uniform variable with the specified location.
This functions converts the matrix into column-major order prior to loading its components into the GLSL
uniform variable, but does not modify the specified matrix.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
matrix |
Matrix
|
The matrix to load. |
location |
WebGLUniformLocation
|
The location of the uniform variable in the currently bound GLSL program. |
- Inherited From:
- Source:
Throws:
-
If the specified matrix is null or undefined.
-
-
Type
-
ArgumentError
loadVertexOrigin(gl, vector)
Loads the specified vector as the value of this program's 'vertexOrigin' uniform variable.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
vector |
Vec3
|
The vector to load. |
- Inherited From:
- Source:
Throws:
-
If the specified vector is null or undefined.
-
-
Type
-
ArgumentError
setScale(gl)
Sets the program's 'scale', 'scaleDepth' and 'scaleOverScaleDepth' uniform variables.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
- Inherited From:
- Source:
Returns the GLSL uniform location of a specified uniform name.
Parameters:
Name |
Type |
Description |
gl |
WebGLRenderingContext
|
The current WebGL context. |
uniformName |
String
|
The name of the uniform variable whose location is determined. |
- Inherited From:
- Source:
Throws:
-
If the specified uniform name is null, empty or undefined.
-
-
Type
-
ArgumentError
Returns:
The WebGL uniform location of the specified uniform variable,
or -1 if the uniform is not found.
-
Type
-
WebGLUniformLocation