AnchorLayer
Layer managing screen-space UI widgets pinned to 3D/2D world coordinates inside WorldCanvas.
Overview
AnchorLayer manages a collection of screen-space UI widgets pinned to world coordinates within a WorldCanvas.
Key responsibilities:
- Adding, looking up, and removing anchored widgets (add, anchor, remove, clear).
- Hosting interactive widgets (buttons, labels, panels) that maintain screen-space interactivity while following camera movement.
- Efficient snapshot caching for fast frame-by-frame rendering and event routing.
Adding Anchored Widget to World Canvas
AnchorWidget anchor = canvas.anchorLayer().add("flag", worldX, worldY, new Button("Waypoint"))
.screenSize(80.0f, 24.0f)
.pivot(0.5f, 1.0f);
Related links
- AnchorWidget: Spatial anchor pinning a screen-space UI widget to 3D/2D world coordinates with zoom scaling, pivot, and viewport culling.
- WorldCanvas: Infinite 2D/3D world canvas supporting camera pan and zoom, coordinate transformations, background world layers, and pinned screen-space anchor widgets.
API
AnchorLayer::add(String, float, float, Widget)
Adds a UI widget anchored to the specified world coordinates.
| Parameter | Type | Description |
|---|---|---|
id |
String |
Unique string identifier. |
worldX |
float |
World X coordinate. |
worldY |
float |
World Y coordinate. |
widget |
Widget |
UI widget to anchor in world coordinate space. |
Returns AnchorWidget: The created or found AnchorWidget..
AnchorLayer::anchor(String)
Finds an AnchorWidget by its string identifier, or returns null if not found.
| Parameter | Type | Description |
|---|---|---|
id |
String |
Unique string identifier. |
Returns AnchorWidget: The created or found AnchorWidget..
AnchorLayer::anchors()
Returns an unmodifiable list of all active anchors in this layer.
Returns List: Unmodifiable list of active AnchorWidgets..
AnchorLayer::clear()
Removes and detaches all anchors from this layer.
AnchorLayer::remove(AnchorWidget)
Removes the specified AnchorWidget from this layer.
| Parameter | Type | Description |
|---|---|---|
anchor |
AnchorWidget |
AnchorWidget instance to remove. |
Returns boolean: True if active, enabled, or successful..
AnchorLayer::remove(String)
Removes an anchored widget by its string identifier.
| Parameter | Type | Description |
|---|---|---|
id |
String |
Unique string identifier. |
Returns boolean: True if active, enabled, or successful..
AnchorLayer::size()
Returns the count of active anchors in this layer.
Returns int: The integer count value..