/ghibli-threejs:threejs-headless-visual-verificationfrom ghibli-threejs
Verifies three.js/WebGL scenes headlessly using Playwright on real Chrome with GPU flags. Stops animation loops, steps frames deterministically, captures canvas via toDataURL, and handles hover/click with synthetic PointerEvents. Use when screenshots come back blank, stale, or frozen.
Ships in ghibli-threejs. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Every visual change should be checked against the reference from fixed views. Doing that
through an interactive browser tab is slow and flaky (throttled rAF, stolen focus, stale
frames). The reliable path: headless Chrome with a real GPU, the render loop stopped, and
frames stepped by hand. Stack: three.js WebGLRenderer (vanilla or R3F) served locally,
Playwright (npm i playwright), Chrome installed.
pointermove.Verify
{{change}}in{{entry file}}headlessly: serve the folder, launch Playwright Chrome headless with--use-angle={{metal|gl}} --enable-gpu --ignore-gpu-blocklist, wait for the page's ready state, stop the animation loop, set camera / night / weather state, stepframe(t += 50)N times and readcanvas.toDataURL()in the same evaluate. Shoot{{views: reference, eye level, close-up, max zoom-out, 16:9 and phone portrait}}, log the relevant state at shot time, read the console, and compare each PNG with{{reference image}}.
const frame = time => { … }; renderer.setAnimationLoop(frame).window.__app = { scene, camera, controls, renderer, composer, frame, goView, setNight, applySun, … } plus seek(seconds) for tours and k = 0/1 setters for
blends, so end states can be driven directly.#loading.ready) after models load and a warm-up frame has compiled shaders.npx serve -l 8765 . (or any static server).chromium.launch({ channel:'chrome', headless:true, args:['--use-angle=metal', '--enable-gpu', '--ignore-gpu-blocklist'] }) (macOS: metal; Linux: try --use-angle=gl
or swiftshader as a slow fallback).goto(url + '?v=' + Date.now(), { waitUntil:'commit' }) — the default load wait times
out on CDN fonts. npx serve redirects /index.html → / and drops the query string:
/index.html?lang=zh&silent arrives as / with every flag gone, and the page quietly tests
as its default. Navigate to /?flags and assert location.search once.waitForSelector('#loading.ready'), press a key/tap to enter if there is a gate.renderer.setAnimationLoop(null), set camera/state, call
frame(t0 + i*50) N times (a timestamp is required — without it the canvas renders
white), then return canvas.toDataURL('image/png'). Write it to disk from Node.{ name, pos | posExpression, target, night, js, frames, log } —
see references/capture.cjs (template).page.screenshot timed out. Stop the loop and drive it:
renderer.setAnimationLoop(null), then frame(T += 33) N times and
canvas.toDataURL('image/jpeg', .9) in the same evaluate. Keep T on window so
successive shots continue one clock.WEATHER.mode = 'clear', rain 0, night off):
otherwise rain streaks land in some views of a comparison and not others.chromium.launch, not their tab) on your own port (e.g. 8791, not a
port another project serves) and a separate blender --background --factory-startup
process. Never reuse their tab or server.controls.update() silently pulls the camera in.canvas.toDataURL holds only the WebGL frame. To check the DOM overlay (dock, badges,
captions, popovers) use page.screenshot, leave the animation loop running and wait in
wall-clock time (waitForTimeout), since CSS transitions do not follow a stepped clock. On
real Chrome with the GPU flags above this returned correct frames of a heavy scene, canvas
included, at ~15 fps headless.viewport 390×844, deviceScaleFactor 2, hasTouch, isMobile), by day and by night, with each popover open, and in every language.setNight(true), startTour(), button.click())
and wait for the transition; paste several PNGs into one contact sheet to review them at once.git show HEAD:index.html > old/index.html,
symlink the asset folders into old/, serve it on a second port, and interleave runs
(old, new, old, new). Headless frame times swing by ±30 % with whatever else the machine is
doing; single runs prove nothing.renderer.info.programs.length, and launch with --disable-frame-rate-limit --disable-gpu-vsync so both builds are not simply pinned to the refresh rate.A macOS pinch is a wheel event with ctrlKey:true. Dispatch a batch of them on the canvas in
every camera mode and assert the lens was not zoomed and the limits held:
for (const dy of [-40,-40,-40,-40,60,60,60,60,60,60])
c.dispatchEvent(new WheelEvent('wheel', { bubbles:true, cancelable:true, ctrlKey:true, clientX:700, clientY:450, deltaY:dy }))
// expect camera.zoom === 1, fov unchanged, minDistance ≤ distance(camera, target) ≤ maxDistance
Capture fixed views of every object in
{{landmark}}(exterior orbit poses + interior first-person poses), have a critic agent score each object 1–10 on a fixed rubric ({{e.g. 40 % form, 30 % storytelling, 30 % paint}}), rank them, and fix the lowest first. Re-capture the same views, re-score with the same rubric, and stop when the mean gains < ~0.1 over the previous round.
Project objects to NDC once per 0.6 s to prove they cross the frame; walk path samples for
clearance; print height grids around placements; log renderer.info and state at shot time
rather than guessing.
Browser-automation clicks don't fire the pointermove hover logic needs. Dispatch
PointerEvents on the canvas at CSS coordinates (the tool's screenshot frame ≠ CSS px):
const c = renderer.domElement, r = c.getBoundingClientRect()
for (const type of ['pointermove', 'pointerdown', 'pointerup', 'click'])
c.dispatchEvent(new PointerEvent(type, { clientX:r.left + x, clientY:r.top + y, bubbles:true, pointerId:1, isPrimary:true }))
Expect a harmless OrbitControls setPointerCapture exception from the synthetic pointerdown.
A single-file scene dies silently at 0 % (or hangs the headless wait) on a syntax error.
Extract the module and run node --check:
awk '/<script type="module">/{f=1;next}/<\/script>/{f=0}f' index.html > /tmp/m.mjs && node --check /tmp/m.mjs
renderer.info frames not advancing means the tab is hidden, not NaN or a lost context.
Check document.visibilityState and that the time uniform advances. The headless loop
sidesteps this entirely.preserveDrawingBuffer reads back blank after the
frame; toDataURL must run in the same task as the frames. page.screenshot came back blank
when the loop had been stopped; with the loop running it captures canvas and DOM together.index.html — navigate with ?v=N.frame() calls advance dt by ≤ .05 s each, so a 4 s
fade needs ~80 frames; CSS transitions (captions) and wall-clock effects run on real time,
so captions look stale right after a seek.next: 8 + rand*10) fire at once
because the frame clock is page time (thousands of seconds). Seed from the first step's t
(C.next ??= t + …).maxDistance silently pulls a far debug camera in.// in one-line code: a trailing // comment pasted after a ) comments out the paren
("missing ) after argument list"); mid-line it can remove a guard. In CSS // isn't a comment
and swallows the next rule. Comments on their own line.'\n' in a template literal into a
real newline → Invalid or unexpected token. Escape as \\n or edit with a raw string.Math.exp(-(a/.3)**2) is a SyntaxError (unary minus before **) — node --check catches it.ioreg -c IOHIDSystem | awk '/HIDIdleTime/') before opening a visible browser; batch
visible checks for when they're away. Prefer headless.For each change: reference view, eye level, close-up, max zoom-out (plus 16:9 and portrait phone for camera work); console clean; the relevant state logged at shot time; numbers checked where they exist.
references/capture.cjs — TEMPLATE shot-list capture script (Playwright, stepped frames, toDataURL).references/ev.cjs — TEMPLATE: evaluate an expression in the running page and print it.threejs-webgl-performance-profiling · threejs-camera-guided-tour · threejs-object-interaction · threejs-cinematic-loading-screen · threejs-ghibli-night-mode · threejs-blender-glb-pipeline · threejs-floating-island-landmark · threejs-first-person-bvh-walk · threejs-dreamy-glass-hud
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub nicksonthc/ghibli-threejs --plugin ghibli-threejsOther plugins' skills for the same job
31 skills in this plugin
/threejs-blender-glb-pipelineBuilds a reference-image-driven asset pipeline from headless Blender to GLB for a three.js scene — an asset contract (units, axes, grounding, required mesh/material names, budgets, attachment numbers), one parallel subagent per asset group writing craft_<slug>.py generators, preview renders compared against the reference, measured-bounding-box placement in the web scene, Draco compression, and a scored asset quality pass. Use when the user has a reference picture and wants a 3D scene from it, asks to model props/trees/characters in Blender for three.js, export GLBs, fix glTF export issues (vertex-colour alpha, UV flip, axes, custom normals), compress models, or rate and improve every asset in a scene./threejs-boat-buoyancy-steeringFloats a boat (or any buoyant prop) on three.js water with Gerstner waves generated from one JS table that feeds both the GLSL vertex shader and a CPU waveHeight(), four-probe heave/pitch/roll damped springs, an arc-length drift lane that bends round rocks, click-to-steer W/A/S/D rowing with momentum and drag, an autopilot that pursues the lane back, and a chase camera that keeps the orbit. Use when the user wants a drifting or steerable boat, buoyancy, objects bobbing on waves, Gerstner waves on a river/lake, a boat autopilot, or a follow/chase camera behind a vehicle on water.