Create powerful AR image tracking experiences with just a few lines of code! WebXRImageTracking makes it incredibly easy to detect marker images in the real world and anchor 3D content to them. Needle Engine automatically handles all the complexity across different platforms and fallback modes for you.

Image Tracking Demo

What makes Needle Engine special:

  • Write once, run everywhere: The same code works across iOS, Android, and visionOS
  • Automatic platform optimization: Seamlessly switches between WebXR, ARKit, and QuickLook
  • Flexible deployment options: From full WebXR with unlimited markers to QuickLook fallback
  • Production ready: Battle-tested tracking with adaptive smoothing and stability features

Platform Support & Options:

  • iOS (WebXR via AppClip): Full WebXR support - track unlimited markers simultaneously via native ARKit!
  • iOS (QuickLook mode): Instant AR without app installation - perfect for quick demos (tracks first marker)
  • Android (WebXR): Native WebXR Image Tracking API - unlimited markers (requires browser flag during early access)
  • visionOS (QuickLook): Spatial image anchoring with Apple's AR QuickLook

Simple 3-Step Setup:

  1. Add this component to any GameObject in your scene
  2. Configure your markers in the trackedImages array:
    • image: URL to your marker image
    • widthInMeters: Physical size of your printed marker
    • object: The 3D content to display
  3. Export and test - Needle handles the rest!

Pro Tips for Best Results:

  • Use high-contrast markers with unique features for reliable tracking
  • Match widthInMeters to your actual physical marker size for accurate positioning
  • Enable imageDoesNotMove for wall posters or floor markers - significantly improves stability
  • Use smooth (enabled by default) for professional-looking, jitter-free tracking
  • Test with different marker sizes and lighting - Needle's adaptive tracking handles various conditions


WebXRImageTracking component in Unity Editor


WebXRImageTracking panel/component in Blender

// Just add markers and Needle handles everything else
const imageTracking = myObject.addComponent(WebXRImageTracking);
const marker = new WebXRImageTrackingModel({
url: "https://example.com/my-poster.png",
widthInMeters: 0.3, // 30cm poster
object: my3DContent
});
imageTracking.addImage(marker);
// Done! Works on iOS, Android, and visionOS automatically
const imageTracking = myObject.addComponent(WebXRImageTracking);

// In WebXR mode (iOS AppClip, Android), all markers work simultaneously!
const productBox = new WebXRImageTrackingModel({ url: "product-box.png", widthInMeters: 0.15, object: productInfo });
const businessCard = new WebXRImageTrackingModel({ url: "business-card.png", widthInMeters: 0.09, object: contactCard });
const poster = new WebXRImageTrackingModel({ url: "poster.png", widthInMeters: 0.5, object: videoPlayer });

imageTracking.addImage(productBox);
imageTracking.addImage(businessCard);
imageTracking.addImage(poster);

// For QuickLook fallback mode, optionally set which marker is primary
imageTracking.setPrimaryImage(poster); // This will be used in QuickLook
// Perfect for museums, retail displays, or permanent installations
const wallArt = new WebXRImageTrackingModel({
url: "gallery-painting.png",
widthInMeters: 0.6,
object: interactiveExplanation,
imageDoesNotMove: true, // Rock-solid tracking for static markers!
hideWhenTrackingIsLost: false // Content stays visible even if temporarily occluded
});

Why developers love Needle's image tracking:

  • Zero platform-specific code required
  • Automatic graceful degradation across deployment modes
  • Built-in jitter reduction and stability features
  • Works with any image - posters, packaging, business cards, artwork
  • Export once, deploy everywhere

Hierarchy (View Summary)

Properties

gameObject: GameObject

Reference to the GameObject this component is attached to This is a three.js Object3D with additional GameObject functionality

guid: string = "invalid"

Unique identifier for this component instance, used for finding and tracking components

smooth: boolean = true

Enable Needle's professional-grade adaptive smoothing for rock-solid tracking. Automatically reduces jitter while staying responsive to real movement.

Pro tip: Keep this enabled (default) for production experiences!

true
sourceId?: string

Identifier for the source asset that created this component. For example, URL to the glTF file this component was loaded from

trackedImages: WebXRImageTrackingModel[] = []

Your list of markers to track. Add as many as you need!

How it works across platforms:

  • WebXR mode (iOS AppClip, Android): All markers are tracked simultaneously - amazing for multi-marker experiences!
  • QuickLook mode (iOS fallback, visionOS): First marker is used - perfect for quick demos without app installation

Needle's smart deployment: Configure all your markers once, and Needle automatically uses the best tracking mode available on each platform. No platform-specific code needed!

Accessors

  • get "[$componentName]"(): undefined | string

    Get the original component type name before minification (available if the component is registered in the TypeStore)

    Returns undefined | string

  • get activeAndEnabled(): boolean

    Checks if this component is currently active (enabled and part of an active GameObject hierarchy) Components that are inactive won't receive lifecycle method calls

    Returns boolean

    True if the component is enabled and all parent GameObjects are active

  • get context(): Context

    The context this component belongs to, providing access to the runtime environment including physics, timing utilities, camera, and scene

    Returns Context

  • set context(context: Context): void

    Parameters

    Returns void

  • get destroyed(): boolean

    Checks if this component has been destroyed

    Returns boolean

    True if the component or its GameObject has been destroyed

  • get enabled(): boolean

    Controls whether this component is enabled Disabled components don't receive lifecycle callbacks

    Returns boolean

  • set enabled(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get forward(): Vector3

    Gets the forward direction vector (0,0,-1) of this component's GameObject in world space

    Returns Vector3

  • get layer(): number

    The layer value of the GameObject this component is attached to Used for visibility and physics filtering

    Returns number

  • get name(): string

    The name of the GameObject this component is attached to Used for debugging and finding objects

    Returns string

  • set name(str: string): void

    Parameters

    • str: string

    Returns void

  • get right(): Vector3

    Gets the right direction vector (1,0,0) of this component's GameObject in world space

    Returns Vector3

  • get scene(): Scene

    Shorthand accessor for the current scene from the context

    Returns Scene

    The scene this component belongs to

  • get static(): boolean

    Indicates whether the GameObject is marked as static Static objects typically don't move and can be optimized by the engine

    Returns boolean

  • set static(value: boolean): void

    Parameters

    • value: boolean

    Returns void

  • get supported(): boolean

    Check if image tracking is available on this device right now.

    Note: On Android Chrome, WebXR Image Tracking is currently behind a flag during the early access period. Needle automatically falls back to other modes when needed, so your experience keeps working!

    Returns boolean

  • get tag(): string

    The tag of the GameObject this component is attached to Used for categorizing objects and efficient lookup

    Returns string

  • set tag(str: string): void

    Parameters

    • str: string

    Returns void

  • get up(): Vector3

    Gets the up direction vector (0,1,0) of this component's GameObject in world space

    Returns Vector3

  • get worldEuler(): Euler

    Gets the rotation of this component's GameObject in world space as Euler angles (in radians)

    Returns Euler

  • set worldEuler(val: Euler): void

    Sets the rotation of this component's GameObject in world space using Euler angles (in radians)

    Parameters

    • val: Euler

      The world rotation Euler angles to set

    Returns void

  • get worldPosition(): Vector3

    Gets the position of this component's GameObject in world space.
    Note: This is equivalent to calling this.gameObject.worldPosition

    Returns Vector3

  • set worldPosition(val: Vector3): void

    Sets the position of this component's GameObject in world space

    Parameters

    • val: Vector3

      The world position vector to set

    Returns void

  • get worldQuaternion(): Quaternion

    Gets the rotation of this component's GameObject in world space as a quaternion Note: This is equivalent to calling this.gameObject.worldQuaternion

    Returns Quaternion

  • set worldQuaternion(val: Quaternion): void

    Sets the rotation of this component's GameObject in world space using a quaternion

    Parameters

    • val: Quaternion

      The world rotation quaternion to set

    Returns void

  • get worldRotation(): Vector3

    Gets the rotation of this component's GameObject in world space as Euler angles (in degrees)
    Note: This is equivalent to calling this.gameObject.worldRotation

    Returns Vector3

  • set worldRotation(val: Vector3): void

    Sets the rotation of this component's GameObject in world space using Euler angles (in degrees)

    Parameters

    • val: Vector3

      The world rotation vector to set (in degrees)

    Returns void

Methods

  • Registers an event listener for the specified event type

    Type Parameters

    Parameters

    • type: string

      The event type to listen for

    • listener: (evt: T) => any

      The callback function to execute when the event occurs

    Returns void

  • Add a marker to track - it's that simple! Needle Engine handles all the platform differences automatically.

    Tip: Add all your markers upfront. In WebXR mode they all work simultaneously. In QuickLook mode, the first (primary) marker is used.

    Parameters

    • image: WebXRImageTrackingModel

      The marker configuration to add

    • asPrimary: boolean = false

      Set to true to make this the primary marker (for QuickLook fallback)

    Returns void

    // Super simple - works across all platforms
    const marker = new WebXRImageTrackingModel({
    url: "https://mysite.com/poster.png",
    widthInMeters: 0.42, // A3 poster width
    object: cool3DModel
    });
    imageTracking.addImage(marker);
    // That's it! Needle does the rest.
  • Destroys this component and removes it from its GameObject After destruction, the component will no longer receive lifecycle callbacks

    Returns void

  • Dispatches an event to all registered listeners

    Parameters

    • evt: Event

      The event object to dispatch

    Returns boolean

    Always returns false (standard implementation of EventTarget)

  • Called at the beginning of each frame before regular updates. Use for logic that needs to run before standard update callbacks.

    Returns void

  • Called after all update functions have been called. Use for calculations that depend on other components being updated first.

    Returns void

  • Called after the scene has been rendered. Use for post-processing or UI updates that should happen after rendering

    Returns void

  • Called immediately before the scene is rendered.

    Parameters

    • frame: null | XRFrame

      Current XRFrame if in an XR session, null otherwise

    Returns void

  • Called when this component's collider begins colliding with another collider.

    Parameters

    • col: Collision

      Information about the collision that occurred

    Returns any

  • Called when this component's collider stops colliding with another collider.

    Parameters

    • col: Collision

      Information about the collision that ended

    Returns any

  • Called each frame while this component's collider is colliding with another collider

    Parameters

    • col: Collision

      Information about the ongoing collision

    Returns any

  • Called when the component is destroyed. Use for cleanup operations like removing event listeners

    Returns void

  • Called when the context's pause state changes.

    Parameters

    • isPaused: boolean

      Whether the context is currently paused

    • wasPaused: boolean

      The previous pause state

    Returns void

  • Called when this component's trigger collider is entered by another collider

    Parameters

    • col: ICollider

      The collider that entered this trigger

    Returns any

  • Called when another collider exits this component's trigger collider

    Parameters

    • col: ICollider

      The collider that exited this trigger

    Returns any

  • Called each frame while another collider is inside this component's trigger collider

    Parameters

    • col: ICollider

      The collider that is inside this trigger

    Returns any

  • Called when a field decorated with @validate() is modified.

    Parameters

    • Optionalprop: string

      The name of the field that was changed

    Returns void

  • Removes a previously registered event listener

    Type Parameters

    Parameters

    • type: string

      The event type the listener was registered for

    • listener: (arg: T) => any

      The callback function to remove

    Returns void

  • Called when this component needs to remap guids after an instantiate operation.

    Parameters

    • guidsMap: GuidsMap

      Mapping from old guids to newly generated guids

    Returns void

  • Set which marker should be primary (first in the list). Useful when deploying to QuickLook mode where one marker is tracked at a time. In full WebXR mode (iOS AppClip, Android), all markers track simultaneously regardless of order.

    Note: Needle Engine automatically adapts - in WebXR all markers work, in QuickLook the primary is used.

    Parameters

    Returns void

    // Great for offering different AR experiences from one deployment
    imageTracking.setPrimaryImage(businessCardMarker); // Use this for QuickLook
    // In WebXR mode, all markers still work simultaneously!
  • Sets the position of this component's GameObject in world space using individual coordinates

    Parameters

    • x: number

      X-coordinate in world space

    • y: number

      Y-coordinate in world space

    • z: number

      Z-coordinate in world space

    Returns void

  • Sets the rotation of this component's GameObject in world space using quaternion components

    Parameters

    • x: number

      X component of the quaternion

    • y: number

      Y component of the quaternion

    • z: number

      Z component of the quaternion

    • w: number

      W component of the quaternion

    Returns void

  • Sets the rotation of this component's GameObject in world space using individual Euler angles

    Parameters

    • x: number

      X-axis rotation

    • y: number

      Y-axis rotation

    • z: number

      Z-axis rotation

    • degrees: boolean = true

      Whether the values are in degrees (true) or radians (false)

    Returns void

  • Called once at the beginning of the first frame after the component is enabled. Use for initialization that requires other components to be awake.

    Returns void

  • Starts a coroutine that can yield to wait for events. Coroutines allow for time-based sequencing of operations without blocking. Coroutines are based on generator functions, a JavaScript language feature.

    Parameters

    • routine: Generator

      Generator function to start

    • evt: FrameEvent = FrameEvent.Update

      Event to register the coroutine for (default: FrameEvent.Update)

    Returns Generator

    The generator function that can be used to stop the coroutine

    Time-based sequencing of operations

    *myCoroutine() {
    yield WaitForSeconds(1); // wait for 1 second
    yield WaitForFrames(10); // wait for 10 frames
    yield new Promise(resolve => setTimeout(resolve, 1000)); // wait for a promise to resolve
    }

    Coroutine that logs a message every 5 frames

    onEnable() {
    this.startCoroutine(this.myCoroutine());
    }
    private *myCoroutine() {
    while(this.activeAndEnabled) {
    console.log("Hello World", this.context.time.frame);
    // wait for 5 frames
    for(let i = 0; i < 5; i++) yield;
    }
    }
  • Stops a coroutine that was previously started with startCoroutine

    Parameters

    • routine: Generator

      The routine to be stopped

    • evt: FrameEvent = FrameEvent.Update

      The frame event the routine was registered with

    Returns void

  • Determines if this component supports a specific XR mode

    Parameters

    • mode: XRSessionMode

      The XR session mode to check support for

    Returns boolean

    True if the component supports the specified mode

  • Called once per frame during the main update loop. The primary location for frame-based game logic.

    Returns void