Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
3837012
fix(hybrid_viewer): light entries hold one part per actor
JulienChampagnol Dec 2, 2026
4fe0b7e
feat(hybrid_viewer): detailed light viewables after the bounding box
JulienChampagnol Dec 2, 2026
bf475f9
feat(hybrid_viewer): light actors follow component visibility
JulienChampagnol Dec 2, 2026
16ed9bf
perf(hybrid_viewer): one merged light actor per data
JulienChampagnol Dec 2, 2026
745ee23
fix(hybrid_viewer): light view races, z-scaled bounds, explode kept
JulienChampagnol Dec 2, 2026
ebf020f
fix(hybrid_viewer): corners visible in the light view
JulienChampagnol Dec 2, 2026
584f61f
feat(hybrid_viewer): light parts drawn with their own colours
JulienChampagnol Dec 2, 2026
e3f9468
feat(hybrid_viewer): light view built with the data styles
JulienChampagnol Dec 2, 2026
6a67dd1
feat(hybrid_viewer): light view follows style changes
JulienChampagnol Dec 2, 2026
61b06bf
fix(hybrid_viewer): light corners take the model points size
JulienChampagnol Dec 2, 2026
3adc976
fix(hybrid_viewer): light colours in vtk.js cell order, recoloured at…
JulienChampagnol Dec 2, 2026
52cf533
fix(hybrid_viewer): recoloured light parts shown at once
JulienChampagnol Dec 2, 2026
a9d6304
fix(hybrid_viewer): light view styles use the viewer schema types
JulienChampagnol Dec 2, 2026
e7ae86a
fix(hybrid_viewer): light lines and corners drawn in front of surfaces
JulienChampagnol Dec 2, 2026
521be69
feat(viewer_reset): app highlight colours sent to the viewer
JulienChampagnol Dec 3, 2026
bd84167
fix(nuxt_config): pre-bundle the vtk.js modules of the light view
JulienChampagnol Dec 3, 2026
802eb06
Merge remote-tracking branch 'origin/next' into feat/component_light_…
JulienChampagnol Dec 3, 2026
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
5 changes: 5 additions & 0 deletions app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ChromeTheme } from "@ogw_front/composables/chrome_theme";
import type { HighlightColors } from "@ogw_front/utils/highlight_colors";
import type { SceneColors } from "@ogw_front/utils/default_styles";

declare module "nuxt/schema" {
Expand All @@ -10,6 +11,8 @@ declare module "nuxt/schema" {
basemap?: boolean;
// Colors ({ red, green, blue, alpha }) of a new or reset scene, see plugins/scene_colors.ts
sceneColors?: SceneColors;
// Highlight colors ({ red, green, blue }) given to the viewer, see utils/highlight_colors.ts
highlightColors?: HighlightColors;
};
}
}
Expand All @@ -28,5 +31,7 @@ export default defineAppConfig({
basemap: false,
// Colors of a new or reset scene, the OpenGeodeWeb ones when not set (see utils/default_styles)
sceneColors: {},
// Highlight colors given to the viewer, its own (brand-neutral) ones when not set
highlightColors: undefined,
},
});
2 changes: 1 addition & 1 deletion app/components/ClippingPlanes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ watch(allItems, () => {
});

watch(
() => Object.values(hybridViewerStore.hybridDb).filter((entry) => entry && entry.actor).length,
() => Object.values(hybridViewerStore.hybridDb).filter(Boolean).length,
(actorCount) => {
if (show.value && actorCount > 0) {
updateWidgetPlacement({ isReset: true });
Expand Down
2 changes: 1 addition & 1 deletion app/components/FactorFilterPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ watch(allItems, () => {
});

watch(
() => Object.values(hybridViewerStore.hybridDb).filter((entry) => entry && entry.actor).length,
() => Object.values(hybridViewerStore.hybridDb).filter(Boolean).length,
(actorCount) => {
if (show.value && actorCount > 0) {
applyFactor();
Expand Down
7 changes: 4 additions & 3 deletions app/composables/clipping_planes_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
alignCameraToMainCamera,
computeSceneBoundsInfo,
followsSceneCenter,
resolveActiveActors,
resolveActiveEntries,
} from "@ogw_front/utils/clipping_planes";
import {
type ClippingPlane,
Expand All @@ -19,6 +19,7 @@ import type { Coordinates } from "@ogw_front/types/geometry";
import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
import type { DataIdentified } from "@ogw_front/types/identifiers";
import type { vtkGenericRenderWindow as GenericRenderWindowInstance } from "@ogw_internal/stores/hybrid_viewer/vtk_types";
import { entrySceneBounds } from "@ogw_internal/stores/hybrid_viewer/parts";
import type { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
import type { vtkCamera } from "@kitware/vtk.js/Rendering/Core/Camera";
import { newInstance as vtkGenericRenderWindow } from "@kitware/vtk.js/Rendering/Misc/GenericRenderWindow";
Expand Down Expand Up @@ -58,12 +59,12 @@ function useClippingPlanesWidget({

function getSceneBoundsInfo(): SceneBoundsInfo {
return computeSceneBoundsInfo(
resolveActiveActors(
resolveActiveEntries(
targetAllVisible.value,
allItems.value,
selectedDatasetIds.value,
hybridViewerStore.hybridDb,
),
).map((entry) => entrySceneBounds(entry)),
);
}
function getSceneCenter(): Readonly<Coordinates> {
Expand Down
12 changes: 10 additions & 2 deletions app/composables/crs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Coordinate } from "@ogw_front/types/geometry";
import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
import type { LightViewable } from "@ogw_front/types/data";
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
import { clearComponentLightViewables } from "@ogw_internal/stores/data/model/light_viewables";
import { reloadObject } from "@ogw_front/utils/reload_object";
import { useBackStore } from "@ogw_front/stores/back";
import { useCrsStore } from "@ogw_front/stores/crs";
Expand Down Expand Up @@ -66,16 +67,23 @@ async function refresh(
{ binary_light_viewable, crs }: MovedData,
focus = true,
): Promise<void> {
// The local actor is rebuilt from the stored light viewable: store the moved one first
// The local actor is rebuilt from the stored light viewable: store the moved one first.
// The previous detail no longer matches the geometry: dropped, then asked again
const dataStore = useDataStore();
const hybridViewerStore = useHybridViewerStore();
hybridViewerStore.cancelRefine(item.data_id);
await clearComponentLightViewables(item.data_id);
await dataStore.updateItem(item.data_id, { binary_light_viewable });
await reloadObject(item.data_id, { rebuildActor: true });
// Only then the CRS: a basemap built for the new CRS reads the data bounds from the actors,
// Which must no longer hold the previous coordinates
await dataStore.updateItem(item.data_id, { crs });
if (focus) {
await useHybridViewerStore().focusCameraOnObject(item.data_id);
await hybridViewerStore.focusCameraOnObject(item.data_id);
}
// A failed detail leaves the bounding box shown; the back store reports the error
// oxlint-disable-next-line promise/prefer-await-to-then -- fire-and-forget: the CRS change does not wait for the detail.
hybridViewerStore.refineItem(item.data_id).catch(() => undefined);
}

// Each reload rebuilds an actor: one after another, then the camera moves once on the item
Expand Down
17 changes: 17 additions & 0 deletions app/composables/viewer_reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
hideViewerMarker,
resetOrientationMarkerVisibility,
} from "@ogw_front/composables/orientation_overlay";
import { getHighlightColors } from "@ogw_front/utils/highlight_colors";

// The scene colors of the viewer have no alpha (the text one takes it as its opacity)
function toViewerColor({ red, green, blue }: ColorRGBA): ColorRGB {
Expand Down Expand Up @@ -39,6 +40,17 @@ async function applyAppSceneColors(request: ViewerRequest): Promise<void> {
}
}

// A reset viewer highlights with its own colors: give it the app's (`ogwFront.highlightColors`), if any
async function applyAppHighlightColors(request: ViewerRequest): Promise<void> {
const highlightColors = getHighlightColors();
if (highlightColors) {
await request({
schema: viewer_schemas.opengeodeweb_viewer.viewer.set_highlight_colors,
params: highlightColors,
});
}
}

// To call after each viewer reset (reset_visualization), which brings back the viewer's own scene. Neither
// Step fails the reset: the viewer stays usable with its own colors, and the marker is hidden either way
async function afterViewerReset(request: ViewerRequest): Promise<void> {
Expand All @@ -48,6 +60,11 @@ async function afterViewerReset(request: ViewerRequest): Promise<void> {
} catch (error) {
consola.warn("[SceneColors] The viewer kept its own scene colors:", error);
}
try {
await applyAppHighlightColors(request);
} catch (error) {
consola.warn("[HighlightColors] The viewer kept its own highlight colors:", error);
}
await hideViewerMarker(request);
}

Expand Down
5 changes: 4 additions & 1 deletion app/plugins/scene_colors.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { setHighlightColors } from "@ogw_front/utils/highlight_colors";
import { setSceneColors } from "@ogw_front/utils/default_styles";

// Hands `ogwFront.sceneColors` (app.config.ts) to the default scene style, before any data style store is created
// Hands `ogwFront.sceneColors` (app.config.ts) to the default scene style, before any data style store is created,
// And `ogwFront.highlightColors` to the viewer reset
export default defineNuxtPlugin({
name: "ogw-scene-colors",
enforce: "pre",
setup() {
setSceneColors(useAppConfig().ogwFront?.sceneColors ?? {});
setHighlightColors(useAppConfig().ogwFront?.highlightColors);
},
});
3 changes: 2 additions & 1 deletion app/stores/basemap_helpers/georeferenced.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type Extent, boxesExtent } from "./extent.js";
import type { ComputedRef } from "vue";
import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
import { entryBounds } from "@ogw_internal/stores/hybrid_viewer/parts";
import { sameCrs } from "@ogw_front/utils/crs";
import { useCrsStore } from "@ogw_front/stores/crs";
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
Expand Down Expand Up @@ -38,7 +39,7 @@ function useGeoreferenced(): Georeferenced {
return boxesExtent(
Object.entries(hybridViewerStore.hybridDb)
.filter(([id]) => georeferenced.has(id))
.map(([, entry]) => entry.polydata.getBounds()),
.map(([, entry]) => entryBounds(entry)),
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/utils/clipping_planes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export {
export {
computeSceneBounds,
computeSceneBoundsInfo,
resolveActiveActors,
resolveActiveEntries,
alignCameraToMainCamera,
} from "./clipping_planes_scene";
export type { SceneBoundsInfo, MainCameraOptions } from "./clipping_planes_scene";
Expand Down
46 changes: 22 additions & 24 deletions app/utils/clipping_planes_scene.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { HybridDb, HybridDbEntry } from "@ogw_internal/stores/hybrid_viewer/vtk_types";
import type { Bounds } from "@kitware/vtk.js/types";
import type { Coordinates } from "@ogw_front/types/geometry";
import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
import type { DataIdentified } from "@ogw_front/types/identifiers";
import type vtkActor from "@kitware/vtk.js/Rendering/Core/Actor";
import type { vtkCamera } from "@kitware/vtk.js/Rendering/Core/Camera";

function computeSceneBounds(actors: readonly vtkActor[]): Bounds {
// Each box is the bounds of one data, all its parts together
function computeSceneBounds(boxes: readonly Bounds[]): Bounds {
let bounds: Bounds = [Infinity, -Infinity, Infinity, -Infinity, Infinity, -Infinity];
for (const actor of actors) {
const boundsOfActor = actor.getBounds();
for (const boundsOfActor of boxes) {
bounds = [
Math.min(bounds[0], boundsOfActor[0]),
Math.max(bounds[1], boundsOfActor[1]),
Expand All @@ -26,22 +26,21 @@ interface SceneBoundsInfo {
readonly cubicBounds: readonly number[];
}

function computeSceneBoundsInfo(actors: readonly vtkActor[]): SceneBoundsInfo {
if (actors.length === 0) {
function computeSceneBoundsInfo(boxes: readonly Bounds[]): SceneBoundsInfo {
if (boxes.length === 0) {
return { center: [0, 0, 0], cubicBounds: [-1, 1, -1, 1, -1, 1] };
}
const [xmin, xmax, ymin, ymax, zmin, zmax] = computeSceneBounds(actors);
const [xmin, xmax, ymin, ymax, zmin, zmax] = computeSceneBounds(boxes);
const center = [
Number(((xmin + xmax) / 2).toFixed(4)),
Number(((ymin + ymax) / 2).toFixed(4)),
Number(((zmin + zmax) / 2).toFixed(4)),
];

const maxActorExtent = Math.max(
...actors.map((actor: vtkActor) => {
const bounds = actor.getBounds();
return Math.max(bounds[1] - bounds[0], bounds[3] - bounds[2], bounds[5] - bounds[4]);
}),
...boxes.map((bounds: Readonly<Bounds>) =>
Math.max(bounds[1] - bounds[0], bounds[3] - bounds[2], bounds[5] - bounds[4]),
),
);
const halfExtent = maxActorExtent / 2;
const [centerX = 0, centerY = 0, centerZ = 0] = center;
Expand All @@ -56,35 +55,29 @@ function computeSceneBoundsInfo(actors: readonly vtkActor[]): SceneBoundsInfo {
return { center, cubicBounds };
}

interface ActorEntry {
readonly actor: vtkActor;
}

interface MainCameraOptions {
readonly focal_point?: readonly number[];
readonly position?: Readonly<Coordinates>;
readonly view_up?: readonly number[];
}

function resolveActiveActors(
function resolveActiveEntries(
targetAllVisible: boolean,
allItems: readonly Readonly<DataIdentified>[],
selectedDatasetIds: readonly DataId[],
hybridDb: Record<DataId, ActorEntry | undefined>,
): vtkActor[] {
hybridDb: Readonly<HybridDb>,
): HybridDbEntry[] {
let targetIds: readonly DataId[] = selectedDatasetIds;
if (targetAllVisible) {
targetIds = allItems.map((item: Readonly<DataIdentified>) => item.data_id);
}
const targeted = targetIds
.map((dataId) => hybridDb[dataId]?.actor)
.filter((actor: vtkActor | undefined): actor is vtkActor => actor !== undefined);
.map((dataId) => hybridDb[dataId])
.filter((entry): entry is HybridDbEntry => entry !== undefined);
if (targeted.length > 0) {
return targeted;
}
return Object.values(hybridDb)
.filter((entry: ActorEntry | undefined): entry is ActorEntry => entry !== undefined)
.map((entry: ActorEntry) => entry.actor);
return Object.values(hybridDb).filter((entry): entry is HybridDbEntry => entry !== undefined);
}

function computeNormalizedViewDirection(
Expand Down Expand Up @@ -130,5 +123,10 @@ function alignCameraToMainCamera(
}
}

export { alignCameraToMainCamera, computeSceneBounds, computeSceneBoundsInfo, resolveActiveActors };
export {
alignCameraToMainCamera,
computeSceneBounds,
computeSceneBoundsInfo,
resolveActiveEntries,
};
export type { MainCameraOptions, SceneBoundsInfo };
22 changes: 22 additions & 0 deletions app/utils/highlight_colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { ParamsOf } from "@ogw_shared/utils/types.js";
import type viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";

// The highlight colors an app gives the viewer: some components or a picked element, the picked cell outline,
// And each component type of a whole model highlighted
type HighlightColors = ParamsOf<
typeof viewer_schemas.opengeodeweb_viewer.viewer.set_highlight_colors
>;

// `ogwFront.highlightColors` of the app (app.config.ts), handed over by plugins/scene_colors.ts
let appHighlightColors: HighlightColors | undefined = undefined;

function setHighlightColors(colors: HighlightColors | undefined): void {
appHighlightColors = colors;
}

function getHighlightColors(): HighlightColors | undefined {
return appHighlightColors;
}

export { getHighlightColors, setHighlightColors };
export type { HighlightColors };
13 changes: 13 additions & 0 deletions app/utils/import_item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ async function addToViewerWhenViewable(
return useHybridViewerStore().addItem(item.data_id);
}

// The simplified light viewable takes a while: the import does not wait for it
async function refineWhenShown(item: NewDataItem, shown: Promise<unknown>): Promise<void> {
await shown;
if (!(await useDataStore().fetchIsViewable(item.data_id))) {
return;
}
await useHybridViewerStore().refineItem(item.data_id);
}

async function applyStyleWhenReady(item: NewDataItem, ready: Promise<unknown>): Promise<unknown> {
await ready;
if (!(await useDataStore().fetchIsViewable(item.data_id))) {
Expand Down Expand Up @@ -92,6 +101,10 @@ async function importDataItem(item: NewDataItem): Promise<DataId> {
addViewerTask,
applyStyleTask,
]);
// The detail is stored on the component rows: they must exist first
// A failed detail leaves the bounding box shown; the back store reports the error
// oxlint-disable-next-line promise/prefer-await-to-then -- fire-and-forget: the import does not wait for the detail.
refineWhenShown(item, Promise.all([addViewerTask, addDataComponentsTask])).catch(() => undefined);
return item.data_id;
}
// Every item comes through here: from the back-end, which still names its data id `id`, or from a project
Expand Down
3 changes: 3 additions & 0 deletions internal/database/tables/model_components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import type {
ModelComponentType,
ModelComponentViewerId,
} from "@ogw_front/types/model";
import type { LightViewable } from "@ogw_front/types/data";
import type { TableDefinition } from "./table_definition";

interface ModelComponentRecord extends DataIdentified, GeodeIdentified {
type: ModelComponentType;
viewer_id: ModelComponentViewerId;
name: ModelComponentName;
is_active: boolean;
// The simplified light viewable of a mesh component, once the back computed it
binary_light_viewable?: LightViewable;
}

const modelComponentsTable: TableDefinition = {
Expand Down
Loading
Loading