src/draw.js
function drawBufferInfo(gl, bufferInfo, type, count, offset, instanceCount) {
  type = type === undefined ? gl.TRIANGLES : type;
  const indices = bufferInfo.indices;
  const elementType = bufferInfo.elementType;
  const numElements = count === undefined ? bufferInfo.numElements : count;
  offset = offset === undefined ? 0 : offset;
  if (elementType || indices) {
    if (instanceCount !== undefined) {
      gl.drawElementsInstanced(type, numElements, elementType === undefined ? gl.UNSIGNED_SHORT : bufferInfo.elementType, offset, instanceCount);
    } else {
      gl.drawElements(type, numElements, elementType === undefined ? gl.UNSIGNED_SHORT : bufferInfo.elementType, offset);
    }
  } else {
    if (instanceCount !== undefined) {
      gl.drawArraysInstanced(type, offset, numElements, instanceCount);
    } else {
      gl.drawArrays(type, offset, numElements);
    }
  }
}
function drawBufferInfo(gl, bufferInfo, type, count, offset, instanceCount) {
  type = type === undefined ? gl.TRIANGLES : type;
  const indices = bufferInfo.indices;
  const elementType = bufferInfo.elementType;
  const numElements = count === undefined ? bufferInfo.numElements : count;
  offset = offset === undefined ? 0 : offset;
  if (elementType || indices) {
    if (instanceCount !== undefined) {
      gl.drawElementsInstanced(type, numElements, elementType === undefined ? gl.UNSIGNED_SHORT : bufferInfo.elementType, offset, instanceCount);
    } else {
      gl.drawElements(type, numElements, elementType === undefined ? gl.UNSIGNED_SHORT : bufferInfo.elementType, offset);
    }
  } else {
    if (instanceCount !== undefined) {
      gl.drawArraysInstanced(type, offset, numElements, instanceCount);
    } else {
      gl.drawArrays(type, offset, numElements);
    }
  }
}
function drawBufferInfo ( gl , bufferInfo , type , count , offset , instanceCount ) { type = type === undefined ? gl . TRIANGLES : type ; const indices = bufferInfo . indices ; const elementType = bufferInfo . elementType ; const numElements = count === undefined ? bufferInfo . numElements : count ; offset = offset === undefined ? 0 : offset ; if ( elementType || indices ) { if ( instanceCount !== undefined ) { gl . drawElementsInstanced ( type , numElements , elementType === undefined ? gl . UNSIGNED_SHORT : bufferInfo . elementType , offset , instanceCount ) ; } else { gl . drawElements ( type , numElements , elementType === undefined ? gl . UNSIGNED_SHORT : bufferInfo . elementType , offset ) ; } } else { if ( instanceCount !== undefined ) { gl . drawArraysInstanced ( type , offset , numElements , instanceCount ) ; } else { gl . drawArrays ( type , offset , numElements ) ; } } }
Drawing related functions

For backward compatibily they are available at both `twgl.draw` and `twgl`
itself

See {@link module:twgl} for core functions

@module twgl/draw
 
Calls `gl.drawElements` or `gl.drawArrays`, whichever is appropriate

normally you'd call `gl.drawElements` or `gl.drawArrays` yourself
but calling this means if you switch from indexed data to non-indexed
data you don't have to remember to update your draw call.

@param {WebGLRenderingContext} gl A WebGLRenderingContext
@param {(module:twgl.BufferInfo|module:twgl.VertexArrayInfo)} bufferInfo A BufferInfo as returned from {@link module:twgl.createBufferInfoFromArrays} or
a VertexArrayInfo as returned from {@link module:twgl.createVertexArrayInfo}
@param {number} [type] eg (gl.TRIANGLES, gl.LINES, gl.POINTS, gl.TRIANGLE_STRIP, ...). Defaults to `gl.TRIANGLES`
@param {number} [count] An optional count. Defaults to bufferInfo.numElements
@param {number} [offset] An optional offset. Defaults to 0.
@param {number} [instanceCount] An optional instanceCount. if set then `drawArraysInstanced` or `drawElementsInstanced` will be called
@memberOf module:twgl/draw
Drawing related functions