Skip to content

Commit

Permalink
fix counter var
Browse files Browse the repository at this point in the history
  • Loading branch information
peppsac committed Apr 10, 2018
1 parent 519166d commit 32f104c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
5 changes: 1 addition & 4 deletions examples/pointcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ function showPointcloud(serverUrl, fileName, lopocsTable) {
pointcloud.postUpdate = function postUpdate() {
var info = document.getElementById('info');
oldPostUpdate.apply(pointcloud, arguments);
info.textContent = 'Nb points: ' +
pointcloud.counters.displayedCount.toLocaleString() + ' (' +
Math.floor(100 * pointcloud.counters.displayedCount / pointcloud.counters.pointCount) + '%) (' +
view.mainLoop.gfxEngine.renderer.info.memory.geometries + ')';
info.textContent = 'Nb points: ' + pointcloud.displayedCount.toLocaleString();
};
window.view = view;
}
Expand Down
5 changes: 1 addition & 4 deletions examples/pointcloud_globe.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ function showPointcloud(serverUrl, fileName) {
pointcloud.postUpdate = function postUpdate() {
var info = document.getElementById('info');
oldPostUpdate.apply(pointcloud, arguments);
info.textContent = 'Nb points: ' +
pointcloud.counters.displayedCount.toLocaleString() + ' (' +
Math.floor(100 * pointcloud.counters.displayedCount / pointcloud.counters.pointCount) + '%) (' +
view.mainLoop.gfxEngine.renderer.info.memory.geometries + ')';
info.textContent = 'Nb points: ' + pointcloud.displayedCount.toLocaleString();
};
window.view = view;
}
Expand Down
12 changes: 5 additions & 7 deletions src/Process/PointCloudProcessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,20 @@ export default {
return;
}

layer.counters = {
displayedCount: 0,
};
layer.displayedCount = 0;
for (const pts of layer.group.children) {
layer.counters.displayedCount += pts.geometry.drawRange.count;
layer.displayedCount += pts.geometry.drawRange.count;
}

if (layer.counters.displayedCount > layer.pointBudget) {
const reduction = layer.pointBudget / layer.counters.displayedCount;
if (layer.displayedCount > layer.pointBudget) {
const reduction = layer.pointBudget / layer.displayedCount;
for (const pts of layer.group.children) {
if (pts.material.visible) {
const count = Math.max(1.0, Math.floor(pts.geometry.drawRange.count * reduction));
pts.geometry.setDrawRange(0, count);
}
}
layer.counters.displayedCount *= reduction;
layer.displayedCount *= reduction;
}

const now = Date.now();
Expand Down

0 comments on commit 32f104c

Please sign in to comment.