AGENT SKILL

XR Blocks 空间 UI 构建

xb-add-spatial-ui

在 XR Blocks 中构建空间 UI。适用于使用内置 UI 系统添加卡片、覆盖层、面板、文本、控件、模型查看器界面,以及布局、样式、主题或 UI 放置。

License 许可
Apache-2.0
所属仓库
google/xrblocks
最近更新
2026-11-14
Stars
★ 517
Forks
105

01 前言 Front Matter

name
xb-add-spatial-ui
description
Build spatial UI in XR Blocks. Use when adding cards, overlays, panels, text, controls, model-viewer interfaces, layout, styling, themes, or UI placement with the built-in UI system.

02 资源文件 1

03 SKILL.md 正文

Add spatial UI

Build a usable surface: information and controls that remain legible, targetable, and observable in their intended pose.

1. Write the surface contract

Record every displayed value and action, its state owner, spatial anchor, appearance states, update cadence, desktop input, XR input, and observable result.

Complete this step when every value and control has a user purpose, source, anchor, and testable result.

2. Select the correct UI root

Read ../../docs/docs/manual/UI.mdx before implementation.

  • Use UICard for a world-space surface measured and positioned in meters.
  • Use UIOverlay for a bounded view-space surface.
  • Use UIPanel only inside a card or overlay for layout or visual grouping.

Import components from xrblocks. Built-in UI starts automatically and joins the normal XR Blocks interaction pipeline. Application code does not enable a UI subsystem, register UIKit, or install a second raycaster.

Complete this step when one root owns the intended coordinate space and every nested element has one layout parent.

3. Compose semantic UI

Build reading order with UIPanel, UIText, UIImage, and UIIcon. Use UIButton, UIToggle, UIDropdown, and UISlider for actions and choices instead of raw pointer handlers. Use ModelViewer for supported interactive model presentation. Use semantic UI for status, telemetry, instructions, and debug state instead of canvas sprites.

Treat UICard.size and world transforms as meters. Treat descendant numeric layout values as UIKit layout units. Treat numeric lineHeight as a font-size multiplier; use px or % strings for explicit units.

Omit size to fit both dimensions to content. Each omitted dimension defaults to 'auto', so size: {width: 0.6} fixes width while height follows content, and size: {height: 0.3} fixes height while width follows content. Use a fixed width or style.maxWidth when text needs a predictable wrapping limit. Percentage-width children need a definite parent width. Dragging a resize corner fixes automatic dimensions from their laid-out size; pressing and releasing without changing size preserves automatic sizing.

Complete this step when all content fits at the intended physical size and each state-changing control has hover or active feedback plus an observable result.

4. Connect state, theme, and spatial behavior

Update component properties directly. Keep mounted text and controls stable; change structure only when the application structure changes. Use a theme preset or theme update for shared palette and structural roles, then use local styles for exceptions.

Use pointerEvents, interactionEnabled, visibility, material depth behavior, and opacity for their separate purposes. Transparency alone does not disable depth writes or input.

Read ../../docs/docs/manual/Placement.md when the root follows, faces, or orbits another object. Read ../../docs/docs/manual/Interaction.md for manipulation and target semantics.

Complete this step when state changes update the intended mounted element, theme changes produce the intended structure and palette, and placement does not compete with user manipulation.

5. Validate and hand off

Build or type-check the app. After a completed UI frame, run xb.ui.validate() for the root or all roots. Check overflow, clipping, disabled behavior, input, cleanup, and relevant console output. Start from ../../templates/01_spatial_ui/ or the closest focused sample for executable evidence.

Give the user the exact URL, viewing pose, input route, control instructions, and expected idle, hover, active, disabled, and result states. Name real-device checks for legibility, target size, occlusion, reach, and head motion.

Finish when validation and available smoke checks pass and the user can test every control and state without inferring expected behavior from source.

04 同仓库更多 Skills

google
google/xrblocks

XR Blocks 应用调试修复

xb-debug-app

调试并修复 XR Blocks 应用。当应用构建或运行失败、UI/交互/感知/渲染行为异常、模拟器与真机表现不一致、存在资源泄漏或包含过时的 SDK 模式时使用。

软件开发工程师XR 与空间计算开发
★ 517
google
google/xrblocks

XR Blocks SDK贡献开发

xb-contribute-sdk

完成 XR Blocks SDK 的变更,涵盖实现、运行时接线、公共导出、验证、构建输出、示例和权威文档。适用于编辑 XR Blocks 仓库本身,而非使用它的应用程序。

软件开发工程师XR 与空间计算开发
★ 517
google
google/xrblocks

XR Blocks应用搭建

xb-build-app

构建或扩展完整的 XR Blocks 应用。当请求涉及应用脚手架、完整体验、多个 SDK 领域,或端到端模拟器及 XR 交接,而非单个聚焦子系统时使用。

软件开发工程师XR 与空间计算开发
★ 517
google
google/xrblocks

WebXR空间锚点固定与恢复

xb-anchors

使用 WebXR 空间锚点将内容固定在真实位置,并在后续会话中将其恢复。当虚拟内容必须在头显不断完善房间地图时保持原位,或应用需要记住物品的放置位置时使用。涵盖 `enableAnchors()`、`enableAnchorPersistence()`、创建与恢复锚点、`capability` 状态,以及无需头显即可开发锚点代码的桌面回退方案。可与 xb-world 配合使用,以检测可锚定到的对象。

软件开发工程师XR 与空间计算开发
★ 517
google
google/xrblocks

XR Blocks 物理世界感知接入

xb-add-world-sensing

将物理世界感知连接到 XR Blocks 应用状态。适用于添加平面、场景网格、深度、遮挡、世界碰撞证据、物体或人体识别、面部追踪、分割,或面向智能体(agent)的场景上下文。

软件开发工程师XR 与空间计算开发
★ 517
google
google/xrblocks

XR Blocks 交互设计与实现

xb-add-interactions

设计并实现 XR Blocks 交互。适用于添加选择、悬停、直接触摸、抓取、手势、事件所有权、事件传播、自动操作或物理驱动的对象行为。

软件开发工程师XR 与空间计算开发
★ 517