What does robot-viewer do?
Pipeline: URDF + meshes → one GLB (gltf-transform, meshopt compression, link/joint node tree, joints JSON inside and beside it) → <robot-viewer> bundle (three.js + a pure-JavaScript meshopt decoder, no WebAssembly, no workers, no inline code) → poster drawn by the real component in headless Chrome → demo page, snippet, size report.
Skill folder (written $V below): this folder. Every command is $V/robot-viewer <command>; $V/robot-viewer help lists them all.
Workflow
$V/robot-viewer check.npm ciin$Vif packages are missing. Chrome with WebGL is needed only for posters,verifyandrecord; ffmpeg only forrecord.- Rights. Ask where the robot model came from unless it is clearly the user's own. The GLB, poster and any video are modified copies (derivative works) of the meshes that every visitor downloads, so the user needs the right to redistribute and modify them. Many public robot descriptions do not allow it. Pass
--licenseand--sourceto the build: they are written into the GLB (asset.copyright) and shown on the demo page. Keep the upstream licence (and NOTICE file, if there is one) with the published files. $V/robot-viewer inspect <robot.urdf>: joint names, types, limits in degrees or metres, meshes found or refused. Xacro must be expanded first (xacro x.urdf.xacro > x.urdf). Pass--package <package folder>(the folder holding bothurdf/andmeshes/) when meshes are written aspackage://name/...and that folder is not calledname, or as../meshes/....- Write a poses file with the user, using only joint names from
inspect:{ "units": "deg", "default": "home", "poses": { "home": { "shoulder": -12, "elbow": 118 }, "reach": { ... } } }- 2 to 5 poses that show what the robot is for. Names are button labels: short words.
defaultis how the robot first appears and where the floor goes (the lowest point in that pose). Pick a pose in which it stands on its base.- Sliding joints are metres whatever
unitssays. Mimic and fixed joints cannot be posed. - Values outside the limits stop the build.
--clamppulls them in with a warning; prefer fixing the value.
- Build:
It prints every warning, the size report and the snippet.$V/robot-viewer build <robot.urdf> --out <site's static folder>/robots --poses poses.json --title "Name" --alt "what it is" --base /robots/--orbit "az el"sets the starting view (degrees; 0 is the robot's +X side). Run it once per robot into the same--out; the demo page lists them all. - Look at it. Read the poster PNG (
<out>/<name>.poster.png). Check the robot is upright, whole, in the default pose and not tiny. If the view is edge-on, rebuild with another--orbit; if a pose looks wrong, fix the poses file. For more angles:$V/robot-viewer poster <out> <name> --pose reach --orbit "120 20". Do not say it looks right without having viewed it. $V/robot-viewer verify <out>: static CSP check of every page and script, then the demo page in Chrome under the headerContent-Security-Policy: default-src 'self'. It must end with "no violations or errors".- Hand over: the snippet, the size report, the poster path, and the rules below. Optional:
$V/robot-viewer record <out> <name> --out demo.mp4for a short video of poses, a slider and a drag (--theme darkfor a dark one). Read a few frames from it before sending it on.
Putting it on a site
- Copy the whole
dist/folder into the site's static files. At the least keeprobot-viewer.js,robot-viewer-engine.js,robot-viewer.css,robot-viewer-licenses.txt(the MIT texts of three.js and meshoptimizer, which their licences require you to ship) and each robot's.glband.poster.*. The JS files must stay side by side. - Paste the snippet. The
<script type="module">goes in once per page, however many robots it shows. - Size: the element fills its width; height comes from
--rv-aspect(default4 / 3) or a CSS height. When it is 760 px or wider the control panel moves to the side (--rv-aspect-wide, default16 / 9). - Restyle with CSS variables on the element:
--rv-accent,--rv-surface,--rv-ink,--rv-line,--rv-stage,--rv-grid,--rv-shadow,--rv-radius-frame,--rv-panel-width,--rv-font,--rv-mono.theme="dark"ortheme="light"forces a theme; otherwise it follows the visitor's setting. - Attributes:
src,poster,alt,pose,orbit,controls(full,poses,none),ik,grid="off",loading="eager",theme,ar-glb,ar-usdz. Changingsrc,controlsorikafter loading rebuilds the 3D view;pose,theme,grid,poster,altand the AR attributes apply in place;orbitandloadingare read when the view is built. Removing the element frees its WebGL context. - React, Vue, Svelte: load the script once on the client and render
<robot-viewer ...>as a normal element. Do not render it on the server with properties; attributes are enough. - Serve
.glbasmodel/gltf-binary(most hosts already do). Turn on gzip or brotli for.js.
AR button
The viewer shows "View in your room" only when it is given AR files and the visitor's phone can open them. Make the files with the ar-models skill (~/.claude/skills/ar-models): ar convert robot.urdf --height <real height in metres> --pose "..." --out ar/, then pass them to the build: --ar-glb ar/robot.glb --ar-usdz ar/robot.usdz. Its README covers real-world size, the MIME types and testing on phones. Do not copy its code here; it is a separate tool. AR was not tested on phones by this skill.
Rules
- Say what the viewer is: an interactive model. Nothing checks collisions, balance, torque or speed. Joint limits from the URDF are the only rule enforced. The demo page says so; keep that line or an equivalent where the user publishes it.
- Never invent specifications in titles, alt text or pages. Numbers shown (joints, links, triangles, file size) come from the build.
- Textures are not carried into the GLB (colours are). This keeps the viewer free of
blob:URLs, which a strict policy blocks. If the user's robot relies on image textures, say so. - Keep the GLB under about 4 MB. If it is larger, give a triangle budget:
--triangles 60000for the whole robot (or--simplify 0.3, the share to keep). It works on CAD and STL meshes with per-face normals: it merges by position, simplifies within a growing error bound, and rebuilds crease-aware normals. The build prints before, after and the error used. Look at the poster again afterwards.
Troubleshooting
- "not found" for meshes:
inspectshows where it looked. Use--package <folder>forpackage://name/...paths, or fix the path in the URDF. - "leads outside the URDF folder": the usual ROS layout (
urdf/robot.urdfwith../meshes/...orpackage://name/meshes/...) needs--package <folder that holds urdf/ and meshes/>. Anything outside that folder is refused on purpose. - "absolute path": refused on purpose. Copy the meshes into the package folder and use relative paths.
- Robot lying on its side: the URDF is not Z-up, or a COLLADA file declares the wrong up axis. Check
<up_axis>in the.dae. - Robot floating or under the floor: the floor sits under the default pose. Choose a default pose that rests on the base.
- Blank grey box in the page: open the browser console. A 404 means the
.glbpath insrcis wrong (it is relative to the page, or use--base). A policy error means the site's own CSP is stricter thandefault-src 'self'(for exampleconnect-src 'none'). - No poster: Chrome with WebGL was not found. The build still works; run
posterlater on a machine that has it. recordcannot find ffmpeg: install it, or setFF=/path/to/ffmpeg, orROBOT_VIEWER_PYTHONto a Python that hasimageio-ffmpeg.recordis slow: rendering is in software (SwiftShader) without a GPU, roughly 5 to 6 frames a second at 1280x720.