-
Notifications
You must be signed in to change notification settings - Fork 83
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
Add support for polygon clipping #407
Conversation
#if UNITY_EDITOR | ||
private void Reset() | ||
{ | ||
this.materialKey = "Clipping"; |
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.
Annoyingly, when you first add the overlay, its material key will be initialized with the default value in CesiumRasterOverlay
. Reset
happens after OnEnable
, so it will potentially log a warning that it shares a material key with another overlay on the tileset.
I'll see if I can try doing something similar to CesiumSubScene
for circumventing this.
6909653
to
a187b57
Compare
a187b57
to
02b749d
Compare
Also, the created Spline Container in the above scenario had default settings, which made it hard to use. |
This looks really good! One thing I want to test is that the packaged version of the plugin works just as well, in both 2021.3 and 2022.2. But to do that, we need a working build from CI, which is proving elusive. At the moment, the problem is that Chocolatey is down, so none of our self-hosted builds can start. 😞 |
Thanks for the review @kring ! I just pushed some code that should improve the case where a polygon is created before the Splines package is added. |
I tried this out and it looks good! I also tested the release package in 2021.3 and 2022.3, and it also works well in both cases. It's pretty amazing how well this turned out, and how quickly. Nice job! |
Fixes #360 #64. Depends on #405 (which itself depends on material keys), so merge that first.
This PR adds support for rasterized polygon clipping.
DISCLAIMER: This requires the Splines package, which is only available in Unity 2022.2 or later. It's not listed as a package dependency, so our package will still load in 2021.3. However, this functionality will be inaccessible in the older versions.
Workflow
The workflow is similar to Cesium for Unreal's. Users can add a
CesiumCartographicPolygon
from the quick add panel.This will spawn a game object with a
CesiumCartographicPolygon
component, which automatically adds aSpline
andCesiumGlobeAnchor
component. You can modify the game object's transform, add or remove points from the spline component, and edit the spline itself by clicking this icon in the Scene View.Note that the spline is required to be closed, and completely linear. If either of these conditions is not true, the polygon will log errors. Interestingly, the Spline component supports multiple splines. For simplicity, only the first one is rasterized.
Then, you can connect this polygon to a tileset using the
CesiumPolygonRasterOverlay
component. The settings are exactly the same as in Unreal.The materials have been modified to handle alpha clipping via "Clipping" overlay parameters. The final result:
Splines package missing (Unity 2022.2+)
The assembly definition has been modified to reference the
com.unity.splines
package. If it isn't detected, then theSUPPORTS_SPLINES
won't be defined. Users will still be able to addCesiumCartographicPolygon
andCesiumPolygonRasterOverlay
through the UI, but they will appear with these warnings:Splines package unavailable (Unity 2021.3f)
com.unity.splines
is not listedpackage.json
as a dependency, so Cesium for Unity isn't blocked from loading in earlier versions. When it does load, there will be no UI to addCesiumCartographicPolygon
, andCesiumPolygonRasterOverlay
is hidden from the component menu. If somehow they make their way into the scene, these warnings will appear: