Prompt specification
Build or customize the Three.js 3D scene "Schoolbag name-tag matching" 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: Schoolbag name-tag matching
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/schoolbag-name-tag-matching-x3861
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring a child's first day at school. Show a schoolbag, cubby, and desk card carrying the same simple personal symbol; distinguish that set from neighboring belongings without relying on text alone. Stylized solid forms.
Working Three.js Starter (schoolbag-name-tag-matching-x3861):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>A Child's First Day at School</title>
<style>
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #f4eee4;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
#hud {
position: fixed;
top: 20px;
left: 20px;
max-width: calc(100vw - 40px);
padding: 12px 16px;
color: #294a55;
background: rgba(255, 252, 244, 0.88);
border: 1px solid rgba(47, 159, 179, 0.25);
border-radius: 16px;
box-shadow: 0 8px 30px rgba(57, 65, 67, 0.12);
backdrop-filter: blur(8px);
pointer-events: none;
user-select: none;
}
#hud strong {
display: block;
margin-bottom: 3px;
font-size: 15px;
letter-spacing: 0.01em;
}
#hud span {
display: block;
font-size: 12px;
opacity: 0.72;
}
@media (max-width: 560px) {
#hud {
top: 12px;
left: 12px;
padding: 10px 13px;
}
#hud span {
font-size: 11px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div id="hud">
<strong>First day at school</strong>
<span>Drag to orbit · Scroll to zoom · Double-click to reset</span>
</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.getElementById("scene");
// -------------------------------------------------------------------------
// Renderer, scene, camera, and lighting
// -------------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({ antialias: true });
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;
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf4eee4);
scene.fog = new THREE.Fog(0xf4eee4, 14, 25);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
60
);
const target = new THREE.Vector3(0, 1.3, -0.5);
let azimuth = 0.48;
let polar = 1.08;
let radius = 11.2;
function updateCamera() {
const horizontal = Math.sin(polar) * radius;
camera.position.set(
target.x + horizontal * Math.sin(azimuth),
target.y + Math.cos(polar) * radius,
target.z + horizontal * Math.cos(azimuth)
);
camera.lookAt(target);
}
updateCamera();
const hemisphere = new THREE.HemisphereLight(0xfff8e8, 0x7895a4, 2.2);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffefd4, 3.2);
keyLight.position.set(-4, 8, 6);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -7;
keyLight.shadow.camera.right = 7;
keyLight.shadow.camera.top = 7;
keyLight.shadow.camera.bottom = -3;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 22;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xb9e5ef, 1.25);
fillLight.position.set(5, 4, -1);
scene.add(fillLight);
// -------------------------------------------------------------------------
// Materials
// -------------------------------------------------------------------------
const material = (color, roughness = 0.78, metalness = 0) =>
new THREE.MeshStandardMaterial({
color,
roughness,
metalness
});
const mats = {
floor: material(0xd9c3a4),
wall: material(0xf1d9c8),
baseboard: material(0x8eb8b8),
rug: material(0xb8d8d3),
cream: material(0xfff8e9),
wood: material(0xb97645),
woodLight: material(0xd19a68),
woodDark: material(0x925b3d),
teal: material(0x2f9fb3),
tealDark: material(0x236f81),
sky: material(0x8dd4e5),
yellow: material(0xffc83d, 0.6),
coral: material(0xef7467),
green: material(0x70a66e),
purple: material(0x9078b5),
dark: material(0x34434c),
skin: material(0xe8aa80),
hair: material(0x56392c),
shoe: material(0x36505b),
pink: material(0xeaa39a)
};
// -------------------------------------------------------------------------
// Geometry helpers
// -------------------------------------------------------------------------
function box(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 rounded(parent, w, h, d, radius, x, y, z, mat) {
const r = Math.min(radius, w / 2, h / 2);
const shape = new THREE.Shape();
const left = -w / 2;
const bottom = -h / 2;
shape.moveTo(left + r, bottom);
shape.lineTo(left + w - r, bottom);
shape.quadraticCurveTo(left + w, bottom, left + w, bottom + r);
shape.lineTo(left + w, bottom + h - r);
shape.quadraticCurveTo(
left + w,
bottom + h,
left + w - r,
bottom + h
);
shape.lineTo(left + r, bottom + h);
shape.quadraticCurveTo(left, bottom + h, left, bottom + h - r);
shape.lineTo(left, bottom + r);
shape.quadraticCurveTo(left, bottom, left + r, bottom);
const bevel = Math.min(0.035, r * 0.25, d * 0.2);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: d,
steps: 1,
bevelEnabled: true,
bevelSegments: 3,
bevelSize: bevel,
bevelThickness: bevel,
curveSegments: 8
});
geometry.translate(0, 0, -d / 2);
const mesh = new THREE.Mesh(geometry, 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, sx = 1, sy = 1, sz = 1) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(radius, 24, 16),
mat
);
mesh.position.set(x, y, z);
mesh.scale.set(sx, sy, sz);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
parent,
radiusTop,
radiusBottom,
height,
x,
y,
z,
mat,
segments = 24
) {
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 capsule(parent, radius, length, x, y, z, mat) {
const mesh = new THREE.Mesh(
new THREE.CapsuleGeometry(radius, length, 4, 12),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// The exact same raised star is used on the bag, cubby, and desk card.
function star(parent, radius, x, y, z, mat = mats.yellow) {
const shape = new THREE.Shape();
for (let i = 0; i < 10; i++) {
const angle = Math.PI / 2 + i * Math.PI / 5;
const r = i % 2 === 0 ? radius : radius * 0.46;
const px = Math.cos(angle) * r;
const py = Math.sin(angle) * r;
if (i === 0) shape.moveTo(px, py);
else shape.lineTo(px, py);
}
shape.closePath();
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: radius * 0.18,
steps: 1,
bevelEnabled: true,
bevelSegments: 2,
bevelSize: radius * 0.055,
bevelThickness: radius * 0.045
});
geometry.translate(0, 0, -radius * 0.09);
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function circleMotif(parent, radius, x, y, z, mat) {
const mesh = new THREE.Mesh(
new THREE.CircleGeometry(radius, 28),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
parent.add(mesh);
return mesh;
}
function triangleMotif(parent, radius, x, y, z, mat) {
const shape = new THREE.Shape();
shape.moveTo(0, radius);
shape.lineTo(-radius * 0.86, -radius * 0.5);
shape.lineTo(radius * 0.86, -radius * 0.5);
shape.closePath();
const mesh = new THREE.Mesh(
new THREE.ShapeGeometry(shape),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
parent.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Classroom environment
// -------------------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(20, 16),
mats.floor
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.02;
floor.receiveShadow = true;
scene.add(floor);
const rug = new THREE.Mesh(
new THREE.CircleGeometry(3.45, 64),
mats.rug
);
rug.rotation.x = -Math.PI / 2;
rug.position.set(0.05, 0.002, -0.05);
rug.receiveShadow = true;
scene.add(rug);
box(scene, 10, 5, 0.18, 0, 2.45, -3.25, mats.wall);
box(scene, 10, 0.18, 0.08, 0, 0.09, -3.12, mats.baseboard);
// A simple classroom clock, intentionally free of lettering.
const clockGroup = new THREE.Group();
clockGroup.position.set(3.55, 3.05, -3.11);
scene.add(clockGroup);
const clockFace = new THREE.Mesh(
new THREE.CircleGeometry(0.43, 40),
mats.cream
);
clockFace.castShadow = true;
clockGroup.add(clockFace);
const clockRim = new THREE.Mesh(
new THREE.TorusGeometry(0.43, 0.045, 8, 40),
mats.tealDark
);
clockRim.position.z = 0.015;
clockGroup.add(clockRim);
const hourHand = box(
clockGroup,
0.035,
0.25,
0.025,
-0.055,
0.07,
0.035,
mats.dark
);
hourHand.rotation.z = -0.45;
const minuteHand = box(
clockGroup,
0.025,
0.31,
0.025,
0.095,
0.04,
0.045,
mats.dark
);
minuteHand.rotation.z = 0.72;
sphere(clockGroup, 0.045, 0, 0, 0.055, mats.coral);
// -------------------------------------------------------------------------
// Cubby unit
// -------------------------------------------------------------------------
const cubby = new THREE.Group();
scene.add(cubby);
const cubbyLeft = -3.6;
const cubbyRight = 0.3;
const cubbyBottom = 0.22;
const cubbyMiddle = 1.56;
const cubbyTop = 2.92;
const cubbyFront = -2.01;
const cubbyBack = -2.82;
box(
cubby,
3.9,
2.7,
0.1,
-1.65,
1.57,
cubbyBack,
mats.woodLight
);
for (const x of [cubbyLeft, -2.3, -1.0, cubbyRight]) {
box(
cubby,
0.13,
2.7,
0.78,
x,
1.57,
-2.42,
mats.wood
);
}
for (const y of [cubbyBottom, cubbyMiddle, cubbyTop]) {
box(
cubby,
3.9,
0.14,
0.78,
-1.65,
y,
-2.42,
mats.wood
);
}
// The child's middle-lower cubby has a blue interior and teal trim.
box(
cubby,
1.16,
1.18,
0.035,
-1.65,
0.88,
-2.745,
mats.sky
);
for (const x of [-2.245, -1.055]) {
box(
cubby,
0.055,
1.23,
0.05,
x,
0.87,
cubbyFront + 0.01,
mats.teal
);
}
for (const y of [0.30, 1.485]) {
box(
cubby,
1.18,
0.055,
0.05,
-1.65,
y,
cubbyFront + 0.01,
mats.teal
);
}
// Matching star badge attached to the cubby.
rounded(
cubby,
0.48,
0.48,
0.1,
0.09,
-1.65,
0.27,
-1.93,
mats.teal
);
rounded(
cubby,
0.37,
0.37,
0.03,
0.06,
-1.65,
0.27,
-1.865,
mats.cream
);
star(cubby, 0.17, -1.65, 0.27, -1.835);
// Neighboring belongings use deliberately different colors and motifs.
const neighborLunchbox = new THREE.Group();
neighborLunchbox.position.set(-2.95, 2.13, -2.36);
cubby.add(neighborLunchbox);
rounded(
neighborLunchbox,
0.8,
0.48,
0.45,
0.1,
0,
0,
0,
mats.coral
);
circleMotif(neighborLunchbox, 0.12, 0, 0, 0.235, mats.cream);
const upperBooks = new THREE.Group();
upperBooks.position.set(-1.65, 2.08, -2.47);
cubby.add(upperBooks);
rounded(
upperBooks,
0.8,
0.13,
0.42,
0.035,
0,
-0.08,
0,
mats.green
);
rounded(
upperBooks,
0.72,
0.12,
0.39,
0.035,
0.03,
0.06,
0,
mats.purple
);
cylinder(cubby, 0.18, 0.2, 0.58, -0.65, 2.12, -2.45, mats.yellow);
cylinder(cubby, 0.12, 0.12, 0.13, -0.65, 2.47, -2.45, mats.coral);
triangleMotif(cubby, 0.1, -0.65, 2.13, -2.255, mats.purple);
for (let i = 0; i < 3; i++) {
rounded(
cubby,
0.8 - i * 0.035,
0.11,
0.4,
0.025,
-2.95,
0.58 + i * 0.13,
-2.46,
i === 1 ? mats.green : mats.coral
);
}
rounded(
cubby,
0.74,
0.58,
0.42,
0.13,
-0.65,
0.87,
-2.37,
mats.purple
);
triangleMotif(cubby, 0.12, -0.65, 0.87, -2.145, mats.green);
// -------------------------------------------------------------------------
// Child's desk
// -------------------------------------------------------------------------
const desk = new THREE.Group();
scene.add(desk);
rounded(
desk,
3.35,
0.17,
1.6,
0.08,
2.15,
1.46,
0.05,
mats.woodLight
);
for (const x of [0.78, 3.52]) {
for (const z of [-0.48, 0.58]) {
box(desk, 0.14, 1.38, 0.14, x, 0.68, z, mats.wood);
}
}
box(desk, 2.85, 0.14, 0.13, 2.15, 1.12, 0.57, mats.wood);
box(desk, 0.07, 0.08, 1.48, 0.54, 1.47, 0.05, mats.teal);
// The matching desk card.
const deskCard = new THREE.Group();
deskCard.position.set(2.27, 1.84, 0.18);
deskCard.rotation.x = -0.06;
desk.add(deskCard);
rounded(deskCard, 0.86, 0.57, 0.11, 0.09, 0, 0, 0, mats.teal);
rounded(
deskCard,
0.71,
0.42,
0.035,
0.055,
0,
0,
0.073,
mats.cream
);
star(deskCard, 0.18, 0, 0, 0.105);
box(desk, 0.77, 0.05, 0.34, 2.27, 1.56, 0.08, mats.tealDark);
// Neighboring desk items use other colors and non-star motifs.
rounded(
desk,
0.58,
0.08,
0.43,
0.035,
1.02,
1.59,
0.22,
mats.purple
);
const deskCircle = circleMotif(
desk,
0.11,
1.02,
1.637,
0.22,
mats.yellow
);
deskCircle.rotation.x = -Math.PI / 2;
cylinder(desk, 0.16, 0.14, 0.35, 3.25, 1.72, 0.27, mats.coral);
const pencilColors = [mats.yellow, mats.teal, mats.purple];
pencilColors.forEach((pencilMat, i) => {
const pencil = cylinder(
desk,
0.025,
0.025,
0.55,
3.17 + i * 0.075,
1.99,
0.27,
pencilMat,
10
);
pencil.rotation.z = (i - 1) * 0.12;
});
// -------------------------------------------------------------------------
// Child's schoolbag
// -------------------------------------------------------------------------
const bag = new THREE.Group();
bag.position.set(0.08, 0.67, 0.76);
bag.rotation.y = -0.28;
scene.add(bag);
rounded(
bag,
0.96,
1.05,
0.54,
0.18,
0,
0,
0,
mats.teal
);
rounded(
bag,
0.74,
0.47,
0.2,
0.12,
0,
-0.2,
0.29,
mats.sky
);
star(bag, 0.18, 0, -0.2, 0.405);
const handle = new THREE.Mesh(
new THREE.TorusGeometry(0.18, 0.038, 8, 24, Math.PI),
mats.tealDark
);
handle.position.set(0, 0.47, 0);
handle.castShadow = true;
bag.add(handle);
for (const side of [-1, 1]) {
const curve = new THREE.CatmullRomCurve3([
new THREE.Vector3(side * 0.23, 0.42, -0.25),
new THREE.Vector3(side * 0.32, 0.08, -0.46),
new THREE.Vector3(side * 0.27, -0.42, -0.32)
]);
const strap = new THREE.Mesh(
new THREE.TubeGeometry(curve, 20, 0.035, 6, false),
mats.tealDark
);
strap.castShadow = true;
bag.add(strap);
}
sphere(bag, 0.055, 0.36, 0.08, 0.2, mats.yellow);
// -------------------------------------------------------------------------
// Stylized child waving
// -------------------------------------------------------------------------
const child = new THREE.Group();
child.position.set(-0.06, 0, -0.55);
child.rotation.y = 0.04;
scene.add(child);
for (const x of [-0.14, 0.14]) {
capsule(child, 0.095, 0.38, x, 0.48, 0, mats.skin);
sphere(child, 0.145, x, 0.12, 0.09, mats.shoe, 1, 0.7, 1.5);
}
rounded(
child,
0.56,
0.5,
0.36,
0.12,
0,
1.01,
0,
mats.tealDark
);
capsule(child, 0.245, 0.3, 0, 1.38, 0, mats.coral);
// Blue overall bib and straps.
rounded(
child,
0.43,
0.43,
0.36,
0.08,
0,
1.31,
0.045,
mats.teal
);
for (const x of [-0.145, 0.145]) {
const strap = box(
child,
0.075,
0.38,
0.045,
x,
1.48,
0.205,
mats.teal
);
strap.rotation.z = x > 0 ? -0.08 : 0.08;
sphere(child, 0.032, x, 1.38, 0.24, mats.cream);
}
cylinder(child, 0.1, 0.1, 0.13, 0, 1.73, 0, mats.skin);
sphere(child, 0.3, 0, 2.0, 0, mats.skin);
sphere(child, 0.31, 0, 2.19, -0.015, mats.hair, 1, 0.62, 1);
sphere(child, 0.12, -0.1, 2.14, 0.18, mats.hair, 1.15, 0.7, 0.8);
sphere(child, 0.145, 0.05, 2.23, -0.24, mats.hair);
sphere(child, 0.025, -0.095, 2.025, 0.276, mats.dark);
sphere(child, 0.025, 0.095, 2.025, 0.276, mats.dark);
sphere(child, 0.04, 0, 1.955, 0.296, mats.skin);
const smile = new THREE.Mesh(
new THREE.TorusGeometry(0.055, 0.009, 5, 16, Math.PI),
mats.dark
);
smile.position.set(0, 1.91, 0.292);
smile.rotation.z = Math.PI;
child.add(smile);
function makeArm(x, rotationZ) {
const pivot = new THREE.Group();
pivot.position.set(x, 1.52, 0);
pivot.rotation.z = rotationZ;
child.add(pivot);
capsule(pivot, 0.078, 0.2, 0, -0.13, 0, mats.coral);
capsule(pivot, 0.066, 0.26, 0, -0.41, 0, mats.skin);
sphere(pivot, 0.078, 0, -0.64, 0, mats.skin);
return pivot;
}
makeArm(-0.28, -0.28);
const wavingArm = makeArm(0.28, 2.22);
// -------------------------------------------------------------------------
// Direct camera controls: orbit, zoom, and reset
// -------------------------------------------------------------------------
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;
azimuth -= deltaX * 0.006;
polar = THREE.MathUtils.clamp(
polar - deltaY * 0.005,
0.48,
1.38
);
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined) {
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,
18
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
azimuth = 0.48;
polar = 1.08;
radius = 11.2;
target.set(0, 1.3, -0.5);
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
wavingArm.rotation.z = 2.22 + Math.sin(elapsed * 3.2) * 0.11;
wavingArm.rotation.x = Math.sin(elapsed * 2.1) * 0.045;
updateCamera();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```