WebGPUInfo.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. class WebGPUInfo {
  2. constructor() {
  3. this.autoReset = true;
  4. this.render = {
  5. frame: 0,
  6. drawCalls: 0,
  7. triangles: 0,
  8. points: 0,
  9. lines: 0
  10. };
  11. this.memory = {
  12. geometries: 0,
  13. textures: 0
  14. };
  15. }
  16. update( object, count, instanceCount ) {
  17. this.render.drawCalls ++;
  18. if ( object.isMesh ) {
  19. this.render.triangles += instanceCount * ( count / 3 );
  20. } else if ( object.isPoints ) {
  21. this.render.points += instanceCount * count;
  22. } else if ( object.isLineSegments ) {
  23. this.render.lines += instanceCount * ( count / 2 );
  24. } else if ( object.isLine ) {
  25. this.render.lines += instanceCount * ( count - 1 );
  26. } else {
  27. console.error( 'THREE.WebGPUInfo: Unknown object type.' );
  28. }
  29. }
  30. reset() {
  31. this.render.frame ++;
  32. this.render.drawCalls = 0;
  33. this.render.triangles = 0;
  34. this.render.points = 0;
  35. this.render.lines = 0;
  36. }
  37. dispose() {
  38. this.reset();
  39. this.render.frame = 0;
  40. this.memory.geometries = 0;
  41. this.memory.textures = 0;
  42. }
  43. }
  44. export default WebGPUInfo;