mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 03:32:19 +00:00
feat(aircraft): draw far-away aircraft as shaded sprites seen from the camera's angle
Aircraft on the map were flat, top-down SVG silhouettes turned along
their course: from an oblique camera they read as paper cut-outs lying
on the ground.
Each aircraft class (and each helicopter rotor frame) is now rendered in
Blender from a sphere of directions into one sheet of shaded sprites
(public/sprites/aircraft-views.webp: 302 views a class, 7.5 degrees
apart from straight above to 30 degrees below the horizon, 4096 x 3648,
grey, 3.1 MB). The renderer lays a contact flat on the ground along its
course, works out where the eye is in that frame and draws the nearest
view, mirrored for the port side. The view is a card standing at the
contact, square to the direction it was rendered from, so between views
the sprite is tilted (foreshortened and turned) as the aircraft would
be; views are not blended. Sprites are neutral, so the fleet, tracked
and military tints still apply.
Renderer: a new `viewSheets` capability, `DrawPort.views(id, sheet)` and
an image `{views, first, fallback}` for icon items (src/data/viewSheet.js
holds the layout and maths, in JS and GLSL). A view row draws from the
sheet's own texture, kept as luminance and alpha; until the sheet has
loaded, and if it cannot load, it draws its flat `fallback` along its
course as before. View sheets are offered on WebGL 2 only, and on
WebGL 1 the icon shader is as it was.
Layers: Flights, Military Flights (fleet and tracked contact) and Local
ADS-B draw views; the TR-3B, airport vehicles, ground stations and
Cockpit's far pips stay flat, as does any renderer without the
capability.
Tools: `npm run build:aircraft-views` bakes the sheet from the repo's
own fleet models (about 7 minutes); scripts/qa-aircraft-view-sheet.mjs
writes contact sheets of a bake and scripts/qa-aircraft-views.mjs
photographs a grid of every class in the app from above, tilted, from
below and round an orbit.
With 5,000 contacts on an M3 Max the frame takes 5.9-6.1 ms against
5.9 ms with the flat glyphs.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
1 parent
d9d79ebc4d
commit
efdac0ba70
40 files changed
+3535
-109
No files matched your search
Vendored
+47
-1
@@ -154,10 +154,48 @@ export interface Placed {
|
||||
disableDepthTest?: number;
|
||||
}
|
||||
|
||||
/** An image an icon draws: a URL, a slot in a shared atlas, or generated. */
|
||||
/**
|
||||
* `viewSheets`: one image of small sprites that show subjects from a sphere
|
||||
* of directions, registered with `DrawPort.views`. An icon whose image is a
|
||||
* view (`{views, first}`) lies flat on the ground, forward along its course,
|
||||
* and is drawn as the sprite that shows it from where the eye is.
|
||||
*
|
||||
* The image is a grid of square cells, `cellPx` a side, `columns` across and
|
||||
* `rows` down. A subject is a block of consecutive cells, row-major from its
|
||||
* `first`: rings of frames `ringStepDeg` apart, from straight above (ring 0,
|
||||
* one frame) downward, short of straight below; ring `k` holds `rings[k]`
|
||||
* frames, from the eye dead ahead of the subject, round its right side, to
|
||||
* dead astern. The eye on its left side draws the right side's frame
|
||||
* mirrored. A frame's up is the subject's forward, turned by the smallest
|
||||
* rotation that takes its up onto the frame's direction. The frame nearest
|
||||
* the eye's direction is drawn, as a card square to its own direction, so
|
||||
* between frames it is tilted as its subject is (`data/viewSheet.js` holds
|
||||
* the maths).
|
||||
*/
|
||||
export interface ViewSheet {
|
||||
/** The sheet's URL. */
|
||||
image: string;
|
||||
cellPx: number;
|
||||
columns: number;
|
||||
rows: number;
|
||||
ringStepDeg: number;
|
||||
/** Frames in each ring; the first is 1. At most 18 rings. */
|
||||
rings: readonly number[];
|
||||
/**
|
||||
* The sheet's pixels are grey (red, green and blue equal): a renderer may
|
||||
* keep it as one channel and alpha.
|
||||
*/
|
||||
grey?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* An image an icon draws: a URL, a slot in a shared atlas, generated, or
|
||||
* (`viewSheets`, icons only) a subject of a view sheet by its first cell.
|
||||
*/
|
||||
export type ImageRef =
|
||||
| string
|
||||
| { atlas: string; slot: string }
|
||||
| { views: string; first: number; fallback?: ImageRef }
|
||||
| { svg: string }
|
||||
| { blob: Blob }
|
||||
| { canvas: HTMLCanvasElement | OffscreenCanvas; key: string };
|
||||
@@ -211,6 +249,12 @@ export interface CourseGlide {
|
||||
}
|
||||
|
||||
export interface IconItem extends Placed {
|
||||
/**
|
||||
* A view (`{views, first}`) needs `rotationMode: 'course'` and takes no
|
||||
* `imageLod`; a set draws views from one sheet. Until its sheet is
|
||||
* registered and loaded, and if that cannot load, it draws its `fallback`
|
||||
* (any image but a view) along its course, or nothing without one.
|
||||
*/
|
||||
image: ImageRef;
|
||||
/** Drawn size in CSS pixels. */
|
||||
size: [width: number, height: number];
|
||||
@@ -752,4 +796,6 @@ export interface DrawPort {
|
||||
on(event: 'clampState', cb: (state: 'draped' | 'overlay') => void): Off;
|
||||
/** Register an atlas of images icons refer to by slot. */
|
||||
atlas(id: string, images: Record<string, ImageRef>): void;
|
||||
/** `viewSheets`: register a sheet of views icons refer to by id. */
|
||||
views?(id: string, sheet: ViewSheet): void;
|
||||
}
|
||||
Reference in new issue
Block a user