Prompt specification
Build or customize the Three.js 3D scene "Welcome basket object relationships" 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: Welcome basket object relationships
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/welcome-basket-object-relationships-x3889
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: welcome basket object relationships. Arrange folded baby clothes, a greeting card, and an empty storage basket beside a family photo represented by simple silhouettes; each object should have a clear purpose. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (welcome-basket-object-relationships-x3889):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Welcome Basket</title>
<style>
:root {
--ink: #30454a;
--muted: #6d7d7d;
--paper: rgba(255, 253, 247, 0.9);
--line: rgba(48, 69, 74, 0.2);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #eee9de;
color: var(--ink);
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;
cursor: grab;
outline: none;
}
canvas.dragging {
cursor: grabbing;
}
.intro {
position: fixed;
top: 28px;
left: 30px;
z-index: 5;
width: min(390px, calc(100vw - 60px));
padding: 20px 22px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 18px;
background: var(--paper);
box-shadow: 0 18px 50px rgba(58, 69, 65, 0.12);
backdrop-filter: blur(12px);
pointer-events: none;
}
.kicker {
margin-bottom: 8px;
color: #b46752;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 3vw, 42px);
font-weight: 500;
line-height: 1.02;
letter-spacing: -0.025em;
}
.intro p {
max-width: 330px;
margin: 12px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
#labels {
position: fixed;
inset: 0;
z-index: 4;
overflow: hidden;
pointer-events: none;
}
.callout {
position: absolute;
display: flex;
align-items: flex-start;
gap: 9px;
min-width: 150px;
padding: 9px 12px;
border: 1px solid rgba(48, 69, 74, 0.13);
border-radius: 11px;
background: rgba(255, 253, 247, 0.93);
box-shadow: 0 9px 25px rgba(49, 62, 60, 0.12);
transform: translate(-50%, calc(-100% - 16px));
transition: opacity 160ms ease;
backdrop-filter: blur(8px);
}
.callout::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
width: 1px;
height: 16px;
background: rgba(48, 69, 74, 0.35);
}
.callout::before {
content: "";
position: absolute;
top: calc(100% + 13px);
left: calc(50% - 3px);
width: 7px;
height: 7px;
border: 2px solid #fffaf0;
border-radius: 50%;
background: var(--dot, var(--ink));
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}
.swatch {
flex: 0 0 auto;
width: 9px;
height: 9px;
margin-top: 4px;
border-radius: 3px;
background: var(--dot);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 18%, transparent);
}
.callout strong {
display: block;
font-size: 11px;
line-height: 1.25;
letter-spacing: 0.01em;
}
.callout small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
line-height: 1.3;
}
.controls {
position: fixed;
right: 25px;
bottom: 22px;
z-index: 6;
display: flex;
align-items: center;
gap: 10px;
}
.hint {
padding: 8px 11px;
border-radius: 999px;
background: rgba(255, 253, 247, 0.82);
color: var(--muted);
font-size: 10px;
letter-spacing: 0.02em;
backdrop-filter: blur(8px);
pointer-events: none;
}
button {
border: 1px solid rgba(48, 69, 74, 0.16);
border-radius: 999px;
padding: 9px 13px;
background: #fffdf7;
color: var(--ink);
font: inherit;
font-size: 10px;
font-weight: 700;
cursor: pointer;
box-shadow: 0 8px 20px rgba(49, 62, 60, 0.1);
}
button:hover {
background: #fff;
transform: translateY(-1px);
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #eee9de;
color: var(--ink);
font-size: 12px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
#loading::before {
content: "";
width: 24px;
height: 24px;
margin-right: 12px;
border: 3px solid rgba(48, 69, 74, 0.15);
border-top-color: #c77b60;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
#loading {
grid-auto-flow: column;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (max-width: 700px) {
.intro {
top: 14px;
left: 14px;
width: min(330px, calc(100vw - 28px));
padding: 15px 17px;
border-radius: 14px;
}
.intro p {
display: none;
}
h1 {
font-size: 27px;
}
.callout {
min-width: 0;
padding: 7px 9px;
gap: 6px;
border-radius: 9px;
}
.callout strong {
font-size: 9px;
}
.callout small {
font-size: 8px;
}
.controls {
right: 14px;
bottom: 14px;
}
.hint {
display: none;
}
}
@media (max-height: 560px) {
.intro p,
.hint {
display: none;
}
}
</style>
</head>
<body>
<canvas
id="scene"
tabindex="0"
role="img"
aria-label="A voxel-style welcome scene with folded baby clothes, a greeting card, an empty storage basket, and a family photo made from simple silhouettes."
></canvas>
<header class="intro">
<div class="kicker">Voxel welcome · object study</div>
<h1>Ready for a new beginning.</h1>
<p>
Folded comfort, a warm welcome, room to organize, and family at the center—
each object with a clear purpose.
</p>
</header>
<div id="labels" aria-hidden="true">
<div
class="callout"
id="label-clothes"
style="--dot:#91aaa0"
>
<span class="swatch"></span>
<div>
<strong>Folded baby clothes</strong>
<small>Comfort, ready to wear</small>
</div>
</div>
<div
class="callout"
id="label-card"
style="--dot:#d78c73"
>
<span class="swatch"></span>
<div>
<strong>Greeting card</strong>
<small>A warm personal welcome</small>
</div>
</div>
<div
class="callout"
id="label-basket"
style="--dot:#c69b62"
>
<span class="swatch"></span>
<div>
<strong>Empty storage basket</strong>
<small>Room for what comes next</small>
</div>
</div>
<div
class="callout"
id="label-photo"
style="--dot:#789aaa"
>
<span class="swatch"></span>
<div>
<strong>Family photo</strong>
<small>The people and memories waiting</small>
</div>
</div>
</div>
<div class="controls">
<div class="hint">Drag to orbit · Scroll to zoom · Double-click to reset</div>
<button id="reset" type="button">Reset view</button>
</div>
<div id="loading">Building welcome scene</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const loading = document.querySelector("#loading");
const renderer = new THREE.WebGLRenderer({
canvas,
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;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#eee9de");
scene.fog = new THREE.Fog("#eee9de", 15, 27);
const camera = new THREE.OrthographicCamera(-6, 6, 4, -4, 0.1, 50);
const cameraTarget = new THREE.Vector3(0, 1.05, 0);
let yaw = 0.48;
let pitch = 0.52;
let zoom = 1;
const cameraRadius = 11.5;
const hemi = new THREE.HemisphereLight("#fff8e9", "#82908e", 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight("#fff1d9", 3.25);
sun.position.set(5.5, 8.5, 6.5);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -8;
sun.shadow.camera.right = 8;
sun.shadow.camera.top = 8;
sun.shadow.camera.bottom = -8;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 25;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight("#b9d6e1", 1.1);
fill.position.set(-5, 4, 3);
scene.add(fill);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
function material(color, roughness = 0.82, metalness = 0) {
return new THREE.MeshStandardMaterial({
color,
roughness,
metalness
});
}
const M = {
floorEdge: material("#c8bea9"),
floor: material("#e9e2d4"),
rug: material("#cbd5cf"),
rugBorder: material("#e6ddcd"),
wood: material("#b88458"),
woodLight: material("#d2a66f"),
woodDark: material("#76533e"),
bench: material("#bca37f"),
basket: material("#c79a62"),
basketLight: material("#d7ae78"),
basketDark: material("#79583f"),
blue: material("#8fb5c5"),
sage: material("#91aaa0"),
blush: material("#d99a88"),
cream: material("#fff2d8"),
gold: material("#e3b65f"),
coral: material("#c8755d"),
navy: material("#344b55"),
photoSky: material("#b8d1d9"),
photoGround: material("#d9d2b8")
};
function box(parent, mat, size, position, options = {}) {
const mesh = new THREE.Mesh(unitBox, mat);
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = options.cast !== false;
mesh.receiveShadow = options.receive !== false;
parent.add(mesh);
return mesh;
}
// Diorama floor and softly inset woven mat.
box(scene, M.floorEdge, [12, 0.3, 8], [0, -0.25, 0]);
box(scene, M.floor, [11.94, 0.06, 7.94], [0, -0.07, 0]);
box(scene, M.rug, [8.15, 0.05, 4.4], [0.05, -0.015, 0.15]);
box(scene, M.rugBorder, [7.85, 0.012, 4.1], [0.05, 0.016, 0.15]);
// Low bench holding the folded baby clothes.
const clothesGroup = new THREE.Group();
clothesGroup.position.set(-2.25, 0, -0.38);
scene.add(clothesGroup);
for (const x of [-0.88, 0.88]) {
for (const z of [-0.45, 0.45]) {
box(clothesGroup, M.woodDark, [0.16, 0.31, 0.16], [x, 0.16, z]);
}
}
box(clothesGroup, M.bench, [2.18, 0.14, 1.22], [0, 0.36, 0]);
function foldedOnesie(parent, color, y, z, accent) {
const garment = new THREE.Group();
garment.position.z = z;
parent.add(garment);
// Main folded body and small sleeves.
box(garment, color, [1.02, 0.16, 0.7], [0, y, 0]);
box(garment, color, [0.28, 0.13, 0.42], [-0.62, y - 0.005, 0]);
box(garment, color, [0.28, 0.13, 0.42], [0.62, y - 0.005, 0]);
// Folded lower section and visible neckline.
box(garment, color, [0.43, 0.105, 0.29], [0, y - 0.008, 0.47]);
box(garment, accent, [0.25, 0.024, 0.12], [0, y + 0.092, -0.22]);
// Tiny voxel buttons make the garment read as baby clothing.
box(garment, M.cream, [0.055, 0.025, 0.055], [0, y + 0.097, 0.12]);
box(garment, M.cream, [0.055, 0.025, 0.055], [0, y + 0.097, 0.23]);
}
foldedOnesie(clothesGroup, M.sage, 0.51, 0.03, M.cream);
foldedOnesie(clothesGroup, M.blue, 0.69, -0.02, M.cream);
foldedOnesie(clothesGroup, M.blush, 0.87, 0.02, M.cream);
// Open greeting card with a pixel heart.
const cardGroup = new THREE.Group();
cardGroup.position.set(-0.42, 0, 0.78);
cardGroup.rotation.y = -0.12;
scene.add(cardGroup);
box(cardGroup, M.woodDark, [1.43, 0.11, 0.48], [0, 0.065, 0.08]);
const leftCard = new THREE.Group();
leftCard.position.set(-0.31, 0.63, 0.02);
leftCard.rotation.y = 0.12;
cardGroup.add(leftCard);
const rightCard = new THREE.Group();
rightCard.position.set(0.31, 0.63, 0.02);
rightCard.rotation.y = -0.12;
cardGroup.add(rightCard);
box(leftCard, M.blush, [0.63, 0.9, 0.065], [0, 0, 0]);
box(rightCard, M.cream, [0.63, 0.9, 0.065], [0, 0, 0]);
// Small greeting marks on the left page.
const markRows = ["00100", "01110", "11111", "01110", "00100"];
markRows.forEach((row, y) => {
[...row].forEach((cell, x) => {
if (cell === "1") {
box(
leftCard,
M.cream,
[0.045, 0.045, 0.018],
[(x - 2) * 0.055, (2 - y) * 0.055, 0.041],
{ cast: false }
);
}
});
});
const heartRows = ["01110", "11111", "11111", "01110", "00100"];
heartRows.forEach((row, y) => {
[...row].forEach((cell, x) => {
if (cell === "1") {
box(
rightCard,
M.coral,
[0.07, 0.07, 0.025],
[(x - 2) * 0.078, (2 - y) * 0.078, 0.044],
{ cast: false }
);
}
});
});
// Open-top storage basket. Nothing is placed inside it.
const basketGroup = new THREE.Group();
basketGroup.position.set(1.05, 0, 0.57);
scene.add(basketGroup);
box(basketGroup, M.basketDark, [1.58, 0.11, 1.16], [0, 0.075, 0]);
// Corner uprights.
for (const x of [-0.78, 0.78]) {
for (const z of [-0.57, 0.57]) {
box(basketGroup, M.basketDark, [0.14, 1.02, 0.14], [x, 0.58, z]);
}
}
// Upper and lower rims.
for (const z of [-0.61, 0.61]) {
box(basketGroup, M.basketLight, [1.72, 0.11, 0.13], [0, 0.22, z]);
box(basketGroup, M.basketLight, [1.72, 0.12, 0.14], [0, 1.08, z]);
}
for (const x of [-0.79, 0.79]) {
box(basketGroup, M.basketLight, [0.13, 0.11, 1.28], [x, 0.22, 0]);
box(basketGroup, M.basketLight, [0.14, 0.12, 1.28], [x, 1.08, 0]);
}
// Vertical voxel slats leave the basket visibly open and ventilated.
for (let i = 0; i < 9; i++) {
const x = -0.72 + i * 0.18;
const slatMat = i % 2 === 0 ? M.basket : M.basketLight;
box(basketGroup, slatMat, [0.105, 0.73, 0.09], [x, 0.64, -0.61]);
box(basketGroup, slatMat, [0.105, 0.73, 0.09], [x, 0.64, 0.61]);
}
for (let i = 0; i < 7; i++) {
const z = -0.54 + i * 0.18;
const slatMat = i % 2 === 0 ? M.basketLight : M.basket;
box(basketGroup, slatMat, [0.09, 0.73, 0.105], [-0.79, 0.64, z]);
box(basketGroup, slatMat, [0.09, 0.73, 0.105], [0.79, 0.64, z]);
}
// Family photo, built from simple block silhouettes.
const photoGroup = new THREE.Group();
photoGroup.position.set(2.52, 1.8, -1.78);
photoGroup.rotation.y = -0.08;
scene.add(photoGroup);
box(photoGroup, M.woodDark, [2.68, 2.18, 0.16], [0, 0, 0]);
box(photoGroup, M.cream, [2.43, 1.93, 0.045], [0, 0, 0.102], {
cast: false
});
box(photoGroup, M.photoSky, [2.2, 1.7, 0.05], [0, 0, 0.145], {
cast: false
});
// Simple pixel landscape behind the family.
box(photoGroup, M.photoGround, [2.18, 0.22, 0.015], [0, -0.73, 0.177], {
cast: false
});
box(photoGroup, M.sage, [0.34, 0.25, 0.015], [-0.73, -0.57, 0.179], {
cast: false
});
box(photoGroup, M.sage, [0.44, 0.34, 0.015], [0.76, -0.5, 0.179], {
cast: false
});
function silhouette(parent, x, y, scale = 1) {
const person = new THREE.Group();
person.position.set(x, y, 0.195);
person.scale.setScalar(scale);
parent.add(person);
box(person, M.navy, [0.23, 0.23, 0.04], [0, 0.59, 0], {
cast: false
});
box(person, M.navy, [0.39, 0.53, 0.04], [0, 0.16, 0], {
cast: false
});
box(person, M.navy, [0.13, 0.44, 0.04], [-0.105, -0.31, 0], {
cast: false
});
box(person, M.navy, [0.13, 0.44, 0.04], [0.105, -0.31, 0], {
cast: false
});
const leftArm = box(
person,
M.navy,
[0.105, 0.43, 0.04],
[-0.255, 0.15, 0],
{ cast: false }
);
leftArm.rotation.z = -0.13;
const rightArm = box(
person,
M.navy,
[0.105, 0.43, 0.04],
[0.255, 0.15, 0],
{ cast: false }
);
rightArm.rotation.z = 0.13;
}
silhouette(photoGroup, -0.63, -0.04, 1);
silhouette(photoGroup, 0.63, -0.04, 1);
silhouette(photoGroup, 0, -0.2, 0.67);
// Voxel easel supporting the framed photo.
box(photoGroup, M.wood, [0.16, 0.88, 0.16], [0, -1.31, -0.12]);
box(photoGroup, M.woodDark, [1.3, 0.12, 0.48], [0, -1.72, -0.04]);
function updateCamera() {
const aspect = window.innerWidth / window.innerHeight;
const viewHeight = Math.max(7.35, 9.35 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.zoom = zoom;
camera.updateProjectionMatrix();
const horizontal = cameraRadius * Math.cos(pitch);
camera.position.set(
cameraTarget.x + horizontal * Math.sin(yaw),
cameraTarget.y + cameraRadius * Math.sin(pitch),
cameraTarget.z + horizontal * Math.cos(yaw)
);
camera.lookAt(cameraTarget);
camera.updateMatrixWorld();
}
function resetCamera() {
yaw = 0.48;
pitch = 0.52;
zoom = 1;
updateCamera();
}
const labelData = [
{
element: document.querySelector("#label-clothes"),
anchor: new THREE.Vector3(-2.25, 1.12, -0.38)
},
{
element: document.querySelector("#label-card"),
anchor: new THREE.Vector3(-0.42, 1.17, 0.78)
},
{
element: document.querySelector("#label-basket"),
anchor: new THREE.Vector3(1.05, 1.3, 0.57)
},
{
element: document.querySelector("#label-photo"),
anchor: new THREE.Vector3(2.52, 3.02, -1.78)
}
];
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const item of labelData) {
projected.copy(item.anchor).project(camera);
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
const visible =
projected.z > -1 &&
projected.z < 1 &&
x > -80 &&
x < width + 80 &&
y > -80 &&
y < height + 80;
item.element.style.left = `${x}px`;
item.element.style.top = `${y}px`;
item.element.style.opacity = visible ? "1" : "0";
}
}
let dragging = false;
let pointerX = 0;
let pointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
yaw -= dx * 0.006;
pitch = THREE.MathUtils.clamp(pitch + dy * 0.005, 0.28, 1.02);
updateCamera();
});
function endDrag(event) {
dragging = false;
canvas.classList.remove("dragging");
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
zoom = THREE.MathUtils.clamp(
zoom * Math.exp(-event.deltaY * 0.001),
0.72,
1.5
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetCamera);
document.querySelector("#reset").addEventListener("click", resetCamera);
canvas.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
yaw += 0.08;
break;
case "ArrowRight":
yaw -= 0.08;
break;
case "ArrowUp":
pitch = THREE.MathUtils.clamp(pitch + 0.06, 0.28, 1.02);
break;
case "ArrowDown":
pitch = THREE.MathUtils.clamp(pitch - 0.06, 0.28, 1.02);
break;
case "+":
case "=":
zoom = THREE.MathUtils.clamp(zoom + 0.08, 0.72, 1.5);
break;
case "-":
zoom = THREE.MathUtils.clamp(zoom - 0.08, 0.72, 1.5);
break;
case "0":
resetCamera();
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
updateCamera();
}
});
window.addEventListener("resize", () => {
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
updateCamera();
});
updateCamera();
renderer.setAnimationLoop(() => {
renderer.render(scene, camera);
updateLabels();
});
requestAnimationFrame(() => loading.remove());
</script>
</body>
</html>
```