|
5 | 5 | <title>Calibration parser</title> |
6 | 6 | <style> |
7 | 7 | body { margin: 0; } |
| 8 | + |
| 9 | + .popup { |
| 10 | + position: fixed; |
| 11 | + top: 50%; |
| 12 | + left: 50%; |
| 13 | + transform: translate(-50%, -50%); |
| 14 | + background-color: #303841; |
| 15 | + border-radius: 4px; |
| 16 | + font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; |
| 17 | + color: #EFEFEF; |
| 18 | + overflow: hidden; |
| 19 | + } |
| 20 | + |
| 21 | + .editor { |
| 22 | + font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; |
| 23 | + border: none; |
| 24 | + box-shadow: none; |
| 25 | + outline: none; |
| 26 | + background-color: #303841; |
| 27 | + color: #EFEFEF; |
| 28 | + resize: none; |
| 29 | + margin: 0px; |
| 30 | + } |
8 | 31 | </style> |
9 | 32 | </head> |
10 | 33 | <body style="background-color:black;"> |
11 | 34 |
|
| 35 | + <div class="popup"> |
| 36 | + <div style="background-color: #50565E; padding: 8px"> |
| 37 | + Paste your Mixed Reality calibration below: |
| 38 | + </div> |
| 39 | + <textarea id="calibration-editor" rows="20" cols="80" class="editor" spellcheck="false"> |
| 40 | +{ |
| 41 | + "schemaVersion": 1, |
| 42 | + "camera": { |
| 43 | + "width": 1280, |
| 44 | + "height": 720, |
| 45 | + "fov": 38, |
| 46 | + "position": [0, 1.5, 0], |
| 47 | + "orientation": [0, 0, 0, 1] |
| 48 | + }, |
| 49 | + "chromaKey": { |
| 50 | + "color": [0, 1, 0], |
| 51 | + "similarity": 0.25, |
| 52 | + "smoothness": 0 |
| 53 | + }, |
| 54 | + "delay": 4 |
| 55 | +} |
| 56 | + </textarea> |
| 57 | + <div style="padding: 8px; white-space: pre-wrap; background-color: green;" id="result"></div> |
| 58 | + </div> |
| 59 | + |
12 | 60 | <script async src=" https://unpkg.com/[email protected]/dist/es-module-shims.js" ></script> |
13 | 61 |
|
14 | 62 | <script type="importmap"> |
|
23 | 71 | <script type="module"> |
24 | 72 | import * as MRC from 'reality-mixer'; |
25 | 73 |
|
26 | | - const json = ` |
27 | | - { |
28 | | - "schemaVersion": 1, |
29 | | - "camera": { |
30 | | - "width": 1280, |
31 | | - "height": 720, |
32 | | - "fov": 38, |
33 | | - "position": [0, 1.5, 0], |
34 | | - "orientation": [0, 0, 0, 1] |
35 | | - }, |
36 | | - "chromaKey": { |
37 | | - "color": [0, 1, 0], |
38 | | - "similarity": 0.25, |
39 | | - "smoothness": 0 |
40 | | - }, |
41 | | - "delay": 4 |
42 | | - } |
43 | | - `; |
| 74 | + function validateCalibration() { |
| 75 | + let result = document.getElementById("result"); |
| 76 | + const maybeJson = document.getElementById("calibration-editor").value; |
44 | 77 |
|
45 | | - const calibrationData = JSON.parse( json ); |
| 78 | + try { |
| 79 | + const json = JSON.parse(maybeJson); |
| 80 | + const calibration = MRC.Calibration.fromData(json); |
| 81 | + console.log(calibration); |
46 | 82 |
|
47 | | - const calibration = MRC.Calibration.fromData( calibrationData ); |
48 | | - console.log(calibration); |
| 83 | + result.style.backgroundColor = "green"; |
| 84 | + result.innerText = "Valid"; |
| 85 | + } catch (error) { |
| 86 | + console.log(error); |
| 87 | + result.innerText = error; |
| 88 | + result.style.backgroundColor = "red"; |
| 89 | + } |
| 90 | + } |
| 91 | + |
| 92 | + document.getElementById("calibration-editor").oninput = validateCalibration; |
| 93 | + validateCalibration(); |
49 | 94 | </script> |
| 95 | + |
50 | 96 | </body> |
51 | 97 | </html> |
0 commit comments