Info.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. };
  16. this.memory = {
  17. geometries: 0,
  18. textures: 0
  19. };
  20. }
  21. update( object, count, instanceCount ) {
  22. this.render.drawCalls ++;
  23. if ( object.isMesh || object.isSprite ) {
  24. this.render.triangles += instanceCount * ( count / 3 );
  25. } else if ( object.isPoints ) {
  26. this.render.points += instanceCount * count;
  27. } else if ( object.isLineSegments ) {
  28. this.render.lines += instanceCount * ( count / 2 );
  29. } else if ( object.isLine ) {
  30. this.render.lines += instanceCount * ( count - 1 );
  31. } else {
  32. console.error( 'THREE.WebGPUInfo: Unknown object type.' );
  33. }
  34. }
  35. reset() {
  36. this.render.drawCalls = 0;
  37. this.render.triangles = 0;
  38. this.render.points = 0;
  39. this.render.lines = 0;
  40. }
  41. dispose() {
  42. this.reset();
  43. this.calls = 0;
  44. this.render.calls = 0;
  45. this.compute.calls = 0;
  46. this.memory.geometries = 0;
  47. this.memory.textures = 0;
  48. }
  49. }
  50. export default Info;