Prompt specification
Build or customize the Three.js 3D scene "Warehouse access-rule teaching scene" 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: Warehouse access-rule teaching scene
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/warehouse-access-rule-teaching-scene-x1855
Scene Description Prompt:
A fictional voxel warehouse door controlled by badge, opening-hours, and override switches; display its Boolean rule. Three.js from cdnjs, one HTML file.
Working Three.js Starter (warehouse-access-rule-teaching-scene-x1855):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voxel Warehouse Access Control</title>
<style>
:root {
color-scheme: dark;
--bg: #0c1218;
--panel: rgba(13, 20, 27, 0.9);
--border: rgba(255, 255, 255, 0.12);
--text: #edf5f7;
--muted: #8fa5ad;
--green: #54f08b;
--red: #ff5a57;
--amber: #ffc857;
--cyan: #67d8ff;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
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;
}
#ui {
position: fixed;
inset: 0;
pointer-events: none;
}
.panel {
pointer-events: auto;
border: 1px solid var(--border);
border-radius: 16px;
background: var(--panel);
box-shadow:
0 18px 60px rgba(0, 0, 0, 0.35),
inset 0 1px 0 rgba(255, 255, 255, 0.04);
backdrop-filter: blur(14px);
}
.control-panel {
position: absolute;
top: 22px;
left: 22px;
width: min(350px, calc(100vw - 44px));
padding: 20px;
}
.eyebrow {
margin-bottom: 7px;
color: var(--cyan);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 27px;
line-height: 1.1;
letter-spacing: -0.035em;
}
.subtitle {
margin: 8px 0 18px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.status-box {
display: flex;
align-items: center;
gap: 10px;
min-height: 48px;
margin-bottom: 15px;
padding: 11px 12px;
border: 1px solid rgba(255, 90, 87, 0.25);
border-radius: 11px;
background: rgba(255, 90, 87, 0.07);
}
.status-dot {
width: 10px;
height: 10px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--red);
box-shadow: 0 0 13px var(--red);
transition: 180ms ease;
}
.status-box.open {
border-color: rgba(84, 240, 139, 0.27);
background: rgba(84, 240, 139, 0.07);
}
.status-box.open .status-dot {
background: var(--green);
box-shadow: 0 0 13px var(--green);
}
.status-copy {
min-width: 0;
}
#status-label {
display: block;
font-size: 12px;
font-weight: 850;
letter-spacing: 0.09em;
}
#status-detail {
display: block;
margin-top: 2px;
overflow: hidden;
color: var(--muted);
font-size: 11px;
text-overflow: ellipsis;
white-space: nowrap;
}
.switch-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 12px 0;
border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.switch-copy {
min-width: 0;
}
.switch-name {
display: block;
font-size: 14px;
font-weight: 700;
}
.switch-description {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 11px;
}
.switch {
position: relative;
width: 48px;
height: 26px;
flex: 0 0 auto;
padding: 0;
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 999px;
outline: none;
background: #26313a;
cursor: pointer;
transition:
background 180ms ease,
border-color 180ms ease,
box-shadow 180ms ease;
}
.switch::after {
position: absolute;
top: 3px;
left: 3px;
width: 18px;
height: 18px;
border-radius: 50%;
background: #a7b3b9;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
content: "";
transition:
transform 180ms ease,
background 180ms ease;
}
.switch[aria-checked="true"] {
border-color: rgba(84, 240, 139, 0.55);
background: rgba(84, 240, 139, 0.25);
box-shadow: 0 0 18px rgba(84, 240, 139, 0.1);
}
.switch[aria-checked="true"]::after {
transform: translateX(22px);
background: var(--green);
}
.switch:focus-visible {
box-shadow: 0 0 0 3px rgba(103, 216, 255, 0.35);
}
.switch.override[aria-checked="true"] {
border-color: rgba(255, 200, 87, 0.6);
background: rgba(255, 200, 87, 0.23);
}
.switch.override[aria-checked="true"]::after {
background: var(--amber);
}
.rule-panel {
position: absolute;
bottom: 22px;
left: 50%;
width: min(780px, calc(100vw - 44px));
padding: 17px 20px;
transform: translateX(-50%);
}
.rule-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
margin-bottom: 12px;
}
.rule-heading strong {
font-size: 12px;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.rule-heading span {
color: var(--muted);
font-size: 11px;
}
.formula {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
gap: 9px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: clamp(12px, 1.6vw, 17px);
font-weight: 750;
text-align: center;
}
.token {
padding: 7px 10px;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 7px;
background: rgba(255, 255, 255, 0.04);
color: #81939b;
transition: 160ms ease;
}
.token.active {
border-color: rgba(103, 216, 255, 0.4);
background: rgba(103, 216, 255, 0.12);
color: var(--cyan);
box-shadow: 0 0 15px rgba(103, 216, 255, 0.08);
}
.token.active-override {
border-color: rgba(255, 200, 87, 0.45);
background: rgba(255, 200, 87, 0.12);
color: var(--amber);
box-shadow: 0 0 15px rgba(255, 200, 87, 0.08);
}
.operator {
color: #73848c;
}
.result {
min-width: 72px;
padding: 7px 12px;
border-radius: 7px;
background: rgba(255, 90, 87, 0.13);
color: var(--red);
}
.result.true {
background: rgba(84, 240, 139, 0.14);
color: var(--green);
}
.view-hint {
position: absolute;
right: 22px;
bottom: 25px;
display: flex;
align-items: center;
gap: 10px;
color: rgba(226, 240, 244, 0.62);
font-size: 11px;
pointer-events: none;
}
#reset-view {
pointer-events: auto;
padding: 8px 10px;
border: 1px solid var(--border);
border-radius: 8px;
background: rgba(13, 20, 27, 0.8);
color: var(--text);
font: inherit;
font-size: 11px;
cursor: pointer;
}
#reset-view:hover {
border-color: rgba(103, 216, 255, 0.4);
}
@media (max-width: 900px) {
.view-hint {
display: none;
}
}
@media (max-width: 600px) {
.control-panel {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 16px;
}
.rule-panel {
bottom: 12px;
width: calc(100vw - 24px);
padding: 14px 12px;
}
.rule-heading span {
display: none;
}
.formula {
gap: 5px;
}
.token {
padding: 5px 7px;
}
h1 {
font-size: 23px;
}
}
</style>
</head>
<body>
<div id="ui">
<section class="panel control-panel" aria-label="Door control switches">
<div class="eyebrow">Voxel Logistics / Access Terminal</div>
<h1>Warehouse Bay 07</h1>
<p class="subtitle">
Toggle the three access conditions and watch the automated loading door respond.
</p>
<div class="status-box" id="status-box">
<span class="status-dot" aria-hidden="true"></span>
<span class="status-copy">
<span id="status-label">LOCKED</span>
<span id="status-detail">Waiting for an authorized badge</span>
</span>
</div>
<div class="switch-row">
<span class="switch-copy">
<span class="switch-name">Badge</span>
<span class="switch-description">Valid employee credential presented</span>
</span>
<button
class="switch"
id="badge-switch"
type="button"
role="switch"
aria-checked="false"
aria-label="Badge credential"
></button>
</div>
<div class="switch-row">
<span class="switch-copy">
<span class="switch-name">Opening hours</span>
<span class="switch-description">Scheduled loading window is active</span>
</span>
<button
class="switch"
id="hours-switch"
type="button"
role="switch"
aria-checked="true"
aria-label="Opening hours"
></button>
</div>
<div class="switch-row">
<span class="switch-copy">
<span class="switch-name">Override</span>
<span class="switch-description">Supervisor bypass, independent of badge</span>
</span>
<button
class="switch override"
id="override-switch"
type="button"
role="switch"
aria-checked="false"
aria-label="Supervisor override"
></button>
</div>
</section>
<section class="panel rule-panel" aria-label="Boolean access rule">
<div class="rule-heading">
<strong>Boolean access rule</strong>
<span>Badge and hours are both required unless override is on</span>
</div>
<div class="formula">
<span class="token" id="door-token">DOOR_OPEN</span>
<span class="operator">=</span>
<span>(</span>
<span class="token" id="badge-token">BADGE</span>
<span class="operator">∧</span>
<span class="token" id="hours-token">OPENING_HOURS</span>
<span>)</span>
<span class="operator">∨</span>
<span class="token" id="override-token">OVERRIDE</span>
<span class="operator">=</span>
<span class="result" id="result">FALSE</span>
</div>
</section>
<div class="view-hint">
<span>Drag to orbit · Scroll to zoom · Double-click to reset</span>
<button id="reset-view" type="button">Reset view</button>
</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Application state and Boolean rule
// ------------------------------------------------------------
const access = {
badge: false,
hours: true,
override: false
};
const switches = {
badge: document.querySelector("#badge-switch"),
hours: document.querySelector("#hours-switch"),
override: document.querySelector("#override-switch")
};
const resultElement = document.querySelector("#result");
const statusBox = document.querySelector("#status-box");
const statusLabel = document.querySelector("#status-label");
const statusDetail = document.querySelector("#status-detail");
function evaluateDoorRule() {
return (access.badge && access.hours) || access.override;
}
function updateInterface() {
for (const [key, element] of Object.entries(switches)) {
element.setAttribute("aria-checked", String(access[key]));
}
document.querySelector("#badge-token").classList.toggle("active", access.badge);
document.querySelector("#hours-token").classList.toggle("active", access.hours);
document
.querySelector("#override-token")
.classList.toggle("active-override", access.override);
const shouldOpen = evaluateDoorRule();
resultElement.textContent = String(shouldOpen).toUpperCase();
resultElement.classList.toggle("true", shouldOpen);
if (shouldOpen) {
statusLabel.textContent = "UNLOCKING";
statusDetail.textContent = access.override
? "Supervisor override bypass active"
: "Badge accepted during opening hours";
} else {
statusLabel.textContent = "LOCKED";
statusDetail.textContent = access.badge
? "Badge valid, but opening hours are inactive"
: "Waiting for an authorized badge";
}
}
for (const [key, element] of Object.entries(switches)) {
element.addEventListener("click", () => {
access[key] = !access[key];
updateInterface();
});
}
updateInterface();
// ------------------------------------------------------------
// Renderer, scene, and camera
// ------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({ antialias: true });
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.12;
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x101820);
scene.fog = new THREE.Fog(0x101820, 17, 39);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraTarget = new THREE.Vector3(0, 3.0, -0.6);
let cameraYaw = 0.47;
let cameraPitch = 0.25;
let cameraDistance = 15;
function resetCamera() {
cameraYaw = 0.47;
cameraPitch = 0.25;
cameraDistance = 15;
}
function updateCamera() {
const horizontalDistance = cameraDistance * Math.cos(cameraPitch);
camera.position.set(
cameraTarget.x + Math.sin(cameraYaw) * horizontalDistance,
cameraTarget.y + Math.sin(cameraPitch) * cameraDistance,
cameraTarget.z + Math.cos(cameraYaw) * horizontalDistance
);
camera.lookAt(cameraTarget);
}
updateCamera();
// Direct camera controls; no addons are imported.
const activePointer = {
active: false,
id: null,
x: 0,
y: 0
};
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.pointerType === "mouse" && event.button !== 0) return;
activePointer.active = true;
activePointer.id = event.pointerId;
activePointer.x = event.clientX;
activePointer.y = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!activePointer.active || event.pointerId !== activePointer.id) return;
const deltaX = event.clientX - activePointer.x;
const deltaY = event.clientY - activePointer.y;
cameraYaw -= deltaX * 0.006;
cameraPitch = THREE.MathUtils.clamp(
cameraPitch + deltaY * 0.005,
0.08,
0.8
);
activePointer.x = event.clientX;
activePointer.y = event.clientY;
updateCamera();
});
function releasePointer(event) {
if (event.pointerId !== activePointer.id) return;
activePointer.active = false;
activePointer.id = null;
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraDistance = THREE.MathUtils.clamp(
cameraDistance + event.deltaY * 0.012,
8,
23
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
document.querySelector("#reset-view").addEventListener("click", resetCamera);
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xb8dcff, 0x25242a, 1.65);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 2.5);
keyLight.position.set(8, 13, 10);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -15;
keyLight.shadow.camera.right = 15;
keyLight.shadow.camera.top = 15;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const blueFill = new THREE.DirectionalLight(0x74aaff, 0.75);
blueFill.position.set(-9, 5, 4);
scene.add(blueFill);
// ------------------------------------------------------------
// Materials and reusable box helper
// ------------------------------------------------------------
const materials = {
facade: new THREE.MeshStandardMaterial({
color: 0x2b3942,
roughness: 0.9,
metalness: 0.08
}),
darkFacade: new THREE.MeshStandardMaterial({
color: 0x1d2931,
roughness: 0.95,
metalness: 0.05
}),
floor: new THREE.MeshStandardMaterial({
color: 0x202a30,
roughness: 0.93,
metalness: 0.04
}),
interior: new THREE.MeshStandardMaterial({
color: 0x111b22,
roughness: 0.95
}),
frame: new THREE.MeshStandardMaterial({
color: 0x495862,
roughness: 0.48,
metalness: 0.65
}),
darkMetal: new THREE.MeshStandardMaterial({
color: 0x172129,
roughness: 0.58,
metalness: 0.72
}),
yellow: new THREE.MeshStandardMaterial({
color: 0xe7ae36,
roughness: 0.62,
metalness: 0.2
}),
black: new THREE.MeshStandardMaterial({
color: 0x15191c,
roughness: 0.72,
metalness: 0.25
}),
wood: new THREE.MeshStandardMaterial({
color: 0x805b38,
roughness: 0.92
}),
woodLight: new THREE.MeshStandardMaterial({
color: 0xa77a49,
roughness: 0.9
}),
orange: new THREE.MeshStandardMaterial({
color: 0xbd5b31,
roughness: 0.72,
metalness: 0.1
})
};
function addBox(
parent,
width,
height,
depth,
x,
y,
z,
material,
castShadow = true,
receiveShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
// ------------------------------------------------------------
// Ground and warehouse facade
// ------------------------------------------------------------
const ground = addBox(
scene,
48,
0.25,
48,
0,
-0.14,
-2,
materials.floor,
false,
true
);
const grid = new THREE.GridHelper(42, 42, 0x52636a, 0x344249);
grid.position.set(0, 0.005, -2);
grid.material.transparent = true;
grid.material.opacity = 0.22;
scene.add(grid);
// Main facade, leaving a central loading-door opening.
addBox(scene, 6.5, 7.8, 1.2, -6.55, 3.9, -1.2, materials.facade);
addBox(scene, 6.5, 7.8, 1.2, 6.55, 3.9, -1.2, materials.facade);
addBox(scene, 6.4, 1.8, 1.2, 0, 7.0, -1.2, materials.facade);
// Dark interior corridor.
addBox(scene, 0.35, 6.4, 8.4, -3.35, 3.2, -5.45, materials.interior);
addBox(scene, 0.35, 6.4, 8.4, 3.35, 3.2, -5.45, materials.interior);
addBox(scene, 6.8, 6.4, 0.35, 0, 3.2, -9.55, materials.interior);
addBox(scene, 6.8, 0.12, 8.5, 0, 0.01, -5.35, materials.interior);
// Facade panel details.
for (let i = 0; i < 5; i++) {
const x = -9.1 + i * 1.2;
addBox(scene, 0.07, 6.7, 0.08, x, 3.6, -0.54, materials.darkMetal);
}
for (let i = 0; i < 5; i++) {
const x = 3.5 + i * 1.2;
addBox(scene, 0.07, 6.7, 0.08, x, 3.6, -0.54, materials.darkMetal);
}
// Door frame.
addBox(scene, 0.34, 6.15, 0.72, -3.22, 3.02, -0.22, materials.frame);
addBox(scene, 0.34, 6.15, 0.72, 3.22, 3.02, -0.22, materials.frame);
addBox(scene, 6.78, 0.38, 0.72, 0, 6.1, -0.22, materials.frame);
// Black-and-yellow hazard blocks across the lintel.
for (let i = 0; i < 14; i++) {
const material = i % 2 === 0 ? materials.yellow : materials.black;
addBox(
scene,
0.47,
0.32,
0.76,
-3.01 + i * 0.465,
6.12,
-0.19,
material
);
}
// Hazard stripes on the vertical frame edges.
for (const side of [-1, 1]) {
for (let i = 0; i < 6; i++) {
const material = i % 2 === 0 ? materials.yellow : materials.black;
addBox(
scene,
0.34,
0.46,
0.74,
side * 3.22,
0.5 + i * 0.48,
-0.19,
material
);
}
}
// ------------------------------------------------------------
// Voxel sliding door
// ------------------------------------------------------------
const leftDoor = new THREE.Group();
const rightDoor = new THREE.Group();
scene.add(leftDoor, rightDoor);
const doorColors = [
0x3b505b,
0x425a65,
0x354a55,
0x4a606a,
0x30444f
];
const columns = 8;
const rows = 7;
const spacing = 0.78;
const startX = -2.73;
for (let column = 0; column < columns; column++) {
for (let row = 0; row < rows; row++) {
const x = startX + column * spacing;
const y = 0.45 + row * spacing;
const colorIndex = (column * 3 + row * 5) % doorColors.length;
const material = new THREE.MeshStandardMaterial({
color: doorColors[colorIndex],
roughness: 0.62,
metalness: 0.48
});
const cell = addBox(
column < columns / 2 ? leftDoor : rightDoor,
0.72,
0.72,
0.32,
x,
y,
-0.72,
material
);
// A few inset rivets add scale without relying on textures.
if ((column + row) % 3 === 0) {
addBox(
cell,
0.12,
0.12,
0.035,
0.22,
0.22,
0.176,
materials.frame,
false,
false
);
}
}
}
// Bright vertical warning rails attached to the moving leaves.
addBox(
leftDoor,
0.11,
5.1,
0.38,
-2.99,
2.92,
-0.68,
materials.yellow
);
addBox(
rightDoor,
0.11,
5.1,
0.38,
2.99,
2.92,
-0.68,
materials.yellow
);
// Door center seam.
addBox(leftDoor, 0.09, 5.25, 0.38, -0.39, 2.92, -0.67, materials.black);
addBox(rightDoor, 0.09, 5.25, 0.38, 0.39, 2.92, -0.67, materials.black);
// ------------------------------------------------------------
// Status beacon
// ------------------------------------------------------------
addBox(scene, 0.72, 0.5, 0.48, 0, 6.55, -0.18, materials.darkMetal);
const beaconMaterial = new THREE.MeshStandardMaterial({
color: 0xff4038,
emissive: 0xff4038,
emissiveIntensity: 1.4,
roughness: 0.28
});
const beacon = addBox(
scene,
0.34,
0.3,
0.3,
0,
6.55,
0.12,
beaconMaterial,
false,
false
);
const beaconGlowMaterial = new THREE.MeshBasicMaterial({
color: 0xff4038,
transparent: true,
opacity: 0.16,
depthWrite: false
});
const beaconGlow = addBox(
scene,
0.62,
0.56,
0.54,
0,
6.55,
0.12,
beaconGlowMaterial,
false,
false
);
const beaconLight = new THREE.PointLight(0xff4038, 4, 4.5, 2);
beaconLight.position.set(0, 6.55, 0.5);
scene.add(beaconLight);
// ------------------------------------------------------------
// Signs made with local canvas textures
// ------------------------------------------------------------
function createSignTexture(
title,
subtitle,
background = "#18242c",
foreground = "#d9f3ff",
accent = "#67d8ff"
) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const context = canvas.getContext("2d");
context.fillStyle = background;
context.fillRect(0, 0, canvas.width, canvas.height);
context.fillStyle = accent;
context.fillRect(0, 0, 22, canvas.height);
context.fillRect(0, canvas.height - 12, canvas.width, 12);
context.fillStyle = foreground;
context.font = "800 78px Arial, sans-serif";
context.textBaseline = "middle";
context.fillText(title, 70, 91);
context.fillStyle = accent;
context.font = "700 31px monospace";
context.fillText(subtitle, 74, 179);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
4,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
const baySign = new THREE.Mesh(
new THREE.PlaneGeometry(4.2, 1.05),
new THREE.MeshStandardMaterial({
map: createSignTexture(
"BAY 07",
"CONTROLLED STORAGE / NORTH WING"
),
roughness: 0.85
})
);
baySign.position.set(0, 7.03, -0.575);
scene.add(baySign);
const sideSign = new THREE.Mesh(
new THREE.PlaneGeometry(3.25, 0.82),
new THREE.MeshStandardMaterial({
map: createSignTexture(
"VOXEL LOGISTICS",
"AUTHORIZED CARGO ONLY",
"#202d35",
"#f4e7ce",
"#ffc857"
),
roughness: 0.9
})
);
sideSign.position.set(-6.25, 4.55, -0.57);
scene.add(sideSign);
const interiorSign = new THREE.Mesh(
new THREE.PlaneGeometry(2.8, 0.7),
new THREE.MeshBasicMaterial({
map: createSignTexture(
"INBOUND",
"KEEP CLEAR",
"#132d28",
"#b9ffcf",
"#54f08b"
)
})
);
interiorSign.position.set(0, 4.7, -9.34);
scene.add(interiorSign);
// ------------------------------------------------------------
// Interior and exterior voxel props
// ------------------------------------------------------------
function addCrate(parent, x, y, z, size, material = materials.wood) {
addBox(parent, size, size, size, x, y, z, material);
// Crossed reinforcement strips.
addBox(
parent,
size * 1.025,
size * 0.12,
size * 1.025,
x,
y,
z,
materials.woodLight
);
addBox(
parent,
size * 0.12,
size * 1.025,
size * 1.025,
x,
y,
z,
materials.woodLight
);
}
function addPallet(parent, x, z, width = 1.8, depth = 1.35) {
for (let i = 0; i < 4; i++) {
addBox(
parent,
width,
0.12,
0.22,
x,
0.12,
z - depth / 2 + 0.18 + i * ((depth - 0.36) / 3),
materials.woodLight
);
}
addBox(parent, 0.22, 0.18, depth, x - width * 0.34, 0.02, z, materials.wood);
addBox(parent, 0.22, 0.18, depth, x + width * 0.34, 0.02, z, materials.wood);
}
// Interior pallets and cargo.
addPallet(scene, -1.65, -4.25);
addCrate(scene, -1.65, 0.77, -4.25, 1.05);
addCrate(scene, -1.65, 1.87, -4.25, 0.92, materials.woodLight);
addPallet(scene, 1.6, -5.55);
addCrate(scene, 1.6, 0.72, -5.55, 1.0, materials.woodLight);
addCrate(scene, 1.6, 1.72, -5.55, 0.82);
addPallet(scene, -1.5, -7.3, 2.0, 1.4);
addCrate(scene, -1.5, 0.9, -7.3, 1.25, materials.woodLight);
// Exterior loading cargo.
addPallet(scene, 5.25, 2.0, 2.1, 1.55);
addCrate(scene, 5.25, 0.87, 2.0, 1.25);
addCrate(scene, 5.25, 2.15, 2.0, 1.05, materials.woodLight);
addPallet(scene, -5.45, 1.1, 1.8, 1.35);
addCrate(scene, -5.45, 0.75, 1.1, 1.0, materials.woodLight);
// Safety bollards.
for (const x of [-4.25, 4.25]) {
addBox(scene, 0.34, 1.15, 0.34, x, 0.57, 1.15, materials.orange);
addBox(scene, 0.37, 0.18, 0.37, x, 0.82, 1.15, materials.yellow);
addBox(scene, 0.55, 0.12, 0.55, x, 0.06, 1.15, materials.black);
}
// Floor markings.
const markingMaterial = new THREE.MeshStandardMaterial({
color: 0xb58c2f,
roughness: 0.9
});
addBox(scene, 0.09, 0.018, 5.8, -3.75, 0.025, 0.7, markingMaterial, false);
addBox(scene, 0.09, 0.018, 5.8, 3.75, 0.025, 0.7, markingMaterial, false);
addBox(scene, 7.6, 0.018, 0.09, 0, 0.025, 3.55, markingMaterial, false);
// Ceiling lamps inside the corridor.
for (const z of [-2.8, -5.4, -8.0]) {
const lampMaterial = new THREE.MeshStandardMaterial({
color: 0xffe5ad,
emissive: 0xffd88a,
emissiveIntensity: 1.6,
roughness: 0.4
});
addBox(scene, 1.4, 0.12, 0.35, 0, 5.85, z, lampMaterial, false, false);
const light = new THREE.PointLight(0xffcc82, 32, 7, 2);
light.position.set(0, 5.5, z);
scene.add(light);
}
// Wall-mounted utility conduits.
addBox(scene, 0.18, 6.4, 0.18, -8.7, 3.4, -0.4, materials.yellow);
addBox(scene, 0.18, 6.4, 0.18, -8.25, 3.4, -0.4, materials.darkMetal);
// ------------------------------------------------------------
// Animation
// ------------------------------------------------------------
const clock = new THREE.Clock();
let doorOpenAmount = 0;
let lastStatus = "";
const red = new THREE.Color(0xff4038);
const green = new THREE.Color(0x54f08b);
const currentBeaconColor = new THREE.Color();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
const shouldOpen = evaluateDoorRule();
doorOpenAmount = THREE.MathUtils.damp(
doorOpenAmount,
shouldOpen ? 1 : 0,
4.8,
delta
);
// The two voxel leaves retract into the facade.
leftDoor.position.x = -2.72 * doorOpenAmount;
rightDoor.position.x = 2.72 * doorOpenAmount;
// Beacon color and pulse.
currentBeaconColor.lerpColors(red, green, doorOpenAmount);
beaconMaterial.color.copy(currentBeaconColor);
beaconMaterial.emissive.copy(currentBeaconColor);
beaconGlowMaterial.color.copy(currentBeaconColor);
beaconLight.color.copy(currentBeaconColor);
const pulse = shouldOpen
? 0.88 + Math.sin(elapsed * 5.5) * 0.12
: 0.95;
beaconGlow.scale.setScalar(pulse);
beaconGlowMaterial.opacity = 0.11 + doorOpenAmount * 0.12;
beaconLight.intensity = 2.5 + doorOpenAmount * 5.5;
// Detailed animated status.
let status;
let detail;
if (shouldOpen && doorOpenAmount < 0.985) {
status = "OPENING";
detail = access.override
? "Supervisor override bypass active"
: "Badge accepted during opening hours";
} else if (shouldOpen) {
status = "OPEN";
detail = access.override
? "Door held open by supervisor override"
: "Badge and opening-hours conditions satisfied";
} else if (!shouldOpen && doorOpenAmount > 0.015) {
status = "CLOSING";
detail = "Access conditions are no longer satisfied";
} else {
status = "LOCKED";
detail = access.badge
? "Badge valid, but opening hours are inactive"
: "Waiting for an authorized badge";
}
if (status !== lastStatus) {
statusLabel.textContent = status;
statusDetail.textContent = detail;
statusBox.classList.toggle("open", shouldOpen);
lastStatus = status;
}
renderer.render(scene, camera);
}
animate();
// ------------------------------------------------------------
// Resize handling
// ------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
</script>
</body>
</html>
```