Prompt specification
Build or customize the Three.js 3D scene "Cup telephone tension model" 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: Cup telephone tension model
Category: Games & Play · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/cup-telephone-tension-model-x0381
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows a string telephone. Build two paper cups connected by a taut string, with cup bases clearly pierced at attachment points; include a sagging disconnected comparison segment nearby. Stylized solid forms.
Working Three.js Starter (cup-telephone-tension-model-x0381):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>String Telephone</title>
<style>
:root {
color-scheme: light;
--ink: #26323a;
--paper: #fffaf0;
--accent: #d96747;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #eee3d2;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene canvas:active {
cursor: grabbing;
}
.title-card {
position: fixed;
top: 24px;
left: 24px;
z-index: 10;
width: min(360px, calc(100vw - 48px));
padding: 17px 19px 16px;
border: 1px solid rgba(38, 50, 58, 0.14);
border-radius: 18px;
background: rgba(255, 250, 240, 0.82);
box-shadow: 0 12px 35px rgba(72, 52, 34, 0.12);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
margin: 0 0 6px;
color: var(--accent);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 4vw, 38px);
line-height: 1;
letter-spacing: -0.045em;
}
.subtitle {
margin: 9px 0 0;
color: rgba(38, 50, 58, 0.66);
font-size: 13px;
line-height: 1.45;
}
.controls {
position: fixed;
right: 22px;
bottom: 22px;
z-index: 10;
display: flex;
align-items: center;
gap: 12px;
padding: 9px 10px 9px 14px;
border: 1px solid rgba(38, 50, 58, 0.12);
border-radius: 999px;
background: rgba(255, 250, 240, 0.86);
box-shadow: 0 10px 30px rgba(72, 52, 34, 0.12);
backdrop-filter: blur(10px);
color: rgba(38, 50, 58, 0.7);
font-size: 12px;
}
button {
border: 0;
border-radius: 999px;
padding: 8px 13px;
background: var(--ink);
color: white;
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
transition: transform 150ms ease, background 150ms ease;
}
button:hover {
background: #3d4b54;
transform: translateY(-1px);
}
button:active {
transform: translateY(0);
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #eee3d2;
color: var(--ink);
font-size: 13px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 640px) {
.title-card {
top: 14px;
left: 14px;
padding: 14px 16px;
}
.subtitle {
display: none;
}
.controls {
right: 12px;
bottom: 12px;
}
.controls span {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<header class="title-card">
<p class="eyebrow">Solid-form study</p>
<h1>String Telephone</h1>
<p class="subtitle">
Two pierced paper cups joined by a taut cord, with a separate sagging
string segment for comparison.
</p>
</header>
<div class="controls">
<span>Drag to orbit · Scroll to zoom</span>
<button id="reset-view" type="button">Reset view</button>
</div>
<div id="loading">Building the telephone…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const container = document.querySelector("#scene");
const loading = document.querySelector("#loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xeee3d2);
scene.fog = new THREE.Fog(0xeee3d2, 19, 34);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive 3D scene of two paper cups connected by string"
);
container.appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
36,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3(0, 2.55, 0);
let theta = 0.48;
let phi = 1.67;
let radius = 12.8;
function updateCamera() {
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
}
updateCamera();
// Lighting
const hemisphere = new THREE.HemisphereLight(
0xfff8e9,
0x705745,
1.9
);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffefd2, 3.2);
keyLight.position.set(-5, 9, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 9;
keyLight.shadow.camera.bottom = -6;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 28;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x9bc9d4, 1.15);
fillLight.position.set(6, 4, -7);
scene.add(fillLight);
const rimLight = new THREE.PointLight(0xff8b66, 18, 18, 2);
rimLight.position.set(-4.5, 4.8, 3.8);
scene.add(rimLight);
// Matte display surface
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(60, 60),
new THREE.MeshStandardMaterial({
color: 0xdcc9ac,
roughness: 0.95,
metalness: 0
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.78;
ground.receiveShadow = true;
scene.add(ground);
// Soft decorative platform rings
const platformMaterial = new THREE.MeshStandardMaterial({
color: 0xcbb797,
roughness: 0.92
});
for (const radiusValue of [2.35, 4.15, 5.95]) {
const platform = new THREE.Mesh(
new THREE.TorusGeometry(radiusValue, 0.018, 8, 128),
platformMaterial
);
platform.rotation.x = Math.PI / 2;
platform.position.set(0, -0.755, -0.25);
platform.receiveShadow = true;
scene.add(platform);
}
const stringMaterial = new THREE.MeshStandardMaterial({
color: 0xb88b58,
roughness: 0.82,
metalness: 0
});
const paperInnerMaterial = new THREE.MeshStandardMaterial({
color: 0xf5e7ce,
roughness: 0.92,
side: THREE.BackSide
});
const punctureMaterial = new THREE.MeshStandardMaterial({
color: 0x5e4938,
roughness: 1,
side: THREE.DoubleSide
});
const fringeMaterial = new THREE.MeshStandardMaterial({
color: 0xd6ad78,
roughness: 0.95
});
function makeCup({
position,
color,
accent,
holeOffsetX,
zRotation
}) {
const group = new THREE.Group();
group.position.copy(position);
group.rotation.set(-0.22, 0, zRotation);
scene.add(group);
const paperMaterial = new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0,
side: THREE.DoubleSide
});
const accentMaterial = new THREE.MeshStandardMaterial({
color: accent,
roughness: 0.8
});
// Open, tapered outer paper wall
const outerWall = new THREE.Mesh(
new THREE.CylinderGeometry(0.72, 0.48, 1.36, 64, 1, true),
paperMaterial
);
outerWall.castShadow = true;
outerWall.receiveShadow = true;
group.add(outerWall);
// Visible inner paper wall
const innerWall = new THREE.Mesh(
new THREE.CylinderGeometry(0.655, 0.425, 1.30, 64, 1, true),
paperInnerMaterial
);
innerWall.position.y = 0.012;
innerWall.castShadow = true;
group.add(innerWall);
// A genuinely pierced base: the base is an extruded shape with a hole.
const baseShape = new THREE.Shape();
baseShape.absarc(0, 0, 0.49, 0, Math.PI * 2, false);
const puncturePath = new THREE.Path();
puncturePath.absarc(
holeOffsetX,
0,
0.145,
0,
Math.PI * 2,
true
);
baseShape.holes.push(puncturePath);
const baseGeometry = new THREE.ExtrudeGeometry(baseShape, {
depth: 0.075,
steps: 1,
bevelEnabled: true,
bevelSegments: 2,
bevelSize: 0.012,
bevelThickness: 0.01,
curveSegments: 48
});
baseGeometry.rotateX(-Math.PI / 2);
const base = new THREE.Mesh(
baseGeometry,
new THREE.MeshStandardMaterial({
color: new THREE.Color(color).lerp(new THREE.Color(0xf2dfc1), 0.3),
roughness: 0.9
})
);
base.position.y = -0.705;
base.castShadow = true;
base.receiveShadow = true;
group.add(base);
// Dark sleeve and light torn rim make the puncture read clearly.
const punctureSleeve = new THREE.Mesh(
new THREE.CylinderGeometry(0.142, 0.142, 0.14, 40, 1, true),
punctureMaterial
);
punctureSleeve.position.set(holeOffsetX, -0.657, 0);
group.add(punctureSleeve);
const tornRim = new THREE.Mesh(
new THREE.TorusGeometry(0.151, 0.019, 10, 56),
fringeMaterial
);
tornRim.rotation.x = Math.PI / 2;
tornRim.position.set(holeOffsetX, -0.722, 0);
tornRim.castShadow = true;
group.add(tornRim);
// Rolled upper lip
const rim = new THREE.Mesh(
new THREE.TorusGeometry(0.705, 0.036, 14, 72),
accentMaterial
);
rim.rotation.x = Math.PI / 2;
rim.position.y = 0.68;
rim.castShadow = true;
group.add(rim);
// Solid decorative bands
const lowerBand = new THREE.Mesh(
new THREE.TorusGeometry(0.545, 0.016, 8, 64),
accentMaterial
);
lowerBand.rotation.x = Math.PI / 2;
lowerBand.position.y = -0.23;
group.add(lowerBand);
const upperBand = new THREE.Mesh(
new THREE.TorusGeometry(0.635, 0.014, 8, 64),
accentMaterial
);
upperBand.rotation.x = Math.PI / 2;
upperBand.position.y = 0.25;
group.add(upperBand);
// Bottom rolled edge around the rest of the base
const bottomEdge = new THREE.Mesh(
new THREE.TorusGeometry(0.486, 0.018, 8, 64),
accentMaterial
);
bottomEdge.rotation.x = Math.PI / 2;
bottomEdge.position.y = -0.646;
group.add(bottomEdge);
group.updateMatrixWorld(true);
const anchor = group.localToWorld(
new THREE.Vector3(holeOffsetX, -0.705, 0)
);
return { group, anchor };
}
const leftCup = makeCup({
position: new THREE.Vector3(-3.15, 2.65, 0.08),
color: 0xe76f51,
accent: 0x994436,
holeOffsetX: 0.285,
zRotation: 0.1
});
const rightCup = makeCup({
position: new THREE.Vector3(3.15, 2.68, 0.04),
color: 0x2a9d8f,
accent: 0x176b62,
holeOffsetX: -0.285,
zRotation: -0.1
});
// Taut connecting string: a straight tube between the two pierced bases.
const tautCurve = new THREE.LineCurve3(leftCup.anchor, rightCup.anchor);
const tautString = new THREE.Mesh(
new THREE.TubeGeometry(tautCurve, 96, 0.023, 10, false),
stringMaterial
);
tautString.castShadow = true;
scene.add(tautString);
// Small knots sit just beyond the holes, leaving the openings visible.
function makeKnot(position) {
const knot = new THREE.Mesh(
new THREE.SphereGeometry(0.052, 16, 12),
stringMaterial
);
knot.position.copy(position);
knot.scale.set(1.25, 0.8, 1);
knot.castShadow = true;
scene.add(knot);
}
makeKnot(leftCup.anchor.clone().add(new THREE.Vector3(-0.06, -0.012, 0)));
makeKnot(rightCup.anchor.clone().add(new THREE.Vector3(0.06, -0.012, 0)));
// Nearby disconnected string segment with a pronounced sag.
const comparisonPoints = [
new THREE.Vector3(3.82, 2.95, -1.12),
new THREE.Vector3(4.13, 2.75, -1.16),
new THREE.Vector3(4.47, 1.86, -1.21),
new THREE.Vector3(5.06, 1.34, -1.22),
new THREE.Vector3(5.63, 1.55, -1.16),
new THREE.Vector3(5.93, 1.86, -1.1)
];
const comparisonCurve = new THREE.CatmullRomCurve3(
comparisonPoints,
false,
"centripetal"
);
const comparisonString = new THREE.Mesh(
new THREE.TubeGeometry(comparisonCurve, 100, 0.024, 10, false),
stringMaterial
);
comparisonString.castShadow = true;
scene.add(comparisonString);
// Loose fibers emphasize that this piece is separate and unfinished.
function addFiber(points) {
const curve = new THREE.CatmullRomCurve3(points, false, "centripetal");
const fiber = new THREE.Mesh(
new THREE.TubeGeometry(curve, 16, 0.006, 6, false),
fringeMaterial
);
fiber.castShadow = true;
scene.add(fiber);
}
addFiber([
new THREE.Vector3(3.82, 2.95, -1.12),
new THREE.Vector3(3.72, 3.03, -1.11),
new THREE.Vector3(3.66, 3.08, -1.08)
]);
addFiber([
new THREE.Vector3(3.82, 2.95, -1.12),
new THREE.Vector3(3.75, 2.92, -1.06),
new THREE.Vector3(3.68, 2.9, -1.01)
]);
addFiber([
new THREE.Vector3(5.93, 1.86, -1.1),
new THREE.Vector3(6.02, 1.94, -1.08),
new THREE.Vector3(6.07, 2.01, -1.05)
]);
addFiber([
new THREE.Vector3(5.93, 1.86, -1.1),
new THREE.Vector3(6.04, 1.84, -1.05),
new THREE.Vector3(6.11, 1.83, -1.01)
]);
// Canvas-texture labels remain part of the Three.js scene.
function createLabel(text, accentColor) {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 180;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
const x = 18;
const y = 24;
const width = canvas.width - 36;
const height = canvas.height - 48;
const radius = 42;
context.beginPath();
context.moveTo(x + radius, y);
context.lineTo(x + width - radius, y);
context.quadraticCurveTo(x + width, y, x + width, y + radius);
context.lineTo(x + width, y + height - radius);
context.quadraticCurveTo(
x + width,
y + height,
x + width - radius,
y + height
);
context.lineTo(x + radius, y + height);
context.quadraticCurveTo(x, y + height, x, y + height - radius);
context.lineTo(x, y + radius);
context.quadraticCurveTo(x, y, x + radius, y);
context.closePath();
context.fillStyle = "rgba(255, 250, 240, 0.94)";
context.fill();
context.lineWidth = 5;
context.strokeStyle = accentColor;
context.stroke();
context.fillStyle = accentColor;
context.font = "800 43px system-ui, sans-serif";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, canvas.width / 2, canvas.height / 2 + 2);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(2.55, 0.6, 1);
sprite.renderOrder = 20;
return sprite;
}
const connectedLabel = createLabel("TAUT / CONNECTED", "#b95039");
connectedLabel.position.set(0, 1.17, 0.42);
scene.add(connectedLabel);
const saggingLabel = createLabel("SAGGING / DISCONNECTED", "#a66d2e");
saggingLabel.position.set(4.88, 3.25, -1.05);
scene.add(saggingLabel);
// Custom camera controls implemented without Three.js addons.
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 deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
theta -= deltaX * 0.006;
phi = THREE.MathUtils.clamp(phi + deltaY * 0.005, 0.38, 2.62);
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();
radius = THREE.MathUtils.clamp(
radius * Math.exp(event.deltaY * 0.001),
7.5,
19
);
updateCamera();
},
{ passive: false }
);
function resetView() {
theta = 0.48;
phi = 1.67;
radius = 12.8;
updateCamera();
}
renderer.domElement.addEventListener("dblclick", resetView);
document.querySelector("#reset-view").addEventListener("click", resetView);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
renderer.setAnimationLoop(() => {
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 400);
});
</script>
</body>
</html>
```