Prompt specification
Build or customize the Three.js 3D scene "Rounded tissue dispenser box" 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: Rounded tissue dispenser box
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/rounded-tissue-dispenser-box-x0069
Scene Description Prompt:
Make a stylized Three.js scene in a self-contained HTML file using cdnjs: rounded tissue dispenser box. Build a rectangular tissue box with an oval top opening and one folded tissue emerging; show the thin sheet's crease without using a flat picture.
Working Three.js Starter (rounded-tissue-dispenser-box-x0069):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Folded Tissue — Three.js</title>
<style>
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce9e5;
font-family: Inter, ui-sans-serif, 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;
}
.caption {
position: fixed;
top: clamp(22px, 4vw, 48px);
left: clamp(22px, 4vw, 48px);
z-index: 2;
color: #25423d;
pointer-events: none;
user-select: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
opacity: 0.65;
}
.eyebrow::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: #e98368;
box-shadow: 0 0 0 5px rgb(233 131 104 / 14%);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 4vw, 48px);
font-weight: 500;
letter-spacing: -0.035em;
line-height: 0.95;
}
.hint {
position: fixed;
right: clamp(20px, 4vw, 48px);
bottom: clamp(20px, 4vw, 42px);
z-index: 2;
padding: 9px 13px;
border: 1px solid rgb(37 66 61 / 12%);
border-radius: 999px;
background: rgb(255 255 255 / 34%);
color: #385650;
font-size: 11px;
letter-spacing: 0.03em;
backdrop-filter: blur(12px);
pointer-events: none;
user-select: none;
}
@media (max-width: 600px) {
.caption {
top: 20px;
left: 20px;
}
.hint {
right: 16px;
bottom: 16px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="caption">
<div class="eyebrow">Form study · 01</div>
<h1>Folded tissue</h1>
</div>
<div class="hint">Drag to orbit · Scroll to zoom · Double-click 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";
const sceneContainer = document.getElementById("scene");
// ---------------------------------------------------------------------
// Renderer and scene
// ---------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
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;
renderer.domElement.setAttribute(
"aria-label",
"Interactive three-dimensional tissue dispenser"
);
sceneContainer.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce9e5);
scene.fog = new THREE.Fog(0xdce9e5, 10, 22);
const camera = new THREE.PerspectiveCamera(
37,
window.innerWidth / window.innerHeight,
0.1,
100
);
// ---------------------------------------------------------------------
// Lighting
// ---------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(
0xfff8ee,
0x788d87,
1.75
);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff2df, 3.25);
keyLight.position.set(-4.5, 7.5, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -6;
keyLight.shadow.camera.right = 6;
keyLight.shadow.camera.top = 7;
keyLight.shadow.camera.bottom = -4;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 20;
keyLight.shadow.bias = -0.0004;
keyLight.shadow.normalBias = 0.025;
keyLight.target.position.set(0, 1.2, 0);
scene.add(keyLight, keyLight.target);
const fillLight = new THREE.DirectionalLight(0xcce8ff, 1.15);
fillLight.position.set(5, 3.5, 2);
scene.add(fillLight);
const rimLight = new THREE.DirectionalLight(0xffb89e, 1.3);
rimLight.position.set(0, 4, -5);
scene.add(rimLight);
// ---------------------------------------------------------------------
// Materials
// ---------------------------------------------------------------------
const topMaterial = new THREE.MeshStandardMaterial({
color: 0xec9579,
roughness: 0.72,
metalness: 0.015
});
const sideMaterial = new THREE.MeshStandardMaterial({
color: 0xdd7f67,
roughness: 0.78,
metalness: 0.01
});
const rimMaterial = new THREE.MeshStandardMaterial({
color: 0xf4aa8e,
roughness: 0.65,
metalness: 0.015
});
const interiorMaterial = new THREE.MeshStandardMaterial({
color: 0x4c302d,
roughness: 0.95,
metalness: 0,
side: THREE.DoubleSide
});
const paperMaterial = new THREE.MeshStandardMaterial({
color: 0xfffaf0,
roughness: 0.88,
metalness: 0,
side: THREE.DoubleSide
});
const creaseMaterial = new THREE.MeshStandardMaterial({
color: 0xfff3df,
roughness: 0.84,
metalness: 0,
side: THREE.DoubleSide
});
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0xd6dfd9,
roughness: 1,
metalness: 0
});
// ---------------------------------------------------------------------
// Rounded dispenser body
//
// The top is made from an extruded rounded rectangle with a genuine
// elliptical hole. Beveling rounds the upper and lower box edges.
// ---------------------------------------------------------------------
const BOX_WIDTH = 3.8;
const BOX_DEPTH = 2.15;
const BOX_HEIGHT = 1.72;
const CORNER_RADIUS = 0.28;
const BEVEL_SIZE = 0.055;
const BEVEL_THICKNESS = 0.07;
const bodyShape = new THREE.Shape();
const halfWidth = BOX_WIDTH / 2;
const halfDepth = BOX_DEPTH / 2;
const radius = CORNER_RADIUS;
bodyShape.moveTo(-halfWidth + radius, -halfDepth);
bodyShape.lineTo(halfWidth - radius, -halfDepth);
bodyShape.quadraticCurveTo(
halfWidth, -halfDepth,
halfWidth, -halfDepth + radius
);
bodyShape.lineTo(halfWidth, halfDepth - radius);
bodyShape.quadraticCurveTo(
halfWidth, halfDepth,
halfWidth - radius, halfDepth
);
bodyShape.lineTo(-halfWidth + radius, halfDepth);
bodyShape.quadraticCurveTo(
-halfWidth, halfDepth,
-halfWidth, halfDepth - radius
);
bodyShape.lineTo(-halfWidth, -halfDepth + radius);
bodyShape.quadraticCurveTo(
-halfWidth, -halfDepth,
-halfWidth + radius, -halfDepth
);
// Clockwise elliptical path creates an actual hole in the top surface.
const opening = new THREE.Path();
opening.absellipse(
0,
0,
0.72,
0.35,
0,
Math.PI * 2,
true
);
bodyShape.holes.push(opening);
const bodyGeometry = new THREE.ExtrudeGeometry(bodyShape, {
depth: BOX_HEIGHT,
bevelEnabled: true,
bevelSize: BEVEL_SIZE,
bevelThickness: BEVEL_THICKNESS,
bevelOffset: 0,
bevelSegments: 5,
curveSegments: 20,
steps: 1
});
// Extrusion is along Z; rotate it so the box stands along Y.
bodyGeometry.rotateX(-Math.PI / 2);
bodyGeometry.computeVertexNormals();
const body = new THREE.Mesh(bodyGeometry, [
topMaterial,
sideMaterial
]);
body.position.y = BEVEL_THICKNESS;
body.castShadow = true;
body.receiveShadow = true;
scene.add(body);
const topY = BEVEL_THICKNESS + BOX_HEIGHT + BEVEL_THICKNESS;
// ---------------------------------------------------------------------
// Oval opening details: recessed interior, dark cavity, and soft rim
// ---------------------------------------------------------------------
const interiorWall = new THREE.Mesh(
new THREE.CylinderGeometry(1, 1, 0.19, 64, 1, true),
interiorMaterial
);
interiorWall.scale.set(0.68, 1, 0.32);
interiorWall.position.y = topY - 0.11;
interiorWall.receiveShadow = true;
scene.add(interiorWall);
const cavityBottom = new THREE.Mesh(
new THREE.CircleGeometry(1, 64),
new THREE.MeshBasicMaterial({
color: 0x402827,
side: THREE.DoubleSide
})
);
cavityBottom.rotation.x = -Math.PI / 2;
cavityBottom.scale.set(0.68, 0.32, 1);
cavityBottom.position.y = topY - 0.205;
scene.add(cavityBottom);
const openingRim = new THREE.Mesh(
new THREE.TorusGeometry(1, 0.047, 14, 96),
rimMaterial
);
openingRim.rotation.x = Math.PI / 2;
openingRim.scale.set(0.72, 0.35, 1);
openingRim.position.y = topY + 0.012;
openingRim.castShadow = true;
scene.add(openingRim);
// ---------------------------------------------------------------------
// Folded tissue
//
// This is real geometry. The profile contains a narrow V-shaped ridge,
// and each adjacent panel has independent vertices so the fold catches
// light with a crisp crease rather than being drawn or textured.
// ---------------------------------------------------------------------
function createFoldedTissue() {
const profile = [
{ x: -0.62, z: 0.000 },
{ x: -0.18, z: 0.005 },
{ x: -0.045, z: 0.028 },
{ x: 0.000, z: 0.225 },
{ x: 0.045, z: 0.028 },
{ x: 0.18, z: 0.005 },
{ x: 0.62, z: 0.000 }
];
const rows = 22;
const positions = [];
const indices = [];
const groups = [];
for (let segment = 0; segment < profile.length - 1; segment++) {
const vertexStart = positions.length / 3;
const indexStart = indices.length;
const p0 = profile[segment];
const p1 = profile[segment + 1];
for (let row = 0; row <= rows; row++) {
const v = row / rows;
for (let edge = 0; edge < 2; edge++) {
const px = THREE.MathUtils.lerp(p0.x, p1.x, edge);
const pz = THREE.MathUtils.lerp(p0.z, p1.z, edge);
// Slight fan as the tissue leaves the box.
const x =
px * (0.90 + 0.10 * v) +
0.025 * Math.sin(v * Math.PI * 1.4);
// The upper portion curls gently backward.
const z =
pz * (0.84 + 0.16 * v) -
0.055 * v * v -
0.018 *
Math.sin(v * Math.PI * 2) *
(0.5 + Math.abs(px));
// Slightly irregular upper edge.
const y =
v * 1.48 +
0.028 * Math.sin(px * 7.0) * Math.pow(v, 4) +
0.020 * Math.cos(px * 4.0) * Math.pow(v, 3);
positions.push(x, y, z);
}
}
for (let row = 0; row < rows; row++) {
const a = vertexStart + row * 2;
const b = a + 1;
const c = a + 2;
const d = a + 3;
indices.push(a, b, c, b, d, c);
}
const materialIndex =
segment === 2 || segment === 3 ? 1 : 0;
groups.push({
start: indexStart,
count: indices.length - indexStart,
materialIndex
});
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
groups.forEach((group) => {
geometry.addGroup(
group.start,
group.count,
group.materialIndex
);
});
geometry.computeVertexNormals();
geometry.computeBoundingSphere();
return new THREE.Mesh(geometry, [
paperMaterial,
creaseMaterial
]);
}
const tissue = createFoldedTissue();
tissue.position.set(0.02, topY - 0.20, 0.015);
tissue.rotation.y = -0.06;
tissue.castShadow = true;
tissue.receiveShadow = true;
scene.add(tissue);
// ---------------------------------------------------------------------
// Ground
// ---------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.CircleGeometry(16, 96),
floorMaterial
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.006;
ground.receiveShadow = true;
scene.add(ground);
// ---------------------------------------------------------------------
// Camera controls implemented directly without external add-ons
// ---------------------------------------------------------------------
const target = new THREE.Vector3(0, 1.35, 0);
const spherical = new THREE.Spherical();
let azimuth = 0.58;
let polar = 1.16;
let distance = 7.25;
let dragging = false;
let previousX = 0;
let previousY = 0;
function updateCamera() {
const portraitMultiplier =
camera.aspect < 0.8 ? 1.25 : 1;
spherical.set(
distance * portraitMultiplier,
polar,
azimuth
);
const offset = new THREE.Vector3().setFromSpherical(spherical);
camera.position.copy(target).add(offset);
camera.lookAt(target);
}
function resetCamera() {
azimuth = 0.58;
polar = 1.16;
distance = 7.25;
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
azimuth -= deltaX * 0.006;
polar = THREE.MathUtils.clamp(
polar + deltaY * 0.005,
0.62,
1.46
);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (
event.pointerId !== undefined &&
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();
distance = THREE.MathUtils.clamp(
distance * Math.exp(event.deltaY * 0.001),
4.4,
11
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
// ---------------------------------------------------------------------
// Resize and render
// ---------------------------------------------------------------------
function onResize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
updateCamera();
}
window.addEventListener("resize", onResize);
onResize();
renderer.setAnimationLoop(() => {
renderer.render(scene, camera);
});
</script>
</body>
</html>
```