ui/*.uikitml using HTML/CSS‑like syntax.hover, active, focus, sm..2xl).@iwsdk/vite-plugin-uikitml watches your source directory (default ui) and writes JSON to public/ui in dev.buildStart and prints a summary.parse(text) from @pmndrs/uikitml.// vite.config.ts
import UIKitML from '@iwsdk/vite-plugin-uikitml';
export default {
plugins: [
UIKitML({
sourceDir: 'ui', // where .uikitml lives
outputDir: 'public/ui', // where .json is written
watch: true,
verbose: false,
include: /\.uikitml$/, // files to compile
}),
],
};
PanelUI component at the JSON path and add it to an entity.entity.addComponent(PanelUI, {
config: '/ui/menu.json', // served from public/ui
maxWidth: 1.0, // meters (world‑space cap)
maxHeight: 0.6,
});
PanelUISystem will:
fetch(config) → load JSONinterpret(parseResult) → build a UIKit root componentUIKitDocument and attach to your entity’s object3Dupdate() each frame (animation/tween support)PanelUI.maxWidth/maxHeight and the entity’s world scale.ScreenSpace to place the panel relative to the camera using CSS‑like strings:entity.addComponent(ScreenSpace, {
width: '40vw',
height: 'auto',
bottom: '24px',
right: '24px',
zOffset: 0.25,
});
UIKitDocument from PanelDocument to reach into the UI tree:const doc = entity.getValue(PanelDocument, 'document');
const startBtn = doc?.getElementById('start');
vite serve, the plugin compiles all ui/*.uikitml to public/ui/*.json and starts a watcher..uikitml trigger regeneration; your app can fetch('/ui/file.json') without manual steps.verbose: true for detailed logs and parse diagnostics.vite build, compilation runs once at the start; a summary lists generated files and any failures.public/ui path for static serving.ui/menu.uikitml → public/ui/menu.json (same relative structure under subfolders).fetch(config) fails, PanelUISystem throws an error with status details.zOffset meters in front of the near plane:
worldHeightAtZ = 2 * tan(fov/2) * zOffsetworldPerPixel = worldHeightAtZ / canvasHeighttargetWorldWidth = pixelWidth * worldPerPixeltargetWorldHeight = pixelHeight * worldPerPixelUIKitDocument then scales uniformly to fit those target meters.hover, active, focus) is reflected in styles automatically.PanelUI documents to different entities; each can be world‑ or screen‑space independently.interpret(parseResult, kit) to map custom tags to specialized UIKit components.