Prompt specification
Build or customize the Three.js 3D scene "Windmill sail frame facing an arrow" 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: Windmill sail frame facing an arrow
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/windmill-sail-frame-facing-an-arrow-x2557
Scene Description Prompt:
Build one traditional windmill sail frame beside a fixed wind-direction arrow. Show its rotation plane and distinguish wind direction from the direction of shaft rotation. Build this with Three.js from cdnjs as a stylized scene in one self-contained HTML file.
Working Three.js Starter (windmill-sail-frame-facing-an-arrow-x2557):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Traditional Windmill Sail Frame</title>
<style>
:root {
--ink: #283238;
--muted: #667176;
--paper: #f4efe3;
--blue: #1689b5;
--orange: #e87932;
--plane: #8b9699;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--paper);
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;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
header {
position: fixed;
z-index: 5;
top: 26px;
left: 30px;
max-width: 470px;
pointer-events: none;
}
.eyebrow {
margin-bottom: 8px;
color: var(--blue);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 3.2vw, 48px);
font-weight: 500;
line-height: 1.02;
letter-spacing: -0.025em;
}
header p {
max-width: 420px;
margin: 12px 0 0;
color: var(--muted);
font-size: 14px;
line-height: 1.5;
}
.legend {
position: fixed;
z-index: 5;
right: 26px;
bottom: 26px;
width: min(340px, calc(100vw - 52px));
padding: 18px 20px;
border: 1px solid rgba(40, 50, 56, 0.13);
border-radius: 16px;
background: rgba(250, 247, 239, 0.88);
box-shadow: 0 14px 45px rgba(45, 48, 43, 0.12);
backdrop-filter: blur(12px);
}
.legend-title {
margin-bottom: 13px;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.legend-row {
display: grid;
grid-template-columns: 32px 1fr;
gap: 10px;
align-items: start;
margin-top: 11px;
}
.symbol {
position: relative;
width: 30px;
height: 22px;
margin-top: 1px;
}
.symbol.wind::before {
content: "";
position: absolute;
top: 10px;
left: 1px;
width: 23px;
height: 2px;
background: var(--blue);
}
.symbol.wind::after {
content: "";
position: absolute;
top: 5px;
right: 0;
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-left: 9px solid var(--blue);
}
.symbol.rotation::before {
content: "";
position: absolute;
inset: 3px 2px;
border: 2px solid var(--orange);
border-right-color: transparent;
border-radius: 50%;
transform: rotate(-25deg);
}
.symbol.rotation::after {
content: "";
position: absolute;
right: 1px;
top: 4px;
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
border-left: 7px solid var(--orange);
transform: rotate(-18deg);
}
.symbol.plane::before {
content: "";
position: absolute;
left: 2px;
right: 2px;
top: 4px;
height: 14px;
border: 1px solid var(--plane);
border-radius: 50%;
background: rgba(139, 150, 153, 0.18);
transform: rotate(-12deg);
}
.legend strong {
display: block;
margin-bottom: 3px;
font-size: 13px;
}
.legend small {
display: block;
color: var(--muted);
font-size: 12px;
line-height: 1.4;
}
.controls-note {
position: fixed;
z-index: 5;
bottom: 30px;
left: 30px;
color: rgba(40, 50, 56, 0.6);
font-size: 11px;
letter-spacing: 0.04em;
pointer-events: none;
}
#reset {
position: fixed;
z-index: 6;
left: 26px;
top: 25px;
display: none;
border: 1px solid rgba(40, 50, 56, 0.16);
border-radius: 999px;
padding: 8px 12px;
background: rgba(250, 247, 239, 0.85);
color: var(--ink);
font: inherit;
font-size: 12px;
cursor: pointer;
}
.scene-label {
position: fixed;
z-index: 4;
transform: translate(-50%, -50%);
padding: 7px 11px;
border: 1px solid rgba(40, 50, 56, 0.12);
border-radius: 999px;
background: rgba(250, 247, 239, 0.9);
box-shadow: 0 7px 22px rgba(44, 48, 44, 0.1);
color: var(--ink);
font-size: 11px;
font-weight: 750;
line-height: 1.25;
white-space: nowrap;
pointer-events: none;
backdrop-filter: blur(7px);
}
.scene-label small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 9px;
font-weight: 650;
letter-spacing: 0.04em;
text-transform: uppercase;
}
#wind-label {
border-color: rgba(22, 137, 181, 0.35);
color: #0b6f96;
}
#rotation-label {
border-color: rgba(232, 121, 50, 0.38);
color: #b8531e;
}
@media (max-width: 720px) {
header {
top: 18px;
left: 18px;
right: 18px;
}
header p {
display: none;
}
.legend {
right: 14px;
bottom: 14px;
width: 270px;
padding: 14px 16px;
}
.controls-note {
display: none;
}
.scene-label {
padding: 5px 8px;
font-size: 9px;
}
.scene-label small {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive three-dimensional windmill diagram"></canvas>
<header>
<div class="eyebrow">Mechanics of a traditional windmill</div>
<h1>Wind direction is not rotation direction.</h1>
<p>
The blue arrow shows fixed wind traveling along the shaft axis.
The orange arrow shows the shaft rotating around that axis inside
the translucent sail plane.
</p>
</header>
<div class="legend">
<div class="legend-title">Reading the diagram</div>
<div class="legend-row">
<div class="symbol wind"></div>
<div>
<strong>Fixed wind</strong>
<small>Straight and axial, parallel to the shaft and normal to the sail plane.</small>
</div>
</div>
<div class="legend-row">
<div class="symbol rotation"></div>
<div>
<strong>Shaft rotation</strong>
<small>Circular and tangential, around the hub within the sail plane.</small>
</div>
</div>
<div class="legend-row">
<div class="symbol plane"></div>
<div>
<strong>Rotor plane</strong>
<small>The translucent disc contains the four traditional lattice sails.</small>
</div>
</div>
</div>
<div class="controls-note">Drag to orbit · Scroll to zoom</div>
<button id="reset" type="button">Reset view</button>
<div id="wind-label" class="scene-label">
Fixed wind
<small>Along shaft axis</small>
</div>
<div id="rotation-label" class="scene-label">
Shaft rotation
<small>Clockwise from windward side</small>
</div>
<div id="plane-label" class="scene-label">
Rotor / shaft plane
<small>Perpendicular to wind</small>
</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.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xeee8db);
scene.fog = new THREE.Fog(0xeee8db, 15, 31);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const orbit = {
target: new THREE.Vector3(0.15, 3.05, -0.15),
radius: 12.8,
theta: 0.62,
phi: 1.18
};
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
}
updateCamera();
// Lighting and atmosphere.
scene.add(new THREE.HemisphereLight(0xfff7e8, 0x7f8b83, 2.25));
const sun = new THREE.DirectionalLight(0xffe5bc, 3.2);
sun.position.set(6, 11, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -10;
sun.shadow.camera.right = 10;
sun.shadow.camera.top = 11;
sun.shadow.camera.bottom = -4;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 30;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x91c6df, 1.15);
fill.position.set(-7, 5, -5);
scene.add(fill);
// Materials.
const woodDark = new THREE.MeshStandardMaterial({
color: 0x5e3f2c,
roughness: 0.78,
metalness: 0.02
});
const wood = new THREE.MeshStandardMaterial({
color: 0x9b6941,
roughness: 0.72,
metalness: 0.02
});
const woodLight = new THREE.MeshStandardMaterial({
color: 0xc28b58,
roughness: 0.68,
metalness: 0.02
});
const brass = new THREE.MeshStandardMaterial({
color: 0xb9903f,
roughness: 0.34,
metalness: 0.68
});
const iron = new THREE.MeshStandardMaterial({
color: 0x394449,
roughness: 0.55,
metalness: 0.55
});
const stone = new THREE.MeshStandardMaterial({
color: 0xc8b99e,
roughness: 0.95
});
const canvasCloth = new THREE.MeshStandardMaterial({
color: 0xeee3c8,
roughness: 0.95,
transparent: true,
opacity: 0.27,
side: THREE.DoubleSide,
depthWrite: false
});
const windBlue = new THREE.MeshStandardMaterial({
color: 0x1689b5,
emissive: 0x073d50,
emissiveIntensity: 0.22,
roughness: 0.4,
metalness: 0.08
});
const rotationOrange = new THREE.MeshStandardMaterial({
color: 0xe87932,
emissive: 0x6b2408,
emissiveIntensity: 0.18,
roughness: 0.4,
metalness: 0.05
});
const planeMaterial = new THREE.MeshBasicMaterial({
color: 0x829195,
transparent: true,
opacity: 0.095,
side: THREE.DoubleSide,
depthWrite: false
});
const planeEdgeMaterial = new THREE.MeshBasicMaterial({
color: 0x66767b,
transparent: true,
opacity: 0.52,
depthWrite: false
});
// Helpers.
function mesh(geometry, material, castShadow = true, receiveShadow = true) {
const object = new THREE.Mesh(geometry, material);
object.castShadow = castShadow;
object.receiveShadow = receiveShadow;
return object;
}
function beamBetween(start, end, width, depth, material) {
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const midpoint = new THREE.Vector3()
.addVectors(start, end)
.multiplyScalar(0.5);
const object = mesh(
new THREE.BoxGeometry(width, length, depth),
material
);
object.position.copy(midpoint);
object.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return object;
}
function cylinderBetween(start, end, radius, material, radialSegments = 18) {
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const midpoint = new THREE.Vector3()
.addVectors(start, end)
.multiplyScalar(0.5);
const object = mesh(
new THREE.CylinderGeometry(radius, radius, length, radialSegments),
material
);
object.position.copy(midpoint);
object.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return object;
}
// Ground and compact display platform.
const ground = mesh(
new THREE.PlaneGeometry(60, 60),
new THREE.MeshStandardMaterial({
color: 0xe1d8c7,
roughness: 1
}),
false,
true
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.02;
scene.add(ground);
const platform = mesh(
new THREE.CylinderGeometry(3.1, 3.35, 0.22, 64),
stone
);
platform.position.set(0, 0.09, -0.35);
scene.add(platform);
const platformTop = mesh(
new THREE.CylinderGeometry(2.92, 2.92, 0.025, 64),
new THREE.MeshStandardMaterial({
color: 0xd9cdb6,
roughness: 0.95
}),
false,
true
);
platformTop.position.set(0, 0.215, -0.35);
scene.add(platformTop);
// A simplified windmill body behind the exposed rotor.
const tower = mesh(
new THREE.CylinderGeometry(0.63, 1.02, 3.25, 10),
stone
);
tower.position.set(0, 1.84, -1.42);
scene.add(tower);
const towerBand = mesh(
new THREE.TorusGeometry(0.68, 0.065, 10, 36),
woodDark
);
towerBand.rotation.x = Math.PI / 2;
towerBand.position.set(0, 3.3, -1.42);
scene.add(towerBand);
const door = mesh(
new THREE.BoxGeometry(0.48, 0.94, 0.08),
woodDark
);
door.position.set(0, 0.77, -0.38);
scene.add(door);
// Main world coordinates.
const rotorCenter = new THREE.Vector3(0, 3.65, 0);
// Fixed shaft, running along the world Z axis.
const shaftStart = new THREE.Vector3(0, 3.65, 1.18);
const shaftEnd = new THREE.Vector3(0, 3.65, -2.4);
scene.add(
cylinderBetween(shaftStart, shaftEnd, 0.105, iron, 24)
);
// Bearing collar behind the rotor.
const bearing = mesh(
new THREE.TorusGeometry(0.25, 0.09, 14, 40),
iron
);
bearing.position.set(0, 3.65, -0.76);
scene.add(bearing);
// Translucent rotor plane.
const plane = mesh(
new THREE.CircleGeometry(3.42, 96),
planeMaterial,
false,
false
);
plane.position.copy(rotorCenter);
plane.position.z = -0.075;
scene.add(plane);
const planeEdge = mesh(
new THREE.TorusGeometry(3.42, 0.018, 8, 128),
planeEdgeMaterial,
false,
false
);
planeEdge.position.copy(rotorCenter);
planeEdge.position.z = 0.225;
scene.add(planeEdge);
// Animated four-sail traditional rotor.
const rotor = new THREE.Group();
rotor.position.copy(rotorCenter);
rotor.rotation.z = 0.12;
scene.add(rotor);
const hub = mesh(
new THREE.CylinderGeometry(0.38, 0.38, 0.46, 36),
brass
);
hub.rotation.x = Math.PI / 2;
hub.position.z = 0.08;
rotor.add(hub);
const hubCap = mesh(
new THREE.CylinderGeometry(0.22, 0.22, 0.52, 30),
iron
);
hubCap.rotation.x = Math.PI / 2;
hubCap.position.z = 0.11;
rotor.add(hubCap);
function addSail(angle) {
const sail = new THREE.Group();
sail.rotation.z = angle;
// Subtle cloth behind the open lattice.
const fabric = mesh(
new THREE.PlaneGeometry(2.25, 1.16),
canvasCloth,
false,
false
);
fabric.position.set(2.075, 0, -0.055);
sail.add(fabric);
// Main radial stock.
sail.add(
beamBetween(
new THREE.Vector3(0.32, 0, 0.07),
new THREE.Vector3(3.3, 0, 0.07),
0.15,
0.16,
woodDark
)
);
// Inner and outer rails.
sail.add(
beamBetween(
new THREE.Vector3(0.95, -0.58, 0.07),
new THREE.Vector3(0.95, 0.58, 0.07),
0.105,
0.14,
woodLight
)
);
sail.add(
beamBetween(
new THREE.Vector3(3.2, -0.62, 0.07),
new THREE.Vector3(3.2, 0.62, 0.07),
0.12,
0.16,
woodLight
)
);
// Side rails.
sail.add(
beamBetween(
new THREE.Vector3(0.95, -0.58, 0.07),
new THREE.Vector3(3.2, -0.58, 0.07),
0.105,
0.14,
wood
)
);
sail.add(
beamBetween(
new THREE.Vector3(0.95, 0.58, 0.07),
new THREE.Vector3(3.2, 0.58, 0.07),
0.105,
0.14,
wood
)
);
// Alternating diagonal lattice strips.
const strips = 7;
const step = 2.25 / strips;
for (let i = 0; i < strips; i++) {
const x0 = 0.95 + i * step;
const x1 = x0 + step;
const a = new THREE.Vector3(
x0,
i % 2 === 0 ? -0.58 : 0.58,
0.075
);
const b = new THREE.Vector3(
x1,
i % 2 === 0 ? 0.58 : -0.58,
0.075
);
sail.add(
beamBetween(a, b, 0.055, 0.09, woodLight)
);
}
rotor.add(sail);
}
[0, Math.PI / 2, Math.PI, Math.PI * 1.5].forEach(addSail);
// Fixed straight wind arrow: +Z toward -Z, parallel to the shaft.
const windStart = new THREE.Vector3(4.95, 2.75, 4.15);
const windEnd = new THREE.Vector3(4.95, 2.75, -0.45);
const windDirection = new THREE.Vector3()
.subVectors(windEnd, windStart)
.normalize();
const windShaftEnd = windEnd.clone().addScaledVector(
windDirection,
-0.42
);
scene.add(
cylinderBetween(
windStart,
windShaftEnd,
0.065,
windBlue,
20
)
);
const windHead = mesh(
new THREE.ConeGeometry(0.23, 0.55, 24),
windBlue
);
windHead.position.copy(windEnd);
windHead.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
windDirection
);
scene.add(windHead);
// Small rear collar visually anchors the blue arrow to the scene.
const windTail = mesh(
new THREE.TorusGeometry(0.12, 0.035, 10, 28),
windBlue
);
windTail.position.copy(windStart);
windTail.rotation.y = Math.PI / 2;
scene.add(windTail);
// Curved orange arrow showing angular shaft rotation.
// Decreasing theta means clockwise when viewed from the windward +Z side.
const arcRadius = 3.56;
const arcPoints = [];
const arcStart = 0.48;
const arcEnd = -5.15;
for (let i = 0; i <= 72; i++) {
const theta = THREE.MathUtils.lerp(
arcStart,
arcEnd,
i / 72
);
arcPoints.push(
new THREE.Vector3(
rotorCenter.x + Math.cos(theta) * arcRadius,
rotorCenter.y + Math.sin(theta) * arcRadius,
0.34
)
);
}
const arcCurve = new THREE.CatmullRomCurve3(arcPoints);
const arc = mesh(
new THREE.TubeGeometry(arcCurve, 100, 0.047, 10, false),
rotationOrange
);
scene.add(arc);
const endTheta = arcEnd;
const tangent = new THREE.Vector3(
Math.sin(endTheta),
-Math.cos(endTheta),
0
).normalize();
const rotationHead = mesh(
new THREE.ConeGeometry(0.18, 0.48, 20),
rotationOrange
);
rotationHead.position.copy(arcPoints[arcPoints.length - 1]);
rotationHead.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
tangent
);
scene.add(rotationHead);
// Dashed shaft-axis guide.
const axisGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(0, 3.65, 1.45),
new THREE.Vector3(0, 3.65, -2.55)
]);
const axis = new THREE.Line(
axisGeometry,
new THREE.LineDashedMaterial({
color: 0x738287,
dashSize: 0.16,
gapSize: 0.11,
transparent: true,
opacity: 0.55
})
);
axis.computeLineDistances();
scene.add(axis);
// Projected HTML labels.
const labels = [
{
element: document.getElementById("wind-label"),
position: new THREE.Vector3(5.0, 3.05, 2.45)
},
{
element: document.getElementById("rotation-label"),
position: new THREE.Vector3(2.5, 6.95, 0.25)
},
{
element: document.getElementById("plane-label"),
position: new THREE.Vector3(-2.45, 6.65, -0.05)
}
];
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labels) {
const projected = label.position.clone().project(camera);
if (projected.z < -1 || projected.z > 1) {
label.element.style.display = "none";
continue;
}
label.element.style.display = "block";
label.element.style.left =
`${(projected.x * 0.5 + 0.5) * width}px`;
label.element.style.top =
`${(-projected.y * 0.5 + 0.5) * height}px`;
}
}
// Camera controls implemented directly, without external addons.
let dragging = false;
let previousX = 0;
let previousY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
orbit.theta -= deltaX * 0.006;
orbit.phi = THREE.MathUtils.clamp(
orbit.phi + deltaY * 0.005,
0.65,
1.45
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined) {
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.008,
8.3,
18
);
updateCamera();
},
{ passive: false }
);
document.getElementById("reset").addEventListener("click", () => {
orbit.radius = 12.8;
orbit.theta = 0.62;
orbit.phi = 1.18;
updateCamera();
});
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();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
// Negative Z rotation is clockwise when viewed from the windward +Z side.
rotor.rotation.z -= delta * 0.24;
updateLabels();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```