ThreePipe
    Preparing search index...

    Interface IGPUPicker

    A GPU picker: finds the front-most mesh under a point of the canvas, with the hit point and normal, by reading what the GPU drew under that point instead of testing triangles.

    Each implementation is a separate plugin with this one interface:

    • GPUPickingPlugin draws the ids, depth and normals into a 1×1 target on each pick.
    • A future GBufferPickingPlugin (deferred, depends on GBufferPlugin) reads the ids, depth and normals of the frame that the G-buffer already has, with no extra draw.

    A consumer (for example a future GPU hover in PickingPlugin) does not depend on one of them. It looks up any added plugin that is a GPU picker:

    const picker = Object.values(viewer.plugins).find((p): p is IGPUPicker & IViewerPlugin => !!(p as Partial<IGPUPicker>).isGPUPicker)
    const hit = picker?.pick(x, y)
    interface IGPUPicker {
        isGPUPicker: true;
        pick(
            x: number,
            y: number,
            filter?: (o: IObject3D) => boolean,
        ): GPUPickResult | null;
    }

    Implemented by

    Index
    isGPUPicker: true

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

    • The front-most mesh under a point of the canvas, with the hit point and 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

      Returns GPUPickResult | null