Skip to content

Commit

Permalink
Update WebGLBackend.js
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Sep 29, 2023
1 parent f8bb60e commit 39d296f
Showing 1 changed file with 1 addition and 58 deletions.
59 changes: 1 addition & 58 deletions examples/jsm/renderers/webgl/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ class WebGLBackend extends Backend {
state.setMaterial( material );

gl.useProgram( programGPU );
gl.bindVertexArray( vaoGPU );

//

Expand Down Expand Up @@ -654,66 +653,10 @@ class WebGLBackend extends Backend {

}

// VAO

const vaoGPU = gl.createVertexArray();

const index = renderObject.getIndex();
const attributes = renderObject.getAttributes();

gl.bindVertexArray( vaoGPU );

if ( index !== null ) {

const indexData = this.get( index );

gl.bindBuffer( gl.ELEMENT_ARRAY_BUFFER, indexData.bufferGPU );

}

for ( let i = 0; i < attributes.length; i ++ ) {

const attribute = attributes[ i ];
const attributeData = this.get( attribute );

gl.bindBuffer( gl.ARRAY_BUFFER, attributeData.bufferGPU );
gl.enableVertexAttribArray( i );

let stride, offset;

if ( attribute.isInterleavedBufferAttribute === true ) {

stride = attribute.data.stride * attributeData.bytesPerElement;
offset = attribute.offset * attributeData.bytesPerElement;

} else {

stride = 0;
offset = 0;

}

gl.vertexAttribPointer( i, attribute.itemSize, attributeData.type, false, stride, offset );

if ( attribute.isInstancedBufferAttribute && ! attribute.isInterleavedBufferAttribute ) {

gl.vertexAttribDivisor( i, attribute.meshPerAttribute );

} else if ( attribute.isInterleavedBufferAttribute && attribute.data.isInstancedInterleavedBuffer ) {

gl.vertexAttribDivisor( i, attribute.data.meshPerAttribute );

}

}

gl.bindVertexArray( null );

//

this.set( pipeline, {
programGPU,
vaoGPU
programGPU
} );

}
Expand Down

0 comments on commit 39d296f

Please sign in to comment.