Create a new Picker instance.
The application managing this picker instance.
The width of the pick buffer in pixels.
The height of the pick buffer in pixels.
Optionaldepth: boolean = falseWhether to enable depth picking. When enabled, depth information is captured alongside mesh IDs using MRT. Defaults to false.
Frees resources associated with this picker.
Return the list of mesh instances selected by the specified rectangle in the previously prepared pick buffer. The rectangle using top-left coordinate system.
Note: This function is not supported on WebGPU. Use Picker#getSelectionAsync instead. Note: This function is blocks the main thread while reading pixels from GPU memory. It's recommended to use Picker#getSelectionAsync instead.
The left edge of the rectangle.
The top edge of the rectangle.
Optionalwidth: number = 1The width of the rectangle. Defaults to 1.
Optionalheight: number = 1The height of the rectangle. Defaults to 1.
An array of mesh instances that are in the selection.
Return the list of mesh instances selected by the specified rectangle in the previously prepared pick buffer. The rectangle uses top-left coordinate system.
This method is asynchronous and does not block the execution.
The left edge of the rectangle.
The top edge of the rectangle.
Optionalwidth: number = 1The width of the rectangle. Defaults to 1.
Optionalheight: number = 1The height of the rectangle. Defaults to 1.
Return the world position of the mesh instance picked at the specified screen coordinates.
The x coordinate of the pixel to pick.
The y coordinate of the pixel to pick.
Promise that resolves with the world position of the picked point, or null if no depth is available or nothing was picked.
Primes the pick buffer with a rendering of the specified models from the point of view of the supplied camera. Once the pick buffer has been prepared, Picker#getSelection can be called multiple times on the same picker object. Therefore, if the models or camera do not change in any way, Picker#prepare does not need to be called again.
The camera component used to render the scene.
The scene containing the pickable mesh instances.
Optionallayers: Layer[]Layers from which objects will be picked. If not supplied, all layers of the specified camera will be used.
Sets the resolution of the pick buffer. The pick buffer resolution does not need to match the resolution of the corresponding frame buffer use for general rendering of the 3D scene. However, the lower the resolution of the pick buffer, the less accurate the selection results returned by Picker#getSelection. On the other hand, smaller pick buffers will yield greater performance, so there is a trade off.
The width of the pick buffer in pixels.
The height of the pick buffer in pixels.
Picker object used to select mesh instances from screen coordinates. It can also optionally capture depth information to determine world positions of picked points.
The picker works by rendering mesh instances to an offscreen render target with unique IDs encoded as colors. When queried, it reads back the pixel data to identify which mesh instance was at the specified screen coordinates. If depth picking is enabled, it also captures depth values to compute world positions.
Main API methods:
Performance considerations: The picker resolution can be set lower than the screen resolution for better performance, though this reduces picking precision and may miss small objects.
Example
See