Prompt specification
Build or customize the Three.js 3D scene "Gemmayzeh triple-arched window and stair tile" 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: Gemmayzeh triple-arched window and stair tile
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/gemmayzeh-triple-arched-window-and-stair-tile-x2893
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts a voxel facade fragment from Beirut's Gemmayzeh neighborhood. Use a selected local reference for a triple-arched window group and the neighboring stone stair passage. Model the arch divisions, wall depth, railing, and a small landing at a coherent block scale. The stairs should meet the building threshold rather than float against the wall. Keep the surrounding fragment modest: a narrow pavement strip, one doorway, and enough neighboring wall to establish the slope. Use warm stone, darker window recesses, and simple greenery. Frame the piece from the lower stair so the facade and vertical connection are visible together.
Working Three.js Starter (gemmayzeh-triple-arched-window-and-stair-tile-x2893):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Gemmayzeh — Triple Arch and Stone Stair</title>
<style>
:root {
color-scheme: dark;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #aebfc1;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.caption {
position: fixed;
top: 24px;
left: 26px;
z-index: 2;
max-width: min(390px, calc(100vw - 52px));
padding: 14px 17px 15px;
color: #f5eddc;
background: rgba(30, 35, 32, 0.76);
border: 1px solid rgba(255, 255, 255, 0.16);
border-radius: 3px;
backdrop-filter: blur(9px);
pointer-events: none;
box-shadow: 0 10px 30px rgba(29, 25, 18, 0.15);
}
.caption small {
display: block;
margin-bottom: 5px;
color: #d5bb8a;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.caption h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(22px, 3vw, 31px);
font-weight: 500;
line-height: 1.04;
}
.caption p {
margin: 8px 0 0;
color: rgba(245, 237, 220, 0.72);
font-size: 12px;
letter-spacing: 0.03em;
}
.help {
position: fixed;
right: 20px;
bottom: 18px;
z-index: 2;
padding: 9px 12px;
color: rgba(250, 244, 230, 0.86);
background: rgba(29, 34, 31, 0.65);
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 3px;
font-size: 11px;
letter-spacing: 0.035em;
pointer-events: none;
backdrop-filter: blur(7px);
}
.vignette {
position: fixed;
inset: 0;
z-index: 1;
pointer-events: none;
background:
linear-gradient(180deg, rgba(31, 36, 34, 0.08), transparent 23%),
radial-gradient(circle at 52% 45%, transparent 54%, rgba(34, 32, 27, 0.13));
}
@media (max-width: 650px) {
.caption {
top: 14px;
left: 14px;
padding: 11px 13px;
}
.caption p {
display: none;
}
.help {
right: 12px;
bottom: 12px;
font-size: 10px;
}
}
</style>
</head>
<body>
<div class="caption">
<small>Beirut · Gemmayzeh</small>
<h1>Triple Arch / Stone Stair</h1>
<p>Selected local reference study: arched window group and neighboring stair passage.</p>
</div>
<div class="help">Drag to orbit · Wheel to zoom · Shift-drag to pan · Double-click to reset</div>
<div class="vignette"></div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer, scene and camera
// ------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.03;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb9c9c9);
scene.fog = new THREE.Fog(0xb9c9c9, 19, 46);
const camera = new THREE.PerspectiveCamera(
48,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemi = new THREE.HemisphereLight(0xd8e7e8, 0x8b7354, 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffe1a9, 3.5);
sun.position.set(-8, 15, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -14;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 45;
sun.shadow.bias = -0.00015;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const bounce = new THREE.DirectionalLight(0x8ea6a2, 0.45);
bounce.position.set(9, 5, -8);
scene.add(bounce);
// ------------------------------------------------------------
// Materials and geometry helpers
// ------------------------------------------------------------
const material = {
wall: new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.94,
metalness: 0
}),
backing: new THREE.MeshStandardMaterial({
color: 0xae926e,
roughness: 1
}),
trim: new THREE.MeshStandardMaterial({
color: 0xd5b98a,
roughness: 0.88
}),
trimLight: new THREE.MeshStandardMaterial({
color: 0xe0c69a,
roughness: 0.86
}),
recess: new THREE.MeshStandardMaterial({
color: 0x18201e,
roughness: 0.98,
emissive: 0x030504,
emissiveIntensity: 0.25
}),
door: new THREE.MeshStandardMaterial({
color: 0x354039,
roughness: 0.83
}),
doorDark: new THREE.MeshStandardMaterial({
color: 0x202824,
roughness: 0.9
}),
metal: new THREE.MeshStandardMaterial({
color: 0x303a36,
roughness: 0.58,
metalness: 0.48
}),
paving: new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.96
}),
ground: new THREE.MeshStandardMaterial({
color: 0x817d72,
roughness: 1
}),
pot: new THREE.MeshStandardMaterial({
color: 0x9b6546,
roughness: 0.96
}),
leaf: new THREE.MeshStandardMaterial({
color: 0x4e6947,
roughness: 1,
flatShading: true
}),
leafLight: new THREE.MeshStandardMaterial({
color: 0x70865a,
roughness: 1,
flatShading: true
}),
trunk: new THREE.MeshStandardMaterial({
color: 0x65523b,
roughness: 1
})
};
const facade = new THREE.Group();
const stairs = new THREE.Group();
const details = new THREE.Group();
const greenery = new THREE.Group();
scene.add(facade, stairs, details, greenery);
function box(w, h, d, mat, x, y, z, parent = scene, cast = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinderBetween(a, b, radius, mat, parent = scene, segments = 8) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, segments),
mat
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
let randomSeed = 7301;
function random() {
randomSeed =
(randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
function stoneColor(base = 0xc5a578) {
return new THREE.Color(base).offsetHSL(
(random() - 0.5) * 0.012,
(random() - 0.5) * 0.035,
(random() - 0.5) * 0.095
);
}
function instanceBoxes(items, mat, parent) {
const geometry = new THREE.BoxGeometry(1, 1, 1);
const mesh = new THREE.InstancedMesh(geometry, mat, items.length);
const dummy = new THREE.Object3D();
items.forEach((item, index) => {
dummy.position.set(item.x, item.y, item.z);
dummy.scale.set(item.w, item.h, item.d);
dummy.rotation.set(0, item.ry || 0, item.rz || 0);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
mesh.setColorAt(index, item.color || new THREE.Color(0xffffff));
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function rectangleHole(x0, y0, x1, y1) {
const path = new THREE.Path();
path.moveTo(x0, y0);
path.lineTo(x1, y0);
path.lineTo(x1, y1);
path.lineTo(x0, y1);
path.closePath();
return path;
}
function archedHole(cx, bottom, spring, radius) {
const path = new THREE.Path();
path.moveTo(cx - radius, bottom);
path.lineTo(cx + radius, bottom);
path.lineTo(cx + radius, spring);
path.absarc(cx, spring, radius, 0, Math.PI, false);
path.lineTo(cx - radius, bottom);
path.closePath();
return path;
}
function archedShape(cx, bottom, spring, radius) {
const shape = new THREE.Shape();
shape.moveTo(cx - radius, bottom);
shape.lineTo(cx + radius, bottom);
shape.lineTo(cx + radius, spring);
shape.absarc(cx, spring, radius, 0, Math.PI, false);
shape.lineTo(cx - radius, bottom);
shape.closePath();
return shape;
}
// ------------------------------------------------------------
// Main facade: recessed masonry with real wall depth
// ------------------------------------------------------------
const facadeX0 = -6.3;
const facadeX1 = 4.8;
const facadeTop = 12.2;
const windowCenters = [-3.75, -1.75, 0.25];
const windowBottom = 6.1;
const windowSpring = 7.8;
const windowRadius = 0.7;
const doorX0 = 2.35;
const doorX1 = 4.05;
const doorBottom = 4.8;
const doorTop = 7.55;
const facadeShape = new THREE.Shape();
// Clockwise outer contour.
facadeShape.moveTo(facadeX0, 0);
facadeShape.lineTo(facadeX0, facadeTop);
facadeShape.lineTo(facadeX1, facadeTop);
facadeShape.lineTo(facadeX1, 0);
facadeShape.closePath();
for (const cx of windowCenters) {
facadeShape.holes.push(
archedHole(cx, windowBottom, windowSpring, windowRadius)
);
}
facadeShape.holes.push(
rectangleHole(doorX0, doorBottom, doorX1, doorTop)
);
const backingGeometry = new THREE.ExtrudeGeometry(facadeShape, {
depth: 0.72,
bevelEnabled: false,
curveSegments: 18,
steps: 1
});
backingGeometry.translate(0, 0, -0.72);
const backing = new THREE.Mesh(backingGeometry, material.backing);
backing.castShadow = true;
backing.receiveShadow = true;
facade.add(backing);
function isInsideOpening(x, y) {
if (
x > doorX0 && x < doorX1 &&
y > doorBottom && y < doorTop
) {
return true;
}
for (const cx of windowCenters) {
if (
x > cx - windowRadius &&
x < cx + windowRadius &&
y > windowBottom &&
y <= windowSpring
) {
return true;
}
const dy = y - windowSpring;
const dx = x - cx;
if (
y > windowSpring &&
dy <= windowRadius &&
dx * dx + dy * dy < windowRadius * windowRadius
) {
return true;
}
}
return false;
}
const masonry = [];
const blockWidth = 0.88;
const blockHeight = 0.58;
const blockDepth = 0.82;
for (let row = 0; row < 21; row++) {
const y = (row + 0.5) * blockHeight;
const offset = row % 2 ? blockWidth * 0.5 : 0;
for (
let x = facadeX0 - offset;
x < facadeX1;
x += blockWidth
) {
const left = Math.max(x, facadeX0);
const right = Math.min(x + blockWidth, facadeX1);
const cx = (left + right) * 0.5;
if (right <= left) continue;
if (isInsideOpening(cx, y)) continue;
masonry.push({
x: cx,
y,
z: 0.04 + (random() - 0.5) * 0.025,
w: right - left - 0.025,
h: blockHeight - 0.025,
d: blockDepth,
color: stoneColor()
});
}
}
instanceBoxes(masonry, material.wall, facade);
// ------------------------------------------------------------
// Neighbor wall: stepped roofline behind the stair passage
// ------------------------------------------------------------
const neighborShape = new THREE.Shape();
neighborShape.moveTo(4.84, 0);
neighborShape.lineTo(10.38, 0);
neighborShape.lineTo(10.38, 8.35);
neighborShape.lineTo(9.78, 8.35);
neighborShape.lineTo(9.78, 8.75);
neighborShape.lineTo(9.18, 8.75);
neighborShape.lineTo(9.18, 9.15);
neighborShape.lineTo(8.58, 9.15);
neighborShape.lineTo(8.58, 9.55);
neighborShape.lineTo(7.98, 9.55);
neighborShape.lineTo(7.98, 9.95);
neighborShape.lineTo(7.38, 9.95);
neighborShape.lineTo(7.38, 10.35);
neighborShape.lineTo(4.84, 10.35);
neighborShape.closePath();
const neighborBackingGeometry = new THREE.ExtrudeGeometry(
neighborShape,
{
depth: 0.65,
bevelEnabled: false,
steps: 1
}
);
neighborBackingGeometry.translate(0, 0, -0.65);
const neighborBacking = new THREE.Mesh(
neighborBackingGeometry,
material.backing
);
neighborBacking.castShadow = true;
neighborBacking.receiveShadow = true;
facade.add(neighborBacking);
function neighborTopAt(x) {
if (x < 7.38) return 10.35;
if (x < 7.98) return 9.95;
if (x < 8.58) return 9.55;
if (x < 9.18) return 9.15;
if (x < 9.78) return 8.75;
return 8.35;
}
const neighborMasonry = [];
for (let row = 0; row < 18; row++) {
const y = (row + 0.5) * blockHeight;
const offset = row % 2 ? blockWidth * 0.5 : 0;
for (
let x = 4.84 - offset;
x < 10.38;
x += blockWidth
) {
const left = Math.max(x, 4.84);
const right = Math.min(x + blockWidth, 10.38);
const cx = (left + right) * 0.5;
if (right <= left) continue;
if (y > neighborTopAt(cx)) continue;
neighborMasonry.push({
x: cx,
y,
z: 0.025,
w: right - left - 0.025,
h: blockHeight - 0.025,
d: 0.8,
color: stoneColor(0xbca47d)
});
}
}
instanceBoxes(neighborMasonry, material.wall, facade);
// Facade cornice.
box(
11.48,
0.28,
1.08,
material.trim,
-0.75,
12.0,
0.55,
facade
);
box(
11.25,
0.16,
0.94,
material.trimLight,
-0.75,
11.73,
0.49,
facade
);
// ------------------------------------------------------------
// Triple arched window group
// ------------------------------------------------------------
for (const cx of windowCenters) {
// Dark recess set behind the projecting masonry face.
const recessGeometry = new THREE.ShapeGeometry(
archedShape(
cx,
windowBottom,
windowSpring,
windowRadius
),
18
);
const recess = new THREE.Mesh(recessGeometry, material.recess);
recess.position.z = -0.025;
recess.receiveShadow = true;
details.add(recess);
// Vertical jambs.
for (const side of [-1, 1]) {
box(
0.25,
windowSpring - windowBottom + 0.2,
0.3,
material.trim,
cx + side * (windowRadius + 0.06),
(windowBottom + windowSpring) * 0.5,
0.58,
details
);
}
// Individually modeled radial arch stones.
const stoneCount = 9;
for (let i = 0; i < stoneCount; i++) {
const angle =
(i + 0.5) / stoneCount * Math.PI;
const radius = windowRadius + 0.11;
box(
0.3,
0.43,
0.3,
i % 2 ? material.trimLight : material.trim,
cx + Math.cos(angle) * radius,
windowSpring + Math.sin(angle) * radius,
0.58,
details,
true
).rotation.z = angle - Math.PI * 0.5;
}
// Sill and shallow glazing bars.
box(
windowRadius * 2 + 0.55,
0.17,
0.45,
material.trimLight,
cx,
windowBottom - 0.06,
0.61,
details
);
box(
0.055,
windowSpring - windowBottom + 0.04,
0.055,
material.metal,
cx,
(windowBottom + windowSpring) * 0.5,
0.095,
details,
false
);
box(
windowRadius * 1.82,
0.045,
0.045,
material.metal,
cx,
windowBottom + 0.78,
0.1,
details,
false
);
}
// Continuous sill visually binds the three openings.
box(
6.25,
0.16,
0.4,
material.trim,
-1.75,
windowBottom - 0.22,
0.55,
details
);
// ------------------------------------------------------------
// The single doorway and its raised threshold
// ------------------------------------------------------------
const doorCenter = (doorX0 + doorX1) * 0.5;
// Deep dark reveal behind the door.
box(
doorX1 - doorX0 + 0.04,
doorTop - doorBottom,
0.08,
material.recess,
doorCenter,
(doorBottom + doorTop) * 0.5,
-0.48,
details,
false
);
// Recessed wooden door.
box(
1.48,
2.62,
0.12,
material.door,
doorCenter,
doorBottom + 1.33,
-0.25,
details
);
// Subtle vertical boards.
for (const offset of [-0.48, -0.24, 0, 0.24, 0.48]) {
box(
0.025,
2.48,
0.025,
material.doorDark,
doorCenter + offset,
doorBottom + 1.33,
-0.175,
details,
false
);
}
box(
1.23,
0.9,
0.025,
material.doorDark,
doorCenter,
doorBottom + 1.95,
-0.17,
details,
false
);
box(
1.23,
0.9,
0.025,
material.doorDark,
doorCenter,
doorBottom + 0.64,
-0.17,
details,
false
);
// Door frame and lintel.
for (const x of [doorX0 - 0.1, doorX1 + 0.1]) {
box(
0.25,
doorTop - doorBottom + 0.15,
0.35,
material.trim,
x,
(doorBottom + doorTop) * 0.5,
0.58,
details
);
}
box(
2.05,
0.25,
0.38,
material.trimLight,
doorCenter,
doorTop + 0.08,
0.58,
details
);
// Handle.
box(
0.07,
0.07,
0.12,
material.metal,
doorCenter + 0.47,
doorBottom + 1.23,
-0.09,
details,
false
);
// Threshold physically meets the landing and doorway.
box(
1.75,
0.14,
1.0,
material.trimLight,
doorCenter,
4.73,
0.22,
details
);
// ------------------------------------------------------------
// Stone stair passage and landing
// ------------------------------------------------------------
const stairCount = 16;
const stairRise = 0.3;
const stairRun = 0.34;
const stairBottomX = 10.0;
const stairWidth = 2.55;
const stairZ = 1.72;
const stairBlocks = [];
for (let i = 0; i < stairCount; i++) {
const right = stairBottomX - i * stairRun;
const left = right - stairRun;
const top = (i + 1) * stairRise;
stairBlocks.push({
x: (left + right) * 0.5,
y: top * 0.5,
z: stairZ,
w: stairRun + 0.006,
h: top,
d: stairWidth,
color: stoneColor(0xc1a273)
});
}
instanceBoxes(stairBlocks, material.wall, stairs);
// Small raised landing: its top is exactly the doorway threshold.
box(
3.12,
0.26,
2.65,
material.trim,
3.68,
4.67,
1.72,
stairs
);
box(
3.02,
0.055,
2.55,
material.trimLight,
3.68,
4.78,
1.72,
stairs
);
// Visible support brackets make the landing's vertical connection clear.
box(
0.38,
0.78,
0.8,
material.trim,
2.55,
4.24,
0.83,
stairs
);
box(
0.38,
0.78,
0.8,
material.trim,
4.55,
4.24,
0.83,
stairs
);
// Landing outer edge.
box(
3.1,
0.13,
0.13,
material.trimLight,
3.68,
4.73,
3.07,
stairs
);
// ------------------------------------------------------------
// Railing along the open side of the stair
// ------------------------------------------------------------
const railingZ = 3.13;
const railStart = [9.84, 1.31, railingZ];
const railEnd = [4.65, 5.81, railingZ];
cylinderBetween(
railStart,
railEnd,
0.047,
material.metal,
details
);
const postPositions = [9.84, 9.0, 8.16, 7.32, 6.48, 5.64, 4.72];
for (const x of postPositions) {
const stairIndex = Math.min(
stairCount - 1,
Math.max(0, Math.floor((stairBottomX - x) / stairRun))
);
const baseY = (stairIndex + 1) * stairRise;
cylinderBetween(
[x, baseY, railingZ],
[x, baseY + 1.0, railingZ],
0.035,
material.metal,
details
);
}
// Rail continues across the landing's open front edge.
cylinderBetween(
[4.66, 5.81, railingZ],
[2.25, 5.81, railingZ],
0.047,
material.metal,
details
);
cylinderBetween(
[2.25, 4.8, railingZ],
[2.25, 5.81, railingZ],
0.035,
material.metal,
details
);
// ------------------------------------------------------------
// Narrow pavement strip
// ------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(70, 70),
material.ground
);
ground.rotation.x = -Math.PI * 0.5;
ground.position.y = -0.035;
ground.receiveShadow = true;
scene.add(ground);
const pavers = [];
const pavementX0 = -6.85;
const pavementX1 = 10.65;
const paverWidth = 0.86;
const paverDepth = 0.7;
for (let row = 0; row < 4; row++) {
const z = 0.78 + row * paverDepth;
const offset = row % 2 ? paverWidth * 0.5 : 0;
for (
let x = pavementX0 - offset;
x < pavementX1;
x += paverWidth
) {
const left = Math.max(x, pavementX0);
const right = Math.min(x + paverWidth, pavementX1);
if (right <= left) continue;
pavers.push({
x: (left + right) * 0.5,
y: 0.018,
z,
w: right - left - 0.035,
h: 0.065,
d: paverDepth - 0.035,
color: stoneColor(0x9b9484)
});
}
}
instanceBoxes(pavers, material.paving, details);
// ------------------------------------------------------------
// Restrained greenery
// ------------------------------------------------------------
function makePlanter(x, z, scale = 1) {
box(
1.0 * scale,
0.5 * scale,
0.78 * scale,
material.pot,
x,
0.27 * scale,
z,
greenery
);
box(
0.78 * scale,
0.08 * scale,
0.58 * scale,
material.trunk,
x,
0.53 * scale,
z,
greenery
);
const clusters = [
[-0.25, 0.9, 0.02, 0.48],
[0.18, 1.04, -0.04, 0.53],
[0.39, 0.82, 0.08, 0.38],
[0.01, 1.38, 0.03, 0.37]
];
clusters.forEach((cluster, index) => {
const leaf = new THREE.Mesh(
new THREE.IcosahedronGeometry(cluster[3] * scale, 1),
index % 2 ? material.leaf : material.leafLight
);
leaf.position.set(
x + cluster[0] * scale,
cluster[1] * scale,
z + cluster[2] * scale
);
leaf.scale.set(1, 0.86, 0.92);
leaf.rotation.set(random(), random(), random());
leaf.castShadow = true;
leaf.receiveShadow = true;
greenery.add(leaf);
});
}
makePlanter(-5.2, 3.05, 1.0);
const smallPot = new THREE.Mesh(
new THREE.CylinderGeometry(0.32, 0.42, 0.48, 8),
material.pot
);
smallPot.position.set(9.85, 0.25, 3.2);
smallPot.castShadow = true;
smallPot.receiveShadow = true;
greenery.add(smallPot);
const shrub = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.55, 1),
material.leaf
);
shrub.position.set(9.85, 0.88, 3.2);
shrub.scale.set(0.9, 1.15, 0.9);
shrub.castShadow = true;
greenery.add(shrub);
// A few ivy stones climbing the lower facade edge.
for (let i = 0; i < 7; i++) {
const leaf = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.18 + random() * 0.09, 0),
i % 2 ? material.leaf : material.leafLight
);
leaf.position.set(
facadeX0 + 0.15 + random() * 0.65,
0.25 + i * 0.19,
0.54
);
leaf.rotation.set(random(), random(), random());
leaf.castShadow = true;
greenery.add(leaf);
}
// ------------------------------------------------------------
// Direct camera controls — no external addons
// ------------------------------------------------------------
const controls = {
target: new THREE.Vector3(-0.8, 5.4, 0.1),
spherical: new THREE.Spherical(13.8, 1.78, 1.03),
minRadius: 6.2,
maxRadius: 24,
minPhi: 0.55,
maxPhi: 1.86
};
function updateCamera() {
controls.spherical.phi = THREE.MathUtils.clamp(
controls.spherical.phi,
controls.minPhi,
controls.maxPhi
);
controls.spherical.radius = THREE.MathUtils.clamp(
controls.spherical.radius,
controls.minRadius,
controls.maxRadius
);
const offset = new THREE.Vector3().setFromSpherical(
controls.spherical
);
camera.position.copy(controls.target).add(offset);
camera.lookAt(controls.target);
}
function resetCamera() {
controls.target.set(-0.8, 5.4, 0.1);
controls.spherical.set(13.8, 1.78, 1.03);
updateCamera();
}
let pointerDown = false;
let shiftDown = false;
let previousX = 0;
let previousY = 0;
let activePointer = null;
const pointer = new THREE.Vector2();
const panRight = new THREE.Vector3();
const panUp = new THREE.Vector3();
renderer.domElement.addEventListener("pointerdown", event => {
pointerDown = true;
activePointer = event.pointerId;
previousX = event.clientX;
previousY = event.clientY;
shiftDown = event.shiftKey;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointerDown || event.pointerId !== activePointer) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
if (shiftDown) {
camera.getWorldDirection(pointer);
panRight.crossVectors(pointer, camera.up).normalize();
panUp.crossVectors(panRight, pointer).normalize();
const panScale = controls.spherical.radius * 0.0013;
controls.target.addScaledVector(panRight, -dx * panScale);
controls.target.addScaledVector(panUp, dy * panScale);
controls.target.x = THREE.MathUtils.clamp(
controls.target.x,
-7,
8
);
controls.target.y = THREE.MathUtils.clamp(
controls.target.y,
1.5,
10.5
);
controls.target.z = THREE.MathUtils.clamp(
controls.target.z,
-1,
4
);
} else {
controls.spherical.theta -= dx * 0.005;
controls.spherical.phi -= dy * 0.0045;
}
updateCamera();
});
function endPointer(event) {
if (event.pointerId !== activePointer) return;
pointerDown = false;
activePointer = null;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
controls.spherical.radius *= Math.exp(
event.deltaY * 0.001
);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", event => {
if (event.key.toLowerCase() === "r") resetCamera();
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
resetCamera();
renderer.render(scene, camera);
</script>
</body>
</html>
```