Skip to content

WasmGPU.createAnnotation.toolkit().hoverProbe

Summary

WasmGPU.createAnnotation.toolkit().hoverProbe returns the latest hover readout snapshot. The readout mirrors the most recent hover pick result or a no-hit state.

Syntax

WasmGPU.createAnnotation.toolkit().hoverProbe: AnnotationProbeReadout
const probe = toolkit.hoverProbe;

Parameters

This accessor does not take parameters.

Returns

AnnotationProbeReadout - Latest hover probe payload.

Type Details

type AnnotationProbeReadout = {
    hit: boolean;
    kind: "mesh" | "pointcloud" | "glyphfield" | null;
    objectId: number | null;
    elementIndex: number | null;
    worldPosition: [number, number, number] | null;
    ndIndex: number[] | null;
    attributes: PickAttributes | null;
};

Example

const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const scene = wgpu.createScene();
const camera = wgpu.createCamera.perspective({ fov: 55, aspect: canvas.clientWidth / canvas.clientHeight, near: 0.1, far: 1000 });
const toolkit = wgpu.createAnnotation.toolkit({ scene, camera, canvas });

await toolkit.pickHoverAt(120, 80);
console.log(toolkit.hoverProbe);

See Also