Prompt specification
Build or customize the Three.js 3D scene "Voxel Character Turns With Consistent Features" 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: Voxel Character Turns With Consistent Features
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/voxel-character-turns-with-consistent-features-x3754
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring consistent voxel character identity across views and resolutions. Animate a turntable and a short arm gesture for an original voxel figure. Preserve feature placement and avoid replacing the character with unrelated view-specific shapes. Voxel style.
Working Three.js Starter (voxel-character-turns-with-consistent-features-x3754):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bramble-08 — Voxel Character</title>
<style>
:root {
color-scheme: dark;
--ink: #f4f1e8;
--muted: #a8b5c8;
--panel: rgba(12, 19, 34, 0.72);
--line: rgba(255, 255, 255, 0.13);
--cyan: #65ead7;
--orange: #ff875c;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 50% 38%, #243452 0%, #10182b 42%, #070b15 100%);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
outline: none;
}
canvas:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
}
.identity {
position: absolute;
top: clamp(18px, 4vw, 44px);
left: clamp(18px, 4vw, 48px);
max-width: min(430px, calc(100vw - 36px));
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
color: var(--cyan);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 25px;
height: 2px;
background: var(--cyan);
box-shadow: 0 0 12px rgba(101, 234, 215, 0.8);
}
h1 {
margin: 10px 0 5px;
color: var(--ink);
font-size: clamp(32px, 6vw, 64px);
line-height: 0.95;
letter-spacing: -0.055em;
}
.subtitle {
margin: 12px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.status {
position: absolute;
top: clamp(18px, 4vw, 44px);
right: clamp(18px, 4vw, 48px);
display: flex;
align-items: center;
gap: 9px;
padding: 9px 12px;
border: 1px solid var(--line);
border-radius: 999px;
background: var(--panel);
color: #c9d5e8;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
backdrop-filter: blur(14px);
}
.status-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 10px var(--cyan);
animation: pulse 1.5s ease-in-out infinite;
}
.status.paused .status-dot {
background: #ffbd66;
box-shadow: 0 0 10px #ffbd66;
animation: none;
}
@keyframes pulse {
50% {
opacity: 0.35;
transform: scale(0.75);
}
}
.controls {
position: absolute;
left: 50%;
bottom: clamp(18px, 4vw, 36px);
display: flex;
align-items: center;
gap: 8px;
padding: 8px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
backdrop-filter: blur(16px);
pointer-events: auto;
transform: translateX(-50%);
}
button {
min-height: 40px;
padding: 0 15px;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 10px;
background: rgba(255, 255, 255, 0.055);
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
transition:
background 150ms ease,
border-color 150ms ease,
transform 150ms ease;
}
button:hover {
background: rgba(255, 255, 255, 0.11);
border-color: rgba(255, 255, 255, 0.22);
transform: translateY(-1px);
}
button:focus-visible {
outline: 2px solid var(--cyan);
outline-offset: 2px;
}
#wave {
border-color: rgba(101, 234, 215, 0.36);
background: rgba(101, 234, 215, 0.11);
color: #b9fff5;
}
.hint {
position: absolute;
right: clamp(18px, 4vw, 48px);
bottom: clamp(24px, 4vw, 44px);
color: rgba(202, 215, 235, 0.64);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.09em;
text-align: right;
line-height: 1.65;
text-transform: uppercase;
}
@media (max-width: 720px) {
.subtitle {
max-width: 260px;
font-size: 12px;
}
.status {
top: auto;
right: 16px;
bottom: 84px;
}
.hint {
display: none;
}
.controls {
width: calc(100vw - 28px);
justify-content: stretch;
}
button {
flex: 1;
padding-inline: 8px;
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive voxel character turntable"></main>
<div class="hud">
<header class="identity">
<div class="eyebrow">Voxel courier series · Unit 08</div>
<h1>Bramble–08</h1>
<p class="subtitle">
A compact trail scout with a fixed visor, cap, antenna, scarf,
and solar-yellow field pack.
</p>
</header>
<div class="status" id="status">
<span class="status-dot"></span>
<span id="statusText">Turning</span>
</div>
<nav class="controls" aria-label="Animation controls">
<button id="pause" type="button" aria-pressed="false">Pause</button>
<button id="wave" type="button">Wave</button>
<button id="reset" type="button">Reset view</button>
</nav>
<div class="hint">
Drag to orbit<br>
Scroll or pinch to zoom
</div>
</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 host = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setClearColor(0x000000, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Bramble-08, an animated voxel figure on a rotating display"
);
renderer.domElement.tabIndex = 0;
host.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x0b1022, 9, 19);
const camera = new THREE.PerspectiveCamera(34, 1, 0.1, 60);
const hemisphere = new THREE.HemisphereLight(
0xa8eaff,
0x171326,
1.65
);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffefd4, 3.2);
keyLight.position.set(4.5, 8, 6);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 20;
keyLight.shadow.camera.left = -5;
keyLight.shadow.camera.right = 5;
keyLight.shadow.camera.top = 6;
keyLight.shadow.camera.bottom = -4;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const rimLight = new THREE.PointLight(0x4cf3db, 28, 12, 2);
rimLight.position.set(-4, 4.5, -3.5);
scene.add(rimLight);
const warmLight = new THREE.PointLight(0xff714b, 18, 10, 2);
warmLight.position.set(3.5, 2.5, 4);
scene.add(warmLight);
// A single permanent hierarchy contains the display and character.
const turntable = new THREE.Group();
turntable.name = "Bramble-08 turntable";
scene.add(turntable);
// -------------------------------------------------------------------------
// Voxel construction helpers and materials
// -------------------------------------------------------------------------
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0.04,
flatShading: true,
...options
});
}
const materials = {
platform: material(0x25354e),
platformAlt: material(0x2d405b),
platformEdge: material(0x111c2e),
coat: material(0xf06f43),
coatDark: material(0xb84432),
cream: material(0xf5e6c7),
teal: material(0x36b9aa),
tealDark: material(0x1d706c),
navy: material(0x17243a),
visor: material(0x0c1729, {
roughness: 0.28,
metalness: 0.35
}),
cyan: material(0x75fff0, {
emissive: 0x23d8c4,
emissiveIntensity: 2.2,
roughness: 0.35
}),
yellow: material(0xf3bd4c),
yellowDark: material(0xb97927),
mint: material(0x9de1bd)
};
function box(parent, size, position, mat, castShadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
mat
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Display platform: a grid of square tiles preserves the voxel language.
// -------------------------------------------------------------------------
box(
turntable,
[3.85, 0.24, 3.85],
[0, -0.27, 0],
materials.platformEdge
);
box(
turntable,
[3.48, 0.045, 3.48],
[0, -0.145, 0],
materials.tealDark,
false
);
const tileSize = 0.68;
const tileGap = 0.035;
const tilePitch = tileSize + tileGap;
for (let row = -2; row <= 2; row++) {
for (let column = -2; column <= 2; column++) {
const tileMaterial =
(row + column) % 2 === 0
? materials.platform
: materials.platformAlt;
box(
turntable,
[tileSize, 0.16, tileSize],
[
column * tilePitch,
-0.07,
row * tilePitch
],
tileMaterial
);
}
}
// -------------------------------------------------------------------------
// Bramble-08: one permanent voxel hierarchy.
// All facial and costume features are children of the same model and are
// never replaced or conditionally rebuilt for different camera views.
// -------------------------------------------------------------------------
const character = new THREE.Group();
character.name = "Bramble-08 fixed voxel character";
turntable.add(character);
// Legs and boots.
for (const side of [-1, 1]) {
box(
character,
[0.34, 0.68, 0.38],
[side * 0.34, 0.57, 0],
materials.navy
);
box(
character,
[0.48, 0.30, 0.65],
[side * 0.34, 0.16, 0.13],
materials.coatDark
);
box(
character,
[0.39, 0.10, 0.12],
[side * 0.34, 0.23, 0.46],
materials.mint
);
}
// Pelvis, torso, and field-pack straps.
box(
character,
[1.12, 0.40, 0.78],
[0, 0.84, 0],
materials.navy
);
box(
character,
[1.30, 1.22, 0.90],
[0, 1.42, 0],
materials.coat
);
box(
character,
[0.72, 0.68, 0.08],
[0, 1.44, 0.49],
materials.cream
);
box(
character,
[0.23, 0.23, 0.08],
[0.22, 1.53, 0.55],
materials.teal
);
for (const side of [-1, 1]) {
box(
character,
[0.11, 0.88, 0.08],
[side * 0.43, 1.46, 0.48],
materials.yellowDark
);
}
for (let i = 0; i < 3; i++) {
box(
character,
[0.09, 0.09, 0.07],
[-0.21, 1.28 + i * 0.16, 0.55],
materials.yellow
);
}
// Backpack: remains visible and identical during rear views.
box(
character,
[0.96, 1.12, 0.38],
[0, 1.48, -0.64],
materials.yellow
);
box(
character,
[0.65, 0.52, 0.10],
[0, 1.57, -0.87],
materials.teal
);
box(
character,
[0.76, 0.12, 0.10],
[0, 1.27, -0.88],
materials.yellowDark
);
// Neck and scarf.
box(
character,
[0.42, 0.24, 0.42],
[0, 2.07, 0],
materials.navy
);
box(
character,
[1.28, 0.16, 0.98],
[0, 2.06, 0],
materials.teal
);
box(
character,
[0.24, 0.55, 0.12],
[-0.39, 1.79, 0.48],
materials.teal
);
// Head core.
box(
character,
[1.28, 1.08, 1.08],
[0, 2.61, 0],
materials.cream
);
// Face plate, visor, eyes, and mouth grille.
box(
character,
[1.08, 0.67, 0.12],
[0, 2.61, 0.57],
materials.cream
);
box(
character,
[0.92, 0.32, 0.08],
[0, 2.73, 0.65],
materials.visor
);
for (const side of [-1, 1]) {
box(
character,
[0.15, 0.15, 0.055],
[side * 0.23, 2.73, 0.71],
materials.cyan,
false
);
}
for (let i = -1; i <= 1; i++) {
box(
character,
[0.08, 0.07, 0.045],
[i * 0.14, 2.43, 0.66],
materials.navy,
false
);
}
// Ear modules and cap.
for (const side of [-1, 1]) {
box(
character,
[0.22, 0.47, 0.47],
[side * 0.73, 2.61, 0],
materials.tealDark
);
box(
character,
[0.10, 0.19, 0.22],
[side * 0.86, 2.61, 0.03],
materials.cyan,
false
);
}
box(
character,
[1.38, 0.22, 1.17],
[0, 3.20, 0],
materials.coatDark
);
box(
character,
[1.32, 0.12, 0.28],
[0, 3.15, 0.63],
materials.coat
);
// Antenna is a permanent, asymmetric silhouette feature.
box(
character,
[0.10, 0.42, 0.10],
[0.43, 3.49, -0.04],
materials.navy
);
box(
character,
[0.21, 0.21, 0.21],
[0.43, 3.74, -0.04],
materials.cyan,
false
);
// -------------------------------------------------------------------------
// Arms: separate shoulder and elbow pivots enable the short wave.
// The model's arm geometry itself is never swapped.
// -------------------------------------------------------------------------
function createArm(side) {
const shoulder = new THREE.Group();
shoulder.position.set(side * 0.84, 1.83, 0);
character.add(shoulder);
box(
shoulder,
[0.43, 0.36, 0.50],
[0, 0, 0],
materials.coatDark
);
box(
shoulder,
[0.34, 0.64, 0.42],
[0, -0.30, 0],
materials.coat
);
const elbow = new THREE.Group();
elbow.position.set(0, -0.62, 0);
shoulder.add(elbow);
box(
elbow,
[0.32, 0.58, 0.40],
[0, -0.27, 0],
materials.teal
);
box(
elbow,
[0.38, 0.28, 0.42],
[0, -0.62, 0.02],
materials.cream
);
return { shoulder, elbow };
}
const leftArm = createArm(-1);
const rightArm = createArm(1);
leftArm.shoulder.rotation.z = -0.06;
// -------------------------------------------------------------------------
// Ground and a few distant voxel markers for depth.
// -------------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
material(0x0b1220, { roughness: 1 })
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.41;
ground.receiveShadow = true;
scene.add(ground);
const distantMaterial = material(0x263650);
const distantPositions = [
[-5.2, 1.0, -3.8, 0.24],
[4.8, 1.6, -4.5, 0.32],
[-4.2, 3.4, 2.0, 0.18],
[5.5, 3.8, 1.3, 0.20],
[0.2, 5.1, -5.8, 0.15]
];
for (const [x, y, z, size] of distantPositions) {
box(
scene,
[size, size, size],
[x, y, z],
distantMaterial,
false
);
}
// -------------------------------------------------------------------------
// Custom camera controls. No examples/addons modules are used.
// -------------------------------------------------------------------------
const cameraTarget = new THREE.Vector3(0, 1.62, 0);
const defaultCamera = {
theta: 0.58,
phi: 1.16,
radius: 7.25
};
const cameraState = { ...defaultCamera };
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraTarget.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraTarget.y +
cameraState.radius * Math.cos(cameraState.phi),
cameraTarget.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraTarget);
}
updateCamera();
const pointers = new Map();
let pinchDistance = 0;
function currentPinchDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
pinchDistance = currentPinchDistance();
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.67,
1.48
);
} else if (pointers.size === 2) {
const nextDistance = currentPinchDistance();
if (pinchDistance > 0 && nextDistance > 0) {
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * (pinchDistance / nextDistance),
4.7,
11
);
}
pinchDistance = nextDistance;
}
updateCamera();
});
function releasePointer(event) {
pointers.delete(event.pointerId);
pinchDistance = pointers.size === 2 ? currentPinchDistance() : 0;
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.0035,
4.7,
11
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
Object.assign(cameraState, defaultCamera);
updateCamera();
});
// -------------------------------------------------------------------------
// Responsive sizing
// -------------------------------------------------------------------------
function resize() {
const width = Math.max(1, host.clientWidth);
const height = Math.max(1, host.clientHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(host);
resize();
// -------------------------------------------------------------------------
// Animation state
// -------------------------------------------------------------------------
const pauseButton = document.querySelector("#pause");
const waveButton = document.querySelector("#wave");
const resetButton = document.querySelector("#reset");
const status = document.querySelector("#status");
const statusText = document.querySelector("#statusText");
let paused = false;
let simulationTime = 0;
let manualWaveStart = -100;
let previousFrame = performance.now();
function setPaused(value) {
paused = value;
pauseButton.textContent = paused ? "Resume" : "Pause";
pauseButton.setAttribute("aria-pressed", String(paused));
status.classList.toggle("paused", paused);
statusText.textContent = paused ? "Paused" : "Turning";
}
pauseButton.addEventListener("click", () => {
setPaused(!paused);
});
waveButton.addEventListener("click", () => {
manualWaveStart = simulationTime;
setPaused(false);
});
resetButton.addEventListener("click", () => {
Object.assign(cameraState, defaultCamera);
updateCamera();
});
window.addEventListener("keydown", (event) => {
if (event.code === "Space") {
event.preventDefault();
setPaused(!paused);
}
if (event.key.toLowerCase() === "w") {
manualWaveStart = simulationTime;
setPaused(false);
}
if (event.key.toLowerCase() === "r") {
Object.assign(cameraState, defaultCamera);
updateCamera();
}
});
function waveEnvelope(elapsed, duration) {
if (elapsed < 0 || elapsed > duration) return 0;
return Math.sin((elapsed / duration) * Math.PI) ** 2;
}
function animate(now) {
requestAnimationFrame(animate);
const delta = Math.min((now - previousFrame) / 1000, 0.05);
previousFrame = now;
if (!paused) {
simulationTime += delta;
}
// Continuous turntable rotation.
turntable.rotation.y = simulationTime * 0.31;
// Automatic wave every 5.5 seconds.
const automaticPhase = simulationTime % 5.5;
let automaticWave = 0;
if (automaticPhase >= 1.1 && automaticPhase <= 2.9) {
automaticWave =
Math.sin(
((automaticPhase - 1.1) / 1.8) * Math.PI
) ** 2;
}
// The button triggers the same articulation as the automatic gesture.
const manualWave = waveEnvelope(
simulationTime - manualWaveStart,
1.8
);
const gesture = Math.max(automaticWave, manualWave);
const handWave =
Math.sin(simulationTime * 14) * gesture * 0.17;
rightArm.shoulder.rotation.z =
0.035 + gesture * 1.25;
rightArm.elbow.rotation.z =
gesture * 1.45 + handWave;
// A very small body motion keeps the scene alive without changing the
// character's proportions or relative feature placement.
character.position.y = Math.sin(simulationTime * 1.6) * 0.012;
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```