Prompt specification
Build or customize the Three.js 3D scene "Two Fishers and One Renewal Step" 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: Two Fishers and One Renewal Step
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/two-fishers-and-one-renewal-step-x3130
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows shared renewable resources and collective withdrawal rules. Animate two boats removing fish under a stated discrete rule, followed by limited renewal. Conserve token counts and prevent regeneration from exceeding the declared carrying capacity. Voxel style.
Working Three.js Starter (two-fishers-and-one-renewal-step-x3130):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Shared Renewable Lagoon</title>
<style>
:root {
--ink:#16313a; --panel:#f7f4e8; --edge:#294b55;
--a:#ef6f4c; --b:#4f8fbd; --green:#48a36b; --gold:#e5b84b;
}
* { box-sizing:border-box }
html,body { margin:0; width:100%; height:100%; overflow:hidden; background:#b9e2e7 }
body { font-family:ui-monospace,SFMono-Regular,Consolas,monospace; color:var(--ink) }
canvas { display:block; width:100%; height:100%; touch-action:none }
.panel {
position:fixed; z-index:5; pointer-events:none;
background:rgba(247,244,232,.95); border:3px solid var(--edge);
box-shadow:6px 6px 0 rgba(22,49,58,.18);
}
h1 { margin:0 0 5px; font-size:clamp(16px,2vw,25px); letter-spacing:.04em }
h2 { margin:0 0 9px; font-size:14px; text-transform:uppercase; letter-spacing:.08em }
p { margin:6px 0; font-size:12px; line-height:1.45 }
.title { top:14px; left:14px; padding:12px 15px; max-width:440px }
.subtitle { font-size:11px; opacity:.75 }
.rules { top:14px; right:14px; width:345px; padding:13px }
.badge {
display:inline-block; padding:4px 8px; background:var(--green); color:white;
border:2px solid var(--edge); font-weight:800; font-size:12px
}
ol { margin:8px 0; padding-left:21px; font-size:12px; line-height:1.5 }
.equation {
margin-top:9px; padding:8px; background:#dcebe2; border-left:5px solid var(--green);
font-size:12px; font-weight:800
}
.capacity { margin-top:10px; padding-top:9px; border-top:2px solid #9baea6 }
.meter { height:17px; margin:6px 0; background:#d3ded7; border:2px solid var(--edge) }
#stockFill { display:block; height:100%; width:0; background:var(--green); transition:width .25s }
.capacity-row { display:flex; justify-content:space-between; font-size:12px }
.status { left:50%; bottom:14px; transform:translateX(-50%); width:min(610px,calc(100% - 28px)); padding:11px 14px }
.steps { display:flex; gap:7px; margin-bottom:8px }
.step { flex:1; padding:6px; border:2px solid #9baea6; background:#e5e8de; font-size:10px; text-align:center; font-weight:800 }
.step.active { border-color:var(--edge); background:#fff0a9 }
.step.done { background:#bfe1c8 }
#statusLine { min-height:34px; font-size:12px; line-height:1.4 }
.controls { position:fixed; z-index:8; left:14px; bottom:14px; display:flex; gap:7px }
button {
pointer-events:auto; cursor:pointer; padding:8px 10px; border:3px solid var(--edge);
background:var(--panel); color:var(--ink); font:700 11px ui-monospace,monospace;
box-shadow:3px 3px 0 rgba(22,49,58,.2)
}
button:hover { background:#fff0a9 }
button:active { transform:translate(2px,2px); box-shadow:none }
.hint { position:fixed; z-index:4; right:14px; bottom:14px; padding:7px 9px; background:rgba(247,244,232,.85); font-size:10px }
.world-label {
position:fixed; z-index:3; pointer-events:none; transform:translate(-50%,-100%);
padding:4px 7px; border:2px solid var(--edge); background:rgba(247,244,232,.92);
font-size:10px; font-weight:800; white-space:nowrap
}
#labelA { background:var(--a); color:white }
#labelB { background:var(--b); color:white }
#labelReef { background:#ffd36b }
#labelLagoon { background:#d9f3f5 }
@media(max-width:760px) {
.title { top:8px; left:8px; right:8px; max-width:none }
.rules { top:91px; left:8px; right:8px; width:auto; padding:9px }
.rules ol,.rules p,.equation { font-size:10px }
.status { bottom:62px; padding:8px }
.controls { left:8px; bottom:10px }
.hint { display:none }
}
</style>
</head>
<body>
<canvas id="scene"></canvas>
<section class="panel title">
<h1>SHARED RENEWABLE LAGOON</h1>
<div class="subtitle">Voxel commons · collective harvest · capacity-safe renewal</div>
</section>
<section class="panel rules">
<h2>Declared Rules</h2>
<span class="badge">CARRYING CAPACITY K = 24</span>
<ol>
<li>Both boats use the <b>same fish stock N</b>.</li>
<li>Joint withdrawal limit: <b>2 fish/round</b>. Boat A takes one if available, then Boat B takes one.</li>
<li>After withdrawal, at most <b>3 recruits</b> renew. The total may never exceed <b>24 fish</b>.</li>
</ol>
<div class="equation">N<sub>next</sub> = min(K, N − W + R)</div>
<div class="capacity">
<div class="capacity-row"><b>SHARED STOCK</b><b id="stockValue">0 / 24</b></div>
<div class="meter"><span id="stockFill"></span></div>
<div class="capacity-row"><span>A: <b id="aState">pending</b></span><span>B: <b id="bState">pending</b></span><span>Renewal: <b id="rState">pending</b></span></div>
</div>
</section>
<section class="panel status">
<div class="steps">
<div class="step" id="stepWithdraw">1 · JOINT WITHDRAWAL</div>
<div class="step" id="stepRenew">2 · LIMITED RENEWAL</div>
<div class="step" id="stepComplete">ROUND RESULT</div>
</div>
<div id="statusLine" aria-live="polite">Starting the shared-stock cycle…</div>
</section>
<div class="controls">
<button id="pause">Pause</button>
<button id="restart">Restart</button>
<button id="view">Reset view</button>
</div>
<div class="hint">Drag: orbit · Wheel: zoom · Double-click: reset view</div>
<div id="labelA" class="world-label">BOAT A</div>
<div id="labelB" class="world-label">BOAT B</div>
<div id="labelReef" class="world-label">RENEWAL CORAL · +3 MAX</div>
<div id="labelLagoon" class="world-label">SHARED LAGOON</div>
<script type="module">
import * as THREE from 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js';
const K = 24, INITIAL = 16, RENEWAL_LIMIT = 3;
const canvas = document.querySelector('#scene');
const renderer = new THREE.WebGLRenderer({canvas, antialias:true});
renderer.setPixelRatio(Math.min(devicePixelRatio,2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
const scene = new THREE.Scene();
scene.background = new THREE.Color('#b9e2e7');
scene.fog = new THREE.Fog('#b9e2e7',35,58);
const camera = new THREE.OrthographicCamera(-16,16,10,-10,.1,100);
const target = new THREE.Vector3(0,0,0);
let azimuth=.55, polar=.88, zoom=1;
function updateCamera() {
camera.position.set(
30*Math.sin(polar)*Math.sin(azimuth),
30*Math.cos(polar),
30*Math.sin(polar)*Math.cos(azimuth)
);
camera.lookAt(target);
camera.zoom=zoom;
camera.updateProjectionMatrix();
camera.updateMatrixWorld();
}
updateCamera();
scene.add(new THREE.HemisphereLight('#e8ffff','#6f855c',2.0));
const sun = new THREE.DirectionalLight('#fff3cf',3.1);
sun.position.set(-8,17,9); sun.castShadow=true;
sun.shadow.mapSize.set(2048,2048);
sun.shadow.camera.left=-16; sun.shadow.camera.right=16;
sun.shadow.camera.top=14; sun.shadow.camera.bottom=-14;
scene.add(sun);
const mats = new Map();
function mat(color) {
if(!mats.has(color)) mats.set(color,new THREE.MeshStandardMaterial({
color, roughness:.82, metalness:0, flatShading:true
}));
return mats.get(color);
}
function cube(parent,w,h,d,x,y,z,color) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w,h,d),
color?.isMaterial ? color : mat(color));
mesh.position.set(x,y,z);
mesh.castShadow=true; mesh.receiveShadow=true;
parent.add(mesh);
return mesh;
}
// Voxel landscape and tiled water.
cube(scene,23,.8,17,0,-.65,0,'#78a765');
cube(scene,22,.3,15.5,0,-.18,0,'#d8c487');
for(let x=0;x<6;x++) for(let z=0;z<4;z++) {
cube(scene,2.96,.18,2.96,-7.5+x*3,-.02,-4.5+z*3,
(x+z)%2 ? '#55bfd0' : '#62cbd8');
}
cube(scene,2,.28,15,-10,0,0,'#e5d39a');
cube(scene,2,.28,15,10,0,0,'#e5d39a');
cube(scene,18,.28,2,0,0,-7,'#e5d39a');
cube(scene,18,.28,2,0,0,7,'#e5d39a');
function tree(x,z,scale=1) {
const g=new THREE.Group(); g.position.set(x,0,z); g.scale.setScalar(scale); scene.add(g);
cube(g,.45,2,.45,0,1,0,'#79583d');
cube(g,2.1,1.2,2.1,0,2.2,0,'#3f8b52');
cube(g,1.45,.8,1.45,.15,3.05,0,'#5ca965');
cube(g,1.15,.65,1.15,-.15,3.55,0,'#79bd70');
}
tree(-9.2,-6.3,1.15); tree(9.1,-6.3,1.25);
tree(-9.3,6.4,.9); tree(9.2,6.5,1);
for(const x of [-9,-3,3,9]) {
cube(scene,.22,.8,.22,x,.3,-6.05,'#6c5839');
cube(scene,.38,.25,.38,x,.72,-6.05,'#e8b84c');
}
// Renewal coral: recruits enter the shared stock here.
const reef = new THREE.Group(); reef.position.set(0,.08,2.7); scene.add(reef);
cube(reef,1.4,.25,1.4,0,.1,0,'#b67c45');
cube(reef,.45,.8,.45,-.35,.55,0,'#ef8b45');
cube(reef,.45,1.15,.45,.25,.68,0,'#f3b54a');
cube(reef,.4,.7,.4,.62,.45,0,'#e96d4c');
cube(reef,.35,.55,.35,-.68,.38,0,'#ffd16a');
// Two voxel boats.
function makeBoat(x,z,rot,color,name,label) {
const g=new THREE.Group(); g.position.set(x,.2,z); g.rotation.y=rot; scene.add(g);
cube(g,2.8,.35,1.2,0,0,0,color);
cube(g,2.45,.22,1.02,0,-.22,0,'#7e4438');
cube(g,.5,.3,.82,1.52,.02,0,color);
cube(g,.75,.7,.8,-.35,.52,0,'#f1e6c8');
cube(g,.9,.16,.95,-.35,.94,0,'#324f56');
cube(g,.28,.38,.28,-.35,.73,.42,'#e0a16e');
cube(g,.32,.3,.32,-.35,1.05,.42,'#273b43');
cube(g,.18,.9,.18,.7,.45,0,'#79583d');
const cargo=cube(g,.42,.2,.35,.65,.32,0,'#f39b3e'); cargo.visible=false;
return {group:g,cargo,total:0,label,baseY:.2};
}
const boatA=makeBoat(-6.8,1.5,-.28,'#e96543','A',document.querySelector('#labelA'));
const boatB=makeBoat(6.5,-1.7,2.78,'#397eae','B',document.querySelector('#labelB'));
// Fish pool. Exactly K fish objects exist; the stock counter controls visibility.
let seed=8192;
function rand(a=0,b=1) {
seed=(seed*1664525+1013904223)>>>0;
return a+(b-a)*(seed/4294967296);
}
const fishPool=[];
for(let i=0;i<K;i++) {
const g=new THREE.Group();
const color=i%3===0?'#f3b84b':i%3===1?'#ed7d45':'#ffd36b';
cube(g,.72,.24,.28,0,0,0,color);
cube(g,.22,.28,.12,-.43,0,0,color);
cube(g,.2,.34,.1,-.61,.03,0,color);
cube(g,.14,.3,.1,.02,.22,0,color);
cube(g,.09,.09,.06,.25,.04,.155,'#20363d');
cube(g,.09,.09,.06,.25,.04,-.155,'#20363d');
g.visible=false; scene.add(g);
fishPool.push({
group:g, active:false, state:'inactive', base:new THREE.Vector3(),
phase:rand(0,Math.PI*2), speed:rand(.55,1.05), direction:rand()>.5?1:-1
});
}
let stock=0, round=1, phase='A', phaseTime=0, phaseLength=1.55;
let roundWithdrawal=0, renewalAdmitted=0, renewalSpawned=0;
let catchState=null, paused=false, elapsed=0;
const reefSource=new THREE.Vector3(0,.35,2.7);
const statusLine=document.querySelector('#statusLine');
const stockValue=document.querySelector('#stockValue');
const stockFill=document.querySelector('#stockFill');
const aState=document.querySelector('#aState');
const bState=document.querySelector('#bState');
const rState=document.querySelector('#rState');
const stepWithdraw=document.querySelector('#stepWithdraw');
const stepRenew=document.querySelector('#stepRenew');
const stepComplete=document.querySelector('#stepComplete');
function announce(text) { statusLine.textContent=text; }
function updateHUD() {
stockValue.textContent=`${stock} / ${K}`;
stockFill.style.width=`${stock/K*100}%`;
stockFill.style.background=stock===K?'#d79c32':'#48a36b';
aState.textContent=roundWithdrawal>=1?'1 landed':'pending';
bState.textContent=roundWithdrawal>=2?'1 landed':'pending';
rState.textContent=renewalAdmitted?`+${renewalAdmitted}`:'pending';
boatA.label.textContent=`BOAT A · ${boatA.total} landed`;
boatB.label.textContent=`BOAT B · ${boatB.total} landed`;
boatA.cargo.visible=boatA.total>0;
boatB.cargo.visible=boatB.total>0;
}
function activateFish(f,animate=true) {
f.base.set(rand(-7.2,7.2),.35,rand(-4.2,4.2));
f.active=true; f.state=animate?'spawning':'swimming'; f.spawnTime=0;
f.group.visible=true; f.group.scale.setScalar(animate?.05:1);
f.group.position.copy(animate?reefSource:f.base);
stock++; updateHUD();
}
function beginCatch(boat) {
const choices=fishPool.filter(f=>f.active && f.state!=='caught');
if(!choices.length) return;
const fish=choices[Math.floor(rand(0,choices.length))];
fish.state='caught';
const end=boat.group.localToWorld(new THREE.Vector3(0,.5,0));
catchState={fish,boat,start:fish.group.position.clone(),end,time:0,done:false};
}
function enterPhase(next) {
phase=next; phaseTime=0;
stepWithdraw.className='step'; stepRenew.className='step'; stepComplete.className='step';
if(next==='A') {
phaseLength=1.55; roundWithdrawal=0;
stepWithdraw.classList.add('active');
announce(`Round ${round}: shared stock is ${stock}. Boat A may withdraw one fish.`);
} else if(next==='B') {
phaseLength=1.55;
announce(`Boat A: ${roundWithdrawal?1:0}. Boat B may now withdraw one remaining fish.`);
} else if(next==='renew') {
phaseLength=2.35;
renewalAdmitted=Math.min(RENEWAL_LIMIT,K-stock); // hard capacity guard
renewalSpawned=0;
stepRenew.classList.add('active');
announce(`Renewal requested: +${RENEWAL_LIMIT}; admitted +${renewalAdmitted}. Stock cannot exceed ${K}.`);
} else {
phaseLength=1.4;
stepWithdraw.classList.add('done'); stepRenew.classList.add('done');
stepComplete.classList.add('active');
announce(`Round ${round} complete: withdrew ${roundWithdrawal}, admitted ${renewalAdmitted} recruits, stock ${stock}/${K}.`);
}
updateHUD();
}
function completeCatch(cs) {
cs.done=true;
cs.fish.active=false; cs.fish.state='inactive'; cs.fish.group.visible=false;
stock=Math.max(0,stock-1);
cs.boat.total++; roundWithdrawal++;
cs.boat.cargo.visible=true;
announce(`${cs.boat===boatA?'Boat A':'Boat B'} landed one fish. Shared stock: ${stock}/${K}.`);
updateHUD();
catchState=null;
}
function updateSimulation(dt) {
phaseTime+=dt;
if(phase==='A' && roundWithdrawal===0 && !catchState && stock>0) beginCatch(boatA);
if(phase==='B' && roundWithdrawal===1 && !catchState && stock>0) beginCatch(boatB);
if(phase==='renew') {
while(renewalSpawned<renewalAdmitted && phaseTime>=.35+renewalSpawned*.58) {
const inactive=fishPool.find(f=>!f.active);
if(inactive) activateFish(inactive,true);
renewalSpawned++;
}
}
if(phaseTime>=phaseLength) {
if(phase==='A') enterPhase('B');
else if(phase==='B') enterPhase('renew');
else if(phase==='renew') enterPhase('hold');
else { round++; enterPhase('A'); }
}
}
function updateFish(dt) {
for(const f of fishPool) {
if(!f.active || f.state==='caught') continue;
if(f.state==='spawning') {
f.spawnTime+=dt;
const p=Math.min(1,f.spawnTime/.95), e=1-Math.pow(1-p,3);
f.group.position.lerpVectors(reefSource,f.base,e);
f.group.position.y+=Math.sin(Math.PI*p)*.5;
f.group.scale.setScalar(.05+.95*e);
if(p===1) f.state='swimming';
} else {
f.group.position.set(
f.base.x+Math.sin(elapsed*f.speed+f.phase)*.38,
f.base.y+Math.sin(elapsed*1.8+f.phase)*.025,
f.base.z+Math.cos(elapsed*f.speed*.8+f.phase)*.28
);
f.group.rotation.y=f.direction>0?0:Math.PI;
}
}
}
function updateCatch(dt) {
if(!catchState || catchState.done) return;
const cs=catchState; cs.time+=dt;
const p=Math.min(1,cs.time/1.12), e=p*p*(3-2*p);
cs.fish.group.position.lerpVectors(cs.start,cs.end,e);
cs.fish.group.position.y+=Math.sin(Math.PI*p)*.72;
cs.fish.group.rotation.y=Math.atan2(-(cs.end.z-cs.start.z),cs.end.x-cs.start.x);
if(p===1) completeCatch(cs);
}
function updateBoats() {
for(const [i,b] of [boatA,boatB].entries()) {
b.group.position.y=b.baseY+Math.sin(elapsed*1.7+i*2)*.035;
b.group.rotation.z=Math.sin(elapsed*1.2+i)*.012;
}
reef.rotation.y=Math.sin(elapsed*.5)*.08;
reef.children.forEach((m,i)=>{ if(i>0) m.scale.y=1+Math.sin(elapsed*2+i)*.08; });
}
// Direct orbit and zoom controls; no add-ons are loaded.
let dragging=false, lastX=0, lastY=0;
canvas.addEventListener('pointerdown',e=>{
dragging=true; lastX=e.clientX; lastY=e.clientY; canvas.setPointerCapture(e.pointerId);
});
canvas.addEventListener('pointermove',e=>{
if(!dragging) return;
azimuth-=(e.clientX-lastX)*.006;
polar=THREE.MathUtils.clamp(polar+(e.clientY-lastY)*.005,.48,1.32);
lastX=e.clientX; lastY=e.clientY; updateCamera();
});
canvas.addEventListener('pointerup',()=>dragging=false);
canvas.addEventListener('pointercancel',()=>dragging=false);
canvas.addEventListener('wheel',e=>{
e.preventDefault(); zoom=THREE.MathUtils.clamp(zoom*Math.exp(-e.deltaY*.001),.65,1.8); updateCamera();
},{passive:false});
function resetView(){ azimuth=.55; polar=.88; zoom=1; updateCamera(); }
canvas.addEventListener('dblclick',resetView);
function projectLabel(el,pos) {
const p=pos.clone().project(camera);
const visible=p.z>-1 && p.z<1;
el.style.display=visible?'block':'none';
el.style.left=`${(p.x*.5+.5)*innerWidth}px`;
el.style.top=`${(-p.y*.5+.5)*innerHeight}px`;
}
function updateLabels() {
projectLabel(boatA.label,boatA.group.position.clone().add(new THREE.Vector3(0,2.1,0)));
projectLabel(boatB.label,boatB.group.position.clone().add(new THREE.Vector3(0,2.1,0)));
projectLabel(document.querySelector('#labelReef'),reef.position.clone().add(new THREE.Vector3(0,1.65,0)));
projectLabel(document.querySelector('#labelLagoon'),new THREE.Vector3(0,.2,-5.1));
}
function resize() {
const w=innerWidth,h=innerHeight,aspect=w/h;
renderer.setSize(w,h,false);
const span=aspect<1.2?23/aspect:18;
camera.left=-span*aspect/2; camera.right=span*aspect/2;
camera.top=span/2; camera.bottom=-span/2;
camera.updateProjectionMatrix();
}
addEventListener('resize',resize); resize();
function restart() {
paused=false; document.querySelector('#pause').textContent='Pause';
catchState=null; stock=0; round=1; renewalAdmitted=0; renewalSpawned=0;
fishPool.forEach(f=>{ f.active=false; f.state='inactive'; f.group.visible=false; });
for(let i=0;i<INITIAL;i++) activateFish(fishPool[i],false);
boatA.total=boatB.total=0; updateHUD(); enterPhase('A');
}
document.querySelector('#pause').onclick=()=>{
paused=!paused;
document.querySelector('#pause').textContent=paused?'Resume':'Pause';
announce(paused?'Simulation paused. Camera remains interactive.':'Simulation resumed.');
};
document.querySelector('#restart').onclick=restart;
document.querySelector('#view').onclick=resetView;
restart();
const clock=new THREE.Clock();
function frame() {
requestAnimationFrame(frame);
const dt=Math.min(clock.getDelta(),.05);
if(!paused) {
elapsed+=dt; updateBoats(); updateFish(dt); updateSimulation(dt); updateCatch(dt);
}
updateLabels();
renderer.render(scene,camera);
}
frame();
</script>
</body>
</html>
```