| 28 | } |
| 29 | |
| 30 | async function setupCamera() { |
| 31 | video = document.getElementById('video'); |
| 32 | |
| 33 | const stream = await navigator.mediaDevices.getUserMedia({ |
| 34 | 'audio': false, |
| 35 | 'video': { |
| 36 | facingMode: 'user', |
| 37 | width: videoWidth, |
| 38 | height: videoHeight |
| 39 | }, |
| 40 | }); |
| 41 | video.srcObject = stream; |
| 42 | |
| 43 | await new Promise((resolve) => { |
| 44 | video.onloadedmetadata = () => { |
| 45 | resolve(video); |
| 46 | }; |
| 47 | }); |
| 48 | |
| 49 | video.play(); |
| 50 | video.width = videoWidth; |
| 51 | video.height = videoHeight; |
| 52 | } |
| 53 | |
| 54 | function createStatsPanel() { |
| 55 | stats = new Stats(); |