Repository navigation
Expand file tree
/
Copy paths-pc.js
More file actions
284 lines (267 loc) · 47.9 KB
/
Copy paths-pc.js
File metadata and controls
284 lines (267 loc) · 47.9 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
/* Set 3 · 1981 · Personal computers.
A saffron studio, a walnut desk, one beige machine: system unit with two 5.25-inch drives, a green-phosphor monitor,
an 83-key keyboard on its coiled lead. The screen is live: it boots, runs a ledger in a spreadsheet, then dials out.
The exit is the screen. Units are 10 cm. */
H.def('pc', ({ renderer, H }) => {
const T = THREE, U = H.U, scene = new T.Scene(), BG = K.col('#ffb81f');
scene.background = BG; scene.fog = new T.Fog(BG.getHex(), 34, 90);
const camera = new T.PerspectiveCamera(36, 1, 0.05, 220);
scene.environment = K.env(renderer, { top: '#a39a86', bottom: '#4a3410', boxes: [{ p: [-12, 16, 12], s: [16, 12], i: 3.4 }, { p: [16, 8, 8], s: [8, 14], i: 1.3 }, { p: [2, 22, 0], s: [14, 14], i: 1.5 }] });
K.lights(scene, { pos: [-10, 18, 13], target: [0, 1, 0], key: 2.3, amb: 0.5, sky: '#fff6e0', ground: '#f0a520', extent: 16, far: 70, map: 2048 });
K.mesh(K.cove(220, 46, -11, 4.5, 60), K.std('#ffbb22', 0.96), { to: scene, cast: false });
/* photographs in the set: the 1984 festival crowd, and four machines of the decade on plinths, like a museum line */
const plinth = K.std('#fff3d6', 0.8), flats = [K.flat('img/c/festival', { h: 9.4, p: [11.4, 0, -8.4], face: 0.4, to: scene, gain: 1.1 })];
[['apple2', 3.2, 3.6, -8.8, 2.5], ['pet', 3.4, 7.0, -9.4, 2.9], ['macplus', 3.0, 14.6, -4.4, 2.2], ['osborne', 2.4, 16.2, -0.6, 1.8]].forEach(([n, h, x, z, ph]) => { K.mesh(K.rbox(3.4, ph, 2.6, 0.08), plinth, { p: [x, ph / 2, z], to: scene }); flats.push(K.flat('img/c/' + n, { h, p: [x, ph, z + 0.2], face: 0.6, to: scene })); });
const beige = K.std('#d8cfb9', 0.62), beigeD = K.std('#b9b09b', 0.66), black = K.std('#15140f', 0.55), steel = K.std('#b9bcc0', 0.3, 0.9), pinkM = K.std('#ff00b0', 0.3, 0, { envMapIntensity: 1.2 });
const root = new T.Group(); root.position.set(0.4, 0, 0.2); root.rotation.y = -0.2; scene.add(root);
/* moulded plastic is never glass-smooth, and a slipcase is cloth: two fine reliefs */
const grain = K.tex(256, 256, (g) => { g.fillStyle = '#808080'; g.fillRect(0, 0, 256, 256); const R = K.rng(21); for (let i = 0; i < 9000; i++) { const v = 100 + Math.floor(R() * 56); g.fillStyle = 'rgb(' + v + ',' + v + ',' + v + ')'; g.fillRect(R() * 256, R() * 256, 1.7, 1.7); } }, { linear: true, repeat: [5, 5] });
const weave = K.tex(128, 128, (g) => { g.fillStyle = '#808080'; g.fillRect(0, 0, 128, 128); for (let y = 0; y < 128; y += 4) for (let x = 0; x < 128; x += 4) { g.fillStyle = (x + y) % 8 ? '#6c6c6c' : '#949494'; g.fillRect(x, y, 3, 3); } }, { linear: true, repeat: [9, 9] });
[beige, beigeD].forEach((m) => { m.bumpMap = grain; m.bumpScale = 0.55; });
/* desk */
const wood = K.tex(1024, 512, (g, w, h) => { g.fillStyle = '#7b4a26'; g.fillRect(0, 0, w, h); const R = K.rng(4); for (let i = 0; i < 520; i++) { const y = R() * h, a = 0.05 + R() * 0.16; g.strokeStyle = (R() < 0.55 ? 'rgba(40,18,6,' : 'rgba(190,130,80,') + a + ')'; g.lineWidth = 0.6 + R() * 2.4; g.beginPath(); g.moveTo(0, y); for (let x = 0; x <= w; x += 64) g.lineTo(x, y + Math.sin(x * 0.006 + i) * 5 + (R() - 0.5) * 3); g.stroke(); } });
K.mesh(K.rbox(12.8, 0.42, 8.6, 0.14), K.std('#6d4021', 0.5), { p: [1.5, 0.21, 0.5], to: root });
K.mesh(new T.PlaneGeometry(12.5, 8.3), K.std('#ffffff', 0.42, 0, { map: wood, envMapIntensity: 0.7 }), { p: [1.5, 0.423, 0.5], r: [-Math.PI / 2, 0, 0], to: root, cast: false });
const Y0 = 0.425;
/* system unit */
const su = new T.Group(); su.position.set(0, Y0, -0.9); root.add(su);
K.mesh(K.rbox(5.0, 1.42, 4.1, 0.07), beige, { p: [0, 0.71, 0], to: su });
K.mesh(K.plate(4.86, 1.26, 0.04, 0.03), beigeD, { p: [0, 0.71, 2.045], to: su, cast: false });
const vent = K.tex(512, 256, (g, w, h) => { g.fillStyle = '#cfc6b0'; g.fillRect(0, 0, w, h); for (let y = 26; y < h - 14; y += 15) { g.fillStyle = '#6f685a'; g.fillRect(24, y, w - 48, 5); g.fillStyle = 'rgba(255,255,255,0.5)'; g.fillRect(24, y + 5, w - 48, 1.5); } });
K.mesh(new T.PlaneGeometry(2.3, 0.82), K.std('#ffffff', 0.6, 0, { map: vent }), { p: [-1.2, 0.56, 2.07], to: su, cast: false });
const badge = K.tex(512, 128, (g, w, h) => { const gr = g.createLinearGradient(0, 0, 0, h); gr.addColorStop(0, '#e8e8e4'); gr.addColorStop(1, '#a9aaa6'); g.fillStyle = gr; g.fillRect(0, 0, w, h); g.fillStyle = '#1b1a17'; g.font = '700 46px ' + K.SANS; g.textBaseline = 'middle'; g.fillText('Personal Computer', 26, 68); for (let i = 0; i < 5; i++) { g.fillStyle = ['#ff00b0', '#ffb81f', '#e2462c', '#1f4fd6', '#00857d'][i]; g.fillRect(440 + i * 11, 28, 7, 72); } });
K.mesh(new T.PlaneGeometry(1.5, 0.375), K.std('#ffffff', 0.3, 0.6, { map: badge }), { p: [-1.55, 1.14, 2.071], to: su, cast: false });
const leds = [];
[0.42, 1.58].forEach((x, i) => { const d = new T.Group(); d.position.set(x, 0.71, 2.05); su.add(d);
K.mesh(K.plate(1.1, 1.14, 0.03, 0.05), black, { to: d, cast: false }); K.mesh(new T.BoxGeometry(0.96, 0.035, 0.03), K.std('#000', 0.9), { p: [0, 0.12, 0.03], to: d, cast: false });
K.mesh(K.rbox(0.2, 0.3, 0.09, 0.03, 2), black, { p: [0.02, 0.12, 0.07], r: [0, 0, i ? 0 : 1.57], to: d, cast: false });
const led = K.mesh(new T.BoxGeometry(0.07, 0.045, 0.02), new T.MeshBasicMaterial({ color: 0x220000, toneMapped: false }), { p: [-0.38, -0.36, 0.03], to: d, cast: false }); leds.push(led); });
K.mesh(K.rbox(0.16, 0.4, 0.5, 0.04, 2), K.std('#d32a1c', 0.4), { p: [2.52, 0.9, -1.3], to: su });
/* monitor */
const mo = new T.Group(); mo.position.set(-0.35, Y0 + 1.42, -1.0); mo.rotation.y = 0.06; root.add(mo);
K.mesh(K.rbox(2.6, 0.24, 2.6, 0.06), beigeD, { p: [0, 0.12, 0], to: mo });
K.mesh(K.rbox(3.8, 2.8, 3.3, 0.12), beige, { p: [0, 1.64, 0], to: mo });
K.mesh(K.plate(3.5, 2.5, 0.16, 0.05), K.std('#2a2823', 0.5), { p: [-0.02, 1.66, 1.652], to: mo, cast: false });
const SW = 2.76, SH = 2.07, scrG = new T.PlaneGeometry(SW, SH, 28, 20); { const p = scrG.attributes.position; for (let i = 0; i < p.count; i++) { const x = p.getX(i) / (SW / 2), y = p.getY(i) / (SH / 2); p.setZ(i, 0.075 * (1 - (x * x + y * y) / 2)); } scrG.computeVertexNormals(); }
const scrC = document.createElement('canvas'); scrC.width = 640; scrC.height = 480; const sg = scrC.getContext('2d'), scrT = new T.CanvasTexture(scrC); scrT.colorSpace = T.SRGBColorSpace; scrT.minFilter = T.LinearFilter; scrT.generateMipmaps = false;
const crt = new T.ShaderMaterial({ uniforms: { tScr: { value: scrT }, tNext: U.tNext, uRes: U.uRes, uMix: { value: 0 }, uTime: { value: 0 } },
vertexShader: 'varying vec2 vUv; void main(){ vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }',
fragmentShader: `varying vec2 vUv; uniform sampler2D tScr; uniform sampler2D tNext; uniform vec2 uRes; uniform float uMix; uniform float uTime;
void main(){ vec2 c = vUv - 0.5; vec2 uv = 0.5 + c * (1.0 + 0.07 * dot(c, c));
vec3 s = texture2D(tScr, uv).rgb; s += (texture2D(tScr, uv + vec2(0.002, 0.0)).rgb + texture2D(tScr, uv - vec2(0.002, 0.0)).rgb + texture2D(tScr, uv + vec2(0.0, 0.0026)).rgb + texture2D(tScr, uv - vec2(0.0, 0.0026)).rgb) * 0.1;
float scan = 0.8 + 0.2 * sin(uv.y * 480.0 * 3.14159), fl = 0.965 + 0.035 * sin(uTime * 47.0);
vec3 col = s * scan * fl * 1.25 + vec3(0.010, 0.030, 0.016); col *= smoothstep(0.86, 0.25, length(c));
vec2 rq = c - vec2(-0.2, 0.2) + vec2(0.0, c.x * c.x * 0.22); float win = smoothstep(0.19, 0.15, abs(rq.x - rq.y * 0.12)) * smoothstep(0.15, 0.12, abs(rq.y)), slat = smoothstep(0.25, 0.6, 0.5 + 0.5 * sin(rq.y * 205.0));
col += vec3(0.05, 0.06, 0.055) * smoothstep(0.34, 0.0, length(c - vec2(-0.22, 0.24))) * 0.6 + vec3(0.03, 0.036, 0.033) * win * slat;
gl_FragColor = vec4(mix(col, texture2D(tNext, gl_FragCoord.xy / uRes).rgb, uMix), 1.0); }` });
const screen = K.mesh(scrG, crt, { p: [-0.02, 1.68, 1.74], to: mo, cast: false, receive: false });
const knobM = K.std('#1b1a15', 0.5, 0, { flatShading: true });
[1.02, 1.4].forEach((x, n) => { K.mesh(new T.CylinderGeometry(0.1, 0.1, 0.03, 24).rotateX(Math.PI / 2), K.std('#8f8877', 0.6), { p: [x, 0.47, 1.9], to: mo, cast: false }); K.mesh(new T.CylinderGeometry(0.082, 0.092, 0.13, 18).rotateX(Math.PI / 2), knobM, { p: [x, 0.47, 1.96], to: mo, cast: false });
K.mesh(new T.BoxGeometry(0.012, 0.06, 0.004), K.std('#efe8d6', 0.5), { p: [x + (n ? 0.03 : -0.02), 0.5, 2.027], r: [0, 0, n ? -0.5 : 0.35], to: mo, cast: false }); });
K.mesh(new T.PlaneGeometry(0.62, 0.075), new T.MeshBasicMaterial({ transparent: true, depthWrite: false, map: K.tex(256, 32, (g) => { g.clearRect(0, 0, 256, 32); g.fillStyle = '#4a453a'; g.font = '700 17px ' + K.SANS; g.textBaseline = 'middle'; g.textAlign = 'center'; g.fillText('BRIGHT', 50, 17); g.fillText('CONTRAST', 196, 17); }) }), { p: [1.21, 0.34, 1.899], to: mo, cast: false, receive: false });
/* a proper tube housing: a moulded frame the glass sits behind, a stepped rear, vents on top, a swivel foot, a pilot light */
K.mesh(K.frame(3.52, 2.76, 0.14, 0.34, 0.2, 0.3), beige, { p: [-0.02, 1.68, 1.78], to: mo }); K.mesh(K.rbox(2.9, 2.1, 1.1, 0.14), beigeD, { p: [0, 1.56, -2.05], to: mo });
K.mesh(new T.PlaneGeometry(3.0, 1.9), K.std('#ffffff', 0.6, 0, { map: K.tex(512, 320, (g) => { g.fillStyle = '#d8cfb9'; g.fillRect(0, 0, 512, 320); for (let x = 40; x < 480; x += 22) { g.fillStyle = '#5d564a'; g.fillRect(x, 40, 9, 240); g.fillStyle = 'rgba(255,255,255,0.55)'; g.fillRect(x + 9, 40, 2, 240); } }) }), { p: [0, 3.041, -0.2], r: [-Math.PI / 2, 0, 0], to: mo, cast: false });
K.mesh(new T.CylinderGeometry(1.0, 1.15, 0.12, 40), beigeD, { p: [0, 0.0, 0], to: mo }); K.mesh(new T.PlaneGeometry(0.1, 0.05), new T.MeshBasicMaterial({ color: K.col('#49ff7a').multiplyScalar(1.2), toneMapped: false }), { p: [-1.5, 0.43, 1.902], to: mo, cast: false });
K.mesh(new T.PlaneGeometry(0.9, 0.16), K.std('#ffffff', 0.4, 0.5, { map: K.tex(256, 48, (g) => { g.fillStyle = '#bfb8a6'; g.fillRect(0, 0, 256, 48); g.fillStyle = '#2a2620'; g.font = '700 22px ' + K.SANS; g.textBaseline = 'middle'; g.fillText('Display 12 in', 12, 26); }) }), { p: [-0.85, 0.43, 1.9], to: mo, cast: false });
/* system unit: lid seam, lip, feet, bay lettering, the cables at the back */
K.mesh(new T.BoxGeometry(4.96, 0.014, 0.02), K.std('#6b6456', 0.8), { p: [0, 1.3, 2.062], to: su, cast: false }); K.mesh(K.rbox(4.9, 0.12, 0.1, 0.03, 2), beigeD, { p: [0, 0.08, 2.06], to: su, cast: false });
[[-2.1, 1.6], [2.1, 1.6], [-2.1, -1.6], [2.1, -1.6]].forEach(([x, z]) => K.mesh(new T.CylinderGeometry(0.17, 0.17, 0.06, 16), black, { p: [x, 0.0, z], to: su, cast: false }));
['A', 'B'].forEach((ch, i) => K.mesh(new T.PlaneGeometry(0.16, 0.16), K.std('#ffffff', 0.5, 0, { map: K.tex(64, 64, (g) => { g.fillStyle = '#15140f'; g.fillRect(0, 0, 64, 64); g.fillStyle = '#d8cfb9'; g.font = '700 46px ' + K.SANS; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(ch, 32, 35); }) }), { p: [0.42 + i * 1.16 + 0.4, 0.31, 2.082], to: su, cast: false }));
{ const cab = (pts, r, c) => K.mesh(new T.TubeGeometry(new T.CatmullRomCurve3(pts.map((p) => new T.Vector3(...p))), 60, r, 8), K.std(c, 0.6), { to: root });
cab([[-0.4, Y0 + 2.6, -3.4], [-0.6, Y0 + 1.6, -3.9], [-0.9, Y0 + 0.7, -3.6], [-0.8, Y0 + 0.6, -2.9]], 0.055, '#2a2823'); cab([[1.6, Y0 + 0.5, -2.9], [2.2, Y0 + 0.2, -3.8], [3.6, Y0 + 0.05, -4.2], [5.6, Y0 + 0.05, -4.3]], 0.06, '#2a2823'); }
K.blob(8, 7, { p: [0, Y0, -0.4], a: 0.26, to: root });
/* keyboard: 83 keys */
const kb = new T.Group(); kb.position.set(-0.2, Y0 + 0.1, 2.75); kb.rotation.set(0.1, 0.1, 0, 'YXZ'); root.add(kb);
K.mesh(K.rbox(5.0, 0.34, 2.05, 0.07), beige, { p: [0, 0.2, 0], to: kb }); K.mesh(K.plate(4.7, 1.72, 0.05, 0.03), beigeD, { p: [0, 0.372, 0], r: [-Math.PI / 2, 0, 0], to: kb, cast: false });
const keys = [], P0 = 0.19, add = (x, r, w, dk) => keys.push({ x: x + (w * P0) / 2, z: -0.38 + r * P0, w, dk });
for (let r = 0; r < 5; r++) { add(-2.2, r, 1, 1); add(-2.2 + P0, r, 1, 1); }
[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.5], [1.7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.3], [1.2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.8], [1.6, 7.4, 1.5, 1.5, 1]].forEach((row, r) => { let x = -1.72; row.forEach((w, c) => { add(x, r, w, (c === 0 || c === row.length - 1 || r === 4) && w !== 7.4 ? 1 : 0); x += w * P0; }); });
for (let r = 0; r < 5; r++) for (let c = 0; c < 4; c++) add(1.06 + c * P0, r, 1, c === 3 ? 1 : 0);
const keyG = K.rbox(0.165, 0.13, 0.165, 0.035, 2), keyM = new T.InstancedMesh(keyG, K.std('#ffffff', 0.5), keys.length), o3 = new T.Object3D(), cK = K.col('#efe8d6'), cD = K.col('#a8a190');
keys.forEach((q, i) => keyM.setColorAt(i, q.dk ? cD : cK)); keyM.castShadow = true; keyM.receiveShadow = true; kb.add(keyM);
[[-2.2, 0.39, -0.86], [-2.02, 0.39, -0.86]].forEach((p) => K.mesh(new T.PlaneGeometry(0.1, 0.045), new T.MeshBasicMaterial({ color: K.col('#49ff7a'), toneMapped: false }), { p, r: [-Math.PI / 2, 0, 0], to: kb, cast: false }));
[-2.0, 2.0].forEach((x) => K.mesh(K.rbox(0.5, 0.16, 0.2, 0.04, 2), beigeD, { p: [x, -0.02, -0.86], to: kb }));
/* legends, printed on one sheet that sits a hair above the keycaps */
{ const LW = 4.6, LD = 1.2, sx = 1024 / LW, legend = K.tex(1024, Math.round(LD * sx), (g, w, h) => { g.textAlign = 'center'; g.textBaseline = 'middle';
const R1 = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '='], rows = [['Esc', ...R1, '←'], ['Tab', ...'QWERTYUIOP[]'.split(''), ''], ['Ctrl', ...'ASDFGHJKL;\''.split(''), '⏎'], ['⇧', ...'ZXCVBNM,./'.split(''), '⇧', '*'], ['Alt', '', 'Caps', 'Ins', 'Del']], pad = [['7', '8', '9', '-'], ['4', '5', '6', '+'], ['1', '2', '3', ''], ['0', '.', '', ''], ['', '', '', '']];
let ki = 0; const put = (s, q) => { if (!s) return; g.fillStyle = q.dk ? '#f3efe2' : '#2a2620'; g.font = (s.length > 1 ? '600 ' + 0.062 * sx : '700 ' + 0.084 * sx) + 'px ' + K.SANS; g.fillText(s, (q.x + LW / 2 + 0.05) * sx, (q.z + LD / 2 - 0.1) * sx); };
for (let r = 0; r < 5; r++) { put('F' + (r * 2 + 1), keys[ki++]); put('F' + (r * 2 + 2), keys[ki++]); }
rows.forEach((row) => row.forEach((s) => put(s, keys[ki++]))); pad.forEach((row) => row.forEach((s) => put(s, keys[ki++]))); });
K.mesh(new T.PlaneGeometry(LW, LD), new T.MeshBasicMaterial({ map: legend, transparent: true, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -2 }), { p: [-0.05, 0.499, 0.1], r: [-Math.PI / 2, 0, 0], to: kb, cast: false, receive: false }); }
/* coiled lead */
{ const pts = []; for (let i = 0; i <= 260; i++) { const u = i / 260, a = u * Math.PI * 2 * 22, cx = K.lerp(-2.55, -3.2, u) - Math.sin(u * Math.PI) * 0.9, cz = K.lerp(-0.6, -3.3, u); pts.push(new T.Vector3(cx + Math.cos(a) * 0.09, 0.12 + Math.sin(a) * 0.09 + 0.0, cz)); }
K.mesh(new T.TubeGeometry(new T.CatmullRomCurve3(pts), 900, 0.028, 6), K.std('#2a2823', 0.6), { p: [0, 0, 0], to: kb }); }
/* desk things: two floppies (one with a pink label), a pink mug, three manuals */
const disk = (label, tint) => K.tex(512, 512, (g) => { g.fillStyle = '#17171a'; g.fillRect(0, 0, 512, 512); g.fillStyle = '#0a0a0b'; g.beginPath(); g.arc(256, 256, 62, 0, 7); g.fill(); g.strokeStyle = '#3a3a40'; g.lineWidth = 5; g.beginPath(); g.arc(256, 256, 62, 0, 7); g.stroke(); g.fillStyle = '#060606'; g.beginPath(); g.ellipse(256, 410, 20, 62, 0, 0, 7); g.fill(); g.fillRect(490, 120, 22, 30);
g.fillStyle = tint; g.fillRect(40, 24, 432, 132); g.fillStyle = '#16130f'; g.font = '700 40px ' + K.MONO; g.fillText(label, 60, 82); g.font = '500 24px ' + K.MONO; g.fillText('5.25 IN DS/DD 360K', 60, 128); });
[['LEDGER 1981', '#ff00b0', [3.75, 2.2], 0.35], ['PAYROLL B', '#f3f1ea', [4.1, 3.2], -0.5]].forEach(([l, c, [x, z], a], i) => { K.mesh(new T.BoxGeometry(1.33, 0.02, 1.33), black, { p: [x, Y0 + 0.012 + i * 0.022, z], r: [0, a, 0], to: root }); K.mesh(new T.PlaneGeometry(1.33, 1.33), K.std('#fff', 0.55, 0, { map: disk(l, c) }), { p: [x, Y0 + 0.024 + i * 0.022, z], r: [-Math.PI / 2, 0, a], to: root, cast: false }); });
{ const prof = [[0, 0], [0.36, 0], [0.4, 0.04], [0.4, 0.92], [0.37, 0.96], [0.34, 0.92], [0.34, 0.08], [0, 0.08]].map(([x, y]) => new T.Vector2(x, y)), mug = new T.Group(); mug.position.set(5.9, Y0, 1.1); root.add(mug);
K.mesh(new T.LatheGeometry(prof, 40), pinkM, { to: mug }); K.mesh(new T.TorusGeometry(0.26, 0.055, 12, 28, Math.PI), pinkM, { p: [0.38, 0.5, 0], r: [0, 0, -Math.PI / 2], to: mug });
K.mesh(new T.CircleGeometry(0.335, 32), K.std('#2a1608', 0.25), { p: [0, 0.82, 0], r: [-Math.PI / 2, 0, 0], to: mug, cast: false }); }
[['#1f4fd6', 0, 'Disk Operating System', '1.00', '#f3f1ea'], ['#e2462c', 0.12, 'BASIC', 'reference', '#f3f1ea'], ['#f3f1ea', -0.08, 'Guide to Operations', '', '#16130f']].forEach(([c, a, title, sub, ink], i) => { const m = new T.Group(); m.position.set(3.1, Y0 + 0.173 + i * 0.347, -3.3); m.rotation.y = -0.25 + a; m.scale.setScalar(0.82); root.add(m);
K.mesh(K.rbox(2.3, 0.42, 2.9, 0.035), K.std(c, 0.82, 0, { bumpMap: weave, bumpScale: 0.6 }), { to: m });
/* the open end of the slipcase shows the binder inside; the spine carries the title */
K.mesh(new T.PlaneGeometry(2.7, 0.34), K.std('#ebe4d2', 0.9), { p: [1.152, 0, 0], r: [0, Math.PI / 2, 0], to: m, cast: false }); K.mesh(new T.BoxGeometry(0.01, 0.3, 2.62), K.std(c, 0.8), { p: [1.156, 0, 0], to: m, cast: false });
K.mesh(new T.PlaneGeometry(2.1, 0.3), new T.MeshBasicMaterial({ transparent: true, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -2, map: K.tex(1024, 146, (g) => { g.clearRect(0, 0, 1024, 146); g.fillStyle = ink; g.textBaseline = 'middle'; g.font = '700 62px ' + K.SANS; g.fillText(title, 96, 76); const w = g.measureText(title).width; g.font = '500 44px ' + K.SANS; g.globalAlpha = 0.85; g.fillText(sub, 96 + w + 30, 80); g.globalAlpha = 1; g.fillRect(30, 30, 34, 86); g.fillRect(900, 70, 94, 6); }) }), { p: [0, 0, 1.452], to: m, cast: false, receive: false }); });
/* a desk lamp with its pool of light, a dot-matrix printer (photograph), steam off the coffee */
{ const lamp = new T.Group(); lamp.position.set(-3.5, Y0, -2.4); root.add(lamp); const lm = K.std('#1f1e1a', 0.4, 0.6);
K.mesh(new T.CylinderGeometry(0.7, 0.78, 0.14, 32), lm, { p: [0, 0.07, 0], to: lamp }); K.mesh(new T.CylinderGeometry(0.05, 0.05, 3.2, 10), lm, { p: [0.45, 1.6, 0], r: [0, 0, -0.28], to: lamp }); K.mesh(new T.CylinderGeometry(0.05, 0.05, 2.6, 10), lm, { p: [1.75, 3.5, 0], r: [0, 0, -1.05], to: lamp });
const shade = K.mesh(new T.ConeGeometry(0.8, 0.95, 32, 1, true), K.std('#e2462c', 0.45, 0.2, { side: T.DoubleSide }), { p: [2.95, 3.72, 0.2], r: [0.2, 0, 0.42], to: lamp });
K.mesh(new T.SphereGeometry(0.24, 16, 12), new T.MeshBasicMaterial({ color: K.col('#fff3cf').multiplyScalar(3.2), toneMapped: false }), { p: [3.05, 3.5, 0.24], to: lamp, cast: false });
const cone = K.mesh(new T.ConeGeometry(2.6, 3.9, 40, 1, true), new T.MeshBasicMaterial({ map: K.tex(8, 128, (g) => { const gr = g.createLinearGradient(0, 0, 0, 128); gr.addColorStop(0, 'rgba(255,240,200,0.5)'); gr.addColorStop(1, 'rgba(255,240,200,0)'); g.fillStyle = gr; g.fillRect(0, 0, 8, 128); }), transparent: true, depthWrite: false, blending: T.AdditiveBlending, side: T.DoubleSide, toneMapped: false }), { p: [3.7, 1.9, 0.9], r: [0.2, 0, 0.42], to: lamp, cast: false, receive: false });
const pl = new T.PointLight('#ffe2b0', 26, 9, 2); pl.position.set(3.2, 3.2, 0.4); lamp.add(pl);
[[0.9, 3.13, 0], [2.86, 4.13, 0.03]].forEach((p) => { K.mesh(new T.CylinderGeometry(0.11, 0.11, 0.2, 18).rotateX(Math.PI / 2), steel, { p, to: lamp, cast: false }); K.mesh(new T.CylinderGeometry(0.05, 0.05, 0.3, 6).rotateX(Math.PI / 2), lm, { p, to: lamp, cast: false }); });
K.mesh(new T.CylinderGeometry(0.72, 0.72, 0.02, 32), steel, { p: [0, 0.145, 0], to: lamp, cast: false }); K.mesh(K.rbox(0.24, 0.07, 0.13, 0.02, 2), K.std('#d32a1c', 0.4), { p: [-0.32, 0.17, 0.36], r: [0.12, 0.5, 0], to: lamp, cast: false });
K.mesh(new T.TubeGeometry(new T.CatmullRomCurve3([[0.62, 0.06, -0.3], [1.05, 0.03, -0.75], [0.85, 0.03, -1.1], [1.2, 0.02, -1.42], [1.25, -0.3, -1.6]].map((p) => new T.Vector3(...p))), 40, 0.03, 6), K.std('#1f1e1a', 0.6), { to: lamp }); }
const flatsD = [K.flat('img/c/dotmatrix', { h: 1.6, p: [5.9, Y0, -2.2], face: 0.3, to: root, cast: true })];
const steam = K.dust({ box: [5.9, Y0 + 1.6, 1.1, 0.5, 1.4, 0.5], color: '#ffffff', n: 26, size: 60, gain: 0.5, rise: 0.5, seed: 9 }); root.add(steam);
const ROWS = [['', 'Q1', 'Q2', 'Q3', 'Q4', 'YEAR'], ['REVENUE', 4120, 4480, 5010, 5630], ['PAYROLL', 1840, 1840, 1910, 2060], ['RENT', 420, 420, 420, 450], ['STOCK', 980, 1105, 1260, 1390], ['FREIGHT', 212, 240, 268, 305], ['COSTS'], ['MARGIN'], ['MARGIN %']];
/* ---------- 1981, looked at closely: fasteners, labels, vents, and what a bookkeeper leaves lying about ---------- */
const HAND = '"Noteworthy", "Bradley Hand", "Segoe Print", "Ink Free", cursive', paperM = (map, extra) => K.std('#ffffff', 0.92, 0, Object.assign({ map, envMapIntensity: 0.3 }, extra || {}));
const screwM = K.std('#ffffff', 0.35, 0.6, { alphaTest: 0.5, map: K.tex(64, 64, (g) => { g.clearRect(0, 0, 64, 64); const gr = g.createLinearGradient(0, 0, 64, 64); gr.addColorStop(0, '#f2f2ee'); gr.addColorStop(1, '#7d7f80'); g.fillStyle = gr; g.beginPath(); g.arc(32, 32, 29, 0, 7); g.fill(); g.strokeStyle = 'rgba(0,0,0,0.45)'; g.lineWidth = 2; g.stroke(); g.strokeStyle = '#2b2b2b'; g.lineWidth = 6; g.lineCap = 'round'; g.beginPath(); g.moveTo(17, 32); g.lineTo(47, 32); g.moveTo(32, 17); g.lineTo(32, 47); g.stroke(); }) });
const screw = (to, p, r, d = 0.085) => K.mesh(new T.CircleGeometry(d / 2, 14), screwM, { p, r: [r[0], r[1], (p[0] * 7 + p[1] * 13 + p[2] * 5) % 3], to, cast: false, receive: false });
/* a strip of embossing tape: raised white letters on a glossy colour, the office label of the day */
const tape = (text, hex, to, p, r) => { const n = text.length, cw = 30, w = n * cw + 28; return K.mesh(new T.PlaneGeometry(w / 52 * 0.105, 0.105), K.std('#ffffff', 0.26, 0, { map: K.tex(w, 52, (g) => { g.fillStyle = hex; g.fillRect(0, 0, w, 52); const gr = g.createLinearGradient(0, 0, 0, 52); gr.addColorStop(0, 'rgba(255,255,255,0.3)'); gr.addColorStop(0.4, 'rgba(255,255,255,0)'); gr.addColorStop(1, 'rgba(0,0,0,0.25)'); g.fillStyle = gr; g.fillRect(0, 0, w, 52); g.font = '700 34px ' + K.MONO; g.textBaseline = 'middle'; g.textAlign = 'center'; for (let i = 0; i < n; i++) { g.fillStyle = 'rgba(0,0,0,0.32)'; g.fillText(text[i], 14 + cw * (i + 0.5) + 1.5, 29.5); g.fillStyle = '#fbfaf5'; g.fillText(text[i], 14 + cw * (i + 0.5), 27.5); } }) }), { p, r, to, cast: false }); };
/* vent panels let into the sides of both cases */
const slotT = (cols, rows) => K.tex(512, 256, (g) => { g.fillStyle = '#d6cdb7'; g.fillRect(0, 0, 512, 256); g.strokeStyle = 'rgba(70,62,48,0.55)'; g.lineWidth = 3; g.strokeRect(5, 5, 502, 246); g.strokeStyle = 'rgba(255,255,255,0.5)'; g.lineWidth = 1.5; g.strokeRect(8, 8, 496, 240); const sw = 472 / cols, sh = 216 / rows; for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) { const x = 20 + c * sw, y = 20 + r * sh; g.fillStyle = '#3d382e'; g.fillRect(x + sw * 0.28, y + 5, sw * 0.44, sh - 10); g.fillStyle = 'rgba(0,0,0,0.5)'; g.fillRect(x + sw * 0.28, y + 5, sw * 0.44, 4); g.fillStyle = 'rgba(255,255,255,0.55)'; g.fillRect(x + sw * 0.72, y + 5, 1.6, sh - 10); } });
const ventM = K.std('#ffffff', 0.62, 0, { map: slotT(30, 2) }), ventM2 = K.std('#ffffff', 0.62, 0, { map: slotT(22, 3) });
K.mesh(new T.PlaneGeometry(2.5, 0.72), ventM, { p: [-2.503, 0.62, 0.55], r: [0, -Math.PI / 2, 0], to: su, cast: false }); K.mesh(new T.PlaneGeometry(2.5, 0.72), ventM, { p: [2.503, 0.62, 0.55], r: [0, Math.PI / 2, 0], to: su, cast: false });
[-1, 1].forEach((sd) => { K.mesh(new T.PlaneGeometry(2.3, 1.5), ventM2, { p: [sd * 1.903, 1.85, -0.25], r: [0, sd * Math.PI / 2, 0], to: mo, cast: false }); [[-1.02, 0.66], [1.02, 0.66], [-1.02, -0.66], [1.02, -0.66]].forEach(([a, b]) => screw(mo, [sd * 1.906, 1.85 + b, -0.25 + a], [0, sd * Math.PI / 2, 0], 0.07)); });
/* the power switch gets its plate and its two words; the side gets the firm's inventory tag */
K.mesh(K.plate(0.5, 0.74, 0.04, 0.012), K.std('#24221c', 0.6), { p: [2.506, 0.9, -1.3], r: [0, Math.PI / 2, 0], to: su, cast: false }); [[0.3, 1], [-0.3, 0]].forEach(([dy]) => screw(su, [2.514, 0.9 + dy, -1.3], [0, Math.PI / 2, 0], 0.06));
K.mesh(new T.PlaneGeometry(0.2, 0.62), new T.MeshBasicMaterial({ transparent: true, depthWrite: false, map: K.tex(64, 200, (g) => { g.clearRect(0, 0, 64, 200); g.fillStyle = '#efe8d6'; g.font = '700 22px ' + K.SANS; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText('ON', 32, 22); g.fillText('OFF', 32, 180); }) }), { p: [2.515, 0.9, -0.93], r: [0, Math.PI / 2, 0], to: su, cast: false, receive: false });
K.mesh(new T.PlaneGeometry(0.92, 0.36), K.std('#ffffff', 0.3, 0.75, { map: K.tex(368, 144, (g) => { const gr = g.createLinearGradient(0, 0, 368, 144); gr.addColorStop(0, '#e6e7e4'); gr.addColorStop(0.5, '#babcb9'); gr.addColorStop(1, '#dcdedb'); g.fillStyle = gr; g.fillRect(0, 0, 368, 144); g.strokeStyle = '#5a5c5a'; g.lineWidth = 3; g.strokeRect(7, 7, 354, 130); g.fillStyle = '#26282a'; g.textBaseline = 'middle'; g.font = '700 26px ' + K.SANS; g.fillText('ACCOUNTS DEPT · INVENTORY', 22, 44); g.font = '700 50px ' + K.MONO; g.fillText('No 0142', 22, 98); g.beginPath(); g.arc(336, 30, 7, 0, 7); g.arc(336, 114, 7, 0, 7); g.fill(); }) }), { p: [2.504, 1.2, 1.25], r: [0, Math.PI / 2, 0], to: su, cast: false });
/* drive fronts: the recess round the slot, the finger notch, moulded ribs, a legend by the lamp */
const driveT = K.tex(512, 532, (g) => { const gr = g.createLinearGradient(0, 0, 0, 532); gr.addColorStop(0, '#22211a'); gr.addColorStop(1, '#141310'); g.fillStyle = gr; g.fillRect(0, 0, 512, 532); g.strokeStyle = 'rgba(255,255,255,0.07)'; g.lineWidth = 3; g.strokeRect(6, 6, 500, 520);
g.fillStyle = '#0a0a08'; g.fillRect(14, 150, 484, 118); g.fillStyle = 'rgba(0,0,0,0.6)'; g.fillRect(14, 150, 484, 9); g.fillStyle = 'rgba(255,255,255,0.09)'; g.fillRect(14, 264, 484, 3);
g.fillStyle = '#050504'; g.beginPath(); g.ellipse(256, 268, 66, 40, 0, 0, Math.PI); g.fill(); g.strokeStyle = 'rgba(255,255,255,0.1)'; g.lineWidth = 2.5; g.beginPath(); g.ellipse(256, 268, 66, 40, 0, 0.25, Math.PI - 0.25); g.stroke();
for (let i = 0; i < 5; i++) { g.fillStyle = 'rgba(0,0,0,0.55)'; g.fillRect(170, 452 + i * 13, 310, 5); g.fillStyle = 'rgba(255,255,255,0.07)'; g.fillRect(170, 457 + i * 13, 310, 1.5); }
g.fillStyle = '#8f8a78'; g.font = '700 15px ' + K.SANS; g.textBaseline = 'middle'; g.fillText('IN USE', 104, 441); g.strokeStyle = '#3a382f'; g.lineWidth = 3; g.strokeRect(52, 427, 40, 27); g.fillStyle = '#6f6a5a'; g.font = '600 14px ' + K.SANS; g.fillText('5¼ in · 160 K', 34, 40); });
[0.42, 1.58].forEach((x) => K.mesh(new T.PlaneGeometry(1.06, 1.1), K.std('#ffffff', 0.5, 0, { map: driveT }), { p: [x, 0.71, 2.0775], to: su, cast: false }));
/* labels: one in tape on the tube, one on the keyboard, and a note somebody stuck on the bezel */
tape('DO NOT SWITCH OFF', '#c8281c', mo, [0.2, 0.47, 1.9], [0, 0, -0.012]); tape('ACCOUNTS 2', '#1f4fd6', kb, [1.42, 0.3985, -0.82], [-Math.PI / 2, 0, 0.03]);
const noteG = new T.PlaneGeometry(0.64, 0.64, 1, 8); { const p = noteG.attributes.position; for (let i = 0; i < p.count; i++) { const v = 0.5 - p.getY(i) / 0.64; p.setZ(i, v * v * 0.09); } noteG.computeVertexNormals(); }
const note = K.mesh(noteG, K.std('#ffffff', 0.85, 0, { side: T.DoubleSide, map: K.tex(256, 256, (g) => { g.fillStyle = '#f7e36b'; g.fillRect(0, 0, 256, 256); g.fillStyle = 'rgba(0,0,0,0.05)'; g.fillRect(0, 0, 256, 36); g.fillStyle = '#1b2a6b'; g.font = '700 50px ' + HAND; g.textAlign = 'center'; g.textBaseline = 'middle'; g.save(); g.translate(128, 138); g.rotate(-0.06); g.fillText('SAVE', 0, -54); g.fillText('before', 0, 2); g.fillText('lunch!', 0, 58); g.restore(); }) }), { p: [1.62, 2.42, 1.9], r: [0, 0, -0.07], to: mo });
/* a disk in its sleeve, propped against the tube where the next person will find it */
const sleeveT = K.tex(512, 400, (g) => { g.fillStyle = '#f1eee4'; g.fillRect(0, 0, 512, 400); g.strokeStyle = 'rgba(60,50,30,0.25)'; g.lineWidth = 3; g.strokeRect(3, 3, 506, 394); g.fillStyle = 'rgba(60,50,30,0.1)'; g.beginPath(); g.ellipse(256, 0, 120, 44, 0, 0, Math.PI); g.fill(); g.fillStyle = '#5c574a'; g.font = '600 19px ' + K.SANS; g.textBaseline = 'middle'; ['Keep away from magnets', 'Do not bend or fold', 'Never touch the recording surface', 'Return to sleeve after use'].forEach((t, i) => { g.strokeStyle = '#5c574a'; g.lineWidth = 2.5; g.strokeRect(40, 176 + i * 50, 30, 30); g.fillText(t, 88, 192 + i * 50); }); g.font = '700 24px ' + K.SANS; g.fillText('5¼-inch flexible disk · handle with care', 40, 128); });
{ const lean = new T.Group(); lean.position.set(2.31, 1.425, -0.55); lean.rotation.z = 0.56; su.add(lean);
K.mesh(new T.BoxGeometry(0.02, 1.33, 1.33), black, { p: [0, 0.665, 0], to: lean }); K.mesh(new T.PlaneGeometry(1.33, 1.33), K.std('#fff', 0.55, 0, { map: disk('BACKUP wk 32', '#f3f1ea') }), { p: [0.012, 0.665, 0], r: [0, Math.PI / 2, 0], to: lean, cast: false });
K.mesh(new T.BoxGeometry(0.012, 1.02, 1.37), K.std('#f1eee4', 0.9), { p: [0.006, 0.51, 0], to: lean, cast: false }); K.mesh(new T.PlaneGeometry(1.37, 1.02), paperM(sleeveT), { p: [0.02, 0.51, 0], r: [0, Math.PI / 2, 0], to: lean, cast: false }); }
/* an empty sleeve by the disks on the desk */
K.mesh(new T.PlaneGeometry(1.37, 1.02), paperM(sleeveT), { p: [3.95, Y0 + 0.008, 4.12], r: [-Math.PI / 2, 0, 0.22], to: root, cast: false });
/* the blotter the keyboard sits on */
K.mesh(K.rbox(6.5, 0.024, 3.5, 0.01, 1), K.std('#1d3a2f', 0.62), { p: [-0.1, Y0 + 0.012, 2.92], to: root, cast: false });
K.mesh(new T.PlaneGeometry(6.5, 3.5), K.std('#ffffff', 0.6, 0, { polygonOffset: true, polygonOffsetFactor: -2, polygonOffsetUnits: -2, bumpMap: grain, bumpScale: 0.8, map: K.tex(1024, 552, (g) => { g.fillStyle = '#1f3e32'; g.fillRect(0, 0, 1024, 552); const R = K.rng(6); for (let i = 0; i < 2600; i++) { g.fillStyle = R() < 0.5 ? 'rgba(255,255,255,0.025)' : 'rgba(0,0,0,0.05)'; g.fillRect(R() * 1024, R() * 552, 2 + R() * 5, 2 + R() * 3); } g.strokeStyle = 'rgba(214,190,130,0.75)'; g.lineWidth = 2.5; g.setLineDash([9, 7]); g.strokeRect(16, 16, 992, 520); g.setLineDash([]); g.strokeStyle = 'rgba(0,0,0,0.3)'; g.lineWidth = 2; g.strokeRect(11, 11, 1002, 530); }) }), { p: [-0.1, Y0 + 0.027, 2.92], r: [-Math.PI / 2, 0, 0], to: root, cast: false });
/* yesterday's run, torn off the printer: green-bar paper with the same ledger, and a query in red pencil */
const BAR = '#dcefdc', printRows = (g, x0, y0, lh, fs, n) => { g.fillStyle = '#2c2c30'; g.font = '600 ' + fs + 'px ' + K.MONO; g.textBaseline = 'middle'; for (let r = 0; r < n; r++) { const row = ROWS[r % ROWS.length]; g.textAlign = 'left'; g.fillText(row[0] || 'ACCOUNT', x0, y0 + r * lh); for (let c = 1; c <= 4; c++) { g.textAlign = 'right'; g.fillText(String(row[c] === undefined ? (r % ROWS.length === 0 ? 'Q' + c : 1200 + ((r * 37 + c * 211) % 4200)) : row[c]), x0 + fs * (9 + c * 6.2), y0 + r * lh); } } g.textAlign = 'left'; };
const sheetT = K.tex(1024, 760, (g) => { g.fillStyle = '#f8f6ee'; g.fillRect(0, 0, 1024, 760); for (let y = 40; y < 760; y += 76) { g.fillStyle = BAR; g.fillRect(48, y, 928, 38); } g.fillStyle = '#e9e6da'; g.fillRect(0, 0, 44, 760); g.fillRect(980, 0, 44, 760); for (let y = 19; y < 760; y += 38) { g.fillStyle = '#6d4021'; g.beginPath(); g.arc(22, y, 9, 0, 7); g.arc(1002, y, 9, 0, 7); g.fill(); } g.strokeStyle = 'rgba(0,0,0,0.25)'; g.setLineDash([3, 5]); g.lineWidth = 1.5; g.beginPath(); g.moveTo(46, 0); g.lineTo(46, 760); g.moveTo(978, 0); g.lineTo(978, 760); g.stroke(); g.setLineDash([]);
g.fillStyle = '#2c2c30'; g.font = '700 23px ' + K.MONO; g.textBaseline = 'middle'; g.fillText('LEDGER.81 QUARTERLY SUMMARY PAGE 1', 80, 59); printRows(g, 80, 135, 38, 23, 9); g.fillText('END OF REPORT', 80, 135 + 10 * 38);
g.strokeStyle = '#c8281c'; g.lineWidth = 4; g.beginPath(); g.ellipse(566, 287, 62, 24, -0.05, 0, 7); g.stroke(); g.beginPath(); g.moveTo(628, 280); g.lineTo(720, 250); g.stroke(); g.fillStyle = '#c8281c'; g.font = '700 38px ' + HAND; g.fillText('check with Sue', 728, 240); });
K.mesh(new T.PlaneGeometry(3.3, 2.45), paperM(sheetT), { p: [4.95, Y0 + 0.005, 1.25], r: [-Math.PI / 2, 0, 0.11], to: root, cast: false });
/* a coffee ring on it, a pencil, three paper clips */
K.mesh(new T.PlaneGeometry(0.9, 0.9), new T.MeshBasicMaterial({ transparent: true, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -3, map: K.tex(128, 128, (g) => { g.clearRect(0, 0, 128, 128); g.strokeStyle = 'rgba(110,70,30,0.42)'; g.lineWidth = 5; g.beginPath(); g.arc(64, 64, 50, 0.4, 5.6); g.stroke(); g.strokeStyle = 'rgba(110,70,30,0.16)'; g.lineWidth = 11; g.beginPath(); g.arc(64, 64, 47, 1.2, 4.4); g.stroke(); }) }), { p: [5.2, Y0 + 0.0065, 1.95], r: [-Math.PI / 2, 0, 1], to: root, cast: false, receive: false });
const brass = K.std('#c9a24a', 0.3, 0.9), rubber = K.std('#e58a94', 0.8), cedar = K.std('#e2c7a0', 0.8), lead = K.std('#2a2a2a', 0.5), pencilM = {};
const pencil = (to, len, hex, point) => { const g = new T.Group(); to.add(g); K.mesh(new T.CylinderGeometry(0.037, 0.037, len, 6), pencilM[hex] || (pencilM[hex] = K.std(hex, 0.45)), { p: [0, len / 2, 0], to: g }); K.mesh(new T.CylinderGeometry(0.04, 0.04, 0.13, 10), brass, { p: [0, len + 0.065, 0], to: g, cast: false }); K.mesh(new T.CylinderGeometry(0.037, 0.037, 0.11, 10), rubber, { p: [0, len + 0.185, 0], to: g, cast: false });
if (point) { K.mesh(new T.ConeGeometry(0.037, 0.17, 6), cedar, { p: [0, -0.085, 0], r: [Math.PI, 0, 0], to: g, cast: false }); K.mesh(new T.ConeGeometry(0.014, 0.06, 6), lead, { p: [0, -0.14, 0], r: [Math.PI, 0, 0], to: g, cast: false }); } return g; };
{ const p = pencil(root, 1.5, '#e9b21a', true); p.position.set(3.55, Y0 + 0.045, 1.2); p.rotation.set(Math.PI / 2, 0, 0.9, 'YXZ'); p.rotation.y = 0.75;
const clip = new T.TubeGeometry(new T.CatmullRomCurve3([[0, 0, 0.16], [0.045, 0, 0.19], [0.09, 0, 0.16], [0.09, 0, -0.14], [0.045, 0, -0.18], [0, 0, -0.14], [0, 0, 0.1], [0.035, 0, 0.13], [0.065, 0, 0.1], [0.065, 0, -0.08]].map((q) => new T.Vector3(...q))), 60, 0.007, 5);
[[3.25, 2.05, 0.4], [3.42, 2.3, 1.9], [6.35, 2.35, -0.6]].forEach(([x, z, a]) => K.mesh(clip, steel, { p: [x, Y0 + 0.016, z], r: [0, a, 0], to: root, cast: false })); }
/* a page-a-day calendar, open at the day this machine went on sale */
{ const cal = new T.Group(); cal.position.set(3.72, Y0, 0.0); cal.rotation.y = -0.42; root.add(cal); const chrome = K.std('#e6e8ea', 0.18, 1), edge = K.std('#efe9d9', 0.9);
K.mesh(K.rbox(1.2, 0.1, 0.9, 0.035, 2), black, { p: [0, 0.05, -0.12], to: cal });
const pageT = K.tex(512, 640, (g) => { g.fillStyle = '#f8f4e9'; g.fillRect(0, 0, 512, 640); g.fillStyle = '#c8281c'; g.fillRect(0, 62, 512, 96); g.fillStyle = '#fff'; g.font = '700 56px ' + K.SANS; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText('AUGUST 1981', 256, 112); g.fillStyle = '#16130f'; g.font = '800 318px ' + K.SERIF; g.fillText('12', 256, 372); g.font = '700 50px ' + K.SANS; g.fillText('WEDNESDAY', 256, 566); g.fillStyle = '#16130f'; [150, 362].forEach((x) => { g.beginPath(); g.arc(x, 30, 13, 0, 7); g.fill(); }); g.fillStyle = 'rgba(22,19,15,0.45)'; g.font = '500 22px ' + K.SANS; g.fillText('224th day · 141 to come', 256, 614); });
const pg = new T.Group(); pg.position.set(0, 0.1, 0.18); pg.rotation.x = -0.36; cal.add(pg);
K.mesh(new T.BoxGeometry(0.88, 1.1, 0.12), [edge, edge, edge, edge, paperM(pageT), edge], { p: [0, 0.55, -0.06], to: pg });
const back = new T.Group(); back.position.set(0, 0.1, -0.5); back.rotation.x = 0.34; cal.add(back); K.mesh(new T.BoxGeometry(0.88, 1.06, 0.07), edge, { p: [0, 0.53, 0.035], to: back });
[-0.26, 0.26].forEach((x) => K.mesh(new T.TorusGeometry(0.2, 0.02, 8, 26), chrome, { p: [x, 1.1, -0.18], r: [0, Math.PI / 2, 0], to: cal, cast: false })); }
/* pencils, a ballpoint and a steel rule in a tobacco-brown pot */
{ const pot = new T.Group(); pot.position.set(4.55, Y0, -1.05); root.add(pot);
K.mesh(new T.LatheGeometry([[0, 0.02], [0.33, 0.02], [0.36, 0.05], [0.37, 0.98], [0.355, 1.0], [0.34, 0.98], [0.33, 0.08], [0, 0.08]].map(([x, y]) => new T.Vector2(x, y)), 36), K.std('#5a371f', 0.3, 0, { envMapIntensity: 1.1 }), { to: pot });
[[0.12, 0.1, 0.16, -0.12, 1.55, '#e9b21a'], [-0.14, 0.05, -0.1, 0.17, 1.62, '#e9b21a'], [0.02, -0.16, 0.2, 0.1, 1.38, '#2f6b3a']].forEach(([x, z, rx, rz, len, c]) => { const p = pencil(pot, len, c); p.position.set(x, 0.24, z); p.rotation.set(rx, 0, rz); });
const pen = new T.Group(); pen.position.set(-0.05, 0.1, 0.18); pen.rotation.set(-0.2, 0, 0.14); pot.add(pen); K.mesh(new T.CylinderGeometry(0.04, 0.04, 1.3, 12), K.std('#1f4fd6', 0.3), { p: [0, 0.65, 0], to: pen }); K.mesh(new T.CylinderGeometry(0.043, 0.043, 0.42, 12), K.std('#16399c', 0.25), { p: [0, 1.2, 0], to: pen, cast: false });
K.mesh(new T.BoxGeometry(0.3, 1.9, 0.012), K.std('#c9ced2', 0.25, 0.95, { map: K.tex(64, 512, (g) => { g.fillStyle = '#d8dcdf'; g.fillRect(0, 0, 64, 512); g.fillStyle = '#33363a'; for (let i = 0; i < 64; i++) g.fillRect(0, i * 8, i % 8 ? (i % 4 ? 12 : 18) : 28, 1.5); }) }), { p: [0.2, 0.98, -0.12], r: [0.13, 0.5, -0.1], to: pot }); }
/* the telephone: push-button, chocolate brown, its number on a card and the handset on a coiled cord */
{ const ph = new T.Group(); ph.position.set(6.05, Y0, 3.0); ph.rotation.y = -0.62; root.add(ph); const brown = K.std('#4b2e1f', 0.32, 0, { envMapIntensity: 1.1, bumpMap: grain, bumpScale: 0.3 }), brownD = K.std('#2e1b12', 0.5);
const sh = new T.Shape(); sh.moveTo(-1.08, 0.03); sh.lineTo(1.06, 0.03); sh.quadraticCurveTo(1.14, 0.04, 1.13, 0.16); sh.quadraticCurveTo(1.1, 0.3, 0.94, 0.36); sh.lineTo(0.02, 0.72); sh.quadraticCurveTo(-0.16, 0.8, -0.36, 0.82); sh.lineTo(-0.98, 0.82); sh.quadraticCurveTo(-1.12, 0.8, -1.12, 0.66); sh.lineTo(-1.12, 0.08); sh.quadraticCurveTo(-1.12, 0.03, -1.08, 0.03);
const bg = new T.ExtrudeGeometry(sh, { depth: 1.9, bevelEnabled: true, bevelThickness: 0.05, bevelSize: 0.05, bevelSegments: 3, curveSegments: 8 }); bg.rotateY(-Math.PI / 2); bg.translate(0.95, 0, 0); K.mesh(bg, brown, { to: ph });
/* the keys, on the slope */
const face = new T.Group(); face.position.set(0, 0.565, 0.47); face.rotation.x = -1.2; ph.add(face);
K.mesh(K.plate(1.0, 0.92, 0.05, 0.02), brownD, { p: [0, 0.03, 0.004], to: face, cast: false });
const pk = new T.InstancedMesh(K.rbox(0.2, 0.15, 0.07, 0.025, 2), K.std('#efe8d6', 0.45), 12), po = new T.Object3D(); for (let i = 0; i < 12; i++) { po.position.set((i % 3 - 1) * 0.27, 0.33 - Math.floor(i / 3) * 0.2, 0.045); po.updateMatrix(); pk.setMatrixAt(i, po.matrix); } pk.castShadow = false; pk.receiveShadow = true; face.add(pk);
K.mesh(new T.PlaneGeometry(0.81, 0.8), new T.MeshBasicMaterial({ transparent: true, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -2, map: K.tex(324, 320, (g) => { g.clearRect(0, 0, 324, 320); g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillStyle = '#2a2620'; ['1', '2', '3', '4', '5', '6', '7', '8', '9', '*', '0', '#'].forEach((d, i) => { const x = 54 + (i % 3) * 108, y = 40 + Math.floor(i / 3) * 80; g.font = '700 34px ' + K.SANS; g.fillText(d, x - 16, y); g.font = '600 13px ' + K.SANS; g.fillText(['', 'ABC', 'DEF', 'GHI', 'JKL', 'MNO', 'PRS', 'TUV', 'WXY', '', 'OPER', ''][i], x + 20, y + 1); }); }) }), { p: [0, 0.03, 0.082], to: face, cast: false, receive: false });
K.mesh(new T.PlaneGeometry(0.78, 0.2), paperM(K.tex(312, 80, (g) => { g.fillStyle = '#f6f2e6'; g.fillRect(0, 0, 312, 80); g.strokeStyle = '#8a8474'; g.lineWidth = 3; g.strokeRect(2, 2, 308, 76); g.fillStyle = '#1b2a6b'; g.font = '700 46px ' + HAND; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText('555-0142', 156, 42); }), { roughness: 0.3 }), { p: [0, -0.52, 0.012], to: face, cast: false });
/* the handset across the back, on its two cups */
[-0.74, 0.74].forEach((x) => { K.mesh(new T.CylinderGeometry(0.33, 0.3, 0.07, 28), brownD, { p: [x, 0.86, -0.66], to: ph, cast: false }); K.mesh(new T.CylinderGeometry(0.3, 0.26, 0.3, 28), brown, { p: [x, 1.02, -0.66], to: ph }); });
K.mesh(new T.TubeGeometry(new T.CatmullRomCurve3([[-0.78, 1.1, -0.66], [-0.5, 1.3, -0.66], [0, 1.38, -0.66], [0.5, 1.3, -0.66], [0.78, 1.1, -0.66]].map((p) => new T.Vector3(...p))), 30, 0.135, 12), brown, { s: [1, 1, 1.35], p: [0, 0, 0.231], to: ph });
const cp = []; for (let i = 0; i <= 200; i++) { const u = i / 200, a = u * Math.PI * 2 * 18, x = K.lerp(-1.02, -1.0, u) - Math.sin(u * Math.PI) * 0.75, y = K.lerp(0.98, 0.3, K.smooth(0, 0.35, u)) * (1 - K.smooth(0.25, 0.5, u) * 0.75) + K.smooth(0.8, 1, u) * 0.2, z = K.lerp(-0.66, -0.1, u) + Math.sin(u * Math.PI) * 0.9; cp.push(new T.Vector3(x + Math.cos(a) * 0.055, Math.max(0.06, y) + Math.sin(a) * 0.055, z)); }
K.mesh(new T.TubeGeometry(new T.CatmullRomCurve3(cp), 460, 0.019, 5), brownD, { to: ph, cast: false });
K.mesh(new T.TubeGeometry(new T.CatmullRomCurve3([[0.4, 0.1, -1.12], [0.6, 0.03, -1.5], [1.3, 0.03, -1.7], [2.2, 0.03, -1.5], [2.4, -0.3, -1.4]].map((p) => new T.Vector3(...p))), 40, 0.025, 6), K.std('#b9b09b', 0.6), { to: ph }); K.blob(2.6, 2.6, { p: [6.05, Y0, 3.0], a: 0.2, to: root }); }
/* the printer is at work: fan-fold paper climbs out of it a line at a time and falls away behind */
const feedT = K.tex(512, 600, (g) => { g.clearRect(0, 0, 512, 600); g.fillStyle = '#f8f6ee'; g.fillRect(0, 0, 512, 600); const lh = 600 / 66; for (let l = 0; l < 66; l += 6) { g.fillStyle = BAR; g.fillRect(30, l * lh, 452, lh * 3); } g.fillStyle = '#eceadf'; g.fillRect(0, 0, 28, 600); g.fillRect(484, 0, 28, 600); g.strokeStyle = 'rgba(0,0,0,0.3)'; g.setLineDash([2, 4]); g.lineWidth = 1; g.beginPath(); g.moveTo(29, 0); g.lineTo(29, 600); g.moveTo(483, 0); g.lineTo(483, 600); g.moveTo(0, 1); g.lineTo(512, 1); g.stroke(); g.setLineDash([]);
g.fillStyle = '#2c2c30'; g.font = '700 8.4px ' + K.MONO; g.textBaseline = 'middle'; g.fillText('LEDGER.81 QUARTERLY SUMMARY', 44, lh * 3.5); printRows(g, 44, lh * 6.5, lh, 8.4, 54);
g.globalCompositeOperation = 'destination-out'; for (let y = lh * 1.5; y < 600; y += lh * 3) { g.beginPath(); g.arc(14, y, 5.2, 0, 7); g.arc(498, y, 5.2, 0, 7); g.fill(); } g.globalCompositeOperation = 'source-over'; });
feedT.wrapT = T.RepeatWrapping; feedT.needsUpdate = true;
{ const path = new T.CatmullRomCurve3([[Y0 + 1.1, -2.24], [Y0 + 1.7, -2.3], [Y0 + 2.3, -2.5], [Y0 + 2.62, -2.86], [Y0 + 2.48, -3.26], [Y0 + 1.8, -3.6], [Y0 + 0.9, -3.72], [Y0 - 0.2, -3.7]].map(([y, z]) => new T.Vector3(0, y, z))), N = 60, pts = path.getSpacedPoints(N), L = path.getLength(), W2 = 0.74, PAGE = 1.7, pos = [], uv = [], idx = [];
pts.forEach((p, j) => { pos.push(-W2, p.y, p.z, W2, p.y, p.z); uv.push(0, j / N * L / PAGE, 1, j / N * L / PAGE); if (j < N) { const a = j * 2; idx.push(a, a + 1, a + 2, a + 1, a + 3, a + 2); } });
const fg = new T.BufferGeometry(); fg.setAttribute('position', new T.Float32BufferAttribute(pos, 3)); fg.setAttribute('uv', new T.Float32BufferAttribute(uv, 2)); fg.setIndex(idx); fg.computeVertexNormals();
K.mesh(fg, paperM(feedT, { alphaTest: 0.5, side: T.DoubleSide }), { p: [5.86, 0, 0], to: root, cast: false }); }
let feed = 0;
/* live screen */
const G = '#63ff97', DIM = '#1f7a40';
let lastDraw = -1;
function drawScreen(k, t) {
const fr = Math.floor(t * 12); if (fr === lastDraw) return; lastDraw = fr;
sg.fillStyle = '#020503'; sg.fillRect(0, 0, 640, 480); sg.font = '700 21px ' + K.MONO; sg.textBaseline = 'top'; sg.fillStyle = G;
const blink = fr % 8 < 5, type = (s, p) => s.slice(0, Math.max(0, Math.floor(p * s.length)));
if (k < 0.1) { const p = K.clamp(k / 0.1); sg.fillText('64K RAM 2 DRIVES', 24, 22); if (p > 0.25) sg.fillText('DOS 1.00', 24, 50); if (p > 0.45) sg.fillText('A>' + type('LEDGER', (p - 0.5) / 0.4) + (blink ? '_' : ''), 24, 96); }
else if (k < 0.68) {
const p = (k - 0.1) / 0.58, bump = 1 + 0.06 * Math.floor(p * 6), cw = 92, x0 = 122, y0 = 60, rh = 38, cur = Math.floor(t * 1.6) % 20;
sg.fillStyle = G; sg.fillRect(0, 0, 640, 30); sg.fillStyle = '#020503'; sg.fillText('LEDGER.81 C' + (2 + (cur % 4)) + ' RECALC ' + (fr % 6 < 3 ? '*' : ' '), 12, 4);
const tot = [0, 0, 0, 0], rev = [];
ROWS.forEach((row, r) => { const y = y0 + r * rh; sg.fillStyle = r === 0 ? DIM : G; sg.fillText(row[0], 10, y);
for (let c = 1; c <= 5; c++) { let v = row[c]; const shown = p * 9 > r - 0.4 + c * 0.12;
if (r >= 1 && r <= 5 && c <= 4) { v = Math.round(row[c] * (r === 1 ? bump : 1 + (bump - 1) * 0.4)); if (r === 1) rev[c - 1] = v; else tot[c - 1] += v; }
if (r >= 1 && r <= 5 && c === 5) v = [1, 2, 3, 4].reduce((a, j) => a + Math.round(row[j] * (r === 1 ? bump : 1 + (bump - 1) * 0.4)), 0);
if (r === 6) v = c <= 4 ? tot[c - 1] : tot.reduce((a, b) => a + b, 0);
if (r === 7) v = c <= 4 ? rev[c - 1] - tot[c - 1] : rev.reduce((a, b) => a + b, 0) - tot.reduce((a, b) => a + b, 0);
if (r === 8) { const R2 = c <= 4 ? rev[c - 1] : rev.reduce((a, b) => a + b, 0), C2 = c <= 4 ? tot[c - 1] : tot.reduce((a, b) => a + b, 0); v = ((R2 - C2) / R2 * 100).toFixed(1); }
if (v === undefined || !shown) continue; const s = String(v), x = x0 + c * cw;
const here = r >= 1 && cur === (r - 1) * 4 + (c - 1) % 4 && c <= 4 && r <= 5;
if (here) { sg.fillStyle = G; sg.fillRect(x - cw + 8, y - 4, cw - 6, 30); sg.fillStyle = '#020503'; } else sg.fillStyle = r === 0 ? DIM : G;
sg.textAlign = 'right'; sg.fillText(s, x, y); sg.textAlign = 'left'; } });
sg.fillStyle = DIM; sg.fillRect(0, y0 + 6 * rh - 8, 640, 2); sg.fillRect(x0 + 4.08 * cw, y0 - 6, 2, 9 * rh);
} else { const p = (k - 0.68) / 0.32; sg.fillText('A>' + type('TERM', p / 0.12), 24, 22); if (p > 0.16) sg.fillText(type('ATDT 5550142', (p - 0.16) / 0.2), 24, 68); if (p > 0.42) sg.fillText('RINGING' + '.'.repeat(1 + (fr % 4)), 24, 114); if (p > 0.56) { sg.fillText('CONNECT 300', 24, 160); for (let i = 0; i < 9; i++) { let s = ''; for (let c = 0; c < 44; c++) s += String.fromCharCode(33 + ((fr * 7 + i * 31 + c * 13) % 90)); sg.fillStyle = DIM; sg.fillText(s, 24, 210 + i * 28); } } }
scrT.needsUpdate = true;
}
root.updateMatrixWorld(true);
const sc = new T.Vector3(0, 0, 0.07).applyMatrix4(screen.matrixWorld), sn = new T.Vector3(0, 0, 1).transformDirection(screen.matrixWorld), sx = new T.Vector3(1, 0, 0).transformDirection(screen.matrixWorld).multiplyScalar(SW / 2 * 0.98), sy = new T.Vector3(0, 1, 0).multiplyScalar(SH / 2 * 0.98);
const at = (d, up = 0, sd = 0) => [sc.x + sn.x * d + sx.x * sd, sc.y + up, sc.z + sn.z * d + sx.z * sd];
const kv = new T.Vector3();
const rail = K.rail([
{ k: -0.4, p: [-12, 9.5, 15], l: [1.2, 2.6, 0], f: 37 },
{ k: 0, p: [-10, 8.0, 13], l: [1.0, 2.7, 0], f: 36 },
{ k: 0.34, p: [-5.2, 4.6, 10.8], l: [0.8, 3.0, 0.4] },
{ k: 0.62, p: [3.6, 4.2, 10.2], l: [0.3, 3.1, 0] },
{ k: 0.85, p: at(4.6, 0.25, 0.4), l: [sc.x, sc.y, sc.z], f: 34 },
{ k: 1, p: at(1.25), l: at(-3), f: 30 }
]);
return {
scene, camera, textDepth: 0, outStart: 0.42, irisAt: 0.32, shiftX: 0.17,
portal() { return { c: sc, hx: sx, hy: sy, round: 0.16 }; },
update(k, t, dt, P) {
const kk = K.clamp(k, -0.4, 1), k01 = K.clamp(k, 0, 1);
drawScreen(k01, t); crt.uniforms.uTime.value = t; crt.uniforms.uMix.value = K.smooth(0.25, 0.7, P.kt);
const busy = k01 > 0.03 && k01 < 0.9, hit = Math.floor(t * 9);
keyM.updateMatrixWorld(); keys.forEach((q, i) => { let down = busy && ((hit * 37 + 11) % keys.length === i || (hit * 53 + 29) % keys.length === i) ? 0.045 : 0;
if (P.hot > 0.05) { kv.set(q.x, 0.43, q.z).applyMatrix4(keyM.matrixWorld).project(camera); down = Math.max(down, 0.055 * P.hot * K.smooth(0.07, 0.02, Math.hypot((kv.x - P.nx) * P.aspect, kv.y - P.ny))); }
o3.position.set(q.x, 0.43 - down, q.z); o3.scale.set(q.w * 1.0 + (q.w - 1) * 0.15, 1, 1); o3.rotation.set(0, 0, 0); o3.updateMatrix(); keyM.setMatrixAt(i, o3.matrix); });
keyM.instanceMatrix.needsUpdate = true;
leds[0].material.color.setRGB(((Math.sin(t * 13) > 0.2 && k01 < 0.14) || (k01 > 0.66 && k01 < 0.72)) ? 3 : 0.12, 0.02, 0.01);
leds[1].material.color.setRGB(Math.sin(t * 7 + 1) > 0.86 ? 3 : 0.12, 0.02, 0.01);
steam.material.uniforms.uT.value = t;
if (busy && k01 > 0.1 && k01 < 0.68) feed += dt * 2.4; feedT.offset.y = -(Math.floor(feed) + K.ease(K.clamp((feed % 1) * 2.5))) / 66; note.rotation.x = Math.sin(t * 1.3) * 0.012;
K.aim(camera, rail(kk), P, 1 - K.smooth(0.66, 0.98, k01)); K.faceFlats(flats, camera);
}
};
});