Prompt specification
Build or customize the Three.js 3D scene "Stage Markers and Audience Sight Cone" 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: Stage Markers and Audience Sight Cone
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/stage-markers-and-audience-sight-cone-x3353
Scene Description Prompt:
Please use Three.js from cdnjs for a low-poly scene based on this idea: stage markers and audience sight cone. Build a small stage with three actor marks and a simplified audience viewing cone. Show when a prop blocks an actor rather than merely changing its color. Return one self-contained HTML file.
Working Three.js Starter (stage-markers-and-audience-sight-cone-x3353):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Stage Sightline Test</title>
<style>
:root {
color-scheme: dark;
--ink: #edf7f7;
--muted: #91a8ad;
--panel: rgba(7, 18, 25, 0.82);
--line: rgba(135, 205, 214, 0.18);
--cyan: #59d8e8;
--amber: #ffb44f;
--red: #ff6570;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #071018;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
#app,
canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
canvas {
touch-action: none;
cursor: grab;
}
.glass {
background: var(--panel);
border: 1px solid var(--line);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(12px);
}
#readout {
position: fixed;
top: 20px;
left: 20px;
width: min(330px, calc(100vw - 40px));
padding: 17px;
border-radius: 16px;
pointer-events: none;
z-index: 5;
}
.eyebrow {
margin-bottom: 5px;
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 19px;
line-height: 1.2;
}
.subtitle {
margin: 8px 0 14px;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.status-row {
display: grid;
grid-template-columns: 28px 1fr auto;
align-items: center;
gap: 9px;
min-height: 44px;
padding: 7px 0;
border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.status-icon {
display: grid;
place-items: center;
width: 25px;
height: 25px;
border: 1px solid rgba(255, 255, 255, 0.17);
border-radius: 8px;
font-size: 17px;
font-weight: 900;
color: var(--ink);
background: rgba(255, 255, 255, 0.05);
}
.status-row.blocked .status-icon {
color: #fff;
background: var(--red);
border-color: var(--red);
}
.status-row.partial .status-icon {
color: #21180b;
background: var(--amber);
border-color: var(--amber);
}
.status-row.visible .status-icon {
color: #092026;
background: var(--cyan);
border-color: var(--cyan);
}
.status-name {
font-size: 12px;
font-weight: 800;
letter-spacing: 0.05em;
}
.status-detail {
margin-top: 2px;
color: var(--muted);
font-size: 10px;
}
.ray-count {
color: var(--muted);
font-size: 10px;
text-align: right;
white-space: nowrap;
}
#toolbar {
position: fixed;
left: 50%;
bottom: 22px;
z-index: 10;
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 7px;
width: min(720px, calc(100vw - 32px));
padding: 9px;
border-radius: 15px;
transform: translateX(-50%);
}
button {
appearance: none;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 9px;
padding: 9px 11px;
color: var(--ink);
background: rgba(255, 255, 255, 0.055);
font: inherit;
font-size: 11px;
font-weight: 750;
cursor: pointer;
transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}
button:hover {
background: rgba(89, 216, 232, 0.12);
border-color: rgba(89, 216, 232, 0.4);
transform: translateY(-1px);
}
button.primary {
color: #06171b;
background: var(--cyan);
border-color: var(--cyan);
}
button.primary:hover {
background: #8be8f2;
}
#legend {
position: fixed;
right: 20px;
bottom: 22px;
z-index: 5;
display: grid;
gap: 8px;
padding: 13px 15px;
border-radius: 13px;
color: var(--muted);
font-size: 10px;
pointer-events: none;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
}
.swatch {
width: 22px;
height: 8px;
border-radius: 8px;
}
.swatch.cone {
height: 2px;
background: var(--cyan);
box-shadow: 0 0 8px var(--cyan);
}
.swatch.ray {
height: 2px;
background: #d5f7fa;
}
.swatch.block {
display: grid;
place-items: center;
width: 18px;
height: 18px;
margin-left: 2px;
color: white;
background: var(--red);
font-size: 14px;
font-weight: 900;
}
#help {
position: fixed;
top: 20px;
right: 20px;
z-index: 5;
max-width: 240px;
padding: 11px 13px;
border-radius: 12px;
color: var(--muted);
font-size: 10px;
line-height: 1.5;
pointer-events: none;
}
#help strong {
color: var(--ink);
}
#loading {
position: fixed;
inset: 0;
z-index: 50;
display: grid;
place-items: center;
background: #071018;
color: var(--cyan);
font-size: 12px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
@media (max-width: 760px) {
#readout {
top: 12px;
left: 12px;
width: min(300px, calc(100vw - 24px));
padding: 13px;
}
#help,
#legend {
display: none;
}
#toolbar {
bottom: 12px;
width: calc(100vw - 24px);
}
button {
padding: 9px 9px;
font-size: 10px;
}
}
</style>
</head>
<body>
<div id="app"></div>
<aside id="readout" class="glass">
<div class="eyebrow">Live occlusion test</div>
<h1>Audience sightlines</h1>
<p class="subtitle">
Three audience eye positions sample the path to each actor.
Blocked rays physically stop at the prop.
</p>
<div id="statusRows" aria-live="polite"></div>
</aside>
<div id="help" class="glass">
<strong>Drag the amber prop</strong> to reposition it.<br>
Drag empty space to orbit; scroll to zoom.<br>
Press <strong>V</strong> for audience view or <strong>R</strong> to reset.
</div>
<nav id="toolbar" class="glass" aria-label="Scene controls">
<button data-block="-2.75">Move prop to A1</button>
<button data-block="0" class="primary">Move prop to A2</button>
<button data-block="2.75">Move prop to A3</button>
<button id="viewButton">Audience POV</button>
<button id="resetButton">Reset prop</button>
</nav>
<div id="legend" class="glass">
<div class="legend-row"><span class="swatch cone"></span>Audience viewing cone</div>
<div class="legend-row"><span class="swatch ray"></span>Eye-to-actor ray</div>
<div class="legend-row"><span class="swatch block">×</span>Physical obstruction point</div>
</div>
<div id="loading">Building stage…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const app = document.getElementById("app");
const statusRows = document.getElementById("statusRows");
const viewButton = document.getElementById("viewButton");
const resetButton = document.getElementById("resetButton");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x071018);
scene.fog = new THREE.Fog(0x071018, 19, 38);
const camera = new THREE.PerspectiveCamera(
44,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(innerWidth, innerHeight);
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.08;
app.appendChild(renderer.domElement);
const clock = new THREE.Clock();
const stageTop = 0.05;
const orbit = {
target: new THREE.Vector3(0, 1.05, -0.2),
radius: 15.2,
theta: 0.39,
phi: 1.03
};
let viewMode = "orbit";
let audienceZoom = 1.45;
let anyObstruction = false;
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0.04,
flatShading: true,
...options
});
}
function addBox(parent, width, height, depth, mat, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
parent,
radiusTop,
radiusBottom,
height,
segments,
mat,
x = 0,
y = 0,
z = 0
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function roundedRect(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + width, y, x + width, y + height, r);
ctx.arcTo(x + width, y + height, x, y + height, r);
ctx.arcTo(x, y + height, x, y, r);
ctx.arcTo(x, y, x + width, y, r);
ctx.closePath();
}
function makeFloorLabel(text, width = 0.7, height = 0.45) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 160;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "rgba(235, 249, 250, 0.92)";
ctx.font = "800 74px Arial, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 82);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false
})
);
mesh.rotation.x = -Math.PI / 2;
return mesh;
}
function makeBadge(actor) {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 150;
const ctx = canvas.getContext("2d");
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(2.25, 0.53, 1);
sprite.position.set(actor.x, 2.72, actor.z);
sprite.renderOrder = 20;
scene.add(sprite);
actor.badge = { canvas, ctx, texture, sprite };
}
function drawBadge(actor) {
const { canvas, ctx, texture } = actor.badge;
const labels = {
clear: ["VISIBLE", "✓", "#59d8e8"],
partial: ["PARTIAL BLOCK", "!", "#ffb44f"],
blocked: ["BLOCKED", "×", "#ff6570"]
};
const [label, icon, accent] = labels[actor.status];
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(ctx, 8, 8, 624, 134, 24);
ctx.fillStyle = "rgba(5, 15, 21, 0.92)";
ctx.fill();
ctx.lineWidth = 4;
ctx.strokeStyle = accent;
ctx.stroke();
ctx.fillStyle = accent;
ctx.beginPath();
ctx.arc(66, 75, 35, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = actor.status === "partial" ? "#21180b" : "#ffffff";
ctx.font = "900 48px Arial, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(icon, 66, 75);
ctx.textAlign = "left";
ctx.fillStyle = "#eef8f8";
ctx.font = "800 29px Arial, sans-serif";
ctx.fillText(actor.id, 124, 52);
ctx.font = "900 37px Arial, sans-serif";
ctx.fillText(label, 124, 101);
texture.needsUpdate = true;
}
function makeImpactMarker() {
const canvas = document.createElement("canvas");
canvas.width = 128;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.arc(64, 64, 49, 0, Math.PI * 2);
ctx.fillStyle = "rgba(5, 15, 21, 0.94)";
ctx.fill();
ctx.lineWidth = 7;
ctx.strokeStyle = "#ff6570";
ctx.stroke();
ctx.lineWidth = 13;
ctx.lineCap = "round";
ctx.strokeStyle = "#ffffff";
ctx.beginPath();
ctx.moveTo(42, 42);
ctx.lineTo(86, 86);
ctx.moveTo(86, 42);
ctx.lineTo(42, 86);
ctx.stroke();
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.setScalar(0.4);
sprite.renderOrder = 30;
sprite.visible = false;
scene.add(sprite);
return sprite;
}
// Lighting.
scene.add(new THREE.HemisphereLight(0x9bdbe3, 0x142027, 1.65));
const keyLight = new THREE.DirectionalLight(0xffe1b4, 3.2);
keyLight.position.set(7, 12, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -11;
keyLight.shadow.camera.right = 11;
keyLight.shadow.camera.top = 11;
keyLight.shadow.camera.bottom = -11;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x68d9ef, 1.5);
rimLight.position.set(-8, 6, -5);
scene.add(rimLight);
// Auditorium floor and stage.
const floorMat = material(0x0c1920);
addBox(scene, 30, 0.12, 30, floorMat, 0, -0.46, 0);
const grid = new THREE.GridHelper(30, 30, 0x285261, 0x142b34);
grid.position.y = -0.39;
grid.material.transparent = true;
grid.material.opacity = 0.42;
scene.add(grid);
const stageBaseMat = material(0x263039);
addBox(scene, 11.5, 0.36, 5.8, stageBaseMat, 0, -0.18, -0.15);
const plankMats = [
material(0x6b4934),
material(0x76503a),
material(0x5e4130),
material(0x81583d)
];
for (let i = 0; i < 9; i++) {
addBox(
scene,
1.25,
0.05,
5.65,
plankMats[i % plankMats.length],
-4.375 + i * 1.25,
0.025,
-0.15
);
}
const frontFascia = material(0x17242c);
addBox(scene, 11.55, 0.42, 0.18, frontFascia, 0, -0.08, 2.72);
const backdropMat = material(0x142a35);
addBox(scene, 11.5, 4.05, 0.22, backdropMat, 0, 2.02, -3.01);
const panelMat = material(0x1d3b47);
for (let i = 0; i < 7; i++) {
const panel = addBox(
scene,
0.58,
2.85,
0.09,
panelMat,
-4.5 + i * 1.5,
1.75,
-2.86
);
panel.rotation.z = (i % 2 ? 1 : -1) * 0.035;
}
const trussMat = material(0x2c4650);
addBox(scene, 10.7, 0.16, 0.18, trussMat, 0, 3.78, -2.8);
addBox(scene, 0.18, 4.0, 0.18, trussMat, -5.22, 1.95, -2.8);
addBox(scene, 0.18, 4.0, 0.18, trussMat, 5.22, 1.95, -2.8);
const footlightMat = new THREE.MeshStandardMaterial({
color: 0xffd48a,
emissive: 0xffa63b,
emissiveIntensity: 2.1,
roughness: 0.45
});
for (let i = 0; i < 9; i++) {
const light = new THREE.Mesh(
new THREE.SphereGeometry(0.085, 6, 4),
footlightMat
);
light.position.set(-4.4 + i * 1.1, 0.16, 2.52);
scene.add(light);
}
// Simplified audience viewing cone: translucent pyramid plus floor fan.
const coneApex = new THREE.Vector3(0, 1.45, 6.65);
const coneBase = [
new THREE.Vector3(-5.55, 0.05, -2.88),
new THREE.Vector3(5.55, 0.05, -2.88),
new THREE.Vector3(5.55, 3.65, -2.88),
new THREE.Vector3(-5.55, 3.65, -2.88)
];
const conePositions = [];
function addTriangle(a, b, c) {
conePositions.push(
a.x, a.y, a.z,
b.x, b.y, b.z,
c.x, c.y, c.z
);
}
for (let i = 0; i < 4; i++) {
addTriangle(coneApex, coneBase[i], coneBase[(i + 1) % 4]);
}
const coneGeometry = new THREE.BufferGeometry();
coneGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(conePositions, 3)
);
const coneMaterial = new THREE.MeshBasicMaterial({
color: 0x59d8e8,
transparent: true,
opacity: 0.045,
side: THREE.DoubleSide,
depthWrite: false,
blending: THREE.AdditiveBlending
});
const coneMesh = new THREE.Mesh(coneGeometry, coneMaterial);
coneMesh.renderOrder = 1;
scene.add(coneMesh);
const fanGeometry = new THREE.BufferGeometry();
fanGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
0, stageTop + 0.018, 6.65,
-5.55, stageTop + 0.018, -2.88,
5.55, stageTop + 0.018, -2.88
], 3)
);
const fan = new THREE.Mesh(
fanGeometry,
new THREE.MeshBasicMaterial({
color: 0x59d8e8,
transparent: true,
opacity: 0.105,
side: THREE.DoubleSide,
depthWrite: false
})
);
fan.renderOrder = 2;
scene.add(fan);
const coneEdges = new THREE.LineSegments(
new THREE.BufferGeometry().setFromPoints([
coneApex, coneBase[0],
coneApex, coneBase[1],
coneApex, coneBase[2],
coneApex, coneBase[3],
coneBase[0], coneBase[1],
coneBase[1], coneBase[2],
coneBase[2], coneBase[3],
coneBase[3], coneBase[0]
]),
new THREE.LineBasicMaterial({
color: 0x59d8e8,
transparent: true,
opacity: 0.28,
depthWrite: false
})
);
coneEdges.renderOrder = 3;
scene.add(coneEdges);
const audienceLabel = makeFloorLabel("AUDIENCE VIEW", 2.5, 0.42);
audienceLabel.position.set(0, -0.385, 7.55);
scene.add(audienceLabel);
const eyes = [
new THREE.Vector3(-1.6, 1.45, 6.65),
new THREE.Vector3(0, 1.45, 6.65),
new THREE.Vector3(1.6, 1.45, 6.65)
];
const eyeMat = new THREE.MeshBasicMaterial({ color: 0x8beaf3 });
for (const eye of eyes) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.13, 0.028, 4, 12),
eyeMat
);
ring.position.copy(eye);
scene.add(ring);
const stem = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(eye.x, -0.38, eye.z),
eye
]),
new THREE.LineBasicMaterial({
color: 0x59d8e8,
transparent: true,
opacity: 0.3
})
);
scene.add(stem);
}
// Actors and their three stage markers.
const actorDefs = [
{ id: "A1", x: -2.75, z: -1.0, color: 0x49cdb5, status: "clear" },
{ id: "A2", x: 0, z: -1.0, color: 0xffa94f, status: "clear" },
{ id: "A3", x: 2.75, z: -1.0, color: 0x819fff, status: "clear" }
];
const darkCloth = material(0x18242c);
for (const actor of actorDefs) {
const markerMat = material(actor.color, {
emissive: actor.color,
emissiveIntensity: 0.12
});
const markerBase = addCylinder(
scene,
0.6,
0.6,
0.045,
12,
material(0x13262d),
actor.x,
0.075,
actor.z
);
markerBase.castShadow = false;
const markerRing = new THREE.Mesh(
new THREE.TorusGeometry(0.57, 0.042, 4, 20),
markerMat
);
markerRing.rotation.x = Math.PI / 2;
markerRing.position.set(actor.x, 0.112, actor.z);
scene.add(markerRing);
const floorId = makeFloorLabel(actor.id, 0.62, 0.32);
floorId.position.set(actor.x, 0.116, actor.z + 0.32);
scene.add(floorId);
const group = new THREE.Group();
group.position.set(actor.x, stageTop, actor.z);
scene.add(group);
const bodyMat = material(actor.color);
const skinMat = material(0xe8b58f);
addCylinder(group, 0.12, 0.14, 0.66, 6, darkCloth, -0.17, 0.36, 0);
addCylinder(group, 0.12, 0.14, 0.66, 6, darkCloth, 0.17, 0.36, 0);
addCylinder(group, 0.31, 0.42, 0.82, 6, bodyMat, 0, 1.1, 0);
const leftArm = addCylinder(
group, 0.085, 0.105, 0.68, 6, bodyMat, -0.39, 1.13, 0
);
const rightArm = addCylinder(
group, 0.085, 0.105, 0.68, 6, bodyMat, 0.39, 1.13, 0
);
leftArm.rotation.z = -0.15;
rightArm.rotation.z = 0.15;
const head = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.265, 0),
skinMat
);
head.position.set(0, 1.83, 0.015);
head.castShadow = true;
group.add(head);
const nose = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.055, 0),
skinMat
);
nose.position.set(0, 1.82, 0.265);
group.add(nose);
makeBadge(actor);
actor.rays = [];
actor.impacts = [];
for (let i = 0; i < eyes.length; i++) {
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(),
new THREE.Vector3()
]),
new THREE.LineBasicMaterial({
color: 0x7ee8f3,
transparent: true,
opacity: 0.32,
depthTest: false,
depthWrite: false
})
);
line.frustumCulled = false;
line.renderOrder = 10;
scene.add(line);
actor.rays.push(line);
actor.impacts.push(makeImpactMarker());
}
}
// Draggable scenic prop.
const prop = new THREE.Group();
prop.position.set(0, 0, 0.45);
scene.add(prop);
const propWidth = 1.9;
const propHeight = 2.15;
const propDepth = 0.66;
const propMat = material(0xb96532, { roughness: 0.68 });
const stripeMat = material(0xf2b84b);
const braceMat = material(0x34251f);
const propBody = addBox(
prop,
propWidth,
propHeight,
propDepth,
propMat,
0,
stageTop + propHeight / 2,
0
);
const propCap = addBox(
prop,
propWidth + 0.12,
0.12,
propDepth + 0.08,
braceMat,
0,
stageTop + propHeight + 0.05,
0
);
const propPickMeshes = [propBody, propCap];
for (let i = 0; i < 4; i++) {
const stripe = addBox(
prop,
propWidth * 0.92,
0.105,
0.025,
stripeMat,
0,
stageTop + 0.28 + i * 0.48,
propDepth / 2 + 0.018
);
propPickMeshes.push(stripe);
}
for (const x of [-0.59, 0.59]) {
const brace = addBox(
prop,
0.09,
propHeight * 0.78,
0.035,
braceMat,
x,
stageTop + propHeight / 2,
propDepth / 2 + 0.025
);
brace.rotation.z = x < 0 ? -0.12 : 0.12;
propPickMeshes.push(brace);
}
const propOutline = new THREE.LineSegments(
new THREE.EdgesGeometry(propBody.geometry),
new THREE.LineBasicMaterial({
color: 0xff6570,
transparent: true,
opacity: 0.8,
depthTest: false
})
);
propOutline.renderOrder = 12;
propBody.add(propOutline);
const selectionRing = new THREE.Mesh(
new THREE.TorusGeometry(1.19, 0.025, 4, 32),
new THREE.MeshBasicMaterial({
color: 0xffbf55,
transparent: true,
opacity: 0.72,
depthWrite: false
})
);
selectionRing.rotation.x = Math.PI / 2;
selectionRing.position.y = 0.095;
prop.add(selectionRing);
const propBox = new THREE.Box3();
statusRows.innerHTML = actorDefs.map(actor => `
<div class="status-row visible" id="row-${actor.id}">
<div class="status-icon">✓</div>
<div>
<div class="status-name">${actor.id} · VISIBLE</div>
<div class="status-detail">No prop intersection</div>
</div>
<div class="ray-count">0 / 3 rays</div>
</div>
`).join("");
function updateStatusRow(actor, blockedCount) {
const row = document.getElementById(`row-${actor.id}`);
const icon = row.querySelector(".status-icon");
const name = row.querySelector(".status-name");
const detail = row.querySelector(".status-detail");
const count = row.querySelector(".ray-count");
row.classList.remove("visible", "partial", "blocked");
if (actor.status === "blocked") {
row.classList.add("blocked");
icon.textContent = "×";
name.textContent = `${actor.id} · BLOCKED`;
detail.textContent = "Sightline meets the prop";
} else if (actor.status === "partial") {
row.classList.add("partial");
icon.textContent = "!";
name.textContent = `${actor.id} · PARTIAL BLOCK`;
detail.textContent = "Some audience positions are blocked";
} else {
row.classList.add("visible");
icon.textContent = "✓";
name.textContent = `${actor.id} · VISIBLE`;
detail.textContent = "No prop intersection";
}
count.textContent = `${blockedCount} / 3 rays`;
}
function updateVisibility() {
propBox.min.set(
prop.position.x - propWidth / 2,
stageTop,
prop.position.z - propDepth / 2
);
propBox.max.set(
prop.position.x + propWidth / 2,
stageTop + propHeight,
prop.position.z + propDepth / 2
);
anyObstruction = false;
for (const actor of actorDefs) {
let blockedCount = 0;
const target = new THREE.Vector3(actor.x, 1.27, actor.z);
for (let i = 0; i < eyes.length; i++) {
const start = eyes[i];
const direction = target.clone().sub(start);
const distance = direction.length();
direction.normalize();
const ray = new THREE.Ray(start, direction);
const hit = ray.intersectBox(propBox, new THREE.Vector3());
const hitDistance = hit ? start.distanceTo(hit) : Infinity;
const isBlocked = hit && hitDistance < distance - 0.06;
const line = actor.rays[i];
const impact = actor.impacts[i];
const positions = line.geometry.attributes.position;
if (isBlocked) {
blockedCount++;
anyObstruction = true;
positions.setXYZ(0, start.x, start.y, start.z);
positions.setXYZ(1, hit.x, hit.y, hit.z);
line.material.color.setHex(0xff6570);
line.material.opacity = 0.95;
impact.visible = true;
impact.position.copy(hit);
} else {
positions.setXYZ(0, start.x, start.y, start.z);
positions.setXYZ(1, target.x, target.y, target.z);
line.material.color.setHex(0x7ee8f3);
line.material.opacity = 0.3;
impact.visible = false;
}
positions.needsUpdate = true;
}
const nextStatus =
blockedCount >= 2 ? "blocked" :
blockedCount === 1 ? "partial" :
"clear";
if (actor.status !== nextStatus) {
actor.status = nextStatus;
drawBadge(actor);
}
updateStatusRow(actor, blockedCount);
}
propOutline.visible = anyObstruction;
}
// Camera controls are implemented directly, without Three.js addons.
function applyOrbit() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
}
function applyAudience() {
camera.position.set(0, 1.55, 6.65 + audienceZoom);
camera.lookAt(0, 1.25, -1.0);
}
function setView(mode) {
viewMode = mode;
if (mode === "audience") {
audienceZoom = 1.45;
applyAudience();
viewButton.textContent = "Orbit View";
viewButton.classList.add("primary");
} else {
applyOrbit();
viewButton.textContent = "Audience POV";
viewButton.classList.remove("primary");
}
}
viewButton.addEventListener("click", () => {
setView(viewMode === "audience" ? "orbit" : "audience");
});
function resetProp() {
prop.position.set(0, 0, 0.45);
updateVisibility();
}
resetButton.addEventListener("click", resetProp);
document.querySelectorAll("[data-block]").forEach(button => {
button.addEventListener("click", () => {
prop.position.x = Number(button.dataset.block);
prop.position.z = 0.45;
updateVisibility();
});
});
const pointer = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
const dragPlane = new THREE.Plane(new THREE.Vector3(0, 1, 0), -stageTop);
const dragPoint = new THREE.Vector3();
const dragOffset = new THREE.Vector3();
let pointerState = null;
let lastX = 0;
let lastY = 0;
function updatePointer(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;
}
renderer.domElement.addEventListener("pointerdown", event => {
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
const propHit = raycaster.intersectObjects(propPickMeshes, false)[0];
if (event.button === 0 && propHit) {
raycaster.ray.intersectPlane(dragPlane, dragPoint);
dragOffset.set(
prop.position.x - dragPoint.x,
0,
prop.position.z - dragPoint.z
);
pointerState = "drag";
} else if (event.button === 0 && viewMode === "orbit") {
pointerState = "orbit";
} else {
pointerState = null;
}
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = pointerState === "drag" ? "grabbing" : "grab";
});
renderer.domElement.addEventListener("pointermove", event => {
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
if (pointerState === "drag") {
if (raycaster.ray.intersectPlane(dragPlane, dragPoint)) {
prop.position.x = THREE.MathUtils.clamp(
dragPoint.x + dragOffset.x,
-4.25,
4.25
);
prop.position.z = THREE.MathUtils.clamp(
dragPoint.z + dragOffset.z,
-0.2,
1.65
);
updateVisibility();
}
} else if (pointerState === "orbit") {
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(
orbit.phi + dy * 0.005,
0.28,
1.43
);
applyOrbit();
} else {
const hit = raycaster.intersectObjects(propPickMeshes, false)[0];
renderer.domElement.style.cursor = hit ? "grab" : "default";
}
lastX = event.clientX;
lastY = event.clientY;
});
function endPointer(event) {
pointerState = null;
renderer.domElement.style.cursor = "grab";
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("contextmenu", event => event.preventDefault());
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
if (viewMode === "audience") {
audienceZoom = THREE.MathUtils.clamp(
audienceZoom + event.deltaY * 0.0018,
0.72,
4.0
);
applyAudience();
} else {
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * Math.exp(event.deltaY * 0.001),
7.5,
25
);
applyOrbit();
}
},
{ passive: false }
);
addEventListener("keydown", event => {
if (event.key.toLowerCase() === "r") resetProp();
if (event.key.toLowerCase() === "v") {
setView(viewMode === "audience" ? "orbit" : "audience");
}
});
addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
updateVisibility();
applyOrbit();
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
const pulse = 1 + Math.sin(time * 2.4) * 0.035;
selectionRing.scale.set(pulse, pulse, pulse);
if (anyObstruction) {
propOutline.material.opacity = 0.62 + Math.sin(time * 4.2) * 0.25;
}
for (const actor of actorDefs) {
for (const impact of actor.impacts) {
if (impact.visible) {
const impactPulse = 1 + Math.sin(time * 5.5) * 0.1;
impact.scale.setScalar(0.4 * impactPulse);
}
}
}
coneMaterial.opacity = 0.042 + Math.sin(time * 1.4) * 0.008;
renderer.render(scene, camera);
}
animate();
document.getElementById("loading").style.display = "none";
</script>
</body>
</html>
```