Prompt specification
Build or customize the Three.js 3D scene "Family resemblance fictional creature exhibit" 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: Family resemblance fictional creature exhibit
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/family-resemblance-fictional-creature-exhibit-x0955
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring sexual reproduction and genetic variation. Compose siblings built from recombined symbolic parental features, with all organisms invented; show shared ancestry alongside varied combinations without implying exact genetics for complex real traits. Voxel style.
Working Three.js Starter (family-resemblance-fictional-creature-exhibit-x0955):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mosaic Kin — Symbolic Recombination</title>
<style>
:root {
color-scheme: dark;
--bg: #07111f;
--panel: rgba(9, 22, 38, 0.86);
--panel-border: rgba(126, 188, 223, 0.2);
--text: #eaf6ff;
--muted: #91aabd;
--amber: #f5b94f;
--mint: #5de1d1;
--white: #eefaff;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--text);
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
outline: none;
}
.brand {
position: fixed;
z-index: 10;
top: 22px;
left: 24px;
width: min(430px, calc(100vw - 48px));
pointer-events: none;
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 6px 10px;
border: 1px solid rgba(93, 225, 209, 0.28);
border-radius: 999px;
background: rgba(10, 30, 44, 0.74);
color: #a6f4e9;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 7px;
height: 7px;
background: var(--mint);
box-shadow: 0 0 13px var(--mint);
}
h1 {
margin: 12px 0 7px;
font-size: clamp(29px, 3.3vw, 50px);
line-height: 0.98;
letter-spacing: -0.045em;
}
.brand p {
max-width: 390px;
margin: 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.toolbar {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 16px;
pointer-events: auto;
}
.tool-button {
min-height: 36px;
padding: 8px 12px;
color: var(--text);
background: rgba(15, 34, 53, 0.92);
border: 1px solid rgba(132, 191, 225, 0.24);
border-radius: 9px;
cursor: pointer;
transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}
.tool-button:hover {
border-color: rgba(132, 213, 235, 0.6);
background: rgba(21, 48, 68, 0.96);
transform: translateY(-1px);
}
.tool-button.primary {
color: #10202b;
background: linear-gradient(135deg, #74eadc, #b5f5eb);
border-color: transparent;
font-weight: 800;
}
.tool-button[aria-pressed="false"] {
color: #7891a5;
}
.panel {
position: fixed;
z-index: 9;
padding: 16px;
background: var(--panel);
border: 1px solid var(--panel-border);
border-radius: 14px;
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(16px);
}
.panel h2 {
margin: 0 0 4px;
font-size: 14px;
letter-spacing: 0.02em;
}
.panel-intro {
margin: 0 0 12px;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.donor-panel {
top: 225px;
left: 24px;
width: 255px;
}
.donor-grid {
display: grid;
gap: 8px;
}
.donor-card {
padding: 10px;
border-radius: 10px;
border: 1px solid rgba(255, 255, 255, 0.07);
background: rgba(255, 255, 255, 0.025);
}
.donor-card.a {
border-left: 3px solid var(--amber);
}
.donor-card.b {
border-left: 3px solid var(--mint);
}
.donor-title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
font-size: 12px;
font-weight: 800;
}
.donor-token {
font-size: 9px;
color: var(--muted);
letter-spacing: 0.12em;
text-transform: uppercase;
}
.mini-traits {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 5px 8px;
}
.mini-trait {
min-width: 0;
color: #a9bfce;
font-size: 9px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.mini-trait strong {
color: #edf8ff;
font-weight: 700;
}
.detail-panel {
top: 24px;
right: 24px;
width: 335px;
max-height: calc(100vh - 48px);
overflow: auto;
}
.detail-title {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
}
#selectedName {
margin: 0;
font-size: 25px;
letter-spacing: -0.035em;
}
#selectedSummary {
color: var(--muted);
font-size: 11px;
white-space: nowrap;
}
.token-strip {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 5px;
margin: 14px 0 12px;
}
.token {
height: 13px;
border-radius: 3px;
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.token.a {
background: var(--amber);
}
.token.b {
background: var(--mint);
}
.token-caption {
display: flex;
justify-content: space-between;
color: #7894a8;
font-size: 9px;
text-transform: uppercase;
letter-spacing: 0.08em;
}
.trait-list {
display: grid;
gap: 5px;
margin-top: 11px;
}
.trait-row {
display: grid;
grid-template-columns: 82px 1fr 42px;
align-items: center;
min-height: 31px;
padding: 5px 7px;
border-radius: 7px;
background: rgba(255, 255, 255, 0.028);
font-size: 10px;
}
.trait-label {
color: var(--muted);
}
.trait-value {
color: #effaff;
font-weight: 700;
}
.source-tag {
justify-self: end;
padding: 3px 6px;
border-radius: 5px;
color: #10202a;
font-size: 9px;
font-weight: 900;
}
.source-tag.a {
background: var(--amber);
}
.source-tag.b {
background: var(--mint);
}
.sibling-heading {
margin: 17px 0 8px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.sibling-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
}
.sibling-button {
padding: 8px 7px;
color: #bad0df;
background: rgba(255, 255, 255, 0.03);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 8px;
cursor: pointer;
text-align: left;
}
.sibling-button:hover,
.sibling-button.active {
border-color: rgba(174, 231, 244, 0.65);
background: rgba(67, 124, 151, 0.16);
color: white;
}
.sibling-number {
display: block;
margin-bottom: 5px;
font-size: 10px;
font-weight: 850;
}
.sibling-pattern {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 2px;
}
.sibling-pattern i {
height: 5px;
border-radius: 1px;
}
.sibling-pattern i.a {
background: var(--amber);
}
.sibling-pattern i.b {
background: var(--mint);
}
.disclaimer {
margin: 14px 0 0;
padding-top: 12px;
border-top: 1px solid rgba(255, 255, 255, 0.08);
color: #829bae;
font-size: 10px;
line-height: 1.5;
}
#labelLayer {
position: fixed;
inset: 0;
z-index: 6;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
left: 0;
top: 0;
transform: translate(-50%, -50%);
padding: 5px 8px;
border: 1px solid rgba(145, 202, 228, 0.2);
border-radius: 7px;
background: rgba(5, 16, 29, 0.78);
color: #d7ebf5;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
box-shadow: 0 5px 18px rgba(0, 0, 0, 0.18);
}
.world-label.root {
color: #fff2c4;
border-color: rgba(245, 185, 79, 0.35);
}
.world-label.a {
color: #ffd991;
border-color: rgba(245, 185, 79, 0.34);
}
.world-label.b {
color: #a4fff4;
border-color: rgba(93, 225, 209, 0.34);
}
.world-label.child {
pointer-events: auto;
cursor: pointer;
padding: 4px 7px;
color: #dbeefa;
background: rgba(8, 24, 39, 0.7);
}
.world-label.child.selected {
color: white;
border-color: rgba(255, 255, 255, 0.65);
background: rgba(32, 76, 94, 0.9);
}
.timeline {
position: fixed;
z-index: 8;
left: 50%;
bottom: 22px;
transform: translateX(-50%);
display: flex;
align-items: center;
gap: 9px;
padding: 10px 13px;
border: 1px solid var(--panel-border);
border-radius: 12px;
background: rgba(6, 18, 32, 0.83);
backdrop-filter: blur(14px);
box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
}
.timeline-step {
display: flex;
align-items: center;
gap: 6px;
color: #a9c0ce;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.06em;
text-transform: uppercase;
white-space: nowrap;
}
.timeline-dot {
width: 8px;
height: 8px;
border: 2px solid #8ccfe2;
background: #112c3b;
transform: rotate(45deg);
}
.timeline-step:first-child .timeline-dot {
border-color: #f5d178;
background: #f5b94f;
}
.timeline-step:last-child .timeline-dot {
border-color: #5de1d1;
background: #5de1d1;
box-shadow: 0 0 12px rgba(93, 225, 209, 0.55);
}
.timeline-arrow {
color: #476477;
font-size: 11px;
}
.interaction-note {
position: fixed;
z-index: 8;
right: 25px;
bottom: 24px;
color: #6f899c;
font-size: 9px;
letter-spacing: 0.05em;
pointer-events: none;
}
@media (max-width: 1050px) {
.donor-panel {
width: 215px;
}
.detail-panel {
width: 300px;
}
.brand {
width: 350px;
}
.timeline-step {
font-size: 8px;
}
}
@media (max-width: 780px) {
.brand {
top: 14px;
left: 14px;
}
.brand p {
max-width: 290px;
font-size: 11px;
}
.toolbar {
margin-top: 10px;
}
.donor-panel {
display: none;
}
.detail-panel {
top: auto;
right: 12px;
bottom: 12px;
width: min(330px, calc(100vw - 24px));
max-height: 46vh;
}
.timeline,
.interaction-note {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel scene showing symbolic genetic recombination"></canvas>
<header class="brand">
<div class="eyebrow">Invented biparental sexual reproduction</div>
<h1>Mosaic Kin</h1>
<p>
A toy Luminid population shares an ancestor, while recombined gamete packets
produce visibly different siblings. Select a voxel organism to inspect its
symbolic trait-token pattern.
</p>
<div class="toolbar">
<button class="tool-button primary" id="newLitter">New meiosis</button>
<button class="tool-button" id="toggleAncestry" aria-pressed="true">Ancestry on</button>
<button class="tool-button" id="resetView">Reset view</button>
</div>
</header>
<aside class="panel donor-panel">
<h2>Two gamete donors</h2>
<p class="panel-intro">
Each donor contributes one symbolic token at every trait locus.
Recombination changes which donor supplies each token in a sibling.
</p>
<div class="donor-grid" id="donorCards"></div>
</aside>
<aside class="panel detail-panel">
<div class="detail-title">
<h2 id="selectedName">Sibling 01</h2>
<span id="selectedSummary"></span>
</div>
<div class="token-strip" id="tokenStrip" aria-label="Selected sibling token pattern"></div>
<div class="token-caption">
<span>Donor A tokens</span>
<span>Donor B tokens</span>
</div>
<div class="trait-list" id="traitRows"></div>
<div class="sibling-heading">Sibling patterns</div>
<div class="sibling-grid" id="siblingButtons"></div>
<p class="disclaimer">
Educational abstraction only. All organisms and trait names are invented.
A colored voxel represents a symbolic inheritance token, not a real gene,
chromosome, biological trait, or predictive model of complex inheritance.
</p>
</aside>
<div id="labelLayer"></div>
<div class="timeline" aria-label="Shared ancestry to varied siblings">
<div class="timeline-step"><span class="timeline-dot"></span>Shared root</div>
<span class="timeline-arrow">→</span>
<div class="timeline-step"><span class="timeline-dot"></span>Two donors</div>
<span class="timeline-arrow">→</span>
<div class="timeline-step"><span class="timeline-dot"></span>Gamete fusion</div>
<span class="timeline-arrow">→</span>
<div class="timeline-step"><span class="timeline-dot"></span>Varied siblings</div>
</div>
<div class="interaction-note">Drag to orbit · wheel to zoom · click a sibling</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Scene setup
// -------------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07111f);
scene.fog = new THREE.Fog(0x07111f, 20, 38);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemisphere = new THREE.HemisphereLight(0xa9dcff, 0x172333, 1.65);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff2d5, 2.5);
keyLight.position.set(-5, 11, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -13;
keyLight.shadow.camera.right = 13;
keyLight.shadow.camera.top = 11;
keyLight.shadow.camera.bottom = -11;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x5de1d1, 1.45);
rimLight.position.set(8, 6, -8);
scene.add(rimLight);
const warmLight = new THREE.PointLight(0xf5b94f, 18, 13, 2);
warmLight.position.set(-4, 3.4, -1.5);
scene.add(warmLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(34, 30),
new THREE.MeshStandardMaterial({
color: 0x091727,
roughness: 0.94,
metalness: 0.02
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.03;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(30, 30, 0x23465d, 0x102a3d);
grid.position.y = -0.005;
grid.material.transparent = true;
grid.material.opacity = 0.46;
scene.add(grid);
// -------------------------------------------------------------------------
// Materials and toy symbolic trait model
// -------------------------------------------------------------------------
const standard = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.72,
metalness: 0.04,
flatShading: true,
...options
});
const MAT = {
body: standard(0x26384b),
bodyLight: standard(0x344d61),
dark: standard(0x101b29),
black: standard(0x071018),
white: standard(0xf1fbff, { emissive: 0x284452, emissiveIntensity: 0.35 }),
amberShell: standard(0xd99831, { roughness: 0.62 }),
mintShell: standard(0x39b7aa, { roughness: 0.62 }),
amberSource: standard(0xf5b94f, {
emissive: 0xf5b94f,
emissiveIntensity: 0.38,
roughness: 0.55
}),
mintSource: standard(0x5de1d1, {
emissive: 0x5de1d1,
emissiveIntensity: 0.38,
roughness: 0.55
}),
pedestal: standard(0x142b3c),
pedestalEdge: standard(0x203f54),
spot: standard(0xb9d6d2),
fusion: standard(0xd9fbff, {
emissive: 0x9cecff,
emissiveIntensity: 0.7,
transparent: true,
opacity: 0.9
})
};
const donorColors = {
A: 0xf5b94f,
B: 0x5de1d1
};
// Every locus has one symbolic token from donor A and one from donor B.
const loci = [
{
key: "body",
label: "Body plan",
a: "block",
b: "tall",
aName: "Stack",
bName: "Spire"
},
{
key: "shell",
label: "Shell hue",
a: "amber",
b: "mint",
aName: "Amber",
bName: "Mint"
},
{
key: "crest",
label: "Crest",
a: "fan",
b: "horn",
aName: "Fan",
bName: "Horn"
},
{
key: "eyes",
label: "Eyes",
a: "twin",
b: "visor",
aName: "Twin",
bName: "Visor"
},
{
key: "spots",
label: "Markings",
a: "speck",
b: "plain",
aName: "Speckled",
bName: "Plain"
},
{
key: "tail",
label: "Tail",
a: "zig",
b: "fan",
aName: "Zig",
bName: "Fan"
}
];
const donorA = {
body: "block",
shell: "amber",
crest: "fan",
eyes: "twin",
spots: "speck",
tail: "zig"
};
const donorB = {
body: "tall",
shell: "mint",
crest: "horn",
eyes: "visor",
spots: "plain",
tail: "fan"
};
function addBox(parent, size, position, material, castShadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function createCreature(traits, scale = 1) {
const group = new THREE.Group();
const bodyHeight = traits.body === "tall" ? 1.16 : 0.82;
const bodyWidth = traits.body === "tall" ? 0.82 : 0.98;
const bodyDepth = 0.78;
const bodyBottom = 0.24;
const bodyCenter = bodyBottom + bodyHeight / 2;
const bodyTop = bodyBottom + bodyHeight;
const shellMaterial = traits.shell === "amber" ? MAT.amberShell : MAT.mintShell;
// Legs and torso.
addBox(group, [0.22, 0.25, 0.3], [-0.25, 0.13, 0.02], MAT.dark);
addBox(group, [0.22, 0.25, 0.3], [0.25, 0.13, 0.02], MAT.dark);
addBox(
group,
[bodyWidth, bodyHeight, bodyDepth],
[0, bodyCenter, 0],
traits.body === "tall" ? MAT.bodyLight : MAT.body
);
// Colored shell panels.
addBox(
group,
[bodyWidth * 0.82, 0.13, bodyDepth * 0.76],
[0, bodyTop + 0.055, -0.02],
shellMaterial
);
addBox(
group,
[0.11, bodyHeight * 0.72, bodyDepth * 0.76],
[-bodyWidth / 2 - 0.04, bodyCenter, -0.02],
shellMaterial
);
addBox(
group,
[0.11, bodyHeight * 0.72, bodyDepth * 0.76],
[bodyWidth / 2 + 0.04, bodyCenter, -0.02],
shellMaterial
);
// Eye symbols.
const frontZ = bodyDepth / 2 + 0.045;
if (traits.eyes === "twin") {
for (const x of [-0.22, 0.22]) {
addBox(group, [0.19, 0.19, 0.08], [x, bodyCenter + 0.12, frontZ], MAT.black);
addBox(group, [0.055, 0.065, 0.025], [x + 0.025, bodyCenter + 0.13, frontZ + 0.052], MAT.white);
}
} else {
addBox(group, [0.58, 0.17, 0.08], [0, bodyCenter + 0.12, frontZ], MAT.black);
addBox(group, [0.065, 0.055, 0.025], [-0.13, bodyCenter + 0.13, frontZ + 0.052], MAT.mintSource);
addBox(group, [0.065, 0.055, 0.025], [0.13, bodyCenter + 0.13, frontZ + 0.052], MAT.mintSource);
}
// Mouth.
addBox(group, [0.18, 0.035, 0.025], [0, bodyCenter - 0.16, frontZ + 0.03], MAT.dark);
// Crest symbol.
if (traits.crest === "fan") {
addBox(group, [0.13, 0.42, 0.13], [-0.2, bodyTop + 0.26, -0.03], shellMaterial);
addBox(group, [0.13, 0.54, 0.13], [0, bodyTop + 0.31, -0.03], shellMaterial);
addBox(group, [0.13, 0.42, 0.13], [0.2, bodyTop + 0.26, -0.03], shellMaterial);
} else {
addBox(group, [0.16, 0.57, 0.16], [0, bodyTop + 0.31, -0.03], shellMaterial);
addBox(group, [0.12, 0.18, 0.12], [-0.17, bodyTop + 0.13, -0.03], shellMaterial);
addBox(group, [0.12, 0.18, 0.12], [0.17, bodyTop + 0.13, -0.03], shellMaterial);
}
// Marking symbol.
if (traits.spots === "speck") {
const spots = [
[-0.23, 0.54, 0.12],
[0.19, 0.61, -0.05],
[-0.12, 0.36, -0.2],
[0.29, 0.39, 0.13],
[-0.3, 0.72, -0.12]
];
for (const spot of spots) {
addBox(
group,
[0.09, 0.09, 0.07],
[spot[0], spot[1], frontZ + 0.015],
MAT.spot
);
}
}
// Tail symbol.
if (traits.tail === "zig") {
addBox(group, [0.18, 0.18, 0.36], [0.12, 0.45, -bodyDepth / 2 - 0.15], shellMaterial);
addBox(group, [0.18, 0.18, 0.34], [-0.1, 0.65, -bodyDepth / 2 - 0.42], shellMaterial);
} else {
addBox(group, [0.17, 0.16, 0.4], [0, 0.48, -bodyDepth / 2 - 0.18], shellMaterial);
addBox(group, [0.17, 0.16, 0.36], [-0.22, 0.48, -bodyDepth / 2 - 0.38], shellMaterial);
addBox(group, [0.17, 0.16, 0.36], [0.22, 0.48, -bodyDepth / 2 - 0.38], shellMaterial);
}
group.scale.setScalar(scale);
return group;
}
function createPedestal(radius, accentMaterial) {
const group = new THREE.Group();
const base = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius * 1.12, 0.18, 8),
MAT.pedestal
);
base.position.y = 0.03;
base.castShadow = true;
base.receiveShadow = true;
group.add(base);
const rim = new THREE.Mesh(
new THREE.CylinderGeometry(radius * 0.93, radius * 0.93, 0.07, 8),
accentMaterial
);
rim.position.y = 0.145;
rim.castShadow = true;
group.add(rim);
return group;
}
// -------------------------------------------------------------------------
// Parents, common ancestor, and fusion marker
// -------------------------------------------------------------------------
const parentAGroup = new THREE.Group();
parentAGroup.position.set(-3.65, 0, -2.8);
parentAGroup.add(createPedestal(1.04, MAT.amberSource));
const parentAModel = createCreature(donorA, 1.08);
parentAGroup.add(parentAModel);
scene.add(parentAGroup);
const parentBGroup = new THREE.Group();
parentBGroup.position.set(3.65, 0, -2.8);
parentBGroup.add(createPedestal(1.04, MAT.mintSource));
const parentBModel = createCreature(donorB, 1.08);
parentBGroup.add(parentBModel);
scene.add(parentBGroup);
const rootGroup = new THREE.Group();
rootGroup.position.set(0, 0, -6.45);
const rootPedestal = createPedestal(0.72, MAT.amberSource);
rootGroup.add(rootPedestal);
const rootCubePositions = [
[0, 0.48, 0],
[-0.24, 0.48, 0],
[0.24, 0.48, 0],
[0, 0.7, 0],
[-0.24, 0.7, 0],
[0.24, 0.7, 0],
[0, 0.92, 0]
];
rootCubePositions.forEach((position, index) => {
addBox(
rootGroup,
[0.22, 0.22, 0.22],
position,
index % 2 ? MAT.mintSource : MAT.amberSource
);
});
scene.add(rootGroup);
const fusionPosition = new THREE.Vector3(0, 1.55, -0.35);
const fusionGroup = new THREE.Group();
fusionGroup.position.copy(fusionPosition);
const cubeCorners = [];
for (const x of [-0.22, 0.22]) {
for (const y of [-0.22, 0.22]) {
for (const z of [-0.22, 0.22]) cubeCorners.push([x, y, z]);
}
}
cubeCorners.forEach((position, index) => {
addBox(
fusionGroup,
[0.12, 0.12, 0.12],
position,
index % 2 ? MAT.mintSource : MAT.amberSource,
false
);
});
addBox(fusionGroup, [0.18, 0.18, 0.18], [0, 0, 0], MAT.fusion, false);
scene.add(fusionGroup);
// -------------------------------------------------------------------------
// Offspring and symbolic recombination patterns
// -------------------------------------------------------------------------
const childrenRoot = new THREE.Group();
scene.add(childrenRoot);
const ancestryRoot = new THREE.Group();
scene.add(ancestryRoot);
const childRecords = [];
const worldLabels = [];
let selectedIndex = 0;
let litterSeed = 1;
function mulberry32(seed) {
return function random() {
let value = seed += 0x6D2B79F5;
value = Math.imul(value ^ value >>> 15, value | 1);
value ^= value + Math.imul(value ^ value >>> 7, value | 61);
return ((value ^ value >>> 14) >>> 0) / 4294967296;
};
}
function makePattern(index) {
const random = mulberry32(litterSeed * 1009 + index * 97 + 41);
let source = random() > 0.5 ? "A" : "B";
const cuts = new Set([1 + Math.floor(random() * 5)]);
if (random() > 0.56) {
cuts.add(1 + Math.floor(random() * 5));
}
const pattern = [];
for (let locusIndex = 0; locusIndex < loci.length; locusIndex++) {
if (cuts.has(locusIndex)) {
source = source === "A" ? "B" : "A";
}
pattern.push(source);
}
if (pattern.every(value => value === pattern[0])) {
pattern[3] = pattern[3] === "A" ? "B" : "A";
}
return pattern;
}
function traitsFromPattern(pattern) {
const traits = {};
pattern.forEach((source, index) => {
traits[loci[index].key] = source === "A" ? loci[index].a : loci[index].b;
});
return traits;
}
function disposeGeometry(group) {
group.traverse(object => {
if (object.geometry) object.geometry.dispose();
if (object.material && object.material.userData?.temporary) {
object.material.dispose();
}
});
}
function removeLabel(entry) {
const index = worldLabels.indexOf(entry);
if (index !== -1) worldLabels.splice(index, 1);
entry.element.remove();
}
function addWorldLabel(text, className, position, onClick = null) {
const element = document.createElement("div");
element.className = `world-label ${className}`;
element.textContent = text;
if (onClick) {
element.addEventListener("click", onClick);
}
document.querySelector("#labelLayer").appendChild(element);
const entry = { element, position };
worldLabels.push(entry);
return entry;
}
addWorldLabel(
"Shared ancestral stock",
"root",
new THREE.Vector3(0, 1.55, -6.45)
);
addWorldLabel(
"Donor A",
"a",
new THREE.Vector3(-3.65, 2.05, -2.8)
);
addWorldLabel(
"Donor B",
"b",
new THREE.Vector3(3.65, 2.15, -2.8)
);
addWorldLabel(
"Gamete fusion",
"",
new THREE.Vector3(0, 2.3, -0.35)
);
function createDashedLine(points, color, opacity = 0.25, childIndex = null) {
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const material = new THREE.LineDashedMaterial({
color,
transparent: true,
opacity,
dashSize: 0.17,
gapSize: 0.11,
depthWrite: false
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
line.userData.childIndex = childIndex;
ancestryRoot.add(line);
return line;
}
const lineageLines = [];
function rebuildChildren() {
for (const record of childRecords) {
disposeGeometry(record.group);
childrenRoot.remove(record.group);
removeLabel(record.label);
}
childRecords.length = 0;
lineageLines.length = 0;
const xs = [-5.15, -3.1, -1.03, 1.03, 3.1, 5.15];
for (let index = 0; index < 6; index++) {
const pattern = makePattern(index);
const traits = traitsFromPattern(pattern);
const group = new THREE.Group();
group.position.set(xs[index], 0, 2.65);
group.userData.childIndex = index;
const pedestal = createPedestal(0.72, MAT.pedestalEdge);
group.add(pedestal);
const ringMaterial = standard(0x27445a, {
emissive: 0x000000,
emissiveIntensity: 0,
transparent: true,
opacity: 0.62
});
ringMaterial.userData.temporary = true;
for (let segment = 0; segment < 8; segment++) {
const angle = segment / 8 * Math.PI * 2;
const ringBox = addBox(
group,
[0.17, 0.035, 0.09],
[Math.sin(angle) * 0.78, 0.17, Math.cos(angle) * 0.78],
ringMaterial,
false
);
ringBox.rotation.y = angle;
}
// Six little provenance blocks mirror the selected sibling's token order.
for (let tokenIndex = 0; tokenIndex < pattern.length; tokenIndex++) {
const angle = -1.12 + tokenIndex / (pattern.length - 1) * 2.24;
addBox(
group,
[0.095, 0.075, 0.095],
[
Math.sin(angle) * 0.62,
0.225,
Math.cos(angle) * 0.62
],
pattern[tokenIndex] === "A" ? MAT.amberSource : MAT.mintSource,
false
);
}
const model = createCreature(traits, 0.78);
group.add(model);
childrenRoot.add(group);
const label = addWorldLabel(
`Sibling ${String(index + 1).padStart(2, "0")}`,
"child",
new THREE.Vector3(xs[index], 0.18, 3.58),
() => selectChild(index)
);
childRecords.push({
group,
model,
label,
ringMaterial,
pattern
});
}
// Shared root to the two donors.
lineageLines.push(
createDashedLine(
[
new THREE.Vector3(0, 0.08, -6.05),
new THREE.Vector3(-2.0, 0.08, -4.9),
new THREE.Vector3(-3.65, 0.08, -2.8)
],
0xf5d178,
0.5
)
);
lineageLines.push(
createDashedLine(
[
new THREE.Vector3(0, 0.08, -6.05),
new THREE.Vector3(2.0, 0.08, -4.9),
new THREE.Vector3(3.65, 0.08, -2.8)
],
0xf5d178,
0.5
)
);
// Every sibling shares both parental branches.
for (let index = 0; index < childRecords.length; index++) {
const childPosition = childRecords[index].group.position;
lineageLines.push(
createDashedLine(
[
new THREE.Vector3(-3.65, 0.08, -2.8),
new THREE.Vector3(-3.65 + (childPosition.x + 3.65) * 0.45, 0.08, -0.2),
new THREE.Vector3(childPosition.x, 0.08, childPosition.z)
],
donorColors.A,
0.17,
index
)
);
lineageLines.push(
createDashedLine(
[
new THREE.Vector3(3.65, 0.08, -2.8),
new THREE.Vector3(3.65 + (childPosition.x - 3.65) * 0.45, 0.08, -0.2),
new THREE.Vector3(childPosition.x, 0.08, childPosition.z)
],
donorColors.B,
0.17,
index
)
);
}
selectChild(selectedIndex);
}
function renderDonorCards() {
const card = (donor, label, className) => `
<div class="donor-card ${className}">
<div class="donor-title">
<span>${label}</span>
<span class="donor-token">Gamete donor</span>
</div>
<div class="mini-traits">
${loci.map(locus => `
<div class="mini-trait">
${locus.label}: <strong>${donor[locus.key] === locus.a ? locus.aName : locus.bName}</strong>
</div>
`).join("")}
</div>
</div>
`;
document.querySelector("#donorCards").innerHTML =
card(donorA, "Donor A", "a") + card(donorB, "Donor B", "b");
}
function selectChild(index) {
selectedIndex = index;
const record = childRecords[index];
if (!record) return;
const countA = record.pattern.filter(source => source === "A").length;
const countB = record.pattern.length - countA;
document.querySelector("#selectedName").textContent =
`Sibling ${String(index + 1).padStart(2, "0")}`;
document.querySelector("#selectedSummary").textContent =
`${countA} A · ${countB} B tokens`;
document.querySelector("#tokenStrip").innerHTML = record.pattern
.map(source => `<span class="token ${source.toLowerCase()}"></span>`)
.join("");
document.querySelector("#traitRows").innerHTML = loci.map((locus, locusIndex) => {
const source = record.pattern[locusIndex];
const valueName = source === "A" ? locus.aName : locus.bName;
return `
<div class="trait-row">
<span class="trait-label">${locus.label}</span>
<span class="trait-value">${valueName}</span>
<span class="source-tag ${source.toLowerCase()}">${source}</span>
</div>
`;
}).join("");
document.querySelector("#siblingButtons").innerHTML = childRecords
.map((child, childIndex) => `
<button
class="sibling-button ${childIndex === selectedIndex ? "active" : ""}"
data-child="${childIndex}"
aria-label="Select sibling ${childIndex + 1}"
>
<span class="sibling-number">${String(childIndex + 1).padStart(2, "0")}</span>
<span class="sibling-pattern">
${child.pattern.map(source => `<i class="${source.toLowerCase()}"></i>`).join("")}
</span>
</button>
`).join("");
document.querySelectorAll(".sibling-button").forEach(button => {
button.addEventListener("click", () => {
selectChild(Number(button.dataset.child));
});
});
childRecords.forEach((child, childIndex) => {
child.ringMaterial.color.setHex(
childIndex === selectedIndex ? 0xc9f8ff : 0x27445a
);
child.ringMaterial.emissive.setHex(
childIndex === selectedIndex ? 0x4acbd0 : 0x000000
);
child.ringMaterial.emissiveIntensity = childIndex === selectedIndex ? 0.75 : 0;
child.ringMaterial.opacity = childIndex === selectedIndex ? 1 : 0.45;
child.label.element.classList.toggle("selected", childIndex === selectedIndex);
});
for (const line of lineageLines) {
if (line.userData.childIndex === null) {
line.material.opacity = 0.5;
} else {
line.material.opacity = line.userData.childIndex === selectedIndex ? 0.88 : 0.14;
}
}
}
rebuildChildren();
renderDonorCards();
// -------------------------------------------------------------------------
// Moving gamete packets and selection sparkles
// -------------------------------------------------------------------------
const gametePackets = ["A", "B"].map(source => {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(0.18, 0.18, 0.18),
source === "A" ? MAT.amberSource : MAT.mintSource
);
mesh.castShadow = true;
scene.add(mesh);
return mesh;
});
const sparkleRoot = new THREE.Group();
scene.add(sparkleRoot);
const sparkles = [];
for (let index = 0; index < 6; index++) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(0.055, 0.055, 0.055),
MAT.fusion
);
sparkleRoot.add(mesh);
sparkles.push(mesh);
}
const tempPacket = new THREE.Vector3();
function quadraticPoint(out, p0, p1, p2, t) {
const inverse = 1 - t;
out.set(0, 0, 0)
.addScaledVector(p0, inverse * inverse)
.addScaledVector(p1, 2 * inverse * t)
.addScaledVector(p2, t * t);
return out;
}
// -------------------------------------------------------------------------
// Custom camera controls — no Three.js addons
// -------------------------------------------------------------------------
const cameraState = {
yaw: 0,
pitch: 0.47,
radius: 20.5,
target: new THREE.Vector3(0, 0.65, -1.45)
};
function updateCamera() {
const horizontal = cameraState.radius * Math.cos(cameraState.pitch);
camera.position.set(
cameraState.target.x + Math.sin(cameraState.yaw) * horizontal,
cameraState.target.y + Math.sin(cameraState.pitch) * cameraState.radius,
cameraState.target.z + Math.cos(cameraState.yaw) * horizontal
);
camera.lookAt(cameraState.target);
}
function resetCamera() {
cameraState.yaw = 0;
cameraState.pitch = 0.47;
cameraState.radius = 20.5;
cameraState.target.set(0, 0.65, -1.45);
updateCamera();
}
updateCamera();
let dragging = false;
let draggedDistance = 0;
let previousPointerX = 0;
let previousPointerY = 0;
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function setPointer(event) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function childIndexFromIntersection(intersection) {
let object = intersection.object;
while (object && object !== childrenRoot) {
if (object.userData.childIndex !== undefined) {
return object.userData.childIndex;
}
object = object.parent;
}
return null;
}
canvas.addEventListener("pointerdown", event => {
dragging = true;
draggedDistance = 0;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", event => {
if (dragging) {
const deltaX = event.clientX - previousPointerX;
const deltaY = event.clientY - previousPointerY;
draggedDistance += Math.abs(deltaX) + Math.abs(deltaY);
cameraState.yaw -= deltaX * 0.006;
cameraState.pitch = THREE.MathUtils.clamp(
cameraState.pitch + deltaY * 0.0045,
0.16,
1.08
);
previousPointerX = event.clientX;
previousPointerY = event.clientY;
} else {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(childrenRoot.children, true);
canvas.style.cursor = intersections.length ? "pointer" : "grab";
}
});
canvas.addEventListener("pointerup", event => {
dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
if (draggedDistance < 6) {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(childrenRoot.children, true);
if (intersections.length) {
const index = childIndexFromIntersection(intersections[0]);
if (index !== null) selectChild(index);
}
}
});
canvas.addEventListener("pointercancel", () => {
dragging = false;
});
canvas.addEventListener(
"wheel",
event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.012,
12,
29
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetCamera);
document.querySelector("#resetView").addEventListener("click", resetCamera);
document.querySelector("#newLitter").addEventListener("click", () => {
litterSeed++;
rebuildChildren();
});
const ancestryButton = document.querySelector("#toggleAncestry");
ancestryButton.addEventListener("click", () => {
ancestryRoot.visible = !ancestryRoot.visible;
ancestryButton.setAttribute("aria-pressed", String(ancestryRoot.visible));
ancestryButton.textContent = ancestryRoot.visible ? "Ancestry on" : "Ancestry off";
});
// -------------------------------------------------------------------------
// Labels, animation, and resize
// -------------------------------------------------------------------------
const projected = new THREE.Vector3();
function updateLabels() {
for (const entry of worldLabels) {
projected.copy(entry.position).project(camera);
const visible = projected.z >= -1 && projected.z <= 1;
entry.element.style.display = visible ? "block" : "none";
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
entry.element.style.left = `${x}px`;
entry.element.style.top = `${y}px`;
}
}
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
parentAModel.position.y = Math.sin(elapsed * 1.15) * 0.025;
parentBModel.position.y = Math.sin(elapsed * 1.15 + 1.8) * 0.025;
childRecords.forEach((record, index) => {
record.model.position.y = Math.sin(elapsed * 1.3 + index * 0.9) * 0.025;
});
fusionGroup.rotation.y = elapsed * 0.55;
fusionGroup.rotation.x = Math.sin(elapsed * 0.4) * 0.16;
const fusionPulse = 1 + Math.sin(elapsed * 2.4) * 0.07;
fusionGroup.scale.setScalar(fusionPulse);
const selectedChild = childRecords[selectedIndex];
const childPosition = selectedChild
? selectedChild.group.position
: new THREE.Vector3();
const donorPositions = [
parentAGroup.position.clone().add(new THREE.Vector3(0, 1.05, 0)),
parentBGroup.position.clone().add(new THREE.Vector3(0, 1.05, 0))
];
gametePackets.forEach((packet, index) => {
const phase = (elapsed * 0.25 + index * 0.5) % 1;
const donorPosition = donorPositions[index];
const childTarget = childPosition.clone().add(new THREE.Vector3(0, 0.72, 0));
if (phase < 0.5) {
const t = phase * 2;
const control = donorPosition.clone().lerp(fusionPosition, 0.5);
control.y += 1.35;
quadraticPoint(tempPacket, donorPosition, control, fusionPosition, t);
} else {
const t = (phase - 0.5) * 2;
const control = fusionPosition.clone().lerp(childTarget, 0.5);
control.y += 2.25;
quadraticPoint(tempPacket, fusionPosition, control, childTarget, t);
}
packet.position.copy(tempPacket);
packet.rotation.set(elapsed * 1.7, elapsed * 2.2, elapsed * 1.3);
packet.scale.setScalar(0.8 + Math.sin(phase * Math.PI) * 0.55);
});
sparkles.forEach((sparkle, index) => {
const angle = elapsed * 0.8 + index / sparkles.length * Math.PI * 2;
sparkle.position.set(
childPosition.x + Math.cos(angle) * 0.88,
0.36 + Math.sin(elapsed * 1.8 + index) * 0.16,
childPosition.z + Math.sin(angle) * 0.88
);
sparkle.rotation.set(elapsed, elapsed * 0.7, 0);
sparkle.scale.setScalar(0.7 + Math.sin(elapsed * 3 + index) * 0.2);
});
updateCamera();
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
</script>
</body>
</html>
```