amenui
en·中 github ↗ v0.0.1
01docs 02components 03lab 04works
en·中github ↗
×

docs / components / display / orbit docs / components / display /

orbit

04.12
On this page ▾
  1. Installation
  2. Usage
  3. API
  4. Keyboard and accessibility

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.

drawn by amenuiopen ↗

Installation

Components are distributed as source. Copy it and what it depends on into your project, then change it as you need:

sh
cargo run --release --bin amenui -- add orbit --to ../my-app

Files copied: src/widgets/orbit.rs, src/mesh.rs, src/widgets/mod.rs

Usage

rust
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

Functionsorbit
Propskey, scene (its camera is replaced by the orbit's), orbit, msg.
Filessrc/widgets/orbit.rs, src/mesh.rs
Depends onbase
Response to frontsloosen (a 3D element is decoration, like a picture, even when it can be turned)
Recompositionnone (no text)

Keyboard and accessibility

Statesrest, focused, dragging (captured until release), coasting (after a fast drag).
Keys and messagesmsg(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