Prompt specification
Build or customize the Three.js 3D scene "Small Skate Park Motion Study" 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: Small Skate Park Motion Study
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/small-skate-park-motion-study-x3655
Scene Description Prompt:
Please use Three.js from cdnjs for a voxel scene based on this idea: small skate park motion study. Build an original compact park with one gentle ramp and a scripted rider. Show anticipation and landing compression without claiming realistic stunt physics or training advice. Return one self-contained HTML file.
Working Three.js Starter (small-skate-park-motion-study-x3655):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Park — Motion Study 01</title>
<style>
:root {
color-scheme: dark;
--ink: #f4f0e8;
--muted: #b9c5cb;
--panel: rgba(18, 29, 43, 0.84);
--line: rgba(255, 255, 255, 0.14);
--coral: #ff765d;
--teal: #58d4c4;
--amber: #f3c969;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c8d5d5;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene canvas.dragging {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.brand {
position: absolute;
top: 22px;
left: 24px;
max-width: min(380px, calc(100vw - 48px));
padding: 15px 17px 14px;
color: var(--ink);
background: var(--panel);
border: 1px solid var(--line);
border-radius: 4px;
box-shadow: 0 14px 40px rgba(15, 25, 35, 0.18);
backdrop-filter: blur(12px);
}
.eyebrow {
margin-bottom: 7px;
color: var(--teal);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(18px, 2.2vw, 27px);
line-height: 1.05;
letter-spacing: -0.035em;
}
.subtitle {
margin-top: 8px;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.phase-card {
position: absolute;
top: 22px;
right: 24px;
min-width: 190px;
padding: 14px 16px;
color: var(--ink);
background: var(--panel);
border: 1px solid var(--line);
border-radius: 4px;
box-shadow: 0 14px 40px rgba(15, 25, 35, 0.18);
backdrop-filter: blur(12px);
}
.phase-label {
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
#phase-name {
display: flex;
align-items: center;
gap: 9px;
margin-top: 8px;
font-size: 15px;
font-weight: 750;
}
#phase-dot {
width: 9px;
height: 9px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 4px rgba(88, 212, 196, 0.12);
}
.controls {
position: absolute;
left: 24px;
right: 24px;
bottom: 22px;
display: grid;
grid-template-columns: auto minmax(180px, 1fr) auto;
align-items: center;
gap: 14px;
padding: 13px 14px;
color: var(--ink);
background: var(--panel);
border: 1px solid var(--line);
border-radius: 4px;
box-shadow: 0 14px 40px rgba(15, 25, 35, 0.2);
backdrop-filter: blur(12px);
pointer-events: auto;
}
button {
min-height: 36px;
padding: 0 13px;
color: var(--ink);
background: rgba(255, 255, 255, 0.07);
border: 1px solid rgba(255, 255, 255, 0.16);
border-radius: 3px;
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
}
button:hover {
background: rgba(255, 255, 255, 0.12);
}
button:focus-visible,
input:focus-visible {
outline: 2px solid var(--teal);
outline-offset: 3px;
}
#play {
width: 42px;
padding: 0;
color: #102031;
background: var(--teal);
border-color: var(--teal);
}
#timeline {
width: 100%;
accent-color: var(--coral);
cursor: pointer;
}
.time-readout {
min-width: 82px;
color: var(--muted);
font-size: 11px;
font-variant-numeric: tabular-nums;
text-align: right;
}
.note {
position: absolute;
right: 24px;
bottom: 88px;
max-width: 260px;
color: rgba(20, 35, 48, 0.74);
font-size: 10px;
font-weight: 650;
line-height: 1.4;
text-align: right;
}
.annotation {
position: absolute;
padding: 6px 8px;
color: #132234;
background: rgba(248, 244, 233, 0.92);
border-left: 3px solid var(--coral);
border-radius: 2px;
box-shadow: 0 6px 18px rgba(20, 30, 40, 0.14);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
transform: translate(-50%, -100%);
transition: opacity 180ms ease;
white-space: nowrap;
}
.annotation::after {
content: "";
position: absolute;
top: 100%;
left: 10px;
width: 1px;
height: 21px;
background: currentColor;
opacity: 0.55;
}
#annotation-landing {
border-left-color: var(--teal);
}
@media (max-width: 700px) {
.brand {
top: 12px;
left: 12px;
padding: 12px 13px;
}
.subtitle {
display: none;
}
.phase-card {
top: 12px;
right: 12px;
min-width: 145px;
padding: 11px 12px;
}
.controls {
left: 12px;
right: 12px;
bottom: 12px;
grid-template-columns: auto 1fr;
gap: 10px;
}
#reset-camera,
.time-readout {
display: none;
}
.note {
right: 12px;
bottom: 78px;
max-width: 220px;
font-size: 9px;
}
.annotation {
font-size: 8px;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Animated voxel skate park"></div>
<div class="hud">
<header class="brand">
<div class="eyebrow">Motion Study 01</div>
<h1>Small Park, One Ramp</h1>
<div class="subtitle">
A compact voxel diorama with a scripted roll-in, anticipation, brief float,
and visible landing compression.
</div>
</header>
<section class="phase-card" aria-live="polite">
<div class="phase-label">Current movement</div>
<div id="phase-name">
<span id="phase-dot"></span>
<span id="phase-text">Roll-in</span>
</div>
</section>
<div id="annotation-anticipation" class="annotation">01 / Anticipation</div>
<div id="annotation-landing" class="annotation">02 / Landing compression</div>
<div class="note">
Abstract pose animation only — not a stunt-physics simulation or training advice.
</div>
<footer class="controls">
<button id="play" type="button" aria-label="Pause animation">Ⅱ</button>
<input
id="timeline"
type="range"
min="0"
max="12"
step="0.01"
value="0"
aria-label="Animation timeline"
/>
<div class="time-readout"><span id="current-time">0.00</span> / 12.00 s</div>
<button id="reset-camera" type="button">Reset view</button>
</footer>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.querySelector("#scene");
const timeline = document.querySelector("#timeline");
const playButton = document.querySelector("#play");
const resetCameraButton = document.querySelector("#reset-camera");
const phaseText = document.querySelector("#phase-text");
const phaseDot = document.querySelector("#phase-dot");
const currentTime = document.querySelector("#current-time");
const anticipationAnnotation = document.querySelector("#annotation-anticipation");
const landingAnnotation = document.querySelector("#annotation-landing");
const DURATION = 12;
const GROUND_Y = 0.05;
const RAMP_X0 = -5.5;
const RAMP_X1 = -0.7;
const RAMP_LENGTH = RAMP_X1 - RAMP_X0;
const RAMP_HEIGHT = 1.15;
const RAMP_SLOPE = RAMP_HEIGHT / RAMP_LENGTH;
const LAND_X = 5.5;
const OUT_X = 10.4;
const START_X = -10.5;
const renderer = new THREE.WebGLRenderer({ antialias: true });
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.12;
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc8d5d5);
scene.fog = new THREE.Fog(0xc8d5d5, 24, 46);
const camera = new THREE.OrthographicCamera(-15, 15, 8, -8, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 0.35, 0);
let cameraYaw = 0.62;
let cameraPitch = 0.62;
let cameraZoom = 0.96;
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
function updateCamera() {
const aspect = window.innerWidth / window.innerHeight;
const viewHeight = Math.max(13, 28 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.zoom = cameraZoom;
camera.updateProjectionMatrix();
const radius = 23;
camera.position.set(
cameraTarget.x + Math.sin(cameraYaw) * Math.cos(cameraPitch) * radius,
cameraTarget.y + Math.sin(cameraPitch) * radius,
cameraTarget.z + Math.cos(cameraYaw) * Math.cos(cameraPitch) * radius
);
camera.lookAt(cameraTarget);
camera.updateMatrixWorld();
}
function resetCamera() {
cameraYaw = 0.62;
cameraPitch = 0.62;
cameraZoom = 0.96;
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.classList.add("dragging");
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
cameraYaw -= dx * 0.006;
cameraPitch = THREE.MathUtils.clamp(cameraPitch + dy * 0.004, 0.34, 1.12);
updateCamera();
});
function endDrag(event) {
dragging = false;
renderer.domElement.classList.remove("dragging");
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();
cameraZoom = THREE.MathUtils.clamp(
cameraZoom * Math.exp(-event.deltaY * 0.001),
0.65,
1.7
);
updateCamera();
},
{ passive: false }
);
resetCameraButton.addEventListener("click", resetCamera);
const hemisphere = new THREE.HemisphereLight(0xeaf6f3, 0x33465a, 2.25);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffe8c6, 3.25);
keyLight.position.set(-9, 15, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -17;
keyLight.shadow.camera.right = 17;
keyLight.shadow.camera.top = 14;
keyLight.shadow.camera.bottom = -14;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 40;
keyLight.shadow.bias = -0.0004;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x8de2d7, 1.05);
rimLight.position.set(10, 7, -10);
scene.add(rimLight);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const matrixDummy = new THREE.Object3D();
const zAxis = new THREE.Vector3(0, 0, 1);
const identityQuaternion = new THREE.Quaternion();
function seededRandom(seed) {
let value = seed >>> 0;
return () => {
value += 0x6d2b79f5;
let result = value;
result = Math.imul(result ^ (result >>> 15), result | 1);
result ^= result + Math.imul(result ^ (result >>> 7), result | 61);
return ((result ^ (result >>> 14)) >>> 0) / 4294967296;
};
}
const random = seededRandom(8041);
function addBox(parent, size, position, material, rotation = null) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(size.x, size.y, size.z);
mesh.position.copy(position);
if (rotation) mesh.rotation.set(rotation.x, rotation.y, rotation.z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// Raised diorama base.
const baseMaterial = new THREE.MeshStandardMaterial({
color: 0x223047,
roughness: 0.82,
metalness: 0.04
});
addBox(
scene,
new THREE.Vector3(25.4, 0.58, 13.4),
new THREE.Vector3(0, -0.29, 0),
baseMaterial
);
const lowerBandMaterial = new THREE.MeshStandardMaterial({
color: 0x172236,
roughness: 0.9
});
addBox(
scene,
new THREE.Vector3(25.55, 0.16, 13.55),
new THREE.Vector3(0, -0.51, 0),
lowerBandMaterial
);
// A tiled ground surface gives the park its voxel language.
const tileCountX = 25;
const tileCountZ = 13;
const tileGeometry = new THREE.BoxGeometry(0.965, 0.1, 0.965);
const tileMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.88,
metalness: 0.015
});
const groundTiles = new THREE.InstancedMesh(
tileGeometry,
tileMaterial,
tileCountX * tileCountZ
);
groundTiles.receiveShadow = true;
const tilePalette = [0x82969b, 0x8b9da0, 0x789097, 0x92a2a2, 0x83999c];
let tileIndex = 0;
for (let ix = 0; ix < tileCountX; ix++) {
for (let iz = 0; iz < tileCountZ; iz++) {
const x = ix - (tileCountX - 1) / 2;
const z = iz - (tileCountZ - 1) / 2;
matrixDummy.position.set(x, 0, z);
matrixDummy.quaternion.copy(identityQuaternion);
matrixDummy.scale.set(1, 1, 1);
matrixDummy.updateMatrix();
groundTiles.setMatrixAt(tileIndex, matrixDummy.matrix);
let color = tilePalette[Math.floor(random() * tilePalette.length)];
const colorObject = new THREE.Color(color);
if (x < -5.5 && Math.abs(z) < 0.55) {
colorObject.lerp(new THREE.Color(0xe6bd70), 0.48);
}
if (x > 4.7 && x < 8.5 && Math.abs(z) < 0.7) {
colorObject.lerp(
new THREE.Color((ix + iz) % 2 ? 0x65b8ae : 0xa9c6bd),
0.52
);
}
if (x > 8 && z > 3) {
colorObject.lerp(new THREE.Color(0xd8836e), 0.32);
}
groundTiles.setColorAt(tileIndex, colorObject);
tileIndex++;
}
}
groundTiles.instanceMatrix.needsUpdate = true;
groundTiles.instanceColor.needsUpdate = true;
scene.add(groundTiles);
// Segmented voxel curb around the platform.
const curbMaterial = new THREE.MeshStandardMaterial({
color: 0xe0d9c7,
roughness: 0.8
});
const curbMatrices = [];
for (let x = -12; x <= 12; x++) {
curbMatrices.push({
position: new THREE.Vector3(x, 0.21, -6.32),
scale: new THREE.Vector3(0.94, 0.42, 0.25)
});
curbMatrices.push({
position: new THREE.Vector3(x, 0.21, 6.32),
scale: new THREE.Vector3(0.94, 0.42, 0.25)
});
}
for (let z = -5; z <= 5; z++) {
curbMatrices.push({
position: new THREE.Vector3(-12.32, 0.21, z),
scale: new THREE.Vector3(0.25, 0.42, 0.94)
});
curbMatrices.push({
position: new THREE.Vector3(12.32, 0.21, z),
scale: new THREE.Vector3(0.25, 0.42, 0.94)
});
}
const curbs = new THREE.InstancedMesh(unitBox, curbMaterial, curbMatrices.length);
curbs.castShadow = true;
curbs.receiveShadow = true;
curbMatrices.forEach((entry, index) => {
matrixDummy.position.copy(entry.position);
matrixDummy.quaternion.copy(identityQuaternion);
matrixDummy.scale.copy(entry.scale);
matrixDummy.updateMatrix();
curbs.setMatrixAt(index, matrixDummy.matrix);
});
scene.add(curbs);
// One gentle ramp: voxel masonry underneath with a segmented riding surface.
const rampSupports = [];
const supportRows = 5;
const supportDepthRows = 6;
const supportStep = RAMP_LENGTH / 18;
for (let column = 0; column < 18; column++) {
const x = RAMP_X0 + (column + 0.5) * supportStep;
const surface = rampHeightAt(x);
for (let row = 0; row < supportRows; row++) {
for (let depth = 0; depth < supportDepthRows; depth++) {
rampSupports.push({
x,
y: GROUND_Y + (row + 0.5) * 0.225,
z: -2.2 + (depth + 0.5) * 0.733,
shade: random()
});
}
}
}
const supportMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.92
});
const supports = new THREE.InstancedMesh(
unitBox,
supportMaterial,
rampSupports.length
);
supports.castShadow = true;
supports.receiveShadow = true;
rampSupports.forEach((entry, index) => {
matrixDummy.position.set(entry.x, entry.y, entry.z);
matrixDummy.quaternion.copy(identityQuaternion);
matrixDummy.scale.set(supportStep * 0.98, 0.22, 0.7);
matrixDummy.updateMatrix();
supports.setMatrixAt(index, matrixDummy.matrix);
supports.setColorAt(
index,
new THREE.Color(0xb58e69).lerp(new THREE.Color(0xd0ad82), entry.shade * 0.55)
);
});
supports.instanceMatrix.needsUpdate = true;
supports.instanceColor.needsUpdate = true;
scene.add(supports);
const rampSegments = 18;
const rampWidthRows = 6;
const rampDeckMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.68,
metalness: 0.025
});
const rampDeck = new THREE.InstancedMesh(
unitBox,
rampDeckMaterial,
rampSegments * rampWidthRows
);
rampDeck.castShadow = true;
rampDeck.receiveShadow = true;
let deckIndex = 0;
const segmentLength = RAMP_LENGTH / rampSegments;
const segmentRise = RAMP_HEIGHT / rampSegments;
const segmentAngle = Math.atan2(segmentRise, segmentLength);
const segmentSpan = Math.hypot(segmentLength, segmentRise);
for (let segment = 0; segment < rampSegments; segment++) {
const x = RAMP_X0 + (segment + 0.5) * segmentLength;
const y = rampHeightAt(x);
for (let depth = 0; depth < rampWidthRows; depth++) {
matrixDummy.position.set(x, y - 0.058, -2.2 + (depth + 0.5) * 0.733);
matrixDummy.quaternion.setFromAxisAngle(zAxis, segmentAngle);
matrixDummy.scale.set(segmentSpan + 0.018, 0.12, 0.705);
matrixDummy.updateMatrix();
rampDeck.setMatrixAt(deckIndex, matrixDummy.matrix);
const edge = depth === 0 || depth === rampWidthRows - 1;
const baseColor = edge ? 0xd9785f : 0xc7a77f;
const shade = ((segment + depth) % 3) * 0.045;
rampDeck.setColorAt(
deckIndex,
new THREE.Color(baseColor).offsetHSL(0, 0, shade)
);
deckIndex++;
}
}
rampDeck.instanceMatrix.needsUpdate = true;
rampDeck.instanceColor.needsUpdate = true;
scene.add(rampDeck);
// Small inlaid markers suggest the motion path without becoming obstacles.
const markerMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.8
});
const markerData = [];
for (let x = -10; x <= -6.2; x += 0.9) {
markerData.push({ x, z: 0.66, color: 0xf0c66b });
}
for (let x = 6.8; x <= 9.8; x += 0.9) {
markerData.push({ x, z: -0.66, color: 0x56b9ad });
}
const markers = new THREE.InstancedMesh(unitBox, markerMaterial, markerData.length);
markerData.forEach((entry, index) => {
matrixDummy.position.set(entry.x, GROUND_Y + 0.025, entry.z);
matrixDummy.quaternion.copy(identityQuaternion);
matrixDummy.scale.set(0.44, 0.025, 0.1);
matrixDummy.updateMatrix();
markers.setMatrixAt(index, matrixDummy.matrix);
markers.setColorAt(index, new THREE.Color(entry.color));
});
scene.add(markers);
// A block bench, planters, and cubic trees keep the park compact but inhabited.
const benchWood = new THREE.MeshStandardMaterial({ color: 0x9a7054, roughness: 0.84 });
const benchFrame = new THREE.MeshStandardMaterial({ color: 0x26374a, roughness: 0.78 });
const bench = new THREE.Group();
bench.position.set(3.3, 0, -4.55);
for (let x = -1; x <= 1; x++) {
addBox(
bench,
new THREE.Vector3(0.92, 0.22, 0.72),
new THREE.Vector3(x, 0.68, 0),
benchWood
);
}
addBox(bench, new THREE.Vector3(2.8, 0.18, 0.18), new THREE.Vector3(0, 0.43, 0), benchFrame);
addBox(bench, new THREE.Vector3(0.18, 0.62, 0.58), new THREE.Vector3(-1.05, 0.3, 0), benchFrame);
addBox(bench, new THREE.Vector3(0.18, 0.62, 0.58), new THREE.Vector3(1.05, 0.3, 0), benchFrame);
scene.add(bench);
const planterMaterial = new THREE.MeshStandardMaterial({ color: 0x526975, roughness: 0.88 });
const soilMaterial = new THREE.MeshStandardMaterial({ color: 0x293c38, roughness: 1 });
const trunkMaterial = new THREE.MeshStandardMaterial({ color: 0x8c6247, roughness: 0.95 });
const foliageMaterial = new THREE.MeshStandardMaterial({ color: 0x527e69, roughness: 0.93 });
function createPlanter(x, z, variant = 0) {
const group = new THREE.Group();
group.position.set(x, GROUND_Y, z);
addBox(group, new THREE.Vector3(1.25, 0.65, 1.25), new THREE.Vector3(0, 0.325, 0), planterMaterial);
addBox(group, new THREE.Vector3(0.92, 0.06, 0.92), new THREE.Vector3(0, 0.67, 0), soilMaterial);
addBox(group, new THREE.Vector3(0.24, 1.1, 0.24), new THREE.Vector3(0, 1.2, 0), trunkMaterial);
const foliage = new THREE.Group();
foliage.position.y = 1.95 + variant * 0.12;
addBox(foliage, new THREE.Vector3(1.2, 0.72, 1.05), new THREE.Vector3(0, 0, 0), foliageMaterial);
addBox(foliage, new THREE.Vector3(0.75, 0.68, 1.2), new THREE.Vector3(-0.35, 0.45, 0.05), foliageMaterial);
addBox(foliage, new THREE.Vector3(0.8, 0.6, 0.75), new THREE.Vector3(0.36, 0.4, -0.3), foliageMaterial);
group.add(foliage);
scene.add(group);
}
createPlanter(-9.3, 4.55, 0);
createPlanter(9.0, -4.7, 1);
createPlanter(-9.5, -4.65, 2);
// A small physical sign, drawn locally so the page needs no image assets.
const signCanvas = document.createElement("canvas");
signCanvas.width = 512;
signCanvas.height = 256;
const signContext = signCanvas.getContext("2d");
signContext.fillStyle = "#17283c";
signContext.fillRect(0, 0, 512, 256);
signContext.strokeStyle = "#68d5c5";
signContext.lineWidth = 12;
signContext.strokeRect(16, 16, 480, 224);
signContext.fillStyle = "#f4efe4";
signContext.font = "800 56px system-ui, sans-serif";
signContext.fillText("MOTION", 42, 102);
signContext.fillStyle = "#f3c969";
signContext.font = "800 82px system-ui, sans-serif";
signContext.fillText("01", 42, 194);
signContext.fillStyle = "#b9c9cd";
signContext.font = "600 22px system-ui, sans-serif";
signContext.fillText("SMALL PARK STUDY", 190, 185);
const signTexture = new THREE.CanvasTexture(signCanvas);
signTexture.colorSpace = THREE.SRGBColorSpace;
const signMaterial = new THREE.MeshBasicMaterial({ map: signTexture });
const sign = new THREE.Group();
sign.position.set(-7.7, 0, 4.65);
addBox(sign, new THREE.Vector3(0.16, 1.55, 0.16), new THREE.Vector3(-0.75, 0.78, 0), benchFrame);
addBox(sign, new THREE.Vector3(0.16, 1.55, 0.16), new THREE.Vector3(0.75, 0.78, 0), benchFrame);
const signFace = new THREE.Mesh(new THREE.PlaneGeometry(2.05, 1.025), signMaterial);
signFace.position.set(0, 1.58, 0.01);
sign.add(signFace);
scene.add(sign);
// Rider and board.
const fadeMaterials = [];
function riderMaterial(color, roughness = 0.72) {
const material = new THREE.MeshStandardMaterial({
color,
roughness,
metalness: 0.015,
transparent: true,
opacity: 1
});
fadeMaterials.push(material);
return material;
}
const boardGroup = new THREE.Group();
scene.add(boardGroup);
const deckMaterial = riderMaterial(0x315a72, 0.62);
const gripMaterial = riderMaterial(0x172536, 0.96);
const wheelMaterial = riderMaterial(0xf3c969, 0.58);
const truckMaterial = riderMaterial(0xb8c2bd, 0.48);
const jacketMaterial = riderMaterial(0xff765d, 0.76);
const pantsMaterial = riderMaterial(0x26364e, 0.84);
const shoeMaterial = riderMaterial(0xf0eadb, 0.9);
const helmetMaterial = riderMaterial(0xece2cb, 0.66);
const visorMaterial = riderMaterial(0x1d2a3b, 0.7);
const skinMaterial = riderMaterial(0xc88f68, 0.86);
addBox(
boardGroup,
new THREE.Vector3(1.38, 0.105, 0.38),
new THREE.Vector3(0, 0.205, 0),
deckMaterial
);
addBox(
boardGroup,
new THREE.Vector3(1.28, 0.018, 0.31),
new THREE.Vector3(0, 0.267, 0),
gripMaterial
);
addBox(
boardGroup,
new THREE.Vector3(0.34, 0.035, 0.395),
new THREE.Vector3(0.1, 0.285, 0),
jacketMaterial
);
const wheelSpinGroups = [];
for (const x of [-0.46, 0.46]) {
addBox(
boardGroup,
new THREE.Vector3(0.16, 0.08, 0.45),
new THREE.Vector3(x, 0.13, 0),
truckMaterial
);
for (const z of [-0.235, 0.235]) {
const wheelGroup = new THREE.Group();
wheelGroup.position.set(x, 0.098, z);
wheelGroup.rotation.x = Math.PI / 2;
const wheel = new THREE.Mesh(
new THREE.CylinderGeometry(0.098, 0.098, 0.075, 12),
wheelMaterial
);
wheel.castShadow = true;
wheelGroup.add(wheel);
boardGroup.add(wheelGroup);
wheelSpinGroups.push(wheel);
}
}
const rider = new THREE.Group();
rider.position.y = 0.25;
boardGroup.add(rider);
// Feet are separated along the board to create a readable side-on stance.
addBox(
rider,
new THREE.Vector3(0.31, 0.11, 0.19),
new THREE.Vector3(0.31, 0.055, 0.12),
shoeMaterial
);
addBox(
rider,
new THREE.Vector3(0.31, 0.11, 0.19),
new THREE.Vector3(-0.29, 0.055, -0.12),
shoeMaterial
);
addBox(
rider,
new THREE.Vector3(0.18, 0.58, 0.18),
new THREE.Vector3(0.29, 0.37, 0.12),
pantsMaterial,
new THREE.Vector3(0, 0, -0.04)
);
addBox(
rider,
new THREE.Vector3(0.18, 0.58, 0.18),
new THREE.Vector3(-0.27, 0.37, -0.12),
pantsMaterial,
new THREE.Vector3(0, 0, 0.045)
);
const upperBody = new THREE.Group();
upperBody.position.y = 0.64;
rider.add(upperBody);
addBox(
upperBody,
new THREE.Vector3(0.39, 0.24, 0.34),
new THREE.Vector3(0, 0.02, 0),
pantsMaterial
);
addBox(
upperBody,
new THREE.Vector3(0.48, 0.59, 0.34),
new THREE.Vector3(0.055, 0.39, 0),
jacketMaterial,
new THREE.Vector3(0, 0, 0.035)
);
addBox(
upperBody,
new THREE.Vector3(0.28, 0.19, 0.36),
new THREE.Vector3(0.12, 0.79, 0),
skinMaterial
);
addBox(
upperBody,
new THREE.Vector3(0.48, 0.39, 0.45),
new THREE.Vector3(0.1, 1.02, 0),
helmetMaterial
);
addBox(
upperBody,
new THREE.Vector3(0.27, 0.065, 0.47),
new THREE.Vector3(0.36, 0.96, 0),
visorMaterial
);
function createArm(z) {
const pivot = new THREE.Group();
pivot.position.set(0.12, 0.61, z);
addBox(
pivot,
new THREE.Vector3(0.15, 0.48, 0.16),
new THREE.Vector3(0, -0.24, 0),
jacketMaterial
);
addBox(
pivot,
new THREE.Vector3(0.16, 0.16, 0.17),
new THREE.Vector3(0, -0.5, 0),
skinMaterial
);
upperBody.add(pivot);
return pivot;
}
const nearArm = createArm(0.245);
const farArm = createArm(-0.245);
// Scripted motion. This is intentionally an authored pose sequence rather than
// a physics solver: the path, board pitch, and body compression are keyframed.
function rampHeightAt(x) {
const u = THREE.MathUtils.clamp((x - RAMP_X0) / RAMP_LENGTH, 0, 1);
return GROUND_Y + RAMP_HEIGHT * u;
}
function smoothstep(min, max, value) {
const x = THREE.MathUtils.clamp((value - min) / (max - min), 0, 1);
return x * x * (3 - 2 * x);
}
function anticipationAmount(t) {
if (t < 2.25) return 0;
if (t < 2.85) return smoothstep(2.25, 2.85, t);
if (t < 3.5) return 1 - smoothstep(2.85, 3.5, t);
return 0;
}
function landingAmount(t) {
if (t < 5.88) return 0;
if (t < 6.08) return smoothstep(5.88, 6.08, t);
if (t < 6.78) return 1 - 0.78 * smoothstep(6.08, 6.78, t);
if (t < 7.1) return 0.22 * (1 - smoothstep(6.78, 7.1, t));
return 0;
}
function phaseForTime(t) {
if (t < 2.55) return { label: "Roll-in", color: "#58d4c4" };
if (t < 3.15) return { label: "Anticipation", color: "#f3c969" };
if (t < 4.65) return { label: "Ramp ascent", color: "#e9a963" };
if (t < 6.05) return { label: "Brief float", color: "#b99ae8" };
if (t < 7.05) return { label: "Landing / compression", color: "#ff765d" };
if (t < 9.6) return { label: "Roll-away", color: "#58d4c4" };
return { label: "Soft reset", color: "#aab8bf" };
}
const flightDistance = LAND_X - RAMP_X1;
const flightStartHeight = GROUND_Y + RAMP_HEIGHT;
const flightQuadratic = -(flightStartHeight - GROUND_Y - RAMP_SLOPE * flightDistance) /
(flightDistance * flightDistance);
function sampleMotion(t) {
let x = START_X;
let y = GROUND_Y;
let angle = 0;
let crouch = 0;
let lean = 0;
if (t < 2.55) {
x = THREE.MathUtils.lerp(START_X, -5.85, t / 2.55);
lean = 0.035;
crouch = anticipationAmount(t);
} else if (t < 3.15) {
x = THREE.MathUtils.lerp(-5.85, RAMP_X0, (t - 2.55) / 0.6);
crouch = anticipationAmount(t);
lean = 0.11 * crouch;
} else if (t < 4.65) {
const u = (t - 3.15) / 1.5;
x = THREE.MathUtils.lerp(RAMP_X0, RAMP_X1, u);
y = rampHeightAt(x);
angle = Math.atan(RAMP_SLOPE);
crouch = anticipationAmount(t) * 0.3;
lean = 0.065;
} else if (t < 6.05) {
const u = (t - 4.65) / 1.4;
const distance = u * flightDistance;
x = RAMP_X1 + distance;
y =
flightStartHeight +
RAMP_SLOPE * distance +
flightQuadratic * distance * distance;
const slope = RAMP_SLOPE + 2 * flightQuadratic * distance;
angle = Math.atan(slope);
lean = 0.14 + Math.sin(u * Math.PI) * 0.08;
} else if (t < 7.05) {
const u = (t - 6.05) / 1.0;
x = THREE.MathUtils.lerp(LAND_X, 6.6, u);
y = GROUND_Y;
const impactAngle = Math.atan(
RAMP_SLOPE + 2 * flightQuadratic * flightDistance
);
angle = THREE.MathUtils.lerp(
impactAngle,
0,
smoothstep(0, 0.34, u)
);
crouch = landingAmount(t);
lean = -0.09 * crouch;
} else if (t < 9.6) {
const u = (t - 7.05) / 2.55;
x = THREE.MathUtils.lerp(6.6, OUT_X, u);
y = GROUND_Y;
angle = 0;
crouch = landingAmount(t);
lean = 0.025;
} else {
x = OUT_X;
y = GROUND_Y;
}
if (t >= 10.4 && t < 11.35) {
x = START_X;
y = GROUND_Y;
angle = 0;
crouch = 0;
lean = 0;
} else if (t >= 11.35) {
x = START_X;
y = GROUND_Y;
angle = 0;
crouch = 0;
lean = 0;
}
return { x, y, angle, crouch, lean };
}
function fadeOpacityAt(t) {
if (t < 9.6) return 1;
if (t < 10.4) return 1 - smoothstep(9.6, 10.4, t);
if (t < 11.35) return 0;
return smoothstep(11.35, DURATION, t);
}
let animationTime = 0;
let playing = true;
function togglePlayback() {
playing = !playing;
playButton.textContent = playing ? "Ⅱ" : "▶";
playButton.setAttribute("aria-label", playing ? "Pause animation" : "Play animation");
}
playButton.addEventListener("click", togglePlayback);
timeline.addEventListener("input", () => {
animationTime = Number(timeline.value);
});
window.addEventListener("keydown", (event) => {
if (event.code === "Space") {
event.preventDefault();
togglePlayback();
}
if (event.key.toLowerCase() === "r") resetCamera();
});
const projected = new THREE.Vector3();
function projectAnnotation(element, worldPosition, opacity) {
projected.copy(worldPosition).project(camera);
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
element.style.opacity = `${opacity}`;
}
const anticipationPoint = new THREE.Vector3(-5.9, 0.42, 0.35);
const landingPoint = new THREE.Vector3(5.65, 0.42, 0.35);
const clock = new THREE.Clock();
let previousPhase = "";
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
if (playing) animationTime = (animationTime + delta) % DURATION;
const motion = sampleMotion(animationTime);
const opacity = fadeOpacityAt(animationTime);
boardGroup.visible = opacity > 0.01;
boardGroup.position.set(motion.x, motion.y, 0);
boardGroup.rotation.z = motion.angle;
rider.scale.y = 1 - motion.crouch * 0.25;
upperBody.position.y = 0.64 - motion.crouch * 0.035;
upperBody.rotation.z = motion.lean;
const armSwing = animationTime >= 4.65 && animationTime < 6.05 ? 0.52 : 0.12;
nearArm.rotation.z = armSwing + motion.crouch * 0.12;
farArm.rotation.z = -armSwing * 0.7 - motion.crouch * 0.08;
for (const wheel of wheelSpinGroups) {
wheel.rotation.y = motion.x / 0.098;
}
for (const material of fadeMaterials) {
material.opacity = opacity;
}
const phase = phaseForTime(animationTime);
if (phase.label !== previousPhase) {
phaseText.textContent = phase.label;
phaseDot.style.background = phase.color;
phaseDot.style.boxShadow = `0 0 0 4px ${phase.color}22`;
previousPhase = phase.label;
}
timeline.value = animationTime.toFixed(2);
currentTime.textContent = animationTime.toFixed(2);
const anticipationOpacity = 0.35 + 0.65 * smoothstep(2.05, 2.55, animationTime) *
(1 - smoothstep(3.25, 3.8, animationTime));
const landingOpacity = 0.35 + 0.65 * smoothstep(5.55, 6.02, animationTime) *
(1 - smoothstep(6.75, 7.3, animationTime));
projectAnnotation(anticipationAnnotation, anticipationPoint, anticipationOpacity);
projectAnnotation(landingAnnotation, landingPoint, landingOpacity);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
window.addEventListener("resize", () => {
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
updateCamera();
});
updateCamera();
animate();
</script>
</body>
</html>
```