12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /**
- * @author mrdoob / http://mrdoob.com/
- */
- THREE.WebGLBufferRenderer = function ( _gl, extensions, _infoRender ) {
- var mode;
- function setMode( value ) {
- mode = value;
- }
- function render( start, count ) {
- _gl.drawArrays( mode, start, count );
- _infoRender.calls ++;
- _infoRender.vertices += count;
- if ( mode === _gl.TRIANGLES ) _infoRender.faces += count / 3;
- }
- function renderInstances( geometry ) {
- var extension = extensions.get( 'ANGLE_instanced_arrays' );
- if ( extension === null ) {
- console.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
- return;
- }
- var position = geometry.attributes.position;
- var count = 0;
- if ( position instanceof THREE.InterleavedBufferAttribute ) {
- count = position.data.count;
- extension.drawArraysInstancedANGLE( mode, 0, count, geometry.maxInstancedCount );
- } else {
- count = position.count;
- extension.drawArraysInstancedANGLE( mode, 0, count, geometry.maxInstancedCount );
- }
- _infoRender.calls ++;
- _infoRender.vertices += count * geometry.maxInstancedCount;
- if ( mode === _gl.TRIANGLES ) _infoRender.faces += geometry.maxInstancedCount * count / 3;
- }
- this.setMode = setMode;
- this.render = render;
- this.renderInstances = renderInstances;
- };
|