mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
3D models only within 3 km of the camera, at true size
An aircraft, vessel, transit or rail vehicle now draws as its 3D model only when it is within 3 km of the camera, and as its icon farther away. A model already drawn is kept out to 3.6 km, so a vehicle on the edge does not flicker. Proximity and All use the same distance and still differ by how many models they allow (150 and 350). Models are drawn at their true size: the minimum pixel size that inflated distant models is gone. The camera altitude above which no model is considered is now the highest aircraft the layers draw (30 km) plus the 3.6 km, so a camera high above the ground still models an aircraft close to it. Cockpit's aircraft silhouettes keep their own 150/185 km and 400/450 km bands, since they are icons.
This commit is contained in:
1 parent
624c229bc2
commit
36624cd329
22 files changed
+260
-181
No files matched your search
@@ -44,7 +44,6 @@ import {
|
||||
import {
|
||||
displayDelayMs,
|
||||
followsClock,
|
||||
MODEL_MIN_PX,
|
||||
BILLBOARD_SCALE,
|
||||
TRACKED_BILLBOARD_SCALE_BY_DISTANCE,
|
||||
DR_CORRECTION_MS,
|
||||
@@ -312,11 +311,11 @@ export function createMotion({
|
||||
const spec = parts.rendering._modelSpec(
|
||||
flightState.records.data.get(icao24),
|
||||
);
|
||||
// Drawn as the fleet draws it: its own size, never under MODEL_MIN_PX.
|
||||
// Drawn as the fleet draws it: at its true size.
|
||||
const focalLengthPx = viewportHeightPx / (2 * Math.tan(pose.fovy / 2));
|
||||
const projectedDiameterPx =
|
||||
(2 * spec.nativeRadiusM * spec.scale * focalLengthPx) / rangeM;
|
||||
return Math.max(MODEL_MIN_PX, projectedDiameterPx);
|
||||
return projectedDiameterPx;
|
||||
}
|
||||
|
||||
const sprite = readEntityRecord(flightState._trackedEntity)?.sprite;
|
||||
@@ -515,9 +514,8 @@ export function createMotion({
|
||||
}
|
||||
|
||||
/** The tracked model's rendered bounding radius (m), or 0 when no model of this
|
||||
* contact is drawing. Carries the scale it is drawn at, which may be
|
||||
* above `scale` to satisfy its pixel floor — the trail head has to be judged
|
||||
* against the size the operator SEES, not the nominal one. */
|
||||
* contact is drawing, at the scale it is drawn at — the trail head has to
|
||||
* be judged against the size the operator SEES. */
|
||||
/** World-space origin of the tracked model, or null when no model of this
|
||||
* contact is drawing. This is the centre the rendered bounding sphere is
|
||||
* measured from, so the trail clip and the envelope agree on one frame. */
|
||||
|
||||
@@ -61,21 +61,26 @@ export const MODEL_WHITE = rgba('#FFFFFF');
|
||||
export const GROUND_SCALE = 0.8;
|
||||
|
||||
// --- 3D model rendering (mirrors flights.js) -----------------------------------------
|
||||
// When enabled, military aircraft render as 3D glTF models once the camera is below
|
||||
// MODEL_ALT_CEIL_M (zoomed in); higher up they stay flat billboards. Eligibility is
|
||||
// FRUSTUM-based (on-screen), and the slots go to either the nearest planes ('proximity')
|
||||
// or every in-view plane ('all'), each backed by a hard cap so a draw-call explosion
|
||||
// can't tank the frame (no instancing yet). Each aircraft draws the fleet model of its
|
||||
// type, as the flights layer does; the amber tint sets this layer apart.
|
||||
// When enabled, a military aircraft draws as its 3D glTF model only within MODEL_ADD_M of the
|
||||
// camera (eye to aircraft); farther away it stays its icon. Models are drawn at their true size,
|
||||
// with no minimum pixel size. Eligibility is distance-based with on-screen priority, and the slots
|
||||
// go to either the nearest planes ('proximity') or every in-range plane ('all'): the two modes share
|
||||
// the radius and differ by their caps. Each aircraft draws the fleet model of its type, as the
|
||||
// flights layer does; the amber tint sets this layer apart.
|
||||
|
||||
export const MODEL_ALT_CEIL_M = 800000;
|
||||
// m: below this camera altitude, draw 3D models (raised so it's easy to trigger)
|
||||
export const MODEL_ADD_M = 3000;
|
||||
// model NEW planes within 3 km of the camera (mirror of flights.js)
|
||||
|
||||
export const MODEL_MIN_PX = 24;
|
||||
// floor so distant models stay visible without ballooning into a min-pixel blob (mirror of flights.js)
|
||||
export const MODEL_KEEP_M = 3600;
|
||||
// KEEP modeled planes out to 3.6 km (hysteresis, mirror of flights.js)
|
||||
|
||||
// Per-mode caps + radii — mirror of flights.js. Modes differ by RADIUS (not just cap) so Proximity
|
||||
// and All aren't identical when few planes are in range; on-screen planes win the cap (see flights.js).
|
||||
export const MODEL_HIGHEST_CONTACT_M = 30000;
|
||||
// m above the ellipsoid: no aircraft the layer draws flies higher (mirror of flights.js)
|
||||
|
||||
export const MODEL_ALT_CEIL_M = MODEL_HIGHEST_CONTACT_M + MODEL_KEEP_M;
|
||||
// m: above this camera altitude no contact can be within MODEL_KEEP_M (mirror of flights.js)
|
||||
|
||||
// Per-mode caps — mirror of flights.js; on-screen planes win the cap (see flights.js).
|
||||
|
||||
export const MODEL_MAX = 150;
|
||||
// 'proximity' cap
|
||||
@@ -83,24 +88,20 @@ export const MODEL_MAX = 150;
|
||||
export const MODEL_MAX_ALL = 350;
|
||||
// 'all' cap
|
||||
|
||||
export const MODEL_PROX_ADD_M = 150000;
|
||||
// proximity: model NEW planes within 150 km
|
||||
|
||||
export const MODEL_PROX_KEEP_M = 185000;
|
||||
// proximity: KEEP modeled planes out to 185 km
|
||||
|
||||
// Cockpit keeps the standard Display radii but lowers the GLB budget. Contacts
|
||||
// inside the selected band remain AIR silhouettes when they cannot own a model;
|
||||
// contacts outside the band use compact dots.
|
||||
|
||||
export const COCKPIT_MODEL_MAX = 60;
|
||||
// max concurrent GLBs in cockpit (never raises the map cap)
|
||||
|
||||
export const MODEL_ALL_ADD_M = 400000;
|
||||
// all: model NEW planes within 400 km (~to the horizon)
|
||||
// Cockpit's AIR band (mirror of flights.js): contacts inside it remain AIR
|
||||
// silhouettes when they cannot own a model; contacts outside it use compact
|
||||
// dots. Independent of the 3D model radius.
|
||||
|
||||
export const MODEL_ALL_KEEP_M = 450000;
|
||||
// all: KEEP modeled planes out to 450 km
|
||||
export const COCKPIT_AIR_PROX_ADD_M = 150000;
|
||||
|
||||
export const COCKPIT_AIR_PROX_KEEP_M = 185000;
|
||||
|
||||
export const COCKPIT_AIR_ALL_ADD_M = 400000;
|
||||
|
||||
export const COCKPIT_AIR_ALL_KEEP_M = 450000;
|
||||
|
||||
export const MODEL_HEADING_OFFSET_DEG = 180;
|
||||
// every fleet model is nose -X: opposite Cesium heading 0
|
||||
|
||||
@@ -249,11 +249,11 @@ export function createQueries({
|
||||
|
||||
/**
|
||||
* Live layer params.
|
||||
* `models3d` toggles 3D glTF jet-model rendering for the FLEET (altitude-gated): when on,
|
||||
* surrounding military aircraft become 3D models once the camera is zoomed in past
|
||||
* MODEL_ALT_CEIL_M. The TRACKED contact follows the same rule (`_trackedModelRegimeActive`),
|
||||
* `models3d` toggles 3D glTF jet-model rendering for the FLEET: when on, military
|
||||
* aircraft within MODEL_ADD_M (3 km) of the camera become 3D models, drawn at their true
|
||||
* size. The TRACKED contact follows the same rule (`_trackedModelRegimeActive`),
|
||||
* so selecting a contact never turns its icon into a model or its model into an icon.
|
||||
* `models3dMode` is 'proximity' (nearest MODEL_MAX in view) or 'all' (every in-view plane).
|
||||
* `models3dMode` is 'proximity' (cap MODEL_MAX) or 'all' (cap MODEL_MAX_ALL); both use the 3 km radius.
|
||||
* @param {{models3d?: boolean, models3dMode?: 'proximity'|'all', selectedMilitaryTrackingId?: string|null}} params
|
||||
*/
|
||||
setParams(params = {}, { origin = 'programmatic' } = {}) {
|
||||
|
||||
@@ -27,6 +27,10 @@ import {
|
||||
} from '../../data/trackingClickGesture.js';
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import {
|
||||
COCKPIT_AIR_ALL_ADD_M,
|
||||
COCKPIT_AIR_ALL_KEEP_M,
|
||||
COCKPIT_AIR_PROX_ADD_M,
|
||||
COCKPIT_AIR_PROX_KEEP_M,
|
||||
TRAIL_MAX_POINTS,
|
||||
displayDelayMs,
|
||||
followsClock,
|
||||
@@ -212,11 +216,13 @@ export function createTracking({
|
||||
);
|
||||
distancesSquared.push([icao24, distanceSquared(eye, position)]);
|
||||
}
|
||||
// The AIR band follows the 3D mode, not the 3D model radius.
|
||||
const all = flightState._models3dMode === 'all';
|
||||
const next = nextCockpitNearContacts(
|
||||
previous,
|
||||
distancesSquared,
|
||||
parts.rendering._modelAddDistM(),
|
||||
parts.rendering._modelKeepDistM(),
|
||||
all ? COCKPIT_AIR_ALL_ADD_M : COCKPIT_AIR_PROX_ADD_M,
|
||||
all ? COCKPIT_AIR_ALL_KEEP_M : COCKPIT_AIR_PROX_KEEP_M,
|
||||
);
|
||||
flightState._cockpitNearContacts = next;
|
||||
for (const icao24 of previous)
|
||||
|
||||
Reference in new issue
Block a user