Prompt specification
Build or customize the Three.js 3D scene "Dog play-bow posture study" 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: Dog play-bow posture study
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/dog-play-bow-posture-study-x0669
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing a dog play-bow posture study made from visible voxel blocks. Put two versions of the same dog on adjacent ground tiles: one standing neutrally and one with its front body lowered and hindquarters raised. Keep the head, shoulders, elbows, hips, and paws readable, using the same body proportions in both poses. The lowered pose should still have plausible ground contacts rather than bent limbs intersecting the floor. A small caption can name the posture, but do not treat it as proof of one guaranteed emotion. Keep the background simple enough to compare the silhouettes.
Working Three.js Starter (dog-play-bow-posture-study-x0669):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Voxel Dog Posture Study</title>
<style>
:root {
color-scheme: light;
--ink: #282925;
--muted: #696b64;
--paper: #f3f0e9;
--tile: #dedbd2;
--line: rgba(40, 41, 37, 0.18);
}
* {
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;
}
#stage {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#stage canvas:active {
cursor: grabbing;
}
header {
position: fixed;
z-index: 2;
top: 22px;
left: 26px;
max-width: min(560px, calc(100vw - 52px));
pointer-events: none;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}
h1 {
margin: 0;
font-size: clamp(19px, 2.2vw, 29px);
font-weight: 650;
letter-spacing: -0.025em;
}
header p {
margin: 5px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
#controls-hint {
position: fixed;
z-index: 2;
top: 24px;
right: 26px;
color: var(--muted);
font-size: 11px;
letter-spacing: 0.04em;
pointer-events: none;
}
.captions {
position: fixed;
z-index: 2;
left: 50%;
bottom: 20px;
width: min(900px, calc(100vw - 32px));
transform: translateX(-50%);
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
pointer-events: none;
}
.caption {
min-height: 70px;
padding: 11px 15px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(248, 246, 240, 0.88);
box-shadow: 0 6px 22px rgba(49, 47, 39, 0.06);
backdrop-filter: blur(8px);
}
.caption strong {
display: block;
margin-bottom: 4px;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.caption p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.35;
}
#loading {
position: fixed;
z-index: 5;
inset: 0;
display: grid;
place-items: center;
background: var(--paper);
color: var(--muted);
font-size: 13px;
transition: opacity 240ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
header {
top: 15px;
left: 16px;
}
header p {
max-width: 310px;
font-size: 11px;
}
#controls-hint {
display: none;
}
.captions {
bottom: 10px;
width: calc(100vw - 20px);
gap: 7px;
}
.caption {
min-height: 76px;
padding: 9px 10px;
}
.caption strong {
font-size: 9px;
}
.caption p {
font-size: 10px;
}
}
</style>
</head>
<body>
<div id="stage"></div>
<header>
<h1>Voxel canine posture study</h1>
<p>Identical body proportions, arranged for silhouette comparison.</p>
</header>
<div id="controls-hint">DRAG TO ORBIT · WHEEL TO ZOOM · DOUBLE-CLICK TO RESET</div>
<div class="captions">
<section class="caption">
<strong>Neutral standing posture</strong>
<p>Level trunk, readable shoulder and hip masses, and four planted paws.</p>
</section>
<section class="caption">
<strong>Play-bow posture</strong>
<p>Front body lowered and hindquarters raised. This names a posture, not proof of one guaranteed emotion.</p>
</section>
</div>
<div id="loading">Building the voxel study…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.querySelector("#stage");
const loading = document.querySelector("#loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf3f0e9);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
stage.appendChild(renderer.domElement);
renderer.domElement.setAttribute(
"aria-label",
"Two voxel dogs on adjacent tiles: one standing neutrally and one in a play-bow posture."
);
const camera = new THREE.OrthographicCamera(-6, 6, 4, -4, 0.1, 60);
const target = new THREE.Vector3(0, 1.25, 0);
const hemisphere = new THREE.HemisphereLight(
0xfff8e9,
0xaaa89f,
2.25
);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff4dc, 3.25);
keyLight.position.set(-4.5, 9, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 7;
keyLight.shadow.camera.bottom = -5;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 25;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xdde8f2, 0.9);
fillLight.position.set(6, 4, -5);
scene.add(fillLight);
const groundMaterial = new THREE.MeshStandardMaterial({
color: 0xebe8e0,
roughness: 0.98,
metalness: 0
});
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(30, 20),
groundMaterial
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.235;
ground.receiveShadow = true;
scene.add(ground);
const tileMaterial = new THREE.MeshStandardMaterial({
color: 0xdad7ce,
roughness: 0.92,
metalness: 0
});
const tileGeometry = new THREE.BoxGeometry(4.9, 0.22, 3.8);
const tileEdgeMaterial = new THREE.LineBasicMaterial({
color: 0x77786f,
transparent: true,
opacity: 0.3
});
function addTile(x) {
const tile = new THREE.Mesh(tileGeometry, tileMaterial);
tile.position.set(x, -0.11, 0);
tile.receiveShadow = true;
tile.castShadow = true;
scene.add(tile);
const edge = new THREE.LineSegments(
new THREE.EdgesGeometry(tileGeometry),
tileEdgeMaterial
);
edge.position.copy(tile.position);
scene.add(edge);
}
addTile(-2.55);
addTile(2.55);
const UNIT = 0.22;
const BODY_CUBE = UNIT * 0.91;
const COLORS = {
torso: "#c98b49",
shoulder: "#d69a57",
neck: "#d49a56",
hip: "#bf773c",
head: "#d9a15d",
muzzle: "#e1b176",
leg: "#b9783d",
joint: "#87502d",
paw: "#d29a60",
toe: "#dfaa70",
nose: "#302b27",
eye: "#171918",
ear: "#9b6034",
tail: "#a76635"
};
/*
The same canonical body map is used for both poses.
Only the pose transform and the limb joint positions change.
*/
function makeCanonicalBody() {
const blocks = [];
const occupancy = new Map();
function addEllipsoid(center, radii, color, priority) {
const [cx, cy, cz] = center;
const [rx, ry, rz] = radii;
const ix0 = Math.ceil((cx - rx) / UNIT);
const ix1 = Math.floor((cx + rx) / UNIT);
const iy0 = Math.ceil((cy - ry) / UNIT);
const iy1 = Math.floor((cy + ry) / UNIT);
const iz0 = Math.ceil((cz - rz) / UNIT);
const iz1 = Math.floor((cz + rz) / UNIT);
for (let ix = ix0; ix <= ix1; ix++) {
const x = ix * UNIT;
const nx = (x - cx) / rx;
for (let iy = iy0; iy <= iy1; iy++) {
const y = iy * UNIT;
const ny = (y - cy) / ry;
for (let iz = iz0; iz <= iz1; iz++) {
const z = iz * UNIT;
const nz = (z - cz) / rz;
if (nx * nx + ny * ny + nz * nz <= 1.015) {
const key = `${ix}|${iy}|${iz}`;
const previous = occupancy.get(key);
if (!previous || priority >= previous.priority) {
occupancy.set(key, { color, priority });
}
}
}
}
}
}
// Trunk, chest, neck and pelvis form one voxel silhouette.
addEllipsoid([0.05, 1.67, 0], [1.18, 0.57, 0.55], COLORS.torso, 0);
addEllipsoid([-0.94, 2.14, 0], [0.46, 0.65, 0.48], COLORS.neck, 1);
addEllipsoid([-0.62, 1.67, 0], [0.58, 0.67, 0.55], COLORS.shoulder, 2);
addEllipsoid([1.02, 1.75, 0], [0.67, 0.72, 0.59], COLORS.hip, 3);
addEllipsoid([-1.36, 2.54, 0], [0.50, 0.46, 0.45], COLORS.head, 4);
for (const [key, entry] of occupancy) {
const [ix, iy, iz] = key.split("|").map(Number);
const color = new THREE.Color(entry.color);
const shade = (ix + 2 * iy + iz) % 5 === 0 ? -0.035 : 0.008;
color.offsetHSL(0, 0, shade);
blocks.push({
p: [ix * UNIT, iy * UNIT, iz * UNIT],
s: [BODY_CUBE, BODY_CUBE, BODY_CUBE],
c: color
});
}
// Block-built muzzle.
for (const x of [-2.08, -1.86, -1.64]) {
for (const y of [2.27, 2.49]) {
for (const z of [-0.11, 0.11]) {
blocks.push({
p: [x, y, z],
s: [BODY_CUBE, BODY_CUBE, BODY_CUBE],
c: COLORS.muzzle
});
}
}
}
// Nose, visible eye and two simple voxel ears.
blocks.push({
p: [-2.23, 2.38, 0],
s: [0.18, 0.21, 0.38],
c: COLORS.nose
});
blocks.push({
p: [-1.47, 2.67, 0.48],
s: [0.12, 0.12, 0.09],
c: COLORS.eye
});
for (const z of [-0.18, 0.18]) {
blocks.push({
p: [-1.15, 2.91, z],
s: [0.23, 0.28, 0.28],
c: COLORS.ear
});
blocks.push({
p: [-1.13, 3.12, z],
s: [0.22, 0.24, 0.27],
c: COLORS.ear
});
}
return blocks;
}
const canonicalBody = makeCanonicalBody();
function transformPoint(point, pose) {
if (pose === "standing") {
return { ...point };
}
// A rigid approximately 27-degree body rotation:
// the shoulder remains the pivot while the chest/head lower
// and the pelvis rises.
const pivot = { x: -0.30, y: 1.45 };
const angle = 0.47;
const cos = Math.cos(angle);
const sin = Math.sin(angle);
const dx = point.x - pivot.x;
const dy = point.y - pivot.y;
return {
x: pivot.x + cos * dx - sin * dy,
y: pivot.y + sin * dx + cos * dy,
z: point.z
};
}
function addBlock(blocks, p, s, color) {
blocks.push({
p,
s,
c: new THREE.Color(color)
});
}
function addSegment(blocks, a, b, count, color = COLORS.leg) {
for (let i = 1; i < count; i++) {
const t = i / count;
addBlock(
blocks,
[
THREE.MathUtils.lerp(a[0], b[0], t),
THREE.MathUtils.lerp(a[1], b[1], t),
a[2]
],
[0.205, 0.205, 0.205],
color
);
}
}
function addJoint(blocks, point, size = 0.26, z = 0.28) {
addBlock(
blocks,
[point[0], point[1], z],
[size, size, size],
COLORS.joint
);
}
function addPaw(blocks, x, z = 0.23) {
// The bottom remains slightly above y=0 so the paw sits on
// the tile rather than intersecting it.
addBlock(
blocks,
[x, 0.14, z],
[0.52, 0.22, 0.62],
COLORS.paw
);
for (const dz of [-0.20, 0, 0.20]) {
addBlock(
blocks,
[x - 0.23, 0.09, z + dz],
[0.15, 0.12, 0.16],
COLORS.toe
);
}
}
function makeDog(pose) {
const blocks = [];
for (const block of canonicalBody) {
const p = transformPoint(
{ x: block.p[0], y: block.p[1], z: block.p[2] },
pose
);
blocks.push({ p: [p.x, p.y, p.z], s: block.s, c: block.c });
}
let shoulder = [-0.55, 1.62, 0.28];
let hip = [1.02, 1.68, 0.28];
if (pose === "standing") {
const elbow = [-0.18, 1.02, 0.28];
const frontWrist = [-0.38, 0.33, 0.28];
addJoint(blocks, shoulder, 0.27, 0.48);
addSegment(blocks, shoulder, elbow, 4);
addJoint(blocks, elbow, 0.255, 0.30);
addSegment(blocks, elbow, frontWrist, 4);
addJoint(blocks, frontWrist, 0.22, 0.30);
addPaw(blocks, -0.48);
const knee = [0.55, 0.95, 0.28];
const hock = [1.02, 0.38, 0.28];
const rearWrist = [0.88, 0.23, 0.28];
addJoint(blocks, hip, 0.29, 0.48);
addSegment(blocks, hip, knee, 6);
addJoint(blocks, knee, 0.265, 0.30);
addSegment(blocks, knee, hock, 5);
addJoint(blocks, hock, 0.235, 0.30);
addSegment(blocks, hock, rearWrist, 2);
addPaw(blocks, 0.88);
} else {
const transformedShoulder = transformPoint(
{ x: shoulder[0], y: shoulder[1], z: shoulder[2] },
pose
);
const transformedHip = transformPoint(
{ x: hip[0], y: hip[1], z: hip[2] },
pose
);
shoulder = [
transformedShoulder.x,
transformedShoulder.y,
0.28
];
hip = [transformedHip.x, transformedHip.y, 0.28];
// The forelimb reaches the floor through a long, readable
// diagonal. Every paw remains flat on the tile.
const elbow = [-0.34, 0.72, 0.28];
const frontWrist = [-0.94, 0.31, 0.28];
addJoint(blocks, shoulder, 0.27, 0.48);
addSegment(blocks, shoulder, elbow, 4);
addJoint(blocks, elbow, 0.255, 0.30);
addSegment(blocks, elbow, frontWrist, 4);
addJoint(blocks, frontWrist, 0.22, 0.30);
addPaw(blocks, -1.06);
// The elevated pelvis is connected to a nearly extended rear
// limb, ending in another flat ground contact.
const knee = [0.67, 1.17, 0.28];
const hock = [1.05, 0.35, 0.28];
const rearWrist = [0.89, 0.23, 0.28];
addJoint(blocks, hip, 0.29, 0.48);
addSegment(blocks, hip, knee, 6);
addJoint(blocks, knee, 0.265, 0.30);
addSegment(blocks, knee, hock, 5);
addJoint(blocks, hock, 0.235, 0.30);
addSegment(blocks, hock, rearWrist, 2);
addPaw(blocks, 0.89);
}
// Tail: a tapered chain with the same number of blocks in both poses.
const tailBase = transformPoint(
{ x: 1.40, y: 1.92, z: 0.08 },
pose
);
const tailEnd = pose === "standing"
? { x: 2.23, y: 2.35, z: 0.08 }
: { x: 1.93, y: 2.70, z: 0.08 };
for (let i = 0; i < 7; i++) {
const t = i / 6;
const size = THREE.MathUtils.lerp(0.25, 0.14, t);
addBlock(
blocks,
[
THREE.MathUtils.lerp(tailBase.x, tailEnd.x, t),
THREE.MathUtils.lerp(tailBase.y, tailEnd.y, t),
tailBase.z
],
[size, size, size],
COLORS.tail
);
}
return blocks;
}
function createVoxelMesh(blocks) {
const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.86,
metalness: 0
});
const mesh = new THREE.InstancedMesh(
geometry,
material,
blocks.length
);
const dummy = new THREE.Object3D();
blocks.forEach((block, index) => {
dummy.position.set(block.p[0], block.p[1], block.p[2]);
dummy.scale.set(block.s[0], block.s[1], block.s[2]);
dummy.rotation.set(0, 0, 0);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
mesh.setColorAt(index, block.c.isColor ? block.c : new THREE.Color(block.c));
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) {
mesh.instanceColor.needsUpdate = true;
}
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
const standingDog = createVoxelMesh(makeDog("standing"));
standingDog.position.x = -2.55;
scene.add(standingDog);
const playBowDog = createVoxelMesh(makeDog("play-bow"));
playBowDog.position.x = 2.55;
scene.add(playBowDog);
/*
Small custom orthographic orbit controls.
No examples/jsm or legacy controls are used.
*/
let yaw = 0;
let pitch = 0.12;
let dragging = false;
let previousX = 0;
let previousY = 0;
function updateCamera() {
const radius = 15;
camera.position.set(
target.x + radius * Math.sin(yaw) * Math.cos(pitch),
target.y + radius * Math.sin(pitch),
target.z + radius * Math.cos(yaw) * Math.cos(pitch)
);
camera.lookAt(target);
camera.updateProjectionMatrix();
renderer.render(scene, camera);
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
renderer.setSize(width, height);
// Preserve the full pair of tiles on both wide and narrow displays.
const worldWidth = 11.7;
const viewHeight = Math.max(5.25, worldWidth / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
yaw = THREE.MathUtils.clamp(yaw - dx * 0.004, -0.48, 0.48);
pitch = THREE.MathUtils.clamp(pitch + dy * 0.003, -0.03, 0.34);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (
event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
camera.zoom = THREE.MathUtils.clamp(
camera.zoom - event.deltaY * 0.0007,
0.82,
1.28
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
yaw = 0;
pitch = 0.12;
camera.zoom = 1;
updateCamera();
});
window.addEventListener("resize", resize);
resize();
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 300);
</script>
</body>
</html>
```