UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) • 1.25 kB
import{initWayfindingLayers as L}from"@expofp/wayfinding";import{createLayerDef as f}from"../../../../engine/defs";import m,{boothStore as d,uiState as s}from"../../../../store";import{isPathwayLayer as A}from"../../../../utils/is-pathway-layer";import{createTrafficLayers as E}from"../../traffic/trafficLayers";import{configBoothsBadges as _}from"./config-booth-badge";import g from"./config-load-layer";import{MARKER_LAYER_NAME as h}from"./config-markers";import{configPins as N,PIN_CLUSTER_LAYER_NAME as P,PIN_COUNT_LAYER_NAME as R,PIN_LAYER_NAME as w}from"./config-pins";export default function M(){const{defaultLayer:r}=m.layerStore;let{layers:o}=m.layerStore;if(r){const e=[...o],t=o.indexOf(r);e.splice(t,1),o=[r,...e]}const i=o.filter(e=>!e.rootParent).map(e=>g(e));return Promise.all(i).then(e=>{const t=f(h,[]);t.overlay=s.is3DView;const a=s.is3DView?S():void 0,p=L({overlay:s.is3DView}),l=[],c=[];for(const n of e.flat())A(n.name)?(n.dim=0,c.push(n)):l.push(n);const{layer:y,cleanup:u}=_("root",d.booths);return{layers:[...l,...y?[y]:[],...c,...E(),t,...a?.layers??[],p],cleanup:()=>{u(),a?.cleanup()}}})}function S(){const r=[w,P,R].map(t=>{const a=f(t,[]);return a.overlay=!0,a.dim=0,a}),[o,i,e]=r;return{layers:r,cleanup:N(o,i,e)}}