add left align (y axis)
This commit is contained in:
parent
b52ab788e5
commit
cff74ef04c
4 changed files with 33 additions and 0 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue