Prompt specification
Build or customize the Three.js 3D scene "Birthday table place-setting count" 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: Birthday table place-setting count
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/birthday-table-place-setting-count-x3845
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts birthday table place settings. Arrange plates, cups, and name cards around a small table with one incomplete setting; the missing item should be apparent from matching repeated groups. Voxel style.
Working Three.js Starter (birthday-table-place-setting-count-x3845):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voxel Birthday Table</title>
<style>
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #efe2cf;
font-family: ui-rounded, "Trebuchet MS", system-ui, sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.title-card {
position: fixed;
top: 22px;
left: 22px;
z-index: 2;
padding: 14px 17px;
color: #244f57;
background: rgba(255, 248, 230, 0.9);
border: 2px solid rgba(36, 79, 87, 0.16);
border-radius: 14px;
box-shadow: 0 8px 24px rgba(74, 54, 40, 0.12);
pointer-events: none;
backdrop-filter: blur(5px);
}
.title-card h1 {
margin: 0;
font-size: clamp(18px, 2.2vw, 28px);
line-height: 1;
letter-spacing: 0.04em;
}
.title-card p {
margin: 7px 0 0;
font-size: 12px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
opacity: 0.68;
}
.controls {
position: fixed;
right: 20px;
bottom: 18px;
z-index: 2;
display: flex;
align-items: center;
gap: 12px;
color: #355c61;
font-size: 12px;
font-weight: 700;
pointer-events: none;
}
#reset {
padding: 9px 13px;
color: #fff9e9;
background: #355c61;
border: 0;
border-radius: 9px;
font: inherit;
font-weight: 800;
cursor: pointer;
box-shadow: 0 5px 15px rgba(36, 79, 87, 0.2);
pointer-events: auto;
}
#reset:hover {
background: #244f57;
}
@media (max-width: 600px) {
.title-card {
top: 12px;
left: 12px;
}
.controls {
right: 12px;
bottom: 12px;
}
.controls span {
display: none;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive voxel birthday table scene"></div>
<div class="title-card">
<h1>Happy Birthday!</h1>
<p>Six matching settings · one small mystery</p>
</div>
<div class="controls">
<span>Drag to orbit · Scroll or pinch to zoom</span>
<button id="reset" type="button">Reset view</button>
</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.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xefe2cf);
scene.fog = new THREE.Fog(0xefe2cf, 24, 48);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
sceneHost.appendChild(renderer.domElement);
const colors = {
floor: 0xeadbc5,
rug: 0xe4b99d,
tableEdge: 0xa95f45,
tabletop: 0xc9825d,
runner: 0x70b9aa,
cream: 0xfff3d8,
blush: 0xf5c7bd,
coral: 0xef6b5b,
teal: 0x6fc1b1,
lavender: 0xb7a4df,
darkTeal: 0x315a60,
metal: 0x64777a,
card: 0xf8e3a7,
cake: 0xf6c3ae,
frosting: 0xfff5df,
candle: 0x66b9ab,
flame: 0xffad45,
coffee: 0x704638
};
const materialCache = new Map();
function material(color) {
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0
})
);
}
return materialCache.get(color);
}
function box(parent, width, height, depth, color, x = 0, y = 0, z = 0, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material(color)
);
mesh.position.set(x, y, z);
mesh.castShadow = options.cast !== false;
mesh.receiveShadow = options.receive !== false;
parent.add(mesh);
return mesh;
}
function textTexture(text, background, foreground, width = 512, height = 200) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const context = canvas.getContext("2d");
context.fillStyle = background;
context.fillRect(0, 0, width, height);
context.fillStyle = foreground;
context.textAlign = "center";
context.textBaseline = "middle";
context.font = `800 ${Math.floor(height * 0.43)}px "Trebuchet MS", sans-serif`;
context.fillText(text, width / 2, height / 2 + height * 0.025);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
// Lighting
scene.add(new THREE.HemisphereLight(0xfff8e9, 0x8d7469, 2.1));
const keyLight = new THREE.DirectionalLight(0xfff3d6, 3.2);
keyLight.position.set(7, 13, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -11;
keyLight.shadow.camera.right = 11;
keyLight.shadow.camera.top = 11;
keyLight.shadow.camera.bottom = -11;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xb9dce0, 1.25);
fillLight.position.set(-8, 7, -6);
scene.add(fillLight);
// Floor and rug
box(scene, 32, 0.16, 32, colors.floor, 0, -0.08, 0, { cast: false });
box(scene, 12.8, 0.045, 8.0, colors.rug, 0, 0.022, 0, { cast: false });
// Rug border made from chunky blocks.
box(scene, 13.2, 0.065, 0.22, 0xcf9579, 0, 0.045, 4.02, { cast: false });
box(scene, 13.2, 0.065, 0.22, 0xcf9579, 0, 0.045, -4.02, { cast: false });
box(scene, 0.22, 0.065, 7.8, 0xcf9579, 6.52, 0.045, 0, { cast: false });
box(scene, 0.22, 0.065, 7.8, 0xcf9579, -6.52, 0.045, 0, { cast: false });
// Table
const tableY = 2.87;
box(scene, 11.0, 0.55, 6.6, colors.tableEdge, 0, 2.45, 0);
box(scene, 10.7, 0.18, 6.3, colors.tabletop, 0, 2.78, 0);
for (const x of [-4.45, 4.45]) {
for (const z of [-2.45, 2.45]) {
box(scene, 0.68, 2.2, 0.68, colors.tableEdge, x, 1.1, z);
}
}
// Aprons
box(scene, 9.2, 0.42, 0.2, colors.tableEdge, 0, 2.12, 2.75);
box(scene, 9.2, 0.42, 0.2, colors.tableEdge, 0, 2.12, -2.75);
box(scene, 0.2, 0.42, 5.5, colors.tableEdge, 4.95, 2.12, 0);
box(scene, 0.2, 0.42, 5.5, colors.tableEdge, -4.95, 2.12, 0);
// Table runner
box(scene, 8.4, 0.05, 2.15, colors.runner, 0, 2.895, 0);
function makeCup(parent, x, z) {
const cup = new THREE.Group();
cup.position.set(x, 0, z);
parent.add(cup);
// Open, square voxel mug.
box(cup, 0.54, 0.09, 0.54, colors.coral, 0, 0.105, 0);
box(cup, 0.54, 0.44, 0.08, colors.coral, 0, 0.35, 0.23);
box(cup, 0.54, 0.44, 0.08, colors.coral, 0, 0.35, -0.23);
box(cup, 0.08, 0.44, 0.38, colors.coral, 0.23, 0.35, 0);
box(cup, 0.08, 0.44, 0.38, colors.coral, -0.23, 0.35, 0);
// Coffee surface.
box(cup, 0.35, 0.025, 0.35, colors.coffee, 0, 0.505, 0);
// Blocky handle.
box(cup, 0.11, 0.34, 0.12, colors.coral, 0.36, 0.35, 0);
box(cup, 0.17, 0.10, 0.12, colors.coral, 0.29, 0.20, 0);
box(cup, 0.17, 0.10, 0.12, colors.coral, 0.29, 0.50, 0);
return cup;
}
function makeNameCard(parent, name) {
const cardGroup = new THREE.Group();
cardGroup.position.set(0, 0, 1.03);
parent.add(cardGroup);
box(cardGroup, 0.92, 0.10, 0.36, colors.card, 0, 0.05, 0);
const texture = textTexture(name, "#f8e3a7", "#315a60", 512, 200);
const label = new THREE.Mesh(
new THREE.PlaneGeometry(0.92, 0.36),
new THREE.MeshBasicMaterial({
map: texture,
toneMapped: false
})
);
label.rotation.x = -Math.PI / 2;
label.position.y = 0.102;
cardGroup.add(label);
}
function makePlaceSetting(name, x, z, backFacing, includeCup) {
const setting = new THREE.Group();
setting.position.set(x, tableY + 0.025, z);
setting.rotation.y = backFacing ? Math.PI : 0;
scene.add(setting);
// Square stepped plate.
box(setting, 1.55, 0.12, 1.38, colors.cream, 0, 0.06, 0);
box(setting, 1.27, 0.055, 1.10, colors.blush, 0, 0.1475, 0);
// Folded napkin.
box(setting, 0.55, 0.09, 0.78, colors.lavender, -1.02, 0.05, 0.08);
box(setting, 0.43, 0.035, 0.31, 0xc9b9ed, -1.02, 0.11, 0.02);
// Pixel-style fork.
box(setting, 0.12, 0.075, 0.65, colors.metal, -1.02, 0.15, 0.08);
box(setting, 0.31, 0.075, 0.13, colors.metal, -1.02, 0.15, 0.47);
for (let i = 0; i < 4; i++) {
box(
setting,
0.045,
0.075,
0.17,
colors.metal,
-1.135 + i * 0.077,
0.15,
0.57
);
}
// Pixel-style knife.
box(setting, 0.16, 0.075, 0.42, colors.metal, 1.02, 0.15, 0.28);
box(setting, 0.14, 0.085, 0.38, colors.darkTeal, 1.02, 0.15, -0.07);
// Every place setting has a matching coaster.
box(setting, 0.66, 0.06, 0.66, colors.teal, 0.97, 0.03, -0.95);
// One cup is deliberately absent.
if (includeCup) {
makeCup(setting, 0.97, -0.95);
}
makeNameCard(setting, name);
}
// Front row
makePlaceSetting("JUNE", -3.25, 1.85, false, true);
makePlaceSetting("MAX", 0, 1.85, false, true);
makePlaceSetting("NORA", 3.25, 1.85, false, false);
// Back row
makePlaceSetting("AVA", -3.25, -1.85, true, true);
makePlaceSetting("LEO", 0, -1.85, true, true);
makePlaceSetting("ELI", 3.25, -1.85, true, true);
// Birthday cake
const cake = new THREE.Group();
cake.position.set(0, tableY + 0.05, 0.05);
scene.add(cake);
box(cake, 2.02, 0.12, 1.42, colors.cream, 0, 0.06, 0.13);
box(cake, 1.62, 0.55, 1.06, colors.cake, 0, 0.395, 0.13);
box(cake, 1.70, 0.11, 1.14, colors.frosting, 0, 0.725, 0.13);
// Frosting drips.
for (let i = 0; i < 6; i++) {
const dripHeight = i % 2 === 0 ? 0.17 : 0.12;
box(
cake,
0.18,
dripHeight,
0.07,
colors.frosting,
-0.63 + i * 0.25,
0.62,
0.70
);
}
// Pixel sprinkles on the cake.
const sprinkleColors = [colors.coral, colors.teal, colors.lavender, colors.card];
for (let i = 0; i < 12; i++) {
const column = i % 4;
const row = Math.floor(i / 4);
box(
cake,
0.10,
0.055,
0.10,
sprinkleColors[i % sprinkleColors.length],
-0.52 + column * 0.35,
0.82,
-0.22 + row * 0.30
);
}
const flames = [];
// Three voxel candles.
for (let i = 0; i < 3; i++) {
const candleX = -0.45 + i * 0.45;
box(cake, 0.12, 0.36, 0.12, colors.candle, candleX, 0.98, 0.10);
box(cake, 0.025, 0.09, 0.025, colors.darkTeal, candleX, 1.205, 0.10);
const flameMaterial = new THREE.MeshStandardMaterial({
color: colors.flame,
emissive: 0xff7b20,
emissiveIntensity: 1.4,
roughness: 1
});
const flame = new THREE.Mesh(
new THREE.BoxGeometry(0.14, 0.20, 0.14),
flameMaterial
);
flame.position.set(candleX, 1.34, 0.10);
flame.castShadow = false;
cake.add(flame);
flames.push({ mesh: flame, baseY: flame.position.y, phase: i * 1.8 });
}
const cakeGlow = new THREE.PointLight(0xffa04b, 3.2, 4.5, 2);
cakeGlow.position.set(0, 1.25, 0.1);
cake.add(cakeGlow);
// Birthday sign behind the cake.
const sign = new THREE.Group();
sign.position.set(0, 0, -0.63);
cake.add(sign);
box(sign, 2.12, 0.54, 0.10, colors.cream, 0, 1.18, 0);
const signTexture = textTexture(
"HAPPY BIRTHDAY",
"#fff5df",
"#315a60",
1024,
256
);
const signFace = new THREE.Mesh(
new THREE.PlaneGeometry(2.08, 0.52),
new THREE.MeshBasicMaterial({
map: signTexture,
toneMapped: false
})
);
signFace.position.set(0, 1.18, 0.056);
sign.add(signFace);
box(sign, 0.08, 0.62, 0.08, colors.coral, -0.77, 0.70, 0);
box(sign, 0.08, 0.62, 0.08, colors.coral, 0.77, 0.70, 0);
// Tiny confetti blocks on the runner.
let seed = 1729;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
for (let i = 0; i < 28; i++) {
const confetti = box(
scene,
0.09,
0.045,
0.09,
sprinkleColors[i % sprinkleColors.length],
-3.8 + random() * 7.6,
tableY + 0.075,
-0.83 + random() * 1.66
);
confetti.rotation.y = random() * Math.PI;
}
// Simple camera orbit controls implemented directly, without addons.
const view = {
target: new THREE.Vector3(0, 2.35, 0),
radius: 15.7,
theta: 0.72,
phi: 0.88
};
const defaultView = {
radius: 15.7,
theta: 0.72,
phi: 0.88
};
function updateCamera() {
const sinPhi = Math.sin(view.phi);
camera.position.set(
view.target.x + view.radius * sinPhi * Math.sin(view.theta),
view.target.y + view.radius * Math.cos(view.phi),
view.target.z + view.radius * sinPhi * Math.cos(view.theta)
);
camera.lookAt(view.target);
}
function resetView() {
view.radius = defaultView.radius;
view.theta = defaultView.theta;
view.phi = defaultView.phi;
}
const pointers = new Map();
let lastPinchDistance = 0;
function currentPinchDistance() {
const points = [...pointers.values()];
if (points.length < 2) return 0;
return Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
lastPinchDistance = currentPinchDistance();
}
});
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 === 1) {
view.theta -= dx * 0.006;
view.phi -= dy * 0.006;
view.phi = THREE.MathUtils.clamp(view.phi, 0.28, 1.43);
} else if (pointers.size === 2) {
const distance = currentPinchDistance();
if (lastPinchDistance > 0 && distance > 0) {
view.radius *= lastPinchDistance / distance;
view.radius = THREE.MathUtils.clamp(view.radius, 10, 24);
}
lastPinchDistance = distance;
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
lastPinchDistance = pointers.size === 2 ? currentPinchDistance() : 0;
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
view.radius += event.deltaY * 0.012;
view.radius = THREE.MathUtils.clamp(view.radius, 10, 24);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
document.getElementById("reset").addEventListener("click", resetView);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const clock = new THREE.Clock();
function animate() {
const time = clock.getElapsedTime();
for (const flame of flames) {
flame.mesh.scale.y = 1 + Math.sin(time * 9 + flame.phase) * 0.12;
flame.mesh.position.y =
flame.baseY + Math.sin(time * 7 + flame.phase) * 0.018;
}
updateCamera();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
updateCamera();
animate();
</script>
</body>
</html>
```