@expofp/wayfinding 0.0.0-experimental.2d6c681
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -0
- package/dist/core/createWayfindingEngine.d.ts +16 -0
- package/dist/core/createWayfindingEngine.js +87 -0
- package/dist/core/geometry/pointInPolygon.d.ts +17 -0
- package/dist/core/geometry/pointInPolygon.js +50 -0
- package/dist/core/geometry/projectPointOnSegment.d.ts +27 -0
- package/dist/core/geometry/projectPointOnSegment.js +21 -0
- package/dist/core/graph/buildGraph.d.ts +3 -0
- package/dist/core/graph/buildGraph.js +7 -0
- package/dist/core/graph/buildNGraph.d.ts +13 -0
- package/dist/core/graph/buildNGraph.js +24 -0
- package/dist/core/graph/constants.d.ts +20 -0
- package/dist/core/graph/constants.js +19 -0
- package/dist/core/graph/findShortestPath.d.ts +23 -0
- package/dist/core/graph/findShortestPath.js +65 -0
- package/dist/core/graph/graphCache.d.ts +7 -0
- package/dist/core/graph/graphCache.js +23 -0
- package/dist/core/graph/graphHelpers.d.ts +8 -0
- package/dist/core/graph/graphHelpers.js +63 -0
- package/dist/core/graph/linkCost.d.ts +13 -0
- package/dist/core/graph/linkCost.js +24 -0
- package/dist/core/graph/pathfinder/aStarPathFinder.d.ts +3 -0
- package/dist/core/graph/pathfinder/aStarPathFinder.js +64 -0
- package/dist/core/graph/pathfinder/parseNodeId.d.ts +10 -0
- package/dist/core/graph/pathfinder/parseNodeId.js +20 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.js +12 -0
- package/dist/core/position/distanceToRoute.d.ts +3 -0
- package/dist/core/position/distanceToRoute.js +29 -0
- package/dist/core/position/gpsThreshold.d.ts +32 -0
- package/dist/core/position/gpsThreshold.js +48 -0
- package/dist/core/position/rerouteController.d.ts +13 -0
- package/dist/core/position/rerouteController.js +22 -0
- package/dist/core/position/snapToRoute.d.ts +9 -0
- package/dist/core/position/snapToRoute.js +50 -0
- package/dist/core/position/splitRouteByPoint.d.ts +6 -0
- package/dist/core/position/splitRouteByPoint.js +56 -0
- package/dist/core/rendering/computeTrailPoints.d.ts +12 -0
- package/dist/core/rendering/computeTrailPoints.js +35 -0
- package/dist/core/rendering/computeTransitionPoints.d.ts +35 -0
- package/dist/core/rendering/computeTransitionPoints.js +112 -0
- package/dist/core/rendering/getVisibleRouteLines.d.ts +10 -0
- package/dist/core/rendering/getVisibleRouteLines.js +18 -0
- package/dist/core/rendering/routeGeometry.d.ts +9 -0
- package/dist/core/rendering/routeGeometry.js +10 -0
- package/dist/core/routing/buildMultiPointRoute.d.ts +13 -0
- package/dist/core/routing/buildMultiPointRoute.js +36 -0
- package/dist/core/routing/buildRoute.d.ts +12 -0
- package/dist/core/routing/buildRoute.js +19 -0
- package/dist/core/routing/getRouteLength.d.ts +3 -0
- package/dist/core/routing/getRouteLength.js +4 -0
- package/dist/core/routing/graphPointResolvers.d.ts +9 -0
- package/dist/core/routing/graphPointResolvers.js +13 -0
- package/dist/core/routing/optimizeWaypointOrder.d.ts +14 -0
- package/dist/core/routing/optimizeWaypointOrder.js +88 -0
- package/dist/core/routing/resolveWaypointCandidates.d.ts +23 -0
- package/dist/core/routing/resolveWaypointCandidates.js +49 -0
- package/dist/core/routing/routeResult.d.ts +4 -0
- package/dist/core/routing/routeResult.js +2 -0
- package/dist/core/types.d.ts +102 -0
- package/dist/core/types.js +1 -0
- package/dist/createWayfinding.d.ts +81 -0
- package/dist/createWayfinding.js +46 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +16 -0
- package/dist/renderer/createWayfindingRenderer.d.ts +8 -0
- package/dist/renderer/createWayfindingRenderer.js +45 -0
- package/dist/renderer/iconManager.d.ts +58 -0
- package/dist/renderer/iconManager.js +222 -0
- package/dist/renderer/index.d.ts +5 -0
- package/dist/renderer/index.js +2 -0
- package/dist/renderer/layerManager.d.ts +36 -0
- package/dist/renderer/layerManager.js +31 -0
- package/dist/renderer/layers.d.ts +54 -0
- package/dist/renderer/layers.js +66 -0
- package/dist/renderer/lineAnimation.d.ts +25 -0
- package/dist/renderer/lineAnimation.js +196 -0
- package/dist/renderer/routeLineManager.d.ts +45 -0
- package/dist/renderer/routeLineManager.js +153 -0
- package/dist/renderer/trailManager.d.ts +29 -0
- package/dist/renderer/trailManager.js +183 -0
- package/dist/renderer/types.d.ts +163 -0
- package/dist/renderer/types.js +1 -0
- package/dist/runtime/createWayfindingRuntime.d.ts +3 -0
- package/dist/runtime/createWayfindingRuntime.js +237 -0
- package/dist/runtime/endpointView.d.ts +19 -0
- package/dist/runtime/endpointView.js +44 -0
- package/dist/runtime/getRouteLines.d.ts +19 -0
- package/dist/runtime/getRouteLines.js +16 -0
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/positionTrailView.d.ts +51 -0
- package/dist/runtime/positionTrailView.js +35 -0
- package/dist/runtime/positionView.d.ts +22 -0
- package/dist/runtime/positionView.js +34 -0
- package/dist/runtime/routeLinesView.d.ts +16 -0
- package/dist/runtime/routeLinesView.js +10 -0
- package/dist/runtime/routeRenderData.d.ts +31 -0
- package/dist/runtime/routeRenderData.js +44 -0
- package/dist/runtime/routeUpdate.d.ts +17 -0
- package/dist/runtime/routeUpdate.js +17 -0
- package/dist/runtime/snapPositionToRoute.d.ts +10 -0
- package/dist/runtime/snapPositionToRoute.js +36 -0
- package/dist/runtime/trailView.d.ts +19 -0
- package/dist/runtime/trailView.js +43 -0
- package/dist/runtime/transitionView.d.ts +16 -0
- package/dist/runtime/transitionView.js +51 -0
- package/dist/runtime/types.d.ts +81 -0
- package/dist/runtime/types.js +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RouteLine } from '../core/index.js';
|
|
2
|
+
import { type WayfindingRenderer } from '../renderer/index.js';
|
|
3
|
+
interface RouteLinesView {
|
|
4
|
+
/** Push pre-split passed/remaining route lines to the renderer. */
|
|
5
|
+
draw(data: {
|
|
6
|
+
readonly passed: RouteLine[];
|
|
7
|
+
readonly remaining: RouteLine[];
|
|
8
|
+
}, preserveProgress?: boolean): void;
|
|
9
|
+
/** Clear all rendered route lines + animated segments. */
|
|
10
|
+
clear(): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function createRouteLinesView({ renderer, }: {
|
|
13
|
+
renderer: Pick<WayfindingRenderer, 'setRouteLines'>;
|
|
14
|
+
}): RouteLinesView;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=routeLinesView.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function createRouteLinesView({ renderer, }) {
|
|
2
|
+
return {
|
|
3
|
+
draw({ passed, remaining }, preserveProgress = false) {
|
|
4
|
+
renderer.setRouteLines(passed, remaining, { resetAnimation: !preserveProgress });
|
|
5
|
+
},
|
|
6
|
+
clear() {
|
|
7
|
+
renderer.setRouteLines([], [], { resetAnimation: true });
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type RouteLine, type RouteSnapResult } from '../core/index.js';
|
|
2
|
+
interface RouteRenderData {
|
|
3
|
+
/** Route lines behind the current user position (empty when no snap). */
|
|
4
|
+
readonly passed: RouteLine[];
|
|
5
|
+
/** Route lines ahead of the current user position (the full normalized route when no snap). */
|
|
6
|
+
readonly remaining: RouteLine[];
|
|
7
|
+
/** Remaining route distance along the polyline. */
|
|
8
|
+
readonly distance: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Pure pipeline that produces the data needed to render the route: the
|
|
12
|
+
* passed/remaining split for the visible floors plus the remaining
|
|
13
|
+
* distance to the destination.
|
|
14
|
+
*
|
|
15
|
+
* The full non-virtual route is sliced down to the visible floors for rendering.
|
|
16
|
+
* The remaining distance is read from `snap.distance` (computed once by the
|
|
17
|
+
* runtime snap, `snapPositionToRoute`); with no snap it falls back to the full
|
|
18
|
+
* route length.
|
|
19
|
+
* @param root0
|
|
20
|
+
* @param root0.routeLines
|
|
21
|
+
* @param root0.activeFloors
|
|
22
|
+
* @param root0.snap
|
|
23
|
+
*/
|
|
24
|
+
export declare function computeRouteRenderData({ routeLines, activeFloors, snap, }: {
|
|
25
|
+
readonly routeLines: RouteLine[];
|
|
26
|
+
/** null = show-all mode; otherwise the active route floors. */
|
|
27
|
+
readonly activeFloors: readonly string[] | null;
|
|
28
|
+
readonly snap: RouteSnapResult | null;
|
|
29
|
+
}): RouteRenderData;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=routeRenderData.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getRouteLength, splitRouteByPoint, } from '../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Pure pipeline that produces the data needed to render the route: the
|
|
4
|
+
* passed/remaining split for the visible floors plus the remaining
|
|
5
|
+
* distance to the destination.
|
|
6
|
+
*
|
|
7
|
+
* The full non-virtual route is sliced down to the visible floors for rendering.
|
|
8
|
+
* The remaining distance is read from `snap.distance` (computed once by the
|
|
9
|
+
* runtime snap, `snapPositionToRoute`); with no snap it falls back to the full
|
|
10
|
+
* route length.
|
|
11
|
+
* @param root0
|
|
12
|
+
* @param root0.routeLines
|
|
13
|
+
* @param root0.activeFloors
|
|
14
|
+
* @param root0.snap
|
|
15
|
+
*/
|
|
16
|
+
export function computeRouteRenderData({ routeLines, activeFloors, snap, }) {
|
|
17
|
+
const nonVirtualOrdered = routeLines.filter((line) => !line.virtual);
|
|
18
|
+
const clipToVisibleFloors = (lines) => activeFloors === null ? lines : lines.filter((line) => activeFloors.includes(line.p0.layer));
|
|
19
|
+
if (!snap?.snapped) {
|
|
20
|
+
return {
|
|
21
|
+
passed: [],
|
|
22
|
+
remaining: clipToVisibleFloors(nonVirtualOrdered),
|
|
23
|
+
distance: getRouteLength(nonVirtualOrdered),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// Split the full route at the snap point first, then filter each side to the visible
|
|
27
|
+
// floors, so an already-passed floor renders fully as passed even when the snap is on a
|
|
28
|
+
// later floor.
|
|
29
|
+
const { passed, remaining } = splitRouteByPoint(nonVirtualOrdered, snap.snappedPoint);
|
|
30
|
+
// Ref-equal result means no segment matched the snap layer (bestIndex === -1); only on a
|
|
31
|
+
// real split do we anchor the first remaining segment at the snap point.
|
|
32
|
+
const splitOccurred = remaining !== nonVirtualOrdered;
|
|
33
|
+
// Anchor only when `remaining[0]` is on the snap's floor — at a transition it
|
|
34
|
+
// already belongs to the next floor, and keeping its own `p0` survives the clip.
|
|
35
|
+
const anchorAtSnap = splitOccurred && remaining.length > 0 && remaining[0].p0.layer === snap.snappedPoint.layer;
|
|
36
|
+
const adjustedRemaining = anchorAtSnap
|
|
37
|
+
? [{ ...remaining[0], p0: snap.snappedPoint }, ...remaining.slice(1)]
|
|
38
|
+
: remaining;
|
|
39
|
+
return {
|
|
40
|
+
passed: clipToVisibleFloors(passed),
|
|
41
|
+
remaining: clipToVisibleFloors(adjustedRemaining),
|
|
42
|
+
distance: snap.distance,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Box } from '@expofp/geometry';
|
|
2
|
+
import { type RouteLine } from '../core/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Compute the payload for the runtime's `onRouteUpdate` callback:
|
|
5
|
+
* - `lines`: route lines as the consumer sees them — virtual graph-internal
|
|
6
|
+
* segments are filtered out before publication.
|
|
7
|
+
* - `bounds`: bounding box over the visible route points. It is an EMPTY box
|
|
8
|
+
* (`bounds.isEmpty()`) when the route is empty or collapses to a single point
|
|
9
|
+
* (no useful viewport to fit); consumers check `isEmpty()` rather than null.
|
|
10
|
+
* @param routeLines
|
|
11
|
+
* @param visibleLines
|
|
12
|
+
*/
|
|
13
|
+
export declare function computeRouteUpdate(routeLines: readonly RouteLine[], visibleLines: readonly RouteLine[]): {
|
|
14
|
+
lines: RouteLine[];
|
|
15
|
+
bounds: Box;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=routeUpdate.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { computeBoundingBox } from '../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Compute the payload for the runtime's `onRouteUpdate` callback:
|
|
4
|
+
* - `lines`: route lines as the consumer sees them — virtual graph-internal
|
|
5
|
+
* segments are filtered out before publication.
|
|
6
|
+
* - `bounds`: bounding box over the visible route points. It is an EMPTY box
|
|
7
|
+
* (`bounds.isEmpty()`) when the route is empty or collapses to a single point
|
|
8
|
+
* (no useful viewport to fit); consumers check `isEmpty()` rather than null.
|
|
9
|
+
* @param routeLines
|
|
10
|
+
* @param visibleLines
|
|
11
|
+
*/
|
|
12
|
+
export function computeRouteUpdate(routeLines, visibleLines) {
|
|
13
|
+
const lines = routeLines.filter((line) => !line.virtual);
|
|
14
|
+
const points = visibleLines.flatMap((line) => [line.p0, line.p1]);
|
|
15
|
+
const bbox = computeBoundingBox(points);
|
|
16
|
+
return { lines, bounds: bbox };
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type RouteEndpoint, type RouteLine, type RoutePoint, type RouteSnapResult } from '../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Snap a position to the from→to route, resolving from/to booth containment
|
|
4
|
+
* first (domain logic kept out of the geometric `snapToRoute`):
|
|
5
|
+
* - inside the origin booth → route start, full distance remaining;
|
|
6
|
+
* - inside the destination booth → route end, zero remaining;
|
|
7
|
+
* - otherwise → geometric snap within `snapThreshold`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function snapPositionToRoute(position: RoutePoint, routeLines: readonly RouteLine[], from: RouteEndpoint, to: RouteEndpoint, snapThreshold: number): RouteSnapResult;
|
|
10
|
+
//# sourceMappingURL=snapPositionToRoute.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { pointInPolygon } from '../core/geometry/pointInPolygon.js';
|
|
2
|
+
import { getRouteLength, snapToRoute, } from '../core/index.js';
|
|
3
|
+
/** Whether `position` lies inside `endpoint`'s booth bounds on a matching layer. */
|
|
4
|
+
function insideBounds(position, endpoint, posLayer) {
|
|
5
|
+
if (!endpoint?.bounds)
|
|
6
|
+
return false;
|
|
7
|
+
const layerMatches = posLayer == null || !endpoint.layer || endpoint.layer === posLayer;
|
|
8
|
+
const containsPosition = pointInPolygon({ x: position.x, y: position.y }, endpoint.bounds);
|
|
9
|
+
return layerMatches && containsPosition;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Snap a position to the from→to route, resolving from/to booth containment
|
|
13
|
+
* first (domain logic kept out of the geometric `snapToRoute`):
|
|
14
|
+
* - inside the origin booth → route start, full distance remaining;
|
|
15
|
+
* - inside the destination booth → route end, zero remaining;
|
|
16
|
+
* - otherwise → geometric snap within `snapThreshold`.
|
|
17
|
+
*/
|
|
18
|
+
export function snapPositionToRoute(position, routeLines, from, to, snapThreshold) {
|
|
19
|
+
if (!routeLines.length)
|
|
20
|
+
return { snapped: false };
|
|
21
|
+
const posLayer = position.layer || null;
|
|
22
|
+
if (insideBounds(position, from, posLayer)) {
|
|
23
|
+
const first = routeLines[0];
|
|
24
|
+
return {
|
|
25
|
+
snapped: true,
|
|
26
|
+
snappedPoint: first.p0,
|
|
27
|
+
snappedLine: first,
|
|
28
|
+
distance: getRouteLength(routeLines),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (insideBounds(position, to, posLayer)) {
|
|
32
|
+
const last = routeLines[routeLines.length - 1];
|
|
33
|
+
return { snapped: true, snappedPoint: last.p1, snappedLine: last, distance: 0 };
|
|
34
|
+
}
|
|
35
|
+
return snapToRoute(position, routeLines, { snapThreshold });
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type RoutePoint } from '../core/index.js';
|
|
2
|
+
import { type WayfindingRenderer } from '../renderer/index.js';
|
|
3
|
+
import { type FloorContext, type IconProvider } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Callers choose the slot name and provide two route-points; the view draws a dotted trail between them (or hides
|
|
6
|
+
* them if the layers are not on the active floor)
|
|
7
|
+
*/
|
|
8
|
+
export interface TrailView {
|
|
9
|
+
/** Draws dotted points between two route-points in the named slot. */
|
|
10
|
+
place(slot: string, from: RoutePoint, to: RoutePoint): void;
|
|
11
|
+
clear(slot: string): void;
|
|
12
|
+
clearAll(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function createTrailView({ renderer, iconProvider, floorContext, }: {
|
|
15
|
+
renderer: Pick<WayfindingRenderer, 'setTrail'>;
|
|
16
|
+
iconProvider: Pick<IconProvider, 'getIcon'>;
|
|
17
|
+
floorContext: Pick<FloorContext, 'showAllFloors' | 'getActiveFloors'>;
|
|
18
|
+
}): TrailView;
|
|
19
|
+
//# sourceMappingURL=trailView.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export function createTrailView({ renderer, iconProvider, floorContext, }) {
|
|
2
|
+
const activeSlots = new Set();
|
|
3
|
+
/**
|
|
4
|
+
* Trails share one global layer (not per-floor). In scoped-floor mode the
|
|
5
|
+
* trail renders only when both endpoints lie on an active floor —
|
|
6
|
+
* otherwise the line would bleed through on unrelated floors.
|
|
7
|
+
* @param fromLayer
|
|
8
|
+
* @param toLayer
|
|
9
|
+
*/
|
|
10
|
+
function isTrailVisible(fromLayer, toLayer) {
|
|
11
|
+
if (floorContext.showAllFloors())
|
|
12
|
+
return true;
|
|
13
|
+
const activeFloors = floorContext.getActiveFloors();
|
|
14
|
+
return activeFloors.includes(fromLayer) && activeFloors.includes(toLayer);
|
|
15
|
+
}
|
|
16
|
+
function clearSlot(slot) {
|
|
17
|
+
renderer.setTrail(slot, null, null);
|
|
18
|
+
activeSlots.delete(slot);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
place(slot, from, to) {
|
|
22
|
+
if (!isTrailVisible(from.layer, to.layer)) {
|
|
23
|
+
clearSlot(slot);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const dot = iconProvider.getIcon('trail');
|
|
27
|
+
renderer.setTrail(slot, from, to, {
|
|
28
|
+
canvas: dot.canvas,
|
|
29
|
+
width: dot.width,
|
|
30
|
+
height: dot.height,
|
|
31
|
+
});
|
|
32
|
+
activeSlots.add(slot);
|
|
33
|
+
},
|
|
34
|
+
clear(slot) {
|
|
35
|
+
clearSlot(slot);
|
|
36
|
+
},
|
|
37
|
+
clearAll() {
|
|
38
|
+
for (const slot of activeSlots)
|
|
39
|
+
renderer.setTrail(slot, null, null);
|
|
40
|
+
activeSlots.clear();
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RouteLine, type TransitionPointDef } from '../core/index.js';
|
|
2
|
+
import type { WayfindingRenderer } from '../renderer/index.js';
|
|
3
|
+
import type { FloorContext, IconProvider } from './types.js';
|
|
4
|
+
interface TransitionView {
|
|
5
|
+
/** Recomputes transition points from route lines + floor context and places their icons. */
|
|
6
|
+
place(routeLines: RouteLine[]): void;
|
|
7
|
+
clear(): void;
|
|
8
|
+
}
|
|
9
|
+
export declare function createTransitionView({ renderer, iconProvider, floorContext, onTransitionClick, }: {
|
|
10
|
+
renderer: Pick<WayfindingRenderer, 'setIcon' | 'clearIcons'>;
|
|
11
|
+
iconProvider: Pick<IconProvider, 'getIcon'>;
|
|
12
|
+
floorContext: Pick<FloorContext, 'showAllFloors' | 'getActiveFloors' | 'getFloorOrder'>;
|
|
13
|
+
onTransitionClick: (point: TransitionPointDef) => void;
|
|
14
|
+
}): TransitionView;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=transitionView.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { computeTransitionPoints } from '../core/index.js';
|
|
2
|
+
const TRANSITION_ICON_NAME = 'transition';
|
|
3
|
+
export function createTransitionView({ renderer, iconProvider, floorContext, onTransitionClick, }) {
|
|
4
|
+
return {
|
|
5
|
+
place(routeLines) {
|
|
6
|
+
renderer.clearIcons(TRANSITION_ICON_NAME);
|
|
7
|
+
// `null` here means "don't scope to a floor" (computeTransitionPoints
|
|
8
|
+
// returns transitions for every floor). Only emit `null` in show-all
|
|
9
|
+
// mode — in scoped mode with no resolvable active floor we must
|
|
10
|
+
// hide transitions instead of accidentally placing them on all floors.
|
|
11
|
+
let currentLayerNames;
|
|
12
|
+
if (floorContext.showAllFloors()) {
|
|
13
|
+
currentLayerNames = null;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
currentLayerNames = floorContext.getActiveFloors();
|
|
17
|
+
if (!currentLayerNames.length)
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const transitionPoints = computeTransitionPoints({
|
|
21
|
+
routeLines,
|
|
22
|
+
currentLayerNames,
|
|
23
|
+
floorOrder: floorContext.getFloorOrder(),
|
|
24
|
+
});
|
|
25
|
+
for (const [index, point] of transitionPoints.entries()) {
|
|
26
|
+
const icon = iconProvider.getIcon(iconNameFor(point.role, point.direction));
|
|
27
|
+
renderer.setIcon(TRANSITION_ICON_NAME, {
|
|
28
|
+
canvas: icon.canvas,
|
|
29
|
+
width: icon.width,
|
|
30
|
+
height: icon.height,
|
|
31
|
+
x: point.x,
|
|
32
|
+
y: point.y,
|
|
33
|
+
cardinalSnap: true,
|
|
34
|
+
onClick: point.role === 'exit' ? () => onTransitionClick(point) : undefined,
|
|
35
|
+
}, index);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
clear() {
|
|
39
|
+
renderer.clearIcons(TRANSITION_ICON_NAME);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function iconNameFor(role, direction) {
|
|
44
|
+
if (role === 'entry')
|
|
45
|
+
return 'transition_entry';
|
|
46
|
+
if (direction === 'up')
|
|
47
|
+
return 'transition_up';
|
|
48
|
+
if (direction === 'down')
|
|
49
|
+
return 'transition_down';
|
|
50
|
+
return 'transition';
|
|
51
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Box } from '@expofp/geometry';
|
|
2
|
+
import type { RouteEndpoint, RouteLine, RoutePoint, TransitionPointDef, WayfindingEngine } from '../core/index.js';
|
|
3
|
+
import type { WayfindingRenderer } from '../renderer/index.js';
|
|
4
|
+
export type IconName = 'source' | 'source_inactive' | 'destination' | 'current' | 'current_arrow' | 'transition' | 'transition_up' | 'transition_down' | 'transition_entry' | 'trail';
|
|
5
|
+
export interface IconAsset {
|
|
6
|
+
readonly canvas: HTMLCanvasElement;
|
|
7
|
+
/** The width the icon is drawn at, in CSS pixels; not the canvas's backing width. */
|
|
8
|
+
readonly width: number;
|
|
9
|
+
/** The height the icon is drawn at, in CSS pixels; not the canvas's backing height. */
|
|
10
|
+
readonly height: number;
|
|
11
|
+
}
|
|
12
|
+
export interface IconProvider {
|
|
13
|
+
getIcon(name: IconName): IconAsset;
|
|
14
|
+
}
|
|
15
|
+
/** User position + optional heading, without efp store coupling. */
|
|
16
|
+
export interface PositionInput {
|
|
17
|
+
readonly x: number;
|
|
18
|
+
readonly y: number;
|
|
19
|
+
readonly layer: string;
|
|
20
|
+
/** Heading in degrees. Absent → no rotation (dot variant). */
|
|
21
|
+
readonly heading?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface SetRouteInput {
|
|
24
|
+
readonly from: RouteEndpoint;
|
|
25
|
+
readonly to: RouteEndpoint;
|
|
26
|
+
readonly waypoints?: readonly RouteEndpoint[];
|
|
27
|
+
readonly accessible: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface WayfindingRuntime {
|
|
30
|
+
/**
|
|
31
|
+
* Build (or update) the active route. Places endpoint/transition/trail icons
|
|
32
|
+
* and fires `onRouteUpdate` + `onRouteDistance` callbacks.
|
|
33
|
+
*/
|
|
34
|
+
setRoute(input: SetRouteInput): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Notify the runtime that the user position changed. `null` hides the position icon and clears
|
|
37
|
+
* the off-route trail. Dot vs arrow variant is derived from `position.heading` internally.
|
|
38
|
+
*/
|
|
39
|
+
onPositionChanged(position: PositionInput | null): void;
|
|
40
|
+
/** Notify the runtime that the active floor changed; re-renders visible route content. */
|
|
41
|
+
onFloorChanged(): void;
|
|
42
|
+
/** Whether the position drifted off the active (non-virtual) route far enough to reroute. */
|
|
43
|
+
shouldReroute(position: RoutePoint): boolean;
|
|
44
|
+
clearRoute(): void;
|
|
45
|
+
destroy(): void;
|
|
46
|
+
}
|
|
47
|
+
export interface WayfindingRuntimeConfig {
|
|
48
|
+
readonly engine: WayfindingEngine;
|
|
49
|
+
readonly renderer: WayfindingRenderer;
|
|
50
|
+
readonly iconProvider: IconProvider;
|
|
51
|
+
readonly floorContext: FloorContext;
|
|
52
|
+
readonly snapThreshold: number;
|
|
53
|
+
/** Plan-scale-aware off-route reroute distance (SVG units). */
|
|
54
|
+
readonly rerouteThreshold: number;
|
|
55
|
+
readonly onTransitionClick: (point: TransitionPointDef) => void;
|
|
56
|
+
/** Fired when the route itself changes. `bounds` is the bbox of visible route points; call `bounds.isEmpty()` to detect an empty/cleared route. */
|
|
57
|
+
readonly onRouteUpdate: (lines: readonly RouteLine[], bounds: Box) => void;
|
|
58
|
+
/** Fired when distance changes — on route change and on position snap updates. */
|
|
59
|
+
readonly onRouteDistance: (distance: number) => void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Abstracts floor-state queries for the runtime.
|
|
63
|
+
*
|
|
64
|
+
* Views ask these predicates instead of reading any store directly;
|
|
65
|
+
* an adapter (see `adapters/floorContext.ts`) supplies the implementation
|
|
66
|
+
* that bridges to a concrete store (e.g., efp `LayerStore` + `RouteStore`).
|
|
67
|
+
*
|
|
68
|
+
* - {@link showAllFloors} — true when the map is rendering all floors simultaneously (no floor scoping/single-floor).
|
|
69
|
+
* - {@link getActiveFloors} — names of the active route floors: one on a single-venue plan, one
|
|
70
|
+
* level per venue when several venues show a level at once; empty when unresolvable.
|
|
71
|
+
* Callers must check `!showAllFloors()` first.
|
|
72
|
+
* - {@link isLayerVisible} — per-layer visibility for endpoint dim/hide and cross-floor trail gating.
|
|
73
|
+
* - {@link getFloorOrder} — stable floor-name order used by transition placement.
|
|
74
|
+
*/
|
|
75
|
+
export interface FloorContext {
|
|
76
|
+
showAllFloors(): boolean;
|
|
77
|
+
getActiveFloors(): readonly string[];
|
|
78
|
+
isLayerVisible(layer: string): boolean;
|
|
79
|
+
getFloorOrder(): string[];
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@expofp/wayfinding",
|
|
3
|
+
"version": "0.0.0-experimental.2d6c681",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "ExpoFP SDK internal: framework-neutral wayfinding (routing, snapping, scene rendering)",
|
|
6
|
+
"homepage": "https://developer.expofp.com/",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/expofp/efp-app.git",
|
|
11
|
+
"directory": "packages/wayfinding"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"module": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
"./package.json": "./package.json",
|
|
22
|
+
".": {
|
|
23
|
+
"@expofp/source": "./src/index.ts",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"!**/*.tsbuildinfo",
|
|
32
|
+
"!**/*.map"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"ngraph.graph": "^19.1.0",
|
|
36
|
+
"tslib": "^2.3.0",
|
|
37
|
+
"@expofp/geometry": "0.0.0-experimental.2d6c681"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@expofp/renderer": "0.0.0-experimental.2d6c681"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@expofp/renderer": "0.0.0-experimental.2d6c681"
|
|
44
|
+
}
|
|
45
|
+
}
|