Motion and interactive scenes
Status: proposed and approved 2026-11-14 (Kevin), with the decisions at the end, a Reduce motion switch for visitors, and the Globe as the first registry scene. Phase 1 has started: Brand → Motion (the level, duration, easing, distance and the visitor switch, a lockable brand part), the Motion settings on blocks (entrance, delay, stagger and hover), the motion script and the Reduce motion switch for visitors. Then the scroll effects (parallax on a Hero's background, fade out, pin), Play motion in the page builder and Reduce motion in the preview bar. Then background video on the Hero (and on Section once it gained a background image, with parallax: section-media-icons-anchors.md), count up on Stats, and the motion checks (a background video without a poster image is an error; a file other than .mp4 or .webm a warning). Phase 1 is complete apart from the visual warnings (entrances above the fold, the total weight of motion assets), which come with phase 2's media types. Phase 2 has started: the marquee on Logo strip and Testimonials (on, it loops the row with a Pause scrolling button placed before it, pauses on hover and focus, and stays a still row when motion is off or reduced; the copies that make the loop are hidden from screen readers and keyboard focus), then the Scrollytelling block with images (a scene in its media column comes with phase 3; video waits for a reason to need it), and the Lottie animation and 3D model blocks with their players served by the instance (/_motion/lottie.js, the light build without expressions; /_motion/model-viewer.js, which needs 'wasm-unsafe-eval' on the pages that have a model) and .json, .glb and .gltf in the media library. Draco and KTX2 decoders are not bundled yet (model-viewer fetches them from a Google CDN, which the policy refuses), so compressed models do not load; bundling them is the next step if sites need them. Phase 3 has started with scenes: scene on a module block (capability scenes), the sandboxed frame at /_scene/<module>/frame/<key> with its runtime and message protocol (createScene(canvas, context) and progress, playing, reducedMotion, state, theme, resize), the frame's own policy, the poster and the pause button, and the fallback to the poster when a scene fails (modules). Then the @spillway-cms/scene starter (types, a render loop that runs only while playing, navigate, a three.js template), the navigate message (the page opens only links the block lists) and the block's title passed to the scene, and the Globe (registry/modules/globe): a sandboxed module whose Rust render lists the places by region and whose three.js scene (about 590 KB, 150 KB compressed, land shapes included) shows them with routes, keyboard use and cards. It publishes once the registry runs a release with scenes. Next: Scrollytelling driving a scene's state, the registry's size rules, and places from a collection.
Marketing sites increasingly ask for movement: sections that ease in as you scroll, a hero with a slow background video, numbers that count up, a product you can turn in 3D, a WebGL scene behind the headline, a story told as you scroll past a pinned image. This proposal is how Spillway could offer that in the page builder without giving up what it is built on: pages rendered on the server as plain HTML, fast first paint, a strict content security policy, accessibility by default, and editors who never write code.
The short version: most motion is a setting, not a block. A small set of motion presets on every block, driven by brand tokens and CSS, covers most of what sites ask for at almost no cost. A handful of motion blocks covers the rest of the common cases. Real-time 3D and custom WebGL come last, as scenes: client code that runs in a sandboxed frame, so a scene can never reach the visitor's session or the admin's.
What exists
- Blocks render on the server to HTML with cache tags. There is no client framework on public pages and nothing to hydrate; the few blocks that need a script (Gallery's lightbox, the Ask block, forms) carry a short inline script with the page's CSP nonce.
- The public CSP (
render/csp.ts) allows scripts from the site itself and by nonce, plus the hosts of the integrations a site turns on. Inline event handlers and other origins are refused. - A global reduced-motion rule in the block stylesheet turns transitions off under
prefers-reduced-motion: reduce; existing motion is limited to 120 to 200 ms hover and focus transitions. - Theme tokens (Brand → Color, Type, Space and shape) become CSS custom properties; block styles (Brand → Styles) are named variants of a block that editors pick.
- Modules: sandboxed modules render a block's HTML in WebAssembly, and the host sanitizes it, so they cannot ship scripts to visitors. Trusted modules can serve static files from
/modules/<name>/on the site's own origin. - Islands: the Personalize and Experiment blocks are served as islands so pages stay cached; the same idea fits blocks that need to load something after the page.
- Front-end adapters (
@spillway-cms/astro,@spillway-cms/next) render the same blocks from/api/public/*.
Principles
- Content first, motion second. Every block renders complete, readable HTML before any motion runs. Motion only changes how it arrives or responds; nothing is hidden from search engines, screen readers, people without JavaScript or the AI's page reading.
- Reduced motion is honored everywhere, including scenes, videos and marquees. Under
prefers-reduced-motion: reducean entrance shows the end state, a parallax stays still, a video shows its poster, a scene shows its still image. - Pay only for what a page uses. A page with no motion loads no motion code. The motion runtime is one small file loaded only when a block on the page asks for it; heavier libraries (Lottie, the 3D model viewer, a scene) load only on pages that use them, and only when they scroll near the viewport.
- The brand sets the tone, editors pick from it. Durations, easing and distances are brand tokens; a site's motion level (off, subtle, expressive) caps what editors can choose. Editors pick named presets, not keyframes.
- No third-party code on the site's origin. Anything beyond core presets that runs custom code in the visitor's browser runs in a sandboxed frame with no access to the site's cookies, storage or API.
Layer 1: motion settings on every block
A Motion group in each block's fields in the page builder, next to the block style and spacing:
- Entrance: none, fade, rise, scale, slide from the left or right, and stagger for blocks with items (Cards, Stats, Logo strip, Testimonials, Collection), so items arrive one after another. A delay (none, short, medium).
- On scroll: none, parallax (a Section's or Hero's background moves slower than the content), fade out as the block leaves the viewport, pin (the block stays in place while the next ones scroll over it).
- On hover (cards, buttons, images): lift, zoom the image, tilt (expressive level only).
How it renders: the server adds data-motion attributes and classes to the block's wrapper; the block stylesheet defines the presets with the brand's motion tokens. Scroll-linked effects use CSS scroll-driven animations (animation-timeline: view()) where the browser supports them; a small motion runtime (one file on the site's origin, loaded only when a page has motion) uses IntersectionObserver for entrances and stands in for scroll-driven animations where they are missing. Without the runtime the content is simply there.
Brand → Motion (a new tab beside Space and shape): the motion level, durations (short, medium, long), the easing curve, the entrance distance, and whether hover tilt is allowed. These become --sw-motion-* tokens, are part of the brand draft and its versions, and can be locked by a parent site in a shared brand, like the other brand parts. Block styles can carry a default motion (a "Feature band" style that always rises in).
For visitors, a Reduce motion switch the brand can show (Brand → Motion, Show a Reduce motion switch, on by default whenever the motion level is not off). It sits in the footer by default, or in a placement the site chooses, as a real button with aria-pressed. It starts from the visitor's own prefers-reduced-motion setting and, once pressed, keeps their choice in local storage, so a cached page needs nothing from the server: the motion runtime sets a class on the root element before first paint, and every motion rule (entrances, parallax, hover, background video, marquees, Lottie, models, scenes) treats that class exactly like the operating system setting. Turning it off again restores the brand's motion. The switch is part of the theme, so a theme can restyle or move it but not remove it while motion is on.
In the page builder the canvas runs the same runtime: a Play motion button in the toolbar replays every entrance, and selecting a block plays its own. A Reduce motion toggle in the preview bar shows the page as a visitor with reduced motion sees it.
This layer is core, small, and covers most requests on its own.
Layer 2: motion blocks and media
Blocks or options that need more than a preset, each with the same reduced-motion and pause rules:
- Background video on Section and Hero: a muted, looping video from the media library with a required poster image,
playsinline, paused off screen, a visible pause button (WCAG 2.2.2 Pause, Stop, Hide), the poster only under reduced motion or Save-Data. - Count up on Stats: numbers count from zero when they come into view; the final number is in the HTML.
- Marquee on Logo strip and Testimonials: a continuous scroll with a pause button, paused on hover and focus, still under reduced motion.
- Autoplay on the Carousel block (blocks-carousel-accordion-tabs.md): off by default, with a pause button, held on hover, stopped when keyboard focus enters, never when the motion level is off or motion is reduced. A carousel with autoplay counts as motion, so its page carries the motion script and the Reduce motion switch.
- Scrollytelling block: a pinned media column (image, video or a scene) beside text steps; each step can switch the image or move a scene to a named state as it scrolls past. Without motion it is an ordinary list of steps with their images.
- Lottie block: a vector animation file (
.jsonor.lottie) from the media library, played when in view, looped or once, with a still frame for reduced motion. The player is self-hosted and loads only on pages that use it. - 3D model block: a
.glbor.gltffile from the media library shown with a self-hosted model viewer: orbit, zoom, auto-rotate, an optional AR button on phones, a poster image, alt text required. This covers "let people turn the product around" without writing WebGL.
The media library learns the new types (video posters, Lottie files, 3D models with a size limit and a generated poster), and the pre-publish checks gain rules for them (below).
Layer 3: scenes (custom WebGL and three.js)
For real-time graphics, such as a generative background, a particle hero, an interactive three.js product or a data visualization, a scene is a block whose content is drawn by client code.
Where the code comes from. A module declares a scene in its manifest (scenes: [{ key, label, fields, poster }]) and ships a browser bundle (its own three.js, or any library) in its public/ folder. Both tiers may declare scenes, because the code never runs on the site's origin. Spillway publishes a starter (@spillway-cms/scene, with a three.js template) whose entry is createScene(canvas, { props, theme, progress, reducedMotion }), so a developer writes the drawing code and nothing else. Later, site administrators could paste a scene's code directly (a Code scene block behind its own permission), running under the same sandbox.
How it runs. The block renders its poster image and its text on the server, then a <iframe sandbox="allow-scripts"> that loads /_scene/<module>/<key> with the block's props. Without allow-same-origin the frame has an opaque origin: it cannot read the site's cookies or storage, cannot call the API with the visitor's (or an editor's) session, and cannot reach the page around it. The page talks to it only through postMessage: the brand tokens, the scroll progress of the block (so a scene can move with the page, and Scrollytelling can drive it), visibility (paused when off screen), and reduced motion. The frame's own CSP allows its bundle and nothing else unless the manifest declares hosts.
Why a frame and not a script on the page. A script on the site's origin can do anything the person viewing the page can, and editors view the public site while signed in. Running third-party code in the page would let a scene act with an editor's permissions; the sandbox makes that impossible by construction, which is the same reason sandboxed modules may not ship scripts today. The cost is layout (the frame is sized by the block, full-bleed backgrounds sit behind the content with pointer-events passed through when the scene is decorative) and one more document per scene, which is acceptable for something that is already the heaviest thing on the page.
Budgets. A scene loads when it nears the viewport, renders at a capped device pixel ratio, pauses when hidden or off screen, and falls back to its poster on reduced motion, Save-Data, very low memory or a failed WebGL context. The registry shows a scene's bundle size, and the checks warn above a size a site sets.
The Globe: a scene that does a job
The first registry scene should be useful on its own, not a demo, and show every part of the scene contract. Globe (@spillway/globe, a sandboxed module with a three.js scene) draws an interactive 3D earth with places on it: campuses and study-abroad sites, offices, the countries a nonprofit works in, where alumni or donors are, event cities.
- Places come from the block's own list (name, latitude and longitude, a short description, a link) or from a collection whose type has a location field, so a city adds a project page and it appears on the globe. Optional routes draw arcs between places (exchange programs, supply chains, flight paths).
- On the page the globe turns slowly, leans toward the place under the pointer, and opens a small card with the place's description and link on click or Enter; arrow keys move between places, and the card is announced to screen readers. Brand colors style the land, the sea, the pins and the arcs, through the tokens the page passes in.
- The same places are HTML. The server renders them as a list (grouped by region) beside the frame, so search engines, screen readers, the AI's page reading and visitors without WebGL, with reduced motion or with Save-Data get the full content; the globe is the enhancement. The poster is a still of the globe at the block's starting view.
- Scrollytelling can drive it: each step names a place, and the globe turns to it as the step scrolls by.
- No network access. The places reach the frame as props (the server resolves the collection), and the land shapes ship inside the module, so the scene needs no hosts and never calls the API: the sandbox contract, shown working.
It doubles as the reference for the @spillway-cms/scene starter: a module author can read it to see props, tokens, scroll progress, keyboard handling, the HTML fallback and the poster done properly.
Accessibility, performance and the checks
The pre-publish checks gain motion rules:
- Error: a background video, marquee or scene that moves for more than five seconds without a pause control (WCAG 2.2.2); a 3D model without alt text; a scene or video without a poster.
- Warning: more than a few entrance animations above the fold (they delay the content people came for); a Hero whose largest element only appears after an entrance (it delays Largest Contentful Paint, so the Hero's own text skips its entrance unless forced); total motion assets on the page above the site's budget; Lottie or video files above a size limit.
- Flashing content (WCAG 2.3.1) cannot be detected in a scene or video automatically; the scene manifest and the media upload ask the author to confirm none, and the registry review checks scenes for it.
AI
Motion fields are ordinary block props, so the AI's layout tools (get_block_schema, edit_layout, validate_layout) cover them with no new tools. The brand profile gains a motion personality (calm, lively) that page-from-brief uses to choose presets within the site's motion level, and the checks above apply to AI drafts like any other. Agents never install scene modules on their own: that goes through install_module and its two-step confirmation.
Front-end adapters
Layer 1 is attributes and CSS, so the Astro and Next adapters render it as they render blocks today and include the motion runtime with the blocks' stylesheet. Motion blocks and scenes ship as small client components in the adapters, using the same frame for scenes.
Phases
- Motion settings and tokens (core): Brand → Motion and the
--sw-motion-*tokens, the motion level, entrance, stagger, parallax and hover presets, the motion runtime, Play motion and Reduce motion in the page builder and preview, background video on Section and Hero with its pause button and poster, Count up on Stats, the checks above. Small and self-contained. - Motion blocks: Marquee, Scrollytelling, Lottie and 3D model, with the media library types they need.
- Scenes: the scene manifest entry, the
/_sceneframe and its message protocol, the@spillway-cms/scenestarter with a three.js template, the Globe module in the registry (below) and a lighter decorative scene (an ambient gradient in brand colors), scenes driven by Scrollytelling, and the registry's size and review rules. Code scenes for site administrators after that.
Decisions
Decided 2026-11-14 (Kevin):
- Default motion level: new sites and kits start at subtle; existing sites stay off until someone turns motion on, so nothing starts moving after an upgrade.
- Scenes always run in the sandboxed frame, from trusted modules too.
- Lottie and 3D models are in core, loaded only on pages that use them.
- Code scenes pasted by site administrators come later, behind their own permission and in the same sandbox, after module scenes.
- Motion is a brand part a parent site can lock in a shared brand.
- Visitors get a Reduce motion switch (above), on by default whenever motion is on.
- The Globe is the first registry scene, built with phase 3.
Spillway 0.1.24