feat(observatory): persist scene profiles and stable device view bindings
This commit is contained in:
@@ -8,6 +8,7 @@ export function ObservationTimeline({
|
||||
sourceCount,
|
||||
mode = "live-only",
|
||||
seekable = false,
|
||||
followingLive,
|
||||
synchronization = "host-arrival-best-effort",
|
||||
rangeNs = null,
|
||||
currentNs = null,
|
||||
@@ -28,6 +29,8 @@ export function ObservationTimeline({
|
||||
sourceCount: number;
|
||||
mode?: ObservationTimelineMode;
|
||||
seekable?: boolean;
|
||||
/** Defined by a live receiver with a retained native recording. */
|
||||
followingLive?: boolean;
|
||||
synchronization?: "host-arrival-best-effort" | "shared-clock" | "frame-accurate";
|
||||
rangeNs?: { min: number; max: number } | null;
|
||||
currentNs?: number | null;
|
||||
@@ -69,6 +72,7 @@ export function ObservationTimeline({
|
||||
className={`observation-timeline nodedc-viewport-controls ${className}`.trim()}
|
||||
data-active={active ? "true" : undefined}
|
||||
data-mode={mode}
|
||||
data-live-history={followingLive === undefined ? undefined : "true"}
|
||||
data-accumulation={accumulationValue !== null ? "true" : undefined}
|
||||
>
|
||||
{accumulationValue !== null ? (
|
||||
@@ -140,18 +144,18 @@ export function ObservationTimeline({
|
||||
? `${formatTimelineDuration(elapsedSeconds)} / ${formatTimelineDuration(durationSeconds)}`
|
||||
: active ? "LIVE" : "—:—:—.———"}
|
||||
</code>
|
||||
<small>
|
||||
{followingLive === undefined ? <small>
|
||||
{buffered ? `${sourceCount} каналов` : `${synchronizationLabel} · буфер не включён`}
|
||||
</small>
|
||||
</small> : null}
|
||||
</div>
|
||||
{showJumpToEnd ? (
|
||||
<Button variant="ghost" shape="pill"
|
||||
className="observation-timeline__follow"
|
||||
data-active={!buffered && active ? "true" : undefined}
|
||||
data-active={(followingLive === undefined ? !buffered && active : followingLive && active) ? "true" : undefined}
|
||||
disabled={buffered ? !onJumpToEnd : true}
|
||||
onClick={onJumpToEnd}
|
||||
>
|
||||
{buffered ? "К КОНЦУ" : "ЭФИР"}
|
||||
{followingLive !== undefined || !buffered ? "ЭФИР" : "К КОНЦУ"}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@@ -25,7 +25,7 @@ export function SceneDisplayControls({displayDraft,stageDisplayPatch,commitDispl
|
||||
}) { return (
|
||||
<Inspector
|
||||
defaultOpen={["points"]}
|
||||
singleOpen
|
||||
variant="panel"
|
||||
sections={[
|
||||
{
|
||||
id: "points",
|
||||
@@ -60,6 +60,7 @@ export function SceneDisplayControls({displayDraft,stageDisplayPatch,commitDispl
|
||||
/>
|
||||
<p className="scene-window-note">0% — все точки, 100% — без точек. Предпросмотр обновляется после изменения. Настройки сохраняются при закрытии окна; исходная запись не меняется.</p>
|
||||
</> : null}
|
||||
<div className="scene-select-grid">
|
||||
<div className="scene-settings-commit-field" onBlur={flushDisplaySettings}>
|
||||
<ControlRow label="Атрибут цвета">
|
||||
<Select
|
||||
@@ -82,6 +83,7 @@ export function SceneDisplayControls({displayDraft,stageDisplayPatch,commitDispl
|
||||
/>
|
||||
</ControlRow>
|
||||
</div>
|
||||
</div>
|
||||
{displayDraft.palette === "custom" || displayDraft.colorMode === "class" ? (
|
||||
<div
|
||||
className="scene-settings-commit-field"
|
||||
|
||||
@@ -3,7 +3,7 @@ import type {SceneSettings} from './sceneSettings';
|
||||
export function SceneLayerControls({sceneSettings,pending=false,applyScenePatch}:{sceneSettings:SceneSettings;pending?:boolean;applyScenePatch:(patch:Partial<SceneSettings>)=>void}) { return (
|
||||
<Inspector
|
||||
defaultOpen={["geometry"]}
|
||||
singleOpen
|
||||
variant="panel"
|
||||
sections={[
|
||||
{
|
||||
id: "geometry",
|
||||
|
||||
@@ -5,13 +5,13 @@ import {StatusBadge} from '@nodedc/ui-react';
|
||||
export function SpatialScene({viewportRef, focused, primaryFocused, mediaMaximized, toolbar,
|
||||
renderer, deviceControls, sourceControls, status, metrics, timeline, media, overlays, footer}: {
|
||||
viewportRef: RefObject<HTMLDivElement|null>; focused?:boolean; primaryFocused?:boolean;
|
||||
mediaMaximized?:boolean; toolbar:ReactNode; renderer:ReactNode; deviceControls?:ReactNode;
|
||||
mediaMaximized?:boolean; toolbar?:ReactNode; renderer:ReactNode; deviceControls?:ReactNode;
|
||||
sourceControls?:ReactNode; status:{label:string;tone:'neutral'|'success'|'warning'|'danger';message?:string;pulse?:boolean};
|
||||
metrics:ReactNode; timeline?:ReactNode; media?:ReactNode; overlays?:ReactNode; footer?:ReactNode;
|
||||
}) {
|
||||
const detailsHidden = primaryFocused || mediaMaximized;
|
||||
return <div className="spatial-workspace" data-focused={focused?'true':undefined}>
|
||||
<div className="spatial-toolbar" data-viewer-controls="v1"><div className="spatial-toolbar__actions nodedc-viewport-controls">{toolbar}</div></div>
|
||||
return <div className="spatial-workspace" data-toolbar={toolbar?undefined:'absent'} data-focused={focused?'true':undefined}>
|
||||
{toolbar&&<div className="spatial-toolbar" data-viewer-controls="v1"><div className="spatial-toolbar__actions nodedc-viewport-controls">{toolbar}</div></div>}
|
||||
<div ref={viewportRef} className="spatial-viewport-shell" data-primary-focused={primaryFocused?'true':undefined} data-media-maximized={mediaMaximized?'true':undefined}>
|
||||
{renderer}
|
||||
{deviceControls&&<div className="scene-device-controls">{deviceControls}</div>}
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import './spatial.css';
|
||||
import './scene-windows.css';
|
||||
import './observation.css';
|
||||
export * from './heightSlice';
|
||||
export * from './SceneDisplayControls';
|
||||
export * from './SceneLayerControls';
|
||||
export * from './SpatialToolbarActions';
|
||||
|
||||
@@ -608,3 +608,15 @@ i[data-availability="error"] {
|
||||
grid-auto-rows: minmax(14rem, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Live review has two full-width tracks; archive transport remains unchanged. */
|
||||
.observation-timeline[data-live-history="true"] {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.observation-timeline[data-live-history="true"] .observation-timeline__playback {
|
||||
grid-template-columns: auto auto minmax(3rem, 1fr) auto auto;
|
||||
}
|
||||
.observation-timeline[data-live-history="true"] .observation-timeline__playback > .nodedc-button:first-child {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
@@ -83,3 +83,5 @@
|
||||
}
|
||||
|
||||
.inspector-control-stack { display:grid; gap:1rem; }
|
||||
|
||||
.scene-select-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: var(--nodedc-space-3); min-width: 0; }
|
||||
|
||||
@@ -7,6 +7,9 @@ export const MAX_ACCUMULATION_SECONDS = 3 * 60;
|
||||
|
||||
export interface SceneSettings {
|
||||
projection: SceneProjection;
|
||||
followTrajectory?: boolean;
|
||||
heightFloor?: number | null;
|
||||
heightCeiling?: number | null;
|
||||
pointSize: number;
|
||||
pointDecimationPercent?: number;
|
||||
accumulationMaxSeconds?: number;
|
||||
@@ -23,6 +26,9 @@ export interface SceneSettings {
|
||||
|
||||
export const defaultSceneSettings: SceneSettings = {
|
||||
projection: "3d",
|
||||
followTrajectory: false,
|
||||
heightFloor: null,
|
||||
heightCeiling: null,
|
||||
pointSize: 2.5,
|
||||
pointDecimationPercent: 0,
|
||||
accumulationMaxSeconds: MAX_ACCUMULATION_SECONDS,
|
||||
@@ -36,3 +42,19 @@ export const defaultSceneSettings: SceneSettings = {
|
||||
showLabels: false,
|
||||
showCameraFrustums: true,
|
||||
};
|
||||
|
||||
/** Read a portable view profile; reject malformed persisted values as one unit. */
|
||||
export function readSceneSettings(value: unknown): SceneSettings | null {
|
||||
if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
|
||||
const s = {...defaultSceneSettings, ...value} as SceneSettings;
|
||||
if (![s.pointSize, s.accumulationSeconds, s.accumulationMaxSeconds, s.pointDecimationPercent].every(v=>typeof v==='number'&&Number.isFinite(v))
|
||||
|| typeof s.followTrajectory !== 'boolean'
|
||||
|| [s.heightFloor,s.heightCeiling].some(v=>v!==null&&(typeof v!=='number'||!Number.isFinite(v)))
|
||||
|| (s.heightFloor!=null&&s.heightCeiling!=null&&s.heightFloor>s.heightCeiling)
|
||||
|| s.pointSize < .5 || s.pointSize > 12 || s.accumulationSeconds < 0 || s.accumulationMaxSeconds! < 1
|
||||
|| s.pointDecimationPercent! < 0 || s.pointDecimationPercent! > 100
|
||||
|| !['3d','2d','map'].includes(s.projection) || !['intensity','height','distance','rgb','class'].includes(s.colorMode)
|
||||
|| !['turbo','viridis','plasma','grayscale','custom'].includes(s.palette) || !/^#[a-f0-9]{6}$/i.test(s.customColor)
|
||||
|| ['showPoints','showTrajectory','showGrid','showLabels','showCameraFrustums'].some(k=>typeof s[k as keyof SceneSettings]!=='boolean')) return null;
|
||||
return Object.fromEntries(Object.keys(defaultSceneSettings).map(k=>[k,s[k as keyof SceneSettings]])) as unknown as SceneSettings;
|
||||
}
|
||||
|
||||
@@ -507,3 +507,8 @@
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.busy-indicator { animation: none; }
|
||||
}
|
||||
|
||||
.spatial-workspace[data-toolbar="absent"] { grid-template-rows: minmax(0, 1fr) auto; gap: 0; }
|
||||
|
||||
.scene-height-slice { position:absolute; z-index:2; top:64px; right:12px; bottom:104px; width:58px; display:flex; flex-direction:column; align-items:center; color:var(--nodedc-text-muted); font-size:var(--nodedc-font-size-xs); }
|
||||
.scene-height-slice > .nodedc-range-scale { flex:1; min-height:0; }
|
||||
|
||||
Reference in New Issue
Block a user