feat(viewer): unify spatial clipping, planning and observation surfaces

Share spatial clipping and height slices across live planning and recorded observations. Refine scene navigation, report serialization and viewer presentation.
This commit is contained in:
DCCONSTRUCTIONS
2026-10-29 09:10:01 +03:00
parent f48411f8fe
commit 7878937691
40 changed files with 464 additions and 138 deletions
@@ -0,0 +1,6 @@
/** View-only bounds. Each full-range endpoint disables its own clipping plane. */
export function heightSlice([lower, upper]: readonly [number, number], [min, max]: readonly [number, number]) {
const tolerance = Math.max(1, max - min) * 1e-9;
return { floor: lower <= min + tolerance ? null : lower,
ceiling: upper >= max - tolerance ? null : upper };
}
@@ -2,7 +2,7 @@ import { createContext, useCallback, useContext, useEffect, useRef, useState, ty
import { plannerBase, plannerRequest, type Draft } from './planner';
export interface PlanningLiveTest {
schema_version: 'missioncore.planning-live-test/v1'; id: string; profile: 'planning'; plugin_id:string; draft: Draft;
schema_version: 'missioncore.planning-live-test/v1'|'missioncore.planning-live-status/v1'; id: string; profile: 'planning'; plugin_id:string; draft: Omit<Draft,'route'> & {route:Omit<Draft['route'],'points'>};
state: 'preparing'|'waiting'|'running'|'completed'|'cancelled'|'error'|'interrupted';
planning_phase?: 'preparing'|'waiting-cloud'|'collecting'|'searching'|'refreshing'|'validating'|'tracking'|'lost'|'ended';
tracking_state?: 'acquiring'|'tracking'|'lost';
@@ -40,7 +40,7 @@ export function PlanningTestProvider({children}:{children:ReactNode}) {
let disposed=false, timer:ReturnType<typeof setTimeout>;
const poll=async()=>{
const expected=generation.current;
try { const next=await plannerRequest<PlanningLiveTest|null>(endpoint+'/active'); if(!disposed && expected===generation.current) {setTest(next);setPollError(null);} }
try { const next=await plannerRequest<PlanningLiveTest|null>(endpoint+'/status'); if(!disposed && expected===generation.current) {setTest(next);setPollError(null);} }
catch(e) {if(!disposed && expected===generation.current)setPollError(e instanceof Error?e.message:'Исследование недоступно.');}
if(!disposed)timer=setTimeout(()=>void poll(),1500);
};void poll();return()=>{disposed=true;clearTimeout(timer);};
@@ -22,13 +22,13 @@ export async function fetchOverviewSpatial(source: string, signal: AbortSignal):
return response.json();
}
export async function updateOverviewSpatial(source: string, ceiling: number | null, mode: OverviewViewMode | null, aspect: number, signal: AbortSignal,
comparisonGeneration: string | null = null, representation: OverviewRepresentation = "original") {
comparisonGeneration: string | null = null, representation: OverviewRepresentation = "original", floor: number | null = null) {
if (representation === "corrected" && !comparisonGeneration) throw new Error("Исправленная версия недоступна.");
const url = endpoint(source);
const generation = url.searchParams.get("generation");
url.search = "";
const response = await fetch(url, { method: "POST", signal, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ generation, ceiling_m: ceiling, mode, aspect,
body: JSON.stringify({ generation, ceiling_m: ceiling, floor_m: floor, mode, aspect,
comparison_generation: comparisonGeneration, representation }) });
if (!response.ok) throw new Error("Не удалось обновить вид облака.");
const bytes = new Uint8Array(await response.arrayBuffer());