From 3af7d9b3b94438110c6c6cef88f3700b40b0cf61 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Fri, 21 Oct 2016 09:54:14 -0400 Subject: [PATCH] Fix billboard and label clamping Turns out that billboard and label clamping were fundamentally broken because the `QuadtreePrimitive` was processing the tile queue in the wrong order. It was always pulling new tiles from the back of the array rather than the front, which meant that data would get processed in the wrong order causing old tiles to take precedence over newer tiles. Addtiionally, there was a bad if block in `Label.js` which caused the initial position of the individual label billboards to not be properly set when clamping was on, instead we should always set the positions before calling `_updateClamping` (if needed). Fixes #4396 and #4062 --- Source/Scene/Label.js | 16 ++++++++-------- Source/Scene/QuadtreePrimitive.js | 10 +++------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Source/Scene/Label.js b/Source/Scene/Label.js index fbe3b1bc68a3..d36dcb2f11ae 100644 --- a/Source/Scene/Label.js +++ b/Source/Scene/Label.js @@ -166,15 +166,15 @@ define([ if (!Cartesian3.equals(position, value)) { Cartesian3.clone(value, position); - if (this._heightReference === HeightReference.NONE) { - var glyphs = this._glyphs; - for (var i = 0, len = glyphs.length; i < len; i++) { - var billboard = glyphs[i].billboard; - if (defined(billboard)) { - billboard.position = value; - } + var glyphs = this._glyphs; + for (var i = 0, len = glyphs.length; i < len; i++) { + var billboard = glyphs[i].billboard; + if (defined(billboard)) { + billboard.position = value; } - } else { + } + + if (this._heightReference !== HeightReference.NONE) { this._updateClamping(); } } diff --git a/Source/Scene/QuadtreePrimitive.js b/Source/Scene/QuadtreePrimitive.js index 5f9917680789..3c013df87671 100644 --- a/Source/Scene/QuadtreePrimitive.js +++ b/Source/Scene/QuadtreePrimitive.js @@ -617,11 +617,7 @@ define([ var ellipsoid = projection.ellipsoid; while (tilesToUpdateHeights.length > 0) { - var tile = tilesToUpdateHeights[tilesToUpdateHeights.length - 1]; - if (tile !== primitive._lastTileUpdated) { - primitive._lastTileIndex = 0; - } - + var tile = tilesToUpdateHeights[0]; var customData = tile.customData; var customDataLength = customData.length; @@ -682,11 +678,11 @@ define([ } if (timeSliceMax) { - primitive._lastTileUpdated = tile; primitive._lastTileIndex = i; break; } else { - tilesToUpdateHeights.pop(); + primitive._lastTileIndex = 0; + tilesToUpdateHeights.shift(); } } }