@@ -102,55 +102,40 @@ <h1>Loading...</h1>
102
102
Cesium . defined ( pickedFeature . content . tile . i3sNode )
103
103
) {
104
104
const i3sNode = pickedFeature . content . tile . i3sNode ;
105
- i3sNode . loadFields ( ) . then ( function ( ) {
106
- const geometry = i3sNode . geometryData [ 0 ] ;
107
- if ( pickedPosition ) {
108
- const location = geometry . getClosestPointIndexOnTriangle (
109
- pickedPosition . x ,
110
- pickedPosition . y ,
111
- pickedPosition . z
112
- ) ;
105
+ if ( pickedPosition ) {
106
+ i3sNode . loadFields ( ) . then ( function ( ) {
113
107
let description = "No attributes" ;
114
108
let name ;
115
- if (
116
- location . index !== - 1 &&
117
- geometry . customAttributes . featureIndex
118
- ) {
119
- console . log (
120
- `pickedPosition(x,y,z) : ${ pickedPosition . x } , ${ pickedPosition . y } , ${ pickedPosition . z } `
121
- ) ;
122
- const featureIndex =
123
- geometry . customAttributes . featureIndex [ location . index ] ;
124
- if ( Object . keys ( i3sNode . fields ) . length > 0 ) {
125
- description =
126
- '<table class="cesium-infoBox-defaultTable"><tbody>' ;
127
- for ( const fieldName in i3sNode . fields ) {
128
- if ( i3sNode . fields . hasOwnProperty ( fieldName ) ) {
129
- const field = i3sNode . fields [ fieldName ] ;
130
- description += `<tr><th>${ field . name } </th><td>` ;
131
- description += `${ field . values [ featureIndex ] } </td></tr>` ;
132
- console . log (
133
- `${ field . name } : ${ field . values [ featureIndex ] } `
134
- ) ;
135
- if (
136
- ! Cesium . defined ( name ) &&
137
- isNameProperty ( field . name )
138
- ) {
139
- name = field . values [ featureIndex ] ;
140
- }
109
+ console . log (
110
+ `pickedPosition(x,y,z) : ${ pickedPosition . x } , ${ pickedPosition . y } , ${ pickedPosition . z } `
111
+ ) ;
112
+
113
+ const fields = i3sNode . getFieldsForPickedPosition (
114
+ pickedPosition
115
+ ) ;
116
+ if ( Object . keys ( fields ) . length > 0 ) {
117
+ description =
118
+ '<table class="cesium-infoBox-defaultTable"><tbody>' ;
119
+ for ( const fieldName in fields ) {
120
+ if ( i3sNode . fields . hasOwnProperty ( fieldName ) ) {
121
+ description += `<tr><th>${ fieldName } </th><td>` ;
122
+ description += `${ fields [ fieldName ] } </td></tr>` ;
123
+ console . log ( `${ fieldName } : ${ fields [ fieldName ] } ` ) ;
124
+ if ( ! Cesium . defined ( name ) && isNameProperty ( fieldName ) ) {
125
+ name = fields [ fieldName ] ;
141
126
}
142
127
}
143
- description += `</tbody></table>` ;
144
128
}
129
+ description += `</tbody></table>` ;
145
130
}
146
131
if ( ! Cesium . defined ( name ) ) {
147
132
name = "unknown" ;
148
133
}
149
134
selectedEntity . name = name ;
150
135
selectedEntity . description = description ;
151
136
viewer . selectedEntity = selectedEntity ;
152
- }
153
- } ) ;
137
+ } ) ;
138
+ }
154
139
}
155
140
} ,
156
141
Cesium . ScreenSpaceEventType . LEFT_CLICK ) ;
0 commit comments