Lens Scripting API

    Class DeviceTracking

    Enables a SceneObject to align with the movements and orientation of the user's device. Provides tracking modes such as Surface, Rotation, and World.

    Usually added to SceneObject with Camera component.

    If using Surface tracking mode, adding this to a SceneObject enables surface tracking for the scene, and moves the object to a position and rotation that matches the physical camera's pose in the world. Surface tracking can also be enhanced with native AR by enabling the Use Native AR option in the Inspector panel, or through script by setting the component's SurfaceOptions.enhanceWithNativeAR property.

    If using Rotation tracking mode, adding this to a SceneObject will apply the device's real world rotation to the object.

    If using World tracking mode, adding this to a SceneObject enables native AR tracking for the scene, and moves the object to a position and rotation that matches the physical camera's pose in the world.

    Tracking Modes guide for more information.

    Set the surface tracking target.

    //@input Component.DeviceTracking deviceTrackingComponent
    function setTrackingTarget()
    {
    if(script.deviceTrackingComponent)
    {
    script.deviceTrackingComponent.surfaceTrackingTarget = script.getSceneObject();
    }
    }
    setTrackingTarget();

    Hierarchy (View Summary, Expand)

    Index

    Constructors

    Properties

    enabled: boolean

    If disabled, the Component will stop enacting its behavior.

    rotationOptions: RotationOptions

    Used to access rotation tracking settings.

    sceneObject: SceneObject

    The scene object this component is on.

    surfaceOptions: SurfaceOptions

    Used to access surface tracking settings.

    surfaceTrackingTarget: SceneObject

    Helps to improve surface tracking accuracy while the target SceneObject is being moved.

    uniqueIdentifier: string
    worldOptions: WorldOptions

    Returns the WorldOptions object of this component, which can be used to control World Tracking settings.

    worldTrackingCapabilities: WorldTrackingCapabilities

    Returns the World Tracking Capabilities of the current device.

    Methods

    • Calculates a histogram of world mesh surfaces within a sphere at the given world position and radius. Only available when world mesh tracking is supported and enabled.

      Parameters

      • center: vec3
      • radius: number

      Returns TrackedMeshHistogramResult

    • Creates a TrackedPoint at world position worldPos and world rotation worldRot.

      Parameters

      Returns TrackedPoint

    • Destroys the component.

      Returns void

    • Returns the actual DeviceTrackingMode being used. This may be different from the requested DeviceTrackingMode.

      Returns DeviceTrackingMode

    • This capability is no longer available.

      Returns number

    • Exposes User Data

      Returns the 3D point cloud representing important features visible by the camera.

      Returns PointCloud

    • Returns the DeviceTrackingMode currently requested to be used. This may be different from the actual DeviceTrackingMode being used.

      Returns DeviceTrackingMode

    • Returns the name of this object's type.

      Returns string

    • Returns an array of TrackedMeshHitTestResult that intersect with a ray cast from screen position screenPos. Only available when world mesh tracking is supported and enabled.

      Parameters

      Returns TrackedMeshHitTestResult[]

    • 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 an array of TrackedMeshHitTestResult that intersect with a ray cast from the world position from and continuing through the world position to. Only available when world mesh tracking is supported and enabled.

      Parameters

      Returns TrackedMeshHitTestResult[]

    • Requests that a DeviceTrackingMode be used. This requested change may not happen immediately.

      Parameters

      Returns void

    • Resets the World Tracking origin to the point on the surface plane aligned with the screen position position. Screen positions are represented in the range ([0-1], [0-1]), (0,0) being the top-left of the screen and (1,1) being the bottom-right.

      Parameters

      Returns void

    • Offsets the default position of the World Tracking surface origin by offset. Avoid using a y value of zero in offset, because it may cause problems with tracking. If used outside of Initialized or TurnOnEvent, you will need to call resetTracking() to apply the offset. Note: calling resetTracking() will overwrite the x and z components of the offset.

      Parameters

      Returns void

    MMNEPVFCICPMFPCPTTAAATR