threejs-camera-guided-tour
Skill4 starsChanged 18 days agoMITView on GitHub
Builds 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.
In this repository30 other files it gives its agents.
- threejs-blender-glb-pipelineSkill
- threejs-boat-buoyancy-steeringSkill
- threejs-cinematic-loading-screenSkill
- threejs-day-cycle-lightingSkill
- threejs-dreamy-glass-hudSkill
- threejs-first-person-bvh-walkSkill
- threejs-fish-school-boidsSkill
- threejs-floating-island-landmarkSkill
- threejs-ghibli-night-modeSkill
- threejs-ghibli-sky-cloudsSkill
- threejs-ghibli-toon-shadingSkill
- threejs-glb-realism-pipelineSkill
- threejs-gpu-butterfliesSkill
- threejs-headless-visual-verificationSkill
- threejs-hud-objective-markersSkill
- threejs-night-lights-lanternsSkill
- threejs-object-interactionSkill
- threejs-open-world-streamingSkill
- threejs-postprocessing-anime-gradeSkill
- threejs-procedural-vegetationSkill
- threejs-shell-fur-renderingSkill
- threejs-skeletonless-character-animationSkill
- threejs-stylized-rock-materialSkill
- threejs-webaudio-generative-soundtrackSkill
- threejs-webgl-performance-profilingSkill
- threejs-webgl-rain-effectSkill
- threejs-webgl-realistic-waterSkill
- threejs-webgl-underwater-effectSkill
- threejs-webgl-wake-simulationSkill
- threejs-webgl-waterfall-effectSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 72
Keep the sun ~40–42° to the side of the lens heading, ~30° up (+ half the camera pitch, clamp 18–60°), eased with 1 − exp(−dt/2.4) on the …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Guided tour: a hands-free camera journey
A ▶ Tour button (or ?tour) plays a ~80–90 s camera journey that shows every core view in one smooth flow,
day into night, with one short caption per beat. The visitor can take over at any moment — the camera stays where
it is and the orbit controls pick up from there, no jump.
Stack: three.js WebGLRenderer + OrbitControls, an existing sun/day-cycle function and ideally a night blend
(see threejs-day-cycle-lighting, threejs-ghibli-night-mode). Vanilla or R3F (drive it from useFrame).
When to use
- The scene is finished and you want an attract mode, a showcase, or a capturable video path.
- You have preset views and want them stitched into one continuous move.
- You need scripted camera motion that coexists with orbit controls, a day cycle and other camera owners.
Paste-ready prompt
Add a Tour mode to
{{entry file}}: a hands-free camera journey of about{{90}}s that shows every core view in one smooth flow, ending at night.
- Entry/exit: a "▶ Tour" HUD button.
?tourdoes not skip the loading gate: it changes "tap to enter" into "tap to start the tour", so that tap is the gesture that lets the music start.?tour&silentkeeps the music off for capture. The visitor leaves any time via the controls'startevent,wheel, or Esc; the camera stays put and the controls take over. While it plays, atouringclass on<body>hides the HUD and slides in two soft letterbox bars (CSS only).- Sequence (every move eased, no hard cuts):
{{beats, e.g. 1 wide establishing orbit · 2 look up at the sun through backlit leaves · 3 glide down through the water surface · 4 slow glide under the surface while 2–3 fish cross the frame, then rise · 5 core views · 6 pull back while day turns to night, tilt up to the moon · 7 final wide night shot, fade in "tap to explore"}}. One short handwritten caption per beat.- How: keys
{ t, pos, target }plus[t, value]tracks for time of day and night blend; first keynull= the visitor's current camera. Time-parametrised Catmull-Rom on position and target, zero tangents only at the ends. Reuse the scene's cinematic flag ('tour'). The tour owns the time of day. Stage the fish, don't chase them. Widen the lens on portrait phones. Exposetour.seek(seconds).- Verify: screenshot every beat by seeking and calling
frame()directly, at 16:9 and phone portrait. Test drag, Esc, wheel and completion paths.
Implementation (references/tour-path.js)
Keys as data
keys: [ { t:0, pos:null, target:null }, // null = wherever the camera is now
{ t:5, pos:[7.5, 8.6, 10.8], target:[1.8, .4, -1.2] }, … ],
day: [[0, .25], [61, .25], [70, .97], [80, .97]], // dayPhase 0 sunrise … 1 sunset
night: [[0, 0], [65, 0], [75, 1], [80, 1]],
captions: [[2, 10, 'somewhere along the river'], …]Tracks are piecewise with smoothstep between samples.
Path: time-parametrised Catmull-Rom
- Hermite per segment with tangents
(p[i+1] − p[i−1]) · dt_seg / (t[i+1] − t[i−1]). Velocity is continuous through every key: no stop-and-go. Tangents are zero only at the first and last key, so the tour eases in and out. - Evaluate both
posandtarget;camera.position.copy(pos); controls.target.copy(target); camera.lookAt(target).
One camera owner
- Reuse the existing cinematic flag with the value
'tour'— whatever already skipscontrols.update()and the ground/waterline clamp. Audit every reader of that flag: in the reference scene it also hid the hero object's hover glow, which the tour's close-up needed (the ring gets a special case for'tour'). - Ignore view hotkeys while touring. End any follow camera before starting.
The tour owns the time of day
- The day cycle, the night toggle and the night fade all write the same state and would fight it (the toggle even
snaps the sun back to noon). Their per-frame steps return early while the tour is active; the tour writes day
phase, sun angles and
kevery frame, then calls the oneapplySun. - On exit: keep night on if
k ≥ 0.5, else restore the visitor's day-cycle setting. Always switchautoRotateback on at the end (OrbitControls pauses it during drags and resumes by itself — just make sure no path leaves it off).
Sun follows the lens (daytime beats)
- Keep the sun ~40–42° to the side of the lens heading, ~30° up (+ half the camera pitch, clamp 18–60°), eased with
1 − exp(−dt/2.4)on the wrapped angle. Heading uses the sun's convention:az = atan2(fx, −fz)fordir = (sin a, ·, −cos a). Side (±) is sticky: change only when the sun is > 8° from dead ahead. - Boost god rays ×(1 + 2.2·w) and add forward scatter
pow(dot(−V, sunDir), 4); fade the follow out (w → 0) before the sunset sweep. Write absolute values (params.rays * (1 + boost*w)), and restore them instopTourwhen a tour is cut short mid-day.
Staged fish crossings (stage them, don't chase them)
- Pointing at a fish fails when underwater fog hides anything past ~3 m; following one makes the camera jerk.
- Table
{ t, dur, fish, dist, dy, dir }. Each frame, place the fish on a linedistm (≈ 1–1.8) ahead of the lens, moving along the camera's screen-right axis from just past one frame edge (dist·tan(vfov/2)·aspect + body length) to the other, with a small bow toward the lens (.14·sin(πu)), heading from the path. Pure function of tour time, soseeklands mid-crossing. - The flocking step skips
scriptedfish; on release, hand it a velocity along its crossing so it swims on. - Widen the other fish's avoid-the-camera radius (~1.6 → 3.4 m) from the dive on, so the foreground clears.
- Stagger starts ~2 s apart, alternate directions and distances so they never overlap into one blob. Each fish is off-screen for its first and last ~1 s and on screen ~2.5 s.
Portrait phones
- Widen the lens instead of pulling back:
vfov = 2·atan(tan(25°)/aspect), capped at ~80°. Pulling back from a target high in the sky pushed the camera into the canopy and under the water. Restore fov on exit.
Film frame (CSS only)
tour.start/tour.stopalready togglebody.touring(it hides the HUD); hang a letterbox on the same class, with no script: twoposition:fixed; pointer-events:nonepseudo-elements, 8.5vh tall (6vh undermax-aspect-ratio:3/4), each a gradient from near-black (#05090cto 55 %) to transparent, parked attranslateY(∓101%)and brought totransform:noneunderbody.touringover a 1.6 s transition.- The bars only overlay the canvas (soft inner edges, no resize, no change to the camera). Keep them under the
caption's z-index and sit the caption just above the lower bar (
bottom:13vh).
Ending
- On completion, optionally hand off to an auto-play of the hero interaction (e.g. the book reads itself with a 4.5 s dwell per page); any pointerdown/keydown cancels the auto-play.
Pitfalls
- Seeking into a smoothed follow shows the unsmoothed start — make scripted motion a pure function of time.
- The foreground only clears if the beat is played from the dive (~18 s): other fish need seconds to leave the widened radius. Seeking straight to the fish beat shows them in the way.
- CSS transitions (captions) run on real time, not the stepped
frame()clock: screenshots right after a seek show stale captions. Drive captions from the tour clock if you capture video. - A hidden/background tab throttles
requestAnimationFrame: tweens freeze and FPS reads 0 — not a bug. - Boosting with
uStrength *= boostcompounds every frame when the night code returns early in pure day (it reached 1e167). Always write absolute values.
Verify
tour.seek(s)+ directframe()calls for each beat, at 16:9 and ~390×844 portrait.- Project each staged fish to NDC every 0.6 s: off-screen at both ends, on screen in between.
- Drag, wheel, Esc mid-tour: no camera jump, controls live,
autoRotateon, day/night state sensible. - Let it complete once end to end.
Related skills
threejs-day-cycle-lighting · threejs-ghibli-night-mode · threejs-fish-school-boids ·
threejs-cinematic-loading-screen (?tour gate) · threejs-webaudio-generative-soundtrack ·
threejs-object-interaction · threejs-headless-visual-verification
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

