Cesium3DTilesetStatistics.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import defined from "../Core/defined.js";
  2. /**
  3. * @private
  4. */
  5. function Cesium3DTilesetStatistics() {
  6. // Rendering statistics
  7. this.selected = 0;
  8. this.visited = 0;
  9. // Loading statistics
  10. this.numberOfCommands = 0;
  11. this.numberOfAttemptedRequests = 0;
  12. this.numberOfPendingRequests = 0;
  13. this.numberOfTilesProcessing = 0;
  14. this.numberOfTilesWithContentReady = 0; // Number of tiles with content loaded, does not include empty tiles
  15. this.numberOfTilesTotal = 0; // Number of tiles in tileset JSON (and other tileset JSON files as they are loaded)
  16. this.numberOfLoadedTilesTotal = 0; // Running total of loaded tiles for the lifetime of the session
  17. // Features statistics
  18. this.numberOfFeaturesSelected = 0; // Number of features rendered
  19. this.numberOfFeaturesLoaded = 0; // Number of features in memory
  20. this.numberOfPointsSelected = 0;
  21. this.numberOfPointsLoaded = 0;
  22. this.numberOfTrianglesSelected = 0;
  23. // Styling statistics
  24. this.numberOfTilesStyled = 0;
  25. this.numberOfFeaturesStyled = 0;
  26. // Optimization statistics
  27. this.numberOfTilesCulledWithChildrenUnion = 0;
  28. // Memory statistics
  29. this.geometryByteLength = 0;
  30. this.texturesByteLength = 0;
  31. this.batchTableByteLength = 0; // batch textures and any binary metadata properties not otherwise accounted for
  32. }
  33. Cesium3DTilesetStatistics.prototype.clear = function () {
  34. this.selected = 0;
  35. this.visited = 0;
  36. this.numberOfCommands = 0;
  37. this.numberOfAttemptedRequests = 0;
  38. this.numberOfFeaturesSelected = 0;
  39. this.numberOfPointsSelected = 0;
  40. this.numberOfTrianglesSelected = 0;
  41. this.numberOfTilesStyled = 0;
  42. this.numberOfFeaturesStyled = 0;
  43. this.numberOfTilesCulledWithChildrenUnion = 0;
  44. };
  45. function updatePointAndFeatureCounts(statistics, content, decrement, load) {
  46. const contents = content.innerContents;
  47. const pointsLength = content.pointsLength;
  48. const trianglesLength = content.trianglesLength;
  49. const featuresLength = content.featuresLength;
  50. const geometryByteLength = content.geometryByteLength;
  51. const texturesByteLength = content.texturesByteLength;
  52. const batchTableByteLength = content.batchTableByteLength;
  53. if (load) {
  54. statistics.numberOfFeaturesLoaded += decrement
  55. ? -featuresLength
  56. : featuresLength;
  57. statistics.numberOfPointsLoaded += decrement ? -pointsLength : pointsLength;
  58. statistics.geometryByteLength += decrement
  59. ? -geometryByteLength
  60. : geometryByteLength;
  61. statistics.texturesByteLength += decrement
  62. ? -texturesByteLength
  63. : texturesByteLength;
  64. statistics.batchTableByteLength += decrement
  65. ? -batchTableByteLength
  66. : batchTableByteLength;
  67. } else {
  68. statistics.numberOfFeaturesSelected += decrement
  69. ? -featuresLength
  70. : featuresLength;
  71. statistics.numberOfPointsSelected += decrement
  72. ? -pointsLength
  73. : pointsLength;
  74. statistics.numberOfTrianglesSelected += decrement
  75. ? -trianglesLength
  76. : trianglesLength;
  77. }
  78. if (defined(contents)) {
  79. const length = contents.length;
  80. for (let i = 0; i < length; ++i) {
  81. updatePointAndFeatureCounts(statistics, contents[i], decrement, load);
  82. }
  83. }
  84. }
  85. Cesium3DTilesetStatistics.prototype.incrementSelectionCounts = function (
  86. content
  87. ) {
  88. updatePointAndFeatureCounts(this, content, false, false);
  89. };
  90. Cesium3DTilesetStatistics.prototype.incrementLoadCounts = function (content) {
  91. updatePointAndFeatureCounts(this, content, false, true);
  92. };
  93. Cesium3DTilesetStatistics.prototype.decrementLoadCounts = function (content) {
  94. updatePointAndFeatureCounts(this, content, true, true);
  95. };
  96. Cesium3DTilesetStatistics.clone = function (statistics, result) {
  97. result.selected = statistics.selected;
  98. result.visited = statistics.visited;
  99. result.numberOfCommands = statistics.numberOfCommands;
  100. result.selected = statistics.selected;
  101. result.numberOfAttemptedRequests = statistics.numberOfAttemptedRequests;
  102. result.numberOfPendingRequests = statistics.numberOfPendingRequests;
  103. result.numberOfTilesProcessing = statistics.numberOfTilesProcessing;
  104. result.numberOfTilesWithContentReady =
  105. statistics.numberOfTilesWithContentReady;
  106. result.numberOfTilesTotal = statistics.numberOfTilesTotal;
  107. result.numberOfFeaturesSelected = statistics.numberOfFeaturesSelected;
  108. result.numberOfFeaturesLoaded = statistics.numberOfFeaturesLoaded;
  109. result.numberOfPointsSelected = statistics.numberOfPointsSelected;
  110. result.numberOfPointsLoaded = statistics.numberOfPointsLoaded;
  111. result.numberOfTrianglesSelected = statistics.numberOfTrianglesSelected;
  112. result.numberOfTilesStyled = statistics.numberOfTilesStyled;
  113. result.numberOfFeaturesStyled = statistics.numberOfFeaturesStyled;
  114. result.numberOfTilesCulledWithChildrenUnion =
  115. statistics.numberOfTilesCulledWithChildrenUnion;
  116. result.geometryByteLength = statistics.geometryByteLength;
  117. result.texturesByteLength = statistics.texturesByteLength;
  118. result.batchTableByteLength = statistics.batchTableByteLength;
  119. };
  120. export default Cesium3DTilesetStatistics;