Repository navigation
Expand file tree
/
Copy paths-net.js
More file actions
274 lines (268 loc) · 51.4 KB
/
Copy paths-net.js
File metadata and controls
274 lines (268 loc) · 51.4 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
/* Set 4 · 1995 · The Internet.
A teal studio. NASA's Blue Marble hangs over the floor and wires itself up, city to city, while browser windows of the
period circle it: grey chrome, blue links, a visitor counter. On the floor, the black cube that served the first pages,
with its handwritten warning. The exit is a browser window. */
H.def('net', ({ renderer, H }) => {
const T = THREE, U = H.U, scene = new T.Scene(), BG = K.col('#00857d');
scene.background = BG; scene.fog = new T.Fog(BG.getHex(), 40, 100);
const camera = new T.PerspectiveCamera(36, 1, 0.05, 240);
scene.environment = K.env(renderer, { top: '#7d9a96', bottom: '#0b3a36', boxes: [{ p: [-12, 18, 12], s: [16, 12], i: 3.2 }, { p: [16, 8, 8], s: [8, 14], i: 1.2 }, { p: [2, 24, 0], s: [14, 14], i: 1.4 }] });
K.lights(scene, { pos: [-11, 20, 14], target: [1, 4, 0], key: 2.5, amb: 0.55, sky: '#eafffb', ground: '#0a9a90', extent: 22, far: 90 });
K.mesh(K.cove(240, 50, -15, 5, 70), K.std('#008c84', 0.96), { to: scene, cast: false });
/* ---- the Earth ---- */
const R = 4.7, C = new T.Vector3(1.2, 6.5, 0), globe = new T.Group(); globe.position.copy(C); globe.rotation.z = 0.36; scene.add(globe);
const spin = new T.Group(); globe.add(spin);
const earthT = new T.TextureLoader().load(K.url('img/earth.jpg')); earthT.colorSpace = T.SRGBColorSpace; earthT.anisotropy = 8;
K.mesh(new T.SphereGeometry(R, 96, 64), K.std('#ffffff', 0.62, 0, { map: earthT, envMapIntensity: 0.5 }), { to: spin, receive: false });
const halo = new T.Mesh(new T.SphereGeometry(R * 1.035, 64, 48), new T.ShaderMaterial({ transparent: true, depthWrite: false, blending: T.AdditiveBlending,
vertexShader: 'varying vec3 n; varying vec3 v; void main(){ vec4 mv = modelViewMatrix * vec4(position, 1.0); n = normalize(normalMatrix * normal); v = normalize(-mv.xyz); gl_Position = projectionMatrix * mv; }',
fragmentShader: 'varying vec3 n; varying vec3 v; void main(){ float f = pow(1.0 - max(dot(normalize(n), normalize(v)), 0.0), 2.6); gl_FragColor = vec4(vec3(0.55, 1.0, 0.95) * f * 0.7, f * 0.8); }' }));
globe.add(halo);
const ll = (lat, lon, r = 1) => { const ph = (lon + 180) / 360 * Math.PI * 2, th = (90 - lat) / 180 * Math.PI; return new T.Vector3(-Math.cos(ph) * Math.sin(th), Math.cos(th), Math.sin(ph) * Math.sin(th)).multiplyScalar(r); };
const CITY = [[40.7, -74], [37.8, -122.4], [34, -118.2], [41.9, -87.6], [43.7, -79.4], [19.4, -99.1], [-23.5, -46.6], [-34.6, -58.4], [51.5, -0.1], [48.9, 2.35], [46.2, 6.1], [52.4, 4.9], [52.5, 13.4], [40.4, -3.7], [41.9, 12.5], [59.3, 18.1], [55.8, 37.6], [30, 31.2], [6.5, 3.4], [-1.3, 36.8], [-26.2, 28], [25.2, 55.3], [19.1, 72.9], [28.6, 77.2], [1.35, 103.8], [22.3, 114.2], [39.9, 116.4], [37.6, 127], [35.7, 139.7], [-33.9, 151.2], [21.3, -157.9], [64.1, -21.9], [4.7, -74.1], [-12, -77], [33.6, -7.6], [14.7, -17.4], [13.7, 100.5], [-6.2, 106.8], [45.5, -73.6], [47.6, -122.3]].map(([a, b]) => ll(a, b));
const dots = new T.InstancedMesh(new T.SphereGeometry(0.055, 10, 8), new T.MeshBasicMaterial({ color: K.col('#ffffff').multiplyScalar(1.2), toneMapped: false }), CITY.length), o3 = new T.Object3D();
CITY.forEach((p, i) => { o3.position.copy(p).multiplyScalar(R * 1.004); o3.updateMatrix(); dots.setMatrixAt(i, o3.matrix); }); spin.add(dots);
/* arcs: one merged tube geometry, revealed and pulsed in the shader */
const Rn = K.rng(42), pos = [], uvs = [], st = [], idx = [], ARCS = []; let base = 0;
for (let n = 0; n < 104; n++) {
const a = CITY[(Rn() * CITY.length) | 0], b = CITY[(Rn() * CITY.length) | 0], ang = a.angleTo(b); if (ang < 0.12 || ang > 2.4) { n--; continue; }
const pts = []; for (let i = 0; i <= 24; i++) { const u = i / 24, s = Math.sin(ang), p = a.clone().multiplyScalar(Math.sin((1 - u) * ang) / s).addScaledVector(b, Math.sin(u * ang) / s); pts.push(p.multiplyScalar(R * (1.006 + (0.05 + 0.3 * ang / Math.PI) * Math.sin(Math.PI * u)))); }
const g = new T.TubeGeometry(new T.CatmullRomCurve3(pts), 36, 0.019, 5), s0 = Rn() * 0.86; if (ARCS.length < 12 && ang > 0.5) ARCS.push({ a, b, ang, s0 });
pos.push(...g.attributes.position.array); uvs.push(...g.attributes.uv.array); for (let i = 0; i < g.attributes.position.count; i++) st.push(s0); for (const v of g.index.array) idx.push(v + base); base += g.attributes.position.count; g.dispose();
}
const arcG = new T.BufferGeometry(); arcG.setAttribute('position', new T.Float32BufferAttribute(pos, 3)); arcG.setAttribute('uv', new T.Float32BufferAttribute(uvs, 2)); arcG.setAttribute('aS', new T.Float32BufferAttribute(st, 1)); arcG.setIndex(idx);
const arcM = new T.ShaderMaterial({ uniforms: { uK: { value: 0 }, uTime: { value: 0 }, cA: { value: K.col('#ff00b0').multiplyScalar(1.05) }, cB: { value: K.col('#fff3a8').multiplyScalar(1.0) } },
vertexShader: 'attribute float aS; varying float vU; varying float vS; void main(){ vU = uv.x; vS = aS; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }',
fragmentShader: 'uniform float uK; uniform float uTime; uniform vec3 cA; uniform vec3 cB; varying float vU; varying float vS; void main(){ float grow = clamp((uK - vS) / 0.1, 0.0, 1.0); if (vU > grow) discard; float p = fract(vU - uTime * 0.3 - vS * 7.0); float pulse = smoothstep(0.1, 0.0, p) + smoothstep(0.96, 1.0, p); vec3 c = mix(cA, cB, step(0.42, fract(vS * 13.37))) * (0.8 + 0.9 * pulse); gl_FragColor = vec4(c, 1.0); }' });
const arcs = new T.Mesh(arcG, arcM); arcs.frustumCulled = false; spin.add(arcs);
/* a fine graticule every fifteen degrees, the equator a little firmer */
{ const gp = [], eq = [], seg = (arr, f, n) => { for (let i = 0; i < n; i++) { const a = f(i / n), b = f((i + 1) / n); arr.push(a.x, a.y, a.z, b.x, b.y, b.z); } };
for (let la = -75; la <= 75; la += 15) seg(la ? gp : eq, (u) => ll(la, u * 360 - 180, R * 1.003), 120);
for (let lo = -180; lo < 180; lo += 15) seg(gp, (u) => ll(u * 170 - 85, lo, R * 1.003), 60);
[[gp, 0.15], [eq, 0.3]].forEach(([arr, op]) => { const g = new T.BufferGeometry(); g.setAttribute('position', new T.Float32BufferAttribute(arr, 3)); spin.add(new T.LineSegments(g, new T.LineBasicMaterial({ color: '#ffffff', transparent: true, opacity: op, depthWrite: false }))); }); }
/* weather: a thin shell of cloud, streaked along the latitudes, lit by the same key light, drifting a little faster than the ground */
const cloudM = new T.ShaderMaterial({ transparent: true, depthWrite: false, uniforms: { uT: { value: 0 }, uL: { value: new T.Vector3(-12, 16, 14).normalize() } },
vertexShader: 'varying vec3 vP; varying vec3 vN; void main(){ vP = position; vN = normalize(mat3(modelMatrix) * normal); gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }',
fragmentShader: `uniform float uT; uniform vec3 uL; varying vec3 vP; varying vec3 vN;
float h3(vec3 p){ return fract(sin(dot(p, vec3(127.1, 311.7, 74.7))) * 43758.5453); }
float n3(vec3 p){ vec3 i = floor(p), f = fract(p); f = f * f * (3.0 - 2.0 * f); return mix(mix(mix(h3(i), h3(i + vec3(1.0, 0.0, 0.0)), f.x), mix(h3(i + vec3(0.0, 1.0, 0.0)), h3(i + vec3(1.0, 1.0, 0.0)), f.x), f.y), mix(mix(h3(i + vec3(0.0, 0.0, 1.0)), h3(i + vec3(1.0, 0.0, 1.0)), f.x), mix(h3(i + vec3(0.0, 1.0, 1.0)), h3(i + vec3(1.0, 1.0, 1.0)), f.x), f.y), f.z); }
float fbm(vec3 p){ float a = 0.5, s = 0.0; for (int i = 0; i < 4; i++) { s += a * n3(p); p = p * 2.07 + 3.1; a *= 0.5; } return s; }
void main(){ vec3 d = normalize(vP), p = d * 3.4; float w = fbm(p * 0.9 + vec3(0.0, uT * 0.006, 0.0)), n = fbm(p * vec3(1.5, 2.9, 1.5) + w * 1.7), band = 0.05 * cos(abs(d.y) * 9.5) - 0.03, c = smoothstep(0.52 - band, 0.74 - band, n);
float l = max(dot(normalize(vN), uL), 0.0) * 0.78 + 0.3; gl_FragColor = vec4(vec3(l), c * 0.72); }` });
const clouds = K.mesh(new T.SphereGeometry(R * 1.011, 72, 48), cloudM, { to: spin, cast: false, receive: false }); clouds.renderOrder = 1;
/* the places on the net in 1995, lettered on the surface the way the backbone maps were (the label lies east or west of its dot) */
{ const LBL = [[40.7, -74, 'NEW YORK', 1], [37.8, -122.4, 'STANFORD', -1], [41.9, -87.6, 'CHICAGO', -1], [19.4, -99.1, 'MEXICO CITY', -1], [-23.5, -46.6, 'SÃO PAULO', 1], [-34.6, -58.4, 'BUENOS AIRES', 1], [51.5, -0.1, 'LONDON', -1], [46.2, 6.1, 'CERN · GENEVA', 1], [59.3, 18.1, 'STOCKHOLM', 1], [55.8, 37.6, 'MOSCOW', 1], [30, 31.2, 'CAIRO', 1], [-1.3, 36.8, 'NAIROBI', 1], [-26.2, 28, 'JOHANNESBURG', 1], [19.1, 72.9, 'BOMBAY', -1], [28.6, 77.2, 'NEW DELHI', 1], [13.7, 100.5, 'BANGKOK', -1], [1.35, 103.8, 'SINGAPORE', 1], [22.3, 114.2, 'HONG KONG', 1], [39.9, 116.4, 'BEIJING', -1], [35.7, 139.7, 'TOKYO', 1], [-6.2, 106.8, 'JAKARTA', 1], [-33.9, 151.2, 'SYDNEY', 1], [21.3, -157.9, 'HONOLULU', 1], [64.1, -21.9, 'REYKJAVÍK', 1]];
const RH = 42, wpx = [], lt = K.tex(1024, 512, (g) => { g.clearRect(0, 0, 1024, 512); g.textBaseline = 'middle'; g.font = '600 23px ' + K.MONO; try { g.letterSpacing = '1.5px'; } catch (e) {}
LBL.forEach(([, , s], i) => { const x = (i % 2) * 512, y = Math.floor(i / 2) * RH, w = Math.min(500, Math.ceil(g.measureText(s).width) + 22); wpx.push(w); g.fillStyle = 'rgba(6,22,28,0.74)'; g.beginPath(); g.roundRect ? g.roundRect(x + 2, y + 4, w, 34, 5) : g.rect(x + 2, y + 4, w, 34); g.fill(); g.fillStyle = '#ffffff'; g.fillText(s, x + 13, y + 22); }); });
const lp = [], lu = [], li = [], HU = 0.2, NSEG = 6; let vb = 0;
LBL.forEach(([la, lo, , side], i) => { const c = ll(la, lo), east = ll(la, lo + 0.5).sub(c).normalize(), north = ll(la + 0.5, lo).sub(c).normalize(), w = wpx[i] / 34 * HU, u0 = ((i % 2) * 512 + 2) / 1024, u1 = u0 + wpx[i] / 1024, v1 = 1 - (Math.floor(i / 2) * RH + 4) / 512, v0 = v1 - 34 / 512, x0 = side > 0 ? 0.11 : -0.11 - w;
for (let j = 0; j <= NSEG; j++) { const f = j / NSEG, p = c.clone().multiplyScalar(R).addScaledVector(east, x0 + w * f).normalize().multiplyScalar(R * 1.017); [-1, 1].forEach((sg) => { lp.push(p.x + north.x * sg * HU / 2, p.y + north.y * sg * HU / 2, p.z + north.z * sg * HU / 2); lu.push(K.lerp(u0, u1, f), sg < 0 ? v0 : v1); }); if (j < NSEG) { const a = vb + j * 2; li.push(a, a + 2, a + 1, a + 1, a + 2, a + 3); } }
vb += (NSEG + 1) * 2; });
const lg = new T.BufferGeometry(); lg.setAttribute('position', new T.Float32BufferAttribute(lp, 3)); lg.setAttribute('uv', new T.Float32BufferAttribute(lu, 2)); lg.setIndex(li);
const lm = new T.Mesh(lg, new T.MeshBasicMaterial({ map: lt, transparent: true, depthWrite: false, side: T.DoubleSide })); lm.renderOrder = 2; spin.add(lm); }
/* e-mail on its way: envelopes riding the lines that are already up */
const envT = K.tex(96, 64, (g) => { g.fillStyle = '#f6f2e6'; g.fillRect(2, 2, 92, 60); g.strokeStyle = '#2c3138'; g.lineWidth = 3; g.strokeRect(2.5, 2.5, 91, 59); g.beginPath(); g.moveTo(3, 3); g.lineTo(48, 37); g.lineTo(93, 3); g.stroke(); g.fillStyle = '#b8322c'; g.fillRect(72, 40, 14, 15); g.fillStyle = '#2c3138'; g.fillRect(12, 44, 34, 3); g.fillRect(12, 51, 24, 3); });
const NEV = ARCS.length, envs = new T.InstancedMesh(new T.PlaneGeometry(0.3, 0.2), new T.MeshBasicMaterial({ map: envT, side: T.DoubleSide }), Math.max(1, NEV)), oe = new T.Object3D(), ev = new T.Vector3(); envs.frustumCulled = false; scene.add(envs);
/* ---- browser windows ---- */
const TIMES = '"Times New Roman", Times, serif', SYS = 'Tahoma, Verdana, "Segoe UI", sans-serif';
/* nine pages of the kind the first webs were made of. sb: the height of the scrollbar thumb, for pages longer than the window */
const PAGES = [
{ t: 'Welcome to Brennan Hardware', u: 'http://www.brennan-hardware.example/', d(g) { h1(g, 'Welcome to our Home Page!'); hr(g, 92); link(g, 'Product catalogue (new!)', 132); vlink(g, 'Price list, updated 3 March 1995', 166); link(g, 'How to find our shop', 200); link(g, 'Send us e-mail', 234); hr(g, 254); g.fillStyle = '#000'; g.font = '18px ' + TIMES; g.fillText('You are visitor number', 24, 296); counter(g, '0004217', 212, 276); g.font = 'italic 15px ' + TIMES; g.fillText('This page was last changed on 3 March 1995.', 24, 326); } },
{ t: 'Order Form', u: 'http://www.northgate-seeds.example/order.html', d(g) { h1(g, 'Order Form'); hr(g, 104); field(g, 'Your name:', 138); field(g, 'Address:', 184); field(g, 'Catalogue no.:', 230); field(g, 'Quantity:', 276); button(g, 'Submit Order', 160, 326); button(g, 'Clear', 316, 326); } },
{ t: 'Search the Web', u: 'http://www.findit.example/search', sb: 96, d(g) { h1(g, 'Search the Web'); g.fillStyle = '#fff'; g.fillRect(24, 100, 400, 32); bev(g, 24, 100, 400, 32, true); g.fillStyle = '#000'; g.font = '18px ' + TIMES; g.fillText('timetables paris lyon', 32, 122); button(g, 'Search', 436, 100); ['1. SNCF timetables (unofficial)', '2. Lyon city guide for visitors', '3. European rail FAQ, version 2.1', '4. Train spotting in France'].forEach((s, i) => { (i === 1 ? vlink : link)(g, s, 176 + i * 50); g.fillStyle = '#333'; g.font = '15px ' + TIMES; g.fillText('http://www.example/' + ['rail', 'lyon', 'faq', 'spot'][i] + '.html 4K', 24, 198 + i * 50); }); } },
{ t: 'Price List', u: 'http://www.brennan-hardware.example/prices.html', sb: 150, d(g) { h1(g, 'Price List'); const rows = [['Item', 'Code', 'Price'], ['Claw hammer 16 oz', 'H-116', '$ 8.95'], ['Wood screws, box 100', 'S-204', '$ 3.20'], ['Paint brush 2 in', 'B-020', '$ 2.75'], ['Hand saw 22 in', 'W-220', '$ 14.50'], ['Tape measure 5 m', 'T-005', '$ 6.10']]; rows.forEach((r, i) => { const y = 108 + i * 38; g.fillStyle = i ? '#fff' : '#d8d8d8'; g.fillRect(24, y, 560, 36); g.strokeStyle = '#555'; g.lineWidth = 1; g.strokeRect(24.5, y + 0.5, 560, 36); g.fillStyle = '#000'; g.font = (i ? '' : 'bold ') + '18px ' + TIMES; g.fillText(r[0], 34, y + 24); g.fillText(r[1], 320, y + 24); g.fillText(r[2], 470, y + 24); }); } },
{ t: 'Under Construction', u: 'http://www.members.example/~pascal/', d(g) { h1(g, "Pascal's Page"); for (let i = 0; i < 16; i++) { g.fillStyle = i % 2 ? '#111' : '#ffd400'; g.save(); g.beginPath(); g.rect(24, 104, 560, 40); g.clip(); g.beginPath(); g.moveTo(24 + i * 40, 144); g.lineTo(64 + i * 40, 144); g.lineTo(104 + i * 40, 104); g.lineTo(64 + i * 40, 104); g.fill(); g.restore(); } g.fillStyle = '#000'; g.font = 'bold 22px ' + TIMES; g.fillText('This page is under construction.', 24, 186); vlink(g, 'My favourite links', 230); link(g, 'Photos of my cat', 266); link(g, 'Sign my guestbook', 302); g.fillStyle = '#000'; g.font = 'italic 16px ' + TIMES; g.fillText('Best viewed at 640 x 480.', 24, 332); } },
{ t: 'Flight Times', u: 'http://www.aerolinea-sur.example/times.html', sb: 120, d(g) { h1(g, 'Flight Times'); [['BUENOS AIRES', 'MADRID', '21:40'], ['MADRID', 'PARIS', '08:15'], ['PARIS', 'NEW YORK', '11:05'], ['NEW YORK', 'TOKYO', '13:30'], ['TOKYO', 'SYDNEY', '19:55']].forEach((r, i) => { const y = 112 + i * 44; g.fillStyle = '#000'; g.font = '18px "Courier New", monospace'; g.fillText(r[0].padEnd(14) + r[1].padEnd(10) + r[2], 28, y + 20); hr(g, y + 34); }); link(g, 'Book by telephone', 352); } },
{ t: 'Index of /pub/docs', u: 'ftp://ftp.uni-nord.example/pub/docs/', sb: 84, d(g) { h1(g, 'Index of /pub/docs'); hr(g, 90); g.font = 'bold 15px "Courier New", monospace'; g.fillStyle = '#000'; g.fillText('Name' + ' '.repeat(22) + 'Last modified' + ' '.repeat(6) + 'Size', 52, 116); hr(g, 124);
[['Parent Directory', '', '', 1], ['rfc/', '12-Jan-95 09:14', '-', 1], ['README', '03-Mar-95 17:02', '2K', 0], ['html-primer.ps', '21-Feb-95 11:40', '148K', 0], ['httpd_1.3.tar.Z', '09-Feb-95 08:55', '412K', 0], ['net-guide.txt', '30-Nov-94 16:21', '64K', 0], ['www-faq.txt', '27-Mar-95 10:03', '48K', 0]].forEach(([n, dt, sz, dir], i) => { const y = 150 + i * 27; if (dir) { g.fillStyle = '#e8b93a'; g.fillRect(26, y - 12, 18, 13); g.fillRect(26, y - 15, 8, 4); g.strokeStyle = '#6b5210'; g.lineWidth = 1; g.strokeRect(26.5, y - 11.5, 17, 12); } else { g.fillStyle = '#fff'; g.fillRect(28, y - 15, 13, 17); g.strokeStyle = '#333'; g.lineWidth = 1; g.strokeRect(28.5, y - 14.5, 12, 16); g.fillStyle = '#333'; g.fillRect(31, y - 10, 7, 1); g.fillRect(31, y - 7, 7, 1); g.fillRect(31, y - 4, 5, 1); }
g.font = '16px "Courier New", monospace'; g.fillStyle = i === 2 || i === 6 ? '#551a8b' : '#0000ee'; g.fillText(n, 52, y); g.fillRect(52, y + 3, g.measureText(n).width, 1.3); g.fillStyle = '#000'; g.fillText(dt, 286, y); g.fillText(sz.padStart(5), 476, y); }); } },
{ t: 'Guestbook', u: 'http://www.members.example/~pascal/guest.html', sb: 70, d(g) { h1(g, 'Sign my Guestbook!'); hr(g, 90);
[['Ingrid, Uppsala', '2 April 1995', 'Nice page! Greetings from Sweden.'], ['Kenji', '29 March 1995', 'Found you from the What\'s New list.'], ['Tante Odile', '26 March 1995', 'Pascal, téléphone à ta mère.']].forEach(([n, dt, msg], i) => { const y = 122 + i * 62; g.fillStyle = '#000'; g.font = 'bold 18px ' + TIMES; g.fillText(n, 24, y); g.font = 'italic 15px ' + TIMES; g.fillStyle = '#444'; g.fillText(dt, 24 + 190, y); g.fillStyle = '#000'; g.font = '18px ' + TIMES; g.fillText(msg, 24, y + 24); hr(g, y + 38); });
g.fillStyle = '#000'; g.font = '18px ' + TIMES; g.fillText('Your message:', 24, 326); g.fillStyle = '#fff'; g.fillRect(150, 304, 300, 30); bev(g, 150, 304, 300, 30, true); button(g, 'Sign', 462, 303); } },
{ t: "What's New", u: 'http://www.findit.example/whatsnew.html', sb: 60, d(g) { h1(g, "What's New, April 1995"); const bars = ['#e02020', '#f08a00', '#f2d400', '#2aa02a', '#2060d0', '#7a2ac0']; bars.forEach((c, i) => { g.fillStyle = c; g.fillRect(24, 88 + i * 2, 560, 2); });
[['12 Apr', 'A museum puts forty paintings on line', 1], ['10 Apr', 'Weather maps, redrawn every hour', 1], ['7 Apr', 'Order a pizza by filling in a form', 0], ['3 Apr', 'City bus timetables for Lyon', 0], ['30 Mar', 'A coffee pot you can watch from anywhere', 0]].forEach(([dt, s, nw], i) => { const y = 136 + i * 38; g.fillStyle = '#000'; g.font = '16px "Courier New", monospace'; g.fillText(dt, 24, y); g.font = '20px ' + TIMES; g.fillStyle = i > 2 ? '#551a8b' : '#0000ee'; g.fillText(s, 100, y); const tw = g.measureText(s).width; g.fillRect(100, y + 4, tw, 1.5); if (nw) { g.fillStyle = '#ffe600'; g.fillRect(108 + tw, y - 16, 44, 20); g.strokeStyle = '#c00'; g.lineWidth = 1; g.strokeRect(108.5 + tw, y - 15.5, 43, 19); g.fillStyle = '#c00'; g.font = 'bold 14px ' + SYS; g.fillText('NEW!', 113 + tw, y - 1); } });
g.fillStyle = '#000'; g.font = 'italic 15px ' + TIMES; g.fillText('Send additions to webmaster@findit.example', 24, 328); } }
];
function bev(g, x, y, w, h, inset) { g.lineWidth = 2; g.strokeStyle = inset ? '#555' : '#fff'; g.beginPath(); g.moveTo(x, y + h); g.lineTo(x, y); g.lineTo(x + w, y); g.stroke(); g.strokeStyle = inset ? '#fff' : '#555'; g.beginPath(); g.moveTo(x + w, y); g.lineTo(x + w, y + h); g.lineTo(x, y + h); g.stroke(); }
function h1(g, s) { g.fillStyle = '#000'; g.font = 'bold 38px ' + TIMES; g.fillText(s, 24, 70); }
function hr(g, y) { g.fillStyle = '#7b7b7b'; g.fillRect(24, y, 560, 2); g.fillStyle = '#fff'; g.fillRect(24, y + 2, 560, 2); }
function vlink(g, s, y) { g.fillStyle = '#551a8b'; g.font = '21px ' + TIMES; g.fillText(s, 44, y); g.fillRect(44, y + 4, g.measureText(s).width, 1.6); g.fillStyle = '#000'; g.beginPath(); g.arc(31, y - 7, 4, 0, 7); g.fill(); }
function sbar(g, CW, CH, th) { const x = CW - 18; g.fillStyle = '#d6d6d6'; g.fillRect(x, 0, 18, CH); g.fillStyle = '#f2f2f2'; for (let y = 0; y < CH; y += 2) for (let xx = (y / 2) % 2; xx < 18; xx += 2) g.fillRect(x + xx, y, 1, 1);
[[0, [9, 6, 4.5, 11.5, 13.5, 11.5]], [CH - 18, [9, 12, 4.5, 6.5, 13.5, 6.5]], [22, null]].forEach(([y, tri]) => { const hh = tri ? 18 : th; g.fillStyle = '#c0c0c0'; g.fillRect(x, y, 18, hh); bev(g, x + 1, y + 1, 16, hh - 2, false); if (tri) { g.fillStyle = '#000'; g.beginPath(); g.moveTo(x + tri[0], y + tri[1]); g.lineTo(x + tri[2], y + tri[3]); g.lineTo(x + tri[4], y + tri[5]); g.fill(); } }); }
function link(g, s, y) { g.fillStyle = '#0000ee'; g.font = '21px ' + TIMES; g.fillText(s, 44, y); g.fillRect(44, y + 4, g.measureText(s).width, 1.6); g.fillStyle = '#000'; g.beginPath(); g.arc(31, y - 7, 4, 0, 7); g.fill(); }
function field(g, s, y) { g.fillStyle = '#000'; g.font = '19px ' + TIMES; g.fillText(s, 24, y + 22); g.fillStyle = '#fff'; g.fillRect(160, y, 330, 32); bev(g, 160, y, 330, 32, true); }
function button(g, s, x, y) { g.font = '17px ' + SYS; const w = g.measureText(s).width + 36; g.fillStyle = '#c0c0c0'; g.fillRect(x, y, w, 32); bev(g, x, y, w, 32, false); g.fillStyle = '#000'; g.fillText(s, x + 18, y + 22); }
function counter(g, s, x, y) { s.split('').forEach((ch, i) => { g.fillStyle = '#000'; g.fillRect(x + i * 24, y, 22, 28); g.fillStyle = '#39ff5a'; g.font = 'bold 22px "Courier New", monospace'; g.fillText(ch, x + i * 24 + 4, y + 22); }); }
function winTex(pg, w = 640, h = 500, live = true) { return K.tex(w, h, (g) => {
g.fillStyle = '#c0c0c0'; g.fillRect(0, 0, w, h); bev(g, 1, 1, w - 2, h - 2, false);
g.fillStyle = '#000080'; g.fillRect(5, 5, w - 10, 28); g.fillStyle = '#fff'; g.font = 'bold 16px ' + SYS; g.fillText(pg.t + ' - Navigator', 14, 25);
for (let i = 0; i < 3; i++) { const x = w - 30 - i * 26; g.fillStyle = '#c0c0c0'; g.fillRect(x, 8, 22, 22); bev(g, x, 8, 22, 22, false); g.fillStyle = '#000'; g.font = 'bold 14px ' + SYS; g.fillText(['x', '□', '_'][i], x + 6, 24); }
g.fillStyle = '#000'; g.font = '15px ' + SYS; ['File', 'Edit', 'View', 'Go', 'Bookmarks', 'Options', 'Help'].reduce((x, s) => { g.fillText(s, x, 54); return x + g.measureText(s).width + 18; }, 12);
['Back', 'Forward', 'Home', 'Reload', 'Open', 'Print', 'Find', 'Stop'].forEach((s, i) => { const x = 8 + i * 62; g.fillStyle = '#c0c0c0'; g.fillRect(x, 64, 58, 30); bev(g, x, 64, 58, 30, false); g.fillStyle = i === 7 ? '#a00' : '#000'; g.font = '13px ' + SYS; g.fillText(s, x + 8, 84); });
g.fillStyle = '#000'; g.font = '14px ' + SYS; g.fillText('Location:', 10, 118); g.fillStyle = '#fff'; g.fillRect(78, 102, w - 130, 24); bev(g, 78, 102, w - 130, 24, true); g.fillStyle = '#000'; g.fillText(pg.u, 84, 119);
g.fillStyle = '#000080'; g.fillRect(w - 44, 64, 36, 62); g.fillStyle = '#fff'; g.font = 'bold 26px ' + TIMES; g.fillText('N', w - 36, 106);
g.save(); g.translate(8, 134); g.beginPath(); g.rect(0, 0, w - 16, h - 164); g.clip(); g.fillStyle = '#c0c0c0'; g.fillRect(0, 0, w - 16, h - 164); pg.d(g); if (pg.sb) sbar(g, w - 16, h - 164, pg.sb); g.restore(); bev(g, 8, 134, w - 16, h - 164, true);
g.fillStyle = '#000'; g.font = '13px ' + SYS; g.fillText('Document: Done', 12, h - 10);
/* kept out of sight beside the menus: the status line a busy window borrows (see pageMat) */
if (live) g.fillText('Transferring data… 14K read', 376, 54);
}); }
/* a page that is still arriving: the shader holds back everything below the load line, swaps the status line, fills the progress bar and runs the throbber */
const pageMat = (tex) => { const m = K.std('#ffffff', 0.5, 0, { map: tex, envMapIntensity: 0.5 }), u = { uLoad: { value: 1 }, uTm: { value: 0 } }; m.userData.u = u;
m.onBeforeCompile = (sh) => { sh.uniforms.uLoad = u.uLoad; sh.uniforms.uTm = u.uTm;
sh.fragmentShader = 'uniform float uLoad; uniform float uTm;\n' + sh.fragmentShader.replace('#include <map_fragment>', `
vec2 wp = vec2(vMapUv.x * 640.0, (1.0 - vMapUv.y) * 500.0); vec4 wt = texture2D(map, vMapUv); vec3 ws = texture2D(map, vec2((wp.x + 364.0) / 640.0, 1.0 - (wp.y - 437.0) / 500.0)).rgb, wg = vec3(0.527);
wt.rgb = mix(wt.rgb, wg, step(370.0, wp.x) * step(wp.x, 592.0) * step(38.0, wp.y) * step(wp.y, 61.0));
float busy = 1.0 - step(1.0, uLoad);
wt.rgb = mix(wt.rgb, wg, busy * step(10.0, wp.x) * step(wp.x, 630.0) * step(136.0 + uLoad * 334.0, wp.y) * step(wp.y, 468.0));
wt.rgb = mix(wt.rgb, ws, busy * step(8.0, wp.x) * step(wp.x, 226.0) * step(476.0, wp.y) * step(wp.y, 496.0));
float pbx = (wp.x - 458.0) / 168.0, inPb = step(456.0, wp.x) * step(wp.x, 628.0) * step(479.0, wp.y) * step(wp.y, 495.0), blk = step(0.0, pbx) * step(pbx, uLoad) * step(0.2, fract(pbx * 14.0)) * step(482.0, wp.y) * step(wp.y, 492.0);
wt.rgb = mix(wt.rgb, mix(vec3(0.39), vec3(0.0, 0.0, 0.216), blk), busy * inPb);
float sw = fract((wp.x - wp.y) / 30.0 + uTm * 1.7); wt.rgb += busy * step(597.0, wp.x) * step(wp.x, 631.0) * step(65.0, wp.y) * step(wp.y, 125.0) * smoothstep(0.0, 0.06, sw) * smoothstep(0.22, 0.06, sw) * vec3(0.45, 0.55, 0.85);
diffuseColor *= wt;`); }; return m; };
const WW = 3.5, WH = WW * 500 / 640, winG = K.rbox(WW, WH, 0.09, 0.03, 2), chrome = K.std('#b9b9b9', 0.6), wins = [];
let hitTex = null;
PAGES.forEach((pg, i) => {
const g = new T.Group(), tx = winTex(pg), pm = pageMat(tx); if (!i) hitTex = tx; K.mesh(winG, chrome, { to: g }); K.mesh(new T.PlaneGeometry(WW - 0.04, WH - 0.04), pm, { p: [0, 0, 0.047], to: g, cast: false });
g.traverse((o) => o.layers.enable(2)); scene.add(g);
wins.push({ g, u: pm.userData.u, a: (i / 9) * Math.PI * 2 + (i % 2) * 0.3, y: [-2.6, 1.9, -0.6, 2.8, -1.9, 0.5, 2.2, -3.0, 1.0][i], rx: 5.0 + (i % 3) * 0.5, rz: 7.6 + (i % 4) * 0.55, sp: 0.085 + (i % 3) * 0.012 });
});
/* the exit window: a page that offers your business "in the browser" */
const exitPage = winTex({ t: 'Your business, in your browser', u: 'http://www.rent-the-software.example/', d(g) { h1(g, 'Why install software?'); g.fillStyle = '#000'; g.font = '21px ' + TIMES; g.fillText('Rent it. Run it in this window.', 24, 112); hr(g, 132); link(g, 'Start today', 176); } }, 640, 500, false);
const exitWin = new T.Group(); K.mesh(winG, chrome, { to: exitWin }); K.mesh(new T.PlaneGeometry(WW - 0.04, WH - 0.04), K.std('#ffffff', 0.5, 0, { map: exitPage }), { p: [0, 0, 0.047], to: exitWin, cast: false });
const PWd = (WW - 0.04) * (640 - 16) / 640, PHt = (WH - 0.04) * (500 - 164) / 500, pageY = (WH - 0.04) * (0.5 - (134 + (500 - 164) / 2) / 500);
const door = K.mesh(new T.PlaneGeometry(PWd, PHt), K.portalMat(U, K.col('#c0c0c0'), exitPage, [8 / 640, 30 / 500, 624 / 640, 336 / 500]), { p: [0, pageY, 0.052], to: exitWin, cast: false, receive: false }); door.visible = false; scene.add(exitWin);
const WEND = new T.Vector3(2.2, 5.6, 9.2);
/* the first web server, and its line up to the world */
const cube = new T.Group(); cube.position.set(6.6, 0, 4.0); cube.rotation.y = -0.5; scene.add(cube);
K.mesh(K.rbox(2.7, 2.7, 2.7, 0.07), K.std('#1b1b20', 0.42, 0.3), { p: [0, 1.36, 0], to: cube });
for (let i = 0; i < 9; i++) K.mesh(new T.BoxGeometry(2.72, 0.035, 0.02), K.std('#0c0c0f', 0.7), { p: [0, 0.35 + i * 0.25, 1.352], to: cube, cast: false });
K.mesh(new T.BoxGeometry(1.5, 0.07, 0.03), K.std('#060607', 0.7), { p: [0.3, 2.42, 1.356], to: cube, cast: false }); K.mesh(new T.PlaneGeometry(0.62, 0.3), K.std('#ffffff', 0.55, 0.1, { map: K.tex(256, 124, (g) => { g.fillStyle = '#e9e7df'; g.fillRect(0, 0, 256, 124); g.strokeStyle = '#8b8b84'; g.lineWidth = 3; g.strokeRect(3, 3, 250, 118); const R = K.rng(4); let x = 16; while (x < 240) { const w = 1 + Math.floor(R() * 4); g.fillStyle = '#16130f'; g.fillRect(x, 14, w, 54); x += w + 1 + Math.floor(R() * 3); } g.fillStyle = '#16130f'; g.font = '700 22px ' + K.MONO; g.fillText('ASSET 00417', 16, 92); g.font = '500 15px ' + K.MONO; g.fillText('ws-01 · bldg 31', 16, 112); }) }), { p: [-0.92, 2.42, 1.356], r: [0, 0, 0.04], to: cube, cast: false });
[[-1.1, 1.1], [1.1, 1.1], [-1.1, -1.1], [1.1, -1.1]].forEach(([x, z]) => K.mesh(new T.CylinderGeometry(0.14, 0.14, 0.05, 14), K.std('#0a0a0c', 0.8), { p: [x, 0.0, z], to: cube, cast: false })); K.blob(5.4, 5.4, { a: 0.34, to: cube });
const note = K.tex(512, 320, (g) => { g.fillStyle = '#ff5fcd'; g.fillRect(0, 0, 512, 320); g.fillStyle = 'rgba(0,0,0,0.06)'; g.fillRect(0, 0, 512, 22); g.fillStyle = '#16130f'; g.font = 'italic 700 46px ' + K.SERIF; g.fillText('This machine', 30, 96); g.fillText('is a server.', 30, 150); g.font = '800 50px ' + K.SERIF; g.fillText('DO NOT', 30, 226); g.fillText('POWER DOWN!!', 30, 284); });
K.mesh(new T.PlaneGeometry(1.45, 0.9), K.std('#ffffff', 0.8, 0, { map: note }), { p: [-0.3, 1.75, 1.365], r: [0, 0, -0.06], to: cube, cast: false });
{ const a = new T.Vector3(6.3, 2.72, 3.6), pts = [a, new T.Vector3(6.6, 4.4, 3.2), new T.Vector3(5.2, 4.2, 2.0), new T.Vector3(3.2, 2.6, 1.2), new T.Vector3(1.6, 1.9, 0.4), C.clone().add(new T.Vector3(0, -R * 0.99, 0))];
K.mesh(new T.TubeGeometry(new T.CatmullRomCurve3(pts), 90, 0.07, 10), K.std('#ff00b0', 0.4, 0, { emissive: K.col('#ff00b0'), emissiveIntensity: 0.35 }), { to: scene }); }
/* ---- the small hardware: what a server corner looked like in 1995 ---- */
const beige = K.std('#d8d0bd', 0.6), beigeD = K.std('#b9b09b', 0.7), charM = K.std('#25272c', 0.48, 0.2), rubber = K.std('#0e0f11', 0.85), paperM = K.std('#f4f1e8', 0.9);
const cable = (pts, r, mat, seg = 64) => K.mesh(new T.TubeGeometry(new T.CatmullRomCurve3(pts.map((p) => new T.Vector3(p[0], p[1], p[2])), false, 'catmullrom', 0.5), seg, r, 7), mat, { to: scene, cast: false });
const lamps = (n, to) => { const m = new T.InstancedMesh(new T.BoxGeometry(1, 1, 1), new T.MeshBasicMaterial({ toneMapped: false }), n); m.frustumCulled = false; to.add(m); return m; };
const slats = (n, to, w, d, x0, z0, dx, mat, y) => { const m = new T.InstancedMesh(new T.BoxGeometry(w, 0.012, d), mat, n); for (let i = 0; i < n; i++) { o3.position.set(x0 + i * dx, y, z0); o3.rotation.set(0, 0, 0); o3.scale.setScalar(1); o3.updateMatrix(); m.setMatrixAt(i, o3.matrix); } m.castShadow = false; to.add(m); return m; };
const RED1 = new T.Color(1.0, 0.1, 0.06), RED0 = new T.Color(0.13, 0.015, 0.012), GRN1 = new T.Color(0.2, 1.0, 0.36), GRN0 = new T.Color(0.02, 0.1, 0.04), AMB1 = new T.Color(1.0, 0.62, 0.1), AMB0 = new T.Color(0.12, 0.07, 0.01);
/* an eight-port hub on the server, and on the hub the modem that is the line out */
const hub = new T.Group(); hub.position.set(0.1, 2.712, 0.6); cube.add(hub);
K.mesh(K.rbox(2.4, 0.33, 1.45, 0.035, 2), beige, { p: [0, 0.19, 0], to: hub }); K.mesh(new T.BoxGeometry(2.404, 0.012, 1.454), beigeD, { p: [0, 0.2, 0], to: hub, cast: false });
[[-1.05, 0.55], [1.05, 0.55], [-1.05, -0.55], [1.05, -0.55]].forEach(([x, z]) => K.mesh(new T.CylinderGeometry(0.07, 0.07, 0.03, 12), rubber, { p: [x, 0.015, z], to: hub, cast: false }));
const HUBW = 2.2, hubT = K.tex(1024, 112, (g) => { g.fillStyle = '#b5ad98'; g.fillRect(0, 0, 1024, 112); g.strokeStyle = 'rgba(0,0,0,0.28)'; g.lineWidth = 3; g.strokeRect(1.5, 1.5, 1021, 109); g.fillStyle = 'rgba(255,255,255,0.25)'; g.fillRect(4, 106, 1016, 2); g.textBaseline = 'middle'; g.fillStyle = '#2b2d31'; g.font = '700 26px ' + K.SANS; g.fillText('Tarn EH-8', 28, 40); g.font = '500 15px ' + K.MONO; g.fillText('ETHERNET HUB · 10BASE-T', 28, 78);
g.textAlign = 'center'; for (let i = 0; i < 8; i++) { const x = 400 + i * 56; g.fillStyle = '#2b2d31'; g.font = '600 16px ' + K.MONO; g.fillText(String(i + 1), x, 28); g.fillStyle = '#16171a'; g.fillRect(x - 14, 46, 28, 18); } g.fillStyle = '#2b2d31'; g.font = '500 14px ' + K.MONO; g.fillText('LINK / ACT', 400 + 3.5 * 56, 90); ['PWR', 'COL'].forEach((t2, i) => { const x = 884 + i * 70; g.fillStyle = '#2b2d31'; g.font = '600 16px ' + K.MONO; g.fillText(t2, x, 28); g.fillStyle = '#16171a'; g.fillRect(x - 14, 46, 28, 18); }); });
K.mesh(new T.PlaneGeometry(HUBW, 0.24), K.std('#ffffff', 0.6, 0, { map: hubT }), { p: [0, 0.19, 0.7262], to: hub, cast: false });
const hubL = lamps(10, hub), HUBX = [...Array(8)].map((_, i) => (400 + i * 56 - 512) * HUBW / 1024).concat([(884 - 512) * HUBW / 1024, (954 - 512) * HUBW / 1024]);
slats(13, hub, 0.03, 0.62, 0.2, -0.2, 0.075, beigeD, 0.357);
const modem = new T.Group(); modem.position.set(-0.14, 0.356, 0.03); modem.rotation.y = 0.07; hub.add(modem);
K.mesh(K.rbox(2.05, 0.3, 1.32, 0.07, 3), charM, { p: [0, 0.165, 0], to: modem }); K.mesh(K.rbox(1.9, 0.02, 0.5, 0.008, 1), K.std('#1b1c20', 0.6, 0.1), { p: [0, 0.318, -0.3], to: modem, cast: false });
[[-0.9, 0.5], [0.9, 0.5], [-0.9, -0.5], [0.9, -0.5]].forEach(([x, z]) => K.mesh(new T.CylinderGeometry(0.06, 0.06, 0.03, 12), rubber, { p: [x, 0.012, z], to: modem, cast: false }));
slats(16, modem, 0.035, 0.36, -0.68, -0.3, 0.09, K.std('#101114', 0.7), 0.329);
const MODW = 1.8, modT = K.tex(1024, 90, (g) => { g.fillStyle = '#0b0b0d'; g.fillRect(0, 0, 1024, 90); const gr = g.createLinearGradient(0, 0, 0, 90); gr.addColorStop(0, 'rgba(255,255,255,0.16)'); gr.addColorStop(0.45, 'rgba(255,255,255,0)'); g.fillStyle = gr; g.fillRect(0, 0, 1024, 90); g.textAlign = 'center'; g.textBaseline = 'middle';
['HS', 'AA', 'CD', 'OH', 'RD', 'SD', 'TR', 'MR'].forEach((t2, i) => { const x = 90 + i * 72; g.fillStyle = '#dcdcdc'; g.font = '700 20px ' + K.SANS; g.fillText(t2, x, 24); g.fillStyle = '#240505'; g.fillRect(x - 15, 46, 30, 22); }); g.textAlign = 'right'; g.fillStyle = '#dcdcdc'; g.font = '700 27px ' + K.SANS; g.fillText('Halden 14.4', 996, 34); g.font = '500 15px ' + K.MONO; g.fillStyle = '#9a9a9a'; g.fillText('DATA · FAX MODEM', 996, 66); });
K.mesh(new T.PlaneGeometry(MODW, 0.158), K.std('#ffffff', 0.22, 0.2, { map: modT, envMapIntensity: 1.1 }), { p: [0, 0.165, 0.6612], to: modem, cast: false });
const modL = lamps(8, modem), MODX = [...Array(8)].map((_, i) => (90 + i * 72 - 512) * MODW / 1024);
K.mesh(K.rbox(0.05, 0.1, 0.16, 0.015, 1), K.std('#3a3c42', 0.5), { p: [1.03, 0.16, 0.2], to: modem, cast: false });
const ups = new T.Group(); ups.position.set(-1.75, 0, 1.3); ups.rotation.y = -0.34; scene.add(ups);
/* three sticky notes, each with a corner coming away: two on the server's front, one on the UPS */
[['login: www', 'pw: geneva93', 0.94, 2.02, 0.07], ['ISDN line', 'Mon 9:00 !', 1.0, 1.3, -0.08], ['battery', 'new 02/95', 0, 0, 0.06]].forEach(([l1, l2, x, y, rz], i) => { const g = new T.PlaneGeometry(0.58, 0.58, 1, 6), p = g.attributes.position; for (let j = 0; j < p.count; j++) { const v = 0.5 - p.getY(j) / 0.58; p.setZ(j, v * v * 0.07); } g.computeVertexNormals();
K.mesh(g, K.std('#ffffff', 0.85, 0, { side: T.DoubleSide, map: K.tex(192, 192, (c) => { c.fillStyle = '#f7e36a'; c.fillRect(0, 0, 192, 192); c.fillStyle = 'rgba(0,0,0,0.05)'; c.fillRect(0, 0, 192, 26); c.fillStyle = '#1b2a6b'; c.font = 'italic 600 30px ' + K.SERIF; c.fillText(l1, 14, 84); c.fillText(l2, 14, 128); }) }), i < 2 ? { p: [x, y, 1.362], r: [0, 0, rz], to: cube, cast: false } : { p: [0.22, 1.42, 1.458], r: [0, 0, rz], s: 0.72, to: ups, cast: false }); });
K.mesh(new T.BoxGeometry(0.07, 0.04, 0.012), new T.MeshBasicMaterial({ color: GRN1.clone().multiplyScalar(0.85), toneMapped: false }), { p: [1.08, 0.2, 1.357], to: cube, cast: false, receive: false });
const cubeL = lamps(1, cube);
/* the wires: patch leads from the back of the hub over the edge of the server, the telephone line, the mains */
cube.updateMatrixWorld(true); const cw = (x, y, z) => cube.localToWorld(new T.Vector3(x, y, z)).toArray();
[['#9aa0a6', -0.5, [2.9, 0.9, 3.6]], ['#2d5fb0', -0.2, [4.4, 0.05, 6.6]], ['#d8b21c', 0.45, [9.6, 0.05, 1.9]]].forEach(([c, px, end], i) => cable([cw(0.1 + px, 2.92, -0.1), cw(0.1 + px, 2.9, -0.5), cw(0.15 + px * 1.3, 2.76, -1.2), cw(0.2 + px * 1.5, 2.3, -1.46), cw(0.2 + px * 1.6, 0.4, -1.5), cw(0.3 + px * 2, 0.05, -1.9), [K.lerp(cw(0.3, 0, -1.9)[0], end[0], 0.6), 0.05, K.lerp(cw(0.3, 0, -1.9)[2], end[2], 0.55) + (i - 1) * 0.3], end], 0.034, K.std(c, 0.6)));
const cream = K.std('#e3dcc8', 0.7), blackC = K.std('#141518', 0.6);
cable([cw(-0.75, 3.2, 0.0), cw(-0.8, 3.16, -0.5), cw(-0.9, 2.76, -1.25), cw(-0.95, 2.2, -1.45), cw(-1.0, 0.3, -1.5), cw(-1.3, 0.03, -1.8), [3.6, 0.03, 1.0], [1.4, 0.03, 0.7], [-0.6, 0.03, 0.5], [-2.4, 0.03, 0.9], [-3.3, 0.03, 1.5], [-3.0, 0.03, 1.95], [-3.4, 0.03, 2.1], [-3.05, 0.1, 2.25]], 0.02, cream, 120);
{ const j = new T.Group(); j.position.set(-2.9, 0, 2.36); j.rotation.y = 0.5; scene.add(j); K.mesh(K.rbox(0.5, 0.2, 0.42, 0.03, 2), beige, { p: [0, 0.1, 0], to: j }); K.mesh(new T.BoxGeometry(0.16, 0.1, 0.02), rubber, { p: [-0.1, 0.1, 0.212], to: j, cast: false }); K.mesh(new T.CylinderGeometry(0.022, 0.022, 0.012, 10), K.std('#8f8a7a', 0.4, 0.6), { p: [0.14, 0.201, 0], to: j, cast: false }); }
/* a UPS on the floor behind, with the week's discs left on top of it */
K.mesh(K.rbox(1.15, 1.74, 2.9, 0.06, 2), beige, { p: [0, 0.9, 0], to: ups }); [[-0.42, 1.2], [0.42, 1.2], [-0.42, -1.2], [0.42, -1.2]].forEach(([x, z]) => K.mesh(new T.CylinderGeometry(0.09, 0.09, 0.04, 12), rubber, { p: [x, 0.02, z], to: ups, cast: false }));
const upsT = K.tex(512, 768, (g) => { const R = K.rng(17); g.fillStyle = '#d6cebb'; g.fillRect(0, 0, 512, 768); g.fillStyle = '#c4bca8'; g.fillRect(36, 40, 440, 300); g.strokeStyle = 'rgba(0,0,0,0.24)'; g.lineWidth = 3; g.strokeRect(36.5, 40.5, 440, 300); g.fillStyle = 'rgba(255,255,255,0.3)'; g.fillRect(38, 338, 438, 2);
g.textBaseline = 'middle'; g.fillStyle = '#2b2d31'; g.font = '700 40px ' + K.SANS; g.fillText('Norvolt 600', 62, 92); g.font = '500 18px ' + K.MONO; g.fillText('UNINTERRUPTIBLE POWER SUPPLY', 62, 134);
['ON LINE', 'ON BATTERY', 'OVERLOAD', 'REPLACE BATTERY'].forEach((t2, i) => { const y = 190 + i * 36; g.fillStyle = '#17181b'; g.fillRect(64, y - 10, 32, 20); g.fillStyle = '#2b2d31'; g.font = '600 17px ' + K.MONO; g.fillText(t2, 112, y); });
g.beginPath(); g.arc(404, 244, 46, 0, 7); g.fillStyle = '#b1a995'; g.fill(); g.strokeStyle = 'rgba(0,0,0,0.3)'; g.stroke(); g.textAlign = 'center'; g.fillStyle = '#2b2d31'; g.font = '600 15px ' + K.MONO; g.fillText('TEST / ON', 404, 312); g.textAlign = 'left';
for (let i = 0; i < 14; i++) { g.fillStyle = '#35342f'; g.fillRect(56, 400 + i * 24, 400, 11); g.fillStyle = 'rgba(255,255,255,0.28)'; g.fillRect(56, 412 + i * 24, 400, 2); }
for (let i = 0; i < 70; i++) { g.strokeStyle = R() < 0.5 ? 'rgba(60,50,30,0.10)' : 'rgba(255,255,255,0.14)'; g.lineWidth = 1 + R() * 1.5; const x = R() * 512, y = R() * 768; g.beginPath(); g.moveTo(x, y); g.lineTo(x + (R() - 0.5) * 60, y + (R() - 0.5) * 16); g.stroke(); } });
K.mesh(new T.PlaneGeometry(1.03, 1.545), K.std('#ffffff', 0.62, 0, { map: upsT }), { p: [0, 0.9, 1.4512], to: ups, cast: false });
K.mesh(new T.CylinderGeometry(0.078, 0.078, 0.04, 20), K.std('#8c8674', 0.5), { p: [(404 - 256) / 512 * 1.03, 0.9 + (384 - 244) / 768 * 1.545, 1.47], r: [Math.PI / 2, 0, 0], to: ups, cast: false });
const upsL = lamps(4, ups);
{ const sv = new T.InstancedMesh(new T.BoxGeometry(0.012, 0.03, 1.5), K.std('#35342f', 0.7), 12); for (let i = 0; i < 12; i++) { o3.position.set(-0.578, 0.5 + i * 0.075, 0.2); o3.rotation.set(0, 0, 0); o3.scale.setScalar(1); o3.updateMatrix(); sv.setMatrixAt(i, o3.matrix); } sv.castShadow = false; ups.add(sv); }
const discT = K.tex(256, 256, (g) => { g.clearRect(0, 0, 256, 256); g.beginPath(); g.arc(128, 128, 126, 0, 7); if (g.createConicGradient) { const cg = g.createConicGradient(0.7, 128, 128); ['#d9dde2', '#f3cfe2', '#c9e3f5', '#f1eec2', '#dfe3e8', '#c8ecd4', '#e3d1f2', '#f6f8fa', '#d9dde2'].forEach((c, i, a) => cg.addColorStop(i / (a.length - 1), c)); g.fillStyle = cg; } else g.fillStyle = '#d9dde2'; g.fill(); for (let r = 44; r < 124; r += 3) { g.strokeStyle = 'rgba(255,255,255,0.10)'; g.lineWidth = 1; g.beginPath(); g.arc(128, 128, r, 0, 7); g.stroke(); } g.fillStyle = 'rgba(236,239,243,1)'; g.beginPath(); g.arc(128, 128, 42, 0, 7); g.fill(); g.strokeStyle = 'rgba(20,20,20,0.3)'; g.lineWidth = 2; g.beginPath(); g.arc(128, 128, 42, 0, 7); g.stroke(); g.beginPath(); g.arc(128, 128, 125, 0, 7); g.stroke(); });
const discM = K.std('#ffffff', 0.2, 0.75, { map: discT, envMapIntensity: 1.3, side: T.DoubleSide }), sleeveT = K.tex(256, 256, (g) => { g.fillStyle = '#f4f1e8'; g.fillRect(0, 0, 256, 256); g.strokeStyle = 'rgba(0,0,0,0.18)'; g.lineWidth = 2; g.strokeRect(1, 1, 254, 254); g.beginPath(); g.moveTo(2, 40); g.lineTo(128, 70); g.lineTo(254, 40); g.stroke(); g.save(); g.beginPath(); g.arc(128, 142, 92, 0, 7); g.clip(); g.drawImage(discT.image, 22, 36, 212, 212); g.fillStyle = 'rgba(255,255,255,0.28)'; g.fillRect(0, 0, 256, 256); g.restore(); g.beginPath(); g.arc(128, 142, 92, 0, 7); g.stroke(); });
const sleeveM = K.std('#ffffff', 0.85, 0, { map: sleeveT }), sleeveG = K.rbox(1.16, 0.02, 1.16, 0.008, 1), sleeveTop = new T.PlaneGeometry(1.14, 1.14), SR = K.rng(23);
for (let i = 0; i < 7; i++) { const g = new T.Group(); g.position.set(0.02 + (SR() - 0.5) * 0.12, 1.782 + i * 0.024, -0.55 + (SR() - 0.5) * 0.1); g.rotation.y = (SR() - 0.5) * 0.5; ups.add(g); K.mesh(sleeveG, paperM, { to: g, cast: i === 6 }); if (i > 4) K.mesh(sleeveTop, sleeveM, { p: [0, 0.0105, 0], r: [-Math.PI / 2, 0, 0], to: g, cast: false }); }
K.mesh(new T.RingGeometry(0.075, 0.54, 48), discM, { p: [0.12, 1.955, -0.5], r: [-Math.PI / 2 + 0.06, 0, 0.5], to: ups, cast: false }); K.mesh(new T.RingGeometry(0.075, 0.54, 48), discM, { p: [-0.05, 1.79, 0.75], r: [-Math.PI / 2, 0, 1.9], to: ups, cast: false });
K.blob(2.6, 4.2, { a: 0.28, p: [0, 0, 0], to: ups });
/* the mains: a strip of five, three plugs in, leads tied together where they run side by side */
const strip = new T.Group(); strip.position.set(-2.75, 0, 3.15); strip.rotation.y = 0.95; scene.add(strip);
K.mesh(K.rbox(2.3, 0.2, 0.44, 0.04, 2), K.std('#dedbd0', 0.6), { p: [0, 0.1, 0], to: strip });
K.mesh(new T.PlaneGeometry(2.24, 0.4), K.std('#ffffff', 0.6, 0, { map: K.tex(560, 100, (g) => { g.fillStyle = '#e6e3d8'; g.fillRect(0, 0, 560, 100); for (let i = 0; i < 5; i++) { const x = 60 + i * 88; g.fillStyle = '#d7d3c8'; g.beginPath(); g.arc(x, 50, 34, 0, 7); g.fill(); g.strokeStyle = 'rgba(0,0,0,0.3)'; g.lineWidth = 2; g.stroke(); g.fillStyle = '#1a1a1a'; g.beginPath(); g.arc(x - 12, 50, 4.5, 0, 7); g.arc(x + 12, 50, 4.5, 0, 7); g.fill(); g.fillStyle = '#b9b5aa'; g.beginPath(); g.arc(x, 32, 4, 0, 7); g.fill(); } g.fillStyle = '#2a2a2a'; g.fillRect(488, 26, 54, 48); g.fillStyle = '#ff6a1a'; g.fillRect(493, 31, 44, 38); g.fillStyle = 'rgba(255,255,255,0.75)'; g.font = '700 18px ' + K.SANS; g.fillText('I', 502, 58); g.fillText('O', 520, 58); }) }), { p: [0, 0.2012, 0], r: [-Math.PI / 2, 0, 0], to: strip, cast: false });
[-0.88, -0.53, 0.0].forEach((x, i) => { const pm = i === 1 ? K.std('#dedbd0', 0.6) : blackC; K.mesh(new T.CylinderGeometry(0.115, 0.125, 0.1, 20), pm, { p: [x, 0.25, 0], to: strip }); K.mesh(new T.CylinderGeometry(0.085, 0.115, 0.09, 20), pm, { p: [x, 0.345, 0], to: strip, cast: false }); K.mesh(new T.CylinderGeometry(0.04, 0.055, 0.14, 10), pm, { p: [x, 0.36, 0.1], r: [1.1, 0, 0], to: strip, cast: false }); });
{ const sp = (x, y, z) => strip.localToWorld(new T.Vector3(x, y, z)).toArray(); strip.updateMatrixWorld(true);
cable([sp(-0.88, 0.36, 0.1), sp(-0.9, 0.3, 0.5), sp(-0.6, 0.04, 0.9), [-1.9, 0.04, 2.6], [-1.6, 0.04, 2.2], [-1.2, 0.2, 2.5], [-1.3, 0.4, 2.62]], 0.022, blackC, 60);
cable([sp(-0.53, 0.36, 0.1), sp(-0.5, 0.3, 0.55), sp(-0.2, 0.04, 1.0), [-1.2, 0.04, 3.4], [0.6, 0.04, 3.1], [2.6, 0.04, 2.6], [4.4, 0.04, 2.0], cw(-0.6, 0.04, -1.9), cw(-0.6, 0.5, -1.5)], 0.022, K.std('#dedbd0', 0.6), 90);
cable([sp(0.0, 0.36, 0.1), sp(0.05, 0.3, 0.6), sp(0.3, 0.04, 1.1), [-1.16, 0.04, 3.45], [0.6, 0.04, 3.15], [2.6, 0.04, 2.65], [4.4, 0.04, 2.05], cw(-0.3, 0.04, -1.9), cw(-0.3, 0.5, -1.5)], 0.022, blackC, 90);
cable([sp(1.15, 0.1, 0), sp(1.6, 0.05, 0.1), sp(2.4, 0.04, -0.3), sp(3.4, 0.04, 0.4), sp(4.6, 0.04, 0.1)], 0.03, K.std('#dedbd0', 0.6), 40);
[[-0.3, 3.275], [1.6, 2.875]].forEach(([x, z]) => K.mesh(new T.TorusGeometry(0.05, 0.01, 6, 14), blackC, { p: [x, 0.05, z], r: [0, Math.PI / 2 - 0.12, 0], to: scene, cast: false })); }
/* a mouse on its mat, lead trailing off to the machine it belongs to */
{ const m = new T.Group(); m.position.set(-1.25, 0, 3.75); m.rotation.y = 0.5; scene.add(m);
K.mesh(K.rbox(2.0, 0.04, 1.7, 0.02, 1), K.std('#ffffff', 0.92, 0, { map: K.tex(256, 216, (g) => { const R = K.rng(31); g.fillStyle = '#1e4f8c'; g.fillRect(0, 0, 256, 216); for (let i = 0; i < 2600; i++) { g.fillStyle = R() < 0.5 ? 'rgba(255,255,255,0.05)' : 'rgba(0,0,0,0.07)'; g.fillRect(R() * 256, R() * 216, 2, 2); } const gr = g.createRadialGradient(120, 104, 10, 120, 104, 80); gr.addColorStop(0, 'rgba(255,255,255,0.16)'); gr.addColorStop(1, 'rgba(255,255,255,0)'); g.fillStyle = gr; g.fillRect(0, 0, 256, 216); g.strokeStyle = 'rgba(255,255,255,0.22)'; g.lineWidth = 2; g.strokeRect(5, 5, 246, 206); }) }), { p: [0, 0.02, 0], to: m, cast: false });
const ms = new T.Group(); ms.position.set(0.15, 0.04, 0.05); ms.rotation.y = -0.4; m.add(ms); const mb = K.std('#cbc3af', 0.52), ml = K.std('#6d6758', 0.7); K.mesh(K.rbox(0.62, 0.2, 1.04, 0.09, 4), mb, { p: [0, 0.1, 0], to: ms }); K.mesh(K.rbox(0.6, 0.12, 0.56, 0.055, 3), mb, { p: [0, 0.2, 0.2], to: ms, cast: false }); [-0.152, 0.152].forEach((x) => K.mesh(K.rbox(0.286, 0.09, 0.42, 0.04, 3), K.std('#d6ceba', 0.5), { p: [x, 0.205, -0.28], to: ms, cast: false })); K.mesh(new T.BoxGeometry(0.014, 0.1, 0.44), ml, { p: [0, 0.19, -0.28], to: ms, cast: false }); K.mesh(new T.BoxGeometry(0.6, 0.1, 0.014), ml, { p: [0, 0.19, -0.075], to: ms, cast: false }); K.mesh(new T.BoxGeometry(0.624, 0.012, 1.044), ml, { p: [0, 0.075, 0], to: ms, cast: false });
m.updateMatrixWorld(true); const mp = (x, y, z) => ms.localToWorld(new T.Vector3(x, y, z)).toArray(); cable([mp(0, 0.13, -0.5), mp(0, 0.1, -0.75), mp(0.2, 0.05, -1.3), [-0.6, 0.04, 2.3], [0.3, 0.04, 2.0], [1.2, 0.2, 2.6]], 0.022, beigeD, 50); }
/* the hardware of the first web, as photographs: the NeXT that served it, an Indy, an iMac, a box of floppies */
const flats = [
K.flat('img/c/next', { h: 3.6, p: [1.6, 0, 4.4], ry: 0.1, face: 0.5, to: scene }),
K.flat('img/c/imac', { h: 3.6, p: [10.4, 0, 1.4], ry: -0.4, face: 0.5, to: scene }),
K.flat('img/c/indy', { h: 1.9, p: [3.6, 0, 7.4], ry: 0, face: 0.5, to: scene }),
K.flat('img/c/floppies', { h: 2.0, p: [8.6, 0, 7.2], ry: -0.2, face: 0.5, to: scene }),
K.flat('img/c/pcxt', { h: 3.8, p: [12.6, 0, 4.6], ry: -0.5, face: 0.5, to: scene })
];
/* pointers on the loose: the period arrow, flying from window to window */
const curT = K.tex(64, 96, (g) => { g.beginPath(); g.moveTo(6, 4); g.lineTo(6, 74); g.lineTo(22, 58); g.lineTo(34, 88); g.lineTo(46, 82); g.lineTo(34, 54); g.lineTo(56, 54); g.closePath(); g.fillStyle = '#fff'; g.fill(); g.strokeStyle = '#000'; g.lineWidth = 5; g.lineJoin = 'miter'; g.stroke(); });
const NCU = 9, curs = new T.InstancedMesh(new T.PlaneGeometry(0.4, 0.6), new T.MeshBasicMaterial({ map: curT, transparent: true, alphaTest: 0.4, side: T.DoubleSide }), NCU); curs.frustumCulled = false; scene.add(curs);
const wv = new T.Vector3(); let hitN = 4217;
const rail = K.rail([
{ k: -0.4, p: [-11, 9.6, 24], l: [1.2, 5.6, 0], f: 37 },
{ k: 0, p: [-9, 8.9, 22.5], l: [1.6, 5.0, 0], f: 36 },
{ k: 0.34, p: [-4, 7.2, 20], l: [1.8, 5.0, 0] },
{ k: 0.62, p: [3.6, 7.2, 19.5], l: [2.0, 5.2, 0] },
{ k: 0.85, p: [WEND.x + 0.3, WEND.y + 0.1, WEND.z + 5.2], l: [WEND.x, WEND.y + pageY, WEND.z], f: 34 },
{ k: 1, p: [WEND.x, WEND.y + pageY, WEND.z + 1.5], l: [WEND.x, WEND.y + pageY, WEND.z - 3], f: 30 }
]);
const dc = new T.Vector3(), dhx = new T.Vector3(PWd / 2, 0, 0), dhy = new T.Vector3(0, PHt / 2, 0), v = new T.Vector3();
return {
scene, camera, textDepth: 11.5, outStart: 0.44, irisAt: 0.3, shiftX: 0.17,
portal() { dc.set(WEND.x, WEND.y + pageY, WEND.z + 0.052); return { c: dc, hx: dhx, hy: dhy, round: 0.02 }; },
update(k, t, dt, P) {
const kk = K.clamp(k, -0.4, 1), k01 = K.clamp(k, 0, 1);
spin.rotation.y = 1.9 + t * 0.045 + k01 * 0.8 + P.x * 0.25;
arcM.uniforms.uK.value = K.clamp((k01 - 0.02) / 0.7) * 1.0; arcM.uniforms.uTime.value = t;
cloudM.uniforms.uT.value = t; clouds.rotation.y = t * 0.006; globe.updateMatrixWorld(true);
for (let i = 0; i < NEV; i++) { const A = ARCS[i], on = arcM.uniforms.uK.value > A.s0 + 0.14, u = (t * (0.1 + (i % 5) * 0.016) + i * 0.29) % 1, sn = Math.sin(A.ang);
ev.copy(A.a).multiplyScalar(Math.sin((1 - u) * A.ang) / sn).addScaledVector(A.b, Math.sin(u * A.ang) / sn).multiplyScalar(R * (1.03 + (0.05 + 0.3 * A.ang / Math.PI) * Math.sin(Math.PI * u))).applyMatrix4(spin.matrixWorld);
oe.position.copy(ev); oe.quaternion.copy(camera.quaternion); oe.scale.setScalar(on ? 0.7 + 0.3 * Math.sin(Math.PI * u) : 0.001); oe.updateMatrix(); envs.setMatrixAt(i, oe.matrix); } envs.instanceMatrix.needsUpdate = true;
/* each window fetches its page again every ten seconds or so, in bursts, as a 14.4 modem delivered it */
wins.forEach((w, i) => { const a = w.a + t * w.sp + k01 * 0.9, bob = Math.sin(t * 0.5 + i) * 0.25, ld = ((t + i * 3.7) % (9.5 + (i % 4) * 2.3)) / 2.9; w.u.uLoad.value = ld >= 1 ? 1 : Math.min(0.999, (Math.floor(ld * 7) + K.ease(K.clamp((ld * 7 % 1) * 2.4))) / 7); w.u.uTm.value = t;
w.g.position.set(C.x + Math.sin(a) * w.rx, C.y + w.y + bob, C.z + Math.cos(a) * w.rz * 0.92);
w.g.rotation.set(0, a + Math.sin(t * 0.3 + i * 2) * 0.12, Math.sin(t * 0.4 + i) * 0.04); const s = 0.62 + 0.38 * K.back(K.clamp((k01 - 0.03 - i * 0.035) / 0.16));
/* a window under the pointer swells and turns to face you */
wv.copy(w.g.position).project(camera); w.h = (w.h || 0) + (P.hot * K.smooth(0.3, 0.06, Math.hypot((wv.x - P.nx) * P.aspect, wv.y - P.ny)) - (w.h || 0)) * 0.12; w.g.rotation.y = K.lerp(w.g.rotation.y, Math.atan2(camera.position.x - w.g.position.x, camera.position.z - w.g.position.z), w.h); w.g.scale.setScalar((k < -0.39 ? 0.62 : s) * (1 + w.h * 0.35)); });
for (let i = 0; i < NCU; i++) { const A = wins[i % wins.length].g.position, B = wins[(i * 4 + 3) % wins.length].g.position, u = K.ease(((t * (0.1 + i * 0.013) + i * 0.37) % 1)); o3.position.lerpVectors(A, B, u); o3.position.y += Math.sin(u * Math.PI) * 1.6; o3.position.z += 1.2; o3.rotation.set(0, Math.atan2(camera.position.x - o3.position.x, camera.position.z - o3.position.z), -0.2); o3.scale.setScalar(k01 > 0.08 ? 1 : 0.001); o3.updateMatrix(); curs.setMatrixAt(i, o3.matrix); } curs.instanceMatrix.needsUpdate = true;
const e = K.ease(K.smooth(0.42, 0.8, k01)); v.set(C.x - 3.5, C.y - 1.5, C.z - 9).lerp(WEND, e); exitWin.position.copy(v); exitWin.position.y += Math.sin(e * Math.PI) * 2.2; exitWin.rotation.set(0, (1 - e) * 2.4, (1 - e) * 0.2); exitWin.visible = k01 > 0.4;
/* the lamps. The modem dials as the chapter opens (MR, then off hook, then carrier), after which RD and SD flicker with the traffic; the hub's ports blink as they talk */
{ const rnd = (i, f) => { const x = Math.sin((Math.floor(t * f) + i * 7.31) * 12.9898) * 43758.5453; return x - Math.floor(x); }, up = k01 > 0.07 || k < 0, st = [up, false, up, k01 > 0.03 || k < 0, up && rnd(1, 13) > 0.42, up && rnd(2, 11) > 0.55, true, true];
for (let i = 0; i < 8; i++) { o3.position.set(MODX[i], 0.165 - (57 - 45) * 0.158 / 90, 0.664); o3.rotation.set(0, 0, 0); o3.scale.set(0.05, 0.036, 0.008); o3.updateMatrix(); modL.setMatrixAt(i, o3.matrix); modL.setColorAt(i, st[i] ? RED1 : RED0); }
const link = [1, 1, 1, 0, 1, 0, 0, 1]; for (let i = 0; i < 10; i++) { o3.position.set(HUBX[i], 0.19 + (56 - 55) * 0.24 / 112, 0.729); o3.scale.set(0.056, 0.036, 0.008); o3.updateMatrix(); hubL.setMatrixAt(i, o3.matrix); hubL.setColorAt(i, i < 8 ? (link[i] && rnd(i + 3, 9 + i) > 0.22 ? GRN1 : GRN0) : i === 8 ? GRN1 : (rnd(9, 6) > 0.93 ? AMB1 : AMB0)); }
for (let i = 0; i < 4; i++) { o3.position.set((80 - 256) / 512 * 1.03, 0.9 + (384 - (190 + i * 36)) / 768 * 1.545, 1.4545); o3.scale.set(0.06, 0.038, 0.008); o3.updateMatrix(); upsL.setMatrixAt(i, o3.matrix); upsL.setColorAt(i, i === 0 ? GRN1 : i === 1 ? AMB0 : RED0); }
o3.position.set(0.96, 0.2, 1.358); o3.scale.set(0.07, 0.04, 0.012); o3.updateMatrix(); cubeL.setMatrixAt(0, o3.matrix); cubeL.setColorAt(0, rnd(5, 17) > 0.5 ? AMB1 : AMB0); o3.scale.setScalar(1);
[modL, hubL, upsL, cubeL].forEach((m) => { m.instanceMatrix.needsUpdate = true; m.instanceColor.needsUpdate = true; }); }
/* somebody is always arriving: the visitor counter ticks over */
{ const n = 4217 + Math.floor(t / 1.6); if (hitTex && n !== hitN) { hitN = n; const g = hitTex.image.getContext('2d'); g.save(); g.translate(8, 134); counter(g, String(n).padStart(7, '0'), 212, 276); g.restore(); hitTex.needsUpdate = true; } }
door.visible = P.kt > 0.001; door.material.uniforms.uMix.value = K.smooth(0.28, 0.7, P.kt);
K.aim(camera, rail(kk), P, 1 - K.smooth(0.66, 0.98, k01)); K.faceFlats(flats, camera);
}
};
});