mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 17:22:19 +00:00
feat(flights): aircraft draw life-size fleet models chosen by type
Flights, Military Flights and Local ADS-B draw each aircraft with the fleet model its ICAO type, class or emitter category selects, scaled to the type's length, built from the up-front loaded bytes. The eight third-party aircraft models and their attribution are removed; every shipped model is now the project's own.
This commit is contained in:
1 parent
f6760ad96c
commit
fcc44d0eaf
45 files changed
+970
-1371
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { JET_MODEL_URL } from './policy.js';
|
||||
import { loadFleetModelSet } from '../../data/fleetModels.js';
|
||||
|
||||
export function createLifecycle({
|
||||
flightState,
|
||||
@@ -47,29 +47,19 @@ export function createLifecycle({
|
||||
registerSpriteCollection('military', flightState._billboardCollection);
|
||||
flightState._modelCollection = new Cesium.PrimitiveCollection();
|
||||
viewer.scene.primitives.add(flightState._modelCollection);
|
||||
// Warm the glTF cache so the tracked plane's model instantiates instantly when first needed
|
||||
// (keeps the retained instance referenced; never rendered). Captured against this epoch so a
|
||||
// destroy/re-init mid-load doesn't flip the flag for a torn-down lifecycle.
|
||||
if (!flightState._preloadModel) {
|
||||
// Every fleet model loads once, up front, for every layer that draws
|
||||
// them (fleetModels.js), so no model is fetched while the session runs.
|
||||
// Captured against this epoch so a destroy/re-init mid-load doesn't flip
|
||||
// the flag for a torn-down lifecycle.
|
||||
{
|
||||
const epoch = flightState._modelEpoch;
|
||||
Cesium.Model.fromGltfAsync({
|
||||
url: resolveAsset(JET_MODEL_URL),
|
||||
asynchronous: false,
|
||||
})
|
||||
.then((m) => {
|
||||
if (epoch === flightState._modelEpoch) {
|
||||
flightState._preloadModel = m;
|
||||
loadFleetModelSet({ resolveAsset })
|
||||
.then(() => {
|
||||
if (epoch === flightState._modelEpoch)
|
||||
flightState._planeModelLoaded = true;
|
||||
} else {
|
||||
try {
|
||||
m.destroy();
|
||||
} catch {
|
||||
/* gone */
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
/* tracked plane just stays a billboard a beat longer */
|
||||
/* aircraft stay billboards */
|
||||
});
|
||||
}
|
||||
flightState._billboards = new Map();
|
||||
@@ -269,14 +259,6 @@ export function createLifecycle({
|
||||
flightState._modelEpoch += 1; // invalidate any in-flight load from this lifecycle (settles post-destroy)
|
||||
flightState._modelPending.clear();
|
||||
flightState._modelGen.clear();
|
||||
if (flightState._preloadModel) {
|
||||
try {
|
||||
flightState._preloadModel.destroy();
|
||||
} catch {
|
||||
/* gone */
|
||||
}
|
||||
flightState._preloadModel = null;
|
||||
}
|
||||
flightState._planeModelLoaded = false;
|
||||
flightState._billboards.clear();
|
||||
flightState._cullPositions.clear();
|
||||
|
||||
Reference in new issue
Block a user