Skip to content

Commit 9dfd41d

Browse files
committed
Fix webgl errors when rendering over 64k billboards
1 parent 098bbe7 commit 9dfd41d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ We’ve consolidated all of our website content from cesiumjs.org and cesium.com
1919
* Fixed a bug where `scene.sampleHeightMostDetailed` and `scene.clampToHeightMostDetailed` would not resolve in request render mode. [#8281](https://github.com/AnalyticalGraphicsInc/cesium/issues/8281)
2020
* Fixed seam artifacts when log depth is disabled, `scene.globe.depthTestAgainstTerrain` is false, and primitives are under the globe. [#8205](https://github.com/AnalyticalGraphicsInc/cesium/pull/8205)
2121
* Fix dynamic ellipsoids using `innerRadii`, `minimumClock`, `maximumClock`, `minimumCone` or `maximumCone`. [#8277](https://github.com/AnalyticalGraphicsInc/cesium/pull/8277)
22+
* Fixed rendering billboard collections containing more than 65536 billboards. [#8325](https://github.com/AnalyticalGraphicsInc/cesium/pull/8325)
2223

2324
##### Deprecated :hourglass_flowing_sand:
2425
* `OrthographicFrustum.getPixelDimensions`, `OrthographicOffCenterFrustum.getPixelDimensions`, `PerspectiveFrustum.getPixelDimensions`, and `PerspectiveOffCenterFrustum.getPixelDimensions` now take a `pixelRatio` argument before the `result` argument. The previous function definition will no longer work in 1.65. [#8237](https://github.com/AnalyticalGraphicsInc/cesium/pull/8237)

Source/Renderer/VertexArrayFacade.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,13 @@ import VertexArray from './VertexArray.js';
304304
destroyVA(this);
305305
var va = this.va = [];
306306

307-
var numberOfVertexArrays = defined(indexBuffer) ? Math.ceil(this._size / (CesiumMath.SIXTY_FOUR_KILOBYTES - 1)) : 1;
307+
var chunkSize = CesiumMath.SIXTY_FOUR_KILOBYTES - 4; // The 65535 index is reserved for primitive restart. Reserve the last 4 indices so that billboard quads are not broken up.
308+
var numberOfVertexArrays = (defined(indexBuffer) && !this._instanced) ? Math.ceil(this._size / chunkSize) : 1;
308309
for ( var k = 0; k < numberOfVertexArrays; ++k) {
309310
var attributes = [];
310311
for (i = 0, length = allBuffers.length; i < length; ++i) {
311312
buffer = allBuffers[i];
312-
var offset = k * (buffer.vertexSizeInBytes * (CesiumMath.SIXTY_FOUR_KILOBYTES - 1));
313+
var offset = k * (buffer.vertexSizeInBytes * chunkSize);
313314
VertexArrayFacade._appendAttributes(attributes, buffer, offset, this._instanced);
314315
}
315316

@@ -321,7 +322,7 @@ import VertexArray from './VertexArray.js';
321322
attributes : attributes,
322323
indexBuffer : indexBuffer
323324
}),
324-
indicesCount : 1.5 * ((k !== (numberOfVertexArrays - 1)) ? (CesiumMath.SIXTY_FOUR_KILOBYTES - 1) : (this._size % (CesiumMath.SIXTY_FOUR_KILOBYTES - 1)))
325+
indicesCount : 1.5 * ((k !== (numberOfVertexArrays - 1)) ? chunkSize : (this._size % chunkSize))
325326
// TODO: not hardcode 1.5, this assumes 6 indices per 4 vertices (as for Billboard quads).
326327
});
327328
}

0 commit comments

Comments
 (0)