Skip to content

Class: Picker ​

Experimental

Routes picks to the CPU (2D) or GPU (3D) implementation per viewport. One per render root; see createPicker.

Constructors ​

Constructor ​

ts
new Picker(host, options?): Picker;

Experimental

Parameters ​

ParameterType
hostPickerHost
optionsPickerOptions

Returns ​

Picker

Properties ​

PropertyModifierTypeDescription
hostreadonlyPickerHostExperimental

Accessors ​

size ​

Get Signature ​

ts
get size(): number;

Experimental

Number of registrations across all viewports.

Returns ​

number

Methods ​

add() ​

ts
add(
   viewport,
   target,
   options?
): number;

Experimental

Make target pickable in viewport and return a handle id for remove. The route is chosen by viewport kind (pickRouteFor).

Parameters ​

ParameterType
viewportViewport
targetPickTarget
optionsGpuPickableOptions

Returns ​

number

Throws ​

TypeError when the target does not fit the route (e.g. a plain Object3D in 2D).


clearViewport() ​

ts
clearViewport(viewport): void;

Experimental

Drop every registration and pick resource of one viewport (e.g. before removing it).

Parameters ​

ParameterType
viewportViewport

Returns ​

void


dispose() ​

ts
dispose(): void;

Experimental

Returns ​

void


gpuPickerFor() ​

ts
gpuPickerFor(viewport): GpuPickerLike | null;

Experimental

The GPU picker serving a 3D viewport, if any pickable was added there.

Parameters ​

ParameterType
viewportViewport

Returns ​

GpuPickerLike | null


pick() ​

ts
pick(
   x,
   y,
   options?
): Promise<PickResult[]>;

Experimental

Pick at a container-space CSS position (e.g. event.offsetX/Y on the canvas), routed to the topmost viewport there. Results are nearest first and carry viewport.

Parameters ​

ParameterType
xnumber
ynumber
optionsPickOptions

Returns ​

Promise<PickResult[]>


pickIn() ​

ts
pickIn(
   viewport,
   x,
   y,
   options?
): Promise<PickResult[]>;

Experimental

Pick in a specific viewport (container-space CSS position).

Parameters ​

ParameterType
viewportViewport
xnumber
ynumber
optionsPickOptions

Returns ​

Promise<PickResult[]>


pickInSync() ​

ts
pickInSync(
   viewport,
   x,
   y,
   options?
): PickResult[] | null;

Experimental

pickSync for a specific viewport.

Parameters ​

ParameterType
viewportViewport
xnumber
ynumber
optionsPickOptions

Returns ​

PickResult[] | null


pickSync() ​

ts
pickSync(
   x,
   y,
   options?
): PickResult[] | null;

Experimental

Synchronous pick for CPU-routed (2D) viewports; returns null when the position routes to a 3D viewport (use pick). Handy for hover handlers that must answer in the same event.

Parameters ​

ParameterType
xnumber
ynumber
optionsPickOptions

Returns ​

PickResult[] | null


remove() ​

ts
remove(id): boolean;

Experimental

Remove a registration by handle id. Returns whether it existed.

Parameters ​

ParameterType
idnumber

Returns ​

boolean

Released under the MIT License.