1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
//! # bevy_a5
//!
//! A Bevy plugin providing [A5](https://github.com/felixpalmer/a5-rs) geospatial
//! pentagonal cell coordinates for planetary games.
//!
//! `bevy_a5` is to **spherical / planetary** games what
//! [`big_space`](https://docs.rs/big_space) is to deep-space games — the same
//! floating-origin idea, a different cell space, with A5-specific spatial
//! queries on top.
//!
//! ## What it provides
//!
//! 1. **Cell-anchored coordinates.** Position entities as `(GeoCell, Transform)`
//! — *which* A5 cell, plus a small offset within that cell. The
//! `FloatingOrigin`-tagged entity (your camera) defines the world's
//! reference cell; everyone else's `GlobalTransform` is computed relative to
//! it. When the origin's local `Transform` exceeds its
//! [`FloatingOrigin::recenter_threshold`](origin::FloatingOrigin::recenter_threshold), the plugin hops to the
//! neighbouring cell automatically.
//!
//! 2. **Spatial queries on the sphere.** [`grid_disk`](query::grid_disk),
//! [`neighbors`](query::neighbors), [`spherical_cap`](query::spherical_cap),
//! parent/child/compact/uncompact — none of which big_space has, because A5
//! cells tile a sphere.
//!
//! 3. **Display helpers.** [`build_grid_line_mesh`](geometry::build_grid_line_mesh)
//! builds a ready-to-use `Mesh` for a slice of cells in one call;
//! [`DrawCellOutline`](debug::DrawCellOutline) is a marker component that
//! gizmos a cell's pentagon every frame.
//!
//! ## Cell-local frame convention
//!
//! Within a cell, the local frame is **vertex-aligned**: the cell centre is
//! `(0, 0, 0)`, `+Y` is radial-up, and `-Z` (Bevy "forward") points from the
//! centre to the cell's first boundary vertex. So a child entity at
//! `Transform::from_xyz(0.0, 0.0, -d)` sits `d` metres along the cell's
//! "north" — the line from the centre to the first vertex. Adjacent cells
//! have rotated frames; that's the price of a cell-local convention.
//!
//! Use [`orientation::cell_orientation`] / [`coord::tangent_frame`] if you
//! need the geographic (north-up) frame instead.
//!
//! ## Big-space rendering convention
//!
//! The [`FloatingOrigin`](origin::FloatingOrigin)-tagged entity always
//! renders at world `(0, 0, 0)` (rotation and scale preserved). Every other
//! cell-anchored entity is placed in the origin's local frame at its true
//! sphere-space position relative to the origin. Move the origin by
//! mutating its `Transform.translation` — never its `GeoCell` directly. The
//! recenter system rebalances the `(GeoCell, Transform)` pair when the
//! translation grows past the per-origin threshold, *without* moving the
//! origin in world space. Recentres are visually invisible.
//!
//! ## Quick start
//!
//! ```rust,ignore
//! use bevy::prelude::*;
//! use bevy_a5::prelude::*;
//!
//! fn main() {
//! App::new()
//! .add_plugins(DefaultPlugins)
//! .add_plugins(BevyA5Plugins) // plugin group: core + camera + hash
//! .insert_resource(PlanetSettings::earth())
//! .add_systems(Startup, setup)
//! .run();
//! }
//!
//! fn setup(mut commands: Commands) {
//! // Spawn the floating origin (camera) at Paris.
//! let cell = GeoCell::from_lon_lat(2.3522, 48.8566, 9).unwrap();
//! commands.spawn_floating_origin(cell)
//! .insert((Camera3d::default(), FlyCam::default()));
//!
//! // Spawn an entity at a neighbouring cell's centre.
//! let neighbour = GeoCell::from_lon_lat(2.3525, 48.8570, 9).unwrap();
//! commands.spawn_cell_anchor(neighbour);
//! }
//! ```
//!
//! ## Roadmap
//!
//! - **Multi-planet support.** `PlanetSettings` is a global resource today, so
//! apps are restricted to one planet. A `Planet` component on a root entity
//! with per-planet hierarchies is planned.
use ;
use IntoScheduleConfigs;
use ;
/// Core `bevy_a5` plugin: floating-origin recentre, cell→world transform
/// propagation, debug gizmos. No camera, no spatial hash. Use
/// [`BevyA5Plugins`] for the full default set.
;
/// Default plugin group. Combines:
///
/// - [`BevyA5Plugin`] — core transform / floating-origin systems
/// - [`camera::CameraPlugin`] — fly-camera controller
/// - [`hash::CellHashPlugin`] — `CellEntityIndex` spatial hash
///
/// Add individual plugins instead if you don't want the camera or hash.
;
/// Convenient re-exports for common usage.
// Re-export a5 types that appear in our public signatures so users don't
// need a direct `a5` dependency. `LonLat` is the return type of
// `GeoCell::boundary` / `GeoCell::center`; `WORLD_CELL` is the resolution-0
// root cell index used by the planet_grid example.
pub use ;