* Drill pick by repeatedly calling a given `pickCallback`, each time stripping away the previously picked objects. * @param {function(number): object[]} pickCallback Pick callback to execute each iteration * @param {number} [limit=Number.MAX_VALUE] If supplied, stop drilling after collecting this
(pickCallback, limit)
| 882 | * @ignore |
| 883 | */ |
| 884 | function drillPick(pickCallback, limit) { |
| 885 | // PERFORMANCE_IDEA: This function calls each primitive's update for each pass. Instead |
| 886 | // we could update the primitive once, and then just execute their commands for each pass, |
| 887 | // and cull commands for picked primitives. e.g., base on the command's owner. |
| 888 | const results = []; |
| 889 | const pickedPrimitives = []; |
| 890 | const pickedAttributes = []; |
| 891 | const pickedFeatures = []; |
| 892 | if (!defined(limit)) { |
| 893 | limit = Number.MAX_VALUE; |
| 894 | } |
| 895 | |
| 896 | let pickedResults = pickCallback(limit); |
| 897 | while (defined(pickedResults) && pickedResults.length > 0) { |
| 898 | const complete = addDrillPickedResults( |
| 899 | pickedResults, |
| 900 | limit, |
| 901 | results, |
| 902 | pickedPrimitives, |
| 903 | pickedAttributes, |
| 904 | pickedFeatures, |
| 905 | ); |
| 906 | if (complete) { |
| 907 | break; |
| 908 | } |
| 909 | pickedResults = pickCallback(limit - results.length); |
| 910 | } |
| 911 | |
| 912 | // Unhide everything we hid while drill picking |
| 913 | for (let i = 0; i < pickedPrimitives.length; ++i) { |
| 914 | pickedPrimitives[i].show = true; |
| 915 | } |
| 916 | |
| 917 | for (let i = 0; i < pickedAttributes.length; ++i) { |
| 918 | const attributes = pickedAttributes[i]; |
| 919 | attributes.show = ShowGeometryInstanceAttribute.toValue( |
| 920 | true, |
| 921 | attributes.show, |
| 922 | ); |
| 923 | } |
| 924 | |
| 925 | for (let i = 0; i < pickedFeatures.length; ++i) { |
| 926 | pickedFeatures[i].show = true; |
| 927 | } |
| 928 | |
| 929 | return results; |
| 930 | } |
| 931 | |
| 932 | Picking.prototype.drillPick = function ( |
| 933 | scene, |
no test coverage detected
searching dependent graphs…