Prompt specification
Build or customize the Three.js 3D scene "Inclusive visitor announcement 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: Inclusive visitor announcement demo
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/inclusive-visitor-announcement-demo-x0016
Scene Description Prompt:
Build a house entrance and two interior rooms; a doorbell press triggers synchronized visual signals in each room while a simple timeline shows the shared event. Build this with Three.js from cdnjs as a low-poly scene in one self-contained HTML file.
Working Three.js Starter (inclusive-visitor-announcement-demo-x0016):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Linked House — Doorbell Event</title>
<style>
:root {
--ink: #17343a;
--muted: #668087;
--panel: rgba(250, 252, 249, 0.91);
--line: rgba(23, 52, 58, 0.14);
--accent: #ee654f;
--teal: #28b6a6;
--gold: #f3a94c;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce8e9;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
#hud {
position: fixed;
inset: 0;
z-index: 10;
pointer-events: none;
}
.panel {
border: 1px solid rgba(255, 255, 255, 0.72);
background: var(--panel);
box-shadow: 0 14px 42px rgba(32, 64, 66, 0.14);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
#intro {
position: absolute;
top: 22px;
left: 22px;
width: min(350px, calc(100vw - 44px));
padding: 18px 20px 16px;
border-radius: 18px;
}
.eyebrow {
margin-bottom: 7px;
color: var(--accent);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(23px, 3vw, 34px);
line-height: 1;
letter-spacing: -0.045em;
}
.subtitle {
margin: 10px 0 14px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 8px 14px;
padding-top: 12px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 11px;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
}
.dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 3px rgba(40, 182, 166, 0.13);
}
.dot.gold {
background: var(--gold);
box-shadow: 0 0 0 3px rgba(243, 169, 76, 0.14);
}
.dot.red {
background: var(--accent);
box-shadow: 0 0 0 3px rgba(238, 101, 79, 0.14);
}
#actions {
position: absolute;
top: 22px;
right: 22px;
display: flex;
align-items: center;
gap: 10px;
pointer-events: auto;
}
button {
border: 0;
font: inherit;
cursor: pointer;
}
#bell-button {
display: inline-flex;
align-items: center;
gap: 10px;
min-height: 48px;
padding: 0 18px;
border-radius: 14px;
color: white;
background: var(--ink);
box-shadow: 0 10px 26px rgba(23, 52, 58, 0.23);
font-size: 13px;
font-weight: 750;
transition:
transform 150ms ease,
background 150ms ease;
}
#bell-button:hover {
background: #24515a;
transform: translateY(-1px);
}
#bell-button:active,
#bell-button.pressed {
transform: translateY(1px) scale(0.97);
}
#bell-button svg {
width: 19px;
height: 19px;
fill: none;
stroke: currentColor;
stroke-width: 1.8;
stroke-linecap: round;
stroke-linejoin: round;
}
#reset-button {
width: 48px;
height: 48px;
border-radius: 14px;
color: var(--ink);
background: var(--panel);
border: 1px solid rgba(255, 255, 255, 0.8);
box-shadow: 0 10px 26px rgba(23, 52, 58, 0.13);
font-size: 21px;
}
#live-status {
position: absolute;
top: 84px;
right: 22px;
max-width: 270px;
padding: 10px 13px;
border-radius: 12px;
color: var(--muted);
background: rgba(250, 252, 249, 0.86);
border: 1px solid rgba(255, 255, 255, 0.75);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.09em;
text-align: right;
text-transform: uppercase;
}
#timeline-panel {
position: absolute;
left: 50%;
bottom: 20px;
width: min(780px, calc(100vw - 32px));
padding: 15px 18px 16px;
border-radius: 18px;
transform: translateX(-50%);
}
.timeline-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
margin-bottom: 12px;
}
.timeline-title {
font-size: 11px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.timeline-note {
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.timeline-scale,
.sync-row {
display: grid;
grid-template-columns: 112px 1fr 76px;
align-items: center;
gap: 12px;
}
.timeline-scale {
margin-bottom: 6px;
color: #809499;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.04em;
}
.scale-inner {
display: flex;
justify-content: space-between;
padding: 0 3px;
}
.sync-row {
min-height: 27px;
}
.track-label {
color: #47646a;
font-size: 11px;
font-weight: 750;
}
.track {
position: relative;
height: 5px;
border-radius: 999px;
background: rgba(23, 52, 58, 0.11);
}
.track-fill {
position: absolute;
inset: 0 auto 0 0;
width: 0;
border-radius: inherit;
background: linear-gradient(90deg, var(--teal), var(--gold), var(--accent));
}
.marker {
position: absolute;
top: 50%;
left: 0;
width: 11px;
height: 11px;
border: 2px solid white;
border-radius: 50%;
background: #9babad;
box-shadow: 0 2px 8px rgba(23, 52, 58, 0.2);
transform: translate(-50%, -50%);
transition: background 120ms ease;
}
.sync-row.active .marker {
background: var(--accent);
box-shadow:
0 0 0 4px rgba(238, 101, 79, 0.13),
0 2px 8px rgba(23, 52, 58, 0.2);
}
.track-state {
color: #87999d;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.08em;
text-align: right;
}
.sync-row.active .track-state {
color: var(--accent);
}
@media (max-width: 720px) {
#intro {
top: 14px;
left: 14px;
width: calc(100vw - 84px);
padding: 14px 16px;
}
.subtitle {
display: none;
}
.legend {
margin-top: 10px;
padding-top: 10px;
}
#actions {
top: 14px;
right: 14px;
}
#bell-button {
width: 48px;
padding: 0;
justify-content: center;
}
#bell-button span {
display: none;
}
#live-status {
top: 72px;
right: 14px;
max-width: 220px;
}
#timeline-panel {
bottom: 10px;
width: calc(100vw - 20px);
padding: 13px 12px;
}
.timeline-note {
display: none;
}
.timeline-scale,
.sync-row {
grid-template-columns: 82px 1fr 57px;
gap: 8px;
}
.track-label {
font-size: 10px;
}
}
</style>
</head>
<body>
<div id="hud">
<section id="intro" class="panel">
<div class="eyebrow">Shared Signal House</div>
<h1>One press. Every room.</h1>
<p class="subtitle">
Press the physical doorbell or use the button. The entrance and both
interior rooms respond from the same event clock.
</p>
<div class="legend">
<span><i class="dot red"></i> Entrance</span>
<span><i class="dot"></i> Living room</span>
<span><i class="dot gold"></i> Study</span>
</div>
</section>
<div id="actions">
<button id="bell-button" type="button" aria-label="Press the doorbell">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M18 8a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9"></path>
<path d="M10 21h4"></path>
</svg>
<span>Press doorbell</span>
</button>
<button id="reset-button" type="button" title="Reset camera" aria-label="Reset camera">
↺
</button>
</div>
<div id="live-status" role="status" aria-live="polite">
Ready · 3 nodes standing by
</div>
<section id="timeline-panel" class="panel" aria-label="Shared event timeline">
<div class="timeline-header">
<div class="timeline-title">Shared Event Timeline</div>
<div class="timeline-note">One input / three synchronized nodes</div>
</div>
<div class="timeline-scale">
<span>Node</span>
<div class="scale-inner">
<span>0.0 s</span>
<span>1.5 s</span>
<span>3.0 s</span>
</div>
<span>State</span>
</div>
<div class="sync-row" data-node="entrance">
<div class="track-label">Entrance</div>
<div class="track">
<div class="track-fill"></div>
<div class="marker"></div>
</div>
<div class="track-state">READY</div>
</div>
<div class="sync-row" data-node="living">
<div class="track-label">Living room</div>
<div class="track">
<div class="track-fill"></div>
<div class="marker"></div>
</div>
<div class="track-state">READY</div>
</div>
<div class="sync-row" data-node="study">
<div class="track-label">Study</div>
<div class="track">
<div class="track-fill"></div>
<div class="marker"></div>
</div>
<div class="track-state">READY</div>
</div>
</section>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer and scene
// ------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce8e9);
scene.fog = new THREE.Fog(0xdce8e9, 19, 39);
const camera = new THREE.PerspectiveCamera(
38,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.appendChild(renderer.domElement);
const ambient = new THREE.HemisphereLight(0xeaf8f7, 0x8a806d, 2.15);
scene.add(ambient);
const sun = new THREE.DirectionalLight(0xfff0d6, 3.4);
sun.position.set(-7, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -14;
sun.shadow.camera.right = 14;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 35;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const rim = new THREE.DirectionalLight(0xbbe8ff, 1.15);
rim.position.set(10, 7, -8);
scene.add(rim);
// ------------------------------------------------------------
// Materials and geometry helpers
// ------------------------------------------------------------
const standard = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.84,
metalness: 0,
flatShading: true,
...options
});
const mat = {
ground: standard(0xaec6b5),
grass: standard(0x8eb49b),
path: standard(0xd9d4c7),
porch: standard(0xc9b899),
floorA: standard(0xd2ac78),
floorB: standard(0xc9ad82),
wall: standard(0xf0eee4),
wallCool: standard(0xdce7e3),
trim: standard(0x27545b),
wood: standard(0x976847),
woodLight: standard(0xc89562),
darkWood: standard(0x674837),
sofa: standard(0x3b8f89),
sofaLight: standard(0x63aaa0),
rugA: standard(0xd8795f),
rugB: standard(0x7ba7a2),
cream: standard(0xf3e9d5),
black: standard(0x23363a),
screen: standard(0x18383d, { roughness: 0.45 }),
leaf: standard(0x427e54),
leafLight: standard(0x6da26d),
pot: standard(0xb86d4b),
trunk: standard(0x76513a),
white: standard(0xf8f6ed),
yellow: standard(0xe9b654),
red: standard(0xcf6454),
blue: standard(0x568da5)
};
function addBox(size, position, material, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(...size),
material
);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
radiusTop,
radiusBottom,
height,
position,
material,
segments = 12,
parent = scene
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
material
);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addLowPolySphere(radius, position, material, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.IcosahedronGeometry(radius, 0),
material
);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addLabel(text, position, width = 2.6) {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 150;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "rgba(248,250,246,0.92)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = "rgba(23,52,58,0.16)";
ctx.lineWidth = 5;
ctx.strokeRect(3, 3, canvas.width - 6, canvas.height - 6);
ctx.fillStyle = "#17343a";
ctx.font = "800 47px Arial, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, canvas.width / 2, canvas.height / 2 + 2);
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.position.set(...position);
sprite.scale.set(width, width * 0.234, 1);
sprite.renderOrder = 30;
scene.add(sprite);
return sprite;
}
// ------------------------------------------------------------
// Ground, entrance, and cutaway rooms
// ------------------------------------------------------------
addBox([20, 0.3, 13], [0, -0.31, 0], mat.ground);
addBox([15.5, 0.06, 8.2], [0, -0.13, -0.6], mat.grass);
// Entrance porch and approach.
addBox([3.35, 0.22, 5.0], [-5.45, -0.11, 0], mat.porch);
addBox([1.45, 0.08, 0.68], [-5.0, -0.07, 3.05], mat.path);
addBox([1.55, 0.08, 0.68], [-5.0, -0.07, 4.0], mat.path);
addBox([1.65, 0.08, 0.68], [-5.0, -0.07, 4.95], mat.path);
addBox([1.1, 0.025, 0.75], [-4.25, 0.015, -0.2], mat.rugA);
// Room floors.
addBox([4.9, 0.18, 4.6], [-0.75, -0.09, 0], mat.floorA);
addBox([4.9, 0.18, 4.6], [4.7, -0.09, 0], mat.floorB);
addBox([0.3, 0.2, 2.0], [-3.28, -0.08, -0.3], mat.woodLight);
// Back walls.
addBox([4.9, 2.75, 0.16], [-0.75, 1.375, -2.25], mat.wall);
addBox([4.9, 2.75, 0.16], [4.7, 1.375, -2.25], mat.wallCool);
addBox([4.85, 0.12, 0.08], [-0.75, 0.14, -2.13], mat.trim);
addBox([4.85, 0.12, 0.08], [4.7, 0.14, -2.13], mat.trim);
// Cutaway front and side walls.
addBox([0.14, 0.78, 4.6], [1.95, 0.39, 0], mat.wall);
addBox([0.14, 0.78, 4.6], [7.15, 0.39, 0], mat.wallCool);
addBox([0.16, 1.0, 1.2], [1.95, 2.2, -1.65], mat.wall);
// Entrance wall with a real doorway opening.
addBox([0.18, 2.7, 1.12], [-3.35, 1.35, -1.69], mat.wall);
addBox([0.18, 2.7, 1.8], [-3.35, 1.35, 1.35], mat.wall);
addBox([0.18, 0.46, 1.48], [-3.35, 2.47, -0.3], mat.wall);
// Door and frame.
addBox([0.09, 2.13, 1.36], [-3.205, 1.065, -0.3], mat.darkWood);
addBox([0.1, 0.13, 1.55], [-3.13, 2.22, -0.3], mat.trim);
addBox([0.1, 2.28, 0.13], [-3.13, 1.14, -1.01], mat.trim);
addBox([0.1, 2.28, 0.13], [-3.13, 1.14, 0.41], mat.trim);
addBox([0.12, 0.07, 0.32], [-3.12, 1.0, 0.14], mat.yellow);
// Door inset panels.
addBox([0.025, 0.67, 0.91], [-3.15, 1.48, -0.3], mat.wood);
addBox([0.025, 0.55, 0.91], [-3.15, 0.65, -0.3], mat.wood);
// Small canopy.
addBox([1.35, 0.13, 2.02], [-3.84, 2.73, -0.3], mat.trim);
addCylinder(0.045, 0.045, 2.25, [-4.43, 1.15, 0.62], mat.trim);
addCylinder(0.045, 0.045, 2.25, [-4.43, 1.15, -1.22], mat.trim);
// Mailbox.
addBox([0.12, 0.75, 0.12], [-6.55, 0.38, 1.25], mat.darkWood);
addBox([0.62, 0.35, 0.46], [-6.55, 0.91, 1.25], mat.trim);
addBox([0.03, 0.22, 0.31], [-6.87, 0.94, 1.25], mat.black);
// ------------------------------------------------------------
// Living room furniture
// ------------------------------------------------------------
addBox([2.75, 0.035, 1.72], [-0.85, 0.025, 0.2], mat.rugA);
addBox([2.65, 0.43, 0.85], [-0.85, 0.39, -1.45], mat.sofa);
addBox([2.4, 0.23, 0.65], [-0.85, 0.72, -1.23], mat.sofaLight);
addBox([2.65, 0.86, 0.22], [-0.85, 1.16, -1.72], mat.sofa);
addBox([0.23, 0.73, 0.85], [-2.22, 0.73, -1.45], mat.sofa);
addBox([0.23, 0.73, 0.85], [0.52, 0.73, -1.45], mat.sofa);
addBox([0.45, 0.42, 0.16], [-1.53, 1.02, -1.52], mat.cream);
addBox([0.43, 0.4, 0.16], [-0.08, 1.0, -1.52], mat.yellow);
addBox([0.45, 0.42, 0.16], [-1.53, 1.02, -1.52], mat.cream);
addBox([0.45, 0.4, 0.16], [-0.08, 1.0, -1.52], mat.red);
addCylinder(0.64, 0.64, 0.12, [-0.82, 0.48, 0.15], mat.woodLight, 16);
addCylinder(0.1, 0.18, 0.4, [-0.82, 0.23, 0.15], mat.darkWood, 10);
addBox([0.48, 0.05, 0.3], [-0.55, 0.58, 0.18], mat.cream);
// Plant.
addCylinder(0.24, 0.18, 0.43, [-2.6, 0.22, 0.72], mat.pot, 10);
addCylinder(0.035, 0.045, 0.85, [-2.6, 0.82, 0.72], mat.trunk, 8);
addLowPolySphere(0.38, [-2.63, 1.28, 0.72], mat.leaf);
addLowPolySphere(0.28, [-2.29, 1.1, 0.78], mat.leafLight);
addLowPolySphere(0.27, [-2.91, 1.03, 0.68], mat.leaf);
// ------------------------------------------------------------
// Study furniture
// ------------------------------------------------------------
addBox([2.5, 0.16, 0.9], [4.05, 0.92, -1.2], mat.woodLight);
addBox([0.13, 0.85, 0.13], [3.0, 0.44, -1.05], mat.darkWood);
addBox([0.13, 0.85, 0.13], [5.1, 0.44, -1.05], mat.darkWood);
addBox([0.13, 0.85, 0.13], [3.0, 0.44, -1.48], mat.darkWood);
addBox([0.13, 0.85, 0.13], [5.1, 0.44, -1.48], mat.darkWood);
addBox([1.2, 0.72, 0.1], [4.05, 1.42, -1.6], mat.black);
addBox([1.05, 0.58, 0.025], [4.05, 1.42, -1.535], mat.screen);
addBox([0.07, 0.28, 0.07], [4.05, 1.02, -1.6], mat.black);
addBox([0.42, 0.03, 0.28], [4.05, 1.025, -1.05], mat.black);
addLowPolySphere(0.08, [4.44, 1.08, -1.0], mat.cream);
// Chair.
addBox([0.72, 0.16, 0.72], [4.05, 0.53, -0.22], mat.trim);
addBox([0.72, 0.75, 0.15], [4.05, 0.9, -0.53], mat.trim);
addCylinder(0.045, 0.06, 0.47, [4.05, 0.24, -0.22], mat.black, 8);
// Bookcase.
addBox([1.55, 2.2, 0.12], [6.15, 1.1, -2.02], mat.darkWood);
addBox([0.1, 2.1, 0.38], [5.43, 1.1, -1.82], mat.darkWood);
addBox([0.1, 2.1, 0.38], [6.87, 1.1, -1.82], mat.darkWood);
for (const y of [0.22, 0.78, 1.34, 1.9]) {
addBox([1.42, 0.08, 0.4], [6.15, y, -1.8], mat.woodLight);
}
const bookColors = [mat.red, mat.yellow, mat.blue, mat.cream, mat.trim];
const bookHeights = [0.32, 0.43, 0.36, 0.48, 0.39];
for (let shelf = 0; shelf < 4; shelf++) {
for (let book = 0; book < 6; book++) {
addBox(
[0.11, bookHeights[(book + shelf) % bookHeights.length], 0.23],
[5.62 + book * 0.18, 0.29 + shelf * 0.56 + 0.17, -1.78],
bookColors[(book + shelf) % bookColors.length]
);
}
}
// ------------------------------------------------------------
// Outdoor accents
// ------------------------------------------------------------
function addTree(x, z, scale = 1) {
addCylinder(
0.14 * scale,
0.19 * scale,
1.7 * scale,
[x, 0.69 * scale, z],
mat.trunk,
7
);
const crown = addLowPolySphere(
0.95 * scale,
[x, 1.9 * scale, z],
mat.leaf
);
crown.scale.y = 1.12;
}
addTree(-8.0, -3.6, 1.1);
addTree(8.1, -4.2, 1.25);
for (const [x, z, s] of [
[-7.2, 1.8, 0.35],
[-3.8, 2.5, 0.28],
[7.8, 1.3, 0.38],
[8.4, 0.4, 0.3]
]) {
const shrub = addLowPolySphere(s, [x, s * 0.7, z], mat.leafLight);
shrub.scale.y = 0.8;
}
// Labels.
addLabel("01 · ENTRANCE", [-5.35, 3.45, 0.1], 2.65);
addLabel("ROOM A · LIVING", [-0.8, 3.2, -1.8], 2.65);
addLabel("ROOM B · STUDY", [4.75, 3.2, -1.8], 2.45);
// ------------------------------------------------------------
// Signal systems
// ------------------------------------------------------------
const signals = [];
function glowMaterial(accent, dark = false) {
const material = standard(
dark ? 0x17363b : accent,
{
emissive: accent,
emissiveIntensity: dark ? 0.18 : 0.5,
roughness: 0.5
}
);
material.userData.baseEmissive = material.emissiveIntensity;
return material;
}
function createRoomSignal(roomX, panelX, accent) {
// Wall alert panel.
addBox(
[0.95, 0.62, 0.11],
[panelX, 1.55, -2.105],
mat.black
);
const screenMaterial = glowMaterial(accent, true);
addBox(
[0.78, 0.46, 0.025],
[panelX, 1.55, -2.035],
screenMaterial
);
const ringMaterial = new THREE.MeshStandardMaterial({
color: accent,
emissive: accent,
emissiveIntensity: 0.7,
transparent: true,
opacity: 0.62,
roughness: 0.4
});
const panelRing = new THREE.Mesh(
new THREE.TorusGeometry(0.13, 0.025, 6, 18),
ringMaterial
);
panelRing.position.set(panelX, 1.55, -2.005);
scene.add(panelRing);
// Accent light strip.
const stripMaterial = glowMaterial(accent);
addBox(
[4.25, 0.055, 0.04],
[roomX, 2.48, -2.13],
stripMaterial
);
// Pendant lamp.
addCylinder(0.022, 0.022, 0.67, [roomX, 2.96, -0.3], mat.black, 8);
const shade = addCylinder(
0.18,
0.43,
0.33,
[roomX, 2.47, -0.3],
mat.trim,
12
);
shade.rotation.y = Math.PI / 12;
const bulbMaterial = glowMaterial(accent);
const bulb = addLowPolySphere(
0.12,
[roomX, 2.27, -0.3],
bulbMaterial
);
// Horizontal halo around the bulb.
const haloMaterial = new THREE.MeshBasicMaterial({
color: accent,
transparent: true,
opacity: 0.12,
depthWrite: false
});
const halo = new THREE.Mesh(
new THREE.TorusGeometry(0.48, 0.025, 6, 24),
haloMaterial
);
halo.rotation.x = Math.PI / 2;
halo.position.set(roomX, 2.27, -0.3);
scene.add(halo);
// Soft-looking low-poly column of signal light.
const columnMaterial = new THREE.MeshBasicMaterial({
color: accent,
transparent: true,
opacity: 0,
depthWrite: false,
side: THREE.DoubleSide
});
const column = new THREE.Mesh(
new THREE.CylinderGeometry(0.36, 0.56, 2.0, 14, 1, true),
columnMaterial
);
column.position.set(roomX, 1.18, -0.3);
scene.add(column);
// Floor projection.
const discMaterial = new THREE.MeshBasicMaterial({
color: accent,
transparent: true,
opacity: 0.04,
depthWrite: false
});
const disc = new THREE.Mesh(
new THREE.CylinderGeometry(0.58, 0.58, 0.015, 24),
discMaterial
);
disc.position.set(roomX, 0.035, -0.3);
scene.add(disc);
const light = new THREE.PointLight(accent, 2.5, 5.5, 2);
light.position.set(roomX, 2.12, -0.3);
scene.add(light);
signals.push({
rings: [panelRing, halo],
glowMaterials: [screenMaterial, stripMaterial, bulbMaterial],
light,
columns: [column],
discs: [disc]
});
}
createRoomSignal(-0.75, 1.1, 0x35c6b4);
createRoomSignal(4.7, 2.8, 0xf3a94c);
// Entrance doorbell and its matching signal.
addBox([0.055, 0.43, 0.24], [-3.2, 1.45, 0.95], mat.black);
const bellMaterial = glowMaterial(0xff6b57);
const doorbellButton = addCylinder(
0.105,
0.105,
0.065,
[-3.135, 1.47, 0.95],
bellMaterial,
16
);
doorbellButton.rotation.z = Math.PI / 2;
const bellRingMaterial = new THREE.MeshStandardMaterial({
color: 0xff6b57,
emissive: 0xff6b57,
emissiveIntensity: 0.7,
transparent: true,
opacity: 0.65,
roughness: 0.4
});
const bellRing = new THREE.Mesh(
new THREE.TorusGeometry(0.18, 0.025, 6, 20),
bellRingMaterial
);
bellRing.rotation.y = Math.PI / 2;
bellRing.position.set(-3.08, 1.47, 0.95);
scene.add(bellRing);
const bellLight = new THREE.PointLight(0xff6b57, 1.5, 3.2, 2);
bellLight.position.set(-3.0, 1.48, 0.95);
scene.add(bellLight);
const bellDiscMaterial = new THREE.MeshBasicMaterial({
color: 0xff6b57,
transparent: true,
opacity: 0.03,
depthWrite: false
});
const bellDisc = new THREE.Mesh(
new THREE.CylinderGeometry(0.43, 0.43, 0.015, 20),
bellDiscMaterial
);
bellDisc.position.set(-3.95, 0.035, 0.95);
scene.add(bellDisc);
signals.push({
rings: [bellRing],
glowMaterials: [bellMaterial],
light: bellLight,
columns: [],
discs: [bellDisc]
});
// A larger invisible hit target makes the small button easy to click.
const hitMaterial = new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false
});
const bellHitTarget = new THREE.Mesh(
new THREE.SphereGeometry(0.3, 10, 8),
hitMaterial
);
bellHitTarget.position.set(-3.08, 1.47, 0.95);
scene.add(bellHitTarget);
const interactiveObjects = [bellHitTarget, doorbellButton];
// ------------------------------------------------------------
// Direct camera controls: no addons
// ------------------------------------------------------------
const target = new THREE.Vector3(0, 1.05, 0);
const desiredTarget = target.clone();
let desiredTheta = 0.68;
let desiredPhi = 1.04;
let desiredRadius = 18.1;
let currentTheta = desiredTheta;
let currentPhi = desiredPhi;
let currentRadius = desiredRadius;
const canvas = renderer.domElement;
const pointer = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
let drag = null;
function updateCamera() {
const smoothing = 0.13;
currentTheta = THREE.MathUtils.lerp(currentTheta, desiredTheta, smoothing);
currentPhi = THREE.MathUtils.lerp(currentPhi, desiredPhi, smoothing);
currentRadius = THREE.MathUtils.lerp(currentRadius, desiredRadius, smoothing);
target.lerp(desiredTarget, smoothing);
const sinPhi = Math.sin(currentPhi);
camera.position.set(
target.x + currentRadius * sinPhi * Math.sin(currentTheta),
target.y + currentRadius * Math.cos(currentPhi),
target.z + currentRadius * sinPhi * Math.cos(currentTheta)
);
camera.lookAt(target);
}
function isDoorbellHit(clientX, clientY) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
return raycaster.intersectObjects(interactiveObjects, false).length > 0;
}
canvas.addEventListener("pointerdown", (event) => {
if (event.button !== 0 && event.button !== 2) return;
drag = {
pointerId: event.pointerId,
lastX: event.clientX,
lastY: event.clientY,
moved: 0,
pan: event.shiftKey || event.button === 2
};
canvas.setPointerCapture(event.pointerId);
canvas.style.cursor = "grabbing";
});
canvas.addEventListener("pointermove", (event) => {
if (!drag || drag.pointerId !== event.pointerId) {
canvas.style.cursor = isDoorbellHit(event.clientX, event.clientY)
? "pointer"
: "grab";
return;
}
const dx = event.clientX - drag.lastX;
const dy = event.clientY - drag.lastY;
drag.lastX = event.clientX;
drag.lastY = event.clientY;
drag.moved += Math.hypot(dx, dy);
if (drag.pan) {
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
const right = new THREE.Vector3()
.crossVectors(forward, camera.up)
.normalize();
const up = new THREE.Vector3()
.crossVectors(right, forward)
.normalize();
const factor = currentRadius * 0.00125;
desiredTarget.addScaledVector(right, -dx * factor);
desiredTarget.addScaledVector(up, dy * factor);
desiredTarget.x = THREE.MathUtils.clamp(desiredTarget.x, -3, 3);
desiredTarget.y = THREE.MathUtils.clamp(desiredTarget.y, 0.35, 2.8);
desiredTarget.z = THREE.MathUtils.clamp(desiredTarget.z, -2.5, 2.5);
} else {
desiredTheta -= dx * 0.006;
desiredPhi = THREE.MathUtils.clamp(
desiredPhi - dy * 0.005,
0.52,
1.35
);
}
});
canvas.addEventListener("pointerup", (event) => {
if (!drag || drag.pointerId !== event.pointerId) return;
const wasClick = drag.moved < 5 && event.button === 0;
drag = null;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
canvas.style.cursor = isDoorbellHit(event.clientX, event.clientY)
? "pointer"
: "grab";
if (wasClick && isDoorbellHit(event.clientX, event.clientY)) {
triggerDoorbell();
}
});
canvas.addEventListener("pointercancel", () => {
drag = null;
canvas.style.cursor = "grab";
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredRadius = THREE.MathUtils.clamp(
desiredRadius * Math.exp(event.deltaY * 0.001),
10,
26
);
},
{ passive: false }
);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
document.getElementById("reset-button").addEventListener("click", () => {
desiredTarget.set(0, 1.05, 0);
desiredTheta = 0.68;
desiredPhi = 1.04;
desiredRadius = 18.1;
});
// ------------------------------------------------------------
// Shared event timeline and synchronized animation
// ------------------------------------------------------------
const EVENT_DURATION = 3.0;
let eventStart = null;
let statusPhase = "ready";
const bellButton = document.getElementById("bell-button");
const liveStatus = document.getElementById("live-status");
const rows = [...document.querySelectorAll(".sync-row")].map((row) => ({
element: row,
fill: row.querySelector(".track-fill"),
marker: row.querySelector(".marker"),
state: row.querySelector(".track-state")
}));
function triggerDoorbell() {
eventStart = performance.now() * 0.001;
statusPhase = "active";
bellButton.classList.remove("pressed");
void bellButton.offsetWidth;
bellButton.classList.add("pressed");
setTimeout(() => bellButton.classList.remove("pressed"), 250);
for (const row of rows) {
row.element.classList.add("active");
row.element.classList.remove("complete");
}
liveStatus.textContent = "Signal active · 3 / 3 nodes synchronized";
}
bellButton.addEventListener("click", triggerDoorbell);
addEventListener("keydown", (event) => {
if (
event.code === "Space" &&
event.target.tagName !== "BUTTON"
) {
event.preventDefault();
triggerDoorbell();
}
});
function sharedPulse(now) {
if (eventStart === null) return 0;
const elapsed = now - eventStart;
if (elapsed < 0 || elapsed >= EVENT_DURATION) return 0;
const decay = Math.pow(1 - elapsed / EVENT_DURATION, 1.45);
const oscillation = 0.55 + 0.45 * Math.sin(elapsed * 11 + Math.PI / 2);
return decay * oscillation;
}
function updateTimeline(now) {
if (eventStart === null) {
for (const row of rows) {
row.fill.style.width = "0%";
row.marker.style.left = "0%";
row.state.textContent = "READY";
}
return;
}
const elapsed = now - eventStart;
const progress = THREE.MathUtils.clamp(elapsed / EVENT_DURATION, 0, 1);
const complete = elapsed >= EVENT_DURATION;
for (const row of rows) {
row.fill.style.width = `${progress * 100}%`;
row.marker.style.left = `${progress * 100}%`;
row.state.textContent = complete ? "SYNCED" : "PULSE";
row.element.classList.toggle("complete", complete);
}
if (complete && statusPhase === "active") {
statusPhase = "complete";
liveStatus.textContent = "Event complete · all nodes synchronized";
}
}
function updateSignals(now, pulse) {
for (const signal of signals) {
for (const material of signal.glowMaterials) {
material.emissiveIntensity =
material.userData.baseEmissive + pulse * 4.8;
}
for (const ring of signal.rings) {
ring.scale.setScalar(1 + pulse * 0.62);
ring.material.opacity = 0.25 + pulse * 0.65;
}
signal.light.intensity = 1.5 + pulse * 20;
for (const column of signal.columns) {
column.material.opacity = pulse * 0.13;
column.scale.set(1 + pulse * 0.18, 1, 1 + pulse * 0.18);
}
for (const disc of signal.discs) {
disc.material.opacity = 0.025 + pulse * 0.24;
disc.scale.setScalar(1 + pulse * 0.42);
}
}
doorbellButton.scale.setScalar(1 + pulse * 0.12);
}
// ------------------------------------------------------------
// Resize and render loop
// ------------------------------------------------------------
addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
});
updateCamera();
renderer.setAnimationLoop(() => {
const now = performance.now() * 0.001;
const pulse = sharedPulse(now);
updateCamera();
updateTimeline(now);
updateSignals(now, pulse);
renderer.render(scene, camera);
});
</script>
</body>
</html>
```