-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure clipping plane origin matches the bounding sphere center #8392
Conversation
Thanks for the pull request @OmarShehata!
Reviewers, don't forget to make sure that:
|
Thank you for you reply,But,
|
@liyangis the clipping plane is positioned relative to the bounding sphere center. You can use the Setting the modelMatrix to be a transform relative to the bounding center should work. Were you testing your code with this branch? If so, do you have a Sandcastle example showing the issue? |
look at this example |
@liyangis yes this example is fixed in my branch. See this modified version of it. I commented out this section of code, since in this branch it is no longer true that the clipping plane origin is offset from the bounding sphere center:
|
oh,if I want to change the clipping plane's origin to another position on the fly ,how to do? |
Thanks again for your contribution @OmarShehata! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
1 similar comment
Thanks again for your contribution @OmarShehata! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
#8555 might be relevant here. There was a mistake in the sandcastle code. If you want to position the clipping planes at the bounding sphere center try this instead: if (!Cesium.Matrix4.equals(tileset.root.transform, Cesium.Matrix4.IDENTITY)) {
// The clipping plane is initially positioned at the tileset's root transform.
// Apply an additional matrix to center the clipping plane on the bounding sphere center.
var transformCenter = Cesium.Matrix4.getTranslation(tileset.root.transform, new Cesium.Cartesian3());
var transformCartographic = Cesium.Cartographic.fromCartesian(transformCenter);
var boundingSphereCartographic = Cesium.Cartographic.fromCartesian(tileset.boundingSphere.center);
var height = boundingSphereCartographic.height - transformCartographic.height;
clippingPlanes.modelMatrix = Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(0.0, 0.0, height));
} @liyangis If you want to position the clipping planes arbitrarily, create a matrix in global coordinates and multiply it by the inverse of the tileset's root transform (or Sandcastle example of this approach here. I also opened up #8554 since a think we should move to clipping planes always being defined in global space. |
Thanks again for your contribution @OmarShehata! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
1 similar comment
Thanks again for your contribution @OmarShehata! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
@cesium-concierge stop |
@OmarShehata what's the status of this PR? It's a really small change and it's unclear what is holding it up. |
@mramato looking at this again, this isn't resolving a bug as much as a breaking change to make the behavior more intuitive. The ClippingPlaneCollection docs states:
Which means the clipping origin being at the bottom of the tileset is expected (in these cases where the root transform is defined). It isn't clear to me that this is indeed a desired change that won't cause any other issues. I think it makes sense to close this and consider the approach Sean outlined here #8554 where the clipping plane origin will be defined explicitly so that there is no ambiguity. |
Thanks! |
你好,请问你的问题解决了吗,我也遇到相同的问题,请问能否请教下呢?我的版本是1.75 |
This addresses the offset reported in:
This is easy to reproduce in this Sandcastle. Notice that the X/Y directions work fine, where 0 cuts through the middle of the tileset, and it correctly goes from -1 to 1 across in that axis. For Z, the 0 is at the bottom of the model.
This offset is because the difference between where the
tileset.root.computedTransform
places the origin, and where thetileset.root.boundingSphere.center
is. In the image below, the red sphere marks the bounding sphere center. The white marks the root tile's computed transform's origin:You can draw these two points on the power plant model to show that they are very close, but not the same, and that's where the small discrepancy there comes from. This PR fixes this issue by making sure to use the bounding sphere center as the origin for the clipping plane in the case where the bounding sphere center is not above the surface (where the tileset transform is what places the tile in its location on the globe).
I marked as a draft because I still need to go through the discussion in #7182 to see why this wasn't done initially/make sure it's not breaking anything else.