paper-motion

Turn in

turn-in

An object arrives edge-first and turns to face the camera with a spring's overshoot; the camera answers with a small counter-move, in 3 s.

Install
$ npx paper-motion add turn-in

Writes a scene to pieces/, wired to your brand folder.

Tune it, then add it to your kit
Parameters
image
title
ratio
from
format
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>turn-in</title>
<!--
  Shot · turn in (3 s). An object (a card, a cover, a screenshot) arrives edge-first and turns to face the camera,
  overshooting a touch and settling; the camera answers with a small counter-move, so the turn reads in depth.
  Arrive 0–1.4 s · Settle 1.4–2.2 s · Hold 2.2–3 s.
  Look, fonts and sound come from /brand. Edit CONFIG: the object's picture (or a drawn card with a title), its
  proportions. Ask your agent to use it as the reveal of a product shot, a cover, a card.
-->
<style>
  #stage { overflow: hidden; }
  .abs { position: absolute; box-sizing: border-box; }
  #obj { overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
  #obj img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
</style>
</head>
<body>
<main id="stage">
  <div id="bg" class="abs" style="inset:0"></div>
  <div id="vig" class="abs" style="inset:0"></div>
  <div id="world"><div id="obj"><div id="label"></div><div id="title"></div></div></div>
</main>
<script type="module">
import { scene, progress, ease, spring } from 'paper-motion';
import { wordRise, blurIn } from 'paper-motion/moves';
import { camera } from 'paper-motion/kit';
import { loadBrand } from 'paper-motion/brand';

const CONFIG = {
  background: null,
  image: null,
  title: 'Boards',
  label: '01',
  ratio: 1,
  from: 'left',
  format: [1920, 1080],
};

const B = await loadBrand();
const [W, H] = CONFIG.format, SHORT = Math.min(W, H), D = 3, dir = CONFIG.from === 'right' ? -1 : 1;
const s = scene({ width: W, height: H, fps: 30, duration: D, background: B.color('ground') });
const bgId = CONFIG.background ?? B.set.entries.find((e) => e.shader && !e.image)?.id;
if (bgId) B.shader(s, '#bg', bgId);
document.querySelector('#bg').style.opacity = 0.4;
document.querySelector('#vig').style.background = 'radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 35%, rgba(0,0,0,0.6) 100%)';
const $ = (id) => document.getElementById(id);

const DIST = SHORT * 0.7, K = 1 + DIST / (SHORT * 1.7);
const cam = camera($('stage'), $('world'), { perspective: SHORT * 1.7 });
const obj = $('obj'), oh = SHORT * 0.6 * K, ow = oh * CONFIG.ratio, R = (B.tokens?.shape?.radius ?? 12) * (SHORT / 1080) * K;
Object.assign(obj.style, { width: `${ow}px`, height: `${oh}px`, borderRadius: `${R}px`, padding: `${oh * 0.08}px`, background: B.surface(0.22), border: `1.5px solid ${B.color('figure')}70`, boxShadow: `0 ${SHORT * 0.05}px ${SHORT * 0.14}px rgba(0,0,0,0.7)` });
if (CONFIG.image) { const img = document.createElement('img'); img.src = CONFIG.image; obj.prepend(img); $('label').remove(); $('title').remove(); }
else {
  if (bgId) { const f = document.createElement('div'); Object.assign(f.style, { position: 'absolute', inset: 0, opacity: 0.25 }); obj.prepend(f); B.shader(s, f, bgId); }
  const label = B.style($('label'), 'caption', { short: SHORT * K, color: 'muted' }), title = B.style($('title'), 'display', { short: SHORT * K * 0.8 });
  label.textContent = CONFIG.label; title.textContent = CONFIG.title; label.style.position = title.style.position = 'relative';
  title.style.marginTop = `${SHORT * 0.015}px`;
}
await document.fonts.ready;

const T = { turn: [0.1, 1.8] };
s.update((t) => {
  // the turn: from 85° edge-on to face-on with a spring's overshoot
  const q = ease.inOutCubic(progress(t, T.turn[0], T.turn[1] - 0.2));   // slow in and out: the edge reads, then the face settles
  const slide = progress(t, ...T.turn, ease.outCubic);
  cam.place(obj, { x: dir * SHORT * 0.5 * (1 - slide), y: 0, z: -SHORT * 0.1 * (1 - slide), yaw: dir * (85 - 85 * q), pitch: 4 * (1 - q) });
  obj.style.opacity = String(progress(t, 0, 0.3));
  // the camera answers: a small move the other way, then still
  cam.at({ x: -dir * SHORT * 0.05 * (1 - slide), y: 0, z: DIST + SHORT * 0.08 * (1 - slide), yaw: -dir * 6 * (1 - slide), pitch: 0 });
  cam.focus(DIST, SHORT * 1.2, 6);
  if ($('title')) { wordRise($('title'), t, { start: T.turn[1] - 0.3, each: B.pace.stagger, duration: 0.7 }); blurIn($('label'), t, { start: T.turn[1] - 0.4, duration: 0.5 }); }
});
B.cue(s, 'transition', T.turn[0]); B.cue(s, 'land', T.turn[1] - 0.1);
B.sound(s);
await s.start();
</script>
</body>
</html>
Defaults

Structure

Turn in01 / 03
Arrive
edge-first, turning to face the camera
0.0 / 3 s
01Arrive
02Settle
03Hold
0 s3 s
  1. 010–1.4 sArriveedge-first, turning to face the camera
  2. 021.4–2.2 sSettleovershoot and rest; the words land
  3. 032.2–3 sHoldstill

The script, sketched: the beats in order and their length, in the brand's colors and type. The clip above is the engine's render of the same recipe.

Notes

  • Wired to the brand folder: needs brand/tokens.json (a palette and a font pair work) and, for the field, a shader-set entry.
  • The turn is a spring (spring() from paper-motion): stiffness and damping in the scene set the overshoot.

Spec

Id
turn-in
Type
Shots
Version
1.0.0
Engine
>=0.2.6
License
MIT

Related