@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 1.95 kB
JavaScript
import{SEPARATOR as s}from"../../../../constants";import{createImageDef as H}from"../../../../renderer";import T,{boothStore as U,uiState as W}from"../../../../store";import _ from"../../../../tools/settings";import{loadImagesInBatchesById as K}from"../../../../utils/loadImagesInBatches";import{toRadians as P}from"../../../../utils/math";import Z from"./config-booth-bg";import j from"./config-booth-bookmark";import q from"./config-booth-border";import z from"./config-booth-labels";import F from"./config-booth-labels-special";import{createBoothImg as G,getImageLayerName as J,mapBoothsLogos as M}from"./loadBoothsImages";import{Rect as f}from"./Rect";export const BOOTHS_CHUNK_SIZE=350;export default function Q(a,I,k){return(h=>{const t=I,p=[],m=[],l=[],g=[],b=[],d=J(t),B={name:d,children:[]};for(const o of h){const r=Z(a,o)?.getShape();r&&p.push(...r);const n=z(a,o)?.getShape();n&&m.push(...n);const i=F(a,o)?.getShape();if(i&&l.push(...i),!_.borderless){const e=q(a,o)?.getShape();e&&g.push(e)}const c=j(a,o)?.getShape();c&&b.push(c)}const S=m.filter(o=>o.lines),R=l.filter(o=>o.lines),D=m.filter(o=>o.source),x=l.filter(o=>o.source);if(!W.hideLogoInBooth){const o=M(h);a.onLayerImages(d,async()=>{const r=await K(o,BOOTHS_CHUNK_SIZE),n=[];for(const[i,c]of r){const e=T.boothStore.boothById.get(i);if(!e)continue;const{bounds:{x:L,y:$,height:w,angle:N,width:O},htmlImage:A}=G(e,c),y=H(A,new f({x:L,y:$},{x:L+O,y:$+w},P(N))),C=f.fromCoreRect(e.rect,e.rotate),E=f.inflateRect(C,e.borderWidth||U.borderWidth);e.shapes.push(y),n.push({shape:y,parentRect:E})}return{layer:B,children:n}})}let u=[];return h.length&&(u=[{name:`${t}${s}boothBackground`,children:p,interactive:!0},{name:`${t}${s}labels`,children:S},{name:`${t}${s}specialLabels`,children:R},{name:`${t}${s}bots`,children:D},{name:`${t}${s}specialDots`,children:x},B,{name:`${t}${s}boothsBookmark`,children:b},{name:`${t}${s}boothBorder`,children:g}]),{name:t,children:u}})(k)}