The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { PerspectiveCamera, Texture, Vector3 } from "three"; |
| 2 | import { describe, expect, it } from "vite-plus/test"; |
| 3 | import { createAndroidFoldScene } from "./androidFoldScene.ts"; |
| 4 | import { phoneDisplayLayout } from "./phoneScene.ts"; |
| 5 | |
| 6 | describe("Android fold scene", () => { |
| 7 | it("maps touches on each open half and the closed cover to the live frame", () => { |
| 8 | const texture = new Texture(); |
| 9 | const scene = createAndroidFoldScene(texture, phoneDisplayLayout(null, 2200, 1840), 180); |
| 10 | const camera = new PerspectiveCamera(32, 1, 0.1, 30); |
| 11 | camera.position.z = 6; |
| 12 | camera.updateMatrixWorld(true); |
| 13 | const project = (x: number) => { |
| 14 | const point = new Vector3(x, 0, 0.041).project(camera); |
| 15 | return scene.screenPoint((point.x + 1) / 2, (1 - point.y) / 2, camera); |
| 16 | }; |
| 17 | expect(project(-0.52)?.x).toBeCloseTo(0.25, 1); |
| 18 | expect(project(0.52)?.x).toBeCloseTo(0.75, 1); |
| 19 | expect(scene.screenPoint(0.99, 0.5, camera, true)?.x).toBe(1); |
| 20 | scene.setAngle(0); |
| 21 | expect(project(0.52)?.x).toBeCloseTo(0.5, 1); |
| 22 | scene.dispose(); |
| 23 | texture.dispose(); |
| 24 | }); |
| 25 | }); |