WebGPUInfo.js 912 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. };
  14. }
  15. update( object, count ) {
  16. this.render.drawCalls ++;
  17. if ( object.isMesh ) {
  18. this.render.triangles += ( count / 3 );
  19. } else if ( object.isPoints ) {
  20. this.render.points += count;
  21. } else if ( object.isLineSegments ) {
  22. this.render.lines += ( count / 2 );
  23. } else if ( object.isLine ) {
  24. this.render.lines += ( count - 1 );
  25. } else {
  26. console.error( 'THREE.WebGPUInfo: Unknown object type.' );
  27. }
  28. }
  29. reset() {
  30. this.render.frame ++;
  31. this.render.drawCalls = 0;
  32. this.render.triangles = 0;
  33. this.render.points = 0;
  34. this.render.lines = 0;
  35. }
  36. dispose() {
  37. this.reset();
  38. this.render.frame = 0;
  39. this.memory.geometries = 0;
  40. }
  41. }
  42. export default WebGPUInfo;