Prompt specification
Build or customize the Three.js 3D scene "Picnic basket and shelter map" 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: Picnic basket and shelter map
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/picnic-basket-and-shelter-map-x3893
Scene Description Prompt:
Make a stylized Three.js scene in a self-contained HTML file using cdnjs: picnic basket and shelter map. Place a picnic basket beside a small park map showing open lawn and covered pavilion; use matching markers to connect physical objects to planned destinations.
Working Three.js Starter (picnic-basket-and-shelter-map-x3893):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Picnic Basket & Shelter Map</title>
<style>
:root {
--ink: #26352d;
--muted: #69746b;
--cream: #f4efe5;
--panel: rgba(255, 252, 246, 0.9);
--orange: #d98243;
--teal: #328f89;
--line: rgba(38, 53, 45, 0.13);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--cream);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#viewport {
position: fixed;
inset: 0;
}
#viewport canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#viewport canvas.dragging {
cursor: grabbing;
}
.intro {
position: fixed;
top: 28px;
left: 30px;
z-index: 10;
width: min(350px, calc(100vw - 60px));
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
color: #647068;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 25px;
height: 2px;
background: var(--orange);
content: "";
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(32px, 4vw, 52px);
font-weight: 500;
letter-spacing: -0.035em;
line-height: 0.98;
}
.intro p {
max-width: 310px;
margin: 13px 0 0;
color: var(--muted);
font-size: 14px;
line-height: 1.55;
}
.controls {
position: fixed;
top: 26px;
right: 26px;
z-index: 20;
display: flex;
gap: 8px;
}
.controls button {
min-height: 39px;
padding: 0 14px;
border: 1px solid var(--line);
border-radius: 999px;
background: var(--panel);
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
backdrop-filter: blur(12px);
box-shadow: 0 7px 24px rgba(60, 55, 42, 0.08);
transition:
transform 160ms ease,
background 160ms ease;
}
.controls button:hover {
transform: translateY(-1px);
background: #fffdf8;
}
.controls button:active {
transform: translateY(1px);
}
.legend {
position: fixed;
left: 26px;
bottom: 25px;
z-index: 15;
width: min(350px, calc(100vw - 52px));
padding: 17px 18px 15px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 18px 55px rgba(65, 56, 38, 0.11);
backdrop-filter: blur(14px);
}
.legend-title {
margin: 0 0 11px;
color: #778078;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.legend-row {
display: grid;
grid-template-columns: 31px 1fr;
align-items: center;
gap: 10px;
padding: 8px 0;
border-top: 1px solid rgba(38, 53, 45, 0.08);
}
.badge {
display: grid;
width: 28px;
height: 28px;
place-items: center;
border: 2px solid rgba(255, 255, 255, 0.9);
border-radius: 50%;
color: white;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.02em;
box-shadow: 0 4px 10px rgba(38, 53, 45, 0.18);
}
.badge.orange {
background: var(--orange);
}
.badge.teal {
background: var(--teal);
}
.legend-copy strong {
display: block;
margin-bottom: 2px;
font-size: 13px;
font-weight: 750;
}
.legend-copy span {
color: var(--muted);
font-size: 12px;
}
.legend-copy span b {
color: #47554c;
font-weight: 700;
}
.help {
position: fixed;
right: 28px;
bottom: 28px;
z-index: 10;
color: #778078;
font-size: 11px;
font-weight: 650;
letter-spacing: 0.02em;
pointer-events: none;
}
.scene-label {
position: fixed;
z-index: 8;
display: flex;
align-items: center;
gap: 7px;
padding: 6px 9px 6px 6px;
border: 1px solid rgba(38, 53, 45, 0.11);
border-radius: 999px;
background: rgba(255, 252, 246, 0.91);
color: #3a4941;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.06em;
text-transform: uppercase;
white-space: nowrap;
pointer-events: none;
transform: translate(-50%, -115%);
box-shadow: 0 6px 18px rgba(50, 50, 38, 0.1);
backdrop-filter: blur(8px);
opacity: 0;
transition: opacity 180ms ease;
}
.scene-label.visible {
opacity: 1;
}
.scene-label .mini-badge {
display: grid;
width: 20px;
height: 20px;
place-items: center;
border-radius: 50%;
color: white;
font-size: 8px;
}
.scene-label.basket .mini-badge {
background: var(--orange);
}
.scene-label.shelter .mini-badge {
background: var(--teal);
}
@media (max-width: 700px) {
.intro {
top: 20px;
left: 20px;
}
.intro p {
display: none;
}
h1 {
font-size: 36px;
}
.controls {
top: 19px;
right: 18px;
}
.controls button {
padding: 0 11px;
font-size: 11px;
}
.legend {
left: 18px;
bottom: 18px;
padding: 13px 14px;
}
.legend-title {
margin-bottom: 7px;
}
.legend-row {
padding: 6px 0;
}
.help {
display: none;
}
}
</style>
</head>
<body>
<main id="viewport" aria-label="Interactive 3D picnic basket and park map scene"></main>
<header class="intro">
<div class="eyebrow">Cedar Park Field Plan</div>
<h1>A little plan for a lovely day.</h1>
<p>
Match the numbered markers to find the open lawn and the covered pavilion.
Drag the scene to explore.
</p>
</header>
<nav class="controls" aria-label="Camera controls">
<button id="resetView" type="button">Reset view</button>
<button id="topView" type="button">Top view</button>
</nav>
<aside class="legend" aria-label="Marker legend">
<p class="legend-title">Match the markers</p>
<div class="legend-row">
<span class="badge orange">01</span>
<span class="legend-copy">
<strong>Picnic basket</strong>
<span>Destination: <b>Open lawn</b></span>
</span>
</div>
<div class="legend-row">
<span class="badge teal">02</span>
<span class="legend-copy">
<strong>Covered pavilion</strong>
<span>Destination: <b>Pavilion shelter</b></span>
</span>
</div>
</aside>
<div class="help">Drag to orbit • Scroll to zoom • Double-click to reset</div>
<div id="basketLabel" class="scene-label basket">
<span class="mini-badge">01</span>
Picnic basket
</div>
<div id="shelterLabel" class="scene-label shelter">
<span class="mini-badge">02</span>
Covered pavilion
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const viewport = document.getElementById("viewport");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf4efe5);
scene.fog = new THREE.Fog(0xf4efe5, 14, 25);
const camera = new THREE.PerspectiveCamera(
34,
window.innerWidth / window.innerHeight,
0.1,
60
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"A three-dimensional picnic basket beside a park map and covered pavilion"
);
viewport.appendChild(renderer.domElement);
const COLORS = {
cream: 0xf4efe5,
grass: 0xacc987,
orange: 0xd98243,
teal: 0x328f89,
wood: 0xa97746,
darkWood: 0x6f482d,
wicker: 0xc8904f,
roof: 0x367f7b,
ink: 0x29362f
};
const material = (color, roughness = 0.8, metalness = 0) =>
new THREE.MeshStandardMaterial({
color,
roughness,
metalness
});
const hemi = new THREE.HemisphereLight(0xfff8e8, 0x829174, 2.35);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff0cf, 3.4);
sun.position.set(-3.5, 8.5, 5.5);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -7;
sun.shadow.camera.right = 7;
sun.shadow.camera.top = 7;
sun.shadow.camera.bottom = -7;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 22;
sun.shadow.bias = -0.00025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xbcd9db, 1.2);
fill.position.set(6, 4, -5);
scene.add(fill);
// Ground and oval presentation plinth.
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
material(0xf4efe5, 1)
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.26;
ground.receiveShadow = true;
scene.add(ground);
const plinth = new THREE.Mesh(
new THREE.CylinderGeometry(5.8, 5.95, 0.18, 72),
material(0xe9dfcc, 0.95)
);
plinth.scale.z = 0.73;
plinth.position.y = -0.17;
plinth.receiveShadow = true;
plinth.castShadow = true;
scene.add(plinth);
const plinthInset = new THREE.Mesh(
new THREE.CylinderGeometry(5.58, 5.58, 0.018, 72),
material(0xeee6d8, 1)
);
plinthInset.scale.z = 0.73;
plinthInset.position.y = -0.07;
plinthInset.receiveShadow = true;
scene.add(plinthInset);
// Canvas-generated badge textures.
function createBadgeTexture(number, color) {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, 256, 256);
ctx.shadowColor = "rgba(25, 40, 32, 0.22)";
ctx.shadowBlur = 16;
ctx.shadowOffsetY = 7;
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(128, 128, 103, 0, Math.PI * 2);
ctx.fill();
ctx.shadowColor = "transparent";
ctx.lineWidth = 10;
ctx.strokeStyle = "rgba(255,255,255,0.95)";
ctx.stroke();
ctx.fillStyle = "#ffffff";
ctx.font = "800 68px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(number, 128, 133);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
function createBadgeSprite(number, color, size = 0.38) {
const texture = createBadgeTexture(number, color);
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(size, size, 1);
sprite.renderOrder = 20;
return sprite;
}
// Small checkered picnic-cloth texture.
function createClothTexture() {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#f8e9d1";
ctx.fillRect(0, 0, 256, 256);
const colors = ["#d77759", "#efad7a", "#f8e9d1"];
for (let y = 0; y < 4; y++) {
for (let x = 0; x < 4; x++) {
ctx.fillStyle = colors[(x + y) % 3];
ctx.fillRect(x * 64, y * 64, 64, 64);
}
}
ctx.globalAlpha = 0.13;
ctx.strokeStyle = "#75452e";
ctx.lineWidth = 5;
for (let i = -4; i < 9; i++) {
ctx.beginPath();
ctx.moveTo(i * 64, 0);
ctx.lineTo(i * 64 + 256, 256);
ctx.stroke();
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
// ---------------------------------------------------------------------
// Picnic basket
// ---------------------------------------------------------------------
const basket = new THREE.Group();
basket.position.set(-2.75, 0, 0.7);
basket.rotation.y = 0.14;
scene.add(basket);
const blanket = new THREE.Mesh(
new THREE.CircleGeometry(1.02, 48),
material(0xcf7c63, 1)
);
blanket.rotation.x = -Math.PI / 2;
blanket.scale.set(1.18, 0.82, 1);
blanket.position.y = 0.015;
blanket.receiveShadow = true;
basket.add(blanket);
const blanketBorder = new THREE.Mesh(
new THREE.RingGeometry(0.82, 0.9, 48),
material(0xf2c4a1, 1)
);
blanketBorder.rotation.x = -Math.PI / 2;
blanketBorder.scale.set(1.18, 0.82, 1);
blanketBorder.position.y = 0.022;
basket.add(blanketBorder);
const basketCore = new THREE.Mesh(
new THREE.BoxGeometry(1.13, 0.64, 0.76),
material(0xa96f38, 0.96)
);
basketCore.position.y = 0.48;
basketCore.castShadow = true;
basketCore.receiveShadow = true;
basket.add(basketCore);
const wicker = material(COLORS.wicker, 0.92);
const darkWood = material(COLORS.darkWood, 0.88);
// Horizontal front and back slats.
for (let i = 0; i < 5; i++) {
for (const z of [-0.395, 0.395]) {
const slat = new THREE.Mesh(
new THREE.BoxGeometry(1.2, 0.075, 0.055),
wicker
);
slat.position.set(0, 0.235 + i * 0.105, z);
slat.castShadow = true;
basket.add(slat);
}
// Side slats.
for (const x of [-0.61, 0.61]) {
const slat = new THREE.Mesh(
new THREE.BoxGeometry(0.055, 0.075, 0.78),
wicker
);
slat.position.set(x, 0.235 + i * 0.105, 0);
slat.castShadow = true;
basket.add(slat);
}
}
// Dark corner straps.
for (const x of [-0.575, 0.575]) {
for (const z of [-0.385, 0.385]) {
const strap = new THREE.Mesh(
new THREE.BoxGeometry(0.085, 0.73, 0.085),
darkWood
);
strap.position.set(x, 0.49, z);
strap.castShadow = true;
basket.add(strap);
}
}
const topRim = material(0xb9783d, 0.86);
for (const z of [-0.4, 0.4]) {
const rim = new THREE.Mesh(
new THREE.BoxGeometry(1.28, 0.11, 0.1),
topRim
);
rim.position.set(0, 0.83, z);
rim.castShadow = true;
basket.add(rim);
}
for (const x of [-0.615, 0.615]) {
const rim = new THREE.Mesh(
new THREE.BoxGeometry(0.1, 0.11, 0.87),
topRim
);
rim.position.set(x, 0.83, 0);
rim.castShadow = true;
basket.add(rim);
}
const handleCurve = new THREE.QuadraticBezierCurve3(
new THREE.Vector3(-0.58, 0.87, 0),
new THREE.Vector3(0, 1.72, 0),
new THREE.Vector3(0.58, 0.87, 0)
);
const handle = new THREE.Mesh(
new THREE.TubeGeometry(handleCurve, 36, 0.055, 8, false),
darkWood
);
handle.castShadow = true;
basket.add(handle);
const grip = new THREE.Mesh(
new THREE.CylinderGeometry(0.073, 0.073, 0.25, 12),
material(0x80502f, 0.85)
);
grip.position.set(0, 1.285, 0);
grip.castShadow = true;
basket.add(grip);
const clothTexture = createClothTexture();
const clothTop = new THREE.Mesh(
new THREE.PlaneGeometry(0.89, 0.56),
new THREE.MeshStandardMaterial({
map: clothTexture,
roughness: 0.96,
side: THREE.DoubleSide
})
);
clothTop.rotation.x = -Math.PI / 2;
clothTop.position.set(-0.02, 0.875, 0.01);
clothTop.castShadow = true;
basket.add(clothTop);
const clothDrape = new THREE.Mesh(
new THREE.PlaneGeometry(0.52, 0.36),
new THREE.MeshStandardMaterial({
map: clothTexture,
roughness: 0.96,
side: THREE.DoubleSide
})
);
clothDrape.position.set(-0.25, 0.73, 0.425);
clothDrape.rotation.z = -0.08;
clothDrape.castShadow = true;
basket.add(clothDrape);
// Bread tucked into the basket.
const breadMaterial = material(0xd6a158, 0.95);
const bread = new THREE.Mesh(
new THREE.CylinderGeometry(0.105, 0.105, 0.66, 12),
breadMaterial
);
bread.rotation.z = Math.PI / 2;
bread.position.set(0.17, 0.97, 0.02);
bread.castShadow = true;
basket.add(bread);
for (const x of [-0.16, 0.5]) {
const cap = new THREE.Mesh(
new THREE.SphereGeometry(0.105, 12, 8),
breadMaterial
);
cap.position.set(x, 0.97, 0.02);
cap.scale.x = 0.65;
cap.castShadow = true;
basket.add(cap);
}
const bottle = new THREE.Mesh(
new THREE.CylinderGeometry(0.12, 0.14, 0.42, 16),
material(0x507d55, 0.5)
);
bottle.position.set(-0.22, 1.03, -0.08);
bottle.castShadow = true;
basket.add(bottle);
const bottleNeck = new THREE.Mesh(
new THREE.CylinderGeometry(0.055, 0.075, 0.15, 12),
material(0x6d593e, 0.55)
);
bottleNeck.position.set(-0.22, 1.29, -0.08);
bottleNeck.castShadow = true;
basket.add(bottleNeck);
const basketBadge = createBadgeSprite("01", "#d98243", 0.39);
basketBadge.position.set(0, 0.64, 0.47);
basket.add(basketBadge);
// ---------------------------------------------------------------------
// Covered pavilion
// ---------------------------------------------------------------------
const shelter = new THREE.Group();
shelter.position.set(-1.35, 0, -1.35);
shelter.rotation.y = -0.13;
scene.add(shelter);
const shelterPad = new THREE.Mesh(
new THREE.CylinderGeometry(1.02, 1.05, 0.08, 48),
material(0xd5c9b3, 0.95)
);
shelterPad.scale.z = 0.76;
shelterPad.position.y = 0.015;
shelterPad.receiveShadow = true;
shelter.add(shelterPad);
const shelterFloor = new THREE.Mesh(
new THREE.BoxGeometry(1.45, 0.09, 1.08),
material(0xb98655, 0.92)
);
shelterFloor.position.y = 0.08;
shelterFloor.castShadow = true;
shelterFloor.receiveShadow = true;
shelter.add(shelterFloor);
const shelterWood = material(0x9f6f43, 0.88);
const shelterRoof = material(COLORS.roof, 0.75);
for (const x of [-0.57, 0.57]) {
for (const z of [-0.43, 0.43]) {
const post = new THREE.Mesh(
new THREE.BoxGeometry(0.105, 1.28, 0.105),
shelterWood
);
post.position.set(x, 0.72, z);
post.castShadow = true;
shelter.add(post);
}
}
// Back-wall slats.
for (let i = 0; i < 7; i++) {
const slat = new THREE.Mesh(
new THREE.BoxGeometry(0.13, 0.73, 0.055),
material(0xc08b57, 0.9)
);
slat.position.set(-0.48 + i * 0.16, 0.62, -0.43);
slat.castShadow = true;
shelter.add(slat);
}
const leftRoof = new THREE.Mesh(
new THREE.BoxGeometry(0.95, 0.1, 1.38),
shelterRoof
);
leftRoof.position.set(-0.42, 1.48, 0);
leftRoof.rotation.z = 0.48;
leftRoof.castShadow = true;
shelter.add(leftRoof);
const rightRoof = new THREE.Mesh(
new THREE.BoxGeometry(0.95, 0.1, 1.38),
shelterRoof
);
rightRoof.position.set(0.42, 1.48, 0);
rightRoof.rotation.z = -0.48;
rightRoof.castShadow = true;
shelter.add(rightRoof);
const ridge = new THREE.Mesh(
new THREE.BoxGeometry(0.08, 0.1, 1.45),
material(0x276b69, 0.75)
);
ridge.position.set(0, 1.79, 0);
ridge.castShadow = true;
shelter.add(ridge);
for (const z of [-0.7, 0.7]) {
const fascia = new THREE.Mesh(
new THREE.BoxGeometry(1.72, 0.12, 0.065),
material(0x2d7773, 0.82)
);
fascia.position.set(0, 1.4, z);
fascia.castShadow = true;
shelter.add(fascia);
}
// Picnic table inside the pavilion.
const tableTop = new THREE.Mesh(
new THREE.BoxGeometry(0.92, 0.08, 0.42),
material(0xd3a06b, 0.9)
);
tableTop.position.set(0, 0.61, 0.02);
tableTop.castShadow = true;
shelter.add(tableTop);
for (const z of [-0.29, 0.29]) {
const bench = new THREE.Mesh(
new THREE.BoxGeometry(0.94, 0.07, 0.17),
material(0xc18b58, 0.9)
);
bench.position.set(0, 0.35, z);
bench.castShadow = true;
shelter.add(bench);
}
for (const x of [-0.32, 0.32]) {
for (const z of [-0.14, 0.15]) {
const leg = new THREE.Mesh(
new THREE.BoxGeometry(0.07, 0.48, 0.07),
shelterWood
);
leg.position.set(x, 0.37, z);
leg.castShadow = true;
shelter.add(leg);
}
}
const shelterBadge = createBadgeSprite("02", "#328f89", 0.4);
shelterBadge.position.set(0, 2.04, 0);
shelter.add(shelterBadge);
// ---------------------------------------------------------------------
// Park map canvas
// ---------------------------------------------------------------------
function drawMapBadge(ctx, x, y, number, color) {
ctx.save();
ctx.shadowColor = "rgba(32, 52, 40, 0.26)";
ctx.shadowBlur = 13;
ctx.shadowOffsetY = 5;
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(x, y, 29, 0, Math.PI * 2);
ctx.fill();
ctx.shadowColor = "transparent";
ctx.lineWidth = 6;
ctx.strokeStyle = "rgba(255,255,255,0.95)";
ctx.stroke();
ctx.fillStyle = "#ffffff";
ctx.font = "800 25px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(number, x, y + 1);
ctx.restore();
}
function drawTree(ctx, x, y, radius = 18) {
ctx.fillStyle = "rgba(48, 85, 48, 0.16)";
ctx.beginPath();
ctx.ellipse(x + 4, y + 8, radius * 0.85, radius * 0.34, 0, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = "#668d59";
ctx.beginPath();
ctx.arc(x, y, radius, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = "#7fa46a";
ctx.beginPath();
ctx.arc(x - radius * 0.25, y - radius * 0.25, radius * 0.58, 0, Math.PI * 2);
ctx.fill();
}
function createMapTexture() {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 768;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#dce7cb";
ctx.fillRect(0, 0, 1024, 768);
// Subtle map grid.
ctx.strokeStyle = "rgba(79, 111, 75, 0.06)";
ctx.lineWidth = 2;
for (let x = 0; x <= 1024; x += 64) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, 768);
ctx.stroke();
}
for (let y = 0; y <= 768; y += 64) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(1024, y);
ctx.stroke();
}
// Main lawn.
ctx.beginPath();
ctx.moveTo(125, 330);
ctx.bezierCurveTo(175, 260, 325, 255, 410, 315);
ctx.bezierCurveTo(520, 395, 575, 510, 505, 620);
ctx.bezierCurveTo(435, 716, 220, 700, 135, 625);
ctx.bezierCurveTo(60, 560, 75, 410, 125, 330);
ctx.closePath();
ctx.fillStyle = "#aeca83";
ctx.fill();
ctx.strokeStyle = "#7ea064";
ctx.lineWidth = 6;
ctx.stroke();
// Winding path.
ctx.lineCap = "round";
ctx.lineJoin = "round";
ctx.beginPath();
ctx.moveTo(72, 690);
ctx.bezierCurveTo(250, 610, 345, 640, 455, 525);
ctx.bezierCurveTo(575, 400, 610, 315, 764, 303);
ctx.bezierCurveTo(855, 296, 895, 222, 966, 166);
ctx.strokeStyle = "#eadbbd";
ctx.lineWidth = 72;
ctx.stroke();
ctx.strokeStyle = "#fff1d4";
ctx.lineWidth = 43;
ctx.stroke();
// Secondary path.
ctx.beginPath();
ctx.moveTo(435, 526);
ctx.bezierCurveTo(520, 538, 596, 592, 663, 626);
ctx.strokeStyle = "#eadbbd";
ctx.lineWidth = 48;
ctx.stroke();
ctx.strokeStyle = "#fff1d4";
ctx.lineWidth = 28;
ctx.stroke();
// Pond.
ctx.beginPath();
ctx.ellipse(807, 559, 93, 52, -0.12, 0, Math.PI * 2);
ctx.fillStyle = "#a9d3cf";
ctx.fill();
ctx.strokeStyle = "#7eb5b0";
ctx.lineWidth = 7;
ctx.stroke();
ctx.strokeStyle = "rgba(255,255,255,0.55)";
ctx.lineWidth = 4;
ctx.beginPath();
ctx.ellipse(803, 554, 66, 30, -0.12, 0, Math.PI * 2);
ctx.stroke();
// Pavilion area.
ctx.fillStyle = "#d5dbc5";
ctx.fillRect(590, 146, 220, 194);
ctx.strokeStyle = "#9ca98e";
ctx.lineWidth = 5;
ctx.strokeRect(590, 146, 220, 194);
// Pavilion icon.
ctx.fillStyle = "#b99a6d";
ctx.fillRect(630, 266, 141, 24);
ctx.fillStyle = "#367f7b";
ctx.beginPath();
ctx.moveTo(618, 247);
ctx.lineTo(700, 186);
ctx.lineTo(784, 247);
ctx.closePath();
ctx.fill();
ctx.fillStyle = "#2c6e6a";
ctx.fillRect(615, 244, 172, 13);
ctx.fillStyle = "#9c7048";
ctx.fillRect(637, 254, 11, 34);
ctx.fillRect(754, 254, 11, 34);
// Tree clusters.
[
[74, 165, 25],
[139, 121, 19],
[197, 184, 23],
[860, 103, 21],
[925, 97, 27],
[955, 350, 20],
[913, 401, 25],
[75, 510, 18],
[141, 718, 19],
[527, 704, 23],
[926, 668, 21]
].forEach(([x, y, r]) => drawTree(ctx, x, y, r));
// Map labels.
ctx.fillStyle = "#496344";
ctx.font = "700 25px Georgia, serif";
ctx.fillText("OPEN LAWN", 160, 414);
ctx.font = "600 19px system-ui, sans-serif";
ctx.fillStyle = "#60735a";
ctx.fillText("Picnic meadow", 160, 444);
ctx.fillStyle = "#496344";
ctx.font = "700 24px Georgia, serif";
ctx.fillText("COVERED PAVILION", 595, 120);
ctx.font = "600 18px system-ui, sans-serif";
ctx.fillStyle = "#60735a";
ctx.fillText("Rain or shine", 635, 140);
// Map title.
ctx.fillStyle = "#304f3c";
ctx.font = "700 38px Georgia, serif";
ctx.fillText("CEDAR PARK", 55, 66);
ctx.font = "600 16px system-ui, sans-serif";
ctx.fillStyle = "#62735e";
ctx.fillText("COMMUNITY PARK • WALKING PLAN", 58, 94);
// North arrow.
ctx.save();
ctx.translate(940, 74);
ctx.fillStyle = "#48624d";
ctx.beginPath();
ctx.moveTo(0, -29);
ctx.lineTo(12, 13);
ctx.lineTo(0, 7);
ctx.lineTo(-12, 13);
ctx.closePath();
ctx.fill();
ctx.font = "800 17px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.fillText("N", 0, 34);
ctx.restore();
// Scale bar.
ctx.strokeStyle = "#526a55";
ctx.lineWidth = 5;
ctx.beginPath();
ctx.moveTo(55, 716);
ctx.lineTo(155, 716);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(55, 708);
ctx.lineTo(55, 724);
ctx.moveTo(155, 708);
ctx.lineTo(155, 724);
ctx.stroke();
ctx.font = "600 15px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.fillText("5 MIN WALK", 105, 745);
// Matching numbered map markers.
drawMapBadge(ctx, 292, 535, "01", "#d98243");
drawMapBadge(ctx, 690, 218, "02", "#328f89");
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
const mapGroup = new THREE.Group();
mapGroup.position.set(1.35, 0.24, 0);
scene.add(mapGroup);
const mapBase = new THREE.Mesh(
new THREE.BoxGeometry(4.74, 0.18, 3.44),
material(0x9e7046, 0.86)
);
mapBase.castShadow = true;
mapBase.receiveShadow = true;
mapGroup.add(mapBase);
const mapSurface = new THREE.Mesh(
new THREE.PlaneGeometry(4.5, 3.2),
new THREE.MeshStandardMaterial({
map: createMapTexture(),
roughness: 0.96,
metalness: 0
})
);
mapSurface.rotation.x = -Math.PI / 2;
mapSurface.position.y = 0.105;
mapSurface.receiveShadow = true;
mapGroup.add(mapSurface);
const frameMaterial = material(0xb37d49, 0.86);
for (const z of [-1.66, 1.66]) {
const frame = new THREE.Mesh(
new THREE.BoxGeometry(4.76, 0.11, 0.12),
frameMaterial
);
frame.position.set(0, 0.13, z);
frame.castShadow = true;
mapGroup.add(frame);
}
for (const x of [-2.31, 2.31]) {
const frame = new THREE.Mesh(
new THREE.BoxGeometry(0.12, 0.11, 3.43),
frameMaterial
);
frame.position.set(x, 0.13, 0);
frame.castShadow = true;
mapGroup.add(frame);
}
// Small support feet.
for (const x of [-1.65, 1.65]) {
for (const z of [-1.05, 1.05]) {
const foot = new THREE.Mesh(
new THREE.BoxGeometry(0.14, 0.45, 0.14),
darkWood
);
foot.position.set(x, -0.28, z);
foot.castShadow = true;
mapGroup.add(foot);
}
}
// Convert map pixel positions to the corresponding 3D board positions.
function mapPoint(px, py) {
const u = px / 1024;
const v = 1 - py / 768;
const x = (u - 0.5) * 4.5;
const z = -(v - 0.5) * 3.2;
return new THREE.Vector3(
mapGroup.position.x + x,
mapGroup.position.y + 0.17,
mapGroup.position.z + z
);
}
const picnicMapPoint = mapPoint(292, 535);
const pavilionMapPoint = mapPoint(690, 218);
// Pulsing rings emphasize the map destinations.
function createMapRing(color) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.18, 0.025, 8, 40),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.85
})
);
ring.rotation.x = Math.PI / 2;
return ring;
}
const picnicRing = createMapRing(COLORS.orange);
picnicRing.position.copy(picnicMapPoint);
picnicRing.position.y += 0.01;
scene.add(picnicRing);
const pavilionRing = createMapRing(COLORS.teal);
pavilionRing.position.copy(pavilionMapPoint);
pavilionRing.position.y += 0.01;
scene.add(pavilionRing);
// ---------------------------------------------------------------------
// Dotted connections from physical objects to matching map destinations.
// ---------------------------------------------------------------------
scene.updateMatrixWorld(true);
const basketWorldBadge = new THREE.Vector3();
const shelterWorldBadge = new THREE.Vector3();
basketBadge.getWorldPosition(basketWorldBadge);
shelterBadge.getWorldPosition(shelterWorldBadge);
const connectorAnimations = [];
function createConnector(start, end, color, lift) {
const midpoint = start.clone().add(end).multiplyScalar(0.5);
const control = midpoint.clone();
control.y += lift;
const curve = new THREE.QuadraticBezierCurve3(start, control, end);
const geometry = new THREE.BufferGeometry().setFromPoints(
curve.getPoints(80)
);
const line = new THREE.Line(
geometry,
new THREE.LineDashedMaterial({
color,
transparent: true,
opacity: 0.3,
dashSize: 0.07,
gapSize: 0.1,
depthWrite: false
})
);
line.computeLineDistances();
scene.add(line);
const movingDots = [];
const count = 11;
for (let i = 0; i < count; i++) {
const dot = new THREE.Mesh(
new THREE.SphereGeometry(0.035, 10, 8),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.85,
depthWrite: false
})
);
scene.add(dot);
movingDots.push(dot);
}
connectorAnimations.push({ curve, movingDots, count });
}
createConnector(
basketWorldBadge.clone(),
picnicMapPoint.clone(),
COLORS.orange,
1.55
);
createConnector(
shelterWorldBadge.clone(),
pavilionMapPoint.clone(),
COLORS.teal,
2.1
);
// ---------------------------------------------------------------------
// Camera controls implemented directly, without Three.js addons.
// ---------------------------------------------------------------------
const cameraTarget = new THREE.Vector3(0, 0.5, 0);
const defaultView = {
theta: 0.72,
phi: 0.82,
radius: window.innerWidth < 700 ? 14.5 : 11.7
};
const desired = { ...defaultView };
const current = { ...defaultView };
let dragging = false;
let moved = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
moved = false;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.classList.add("dragging");
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
if (Math.abs(dx) + Math.abs(dy) > 2) moved = true;
pointerX = event.clientX;
pointerY = event.clientY;
desired.theta -= dx * 0.006;
desired.phi = THREE.MathUtils.clamp(
desired.phi - dy * 0.005,
0.16,
1.36
);
});
function endDrag(event) {
dragging = false;
renderer.domElement.classList.remove("dragging");
if (event.pointerId !== undefined) {
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius * Math.exp(event.deltaY * 0.001),
7.5,
18
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
Object.assign(desired, defaultView);
});
document.getElementById("resetView").addEventListener("click", () => {
Object.assign(desired, defaultView);
});
document.getElementById("topView").addEventListener("click", () => {
desired.theta = 0;
desired.phi = 0.12;
desired.radius = window.innerWidth < 700 ? 14.5 : 11.2;
});
// Project DOM labels from their 3D anchors.
const basketLabel = document.getElementById("basketLabel");
const shelterLabel = document.getElementById("shelterLabel");
const projected = new THREE.Vector3();
function updateLabel(element, worldPosition, offsetX = 0, offsetY = 0) {
projected.copy(worldPosition).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.25 &&
Math.abs(projected.y) < 1.25;
element.classList.toggle("visible", visible);
if (!visible) return;
const x = (projected.x * 0.5 + 0.5) * window.innerWidth + offsetX;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight + offsetY;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
// Animation loop.
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
// Smooth camera interpolation.
current.theta += (desired.theta - current.theta) * 0.085;
current.phi += (desired.phi - current.phi) * 0.085;
current.radius += (desired.radius - current.radius) * 0.085;
const sinPhi = Math.sin(current.phi);
camera.position.set(
cameraTarget.x + current.radius * sinPhi * Math.sin(current.theta),
cameraTarget.y + current.radius * Math.cos(current.phi),
cameraTarget.z + current.radius * sinPhi * Math.cos(current.theta)
);
camera.lookAt(cameraTarget);
// Animate moving beads along each matching dotted route.
connectorAnimations.forEach(({ curve, movingDots, count }) => {
movingDots.forEach((dot, index) => {
const t = (elapsed * 0.085 + index / count) % 1;
dot.position.copy(curve.getPointAt(t));
dot.material.opacity = Math.sin(Math.PI * t) * 0.9;
const scale = 0.75 + Math.sin(Math.PI * t) * 0.45;
dot.scale.setScalar(scale);
});
});
const pulse = 1 + Math.sin(elapsed * 3.1) * 0.12;
picnicRing.scale.setScalar(pulse);
pavilionRing.scale.setScalar(1 + Math.sin(elapsed * 3.1 + 1.4) * 0.12);
const badgeWorld = new THREE.Vector3();
basketBadge.getWorldPosition(badgeWorld);
updateLabel(basketLabel, badgeWorld, 0, -14);
shelterBadge.getWorldPosition(badgeWorld);
updateLabel(shelterLabel, badgeWorld, 0, -12);
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```