Prompt specification
Build or customize the Three.js 3D scene "Jump With Preparation and Landing Settle" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Jump With Preparation and Landing Settle
Category: Games & Play · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/jump-with-preparation-and-landing-settle-x3690
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring an animation of a short stylized jump with anticipation, flight, and landing compression. Keep the trajectory continuous and distinguish animation exaggeration from a calibrated biomechanical model. Stylized solid forms.
Working Three.js Starter (jump-with-preparation-and-landing-settle-x3690):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Stylized Jump — Continuous Trajectory Study</title>
<style>
:root {
color-scheme: light;
--ink: #20303a;
--muted: #65747c;
--panel: rgba(250, 248, 241, 0.88);
--line: rgba(32, 48, 58, 0.15);
--accent: #e9674d;
--guide: #159a9a;
--progress: 0%;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #eee9df;
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
#viewport {
position: fixed;
inset: 0;
}
#viewport canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#viewport canvas:active {
cursor: grabbing;
}
.title-block {
position: fixed;
top: 28px;
left: 30px;
z-index: 3;
pointer-events: none;
max-width: 430px;
}
.eyebrow {
margin-bottom: 8px;
color: var(--accent);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 4vw, 48px);
line-height: 0.98;
letter-spacing: -0.045em;
font-weight: 850;
}
.subtitle {
margin-top: 10px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.disclaimer {
position: fixed;
top: 28px;
right: 28px;
z-index: 3;
width: min(350px, calc(100vw - 40px));
padding: 15px 16px;
border: 1px solid var(--line);
border-radius: 15px;
background: var(--panel);
backdrop-filter: blur(12px);
box-shadow: 0 12px 34px rgba(40, 47, 48, 0.08);
pointer-events: none;
}
.badge {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
color: var(--accent);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.badge::before {
content: "";
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 4px rgba(233, 103, 77, 0.14);
}
.disclaimer p {
margin: 0;
color: #536169;
font-size: 11.5px;
line-height: 1.55;
}
.legend {
display: flex;
align-items: center;
gap: 9px;
margin-top: 11px;
color: var(--guide);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.legend::before {
content: "";
width: 30px;
height: 0;
border-top: 2px dashed var(--guide);
}
.timeline-panel {
position: fixed;
left: 50%;
bottom: 24px;
z-index: 4;
width: min(880px, calc(100vw - 32px));
transform: translateX(-50%);
padding: 16px 18px 14px;
border: 1px solid var(--line);
border-radius: 18px;
background: rgba(250, 248, 241, 0.93);
backdrop-filter: blur(16px);
box-shadow: 0 16px 50px rgba(40, 47, 48, 0.13);
}
.timeline-top {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18px;
}
.phase-wrap {
min-width: 0;
}
#phase-name {
margin-bottom: 3px;
color: var(--accent);
font-size: 11px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
}
#phase-copy {
margin: 0;
color: #526168;
font-size: 12px;
line-height: 1.35;
}
#time-readout {
flex: 0 0 auto;
color: var(--ink);
font-variant-numeric: tabular-nums;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.05em;
}
.scrubber {
position: relative;
margin: 15px 0 13px;
height: 14px;
}
#timeline {
position: absolute;
inset: 3px 0 auto;
width: 100%;
height: 5px;
margin: 0;
appearance: none;
border-radius: 999px;
outline: none;
background:
linear-gradient(
to right,
var(--accent) 0%,
var(--accent) var(--progress),
rgba(32, 48, 58, 0.13) var(--progress),
rgba(32, 48, 58, 0.13) 100%
);
cursor: pointer;
}
#timeline::-webkit-slider-thumb {
width: 16px;
height: 16px;
appearance: none;
border: 3px solid #fffaf0;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 2px 8px rgba(32, 48, 58, 0.28);
}
#timeline::-moz-range-thumb {
width: 12px;
height: 12px;
border: 3px solid #fffaf0;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 2px 8px rgba(32, 48, 58, 0.28);
}
.controls {
display: flex;
align-items: center;
gap: 8px;
}
button {
appearance: none;
border: 1px solid rgba(32, 48, 58, 0.16);
border-radius: 9px;
padding: 7px 11px;
background: rgba(255, 255, 255, 0.6);
color: var(--ink);
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
cursor: pointer;
transition:
background 140ms ease,
transform 140ms ease,
border-color 140ms ease;
}
button:hover {
border-color: rgba(32, 48, 58, 0.32);
background: #fff;
}
button:active {
transform: translateY(1px);
}
button.primary {
border-color: var(--accent);
background: var(--accent);
color: white;
}
button.primary:hover {
background: #d95b43;
}
.camera-hint {
margin-left: auto;
color: #7a868b;
font-size: 10px;
letter-spacing: 0.035em;
}
@media (max-width: 760px) {
.title-block {
top: 18px;
left: 18px;
max-width: 58vw;
}
.subtitle {
display: none;
}
.disclaimer {
top: 18px;
right: 18px;
width: min(270px, 40vw);
padding: 11px 12px;
}
.disclaimer p {
font-size: 10px;
}
.legend {
display: none;
}
.timeline-panel {
bottom: 14px;
padding: 13px 14px 12px;
}
#phase-copy {
max-width: 270px;
font-size: 11px;
}
.camera-hint {
display: none;
}
}
@media (max-width: 520px) {
.disclaimer {
top: auto;
right: 14px;
bottom: 154px;
width: 230px;
}
.disclaimer p {
display: none;
}
.timeline-top {
gap: 8px;
}
#phase-copy {
max-width: 210px;
}
.controls {
gap: 5px;
}
button {
padding: 7px 8px;
font-size: 9px;
}
}
</style>
</head>
<body>
<div id="viewport"></div>
<header class="title-block">
<div class="eyebrow">Motion study / 01</div>
<h1>One clean jump.</h1>
<div class="subtitle">
Anticipation, a continuous flight arc, and an exaggerated landing compression.
</div>
</header>
<aside class="disclaimer" aria-label="Animation interpretation note">
<div class="badge">Stylized — not biomechanically calibrated</div>
<p>
Timing, limb extension, and compression are art-directed for readability.
No measured joint angles, forces, energy, or ground-reaction values are represented.
</p>
<div class="legend">Authored pelvis path</div>
</aside>
<section class="timeline-panel" aria-label="Animation timeline">
<div class="timeline-top">
<div class="phase-wrap">
<div id="phase-name" aria-live="polite">Ready</div>
<p id="phase-copy">The character holds a neutral starting pose.</p>
</div>
<div id="time-readout">0.00 / 4.30 s</div>
</div>
<div class="scrubber">
<input
id="timeline"
type="range"
min="0"
max="4.3"
step="0.001"
value="0"
aria-label="Animation time"
/>
</div>
<div class="controls">
<button id="play" class="primary" type="button">Pause</button>
<button id="replay" type="button">Replay</button>
<button id="speed" type="button">1×</button>
<div class="camera-hint">Drag to orbit · Wheel to zoom · Double-click to reset</div>
</div>
</section>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer, scene, and camera
// ------------------------------------------------------------
const viewport = document.getElementById("viewport");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.domElement.setAttribute(
"aria-label",
"A stylized solid-form character performing a short jump"
);
viewport.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xeee9df);
scene.fog = new THREE.Fog(0xeee9df, 11, 23);
const camera = new THREE.PerspectiveCamera(
34,
window.innerWidth / window.innerHeight,
0.1,
60
);
const cameraState = {
yaw: 0.58,
pitch: 0.25,
radius: 10.2,
target: new THREE.Vector3(0.28, 1.45, 0)
};
function updateCamera() {
const { yaw, pitch, radius, target } = cameraState;
camera.position.set(
target.x + radius * Math.cos(pitch) * Math.sin(yaw),
target.y + radius * Math.sin(pitch),
target.z + radius * Math.cos(pitch) * Math.cos(yaw)
);
camera.lookAt(target);
}
updateCamera();
// Direct, dependency-free camera controls.
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
cameraState.yaw -= dx * 0.006;
cameraState.pitch = THREE.MathUtils.clamp(
cameraState.pitch + dy * 0.005,
0.03,
0.82
);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.008,
6.8,
15
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
cameraState.yaw = 0.58;
cameraState.pitch = 0.25;
cameraState.radius = 10.2;
updateCamera();
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
// ------------------------------------------------------------
// Lighting and stage
// ------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xfff7e7, 0x738994, 2.15));
const keyLight = new THREE.DirectionalLight(0xfff0d6, 3.2);
keyLight.position.set(4.5, 8.5, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -6;
keyLight.shadow.camera.right = 6;
keyLight.shadow.camera.top = 7;
keyLight.shadow.camera.bottom = -3;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 22;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xc9e8ed, 1.25);
fillLight.position.set(-5, 4, -4);
scene.add(fillLight);
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0xe7e0d4,
roughness: 1
});
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(32, 32),
floorMaterial
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.125;
floor.receiveShadow = true;
scene.add(floor);
const stage = new THREE.Mesh(
new THREE.CylinderGeometry(3.45, 3.45, 0.12, 96),
new THREE.MeshStandardMaterial({
color: 0xf6f1e7,
roughness: 0.94
})
);
stage.position.set(0.35, -0.06, 0);
stage.receiveShadow = true;
scene.add(stage);
const grid = new THREE.GridHelper(7, 28, 0x8ea0a0, 0xaeb9b5);
grid.position.set(0.35, 0.003, 0);
grid.material.transparent = true;
grid.material.opacity = 0.16;
scene.add(grid);
// ------------------------------------------------------------
// Materials and reusable helpers
// ------------------------------------------------------------
const materials = {
skin: new THREE.MeshStandardMaterial({
color: 0xf0a77e,
roughness: 0.82
}),
shirt: new THREE.MeshStandardMaterial({
color: 0x233b49,
roughness: 0.86
}),
shorts: new THREE.MeshStandardMaterial({
color: 0x168b87,
roughness: 0.84
}),
shoe: new THREE.MeshStandardMaterial({
color: 0xe9674d,
roughness: 0.8
}),
sole: new THREE.MeshStandardMaterial({
color: 0xfff6e8,
roughness: 0.92
}),
hair: new THREE.MeshStandardMaterial({
color: 0x263039,
roughness: 0.94
}),
eye: new THREE.MeshStandardMaterial({
color: 0x182126,
roughness: 0.6
}),
badge: new THREE.MeshStandardMaterial({
color: 0xf6c85f,
roughness: 0.8
})
};
function addMesh(geometry, material, parent) {
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeLimb(topRadius, bottomRadius, material, parent) {
return addMesh(
new THREE.CylinderGeometry(
topRadius,
bottomRadius,
1,
12
),
material,
parent
);
}
const UP = new THREE.Vector3(0, 1, 0);
function setSegment(mesh, start, end) {
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
UP,
direction.normalize()
);
mesh.scale.set(1, length, 1);
}
// ------------------------------------------------------------
// Continuous authored trajectory
//
// These values are intentionally art-directed, not measured.
// Position and velocity are matched at the major path joins.
// ------------------------------------------------------------
const DURATION = 4.3;
const READY_END = 0.35;
const CROUCH_END = 0.95;
const LAUNCH_TIME = 1.3;
const LAUNCH_Y = 1.72;
const LAUNCH_VELOCITY = 3.3;
const GRAVITY = 6.0;
const LAND_Y = 1.18;
const FLIGHT_DURATION =
(LAUNCH_VELOCITY +
Math.sqrt(
LAUNCH_VELOCITY * LAUNCH_VELOCITY +
2 * GRAVITY * (LAUNCH_Y - LAND_Y)
)) /
GRAVITY;
const LAND_TIME = LAUNCH_TIME + FLIGHT_DURATION;
const APEX_TIME = LAUNCH_TIME + LAUNCH_VELOCITY / GRAVITY;
const LANDING_VELOCITY =
LAUNCH_VELOCITY - GRAVITY * FLIGHT_DURATION;
const COMPRESSION_DURATION = 0.44;
const COMPRESSION_DECAY = 17;
const COMPRESSION_TIME = LAND_TIME + COMPRESSION_DURATION;
const COMPRESSION_DROP =
Math.abs(LANDING_VELOCITY) /
COMPRESSION_DECAY *
(1 - Math.exp(-COMPRESSION_DECAY * COMPRESSION_DURATION));
const BOTTOM_Y = LAND_Y - COMPRESSION_DROP;
const RECOVERY_END = 3.55;
function hermite(t, t0, y0, m0, t1, y1, m1) {
const duration = t1 - t0;
const u = THREE.MathUtils.clamp((t - t0) / duration, 0, 1);
const u2 = u * u;
const u3 = u2 * u;
const h00 = 2 * u3 - 3 * u2 + 1;
const h10 = u3 - 2 * u2 + u;
const h01 = -2 * u3 + 3 * u2;
const h11 = u3 - u2;
return (
h00 * y0 +
h10 * duration * m0 +
h01 * y1 +
h11 * duration * m1
);
}
function rootHeight(time) {
if (time <= READY_END) {
return 1.45;
}
if (time <= CROUCH_END) {
return hermite(
time,
READY_END,
1.45,
0,
CROUCH_END,
1.08,
0
);
}
if (time <= LAUNCH_TIME) {
return hermite(
time,
CROUCH_END,
1.08,
0,
LAUNCH_TIME,
LAUNCH_Y,
LAUNCH_VELOCITY
);
}
if (time <= LAND_TIME) {
const u = time - LAUNCH_TIME;
return (
LAUNCH_Y +
LAUNCH_VELOCITY * u -
0.5 * GRAVITY * u * u
);
}
if (time <= COMPRESSION_TIME) {
const u = time - LAND_TIME;
return (
LAND_Y +
(LANDING_VELOCITY / COMPRESSION_DECAY) *
(1 - Math.exp(-COMPRESSION_DECAY * u))
);
}
if (time <= RECOVERY_END) {
const bottomVelocity =
LANDING_VELOCITY *
Math.exp(-COMPRESSION_DECAY * COMPRESSION_DURATION);
return hermite(
time,
COMPRESSION_TIME,
BOTTOM_Y,
bottomVelocity,
RECOVERY_END,
1.45,
0
);
}
return 1.45;
}
function smooth01(value) {
const u = THREE.MathUtils.clamp(value, 0, 1);
return u * u * (3 - 2 * u);
}
function rootX(time) {
if (time <= 1) return 0;
if (time < LAND_TIME) {
return (
0.64 *
smooth01((time - 1) / (LAND_TIME - 1))
);
}
return (
0.64 +
0.06 *
smooth01(
(time - LAND_TIME) /
(RECOVERY_END - LAND_TIME)
)
);
}
// ------------------------------------------------------------
// Stylized solid-form character
// ------------------------------------------------------------
const character = new THREE.Group();
scene.add(character);
const upperBody = new THREE.Group();
upperBody.position.y = 0.04;
character.add(upperBody);
const pelvis = addMesh(
new THREE.BoxGeometry(0.6, 0.3, 0.42),
materials.shorts,
character
);
pelvis.position.y = -0.02;
const torso = addMesh(
new THREE.CapsuleGeometry(0.27, 0.3, 6, 14),
materials.shirt,
upperBody
);
torso.position.y = 0.38;
const chestBadge = addMesh(
new THREE.CircleGeometry(0.075, 24),
materials.badge,
upperBody
);
chestBadge.position.set(0.268, 0.43, 0);
chestBadge.rotation.y = Math.PI / 2;
const neck = addMesh(
new THREE.CylinderGeometry(0.085, 0.095, 0.18, 12),
materials.skin,
upperBody
);
neck.position.y = 0.79;
const head = new THREE.Group();
head.position.set(0.025, 0.98, 0);
upperBody.add(head);
addMesh(
new THREE.SphereGeometry(0.235, 20, 16),
materials.skin,
head
);
const hair = addMesh(
new THREE.SphereGeometry(
0.244,
20,
10,
0,
Math.PI * 2,
0,
Math.PI / 2
),
materials.hair,
head
);
hair.position.y = 0.025;
hair.scale.y = 0.86;
const nose = addMesh(
new THREE.SphereGeometry(0.052, 12, 8),
materials.skin,
head
);
nose.position.set(0.224, -0.005, 0);
for (const z of [-0.085, 0.085]) {
const eye = addMesh(
new THREE.SphereGeometry(0.022, 10, 8),
materials.eye,
head
);
eye.position.set(0.215, 0.075, z);
}
const legs = [];
const arms = [];
for (let i = 0; i < 2; i++) {
const z = i === 0 ? 0.145 : -0.145;
const thigh = makeLimb(0.145, 0.13, materials.shorts, character);
const calf = makeLimb(0.12, 0.095, materials.skin, character);
const knee = addMesh(
new THREE.SphereGeometry(0.115, 14, 10),
materials.skin,
character
);
const shoe = addMesh(
new THREE.BoxGeometry(0.4, 0.16, 0.2),
materials.shoe,
character
);
const sole = addMesh(
new THREE.BoxGeometry(0.41, 0.055, 0.21),
materials.sole,
character
);
legs.push({
z,
thigh,
calf,
knee,
shoe,
sole
});
const armZ = i === 0 ? 0.285 : -0.285;
const upperArm = makeLimb(
0.105,
0.09,
materials.shirt,
upperBody
);
const forearm = makeLimb(
0.09,
0.075,
materials.skin,
upperBody
);
const shoulder = addMesh(
new THREE.SphereGeometry(0.115, 14, 10),
materials.shirt,
upperBody
);
const elbow = addMesh(
new THREE.SphereGeometry(0.09, 14, 10),
materials.skin,
upperBody
);
const hand = addMesh(
new THREE.SphereGeometry(0.105, 14, 10),
materials.skin,
upperBody
);
arms.push({
z: armZ,
upperArm,
forearm,
shoulder,
elbow,
hand
});
}
// ------------------------------------------------------------
// Art-directed pose keys
// ------------------------------------------------------------
const poseKeys = [
{
t: 0,
torso: 0,
head: 0,
ankles: [[-0.02, -1.34], [0.08, -1.34]],
elbows: [[-0.04, 0.30], [-0.07, 0.30]],
wrists: [[-0.06, -0.02], [-0.08, -0.02]]
},
{
t: READY_END,
torso: 0,
head: 0,
ankles: [[-0.02, -1.34], [0.08, -1.34]],
elbows: [[-0.04, 0.30], [-0.07, 0.30]],
wrists: [[-0.06, -0.02], [-0.08, -0.02]]
},
{
t: CROUCH_END,
torso: -0.16,
head: 0.035,
ankles: [[0.26, -0.97], [0.35, -0.97]],
elbows: [[-0.25, 0.32], [-0.28, 0.31]],
wrists: [[-0.44, 0.16], [-0.47, 0.15]]
},
{
t: LAUNCH_TIME,
torso: -0.03,
head: -0.025,
ankles: [[0.18, -1.30], [0.08, -1.30]],
elbows: [[0.12, 0.90], [-0.02, 0.90]],
wrists: [[0.16, 1.24], [-0.10, 1.25]]
},
{
t: APEX_TIME,
torso: 0.05,
head: -0.02,
ankles: [[0.32, -0.50], [-0.04, -0.54]],
elbows: [[0.28, 0.88], [-0.16, 0.91]],
wrists: [[0.42, 1.10], [-0.22, 1.24]]
},
{
t: 2.18,
torso: 0.02,
head: 0.01,
ankles: [[0.35, -0.64], [0.12, -0.70]],
elbows: [[0.42, 0.66], [-0.08, 0.80]],
wrists: [[0.58, 0.79], [-0.12, 1.06]]
},
{
t: LAND_TIME,
torso: -0.10,
head: 0.025,
ankles: [[0.24, -1.07], [0.14, -1.07]],
elbows: [[0.40, 0.31], [0.22, 0.30]],
wrists: [[0.65, 0.13], [0.38, 0.10]]
},
{
t: COMPRESSION_TIME,
torso: -0.22,
head: 0.05,
ankles: [[0.30, 0.11 - BOTTOM_Y], [0.20, 0.11 - BOTTOM_Y]],
elbows: [[0.47, 0.20], [0.28, 0.18]],
wrists: [[0.73, -0.02], [0.44, -0.03]]
},
{
t: RECOVERY_END,
torso: 0,
head: 0,
ankles: [[-0.02, -1.34], [0.08, -1.34]],
elbows: [[-0.04, 0.30], [-0.07, 0.30]],
wrists: [[-0.06, -0.02], [-0.08, -0.02]]
},
{
t: DURATION,
torso: 0,
head: 0,
ankles: [[-0.02, -1.34], [0.08, -1.34]],
elbows: [[-0.04, 0.30], [-0.07, 0.30]],
wrists: [[-0.06, -0.02], [-0.08, -0.02]]
}
];
function mixPose(a, b, u) {
const mix = (x, y) => THREE.MathUtils.lerp(x, y, u);
const mixPair = (x, y) => [
mix(x[0], y[0]),
mix(x[1], y[1])
];
return {
torso: mix(a.torso, b.torso),
head: mix(a.head, b.head),
ankles: [
mixPair(a.ankles[0], b.ankles[0]),
mixPair(a.ankles[1], b.ankles[1])
],
elbows: [
mixPair(a.elbows[0], b.elbows[0]),
mixPair(a.elbows[1], b.elbows[1])
],
wrists: [
mixPair(a.wrists[0], b.wrists[0]),
mixPair(a.wrists[1], b.wrists[1])
]
};
}
function samplePose(time) {
if (time <= poseKeys[0].t) return poseKeys[0];
if (time >= poseKeys.at(-1).t) return poseKeys.at(-1);
for (let i = 0; i < poseKeys.length - 1; i++) {
const a = poseKeys[i];
const b = poseKeys[i + 1];
if (time <= b.t) {
const u = smooth01((time - a.t) / (b.t - a.t));
return mixPose(a, b, u);
}
}
return poseKeys.at(-1);
}
// Analytic two-bone knee solve.
function solveKnee(hip, ankle, upperLength = 0.7, lowerLength = 0.69) {
const delta = new THREE.Vector3().subVectors(ankle, hip);
let distance = delta.length();
const maxDistance = upperLength + lowerLength - 0.001;
if (distance > maxDistance) {
delta.multiplyScalar(maxDistance / distance);
distance = maxDistance;
}
const direction = delta.clone().normalize();
const along =
(upperLength * upperLength -
lowerLength * lowerLength +
distance * distance) /
(2 * distance);
const height = Math.sqrt(
Math.max(
0,
upperLength * upperLength - along * along
)
);
const perpendicular = new THREE.Vector3(
-direction.y,
direction.x,
0
);
return hip
.clone()
.addScaledVector(direction, along)
.addScaledVector(perpendicular, height);
}
function applyAnimation(time) {
const pose = samplePose(time);
const rootY = rootHeight(time);
character.position.set(rootX(time), rootY, 0);
upperBody.rotation.z = pose.torso;
head.rotation.z = pose.head;
for (let i = 0; i < 2; i++) {
const leg = legs[i];
const ankleY = pose.ankles[i][1];
const hip = new THREE.Vector3(
0,
-0.1,
leg.z
);
const ankle = new THREE.Vector3(
pose.ankles[i][0],
ankleY,
leg.z
);
const knee = solveKnee(hip, ankle);
setSegment(leg.thigh, hip, knee);
setSegment(leg.calf, knee, ankle);
leg.knee.position.copy(knee);
leg.shoe.position.set(
ankle.x + 0.105,
ankle.y - 0.03,
leg.z
);
leg.sole.position.set(
ankle.x + 0.105,
ankle.y - 0.087,
leg.z
);
const arm = arms[i];
const shoulder = new THREE.Vector3(
0.015,
0.68,
arm.z
);
const elbow = new THREE.Vector3(
pose.elbows[i][0],
pose.elbows[i][1],
arm.z
);
const wrist = new THREE.Vector3(
pose.wrists[i][0],
pose.wrists[i][1],
arm.z
);
setSegment(arm.upperArm, shoulder, elbow);
setSegment(arm.forearm, elbow, wrist);
arm.shoulder.position.copy(shoulder);
arm.elbow.position.copy(elbow);
arm.hand.position.copy(wrist);
}
}
// ------------------------------------------------------------
// Authored trajectory guide and landing markers
// ------------------------------------------------------------
const trajectoryPoints = [];
for (let i = 0; i <= 140; i++) {
const time = THREE.MathUtils.lerp(
LAUNCH_TIME,
LAND_TIME,
i / 140
);
trajectoryPoints.push(
new THREE.Vector3(
rootX(time),
rootHeight(time),
0.035
)
);
}
const trajectoryLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(trajectoryPoints),
new THREE.LineDashedMaterial({
color: 0x159a9a,
dashSize: 0.1,
gapSize: 0.075,
transparent: true,
opacity: 0.65,
depthWrite: false
})
);
trajectoryLine.computeLineDistances();
scene.add(trajectoryLine);
const launchMarker = new THREE.Mesh(
new THREE.SphereGeometry(0.055, 14, 10),
new THREE.MeshBasicMaterial({ color: 0x159a9a })
);
launchMarker.position.set(
rootX(LAUNCH_TIME),
rootHeight(LAUNCH_TIME),
0.035
);
scene.add(launchMarker);
const apexMarker = new THREE.Mesh(
new THREE.OctahedronGeometry(0.07),
new THREE.MeshBasicMaterial({ color: 0xf6c85f })
);
apexMarker.position.set(
rootX(APEX_TIME),
rootHeight(APEX_TIME),
0.035
);
apexMarker.rotation.z = Math.PI / 4;
scene.add(apexMarker);
const landingRing = new THREE.Mesh(
new THREE.RingGeometry(0.25, 0.32, 48),
new THREE.MeshBasicMaterial({
color: 0xe9674d,
side: THREE.DoubleSide
})
);
landingRing.rotation.x = -Math.PI / 2;
landingRing.position.set(
rootX(LAND_TIME),
0.008,
0
);
scene.add(landingRing);
// ------------------------------------------------------------
// UI and playback
// ------------------------------------------------------------
const timelineInput = document.getElementById("timeline");
const playButton = document.getElementById("play");
const replayButton = document.getElementById("replay");
const speedButton = document.getElementById("speed");
const phaseName = document.getElementById("phase-name");
const phaseCopy = document.getElementById("phase-copy");
const timeReadout = document.getElementById("time-readout");
let animationTime = 0;
let playing = true;
let playbackSpeed = 1;
const phases = [
{
end: READY_END,
name: "Ready",
copy: "The character holds a neutral starting pose."
},
{
end: CROUCH_END,
name: "Anticipation",
copy: "A short, deliberately oversized crouch loads the pose."
},
{
end: LAUNCH_TIME,
name: "Takeoff / extension",
copy: "Legs extend and the arms counter-swing into the launch."
},
{
end: LAND_TIME,
name: "Flight",
copy: "One continuous authored arc; the pelvis path is shown dashed."
},
{
end: COMPRESSION_TIME,
name: "Landing / compression",
copy: "Contact resolves into a deep, visibly exaggerated compression."
},
{
end: RECOVERY_END,
name: "Recovery",
copy: "The body pushes back to the original standing height."
},
{
end: DURATION,
name: "Settle",
copy: "The motion settles at the same pose used at the beginning."
}
];
function phaseFor(time) {
for (const phase of phases) {
if (time < phase.end) return phase;
}
return phases.at(-1);
}
function updateUI() {
const phase = phaseFor(animationTime);
phaseName.textContent = phase.name;
phaseCopy.textContent = phase.copy;
timeReadout.textContent =
`${animationTime.toFixed(2)} / ${DURATION.toFixed(2)} s`;
timelineInput.value = animationTime;
document.documentElement.style.setProperty(
"--progress",
`${(animationTime / DURATION) * 100}%`
);
if (playing) {
playButton.textContent = "Pause";
} else if (animationTime >= DURATION - 0.001) {
playButton.textContent = "Replay";
} else {
playButton.textContent = "Play";
}
}
playButton.addEventListener("click", () => {
if (animationTime >= DURATION - 0.001) {
animationTime = 0;
playing = true;
} else {
playing = !playing;
}
});
replayButton.addEventListener("click", () => {
animationTime = 0;
playing = true;
});
speedButton.addEventListener("click", () => {
playbackSpeed = playbackSpeed === 1 ? 0.5 : 1;
speedButton.textContent = `${playbackSpeed}×`;
});
timelineInput.addEventListener("input", () => {
animationTime = Number(timelineInput.value);
playing = false;
});
let previousTime = performance.now();
renderer.setAnimationLoop((now) => {
const delta = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
if (playing) {
animationTime = Math.min(
DURATION,
animationTime + delta * playbackSpeed
);
if (animationTime >= DURATION) {
playing = false;
}
}
applyAnimation(animationTime);
updateUI();
renderer.render(scene, camera);
});
</script>
</body>
</html>
```