@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 1.78 kB
JavaScript
import h from"../core/Rect";import{fpGeo as n}from"../data/fpGeo";import o,{layersStore as s,uiState as f}from"../store";import{createCanvasIconProvider as E,createFloorContext as y,graphDataSource as T}from"./adapters";import{bindMobxReactions as A}from"./bindMobxReactions";import{SNAP_THRESHOLD_METERS as M,createWayfindingEngine as N,getThresholdFromMetersToSvg as x,getThresholdSafe as I,resolveRerouteThresholdSvg as L}from"./core";import{createKioskHandler as v}from"./handlers/kioskHandler";import{createYahHandler as W}from"./handlers/yahHandler";import{WF_CURRENT_POSITION_LAYER_NAME as F,WF_LINES_ANIMATED_LAYER_NAME as P,WF_LINES_LAYER_NAME as k,WF_POINTS_LAYER_NAME as C,WF_TRAIL_LAYER_NAME as H}from"./layers";import{createWayfindingRuntime as Y}from"./runtime/createWayfindingRuntime";import{createWayfindingRenderer as D}from"./renderer";export function createWayfinding(l){const m=N(T),a=E({iconMap:o.fp.icons,pixelRatio:devicePixelRatio}),t=D(l),c=y(s,o.routeStore),i={points:C,trail:H,lines:k,linesAnimated:P,currentPosition:F},d=I(n?.properties?.config?.snapThreshold)||M,R=x({thresholdInMeters:d,gpsConfig:n?.properties?.config}),p=Y({engine:m,renderer:t,iconProvider:a,floorContext:c,layers:i,snapThreshold:R,onTransitionClick:e=>{e.role==="exit"&&s.updateVisibility(e.targetLayer,!0)},onRouteUpdate:(e,r)=>{o.routeStore.updateRoute(e),r&&(f.moveToRect=h.fromX1y1x2y2(r.x1,r.y1,r.x2,r.y2))},onRouteDistance:e=>o.routeStore.updateRouteDistance(e)}),S=v({renderer:t,kioskIconMap:o.fp.icons,layer:i.points}),g=W({renderer:t,iconProvider:a,floorContext:c,layer:i.points}),u=L(n?.properties?.config),_=A({runtime:p,kioskHandler:S,yahHandler:g,stores:{routeStore:o.routeStore,uiState:f,layerStore:s},rerouteThresholdSvg:u});return t.flush(),()=>{_(),p.destroy()}}