code: function toBufferGeometry (geometry, doBuffer) {
    var bufferGeometry;
    if (!doBuffer) { return geometry; }
  
    bufferGeometry = new THREE.BufferGeometry().fromGeometry(geometry);
    bufferGeometry.metadata = {type: geometry.type, parameters: geometry.parameters || {}};
    geometry.dispose();  // Dispose no longer needed non-buffer geometry.
    return bufferGeometry;
  }
docs: Transform geometry to BufferGeometry if `doBuffer`.
  
  @param {object} geometry
  @param {boolean} doBuffer
  @returns {object} Geometry.