Skip to content
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

Allow users to define clipping regions with polygons #11750

Merged
merged 31 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
77bb0d1
ClippingPolygonCollection
ggetz Jan 9, 2024
eab1d19
Fix TS
ggetz Jan 9, 2024
0140ce0
Update CHANGES.md
ggetz Jan 9, 2024
15cad35
Draft
ggetz Mar 12, 2024
5079310
Merge branch 'main' into clip-region
ggetz Mar 12, 2024
7a789fd
Draft 2
ggetz Mar 13, 2024
70f1170
Merge branch 'main' into clip-region
ggetz Mar 15, 2024
b5ba48d
Draft
ggetz Mar 18, 2024
c185b7b
Merge branch 'main' into clip-region
ggetz Mar 18, 2024
fe5704e
Start cleanup
ggetz Mar 19, 2024
f42b7db
Update Specs
ggetz Mar 22, 2024
be45ded
Update clipping plane performance, wire through terrain clipping
ggetz Mar 25, 2024
c624775
Merge branch 'main' into clip-region
ggetz Mar 25, 2024
aca4f14
cleanup doc
ggetz Mar 25, 2024
3158943
Cleanup private classes
ggetz Mar 25, 2024
e87589d
Fix jagged edges
ggetz Apr 3, 2024
7305ce1
Specs cleanup
ggetz Apr 5, 2024
1b24f93
More specs
ggetz Apr 5, 2024
3cf00dc
More specs
ggetz Apr 5, 2024
58b5a42
Cleanup AEC example for tutorial
ggetz Apr 10, 2024
73cf3e2
Fix typos and whitespace
Apr 10, 2024
a43d78f
Fix typos and whitespace
Apr 11, 2024
dc84c67
Feedback from PR
ggetz Apr 12, 2024
3ac081f
Fix issue with terrain when zoomed out
ggetz Apr 15, 2024
38a2b9d
Update tests
ggetz Apr 16, 2024
e69d21f
Fix P3DT not clipping when zoomed out
ggetz Apr 16, 2024
b32fa28
Cleanup:
ggetz Apr 17, 2024
0f5c0a3
Cleanup
ggetz Apr 17, 2024
859abb9
Fix minor docs typos
Apr 22, 2024
71f7197
Fix sandcastle angle, too agressive simplification
ggetz Apr 23, 2024
620a0ec
Adjust clip polygon region combining
ggetz Apr 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions Apps/Sandcastle/gallery/AEC Clipping.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
/>
<meta
name="description"
content="Use clipping regions to hide the area under a model or 3D tileset."
/>
<meta name="cesium-sandcastle-labels" content="Beginner, Showcases" />
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="module" src="../load-cesium-es6.js"></script>
</head>
<body
class="sandcastle-loading"
data-sandcastle-bucket="bucket-requirejs.html"
>
<style>
@import url(../templates/bucket.css);
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>
<script id="cesium_sandcastle_script">
window.startup = async function (Cesium) {
"use strict";
//Sandcastle_Begin
const viewer = new Cesium.Viewer("cesiumContainer", {
timeline: false,
animation: false,
sceneModePicker: false,
baseLayerPicker: false,
// The globe does not need to be displayed,
// since the Photorealistic 3D Tiles include terrain
globe: false,
});

// Enable rendering the sky
viewer.scene.skyAtmosphere.show = true;

const currentTime = Cesium.JulianDate.fromIso8601(
"2020-01-09T23:00:39.018261982600961346Z"
);
viewer.clock.currentTime = currentTime;

// Add Photorealistic 3D Tiles
let googleTileset;
try {
googleTileset = await Cesium.createGooglePhotorealistic3DTileset();
viewer.scene.primitives.add(googleTileset);
} catch (error) {
console.log(`Error loading Photorealistic 3D Tiles tileset.
${error}`);
}

// Load a GeoJSON file with positions defining the project footprint
let footprint;
try {
const resource = await Cesium.IonResource.fromAssetId(2533131);
const dataSource = await Cesium.GeoJsonDataSource.load(resource, {
clampToGround: true,
});

viewer.dataSources.add(dataSource);

footprint = dataSource.entities.values.find((entity) =>
Cesium.defined(entity.polygon)
);
footprint.polygon.outline = false;

// Zoom to data location, and set the home view
const cameraOffset = new Cesium.HeadingPitchRange(
Cesium.Math.toRadians(95.0),
Cesium.Math.toRadians(-75.0),
800.0
);
viewer.zoomTo(footprint, cameraOffset);
viewer.homeButton.viewModel.command.beforeExecute.addEventListener(
(e) => {
e.cancel = true;
viewer.zoomTo(footprint, cameraOffset);
}
);
} catch (error) {
console.log(`Error loading geojson. ${error}`);
}

// Add a clipping region based on the loaded project footprint
const positions = footprint.polygon.hierarchy.getValue().positions;
const clippingPolygons = new Cesium.ClippingPolygonCollection({
polygons: [
new Cesium.ClippingPolygon({
positions: positions,
}),
],
});
googleTileset.clippingPolygons = clippingPolygons;

// Add tileset of proposed project design
let buildingTileset;
try {
buildingTileset = await Cesium.Cesium3DTileset.fromIonAssetId(
2533124
);
viewer.scene.primitives.add(buildingTileset);
} catch (error) {
console.log(`Error loading design tileset.
${error}`);
}

Sandcastle.addToggleButton("Show proposed design", true, function (
checked
) {
buildingTileset.show = checked;
});

Sandcastle.addToggleButton("Show footprint", true, function (checked) {
footprint.show = checked;
});

Sandcastle.addToggleButton("Clip target location", true, function (
checked
) {
clippingPolygons.enabled = checked;
});

Sandcastle.addToggleButton("Inverse clip", false, function (checked) {
clippingPolygons.inverse = checked;
});
//Sandcastle_End
Sandcastle.finishedLoading();
};
if (typeof Cesium !== "undefined") {
window.startupCalled = true;
window.startup(Cesium).catch((error) => {
"use strict";
console.error(error);
});
}
</script>
</body>
</html>
Binary file added Apps/Sandcastle/gallery/AEC Clipping.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading