Members
a_coords_loc :GLuint
Type:
- GLuint
- Source:
- See:
a_normal_loc :GLuint
Type:
- GLuint
- Source:
a_tangent_loc :GLuint
Type:
- GLuint
- Source:
a_texCoords_loc :GLuint
Type:
- GLuint
- Source:
bumpmap :WebGLTexture
Type:
- WebGLTexture
- Source:
(constant) bumpmapURLs :Array.<String>
Type:
- Array.<String>
- Source:
canvas :CanvasRenderingContext2D
Type:
- CanvasRenderingContext2D
- Source:
(constant) colors :Array.<Array.<Number>>
Type:
- Array.<Array.<Number>>
- Source:
gl :WebGLRenderingContext
Type:
- WebGLRenderingContext
- Source:
modelview :mat3
Type:
- mat3
- Source:
(constant) normalMatrix :mat3
Type:
- mat3
- Source:
(constant) objects :Array.<model>
Type:
- Array.<model>
- Source:
(constant) projection :mat4
Type:
- mat4
- Source:
rotator :TrackballRotator
Type:
- Source:
texture :WebGLTexture
Type:
- WebGLTexture
- Source:
u_bumpmap :WebGLUniformLocation
Type:
- WebGLUniformLocation
- Source:
u_bumpmapSize :WebGLUniformLocation
Type:
- WebGLUniformLocation
- Source:
u_bumpmapStrength :WebGLUniformLocation
Type:
- WebGLUniformLocation
- Source:
u_lights :WebGLUniformLocation
Type:
- WebGLUniformLocation
- Source:
u_material :WebGLUniformLocation
Type:
- WebGLUniformLocation
- Source:
u_modelview :WebGLUniformLocation
Type:
- WebGLUniformLocation
- Source:
- See:
u_normalMatrix :WebGLUniformLocation
Type:
- WebGLUniformLocation
- Source:
u_projection :WebGLUniformLocation
Type:
- WebGLUniformLocation
- Source:
u_texture :WebGLUniformLocation
Type:
- WebGLUniformLocation
- Source:
u_useTexture :WebGLUniformLocation
Type:
- WebGLUniformLocation
- Source:
Methods
createModel(modelData) → {model}
Create an object representing an IFS model.
The modelData holds the data for an IFS using the structure from basic-object-models-with-tangents-IFS.js.This function creates VBOs to hold the coordinates, normal vectors, tangent vectors,
texture coordinates and indices from the IFS. It also loads the data into those buffers.
The function creates a new object whose properties are the identifiers of the VBOs.
The new object also has a function, render, that can be called to
render the object, using all the data from the buffers.
That object is returned as the value of the function.
Parameters:
Name | Type | Description |
---|---|---|
modelData |
Object.<{vertexPositions: Float32Array, vertexNormals: Float32Array, vertexTextureCoords: Float32Array, vertexTangents:Float32Array, indices: Uint16Array}> |
Properties:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
model |
object |
Properties
|
- Source:
Returns:
- Type
- model
createProgram(gl, vShader, fShader)
Creates a program for use in the WebGL context gl, and returns the identifier for that program.
If an error occurs while compiling or linking the program, an exception of type Error is thrown. The error string contains the compilation or linking error.If no error occurs, the program identifier is the return value of the function. The second and third parameters are strings that contain the source code for the vertex shader and for the fragment shader.
Parameters:
Name | Type | Description |
---|---|---|
gl |
WebGLProgram | WebGL context. |
vShader |
WebGLShader | vertex shader. |
fShader |
WebGLShader | fragment shade. |
- Source:
cube(side) → {Object.<{vertexPositions: Float32Array, vertexNormals: Float32Array, vertexTextureCoords: Float32Array, vertexTangents: Float32Array, indices: Uint16Array}>}
Parameters:
Name | Type | Description |
---|---|---|
side |
Number | the length of a side of the cube. If not given, the value will be 1. |
Returns:
- Type
- Object.<{vertexPositions: Float32Array, vertexNormals: Float32Array, vertexTextureCoords: Float32Array, vertexTangents: Float32Array, indices: Uint16Array}>
draw()
- Source:
init()
- Source:
initGL()
Initialize the WebGL context.
Called from init.- Source:
loadBumpmap()
- Source:
setDiffuse()
- Source:
uvCone(radius, height, slices, noBottom) → {Object.<{vertexPositions:Float32Array, vertexNormals:Float32Array, vertexTextureCoords:Float32Array, vertexTangents: Float32Array, indices:Uint16Array}>}
Parameters:
Name | Type | Description |
---|---|---|
radius |
Number | the radius of the cone. |
height |
Number | the height of the cone. The cone extends from -height/2 to height/2 along the z-axis, with the tip at (0,0,height/2). |
slices |
Number | the number of slices, like the slices of an orange. |
noBottom |
Boolean | if missing or false, the cone has a bottom;
if set to true, the cone does not have a bottom. The bottom is a disk at the wide end of the cone. |
Returns:
- Type
- Object.<{vertexPositions:Float32Array, vertexNormals:Float32Array, vertexTextureCoords:Float32Array, vertexTangents: Float32Array, indices:Uint16Array}>
uvCylinder(radius, height, slices, noTop, noBottom) → {Object.<{vertexPositions: Float32Array, vertexNormals: Float32Array, vertexTextureCoords: Float32Array, vertexTangents: Float32Array, indices: Uint16Array}>}
Parameters:
Name | Type | Description |
---|---|---|
radius |
Number | the radius of the cylinder |
height |
Number | the height of the cylinder. The cylinder extends from -height/2 to height/2 along the z-axis. |
slices |
Number | the number of slices, like the slices of an orange. |
noTop |
Boolean | if missing or false, the cylinder has a top; if set to true, the cylinder does not have a top. The top is a disk at the positive end of the cylinder. |
noBottom |
Boolean | if missing or false, the cylinder has a bottom; if set to true, the cylinder does not have a bottom. The bottom is a disk at the negtive end of the cylinder. |
Returns:
- Type
- Object.<{vertexPositions: Float32Array, vertexNormals: Float32Array, vertexTextureCoords: Float32Array, vertexTangents: Float32Array, indices: Uint16Array}>
uvSphere(radius, slices, stacks) → {Object.<{vertexPositions:Float32Array, vertexNormals:Float32Array, vertexTextureCoords:Float32Array, vertexTangents: Float32Array, indices:Uint16Array}>}
Create a model of a sphere.
The z-axis is the axis of the sphere, with the north pole on the positive z-axis and the center at (0,0,0).Parameters:
Name | Type | Description |
---|---|---|
radius |
Number | the radius of the sphere, default 0.5 if not specified. |
slices |
Number | the number of lines of longitude, default 32 |
stacks |
Number | the number of lines of latitude plus 1, default 16. (This is the number of vertical slices, bounded by lines of latitude, the north pole and the south pole.) |
Returns:
- Type
- Object.<{vertexPositions:Float32Array, vertexNormals:Float32Array, vertexTextureCoords:Float32Array, vertexTangents: Float32Array, indices:Uint16Array}>
uvTorus(outerRadius, innerRadius, slices, stacks) → {Object.<{vertexPositions: Float32Array, vertexNormals: Float32Array, vertexTextureCoords: Float32Array, vertexTangents: Float32Array, indices: Uint16Array}>}
Parameters:
Name | Type | Description |
---|---|---|
outerRadius |
Number | the distance from the center to the outside of the tube, 0.5 if not specified. |
innerRadius |
Number | the distance from the center to the inside of the tube, outerRadius/3 if not specified. (This is the radius of the doughnut hole.) |
slices |
Number | the number of lines of longitude, default 32. These are slices parallel to the z-axis and go around the tube the short way (through the hole). |
stacks |
Number | the number of lines of latitude plus 1, default 16. These lines are perpendicular to the z-axis and go around the tube the long way (arouind the hole). |
Returns:
- Type
- Object.<{vertexPositions: Float32Array, vertexNormals: Float32Array, vertexTextureCoords: Float32Array, vertexTangents: Float32Array, indices: Uint16Array}>
Type Definitions
render()
This function will render the object.
Since the buffer from which we are taking the coordinates and normals change each time an object is drawn,we have to use gl.vertexAttribPointer to specify the location of the data.
To accomplish that, we must first bind the buffer that contains the data.
Similarly, we have to bind this object's index buffer before calling gl.drawElements.
- Source: