Info.js 1.4 KB

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