Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -128,9 +128,31 @@ export function pushCubeFace(dirWorld: THREE.Vector3) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
// Auto-rotate the main camera to look straight at the picked cube face
|
||||
// so the user sees the corresponding model face head-on (especially helpful
|
||||
// in orthographic mode where this guarantees a perpendicular click).
|
||||
try { requestView(dirWorld.clone()); } catch {}
|
||||
notify();
|
||||
}
|
||||
|
||||
/** Snap a unit vector to the nearest principal axis (±X/±Y/±Z) when within
|
||||
* `maxDeg` degrees of it. Returns the snapped vector or the input unchanged. */
|
||||
function snapToPrincipalAxis(v: THREE.Vector3, maxDeg = 12): THREE.Vector3 {
|
||||
const cosT = Math.cos(THREE.MathUtils.degToRad(maxDeg));
|
||||
const axes = [
|
||||
new THREE.Vector3(1, 0, 0), new THREE.Vector3(-1, 0, 0),
|
||||
new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, -1, 0),
|
||||
new THREE.Vector3(0, 0, 1), new THREE.Vector3(0, 0,-1),
|
||||
];
|
||||
let best = v;
|
||||
let bestDot = cosT;
|
||||
for (const a of axes) {
|
||||
const d = v.dot(a);
|
||||
if (d > bestDot) { bestDot = d; best = a.clone(); }
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when user clicks a model face during calibration.
|
||||
* @param normalWorld world-space face normal of the clicked face
|
||||
|
||||
Reference in New Issue
Block a user