Preparing search index...

    Enumeration SurfaceClassificationWearable 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.

    Lens Scripting Version 377

    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

    Ceiling: number

    The detected surface is ceiling.

    Lens Scripting Version 377

    Ground: number

    The detected surface is ground.

    Lens Scripting Version 377

    None: number

    The detected surface could not be identified.

    Lens Scripting Version 377

    Table: number

    The detected surface is table.

    Lens Scripting Version 377

    Wall: number

    The detected surface is wall.

    Lens Scripting Version 377