agentcut 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/studio/tools.js +17 -2
  2. package/dist/studio/tools.js.map +1 -1
  3. package/dist/studio/workspace.js +4 -0
  4. package/dist/studio/workspace.js.map +1 -1
  5. package/package.json +1 -1
  6. package/template/components/CATALOG.md +52 -0
  7. package/template/components/README.md +70 -61
  8. package/template/components/STYLES.md +2 -0
  9. package/template/components/catalog.json +477 -0
  10. package/template/components/catalog.ts +4 -0
  11. package/template/components/cinematic/Cinematic.tsx +1139 -0
  12. package/template/components/cinematic/Device3D.tsx +299 -0
  13. package/template/components/cinematic/devices3d/display-model.ts +184 -0
  14. package/template/components/cinematic/devices3d/iphone-model.ts +643 -0
  15. package/template/components/cinematic/devices3d/macbook-model.ts +553 -0
  16. package/template/components/cinematic/devices3d/models.ts +612 -0
  17. package/template/components/cinematic/devices3d/runtime.ts +258 -0
  18. package/template/components/cinematic/math.ts +100 -0
  19. package/template/components/dot-trace-title/DotTraceTitle.tsx +181 -0
  20. package/template/components/dot-trace-title/meta.json +51 -0
  21. package/template/components/generate/GenerateReveal.tsx +381 -0
  22. package/template/components/index.ts +36 -0
  23. package/template/components/lib.ts +18 -6
  24. package/template/components/loops/LoopCanvas.tsx +132 -0
  25. package/template/components/loops/engine.ts +184 -0
  26. package/template/components/loops/library.ts +667 -0
  27. package/template/components/loops/library2.ts +777 -0
  28. package/template/components/motion-loop/MotionLoop.tsx +37 -0
  29. package/template/components/motion-loop/meta.json +312 -0
  30. package/template/runtime/composition.tsx +927 -920
  31. package/template/skill/SKILL.md +20 -3
  32. package/template/skill/references/browser-export.md +61 -61
  33. package/template/skill/references/cinematic.md +171 -0
  34. package/template/skill/references/loops.md +151 -0
  35. package/template/skill/references/performance.md +81 -0
@@ -0,0 +1,553 @@
1
+ import * as THREE from "three";
2
+ import { RoundedBoxGeometry } from "three/examples/jsm/geometries/RoundedBoxGeometry.js";
3
+ import { SVGLoader } from "three/examples/jsm/loaders/SVGLoader.js";
4
+ import { mergeGeometries } from "three/examples/jsm/utils/BufferGeometryUtils.js";
5
+ import {
6
+ APPLE_MARK_SVG,
7
+ createRoundedExtrudedGeometry,
8
+ createRoundedPlaneGeometry,
9
+ } from "./iphone-model";
10
+ const DEFAULT_LAPTOP_LID_ANGLE = 110;
11
+
12
+ /**
13
+ * Procedural 13-inch laptop in the spirit of a MacBook Air. Built from real
14
+ * millimetre proportions, then scaled so the deck is 2 scene units wide.
15
+ *
16
+ * Axes: +x right, +y up, +z toward the viewer. The deck's top surface sits at
17
+ * y = 0 and the lid hinges along its back edge.
18
+ */
19
+
20
+ const MM = 2 / 312.6;
21
+ const mm = (value: number) => value * MM;
22
+
23
+ const BASE = { w: 312.6, d: 221.2, t: 10.4, corner: 10.5 };
24
+ const LID = {
25
+ h: 221.2,
26
+ t: 4.8,
27
+ corner: 10.5,
28
+ glassInset: 1.1,
29
+ bezelSide: 5.6,
30
+ bezelTop: 5.6,
31
+ bezelBottom: 7.6,
32
+ notch: { w: 31, h: 6.4 },
33
+ };
34
+ const KEYBOARD = { pitch: 18.55, gap: 2.35, back: 13, corner: 1.6 };
35
+ const TRACKPAD = { w: 140, h: 82, gap: 10, corner: 7.5 };
36
+
37
+ export const MACBOOK_SCREEN_ASPECT =
38
+ (BASE.w - LID.bezelSide * 2) / (LID.h - LID.bezelTop - LID.bezelBottom);
39
+
40
+
41
+ type KeySpec = [label: string, width: number, kind?: "mod" | "half"];
42
+
43
+ const U = 1;
44
+ const KEY_ROWS: KeySpec[][] = [
45
+ [
46
+ ["esc", 1.5, "mod"],
47
+ ...Array.from(
48
+ { length: 12 },
49
+ (_, index): KeySpec => [`F${index + 1}`, U, "mod"],
50
+ ),
51
+ ["", U],
52
+ ],
53
+ [
54
+ ...["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "="].map(
55
+ (label): KeySpec => [label, U],
56
+ ),
57
+ ["delete", 1.5, "mod"],
58
+ ],
59
+ [
60
+ ["tab", 1.5, "mod"],
61
+ ...[..."QWERTYUIOP", "[", "]", "\\"].map((label): KeySpec => [label, U]),
62
+ ],
63
+ [
64
+ ["caps lock", 1.8, "mod"],
65
+ ...[..."ASDFGHJKL", ";", "'"].map((label): KeySpec => [label, U]),
66
+ ["return", 1.7, "mod"],
67
+ ],
68
+ [
69
+ ["shift", 2.35, "mod"],
70
+ ...[..."ZXCVBNM", ",", ".", "/"].map((label): KeySpec => [label, U]),
71
+ ["shift", 2.15, "mod"],
72
+ ],
73
+ [
74
+ ["fn", U, "mod"],
75
+ ["control", U, "mod"],
76
+ ["option", U, "mod"],
77
+ ["command", 1.25, "mod"],
78
+ ["", 5],
79
+ ["command", 1.25, "mod"],
80
+ ["option", U, "mod"],
81
+ ["◀", U, "half"],
82
+ ["▲▼", U, "half"],
83
+ ["▶", U, "half"],
84
+ ],
85
+ ];
86
+
87
+ interface KeyRect {
88
+ label: string;
89
+ kind?: "mod" | "half";
90
+ x: number;
91
+ z: number;
92
+ w: number;
93
+ d: number;
94
+ }
95
+
96
+ function layoutKeys() {
97
+ const { pitch, gap, back } = KEYBOARD;
98
+ const rowWidth = 14.5 * pitch - gap;
99
+ const keys: KeyRect[] = [];
100
+ let z = -BASE.d / 2 + back;
101
+ KEY_ROWS.forEach((row, rowIndex) => {
102
+ const rowDepth = rowIndex === 0 ? pitch * 0.55 : pitch;
103
+ let x = -rowWidth / 2;
104
+ for (const [label, width, kind] of row) {
105
+ const keyWidth = width * pitch - gap;
106
+ const keyDepth = rowDepth - gap;
107
+ if (kind === "half") {
108
+ if (label === "▲▼") {
109
+ const half = (keyDepth - gap * 0.5) / 2;
110
+ keys.push({ label: "▲", kind, x, z, w: keyWidth, d: half });
111
+ keys.push({
112
+ label: "▼",
113
+ kind,
114
+ x,
115
+ z: z + half + gap * 0.5,
116
+ w: keyWidth,
117
+ d: half,
118
+ });
119
+ } else {
120
+ const half = (keyDepth - gap * 0.5) / 2;
121
+ keys.push({
122
+ label,
123
+ kind,
124
+ x,
125
+ z: z + half + gap * 0.5,
126
+ w: keyWidth,
127
+ d: half,
128
+ });
129
+ }
130
+ } else {
131
+ keys.push({ label, kind, x, z, w: keyWidth, d: keyDepth });
132
+ }
133
+ x += width * pitch;
134
+ }
135
+ z += rowDepth;
136
+ });
137
+ return { keys, rowWidth, depth: z - (-BASE.d / 2 + back) };
138
+ }
139
+
140
+ function createCanvas(width: number, height: number) {
141
+ if (typeof OffscreenCanvas !== "undefined") {
142
+ return new OffscreenCanvas(width, height);
143
+ }
144
+ if (typeof document !== "undefined") {
145
+ const canvas = document.createElement("canvas");
146
+ canvas.width = width;
147
+ canvas.height = height;
148
+ return canvas;
149
+ }
150
+ return null;
151
+ }
152
+
153
+ /** Key legends painted once into a texture laid over the keycaps. */
154
+ function createLegendTexture(
155
+ keys: KeyRect[],
156
+ bounds: { x: number; z: number; w: number; d: number },
157
+ ) {
158
+ const pxPerMm = 9;
159
+ const width = Math.ceil(bounds.w * pxPerMm);
160
+ const height = Math.ceil(bounds.d * pxPerMm);
161
+ const canvas = createCanvas(width, height);
162
+ const context = canvas?.getContext("2d") as
163
+ | CanvasRenderingContext2D
164
+ | OffscreenCanvasRenderingContext2D
165
+ | null
166
+ | undefined;
167
+ if (!canvas || !context) return null;
168
+ context.clearRect(0, 0, width, height);
169
+ context.fillStyle = "rgba(236, 238, 242, 0.92)";
170
+ context.textBaseline = "middle";
171
+ for (const key of keys) {
172
+ if (!key.label) continue;
173
+ const left = (key.x - bounds.x) * pxPerMm;
174
+ const top = (key.z - bounds.z) * pxPerMm;
175
+ const keyWidth = key.w * pxPerMm;
176
+ const keyDepth = key.d * pxPerMm;
177
+ if (key.kind === "mod") {
178
+ context.font = `500 ${Math.round(2.3 * pxPerMm)}px -apple-system, "SF Pro Text", "Helvetica Neue", Arial, sans-serif`;
179
+ context.textAlign = "left";
180
+ context.fillText(
181
+ key.label,
182
+ left + 1.6 * pxPerMm,
183
+ top + keyDepth - 2.4 * pxPerMm,
184
+ keyWidth - 3 * pxPerMm,
185
+ );
186
+ } else {
187
+ const fontSize = key.kind === "half" ? 2.4 : 3.6;
188
+ context.font = `500 ${Math.round(fontSize * pxPerMm)}px -apple-system, "SF Pro Text", "Helvetica Neue", Arial, sans-serif`;
189
+ context.textAlign = "center";
190
+ context.fillText(
191
+ key.label,
192
+ left + keyWidth / 2,
193
+ top + keyDepth / 2,
194
+ keyWidth - 2 * pxPerMm,
195
+ );
196
+ }
197
+ }
198
+ const texture = new THREE.CanvasTexture(canvas as HTMLCanvasElement);
199
+ texture.colorSpace = THREE.SRGBColorSpace;
200
+ texture.anisotropy = 4;
201
+ return texture;
202
+ }
203
+
204
+ function createFlatRoundedRect(width: number, depth: number, radius: number) {
205
+ const geometry = createRoundedPlaneGeometry(width, depth, radius);
206
+ geometry.rotateX(-Math.PI / 2);
207
+ return geometry;
208
+ }
209
+
210
+ function createLogoGeometry(width: number) {
211
+ const svg = new SVGLoader().parse(APPLE_MARK_SVG);
212
+ const shapes = svg.paths.flatMap((path) => SVGLoader.createShapes(path));
213
+ const geometry = new THREE.ShapeGeometry(shapes, 32);
214
+ geometry.center();
215
+ const scale = width / 814;
216
+ geometry.scale(scale, -scale, 1);
217
+ return geometry;
218
+ }
219
+
220
+ function createMaterials(finishColor: THREE.ColorRepresentation) {
221
+ const finish = new THREE.Color(finishColor);
222
+ const { l: lightness } = finish.getHSL({ h: 0, s: 0, l: 0 });
223
+ const isDark = lightness < 0.35;
224
+ return {
225
+ aluminum: new THREE.MeshPhysicalMaterial({
226
+ color: finish,
227
+ metalness: 0.92,
228
+ roughness: 0.4,
229
+ clearcoat: 0.12,
230
+ clearcoatRoughness: 0.5,
231
+ }),
232
+ edge: new THREE.MeshPhysicalMaterial({
233
+ color: finish.clone().lerp(new THREE.Color(0xffffff), isDark ? 0.08 : 0.2),
234
+ metalness: 1,
235
+ roughness: 0.22,
236
+ }),
237
+ trackpad: new THREE.MeshPhysicalMaterial({
238
+ color: finish.clone().lerp(new THREE.Color(0x000000), 0.04),
239
+ metalness: 0.55,
240
+ roughness: 0.3,
241
+ clearcoat: 0.6,
242
+ clearcoatRoughness: 0.18,
243
+ }),
244
+ well: new THREE.MeshStandardMaterial({
245
+ color: 0x050506,
246
+ roughness: 0.85,
247
+ metalness: 0,
248
+ userData: { envMapIntensity: 0.1 },
249
+ }),
250
+ key: new THREE.MeshPhysicalMaterial({
251
+ color: 0x0c0c0e,
252
+ roughness: 0.62,
253
+ metalness: 0.05,
254
+ clearcoat: 0.08,
255
+ userData: { envMapIntensity: 0.3 },
256
+ }),
257
+ legends: new THREE.MeshBasicMaterial({
258
+ transparent: true,
259
+ depthWrite: false,
260
+ toneMapped: false,
261
+ }),
262
+ glass: new THREE.MeshBasicMaterial({ color: 0x030405 }),
263
+ notch: new THREE.MeshBasicMaterial({ color: 0x030304 }),
264
+ lens: new THREE.MeshPhysicalMaterial({
265
+ color: 0x10162a,
266
+ roughness: 0.05,
267
+ metalness: 0.3,
268
+ clearcoat: 1,
269
+ }),
270
+ hinge: new THREE.MeshPhysicalMaterial({
271
+ color: finish.clone().lerp(new THREE.Color(0x000000), 0.45),
272
+ metalness: 0.8,
273
+ roughness: 0.35,
274
+ }),
275
+ rubber: new THREE.MeshStandardMaterial({ color: 0x18181a, roughness: 0.9 }),
276
+ logo: new THREE.MeshPhysicalMaterial({
277
+ color: finish
278
+ .clone()
279
+ .lerp(new THREE.Color(isDark ? 0xffffff : 0x000000), isDark ? 0.2 : 0.45),
280
+ metalness: 1,
281
+ roughness: 0.05,
282
+ side: THREE.DoubleSide,
283
+ }),
284
+ screenOff: new THREE.MeshBasicMaterial({ color: 0x050608 }),
285
+ };
286
+ }
287
+
288
+ export interface MacbookModelOptions {
289
+ screenMaterial?: THREE.Material;
290
+ finishColor?: THREE.ColorRepresentation;
291
+ lidAngle?: number;
292
+ }
293
+
294
+ export function createMacbookModel(options: MacbookModelOptions = {}) {
295
+ const root = new THREE.Group();
296
+ root.name = "procedural-macbook";
297
+ const materials = createMaterials(options.finishColor ?? 0xcfd1d3);
298
+ const add = (
299
+ name: string,
300
+ mesh: THREE.Mesh,
301
+ parent: THREE.Object3D = root,
302
+ ) => {
303
+ mesh.name = name;
304
+ mesh.castShadow = true;
305
+ mesh.receiveShadow = true;
306
+ parent.add(mesh);
307
+ return mesh;
308
+ };
309
+
310
+ // ── Deck ─────────────────────────────────────────────────────────────
311
+ const baseGeometry = createRoundedExtrudedGeometry(
312
+ mm(BASE.w),
313
+ mm(BASE.d),
314
+ mm(BASE.corner),
315
+ mm(BASE.t - 1.2),
316
+ mm(0.6),
317
+ mm(0.6),
318
+ );
319
+ baseGeometry.rotateX(-Math.PI / 2);
320
+ const base = add("laptop-base", new THREE.Mesh(baseGeometry, materials.aluminum));
321
+ base.position.y = -mm(BASE.t) / 2;
322
+
323
+ // Chamfered rim catching a bright highlight around the deck.
324
+ const rim = add(
325
+ "laptop-deck-rim",
326
+ new THREE.Mesh(
327
+ createFlatRoundedRect(mm(BASE.w - 0.8), mm(BASE.d - 0.8), mm(BASE.corner)),
328
+ materials.edge,
329
+ ),
330
+ );
331
+ rim.position.y = mm(0.12);
332
+ const deckTop = add(
333
+ "laptop-deck-top",
334
+ new THREE.Mesh(
335
+ createFlatRoundedRect(mm(BASE.w - 2.2), mm(BASE.d - 2.2), mm(BASE.corner - 1)),
336
+ materials.aluminum,
337
+ ),
338
+ );
339
+ deckTop.position.y = mm(0.24);
340
+
341
+ // ── Keyboard ─────────────────────────────────────────────────────────
342
+ const { keys, rowWidth, depth } = layoutKeys();
343
+ const keyboardBounds = {
344
+ x: -rowWidth / 2 - 1.2,
345
+ z: -BASE.d / 2 + KEYBOARD.back - 1.2,
346
+ w: rowWidth + 2.4,
347
+ d: depth - KEYBOARD.gap + 2.4,
348
+ };
349
+ const well = add(
350
+ "laptop-keyboard-well",
351
+ new THREE.Mesh(
352
+ createFlatRoundedRect(
353
+ mm(keyboardBounds.w),
354
+ mm(keyboardBounds.d),
355
+ mm(2.4),
356
+ ),
357
+ materials.well,
358
+ ),
359
+ );
360
+ well.position.set(
361
+ mm(keyboardBounds.x + keyboardBounds.w / 2),
362
+ mm(0.4),
363
+ mm(keyboardBounds.z + keyboardBounds.d / 2),
364
+ );
365
+
366
+ const keyHeight = 0.9;
367
+ const keyGeometries = keys.map((key) => {
368
+ const geometry = new RoundedBoxGeometry(
369
+ mm(key.w),
370
+ mm(keyHeight),
371
+ mm(key.d),
372
+ 2,
373
+ mm(Math.min(KEYBOARD.corner, key.d / 2.2, key.w / 2.2)),
374
+ );
375
+ geometry.translate(
376
+ mm(key.x + key.w / 2),
377
+ mm(keyHeight / 2 + 0.45),
378
+ mm(key.z + key.d / 2),
379
+ );
380
+ return geometry;
381
+ });
382
+ const keysGeometry = mergeGeometries(keyGeometries, false);
383
+ keyGeometries.forEach((geometry) => geometry.dispose());
384
+ if (keysGeometry) add("laptop-keys", new THREE.Mesh(keysGeometry, materials.key));
385
+
386
+ const legendTexture = createLegendTexture(keys, keyboardBounds);
387
+ if (legendTexture) {
388
+ materials.legends.map = legendTexture;
389
+ const legends = add(
390
+ "laptop-key-legends",
391
+ new THREE.Mesh(
392
+ new THREE.PlaneGeometry(mm(keyboardBounds.w), mm(keyboardBounds.d)).rotateX(
393
+ -Math.PI / 2,
394
+ ),
395
+ materials.legends,
396
+ ),
397
+ );
398
+ legends.castShadow = false;
399
+ legends.position.set(
400
+ mm(keyboardBounds.x + keyboardBounds.w / 2),
401
+ mm(keyHeight + 0.6),
402
+ mm(keyboardBounds.z + keyboardBounds.d / 2),
403
+ );
404
+ legends.renderOrder = 2;
405
+ }
406
+
407
+ // ── Trackpad and front lip ──────────────────────────────────────────
408
+ const trackpadCenterZ =
409
+ keyboardBounds.z + keyboardBounds.d + TRACKPAD.gap + TRACKPAD.h / 2;
410
+ const trackpad = add(
411
+ "laptop-trackpad",
412
+ new THREE.Mesh(
413
+ createFlatRoundedRect(mm(TRACKPAD.w), mm(TRACKPAD.h), mm(TRACKPAD.corner)),
414
+ materials.trackpad,
415
+ ),
416
+ );
417
+ trackpad.position.set(0, mm(0.4), mm(trackpadCenterZ));
418
+
419
+ const notchGeometry = new THREE.CylinderGeometry(
420
+ mm(14),
421
+ mm(14),
422
+ mm(1.4),
423
+ 48,
424
+ 1,
425
+ false,
426
+ Math.PI / 2,
427
+ Math.PI,
428
+ );
429
+ notchGeometry.scale(1, 1, 0.22);
430
+ const thumbNotch = add(
431
+ "laptop-thumb-notch",
432
+ new THREE.Mesh(notchGeometry, materials.hinge),
433
+ );
434
+ thumbNotch.position.set(0, -mm(0.6), mm(BASE.d / 2 + 0.25));
435
+
436
+ // ── Feet ─────────────────────────────────────────────────────────────
437
+ const footGeometry = new THREE.CylinderGeometry(mm(6), mm(6.5), mm(1.3), 32);
438
+ for (const x of [-1, 1]) {
439
+ for (const z of [-1, 1]) {
440
+ const foot = add("laptop-foot", new THREE.Mesh(footGeometry, materials.rubber));
441
+ foot.position.set(
442
+ x * mm(BASE.w / 2 - 24),
443
+ -mm(BASE.t) - mm(0.5),
444
+ z * mm(BASE.d / 2 - 24),
445
+ );
446
+ }
447
+ }
448
+
449
+ // ── Hinge and lid ───────────────────────────────────────────────────
450
+ const hingeZ = -mm(BASE.d / 2) + mm(3.2);
451
+ const hingeY = mm(1.2);
452
+ const hinge = add(
453
+ "laptop-hinge",
454
+ new THREE.Mesh(
455
+ new THREE.CylinderGeometry(mm(3.4), mm(3.4), mm(BASE.w - 72), 32).rotateZ(
456
+ Math.PI / 2,
457
+ ),
458
+ materials.hinge,
459
+ ),
460
+ );
461
+ hinge.position.set(0, -mm(1.8), hingeZ - mm(1.4));
462
+
463
+ const lid = new THREE.Group();
464
+ lid.name = "laptop-lid-pivot";
465
+ lid.position.set(0, hingeY, hingeZ);
466
+ root.add(lid);
467
+
468
+ const lidBevel = mm(0.5);
469
+ const lidGeometry = createRoundedExtrudedGeometry(
470
+ mm(BASE.w),
471
+ mm(LID.h),
472
+ mm(LID.corner),
473
+ mm(LID.t) - lidBevel * 2,
474
+ lidBevel,
475
+ lidBevel,
476
+ );
477
+ const lidShell = add(
478
+ "laptop-lid",
479
+ new THREE.Mesh(lidGeometry, materials.aluminum),
480
+ lid,
481
+ );
482
+ lidShell.position.set(0, mm(LID.h / 2), -mm(LID.t / 2));
483
+
484
+ const glass = add(
485
+ "laptop-display-glass",
486
+ new THREE.Mesh(
487
+ createRoundedPlaneGeometry(
488
+ mm(BASE.w - LID.glassInset * 2),
489
+ mm(LID.h - LID.glassInset * 2),
490
+ mm(LID.corner - LID.glassInset),
491
+ ),
492
+ materials.glass,
493
+ ),
494
+ lid,
495
+ );
496
+ glass.position.set(0, mm(LID.h / 2), mm(0.25));
497
+
498
+ const screenWidth = BASE.w - LID.bezelSide * 2;
499
+ const screenHeight = LID.h - LID.bezelTop - LID.bezelBottom;
500
+ const screen = add(
501
+ "display-surface",
502
+ new THREE.Mesh(
503
+ createRoundedPlaneGeometry(mm(screenWidth), mm(screenHeight), mm(4.2)),
504
+ options.screenMaterial ?? materials.screenOff,
505
+ ),
506
+ lid,
507
+ );
508
+ screen.position.set(0, mm(LID.bezelBottom + screenHeight / 2), mm(0.5));
509
+ screen.castShadow = false;
510
+
511
+ const notch = add(
512
+ "laptop-camera-notch",
513
+ new THREE.Mesh(
514
+ createRoundedPlaneGeometry(mm(LID.notch.w), mm(LID.notch.h + 4), mm(2.6)),
515
+ materials.notch,
516
+ ),
517
+ lid,
518
+ );
519
+ notch.position.set(
520
+ 0,
521
+ mm(LID.bezelBottom + screenHeight - LID.notch.h / 2 + 2),
522
+ mm(0.75),
523
+ );
524
+ const lens = add(
525
+ "laptop-camera-lens",
526
+ new THREE.Mesh(new THREE.CircleGeometry(mm(1.1), 24), materials.lens),
527
+ lid,
528
+ );
529
+ lens.position.set(0, mm(LID.bezelBottom + screenHeight + 2), mm(0.85));
530
+
531
+ const logo = add(
532
+ "laptop-lid-logo",
533
+ new THREE.Mesh(createLogoGeometry(mm(26)), materials.logo),
534
+ lid,
535
+ );
536
+ logo.rotation.y = Math.PI;
537
+ logo.position.set(0, mm(LID.h * 0.53), -mm(LID.t) - mm(0.3));
538
+
539
+ setMacbookLidAngle(root, options.lidAngle ?? DEFAULT_LAPTOP_LID_ANGLE);
540
+ return root;
541
+ }
542
+
543
+ /** Works on clones too, since it looks the hinge up by name. */
544
+ export function setMacbookLidAngle(root: THREE.Object3D, degrees: number) {
545
+ const lid = root.getObjectByName("laptop-lid-pivot");
546
+ if (!lid) return;
547
+ const clamped = THREE.MathUtils.clamp(degrees, 0, 140);
548
+ lid.rotation.x = THREE.MathUtils.degToRad(90 - clamped);
549
+ }
550
+
551
+ export function isMacbookModel(root: THREE.Object3D) {
552
+ return Boolean(root.getObjectByName("laptop-lid-pivot"));
553
+ }