mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
Draw Street Level's marker and cones through the renderer's draw port
The photo marker and every provider's image cones are icon sets on the draw port now, not billboard collections of their own. Each keeps its pick id as the item id, so clicks route as before; each set is drawn (empty) as soon as it is made, so the cones stay drawn over the marker whichever is first given something to show. The horizon cull still runs in the layer, against the ellipsoid lowered 1,000 m, and sends only the items whose show changed; a quiet first cull of items about to be drawn replaces the flags that held its callback back. marker and sequenceCones leave the Cesium allow-list. The Panoramax line click reads the camera height from the camera port. A difference the contract does not let us avoid: the icons turn to their bearing about local north (the contract's `course`), where the billboards used the Earth's axis. Looking straight down nothing changes; in a tilted view a cone now points along its true bearing on the ground instead of leaning toward the pole.
This commit is contained in:
1 parent
a10f3a16e1
commit
40ad27fb95
14 files changed
+432
-233
No files matched your search
@@ -99,7 +99,8 @@ export function createKartaViewProvider({
|
||||
sequence: {
|
||||
selectedId: null,
|
||||
images: [],
|
||||
collection: null,
|
||||
set: null,
|
||||
sprite: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
abort: null,
|
||||
|
||||
@@ -15,9 +15,11 @@ import {
|
||||
import { validateProviders } from '../../registry.js';
|
||||
import { fakeHost, until } from '../../../../testSupport/kartaViewFakes.mjs';
|
||||
import {
|
||||
bindStreetViewer,
|
||||
coverageViewer,
|
||||
tileCentre,
|
||||
} from '../../../../testSupport/streetLevelFakes.mjs';
|
||||
import { fakeDrawPort } from '../../../../testSupport/fakeDrawPort.mjs';
|
||||
|
||||
/** A photo record `metres` east of (42.3314, -83.0458), in sequence `seq` at `index`. */
|
||||
function photoRecord(id, { metres = 0, seq = '14010', index = 0 } = {}) {
|
||||
@@ -411,24 +413,24 @@ async function withCones(t, env) {
|
||||
createElement: () => ({ getContext: () => drawing }),
|
||||
};
|
||||
t.after(() => (globalThis.document = saved));
|
||||
let collection = null;
|
||||
env.instance.init({
|
||||
scene: {
|
||||
frameState: { mode: Cesium.SceneMode.SCENE3D },
|
||||
updateHeight: () => () => {},
|
||||
getHeight: () => undefined,
|
||||
primitives: { add: (c) => (collection = c), remove() {} },
|
||||
preRender: { addEventListener: () => () => {} },
|
||||
},
|
||||
camera: { positionWC: new Cesium.Cartesian3(0, 0, 1e8) },
|
||||
});
|
||||
const draw = fakeDrawPort();
|
||||
env.instance.init(
|
||||
bindStreetViewer(
|
||||
{
|
||||
scene: { preRender: { addEventListener: () => () => {} } },
|
||||
camera: { positionWC: new Cesium.Cartesian3(0, 0, 1e8) },
|
||||
},
|
||||
{ draw },
|
||||
),
|
||||
);
|
||||
const drawn = () => [
|
||||
...(draw.find('street-level:kartaview-cones:')?.items.values() ?? []),
|
||||
];
|
||||
const cones = () => {
|
||||
const indexes = [];
|
||||
for (let i = 0; i < collection.length; i++)
|
||||
indexes.push(Number(collection.get(i).id.split('-').at(-1)));
|
||||
const indexes = drawn().map((cone) => Number(cone.id.split('-').at(-1)));
|
||||
return [Math.min(...indexes), Math.max(...indexes)];
|
||||
};
|
||||
cones.count = () => collection?.length ?? 0;
|
||||
cones.count = () => drawn().length;
|
||||
return cones;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,8 @@ function createProviderState(context) {
|
||||
sequence: {
|
||||
selectedId: null,
|
||||
images: [],
|
||||
collection: null,
|
||||
set: null,
|
||||
sprite: null,
|
||||
loading: false,
|
||||
/** Why the selected sequence's images could not load, until it goes. */
|
||||
error: null,
|
||||
|
||||
@@ -7,6 +7,7 @@ import { createSequenceCones, thinImages } from '../../sequenceCones.js';
|
||||
import { passesImageryFilter } from '../../filter.js';
|
||||
import { lonToTileX, latToTileY, tileBounds } from '../../tileMath.js';
|
||||
import { metresBetween } from '../../view.js';
|
||||
import { findCamera } from '../../../../render/rendererOf.js';
|
||||
import { createLru, createTileCache } from '../../tileCache.js';
|
||||
import { decodeCoverageTileSliced, decodePictures } from './decode.js';
|
||||
import { createPanoramaxSource } from './source.js';
|
||||
@@ -169,7 +170,8 @@ export function createPanoramaxProvider({
|
||||
sequence: {
|
||||
selectedId: null,
|
||||
images: [],
|
||||
collection: null,
|
||||
set: null,
|
||||
sprite: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
abort: null,
|
||||
@@ -256,7 +258,9 @@ export function createPanoramaxProvider({
|
||||
* from high up the click may land tens of metres off the line.
|
||||
*/
|
||||
function lineClickRadius() {
|
||||
const height = state.viewer?.camera?.positionCartographic?.height;
|
||||
const height = state.viewer
|
||||
? findCamera(state.viewer)?.pose().height
|
||||
: undefined;
|
||||
if (!Number.isFinite(height)) return NEAREST_RADIUS_M;
|
||||
return Math.min(
|
||||
LINE_CLICK_RADIUS_MAX_M,
|
||||
|
||||
@@ -16,9 +16,11 @@ import { validateProviders } from '../../registry.js';
|
||||
import { tileBounds } from '../../tileMath.js';
|
||||
import { fakeHost, until } from '../../../../testSupport/kartaViewFakes.mjs';
|
||||
import {
|
||||
bindStreetViewer,
|
||||
coverageViewer,
|
||||
tileCentre,
|
||||
} from '../../../../testSupport/streetLevelFakes.mjs';
|
||||
import { fakeDrawPort } from '../../../../testSupport/fakeDrawPort.mjs';
|
||||
import {
|
||||
encodePanoramaxTile,
|
||||
stacItem,
|
||||
@@ -357,23 +359,22 @@ async function withCones(t, env) {
|
||||
createElement: () => ({ getContext: () => drawing }),
|
||||
};
|
||||
t.after(() => (globalThis.document = saved));
|
||||
let collection = null;
|
||||
env.instance.init({
|
||||
scene: {
|
||||
frameState: { mode: Cesium.SceneMode.SCENE3D },
|
||||
updateHeight: () => () => {},
|
||||
getHeight: () => undefined,
|
||||
primitives: { add: (c) => (collection = c), remove() {} },
|
||||
preRender: { addEventListener: () => () => {} },
|
||||
},
|
||||
camera: { positionWC: new Cesium.Cartesian3(0, 0, 1e8) },
|
||||
});
|
||||
const draw = fakeDrawPort();
|
||||
env.instance.init(
|
||||
bindStreetViewer(
|
||||
{
|
||||
scene: { preRender: { addEventListener: () => () => {} } },
|
||||
camera: { positionWC: new Cesium.Cartesian3(0, 0, 1e8) },
|
||||
},
|
||||
{ draw },
|
||||
),
|
||||
);
|
||||
const drawn = () => [
|
||||
...(draw.find('street-level:panoramax-cones:')?.items.values() ?? []),
|
||||
];
|
||||
return {
|
||||
count: () => collection?.length ?? 0,
|
||||
ids: () =>
|
||||
Array.from({ length: collection?.length ?? 0 }, (_, i) =>
|
||||
String(collection.get(i).id).replace(PICK_PREFIX.image, ''),
|
||||
),
|
||||
count: () => drawn().length,
|
||||
ids: () => drawn().map((cone) => cone.id.replace(PICK_PREFIX.image, '')),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -455,13 +456,12 @@ test('a line clicked from high up looks for its sequence further off; the radius
|
||||
];
|
||||
const { instance, source } = setup({ items });
|
||||
const height = (h) =>
|
||||
instance.init({
|
||||
camera: { positionCartographic: { height: h } },
|
||||
scene: {
|
||||
primitives: { add() {}, remove() {} },
|
||||
preRender: { addEventListener: () => () => {} },
|
||||
},
|
||||
});
|
||||
instance.init(
|
||||
bindStreetViewer({
|
||||
camera: { positionCartographic: { height: h } },
|
||||
scene: { preRender: { addEventListener: () => () => {} } },
|
||||
}),
|
||||
);
|
||||
const click = () =>
|
||||
instance.handlePick(`${PICK_PREFIX.sequence}line`, {
|
||||
groundPoint: () => east(0),
|
||||
@@ -821,13 +821,12 @@ test('a line clicked from low down still searches its own sequence within 50 m',
|
||||
...sequence('clicked', 1, { offset: 30 }),
|
||||
];
|
||||
const { instance, source } = setup({ items });
|
||||
instance.init({
|
||||
camera: { positionCartographic: { height: 300 } },
|
||||
scene: {
|
||||
primitives: { add() {}, remove() {} },
|
||||
preRender: { addEventListener: () => () => {} },
|
||||
},
|
||||
});
|
||||
instance.init(
|
||||
bindStreetViewer({
|
||||
camera: { positionCartographic: { height: 300 } },
|
||||
scene: { preRender: { addEventListener: () => () => {} } },
|
||||
}),
|
||||
);
|
||||
instance.handlePick(`${PICK_PREFIX.sequence}clicked`, {
|
||||
groundPoint: () => east(0),
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user