Prompt specification
Build or customize the Three.js 3D scene "Weekly fridge notice corner" 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: Weekly fridge notice corner
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/weekly-fridge-notice-corner-x0034
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring refrigerator magnets. Place magnets over overlapping grocery notes on a refrigerator door; let users slide one magnet while the retained note stays visibly pinned underneath. Low-poly.
Working Three.js Starter (weekly-fridge-notice-corner-x0034):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Pinned — Refrigerator Magnets</title>
<style>
:root {
color-scheme: light;
--ink: #26332f;
--muted: #62706a;
--paper: #fffaf0;
--coral: #e96852;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9e4da;
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;
outline: none;
}
canvas:focus-visible {
outline: 3px solid rgba(233, 104, 82, 0.85);
outline-offset: -5px;
}
.info {
position: fixed;
top: 24px;
left: 24px;
z-index: 2;
max-width: 310px;
pointer-events: none;
}
.eyebrow {
margin-bottom: 7px;
color: var(--coral);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(28px, 4vw, 48px);
font-weight: 800;
letter-spacing: -0.055em;
line-height: 0.95;
}
.info p {
margin: 13px 0 0;
max-width: 275px;
color: var(--muted);
font-size: 13px;
line-height: 1.5;
}
.controls {
position: fixed;
z-index: 3;
left: 50%;
bottom: 22px;
display: flex;
align-items: center;
gap: 10px;
transform: translateX(-50%);
white-space: nowrap;
}
.hint,
button {
min-height: 42px;
border: 1px solid rgba(38, 51, 47, 0.12);
border-radius: 999px;
box-shadow: 0 8px 24px rgba(45, 57, 52, 0.12);
backdrop-filter: blur(12px);
}
.hint {
display: flex;
align-items: center;
gap: 9px;
padding: 0 16px;
background: rgba(255, 250, 240, 0.84);
color: var(--ink);
font-size: 12px;
font-weight: 650;
}
.hint::before {
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--coral);
box-shadow: 0 0 0 5px rgba(233, 104, 82, 0.14);
content: "";
}
button {
padding: 0 17px;
background: var(--ink);
color: #fffaf0;
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
transition:
transform 150ms ease,
background 150ms ease;
}
button:hover {
background: #374842;
transform: translateY(-1px);
}
button:active {
transform: translateY(1px);
}
.corner {
position: fixed;
right: 24px;
top: 25px;
z-index: 2;
color: rgba(38, 51, 47, 0.52);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
pointer-events: none;
text-transform: uppercase;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
@media (max-width: 640px) {
.info {
top: 17px;
left: 17px;
}
.info p {
max-width: 220px;
font-size: 12px;
}
.corner {
display: none;
}
.controls {
bottom: 15px;
}
.hint {
padding: 0 13px;
}
.hint .keyboard {
display: none;
}
}
</style>
</head>
<body>
<canvas
id="scene"
tabindex="0"
aria-label="Interactive refrigerator with grocery notes and magnets. Drag the coral magnet, or use the arrow keys, to move its pinned note."
></canvas>
<header class="info">
<div class="eyebrow">Pinned / Kitchen Study 01</div>
<h1>Grocery magnets</h1>
<p>
Drag the coral magnet across the refrigerator. Its grocery note stays
captured and visibly pinned underneath.
</p>
</header>
<div class="corner">Low-poly interactive scene</div>
<div class="controls">
<div class="hint">
<span>Drag the coral magnet</span>
<span class="keyboard">· or use arrow keys</span>
</div>
<button id="reset" type="button">Reset note</button>
</div>
<div id="status" class="sr-only" aria-live="polite"></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 resetButton = document.querySelector("#reset");
const status = document.querySelector("#status");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#e9e4da");
scene.fog = new THREE.Fog("#e9e4da", 24, 38);
const camera = new THREE.OrthographicCamera(-8, 8, 6, -6, 0.1, 50);
camera.position.set(0, 0, 20);
camera.lookAt(0, 0, 0);
const hemisphere = new THREE.HemisphereLight("#fff8e8", "#7c9288", 2.15);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight("#fff1d9", 3.2);
keyLight.position.set(-7, 9, 14);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 9;
keyLight.shadow.camera.bottom = -9;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 32;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight("#b8d7d1", 1.1);
fillLight.position.set(8, 1, 10);
scene.add(fillLight);
function roundedRectShape(width, height, radius) {
const x = -width / 2;
const y = -height / 2;
const shape = new THREE.Shape();
shape.moveTo(x + radius, y);
shape.lineTo(x + width - radius, y);
shape.quadraticCurveTo(x + width, y, x + width, y + radius);
shape.lineTo(x + width, y + height - radius);
shape.quadraticCurveTo(
x + width,
y + height,
x + width - radius,
y + height
);
shape.lineTo(x + radius, y + height);
shape.quadraticCurveTo(x, y + height, x, y + height - radius);
shape.lineTo(x, y + radius);
shape.quadraticCurveTo(x, y, x + radius, y);
shape.closePath();
return shape;
}
// Wall behind the refrigerator.
const wall = new THREE.Mesh(
new THREE.PlaneGeometry(50, 30),
new THREE.MeshStandardMaterial({
color: "#e9e4da",
roughness: 1
})
);
wall.position.z = -1.2;
wall.receiveShadow = true;
scene.add(wall);
// Faceted refrigerator body and door.
const body = new THREE.Mesh(
new THREE.BoxGeometry(8.75, 11.65, 0.64),
new THREE.MeshStandardMaterial({
color: "#8fa59a",
roughness: 0.76,
metalness: 0.04,
flatShading: true
})
);
body.position.z = -0.45;
body.castShadow = true;
body.receiveShadow = true;
scene.add(body);
const doorGeometry = new THREE.ExtrudeGeometry(
roundedRectShape(8.35, 11.2, 0.32),
{
depth: 0.22,
steps: 1,
bevelEnabled: true,
bevelSegments: 1,
bevelSize: 0.075,
bevelThickness: 0.055,
curveSegments: 4
}
);
const door = new THREE.Mesh(
doorGeometry,
new THREE.MeshStandardMaterial({
color: "#b7c8bb",
roughness: 0.7,
metalness: 0.035,
flatShading: true
})
);
door.position.z = -0.025;
door.castShadow = true;
door.receiveShadow = true;
scene.add(door);
// Subtle inset border.
const borderMaterial = new THREE.MeshStandardMaterial({
color: "#a6b9ab",
roughness: 0.78
});
const borderParts = [
[0, -4.93, 7.48, 0.035],
[0, 4.93, 7.48, 0.035],
[-3.72, 0, 0.035, 9.82],
[3.72, 0, 0.035, 9.82]
];
for (const [x, y, width, height] of borderParts) {
const strip = new THREE.Mesh(
new THREE.BoxGeometry(width, height, 0.035),
borderMaterial
);
strip.position.set(x, y, 0.31);
strip.receiveShadow = true;
scene.add(strip);
}
// Low-poly vertical handle.
const metalMaterial = new THREE.MeshStandardMaterial({
color: "#d8ddd7",
roughness: 0.34,
metalness: 0.72,
flatShading: true
});
const handle = new THREE.Mesh(
new THREE.CylinderGeometry(0.105, 0.105, 3.05, 8),
metalMaterial
);
handle.position.set(3.34, 0.15, 0.72);
handle.castShadow = true;
scene.add(handle);
for (const y of [-1.2, 1.5]) {
const mount = new THREE.Mesh(
new THREE.CylinderGeometry(0.13, 0.16, 0.34, 8),
metalMaterial
);
mount.rotation.x = Math.PI / 2;
mount.position.set(3.34, y, 0.48);
mount.castShadow = true;
scene.add(mount);
}
// Small faceted maker's badge.
const badge = new THREE.Mesh(
new THREE.BoxGeometry(0.58, 0.19, 0.06),
new THREE.MeshStandardMaterial({
color: "#e6ebe3",
roughness: 0.5,
metalness: 0.25
})
);
badge.position.set(-2.85, 4.82, 0.39);
badge.rotation.z = -0.03;
scene.add(badge);
function createNoteTexture(title, lines, accent, paperColor) {
const noteCanvas = document.createElement("canvas");
noteCanvas.width = 320;
noteCanvas.height = 400;
const ctx = noteCanvas.getContext("2d");
ctx.clearRect(0, 0, 320, 400);
// Paper silhouette with a clipped upper-right corner.
ctx.beginPath();
ctx.moveTo(15, 12);
ctx.lineTo(258, 12);
ctx.lineTo(307, 61);
ctx.lineTo(307, 387);
ctx.lineTo(15, 387);
ctx.closePath();
ctx.fillStyle = paperColor;
ctx.fill();
ctx.strokeStyle = "rgba(70, 65, 52, 0.22)";
ctx.lineWidth = 3;
ctx.stroke();
// Folded corner.
ctx.beginPath();
ctx.moveTo(258, 12);
ctx.lineTo(307, 61);
ctx.lineTo(250, 61);
ctx.closePath();
ctx.fillStyle = "rgba(70, 65, 52, 0.09)";
ctx.fill();
ctx.fillStyle = accent;
ctx.font = "800 38px Arial, sans-serif";
ctx.fillText(title, 30, 78);
ctx.strokeStyle = "rgba(56, 65, 59, 0.13)";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(30, 98);
ctx.lineTo(276, 98);
ctx.stroke();
ctx.fillStyle = "#4b554f";
ctx.font = "600 24px Arial, sans-serif";
lines.forEach((line, index) => {
const y = 139 + index * 38;
ctx.strokeStyle = accent;
ctx.lineWidth = 3;
ctx.strokeRect(31, y - 17, 20, 20);
ctx.beginPath();
ctx.moveTo(36, y - 7);
ctx.lineTo(42, y - 1);
ctx.lineTo(51, y - 15);
ctx.stroke();
ctx.fillStyle = "#4b554f";
ctx.fillText(line, 66, y);
});
// Hand-drawn-looking underline.
ctx.strokeStyle = "rgba(66, 73, 67, 0.24)";
ctx.lineWidth = 3;
ctx.beginPath();
ctx.moveTo(66, 326);
ctx.bezierCurveTo(115, 319, 185, 334, 265, 324);
ctx.stroke();
const texture = new THREE.CanvasTexture(noteCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
function createPaperMesh(texture, width, height) {
const geometry = new THREE.PlaneGeometry(width, height, 3, 4);
const positions = geometry.attributes.position;
for (let i = 0; i < positions.count; i++) {
const x = positions.getX(i);
const y = positions.getY(i);
const edge = Math.pow(Math.abs(x) / (width / 2), 3);
const corner = Math.pow(Math.abs(y) / (height / 2), 4);
positions.setZ(i, edge * 0.027 + corner * 0.012);
}
geometry.computeVertexNormals();
const material = new THREE.MeshStandardMaterial({
map: texture,
transparent: true,
alphaTest: 0.45,
roughness: 0.96,
metalness: 0,
side: THREE.DoubleSide
});
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function createMagnet(color, selected = false) {
const group = new THREE.Group();
const bodyMaterial = new THREE.MeshStandardMaterial({
color,
roughness: 0.5,
metalness: 0.06,
flatShading: true
});
const body = new THREE.Mesh(
new THREE.CylinderGeometry(0.32, 0.32, 0.16, 12),
bodyMaterial
);
body.rotation.x = Math.PI / 2;
body.position.z = 0.11;
body.castShadow = true;
body.receiveShadow = true;
group.add(body);
const cap = new THREE.Mesh(
new THREE.CylinderGeometry(0.255, 0.255, 0.05, 12),
new THREE.MeshStandardMaterial({
color: new THREE.Color(color).offsetHSL(0, -0.04, 0.08),
roughness: 0.43,
flatShading: true
})
);
cap.rotation.x = Math.PI / 2;
cap.position.z = 0.195;
cap.castShadow = true;
group.add(cap);
const markShape = new THREE.Shape();
if (selected) {
// A small arrow makes the draggable magnet easy to identify.
markShape.moveTo(-0.075, -0.075);
markShape.lineTo(0.09, 0);
markShape.lineTo(-0.075, 0.075);
markShape.closePath();
} else {
markShape.moveTo(0, -0.075);
markShape.lineTo(0.075, 0);
markShape.lineTo(0, 0.075);
markShape.lineTo(-0.075, 0);
markShape.closePath();
}
const mark = new THREE.Mesh(
new THREE.ShapeGeometry(markShape),
new THREE.MeshBasicMaterial({
color: "#fff9ec",
transparent: true,
opacity: 0.88,
side: THREE.DoubleSide
})
);
mark.position.z = 0.226;
group.add(mark);
if (selected) {
// Oversized invisible target for comfortable mouse/touch dragging.
const hit = new THREE.Mesh(
new THREE.SphereGeometry(0.47, 12, 8),
new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false,
colorWrite: false
})
);
hit.userData.draggable = true;
group.add(hit);
group.userData.hitTarget = hit;
}
return group;
}
function createNoteAssembly({
title,
lines,
accent,
paperColor,
magnetColor,
position,
rotation,
z,
selected = false,
magnetOffset = new THREE.Vector2(0, 0.55)
}) {
const assembly = new THREE.Group();
assembly.position.set(position.x, position.y, z);
assembly.rotation.z = rotation;
const texture = createNoteTexture(title, lines, accent, paperColor);
const paper = createPaperMesh(texture, 1.68, 2.08);
assembly.add(paper);
const magnet = createMagnet(magnetColor, selected);
magnet.position.set(magnetOffset.x, magnetOffset.y, 0);
assembly.add(magnet);
if (selected) {
// The soft footprint on the paper makes the captured note clear.
const pinFootprint = new THREE.Mesh(
new THREE.CircleGeometry(0.37, 12),
new THREE.MeshBasicMaterial({
color: magnetColor,
transparent: true,
opacity: 0.2,
depthWrite: false,
side: THREE.DoubleSide
})
);
pinFootprint.position.set(magnetOffset.x, magnetOffset.y, 0.018);
assembly.add(pinFootprint);
}
scene.add(assembly);
return { assembly, magnet };
}
createNoteAssembly({
title: "MILK",
lines: ["2%", "one carton"],
accent: "#b94f42",
paperColor: "#fff2d7",
magnetColor: "#2f6470",
position: new THREE.Vector2(-2.45, 2.65),
rotation: -0.1,
z: 0.43,
magnetOffset: new THREE.Vector2(-0.32, 0.54)
});
createNoteAssembly({
title: "EGGS",
lines: ["12", "free range"],
accent: "#c58b22",
paperColor: "#fff8df",
magnetColor: "#6d4f85",
position: new THREE.Vector2(-1.3, 1.65),
rotation: 0.07,
z: 0.442,
magnetOffset: new THREE.Vector2(0.3, 0.55)
});
createNoteAssembly({
title: "BREAD",
lines: ["sourdough", "rye too"],
accent: "#397b68",
paperColor: "#eef3dc",
magnetColor: "#d39b32",
position: new THREE.Vector2(0.65, 2.6),
rotation: -0.055,
z: 0.454,
magnetOffset: new THREE.Vector2(-0.3, 0.55)
});
createNoteAssembly({
title: "TOMATOES",
lines: ["6 ripe", "on the vine"],
accent: "#b9493b",
paperColor: "#ffe4d5",
magnetColor: "#315c77",
position: new THREE.Vector2(1.8, 1.65),
rotation: 0.085,
z: 0.466,
magnetOffset: new THREE.Vector2(0.32, 0.55)
});
createNoteAssembly({
title: "COFFEE",
lines: ["dark roast", "ground"],
accent: "#5b4a3f",
paperColor: "#f2e7d4",
magnetColor: "#3d8279",
position: new THREE.Vector2(-2.45, 0.35),
rotation: 0.045,
z: 0.478,
magnetOffset: new THREE.Vector2(0.2, 0.55)
});
const selectedNote = createNoteAssembly({
title: "ORANGES",
lines: ["4", "juice"],
accent: "#2f765e",
paperColor: "#fff0c8",
magnetColor: "#e96852",
position: new THREE.Vector2(0.05, 0.68),
rotation: 0.025,
z: 0.56,
selected: true,
magnetOffset: new THREE.Vector2(0.38, 0.55)
});
const selectedAssembly = selectedNote.assembly;
const selectedMagnet = selectedNote.magnet;
const selectedHit = selectedMagnet.userData.hitTarget;
const initialPosition = selectedAssembly.position.clone();
const initialRotation = selectedAssembly.rotation.z;
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const dragPlane = new THREE.Plane(new THREE.Vector3(0, 0, 1), -0.79);
const planePoint = new THREE.Vector3();
const dragOffset = new THREE.Vector2();
let dragging = false;
let hovered = false;
let activePointerId = null;
function setPointer(event) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function updatePointerRay(event) {
setPointer(event);
scene.updateMatrixWorld(true);
raycaster.setFromCamera(pointer, camera);
}
function hitsSelectedMagnet() {
return raycaster.intersectObject(selectedHit, false).length > 0;
}
function constrainSelectedNote() {
selectedAssembly.position.x = THREE.MathUtils.clamp(
selectedAssembly.position.x,
-2.75,
2.7
);
selectedAssembly.position.y = THREE.MathUtils.clamp(
selectedAssembly.position.y,
-4.35,
4.35
);
}
canvas.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
updatePointerRay(event);
if (!hitsSelectedMagnet()) return;
if (!raycaster.ray.intersectPlane(dragPlane, planePoint)) return;
dragging = true;
activePointerId = event.pointerId;
dragOffset.set(
selectedAssembly.position.x - planePoint.x,
selectedAssembly.position.y - planePoint.y
);
canvas.setPointerCapture(event.pointerId);
canvas.style.cursor = "grabbing";
status.textContent =
"The orange grocery note is pinned underneath the coral magnet.";
event.preventDefault();
});
canvas.addEventListener("pointermove", (event) => {
if (dragging && event.pointerId === activePointerId) {
updatePointerRay(event);
if (raycaster.ray.intersectPlane(dragPlane, planePoint)) {
selectedAssembly.position.x = planePoint.x + dragOffset.x;
selectedAssembly.position.y = planePoint.y + dragOffset.y;
constrainSelectedNote();
}
event.preventDefault();
return;
}
updatePointerRay(event);
hovered = hitsSelectedMagnet();
canvas.style.cursor = hovered ? "grab" : "default";
});
function endDrag(event) {
if (!dragging) return;
if (event.pointerId !== activePointerId) return;
dragging = false;
activePointerId = null;
canvas.style.cursor = hovered ? "grab" : "default";
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
status.textContent =
"The orange note remains pinned to the coral magnet.";
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("pointerleave", () => {
if (!dragging) {
hovered = false;
canvas.style.cursor = "default";
}
});
canvas.addEventListener("keydown", (event) => {
const step = event.shiftKey ? 0.45 : 0.18;
let moved = false;
switch (event.key) {
case "ArrowLeft":
selectedAssembly.position.x -= step;
moved = true;
break;
case "ArrowRight":
selectedAssembly.position.x += step;
moved = true;
break;
case "ArrowUp":
selectedAssembly.position.y += step;
moved = true;
break;
case "ArrowDown":
selectedAssembly.position.y -= step;
moved = true;
break;
default:
return;
}
constrainSelectedNote();
event.preventDefault();
status.textContent =
"The orange grocery note moved with the coral magnet.";
});
resetButton.addEventListener("click", () => {
selectedAssembly.position.copy(initialPosition);
selectedAssembly.rotation.z = initialRotation;
status.textContent = "The orange note has been returned to its starting position.";
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
let viewHeight = 12.35;
const requiredWidth = 9.25;
if (viewHeight * aspect < requiredWidth) {
viewHeight = requiredWidth / aspect;
}
const viewWidth = viewHeight * aspect;
camera.left = -viewWidth / 2;
camera.right = viewWidth / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(width, height, false);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
const targetScale = new THREE.Vector3();
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const liftZ = dragging ? 0.61 : 0.56;
selectedAssembly.position.z = THREE.MathUtils.lerp(
selectedAssembly.position.z,
liftZ,
1 - Math.pow(0.001, delta)
);
const scale = dragging || hovered ? 1.07 : 1;
targetScale.setScalar(scale);
selectedMagnet.scale.lerp(targetScale, 1 - Math.pow(0.002, delta));
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```