Documentation generator: JsDoc Toolkit 2.4.0
Template: Codeview 1.2
Generated on: 2012-11-19 0:05

Namespace SpiderGL.Utility

The SpiderGL.Utility namespace.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
The SpiderGL.Utility namespace.

Method Summary

Method Attributes Method Name and Description
<static>  
SpiderGL.Utility.getAttrib4fv(x)
Converts the input arguments to a 4-component Float32Array.
<static>  
SpiderGL.Utility.getDefaultObject(defaultObj, obj)
Gets default values for objects.
<static>  
SpiderGL.Utility.getDefaultValue(arg, defaultValue)
Gets default value for varibles.
<static>  
SpiderGL.Utility.getTime()
Gets the number of milliseconds elapsed since January 1, 1970 at 00:00.
<static>  
SpiderGL.Utility.setDefaultValues(defaultObj, obj)
Sets default values for the passed object.
<static>  
SpiderGL.Utility.Timer()

Namespace Detail

SpiderGL.Utility
The SpiderGL.Utility namespace.

Method Detail

  • <static> {array} SpiderGL.Utility.getAttrib4fv(x)
    Converts the input arguments to a 4-component Float32Array. The input value is handled like WebGL handles constant vertex attributes, that is, if the input parameter is null, a number, or an array with less than four components, missing values are taken from the array [0, 0, 0, 1] at the respective position.
    x = SpiderGL.Utility.getAttrib4fv();                        // x = [0, 0, 0, 1]
    x = SpiderGL.Utility.getAttrib4fv(null);                    // x = [0, 0, 0, 1]
    x = SpiderGL.Utility.getAttrib4fv(undefined);               // x = [0, 0, 0, 1]
    x = SpiderGL.Utility.getAttrib4fv(0);                       // x = [0, 0, 0, 1]
    x = SpiderGL.Utility.getAttrib4fv(7);                       // x = [7, 0, 0, 1]
    x = SpiderGL.Utility.getAttrib4fv([]);                      // x = [0, 0, 0, 1]
    x = SpiderGL.Utility.getAttrib4fv([1]);                     // x = [1, 0, 0, 1]
    x = SpiderGL.Utility.getAttrib4fv([1, 2]);                  // x = [1, 2, 0, 1]
    x = SpiderGL.Utility.getAttrib4fv([1, 2, 3]);               // x = [1, 2, 3, 1]
    x = SpiderGL.Utility.getAttrib4fv([1, 2, 3, 4, 5, 6]);      // x = [1, 2, 3, 4]
    x = SpiderGL.Utility.getAttrib4fv(new Float32Array([0,9]);  // x = [0, 9, 0, 1]
    Parameters:
    {null|undefined|number|array|Float32Array} x
    The input value.
    Returns:
    {array} a 4-component array.
  • <static> {object} SpiderGL.Utility.getDefaultObject(defaultObj, obj)
    Gets default values for objects.
    Parameters:
    {object} defaultObj
    The object containing the default values.
    {object} obj
    The object from which values are extracted.
    Returns:
    {object} The modified defaultObj.
  • <static> {any} SpiderGL.Utility.getDefaultValue(arg, defaultValue)
    Gets default value for varibles. This function is used to get default values for optional variables. If arg is undefined or is SpiderGL.Core.DEFAULT, then defaultValue will be returned. Otherwise, arg will be returned.
    var DEFAULT_V = 1;
    
    var v = null;
    v = SpiderGL.Utility.getDefaultValue(someVar, DEFAULT_V); // someVar is undefined, so v = DEFAULT_V
    
    var someVar = 2;
    v = SpiderGL.Utility.getDefaultValue(someVar, DEFAULT_V); // someVar is defined, so v = someVar
    
    var someVar = SpiderGL.Core.DEFAULT;
    v = SpiderGL.Utility.getDefaultValue(someVar, DEFAULT_V); // someVar is SpiderGL.Core.DEFAULT, so v = DEFAULT_V
    var DEFAULT_Y = 1;
    var DEFAULT_Z = 2;
    
    function setObject(obj, x, options) {
      options = options || { }; // create an empty object to avoid testing for null
      obj.x = x;
      obj.y = SpiderGL.Utility.getDefaultValue(options.y, DEFAULT_Y);
      obj.z = SpiderGL.Utility.getDefaultValue(options.z, DEFAULT_Z);
    }
    
    var obj = {
      x : 0,
      y : 1,
      z : 2
    };
    
    setObject(obj, 3);        // obj = { x:3, y:DEFAULT_Y, z:DEFAULT_Z }
    setObject(obj, 4, {z:5}); // obj = { x:4, y:DEFAULT_Y, z:5         }
    Parameters:
    arg
    defaultValue
    Returns:
    {any} Returns arg if arg is not undefined and is not SpiderGL.Core.DEFAULT, otherwise returns defaultValue.
  • <static> {number} SpiderGL.Utility.getTime()
    Gets the number of milliseconds elapsed since January 1, 1970 at 00:00. It is a utility function for (new Date()).getTime().
    Returns:
    {number} The number of milliseconds elapsed since January 1, 1970 at 00:00.
  • <static> {object} SpiderGL.Utility.setDefaultValues(defaultObj, obj)
    Sets default values for the passed object.
    Parameters:
    {object} defaultObj
    The object containing the default values.
    {object} obj
    The object from which values are extracted.
    Returns:
    {object} The modified obj. If obj is null, defaultObj will be returned.
  • <static> SpiderGL.Utility.Timer()