Skip to content

Commit

Permalink
allow index attribute typed arrays to be dropped from javascript memory
Browse files Browse the repository at this point in the history
after upload to GPU.
  • Loading branch information
aardgoose committed May 29, 2017
1 parent ed717ae commit 87489e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
7 changes: 5 additions & 2 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -784,11 +784,14 @@ function WebGLRenderer( parameters ) {
}

var renderer = bufferRenderer;
var indexProperties;

if ( index !== null ) {

indexProperties = attributes.get( index );

renderer = indexedBufferRenderer;
renderer.setIndex( index );
renderer.setIndex( indexProperties );

}

Expand All @@ -798,7 +801,7 @@ function WebGLRenderer( parameters ) {

if ( index !== null ) {

_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, attributes.get( index ).buffer );
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, indexProperties.buffer );

}

Expand Down
20 changes: 3 additions & 17 deletions src/renderers/webgl/WebGLIndexedBufferRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,10 @@ function WebGLIndexedBufferRenderer( gl, extensions, infoRender ) {

var type, size;

function setIndex( index ) {
function setIndex( indexProperties ) {

if ( index.array instanceof Uint32Array && extensions.get( 'OES_element_index_uint' ) ) {

type = gl.UNSIGNED_INT;
size = 4;

} else if ( index.array instanceof Uint16Array ) {

type = gl.UNSIGNED_SHORT;
size = 2;

} else {

type = gl.UNSIGNED_BYTE;
size = 1;

}
type = indexProperties.type;
size = indexProperties.bytesPerElement;

}

Expand Down

0 comments on commit 87489e3

Please sign in to comment.