You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api-reference/core/deck.md
+79Lines changed: 79 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -634,8 +634,83 @@ Parameters:
634
634
* `force` (boolean) - if `false`, only redraw if necessary (e.g. changes have been made to views or layers). If `true`, skip the check. Default `false`.
635
635
636
636
637
+
#### `pickObjectAsync` {#pickobjectasync}
638
+
639
+
Get the closest pickable and visible object at the given screen coordinate.
640
+
641
+
```ts
642
+
awaitdeck.pickObjectAsync({x, y, radius, layerIds, unproject3D})
643
+
```
644
+
645
+
Parameters:
646
+
647
+
* `x` (number) - x position in pixels
648
+
* `y` (number) - y position in pixels
649
+
* `radius` (number, optional) - radius of tolerance in pixels. Default `0`.
650
+
* `layerIds` (string[], optional) - a list of layer ids to query from. If not specified, then all pickable and visible layers are queried.
651
+
* `unproject3D` (boolean, optional) - if `true`, `info.coordinate` will be a 3D point by unprojecting the `x, y` screen coordinates onto the picked geometry. Default `false`.
652
+
653
+
Returns:
654
+
655
+
* a single [`info`](../../developer-guide/interactivity.md#the-pickinginfo-object) object, or `null` if nothing is found.
Performs deep picking. Finds all close pickable and visible object at the given screen coordinate, even if those objects are occluded by other objects.
661
+
662
+
```ts
663
+
awaitdeck.pickMultipleObjectsAsync({x, y, radius, layerIds, depth, unproject3D})
664
+
```
665
+
666
+
Parameters:
667
+
668
+
* `x` (number) - x position in pixels
669
+
* `y` (number) - y position in pixels
670
+
* `radius` (number, optional) - radius of tolerance in pixels. Default `0`.
671
+
* `layerIds` (string[], optional) - a list of layer ids to query from. If not specified, then all pickable and visible layers are queried.
672
+
* `depth` - Specifies the max number of objects to return. Default `10`.
673
+
* `unproject3D` (boolean, optional) - if `true`, `info.coordinate` will be a 3D point by unprojecting the `x, y` screen coordinates onto the picked geometry. Default `false`.
674
+
675
+
Returns:
676
+
677
+
* An array of [`info`](../../developer-guide/interactivity.md#the-pickinginfo-object) objects. The array will be empty if no object was picked.
678
+
679
+
Notes:
680
+
681
+
* Deep picking is implemented as a sequence of simpler picking operations and can have a performance impact. Should this become a concern, you can use the `depth` parameter to limit the number of matches that can be returned, and thus the maximum number of picking operations.
682
+
683
+
684
+
#### `pickObjectsAsync` {#pickobjectsasync}
685
+
686
+
Get all pickable and visible objects within a bounding box.
687
+
688
+
```ts
689
+
awaitdeck.pickObjectsAsync({x, y, width, height, layerIds, maxObjects})
690
+
```
691
+
692
+
Parameters:
693
+
694
+
* `x` (number) - left of the bounding box in pixels
695
+
* `y` (number) - top of the bouding box in pixels
696
+
* `width` (number, optional) - width of the bouding box in pixels. Default `1`.
697
+
* `height` (number, optional) - height of the bouding box in pixels. Default `1`.
698
+
* `layerIds` (string[], optional) - a list of layer ids to query from. If not specified, then all pickable and visible layers are queried.
699
+
* `maxObjects` (number, optional) - if specified, limits the number of objects that can be returned.
700
+
701
+
Returns:
702
+
703
+
* an array of unique [`info`](../../developer-guide/interactivity.md#the-pickinginfo-object) objects
704
+
705
+
Notes:
706
+
707
+
* The query methods are designed to quickly find objects by utilizing the picking buffer.
708
+
* The query methods offer more flexibility for developers to handle events compared to the built-in hover and click callbacks.
Performs deep picking. Finds all close pickable and visible object at the given screen coordinate, even if those objects are occluded by other objects.
Copy file name to clipboardExpand all lines: docs/developer-guide/interactivity.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -965,7 +965,7 @@ function App() {
965
965
966
966
While the default events handle most of the use cases, sometimes applications need more control over when and how picking is performed.
967
967
968
-
The picking engine is exposed through the [`Deck.pickObject`](../api-reference/core/deck.md#pickobject) and [`Deck.pickObjects`](../api-reference/core/deck.md#pickobjects) methods. These methods allow you to query what layers and objects within those layers are under a specific point or within a specified rectangle. They return `PickingInfo` objects as described above.
968
+
The picking engine is exposed through the [`Deck.pickObjectAsync`](../api-reference/core/deck.md#pickobjectasync) and [`Deck.pickObjectsAsync`](../api-reference/core/deck.md#pickobjectsasync) methods. These methods allow you to query what layers and objects within those layers are under a specific point or within a specified rectangle. They return `PickingInfo` objects as described above.
969
969
970
970
971
971
<TabsgroupId="language">
@@ -976,9 +976,9 @@ import {Deck} from '@deck.gl/core';
976
976
977
977
constdeckInstance=newDeck({
978
978
// ...
979
-
onClick: ({x, y}) => {
979
+
onClick:async({x, y}) => {
980
980
// Query up to 5 overlapping objects under the pointer
981
-
constpickInfos=deckInstance.pickMultipleObjects({x, y, radius:1, depth:5});
981
+
constpickInfos=awaitdeckInstance.pickMultipleObjectsAsync({x, y, radius:1, depth:5});
982
982
console.log(pickInfo);
983
983
}
984
984
});
@@ -992,9 +992,9 @@ import {Deck, PickingInfo} from '@deck.gl/core';
992
992
993
993
const deckInstance =newDeck({
994
994
// ...
995
-
onClick: ({x, y}:PickingInfo) => {
995
+
onClick: async({x, y}:PickingInfo) => {
996
996
// Query up to 5 overlapping objects under the pointer
997
-
const pickInfos:PickingInfo[] =deckInstance.pickMultipleObjects({x, y, radius: 1, depth: 5});
997
+
const pickInfos:PickingInfo[] =awaitdeckInstance.pickMultipleObjectsAsync({x, y, radius: 1, depth: 5});
998
998
console.log(pickInfo);
999
999
}
1000
1000
});
@@ -1011,13 +1011,13 @@ import {PickingInfo} from '@deck.gl/core';
// Query up to 5 overlapping objects under the pointer
1020
-
const pickInfos:PickingInfo[] =deckRef.current?.pickMultipleObjects({x, y, radius: 1, depth: 5});
1020
+
const pickInfos:PickingInfo[] =awaitdeckRef.current?.pickMultipleObjectsAsync({x, y, radius: 1, depth: 5});
1021
1021
console.log(pickInfo);
1022
1022
}, [])
1023
1023
@@ -1031,7 +1031,7 @@ function App() {
1031
1031
</Tabs>
1032
1032
1033
1033
1034
-
Also note that by directly calling `pickObject`, integrating deck.gl into an existing application often becomes easier since you don't have to change the application's existing approach to event handling.
1034
+
Also note that by directly calling `pickObjectAsync`, integrating deck.gl into an existing application often becomes easier since you don't have to change the application's existing approach to event handling.
0 commit comments