lib/create-attributes.js
function addVectorAttribute(gl, program, location, dimension, obj, name, doLink) {
  var constFuncArgs = [ 'gl', 'v' ]
  var varNames = []
  for(var i=0; i<dimension; ++i) {
    constFuncArgs.push('x'+i)
    varNames.push('x'+i)
  }
  constFuncArgs.push([
    'if(x0.length===void 0){return gl.vertexAttrib', dimension, 'f(v,', varNames.join(), ')}else{return gl.vertexAttrib', dimension, 'fv(v,x0)}'
  ].join(''))
  var constFunc = Function.apply(undefined, constFuncArgs)
  var attr = new ShaderAttribute(gl, program, location, dimension, name, constFunc, doLink)
  Object.defineProperty(obj, name, {
    set: function(x) {
      gl.disableVertexAttribArray(attr._location)
      constFunc(gl, attr._location, x)
      return x
    }
    , get: function() {
      return attr
    }
    , enumerable: true
  })
}
function addVectorAttribute(gl, program, location, dimension, obj, name, doLink) {
  var constFuncArgs = [ 'gl', 'v' ]
  var varNames = []
  for(var i=0; i<dimension; ++i) {
    constFuncArgs.push('x'+i)
    varNames.push('x'+i)
  }
  constFuncArgs.push([
    'if(x0.length===void 0){return gl.vertexAttrib', dimension, 'f(v,', varNames.join(), ')}else{return gl.vertexAttrib', dimension, 'fv(v,x0)}'
  ].join(''))
  var constFunc = Function.apply(undefined, constFuncArgs)
  var attr = new ShaderAttribute(gl, program, location, dimension, name, constFunc, doLink)
  Object.defineProperty(obj, name, {
    set: function(x) {
      gl.disableVertexAttribArray(attr._location)
      constFunc(gl, attr._location, x)
      return x
    }
    , get: function() {
      return attr
    }
    , enumerable: true
  })
}
function addVectorAttribute ( gl , program , location , dimension , obj , name , doLink ) { var constFuncArgs = [ 'gl' , 'v' ] var varNames = [ ] for ( var i = 0 ; i < dimension ; ++ i ) { constFuncArgs . push ( 'x' + i ) varNames . push ( 'x' + i ) } constFuncArgs . push ( [ 'if(x0.length===void 0){return gl.vertexAttrib' , dimension , 'f(v,' , varNames . join ( ) , ')}else{return gl.vertexAttrib' , dimension , 'fv(v,x0)}' ] . join ( '' ) ) var constFunc = Function . apply ( undefined , constFuncArgs ) var attr = new ShaderAttribute ( gl , program , location , dimension , name , constFunc , doLink ) Object . defineProperty ( obj , name , { set : function ( x ) { gl . disableVertexAttribArray ( attr . _location ) constFunc ( gl , attr . _location , x ) return x } , get : function ( ) { return attr } , enumerable : true } ) }
Adds a vector attribute to obj
Adds a vector attribute to obj