Prompt specification
Build or customize the Three.js 3D scene "Rug and furniture footprint" 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: Rug and furniture footprint
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/rug-and-furniture-footprint-x0217
Scene Description Prompt:
Place a rectangular rug beneath the front feet of two simple chairs and a table; contrasting floor colors reveal the activity zone without adding physical walls. Build this with Three.js from cdnjs as a stylized scene in one self-contained HTML file.
Working Three.js Starter (rug-and-furniture-footprint-x0217):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shared Table Activity Zone</title>
<style>
:root {
color-scheme: light;
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8e3df;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.info {
position: fixed;
top: 28px;
left: 30px;
z-index: 2;
max-width: min(360px, calc(100vw - 60px));
pointer-events: none;
color: #213c3d;
text-shadow: 0 1px 18px rgba(255, 255, 255, 0.65);
}
.eyebrow {
margin-bottom: 8px;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
opacity: 0.72;
}
h1 {
margin: 0;
font-size: clamp(28px, 4vw, 48px);
font-weight: 750;
line-height: 0.98;
letter-spacing: -0.045em;
}
.subtitle {
margin: 13px 0 0;
max-width: 310px;
font-size: 13px;
font-weight: 550;
line-height: 1.5;
opacity: 0.78;
}
.swatches {
display: flex;
gap: 14px;
margin-top: 17px;
}
.swatch {
display: flex;
align-items: center;
gap: 7px;
font-size: 11px;
font-weight: 700;
opacity: 0.78;
}
.swatch i {
width: 12px;
height: 12px;
border-radius: 3px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.hint {
position: fixed;
right: 24px;
bottom: 22px;
z-index: 2;
padding: 9px 13px;
border: 1px solid rgba(255, 255, 255, 0.52);
border-radius: 999px;
background: rgba(246, 247, 239, 0.68);
color: #294344;
backdrop-filter: blur(10px);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.02em;
pointer-events: none;
}
@media (max-width: 650px) {
.info {
top: 20px;
left: 20px;
}
.subtitle {
max-width: 250px;
}
.swatches {
display: none;
}
.hint {
right: 14px;
bottom: 14px;
font-size: 10px;
}
}
</style>
</head>
<body>
<div class="info">
<div class="eyebrow">Open-floor activity study</div>
<h1>Shared table</h1>
<p class="subtitle">
A warm rug gathers two chairs and a table. Contrasting floor colors
define the activity zone without adding walls.
</p>
<div class="swatches" aria-hidden="true">
<span class="swatch">
<i style="background:#d8c39e"></i>Oak floor
</span>
<span class="swatch">
<i style="background:#739999"></i>Activity zone
</span>
<span class="swatch">
<i style="background:#f0dfc3"></i>Rug
</span>
</div>
</div>
<div class="hint">Drag to orbit · Scroll or pinch to zoom · R to reset</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 renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.domElement.setAttribute(
"aria-label",
"A stylized open floor with two chairs, a table, and a rectangular rug"
);
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd8e3df);
scene.fog = new THREE.Fog(0xd8e3df, 13, 25);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
50
);
// ------------------------------------------------------------
// Procedural textures: no external assets
// ------------------------------------------------------------
function createWoodTexture() {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 1024;
const ctx = canvas.getContext("2d");
const plankWidth = 128;
const plankColors = [
"#d8c19a",
"#dfcba7",
"#d2b990",
"#e1cdab",
"#d7bf98",
"#ddc7a2"
];
ctx.fillStyle = plankColors[0];
ctx.fillRect(0, 0, canvas.width, canvas.height);
for (let x = 0; x < canvas.width; x += plankWidth) {
const colorIndex = Math.floor(x / plankWidth) % plankColors.length;
ctx.fillStyle = plankColors[colorIndex];
ctx.fillRect(x, 0, plankWidth, canvas.height);
// Plank seams.
ctx.strokeStyle = "rgba(94, 66, 42, 0.19)";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(x + 0.5, 0);
ctx.lineTo(x + 0.5, canvas.height);
ctx.stroke();
// Short cross joints.
const joint = ((x * 37) % 820) + 80;
ctx.beginPath();
ctx.moveTo(x, joint);
ctx.lineTo(x + plankWidth, joint);
ctx.stroke();
// Fine grain.
for (let i = 0; i < 28; i++) {
const gx = x + 8 + ((i * 17 + colorIndex * 13) % (plankWidth - 16));
const gy = ((i * 101 + x * 7) % 1024);
const length = 30 + ((i * 29) % 130);
ctx.strokeStyle = `rgba(104, 75, 48, ${0.025 + (i % 3) * 0.009})`;
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(gx, gy);
ctx.bezierCurveTo(
gx + 7, gy + length * 0.25,
gx - 6, gy + length * 0.72,
gx + 2, gy + length
);
ctx.stroke();
}
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(2.6, 2.6);
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function createRugTexture() {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 640;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#f0dfc3";
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Outer woven bands.
ctx.fillStyle = "#c76e54";
ctx.fillRect(22, 22, 980, 28);
ctx.fillRect(22, 590, 980, 28);
ctx.fillRect(22, 22, 28, 596);
ctx.fillRect(974, 22, 28, 596);
ctx.strokeStyle = "#526f70";
ctx.lineWidth = 7;
ctx.strokeRect(68, 68, 888, 504);
ctx.strokeStyle = "#d99a68";
ctx.lineWidth = 3;
ctx.strokeRect(84, 84, 856, 472);
// Repeating diamond motif.
ctx.save();
ctx.translate(512, 320);
for (let row = -2; row <= 2; row++) {
for (let col = -5; col <= 5; col++) {
const x = col * 145 + (row % 2 ? 72 : 0);
const y = row * 85;
ctx.strokeStyle = row % 2 === 0 ? "#526f70" : "#cf7459";
ctx.lineWidth = 6;
ctx.beginPath();
ctx.moveTo(x, y - 29);
ctx.lineTo(x + 42, y);
ctx.lineTo(x, y + 29);
ctx.lineTo(x - 42, y);
ctx.closePath();
ctx.stroke();
ctx.fillStyle = "#d99a68";
ctx.beginPath();
ctx.arc(x, y, 6, 0, Math.PI * 2);
ctx.fill();
}
}
ctx.restore();
// Small warp threads.
ctx.fillStyle = "rgba(76, 96, 91, 0.16)";
for (let y = 68; y < 572; y += 9) {
ctx.fillRect(69, y, 886, 1);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
const woodTexture = createWoodTexture();
const rugTexture = createRugTexture();
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(
0xf8fbf4,
0x8d765d,
2.05
);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff2d8, 3.25);
keyLight.position.set(-4.5, 9, 5.5);
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 = -9;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 25;
keyLight.shadow.bias = -0.00025;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xb9dfe0, 1.15);
fillLight.position.set(6, 4, -5);
scene.add(fillLight);
// ------------------------------------------------------------
// Materials
// ------------------------------------------------------------
const materials = {
floor: new THREE.MeshStandardMaterial({
map: woodTexture,
color: 0xffffff,
roughness: 0.92,
metalness: 0
}),
zone: new THREE.MeshStandardMaterial({
color: 0x739999,
roughness: 0.94,
metalness: 0
}),
zoneLine: new THREE.MeshStandardMaterial({
color: 0xb9d0ca,
roughness: 0.86,
metalness: 0
}),
rugEdge: new THREE.MeshStandardMaterial({
color: 0xc77b60,
roughness: 0.98
}),
rugTop: new THREE.MeshStandardMaterial({
map: rugTexture,
roughness: 1,
metalness: 0
}),
fringe: new THREE.MeshStandardMaterial({
color: 0xe7d4b7,
roughness: 1
}),
tableWood: new THREE.MeshStandardMaterial({
color: 0xa76543,
roughness: 0.68,
metalness: 0
}),
tableDark: new THREE.MeshStandardMaterial({
color: 0x704735,
roughness: 0.74
}),
chair: new THREE.MeshStandardMaterial({
color: 0xe1ae55,
roughness: 0.74
}),
chairFrame: new THREE.MeshStandardMaterial({
color: 0x29494a,
roughness: 0.66,
metalness: 0.06
}),
ceramic: new THREE.MeshStandardMaterial({
color: 0xf5efe2,
roughness: 0.35
}),
coffee: new THREE.MeshStandardMaterial({
color: 0x503428,
roughness: 0.4
}),
bookBlue: new THREE.MeshStandardMaterial({
color: 0x426f78,
roughness: 0.82
}),
bookCream: new THREE.MeshStandardMaterial({
color: 0xe9dfc9,
roughness: 0.88
})
};
// ------------------------------------------------------------
// Geometry helpers
// ------------------------------------------------------------
function addBox(parent, width, height, depth, material, x, y, z) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
parent,
radiusTop,
radiusBottom,
height,
material,
x,
y,
z,
segments = 12
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// ------------------------------------------------------------
// Open floor and contrasting activity zone
// ------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(24, 20),
materials.floor
);
floor.rotation.x = -Math.PI / 2;
floor.receiveShadow = true;
scene.add(floor);
const zone = addBox(
scene,
7.2,
0.06,
5.5,
materials.zone,
0,
0.015,
0.05
);
zone.castShadow = false;
// A restrained inset outline makes the zone legible.
const lineY = 0.052;
addBox(scene, 6.92, 0.012, 0.035, materials.zoneLine, 0, lineY, 2.70);
addBox(scene, 6.92, 0.012, 0.035, materials.zoneLine, 0, lineY, -2.60);
addBox(scene, 0.035, 0.012, 5.30, materials.zoneLine, 3.445, lineY, 0.05);
addBox(scene, 0.035, 0.012, 5.30, materials.zoneLine, -3.445, lineY, 0.05);
// ------------------------------------------------------------
// Rectangular woven rug
// ------------------------------------------------------------
const rugWidth = 5.4;
const rugDepth = 3.8;
const rugCenterZ = 0.05;
const rugBase = addBox(
scene,
rugWidth,
0.035,
rugDepth,
materials.rugEdge,
0,
0.0625,
rugCenterZ
);
rugBase.castShadow = true;
const rugTop = new THREE.Mesh(
new THREE.PlaneGeometry(rugWidth - 0.035, rugDepth - 0.035),
materials.rugTop
);
rugTop.rotation.x = -Math.PI / 2;
rugTop.position.set(0, 0.081, rugCenterZ);
rugTop.receiveShadow = true;
scene.add(rugTop);
// Fringe on the short ends.
for (const side of [-1, 1]) {
for (let i = 0; i < 27; i++) {
const z = rugCenterZ - rugDepth / 2 + 0.07 + i * 0.138;
addBox(
scene,
0.15,
0.012,
0.026,
materials.fringe,
side * (rugWidth / 2 + 0.075),
0.061,
z
);
}
}
// ------------------------------------------------------------
// Table
// ------------------------------------------------------------
const furniture = new THREE.Group();
furniture.position.y = 0.081;
scene.add(furniture);
const table = new THREE.Group();
table.position.z = -0.48;
furniture.add(table);
addBox(
table,
2.35,
0.16,
1.22,
materials.tableWood,
0,
1.13,
0
);
addBox(
table,
1.92,
0.17,
0.88,
materials.tableDark,
0,
0.99,
0
);
// Four gently tapered legs.
const tableLegPositions = [
[-0.88, -0.42],
[ 0.88, -0.42],
[-0.88, 0.42],
[ 0.88, 0.42]
];
for (const [x, z] of tableLegPositions) {
const leg = addCylinder(
table,
0.085,
0.115,
1.07,
materials.tableDark,
x,
0.535,
z,
10
);
leg.rotation.z = x < 0 ? -0.025 : 0.025;
leg.rotation.x = z < 0 ? 0.018 : -0.018;
}
// ------------------------------------------------------------
// Two simple chairs
// ------------------------------------------------------------
function createChair() {
const chair = new THREE.Group();
// Seat.
addBox(
chair,
0.92,
0.16,
0.82,
materials.chair,
0,
0.68,
0
);
// Subtle seat underside.
addBox(
chair,
0.79,
0.07,
0.68,
materials.chairFrame,
0,
0.57,
0
);
// Four legs; front legs are at local negative Z.
const legPositions = [
[-0.34, -0.28],
[ 0.34, -0.28],
[-0.34, 0.28],
[ 0.34, 0.28]
];
for (const [x, z] of legPositions) {
const leg = addCylinder(
chair,
0.058,
0.072,
0.64,
materials.chairFrame,
x,
0.32,
z,
10
);
leg.rotation.z = x < 0 ? -0.025 : 0.025;
leg.rotation.x = z < 0 ? -0.015 : 0.015;
}
// Back supports.
addCylinder(
chair,
0.045,
0.052,
0.69,
materials.chairFrame,
-0.36,
0.99,
0.34,
10
);
addCylinder(
chair,
0.045,
0.052,
0.69,
materials.chairFrame,
0.36,
0.99,
0.34,
10
);
// Gently tilted backrest.
const back = addBox(
chair,
0.92,
0.61,
0.14,
materials.chair,
0,
1.17,
0.35
);
back.rotation.x = 0.09;
return chair;
}
const leftChair = createChair();
leftChair.position.set(-1.38, 0, 0.78);
leftChair.rotation.y = -0.25;
furniture.add(leftChair);
const rightChair = createChair();
rightChair.position.set(1.38, 0, 0.78);
rightChair.rotation.y = 0.25;
furniture.add(rightChair);
// ------------------------------------------------------------
// Small table details
// ------------------------------------------------------------
function createCup() {
const cup = new THREE.Group();
addCylinder(
cup,
0.12,
0.105,
0.22,
materials.ceramic,
0,
0.11,
0,
20
);
const coffee = addCylinder(
cup,
0.099,
0.099,
0.012,
materials.coffee,
0,
0.218,
0,
20
);
coffee.castShadow = false;
const handle = new THREE.Mesh(
new THREE.TorusGeometry(0.075, 0.022, 8, 18),
materials.ceramic
);
handle.position.set(0.125, 0.115, 0);
handle.castShadow = true;
cup.add(handle);
return cup;
}
const cupOne = createCup();
cupOne.position.set(-0.48, 1.215, 0.08);
table.add(cupOne);
const cupTwo = createCup();
cupTwo.position.set(0.47, 1.215, -0.10);
cupTwo.rotation.y = -0.45;
table.add(cupTwo);
addBox(
table,
0.62,
0.065,
0.39,
materials.bookBlue,
0.02,
1.247,
0.28
);
addBox(
table,
0.58,
0.045,
0.36,
materials.bookCream,
0.00,
1.302,
0.27
);
// ------------------------------------------------------------
// Direct camera controls: orbit, wheel zoom, pinch zoom, keys
// ------------------------------------------------------------
const initialRadius =
window.innerWidth / window.innerHeight < 0.8 ? 11.7 : 9.8;
const cameraState = {
theta: 0.38,
phi: 1.05,
radius: initialRadius
};
const desiredState = {
theta: cameraState.theta,
phi: cameraState.phi,
radius: cameraState.radius
};
const cameraTarget = new THREE.Vector3(0, 0.55, 0.05);
function updateCameraPosition() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraTarget.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraTarget.y +
cameraState.radius * Math.cos(cameraState.phi),
cameraTarget.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraTarget);
}
updateCameraPosition();
const pointers = new Map();
let pinchDistance = 0;
function currentPinchDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[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) {
pinchDistance = currentPinchDistance();
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const next = {
x: event.clientX,
y: event.clientY
};
pointers.set(event.pointerId, next);
if (pointers.size === 1) {
const dx = next.x - previous.x;
const dy = next.y - previous.y;
desiredState.theta -= dx * 0.006;
desiredState.phi -= dy * 0.005;
desiredState.phi = THREE.MathUtils.clamp(
desiredState.phi,
0.42,
1.42
);
} else if (pointers.size === 2) {
const distance = currentPinchDistance();
if (pinchDistance > 0 && distance > 0) {
desiredState.radius *= pinchDistance / distance;
desiredState.radius = THREE.MathUtils.clamp(
desiredState.radius,
6.2,
14
);
}
pinchDistance = distance;
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) {
pinchDistance = 0;
}
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener("lostpointercapture", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredState.radius *= Math.exp(event.deltaY * 0.001);
desiredState.radius = THREE.MathUtils.clamp(
desiredState.radius,
6.2,
14
);
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
const step = 0.09;
if (event.key === "ArrowLeft") {
desiredState.theta += step;
} else if (event.key === "ArrowRight") {
desiredState.theta -= step;
} else if (event.key === "ArrowUp") {
desiredState.phi = Math.max(0.42, desiredState.phi - step);
} else if (event.key === "ArrowDown") {
desiredState.phi = Math.min(1.42, desiredState.phi + step);
} else if (event.key === "+" || event.key === "=") {
desiredState.radius = Math.max(6.2, desiredState.radius - 0.5);
} else if (event.key === "-" || event.key === "_") {
desiredState.radius = Math.min(14, desiredState.radius + 0.5);
} else if (event.key.toLowerCase() === "r") {
desiredState.theta = 0.38;
desiredState.phi = 1.05;
desiredState.radius = initialRadius;
} else {
return;
}
event.preventDefault();
});
// ------------------------------------------------------------
// Resize and animation
// ------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const delta = Math.min(clock.getDelta(), 0.05);
const smoothing = 1 - Math.exp(-10 * delta);
cameraState.theta = THREE.MathUtils.lerp(
cameraState.theta,
desiredState.theta,
smoothing
);
cameraState.phi = THREE.MathUtils.lerp(
cameraState.phi,
desiredState.phi,
smoothing
);
cameraState.radius = THREE.MathUtils.lerp(
cameraState.radius,
desiredState.radius,
smoothing
);
updateCameraPosition();
renderer.render(scene, camera);
});
</script>
</body>
</html>
```