Develop and iterate on IWSDK UI panels efficiently. Use when working on PanelUI components, debugging UI layout, or improving UI design in IWSDK applications.
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "iwsdk-ui-panel" 技能: 1. 下载 https://raw.githubusercontent.com/facebook/immersive-web-sdk/main/.claude/skills/iwsdk-ui-panel/SKILL.md 2. 保存为 ~/.claude/skills/iwsdk-ui-panel/SKILL.md 3. 装好后重载技能,告诉我可以用了
This skill teaches the efficient workflow for developing UI panels in IWSDK applications using temporary ScreenSpace positioning and backdrop techniques.
When working on a UI panel, follow these steps for rapid iteration:
Temporarily add the ScreenSpace component to your PanelUI entity to make it fill the 2D screen during development:
import { ScreenSpace } from '@iwsdk/core';
world
.createTransformEntity(panelHolder)
.addComponent(PanelUI, {
config: '/ui/your-panel.json',
maxWidth: 1.0,
maxHeight: 0.5,
})
.addComponent(ScreenSpace, {
width: '90vw', // Fill 90% of viewport width
height: '90vh', // Fill 90% of viewport height
top: '5vh', // Center with 5% margins
left: '5vw',
});
Important: This is temporary for development only. Remove before production.
Create a solid color backdrop far from your gameplay area for clean UI visibility:
const backdrop = new Mesh(
new BoxGeometry(20, 20, 0.1),
new MeshBasicMaterial({ color: 0x1a1a2e }),
);
backdrop.position.set(0, 0, -50); // Far from gameplay
scene.add(backdrop);
Move the camera very close to the backdrop (within 0.5m) to eliminate background distractions:
// Position camera very close to backdrop for clean UI development
camera.position.set(0, 0, -49.5); // Just 0.5m from backdrop at z=-50
camera.lookAt(0, 0, -50);
Why close? The backdrop must fill the entire field of view to block out the 3D scene. Being far away (50m) won't work - you'll still see the environment around the edges.
Now you can rapidly iterate on your UI:
.uikitml fileThe ScreenSpace component makes the panel "follow" the camera, so it appears as a 2D overlay on your backdrop.
When you enter VR mode:
This dual-mode behavior is handled automatically by the ScreenSpaceUISystem.
UIKit components expose size information through signals. Log these to debug layout issues:
const document = PanelDocument.data.document[entity.index];
console.log('computedSize:', document.computedSize); // Intrinsic size in cm
console.log('targetSize:', document.targetSize); // Target size in meters
console.log('rootElement.size.value:', document.rootElement?.size?.value);
console.log('document.scale:', document.scale); // Applied scale
Understanding the output:
computedSize: UIKit's rendered size in centimeters (based on your CSS)targetSize: The requested size in meters (from PanelUI maxWidth/maxHeight or ScreenSpace constraints)document.scale: Uniform scale factor applied to fit target while preserving aspect ratioExample output:
computedSize: { width: 100, height: 50 } // 100cm × 50cm
targetSize: { width: 0.274, height: 0.168 } // 0.274m × 0.168m
document.scale: { x: 0.274, y: 0.274, z: 0.274 } // Scaled down by 0.274x
The ScreenSpace component positions panels using CSS-like properties:
.addComponent(ScreenSpace, {
width: '90vw', // CSS size: px, vw, vh, %, auto
height: '90vh', // CSS size: px, vw, vh, %, auto
top: '5vh', // CSS position: px, %, vh, auto
bottom: 'auto', // CSS position: px, %, vh, auto
…
Test grab system (distance grab, one-hand grab, two-hand grab) against the grab example using the iwsdk CLI.
Test XR interactions (ray, poke/touch, dual-mode, audio, UI panel) against the poke example using the iwsdk CLI.
Find and click a target object in XR. Use when testing UI interactions, clicking buttons, or verifying interactable elements work correctly.
IWSDK project planning and best practices guide. Use when planning new IWSDK features, designing systems/components, reviewing IWSDK code architecture, or when the user asks about IWSDK patterns, ECS design, signals, or reactive programming in this codebase.
Parallel test orchestrator. Runs all 9 test suites concurrently via Task sub-agents and the iwsdk CLI. Handles build, example setup, dev servers, agent launch, polling, retries, and result aggregation.
Test level system (LevelRoot, LevelTag, default lighting, scene hierarchy) against the poke example using the iwsdk CLI.