mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
fix(rail, transit): a train or vehicle a first-person view holds draws no 3D model either, since the view's eye is inside it; let go, its model draws again
The fleet models (#1714) draw nearby trains and vehicles under the 3D toggle. A held one now leaves out its model as it does its icon, as the Vessels layer does for its bridge subject: its model item is hidden, and handing the visual back to its icon keeps the icon hidden while held. Tests drive each layer with the real fleet-model layer and a stubbed glTF loader; both fail without the fix.
This commit is contained in:
1 parent
546ac22708
commit
974023510f
12 files changed
+212
-17
No files matched your search
@@ -0,0 +1,68 @@
|
||||
// Fleet models for a layer test (fleetModelInstances.js): the project's model
|
||||
// set loaded from public/, a DISPLAY 3D toggle that is on, and Cesium's glTF
|
||||
// loader replaced by one that answers at once with a ready model, recorded.
|
||||
import * as Cesium from 'cesium';
|
||||
import { loadFleetModelSet } from '../data/fleetModels.js';
|
||||
import { fetchPublicFile } from './fleetGlb.mjs';
|
||||
|
||||
/** A model policy whose eligibility is read again on every frame. */
|
||||
export const FLEET_TEST_POLICY = Object.freeze({
|
||||
altitudeCeilingM: 800_000,
|
||||
minimumPixelSize: 16,
|
||||
cap: 4,
|
||||
capAll: 8,
|
||||
addM: 5_000,
|
||||
addAllM: 20_000,
|
||||
keepM: 6_000,
|
||||
keepAllM: 24_000,
|
||||
intervalMs: 0,
|
||||
});
|
||||
|
||||
/**
|
||||
* Load the fleet set (once a process, as the app does) and fake the loader
|
||||
* for this test. Call it before the layer's harness, which replaces `fetch`.
|
||||
* @param {import('node:test').TestContext} t
|
||||
* @returns {Promise<{fleet: object, created: object[],
|
||||
* drawn: (id: string) => object[]}>} `fleet` for the layer's services;
|
||||
* `drawn(id)` the models drawn for the vehicle `id` now.
|
||||
*/
|
||||
export async function fleetModelFakes(t) {
|
||||
const info = console.info;
|
||||
console.info = () => {};
|
||||
try {
|
||||
await loadFleetModelSet({ fetchImpl: fetchPublicFile });
|
||||
} finally {
|
||||
console.info = info;
|
||||
}
|
||||
const created = [];
|
||||
t.mock.method(Cesium.Model, 'fromGltfAsync', async (options) => {
|
||||
const model = {
|
||||
...options,
|
||||
ready: true,
|
||||
show: false,
|
||||
modelMatrix: new Cesium.Matrix4(),
|
||||
destroyed: false,
|
||||
destroy() {
|
||||
this.destroyed = true;
|
||||
},
|
||||
isDestroyed() {
|
||||
return this.destroyed;
|
||||
},
|
||||
update() {},
|
||||
};
|
||||
created.push(model);
|
||||
return model;
|
||||
});
|
||||
return {
|
||||
fleet: {
|
||||
policy: FLEET_TEST_POLICY,
|
||||
display: () => ({ models3d: true, models3dMode: 'proximity' }),
|
||||
resolveAsset: (url) => url,
|
||||
},
|
||||
created,
|
||||
drawn: (id) =>
|
||||
created.filter(
|
||||
(model) => model.id === id && !model.destroyed && model.show,
|
||||
),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user