Lens Scripting API
    Preparing search index...

    Class WorldQueryHitTestResultWearable Only

    The result of the hitTest method call. This includes the world position of the hit, the world normal of the hit. Returns null if no intersection with environment was detected.

    // Set object's position and rotation if WorldQuery ray hits something.

    onHitTestResult(result) {
    if (result === null) {
    // no hit detected
    } else {
    // get hit information
    const hitPosition = results.position;
    const hitNormal = results.normal;
    //identifying the direction the object should look at based on the normal of the hit location.

    var lookDirection;
    if (1 - Math.abs(hitNormal.normalize().dot(vec3.up())) < 0.01) {
    lookDirection = vec3.forward();
    } else {
    lookDirection = hitNormal.cross(vec3.up());
    }
    const toRotation = quat.lookAt(lookDirection, hitNormal);

    //set position and rotation

    this.targetObject.getTransform().setWorldPosition(hitPosition);
    this.targetObject.getTransform().setWorldRotation(toRotation);
    }
    }

    Hierarchy (View Summary)

    Index

    Properties

    classification: SurfaceClassification

    The classification of the surface at the position where the ray intersects with the environment.

    normal: vec3

    A normal of the surface at the position where the ray intersects with the environment.

    position: vec3

    A position where ray intersects with the environment.

    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