@vesium/plot 1.0.1-beta.50 → 1.0.1-beta.52

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.
@@ -1,2 +1,2 @@
1
- var VesiumPlot=function(P,n,u,L,w){"use strict";var q=Object.defineProperty,z=(i,e,t)=>e in i?q(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,E=(i,e,t)=>z(i,typeof e!="symbol"?e+"":e,t);const F=class R{constructor(e){E(this,"type"),E(this,"complete"),E(this,"allowManualComplete"),E(this,"definingCursor"),E(this,"skeletons"),E(this,"initEntites"),E(this,"initPrimitives"),E(this,"initGroundPrimitives"),E(this,"render");var t;this.type=e.type,this.complete=e.complete,this.allowManualComplete=e.allowManualComplete,this.definingCursor=e.definingCursor??"crosshair",this.skeletons=((t=e.skeletons)==null?void 0:t.map(a=>a()))??[],this.initEntites=e.initEntites,this.initPrimitives=e.initPrimitives,this.initGroundPrimitives=e.initGroundPrimitives,this.render=e.render}static getCacheTypes(){return[...this._record.keys()]}static getCache(e){return R._record.get(e)}static setCache(e){u.assertError(!e.type,"`scheme.type` is required"),R._record.set(e.type,e)}static resolve(e){if(typeof e=="string"){const t=R.getCache(e);return L.assert(!!t,`scheme ${e} not found`),t}else return e instanceof R?e:new R(e)}};E(F,"_record",new Map);let I=F;var Y=(i=>(i[i.NEAR=0]="NEAR",i[i.CYCLE=1]="CYCLE",i[i.STRICT=2]="STRICT",i))(Y||{});const $=(i,e,t,a)=>{var o,s,d;return a===0?{time:i,positions:(o=e.positions)==null?void 0:o.map(r=>r.clone()),derivative:e.derivative}:a===1?{time:i,positions:(s=t.positions)==null?void 0:s.map(r=>r.clone()),derivative:e.derivative}:{time:i,positions:(d=t.positions)==null?void 0:d.map((r,v)=>{var p;const C=(p=e.positions)==null?void 0:p[v];return C?n.Cartesian3.lerp(C,r,a,new n.Cartesian3):r}),derivative:e.derivative}},J=class j{constructor(e){E(this,"strategy"),E(this,"interpolationAlgorithm"),E(this,"_times",[]),E(this,"_sampleds",[]),E(this,"_derivatives",[]),E(this,"_definitionChanged",new n.Event);var t;this.interpolationAlgorithm=e?.interpolationAlgorithm,this.strategy=e?.strategy??0,(t=e?.packables)==null||t.forEach(a=>this.setSample(a)),this._times.length||this.setSample({time:new n.JulianDate(0,0),positions:[],derivative:void 0})}get isConstant(){return this._times.length===0}get definitionChanged(){return this._definitionChanged}getTimes(){return this._times.map(e=>e.clone())}getIndexScope(e){if(!this._times.length)return;const t=this._times[0],a=this._times[this._times.length-1];if(n.JulianDate.lessThan(e,t)||n.JulianDate.greaterThan(e,a))switch(this.strategy){case 2:return;case 0:{e=n.JulianDate.lessThan(e,this._times[0])?this._times[0].clone():this._times[this._times.length-1].clone();break}case 1:{const p=n.JulianDate.toDate(this._times[0]).getTime(),g=n.JulianDate.toDate(this._times[this._times.length-1]).getTime()-p,c=(n.JulianDate.toDate(e).getTime()-p)%g,f=new Date(p+c);e=n.JulianDate.fromDate(f);break}}const o=this._times.findIndex(p=>n.JulianDate.lessThanOrEquals(e,p)),s=Math.min(o,this._times.length-1),d=n.JulianDate.toDate(this._times[o]).getTime(),r=n.JulianDate.toDate(this._times[s]).getTime(),v=n.JulianDate.toDate(e).getTime();return{prevIndex:o,nextIndex:s,proportion:(v-d)/(r-d)||0}}getValue(e,t){var a;if(t??(t={time:e}),Object.assign(t,{time:e?.clone(),positions:void 0,derivative:void 0}),!e)return t.time=this._times[0].clone(),t.positions=(a=this._sampleds[0])==null?void 0:a.map(g=>g.clone(g)),t.derivative=this._derivatives[0],t;const o=this.getIndexScope(e);if(!o)return t;t.time=e;const{prevIndex:s,nextIndex:d,proportion:r}=o,v={time:this._times[s],positions:this._sampleds[s],derivative:this._derivatives[s]},p={time:this._times[d],positions:this._sampleds[d],derivative:this._derivatives[d]},C=(this.interpolationAlgorithm||j.defaultInterpolationAlgorithm)(e,v,p,r);return Object.assign(t,C),t}setSample(e){var t,a;const o=((t=e.time)==null?void 0:t.clone())??this._times[0].clone(),s=((a=e.positions)==null?void 0:a.map(v=>v.clone()))??[],d=e.derivative,r=this._times.findIndex(v=>n.JulianDate.equals(o,v));r!==-1?(this._times[r]=o,this._sampleds[r]=s,this._derivatives[r]=e.derivative):this._times.length===0?(this._times[0]=o,this._sampleds[0]=s,this._derivatives[0]=e.derivative):n.JulianDate.lessThan(o,this._times[0])?(this._times.splice(0,0,o),this._sampleds.splice(0,0,s),this._derivatives.splice(0,0,d)):n.JulianDate.greaterThan(o,this._times[this._times.length-1])&&(this._times.push(o),this._sampleds.push(s),this._derivatives.push(d)),this.definitionChanged.raiseEvent(this)}setSamples(e){e.forEach(t=>this.setSample(t))}removeSample(e){const t=this._times.findIndex(a=>a.equals(e));return t!==-1&&(this._sampleds.splice(t,1),this._derivatives.splice(t,1),this._times.splice(t,1).length)?(this._definitionChanged.raiseEvent(this),!0):!1}removeSamples(e){for(let t=0;t<this._times.length;t++){const a=this._times[t];n.TimeInterval.contains(e,a)&&this.removeSample(a)}}equals(e){return e===this}};E(J,"defaultInterpolationAlgorithm",$);let G=J;class A{constructor(e){E(this,"_id"),E(this,"_scheme"),E(this,"_definitionChanged"),E(this,"_defining"),E(this,"_disabled"),E(this,"_sampled"),E(this,"_entities"),E(this,"_primitives"),E(this,"_groundPrimitives"),E(this,"_skeletons");var t,a,o,s,d,r;const{id:v,disabled:p=!1,sampled:C}=e;this._id=v||n.createGuid(),this._scheme=I.resolve(e.scheme),this._definitionChanged=new n.Event,this._defining=!0,this._disabled=p,this._sampled=C instanceof G?C:new G(C),this._sampled.definitionChanged.addEventListener(g=>this._definitionChanged.raiseEvent(this,"sampled",g,g),this),this._entities=[...((a=(t=this._scheme).initEntites)==null?void 0:a.call(t))??[]],this._primitives=[...((s=(o=this._scheme).initPrimitives)==null?void 0:s.call(o))??[]],this._groundPrimitives=[...((r=(d=this._scheme).initGroundPrimitives)==null?void 0:r.call(d))??[]],this._skeletons=[]}get id(){return this._id}get scheme(){return this._scheme}get definitionChanged(){return this._definitionChanged}get defining(){return this._defining}static setDefining(e,t){e._defining!==t&&(e._definitionChanged.raiseEvent(e,"defining",t,e._defining),e._defining=t)}get disabled(){return this._disabled}set disabled(e){this.disabled=e}get sampled(){return this._sampled}get entities(){return this._entities}set entities(e){this._definitionChanged.raiseEvent(this,"entities",e,this._entities),this._entities=e}get primitives(){return this._primitives}set primitives(e){this._definitionChanged.raiseEvent(this,"primitives",e,this._primitives),this._primitives=e}get groundPrimitives(){return this._groundPrimitives}set groundPrimitives(e){this._definitionChanged.raiseEvent(this,"groundPrimitives",e,this._groundPrimitives),this._groundPrimitives=e}get skeletons(){return this._skeletons}set skeletons(e){this._definitionChanged.raiseEvent(this,"skeletons",e,this._skeletons),this._skeletons=e}}var b=(i=>(i[i.IDLE=0]="IDLE",i[i.HOVER=1]="HOVER",i[i.ACTIVE=2]="ACTIVE",i))(b||{});class V extends n.Entity{constructor(e){super(e)}}function Q(i,e,t){const a=u.useViewer(),o=u.usePrimitive(new n.PrimitiveCollection),s=u.usePrimitive(new n.PrimitiveCollection,{collection:"ground"}),d=u.useDataSource(new n.CustomDataSource),r=u.useEntityScope({collection:()=>d.value.entities}),v=u.usePrimitiveScope({collection:()=>o.value}),p=u.usePrimitiveScope({collection:()=>s.value}),C=w.shallowRef();u.useScreenSpaceEventHandler(n.ScreenSpaceEventType.MOUSE_MOVE,l=>{C.value=u.canvasCoordToCartesian(l?.endPosition,a.value.scene)}),L.watchArray(i,(l,c,f,h=[])=>{h.forEach(m=>{r.removeWhere(_=>m.entities.includes(_)),v.removeWhere(_=>m.primitives.includes(_)),p.removeWhere(_=>m.groundPrimitives.includes(_))}),f.forEach(m=>{m.entities.forEach(_=>r.add(_)),m.primitives.forEach(_=>v.add(_)),m.groundPrimitives.forEach(_=>p.add(_))})},{immediate:!0,flush:"post"}),u.useCesiumEventListener(()=>i.value.map(l=>l.definitionChanged),(l,c,f,h)=>{if(c==="entities"){const{added:m,removed:_}=u.arrayDiff(f,h);m.forEach(y=>r.add(y)),_.forEach(y=>r.remove(y))}else if(c==="primitives"){const{added:m,removed:_}=u.arrayDiff(f,h);m.forEach(y=>v.add(y)),_.forEach(y=>v.remove(y))}else if(c==="groundPrimitives"){const{added:m,removed:_}=u.arrayDiff(f,h);m.forEach(y=>p.add(y)),_.forEach(y=>p.remove(y))}});const g=async l=>{var c,f;const h=await((f=(c=l.scheme).render)==null?void 0:f.call(c,{packable:l.sampled.getValue(t()),mouse:l.defining?C.value:void 0,defining:l.defining,previous:{entities:l.entities,primitives:l.primitives,groundPrimitives:l.groundPrimitives}}));l.entities=h?.entities??[],l.primitives=h?.primitives??[],l.groundPrimitives=h?.groundPrimitives??[]};return w.watch(e,(l,c)=>{c&&g(c)}),u.useCesiumEventListener(()=>i.value.map(l=>l.definitionChanged),(l,c)=>{["disabled","defining","scheme","sampled","time"].includes(c)&&g(l)}),w.watch(C,()=>{i.value.forEach(l=>l.defining&&g(l))}),{primitives:w.computed(()=>Array.from(v.scope)),groundPrimitives:w.computed(()=>Array.from(v.scope)),entities:w.computed(()=>Array.from(r.scope))}}function X(i,e){const t=u.useViewer(),a=w.ref(!1),o=w.computed(()=>{var r;return(r=i.value)==null?void 0:r.sampled.getValue(e())});u.useScreenSpaceEventHandler(n.ScreenSpaceEventType.LEFT_CLICK,async r=>{var v,p;if(await L.promiseTimeout(1),!i.value||!o.value||a.value)return;const{scheme:C,defining:g,sampled:l}=i.value;if(!g)return;const c=u.canvasCoordToCartesian(r.position,t.value.scene);if(!c)return;(v=o.value).positions??(v.positions=[]),o.value.positions.push(c),l.setSample(o.value),((p=C.complete)==null?void 0:p.call(C,o.value))&&A.setDefining(i.value,!1)}),u.useScreenSpaceEventHandler(n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,async r=>{var v;if(!i.value||!o.value)return;a.value=!0,await L.promiseTimeout(2),a.value=!1;const{scheme:p,defining:C}=i.value;if(!C||!u.canvasCoordToCartesian(r.position,t.value.scene))return;((v=p.allowManualComplete)==null?void 0:v.call(p,o.value))&&A.setDefining(i.value,!1)}),u.useScreenSpaceEventHandler(n.ScreenSpaceEventType.RIGHT_CLICK,async()=>{var r;if(!i.value||!o.value)return;const{defining:v,sampled:p}=i.value;v&&((r=o.value).positions??(r.positions=[]),o.value.positions.length!==0&&(o.value.positions.splice(o.value.positions.length-1,1),p.setSample(o.value)))});const s=w.ref(),d=()=>{var r,v;if(!((r=i.value)!=null&&r.defining))s.value&&(s.value=void 0,t.value.container.parentElement.style.removeProperty("cursor"));else{const p=i.value.scheme.definingCursor;s.value=u.isFunction(p)?p(o.value):p,s.value&&((v=t.value)==null||v.container.parentElement.style.setProperty("cursor",s.value))}};u.useCesiumEventListener(()=>{var r;return(r=i.value)==null?void 0:r.definitionChanged},(r,v)=>{(v==="defining"||v==="sampled")&&d()}),w.watch(i,()=>d())}function Z(i,e,t){const a=u.useViewer(),o=u.useDataSource(new n.CustomDataSource),s=u.useEntityScope({collection:()=>o.value.entities}),d=w.shallowRef(),r=w.shallowRef(),v=g=>{var l,c;return g?((l=r.value)==null?void 0:l.id)===g.id?b.ACTIVE:((c=d.value)==null?void 0:c.id)===g.id?b.HOVER:b.IDLE:b.IDLE},p=(g,l)=>{const c=g.skeletons,f=[];if(l||g.disabled)g.skeletons=[];else{const h=g.sampled.getValue(t()),m=g.defining,_=e.value===g;g.scheme.skeletons.forEach(T=>{var D;if(u.isFunction(T.disabled)?T.disabled({active:_,defining:m}):T.disabled)return;const H=((D=T.format)==null?void 0:D.call(T,h))??h?.positions??[];H.forEach((ve,W)=>{var K;let S=c.find(O=>O.index===W&&O.skeleton===T);const pe=(K=T.render)==null?void 0:K.call(T,{defining:m,active:_,index:W,packable:h,positions:H,position:ve,action:v(S)}),x=new V(pe??{});S?x.propertyNames.forEach(O=>{O!=="id"&&(S[O]=x[O])}):S=x,S.plot=g,S.skeleton=T,S.index=W,f.push(S)})})}g.skeletons=f},{addGraphicEvent:C}=u.useGraphicEvent();return w.watchEffect(g=>{const l=C("global","DRAG",({event:c,pick:f,dragging:h,lockCamera:m})=>{var _;if(f.id instanceof V&&s.scope.has(f.id)){const y=f.id,T=y.plot;if(T.defining)return;r.value=y;const D=y.skeleton,B=y.index,H=T.sampled.getValue(t());(_=D.onDrag)==null||_.call(D,{viewer:a.value,sampled:T.sampled,packable:H,active:e.value===T,index:B,event:c,dragging:h,lockCamera:m})}else r.value=void 0},{cursor:({pick:c})=>{var f;if(!((f=e.value)!=null&&f.defining)&&s.scope.has(c.id)){const h=c.id.skeleton;return u.isFunction(h?.cursor)?h.cursor(c):w.toValue(h?.cursor)}},dragCursor:({pick:c})=>{var f;if(!((f=e.value)!=null&&f.defining)&&s.scope.has(c.id)){const h=c.id.skeleton;return u.isFunction(h?.dragCursor)?h.dragCursor(c):w.toValue(h?.dragCursor)}}});g(l)}),L.onKeyStroke(g=>{var l;if(r.value){const c=r.value,f=c.plot,h=c.skeleton,m=c.index,_=f.sampled.getValue(t());(l=h.onKeyPressed)==null||l.call(h,{viewer:a.value,sampled:f.sampled,packable:_,index:m,keyEvent:g})}}),w.watchEffect(g=>{const l=C("global","HOVER",({hovering:c,pick:f})=>{if(c&&f.id instanceof V&&s.scope.has(f.id)){const h=f.id;d.value=h}else d.value=void 0});g(l)}),w.watchEffect(g=>{const l=C("global","LEFT_CLICK",({event:c,pick:f})=>{var h;if(f.id instanceof V&&s.scope.has(f.id)){const m=f.id;r.value=m;const _=m.plot,y=m.skeleton,T=m.index,D=_.sampled.getValue(t());(h=y.onLeftClick)==null||h.call(y,{viewer:a.value,sampled:_.sampled,packable:D,active:e.value===_,defining:_.defining,index:T,event:c})}else r.value=void 0});g(l)}),L.watchArray(i,(g,l,c,f=[])=>{c.forEach(h=>p(h)),f.forEach(h=>p(h,!0))}),u.useCesiumEventListener(()=>i.value.map(g=>g.definitionChanged),(g,l,c,f)=>{if(["disabled","defining","scheme","sampled","time"].includes(l))w.nextTick(()=>p(g));else if(l==="skeletons"){const{added:h,removed:m}=u.arrayDiff(c,f);h.forEach(_=>s.add(_)),m.forEach(_=>s.remove(_))}}),w.watch(e,(g,l)=>{g&&p(g),l&&p(l)}),{dataSource:o}}function ee(i){const e=i?.time||w.shallowRef(),t=u.useViewer(),a=()=>{var l;return((l=e.value)==null?void 0:l.clone())||new n.JulianDate(0,0)},o=w.shallowReactive(new Set),s=w.computed(()=>Array.from(o)),d=w.shallowRef(),r=w.shallowRef();u.useCesiumEventListener([()=>{var l;return(l=d.value)==null?void 0:l.sampled.definitionChanged}],()=>{var l;r.value=(l=d.value)==null?void 0:l.sampled.getValue(a())}),X(d,a),Q(s,d,a),Z(s,d,a),u.useScreenSpaceEventHandler(n.ScreenSpaceEventType.LEFT_CLICK,l=>{var c,f,h;if((c=d.value)!=null&&c.defining)return;const m=(f=t.value)==null?void 0:f.scene.pick(l.position.clone());if(!(((h=m?.id)==null?void 0:h.plot)instanceof A)){if(!m){d.value=void 0;return}d.value=s.value.find(_=>u.pickHitGraphic(m,[..._.entities,..._.primitives,..._.groundPrimitives]))}});let v,p;return w.watch(d,(l,c)=>{var f,h;if(c&&c.defining){const m=c.sampled.getValue(a());((h=(f=c.scheme).allowManualComplete)==null?void 0:h.call(f,m))?(A.setDefining(c,!1),v?.(c)):o.delete(c)}}),{plots:s,time:e,operate:async l=>new Promise((c,f)=>{v=c,p=f;const h=l instanceof A?l:new A(l);return o.has(h)||o.add(h),d.value=h,c(h)}),remove:l=>(l===d.value&&(d.value=void 0),o.has(l)?(o.delete(l),!0):!1),cancel:p}}function M(){return{disabled:({active:i})=>!i,cursor:"pointer",dragCursor:"crosshair",onDrag({viewer:i,sampled:e,packable:t,event:a,index:o,lockCamera:s}){s();const d=u.canvasCoordToCartesian(a.endPosition,i.scene);if(d){const r=[...t.positions??[]];r[o]=d,e.setSample({time:t.time,derivative:t.derivative,positions:r})}},onKeyPressed({viewer:i,keyEvent:e,sampled:t,packable:a,index:o}){var s;const d=(s=u.toCartographic(i.camera.position))==null?void 0:s.height;if(!d||!["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"].includes(e.key))return;e.preventDefault();let r=0;switch(e.key){case"ArrowRight":r=Math.PI/2;break;case"ArrowDown":r=Math.PI;break;case"ArrowLeft":r=-Math.PI/2;break;case"ArrowUp":r=0;break}const v=(i.camera.heading+r)%(2*Math.PI),p=[...a.positions??[]],C=u.toCartographic(p[o]),l=d/1e5*Math.PI/180/1e3;C.latitude+=l*Math.cos(v),C.longitude+=l*Math.sin(v),p[o]=u.toCartesian3(C),t.setSample({time:a.time,derivative:a.derivative,positions:p})},render:({position:i,action:e})=>{const t={[b.IDLE]:n.Color.BLUE.withAlpha(.4),[b.HOVER]:n.Color.BLUE.withAlpha(.6),[b.ACTIVE]:n.Color.AQUA.withAlpha(1)};return{position:i,point:{pixelSize:8,color:t[e],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:n.Color.WHITE.withAlpha(.4)}}}}}function N(){let i=-1;return{disabled:({active:e,defining:t})=>!e||t,cursor:"pointer",dragCursor:"crosshair",format(e){const t=e.positions??[];return t.length<2?[]:t.map((a,o)=>{const s=o===t.length-1?t[0]:t[o+1];return n.Cartesian3.midpoint(a,s,new n.Cartesian3)})},onDrag({viewer:e,sampled:t,packable:a,event:o,index:s,lockCamera:d,dragging:r}){d();const v=u.canvasCoordToCartesian(o.endPosition,e.scene);if(!v)return;const p=[...a.positions??[]];i===-1?(i=s,p.splice(s+1,0,v)):p[i+1]=v,r||(i=-1),t.setSample({time:a.time,derivative:a.derivative,positions:p})},render:({position:e,action:t,active:a})=>{if(!a)return;const o={[b.IDLE]:n.Color.GREEN.withAlpha(.4),[b.HOVER]:n.Color.GREEN.withAlpha(.6),[b.ACTIVE]:n.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:o[t],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:n.Color.WHITE.withAlpha(.4)}}}}}function U(){let i=-1;return{disabled:({active:e,defining:t})=>!e||t,cursor:"pointer",dragCursor:"crosshair",format(e){const t=e.positions??[];if(t.length<2)return[];const a=[];for(let o=0;o<t.length-1;o++)a.push(n.Cartesian3.midpoint(t[o],t[o+1],new n.Cartesian3));return a},onDrag({viewer:e,sampled:t,packable:a,event:o,index:s,lockCamera:d,dragging:r}){d();const v=u.canvasCoordToCartesian(o.endPosition,e.scene);if(!v)return;const p=[...a.positions??[]];i===-1?(i=s,p.splice(s+1,0,v)):p[i+1]=v,r||(i=-1),t.setSample({time:a.time,derivative:a.derivative,positions:p})},render:({position:e,action:t})=>{const a={[b.IDLE]:n.Color.GREEN.withAlpha(.4),[b.HOVER]:n.Color.GREEN.withAlpha(.6),[b.ACTIVE]:n.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:a[t],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:n.Color.WHITE.withAlpha(.4)}}}}}const te=`data:image/svg+xml;utf8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m18 9l3 3l-3 3m-3-3h6M6 9l-3 3l3 3m-3-3h6m0 6l3 3l3-3m-3-3v6m3-15l-3-3l-3 3m3-3v6"/></svg>')}`;function k(){return{disabled:({active:i,defining:e})=>!i||e,cursor:"pointer",dragCursor:"crosshair",format(i){const e=i.positions??[];if(e.length===0)return[];if(e.length===1)return[e[0]];{const t=n.Rectangle.center(n.Rectangle.fromCartesianArray(e));return[u.toCartesian3(t)]}},onDrag({viewer:i,sampled:e,packable:t,event:a,lockCamera:o,dragging:s}){s&&o();const d=u.canvasCoordToCartesian(a.startPosition,i.scene),r=u.canvasCoordToCartesian(a.endPosition,i.scene);if(!d||!r)return;const v=n.Cartesian3.subtract(r,d,new n.Cartesian3),p=[...t.positions??[]];e.setSample({time:t.time,derivative:t.derivative,positions:p.map(C=>n.Cartesian3.add(C,v,new n.Cartesian3))})},render:({position:i,action:e})=>{const t={[b.IDLE]:n.Color.WHITE,[b.HOVER]:n.Color.WHITE,[b.ACTIVE]:n.Color.AQUA.withAlpha(1)};return{position:i,billboard:{image:te,width:20,height:20,color:t[e],pixelOffset:new n.Cartesian3(0,-20),horizontalOrigin:n.HorizontalOrigin.CENTER,verticalOrigin:n.VerticalOrigin.BOTTOM,disableDepthTestDistance:Number.POSITIVE_INFINITY}}}}}function ie(i){if(i.length<3)throw new Error("positions must >= 3");if(i.length===3)return[[i[0].clone(),i[1].clone(),i[2].clone()]];const e=n.CoplanarPolygonGeometry.createGeometry(n.CoplanarPolygonGeometry.fromPositions({positions:i,vertexFormat:n.VertexFormat.POSITION_ONLY}));if(!e)throw new Error("positions\u65E0\u6CD5\u7EC4\u6210\u6709\u6548\u7684geometry,\u68C0\u67E5\u70B9\u4F4D\u662F\u5426\u9519\u8BEF");const t=e.attributes.position.values,a=e.indices,o=[];for(let s=0;s<a.length;s+=3){const d=n.Cartesian3.unpack(t,a[s]*3,new n.Cartesian3),r=n.Cartesian3.unpack(t,a[s+1]*3,new n.Cartesian3),v=n.Cartesian3.unpack(t,a[s+2]*3,new n.Cartesian3);o.push([d,r,v])}return o}function ne(i,e,t){const a=n.Cartesian3.subtract(i,e,new n.Cartesian3),o=n.Cartesian3.subtract(t,e,new n.Cartesian3),s=n.Cartesian3.cross(a,o,a);return n.Cartesian3.magnitude(s)*.5}function oe(i){const t=n.ClassificationType.BOTH,a=Math.floor(10);return{scene:i?.scene,clampToGround:!1,classificationType:t,terrainProvider:i?.terrainProvider,density:a}}async function se(i,e){if(i.length<2)throw new Error("positions.length must >= 2");const{density:t}=oe(e);if(t<=0)throw new Error("options.density must > 0");return ie(i).reduce((o,s)=>o+=ne(...s),0)}const ae=new I({type:"measureArea",allowManualComplete:i=>i.positions.length>=3,skeletons:[M,N],initEntites:()=>[new n.Entity({label:{font:"14pt"},polyline:{material:n.Color.YELLOW.withAlpha(.5)},polygon:{material:n.Color.YELLOW.withAlpha(.5)}})],render(i){var e;const{mouse:t,packable:a}=i,o=((e=i.previous.entities)==null?void 0:e[0])??new n.Entity({label:{font:"14pt"},polyline:{material:n.Color.YELLOW.withAlpha(.5)},polygon:{material:n.Color.YELLOW.withAlpha(.5)}}),s=[...a.positions??[]];return t&&s.push(t),s.length===2?(o.position=void 0,o.label.text=void 0,o.polygon.hierarchy=void 0,o.polyline.positions=new n.CallbackProperty(()=>s,!1)):s.length>=3?(s.push(s[0]),o.position=new n.ConstantPositionProperty(u.toCartesian3(n.Rectangle.center(n.Rectangle.fromCartesianArray(s)))),o.label.text=new n.ConstantProperty(""),se(s).then(d=>{let r="";d/1e3/1e3>10?r=`${(d/1e3/1e3).toFixed(2)}km\xB2`:r=`${(+d).toFixed(2)}m\xB2`,o.label.text=new n.ConstantProperty(r)}),o.polyline.positions=void 0,o.polygon.hierarchy=new n.CallbackProperty(()=>s.length>=3?new n.PolygonHierarchy([...s]):void 0,!1)):(o.position=void 0,o.polygon.hierarchy=void 0,o.polyline.positions=void 0),{entities:[o]}}}),re=new I({type:"billboard",complete:i=>i.positions.length>=1,skeletons:[k],initEntites:()=>[new n.Entity({billboard:{image:"/favicon.svg",width:32,height:32}})],render(i){var e,t;const{mouse:a,packable:o}=i,s=((e=i.previous.entities)==null?void 0:e[0])??new n.Entity({billboard:{}}),d=((t=o.positions)==null?void 0:t[0])??a;return s.position=new n.CallbackPositionProperty(()=>d,!0),{entities:[s]}}}),le=new I({type:"label",complete:i=>i.positions.length>=1,skeletons:[k],initEntites:()=>[new n.Entity({label:{text:"Label"}})],render(i){var e,t;const{mouse:a,packable:o}=i,s=((e=i.previous.entities)==null?void 0:e[0])??new n.Entity({label:{}}),d=((t=o.positions)==null?void 0:t[0])??a;return s.position=new n.CallbackPositionProperty(()=>d,!0),{entities:[s]}}}),de=new I({type:"polygon",allowManualComplete:i=>i.positions.length>=3,skeletons:[M,N,k],initEntites:()=>[new n.Entity({polyline:{material:n.Color.YELLOW.withAlpha(.5)},polygon:{material:n.Color.YELLOW.withAlpha(.5)}})],render(i){var e;const{mouse:t,packable:a}=i,o=((e=i.previous.entities)==null?void 0:e[0])??new n.Entity({polyline:{material:n.Color.YELLOW.withAlpha(.5)},polygon:{material:n.Color.YELLOW.withAlpha(.5)}}),s=[...a.positions??[]];return t&&s.push(t),s.length===2?(o.polygon.hierarchy=void 0,o.polyline.positions=new n.CallbackProperty(()=>s,!1)):s.length>=3?(o.polyline.positions=void 0,o.polygon.hierarchy=new n.CallbackProperty(()=>(s.push(s[0]),s.length>=3?new n.PolygonHierarchy([...s]):void 0),!1)):(o.polygon.hierarchy=void 0,o.polyline.positions=void 0),{entities:[o]}}}),ce=new I({type:"polyline",allowManualComplete:i=>i.positions.length>=2,skeletons:[M,U,k],initEntites:()=>[new n.Entity({polyline:{width:1}})],render(i){var e;const{mouse:t,packable:a}=i,o=((e=i.previous.entities)==null?void 0:e[0])??new n.Entity({polyline:{}});return o.polyline.positions=new n.CallbackProperty(()=>{const s=[...a.positions??[]].concat(t?[t]:[]);return s.length>=2?s:[]},!1),{entities:[o]}}}),he=new I({type:"rectangle",complete:i=>i.positions.length>=2,skeletons:[M,N,k],initEntites:()=>[new n.Entity({rectangle:{material:n.Color.YELLOW.withAlpha(.5)}})],render(i){var e;const{mouse:t,packable:a}=i,o=((e=i.previous.entities)==null?void 0:e[0])??new n.Entity({rectangle:{material:n.Color.YELLOW.withAlpha(.5)}}),s=[...a.positions??[]];return t&&s.push(t),s.length>=2?o.rectangle.coordinates=new n.CallbackProperty(()=>n.Rectangle.fromCartesianArray(s),!1):o.rectangle.coordinates=void 0,{entities:[o]}}});return P.PlotAction=b,P.PlotFeature=A,P.PlotScheme=I,P.PlotSkeletonEntity=V,P.SampledPlotProperty=G,P.SampledPlotStrategy=Y,P.control=M,P.interval=N,P.intervalNonclosed=U,P.moved=k,P.schemeBillboard=re,P.schemeLabel=le,P.schemeMeasureArea=ae,P.schemePolygon=de,P.schemePolyline=ce,P.schemeRectangle=he,P.usePlot=ee,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),P}({},Cesium,Vesium,VueUse,Vue);
2
- //# sourceMappingURL=index.iife.min.js.map
1
+ (function(exports,t,n,r,i,a){var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e},p=(e,t,n)=>(n=e==null?{}:o(u(e)),f(t||!e||!e.__esModule?s(n,`default`,{value:e,enumerable:!0}):n,e));t=p(t),n=p(n),r=p(r),i=p(i),a=p(a);var m=class e{constructor(e){this.type=e.type,this.complete=e.complete,this.allowManualComplete=e.allowManualComplete,this.definingCursor=e.definingCursor??`crosshair`,this.skeletons=e.skeletons?.map(e=>e())??[],this.initRender=e.initRender,this.render=e.render}type;complete;allowManualComplete;definingCursor;skeletons;initRender;render;static _record=new Map;static getCacheTypes(){return[...this._record.keys()]}static getCache(t){return e._record.get(t)}static setCache(t){(0,n.assertError)(!t.type,"`scheme.type` is required"),e._record.set(t.type,t)}static resolve(t){if(typeof t==`string`){let n=e.getCache(t);return(0,r.assert)(!!n,`scheme ${t} not found`),n}else if(t instanceof e)return t;else return new e(t)}};let h=function(e){return e[e.NEAR=0]=`NEAR`,e[e.CYCLE=1]=`CYCLE`,e[e.STRICT=2]=`STRICT`,e}({}),g=(e,n,r,i)=>i===0?{time:e,positions:n.positions?.map(e=>e.clone()),derivative:n.derivative}:i===1?{time:e,positions:r.positions?.map(e=>e.clone()),derivative:n.derivative}:{time:e,positions:r.positions?.map((e,r)=>{let a=n.positions?.[r];return a?t.Cartesian3.lerp(a,e,i,new t.Cartesian3):e}),derivative:n.derivative};var _=class e{constructor(e){this.interpolationAlgorithm=e?.interpolationAlgorithm,this.strategy=e?.strategy??h.NEAR,e?.packables?.forEach(e=>this.setSample(e)),this._times.length||this.setSample({time:new t.JulianDate(0,0),positions:[],derivative:void 0})}static defaultInterpolationAlgorithm=g;strategy;interpolationAlgorithm;_times=[];_sampleds=[];_derivatives=[];get isConstant(){return this._times.length===0}_definitionChanged=new t.Event;get definitionChanged(){return this._definitionChanged}getTimes(){return this._times.map(e=>e.clone())}getIndexScope(e){if(!this._times.length)return;let n=this._times[0],r=this._times[this._times.length-1];if(t.JulianDate.lessThan(e,n)||t.JulianDate.greaterThan(e,r))switch(this.strategy){case h.STRICT:return;case h.NEAR:e=t.JulianDate.lessThan(e,this._times[0])?this._times[0].clone():this._times[this._times.length-1].clone();break;case h.CYCLE:{let n=t.JulianDate.toDate(this._times[0]).getTime(),r=t.JulianDate.toDate(this._times[this._times.length-1]).getTime(),i=r-n,a=t.JulianDate.toDate(e).getTime(),o=(a-n)%i,s=new Date(n+o);e=t.JulianDate.fromDate(s);break}}let i=this._times.findIndex(n=>t.JulianDate.lessThanOrEquals(e,n)),a=Math.min(i,this._times.length-1),o=t.JulianDate.toDate(this._times[i]).getTime(),s=t.JulianDate.toDate(this._times[a]).getTime(),c=t.JulianDate.toDate(e).getTime();return{prevIndex:i,nextIndex:a,proportion:(c-o)/(s-o)||0}}getValue(t,n){if(n??={time:t,positions:[]},Object.assign(n,{time:t?.clone(),positions:[],derivative:void 0}),!t)return n.time=this._times[0].clone(),n.positions=this._sampleds[0]?.map(e=>e.clone(e)),n.derivative=this._derivatives[0],n;let r=this.getIndexScope(t);if(!r)return n;n.time=t;let{prevIndex:i,nextIndex:a,proportion:o}=r,s={time:this._times[i],positions:this._sampleds[i],derivative:this._derivatives[i]},c={time:this._times[a],positions:this._sampleds[a],derivative:this._derivatives[a]},l=(this.interpolationAlgorithm||e.defaultInterpolationAlgorithm)(t,s,c,o);return Object.assign(n,l),n}setSample(e){let n=e.time?.clone()??this._times[0].clone(),r=e.positions?.map(e=>e.clone())??[],i=e.derivative,a=this._times.findIndex(e=>t.JulianDate.equals(n,e));a===-1?this._times.length===0?(this._times[0]=n,this._sampleds[0]=r,this._derivatives[0]=e.derivative):t.JulianDate.lessThan(n,this._times[0])?(this._times.splice(0,0,n),this._sampleds.splice(0,0,r),this._derivatives.splice(0,0,i)):t.JulianDate.greaterThan(n,this._times[this._times.length-1])&&(this._times.push(n),this._sampleds.push(r),this._derivatives.push(i)):(this._times[a]=n,this._sampleds[a]=r,this._derivatives[a]=e.derivative),this.definitionChanged.raiseEvent(this)}setSamples(e){e.forEach(e=>this.setSample(e))}removeSample(e){let t=this._times.findIndex(t=>t.equals(e));if(t!==-1){this._sampleds.splice(t,1),this._derivatives.splice(t,1);let e=this._times.splice(t,1);if(e.length)return this._definitionChanged.raiseEvent(this),!0}return!1}removeSamples(e){for(let n=0;n<this._times.length;n++){let r=this._times[n];t.TimeInterval.contains(e,r)&&this.removeSample(r)}}equals(e){return e===this}},v=class{constructor(e){let{id:n,disabled:r=!1,sampled:i}=e;this._id=n||(0,t.createGuid)(),this._scheme=m.resolve(e.scheme),this._definitionChanged=new t.Event,this._defining=!0,this._disabled=r,this._sampled=i instanceof _?i:new _(i),this._sampled.definitionChanged.addEventListener(e=>this._definitionChanged.raiseEvent(this,`sampled`,e,e),this);let a=this._scheme.initRender?.()??{};this._entities=[...a.entities??[]],this._primitives=[...a.primitives??[]],this._groundPrimitives=[...a.groundPrimitives??[]],this._skeletons=[]}_id;get id(){return this._id}_scheme;get scheme(){return this._scheme}_definitionChanged;get definitionChanged(){return this._definitionChanged}_defining;get defining(){return this._defining}static setDefining(e,t){e._defining!==t&&(e._definitionChanged.raiseEvent(e,`defining`,t,e._defining),e._defining=t)}_disabled;get disabled(){return this._disabled}set disabled(e){this.disabled=e}_sampled;get sampled(){return this._sampled}_entities;get entities(){return this._entities}set entities(e){this._definitionChanged.raiseEvent(this,`entities`,e,this._entities),this._entities=e}_primitives;get primitives(){return this._primitives}set primitives(e){this._definitionChanged.raiseEvent(this,`primitives`,e,this._primitives),this._primitives=e}_groundPrimitives;get groundPrimitives(){return this._groundPrimitives}set groundPrimitives(e){this._definitionChanged.raiseEvent(this,`groundPrimitives`,e,this._groundPrimitives),this._groundPrimitives=e}_skeletons;get skeletons(){return this._skeletons}set skeletons(e){this._definitionChanged.raiseEvent(this,`skeletons`,e,this._skeletons),this._skeletons=e}};let y=function(e){return e[e.IDLE=0]=`IDLE`,e[e.HOVER=1]=`HOVER`,e[e.ACTIVE=2]=`ACTIVE`,e}({});var b=class extends t.Entity{constructor(e){super(e)}};function x(e,a,o){let s=(0,n.useViewer)(),c=(0,n.usePrimitive)(new t.PrimitiveCollection),l=(0,n.usePrimitive)(new t.PrimitiveCollection,{collection:`ground`}),u=(0,n.useDataSource)(new t.CustomDataSource),d=(0,n.useEntityScope)({collection:()=>u.value.entities}),f=(0,n.usePrimitiveScope)({collection:()=>c.value}),p=(0,n.usePrimitiveScope)({collection:()=>l.value}),m=(0,i.shallowRef)();(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.MOUSE_MOVE,e=>{m.value=(0,n.canvasCoordToCartesian)(e?.endPosition,s.value.scene)}),(0,r.watchArray)(e,(e,t,n,r=[])=>{r.forEach(e=>{d.removeWhere(t=>e.entities.includes(t)),f.removeWhere(t=>e.primitives.includes(t)),p.removeWhere(t=>e.groundPrimitives.includes(t))}),n.forEach(e=>{e.entities.forEach(e=>d.add(e)),e.primitives.forEach(e=>f.add(e)),e.groundPrimitives.forEach(e=>p.add(e))})},{immediate:!0,flush:`post`}),(0,n.useCesiumEventListener)(()=>e.value.map(e=>e.definitionChanged),(e,t,r,i)=>{if(t===`entities`){let{added:e,removed:t}=(0,n.arrayDiff)(r,i);e.forEach(e=>d.add(e)),t.forEach(e=>d.remove(e))}else if(t===`primitives`){let{added:e,removed:t}=(0,n.arrayDiff)(r,i);e.forEach(e=>f.add(e)),t.forEach(e=>f.remove(e))}else if(t===`groundPrimitives`){let{added:e,removed:t}=(0,n.arrayDiff)(r,i);e.forEach(e=>p.add(e)),t.forEach(e=>p.remove(e))}});let h=async e=>{let t=await e.scheme.render?.({packable:e.sampled.getValue(o()),mouse:e.defining?m.value:void 0,defining:e.defining,previous:{entities:e.entities,primitives:e.primitives,groundPrimitives:e.groundPrimitives}});e.entities=t?.entities??[],e.primitives=t?.primitives??[],e.groundPrimitives=t?.groundPrimitives??[]};return(0,i.watch)(a,(e,t)=>{t&&h(t)}),(0,n.useCesiumEventListener)(()=>e.value.map(e=>e.definitionChanged),(e,t)=>{[`disabled`,`defining`,`scheme`,`sampled`,`time`].includes(t)&&h(e)}),(0,i.watch)(m,()=>{e.value.forEach(e=>e.defining&&h(e))}),{primitives:(0,i.computed)(()=>Array.from(f.scope)),groundPrimitives:(0,i.computed)(()=>Array.from(f.scope)),entities:(0,i.computed)(()=>Array.from(d.scope))}}function ee(e,a){let o=(0,n.useViewer)(),s=(0,i.ref)(!1),c=(0,i.computed)(()=>e.value?.sampled.getValue(a()));(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.LEFT_CLICK,async t=>{if(await(0,r.promiseTimeout)(1),!e.value||!c.value||s.value)return;let{scheme:i,defining:a,sampled:l}=e.value;if(!a)return;let u=(0,n.canvasCoordToCartesian)(t.position,o.value.scene);if(!u)return;c.value.positions??=[],c.value.positions.push(u),l.setSample(c.value);let d=i.complete?.(c.value);d&&v.setDefining(e.value,!1)}),(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,async t=>{if(!e.value||!c.value)return;s.value=!0,await(0,r.promiseTimeout)(2),s.value=!1;let{scheme:i,defining:a}=e.value;if(!a)return;let l=(0,n.canvasCoordToCartesian)(t.position,o.value.scene);if(!l)return;let u=i.allowManualComplete?.(c.value);u&&v.setDefining(e.value,!1)}),(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.RIGHT_CLICK,async()=>{if(!e.value||!c.value)return;let{defining:t,sampled:n}=e.value;t&&(c.value.positions??=[],c.value.positions.length!==0&&(c.value.positions.splice(c.value.positions.length-1,1),n.setSample(c.value)))});let l=(0,i.ref)(),u=()=>{if(!e.value?.defining)l.value&&(l.value=void 0,o.value.container.parentElement.style.removeProperty(`cursor`));else{let t=e.value.scheme.definingCursor;l.value=(0,n.isFunction)(t)?t(c.value):t,l.value&&o.value?.container.parentElement.style.setProperty(`cursor`,l.value)}};(0,n.useCesiumEventListener)(()=>e.value?.definitionChanged,(e,t)=>{(t===`defining`||t===`sampled`)&&u()}),(0,i.watch)(e,()=>u())}function te(e,a,o){let s=(0,n.useViewer)(),c=(0,n.useDataSource)(new t.CustomDataSource),l=(0,n.useEntityScope)({collection:()=>c.value.entities}),u=(0,i.shallowRef)(),d=(0,i.shallowRef)(),f=e=>e?d.value?.id===e.id?y.ACTIVE:u.value?.id===e.id?y.HOVER:y.IDLE:y.IDLE,p=(e,t)=>{let r=e.skeletons,i=[];if(t||e.disabled)e.skeletons=[];else{let t=e.sampled.getValue(o()),s=e.defining,c=a.value===e,l=e.scheme.skeletons;l.forEach(a=>{let o=(0,n.isFunction)(a.disabled)?a.disabled({active:c,defining:s}):a.disabled;if(o)return;let l=a.format?.(t)??t?.positions??[];l.forEach((n,o)=>{let u=r.find(e=>e.index===o&&e.skeleton===a),d=a.render?.({defining:s,active:c,index:o,packable:t,positions:l,position:n,action:f(u)}),p=new b(d??{});u?p.propertyNames.forEach(e=>{e!==`id`&&(u[e]=p[e])}):u=p,u.plot=e,u.skeleton=a,u.index=o,i.push(u)})})}e.skeletons=i},{addGraphicEvent:m}=(0,n.useGraphicEvent)();return(0,i.watchEffect)(e=>{let t=m(`global`,`DRAG`,({event:e,pick:t,dragging:n,lockCamera:r})=>{if(t.id instanceof b&&l.scope.has(t.id)){let i=t.id,c=i.plot;if(c.defining)return;d.value=i;let l=i.skeleton,u=i.index,f=c.sampled.getValue(o());l.onDrag?.({viewer:s.value,sampled:c.sampled,packable:f,active:a.value===c,index:u,event:e,dragging:n,lockCamera:r})}else d.value=void 0},{cursor:({pick:e})=>{if(!a.value?.defining&&l.scope.has(e.id)){let t=e.id.skeleton;return(0,n.isFunction)(t?.cursor)?t.cursor(e):(0,i.toValue)(t?.cursor)}},dragCursor:({pick:e})=>{if(!a.value?.defining&&l.scope.has(e.id)){let t=e.id.skeleton;return(0,n.isFunction)(t?.dragCursor)?t.dragCursor(e):(0,i.toValue)(t?.dragCursor)}}});e(t)}),(0,r.onKeyStroke)(e=>{if(d.value){let t=d.value,n=t.plot,r=t.skeleton,i=t.index,a=n.sampled.getValue(o());r.onKeyPressed?.({viewer:s.value,sampled:n.sampled,packable:a,index:i,keyEvent:e})}}),(0,i.watchEffect)(e=>{let t=m(`global`,`HOVER`,({hovering:e,pick:t})=>{if(e&&t.id instanceof b&&l.scope.has(t.id)){let e=t.id;u.value=e}else u.value=void 0});e(t)}),(0,i.watchEffect)(e=>{let t=m(`global`,`LEFT_CLICK`,({event:e,pick:t})=>{if(t.id instanceof b&&l.scope.has(t.id)){let n=t.id;d.value=n;let r=n.plot,i=n.skeleton,c=n.index,l=r.sampled.getValue(o());i.onLeftClick?.({viewer:s.value,sampled:r.sampled,packable:l,active:a.value===r,defining:r.defining,index:c,event:e})}else d.value=void 0});e(t)}),(0,r.watchArray)(e,(e,t,n,r=[])=>{n.forEach(e=>p(e)),r.forEach(e=>p(e,!0))}),(0,n.useCesiumEventListener)(()=>e.value.map(e=>e.definitionChanged),(e,t,r,a)=>{if([`disabled`,`defining`,`scheme`,`sampled`,`time`].includes(t))(0,i.nextTick)(()=>p(e));else if(t===`skeletons`){let{added:e,removed:t}=(0,n.arrayDiff)(r,a);e.forEach(e=>l.add(e)),t.forEach(e=>l.remove(e))}}),(0,i.watch)(a,(e,t)=>{e&&p(e),t&&p(t)}),{dataSource:c}}function S(e){let r=e?.time||(0,i.shallowRef)(),a=(0,n.useViewer)(),o=()=>r.value?.clone()||new t.JulianDate(0,0),s=(0,i.shallowReactive)(new Set),c=(0,i.computed)(()=>Array.from(s)),l=(0,i.shallowRef)(),u=(0,i.shallowRef)();(0,n.useCesiumEventListener)([()=>l.value?.sampled.definitionChanged],()=>{u.value=l.value?.sampled.getValue(o())}),ee(l,o),x(c,l,o),te(c,l,o),(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.LEFT_CLICK,e=>{if(l.value?.defining)return;let t=a.value?.scene.pick(e.position.clone());if(!(t?.id?.plot instanceof v)){if(!t){l.value=void 0;return}l.value=c.value.find(e=>(0,n.pickHitGraphic)(t,[...e.entities,...e.primitives,...e.groundPrimitives]))}});let d,f;(0,i.watch)(l,(e,t)=>{if(t&&t.defining){let e=t.sampled.getValue(o()),n=t.scheme.allowManualComplete?.(e);n?(v.setDefining(t,!1),d?.(t)):s.delete(t)}});let p=async e=>new Promise((t,n)=>{d=t,f=n;let r=e instanceof v?e:new v(e);return s.has(r)||s.add(r),l.value=r,t(r)}),m=e=>(e===l.value&&(l.value=void 0),s.has(e)?(s.delete(e),!0):!1);return{plots:c,time:r,operate:p,remove:m,cancel:f}}function C(){return{disabled:({active:e})=>!e,cursor:`pointer`,dragCursor:`crosshair`,onDrag({viewer:e,sampled:t,packable:r,event:i,index:a,lockCamera:o}){o();let s=(0,n.canvasCoordToCartesian)(i.endPosition,e.scene);if(s){let e=[...r.positions??[]];e[a]=s,t.setSample({time:r.time,derivative:r.derivative,positions:e})}},onKeyPressed({viewer:e,keyEvent:t,sampled:r,packable:i,index:a}){let o=(0,n.toCartographic)(e.camera.position)?.height;if(!o||![`ArrowUp`,`ArrowRight`,`ArrowDown`,`ArrowLeft`].includes(t.key))return;t.preventDefault();let s=0;switch(t.key){case`ArrowRight`:s=Math.PI/2;break;case`ArrowDown`:s=Math.PI;break;case`ArrowLeft`:s=-Math.PI/2;break;case`ArrowUp`:s=0;break}let c=(e.camera.heading+s)%(2*Math.PI),l=[...i.positions??[]],u=(0,n.toCartographic)(l[a]),d=o/1e5,f=d*Math.PI/180/1e3;u.latitude+=f*Math.cos(c),u.longitude+=f*Math.sin(c),l[a]=(0,n.toCartesian3)(u),r.setSample({time:i.time,derivative:i.derivative,positions:l})},render:({position:e,action:n})=>{let r={[y.IDLE]:t.Color.BLUE.withAlpha(.4),[y.HOVER]:t.Color.BLUE.withAlpha(.6),[y.ACTIVE]:t.Color.AQUA.withAlpha(1)};return{position:e,point:{pixelSize:8,color:r[n],disableDepthTestDistance:1/0,outlineWidth:1,outlineColor:t.Color.WHITE.withAlpha(.4)}}}}}function w(){let e=-1;return{disabled:({active:e,defining:t})=>!e||t,cursor:`pointer`,dragCursor:`crosshair`,format(e){let n=e.positions??[];return n.length<2?[]:n.map((e,r)=>{let i=r===n.length-1?n[0]:n[r+1];return t.Cartesian3.midpoint(e,i,new t.Cartesian3)})},onDrag({viewer:t,sampled:r,packable:i,event:a,index:o,lockCamera:s,dragging:c}){s();let l=(0,n.canvasCoordToCartesian)(a.endPosition,t.scene);if(!l)return;let u=[...i.positions??[]];e===-1?(e=o,u.splice(o+1,0,l)):u[e+1]=l,c||(e=-1),r.setSample({time:i.time,derivative:i.derivative,positions:u})},render:({position:e,action:n,active:r})=>{if(!r)return;let i={[y.IDLE]:t.Color.GREEN.withAlpha(.4),[y.HOVER]:t.Color.GREEN.withAlpha(.6),[y.ACTIVE]:t.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:i[n],disableDepthTestDistance:1/0,outlineWidth:1,outlineColor:t.Color.WHITE.withAlpha(.4)}}}}}function T(){let e=-1;return{disabled:({active:e,defining:t})=>!e||t,cursor:`pointer`,dragCursor:`crosshair`,format(e){let n=e.positions??[];if(n.length<2)return[];let r=[];for(let e=0;e<n.length-1;e++)r.push(t.Cartesian3.midpoint(n[e],n[e+1],new t.Cartesian3));return r},onDrag({viewer:t,sampled:r,packable:i,event:a,index:o,lockCamera:s,dragging:c}){s();let l=(0,n.canvasCoordToCartesian)(a.endPosition,t.scene);if(!l)return;let u=[...i.positions??[]];e===-1?(e=o,u.splice(o+1,0,l)):u[e+1]=l,c||(e=-1),r.setSample({time:i.time,derivative:i.derivative,positions:u})},render:({position:e,action:n})=>{let r={[y.IDLE]:t.Color.GREEN.withAlpha(.4),[y.HOVER]:t.Color.GREEN.withAlpha(.6),[y.ACTIVE]:t.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:r[n],disableDepthTestDistance:1/0,outlineWidth:1,outlineColor:t.Color.WHITE.withAlpha(.4)}}}}}let ne=`data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m18 9l3 3l-3 3m-3-3h6M6 9l-3 3l3 3m-3-3h6m0 6l3 3l3-3m-3-3v6m3-15l-3-3l-3 3m3-3v6"/></svg>`)}`;function E(){return{disabled:({active:e,defining:t})=>!e||t,cursor:`pointer`,dragCursor:`crosshair`,format(e){let r=e.positions??[];if(r.length===0)return[];if(r.length===1)return[r[0]];{let e=t.Rectangle.center(t.Rectangle.fromCartesianArray(r));return[(0,n.toCartesian3)(e)]}},onDrag({viewer:e,sampled:r,packable:i,event:a,lockCamera:o,dragging:s}){s&&o();let c=(0,n.canvasCoordToCartesian)(a.startPosition,e.scene),l=(0,n.canvasCoordToCartesian)(a.endPosition,e.scene);if(!c||!l)return;let u=t.Cartesian3.subtract(l,c,new t.Cartesian3),d=[...i.positions??[]];r.setSample({time:i.time,derivative:i.derivative,positions:d.map(e=>t.Cartesian3.add(e,u,new t.Cartesian3))})},render:({position:e,action:n})=>{let r={[y.IDLE]:t.Color.WHITE,[y.HOVER]:t.Color.WHITE,[y.ACTIVE]:t.Color.AQUA.withAlpha(1)};return{position:e,billboard:{image:ne,width:20,height:20,color:r[n],pixelOffset:new t.Cartesian3(0,-20),horizontalOrigin:t.HorizontalOrigin.CENTER,verticalOrigin:t.VerticalOrigin.BOTTOM,disableDepthTestDistance:1/0}}}}}function re(e){if(e.length<3)throw Error(`positions must >= 3`);if(e.length===3)return[[e[0].clone(),e[1].clone(),e[2].clone()]];let n=t.CoplanarPolygonGeometry.createGeometry(t.CoplanarPolygonGeometry.fromPositions({positions:e,vertexFormat:t.VertexFormat.POSITION_ONLY}));if(!n)throw Error(`positions无法组成有效的geometry,检查点位是否错误`);let r=n.attributes.position.values,i=n.indices,a=[];for(let e=0;e<i.length;e+=3){let n=t.Cartesian3.unpack(r,i[e]*3,new t.Cartesian3),o=t.Cartesian3.unpack(r,i[e+1]*3,new t.Cartesian3),s=t.Cartesian3.unpack(r,i[e+2]*3,new t.Cartesian3);a.push([n,o,s])}return a}async function D(e){let{positions:n,scene:r,classificationType:i=t.ClassificationType.BOTH,terrainProvider:a=r.terrainProvider}=e,o=[t.ClassificationType.BOTH,t.ClassificationType.CESIUM_3D_TILE].includes(i),s=[t.ClassificationType.BOTH,t.ClassificationType.TERRAIN].includes(i),c=new Promise(e=>{o?r.clampToHeightMostDetailed(n.map(e=>e.clone())).then(e).catch(t=>{console.warn(t),e([])}):e([])}),l=new Promise(e=>{s&&a?(0,t.sampleTerrainMostDetailed)(a,n.map(e=>t.Cartographic.fromCartesian(e))).then(t=>e(t)).catch(t=>{console.warn(t),e([])}):e([])}),[u,d]=await Promise.all([c,l]),f=[];return n.forEach((e,n)=>{let r=u[n]||d[n]?t.Ellipsoid.WGS84.cartographicToCartesian(d[n]):e.clone();f.push(r)}),f}function ie(e){let n=e?.clampToGround??!1,r=e?.classificationType??t.ClassificationType.BOTH,i=Math.floor(e?.density??10);return{scene:e?.scene,clampToGround:n,classificationType:r,terrainProvider:e?.terrainProvider,density:i}}async function ae(e,n){if(e.length<3)throw Error(`positions must >= 3`);let{density:r,scene:i,clampToGround:a,classificationType:o,terrainProvider:s}=ie(n);if(r<=0)throw Error(`options.density must > 0`);let c=t.Rectangle.fromCartesianArray(e),l=c.north-c.south,u=c.east-c.west,d=Math.max(u,l),f=d/r,p=t.PolygonGeometry.fromPositions({positions:e,vertexFormat:t.PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,granularity:f}),m=t.PolygonGeometry.createGeometry(p),h=m.attributes.position.values;if(!m||!h)throw Error(`positions无法组成有效的geometry,检查点位是否错误`);let g=m.indices,_=[];for(let e=0;e<g.length;e+=3){let n=t.Cartesian3.unpack(h,g[e]*3,new t.Cartesian3),r=t.Cartesian3.unpack(h,g[e+1]*3,new t.Cartesian3),i=t.Cartesian3.unpack(h,g[e+2]*3,new t.Cartesian3);_.push(n,r,i)}if(a){if(!i)throw Error("scene is required on `clampToGround == true`.");let e=await D({scene:i,terrainProvider:s,positions:_,classificationType:o});_=e}let v=[];for(;_?.length;){let[e,t,n]=_.splice(0,3);v.push([e,t,n])}return v}function O(e,n,r){let i=t.Cartesian3.subtract(e,n,new t.Cartesian3),a=t.Cartesian3.subtract(r,n,new t.Cartesian3),o=t.Cartesian3.cross(i,a,i);return t.Cartesian3.magnitude(o)*.5}function k(e){let n=e?.clampToGround??!1,r=e?.classificationType??t.ClassificationType.BOTH,i=Math.floor(e?.density??10);return{scene:e?.scene,clampToGround:n,classificationType:r,terrainProvider:e?.terrainProvider,density:i}}async function A(e,t){if(e.length<2)throw Error(`positions.length must >= 2`);let{density:n,scene:r,clampToGround:i,classificationType:a,terrainProvider:o}=k(t);if(n<=0)throw Error(`options.density must > 0`);if(!i){let t=re(e);return t.reduce((e,t)=>e+=O(...t),0)}let s=await ae(e,{density:n,scene:r,clampToGround:i,classificationType:a,terrainProvider:o});return s.reduce((e,t)=>e+=O(...t),0)}async function j(e){let{start:n,end:r,count:i,scene:a,clampToGround:o,classificationType:s,terrainProvider:c}=e,l=[];for(let e=0;e<i;e++){let e=t.Cartesian3.lerp(n,r,1/i,new t.Cartesian3);l.push(e)}if(l.push(r.clone()),!o)return l;if(!a)throw Error("scene is required on `clampToGround == true`.");let u=await D({scene:a,terrainProvider:c,positions:l,classificationType:s});return u}function M(e){let n=e?.clampToGround??!1,r=e?.classificationType??t.ClassificationType.BOTH,i=Math.floor(e?.density??50);return{scene:e?.scene,clampToGround:n,classificationType:r,terrainProvider:e?.terrainProvider,density:i}}async function N(e,n){if(e.length<2)throw Error(`positions.length must >= 2`);let r=M(n),i=[],a=0;if(e.forEach((n,r)=>{if(r!==e.length-1){let o=e[r+1],s=t.Cartesian3.distance(n,o);i.push(s),a+=s}}),!r.clampToGround)return{stages:i,count:a};let o=r.density;if(o<=0)throw Error(`options.density must > 0`);let s=i.map(e=>Math.floor(e/a*o)),c=o-s.reduce((e,t)=>e+=t,0);c&&(s[s.length-1]+=c);let l=s.map((t,n)=>j({scene:r.scene,start:e[n],end:e[n+1],count:t,clampToGround:!0,classificationType:r.classificationType,terrainProvider:r.terrainProvider})),u=await Promise.all(l),d=u.map(async e=>{let{count:t}=await N(e);return t}),f=await Promise.all(d);return{stages:f,count:f.reduce((e,t)=>e+=t,0)}}let oe=new m({type:`MeasureArea`,allowManualComplete:e=>e.positions.length>=3,skeletons:[C,w],initRender(){return{entities:[new t.Entity({label:{font:`14pt`},polyline:{material:t.Color.YELLOW.withAlpha(.5)},polygon:{material:t.Color.YELLOW.withAlpha(.5)}})]}},render(e){let r=e.previous.entities[0],{mouse:i,packable:a}=e,o=[...a.positions??[]];return i&&o.push(i),o.length===2?(r.position=void 0,r.label.text=void 0,r.polygon.hierarchy=void 0,r.polyline.positions=new t.CallbackProperty(()=>o,!1)):o.length>=3?(o.push(o[0]),r.position=new t.ConstantPositionProperty((0,n.toCartesian3)(t.Rectangle.center(t.Rectangle.fromCartesianArray(o)))),r.label.text=new t.ConstantProperty(``),A(o).then(e=>{let n=``;n=e/1e3/1e3>10?`${(e/1e3/1e3).toFixed(2)}km²`:`${(+e).toFixed(2)}m²`,r.label.text=new t.ConstantProperty(n)}),r.polyline.positions=void 0,r.polygon.hierarchy=new t.CallbackProperty(()=>o.length>=3?new t.PolygonHierarchy([...o]):void 0,!1)):(r.position=void 0,r.polygon.hierarchy=void 0,r.polyline.positions=void 0),{entities:[r]}}}),se=new m({type:`MeasureDistance`,allowManualComplete:e=>e.positions.length>=2,skeletons:[C],initRender(){return{entities:[new t.Entity({polyline:{width:2,material:t.Color.YELLOW.withAlpha(.5)}})]}},render(e){let n=e.previous.entities[0],{mouse:r,packable:i,previous:a}=e,o=a.entities,s=[...i.positions??[]];if(r&&s.push(r),s.length<2)return{entities:o};let c=o[0];return c.polyline??=new t.PolylineGraphics,c.polyline.positions=new t.CallbackProperty(()=>s,!1),s.forEach((e,n)=>{o[n+1]||(o[n+1]=new t.Entity({position:e,label:new t.LabelGraphics({backgroundColor:t.Color.fromCssColorString(`#fff`),font:`12pt sans-serif`})}))}),o.splice(s.length,o.length-s.length-1),N(s).then(({count:e,stages:n})=>{n.forEach((e,n)=>{o[n+1].position=new t.CallbackPositionProperty(()=>t.Cartesian3.midpoint(s[n],s[n+1],new t.Cartesian3),!1),o[n+1].label.text=new t.CallbackProperty(()=>`${e.toFixed(2)} m`,!1)}),n.length>1?(o[o.length-1].position=new t.CallbackPositionProperty(()=>s[s.length-1],!1),o[o.length-1].label.text=new t.CallbackProperty(()=>`${e.toFixed(2)} m`,!1)):(o[o.length-1].position=void 0,o[o.length-1].label.text=void 0)}),{entities:o}}}),ce=new m({type:`Billboard`,complete:e=>e.positions.length>=1,skeletons:[E],initRender:()=>({entities:[new t.Entity({billboard:{image:`/favicon.svg`,width:32,height:32}})]}),render(e){let{mouse:n,packable:r}=e,i=e.previous.entities?.[0]??new t.Entity({billboard:{}}),a=r.positions?.[0]??n;return i.position=new t.CallbackPositionProperty(()=>a,!0),{entities:[i]}}}),le=new m({type:`BillboardPinBuilder`,complete:e=>e.positions.length>=1,skeletons:[E],initRender(){return{entities:[new t.Entity({billboard:{}})]}},render(e){let n=e.previous.entities[0],r=e.packable.positions[0]??e.mouse;return n.position=new t.CallbackPositionProperty(()=>r,!0),{entities:[n]}}}),ue=new m({type:`Cylinder`,complete:e=>e.positions.length>=2,skeletons:[E,C],initRender(){return{entities:[new t.Entity({cylinder:{}})]}},render(e){let r=e.previous.entities[0],i=[...e.packable.positions];if(i.length===0)return e.previous;if(i.length===1){let t=e.mouse;t&&i.push(t)}if(i.length<2)return e.previous;r.position=new t.ConstantPositionProperty(i[0]);let a=t.Cartesian3.distance(i[0],i[1]);return r.cylinder.bottomRadius=new t.CallbackProperty(()=>a,!1),(e.defining||!(0,n.toPropertyValue)(r.cylinder.length))&&(r.cylinder.length=(0,n.toProperty)(a*2)),{entities:[r]}}}),de=new m({type:`Ellipse`,complete:e=>e.positions.length>=2,skeletons:[E,C],initRender(){return{entities:[new t.Entity({ellipse:{}})]}},render(e){let n=e.previous.entities[0],r=[...e.packable.positions];if(r.length===0)return e.previous;if(r.length===1){let t=e.mouse;t&&r.push(t)}if(r.length<2)return e.previous;n.position=new t.ConstantPositionProperty(r[0]);let i=t.Cartesian3.distance(r[0],r[1]);return n.ellipse.semiMinorAxis=new t.CallbackProperty(()=>i||1,!1),n.ellipse.semiMajorAxis=n.ellipse.semiMinorAxis,{entities:[n]}}}),fe=new m({type:`Label`,complete:e=>e.positions.length>=1,skeletons:[E],initRender(){return{entities:[new t.Entity({label:{text:`Label`}})]}},render(e){let n=e.previous.entities[0],r=e.packable.positions[0]??e.mouse;return n.position=new t.CallbackPositionProperty(()=>r,!0),{entities:[n]}}}),pe=new m({type:`Point`,complete:e=>e.positions.length>=1,skeletons:[E],initRender(){return{entities:[new t.Entity({point:{pixelSize:10,color:t.Color.RED}})]}},render(e){let n=e.previous.entities[0],r=e.packable.positions[0]??e.mouse;return n.position=new t.CallbackPositionProperty(()=>r,!0),{entities:[n]}}}),P=new m({type:`Polygon`,allowManualComplete:e=>e.positions.length>=2,skeletons:[E,C,w],initRender:()=>({entities:[new t.Entity({polyline:{},polygon:{}})]}),render(e){let{mouse:n,packable:r}=e,i=e.previous.entities[0],a=[...r.positions??[]];return n&&a.push(n),a.length===2?(i.polygon.hierarchy=void 0,i.polyline.positions=new t.CallbackProperty(()=>a,!1)):a.length>=3?(i.polyline.positions=void 0,i.polygon.hierarchy=new t.CallbackProperty(()=>(a.push(a[0]),a.length>=3?new t.PolygonHierarchy([...a]):void 0),!1)):(i.polygon.hierarchy=void 0,i.polyline.positions=void 0),{entities:[i]}}}),F=100,I=Math.PI/2,L=1e-4,me=Math.PI*2;function R(e,t){return Math.hypot(e[0]-t[0],e[1]-t[1])}function z(e){let t=0;return e&&Array.isArray(e)&&e.length>0&&e.forEach((n,r)=>{r<e.length-1&&(t+=R(n,e[r+1]))}),t}let B=e=>z(e)**.99;function V(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}function he(e,t,n){let r=[(e[0]+t[0])/2,(e[1]+t[1])/2],i=[r[0]-e[1]+t[1],r[1]+e[0]-t[0]],a=[(e[0]+n[0])/2,(e[1]+n[1])/2],o=[a[0]-e[1]+n[1],a[1]+e[0]-n[0]];return ge(r,i,a,o)}function ge(e,t,n,r){if(e[1]===t[1]){let t=(r[0]-n[0])/(r[1]-n[1]),i=t*(e[1]-n[1])+n[0],a=e[1];return[i,a]}if(n[1]===r[1]){let r=(t[0]-e[0])/(t[1]-e[1]),i=r*(n[1]-e[1])+e[0],a=n[1];return[i,a]}let i=(t[0]-e[0])/(t[1]-e[1]),a=(r[0]-n[0])/(r[1]-n[1]),o=(i*e[1]-e[0]-a*n[1]+n[0])/(i-a),s=i*o-i*e[1]+e[0];return[s,o]}function H(e,t){let n=0,r=Math.asin(Math.abs(t[1]-e[1])/R(e,t));return t[1]>=e[1]&&t[0]>=e[0]?n=r+Math.PI:t[1]>=e[1]&&t[0]<e[0]?n=Math.PI*2-r:t[1]<e[1]&&t[0]<e[0]?n=r:t[1]<e[1]&&t[0]>=e[0]&&(n=Math.PI-r),n}function U(e,t,n){let r=H(t,e)-H(t,n);return r<0?r+Math.PI*2:r}function W(e,t,n){return(n[1]-e[1])*(t[0]-e[0])>(t[1]-e[1])*(n[0]-e[0])}function _e(e,t,n,r,i){e=Math.max(Math.min(e,1),0);let[a,o]=[1-e,e*e],s=o*e,c=a*a,l=c*a,u=l*t[0]+3*c*e*n[0]+3*a*o*r[0]+s*i[0],d=l*t[1]+3*c*e*n[1]+3*a*o*r[1]+s*i[1];return[u,d]}function G(e,t,n,r,i){let a=H(e,t),o=i?a+n:a-n,s=r*Math.cos(o),c=r*Math.sin(o);return[t[0]+s,t[1]+c]}function ve(e,t,n,r){let[i,a,o,s]=[0,0,[],r-n];s=s<0?s+Math.PI*2:s;for(let r=0;r<=100;r++){let c=n+s*r/100;i=e[0]+t*Math.cos(c),a=e[1]+t*Math.sin(c),o.push([i,a])}return o}function ye(e,t,n,r){let i=be(t,n,r),[a,o,s,c,l]=[[0,0],[0,0],0,0,0],u=Math.hypot(i[0],i[1]),d=i[0]/u,f=i[1]/u,p=R(t,n),m=R(n,r);return u>L?W(t,n,r)?(s=e*p,c=n[0]-s*f,l=n[1]+s*d,a=[c,l],s=e*m,c=n[0]+s*f,l=n[1]-s*d,o=[c,l]):(s=e*p,c=n[0]+s*f,l=n[1]-s*d,a=[c,l],s=e*m,c=n[0]-s*f,l=n[1]+s*d,o=[c,l]):(c=n[0]+e*(t[0]-n[0]),l=n[1]+e*(t[1]-n[1]),a=[c,l],c=n[0]+e*(r[0]-n[0]),l=n[1]+e*(r[1]-n[1]),o=[c,l]),[a,o]}function be(e,t,n){let r=e[0]-t[0],i=e[1]-t[1],a=Math.hypot(r,i);r/=a,i/=a;let o=n[0]-t[0],s=n[1]-t[1],c=Math.hypot(o,s);o/=c,s/=c;let l=r+o,u=i+s;return[l,u]}function K(e){if(e.length<=2)return e;let t=[],n=e.length-1;for(let r=0;r<=1;r+=.01){let[i,a]=[0,0];for(let t=0;t<=n;t++){let o=xe(n,t),s=r**t,c=(1-r)**(n-t);i+=o*s*c*e[t][0],a+=o*s*c*e[t][1]}t.push([i,a])}return t.push(e[n]),t}function q(e){let t=1;switch(!0){case e<=1:t=1;break;case e===2:t=2;break;case e===3:t=6;break;case e===24:t=24;break;case e===5:t=120;break;default:for(let n=1;n<=e;n++)t*=n;break}return t}function xe(e,t){return q(e)/(q(t)*q(e-t))}function J(e){if(e.length<=2)return e;let[t,n]=[2,[]],r=e.length-t-1;n.push(e[0]);for(let i=0;i<=r;i++)for(let r=0;r<=1;r+=.05){let[a,o]=[0,0];for(let n=0;n<=t;n++){let t=Se(n,r);a+=t*e[i+n][0],o+=t*e[i+n][1]}n.push([a,o])}return n.push(e.at(-1)),n}function Se(e,t){let n=0;return e===0?n=(t-1)**2/2:e===1?n=(-2*t**2+2*t+1)/2:e===2&&(n=t**2/2),n}function Ce(e){let t=e.length;if(t<=2)throw Error(`coords.length must >= 3`);{let[t,n,r,i,a]=[e[0],e[1],e[2],0,0],o=he(t,n,r),s=R(t,o),c=H(t,o),l=H(n,o);return W(t,n,r)?(i=l,a=c):(i=c,a=l),ve(o,s,i,a)}}function we(e,t={}){let n=e.length;if(n<3)throw Error(`coords.length must >= 3`);{let[n,r]=[e[0],e[1]];W(e[0],e[1],e[2])&&(n=e[1],r=e[0]);let i=V(n,r),a=[i].concat(e.slice(2)),o=Y(a,{tailLeft:n,tailRight:r,...t});if(o&&o.length>4){let[e,t]=[o[0],o[4]],i=R(n,r)/B(a),s=X(a,e,t,i),c=s.length,l=[n].concat(s.slice(0,c/2));l.push(e);let u=[r].concat(s.slice(c/2,c));return u.push(t),l=J(l),u=J(u),l.concat(o,u.reverse())}else return[]}}function Y(e,t){let{tailLeft:n,tailRight:r,headHeightFactor:i=.18,headWidthFactor:a=.3,neckHeightFactor:o=.85,neckWidthFactor:s=.15,headTailFactor:c=.8}=t,l=B(e),u=l*i,d=e.at(-1);l=R(d,e.at(-2));let f=0;n&&r&&(f=R(n,r)),u>f*c&&(u=f*c);let p=u*a,m=u*s;u=Math.min(u,l);let h=u*o,g=G(e.at(-2),d,0,u,!0),_=G(e.at(-2),d,0,h,!0),v=G(d,g,I,p,!1),y=G(d,g,I,p,!0),b=G(d,_,I,m,!1),x=G(d,_,I,m,!0);return[b,v,d,y,x]}function X(e,t,n,r){let i=z(e),a=B(e),o=a*r,s=R(t,n),c=(o-s)/2,l=0,u=[],d=[];for(let t=1;t<e.length-1;t++){let n=U(e[t-1],e[t],e[t+1])/2;l+=R(e[t-1],e[t]);let r=(o/2-l/i*c)/Math.sin(n),a=G(e[t-1],e[t],Math.PI-n,r,!0),s=G(e[t-1],e[t],n,r,!1);u.push(a),d.push(s)}return u.concat(d)}function Te(e,t={}){let{headHeightFactor:n=.18,headWidthFactor:r=.3,neckHeightFactor:i=.85,neckWidthFactor:a=.15,tailWidthFactor:o=.1,swallowTailFactor:s=1}=t,c=e.length;if(c<3)throw Error(`coords.length must >= 3`);let[l,u]=[e[0],e[1]];W(e[0],e[1],e[2])&&(l=e[1],u=e[0]);let d=V(l,u),f=[d].concat(e.slice(2)),p=Y(f,{tailLeft:l,tailRight:u,headHeightFactor:n,headWidthFactor:r,neckWidthFactor:a,neckHeightFactor:i});if(p&&p.length>4){let[e,t]=[p[0],p[4]],n=R(l,u),r=B(f),i=r*o*s,a=G(f[1],f[0],0,i,!0),c=n/r,d=X(f,e,t,c),m=d.length,h=[l].concat(d.slice(0,m/2));h.push(e);let g=[u].concat(d.slice(m/2,m));return g.push(t),h=J(h),g=J(g),h.concat(p,g.reverse(),[a,h[0]])}else return[]}function Ee(e){let t={headHeightFactor:.25,headWidthFactor:.3,neckHeightFactor:.85,neckWidthFactor:.15};if(e.length<3)throw Error(`coords.length must >= 3`);let[n,r,i]=e,a,o;e.length===3?(a=ke(n,r,i),o=V(n,r)):e.length===4?(a=e[3],o=V(n,r)):(a=e[3],o=e[4]);let s,c;W(n,r,i)?(s=Z(n,o,a,!1,t),c=Z(o,r,i,!0,t)):(s=Z(r,o,i,!1,t),c=Z(o,n,a,!0,t));let l=s.length,u=(l-5)/2,d=s.slice(0,u),f=s.slice(u,u+5),p=s.slice(u+5,l),m=c.slice(0,u),h=c.slice(u,u+5),g=c.slice(u+5,l);m=K(m);let _=K(g.concat(d.slice(1)));return p=K(p),m.concat(h,_,f,p)}function Z(e,t,n,r,i){let a=V(e,t),o=R(a,n),s=G(n,a,0,o*.3,!0),c=G(n,a,0,o*.5,!0);s=G(a,s,I,o/5,r),c=G(a,c,I,o/4,r);let l=[a,s,c,n],u=De(l,i);if(u&&Array.isArray(u)&&u.length>0){let[n,r]=[u[0],u[4]],i=R(e,t)/B(l)/2,a=Oe(l,n,r,i),o=a.length,s=a.slice(0,o/2),c=a.slice(o/2,o);return s.push(n),c.push(r),s=s.reverse(),s.push(t),c=c.reverse(),c.push(e),s.reverse().concat(u,c)}else throw Error(`插值出错`)}function De(e,t){let{headHeightFactor:n,headWidthFactor:r,neckWidthFactor:i,neckHeightFactor:a}=t,o=B(e),s=o*n,c=e.at(-1),l=s*r,u=s*i,d=s*a,f=G(e.at(-2),c,0,s,!0),p=G(e.at(-2),c,0,d,!0),m=G(c,f,I,l,!1),h=G(c,f,I,l,!0),g=G(c,p,I,u,!1),_=G(c,p,I,u,!0);return[g,m,c,h,_]}function Oe(e,t,n,r){let i=z(e),a=B(e),o=a*r,s=R(t,n),c=(o-s)/2,l=0,u=[],d=[];for(let t=1;t<e.length-1;t++){let n=U(e[t-1],e[t],e[t+1])/2;l+=R(e[t-1],e[t]);let r=(o/2-l/i*c)/Math.sin(n),a=G(e[t-1],e[t],Math.PI-n,r,!0),s=G(e[t-1],e[t],n,r,!1);u.push(a),d.push(s)}return u.concat(d)}function ke(e,t,n){let r=V(e,t),i=R(r,n),a=U(e,r,n);if(a<I){let t=i*Math.sin(a),n=i*Math.cos(a),o=G(e,r,I,t,!1);return G(r,o,I,n,!0)}else if(a>=I&&a<Math.PI){let t=i*Math.sin(Math.PI-a),n=i*Math.cos(Math.PI-a),o=G(e,r,I,t,!1);return G(r,o,I,n,!1)}else if(a>=Math.PI&&a<Math.PI*1.5){let t=i*Math.sin(a-Math.PI),n=i*Math.cos(a-Math.PI),o=G(e,r,I,t,!0);return G(r,o,I,n,!0)}else{let t=i*Math.sin(Math.PI*2-a),n=i*Math.cos(Math.PI*2-a),o=G(e,r,I,t,!0);return G(r,o,I,n,!1)}}function Q(e,t={}){let{tailWidthFactor:n=.1,neckWidthFactor:r=.2,headWidthFactor:i=.25,headAngle:a=Math.PI/8.5,neckAngle:o=Math.PI/13}=t,s=e.length;if(s<2)throw Error(`coords.length must >= 2`);let[c,l]=[e[0],e[1]],u=B(e),d=u*n,f=u*r,p=u*i,m=G(l,c,I,d,!0),h=G(l,c,I,d,!1),g=G(c,l,a,p,!1),_=G(c,l,a,p,!0),v=G(c,l,o,f,!1),y=G(c,l,o,f,!0),b=[m,v,g,l,_,y,h];return b}function Ae(e){let t=.05,n=.1,r=.15,i=Math.PI/4,a=Math.PI*.17741;return Q(e,{tailWidthFactor:t,neckWidthFactor:n,headWidthFactor:r,headAngle:i,neckAngle:a})}function je(e,t={}){let{headHeightFactor:n=.18,headWidthFactor:r=.3,neckHeightFactor:i=.85,neckWidthFactor:a=.15,tailWidthFactor:o=.1}=t,s=e.length;if(s<2)throw Error(`coords.length must >= 2`);{let t=B(e),s=t*o,c=G(e[1],e[0],I,s,!1),l=G(e[1],e[0],I,s,!0),u=Y(e,{tailLeft:c,tailRight:l,headHeightFactor:n,headWidthFactor:r,neckWidthFactor:a,neckHeightFactor:i});if(u&&u.length>4){let t=u[0],n=u[4],r=X(e,t,n,o),i=r.length,a=[c].concat(r.slice(0,i/2));a.push(t);let s=[l].concat(r.slice(i/2,i));return s.push(n),a=J(a),s=J(s),a.concat(u,s.reverse())}else return[]}}function Me(e,t={}){let{headHeightFactor:n=.18,headWidthFactor:r=.3,neckHeightFactor:i=.85,neckWidthFactor:a=.15,tailWidthFactor:o=.1,swallowTailFactor:s=1}=t,c=e.length;if(c<2)throw Error(`coords.length must >= 2`);let l=B(e),u=l*o,d=G(e[1],e[0],I,u,!1),f=G(e[1],e[0],I,u,!0),p=u*s,m=G(e[1],e[0],0,p,!0),h=[d,m,f],g=Y(e,{tailLeft:h[0],tailRight:h[2],headHeightFactor:n,headWidthFactor:r,neckWidthFactor:a,neckHeightFactor:i});if(g&&g.length>4){let t=g[0],n=g[4],r=X(e,t,n,o),i=r.length,a=[h[0]].concat(r.slice(0,i/2));a.push(t);let s=[h[2]].concat(r.slice(i/2,i));return s.push(n),a=J(a),s=J(s),a.concat(g,s.reverse(),[h[1],a[0]])}return[]}function Ne(e){if(e.length<3)throw Error(`coords.length must >= 3`);let t=.4,n=V(e[0],e[2]);e.push(n,e[0],e[1]);let r=[],i=[];for(let n=0;n<e.length-2;n++){let i=e[n],a=e[n+1],o=e[n+2],s=ye(t,i,a,o);r=r.concat(s)}let a=r.length;r=[r[a-1]].concat(r.slice(0,a-1));for(let t=0;t<e.length-2;t++){let n=e[t],a=e[t+1];i.push(n);for(let e=0;e<=F;e++){let o=_e(e/F,n,r[t*2],r[t*2+1],a);i.push(o)}i.push(a)}return i}function Pe(e){let t=e.length;if(t<2)throw Error(`coords.length must >= 2`);return Fe(e)}function Fe(e){let t=[];if(e.length>1){let n=e[0],r=e.at(-1),i=n,a=[(r[0]-n[0])/4+n[0],(r[1]-n[1])/8+n[1]],o=[(n[0]+r[0])/2,n[1]],s=[(r[0]-n[0])*3/4+n[0],-(r[1]-n[1])/8+n[1]],c=[r[0],n[1]],l=[r[0],(n[1]+r[1])/2],u=[(r[0]-n[0])*3/4+n[0],(r[1]-n[1])*3/8+n[1]],d=[(n[0]+r[0])/2,(n[1]+r[1])/2],f=[(r[0]-n[0])/4+n[0],(r[1]-n[1])*5/8+n[1]],p=[n[0],(n[1]+r[1])/2],m=[n[0],r[1]],h=K([i,a,o,s,c]),g=K([l,u,d,f,p]);t=h.concat(g),t.push(m)}return t}function Ie(e){if(e.length<2)throw Error(`coords.length must >= 2`);let[t,n]=e,r=[n[0],t[1]],i=[n[0],(t[1]+n[1])/2],a=[t[0],(t[1]+n[1])/2],o=[t[0],n[1]];return[t,r,i,a,o]}function Le(e){let t=e.length;if(t<2)throw Error(`coords.length must >= 2`);let[n,r]=e,i=[r[0],(n[1]+r[1])/2],a=[n[0],(n[1]+r[1])/2],o=[n[0],r[1]];return[n,i,a,o]}let Re=new m({type:`PolygonArc`,complete:e=>e.positions.length>=3,skeletons:[E,C],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;i.length<3&&e.mouse&&i.push(e.mouse.clone());let a=i.map(e=>(0,n.toCoord)(e));if(a.length<3)return r.polygon.hierarchy=void 0,e.previous;let o=Ce(a).map(e=>(0,n.toCartesian3)(e)),s=new t.PolygonHierarchy(o);return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),ze=new m({type:`PolygonArrowAttackDirection`,allowManualComplete:e=>e.positions.length>=3,skeletons:[E,C,T],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;e.mouse&&i.push(e.mouse.clone());let a=i.map(e=>(0,n.toCoord)(e));if(a.length<3)return r.polygon.hierarchy=void 0,e.previous;let o=we(a).map(e=>(0,n.toCartesian3)(e)),s=new t.PolygonHierarchy(o);return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),Be=new m({type:`PolygonArrowAttackDirectionTailed`,allowManualComplete:e=>e.positions.length>=3,skeletons:[E,C,T],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;e.mouse&&i.push(e.mouse.clone());let a=i.map(e=>(0,n.toCoord)(e));if(a.length<3)return r.polygon.hierarchy=void 0,e.previous;let o=Te(a).map(e=>(0,n.toCartesian3)(e)),s=new t.PolygonHierarchy(o);return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),Ve=new m({type:`PolygonArrowClamped`,complete:e=>e.positions.length>=5,skeletons:[E,C],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;if(i.length<5){let t=e.mouse;t&&i.push(t.clone())}let a=i.map(e=>(0,n.toCoord)(e));if(a.length>=3){let e=Ee(a),i=new t.PolygonHierarchy(e.map(e=>(0,n.toCartesian3)(e)));r.polygon.hierarchy=new t.CallbackProperty(()=>i,!1)}else r.polygon.hierarchy=void 0;return{entities:[r]}}}),He=new m({type:`PolygonArrowStraight`,complete:e=>e.positions.length>=2,skeletons:[E,C],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;if(i.length<2){let t=e.mouse;t&&i.push(t.clone())}let a=i.map(e=>(0,n.toCoord)(e));if(a.length>=2){let e=Ae(a),i=new t.PolygonHierarchy(e.map(e=>(0,n.toCartesian3)(e)));r.polygon.hierarchy=new t.CallbackProperty(()=>i,!1)}else r.polygon.hierarchy=void 0;return{entities:[r]}}}),Ue=new m({type:`PolygonArrowStraightSharp`,complete:e=>e.positions.length>=2,skeletons:[E,C],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;if(i.length<2){let t=e.mouse;t&&i.push(t.clone())}let a=i.map(e=>(0,n.toCoord)(e));if(a.length>=2){let e=Q(a),i=new t.PolygonHierarchy(e.map(e=>(0,n.toCartesian3)(e)));r.polygon.hierarchy=new t.CallbackProperty(()=>i,!1)}else r.polygon.hierarchy=void 0;return{entities:[r]}}}),We=new m({type:`PolygonArrowUnitCombatOperation`,allowManualComplete:e=>e.positions.length>=2,skeletons:[E,C,T],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;e.mouse&&i.push(e.mouse.clone());let a=i.map(e=>(0,n.toCoord)(e));if(a.length<2)return r.polygon.hierarchy=void 0,e.previous;let o=je(a).map(e=>(0,n.toCartesian3)(e)),s=new t.PolygonHierarchy(o);return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),$=new m({type:`PolygonArrowUnitCombatOperationTailed`,allowManualComplete:e=>e.positions.length>=2,skeletons:[E,C,w],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;e.mouse&&i.push(e.mouse.clone());let a=i.map(e=>(0,n.toCoord)(e));if(a.length<2)return r.polygon.hierarchy=void 0,e.previous;let o=Me(a).map(e=>(0,n.toCartesian3)(e)),s=new t.PolygonHierarchy(o);return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),Ge=new m({type:`PolygonAssemblingPlace`,complete:e=>e.positions.length>=3,skeletons:[E,C,w],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;e.mouse&&i.push(e.mouse.clone());let a=i.map(e=>(0,n.toCoord)(e));if(a.length<2)return r.polygon.hierarchy=void 0,e.previous;let o=Ne(a).map(e=>(0,n.toCartesian3)(e)),s=new t.PolygonHierarchy(o);return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),Ke=new m({type:`PolygonFlagCurve`,complete:e=>e.positions.length>=2,skeletons:[E,C],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;e.mouse&&i.push(e.mouse.clone());let a=i.map(e=>(0,n.toCoord)(e));if(a.length<2)return r.polygon.hierarchy=void 0,e.previous;let o=Pe(a).map(e=>(0,n.toCartesian3)(e)),s=new t.PolygonHierarchy(o);return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),qe=new m({type:`PolygonFlagRect`,complete:e=>e.positions.length>=2,skeletons:[E,C],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;e.mouse&&i.push(e.mouse.clone());let a=i.map(e=>(0,n.toCoord)(e));if(a.length<2)return r.polygon.hierarchy=void 0,e.previous;let o=Ie(a).map(e=>(0,n.toCartesian3)(e)),s=new t.PolygonHierarchy(o);return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),Je=new m({type:`PolygonFlagTriangle`,complete:e=>e.positions.length>=2,skeletons:[E,C],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;e.mouse&&i.push(e.mouse.clone());let a=i.map(e=>(0,n.toCoord)(e));if(a.length<2)return r.polygon.hierarchy=void 0,e.previous;let o=Le(a).map(e=>(0,n.toCartesian3)(e)),s=new t.PolygonHierarchy(o);return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),Ye=new m({type:`PolygonSmooth`,allowManualComplete:e=>e.positions.length>=3,skeletons:[E,C,T],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions,o=e.mouse;if(o&&i.push(o.clone()),i.length<=2)return r.polygon.hierarchy=void 0,e.previous;let s=i.map(e=>(0,n.toCoord)(e));s.push(s[0]);let{features:c}=a.polygonSmooth(a.polygon([s]),{iterations:3}),l=c[0].geometry.coordinates[0].map(e=>(0,n.toCartesian3)(e)).filter(e=>!!e),u=new t.PolygonHierarchy(l);return r.polygon.hierarchy=new t.CallbackProperty(()=>u,!1),{entities:[r]}}}),Xe=new m({type:`Polyline`,allowManualComplete:e=>e.positions.length>1,skeletons:[E,C,T],initRender(){return{entities:[new t.Entity({polyline:{material:t.Color.RED,width:2}})]}},render(e){let n=e.previous.entities[0],r=[...e.packable.positions],i=e.mouse;i&&r.push(i.clone());let a=r.length>=2?r:[];return n.polyline.positions=new t.CallbackProperty(()=>a,!1),{entities:[n]}}}),Ze=new m({type:`PolylineCurve`,allowManualComplete:e=>e.positions.length>1,skeletons:[E,C,T],initRender(){return{entities:[new t.Entity({polyline:{material:t.Color.RED,width:2}})]}},render(e){let r=e.previous.entities[0],i=[...e.packable.positions],o=e.mouse;if(o&&i.push(o.clone()),i.length<2)return r.polyline.positions=void 0,e.previous;let s=i.map(e=>(0,n.toCoord)(e)),{geometry:{coordinates:c}}=a.bezierSpline(a.lineString(s));return r.polyline.positions=new t.CallbackProperty(()=>c.map(n.toCartesian3),!1),{entities:[r]}}}),Qe=new m({type:`Rectangle`,complete:e=>e.positions.length>=2,skeletons:[E,C],initRender(){return{entities:[new t.Entity({rectangle:{}})]}},render(e){let n=e.previous.entities[0],r=[...e.packable.positions],i=e.mouse;if(i&&r.push(i.clone()),r.length<2)return n.rectangle.coordinates=void 0,e.previous;let a=t.Rectangle.fromCartesianArray(r??[]);return n.rectangle.coordinates=new t.CallbackProperty(()=>a,!1),{entities:[n]}}});exports.PlotAction=y,exports.PlotFeature=v,exports.PlotScheme=m,exports.PlotSchemeBillboard=ce,exports.PlotSchemeBillboardPinBuilder=le,exports.PlotSchemeCylinder=ue,exports.PlotSchemeEllipse=de,exports.PlotSchemeLabel=fe,exports.PlotSchemePoint=pe,exports.PlotSchemePolygon=P,exports.PlotSchemePolygonArc=Re,exports.PlotSchemePolygonArrowAttackDirection=ze,exports.PlotSchemePolygonArrowAttackDirectionTailed=Be,exports.PlotSchemePolygonArrowClamped=Ve,exports.PlotSchemePolygonArrowStraight=He,exports.PlotSchemePolygonArrowStraightSharp=Ue,exports.PlotSchemePolygonArrowUnitCombatOperation=We,exports.PlotSchemePolygonArrowUnitCombatOperationTailed=$,exports.PlotSchemePolygonAssemblingPlace=Ge,exports.PlotSchemePolygonFlagCurve=Ke,exports.PlotSchemePolygonFlagRect=qe,exports.PlotSchemePolygonFlagTriangle=Je,exports.PlotSchemePolygonSmooth=Ye,exports.PlotSchemePolyline=Xe,exports.PlotSchemePolylineCurve=Ze,exports.PlotSchemeRectangle=Qe,exports.PlotSkeletonEntity=b,exports.SampledPlotProperty=_,exports.SampledPlotStrategy=h,exports.control=C,exports.interval=w,exports.intervalNonclosed=T,exports.moved=E,exports.schemeMeasureArea=oe,exports.schemeMeasureDistance=se,exports.usePlot=S})(this.Vesium=this.Vesium||{},Cesium,Vesium,VueUse,Vue,turf);
2
+ //# sourceMappingURL=index.iife.min.js.map