mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Stack sprite layers by draw order, flights on top
Each sprite layer's icon or dot set is now made at a draw order taken from SPRITE_LAYER_ORDER through the renderer's per-set drawOrder: flights over military, vessels, directions, transit, bikeshare, FIRMS and CCTV, whichever layer was turned on first. Picks name the topmost first. The orders are negative, so selection highlights, route endpoints, the tracked plane and every other set at the default order still draw over all sprite layers, as they did before. The raise-to-top restorer, the sprite registry and the primitive-name lookups are gone, which takes spriteOrder.js off the viewer-access list. Before, the restorer raised the layers to the bottom of the scene in the order they were enabled, so flights usually ended up under the others.
This commit is contained in:
1 parent
657ef94f77
commit
c073064507
40 files changed
+271
-562
No files matched your search
@@ -4,7 +4,7 @@ import { createHorizonCull } from './view.js';
|
||||
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
import { drawOf } from '../../render/rendererOf.js';
|
||||
|
||||
const SPRITE_ID = 'street-level:marker';
|
||||
const SET_ID = 'street-level:marker';
|
||||
|
||||
/** Draw-set ids of the markers made so far, so every layer instance has its own. */
|
||||
let markerSets = 0;
|
||||
@@ -45,7 +45,7 @@ function markerIcon(position, bearing, look) {
|
||||
|
||||
/** On-globe marker for the open image, clamped to the ground. */
|
||||
export function createMarker({ state }) {
|
||||
const { render, sprites } = state.services;
|
||||
const { render } = state.services;
|
||||
|
||||
function requestRender() {
|
||||
render?.governorRequestRender?.('street-level-marker');
|
||||
@@ -69,13 +69,11 @@ export function createMarker({ state }) {
|
||||
function ensure(viewer) {
|
||||
if (state.marker.set) return;
|
||||
state.marker.set = drawOf(viewer).icons({
|
||||
id: `${SPRITE_ID}:${++markerSets}`,
|
||||
id: `${SET_ID}:${++markerSets}`,
|
||||
});
|
||||
// Drawn from now, empty: the marker keeps its place under the cones
|
||||
// (made after it), whichever is first given something to draw.
|
||||
// Drawn from now, empty: the marker keeps its place by when it was made
|
||||
// (before the cones), whichever is first given something to draw.
|
||||
state.marker.set.set([]);
|
||||
state.marker.sprite =
|
||||
sprites?.registerSpriteSet?.(SPRITE_ID, state.marker.set.id) ?? null;
|
||||
}
|
||||
|
||||
/** Move (or create) the marker; null removes it. `style`: the provider's `marker`. */
|
||||
@@ -112,10 +110,8 @@ export function createMarker({ state }) {
|
||||
horizon.stop();
|
||||
const markers = state.marker.set;
|
||||
if (!markers) return;
|
||||
sprites?.unregisterSpriteCollection?.(SPRITE_ID, state.marker.sprite);
|
||||
markers.dispose();
|
||||
state.marker.set = null;
|
||||
state.marker.sprite = null;
|
||||
state.marker.placed = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,23 +27,10 @@ function setup() {
|
||||
};
|
||||
const draw = fakeDrawPort();
|
||||
bindRenderer(viewer, streetPorts(viewer, { camera: true, draw }));
|
||||
/** Sprite-order registrations: setId → the entry handed out. */
|
||||
const sprites = new Map();
|
||||
const state = {
|
||||
services: {
|
||||
sprites: {
|
||||
registerSpriteSet(layerId, setId) {
|
||||
const entry = { layerId, setId };
|
||||
sprites.set(setId, entry);
|
||||
return entry;
|
||||
},
|
||||
unregisterSpriteCollection(layerId, entry) {
|
||||
if (sprites.get(entry?.setId) === entry) sprites.delete(entry.setId);
|
||||
},
|
||||
},
|
||||
},
|
||||
services: {},
|
||||
viewer,
|
||||
marker: { set: null, sprite: null, placed: null, look: null },
|
||||
marker: { set: null, placed: null, look: null },
|
||||
};
|
||||
const marker = createMarker({ state });
|
||||
marker.ensure(viewer);
|
||||
@@ -52,7 +39,7 @@ function setup() {
|
||||
};
|
||||
/** The marker's drawn icon, or undefined. */
|
||||
const icon = () => draw.find('street-level:marker:')?.items.get('sl:pos');
|
||||
return { state, viewer, view, preRender, marker, frame, draw, icon, sprites };
|
||||
return { state, viewer, view, preRender, marker, frame, draw, icon };
|
||||
}
|
||||
|
||||
test('the photo marker is hidden behind the globe, and shows from its side', () => {
|
||||
@@ -138,16 +125,14 @@ test('each placement is one write, culled before it is sent', () => {
|
||||
assert.equal(set.writes, before + 2);
|
||||
});
|
||||
|
||||
test('a marker destroyed and made again draws in a new set, registered once', () => {
|
||||
const { marker, viewer, draw, sprites, icon } = setup();
|
||||
test('a marker destroyed and made again draws in a new set', () => {
|
||||
const { marker, viewer, draw, icon } = setup();
|
||||
const first = draw.find('street-level:marker:').spec.id;
|
||||
assert.deepEqual([...sprites.keys()], [first]);
|
||||
marker.destroy();
|
||||
assert.equal(sprites.size, 0, 'its sprite order entry goes with it');
|
||||
assert.equal(draw.set(first), undefined, 'its set goes with it');
|
||||
marker.ensure(viewer);
|
||||
const second = draw.find('street-level:marker:').spec.id;
|
||||
assert.notEqual(second, first);
|
||||
assert.deepEqual([...sprites.keys()], [second]);
|
||||
marker.set(SPOT, 30);
|
||||
assert.equal(icon().course, 30);
|
||||
});
|
||||
@@ -100,7 +100,6 @@ export function createKartaViewProvider({
|
||||
selectedId: null,
|
||||
images: [],
|
||||
set: null,
|
||||
sprite: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
abort: null,
|
||||
|
||||
@@ -46,7 +46,6 @@ function createProviderState(context) {
|
||||
selectedId: null,
|
||||
images: [],
|
||||
set: null,
|
||||
sprite: null,
|
||||
loading: false,
|
||||
/** Why the selected sequence's images could not load, until it goes. */
|
||||
error: null,
|
||||
|
||||
@@ -171,7 +171,6 @@ export function createPanoramaxProvider({
|
||||
selectedId: null,
|
||||
images: [],
|
||||
set: null,
|
||||
sprite: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
abort: null,
|
||||
|
||||
@@ -27,7 +27,7 @@ export function filtersOf(provider) {
|
||||
* @property {(context: ProviderContext) => ProviderInstance} create
|
||||
*
|
||||
* @typedef {object} ProviderContext Handed to `create()` once by the core.
|
||||
* @property {object} services Scene services: picking, input, render, sprites (a `scenePick` given is not read).
|
||||
* @property {object} services Scene services: picking, input, render (a `scenePick` given is not read).
|
||||
* @property {() => {pano: string, sinceMs: number|null}} getFilter Filter resolved against now; read it on every use so "since N days" keeps up.
|
||||
* @property {() => boolean} isActive Layer enabled and this provider switched on.
|
||||
* @property {() => void} notify Ask the core to publish a new UI snapshot.
|
||||
|
||||
@@ -54,7 +54,7 @@ export function thinImages(images, spacingM = IMAGE_CONE_MIN_SPACING_M) {
|
||||
* The sequence's images in capture order, thinned (see `thinImages`).
|
||||
* @param {{coverage: string}} options.colors
|
||||
* @param {string} options.pickPrefix Pick-id prefix of the cones.
|
||||
* @param {string} options.spriteId Sprite-order id of the cone set (and its draw-set id's stem).
|
||||
* @param {string} options.spriteId Stem of the cone set's draw-set id.
|
||||
* @param {string} options.renderKey Render-governor reason.
|
||||
* @param {(sequenceId: string|null) => void} [options.onHighlight]
|
||||
* Highlight the sequence's coverage line (null: none).
|
||||
@@ -71,7 +71,7 @@ export function createSequenceCones({
|
||||
onHighlight = () => {},
|
||||
passes = passesImageryFilter,
|
||||
}) {
|
||||
const { render, sprites } = state.services;
|
||||
const { render } = state.services;
|
||||
|
||||
function requestRender() {
|
||||
render?.governorRequestRender?.(renderKey);
|
||||
@@ -101,10 +101,9 @@ export function createSequenceCones({
|
||||
state.sequence.set = drawOf(viewer).icons({
|
||||
id: `${spriteId}:${++coneSets}`,
|
||||
});
|
||||
// Drawn from now, empty: the cones keep their place over the marker.
|
||||
// Drawn from now, empty: the cones keep their place by when they were
|
||||
// made (after the marker).
|
||||
state.sequence.set.set([]);
|
||||
state.sequence.sprite =
|
||||
sprites?.registerSpriteSet?.(spriteId, state.sequence.set.id) ?? null;
|
||||
}
|
||||
|
||||
function clearCones() {
|
||||
@@ -232,10 +231,8 @@ export function createSequenceCones({
|
||||
cones = [];
|
||||
const set = state.sequence.set;
|
||||
if (set) {
|
||||
sprites?.unregisterSpriteCollection?.(spriteId, state.sequence.sprite);
|
||||
set.dispose();
|
||||
state.sequence.set = null;
|
||||
state.sequence.sprite = null;
|
||||
}
|
||||
state.sequence.images = [];
|
||||
state.sequence.selectedId = null;
|
||||
|
||||
@@ -55,8 +55,8 @@ export function createState({ services }) {
|
||||
/** Whether the camera is low enough for a ground click to open an image. */
|
||||
groundClickReady: false,
|
||||
|
||||
/** The open image's marker: its draw set, sprite registration and drawn icon. */
|
||||
marker: { set: null, sprite: null, placed: null, look: null },
|
||||
/** The open image's marker: its draw set and drawn icon. */
|
||||
marker: { set: null, placed: null, look: null },
|
||||
clickSubscription: null,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user