mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 16:52:20 +00:00
Draw the vessels layer's ships through the renderer's ports
The ships are one icon set from the draw port, held on course with hold motion segments and drawn over depth as before; the layer keeps what it last drew in an icon book and reads focus and pick ownership back from there, matching clicks on the draw hit's set and id. Its frame hook, camera pose, horizon test and screen projection come from the frame, camera and query ports, with the horizon lift in geo/horizon judging the same point the GPU cull does. The icons' draw set is disposed when the layer is destroyed. rendering.js no longer imports Cesium or touches the scene's primitives, picks, render events or camera, and leaves the Cesium allow-list. It still reads the canvas size for the label budget. Callers of the vessels entry load the Cesium adapter's unbound fallbacks.
This commit is contained in:
1 parent
bb85e0fa74
commit
f6422d2247
16 files changed
+394
-190
No files matched your search
@@ -3,7 +3,16 @@ import assert from 'node:assert/strict';
|
||||
import { createVesselLayer } from './index.js';
|
||||
import { createVesselState } from './state.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { createIconSet } from '../../data/iconSet.js';
|
||||
import { createVesselIconBook } from './iconBook.js';
|
||||
import { liftedForHorizon } from '../../geo/horizon.js';
|
||||
import { bindFakeCesiumCamera } from '../../testSupport/fakeCameraPort.mjs';
|
||||
import { fakeDrawPort } from '../../testSupport/fakeDrawPort.mjs';
|
||||
|
||||
/** A query port with nothing on screen: the viewer doubles have no scene. */
|
||||
const offscreen = {
|
||||
project: () => null,
|
||||
projectMany: (source, out) => out.fill(NaN),
|
||||
};
|
||||
|
||||
const noop = () => {};
|
||||
function services() {
|
||||
@@ -40,7 +49,9 @@ function services() {
|
||||
}
|
||||
function setup(source, options = {}, viewer = {}) {
|
||||
const layer = createVesselLayer({ source, services: services(), options });
|
||||
const icons = createIconSet();
|
||||
const icons = createVesselIconBook();
|
||||
if (viewer.camera)
|
||||
bindFakeCesiumCamera(viewer, { query: offscreen, draw: fakeDrawPort() });
|
||||
layer.testing._setVesselStateForTest({ viewer, icons });
|
||||
let now = 1000;
|
||||
layer.testing._setAisRuntimeForTest({
|
||||
@@ -279,19 +290,17 @@ test('refresh keeps the icon row and its pick identity, and eviction releases th
|
||||
let current = snapshot([observation('111')]);
|
||||
const { layer, icons } = setup({ getSnapshot: async () => current });
|
||||
await layer.update();
|
||||
assert.equal(icons.count, 1);
|
||||
assert.equal(icons.idAt(0), '111');
|
||||
const meta = icons.metaAt(0);
|
||||
const drawn = () =>
|
||||
icons.position(icons.row('111'), 0, new Cesium.Cartesian3());
|
||||
assert.deepEqual(icons.ids(), ['111']);
|
||||
const meta = icons.item('111').meta;
|
||||
const drawn = () => icons.item('111').pos;
|
||||
const near = (a, b) => Cesium.Cartesian3.distance(a, b) < 0.01;
|
||||
assert.ok(near(layer.findByQuery('111').position, drawn()));
|
||||
const oldPosition = drawn();
|
||||
current = snapshot([{ ...observation('111'), longitude: 4.06 }]);
|
||||
await layer.update();
|
||||
assert.equal(icons.count, 1);
|
||||
assert.equal(icons.size, 1);
|
||||
assert.equal(
|
||||
icons.metaAt(icons.row('111')),
|
||||
icons.item('111').meta,
|
||||
meta,
|
||||
'focus identity survives a refresh',
|
||||
);
|
||||
@@ -431,12 +440,9 @@ test('cards and detection judge the horizon where the icon shader culls the row'
|
||||
viewer,
|
||||
);
|
||||
await layer.update();
|
||||
const row = icons.row('111');
|
||||
occluder.cameraPosition = positionWC;
|
||||
assert.equal(
|
||||
occluder.isPointVisible(
|
||||
icons.cullPoint(row, icons.position(row, 0, new Cesium.Cartesian3())),
|
||||
),
|
||||
occluder.isPointVisible(liftedForHorizon(icons.item('111').pos)),
|
||||
true,
|
||||
);
|
||||
assert.deepEqual(
|
||||
|
||||
Reference in new issue
Block a user