diff --git a/changelog.d/1857-zoom-freeze-under-icons.md b/changelog.d/1857-zoom-freeze-under-icons.md new file mode 100644 index 0000000000..6816fdfa88 --- /dev/null +++ b/changelog.d/1857-zoom-freeze-under-icons.md @@ -0,0 +1,3 @@ +- Wheel and trackpad zoom no longer freeze below 150 km while an aircraft or + vessel icon is under the centre of the view: icons drawn over depth write a + depth of exactly 0, which the camera's depth pick ignores (asturksever, #1857). diff --git a/changelog.d/1861-bare-address-defaults.md b/changelog.d/1861-bare-address-defaults.md new file mode 100644 index 0000000000..77faf35c49 --- /dev/null +++ b/changelog.d/1861-bare-address-defaults.md @@ -0,0 +1,4 @@ +- Opening the bare address starts with the default layers again, instead of + bringing back the last session's: a link still restores everything it + carries, so clearing the address always resets the view (samehkhamis, + #1861). diff --git a/changelog.d/1862-kit-sweep-chat-voice.md b/changelog.d/1862-kit-sweep-chat-voice.md new file mode 100644 index 0000000000..511c798fcb --- /dev/null +++ b/changelog.d/1862-kit-sweep-chat-voice.md @@ -0,0 +1,2 @@ +- The AI chat panel's and voice control's buttons and glyphs are now kit + controls (manjunath22466, samehkhamis, #1862). diff --git a/changelog.d/1863-kit-sweep-draw.md b/changelog.d/1863-kit-sweep-draw.md new file mode 100644 index 0000000000..4822dd8265 --- /dev/null +++ b/changelog.d/1863-kit-sweep-draw.md @@ -0,0 +1,2 @@ +- Draw's and Import's buttons and glyphs are now kit controls + (manjunath22466, samehkhamis, #1863). diff --git a/changelog.d/1864-kit-sweep-missions-radio.md b/changelog.d/1864-kit-sweep-missions-radio.md new file mode 100644 index 0000000000..9f2c26b390 --- /dev/null +++ b/changelog.d/1864-kit-sweep-missions-radio.md @@ -0,0 +1,2 @@ +- Space Missions', Contacts', Radio's, the RTL-SDR card's and key setup's + buttons and glyphs are now kit controls (manjunath22466, samehkhamis, #1864). diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 51dd971fe0..b89acd8ae3 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -93,6 +93,16 @@ settling. Oblique views below 300 km are left alone. `QA_BASE_URL=http://localhost:4173 node scripts/qa-zoom-out-guard.mjs` exercises the real browser controller at desktop and phone widths with keyless fixtures. +Below 150 km Cesium sizes a wheel or pinch zoom step from the depth it picks at +the canvas centre. Icons drawn over depth (aircraft, vessels and most markers: +`disableDepthTest: Infinity`) sit on the near plane and write a depth of +exactly 0 there (`src/render/cesium/iconSetPrimitive.js`), which that pick +reads as nothing drawn, so it keeps the ground under the icon. Any depth past +the near plane would be taken for a surface a near plane's distance from the +camera, and the zoom would stop while an icon is under the centre. +`QA_BASE_URL=http://localhost:5173 node scripts/qa-zoom-under-icon.mjs` checks +this against a dev server (`npm run dev`). + Cesium's free look (Shift+drag, which turns the camera in place) works only below 1,000 km. Above that height a few drags could turn the whole planet out of frame and leave only stars, so Shift+drag does nothing there. Cesium also turns @@ -8562,7 +8572,7 @@ pins and share links already supply complete boxes. - Vessels, Transit and Rail draw fleet models under the same DISPLAY rail `3D` toggle, at the same altitude ceiling, caps and 3 km add/keep radii as the aircraft, at true size (`FLEET_MODEL_POLICY`, `src/layers/flights/policy.js`; `createFleetModelLayer`, `src/data/fleetModelInstances.js`). A vessel's model follows its AIS ship type and is drawn at its reported length and beam (AIS static dimensions A+B and C+D, now carried on vessel rows as `length` and `beam`), standing at the sea surface, heading by true heading then course. An aid to navigation is not a hull: a vessel record whose type names a buoy, beacon, mark, RACON or light, or whose MMSI is an aid-to-navigation station's (`99MIDxxxx`), is `isAidToNavigation` (`src/data/vesselTypes.js`) and is drawn as the set's `buoys` model of the IALA mark its type names (`aidToNavigationModel`, `src/data/fleetModels.js`: cardinal N/E/S/W, port or starboard hand, preferred channel by its side, safe water, isolated danger, special mark; a beacon, light, light vessel, RACON or reference point with no mark of its own is the special mark), else a red can (`DEFAULT_AID_MODEL`), at its built size and facing north whatever heading it reports. A type is an aid's when it is one of the 32 kinds an aid report names or uses a word for one (buoy, beacon, cardinal, safe water, RACON, lighthouse and so on); a vessel that works on aids (`Buoy Tender`, `Buoy Layer`) is not one. Its icon is the buoy sprite, tinted bone white (`AID_TO_NAVIGATION_STYLE`, `src/data/vesselLabels.js`), upright and never turned, and its card, selected card and HUD readout (`src/layers/vessels/cards.js`) show its kind alone, whole, in that colour: no speed or heading, since a fixed mark has neither. AISStream subscribes to `AidsToNavigationReport` (message 21) by default, and the server names each report's aid type code (0 to 31) as its kind (`aidToNavigationTypeName`: `20` is `Cardinal Mark N`) rather than reading it as a ship type, and its name runs on into the report's `NameExtension`. A virtual aid (the report's `VirtualAtoN` flag: a mark broadcast where nothing physical stands) carries `virtual: true` on its row, and on its vessel source record (the live-source contract's `virtual`, `src/sources/live/contract.js`, false unless a source says true; any source may set it). It keeps its buoy sprite but never gets a model (`vesselModelSpec` returns null for it, and the vessel layer gathers no model item for it), and its card and readout add `VIRTUAL` after its kind. `aisStreamRows` (`server/providers/vessels/ais-store.js`) puts every vessel ahead of every aid, so a capped request (the layer asks for 12,000 rows) never gives up a ship for a buoy. The `vessels_in_area` tool (and the brief built on it) counts ships only: it leaves aids out of its rows, counts, breakdowns and speed stats. A transit vehicle's model follows its route's GTFS `route_type` when its record carries one and that type is a kind of the vehicle's mode (`types.json` `transit.route_types`: 200 a coach, 101 a high-speed set, 106 a regional DMU, 710 a double-decker), else its layer mode (`transit.modes`: bus, trolleybus, tram, cable car, subway, monorail, rail, funicular, gondola or ferry; a vehicle of `unknown` mode keeps its icon); a fleet hint that overrules the route (a bus on a tram route) leaves the type unused. A monorail and a gondola are raised by their `transit.elevation` lifts. A train's model follows its rail category and mode (rail, metro or tram). The bundled GTFS-Realtime proxy carries no route type, so its vehicles draw their mode's model; a source that adds `routeType` reaches the finer ones. Both stand on the road or rail top they are drawn on, without the 1.5 m `GROUND_FLOOR_LIFT_M` their icons carry, and are painted in their mode or category colour where the model's `_TINT` attribute marks it. A vessel model is clipped at its waterline (one clipping plane per model, at the model origin's horizontal plane), so its hull below the water never shows through a plain globe, which Cesium does not depth-test models against. Under the NVG/FLIR styles (the Flights `irBoost` parameter) these models render unlit flat white, as aircraft models do. Each vehicle's icon stays the visual until its model is loaded, ready and placed; a model is picked as its icon is, and a vehicle drawn as its model keeps its selection card and its place in the detection overlay. - **Aircraft models skip Cesium's dynamic environment map (2026-10-24).** Flights, Military Flights and Local ADS-B pass `environmentMapOptions: AIRCRAFT_ENVIRONMENT_MAP_OPTIONS` (`{ enabled: false }`, `src/data/aircraftModelLighting.js`) to every drawn model. Otherwise each `Model` renders the sky around it and reads it back from the GPU (`readPixels`) when it is first placed, and again whenever it moves more than 1 km, the scene's atmosphere settings change, or (under sunlight dynamic lighting) an hour of scene time passes (`DynamicEnvironmentMapManager`, Cesium 1.138). The models are lit from Cesium's default spherical harmonics instead, with no specular environment map, so the sky's model-lighting cube map no longer reaches aircraft. `src/data/aircraftModelLighting.test.mjs` pins the option at every drawn model call; every model is built from the fleet set loaded up front, so there is no separate preload. - The DISPLAY-rail `3D` toggle is the user-facing activation path for both aircraft layers. Their small approved GLBs build their render resources without Cesium's frame-spread job queue, preventing continuous Photorealistic 3D Tiles streaming from starving model readiness; model caps, tracking, camera, and fallback billboards are unchanged. -- **The `3D` toggle DEFAULTS ON in `proximity` on a first run.** Proximity is itself the budget — models appear only within 3 km of the camera and only for the nearest `MODEL_MAX` — so the default costs nothing at globe scale, and `all` remains a deliberate opt-in. A fresh boot runs NO layer-state restoration (`LayerStateCoordinator.start()` returns early with neither a share payload nor stored state), so four independent initializers decide what a first-run operator sees and must agree: `booleanOption('models3d', 'e', true)` in `src/data/layerState.js`, `_models3dEnabled = true` in BOTH flight layers, `this._models3dEnabled = true` in `src/ui/aircraftDisplay.js`, and the `active` / `visible` classes on `#models3d-toggle` / `#models3d-mode-row` in `index.html`. All four are pinned together in `src/data/layerState.test.mjs`. Explicit state still wins: because the codec omits default-valued options, `models3d: false` is now what travels in a link (`lo=…f.e.0`) and restores OFF at both aircraft layers. **Consequence for returning users:** a stored `gev:layer-state:v2` blob is a FULL options snapshot, so a session that wrote one before this change carries `models3d:false` and keeps 3D off until the operator flips it (or clears the key) — the durable snapshot is treated as the recipient's own state, by design. +- **The `3D` toggle DEFAULTS ON in `proximity` on a first run.** Proximity is itself the budget — models appear only within 3 km of the camera and only for the nearest `MODEL_MAX` — so the default costs nothing at globe scale, and `all` remains a deliberate opt-in. A fresh boot runs NO layer-state restoration (`LayerStateCoordinator.start()` returns early with neither a share payload nor stored state), so four independent initializers decide what a first-run operator sees and must agree: `booleanOption('models3d', 'e', true)` in `src/data/layerState.js`, `_models3dEnabled = true` in BOTH flight layers, `this._models3dEnabled = true` in `src/ui/aircraftDisplay.js`, and the `active` / `visible` classes on `#models3d-toggle` / `#models3d-mode-row` in `index.html`. All four are pinned together in `src/data/layerState.test.mjs`. Explicit state still wins: because the codec omits default-valued options, `models3d: false` is now what travels in a link (`lo=…f.e.0`) and restores OFF at both aircraft layers. Start-up never reads a stored `gev:layer-state:v2` blob back: a bare URL starts from these defaults and a link from its hash (`src/ui/shareRestoration.js`, `allowLocalState: false`), so clearing the address always resets the view. - Civilian and military 2D aircraft use the established distance scale: `3×` near the camera and a `0.5×` floor from 8,000 km outward. A standard 20 px ambient icon therefore remains about 10 px at globe altitude while retaining the @@ -8805,13 +8815,15 @@ that era's default (`scf` → 35, `ko` → 5). Every link since carries both fie explicitly, because the generator always writes them, so no era whose default later changed depends on a fallback either way. -**They do NOT all persist the same way, and only one of them persists at all.** +**None of them comes back from storage on a bare URL; only the hash carries them.** Worth stating plainly, because "a default you can override" and "a default that remembers" are different promises: -- **3D models** have durable storage — `gev:layer-state:v2` in local storage, - written by `LayerStateCoordinator` on explicit intent. A session that stored a - snapshot keeps whatever it stored, across tabs and restarts. +- **3D models** are written to `gev:layer-state:v2` in local storage by + `LayerStateCoordinator` on explicit intent, but start-up never reads it back: + a link restores what its hash carries, and a bare URL starts with the default + layers and options (`src/ui/shareRestoration.js` passes + `allowLocalState: false`), so clearing the address always resets the view. - **Detection mode/density and scope feather have NO storage key at all.** Their only durable carrier is the URL hash (`dm`/`dd`, `scf`), written on a 500 ms debounce. A same-URL reload therefore keeps them only if that debounce already diff --git a/docs/VUE-MIGRATION.md b/docs/VUE-MIGRATION.md index 32df6b782a..5079c0d416 100644 --- a/docs/VUE-MIGRATION.md +++ b/docs/VUE-MIGRATION.md @@ -96,8 +96,16 @@ header's search and expand, the imported files' row actions and the rail chips' icons), the glyphs are `UiIcon`s with `:size="null"`, so the site rules still size them. Core's pressable chips and pills (the rail cards' chips and action chips, Recent Imagery's day chips, SWAP and ZOOM IN, map -sources, cities and places, and the view context's place and layer chips) -are `UiButton`s too; the key setup chip is still a plain button. `UiChip` +sources, cities and places, the view context's place and layer chips and +the key setup chip) are `UiButton`s too. `UiChip` is a non-interactive +label chip, used by the voice card. +header's search and expand, Draw, Import, the imported files' and drawn +shapes' row actions and the rail chips' icons), the glyphs are `UiIcon`s +with `:size="null"`, so the site rules still size them. Core's pressable +chips and pills (the rail cards' chips and action chips, Recent Imagery's +day chips, SWAP and ZOOM IN, map sources, cities and places, and the view +context's place and layer chips) are `UiButton`s too; the key setup chip +is still a plain button. `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: @@ -191,6 +199,51 @@ while a query is typed. The Filter button opens a disclosure and carries 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. +The Space Missions panel's buttons (a mission's roster row, FOCUS, +REPLAY ASCENT, the replay's pause, PREV, NEXT and SHOW ALL / DESELECT), +the Contacts panel's (PREV, FOCUS, NEXT and a contact's row), the Radio +panel's (Enable, PREV, PLAY, NEXT and STOP), the RTL-SDR card's (Connect, +Locate, Change device, FM, ADS-B, Tune and the two seeks) and the key +setup's (the POWER UP chip, a key's REMOVE, the voice auth toggle and +SAVE KEYS) are ghost `UiButton`s. Radio's Enable and the card's Connect, +FM and ADS-B are pressed toggles with `active`; PLAY and Locate keep +their own `active` class without `aria-pressed`, since their words say +what they will do or have done. The chip's bolt is a `UiIcon` with +`:size="null"`, so provider-settings.css still sizes it +(`src/ui/kit/missionsRadioControls.test.mjs` pins it). The card's FM +frequency stays a native number field, which the kit has no control for, +and the replay's pause, the roster's chevron and the compass arrows are +text characters, not Material symbols. +Utilities' Draw and Import are on the kit. Draw (a pressed toggle with +`active`), Clear and Import are ghost `UiButton`s, their glyphs `UiIcon`s +with `pp-icon` and `:size="null"`. Draw's five colour swatches, in the +toolbar and in a drawn shape's row, are ghost `UiButton`s with +`role="radio"`: they say they are chosen with `aria-checked` and their own +`active` class, never `aria-pressed`. A drawn shape's row (its swatch, +show/hide, the application's row actions and fly to, beside its remove +`UiCloseButton`) is on the kit too, its glyphs `UiIcon`s with +`:size="null"`, so `controls.css` still sizes them; show/hide says what it +does in its name (Show …, Hide …) rather than being pressed. The Street +Level panel's controls already were kit controls; its EXPAND ⤢ ⤡ and its +errors' ⚠ are text characters and stay text +(`src/ui/kit/drawControls.test.mjs` pins it). +The AI chat panel's and the voice control's buttons are ghost +`UiButton`s: the chat's Settings, quick prompts, attachment removes, +Attach layer, Attach a file, Expand conversation, command suggestions, +Expand chat, Add attachment and Send (a submit button that turns into +Stop reply), and the voice control's Open AI chat, Back to chat, Back to +voice, its Preview and Settings tabs and the error tray's DISMISS, beside +the tier button, the mic and the dock and minimize buttons, which already +were. The tier button and dock are pressed toggles; the mic is one only +while its owner has a state for it; the tabs keep `role="tab"` and +`aria-selected`. DISMISS is a text button, not a cross, so it is not a +`UiCloseButton`. The Settings and tab glyphs are `UiIcon`s with +`:size="null"`, so voice-cost.css and voice-card.css still size them +(`src/ui/kit/chatVoiceControls.test.mjs` pins it). The chat bubble, +globe, attach, send and stop, expand and Back glyphs stay inline SVG, +since no Material symbol the page loads draws them the same, and the +message box, file picker and inactivity minutes stay native fields, which +the kit has none of. The voice modules build no controls in script. The small surfaces' buttons are ghost `UiButton`s: the locale picker's button, the phone tab bar's tabs, the globe actions' Clear, Share, Reset and north-up compass, the imagery divider's handle, the scene sharing diff --git a/scripts/format-scope.json b/scripts/format-scope.json index 9e135b5904..4440882456 100644 --- a/scripts/format-scope.json +++ b/scripts/format-scope.json @@ -1290,6 +1290,7 @@ "src/render/cesium/zoomOutGuard.test.mjs", "src/app/controls.test.mjs", "scripts/qa-zoom-out-guard.mjs", + "scripts/qa-zoom-under-icon.mjs", "src/hudSummaryGate.test.mjs", "src/hudSummaryLine.test.mjs", "src/testSupport/stubMgrs.mjs", @@ -1350,11 +1351,14 @@ "src/ui/kit/welcomeControls.test.mjs", "src/ui/kit/omnibarControls.test.mjs", "src/ui/kit/storiesControls.test.mjs", + "src/ui/kit/chatVoiceControls.test.mjs", "src/ui/kit/cockpitControls.test.mjs", "src/ui/kit/smallSurfacesControls.test.mjs", "src/ui/kit/commandDockControls.test.mjs", "src/ui/kit/bhoteKoshiControls.test.mjs", "src/ui/bhoteKoshi/BhoteKoshiMediaCards.vue", + "src/ui/kit/missionsRadioControls.test.mjs", + "src/ui/kit/drawControls.test.mjs", "src/ui/styles/chip.css", "src/ui/styles/empty-state.css", "src/ui/rail/RailChips.vue", diff --git a/scripts/qa-zoom-under-icon.mjs b/scripts/qa-zoom-under-icon.mjs new file mode 100644 index 0000000000..2ae7f5366b --- /dev/null +++ b/scripts/qa-zoom-under-icon.mjs @@ -0,0 +1,214 @@ +#!/usr/bin/env node +/** + * Real-app regression: the wheel zooms with an over-depth icon under the + * centre of the canvas. Start a dev server (`npm run dev`), then run this + * file with QA_BASE_URL set to it. + * + * Below 150 km Cesium sizes a zoom step from the depth it picks at the canvas + * centre. An icon drawn over depth must leave nothing there for that pick, or + * the camera takes the icon (a metre away, on the near plane) for the ground + * and stops zooming. + */ +import assert from 'node:assert/strict'; +import puppeteer from 'puppeteer'; + +const origin = process.env.QA_BASE_URL || 'http://localhost:4173'; +const CAMERA_HEIGHT_M = 15_000; +const browser = await puppeteer.launch({ + headless: true, + args: [ + '--no-sandbox', + ...(process.platform === 'darwin' + ? ['--use-angle=metal', '--enable-gpu'] + : [ + '--use-gl=angle', + '--use-angle=swiftshader', + '--enable-unsafe-swiftshader', + ]), + ], + protocolTimeout: 120_000, +}); +const errors = []; +try { + const page = await browser.newPage(); + page.on('pageerror', (error) => errors.push(error.message)); + const viewport = { width: 1200, height: 800 }; + await page.setViewport(viewport); + await page.goto(`${origin}/?welcome=0`, { waitUntil: 'domcontentloaded' }); + await page.waitForFunction( + () => + window.__godsEyeView?.viewer && + window.__godsEyeView.viewer.scene.screenSpaceCameraController + .enableInputs && + document.getElementById('loading-screen')?.classList.contains('hidden'), + { timeout: 90_000 }, + ); + const setup = await page.evaluate(async (cameraHeight) => { + const C = await import('/node_modules/cesium/Build/Cesium/index.js'); + const { drawOf } = await import('/src/render/rendererOf.js'); + const viewer = window.__godsEyeView.viewer; + const scene = viewer.scene; + viewer.camera.cancelFlight(); + viewer.trackedEntity = undefined; + // Explicit real renders make each gesture independent of host frame rate. + viewer.useDefaultRenderLoop = false; + const controller = scene.screenSpaceCameraController; + controller.inertiaZoom = 0; + controller.inertiaSpin = 0; + const lon = -30; + const lat = 40; // open Atlantic: nothing else of the app's draws here + const icons = drawOf(viewer).icons({ id: 'qa-zoom-under-icon' }); + const item = { + id: 'qa-icon', + pos: C.Cartesian3.fromDegrees(lon, lat, 100), + // Held in place on the GPU, as a live aircraft or vessel icon is. + motion: { kind: 'hold', courseDeg: 0 }, + image: `data:image/svg+xml;charset=utf-8,${encodeURIComponent( + '', + )}`, + size: [64, 64], + disableDepthTest: Infinity, + }; + const centre = () => + new C.Cartesian2( + scene.canvas.clientWidth / 2, + scene.canvas.clientHeight / 2, + ); + const frame = () => { + scene.requestRender(); + viewer.render(); + }; + const qa = { + height: () => viewer.camera.positionCartographic.height, + setIcon(shown) { + icons.set(shown ? [item] : []); + }, + reset() { + viewer.camera.cancelFlight(); + viewer.camera.lookAtTransform(C.Matrix4.IDENTITY); + viewer.camera.setView({ + destination: C.Cartesian3.fromDegrees(lon, lat, cameraHeight), + orientation: { heading: 0, pitch: -C.Math.PI_OVER_TWO, roll: 0 }, + }); + frame(); + }, + async frames(count) { + for (let i = 0; i < count; i++) { + frame(); + await new Promise((resolve) => setTimeout(resolve, 0)); + } + return qa.height(); + }, + /** Whether the icon is what a click at the canvas centre picks. */ + iconAtCentre() { + const picked = scene.pick(centre()); + return JSON.stringify(picked?.id ?? null).includes('qa-icon'); + }, + /** Metres from the camera to what the depth pick finds at the centre. */ + centreDepthM() { + frame(); + const point = scene.pickPositionWorldCoordinates(centre()); + return point + ? C.Cartesian3.distance(point, viewer.camera.positionWC) + : null; + }, + }; + window.__zoomUnderIconQa = qa; + const gl = scene.context._gl; + const debug = gl.getExtension('WEBGL_debug_renderer_info'); + return { + renderer: gl.getParameter( + debug ? debug.UNMASKED_RENDERER_WEBGL : gl.RENDERER, + ), + logDepth: scene.logarithmicDepthBuffer, + pickPosition: scene.pickPositionSupported, + }; + }, CAMERA_HEIGHT_M); + console.log( + `[INFO] WebGL renderer: ${setup.renderer}; log depth ${setup.logDepth}`, + ); + assert.ok(setup.pickPosition, 'the context must support depth picks'); + + const qa = (method, ...args) => + page.evaluate( + (name, rest) => window.__zoomUnderIconQa[name](...rest), + method, + args, + ); + const x = viewport.width / 2; + const y = viewport.height / 2; + await page.mouse.move(x, y); + /** Wheel `deltaY` at the canvas centre, then the settled camera height. */ + const wheel = async (deltaY) => { + await qa('reset'); + await page.evaluate( + ({ x, y, deltaY }) => { + window.__godsEyeView.viewer.canvas.dispatchEvent( + new WheelEvent('wheel', { + deltaY, + clientX: x, + clientY: y, + bubbles: true, + cancelable: true, + }), + ); + }, + { x, y, deltaY }, + ); + return qa('frames', 40); + }; + + // The ground alone: what the icon must not change. + await qa('setIcon', false); + await qa('reset'); + await qa('frames', 10); + const groundDepth = await qa('centreDepthM'); + const groundIn = await wheel(-600); + const groundOut = await wheel(600); + console.log( + `[INFO] no icon: centre depth ${groundDepth?.toFixed(1)} m, wheel in to ${groundIn.toFixed(0)} m, out to ${groundOut.toFixed(0)} m`, + ); + assert.ok(groundIn < CAMERA_HEIGHT_M * 0.95, 'control: wheel in zooms in'); + assert.ok(groundOut > CAMERA_HEIGHT_M * 1.05, 'control: wheel out zooms out'); + + await qa('setIcon', true); + await qa('reset'); + await page.waitForFunction( + async () => { + await window.__zoomUnderIconQa.frames(1); + return window.__zoomUnderIconQa.iconAtCentre(); + }, + { timeout: 30_000 }, + ); + console.log('[PASS] the icon draws under the canvas centre'); + + const depth = await qa('centreDepthM'); + const zoomedIn = await wheel(-600); + const zoomedOut = await wheel(600); + console.log( + `[INFO] icon at centre: depth pick ${depth === null ? 'finds nothing' : `${depth.toFixed(3)} m away`}, wheel in to ${zoomedIn.toFixed(0)} m, out to ${zoomedOut.toFixed(0)} m`, + ); + assert.ok( + depth === null || depth > 100, + `the depth pick must not land on the icon (${depth} m from the camera)`, + ); + console.log('[PASS] the depth pick at the centre ignores the icon'); + assert.ok( + zoomedIn < CAMERA_HEIGHT_M * 0.95, + `wheel in must zoom in under an icon (height ${zoomedIn.toFixed(1)} m)`, + ); + console.log('[PASS] wheel in zooms in'); + assert.ok( + zoomedOut > CAMERA_HEIGHT_M * 1.05, + `wheel out must zoom out under an icon (height ${zoomedOut.toFixed(1)} m)`, + ); + console.log('[PASS] wheel out zooms out'); + + assert.ok(await qa('iconAtCentre'), 'the icon must still pick by click'); + console.log('[PASS] the icon still picks by click'); + + assert.deepEqual(errors, [], 'no JavaScript page errors'); + console.log('[PASS] no JavaScript page errors'); +} finally { + await browser.close(); +} diff --git a/src/render/cesium/iconSetPrimitive.js b/src/render/cesium/iconSetPrimitive.js index 432f78ffd1..581fb95f46 100644 --- a/src/render/cesium/iconSetPrimitive.js +++ b/src/render/cesium/iconSetPrimitive.js @@ -92,6 +92,7 @@ out vec2 v_uv; out vec4 v_color; out vec4 v_pickColor; out float v_proxy; +out float v_overDepth; // 1 for a row drawn over depth, on the near plane // The row's anchor in clip space before screen offsets, for effects that wrap // main() (sonar) and must not change geometry or picks. @@ -125,6 +126,7 @@ void main() { v_uv = vec2(0.0); v_color = vec4(0.0); v_proxy = 0.0; + v_overDepth = 0.0; gl_Position = vec4(0.0, 0.0, 2.0, 1.0); // outside the clip volume: not drawn float flags = style1.z; @@ -260,14 +262,9 @@ void main() { distanceSq < style3.w * style3.w; if (overDepth && zclip >= -1.0 && zclip <= 1.0) { gl_Position.z = -gl_Position.w; -#ifdef LOG_DEPTH - // Just past the near plane, not on it: czm_writeLogDepth discards a - // fragment at or below 0.9999999, and 1.0 interpolated across the quad - // can arrive a rounding step or two under that, dropping the icon for a - // frame as it moves (flicker). 1e-4 m past the near plane is still in - // front of everything the scene draws. - v_depthFromNearPlusOne = 1.0001; -#endif + // With a log depth buffer the fragment shader writes the near plane's + // depth itself. + v_overDepth = 1.0; } v_uv = mix(rect.xy, rect.zw, vec2(corner.x * 0.5 + 0.5, 0.5 - corner.y * 0.5)); @@ -282,6 +279,7 @@ in vec2 v_uv; in vec4 v_color; in vec4 v_pickColor; in float v_proxy; +in float v_overDepth; void main() { vec4 color = czm_gammaCorrect(texture(u_atlas, v_uv)); @@ -296,7 +294,16 @@ void main() { #endif out_FragColor = color; #ifdef LOG_DEPTH - czm_writeLogDepth(v_depthFromNearPlusOne); + // Over depth: exactly the near plane's depth, written here and not through + // czm_writeLogDepth. That function discards a fragment whose interpolated + // depth arrives a rounding step under the near plane (the icon drops for a + // frame as it moves), and any depth past the near plane is a surface to + // Cesium's depth pick: the camera controller then sizes a zoom step from an + // icon under the canvas centre, a near plane's distance away, and the wheel + // stops zooming. The pick reads a depth of 0 as nothing drawn, and keeps + // the depth of the ground under the icon. + if (v_overDepth > 0.5) gl_FragDepth = 0.0; + else czm_writeLogDepth(v_depthFromNearPlusOne); #endif } `; diff --git a/src/render/cesium/iconSetPrimitive.test.mjs b/src/render/cesium/iconSetPrimitive.test.mjs index 511acf676e..562a125a61 100644 --- a/src/render/cesium/iconSetPrimitive.test.mjs +++ b/src/render/cesium/iconSetPrimitive.test.mjs @@ -1,5 +1,6 @@ import assert from 'node:assert/strict'; import test from 'node:test'; +import fs from 'node:fs'; import * as Cesium from 'cesium'; import { createIconSet } from '../../data/iconSet.js'; import { IconSetPrimitive } from './iconSetPrimitive.js'; @@ -58,3 +59,29 @@ test('by default the set draws an opaque pass and a translucent one, and draws n assert.equal(translucent.renderState.depthMask, false); assert.equal(primitive.drawsBlend('translucent'), false); }); + +test('an over-depth row writes a depth of exactly 0, which a depth pick ignores', () => { + // Shaders do not compile under node: this reads the fragment shader's + // source. A depth past the near plane (as 1.0001 through + // czm_writeLogDepth was) is a surface to Cesium's depth pick, a near + // plane's distance from the camera, and the wheel stops zooming with an + // icon under the canvas centre (scripts/qa-zoom-under-icon.mjs). + const source = fs.readFileSync( + new URL('./iconSetPrimitive.js', import.meta.url), + 'utf8', + ); + const [vertex, fragment] = source + .slice(source.indexOf('const VERTEX_SHADER')) + .split('const FRAGMENT_SHADER') + .map((shader) => shader.replace(/\/\/.*$/gm, '')); // comments out + assert.match( + fragment, + /if \(v_overDepth > 0\.5\) gl_FragDepth = 0\.0;\s+else czm_writeLogDepth\(v_depthFromNearPlusOne\);/, + ); + // The vertex shader flags the row and leaves its log depth alone. + assert.match( + vertex, + /gl_Position\.z = -gl_Position\.w;[^}]*v_overDepth = 1\.0;/, + ); + assert.doesNotMatch(vertex, /v_depthFromNearPlusOne\s*=/); +}); diff --git a/src/ui/kit/chatVoiceControls.test.mjs b/src/ui/kit/chatVoiceControls.test.mjs new file mode 100644 index 0000000000..b1716157ca --- /dev/null +++ b/src/ui/kit/chatVoiceControls.test.mjs @@ -0,0 +1,150 @@ +// The AI chat panel's and the voice control's buttons and Material glyphs +// are the kit's: neither their templates nor the voice card and panel +// layout buttons they render hand-write a +