From b7ae692a17c502ee3c53639544c052e8bc9486c6 Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Mon, 20 Mar 2017 19:45:37 -0400 Subject: [PATCH 1/2] Return transformed bounding spheres by the current model matrix. --- Source/Scene/Primitive.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/Source/Scene/Primitive.js b/Source/Scene/Primitive.js index 90968e3ba53e..8dac7a799c42 100644 --- a/Source/Scene/Primitive.js +++ b/Source/Scene/Primitive.js @@ -1165,10 +1165,11 @@ define([ var scratchBoundingSphereCenterEncoded = new EncodedCartesian3(); var scratchBoundingSphereCartographic = new Cartographic(); var scratchBoundingSphereCenter2D = new Cartesian3(); + var scratchBoundingSphere = new BoundingSphere(); function updateBatchTableBoundingSpheres(primitive, frameState) { var hasDistanceDisplayCondition = defined(primitive._batchTableAttributeIndices.distanceDisplayCondition); - if (!hasDistanceDisplayCondition && primitive._batchTableBoundingSpheresUpdated) { + if (!hasDistanceDisplayCondition || primitive._batchTableBoundingSpheresUpdated) { return; } @@ -1194,24 +1195,22 @@ define([ var modelMatrix = primitive.modelMatrix; if (defined(modelMatrix)) { - boundingSphere = BoundingSphere.transform(boundingSphere, modelMatrix, boundingSphere); + boundingSphere = BoundingSphere.transform(boundingSphere, modelMatrix, scratchBoundingSphere); } - if (hasDistanceDisplayCondition) { - var center = boundingSphere.center; - var radius = boundingSphere.radius; + var center = boundingSphere.center; + var radius = boundingSphere.radius; - var encodedCenter = EncodedCartesian3.fromCartesian(center, scratchBoundingSphereCenterEncoded); - batchTable.setBatchedAttribute(i, center3DHighIndex, encodedCenter.high); - batchTable.setBatchedAttribute(i, center3DLowIndex, encodedCenter.low); + var encodedCenter = EncodedCartesian3.fromCartesian(center, scratchBoundingSphereCenterEncoded); + batchTable.setBatchedAttribute(i, center3DHighIndex, encodedCenter.high); + batchTable.setBatchedAttribute(i, center3DLowIndex, encodedCenter.low); - var cartographic = ellipsoid.cartesianToCartographic(center, scratchBoundingSphereCartographic); - var center2D = projection.project(cartographic, scratchBoundingSphereCenter2D); - encodedCenter = EncodedCartesian3.fromCartesian(center2D, scratchBoundingSphereCenterEncoded); - batchTable.setBatchedAttribute(i, center2DHighIndex, encodedCenter.high); - batchTable.setBatchedAttribute(i, center2DLowIndex, encodedCenter.low); - batchTable.setBatchedAttribute(i, radiusIndex, radius); - } + var cartographic = ellipsoid.cartesianToCartographic(center, scratchBoundingSphereCartographic); + var center2D = projection.project(cartographic, scratchBoundingSphereCenter2D); + encodedCenter = EncodedCartesian3.fromCartesian(center2D, scratchBoundingSphereCenterEncoded); + batchTable.setBatchedAttribute(i, center2DHighIndex, encodedCenter.high); + batchTable.setBatchedAttribute(i, center2DLowIndex, encodedCenter.low); + batchTable.setBatchedAttribute(i, radiusIndex, radius); } primitive._batchTableBoundingSpheresUpdated = true; @@ -1684,7 +1683,12 @@ define([ function createBoundingSphereProperties(primitive, properties, index) { properties.boundingSphere = { get : function() { - return primitive._instanceBoundingSpheres[index]; + var boundingSphere = primitive._instanceBoundingSpheres[index]; + var modelMatrix = primitive.modelMatrix; + if (defined(modelMatrix) && defined(boundingSphere)) { + boundingSphere = BoundingSphere.transform(boundingSphere, modelMatrix); + } + return boundingSphere; } }; properties.boundingSphereCV = { From bb33c6609618cd98ac454e89cb84891d32e78a40 Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Tue, 28 Mar 2017 16:51:51 -0400 Subject: [PATCH 2/2] CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 1d4bc78ed3cf..bd707a26b952 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -27,6 +27,7 @@ Change Log * Added support for an orthographic projection in 3D and Columbus view. * Set `projectionPicker` to `true` in the options when creating a `Viewer` to add a widget that will switch projections. [#5021](https://github.com/AnalyticalGraphicsInc/cesium/pull/5021) * Call `switchToOrthographicFrustum` or `switchToPerspectiveFrustum` on `Camera` to change projections. +* Fixed an issue with camera tracking of dynamic ellipsoids. [#5133](https://github.com/AnalyticalGraphicsInc/cesium/pull/5133) * Fix billboard, point and label clustering in 2D and Columbus view. [#5136](https://github.com/AnalyticalGraphicsInc/cesium/pull/5136) * Fixed issues with imagerySplitPosition and the international date line in 2D mode. [#5151](https://github.com/AnalyticalGraphicsInc/cesium/pull/5151) * Fixed an issue with `TileBoundingBox` that caused the terrain to disappear in certain places [4032](https://github.com/AnalyticalGraphicsInc/cesium/issues/4032)