API

Class GPUPicker

Class used to perform a picking operation using GPU GPUPicker can pick meshes, instances and thin instances

Index
  • get defaultRenderMaterials(): readonly Nullable<ShaderMaterial>[]

    Gets the default render materials used by the picker.

    index is Material filling mode

    Returns readonly Nullable<ShaderMaterial>[]

  • get enableDepthPicking(): boolean

    Gets or sets a boolean indicating if depth-based pickedPoint and normal reconstruction should be enabled.

    When disabled, GPUPicker uses the original single-color render target and shader path. When enabled, GPUPicker switches to a MultiRenderTarget and compiles the default picking shader with GPUPICKER_DEPTH to output both the picking id and the depth required to reconstruct the picked point and normal.

    Custom picking materials and special picking material plugins should also write the depth attachment. If they do not, GPUPicker will still try to reconstruct pickedPoint and normal from the depth target, but the returned values may be missing or incorrect.

    Returns boolean

  • set enableDepthPicking(value: boolean): void

    Parameters

    • value: boolean

    Returns void

  • Execute a picking operation on box defined by two screen coordinates

    Parameters

    • x1: number

      defines the X coordinate of the first corner of the box where to run the pick

    • y1: number

      defines the Y coordinate of the first corner of the box where to run the pick

    • x2: number

      defines the X coordinate of the opposite corner of the box where to run the pick

    • y2: number

      defines the Y coordinate of the opposite corner of the box where to run the pick

    • disposeWhenDone: boolean = false

      defines a boolean indicating we do not want to keep resources alive (false by default)

    Returns Promise<Nullable<IGPUMultiPickingInfo>>

    A promise with the picking results. Contains one entry for each picked pixel in the box.

  • Execute a picking operation on multiple coordinates

    Parameters

    • xy: IVector2Like[]

      defines the X,Y coordinates where to run the pick

    • disposeWhenDone: boolean = false

      defines a boolean indicating we do not want to keep resources alive (false by default)

    • Optionaloptions: IGPUMultiPickOptions

      defines options used to tune the multi pick readback strategy

    Returns Promise<Nullable<IGPUMultiPickingInfo>>

    A promise with the picking results. Always returns an array with the same length as the number of coordinates. The mesh or null at the index where no mesh was picked.

  • Execute a picking operation

    Parameters

    • x: number

      defines the X coordinates where to run the pick

    • y: number

      defines the Y coordinates where to run the pick

    • disposeWhenDone: boolean = false

      defines a boolean indicating we do not want to keep resources alive (false by default)

    Returns Promise<Nullable<IGPUPickingInfo>>

    A promise with the picking results

  • Set the list of meshes to pick from Set that value to null to clear the list (and avoid leaks) The module will read and delete from the array provided by reference. Disposing the module or setting the value to null will clear the array.

    Parameters

    • list: Nullable<any[]>

      defines the list of meshes to pick from

    Returns void