UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.3 kB
import s from"../../../core/Logger.js";import{unwrapOrThrow as e,isSome as t}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{WorkerHandle as r}from"../../../core/workers/WorkerHandle.js";import{canProjectWithoutEngine as p,projectVectorToVector as h}from"../../../geometry/projection.js";import{ModificationType as i}from"../../../libs/i3s/enums.js";class u extends r{constructor(s){super("SceneLayerWorker","process",{process:s=>[s.geometryBuffer]},s,{hasInitialize:!0})}setModifications(s,e,t,o){const r={context:s,modifications:c(e,t,o),isGeodetic:o.isGeographic};this.broadcast(r,"setModifications")}setLegacySchema(s,e){const t=JSON.stringify(e);this.broadcast({context:s,jsonSchema:t},"setLegacySchema")}destroyContext(s){return this.broadcast(s,"destroyContext")}}const n=new o({deallocator:null}),a=[0,0,0];function c(o,r,u){n.clear();let c=1/0,f=1/0,m=-1/0,l=-1/0,d=!1;for(const t of r){const o="clip"===t.type?i.Inside:"mask"===t.type?i.Outside:i.Replace,r=e(t.geometry,"modification.geometry");let g=s=>s;if(r.spatialReference){if(!p(r.spatialReference,u)){s.getLogger("esri.views.3d.layers.I3SMeshWorkerHandle").warn("Can't project modification polygon into layer spatial reference, ignoring modification");continue}g=s=>(h(s,r.spatialReference,a,u),a)}else r.hasZ||(a[2]=0,g=s=>(a[0]=s[0],a[1]=s[1],a));d=d||o===i.Outside,n.push(o),n.push(r.rings.length);for(const s of r.rings){n.push(s.length);for(const e of s){const s=g(e);n.push(s[0]),n.push(s[1]),n.push(s[2]),c=Math.min(c,s[0]),f=Math.min(f,s[1]),m=Math.max(m,s[0]),l=Math.max(l,s[1])}}}if(t(o))if(d){const s=1e-4;n.push(i.Inside),n.push(2),n.push(4),n.push(c-s),n.push(f-s),n.push(0),n.push(m+s),n.push(f-s),n.push(0),n.push(m+s),n.push(l+s),n.push(0),n.push(c-s),n.push(l+s),n.push(0),n.push(4),n.push(o[0]),n.push(o[1]),n.push(0),n.push(o[2]),n.push(o[1]),n.push(0),n.push(o[2]),n.push(o[3]),n.push(0),n.push(o[0]),n.push(o[3]),n.push(0)}else n.push(i.Outside),n.push(1),n.push(4),n.push(o[0]),n.push(o[1]),n.push(0),n.push(o[2]),n.push(o[1]),n.push(0),n.push(o[2]),n.push(o[3]),n.push(0),n.push(o[0]),n.push(o[3]),n.push(0);n.push(i.Finished);const g=new Float64Array(n.length);for(let s=0;s<n.length;++s)g[s]=n.getItemAt(s);return g}export{u as I3SMeshWorkerHandle,c as toWasmModification};