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
@@ -0,0 +1,71 @@
|
||||
# Aircraft View Sheet
|
||||
|
||||
`aircraft-views.webp` is the sheet of shaded sprites far-away aircraft are
|
||||
drawn with in Flights, Military Flights and Local ADS-B, on a renderer with the
|
||||
`viewSheets` capability. Each aircraft class is rendered from a sphere of
|
||||
camera angles; the renderer lays a contact flat on the earth along its course
|
||||
and draws the frame nearest to where the eye is, as a card that tilts as the
|
||||
eye moves off its direction until the next frame is the nearer (frames are
|
||||
not blended), so an aircraft seen at an oblique angle looks solid and turns
|
||||
with the camera. `aircraft-views.json` is its manifest.
|
||||
|
||||
The sprites are rendered from the project's own procedural fleet models
|
||||
([`../models/fleet/`](../models/README.md)), so, like them, they contain no
|
||||
third-party artwork and are covered by the repository's
|
||||
[MIT license](../../LICENSE).
|
||||
|
||||
| Path | What it holds |
|
||||
|---|---|
|
||||
| `aircraft-views.webp` | 4096 × 3648 px, lossless WebP: 64 px cells, 64 a row, 57 rows. Grey: every pixel's red, green and blue are equal. |
|
||||
| `aircraft-views.json` | The layout (`cellPx`, `columns`, `rows`, `ringStepDeg`, `rings`, `fill`, `grey`) and each subject's first cell, fleet model and bounding radius in metres. |
|
||||
|
||||
## Layout
|
||||
|
||||
Each subject owns 302 consecutive cells, row-major: subject `i` starts at
|
||||
cell `i × 302`. The subjects, in order, are `airliner`, `widebody`, `quadjet`,
|
||||
`turboprop`, `light`, `glider`, `fastjet`, `bizjet`, `uav`, and `helicopter0`
|
||||
to `helicopter2` (the helicopter's three rotor frames, `src/data/rotorFrames.js`).
|
||||
|
||||
Within a block the frames lie in 17 rings 7.5° apart, from straight above
|
||||
(ring 0, one frame) to 30° below the horizon, of 1, 4, 7, 10, 13, 16, 18, 20,
|
||||
22, 23, 24, 25, 25, 25, 24, 23 and 22 frames. A ring runs from the eye dead
|
||||
ahead of the nose, round the starboard side, to dead astern; the renderer
|
||||
mirrors a starboard frame for an eye on the port side, so the light is
|
||||
symmetric about the aircraft's centre plane. A frame is an orthographic view
|
||||
centred on the model's origin, its bounding sphere spanning 0.92 of the cell,
|
||||
turned so that straight above the nose points up the image.
|
||||
`src/data/viewSheet.js` holds the same layout and the maths that picks a frame
|
||||
(`AIRCRAFT_VIEWS`); `src/data/viewSheet.test.mjs` checks the manifest and the
|
||||
bake script against it.
|
||||
|
||||
The sprites are neutral (white paint, grey shading, dark glass, a dark edge)
|
||||
so each layer's tint multiplies them, as it does the flat glyphs. They are
|
||||
exactly grey (`"grey": true`): the renderer keeps the sheet as grey and
|
||||
alpha, reading its red channel, which halves its memory. The bake refuses a
|
||||
frame that is not grey, and so does the step that writes the WebP. The thin
|
||||
glider, UAV, light aircraft and helicopter are thickened a little before
|
||||
their edge so they still read 20 to 30 px wide. Every cell keeps its outer
|
||||
2 px transparent, so the renderer's mipmaps never pull in a neighbour.
|
||||
|
||||
## Rebuilding
|
||||
|
||||
```
|
||||
npm run build:aircraft-views # about 7 minutes
|
||||
npm run build:aircraft-views -- --only glider,uav --out /tmp/views
|
||||
```
|
||||
|
||||
This needs Blender (`$BLENDER`, else `blender` on the `PATH`, else
|
||||
`/Applications/Blender.app`). It runs `scripts/build-aircraft-view-sheet.py`
|
||||
headless, which renders every frame with Cycles and refuses a frame whose
|
||||
pixels reach within 2 px of its cell's edge, then
|
||||
`scripts/build-aircraft-views.mjs` writes the PNG as lossless WebP here with
|
||||
the manifest. With `--only`, the other subjects' cells are left empty, so
|
||||
ship only a full bake.
|
||||
|
||||
To review a bake, write a contact sheet per subject (its rings as rows over a
|
||||
dark sea, pale land and a mid satellite tone, plus a few frames at 40, 30 and
|
||||
20 px in the fleet, tracked and military tints):
|
||||
|
||||
```
|
||||
node scripts/qa-aircraft-view-sheet.mjs [--manifest public/sprites/aircraft-views.json] [--out qa-shots/aircraft-views]
|
||||
```
|
||||
Reference in new issue
Block a user