* Navigation: Free orbit can turn around the vertical axis (#6964) A new option under Free orbit, Turn around the vertical axis, makes mouse drags a turntable without the pole limit: sideways turns about the world's up axis (reversed upside down so the model follows the cursor), up/down tilts over the top. Off by default; free orbit without it is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * i18n: Japanese and Chinese for the vertical-axis orbit option (#6964) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * i18n: Arabic, Hebrew, Vietnamese, German and Korean for the vertical-axis orbit option (#6964) Main now treats ar, he and vi as complete catalogs, so the merge queue's every_complete_catalog_carries_every_english_message failed on the two new ids. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UhpMr6L9PR8SJXjM6MbQrD --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: danieldimitrov86 <danieldimitrovdev@gmail.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"en": {
|
||||
"nav.free_orbit_upright.label": "Turn around the vertical axis",
|
||||
"nav.free_orbit_upright.help": "Sideways mouse drags spin the model around the world's vertical axis; up and down drags tilt over the top without a limit."
|
||||
},
|
||||
"ar": {
|
||||
"nav.free_orbit_upright.label": "الدوران حول المحور الرأسي",
|
||||
"nav.free_orbit_upright.help": "سحب الفأرة جانبيًا يدوّر النموذج حول المحور الرأسي للعالم؛ والسحب لأعلى ولأسفل يميله فوق القمة دون حد."
|
||||
},
|
||||
"de": {
|
||||
"nav.free_orbit_upright.label": "Um die senkrechte Achse drehen",
|
||||
"nav.free_orbit_upright.help": "Seitliches Ziehen mit der Maus dreht das Modell um die senkrechte Achse der Welt; Ziehen nach oben und unten neigt es ohne Begrenzung über den Pol hinweg."
|
||||
},
|
||||
"he": {
|
||||
"nav.free_orbit_upright.label": "סיבוב סביב הציר האנכי",
|
||||
"nav.free_orbit_upright.help": "גרירת העכבר הצידה מסובבת את המודל סביב הציר האנכי של העולם; גרירה למעלה ולמטה מטה אותו מעבר לקודקוד ללא הגבלה."
|
||||
},
|
||||
"ja": {
|
||||
"nav.free_orbit_upright.label": "垂直軸を中心に回転",
|
||||
"nav.free_orbit_upright.help": "マウスを左右にドラッグするとワールドの垂直軸を中心にモデルが回転し、上下にドラッグすると制限なく真上を越えて傾きます。"
|
||||
},
|
||||
"ko": {
|
||||
"nav.free_orbit_upright.label": "수직 축을 중심으로 회전",
|
||||
"nav.free_orbit_upright.help": "마우스를 좌우로 드래그하면 모델이 월드의 수직 축을 중심으로 회전하고, 위아래로 드래그하면 제한 없이 극점을 넘어 기울어집니다."
|
||||
},
|
||||
"vi": {
|
||||
"nav.free_orbit_upright.label": "Xoay quanh trục thẳng đứng",
|
||||
"nav.free_orbit_upright.help": "Kéo chuột sang ngang sẽ xoay mô hình quanh trục thẳng đứng của không gian; kéo lên và xuống sẽ nghiêng qua đỉnh mà không bị giới hạn."
|
||||
},
|
||||
"zh": {
|
||||
"nav.free_orbit_upright.label": "绕竖直轴旋转",
|
||||
"nav.free_orbit_upright.help": "左右拖动鼠标时模型绕世界竖直轴旋转;上下拖动可不受限制地越过顶部倾斜。"
|
||||
}
|
||||
}
|
||||
@@ -442,6 +442,19 @@ impl Camera {
|
||||
self.roll = roll;
|
||||
}
|
||||
}
|
||||
/// Orbit by pixel deltas like [`Camera::orbit`], without its pole limit: sideways turns
|
||||
/// about the world's up axis and up/down tilts about the screen's right, on over the top.
|
||||
/// Upside down (past a pole) sideways turns the other way, so the model still follows the
|
||||
/// cursor.
|
||||
pub fn orbit_unlimited(&mut self, dx: f64, dy: f64) {
|
||||
if !self.is_valid() || !dx.is_finite() || !dy.is_finite() {
|
||||
return;
|
||||
}
|
||||
let upright = self.basis().1.dot(self.up_dir()) >= 0.0;
|
||||
let turn = if upright { dx } else { -dx } * 0.008;
|
||||
self.yaw = (self.yaw + turn) % std::f64::consts::TAU;
|
||||
self.rotate_in_view(Vec3::new(-dy * 0.008, 0.0, 0.0));
|
||||
}
|
||||
pub fn set_view(&mut self, v: StandardView) {
|
||||
let lim = std::f64::consts::FRAC_PI_2 - 1e-6;
|
||||
let (y, p) = v.angles();
|
||||
|
||||
@@ -976,10 +976,12 @@ pub(crate) fn orbit_about(app: &mut SolveApp, _rect: egui::Rect, dx: f64, dy: f6
|
||||
}
|
||||
|
||||
fn orbit_camera(app: &mut SolveApp, dx: f64, dy: f64) {
|
||||
if app.preferences.free_orbit {
|
||||
app.cam.rotate_in_view(Vec3::new(-dy * 0.008, -dx * 0.008, 0.0));
|
||||
} else {
|
||||
if !app.preferences.free_orbit {
|
||||
app.cam.orbit(dx, dy);
|
||||
} else if app.preferences.free_orbit_upright {
|
||||
app.cam.orbit_unlimited(dx, dy);
|
||||
} else {
|
||||
app.cam.rotate_in_view(Vec3::new(-dy * 0.008, -dx * 0.008, 0.0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1373,6 +1375,51 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Free orbit turning around the vertical axis: sideways drags keep the elevation and the
|
||||
/// world's up axis on screen (no tumbling), and up/down drags go on over the top; past it,
|
||||
/// sideways still turns about the vertical axis, the model following the cursor.
|
||||
#[test]
|
||||
fn free_orbit_upright_turns_about_the_vertical_axis_past_the_pole() {
|
||||
use super::*;
|
||||
for up in [solidcraft_engine::render::UpAxis::Z, solidcraft_engine::render::UpAxis::Y] {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.preferences.free_orbit = true;
|
||||
h.app.preferences.free_orbit_upright = true;
|
||||
h.app.cam = Camera { yaw: 0.2, pitch: 0.6, up, ..Default::default() };
|
||||
let rect = Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0));
|
||||
let height = |c: &Camera| c.back().dot(c.up_dir());
|
||||
let before = h.app.cam;
|
||||
for _ in 0..50 {
|
||||
orbit_drag(&mut h.app, rect, 7.0, 0.0, None, false, false);
|
||||
assert!((height(&h.app.cam) - height(&before)).abs() < 1e-9, "{up:?}: {:?}", h.app.cam);
|
||||
assert!(h.app.cam.basis().0.dot(h.app.cam.up_dir()).abs() < 1e-9, "{up:?}: the horizon stays level");
|
||||
}
|
||||
assert!((h.app.cam.yaw - (before.yaw + 350.0 * 0.008)).rem_euclid(std::f64::consts::TAU) < 1e-9);
|
||||
// Up over the top: 2 rad of tilt from 0.6 rad elevation passes straight down.
|
||||
h.app.cam = Camera { yaw: 0.0, pitch: 0.6, up, ..Default::default() };
|
||||
for _ in 0..100 {
|
||||
orbit_drag(&mut h.app, rect, 0.0, 2.5, None, false, false);
|
||||
}
|
||||
let past = h.app.cam;
|
||||
assert!((height(&past) - 2.6_f64.sin()).abs() < 1e-9, "{up:?}: {past:?}");
|
||||
assert!(past.basis().1.dot(past.up_dir()) < 0.0, "{up:?}: upside down past the pole");
|
||||
orbit_drag(&mut h.app, rect, 10.0, 0.0, None, false, false);
|
||||
assert!((height(&h.app.cam) - height(&past)).abs() < 1e-9);
|
||||
// Upright and upside down alike, a drag to the right moves the near side right.
|
||||
let near = |c: &Camera| c.target + (c.back() - c.up_dir() * height(c)) * 10.0;
|
||||
assert!(h.app.cam.frame_coords(near(&past)).x > 0.5, "{up:?}: {:?}", h.app.cam);
|
||||
h.app.cam = before;
|
||||
orbit_drag(&mut h.app, rect, 10.0, 0.0, None, false, false);
|
||||
assert!(h.app.cam.frame_coords(near(&before)).x > 0.5, "{up:?}: {:?}", h.app.cam);
|
||||
}
|
||||
// Without the option, free orbit still turns about the screen's axes.
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.preferences.free_orbit = true;
|
||||
h.app.cam = Camera { yaw: 0.0, pitch: 0.6, ..Default::default() };
|
||||
orbit_drag(&mut h.app, Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0)), 50.0, 0.0, None, false, false);
|
||||
assert!((h.app.cam.back().z - 0.6_f64.sin()).abs() > 1e-3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn solidworks_mouse_orbit_passes_the_pole_and_shift_snaps() {
|
||||
use serde_json::json;
|
||||
|
||||
@@ -514,6 +514,9 @@ preference_settings! {
|
||||
/// Opt in to rotation through both poles with roll, without the Shift axis-snap spring.
|
||||
/// Independent of mouse bindings; false also preserves existing saved presets' behavior.
|
||||
free_orbit: bool = false, PAGE_NAVIGATION => check_tr("nav.free_orbit.label");
|
||||
/// With free orbit, mouse drags turn sideways about the world's up axis (a turntable without
|
||||
/// the pole limit) instead of the screen's.
|
||||
free_orbit_upright: bool = false, PAGE_NAVIGATION => check_tr("nav.free_orbit_upright.label");
|
||||
/// View orientation widget: original signed axes (default) or compact cube.
|
||||
navigator_style: NavigatorStyle = NavigatorStyle::default(), PAGE_NAVIGATION;
|
||||
/// Show the radial ring and enable hold/flick gestures for viewport context menus.
|
||||
|
||||
@@ -71,6 +71,11 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
crate::scenario::publish_target("prefs:free_orbit", free_orbit.rect);
|
||||
if app.preferences.free_orbit {
|
||||
ui_kit::text(ui, crate::i18n::tr("nav.free_orbit.snap_help"), ui_kit::Text::Hint("free_orbit"));
|
||||
let upright = setting::free_orbit_upright(app, ui);
|
||||
crate::scenario::publish_target("prefs:free_orbit_upright", upright.rect);
|
||||
if app.preferences.free_orbit_upright {
|
||||
ui_kit::text(ui, crate::i18n::tr("nav.free_orbit_upright.help"), ui_kit::Text::Hint("free_orbit_upright"));
|
||||
}
|
||||
}
|
||||
let help = if app.preferences.nav == TOUCHPAD_NAV {
|
||||
app.tr("nav.touchpad.help").to_owned()
|
||||
|
||||
@@ -44,7 +44,9 @@
|
||||
Enable **Preferences → Navigation → Free orbit** to rotate the mouse and 3D mouse continuously
|
||||
through both poles, preserving roll. During an orbit drag, Shift snaps the view direction and
|
||||
the picture rotation to the nearest quarter turn; releasing Shift resumes the unsnapped rotation.
|
||||
Free orbit defaults to off for every mouse
|
||||
Under it, **Turn around the vertical axis** makes sideways mouse drags spin the model around the
|
||||
world's vertical axis instead of the screen's, while up and down drags still tilt over the top
|
||||
without a limit. Both default to off for every mouse
|
||||
preset. With SolidWorks navigation, right-click a planar face and choose **Normal to Selection**
|
||||
to use Look At (also Ctrl+8); repeat to flip the side, preserving scale and projection.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user