Prompt specification
Build or customize the Three.js 3D scene "Small Product Photography Studio" 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: Small Product Photography Studio
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/small-product-photography-studio-x3323
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring camera framing, lighting, and photographic storytelling. Build a studio with a turntable, diffuser panels, and adjustable lights. Show reflections and shadows as render behavior without claiming physically calibrated photographic measurements. Voxel style.
Working Three.js Starter (small-product-photography-studio-x3323):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>Voxel Studio — A Photographic Turntable</title>
<style>
:root {
color-scheme: dark;
--ink: #17191c;
--panel: rgba(22, 24, 27, 0.88);
--panel-line: rgba(255, 255, 255, 0.12);
--paper: #f4efe6;
--muted: rgba(244, 239, 230, 0.58);
--accent: #ef7658;
--accent-soft: rgba(239, 118, 88, 0.18);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d7d0c3;
color: var(--paper);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button, input { font: inherit; }
#stage {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#stage canvas:active { cursor: grabbing; }
.topbar {
position: fixed;
z-index: 5;
top: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-between;
align-items: flex-start;
padding: 24px 28px;
pointer-events: none;
background: linear-gradient(to bottom, rgba(18, 20, 22, 0.35), transparent);
}
.brand {
display: flex;
align-items: center;
gap: 12px;
text-shadow: 0 1px 14px rgba(0, 0, 0, 0.22);
}
.brand-mark {
width: 13px;
height: 13px;
background: var(--accent);
box-shadow:
14px 0 0 rgba(239, 118, 88, 0.45),
0 14px 0 rgba(239, 118, 88, 0.45),
14px 14px 0 rgba(239, 118, 88, 0.22);
}
.brand strong {
display: block;
font-size: 12px;
letter-spacing: 0.18em;
font-weight: 800;
}
.brand span {
display: block;
margin-top: 4px;
color: rgba(255, 255, 255, 0.68);
font-size: 10px;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.render-status {
display: flex;
align-items: center;
gap: 8px;
padding: 9px 12px;
border: 1px solid rgba(255, 255, 255, 0.18);
border-radius: 999px;
background: rgba(18, 20, 22, 0.42);
backdrop-filter: blur(12px);
font-size: 10px;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.render-status::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: #a8d890;
box-shadow: 0 0 12px rgba(168, 216, 144, 0.9);
}
.story {
position: fixed;
z-index: 5;
left: 28px;
bottom: 28px;
width: min(390px, calc(100vw - 56px));
padding: 19px 20px 18px;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 16px;
background: rgba(20, 22, 25, 0.78);
box-shadow: 0 18px 60px rgba(25, 22, 18, 0.2);
backdrop-filter: blur(18px) saturate(120%);
}
.eyebrow {
margin-bottom: 9px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.story h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(26px, 4vw, 42px);
line-height: 0.98;
font-weight: 400;
letter-spacing: -0.035em;
}
.story p {
min-height: 48px;
margin: 12px 0 16px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.shot-nav {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
}
.shot-nav button {
min-width: 0;
padding: 10px 8px;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 9px;
color: rgba(255, 255, 255, 0.7);
background: rgba(255, 255, 255, 0.035);
cursor: pointer;
font-size: 10px;
letter-spacing: 0.06em;
transition: 160ms ease;
}
.shot-nav button:hover,
.shot-nav button.active {
color: #fff;
border-color: rgba(239, 118, 88, 0.58);
background: var(--accent-soft);
}
.controls {
position: fixed;
z-index: 6;
top: 88px;
right: 28px;
width: 286px;
border: 1px solid var(--panel-line);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 18px 60px rgba(25, 22, 18, 0.22);
backdrop-filter: blur(18px) saturate(120%);
overflow: hidden;
}
.controls-head {
display: flex;
align-items: center;
justify-content: space-between;
padding: 15px 17px;
border-bottom: 1px solid var(--panel-line);
}
.controls-head strong {
font-size: 11px;
letter-spacing: 0.15em;
text-transform: uppercase;
}
#controls-toggle {
display: none;
border: 0;
color: var(--paper);
background: transparent;
cursor: pointer;
font-size: 20px;
line-height: 1;
}
.control-body { padding: 6px 17px 16px; }
.control {
padding: 12px 0 9px;
border-bottom: 1px solid rgba(255, 255, 255, 0.075);
}
.control:last-child { border-bottom: 0; }
.control label {
display: flex;
justify-content: space-between;
gap: 12px;
margin-bottom: 9px;
color: rgba(255, 255, 255, 0.78);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.control output {
color: var(--muted);
font-variant-numeric: tabular-nums;
font-weight: 500;
}
input[type="range"] {
width: 100%;
height: 14px;
margin: 0;
appearance: none;
background: transparent;
cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
height: 3px;
border-radius: 999px;
background: linear-gradient(to right, var(--accent), rgba(255, 255, 255, 0.14));
}
input[type="range"]::-webkit-slider-thumb {
width: 13px;
height: 13px;
margin-top: -5px;
appearance: none;
border: 2px solid #191b1e;
border-radius: 50%;
background: #fff4e9;
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22);
}
input[type="range"]::-moz-range-track {
height: 3px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.14);
}
input[type="range"]::-moz-range-progress {
height: 3px;
border-radius: 999px;
background: var(--accent);
}
input[type="range"]::-moz-range-thumb {
width: 11px;
height: 11px;
border: 2px solid #191b1e;
border-radius: 50%;
background: #fff4e9;
}
.button-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 13px;
}
.action {
padding: 10px 8px;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 8px;
color: rgba(255, 255, 255, 0.78);
background: rgba(255, 255, 255, 0.04);
cursor: pointer;
font-size: 10px;
letter-spacing: 0.05em;
transition: 150ms ease;
}
.action:hover,
.action.active {
color: white;
border-color: rgba(239, 118, 88, 0.55);
background: var(--accent-soft);
}
.disclaimer {
position: fixed;
z-index: 4;
right: 28px;
bottom: 28px;
max-width: 286px;
color: rgba(39, 35, 30, 0.65);
font-size: 10px;
line-height: 1.45;
text-align: right;
pointer-events: none;
text-shadow: 0 1px 8px rgba(255, 255, 255, 0.45);
}
#loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-content: center;
gap: 16px;
background: #191b1e;
color: rgba(255, 255, 255, 0.7);
font-size: 11px;
letter-spacing: 0.16em;
text-align: center;
text-transform: uppercase;
transition: opacity 500ms ease, visibility 500ms ease;
}
#loading.hidden {
opacity: 0;
visibility: hidden;
}
.loader-cube {
width: 24px;
height: 24px;
margin: auto;
background: var(--accent);
animation: loader 1.1s ease-in-out infinite alternate;
}
@keyframes loader {
to { transform: rotate(90deg) scale(0.72); }
}
@media (max-width: 760px) {
.topbar { padding: 18px; }
.brand span { display: none; }
.render-status { font-size: 8px; }
.story {
left: 14px;
right: 14px;
bottom: 14px;
width: auto;
padding: 14px;
}
.story h1 { font-size: 27px; }
.story p { min-height: 0; margin: 9px 0 12px; }
.controls {
top: 67px;
right: 14px;
width: min(270px, calc(100vw - 28px));
}
#controls-toggle { display: block; }
.controls.collapsed .control-body { display: none; }
.disclaimer { display: none; }
}
</style>
</head>
<body>
<main id="stage" aria-label="Interactive voxel photography studio"></main>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<strong>VOXEL STUDIO</strong>
<span>Light, form & reflection study</span>
</div>
</div>
<div class="render-status">Live render</div>
</header>
<section class="story" aria-live="polite">
<div class="eyebrow" id="frame-label">Frame 01 / Hero</div>
<h1 id="story-title">The reveal</h1>
<p id="story-copy">
A broad studio frame introduces the object, its turntable, and the warm geometry of the set.
</p>
<nav class="shot-nav" aria-label="Camera shot presets">
<button class="active" data-shot="0">01 · Hero</button>
<button data-shot="1">02 · Detail</button>
<button data-shot="2">03 · Rim</button>
</nav>
</section>
<aside class="controls" id="controls">
<div class="controls-head">
<strong>Studio controls</strong>
<button id="controls-toggle" aria-label="Toggle studio controls">−</button>
</div>
<div class="control-body">
<div class="control">
<label for="key">Key light <output id="key-out">620</output></label>
<input id="key" type="range" min="40" max="1400" value="620" step="10" />
</div>
<div class="control">
<label for="fill">Fill light <output id="fill-out">210</output></label>
<input id="fill" type="range" min="0" max="800" value="210" step="10" />
</div>
<div class="control">
<label for="rim">Rim light <output id="rim-out">950</output></label>
<input id="rim" type="range" min="0" max="1900" value="950" step="10" />
</div>
<div class="control">
<label for="exposure">Exposure <output id="exposure-out">1.08</output></label>
<input id="exposure" type="range" min="0.45" max="1.8" value="1.08" step="0.01" />
</div>
<div class="control">
<label for="diffuser">Diffuser veil <output id="diffuser-out">70%</output></label>
<input id="diffuser" type="range" min="0" max="100" value="70" step="1" />
</div>
<div class="control">
<label for="rotation">Turntable <output id="rotation-out">6°/s</output></label>
<input id="rotation" type="range" min="0" max="30" value="6" step="1" />
</div>
<div class="button-row">
<button class="action" id="rotation-toggle">Pause rotation</button>
<button class="action" id="sequence-toggle">Play sequence</button>
</div>
<div class="button-row">
<button class="action" id="reset">Reset framing</button>
</div>
</div>
</aside>
<div class="disclaimer">
Reflections and shadows are real-time rendering cues, not calibrated photographic measurements.
</div>
<div id="loading">
<div class="loader-cube"></div>
<div>Building the studio</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.querySelector("#stage");
const loading = document.querySelector("#loading");
const renderer = new THREE.WebGLRenderer({
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;
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd8d0c2);
scene.fog = new THREE.Fog(0xd8d0c2, 13, 31);
const camera = new THREE.PerspectiveCamera(
36,
window.innerWidth / window.innerHeight,
0.1,
80
);
const reflectionCamera = new THREE.PerspectiveCamera();
reflectionCamera.layers.set(0);
const clipPlane = new THREE.Plane(new THREE.Vector3(0, 1, 0), 1000);
renderer.clippingPlanes = [clipPlane];
// A tiny procedural environment gives the product and metal surfaces
// recognizable studio-card reflections without any external assets.
const environmentScene = new THREE.Scene();
environmentScene.background = new THREE.Color(0x80796f);
function environmentCard(position, scale, rgb) {
const geometry = new THREE.BoxGeometry(scale.x, scale.y, scale.z);
const material = new THREE.MeshBasicMaterial({
color: new THREE.Color().setRGB(rgb.x, rgb.y, rgb.z),
side: THREE.DoubleSide
});
const card = new THREE.Mesh(geometry, material);
card.position.copy(position);
environmentScene.add(card);
}
environmentCard(
new THREE.Vector3(-4, 4, 3),
new THREE.Vector3(4, 5, 0.15),
new THREE.Vector3(4.8, 4.1, 3.2)
);
environmentCard(
new THREE.Vector3(4, 2.5, 1),
new THREE.Vector3(3, 4, 0.15),
new THREE.Vector3(1.8, 2.1, 2.8)
);
environmentCard(
new THREE.Vector3(0, 5, -4),
new THREE.Vector3(5, 3, 0.15),
new THREE.Vector3(3.2, 2.2, 1.7)
);
environmentCard(
new THREE.Vector3(0, -4, 0),
new THREE.Vector3(12, 0.15, 12),
new THREE.Vector3(0.45, 0.43, 0.4)
);
const pmrem = new THREE.PMREMGenerator(renderer);
const environmentTarget = pmrem.fromScene(environmentScene, 0.055, 0.1, 50);
scene.environment = environmentTarget.texture;
pmrem.dispose();
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x252326,
transparent: true,
opacity: 0.28
});
const material = {
body: new THREE.MeshStandardMaterial({
color: 0xd85f42,
roughness: 0.48,
metalness: 0.08
}),
bodyDark: new THREE.MeshStandardMaterial({
color: 0x22272b,
roughness: 0.42,
metalness: 0.35
}),
black: new THREE.MeshStandardMaterial({
color: 0x111416,
roughness: 0.32,
metalness: 0.5
}),
metal: new THREE.MeshStandardMaterial({
color: 0x778087,
roughness: 0.2,
metalness: 0.9,
envMapIntensity: 1.7
}),
glass: new THREE.MeshPhysicalMaterial({
color: 0x102b3b,
roughness: 0.08,
metalness: 0.72,
clearcoat: 1,
clearcoatRoughness: 0.06,
envMapIntensity: 2.4
}),
cream: new THREE.MeshStandardMaterial({
color: 0xe9dfce,
roughness: 0.8
}),
floor: new THREE.MeshStandardMaterial({
color: 0xc9c1b3,
roughness: 0.9
}),
wall: new THREE.MeshStandardMaterial({
color: 0xd8d0c2,
roughness: 0.94
})
};
function addBox(parent, size, position, mat, edges = false) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size.x, size.y, size.z),
mat
);
mesh.position.copy(position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
if (edges) {
const outline = new THREE.LineSegments(
new THREE.EdgesGeometry(mesh.geometry),
edgeMaterial
);
mesh.add(outline);
}
return mesh;
}
// Studio shell: deliberately block-built to retain the voxel language.
const studio = new THREE.Group();
scene.add(studio);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(36, 36),
material.floor
);
floor.rotation.x = -Math.PI / 2;
floor.receiveShadow = true;
studio.add(floor);
addBox(
studio,
new THREE.Vector3(24, 11, 0.45),
new THREE.Vector3(0, 5.5, -8.2),
material.wall
);
addBox(
studio,
new THREE.Vector3(0.45, 11, 18),
new THREE.Vector3(-11.5, 5.5, -0.2),
material.wall
);
// Terraced cyclorama steps.
for (let i = 0; i < 4; i++) {
const height = (4 - i) * 0.28;
addBox(
studio,
new THREE.Vector3(24, height, 0.58),
new THREE.Vector3(0, height / 2, -7.88 + i * 0.58),
material.wall
);
}
// Quiet set dressing made from stacked cubes.
const dressing = new THREE.Group();
scene.add(dressing);
addBox(
dressing,
new THREE.Vector3(1.7, 0.5, 1.7),
new THREE.Vector3(-5.4, 0.25, -3.8),
material.cream
);
addBox(
dressing,
new THREE.Vector3(1.2, 0.5, 1.2),
new THREE.Vector3(-5.4, 0.75, -3.8),
material.cream
);
addBox(
dressing,
new THREE.Vector3(0.7, 0.5, 0.7),
new THREE.Vector3(-5.4, 1.25, -3.8),
material.cream
);
addBox(
dressing,
new THREE.Vector3(2.1, 0.5, 2.1),
new THREE.Vector3(5.8, 0.25, -4.5),
material.cream
);
addBox(
dressing,
new THREE.Vector3(1.4, 0.5, 1.4),
new THREE.Vector3(5.8, 0.75, -4.5),
material.cream
);
// Turntable base.
const turntableBase = new THREE.Group();
scene.add(turntableBase);
const baseMaterial = new THREE.MeshStandardMaterial({
color: 0x292c30,
roughness: 0.32,
metalness: 0.68,
envMapIntensity: 1.25
});
const base = new THREE.Mesh(
new THREE.CylinderGeometry(2.55, 2.68, 0.42, 64),
baseMaterial
);
base.position.y = 0.21;
base.castShadow = true;
base.receiveShadow = true;
turntableBase.add(base);
const platter = new THREE.Mesh(
new THREE.CylinderGeometry(2.42, 2.48, 0.13, 64),
new THREE.MeshStandardMaterial({
color: 0x34373b,
roughness: 0.19,
metalness: 0.78,
envMapIntensity: 1.7
})
);
platter.position.y = 0.485;
platter.castShadow = true;
platter.receiveShadow = true;
turntableBase.add(platter);
const rotatingAssembly = new THREE.Group();
rotatingAssembly.position.y = 0.555;
scene.add(rotatingAssembly);
const tickMaterial = new THREE.MeshStandardMaterial({
color: 0x85898b,
roughness: 0.3,
metalness: 0.65
});
for (let i = 0; i < 24; i++) {
const angle = (i / 24) * Math.PI * 2;
const tick = addBox(
rotatingAssembly,
new THREE.Vector3(i % 6 === 0 ? 0.08 : 0.035, 0.018, 0.18),
new THREE.Vector3(
Math.sin(angle) * 2.23,
0.012,
Math.cos(angle) * 2.23
),
tickMaterial
);
tick.rotation.y = angle;
}
// Voxel camera product.
const product = new THREE.Group();
product.rotation.y = -0.14;
rotatingAssembly.add(product);
addBox(
product,
new THREE.Vector3(2.7, 1.55, 0.9),
new THREE.Vector3(0, 0.96, 0),
material.body,
true
);
addBox(
product,
new THREE.Vector3(2.78, 0.22, 0.96),
new THREE.Vector3(0, 0.31, 0),
material.bodyDark,
true
);
addBox(
product,
new THREE.Vector3(2.78, 0.26, 0.96),
new THREE.Vector3(0, 1.75, -0.02),
material.bodyDark,
true
);
addBox(
product,
new THREE.Vector3(0.72, 0.38, 0.5),
new THREE.Vector3(-0.55, 2.04, -0.05),
material.bodyDark,
true
);
addBox(
product,
new THREE.Vector3(0.28, 0.18, 0.28),
new THREE.Vector3(-1.03, 1.99, 0.02),
new THREE.MeshStandardMaterial({
color: 0xf0b83c,
roughness: 0.28,
metalness: 0.55
}),
true
);
addBox(
product,
new THREE.Vector3(0.25, 0.85, 0.96),
new THREE.Vector3(-1.43, 0.95, 0),
material.bodyDark,
true
);
function squareFrame(parent, centerX, centerY, z, size, bar, depth, mat) {
const half = size / 2;
addBox(
parent,
new THREE.Vector3(size, bar, depth),
new THREE.Vector3(centerX, centerY + half - bar / 2, z),
mat,
true
);
addBox(
parent,
new THREE.Vector3(size, bar, depth),
new THREE.Vector3(centerX, centerY - half + bar / 2, z),
mat,
true
);
addBox(
parent,
new THREE.Vector3(bar, size - bar * 2, depth),
new THREE.Vector3(centerX - half + bar / 2, centerY, z),
mat,
true
);
addBox(
parent,
new THREE.Vector3(bar, size - bar * 2, depth),
new THREE.Vector3(centerX + half - bar / 2, centerY, z),
mat,
true
);
}
squareFrame(product, 0.25, 0.96, 0.56, 1.34, 0.15, 0.25, material.black);
squareFrame(product, 0.25, 0.96, 0.75, 1.12, 0.13, 0.22, material.metal);
squareFrame(product, 0.25, 0.96, 0.91, 0.92, 0.12, 0.18, material.black);
const lens = addBox(
product,
new THREE.Vector3(0.72, 0.72, 0.11),
new THREE.Vector3(0.25, 0.96, 1.01),
material.glass,
true
);
lens.castShadow = false;
addBox(
product,
new THREE.Vector3(0.13, 0.04, 0.03),
new THREE.Vector3(0.07, 1.14, 1.075),
new THREE.MeshBasicMaterial({ color: 0xbfe8f5 })
);
// Pixel-like label texture.
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 256;
labelCanvas.height = 128;
const labelContext = labelCanvas.getContext("2d");
labelContext.fillStyle = "#eee4d3";
labelContext.fillRect(0, 0, 256, 128);
labelContext.fillStyle = "#26272a";
labelContext.font = "bold 58px monospace";
labelContext.textAlign = "center";
labelContext.textBaseline = "middle";
labelContext.fillText("35", 128, 66);
const labelTexture = new THREE.CanvasTexture(labelCanvas);
labelTexture.colorSpace = THREE.SRGBColorSpace;
const label = new THREE.Mesh(
new THREE.PlaneGeometry(0.43, 0.22),
new THREE.MeshBasicMaterial({ map: labelTexture })
);
label.position.set(-0.93, 1.25, 0.456);
product.add(label);
addBox(
product,
new THREE.Vector3(0.48, 0.1, 0.34),
new THREE.Vector3(0.83, 1.94, -0.03),
material.metal,
true
);
// Lighting rig.
const hemisphere = new THREE.HemisphereLight(0xd9e5f2, 0x8f7964, 1.05);
scene.add(hemisphere);
function createSpot(color, intensity, position, angle, penumbra) {
const light = new THREE.SpotLight(
color,
intensity,
30,
angle,
penumbra,
2
);
light.position.copy(position);
light.target.position.set(0, 1.35, 0);
light.castShadow = true;
light.shadow.mapSize.set(
window.innerWidth < 760 ? 1024 : 2048,
window.innerWidth < 760 ? 1024 : 2048
);
light.shadow.camera.near = 0.5;
light.shadow.camera.far = 24;
light.shadow.bias = -0.00035;
light.shadow.normalBias = 0.025;
scene.add(light, light.target);
return light;
}
const keyLight = createSpot(
0xffead1,
620,
new THREE.Vector3(-4.8, 5.3, 4.6),
0.53,
0.72
);
const fillLight = createSpot(
0xc8dcff,
210,
new THREE.Vector3(5.2, 3.7, 2.7),
0.58,
0.82
);
const rimLight = createSpot(
0xffc594,
950,
new THREE.Vector3(-3.2, 5.3, -5.3),
0.48,
0.76
);
function makePanel(position, size, color, intensity) {
const group = new THREE.Group();
group.position.copy(position);
group.lookAt(new THREE.Vector3(0, 1.35, 0));
const frameMaterial = new THREE.MeshStandardMaterial({
color: 0x191b1d,
roughness: 0.62,
metalness: 0.28
});
const frame = new THREE.Mesh(
new THREE.BoxGeometry(size.x, size.y, 0.18),
frameMaterial
);
group.add(frame);
const diffuserMaterial = new THREE.MeshPhysicalMaterial({
color,
emissive: color,
emissiveIntensity: intensity,
roughness: 0.88,
transparent: true,
opacity: 0.84,
transmission: 0.08,
side: THREE.DoubleSide
});
const diffuser = new THREE.Mesh(
new THREE.BoxGeometry(size.x - 0.16, size.y - 0.16, 0.055),
diffuserMaterial
);
diffuser.position.z = 0.12;
group.add(diffuser);
const poleHeight = Math.max(0.2, position.y - size.y * 0.5 - 0.25);
const pole = new THREE.Mesh(
new THREE.BoxGeometry(0.07, poleHeight, 0.07),
frameMaterial
);
pole.position.set(position.x, poleHeight / 2, position.z);
pole.castShadow = true;
scene.add(pole);
const foot = new THREE.Mesh(
new THREE.BoxGeometry(0.7, 0.07, 0.7),
frameMaterial
);
foot.position.set(position.x, 0.035, position.z);
foot.castShadow = true;
scene.add(foot);
scene.add(group);
return { group, diffuserMaterial, intensity };
}
const panels = [
makePanel(
new THREE.Vector3(-4.8, 5.3, 4.6),
new THREE.Vector3(2.8, 3.7, 0.3),
0xffe4bf,
1.1
),
makePanel(
new THREE.Vector3(5.2, 3.7, 2.7),
new THREE.Vector3(2.2, 3.1, 0.3),
0xd7e5ff,
0.55
),
makePanel(
new THREE.Vector3(-3.2, 5.3, -5.3),
new THREE.Vector3(2.4, 2.8, 0.3),
0xffc38b,
1.35
)
];
// Real-time planar reflection on the turntable.
const reflectionHeight = 0.552;
const reflectionTarget = new THREE.WebGLRenderTarget(1, 1, {
minFilter: THREE.LinearFilter,
magFilter: THREE.LinearFilter,
depthBuffer: true
});
const reflectionTextureMatrix = new THREE.Matrix4();
const reflectionCircle = new THREE.Mesh(
new THREE.CircleGeometry(2.36, 96),
new THREE.ShaderMaterial({
uniforms: {
tReflection: { value: reflectionTarget.texture },
textureMatrix: { value: reflectionTextureMatrix },
uStrength: { value: 0.42 }
},
vertexShader: `
uniform mat4 textureMatrix;
varying vec4 vReflectionUv;
void main() {
vReflectionUv = textureMatrix * vec4(position, 1.0);
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,
fragmentShader: `
uniform sampler2D tReflection;
uniform float uStrength;
varying vec4 vReflectionUv;
void main() {
vec4 reflected = texture2DProj(tReflection, vReflectionUv);
gl_FragColor = vec4(reflected.rgb, reflected.a * uStrength);
#include <tonemapping_fragment>
#include <colorspace_fragment>
}
`,
transparent: true,
depthWrite: false,
blending: THREE.NormalBlending
})
);
reflectionCircle.rotation.x = -Math.PI / 2;
reflectionCircle.position.y = reflectionHeight + 0.003;
reflectionCircle.layers.set(1);
scene.add(reflectionCircle);
camera.layers.enable(1);
function resizeReflectionTarget() {
const ratio = Math.min(window.devicePixelRatio, 1.5);
reflectionTarget.setSize(
Math.max(1, Math.floor(window.innerWidth * ratio * 0.55)),
Math.max(1, Math.floor(window.innerHeight * ratio * 0.55))
);
}
resizeReflectionTarget();
const cameraState = {
yaw: 0.52,
pitch: 0.28,
radius: 8.6,
fov: 36,
target: new THREE.Vector3(0, 1.38, 0)
};
const desiredCamera = {
yaw: cameraState.yaw,
pitch: cameraState.pitch,
radius: cameraState.radius,
fov: cameraState.fov,
target: cameraState.target.clone()
};
function updateCamera(dt) {
const damping = 1 - Math.exp(-dt * 4.6);
cameraState.yaw = THREE.MathUtils.lerp(cameraState.yaw, desiredCamera.yaw, damping);
cameraState.pitch = THREE.MathUtils.lerp(cameraState.pitch, desiredCamera.pitch, damping);
cameraState.radius = THREE.MathUtils.lerp(cameraState.radius, desiredCamera.radius, damping);
cameraState.fov = THREE.MathUtils.lerp(cameraState.fov, desiredCamera.fov, damping);
cameraState.target.lerp(desiredCamera.target, damping);
const cosPitch = Math.cos(cameraState.pitch);
camera.position.set(
cameraState.target.x + Math.sin(cameraState.yaw) * cosPitch * cameraState.radius,
cameraState.target.y + Math.sin(cameraState.pitch) * cameraState.radius,
cameraState.target.z + Math.cos(cameraState.yaw) * cosPitch * cameraState.radius
);
camera.lookAt(cameraState.target);
if (Math.abs(camera.fov - cameraState.fov) > 0.001) {
camera.fov = cameraState.fov;
camera.updateProjectionMatrix();
}
}
// Direct camera controls; no examples/addons are used.
let pointerActive = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
pointerActive = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointerActive) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
desiredCamera.yaw -= dx * 0.005;
desiredCamera.pitch = THREE.MathUtils.clamp(
desiredCamera.pitch + dy * 0.004,
0.08,
0.82
);
});
function endPointer(event) {
pointerActive = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
desiredCamera.radius = THREE.MathUtils.clamp(
desiredCamera.radius + event.deltaY * 0.007,
3.8,
14
);
}, { passive: false });
// Story and shot presets.
const shots = [
{
label: "Frame 01 / Hero",
title: "The reveal",
copy: "A broad studio frame introduces the object, its turntable, and the warm geometry of the set.",
camera: { yaw: 0.52, pitch: 0.28, radius: 8.6, fov: 36, target: [0, 1.38, 0] },
lights: { key: 620, fill: 210, rim: 950, exposure: 1.08 }
},
{
label: "Frame 02 / Detail",
title: "Material study",
copy: "A closer crop lets the stepped lens, metallic rings, and reflection carry the narrative.",
camera: { yaw: 0.84, pitch: 0.18, radius: 5.35, fov: 31, target: [0.12, 1.55, 0.18] },
lights: { key: 780, fill: 120, rim: 1050, exposure: 1.12 }
},
{
label: "Frame 03 / Rim",
title: "After the silhouette",
copy: "A lower, wider angle lets the backlight separate the camera from the studio architecture.",
camera: { yaw: -0.48, pitch: 0.12, radius: 9.7, fov: 40, target: [0, 1.25, 0] },
lights: { key: 260, fill: 70, rim: 1450, exposure: 0.92 }
}
];
const keyInput = document.querySelector("#key");
const fillInput = document.querySelector("#fill");
const rimInput = document.querySelector("#rim");
const exposureInput = document.querySelector("#exposure");
const diffuserInput = document.querySelector("#diffuser");
const rotationInput = document.querySelector("#rotation");
function output(id, value) {
document.querySelector(id).textContent = value;
}
function updateLights() {
keyLight.intensity = Number(keyInput.value);
fillLight.intensity = Number(fillInput.value);
rimLight.intensity = Number(rimInput.value);
output("#key-out", Math.round(keyLight.intensity));
output("#fill-out", Math.round(fillLight.intensity));
output("#rim-out", Math.round(rimLight.intensity));
panels[0].diffuserMaterial.emissiveIntensity = 0.25 + keyLight.intensity / 650;
panels[1].diffuserMaterial.emissiveIntensity = 0.12 + fillLight.intensity / 550;
panels[2].diffuserMaterial.emissiveIntensity = 0.2 + rimLight.intensity / 700;
}
function updateExposure() {
renderer.toneMappingExposure = Number(exposureInput.value);
output("#exposure-out", Number(exposureInput.value).toFixed(2));
}
function updateDiffuser() {
const amount = Number(diffuserInput.value) / 100;
for (const panel of panels) {
panel.diffuserMaterial.opacity = 0.22 + amount * 0.72;
}
output("#diffuser-out", `${Math.round(amount * 100)}%`);
}
keyInput.addEventListener("input", updateLights);
fillInput.addEventListener("input", updateLights);
rimInput.addEventListener("input", updateLights);
exposureInput.addEventListener("input", updateExposure);
diffuserInput.addEventListener("input", updateDiffuser);
rotationInput.addEventListener("input", () => {
output("#rotation-out", `${rotationInput.value}°/s`);
});
let activeShot = 0;
let sequencePlaying = false;
let sequenceClock = 0;
let rotationPaused = false;
function applyShot(index) {
activeShot = index;
const shot = shots[index];
desiredCamera.yaw = shot.camera.yaw;
desiredCamera.pitch = shot.camera.pitch;
desiredCamera.radius = shot.camera.radius;
desiredCamera.fov = shot.camera.fov;
desiredCamera.target.set(...shot.camera.target);
keyInput.value = shot.lights.key;
fillInput.value = shot.lights.fill;
rimInput.value = shot.lights.rim;
exposureInput.value = shot.lights.exposure;
updateLights();
updateExposure();
document.querySelector("#frame-label").textContent = shot.label;
document.querySelector("#story-title").textContent = shot.title;
document.querySelector("#story-copy").textContent = shot.copy;
document.querySelectorAll("[data-shot]").forEach((button) => {
button.classList.toggle("active", Number(button.dataset.shot) === index);
});
}
document.querySelectorAll("[data-shot]").forEach((button) => {
button.addEventListener("click", () => {
sequencePlaying = false;
document.querySelector("#sequence-toggle").classList.remove("active");
document.querySelector("#sequence-toggle").textContent = "Play sequence";
applyShot(Number(button.dataset.shot));
});
});
document.querySelector("#sequence-toggle").addEventListener("click", (event) => {
sequencePlaying = !sequencePlaying;
sequenceClock = 0;
event.currentTarget.classList.toggle("active", sequencePlaying);
event.currentTarget.textContent = sequencePlaying ? "Stop sequence" : "Play sequence";
if (sequencePlaying) applyShot((activeShot + 1) % shots.length);
});
document.querySelector("#rotation-toggle").addEventListener("click", (event) => {
rotationPaused = !rotationPaused;
event.currentTarget.classList.toggle("active", rotationPaused);
event.currentTarget.textContent = rotationPaused ? "Resume rotation" : "Pause rotation";
});
document.querySelector("#reset").addEventListener("click", () => applyShot(0));
const controls = document.querySelector("#controls");
document.querySelector("#controls-toggle").addEventListener("click", (event) => {
controls.classList.toggle("collapsed");
event.currentTarget.textContent = controls.classList.contains("collapsed") ? "+" : "−";
});
updateLights();
updateExposure();
updateDiffuser();
function renderReflection() {
camera.updateMatrixWorld();
reflectionCircle.updateMatrixWorld();
const cameraDirection = new THREE.Vector3();
camera.getWorldDirection(cameraDirection);
reflectionCamera.position.copy(camera.position);
reflectionCamera.position.y = reflectionHeight * 2 - camera.position.y;
const reflectedDirection = new THREE.Vector3(
cameraDirection.x,
-cameraDirection.y,
cameraDirection.z
);
const reflectedLookTarget = reflectionCamera.position.clone().add(reflectedDirection);
reflectionCamera.up.set(0, 1, 0);
reflectionCamera.lookAt(reflectedLookTarget);
reflectionCamera.projectionMatrix.copy(camera.projectionMatrix);
reflectionCamera.projectionMatrixInverse.copy(camera.projectionMatrixInverse);
reflectionCamera.updateMatrixWorld(true);
// Keep only geometry above the reflection plane.
clipPlane.constant = -reflectionHeight;
reflectionTextureMatrix.set(
0.5, 0.0, 0.0, 0.5,
0.0, 0.5, 0.0, 0.5,
0.0, 0.0, 0.5, 0.5,
0.0, 0.0, 0.0, 1.0
);
reflectionTextureMatrix.multiply(reflectionCamera.projectionMatrix);
reflectionTextureMatrix.multiply(reflectionCamera.matrixWorldInverse);
reflectionTextureMatrix.multiply(reflectionCircle.matrixWorld);
renderer.setRenderTarget(reflectionTarget);
renderer.clear();
renderer.render(scene, reflectionCamera);
renderer.setRenderTarget(null);
// The reflection plane remains active but no longer clips the main view.
clipPlane.constant = 1000;
}
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
if (sequencePlaying) {
sequenceClock += dt;
if (sequenceClock >= 7) {
sequenceClock = 0;
applyShot((activeShot + 1) % shots.length);
}
}
if (!rotationPaused) {
rotatingAssembly.rotation.y +=
THREE.MathUtils.degToRad(Number(rotationInput.value)) * dt;
}
updateCamera(dt);
// Generate shadows and the planar reflection once per frame.
renderer.shadowMap.autoUpdate = true;
renderReflection();
renderer.shadowMap.autoUpdate = false;
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
resizeReflectionTarget();
});
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") applyShot(0);
if (event.key === " ") {
event.preventDefault();
rotationPaused = !rotationPaused;
const button = document.querySelector("#rotation-toggle");
button.classList.toggle("active", rotationPaused);
button.textContent = rotationPaused ? "Resume rotation" : "Pause rotation";
}
});
updateCamera(0.016);
animate();
requestAnimationFrame(() => loading.classList.add("hidden"));
</script>
</body>
</html>
```