(controller, mousePosition, result)
| 1143 | const scratchRayIntersection = new Cartesian3(); |
| 1144 | |
| 1145 | function pickPosition(controller, mousePosition, result) { |
| 1146 | const scene = controller._scene; |
| 1147 | const globe = controller._globe; |
| 1148 | const camera = scene.camera; |
| 1149 | |
| 1150 | let depthIntersection; |
| 1151 | if (scene.pickPositionSupported) { |
| 1152 | depthIntersection = scene.pickPositionWorldCoordinates( |
| 1153 | mousePosition, |
| 1154 | scratchDepthIntersection, |
| 1155 | ); |
| 1156 | } |
| 1157 | |
| 1158 | if (!defined(globe)) { |
| 1159 | return Cartesian3.clone(depthIntersection, result); |
| 1160 | } |
| 1161 | |
| 1162 | const cullBackFaces = !controller._cameraUnderground; |
| 1163 | const ray = camera.getPickRay(mousePosition, pickGlobeScratchRay); |
| 1164 | const rayIntersection = globe.pickWorldCoordinates( |
| 1165 | ray, |
| 1166 | scene, |
| 1167 | cullBackFaces, |
| 1168 | scratchRayIntersection, |
| 1169 | ); |
| 1170 | |
| 1171 | const pickDistance = defined(depthIntersection) |
| 1172 | ? Cartesian3.distance(depthIntersection, camera.positionWC) |
| 1173 | : Number.POSITIVE_INFINITY; |
| 1174 | const rayDistance = defined(rayIntersection) |
| 1175 | ? Cartesian3.distance(rayIntersection, camera.positionWC) |
| 1176 | : Number.POSITIVE_INFINITY; |
| 1177 | |
| 1178 | if (pickDistance < rayDistance) { |
| 1179 | return Cartesian3.clone(depthIntersection, result); |
| 1180 | } |
| 1181 | |
| 1182 | return Cartesian3.clone(rayIntersection, result); |
| 1183 | } |
| 1184 | |
| 1185 | const scratchDistanceCartographic = new Cartographic(); |
| 1186 |
no test coverage detected
searching dependent graphs…