Prompt specification
Build or customize the Three.js 3D scene "Transparent Bag of Weather Cards" 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: Transparent Bag of Weather Cards
Category: Games & Play · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/transparent-bag-of-weather-cards-x3529
Scene Description Prompt:
Model a bag or tray containing a fixed visible count of weather symbol cards. Show the initial composition and label it as a fictional game deck. Build this with Three.js from cdnjs as a stylized scene in one self-contained HTML file.
Working Three.js Starter (transparent-bag-of-weather-cards-x3529):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sky Signal — Fictional Weather Game Deck</title>
<style>
:root {
--ink: #17353a;
--muted: #567077;
--paper: rgba(255, 255, 255, 0.82);
--line: rgba(23, 53, 58, 0.14);
--accent: #e9a93a;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 72% 18%, rgba(255, 229, 157, 0.72), transparent 25%),
radial-gradient(circle at 18% 82%, rgba(133, 197, 187, 0.46), transparent 31%),
linear-gradient(145deg, #eaf3ef 0%, #d5e5e1 55%, #c4d7d4 100%);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.interface {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
}
.brand {
position: absolute;
top: 28px;
left: 30px;
max-width: 380px;
}
.eyebrow {
margin-bottom: 7px;
color: #5d777b;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(34px, 4vw, 58px);
font-weight: 600;
line-height: 0.92;
letter-spacing: -0.035em;
}
.subtitle {
margin: 11px 0 0;
color: var(--muted);
font-size: 13px;
font-weight: 650;
letter-spacing: 0.035em;
}
.count-badge {
position: absolute;
top: 28px;
right: 30px;
display: flex;
align-items: center;
gap: 12px;
padding: 10px 14px 10px 11px;
border: 1px solid rgba(23, 53, 58, 0.13);
border-radius: 999px;
background: rgba(255, 255, 255, 0.65);
box-shadow: 0 12px 34px rgba(32, 70, 72, 0.11);
backdrop-filter: blur(14px);
}
.count-badge strong {
display: grid;
width: 37px;
height: 37px;
place-items: center;
border-radius: 50%;
background: var(--ink);
color: #fff9e9;
font-size: 14px;
}
.count-copy {
font-size: 11px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
line-height: 1.35;
}
.manifest {
position: absolute;
bottom: 26px;
left: 28px;
width: min(350px, calc(100vw - 56px));
padding: 18px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--paper);
box-shadow: 0 18px 54px rgba(32, 70, 72, 0.13);
backdrop-filter: blur(16px);
}
.manifest-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 12px;
}
.manifest-head strong {
font-family: Georgia, "Times New Roman", serif;
font-size: 20px;
font-weight: 600;
}
.manifest-head span {
color: #698084;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
#manifest-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 7px;
}
.card-chip {
display: flex;
min-width: 0;
align-items: center;
gap: 7px;
padding: 7px 8px;
border: 1px solid rgba(23, 53, 58, 0.1);
border-radius: 9px;
background: rgba(255, 255, 255, 0.56);
color: #38545a;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.055em;
text-transform: uppercase;
transition: 160ms ease;
}
.card-chip .dot {
width: 8px;
height: 8px;
flex: 0 0 auto;
border-radius: 50%;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.card-chip.active {
transform: translateY(-2px);
border-color: rgba(233, 169, 58, 0.72);
background: #fff8e7;
box-shadow: 0 5px 14px rgba(75, 69, 44, 0.09);
}
.manifest-note {
margin-top: 12px;
color: #70858a;
font-size: 10px;
line-height: 1.45;
}
.controls {
position: absolute;
right: 28px;
bottom: 27px;
padding: 9px 12px;
border: 1px solid rgba(23, 53, 58, 0.11);
border-radius: 10px;
background: rgba(255, 255, 255, 0.54);
color: #60777c;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
backdrop-filter: blur(12px);
}
.controls kbd {
padding: 2px 5px;
border: 1px solid rgba(23, 53, 58, 0.14);
border-radius: 4px;
background: rgba(255, 255, 255, 0.65);
color: var(--ink);
font: inherit;
}
#boot {
position: fixed;
inset: 0;
z-index: 5;
display: grid;
place-items: center;
background: #dbe9e5;
color: var(--ink);
font-family: Georgia, "Times New Roman", serif;
font-size: 24px;
letter-spacing: 0.03em;
transition: opacity 450ms ease;
}
#boot.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
.brand {
top: 20px;
left: 20px;
}
.subtitle {
max-width: 230px;
font-size: 11px;
}
.count-badge {
top: 20px;
right: 20px;
}
.count-copy {
display: none;
}
.manifest {
bottom: 18px;
left: 18px;
width: calc(100vw - 36px);
padding: 13px;
}
#manifest-grid {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
.card-chip {
padding: 6px;
font-size: 8px;
}
.controls {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="A three-dimensional tray containing twelve fictional weather game cards"></canvas>
<div class="interface">
<header class="brand">
<div class="eyebrow">Fictional tabletop game</div>
<h1>Sky Signal</h1>
<p class="subtitle">A twelve-card weather deck · initial composition</p>
</header>
<div class="count-badge" aria-label="12 of 12 cards visible">
<strong>12</strong>
<div class="count-copy">12 of 12<br />visible cards</div>
</div>
<aside class="manifest">
<div class="manifest-head">
<strong>Deck manifest</strong>
<span>One of each</span>
</div>
<div id="manifest-grid"></div>
<div class="manifest-note" id="selection-note">
All twelve symbols are visible. Hover a card to lift it; click to select.
</div>
</aside>
<div class="controls">
<kbd>Drag</kbd> orbit · <kbd>Scroll</kbd> zoom · <kbd>R</kbd> reset
</div>
</div>
<div id="boot">Preparing the weather deck…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Scene setup
// -------------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x000000, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0xd7e5e1, 24, 48);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemi = new THREE.HemisphereLight(0xf4fbff, 0x7a5a43, 2.15);
scene.add(hemi);
const keyLight = new THREE.DirectionalLight(0xfff1cf, 4.25);
keyLight.position.set(-7, 14, 10);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -13;
keyLight.shadow.camera.right = 13;
keyLight.shadow.camera.top = 13;
keyLight.shadow.camera.bottom = -13;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x9bd8dd, 1.8);
rimLight.position.set(10, 8, -9);
scene.add(rimLight);
const warmLight = new THREE.PointLight(0xffb75d, 45, 24, 2);
warmLight.position.set(-8, 7, 7);
scene.add(warmLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(70, 70),
new THREE.MeshStandardMaterial({
color: 0xd5e2de,
roughness: 0.97,
metalness: 0
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.36;
floor.receiveShadow = true;
scene.add(floor);
// Decorative game-board rings beneath the tray.
for (const radius of [8.5, 11.4]) {
const ring = new THREE.Mesh(
new THREE.RingGeometry(radius, radius + 0.035, 128),
new THREE.MeshBasicMaterial({
color: 0x6f9d98,
transparent: true,
opacity: 0.16,
side: THREE.DoubleSide,
depthWrite: false
})
);
ring.rotation.x = -Math.PI / 2;
ring.position.y = -0.345;
scene.add(ring);
}
// -------------------------------------------------------------------------
// Geometry helpers
// -------------------------------------------------------------------------
function addRoundedPath(path, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
path.moveTo(x + r, y);
path.lineTo(x + width - r, y);
path.quadraticCurveTo(x + width, y, x + width, y + r);
path.lineTo(x + width, y + height - r);
path.quadraticCurveTo(x + width, y + height, x + width - r, y + height);
path.lineTo(x + r, y + height);
path.quadraticCurveTo(x, y + height, x, y + height - r);
path.lineTo(x, y + r);
path.quadraticCurveTo(x, y, x + r, y);
return path;
}
function roundedExtrude(width, height, depth, radius, bevel = 0.035) {
const shape = new THREE.Shape();
addRoundedPath(
shape,
-width / 2,
-height / 2,
width,
height,
radius
);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth,
steps: 1,
bevelEnabled: bevel > 0,
bevelThickness: bevel,
bevelSize: Math.min(bevel, radius * 0.35),
bevelSegments: 3,
curveSegments: 12
});
geometry.translate(0, 0, -depth / 2);
geometry.computeVertexNormals();
return geometry;
}
function roundedBoxGeometry(width, height, depth, radius, bevel = 0.035) {
const geometry = roundedExtrude(width, height, depth, radius, bevel);
geometry.rotateX(-Math.PI / 2);
geometry.computeVertexNormals();
return geometry;
}
// -------------------------------------------------------------------------
// Tray
// -------------------------------------------------------------------------
const tray = new THREE.Group();
scene.add(tray);
const walnut = new THREE.MeshStandardMaterial({
color: 0x70442f,
roughness: 0.58,
metalness: 0.03
});
const walnutEdge = new THREE.MeshStandardMaterial({
color: 0x4b2e24,
roughness: 0.64
});
const felt = new THREE.MeshStandardMaterial({
color: 0x214c49,
roughness: 0.96,
metalness: 0
});
const brass = new THREE.MeshStandardMaterial({
color: 0xd8a749,
roughness: 0.28,
metalness: 0.72
});
const trayBase = new THREE.Mesh(
roundedBoxGeometry(11.7, 9.25, 0.45, 0.58, 0.075),
walnut
);
trayBase.position.y = -0.12;
trayBase.castShadow = true;
trayBase.receiveShadow = true;
tray.add(trayBase);
const feltInsert = new THREE.Mesh(
roundedBoxGeometry(10.8, 8.4, 0.14, 0.45, 0.035),
felt
);
feltInsert.position.y = 0.15;
feltInsert.receiveShadow = true;
tray.add(feltInsert);
const frontRail = new THREE.Mesh(
roundedBoxGeometry(11.75, 0.52, 0.52, 0.17, 0.045),
walnutEdge
);
frontRail.position.set(0, 0.27, 4.47);
frontRail.castShadow = true;
tray.add(frontRail);
const backRail = frontRail.clone();
backRail.position.z = -4.47;
tray.add(backRail);
const sideRail = new THREE.Mesh(
roundedBoxGeometry(0.52, 8.48, 0.52, 0.17, 0.045),
walnutEdge
);
sideRail.position.set(-5.55, 0.27, 0);
sideRail.castShadow = true;
tray.add(sideRail);
const oppositeSideRail = sideRail.clone();
oppositeSideRail.position.x = 5.55;
tray.add(oppositeSideRail);
// Brass corner fasteners.
for (const x of [-5.2, 5.2]) {
for (const z of [-4.18, 4.18]) {
const screw = new THREE.Mesh(
new THREE.CylinderGeometry(0.085, 0.085, 0.085, 18),
brass
);
screw.position.set(x, 0.56, z);
screw.castShadow = true;
tray.add(screw);
}
}
// -------------------------------------------------------------------------
// Tray label
// -------------------------------------------------------------------------
function makePlaqueTexture() {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 1024;
labelCanvas.height = 192;
const ctx = labelCanvas.getContext("2d");
const gradient = ctx.createLinearGradient(0, 0, 1024, 0);
gradient.addColorStop(0, "#173c40");
gradient.addColorStop(0.55, "#245659");
gradient.addColorStop(1, "#173c40");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 1024, 192);
ctx.strokeStyle = "#d9aa52";
ctx.lineWidth = 5;
ctx.strokeRect(12, 12, 1000, 168);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = "#fff6d9";
ctx.font = "700 64px Georgia";
ctx.fillText("SKY SIGNAL", 512, 73);
ctx.fillStyle = "#bcd7d1";
ctx.font = "700 25px Arial";
ctx.fillText("FICTIONAL WEATHER GAME DECK • 12 CARDS", 512, 132);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
const plaqueFrame = new THREE.Mesh(
new THREE.BoxGeometry(5.75, 0.94, 0.13),
new THREE.MeshStandardMaterial({
color: 0x3c251e,
roughness: 0.5,
metalness: 0.08
})
);
plaqueFrame.position.set(0, 0.19, 4.765);
plaqueFrame.castShadow = true;
tray.add(plaqueFrame);
const plaque = new THREE.Mesh(
new THREE.PlaneGeometry(5.57, 0.77),
new THREE.MeshBasicMaterial({
map: makePlaqueTexture(),
toneMapped: false
})
);
plaque.position.set(0, 0.19, 4.836);
tray.add(plaque);
// -------------------------------------------------------------------------
// Weather card data: exactly twelve cards, one of each symbol
// -------------------------------------------------------------------------
const cards = [
{ id: "sun", name: "Sunshine", color: "#e8a72f", soft: "#fff0b8" },
{ id: "cloud", name: "Cloud", color: "#5f8ca3", soft: "#dcecf1" },
{ id: "rain", name: "Rain", color: "#3c82b5", soft: "#dcecf8" },
{ id: "storm", name: "Thunder", color: "#655a96", soft: "#e9e4f7" },
{ id: "snow", name: "Snow", color: "#68aebd", soft: "#e5f4f5" },
{ id: "fog", name: "Fog", color: "#7c8e91", soft: "#e8eeee" },
{ id: "wind", name: "Wind", color: "#4a9b91", soft: "#dff1ed" },
{ id: "humid", name: "Humidity", color: "#3f91a7", soft: "#dff2f5" },
{ id: "hail", name: "Hail", color: "#678cae", soft: "#e2ebf3" },
{ id: "heat", name: "Heat", color: "#e16643", soft: "#ffe3d8" },
{ id: "rainbow", name: "Rainbow", color: "#c16889", soft: "#f8e3ec" },
{ id: "moon", name: "Moon", color: "#625b9b", soft: "#e8e4f7" }
];
// -------------------------------------------------------------------------
// Canvas-drawn weather symbols
// -------------------------------------------------------------------------
function drawSun(ctx, color) {
ctx.strokeStyle = color;
ctx.fillStyle = color;
ctx.lineWidth = 8;
ctx.lineCap = "round";
for (let i = 0; i < 12; i++) {
const angle = (Math.PI * 2 * i) / 12;
const inner = 53;
const outer = 76;
ctx.beginPath();
ctx.moveTo(Math.cos(angle) * inner, Math.sin(angle) * inner);
ctx.lineTo(Math.cos(angle) * outer, Math.sin(angle) * outer);
ctx.stroke();
}
ctx.beginPath();
ctx.arc(0, 0, 43, 0, Math.PI * 2);
ctx.fill();
}
function drawCloudShape(ctx, color) {
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(-36, 8, 29, 0, Math.PI * 2);
ctx.arc(-5, -10, 39, 0, Math.PI * 2);
ctx.arc(36, 8, 30, 0, Math.PI * 2);
ctx.rect(-35, 7, 71, 29);
ctx.fill();
}
function drawCloud(ctx, color) {
drawCloudShape(ctx, color);
}
function drawRain(ctx, color) {
ctx.save();
ctx.translate(0, -14);
ctx.scale(0.82, 0.82);
drawCloudShape(ctx, "#718b99");
ctx.restore();
ctx.strokeStyle = color;
ctx.lineWidth = 9;
ctx.lineCap = "round";
for (const x of [-37, 0, 37]) {
ctx.beginPath();
ctx.moveTo(x - 5, 43);
ctx.lineTo(x - 13, 68);
ctx.stroke();
}
}
function drawStorm(ctx, color) {
ctx.save();
ctx.translate(0, -14);
ctx.scale(0.82, 0.82);
drawCloudShape(ctx, "#6c6e83");
ctx.restore();
ctx.fillStyle = color;
ctx.beginPath();
ctx.moveTo(12, 29);
ctx.lineTo(-28, 70);
ctx.lineTo(-2, 65);
ctx.lineTo(-13, 91);
ctx.lineTo(32, 43);
ctx.lineTo(4, 49);
ctx.closePath();
ctx.fill();
}
function drawSnowflake(ctx, color) {
ctx.strokeStyle = color;
ctx.lineWidth = 8;
ctx.lineCap = "round";
for (let i = 0; i < 6; i++) {
ctx.save();
ctx.rotate((Math.PI * 2 * i) / 6);
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(0, -68);
ctx.moveTo(0, -43);
ctx.lineTo(-17, -57);
ctx.moveTo(0, -43);
ctx.lineTo(17, -57);
ctx.stroke();
ctx.restore();
}
}
function drawFog(ctx, color) {
ctx.strokeStyle = color;
ctx.lineWidth = 10;
ctx.lineCap = "round";
for (const y of [-33, 3, 39]) {
ctx.beginPath();
ctx.moveTo(-62, y);
ctx.lineTo(62, y);
ctx.stroke();
}
ctx.globalAlpha = 0.4;
ctx.beginPath();
ctx.arc(-34, -67, 18, 0, Math.PI * 2);
ctx.arc(8, -67, 24, 0, Math.PI * 2);
ctx.fill();
ctx.globalAlpha = 1;
}
function drawWind(ctx, color) {
ctx.strokeStyle = color;
ctx.lineWidth = 9;
ctx.lineCap = "round";
ctx.beginPath();
ctx.moveTo(-70, -27);
ctx.bezierCurveTo(-20, -57, 39, -50, 35, -18);
ctx.bezierCurveTo(32, 3, 7, 4, 4, -12);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(-58, 9);
ctx.bezierCurveTo(-3, -10, 68, 0, 52, 34);
ctx.bezierCurveTo(41, 56, 11, 51, 12, 31);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(-70, 44);
ctx.bezierCurveTo(-27, 29, 20, 35, 44, 59);
ctx.stroke();
}
function drawHumidity(ctx, color) {
ctx.fillStyle = color;
ctx.beginPath();
ctx.moveTo(0, -67);
ctx.bezierCurveTo(-18, -32, -45, 0, -45, 27);
ctx.bezierCurveTo(-45, 61, -24, 79, 0, 79);
ctx.bezierCurveTo(24, 79, 45, 61, 45, 27);
ctx.bezierCurveTo(45, 0, 18, -32, 0, -67);
ctx.fill();
ctx.strokeStyle = "rgba(255,255,255,0.65)";
ctx.lineWidth = 8;
ctx.lineCap = "round";
ctx.beginPath();
ctx.moveTo(-24, 25);
ctx.bezierCurveTo(-29, 46, -18, 58, -7, 61);
ctx.stroke();
}
function drawHail(ctx, color) {
ctx.save();
ctx.translate(0, -18);
ctx.scale(0.82, 0.82);
drawCloudShape(ctx, "#778c9c");
ctx.restore();
ctx.fillStyle = color;
for (const [x, y, r] of [
[-40, 49, 11],
[-3, 67, 12],
[37, 48, 10],
[17, 82, 8]
]) {
ctx.beginPath();
ctx.arc(x, y, r, 0, Math.PI * 2);
ctx.fill();
}
}
function drawHeat(ctx, color) {
drawSun(ctx, color);
ctx.strokeStyle = "#d94b3d";
ctx.lineWidth = 8;
ctx.lineCap = "round";
for (const x of [-38, 0, 38]) {
ctx.beginPath();
ctx.moveTo(x - 9, 72);
ctx.quadraticCurveTo(x + 10, 80, x - 7, 89);
ctx.quadraticCurveTo(x + 8, 96, x - 5, 104);
ctx.stroke();
}
}
function drawRainbow(ctx, color) {
const colors = ["#dd6678", "#e6a13c", "#e2c64d", "#5ba880", "#548fba", "#7164a2"];
for (let i = 0; i < colors.length; i++) {
ctx.strokeStyle = colors[i];
ctx.lineWidth = 13;
ctx.beginPath();
ctx.arc(0, 57, 90 - i * 13, Math.PI, Math.PI * 2);
ctx.stroke();
}
ctx.fillStyle = color;
for (const [x, y] of [[-86, -46], [-55, -70], [82, -53]]) {
ctx.beginPath();
ctx.arc(x, y, 5, 0, Math.PI * 2);
ctx.fill();
}
}
function drawMoon(ctx, color, soft) {
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(-7, -4, 54, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = soft;
ctx.beginPath();
ctx.arc(16, -20, 48, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = color;
for (const [x, y, r] of [[51, -44, 5], [69, -16, 4], [-48, 44, 4]]) {
ctx.beginPath();
ctx.arc(x, y, r, 0, Math.PI * 2);
ctx.fill();
}
}
function drawIcon(ctx, type, color, soft) {
ctx.save();
ctx.translate(0, 0);
switch (type) {
case "sun": drawSun(ctx, color); break;
case "cloud": drawCloud(ctx, color); break;
case "rain": drawRain(ctx, color); break;
case "storm": drawStorm(ctx, color); break;
case "snow": drawSnowflake(ctx, color); break;
case "fog": drawFog(ctx, color); break;
case "wind": drawWind(ctx, color); break;
case "humid": drawHumidity(ctx, color); break;
case "hail": drawHail(ctx, color); break;
case "heat": drawHeat(ctx, color); break;
case "rainbow": drawRainbow(ctx, color); break;
case "moon": drawMoon(ctx, color, soft); break;
}
ctx.restore();
}
function canvasRoundRect(ctx, x, y, width, height, radius) {
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
ctx.lineTo(x + width, y + height - radius);
ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
ctx.lineTo(x + radius, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
}
function makeCardTexture(card, index) {
const cardCanvas = document.createElement("canvas");
cardCanvas.width = 512;
cardCanvas.height = 640;
const ctx = cardCanvas.getContext("2d");
ctx.clearRect(0, 0, 512, 640);
// Cream paper with rounded transparent corners.
ctx.save();
ctx.shadowColor = "rgba(28, 46, 48, 0.13)";
ctx.shadowBlur = 10;
ctx.shadowOffsetY = 4;
canvasRoundRect(ctx, 8, 8, 496, 624, 34);
ctx.fillStyle = "#fffdf4";
ctx.fill();
ctx.restore();
canvasRoundRect(ctx, 12, 12, 488, 616, 31);
ctx.strokeStyle = card.color;
ctx.lineWidth = 8;
ctx.stroke();
// Colored header and footer details.
ctx.fillStyle = card.color;
canvasRoundRect(ctx, 12, 12, 488, 56, 31);
ctx.fill();
ctx.fillRect(12, 39, 488, 29);
ctx.textAlign = "left";
ctx.textBaseline = "middle";
ctx.fillStyle = "rgba(255,255,255,0.92)";
ctx.font = "800 21px Arial";
ctx.fillText("SKY SIGNAL", 36, 41);
ctx.textAlign = "right";
ctx.font = "800 20px Arial";
ctx.fillText(String(index + 1).padStart(2, "0"), 477, 41);
// Symbol field.
ctx.fillStyle = card.soft;
ctx.beginPath();
ctx.arc(256, 257, 128, 0, Math.PI * 2);
ctx.fill();
ctx.strokeStyle = "rgba(255,255,255,0.92)";
ctx.lineWidth = 5;
ctx.stroke();
ctx.save();
ctx.translate(256, 257);
drawIcon(ctx, card.id, card.color, card.soft);
ctx.restore();
// Title and category.
ctx.textAlign = "center";
ctx.fillStyle = "#193c40";
ctx.font = "800 39px Arial";
ctx.fillText(card.name.toUpperCase(), 256, 461);
ctx.fillStyle = "#6b7d7f";
ctx.font = "700 19px Arial";
ctx.fillText("WEATHER SIGNAL", 256, 505);
ctx.strokeStyle = "rgba(23,53,58,0.14)";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(72, 541);
ctx.lineTo(440, 541);
ctx.stroke();
ctx.fillStyle = card.color;
ctx.beginPath();
ctx.arc(256, 584, 12, 0, Math.PI * 2);
ctx.fill();
const texture = new THREE.CanvasTexture(cardCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
// -------------------------------------------------------------------------
// Create the twelve cards in a fully visible 4 × 3 arrangement
// -------------------------------------------------------------------------
const cardObjects = [];
const faceMeshes = [];
const cardWidth = 2.15;
const cardHeight = 2.55;
const cardDepth = 0.14;
const baseY = 0.30;
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 4; col++) {
const index = row * 4 + col;
const card = cards[index];
const holder = new THREE.Group();
holder.position.set(
(col - 1.5) * 2.5 + Math.sin(index * 2.1) * 0.025,
baseY,
(row - 1) * 2.7 + Math.cos(index * 1.7) * 0.022
);
holder.rotation.x = -Math.PI / 2;
const visual = new THREE.Group();
const angle = Math.sin(index * 3.4) * 0.011;
visual.rotation.z = angle;
holder.add(visual);
const backing = new THREE.Mesh(
roundedExtrude(cardWidth, cardHeight, cardDepth, 0.17, 0.018),
new THREE.MeshStandardMaterial({
color: 0xeee7d5,
roughness: 0.78,
metalness: 0
})
);
backing.castShadow = true;
backing.receiveShadow = true;
visual.add(backing);
const face = new THREE.Mesh(
new THREE.PlaneGeometry(cardWidth - 0.11, cardHeight - 0.11),
new THREE.MeshStandardMaterial({
map: makeCardTexture(card, index),
transparent: true,
alphaTest: 0.03,
roughness: 0.78,
metalness: 0
})
);
face.position.z = cardDepth / 2 + 0.018 + 0.009;
face.userData.cardIndex = index;
visual.add(face);
faceMeshes.push(face);
scene.add(holder);
cardObjects.push({
holder,
visual,
face,
index,
baseY,
baseAngle: angle,
hovered: false,
selected: false
});
}
}
// -------------------------------------------------------------------------
// Manifest interface
// -------------------------------------------------------------------------
const manifestGrid = document.querySelector("#manifest-grid");
const selectionNote = document.querySelector("#selection-note");
const chips = [];
for (const card of cards) {
const chip = document.createElement("div");
chip.className = "card-chip";
chip.innerHTML = `
<span class="dot" style="background:${card.color}"></span>
<span>${card.name}</span>
`;
manifestGrid.appendChild(chip);
chips.push(chip);
}
// -------------------------------------------------------------------------
// Custom orbit controls — no external controls addon
// -------------------------------------------------------------------------
const target = new THREE.Vector3(0, 0.22, 0);
const defaultView = {
theta: 0.285,
phi: 0.72,
radius: 16.8
};
const view = { ...defaultView };
let dragging = false;
let pointerId = null;
let lastX = 0;
let lastY = 0;
let downX = 0;
let downY = 0;
let moved = false;
let hoveredIndex = -1;
let selectedIndex = -1;
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function updateCamera() {
const sinPhi = Math.sin(view.phi);
camera.position.set(
target.x + view.radius * sinPhi * Math.sin(view.theta),
target.y + view.radius * Math.cos(view.phi),
target.z + view.radius * sinPhi * Math.cos(view.theta)
);
camera.lookAt(target);
}
function resetView() {
view.theta = defaultView.theta;
view.phi = defaultView.phi;
view.radius = defaultView.radius;
}
function updatePointer(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function updateHover(event) {
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(faceMeshes, false);
if (intersections.length) {
const index = intersections[0].object.userData.cardIndex;
if (index !== hoveredIndex) {
if (hoveredIndex >= 0) {
cardObjects[hoveredIndex].hovered = false;
chips[hoveredIndex].classList.remove("active");
}
hoveredIndex = index;
cardObjects[hoveredIndex].hovered = true;
chips[hoveredIndex].classList.add("active");
canvas.style.cursor = "pointer";
}
} else {
if (hoveredIndex >= 0) {
cardObjects[hoveredIndex].hovered = false;
chips[hoveredIndex].classList.remove("active");
}
hoveredIndex = -1;
canvas.style.cursor = dragging ? "grabbing" : "grab";
}
}
canvas.addEventListener("pointerdown", event => {
dragging = true;
moved = false;
pointerId = event.pointerId;
lastX = downX = event.clientX;
lastY = downY = event.clientY;
canvas.setPointerCapture(pointerId);
canvas.style.cursor = "grabbing";
});
canvas.addEventListener("pointermove", event => {
if (dragging && event.pointerId === pointerId) {
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
if (Math.hypot(event.clientX - downX, event.clientY - downY) > 4) {
moved = true;
}
view.theta -= dx * 0.0055;
view.phi = THREE.MathUtils.clamp(view.phi + dy * 0.0045, 0.38, 1.28);
lastX = event.clientX;
lastY = event.clientY;
} else {
updateHover(event);
}
});
function endPointer(event) {
if (!dragging || event.pointerId !== pointerId) return;
dragging = false;
if (canvas.hasPointerCapture(pointerId)) {
canvas.releasePointerCapture(pointerId);
}
pointerId = null;
canvas.style.cursor = hoveredIndex >= 0 ? "pointer" : "grab";
if (!moved) {
updateHover(event);
if (hoveredIndex >= 0) {
if (selectedIndex === hoveredIndex) {
cardObjects[selectedIndex].selected = false;
selectedIndex = -1;
selectionNote.textContent =
"Selection cleared. Hover a card to lift it; click to select.";
} else {
if (selectedIndex >= 0) {
cardObjects[selectedIndex].selected = false;
}
selectedIndex = hoveredIndex;
cardObjects[selectedIndex].selected = true;
selectionNote.textContent =
`${cards[selectedIndex].name} selected. All 12 cards remain visible in the tray.`;
}
} else if (selectedIndex >= 0) {
cardObjects[selectedIndex].selected = false;
selectedIndex = -1;
selectionNote.textContent =
"All twelve symbols are visible. Hover a card to lift it; click to select.";
}
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("pointerleave", () => {
if (!dragging && hoveredIndex >= 0) {
cardObjects[hoveredIndex].hovered = false;
chips[hoveredIndex].classList.remove("active");
hoveredIndex = -1;
}
});
canvas.addEventListener(
"wheel",
event => {
event.preventDefault();
view.radius = THREE.MathUtils.clamp(
view.radius * Math.exp(event.deltaY * 0.001),
10.5,
24
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetView);
window.addEventListener("keydown", event => {
if (event.key === "r" || event.key === "R") {
resetView();
} else if (event.key === "ArrowLeft") {
view.theta += 0.09;
} else if (event.key === "ArrowRight") {
view.theta -= 0.09;
} else if (event.key === "ArrowUp") {
view.phi = Math.max(0.38, view.phi - 0.06);
} else if (event.key === "ArrowDown") {
view.phi = Math.min(1.28, view.phi + 0.06);
} else if (event.key === "+" || event.key === "=") {
view.radius = Math.max(10.5, view.radius - 0.7);
} else if (event.key === "-") {
view.radius = Math.min(24, view.radius + 0.7);
}
});
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
let firstFrame = true;
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
updateCamera();
for (const card of cardObjects) {
const targetLift =
(card.selected ? 0.68 : 0) + (card.hovered ? 0.34 : 0);
const targetY = card.baseY + targetLift;
card.holder.position.y = THREE.MathUtils.damp(
card.holder.position.y,
targetY,
10,
delta
);
const targetAngle =
card.baseAngle + (card.selected ? -0.018 : 0);
card.visual.rotation.z = THREE.MathUtils.damp(
card.visual.rotation.z,
targetAngle,
10,
delta
);
}
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
requestAnimationFrame(() => {
document.querySelector("#boot").classList.add("hidden");
});
}
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```