API Reference

Class List

pc.Picker

Picker object used to select mesh instances from screen coordinates.

Summary

Properties

heightHeight of the pick buffer in pixels (read-only).
renderTargetThe render target used by the picker internally (read-only).
widthWidth of the pick buffer in pixels (read-only).

Methods

getSelectionReturn the list of mesh instances selected by the specified rectangle in the previously prepared pick buffer.
preparePrimes the pick buffer with a rendering of the specified models from the point of view of the supplied camera.
resizeSets the resolution of the pick buffer.

Details

Constructor

Picker(device, width, height)

Create a new instance of a Picker object

Parameters

devicepc.GraphicsDeviceGraphics device used to manage internal graphics resources.
widthNumberThe width of the pick buffer in pixels.
heightNumberThe height of the pick buffer in pixels.

Properties

Numberheight

Height of the pick buffer in pixels (read-only).

pc.RenderTargetrenderTarget

The render target used by the picker internally (read-only).

Numberwidth

Width of the pick buffer in pixels (read-only).

Methods

getSelection(x, y, [width], [height])

Return the list of mesh instances selected by the specified rectangle in the previously prepared pick buffer.The rectangle using top-left coordinate system.

// 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);

Parameters

xNumberThe left edge of the rectangle
yNumberThe top edge of the rectangle
widthNumberThe width of the rectangle
heightNumberThe height of the rectangle

Returns

pc.MeshInstance[] An array of mesh instances that are in the selection

prepare(camera, scene)

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

camerapc.CameraThe camera used to render the scene, note this is the CameraNode, not an Entity
scenepc.SceneThe scene containing the pickable mesh instances.

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

widthNumberThe width of the pick buffer in pixels.
heightNumberThe height of the pick buffer in pixels.