Prompt specification
Build or customize the Three.js 3D scene "Table sharing negotiation demo" 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: Table sharing negotiation demo
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/table-sharing-negotiation-demo-x0222
Scene Description Prompt:
I'd like to see this as a low-poly Three.js scene: table sharing negotiation demo. Slide a divider between two sets of objects as their needed areas change; visibly preserve a small shared central space for tools used by both sides. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (table-sharing-negotiation-demo-x0222):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Shared Table — Negotiation Demo</title>
<style>
:root {
--ink: #263238;
--muted: #6f7775;
--paper: rgba(250, 248, 241, 0.92);
--line: rgba(38, 50, 56, 0.12);
--blue: #3f7892;
--blue-soft: #dceaf0;
--coral: #d86f5d;
--coral-soft: #f6e2dd;
--gold: #d89a35;
--gold-soft: #fff0cd;
--green: #4f8c70;
--red: #b94e43;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9e4d8;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
z-index: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
.hero {
position: fixed;
top: 26px;
left: 30px;
z-index: 3;
width: min(520px, calc(100vw - 410px));
pointer-events: none;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}
.eyebrow {
margin: 0 0 7px;
color: #68716e;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
h1 {
margin: 0;
max-width: 480px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 4vw, 52px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.hero p:last-child {
max-width: 450px;
margin: 12px 0 0;
color: #5f6865;
font-size: 14px;
line-height: 1.45;
}
.panel {
position: fixed;
z-index: 5;
top: 20px;
right: 20px;
bottom: 20px;
width: 350px;
overflow: auto;
padding: 20px;
border: 1px solid rgba(255, 255, 255, 0.75);
border-radius: 22px;
background: var(--paper);
box-shadow:
0 18px 50px rgba(45, 49, 44, 0.14),
inset 0 0 0 1px rgba(48, 55, 50, 0.04);
backdrop-filter: blur(16px) saturate(1.1);
scrollbar-width: thin;
scrollbar-color: rgba(38, 50, 56, 0.22) transparent;
}
.panel-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
margin-bottom: 18px;
}
.panel-head h2 {
margin: 2px 0 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 25px;
font-weight: 500;
letter-spacing: -0.02em;
}
.live-dot {
display: inline-flex;
align-items: center;
gap: 6px;
margin-top: 4px;
padding: 6px 8px;
border: 1px solid var(--line);
border-radius: 999px;
color: #69716e;
background: rgba(255, 255, 255, 0.45);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
}
.live-dot::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 0 4px rgba(79, 140, 112, 0.12);
content: "";
}
.control {
padding: 15px 0;
border-top: 1px solid var(--line);
}
.control:first-of-type {
border-top: 0;
padding-top: 0;
}
.control-label {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
margin-bottom: 10px;
}
.control-label strong {
font-size: 13px;
font-weight: 750;
}
.control-label output {
color: var(--muted);
font-size: 12px;
font-weight: 700;
white-space: nowrap;
}
.range-wrap {
position: relative;
padding: 4px 0 2px;
}
input[type="range"] {
--fill: 50%;
width: 100%;
height: 18px;
margin: 0;
border-radius: 999px;
outline: none;
background: transparent;
cursor: pointer;
appearance: none;
-webkit-appearance: none;
}
input[type="range"]::-webkit-slider-runnable-track {
height: 5px;
border-radius: 999px;
background: linear-gradient(
to right,
var(--range-color, var(--gold)) 0 var(--fill),
rgba(38, 50, 56, 0.12) var(--fill) 100%
);
}
input[type="range"]::-moz-range-track {
height: 5px;
border-radius: 999px;
background: rgba(38, 50, 56, 0.12);
}
input[type="range"]::-moz-range-progress {
height: 5px;
border-radius: 999px;
background: var(--range-color, var(--gold));
}
input[type="range"]::-webkit-slider-thumb {
width: 19px;
height: 19px;
margin-top: -7px;
border: 3px solid #fff;
border-radius: 50%;
background: var(--range-color, var(--gold));
box-shadow: 0 2px 7px rgba(34, 42, 39, 0.25);
appearance: none;
-webkit-appearance: none;
}
input[type="range"]::-moz-range-thumb {
width: 14px;
height: 14px;
border: 3px solid #fff;
border-radius: 50%;
background: var(--range-color, var(--gold));
box-shadow: 0 2px 7px rgba(34, 42, 39, 0.25);
}
input[type="range"]:focus-visible::-webkit-slider-thumb {
outline: 3px solid rgba(216, 154, 53, 0.28);
outline-offset: 2px;
}
.scale {
display: flex;
justify-content: space-between;
margin-top: 5px;
color: #929894;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
}
.team-controls {
display: grid;
gap: 3px;
}
.team-control {
padding: 11px 12px;
border: 1px solid rgba(38, 50, 56, 0.07);
border-radius: 13px;
background: rgba(255, 255, 255, 0.38);
}
.team-control.blue {
background: linear-gradient(135deg, rgba(220, 234, 240, 0.8), rgba(255, 255, 255, 0.4));
}
.team-control.coral {
background: linear-gradient(135deg, rgba(246, 226, 221, 0.8), rgba(255, 255, 255, 0.4));
}
.team-title {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 7px;
font-size: 12px;
font-weight: 800;
}
.team-title span:last-child {
margin-left: auto;
color: var(--muted);
font-size: 11px;
}
.swatch {
width: 9px;
height: 9px;
border-radius: 3px;
background: var(--blue);
}
.coral .swatch {
background: var(--coral);
}
.presets-title {
margin: 17px 0 9px;
color: #7a817e;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.presets {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
.preset {
min-height: 38px;
padding: 8px 10px;
border: 1px solid var(--line);
border-radius: 11px;
color: #56605d;
background: rgba(255, 255, 255, 0.55);
font-size: 11px;
font-weight: 750;
cursor: pointer;
transition: 160ms ease;
}
.preset:hover {
transform: translateY(-1px);
border-color: rgba(38, 50, 56, 0.2);
background: #fff;
}
.preset.active {
border-color: rgba(216, 154, 53, 0.45);
color: #785313;
background: var(--gold-soft);
}
.status {
display: flex;
gap: 11px;
margin-top: 17px;
padding: 13px;
border: 1px solid rgba(79, 140, 112, 0.15);
border-radius: 14px;
background: rgba(226, 241, 232, 0.72);
}
.status.warn {
border-color: rgba(185, 78, 67, 0.18);
background: rgba(249, 226, 221, 0.8);
}
.status-dot {
flex: 0 0 auto;
width: 10px;
height: 10px;
margin-top: 3px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 0 5px rgba(79, 140, 112, 0.12);
}
.status.warn .status-dot {
background: var(--red);
box-shadow: 0 0 0 5px rgba(185, 78, 67, 0.11);
}
.status strong {
display: block;
margin-bottom: 3px;
font-size: 12px;
}
.status p {
margin: 0;
color: #68716d;
font-size: 11px;
line-height: 1.4;
}
.metrics {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 13px;
}
.metric {
min-height: 74px;
padding: 11px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(255, 255, 255, 0.45);
}
.metric.shared {
border-color: rgba(216, 154, 53, 0.22);
background: var(--gold-soft);
}
.metric-label {
color: #777f7c;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.metric-value {
margin-top: 6px;
font-family: Georgia, "Times New Roman", serif;
font-size: 23px;
line-height: 1;
}
.metric-value small {
color: #7b827f;
font-family: Inter, ui-sans-serif, system-ui, sans-serif;
font-size: 10px;
font-weight: 700;
}
.panel-note {
margin: 13px 2px 0;
color: #858c88;
font-size: 10px;
line-height: 1.45;
}
.legend {
position: fixed;
z-index: 3;
left: 30px;
bottom: 24px;
display: flex;
flex-wrap: wrap;
gap: 15px;
padding: 10px 13px;
border: 1px solid rgba(255, 255, 255, 0.66);
border-radius: 13px;
color: #5f6865;
background: rgba(248, 246, 239, 0.76);
box-shadow: 0 7px 24px rgba(47, 52, 47, 0.09);
backdrop-filter: blur(10px);
font-size: 10px;
font-weight: 700;
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
}
.legend-item i {
display: inline-block;
width: 9px;
height: 9px;
border-radius: 3px;
}
.legend-item .blue-dot {
background: var(--blue);
}
.legend-item .coral-dot {
background: var(--coral);
}
.legend-item .gold-dot {
border: 2px solid var(--gold);
background: #f4d891;
}
.scene-label {
position: fixed;
z-index: 2;
pointer-events: none;
transform: translate(-50%, -50%);
will-change: transform;
}
#sharedLabel {
padding: 7px 10px;
border: 1px solid rgba(127, 85, 20, 0.22);
border-radius: 9px;
color: #6e4a13;
background: rgba(255, 239, 203, 0.94);
box-shadow: 0 5px 15px rgba(70, 52, 18, 0.12);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
}
#sharedLabel::after {
display: block;
margin-top: 2px;
color: #9a7432;
font-size: 7px;
letter-spacing: 0.06em;
text-align: center;
}
#dividerLabel {
padding: 5px 8px;
border: 1px solid rgba(38, 50, 56, 0.12);
border-radius: 999px;
color: #626b68;
background: rgba(255, 255, 255, 0.82);
box-shadow: 0 4px 12px rgba(40, 45, 42, 0.1);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.09em;
text-transform: uppercase;
white-space: nowrap;
}
@media (max-width: 900px) {
.hero {
top: 18px;
left: 20px;
width: calc(100vw - 380px);
}
.hero p:last-child {
display: none;
}
.panel {
top: 12px;
right: 12px;
bottom: 12px;
width: 330px;
}
.legend {
left: 18px;
bottom: 16px;
}
}
@media (max-width: 680px) {
.hero {
top: 14px;
left: 15px;
width: calc(100vw - 30px);
}
h1 {
max-width: 330px;
font-size: 32px;
}
.panel {
top: auto;
left: 10px;
right: 10px;
bottom: 10px;
width: auto;
max-height: 47vh;
padding: 16px;
border-radius: 18px;
}
.panel-head {
margin-bottom: 12px;
}
.panel-head h2 {
font-size: 21px;
}
.legend {
display: none;
}
.presets,
.metrics {
grid-template-columns: repeat(4, 1fr);
}
.metric {
min-height: 62px;
padding: 8px;
}
.metric-value {
font-size: 18px;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive low-poly table allocation scene"></div>
<header class="hero">
<p class="eyebrow">Workspace allocation lab</p>
<h1>Make room for both sides.</h1>
<p>
Move the divider, respond to changing needs, and keep the small amber
island available for tools used by everyone.
</p>
</header>
<aside class="panel" aria-label="Allocation controls">
<div class="panel-head">
<div>
<p class="eyebrow">Shared table</p>
<h2>Negotiation controls</h2>
</div>
<span class="live-dot">Live</span>
</div>
<section class="control">
<div class="control-label">
<strong>Divider position</strong>
<output id="dividerOutput">Centered · 50%</output>
</div>
<div class="range-wrap">
<input
id="dividerRange"
type="range"
min="-3.6"
max="3.6"
step="0.05"
value="0"
aria-label="Divider position"
/>
</div>
<div class="scale">
<span>More blue space</span>
<span>More coral space</span>
</div>
</section>
<section class="control">
<div class="control-label">
<strong>Required work areas</strong>
<output>1 unit = 1 m²</output>
</div>
<div class="team-controls">
<div class="team-control blue">
<div class="team-title">
<span class="swatch"></span>
<span>Blue team</span>
<span id="leftNeedOutput">5.0 m²</span>
</div>
<input
id="leftRange"
type="range"
min="2"
max="8"
step="1"
value="5"
style="--range-color: var(--blue)"
aria-label="Blue team required area"
/>
</div>
<div class="team-control coral">
<div class="team-title">
<span class="swatch"></span>
<span>Coral team</span>
<span id="rightNeedOutput">5.0 m²</span>
</div>
<input
id="rightRange"
type="range"
min="2"
max="8"
step="1"
value="5"
style="--range-color: var(--coral)"
aria-label="Coral team required area"
/>
</div>
</div>
</section>
<p class="presets-title">Scenario presets</p>
<div class="presets">
<button class="preset active" data-preset="balanced">Balanced</button>
<button class="preset" data-preset="left">Blue surge</button>
<button class="preset" data-preset="right">Coral surge</button>
<button class="preset" data-preset="tight">Tight fit</button>
</div>
<div id="statusBox" class="status" aria-live="polite">
<span class="status-dot"></span>
<div>
<strong id="statusTitle">Balanced fit</strong>
<p id="statusMessage">Both teams have room, and the shared tools stay protected.</p>
</div>
</div>
<div class="metrics">
<div class="metric">
<div class="metric-label">Blue lane</div>
<div class="metric-value"><span id="leftMetric">5.0</span> <small>/ <span id="leftCapacity">8</span> m²</small></div>
</div>
<div class="metric">
<div class="metric-label">Coral lane</div>
<div class="metric-value"><span id="rightMetric">5.0</span> <small>/ <span id="rightCapacity">8</span> m²</small></div>
</div>
<div class="metric shared">
<div class="metric-label">Shared center</div>
<div class="metric-value">1.8 <small>m² protected</small></div>
</div>
<div class="metric">
<div class="metric-label">Divider</div>
<div class="metric-value"><span id="dividerMetric">50</span><small>% of table</small></div>
</div>
</div>
<p class="panel-note">
Drag empty space to orbit, use the wheel to zoom, or drag the amber divider
directly. The shared center is never allocated to either team.
</p>
</aside>
<div class="legend" aria-hidden="true">
<span class="legend-item"><i class="blue-dot"></i>Blue team</span>
<span class="legend-item"><i class="coral-dot"></i>Coral team</span>
<span class="legend-item"><i class="gold-dot"></i>Shared tools</span>
<span>Drag scene to orbit</span>
</div>
<div id="sharedLabel" class="scene-label">
Shared tools
<span style="display:block">1.8 m² protected</span>
</div>
<div id="dividerLabel" class="scene-label">Movable divider</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const container = document.getElementById("scene");
const dividerRange = document.getElementById("dividerRange");
const leftRange = document.getElementById("leftRange");
const rightRange = document.getElementById("rightRange");
const leftNeedOutput = document.getElementById("leftNeedOutput");
const rightNeedOutput = document.getElementById("rightNeedOutput");
const dividerOutput = document.getElementById("dividerOutput");
const leftMetric = document.getElementById("leftMetric");
const rightMetric = document.getElementById("rightMetric");
const leftCapacity = document.getElementById("leftCapacity");
const rightCapacity = document.getElementById("rightCapacity");
const dividerMetric = document.getElementById("dividerMetric");
const statusBox = document.getElementById("statusBox");
const statusTitle = document.getElementById("statusTitle");
const statusMessage = document.getElementById("statusMessage");
const sharedLabel = document.getElementById("sharedLabel");
const dividerLabel = document.getElementById("dividerLabel");
const presetButtons = [...document.querySelectorAll(".preset")];
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9e4d8);
scene.fog = new THREE.Fog(0xe9e4d8, 16, 29);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
60
);
const orbit = {
target: new THREE.Vector3(0, 1.25, 0),
yaw: 0.58,
pitch: 0.67,
radius: 12.8
};
function updateCamera() {
const horizontal = Math.cos(orbit.pitch) * orbit.radius;
camera.position.set(
orbit.target.x + Math.sin(orbit.yaw) * horizontal,
orbit.target.y + Math.sin(orbit.pitch) * orbit.radius,
orbit.target.z + Math.cos(orbit.yaw) * horizontal
);
camera.lookAt(orbit.target);
}
updateCamera();
scene.add(new THREE.HemisphereLight(0xfff8e9, 0x65716e, 2.15));
const sun = new THREE.DirectionalLight(0xffefd4, 3.25);
sun.position.set(5.5, 10, 6.5);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -9;
sun.shadow.camera.right = 9;
sun.shadow.camera.top = 8;
sun.shadow.camera.bottom = -8;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 24;
sun.shadow.bias = -0.00025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xc7dce4, 0.85);
fill.position.set(-7, 5, -4);
scene.add(fill);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(50, 50),
new THREE.MeshStandardMaterial({ color: 0xd8d2c6, roughness: 1 })
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.025;
floor.receiveShadow = true;
scene.add(floor);
const table = new THREE.Group();
scene.add(table);
const slabMaterial = new THREE.MeshStandardMaterial({
color: 0xa9784f,
roughness: 0.84,
flatShading: true
});
const slab = new THREE.Mesh(new THREE.BoxGeometry(9.45, 0.28, 6.25), slabMaterial);
slab.position.y = 1.24;
slab.castShadow = true;
slab.receiveShadow = true;
table.add(slab);
const edgeMaterial = new THREE.MeshStandardMaterial({
color: 0x7e573c,
roughness: 0.9
});
const rim = new THREE.Mesh(new THREE.BoxGeometry(9.58, 0.12, 6.38), edgeMaterial);
rim.position.y = 1.13;
rim.castShadow = true;
table.add(rim);
const plankColors = [0xc79a70, 0xbe8b62, 0xcda47c, 0xb9825b, 0xc99b72];
for (let i = 0; i < 5; i++) {
const plank = new THREE.Mesh(
new THREE.BoxGeometry(9.22, 0.035, 1.11),
new THREE.MeshStandardMaterial({
color: plankColors[i],
roughness: 0.92,
flatShading: true
})
);
plank.position.set(0, 1.3975, -2.3 + i * 1.15);
plank.receiveShadow = true;
table.add(plank);
}
const legMaterial = new THREE.MeshStandardMaterial({
color: 0x6e5846,
roughness: 0.86,
flatShading: true
});
for (const x of [-3.85, 3.85]) {
for (const z of [-2.35, 2.35]) {
const leg = new THREE.Mesh(
new THREE.CylinderGeometry(0.23, 0.34, 1.1, 4),
legMaterial
);
leg.position.set(x, 0.57, z);
leg.rotation.y = Math.PI / 4;
leg.castShadow = true;
leg.receiveShadow = true;
table.add(leg);
}
}
const leftZone = new THREE.Mesh(
new THREE.PlaneGeometry(1, 5.72),
new THREE.MeshBasicMaterial({
color: 0x4f8ba5,
transparent: true,
opacity: 0.105,
depthWrite: false,
side: THREE.DoubleSide
})
);
leftZone.rotation.x = -Math.PI / 2;
leftZone.position.y = 1.419;
table.add(leftZone);
const rightZone = new THREE.Mesh(
new THREE.PlaneGeometry(1, 5.72),
new THREE.MeshBasicMaterial({
color: 0xd86f5d,
transparent: true,
opacity: 0.105,
depthWrite: false,
side: THREE.DoubleSide
})
);
rightZone.rotation.x = -Math.PI / 2;
rightZone.position.y = 1.42;
table.add(rightZone);
const sharedMat = new THREE.Mesh(
new THREE.CylinderGeometry(1.02, 1.02, 0.08, 8),
new THREE.MeshStandardMaterial({
color: 0xe8b45d,
roughness: 0.72,
emissive: 0x6b3c08,
emissiveIntensity: 0.06,
flatShading: true
})
);
sharedMat.position.y = 1.46;
sharedMat.castShadow = true;
sharedMat.receiveShadow = true;
table.add(sharedMat);
const sharedRing = new THREE.Mesh(
new THREE.TorusGeometry(0.93, 0.035, 4, 8),
new THREE.MeshStandardMaterial({
color: 0xffdf83,
roughness: 0.55,
emissive: 0xa66a0a,
emissiveIntensity: 0.24
})
);
sharedRing.rotation.x = Math.PI / 2;
sharedRing.position.y = 1.505;
sharedRing.castShadow = true;
table.add(sharedRing);
const toolMetal = new THREE.MeshStandardMaterial({
color: 0xd9d9ce,
roughness: 0.48,
metalness: 0.32,
flatShading: true
});
const toolDark = new THREE.MeshStandardMaterial({
color: 0x45585b,
roughness: 0.68,
flatShading: true
});
const toolRed = new THREE.MeshStandardMaterial({
color: 0xb85d4c,
roughness: 0.7,
flatShading: true
});
const toolWood = new THREE.MeshStandardMaterial({
color: 0x9d7046,
roughness: 0.85,
flatShading: true
});
function addToolMesh(group, geometry, material, position, rotation = null) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(...position);
if (rotation) mesh.rotation.set(...rotation);
mesh.castShadow = true;
group.add(mesh);
return mesh;
}
const tools = new THREE.Group();
tools.position.y = 1.525;
table.add(tools);
const wrench = new THREE.Group();
wrench.position.set(-0.25, 0.015, 0.02);
wrench.rotation.y = 0.28;
tools.add(wrench);
addToolMesh(wrench, new THREE.BoxGeometry(0.62, 0.055, 0.13), toolMetal, [0, 0, 0]);
addToolMesh(wrench, new THREE.BoxGeometry(0.18, 0.055, 0.065), toolMetal, [0.36, 0, 0.075]);
addToolMesh(wrench, new THREE.BoxGeometry(0.18, 0.055, 0.065), toolMetal, [0.36, 0, -0.075]);
addToolMesh(
wrench,
new THREE.TorusGeometry(0.11, 0.035, 4, 8),
toolMetal,
[-0.34, 0, 0],
[Math.PI / 2, 0, 0]
);
const hammer = new THREE.Group();
hammer.position.set(0.36, 0.02, -0.24);
hammer.rotation.y = -0.55;
tools.add(hammer);
addToolMesh(hammer, new THREE.BoxGeometry(0.12, 0.07, 0.68), toolWood, [0, 0, 0]);
addToolMesh(hammer, new THREE.BoxGeometry(0.42, 0.13, 0.16), toolDark, [0, 0.02, -0.32]);
const tape = new THREE.Mesh(
new THREE.TorusGeometry(0.17, 0.052, 4, 8),
new THREE.MeshStandardMaterial({
color: 0xf1d277,
roughness: 0.55,
flatShading: true
})
);
tape.rotation.x = Math.PI / 2;
tape.position.set(-0.27, 0.065, -0.34);
tape.castShadow = true;
tools.add(tape);
const clipboard = new THREE.Group();
clipboard.position.set(0.26, 0.02, 0.31);
clipboard.rotation.y = 0.28;
tools.add(clipboard);
addToolMesh(clipboard, new THREE.BoxGeometry(0.38, 0.045, 0.48), toolWood, [0, 0, 0]);
addToolMesh(clipboard, new THREE.BoxGeometry(0.31, 0.02, 0.39), toolMetal, [0, 0.035, -0.015]);
addToolMesh(clipboard, new THREE.BoxGeometry(0.15, 0.03, 0.06), toolDark, [0, 0.055, -0.2]);
const divider = new THREE.Group();
table.add(divider);
const dividerFrame = new THREE.MeshStandardMaterial({
color: 0x76654d,
roughness: 0.65,
flatShading: true
});
for (const z of [-1.65, 1.65]) {
const foot = new THREE.Mesh(new THREE.BoxGeometry(0.62, 0.09, 0.42), dividerFrame);
foot.position.set(0, 1.455, z);
foot.castShadow = true;
divider.add(foot);
const post = new THREE.Mesh(new THREE.BoxGeometry(0.13, 1.1, 0.13), dividerFrame);
post.position.set(0, 2.02, z);
post.castShadow = true;
divider.add(post);
}
const beam = new THREE.Mesh(new THREE.BoxGeometry(0.16, 0.15, 3.47), dividerFrame);
beam.position.set(0, 2.61, 0);
beam.castShadow = true;
divider.add(beam);
const dividerPanel = new THREE.Mesh(
new THREE.BoxGeometry(0.035, 0.72, 3.08),
new THREE.MeshStandardMaterial({
color: 0xe7a642,
roughness: 0.55,
transparent: true,
opacity: 0.17,
depthWrite: false,
side: THREE.DoubleSide
})
);
dividerPanel.position.set(0, 2.12, 0);
divider.add(dividerPanel);
const blueArrow = new THREE.Mesh(
new THREE.ConeGeometry(0.105, 0.28, 4),
new THREE.MeshStandardMaterial({ color: 0x3f7892, flatShading: true })
);
blueArrow.rotation.z = Math.PI / 2;
blueArrow.position.set(-0.17, 2.61, -1.57);
blueArrow.castShadow = true;
divider.add(blueArrow);
const coralArrow = new THREE.Mesh(
new THREE.ConeGeometry(0.105, 0.28, 4),
new THREE.MeshStandardMaterial({ color: 0xd86f5d, flatShading: true })
);
coralArrow.rotation.z = -Math.PI / 2;
coralArrow.position.set(0.17, 2.61, 1.57);
coralArrow.castShadow = true;
divider.add(coralArrow);
const dividerHit = new THREE.Mesh(
new THREE.BoxGeometry(0.62, 1.35, 3.62),
new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false
})
);
dividerHit.position.set(0, 2.02, 0);
divider.add(dividerHit);
function standard(color, roughness = 0.78, metalness = 0.04) {
return new THREE.MeshStandardMaterial({
color,
roughness,
metalness,
flatShading: true
});
}
function outlinedMesh(geometry, material, position, rotation = null) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(...position);
if (rotation) mesh.rotation.set(...rotation);
mesh.castShadow = true;
mesh.receiveShadow = true;
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 25),
new THREE.LineBasicMaterial({
color: 0x263238,
transparent: true,
opacity: 0.24
})
);
mesh.add(edges);
return mesh;
}
function makeTeamObject(side, index) {
const group = new THREE.Group();
const isBlue = side === "left";
const palette = isBlue
? [0x3f7892, 0x5c91a7, 0x2f687f, 0x7aa2b4]
: [0xd86f5d, 0xe48b6f, 0xbf5d50, 0xdc9b66];
const bodyMaterial = standard(palette[index % palette.length]);
const accentMaterial = standard(palette[(index + 2) % palette.length]);
const darkMaterial = standard(isBlue ? 0x294f60 : 0x82483e);
const materials = [bodyMaterial, accentMaterial];
const padMaterial = new THREE.MeshBasicMaterial({
color: isBlue ? 0x3f7892 : 0xd86f5d,
transparent: true,
opacity: 0.15,
depthWrite: false,
side: THREE.DoubleSide
});
const pad = new THREE.Mesh(new THREE.CircleGeometry(0.4, 8), padMaterial);
pad.rotation.x = -Math.PI / 2;
pad.position.y = 0.018;
group.add(pad);
if (index === 0) {
group.add(outlinedMesh(new THREE.BoxGeometry(0.58, 0.42, 0.52), bodyMaterial, [0, 0.245, 0]));
group.add(outlinedMesh(new THREE.BoxGeometry(0.63, 0.06, 0.57), accentMaterial, [0, 0.49, 0]));
group.add(outlinedMesh(new THREE.BoxGeometry(0.075, 0.44, 0.56), darkMaterial, [0.16, 0.25, 0]));
} else if (index === 1) {
group.add(outlinedMesh(new THREE.CylinderGeometry(0.27, 0.3, 0.58, 8), bodyMaterial, [0, 0.32, 0]));
group.add(outlinedMesh(new THREE.CylinderGeometry(0.29, 0.29, 0.06, 8), accentMaterial, [0, 0.63, 0]));
group.add(outlinedMesh(new THREE.CylinderGeometry(0.305, 0.305, 0.075, 8), darkMaterial, [0, 0.33, 0]));
} else if (index === 2) {
group.add(outlinedMesh(new THREE.BoxGeometry(0.52, 0.18, 0.46), bodyMaterial, [0, 0.12, 0]));
group.add(outlinedMesh(new THREE.BoxGeometry(0.43, 0.18, 0.39), accentMaterial, [-0.04, 0.3, 0.02]));
group.add(outlinedMesh(new THREE.BoxGeometry(0.29, 0.17, 0.3), darkMaterial, [0.1, 0.47, -0.03]));
} else if (index === 3) {
group.add(outlinedMesh(new THREE.ConeGeometry(0.37, 0.61, 4), bodyMaterial, [0, 0.33, 0], [0, Math.PI / 4, 0]));
group.add(outlinedMesh(new THREE.BoxGeometry(0.53, 0.055, 0.53), accentMaterial, [0, 0.05, 0]));
} else if (index === 4) {
group.add(outlinedMesh(new THREE.BoxGeometry(0.44, 0.66, 0.44), bodyMaterial, [0, 0.35, 0]));
group.add(outlinedMesh(new THREE.BoxGeometry(0.5, 0.06, 0.5), accentMaterial, [0, 0.71, 0]));
group.add(outlinedMesh(new THREE.BoxGeometry(0.075, 0.68, 0.46), darkMaterial, [0.12, 0.35, 0]));
} else if (index === 5) {
group.add(outlinedMesh(new THREE.CylinderGeometry(0.22, 0.22, 0.58, 8), bodyMaterial, [0, 0.26, 0], [0, 0, Math.PI / 2]));
group.add(outlinedMesh(new THREE.CylinderGeometry(0.25, 0.25, 0.08, 8), accentMaterial, [-0.3, 0.26, 0], [0, 0, Math.PI / 2]));
group.add(outlinedMesh(new THREE.CylinderGeometry(0.25, 0.25, 0.08, 8), darkMaterial, [0.3, 0.26, 0], [0, 0, Math.PI / 2]));
} else if (index === 6) {
group.add(outlinedMesh(new THREE.CylinderGeometry(0.28, 0.32, 0.66, 8), bodyMaterial, [0, 0.35, 0]));
group.add(outlinedMesh(new THREE.ConeGeometry(0.3, 0.25, 8), accentMaterial, [0, 0.805, 0]));
group.add(outlinedMesh(new THREE.CylinderGeometry(0.11, 0.11, 0.11, 8), darkMaterial, [0, 0.98, 0]));
} else {
group.add(outlinedMesh(new THREE.BoxGeometry(0.62, 0.3, 0.5), bodyMaterial, [0, 0.18, 0]));
group.add(outlinedMesh(new THREE.BoxGeometry(0.38, 0.22, 0.36), accentMaterial, [-0.08, 0.44, 0.03]));
group.add(outlinedMesh(new THREE.BoxGeometry(0.18, 0.12, 0.18), darkMaterial, [0.18, 0.39, -0.11]));
}
const marker = new THREE.Mesh(
new THREE.ConeGeometry(0.1, 0.2, 4),
new THREE.MeshStandardMaterial({
color: 0xb94e43,
emissive: 0x7c1d17,
emissiveIntensity: 0.25,
flatShading: true
})
);
marker.position.set(0, 1.14, 0);
marker.rotation.z = Math.PI;
marker.visible = false;
marker.castShadow = true;
group.add(marker);
group.userData.target = new THREE.Vector3();
group.userData.targetRotation = 0;
group.userData.materials = materials;
group.userData.padMaterial = padMaterial;
group.userData.marker = marker;
group.userData.stressed = false;
group.userData.spawn = 0;
return group;
}
const teamObjects = { left: [], right: [] };
for (const side of ["left", "right"]) {
for (let i = 0; i < 8; i++) {
const object = makeTeamObject(side, i);
table.add(object);
teamObjects[side].push(object);
}
}
let desiredDivider = 0;
let desiredLeft = 5;
let desiredRight = 5;
let currentDivider = 0;
const tableHalfWidth = 4.35;
const tableHalfDepth = 2.3;
const sharedClearance = 1.3;
const xValues = [];
for (let x = -3.85; x <= 3.86; x += 0.62) xValues.push(Number(x.toFixed(2)));
const zValues = [-2.05, -1.4, -0.75, -0.1, 0.55, 1.2, 1.85];
function buildSlots(side) {
const candidates = [];
const isLeft = side === "left";
for (const z of zValues) {
const validX = xValues.filter((x) => {
const onCorrectSide = isLeft
? x < desiredDivider - 0.36
: x > desiredDivider + 0.36;
const outsideSharedArea = x * x + z * z > sharedClearance * sharedClearance;
return onCorrectSide && outsideSharedArea;
});
validX.sort((a, b) => (isLeft ? a - b : b - a));
for (const x of validX) {
candidates.push({ x, z, overlap: false });
}
}
const candidateCount = candidates.length;
const slots = candidates.slice(0, 8);
while (slots.length < 8) {
const i = slots.length;
const row = i % zValues.length;
let x;
if (isLeft) {
x = Math.max(-4.02, desiredDivider - 0.43) - (i - candidateCount) * 0.035;
} else {
x = Math.min(4.02, desiredDivider + 0.43) + (i - candidateCount) * 0.035;
}
slots.push({
x: Number(x.toFixed(3)),
z: zValues[row],
overlap: true
});
}
return { slots, capacity: Math.min(8, candidateCount) };
}
function setStress(object, stressed) {
object.userData.stressed = stressed;
object.userData.marker.visible = stressed;
for (const material of object.userData.materials) {
material.emissive.setHex(stressed ? 0x741b13 : 0x000000);
material.emissiveIntensity = stressed ? 0.24 : 0;
}
object.userData.padMaterial.color.setHex(stressed ? 0xb94e43 : object.userData.baseColor);
object.userData.padMaterial.opacity = stressed ? 0.25 : 0.15;
}
for (const side of ["left", "right"]) {
for (const object of teamObjects[side]) {
object.userData.baseColor = side === "left" ? 0x3f7892 : 0xd86f5d;
}
}
let layoutInfo = { left: null, right: null };
function layoutObjects(snap = false) {
layoutInfo.left = buildSlots("left");
layoutInfo.right = buildSlots("right");
for (const side of ["left", "right"]) {
const needed = side === "left" ? desiredLeft : desiredRight;
const info = layoutInfo[side];
teamObjects[side].forEach((object, index) => {
const wasVisible = object.visible;
const visible = index < needed;
object.visible = visible;
if (!visible) {
object.userData.spawn = 0;
return;
}
if (!wasVisible) object.userData.spawn = 0.55;
const slot = info.slots[index];
object.userData.target.set(slot.x, 1.43, slot.z);
object.userData.targetRotation = (slot.x * 0.07 + index * 0.43) % (Math.PI * 2);
setStress(object, slot.overlap);
if (snap) {
object.position.copy(object.userData.target);
object.rotation.y = object.userData.targetRotation;
object.scale.setScalar(1);
}
});
}
}
function updateRangeFill(input) {
const min = Number(input.min);
const max = Number(input.max);
const value = Number(input.value);
const percent = ((value - min) / (max - min)) * 100;
input.style.setProperty("--fill", `${percent}%`);
}
function updateReadouts() {
const leftNeed = desiredLeft;
const rightNeed = desiredRight;
const leftCap = layoutInfo.left.capacity;
const rightCap = layoutInfo.right.capacity;
leftNeedOutput.textContent = `${leftNeed.toFixed(1)} m²`;
rightNeedOutput.textContent = `${rightNeed.toFixed(1)} m²`;
leftMetric.textContent = leftNeed.toFixed(1);
rightMetric.textContent = rightNeed.toFixed(1);
leftCapacity.textContent = leftCap;
rightCapacity.textContent = rightCap;
const percent = Math.round(((desiredDivider + 3.6) / 7.2) * 100);
dividerMetric.textContent = percent;
let positionText = "Centered";
if (desiredDivider > 0.22) positionText = `Toward coral · ${percent}%`;
else if (desiredDivider < -0.22) positionText = `Toward blue · ${percent}%`;
else positionText = `Centered · ${percent}%`;
dividerOutput.textContent = positionText;
let title = "Balanced fit";
let message = "Both teams have room, and the shared tools stay protected.";
let warning = false;
if (leftNeed > leftCap || rightNeed > rightCap) {
title = "Needs negotiation";
message = "One side is over its lane. Move the divider before adding more work.";
warning = true;
} else if (leftCap - leftNeed <= 1 || rightCap - rightNeed <= 1) {
title = "Tight but workable";
message = "Little slack remains. Keep the amber shared island untouched.";
} else if (Math.abs(desiredDivider) < 0.36 && Math.abs(leftNeed - rightNeed) <= 1) {
title = "Balanced fit";
message = "Both teams have room, and the shared tools stay protected.";
} else {
title = "Workable split";
message = "The allocation can accommodate both teams. Shared access remains open.";
}
statusTitle.textContent = title;
statusMessage.textContent = message;
statusBox.classList.toggle("warn", warning);
updateRangeFill(dividerRange);
updateRangeFill(leftRange);
updateRangeFill(rightRange);
}
function applyControls(clearPreset = true) {
desiredDivider = Number(dividerRange.value);
desiredLeft = Number(leftRange.value);
desiredRight = Number(rightRange.value);
layoutObjects(false);
updateReadouts();
if (clearPreset) {
presetButtons.forEach((button) => button.classList.remove("active"));
}
}
dividerRange.addEventListener("input", () => applyControls(true));
leftRange.addEventListener("input", () => applyControls(true));
rightRange.addEventListener("input", () => applyControls(true));
const presets = {
balanced: { divider: 0, left: 5, right: 5 },
left: { divider: 0.9, left: 8, right: 4 },
right: { divider: -0.9, left: 4, right: 8 },
tight: { divider: 0.15, left: 7, right: 7 }
};
presetButtons.forEach((button) => {
button.addEventListener("click", () => {
const preset = presets[button.dataset.preset];
dividerRange.value = preset.divider;
leftRange.value = preset.left;
rightRange.value = preset.right;
applyControls(false);
presetButtons.forEach((item) => item.classList.toggle("active", item === button));
});
});
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const dragPlane = new THREE.Plane(new THREE.Vector3(0, 1, 0), -1.42);
const dragPoint = new THREE.Vector3();
let draggingDivider = false;
let orbiting = false;
let pointerId = null;
let previousX = 0;
let previousY = 0;
function setPointer(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function hitDivider(event) {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
return raycaster.intersectObject(dividerHit, false).length > 0;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
pointerId = event.pointerId;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
if (hitDivider(event)) {
draggingDivider = true;
renderer.domElement.style.cursor = "ew-resize";
} else {
orbiting = true;
renderer.domElement.style.cursor = "grabbing";
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (draggingDivider) {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
if (raycaster.ray.intersectPlane(dragPlane, dragPoint)) {
dividerRange.value = THREE.MathUtils.clamp(dragPoint.x, -3.6, 3.6).toFixed(2);
applyControls(true);
}
return;
}
if (orbiting) {
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
orbit.yaw -= dx * 0.006;
orbit.pitch = THREE.MathUtils.clamp(orbit.pitch + dy * 0.005, 0.28, 1.25);
previousX = event.clientX;
previousY = event.clientY;
} else {
renderer.domElement.style.cursor = hitDivider(event) ? "ew-resize" : "grab";
}
});
function endPointer(event) {
draggingDivider = false;
orbiting = false;
if (pointerId !== null && renderer.domElement.hasPointerCapture(pointerId)) {
renderer.domElement.releasePointerCapture(pointerId);
}
pointerId = null;
renderer.domElement.style.cursor = "grab";
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * Math.exp(event.deltaY * 0.001),
7.2,
18
);
},
{ passive: false }
);
function updateZones() {
const leftWidth = Math.max(0.02, currentDivider + tableHalfWidth);
const rightWidth = Math.max(0.02, tableHalfWidth - currentDivider);
leftZone.scale.x = leftWidth;
leftZone.position.x = (-tableHalfWidth + currentDivider) * 0.5;
rightZone.scale.x = rightWidth;
rightZone.position.x = (currentDivider + tableHalfWidth) * 0.5;
}
const projected = new THREE.Vector3();
function placeLabel(element, worldPosition) {
projected.copy(worldPosition).project(camera);
const visible = projected.z > -1 && projected.z < 1;
element.style.display = visible ? "block" : "none";
if (!visible) return;
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
const sharedLabelPosition = new THREE.Vector3(0, 1.72, 0);
const dividerLabelPosition = new THREE.Vector3();
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
applyControls(false);
layoutObjects(true);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
const time = clock.elapsedTime;
currentDivider = THREE.MathUtils.lerp(
currentDivider,
desiredDivider,
1 - Math.exp(-dt * 10)
);
divider.position.x = currentDivider;
updateZones();
for (const side of ["left", "right"]) {
for (const object of teamObjects[side]) {
if (!object.visible) continue;
object.position.lerp(
object.userData.target,
1 - Math.exp(-dt * 8)
);
const angleDifference = Math.atan2(
Math.sin(object.userData.targetRotation - object.rotation.y),
Math.cos(object.userData.targetRotation - object.rotation.y)
);
object.rotation.y += angleDifference * (1 - Math.exp(-dt * 9));
object.userData.spawn = Math.min(1, object.userData.spawn + dt * 2.4);
const scale = 0.78 + 0.22 * THREE.MathUtils.smoothstep(
object.userData.spawn,
0,
1
);
object.scale.setScalar(scale);
}
}
sharedRing.scale.setScalar(1 + Math.sin(time * 2.1) * 0.012);
sharedRing.material.emissiveIntensity = 0.2 + Math.sin(time * 2.1) * 0.055;
updateCamera();
placeLabel(sharedLabel, sharedLabelPosition);
dividerLabelPosition.set(currentDivider, 2.86, 0);
placeLabel(dividerLabel, dividerLabelPosition);
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```