three_rs_controls/lib.rs
1//! `three-rs-controls` — a camera over a ground, and the ground.
2//!
3//! An addon in the sense of three.js' `examples/jsm/controls/`: it depends on
4//! `three-rs` the way any user would and is not a port of anything in
5//! three.js' `src/`. [`Ground`] and [`MapControls`] are this crate's own
6//! design; [`smooth_damp`] is camera-controls', not three.js'.
7//!
8//! [`Ground`] is a sphere with a distinguished point at the world origin and
9//! arc-length coordinates around it; at its largest radius it is a plane to the
10//! eye. [`MapControls`] drives a camera over it the way three.js'
11//! `MapControls` drives one over a map — the ground is what you grab — with
12//! `camera-controls`' `smoothDamp` on every field.
13//!
14//! ```no_run
15//! use three_rs::cameras::PerspectiveCamera;
16//! use three_rs_controls::{Ground, MapControls, Pose};
17//!
18//! let mut controls = MapControls::new(
19//! Ground::new(1e7),
20//! Pose {
21//! u: 0.0,
22//! v: 0.0,
23//! distance: 160.0,
24//! azimuth: 0.0,
25//! polar: 0.0,
26//! },
27//! );
28//!
29//! let mut camera = PerspectiveCamera::new(60.0, 16.0 / 9.0, 1.0, 50_000.0);
30//! controls.update(1.0 / 60.0);
31//! controls.apply(&mut camera);
32//! ```
33
34#![warn(missing_docs)]
35mod ground;
36mod map_controls;
37mod smooth_damp;
38
39pub use ground::{Frame, Ground, MAX_RADIUS, MIN_RADIUS};
40pub use map_controls::{
41 Damping, MapControls, Mode, Pane, Pose, DRAGGING_SMOOTH_TIME, MAX_DISTANCE, MAX_POLAR,
42 MIN_DISTANCE, MIN_POLAR, PANE_LIFT, REST_THRESHOLD, SMOOTH_TIME, WHEEL_SMOOTH_TIME,
43};
44pub use smooth_damp::smooth_damp;