MCPcopy
hub / github.com/CesiumGS/cesium / pickPosition

Function pickPosition

packages/engine/Source/Scene/ScreenSpaceCameraController.js:1145–1183  ·  view source on GitHub ↗
(controller, mousePosition, result)

Source from the content-addressed store, hash-verified

1143const scratchRayIntersection = new Cartesian3();
1144
1145function 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
1185const scratchDistanceCartographic = new Cartographic();
1186

Callers 8

handleZoomFunction · 0.85
translateCVFunction · 0.85
rotateCVOnTerrainFunction · 0.85
zoomCVFunction · 0.85
spin3DFunction · 0.85
pan3DFunction · 0.85
zoom3DFunction · 0.85
tilt3DOnTerrainFunction · 0.85

Calls 3

definedFunction · 0.50
cloneMethod · 0.45
distanceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…