Gallery Rail

The museum’s path-and-gaze camera controller with inertial scroll, drag, keyboard travel, custom Catmull–Rom routes and reduced-motion seeking. Its small gallery demo loads no museum model.

Exact preview of Gallery Rail
Type
Component
Category
Scroll
Source license
MIT
Collection
Open Source Experiences

View source in the repository

Usage

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Frontfield component</title>
<style>html,body{margin:0;background:#121418;color:#eee;font:14px system-ui}canvas{display:block}button{padding:10px 16px}</style>
<!-- Serve the included public/experiences/museum/ directory alongside this file. -->

<script type="importmap">{
  "imports": {
    "three": "/experiences/museum/lib/three.module.js"
  }
}</script>
<script type="module">
import * as THREE from 'three';
import {GalleryRail} from '/experiences/museum/parts/gallery-rail.js';
const scene=new THREE.Scene();
const camera=new THREE.PerspectiveCamera(50,innerWidth/innerHeight,.1,100);
const renderer=new THREE.WebGLRenderer({antialias:true});renderer.setSize(innerWidth,innerHeight);document.body.append(renderer.domElement);renderer.domElement.tabIndex=0;
const path=new THREE.CatmullRomCurve3([new THREE.Vector3(0,1,10),new THREE.Vector3(3,1,3),new THREE.Vector3(-2,1,-4)]);
const rail=new GalleryRail(camera,{path,rotations:[{progress:0,rotation:new THREE.Euler(0,0,0)},{progress:1,rotation:new THREE.Euler(0,0,0)}]});
const cube=new THREE.Mesh(new THREE.BoxGeometry(2,2,2),new THREE.MeshNormalMaterial());scene.add(cube);
rail.attach(renderer.domElement);const clock=new THREE.Clock();
renderer.setAnimationLoop(()=>{rail.update(clock.getDelta());renderer.render(scene,camera);});
addEventListener('resize',()=>{renderer.setSize(innerWidth,innerHeight);camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();});
// rail.seek(.5,true); rail.dispose() removes controls. Supply your own path and scene.
</script>
</html>

License and credits

Codrops Fan Museum by Andrew Woan. Original upstream source

Read the original MIT license

Credits and asset notices

Third-party assets and dependencies

vendor/experiences/museum/ASSET-NOTICES.md

Keep the original source and media notices with your copy.

Explore more

  • Liquid FormExact preview of Liquid Form

    A centered silver ray-marched liquid form with authored studio reflections and pointer-responsive camera drift.

  • Boarding PassExact preview of Boarding Pass

    A live flight pass whose changed gate and times roll over like a departures board.

  • Aurora TextExact preview of Aurora Text

    Multi-colour aurora motion within a large type specimen.

Frontfield homepage