Namespace c3dl
Prevent name conflicts by placing c3dl variables
and functions in a javascript 'namespace'. Class adapted from
Jeremy Giberson's refactorization code.
Defined in: c3dlnamespace.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
| Field Attributes | Field Name and Description |
|---|---|
| <static> |
c3dl.COLLADA
|
| <static> <constant> |
c3dl.DEFAULT_BG_BLUE
|
| <static> <constant> |
c3dl.DEFAULT_BG_GREEN
|
| <static> <constant> |
c3dl.DEFAULT_BG_RED
|
| <static> <constant> |
c3dl.DST_ALPHA
Used to set blending factors in c3dl.ParticleSystem.
|
| <static> <constant> |
c3dl.DST_COLOR
Used to set blending factors in c3dl.ParticleSystem.
|
| <static> <constant> |
c3dl.FILL
Pass this to a renderer's setFillMode() if you want models to be
drawn 'filled in'.
|
| <static> <constant> |
c3dl.FUNC_ADD
Used to set the blending equation in c3dl.ParticleSystem.
|
| <static> <constant> |
Used to set the blending equation in c3dl.ParticleSystem.
|
| <static> <constant> |
c3dl.FUNC_SUBTRACT
Used to set the blending equation in c3dl.ParticleSystem.
|
| <static> |
c3dl.LINE
|
| <static> <constant> |
c3dl.ONE
Used to set blending factors in c3dl.ParticleSystem.
|
| <static> <constant> |
c3dl.ONE_MINUS_DST_ALPHA
Used to set blending factors in c3dl.ParticleSystem.
|
| <static> <constant> |
c3dl.ONE_MINUS_DST_COLOR
Used to set blending factors in c3dl.ParticleSystem.
|
| <static> <constant> |
c3dl.ONE_MINUS_SRC_ALPHA
Used to set blending factors in c3dl.ParticleSystem.
|
| <static> <constant> |
c3dl.ONE_MINUS_SRC_COLOR
Used to set blending factors in c3dl.ParticleSystem.
|
| <static> |
c3dl.PARTICLE_SYSTEM
|
| <static> <constant> |
This constant can be passed into the setPickingPrecision() of scene
if accuracy is not important for your script and/or you require the
picking algorithm to work as fast as possible.
|
| <static> <constant> |
This is currently the most accurate test available.
|
| <static> |
c3dl.POINT
|
| <static> <constant> |
c3dl.POINT_MODE_POINT
To render c3dl.Point objects using the built-in OpenGL
points rendering ( using circles ), pass this value to
the Scene's setPointRenderingMode() method.
|
| <static> <constant> |
c3dl.POINT_MODE_SPHERE
To render c3dl.Point objects using spheres, pass this
value to the Scene's setPointRenderingMode() method.
|
| <static> <constant> |
c3dl.SRC_ALPHA
Used to set blending factors in c3dl.ParticleSystem.
|
| <static> <constant> |
c3dl.SRC_ALPHA_SATURATE
Used to set blending factors in c3dl.ParticleSystem.
|
| <static> <constant> |
c3dl.SRC_COLOR
Used to set blending factors in c3dl.ParticleSystem.
|
| <static> <constant> |
c3dl.TOLERANCE
c3dl.TOLERANCE = 0.00001
This is used as a buffer when doing some calculations with floating point numbers. |
| <static> <constant> |
c3dl.WIRE_FRAME
Pass this to renderer's setFillMode() if you want models to be
drawn with lines.
|
| <static> <constant> |
c3dl.ZERO
Used to set blending factors in c3dl.ParticleSystem.
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
c3dl.addMainCallBack(func, tagName)
Add a function to a list of functions to call once the
page is finished loading.
|
| <static> |
c3dl.addMatrices(matOne, matTwo)
Add two matrices.
|
| <static> |
c3dl.addModel(model)
Add a model to the collada queue to be parsed
before the main funciton is run.
|
| <static> |
c3dl.addQuats(quatOne, quatTwo)
Add two quaternions.
|
| <static> |
c3dl.addVectors(vecOne, vecTwo, dest)
Add two Vectors together and place the result in dest and
return it.
|
| <static> |
c3dl.axisAngleToQuat(axisVec, angleScalar, dest)
|
| <static> |
c3dl.cartoon_callback(renderingObj)
|
| <static> |
c3dl.copyObj(object)
Create a copy of 'object' and return the copy.
|
| <static> |
c3dl.copyVector(srcVec)
Copy the Vector 'srcVec' and return it.
|
| <static> |
c3dl.copyVectorContents(srcVec, destVec)
Copy the components of srcVec Vector to destVec Vector.
|
| <static> |
c3dl.degreesToRadians(degrees)
Convert 'deg' degrees into radians.
|
| <static> |
c3dl.divideMatrixByScalar(mat, scalar)
Divide a Matrix 'mat' by a scalar value.
|
| <static> |
c3dl.divideVector(vec, scalar, dest)
Divide each component of 'vec' and store into dest and return it.
|
| <static> |
c3dl.getAngleBetweenVectors(vecOne, vecTwo)
Get the angle (in degrees) between two vectors.
|
| <static> |
c3dl.getMatrixStackHeight()
Get the number of elements in the matrix stack.
|
| <static> |
c3dl.getObjectPosition(obj)
Get the absolute position of an object in the DOM.
|
| <static> |
c3dl.getPathWithoutFilename(path)
Given a path to a file, this funciton will return the path without the
filename.
|
| <static> |
c3dl.getQuatConjugate(quat)
Get the conjugate of Quaternion 'quat'.
|
| <static> |
c3dl.getRandom(min, max)
Get a random value from min to max inclusive
|
| <static> |
c3dl.gooch_callback(renderingObj)
|
| <static> |
c3dl.inverseMatrix(mat)
Get the inverse of matrix 'mat'.
|
| <static> |
c3dl.inverseQuat(quat)
Get the inverse of the Quaternion quat.
|
| <static> |
c3dl.invSqrt(num)
Inverse of a square root.
|
| <static> |
c3dl.isContextSupported(contextVersion)
Check if the context, 'contextVersion' is supported.
|
| <static> |
c3dl.isPathAbsolute(path)
Is the given path absolute or relative?
|
| <static> |
c3dl.isValidMatrix(mat)
Is the Matrix 'mat' is valid? That is, does it contain 16
values and are all the values numbers?
|
| <static> |
c3dl.isValidQuat(quat)
Is the object 'quat' a valid Quaternion?
|
| <static> |
c3dl.isValidVector(vecArr)
Check to see if vector 'vecArr' is valid.
|
| <static> |
c3dl.isVectorEqual(vecOne, vectwo)
Compare two vectors for equality.
|
| <static> |
c3dl.isVectorZero(vec)
Check to see if a Vector is a zero vector, that is a vector with a
length of zero, or it has components close enough to zero to be
considered zero.
|
| <static> |
c3dl.loadIdentity()
Replace the top matrix with an identity matrix.
|
| <static> |
c3dl.loadMatrix(matrix)
Replace the top matrix with a specified matrix.
|
| <static> |
c3dl.lookAt(eye, center, up)
gluLookAt Implementation
|
| <static> |
c3dl.makeFrustum(left, right, bottom, top, znear, zfar)
glFrustum Implementation
|
| <static> |
c3dl.makeIdentityMatrix()
Create an identity matrix.
|
| <static> |
c3dl.makeMatrix(e00, e01, e02, e03, e10, e11, e12, e13, e20, e21, e22, e23, e30, e31, e32, e33)
Make a matrix by providing each component.
|
| <static> |
c3dl.makePerspective(fovy, aspect, znear, zfar)
Create a perspective projection matrix.
|
| <static> |
c3dl.makePoseMatrix(vecLeft, vecUp, vecFrwd, vecPos)
|
| <static> |
c3dl.makeQuat(newW, newX, newY, newZ)
Make a Quaternion from the arguments.
|
| <static> |
c3dl.makeVector(newX, newY, newZ)
Create a 3D Vector from the given 'newX', 'newY'
and 'newZ' arguments.
|
| <static> |
c3dl.makeZeroMatrix()
Create a Zero matrix, that is a matrix in which each component
of the matrix is zero.
|
| <static> |
c3dl.matricesEqual(matrix1, matrix2)
Check if two matrices are equal.
|
| <static> |
c3dl.matrixAdjoint(mat)
Get the adjoint matrix of matrix 'mat'.
|
| <static> |
c3dl.matrixDeterminant(mat)
Get the matrix determinant of 'mat'.
|
| <static> |
c3dl.matrixMode(mode)
Change the matrix mode to either model view or projection.
|
| <static> |
c3dl.matrixToQuat(newMat)
Convert a Matrix to a Quaternion.
|
| <static> |
c3dl.multiplyMatrixByDirection(mat, vec, dest)
Multiply a matrix by a direction vector
|
| <static> |
c3dl.multiplyMatrixByMatrix(matOne, matTwo, newMat)
Multiply matrix 'matOne' by 'matTwo'.
|
| <static> |
c3dl.multiplyMatrixByScalar(mat, scalar)
Multiply a given Matrix 'mat' with a scalar value.
|
| <static> |
c3dl.multiplyMatrixByVector(mat, vec, dest)
Multiply a vector 'vec' by Matrix 'mat'.
|
| <static> |
c3dl.multiplyQuatByScalar(quatOne, scalar)
Multiply the Quaternion 'quatOne' with a scalar.
|
| <static> |
c3dl.multiplyVector(vec, scalar, dest)
Multiply the specified vector by the scalar.
|
| <static> |
c3dl.multiplyVectorByVector(vecOne, vecTwo, dest)
Multiply two Vectors together, this is not a dot product or a cross
product operation.
|
| <static> |
c3dl.multMatrix(matrix)
Post multiply the matrix at the top of the stack with the
parameter 'matrix' and replace the top element with the product.
|
| <static> |
c3dl.normalizeQuat(quat)
Get the normalized Quaternion of quat.
|
| <static> |
c3dl.normalizeVector(vec)
Normalize the given Vector.
|
| <static> |
c3dl.peekMatrix()
Get the matrix at the top of the stack.
|
| <static> |
c3dl.popMatrix()
Pop the top matrix off the stack.
|
| <static> |
c3dl.pushMatrix()
create a copy of the top element and push on that copy.
|
| <static> |
c3dl.quatDotProduct(quatOne, quatTwo)
Dot Product
|
| <static> |
c3dl.quatLength(quat)
Get the length of Quaternion 'quat'.
|
| <static> |
c3dl.quatLengthSq(quat)
|
| <static> |
c3dl.quatToAxisAngle(axisVec, angleScalar)
|
| <static> |
c3dl.quatToMatrix(quat, dest)
Convert a Quaternion to a Matrix.
|
| <static> |
c3dl.radiansToDegrees(rad)
Convert 'rad' radians into degrees.
|
| <static> |
c3dl.rayIntersectsSphere(rayInitialPoint, rayDir, spherePos, sphereRadius)
Does the given ray intersect the sphere? When using this function to test
the ray created by a user click against a boundingsphere, keep the following
in mind: When trying to pick the bounding sphere the test will fail if a few
pixels from the edges of the sphere.
|
| <static> |
c3dl.scale(scaleX, scaleY, scaleZ)
Create a scale matrix from the parameters provided and call multMatrix()
with this matrix.
|
| <static> |
c3dl.setMatrix(mat, e00, e01, e02, e03, e10, e11, e12, e13, e20, e21, e22, e23, e30, e31, e32, e33)
Set the elements of a matrix.
|
| <static> |
c3dl.setSize(s)
|
| <static> |
c3dl.subtractMatrices(matOne, matTwo)
Subtract Matrix 'matTwo' from 'matOne'.
|
| <static> |
c3dl.subtractQuats(quatOne, quatTwo)
Subtract Quaternion 'quatTwo' from 'quatOne'.
|
| <static> |
c3dl.subtractVectors(vecOne, vecTwo, dest)
Subtract vector 'vecTwo' from vector 'vecOne'.
|
| <static> |
c3dl.translate(translateX, translateY, translateZ)
Create a translate matrix and call C3DL.multMatrix() passing in the
translate matrix.
|
| <static> |
c3dl.transposeMatrix(mat)
Get the transpose of matrix 'mat'.
|
| <static> |
c3dl.vectorCrossProduct(vecOne, vecTwo, dest)
Get the cross product of two Vectors.
|
| <static> |
c3dl.vectorDotProduct(vecOne, vecTwo)
Get the dot product of two vectors.
|
| <static> |
c3dl.vectorLength(vec)
Get the length of the vector 'vec'.
|
| <static> |
c3dl.vectorLengthSq(vec)
Get the squared length of the vector 'vec'.
|
| <static> |
c3dl.vectorProject(vecOne, vecTwo)
Get the result of projecting vector 'vecOne' onto 'vecTwo'.
|
Field Detail
<static>
c3dl.COLLADA
Defined in: constants.js.
<static> <constant>
c3dl.DEFAULT_BG_BLUE
Defined in: constants.js.
<static> <constant>
c3dl.DEFAULT_BG_GREEN
Defined in: constants.js.
<static> <constant>
c3dl.DEFAULT_BG_RED
Defined in: constants.js.
<static> <constant>
c3dl.DST_ALPHA
Used to set blending factors in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.DST_COLOR
Used to set blending factors in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.FILL
Pass this to a renderer's setFillMode() if you want models to be
drawn 'filled in'. Renderers will use fill mode by default.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.FUNC_ADD
Used to set the blending equation in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.FUNC_REVERSE_SUBTRACT
Used to set the blending equation in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.FUNC_SUBTRACT
Used to set the blending equation in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
<static>
c3dl.LINE
Defined in: constants.js.
<static> <constant>
c3dl.ONE
Used to set blending factors in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.ONE_MINUS_DST_ALPHA
Used to set blending factors in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.ONE_MINUS_DST_COLOR
Used to set blending factors in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.ONE_MINUS_SRC_ALPHA
Used to set blending factors in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.ONE_MINUS_SRC_COLOR
Used to set blending factors in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
<static>
c3dl.PARTICLE_SYSTEM
Defined in: constants.js.
<static> <constant>
c3dl.PICK_PRECISION_BOUNDING_VOLUME
This constant can be passed into the setPickingPrecision() of scene
if accuracy is not important for your script and/or you require the
picking algorithm to work as fast as possible. If using this value, when
a user clicks on the canvas, all objects which can be picked will only
be tested against their bounding volume.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.PICK_PRECISION_TRIANGLE
This is currently the most accurate test available. If this is passed
into the setPickingPrecision() function of scene, everytime the user clicks,
the ray generated will be tested against the triangles of each model which
pass the bounding volume test. Use this constant if accuracy is important
for your script using C3DL.
This is the default precision of each scene created.
Defined in: constants.js.
This is the default precision of each scene created.
Defined in: constants.js.
<static>
c3dl.POINT
Defined in: constants.js.
<static> <constant>
c3dl.POINT_MODE_POINT
To render c3dl.Point objects using the built-in OpenGL
points rendering ( using circles ), pass this value to
the Scene's setPointRenderingMode() method.
Note that using this method of rendering c3dl.Point objects may crash
the browser or OS.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.POINT_MODE_SPHERE
To render c3dl.Point objects using spheres, pass this
value to the Scene's setPointRenderingMode() method.
This is the default method to render c3dl.Point objects.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.SRC_ALPHA
Used to set blending factors in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.SRC_ALPHA_SATURATE
Used to set blending factors in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.SRC_COLOR
Used to set blending factors in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.TOLERANCE
c3dl.TOLERANCE = 0.00001
This is used as a buffer when doing some calculations with floating point numbers. Due to floating point innacuracy, we cannot use == on floating point numbers for comparison. Two floats which we believe to be equal may in fact not be equal, they may vary a small amount. Therefore a constant is defined here which will later be used to compare against the difference on vector component allowing some tolerance.
Defined in: constants.js.
This is used as a buffer when doing some calculations with floating point numbers. Due to floating point innacuracy, we cannot use == on floating point numbers for comparison. Two floats which we believe to be equal may in fact not be equal, they may vary a small amount. Therefore a constant is defined here which will later be used to compare against the difference on vector component allowing some tolerance.
Defined in: constants.js.
<static> <constant>
c3dl.WIRE_FRAME
Pass this to renderer's setFillMode() if you want models to be
drawn with lines. Note that using this may result in rendering of
extra lines. This should mostly used for debugging scripts such as
when drawing bounding volumes.
Defined in: constants.js.
Defined in: constants.js.
<static> <constant>
c3dl.ZERO
Used to set blending factors in c3dl.ParticleSystem.
Defined in: constants.js.
Defined in: constants.js.
Method Detail
<static>
c3dl.addMainCallBack(func, tagName)
Add a function to a list of functions to call once the
page is finished loading.
Defined in: init.js.
Defined in: init.js.
- Parameters:
- {Function} func
- - the function to call once the web page is finished loading.
- {String} tagName
- - the tag name of the canvas associated with the function.
<static>
{Array}
c3dl.addMatrices(matOne, matTwo)
Add two matrices. This will result in a matrix in which each
corresponding component of each matrix are added together.
Defined in: matrix.js.
Defined in: matrix.js.
- Parameters:
- {Array} matOne
- The first matrix.
- {Array} matTwo
- The second matrix.
- Returns:
- {Array} A Matrix which is the addition of 'matOne' and 'matTwo'.
<static>
c3dl.addModel(model)
Add a model to the collada queue to be parsed
before the main funciton is run. Call this function
once for each collada file your script will use.
Defined in: init.js.
Defined in: init.js.
- Parameters:
- {string} model
- - path to a .dae file.
<static>
{Array}
c3dl.addQuats(quatOne, quatTwo)
Add two quaternions.
Defined in: quaternion.js.
Defined in: quaternion.js.
- Parameters:
- {Array} quatOne
- {Array} quatTwo
- Returns:
- {Array} The result of adding quatOne and quatTwo.
<static>
{Array}
c3dl.addVectors(vecOne, vecTwo, dest)
Add two Vectors together and place the result in dest and
return it.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vecOne
- The first Vector.
- {Array} vecTwo
- The second Vector.
- {Array} dest Optional
- A vector which will hold the result.
- Returns:
- {Array} The resultant Vector if both were valid Vectors, otherwise returns null.
<static>
c3dl.axisAngleToQuat(axisVec, angleScalar, dest)
Defined in: quaternion.js.
- Parameters:
- axisVec
- angleScalar
- dest
<static>
c3dl.cartoon_callback(renderingObj)
Defined in: cartoon_callback.js.
- Parameters:
- renderingObj
<static>
{Object|Array}
c3dl.copyObj(object)
Create a copy of 'object' and return the copy. This works with single
dimensional Arrays and Objects.
Defined in: utilities.js.
Defined in: utilities.js.
- Parameters:
- {Object|Array} object
- The object to copy.
- Returns:
- {Object|Array} A copy of 'object'.
<static>
{Array}
c3dl.copyVector(srcVec)
Copy the Vector 'srcVec' and return it.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} srcVec
- The vector to copy.
- Returns:
- {Array} A copy of the 'srcVec' vector.
<static>
c3dl.copyVectorContents(srcVec, destVec)
Copy the components of srcVec Vector to destVec Vector.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} srcVec
- The source Vector to copy from.
- {Array} destVec
- The destination Vector to copy to.
<static>
{float}
c3dl.degreesToRadians(degrees)
Convert 'deg' degrees into radians.
Defined in: mathutils.js.
Defined in: mathutils.js.
- Parameters:
- {float} degrees
- The value in degrees to convert into radians.
- Returns:
- {float} The value of 'deg' degrees converted to radians.
<static>
{Array}
c3dl.divideMatrixByScalar(mat, scalar)
Divide a Matrix 'mat' by a scalar value. This will divide each
component of the matrix 'mat' by 'scalar' and reutrn the value.
Defined in: matrix.js.
Defined in: matrix.js.
- Parameters:
- {Array} mat
- The matrix which will be divided.
- {float} scalar
- The value which the matrix components will be divided by.
- Returns:
- {Array} The Matrix 'mat' divided by 'scalar'.
<static>
{Array}
c3dl.divideVector(vec, scalar, dest)
Divide each component of 'vec' and store into dest and return it.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vec
- The vector to divide.
- {float} scalar
- The amount to scale 'vec'.
- {Array} dest Optional
- A vector which will hold the result if provided.
- Returns:
- {Array} A vector 'vec' which has been divided by 'scalar' or returns null if 'vec' was invalid or 'scalar' was NaN.
<static>
{float}
c3dl.getAngleBetweenVectors(vecOne, vecTwo)
Get the angle (in degrees) between two vectors.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vecOne
- The first vector.
- {Array} vecTwo
- The second vector.
- Returns:
- {float} The angle in degrees between the two vectors.
<static>
{int}
c3dl.getMatrixStackHeight()
Get the number of elements in the matrix stack.
Defined in: matrixstack.js.
Defined in: matrixstack.js.
- Returns:
- {int} The number of elements in the current matrix stack.
<static>
{Array}
c3dl.getObjectPosition(obj)
Get the absolute position of an object in the DOM.
Defined in: utilities.js.
Defined in: utilities.js.
- Parameters:
- obj
- Returns:
- {Array} an array with two elements, x and y.
<static>
{String}
c3dl.getPathWithoutFilename(path)
Given a path to a file, this funciton will return the path without the
filename. If the following path was given,
http://www.site.com/images/file.jpg
this would be returned
http://www.site.com/images/
If the path is simply a filename, null will be returned.
Defined in: utilities.js.
Defined in: utilities.js.
- Parameters:
- path
- Returns:
- {String} the path the user specified without the filename.
<static>
c3dl.getQuatConjugate(quat)
Get the conjugate of Quaternion 'quat'.
Defined in: quaternion.js.
Defined in: quaternion.js.
- Parameters:
- {Array} quat
- return {Array}
<static>
{num}
c3dl.getRandom(min, max)
Get a random value from min to max inclusive
Defined in: mathutils.js.
Defined in: mathutils.js.
- Parameters:
- {num} min
- {num} max
- Returns:
- {num} a random number from min to max.
<static>
c3dl.gooch_callback(renderingObj)
Defined in: gooch_callback.js.
- Parameters:
- renderingObj
<static>
{Array}
c3dl.inverseMatrix(mat)
Get the inverse of matrix 'mat'. Matrix-matrix division is not
defined mathematically, but there is a multiplicative inverse
operation which is useful in solving some matrix equations.
Note that only matrices with a determinant not equal to zero
will have an inverse. There is no need to check if first if
the matrix has a determinant not equal to zero as this function
does that anyway.
Defined in: matrix.js.
Defined in: matrix.js.
- Parameters:
- {Array} mat
- The Matrix for which the inverse is required.
- Returns:
- {Array} The inverse of matrix 'mat' if it has one
<static>
{Array}
c3dl.inverseQuat(quat)
Get the inverse of the Quaternion quat.
Defined in: quaternion.js.
Defined in: quaternion.js.
- Parameters:
- {Array} quat
- Returns:
- {Array}
<static>
{float}
c3dl.invSqrt(num)
Inverse of a square root.
Defined in: mathutils.js.
Defined in: mathutils.js.
- Parameters:
- {float} num
- Returns:
- {float} the inverse square root of num or 0 ir num was not a number.
<static>
{boolean}
c3dl.isContextSupported(contextVersion)
Check if the context, 'contextVersion' is supported.
Defined in: utilities.js.
Defined in: utilities.js.
- Parameters:
- {float} contextVersion
- must be c3dl.GLES_CONTEXT_20
- Returns:
- {boolean} True if the context 'contextVersion' is supported or false if it's not supported or the 'contextVersion' number was invalid.
<static>
{boolean}
c3dl.isPathAbsolute(path)
Is the given path absolute or relative?
Defined in: utilities.js.
Defined in: utilities.js.
- Parameters:
- path
- Returns:
- {boolean} true if the path is absolute false if relative
<static>
{boolean}
c3dl.isValidMatrix(mat)
Is the Matrix 'mat' is valid? That is, does it contain 16
values and are all the values numbers?
Defined in: matrix.js.
Defined in: matrix.js.
- Parameters:
- {Array} mat
- The matrix to check.
- Returns:
- {boolean} True if the object 'mat' is a matrix, false otherwise.
<static>
{boolean}
c3dl.isValidQuat(quat)
Is the object 'quat' a valid Quaternion?
Defined in: quaternion.js.
Defined in: quaternion.js.
- Parameters:
- {Array} quat
- Returns:
- {boolean} True if 'quat' is a valid Quaternion, false otherwise.
<static>
{boolean}
c3dl.isValidVector(vecArr)
Check to see if vector 'vecArr' is valid. That is, if it
has the correct amount of components, is the right type and has
the correct types.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vecArr
- The vector to check.
- Returns:
- {boolean} True if the 'vecArr' is valid, false otherwise.
<static>
{boolean}
c3dl.isVectorEqual(vecOne, vectwo)
Compare two vectors for equality. Two Vectors are said to be equal
if all their components are equal.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vecOne
- Vector one.
- {Array} vectwo
- Vector two.
- Returns:
- {boolean} True if both vectors are equal, null otherwise.
<static>
{boolean}
c3dl.isVectorZero(vec)
Check to see if a Vector is a zero vector, that is a vector with a
length of zero, or it has components close enough to zero to be
considered zero. 'Close enough' is considered true if the components
lie between the -TOLERANCE and +TOLERANCE constant.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vec
- The Vector to check.
- Returns:
- {boolean} True if the vector is considered a zero vector, false otherwise.
<static>
c3dl.loadIdentity()
Replace the top matrix with an identity matrix. This can also
be accomplished by calling C3DL.loadMatrix() passing in zero
arguments.
Defined in: matrixstack.js.
Defined in: matrixstack.js.
<static>
c3dl.loadMatrix(matrix)
Replace the top matrix with a specified matrix. If paramter is
not provided, an identity matrix will replace the top matrix.
Defined in: matrixstack.js.
Defined in: matrixstack.js.
- Parameters:
- {Array} matrix Optional
- The matrix which will replace the element at the top of the stack. If omitted, it will replace the top element with an identity matrix.
<static>
{Array}
c3dl.lookAt(eye, center, up)
gluLookAt Implementation
Defined in: mathutils.js.
Defined in: mathutils.js.
- Parameters:
- {Array} eye
- The location of the camera.
- {Array} center
- Where the camera is looking at.
- {Array} up
- A Vector which represents the camera's up vector.
- Returns:
- {Array} the lookat matrix or null if one of the arguments were not valid Vectors.
<static>
{Array}
c3dl.makeFrustum(left, right, bottom, top, znear, zfar)
glFrustum Implementation
Defined in: mathutils.js.
Defined in: mathutils.js.
- Parameters:
- {float} left
- The coordinate of the left vertical clipping plane.
- {float} right
- The coordinate of the right vertical clipping plane.
- {float} bottom
- The coordinate of the bottom horizontal clipping plane.
- {float} top
- The coordinate of the top horizontal clipping plane.
- {float} znear
- The distance to the near clipping plane.
- {float} zfar
- The distance to the far clipping plane.
- Returns:
- {Array} A perspective projection matrix.
<static>
{Array}
c3dl.makeIdentityMatrix()
Create an identity matrix. An identity matrix is a matrix in
which all the elements are zero, save on the main diagonal
where all elements are ones.
Example:
Defined in: matrix.js.
Example:
+- -+ | 1, 0, 0, 0 | | 0, 1, 0, 0 | | 0, 0, 1, 0 | | 0, 0, 0, 1 | +- -+An identity matrix is equivalent to the number one in some respects, that is multiplying matrix M by an identity matrix will yield M. Matrix multiplication with an identity matrix is one case in which matrix multiplication is commutative. M * I = M I * M = M
Defined in: matrix.js.
- Returns:
- {Array} An identity matrix.
<static>
{Array}
c3dl.makeMatrix(e00, e01, e02, e03, e10, e11, e12, e13, e20, e21, e22, e23, e30, e31, e32, e33)
Make a matrix by providing each component. Supply the values in colum-major order.
Indices:
Defined in: matrix.js.
Indices:
+- -+ | 0, 4, 8, 12 | | 1, 5, 9, 13 | | 2, 6, 10, 14 | | 3, 7, 11, 15 | +- -+
Defined in: matrix.js.
- Parameters:
- {float} e00
- Element at row 0 column 0.
- {float} e01
- Element at row 1 column 0.
- {float} e02
- Element at row 2 column 0.
- {float} e03
- Element at row 3 column 0.
- {float} e10
- Element at row 0 column 1.
- {float} e11
- Element at row 1 column 1.
- {float} e12
- Element at row 2 column 1.
- {float} e13
- Element at row 3 column 1.
- {float} e20
- Element at row 0 column 2.
- {float} e21
- Element at row 1 column 2.
- {float} e22
- Element at row 2 column 2.
- {float} e23
- Element at row 3 column 2.
- {float} e30
- Element at row 0 column 3.
- {float} e31
- Element at row 1 column 3.
- {float} e32
- Element at row 2 column 3.
- {float} e33
- Element at row 3 column 3.
- Returns:
- {Array} A matrix defined by the provided arguments.
<static>
{Array}
c3dl.makePerspective(fovy, aspect, znear, zfar)
Create a perspective projection matrix.
Defined in: mathutils.js.
Defined in: mathutils.js.
- Parameters:
- {float} fovy
- The field of view angle in degrees in the Y direction.
- {float} aspect
- The aspect ratio
- {float} znear
- The distance from the viewer to the near clipping plane.
- {float} zfar
- The distance from the viewer to the far clipping plane.
- Returns:
- {Array} A perspective projection matrix.
<static>
c3dl.makePoseMatrix(vecLeft, vecUp, vecFrwd, vecPos)
Defined in: matrix.js.
- Parameters:
- vecLeft
- vecUp
- vecFrwd
- vecPos
<static>
{Array}
c3dl.makeQuat(newW, newX, newY, newZ)
Make a Quaternion from the arguments.
Defined in: quaternion.js.
Defined in: quaternion.js.
- Parameters:
- {float} newW
- {float} newX
- {float} newY
- {float} newZ
- Returns:
- {Array} A Quaternion defined by the passed in arguments.
<static>
{Array}
c3dl.makeVector(newX, newY, newZ)
Create a 3D Vector from the given 'newX', 'newY'
and 'newZ' arguments.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {float} newX
- The x value.
- {float} newY
- The y value.
- {float} newZ
- The z value.
- Returns:
- {Array} A 3D Vector with the components specified by the three arguments.
<static>
{Array}
c3dl.makeZeroMatrix()
Create a Zero matrix, that is a matrix in which each component
of the matrix is zero.
Defined in: matrix.js.
Defined in: matrix.js.
- Returns:
- {Array} A zero matrix.
<static>
{boolean}
c3dl.matricesEqual(matrix1, matrix2)
Check if two matrices are equal. Assumes for performance reasons
that the matrices passed in are valid. Two matrices are equal if
they're corresponding components are equal or their difference is
less than TOLERANCE. This tolerance is simply a small number used
as a buffer due to floating point inaccuracies.
Defined in: matrix.js.
Defined in: matrix.js.
- Parameters:
- {Array} matrix1
- The first matrix.
- {Array} matrix2
- The second matrix.
- Returns:
- {boolean} True if matrices are equal, false otherwise.
<static>
{Array}
c3dl.matrixAdjoint(mat)
Get the adjoint matrix of matrix 'mat'.
Defined in: matrix.js.
Defined in: matrix.js.
- Parameters:
- {Array} mat
- The matrix which the adjoint is required.
- Returns:
- {Array} the adjoint matrix of 'mat' if it was valid, otherwise returns null.
<static>
{float}
c3dl.matrixDeterminant(mat)
Get the matrix determinant of 'mat'.
Defined in: matrix.js.
Defined in: matrix.js.
- Parameters:
- {Array} mat
- The matrix for which the determinant is required.
- Returns:
- {float} The matrix determinant of 'mat' or null if 'mat' is invalid.
<static>
c3dl.matrixMode(mode)
Change the matrix mode to either model view or projection.
Defined in: matrixstack.js.
Defined in: matrixstack.js.
- Parameters:
- {c3dl.PROJECTION | c3dl.MODELVIEW} mode
<static>
{Array}
c3dl.matrixToQuat(newMat)
Convert a Matrix to a Quaternion.
Defined in: quaternion.js.
Defined in: quaternion.js.
- Parameters:
- {Array} newMat
- Returns:
- {Array}
<static>
{Array}
c3dl.multiplyMatrixByDirection(mat, vec, dest)
Multiply a matrix by a direction vector
Defined in: matrix.js.
Defined in: matrix.js.
- Parameters:
- {Array} mat
- {Array} vec
- {Array} dest
- Returns:
- {Array} vector
<static>
{Array}
c3dl.multiplyMatrixByMatrix(matOne, matTwo, newMat)
Multiply matrix 'matOne' by 'matTwo'.
Defined in: matrix.js.
Defined in: matrix.js.
- Parameters:
- {Array} matOne
- {Array} matTwo
- newMat
- Returns:
- {Array} The result of multiplying 'matOne' by 'matTwo'.
<static>
{Array}
c3dl.multiplyMatrixByScalar(mat, scalar)
Multiply a given Matrix 'mat' with a scalar value. This will result
in a matrix which has each component in 'mat' multiplied with 'scalar'.
Defined in: matrix.js.
Defined in: matrix.js.
- Parameters:
- {Array} mat
- The matrix to "scale".
- {float} scalar
- The value which will be multiplied by each component of 'mat'.
- Returns:
- {Array} The Matrix 'mat', with each component multiplied by 'scalar'.
<static>
{Array}
c3dl.multiplyMatrixByVector(mat, vec, dest)
Multiply a vector 'vec' by Matrix 'mat'. This results in a vector
which the elements are found by calculatig the dot product of the
column vectors of 'mat' by 'vec'.
If 'vec' is an array of 3 values, the last component, w will be assumed to be 1. If 'vec'
is an array of 4 values, dest must also be an array of 4 values.
Defined in: matrix.js.
Defined in: matrix.js.
- Parameters:
- {Array} mat
- The matrix, an array of 16 values.
- {Array} vec
- Array of 3 or 4 values. If last component, W is not present, W=1 will be assumed. Also, if the Array has 3 elements, the return value will be 3 elements. If the array has 4 elements, the return value will have 4 elements.
- {Array} dest
- Optional return by reference.
- Returns:
- {Array} The vector 'vec' multiplied by matrix 'mat' if both arguments were valid, otherwise returns null.
<static>
{Array}
c3dl.multiplyQuatByScalar(quatOne, scalar)
Multiply the Quaternion 'quatOne' with a scalar.
Defined in: quaternion.js.
Defined in: quaternion.js.
- Parameters:
- {Array} quatOne
- {float} scalar
- Returns:
- {Array}
<static>
{Array}
c3dl.multiplyVector(vec, scalar, dest)
Multiply the specified vector by the scalar. Place the result
in 'dest' and return it. This operation will multiply the scalar
by each component of the vector, effectively scaling it, making it
geometrically longer or shorter. If the scalar value is negative,
the result will point in the opposite direction of 'vec'.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vec
- The vector to scale.
- {float} scalar
- The amount to scale the vector.
- {Array} dest Optional
- A vector which will hold the result if provided.
- Returns:
- {Array} A vector 'vec' which has been scaled by 'scalar' or returns null if 'vec' was invalid or 'scalar' was not a number.
<static>
{Array}
c3dl.multiplyVectorByVector(vecOne, vecTwo, dest)
Multiply two Vectors together, this is not a dot product or a cross
product operation. Instead, each corresponding component of each of
the vectors are multiplied together
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vecOne
- Vector one.
- {Array} vecTwo
- Vector two.
- {Array} dest Optional
- The destination will contain the result of the operation.
- Returns:
- {Array} A Vector which is the result of multiplying each component together or null if one of the vectors where not valid Vectors.
<static>
c3dl.multMatrix(matrix)
Post multiply the matrix at the top of the stack with the
parameter 'matrix' and replace the top element with the product.
Defined in: matrixstack.js.
Defined in: matrixstack.js.
- Parameters:
- {Array} matrix
- The matrix which will be post multiplied with the top matrix.
<static>
{Array}
c3dl.normalizeQuat(quat)
Get the normalized Quaternion of quat.
Defined in: quaternion.js.
Defined in: quaternion.js.
- Parameters:
- {Array} quat
- Returns:
- {Array}
<static>
{Array}
c3dl.normalizeVector(vec)
Normalize the given Vector. A normalized Vector points in the same direction
as the original, yet has a length of 1.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vec
- The Vector to normalize.
- Returns:
- {Array} The normalized Vector if the argument is a Vector object, otherwise returns nulls.
<static>
{Array}
c3dl.peekMatrix()
Get the matrix at the top of the stack.
Defined in: matrixstack.js.
Defined in: matrixstack.js.
- Returns:
- {Array} The matrix at the top of the matrix stack.
<static>
c3dl.popMatrix()
Pop the top matrix off the stack. If there is only one matrix
left in the stack, this function does nothing.
Defined in: matrixstack.js.
Defined in: matrixstack.js.
<static>
c3dl.pushMatrix()
create a copy of the top element and push on that copy. This results
in the first two element being identical. This is simply emulating what
OpenGL does.
Defined in: matrixstack.js.
Defined in: matrixstack.js.
<static>
{float}
c3dl.quatDotProduct(quatOne, quatTwo)
Dot Product
Defined in: quaternion.js.
Defined in: quaternion.js.
- Parameters:
- {Array} quatOne
- {Array} quatTwo
- Returns:
- {float}
<static>
{float}
c3dl.quatLength(quat)
Get the length of Quaternion 'quat'.
Defined in: quaternion.js.
Defined in: quaternion.js.
- Parameters:
- {Array} quat
- Returns:
- {float} The length 'quat' or null if 'quat' was not a valid Quaternion.
<static>
{float}
c3dl.quatLengthSq(quat)
Defined in: quaternion.js.
- Parameters:
- {Array} quat
- Returns:
- {float}
<static>
c3dl.quatToAxisAngle(axisVec, angleScalar)
Defined in: quaternion.js.
- Parameters:
- {Array} axisVec
- {float} angleScalar
<static>
{Array}
c3dl.quatToMatrix(quat, dest)
Convert a Quaternion to a Matrix.
Defined in: quaternion.js.
Defined in: quaternion.js.
- Parameters:
- {Array} quat
- {Array} dest
- Returns:
- {Array} A matrix
<static>
{float}
c3dl.radiansToDegrees(rad)
Convert 'rad' radians into degrees.
Defined in: mathutils.js.
Defined in: mathutils.js.
- Parameters:
- {float} rad
- The value in radians to convert into degrees.
- Returns:
- {float} The value of 'rad' radians converted to degrees.
<static>
{boolean}
c3dl.rayIntersectsSphere(rayInitialPoint, rayDir, spherePos, sphereRadius)
Does the given ray intersect the sphere? When using this function to test
the ray created by a user click against a boundingsphere, keep the following
in mind: When trying to pick the bounding sphere the test will fail if a few
pixels from the edges of the sphere. Either it will seem that the test is passing
when it should not or the test is failing when it should should pass.
This could be because the 'pixel point' associated with the cursor is not at the
very tip of the cursor where it is expected it to be. This occurs on osx.
Defined in: picking.js.
Defined in: picking.js.
- Parameters:
- {Array} rayInitialPoint
- The initial point of the ray in world space.
- {Array} rayDir
- A normalized vector which has the ray's direction.
- {Array} spherePos
- position of the sphere.
- {float} sphereRadius
- radius of the sphere.
- Returns:
- {boolean} true if the given ray intersects the boundingsphere, otherwise false.
<static>
c3dl.scale(scaleX, scaleY, scaleZ)
Create a scale matrix from the parameters provided and call multMatrix()
with this matrix.
Defined in: matrixstack.js.
Defined in: matrixstack.js.
- Parameters:
- {float} scaleX
- Scaling factor for the x component.
- {float} scaleY
- Scaling factor for the y component.
- {float} scaleZ
- Scaling factor for the z component.
<static>
c3dl.setMatrix(mat, e00, e01, e02, e03, e10, e11, e12, e13, e20, e21, e22, e23, e30, e31, e32, e33)
Set the elements of a matrix. Supply the values in column-major
ordering.
e[r][c], e01 = row 0, column 1
Defined in: matrix.js.
Defined in: matrix.js.
- Parameters:
- {Array} mat
- The matrix to set
- {float} e00
- Column 0, Row 0
- {float} e01
- {float} e02
- {float} e03
- {float} e10
- Column 1, Row 0
- {float} e11
- {float} e12
- {float} e13
- {float} e20
- Column 2, Row 0
- {float} e21
- {float} e22
- {float} e23
- {float} e30
- Column 3, Row 0
- {float} e31
- {float} e32
- {float} e33
<static>
c3dl.setSize(s)
Defined in: particle.js.
- Parameters:
- s
<static>
{Array}
c3dl.subtractMatrices(matOne, matTwo)
Subtract Matrix 'matTwo' from 'matOne'. This will result in a
matrix in which each component of 'matTwo' is subtracted from
Matrix 'matOne.
Defined in: matrix.js.
Defined in: matrix.js.
- Parameters:
- {Array} matOne
- The matrix which is being subtracted from.
- {Array} matTwo
- The matrix which is matOne is being subtracted from.
- Returns:
- {Array} A matrix which is 'matTwo' subtracted from 'matOne'.
<static>
{Array}
c3dl.subtractQuats(quatOne, quatTwo)
Subtract Quaternion 'quatTwo' from 'quatOne'.
Defined in: quaternion.js.
Defined in: quaternion.js.
- Parameters:
- {Array} quatOne
- {Array} quatTwo
- Returns:
- {Array}
<static>
{Array}
c3dl.subtractVectors(vecOne, vecTwo, dest)
Subtract vector 'vecTwo' from vector 'vecOne'.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vecOne
- The Vector to subtract from.
- {Array} vecTwo
- The Vector which is used to subtract.
- {Array} dest Optional
- The Vector which will contains the resultant.
- Returns:
- {Array} The resultant Vector, which is the first vector minus the second. If one of the vector were not valid, returns null.
<static>
c3dl.translate(translateX, translateY, translateZ)
Create a translate matrix and call C3DL.multMatrix() passing in the
translate matrix.
Defined in: matrixstack.js.
Defined in: matrixstack.js.
- Parameters:
- {float} translateX
- The translation for the x component.
- {float} translateY
- The translation for the y component.
- {float} translateZ
- The translation for the z component.
<static>
{Array}
c3dl.transposeMatrix(mat)
Get the transpose of matrix 'mat'. A transposed matrix is created
by interchanging the rows and columns of a matrix.
Transposing the following matrix,
Defined in: matrix.js.
+- -+ | A, B, C, D | | E, F, G, H | | I, J, K, L | | M, N, O, P | +- -+would yield:
+- -+ | A, E, I, M | | B, F, J, N | | C, G, K, O | | D, H, L, P | +- -+
Defined in: matrix.js.
- Parameters:
- {Array} mat
- Matrix to transpose.
- Returns:
- {Array} The transposed matrix if the passed in matrix was valid, otherwise returns null.
<static>
{Array}
c3dl.vectorCrossProduct(vecOne, vecTwo, dest)
Get the cross product of two Vectors. The cross product is a Vector which
is perpendicular to both the first and second vector.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vecOne
- The first vector.
- {Array} vecTwo
- The second vector.
- dest
- Returns:
- {Array} The cross product of 'vecOne' and 'vecTwo'.
<static>
{float}
c3dl.vectorDotProduct(vecOne, vecTwo)
Get the dot product of two vectors.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vecOne
- The first vector.
- {Array} vecTwo
- The second vector.
- Returns:
- {float} The dot product of the two specified Vectors. If one of the Vectors was invalid, returns null.
<static>
{float}
c3dl.vectorLength(vec)
Get the length of the vector 'vec'.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vec
- The vector for which the length is needed.
- Returns:
- {float} The length of the vector 'vec'.
<static>
{float}
c3dl.vectorLengthSq(vec)
Get the squared length of the vector 'vec'.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vec
- The vector for which the squared length is required.
- Returns:
- {float} The 'length' of each component of 'vec' added together.
<static>
{Array}
c3dl.vectorProject(vecOne, vecTwo)
Get the result of projecting vector 'vecOne' onto 'vecTwo'.
Defined in: vector.js.
Defined in: vector.js.
- Parameters:
- {Array} vecOne
- {Array} vecTwo
- Returns:
- {Array} result of projecting vector 'vecOne' onto 'vecTwo'.