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

Added I3S data source support in Cesium #9634

Merged
merged 66 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
7b01bde
Added I3S data source support in Cesium
Tamrat-B Jun 23, 2021
4b7c081
Fixes for travis-ci issues
Tamrat-B Jun 24, 2021
37bf80a
Fixed lint issues
Tamrat-B Jun 30, 2021
dbdb35d
Additional eslint fixes
Tamrat-B Jul 2, 2021
882b9b6
log clean ups
Tamrat-B Jul 6, 2021
0e566d0
- Updated i3s support to cesiumjs 1.87
Tamrat-B Nov 9, 2021
1d575f8
-Removed default access tokens
Tamrat-B Nov 9, 2021
8010d82
- Run prettier
Tamrat-B Nov 9, 2021
c01868a
formatting fix
Tamrat-B Nov 9, 2021
413eaad
Merge branch 'CesiumGS:main' into cesium_i3s_support
Tamrat-B Jul 7, 2022
6aa4fd7
Updates to I3S support
Tamrat-B Jul 7, 2022
ab8033b
Updated samples
Tamrat-B Jul 8, 2022
27348e0
Merge branch 'CesiumGS:main' into cesium_i3s_support
Tamrat-B Jul 8, 2022
4240326
Refactoring to satisfy Travis CI errors
Tamrat-B Jul 8, 2022
0d887a6
eslint fixes...
Tamrat-B Jul 8, 2022
9dbd070
Updated samples, added ability to consume an i3s layer from service a…
Tamrat-B Jul 9, 2022
3fa1e71
Merge branch 'CesiumGS:main' into cesium_i3s_support
Tamrat-B Jul 12, 2022
5dd0ef4
Merge branch 'CesiumGS:main' into cesium_i3s_support
Tamrat-B Jul 13, 2022
084e202
Merge branch 'CesiumGS:main' into cesium_i3s_support
Tamrat-B Jul 14, 2022
636d836
Merge branch 'CesiumGS:main' into cesium_i3s_support
Tamrat-B Jul 15, 2022
10feb5d
Merge branch 'CesiumGS:main' into cesium_i3s_support
Tamrat-B Aug 5, 2022
3e4ae82
Merge branch 'main' into cesium_i3s_support
lilleyse Aug 31, 2022
6a31215
Fix Lerc include, after https://github.com/CesiumGS/cesium/pull/10674
lilleyse Aug 31, 2022
405e579
Fixes in ArcGISTiledElevationTerrainProvider
lilleyse Aug 31, 2022
65c9803
Clean up I3S 3D Object Layer sandcastle
lilleyse Aug 31, 2022
2f3324e
Update thumbnail dimensions to 225x150
lilleyse Aug 31, 2022
19e7679
Tweak sandcastle labels
lilleyse Aug 31, 2022
80a26cd
Clean up I3S IntegratedMesh Layer sandcastle
lilleyse Aug 31, 2022
d031b3a
Clean up I3SDataProvider documentation, remove traceCode
lilleyse Aug 31, 2022
c7017ad
Fix z-fighting with base terrain layer in sandcastle demo
lilleyse Aug 31, 2022
9033839
Constructor cleanup
lilleyse Aug 31, 2022
bb0fe76
Fix boolean documentation
lilleyse Aug 31, 2022
0199346
Fix typo
lilleyse Aug 31, 2022
f0b3079
Remove unused getter
lilleyse Aug 31, 2022
f08066a
Use Check and wrap in pragma.debug
lilleyse Aug 31, 2022
ac44992
Comment spacing
lilleyse Aug 31, 2022
9418bd6
Remove debug console.log
lilleyse Aug 31, 2022
4a1a734
Fix doc
lilleyse Aug 31, 2022
4fe6e6c
Remove update doc and mark private
lilleyse Aug 31, 2022
7f6c1f9
Simplify prePassesUpdate, postPassesUpdate, updateForPass
lilleyse Aug 31, 2022
decf059
Style: Rename GLTF to Gltf
lilleyse Aug 31, 2022
06932f0
Remove private from local functions
lilleyse Aug 31, 2022
6317716
Clea up I3SSceneLayer doc
lilleyse Aug 31, 2022
32e7954
Remove _entities
lilleyse Aug 31, 2022
838d8dd
Clean up I3SLayer doc
lilleyse Aug 31, 2022
8cbe744
Use defined
lilleyse Aug 31, 2022
755c76e
Doc type consistency
lilleyse Aug 31, 2022
ba1c503
Remove empty line
lilleyse Aug 31, 2022
6ffdc1e
Merge branch 'CesiumGS:main' into cesium_i3s_support
Tamrat-B Sep 20, 2022
7b7d19a
-Added suite of unit tests and code reveiw changes
Tamrat-B Sep 20, 2022
ac04058
updated an outdated param
Tamrat-B Sep 20, 2022
37a3d29
added removed line to suppress terrain
Tamrat-B Sep 20, 2022
5a57a6a
Cleanup part 1
lilleyse Sep 22, 2022
f3917c8
Cleanup part 2
lilleyse Sep 22, 2022
178f357
Cleanup part 3
lilleyse Sep 22, 2022
9eab492
Cleanup part 4
lilleyse Sep 22, 2022
2e485b9
Add position min/max to fix culling issues
lilleyse Oct 6, 2022
fe1e95f
Use defined
lilleyse Oct 6, 2022
fa68785
Cleanup part 5
lilleyse Oct 6, 2022
9add20d
Update sandcastles
lilleyse Oct 6, 2022
1f98b36
Fix tests
lilleyse Oct 7, 2022
f0d7d17
Update documentation
lilleyse Oct 7, 2022
178ed54
Cleanup
lilleyse Oct 7, 2022
fbd4ad4
Fix tests
lilleyse Oct 7, 2022
9dd6024
Fix Promise types
lilleyse Oct 17, 2022
bb23732
Add separate files for I3SField and I3SGeometry
lilleyse Oct 17, 2022
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
176 changes: 176 additions & 0 deletions Apps/Sandcastle/gallery/I3S 3D Object Layer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<!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="Add I3S 3D Object Layer from a service."
/>
<meta name="cesium-sandcastle-labels" content="DataSources" />
<title>I3S Consumption Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script
type="text/javascript"
src="../../../Build/CesiumUnminified/Cesium.js"
nomodule
></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 = function (Cesium) {
"use strict";
//Sandcastle_Begin
const viewer = new Cesium.Viewer("cesiumContainer", {
terrainProvider: new Cesium.createWorldTerrain(),
animation: false,
timeline: false,
});
// More datasets to tour can be added here...
// The url passed to I3SDataProvider supports loading a single Indexed 3D Scene (I3S) layer (.<host>/SceneServer/layers/<id>) or a collection of scene layers (.<host>/SceneServer) from a SceneServer.
const tours = {
"San Francisco":
"https://tiles.arcgis.com/tiles/z2tnIkrLQ2BRzr6P/arcgis/rest/services/SanFrancisco_3DObjects_1_7/SceneServer/layers/0",
};
// Initialize a terrain provider which provides geoid conversion between gravity related (typically I3S datasets) and ellipsoidal based
// height systems (Cesium World Terrain).
// If this is not specified, or the URL is invalid no geoid conversion will be applied.
// The source data used in this transcoding service was compiled from https://earth-info.nga.mil/#tab_wgs84-data and is based on EGM2008 Gravity Model
const geoidService = new Cesium.ArcGISTiledElevationTerrainProvider({
url:
"https://tiles.arcgis.com/tiles/z2tnIkrLQ2BRzr6P/arcgis/rest/services/EGM2008/ImageServer",
});
// Create i3s and Cesium3DTileset options to pass optional parameters useful for debugging and visualizing
const cesium3dTilesetOptions = {
skipLevelOfDetail: false,
debugShowBoundingVolume: false,
};
const i3sOptions = {
url: tours["San Francisco"],
traceFetches: false, // for tracing I3S fetches
geoidTiledTerrainProvider: geoidService, // pass the geoid service
cesium3dTilesetOptions: cesium3dTilesetOptions, // options for internal Cesium3dTileset
};

// Create I3S data provider
const i3sProvider = new Cesium.I3SDataProvider(i3sOptions);

// Center camera on I3S once it's loaded
i3sProvider.readyPromise.then(function () {
const center = Cesium.Rectangle.center(i3sProvider.extent);
center.height = 10000.0;
viewer.camera.setView({
destination: Cesium.Ellipsoid.WGS84.cartographicToCartesian(center),
});
});

// Add the i3s layer provider as a primitive data type
viewer.scene.primitives.add(i3sProvider);
// An entity object which will hold info about the currently selected feature for infobox display
const selectedEntity = new Cesium.Entity();
// Show metadata in the InfoBox.
viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(
movement
) {
// Pick a new feature
const pickedFeature = viewer.scene.pick(movement.position);
if (!Cesium.defined(pickedFeature)) {
return;
}

const pickedPosition = viewer.scene.pickPosition(movement.position);

if (
Cesium.defined(pickedFeature.content) &&
Cesium.defined(pickedFeature.content.tile.i3sNode)
) {
const i3sNode = pickedFeature.content.tile.i3sNode;
i3sNode.loadFields().then(function () {
const geometry = i3sNode.geometryData[0];
if (pickedPosition) {
const location = geometry.getClosestPointIndexOnTriangle(
pickedPosition.x,
pickedPosition.y,
pickedPosition.z
);
let description = "No attributes";
let name;
if (
location.index !== -1 &&
geometry.customAttributes.featureIndex
) {
console.log(
`pickedPosition(x,y,z) : ${pickedPosition.x}, ${pickedPosition.y}, ${pickedPosition.z}`
);
const featureIndex =
geometry.customAttributes.featureIndex[location.index];
if (Object.keys(i3sNode.fields).length > 0) {
description =
'<table class="cesium-infoBox-defaultTable"><tbody>';
for (const fieldName in i3sNode.fields) {
if (i3sNode.fields.hasOwnProperty(fieldName)) {
const field = i3sNode.fields[fieldName];
description += `<tr><th>${field.name}</th><td>`;
description += `${field.values[featureIndex]}</td></tr>`;
console.log(
`${field.name}: ${field.values[featureIndex]}`
);
if (
!Cesium.defined(name) &&
isNameProperty(field.name)
) {
name = field.values[featureIndex];
}
}
}
description += `</tbody></table>`;
}
}
if (!Cesium.defined(name)) {
name = "unknown";
}
selectedEntity.name = name;
lilleyse marked this conversation as resolved.
Show resolved Hide resolved
selectedEntity.description = description;
viewer.selectedEntity = selectedEntity;
}
});
}
},
Cesium.ScreenSpaceEventType.LEFT_CLICK);

function isNameProperty(propertyName) {
const name = propertyName.toLowerCase();
if (
name.localeCompare("name") === 0 ||
name.localeCompare("objname") === 0
) {
return true;
}
return false;
}
//Sandcastle_End
if (typeof Cesium !== "undefined") {
window.startupCalled = true;
window.startup(Cesium);
}
};
</script>
</body>
</html>
Binary file added Apps/Sandcastle/gallery/I3S 3D Object Layer.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
176 changes: 176 additions & 0 deletions Apps/Sandcastle/gallery/I3S Feature Picking.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<!DOCTYPE html>
lilleyse marked this conversation as resolved.
Show resolved Hide resolved
<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="Pick features from an I3S 3D Object Layer."
/>
<meta name="cesium-sandcastle-labels" content="DataSources, Showcases" />
<title>I3S Feature Picking Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script
type="text/javascript"
src="../../../Build/CesiumUnminified/Cesium.js"
nomodule
></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 = function (Cesium) {
"use strict";
//Sandcastle_Begin
const viewer = new Cesium.Viewer("cesiumContainer", {
terrainProvider: new Cesium.createWorldTerrain(),
animation: false,
timeline: false,
});
// More datasets to tour can be added here...
// The url passed to I3SDataProvider supports loading a single Indexed 3D Scene (I3S) layer (.<host>/SceneServer/layers/<id>) or a collection of scene layers (.<host>/SceneServer) from a SceneServer.
const tours = {
lilleyse marked this conversation as resolved.
Show resolved Hide resolved
"New York":
"https://tiles.arcgis.com/tiles/z2tnIkrLQ2BRzr6P/arcgis/rest/services/NYC_Attributed_v17/SceneServer",
};
// Initialize a terrain provider which provides geoid conversion between gravity related (typically I3S datasets) and ellipsoidal based
// height systems (Cesium World Terrain).
// If this is not specified, or the URL is invalid no geoid conversion will be applied.
// The source data used in this transcoding service was compiled from https://earth-info.nga.mil/#tab_wgs84-data and is based on EGM2008 Gravity Model
const geoidService = new Cesium.ArcGISTiledElevationTerrainProvider({
url:
"https://tiles.arcgis.com/tiles/z2tnIkrLQ2BRzr6P/arcgis/rest/services/EGM2008/ImageServer",
});
// Create i3s and Cesium3DTileset options to pass optional parameters useful for debugging and visualizing
const cesium3dTilesetOptions = {
skipLevelOfDetail: false,
debugShowBoundingVolume: false,
};
const i3sOptions = {
url: tours["New York"],
traceFetches: false, // for tracing I3S fetches
geoidTiledTerrainProvider: geoidService, // pass the geoid service
cesium3dTilesetOptions: cesium3dTilesetOptions, // options for internal Cesium3dTileset
};

// Create I3S data provider
const i3sProvider = new Cesium.I3SDataProvider(i3sOptions);

// Center camera on I3S once it's loaded
i3sProvider.readyPromise.then(function () {
const center = Cesium.Rectangle.center(i3sProvider.extent);
center.height = 10000.0;
viewer.camera.setView({
destination: Cesium.Ellipsoid.WGS84.cartographicToCartesian(center),
});
});

// Add the i3s layer provider as a primitive data type
viewer.scene.primitives.add(i3sProvider);
// An entity object which will hold info about the currently selected feature for infobox display
const selectedEntity = new Cesium.Entity();
// Show metadata in the InfoBox.
viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(
movement
) {
// Pick a new feature
const pickedFeature = viewer.scene.pick(movement.position);
if (!Cesium.defined(pickedFeature)) {
return;
}

const pickedPosition = viewer.scene.pickPosition(movement.position);

if (
Cesium.defined(pickedFeature.content) &&
Cesium.defined(pickedFeature.content.tile.i3sNode)
) {
const i3sNode = pickedFeature.content.tile.i3sNode;
i3sNode.loadFields().then(function () {
const geometry = i3sNode.geometryData[0];
if (pickedPosition) {
const location = geometry.getClosestPointIndexOnTriangle(
pickedPosition.x,
pickedPosition.y,
pickedPosition.z
);
let description = "No attributes";
let name;
if (
location.index !== -1 &&
geometry.customAttributes.featureIndex
) {
console.log(
`pickedPosition(x,y,z) : ${pickedPosition.x}, ${pickedPosition.y}, ${pickedPosition.z}`
);
const featureIndex =
geometry.customAttributes.featureIndex[location.index];
if (Object.keys(i3sNode.fields).length > 0) {
description =
'<table class="cesium-infoBox-defaultTable"><tbody>';
for (const fieldName in i3sNode.fields) {
if (i3sNode.fields.hasOwnProperty(fieldName)) {
const field = i3sNode.fields[fieldName];
description += `<tr><th>${field.name}</th><td>`;
description += `${field.values[featureIndex]}</td></tr>`;
console.log(
`${field.name}: ${field.values[featureIndex]}`
);
if (
!Cesium.defined(name) &&
isNameProperty(field.name)
) {
name = field.values[featureIndex];
}
}
}
description += `</tbody></table>`;
}
}
if (!Cesium.defined(name)) {
name = "unknown";
}
selectedEntity.name = name;
selectedEntity.description = description;
viewer.selectedEntity = selectedEntity;
}
});
}
},
Cesium.ScreenSpaceEventType.LEFT_CLICK);

function isNameProperty(propertyName) {
const name = propertyName.toLowerCase();
if (
name.localeCompare("name") === 0 ||
name.localeCompare("objname") === 0
) {
return true;
}
return false;
}
//Sandcastle_End
if (typeof Cesium !== "undefined") {
window.startupCalled = true;
window.startup(Cesium);
}
};
</script>
</body>
</html>
Binary file added Apps/Sandcastle/gallery/I3S Feature Picking.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading