/ghibli-threejs:threejs-day-cycle-lightingfrom ghibli-threejs
Animates the sun in a three.js scene from sunrise to sunset via a single applySun(az, el) writer. Handles azimuth sweep, elevation arc, warm-to-gold light color, horizon falloff, sky dome and fog warming, god rays, and all sun-driven shader uniforms. Includes a cinematic mode that keeps the sun beside the camera for backlit shots.
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.
A toggle sweeps the sun across the sky; light colour, intensity, sky, fog, god rays, water and
every patched shader follow, and the shadow map follows for free. The key design is one
writer: applySun(az, el) writes the day state for that sun position, then the night blend on
top, then weather on top. The day cycle, GUI sliders, the night toggle and a guided tour all call
it, so nothing disagrees and nothing compounds.
Stack: three.js WebGLRenderer, a shadow-casting DirectionalLight with a target, shared
uniform objects (uSunDir, uSunColor, uSunLum) read by ShaderMaterials and
onBeforeCompile patches. Vanilla or R3F.
Add a day cycle to
{{entry file}}: a toggle animates the sun from sunrise to sunset.
- Azimuth sweeps about 230°, and elevation = 3° + 70°·sin(π·phase).
- Light colour lerps from warm orange to noon gold, and intensity falls near the horizon.
- The sky dome warms and the fog tints warm.
- Light shafts re-aim, and the water's sun-luminance uniform updates.
- Shadows follow for free, because the shadow map updates every frame. Route everything through one
applySun(az, el); anything that already drives the sun (a sun GUI, a night toggle) must keep driving every shader.Optional, for tours: "During the daytime beats of
{{tour}}, move the sun with the camera: keep it ~40° to the side of the lens's heading, ~30° up (tilting the camera lifts it), easing in over a couple of seconds and never flipping sides. Make the god rays clearly stronger then and add forward scattering (brighter looking toward the sun). Fade the follow out before the sunset sweep."
applySun(az, el):
if (weatherReady) weatherUndo() // restore the clean base (see threejs-webgl-rain-effect)
applyDay(az, el) // this file
applyNight(night.k) // threejs-ghibli-night-mode
if (weatherReady){ captureWeatherBase(); applyWeather() }
sunDir = (sin a·cos e, sin e, −cos a·cos e); place the light 30 m up sunDir from a shadow
focus point and aim its target there (move the focus with the view, snapped to 2 m, if the
world is larger than the shadow frustum).h = smoothstep(el, 4°, 40°): sun colour lerp(0xff8a4a, noon, h); intensity
SUN · (.25 + .75·smoothstep(el, 0°, 25°)).1 − h; fog colour toward 0xf0c49a
by (1 − h)·.7.uSunDir, uSunColor, uSunLum (luminance × intensity) every call — sky halo, clouds,
toon ramp, caustics and water glints all read them.quaternion.setFromUnitVectors(up, sunDir).phase = (phase + dt/150 s) % 1, az = −75° + 230°·phase (east → west), el = 3° + 70°·sin(π·phase).
When toggled off, restore the default sun and call applySun once. A tour owning the time of day
makes stepDay return early (threejs-camera-guided-tour).
camAz = atan2(fx, −fz) for dir = (sin a, ·, −cos a).camAz ± 42°, elevation clamp(30° + pitch/2, 18°, 60°). Ease with
1 − exp(−dt/2.4 s) on the wrapped angle difference.1 − |dot(axis, V)|³, so looking straight down a shaft makes it vanish. Side-on shafts plus a
pow(dot(−V, sunDir), 4) forward-scatter term reads as backlit haze.w that fades out over a handover window before the sunset sweep:
az = lerpAngle(sweepAz, followAz, w), el = lerp(sweepEl, followEl, w).strength = baseRays·(1 + 2.2·w), motes 1 + .8w.references/day-cycle.js.applyNight returns early in pure day, so uStrength *= boost compounded
every frame (it reached 1e167). Write absolute values (params.rays·(1 + boost·w)), and put
them back when a tour is cut short mid-day.applySun.threejs-ghibli-night-mode · threejs-webgl-rain-effect · threejs-ghibli-sky-clouds ·
threejs-camera-guided-tour · threejs-ghibli-toon-shading · threejs-webgl-realistic-water
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub nicksonthc/ghibli-threejs --plugin ghibli-threejs31 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./threejs-camera-guided-tourBuilds a hands-free guided camera tour for a three.js scene — keyframes as data, a time-parametrised Catmull-Rom (Hermite) path with continuous velocity, one camera-owner flag, the tour driving time of day and a day→night blend, staged creatures crossing the frame, handwritten captions, portrait-phone lens widening, instant hand-back on drag/scroll/tap/Esc, and a seek() hook for screenshots and video capture. Use when adding a tour mode, cinematic flythrough, attract mode, camera path animation, keyframed camera, spline camera or showcase video capture to a WebGL scene./threejs-cinematic-loading-screenBuilds a cinematic loading gate for a three.js scene — a painted CSS dawn (layered gradients, drifting blurred mist bands, optional conic god rays, SVG feTurbulence grain, vignette), a 2D-canvas layer of falling petals and glowing motes, a handwritten title that animates in, a gold progress line with stage captions, then "tap anywhere to enter" whose tap is the browser gesture that unlocks audio; uses a still captured from the live scene as the backdrop that cross-fades into the real render, and warms up shaders before lifting so the first interaction never stalls. Use when adding a loading screen, splash screen, intro curtain, preloader, tap-to-start / audio unlock gate or shader pre-compilation to a WebGL scene./threejs-dreamy-glass-hudTurns a three.js scene's DOM overlay into one coherent, dreamlike HUD — a single frosted-glass material shared by every pill, badge and popover whose colours are registered CSS properties so the whole HUD cross-fades from pearl to deep indigo as the scene turns to night; an inline-SVG icon dock whose lit toggles glow gold instead of shouting; a glass popover in place of a native select; first-visit hints "whispered" in handwriting that step aside the moment the visitor understands; a HUD that drifts away after half a minute of stillness; a mote of light under each tap; a staggered arrival after the loading gate; and letterbox bars during a camera tour. Use when the overlay UI looks like a dev panel on top of a beautiful scene, when asked for a dreamy, cinematic, premium or 梦幻 / 绝美 UI, glassmorphism, a day/night-aware HUD, onboarding hints, auto-hiding UI, tap feedback, or to restyle lil-gui to match./threejs-first-person-bvh-walkLands a character on a landmark and lets the visitor walk it in first person in three.js — a floating-down arrival, the camera slipping from a three-quarter view into her eyes, WASD + pointer-lock look, Shift run, E use, V over-shoulder, Esc leave, a touch thumb stick, a levitation lift between floors, interiors lit by the nearest lamps — with a three-mesh-bvh capsule controller that never gets stuck (footprint ground, sideways-only capsule push-out, glancing along edges, climb-back for every drop, a breadcrumb unstick) and a headless flood-fill + random-wander soak test that proves it. Use when the user wants first-person or third-person walking inside a GLB building or island, WASD movement with collision, a character controller, pointer lock, or says the player gets stuck on walls, balconies, stairs, rails or seams.