Prompt specification
Build or customize the Three.js 3D scene "Rotating Motif Floor Strip" 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: Rotating Motif Floor Strip
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/rotating-motif-floor-strip-x3306
Scene Description Prompt:
Animate a voxel floor motif repeating through translations and quarter turns, with neighboring tiles fitting cleanly. Three.js from cdnjs, one HTML file.
Working Three.js Starter (rotating-motif-floor-strip-x3306):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Quarter Field — Voxel Tessellation</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: #050914;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.hud {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
color: #eafcff;
}
.title-block {
position: absolute;
top: clamp(22px, 5vw, 58px);
left: clamp(22px, 5vw, 64px);
max-width: 360px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 16px;
color: #6de8e0;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.24em;
text-transform: uppercase;
}
.eyebrow::before {
width: 28px;
height: 1px;
background: currentColor;
content: "";
box-shadow: 0 0 12px currentColor;
}
h1 {
margin: 0;
font-size: clamp(42px, 7vw, 88px);
font-weight: 800;
letter-spacing: -0.075em;
line-height: 0.78;
text-transform: uppercase;
}
h1 span {
color: transparent;
-webkit-text-stroke: 1px rgba(220, 253, 255, 0.75);
}
.description {
max-width: 290px;
margin: 24px 0 0;
color: rgba(221, 239, 247, 0.6);
font-size: 12px;
line-height: 1.65;
letter-spacing: 0.03em;
}
.readout {
position: absolute;
right: clamp(20px, 4vw, 52px);
bottom: clamp(20px, 4vw, 44px);
display: grid;
grid-template-columns: auto auto;
gap: 6px 24px;
padding: 14px 17px;
border: 1px solid rgba(135, 226, 226, 0.16);
border-radius: 10px;
background: rgba(5, 12, 23, 0.54);
backdrop-filter: blur(12px);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.readout span {
color: rgba(202, 231, 239, 0.45);
}
.readout b {
color: #79eee4;
font-weight: 600;
text-align: right;
}
.controls {
position: absolute;
left: clamp(22px, 5vw, 64px);
bottom: clamp(22px, 4vw, 44px);
color: rgba(202, 231, 239, 0.38);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.controls strong {
color: rgba(234, 252, 255, 0.72);
font-weight: 600;
}
.vignette {
position: fixed;
inset: 0;
z-index: 1;
pointer-events: none;
background:
radial-gradient(circle at 50% 48%, transparent 42%, rgba(1, 4, 10, 0.4) 100%),
linear-gradient(180deg, rgba(2, 5, 12, 0.25), transparent 22%, transparent 78%, rgba(2, 5, 12, 0.45));
}
@media (max-width: 700px) {
.description {
display: none;
}
.readout {
grid-template-columns: auto;
gap: 3px;
}
.readout b {
text-align: left;
}
}
</style>
</head>
<body>
<div class="hud">
<div class="title-block">
<div class="eyebrow">Procedural voxel study</div>
<h1>Quarter<br /><span>Field</span></h1>
<p class="description">
A flush-edged voxel tessellation. A diagonal phase translates across the
floor while each embedded labyrinth resolves through ninety-degree turns.
</p>
</div>
<div class="controls">
<strong>Drag</strong> orbit ·
<strong>Scroll</strong> zoom ·
<strong>Double-click</strong> reset
</div>
<div class="readout">
<span>Formation</span><b>5 × 5 tiles</b>
<span>Cell grid</span><b>30 × 30</b>
<span>Transform</span><b>Translate + 90°</b>
</div>
</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 and scene
// ------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
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.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x050914);
scene.fog = new THREE.Fog(0x050914, 18, 48);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
150
);
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0x78bfff, 0x060810, 1.35);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 2.5);
keyLight.position.set(8, 16, 10);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -20;
keyLight.shadow.camera.right = 20;
keyLight.shadow.camera.top = 20;
keyLight.shadow.camera.bottom = -20;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 45;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const cyanLight = new THREE.DirectionalLight(0x28dce8, 1.15);
cyanLight.position.set(-12, 7, -10);
scene.add(cyanLight);
const movingLight = new THREE.PointLight(0xffc857, 34, 30, 2);
movingLight.position.set(0, 5, 0);
scene.add(movingLight);
// ------------------------------------------------------------
// Voxel tessellation
// ------------------------------------------------------------
const TILE_SIZE = 6;
const TILE_COUNT = 5;
const GRID_SIZE = TILE_SIZE * TILE_COUNT;
const CELL_COUNT = GRID_SIZE * GRID_SIZE;
const CELL_GAP = 0.025;
// Asymmetric four-by-four pixel labyrinth.
// It has four visually distinct quarter-turn orientations.
const PATTERN = [
[0, 0, 1, 2],
[0, 1, 1, 2],
[1, 1, 0, 2],
[2, 2, 0, 0]
];
const PATTERN_SIZE = PATTERN.length;
const palette = [
new THREE.Color(0x182b49),
new THREE.Color(0x18d8d0),
new THREE.Color(0xffc857)
];
const borderColor = new THREE.Color(0x0c1729);
const highlightColor = new THREE.Color(0xeaffff);
const heights = [
0.145,
0.34,
0.56
];
const voxelGeometry = new THREE.BoxGeometry(
1 - CELL_GAP,
1,
1 - CELL_GAP
);
const voxelMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
vertexColors: true,
roughness: 0.34,
metalness: 0.16,
emissive: 0x061521,
emissiveIntensity: 0.38
});
const voxels = new THREE.InstancedMesh(
voxelGeometry,
voxelMaterial,
CELL_COUNT
);
voxels.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
voxels.castShadow = true;
voxels.receiveShadow = true;
voxels.frustumCulled = false;
scene.add(voxels);
// A dark foundation catches the tile shadows.
const foundation = new THREE.Mesh(
new THREE.PlaneGeometry(120, 120),
new THREE.MeshStandardMaterial({
color: 0x050a14,
roughness: 0.95,
metalness: 0.02
})
);
foundation.rotation.x = -Math.PI / 2;
foundation.position.y = -0.052;
foundation.receiveShadow = true;
scene.add(foundation);
const dummy = new THREE.Object3D();
const workingColor = new THREE.Color();
const clamp = THREE.MathUtils.clamp;
const lerp = THREE.MathUtils.lerp;
function smoothstep(value) {
return value * value * (3 - 2 * value);
}
function mod4(value) {
return ((value % 4) + 4) % 4;
}
function rotatedPatternValue(rotation, row, column) {
const last = PATTERN_SIZE - 1;
let sourceRow;
let sourceColumn;
switch (rotation) {
case 0:
sourceRow = row;
sourceColumn = column;
break;
case 1:
sourceRow = column;
sourceColumn = last - row;
break;
case 2:
sourceRow = last - row;
sourceColumn = last - column;
break;
default:
sourceRow = last - column;
sourceColumn = row;
break;
}
return PATTERN[sourceRow][sourceColumn];
}
function updateVoxels(elapsed) {
const halfGrid = GRID_SIZE * 0.5;
for (let gridZ = 0; gridZ < GRID_SIZE; gridZ++) {
for (let gridX = 0; gridX < GRID_SIZE; gridX++) {
const index = gridZ * GRID_SIZE + gridX;
const tileX = Math.floor(gridX / TILE_SIZE);
const tileZ = Math.floor(gridZ / TILE_SIZE);
const localX = gridX % TILE_SIZE;
const localZ = gridZ % TILE_SIZE;
const isBorder =
localX === 0 ||
localX === TILE_SIZE - 1 ||
localZ === 0 ||
localZ === TILE_SIZE - 1;
let height = 0.1;
let color = borderColor;
if (isBorder) {
/*
* Every tile perimeter has exactly the same height and color.
* Adjacent tiles therefore remain flush throughout the animation.
*/
workingColor.copy(borderColor);
} else {
const row = localZ - 1;
const column = localX - 1;
/*
* The phase advances diagonally. A local phase crossing causes
* the motif to move through one quarter-turn.
*/
const phase =
tileX * 0.43 +
tileZ * 0.29 +
elapsed * 0.72;
const phaseStep = Math.floor(phase);
const phaseFraction = phase - phaseStep;
const fromRotation = mod4(phaseStep - 1);
const toRotation = mod4(phaseStep);
// Hold briefly, turn, then hold again.
const turnProgress = clamp(
(phaseFraction - 0.18) / 0.64,
0,
1
);
const turn = smoothstep(turnProgress);
const pulse = Math.sin(Math.PI * turnProgress);
const fromValue = rotatedPatternValue(
fromRotation,
row,
column
);
const toValue = rotatedPatternValue(
toRotation,
row,
column
);
height = lerp(
heights[fromValue],
heights[toValue],
turn
);
height += pulse * 0.065;
workingColor
.copy(palette[fromValue])
.lerp(palette[toValue], turn);
// A restrained flash emphasizes each discrete quarter-turn.
workingColor.lerp(highlightColor, pulse * 0.11);
}
const worldX = gridX - halfGrid + 0.5;
const worldZ = gridZ - halfGrid + 0.5;
dummy.position.set(
worldX,
height * 0.5 - 0.04,
worldZ
);
dummy.scale.set(1, height, 1);
dummy.updateMatrix();
voxels.setMatrixAt(index, dummy.matrix);
voxels.setColorAt(index, workingColor);
}
}
voxels.instanceMatrix.needsUpdate = true;
if (voxels.instanceColor) {
voxels.instanceColor.needsUpdate = true;
}
}
// ------------------------------------------------------------
// Direct camera controls — no external control modules
// ------------------------------------------------------------
const orbit = {
yaw: 0.72,
targetYaw: 0.72,
pitch: 0.72,
targetPitch: 0.72,
distance: 30,
targetDistance: 30,
target: new THREE.Vector3(0, 0, 0),
dragging: false,
pointerId: null,
lastX: 0,
lastY: 0
};
function resetCamera() {
orbit.targetYaw = 0.72;
orbit.targetPitch = 0.72;
orbit.targetDistance = 30;
}
function updateCamera() {
const damping = 0.1;
orbit.yaw = lerp(orbit.yaw, orbit.targetYaw, damping);
orbit.pitch = lerp(orbit.pitch, orbit.targetPitch, damping);
orbit.distance = lerp(
orbit.distance,
orbit.targetDistance,
damping
);
const horizontalDistance =
orbit.distance * Math.cos(orbit.pitch);
camera.position.set(
orbit.target.x + horizontalDistance * Math.cos(orbit.yaw),
orbit.target.y + orbit.distance * Math.sin(orbit.pitch),
orbit.target.z + horizontalDistance * Math.sin(orbit.yaw)
);
camera.lookAt(orbit.target);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
orbit.dragging = true;
orbit.pointerId = event.pointerId;
orbit.lastX = event.clientX;
orbit.lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!orbit.dragging || event.pointerId !== orbit.pointerId) {
return;
}
const deltaX = event.clientX - orbit.lastX;
const deltaY = event.clientY - orbit.lastY;
orbit.lastX = event.clientX;
orbit.lastY = event.clientY;
orbit.targetYaw -= deltaX * 0.006;
orbit.targetPitch = clamp(
orbit.targetPitch + deltaY * 0.005,
0.28,
1.38
);
});
function endPointer(event) {
if (event.pointerId !== orbit.pointerId) {
return;
}
orbit.dragging = false;
orbit.pointerId = 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();
orbit.targetDistance = clamp(
orbit.targetDistance * Math.exp(event.deltaY * 0.001),
13,
44
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
switch (event.key) {
case "ArrowLeft":
orbit.targetYaw += 0.15;
break;
case "ArrowRight":
orbit.targetYaw -= 0.15;
break;
case "ArrowUp":
orbit.targetPitch = clamp(
orbit.targetPitch + 0.08,
0.28,
1.38
);
break;
case "ArrowDown":
orbit.targetPitch = clamp(
orbit.targetPitch - 0.08,
0.28,
1.38
);
break;
case "+":
case "=":
orbit.targetDistance = clamp(
orbit.targetDistance - 1.5,
13,
44
);
break;
case "-":
orbit.targetDistance = clamp(
orbit.targetDistance + 1.5,
13,
44
);
break;
case "r":
case "R":
resetCamera();
break;
}
});
// ------------------------------------------------------------
// Resize and animation
// ------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
const clock = new THREE.Clock();
let elapsed = 0;
updateVoxels(0);
updateCamera();
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
elapsed += delta;
updateVoxels(elapsed);
updateCamera();
// A slow orbiting accent light adds depth without changing the grid.
movingLight.position.set(
Math.sin(elapsed * 0.34) * 10,
4.8 + Math.sin(elapsed * 0.5) * 0.7,
Math.cos(elapsed * 0.34) * 10
);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```