add left align (y axis)

This commit is contained in:
Stewart Allen 2025-10-26 19:17:03 -04:00
commit cff74ef04c
4 changed files with 33 additions and 0 deletions

View file

@ -1784,6 +1784,7 @@ function init_two() {
$('context-duplicate').onclick = duplicateSelection;
$('context-mirror').onclick = mirrorSelection;
$('context-layflat').onclick = () => { api.event.emit("tool.mesh.lay-flat") };
$('context-lefty').onclick = () => { api.event.emit("tool.mesh.lefty") };
$('context-setfocus').onclick = () => {
api.event.emit(
"tool.camera.focus",

View file

@ -49,6 +49,24 @@ function onLayFlatSelect() {
// endIt();
}
function onLeftySelect() {
// Project the face normal onto the XY plane (ignore Z component)
let projectedNormal = new Vector3(lastface.normal.x, lastface.normal.y, 0).normalize();
// Target direction on XY plane (negative Y axis)
let targetDir = new Vector3(0, -1, 0);
// Calculate angle between projected normal and target
let angle = Math.atan2(
projectedNormal.x * targetDir.y - projectedNormal.y * targetDir.x, // cross product Z component
projectedNormal.x * targetDir.x + projectedNormal.y * targetDir.y // dot product
);
// Create quaternion for Z-axis rotation only
let q = new Quaternion().setFromAxisAngle(ZAXIS, angle);
api.selection.rotate(q);
}
function onFaceUpSelect() {
api.event.emit('tool.mesh.face-normal', lastface.normal);
// endIt();
@ -105,6 +123,12 @@ api.event.on('tool.mesh.lay-flat', () => {
startIt();
});
api.event.on('tool.mesh.lefty', () => {
opName = 'align y axis';
onDone = onLeftySelect;
startIt();
});
function scale() {
let cam = space.internals().camera;
let dist = cam.position.distanceTo(pmesh.position);

View file

@ -213,6 +213,10 @@ details[open] summary::after {
transform: rotate(90deg);
}
.rot90 {
transform: rotate(90deg);
}
/* for bambu mgr dialog */
.video {
border: 1px solid #888;

View file

@ -304,6 +304,10 @@
<i class="fas fa-arrows-down-to-line"></i>
<div class="pop">choose a face to place<br>on the work surface</div>
</span>
<span id="context-lefty" xlk="rc_lafl">
<i class="fas fa-arrows-down-to-line rot90"></i>
<div class="pop">choose a face to align<br>to the y axis</div>
</span>
<span id="context-setfocus" xlk="rc_focs">
<i class="fas fa-eye"></i>
<div class="pop">choose focal point<br>camera orbit center</div>