Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions public/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"description": "Use latest data point in the last year, or the most recent data point within the last 15 seconds"
}
}
},
"defaultVisibility": {
"type": "boolean",
"default": true,
"description": "Show this layer by default"
}
}
}
Expand Down Expand Up @@ -183,6 +188,11 @@
]
}
}
},
"defaultVisibility": {
"type": "boolean",
"default": true,
"description": "Show this layer by default"
}
}
}
Expand Down Expand Up @@ -305,6 +315,11 @@
]
}
}
},
"defaultVisibility": {
"type": "boolean",
"default": true,
"description": "Show this layer by default"
}
}
}
Expand Down Expand Up @@ -417,6 +432,11 @@
]
}
}
},
"defaultVisibility": {
"type": "boolean",
"default": true,
"description": "Show this layer by default"
}
}
}
Expand Down Expand Up @@ -500,6 +520,11 @@
]
}
}
},
"defaultVisibility": {
"type": "boolean",
"default": true,
"description": "Show this layer by default"
}
}
}
Expand Down
65 changes: 0 additions & 65 deletions src/UIDataContext.tsx

This file was deleted.

6 changes: 6 additions & 0 deletions src/buildScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function buildScene(
positioning={positioning}
treePath={getTreePath()}
name={layer.mapName || "Ground Plane"}
visible={layer.defaultVisibility}
/>
);
}
Expand All @@ -59,6 +60,7 @@ export function buildScene(
dataSource={dataSource as UniverseTelemetrySource}
name={layer.mapName || "Map"}
treePath={getTreePath()}
visible={layer.defaultVisibility}
/>
);
});
Expand All @@ -74,6 +76,7 @@ export function buildScene(
positioning={positioning}
treePath={getTreePath()}
name={layer.name || "Marker"}
visible={layer.defaultVisibility}
/>
);
}
Expand All @@ -86,6 +89,7 @@ export function buildScene(
dataSource={dataSource as UniverseTelemetrySource | undefined}
treePath={getTreePath()}
name={layer.name || "Point Cloud"}
visible={layer.defaultVisibility}
/>
);
});
Expand All @@ -102,6 +106,7 @@ export function buildScene(
dataSource={dataSource as UniverseTelemetrySource}
treePath={getTreePath()}
name={layer.name || "Geometry"}
visible={layer.defaultVisibility}
/>
);
}
Expand All @@ -117,6 +122,7 @@ export function buildScene(
name={device.name}
id={currentDeviceId || undefined}
treePath={[devices.length]}
visible={device.defaultVisibility}
>
{mapLayers}
{deviceLayers}
Expand Down
45 changes: 25 additions & 20 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Authentication, App } from "@formant/data-sdk";
import { TelemetryUniverseData } from "@formant/universe-connector";
import { StreamType, UniverseDataSource } from "@formant/universe-core";
import { DataSourceBuilder } from "./layers/utils/DataSourceBuilder";
import { Positioning } from "./layers/common/Positioning";
import { PositioningBuilder } from "./layers/utils/PositioningBuilder";
import { Authentication, App } from '@formant/data-sdk';
import { TelemetryUniverseData } from '@formant/universe-connector';
import { StreamType, UniverseDataSource } from '@formant/universe-core';
import { DataSourceBuilder } from './layers/utils/DataSourceBuilder';
import { Positioning } from './layers/common/Positioning';
import { PositioningBuilder } from './layers/utils/PositioningBuilder';

// get query strings
const urlParams = new URLSearchParams(window.location.search);
const deviceId = urlParams.get("device") ?? undefined;
const deviceId = urlParams.get('device') ?? undefined;

export type Viewer3DConfiguarationPositioning = {
positioningType?: "Fixed" | "Gps" | "Odometry" | "Transform Tree" | "Hud";
positioningType?: 'Fixed' | 'Gps' | 'Odometry' | 'Transform Tree' | 'Hud';
x?: number;
y?: number;
z?: number;
Expand Down Expand Up @@ -38,29 +38,34 @@ export type Viewer3DConfiguration = {
pointCloudLayers?: {
name?: string;
dataSource?: Viewer3DConfigurationDataSource;
defaultVisibility?: boolean;
}[];
mapLayers?: {
mapType?: "Ground Plane" | "World Map";
worldMapType?: "Satellite" | "Street" | "Satellite Street";
mapType?: 'Ground Plane' | 'World Map';
worldMapType?: 'Satellite' | 'Street' | 'Satellite Street';
mapName?: string;
mapSize?: string;
longitude?: string;
latitude?: string;
mapboxKey?: string;
dataSource?: Viewer3DConfigurationDataSource;
positioning?: Viewer3DConfiguarationPositioning;
defaultVisibility?: boolean;
}[];
deviceVisualLayers?: {
name?: string;
visualType?: "Circle";
visualType?: 'Circle';
dataSource?: Viewer3DConfigurationDataSource;
positioning?: Viewer3DConfiguarationPositioning;
defaultVisibility?: boolean;
}[];
geometryLayers?: {
name?: string;
dataSource?: Viewer3DConfigurationDataSource;
positioning?: Viewer3DConfiguarationPositioning;
defaultVisibility?: boolean;
}[];
defaultVisibility?: boolean;
}[];
};

Expand All @@ -70,7 +75,7 @@ export function parseDataSource(
if (dataSource.telemetryStreamName) {
return DataSourceBuilder.telemetry(
dataSource.telemetryStreamName,
(dataSource.telemetryStreamType as StreamType) || "json",
(dataSource.telemetryStreamType as StreamType) || 'json',
dataSource.latestDataPoint
);
}
Expand All @@ -81,25 +86,25 @@ export function parsePositioning(
positioning: Viewer3DConfiguarationPositioning
): Positioning {
switch (positioning.positioningType) {
case "Fixed":
case 'Fixed':
return PositioningBuilder.fixed(
positioning.x || 0,
positioning.y || 0,
positioning.z || 0
);
case "Gps":
return PositioningBuilder.gps(positioning.gpsStream || "", {
case 'Gps':
return PositioningBuilder.gps(positioning.gpsStream || '', {
long: positioning.relativeLongitude || 0,
lat: positioning.relativeLatitude || 0,
});
case "Odometry":
case 'Odometry':
return PositioningBuilder.localization(
positioning.localizationStream || ""
positioning.localizationStream || ''
);
case "Transform Tree":
case 'Transform Tree':
return PositioningBuilder.tranformTree(
positioning.transformTreeStream || "",
positioning.transformTreeEndPoint || ""
positioning.transformTreeStream || '',
positioning.transformTreeEndPoint || ''
);
default:
return PositioningBuilder.fixed(0, 0, 0);
Expand Down
4 changes: 2 additions & 2 deletions src/layers/DataVisualizationLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export function DataVisualizationLayer(props: IDataVisualizationLayerProps) {

const { register, layers } = useContext(UIDataContext);
useEffect(() => {
const autoId = id || getUuid(JSON.stringify({ name, type, treePath }));
const registeredLayer = register(name || "Layer", autoId, type || LayerType.UNDEFINED, treePath);
const autoId = id || getUuid(JSON.stringify({ name, type, treePath, deviceId }));
const registeredLayer = register(name || "Layer", autoId, type || LayerType.UNDEFINED, treePath, visible);
setThisLayer(registeredLayer);
}, []);

Expand Down
12 changes: 7 additions & 5 deletions src/layers/common/UIDataContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface LayerData {

interface UIContextData {
layers: LayerData[];
register: (name: string, id: string, type: LayerType, treePath?: number[]) => LayerData;
register: (name: string, id: string, type: LayerType, treePath?: number[], defaultVisibility?: boolean) => LayerData;
toggleVisibility: (id: string) => void;
cameraTargetId: string;
setCameraTargetId: (id: string) => void;
Expand All @@ -22,7 +22,7 @@ export const UIDataContext =
React.createContext<UIContextData>(
{
layers: [],
register: (name: string, id: string, type: LayerType, treePath?: number[]) => { return { name, id, type, visible: true, treePath } },
register: (name: string, id: string, type: LayerType, treePath?: number[], defaultVisibility?: boolean) => { return { name, id, type, visible: true, treePath } },
toggleVisibility: (id: string) => { },
cameraTargetId: '',
setCameraTargetId: (id: string) => { }
Expand All @@ -34,9 +34,11 @@ export function useUI(): UIContextData {
const [layers, setLayers] = React.useState<LayerData[]>([]);
const [cameraTargetId, setCameraTargetId] = React.useState<string>('');

const register = (name: string, id: string, type: LayerType, treePath?: number[]) => {
const visible = JSON.parse(sessionStorage.getItem(`${id}-visible`) || 'true');
const layer = { name, id, visible, type, treePath };
const register = (name: string, id: string, type: LayerType, treePath?: number[], defaultVisibility?: boolean) => {
const storedVisibility = JSON.parse(sessionStorage.getItem(`${id}-visible`) || 'null');
const visible = storedVisibility === null ? defaultVisibility : storedVisibility;
const layer = { name, id, visible: visible === undefined ? true : visible, type, treePath };


setLayers(prevState => [...prevState, layer]);
return layer;
Expand Down