Appearance
Anchor
Anchor types for object placement
Static Methods
position()
javascript
Anchor.position(xOrVector: Vector3 | number, y?: number, z?: number): ObjectAnchor at fixed world position
Parameters:
xOrVector(Vector3 | number) - Position vector or X coordinatey(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): voidAnchor 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): voidAnchor relative to camera
Parameters:
xOrVector(Vector3 | number) - Offset vector or X coordinatey(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): ObjectAnchor at user's current point of view (captures current camera position)
Parameters:
xOrVector(Vector3 | number) (optional) - Offset vector or X coordinatey(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): ObjectAnchor 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): ObjectAnchor on detected horizontal plane (floor, table, etc.)
Parameters:
classification(string) (optional) - Surface type: "floor", "table", "seat", "ceiling"minWidth(number) (optional) - Minimum plane width in metersminHeight(number) (optional) - Minimum plane depth in meters
Returns: Object
verticalPlane()
javascript
Anchor.verticalPlane(classification?: string, minWidth?: number, minHeight?: number): voidAnchor 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): ObjectAnchor to user's hand (visionOS hand tracking)
Parameters:
chirality(string) - "left" or "right" handjoint(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
accessory()
javascript
Anchor.accessory(options?: Object): ObjectAnchor to a spatial accessory: a stylus or a tracked spatial controller (Apple Vision Pro). The object hides while the accessory isn't tracked and moves to another match when it disconnects. Where environment.features.has('accessoryTracking') is false it stays hidden.
Example:
javascript
var brush = await scene.createEntity(
createSphere(0.004).anchor(Anchor.accessory({ kind: 'stylus' }))
);Parameters:
options(Object) (optional)options.kind(string) (optional) -"stylus"or"spatialController"; left out, any accessory matches.options.hand(string) (optional) -"left"or"right": a controller's own side, the hand holding a stylus. Left out, either hand matches.options.location(string) (optional) -"aim"(stylus tip, controller aim) or"grip"(where the hand holds a controller). A stylus has only an aim; asking for its grip uses the aim.options.offset(Transform | Object) (optional) - Offset from the location, in its space; -z points along the aim.options.smoothing(number) (optional) - Fraction of the way to the new pose per frame, 0 to 1; lower is smoother. Left out, the object follows without delay.options.trackingMode(string) (optional) -"predicted"(lowest latency, can overshoot on jerky moves) or"continuous"(more accurate, more latency).
Returns: Object
image()
javascript
Anchor.image(imageUrl: string, physicalWidth: number, identifier?: string, orientation?: string, tracksContinuously?: boolean, hideIfTrackingLost?: boolean, providesDiscoveryHint?: boolean): ObjectAnchor to image marker (image tracking)
Parameters:
imageUrl(string) - URL to reference image for trackingphysicalWidth(number) - Real-world width of the image in metersidentifier(string) (optional) - Optional unique identifierorientation(string) (optional) - Expected orientation: "horizontal" or "vertical"tracksContinuously(boolean) (optional) - Continue tracking after initial detectionhideIfTrackingLost(boolean) (optional) - Hide object when image not visibleprovidesDiscoveryHint(boolean) (optional) - Show visual hint to find image
Returns: Object