mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6982dc934 | ||
|
|
2b7a6b0c63 | ||
|
|
81fe7f88cc | ||
|
|
2e18673df8 | ||
|
|
65942008bf | ||
|
|
c536d22ff0 | ||
|
|
aabfa5e084 | ||
|
|
87bff9957b | ||
|
|
607796737c |
No files matched your search
@@ -1,7 +0,0 @@
|
||||
- `F` now collapses and reopens the Data Layers panel the way the panel's own
|
||||
button does, and its rail entry stays. Before, `F` hid the panel together
|
||||
with its rail entry, so only another `F` brought it back. When `F` or a
|
||||
panel's collapse button hides a panel that holds the focus, including one
|
||||
the opened panel folds away, the focus moves to that panel's rail entry;
|
||||
in Cockpit, focus in the Contact card it folds moves to the card's expand
|
||||
button (asturksever, #1598).
|
||||
@@ -0,0 +1,8 @@
|
||||
- Zoomed out, a CCTV ground cell with two or more cameras is now one round
|
||||
marker with a camera icon and the count (`999`, `1.7K`, `12K` in every
|
||||
language). It grows with the count, merges with markers it would overlap,
|
||||
takes in a lone camera right beside it, and zooms in on click until the
|
||||
group splits. Idle cameras and markers are green. The active camera stays
|
||||
amber and video cameras violet. Cameras on one mount draw side by side, and
|
||||
a camera the terrain height service never answered for stands on the drawn
|
||||
terrain (gekh, #1808).
|
||||
@@ -1,3 +0,0 @@
|
||||
- The data credits line and its list are now a single-file component. The
|
||||
close button is the kit's, and a focused link keeps focus when the list
|
||||
redraws (manjunath22466, samehkhamis, #1844).
|
||||
@@ -1,3 +0,0 @@
|
||||
- The Québec CCTV camera window and its map marker are now a single-file
|
||||
component with the kit's close and buttons, and the window's labels follow
|
||||
the language at each update (manjunath22466, samehkhamis, #1845).
|
||||
@@ -1,3 +0,0 @@
|
||||
- The Omnibar's guided walk is now a single-file component with the kit's
|
||||
close and buttons, and a walk started while the page is still drawing no
|
||||
longer fails (manjunath22466, samehkhamis, #1846).
|
||||
@@ -1,2 +0,0 @@
|
||||
- The Omnibar's mic, suggestion strip chips and glyphs are now kit controls,
|
||||
with the same look and behaviour (manjunath22466, samehkhamis, #1847).
|
||||
@@ -1,2 +0,0 @@
|
||||
- The welcome card's buttons and glyphs are now kit controls, with the same
|
||||
look and behaviour (manjunath22466, samehkhamis, #1848).
|
||||
@@ -1,2 +0,0 @@
|
||||
- The Visual panel's buttons and glyphs are now kit controls, with the same
|
||||
look and behaviour (manjunath22466, samehkhamis, #1849).
|
||||
@@ -1,2 +0,0 @@
|
||||
- The entity card's buttons and glyphs are now kit controls, with the same
|
||||
look and behaviour (manjunath22466, samehkhamis, #1850).
|
||||
@@ -1,2 +0,0 @@
|
||||
- The Layer Finder's buttons and glyphs are now kit controls, with the same
|
||||
look and behaviour (manjunath22466, samehkhamis, #1851).
|
||||
@@ -1,3 +0,0 @@
|
||||
- The Stories views' buttons and Explore's filter checkbox are now kit
|
||||
controls, with the same look and behaviour (manjunath22466, samehkhamis,
|
||||
#1852).
|
||||
+31
-14
@@ -1991,14 +1991,31 @@ directory. Every `/api/cctv` route refuses cross-site browser requests but
|
||||
accepts forwarding headers, so cameras work behind a reverse proxy; a forwarded
|
||||
request skips the key-bearing Street View fallback and gets the placeholder.
|
||||
|
||||
The CCTV layer draws only the cameras on or near the screen. Zoomed out, it
|
||||
keeps one camera per ground cell sized to the view, preferring a healthy feed,
|
||||
and the cells are anchored to the ground so a pan keeps the same cameras. The
|
||||
active camera always shows. Ground placement and coverage geometry load only
|
||||
for the cameras in view, with at most two attempts per camera and view regime.
|
||||
The view pass reruns while the camera moves, paced by its own cost. The camera
|
||||
picker lists the cameras in view, active camera first, and closes with the
|
||||
count of cameras outside the view.
|
||||
The CCTV layer draws only the cameras on or near the screen. Zoomed out, a
|
||||
ground cell with two or more cameras shows one marker at their mean position. A
|
||||
green camera pictogram sits under its top edge and the count just below its
|
||||
middle. The marker grows with the count and paints on the world overlay at
|
||||
callout resolution. The count covers the whole cell up to the horizon, including
|
||||
its off-screen cameras. Overlapping markers merge and add their counts. A lone
|
||||
camera whose icon would touch a marker joins the nearest one, unless the HUD
|
||||
hides the merged marker. In that case the lone camera keeps its icon and the
|
||||
count stays where it was before the merge. The active camera keeps its own icon
|
||||
beside any marker that would cover it and stays out of the count. A click on a
|
||||
marker zooms in on its group, at least halving the distance each time. If halving
|
||||
would leave the group wider than the frame, the view zooms in on the group's
|
||||
ground cell nearest the eye. The cockpit or a tracked object holds the view
|
||||
in place. Ambient cards and coverage attach only to
|
||||
cameras drawn as icons. On a globe map a marker stands on the drawn terrain. A
|
||||
camera the height batch never answered for takes the drawn terrain as its ground
|
||||
once it is near the screen. It reads that height again from much closer, once
|
||||
the terrain in view has loaded, or when the terrain source changes. A later
|
||||
Re:Earth answer replaces it. A fallback preserves it. Close up every camera
|
||||
shows. Cameras on one mount draw side by side and their records keep the mount.
|
||||
Ground placement has at most two attempts per camera and view regime. The view
|
||||
pass reruns while the camera moves, paced by its own cost, and when the terrain
|
||||
in view finishes loading. The camera picker lists the active camera first, then
|
||||
one camera per visible cell, preferring healthy feeds. It ends with the count of
|
||||
catalog cameras missing from the list.
|
||||
|
||||
Traffic owns its rendered-surface observer only while enabled, removes it on disable/destroy, and rebuilds no cached heights on frames where the surface identity is unchanged. Its dots and heat-lines are two renderer draw sets, it animates on the frame port's preRender, and it follows the camera through the camera port at its own 5% threshold rather than the shared `percentageChanged` ledger. The surface identity is the globe port's `surfaceVersion()` and tile readiness its `isSettled('surface')`, so the layer no longer reaches Cesium. Heat-lines are always asked for draped: where the Cesium renderer cannot drape (no depth textures) its draw port draws them (and every other draped line) over the surface, in their colour where the surface hides them and hidden past the horizon, recolouring a line in place when only its colour changes, rather than the layer dropping them.
|
||||
|
||||
@@ -2117,7 +2134,10 @@ trail, a route. A layer under another layer's card or label
|
||||
(`isUnderOtherCard`) does nothing: it neither acts on its item there nor
|
||||
treats the click as empty space, so a tracked aircraft stays tracked and a
|
||||
selection stays selected. Context (`src/ui/entityContextBridge.js`) names
|
||||
nothing under a card. With no card on top, the scene rules are unchanged.
|
||||
nothing under a card. A layer can claim a target it paints outside the overlay's
|
||||
entries (`registerClickClaim`) where no card or label is on top. A CCTV count
|
||||
claims each click that zooms to it, so a tracked aircraft stays tracked.
|
||||
With no card or claim on top, the scene rules are unchanged.
|
||||
World-overlay hit rectangles are what is painted on screen until the next
|
||||
paint: an overlay change (a click subscriber publishing its selection card)
|
||||
no longer clears them mid-click, and a paint that draws nothing clears them
|
||||
@@ -3350,10 +3370,7 @@ Browser acceptance: `QA_BASE_URL=http://127.0.0.1:4173 node scripts/qa-segmented
|
||||
|
||||
`ui/input` supplies the bubbling application shortcut listener and generated
|
||||
shader-parameter rows. Number/style keys, H/O/V/F/D/C actions, native form-control
|
||||
typing and Escape behavior retain their existing mappings. `F` collapses and
|
||||
reopens Data Layers the way the panel's own collapse button does, so its rail
|
||||
entry stays; if focus was inside the panel, it moves to that rail entry.
|
||||
A shortcut key held
|
||||
typing and Escape behavior retain their existing mappings. A shortcut key held
|
||||
with Cmd, Ctrl or Alt runs no shortcut, so the browser's own chord (Cmd+C to
|
||||
copy, Cmd+F to find, Cmd+1 to switch tab) does not also toggle CCTV, the layers
|
||||
panel or a style; Shift does not count, and Escape dismisses search either way.
|
||||
@@ -7516,7 +7533,7 @@ silently demoting every later lookup for the session.
|
||||
ground clamp now lifts the cap _center_ only so the wireframe stays a true pyramid welded to
|
||||
the plane (was a flattened fan / the ~47.5 m divergence — RESOLVED), re-selecting the active
|
||||
camera is a no-op (killed a click-flash), and texture swaps gate on canvas content (killed a
|
||||
periodic white flash). Camera icons are cyan for stills, violet for cameras with a video feed, and amber for the active camera. Coverage is now **metro-wide: 250 cameras** (`CCTV_AUSTIN_MAX_SOURCES`
|
||||
periodic white flash). Camera icons are green for stills, violet for cameras with a video feed, and amber for the active camera. Coverage is now **metro-wide: 250 cameras** (`CCTV_AUSTIN_MAX_SOURCES`
|
||||
default 36 → 250, hard bound 300), filtered to `camera_status === TURNED_ON` (~815 live of
|
||||
1,003 rows). City packs (2026-07-04): Caltrans (districts 4/7/11/3 — SF, LA, San Diego,
|
||||
Sacramento; cap 300) and TfL London JamCams (cap 250) join Austin (cap 250) as keyless default
|
||||
|
||||
@@ -107,6 +107,7 @@ Call it before views render. `onLocaleChange` listeners word their text again at
|
||||
- **Translate the label, not the value.** Layer ids, enums, share-link parameters, API fields, voice tool schemas and feed data (callsigns, vessel and place names) stay as they are; translate only the text shown for them.
|
||||
- **No `t()` at module top level.** Keep the English in `msg()` and call `t()` when rendering.
|
||||
- **Numbers and dates** go through `formatNumber`, `formatDate`, `formatRelativeTime` and `formatUtcDayMonth` from `src/i18n/index.js`, which follow the active language.
|
||||
Compact CCTV count badges painted on the map use Latin digits, a decimal point and a `K` suffix for thousands (`999`, `1.7K`, `12K`). Each badge keeps its width and reads the same across locales. Format these badges only with `formatCameraCount` in `src/data/cctvCellCounts.js`.
|
||||
- **Identical English means identical translation,** unless you give it a context: `t('CLEAR', { context: 'action' })` (a button) is its own catalog entry, `action|CLEAR`, while `t('CLEAR')` (the sky) stays separate. English output is the same.
|
||||
- **Text that should stay English** (a brand, a code, a unit symbol) is simply not wrapped.
|
||||
|
||||
|
||||
+14
-99
@@ -83,70 +83,12 @@ segmented group in Core is a `UiSegmented`; the old `segmentedControl.js`
|
||||
adapter is gone.
|
||||
`UiButton` adds `pressedClass`, Core's class on a pressed toggle (most use
|
||||
`active`); its pressed classes toggle through `classList`, so a class other
|
||||
code adds (a voice highlight) survives a press. Not every pressed toggle in
|
||||
the views is one yet: the context view and a few panel buttons still
|
||||
hand-write theirs, and
|
||||
Bhote Koshi's cinematic button and the tilt-map button have owners that
|
||||
write their state into the DOM. Core's
|
||||
code adds (a voice highlight) survives a press. Every pressed toggle in the
|
||||
views is a `UiButton` except Bhote Koshi's cinematic button and the
|
||||
tilt-map button, whose owners still write their state into the DOM. Core's
|
||||
pressable chips and pills (rail card chips, map sources, cities and places)
|
||||
are `UiButton`s too; `UiChip` is a non-interactive label chip, used by
|
||||
the voice card.
|
||||
The welcome card's buttons (SKIP, the three start tiles, BROWSE STORIES,
|
||||
BACK and the main NEXT / ENTER GOD MODE action) are ghost `UiButton`s:
|
||||
the start tiles are pressed toggles, and all but SKIP keep `aria-disabled`
|
||||
rather than `disabled`, so they stay focusable while the card is busy. Its
|
||||
tile, tip, Stories and arrow glyphs are `UiIcon`s with `:size="null"`, so
|
||||
first-run.css still sizes them (`src/ui/kit/welcomeControls.test.mjs` pins
|
||||
it). God mode's preview globe and callouts stay inline SVG drawings, and
|
||||
its outbound links stay links.
|
||||
Every button in the Stories views (the Stories entry and its popup and
|
||||
toast, Explore, the Story screen, its header, rail, timeline and context
|
||||
panel) is a ghost `UiButton`. Explore's topic chips and map pins, the
|
||||
Story screen's Context button and the timeline's Expand map are pressed
|
||||
toggles, with no pressed class since their skins read `aria-pressed`;
|
||||
Explore's story cards are `role="button"` elements and keep their own
|
||||
`aria-pressed`. Their glyphs are inline SVG drawn for Stories, which no
|
||||
Material symbol the page loads draws the same, so they stay SVG; the two
|
||||
search fields keep their own markup, since `UiSearchField`'s Material
|
||||
magnifier would replace their SVG one, and their clear buttons, which draw
|
||||
an SVG cross, are ghost `UiButton`s rather than `UiCloseButton`s
|
||||
(`src/ui/kit/storiesControls.test.mjs` pins it).
|
||||
The Omnibar's mic (a pressed toggle with `active`) and its suggestion
|
||||
strip's chips (options, so `aria-current` rather than `pressed`) are
|
||||
ghost `UiButton`s, and its search, row and chip glyphs are `UiIcon`s with
|
||||
`:size="null"`, so its own rules still size them
|
||||
(`src/ui/kit/omnibarControls.test.mjs` pins it). The mic's and the chat
|
||||
row's glyphs stay inline SVG, since no Material symbol the page loads
|
||||
draws them, and its field is its own combobox rather than a
|
||||
`UiSearchField`.
|
||||
The Visual panel's buttons (its presets and map sources, HUD, Sonar,
|
||||
Detection, 3D, Clean UI, Celestial, Bloom, Sharpen and Reset to default) are
|
||||
ghost `UiButton`s. HUD, Sonar, 3D, Celestial, Bloom and Sharpen are
|
||||
pressed toggles with `active` as their pressed class; Detection sets its own
|
||||
`active` and `panoptic` classes, and Clean UI is not a pressed toggle (its
|
||||
owner marks it `active`). The panel's Scope, Celestial,
|
||||
sky, application-row and Reset glyphs are `UiIcon`s with `:size="null"`, so
|
||||
the panel's rules still size them (`src/ui/kit/visualControls.test.mjs` pins
|
||||
it). The toggles' other glyphs (◎ ▣ ✈ □ ✨ 🔍) and the presets' style glyphs
|
||||
are text characters, not Material symbols, and stay plain spans.
|
||||
The entity card's buttons are ghost `UiButton`s: its four preview buttons
|
||||
(Photos, Route, 3D, Cockpit view) are pressed toggles with `active`, Follow
|
||||
is one with `entity-card__action--on`, and the cockpit entry, Fly to and
|
||||
Ask GEV are plain buttons; so are the camera preview's bigger-view and More
|
||||
info buttons and the nearby lists' rows (`SpotConditions`, which the
|
||||
context view shows too). Their glyphs are `UiIcon`s with `:size="null"`,
|
||||
so entity-card.css and spot-conditions.css still size them
|
||||
(`src/ui/kit/entityCardControls.test.mjs` pins it). Ask GEV's chat bubble
|
||||
stays inline SVG, since no Material symbol the page loads draws it.
|
||||
The Layer Finder's buttons (Search, Filter, the filter menu's Status and
|
||||
Category options and the bar's two clear chips) are ghost `UiButton`s.
|
||||
Search and the options are pressed toggles; the options' pressed class is
|
||||
`active`, while Search keeps its own `active` binding, which also stays on
|
||||
while a query is typed. The Filter button opens a disclosure and carries
|
||||
`aria-expanded`, not `aria-pressed`. Every glyph its own template draws is
|
||||
a `UiIcon` with `:size="null"`, so `layer-finder.css` still sizes them
|
||||
(`src/ui/kit/layerFinderControls.test.mjs` pins it); the search field's
|
||||
magnifier is `UiSearchField`'s own span.
|
||||
`UiSelect` renders the bare native select (Core's labels sit outside it or
|
||||
come as an `aria-label`) with `v-model`, `options` and `disabled`;
|
||||
options that carry their own attributes come through the slot, a caller's
|
||||
@@ -164,14 +106,10 @@ empty rows stay a paragraph and table cells.
|
||||
`UiCloseButton` is a `UiButton` with a fixed glyph, a required `label` and
|
||||
no tip unless the site passes a `title`; attributes and classes pass through,
|
||||
so each site keeps its id, feature class and look. Every close, dismiss and
|
||||
clear button in the views that draws a cross is one
|
||||
(`src/ui/kit/closeButtons.test.mjs` pins it) except Story Explore's two
|
||||
search clears, whose SVG cross is neither of its glyphs; the Story context
|
||||
sheet's Close is a text button, a plain `UiButton`. Street Level's and the
|
||||
space mission's keep `bare`, since their skins set their own padding and
|
||||
border, and so does the credits list's. The
|
||||
Quebec CCTV overlay's close is one too, and so is the Omnibar guide's,
|
||||
which keeps its feature class and tip.
|
||||
clear button in the views is one (`src/ui/kit/closeButtons.test.mjs` pins
|
||||
it); Street Level's and the space mission's keep `bare`, since their skins
|
||||
set their own padding and border. The close buttons built in script (credits, the
|
||||
Quebec CCTV overlay, the guide) are not converted yet.
|
||||
`UiSearchField` takes `v-model`, a required `label` (the input's
|
||||
accessible name), `placeholder` and `tag` (`div`, given `role="search"` by
|
||||
the site, or `label`); attributes and classes go to the frame, and
|
||||
@@ -196,10 +134,9 @@ a refused change. Attributes and classes go to the label; `inputId` and
|
||||
`inputAttrs` (such as `aria-describedby` or a data hook) to the box. The
|
||||
Visual panel's Scope, sky and application toggles, the voice and chat
|
||||
preferences, the Data Library's filter and the welcome card's box are
|
||||
`UiCheckbox`es, and so are Story Explore's filter options, whose label
|
||||
keeps its `fopt` class (`src/ui/kit/checkboxes.test.mjs` pins it). Its kit
|
||||
rule holds the centred row the checkbox-only labels drew, moved rather than
|
||||
copied.
|
||||
`UiCheckbox`es (`src/ui/kit/checkboxes.test.mjs` pins it); Story Explore's
|
||||
filters are not converted yet. Its kit rule holds the centred row the
|
||||
checkbox-only labels drew, moved rather than copied.
|
||||
`UiDialog` is a native `<dialog>` its owner opens and closes with `open`:
|
||||
true opens it with `showModal()` (on mount, for one mounted open), false
|
||||
closes it, and unmounting closes it. Each change is applied once the content
|
||||
@@ -240,12 +177,6 @@ page declares no dark `color-scheme`. Selects and number fields are
|
||||
and keeps native spinners dark; ranges are `.gev-quantitative-slider`, with
|
||||
a feature supplying only its accent.
|
||||
|
||||
`t()` is not reactive. Words a view passes to a kit component as a prop
|
||||
(`UiCloseButton`'s `label`) follow a locale change on the view's next
|
||||
render, but words in a kit component's slot do not: the compiled slot does
|
||||
not render the child again. A view whose words must follow the locale at
|
||||
once passes the locale itself as a prop or key, as the credits line does.
|
||||
|
||||
## Phases
|
||||
|
||||
1. **Foundation.** Vue, Pinia and the Vite Vue plugin join the browser build
|
||||
@@ -313,13 +244,8 @@ once passes the locale itself as a prop or key, as the credits line does.
|
||||
the whole panel from the `gev-cctv` store, including the camera picker,
|
||||
the inline pose editor, the frame preview, source badge and typed
|
||||
summary; `CctvControls` keeps its listeners, the frame requests and the
|
||||
live video surface; `QuebecCctvOverlay` teleports the Québec 511 player
|
||||
and its map preview to the end of the body, rendered synchronously by
|
||||
`createQuebecCctvOverlay()` from the view it computes, as the rail cards
|
||||
are; the owner keeps every decision and the parts the template never
|
||||
binds: each video's source, playback and refresh timer, the window's drag
|
||||
and the marker's per-frame visibility and place), Layers (done:
|
||||
`LayerPanel` presents each row and renders `LayerRows` synchronously; keyed chips and list items keep focus
|
||||
live video surface), Layers (done: `LayerPanel` presents each row and
|
||||
renders `LayerRows` synchronously; keyed chips and list items keep focus
|
||||
through the refresh their own click triggers, and clicks re-read the live
|
||||
descriptor before acting), Display (in progress: `DisplayPanel` renders
|
||||
the HUD, Sonar, Scope, Celestial, detection, bloom, sharpen and the
|
||||
@@ -364,11 +290,7 @@ once passes the locale itself as a prop or key, as the credits line does.
|
||||
`gev-location` store, and the search field keeps its listeners; beside
|
||||
the voice control, the dock teleports each voice pointer reticle to the
|
||||
body where its `PointerReticle` presents it in the `gev-pointer-reticle`
|
||||
store; `startGuide()` renders the Omnibar's guided walk, `OmnibarGuide`,
|
||||
synchronously from the view it computes for each step, teleported to the
|
||||
end of the body, and keeps every decision and word, focus and its return,
|
||||
Escape, the entrance replay, and the callout's and spotlight rings' place
|
||||
each frame), the phone shell (`PhoneTabBar` renders the tabs and open sheet the shell
|
||||
store), the phone shell (`PhoneTabBar` renders the tabs and open sheet the shell
|
||||
publishes to the `gev-display` store, teleporting the tab bar and sheet
|
||||
backdrop to the end of the page from the first publish until the shell
|
||||
is destroyed; the shell takes their clicks from the document), the
|
||||
@@ -446,14 +368,7 @@ once passes the locale itself as a prop or key, as the credits line does.
|
||||
choices, DISMISS and "Don't show this again" call the launcher's
|
||||
controls; a refused save hands the tick back to the view to revert. The
|
||||
launcher still reads the rendered card for its hit test, keyboard trap,
|
||||
focus and overflow measurement), the attribution line (for a renderer
|
||||
without its own credit display, `mountCreditsView()` renders
|
||||
`CreditsView` synchronously, as the weather readout is, and the view
|
||||
teleports the line and its "Data attribution" list to the end of the
|
||||
body, where the page's rules select them; the owner keeps the credits
|
||||
shown, the list's open state and its focus, and words the view again
|
||||
when the locale changes; the list's close button is a bare
|
||||
`UiCloseButton`), then
|
||||
focus and overflow measurement), then
|
||||
Cockpit (in progress: `CockpitBriefing` renders the briefing card's
|
||||
pages, cycle toggle, regional news and local conditions, and
|
||||
`CockpitContext` the Contact card's scope, navigation, counts, nearest
|
||||
|
||||
@@ -640,6 +640,9 @@
|
||||
"src/layers/cctv/health.js",
|
||||
"src/data/cctv.js",
|
||||
"src/data/cctvCatalogCap.test.mjs",
|
||||
"src/data/cctvCellCounts.test.mjs",
|
||||
"src/data/cctvViewPass.test.mjs",
|
||||
"src/data/cctvViewThinning.test.mjs",
|
||||
"src/data/cctvDisplayCode.test.mjs",
|
||||
"src/data/cctvFootprint.js",
|
||||
"src/data/cctvGroundHeights.test.mjs",
|
||||
@@ -658,6 +661,10 @@
|
||||
"src/data/cctvTxdotSource.test.mjs",
|
||||
"src/layers/cctv/source.test.mjs",
|
||||
"src/layers/cctv/frames.test.mjs",
|
||||
"src/layers/cctv/countMarkers.test.mjs",
|
||||
"src/layers/cctv/count_click_overlay.test.mjs",
|
||||
"src/layers/cctv/count_click_framing.test.mjs",
|
||||
"src/layers/cctv/ground.test.mjs",
|
||||
"src/layers/cctv/rendering.test.mjs",
|
||||
"src/data/alprCameras.js",
|
||||
"src/data/alprCameras.test.mjs",
|
||||
@@ -1343,12 +1350,6 @@
|
||||
"src/ui/kit/UiDialog.vue",
|
||||
"src/ui/kit/UiDialog.test.mjs",
|
||||
"src/ui/kit/dialogs.test.mjs",
|
||||
"src/ui/kit/layerFinderControls.test.mjs",
|
||||
"src/ui/kit/entityCardControls.test.mjs",
|
||||
"src/ui/kit/visualControls.test.mjs",
|
||||
"src/ui/kit/welcomeControls.test.mjs",
|
||||
"src/ui/kit/omnibarControls.test.mjs",
|
||||
"src/ui/kit/storiesControls.test.mjs",
|
||||
"src/ui/styles/chip.css",
|
||||
"src/ui/styles/empty-state.css",
|
||||
"src/ui/rail/RailChips.vue",
|
||||
@@ -1591,8 +1592,6 @@
|
||||
"src/ui/creditLineHeight.js",
|
||||
"src/ui/creditLineHeight.test.mjs",
|
||||
"src/ui/creditsView.test.mjs",
|
||||
"src/ui/credits/CreditsView.vue",
|
||||
"src/ui/credits/CreditItem.vue",
|
||||
"src/cockpitSubjectProviders.js",
|
||||
"src/cockpitSubjectProviders.test.mjs",
|
||||
"src/cockpitProgress.js",
|
||||
@@ -1632,7 +1631,6 @@
|
||||
"src/tooling/wikidataPlaceTiles.test.mjs",
|
||||
"src/ui/omnibarIntent.test.mjs",
|
||||
"src/ui/omnibarRows.test.mjs",
|
||||
"src/ui/omnibarGuide.test.mjs",
|
||||
"src/ui/styles/omnibar-dock.css",
|
||||
"src/ui/styles/guide.css",
|
||||
"src/ui/commandDock.test.mjs",
|
||||
|
||||
@@ -300,7 +300,6 @@
|
||||
"src/exclusiveSurfaces.js",
|
||||
"src/geoDistance.js",
|
||||
"src/ui/omnibarGuide.js",
|
||||
"src/ui/views/panels/OmnibarGuide.vue",
|
||||
"src/cityPois.js",
|
||||
"src/search/photonSetting.js",
|
||||
"src/sources/requestDeadline.js",
|
||||
@@ -1097,11 +1096,6 @@
|
||||
"src/ui/cctvVideo.js",
|
||||
"src/ui/cctvPresentation.js",
|
||||
"src/ui/quebecCctvOverlay.js",
|
||||
"src/ui/views/panels/QuebecCctvOverlay.vue",
|
||||
"src/ui/kit/UiButton.vue",
|
||||
"src/ui/kit/UiCloseButton.vue",
|
||||
"src/ui/kit/UiIcon.vue",
|
||||
"src/ui/rail/classToggle.js",
|
||||
"src/i18n/index.js",
|
||||
"src/i18n/locale.js",
|
||||
"src/i18n/locales/ar.json",
|
||||
@@ -1641,7 +1635,6 @@
|
||||
"src/layers/wildlifeSightings/photoText.js",
|
||||
"src/data/iconOrientation.js",
|
||||
"src/ui/quebecCctvOverlay.js",
|
||||
"src/ui/views/panels/QuebecCctvOverlay.vue",
|
||||
"src/time/worldClock.js",
|
||||
"src/cockpitSubjects.js",
|
||||
"src/cockpitRadar.js",
|
||||
@@ -3351,6 +3344,9 @@
|
||||
"src/data/cctvCards.js",
|
||||
"src/data/cctvGizmo.js",
|
||||
"src/data/cctvLod.js",
|
||||
"src/data/cameraFraming.js",
|
||||
"src/data/cctvCellCounts.js",
|
||||
"src/layers/cctv/countMarkers.js",
|
||||
"src/data/cctvViewshed.js",
|
||||
"src/data/iconOrientation.js",
|
||||
"src/data/screenRotation.js",
|
||||
@@ -4313,6 +4309,8 @@
|
||||
"src/data/cctvFootprint.js",
|
||||
"src/data/cctvGizmo.js",
|
||||
"src/data/cctvLod.js",
|
||||
"src/data/cctvCellCounts.js",
|
||||
"src/layers/cctv/countMarkers.js",
|
||||
"src/data/cctvViewshed.js",
|
||||
"src/data/cockpitAirLod.js",
|
||||
"src/data/cockpitContactDot.js",
|
||||
@@ -5385,7 +5383,6 @@
|
||||
"src/ui/kit/UiEmpty.vue",
|
||||
"src/ui/kit/UiBadge.vue",
|
||||
"src/ui/kit/UiCloseButton.vue",
|
||||
"src/ui/kit/UiCheckbox.vue",
|
||||
"src/ui/stores/globeActions.js",
|
||||
"src/ui/stores/recording.js",
|
||||
"src/ui/i18n.js",
|
||||
@@ -5467,7 +5464,6 @@
|
||||
"src/layers/wildlifeSightings/iconCollection.js",
|
||||
"src/layers/wildlifeSightings/view.js",
|
||||
"src/ui/quebecCctvOverlay.js",
|
||||
"src/ui/views/panels/QuebecCctvOverlay.vue",
|
||||
"src/time/viewerClock.js",
|
||||
"src/time/worldClock.js",
|
||||
"src/cockpitSubjects.js",
|
||||
@@ -5497,8 +5493,6 @@
|
||||
"src/render/cesium/viewers.js",
|
||||
"src/ui/creditLineHeight.js",
|
||||
"src/ui/creditsView.js",
|
||||
"src/ui/credits/CreditsView.vue",
|
||||
"src/ui/credits/CreditItem.vue",
|
||||
"src/data/planespottersPhoto.js",
|
||||
"src/maps/keylessTerrain.js",
|
||||
"src/render/cesium/vectorBase.js",
|
||||
@@ -5654,6 +5648,8 @@
|
||||
"src/data/cctvFootprint.js",
|
||||
"src/data/cctvGizmo.js",
|
||||
"src/data/cctvLod.js",
|
||||
"src/data/cctvCellCounts.js",
|
||||
"src/layers/cctv/countMarkers.js",
|
||||
"src/data/cctvViewshed.js",
|
||||
"src/data/cockpitAirLod.js",
|
||||
"src/data/cockpitContactDot.js",
|
||||
|
||||
@@ -444,14 +444,14 @@ const MUTATIONS = [
|
||||
{
|
||||
defect: 'a mission tile is dropped from the menu',
|
||||
file: 'html',
|
||||
from: ' <UiButton data-first-run-start="space-missions"',
|
||||
to: ' <UiButton data-first-run-start-disabled="space-missions"',
|
||||
from: ' <button type="button" data-first-run-start="space-missions"',
|
||||
to: ' <button type="button" data-first-run-start-disabled="space-missions"',
|
||||
},
|
||||
{
|
||||
defect: "the menu order stops matching the owner's",
|
||||
file: 'html',
|
||||
from: '<UiButton data-first-run-start="environmental"',
|
||||
to: '<UiButton data-first-run-start="zzz-environmental"',
|
||||
from: '<button type="button" data-first-run-start="environmental"',
|
||||
to: '<button type="button" data-first-run-start="zzz-environmental"',
|
||||
},
|
||||
{
|
||||
defect: 'the "don\'t show again" checkbox loses its hook',
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createCctvLayer } from '../../layers/cctv/index.js';
|
||||
import * as credits from '../../data/dataCredits.js';
|
||||
import * as sprites from '../../data/spriteOrder.js';
|
||||
import * as activation from '../../cctvFocusRequest.js';
|
||||
import { keyholeLabelAlphaFromGeometry } from '../../celestialRing.js';
|
||||
import * as overlays from '../../overlays/worldOverlay.js';
|
||||
import { CITY_POIS } from '../../cityPois.js';
|
||||
import * as picking from '../../data/pickRegistry.js';
|
||||
@@ -17,7 +18,7 @@ export function createApplicationCctv({ surface, source }) {
|
||||
credits,
|
||||
sprites,
|
||||
activation,
|
||||
overlays,
|
||||
overlays: { ...overlays, keyholeAlpha: keyholeLabelAlphaFromGeometry },
|
||||
locations: { CITY_POIS },
|
||||
picking,
|
||||
terrain,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toRadians } from '../geo/index.js';
|
||||
import { toRadians } from '../geo/vector.js';
|
||||
import { findCamera } from '../render/rendererOf.js';
|
||||
|
||||
/** The camera port's pose, or null when there is none to read. */
|
||||
|
||||
+15
-1
@@ -85,7 +85,9 @@ import {
|
||||
} from '../cctvFocusRequest.js';
|
||||
import {
|
||||
ACTIVE_CAMERA_COLOR,
|
||||
CAMERA_ICON,
|
||||
IDLE_CAMERA_COLOR,
|
||||
IDLE_CAMERA_ICON,
|
||||
LIVE_CAMERA_COLOR,
|
||||
} from '../layers/cctv/policy.js';
|
||||
import { bindFakeDraw } from '../testSupport/fakeDrawPort.mjs';
|
||||
@@ -353,7 +355,7 @@ test('default COVERAGE refresh materializes the active and visible camera frustu
|
||||
}
|
||||
});
|
||||
|
||||
test('camera icons are violet for video feeds, cyan for stills, amber when active', () => {
|
||||
test('camera icons are violet for video feeds, green for stills, amber when active', () => {
|
||||
const record = (id, feedType) => ({
|
||||
camera: { ...UNCLAMPED_CAMERA, id, feedType, groundElevationM: 0 },
|
||||
// Every catalog record is placed as it is made, and drawn there.
|
||||
@@ -385,6 +387,18 @@ test('camera icons are violet for video feeds, cyan for stills, amber when activ
|
||||
assert.deepEqual(color(activeVideo), ACTIVE_CAMERA_COLOR);
|
||||
assert.equal(icons.item(activeVideo.camera.id).scale, 1.25);
|
||||
assert.equal(icons.item(idleVideo.camera.id).scale, 1);
|
||||
const image = (record) => icons.item(record.camera.id).image;
|
||||
const idleImage = image(idleStill);
|
||||
assert.equal(idleImage, IDLE_CAMERA_ICON);
|
||||
assert.equal(image(activeVideo), CAMERA_ICON);
|
||||
assert.equal(image(idleVideo), CAMERA_ICON);
|
||||
idleStill.camera.feedType = 'hls';
|
||||
refreshCoverageStyles();
|
||||
assert.equal(image(idleStill), CAMERA_ICON);
|
||||
idleStill.camera.feedType = 'image';
|
||||
refreshCoverageStyles();
|
||||
assert.equal(image(idleStill), idleImage);
|
||||
|
||||
} finally {
|
||||
_setCctvCoverageStateForTest({ enabled: false });
|
||||
unbind();
|
||||
|
||||
@@ -86,6 +86,8 @@ const RETRY_BASE_MS = 15_000;
|
||||
const RETRY_MAX_MS = 5 * 60 * 1000;
|
||||
|
||||
export const CCTV_OVERLAY_SOURCE_ID = 'cctv';
|
||||
/** The source a CCTV count marker takes clicks as. */
|
||||
export const CCTV_COUNT_CARD_SOURCE_ID = 'cctv-count';
|
||||
export const CCTV_THUMBNAIL_ALTITUDE_SCALE = Object.freeze({
|
||||
fullEnd: CCTV_CARD_SCALE_FULL_M,
|
||||
midEnd: CCTV_CARD_SCALE_MID_M,
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
import { fromDegrees } from '../geo/ellipsoid.js';
|
||||
|
||||
/** Exact below 1,000, then K with one decimal below 10K. Uses Latin digits in every locale. */
|
||||
export function formatCameraCount(count) {
|
||||
if (count < 1000) return String(count);
|
||||
const thousands =
|
||||
count < 10000 ? Math.round(count / 100) / 10 : Math.round(count / 1000);
|
||||
return `${thousands}K`;
|
||||
}
|
||||
|
||||
/** An empty cell and its on-screen picker candidate. */
|
||||
export function createCameraCell(key) {
|
||||
return {
|
||||
key,
|
||||
count: 0,
|
||||
latSum: 0,
|
||||
lonSum: 0,
|
||||
heightSum: 0,
|
||||
south: Infinity,
|
||||
north: -Infinity,
|
||||
west: Infinity,
|
||||
east: -Infinity,
|
||||
low: Infinity,
|
||||
high: -Infinity,
|
||||
winner: null,
|
||||
rank: Infinity,
|
||||
};
|
||||
}
|
||||
|
||||
/** Accumulate one horizon-visible mount in its ground cell. */
|
||||
export function addCellCamera(cell, camera) {
|
||||
const { lat, lon, absoluteHeightM: height = 0 } = camera;
|
||||
cell.count++;
|
||||
// Integer sums make the mean independent of catalog order, to about a centimetre.
|
||||
cell.latSum += Math.round(lat * 1e7);
|
||||
cell.lonSum += Math.round(lon * 1e7);
|
||||
cell.heightSum += Math.round(height * 100);
|
||||
cell.south = Math.min(cell.south, lat);
|
||||
cell.north = Math.max(cell.north, lat);
|
||||
cell.west = Math.min(cell.west, lon);
|
||||
cell.east = Math.max(cell.east, lon);
|
||||
cell.low = Math.min(cell.low, height);
|
||||
cell.high = Math.max(cell.high, height);
|
||||
}
|
||||
|
||||
const wrapLongitude = (lon) => ((((lon + 180) % 360) + 360) % 360) - 180;
|
||||
|
||||
/** Mean longitude and latitude of a cell's mounts, in degrees. */
|
||||
export function cellLonLat(cell) {
|
||||
return {
|
||||
lon: wrapLongitude(cell.lonSum / (1e7 * cell.count)),
|
||||
lat: cell.latSum / (1e7 * cell.count),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Geographic mean of the mounts. Its height is the drawn ground under it
|
||||
* when the cell carries one (`groundM`), since a camera nobody has looked at
|
||||
* yet may still hold a catalog height far from the terrain; otherwise the
|
||||
* mean mount height.
|
||||
*/
|
||||
export function cellCenter(cell) {
|
||||
const { lon, lat } = cellLonLat(cell);
|
||||
return fromDegrees(
|
||||
lon,
|
||||
lat,
|
||||
Number.isFinite(cell.groundM)
|
||||
? cell.groundM
|
||||
: cell.heightSum / (100 * cell.count),
|
||||
);
|
||||
}
|
||||
|
||||
/** A padded sphere over the rectangle and every mount, centred at groundM
|
||||
* when set, otherwise at the mid mount height. */
|
||||
export function cellBounds(cell) {
|
||||
const lat = (cell.north + cell.south) / 2;
|
||||
const lon = wrapLongitude((cell.east + cell.west) / 2);
|
||||
const height = Number.isFinite(cell.groundM)
|
||||
? cell.groundM
|
||||
: (cell.high + cell.low) / 2;
|
||||
// The parallel nearest the equator bounds the width of every row.
|
||||
const parallel = (Math.max(0, cell.south, -cell.north) * Math.PI) / 180;
|
||||
const halfWidth =
|
||||
0.5 *
|
||||
Math.hypot(
|
||||
(cell.east - cell.west) * 111_320 * Math.cos(parallel),
|
||||
(cell.north - cell.south) * 111_320,
|
||||
);
|
||||
const vertical = Math.max(cell.high - height, height - cell.low);
|
||||
const radius = 1.2 * Math.hypot(halfWidth, vertical);
|
||||
return { center: fromDegrees(lon, lat, height), radius: Math.max(1, radius) };
|
||||
}
|
||||
|
||||
/** Add a whole ground cell to a marker, retaining the sums for a weighted mean. */
|
||||
function addCell(target, cell) {
|
||||
// Across the antimeridian a cell joins on the side of the group's mean.
|
||||
const shift = target.count
|
||||
? 360 *
|
||||
Math.round(
|
||||
(target.lonSum / target.count - cell.lonSum / cell.count) / 3.6e9,
|
||||
)
|
||||
: 0;
|
||||
target.count += cell.count;
|
||||
target.latSum += cell.latSum;
|
||||
target.lonSum += cell.lonSum + shift * 1e7 * cell.count;
|
||||
target.heightSum += cell.heightSum;
|
||||
target.south = Math.min(target.south, cell.south);
|
||||
target.north = Math.max(target.north, cell.north);
|
||||
target.west = Math.min(target.west, cell.west + shift);
|
||||
target.east = Math.max(target.east, cell.east + shift);
|
||||
target.low = Math.min(target.low, cell.low);
|
||||
target.high = Math.max(target.high, cell.high);
|
||||
}
|
||||
|
||||
/** Visit the touching pills in this marker's bucket and its eight neighbors. */
|
||||
function visitNeighbors(marker, grid, gap, visit) {
|
||||
for (let col = -1; col <= 1; col++) {
|
||||
for (let row = -1; row <= 1; row++) {
|
||||
const bucket = grid.get(`${marker.col + col},${marker.row + row}`);
|
||||
if (!bucket) continue;
|
||||
for (const other of bucket) {
|
||||
// Distance between the horizontal centre segments of the two pills.
|
||||
const extra = marker.halfSegment + other.halfSegment;
|
||||
const dx = Math.max(0, Math.abs(marker.x - other.x) - extra);
|
||||
const dy = marker.y - other.y;
|
||||
const reach = marker.radius + other.radius + gap;
|
||||
if (dx * dx + dy * dy >= reach * reach) continue;
|
||||
visit(other, dx * dx + dy * dy, reach);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge connected groups of overlapping horizontal pills. Each marker occupies
|
||||
* one grid bucket. Even the widest pill can only touch its eight neighbors.
|
||||
* A cell with one camera takes the footprint `sizeFor(1)` gives its icon and
|
||||
* joins the nearest count it touches. Lone cameras never join each other
|
||||
* or bridge two counts. A spread icon's `offsetPx` shifts its footprint sideways.
|
||||
* A merged group lists its ground cells in `parts`.
|
||||
* Ground cells stay intact for the camera picker and individual-icon pass.
|
||||
*/
|
||||
export function mergeCountCells(cells, project, sizeFor, gap) {
|
||||
let columnWidth = 0;
|
||||
let rowHeight = 0;
|
||||
const markers = cells.map((cell) => {
|
||||
const screen = project(cellCenter(cell));
|
||||
const { width, height } = sizeFor(cell.count, cell);
|
||||
columnWidth = Math.max(columnWidth, width + gap);
|
||||
rowHeight = Math.max(rowHeight, height + gap);
|
||||
// The view projector reuses its result object.
|
||||
return {
|
||||
cell,
|
||||
x: screen ? screen.x + (cell.offsetPx ?? 0) : undefined,
|
||||
y: screen?.y,
|
||||
halfSegment: (width - height) / 2,
|
||||
radius: height / 2,
|
||||
};
|
||||
});
|
||||
const grid = new Map();
|
||||
for (const marker of markers) {
|
||||
if (!Number.isFinite(marker.x) || !Number.isFinite(marker.y)) continue;
|
||||
marker.col = Math.floor(marker.x / columnWidth);
|
||||
marker.row = Math.floor(marker.y / rowHeight);
|
||||
const key = `${marker.col},${marker.row}`;
|
||||
if (!grid.has(key)) grid.set(key, new Set());
|
||||
marker.bucket = grid.get(key);
|
||||
if (marker.cell.count > 1) marker.bucket.add(marker);
|
||||
}
|
||||
|
||||
for (const marker of markers) {
|
||||
if (marker.cell.count !== 1 || !marker.bucket) continue;
|
||||
let best = Infinity;
|
||||
visitNeighbors(marker, grid, gap, (other, distanceSquared, reach) => {
|
||||
const clearance = Math.sqrt(distanceSquared) - reach;
|
||||
if (clearance < best) {
|
||||
best = clearance;
|
||||
marker.nearest = other;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Only counts were candidates for nearest. Now they can claim lone cameras.
|
||||
for (const marker of markers)
|
||||
if (marker.cell.count === 1) marker.bucket?.add(marker);
|
||||
|
||||
const members = [];
|
||||
for (const seed of markers) {
|
||||
if (seed.cell.count === 1 || !seed.bucket?.delete(seed)) continue;
|
||||
members.length = 0;
|
||||
members.push(seed);
|
||||
for (const marker of members) {
|
||||
if (marker.cell.count === 1) continue;
|
||||
visitNeighbors(marker, grid, gap, (other) => {
|
||||
if (other.cell.count === 1 && other.nearest !== marker) return;
|
||||
other.bucket.delete(other);
|
||||
members.push(other);
|
||||
});
|
||||
}
|
||||
if (members.length === 1) {
|
||||
seed.result = seed.cell;
|
||||
} else {
|
||||
const group = createCameraCell(seed.cell.key);
|
||||
group.lone = [];
|
||||
group.parts = [];
|
||||
for (const { cell } of members) {
|
||||
addCell(group, cell);
|
||||
group.parts.push(...(cell.parts ?? [cell]));
|
||||
if (cell.count === 1) group.lone.push(cell);
|
||||
else if (cell.lone) group.lone.push(...cell.lone);
|
||||
}
|
||||
seed.result = group;
|
||||
}
|
||||
}
|
||||
|
||||
const groups = [];
|
||||
for (const marker of markers) {
|
||||
if (marker.result) groups.push(marker.result);
|
||||
else if (!marker.bucket || marker.bucket.has(marker))
|
||||
groups.push(marker.cell);
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
/** Rebuild a group's count under its original key, excluding lone cameras. */
|
||||
export function withoutLoneCameras(group) {
|
||||
const counts = (group.parts ?? []).filter((cell) => cell.count > 1);
|
||||
if (!counts.length) return null;
|
||||
const core = createCameraCell(group.key);
|
||||
core.parts = counts;
|
||||
for (const cell of counts) addCell(core, cell);
|
||||
return core;
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { fromDegrees } from '../geo/ellipsoid.js';
|
||||
import { distance } from '../geo/vector.js';
|
||||
import { getLocale, setLocale } from '../i18n/index.js';
|
||||
import {
|
||||
createCameraCell,
|
||||
addCellCamera,
|
||||
cellCenter,
|
||||
cellBounds,
|
||||
formatCameraCount,
|
||||
mergeCountCells,
|
||||
} from './cctvCellCounts.js';
|
||||
|
||||
test('camera counts use Latin digits and K notation whatever the UI language', () => {
|
||||
const previous = getLocale();
|
||||
const examples = [
|
||||
[2, '2'],
|
||||
[999, '999'],
|
||||
[1000, '1K'],
|
||||
[1150, '1.2K'],
|
||||
[1687, '1.7K'],
|
||||
[9960, '10K'],
|
||||
[10000, '10K'],
|
||||
[12345, '12K'],
|
||||
[12500, '13K'],
|
||||
[1000000, '1000K'],
|
||||
];
|
||||
try {
|
||||
setLocale('ar');
|
||||
for (const [count, label] of examples)
|
||||
assert.equal(formatCameraCount(count), label);
|
||||
} finally {
|
||||
setLocale(previous);
|
||||
}
|
||||
});
|
||||
|
||||
test('the marker mean weights every mount and the flight bounds cover the outlier', () => {
|
||||
const cameras = [
|
||||
{ lon: 12, lat: 52, absoluteHeightM: 30 },
|
||||
{ lon: 12, lat: 52, absoluteHeightM: 40 },
|
||||
{ lon: 12.003, lat: 52.006, absoluteHeightM: 50 },
|
||||
];
|
||||
const cell = createCameraCell();
|
||||
for (const camera of cameras) addCellCamera(cell, camera);
|
||||
const expected = fromDegrees(12.001, 52.002, 40);
|
||||
assert.ok(distance(cellCenter(cell), expected) < 0.001);
|
||||
const bounds = cellBounds(cell);
|
||||
for (const { lon, lat, absoluteHeightM } of cameras) {
|
||||
assert.ok(
|
||||
distance(bounds.center, fromDegrees(lon, lat, absoluteHeightM)) <
|
||||
bounds.radius,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
function mergeCounts(sizes, counts, positions) {
|
||||
const cells = counts.map((count, i) => ({
|
||||
...createCameraCell(String(i)),
|
||||
count,
|
||||
}));
|
||||
let i = 0;
|
||||
const groups = mergeCountCells(
|
||||
cells,
|
||||
() => positions[i++],
|
||||
(count) => sizes[count],
|
||||
4,
|
||||
);
|
||||
return { cells, groups };
|
||||
}
|
||||
|
||||
test('stadiums merge by their own radii and segment lengths across grid boundaries', () => {
|
||||
const sizes = {
|
||||
2: { width: 28, height: 28 },
|
||||
7350: { width: 80, height: 48 },
|
||||
};
|
||||
const check = (counts, positions, expected) => {
|
||||
const { groups } = mergeCounts(sizes, counts, positions);
|
||||
assert.deepEqual(
|
||||
groups.map((cell) => cell.count),
|
||||
expected,
|
||||
);
|
||||
assert.equal(
|
||||
groups.reduce((sum, cell) => sum + cell.count, 0),
|
||||
counts[0] + counts[1],
|
||||
);
|
||||
};
|
||||
const origin = { x: 35, y: 37 };
|
||||
// Mixed radii sum to 38. At 42 pixels vertically the gap is exactly clear.
|
||||
check([2, 7350], [origin, { x: 35, y: 78 }], [7352]);
|
||||
check([2, 7350], [origin, { x: 35, y: 79 }], [2, 7350]);
|
||||
// The large pill's centre segment extends 16 pixels towards the circle.
|
||||
check([7350, 2], [origin, { x: 92, y: 37 }], [7352]);
|
||||
check([7350, 2], [origin, { x: 92, y: 49 }], [7350, 2]);
|
||||
check([2, 2], [origin, { x: 70, y: 37 }], [2, 2]);
|
||||
// Large pills can reach across a row boundary at their full diameter.
|
||||
check([7350, 7350], [origin, { x: 35, y: 88 }], [14700]);
|
||||
});
|
||||
|
||||
test('a lone camera joins a count it touches, and lone cameras alone stay apart', () => {
|
||||
const sizes = {
|
||||
1: { width: 24, height: 24 },
|
||||
9: { width: 40, height: 40 },
|
||||
};
|
||||
const check = (counts, positions, expected) => {
|
||||
const { cells, groups } = mergeCounts(sizes, counts, positions);
|
||||
assert.deepEqual(
|
||||
groups.map((cell) => cell.count),
|
||||
expected,
|
||||
);
|
||||
// A lone camera that stays apart is still its own cell object.
|
||||
assert.deepEqual(
|
||||
groups.filter((cell) => cell.count === 1),
|
||||
cells.filter((cell) => groups.includes(cell) && cell.count === 1),
|
||||
);
|
||||
};
|
||||
const at = (x, y = 100) => ({ x, y });
|
||||
// Radii 20 and 12: the four-pixel gap is clear at 36 pixels.
|
||||
check([9, 1], [at(100), at(135)], [10]);
|
||||
check([9, 1], [at(100), at(136)], [9, 1]);
|
||||
check([1, 9], [at(135), at(100)], [10]);
|
||||
// Overlapping icons with no count beside them stay two icons.
|
||||
check([1, 1], [at(100), at(110)], [1, 1]);
|
||||
// A count takes every lone camera it touches, on either side.
|
||||
check([1, 9, 1], [at(70), at(100), at(130)], [11]);
|
||||
// A lone camera that only touches another lone camera is left alone.
|
||||
check([1, 1, 9], [at(40), at(70), at(100)], [1, 10]);
|
||||
});
|
||||
|
||||
test('cells merged across the antimeridian stay at the antimeridian', () => {
|
||||
for (const lon of [179.9, 179.99, 179.999]) {
|
||||
for (const reversed of [false, true]) {
|
||||
const east = createCameraCell('e');
|
||||
const west = createCameraCell('w');
|
||||
for (let i = 0; i < 2; i++) {
|
||||
addCellCamera(east, { lon, lat: 0, absoluteHeightM: 0 });
|
||||
addCellCamera(west, { lon: -lon, lat: 0, absoluteHeightM: 0 });
|
||||
}
|
||||
const cells = reversed ? [west, east] : [east, west];
|
||||
const screens = [
|
||||
{ x: 100, y: 100 },
|
||||
{ x: 120, y: 100 },
|
||||
];
|
||||
let i = 0;
|
||||
const [group, ...rest] = mergeCountCells(
|
||||
cells,
|
||||
() => screens[i++],
|
||||
() => ({ width: 40, height: 40 }),
|
||||
4,
|
||||
);
|
||||
assert.equal(rest.length, 0);
|
||||
assert.equal(group.count, 4);
|
||||
const expected = fromDegrees(180, 0, 0);
|
||||
assert.ok(distance(cellCenter(group), expected) < 1000, `${lon}: centre`);
|
||||
const bounds = cellBounds(group);
|
||||
assert.ok(bounds.radius < 15_000, `${lon}: radius ${bounds.radius}`);
|
||||
for (const l of [lon, -lon])
|
||||
assert.ok(
|
||||
distance(bounds.center, fromDegrees(l, 0, 0)) <= bounds.radius,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('flight bounds on drawn ground still contain every mount', () => {
|
||||
// Flat ellipsoid terrain (Re:Earth terrain failed), mounts at 1,800 m.
|
||||
const flat = createCameraCell('k');
|
||||
addCellCamera(flat, { lon: 10, lat: 46, absoluteHeightM: 1800 });
|
||||
addCellCamera(flat, { lon: 10, lat: 46, absoluteHeightM: 1800 });
|
||||
flat.groundM = 0;
|
||||
const fb = cellBounds(flat);
|
||||
assert.ok(
|
||||
distance(fromDegrees(10, 46, 1800), fb.center) <= fb.radius,
|
||||
'flat',
|
||||
);
|
||||
// Ravine: mounts 200 m apart at 600 m, the floor at 0 m between them.
|
||||
const east = 10 + 200 / (111_320 * Math.cos((46 * Math.PI) / 180));
|
||||
const ravine = createCameraCell('r');
|
||||
addCellCamera(ravine, { lon: 10, lat: 46, absoluteHeightM: 600 });
|
||||
addCellCamera(ravine, { lon: east, lat: 46, absoluteHeightM: 600 });
|
||||
ravine.groundM = 0;
|
||||
const rb = cellBounds(ravine);
|
||||
for (const lon of [10, east])
|
||||
assert.ok(
|
||||
distance(fromDegrees(lon, 46, 600), rb.center) <= rb.radius,
|
||||
'ravine',
|
||||
);
|
||||
});
|
||||
|
||||
test('a lone camera between two counts joins one of them and does not merge them', () => {
|
||||
const sizes = { 1: { width: 24, height: 24 }, 9: { width: 40, height: 40 } };
|
||||
const run = (counts, xs) =>
|
||||
mergeCounts(
|
||||
sizes,
|
||||
counts,
|
||||
xs.map((x) => ({ x, y: 100 })),
|
||||
)
|
||||
.groups.map((cell) => cell.count)
|
||||
.sort((a, b) => a - b);
|
||||
assert.deepEqual(run([9, 9], [70, 130]), [9, 9]);
|
||||
for (const [counts, xs] of [
|
||||
[
|
||||
[9, 1, 9],
|
||||
[70, 100, 130],
|
||||
],
|
||||
[
|
||||
[1, 9, 9],
|
||||
[100, 70, 130],
|
||||
],
|
||||
[
|
||||
[9, 9, 1],
|
||||
[70, 130, 100],
|
||||
],
|
||||
])
|
||||
assert.deepEqual(run(counts, xs), [9, 10], String(counts));
|
||||
});
|
||||
@@ -1,174 +0,0 @@
|
||||
// Live HLS through the real /api/cctv middleware: playlist, segment and
|
||||
// release. HLS leases are random per-playback ids, not bound to the socket
|
||||
// address, so viewers who share one address (a Docker bridge gateway, a reverse
|
||||
// proxy, NAT) get the whole per-session budget, and a viewer whose address
|
||||
// changes mid-playback keeps its lease.
|
||||
//
|
||||
// Run with: npm test (node --test)
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { cctvProxy } from '../../server/providers/cctv.js';
|
||||
|
||||
const camera = (id) => ({
|
||||
id,
|
||||
name: id,
|
||||
lat: 30.27,
|
||||
lon: -97.74,
|
||||
feedType: 'hls',
|
||||
url: `https://cams.upstream.invalid/${id}/list.m3u8`,
|
||||
});
|
||||
const PLAYLIST =
|
||||
'#EXTM3U\n#EXT-X-MEDIA-SEQUENCE:12\n#EXTINF:2,\na.ts\n#EXTINF:2,\nb.ts\n#EXTINF:2,\nc.ts\n';
|
||||
const lease = (index) =>
|
||||
`00000000-0000-4000-8000-${String(index).padStart(12, '0')}`;
|
||||
|
||||
/** Collects what a handler wrote, the way a Node ServerResponse would. */
|
||||
function recordingResponse() {
|
||||
const chunks = [];
|
||||
let finished;
|
||||
const done = new Promise((resolve) => {
|
||||
finished = resolve;
|
||||
});
|
||||
const res = {
|
||||
statusCode: 0,
|
||||
headers: {},
|
||||
writableEnded: false,
|
||||
body: '',
|
||||
writeHead(status, headers) {
|
||||
res.statusCode = status;
|
||||
res.headers = { ...res.headers, ...headers };
|
||||
},
|
||||
setHeader(name, value) {
|
||||
res.headers[name] = value;
|
||||
},
|
||||
write(chunk) {
|
||||
chunks.push(Buffer.from(chunk));
|
||||
return true;
|
||||
},
|
||||
end(chunk) {
|
||||
if (chunk) chunks.push(Buffer.from(chunk));
|
||||
res.writableEnded = true;
|
||||
res.body = Buffer.concat(chunks).toString('utf8');
|
||||
finished();
|
||||
},
|
||||
on() {},
|
||||
once() {},
|
||||
emit() {},
|
||||
destroy() {},
|
||||
};
|
||||
return { res, done };
|
||||
}
|
||||
|
||||
/** Mount the provider over two HLS cameras whose upstream always answers. */
|
||||
function mount(t) {
|
||||
const before = {
|
||||
json: process.env.CCTV_SOURCES_JSON,
|
||||
file: process.env.CCTV_SOURCES_FILE,
|
||||
austin: process.env.CCTV_FORCE_AUSTIN,
|
||||
};
|
||||
process.env.CCTV_SOURCES_JSON = JSON.stringify([
|
||||
camera('cam-a'),
|
||||
camera('cam-b'),
|
||||
]);
|
||||
process.env.CCTV_SOURCES_FILE = 'absent-source-file.json';
|
||||
process.env.CCTV_FORCE_AUSTIN = '0';
|
||||
const nativeFetch = globalThis.fetch;
|
||||
// The puller binds fetch when cctvProxy() creates it, so mock first.
|
||||
globalThis.fetch = async (url) =>
|
||||
new Response(String(url).endsWith('.m3u8') ? PLAYLIST : 'abc');
|
||||
let handler;
|
||||
const closers = [];
|
||||
cctvProxy().configureServer({
|
||||
httpServer: { on: (_event, fn) => closers.push(fn) },
|
||||
middlewares: { use: (_route, fn) => (handler = fn) },
|
||||
});
|
||||
t.after(() => {
|
||||
for (const fn of closers) fn();
|
||||
globalThis.fetch = nativeFetch;
|
||||
for (const [name, value] of [
|
||||
['CCTV_SOURCES_JSON', before.json],
|
||||
['CCTV_SOURCES_FILE', before.file],
|
||||
['CCTV_FORCE_AUSTIN', before.austin],
|
||||
]) {
|
||||
if (value === undefined) delete process.env[name];
|
||||
else process.env[name] = value;
|
||||
}
|
||||
});
|
||||
return async (url, remoteAddress, method = 'GET') => {
|
||||
const { res, done } = recordingResponse();
|
||||
await handler(
|
||||
{
|
||||
url,
|
||||
method,
|
||||
headers: { host: 'localhost:4173', 'sec-fetch-site': 'same-origin' },
|
||||
socket: { remoteAddress },
|
||||
on() {},
|
||||
},
|
||||
res,
|
||||
);
|
||||
await done;
|
||||
return res;
|
||||
};
|
||||
}
|
||||
|
||||
/** Open a playlist and return the first segment path it lists. */
|
||||
async function openPlaylist(call, cameraId, leaseId, remoteAddress) {
|
||||
const res = await call(`/media/${cameraId}?lease=${leaseId}`, remoteAddress);
|
||||
assert.equal(res.statusCode, 200, `playlist ${cameraId} ${leaseId}`);
|
||||
const segment = res.body
|
||||
.split('\n')
|
||||
.find((line) => line.startsWith('/api/cctv/media/'));
|
||||
assert.ok(segment, 'the playlist lists a segment');
|
||||
return segment.replace('/api/cctv', '');
|
||||
}
|
||||
|
||||
test('viewers on distinct addresses open, read and release their own leases', async (t) => {
|
||||
const call = mount(t);
|
||||
const viewers = Array.from({ length: 9 }, (_, index) => ({
|
||||
camera: index < 5 ? 'cam-a' : 'cam-b',
|
||||
lease: lease(index),
|
||||
// IPv4-mapped form, as a dual-stack listener reports it.
|
||||
peer: `::ffff:192.168.1.${20 + index}`,
|
||||
}));
|
||||
for (const viewer of viewers)
|
||||
viewer.segment = await openPlaylist(
|
||||
call,
|
||||
viewer.camera,
|
||||
viewer.lease,
|
||||
viewer.peer,
|
||||
);
|
||||
for (const viewer of viewers)
|
||||
assert.equal((await call(viewer.segment, viewer.peer)).statusCode, 200);
|
||||
for (const viewer of viewers) {
|
||||
const release = await call(
|
||||
`/media/${viewer.camera}?lease=${viewer.lease}`,
|
||||
viewer.peer,
|
||||
'DELETE',
|
||||
);
|
||||
assert.equal(release.statusCode, 204);
|
||||
}
|
||||
});
|
||||
|
||||
test('viewers behind one shared address get every session slot', async (t) => {
|
||||
const call = mount(t);
|
||||
const shared = '::ffff:172.17.0.1';
|
||||
for (let index = 0; index < 8; index++)
|
||||
await openPlaylist(call, 'cam-a', lease(index), shared);
|
||||
const segment = await openPlaylist(call, 'cam-b', lease(8), shared);
|
||||
assert.equal((await call(segment, shared)).statusCode, 200);
|
||||
});
|
||||
|
||||
test('a lease keeps working after its viewer reconnects from another address', async (t) => {
|
||||
const call = mount(t);
|
||||
await openPlaylist(call, 'cam-a', lease(0), '192.168.1.20');
|
||||
const segment = await openPlaylist(call, 'cam-a', lease(0), '192.168.1.21');
|
||||
assert.equal((await call(segment, '192.168.1.21')).statusCode, 200);
|
||||
const release = await call(
|
||||
`/media/cam-a?lease=${lease(0)}`,
|
||||
'192.168.1.21',
|
||||
'DELETE',
|
||||
);
|
||||
assert.equal(release.statusCode, 204);
|
||||
// Released from the new address: the same lease can no longer read segments.
|
||||
assert.equal((await call(segment, '192.168.1.21')).statusCode, 404);
|
||||
});
|
||||
@@ -155,9 +155,9 @@ function mount(t, respond) {
|
||||
});
|
||||
assert.ok(handler, 'the CCTV provider must mount a middleware');
|
||||
|
||||
const call = async (path, headers = {}, method = 'GET') => {
|
||||
const call = async (path, headers = {}) => {
|
||||
const { res, done } = recordingResponse();
|
||||
await handler({ url: path, headers, method, on() {} }, res);
|
||||
await handler({ url: path, headers, method: 'GET', on() {} }, res);
|
||||
await done;
|
||||
return res;
|
||||
};
|
||||
@@ -401,35 +401,24 @@ test('every CCTV route refuses cross-site requests and admits the app itself', a
|
||||
}),
|
||||
);
|
||||
const host = 'localhost:5173';
|
||||
const lease = '00000000-0000-4000-8000-000000000000';
|
||||
const routes = [
|
||||
['GET', '/sources'],
|
||||
['GET', '/health'],
|
||||
['GET', `/stream/${STILL.id}`],
|
||||
['GET', `/frame/${STILL.id}`],
|
||||
['GET', `/media/${VIDEO.id}`],
|
||||
['GET', `/media/${VIDEO.id}/seg_0.ts?lease=${lease}`],
|
||||
['DELETE', `/media/${VIDEO.id}?lease=${lease}`],
|
||||
const paths = [
|
||||
'/sources',
|
||||
'/health',
|
||||
`/stream/${STILL.id}`,
|
||||
`/frame/${STILL.id}`,
|
||||
`/media/${VIDEO.id}`,
|
||||
];
|
||||
// A catalog refresh would fetch the live packs: a refused request must not
|
||||
// start one.
|
||||
process.env.CCTV_FORCE_AUSTIN = '1';
|
||||
for (const headers of [
|
||||
{ host, 'sec-fetch-site': 'cross-site' },
|
||||
{ host, 'sec-fetch-site': 'same-site' },
|
||||
{ host, origin: 'https://elsewhere.example' },
|
||||
{ host, origin: 'null' },
|
||||
])
|
||||
for (const [method, path] of routes) {
|
||||
const res = await app.call(path, headers, method);
|
||||
assert.equal(
|
||||
res.statusCode,
|
||||
403,
|
||||
`${method} ${path} ${JSON.stringify(headers)}`,
|
||||
);
|
||||
for (const path of paths) {
|
||||
const res = await app.call(path, headers);
|
||||
assert.equal(res.statusCode, 403, `${path} ${JSON.stringify(headers)}`);
|
||||
}
|
||||
assert.deepEqual(app.requests, [], 'a refused request reached an upstream');
|
||||
process.env.CCTV_FORCE_AUSTIN = '0';
|
||||
for (const headers of [
|
||||
{ host, 'sec-fetch-site': 'same-origin' },
|
||||
{ host, origin: `http://${host}` },
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
import { afterEach, beforeEach, test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as Cesium from 'cesium';
|
||||
import { bindRenderer } from '../render/rendererOf.js';
|
||||
import { fakeCameraPort } from '../testSupport/fakeCameraPort.mjs';
|
||||
import { fakeDrawPort } from '../testSupport/fakeDrawPort.mjs';
|
||||
import cctvLayer, {
|
||||
_cctvIconsForTest,
|
||||
_setCctvCoverageStateForTest,
|
||||
refreshHorizonCulling,
|
||||
} from './cctv.js';
|
||||
|
||||
const WIDTH = 800;
|
||||
const HEIGHT = 600;
|
||||
const bindings = [];
|
||||
beforeEach(() => {
|
||||
globalThis.document = {
|
||||
createElement: () => ({
|
||||
getContext: () => ({
|
||||
measureText: (text) => ({
|
||||
width: text.length * 8,
|
||||
actualBoundingBoxAscent: 4,
|
||||
actualBoundingBoxDescent: 4,
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
};
|
||||
});
|
||||
afterEach(() => {
|
||||
delete globalThis.document;
|
||||
for (const unbind of bindings.splice(0)) unbind();
|
||||
});
|
||||
|
||||
function recordsAt(lonLats, height = 10) {
|
||||
return lonLats.map(([lon, lat], index) => {
|
||||
const position = Cesium.Cartesian3.fromDegrees(lon, lat, height);
|
||||
return {
|
||||
camera: {
|
||||
id: `cam-${String(index).padStart(4, '0')}`,
|
||||
name: `Camera ${index}`,
|
||||
city: 'Test',
|
||||
lat,
|
||||
lon,
|
||||
headingDeg: 0,
|
||||
pitchDeg: -18,
|
||||
fovDeg: 44,
|
||||
rangeM: 145,
|
||||
mountHeightM: 8,
|
||||
absoluteHeightM: height,
|
||||
},
|
||||
position: { x: position.x, y: position.y, z: position.z },
|
||||
groundSamples: {},
|
||||
groundResolved: {},
|
||||
coverageEntities: [],
|
||||
projection: null,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const plain = ({ x, y, z }) => ({ x, y, z });
|
||||
|
||||
function lookingAt(eye, target, ports = {}) {
|
||||
const direction = Cesium.Cartesian3.normalize(
|
||||
Cesium.Cartesian3.subtract(target, eye, new Cesium.Cartesian3()),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const right = Cesium.Cartesian3.normalize(
|
||||
Cesium.Cartesian3.cross(direction, eye, new Cesium.Cartesian3()),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const up = Cesium.Cartesian3.cross(right, direction, new Cesium.Cartesian3());
|
||||
return {
|
||||
viewer: viewerWithAxes(eye, direction, right, up, ports),
|
||||
direction,
|
||||
right,
|
||||
up,
|
||||
};
|
||||
}
|
||||
|
||||
function topDown(height, ports = {}) {
|
||||
const eye = Cesium.Cartesian3.fromDegrees(0, 0, height);
|
||||
return viewerWithAxes(
|
||||
eye,
|
||||
{ x: -1, y: 0, z: 0 },
|
||||
{ x: 0, y: 1, z: 0 },
|
||||
{ x: 0, y: 0, z: 1 },
|
||||
ports,
|
||||
);
|
||||
}
|
||||
|
||||
function viewerWithAxes(eye, direction, right, up, ports) {
|
||||
const carto = Cesium.Cartographic.fromCartesian(eye);
|
||||
const { port } = fakeCameraPort({
|
||||
pose: {
|
||||
lon: Cesium.Math.toDegrees(carto.longitude),
|
||||
lat: Cesium.Math.toDegrees(carto.latitude),
|
||||
height: carto.height,
|
||||
position: plain(eye),
|
||||
direction: plain(direction),
|
||||
up: plain(up),
|
||||
right: plain(right),
|
||||
fovy: Math.PI / 3,
|
||||
aspectRatio: WIDTH / HEIGHT,
|
||||
near: 0.1,
|
||||
far: 5e8,
|
||||
},
|
||||
});
|
||||
const viewer = {};
|
||||
bindings.push(
|
||||
bindRenderer(viewer, {
|
||||
camera: port,
|
||||
canvas: { clientWidth: WIDTH, clientHeight: HEIGHT },
|
||||
draw: fakeDrawPort(),
|
||||
...ports,
|
||||
}),
|
||||
);
|
||||
return viewer;
|
||||
}
|
||||
|
||||
/** Pinhole projection, as the layer's projector. */
|
||||
function project(view, eye, point) {
|
||||
const d = Cesium.Cartesian3.subtract(point, eye, new Cesium.Cartesian3());
|
||||
const z = Cesium.Cartesian3.dot(d, view.direction);
|
||||
const t = Math.tan(Math.PI / 6);
|
||||
const x = Cesium.Cartesian3.dot(d, view.right) / z / (t * (WIDTH / HEIGHT));
|
||||
const y = Cesium.Cartesian3.dot(d, view.up) / z / t;
|
||||
return { x: (0.5 + x / 2) * WIDTH, y: (0.5 - y / 2) * HEIGHT, z };
|
||||
}
|
||||
|
||||
for (const [label, horizontalM, aboveM] of [
|
||||
['100 m approach', 100, 4],
|
||||
['800 m approach', 800, 50],
|
||||
]) {
|
||||
test(`a camera with a stale height is read even when it projects off the screen at ${label}`, () => {
|
||||
const ground = 1872;
|
||||
const records = recordsAt([
|
||||
[0, 0],
|
||||
[0, 0],
|
||||
]);
|
||||
// geoid fallback after a 429
|
||||
for (const r of records)
|
||||
r.groundPrior = { ellipsoid: 2, source: 'geoid-fallback' };
|
||||
const mount = Cesium.Cartesian3.fromDegrees(0, 0, ground + 8);
|
||||
const eye = Cesium.Cartesian3.fromDegrees(
|
||||
0,
|
||||
-horizontalM / 111_320,
|
||||
ground + 8 + aboveM,
|
||||
);
|
||||
const reads = [];
|
||||
const view = lookingAt(eye, mount, {
|
||||
globe: { isGlobeVisible: () => true },
|
||||
query: {
|
||||
sampleHeightNow(point) {
|
||||
reads.push(point);
|
||||
return ground;
|
||||
},
|
||||
},
|
||||
});
|
||||
_setCctvCoverageStateForTest({ viewer: view.viewer, records });
|
||||
const stale = project(view, eye, records[0].position);
|
||||
const truth = project(view, eye, mount);
|
||||
|
||||
assert.ok(stale.y > HEIGHT * 2);
|
||||
assert.ok(truth.y > 0 && truth.y < HEIGHT);
|
||||
refreshHorizonCulling();
|
||||
refreshHorizonCulling();
|
||||
assert.equal(records[0].groundPrior.ellipsoid, ground);
|
||||
|
||||
assert.ok(reads.length > 0, 'the stale camera was never read');
|
||||
});
|
||||
}
|
||||
|
||||
test('cameras off the visible screen cannot spend the whole terrain read budget', () => {
|
||||
// 300 cameras with no prior around the screen edge, tiles not loaded; the
|
||||
// 301st at the screen centre over a loaded tile.
|
||||
const lonLats = [];
|
||||
for (let i = 0; i < 300; i++) {
|
||||
const a = (i / 300) * 2 * Math.PI;
|
||||
// ~ 0.8 screen widths out at 200 m altitude (screen ~ 307 m wide)
|
||||
lonLats.push([
|
||||
(Math.cos(a) * 250) / 111_320,
|
||||
(Math.sin(a) * 190) / 111_320,
|
||||
]);
|
||||
}
|
||||
lonLats.push([0, 0]);
|
||||
const records = recordsAt(lonLats);
|
||||
const perPass = [];
|
||||
let reads;
|
||||
const viewer = topDown(200, {
|
||||
globe: { isGlobeVisible: () => true },
|
||||
query: {
|
||||
sampleHeightNow(point) {
|
||||
reads.push(point);
|
||||
return Math.abs(point.lon) < 1e-9 && Math.abs(point.lat) < 1e-9
|
||||
? 40
|
||||
: null;
|
||||
},
|
||||
},
|
||||
});
|
||||
_setCctvCoverageStateForTest({ viewer, records });
|
||||
for (let pass = 0; pass < 3; pass++) {
|
||||
reads = [];
|
||||
refreshHorizonCulling();
|
||||
perPass.push(reads.length);
|
||||
}
|
||||
const last = records.at(-1);
|
||||
|
||||
assert.equal(last.groundPrior?.ellipsoid, 40);
|
||||
assert.ok(perPass.every((n) => n <= 300));
|
||||
});
|
||||
|
||||
test("the active camera's icon moves beside a count that would cover it", () => {
|
||||
const records = recordsAt([
|
||||
[0, 0],
|
||||
[0, 0],
|
||||
[0, 0],
|
||||
]);
|
||||
const viewer = topDown(20_000);
|
||||
_setCctvCoverageStateForTest({ viewer, records, activeCameraId: 'cam-0000' });
|
||||
refreshHorizonCulling();
|
||||
const icons = _cctvIconsForTest();
|
||||
const [marker] = cctvLayer._cctvDrawnForTest().counts.markers;
|
||||
const metresPerPixel = ((2 * Math.tan(Math.PI / 6)) / HEIGHT) * 19_990;
|
||||
const apartPx =
|
||||
Cesium.Cartesian3.distance(marker.pos, icons.item('cam-0000').pos) /
|
||||
metresPerPixel;
|
||||
|
||||
assert.ok(apartPx > marker.width / 2, 'the marker covers the active icon');
|
||||
});
|
||||
|
||||
test('a lone camera just inside the grouping threshold joins the count beside it', () => {
|
||||
const h = 740;
|
||||
// mounts at 8 m mount height above a 0 m ground: positions at 10 m, eye at h+10
|
||||
const records = recordsAt([
|
||||
[0, 235 / 111_320],
|
||||
[0, 255 / 111_320],
|
||||
[0, 255 / 111_320],
|
||||
]);
|
||||
for (const r of records) r.groundPrior = { ellipsoid: 2, source: 'reearth' };
|
||||
const viewer = topDown(h + 10);
|
||||
_setCctvCoverageStateForTest({ viewer, records });
|
||||
refreshHorizonCulling();
|
||||
const icons = _cctvIconsForTest();
|
||||
const markers = cctvLayer._cctvDrawnForTest().counts.markers;
|
||||
assert.deepEqual(
|
||||
markers.map((marker) => marker.cell.count),
|
||||
[3],
|
||||
);
|
||||
assert.equal(
|
||||
icons.item('cam-0000').show,
|
||||
false,
|
||||
'the near singleton still draws beside the count',
|
||||
);
|
||||
});
|
||||
+1280
-52
File diff suppressed because it is too large.
Load diff
@@ -154,6 +154,24 @@ export function pickContact(query, position, options = {}) {
|
||||
let _overlayHitTest = null;
|
||||
/** @type {WeakMap<object, {sourceId: string, entryId: string}|null>} */
|
||||
const clickCards = new WeakMap();
|
||||
const _clickClaims = new Map();
|
||||
|
||||
/**
|
||||
* Register a target drawn outside the world overlay's entries, such as a CCTV
|
||||
* count. A claim runs once per click where no card or label is painted above
|
||||
* it and must not call `clickCard`.
|
||||
* @param {string} layerId
|
||||
* @param {(click: object) => ({sourceId: string, entryId: string}|null)} claim
|
||||
*/
|
||||
export function registerClickClaim(layerId, claim) {
|
||||
if (!layerId || typeof claim !== 'function') return;
|
||||
_clickClaims.set(layerId, claim);
|
||||
}
|
||||
|
||||
/** Remove a layer's claim when it is disabled or destroyed. */
|
||||
export function unregisterClickClaim(layerId) {
|
||||
_clickClaims.delete(layerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets (or with null, clears) the hit test that names the card or label
|
||||
@@ -166,8 +184,8 @@ export function setClickCardHitTest(hitTest) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The topmost interactive card or label painted at a click, read once per
|
||||
* click so every handler of it sees the same one whatever ran first.
|
||||
* The topmost interactive card or label painted at a click, or a target a
|
||||
* layer claims (`registerClickClaim`). All handlers share one result per click.
|
||||
* @param {{screenPosition?: {x: number, y: number}}|null|undefined} click
|
||||
* @returns {{sourceId: string, entryId: string}|null}
|
||||
*/
|
||||
@@ -179,14 +197,28 @@ export function clickCard(click) {
|
||||
try {
|
||||
card = _overlayHitTest?.(at?.x, at?.y) ?? null;
|
||||
} catch {
|
||||
// a broken hit test must never break click handling
|
||||
clickCards.set(click, null);
|
||||
return null;
|
||||
}
|
||||
if (!card) {
|
||||
// A claim that reads this click again cannot re-enter the claims loop.
|
||||
clickCards.set(click, null);
|
||||
for (const claim of _clickClaims.values()) {
|
||||
try {
|
||||
card = claim(click) ?? null;
|
||||
} catch {
|
||||
card = null;
|
||||
}
|
||||
if (card) break;
|
||||
}
|
||||
}
|
||||
clickCards.set(click, card);
|
||||
return card;
|
||||
}
|
||||
|
||||
/**
|
||||
* True when another layer's card or label is painted on top at a click. The
|
||||
* True when another layer has the top card, label, or claimed target
|
||||
* (`registerClickClaim`) at a click. The
|
||||
* card on top takes the click: a scene item under it does not act, and is
|
||||
* not empty space either, so the layer leaves its selection alone.
|
||||
* @param {object} click The shared dispatcher event.
|
||||
|
||||
@@ -20,6 +20,8 @@ import {
|
||||
clickCard,
|
||||
isUnderOtherCard,
|
||||
setClickCardHitTest,
|
||||
registerClickClaim,
|
||||
unregisterClickClaim,
|
||||
} from './pickRegistry.js';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -237,3 +239,42 @@ test("the card on top is read once per click, and only another layer's card coun
|
||||
setClickCardHitTest(null);
|
||||
}
|
||||
});
|
||||
|
||||
test('a click claim is the card on top only where no card or label is painted', () => {
|
||||
const event = (x) => ({ screenPosition: { x, y: 5 } });
|
||||
let calls = 0;
|
||||
registerClickClaim('counts', (click) => {
|
||||
calls++;
|
||||
return click.screenPosition.x === 4
|
||||
? { sourceId: 'counts', entryId: 'k' }
|
||||
: null;
|
||||
});
|
||||
try {
|
||||
registerClickClaim('counts', null);
|
||||
const click = event(4);
|
||||
assert.equal(isUnderOtherCard(click), true);
|
||||
assert.equal(isUnderOtherCard(click, ['counts']), false);
|
||||
assert.equal(calls, 1);
|
||||
assert.equal(clickCard(event(9)), null);
|
||||
const quake = { sourceId: 'quake-card', entryId: 'q1' };
|
||||
setClickCardHitTest(() => quake);
|
||||
assert.deepEqual(clickCard(event(4)), quake);
|
||||
assert.equal(calls, 2);
|
||||
setClickCardHitTest(() => {
|
||||
throw new Error('broken overlay hit test');
|
||||
});
|
||||
assert.equal(clickCard(event(4)), null);
|
||||
assert.equal(calls, 2);
|
||||
setClickCardHitTest(null);
|
||||
|
||||
unregisterClickClaim('counts');
|
||||
assert.equal(clickCard(event(4)), null);
|
||||
registerClickClaim('counts', () => {
|
||||
throw new Error('broken claim');
|
||||
});
|
||||
assert.equal(clickCard(event(4)), null);
|
||||
} finally {
|
||||
unregisterClickClaim('counts');
|
||||
setClickCardHitTest(null);
|
||||
}
|
||||
});
|
||||
@@ -946,7 +946,7 @@ test('the card closes without a keyboard: the ESC hint is a button, kept on phon
|
||||
);
|
||||
assert.match(
|
||||
header,
|
||||
/<button type="button" class="[^"]*\bfirst-run-dismiss\b[^"]*" data-first-run-dismiss>/,
|
||||
/<button type="button" class="first-run-dismiss" data-first-run-dismiss>/,
|
||||
);
|
||||
assert.match(header, />SKIP · ESC</);
|
||||
assert.match(header, />SKIP</);
|
||||
|
||||
@@ -229,7 +229,7 @@ export function createCards({ state: layerState, services, parts, source }) {
|
||||
let rank = 0;
|
||||
const push = (id, { pinned = false, active = false } = {}) => {
|
||||
const record = layerState._recordById.get(id);
|
||||
if (!record?.position) return;
|
||||
if (!record?.position || (!active && record.viewGrouped)) return;
|
||||
entries.push(
|
||||
createCctvThumbnailOverlayEntry({
|
||||
id,
|
||||
|
||||
Vendored
+2
-1
@@ -219,7 +219,8 @@ export function createControls({ state: layerState, services, parts, source }) {
|
||||
for (let i = start; i < records.length; i += stride) {
|
||||
const camera = records[i].camera;
|
||||
objects.push({
|
||||
position: records[i].position,
|
||||
// A camera sharing its mount is drawn beside its mates.
|
||||
position: records[i].spreadPosition ?? records[i].position,
|
||||
sourceId: camera.id,
|
||||
// Short semantic code where the id is opaque (see cameraDisplayCode).
|
||||
id: `CAM-${camera.code || camera.id}`,
|
||||
|
||||
@@ -0,0 +1,398 @@
|
||||
import {
|
||||
cellCenter,
|
||||
cellLonLat,
|
||||
formatCameraCount,
|
||||
mergeCountCells,
|
||||
withoutLoneCameras,
|
||||
} from '../../data/cctvCellCounts.js';
|
||||
import { WORLD_OVERLAY_STYLE } from '../../overlays/worldOverlayTokens.js';
|
||||
import {
|
||||
CAMERA_GREEN,
|
||||
COUNT_CAMERA_ICON,
|
||||
CAMERA_ICON_PX,
|
||||
COUNT_MERGE_GAP_PX,
|
||||
} from './policy.js';
|
||||
import { liftedForHorizon } from '../../geo/horizon.js';
|
||||
|
||||
// Diameter at one camera before applying the size limits, in CSS pixels.
|
||||
const COUNT_BASE_PX = 38;
|
||||
|
||||
// Extra diameter for each tenfold increase in camera count.
|
||||
const COUNT_PX_PER_DECADE = 5;
|
||||
|
||||
// Minimum height of a count marker in CSS pixels.
|
||||
const COUNT_MIN_HEIGHT_PX = 40;
|
||||
|
||||
// Maximum height of a count marker in CSS pixels.
|
||||
const COUNT_MAX_HEIGHT_PX = 58;
|
||||
|
||||
// Clear fill between the count and the inside of the ring, in CSS pixels.
|
||||
const COUNT_TEXT_PADDING_PX = 6;
|
||||
|
||||
// Height of the camera glyph in the smallest and the largest marker.
|
||||
const COUNT_GLYPH_MIN_PX = 7.5;
|
||||
const COUNT_GLYPH_MAX_PX = 10;
|
||||
|
||||
// Clear fill above the glyph in the smallest and the largest marker.
|
||||
const COUNT_GLYPH_TOP_MIN_PX = 3;
|
||||
const COUNT_GLYPH_TOP_MAX_PX = 4;
|
||||
|
||||
// Clear fill between the glyph's top corners and the inside of the ring.
|
||||
const COUNT_GLYPH_PADDING_PX = 2;
|
||||
|
||||
// The middle of the digits sits this share of the inner radius below the
|
||||
// marker's centre, which leaves the glyph clear of the count.
|
||||
const COUNT_LABEL_DROP = 0.2;
|
||||
|
||||
// Merge passes per view. A merged centre and wider label can reach a further
|
||||
// marker. The cap bounds work on motion ticks.
|
||||
const COUNT_MERGE_PASSES = 3;
|
||||
const FONT = WORLD_OVERLAY_STYLE.fontTitle;
|
||||
// Reserve the camera's landscape slot even while the map sprite is loading.
|
||||
const GLYPH_ASPECT = 1.5;
|
||||
const RING_PX = 2;
|
||||
const RIM_PX = 1;
|
||||
const STROKE_INSET = RIM_PX + RING_PX / 2;
|
||||
// Painted bounds of the camera art, scaled from its viewBox to source pixels.
|
||||
const GLYPH_SOURCE = [3.4, 13.4, 28.1, 19.5].map((v) => (v * 48) / 36);
|
||||
const GLYPH_SOURCE_ASPECT = 28.1 / 19.5;
|
||||
|
||||
/** Merged camera groups and their last painted hit rectangles in CSS pixels. */
|
||||
export function createCountMarkers(
|
||||
registerPaintLane,
|
||||
id,
|
||||
refreshView,
|
||||
keyholeAlpha,
|
||||
) {
|
||||
let hardUi = null;
|
||||
let sprite = null;
|
||||
let spriteReady = false;
|
||||
const markers = [];
|
||||
const hits = [];
|
||||
const textMetrics = new Map();
|
||||
const fonts = globalThis.document?.fonts;
|
||||
let measureCtx;
|
||||
let hitCount = 0;
|
||||
const lane = registerPaintLane?.('ambient-label', paint, {
|
||||
id,
|
||||
active: false,
|
||||
target: 'shared',
|
||||
});
|
||||
function loadSprite() {
|
||||
if (sprite || typeof Image === 'undefined') return;
|
||||
sprite = new Image();
|
||||
sprite.onload = () => {
|
||||
spriteReady = true;
|
||||
if (markers.length) lane?.requestPaint();
|
||||
};
|
||||
sprite.src = COUNT_CAMERA_ICON;
|
||||
}
|
||||
fonts?.addEventListener?.('loadingdone', fontsLoaded);
|
||||
|
||||
/** Font changes can widen a pill enough to merge it with its neighbor. */
|
||||
function fontsLoaded() {
|
||||
textMetrics.clear();
|
||||
if (!markers.length) return;
|
||||
refreshView();
|
||||
lane?.requestPaint();
|
||||
}
|
||||
|
||||
/** Seat the glyph under the top of the ring and the count just below centre. */
|
||||
function sizeFor(count) {
|
||||
const text = formatCameraCount(count);
|
||||
let metrics = textMetrics.get(text);
|
||||
if (!metrics) {
|
||||
measureCtx ??= globalThis.document
|
||||
.createElement('canvas')
|
||||
.getContext('2d');
|
||||
measureCtx.font = FONT;
|
||||
measureCtx.textBaseline = 'middle';
|
||||
metrics = measureCtx.measureText(text);
|
||||
textMetrics.set(text, metrics);
|
||||
}
|
||||
const diameter = COUNT_BASE_PX + COUNT_PX_PER_DECADE * Math.log10(count);
|
||||
const clamped = Math.max(
|
||||
COUNT_MIN_HEIGHT_PX,
|
||||
Math.min(COUNT_MAX_HEIGHT_PX, diameter),
|
||||
);
|
||||
const height = 2 * Math.round(clamped / 2);
|
||||
const grown =
|
||||
(height - COUNT_MIN_HEIGHT_PX) /
|
||||
(COUNT_MAX_HEIGHT_PX - COUNT_MIN_HEIGHT_PX);
|
||||
const glyphHeight =
|
||||
COUNT_GLYPH_MIN_PX + (COUNT_GLYPH_MAX_PX - COUNT_GLYPH_MIN_PX) * grown;
|
||||
const radius = height / 2 - RIM_PX - RING_PX;
|
||||
const glyphTop =
|
||||
COUNT_GLYPH_TOP_MIN_PX +
|
||||
(COUNT_GLYPH_TOP_MAX_PX - COUNT_GLYPH_TOP_MIN_PX) * grown -
|
||||
radius;
|
||||
const ascent = metrics.actualBoundingBoxAscent;
|
||||
const descent = metrics.actualBoundingBoxDescent;
|
||||
const labelY = COUNT_LABEL_DROP * radius + (ascent - descent) / 2;
|
||||
// Each row must clear the ring at the edge where the circle is narrowest.
|
||||
const chordAt = (y) => 2 * Math.sqrt(Math.max(0, radius ** 2 - y ** 2));
|
||||
const extra = Math.max(
|
||||
0,
|
||||
Math.ceil(
|
||||
Math.max(
|
||||
metrics.width + 2 * COUNT_TEXT_PADDING_PX - chordAt(labelY + descent),
|
||||
glyphHeight * GLYPH_ASPECT +
|
||||
2 * COUNT_GLYPH_PADDING_PX -
|
||||
chordAt(glyphTop),
|
||||
),
|
||||
),
|
||||
);
|
||||
return {
|
||||
text,
|
||||
width: height + extra,
|
||||
height,
|
||||
glyphHeight,
|
||||
glyphBottom: glyphTop + glyphHeight,
|
||||
labelY,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reuse marker slots in ground-key order, and invalidate only changed frames.
|
||||
* `groundHeight(lon, lat)` gives the drawn terrain in metres, or a non-finite
|
||||
* value where it has not loaded. A count stands on that ground when available
|
||||
* and otherwise uses its cameras' mean mount height.
|
||||
*/
|
||||
function update(cells, project, groundHeight = null) {
|
||||
// Lone cameras take part so that one beside a count joins it.
|
||||
let visible = cells.slice().sort((a, b) => a.key.localeCompare(b.key));
|
||||
const footprint = (count, cell) => {
|
||||
if (count > 1) return sizeFor(count);
|
||||
const px = cell.iconPx ?? CAMERA_ICON_PX;
|
||||
return { width: px, height: px };
|
||||
};
|
||||
/** A lone camera keeps its icon's own position; a count goes to ground. */
|
||||
const ground = (list) => {
|
||||
if (!groundHeight) return;
|
||||
for (const cell of list) {
|
||||
if (cell.count === 1 || cell.groundM !== undefined) continue;
|
||||
const { lon, lat } = cellLonLat(cell);
|
||||
const height = groundHeight(lon, lat);
|
||||
cell.groundM = Number.isFinite(height) ? Math.round(height) : null;
|
||||
}
|
||||
};
|
||||
for (
|
||||
let pass = 0;
|
||||
pass < COUNT_MERGE_PASSES &&
|
||||
visible.length > 1 &&
|
||||
visible.some((cell) => cell.count > 1);
|
||||
pass++
|
||||
) {
|
||||
ground(visible);
|
||||
const merged = mergeCountCells(
|
||||
visible,
|
||||
project,
|
||||
footprint,
|
||||
COUNT_MERGE_GAP_PX,
|
||||
);
|
||||
if (merged.length === visible.length) break;
|
||||
visible = merged;
|
||||
}
|
||||
// A lone camera that is no longer its own entry now counts in a marker.
|
||||
const apart = new Set(visible);
|
||||
for (const cell of cells)
|
||||
if (cell.count === 1) cell.absorbed = !apart.has(cell);
|
||||
visible = visible.filter((cell) => cell.count > 1);
|
||||
ground(visible);
|
||||
let changed = visible.length !== markers.length;
|
||||
for (let i = 0; i < visible.length; i++) {
|
||||
let cell = visible[i];
|
||||
// If the merged count is under the HUD, restore the count and its lone icons.
|
||||
if (hardUi && cell.lone?.length) {
|
||||
const at = project(cellCenter(cell));
|
||||
const { width, height } = sizeFor(cell.count);
|
||||
const rect = at && {
|
||||
x: at.x - width / 2,
|
||||
y: at.y - height / 2,
|
||||
w: width,
|
||||
h: height,
|
||||
};
|
||||
if (rect && hardUi(rect)) {
|
||||
for (const lone of cell.lone) lone.absorbed = false;
|
||||
const core = withoutLoneCameras(cell);
|
||||
if (core) {
|
||||
core.releasedAt = rect;
|
||||
ground([core]);
|
||||
cell = core;
|
||||
}
|
||||
}
|
||||
}
|
||||
const marker = (markers[i] ??= { focus: 1 });
|
||||
const last = marker.cell;
|
||||
const size = sizeFor(cell.count);
|
||||
if (
|
||||
!last ||
|
||||
last.count !== cell.count ||
|
||||
last.latSum !== cell.latSum ||
|
||||
last.lonSum !== cell.lonSum ||
|
||||
last.heightSum !== cell.heightSum ||
|
||||
last.groundM !== cell.groundM
|
||||
) {
|
||||
marker.pos = cellCenter(cell);
|
||||
marker.cullPos = liftedForHorizon(marker.pos);
|
||||
marker.hudHidden = undefined;
|
||||
changed = true;
|
||||
}
|
||||
changed ||=
|
||||
size.text !== marker.text ||
|
||||
size.width !== marker.width ||
|
||||
size.glyphBottom !== marker.glyphBottom ||
|
||||
size.labelY !== marker.labelY;
|
||||
marker.cell = cell;
|
||||
Object.assign(marker, size);
|
||||
// Paint never grows the hit buffer, even when a pan reveals every group.
|
||||
hits[i] ??= {};
|
||||
}
|
||||
markers.length = visible.length;
|
||||
if (markers.length) loadSprite();
|
||||
// Keep the last frame pickable until the host clears its pixels.
|
||||
lane?.setActive(markers.length > 0 || hitCount > 0);
|
||||
if (changed) lane?.requestPaint();
|
||||
}
|
||||
|
||||
/** Draw at device density using the host's CSS-pixel transform and projection. */
|
||||
function paint(frame) {
|
||||
hardUi = frame.overlapsHardUi ?? hardUi;
|
||||
if (!markers.length) {
|
||||
// Deactivating invalidates the host, so finish the shared frame first.
|
||||
if (hitCount) queueMicrotask(deactivateIfEmpty);
|
||||
hitCount = 0;
|
||||
return;
|
||||
}
|
||||
hitCount = 0;
|
||||
const { ctx, occluder, viewProjectionMatrix: m } = frame;
|
||||
let refresh = false;
|
||||
ctx.save();
|
||||
try {
|
||||
ctx.font = FONT;
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
for (let i = 0; i < markers.length; i++) {
|
||||
const marker = markers[i];
|
||||
// The core can stay visible while the HUD uncovers the merged count.
|
||||
if (marker.cell.releasedAt) refresh ||= !hardUi(marker.cell.releasedAt);
|
||||
const { height } = marker;
|
||||
const { x: px, y: py, z: pz } = marker.pos;
|
||||
const w = m[3] * px + m[7] * py + m[11] * pz + m[15];
|
||||
if (!(w > 0) || (occluder && !occluder.isPointVisible(marker.cullPos)))
|
||||
continue;
|
||||
const x =
|
||||
(0.5 + (0.5 * (m[0] * px + m[4] * py + m[8] * pz + m[12])) / w) *
|
||||
frame.width;
|
||||
const y =
|
||||
(0.5 - (0.5 * (m[1] * px + m[5] * py + m[9] * pz + m[13])) / w) *
|
||||
frame.height;
|
||||
const rect = hits[hitCount];
|
||||
rect.x = x - marker.width / 2;
|
||||
rect.y = y - height / 2;
|
||||
rect.w = marker.width;
|
||||
rect.h = height;
|
||||
if (
|
||||
rect.x >= frame.width ||
|
||||
rect.y >= frame.height ||
|
||||
rect.x + rect.w <= 0 ||
|
||||
rect.y + rect.h <= 0
|
||||
)
|
||||
continue;
|
||||
const hidden = Boolean(hardUi?.(rect));
|
||||
const previous = marker.hudHidden;
|
||||
if (previous !== hidden) {
|
||||
marker.hudHidden = hidden;
|
||||
// The active icon steps aside only for visible counts.
|
||||
refresh ||=
|
||||
hidden ||
|
||||
previous !== undefined ||
|
||||
marker.cell.lone?.some((cell) => cell.absorbed === hidden);
|
||||
}
|
||||
if (hidden) continue;
|
||||
const fade =
|
||||
frame.keyhole && keyholeAlpha ? keyholeAlpha(x, y, frame.keyhole) : 1;
|
||||
if (!(fade > 0)) continue;
|
||||
ctx.globalAlpha = marker.focus * fade;
|
||||
ctx.beginPath();
|
||||
ctx.roundRect(
|
||||
rect.x + STROKE_INSET,
|
||||
rect.y + STROKE_INSET,
|
||||
rect.w - 2 * STROKE_INSET,
|
||||
height - 2 * STROKE_INSET,
|
||||
height / 2 - STROKE_INSET,
|
||||
);
|
||||
ctx.strokeStyle = 'rgba(8, 14, 20, 0.85)';
|
||||
ctx.lineWidth = RING_PX + 2 * RIM_PX;
|
||||
ctx.stroke();
|
||||
ctx.fillStyle = '#0e1720';
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = CAMERA_GREEN;
|
||||
ctx.lineWidth = RING_PX;
|
||||
ctx.stroke();
|
||||
ctx.fillStyle = CAMERA_GREEN;
|
||||
if (spriteReady) {
|
||||
const width = marker.glyphHeight * GLYPH_SOURCE_ASPECT;
|
||||
ctx.drawImage(
|
||||
sprite,
|
||||
...GLYPH_SOURCE,
|
||||
x - width / 2,
|
||||
y + marker.glyphBottom - marker.glyphHeight,
|
||||
width,
|
||||
marker.glyphHeight,
|
||||
);
|
||||
}
|
||||
ctx.fillText(marker.text, x, y + marker.labelY);
|
||||
rect.cell = marker.cell;
|
||||
hitCount++;
|
||||
}
|
||||
} finally {
|
||||
ctx.restore();
|
||||
}
|
||||
if (refresh) queueMicrotask(refreshView);
|
||||
}
|
||||
|
||||
/** Resolve the topmost group actually painted at this screen position. */
|
||||
function pickedCell(point) {
|
||||
if (!point) return null;
|
||||
for (let i = hitCount - 1; i >= 0; i--) {
|
||||
const rect = hits[i];
|
||||
const radius = rect.h / 2;
|
||||
// Distance from the pill's horizontal centre segment.
|
||||
const dx = Math.max(
|
||||
0,
|
||||
Math.abs(point.x - (rect.x + rect.w / 2)) - (rect.w - rect.h) / 2,
|
||||
);
|
||||
const dy = point.y - (rect.y + radius);
|
||||
if (dx * dx + dy * dy <= radius * radius) return rect.cell;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** A new group may already have arrived since the empty frame. */
|
||||
function deactivateIfEmpty() {
|
||||
if (!markers.length) lane?.setActive(false);
|
||||
}
|
||||
|
||||
/** Release the visible groups and clear their hit targets immediately. */
|
||||
function hide() {
|
||||
markers.length = hits.length = hitCount = 0;
|
||||
lane?.setActive(false);
|
||||
}
|
||||
|
||||
/** Unhook this viewer's painter and its font listener. */
|
||||
function dispose() {
|
||||
hide();
|
||||
fonts?.removeEventListener?.('loadingdone', fontsLoaded);
|
||||
lane?.unregister();
|
||||
}
|
||||
|
||||
return {
|
||||
markers,
|
||||
update,
|
||||
pickedCell,
|
||||
hide,
|
||||
dispose,
|
||||
requestPaint: () => lane?.requestPaint(),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
import { test, beforeEach, afterEach } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createCountMarkers } from './countMarkers.js';
|
||||
import { addCellCamera, createCameraCell } from '../../data/cctvCellCounts.js';
|
||||
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
import { horizonFrom } from '../../geo/horizon.js';
|
||||
|
||||
const W = 800;
|
||||
const H = 600;
|
||||
const A = 6378137;
|
||||
// Screen x = W/2 + ecefY/30, y = H/2 - ecefZ/30 (as the view-thinning fixture).
|
||||
const project = (p) => ({ x: W / 2 + p.y / 30, y: H / 2 - p.z / 30 });
|
||||
const lonFor = (x) => (Math.asin(((x - W / 2) * 30) / A) * 180) / Math.PI;
|
||||
const matrix = new Float64Array([
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2 / (30 * W),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2 / (30 * H),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
]);
|
||||
|
||||
function cellAt(key, x, count, height = 0) {
|
||||
const cell = createCameraCell(key);
|
||||
for (let i = 0; i < count; i++)
|
||||
addCellCamera(cell, { lon: lonFor(x), lat: 0, absoluteHeightM: height });
|
||||
return cell;
|
||||
}
|
||||
|
||||
let painter;
|
||||
function makeCtx() {
|
||||
return {
|
||||
labels: [],
|
||||
globalAlpha: 1,
|
||||
save() {},
|
||||
restore() {},
|
||||
beginPath() {},
|
||||
roundRect() {},
|
||||
stroke() {},
|
||||
fill() {},
|
||||
drawImage() {},
|
||||
fillText(text, x, y) {
|
||||
this.labels.push({ text, x, y, alpha: this.globalAlpha });
|
||||
},
|
||||
};
|
||||
}
|
||||
function paint(overrides = {}) {
|
||||
const ctx = makeCtx();
|
||||
painter({
|
||||
ctx,
|
||||
width: W,
|
||||
height: H,
|
||||
dpr: 1,
|
||||
viewProjectionMatrix: matrix,
|
||||
occluder: { isPointVisible: () => true },
|
||||
overlapsHardUi: () => false,
|
||||
...overrides,
|
||||
});
|
||||
return ctx.labels;
|
||||
}
|
||||
function counts(refresh = () => {}, keyholeAlpha) {
|
||||
return createCountMarkers(
|
||||
(_lane, paintFn) => {
|
||||
painter = paintFn;
|
||||
return { requestPaint() {}, setActive() {}, unregister() {} };
|
||||
},
|
||||
'counts',
|
||||
refresh,
|
||||
keyholeAlpha,
|
||||
);
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
globalThis.document = {
|
||||
createElement: () => ({
|
||||
getContext: () => ({
|
||||
measureText: (text) => ({
|
||||
width: text.length * 7,
|
||||
actualBoundingBoxAscent: 4,
|
||||
actualBoundingBoxDescent: 4,
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
};
|
||||
});
|
||||
afterEach(() => {
|
||||
delete globalThis.document;
|
||||
});
|
||||
test('a count on ground below the ellipsoid stays painted while its mounts are above the horizon', () => {
|
||||
const m = counts();
|
||||
m.update([cellAt('a', 400, 2, -20)], project, () => -30);
|
||||
const eye = fromDegrees(-0.009, 0, 30); // about 1 km away, 30 m above the ellipsoid
|
||||
const horizon = horizonFrom(eye);
|
||||
assert.equal(horizon.isPointVisible(fromDegrees(lonFor(400), 0, -20)), true);
|
||||
assert.equal(paint({ occluder: horizon }).length, 1);
|
||||
});
|
||||
|
||||
test('a lone camera clear of the HUD keeps its icon when the count beside it is hidden', async () => {
|
||||
const hud = { overlapsHardUi: (rect) => rect.x < 200 };
|
||||
for (const paintedFirst of [true, false]) {
|
||||
const cells = [cellAt('a', 200, 2), cellAt('b', 234, 1)];
|
||||
const m = counts(() => m.update(cells, project));
|
||||
if (paintedFirst) paint(hud);
|
||||
m.update(cells, project);
|
||||
const labels = paint(hud);
|
||||
await Promise.resolve();
|
||||
assert.ok(!cells[1].absorbed || labels.length > 0);
|
||||
// Moving the HUD at rest also changes whether the lone icon is needed.
|
||||
paint();
|
||||
await Promise.resolve();
|
||||
assert.equal(cells[1].absorbed, true);
|
||||
paint(hud);
|
||||
await Promise.resolve();
|
||||
assert.equal(cells[1].absorbed, false);
|
||||
m.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
test('a count stays visible when a lone camera would move it under the HUD', async () => {
|
||||
const cells = [cellAt('a', 200, 2), cellAt('b', 234, 1)];
|
||||
const hud = { overlapsHardUi: (rect) => rect.x + rect.w > 225 };
|
||||
const m = counts(() => m.update(cells, project));
|
||||
paint(hud);
|
||||
m.update(cells, project);
|
||||
assert.equal(paint(hud)[0]?.text, '2');
|
||||
assert.equal(cells[1].absorbed, false);
|
||||
await Promise.resolve();
|
||||
paint(hud);
|
||||
await Promise.resolve();
|
||||
|
||||
paint();
|
||||
await Promise.resolve();
|
||||
assert.equal(cells[1].absorbed, true);
|
||||
assert.equal(paint()[0]?.text, '3');
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('counts fade with the Scope keyhole like the callouts', () => {
|
||||
const m = counts(undefined, (_x, _y, keyhole) => keyhole.alpha);
|
||||
m.update([cellAt('a', 400, 2)], project);
|
||||
assert.equal(paint({ keyhole: { alpha: 0.25 } })[0].alpha, 0.25);
|
||||
assert.deepEqual(paint({ keyhole: { alpha: 0 } }), []);
|
||||
assert.equal(m.pickedCell({ x: 400, y: 300 }), null);
|
||||
assert.equal(paint()[0].alpha, 1);
|
||||
});
|
||||
@@ -0,0 +1,67 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { bindRenderer } from '../../render/rendererOf.js';
|
||||
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
import { distance } from '../../geo/vector.js';
|
||||
import {
|
||||
addCellCamera,
|
||||
createCameraCell,
|
||||
mergeCountCells,
|
||||
} from '../../data/cctvCellCounts.js';
|
||||
import { createNavigation } from './navigation.js';
|
||||
|
||||
// A count of four merged in a tilted view: two pairs 10 km and 40 km north of
|
||||
// an eye 800 m up. After the click, at least one member must be in frame.
|
||||
test('a count click from a tilted view keeps the group members in the frame', () => {
|
||||
const viewer = {};
|
||||
const flights = [];
|
||||
const fovy = Math.PI / 3;
|
||||
const aspectRatio = 800 / 600;
|
||||
const unbind = bindRenderer(viewer, {
|
||||
camera: {
|
||||
pose: () => ({ fovy, aspectRatio, position: fromDegrees(0, 0, 800) }),
|
||||
flyToBounds: (bounds, options) => flights.push({ bounds, options }),
|
||||
},
|
||||
canvas: { clientHeight: 600, clientWidth: 800 },
|
||||
});
|
||||
try {
|
||||
const metresPerDegree = 111_320;
|
||||
const members = [];
|
||||
const cells = [10_000, 40_000].map((start) => {
|
||||
const cell = createCameraCell(String(start));
|
||||
for (const northM of [start, start + 10]) {
|
||||
const lat = northM / metresPerDegree;
|
||||
addCellCamera(cell, { lat, lon: 0, absoluteHeightM: 8 });
|
||||
members.push(fromDegrees(0, lat, 8));
|
||||
}
|
||||
return cell;
|
||||
});
|
||||
const screens = [
|
||||
{ x: 400, y: 300 },
|
||||
{ x: 433, y: 300 },
|
||||
];
|
||||
const groups = mergeCountCells(
|
||||
cells,
|
||||
() => screens.shift(),
|
||||
() => ({ width: 40, height: 40 }),
|
||||
2,
|
||||
);
|
||||
assert.equal(groups.length, 1);
|
||||
assert.equal(groups[0].count, 4);
|
||||
const state = { _viewer: viewer };
|
||||
const navigation = createNavigation({ state, parts: {} });
|
||||
navigation.zoomToCell(groups[0]);
|
||||
assert.equal(flights.length, 1);
|
||||
const { range, pitch } = flights[0].options.offset;
|
||||
assert.equal(pitch, -Math.PI / 2);
|
||||
const { center } = flights[0].bounds;
|
||||
const halfSpanM = range * Math.tan(fovy / 2);
|
||||
assert.ok(
|
||||
members.some((point) => distance(point, center) <= halfSpanM),
|
||||
'no member of the group is in the final frame',
|
||||
);
|
||||
assert.ok(range < distance(fromDegrees(0, 0, 800), center));
|
||||
} finally {
|
||||
unbind();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,65 @@
|
||||
import * as picking from '../../data/pickRegistry.js';
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createSelection } from './selection.js';
|
||||
|
||||
function setup() {
|
||||
let zooms = 0,
|
||||
clicks = 0;
|
||||
const selection = createSelection({
|
||||
services: { activation: {}, picking },
|
||||
state: {
|
||||
_enabled: true,
|
||||
_counts: { pickedCell: () => ({}) },
|
||||
_cctvOverlayHost: { hitTest: () => null },
|
||||
},
|
||||
parts: {
|
||||
navigation: { zoomToCell: () => zooms++ },
|
||||
rendering: { extractPickedCameraId: () => null },
|
||||
},
|
||||
});
|
||||
const click = selection.bindCctvWorldClickGesture(
|
||||
{ onClick: (fn) => fn },
|
||||
() => clicks++,
|
||||
);
|
||||
return { click, counts: () => [zooms, clicks] };
|
||||
}
|
||||
|
||||
test('a click a painted overlay target took (Space Missions label) does not fly to the count', () => {
|
||||
const { click, counts } = setup();
|
||||
// What the dispatcher hands subscribers after an onOverlayClick handler returned true.
|
||||
click({
|
||||
screenPosition: { x: 20, y: 26 },
|
||||
overlay: true,
|
||||
topHit: { set: '', id: null, surface: false },
|
||||
drawHit: null,
|
||||
gesture: { travelPx: 0, durationMs: 20 },
|
||||
});
|
||||
assert.equal(
|
||||
counts()[0],
|
||||
0,
|
||||
'count flight ran although an overlay target handled the click',
|
||||
);
|
||||
});
|
||||
|
||||
test("another layer's world-overlay card on top (clickCard) takes the click from the count", () => {
|
||||
const { click, counts } = setup();
|
||||
picking.setClickCardHitTest(() => ({
|
||||
sourceId: 'earthquakes',
|
||||
entryId: 'eq-1',
|
||||
}));
|
||||
try {
|
||||
click({
|
||||
screenPosition: { x: 20, y: 26 },
|
||||
topHit: null,
|
||||
drawHit: null,
|
||||
gesture: { travelPx: 0, durationMs: 20 },
|
||||
});
|
||||
assert.ok(
|
||||
picking.isUnderOtherCard({ screenPosition: { x: 1, y: 1 } }, ['cctv']),
|
||||
);
|
||||
assert.equal(counts()[0], 0, 'count flight ran under another layer card');
|
||||
} finally {
|
||||
picking.setClickCardHitTest(null);
|
||||
}
|
||||
});
|
||||
+77
-47
@@ -1,4 +1,4 @@
|
||||
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
import { fromDegreesInto } from '../../geo/ellipsoid.js';
|
||||
import { findGlobe } from '../../render/rendererOf.js';
|
||||
import {
|
||||
SUPPORT_KEYS,
|
||||
@@ -22,11 +22,12 @@ export function createGround({ state: layerState, services, parts, source }) {
|
||||
* - `google-3d` — photoreal stack: globe hidden, the visible Google 3D
|
||||
* tileset IS the surface → one-shot scene sampling refines.
|
||||
* - `terrain-globe` — any globe stack: the Re:Earth point-height prior IS the
|
||||
* resolution (zero scene queries).
|
||||
* resolution. A camera the batch left unanswered takes the
|
||||
* drawn terrain from the view pass (`adoptDrawnGround`).
|
||||
*
|
||||
* Only an explicit `false` (the photoreal stack hides the globe) selects
|
||||
* `google-3d`; undefined/null (no viewer / torn down) must fall to the regime
|
||||
* that never touches the scene. Pure — exported for the unit suite.
|
||||
* that never samples the scene's tiles. Pure — exported for the unit suite.
|
||||
* @param {boolean|undefined|null} globeShow - Whether the renderer shows the
|
||||
* globe (`globe.isGlobeVisible()`).
|
||||
* @returns {'google-3d'|'terrain-globe'}
|
||||
@@ -214,56 +215,84 @@ export function createGround({ state: layerState, services, parts, source }) {
|
||||
let applied = 0;
|
||||
let moved = 0;
|
||||
for (let i = 0; i < records.length && i < priors.length; i++) {
|
||||
const record = records[i];
|
||||
const prior = priors[i];
|
||||
if (!record || !prior || !Number.isFinite(prior.ellipsoid)) continue;
|
||||
// Stale-record guard: init() may have re-run (destroy/init cycle) while
|
||||
// the batch was in flight — only touch records still live in the map.
|
||||
if (layerState._recordById.get(record.camera.id) !== record) continue;
|
||||
record.groundPrior = prior;
|
||||
// Keep the cheap pre-enable altitude consistent for records whose
|
||||
// geometry hasn't been applied yet (applyFrustumGeometry overwrites it).
|
||||
if (!record.frustumPositions) {
|
||||
record.camera.absoluteHeightM =
|
||||
prior.ellipsoid + record.camera.mountHeightM;
|
||||
}
|
||||
// Cameras without geometry only move their icon onto the prior, so the
|
||||
// view pass projects the right point; their frustums are built when
|
||||
// they enter the view, as recomputing the whole catalog here would
|
||||
// stall a large one.
|
||||
if (!record.frustumGeometry) {
|
||||
if (record.position) {
|
||||
// In place: the record keeps its position object.
|
||||
const { x, y, z } = fromDegrees(
|
||||
record.camera.lon,
|
||||
record.camera.lat,
|
||||
record.camera.absoluteHeightM,
|
||||
);
|
||||
record.position.x = x;
|
||||
record.position.y = y;
|
||||
record.position.z = z;
|
||||
parts.rendering.moveCameraIcon(record);
|
||||
moved += 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const regime = currentSurfaceRegime();
|
||||
if (regime === 'terrain-globe') {
|
||||
// Prior IS the resolution — re-latch onto the fresh value.
|
||||
parts.geometry.updateRecordGeometry(record, { sampleGround: false });
|
||||
applied += 1;
|
||||
} else if (!Number.isFinite(record.groundSamples['google-3d'])) {
|
||||
// Still awaiting the shared floor: snap interim geometry onto the exact
|
||||
// prior (pure recompute; the shared cell may refine later).
|
||||
parts.geometry.applyFrustumGeometry(record, prior.ellipsoid);
|
||||
applied += 1;
|
||||
}
|
||||
const outcome = applyGroundPrior(records[i], priors[i]);
|
||||
if (outcome === 'moved') moved += 1;
|
||||
else if (outcome === 'applied') applied += 1;
|
||||
}
|
||||
if (moved && parts.rendering.refreshHorizonCulling())
|
||||
parts.geometryQueue.enqueueViewGeometry();
|
||||
if (applied || moved) parts.presentation.notifyListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives one live record a ground prior: `'moved'` when only its icon went
|
||||
* onto the prior in place, `'applied'` when its geometry was recomputed,
|
||||
* null when nothing changed. Pure recomputes, no scene queries.
|
||||
*/
|
||||
function applyGroundPrior(record, prior) {
|
||||
if (!record || !prior || !Number.isFinite(prior.ellipsoid)) return null;
|
||||
// Stale-record guard: init() may have re-run (destroy/init cycle) while
|
||||
// the batch was in flight — only touch records still live in the map.
|
||||
if (layerState._recordById.get(record.camera.id) !== record) return null;
|
||||
// The drawn terrain beats a fallback. Only a real batch answer replaces it.
|
||||
if (
|
||||
prior.source === 'geoid-fallback' &&
|
||||
record.groundPrior?.source === 'drawn-terrain'
|
||||
)
|
||||
return null;
|
||||
record.groundPrior = prior;
|
||||
// Keep the cheap pre-enable altitude consistent for records whose
|
||||
// geometry hasn't been applied yet (applyFrustumGeometry overwrites it).
|
||||
if (!record.frustumPositions) {
|
||||
record.camera.absoluteHeightM =
|
||||
prior.ellipsoid + record.camera.mountHeightM;
|
||||
}
|
||||
// Cameras without geometry only move their icon onto the prior, so the
|
||||
// view pass projects the right point; their frustums are built when
|
||||
// they enter the view, as recomputing the whole catalog here would
|
||||
// stall a large one.
|
||||
if (!record.frustumGeometry) {
|
||||
if (!record.position) return null;
|
||||
// In place: the record keeps its position object.
|
||||
fromDegreesInto(
|
||||
record.camera.lon,
|
||||
record.camera.lat,
|
||||
record.camera.absoluteHeightM,
|
||||
record.position,
|
||||
);
|
||||
parts.rendering.moveCameraIcon(record);
|
||||
return 'moved';
|
||||
}
|
||||
const regime = currentSurfaceRegime();
|
||||
if (regime === 'terrain-globe') {
|
||||
// Prior IS the resolution — re-latch onto the fresh value.
|
||||
parts.geometry.updateRecordGeometry(record, { sampleGround: false });
|
||||
return 'applied';
|
||||
}
|
||||
if (!Number.isFinite(record.groundSamples['google-3d'])) {
|
||||
// Still awaiting the shared floor: snap interim geometry onto the exact
|
||||
// prior (pure recompute; the shared cell may refine later).
|
||||
parts.geometry.applyFrustumGeometry(record, prior.ellipsoid);
|
||||
return 'applied';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies drawn terrain as a drawn-terrain prior. The read records the eye
|
||||
* distance (rangeM), globe surface version (surface) and whether terrain
|
||||
* loading had finished (settled). Reading from under half that range or
|
||||
* receiving a later Re:Earth answer replaces the height.
|
||||
* @returns {'moved'|'applied'|null} As `applyGroundPrior`.
|
||||
*/
|
||||
function adoptDrawnGround(record, heightM, read) {
|
||||
return applyGroundPrior(record, {
|
||||
ellipsoid: heightM,
|
||||
source: 'drawn-terrain',
|
||||
...read,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Task 5: surface-regime change handler ('gev:map-stack-changed'
|
||||
* CustomEvent, dispatched by main.js from MapStackController.onChange). The
|
||||
@@ -399,6 +428,7 @@ export function createGround({ state: layerState, services, parts, source }) {
|
||||
resolveCommittedGroundAnchor,
|
||||
resolveGroundPriors,
|
||||
applyLateGroundPriors,
|
||||
adoptDrawnGround,
|
||||
handleMapStackChanged,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createGround } from './ground.js';
|
||||
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
|
||||
function setup(record) {
|
||||
const calls = { culling: 0, geometry: [], notify: 0 };
|
||||
const state = {
|
||||
_viewer: null,
|
||||
_recordById: new Map([[record.camera.id, record]]),
|
||||
};
|
||||
const parts = {
|
||||
rendering: {
|
||||
refreshHorizonCulling: () => (calls.culling++, true),
|
||||
moveCameraIcon() {},
|
||||
},
|
||||
geometryQueue: { enqueueViewGeometry() {} },
|
||||
presentation: { notifyListeners: () => calls.notify++ },
|
||||
geometry: {
|
||||
// Same choice as geometry.updateRecordGeometry on a globe with a cold floor cell.
|
||||
updateRecordGeometry(r) {
|
||||
calls.geometry.push(
|
||||
ground.groundPriorAltFor(r) + r.camera.mountHeightM,
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
const ground = createGround({
|
||||
state,
|
||||
services: {
|
||||
ground: { resolveGroundFloorCells: async () => {} },
|
||||
terrain: { resolveEllipsoidalGround: async () => [] },
|
||||
},
|
||||
parts,
|
||||
});
|
||||
return { ground, calls };
|
||||
}
|
||||
|
||||
test('a late geoid fallback leaves a drawn-terrain height in place', () => {
|
||||
const camera = {
|
||||
id: 'a',
|
||||
lat: 42,
|
||||
lon: -118,
|
||||
mountHeightM: 8,
|
||||
absoluteHeightM: 1880,
|
||||
};
|
||||
const record = {
|
||||
camera,
|
||||
position: fromDegrees(camera.lon, camera.lat, 1880),
|
||||
frustumGeometry: {},
|
||||
frustumPositions: {},
|
||||
groundSamples: {},
|
||||
groundResolved: {},
|
||||
groundPrior: { ellipsoid: 1872, source: 'drawn-terrain', rangeM: 2000 },
|
||||
};
|
||||
const { ground, calls } = setup(record);
|
||||
ground.applyLateGroundPriors(
|
||||
[record],
|
||||
[{ ellipsoid: 0, source: 'geoid-fallback' }],
|
||||
);
|
||||
|
||||
assert.equal(record.groundPrior.source, 'drawn-terrain');
|
||||
assert.ok(!calls.geometry.includes(8), 'mount not lowered to the fallback');
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
import { distance, dot } from '../../geo/vector.js';
|
||||
import { canvasOf, findCamera } from '../../render/rendererOf.js';
|
||||
import { canvasOf, findCamera, findGlobe } from '../../render/rendererOf.js';
|
||||
import { viewshedColors, cameraHue } from '../../data/cctvViewshed.js';
|
||||
import { CCTV_OVERLAY_SOURCE_ID } from '../../data/cctvCards.js';
|
||||
import { GIZMO_ID_PREFIX } from '../../data/cctvGizmo.js';
|
||||
@@ -23,8 +23,14 @@ export function createLifecycle({
|
||||
source,
|
||||
}) {
|
||||
const { activateCctvCameraFromWorldClick } = services.activation;
|
||||
const { resolvePickId, registerPickOwner, unregisterPickOwner, clickCard } =
|
||||
services.picking;
|
||||
const {
|
||||
resolvePickId,
|
||||
registerPickOwner,
|
||||
unregisterPickOwner,
|
||||
clickCard,
|
||||
registerClickClaim,
|
||||
unregisterClickClaim,
|
||||
} = services.picking;
|
||||
const { onFocusTargetAppear } = services.focus;
|
||||
const { releaseContinuousRender } = services.render;
|
||||
|
||||
@@ -103,6 +109,30 @@ export function createLifecycle({
|
||||
* listeners to its camera; one against the same viewer keeps them.
|
||||
*/
|
||||
function attachViewListeners() {
|
||||
const globe = findGlobe(layerState._viewer);
|
||||
if (layerState._surfaceListenerGlobe !== globe) {
|
||||
layerState._surfaceListener?.();
|
||||
layerState._surfaceListener = null;
|
||||
layerState._surfaceListenerGlobe = globe;
|
||||
}
|
||||
if (!layerState._surfaceListener && globe?.on) {
|
||||
// Refresh drawn heights when terrain finishes loading or the surface changes.
|
||||
let version = globe.surfaceVersion?.();
|
||||
let terrainPending = globe.isSettled?.('terrain') === false ? 1 : 0;
|
||||
layerState._surfaceListener = globe.on('progress', (progress) => {
|
||||
const next = globe.surfaceVersion?.();
|
||||
const loaded = progress?.terrainPending === 0 && terrainPending !== 0;
|
||||
const swapped = next !== version;
|
||||
version = next;
|
||||
terrainPending = progress?.terrainPending ?? terrainPending;
|
||||
if (
|
||||
(loaded || swapped) &&
|
||||
layerState._enabled &&
|
||||
!layerState._cameraMoving
|
||||
)
|
||||
settleView();
|
||||
});
|
||||
}
|
||||
const viewCamera = findCamera(layerState._viewer);
|
||||
if (
|
||||
layerState._viewListenerCamera &&
|
||||
@@ -140,6 +170,9 @@ export function createLifecycle({
|
||||
|
||||
/** Drop the move listeners; nothing reports the end of a move after it. */
|
||||
function detachViewListeners() {
|
||||
layerState._surfaceListener?.();
|
||||
layerState._surfaceListener = null;
|
||||
layerState._surfaceListenerGlobe = null;
|
||||
layerState._horizonCullListener?.();
|
||||
layerState._horizonCullListener = null;
|
||||
layerState._moveStartListener?.();
|
||||
@@ -163,9 +196,11 @@ export function createLifecycle({
|
||||
layerState._records = [];
|
||||
layerState._recordById = new Map();
|
||||
layerState._viewRecords = [];
|
||||
layerState._pickerRecords = [];
|
||||
layerState._cameraIndexCache = null;
|
||||
layerState._coverageVisibleIds = new Set();
|
||||
layerState._neighborCountCache = null;
|
||||
layerState._coverageCohort = null;
|
||||
layerState._viewUnpublished = false;
|
||||
layerState._viewPose = null;
|
||||
layerState._viewMotionPass = null;
|
||||
@@ -285,9 +320,8 @@ export function createLifecycle({
|
||||
coverageEntities: [],
|
||||
projection: null,
|
||||
// Task 5 (height-datum fix): regime-aware ground resolution state.
|
||||
// groundPrior — { ellipsoid, source } from the Re:Earth batch
|
||||
// (null until a late batch lands). The prior applies in EVERY
|
||||
// regime and is the terrain-globe resolution outright.
|
||||
// groundPrior — { ellipsoid, source } from the Re:Earth batch, or
|
||||
// drawn-terrain with its read conditions for an unanswered camera.
|
||||
// groundResolved — PER-REGIME one-shot latch (regime key →
|
||||
// boolean): true once this record's resolution completed for that
|
||||
// regime; such records are excluded from the completion pass so
|
||||
@@ -386,6 +420,7 @@ export function createLifecycle({
|
||||
parts.rendering.refreshHorizonCulling();
|
||||
|
||||
const input = inputFor(layerState._viewer);
|
||||
layerState._clickSubscription?.();
|
||||
const unsubscribeClick = parts.selection.bindCctvWorldClickGesture(
|
||||
input,
|
||||
(event) => {
|
||||
@@ -481,6 +516,7 @@ export function createLifecycle({
|
||||
);
|
||||
return Boolean(coverage && layerState._recordById.has(coverage[1]));
|
||||
});
|
||||
registerClickClaim?.('cctv', parts.selection.countClickCard);
|
||||
if (!layerState._activeCameraId && layerState._records.length) {
|
||||
layerState._activeCameraId = parts.navigation.openingCameraId();
|
||||
layerState._autoHopSuspended = false;
|
||||
@@ -517,6 +553,7 @@ export function createLifecycle({
|
||||
services.credits?.hideOsmCredit?.(layerState._viewer, 'cctv');
|
||||
layerState._enabled = false;
|
||||
unregisterPickOwner('cctv');
|
||||
unregisterClickClaim?.('cctv');
|
||||
// ADJUST mode does not survive a layer toggle — predictable re-entry.
|
||||
layerState._calibrationMode = false;
|
||||
releaseContinuousRender('cctv-adjust');
|
||||
@@ -532,6 +569,7 @@ export function createLifecycle({
|
||||
parts.rendering.hideCctvVisuals();
|
||||
// Nothing is in view while the layer is off.
|
||||
layerState._viewRecords = [];
|
||||
layerState._pickerRecords = [];
|
||||
layerState._cameraIndexCache = null;
|
||||
parts.presentation.notifyListeners();
|
||||
},
|
||||
@@ -550,6 +588,7 @@ export function createLifecycle({
|
||||
parts.cards.handleVisibilityChange,
|
||||
);
|
||||
unregisterPickOwner('cctv');
|
||||
unregisterClickClaim?.('cctv');
|
||||
if (layerState._mapStackListener && typeof window !== 'undefined') {
|
||||
window.removeEventListener(
|
||||
'gev:map-stack-changed',
|
||||
|
||||
@@ -77,6 +77,40 @@ test('the view listeners follow the camera port and let go on teardown', () => {
|
||||
assert.equal(state._viewListenerCamera, null);
|
||||
});
|
||||
|
||||
test('terrain loading and surface changes rerun the view pass', () => {
|
||||
const viewer = {};
|
||||
let version = 1,
|
||||
progress,
|
||||
removed = false;
|
||||
bindRenderer(viewer, {
|
||||
camera: fakeCameraPort().port,
|
||||
globe: {
|
||||
surfaceVersion: () => version,
|
||||
on(event, cb) {
|
||||
assert.equal(event, 'progress');
|
||||
progress = cb;
|
||||
return () => {
|
||||
removed = true;
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
const { lifecycle, passes } = lifecycleFor({
|
||||
_viewer: viewer,
|
||||
_enabled: true,
|
||||
});
|
||||
lifecycle.attachViewListeners();
|
||||
progress({ terrainPending: 2 });
|
||||
assert.equal(passes.length, 0);
|
||||
progress({ terrainPending: 0 });
|
||||
assert.equal(passes.length, 1);
|
||||
version++;
|
||||
progress({ terrainPending: 0 });
|
||||
assert.equal(passes.length, 2);
|
||||
lifecycle.detachViewListeners();
|
||||
assert.ok(removed);
|
||||
});
|
||||
|
||||
/** A part whose members are `own`'s, and any other a function that does
|
||||
* nothing. */
|
||||
const inert = (own = {}) =>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { distance } from '../../geo/vector.js';
|
||||
import { rangeForBoundingSphere } from '../../data/cameraFraming.js';
|
||||
import { isFollowing } from '../../data/followed.js';
|
||||
import { CCTV_FOCUS_RESULT } from './policy.js';
|
||||
import { cameraOf } from '../../render/rendererOf.js';
|
||||
import { cellBounds, cellCenter } from '../../data/cctvCellCounts.js';
|
||||
import { CCTV_FOCUS_RESULT, VIEW_CELL_PX, VIEW_MIN_CELL_M } from './policy.js';
|
||||
import { cameraOf, canvasOf } from '../../render/rendererOf.js';
|
||||
|
||||
export function createNavigation({
|
||||
state: layerState,
|
||||
@@ -79,6 +82,16 @@ export function createNavigation({
|
||||
return true;
|
||||
}
|
||||
|
||||
/** What holds the view instead of a CCTV flight, or null when it is free. */
|
||||
function viewHeldBy(viewer) {
|
||||
if (
|
||||
typeof document !== 'undefined' &&
|
||||
document.body?.classList.contains('cockpit-mode')
|
||||
)
|
||||
return CCTV_FOCUS_RESULT.COCKPIT_ACTIVE;
|
||||
return isFollowing(viewer) ? CCTV_FOCUS_RESULT.TRACKING_HOLDS_VIEW : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flies the viewer's camera to frame the specified CCTV camera,
|
||||
* looking along its heading from above.
|
||||
@@ -90,14 +103,12 @@ export function createNavigation({
|
||||
|
||||
function focusCctvRecord(viewer, record, duration = 2.2) {
|
||||
if (!viewer || !record) return CCTV_FOCUS_RESULT.NO_ACTIVE_CAMERA;
|
||||
if (
|
||||
typeof document !== 'undefined' &&
|
||||
document.body?.classList.contains('cockpit-mode')
|
||||
) {
|
||||
const held = viewHeldBy(viewer);
|
||||
if (held === CCTV_FOCUS_RESULT.COCKPIT_ACTIVE) {
|
||||
console.debug('[Data:CCTV] focus ignored while cockpit owns the camera');
|
||||
return CCTV_FOCUS_RESULT.COCKPIT_ACTIVE;
|
||||
}
|
||||
if (isFollowing(viewer)) {
|
||||
if (held === CCTV_FOCUS_RESULT.TRACKING_HOLDS_VIEW) {
|
||||
console.debug(
|
||||
'[Data:CCTV] focus ignored while a tracked entity owns the camera',
|
||||
);
|
||||
@@ -120,6 +131,53 @@ export function createNavigation({
|
||||
return CCTV_FOCUS_RESULT.FOCUSED;
|
||||
}
|
||||
|
||||
/** The ground cell of a group nearest the eye, or the group itself if unmerged. */
|
||||
function nearestPart(cell, eye) {
|
||||
let nearest = cell;
|
||||
let best = Infinity;
|
||||
for (const part of cell.parts ?? []) {
|
||||
const d = distance(eye, cellCenter(part));
|
||||
if (d < best) {
|
||||
best = d;
|
||||
nearest = part;
|
||||
}
|
||||
}
|
||||
return nearest;
|
||||
}
|
||||
|
||||
/** Frame a group's padded bounds from above, including coincident mounts. */
|
||||
function zoomToCell(cell) {
|
||||
const viewer = layerState._viewer;
|
||||
if (!viewer || viewHeldBy(viewer)) return;
|
||||
const camera = cameraOf(viewer);
|
||||
const pose = camera.pose();
|
||||
const tanHalfY = Math.tan((pose.fovy || Math.PI / 3) / 2);
|
||||
const canvas = canvasOf(viewer);
|
||||
const height = canvas?.clientHeight || canvas?.height || 1;
|
||||
// Half the range where cells stop grouping, so even coincident mounts split.
|
||||
const closeRange =
|
||||
(VIEW_MIN_CELL_M * height) / (4 * VIEW_CELL_PX * tanHalfY);
|
||||
const fitRange = (bounds) =>
|
||||
Math.max(closeRange, rangeForBoundingSphere(viewer, bounds.radius));
|
||||
// Approach long groups in halves so every click gets closer.
|
||||
const halfway = (bounds) =>
|
||||
pose.position ? distance(pose.position, bounds.center) / 2 : Infinity;
|
||||
let bounds = cellBounds(cell);
|
||||
const fit = fitRange(bounds);
|
||||
let range = Math.min(halfway(bounds), fit);
|
||||
// If the group exceeds the narrower side of the frame, approach its nearest part.
|
||||
const tanHalf = tanHalfY * Math.min(1, pose.aspectRatio || 1);
|
||||
if (range < fit && range * tanHalf < bounds.radius) {
|
||||
bounds = cellBounds(nearestPart(cell, pose.position));
|
||||
range = Math.min(halfway(bounds), fitRange(bounds));
|
||||
}
|
||||
camera.flyToBounds(bounds, {
|
||||
offset: { heading: 0, pitch: -Math.PI / 2, range },
|
||||
durationS: 1.2,
|
||||
easing: 'cubicInOut',
|
||||
});
|
||||
}
|
||||
|
||||
function focusCamera(cameraId, duration = 2.2) {
|
||||
return focusCctvRecord(
|
||||
layerState._viewer,
|
||||
@@ -196,6 +254,7 @@ export function createNavigation({
|
||||
openingCameraId,
|
||||
reopenNearestCamera,
|
||||
focusCctvRecord,
|
||||
zoomToCell,
|
||||
focusCamera,
|
||||
maybeAutoHop,
|
||||
cctvCycleIndex,
|
||||
|
||||
+66
-18
@@ -60,17 +60,38 @@ export const GEO_PROGRESS_NOTIFY_INTERVAL_MS = 300;
|
||||
|
||||
export const GEO_PROGRESS_NOTIFY_BATCH_LIMIT = 10;
|
||||
|
||||
// View thinning: camera icons show only on or near the screen, and each
|
||||
// camera competes for a world-anchored grid cell sized to about VIEW_CELL_PX
|
||||
// at its distance from the viewer (in power-of-two metre steps, so a pan
|
||||
// keeps the same winners until a camera's distance crosses a step). Cells
|
||||
// smaller than VIEW_MIN_CELL_M do not thin:
|
||||
// close up every camera shows, co-located ones included.
|
||||
// View thinning groups cameras into world-anchored cells of about VIEW_CELL_PX
|
||||
// at their distance. Power-of-two metre steps keep cells stable during a pan.
|
||||
// A cell with several cameras draws one count. Its best-ranked camera represents
|
||||
// it in the picker. Cells smaller than VIEW_MIN_CELL_M do not group, so
|
||||
// every camera shows close up.
|
||||
|
||||
export const VIEW_CELL_PX = 40;
|
||||
|
||||
export const VIEW_MIN_CELL_M = 60;
|
||||
|
||||
// Cameras within this horizontal distance in metres share a mount.
|
||||
export const VIEW_SITE_M = 1.5;
|
||||
|
||||
// Cameras on one mount (VIEW_SITE_M) draw side by side,
|
||||
// this many pixels apart, once they show as icons.
|
||||
export const VIEW_SITE_SPREAD_PX = 30;
|
||||
|
||||
// Drawn-terrain reads per view pass for unanswered cameras and for re-reads
|
||||
// of drawn heights. Off-screen cameras can use at most half of the budget.
|
||||
// Remaining reads wait for the next pass.
|
||||
export const VIEW_GROUND_READS = 300;
|
||||
|
||||
/**
|
||||
* The camera icon's drawn size (px). Its SVG is 48 px: 1.25×
|
||||
* near scale on a 2× display draws it at 60 device px, so it is rasterised
|
||||
* past the drawn size to stay sharp there.
|
||||
*/
|
||||
export const CAMERA_ICON_PX = 24;
|
||||
|
||||
// Minimum gap between the outer rims of two separate markers.
|
||||
export const COUNT_MERGE_GAP_PX = 4;
|
||||
|
||||
// Icons this far past the screen edge (fraction of its size) still show, so
|
||||
// a pan does not reveal empty ground before the next view pass.
|
||||
|
||||
@@ -182,28 +203,51 @@ export const DEFAULT_CAMERA_CALIBRATION = Object.freeze({
|
||||
/**
|
||||
* Base64-encoded SVG camera icon for the camera icons. Icons rasterise an
|
||||
* SVG at its own size, so it is 48 px: drawn at 24 px, 1.25× near scale on a
|
||||
* 2× display draws it at 60 device px, and it stays sharp there.
|
||||
* 2× display draws it at 60 device px, and it stays sharp there. Active and
|
||||
* live cameras use cyan art with a billboard tint. Idle cameras use white
|
||||
* and gray art so the billboard green shows true. The overlay draws the
|
||||
* green variant directly.
|
||||
*/
|
||||
|
||||
export const CAMERA_ICON = (() => {
|
||||
function cameraIcon(tint = null) {
|
||||
function tone(original, gray) {
|
||||
if (!tint) return original;
|
||||
const shade = parseInt(gray.slice(1, 3), 16) / 255;
|
||||
return (
|
||||
'#' +
|
||||
tint
|
||||
.slice(1)
|
||||
.match(/../g)
|
||||
.map((channel) =>
|
||||
Math.round(parseInt(channel, 16) * shade)
|
||||
.toString(16)
|
||||
.padStart(2, '0'),
|
||||
)
|
||||
.join('')
|
||||
);
|
||||
}
|
||||
const stroke = tone('#75e7ff', '#ffffff');
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 36 36">
|
||||
<defs>
|
||||
<linearGradient id="lens" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#c9f6ff"/>
|
||||
<stop offset="45%" stop-color="#6fd9ff"/>
|
||||
<stop offset="100%" stop-color="#1a5f78"/>
|
||||
<stop offset="0%" stop-color="${tone('#c9f6ff', '#ffffff')}"/>
|
||||
<stop offset="45%" stop-color="${tone('#6fd9ff', '#dddddd')}"/>
|
||||
<stop offset="100%" stop-color="${tone('#1a5f78', '#666666')}"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g transform="translate(4 6)">
|
||||
<rect x="0" y="8" width="20" height="9" rx="2.5" fill="#0e1720" stroke="#75e7ff" stroke-width="1.2"/>
|
||||
<rect x="17" y="10" width="10" height="5" rx="1.5" fill="#132433" stroke="#75e7ff" stroke-width="1"/>
|
||||
<circle cx="24" cy="12.5" r="3.1" fill="url(#lens)" stroke="#dbfbff" stroke-width="0.8"/>
|
||||
<rect x="6.4" y="17" width="4.2" height="8.5" rx="1.2" fill="#10212d" stroke="#75e7ff" stroke-width="1"/>
|
||||
<rect x="4.2" y="24" width="8.6" height="2.5" rx="1.1" fill="#0b151d" stroke="#4ecde7" stroke-width="0.8"/>
|
||||
<rect x="0" y="8" width="20" height="9" rx="2.5" fill="${tone('#0e1720', '#181818')}" stroke="${stroke}" stroke-width="1.2"/>
|
||||
<rect x="17" y="10" width="10" height="5" rx="1.5" fill="${tone('#132433', '#222222')}" stroke="${stroke}" stroke-width="1"/>
|
||||
<circle cx="24" cy="12.5" r="3.1" fill="url(#lens)" stroke="${tone('#dbfbff', '#ffffff')}" stroke-width="0.8"/>
|
||||
<rect x="6.4" y="17" width="4.2" height="8.5" rx="1.2" fill="${tone('#10212d', '#202020')}" stroke="${stroke}" stroke-width="1"/>
|
||||
<rect x="4.2" y="24" width="8.6" height="2.5" rx="1.1" fill="${tone('#0b151d', '#151515')}" stroke="${tone('#4ecde7', '#cccccc')}" stroke-width="0.8"/>
|
||||
</g>
|
||||
</svg>`;
|
||||
return 'data:image/svg+xml;base64,' + btoa(svg);
|
||||
})();
|
||||
}
|
||||
|
||||
export const CAMERA_ICON = cameraIcon();
|
||||
export const IDLE_CAMERA_ICON = cameraIcon('#ffffff');
|
||||
|
||||
/**
|
||||
* Seed camera definitions used when no live sources are available.
|
||||
@@ -441,7 +485,11 @@ export const CAMERA_SEEDS = [
|
||||
// Visual style constants: renderer colours, [r, g, b, a] in 0..1
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const IDLE_CAMERA_COLOR = hexColor('#6be8ff', 0.88);
|
||||
/** Shared accent for idle still cameras and grouped cameras. */
|
||||
export const CAMERA_GREEN = '#5dff8f';
|
||||
export const COUNT_CAMERA_ICON = cameraIcon(CAMERA_GREEN);
|
||||
|
||||
export const IDLE_CAMERA_COLOR = hexColor(CAMERA_GREEN);
|
||||
|
||||
export const ACTIVE_CAMERA_COLOR = hexColor('#ffd97a', 0.95);
|
||||
|
||||
|
||||
@@ -229,9 +229,12 @@ export function createPresentation({
|
||||
// separately from the currently applied frustum ground. Google-3D may
|
||||
// legitimately refine the latter to the rendered mesh, so callers must
|
||||
// not infer the prior by subtracting mount height from live geometry.
|
||||
groundPriorM: Number.isFinite(record.groundPrior?.ellipsoid)
|
||||
? record.groundPrior.ellipsoid
|
||||
: null,
|
||||
// A height read from drawn terrain is unavailable as a Re:Earth prior.
|
||||
groundPriorM:
|
||||
Number.isFinite(record.groundPrior?.ellipsoid) &&
|
||||
record.groundPrior.source !== 'drawn-terrain'
|
||||
? record.groundPrior.ellipsoid
|
||||
: null,
|
||||
intrinsics: camera.intrinsics ? { ...camera.intrinsics } : null,
|
||||
extrinsics: camera.extrinsics ? { ...camera.extrinsics } : null,
|
||||
anchor: camera.anchor ? { ...camera.anchor } : null,
|
||||
@@ -310,16 +313,16 @@ export function createPresentation({
|
||||
}
|
||||
|
||||
/**
|
||||
* `{ id, city, name }` for the active camera, then every camera the view
|
||||
* pass shows: what the camera picker lists. A whole catalog would put tens
|
||||
* of thousands of options in the DOM and slow every layout. The same array
|
||||
* is returned until the view or the active camera changes, so a consumer
|
||||
* can compare it by identity.
|
||||
* `{ id, city, name }` for the active camera, then each camera shown as an
|
||||
* icon and the best-ranked camera of each visible group. A whole catalog
|
||||
* would put tens of thousands of options in the DOM and slow every layout.
|
||||
* Consumers can compare the array by identity until the picker records or
|
||||
* active camera change.
|
||||
* @returns {{id: string, city: string, name: string}[]}
|
||||
*/
|
||||
|
||||
function cameraIndex() {
|
||||
const view = layerState._viewRecords;
|
||||
const view = layerState._pickerRecords;
|
||||
const active = parts.selection.getActiveRecord();
|
||||
const cached = layerState._cameraIndexCache;
|
||||
if (cached?.view === view && cached.active === active) return cached.list;
|
||||
|
||||
+409
-87
@@ -1,7 +1,13 @@
|
||||
import { createCountMarkers } from './countMarkers.js';
|
||||
import { addCellCamera, createCameraCell } from '../../data/cctvCellCounts.js';
|
||||
import { isHeadingEstimated } from './headingConfidence.js';
|
||||
import {
|
||||
ACTIVE_CAMERA_COLOR,
|
||||
CAMERA_ICON,
|
||||
CAMERA_ICON_PX,
|
||||
COUNT_MERGE_GAP_PX,
|
||||
VIEW_SITE_M,
|
||||
IDLE_CAMERA_ICON,
|
||||
IDLE_CAMERA_COLOR,
|
||||
LIVE_CAMERA_COLOR,
|
||||
ACTIVE_COVERAGE_CENTER,
|
||||
@@ -14,6 +20,8 @@ import {
|
||||
VIEW_CELL_PX,
|
||||
VIEW_ICON_MARGIN,
|
||||
VIEW_MIN_CELL_M,
|
||||
VIEW_SITE_SPREAD_PX,
|
||||
VIEW_GROUND_READS,
|
||||
} from './policy.js';
|
||||
import { createIconBook } from '../../render/motion/iconBook.js';
|
||||
import { frustumVolumeGeometryData } from '../../data/cctvViewshed.js';
|
||||
@@ -24,11 +32,21 @@ import {
|
||||
findGlobe,
|
||||
findQuery,
|
||||
} from '../../render/rendererOf.js';
|
||||
import { fromDegrees, WGS84 } from '../../geo/ellipsoid.js';
|
||||
import { heightsOf } from '../../queries/heights.js';
|
||||
import {
|
||||
fromDegrees,
|
||||
fromDegreesInto,
|
||||
toLonLatH,
|
||||
WGS84,
|
||||
} from '../../geo/ellipsoid.js';
|
||||
import { eastNorthUp } from '../../geo/frames.js';
|
||||
import { poseProjector } from '../../geo/frustum.js';
|
||||
import { horizonFrom } from '../../geo/horizon.js';
|
||||
import { distance } from '../../geo/vector.js';
|
||||
import { add, distance, dot, scale, sub } from '../../geo/vector.js';
|
||||
|
||||
const IDLE_ICON_STYLE = { image: IDLE_CAMERA_ICON, color: IDLE_CAMERA_COLOR };
|
||||
const ACTIVE_ICON_STYLE = { image: CAMERA_ICON, color: ACTIVE_CAMERA_COLOR };
|
||||
const LIVE_ICON_STYLE = { image: CAMERA_ICON, color: LIVE_CAMERA_COLOR };
|
||||
|
||||
/** An RGBA colour with another alpha. */
|
||||
const withAlpha = (color, alpha) => [color[0], color[1], color[2], alpha];
|
||||
@@ -46,12 +64,6 @@ const samePoint = (a, b) =>
|
||||
/** Degrees to radians. */
|
||||
const toRadians = (degrees) => (degrees * Math.PI) / 180;
|
||||
|
||||
/**
|
||||
* The camera icon's drawn size (px). Its SVG is 48 px (policy.js): 1.25×
|
||||
* near scale on a 2× display draws it at 60 device px, so it is rasterised
|
||||
* past the drawn size to stay sharp there.
|
||||
*/
|
||||
const CAMERA_ICON_PX = 24;
|
||||
const CAMERA_SCALE_BY_DISTANCE = Object.freeze({
|
||||
near: 350,
|
||||
nearValue: 1.25,
|
||||
@@ -139,6 +151,12 @@ export function createRendering({
|
||||
// with its first camera.
|
||||
set.setColumns?.({ ids: [] });
|
||||
layerState._icons = createIconBook(set);
|
||||
layerState._counts = createCountMarkers(
|
||||
services.overlays?.registerWorldOverlayPaintLane,
|
||||
`cctv:${iconSets}:counts`,
|
||||
refreshHorizonCulling,
|
||||
services.overlays?.keyholeAlpha,
|
||||
);
|
||||
return set.id;
|
||||
}
|
||||
|
||||
@@ -146,6 +164,8 @@ export function createRendering({
|
||||
function destroyCameraIcons() {
|
||||
layerState._icons?.dispose();
|
||||
layerState._icons = null;
|
||||
layerState._counts?.dispose();
|
||||
layerState._counts = null;
|
||||
}
|
||||
|
||||
/** The icon item a camera record draws, idle and shown, at its position. */
|
||||
@@ -153,10 +173,9 @@ export function createRendering({
|
||||
const id = record.camera.id;
|
||||
return {
|
||||
id,
|
||||
pos: copyPoint(record.position),
|
||||
image: CAMERA_ICON,
|
||||
pos: copyPoint(record.spreadPosition ?? record.position),
|
||||
...cameraIconStyleFor(record),
|
||||
size: [CAMERA_ICON_PX, CAMERA_ICON_PX],
|
||||
color: cameraColorFor(record),
|
||||
scale: 1,
|
||||
scaleByDistance: CAMERA_SCALE_BY_DISTANCE,
|
||||
disableDepthTest: Infinity,
|
||||
@@ -195,22 +214,26 @@ export function createRendering({
|
||||
function moveCameraIcon(record) {
|
||||
const icons = layerState._icons;
|
||||
if (!icons || !record.position) return;
|
||||
// A camera drawn beside its mount mates keeps its offset from the mount.
|
||||
if (record.spreadOffset)
|
||||
record.spreadPosition = add(record.position, record.spreadOffset);
|
||||
const pos = record.spreadPosition ?? record.position;
|
||||
const item = icons.item(record.camera.id);
|
||||
// A camera whose icon waited for a position is drawn now.
|
||||
if (!item) {
|
||||
icons.put(cameraIconItem(record));
|
||||
return;
|
||||
}
|
||||
if (samePoint(item.pos, record.position)) return;
|
||||
icons.put({ ...item, pos: copyPoint(record.position) });
|
||||
if (samePoint(item.pos, pos)) return;
|
||||
icons.put({ ...item, pos: copyPoint(pos) });
|
||||
}
|
||||
|
||||
/** Icon color: active wins, then live-capable video feeds, then idle stills. */
|
||||
function cameraColorFor(record) {
|
||||
/** Select the sprite and tint together when a camera changes state. */
|
||||
function cameraIconStyleFor(record) {
|
||||
if (record.camera.id === layerState._activeCameraId)
|
||||
return ACTIVE_CAMERA_COLOR;
|
||||
if (parts.model.isVideoFeedCamera(record.camera)) return LIVE_CAMERA_COLOR;
|
||||
return IDLE_CAMERA_COLOR;
|
||||
return ACTIVE_ICON_STYLE;
|
||||
if (parts.model.isVideoFeedCamera(record.camera)) return LIVE_ICON_STYLE;
|
||||
return IDLE_ICON_STYLE;
|
||||
}
|
||||
|
||||
const {
|
||||
@@ -219,11 +242,14 @@ export function createRendering({
|
||||
focusPassIsNeeded,
|
||||
advanceSpriteFocus,
|
||||
focusAlphaNeedsWrite,
|
||||
nearFarScalarValueAtDistance,
|
||||
} = services.focus;
|
||||
const iconScaleAt = (range) =>
|
||||
nearFarScalarValueAtDistance?.(CAMERA_SCALE_BY_DISTANCE, range) ?? 1;
|
||||
|
||||
/**
|
||||
* Focus modulation rides the layer's existing animation loop; no additional
|
||||
* scene listener is installed. Only camera-icon alpha changes here — coverage
|
||||
* scene listener is installed. Camera and count icons share the fade. Coverage
|
||||
* geometry and monitor-plane styling retain their established cadence.
|
||||
*/
|
||||
|
||||
@@ -276,61 +302,71 @@ export function createRendering({
|
||||
let writes = 0;
|
||||
let transitioning = false;
|
||||
let activeCount = 0;
|
||||
for (const record of records || []) {
|
||||
const id = record.camera?.id;
|
||||
const item = icons?.item(id);
|
||||
if (!item) continue;
|
||||
const position = record.position;
|
||||
const scale = item.scale ?? 1;
|
||||
// CCTV never publishes a tracked focus target, so every icon is ambient.
|
||||
const focus = advanceSpriteFocus(item.meta, {
|
||||
// Keep hidden icons in the state/release pass so the active count cannot
|
||||
// drop while a stale dim alpha remains waiting to reappear.
|
||||
screenPosition:
|
||||
item.show === false || !position ? null : screenPositionFor(position),
|
||||
/**
|
||||
* A changed focus factor for an icon or count. CCTV publishes no tracked
|
||||
* focus target, so every icon is ambient.
|
||||
*/
|
||||
function changedFocus(owner, position, shown, width, height, current) {
|
||||
const focus = advanceSpriteFocus(owner, {
|
||||
// Keep hidden owners in the active count until their dim alpha clears,
|
||||
// so the focus pass keeps running while they recover.
|
||||
screenPosition: shown && position ? screenPositionFor(position) : null,
|
||||
cameraDistance: position ? cameraDistanceFor(position) : Number.NaN,
|
||||
nowMs,
|
||||
target,
|
||||
params,
|
||||
spriteHalfWidthPx: item.size[0] * scale * 0.5,
|
||||
spriteHalfHeightPx: item.size[1] * scale * 0.5,
|
||||
spriteHalfWidthPx: width / 2,
|
||||
spriteHalfHeightPx: height / 2,
|
||||
});
|
||||
transitioning ||= focus.transitioning;
|
||||
if (focus.active) activeCount += 1;
|
||||
// Order-independent narrow amendment to always-visible icons: CCTV
|
||||
// contacts retain a non-zero floor while yielding near the tracked target.
|
||||
if (focusAlphaNeedsWrite(icons.focus(id), focus.factor, params)) {
|
||||
icons.setFocus(id, focus.factor);
|
||||
writes += 1;
|
||||
}
|
||||
if (focus.active) activeCount++;
|
||||
if (!focusAlphaNeedsWrite(current, focus.factor, params)) return null;
|
||||
writes++;
|
||||
return focus.factor;
|
||||
}
|
||||
for (const record of records || []) {
|
||||
const id = record.camera?.id;
|
||||
const item = icons?.item(id);
|
||||
if (!item) continue;
|
||||
const scale = item.scale ?? 1;
|
||||
const factor = changedFocus(
|
||||
item.meta,
|
||||
record.position,
|
||||
item.show !== false,
|
||||
item.size[0] * scale,
|
||||
item.size[1] * scale,
|
||||
icons.focus(id),
|
||||
);
|
||||
if (factor !== null) icons.setFocus(id, factor);
|
||||
}
|
||||
const counts = layerState._counts;
|
||||
const iconWrites = writes;
|
||||
for (const marker of counts?.markers ?? []) {
|
||||
const factor = changedFocus(
|
||||
marker,
|
||||
marker.pos,
|
||||
true,
|
||||
marker.width,
|
||||
marker.height,
|
||||
marker.focus,
|
||||
);
|
||||
if (factor !== null) marker.focus = factor;
|
||||
}
|
||||
if (writes > iconWrites) counts.requestPaint();
|
||||
return { writes, transitioning, activeCount, ran: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates visual styles (colors, widths, visibility) for all camera icons,
|
||||
* coverage polylines, viewshed volumes, and projection entities based on which
|
||||
* camera is active, whether the layer is enabled, and the current
|
||||
* coverage-mode/projection toggle states.
|
||||
*/
|
||||
/**
|
||||
* Field-test fix (2026-07-06): horizon-culls camera icons on the CPU as the
|
||||
* icon shader does on the GPU. With the globe hidden (Google-3D
|
||||
* regime) nothing writes far-side depth and the icons are always-on-top, so
|
||||
* the shown set (cards, geometry, the picker) must not include London's
|
||||
* cluster from a US viewpoint.
|
||||
*
|
||||
* The same pass thins the view so a large catalog stays readable and cheap:
|
||||
* icons well off screen hide, and each camera competes for a world-anchored
|
||||
* cell sized to VIEW_CELL_PX at its distance (healthiest first, then a stable
|
||||
* id order). The active camera shows whenever it is above the horizon
|
||||
* and near the screen, even in a crowded cell. The shown records become
|
||||
* `_viewRecords`, the working set for geometry, cards and the camera picker;
|
||||
* the array keeps its identity while the shown set is unchanged.
|
||||
* Cull far-side cameras on the CPU because the hidden globe writes no depth.
|
||||
* Group the rest by ground cell. _viewRecords holds the active camera and
|
||||
* every nearby icon outside a count for geometry and cards. Cells smaller
|
||||
* than VIEW_MIN_CELL_M do not form groups. _pickerRecords adds the
|
||||
* best-ranked camera of each visible cell. Both arrays keep their identity
|
||||
* while their contents are unchanged.
|
||||
*
|
||||
* Runs on camera settle, throttled during motion, on resize, enable and
|
||||
* activation changes — never per frame.
|
||||
* @returns {boolean} Whether the shown set changed.
|
||||
* @returns {boolean} Whether the shown set or the picker list changed.
|
||||
*/
|
||||
|
||||
function refreshHorizonCulling() {
|
||||
@@ -365,7 +401,30 @@ export function createRendering({
|
||||
const project = screenProjector(pose, width, height);
|
||||
const pass = (layerState._viewPassId = (layerState._viewPassId || 0) + 1);
|
||||
const shown = [];
|
||||
const picker = [];
|
||||
const cells = new Map();
|
||||
const visibleCells = [];
|
||||
// Drawn terrain where the globe is the surface. The photoreal stack has
|
||||
// no reader, and unloaded tiles return a non-finite height.
|
||||
const heights = heightsOf(layerState._viewer);
|
||||
const globe = findGlobe(layerState._viewer);
|
||||
const groundHeight =
|
||||
findQuery(layerState._viewer) && globe?.isGlobeVisible?.() === true
|
||||
? (lon, lat) => heights.now({ lon, lat }, { against: 'terrain' })
|
||||
: null;
|
||||
const surface = globe?.surfaceVersion?.() ?? 0;
|
||||
const terrainSettled = globe?.isSettled?.('terrain') ?? true;
|
||||
let groundReads = groundHeight ? VIEW_GROUND_READS : 0;
|
||||
let offscreenReads = groundReads / 2;
|
||||
let eyeGround;
|
||||
const column = { x: 0, y: 0, z: 0 };
|
||||
const inReadWindow = (s) =>
|
||||
s &&
|
||||
s.x >= -width &&
|
||||
s.x <= 2 * width &&
|
||||
s.y >= -height &&
|
||||
s.y <= 2 * height;
|
||||
const regrounded = [];
|
||||
for (const record of layerState._records) {
|
||||
const position = record.position;
|
||||
if (!position) continue;
|
||||
@@ -380,48 +439,305 @@ export function createRendering({
|
||||
(vtDotVc * vtDotVc) / (vx * vx + vy * vy + vz * vz) > limbSquared
|
||||
)
|
||||
continue;
|
||||
const screen = project(position);
|
||||
let screen = project(position);
|
||||
let range = distance(position, viewer);
|
||||
// Missing, unresolved and fallback priors can put a mount kilometres
|
||||
// below the terrain, shifting its projection and inflating its cell.
|
||||
// Read nearby mounts again from under half the range, on finer terrain
|
||||
// after loading, or on a different surface.
|
||||
const prior = record.groundPrior;
|
||||
const drawn = prior?.source === 'drawn-terrain';
|
||||
const unanswered =
|
||||
!Number.isFinite(prior?.ellipsoid) || prior.source === 'geoid-fallback';
|
||||
if (
|
||||
!screen ||
|
||||
!(screen.x >= minX && screen.x <= maxX) ||
|
||||
!(screen.y >= minY && screen.y <= maxY)
|
||||
)
|
||||
continue;
|
||||
const dx = position.x - viewer.x;
|
||||
const dy = position.y - viewer.y;
|
||||
const dz = position.z - viewer.z;
|
||||
const cellM =
|
||||
VIEW_CELL_PX *
|
||||
metresPerPixelPerMetre *
|
||||
Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
if (record.camera.id === activeId || !(cellM >= VIEW_MIN_CELL_M)) {
|
||||
record.viewPass = pass;
|
||||
groundReads > 0 &&
|
||||
!record.regroundPending &&
|
||||
(unanswered ||
|
||||
(drawn &&
|
||||
(prior.rangeM > 2 * range ||
|
||||
prior.surface !== surface ||
|
||||
(!prior.settled && terrainSettled))))
|
||||
) {
|
||||
let probe = inReadWindow(screen) ? screen : null;
|
||||
if (!probe && unanswered) {
|
||||
// Its height is a guess. Try the ground under the eye instead.
|
||||
if (eyeGround === undefined) {
|
||||
const eye = toLonLatH(viewer);
|
||||
eyeGround = eye ? (groundHeight(eye.lon, eye.lat) ?? null) : null;
|
||||
groundReads--;
|
||||
}
|
||||
if (Number.isFinite(eyeGround)) {
|
||||
fromDegreesInto(
|
||||
record.camera.lon,
|
||||
record.camera.lat,
|
||||
eyeGround + (record.camera.mountHeightM || 0),
|
||||
column,
|
||||
);
|
||||
const at = project(column);
|
||||
if (inReadWindow(at)) probe = at;
|
||||
}
|
||||
}
|
||||
const onScreen =
|
||||
probe &&
|
||||
probe.x >= 0 &&
|
||||
probe.x <= width &&
|
||||
probe.y >= 0 &&
|
||||
probe.y <= height;
|
||||
if (probe && groundReads > 0 && (onScreen || offscreenReads > 0)) {
|
||||
groundReads--;
|
||||
if (!onScreen) offscreenReads--;
|
||||
const ground = groundHeight(record.camera.lon, record.camera.lat);
|
||||
if (Number.isFinite(ground)) {
|
||||
const read = { rangeM: range, surface, settled: terrainSettled };
|
||||
if (drawn && Math.abs(ground - prior.ellipsoid) < 1)
|
||||
Object.assign(prior, read);
|
||||
else if (record.frustumGeometry) {
|
||||
// Recomputing geometry writes draw sets after this pass.
|
||||
record.regroundPending = true;
|
||||
regrounded.push([record, ground, read]);
|
||||
} else parts.ground.adoptDrawnGround(record, ground, read);
|
||||
}
|
||||
}
|
||||
// The probe reuses the projector's result, and the mount may have moved.
|
||||
screen = project(position);
|
||||
range = distance(position, viewer);
|
||||
}
|
||||
const nearScreen =
|
||||
screen &&
|
||||
screen.x >= minX &&
|
||||
screen.x <= maxX &&
|
||||
screen.y >= minY &&
|
||||
screen.y <= maxY;
|
||||
const cellM = VIEW_CELL_PX * metresPerPixelPerMetre * range;
|
||||
if (record.camera.id === activeId) {
|
||||
if (!nearScreen) continue;
|
||||
record.viewPass = record.pickerPass = pass;
|
||||
shown.push(record);
|
||||
picker.push(record);
|
||||
continue;
|
||||
}
|
||||
if (!(cellM >= VIEW_MIN_CELL_M)) {
|
||||
if (!nearScreen) continue;
|
||||
// Too close to group, but a count beside it can still take it in.
|
||||
const cell = createCameraCell(`near:${record.camera.id}`);
|
||||
addCellCamera(cell, record.camera);
|
||||
cell.iconPx = CAMERA_ICON_PX * iconScaleAt(range);
|
||||
cell.winner = record;
|
||||
cell.rank = 0;
|
||||
record.viewCell = cell;
|
||||
visibleCells.push(cell);
|
||||
continue;
|
||||
}
|
||||
const key = worldCellKey(record, cellM);
|
||||
let cell = cells.get(key);
|
||||
if (!cell) {
|
||||
cell = createCameraCell(key);
|
||||
cells.set(key, cell);
|
||||
}
|
||||
addCellCamera(cell, record.camera);
|
||||
if (cell.count === 1) cell.iconPx = CAMERA_ICON_PX * iconScaleAt(range);
|
||||
record.viewCell = cell;
|
||||
if (!nearScreen) continue;
|
||||
// The picker ranks only candidates that were in its padded viewport.
|
||||
if (!cell.winner) visibleCells.push(cell);
|
||||
const rank = viewRank(record);
|
||||
const holder = cells.get(key);
|
||||
if (!holder || rank < holder.rank) cells.set(key, { record, rank });
|
||||
if (rank < cell.rank) {
|
||||
cell.winner = record;
|
||||
cell.rank = rank;
|
||||
}
|
||||
}
|
||||
for (const { record } of cells.values()) {
|
||||
record.viewPass = pass;
|
||||
shown.push(record);
|
||||
// Check each mount mate against counts where its icon will be drawn.
|
||||
const lone = visibleCells.filter((cell) => cell.count === 1);
|
||||
spreadSharedMounts(
|
||||
shown.concat(lone.map((cell) => cell.winner)),
|
||||
pose,
|
||||
metresPerPixelPerMetre,
|
||||
pass,
|
||||
);
|
||||
for (const cell of lone)
|
||||
cell.offsetPx =
|
||||
cell.winner.spreadPass === pass ? cell.winner.spreadPx : 0;
|
||||
// A count stands on the drawn terrain too: its cell may be too far for
|
||||
// its cameras to have been read. Marks each lone camera that a count
|
||||
// marker beside it has taken in.
|
||||
layerState._counts?.update(visibleCells, project, groundHeight);
|
||||
for (const cell of visibleCells) {
|
||||
const record = cell.winner;
|
||||
picker.push(record);
|
||||
record.pickerPass = pass;
|
||||
if (cell.count === 1 && !cell.absorbed) {
|
||||
record.viewPass = pass;
|
||||
shown.push(record);
|
||||
}
|
||||
}
|
||||
clearActiveOfCounts(project, pose, metresPerPixelPerMetre, pass);
|
||||
const writes = [];
|
||||
let coverageChanged = false;
|
||||
let cardsChanged = false;
|
||||
for (const record of layerState._records) {
|
||||
const item = patchedCameraIcon(record.camera.id, {
|
||||
show: record.viewPass === pass,
|
||||
});
|
||||
const cell = record.viewCell;
|
||||
record.viewCell = null;
|
||||
const grouped = Boolean(
|
||||
cell?.winner && (cell.count > 1 || cell.absorbed),
|
||||
);
|
||||
if (grouped !== !!record.viewGrouped) {
|
||||
const id = record.camera.id;
|
||||
coverageChanged ||= layerState._coverageCohort?.has(id);
|
||||
cardsChanged ||=
|
||||
layerState._cardIds?.has(id) || layerState._hoverCardId === id;
|
||||
}
|
||||
record.viewGrouped = grouped;
|
||||
const fields = { show: record.viewPass === pass };
|
||||
if (record.spreadPass === pass) {
|
||||
const drawn = layerState._icons?.item(record.camera.id)?.pos;
|
||||
if (!drawn || !samePoint(drawn, record.spreadPosition))
|
||||
fields.pos = copyPoint(record.spreadPosition);
|
||||
} else if (record.spreadPosition) {
|
||||
// No longer beside a mount mate: back onto its own position.
|
||||
record.spreadOffset = null;
|
||||
record.spreadPosition = null;
|
||||
fields.pos = copyPoint(record.position);
|
||||
}
|
||||
const item = patchedCameraIcon(record.camera.id, fields);
|
||||
if (item) writes.push(item);
|
||||
}
|
||||
writeCameraIcons(writes);
|
||||
if (regrounded.length) queueMicrotask(() => reground(regrounded));
|
||||
const previous = layerState._viewRecords;
|
||||
const changed =
|
||||
previous.length !== shown.length ||
|
||||
previous.some((record) => record.viewPass !== pass);
|
||||
if (changed) layerState._viewRecords = shown;
|
||||
return changed;
|
||||
const oldPicker = layerState._pickerRecords ?? [];
|
||||
const pickerChanged =
|
||||
picker.length !== oldPicker.length ||
|
||||
oldPicker.some((record) => record.pickerPass !== pass);
|
||||
if (pickerChanged) layerState._pickerRecords = picker;
|
||||
if (coverageChanged) refreshCoverageStyles();
|
||||
if (cardsChanged) parts.cards.pushAmbientCardEntries();
|
||||
return changed || pickerChanged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cameras that have geometry take the drawn terrain after the pass that
|
||||
* read it, then the view is passed again from their new positions.
|
||||
*/
|
||||
function reground(entries) {
|
||||
let changed = false;
|
||||
for (const [record, ground, read] of entries) {
|
||||
record.regroundPending = false;
|
||||
changed =
|
||||
parts.ground.adoptDrawnGround(record, ground, read) !== null || changed;
|
||||
}
|
||||
if (!changed) return;
|
||||
if (refreshHorizonCulling()) parts.geometryQueue.enqueueViewGeometry();
|
||||
parts.presentation.notifyListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cameras on one mount would draw as one icon with several callouts. Among
|
||||
* icon candidates, those within VIEW_SITE_M horizontally get draw positions
|
||||
* side by side in id order, `VIEW_SITE_SPREAD_PX` apart on screen. A mate
|
||||
* absorbed by a count keeps its place in the row. Geometry and cards stay
|
||||
* on the mount.
|
||||
*/
|
||||
function spreadSharedMounts(shown, pose, metresPerPixelPerMetre, pass) {
|
||||
const { right, direction, position: eye } = pose;
|
||||
if (!right || !direction || shown.length < 2) return;
|
||||
const grid = new Map();
|
||||
const mounts = [];
|
||||
const axes = eastNorthUp(eye);
|
||||
for (const record of shown) {
|
||||
// Sea-level coordinates compare horizontal distance across longitude
|
||||
// and latitude boundaries, including the antimeridian.
|
||||
const p = fromDegrees(record.camera.lon, record.camera.lat, 0);
|
||||
const col = Math.floor(dot(p, axes.x) / VIEW_SITE_M);
|
||||
const row = Math.floor(dot(p, axes.y) / VIEW_SITE_M);
|
||||
let mount;
|
||||
for (let i = col - 1; !mount && i <= col + 1; i++)
|
||||
for (let j = row - 1; !mount && j <= row + 1; j++)
|
||||
mount = grid
|
||||
.get(`${i}:${j}`)
|
||||
?.find((site) => distance(p, site.p) <= VIEW_SITE_M);
|
||||
if (!mount) {
|
||||
mount = { p, mates: [] };
|
||||
mounts.push(mount);
|
||||
const key = `${col}:${row}`;
|
||||
if (!grid.has(key)) grid.set(key, []);
|
||||
grid.get(key).push(mount);
|
||||
}
|
||||
mount.mates.push(record);
|
||||
}
|
||||
for (const { mates } of mounts) {
|
||||
if (mates.length < 2) continue;
|
||||
mates.sort((a, b) => a.camera.id.localeCompare(b.camera.id));
|
||||
for (let i = 0; i < mates.length; i++) {
|
||||
const record = mates[i];
|
||||
const p = record.position;
|
||||
// A pixel's width on the ground grows with depth along the view.
|
||||
const depth =
|
||||
(p.x - eye.x) * direction.x +
|
||||
(p.y - eye.y) * direction.y +
|
||||
(p.z - eye.z) * direction.z;
|
||||
const px = (i - (mates.length - 1) / 2) * VIEW_SITE_SPREAD_PX;
|
||||
record.spreadPx = px;
|
||||
const metres = px * metresPerPixelPerMetre * depth;
|
||||
record.spreadOffset = scale(right, metres);
|
||||
record.spreadPosition = add(p, record.spreadOffset);
|
||||
record.spreadPass = pass;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Only counts visible outside the HUD push the active icon aside. */
|
||||
function clearActiveOfCounts(project, pose, metresPerPixelPerMetre, pass) {
|
||||
if (!layerState._activeCameraId) return;
|
||||
const record = layerState._recordById.get(layerState._activeCameraId);
|
||||
const markers = layerState._counts?.markers;
|
||||
if (
|
||||
record?.viewPass !== pass ||
|
||||
!markers?.length ||
|
||||
!pose.right ||
|
||||
!pose.direction
|
||||
)
|
||||
return;
|
||||
const spread = record.spreadPass === pass;
|
||||
const p = spread ? record.spreadPosition : record.position;
|
||||
const screen = project(p);
|
||||
if (!screen) return;
|
||||
const { x, y } = screen;
|
||||
const half =
|
||||
(CAMERA_ICON_PX * 1.25 * iconScaleAt(distance(p, pose.position))) / 2;
|
||||
const spans = [];
|
||||
for (const marker of markers) {
|
||||
if (marker.hudHidden) continue;
|
||||
const at = project(marker.pos);
|
||||
if (
|
||||
!at ||
|
||||
Math.abs(y - at.y) >= marker.height / 2 + half + COUNT_MERGE_GAP_PX
|
||||
)
|
||||
continue;
|
||||
const reach = marker.width / 2 + half + COUNT_MERGE_GAP_PX;
|
||||
spans.push([at.x - reach, at.x + reach]);
|
||||
}
|
||||
// Leave the entire overlapping interval, including an adjacent count.
|
||||
spans.sort((a, b) => a[0] - b[0]);
|
||||
let left = Infinity,
|
||||
right = -Infinity;
|
||||
for (const [start, end] of spans) {
|
||||
if (start >= right) {
|
||||
if (left < x && x < right) break;
|
||||
left = start;
|
||||
right = end;
|
||||
} else right = Math.max(right, end);
|
||||
}
|
||||
if (!(left < x && x < right)) return;
|
||||
const shift = x - left < right - x ? left - x : right - x;
|
||||
const depth = dot(sub(p, pose.position), pose.direction);
|
||||
const offset = scale(pose.right, shift * metresPerPixelPerMetre * depth);
|
||||
record.spreadOffset = spread ? add(record.spreadOffset, offset) : offset;
|
||||
record.spreadPosition = add(record.position, record.spreadOffset);
|
||||
record.spreadPass = pass;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -526,6 +842,7 @@ export function createRendering({
|
||||
);
|
||||
parts.projection.clearProjectionOverlay();
|
||||
if (layerState._icons) layerState._icons.show = false;
|
||||
layerState._counts?.hide();
|
||||
parts.projection.pauseInactiveProjectionFeeds(null);
|
||||
}
|
||||
|
||||
@@ -535,8 +852,12 @@ export function createRendering({
|
||||
const activeRecord = parts.selection.getActiveRecord();
|
||||
parts.geometry.ensureActiveCoverageEntities(activeRecord);
|
||||
const activeId = activeRecord?.camera.id || null;
|
||||
const coverageVisible =
|
||||
parts.geometry.buildCoverageVisibleSet(activeRecord);
|
||||
const cohort = parts.geometry.buildCoverageVisibleSet(activeRecord);
|
||||
layerState._coverageCohort = cohort;
|
||||
const coverageVisible = new Set();
|
||||
for (const id of cohort) {
|
||||
if (!layerState._recordById.get(id)?.viewGrouped) coverageVisible.add(id);
|
||||
}
|
||||
// Drawn coverage needs geometry too (geometryQueue's working set).
|
||||
layerState._coverageVisibleIds = coverageVisible;
|
||||
const coverageOn = layerState._coverageMode !== 'off';
|
||||
@@ -553,7 +874,7 @@ export function createRendering({
|
||||
for (const record of layerState._records) {
|
||||
const isActive = record.camera.id === activeId;
|
||||
const icon = patchedCameraIcon(record.camera.id, {
|
||||
color: cameraColorFor(record),
|
||||
...cameraIconStyleFor(record),
|
||||
scale: isActive ? 1.25 : 1.0,
|
||||
});
|
||||
if (icon) restyled.push(icon);
|
||||
@@ -865,6 +1186,7 @@ export function createRendering({
|
||||
* @returns {string|null}
|
||||
*/
|
||||
function pickCameraIdAt(position) {
|
||||
if (layerState._counts?.pickedCell(position)) return null;
|
||||
let hit = null;
|
||||
try {
|
||||
hit = findQuery(layerState._viewer)?.pick(position.x, position.y) ?? null;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// src/layers/cctv/rendering.test.mjs
|
||||
// Icon colors under focus de-emphasis (#1200): the focus pass fades each icon
|
||||
// from the same base color the coverage refresh assigns, so a video-feed camera
|
||||
// stays violet while it dims instead of falling back to the idle cyan.
|
||||
// stays violet while it dims instead of falling back to the idle green.
|
||||
// Teardown lets go of the icon set of the viewer that drew it.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
@@ -114,29 +114,80 @@ test('focus de-emphasis fades each icon from its own color', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('focus uses the painted half-width and half-height of each count', () => {
|
||||
const markers = [
|
||||
{ width: 40, height: 40 },
|
||||
{ width: 72, height: 58 },
|
||||
];
|
||||
const sizes = [];
|
||||
const rendering = createRendering({
|
||||
state: { _counts: { markers } },
|
||||
services: {
|
||||
focus: {
|
||||
focusPassIsNeeded: () => true,
|
||||
advanceSpriteFocus(_owner, { spriteHalfWidthPx, spriteHalfHeightPx }) {
|
||||
sizes.push([spriteHalfWidthPx, spriteHalfHeightPx]);
|
||||
return { factor: 1 };
|
||||
},
|
||||
focusAlphaNeedsWrite: () => false,
|
||||
},
|
||||
},
|
||||
});
|
||||
rendering.applyCctvFocusDeemphasis({});
|
||||
assert.deepEqual(sizes, [
|
||||
[20, 20],
|
||||
[36, 29],
|
||||
]);
|
||||
});
|
||||
|
||||
test('the icons go with the viewer that drew them, whichever tears down', () => {
|
||||
const first = {};
|
||||
const second = {};
|
||||
const one = bindFakeDraw(first);
|
||||
const two = bindFakeDraw(second);
|
||||
const state = { _viewer: first };
|
||||
const lanes = [];
|
||||
const overlays = {
|
||||
registerWorldOverlayPaintLane(name, paint, options) {
|
||||
const lane = {
|
||||
name,
|
||||
paint,
|
||||
options,
|
||||
setActive() {},
|
||||
unregister() {
|
||||
this.disposed = true;
|
||||
},
|
||||
};
|
||||
lanes.push(lane);
|
||||
return lane;
|
||||
},
|
||||
};
|
||||
const { createCameraIcons, destroyCameraIcons } = createRendering({
|
||||
state,
|
||||
services: { focus: {} },
|
||||
services: { focus: {}, overlays },
|
||||
parts: {},
|
||||
source: {},
|
||||
});
|
||||
try {
|
||||
const old = createCameraIcons(first);
|
||||
assert.equal(one.draw.sets.size, 1);
|
||||
assert.equal(lanes[0].name, 'ambient-label');
|
||||
assert.equal(lanes[0].options.target, 'shared');
|
||||
assert.equal(lanes[0].options.active, false);
|
||||
state._viewer = second;
|
||||
const current = createCameraIcons(second);
|
||||
assert.notEqual(old, current);
|
||||
assert.equal(one.draw.sets.get(old).disposed, true, 'a re-init lets go');
|
||||
assert.equal(two.draw.sets.get(current).disposed, false);
|
||||
assert.equal(lanes[0].disposed, true);
|
||||
lanes[0].paint({});
|
||||
|
||||
destroyCameraIcons();
|
||||
assert.equal(two.draw.sets.get(current).disposed, true);
|
||||
assert.equal(state._icons, null);
|
||||
assert.equal(lanes[1].disposed, true);
|
||||
lanes[1].paint({});
|
||||
assert.equal(state._counts, null);
|
||||
} finally {
|
||||
one.unbind();
|
||||
two.unbind();
|
||||
@@ -376,3 +427,35 @@ test('a pose with no perspective field of view is projected by the renderer', ()
|
||||
unbind();
|
||||
}
|
||||
});
|
||||
|
||||
test('hover picks the underlying camera only outside a painted count', () => {
|
||||
const viewer = {};
|
||||
const icon = { set: 'icons', id: 'camera' };
|
||||
let picks = 0;
|
||||
const unbind = bindRenderer(viewer, {
|
||||
query: {
|
||||
pick() {
|
||||
picks++;
|
||||
return icon;
|
||||
},
|
||||
},
|
||||
});
|
||||
try {
|
||||
const state = {
|
||||
_viewer: viewer,
|
||||
_counts: { pickedCell: ({ x }) => (x <= 17 ? {} : null) },
|
||||
_icons: { setId: icon.set, has: () => true },
|
||||
_recordById: new Map([[icon.id, {}]]),
|
||||
};
|
||||
const rendering = createRendering({
|
||||
state,
|
||||
services: { focus: {} },
|
||||
parts: {},
|
||||
});
|
||||
assert.equal(rendering.pickCameraIdAt({ x: 17, y: 0 }), null);
|
||||
assert.equal(picks, 0);
|
||||
assert.equal(rendering.pickCameraIdAt({ x: 18, y: 0 }), icon.id);
|
||||
} finally {
|
||||
unbind();
|
||||
}
|
||||
});
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
CCTV_COUNT_CARD_SOURCE_ID,
|
||||
CCTV_OVERLAY_SOURCE_ID,
|
||||
} from '../../data/cctvCards.js';
|
||||
import { isTrackingClickGesture } from '../../data/trackingClickGesture.js';
|
||||
|
||||
export function createSelection({
|
||||
@@ -7,7 +11,8 @@ export function createSelection({
|
||||
source,
|
||||
}) {
|
||||
const { CCTV_ACTIVATION_RESULT } = services.activation;
|
||||
const { resolvePickId } = services.picking;
|
||||
const { resolvePickId, findPickOwner, isUnderOtherCard } = services.picking;
|
||||
const OWN_CARD_SOURCES = [CCTV_OVERLAY_SOURCE_ID, CCTV_COUNT_CARD_SOURCE_ID];
|
||||
|
||||
/**
|
||||
* Returns the camera record for the currently active camera. A stale ID falls
|
||||
@@ -29,6 +34,44 @@ export function createSelection({
|
||||
return fallback;
|
||||
}
|
||||
|
||||
/** Whether another layer's scene object owns the click at this count. */
|
||||
function sceneTakesCountClick(event) {
|
||||
const top = event.topHit;
|
||||
if (!top) return false;
|
||||
const drawHit = event.drawHit;
|
||||
if (drawHit) return !parts.rendering.extractPickedCameraId(drawHit);
|
||||
const id = resolvePickId(top);
|
||||
return id !== null && findPickOwner?.(id) !== 'cctv';
|
||||
}
|
||||
|
||||
/** Leave other layers' cards to the caller since clickCard also calls this. */
|
||||
function clickedCount(event) {
|
||||
if (
|
||||
!isTrackingClickGesture(event.gesture) ||
|
||||
!layerState._enabled ||
|
||||
event.overlay
|
||||
)
|
||||
return null;
|
||||
const cell = layerState._counts?.pickedCell(event.screenPosition);
|
||||
if (!cell) return null;
|
||||
const { x, y } = event.screenPosition;
|
||||
if (
|
||||
layerState._cctvOverlayHost?.hitTest(x, y, {
|
||||
sourceId: CCTV_OVERLAY_SOURCE_ID,
|
||||
})?.entryId
|
||||
)
|
||||
return null;
|
||||
return sceneTakesCountClick(event) ? null : cell;
|
||||
}
|
||||
|
||||
/** The count marker as the card on top of a click it takes, for every layer's clickCard. */
|
||||
function countClickCard(event) {
|
||||
const cell = clickedCount(event);
|
||||
return cell
|
||||
? { sourceId: CCTV_COUNT_CARD_SOURCE_ID, entryId: String(cell.key ?? '') }
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind CCTV activation to clean taps. Drag-like and long-press gestures do
|
||||
* not reach camera activation or focus dispatch.
|
||||
@@ -41,6 +84,12 @@ export function createSelection({
|
||||
function bindCctvWorldClickGesture(input, onClick) {
|
||||
return input.onClick((event) => {
|
||||
if (!isTrackingClickGesture(event.gesture)) return;
|
||||
const cell = clickedCount(event);
|
||||
// Another layer's card or label painted above the count takes the click.
|
||||
if (cell && !isUnderOtherCard?.(event, OWN_CARD_SOURCES)) {
|
||||
parts.navigation.zoomToCell(cell);
|
||||
return;
|
||||
}
|
||||
onClick(event);
|
||||
});
|
||||
}
|
||||
@@ -139,11 +188,11 @@ export function createSelection({
|
||||
// is looking at ever asks.
|
||||
void parts.ground.resolveFootprintGround(record);
|
||||
record.activationDone = true;
|
||||
parts.rendering.refreshCoverageStyles();
|
||||
// The active camera's icon always shows; the previously active one
|
||||
// competes for its cell again. Its coverage neighbours join the working
|
||||
// set and are queued for grounding.
|
||||
// The active icon always shows and the previous one rejoins its cell.
|
||||
// Restyle coverage after the view pass sets grouping. Its coverage
|
||||
// neighbours join the working set and are queued for grounding.
|
||||
parts.rendering.refreshHorizonCulling();
|
||||
parts.rendering.refreshCoverageStyles();
|
||||
parts.geometryQueue.enqueueViewGeometry();
|
||||
// The newly active camera leaves the ambient ring (its monitor plane takes
|
||||
// over); the freed slot re-fills on this same pass.
|
||||
@@ -218,6 +267,7 @@ export function createSelection({
|
||||
return {
|
||||
getActiveRecord,
|
||||
bindCctvWorldClickGesture,
|
||||
countClickCard,
|
||||
setActiveCamera,
|
||||
deactivateActiveCamera,
|
||||
cctvEmptyClickDeselects,
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import * as picking from '../../data/pickRegistry.js';
|
||||
import { CCTV_COUNT_CARD_SOURCE_ID } from '../../data/cctvCards.js';
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { CCTV_ACTIVATION_RESULT } from '../../cctvFocusRequest.js';
|
||||
import { bindRenderer } from '../../render/rendererOf.js';
|
||||
import { createNavigation } from './navigation.js';
|
||||
import { createSelection } from './selection.js';
|
||||
|
||||
function makeSelection(sourceKind) {
|
||||
@@ -52,3 +56,158 @@ test('same-camera selection notifies browser-overlay feeds so playback can retry
|
||||
assert.equal(fixture.state._activeCameraReselection, 1);
|
||||
assert.equal(fixture.notifications(), 1);
|
||||
});
|
||||
|
||||
test('a count click preserves the provisional opening pick until the view settles', () => {
|
||||
const viewer = {};
|
||||
const flights = [];
|
||||
const unbind = bindRenderer(viewer, {
|
||||
camera: {
|
||||
pose: () => ({ fovy: Math.PI / 3, aspectRatio: 1 }),
|
||||
flyToBounds: (bounds) => flights.push(bounds),
|
||||
},
|
||||
canvas: { height: 600 },
|
||||
});
|
||||
try {
|
||||
const cell = { west: 1, east: 2, south: 0, north: 0, low: 0, high: 0 };
|
||||
const state = {
|
||||
_enabled: true,
|
||||
_viewer: viewer,
|
||||
_openingCameraProvisional: true,
|
||||
_activeCameraId: 'opening',
|
||||
_counts: {
|
||||
pickedCell: (point) => (point?.x === 14 && point.y === 26 ? cell : null),
|
||||
},
|
||||
};
|
||||
const parts = {};
|
||||
parts.navigation = createNavigation({ state, parts });
|
||||
const selection = createSelection({
|
||||
state,
|
||||
parts,
|
||||
services: { activation: {}, picking: {} },
|
||||
});
|
||||
const click = selection.bindCctvWorldClickGesture(
|
||||
{ onClick: (fn) => fn },
|
||||
() => {
|
||||
assert.fail('a count click reached activation or deselection');
|
||||
},
|
||||
);
|
||||
click({
|
||||
screenPosition: { x: 14, y: 26 },
|
||||
get drawHit() {
|
||||
assert.fail('the camera underneath was picked');
|
||||
},
|
||||
gesture: { travelPx: 0, durationMs: 20 },
|
||||
});
|
||||
assert.equal(flights.length, 1);
|
||||
assert.equal(state._activeCameraId, 'opening');
|
||||
assert.equal(state._openingCameraProvisional, true);
|
||||
} finally {
|
||||
unbind();
|
||||
}
|
||||
});
|
||||
|
||||
test("a count click yields to a card above it and to another layer's object, not to a CCTV icon", () => {
|
||||
let zooms = 0,
|
||||
clicks = 0;
|
||||
const selection = createSelection({
|
||||
services: { activation: {}, picking },
|
||||
state: {
|
||||
_enabled: true,
|
||||
_counts: { pickedCell: () => ({}) },
|
||||
_cctvOverlayHost: {
|
||||
hitTest: (x) => (x === 14 ? { entryId: 'cam-1' } : null),
|
||||
},
|
||||
},
|
||||
parts: {
|
||||
navigation: { zoomToCell: () => zooms++ },
|
||||
rendering: {
|
||||
extractPickedCameraId: (hit) =>
|
||||
hit?.set === 'cctv-icons' ? hit.id : null,
|
||||
},
|
||||
},
|
||||
});
|
||||
const click = selection.bindCctvWorldClickGesture(
|
||||
{ onClick: (fn) => fn },
|
||||
() => clicks++,
|
||||
);
|
||||
picking.registerPickOwner('cctv', (id) => id.startsWith('cam-'));
|
||||
try {
|
||||
for (const [x, topHit, expected] of [
|
||||
[14, null, [0, 1]],
|
||||
[20, { set: 'flights', id: 'abc' }, [0, 2]],
|
||||
[20, { set: 'cctv-icons', id: 'cam-2' }, [1, 2]],
|
||||
[20, null, [2, 2]],
|
||||
[20, { set: 'flights', id: 'cam-2' }, [2, 3]],
|
||||
]) {
|
||||
click({
|
||||
screenPosition: { x, y: 26 },
|
||||
topHit,
|
||||
drawHit: topHit,
|
||||
gesture: { travelPx: 0, durationMs: 20 },
|
||||
});
|
||||
assert.deepEqual([zooms, clicks], expected);
|
||||
}
|
||||
} finally {
|
||||
picking.unregisterPickOwner('cctv');
|
||||
}
|
||||
});
|
||||
|
||||
test('a count click is the card on top for every layer, unless the count yields', () => {
|
||||
let zooms = 0;
|
||||
let clicks = 0;
|
||||
const selection = createSelection({
|
||||
services: { activation: {}, picking },
|
||||
state: {
|
||||
_enabled: true,
|
||||
_counts: { pickedCell: (p) => (p?.x === 20 ? { key: 'g' } : null) },
|
||||
_cctvOverlayHost: { hitTest: () => null },
|
||||
},
|
||||
parts: {
|
||||
navigation: { zoomToCell: () => zooms++ },
|
||||
rendering: {
|
||||
extractPickedCameraId: (hit) =>
|
||||
hit?.set === 'cctv-icons' ? hit.id : null,
|
||||
},
|
||||
},
|
||||
});
|
||||
const click = selection.bindCctvWorldClickGesture(
|
||||
{ onClick: (fn) => fn },
|
||||
() => clicks++,
|
||||
);
|
||||
const event = (topHit = null, x = 20, durationMs = 20) => ({
|
||||
screenPosition: { x, y: 26 },
|
||||
topHit,
|
||||
drawHit: topHit,
|
||||
gesture: { travelPx: 0, durationMs },
|
||||
});
|
||||
picking.registerClickClaim('cctv', selection.countClickCard);
|
||||
try {
|
||||
const aircraftFirst = event();
|
||||
assert.equal(picking.isUnderOtherCard(aircraftFirst), true);
|
||||
assert.deepEqual(picking.clickCard(aircraftFirst), {
|
||||
sourceId: CCTV_COUNT_CARD_SOURCE_ID,
|
||||
entryId: 'g',
|
||||
});
|
||||
click(aircraftFirst);
|
||||
assert.deepEqual([zooms, clicks], [1, 0]);
|
||||
|
||||
const cctvFirst = event();
|
||||
click(cctvFirst);
|
||||
assert.equal(picking.isUnderOtherCard(cctvFirst), true);
|
||||
assert.deepEqual([zooms, clicks], [2, 0]);
|
||||
|
||||
for (const [e, claimed, expected] of [
|
||||
[event({ set: 'flights', id: 'abc' }), false, [2, 1]],
|
||||
[event({ set: 'cctv-icons', id: 'cam-2' }), true, [3, 1]],
|
||||
[event(null, 20, 1000), false, [3, 1]],
|
||||
[event(null, 60), false, [3, 2]],
|
||||
[{ ...event(), overlay: true }, false, [3, 3]],
|
||||
]) {
|
||||
assert.equal(picking.isUnderOtherCard(e), claimed);
|
||||
click(e);
|
||||
assert.deepEqual([zooms, clicks], expected);
|
||||
}
|
||||
} finally {
|
||||
picking.unregisterClickClaim('cctv');
|
||||
}
|
||||
});
|
||||
@@ -15,6 +15,7 @@ export function createState({ services }) {
|
||||
|
||||
/** The catalog's camera icons: the icon book over their draw set. */
|
||||
layerState._icons = null;
|
||||
layerState._counts = null;
|
||||
|
||||
layerState._records = [];
|
||||
|
||||
@@ -95,10 +96,14 @@ export function createState({ services }) {
|
||||
// work over these, not the whole catalog.
|
||||
|
||||
layerState._viewRecords = [];
|
||||
// The view records plus the best-ranked camera of each visible cell.
|
||||
layerState._pickerRecords = [];
|
||||
|
||||
// Coverage ids refreshCoverageStyles last drew: part of the geometry
|
||||
// working set even when their icons are thinned out.
|
||||
|
||||
// The active camera's coverage neighbours, including grouped ones. A
|
||||
// grouping change in this cohort requires a coverage refresh.
|
||||
layerState._coverageCohort = null;
|
||||
// The cohort minus grouped cameras, last drawn by refreshCoverageStyles.
|
||||
// These belong to the geometry working set even off screen.
|
||||
layerState._coverageVisibleIds = new Set();
|
||||
|
||||
// View pass triggers besides camera settle: an interval while the camera
|
||||
@@ -113,6 +118,9 @@ export function createState({ services }) {
|
||||
// The camera port the moveStart/moveEnd listeners are on.
|
||||
|
||||
layerState._viewListenerCamera = null;
|
||||
// Reruns the view pass when terrain loads or the surface changes.
|
||||
layerState._surfaceListener = null;
|
||||
layerState._surfaceListenerGlobe = null;
|
||||
|
||||
// A motion pass changed the shown set and the settle pass has not yet told
|
||||
// subscribers; the camera pose the last view pass ran at.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { createCountMarkers } from './countMarkers.js';
|
||||
import { createIconBook } from '../../render/motion/iconBook.js';
|
||||
|
||||
/** A draw set that draws nothing, for the icon book the tests read. */
|
||||
@@ -90,6 +91,7 @@ export function createTesting({ state: layerState, services, parts, source }) {
|
||||
* @param {'off'|'on'|'viewshed'} [options.coverageMode='on'] Coverage mode.
|
||||
* @param {boolean} [options.showProjection=false] Projection visibility.
|
||||
* @param {Map<string, Object>} [options.healthById] Health rows by camera id.
|
||||
* @param {Function} [options.registerPaintLane] Receives the count painter.
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
@@ -102,6 +104,7 @@ export function createTesting({ state: layerState, services, parts, source }) {
|
||||
showProjection = false,
|
||||
healthById = new Map(),
|
||||
openingCameraProvisional = false,
|
||||
registerPaintLane,
|
||||
} = {}) {
|
||||
layerState._viewer = viewer;
|
||||
layerState._records = Array.isArray(records) ? records : [];
|
||||
@@ -123,12 +126,20 @@ export function createTesting({ state: layerState, services, parts, source }) {
|
||||
layerState._showProjection = !!showProjection;
|
||||
layerState._healthById = healthById;
|
||||
layerState._viewRecords = [];
|
||||
layerState._pickerRecords = [];
|
||||
layerState._cameraIndexCache = null;
|
||||
layerState._coverageVisibleIds = new Set();
|
||||
layerState._neighborCountCache = null;
|
||||
layerState._coverageCohort = null;
|
||||
// A real book (over a set that draws nothing): every record gets its
|
||||
// icon as init adds it.
|
||||
layerState._icons = createIconBook(testIconSet());
|
||||
layerState._counts?.dispose();
|
||||
layerState._counts = createCountMarkers(
|
||||
registerPaintLane,
|
||||
'cctv:test:counts',
|
||||
parts.rendering.refreshHorizonCulling,
|
||||
);
|
||||
for (const record of layerState._records)
|
||||
if (record?.camera?.id) parts.rendering.addCameraIcon(record);
|
||||
}
|
||||
@@ -148,6 +159,7 @@ export function createTesting({ state: layerState, services, parts, source }) {
|
||||
for (const runtime of layerState._projectionEntities)
|
||||
if (runtime?.plane) planes[runtime.plane.id] = runtime.plane;
|
||||
return {
|
||||
counts: layerState._counts,
|
||||
gizmo: layerState._gizmo?.partsForTest() ?? {},
|
||||
coverage,
|
||||
planes,
|
||||
|
||||
@@ -110,7 +110,7 @@ function harness({ hidden = false, selected = true, noChips = false } = {}) {
|
||||
window.performance = { now: () => now };
|
||||
document.defaultView = window;
|
||||
const methods = new Function('createHoverDisclosure', 'collapsePanelOnEscape', 'document', 'window', 'clearTimeout', 'performance', 'requestAnimationFrame', 't', 'msg', 'readPanelState',
|
||||
`return ({${shellMethod('_initAutoHoverPanel').toString()},\n${shellMethod('_collapsePanelOnEscape').toString()},\n${shellMethod('_railFocusStand').toString()},\n${shellMethod('setPanelCollapsed').toString()},\n${shellMethod('_presentPanel').toString()},\n${shellMethod('_shownPanel').toString()}});`)(
|
||||
`return ({${shellMethod('_initAutoHoverPanel').toString()},\n${shellMethod('_collapsePanelOnEscape').toString()},\n${shellMethod('setPanelCollapsed').toString()},\n${shellMethod('_presentPanel').toString()},\n${shellMethod('_shownPanel').toString()}});`)(
|
||||
createHoverDisclosure, collapsePanelOnEscape, document, window, (id) => timers.delete(id), { now: () => now }, () => {}, t, msg, readPanelState,
|
||||
);
|
||||
const saves = [];
|
||||
|
||||
@@ -244,6 +244,9 @@ const _customPaintFrame = {
|
||||
cameraHeight: Number.NaN,
|
||||
occluder: null,
|
||||
keyhole: null,
|
||||
// Anchored custom glyphs yield to the same below-host chrome as entries.
|
||||
overlapsHardUi: (rect) =>
|
||||
overlayRectIntersectsAnyHard(rect, _uiOcclusionRects),
|
||||
uiRects: _uiOcclusionRects,
|
||||
uiRectCount: 0,
|
||||
layoutRevision: 0,
|
||||
|
||||
@@ -1514,9 +1514,14 @@ test('a placement is only ever kept under chrome that composites ABOVE the host'
|
||||
const paintedUnder = (occluders) => {
|
||||
const env = installMockEnvironment({ width: 400, height: 300, dpr: 1, occluders });
|
||||
initWorldOverlay(env.viewer);
|
||||
let hardUi;
|
||||
registerWorldOverlayPaintLane('ambient-label', (frame) => {
|
||||
hardUi = frame.overlapsHardUi({ x: 180, y: 130, w: 40, h: 40 });
|
||||
}, { id: 'anchored-label', active: true });
|
||||
setOverlayEntries('ambient', [selectedEntry('CONTACT')]);
|
||||
env.postRender.raise();
|
||||
const { paintedCount } = getWorldOverlayDiagnostics();
|
||||
assert.equal(hardUi, paintedCount === 0);
|
||||
env.cleanup();
|
||||
return paintedCount;
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ function panelFixture({ id = 'data-panel', nested = false, nestedCollapsed = fal
|
||||
disclosure.closest = () => panel;
|
||||
}
|
||||
const document = { getElementById: (candidate) => candidate === id ? panel : null };
|
||||
const manager = new Function('document', 'getComputedStyle', 'collapsePanelOnEscape', `return {${method('_collapsePanelOnEscape', '_togglePanel')}, ${method('_railFocusStand', '_setCommandDockPanelPinState')}};`)(document, (el) => ({ visibility: el.visibility ?? 'visible' }), collapsePanelOnEscape);
|
||||
const manager = new Function('document', 'getComputedStyle', 'collapsePanelOnEscape', `return {${method('_collapsePanelOnEscape', '_togglePanel')}};`)(document, (el) => ({ visibility: el.visibility ?? 'visible' }), collapsePanelOnEscape);
|
||||
manager.setPanelCollapsed = (candidate, value, options) => {
|
||||
assert.equal(candidate, id);
|
||||
assert.equal(value, true);
|
||||
|
||||
@@ -637,7 +637,6 @@ export class StyleManager extends ShellFacade {
|
||||
_toggleOrbit: (...args) => this._toggleOrbit(...args),
|
||||
toggleCleanView: (...args) => this.toggleCleanView(...args),
|
||||
_toggleCctvEnabled: (...args) => this._toggleCctvEnabled(...args),
|
||||
_togglePanel: (panelId) => this._panelChrome._togglePanel(panelId),
|
||||
_setBloomEnabled: (...args) => this._setBloomEnabled(...args),
|
||||
_setBloomIntensity: (...args) => this._setBloomIntensity(...args),
|
||||
_setSharpenEnabled: (...args) => this._setSharpenEnabled(...args),
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import {
|
||||
LINK_SCHEMES,
|
||||
LOGO_SCHEMES,
|
||||
safeUrl,
|
||||
splitLink,
|
||||
} from '../../render/creditMarkup.js';
|
||||
|
||||
// One credit: its logo or its text, linked when it has a link. A credit is
|
||||
// plain data (`src/render/contract/credits.d.ts`): its text is set as text,
|
||||
// and a link or logo is kept only for a safe scheme.
|
||||
const props = defineProps({
|
||||
credit: { type: Object, required: true },
|
||||
});
|
||||
|
||||
const href = computed(() =>
|
||||
props.credit.href ? safeUrl(props.credit.href, LINK_SCHEMES) : null,
|
||||
);
|
||||
// A logo is drawn in place of the text, which names it (its alt text).
|
||||
const logo = computed(() =>
|
||||
props.credit.logoUrl ? safeUrl(props.credit.logoUrl, LOGO_SCHEMES) : null,
|
||||
);
|
||||
// Only the credit's linked words are the link, as the source wrote it.
|
||||
const parts = computed(() =>
|
||||
href.value && !logo.value && props.credit.linkText
|
||||
? splitLink(props.credit)
|
||||
: null,
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span v-if="parts" class="gev-credit"
|
||||
>{{ parts[0]
|
||||
}}<a :href="href" target="_blank" rel="noopener noreferrer">{{
|
||||
parts[1]
|
||||
}}</a
|
||||
>{{ parts[2] }}</span
|
||||
><component
|
||||
:is="href ? 'a' : 'span'"
|
||||
v-else
|
||||
class="gev-credit"
|
||||
:href="href || undefined"
|
||||
:target="href ? '_blank' : undefined"
|
||||
:rel="href ? 'noopener noreferrer' : undefined"
|
||||
><img
|
||||
v-if="logo"
|
||||
class="gev-credit-logo"
|
||||
:src="logo"
|
||||
:alt="credit.text"
|
||||
/><template v-else>{{ credit.text }}</template></component
|
||||
>
|
||||
</template>
|
||||
@@ -1,82 +0,0 @@
|
||||
<script setup>
|
||||
import { t } from '../../i18n/index.js';
|
||||
import UiCloseButton from '../kit/UiCloseButton.vue';
|
||||
import CreditItem from './CreditItem.vue';
|
||||
|
||||
// The attribution line at the bottom left and the "Data attribution" list it
|
||||
// opens, both at the end of `to` (the page's body), where the page's rules
|
||||
// place them. The owner (src/ui/creditsView.js) computes the credits shown,
|
||||
// keeps the list's open state and its focus, and takes the clicks and keys;
|
||||
// `elements` receives the line's, the button's and the list's elements for
|
||||
// it.
|
||||
const props = defineProps({
|
||||
to: { type: Object, required: true },
|
||||
panelId: { type: String, required: true },
|
||||
/** The credits on the line, once each. */
|
||||
inline: { type: Array, required: true },
|
||||
/** The credits in the list, once each. */
|
||||
listed: { type: Array, required: true },
|
||||
open: { type: Boolean, default: false },
|
||||
/**
|
||||
* The locale its words are in: a change words them again. The template
|
||||
* never reads it; `t()` is not reactive, so a new value is what makes the
|
||||
* view render again in the new language.
|
||||
*/
|
||||
locale: { type: String, default: '' },
|
||||
elements: { type: Object, required: true },
|
||||
onExpand: { type: Function, default: () => {} },
|
||||
onClose: { type: Function, default: () => {} },
|
||||
onKeydown: { type: Function, default: () => {} },
|
||||
});
|
||||
|
||||
/** Between the line's credits, and before the list's button. */
|
||||
const SEPARATOR = ' · ';
|
||||
/** A credit's key: the same text and link are one credit. */
|
||||
const key = (credit) => `${credit.text}\u0000${credit.href ?? ''}`;
|
||||
/** Keep `name`'s element for the owner. */
|
||||
const keep = (name) => (element) => {
|
||||
props.elements[name] = element?.$el ?? element;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport :to="props.to"
|
||||
><div id="gev-credits" :ref="keep('bar')" class="gev-credits" tabindex="-1"
|
||||
><span :ref="keep('line')" class="gev-credits-line"
|
||||
><template v-for="(credit, i) in props.inline" :key="key(credit)"
|
||||
>{{ i ? SEPARATOR : '' }}<CreditItem :credit="credit" /></template
|
||||
>{{ props.inline.length && props.listed.length ? SEPARATOR : '' }}</span
|
||||
><button
|
||||
:ref="keep('expand')"
|
||||
type="button"
|
||||
class="gev-credits-expand"
|
||||
aria-haspopup="dialog"
|
||||
:aria-controls="props.panelId"
|
||||
:aria-expanded="String(props.open)"
|
||||
:hidden="props.listed.length === 0"
|
||||
@click="props.onExpand()"
|
||||
>{{ t('Data attribution') }}</button
|
||||
></div
|
||||
><div
|
||||
:id="props.panelId"
|
||||
:ref="keep('panel')"
|
||||
class="gev-credits-panel"
|
||||
role="dialog"
|
||||
:aria-labelledby="`${props.panelId}-title`"
|
||||
:hidden="!props.open"
|
||||
@keydown="props.onKeydown($event)"
|
||||
><div class="gev-credits-header"
|
||||
><span class="gev-credits-title" :id="`${props.panelId}-title`">{{
|
||||
t('Data provided by:')
|
||||
}}</span
|
||||
><UiCloseButton
|
||||
:ref="keep('close')"
|
||||
class="gev-credits-close"
|
||||
bare
|
||||
:label="t('Close data attribution')"
|
||||
@click="props.onClose()" /></div
|
||||
><ul class="gev-credits-list"
|
||||
><li v-for="credit in props.listed" :key="key(credit)"
|
||||
><CreditItem :credit="credit" /></li></ul></div
|
||||
></Teleport>
|
||||
</template>
|
||||
+122
-55
@@ -6,14 +6,16 @@
|
||||
* credits). Inline credits are shown on the line at the bottom left; the
|
||||
* rest are in the "Data attribution" list it opens. A credit is plain data
|
||||
* (`src/render/contract/credits.d.ts`): its text is set as text, and a link
|
||||
* or logo is kept only for a safe scheme. `CreditsView` renders the line and
|
||||
* the list; this owner keeps the credits shown, the list's open state and
|
||||
* its focus.
|
||||
* or logo is kept only for a safe scheme.
|
||||
*/
|
||||
import { h, render as renderVue } from 'vue';
|
||||
import { findCredits } from '../render/rendererOf.js';
|
||||
import { getLocale, onLocaleChange } from '../i18n/index.js';
|
||||
import CreditsView from './credits/CreditsView.vue';
|
||||
import {
|
||||
LINK_SCHEMES,
|
||||
LOGO_SCHEMES,
|
||||
safeUrl,
|
||||
splitLink,
|
||||
} from '../render/creditMarkup.js';
|
||||
import { onLocaleChange, t } from '../i18n/index.js';
|
||||
|
||||
const PANEL_ID = 'gev-credits-panel';
|
||||
|
||||
@@ -28,6 +30,42 @@ function distinct(list) {
|
||||
});
|
||||
}
|
||||
|
||||
/** One credit as DOM: its logo or its text, linked when it has a link. */
|
||||
function creditElement(doc, credit) {
|
||||
const href = credit.href ? safeUrl(credit.href, LINK_SCHEMES) : null;
|
||||
const logoUrl = credit.logoUrl ? safeUrl(credit.logoUrl, LOGO_SCHEMES) : null;
|
||||
// Only the credit's linked words are the link, as the source wrote it.
|
||||
if (href && !logoUrl && credit.linkText) {
|
||||
const [before, words, after] = splitLink(credit);
|
||||
const element = doc.createElement('span');
|
||||
element.className = 'gev-credit';
|
||||
const link = doc.createElement('a');
|
||||
link.href = href;
|
||||
link.target = '_blank';
|
||||
link.rel = 'noopener noreferrer';
|
||||
link.textContent = words;
|
||||
element.append(before, link, after);
|
||||
return element;
|
||||
}
|
||||
const element = doc.createElement(href ? 'a' : 'span');
|
||||
element.className = 'gev-credit';
|
||||
if (href) {
|
||||
element.href = href;
|
||||
element.target = '_blank';
|
||||
element.rel = 'noopener noreferrer';
|
||||
}
|
||||
// A logo is drawn in place of the text, which names it (its alt text).
|
||||
const logo = credit.logoUrl ? safeUrl(credit.logoUrl, LOGO_SCHEMES) : null;
|
||||
if (logo) {
|
||||
const image = doc.createElement('img');
|
||||
image.className = 'gev-credit-logo';
|
||||
image.src = logo;
|
||||
image.alt = credit.text;
|
||||
element.append(image);
|
||||
} else element.textContent = credit.text;
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show `viewer`'s renderer credits at the bottom left of `root`'s page.
|
||||
* @param {object} viewer The scene object, bound to its renderer.
|
||||
@@ -38,77 +76,106 @@ export function mountCreditsView(viewer, { root = document.body } = {}) {
|
||||
const credits = findCredits(viewer);
|
||||
if (!credits || !root) return () => {};
|
||||
const doc = root.ownerDocument;
|
||||
// The view teleports the line and the list to the end of `root`; this
|
||||
// host, never in the page, holds only its place.
|
||||
const host = doc.createElement('div');
|
||||
const elements = {};
|
||||
let inline = [];
|
||||
let listed = [];
|
||||
let open = false;
|
||||
const bar = doc.createElement('div');
|
||||
bar.id = 'gev-credits';
|
||||
bar.className = 'gev-credits';
|
||||
// Takes focus back from an emptied list when the line has no link.
|
||||
bar.tabIndex = -1;
|
||||
const line = doc.createElement('span');
|
||||
line.className = 'gev-credits-line';
|
||||
const expand = doc.createElement('button');
|
||||
expand.type = 'button';
|
||||
expand.className = 'gev-credits-expand';
|
||||
expand.setAttribute('aria-haspopup', 'dialog');
|
||||
expand.setAttribute('aria-controls', PANEL_ID);
|
||||
expand.setAttribute('aria-expanded', 'false');
|
||||
|
||||
// The view patches synchronously, so focus can move once it returns.
|
||||
const paint = () =>
|
||||
renderVue(
|
||||
h(CreditsView, {
|
||||
to: root,
|
||||
panelId: PANEL_ID,
|
||||
inline,
|
||||
listed,
|
||||
open,
|
||||
locale: getLocale(),
|
||||
elements,
|
||||
onExpand,
|
||||
onClose,
|
||||
onKeydown,
|
||||
}),
|
||||
host,
|
||||
);
|
||||
const panel = doc.createElement('div');
|
||||
panel.id = PANEL_ID;
|
||||
panel.className = 'gev-credits-panel';
|
||||
panel.setAttribute('role', 'dialog');
|
||||
panel.hidden = true;
|
||||
const header = doc.createElement('div');
|
||||
header.className = 'gev-credits-header';
|
||||
const title = doc.createElement('span');
|
||||
title.className = 'gev-credits-title';
|
||||
title.id = `${PANEL_ID}-title`;
|
||||
panel.setAttribute('aria-labelledby', title.id);
|
||||
const close = doc.createElement('button');
|
||||
close.type = 'button';
|
||||
close.className = 'gev-credits-close';
|
||||
close.textContent = '×';
|
||||
header.append(title, close);
|
||||
const list = doc.createElement('ul');
|
||||
list.className = 'gev-credits-list';
|
||||
panel.append(header, list);
|
||||
bar.append(line, expand);
|
||||
root.append(bar, panel);
|
||||
|
||||
const setOpen = (next, { focus = false } = {}) => {
|
||||
open = next;
|
||||
paint();
|
||||
if (open) elements.close.focus();
|
||||
else if (focus) elements.expand.focus();
|
||||
const label = () => {
|
||||
expand.textContent = t('Data attribution');
|
||||
title.textContent = t('Data provided by:');
|
||||
close.setAttribute('aria-label', t('Close data attribution'));
|
||||
};
|
||||
|
||||
const setOpen = (open, { focus = false } = {}) => {
|
||||
panel.hidden = !open;
|
||||
expand.setAttribute('aria-expanded', String(open));
|
||||
if (open) close.focus();
|
||||
else if (focus) expand.focus();
|
||||
};
|
||||
|
||||
const render = (all) => {
|
||||
const { bar, line, panel } = elements;
|
||||
const focused = panel.contains(doc.activeElement);
|
||||
const shown = distinct(Array.isArray(all) ? all : []);
|
||||
inline = shown.filter((credit) => credit.inline);
|
||||
listed = shown.filter((credit) => !credit.inline);
|
||||
paint();
|
||||
if (listed.length === 0 && open) {
|
||||
const inline = shown.filter((credit) => credit.inline);
|
||||
const listed = shown.filter((credit) => !credit.inline);
|
||||
line.replaceChildren();
|
||||
inline.forEach((credit, i) => {
|
||||
if (i) line.append(doc.createTextNode(' · '));
|
||||
line.append(creditElement(doc, credit));
|
||||
});
|
||||
if (inline.length && listed.length) line.append(doc.createTextNode(' · '));
|
||||
list.replaceChildren(
|
||||
...listed.map((credit) => {
|
||||
const item = doc.createElement('li');
|
||||
item.append(creditElement(doc, credit));
|
||||
return item;
|
||||
}),
|
||||
);
|
||||
expand.hidden = listed.length === 0;
|
||||
if (expand.hidden && !panel.hidden) {
|
||||
// Focus in the list goes back to the line, not to the page.
|
||||
setOpen(false);
|
||||
if (focused) (line.querySelector('a') ?? bar).focus();
|
||||
} else if (focused && !panel.contains(doc.activeElement)) {
|
||||
// A link that focus was on was redrawn: focus stays in the list.
|
||||
elements.close.focus();
|
||||
close.focus();
|
||||
}
|
||||
};
|
||||
|
||||
function onExpand() {
|
||||
setOpen(!open);
|
||||
}
|
||||
function onClose() {
|
||||
setOpen(false, { focus: true });
|
||||
}
|
||||
const onExpand = () => setOpen(panel.hidden);
|
||||
const onClose = () => setOpen(false, { focus: true });
|
||||
// Escape in the open list closes it (it takes focus as it opens).
|
||||
function onKeydown(event) {
|
||||
if (event.key !== 'Escape' || !open) return;
|
||||
const onKey = (event) => {
|
||||
if (event.key !== 'Escape' || panel.hidden) return;
|
||||
event.preventDefault();
|
||||
setOpen(false, { focus: true });
|
||||
}
|
||||
|
||||
paint();
|
||||
};
|
||||
expand.addEventListener('click', onExpand);
|
||||
close.addEventListener('click', onClose);
|
||||
panel.addEventListener('keydown', onKey);
|
||||
label();
|
||||
render(credits.list());
|
||||
const offChange = credits.on('change', render);
|
||||
// The view words its text again in the new locale, as it renders.
|
||||
const offLocale = onLocaleChange(paint);
|
||||
const offLocale = onLocaleChange(label);
|
||||
return () => {
|
||||
offChange();
|
||||
offLocale();
|
||||
renderVue(null, host);
|
||||
expand.removeEventListener('click', onExpand);
|
||||
close.removeEventListener('click', onClose);
|
||||
panel.removeEventListener('keydown', onKey);
|
||||
bar.remove();
|
||||
panel.remove();
|
||||
};
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import assert from 'node:assert/strict';
|
||||
import { mountCreditsView } from './creditsView.js';
|
||||
import { bindRenderer } from '../render/rendererOf.js';
|
||||
import { createStubRenderer } from '../render/stub/index.js';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
|
||||
function scene() {
|
||||
document.body.replaceChildren();
|
||||
@@ -119,12 +118,10 @@ test('focus in the list stays in it as it redraws, and goes to the line as it em
|
||||
const off = mountCreditsView(viewer);
|
||||
const panel = document.getElementById('gev-credits-panel');
|
||||
document.querySelector('.gev-credits-expand').click();
|
||||
const link = panel.querySelector('li a');
|
||||
link.focus();
|
||||
panel.querySelector('li a').focus();
|
||||
const removeOther = renderer.credits.addStatic({ text: 'NOAA' });
|
||||
assert.equal(panel.hidden, false);
|
||||
assert.ok(panel.contains(document.activeElement), 'still in the list');
|
||||
assert.equal(document.activeElement, link, 'the focused link keeps it');
|
||||
remove();
|
||||
removeOther();
|
||||
assert.equal(panel.hidden, true);
|
||||
@@ -155,55 +152,3 @@ test('a credit with linked words links only those words', () => {
|
||||
);
|
||||
off();
|
||||
});
|
||||
|
||||
test('the line and its list follow the locale', () => {
|
||||
const { viewer, renderer } = scene();
|
||||
renderer.credits.addStatic({ text: 'NOAA' });
|
||||
const off = mountCreditsView(viewer);
|
||||
const expand = document.querySelector('.gev-credits-expand');
|
||||
const close = document.querySelector('.gev-credits-close');
|
||||
try {
|
||||
setLocale('fr');
|
||||
assert.equal(expand.textContent, 'Attribution des données');
|
||||
assert.equal(
|
||||
document.getElementById('gev-credits-panel-title').textContent,
|
||||
'Données fournies par\u202f:',
|
||||
);
|
||||
assert.equal(
|
||||
close.getAttribute('aria-label'),
|
||||
"Fermer l'attribution des données",
|
||||
);
|
||||
} finally {
|
||||
setLocale('en');
|
||||
}
|
||||
assert.equal(expand.textContent, 'Data attribution');
|
||||
off();
|
||||
});
|
||||
|
||||
test('the line and its list are the last of the body, and its close button is the kit’s', () => {
|
||||
const { viewer, renderer } = scene();
|
||||
document.body.append(document.createElement('main'));
|
||||
renderer.credits.addStatic({ text: 'NOAA' });
|
||||
const off = mountCreditsView(viewer);
|
||||
const children = [...document.body.children];
|
||||
assert.deepEqual(
|
||||
children.slice(-2).map((element) => element.id),
|
||||
['gev-credits', 'gev-credits-panel'],
|
||||
'the page’s rules select them as children of the body',
|
||||
);
|
||||
const close = document.querySelector('.gev-credits-close');
|
||||
assert.ok(close.classList.contains('ui-button'), 'a UiCloseButton');
|
||||
assert.equal(close.type, 'button');
|
||||
assert.equal(close.textContent, '×');
|
||||
assert.equal(close.hasAttribute('title'), false, 'no tip');
|
||||
assert.equal(
|
||||
close.classList.contains('ui-close-button'),
|
||||
false,
|
||||
'bare: it keeps the browser’s padding',
|
||||
);
|
||||
off();
|
||||
assert.deepEqual(
|
||||
[...document.body.children].map((element) => element.tagName),
|
||||
['MAIN'],
|
||||
);
|
||||
});
|
||||
@@ -64,8 +64,8 @@ export class DisplayBindings {
|
||||
},
|
||||
toggleOrbit: () => this._toggleOrbit(),
|
||||
toggleCleanView: () => this.toggleCleanView(),
|
||||
// Same collapse as the panel's own button, so its rail entry stays.
|
||||
toggleLayers: () => this._togglePanel('data-panel'),
|
||||
toggleLayers: () =>
|
||||
document.getElementById('data-panel').classList.toggle('active'),
|
||||
cycleDetection: () => {
|
||||
this.shareLinkManager?.claimRestoreLane?.('visual');
|
||||
this.claimDetection();
|
||||
|
||||
@@ -72,11 +72,7 @@ function settings(store) {
|
||||
|
||||
test('before VisualSettings renders, the panel shows its initial markup', (t) => {
|
||||
const { $ } = fixture(t);
|
||||
// Beside the kit's ui-* classes, the toggle carries only its own.
|
||||
assert.deepEqual(
|
||||
[...$('bloom-toggle').classList].filter((name) => !name.startsWith('ui-')),
|
||||
['pp-toggle-btn'],
|
||||
);
|
||||
assert.equal($('bloom-toggle').className, 'pp-toggle-btn');
|
||||
assert.equal($('bloom-slider-row').className, 'pp-slider-row');
|
||||
assert.equal($('bloom-intensity-slider').value, '0');
|
||||
assert.equal($('bloom-intensity-value').textContent, '0%');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Every checkbox in a Vue view is a UiCheckbox: no SFC template hand-writes
|
||||
// `<input type="checkbox">`.
|
||||
// `<input type="checkbox">`. Story Explore's filters are not converted yet.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync, readdirSync } from 'node:fs';
|
||||
@@ -8,7 +8,10 @@ import { fileURLToPath } from 'node:url';
|
||||
|
||||
const SRC_ROOT = fileURLToPath(new URL('../../', import.meta.url));
|
||||
const REPO_ROOT = path.resolve(SRC_ROOT, '..');
|
||||
const NOT_YET = new Set(['src/ui/kit/UiCheckbox.vue']);
|
||||
const NOT_YET = new Set([
|
||||
'src/ui/kit/UiCheckbox.vue',
|
||||
'src/ui/views/stories/ExploreScreen.vue',
|
||||
]);
|
||||
|
||||
/** Every SFC under src. */
|
||||
function sfcFiles(directory = SRC_ROOT) {
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
// The entity card's buttons and Material glyphs are the kit's: neither its
|
||||
// template nor the camera preview and nearby lists it renders hand-writes a
|
||||
// <button> or a Material Symbols span. The Ask GEV button's chat bubble is
|
||||
// not a Material symbol the page loads, so it stays drawn as inline SVG; the
|
||||
// hero views (model, route globe, cockpit view, ground view, graphs) draw
|
||||
// their own pictures and have no controls.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
/** A view's template block: everything outside script and style. */
|
||||
function template(file) {
|
||||
const source = readFileSync(
|
||||
new URL(`../views/panels/${file}`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
return source.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '');
|
||||
}
|
||||
const card = template('EntityCard.vue');
|
||||
const camera = template('CctvPreview.vue');
|
||||
const nearby = template('SpotConditions.vue');
|
||||
const heroViews = [
|
||||
'AircraftModelHero.vue',
|
||||
'RouteGlobe.vue',
|
||||
'FlightCockpitView.vue',
|
||||
'SatelliteGroundView.vue',
|
||||
'PreviewHud.vue',
|
||||
'AltitudeGraph.vue',
|
||||
].map(template);
|
||||
|
||||
test('the entity card hand-writes no button; each is a UiButton', () => {
|
||||
for (const markup of [card, camera, nearby, ...heroViews])
|
||||
assert.deepEqual(markup.match(/<button\b/gi) ?? [], []);
|
||||
// Photos, Route, 3D, Cockpit view, the cockpit entry, Fly to, Follow and
|
||||
// Ask GEV.
|
||||
assert.equal(card.match(/<UiButton\b/g)?.length, 8);
|
||||
assert.equal(card.match(/<UiCloseButton\b/g)?.length, 1);
|
||||
// A camera's bigger view and More info; its popup closes with a UiCloseButton.
|
||||
assert.equal(camera.match(/<UiButton\b/g)?.length, 2);
|
||||
assert.equal(camera.match(/<UiCloseButton\b/g)?.length, 1);
|
||||
// The traffic, hazard, alert and other nearby rows.
|
||||
assert.equal(nearby.match(/<UiButton\b/g)?.length, 4);
|
||||
});
|
||||
|
||||
test('the preview switch and Follow are pressed toggles with their classes', () => {
|
||||
const previews = card.match(/<UiButton v-if="\w+" :pressed[^>]*>/g) ?? [];
|
||||
assert.equal(previews.length, 4);
|
||||
for (const button of previews) {
|
||||
assert.match(button, /pressed-class="active"/);
|
||||
assert.doesNotMatch(button, /aria-pressed|:class=/);
|
||||
}
|
||||
assert.match(
|
||||
card,
|
||||
/<UiButton v-if="store\.canFollow\(\)" class="entity-card__action" :pressed="Boolean\(store\.isFollowing\(\)\)" pressed-class="entity-card__action--on"/,
|
||||
);
|
||||
});
|
||||
|
||||
test('the entity card hand-writes no Material glyph; each is a UiIcon', () => {
|
||||
for (const markup of [card, camera, nearby, ...heroViews])
|
||||
assert.deepEqual(markup.match(/material-symbols-outlined/g) ?? [], []);
|
||||
const counts = [
|
||||
// The preview switch's three, the hero glyph, the header icon, the
|
||||
// warning, the route's plane, the route note and the three actions.
|
||||
[card, 11],
|
||||
// Bigger view, the popup's camera and More info.
|
||||
[camera, 3],
|
||||
// The two weather glyphs, five headings and three row glyphs.
|
||||
[nearby, 10],
|
||||
];
|
||||
for (const [markup, count] of counts) {
|
||||
const icons = markup.match(/<UiIcon\b[^>]*>/g) ?? [];
|
||||
assert.equal(icons.length, count);
|
||||
// Without it the kit writes an 18px size that beats the card's own rules.
|
||||
for (const icon of icons) assert.match(icon, /:size="null"/);
|
||||
}
|
||||
});
|
||||
|
||||
test('the only inline SVG glyph is the Ask GEV chat bubble', () => {
|
||||
const svgs = [...card.matchAll(/<svg\b[\s\S]*?<\/svg\s*>/g)].map((m) => m[0]);
|
||||
assert.equal(svgs.length, 1);
|
||||
assert.match(svgs[0], /<path d="M4 5h16v11H9l-5 4z" \/>/);
|
||||
for (const markup of [camera, nearby])
|
||||
assert.deepEqual(markup.match(/<svg\b/gi) ?? [], []);
|
||||
});
|
||||
@@ -1,50 +0,0 @@
|
||||
// The Layer Finder's buttons and Material glyphs are the kit's: its template
|
||||
// hand-writes no <button>, aria-pressed, Material Symbols span or inline SVG.
|
||||
// Its search field is a UiSearchField.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
/** A view's template block: everything outside script and style. */
|
||||
function template(file) {
|
||||
const source = readFileSync(
|
||||
new URL(`../views/panels/${file}`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
return source.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '');
|
||||
}
|
||||
const finder = template('LayerFinder.vue');
|
||||
|
||||
test('the Layer Finder hand-writes no button; each is a UiButton', () => {
|
||||
assert.deepEqual(finder.match(/<button\b/gi) ?? [], []);
|
||||
// Search, Filter, the Status and Category options, and the two chips.
|
||||
assert.equal(finder.match(/<UiButton\b/g)?.length, 6);
|
||||
assert.equal(finder.match(/<UiSearchField\b/g)?.length, 1);
|
||||
});
|
||||
|
||||
test('its pressed toggles leave aria-pressed to UiButton', () => {
|
||||
assert.deepEqual(finder.match(/aria-pressed/g) ?? [], []);
|
||||
const pressed = finder.match(/<UiButton\b[^>]*:pressed=[^>]*>/g) ?? [];
|
||||
// Search and the Status and Category options.
|
||||
assert.equal(pressed.length, 3);
|
||||
// Only the options' active class follows their pressed state; Search's
|
||||
// also stays on while a query is typed, so it keeps its own binding.
|
||||
assert.equal(
|
||||
pressed.filter((tag) => tag.includes('pressed-class="active"')).length,
|
||||
2,
|
||||
);
|
||||
assert.match(
|
||||
finder,
|
||||
/id="layer-finder-search-btn"[^>]*:class="\{ active: searching \|\| query \}"/,
|
||||
);
|
||||
});
|
||||
|
||||
test('the Layer Finder hand-writes no Material glyph; each is a UiIcon', () => {
|
||||
assert.deepEqual(finder.match(/material-symbols-outlined/g) ?? [], []);
|
||||
assert.deepEqual(finder.match(/<svg\b/gi) ?? [], []);
|
||||
const icons = finder.match(/<UiIcon\b[^>]*>/g) ?? [];
|
||||
// Search, Filter, the two option radios and the two chips' close.
|
||||
assert.equal(icons.length, 6);
|
||||
// Without it the kit writes an 18px size that beats layer-finder.css.
|
||||
for (const icon of icons) assert.match(icon, /:size="null"/);
|
||||
});
|
||||
@@ -1,37 +0,0 @@
|
||||
// The Omnibar's buttons and Material glyphs are the kit's: its template
|
||||
// hand-writes no <button> and no Material Symbols span. Its two inline SVG
|
||||
// glyphs (the mic and the chat row's bubble) are not Material symbols the
|
||||
// page loads, so they stay as they are drawn.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const source = readFileSync(
|
||||
new URL('../views/panels/Omnibar.vue', import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
/** The template block: everything outside script and style. */
|
||||
const template = source.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '');
|
||||
|
||||
test('the Omnibar hand-writes no button; each is a UiButton', () => {
|
||||
assert.deepEqual(template.match(/<button\b/gi) ?? [], []);
|
||||
assert.equal(template.match(/<UiButton\b/g)?.length, 2);
|
||||
});
|
||||
|
||||
test('the Omnibar hand-writes no Material glyph; each is a UiIcon', () => {
|
||||
assert.deepEqual(template.match(/material-symbols-outlined/g) ?? [], []);
|
||||
const icons = template.match(/<UiIcon\b[^>]*>/g) ?? [];
|
||||
assert.equal(icons.length, 3);
|
||||
// Without it the kit writes an 18px size that beats the Omnibar's own rules.
|
||||
for (const icon of icons) assert.match(icon, /:size="null"/);
|
||||
});
|
||||
|
||||
test('the only inline SVG glyphs are the mic and the chat row bubble', () => {
|
||||
const svgs = [...template.matchAll(/<svg\b[\s\S]*?<\/svg\s*>/g)].map(
|
||||
(m) => m[0],
|
||||
);
|
||||
assert.equal(svgs.length, 2);
|
||||
assert.match(svgs[0], /<rect x="9" y="3" width="6" height="11" rx="3" \/>/);
|
||||
assert.match(svgs[1], /class="omnibar-item-icon"/);
|
||||
assert.match(svgs[1], /<path d="M4 5h16v11H9l-5 4z" \/>/);
|
||||
});
|
||||
@@ -1,107 +0,0 @@
|
||||
// The Stories views' buttons and checkboxes are the kit's: neither the
|
||||
// Stories entry nor any Explore or Story screen hand-writes a <button> or an
|
||||
// `<input type="checkbox">`. Their glyphs are inline SVG drawn for Stories
|
||||
// (play, pause, back, filter, search, clear, expand, the GEV eye); no
|
||||
// Material symbol the page loads draws any of them the same, so they stay
|
||||
// SVG, and no view hand-writes a Material Symbols span. The two search
|
||||
// fields keep their own markup rather than UiSearchField, whose Material
|
||||
// magnifier would replace their SVG one, and their clear buttons stay ghost
|
||||
// UiButtons with an SVG cross rather than UiCloseButtons, whose glyph is ×
|
||||
// or the Material `close` symbol.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
/** A view's template block: everything outside script and style. */
|
||||
function template(file) {
|
||||
const source = readFileSync(
|
||||
new URL(`../views/${file}`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
return source.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '');
|
||||
}
|
||||
const views = {
|
||||
// The Stories entry, the popup's Browse stories and Not now, and the
|
||||
// toast's Back to story.
|
||||
'StoriesView.vue': { buttons: 4, svgs: 2 },
|
||||
// The list grip, Filter, the two search clears, the topic chips (All and
|
||||
// each topic), the filter's Clear and Show, Clear all, a card's thumbnail
|
||||
// play and Play story, the map pins and the preview's Play story.
|
||||
'stories/ExploreScreen.vue': { buttons: 13, svgs: 8 },
|
||||
// Back, the logo, the breadcrumb's link, search, Share and Back to GEV or
|
||||
// GEV Stories.
|
||||
'stories/StoriesHeader.vue': { buttons: 8, svgs: 5 },
|
||||
// The sheet handle, voice search, the search results, Close, the key
|
||||
// moments and the related stories.
|
||||
'stories/StoryContext.vue': { buttons: 6, svgs: 3 },
|
||||
// Open in GEV and Share.
|
||||
'stories/StoryRail.vue': { buttons: 2, svgs: 1 },
|
||||
// A chapter, Minimise, Expand, the card's page dots, the big Play and
|
||||
// Context.
|
||||
'stories/StoryScreen.vue': { buttons: 6, svgs: 5 },
|
||||
// Play, the key moment pips and Expand map.
|
||||
'stories/StoryTimeline.vue': { buttons: 3, svgs: 2 },
|
||||
};
|
||||
// A tag's attributes, read past quoted values so a handler's `=>` does not
|
||||
// end the tag early.
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const tag = (pattern, flags = '') =>
|
||||
new RegExp(pattern.replaceAll('ATTRS', ATTRS), flags);
|
||||
const markup = Object.fromEntries(
|
||||
Object.keys(views).map((file) => [file, template(file)]),
|
||||
);
|
||||
|
||||
test('the Stories views hand-write no button; each is a UiButton', () => {
|
||||
for (const [file, { buttons }] of Object.entries(views)) {
|
||||
assert.deepEqual(markup[file].match(/<button\b/gi) ?? [], [], file);
|
||||
assert.equal(markup[file].match(/<UiButton\b/g)?.length, buttons, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('the pressed toggles take the kit pressed state', () => {
|
||||
for (const view of Object.values(markup))
|
||||
assert.doesNotMatch(view, tag(String.raw`<UiButton\bATTRS\saria-pressed`));
|
||||
const explore = markup['stories/ExploreScreen.vue'];
|
||||
// All, each topic and the map pins; the cards are role="button" divs that
|
||||
// keep their own aria-pressed.
|
||||
assert.equal(
|
||||
explore.match(tag(String.raw`<UiButton\bATTRS\s:pressed=`, 'g'))?.length,
|
||||
3,
|
||||
);
|
||||
assert.match(
|
||||
explore,
|
||||
tag(String.raw`class="card"\s+role="button"ATTRS\s:aria-pressed=`),
|
||||
);
|
||||
assert.match(
|
||||
markup['stories/StoryScreen.vue'],
|
||||
tag(String.raw`<UiButton\s+id="btnCtx"ATTRS\s:pressed="ctxOpen"`),
|
||||
);
|
||||
assert.match(
|
||||
markup['stories/StoryTimeline.vue'],
|
||||
tag(String.raw`<UiButton\s+id="stExpand"ATTRS\s:pressed="expanded"`),
|
||||
);
|
||||
});
|
||||
|
||||
test("Explore's filter options are UiCheckboxes in their own label", () => {
|
||||
const explore = markup['stories/ExploreScreen.vue'];
|
||||
assert.deepEqual(
|
||||
explore.match(tag(String.raw`<input\bATTRS\stype="checkbox"`, 'g')) ?? [],
|
||||
[],
|
||||
);
|
||||
const boxes = explore.match(tag(String.raw`<UiCheckbox\bATTRS>`, 'g')) ?? [];
|
||||
assert.equal(boxes.length, 1);
|
||||
assert.match(boxes[0], /class="fopt"/);
|
||||
// Controlled, so the box always shows the applied filter.
|
||||
assert.match(boxes[0], /:model-value="Boolean\(/);
|
||||
});
|
||||
|
||||
test('the glyphs stay inline SVG; no view hand-writes a Material span', () => {
|
||||
for (const [file, { svgs }] of Object.entries(views)) {
|
||||
assert.deepEqual(
|
||||
markup[file].match(/material-symbols-outlined/g) ?? [],
|
||||
[],
|
||||
file,
|
||||
);
|
||||
assert.equal(markup[file].match(/<svg\b/g)?.length, svgs, file);
|
||||
}
|
||||
});
|
||||
@@ -1,53 +0,0 @@
|
||||
// The Visual panel's buttons and Material glyphs are the kit's: neither its
|
||||
// template nor the presets it renders hand-writes a <button>, a Material
|
||||
// Symbols span or an inline SVG. The toggles' text glyphs (◎ ▣ ✈ □ ✨ 🔍)
|
||||
// and the presets' style glyphs are characters, not Material symbols, so
|
||||
// they stay text the panel's rules size.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
/** A view's template block: everything outside script and style. */
|
||||
function template(file) {
|
||||
const source = readFileSync(
|
||||
new URL(`../views/panels/${file}`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
return source.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '');
|
||||
}
|
||||
const panel = template('DisplayPanel.vue');
|
||||
const presets = template('VisualPresets.vue');
|
||||
|
||||
test('the Visual panel hand-writes no button; each is a UiButton', () => {
|
||||
for (const markup of [panel, presets])
|
||||
assert.deepEqual(markup.match(/<button\b/gi) ?? [], []);
|
||||
// HUD, Sonar, Detection, 3D, Clean UI, Celestial, Bloom, Sharpen and
|
||||
// Reset to default.
|
||||
assert.equal(panel.match(/<UiButton\b/g)?.length, 9);
|
||||
// The style presets and the map source chips.
|
||||
assert.equal(presets.match(/<UiButton\b/g)?.length, 2);
|
||||
// Scope, the sky rows and the application's toggle rows.
|
||||
assert.equal(panel.match(/<UiCheckbox\b/g)?.length, 3);
|
||||
// 3D model coverage and detection label allocation.
|
||||
assert.equal(panel.match(/<UiSegmented\b/g)?.length, 2);
|
||||
});
|
||||
|
||||
test('the Visual panel hand-writes no Material glyph; each is a UiIcon', () => {
|
||||
for (const markup of [panel, presets]) {
|
||||
assert.deepEqual(markup.match(/material-symbols-outlined/g) ?? [], []);
|
||||
assert.deepEqual(markup.match(/<svg\b/gi) ?? [], []);
|
||||
}
|
||||
const icons = panel.match(/<UiIcon\b[^>]*>/g) ?? [];
|
||||
// Scope, Celestial, the sky rows, the application's rows and Reset.
|
||||
assert.equal(icons.length, 5);
|
||||
// Without it the kit writes an 18px size that beats the panel's own rules.
|
||||
for (const icon of icons) assert.match(icon, /:size="null"/);
|
||||
});
|
||||
|
||||
test('the toggles keep their text glyphs as plain spans', () => {
|
||||
const glyphs = [...panel.matchAll(/<span class="pp-icon">([^<]*)<\/span>/g)];
|
||||
assert.deepEqual(
|
||||
glyphs.map((m) => m[1]),
|
||||
['◎', '▣', '✈', '□', '✨', '🔍'],
|
||||
);
|
||||
});
|
||||
@@ -1,37 +0,0 @@
|
||||
// The welcome card's buttons and Material glyphs are the kit's: its template
|
||||
// hand-writes no <button> and no Material Symbols span, and its one box is a
|
||||
// UiCheckbox. Its two inline SVGs (God mode's globe and its callouts) are
|
||||
// drawings, not glyphs, and its outbound links stay links.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const source = readFileSync(
|
||||
new URL('../views/WelcomeView.vue', import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
/** The template block: everything outside script and style. */
|
||||
const template = source.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '');
|
||||
|
||||
test('the welcome card hand-writes no button; each is a UiButton', () => {
|
||||
assert.deepEqual(template.match(/<button\b/gi) ?? [], []);
|
||||
// SKIP, the three start tiles, BROWSE STORIES, BACK and the main action.
|
||||
assert.equal(template.match(/<UiButton\b/g)?.length, 7);
|
||||
assert.equal(template.match(/<UiCheckbox\b/g)?.length, 1);
|
||||
});
|
||||
|
||||
test('the welcome card hand-writes no Material glyph; each is a UiIcon', () => {
|
||||
assert.deepEqual(template.match(/material-symbols-outlined/g) ?? [], []);
|
||||
const icons = template.match(/<UiIcon\b[^>]*>/g) ?? [];
|
||||
// The three tiles, the three tips, the Stories card and the main arrow.
|
||||
assert.equal(icons.length, 8);
|
||||
// Without it the kit writes an 18px size that beats first-run.css's rules.
|
||||
for (const icon of icons) assert.match(icon, /:size="null"/);
|
||||
});
|
||||
|
||||
test('the only inline SVGs are God mode preview drawings', () => {
|
||||
const svgs = [...template.matchAll(/<svg\b[^>]*>/g)].map((m) => m[0]);
|
||||
assert.equal(svgs.length, 2);
|
||||
assert.match(svgs[0], /class="first-run-globe"/);
|
||||
assert.match(svgs[1], /class="first-run-callouts"/);
|
||||
});
|
||||
+73
-80
@@ -13,11 +13,9 @@
|
||||
// features (styles, HUD, compass, tilt, globe view, share, clear) have their
|
||||
// own. The walk works the same for all of them.
|
||||
|
||||
import { h, render as renderVue } from 'vue';
|
||||
import { t } from '../i18n/index.js';
|
||||
import { EXCLUSIVE_SURFACE_CLASSES } from '../exclusiveSurfaces.js';
|
||||
import { LABEL_LAYERS } from './contextLayerTabs.js';
|
||||
import OmnibarGuide from './views/panels/OmnibarGuide.vue';
|
||||
|
||||
const LEFT_RAIL = '.ui-rail--left .ui-rail__item';
|
||||
const RIGHT_RAIL = '.ui-rail--right .ui-rail__item';
|
||||
@@ -447,71 +445,43 @@ export function startGuide(steps, { title = '' } = {}) {
|
||||
active?.stop();
|
||||
const doc = globalThis.document;
|
||||
if (!doc?.body || screenIsOwned(doc) || !steps?.length) return;
|
||||
// What the view renders: the owner writes it for each step, then paints.
|
||||
// The view never binds what is set on the elements: the guide's `visible`
|
||||
// class, the callout's entrance replay, place and side, and the rings'
|
||||
// boxes, set per frame.
|
||||
const endLabel = t('End guide');
|
||||
const view = {
|
||||
title: title ? t('Guide · {topic}', { topic: title }) : t('Guide'),
|
||||
endLabel,
|
||||
count: '',
|
||||
step: 0,
|
||||
progress: [],
|
||||
text: '',
|
||||
hint: t('Press the highlighted control'),
|
||||
hintHidden: false,
|
||||
// i18n-ignore: the Escape keycap, matching the keyboard shortcut.
|
||||
keyCap: 'Esc',
|
||||
keyText: t('to end'),
|
||||
keysHidden: false,
|
||||
skipLabel: '',
|
||||
skipHidden: true,
|
||||
offerLabel: '',
|
||||
offerHidden: true,
|
||||
nextLabel: t('Next'),
|
||||
nextHidden: false,
|
||||
nextQuiet: false,
|
||||
const root = doc.createElement('div');
|
||||
root.className = 'gev-guide';
|
||||
root.innerHTML =
|
||||
'<div class="gev-guide-ring"><i></i></div>' +
|
||||
'<div class="gev-guide-callout" role="dialog" aria-modal="false" tabindex="-1" aria-labelledby="gev-guide-title" aria-describedby="gev-guide-text">' +
|
||||
'<div class="gev-guide-head"><p id="gev-guide-title" class="gev-guide-title"></p>' +
|
||||
'<p class="gev-guide-count"></p>' +
|
||||
'<button type="button" class="gev-guide-close"><span aria-hidden="true">×</span></button></div>' +
|
||||
'<ol class="gev-guide-progress" aria-hidden="true"></ol>' +
|
||||
'<div class="gev-guide-body"><p id="gev-guide-text" class="gev-guide-text"></p>' +
|
||||
'<p class="gev-guide-hint"><span class="gev-guide-hint-dot"></span><span></span></p></div>' +
|
||||
'<div class="gev-guide-actions"><p class="gev-guide-keys"><kbd></kbd><span></span></p>' +
|
||||
'<span><button type="button" class="gev-guide-skip" hidden></button>' +
|
||||
'<button type="button" class="gev-guide-offer" hidden></button>' +
|
||||
'<button type="button" class="gev-guide-next"></button></span></div>' +
|
||||
// Announces each step once; the dialog itself is not a live region, so
|
||||
// its buttons and progress are not read out on every change.
|
||||
status: '',
|
||||
};
|
||||
const host = doc.createElement('div');
|
||||
const handlers = {
|
||||
onClose: () => stop(),
|
||||
onSkip: () => stop(),
|
||||
// Taking the offer carries the walk on with its steps.
|
||||
onOffer() {
|
||||
if (!current?.offer) return;
|
||||
const extra = current.offer.steps() || [];
|
||||
live.splice(index + 1, live.length, ...extra.filter(Boolean));
|
||||
next();
|
||||
},
|
||||
onNext() {
|
||||
if (current) next();
|
||||
},
|
||||
};
|
||||
let mounted = true;
|
||||
/** Render the view now: the guide goes to the end of the body. */
|
||||
function paint() {
|
||||
if (!mounted) return null;
|
||||
const vnode = h(OmnibarGuide, {
|
||||
to: doc.body,
|
||||
view: { ...view },
|
||||
...handlers,
|
||||
});
|
||||
renderVue(vnode, host);
|
||||
return vnode;
|
||||
}
|
||||
'<p class="gev-guide-status" role="status" aria-live="polite"></p></div>';
|
||||
// Focus returns where it was when the walk ends, if that is still there.
|
||||
const returnFocus = doc.activeElement;
|
||||
// The elements come from the rendered tree, which is in place as soon as the
|
||||
// render returns; template refs are filled after it, and later still when
|
||||
// the walk starts inside one of Vue's own post-render updates.
|
||||
const root = paint().component.subTree.children[0].el;
|
||||
const ring = root.querySelector(':scope > .gev-guide-ring');
|
||||
const callout = root.querySelector(':scope > .gev-guide-callout');
|
||||
doc.body.append(root);
|
||||
const ring = root.querySelector('.gev-guide-ring');
|
||||
const callout = root.querySelector('.gev-guide-callout');
|
||||
const subRings = [];
|
||||
const endLabel = t('End guide');
|
||||
root.querySelector('.gev-guide-close').setAttribute('aria-label', endLabel);
|
||||
root.querySelector('.gev-guide-close').title = endLabel;
|
||||
// i18n-ignore: the Escape keycap, matching the keyboard shortcut.
|
||||
root.querySelector('.gev-guide-keys kbd').textContent = 'Esc';
|
||||
root.querySelector('.gev-guide-keys span').textContent = t('to end');
|
||||
root.querySelector('.gev-guide-title').textContent = title
|
||||
? t('Guide · {topic}', { topic: title })
|
||||
: t('Guide');
|
||||
root.querySelector('.gev-guide-next').textContent = t('Next');
|
||||
root.querySelector('.gev-guide-hint span:last-child').textContent = t(
|
||||
'Press the highlighted control',
|
||||
);
|
||||
|
||||
const live = steps.filter(Boolean);
|
||||
let index = -1;
|
||||
@@ -533,8 +503,7 @@ export function startGuide(steps, { title = '' } = {}) {
|
||||
doc.removeEventListener('click', onClick, true);
|
||||
doc.removeEventListener('keydown', onKey, true);
|
||||
const hadFocus = root.contains(doc.activeElement);
|
||||
mounted = false;
|
||||
renderVue(null, host);
|
||||
root.remove();
|
||||
if (hadFocus && returnFocus?.isConnected) returnFocus.focus?.();
|
||||
if (active?.stop === stop) active = null;
|
||||
};
|
||||
@@ -565,29 +534,41 @@ export function startGuide(steps, { title = '' } = {}) {
|
||||
// would not be skipped as things stand.
|
||||
const total =
|
||||
shown + live.slice(index + 1).filter((later) => !later.skip?.()).length;
|
||||
view.count = `${shown} / ${total}`;
|
||||
view.step = shown;
|
||||
view.progress = Array.from({ length: total }, (_, i) =>
|
||||
i < shown - 1 ? 'done' : i === shown - 1 ? 'current' : null,
|
||||
root.querySelector('.gev-guide-count').textContent = `${shown} / ${total}`;
|
||||
const progress = root.querySelector('.gev-guide-progress');
|
||||
progress.replaceChildren(
|
||||
...Array.from({ length: total }, (_, i) => {
|
||||
const dot = doc.createElement('li');
|
||||
if (i < shown - 1) dot.className = 'done';
|
||||
if (i === shown - 1) dot.className = 'current';
|
||||
return dot;
|
||||
}),
|
||||
);
|
||||
const text = step.text();
|
||||
view.text = text;
|
||||
view.status = `${shown} / ${total}: ${text}`;
|
||||
root.querySelector('.gev-guide-text').textContent = text;
|
||||
root.querySelector('.gev-guide-status').textContent =
|
||||
`${shown} / ${total}: ${text}`;
|
||||
// Steps that point at a control wait for it to be pressed; say so.
|
||||
const waits = Boolean(step.targets) && !step.offer;
|
||||
view.hintHidden = !waits;
|
||||
view.offerHidden = !step.offer;
|
||||
view.skipHidden = !step.offer;
|
||||
view.keysHidden = Boolean(step.offer);
|
||||
root.querySelector('.gev-guide-hint').hidden = !waits;
|
||||
const offer = root.querySelector('.gev-guide-offer');
|
||||
const skip = root.querySelector('.gev-guide-skip');
|
||||
offer.hidden = !step.offer;
|
||||
skip.hidden = !step.offer;
|
||||
root.querySelector('.gev-guide-keys').hidden = Boolean(step.offer);
|
||||
if (step.offer) {
|
||||
view.offerLabel = step.offer.label();
|
||||
view.skipLabel = t('Not now');
|
||||
offer.textContent = step.offer.label();
|
||||
skip.textContent = t('Not now');
|
||||
}
|
||||
const last = index === live.length - 1;
|
||||
view.nextHidden = Boolean(step.offer);
|
||||
view.nextLabel = last ? t('Finish') : waits ? t('Skip step') : t('Next');
|
||||
view.nextQuiet = waits && !last;
|
||||
paint();
|
||||
const nextButton = root.querySelector('.gev-guide-next');
|
||||
nextButton.hidden = Boolean(step.offer);
|
||||
nextButton.textContent = last
|
||||
? t('Finish')
|
||||
: waits
|
||||
? t('Skip step')
|
||||
: t('Next');
|
||||
nextButton.classList.toggle('quiet', waits && !last);
|
||||
// Replay the entrance so each step reads as new.
|
||||
callout.classList.remove('swap');
|
||||
void callout.offsetWidth;
|
||||
@@ -616,6 +597,18 @@ export function startGuide(steps, { title = '' } = {}) {
|
||||
event.stopPropagation();
|
||||
stop();
|
||||
}
|
||||
root.querySelector('.gev-guide-skip').addEventListener('click', stop);
|
||||
root.querySelector('.gev-guide-close').addEventListener('click', stop);
|
||||
root.querySelector('.gev-guide-next').addEventListener('click', () => {
|
||||
if (current) next();
|
||||
});
|
||||
// Taking the offer carries the walk on with its steps.
|
||||
root.querySelector('.gev-guide-offer').addEventListener('click', () => {
|
||||
if (!current?.offer) return;
|
||||
const extra = current.offer.steps() || [];
|
||||
live.splice(index + 1, live.length, ...extra.filter(Boolean));
|
||||
next();
|
||||
});
|
||||
doc.addEventListener('click', onClick, true);
|
||||
doc.addEventListener('keydown', onKey, true);
|
||||
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
// The guided walk's callout, rendered by startGuide() over happy-dom.
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createApp, h, onMounted } from 'vue';
|
||||
import { startGuide } from './omnibarGuide.js';
|
||||
|
||||
const settle = () => new Promise((resolve) => setTimeout(resolve, 0));
|
||||
const $ = (selector) => document.querySelector(selector);
|
||||
|
||||
function fixture(t) {
|
||||
document.body.replaceChildren();
|
||||
const target = document.body.appendChild(document.createElement('button'));
|
||||
const field = document.body.appendChild(document.createElement('input'));
|
||||
field.focus();
|
||||
t.after(() => $('.gev-guide-close')?.click());
|
||||
return { target, field };
|
||||
}
|
||||
|
||||
test('the walk is the last of the body, takes focus and gives it back', async (t) => {
|
||||
const { target, field } = fixture(t);
|
||||
startGuide([{ targets: () => [target], text: () => 'Press it' }], {
|
||||
title: 'Flights',
|
||||
});
|
||||
await settle();
|
||||
const guide = $('.gev-guide');
|
||||
assert.equal(document.body.lastElementChild, guide);
|
||||
assert.equal(guide.parentElement, document.body);
|
||||
assert.ok(guide.classList.contains('visible'));
|
||||
const callout = $('.gev-guide-callout');
|
||||
assert.equal(document.activeElement, callout);
|
||||
assert.equal(callout.getAttribute('role'), 'dialog');
|
||||
assert.equal(callout.getAttribute('aria-modal'), 'false');
|
||||
assert.equal(callout.getAttribute('tabindex'), '-1');
|
||||
assert.equal($('.gev-guide-title').textContent, 'Guide · Flights');
|
||||
const close = $('.gev-guide-close');
|
||||
assert.equal(close.getAttribute('type'), 'button');
|
||||
assert.equal(close.getAttribute('aria-label'), 'End guide');
|
||||
assert.equal(close.getAttribute('title'), 'End guide');
|
||||
assert.ok(close.classList.contains('ui-close-button'));
|
||||
close.focus();
|
||||
close.click();
|
||||
assert.equal($('.gev-guide'), null);
|
||||
assert.equal(document.activeElement, field);
|
||||
});
|
||||
|
||||
test('the status line says each step once, and each step draws new progress', async (t) => {
|
||||
const { target } = fixture(t);
|
||||
startGuide([
|
||||
{ targets: () => [target], text: () => 'Press it' },
|
||||
{ text: () => 'Then this' },
|
||||
{
|
||||
text: () => 'More?',
|
||||
offer: { label: () => 'Show more', steps: () => [] },
|
||||
},
|
||||
]);
|
||||
const status = $('.gev-guide-status');
|
||||
const said = [];
|
||||
// One change per step: its text replaced once, never cleared first.
|
||||
const observer = new MutationObserver(() => said.push(status.textContent));
|
||||
observer.observe(status, {
|
||||
childList: true,
|
||||
characterData: true,
|
||||
subtree: true,
|
||||
});
|
||||
t.after(() => observer.disconnect());
|
||||
await settle();
|
||||
const firstDots = [...document.querySelectorAll('.gev-guide-progress li')];
|
||||
assert.deepEqual(
|
||||
firstDots.map((dot) => dot.getAttribute('class')),
|
||||
['current', null, null],
|
||||
);
|
||||
const next = $('.gev-guide-next');
|
||||
assert.equal(next.textContent, 'Skip step');
|
||||
assert.ok(next.classList.contains('quiet'));
|
||||
assert.equal($('.gev-guide-hint').hidden, false);
|
||||
next.click();
|
||||
await settle();
|
||||
const secondDots = [...document.querySelectorAll('.gev-guide-progress li')];
|
||||
assert.deepEqual(
|
||||
secondDots.map((dot) => dot.getAttribute('class')),
|
||||
['done', 'current', null],
|
||||
);
|
||||
assert.ok(secondDots.every((dot) => !firstDots.includes(dot)));
|
||||
assert.equal(next.textContent, 'Next');
|
||||
assert.equal(next.classList.contains('quiet'), false);
|
||||
assert.equal($('.gev-guide-hint').hidden, true);
|
||||
next.click();
|
||||
await settle();
|
||||
// The closing offer: its two buttons, no Esc hint and no Next.
|
||||
assert.equal($('.gev-guide-keys').hidden, true);
|
||||
assert.equal(next.hidden, true);
|
||||
assert.equal($('.gev-guide-skip').hidden, false);
|
||||
assert.equal($('.gev-guide-skip').textContent, 'Not now');
|
||||
assert.equal($('.gev-guide-offer').textContent, 'Show more');
|
||||
assert.deepEqual(said, [
|
||||
'1 / 3: Press it',
|
||||
'2 / 3: Then this',
|
||||
'3 / 3: More?',
|
||||
]);
|
||||
$('.gev-guide-skip').click();
|
||||
assert.equal($('.gev-guide'), null);
|
||||
});
|
||||
|
||||
test('starting another walk ends the one in progress', async (t) => {
|
||||
fixture(t);
|
||||
startGuide([{ text: () => 'First' }]);
|
||||
startGuide([{ text: () => 'Second' }]);
|
||||
await settle();
|
||||
assert.equal(document.querySelectorAll('.gev-guide').length, 1);
|
||||
assert.equal($('.gev-guide-text').textContent, 'Second');
|
||||
});
|
||||
|
||||
test('a walk started while Vue mounts something else still starts and ends', async (t) => {
|
||||
const { target, field } = fixture(t);
|
||||
let stop = null;
|
||||
const app = createApp({
|
||||
setup() {
|
||||
onMounted(() => {
|
||||
stop = startGuide([
|
||||
{ targets: () => [target], text: () => 'Press it' },
|
||||
]);
|
||||
});
|
||||
return () => h('span');
|
||||
},
|
||||
});
|
||||
app.mount(document.body.appendChild(document.createElement('div')));
|
||||
t.after(() => app.unmount());
|
||||
await settle();
|
||||
assert.equal(typeof stop, 'function');
|
||||
assert.equal(document.activeElement, $('.gev-guide-callout'));
|
||||
assert.ok($('.gev-guide').classList.contains('visible'));
|
||||
stop();
|
||||
assert.equal($('.gev-guide'), null);
|
||||
assert.equal(document.activeElement, field);
|
||||
});
|
||||
+16
-41
@@ -205,7 +205,22 @@ export class PanelChrome {
|
||||
beforeCollapse: () => {
|
||||
if (panelId === 'location-bar') this._closeLocationSearch?.();
|
||||
},
|
||||
returnFocusTo: () => this._railFocusStand(panelId),
|
||||
// A desktop side panel hides entirely once collapsed; its rail item
|
||||
// takes the focus its own disclosure can no longer hold.
|
||||
returnFocusTo: () => {
|
||||
const panel = document.getElementById(panelId);
|
||||
if (!panel?.getClientRects || panel.getClientRects().length > 0)
|
||||
return null;
|
||||
const item = document.querySelector?.(
|
||||
`.ui-rail [data-rail-item="${panelId}"]`,
|
||||
);
|
||||
return item &&
|
||||
!item.disabled &&
|
||||
item.getClientRects().length > 0 &&
|
||||
getComputedStyle(item).visibility === 'visible'
|
||||
? item
|
||||
: null;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -214,49 +229,9 @@ export class PanelChrome {
|
||||
if (this._disposed || !this._disclosurePanelIds?.has(panelId)) return;
|
||||
const panel = document.getElementById(panelId);
|
||||
if (!panel) return;
|
||||
// Opening a panel folds others too (the side accordion, Cockpit's
|
||||
// Contact card): note which open ones hold the focus.
|
||||
const focused = document.activeElement;
|
||||
const holders = [...this._disclosurePanelIds]
|
||||
.map((id) => document.getElementById(id))
|
||||
.filter((el) => el?.contains(focused) && !this._shownPanel(el).collapsed);
|
||||
const cockpit = this.cockpitView;
|
||||
const contactHeld =
|
||||
cockpit?.active &&
|
||||
!cockpit.contextCollapsed &&
|
||||
document.getElementById('cockpit-context')?.contains(focused);
|
||||
this.setPanelCollapsed(panelId, !this._shownPanel(panel).collapsed, {
|
||||
explicit: true,
|
||||
});
|
||||
const stand =
|
||||
contactHeld && cockpit.contextCollapsed
|
||||
? document.getElementById('cockpit-context-toggle')
|
||||
: holders
|
||||
.filter((el) => this._shownPanel(el).collapsed)
|
||||
.map((el) => this._railFocusStand(el.id))
|
||||
.find(Boolean);
|
||||
stand?.focus({ preventScroll: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* A desktop side panel hides entirely once collapsed; its rail item takes
|
||||
* the focus its own disclosure can no longer hold. Null while the panel or
|
||||
* the item is not shown.
|
||||
* @param {string} panelId Panel element id.
|
||||
*/
|
||||
_railFocusStand(panelId) {
|
||||
const panel = document.getElementById(panelId);
|
||||
if (!panel?.getClientRects || panel.getClientRects().length > 0)
|
||||
return null;
|
||||
const item = document.querySelector?.(
|
||||
`.ui-rail [data-rail-item="${panelId}"]`,
|
||||
);
|
||||
return item &&
|
||||
!item.disabled &&
|
||||
item.getClientRects().length > 0 &&
|
||||
getComputedStyle(item).visibility === 'visible'
|
||||
? item
|
||||
: null;
|
||||
}
|
||||
|
||||
_setCommandDockPanelPinState(
|
||||
|
||||
@@ -14,8 +14,6 @@ import PanelCollapseButton from './rail/PanelCollapseButton.vue';
|
||||
import RailPanel from './rail/RailPanel.vue';
|
||||
import UiPanel from './kit/UiPanel.vue';
|
||||
import { usePanelChromeStore } from './stores/panelChrome.js';
|
||||
import { useDisplayStore } from './stores/display.js';
|
||||
import { DisplayBindings } from './displayBindings.js';
|
||||
import CommandDockView from './views/CommandDockView.vue';
|
||||
|
||||
function mount(t, component) {
|
||||
@@ -489,164 +487,3 @@ test('the accordion closes peers through the real store, and opens them again',
|
||||
assert.equal(panels[0].className, '');
|
||||
chrome.destroy();
|
||||
});
|
||||
|
||||
test('F collapses Data Layers like its button and keeps its rail entry', (t) => {
|
||||
document.body.innerHTML = `
|
||||
<nav class="ui-rail"><button data-rail-item="data-panel" style="visibility: visible"></button></nav>
|
||||
<div id="data-panel" class="active"><button class="panel-collapse-btn" data-collapse-target="data-panel"></button></div>`;
|
||||
const panel = document.getElementById('data-panel');
|
||||
const item = document.querySelector('[data-rail-item="data-panel"]');
|
||||
panel.getClientRects = () =>
|
||||
panel.classList.contains('collapsed') ? [] : [{}];
|
||||
item.getClientRects = () => [{}];
|
||||
const store = usePanelChromeStore(createPinia());
|
||||
const chrome = panelChrome(store);
|
||||
followPanelState(store, 'data-panel', panel);
|
||||
chrome._disclosurePanelIds = new Set(['data-panel']);
|
||||
const bindings = new DisplayBindings({
|
||||
viewer: null,
|
||||
services: { isScopeMaskEnabled: () => false, cycleDetectionMode() {} },
|
||||
elements: { _locationSearch: document.createElement('input') },
|
||||
operations: {
|
||||
_setScope() {},
|
||||
_togglePanel: (panelId) => chrome._togglePanel(panelId),
|
||||
},
|
||||
readState: () => ({}),
|
||||
claimDetection() {},
|
||||
displayStore: useDisplayStore(createPinia()),
|
||||
});
|
||||
bindings._initUI();
|
||||
t.after(() => {
|
||||
bindings.destroy();
|
||||
chrome.destroy();
|
||||
});
|
||||
const press = (init = {}) =>
|
||||
document.activeElement.dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'f', bubbles: true, ...init }),
|
||||
);
|
||||
|
||||
panel.querySelector('button').focus();
|
||||
press();
|
||||
assert.equal(store.panels['data-panel']?.collapsed, true);
|
||||
assert.ok(document.activeElement === item, 'focus moves to the rail');
|
||||
assert.ok(panel.classList.contains('collapsed'));
|
||||
// `active` is what shows Data Layers at all (layers.css).
|
||||
assert.ok(panel.classList.contains('active'));
|
||||
press({ metaKey: true });
|
||||
assert.equal(store.panels['data-panel'].collapsed, true, 'Cmd+F is not ours');
|
||||
press();
|
||||
assert.equal(store.panels['data-panel'].collapsed, false);
|
||||
assert.ok(!panel.classList.contains('collapsed'));
|
||||
assert.ok(panel.classList.contains('active'));
|
||||
});
|
||||
|
||||
test('F that folds a focused peer hands the focus to a rail entry', (t) => {
|
||||
document.body.innerHTML = `
|
||||
<nav class="ui-rail">
|
||||
<button data-rail-item="data-panel" style="visibility: visible"></button>
|
||||
<button data-rail-item="pp-toggles" style="visibility: visible"></button>
|
||||
</nav>
|
||||
<div id="left-panel-stack">
|
||||
<div id="data-panel" data-panel-id="data-panel" class="active collapsed"><button class="panel-collapse-btn" data-collapse-target="data-panel"></button></div>
|
||||
<div id="pp-toggles" data-panel-id="pp-toggles"><button class="panel-collapse-btn" data-collapse-target="pp-toggles"></button><button id="crt2">CRT 2</button></div>
|
||||
</div>`;
|
||||
const stack = document.getElementById('left-panel-stack');
|
||||
const store = usePanelChromeStore(createPinia());
|
||||
const chrome = new PanelChrome({
|
||||
elements: { _leftPanelStack: stack },
|
||||
operations: { _showToast() {}, _syncCctvPanelViewport() {} },
|
||||
readHud: () => ({ visible: false, getVariant: () => null }),
|
||||
readCockpit: () => null,
|
||||
readShareLinks: () => null,
|
||||
readInitialShare: () => null,
|
||||
readScrollRestoreOwner: () => null,
|
||||
readDisplayScrollTop: () => 0,
|
||||
store,
|
||||
});
|
||||
for (const id of ['data-panel', 'pp-toggles']) {
|
||||
const panel = document.getElementById(id);
|
||||
panel.getClientRects = () =>
|
||||
panel.classList.contains('collapsed') ? [] : [{}];
|
||||
followPanelState(store, id, panel);
|
||||
}
|
||||
for (const item of document.querySelectorAll('[data-rail-item]'))
|
||||
item.getClientRects = () => [{}];
|
||||
chrome._disclosurePanelIds = new Set(['data-panel', 'pp-toggles']);
|
||||
const bindings = new DisplayBindings({
|
||||
viewer: null,
|
||||
services: { isScopeMaskEnabled: () => false, cycleDetectionMode() {} },
|
||||
elements: { _locationSearch: document.createElement('input') },
|
||||
operations: {
|
||||
_setScope() {},
|
||||
_togglePanel: (panelId) => chrome._togglePanel(panelId),
|
||||
},
|
||||
readState: () => ({}),
|
||||
claimDetection() {},
|
||||
displayStore: useDisplayStore(createPinia()),
|
||||
});
|
||||
bindings._initUI();
|
||||
t.after(() => {
|
||||
bindings.destroy();
|
||||
chrome.destroy();
|
||||
});
|
||||
|
||||
const crt2 = document.getElementById('crt2');
|
||||
crt2.focus();
|
||||
assert.equal(document.activeElement, crt2);
|
||||
crt2.dispatchEvent(new KeyboardEvent('keydown', { key: 'f', bubbles: true }));
|
||||
assert.equal(
|
||||
store.panels['data-panel']?.collapsed,
|
||||
false,
|
||||
'Data Layers opens',
|
||||
);
|
||||
const visual = document.getElementById('pp-toggles');
|
||||
assert.ok(
|
||||
visual.classList.contains('collapsed'),
|
||||
'the accordion folds Visual',
|
||||
);
|
||||
assert.ok(
|
||||
document.activeElement?.matches?.('.ui-rail [data-rail-item]'),
|
||||
`focus lands on a rail entry, not inside the hidden peer (got ${document.activeElement?.id || document.activeElement?.tagName})`,
|
||||
);
|
||||
});
|
||||
|
||||
test('opening Data Layers in Cockpit hands the focus from the folded Contact card to its toggle', (t) => {
|
||||
document.body.innerHTML = `
|
||||
<div id="left-panel-stack">
|
||||
<div id="data-panel" data-panel-id="data-panel" class="active collapsed"><button class="panel-collapse-btn" data-collapse-target="data-panel"></button></div>
|
||||
</div>
|
||||
<aside id="cockpit-context"><button id="cockpit-context-toggle"></button><button id="cockpit-weather-toggle"></button></aside>`;
|
||||
const store = usePanelChromeStore(createPinia());
|
||||
const cockpit = {
|
||||
active: true,
|
||||
contextCollapsed: false,
|
||||
setContextCollapsed(collapsed) {
|
||||
this.contextCollapsed = collapsed;
|
||||
},
|
||||
setSignalCollapsed() {},
|
||||
scheduleContextLayout() {},
|
||||
};
|
||||
const chrome = new PanelChrome({
|
||||
elements: { _leftPanelStack: document.getElementById('left-panel-stack') },
|
||||
operations: { _showToast() {}, _syncCctvPanelViewport() {} },
|
||||
readHud: () => ({ visible: false, getVariant: () => null }),
|
||||
readCockpit: () => cockpit,
|
||||
readShareLinks: () => null,
|
||||
readInitialShare: () => null,
|
||||
readScrollRestoreOwner: () => null,
|
||||
readDisplayScrollTop: () => 0,
|
||||
store,
|
||||
});
|
||||
t.after(() => chrome.destroy());
|
||||
followPanelState(store, 'data-panel', document.getElementById('data-panel'));
|
||||
chrome._disclosurePanelIds = new Set(['data-panel']);
|
||||
document.getElementById('cockpit-weather-toggle').focus();
|
||||
chrome._togglePanel('data-panel');
|
||||
assert.equal(
|
||||
store.panels['data-panel']?.collapsed,
|
||||
false,
|
||||
'Data Layers opens',
|
||||
);
|
||||
assert.equal(cockpit.contextCollapsed, true, 'Contact folds for it');
|
||||
assert.equal(document.activeElement?.id, 'cockpit-context-toggle');
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import PanelRailView from './PanelRailView.vue';
|
||||
import { PANEL_RAIL_HOST_CLASS } from './panelRailCatalog.js';
|
||||
import { PANEL_RAIL_HOST_CLASS, PANEL_RAIL_ITEMS } from './panelRailCatalog.js';
|
||||
import { usePanelStore } from './stores/panels.js';
|
||||
|
||||
/**
|
||||
@@ -71,6 +71,7 @@ export class PanelNavigation {
|
||||
? [...stack.children]
|
||||
.filter((panel) => panel.matches('[data-panel-id]'))
|
||||
.map((panel) => {
|
||||
const shownBy = PANEL_RAIL_ITEMS[panel.id]?.shownBy;
|
||||
return {
|
||||
id: panel.id,
|
||||
title:
|
||||
@@ -78,7 +79,9 @@ export class PanelNavigation {
|
||||
.querySelector('.panel-title, .pp-header-label')
|
||||
?.textContent.trim() || panel.id,
|
||||
open: !panel.classList.contains('collapsed'),
|
||||
available: !panel.hidden,
|
||||
available:
|
||||
!panel.hidden &&
|
||||
(!shownBy || panel.classList.contains(shownBy)),
|
||||
};
|
||||
})
|
||||
: [];
|
||||
|
||||
@@ -22,6 +22,8 @@ function panel(id, { collapsed = true, hidden = false, title = '' } = {}) {
|
||||
element.className = collapsed
|
||||
? 'panel-collapsible collapsed'
|
||||
: 'panel-collapsible';
|
||||
// Data Layers shows only while `active` (the `f` shortcut toggles it).
|
||||
if (id === 'data-panel') element.classList.add('active');
|
||||
element.hidden = hidden;
|
||||
if (title) element.innerHTML = `<span class="panel-title">${title}</span>`;
|
||||
return element;
|
||||
@@ -130,8 +132,8 @@ test('the rails follow disclosure and availability changes', async () => {
|
||||
['global-context-panel', 'false'],
|
||||
['host-panel', 'false'],
|
||||
]);
|
||||
// A hidden panel leaves its rail.
|
||||
document.getElementById('data-panel').hidden = true;
|
||||
// `f` hides Data Layers outright, so the rail stops offering it.
|
||||
document.getElementById('data-panel').classList.remove('active');
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await nextTick();
|
||||
assert.deepEqual(railItems(left), [['scene-panel', 'true']]);
|
||||
|
||||
@@ -7,11 +7,16 @@ export const PANEL_RAIL_HOST_CLASS = 'gev-panel-rail';
|
||||
export const PANEL_RAIL_FALLBACK_ICON = 'more_horiz';
|
||||
|
||||
/**
|
||||
* How each side panel appears on its rail. Labels are the panels' own titles;
|
||||
* `context` is the label's translation context.
|
||||
* How each side panel appears on its rail. Labels are the panels' own titles.
|
||||
* `shownBy` names a class the panel needs to be shown at all (`f` toggles
|
||||
* Data Layers' `active`). `context` is the label's translation context.
|
||||
*/
|
||||
export const PANEL_RAIL_ITEMS = Object.freeze({
|
||||
'data-panel': { icon: 'layers', label: msg('DATA LAYERS') },
|
||||
'data-panel': {
|
||||
icon: 'layers',
|
||||
label: msg('DATA LAYERS'),
|
||||
shownBy: 'active',
|
||||
},
|
||||
'utilities-panel': { icon: 'handyman', label: msg('UTILITIES') },
|
||||
'scene-panel': { icon: 'movie', label: msg('AUTHORING') },
|
||||
// `context` keeps the panel's name apart from the satellite class of the
|
||||
|
||||
+163
-133
@@ -1,4 +1,3 @@
|
||||
import { h, render as renderVue } from 'vue';
|
||||
import { fromDegrees } from '../geo/ellipsoid.js';
|
||||
import { horizonFrom } from '../geo/horizon.js';
|
||||
import { distance } from '../geo/vector.js';
|
||||
@@ -9,7 +8,6 @@ import {
|
||||
findQuery,
|
||||
} from '../render/rendererOf.js';
|
||||
import { t } from '../i18n/index.js';
|
||||
import QuebecCctvOverlay from './views/panels/QuebecCctvOverlay.vue';
|
||||
|
||||
function isQuebecCamera(camera) {
|
||||
return String(camera?.sourceKind || '').startsWith('quebec-');
|
||||
@@ -79,77 +77,72 @@ function mediaRefreshUrl(value) {
|
||||
* Attach the active Québec source to a floating browser player and map
|
||||
* preview. The browser contacts Québec 511 only after the viewer presses Play
|
||||
* for that camera; selecting it (by click, auto-hop, a scene or voice) only
|
||||
* shows its details and the play control. The panel and marker are the
|
||||
* `QuebecCctvOverlay` view, rendered synchronously on each change.
|
||||
* shows its details and the play control.
|
||||
*/
|
||||
export function createQuebecCctvOverlay(viewer) {
|
||||
if (!viewer || typeof document === 'undefined') return null;
|
||||
|
||||
const controller = new AbortController();
|
||||
const { signal } = controller;
|
||||
// What the view renders. The owner writes it where it used to write the
|
||||
// elements, then paints; the view never binds the media sources, the
|
||||
// panel's dragged position or the marker's per-frame visibility and place.
|
||||
const view = {
|
||||
panelHidden: true,
|
||||
title: '',
|
||||
coordinates: '',
|
||||
credit: '',
|
||||
creditHidden: false,
|
||||
liveHidden: false,
|
||||
actionsHidden: false,
|
||||
playHidden: false,
|
||||
refreshHidden: false,
|
||||
note: '',
|
||||
noteHidden: false,
|
||||
sourceHref: null,
|
||||
sourceHidden: false,
|
||||
markerLinkOnly: false,
|
||||
stillHidden: false,
|
||||
markerLabel: '',
|
||||
};
|
||||
const host = document.createElement('div');
|
||||
let disposed = false;
|
||||
const handlers = {
|
||||
onClose: closeWindow,
|
||||
onPlay: startPlayback,
|
||||
onRefresh: refreshStill,
|
||||
onKeydown(event) {
|
||||
if (event.key === 'Escape') close.click();
|
||||
},
|
||||
onHeaderPointerdown: startDrag,
|
||||
onLiveError: markLiveUnavailable,
|
||||
onLiveLoadeddata() {
|
||||
liveUnavailable = false;
|
||||
view.note = t(
|
||||
'The map still uses a separate request and may show a different moment.',
|
||||
);
|
||||
view.noteHidden = false;
|
||||
paint();
|
||||
},
|
||||
onStillError: markStillUnavailable,
|
||||
onStillLoadeddata() {
|
||||
stillUnavailable = false;
|
||||
if (selected)
|
||||
view.markerLabel = markerLabelText(selected, Boolean(selectedMediaUrl));
|
||||
paint();
|
||||
still.pause();
|
||||
},
|
||||
};
|
||||
/** Render the view now: the panel and marker go to the end of the body. */
|
||||
function paint() {
|
||||
if (disposed) return null;
|
||||
const vnode = h(QuebecCctvOverlay, { view: { ...view }, ...handlers });
|
||||
renderVue(vnode, host);
|
||||
return vnode.component.exposed;
|
||||
}
|
||||
const elements = paint();
|
||||
const panel = elements.panel.value;
|
||||
const header = elements.header.value;
|
||||
const close = elements.close.value.$el;
|
||||
const live = elements.live.value;
|
||||
const marker = elements.marker.value;
|
||||
const still = elements.still.value;
|
||||
const panel = document.createElement('section');
|
||||
panel.className = 'qci-panel';
|
||||
panel.hidden = true;
|
||||
panel.setAttribute('role', 'region');
|
||||
panel.setAttribute('aria-label', t('CCTV camera'));
|
||||
|
||||
const header = document.createElement('header');
|
||||
header.className = 'qci-header';
|
||||
const title = document.createElement('strong');
|
||||
const close = document.createElement('button');
|
||||
close.type = 'button';
|
||||
close.textContent = '×';
|
||||
close.setAttribute('aria-label', t('Close camera preview'));
|
||||
header.append(title, close);
|
||||
|
||||
const coordinates = document.createElement('p');
|
||||
coordinates.className = 'qci-coordinates';
|
||||
const credit = document.createElement('p');
|
||||
credit.className = 'qci-credit';
|
||||
const live = document.createElement('video');
|
||||
live.className = 'qci-live';
|
||||
live.controls = true;
|
||||
live.muted = true;
|
||||
live.autoplay = true;
|
||||
live.loop = true;
|
||||
live.playsInline = true;
|
||||
live.setAttribute('aria-label', t('CCTV camera'));
|
||||
|
||||
const actions = document.createElement('div');
|
||||
actions.className = 'qci-actions';
|
||||
const play = document.createElement('button');
|
||||
play.type = 'button';
|
||||
play.className = 'qci-play';
|
||||
play.textContent = t('Play');
|
||||
const refresh = document.createElement('button');
|
||||
refresh.type = 'button';
|
||||
refresh.textContent = t('Refresh map still');
|
||||
actions.append(play, refresh);
|
||||
const note = document.createElement('p');
|
||||
note.className = 'qci-note';
|
||||
const sourceLink = document.createElement('a');
|
||||
sourceLink.target = '_blank';
|
||||
sourceLink.rel = 'noopener noreferrer';
|
||||
sourceLink.textContent = t("Open this image on the provider's site");
|
||||
panel.append(header, coordinates, credit, live, actions, note, sourceLink);
|
||||
|
||||
const marker = document.createElement('div');
|
||||
marker.className = 'qci-marker';
|
||||
marker.hidden = true;
|
||||
const still = document.createElement('video');
|
||||
still.className = 'qci-marker-still';
|
||||
still.muted = true;
|
||||
still.playsInline = true;
|
||||
still.preload = 'none';
|
||||
still.setAttribute('aria-hidden', 'true');
|
||||
const markerLabel = document.createElement('span');
|
||||
markerLabel.className = 'qci-marker-label';
|
||||
marker.append(still, markerLabel);
|
||||
document.body.append(panel, marker);
|
||||
|
||||
let selected = null;
|
||||
let selectedPosition = null;
|
||||
@@ -173,15 +166,13 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
|
||||
function markLiveUnavailable() {
|
||||
liveUnavailable = true;
|
||||
view.note = t('Source unavailable');
|
||||
view.noteHidden = false;
|
||||
paint();
|
||||
note.textContent = t('Source unavailable');
|
||||
note.hidden = false;
|
||||
}
|
||||
|
||||
function markStillUnavailable() {
|
||||
stillUnavailable = true;
|
||||
view.markerLabel = t('Source unavailable');
|
||||
paint();
|
||||
markerLabel.textContent = t('Source unavailable');
|
||||
}
|
||||
|
||||
function startRender() {
|
||||
@@ -227,17 +218,16 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
playingCameraId = selected.id;
|
||||
liveUnavailable = false;
|
||||
stillUnavailable = false;
|
||||
view.playHidden = true;
|
||||
view.refreshHidden = false;
|
||||
view.liveHidden = false;
|
||||
view.stillHidden = false;
|
||||
view.markerLinkOnly = false;
|
||||
view.note = t(
|
||||
play.hidden = true;
|
||||
refresh.hidden = false;
|
||||
live.hidden = false;
|
||||
still.hidden = false;
|
||||
marker.classList.remove('qci-marker-link-only');
|
||||
note.textContent = t(
|
||||
'The map still uses a separate request and may show a different moment.',
|
||||
);
|
||||
view.noteHidden = false;
|
||||
view.markerLabel = markerLabelText(selected, true);
|
||||
paint();
|
||||
note.hidden = false;
|
||||
markerLabel.textContent = markerLabelText(selected, true);
|
||||
setMedia(live, selectedMediaUrl);
|
||||
setMedia(still, selectedMediaUrl);
|
||||
void live.play().catch(onPlayFailure(markLiveUnavailable));
|
||||
@@ -256,8 +246,7 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
stillUnavailable = false;
|
||||
stopMediaRefresh();
|
||||
stopRender();
|
||||
view.panelHidden = true;
|
||||
paint();
|
||||
panel.hidden = true;
|
||||
marker.hidden = true;
|
||||
setMedia(live, '');
|
||||
setMedia(still, '');
|
||||
@@ -274,8 +263,7 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
Number(camera.elevationM) || 10,
|
||||
);
|
||||
if (closedWindowCameraId === camera.id && !reselected) {
|
||||
view.panelHidden = true;
|
||||
paint();
|
||||
panel.hidden = true;
|
||||
updateMarker();
|
||||
return;
|
||||
}
|
||||
@@ -288,8 +276,8 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
playingCameraId = null;
|
||||
}
|
||||
const playing = Boolean(mediaUrl) && playingCameraId === camera.id;
|
||||
view.title = camera.name || t('CCTV camera');
|
||||
view.coordinates = [
|
||||
title.textContent = camera.name || t('CCTV camera');
|
||||
coordinates.textContent = [
|
||||
`${Number(camera.lat).toFixed(5)}, ${Number(camera.lon).toFixed(5)}`,
|
||||
Number.isFinite(camera.accuracyM) && camera.accuracyM > 0
|
||||
? `±${Math.round(camera.accuracyM)} m`
|
||||
@@ -298,13 +286,14 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' · ');
|
||||
view.credit = camera.credit || camera.provider || '';
|
||||
view.creditHidden = !view.credit;
|
||||
view.liveHidden = !playing;
|
||||
view.playHidden = !mediaUrl || playing;
|
||||
view.refreshHidden = !playing;
|
||||
view.actionsHidden = !mediaUrl;
|
||||
view.note = mediaUrl
|
||||
credit.textContent = camera.credit || camera.provider || '';
|
||||
credit.hidden = !credit.textContent;
|
||||
live.hidden = !playing;
|
||||
play.hidden = !mediaUrl || playing;
|
||||
refresh.hidden = !playing;
|
||||
actions.hidden = !mediaUrl;
|
||||
note.hidden = !mediaUrl;
|
||||
note.textContent = mediaUrl
|
||||
? !playing
|
||||
? t('Video plays from Québec 511, which sees your IP address.')
|
||||
: liveUnavailable
|
||||
@@ -315,16 +304,15 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
: sourceUrl
|
||||
? ''
|
||||
: t('Source unavailable');
|
||||
view.noteHidden = !view.note;
|
||||
view.sourceHref = sourceUrl || '#';
|
||||
view.sourceHidden = !sourceUrl;
|
||||
view.markerLabel = stillUnavailable
|
||||
note.hidden = !note.textContent;
|
||||
sourceLink.href = sourceUrl || '#';
|
||||
sourceLink.hidden = !sourceUrl;
|
||||
markerLabel.textContent = stillUnavailable
|
||||
? t('Source unavailable')
|
||||
: markerLabelText(camera, playing);
|
||||
view.markerLinkOnly = !playing;
|
||||
view.stillHidden = !playing;
|
||||
view.panelHidden = false;
|
||||
paint();
|
||||
marker.classList.toggle('qci-marker-link-only', !playing);
|
||||
still.hidden = !playing;
|
||||
panel.hidden = false;
|
||||
|
||||
if (changed || mediaUrl !== selectedMediaUrl) {
|
||||
selectedMediaUrl = mediaUrl;
|
||||
@@ -378,6 +366,34 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
);
|
||||
}
|
||||
|
||||
still.addEventListener(
|
||||
'loadeddata',
|
||||
() => {
|
||||
stillUnavailable = false;
|
||||
if (selected)
|
||||
markerLabel.textContent = markerLabelText(
|
||||
selected,
|
||||
Boolean(selectedMediaUrl),
|
||||
);
|
||||
still.pause();
|
||||
},
|
||||
{ signal },
|
||||
);
|
||||
still.addEventListener('error', markStillUnavailable, { signal });
|
||||
live.addEventListener('error', markLiveUnavailable, { signal });
|
||||
live.addEventListener(
|
||||
'loadeddata',
|
||||
() => {
|
||||
liveUnavailable = false;
|
||||
note.textContent = t(
|
||||
'The map still uses a separate request and may show a different moment.',
|
||||
);
|
||||
note.hidden = false;
|
||||
},
|
||||
{ signal },
|
||||
);
|
||||
refresh.addEventListener('click', refreshStill, { signal });
|
||||
play.addEventListener('click', startPlayback, { signal });
|
||||
const resetCanvasRect = () => {
|
||||
canvasRect = null;
|
||||
};
|
||||
@@ -387,35 +403,49 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
capture: true,
|
||||
passive: true,
|
||||
});
|
||||
function closeWindow() {
|
||||
closedWindowCameraId = selected?.id || null;
|
||||
view.panelHidden = true;
|
||||
paint();
|
||||
live.pause();
|
||||
stopMediaRefresh();
|
||||
// The floating player closes independently; keep the paused map still.
|
||||
updateMarker();
|
||||
}
|
||||
function startDrag(event) {
|
||||
if (event.target.closest('button')) return;
|
||||
const rect = panel.getBoundingClientRect();
|
||||
const offsetX = event.clientX - rect.left;
|
||||
const offsetY = event.clientY - rect.top;
|
||||
header.setPointerCapture(event.pointerId);
|
||||
const move = (moveEvent) => {
|
||||
panel.style.left = `${Math.max(0, Math.min(window.innerWidth - panel.offsetWidth, moveEvent.clientX - offsetX))}px`;
|
||||
panel.style.top = `${Math.max(0, Math.min(window.innerHeight - panel.offsetHeight, moveEvent.clientY - offsetY))}px`;
|
||||
panel.style.right = 'auto';
|
||||
};
|
||||
const stop = () => {
|
||||
header.removeEventListener('pointermove', move);
|
||||
header.removeEventListener('pointerup', stop);
|
||||
header.removeEventListener('pointercancel', stop);
|
||||
};
|
||||
header.addEventListener('pointermove', move, { signal });
|
||||
header.addEventListener('pointerup', stop, { once: true, signal });
|
||||
header.addEventListener('pointercancel', stop, { once: true, signal });
|
||||
}
|
||||
panel.addEventListener(
|
||||
'keydown',
|
||||
(event) => {
|
||||
if (event.key === 'Escape') close.click();
|
||||
},
|
||||
{ signal },
|
||||
);
|
||||
close.addEventListener(
|
||||
'click',
|
||||
() => {
|
||||
closedWindowCameraId = selected?.id || null;
|
||||
panel.hidden = true;
|
||||
live.pause();
|
||||
stopMediaRefresh();
|
||||
// The floating player closes independently; keep the paused map still.
|
||||
updateMarker();
|
||||
},
|
||||
{ signal },
|
||||
);
|
||||
header.addEventListener(
|
||||
'pointerdown',
|
||||
(event) => {
|
||||
if (event.target.closest('button')) return;
|
||||
const rect = panel.getBoundingClientRect();
|
||||
const offsetX = event.clientX - rect.left;
|
||||
const offsetY = event.clientY - rect.top;
|
||||
header.setPointerCapture(event.pointerId);
|
||||
const move = (moveEvent) => {
|
||||
panel.style.left = `${Math.max(0, Math.min(window.innerWidth - panel.offsetWidth, moveEvent.clientX - offsetX))}px`;
|
||||
panel.style.top = `${Math.max(0, Math.min(window.innerHeight - panel.offsetHeight, moveEvent.clientY - offsetY))}px`;
|
||||
panel.style.right = 'auto';
|
||||
};
|
||||
const stop = () => {
|
||||
header.removeEventListener('pointermove', move);
|
||||
header.removeEventListener('pointerup', stop);
|
||||
header.removeEventListener('pointercancel', stop);
|
||||
};
|
||||
header.addEventListener('pointermove', move, { signal });
|
||||
header.addEventListener('pointerup', stop, { once: true, signal });
|
||||
header.addEventListener('pointercancel', stop, { once: true, signal });
|
||||
},
|
||||
{ signal },
|
||||
);
|
||||
document.addEventListener(
|
||||
'visibilitychange',
|
||||
() => {
|
||||
@@ -439,8 +469,8 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
stopRender();
|
||||
setMedia(live, '');
|
||||
setMedia(still, '');
|
||||
disposed = true;
|
||||
renderVue(null, host);
|
||||
panel.remove();
|
||||
marker.remove();
|
||||
selected = null;
|
||||
selectedPosition = null;
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { Window } from 'happy-dom';
|
||||
import { fromDegrees } from '../geo/ellipsoid.js';
|
||||
import { bindFakeDraw } from '../testSupport/fakeDrawPort.mjs';
|
||||
import { fakeCameraPort } from '../testSupport/fakeCameraPort.mjs';
|
||||
@@ -22,36 +22,23 @@ const CAMERA = Object.freeze({
|
||||
});
|
||||
|
||||
/**
|
||||
* Mount the overlay in the registered happy-dom window (Vue binds the
|
||||
* document it loads with) with recorded media loads, timers and postRender
|
||||
* listeners. `play` decides what each play() returns.
|
||||
* Mount the overlay in a happy-dom window with recorded media loads, timers
|
||||
* and postRender listeners. `play` decides what each play() returns.
|
||||
*/
|
||||
function mountOverlay(t, { play = () => Promise.resolve() } = {}) {
|
||||
const { window } = globalThis;
|
||||
const media = window.HTMLMediaElement.prototype;
|
||||
const previous = {
|
||||
load: media.load,
|
||||
play: media.play,
|
||||
pause: media.pause,
|
||||
setInterval: window.setInterval,
|
||||
clearInterval: window.clearInterval,
|
||||
};
|
||||
t.after(() => {
|
||||
media.load = previous.load;
|
||||
media.play = previous.play;
|
||||
media.pause = previous.pause;
|
||||
window.setInterval = previous.setInterval;
|
||||
window.clearInterval = previous.clearInterval;
|
||||
delete window.document.hidden;
|
||||
});
|
||||
const window = new Window({ url: 'http://localhost:4173/' });
|
||||
const previousWindow = globalThis.window;
|
||||
const previousDocument = globalThis.document;
|
||||
globalThis.window = window;
|
||||
globalThis.document = window.document;
|
||||
const loads = [];
|
||||
media.load = function () {
|
||||
window.HTMLMediaElement.prototype.load = function () {
|
||||
if (this.getAttribute('src')) loads.push(this.getAttribute('src'));
|
||||
};
|
||||
media.play = function () {
|
||||
window.HTMLMediaElement.prototype.play = function () {
|
||||
return play(this);
|
||||
};
|
||||
media.pause = function () {};
|
||||
window.HTMLMediaElement.prototype.pause = function () {};
|
||||
const intervals = new Map();
|
||||
let nextTimer = 1;
|
||||
window.setInterval = (fn) => {
|
||||
@@ -78,7 +65,12 @@ function mountOverlay(t, { play = () => Promise.resolve() } = {}) {
|
||||
});
|
||||
t.after(unbind);
|
||||
const overlay = createQuebecCctvOverlay(viewer);
|
||||
t.after(() => overlay?.dispose());
|
||||
t.after(() => {
|
||||
overlay?.dispose();
|
||||
globalThis.window = previousWindow;
|
||||
globalThis.document = previousDocument;
|
||||
window.close();
|
||||
});
|
||||
const [live, still] = window.document.querySelectorAll('video');
|
||||
return {
|
||||
window,
|
||||
@@ -211,21 +203,3 @@ test('the refresh timer reloads with a cache-buster, skips hidden tabs, and stop
|
||||
assert.equal(ui.renderListeners.size, 0);
|
||||
assert.equal(ui.window.document.querySelector('.qci-panel') === null, true);
|
||||
});
|
||||
|
||||
test('Escape in the window closes it and stops the refresh until the camera is picked again', (t) => {
|
||||
const ui = mountOverlay(t);
|
||||
ui.overlay.setCamera(CAMERA);
|
||||
ui.playButton().click();
|
||||
const panel = ui.window.document.querySelector('.qci-panel');
|
||||
panel.dispatchEvent(
|
||||
new ui.window.KeyboardEvent('keydown', { key: 'Escape', bubbles: true }),
|
||||
);
|
||||
assert.equal(panel.hidden, true);
|
||||
assert.equal(ui.intervals.size, 0);
|
||||
|
||||
ui.overlay.setCamera({ ...CAMERA });
|
||||
assert.equal(panel.hidden, true, 'a routine update keeps it closed');
|
||||
ui.overlay.setCamera({ ...CAMERA }, { reselected: true });
|
||||
assert.equal(panel.hidden, false, 'picking the camera again reopens it');
|
||||
assert.equal(ui.intervals.size, 1);
|
||||
});
|
||||
@@ -1,10 +1,9 @@
|
||||
/* Core's close, dismiss and clear buttons draw a bare glyph: no padding,
|
||||
* border or background of their own, and a pointer. The kit's
|
||||
* UiCloseButton wears it as .ui-close-button, and the guide's close (a
|
||||
* UiCloseButton too) shares the rule by its feature class. It selects one
|
||||
* class and loads before the feature stylesheets, so each feature rule still
|
||||
* sets its size, colour, hover and any surface (a border, a chip, a tinted
|
||||
* square). */
|
||||
* UiCloseButton wears it as .ui-close-button; the guide's close button,
|
||||
* built in script, shares the rule. It selects one class and loads before
|
||||
* the feature stylesheets, so each feature rule still sets its size, colour,
|
||||
* hover and any surface (a border, a chip, a tinted square). */
|
||||
.ui-close-button,
|
||||
.gev-guide-close {
|
||||
padding: 0;
|
||||
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
entryPlacement,
|
||||
} from '../../stories/format.js';
|
||||
import { guardStoriesKeyboard } from '../../stories/keyboard.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
|
||||
// The screens, their styles and the story data load with Stories (see
|
||||
// src/stories/boot.js); only the button, popup and toast load with GEV.
|
||||
@@ -319,17 +318,18 @@ watch([mode, storyId], () => nextTick(watchCredit));
|
||||
|
||||
<!-- GEV: the Stories entry, its first-visit popup and the Opened-in-GEV toast -->
|
||||
<template v-if="mode === 'closed' && store.available">
|
||||
<UiButton
|
||||
<button
|
||||
id="hStories"
|
||||
class="tbtn accent gs-entry"
|
||||
:class="{ 'gs-entry-compact': entry.compact }"
|
||||
type="button"
|
||||
:aria-label="entry.compact ? t('Stories') : undefined"
|
||||
:style="{ top: `${entry.top}px`, right: `${entry.right}px` }"
|
||||
@click="openExplore"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"><rect x="3" y="5" width="18" height="14" rx="3" /><path d="M10 9.5v5l4.5-2.5z" fill="currentColor" /></svg>
|
||||
<span>{{ t('Stories') }}</span>
|
||||
</UiButton>
|
||||
</button>
|
||||
<div
|
||||
v-if="popOpen"
|
||||
id="hPop"
|
||||
@@ -342,14 +342,14 @@ watch([mode, storyId], () => nextTick(watchCredit));
|
||||
<h2 id="hPopT">{{ t('GEV Stories') }}</h2>
|
||||
<p>{{ t('Curated, interactive views of what is happening on Earth. Play one, take over the map whenever you like, then pick the story back up.') }}</p>
|
||||
<div class="row">
|
||||
<UiButton class="tbtn solid" @click="openExplore">{{ t('Browse stories') }}</UiButton>
|
||||
<UiButton class="tbtn" @click="markPopSeen">{{ t('Not now') }}</UiButton>
|
||||
<button class="tbtn solid" type="button" @click="openExplore">{{ t('Browse stories') }}</button>
|
||||
<button class="tbtn" type="button" @click="markPopSeen">{{ t('Not now') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="openedToast" id="hToast" class="h-toast glass gs-opened-toast" role="status">
|
||||
<b>{{ t('Opened in GEV') }}</b>
|
||||
<span>{{ openedToast.title }} · {{ openedWhen }}</span>
|
||||
<UiButton class="tbtn" @click="backToStory">{{ t('Back to story') }}</UiButton>
|
||||
<button class="tbtn" type="button" @click="backToStory">{{ t('Back to story') }}</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -3,9 +3,7 @@ import { storeToRefs } from 'pinia';
|
||||
import { nextTick, ref, watch } from 'vue';
|
||||
import { msg, t } from '../../i18n/index.js';
|
||||
import { FIRST_RUN_LINKS, environmentalLabel } from '../../firstRunCopy.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiCheckbox from '../kit/UiCheckbox.vue';
|
||||
import UiIcon from '../kit/UiIcon.vue';
|
||||
import { useFirstRunStore } from '../stores/firstRun.js';
|
||||
import { useStoriesStore } from '../stores/stories.js';
|
||||
|
||||
@@ -167,10 +165,10 @@ function onSuppress(event) {
|
||||
<!-- A button, not just a hint: phones and tablets have no ESC key. It
|
||||
closes exactly as ESC does, for this session only. Touch screens
|
||||
see SKIP; a keyboard sees SKIP · ESC (first-run.css). -->
|
||||
<UiButton class="first-run-dismiss" data-first-run-dismiss @click="controls?.dismiss()">
|
||||
<button type="button" class="first-run-dismiss" data-first-run-dismiss @click="controls?.dismiss()">
|
||||
<span class="first-run-dismiss-key">{{ t('SKIP · ESC') }}</span>
|
||||
<span class="first-run-dismiss-touch">{{ t('SKIP') }}</span>
|
||||
</UiButton>
|
||||
</button>
|
||||
</header>
|
||||
<h2 id="first-run-title">{{ t(TITLES[step - 1]) }}</h2>
|
||||
<p class="first-run-step-announcement" role="status" aria-live="polite" aria-atomic="true">{{ t(TITLES[step - 1]) }}</p>
|
||||
@@ -209,22 +207,22 @@ function onSuppress(event) {
|
||||
<section class="first-run-section" aria-labelledby="first-run-start-heading">
|
||||
<h3 id="first-run-start-heading" class="first-run-section-title">{{ t('Start with') }}</h3>
|
||||
<div class="first-run-missions first-run-missions--tiles" role="group" aria-labelledby="first-run-start-heading">
|
||||
<UiButton data-first-run-start="space-missions" :pressed="start === 'space-missions'" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="selectStart('space-missions')">
|
||||
<UiIcon name="rocket_launch" :size="null" />
|
||||
<button type="button" data-first-run-start="space-missions" :aria-pressed="String(start === 'space-missions')" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="selectStart('space-missions')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">rocket_launch</span>
|
||||
<span><strong>{{ t('SPACE MISSIONS') }}</strong><small>{{ t('Launches, spacecraft and orbital context') }}</small></span>
|
||||
</UiButton>
|
||||
<UiButton data-first-run-start="environmental" :pressed="start === 'environmental'" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="selectStart('environmental')">
|
||||
<UiIcon name="local_fire_department" :size="null" />
|
||||
</button>
|
||||
<button type="button" data-first-run-start="environmental" :aria-pressed="String(start === 'environmental')" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="selectStart('environmental')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">local_fire_department</span>
|
||||
<!-- The title is ENVIRONMENTAL_LABEL_CHOICE's label once initialized. -->
|
||||
<!-- Subcopy names BOTH feeds this tile turns on, because the launcher
|
||||
optimizes for the fully configured experience (owner ruling,
|
||||
2026-08-23) — see the mission table in src/firstRunExperience.js. -->
|
||||
<span><strong data-first-run-environmental-title>{{ launcher?.environmentalTitle ?? environmentalLabel().title }}</strong><small>{{ launcher?.environmentalSub ?? t(ENVIRONMENTAL_SUB) }}</small></span>
|
||||
</UiButton>
|
||||
<UiButton data-first-run-start="explore" :pressed="start === 'explore'" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="selectStart('explore')">
|
||||
<UiIcon name="public" :size="null" />
|
||||
</button>
|
||||
<button type="button" data-first-run-start="explore" :aria-pressed="String(start === 'explore')" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="selectStart('explore')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">public</span>
|
||||
<span><strong>{{ t('EXPLORE MANUALLY') }}</strong><small>{{ t('Begin with a clean globe') }}</small></span>
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -232,17 +230,17 @@ function onSuppress(event) {
|
||||
<div v-else key="3" class="first-run-step">
|
||||
<ul class="first-run-tips">
|
||||
<li class="first-run-tip first-run-tip--search">
|
||||
<span class="first-run-tip-art" aria-hidden="true"><UiIcon name="search" :size="null" /><i class="first-run-tip-caret"></i></span>
|
||||
<span class="first-run-tip-art" aria-hidden="true"><span class="material-symbols-outlined">search</span><i class="first-run-tip-caret"></i></span>
|
||||
<strong>{{ t('Search places') }}</strong>
|
||||
<small>{{ t('Type a place into the search bar.') }}</small>
|
||||
</li>
|
||||
<li class="first-run-tip first-run-tip--layers">
|
||||
<span class="first-run-tip-art" aria-hidden="true"><UiIcon name="layers" :size="null" /><i class="first-run-tip-dot"></i></span>
|
||||
<span class="first-run-tip-art" aria-hidden="true"><span class="material-symbols-outlined">layers</span><i class="first-run-tip-dot"></i></span>
|
||||
<strong>{{ t('Turn on layers') }}</strong>
|
||||
<small>{{ t('Turn layers on to see flights, ships, cameras, weather and more.') }}</small>
|
||||
</li>
|
||||
<li class="first-run-tip first-run-tip--context">
|
||||
<span class="first-run-tip-art" aria-hidden="true"><UiIcon name="my_location" :size="null" /><i class="first-run-tip-ring"></i></span>
|
||||
<span class="first-run-tip-art" aria-hidden="true"><span class="material-symbols-outlined">my_location</span><i class="first-run-tip-ring"></i></span>
|
||||
<strong>{{ t('Click anything') }}</strong>
|
||||
<small>{{ t('Select a map item to see its details.') }}</small>
|
||||
</li>
|
||||
@@ -250,12 +248,12 @@ function onSuppress(event) {
|
||||
<section class="first-run-section" aria-labelledby="first-run-deeper-heading">
|
||||
<h3 id="first-run-deeper-heading" class="first-run-section-title">{{ t('Go deeper') }}</h3>
|
||||
<div v-if="stories.available" class="first-run-link-card first-run-stories">
|
||||
<div class="first-run-preview first-run-preview--stories" aria-hidden="true"><UiIcon name="movie" :size="null" /></div>
|
||||
<div class="first-run-preview first-run-preview--stories" aria-hidden="true"><span class="material-symbols-outlined">movie</span></div>
|
||||
<div class="first-run-link-body">
|
||||
<p class="first-run-mode-title"><strong translate="no">GEV Stories</strong> <span class="first-run-tag">{{ t('NEW') }}</span></p>
|
||||
<p class="first-run-mode-copy">{{ t('Curated, interactive views of what is happening on Earth. Play one, take over the map whenever you like, then pick the story back up.') }}</p>
|
||||
</div>
|
||||
<UiButton class="first-run-link-button" data-first-run-stories :aria-disabled="String(settling || launcher?.busy === 'true')" @click="openStories">{{ t('BROWSE STORIES') }}</UiButton>
|
||||
<button type="button" class="first-run-link-button" data-first-run-stories :aria-disabled="String(settling || launcher?.busy === 'true')" @click="openStories">{{ t('BROWSE STORIES') }}</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -306,10 +304,10 @@ function onSuppress(event) {
|
||||
<p class="first-run-note" data-first-run-status role="status" aria-live="polite">{{ launcher?.status ?? '' }}</p>
|
||||
<!-- The card's main action: God mode, starting where the selected tile
|
||||
says (a clean globe by default). -->
|
||||
<UiButton v-if="step > 1" class="first-run-back" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="go(step - 1, $event)">{{ t('BACK') }}</UiButton>
|
||||
<UiButton class="first-run-enter" :data-first-run-choice="step === STEPS ? start : undefined" :data-first-run-next="step < STEPS ? '' : undefined" data-first-run-primary aria-describedby="first-run-title first-run-description" @pointerdown="onPrimaryDown" @keydown.enter="onPrimaryKeydown" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="onPrimary">
|
||||
{{ step < STEPS ? t('NEXT') : t('ENTER GOD MODE') }} <UiIcon name="arrow_forward" :size="null" />
|
||||
</UiButton>
|
||||
<button v-if="step > 1" type="button" class="first-run-back" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="go(step - 1, $event)">{{ t('BACK') }}</button>
|
||||
<button type="button" class="first-run-enter" :data-first-run-choice="step === STEPS ? start : undefined" :data-first-run-next="step < STEPS ? '' : undefined" data-first-run-primary aria-describedby="first-run-title first-run-description" @pointerdown="onPrimaryDown" @keydown.enter="onPrimaryKeydown" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="onPrimary">
|
||||
{{ step < STEPS ? t('NEXT') : t('ENTER GOD MODE') }} <span class="material-symbols-outlined" aria-hidden="true">arrow_forward</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</aside>
|
||||
|
||||
@@ -4,9 +4,7 @@ import { storeToRefs } from 'pinia';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useCctvStore } from '../../stores/cctv.js';
|
||||
import { usePanelChromeStore } from '../../stores/panelChrome.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiCloseButton from '../../kit/UiCloseButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
|
||||
// A selected camera's card: a thumbnail of its latest frame, a few facts,
|
||||
// and a button that opens the full CCTV panel. The frame and facts come from
|
||||
@@ -70,15 +68,15 @@ function openPanel() {
|
||||
<img v-if="src" :src="src" :alt="name || t('Camera frame')" />
|
||||
<span v-else>{{ t('Acquiring frame…') }}</span>
|
||||
<span v-if="sourceBadge?.label" class="cctv-preview__badge">{{ sourceBadge.label }}</span>
|
||||
<UiButton v-if="src" class="cctv-preview__expand" :label="t('Show a bigger view')" @click="big = true">
|
||||
<UiIcon name="open_in_full" :size="null" />
|
||||
</UiButton>
|
||||
<button v-if="src" type="button" class="cctv-preview__expand" :aria-label="t('Show a bigger view')" :title="t('Show a bigger view')" @click="big = true">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">open_in_full</span>
|
||||
</button>
|
||||
</div>
|
||||
<Teleport to="body">
|
||||
<div v-if="big" class="cctv-popup" role="dialog" :aria-label="name || t('Camera view')" @click.self="big = false">
|
||||
<figure class="cctv-popup__card">
|
||||
<header class="cctv-popup__head">
|
||||
<UiIcon name="videocam" :size="null" />
|
||||
<span class="material-symbols-outlined" aria-hidden="true">videocam</span>
|
||||
<strong>{{ name || t('Camera view') }}</strong>
|
||||
<span v-if="sourceBadge?.label" class="cctv-popup__badge">{{ sourceBadge.label }}</span>
|
||||
<UiCloseButton class="cctv-popup__close" glyph="icon" :label="t('Close')" @click="big = false" />
|
||||
@@ -96,8 +94,8 @@ function openPanel() {
|
||||
<dd>{{ fact.value }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<UiButton class="entity-card__action cctv-preview__more" @click="openPanel">
|
||||
<UiIcon name="videocam" :size="null" />{{ t('More info') }}
|
||||
</UiButton>
|
||||
<button type="button" class="entity-card__action cctv-preview__more" @click="openPanel">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">videocam</span>{{ t('More info') }}
|
||||
</button>
|
||||
</section>
|
||||
</template>
|
||||
@@ -12,7 +12,6 @@ import UiSlider from '../../kit/UiSlider.js';
|
||||
import { useDisplayStore } from '../../stores/display.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiCheckbox from '../../kit/UiCheckbox.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
import UiSelect from '../../kit/UiSelect.js';
|
||||
import { StyleParameterRows } from '../../styleParameters.js';
|
||||
import VisualPresets from './VisualPresets.vue';
|
||||
@@ -86,10 +85,10 @@ const allocationOptions = computed(() => [
|
||||
<p class="pp-section-heading">{{ t('Overlay') }}</p>
|
||||
<Teleport :to="cockpitPortal?.hud ?? 'body'" :disabled="!cockpitPortal?.hud">
|
||||
<div class="pp-toggle-group">
|
||||
<UiButton class="pp-toggle-btn" :pressed="Boolean(hud?.visible)" pressed-class="active" id="hud-toggle" @click="act('toggleHud')" :title="t('Intelligence HUD (H)')">
|
||||
<button class="pp-toggle-btn" :class="{ active: hud?.visible }" :aria-pressed="String(Boolean(hud?.visible))" id="hud-toggle" @click="act('toggleHud')" :title="t('Intelligence HUD (H)')">
|
||||
<span class="pp-icon">◎</span>
|
||||
<span class="pp-label" translate="no">HUD</span>
|
||||
</UiButton>
|
||||
</button>
|
||||
<div class="pp-slider-row" :class="{ visible: hud?.visible }" id="hud-layout-row">
|
||||
<span class="pp-slider-mini-label">{{ t('Layout') }}</span>
|
||||
<UiSelect id="hud-layout-select" class="pp-select gev-field gev-field--compact" :model-value="hud?.variant ?? 'tactical'" @update:model-value="act('setHudLayout', $event)" :aria-label="t('HUD layout')">
|
||||
@@ -185,7 +184,7 @@ const allocationOptions = computed(() => [
|
||||
</Teleport>
|
||||
<div class="pp-toggle-group">
|
||||
<UiCheckbox class="pp-toggle-btn pp-scope-toggle" :title="t('Scope — the circular viewport mask')" input-id="scope-toggle" trailing :model-value="scopeOn" @update:model-value="act('setScopeEnabled', $event)">
|
||||
<UiIcon class="pp-icon" name="adjust" :size="null" />
|
||||
<span class="pp-icon material-symbols-outlined" aria-hidden="true">adjust</span>
|
||||
<span class="pp-label">{{ t('Scope') }}</span>
|
||||
</UiCheckbox>
|
||||
<div class="pp-slider-row visible" id="scope-slider-row">
|
||||
@@ -199,21 +198,21 @@ const allocationOptions = computed(() => [
|
||||
<span class="pp-slider-value" id="scope-opacity-value">{{ pct(scopeOpacity) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<UiButton class="pp-toggle-btn" id="clean-view-toggle" @click="act('toggleCleanView')" :title="t('Hide UI chrome')">
|
||||
<button class="pp-toggle-btn" id="clean-view-toggle" @click="act('toggleCleanView')" :title="t('Hide UI chrome')">
|
||||
<span class="pp-icon">□</span>
|
||||
<span class="pp-label">{{ t('Clean UI') }}</span>
|
||||
</UiButton>
|
||||
</button>
|
||||
<p class="pp-section-heading">{{ t('Effects') }}</p>
|
||||
<div class="pp-toggle-group">
|
||||
<UiButton class="pp-toggle-btn" :pressed="celestial?.active ?? false" pressed-class="active" id="celestial-toggle" @click="act('toggleCelestial')" :title="celestialTitle" :disabled="celestial ? !celestial.supported : undefined" :aria-disabled="celestial ? String(!celestial.supported) : undefined">
|
||||
<UiIcon class="pp-icon" name="flare" :size="null" />
|
||||
<span class="pp-icon material-symbols-outlined" aria-hidden="true">flare</span>
|
||||
<span class="pp-label">{{ t('Celestial') }}</span>
|
||||
</UiButton>
|
||||
</div>
|
||||
<!-- Sky: only where the renderer has a sky to set. -->
|
||||
<div v-if="sky" class="pp-toggle-group" id="sky-group">
|
||||
<UiCheckbox v-for="row in skyRows" :key="row.key" class="pp-toggle-btn pp-scope-toggle" :id="`sky-${row.key}-row`" :input-id="`sky-${row.key}-toggle`" trailing :model-value="sky.switches[row.key]" @update:model-value="act('setSkySwitch', row.key, $event)">
|
||||
<UiIcon class="pp-icon" :name="row.icon" :size="null" />
|
||||
<span class="pp-icon material-symbols-outlined" aria-hidden="true">{{ row.icon }}</span>
|
||||
<span class="pp-label">{{ row.label }}</span>
|
||||
</UiCheckbox>
|
||||
<div class="pp-slider-row visible" id="sky-milkyway-row">
|
||||
@@ -226,7 +225,7 @@ const allocationOptions = computed(() => [
|
||||
<div v-for="group in groups" :key="group.id" class="pp-toggle-group" :id="`${group.id}-group`">
|
||||
<template v-for="row in group.rows" :key="row.id">
|
||||
<UiCheckbox v-if="row.kind === 'toggle'" class="pp-toggle-btn pp-scope-toggle" :title="row.title" :input-id="`${group.id}-${row.id}-toggle`" trailing :model-value="row.checked" @update:model-value="row.onChange?.($event)">
|
||||
<UiIcon v-if="row.icon" class="pp-icon" :name="row.icon" :size="null" />
|
||||
<span v-if="row.icon" class="pp-icon material-symbols-outlined" aria-hidden="true">{{ row.icon }}</span>
|
||||
<span class="pp-label">{{ row.label }}</span>
|
||||
</UiCheckbox>
|
||||
<div v-else-if="row.kind === 'note'" class="pp-slider-row visible" :id="`${group.id}-${row.id}`">
|
||||
@@ -240,28 +239,28 @@ const allocationOptions = computed(() => [
|
||||
</template>
|
||||
</div>
|
||||
<div class="pp-toggle-group">
|
||||
<UiButton class="pp-toggle-btn" :pressed="Boolean(view?.bloom.active)" pressed-class="active" id="bloom-toggle" @click="act('toggleBloom')" :title="t('Bloom / Glow')">
|
||||
<button class="pp-toggle-btn" :class="{ active: view?.bloom.active }" :aria-pressed="String(Boolean(view?.bloom.active))" id="bloom-toggle" @click="act('toggleBloom')" :title="t('Bloom / Glow')">
|
||||
<span class="pp-icon">✨</span>
|
||||
<span class="pp-label">{{ t('Bloom') }}</span>
|
||||
</UiButton>
|
||||
</button>
|
||||
<div class="pp-slider-row" :class="{ visible: view?.bloom.active }" id="bloom-slider-row">
|
||||
<UiSlider class="pp-slider" id="bloom-intensity-slider" @update:model-value="act('setBloomIntensity', $event)" min="0" max="200" :model-value="view?.bloom.intensity ?? 0" :aria-label="t('Bloom intensity')" />
|
||||
<span class="pp-slider-value" id="bloom-intensity-value">{{ pct(view?.bloom.intensity ?? 0) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pp-toggle-group">
|
||||
<UiButton class="pp-toggle-btn" :pressed="Boolean(view?.sharpen.active)" pressed-class="active" id="sharpen-toggle" @click="act('toggleSharpen')" :title="t('Sharpening')">
|
||||
<button class="pp-toggle-btn" :class="{ active: view?.sharpen.active }" :aria-pressed="String(Boolean(view?.sharpen.active))" id="sharpen-toggle" @click="act('toggleSharpen')" :title="t('Sharpening')">
|
||||
<span class="pp-icon">🔍</span>
|
||||
<span class="pp-label">{{ t('Sharpen') }}</span>
|
||||
</UiButton>
|
||||
</button>
|
||||
<div class="pp-slider-row" :class="{ visible: view?.sharpen.active }" id="sharpen-slider-row">
|
||||
<UiSlider class="pp-slider" id="sharpen-intensity-slider" @update:model-value="act('setSharpenIntensity', $event)" min="0" max="100" :model-value="view?.sharpen.intensity ?? 49" :aria-label="t('Sharpen intensity')" />
|
||||
<span class="pp-slider-value" id="sharpen-intensity-value">{{ pct(view?.sharpen.intensity ?? 49) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<UiButton class="pp-reset-btn" :title="t('Reset Visual to its defaults: Normal look, HUD, scope, labels and effects')" @click="act('resetVisual')">
|
||||
<UiIcon name="restart_alt" :size="null" />{{ t('Reset to default') }}
|
||||
</UiButton>
|
||||
<button type="button" class="pp-reset-btn" :title="t('Reset Visual to its defaults: Normal look, HUD, scope, labels and effects')" @click="act('resetVisual')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">restart_alt</span>{{ t('Reset to default') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -10,9 +10,7 @@ import AltitudeGraph from './AltitudeGraph.vue';
|
||||
import { contextNeedle, contextSearchText, matchesContextSearch } from '../../contextSearch.js';
|
||||
import RouteGlobe from './RouteGlobe.vue';
|
||||
import CctvPreview from './CctvPreview.vue';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiCloseButton from '../../kit/UiCloseButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
import { useCctvStore } from '../../stores/cctv.js';
|
||||
import SpotConditions from './SpotConditions.vue';
|
||||
import { shownLayerName } from '../../layerNames.js';
|
||||
@@ -367,10 +365,10 @@ watch(
|
||||
<AircraftModelHero v-if="modelKnown" :key="card.key" class="entity-hero__layer" :class="{ 'is-shown': activeFlightPreview === 'model' }" :active="activeFlightPreview === 'model'" :aircraft="card.aircraftModel" :heading="card.heading || 0" :callouts="callouts" @failed="modelFailed = true" @cycle="showOtherView" />
|
||||
<FlightCockpitView v-if="cockpitMade && cockpitKnown" :key="`cockpit-${card.key}`" class="entity-hero__layer" :class="{ 'is-shown': activeFlightPreview === 'cockpit' }" :active="activeFlightPreview === 'cockpit'" :lat="card.lat" :lon="card.lon" :altitude-m="card.altitudeM" :heading="card.heading" :speed-mps="card.speedMps" @failed="onCockpitFailed" />
|
||||
<div v-if="cockpitKnown || (routeKnown && modelKnown) || (photoAvailable && (routeKnown || modelKnown))" class="entity-card__preview-switch" role="group" :aria-label="t('Preview')">
|
||||
<UiButton v-if="photoAvailable" :pressed="activeFlightPreview === 'photo'" pressed-class="active" :label="t('Photos')" @click="choosePreview('photo')"><UiIcon name="photo_camera" :size="null" /></UiButton>
|
||||
<UiButton v-if="routeKnown" :pressed="activeFlightPreview === 'route'" pressed-class="active" :label="t('Route')" @click="choosePreview('route')"><UiIcon name="timeline" :size="null" /></UiButton>
|
||||
<UiButton v-if="modelKnown" :pressed="activeFlightPreview === 'model'" pressed-class="active" :title="t('3D model')" @click="choosePreview('model')">{{ t('3D') }}</UiButton>
|
||||
<UiButton v-if="cockpitKnown" :pressed="activeFlightPreview === 'cockpit'" pressed-class="active" :label="t('Cockpit view')" @click="choosePreview('cockpit')"><UiIcon name="visibility" :size="null" /></UiButton>
|
||||
<button v-if="photoAvailable" type="button" :class="{ active: activeFlightPreview === 'photo' }" :aria-pressed="String(activeFlightPreview === 'photo')" :aria-label="t('Photos')" :title="t('Photos')" @click="choosePreview('photo')"><span class="material-symbols-outlined" aria-hidden="true">photo_camera</span></button>
|
||||
<button v-if="routeKnown" type="button" :class="{ active: activeFlightPreview === 'route' }" :aria-pressed="String(activeFlightPreview === 'route')" :aria-label="t('Route')" :title="t('Route')" @click="choosePreview('route')"><span class="material-symbols-outlined" aria-hidden="true">timeline</span></button>
|
||||
<button v-if="modelKnown" type="button" :class="{ active: activeFlightPreview === 'model' }" :aria-pressed="String(activeFlightPreview === 'model')" :title="t('3D model')" @click="choosePreview('model')">{{ t('3D') }}</button>
|
||||
<button v-if="cockpitKnown" type="button" :class="{ active: activeFlightPreview === 'cockpit' }" :aria-pressed="String(activeFlightPreview === 'cockpit')" :aria-label="t('Cockpit view')" :title="t('Cockpit view')" @click="choosePreview('cockpit')"><span class="material-symbols-outlined" aria-hidden="true">visibility</span></button>
|
||||
</div>
|
||||
</template>
|
||||
<a v-else-if="heroKind === 'photo'" :key="photo.src" class="entity-hero__layer entity-hero__photo is-shown" :href="photo.link || undefined" target="_blank" rel="noopener">
|
||||
@@ -381,7 +379,7 @@ watch(
|
||||
<CctvPreview v-else-if="heroKind === 'camera'" :camera-id="card.identity?.id || ''" />
|
||||
<!-- No imagery for it yet: its icon, with its headline figures beside it. -->
|
||||
<div v-else class="entity-hero__placeholder" :class="{ 'entity-hero__placeholder--bare': props.withContacts || !tiles.length }">
|
||||
<UiIcon class="entity-hero__glyph" :name="card.icon" :size="null" />
|
||||
<span class="material-symbols-outlined entity-hero__glyph" aria-hidden="true">{{ card.icon }}</span>
|
||||
<div v-if="!props.withContacts && tiles.length" class="entity-hero__figures">
|
||||
<div v-for="fact in tiles" :key="fact.field" class="entity-hero__figure">
|
||||
<strong>{{ factFigure(fact).number }}<small v-if="factFigure(fact).unit">{{ factFigure(fact).unit }}</small></strong>
|
||||
@@ -393,7 +391,7 @@ watch(
|
||||
</div>
|
||||
|
||||
<header class="entity-card__head">
|
||||
<UiIcon class="entity-card__icon" :name="card.icon" :size="null" />
|
||||
<span class="material-symbols-outlined entity-card__icon" aria-hidden="true">{{ card.icon }}</span>
|
||||
<div class="entity-card__name">
|
||||
<span class="entity-card__kind">{{ kindLine }}</span>
|
||||
<h3 class="entity-card__title">{{ shownTitle }}</h3>
|
||||
@@ -408,14 +406,14 @@ watch(
|
||||
</div>
|
||||
|
||||
<div v-if="card.warnings?.length" class="entity-card__warning" role="alert">
|
||||
<UiIcon name="warning" :size="null" />
|
||||
<span class="material-symbols-outlined" aria-hidden="true">warning</span>
|
||||
<span>{{ card.warnings.map((warning, index) => sayWords(card.warningWords?.[index], warning)).join(' · ') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="card.route" class="entity-card__route" :class="{ 'entity-card__route--unverified': !card.route.verified, 'entity-card__route--progress': routeProgress }">
|
||||
<strong>{{ card.route.from }}</strong>
|
||||
<span class="entity-card__route-line" :style="routeProgress ? { '--route-share': `${(routeProgress.share * 100).toFixed(1)}%` } : null" aria-hidden="true">
|
||||
<UiIcon name="flight" :size="null" />
|
||||
<span class="material-symbols-outlined">flight</span>
|
||||
</span>
|
||||
<strong>{{ card.route.to }}</strong>
|
||||
</div>
|
||||
@@ -437,7 +435,7 @@ watch(
|
||||
class="entity-card__route-note"
|
||||
:title="t('The scheduled route for this flight number does not match where the plane is; it may be another leg of the same flight.')"
|
||||
>
|
||||
<UiIcon name="warning" :size="null" />{{ t('Scheduled · unverified: does not match where the plane is') }}
|
||||
<span class="material-symbols-outlined" aria-hidden="true">warning</span>{{ t('Scheduled · unverified: does not match where the plane is') }}
|
||||
</p>
|
||||
|
||||
<div v-if="!props.withContacts && tiles.length && heroKind !== 'none' && !contextNeedle" class="entity-card__tiles" :style="{ gridTemplateColumns: `repeat(${tiles.length}, minmax(0, 1fr))` }">
|
||||
@@ -464,21 +462,20 @@ watch(
|
||||
|
||||
<div class="entity-card__actions">
|
||||
<!-- On an aircraft or a satellite, Cockpit leads: it is the action people come for. -->
|
||||
<UiButton v-if="store.canCockpit()" class="entity-card__action entity-card__action--primary" data-entity-cockpit-entry @click="store.cockpit()">
|
||||
<UiIcon :name="card.layerId === 'satellites' ? 'satellite_alt' : 'flight'" :size="null" />{{ card.layerId === 'satellites' ? t('Enter orbital view') : t('Enter Cockpit') }}
|
||||
</UiButton>
|
||||
<button v-if="store.canCockpit()" type="button" class="entity-card__action entity-card__action--primary" data-entity-cockpit-entry @click="store.cockpit()">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ card.layerId === 'satellites' ? 'satellite_alt' : 'flight' }}</span>{{ card.layerId === 'satellites' ? t('Enter orbital view') : t('Enter Cockpit') }}
|
||||
</button>
|
||||
<div class="entity-card__action-row">
|
||||
<UiButton class="entity-card__action" @click="store.flyTo()">
|
||||
<UiIcon name="my_location" :size="null" />{{ t('Fly to') }}
|
||||
</UiButton>
|
||||
<UiButton v-if="store.canFollow()" class="entity-card__action" :pressed="Boolean(store.isFollowing())" pressed-class="entity-card__action--on" @click="store.follow()">
|
||||
<UiIcon name="navigation" :size="null" />{{ store.isFollowing() ? t('Following') : t('Follow') }}
|
||||
</UiButton>
|
||||
<button type="button" class="entity-card__action" @click="store.flyTo()">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">my_location</span>{{ t('Fly to') }}
|
||||
</button>
|
||||
<button v-if="store.canFollow()" type="button" class="entity-card__action" :class="{ 'entity-card__action--on': store.isFollowing() }" :aria-pressed="String(store.isFollowing())" @click="store.follow()">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">navigation</span>{{ store.isFollowing() ? t('Following') : t('Follow') }}
|
||||
</button>
|
||||
</div>
|
||||
<!-- The chat bubble is no Material symbol the page loads, so it stays drawn. -->
|
||||
<UiButton class="entity-card__action entity-card__action--ask" @click="store.ask()">
|
||||
<button type="button" class="entity-card__action entity-card__action--ask" @click="store.ask()">
|
||||
<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path d="M4 5h16v11H9l-5 4z" /></svg>{{ t('Ask GEV about {name}', { name: shownTitle }) }}
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<slot />
|
||||
|
||||
@@ -22,8 +22,6 @@ const finder = {
|
||||
<script setup>
|
||||
import { nextTick, onBeforeUnmount, onMounted, ref, watch, computed } from 'vue';
|
||||
import { msg, t } from '../../../i18n/index.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
import UiSearchField from '../../kit/UiSearchField.vue';
|
||||
|
||||
// Search and filter for the Data Layers list. The rows are rendered elsewhere
|
||||
@@ -187,8 +185,7 @@ async function toggleFilter() {
|
||||
}
|
||||
function closeFilter({ refocus = false } = {}) {
|
||||
filtering.value = false;
|
||||
// The trigger is a UiButton; its root is the button.
|
||||
if (refocus) triggerEl.value?.$el?.focus();
|
||||
if (refocus) triggerEl.value?.focus();
|
||||
}
|
||||
function onMenuKey(event) {
|
||||
if (event.key === 'Escape') {
|
||||
@@ -226,37 +223,37 @@ if (props.part === 'buttons') {
|
||||
|
||||
<template>
|
||||
<template v-if="part === 'buttons'">
|
||||
<UiButton id="layer-finder-search-btn" class="layer-finder__btn" :class="{ active: searching || query }" :pressed="Boolean(searching)" :aria-label="t('Search layers')" :title="t('Search layers')" @click="toggleSearch">
|
||||
<UiIcon name="search" :size="null" />
|
||||
</UiButton>
|
||||
<button id="layer-finder-search-btn" type="button" class="layer-finder__btn" :class="{ active: searching || query }" :aria-pressed="String(searching)" :aria-label="t('Search layers')" :title="t('Search layers')" @click="toggleSearch">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">search</span>
|
||||
</button>
|
||||
<span ref="filterEl" class="layer-finder__filter">
|
||||
<UiButton ref="triggerEl" class="layer-finder__btn" :class="{ active: show !== 'all' || category }" :aria-expanded="String(filtering)" aria-controls="layer-finder-menu" :aria-label="t('Filter layers')" :title="t('Filter layers')" @click="toggleFilter">
|
||||
<UiIcon name="filter_list" :size="null" />
|
||||
</UiButton>
|
||||
<button ref="triggerEl" type="button" class="layer-finder__btn" :class="{ active: show !== 'all' || category }" :aria-expanded="String(filtering)" aria-controls="layer-finder-menu" :aria-label="t('Filter layers')" :title="t('Filter layers')" @click="toggleFilter">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">filter_list</span>
|
||||
</button>
|
||||
<span v-if="filtering" id="layer-finder-menu" ref="menuEl" class="layer-finder__menu" role="group" :aria-label="t('Filter layers')" @keydown="onMenuKey">
|
||||
<span role="group" :aria-label="t('Status')">
|
||||
<span class="layer-finder__menu-head" aria-hidden="true">{{ t('Status') }}</span>
|
||||
<UiButton v-for="s in SHOWS" :key="s.id" :pressed="show === s.id" pressed-class="active" @click="show = s.id">
|
||||
<UiIcon :name="show === s.id ? 'radio_button_checked' : 'radio_button_unchecked'" :size="null" />{{ t(s.label) }}
|
||||
</UiButton>
|
||||
<button v-for="s in SHOWS" :key="s.id" type="button" :aria-pressed="String(show === s.id)" :class="{ active: show === s.id }" @click="show = s.id">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ show === s.id ? 'radio_button_checked' : 'radio_button_unchecked' }}</span>{{ t(s.label) }}
|
||||
</button>
|
||||
</span>
|
||||
<span v-if="categories.length" role="group" :aria-label="t('Category')">
|
||||
<span class="layer-finder__menu-head" aria-hidden="true">{{ t('Category') }}</span>
|
||||
<UiButton v-for="c in categories" :key="c.key" :pressed="category === c.key" pressed-class="active" @click="pickCategory(c.key)">
|
||||
<UiIcon :name="category === c.key ? 'radio_button_checked' : 'radio_button_unchecked'" :size="null" />{{ c.label }}
|
||||
</UiButton>
|
||||
<button v-for="c in categories" :key="c.key" type="button" :aria-pressed="String(category === c.key)" :class="{ active: category === c.key }" @click="pickCategory(c.key)">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ category === c.key ? 'radio_button_checked' : 'radio_button_unchecked' }}</span>{{ c.label }}
|
||||
</button>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
<div v-else-if="searching || narrowed" class="layer-finder__bar">
|
||||
<UiSearchField v-if="searching" v-model="query" tag="label" class="layer-finder__field" input-id="layer-finder-input" :label="t('Search layers')" :placeholder="t('Search layers…')" @escape="(event) => { event.preventDefault(); closeSearch(); }" />
|
||||
<UiButton v-if="show !== 'all'" class="layer-finder__chip" @click="show = 'all'">
|
||||
{{ show === 'on' ? t('On') : t('Off') }}<UiIcon name="close" :size="null" />
|
||||
</UiButton>
|
||||
<UiButton v-if="category" class="layer-finder__chip" @click="category = ''">
|
||||
{{ categoryLabel }}<UiIcon name="close" :size="null" />
|
||||
</UiButton>
|
||||
<button v-if="show !== 'all'" type="button" class="layer-finder__chip" @click="show = 'all'">
|
||||
{{ show === 'on' ? t('On') : t('Off') }}<span class="material-symbols-outlined" aria-hidden="true">close</span>
|
||||
</button>
|
||||
<button v-if="category" type="button" class="layer-finder__chip" @click="category = ''">
|
||||
{{ categoryLabel }}<span class="material-symbols-outlined" aria-hidden="true">close</span>
|
||||
</button>
|
||||
<p v-if="narrowed && shown === 0" class="layer-finder__empty" role="status">{{ t('No layers match') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -16,8 +16,6 @@ import { useGlobeActionsStore } from '../../stores/globeActions.js';
|
||||
import { useLocationStore } from '../../stores/location.js';
|
||||
import { useOmnibarStore } from '../../stores/omnibar.js';
|
||||
import { useVoiceStore } from '../../stores/voice.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
|
||||
// One field for places, layers and questions. Places run through the location
|
||||
// controls, layers through the shell's omnibar actions, and anything else can
|
||||
@@ -1030,7 +1028,7 @@ watch(
|
||||
<section id="gev-omnibar" :class="{ 'has-results': showResults }" :aria-label="t('Search')">
|
||||
<div class="omnibar-field">
|
||||
<span class="omnibar-edge" aria-hidden="true"></span>
|
||||
<UiIcon class="omnibar-search-icon" name="search" :size="null" />
|
||||
<span class="material-symbols-outlined omnibar-search-icon" aria-hidden="true">search</span>
|
||||
<input
|
||||
ref="input"
|
||||
id="gev-omnibar-input"
|
||||
@@ -1057,9 +1055,9 @@ watch(
|
||||
@blur="focused = false"
|
||||
/>
|
||||
<kbd class="omnibar-kbd" aria-hidden="true">{{ shortcut }}</kbd>
|
||||
<UiButton class="omnibar-mic" :pressed="voiceOn" pressed-class="active" :disabled="!voice.controls" :label="t('Talk to GEV')" @click="onMic(true)">
|
||||
<button type="button" class="omnibar-mic" :class="{ active: voiceOn }" :disabled="!voice.controls" :aria-pressed="String(voiceOn)" :aria-label="t('Talk to GEV')" :title="t('Talk to GEV')" @click="onMic(true)">
|
||||
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="9" y="3" width="6" height="11" rx="3" /><path d="M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21" /></svg>
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
<div v-show="showResults" ref="results" class="omnibar-results" :class="{ 'has-feedback': showFeedback }">
|
||||
<p id="omnibar-error" v-show="showFeedback" role="alert">{{ feedback }}</p>
|
||||
@@ -1067,10 +1065,11 @@ watch(
|
||||
<li v-if="strip" class="omnibar-strip" role="group" :aria-label="strip.title">
|
||||
<span class="omnibar-strip__title" aria-hidden="true">{{ strip.title }}</span>
|
||||
<div ref="stripChips" class="omnibar-strip__chips" role="presentation" @wheel="onStripWheel">
|
||||
<UiButton
|
||||
<button
|
||||
v-for="(chip, index) in strip.chips"
|
||||
:id="`gev-omnibar-chip-${index}`"
|
||||
:key="chip.key"
|
||||
type="button"
|
||||
tabindex="-1"
|
||||
class="omnibar-strip__chip"
|
||||
:class="{ active: chip.pressed, focused: inStrip && index === chipIndex }"
|
||||
@@ -1080,8 +1079,8 @@ watch(
|
||||
@mousedown.prevent
|
||||
@click="chooseChip(chip)"
|
||||
>
|
||||
<UiIcon :name="chip.icon" :size="null" />{{ chip.name }}
|
||||
</UiButton>
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ chip.icon }}</span>{{ chip.name }}
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
<li
|
||||
@@ -1096,7 +1095,7 @@ watch(
|
||||
@click="choose(item)"
|
||||
@mousemove="inStrip = false"
|
||||
>
|
||||
<UiIcon v-if="item.icon" class="omnibar-item-icon" :name="item.icon" :size="null" />
|
||||
<span v-if="item.icon" class="material-symbols-outlined omnibar-item-icon" aria-hidden="true">{{ item.icon }}</span>
|
||||
<svg v-else class="omnibar-item-icon" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path d="M4 5h16v11H9l-5 4z" /></svg>
|
||||
<span class="omnibar-item-label">{{ item.label }}</span>
|
||||
<small>{{ item.hint }}</small>
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
<script setup>
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiCloseButton from '../../kit/UiCloseButton.vue';
|
||||
|
||||
// The Omnibar's guided walk: the spotlight ring and the callout beside it,
|
||||
// teleported to the end of `to` (the page's body). `startGuide()` in
|
||||
// src/ui/omnibarGuide.js owns every decision and every word: it renders this
|
||||
// with the `view` it computes for each step and keeps the parts the template
|
||||
// never binds: the guide's `visible` class, the callout's entrance replay
|
||||
// (its `swap` class), place and side, the ring's and the extra rings' boxes,
|
||||
// and focus. It finds those elements in the rendered tree itself.
|
||||
defineProps({
|
||||
to: { type: Object, required: true },
|
||||
view: { type: Object, required: true },
|
||||
onClose: { type: Function, required: true },
|
||||
onSkip: { type: Function, required: true },
|
||||
onOffer: { type: Function, required: true },
|
||||
onNext: { type: Function, required: true },
|
||||
});
|
||||
|
||||
/** A progress segment's attributes: no class at all for one still to come. */
|
||||
const dot = (name) => (name ? { class: name } : {});
|
||||
</script>
|
||||
|
||||
<!-- Only line breaks inside tags: the markup has no whitespace between elements. -->
|
||||
<template><Teleport :to="to"
|
||||
><div class="gev-guide"
|
||||
><div class="gev-guide-ring"><i></i></div
|
||||
><div
|
||||
class="gev-guide-callout"
|
||||
role="dialog"
|
||||
aria-modal="false"
|
||||
tabindex="-1"
|
||||
aria-labelledby="gev-guide-title"
|
||||
aria-describedby="gev-guide-text"
|
||||
><div class="gev-guide-head"
|
||||
><p id="gev-guide-title" class="gev-guide-title">{{ view.title }}</p
|
||||
><p class="gev-guide-count">{{ view.count }}</p
|
||||
><UiCloseButton
|
||||
class="gev-guide-close"
|
||||
:label="view.endLabel"
|
||||
:title="view.endLabel"
|
||||
@click="onClose()" /></div
|
||||
><ol class="gev-guide-progress" aria-hidden="true"
|
||||
><li
|
||||
v-for="(name, i) in view.progress"
|
||||
:key="`${view.step}-${i}`"
|
||||
v-bind="dot(name)"></li></ol
|
||||
><div class="gev-guide-body"
|
||||
><p id="gev-guide-text" class="gev-guide-text">{{ view.text }}</p
|
||||
><p class="gev-guide-hint" :hidden="view.hintHidden"
|
||||
><span class="gev-guide-hint-dot"></span
|
||||
><span>{{ view.hint }}</span></p
|
||||
></div
|
||||
><div class="gev-guide-actions"
|
||||
><p class="gev-guide-keys" :hidden="view.keysHidden"
|
||||
><kbd>{{ view.keyCap }}</kbd><span>{{ view.keyText }}</span></p
|
||||
><span
|
||||
><UiButton
|
||||
class="gev-guide-skip"
|
||||
:hidden="view.skipHidden"
|
||||
@click="onSkip()"
|
||||
>{{ view.skipLabel }}</UiButton
|
||||
><UiButton
|
||||
class="gev-guide-offer"
|
||||
:hidden="view.offerHidden"
|
||||
@click="onOffer()"
|
||||
>{{ view.offerLabel }}</UiButton
|
||||
><UiButton
|
||||
class="gev-guide-next"
|
||||
:class="{ quiet: view.nextQuiet }"
|
||||
:hidden="view.nextHidden"
|
||||
@click="onNext()"
|
||||
>{{ view.nextLabel }}</UiButton
|
||||
></span
|
||||
></div
|
||||
><p class="gev-guide-status" role="status" aria-live="polite">{{
|
||||
view.status
|
||||
}}</p></div
|
||||
></div
|
||||
></Teleport
|
||||
></template>
|
||||
@@ -1,110 +0,0 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiCloseButton from '../../kit/UiCloseButton.vue';
|
||||
|
||||
// The Québec 511 camera's floating player and its map preview, teleported to
|
||||
// the end of the page. `createQuebecCctvOverlay()` owns every decision: it
|
||||
// renders this with the `view` it computes and keeps the imperative parts,
|
||||
// which the template never binds: each video's source, playback and load, the
|
||||
// panel's dragged position, and the marker's per-frame visibility and place.
|
||||
// The elements those parts need are exposed.
|
||||
defineProps({
|
||||
view: { type: Object, required: true },
|
||||
});
|
||||
const emit = defineEmits([
|
||||
'close',
|
||||
'play',
|
||||
'refresh',
|
||||
'keydown',
|
||||
'headerPointerdown',
|
||||
'liveError',
|
||||
'liveLoadeddata',
|
||||
'stillError',
|
||||
'stillLoadeddata',
|
||||
]);
|
||||
|
||||
const panel = ref(null);
|
||||
const header = ref(null);
|
||||
const close = ref(null);
|
||||
const live = ref(null);
|
||||
const marker = ref(null);
|
||||
const still = ref(null);
|
||||
defineExpose({ panel, header, close, live, marker, still });
|
||||
// Each video's load and failure go to the owner, which marks the source.
|
||||
const liveListeners = {
|
||||
error: () => emit('liveError'),
|
||||
loadeddata: () => emit('liveLoadeddata'),
|
||||
};
|
||||
const stillListeners = {
|
||||
error: () => emit('stillError'),
|
||||
loadeddata: () => emit('stillLoadeddata'),
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- Only line breaks inside tags: the markup has no whitespace between elements. -->
|
||||
<template><Teleport to="body"
|
||||
><section
|
||||
ref="panel"
|
||||
class="qci-panel"
|
||||
:hidden="view.panelHidden"
|
||||
role="region"
|
||||
:aria-label="t('CCTV camera')"
|
||||
@keydown="emit('keydown', $event)"
|
||||
><header
|
||||
ref="header"
|
||||
class="qci-header"
|
||||
@pointerdown="emit('headerPointerdown', $event)"
|
||||
><strong>{{ view.title }}</strong
|
||||
><UiCloseButton
|
||||
ref="close"
|
||||
:label="t('Close camera preview')"
|
||||
@click="emit('close')" /></header
|
||||
><p class="qci-coordinates">{{ view.coordinates }}</p
|
||||
><p class="qci-credit" :hidden="view.creditHidden">{{ view.credit }}</p
|
||||
><video
|
||||
ref="live"
|
||||
class="qci-live"
|
||||
controls
|
||||
muted
|
||||
autoplay
|
||||
loop
|
||||
playsinline
|
||||
:hidden="view.liveHidden"
|
||||
:aria-label="t('CCTV camera')"
|
||||
v-on="liveListeners"></video
|
||||
><div class="qci-actions" :hidden="view.actionsHidden"
|
||||
><UiButton
|
||||
class="qci-play"
|
||||
:hidden="view.playHidden"
|
||||
@click="emit('play')"
|
||||
>{{ t('Play') }}</UiButton
|
||||
><UiButton :hidden="view.refreshHidden" @click="emit('refresh')">{{
|
||||
t('Refresh map still')
|
||||
}}</UiButton></div
|
||||
><p class="qci-note" :hidden="view.noteHidden">{{ view.note }}</p
|
||||
><a
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
:href="view.sourceHref"
|
||||
:hidden="view.sourceHidden"
|
||||
>{{ t("Open this image on the provider's site") }}</a
|
||||
></section
|
||||
><div
|
||||
ref="marker"
|
||||
class="qci-marker"
|
||||
:class="{ 'qci-marker-link-only': view.markerLinkOnly }"
|
||||
hidden
|
||||
><video
|
||||
ref="still"
|
||||
class="qci-marker-still"
|
||||
muted
|
||||
playsinline
|
||||
preload="none"
|
||||
:hidden="view.stillHidden"
|
||||
aria-hidden="true"
|
||||
v-on="stillListeners"></video
|
||||
><span class="qci-marker-label">{{ view.markerLabel }}</span></div
|
||||
></Teleport
|
||||
></template>
|
||||
@@ -5,8 +5,6 @@ import { compassName, hazardsNear, regionalBrief, weatherLook } from '../../spot
|
||||
import { distanceKm } from '../../../data/entityContext.js';
|
||||
import { CONTEXT_RADIUS_STEPS, contextRadiusKm, setContextRadiusKm } from '../../contextRadius.js';
|
||||
import { contextNeedle, matchesContextSearch } from '../../contextSearch.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
import UiSlider from '../../kit/UiSlider.js';
|
||||
import { sayWords, useEntityCardStore } from '../../stores/entityCard.js';
|
||||
import { useOmnibarStore } from '../../stores/omnibar.js';
|
||||
@@ -267,7 +265,7 @@ const sources = computed(() => {
|
||||
<template v-if="entity">
|
||||
<div v-if="weather || entity" class="spot-conditions__weather" :class="{ 'spot-conditions__weather--timed': entity }">
|
||||
<template v-if="weather">
|
||||
<UiIcon class="spot-conditions__weather-icon" :name="look.icon" :size="null" />
|
||||
<span class="material-symbols-outlined spot-conditions__weather-icon" aria-hidden="true">{{ look.icon }}</span>
|
||||
<div class="spot-conditions__weather-now">
|
||||
<strong>{{ round(weather.temperatureC) }}°C</strong>
|
||||
<span>{{ t(look.label) }}<template v-if="Number.isFinite(weather.apparentTemperatureC)"> · {{ t('feels {n}°', { n: round(weather.apparentTemperatureC) }) }}</template></span>
|
||||
@@ -300,18 +298,18 @@ const sources = computed(() => {
|
||||
|
||||
<div v-for="block in trafficBlocks" v-show="!searching || block.items.length" :key="block.id" class="spot-conditions__block">
|
||||
<h4>
|
||||
<UiIcon :name="block.icon" :size="null" />
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ block.icon }}</span>
|
||||
<span>{{ block.title }}</span>
|
||||
<span class="spot-conditions__count">{{ block.count }}</span>
|
||||
</h4>
|
||||
<ul v-if="block.items.length">
|
||||
<li v-for="item in block.items" :key="item.key">
|
||||
<UiButton @click="store.select(item.identity, { fly: true })">
|
||||
<button type="button" @click="store.select(item.identity, { fly: true })">
|
||||
<span class="spot-conditions__row-main">
|
||||
<span class="spot-conditions__row-title">{{ item.title }}</span>
|
||||
</span>
|
||||
<span class="spot-conditions__row-meta">{{ distance(item.distanceKm) }}</span>
|
||||
</UiButton>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-else class="spot-conditions__none">{{ block.none }}</p>
|
||||
@@ -319,14 +317,14 @@ const sources = computed(() => {
|
||||
|
||||
<div v-show="!searching || shownHazards.length" class="spot-conditions__block">
|
||||
<h4>
|
||||
<UiIcon name="warning" :size="null" />
|
||||
<span class="material-symbols-outlined" aria-hidden="true">warning</span>
|
||||
<span>{{ t('Hazards within {radius}', { radius: radiusText }) }}</span>
|
||||
<span class="spot-conditions__count" :class="{ 'spot-conditions__count--hot': hazards.length }">{{ loading ? '…' : searching ? shownHazards.length : hazards.length }}</span>
|
||||
</h4>
|
||||
<ul v-if="shownHazards.length">
|
||||
<li v-for="hazard in shownHazards" :key="`${hazard.kind}-${hazard.title}-${hazard.distanceKm}`" :class="`spot-conditions__hazard--${hazard.kind}`">
|
||||
<UiButton @click="flyTo(hazard)">
|
||||
<UiIcon :name="hazard.icon" :size="null" />
|
||||
<button type="button" @click="flyTo(hazard)">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ hazard.icon }}</span>
|
||||
<span class="spot-conditions__row-main">
|
||||
<span class="spot-conditions__row-title">{{ hazard.title }}</span>
|
||||
<span v-if="hazard.detail || hazard.time" class="spot-conditions__row-detail">{{ [hazard.detail, ago(hazard.time)].filter(Boolean).join(' · ') }}</span>
|
||||
@@ -335,7 +333,7 @@ const sources = computed(() => {
|
||||
</span>
|
||||
</span>
|
||||
<span class="spot-conditions__row-meta">{{ distance(hazard.distanceKm) }} {{ t(hazard.direction) }}</span>
|
||||
</UiButton>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-else-if="!loading" class="spot-conditions__none">{{ t('No earthquakes, tropical storms or wildfires reported within {radius}.', { radius: radiusText }) }}</p>
|
||||
@@ -343,40 +341,40 @@ const sources = computed(() => {
|
||||
|
||||
<div v-if="alerts.length" class="spot-conditions__block">
|
||||
<h4>
|
||||
<UiIcon name="emergency_home" :size="null" />
|
||||
<span class="material-symbols-outlined" aria-hidden="true">emergency_home</span>
|
||||
<span>{{ t('Broadcast alerts within {radius}', { radius: radiusText }) }}</span>
|
||||
<span class="spot-conditions__count spot-conditions__count--hot">{{ alerts.length }}</span>
|
||||
</h4>
|
||||
<ul>
|
||||
<li v-for="alert in alerts" :key="alert.key" class="spot-conditions__hazard--alert">
|
||||
<UiButton @click="store.select(alert.identity, { fly: true })">
|
||||
<UiIcon :name="alert.icon" :size="null" />
|
||||
<button type="button" @click="store.select(alert.identity, { fly: true })">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ alert.icon }}</span>
|
||||
<span class="spot-conditions__row-main">
|
||||
<span class="spot-conditions__row-title">{{ alert.title }}</span>
|
||||
<span class="spot-conditions__row-detail">{{ sayWords(alert.words, alert.text) }}</span>
|
||||
</span>
|
||||
<span class="spot-conditions__row-meta">{{ distance(alert.distanceKm) }}</span>
|
||||
</UiButton>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div v-if="groups?.other.length" class="spot-conditions__block">
|
||||
<h4>
|
||||
<UiIcon name="layers" :size="null" />
|
||||
<span class="material-symbols-outlined" aria-hidden="true">layers</span>
|
||||
<span>{{ t('Also within {radius}', { radius: radiusText }) }}</span>
|
||||
<span class="spot-conditions__count">{{ groups.other.length }}</span>
|
||||
</h4>
|
||||
<ul>
|
||||
<li v-for="item in groups.other" :key="item.key">
|
||||
<UiButton @click="store.select(item.identity, { fly: true })">
|
||||
<UiIcon :name="item.icon" :size="null" />
|
||||
<button type="button" @click="store.select(item.identity, { fly: true })">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ item.icon }}</span>
|
||||
<span class="spot-conditions__row-main">
|
||||
<span class="spot-conditions__row-title">{{ item.title }}</span>
|
||||
<span class="spot-conditions__row-detail">{{ shownLayerName(item.layerName, item.layerId) }}</span>
|
||||
</span>
|
||||
<span class="spot-conditions__row-meta">{{ distance(item.distanceKm) }}</span>
|
||||
</UiButton>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -386,7 +384,7 @@ const sources = computed(() => {
|
||||
<slot name="before-weather" />
|
||||
<div v-if="weather || entity" class="spot-conditions__weather" :class="{ 'spot-conditions__weather--timed': entity }">
|
||||
<template v-if="weather">
|
||||
<UiIcon class="spot-conditions__weather-icon" :name="look.icon" :size="null" />
|
||||
<span class="material-symbols-outlined spot-conditions__weather-icon" aria-hidden="true">{{ look.icon }}</span>
|
||||
<div class="spot-conditions__weather-now">
|
||||
<strong>{{ round(weather.temperatureC) }}°C</strong>
|
||||
<span>{{ t(look.label) }}<template v-if="Number.isFinite(weather.apparentTemperatureC)"> · {{ t('feels {n}°', { n: round(weather.apparentTemperatureC) }) }}</template></span>
|
||||
@@ -409,7 +407,7 @@ const sources = computed(() => {
|
||||
|
||||
<div v-if="articles.length" class="spot-conditions__block">
|
||||
<h4>
|
||||
<UiIcon name="newspaper" :size="null" />
|
||||
<span class="material-symbols-outlined" aria-hidden="true">newspaper</span>
|
||||
<span>{{ t('Local news') }}</span>
|
||||
<span v-if="brief?.newsQuery" class="spot-conditions__query">{{ brief.newsQuery }}</span>
|
||||
</h4>
|
||||
|
||||
@@ -21,8 +21,6 @@ import {
|
||||
windowText,
|
||||
} from '../../../stories/storyMeta.js';
|
||||
import StoriesHeader from './StoriesHeader.vue';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiCheckbox from '../../kit/UiCheckbox.vue';
|
||||
|
||||
/**
|
||||
* Explore (prototype `.scr-explore`): the feed beside GEV's Cesium globe,
|
||||
@@ -131,13 +129,12 @@ function resetAll() {
|
||||
filterOpen.value = false;
|
||||
}
|
||||
const filterEl = ref(null);
|
||||
// The Filter button is a UiButton; its root is the button.
|
||||
const filterBtn = ref(null);
|
||||
function onDocDown(e) {
|
||||
if (
|
||||
filterOpen.value &&
|
||||
!filterEl.value?.contains(e.target) &&
|
||||
!filterBtn.value?.$el?.contains(e.target)
|
||||
!filterBtn.value?.contains(e.target)
|
||||
)
|
||||
filterOpen.value = false;
|
||||
}
|
||||
@@ -423,12 +420,13 @@ defineExpose({
|
||||
@pointerup="onHeadUp"
|
||||
@pointercancel="onHeadUp"
|
||||
>
|
||||
<UiButton
|
||||
<button
|
||||
id="feedGrip"
|
||||
class="feed-grip"
|
||||
type="button"
|
||||
:aria-label="t('Story list size. Drag, or press to change')"
|
||||
@keydown="onGripKey"
|
||||
></UiButton>
|
||||
></button>
|
||||
<h1>{{ t('GEV Stories') }}</h1>
|
||||
<span
|
||||
id="exCount"
|
||||
@@ -451,9 +449,10 @@ defineExpose({
|
||||
<option value="long">{{ t('Longest') }}</option>
|
||||
<option value="az">{{ t('A–Z') }}</option>
|
||||
</select>
|
||||
<UiButton
|
||||
<button
|
||||
id="exFilterBtn"
|
||||
ref="filterBtn"
|
||||
type="button"
|
||||
class="fh-filter"
|
||||
:class="{ on: filterCount }"
|
||||
:aria-expanded="filterOpen"
|
||||
@@ -477,7 +476,7 @@ defineExpose({
|
||||
<path d="M4 6h16M7 12h10M10 18h4" />
|
||||
</svg>
|
||||
<b v-if="filterCount" id="exFilterN">{{ filterCount }}</b>
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="exTools" class="ex-tools" @pointerdown.stop @wheel.stop>
|
||||
@@ -504,8 +503,9 @@ defineExpose({
|
||||
autocomplete="off"
|
||||
@keydown="onSearchKey"
|
||||
/>
|
||||
<UiButton
|
||||
<button
|
||||
v-if="query"
|
||||
type="button"
|
||||
class="ex-qx"
|
||||
:aria-label="t('Clear search')"
|
||||
@click="
|
||||
@@ -523,7 +523,7 @@ defineExpose({
|
||||
>
|
||||
<path d="M6 6l12 12M18 6 6 18" />
|
||||
</svg>
|
||||
</UiButton>
|
||||
</button>
|
||||
<kbd class="hide-m">/</kbd>
|
||||
</div>
|
||||
<div class="fh-row">
|
||||
@@ -533,19 +533,21 @@ defineExpose({
|
||||
role="group"
|
||||
:aria-label="t('Topics')"
|
||||
>
|
||||
<UiButton
|
||||
<button
|
||||
type="button"
|
||||
class="chip"
|
||||
:pressed="!chips.length"
|
||||
:aria-pressed="!chips.length"
|
||||
@click="toggleChip('')"
|
||||
>{{ t('All') }}</UiButton
|
||||
>{{ t('All') }}</button
|
||||
>
|
||||
<UiButton
|
||||
<button
|
||||
v-for="c in topics"
|
||||
:key="c"
|
||||
type="button"
|
||||
class="chip"
|
||||
:pressed="chips.includes(c)"
|
||||
:aria-pressed="chips.includes(c)"
|
||||
@click="toggleChip(c)"
|
||||
>{{ t(c) }}</UiButton
|
||||
>{{ t(c) }}</button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
@@ -559,25 +561,25 @@ defineExpose({
|
||||
>
|
||||
<fieldset v-for="[key, label, opts] in filterGroups" :key="key">
|
||||
<legend>{{ t(label) }}</legend>
|
||||
<UiCheckbox
|
||||
v-for="[value, text] in opts"
|
||||
:key="value"
|
||||
class="fopt"
|
||||
:model-value="Boolean(filters[key]?.includes(value))"
|
||||
@change="toggleFilter(key, value, $event.target.checked)"
|
||||
>
|
||||
<label v-for="[value, text] in opts" :key="value" class="fopt">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="filters[key]?.includes(value)"
|
||||
@change="toggleFilter(key, value, $event.target.checked)"
|
||||
/>
|
||||
<span>{{ t(text) }}</span>
|
||||
</UiCheckbox>
|
||||
</label>
|
||||
</fieldset>
|
||||
<div class="fact">
|
||||
<UiButton class="tbtn" @click="clearFilters">{{
|
||||
<button type="button" class="tbtn" @click="clearFilters">{{
|
||||
t('Clear')
|
||||
}}</UiButton>
|
||||
<UiButton
|
||||
}}</button>
|
||||
<button
|
||||
type="button"
|
||||
class="tbtn solid"
|
||||
@click="
|
||||
filterOpen = false;
|
||||
filterBtn?.$el?.focus();
|
||||
filterBtn?.focus();
|
||||
"
|
||||
>
|
||||
{{
|
||||
@@ -587,7 +589,7 @@ defineExpose({
|
||||
'Show {count} stories',
|
||||
)
|
||||
}}
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -596,9 +598,9 @@ defineExpose({
|
||||
<li v-if="!shown.length" class="feed-empty">
|
||||
<b>{{ t('No stories match') }}</b>
|
||||
<span>{{ t('Try another word or clear the filters.') }}</span>
|
||||
<UiButton class="tbtn" @click="resetAll">{{
|
||||
<button type="button" class="tbtn" @click="resetAll">{{
|
||||
t('Clear all')
|
||||
}}</UiButton>
|
||||
}}</button>
|
||||
</li>
|
||||
<li v-for="s in shown" :key="s.id">
|
||||
<div
|
||||
@@ -621,15 +623,16 @@ defineExpose({
|
||||
s.draft ? t('DRAFT') : t('STORY')
|
||||
}}</span>
|
||||
<span class="dur">{{ fmtDur(s.durationMs) }}</span>
|
||||
<UiButton
|
||||
<button
|
||||
class="thumb-play"
|
||||
type="button"
|
||||
:aria-label="t('Play {title}', { title: titleOf(s) })"
|
||||
@click.stop="play(s.id, $event.currentTarget.parentElement)"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M9 6.5v11l9-5.5z" fill="currentColor" />
|
||||
</svg>
|
||||
</UiButton>
|
||||
</button>
|
||||
</span>
|
||||
<span class="c-title">{{ titleOf(s) }}</span>
|
||||
<span class="c-meta">{{ s.creator }} · {{ windowText(s) }}</span>
|
||||
@@ -637,8 +640,9 @@ defineExpose({
|
||||
><span v-for="l in layerNames(s)" :key="l">{{ l }}</span></span
|
||||
>
|
||||
<span class="c-play">
|
||||
<UiButton
|
||||
<button
|
||||
class="tbtn solid"
|
||||
type="button"
|
||||
@click.stop="
|
||||
play(
|
||||
s.id,
|
||||
@@ -651,7 +655,7 @@ defineExpose({
|
||||
<svg viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M7 4.5v15l12.5-7.5z" /></svg
|
||||
>{{ t('Play story') }}
|
||||
</UiButton>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
@@ -660,13 +664,14 @@ defineExpose({
|
||||
<div class="ex-map">
|
||||
<div class="map-slot"></div>
|
||||
<div id="pins" class="pins">
|
||||
<UiButton
|
||||
<button
|
||||
v-for="p in placedPins"
|
||||
:key="p.id"
|
||||
class="pin"
|
||||
:class="{ out: !shownIds.has(p.id), hidden: !p.visible }"
|
||||
type="button"
|
||||
:data-id="p.id"
|
||||
:pressed="picked === p.id"
|
||||
:aria-pressed="picked === p.id"
|
||||
:aria-label="t('Preview {title}', { title: titleOf(p.story) })"
|
||||
:style="p.style"
|
||||
@click="onPin($event, p.id)"
|
||||
@@ -681,7 +686,7 @@ defineExpose({
|
||||
/></span>
|
||||
<span class="pin-lbl">{{ titleOf(p.story).split(':')[0] }}</span>
|
||||
<span class="pin-dot"></span>
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
<div class="ex-msearch glass" role="search">
|
||||
<label class="sr" for="exQ">{{ t('Search stories') }}</label>
|
||||
@@ -705,8 +710,9 @@ defineExpose({
|
||||
autocomplete="off"
|
||||
@keydown="onSearchKey"
|
||||
/>
|
||||
<UiButton
|
||||
<button
|
||||
v-if="query"
|
||||
type="button"
|
||||
class="ex-qx"
|
||||
:aria-label="t('Clear search')"
|
||||
@click="query = ''"
|
||||
@@ -721,7 +727,7 @@ defineExpose({
|
||||
>
|
||||
<path d="M6 6l12 12M18 6 6 18" />
|
||||
</svg>
|
||||
</UiButton>
|
||||
</button>
|
||||
<kbd>/</kbd>
|
||||
</div>
|
||||
<div
|
||||
@@ -740,11 +746,15 @@ defineExpose({
|
||||
l
|
||||
}}</span></span
|
||||
>
|
||||
<UiButton class="tbtn solid" @click="play(pickedStory.id, null)">
|
||||
<button
|
||||
class="tbtn solid"
|
||||
type="button"
|
||||
@click="play(pickedStory.id, null)"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M7 4.5v15l12.5-7.5z" /></svg
|
||||
>{{ t('Play story') }}
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="ex-hint glass">{{
|
||||
t('Pick a story or a pin to preview it here')
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
} from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useStoriesStore } from '../../stores/stories.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
|
||||
/**
|
||||
* The Stories top bar (prototype `.h-top.s-head`): back, GEV logo and
|
||||
@@ -40,7 +39,6 @@ async function share() {
|
||||
}
|
||||
// Long titles scroll gently so the whole name can be read.
|
||||
const mtitle = ref(null);
|
||||
// Back is a UiButton; its root is the button.
|
||||
const back = ref(null);
|
||||
const trail = ref(null);
|
||||
let observer = null;
|
||||
@@ -54,9 +52,8 @@ function fitTitle() {
|
||||
el.style.setProperty('--mq-dur', `${Math.max(5, (over + 22) / 22)}s`);
|
||||
}
|
||||
onMounted(() => {
|
||||
const backEl = back.value?.$el;
|
||||
const target = backEl?.getClientRects().length
|
||||
? backEl
|
||||
const target = back.value?.getClientRects().length
|
||||
? back.value
|
||||
: trail.value?.querySelector('button');
|
||||
target?.focus({ preventScroll: true });
|
||||
if (globalThis.ResizeObserver && mtitle.value) {
|
||||
@@ -74,9 +71,10 @@ onBeforeUnmount(() => observer?.disconnect());
|
||||
|
||||
<template>
|
||||
<header class="h-top s-head">
|
||||
<UiButton
|
||||
<button
|
||||
ref="back"
|
||||
class="s-back glass"
|
||||
type="button"
|
||||
:aria-label="
|
||||
screen === 'story' ? t('Back to stories') : t('Back to the globe')
|
||||
"
|
||||
@@ -92,28 +90,31 @@ onBeforeUnmount(() => observer?.disconnect());
|
||||
>
|
||||
<path d="M15 6l-6 6 6 6" />
|
||||
</svg>
|
||||
</UiButton>
|
||||
</button>
|
||||
<div class="h-brand">
|
||||
<div class="h-brand-row">
|
||||
<UiButton
|
||||
<button
|
||||
class="s-home"
|
||||
type="button"
|
||||
:aria-label="t('Back to the globe')"
|
||||
@click="emit('home')"
|
||||
>
|
||||
<svg class="eye" viewBox="0 0 775 520" aria-hidden="true">
|
||||
<use href="#gevLogo" />
|
||||
</svg>
|
||||
</UiButton>
|
||||
</button>
|
||||
<span class="h-word" translate="no">GOD'S EYE <b>VIEW</b></span>
|
||||
</div>
|
||||
<nav ref="trail" class="h-tag s-trail" :aria-label="t('Breadcrumb')">
|
||||
<template v-if="screen === 'explore'">
|
||||
<UiButton @click="emit('home')">{{ t('Globe') }}</UiButton>
|
||||
<button type="button" @click="emit('home')">{{ t('Globe') }}</button>
|
||||
<span aria-hidden="true">/</span>
|
||||
<b>{{ t('Stories') }}</b>
|
||||
</template>
|
||||
<template v-else>
|
||||
<UiButton @click="emit('crumb')">{{ t('Stories') }}</UiButton>
|
||||
<button type="button" @click="emit('crumb')">{{
|
||||
t('Stories')
|
||||
}}</button>
|
||||
<span aria-hidden="true">/</span>
|
||||
<b>{{ title }}</b>
|
||||
</template>
|
||||
@@ -123,9 +124,10 @@ onBeforeUnmount(() => observer?.disconnect());
|
||||
><span>{{ screen === 'explore' ? t('Stories') : title }}</span></span
|
||||
>
|
||||
<div class="h-right">
|
||||
<UiButton
|
||||
<button
|
||||
v-if="screen === 'explore'"
|
||||
class="s-msearch ibtn"
|
||||
type="button"
|
||||
:aria-label="t('Search')"
|
||||
@click="emit('search')"
|
||||
>
|
||||
@@ -138,19 +140,21 @@ onBeforeUnmount(() => observer?.disconnect());
|
||||
<circle cx="11" cy="11" r="6.5" />
|
||||
<path d="m16 16 4.5 4.5" />
|
||||
</svg>
|
||||
</UiButton>
|
||||
<UiButton
|
||||
</button>
|
||||
<button
|
||||
v-if="!localOnly"
|
||||
class="tbtn hide-m"
|
||||
type="button"
|
||||
:aria-label="t('Share')"
|
||||
@click="share"
|
||||
>
|
||||
<span class="share-icon" aria-hidden="true">🔗</span>
|
||||
<span>{{ t('Share') }}</span>
|
||||
</UiButton>
|
||||
<UiButton
|
||||
</button>
|
||||
<button
|
||||
v-if="screen === 'explore'"
|
||||
class="tbtn accent hide-m"
|
||||
type="button"
|
||||
@click="emit('home')"
|
||||
>
|
||||
<svg
|
||||
@@ -164,10 +168,11 @@ onBeforeUnmount(() => observer?.disconnect());
|
||||
<path d="M19 12H5M11 6l-6 6 6 6" />
|
||||
</svg>
|
||||
<span>{{ t('Back to GEV') }}</span>
|
||||
</UiButton>
|
||||
<UiButton
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
class="tbtn accent hide-m gs-back-stories"
|
||||
type="button"
|
||||
@click="emit('crumb')"
|
||||
>
|
||||
<svg
|
||||
@@ -181,7 +186,7 @@ onBeforeUnmount(() => observer?.disconnect());
|
||||
<path d="M19 12H5M11 6l-6 6 6 6" />
|
||||
</svg>
|
||||
<span>{{ t('GEV Stories') }}</span>
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
</template>
|
||||
@@ -3,7 +3,6 @@ import { computed, ref } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { t, tn } from '../../../i18n/index.js';
|
||||
import { useStoriesStore } from '../../stores/stories.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import { chapterAt } from '../../../stories/format.js';
|
||||
import {
|
||||
anchorStamp,
|
||||
@@ -207,9 +206,10 @@ defineExpose({ dragging });
|
||||
:aria-label="t('Context')"
|
||||
:style="dragH != null ? { height: `${dragH}px` } : null"
|
||||
>
|
||||
<UiButton
|
||||
<button
|
||||
id="sheetHandle"
|
||||
class="sheet-handle"
|
||||
type="button"
|
||||
:aria-expanded="sheet !== 'peek'"
|
||||
:aria-label="
|
||||
sheet === 'peek'
|
||||
@@ -243,7 +243,7 @@ defineExpose({ dragging });
|
||||
>{{ t(f[1]) }}</span
|
||||
>
|
||||
</span>
|
||||
</UiButton>
|
||||
</button>
|
||||
<div class="cx-search-wrap">
|
||||
<div class="cx-search">
|
||||
<svg
|
||||
@@ -270,8 +270,9 @@ defineExpose({ dragging });
|
||||
@input="onQuery"
|
||||
@keydown="onSearchKey"
|
||||
/>
|
||||
<UiButton
|
||||
<button
|
||||
class="cx-ic"
|
||||
type="button"
|
||||
disabled
|
||||
:aria-label="t('Voice search (not in this build)')"
|
||||
:title="t('Voice search (not in this build)')"
|
||||
@@ -286,7 +287,7 @@ defineExpose({ dragging });
|
||||
<rect x="9" y="3" width="6" height="11" rx="3" />
|
||||
<path d="M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21" />
|
||||
</svg>
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
<ul
|
||||
v-if="results"
|
||||
@@ -296,7 +297,8 @@ defineExpose({ dragging });
|
||||
:aria-label="t('Search results')"
|
||||
>
|
||||
<li v-for="(x, i) in results" :key="`${x.type}:${x.k ?? x.title}`">
|
||||
<UiButton
|
||||
<button
|
||||
type="button"
|
||||
role="option"
|
||||
:aria-selected="i === active"
|
||||
@click="choose(x)"
|
||||
@@ -306,7 +308,7 @@ defineExpose({ dragging });
|
||||
><b>{{ x.title }}</b
|
||||
><span class="sub">{{ x.sub }}</span></span
|
||||
>
|
||||
</UiButton>
|
||||
</button>
|
||||
</li>
|
||||
<li v-if="!results.length" class="empty">{{
|
||||
t('Nothing in this story matches.')
|
||||
@@ -332,11 +334,12 @@ defineExpose({ dragging });
|
||||
<div class="cx-sec">
|
||||
<div class="cx-h">
|
||||
{{ t('About') }}
|
||||
<UiButton
|
||||
<button
|
||||
class="tbtn cx-close"
|
||||
type="button"
|
||||
style="height: 28px; padding: 0 8px"
|
||||
@click="emit('hide')"
|
||||
>{{ t('Close') }}</UiButton
|
||||
>{{ t('Close') }}</button
|
||||
>
|
||||
</div>
|
||||
<p class="cx-p">
|
||||
@@ -353,7 +356,8 @@ defineExpose({ dragging });
|
||||
<div class="cx-h">{{ t('Key moments') }}</div>
|
||||
<ul class="cx-anchors">
|
||||
<li v-for="(ev, i) in events" :key="i">
|
||||
<UiButton
|
||||
<button
|
||||
type="button"
|
||||
:class="{ past: playback.wallMs >= ev.wallMs }"
|
||||
@click="emit('anchor', ev)"
|
||||
>
|
||||
@@ -362,7 +366,7 @@ defineExpose({ dragging });
|
||||
><i :style="{ background: ev.color }"></i
|
||||
>{{ storyText(ev.label) }}</span
|
||||
>
|
||||
</UiButton>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -387,9 +391,10 @@ defineExpose({ dragging });
|
||||
<div class="cx-sec">
|
||||
<div class="cx-h">{{ t('Related stories') }}</div>
|
||||
<div class="cx-related">
|
||||
<UiButton
|
||||
<button
|
||||
v-for="x in related"
|
||||
:key="x.id"
|
||||
type="button"
|
||||
@click="emit('open', x.id)"
|
||||
>
|
||||
<span class="thumb"
|
||||
@@ -399,7 +404,7 @@ defineExpose({ dragging });
|
||||
><b>{{ titleOf(x) }}</b
|
||||
><span class="c-meta">{{ windowText(x) }}</span></span
|
||||
>
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useStoriesStore } from '../../stores/stories.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
|
||||
/**
|
||||
* The right rail over the story map (prototype `.ov-rail`): Open in GEV (it
|
||||
@@ -26,9 +25,10 @@ async function share() {
|
||||
<template>
|
||||
<div id="ovRail" class="ov ov-rail">
|
||||
<!-- The scene opens in GEV's Scenes panel. -->
|
||||
<UiButton
|
||||
<button
|
||||
id="railGev"
|
||||
class="rail-btn rail-gev"
|
||||
type="button"
|
||||
:aria-label="t('Open this moment in GEV')"
|
||||
@click="store.controller.openInGev()"
|
||||
>
|
||||
@@ -36,17 +36,18 @@ async function share() {
|
||||
><svg class="eye" viewBox="0 0 775 520" aria-hidden="true">
|
||||
<use href="#gevLogo" /></svg></span
|
||||
>{{ t('Open') }}
|
||||
</UiButton>
|
||||
<UiButton
|
||||
</button>
|
||||
<button
|
||||
v-if="!localOnly"
|
||||
id="railShare"
|
||||
class="rail-btn"
|
||||
type="button"
|
||||
:aria-label="t('Share this story')"
|
||||
@click="share"
|
||||
>
|
||||
<span class="ic"
|
||||
><span class="share-icon" aria-hidden="true">🔗</span></span
|
||||
>{{ t('Share') }}
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -23,7 +23,6 @@ import StoriesHeader from './StoriesHeader.vue';
|
||||
import StoryTimeline from './StoryTimeline.vue';
|
||||
import StoryContext from './StoryContext.vue';
|
||||
import StoryRail from './StoryRail.vue';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
|
||||
/**
|
||||
* One story (prototype `.scr-story`): a GEV scene playing on GEV's Cesium
|
||||
@@ -156,7 +155,6 @@ function onCardKey(e) {
|
||||
if (e.key === 'ArrowRight') setPage(page.value + 1);
|
||||
else if (e.key === 'ArrowLeft') setPage(page.value - 1);
|
||||
}
|
||||
// Minimise and Expand are UiButtons; each root is the button.
|
||||
const minBtn = ref(null);
|
||||
const miniBtn = ref(null);
|
||||
function setCardMin(on) {
|
||||
@@ -354,9 +352,10 @@ watch([k, page], () => nextTick(sizeCard));
|
||||
</div>
|
||||
<ol class="ch-list">
|
||||
<li v-for="(c, i) in story.chapters" :key="c.id">
|
||||
<UiButton
|
||||
<button
|
||||
class="ch-item"
|
||||
:class="{ done: i < k }"
|
||||
type="button"
|
||||
:aria-current="i === k ? 'step' : undefined"
|
||||
@click="goChapter(i)"
|
||||
>
|
||||
@@ -364,7 +363,7 @@ watch([k, page], () => nextTick(sizeCard));
|
||||
><span
|
||||
><b>{{ chTitle(c) }}</b></span
|
||||
>
|
||||
</UiButton>
|
||||
</button>
|
||||
</li>
|
||||
</ol>
|
||||
</aside>
|
||||
@@ -446,15 +445,16 @@ watch([k, page], () => nextTick(sizeCard));
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<UiButton
|
||||
<button
|
||||
id="pgMin"
|
||||
ref="minBtn"
|
||||
class="pg-min"
|
||||
type="button"
|
||||
:aria-label="t('Minimise card')"
|
||||
:aria-expanded="!cardMin"
|
||||
@click.stop="
|
||||
setCardMin(true);
|
||||
nextTick(() => miniBtn?.$el?.focus());
|
||||
nextTick(() => miniBtn?.focus());
|
||||
"
|
||||
>
|
||||
<svg
|
||||
@@ -467,16 +467,17 @@ watch([k, page], () => nextTick(sizeCard));
|
||||
>
|
||||
<path d="M6 15l6-6 6 6" />
|
||||
</svg>
|
||||
</UiButton>
|
||||
<UiButton
|
||||
</button>
|
||||
<button
|
||||
id="pgMini"
|
||||
ref="miniBtn"
|
||||
class="pg-mini"
|
||||
type="button"
|
||||
:aria-label="t('Expand card')"
|
||||
@click.stop="
|
||||
setCardMin(false);
|
||||
cardPeek();
|
||||
nextTick(() => minBtn?.$el?.focus());
|
||||
nextTick(() => minBtn?.focus());
|
||||
"
|
||||
>
|
||||
<b>{{ k + 1 }}/{{ story.chapters.length }}</b
|
||||
@@ -491,24 +492,25 @@ watch([k, page], () => nextTick(sizeCard));
|
||||
>
|
||||
<path d="M6 9l6 6 6-6" />
|
||||
</svg>
|
||||
</UiButton>
|
||||
</button>
|
||||
<div
|
||||
id="pgDots"
|
||||
class="pg-dots"
|
||||
role="group"
|
||||
:aria-label="t('Card pages')"
|
||||
>
|
||||
<UiButton
|
||||
<button
|
||||
v-for="(lbl, i) in [
|
||||
t('Chapter'),
|
||||
t('On the map'),
|
||||
t('Right now'),
|
||||
]"
|
||||
:key="i"
|
||||
type="button"
|
||||
:aria-label="lbl"
|
||||
:aria-current="String(i === page)"
|
||||
@click="setPage(i)"
|
||||
></UiButton>
|
||||
></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -530,8 +532,9 @@ watch([k, page], () => nextTick(sizeCard));
|
||||
id="ovPlay"
|
||||
class="ov ov-play"
|
||||
>
|
||||
<UiButton
|
||||
<button
|
||||
id="btnBigPlay"
|
||||
type="button"
|
||||
:aria-label="t('Play story')"
|
||||
@click="bigPlayClick"
|
||||
>
|
||||
@@ -540,12 +543,13 @@ watch([k, page], () => nextTick(sizeCard));
|
||||
d="M8 5.7v12.6c0 .9 1 1.4 1.7.9l9.7-6.3a1.1 1.1 0 0 0 0-1.8L9.7 4.8C9 4.3 8 4.8 8 5.7Z"
|
||||
/>
|
||||
</svg>
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
<UiButton
|
||||
<button
|
||||
id="btnCtx"
|
||||
class="ov ov-ctxbtn tbtn"
|
||||
:pressed="ctxOpen"
|
||||
type="button"
|
||||
:aria-pressed="ctxOpen"
|
||||
@click="ctxOpen = !ctxOpen"
|
||||
>
|
||||
<svg
|
||||
@@ -558,7 +562,7 @@ watch([k, page], () => nextTick(sizeCard));
|
||||
<path d="M14 4v16" />
|
||||
</svg>
|
||||
<span>{{ t('Context') }}</span>
|
||||
</UiButton>
|
||||
</button>
|
||||
<div v-if="hint" id="ovHint" class="ov ov-hint glass">{{ hint }}</div>
|
||||
<StoryRail />
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,6 @@ import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useStoriesStore } from '../../stores/stories.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import { chapterAt } from '../../../stories/format.js';
|
||||
import {
|
||||
chapterTitle,
|
||||
@@ -319,9 +318,10 @@ defineExpose({ goChapter });
|
||||
|
||||
<template>
|
||||
<div id="timeline" class="timeline">
|
||||
<UiButton
|
||||
<button
|
||||
id="tlPlay"
|
||||
class="tl-play"
|
||||
type="button"
|
||||
:aria-label="playMode === 'pause' ? t('Pause') : t('Play')"
|
||||
@click="togglePlay"
|
||||
>
|
||||
@@ -331,7 +331,7 @@ defineExpose({ goChapter });
|
||||
fill="currentColor"
|
||||
v-html="ICON[playMode]"
|
||||
></svg>
|
||||
</UiButton>
|
||||
</button>
|
||||
<div
|
||||
id="tlTrack"
|
||||
ref="track"
|
||||
@@ -377,9 +377,10 @@ defineExpose({ goChapter });
|
||||
<span id="tlHeadTime">{{ headTime }}</span>
|
||||
</div>
|
||||
<div id="tlPips" role="group" :aria-label="t('Key moments')">
|
||||
<UiButton
|
||||
<button
|
||||
v-for="(ev, i) in events"
|
||||
:key="i"
|
||||
type="button"
|
||||
class="tl-pip"
|
||||
:class="{ snap: snap === -2 - i }"
|
||||
:data-e="i"
|
||||
@@ -395,7 +396,7 @@ defineExpose({ goChapter });
|
||||
@keydown.enter.stop
|
||||
>
|
||||
<i :style="{ background: ev.color }"></i>
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="tip"
|
||||
@@ -438,11 +439,12 @@ defineExpose({ goChapter });
|
||||
<span id="tlTime" class="tl-time" aria-hidden="true">
|
||||
<span class="tt-c">{{ headTime }}</span>
|
||||
</span>
|
||||
<UiButton
|
||||
<button
|
||||
id="stExpand"
|
||||
class="tl-vol"
|
||||
type="button"
|
||||
:aria-label="expanded ? t('Exit expanded map') : t('Expand map')"
|
||||
:pressed="expanded"
|
||||
:aria-pressed="expanded"
|
||||
@click="toggleExpand"
|
||||
>
|
||||
<svg
|
||||
@@ -455,6 +457,6 @@ defineExpose({ goChapter });
|
||||
>
|
||||
<path d="M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5" />
|
||||
</svg>
|
||||
</UiButton>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user