Repository navigation
Expand file tree
/
Copy paths-main.js
More file actions
297 lines (282 loc) · 47.8 KB
/
Copy paths-main.js
File metadata and controls
297 lines (282 loc) · 47.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/* Set 2 · 1964 · Mainframes.
A cobalt machine room on a polished raised floor. Seven tape units run start-stop like the real ones (the reels jerk,
reverse, and the loops in the vacuum columns breathe), a console counts in binary on 480 lamps, a line printer feeds
green-bar paper. Everything is built twice, the second time upside down under a translucent floor, which is the
reflection. The exit is a reel hub. */
H.def('main', ({ renderer, H }) => {
const T = THREE, U = H.U, scene = new T.Scene(), BG = K.col('#1f4fd6');
scene.background = BG; scene.fog = new T.Fog(BG.getHex(), 30, 84);
const camera = new T.PerspectiveCamera(36, 1, 0.05, 220);
scene.environment = K.env(renderer, { top: '#7f8aa6', bottom: '#141c44', boxes: [{ p: [-10, 18, 10], s: [18, 10], i: 3.2 }, { p: [14, 9, 8], s: [8, 12], i: 1.1 }, { p: [0, 20, -4], s: [30, 4], i: 2.2 }] });
K.lights(scene, { pos: [-9, 19, 13], target: [1, 2, -4], key: 2.3, amb: 0.5, sky: '#eef3ff', ground: '#3f63d8', extent: 24, far: 90 });
const white = K.std('#dde2ec', 0.42, 0.05), grey = K.std('#aab2c0', 0.5, 0.1), dark = K.std('#0e1220', 0.5, 0.25), red = K.std('#de3b25', 0.42, 0.05), steel = K.std('#c2c9d6', 0.22, 0.95), tapeM = K.std('#3b2519', 0.3, 0.15), blackM = K.std('#17181c', 0.6);
const glass = new T.MeshStandardMaterial({ color: '#c6d6ff', transparent: true, opacity: 0.14, roughness: 0.03, metalness: 0.3, envMapIntensity: 2.2, depthWrite: false });
const pinkHub = K.std('#ff00b0', 0.32, 0.1, { emissive: K.col('#ff00b0'), emissiveIntensity: 0.55 });
const lit = (c, i) => new T.MeshStandardMaterial({ color: '#111', emissive: K.col(c), emissiveIntensity: i, roughness: 0.4 });
const btn = [lit('#fff3d0', 1.0), lit('#57ff9a', 0.9), lit('#ff5a3c', 1.0), K.std('#2a2f3c', 0.5)];
/* wall, mural, ceiling */
K.mesh(new T.PlaneGeometry(240, 30), K.std('#2152dc', 0.95), { p: [0, 15, -13], to: scene, cast: false });
/* the people of the room and two real machines, cut out of period photographs and stood among the modelled ones */
const flats = [
K.flat('img/c/ops-lean', { h: 5.2, p: [1.5, 0, -5.0], face: 0.5, to: scene, gain: 1.15 }),
K.flat('img/c/ops-desk', { h: 4.0, p: [5.9, 0, 1.0], face: 0.4, to: scene, gain: 1.15 }),
K.flat('img/c/ops-head', { h: 4.3, p: [9.8, 0, -3.4], face: 0.5, to: scene, gain: 1.15 }),
K.flat('img/c/ops-pair', { h: 5.9, p: [12.9, 0, -5.0], face: 0.5, to: scene, gain: 1.15 }),
K.flat('img/c/s360', { h: 6.4, p: [13.6, 0, 1.6], ry: -0.5, face: 0.5, to: scene }),
K.flat('img/c/c360', { h: 4.6, p: [10.2, 0, 4.6], ry: -0.35, face: 0.5, to: scene })
];
const flange = K.tex(512, 512, (g) => {
g.translate(256, 256); g.fillStyle = 'rgba(226,234,255,0.46)'; g.beginPath(); g.arc(0, 0, 252, 0, 7); g.fill();
g.globalCompositeOperation = 'destination-out';
for (let i = 0; i < 3; i++) { g.save(); g.rotate(i * 2.094); g.beginPath(); g.arc(0, 0, 208, -0.62, 0.62); g.arc(0, 0, 112, 0.62, -0.62, true); g.closePath(); g.fill(); g.restore(); }
g.globalCompositeOperation = 'source-over'; g.strokeStyle = 'rgba(255,255,255,0.85)'; g.lineWidth = 7; g.beginPath(); g.arc(0, 0, 248, 0, 7); g.stroke();
g.strokeStyle = 'rgba(20,30,60,0.35)'; g.lineWidth = 3; for (let i = 0; i < 3; i++) { g.save(); g.rotate(i * 2.094); g.beginPath(); g.arc(0, 0, 208, -0.62, 0.62); g.arc(0, 0, 112, 0.62, -0.62, true); g.closePath(); g.stroke(); g.restore(); }
});
const flangeM = new T.MeshStandardMaterial({ map: flange, transparent: true, roughness: 0.12, metalness: 0.1, side: T.DoubleSide, depthWrite: false, envMapIntensity: 1.6 });
const label = (txt, bg, fg, w = 512, h = 64) => K.tex(w, h, (g) => { g.fillStyle = bg; g.fillRect(0, 0, w, h); g.fillStyle = fg; g.font = '700 ' + h * 0.46 + 'px ' + K.MONO; g.textBaseline = 'middle'; g.fillText(txt, h * 0.4, h * 0.54); });
const circ = new T.CircleGeometry(0.5, 56), packG = new T.CylinderGeometry(1, 1, 0.1, 56).rotateX(Math.PI / 2), hubG = new T.CylinderGeometry(0.17, 0.17, 0.13, 32).rotateX(Math.PI / 2), capG = new T.CylinderGeometry(0.06, 0.06, 0.16, 6).rotateX(Math.PI / 2);
const bodyG = K.rbox(2.5, 5.5, 2.4, 0.07), plinG = new T.BoxGeometry(2.42, 0.3, 2.3), panG = K.plate(2.16, 2.5, 0.06, 0.04), colG = K.plate(0.44, 1.75, 0.04, 0.03), bG = K.rbox(0.2, 0.13, 0.06, 0.02, 2), rollG = new T.CylinderGeometry(0.07, 0.07, 0.16, 20).rotateX(Math.PI / 2);
const louvre = K.std('#ffffff', 0.5, 0.1, { map: K.tex(256, 64, (g) => { g.fillStyle = '#c9cfda'; g.fillRect(0, 0, 256, 64); for (let y = 5; y < 64; y += 9) { g.fillStyle = '#444b59'; g.fillRect(6, y, 244, 4); g.fillStyle = 'rgba(255,255,255,0.7)'; g.fillRect(6, y + 4, 244, 1.2); } }) });
const plateM = K.std('#ffffff', 0.3, 0.7, { map: K.tex(256, 64, (g) => { const gr = g.createLinearGradient(0, 0, 0, 64); gr.addColorStop(0, '#e9ebee'); gr.addColorStop(1, '#a9adb3'); g.fillStyle = gr; g.fillRect(0, 0, 256, 64); g.fillStyle = '#15171c'; g.font = '700 26px ' + K.MONO; g.textBaseline = 'middle'; g.fillText('TYPE 2401', 14, 22); g.font = '500 16px ' + K.MONO; g.fillText('SER. 20417 · 60 KC', 14, 48); }) });
const frameM = K.std('#2b303b', 0.4, 0.5), hingeG = new T.CylinderGeometry(0.04, 0.04, 0.24, 10), capstanG = new T.CylinderGeometry(0.06, 0.06, 0.2, 16).rotateX(Math.PI / 2), postG = new T.CylinderGeometry(0.028, 0.028, 0.18, 10).rotateX(Math.PI / 2);
const stripM = K.std('#ffffff', 0.5, 0.2, { map: K.tex(1024, 140, (g) => { g.fillStyle = '#c3c9d4'; g.fillRect(0, 0, 1024, 140); g.fillStyle = '#20242c'; g.font = '700 22px ' + K.MONO; g.textAlign = 'center'; ['LOAD', 'START', 'RESET', 'UNLOAD', 'READY'].forEach((s, i) => g.fillText(s, 280 + i * 116, 128)); g.textAlign = 'left'; g.fillText('DENSITY 800 BPI', 24, 40); g.fillText('FILE PROTECT', 830, 40); g.strokeStyle = '#6b7280'; g.strokeRect(6, 6, 1012, 128); }) });
const scaleM = K.std('#ffffff', 0.6, 0, { map: K.tex(32, 512, (g) => { g.fillStyle = '#d7dbe3'; g.fillRect(0, 0, 32, 512); g.fillStyle = '#20242c'; for (let y = 8; y < 512; y += 16) g.fillRect(0, y, (y / 16) % 5 === 0 ? 22 : 12, 2); }) });
const reels = [], loops = [], lampSets = [], papers = [];
const reelLab = ['PAYROLL 11-64', 'INVENTORY M3', 'BILLING A/R', 'LEDGER 1964'].map((tx, i) => K.std('#ffffff', 0.8, 0, { map: K.tex(256, 96, (g) => { g.fillStyle = '#f6f3ea'; g.fillRect(0, 0, 256, 96); g.fillStyle = ['#c23b2a', '#2f5fd0', '#2d8f5f', '#c23b2a'][i]; g.fillRect(0, 0, 256, 20); g.fillStyle = '#1d2330'; g.font = '700 24px ' + K.MONO; g.textBaseline = 'middle'; g.fillText(tx, 10, 46); g.font = '500 15px ' + K.MONO; g.fillText('REEL ' + (i + 1) + ' OF 3 · 800 BPI', 10, 76); }) }));
const streakM = new T.MeshBasicMaterial({ transparent: true, depthWrite: false, toneMapped: false, map: K.tex(256, 256, (g) => { g.clearRect(0, 0, 256, 256); [[70, 26, 0.075], [118, 9, 0.05], [196, 40, 0.04]].forEach(([x, w, a]) => { const gr = g.createLinearGradient(x - w, 0, x + w, 0); gr.addColorStop(0, 'rgba(255,255,255,0)'); gr.addColorStop(0.5, 'rgba(255,255,255,' + a + ')'); gr.addColorStop(1, 'rgba(255,255,255,0)'); g.fillStyle = gr; g.save(); g.transform(1, 0, -0.45, 1, 60, 0); g.fillRect(x - w, 0, w * 2, 256); g.restore(); }); }) });
const DX = [0, 2.75, 5.5, 8.25, 11, 13.75, 16.5], DZ = 0, EXIT = 2, ROW = [0, 0, -7.2], YAW = 0;
function drive(root, i) {
const g = new T.Group(); g.position.set(DX[i], 0, DZ); root.add(g);
K.mesh(plinG, blackM, { p: [0, 0.15, 0], to: g }); K.mesh(bodyG, white, { p: [0, 3.05, 0], to: g });
K.mesh(panG, dark, { p: [0, 4.35, 1.2], to: g, cast: false });
K.mesh(new T.PlaneGeometry(2.5, 0.3), K.std('#ffffff', 0.5, 0, { map: label('TAPE UNIT 0' + (i + 1), '#de3b25', '#fff4e8') }), { p: [0, 5.62, 1.206], to: g, cast: false });
const rs = [];
[-0.57, 0.57].forEach((x, s) => {
const r = new T.Group(); r.position.set(x, 4.62, 1.34); g.add(r);
const pack = K.mesh(packG, tapeM, { to: r, cast: false }); K.mesh(circ, flangeM, { p: [0, 0, 0.062], to: r, cast: false }); K.mesh(circ, flangeM, { p: [0, 0, -0.062], to: r, cast: false });
K.mesh(hubG, pinkHub, { to: r, cast: false }); for (let j = 0; j < 3; j++) K.mesh(capG, steel, { p: [Math.cos(j * 2.094) * 0.1, Math.sin(j * 2.094) * 0.1, 0.01], to: r, cast: false });
const strand = K.mesh(new T.BoxGeometry(0.012, 1, 0.085), tapeM, { to: g, cast: false });
rs.push({ r, pack, strand, x, s });
});
reels.push({ i, rs, ph: i * 1.7 + 0.4 });
K.mesh(K.rbox(0.62, 0.3, 0.14, 0.04), steel, { p: [0, 3.62, 1.3], to: g, cast: false }); [-0.42, 0.42].forEach((x) => K.mesh(rollG, steel, { p: [x, 3.72, 1.32], to: g, cast: false }));
K.mesh(new T.BoxGeometry(0.84, 0.012, 0.085), tapeM, { p: [0, 3.79, 1.33], to: g, cast: false });
K.mesh(new T.PlaneGeometry(2.16, 2.5), glass, { p: [0, 4.35, 1.46], to: g, cast: false, receive: false });
[[-1.1, 3.1], [1.1, 3.1], [-1.1, 5.6], [1.1, 5.6]].forEach(([x, y]) => K.mesh(new T.BoxGeometry(0.05, 0.05, 0.28), steel, { p: [x * 0.98, y, 1.33], to: g, cast: false }));
[-0.52, 0.52].forEach((x, s) => { K.mesh(colG, dark, { p: [x, 1.85, 1.2], to: g, cast: false }); const lp = K.mesh(new T.BoxGeometry(0.2, 1, 0.012), tapeM, { p: [x, 2.3, 1.235], to: g, cast: false }); loops.push({ lp, i, s }); K.mesh(new T.PlaneGeometry(0.44, 1.75), glass, { p: [x, 1.85, 1.25], to: g, cast: false, receive: false }); });
for (let b = 0; b < 5; b++) K.mesh(bG, btn[(b * 7 + i * 3) % 4], { p: [-0.5 + b * 0.25, 2.94, 1.22], to: g, cast: false });
K.mesh(new T.BoxGeometry(2.3, 0.012, 0.02), blackM, { p: [0, 2.8, 1.2], to: g, cast: false });
/* small things: louvres at the foot, a door pull, the maker's plate, three status lamps on the header */
K.mesh(new T.PlaneGeometry(2.1, 0.46), louvre, { p: [0, 0.66, 1.206], to: g, cast: false }); K.mesh(K.rbox(0.07, 0.6, 0.09, 0.02, 2), steel, { p: [1.0, 4.35, 1.5], to: g, cast: false });
K.mesh(new T.PlaneGeometry(0.62, 0.15), plateM, { p: [-0.78, 2.62, 1.206], to: g, cast: false }); for (let b = 0; b < 3; b++) K.mesh(new T.CircleGeometry(0.045, 14), btn[b], { p: [0.72 + b * 0.16, 5.62, 1.21], to: g, cast: false });
if (root.parent === room) { /* fine detail, on the real room only (the reflection does without) */
[-1.13, 1.13].forEach((x) => K.mesh(new T.BoxGeometry(0.07, 2.56, 0.2), frameM, { p: [x, 4.35, 1.28], to: g, cast: false })); K.mesh(new T.BoxGeometry(2.33, 0.07, 0.2), frameM, { p: [0, 3.07, 1.28], to: g, cast: false });
[3.5, 4.35, 5.2].forEach((y) => K.mesh(hingeG, steel, { p: [-1.19, y, 1.42], to: g, cast: false }));
K.mesh(K.rbox(0.36, 0.2, 0.1, 0.03, 2), dark, { p: [0, 3.86, 1.37], to: g, cast: false }); K.mesh(new T.BoxGeometry(0.2, 0.05, 0.03), steel, { p: [0, 3.74, 1.4], to: g, cast: false });
[-0.2, 0.2].forEach((x) => K.mesh(capstanG, steel, { p: [x, 3.56, 1.34], to: g, cast: false })); [[-0.66, 3.96], [0.66, 3.96], [-0.3, 4.0], [0.3, 4.0]].forEach(([x, y]) => K.mesh(postG, steel, { p: [x, y, 1.33], to: g, cast: false }));
K.mesh(new T.PlaneGeometry(2.2, 0.3), stripM, { p: [0, 2.94, 1.2065], to: g, cast: false }); K.mesh(new T.BoxGeometry(2.44, 0.05, 0.02), steel, { p: [0, 0.33, 1.165], to: g, cast: false });
[-1.256, 1.256].forEach((x) => [0.5, -0.5].forEach((z) => K.mesh(new T.BoxGeometry(0.012, 5.2, 0.02), blackM, { p: [x, 3.05, z], to: g, cast: false })));
K.mesh(new T.PlaneGeometry(1.9, 1.5), louvre, { p: [0, 5.806, -0.1], r: [-Math.PI / 2, 0, 0], to: g, cast: false });
[-0.52, 0.52].forEach((x) => { K.mesh(new T.PlaneGeometry(0.07, 1.7), scaleM, { p: [x + 0.19, 1.85, 1.252], to: g, cast: false }); K.mesh(new T.CylinderGeometry(0.05, 0.05, 0.06, 12).rotateX(Math.PI / 2), steel, { p: [x, 1.08, 1.23], to: g, cast: false }); });
rs.forEach((q) => { K.mesh(new T.CylinderGeometry(0.055, 0.055, 0.2, 14).rotateX(Math.PI / 2), steel, { p: [0, 0, 0.05], to: q.r, cast: false }); K.mesh(new T.TorusGeometry(0.185, 0.012, 8, 28), steel, { p: [0, 0, 0.068], to: q.r, cast: false });
/* a typed label on each reel, so the turning shows */
K.mesh(new T.PlaneGeometry(0.3, 0.112), reelLab[(i * 2 + q.s) % 4], { p: [0, 0.33, 0.066], to: q.r, cast: false }); });
if (i > EXIT) K.mesh(new T.PlaneGeometry(2.16, 2.5), streakM, { p: [0, 4.35, 1.468], to: g, cast: false, receive: false }); /* not on the doors that pass behind the headline, nor on the exit's */ K.mesh(new T.CylinderGeometry(0.035, 0.035, 0.05, 12).rotateX(Math.PI / 2), steel, { p: [1.0, 3.42, 1.49], to: g, cast: false });
}
return g;
}
/* small properties of the room, shared by the pieces below */
const anim = [], screwG = new T.CylinderGeometry(0.034, 0.034, 0.02, 12), china = K.std('#f1efe8', 0.25, 0.02), vinyl = K.std('#2c3640', 0.5, 0.05), pencilM = K.std('#e2b23a', 0.5);
const edges = (vert) => K.std('#ffffff', 0.85, 0, { map: K.tex(256, 256, (g) => { g.fillStyle = '#e6dab6'; g.fillRect(0, 0, 256, 256); for (let i = 0; i < 256; i += 2) { g.fillStyle = 'rgba(90,70,30,' + (0.1 + ((i * 7) % 5) * 0.035) + ')'; vert ? g.fillRect(i, 0, 0.8, 256) : g.fillRect(0, i, 256, 0.8); } [38, 122, 190].forEach((q, i) => { g.fillStyle = ['#c9402c', '#2f5fd0', '#c9402c'][i]; vert ? g.fillRect(q, 0, 1.6, 256) : g.fillRect(0, q, 256, 1.6); }); }) });
const manila = edges(false), manilaV = edges(true);
const cardFace = K.std('#ffffff', 0.85, 0, { map: K.tex(512, 224, (g) => { g.fillStyle = '#e9dfbf'; g.fillRect(0, 0, 512, 224); g.fillStyle = '#7b3a2c'; g.font = '700 12px ' + K.MONO; g.fillText('PAYROLL REGISTER · WEEK 46', 34, 15); const R = K.rng(21); for (let r = 0; r < 10; r++) for (let c = 0; c < 60; c++) { const x = 12 + c * 8.2, y = 30 + r * 19; if (R() < 0.14) { g.fillStyle = '#20170f'; g.fillRect(x - 0.5, y - 6, 5, 13); } else { g.fillStyle = 'rgba(123,58,44,0.55)'; g.font = '500 8px ' + K.MONO; g.fillText(String(r), x, y + 3); } } }) });
const logT = K.tex(512, 720, (g) => { g.fillStyle = '#f4f1e6'; g.fillRect(0, 0, 512, 720); g.fillStyle = '#1d2330'; g.font = '700 27px ' + K.MONO; g.fillText('RUN LOG', 28, 46); g.font = '500 15px ' + K.MONO; g.fillText('MACHINE ROOM 2 · SHIFT 2 · 12 NOV 1964', 28, 72);
g.strokeStyle = 'rgba(40,60,120,0.5)'; g.lineWidth = 1; for (let y = 96; y < 700; y += 30) { g.beginPath(); g.moveTo(20, y); g.lineTo(492, y); g.stroke(); } [150, 300, 392].forEach((x) => { g.beginPath(); g.moveTo(x, 96); g.lineTo(x, 696); g.stroke(); });
g.font = '700 13px ' + K.MONO; ['JOB', 'TAPES', 'START', 'END / NOTE'].forEach((t, i) => g.fillText(t, [28, 158, 308, 400][i], 117));
g.font = 'italic 500 21px ' + K.SERIF; g.fillStyle = '#1b3fa8'; [['Payroll 46', '3, 5', '21:04', '21:52 ok'], ['Inventory', '1, 2, 6', '21:55', '22:40 ok'], ['Billing A/R', '4', '22:41', 'reel torn'], ['Billing A/R', '4, 7', '23:10', '23:58 ok'], ['Ledger close', '1, 3', '00:02', ''], ['', '', '', ''], ['Sort / merge', '2, 5, 6', '', '']].forEach((row, r) => row.forEach((t, i) => g.fillText(t, [28, 158, 308, 400][i], 148 + r * 30)));
g.strokeStyle = '#c23b2a'; g.lineWidth = 2; g.beginPath(); g.ellipse(444, 202, 52, 15, -0.05, 0, 7); g.stroke(); });
const plateC = K.std('#ffffff', 0.3, 0.7, { map: K.tex(512, 108, (g) => { const gr = g.createLinearGradient(0, 0, 0, 108); gr.addColorStop(0, '#e9ebee'); gr.addColorStop(1, '#a9adb3'); g.fillStyle = gr; g.fillRect(0, 0, 512, 108); g.fillStyle = '#15171c'; g.font = '700 30px ' + K.MONO; g.textBaseline = 'middle'; g.fillText('OPERATOR\'S CONSOLE · 1', 22, 36); g.font = '500 19px ' + K.MONO; g.fillText('208 V · 3 PH · 60 CY · 12 KVA', 22, 78); g.fillStyle = '#6b7280'; [[10, 10], [502, 10], [10, 98], [502, 98]].forEach(([x, y]) => { g.beginPath(); g.arc(x, y, 4, 0, 7); g.fill(); }); }) });
const meterT = (name, top) => K.tex(256, 256, (g) => { g.fillStyle = '#efe9d6'; g.fillRect(0, 0, 256, 256); g.translate(128, 176); g.strokeStyle = '#1b1d22'; g.fillStyle = '#1b1d22'; g.lineWidth = 3; g.beginPath(); g.arc(0, 0, 112, Math.PI * 1.2, Math.PI * 1.8); g.stroke();
for (let i = 0; i <= 20; i++) { const a = Math.PI * (1.2 + 0.6 * i / 20), r0 = i % 5 ? 104 : 94; g.lineWidth = i % 5 ? 1.6 : 3; g.beginPath(); g.moveTo(Math.cos(a) * r0, Math.sin(a) * r0); g.lineTo(Math.cos(a) * 112, Math.sin(a) * 112); g.stroke(); if (i % 5 === 0) { g.font = '700 17px ' + K.MONO; g.textAlign = 'center'; g.fillText(String(Math.round(top * i / 20)), Math.cos(a) * 76, Math.sin(a) * 76 + 6); } }
g.fillStyle = '#c23b2a'; g.beginPath(); g.arc(0, 0, 112, Math.PI * 1.71, Math.PI * 1.8); g.arc(0, 0, 104, Math.PI * 1.8, Math.PI * 1.71, true); g.fill(); g.fillStyle = '#1b1d22'; g.font = '700 15px ' + K.MONO; g.textAlign = 'center'; g.fillText(name, 0, -20); g.font = '500 11px ' + K.MONO; g.fillText('A.C.', 0, -2); });
/* console: a slanted black panel of lamps over a desk, red end panels */
const LR = 12, LC = 40, lampG = new T.CylinderGeometry(0.034, 0.034, 0.03, 24).rotateX(Math.PI / 2);
/* each lamp is a little domed lens: brighter off-centre, darker at the rim */
const lensT = K.tex(64, 64, (g) => { const gr = g.createRadialGradient(27, 25, 2, 32, 32, 32); gr.addColorStop(0, '#ffffff'); gr.addColorStop(0.5, '#e6e6e6'); gr.addColorStop(0.85, '#9c9c9c'); gr.addColorStop(1, '#4a4a4a'); g.fillStyle = gr; g.fillRect(0, 0, 64, 64); });
const panelTex = K.tex(3072, 1280, (g) => { g.scale(2, 2); const w = 1536, h = 640;
g.fillStyle = '#0d0f16'; g.fillRect(0, 0, w, h); const R = K.rng(4); for (let i = 0; i < 1400; i++) { g.fillStyle = 'rgba(255,255,255,' + R() * 0.018 + ')'; g.fillRect(R() * w, R() * h, 1 + R() * 26, 0.6); }
g.strokeStyle = 'rgba(214,222,240,0.55)'; g.fillStyle = 'rgba(224,230,244,0.85)'; g.lineWidth = 2; g.font = '600 15px ' + K.MONO; g.textBaseline = 'middle'; g.textAlign = 'left';
const names = ['INSTRUCTION COUNTER', 'STORAGE ADDRESS', 'STORAGE DATA', 'ACCUMULATOR', 'MULTIPLIER QUOTIENT', 'INDEX A', 'INDEX B', 'INDEX C', 'SENSE', 'CHANNEL A', 'CHANNEL B', 'CHECK'];
for (let r = 0; r < LR; r++) { const y = 40 + r * 47; g.fillStyle = 'rgba(224,230,244,0.85)'; g.fillText(names[r], 22, y); g.beginPath(); g.moveTo(250, y + 21); g.lineTo(w - 22, y + 21); g.stroke(); for (let c = 0; c < LC; c += 4) { g.fillRect(268 + c * 31, y - 20, 1.5, 10); }
/* a turned bezel round every lamp: dark ring, a catch of light on its upper left */
for (let c = 0; c < LC; c++) { const x = 268 + c * 31 + 6; g.strokeStyle = '#2f3440'; g.lineWidth = 2.6; g.beginPath(); g.arc(x, y, 10.6, 0, 7); g.stroke(); g.strokeStyle = 'rgba(255,255,255,0.34)'; g.lineWidth = 1; g.beginPath(); g.arc(x, y, 11.4, 3.3, 4.9); g.stroke(); g.strokeStyle = 'rgba(214,222,240,0.55)'; g.lineWidth = 2; } }
/* bit positions and the maker's line run along the bottom edge. Nothing is lettered along the top: the camera skims it on the way out, and small type there would fill the frame for an instant */
g.font = '600 8.5px ' + K.MONO; g.textAlign = 'center'; g.fillStyle = 'rgba(224,230,244,0.7)'; for (let c = 0; c < LC; c++) g.fillText(String(c), 268 + c * 31 + 6, h - 30);
g.font = '600 9px ' + K.MONO; g.textAlign = 'left'; g.fillStyle = 'rgba(224,230,244,0.55)'; g.fillText('DATA PROCESSING SYSTEM · OPERATOR\'S PANEL', 22, h - 30); g.textAlign = 'right'; g.fillText('SER. 20417', w - 40, h - 14); g.textAlign = 'left';
g.strokeStyle = 'rgba(214,222,240,0.55)'; g.strokeRect(10, 10, w - 20, h - 20);
[[24, 22], [w - 24, 22], [24, h - 22], [w - 24, h - 22]].forEach(([x, y], i) => { g.fillStyle = '#9aa1ad'; g.beginPath(); g.arc(x, y, 5.5, 0, 7); g.fill(); g.strokeStyle = '#23262d'; g.lineWidth = 1.4; g.beginPath(); g.moveTo(x - 4 * Math.cos(i), y - 4 * Math.sin(i)); g.lineTo(x + 4 * Math.cos(i), y + 4 * Math.sin(i)); g.stroke(); });
});
const keysM = K.std('#ffffff', 0.6, 0, { map: K.tex(1024, 448, (g) => { g.scale(2, 2); g.fillStyle = '#2c3a52'; g.fillRect(0, 0, 512, 224); for (let r = 0; r < 4; r++) for (let c = 0; c < 12; c++) { const kx = 34 + c * 40 + r * 9, ky = 34 + r * 46; g.fillStyle = 'rgba(0,0,0,0.4)'; g.beginPath(); g.arc(kx + 2, ky + 4, 16, 0, 7); g.fill(); g.fillStyle = '#b9b5a8'; g.beginPath(); g.arc(kx, ky + 1.5, 16, 0, 7); g.fill(); g.fillStyle = '#e9e6dc'; g.beginPath(); g.arc(kx, ky, 15, 0, 7); g.fill(); g.strokeStyle = 'rgba(255,255,255,0.8)'; g.lineWidth = 1.2; g.beginPath(); g.arc(kx, ky, 12.5, 3.4, 5.2); g.stroke(); g.fillStyle = '#2c3a52'; g.font = '700 15px ' + K.MONO; g.textAlign = 'center'; g.fillText('1234567890-=QWERTYUIOP½¾ASDFGHJKL;\'↵ZXCVBNM,./↑↓'[r * 12 + c] || '', 34 + c * 40 + r * 9, 39 + r * 46); } }) });
function consoleUnit(root) {
const g = new T.Group(); g.position.set(5.0, 0, -2.0); g.rotation.y = 0.3; root.add(g);
K.mesh(K.rbox(6.4, 2.5, 2.7, 0.07), white, { p: [0, 1.25, 0], to: g }); [-3.22, 3.22].forEach((x) => K.mesh(K.rbox(0.08, 4.6, 2.8, 0.03), red, { p: [x, 2.3, 0], to: g }));
K.mesh(K.rbox(6.4, 0.12, 1.5, 0.04), grey, { p: [0, 2.56, 0.9], to: g });
const pn = new T.Group(); pn.position.set(0, 3.72, -0.42); pn.rotation.x = -0.3; g.add(pn);
K.mesh(K.rbox(6.36, 2.5, 0.3, 0.05), blackM, { to: pn }); K.mesh(new T.PlaneGeometry(6.2, 2.34), K.std('#ffffff', 0.55, 0, { map: panelTex }), { p: [0, 0, 0.155], to: pn, cast: false });
const lm = new T.InstancedMesh(lampG, new T.MeshBasicMaterial({ toneMapped: false, map: lensT }), LR * LC), o = new T.Object3D();
for (let r = 0; r < LR; r++) for (let c = 0; c < LC; c++) { o.position.set(-3.1 + (268 + c * 31 + 6) / 1536 * 6.2, 1.17 - (40 + r * 47) / 640 * 2.34, 0.168); o.updateMatrix(); lm.setMatrixAt(r * LC + c, o.matrix); lm.setColorAt(r * LC + c, new T.Color(0, 0, 0)); }
lm.frustumCulled = false; pn.add(lm); lampSets.push(lm);
/* desk: toggles, dials, the emergency pull */
const tg = new T.InstancedMesh(new T.BoxGeometry(0.035, 0.14, 0.035), steel, 44); for (let c = 0; c < 44; c++) { o.position.set(-2.9 + c * 0.118, 2.7, 1.0 + ((c * 13) % 3 === 0 ? 0.03 : -0.02)); o.rotation.set((c * 13) % 3 === 0 ? 0.5 : -0.5, 0, 0); o.updateMatrix(); tg.setMatrixAt(c, o.matrix); } g.add(tg);
[2.55, 2.9].forEach((x, j) => { K.mesh(new T.CylinderGeometry(0.13, 0.15, 0.1, 24), blackM, { p: [x, 2.68, 1.05], to: g }); K.mesh(new T.BoxGeometry(0.02, 0.03, 0.12), white, { p: [x, 2.74, 1.05], r: [0, j * 1.1 + 0.4, 0], to: g, cast: false }); });
K.mesh(new T.CylinderGeometry(0.13, 0.1, 0.16, 24), K.std('#e3261a', 0.35), { p: [-3.0, 2.72, 0.5], to: g });
if (root === room) { /* the operator's typewriter, six rotary switches with their legends, an hour meter */
K.mesh(K.rbox(1.9, 0.5, 1.3, 0.08), K.std('#3a4a63', 0.5, 0.2), { p: [-1.2, 2.88, 1.05], to: g }); K.mesh(new T.PlaneGeometry(1.6, 0.7), keysM, { p: [-1.2, 3.135, 1.28], r: [-1.2, 0, 0], to: g, cast: false });
K.mesh(new T.CylinderGeometry(0.16, 0.16, 1.7, 20).rotateZ(Math.PI / 2), K.std('#17181c', 0.6), { p: [-1.2, 3.2, 0.62], to: g }); K.mesh(new T.PlaneGeometry(1.5, 1.1), K.std('#ffffff', 0.9, 0, { map: barTex, side: T.DoubleSide }), { p: [-1.2, 3.72, 0.5], r: [-0.25, 0, 0], to: g });
for (let q = 0; q < 6; q++) { K.mesh(new T.CylinderGeometry(0.11, 0.13, 0.09, 20), blackM, { p: [0.55 + q * 0.34, 2.68, 1.4], to: g }); K.mesh(new T.BoxGeometry(0.02, 0.03, 0.11), white, { p: [0.55 + q * 0.34, 2.735, 1.4], r: [0, q * 0.9, 0], to: g, cast: false }); }
K.mesh(new T.PlaneGeometry(2.3, 0.3), K.std('#ffffff', 0.5, 0, { map: K.tex(768, 100, (g) => { g.fillStyle = '#aab2c0'; g.fillRect(0, 0, 768, 100); g.fillStyle = '#15171c'; g.font = '700 19px ' + K.MONO; g.textAlign = 'center'; ['ADDR', 'DATA', 'RATE', 'MODE', 'CHK', 'IPL'].forEach((s, i) => g.fillText(s, 76 + i * 113, 86)); }) }), { p: [1.4, 2.622, 1.18], r: [-Math.PI / 2, 0, 0], to: g, cast: false });
K.mesh(K.rbox(0.5, 0.22, 0.06, 0.02, 2), blackM, { p: [2.75, 3.0, -0.07], r: [-0.3, 0, 0], to: g, cast: false });
/* trim on the red end panels: bright edge strips, black kick plates, slotted screws */
[-3.22, 3.22].forEach((x) => { const sg = Math.sign(x); K.mesh(new T.BoxGeometry(0.1, 4.6, 0.035), steel, { p: [x, 2.3, 1.41], to: g, cast: false }); K.mesh(new T.BoxGeometry(0.1, 0.035, 2.8), steel, { p: [x, 4.61, 0], to: g, cast: false }); K.mesh(new T.BoxGeometry(0.095, 0.34, 2.82), blackM, { p: [x, 0.17, 0], to: g, cast: false });
[[4.3, 1.2], [4.3, -1.2], [0.62, 1.2], [0.62, -1.2]].forEach(([y, z]) => K.mesh(screwG, steel, { p: [x + sg * 0.046, y, z], r: [0, 0, Math.PI / 2], to: g, cast: false })); });
K.mesh(new T.PlaneGeometry(0.95, 0.2), plateC, { p: [-3.268, 4.2, -0.6], r: [0, -Math.PI / 2, 0], to: g, cast: false });
/* the run log, on a clipboard hooked to the near panel, pencil on a string */
{ const cb = new T.Group(); cb.position.set(-3.275, 2.86, 0.3); cb.rotation.set(0, -Math.PI / 2, 0.03); g.add(cb);
K.mesh(K.rbox(0.84, 1.16, 0.03, 0.03, 2), K.std('#7b5a3a', 0.8), { p: [0, 0, 0.015], to: cb, cast: false }); K.mesh(new T.PlaneGeometry(0.74, 1.04), K.std('#e3dfd2', 0.9), { p: [0.012, -0.03, 0.034], r: [0, 0, -0.025], to: cb, cast: false }); K.mesh(new T.PlaneGeometry(0.74, 1.04), K.std('#ffffff', 0.9, 0, { map: logT }), { p: [0, -0.02, 0.038], to: cb, cast: false });
K.mesh(K.rbox(0.4, 0.15, 0.05, 0.02, 2), steel, { p: [0, 0.52, 0.055], to: cb, cast: false }); K.mesh(new T.CylinderGeometry(0.03, 0.03, 0.34, 10).rotateZ(Math.PI / 2), steel, { p: [0, 0.6, 0.06], to: cb, cast: false }); K.mesh(new T.CylinderGeometry(0.02, 0.02, 0.07, 8).rotateX(Math.PI / 2), steel, { p: [0, 0.68, 0.03], to: cb, cast: false });
K.mesh(new T.CylinderGeometry(0.004, 0.004, 0.62, 4), blackM, { p: [0.37, 0.3, 0.03], to: cb, cast: false }); K.mesh(new T.CylinderGeometry(0.017, 0.017, 0.5, 6), pencilM, { p: [0.375, -0.25, 0.035], r: [0, 0, 0.05], to: cb, cast: false }); }
/* on the desk: coffee, a banded deck waiting its turn, two meters */
{ const cup = new T.Group(); cup.position.set(-2.56, 2.62, 0.52); g.add(cup); K.mesh(new T.CylinderGeometry(0.2, 0.15, 0.028, 28), china, { p: [0, 0.014, 0], to: cup });
K.mesh(new T.LatheGeometry([[0.0, 0.02], [0.08, 0.02], [0.112, 0.2], [0.122, 0.215], [0.108, 0.215], [0.076, 0.045], [0, 0.045]].map(([x, y]) => new T.Vector2(x, y)), 28), china, { to: cup }); K.mesh(new T.CircleGeometry(0.1, 24), K.std('#2a1608', 0.12, 0.1), { p: [0, 0.18, 0], r: [-Math.PI / 2, 0, 0], to: cup, cast: false }); K.mesh(new T.TorusGeometry(0.055, 0.014, 8, 16, Math.PI * 1.15), china, { p: [0.125, 0.115, 0], r: [0, 0, -Math.PI * 0.575], to: cup, cast: false });
const dk = new T.Group(); dk.position.set(-2.7, 2.62, 1.43); dk.rotation.y = 0.12; g.add(dk); K.mesh(new T.BoxGeometry(0.62, 0.2, 0.27), [manila, manila, cardFace, manila, manila, manila], { p: [0, 0.1, 0], to: dk }); K.mesh(new T.BoxGeometry(0.03, 0.206, 0.276), K.std('#b5452f', 0.7), { p: [0.12, 0.1, 0], to: dk, cast: false });
const mb = new T.Group(); mb.position.set(2.74, 2.62, 0.5); mb.rotation.y = -0.1; g.add(mb); K.mesh(K.rbox(0.92, 0.42, 0.34, 0.04, 2), frameM, { p: [0, 0.21, 0], to: mb }); const mf = new T.Group(); mf.position.set(0, 0.215, 0.172); mb.add(mf); const nd = [];
[['LINE VOLTS', 250], ['AMPERES', 50]].forEach(([nm, top], j) => { const x = j ? 0.22 : -0.22; K.mesh(new T.CircleGeometry(0.165, 36), K.std('#ffffff', 0.6, 0, { map: meterT(nm, top) }), { p: [x, 0, 0.004], to: mf, cast: false }); K.mesh(new T.TorusGeometry(0.168, 0.02, 10, 36), blackM, { p: [x, 0, 0.006], to: mf, cast: false });
const pv2 = new T.Group(); pv2.position.set(x, -0.062, 0.012); mf.add(pv2); K.mesh(new T.BoxGeometry(0.008, 0.19, 0.003), blackM, { p: [0, 0.095, 0], to: pv2, cast: false }); K.mesh(new T.CylinderGeometry(0.02, 0.02, 0.01, 12).rotateX(Math.PI / 2), blackM, { to: pv2, cast: false }); nd.push(pv2); });
anim.push((t) => { nd[0].rotation.z = 0.94 - 1.88 * (0.832 + 0.006 * Math.sin(t * 1.3) + 0.003 * Math.sin(t * 7.1)); nd[1].rotation.z = 0.94 - 1.88 * (0.46 + 0.1 * Math.sin(t * 0.83) + 0.04 * Math.sin(t * 2.1)); }); }
}
return g;
}
/* line printer: green-bar fanfold climbing out and folding over the back */
const barTex = K.tex(512, 512, (g, w, h) => { const R = K.rng(5);
for (let b = 0; b < 8; b++) { g.fillStyle = b % 2 ? '#f6f6ee' : '#cfe9cf'; g.fillRect(0, b * 64, w, 64); }
g.fillStyle = 'rgba(30,34,40,0.78)'; g.font = '600 13px ' + K.MONO;
for (let l = 0; l < 32; l++) { let s = ''; for (let c = 0; c < 52; c++) s += R() < 0.2 ? ' ' : '0123456789ABCDEF.-'[(R() * 18) | 0]; if (R() < 0.82) g.fillText(s, 40, 12 + l * 16); }
g.fillStyle = '#1f4fd6'; for (let y = 8; y < h; y += 16) { g.beginPath(); g.arc(14, y, 4.2, 0, 7); g.arc(w - 14, y, 4.2, 0, 7); g.fill(); }
}, { repeat: [1, 2.2] });
function printer(root) {
const g = new T.Group(); g.position.set(20.2, 0, -6.2); g.rotation.y = -0.35; root.add(g);
K.mesh(K.rbox(4.3, 3.3, 2.7, 0.08), white, { p: [0, 1.75, 0], to: g }); K.mesh(new T.BoxGeometry(4.2, 0.2, 2.6), blackM, { p: [0, 0.1, 0], to: g });
K.mesh(K.rbox(3.4, 0.5, 1.5, 0.06), dark, { p: [0, 3.45, 0.1], to: g }); K.mesh(new T.PlaneGeometry(1.4, 0.26), K.std('#fff', 0.5, 0, { map: label('PRINTER 1', '#de3b25', '#fff4e8', 384, 64) }), { p: [-1.2, 2.9, 1.356], to: g, cast: false });
for (let b = 0; b < 4; b++) K.mesh(bG, btn[b], { p: [0.9 + b * 0.27, 2.9, 1.37], to: g, cast: false });
const pts = [], pw = 2.5; for (let i = 0; i <= 10; i++) pts.push([3.5 + i * 0.16, 0.25]); for (let i = 1; i <= 14; i++) { const a = (i / 14) * Math.PI; pts.push([5.1 + Math.sin(a) * 0.95, 0.25 - (1 - Math.cos(a)) * 0.95]); } for (let i = 1; i <= 10; i++) pts.push([5.1 - i * 0.47, -1.65 - i * 0.02]);
const pos = [], uv = [], idx = []; let len = 0; pts.forEach(([y, z], i) => { if (i) len += Math.hypot(y - pts[i - 1][0], z - pts[i - 1][1]); pos.push(-pw / 2, y, z, pw / 2, y, z); uv.push(0, len / 4, 1, len / 4); if (i) { const a = (i - 1) * 2; idx.push(a, a + 1, a + 2, a + 1, a + 3, a + 2); } });
const pg = new T.BufferGeometry(); pg.setAttribute('position', new T.Float32BufferAttribute(pos, 3)); pg.setAttribute('uv', new T.Float32BufferAttribute(uv, 2)); pg.setIndex(idx); pg.computeVertexNormals();
const paper = K.mesh(pg, K.std('#ffffff', 0.9, 0, { map: barTex, side: T.DoubleSide }), { to: g }); papers.push(paper);
return g;
}
/* ceiling light troughs, as in the NASA room */
const strip = new T.MeshBasicMaterial({ color: K.col('#f4f8ff').multiplyScalar(1.3), toneMapped: false });
function ceiling(root) { for (let i = 0; i < 7; i++) K.mesh(new T.BoxGeometry(0.9, 0.06, 46), strip, { p: [-11 + i * 5.2, 12.6, -2], to: root, cast: false, receive: false }); }
/* the operator's chair: four-star base on casters, vinyl seat and back */
function chair(root) { const g = new T.Group(); g.position.set(6.3, 0, 0.72); g.rotation.y = -Math.PI / 2 + 0.25; g.scale.setScalar(0.9); root.add(g); /* tucked behind the seated operator's cut-out, so he sits on something */
for (let i = 0; i < 4; i++) { const a = i * Math.PI / 2 + 0.4; K.mesh(K.rbox(0.74, 0.07, 0.12, 0.03, 2), steel, { p: [Math.cos(a) * 0.36, 0.2, Math.sin(a) * 0.36], r: [0, -a, 0], to: g }); K.mesh(new T.SphereGeometry(0.085, 14, 10), blackM, { p: [Math.cos(a) * 0.7, 0.09, Math.sin(a) * 0.7], to: g }); }
K.mesh(new T.CylinderGeometry(0.055, 0.065, 1.0, 16), steel, { p: [0, 0.72, 0], to: g }); K.mesh(new T.CylinderGeometry(0.1, 0.11, 0.3, 16), blackM, { p: [0, 0.42, 0], to: g }); K.mesh(K.rbox(1.08, 0.05, 1.02, 0.02, 2), steel, { p: [0, 1.21, 0], to: g });
K.mesh(K.rbox(1.2, 0.2, 1.15, 0.09, 3), vinyl, { p: [0, 1.33, 0], to: g }); [-0.4, 0.4].forEach((x) => K.mesh(K.rbox(0.07, 0.95, 0.05, 0.02, 2), steel, { p: [x, 1.76, -0.57], r: [0.12, 0, 0], to: g })); K.mesh(K.rbox(1.12, 0.62, 0.16, 0.07, 3), vinyl, { p: [0, 2.22, -0.64], r: [0.12, 0, 0], to: g }); }
/* a card reader working through a deck: hopper on the right, read station, stacker on the left */
function reader(root) { const real = root === room, g = new T.Group(); g.position.set(11.3, 0, -0.9); g.rotation.y = -0.5; root.add(g);
K.mesh(new T.BoxGeometry(3.0, 0.26, 1.8), blackM, { p: [0, 0.13, 0], to: g }); K.mesh(K.rbox(3.1, 2.9, 1.9, 0.07), white, { p: [0, 1.7, 0], to: g }); K.mesh(K.rbox(3.14, 0.1, 1.94, 0.04), grey, { p: [0, 3.19, 0], to: g });
K.mesh(new T.PlaneGeometry(3.1, 0.3), K.std('#ffffff', 0.5, 0, { map: label('CARD READ PUNCH 1', '#de3b25', '#fff4e8') }), { p: [0, 2.98, 0.956], to: g, cast: false });
K.mesh(K.rbox(0.72, 0.62, 1.02, 0.05), dark, { p: [0.02, 3.55, -0.2], to: g }); K.mesh(new T.BoxGeometry(0.74, 0.03, 0.66), steel, { p: [0.02, 3.5, -0.2], to: g, cast: false });
const decks = [1, -1].map((sd) => { const tr = new T.Group(); tr.position.set(sd * 0.96, 3.26, -0.2); tr.rotation.z = sd * 0.17; g.add(tr); K.mesh(K.rbox(1.16, 0.05, 0.76, 0.02, 2), steel, { to: tr }); [-0.37, 0.37].forEach((z) => K.mesh(new T.BoxGeometry(1.16, 0.3, 0.025), steel, { p: [0, 0.17, z], to: tr, cast: false }));
const dk = K.mesh(new T.BoxGeometry(1, 0.27, 0.62), [cardFace, cardFace, manilaV, manilaV, manilaV, manilaV], { p: [0, 0.165, 0], to: tr }); const wt = K.mesh(K.rbox(0.07, 0.3, 0.56, 0.02, 2), blackM, { p: [0, 0.18, 0], to: tr, cast: false }); return { dk, wt, sd }; });
const lay = (f) => decks.forEach(({ dk, wt, sd }) => { const len = sd > 0 ? 0.95 - 0.8 * f : 0.12 + 0.8 * f; dk.scale.x = len; dk.position.x = sd * (len / 2 - 0.5); wt.position.x = sd * (len - 0.46); }); lay(0.35);
if (!real) return g;
K.mesh(new T.PlaneGeometry(2.6, 0.46), louvre, { p: [0, 0.66, 0.956], to: g, cast: false }); K.mesh(new T.PlaneGeometry(0.62, 0.15), plateM, { p: [-1.0, 2.6, 0.956], to: g, cast: false }); for (let b = 0; b < 4; b++) K.mesh(bG, btn[(b + 1) % 4], { p: [0.55 + b * 0.27, 2.6, 0.97], to: g, cast: false });
[-1.5, 1.5].forEach((x) => K.mesh(new T.BoxGeometry(0.012, 2.6, 0.02), blackM, { p: [x * 1.035, 1.75, 0.4], to: g, cast: false })); K.mesh(new T.BoxGeometry(3.12, 0.05, 0.02), steel, { p: [0, 0.3, 0.955], to: g, cast: false });
/* cards leaving the station for the stacker, five a second */
const fl = [0, 1, 2].map(() => K.mesh(new T.BoxGeometry(0.008, 0.27, 0.62), cardFace, { to: g, cast: false }));
anim.push((t) => { lay((t * 0.04) % 1); fl.forEach((m, i) => { const p = (t * 1.7 + i / 3) % 1; m.position.set(-0.36 - p * 0.2, 3.5 - p * 0.03, -0.2); m.rotation.z = -0.17 - (1 - p) * 0.5; m.visible = p < 0.9; }); });
return g; }
const room = new T.Group(), mirror = new T.Group(); mirror.scale.y = -1; scene.add(room, mirror);
K.blob(22, 5.4, { p: [8.3, 0, -6.6], a: 0.3, to: scene }); K.blob(9, 5, { p: [5, 0, -1.7], a: 0.3, to: scene });
const rows = [room, mirror].map((root) => { const row = new T.Group(); row.position.set(...ROW); row.rotation.y = YAW; root.add(row); for (let i = 0; i < 7; i++) drive(row, i); consoleUnit(root); printer(root); chair(root); reader(root); if (root === mirror) ceiling(root); return row; });
mirror.traverse((o) => { if (o.isMesh) { o.castShadow = false; o.receiveShadow = false; } });
K.mesh(new T.PlaneGeometry(220, 60), K.std('#0f2a8c', 1), { p: [0, 12.9, -4], r: [Math.PI / 2, 0, 0], to: scene, cast: false, receive: false });
/* polished raised floor: 2 ft tiles, translucent enough to let the upside-down room through */
const tiles = K.tex(512, 512, (g) => { g.fillStyle = '#1c47cc'; g.fillRect(0, 0, 512, 512); const R = K.rng(9); for (let i = 0; i < 900; i++) { g.fillStyle = 'rgba(' + (R() < 0.5 ? '120,160,255' : '8,20,90') + ',' + R() * 0.09 + ')'; g.fillRect(R() * 512, R() * 512, 2 + R() * 30, 1 + R() * 2); } g.strokeStyle = 'rgba(150,180,255,0.42)'; g.lineWidth = 5; g.strokeRect(0, 0, 512, 512); g.fillStyle = 'rgba(190,210,255,0.5)'; [[14, 14], [498, 14], [14, 498], [498, 498]].forEach(([x, y]) => { g.beginPath(); g.arc(x, y, 3, 0, 7); g.fill(); }); }, { repeat: [120, 60] });
const floor = K.mesh(new T.PlaneGeometry(240, 120), new T.MeshStandardMaterial({ map: tiles, transparent: true, opacity: 0.74, roughness: 0.2, metalness: 0.1, envMapIntensity: 0.8 }), { p: [0, 0, 10], r: [-Math.PI / 2, 0, 0], to: scene, cast: false });
floor.renderOrder = -1;
/* ---------- what a working machine room keeps along its wall and on its floor ---------- */
{ /* the tape library: three shelves of reels in their canisters, a coloured tab on each */
/* everything on the wall is for wide screens only: on a phone the headline sits over that wall once the camera closes in */
const wallSet = new T.Group(); room.add(wallSet); anim.push((t, P) => { wallSet.visible = !P.mobile; });
const lib = new T.Group(); lib.position.set(0, 0, -12.45); wallSet.add(lib); const X0 = 3.4, X1 = 19.8, SG = (X1 - X0) / 4, SH = [5.95, 7.2, 8.45], n = Math.floor((X1 - X0 - 0.36) / 0.128), o = new T.Object3D(), R = K.rng(31);
for (let i = 0; i <= 4; i++) K.mesh(new T.BoxGeometry(0.09, 9.75, 0.96), frameM, { p: [X0 + SG * i, 4.875, 0], to: lib, cast: false });
SH.concat([9.7]).forEach((y) => K.mesh(new T.BoxGeometry(X1 - X0, 0.06, 1.0), grey, { p: [(X0 + X1) / 2, y, 0], to: lib, cast: false }));
const can = new T.InstancedMesh(new T.CylinderGeometry(0.47, 0.47, 0.1, 22).rotateZ(Math.PI / 2), K.std('#ffffff', 0.4, 0.05), n * 3), tab = new T.InstancedMesh(new T.BoxGeometry(0.088, 0.22, 0.02), K.std('#ffffff', 0.75), n * 3), CC = ['#d9dee6', '#c5d1e6', '#e8e4d8', '#b7c2d4', '#dfe3ea'].map(K.col), TC2 = ['#f4f1ea', '#de3b25', '#ffb81f', '#f4f1ea', '#3aa76d', '#f4f1ea', '#f4f1ea'].map(K.col);
for (let s2 = 0; s2 < 3; s2++) for (let i = 0; i < n; i++) { const id = s2 * n + i, x = X0 + 0.24 + i * 0.128, d = (x - X0) % SG, gap = R() < 0.08 || d < 0.15 || d > SG - 0.15, lean = !gap && R() < 0.04 ? 0.14 : 0;
o.position.set(x, SH[s2] + 0.5, 0); o.rotation.set(0, 0, lean); o.scale.setScalar(gap ? 1e-4 : 1); o.updateMatrix(); can.setMatrixAt(id, o.matrix); can.setColorAt(id, CC[(R() * 5) | 0]);
o.position.set(x, SH[s2] + 0.5, 0.468); o.rotation.set(0, 0, 0); o.updateMatrix(); tab.setMatrixAt(id, o.matrix); tab.setColorAt(id, TC2[(R() * 7) | 0]); }
[can, tab].forEach((m) => { m.castShadow = false; m.receiveShadow = true; m.frustumCulled = false; lib.add(m); });
K.mesh(new T.PlaneGeometry(2.5, 0.34), K.std('#ffffff', 0.5, 0, { map: label('TAPE LIBRARY · A–F', '#12172b', '#e9edf7') }), { p: [X0 + SG * 2, 9.95, 0.49], to: lib, cast: false });
/* the wall clock: the second hand steps */
const ck = new T.Group(); ck.position.set(12.3, 11.15, -12.9); wallSet.add(ck); K.mesh(new T.CylinderGeometry(0.86, 0.86, 0.12, 44).rotateX(Math.PI / 2), blackM, { to: ck, cast: false });
K.mesh(new T.CircleGeometry(0.78, 48), K.std('#ffffff', 0.55, 0, { map: K.tex(512, 512, (g) => { g.fillStyle = '#f7f5ee'; g.fillRect(0, 0, 512, 512); g.translate(256, 256); g.fillStyle = '#16181d'; for (let i = 0; i < 60; i++) { g.save(); g.rotate(i * Math.PI / 30); g.fillRect(i % 5 ? -1.5 : -4.5, -246, i % 5 ? 3 : 9, i % 5 ? 14 : 30); g.restore(); } g.font = '700 54px ' + K.SANS; g.textAlign = 'center'; g.textBaseline = 'middle'; for (let h = 1; h <= 12; h++) g.fillText(String(h), Math.sin(h * Math.PI / 6) * 176, -Math.cos(h * Math.PI / 6) * 176 + 4); }) }), { p: [0, 0, 0.065], to: ck, cast: false });
const hand = (w, l, tail, m, z) => { const p = new T.Group(); p.position.z = z; ck.add(p); K.mesh(new T.BoxGeometry(w, l + tail, 0.012), m, { p: [0, (l - tail) / 2, 0], to: p, cast: false }); return p; };
const hh = hand(0.06, 0.42, 0.08, blackM, 0.08), mm = hand(0.04, 0.64, 0.1, blackM, 0.095), ss = hand(0.016, 0.7, 0.18, red, 0.11); K.mesh(new T.CylinderGeometry(0.045, 0.045, 0.06, 16).rotateX(Math.PI / 2), blackM, { p: [0, 0, 0.1], to: ck, cast: false });
anim.push((t) => { const sec = 52 * 60 + 14 + t, st = Math.floor(sec) + K.ease(K.clamp((sec % 1) * 7)); mm.rotation.z = -(sec / 3600) * 2 * Math.PI; hh.rotation.z = -((9 + sec / 3600) / 12) * 2 * Math.PI; ss.rotation.z = -(st / 60) * 2 * Math.PI; });
K.mesh(new T.PlaneGeometry(3.0, 0.78), K.std('#ffffff', 0.35, 0.05, { map: K.tex(768, 200, (g) => { g.fillStyle = '#f6f3ea'; g.fillRect(0, 0, 768, 200); g.strokeStyle = '#c23b2a'; g.lineWidth = 10; g.strokeRect(12, 12, 744, 176); g.fillStyle = '#c23b2a'; g.font = '700 104px ' + K.SANS; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText('NO SMOKING', 384, 106); g.fillStyle = '#8c8f96'; [[28, 28], [740, 28], [28, 172], [740, 172]].forEach(([x, y]) => { g.beginPath(); g.arc(x, y, 6, 0, 7); g.fill(); }); }) }), { p: [7.1, 11.0, -12.96], to: wallSet, cast: false });
K.mesh(new T.PlaneGeometry(2.6, 0.62), K.std('#ffffff', 0.4, 0.05, { map: K.tex(640, 152, (g) => { g.fillStyle = '#12172b'; g.fillRect(0, 0, 640, 152); g.strokeStyle = '#e9edf7'; g.lineWidth = 4; g.strokeRect(8, 8, 624, 136); g.fillStyle = '#e9edf7'; g.textBaseline = 'middle'; g.font = '700 46px ' + K.MONO; g.fillText('MACHINE ROOM 2', 28, 52); g.font = '500 25px ' + K.MONO; g.fillText('68 °F · 45 % R.H. · KEEP DOOR SHUT', 28, 110); }) }), { p: [17.3, 11.0, -12.96], to: wallSet, cast: false });
/* floor work: perforated tiles where the air comes up, one tile lifted for a cable pull */
const ventM = K.std('#ffffff', 0.55, 0.25, { map: K.tex(256, 256, (g) => { g.fillStyle = '#4b68c8'; g.fillRect(0, 0, 256, 256); g.fillStyle = '#10205f'; for (let y = 0; y < 14; y++) for (let x = 0; x < 14; x++) { g.beginPath(); g.arc(22 + x * 16.3, 22 + y * 16.3, 4.6, 0, 7); g.fill(); } g.strokeStyle = 'rgba(190,210,255,0.6)'; g.lineWidth = 5; g.strokeRect(2, 2, 252, 252); }) });
[[1, -3], [11, 1], [15, -5]].forEach(([x, z]) => K.mesh(new T.PlaneGeometry(1.97, 1.97), ventM, { p: [x, 0.006, z], r: [-Math.PI / 2, 0, 0], to: room, cast: false }));
const pitM = K.std('#ffffff', 0.9, 0, { map: K.tex(512, 512, (g) => { g.fillStyle = '#070b1c'; g.fillRect(0, 0, 512, 512); const Rp = K.rng(17); for (let i = 0; i < 500; i++) { g.fillStyle = 'rgba(120,140,200,' + Rp() * 0.05 + ')'; g.fillRect(Rp() * 512, Rp() * 512, 2 + Rp() * 20, 2 + Rp() * 8); }
/* cable bundles lying on the slab below */ [[60, '#5c6370', 26], [150, '#3a3f4a', 20], [214, '#6f7682', 30], [300, '#2d323c', 18], [352, '#5c6370', 24], [430, '#444a56', 22]].forEach(([y, c, w], i) => { g.strokeStyle = 'rgba(0,0,0,0.5)'; g.lineWidth = w + 8; g.beginPath(); g.moveTo(-10, y + 10 + i * 6); g.bezierCurveTo(170, y - 30, 340, y + 50, 522, y - 6); g.stroke(); g.strokeStyle = c; g.lineWidth = w; g.beginPath(); g.moveTo(-10, y + i * 6); g.bezierCurveTo(170, y - 40, 340, y + 40, 522, y - 16); g.stroke(); g.strokeStyle = 'rgba(255,255,255,0.14)'; g.lineWidth = w * 0.22; g.beginPath(); g.moveTo(-10, y - w * 0.22 + i * 6); g.bezierCurveTo(170, y - 40 - w * 0.22, 340, y + 40 - w * 0.22, 522, y - 16 - w * 0.22); g.stroke(); });
/* the pit is in shade on the two near sides; pedestal heads at the corners; stringers round the edge */ const sh = g.createLinearGradient(0, 512, 0, 300); sh.addColorStop(0, 'rgba(0,0,0,0.75)'); sh.addColorStop(1, 'rgba(0,0,0,0)'); g.fillStyle = sh; g.fillRect(0, 0, 512, 512); const sh2 = g.createLinearGradient(0, 0, 200, 0); sh2.addColorStop(0, 'rgba(0,0,0,0.7)'); sh2.addColorStop(1, 'rgba(0,0,0,0)'); g.fillStyle = sh2; g.fillRect(0, 0, 512, 512);
g.strokeStyle = '#8f98ab'; g.lineWidth = 16; g.strokeRect(4, 4, 504, 504); g.fillStyle = '#b9c1d1'; [[0, 0], [512, 0], [0, 512], [512, 512]].forEach(([x, y]) => { g.fillRect(x - 46, y - 46, 92, 92); }); }) });
K.mesh(new T.PlaneGeometry(1.98, 1.98), pitM, { p: [7, 0.007, 3], r: [-Math.PI / 2, 0, 0], to: room, cast: false });
const slab = new T.Group(); slab.position.set(4.7, 0, 3.5); slab.rotation.y = 0.22; room.add(slab); K.mesh(new T.BoxGeometry(1.96, 0.11, 1.96), [grey, grey, K.std('#3a5fd2', 0.3, 0.1), grey, grey, grey], { p: [0, 0.055, 0], to: slab });
[-0.26, 0.26].forEach((x) => { K.mesh(new T.CylinderGeometry(0.13, 0.15, 0.07, 20), blackM, { p: [x, 0.145, 0.1], to: slab }); K.mesh(new T.CylinderGeometry(0.02, 0.02, 0.16, 8), steel, { p: [x, 0.26, 0.1], to: slab, cast: false }); }); K.mesh(new T.CylinderGeometry(0.028, 0.028, 0.62, 10).rotateZ(Math.PI / 2), steel, { p: [0, 0.34, 0.1], to: slab });
const rubber = K.std('#5c6370', 0.75, 0.05); [0, 1, 2].forEach((i) => K.mesh(new T.TorusGeometry(0.5 - i * 0.02, 0.06, 10, 44), rubber, { p: [6.0 + i * 0.03, 0.065 + i * 0.115, 4.75 - i * 0.02], r: [-Math.PI / 2 + (i - 1) * 0.03, 0, i * 0.7], to: room }));
K.mesh(new T.TubeGeometry(new T.CatmullRomCurve3([[6.42, 0.3, 4.5], [6.62, 0.24, 4.05], [6.72, 0.1, 3.75], [6.9, 0.03, 3.45], [7.0, 0.012, 3.1]].map((p) => new T.Vector3(...p))), 28, 0.06, 10), rubber, { to: room });
K.mesh(K.rbox(0.36, 0.2, 0.26, 0.03, 2), blackM, { p: [5.35, 0.1, 5.1], r: [0, 0.6, 0], to: room }); K.mesh(new T.BoxGeometry(0.1, 0.16, 0.22), steel, { p: [5.19, 0.1, 5.21], r: [0, 0.6, 0], to: room, cast: false }); K.mesh(new T.TubeGeometry(new T.CatmullRomCurve3([[5.5, 0.1, 5.0], [5.7, 0.07, 4.95], [5.72, 0.07, 5.15], [5.98, 0.07, 5.22]].map((p) => new T.Vector3(...p))), 16, 0.06, 8), rubber, { to: room }); }
/* the exit: the pink hub of unit 6 dilates to the full reel, then turns into the next room */
const exL = new T.Vector3(DX[EXIT] + 0.57, 4.62, 1.34 + 0.09);
const door = K.mesh(new T.CircleGeometry(0.5, 64), K.portalMat(U, K.col('#ff00b0')), { p: [exL.x, exL.y, exL.z], to: rows[0], cast: false, receive: false }); door.visible = false;
scene.updateMatrixWorld(true);
const ex = exL.clone().applyMatrix4(rows[0].matrixWorld), fz = new T.Vector3(0, 0, 1).transformDirection(rows[0].matrixWorld), at = (d, up = 0) => [ex.x + fz.x * d, ex.y + up, ex.z + fz.z * d];
const rail = K.rail([
{ k: -0.4, p: [-8.5, 8.8, 20.5], l: [5, 3.6, -5], f: 38 },
{ k: 0, p: [-6.2, 7.6, 17.2], l: [4.6, 3.5, -5], f: 37 },
{ k: 0.36, p: [-3.9, 5.7, 9.8], l: [2.7, 3.9, -5.8] },
{ k: 0.62, p: [-2.5, 5.0, 4.4], l: [1.7, 4.2, -5.4] },
{ k: 0.84, p: at(4.4, 0.25), l: [ex.x, ex.y, ex.z], f: 34 },
{ k: 1, p: at(0.9), l: at(-3), f: 30 }
]);
let test = 0;
const pv = new T.Vector3(), col = new T.Color(), hx = new T.Vector3(1, 0, 0).transformDirection(rows[0].matrixWorld).multiplyScalar(0.5), hy = new T.Vector3(0, 0.5, 0), ON = K.col('#ffe2b4').multiplyScalar(1.5), PK = K.col('#ff00b0').multiplyScalar(1.3), OFF = K.col('#1b1410');
return {
scene, camera, textDepth: 0, outStart: 0.42, irisAt: 0.3, shiftX: 0.17,
portal() { return { c: ex, hx, hy, round: 1 }; },
update(k, t, dt, P) {
const kk = K.clamp(k, -0.4, 1), k01 = K.clamp(k, 0, 1);
reels.forEach((d) => {
/* a drive under the pointer goes into rewind */
if (d.rs[0].r.parent.parent.parent === room) { pv.set(DX[d.i], 4.4, DZ + 1.3).applyMatrix4(rows[0].matrixWorld).project(camera); d.near = P.hot * K.smooth(0.34, 0.08, Math.hypot((pv.x - P.nx) * P.aspect, pv.y - P.ny)); d.spin = (d.spin || 0) + d.near * dt * 26; }
const src = reels[d.i], th = (src.spin || 0) + 3.0 * (t * 0.55 + 0.9 * Math.sin(t * 0.83 + d.ph) + 0.42 * Math.sin(t * 2.1 + d.ph * 2.3)), fill = 0.5 + 0.5 * Math.sin(d.ph * 3.1) * 0.6 + (d.i === EXIT ? k01 * 0.25 : 0);
d.rs.forEach((q) => { const rad = q.s ? K.lerp(0.2, 0.44, fill) : K.lerp(0.44, 0.2, fill); q.r.rotation.z = -th / (rad * 2.6); q.pack.scale.set(rad, rad, 1);
const sx = q.x + (q.s ? -rad : rad); q.strand.position.set(sx, (4.62 + 3.79) / 2 - 0.2, 1.34); q.strand.scale.y = 4.62 - 3.79 + 0.4; });
});
loops.forEach((l) => { const d = reels[l.i % 7], v = Math.cos(t * 0.83 + d.ph) * 0.9 + Math.cos(t * 2.1 + d.ph * 2.3) * 0.42, h = 0.75 + (l.s ? -1 : 1) * v * 0.3; l.lp.scale.y = h; l.lp.position.y = 2.68 - h / 2; });
const step = Math.floor(t * 9);
lampSets.forEach((lm) => { for (let r = 0; r < LR; r++) { const n = Math.floor(t * (2 + r * 1.7) + r * 977) >>> 0; for (let c = 0; c < LC; c++) { const bit = r < 8 ? (n >>> ((c * 7 + r) % 23)) & 1 : (Math.sin((step + c * 12.9898 + r * 78.233) * 43758.5453) > 0.2 ? 1 : 0); lm.setColorAt(r * LC + c, bit ? ((c + r * 5) % 17 === 0 ? PK : ON) : OFF); } } lm.instanceColor.needsUpdate = true; });
for (const f of anim) f(t, P);
/* point at the console and it runs a lamp test: everything on */
pv.set(4.88, 3.72, -2.4).project(camera); test += ((P.hot * K.smooth(0.3, 0.1, Math.hypot((pv.x - P.nx) * P.aspect, pv.y - P.ny)) > 0.5 ? 1 : 0) - test) * Math.min(1, dt * 9);
if (test > 0.5) lampSets.forEach((lm) => { for (let i = 0; i < LR * LC; i++) lm.setColorAt(i, (i % LC + Math.floor(i / LC) * 5) % 17 === 0 ? PK : ON); lm.instanceColor.needsUpdate = true; });
barTex.offset.y = -t * 0.12;
const g = K.ease(K.smooth(0, 0.42, P.kt)); door.visible = P.kt > 0.001; door.scale.setScalar(K.lerp(0.34, 1.0, g)); door.material.uniforms.uMix.value = K.smooth(0.3, 0.72, P.kt);
K.aim(camera, rail(kk), P, 1 - K.smooth(0.66, 0.98, k01)); K.faceFlats(flats, camera);
}
};
});