Prompt specification
Build or customize the Three.js 3D scene "Superkilen activity-zone urban slice" 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: Superkilen activity-zone urban slice
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/superkilen-activity-zone-urban-slice-x2823
Scene Description Prompt:
Build a standalone HTML scene with Three.js from cdnjs featuring a low-poly Superkilen park slice in Copenhagen, neighboring facades, and everyday activities.
Working Three.js Starter (superkilen-activity-zone-urban-slice-x2823):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Superkilen — A Copenhagen Park Slice</title>
<style>
:root {
color-scheme: light;
--ink: #18302b;
--paper: rgba(255, 255, 255, 0.9);
--accent: #e74432;
--line: rgba(24, 48, 43, 0.14);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c9dce3;
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.title-card {
position: fixed;
top: 24px;
left: 24px;
z-index: 10;
width: min(390px, calc(100vw - 48px));
padding: 20px 22px 18px;
border: 1px solid rgba(255, 255, 255, 0.62);
border-radius: 18px;
background: var(--paper);
box-shadow: 0 14px 40px rgba(25, 45, 41, 0.15);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 7px;
color: #64746e;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--accent);
content: "";
box-shadow: 0 0 0 4px rgba(231, 68, 50, 0.12);
}
h1 {
margin: 0;
color: var(--ink);
font-size: clamp(30px, 4vw, 48px);
font-weight: 850;
letter-spacing: -0.055em;
line-height: 0.95;
}
.subtitle {
max-width: 320px;
margin: 12px 0 0;
color: #50645d;
font-size: 13px;
line-height: 1.55;
}
.coordinates {
margin-top: 13px;
padding-top: 12px;
border-top: 1px solid var(--line);
color: #788782;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.controls {
position: fixed;
right: 22px;
bottom: 22px;
z-index: 20;
display: flex;
gap: 8px;
}
.controls button {
min-height: 42px;
padding: 0 15px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 999px;
background: rgba(255, 255, 255, 0.9);
box-shadow: 0 8px 24px rgba(25, 45, 41, 0.13);
color: var(--ink);
cursor: pointer;
font: inherit;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.07em;
text-transform: uppercase;
transition:
transform 160ms ease,
background 160ms ease;
}
.controls button:hover {
transform: translateY(-2px);
background: white;
}
.controls button:active {
transform: translateY(0);
}
.hint {
position: fixed;
left: 50%;
bottom: 23px;
z-index: 10;
padding: 10px 14px;
border: 1px solid rgba(255, 255, 255, 0.55);
border-radius: 999px;
background: rgba(25, 45, 41, 0.67);
color: rgba(255, 255, 255, 0.92);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.05em;
pointer-events: none;
transform: translateX(-50%);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
white-space: nowrap;
}
@media (max-width: 700px) {
.title-card {
top: 14px;
left: 14px;
width: min(330px, calc(100vw - 28px));
padding: 16px 17px;
}
.subtitle {
max-width: 270px;
font-size: 12px;
}
.coordinates {
display: none;
}
.hint {
display: none;
}
.controls {
right: 14px;
bottom: 14px;
}
}
</style>
</head>
<body>
<header class="title-card">
<div class="eyebrow">Copenhagen · Nørrebro</div>
<h1>Superkilen</h1>
<p class="subtitle">
A small slice of Copenhagen’s urban commons: the red pavilion, playful
landscape, everyday neighbors, bicycles, and street life.
</p>
<div class="coordinates">55.6761° N · 12.5683° E</div>
</header>
<div class="hint">Drag to orbit · Scroll to zoom · R to reset</div>
<div class="controls">
<button id="resetView" type="button">Reset view</button>
<button id="toggleMotion" type="button">Pause life</button>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc9dce3);
scene.fog = new THREE.Fog(0xc9dce3, 43, 88);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
150
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance",
});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
document.body.prepend(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xe8f7ff, 0x65704a, 2.2);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1cf, 3.5);
sun.position.set(-15, 26, 13);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -27;
sun.shadow.camera.right = 27;
sun.shadow.camera.top = 24;
sun.shadow.camera.bottom = -24;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 65;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb8d9ff, 0.65);
fill.position.set(20, 12, -18);
scene.add(fill);
const clock = new THREE.Clock();
const up = new THREE.Vector3(0, 1, 0);
const tmpDirection = new THREE.Vector3();
const tmpMidpoint = new THREE.Vector3();
// -------------------------------------------------------------------------
// Materials and geometry helpers
// -------------------------------------------------------------------------
function material(color, roughness = 0.82, metalness = 0) {
return new THREE.MeshStandardMaterial({
color,
roughness,
metalness,
});
}
const M = {
earth: material(0x8f806b),
grass: material(0x789653),
grassLight: material(0x89a962),
grassDark: material(0x567444),
asphalt: material(0x343b3d),
sidewalk: material(0xb9b4a9),
paving: material(0xc8c1b4),
curb: material(0xd6d0c4),
red: material(0xd94132),
redDark: material(0xa92825),
cream: material(0xf1dfbd),
yellow: material(0xf0b735),
orange: material(0xe77936),
turquoise: material(0x37a6a0),
blue: material(0x397da5),
black: material(0x24292a),
rubber: material(0x34383b),
wood: material(0x9a6943),
woodLight: material(0xb98455),
glass: new THREE.MeshStandardMaterial({
color: 0x506d79,
roughness: 0.26,
metalness: 0.22,
}),
glassLit: new THREE.MeshStandardMaterial({
color: 0xb4c7c6,
emissive: 0x40565b,
emissiveIntensity: 0.2,
roughness: 0.35,
}),
white: material(0xf5f1e7),
leaf: material(0x557b42),
leafLight: material(0x6e934c),
leafDark: material(0x3f6639),
trunk: material(0x765238),
skin: material(0xd99b73),
skinDark: material(0x9d684d),
hair: material(0x392c27),
metal: material(0x657075, 0.42, 0.55),
};
function B(parent, w, h, d, x, y, z, mat) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function Cyl(
parent,
radiusTop,
radiusBottom,
height,
x,
y,
z,
mat,
segments = 10
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function Sphere(parent, radius, x, y, z, mat, widthSegments = 10) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(radius, widthSegments, 7),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function Ico(parent, radius, detail, x, y, z, mat) {
const mesh = new THREE.Mesh(
new THREE.IcosahedronGeometry(radius, detail),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function Rod(parent, a, b, radius, mat, segments = 8) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, segments),
mat
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
up,
direction.clone().normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function updateRod(mesh, a, b) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
tmpDirection.copy(end).sub(start);
const length = tmpDirection.length();
mesh.scale.y = length;
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(up, tmpDirection.normalize());
}
function canvasSign(text, background = "#d94132", foreground = "#fff8e9") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = foreground;
ctx.font = "800 55px Arial, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 67);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
return new THREE.MeshStandardMaterial({
map: texture,
roughness: 0.75,
});
}
// -------------------------------------------------------------------------
// Camera controls, implemented directly without addons
// -------------------------------------------------------------------------
const controls = {
target: new THREE.Vector3(0, 1.4, 0),
yaw: 0.67,
pitch: 0.62,
distance: 38,
minDistance: 21,
maxDistance: 56,
minPitch: 0.23,
maxPitch: 1.36,
};
function updateCamera() {
const horizontal = Math.cos(controls.pitch) * controls.distance;
camera.position.set(
controls.target.x + Math.sin(controls.yaw) * horizontal,
controls.target.y + Math.sin(controls.pitch) * controls.distance,
controls.target.z + Math.cos(controls.yaw) * horizontal
);
camera.lookAt(controls.target);
}
updateCamera();
const pointers = new Map();
let pinchDistance = 0;
let dragging = false;
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY,
});
if (pointers.size === 1) {
dragging = true;
} else if (pointers.size === 2) {
const values = [...pointers.values()];
pinchDistance = Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY,
});
if (pointers.size === 2) {
const values = [...pointers.values()];
const distance = Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
if (pinchDistance > 0) {
controls.distance = THREE.MathUtils.clamp(
controls.distance * (pinchDistance / distance),
controls.minDistance,
controls.maxDistance
);
}
pinchDistance = distance;
} else if (dragging) {
controls.yaw -= dx * 0.006;
controls.pitch = THREE.MathUtils.clamp(
controls.pitch + dy * 0.004,
controls.minPitch,
controls.maxPitch
);
}
updateCamera();
});
function endPointer(event) {
pointers.delete(event.pointerId);
dragging = pointers.size === 1;
pinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.distance = THREE.MathUtils.clamp(
controls.distance + event.deltaY * 0.025,
controls.minDistance,
controls.maxDistance
);
updateCamera();
},
{ passive: false }
);
function resetView() {
controls.target.set(0, 1.4, 0);
controls.yaw = 0.67;
controls.pitch = 0.62;
controls.distance = 38;
updateCamera();
}
document.getElementById("resetView").addEventListener("click", resetView);
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") resetView();
});
// -------------------------------------------------------------------------
// Ground, roads, park paths, and urban furniture
// -------------------------------------------------------------------------
B(scene, 40, 0.8, 29, 0, -0.48, 0, M.earth);
B(scene, 27, 0.22, 17.5, 0, -0.04, 0, M.grass);
// Roads around the park.
B(scene, 39, 0.08, 2.7, 0, -0.01, -10.2, M.asphalt);
B(scene, 39, 0.08, 2.7, 0, -0.01, 10.2, M.asphalt);
B(scene, 2.7, 0.08, 20.6, -14.9, -0.01, 0, M.asphalt);
B(scene, 2.7, 0.08, 20.6, 14.9, -0.01, 0, M.asphalt);
// Pale sidewalks between the park and streets.
B(scene, 29, 0.13, 0.72, 0, 0.05, -8.78, M.sidewalk);
B(scene, 29, 0.13, 0.72, 0, 0.05, 8.78, M.sidewalk);
B(scene, 0.72, 0.13, 18.5, -13.7, 0.05, 0, M.sidewalk);
B(scene, 0.72, 0.13, 18.5, 13.7, 0.05, 0, M.sidewalk);
// Main looping path and central crossings.
B(scene, 26.8, 0.09, 2.15, 0, 0.13, 7.1, M.paving);
B(scene, 26.8, 0.09, 2.15, 0, 0.13, -7.1, M.paving);
B(scene, 2.15, 0.09, 14.2, -12.8, 0.13, 0, M.paving);
B(scene, 2.15, 0.09, 14.2, 12.8, 0.13, 0, M.paving);
B(scene, 3.15, 0.09, 16.7, 0, 0.13, 0, M.paving);
const diagonal = B(
scene,
18.5,
0.09,
1.8,
6.3,
0.13,
-1.5,
M.paving
);
diagonal.rotation.y = -0.48;
// Circular paved terrace around the pavilion.
const terrace = new THREE.Mesh(
new THREE.CircleGeometry(5.8, 40),
M.paving
);
terrace.rotation.x = -Math.PI / 2;
terrace.position.set(-5.4, 0.135, -3.2);
terrace.receiveShadow = true;
scene.add(terrace);
// Grass islands and activity patches.
const playPatch = new THREE.Mesh(
new THREE.CircleGeometry(4.4, 32),
M.rubber
);
playPatch.rotation.x = -Math.PI / 2;
playPatch.position.set(7.1, 0.135, -3.2);
playPatch.receiveShadow = true;
scene.add(playPatch);
const footballPatch = new THREE.Mesh(
new THREE.CircleGeometry(3.4, 32),
M.grassLight
);
footballPatch.rotation.x = -Math.PI / 2;
footballPatch.position.set(7.4, 0.14, 4.1);
footballPatch.receiveShadow = true;
scene.add(footballPatch);
// Crosswalk.
for (let i = 0; i < 6; i++) {
B(
scene,
0.55,
0.025,
2.25,
8.1 + i * 0.85,
0.06,
10.2,
M.white
);
}
// Road dashes.
for (let x = -17; x <= 17; x += 3.2) {
if (x > 7 && x < 13) continue;
B(scene, 1.25, 0.025, 0.1, x, 0.06, 10.2, M.yellow);
B(scene, 1.25, 0.025, 0.1, x, 0.06, -10.2, M.yellow);
}
// -------------------------------------------------------------------------
// Neighboring Copenhagen facades
// -------------------------------------------------------------------------
function building(
x,
z,
width,
height,
depth,
color,
rotation = 0,
gabled = false,
label = ""
) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
scene.add(group);
const facade = material(color);
const trim = material(0xe6dfd2);
const roofMaterial = material(0x4b514f);
const front = depth / 2;
B(group, width, height, depth, 0, height / 2, 0, facade);
B(group, width + 0.2, 0.24, depth + 0.2, 0, 0.12, 0, trim);
if (gabled) {
const shape = new THREE.Shape();
shape.moveTo(-width / 2 - 0.2, 0);
shape.lineTo(width / 2 + 0.2, 0);
shape.lineTo(0, 1.8);
shape.closePath();
const roof = new THREE.Mesh(
new THREE.ExtrudeGeometry(shape, {
depth: depth + 0.35,
bevelEnabled: false,
}),
roofMaterial
);
roof.position.set(0, height, -depth / 2 - 0.17);
roof.castShadow = true;
roof.receiveShadow = true;
group.add(roof);
} else {
B(group, width + 0.35, 0.28, depth + 0.35, 0, height + 0.14, 0, roofMaterial);
B(group, width + 0.1, 0.45, 0.18, 0, height + 0.42, front - 0.05, trim);
}
const floors = Math.floor((height - 1) / 2.15);
const columns = Math.max(2, Math.floor(width / 1.65));
const spacing = (width - 1.2) / Math.max(1, columns - 1);
for (let floor = 0; floor < floors; floor++) {
const windowY = 3.75 + floor * 2.15;
for (let column = 0; column < columns; column++) {
const windowX =
-((width - 1.2) / 2) + column * spacing;
if (floor === 0 && column === Math.floor(columns / 2)) {
continue;
}
B(group, 1.1, 1.43, 0.09, windowX, windowY, front + 0.06, trim);
const glassMaterial =
(floor + column) % 4 === 0 ? M.glassLit : M.glass;
B(
group,
0.91,
1.22,
0.08,
windowX,
windowY,
front + 0.12,
glassMaterial
);
B(group, 0.055, 1.22, 0.045, windowX, windowY, front + 0.18, trim);
B(group, 0.91, 0.055, 0.045, windowX, windowY, front + 0.18, trim);
B(group, 1.23, 0.11, 0.28, windowX, windowY - 0.76, front + 0.15, trim);
}
}
// Ground-floor entrance.
const doorX = ((width - 1.2) / 2) * (columns % 2 === 0 ? -1 : 1);
B(group, 1.28, 2.35, 0.12, doorX, 1.22, front + 0.08, trim);
B(group, 0.98, 2.12, 0.1, doorX, 1.12, front + 0.17, M.blue);
Sphere(group, 0.06, doorX + 0.32, 1.08, front + 0.24, M.yellow, 8);
if (label) {
const sign = new THREE.Mesh(
new THREE.PlaneGeometry(Math.min(width - 0.8, 3.8), 0.58),
canvasSign(label)
);
sign.position.set(0, 2.6, front + 0.24);
group.add(sign);
}
// Small balcony on some facades.
if (width > 5 && height > 7) {
B(group, 2.2, 0.13, 0.75, 0, 5.45, front + 0.35, trim);
B(group, 2.2, 0.08, 0.08, 0, 6.08, front + 0.68, M.metal);
for (let i = 0; i < 7; i++) {
B(
group,
0.045,
0.65,
0.045,
-1 + i * 0.33,
5.75,
front + 0.68,
M.metal
);
}
}
// Chimney.
B(
group,
0.58,
1.05,
0.62,
width * 0.25,
height + (gabled ? 1.35 : 0.65),
-0.2,
facade
);
return group;
}
const northColors = [
0xc88162,
0xd5b16f,
0x9eaa8b,
0xb46b58,
0xd8c9a8,
];
const northWidths = [5.1, 5.8, 6.2, 5.2, 6.0];
const northHeights = [9.2, 10.7, 8.8, 11.5, 9.8];
const northX = [-11.7, -6.25, -0.3, 5.45, 11.25];
const northLabels = ["KØBENHAVN", "CYKLER", "CAFÉ", "", "BØRNENE"];
northX.forEach((x, index) => {
building(
x,
-14.25,
northWidths[index],
northHeights[index],
4.15,
northColors[index],
0,
index % 2 === 0,
northLabels[index]
);
});
building(-18.15, -6.4, 5.5, 9.5, 4.1, 0xb8775f, Math.PI / 2, false, "");
building(-18.15, 0, 5.8, 11.2, 4.1, 0xd0bc8d, Math.PI / 2, true, "IS");
building(-18.15, 6.5, 5.4, 9.1, 4.1, 0x8faaa3, Math.PI / 2, false, "");
building(18.15, -6.6, 5.7, 10.3, 4.1, 0xc69565, -Math.PI / 2, true, "BLOMSTER");
building(18.15, 0, 5.5, 8.9, 4.1, 0xaf7467, -Math.PI / 2, false, "");
building(18.15, 6.5, 5.8, 11.1, 4.1, 0xd1c59b, -Math.PI / 2, true, "BØGER");
// -------------------------------------------------------------------------
// The red Superkilen pavilion and its light-bulb landmark
// -------------------------------------------------------------------------
const pavilion = new THREE.Group();
pavilion.position.set(-5.4, 0, -3.25);
scene.add(pavilion);
B(pavilion, 8.0, 0.42, 5.9, 0, 0.32, 0, M.redDark);
B(pavilion, 8.5, 0.28, 6.35, 0, 3.82, 0, M.red);
for (const x of [-3.45, 3.45]) {
for (const z of [-2.4, 2.4]) {
Cyl(pavilion, 0.18, 0.22, 3.25, x, 2.0, z, M.red, 8);
}
}
B(pavilion, 7.8, 2.35, 0.25, 0, 1.62, -2.35, M.red);
B(pavilion, 0.25, 2.35, 4.7, -3.35, 1.62, 0, M.red);
B(pavilion, 0.25, 2.35, 4.7, 3.35, 1.62, 0, M.red);
// A compact enclosed room under the canopy.
B(pavilion, 3.25, 2.5, 3.55, -1.75, 1.63, -0.35, M.red);
B(pavilion, 2.1, 0.9, 0.08, -1.75, 1.75, 1.47, M.glass);
B(pavilion, 0.08, 0.92, 0.1, -1.75, 1.75, 1.54, M.cream);
B(pavilion, 2.16, 0.08, 0.1, -1.75, 1.75, 1.54, M.cream);
// Steps.
B(pavilion, 5.1, 0.18, 0.72, 0.35, 0.13, 3.35, M.red);
B(pavilion, 5.1, 0.3, 0.72, 0.35, 0.24, 2.93, M.red);
B(pavilion, 5.1, 0.42, 0.72, 0.35, 0.35, 2.51, M.red);
// Tables and stools inside.
Cyl(pavilion, 0.66, 0.66, 0.12, 1.7, 1.0, 0.7, M.cream, 12);
Cyl(pavilion, 0.09, 0.12, 0.8, 1.7, 0.55, 0.7, M.metal, 8);
Cyl(pavilion, 0.28, 0.28, 0.52, 0.7, 0.68, 0.7, M.yellow, 8);
Cyl(pavilion, 0.28, 0.28, 0.52, 2.65, 0.68, 0.7, M.turquoise, 8);
// The oversized yellow bulb landmark.
const bulb = new THREE.Group();
bulb.position.set(-10.25, 0, -2.25);
scene.add(bulb);
Cyl(bulb, 0.7, 0.9, 0.35, 0, 0.28, 0, M.black, 10);
Cyl(bulb, 0.13, 0.18, 1.55, 0, 1.15, 0, M.black, 8);
const bulbGlass = Sphere(bulb, 0.82, 0, 2.35, 0, M.yellow, 12);
bulbGlass.scale.y = 1.28;
Cyl(bulb, 0.32, 0.42, 0.45, 0, 1.43, 0, M.yellow, 10);
Cyl(bulb, 0.29, 0.32, 0.12, 0, 1.18, 0, M.metal, 10);
const bulbLight = new THREE.PointLight(0xffd66a, 0.7, 7, 2);
bulbLight.position.set(0, 2.35, 0);
bulb.add(bulbLight);
// -------------------------------------------------------------------------
// Play landscape, sculptural seating, trees, and lamps
// -------------------------------------------------------------------------
function mound(x, z, radius, height, mat = M.rubber) {
const geometry = new THREE.SphereGeometry(
radius,
8,
4,
0,
Math.PI * 2,
0,
Math.PI / 2
);
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(x, 0.18, z);
mesh.scale.y = height / radius;
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
mound(5.8, -2.7, 2.25, 1.45);
mound(8.7, -3.7, 1.75, 1.15);
// Slide attached to the largest mound.
const slide = B(scene, 1.25, 0.12, 4.1, 5.6, 0.87, -0.4, M.yellow);
slide.rotation.x = -0.29;
Rod(scene, [4.95, 0.18, 1.58], [4.95, 1.65, 1.58], 0.055, M.metal);
Rod(scene, [6.25, 0.18, 1.58], [6.25, 1.65, 1.58], 0.055, M.metal);
for (let i = 0; i < 5; i++) {
Rod(
scene,
[4.95, 0.25 + i * 0.31, 1.58],
[6.25, 0.25 + i * 0.31, 1.58],
0.045,
M.yellow
);
}
// Sculptural, brightly colored seats.
B(scene, 1.55, 0.65, 1.55, 9.2, 0.48, 0.8, M.yellow);
B(scene, 1.0, 0.55, 1.0, 10.65, 0.44, 1.25, M.orange);
const arch = new THREE.Mesh(
new THREE.TorusGeometry(1.3, 0.28, 6, 16, Math.PI),
M.turquoise
);
arch.position.set(11.0, 0.5, -0.9);
arch.rotation.z = Math.PI;
arch.castShadow = true;
scene.add(arch);
const blueSeat = B(scene, 2.8, 0.45, 0.65, 3.4, 0.42, 5.4, M.blue);
blueSeat.rotation.y = -0.35;
function tree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.1, z);
group.scale.setScalar(scale);
scene.add(group);
Cyl(group, 0.17, 0.25, 2.8, 0, 1.35, 0, M.trunk, 7);
Ico(group, 1.35, 1, 0, 3.25, 0, M.leaf);
Ico(group, 0.95, 0, 0.65, 3.8, 0.1, M.leafLight);
Ico(group, 0.92, 0, -0.55, 3.55, 0.25, M.leafDark);
Ico(group, 0.78, 0, 0.1, 4.05, -0.35, M.leaf);
return group;
}
[
[-11.8, -5.2, 1.0],
[-11.3, 4.1, 0.87],
[-2.6, 7.65, 0.8],
[10.9, -5.7, 0.95],
[11.0, 6.5, 0.86],
[3.8, -7.8, 0.78],
[9.8, 1.8, 0.66],
].forEach(([x, z, scale]) => tree(x, z, scale));
// Low shrubs.
[
[-8.9, 4.6],
[-7.9, 4.5],
[4.8, 7.7],
[11.8, 2.6],
[10.9, 2.8],
[-12.3, 0.8],
].forEach(([x, z]) => {
Ico(scene, 0.48, 0, x, 0.46, z, M.leafLight);
Ico(scene, 0.38, 0, x + 0.45, 0.4, z + 0.12, M.leaf);
});
function bench(x, z, rotation = 0, color = M.wood) {
const group = new THREE.Group();
group.position.set(x, 0.12, z);
group.rotation.y = rotation;
scene.add(group);
for (let i = 0; i < 3; i++) {
B(group, 2.35, 0.1, 0.15, 0, 0.62, -0.2 + i * 0.19, color);
}
B(group, 2.35, 0.18, 0.1, 0, 1.03, -0.31, color);
B(group, 2.35, 0.18, 0.1, 0, 1.3, -0.31, color);
for (const side of [-0.87, 0.87]) {
B(group, 0.09, 0.62, 0.09, side, 0.31, -0.22, M.metal);
B(group, 0.09, 0.62, 0.09, side, 0.31, 0.22, M.metal);
Rod(group, [side, 0.42, -0.28], [side, 1.32, -0.28], 0.045, M.metal);
}
return group;
}
bench(-2.0, 6.2, 0, M.red);
bench(7.5, 1.1, -Math.PI / 2, M.woodLight);
bench(-9.6, 2.4, Math.PI / 2, M.wood);
bench(3.2, -7.15, 0, M.turquoise);
bench(10.8, 4.4, -0.4, M.woodLight);
function lamp(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
scene.add(group);
Cyl(group, 0.09, 0.14, 4.1, 0, 2.05, 0, M.metal, 8);
B(group, 0.42, 0.12, 0.42, 0, 0.08, 0, M.metal);
B(group, 0.72, 0.2, 0.34, 0, 4.16, 0, M.black);
B(group, 0.55, 0.08, 0.26, 0, 4.02, 0, M.white);
Rod(group, [0, 4.1, 0], [0.32, 4.1, 0], 0.045, M.metal);
}
lamp(-11.4, 8.75);
lamp(-2.8, 8.75);
lamp(5.8, 8.75);
lamp(13.7, 3.8, -Math.PI / 2);
lamp(-13.7, -3.5, Math.PI / 2);
// Bollards along the pavement.
for (const x of [-9, -6, -3, 0, 3, 6, 9]) {
Cyl(scene, 0.09, 0.13, 0.8, x, 0.47, 8.72, M.metal, 8);
Sphere(scene, 0.1, x, 0.88, 8.72, M.metal, 8);
}
// -------------------------------------------------------------------------
// People
// -------------------------------------------------------------------------
const walkers = [];
function makePerson({
x = 0,
z = 0,
shirt = M.blue,
skin = M.skin,
scale = 1,
hair = M.hair,
} = {}) {
const group = new THREE.Group();
group.position.set(x, 0.18, z);
group.scale.setScalar(scale);
scene.add(group);
Cyl(group, 0.23, 0.29, 0.6, 0, 1.08, 0, shirt, 7);
Sphere(group, 0.18, 0, 1.58, 0.02, skin, 9);
const hairCap = Sphere(group, 0.185, 0, 1.7, -0.005, hair, 9);
hairCap.scale.y = 0.55;
B(group, 0.25, 0.14, 0.12, 0, 1.38, 0.19, skin);
const legs = [];
const arms = [];
for (const side of [-1, 1]) {
const leg = new THREE.Group();
leg.position.set(side * 0.12, 0.78, 0);
group.add(leg);
Cyl(leg, 0.075, 0.07, 0.57, 0, -0.28, 0, M.black, 7);
B(leg, 0.16, 0.12, 0.28, 0, -0.58, 0.08, M.black);
legs.push(leg);
const arm = new THREE.Group();
arm.position.set(side * 0.29, 1.33, 0);
group.add(arm);
Cyl(arm, 0.065, 0.055, 0.46, 0, -0.23, 0, shirt, 7);
Sphere(arm, 0.065, 0, -0.48, 0, skin, 7);
arms.push(arm);
}
return { group, legs, arms };
}
function addWalker(options, motion) {
const person = makePerson(options);
walkers.push({
...person,
...motion,
phase: Math.random() * Math.PI * 2,
});
return person;
}
addWalker(
{ x: -10, z: 7.1, shirt: M.orange, skin: M.skinDark },
{ axis: "x", min: -11.8, max: 11.8, speed: 1.05, direction: 1 }
);
addWalker(
{ x: 1.2, z: 7.2, shirt: M.turquoise, skin: M.skin, scale: 0.94 },
{ axis: "x", min: -11.8, max: 11.8, speed: 0.83, direction: -1 }
);
addWalker(
{ x: 12.8, z: -2.3, shirt: M.yellow, skin: M.skinDark },
{ axis: "z", min: -6.2, max: 6.2, speed: 0.95, direction: 1 }
);
addWalker(
{ x: -12.8, z: 2.8, shirt: M.blue, skin: M.skin, scale: 0.82 },
{ axis: "z", min: -6.2, max: 6.2, speed: 1.15, direction: -1 }
);
addWalker(
{ x: 8.8, z: 4.0, shirt: M.red, skin: M.skin, scale: 0.68 },
{ axis: "x", min: 5.8, max: 10.3, speed: 1.35, direction: 1 }
);
function seatedPerson(x, z, rotation, shirt, skin = M.skin) {
const group = new THREE.Group();
group.position.set(x, 0.72, z);
group.rotation.y = rotation;
scene.add(group);
Cyl(group, 0.2, 0.25, 0.5, 0, 0.36, 0, shirt, 7);
Sphere(group, 0.17, 0, 0.82, 0.02, skin, 9);
const cap = Sphere(group, 0.175, 0, 0.93, 0, M.hair, 9);
cap.scale.y = 0.5;
for (const side of [-1, 1]) {
B(group, 0.16, 0.15, 0.5, side * 0.11, -0.04, 0.22, M.black);
B(group, 0.14, 0.42, 0.14, side * 0.11, -0.31, 0.42, M.black);
Rod(
group,
[side * 0.27, 0.58, 0],
[side * 0.27, 0.12, 0.28],
0.055,
shirt
);
}
}
seatedPerson(-2.45, 6.42, 0, M.cream, M.skinDark);
seatedPerson(7.29, 1.12, -Math.PI / 2, M.blue);
seatedPerson(3.18, -6.91, 0, M.orange);
// -------------------------------------------------------------------------
// Bicycles and cyclist
// -------------------------------------------------------------------------
function makeWheel(parent, z) {
const wheel = new THREE.Group();
wheel.position.set(0, 0.52, z);
parent.add(wheel);
const tire = new THREE.Mesh(
new THREE.TorusGeometry(0.48, 0.055, 6, 18),
M.black
);
tire.rotation.y = Math.PI / 2;
tire.castShadow = true;
wheel.add(tire);
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
Rod(
wheel,
[0, 0, 0],
[0, Math.cos(angle) * 0.43, Math.sin(angle) * 0.43],
0.012,
M.metal,
5
);
}
const hub = Cyl(wheel, 0.045, 0.045, 0.2, 0, 0, 0, M.metal, 8);
hub.rotation.z = Math.PI / 2;
return wheel;
}
function makeBike(withRider = false, riderShirt = M.turquoise) {
const group = new THREE.Group();
scene.add(group);
const rear = [0, 0.52, -0.67];
const front = [0, 0.52, 0.67];
const crank = [0, 0.48, -0.04];
const seatJoint = [0, 1.05, -0.29];
const handleJoint = [0, 1.02, 0.43];
Rod(group, rear, crank, 0.045, M.red);
Rod(group, crank, seatJoint, 0.045, M.red);
Rod(group, seatJoint, rear, 0.045, M.red);
Rod(group, seatJoint, handleJoint, 0.045, M.red);
Rod(group, handleJoint, crank, 0.045, M.red);
Rod(group, handleJoint, front, 0.045, M.metal);
const wheels = [makeWheel(group, -0.67), makeWheel(group, 0.67)];
B(group, 0.32, 0.09, 0.42, 0, 1.1, -0.3, M.black);
Rod(group, [0, 1.02, 0.43], [-0.32, 1.14, 0.48], 0.035, M.metal);
Rod(group, [0, 1.02, 0.43], [0.32, 1.14, 0.48], 0.035, M.metal);
B(group, 0.32, 0.035, 0.035, 0, 1.14, 0.48, M.black);
if (withRider) {
Cyl(group, 0.22, 0.27, 0.57, 0, 1.48, -0.09, riderShirt, 7);
Sphere(group, 0.17, 0, 1.94, 0.02, M.skin, 9);
const helmet = Sphere(group, 0.185, 0, 2.04, 0, M.yellow, 9);
helmet.scale.y = 0.55;
Rod(group, [-0.23, 1.66, -0.06], [-0.28, 1.22, 0.35], 0.055, riderShirt);
Rod(group, [0.23, 1.66, -0.06], [0.28, 1.22, 0.35], 0.055, riderShirt);
Rod(group, [-0.27, 1.2, 0.38], [-0.18, 1.14, 0.46], 0.055, M.black);
Rod(group, [0.27, 1.2, 0.38], [0.18, 1.14, 0.46], 0.055, M.black);
Rod(group, [-0.15, 1.0, -0.28], [-0.17, 0.57, -0.1], 0.07, M.blue);
Rod(group, [0.15, 1.0, -0.28], [0.17, 0.57, -0.1], 0.07, M.blue);
}
return { group, wheels };
}
const cyclist = makeBike(true, M.turquoise);
const cyclistPath = [
new THREE.Vector3(-12.55, 0.18, 7.45),
new THREE.Vector3(12.55, 0.18, 7.45),
new THREE.Vector3(12.55, 0.18, -7.45),
new THREE.Vector3(-12.55, 0.18, -7.45),
];
let cyclistIndex = 0;
const parkedBikeA = makeBike(false);
parkedBikeA.group.position.set(-10.1, 0.18, 8.25);
parkedBikeA.group.rotation.y = Math.PI / 2;
parkedBikeA.group.rotation.z = -0.12;
const parkedBikeB = makeBike(false);
parkedBikeB.group.position.set(-9.05, 0.18, 8.35);
parkedBikeB.group.rotation.y = Math.PI / 2 + 0.08;
// Simple bike rack.
for (let i = 0; i < 4; i++) {
const x = -10.5 + i * 0.62;
Rod(scene, [x, 0.2, 8.75], [x, 0.9, 8.75], 0.035, M.metal);
Rod(scene, [x, 0.9, 8.75], [x, 0.9, 8.35], 0.035, M.metal);
Rod(scene, [x, 0.9, 8.35], [x, 0.2, 8.35], 0.035, M.metal);
}
// -------------------------------------------------------------------------
// Dog walker, football game, kiosk, and street life
// -------------------------------------------------------------------------
const dogWalker = makePerson({
x: -7.5,
z: 5.9,
shirt: M.cream,
skin: M.skinDark,
});
const dog = new THREE.Group();
scene.add(dog);
B(dog, 0.72, 0.34, 0.34, 0, 0.45, 0, M.woodLight);
Sphere(dog, 0.23, 0, 0.62, 0.28, M.woodLight, 8);
B(dog, 0.2, 0.12, 0.2, 0, 0.57, 0.48, M.woodLight);
for (const x of [-0.25, 0.25]) {
for (const z of [-0.12, 0.12]) {
B(dog, 0.09, 0.32, 0.1, x, 0.2, z, M.wood);
}
}
Rod(dog, [0, 0.55, -0.18], [0, 0.88, -0.42], 0.045, M.wood);
const leash = Rod(
scene,
[-7.5, 1.05, 5.9],
[-6.8, 0.7, 5.9],
0.014,
M.black,
5
);
// Football and children.
const football = Sphere(scene, 0.2, 8.2, 0.43, 3.2, M.white, 10);
Ico(football, 0.095, 0, 0.12, 0.05, 0.14, M.black);
const childA = makePerson({
x: 6.7,
z: 3.2,
shirt: M.blue,
skin: M.skinDark,
scale: 0.7,
});
const childB = makePerson({
x: 9.2,
z: 4.8,
shirt: M.yellow,
skin: M.skin,
scale: 0.68,
});
childA.group.rotation.y = 1.1;
childB.group.rotation.y = -1.5;
// Small fruit kiosk at the edge of the pavilion terrace.
const kiosk = new THREE.Group();
kiosk.position.set(-8.0, 0.16, 2.25);
kiosk.rotation.y = 0.12;
scene.add(kiosk);
B(kiosk, 1.8, 0.92, 1.1, 0, 0.62, 0, M.wood);
B(kiosk, 1.95, 0.12, 1.25, 0, 1.15, 0, M.cream);
B(kiosk, 2.15, 0.08, 1.45, 0, 2.05, 0, M.red);
for (const x of [-0.85, 0.85]) {
Cyl(kiosk, 0.045, 0.045, 1.85, x, 1.05, -0.45, M.metal, 8);
Cyl(kiosk, 0.045, 0.045, 1.85, x, 1.05, 0.45, M.metal, 8);
}
const fruitColors = [M.yellow, M.orange, M.red];
for (let i = 0; i < 12; i++) {
const fruit = Sphere(
kiosk,
0.1,
-0.65 + (i % 6) * 0.26,
1.3,
-0.28 + Math.floor(i / 6) * 0.48,
fruitColors[i % 3],
7
);
fruit.scale.y = 0.9;
}
// Parked car.
function makeCar(color, x, z, rotation) {
const group = new THREE.Group();
group.position.set(x, 0.05, z);
group.rotation.y = rotation;
scene.add(group);
B(group, 3.5, 0.62, 1.45, 0, 0.65, 0, material(color));
B(group, 1.8, 0.62, 1.28, -0.1, 1.2, 0, material(color));
B(group, 1.48, 0.4, 1.31, -0.12, 1.25, 0, M.glass);
for (const side of [-1, 1]) {
for (const wheelZ of [-0.48, 0.48]) {
const wheel = Cyl(
group,
0.29,
0.29,
0.2,
side * 0.9,
0.34,
wheelZ,
M.black,
12
);
wheel.rotation.z = Math.PI / 2;
}
}
B(group, 0.08, 0.18, 1.1, 1.77, 0.72, 0, M.white);
B(group, 0.08, 0.18, 1.1, -1.77, 0.72, 0, M.red);
}
makeCar(0xd5a23c, 5.3, 10.25, Math.PI / 2);
makeCar(0x759b9b, -7.0, -10.25, -Math.PI / 2);
// A few pigeons beside the pavilion.
function pigeon(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.22, z);
group.rotation.y = rotation;
scene.add(group);
const body = Sphere(group, 0.13, 0, 0.14, 0, M.metal, 8);
body.scale.set(0.8, 1, 1.35);
Sphere(group, 0.075, 0, 0.27, 0.13, M.metal, 7);
B(group, 0.06, 0.05, 0.1, 0, 0.27, 0.21, M.yellow);
}
pigeon(-1.3, 0.45, 0.3);
pigeon(-0.7, 0.7, -0.6);
pigeon(4.9, -0.6, 1.2);
// Decorative clouds.
const cloudMaterial = new THREE.MeshStandardMaterial({
color: 0xf7fbfb,
roughness: 1,
transparent: true,
opacity: 0.82,
depthWrite: false,
});
[
[-12, 16, -18, 1.6],
[7, 18, -25, 2.1],
[18, 14, -12, 1.3],
[-19, 13, -3, 1.0],
].forEach(([x, y, z, scale]) => {
const cloud = new THREE.Group();
cloud.position.set(x, y, z);
cloud.scale.setScalar(scale);
scene.add(cloud);
Ico(cloud, 1.2, 1, 0, 0, 0, cloudMaterial);
Ico(cloud, 0.85, 1, -1.1, -0.15, 0, cloudMaterial);
Ico(cloud, 0.95, 1, 1.15, -0.1, 0, cloudMaterial);
Ico(cloud, 0.75, 1, 0.2, 0.35, 0, cloudMaterial);
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
let motionPaused = false;
document.getElementById("toggleMotion").addEventListener("click", (event) => {
motionPaused = !motionPaused;
event.currentTarget.textContent = motionPaused ? "Resume life" : "Pause life";
});
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
const time = clock.elapsedTime;
if (!motionPaused) {
// Pedestrians.
walkers.forEach((walker) => {
const position = walker.group.position;
if (walker.axis === "x") {
position.x += walker.speed * walker.direction * dt;
if (position.x > walker.max) {
position.x = walker.max;
walker.direction = -1;
} else if (position.x < walker.min) {
position.x = walker.min;
walker.direction = 1;
}
walker.group.rotation.y =
walker.direction > 0 ? Math.PI / 2 : -Math.PI / 2;
} else {
position.z += walker.speed * walker.direction * dt;
if (position.z > walker.max) {
position.z = walker.max;
walker.direction = -1;
} else if (position.z < walker.min) {
position.z = walker.min;
walker.direction = 1;
}
walker.group.rotation.y = walker.direction > 0 ? 0 : Math.PI;
}
const swing = Math.sin(time * 8.5 + walker.phase) * 0.55;
walker.legs[0].rotation.x = swing;
walker.legs[1].rotation.x = -swing;
walker.arms[0].rotation.x = -swing * 0.8;
walker.arms[1].rotation.x = swing * 0.8;
walker.group.position.y = 0.18 + Math.abs(Math.sin(time * 8.5 + walker.phase)) * 0.018;
});
// Moving cyclist.
const target = cyclistPath[(cyclistIndex + 1) % cyclistPath.length];
const current = cyclistPath[cyclistIndex];
const dx = target.x - current.x;
const dz = target.z - current.z;
const distance = Math.hypot(dx, dz);
const step = 2.45 * dt;
if (distance <= step) {
cyclistIndex = (cyclistIndex + 1) % cyclistPath.length;
} else {
cyclist.group.position.x += (dx / distance) * step;
cyclist.group.position.z += (dz / distance) * step;
cyclist.group.rotation.y = Math.atan2(dx, dz);
}
cyclist.group.position.y =
0.18 + Math.sin(time * 10) * 0.012;
cyclist.wheels[0].rotation.x -= dt * 8;
cyclist.wheels[1].rotation.x -= dt * 8;
// Dog and dynamic leash.
const walkerPosition = dogWalker.group.position;
const rotation = dogWalker.group.rotation.y;
const localX = 0.85;
const localZ = 0.28;
const dogX =
walkerPosition.x +
localX * Math.cos(rotation) +
localZ * Math.sin(rotation);
const dogZ =
walkerPosition.z -
localX * Math.sin(rotation) +
localZ * Math.cos(rotation);
dog.position.x = dogX;
dog.position.z = dogZ;
dog.position.y = 0.16;
dog.rotation.y = rotation;
const handX =
walkerPosition.x +
0.28 * Math.cos(rotation) +
0.18 * Math.sin(rotation);
const handZ =
walkerPosition.z -
0.28 * Math.sin(rotation) +
0.18 * Math.cos(rotation);
updateRod(
leash,
[handX, 1.0, handZ],
[dogX, 0.72, dogZ]
);
// The football rolls in a loose arc.
football.position.x = 8.1 + Math.sin(time * 0.9) * 1.1;
football.position.z = 3.8 + Math.cos(time * 0.72) * 0.7;
football.rotation.x += dt * 2.4;
football.rotation.z += dt * 1.7;
// Subtle play-area movement.
childA.group.position.x = 7.1 + Math.sin(time * 0.8) * 0.75;
childA.group.position.z = 3.45 + Math.cos(time * 0.66) * 0.4;
childA.legs[0].rotation.x = Math.sin(time * 7) * 0.4;
childA.legs[1].rotation.x = -Math.sin(time * 7) * 0.4;
childB.group.position.x = 9.0 + Math.cos(time * 0.72) * 0.65;
childB.group.position.z = 4.6 + Math.sin(time * 0.88) * 0.35;
childB.arms[0].rotation.x = -Math.sin(time * 7.4) * 0.5;
childB.arms[1].rotation.x = Math.sin(time * 7.4) * 0.5;
}
renderer.render(scene, camera);
}
// -------------------------------------------------------------------------
// Resize handling
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
animate();
</script>
</body>
</html>
```