Class responsible for detecting intersections between a virtual ray and real-world surfaces.

const worldQuery = require("LensStudio:WorldQueryModule")
// Create a session with default options (currently, filtering disabled by default)
var hitTestSession = worldQuery.createHitTestSession();

// Create a second session with a smoothing filter applied to the hit test result
var options = HitTestSessionOptions.create();
options.filter = true;
var hitTestSessionWithOptions = worldQuery.createHitTestSessionWithOptions(options);

// Depth computation is started once a session is started
// Multiple sessions access the same depth data, thus there is no additional cost
hitTestSession.start()
hitTestSessionWithOptions.start()

hitTestSession.hitTest(rayStart, rayEnd, onHitTestResult1);
hitTestSessionWithOptions.hitTest(rayStart, rayEnd, onHitTestResult2);

// Depth computation stops once all hit test sessions are stopped
hitTestSession.stop()
hitTestSessionWithOptions.stop()
interface HitTestSession {
    getTypeName(): string;
    hitTest(rayStart: vec3, rayEnd: vec3, hitCallback: ((hit: WorldQueryHitTestResult) => void)): void;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
    reset(): void;
    start(): void;
    stop(): void;
}

Hierarchy (view full)

Methods

  • Returns true if the object matches or derives from the passed in type.

    Parameters

    • type: string

    Returns boolean

  • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

    Parameters

    Returns boolean

  • Returns void

  • Returns void

  • Returns void