-
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
Clipping Planes- Terrain & optimizations, and/or option, plane primitives, edge highlighting #5996
Clipping Planes- Terrain & optimizations, and/or option, plane primitives, edge highlighting #5996
Conversation
…ain-and-highlight-edges
…ing-planes-terrain
@ggetz, thanks for the pull request! Maintainers, we have a signed CLA from @ggetz, so you can review this at any time. I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome. 🌍 🌎 🌏 |
@lilleyse This is all the rest of the features we had in scope for clipping planes. I have one item left to do that is only relevant to the sandcastle examples. TODO:
|
Please bump when the TODOs are addressed. |
Also, please merge in master. |
CI is failing:
|
Part of #5765. @ggetz can you please update the tasklist in #5765 (comment) |
My recent comment was buried - just a reminder to address #5996 (comment) |
@@ -2807,4 +2813,55 @@ defineSuite([ | |||
}); | |||
}); | |||
|
|||
it('clipping planes cull hidden tiles', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of / or in addition to these tests, can you add tests like:
- Calls
update
and checks thatn
draw commands are returned, sets a clipping plane, and checks thatm
draw calls are returned under different cases, e.g., when all draw commands are culled, no draw commands are culled, when a subset are culled in an HLOD fashion - Include
i3dm
in a tileset - Renders, checks that a pixel was colored, sets a clip plane to clip everything, renders, then checks that nothing was rendered
- Multiple planes with and without combine
Similiar comment for terrain.
Also, looks like explicit tests are missing for Model
?
The tests in PointCloud3DTileContentSpec.js look pretty solid - why not apply the pattern throughout? Don't worry about the duplication or encapsulate it.
Finally, please check code coverage for the new files and make it as high as reasonable.
Given the work that this needs, let's target 1.40. No need to rush for 1.39 even if it gets merged soon after the release. CC @tfili |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The globe and point clouds tests look good! @pjcozzi already addressed everything else.
Intersect, | ||
Matrix4, | ||
Plane) { | ||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indentation.
Specs/Core/PlaneSpec.js
Outdated
}); | ||
|
||
it('transform throws without a plane', function() { | ||
var point = Cartesian3.ZERO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a Matrix4
.
Specs/Core/PlaneSpec.js
Outdated
}).toThrowDeveloperError(); | ||
}); | ||
|
||
it('transform throws without a point', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
point
-> transform
.
createDynamicGeometryBoundingSphereSpecs, | ||
createDynamicProperty, | ||
createScene) { | ||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indentation.
visibility = tileset._root.visibility(scene.frameState, CullingVolume.MASK_INSIDE); | ||
|
||
expect(visibility).not.toBe(CullingVolume.MASK_OUTSIDE); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should be tweaked to call tileset.update and check the number of draw commands, similar to some of the other tests. It should expect 5 commands before the clipping plane is enabled and 1 command after. Checking the visibility directly is a bit too low level.
Realized later this is basically a duplicate of @pjcozzi's comment.
Intersect, | ||
Matrix4, | ||
Plane) { | ||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indentation.
|
||
var result = clippingPlanes.transformAndPackPlanes(transform); | ||
expect(result.length).toEqual(2); | ||
expect(result[0] instanceof Cartesian4).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use toBeInstanceOf
}); | ||
}); | ||
|
||
it('computes tile visibility culls tiles when clipped', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wording is awkward.
@lilleyse Spec updates are in, and addressed the plane normals and point cloud issue. |
I assume it would be best to merge in |
} | ||
for (var i = 0; i < length; ++i) { | ||
var plane = this.planes[i]; | ||
result.planes[i] = new Plane(plane.normal, plane.distance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also try to avoid the new
here. Above when the new array is created it could initialize with new planes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok if I point this at the same plane object? The planes aren't manipulated down at the model level after the collection is cloned, just the enabling and modelMatrix. Or better yet just point it at the same array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably better not to use the same plane object or array since callers would expect a deep clone (even though the code right now doesn't care).
I tried running the Sandcastle demo with an i3dm tileset but it seems to always clip. This may just be a matter of hooking up clipping planes in |
Sorry, I didn't know I also had to hook up that class. It looks like the content is a collection of models, so that's what I should clip, correct? |
Yeah it should be easy I think, the clipping planes just need to get to the underlying model that the model instance collection creates. |
Also - don't worry about clipping individual instances (i.e. changing the draw command's instance count). |
@lilleyse Added i3dm and tests, and it works with the composite tilset. |
var plane = this.planes[i]; | ||
result.planes[i] = new Plane(plane.normal, plane.distance); | ||
var resultPlane = result.planes[i]; | ||
resultPlane.normal = plane.normal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Cartesian3.clone
here, with resultPlane.normal
as the result
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind I see that this is already in.
var scratchPlane = new Cesium.Plane(Cesium.Cartesian3.UNIT_X, 0.0); | ||
function createPlaneUpdateFunction(plane, transform) { | ||
return function () { | ||
plane.distance = Cesium.Math.lerp(plane.distance, targetY, 0.1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think lerp
ing here makes sense. Doing it this way never converges, so the value of plane.distance
changes slightly every frame
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove it. It is there to make the plane movement smooth since reflecting the mouse movement directly can be shaky.
Thanks @ggetz all looks good from my end. |
Sounds good. Feel free to open that PR now. I might do one quick glance over everything but it should be quick to merge. |
ClippingPlanesCollection
to encompass clipping plane optionsinclusive
flag to clipping planes, which allows you to and/or the clipping across the planes specifiededgeWidth
andedgeColor
options to style the edgesterrainClippingPlanes
option toGlobe
planePrimitive
for visualizations.