WebGLBufferRenderer.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
  5. const isWebGL2 = capabilities.isWebGL2;
  6. let mode;
  7. function setMode( value ) {
  8. mode = value;
  9. }
  10. function render( start, count ) {
  11. gl.drawArrays( mode, start, count );
  12. info.update( count, mode );
  13. }
  14. function renderInstances( geometry, start, count, primcount ) {
  15. if ( primcount === 0 ) return;
  16. let extension, methodName;
  17. if ( isWebGL2 ) {
  18. extension = gl;
  19. methodName = 'drawArraysInstanced';
  20. } else {
  21. extension = extensions.get( 'ANGLE_instanced_arrays' );
  22. methodName = 'drawArraysInstancedANGLE';
  23. if ( extension === null ) {
  24. console.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
  25. return;
  26. }
  27. }
  28. extension[ methodName ]( mode, start, count, primcount );
  29. info.update( count, mode, primcount );
  30. }
  31. //
  32. this.setMode = setMode;
  33. this.render = render;
  34. this.renderInstances = renderInstances;
  35. }
  36. export { WebGLBufferRenderer };
粤ICP备19079148号