# Interface Selectables

Methods and properties related to gpu picking. Basically "given a rendered pixel what object does that pixel represent".

interface Selectables {
attach(mesh: Mesh | Icon, o?: AttachOption): number;
detach(mesh: Mesh | Icon): boolean;
getVisiblesInSight(o?: GetVisibleInSightOptions): VisibleSelectable[];
getVisiblesInSight(
inSightCamera?: Camera,
textureSizePow2?: number,
isDistanceCullingEnabled?: boolean,
): VisibleSelectable[];
getVisiblesInSight(
inSightCamera?: Camera | GetVisibleInSightOptions,
textureSizePow2?: number,
isDistanceCullingEnabled?: boolean,
): VisibleSelectable[];
idOf(meshOrIcon: Mesh | Icon): number;
pick(o: PickOption): PickResult;
pick(
picker: TargetCamera,
textureSizePow2?: number,
doIntersectionTestOnGeometry?: boolean,
saveRenderedGpuPickingSceneTexture?: boolean,
): PickResult;
}

#### Implemented by

- GpuSelectables

##### Index

### Methods

attach
detach
getVisiblesInSight
idOf
pick

## Methods

### attach

- attach(mesh: Mesh | Icon, o?: AttachOption): number

  Attaches custom BabylonJS meshes so they can be "picked".

  #### Parameters

  - mesh: Mesh | Icon
  - `Optional` o: AttachOption

  #### Returns number

### detach

- detach(mesh: Mesh | Icon): boolean

  Detaches a previously attached BabylonJS mesh from "pick" operations.

  #### Parameters

  - mesh: Mesh | Icon

  #### Returns boolean

### getVisiblesInSight

- getVisiblesInSight(o?: GetVisibleInSightOptions): VisibleSelectable[]

  Renders objects and checks which objects are in sight from given camera.

  #### Parameters

  - `Optional` o: GetVisibleInSightOptions

    Options for getting visible objects in sight.

  #### Returns VisibleSelectable[]

- getVisiblesInSight(
  inSightCamera?: Camera,
  textureSizePow2?: number,
  isDistanceCullingEnabled?: boolean,
  ): VisibleSelectable[]

  Renders objects and checks which objects are in sight from given camera.

  #### Parameters

  - `Optional` inSightCamera: Camera

    Camera to represent the view to check for visible objects. If not specified, then current active camera is used.

  - `Optional` textureSizePow2: number

    Resolution of the texture to be used for in sight detection. (The bigger the texture is, the higher precision when picking.)

  - `Optional` isDistanceCullingEnabled: boolean

    Whether to enable distance culling.

  #### Returns VisibleSelectable[]

- getVisiblesInSight(
  inSightCamera?: Camera | GetVisibleInSightOptions,
  textureSizePow2?: number,
  isDistanceCullingEnabled?: boolean,
  ): VisibleSelectable[]

  #### Parameters

  - `Optional` inSightCamera: Camera | GetVisibleInSightOptions
  - `Optional` textureSizePow2: number
  - `Optional` isDistanceCullingEnabled: boolean

  #### Returns VisibleSelectable[]

### idOf

- idOf(meshOrIcon: Mesh | Icon): number

  Get unique "pick" id of mesh or icon. It is only valid as long as the item has been registered with attach. It will be 0 if not attached.

  #### Parameters

  - meshOrIcon: Mesh | Icon

    mesh or icon to get id for.

  #### Returns number

  0 if not attached, otherwise unique "pick" id.

### pick

- pick(o: PickOption): PickResult

  Performs an intersection test in the world (finds objects below a specific screen coordinate or that intersect a ray).

  #### Parameters

  - o: PickOption

    Options to use for pick operation.

  #### Returns PickResult

  Intersection information.

- pick(
  picker: TargetCamera,
  textureSizePow2?: number,
  doIntersectionTestOnGeometry?: boolean,
  saveRenderedGpuPickingSceneTexture?: boolean,
  ): PickResult

  Performs an intersection test in the world (find objects below a specific camera or screen coordinate, or that intersect a ray).

  #### Parameters

  - picker: TargetCamera

    TargetCamera or PickOption..

  - `Optional` textureSizePow2: number

    texture size (defaults to 16x16) used when rendering the world during pick operation.

  - `Optional` doIntersectionTestOnGeometry: boolean

    `true` to perform exact intersection on intersected object (exact coordinate etc). This is computationally expensive.

  - `Optional` saveRenderedGpuPickingSceneTexture: boolean

    `true` to save the rendering texture of the pick operation. Mostly useful for debugging.

  #### Returns PickResult