Prompt specification
Build or customize the Three.js 3D scene "Shoelace eyelet path model" 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: Shoelace eyelet path model
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/shoelace-eyelet-path-model-x0621
Scene Description Prompt:
A voxel shoe with six eyelet pairs and one continuous contrasting lace, showing every alternating crossing geometrically. Three.js from cdnjs, one HTML file.
Working Three.js Starter (shoelace-eyelet-path-model-x0621):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Cross-Lace Sneaker</title>
<style>
:root {
color-scheme: light;
--ink: #16303b;
--muted: #58717c;
--panel: rgba(245, 249, 250, 0.76);
--line: rgba(22, 48, 59, 0.14);
--accent: #ff5b3d;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 48% 34%, #f8fafb 0%, #e8eef1 47%, #d6e0e4 100%);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 2;
}
.brand {
position: absolute;
top: 28px;
left: 30px;
max-width: 360px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.eyebrow::before {
width: 25px;
height: 3px;
border-radius: 4px;
background: var(--accent);
content: "";
}
h1 {
margin: 0;
font-size: clamp(26px, 4vw, 48px);
font-weight: 760;
letter-spacing: -0.055em;
line-height: 0.98;
}
.subtitle {
margin-top: 12px;
color: var(--muted);
font-size: 12px;
font-weight: 600;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.controls {
position: absolute;
right: 26px;
top: 26px;
display: flex;
gap: 8px;
pointer-events: auto;
}
button {
appearance: none;
border: 1px solid var(--line);
border-radius: 999px;
padding: 10px 14px;
background: var(--panel);
color: var(--ink);
cursor: pointer;
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
backdrop-filter: blur(14px);
transition:
transform 160ms ease,
background 160ms ease,
border-color 160ms ease;
}
button:hover {
transform: translateY(-2px);
border-color: rgba(255, 91, 61, 0.45);
background: rgba(255, 255, 255, 0.92);
}
button.active {
border-color: var(--accent);
color: var(--accent);
}
.hint {
position: absolute;
left: 30px;
bottom: 27px;
display: flex;
align-items: center;
gap: 11px;
color: var(--muted);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.mouse {
position: relative;
width: 17px;
height: 24px;
border: 2px solid currentColor;
border-radius: 9px;
opacity: 0.8;
}
.mouse::after {
position: absolute;
top: 4px;
left: 50%;
width: 2px;
height: 5px;
border-radius: 2px;
background: currentColor;
content: "";
transform: translateX(-50%);
}
.badge {
position: absolute;
right: 28px;
bottom: 27px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
@media (max-width: 620px) {
.brand {
top: 20px;
left: 20px;
}
.subtitle {
max-width: 220px;
}
.controls {
top: auto;
right: 18px;
bottom: 60px;
}
.hint {
left: 20px;
bottom: 22px;
}
.badge {
display: none;
}
}
</style>
</head>
<body>
<div class="hud">
<div class="brand">
<div class="eyebrow">Voxel footwear study</div>
<h1>Cross / 06</h1>
<div class="subtitle">6 eyelet pairs · one continuous lace</div>
</div>
<div class="controls">
<button id="perspective" class="active" type="button">3D</button>
<button id="top" type="button">Top</button>
</div>
<div class="hint">
<span class="mouse"></span>
<span>Drag to orbit · Scroll to zoom</span>
</div>
<div class="badge">Double-click to reset</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 renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x000000, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0xdce5e8, 13, 31);
const camera = new THREE.PerspectiveCamera(
35,
window.innerWidth / window.innerHeight,
0.1,
80
);
const hemi = new THREE.HemisphereLight(0xf7fcff, 0x607985, 2.25);
scene.add(hemi);
const key = new THREE.DirectionalLight(0xfff6eb, 3.1);
key.position.set(-3.5, 8.5, 5.5);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -6;
key.shadow.camera.right = 6;
key.shadow.camera.top = 6;
key.shadow.camera.bottom = -6;
key.shadow.camera.near = 0.5;
key.shadow.camera.far = 24;
key.shadow.bias = -0.00025;
key.shadow.normalBias = 0.025;
scene.add(key);
const fill = new THREE.DirectionalLight(0x8fc9dc, 1.25);
fill.position.set(6, 4, -5);
scene.add(fill);
const rim = new THREE.PointLight(0xff7b54, 24, 15, 2);
rim.position.set(3.5, 2.6, -4.5);
scene.add(rim);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(70, 70),
new THREE.MeshStandardMaterial({
color: 0xdce4e7,
roughness: 0.96,
metalness: 0
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.018;
ground.receiveShadow = true;
scene.add(ground);
// -------------------------------------------------------------------------
// Voxel construction helpers
// -------------------------------------------------------------------------
const V = 0.22;
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const dummy = new THREE.Object3D();
let seed = 92741;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function variedColor(hex, lightness = 0.025) {
const color = new THREE.Color(hex);
color.offsetHSL(
(random() - 0.5) * 0.012,
(random() - 0.5) * 0.025,
(random() - 0.5) * lightness
);
return color;
}
function createInstances(items, material, name) {
const mesh = new THREE.InstancedMesh(unitBox, material, items.length);
mesh.name = name;
mesh.castShadow = true;
mesh.receiveShadow = true;
items.forEach((item, index) => {
dummy.position.set(item.x, item.y, item.z);
dummy.rotation.set(
item.rx || 0,
item.ry || 0,
item.rz || 0
);
dummy.scale.set(item.sx, item.sy, item.sz);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
mesh.setColorAt(index, new THREE.Color(item.color));
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
scene.add(mesh);
return mesh;
}
function halfWidthAt(zIndex) {
if (zIndex <= -12) return 1;
if (zIndex === -11) return 2;
if (zIndex === -10) return 3;
if (zIndex <= 4) return 4;
if (zIndex <= 8) return 3;
if (zIndex === 9) return 2;
if (zIndex <= 11) return 1;
return 0;
}
function sideHeightAt(zIndex) {
if (zIndex <= -11) return 6;
if (zIndex <= -9) return 5;
if (zIndex <= -7) return 4;
return 2;
}
// -------------------------------------------------------------------------
// Sole
// -------------------------------------------------------------------------
const outsoleItems = [];
const midsoleItems = [];
for (let zi = -12; zi <= 12; zi++) {
const half = halfWidthAt(zi);
for (let xi = -half; xi <= half; xi++) {
const x = xi * V;
const z = zi * V;
outsoleItems.push({
x,
y: 0.085,
z,
sx: V * 0.96,
sy: 0.17,
sz: V * 0.96,
color: variedColor(0x17303b, 0.03).getHex()
});
midsoleItems.push({
x,
y: 0.275,
z,
sx: V * 0.91,
sy: 0.19,
sz: V * 0.91,
color: variedColor(0xf0eee4, 0.025).getHex()
});
}
}
createInstances(
outsoleItems,
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.88,
metalness: 0.02
}),
"Voxel outsole"
);
createInstances(
midsoleItems,
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.76,
metalness: 0.01
}),
"Voxel midsole"
);
// -------------------------------------------------------------------------
// Upper shell
// -------------------------------------------------------------------------
const upperItems = [];
const tongueItems = [];
const ivory = [0xeaf0f2, 0xe1e9ec, 0xf2f4f2];
const heelTeal = [0x235563, 0x1d4b59, 0x2b5e69];
for (let zi = -12; zi <= 12; zi++) {
const half = halfWidthAt(zi);
const height = sideHeightAt(zi);
for (let xi = -half; xi <= half; xi++) {
const edge = Math.abs(xi) >= Math.max(0, half - 1);
const toeCap = zi >= 9;
const heelCap = zi <= -11;
if (edge || toeCap || heelCap) {
for (let layer = 0; layer < height; layer++) {
const collar =
zi <= -7 &&
layer === height - 1 &&
!toeCap;
const base = collar
? heelTeal[(xi + zi + layer + 20) % heelTeal.length]
: ivory[(xi + zi + layer + 30) % ivory.length];
upperItems.push({
x: xi * V,
y: 0.42 + layer * V,
z: zi * V,
sx: V * 0.91,
sy: V * 0.91,
sz: V * 0.91,
color: variedColor(base, 0.018).getHex()
});
}
}
}
}
// Raised, block-built tongue.
for (let zi = -8; zi <= 7; zi++) {
const tongueHeight = zi <= -6 ? 4 : 3;
for (let xi = -2; xi <= 2; xi++) {
for (let layer = 0; layer < tongueHeight; layer++) {
tongueItems.push({
x: xi * V,
y: 0.42 + layer * V,
z: zi * V,
sx: V * 0.91,
sy: V * 0.91,
sz: V * 0.91,
color: variedColor(
layer === tongueHeight - 1 ? 0x245866 : 0x1d4a57,
0.025
).getHex()
});
}
}
}
createInstances(
upperItems,
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.72,
metalness: 0.015
}),
"Voxel upper shell"
);
createInstances(
tongueItems,
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.67,
metalness: 0.025
}),
"Voxel tongue"
);
// Small voxel heel pull tab.
const pullTab = new THREE.Mesh(
unitBox,
new THREE.MeshStandardMaterial({
color: 0x245866,
roughness: 0.65
})
);
pullTab.position.set(0, 1.57, -2.54);
pullTab.scale.set(0.23, 0.42, 0.17);
pullTab.castShadow = true;
scene.add(pullTab);
// -------------------------------------------------------------------------
// Six eyelet pairs
// -------------------------------------------------------------------------
const eyeletRows = [-1.32, -0.792, -0.264, 0.264, 0.792, 1.32];
const eyeletX = 0.55;
const eyeletY = 1.035;
const eyeletBars = [];
const eyeletHoles = [];
function addEyelet(x, z) {
const outer = 0.245;
const bar = 0.055;
const offset = outer * 0.5 - bar * 0.5;
eyeletHoles.push({
x,
y: 1.004,
z,
sx: 0.126,
sy: 0.014,
sz: 0.126,
color: 0x102c35
});
eyeletBars.push(
{
x,
y: 1.02,
z: z - offset,
sx: outer,
sy: 0.05,
sz: bar,
color: 0xe0b467
},
{
x,
y: 1.02,
z: z + offset,
sx: outer,
sy: 0.05,
sz: bar,
color: 0xe0b467
},
{
x: x - offset,
y: 1.02,
z,
sx: bar,
sy: 0.05,
sz: outer - bar * 2,
color: 0xe0b467
},
{
x: x + offset,
y: 1.02,
z,
sx: bar,
sy: 0.05,
sz: outer - bar * 2,
color: 0xe0b467
}
);
}
for (const z of eyeletRows) {
addEyelet(-eyeletX, z);
addEyelet(eyeletX, z);
}
createInstances(
eyeletHoles,
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.9
}),
"Eyelet holes"
);
createInstances(
eyeletBars,
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.31,
metalness: 0.68
}),
"Voxel eyelet frames"
);
// -------------------------------------------------------------------------
// One continuous lace path
//
// The path travels forward through alternating eyelets, crosses over at the
// top pair, then returns through the opposite eyelets. Each adjacent pair
// of rows therefore contains a complete geometric X. The vertical offsets
// alternate over and under from one X to the next.
// -------------------------------------------------------------------------
const left = [];
const right = [];
eyeletRows.forEach((z) => {
left.push(new THREE.Vector3(-eyeletX, eyeletY, z));
right.push(new THREE.Vector3(eyeletX, eyeletY, z));
});
const laceSegments = [];
function addLaceSegment(a, b, gap = null, over = false) {
const arch = gap === null ? 0.105 : 0.12;
const offset = gap === null ? 0 : (over ? 0.11 : -0.02);
laceSegments.push({
a: a.clone(),
b: b.clone(),
arch,
offset,
length: a.distanceTo(b)
});
}
// Forward diagonal strand.
for (let gap = 0; gap < 5; gap++) {
const a = gap % 2 === 0 ? left[gap] : right[gap];
const b = gap % 2 === 0 ? right[gap + 1] : left[gap + 1];
addLaceSegment(a, b, gap, gap % 2 === 0);
}
// Join the two ends of the upper eyelet pair.
addLaceSegment(right[5], left[5]);
// Return strand: this supplies the opposite diagonal of every X.
for (let gap = 4; gap >= 0; gap--) {
const a = gap % 2 === 0 ? left[gap + 1] : right[gap + 1];
const b = gap % 2 === 0 ? right[gap] : left[gap];
addLaceSegment(a, b, gap, gap % 2 === 1);
}
const tailStart = new THREE.Vector3(-0.82, 0.84, -1.96);
const tailEnd = new THREE.Vector3(0.82, 0.84, -1.96);
// Prepending and appending these keeps the mesh a single open curve.
laceSegments.unshift({
a: tailStart.clone(),
b: left[0].clone(),
arch: 0,
offset: 0,
length: tailStart.distanceTo(left[0])
});
laceSegments.push({
a: right[0].clone(),
b: tailEnd.clone(),
arch: 0,
offset: 0,
length: right[0].distanceTo(tailEnd)
});
class LaceCurve extends THREE.Curve {
constructor(segments) {
super();
this.segments = segments;
this.totalLength = segments.reduce(
(sum, segment) => sum + segment.length,
0
);
}
getPoint(t, target = new THREE.Vector3()) {
let remaining = THREE.MathUtils.clamp(t, 0, 1) * this.totalLength;
let selected = this.segments[this.segments.length - 1];
let localT = 1;
for (const segment of this.segments) {
if (remaining <= segment.length) {
selected = segment;
localT = segment.length > 0 ? remaining / segment.length : 0;
break;
}
remaining -= segment.length;
}
const point = selected.a.clone().lerp(selected.b, localT);
const bell = Math.sin(Math.PI * localT);
point.y += (selected.arch + selected.offset) * bell * bell;
return target.copy(point);
}
}
const laceCurve = new LaceCurve(laceSegments);
const laceGeometry = new THREE.TubeGeometry(
laceCurve,
900,
0.052,
10,
false
);
const laceMaterial = new THREE.MeshStandardMaterial({
color: 0xff5b3d,
roughness: 0.58,
metalness: 0.02
});
const lace = new THREE.Mesh(laceGeometry, laceMaterial);
lace.name = "One continuous alternating lace";
lace.castShadow = true;
lace.receiveShadow = true;
scene.add(lace);
// Lacelet tips.
const agletMaterial = new THREE.MeshStandardMaterial({
color: 0x8f3429,
roughness: 0.5,
metalness: 0.08
});
for (const tip of [tailStart, tailEnd]) {
const aglet = new THREE.Mesh(unitBox, agletMaterial);
aglet.position.copy(tip);
aglet.scale.set(0.13, 0.085, 0.19);
aglet.rotation.y = tip.x < 0 ? -0.28 : 0.28;
aglet.castShadow = true;
scene.add(aglet);
}
// -------------------------------------------------------------------------
// Custom camera controls — no imported controls or addons
// -------------------------------------------------------------------------
const defaultView = {
theta: 0.67,
phi: 0.76,
radius: 10.6
};
const currentView = { ...defaultView };
const goalView = { ...defaultView };
const cameraTarget = new THREE.Vector3(0, 0.72, 0);
function updateCamera() {
const sinPhi = Math.sin(currentView.phi);
camera.position.set(
cameraTarget.x +
currentView.radius * sinPhi * Math.sin(currentView.theta),
cameraTarget.y + currentView.radius * Math.cos(currentView.phi),
cameraTarget.z +
currentView.radius * sinPhi * Math.cos(currentView.theta)
);
camera.lookAt(cameraTarget);
}
function setPerspectiveView() {
Object.assign(goalView, defaultView);
perspectiveButton.classList.add("active");
topButton.classList.remove("active");
}
function setTopView() {
goalView.theta = 0;
goalView.phi = 0.075;
goalView.radius = 9.2;
perspectiveButton.classList.remove("active");
topButton.classList.add("active");
}
const perspectiveButton = document.getElementById("perspective");
const topButton = document.getElementById("top");
perspectiveButton.addEventListener("click", setPerspectiveView);
topButton.addEventListener("click", setTopView);
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = "grabbing";
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
goalView.theta -= dx * 0.006;
goalView.phi = THREE.MathUtils.clamp(
goalView.phi - dy * 0.005,
0.075,
1.42
);
});
function releasePointer(event) {
dragging = false;
renderer.domElement.style.cursor = "grab";
if (event.pointerId !== undefined) {
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.style.cursor = "grab";
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
goalView.radius = THREE.MathUtils.clamp(
goalView.radius * Math.exp(event.deltaY * 0.001),
6.5,
17
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", setPerspectiveView);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
const smoothing = 1 - Math.exp(-dt * 11);
currentView.theta = THREE.MathUtils.lerp(
currentView.theta,
goalView.theta,
smoothing
);
currentView.phi = THREE.MathUtils.lerp(
currentView.phi,
goalView.phi,
smoothing
);
currentView.radius = THREE.MathUtils.lerp(
currentView.radius,
goalView.radius,
smoothing
);
updateCamera();
renderer.render(scene, camera);
}
updateCamera();
animate();
</script>
</body>
</html>
```