(gl, _ref)
| 45387 | // Pick the closest object at the given (x,y) coordinate |
| 45388 | |
| 45389 | function pickObject(gl, _ref) { |
| 45390 | var layers = _ref.layers, |
| 45391 | viewports = _ref.viewports, |
| 45392 | x = _ref.x, |
| 45393 | y = _ref.y, |
| 45394 | radius = _ref.radius, |
| 45395 | layerFilter = _ref.layerFilter, |
| 45396 | _ref$depth = _ref.depth, |
| 45397 | depth = _ref$depth === void 0 ? 1 : _ref$depth, |
| 45398 | mode = _ref.mode, |
| 45399 | onViewportActive = _ref.onViewportActive, |
| 45400 | pickingFBO = _ref.pickingFBO, |
| 45401 | lastPickedInfo = _ref.lastPickedInfo, |
| 45402 | useDevicePixels = _ref.useDevicePixels; // Convert from canvas top-left to WebGL bottom-left coordinates |
| 45403 | // And compensate for pixelRatio |
| 45404 | |
| 45405 | var pixelRatio = (0, _drawLayers.getPixelRatio)({ |
| 45406 | useDevicePixels: useDevicePixels |
| 45407 | }); |
| 45408 | var deviceX = Math.round(x * pixelRatio); |
| 45409 | var deviceY = Math.round(gl.canvas.height - y * pixelRatio); |
| 45410 | var deviceRadius = Math.round(radius * pixelRatio); |
| 45411 | var deviceRect = getPickingRect({ |
| 45412 | deviceX: deviceX, |
| 45413 | deviceY: deviceY, |
| 45414 | deviceRadius: deviceRadius, |
| 45415 | deviceWidth: pickingFBO.width, |
| 45416 | deviceHeight: pickingFBO.height |
| 45417 | }); |
| 45418 | var result = []; |
| 45419 | var affectedLayers = {}; |
| 45420 | |
| 45421 | for (var i = 0; i < depth; i++) { |
| 45422 | var pickedColors = deviceRect && drawAndSamplePickingBuffer(gl, { |
| 45423 | layers: layers, |
| 45424 | viewports: viewports, |
| 45425 | onViewportActive: onViewportActive, |
| 45426 | useDevicePixels: useDevicePixels, |
| 45427 | pickingFBO: pickingFBO, |
| 45428 | deviceRect: deviceRect, |
| 45429 | layerFilter: layerFilter, |
| 45430 | redrawReason: mode |
| 45431 | }); |
| 45432 | var pickInfo = pickedColors && getClosestFromPickingBuffer(gl, { |
| 45433 | pickedColors: pickedColors, |
| 45434 | layers: layers, |
| 45435 | deviceX: deviceX, |
| 45436 | deviceY: deviceY, |
| 45437 | deviceRadius: deviceRadius, |
| 45438 | deviceRect: deviceRect |
| 45439 | }) || NO_PICKED_OBJECT; // Only exclude if we need to run picking again. |
| 45440 | // We need to run picking again if an object is detected AND |
| 45441 | // we have not exhausted the requested depth. |
| 45442 | |
| 45443 | if (pickInfo.pickedColor && i + 1 < depth) { |
| 45444 | var layerId = pickInfo.pickedColor[3] - 1; |
| 45445 | |
| 45446 | if (!affectedLayers[layerId]) { |
nothing calls this directly
no test coverage detected