Skip to content

Anchor

Anchor types for object placement

Static Methods

position()

javascript
Anchor.position(xOrVector: Vector3 | number, y?: number, z?: number): Object

Anchor at fixed world position

Parameters:

  • xOrVector (Vector3 | number) - Position vector or X coordinate
  • y (number) (optional) - Y coordinate (if first param is number)
  • z (number) (optional) - Z coordinate (if first param is number)

Returns: Object

geoLocation()

javascript
Anchor.geoLocation(latitude: number, longitude: number, altitude?: number): void

Anchor at geographic location

Parameters:

  • latitude (number)
  • longitude (number)
  • altitude (number) (optional)

Returns: void

camera()

javascript
Anchor.camera(xOrVector: Vector3 | number, y?: number, z?: number, lerpFactor?: number): void

Anchor relative to camera

Parameters:

  • xOrVector (Vector3 | number) - Offset vector or X coordinate
  • y (number) (optional) - Y coordinate (if first param is number)
  • z (number) (optional) - Z coordinate (if first param is number)
  • lerpFactor (number) (optional) - Smoothing factor

Returns: void

currentPOV()

javascript
Anchor.currentPOV(xOrVector?: Vector3 | number, y?: number, z?: number, resetRotation?: boolean): Object

Anchor at user's current point of view (captures current camera position)

Parameters:

  • xOrVector (Vector3 | number) (optional) - Offset vector or X coordinate
  • y (number) (optional) - Y coordinate (if first param is number)
  • z (number) (optional) - Z coordinate (if first param is number)
  • resetRotation (boolean) (optional) - If true, object faces forward instead of matching camera

Returns: Object

screenSpace()

javascript
Anchor.screenSpace(options?: Object): Object

Anchor a UI panel in screen space – a flat 2D overlay pinned to a screen edge or corner, rather than a plane placed in the world. Use for HUDs and controls that should stay put wherever the viewer looks.

Example:

javascript
// A slider pinned to the bottom of the screen, 24 pt clear of the edge.
createPanel(
    UI.slider({ name: 'amount', sizing: { width: 'fill' } }),
    { panelSize: 'auto' }
).anchor(Anchor.screenSpace({ alignment: 'bottom', insets: 24 }));

Parameters:

  • options (Object) (optional)
  • options.alignment (string) (optional) - Where the panel sits: "center", "top", "bottom", "leading", "trailing", or a corner ("topLeading", "topTrailing", "bottomLeading", "bottomTrailing").
  • options.insets (number | Object) (optional) - Gap from the screen edges, in points. A number applies to all sides; { top, leading, bottom, trailing } sets each.
  • options.respectsSafeArea (boolean) (optional) - Stay clear of notches, home indicators, and system bars.

Returns: Object

horizontalPlane()

javascript
Anchor.horizontalPlane(classification?: string, minWidth?: number, minHeight?: number): Object

Anchor on detected horizontal plane (floor, table, etc.)

Parameters:

  • classification (string) (optional) - Surface type: "floor", "table", "seat", "ceiling"
  • minWidth (number) (optional) - Minimum plane width in meters
  • minHeight (number) (optional) - Minimum plane depth in meters

Returns: Object

verticalPlane()

javascript
Anchor.verticalPlane(classification?: string, minWidth?: number, minHeight?: number): void

Anchor on vertical plane

Parameters:

  • classification (string) (optional) - "wall", "window", "door"
  • minWidth (number) (optional)
  • minHeight (number) (optional)

Returns: void

hand()

javascript
Anchor.hand(chirality: string, joint?: string, trackingScope?: string, lerpFactor?: number, providesDiscoveryHint?: boolean): Object

Anchor to user's hand (visionOS hand tracking)

Parameters:

  • chirality (string) - "left" or "right" hand
  • joint (string) (optional) - Hand joint: "wrist", "thumbTip", "indexFingerTip", "middleFingerTip", etc.
  • trackingScope (string) (optional) - "full", "position", or "orientation"
  • lerpFactor (number) (optional) - Smoothing factor (0-1, lower = smoother)
  • providesDiscoveryHint (boolean) (optional) - Show visual hint for hand tracking

Returns: Object

image()

javascript
Anchor.image(imageUrl: string, physicalWidth: number, identifier?: string, orientation?: string, tracksContinuously?: boolean, hideIfTrackingLost?: boolean, providesDiscoveryHint?: boolean): Object

Anchor to image marker (image tracking)

Parameters:

  • imageUrl (string) - URL to reference image for tracking
  • physicalWidth (number) - Real-world width of the image in meters
  • identifier (string) (optional) - Optional unique identifier
  • orientation (string) (optional) - Expected orientation: "horizontal" or "vertical"
  • tracksContinuously (boolean) (optional) - Continue tracking after initial detection
  • hideIfTrackingLost (boolean) (optional) - Hide object when image not visible
  • providesDiscoveryHint (boolean) (optional) - Show visual hint to find image

Returns: Object