2
0

Info.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. class Info {
  2. constructor() {
  3. this.autoReset = true;
  4. this.frame = 0;
  5. this.calls = 0;
  6. this.render = {
  7. calls: 0,
  8. drawCalls: 0,
  9. triangles: 0,
  10. points: 0,
  11. lines: 0,
  12. timestamp: 0
  13. };
  14. this.compute = {
  15. calls: 0,
  16. computeCalls: 0,
  17. timestamp: 0
  18. };
  19. this.memory = {
  20. geometries: 0,
  21. textures: 0
  22. };
  23. }
  24. update( object, count, instanceCount ) {
  25. this.render.drawCalls ++;
  26. if ( object.isMesh || object.isSprite ) {
  27. this.render.triangles += instanceCount * ( count / 3 );
  28. } else if ( object.isPoints ) {
  29. this.render.points += instanceCount * count;
  30. } else if ( object.isLineSegments ) {
  31. this.render.lines += instanceCount * ( count / 2 );
  32. } else if ( object.isLine ) {
  33. this.render.lines += instanceCount * ( count - 1 );
  34. } else {
  35. console.error( 'THREE.WebGPUInfo: Unknown object type.' );
  36. }
  37. }
  38. updateTimestamp( type, time ) {
  39. this[ type ].timestamp += time;
  40. }
  41. reset() {
  42. this.render.drawCalls = 0;
  43. this.compute.computeCalls = 0;
  44. this.render.triangles = 0;
  45. this.render.points = 0;
  46. this.render.lines = 0;
  47. this.render.timestamp = 0;
  48. this.compute.timestamp = 0;
  49. }
  50. dispose() {
  51. this.reset();
  52. this.calls = 0;
  53. this.render.calls = 0;
  54. this.compute.calls = 0;
  55. this.render.timestamp = 0;
  56. this.compute.timestamp = 0;
  57. this.memory.geometries = 0;
  58. this.memory.textures = 0;
  59. }
  60. }
  61. export default Info;