Skip to content

Instantly share code, notes, and snippets.

@fredj
Created August 28, 2020 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredj/47b6c57c0f89200fdfd750b817153677 to your computer and use it in GitHub Desktop.
Save fredj/47b6c57c0f89200fdfd750b817153677 to your computer and use it in GitHub Desktop.
// Grant CesiumJS access to your ion assets
Cesium.Ion.defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiNzg2OTI5Ni1hOTY2LTRjZDYtYjdlMy1lZjM2YTlhNzU3YWIiLCJpZCI6MTg3NTIsInNjb3BlcyI6WyJhc3IiLCJnYyJdLCJpYXQiOjE1NzQzNTAyNTB9.42EaQ9sZ9b8Qa3_W5c4opP_ARS3LYY9c-xAz9g_UrkY";
var viewer = new Cesium.Viewer("cesiumContainer");
var location = Cesium.Cartesian3.fromDegrees(7.05468, 46.61793);
var plane = Cesium.Plane.transform(Cesium.Plane.ORIGIN_ZX_PLANE, Cesium.Transforms.eastNorthUpToFixedFrame(location));
var ids = [68881, 139225];
for (var i; i < ids.length; i++) {
var tileset = viewer.scene.primitives.add(
new Cesium.Cesium3DTileset({
url: Cesium.IonResource.fromAssetId(ids[i]),
})
);
tileset.readyPromise
.then(function () {
viewer.zoomTo(tileset);
tileset.clippingPlanes = new Cesium.ClippingPlaneCollection({
modelMatrix: Cesium.Matrix4.inverse(tileset.root.computedTransform, new Cesium.Matrix4()),
planes: [
Cesium.ClippingPlane.fromPlane(plane)
],
edgeWidth: 5.0
});
})
.otherwise(function (error) {
console.log(error);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment