ThreePipe
    Preparing search index...

    Class GPUPickingPlugin

    GPU Picking Plugin

    Finds the front-most mesh under a point of the canvas by rendering object ids instead of testing triangles. The meshes of the model root draw into a 1×1 float target, with the camera's view narrowed to that pixel (one draw of the scene in a tiny viewport). Then one pixel is read back, with the object id, the depth and the surface normal. There is no tree to build or to keep in memory, and the cost does not grow with the triangle count.

    It implements IGPUPicker, the interface that consumers of GPU picking look up.

    Use it for hover and clicks on what is visible: call pick with the pointer position. It finds only the front-most mesh (not the ones behind it), along camera rays only, and the read-back waits for the GPU. For other rays, all the hits, or many queries in a frame, use the Raycaster (with a BVH on big meshes).

    • Skinned, morphed, instanced and batched meshes are drawn in their current pose (one object, no instance id).
    • Each mesh (each geometry group of a multi-material mesh) draws with the side of its material, so a face that a render culls is not hit.
    • A wireframe material is hit only on its lines (and its line width), as it draws.
    • The global clipping planes of the renderer (renderer.clippingPlanes) cut the pick. The clipping planes of a material (material.clippingPlanes) do not: the meshes share one picking material, and three keeps one projected copy of a material's planes per camera.
    • Transparent meshes are hit like opaque ones, and so are the parts that alpha test cuts away.
    • Fat lines (Line2), points, lines, objects outside the model root and meshes on layers that the main camera does not see are not drawn.

    Hierarchy (View Summary)

    Implements

    Index
    _dirty: boolean = false
    _viewer?: ThreeViewer
    _viewerListeners: PartialRecord<IViewerEventTypes, (e: IViewerEvent) => void> = {}
    constructor: typeof AViewerPluginSync & typeof AViewerPlugin
    enabled: boolean = true
    isGPUPicker: true

    Always true: the runtime mark to find a GPU picker among the plugins

    isViewerPluginSync: true = ...
    lastPickMs: number = 0

    The time of the last pick, in ms

    toJSON: any = undefined
    uiConfig?: UiObjectConfig<any, string, any> = undefined
    Layer: number = 29

    A layer that no other render uses, for the meshes being picked

    OldPluginType?: string
    PluginType: "GPUPickingPlugin" = 'GPUPickingPlugin'
    • The front-most mesh under a point of the canvas, with the hit point and the world normal, or null.

      Parameters

      • x: number

        CSS pixels from the left edge of the canvas

      • y: number

        CSS pixels from the top edge of the canvas

      • Optionalfilter: (o: IObject3D) => boolean

        which meshes take part. Default: the visible meshes in the model root, without fat lines.

      Returns GPUPickResult | null