Turn a 3D view: drag to orbit, the wheel to dolly, the arrow keys once focused; a quick drag coasts to a stop.
The camera is an Orbit in the state; the component only reports input.
Installation
Components are distributed as source. Copy it and what it depends on into your project, then change it as you need:
cargo run --release --bin amenui -- add orbit --to ../my-appFiles copied: src/widgets/orbit.rs, src/mesh.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{orbit};
fn view() -> El<Msg> {
orbit("o1", Scene3d::single(MeshId::CUBE), &Orbit::default(), |_| Msg::Nothing).width(240.0).height(160.0)
}API
| Functions | orbit |
|---|---|
| Props | key, scene (its camera is replaced by the orbit's), orbit, msg. |
| Files | src/widgets/orbit.rs, src/mesh.rs |
| Depends on | base |
| Response to fronts | loosen (a 3D element is decoration, like a picture, even when it can be turned) |
| Recomposition | none (no text) |
Keyboard and accessibility
| States | rest, focused, dragging (captured until release), coasting (after a fast drag). |
|---|---|
| Keys and messages | msg(OrbitMsg) for every drag step, wheel turn and arrow key; the application calls |
On the web every control is mirrored into the page as an element with its role and name, so screen readers and the browser's own focus see it (DESIGN.md §1.14).
Recipes: A 3D object in a card