Skip to content

Commit 7f981db

Browse files
committed
Updates
1 parent 1db8461 commit 7f981db

1 file changed

Lines changed: 51 additions & 4 deletions

File tree

index.html

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</label>
1919
<br>
2020
<label>
21-
<input type="checkbox" id="fixScalePixel" checked>
21+
<input type="checkbox" id="fixScalePixel">
2222
fix scale (use pixel unit)
2323
</label>
2424
<br>
@@ -39,6 +39,54 @@
3939
<script>
4040
let jsonObject = null;
4141

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+
4290
// Function to handle the uploaded JSON file and apply selected fixes
4391
function handleJson() {
4492
const fileInput = document.getElementById('uploadJson');
@@ -65,12 +113,11 @@
65113

66114
let prefixParts = [];
67115

68-
// Apply scale fixes if checked
116+
// Only one of fixScaleWorld or fixScalePixel can be checked
69117
if (fixScaleWorld) {
70118
obj = fixScale(obj, false);
71119
prefixParts.push('fixed_scale(world_unit)');
72-
}
73-
if (fixScalePixel) {
120+
} else if (fixScalePixel) {
74121
obj = fixScale(obj, true);
75122
prefixParts.push('fixed_scale(pixel_unit)');
76123
}

0 commit comments

Comments
 (0)