|
18 | 18 | </label> |
19 | 19 | <br> |
20 | 20 | <label> |
21 | | - <input type="checkbox" id="fixScalePixel" checked> |
| 21 | + <input type="checkbox" id="fixScalePixel"> |
22 | 22 | fix scale (use pixel unit) |
23 | 23 | </label> |
24 | 24 | <br> |
|
39 | 39 | <script> |
40 | 40 | let jsonObject = null; |
41 | 41 |
|
| 42 | + // Enforce only one of fixScaleWorld or fixScalePixel can be checked |
| 43 | + function enforceScaleCheckboxes(changedId) { |
| 44 | + const fixScaleWorld = document.getElementById('fixScaleWorld'); |
| 45 | + const fixScalePixel = document.getElementById('fixScalePixel'); |
| 46 | + if (changedId === 'fixScaleWorld' && fixScaleWorld.checked) { |
| 47 | + fixScalePixel.checked = false; |
| 48 | + } else if (changedId === 'fixScalePixel' && fixScalePixel.checked) { |
| 49 | + fixScaleWorld.checked = false; |
| 50 | + } else if (!fixScaleWorld.checked && !fixScalePixel.checked) { |
| 51 | + // Always keep at least one checked, default to world |
| 52 | + fixScaleWorld.checked = true; |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + // Enforce moveUpHalfDepth can only be checked if fixFixture is checked |
| 57 | + function enforceMoveUpHalfDepth() { |
| 58 | + const fixFixture = document.getElementById('fixFixture'); |
| 59 | + const moveUpHalfDepth = document.getElementById('moveUpHalfDepth'); |
| 60 | + if (!fixFixture.checked) { |
| 61 | + moveUpHalfDepth.checked = false; |
| 62 | + moveUpHalfDepth.disabled = true; |
| 63 | + } else { |
| 64 | + moveUpHalfDepth.disabled = false; |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | + // Attach event listeners after DOM is loaded |
| 69 | + window.addEventListener('DOMContentLoaded', function () { |
| 70 | + const fixScaleWorld = document.getElementById('fixScaleWorld'); |
| 71 | + const fixScalePixel = document.getElementById('fixScalePixel'); |
| 72 | + const fixFixture = document.getElementById('fixFixture'); |
| 73 | + const moveUpHalfDepth = document.getElementById('moveUpHalfDepth'); |
| 74 | + |
| 75 | + fixScaleWorld.addEventListener('change', function () { |
| 76 | + enforceScaleCheckboxes('fixScaleWorld'); |
| 77 | + }); |
| 78 | + fixScalePixel.addEventListener('change', function () { |
| 79 | + enforceScaleCheckboxes('fixScalePixel'); |
| 80 | + }); |
| 81 | + |
| 82 | + fixFixture.addEventListener('change', function () { |
| 83 | + enforceMoveUpHalfDepth(); |
| 84 | + }); |
| 85 | + |
| 86 | + // Initial state for moveUpHalfDepth |
| 87 | + enforceMoveUpHalfDepth(); |
| 88 | + }); |
| 89 | + |
42 | 90 | // Function to handle the uploaded JSON file and apply selected fixes |
43 | 91 | function handleJson() { |
44 | 92 | const fileInput = document.getElementById('uploadJson'); |
|
65 | 113 |
|
66 | 114 | let prefixParts = []; |
67 | 115 |
|
68 | | - // Apply scale fixes if checked |
| 116 | + // Only one of fixScaleWorld or fixScalePixel can be checked |
69 | 117 | if (fixScaleWorld) { |
70 | 118 | obj = fixScale(obj, false); |
71 | 119 | prefixParts.push('fixed_scale(world_unit)'); |
72 | | - } |
73 | | - if (fixScalePixel) { |
| 120 | + } else if (fixScalePixel) { |
74 | 121 | obj = fixScale(obj, true); |
75 | 122 | prefixParts.push('fixed_scale(pixel_unit)'); |
76 | 123 | } |
|
0 commit comments