Skip to content

Commit

Permalink
Simplified createElementAddMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Wojciechowski committed Oct 14, 2015
1 parent da278fb commit 6cb9bcd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions js/data/buffer_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ BufferBuilder.prototype._createVertexAddMethod = function(shaderName) {
}

var body = '';
body += 'var elementGroups = this.elementGroups.' + shaderName + ';\n'
body += 'var elementGroups = this.elementGroups.' + shaderName + ';\n';
body += 'elementGroups.current.vertexLength++;\n';
body += 'var attributes = this.type.shaders.' + shaderName + '.attributes;\n';
body += 'return this.buffers.' + shader.vertexBuffer + '.push(\n';
Expand All @@ -91,11 +91,10 @@ BufferBuilder.prototype._createElementAddMethod = function(shaderName, isSecond)
var shader = this.type.shaders[shaderName];
var bufferName = isSecond ? shader.secondElementBuffer : shader.elementBuffer;
if (!bufferName) return;
var lengthName = isSecond ? 'secondElementLength' : 'elementLength';

this[this.getAddElementMethodName(shaderName, isSecond)] = function() {
var elementGroups = this.elementGroups[shaderName];
if (isSecond) elementGroups.current.secondElementLength++;
else elementGroups.current.elementLength++;
this.elementGroups[shaderName].current[lengthName]++;
return this.buffers[bufferName].push(arguments);
};
};
Expand Down

0 comments on commit 6cb9bcd

Please sign in to comment.