Skip to content

Commit

Permalink
BufferAttribute.onUpload() clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Nov 5, 2016
1 parent 629195b commit 91802d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
9 changes: 1 addition & 8 deletions docs/api/core/BufferAttribute.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h2>Constructor</h2>
<h3>[name]( [page:TypedArray array], [page:Integer itemSize], [page:Boolean normalized] )</h3>
<div>
Instantiates this attribute with data from the associated buffer.
itemSize gives the number of values of the array that should be associated with a particular vertex. normalized indicates how the underlying data in the buffer maps to the values in the GLSL shader code.
itemSize gives the number of values of the array that should be associated with a particular vertex. normalized indicates how the underlying data in the buffer maps to the values in the GLSL shader code.
</div>

<h2>Properties</h2>
Expand Down Expand Up @@ -57,7 +57,6 @@ <h3>[property:Integer version]</h3>
<h3>[property:Function onUploadCallback]</h3>
<div>
A callback function that is executed after the Renderer has transfered the attribute array data to the GPU.
The callback is executed with a single parameter "name", the name of the buffer attribute, and "this" set to the BufferAttribute object.
</div>

<h2>Methods</h2>
Expand Down Expand Up @@ -113,12 +112,6 @@ <h3>[method:BufferAttribute clone]() </h3>
Copies this attribute.
</div>

<h3>[method:null disposeArray]() </h3>
<div>
Discards the typed array containing the attribute data. This can be executed after the data has been transfered to the GPU to allow the memory to be reclaimed.
For use where the attribute will not be changed after the discard method is called.
</div>

<h2>Source</h2>

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
Expand Down
11 changes: 2 additions & 9 deletions src/core/BufferAttribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ function BufferAttribute( array, itemSize, normalized ) {
this.dynamic = false;
this.updateRange = { offset: 0, count: - 1 };

this.onUpload = null;

this.version = 0;
this.onUploadCallback = null;

}

Expand Down Expand Up @@ -324,14 +325,6 @@ BufferAttribute.prototype = {

return new this.constructor().copy( this );

},

disposeArray: function () {

var oldArray = this.array;

this.array = new oldArray.constructor( 1 ); // create dummy minimal length TypedArray

}

};
Expand Down
12 changes: 6 additions & 6 deletions src/renderers/webgl/WebGLObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function WebGLObjects( gl, properties, info ) {

for ( var name in attributes ) {

updateAttribute( attributes[ name ], gl.ARRAY_BUFFER, name );
updateAttribute( attributes[ name ], gl.ARRAY_BUFFER );

}

Expand All @@ -58,15 +58,15 @@ function WebGLObjects( gl, properties, info ) {

}

function updateAttribute( attribute, bufferType, name ) {
function updateAttribute( attribute, bufferType ) {

var data = ( attribute.isInterleavedBufferAttribute ) ? attribute.data : attribute;

var attributeProperties = properties.get( data );

if ( attributeProperties.__webglBuffer === undefined ) {

createBuffer( attributeProperties, data, bufferType, name );
createBuffer( attributeProperties, data, bufferType );

} else if ( attributeProperties.version !== data.version ) {

Expand All @@ -76,7 +76,7 @@ function WebGLObjects( gl, properties, info ) {

}

function createBuffer( attributeProperties, data, bufferType, name ) {
function createBuffer( attributeProperties, data, bufferType ) {

attributeProperties.__webglBuffer = gl.createBuffer();
gl.bindBuffer( bufferType, attributeProperties.__webglBuffer );
Expand Down Expand Up @@ -126,9 +126,9 @@ function WebGLObjects( gl, properties, info ) {
attributeProperties.type = type;
attributeProperties.version = data.version;

if ( data.onUploadCallback ) {
if ( data.onUpload !== null ) {

data.onUploadCallback( name );
data.onUpload();

}

Expand Down

0 comments on commit 91802d6

Please sign in to comment.