Prompt specification
Build or customize the Three.js 3D scene "Choose a Cup Without a Handle" 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: Choose a Cup Without a Handle
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/choose-a-cup-without-a-handle-x3398
Scene Description Prompt:
Filter stylized cups, bowls, and jars using combined constraints such as “cup without a handle.” Show remaining candidates. Three.js from cdnjs, standalone HTML.
Working Three.js Starter (choose-a-cup-without-a-handle-x3398):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#f2efe7" />
<title>Vessel — Shape Filter Studio</title>
<style>
:root {
--paper: #f3f0e8;
--paper-deep: #e8e3d8;
--panel: #faf8f2;
--ink: #22251f;
--muted: #73766d;
--line: #d9d5ca;
--accent: #b85f43;
--accent-soft: #f1d9cf;
--sage: #758575;
--stage: #dfe3d9;
--shadow: 0 18px 50px rgba(39, 42, 34, 0.1);
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
min-height: 100%;
background: var(--paper);
color: var(--ink);
font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
.app {
min-height: 100vh;
display: flex;
flex-direction: column;
}
.topbar {
height: 76px;
flex: 0 0 76px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 30px;
border-bottom: 1px solid var(--line);
background: rgba(250, 248, 242, 0.84);
backdrop-filter: blur(18px);
position: relative;
z-index: 10;
}
.brand {
display: flex;
align-items: center;
gap: 14px;
letter-spacing: 0.14em;
text-transform: uppercase;
font-size: 12px;
font-weight: 750;
}
.brand-mark {
width: 32px;
height: 32px;
border: 1px solid var(--ink);
border-radius: 50%;
display: grid;
place-items: center;
font-size: 16px;
font-weight: 500;
letter-spacing: 0;
}
.brand-divider {
width: 1px;
height: 20px;
background: var(--line);
}
.brand-subtitle {
color: var(--muted);
font-weight: 500;
letter-spacing: 0.08em;
}
.top-actions {
display: flex;
align-items: center;
gap: 12px;
}
.logic-badge {
display: flex;
align-items: center;
gap: 8px;
color: var(--muted);
font-size: 12px;
}
.logic-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--sage);
box-shadow: 0 0 0 4px rgba(117, 133, 117, 0.12);
}
.icon-button {
width: 38px;
height: 38px;
border: 1px solid var(--line);
border-radius: 50%;
background: transparent;
cursor: pointer;
transition: background 160ms ease, transform 160ms ease;
}
.icon-button:hover {
background: var(--paper-deep);
transform: translateY(-1px);
}
.workspace {
min-height: 0;
flex: 1;
display: grid;
grid-template-columns: 310px minmax(0, 1fr);
}
.sidebar {
border-right: 1px solid var(--line);
background: var(--panel);
padding: 30px 26px;
overflow-y: auto;
}
.eyebrow {
margin: 0 0 8px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1,
h2,
h3,
p {
margin-top: 0;
}
.sidebar h2 {
margin-bottom: 8px;
font-size: 26px;
line-height: 1.1;
letter-spacing: -0.04em;
}
.intro {
margin-bottom: 28px;
color: var(--muted);
font-size: 13px;
line-height: 1.6;
}
.filter-section {
padding: 21px 0;
border-top: 1px solid var(--line);
}
.filter-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 13px;
font-size: 12px;
font-weight: 750;
}
.filter-number {
color: #a4a59f;
font-size: 10px;
letter-spacing: 0.12em;
}
.preset-list {
display: grid;
gap: 8px;
}
.preset-button {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 12px 13px;
border: 1px solid var(--line);
border-radius: 10px;
background: transparent;
cursor: pointer;
text-align: left;
font-size: 12px;
transition: 160ms ease;
}
.preset-button:hover {
border-color: #aaa99f;
background: #fff;
}
.preset-button.active {
color: #8f442e;
border-color: #d7a38f;
background: var(--accent-soft);
}
.preset-arrow {
color: #999b92;
font-size: 16px;
}
.segmented {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 5px;
padding: 4px;
border-radius: 10px;
background: #ebe7de;
}
.segmented.four {
grid-template-columns: repeat(4, 1fr);
}
.segment-button {
min-height: 35px;
padding: 7px 6px;
border: 0;
border-radius: 7px;
background: transparent;
color: #74766e;
cursor: pointer;
font-size: 11px;
font-weight: 650;
transition: 150ms ease;
}
.segment-button:hover {
color: var(--ink);
}
.segment-button.active {
background: #fffdf8;
color: var(--ink);
box-shadow: 0 2px 8px rgba(38, 41, 34, 0.08);
}
.rule-preview {
margin-top: 18px;
padding: 14px;
border: 1px dashed #c9c5b9;
border-radius: 10px;
background: #f5f1e8;
}
.rule-label {
margin-bottom: 8px;
color: #96978f;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.rule-text {
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 11px;
line-height: 1.7;
overflow-wrap: anywhere;
}
.rule-text strong {
color: var(--accent);
}
.reset-button {
width: 100%;
margin-top: 20px;
padding: 11px;
border: 0;
border-radius: 9px;
background: var(--ink);
color: #fff;
cursor: pointer;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.04em;
transition: transform 150ms ease, background 150ms ease;
}
.reset-button:hover {
background: #3b4037;
transform: translateY(-1px);
}
.main {
min-width: 0;
min-height: 0;
display: flex;
flex-direction: column;
background: var(--stage);
}
.results-header {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 24px;
padding: 27px 32px 24px;
border-bottom: 1px solid rgba(103, 111, 98, 0.18);
background: var(--stage);
}
.results-title-wrap {
min-width: 0;
}
.results-header h2 {
margin: 0 0 5px;
font-size: clamp(24px, 3vw, 38px);
line-height: 1.05;
letter-spacing: -0.045em;
}
.result-summary {
margin: 0;
color: #6e756b;
font-size: 13px;
}
.active-rules {
display: flex;
justify-content: flex-end;
flex-wrap: wrap;
gap: 7px;
max-width: 48%;
}
.rule-chip {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 8px 11px;
border: 1px solid rgba(97, 106, 92, 0.2);
border-radius: 99px;
background: rgba(250, 249, 243, 0.64);
color: #596056;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.04em;
white-space: nowrap;
}
.rule-chip::before {
content: "";
width: 5px;
height: 5px;
border-radius: 50%;
background: var(--accent);
}
.viewport {
position: relative;
min-height: 390px;
flex: 1 1 58%;
overflow: hidden;
isolation: isolate;
}
#scene {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.scene-help {
position: absolute;
top: 18px;
left: 20px;
z-index: 2;
display: flex;
align-items: center;
gap: 9px;
padding: 9px 12px;
border: 1px solid rgba(87, 94, 82, 0.15);
border-radius: 99px;
background: rgba(249, 248, 242, 0.66);
color: #70766d;
font-size: 10px;
letter-spacing: 0.03em;
backdrop-filter: blur(8px);
pointer-events: none;
}
.mouse-icon {
width: 15px;
height: 19px;
border: 1px solid #7e847b;
border-radius: 8px;
position: relative;
}
.mouse-icon::after {
content: "";
position: absolute;
top: 3px;
left: 6px;
width: 2px;
height: 5px;
border-radius: 2px;
background: #7e847b;
}
.scene-counter {
position: absolute;
right: 22px;
top: 20px;
z-index: 2;
color: rgba(47, 53, 45, 0.52);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 10px;
letter-spacing: 0.08em;
pointer-events: none;
}
.empty-state {
position: absolute;
inset: 0;
z-index: 3;
display: grid;
place-items: center;
padding: 30px;
text-align: center;
pointer-events: none;
}
.empty-state.hidden {
display: none;
}
.empty-card {
width: min(360px, 100%);
padding: 28px;
border: 1px solid rgba(77, 84, 72, 0.15);
border-radius: 18px;
background: rgba(250, 248, 242, 0.9);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
}
.empty-symbol {
width: 52px;
height: 52px;
margin: 0 auto 16px;
border: 1px solid #c8c8bf;
border-radius: 50%;
display: grid;
place-items: center;
color: #949a91;
font-size: 22px;
}
.empty-card h3 {
margin-bottom: 8px;
font-size: 19px;
}
.empty-card p {
margin-bottom: 18px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.empty-card button {
padding: 10px 14px;
border: 0;
border-radius: 8px;
background: var(--ink);
color: white;
cursor: pointer;
font-size: 11px;
font-weight: 700;
pointer-events: auto;
}
.gallery {
flex: 0 0 auto;
max-height: 270px;
padding: 18px 24px 22px;
overflow-y: auto;
border-top: 1px solid rgba(103, 111, 98, 0.18);
background: #e9e9e1;
}
.gallery-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.gallery-heading h3 {
margin: 0;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.surprise-button {
padding: 7px 10px;
border: 1px solid #c7c9c0;
border-radius: 7px;
background: transparent;
color: #697066;
cursor: pointer;
font-size: 10px;
font-weight: 700;
transition: 150ms ease;
}
.surprise-button:hover {
background: #f8f6ef;
color: var(--ink);
}
.card-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
gap: 10px;
}
.candidate-card {
min-width: 0;
display: grid;
grid-template-columns: 62px minmax(0, 1fr);
gap: 12px;
align-items: center;
padding: 10px;
border: 1px solid #d0d1c8;
border-radius: 12px;
background: rgba(250, 249, 244, 0.8);
cursor: pointer;
text-align: left;
transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}
.candidate-card:hover {
transform: translateY(-2px);
border-color: #aeb1a7;
background: #fffdf8;
}
.candidate-card.selected {
border-color: #c88369;
background: #fffaf4;
box-shadow: inset 0 0 0 1px rgba(200, 131, 105, 0.25);
}
.vessel-thumb {
width: 62px;
height: 62px;
border-radius: 9px;
display: grid;
place-items: center;
background: #e7e5dc;
}
.vessel-thumb svg {
width: 52px;
height: 52px;
overflow: visible;
}
.candidate-copy {
min-width: 0;
}
.candidate-name {
display: block;
margin-bottom: 5px;
overflow: hidden;
color: #31352e;
font-size: 12px;
font-weight: 750;
text-overflow: ellipsis;
white-space: nowrap;
}
.candidate-meta {
display: flex;
flex-wrap: wrap;
gap: 5px;
}
.meta-tag {
padding: 3px 6px;
border-radius: 4px;
background: #e8e7df;
color: #777b72;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.meta-tag.accent {
background: var(--accent-soft);
color: #9e523a;
}
.no-cards {
padding: 24px 8px;
color: var(--muted);
font-size: 12px;
text-align: center;
}
@media (max-width: 900px) {
.workspace {
grid-template-columns: 255px minmax(0, 1fr);
}
.sidebar {
padding: 24px 20px;
}
.results-header {
padding: 23px 22px;
}
.active-rules {
max-width: 42%;
}
}
@media (max-width: 700px) {
.topbar {
height: 64px;
flex-basis: 64px;
padding: 0 18px;
}
.brand-subtitle,
.brand-divider,
.logic-badge {
display: none;
}
.workspace {
display: flex;
flex-direction: column;
}
.sidebar {
border-right: 0;
border-bottom: 1px solid var(--line);
padding: 22px 18px;
}
.intro,
.rule-preview {
display: none;
}
.preset-list {
grid-template-columns: repeat(3, 1fr);
}
.preset-button {
justify-content: center;
padding: 10px 7px;
text-align: center;
font-size: 10px;
}
.preset-arrow {
display: none;
}
.filter-section {
padding: 15px 0;
}
.filter-section:first-of-type {
border-top: 0;
}
.reset-button {
margin-top: 14px;
}
.results-header {
align-items: flex-start;
flex-direction: column;
gap: 12px;
}
.active-rules {
justify-content: flex-start;
max-width: 100%;
}
.viewport {
min-height: 420px;
}
.gallery {
padding-inline: 16px;
}
}
</style>
</head>
<body>
<div class="app">
<header class="topbar">
<div class="brand">
<span class="brand-mark">V</span>
<span>Vessel</span>
<span class="brand-divider"></span>
<span class="brand-subtitle">Shape filter studio</span>
</div>
<div class="top-actions">
<div class="logic-badge">
<span class="logic-dot"></span>
Combined constraints enabled
</div>
<button class="icon-button" id="resetTop" title="Reset all filters" aria-label="Reset all filters">↺</button>
</div>
</header>
<div class="workspace">
<aside class="sidebar">
<p class="eyebrow">Filter library</p>
<h2>Find the right form.</h2>
<p class="intro">
Combine type, handle, and lid conditions. Every rule must match for a vessel to remain.
</p>
<section class="filter-section">
<div class="filter-heading">
<span>Quick filters</span>
<span class="filter-number">01</span>
</div>
<div class="preset-list">
<button class="preset-button active" data-preset="cupWithout">
Cup without a handle <span class="preset-arrow">→</span>
</button>
<button class="preset-button" data-preset="bowl">
Any bowl <span class="preset-arrow">→</span>
</button>
<button class="preset-button" data-preset="jarLid">
Jar with a lid <span class="preset-arrow">→</span>
</button>
</div>
</section>
<section class="filter-section">
<div class="filter-heading">
<span>Vessel type</span>
<span class="filter-number">02</span>
</div>
<div class="segmented four" id="typeFilter">
<button class="segment-button" data-value="all">All</button>
<button class="segment-button active" data-value="cup">Cup</button>
<button class="segment-button" data-value="bowl">Bowl</button>
<button class="segment-button" data-value="jar">Jar</button>
</div>
</section>
<section class="filter-section">
<div class="filter-heading">
<span>Handle</span>
<span class="filter-number">03</span>
</div>
<div class="segmented" id="handleFilter">
<button class="segment-button active" data-value="any">Any</button>
<button class="segment-button" data-value="with">With</button>
<button class="segment-button" data-value="without">Without</button>
</div>
</section>
<section class="filter-section">
<div class="filter-heading">
<span>Lid</span>
<span class="filter-number">04</span>
</div>
<div class="segmented" id="lidFilter">
<button class="segment-button active" data-value="any">Any</button>
<button class="segment-button" data-value="with">With</button>
<button class="segment-button" data-value="without">Without</button>
</div>
</section>
<div class="rule-preview">
<div class="rule-label">Active logic</div>
<div class="rule-text" id="ruleText"></div>
</div>
<button class="reset-button" id="resetFilters">Reset all filters</button>
</aside>
<main class="main">
<section class="results-header">
<div class="results-title-wrap">
<p class="eyebrow">Filtered collection</p>
<h2 id="resultsTitle">Cup without a handle</h2>
<p class="result-summary" id="resultSummary">3 candidates remain</p>
</div>
<div class="active-rules" id="activeRules"></div>
</section>
<section class="viewport" aria-label="Interactive 3D vessel viewer">
<canvas id="scene" aria-label="Drag to rotate the vessels and scroll to zoom"></canvas>
<div class="scene-help">
<span class="mouse-icon"></span>
Drag to rotate · scroll to zoom
</div>
<div class="scene-counter" id="sceneCounter">03 / 12</div>
<div class="empty-state hidden" id="emptyState">
<div class="empty-card">
<div class="empty-symbol">∅</div>
<h3>No vessels match</h3>
<p>Try removing one constraint or choosing a different vessel type.</p>
<button id="emptyReset">Clear filters</button>
</div>
</div>
</section>
<section class="gallery">
<div class="gallery-heading">
<h3>Remaining candidates</h3>
<button class="surprise-button" id="surpriseButton">Show me one ↗</button>
</div>
<div class="card-list" id="cardList"></div>
</section>
</main>
</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 canvas = document.querySelector('#scene');
const cardList = document.querySelector('#cardList');
const resultsTitle = document.querySelector('#resultsTitle');
const resultSummary = document.querySelector('#resultSummary');
const activeRules = document.querySelector('#activeRules');
const sceneCounter = document.querySelector('#sceneCounter');
const emptyState = document.querySelector('#emptyState');
const ruleText = document.querySelector('#ruleText');
const candidates = [
{
id: 'pebble-cup',
name: 'Pebble Cup',
type: 'cup',
handle: false,
lid: false,
color: '#c96e51',
accent: '#e6b09a',
profile: 'cup'
},
{
id: 'ripple-cup',
name: 'Ripple Cup',
type: 'cup',
handle: false,
lid: false,
color: '#839783',
accent: '#c7d0bd',
profile: 'rippleCup'
},
{
id: 'flare-cup',
name: 'Flare Cup',
type: 'cup',
handle: false,
lid: false,
color: '#e2d5bf',
accent: '#b8a58b',
profile: 'flareCup'
},
{
id: 'loop-cup',
name: 'Loop Cup',
type: 'cup',
handle: true,
lid: false,
color: '#71899a',
accent: '#b7c8d1',
profile: 'cup'
},
{
id: 'siphon-cup',
name: 'Siphon Cup',
type: 'cup',
handle: true,
lid: false,
color: '#d2a35f',
accent: '#ebd0a2',
profile: 'tallCup'
},
{
id: 'dune-bowl',
name: 'Dune Bowl',
type: 'bowl',
handle: false,
lid: false,
color: '#d4b58c',
accent: '#ead7bd',
profile: 'bowl'
},
{
id: 'twin-bowl',
name: 'Twin Bowl',
type: 'bowl',
handle: true,
lid: false,
color: '#9a7b82',
accent: '#cbb4ba',
profile: 'bowl'
},
{
id: 'deep-bowl',
name: 'Deep Basin',
type: 'bowl',
handle: false,
lid: false,
color: '#7e8c91',
accent: '#bec8ca',
profile: 'deepBowl'
},
{
id: 'arc-jar',
name: 'Arc Jar',
type: 'jar',
handle: false,
lid: true,
color: '#bb7259',
accent: '#dbaa93',
profile: 'jar'
},
{
id: 'bell-jar',
name: 'Bell Jar',
type: 'jar',
handle: false,
lid: false,
color: '#91a48d',
accent: '#c9d4c2',
profile: 'bellJar'
},
{
id: 'loop-jar',
name: 'Loop Jar',
type: 'jar',
handle: true,
lid: false,
color: '#788b99',
accent: '#b7c8d1',
profile: 'jar'
},
{
id: 'tall-jar',
name: 'Tall Store Jar',
type: 'jar',
handle: false,
lid: true,
color: '#dfd4bd',
accent: '#b8aa92',
profile: 'tallJar'
}
];
const state = {
type: 'cup',
handle: 'without',
lid: 'any',
selectedId: null
};
const scene = new THREE.Scene();
scene.background = new THREE.Color('#dfe3d9');
scene.fog = new THREE.Fog('#dfe3d9', 15, 28);
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
const camera = new THREE.PerspectiveCamera(35, 1, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 0.95, 0);
const world = new THREE.Group();
scene.add(world);
const hemisphere = new THREE.HemisphereLight('#fff8e9', '#7d8877', 2.3);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight('#fff3dc', 4.2);
keyLight.position.set(-5, 9, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -10;
keyLight.shadow.camera.right = 10;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0003;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight('#d7e8ef', 2.2);
rimLight.position.set(7, 4, -6);
scene.add(rimLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
new THREE.MeshStandardMaterial({ color: '#d8ddd2', roughness: 1 })
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.035;
floor.receiveShadow = true;
scene.add(floor);
const stage = new THREE.Mesh(
new THREE.CircleGeometry(8.2, 96),
new THREE.MeshStandardMaterial({ color: '#e7e9e1', roughness: 0.96 })
);
stage.rotation.x = -Math.PI / 2;
stage.position.y = -0.02;
stage.receiveShadow = true;
scene.add(stage);
const profiles = {
cup: [
[0, 0], [0.57, 0], [0.63, 0.08], [0.67, 0.32],
[0.75, 1.45], [0.91, 1.76], [0.93, 1.83],
[0.80, 1.83], [0.61, 1.46], [0.53, 0.26], [0, 0.18]
],
rippleCup: [
[0, 0], [0.55, 0], [0.65, 0.12], [0.60, 0.34],
[0.72, 0.58], [0.63, 0.82], [0.75, 1.05],
[0.66, 1.30], [0.86, 1.68], [0.92, 1.80],
[0.79, 1.80], [0.54, 1.27], [0.48, 0.25], [0, 0.18]
],
flareCup: [
[0, 0], [0.54, 0], [0.60, 0.12], [0.56, 0.58],
[0.68, 1.25], [0.94, 1.72], [0.98, 1.84],
[0.85, 1.84], [0.54, 1.24], [0.46, 0.20], [0, 0.17]
],
tallCup: [
[0, 0], [0.57, 0], [0.62, 0.10], [0.59, 0.40],
[0.68, 1.78], [0.83, 2.05], [0.85, 2.14],
[0.72, 2.14], [0.53, 1.76], [0.46, 0.23], [0, 0.17]
],
bowl: [
[0, 0], [0.43, 0], [0.51, 0.08], [0.59, 0.34],
[0.82, 0.70], [1.24, 0.91], [1.29, 1.02],
[1.15, 1.04], [0.55, 0.36], [0, 0.22]
],
deepBowl: [
[0, 0], [0.39, 0], [0.50, 0.10], [0.56, 0.42],
[0.75, 0.83], [1.08, 1.12], [1.14, 1.22],
[1.00, 1.23], [0.46, 0.40], [0, 0.25]
],
jar: [
[0, 0], [0.69, 0], [0.76, 0.10], [0.77, 0.38],
[0.73, 1.36], [0.77, 1.62], [0.77, 1.76],
[0.65, 1.77], [0.65, 1.59], [0.61, 1.35], [0.64, 0.35], [0, 0.16]
],
bellJar: [
[0, 0], [0.61, 0], [0.70, 0.12], [0.76, 0.36],
[0.77, 1.23], [0.71, 1.63], [0.56, 1.82],
[0.47, 1.90], [0.40, 1.90], [0.42, 1.80],
[0.58, 1.59], [0.65, 1.21], [0.63, 0.35], [0, 0.16]
],
tallJar: [
[0, 0], [0.62, 0], [0.71, 0.10], [0.73, 0.30],
[0.67, 1.75], [0.70, 2.00], [0.70, 2.12],
[0.59, 2.13], [0.58, 1.74], [0.54, 0.30], [0, 0.16]
]
};
const objectGroups = new Map();
function makeMaterial(color) {
return new THREE.MeshPhysicalMaterial({
color,
roughness: 0.34,
metalness: 0,
clearcoat: 0.22,
clearcoatRoughness: 0.28
});
}
function addHandle(group, item) {
const handleMaterial = makeMaterial(item.accent);
const handleGeometry = new THREE.TorusGeometry(0.47, 0.13, 16, 56);
if (item.type === 'bowl') {
[-1, 1].forEach((direction) => {
const handle = new THREE.Mesh(handleGeometry, handleMaterial);
handle.position.set(direction * 1.10, 0.55, 0);
handle.scale.set(0.78, 0.58, 1);
handle.rotation.y = direction * -0.16;
handle.castShadow = true;
group.add(handle);
});
} else {
const handle = new THREE.Mesh(handleGeometry, handleMaterial);
const height = item.type === 'jar' ? 1.72 : item.profile === 'tallCup' ? 2.02 : 1.72;
handle.position.set(item.type === 'jar' ? 0.73 : 0.80, height * 0.52, 0);
handle.scale.set(0.83, item.type === 'jar' ? 1.35 : 1.08, 1);
handle.castShadow = true;
group.add(handle);
}
}
function addLid(group, item, accentMaterial) {
const lidMaterial = makeMaterial(item.accent);
const radius = item.profile === 'tallJar' ? 0.75 : item.profile === 'bellJar' ? 0.53 : 0.84;
const height = item.profile === 'tallJar' ? 2.13 : item.profile === 'bellJar' ? 1.90 : 1.77;
const lid = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius * 0.98, 0.16, 64),
lidMaterial
);
lid.position.y = height + 0.06;
lid.castShadow = true;
group.add(lid);
const rim = new THREE.Mesh(
new THREE.TorusGeometry(radius * 0.96, 0.055, 12, 64),
accentMaterial
);
rim.rotation.x = Math.PI / 2;
rim.position.y = height - 0.01;
rim.castShadow = true;
group.add(rim);
const knob = new THREE.Mesh(
new THREE.SphereGeometry(0.13, 24, 16),
lidMaterial
);
knob.scale.y = 0.7;
knob.position.y = height + 0.2;
knob.castShadow = true;
group.add(knob);
}
function addDecoration(group, item, accentMaterial) {
if (item.type === 'jar') {
const band = new THREE.Mesh(
new THREE.TorusGeometry(0.73, 0.035, 10, 64),
accentMaterial
);
band.rotation.x = Math.PI / 2;
band.position.y = 1.08;
band.castShadow = true;
group.add(band);
}
if (item.profile === 'rippleCup') {
[0.35, 0.62, 0.89].forEach((y) => {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.72 + y * 0.08, 0.025, 8, 48),
accentMaterial
);
ring.rotation.x = Math.PI / 2;
ring.position.y = y;
group.add(ring);
});
}
if (item.profile === 'flareCup') {
const band = new THREE.Mesh(
new THREE.TorusGeometry(0.66, 0.035, 10, 64),
accentMaterial
);
band.rotation.x = Math.PI / 2;
band.position.y = 1.18;
group.add(band);
}
}
function createCandidate(item) {
const group = new THREE.Group();
group.userData.item = item;
group.userData.targetPosition = new THREE.Vector3();
group.userData.targetScale = 1;
const points = profiles[item.profile].map(
([radius, height]) => new THREE.Vector2(radius, height)
);
const bodyMaterial = makeMaterial(item.color);
const accentMaterial = makeMaterial(item.accent);
const body = new THREE.Mesh(
new THREE.LatheGeometry(points, 72),
bodyMaterial
);
body.castShadow = true;
body.receiveShadow = true;
body.userData.candidateId = item.id;
group.add(body);
if (item.handle) addHandle(group, item);
if (item.lid) addLid(group, item, accentMaterial);
addDecoration(group, item, accentMaterial);
const marker = new THREE.Mesh(
new THREE.RingGeometry(0.73, 0.79, 64),
new THREE.MeshBasicMaterial({
color: '#b85f43',
transparent: true,
opacity: 0.55,
side: THREE.DoubleSide,
depthWrite: false
})
);
marker.rotation.x = -Math.PI / 2;
marker.position.y = 0.012;
marker.visible = false;
marker.userData.selectionMarker = true;
group.add(marker);
group.userData.marker = marker;
world.add(group);
objectGroups.set(item.id, group);
}
candidates.forEach(createCandidate);
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let yaw = -0.12;
let targetYaw = -0.12;
let pitch = 1.10;
let targetPitch = 1.10;
let radius = 10.2;
let targetRadius = 10.2;
let pointerDown = false;
let pointerMoved = false;
let pointerStart = { x: 0, y: 0 };
let lastPointer = { x: 0, y: 0 };
function resize() {
const width = canvas.clientWidth;
const height = canvas.clientHeight;
if (!width || !height) return;
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(canvas.parentElement);
resize();
function getMatches() {
return candidates.filter((item) => {
const typeMatch = state.type === 'all' || item.type === state.type;
const handleMatch =
state.handle === 'any' ||
(state.handle === 'with' && item.handle) ||
(state.handle === 'without' && !item.handle);
const lidMatch =
state.lid === 'any' ||
(state.lid === 'with' && item.lid) ||
(state.lid === 'without' && !item.lid);
return typeMatch && handleMatch && lidMatch;
});
}
function capitalize(value) {
return value.charAt(0).toUpperCase() + value.slice(1);
}
function getTitle() {
const parts = [];
if (state.type !== 'all') parts.push(capitalize(state.type));
else parts.push('All vessels');
if (state.handle === 'with') parts.push('with a handle');
if (state.handle === 'without') parts.push('without a handle');
if (state.lid === 'with') parts.push('with a lid');
if (state.lid === 'without') parts.push('without a lid');
return parts.join(' ');
}
function thumbnailSVG(item) {
const fill = item.color;
const accent = item.accent;
if (item.type === 'bowl') {
return `
<svg viewBox="0 0 64 64" aria-hidden="true">
<ellipse cx="32" cy="51" rx="20" ry="4" fill="#000" opacity=".08"/>
${item.handle ? `<ellipse cx="9" cy="37" rx="7" ry="10" fill="none" stroke="${accent}" stroke-width="4"/><ellipse cx="55" cy="37" rx="7" ry="10" fill="none" stroke="${accent}" stroke-width="4"/>` : ''}
<path d="M10 27 Q32 17 54 27 Q49 49 32 51 Q15 49 10 27Z" fill="${fill}"/>
<ellipse cx="32" cy="27" rx="22" ry="6" fill="${accent}"/>
</svg>`;
}
if (item.type === 'jar') {
return `
<svg viewBox="0 0 64 64" aria-hidden="true">
<ellipse cx="32" cy="54" rx="17" ry="3" fill="#000" opacity=".08"/>
${item.handle ? `<path d="M45 27 C61 24 61 46 44 45" fill="none" stroke="${accent}" stroke-width="5"/>` : ''}
<path d="M16 20 Q32 17 48 20 L46 51 Q32 54 18 51Z" fill="${fill}"/>
<ellipse cx="32" cy="20" rx="16" ry="5" fill="${accent}"/>
${item.lid ? `<rect x="14" y="13" width="36" height="7" rx="3" fill="${accent}"/><circle cx="32" cy="11" r="3" fill="${fill}"/>` : ''}
</svg>`;
}
return `
<svg viewBox="0 0 64 64" aria-hidden="true">
<ellipse cx="32" cy="54" rx="15" ry="3" fill="#000" opacity=".08"/>
${item.handle ? `<path d="M45 27 C62 22 63 44 44 46" fill="none" stroke="${accent}" stroke-width="5"/>` : ''}
<path d="M17 17 Q32 14 47 17 L44 50 Q32 54 20 50Z" fill="${fill}"/>
<ellipse cx="32" cy="17" rx="15" ry="4" fill="${accent}"/>
</svg>`;
}
function setActiveButton(containerId, value) {
const container = document.querySelector(`#${containerId}`);
container.querySelectorAll('[data-value]').forEach((button) => {
const active = button.dataset.value === value;
button.classList.toggle('active', active);
button.setAttribute('aria-pressed', String(active));
});
}
function setPresetButtons() {
const exact =
(state.type === 'cup' && state.handle === 'without' && state.lid === 'any') ||
(state.type === 'bowl' && state.handle === 'any' && state.lid === 'any') ||
(state.type === 'jar' && state.handle === 'any' && state.lid === 'with');
document.querySelectorAll('[data-preset]').forEach((button) => {
const active =
(button.dataset.preset === 'cupWithout' &&
state.type === 'cup' &&
state.handle === 'without' &&
state.lid === 'any') ||
(button.dataset.preset === 'bowl' &&
state.type === 'bowl' &&
state.handle === 'any' &&
state.lid === 'any') ||
(button.dataset.preset === 'jarLid' &&
state.type === 'jar' &&
state.handle === 'any' &&
state.lid === 'with');
button.classList.toggle('active', active);
button.setAttribute('aria-pressed', String(active));
});
}
function arrangeObjects(matches) {
const count = matches.length;
const columns = count <= 4 ? count : count <= 8 ? 4 : 4;
const rows = Math.ceil(count / columns);
const spacing = count > 8 ? 2.45 : 2.7;
matches.forEach((item, index) => {
const group = objectGroups.get(item.id);
const column = index % columns;
const row = Math.floor(index / columns);
const x =
count === 0
? 0
: (column - (Math.min(columns, count) - 1) / 2) * spacing;
const z =
rows === 1
? 0
: (row - (rows - 1) / 2) * 2.65;
group.userData.targetPosition.set(x, 0, z);
group.userData.targetScale = count > 8 ? 0.76 : count > 4 ? 0.88 : 1;
});
const recommendedRadius = count > 8 ? 13.2 : count > 4 ? 11.7 : 10.2;
targetRadius = Math.max(targetRadius * 0.72, Math.min(recommendedRadius, targetRadius));
}
function selectCandidate(id, scroll = false) {
state.selectedId = id;
objectGroups.forEach((group, candidateId) => {
group.userData.marker.visible = candidateId === id;
});
document.querySelectorAll('.candidate-card').forEach((card) => {
const selected = card.dataset.id === id;
card.classList.toggle('selected', selected);
card.setAttribute('aria-pressed', String(selected));
});
if (scroll) {
document.querySelector(`.candidate-card[data-id="${id}"]`)?.scrollIntoView({
behavior: 'smooth',
block: 'nearest',
inline: 'nearest'
});
}
}
function renderCards(matches) {
if (!matches.length) {
cardList.innerHTML = '<div class="no-cards">No remaining candidates.</div>';
return;
}
cardList.innerHTML = matches
.map(
(item) => `
<button class="candidate-card ${item.id === state.selectedId ? 'selected' : ''}"
data-id="${item.id}"
aria-pressed="${item.id === state.selectedId}">
<span class="vessel-thumb">${thumbnailSVG(item)}</span>
<span class="candidate-copy">
<span class="candidate-name">${item.name}</span>
<span class="candidate-meta">
<span class="meta-tag accent">${item.type}</span>
<span class="meta-tag">${item.handle ? 'Handle' : 'No handle'}</span>
${item.lid ? '<span class="meta-tag">Lid</span>' : ''}
</span>
</span>
</button>
`
)
.join('');
cardList.querySelectorAll('.candidate-card').forEach((card) => {
card.addEventListener('click', () => selectCandidate(card.dataset.id));
});
}
function applyFilters() {
const matches = getMatches();
objectGroups.forEach((group, id) => {
group.visible = matches.some((item) => item.id === id);
});
arrangeObjects(matches);
setActiveButton('typeFilter', state.type);
setActiveButton('handleFilter', state.handle);
setActiveButton('lidFilter', state.lid);
setPresetButtons();
resultsTitle.textContent = getTitle();
resultSummary.textContent = `${matches.length} candidate${matches.length === 1 ? '' : 's'} remain`;
sceneCounter.textContent = `${String(matches.length).padStart(2, '0')} / ${candidates.length}`;
emptyState.classList.toggle('hidden', matches.length !== 0);
const chips = [];
if (state.type !== 'all') chips.push(capitalize(state.type));
if (state.handle !== 'any') {
chips.push(state.handle === 'with' ? 'Has handle' : 'No handle');
}
if (state.lid !== 'any') {
chips.push(state.lid === 'with' ? 'Has lid' : 'No lid');
}
activeRules.innerHTML = chips
.map((chip) => `<span class="rule-chip">${chip}</span>`)
.join('');
ruleText.innerHTML = [
`<strong>type</strong> = ${state.type}`,
`<strong>handle</strong> = ${state.handle}`,
`<strong>lid</strong> = ${state.lid}`
].join('<br>');
if (
state.selectedId &&
!matches.some((item) => item.id === state.selectedId)
) {
state.selectedId = null;
}
if (!state.selectedId && matches.length) {
state.selectedId = matches[0].id;
}
renderCards(matches);
objectGroups.forEach((group, id) => {
group.userData.marker.visible = id === state.selectedId;
});
}
function bindSegmented(id, key) {
document.querySelector(`#${id}`).addEventListener('click', (event) => {
const button = event.target.closest('[data-value]');
if (!button) return;
state[key] = button.dataset.value;
applyFilters();
});
}
bindSegmented('typeFilter', 'type');
bindSegmented('handleFilter', 'handle');
bindSegmented('lidFilter', 'lid');
document.querySelectorAll('[data-preset]').forEach((button) => {
button.addEventListener('click', () => {
const preset = button.dataset.preset;
if (preset === 'cupWithout') {
state.type = 'cup';
state.handle = 'without';
state.lid = 'any';
}
if (preset === 'bowl') {
state.type = 'bowl';
state.handle = 'any';
state.lid = 'any';
}
if (preset === 'jarLid') {
state.type = 'jar';
state.handle = 'any';
state.lid = 'with';
}
applyFilters();
});
});
function resetFilters() {
state.type = 'all';
state.handle = 'any';
state.lid = 'any';
applyFilters();
}
document.querySelector('#resetFilters').addEventListener('click', resetFilters);
document.querySelector('#resetTop').addEventListener('click', resetFilters);
document.querySelector('#emptyReset').addEventListener('click', resetFilters);
document.querySelector('#surpriseButton').addEventListener('click', () => {
const matches = getMatches();
if (!matches.length) return;
const currentIndex = matches.findIndex((item) => item.id === state.selectedId);
const next = matches[(currentIndex + 1) % matches.length];
selectCandidate(next.id, true);
});
canvas.addEventListener('pointerdown', (event) => {
pointerDown = true;
pointerMoved = false;
pointerStart = { x: event.clientX, y: event.clientY };
lastPointer = { ...pointerStart };
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener('pointermove', (event) => {
if (!pointerDown) return;
const dx = event.clientX - lastPointer.x;
const dy = event.clientY - lastPointer.y;
if (
Math.abs(event.clientX - pointerStart.x) +
Math.abs(event.clientY - pointerStart.y) >
4
) {
pointerMoved = true;
}
targetYaw -= dx * 0.008;
targetPitch = THREE.MathUtils.clamp(targetPitch + dy * 0.005, 0.68, 1.38);
lastPointer = { x: event.clientX, y: event.clientY };
});
canvas.addEventListener('pointerup', (event) => {
pointerDown = false;
if (!pointerMoved) {
const rect = canvas.getBoundingClientRect();
pointer.x =
((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y =
-((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(world.children, true);
for (const hit of intersections) {
let object = hit.object;
while (object && !object.userData.item) {
object = object.parent;
}
if (object?.userData?.item) {
selectCandidate(object.userData.item.id, true);
break;
}
}
}
});
canvas.addEventListener('pointercancel', () => {
pointerDown = false;
});
canvas.addEventListener(
'wheel',
(event) => {
event.preventDefault();
targetRadius = THREE.MathUtils.clamp(
targetRadius + event.deltaY * 0.008,
7.2,
15
);
},
{ passive: false }
);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const smoothing = 1 - Math.pow(0.0008, delta);
yaw = THREE.MathUtils.lerp(yaw, targetYaw, smoothing);
pitch = THREE.MathUtils.lerp(pitch, targetPitch, smoothing);
radius = THREE.MathUtils.lerp(radius, targetRadius, smoothing);
const sinPitch = Math.sin(pitch);
camera.position.set(
cameraTarget.x + radius * sinPitch * Math.sin(yaw),
cameraTarget.y + radius * Math.cos(pitch),
cameraTarget.z + radius * sinPitch * Math.cos(yaw)
);
camera.lookAt(cameraTarget);
objectGroups.forEach((group) => {
group.position.lerp(group.userData.targetPosition, smoothing);
const currentScale = group.scale.x;
const nextScale = THREE.MathUtils.lerp(
currentScale,
group.userData.targetScale,
smoothing
);
group.scale.setScalar(nextScale);
if (group.userData.marker.visible) {
const pulse = 1 + Math.sin(performance.now() * 0.003) * 0.055;
group.userData.marker.scale.setScalar(pulse);
group.userData.marker.material.opacity = 0.48 + Math.sin(performance.now() * 0.003) * 0.12;
}
});
renderer.render(scene, camera);
}
applyFilters();
animate();
</script>
</body>
</html>
```