Spaces:
Running
Running
Update index.html
Browse files- index.html +4 -30
index.html
CHANGED
@@ -80,7 +80,7 @@
|
|
80 |
width: 100%; padding: 6px; font-size: 14px; border-radius: 4px; border: 1px solid #ccc; }
|
81 |
#editPanel button, #connectionPanel button { margin-top: 10px; }
|
82 |
|
83 |
-
/* Bottom Bar for
|
84 |
#bottomBar {
|
85 |
position: fixed;
|
86 |
bottom: 0;
|
@@ -90,13 +90,10 @@
|
|
90 |
padding: 10px 20px;
|
91 |
z-index: 1000;
|
92 |
display: flex;
|
93 |
-
justify-content:
|
94 |
align-items: center;
|
95 |
box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
|
96 |
-
disply:none;
|
97 |
}
|
98 |
-
#dataDisplay { flex: 1; font-size: 14px; }
|
99 |
-
#dataDisplay h3 { margin: 0 0 5px; font-size: 16px; }
|
100 |
#constraintEditPanel { flex: 0 0 300px; display: none; }
|
101 |
#constraintEditPanel h3 { margin: 0 0 10px; font-size: 16px; }
|
102 |
#constraintEditPanel label { display: block; margin: 10px 0 5px; font-size: 14px; }
|
@@ -152,12 +149,8 @@
|
|
152 |
</div>
|
153 |
</div>
|
154 |
|
155 |
-
<!-- Bottom Bar for
|
156 |
<div id="bottomBar">
|
157 |
-
<div id="dataDisplay">
|
158 |
-
<h3>Real-Time Data</h3>
|
159 |
-
<p id="dataContent">Select an element to view data.</p>
|
160 |
-
</div>
|
161 |
<div id="constraintEditPanel">
|
162 |
<h3>Edit Constraint</h3>
|
163 |
<label for="consA_X">Endpoint A X:</label>
|
@@ -219,8 +212,7 @@
|
|
219 |
rightSidebar = document.getElementById('rightSidebar'),
|
220 |
editPanel = document.getElementById('editPanel'),
|
221 |
connectionPanel = document.getElementById('connectionPanel'),
|
222 |
-
constraintEditPanel = document.getElementById('constraintEditPanel')
|
223 |
-
dataContent = document.getElementById('dataContent');
|
224 |
|
225 |
function getRandomColor() { return '#' + Math.floor(Math.random() * 16777215).toString(16); }
|
226 |
|
@@ -408,7 +400,6 @@
|
|
408 |
hideEditPanel();
|
409 |
hideConnectionPanel();
|
410 |
hideConstraintEditPanel();
|
411 |
-
dataContent.textContent = "Select an element to view data.";
|
412 |
});
|
413 |
|
414 |
function openEditPanel(body) {
|
@@ -560,23 +551,6 @@
|
|
560 |
}
|
561 |
});
|
562 |
|
563 |
-
Events.on(engine, 'afterUpdate', () => {
|
564 |
-
if (selectedBody && !selectedBody.isStatic) {
|
565 |
-
const v = selectedBody.velocity;
|
566 |
-
const ke = 0.5 * selectedBody.mass * (v.x * v.x + v.y * v.y);
|
567 |
-
const pe = selectedBody.elementType === "springMass" ?
|
568 |
-
0.5 * selectedBody.constraints[0].stiffness * Math.pow(Vector.magnitude(Vector.sub(selectedBody.position, selectedBody.fixedPoint)) - selectedBody.customOptions.length, 2) :
|
569 |
-
selectedBody.mass * engine.gravity.y * (window.innerHeight - selectedBody.position.y);
|
570 |
-
dataContent.innerHTML = `
|
571 |
-
Position: (${selectedBody.position.x.toFixed(1)}, ${selectedBody.position.y.toFixed(1)}) m<br>
|
572 |
-
Velocity: (${v.x.toFixed(1)}, ${v.y.toFixed(1)}) m/s<br>
|
573 |
-
Kinetic Energy: ${ke.toFixed(2)} J<br>
|
574 |
-
Potential Energy: ${pe.toFixed(2)} J<br>
|
575 |
-
Total Energy: ${(ke + pe).toFixed(2)} J
|
576 |
-
`;
|
577 |
-
}
|
578 |
-
});
|
579 |
-
|
580 |
window.addEventListener('resize', () => {
|
581 |
render.canvas.width = window.innerWidth;
|
582 |
render.canvas.height = window.innerHeight;
|
|
|
80 |
width: 100%; padding: 6px; font-size: 14px; border-radius: 4px; border: 1px solid #ccc; }
|
81 |
#editPanel button, #connectionPanel button { margin-top: 10px; }
|
82 |
|
83 |
+
/* Bottom Bar for Constraint Edit */
|
84 |
#bottomBar {
|
85 |
position: fixed;
|
86 |
bottom: 0;
|
|
|
90 |
padding: 10px 20px;
|
91 |
z-index: 1000;
|
92 |
display: flex;
|
93 |
+
justify-content: flex-end;
|
94 |
align-items: center;
|
95 |
box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
|
|
|
96 |
}
|
|
|
|
|
97 |
#constraintEditPanel { flex: 0 0 300px; display: none; }
|
98 |
#constraintEditPanel h3 { margin: 0 0 10px; font-size: 16px; }
|
99 |
#constraintEditPanel label { display: block; margin: 10px 0 5px; font-size: 14px; }
|
|
|
149 |
</div>
|
150 |
</div>
|
151 |
|
152 |
+
<!-- Bottom Bar for Constraints -->
|
153 |
<div id="bottomBar">
|
|
|
|
|
|
|
|
|
154 |
<div id="constraintEditPanel">
|
155 |
<h3>Edit Constraint</h3>
|
156 |
<label for="consA_X">Endpoint A X:</label>
|
|
|
212 |
rightSidebar = document.getElementById('rightSidebar'),
|
213 |
editPanel = document.getElementById('editPanel'),
|
214 |
connectionPanel = document.getElementById('connectionPanel'),
|
215 |
+
constraintEditPanel = document.getElementById('constraintEditPanel');
|
|
|
216 |
|
217 |
function getRandomColor() { return '#' + Math.floor(Math.random() * 16777215).toString(16); }
|
218 |
|
|
|
400 |
hideEditPanel();
|
401 |
hideConnectionPanel();
|
402 |
hideConstraintEditPanel();
|
|
|
403 |
});
|
404 |
|
405 |
function openEditPanel(body) {
|
|
|
551 |
}
|
552 |
});
|
553 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
554 |
window.addEventListener('resize', () => {
|
555 |
render.canvas.width = window.innerWidth;
|
556 |
render.canvas.height = window.innerHeight;
|