Class: Picker

pc.Picker

Picker object used to select mesh instances from screen coordinates.

Constructor

new Picker(app, width, height)

Create a new instance of a Picker object
Parameters:
Name Type Description
app pc.Application The application managing this picker instance.
width Number The width of the pick buffer in pixels.
height Number The height of the pick buffer in pixels.
Properties:
Name Type Description
width Number Width of the pick buffer in pixels (read-only).
height Number Height of the pick buffer in pixels (read-only).
renderTarget pc.RenderTarget The render target used by the picker internally (read-only).
Source:

Methods

getSelection(x, y, widthopt, heightopt) → {Array.<pc.MeshInstance>}

Return the list of mesh instances selected by the specified rectangle in the previously prepared pick buffer.The rectangle using top-left coordinate system.
Parameters:
Name Type Attributes Description
x Number The left edge of the rectangle
y Number The top edge of the rectangle
width Number <optional>
The width of the rectangle
height Number <optional>
The height of the rectangle
Source:
Returns:
An array of mesh instances that are in the selection
Type
Array.<pc.MeshInstance>
Example
// Get the selection at the point (10,20)
var selection = picker.getSelection(10, 20);

// Get all models in rectangle with corners at (10,20) and (20,40)
var selection = picker.getSelection(10, 20, 10, 20);

prepare(camera, scene, argopt)

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, pc.Picker#getSelection can be called multiple times on the same picker object. Therefore, if the models or camera do not change in any way, pc.Picker#prepare does not need to be called again.
Parameters:
Name Type Attributes Description
camera pc.CameraComponent The camera component used to render the scene.
scene pc.Scene The scene containing the pickable mesh instances.
arg pc.Layer | pc.RenderTarget <optional>
Layer or RenderTarget from which objects will be picked. If not supplied, all layers rendering to backbuffer before this layer will be used.
Source:

resize(width, height)

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 pc.Picker#getSelection. On the other hand, smaller pick buffers will yield greater performance, so there is a trade off.
Parameters:
Name Type Description
width Number The width of the pick buffer in pixels.
height Number The height of the pick buffer in pixels.
Source: