转动一个三维视图:拖动环绕,滚轮推近拉远,获得焦点后方向键转动;快速拖动后松手会慢慢停下。
相机是状态里的 Orbit,组件只报告输入。
安装
组件以源码分发。把它和它依赖的文件拷进你的项目,再按需要改:
cargo run --release --bin amenui -- add orbit --to ../my-app拷贝的文件: src/widgets/orbit.rs, src/mesh.rs, src/widgets/mod.rs
用法
use amenui::widgets::{orbit};
fn view() -> El<Msg> {
orbit("o1", Scene3d::single(MeshId::CUBE), &Orbit::default(), |_| Msg::Nothing).width(240.0).height(160.0)
}接口
| 函数 | orbit |
|---|---|
| 参数 | key, scene (its camera is replaced by the orbit's), orbit, msg. |
| 文件 | src/widgets/orbit.rs, src/mesh.rs |
| 依赖 | base |
| 对波前的响应 | loosen (a 3D element is decoration, like a picture, even when it can be turned) |
| 重组 | none (no text) |
键盘与无障碍
| 状态 | rest, focused, dragging (captured until release), coasting (after a fast drag). |
|---|---|
| 键盘与消息 | msg(OrbitMsg) for every drag step, wheel turn and arrow key; the application calls |
在网页上,每个控件都在页面里有一个带角色和名字的镜像元素,读屏软件和浏览器自己的焦点都看得到它(DESIGN.md §1.14)。
配方: 卡片里的三维物体