diff --git a/Apps/Sandcastle/gallery/I3S 3D Object Layer.html b/Apps/Sandcastle/gallery/I3S 3D Object Layer.html
index 0adbecb1c5d3..f63947dffc52 100644
--- a/Apps/Sandcastle/gallery/I3S 3D Object Layer.html
+++ b/Apps/Sandcastle/gallery/I3S 3D Object Layer.html
@@ -102,46 +102,31 @@
Loading...
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
- );
+ if (pickedPosition) {
+ i3sNode.loadFields().then(function () {
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 =
- '';
- for (const fieldName in i3sNode.fields) {
- if (i3sNode.fields.hasOwnProperty(fieldName)) {
- const field = i3sNode.fields[fieldName];
- description += `${field.name} | `;
- description += `${field.values[featureIndex]} |
`;
- console.log(
- `${field.name}: ${field.values[featureIndex]}`
- );
- if (
- !Cesium.defined(name) &&
- isNameProperty(field.name)
- ) {
- name = field.values[featureIndex];
- }
+ console.log(
+ `pickedPosition(x,y,z) : ${pickedPosition.x}, ${pickedPosition.y}, ${pickedPosition.z}`
+ );
+
+ const fields = i3sNode.getFieldsForPickedPosition(
+ pickedPosition
+ );
+ if (Object.keys(fields).length > 0) {
+ description =
+ '';
+ for (const fieldName in fields) {
+ if (i3sNode.fields.hasOwnProperty(fieldName)) {
+ description += `${fieldName} | `;
+ description += `${fields[fieldName]} |
`;
+ console.log(`${fieldName}: ${fields[fieldName]}`);
+ if (!Cesium.defined(name) && isNameProperty(fieldName)) {
+ name = fields[fieldName];
}
}
- description += `
`;
}
+ description += `
`;
}
if (!Cesium.defined(name)) {
name = "unknown";
@@ -149,8 +134,8 @@ Loading...
selectedEntity.name = name;
selectedEntity.description = description;
viewer.selectedEntity = selectedEntity;
- }
- });
+ });
+ }
}
},
Cesium.ScreenSpaceEventType.LEFT_CLICK);
diff --git a/Apps/Sandcastle/gallery/I3S Feature Picking.html b/Apps/Sandcastle/gallery/I3S Feature Picking.html
index 40a483927a64..3e9018886b71 100644
--- a/Apps/Sandcastle/gallery/I3S Feature Picking.html
+++ b/Apps/Sandcastle/gallery/I3S Feature Picking.html
@@ -102,46 +102,31 @@ Loading...
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
- );
+ if (pickedPosition) {
+ i3sNode.loadFields().then(function () {
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 =
- '';
- for (const fieldName in i3sNode.fields) {
- if (i3sNode.fields.hasOwnProperty(fieldName)) {
- const field = i3sNode.fields[fieldName];
- description += `${field.name} | `;
- description += `${field.values[featureIndex]} |
`;
- console.log(
- `${field.name}: ${field.values[featureIndex]}`
- );
- if (
- !Cesium.defined(name) &&
- isNameProperty(field.name)
- ) {
- name = field.values[featureIndex];
- }
+ console.log(
+ `pickedPosition(x,y,z) : ${pickedPosition.x}, ${pickedPosition.y}, ${pickedPosition.z}`
+ );
+
+ const fields = i3sNode.getFieldsForPickedPosition(
+ pickedPosition
+ );
+ if (Object.keys(fields).length > 0) {
+ description =
+ '';
+ for (const fieldName in fields) {
+ if (i3sNode.fields.hasOwnProperty(fieldName)) {
+ description += `${fieldName} | `;
+ description += `${fields[fieldName]} |
`;
+ console.log(`${fieldName}: ${fields[fieldName]}`);
+ if (!Cesium.defined(name) && isNameProperty(fieldName)) {
+ name = fields[fieldName];
}
}
- description += `
`;
}
+ description += `
`;
}
if (!Cesium.defined(name)) {
name = "unknown";
@@ -149,8 +134,8 @@ Loading...
selectedEntity.name = name;
selectedEntity.description = description;
viewer.selectedEntity = selectedEntity;
- }
- });
+ });
+ }
}
},
Cesium.ScreenSpaceEventType.LEFT_CLICK);
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index b9f44a0ad8c1..7716f6594ba1 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -337,3 +337,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Ilya Shevelev](https://github.com/ilyaly)
- [Gabriel Aldous](https://github.com/Sn00pyW00dst0ck)
- [金俊](https://github.com/jinjun1994)
+- [Oussama Bonnor](https://github.com/oussamabonnor1)
diff --git a/packages/engine/Source/Scene/I3SDataProvider.js b/packages/engine/Source/Scene/I3SDataProvider.js
index c4a2da950500..ac0fe6cb36dc 100644
--- a/packages/engine/Source/Scene/I3SDataProvider.js
+++ b/packages/engine/Source/Scene/I3SDataProvider.js
@@ -626,7 +626,8 @@ I3SDataProvider.prototype._loadGeoidData = function () {
console.log(
"No Geoid Terrain service provided - no geoid conversion will be performed."
);
- return Promise.resolve();
+ this._geoidDataIsReadyPromise = Promise.resolve();
+ return this._geoidDataIsReadyPromise;
}
this._geoidDataIsReadyPromise = geoidTerrainProvider.readyPromise.then(
diff --git a/packages/engine/Source/Scene/I3SFeature.js b/packages/engine/Source/Scene/I3SFeature.js
index 876fb8f2e548..f2c5b9822a2b 100644
--- a/packages/engine/Source/Scene/I3SFeature.js
+++ b/packages/engine/Source/Scene/I3SFeature.js
@@ -49,7 +49,7 @@ Object.defineProperties(I3SFeature.prototype, {
/**
* Loads the content.
- * @returns {Promise.