Lens Scripting API
    Preparing search index...

    Enumeration SurfaceClassificationExperimental Wearable Only

    The classification of the surface at the position where the ray intersects with the environment. This is used in WorldQueryHitTestResult to provide additional information about the surface type.

    const WorldQueryModule =
    require("LensStudio:WorldQueryModule") as WorldQueryModule;

    @component
    export class HitTestClassification extends BaseScriptComponent {

    private hitTestSession: HitTestSession;

    onAwake() {
    this.hitTestSession = this.createHitTestSession();

    this.createEvent("UpdateEvent").bind(this.onUpdate);
    }

    createHitTestSession() {
    const options = HitTestSessionOptions.create();
    options.classification = true;

    const session =
    WorldQueryModule.createHitTestSessionWithOptions(options);
    return session;
    }

    onHitTestResult = (result: WorldQueryHitTestResult) => {
    if (result === null) {
    // Hit test failed
    return;
    }

    const hitPosition = result.position;
    const hitNormal = result.normal;
    const hitClassification = result.classification;

    switch (hitClassification) {
    case SurfaceClassification.Ground:
    print("Hit ground!");
    break;
    case SurfaceClassification.None:
    print("Hit unknown surface!");
    break;
    }
    };

    onUpdate = () => {
    // Ray start and end depend on the specific application
    const rayStart = new vec3(0, 0, 0);
    const rayEnd = new vec3(0, 0, 1);

    this.hitTestSession.hitTest(rayStart, rayEnd, this.onHitTestResult);
    };
    Index

    Enumeration Members

    Enumeration Members

    Ground: number

    The detected surface is ground.

    None: number

    The detected surface could not be identified.