@vesium/plot 1.0.1-beta.48 → 1.0.1-beta.49

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(y,n,f,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,C=(i,e,t)=>z(i,typeof e!="symbol"?e+"":e,t);const x=class R{constructor(e){C(this,"type"),C(this,"complete"),C(this,"forceComplete"),C(this,"definingCursor"),C(this,"skeletons"),C(this,"initEntites"),C(this,"initPrimitives"),C(this,"initGroundPrimitives"),C(this,"render");var t;this.type=e.type,this.complete=e.complete,this.forceComplete=e.forceComplete,this.definingCursor=e.definingCursor??"crosshair",this.skeletons=((t=e.skeletons)==null?void 0:t.map(r=>r()))??[],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){f.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)}};C(x,"_record",new Map);let D=x;var Y=(i=>(i[i.NEAR=0]="NEAR",i[i.CYCLE=1]="CYCLE",i[i.STRICT=2]="STRICT",i))(Y||{});const $=(i,e,t,r)=>{var o,s,d;return r===0?{time:i,positions:(o=e.positions)==null?void 0:o.map(a=>a.clone()),derivative:e.derivative}:r===1?{time:i,positions:(s=t.positions)==null?void 0:s.map(a=>a.clone()),derivative:e.derivative}:{time:i,positions:(d=t.positions)==null?void 0:d.map((a,v)=>{var p;const E=(p=e.positions)==null?void 0:p[v];return E?n.Cartesian3.lerp(E,a,r,new n.Cartesian3):a}),derivative:e.derivative}},J=class j{constructor(e){C(this,"strategy"),C(this,"interpolationAlgorithm"),C(this,"_times",[]),C(this,"_sampleds",[]),C(this,"_derivatives",[]),C(this,"_definitionChanged",new n.Event);var t;this.interpolationAlgorithm=e?.interpolationAlgorithm,this.strategy=e?.strategy??0,(t=e?.packables)==null||t.forEach(r=>this.setSample(r)),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],r=this._times[this._times.length-1];if(n.JulianDate.lessThan(e,t)||n.JulianDate.greaterThan(e,r))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,u=new Date(p+c);e=n.JulianDate.fromDate(u);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(),a=n.JulianDate.toDate(this._times[s]).getTime(),v=n.JulianDate.toDate(e).getTime();return{prevIndex:o,nextIndex:s,proportion:(v-d)/(a-d)||0}}getValue(e,t){var r;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=(r=this._sampleds[0])==null?void 0:r.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:a}=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]},E=(this.interpolationAlgorithm||j.defaultInterpolationAlgorithm)(e,v,p,a);return Object.assign(t,E),t}setSample(e){var t,r;const o=((t=e.time)==null?void 0:t.clone())??this._times[0].clone(),s=((r=e.positions)==null?void 0:r.map(v=>v.clone()))??[],d=e.derivative,a=this._times.findIndex(v=>n.JulianDate.equals(o,v));a!==-1?(this._times[a]=o,this._sampleds[a]=s,this._derivatives[a]=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(r=>r.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 r=this._times[t];n.TimeInterval.contains(e,r)&&this.removeSample(r)}}equals(e){return e===this}};C(J,"defaultInterpolationAlgorithm",$);let F=J;class I{constructor(e){C(this,"_id"),C(this,"_scheme"),C(this,"_definitionChanged"),C(this,"_defining"),C(this,"_disabled"),C(this,"_sampled"),C(this,"_entities"),C(this,"_primitives"),C(this,"_groundPrimitives"),C(this,"_skeletons");var t,r,o,s,d,a;const{id:v,disabled:p=!1,sampled:E}=e;this._id=v||n.createGuid(),this._scheme=D.resolve(e.scheme),this._definitionChanged=new n.Event,this._defining=!0,this._disabled=p,this._sampled=E instanceof F?E:new F(E),this._sampled.definitionChanged.addEventListener(g=>this._definitionChanged.raiseEvent(this,"sampled",g,g),this),this._entities=[...((r=(t=this._scheme).initEntites)==null?void 0:r.call(t))??[]],this._primitives=[...((s=(o=this._scheme).initPrimitives)==null?void 0:s.call(o))??[]],this._groundPrimitives=[...((a=(d=this._scheme).initGroundPrimitives)==null?void 0:a.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}}class Q{constructor(e={}){C(this,"_id"),C(this,"_isDestroyed");const{id:t}=e;this._id=t||n.createGuid(),this._isDestroyed=!1}get id(){return this._id}get collectionChanged(){return this._collectionChanged}get values(){return Array.from(this._values)}add(e){if(this._isDestroyed)throw new Error("PlotFeatureCollection is isDestroyed");return this._values.has(e)?!1:!!this._values.add(e)}remove(e){return this._values.delete(e)}get entities(){return this._dataSource.entities}get primitives(){return this._primitives}get groundPrimitives(){return this._groundPrimitives}get skeletons(){return this._skeletonDataSource.entities}isDestroyed(){return this._isDestroyed}destroy(){this._isDestroyed||(this._viewer.dataSources.remove(this._dataSource),this._viewer.dataSources.remove(this._skeletonDataSource),this._viewer.scene.primitives.remove(this._primitives),this._viewer.scene.groundPrimitives.remove(this._groundPrimitives),this._viewer.dataSources.remove(this._skeletonDataSource),this._isDestroyed=!0)}}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 X(i,e,t){const r=f.useViewer(),o=f.usePrimitive(new n.PrimitiveCollection),s=f.usePrimitive(new n.PrimitiveCollection,{collection:"ground"}),d=f.useDataSource(new n.CustomDataSource),a=f.useEntityScope({collection:()=>d.value.entities}),v=f.usePrimitiveScope({collection:()=>o.value}),p=f.usePrimitiveScope({collection:()=>s.value}),E=w.shallowRef();f.useScreenSpaceEventHandler(n.ScreenSpaceEventType.MOUSE_MOVE,l=>{E.value=f.canvasCoordToCartesian(l?.endPosition,r.value.scene)}),L.watchArray(i,(l,c,u,h=[])=>{h.forEach(m=>{a.removeWhere(_=>m.entities.includes(_)),v.removeWhere(_=>m.primitives.includes(_)),p.removeWhere(_=>m.groundPrimitives.includes(_))}),u.forEach(m=>{m.entities.forEach(_=>a.add(_)),m.primitives.forEach(_=>v.add(_)),m.groundPrimitives.forEach(_=>p.add(_))})},{immediate:!0,flush:"post"}),f.useCesiumEventListener(()=>i.value.map(l=>l.definitionChanged),(l,c,u,h)=>{if(c==="entities"){const{added:m,removed:_}=f.arrayDiff(u,h);m.forEach(P=>a.add(P)),_.forEach(P=>a.remove(P))}else if(c==="primitives"){const{added:m,removed:_}=f.arrayDiff(u,h);m.forEach(P=>v.add(P)),_.forEach(P=>v.remove(P))}else if(c==="groundPrimitives"){const{added:m,removed:_}=f.arrayDiff(u,h);m.forEach(P=>p.add(P)),_.forEach(P=>p.remove(P))}});const g=async l=>{var c,u;const h=await((u=(c=l.scheme).render)==null?void 0:u.call(c,{packable:l.sampled.getValue(t()),mouse:l.defining?E.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)}),f.useCesiumEventListener(()=>i.value.map(l=>l.definitionChanged),(l,c)=>{["disabled","defining","scheme","sampled","time"].includes(c)&&g(l)}),w.watch(E,()=>{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(a.scope))}}function Z(i,e){const t=f.useViewer(),r=w.ref(!1),o=w.computed(()=>{var a;return(a=i.value)==null?void 0:a.sampled.getValue(e())});f.useScreenSpaceEventHandler(n.ScreenSpaceEventType.LEFT_CLICK,async a=>{var v,p;if(await L.promiseTimeout(1),!i.value||!o.value||r.value)return;const{scheme:E,defining:g,sampled:l}=i.value;if(!g)return;const c=f.canvasCoordToCartesian(a.position,t.value.scene);if(!c)return;(v=o.value).positions??(v.positions=[]),o.value.positions.push(c),l.setSample(o.value),((p=E.complete)==null?void 0:p.call(E,o.value))&&I.setDefining(i.value,!1)}),f.useScreenSpaceEventHandler(n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,async a=>{var v;if(!i.value||!o.value)return;r.value=!0,await L.promiseTimeout(2),r.value=!1;const{scheme:p,defining:E}=i.value;if(!E||!f.canvasCoordToCartesian(a.position,t.value.scene))return;((v=p.forceComplete)==null?void 0:v.call(p,o.value))&&I.setDefining(i.value,!1)}),f.useScreenSpaceEventHandler(n.ScreenSpaceEventType.RIGHT_CLICK,async()=>{var a;if(!i.value||!o.value)return;const{defining:v,sampled:p}=i.value;v&&((a=o.value).positions??(a.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 a,v;if(!((a=i.value)!=null&&a.defining))s.value&&(s.value=void 0,t.value.container.parentElement.style.removeProperty("cursor"));else{const p=i.value.scheme.definingCursor;s.value=f.isFunction(p)?p(o.value):p,s.value&&((v=t.value)==null||v.container.parentElement.style.setProperty("cursor",s.value))}};f.useCesiumEventListener(()=>{var a;return(a=i.value)==null?void 0:a.definitionChanged},(a,v)=>{(v==="defining"||v==="sampled")&&d()}),w.watch(i,()=>d())}function ee(i,e,t){const r=f.useViewer(),o=f.useDataSource(new n.CustomDataSource),s=f.useEntityScope({collection:()=>o.value.entities}),d=w.shallowRef(),a=w.shallowRef(),v=g=>{var l,c;return g?((l=a.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,u=[];if(l||g.disabled)g.skeletons=[];else{const h=g.sampled.getValue(t()),m=g.defining,_=e.value===g;g.scheme.skeletons.forEach(S=>{var A;if(f.isFunction(S.disabled)?S.disabled({active:_,defining:m}):S.disabled)return;const M=((A=S.format)==null?void 0:A.call(S,h))??h?.positions??[];M.forEach((pe,G)=>{var K;let T=c.find(O=>O.index===G&&O.skeleton===S);const ue=(K=S.render)==null?void 0:K.call(S,{defining:m,active:_,index:G,packable:h,positions:M,position:pe,action:v(T)}),W=new V(ue??{});T?W.propertyNames.forEach(O=>{O!=="id"&&(T[O]=W[O])}):T=W,T.plot=g,T.skeleton=S,T.index=G,u.push(T)})})}g.skeletons=u},{addGraphicEvent:E}=f.useGraphicEvent();return w.watchEffect(g=>{const l=E("global","DRAG",({event:c,pick:u,dragging:h,lockCamera:m})=>{var _;if(u.id instanceof V&&s.scope.has(u.id)){const P=u.id,S=P.plot;if(S.defining)return;a.value=P;const A=P.skeleton,B=P.index,M=S.sampled.getValue(t());(_=A.onDrag)==null||_.call(A,{viewer:r.value,sampled:S.sampled,packable:M,active:e.value===S,index:B,event:c,dragging:h,lockCamera:m})}else a.value=void 0},{cursor:({pick:c})=>{var u;if(!((u=e.value)!=null&&u.defining)&&s.scope.has(c.id)){const h=c.id.skeleton;return f.isFunction(h?.cursor)?h.cursor(c):w.toValue(h?.cursor)}},dragCursor:({pick:c})=>{var u;if(!((u=e.value)!=null&&u.defining)&&s.scope.has(c.id)){const h=c.id.skeleton;return f.isFunction(h?.dragCursor)?h.dragCursor(c):w.toValue(h?.dragCursor)}}});g(l)}),L.onKeyStroke(g=>{var l;if(a.value){const c=a.value,u=c.plot,h=c.skeleton,m=c.index,_=u.sampled.getValue(t());(l=h.onKeyPressed)==null||l.call(h,{viewer:r.value,sampled:u.sampled,packable:_,index:m,keyEvent:g})}}),w.watchEffect(g=>{const l=E("global","HOVER",({hovering:c,pick:u})=>{if(c&&u.id instanceof V&&s.scope.has(u.id)){const h=u.id;d.value=h}else d.value=void 0});g(l)}),w.watchEffect(g=>{const l=E("global","LEFT_CLICK",({event:c,pick:u})=>{var h;if(u.id instanceof V&&s.scope.has(u.id)){const m=u.id;a.value=m;const _=m.plot,P=m.skeleton,S=m.index,A=_.sampled.getValue(t());(h=P.onLeftClick)==null||h.call(P,{viewer:r.value,sampled:_.sampled,packable:A,active:e.value===_,defining:_.defining,index:S,event:c})}else a.value=void 0});g(l)}),L.watchArray(i,(g,l,c,u=[])=>{c.forEach(h=>p(h)),u.forEach(h=>p(h,!0))}),f.useCesiumEventListener(()=>i.value.map(g=>g.definitionChanged),(g,l,c,u)=>{if(["disabled","defining","scheme","sampled","time"].includes(l))w.nextTick(()=>p(g));else if(l==="skeletons"){const{added:h,removed:m}=f.arrayDiff(c,u);h.forEach(_=>s.add(_)),m.forEach(_=>s.remove(_))}}),w.watch(e,(g,l)=>{g&&p(g),l&&p(l)}),{dataSource:o}}function te(i){const e=i?.time||w.shallowRef(),t=f.useViewer(),r=()=>{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(),a=w.shallowRef();f.useCesiumEventListener([()=>{var l;return(l=d.value)==null?void 0:l.sampled.definitionChanged}],()=>{var l;a.value=(l=d.value)==null?void 0:l.sampled.getValue(r())}),Z(d,r),X(s,d,r),ee(s,d,r),f.useScreenSpaceEventHandler(n.ScreenSpaceEventType.LEFT_CLICK,l=>{var c,u,h;if((c=d.value)!=null&&c.defining)return;const m=(u=t.value)==null?void 0:u.scene.pick(l.position.clone());if(!(((h=m?.id)==null?void 0:h.plot)instanceof I)){if(!m){d.value=void 0;return}d.value=s.value.find(_=>f.pickHitGraphic(m,[..._.entities,..._.primitives,..._.groundPrimitives]))}});let v,p;return w.watch(d,(l,c)=>{var u,h;if(c&&c.defining){const m=c.sampled.getValue(r());((h=(u=c.scheme).forceComplete)==null?void 0:h.call(u,m))?(I.setDefining(c,!1),v?.(c)):o.delete(c)}}),{plots:s,time:e,operate:async l=>new Promise((c,u)=>{v=c,p=u;const h=l instanceof I?l:new I(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 N(){return{disabled:({active:i})=>!i,cursor:"pointer",dragCursor:"crosshair",onDrag({viewer:i,sampled:e,packable:t,event:r,index:o,lockCamera:s}){s();const d=f.canvasCoordToCartesian(r.endPosition,i.scene);if(d){const a=[...t.positions??[]];a[o]=d,e.setSample({time:t.time,derivative:t.derivative,positions:a})}},onKeyPressed({viewer:i,keyEvent:e,sampled:t,packable:r,index:o}){var s;const d=(s=f.toCartographic(i.camera.position))==null?void 0:s.height;if(!d||!["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"].includes(e.key))return;e.preventDefault();let a=0;switch(e.key){case"ArrowRight":a=Math.PI/2;break;case"ArrowDown":a=Math.PI;break;case"ArrowLeft":a=-Math.PI/2;break;case"ArrowUp":a=0;break}const v=(i.camera.heading+a)%(2*Math.PI),p=[...r.positions??[]],E=f.toCartographic(p[o]),l=d/1e5*Math.PI/180/1e3;E.latitude+=l*Math.cos(v),E.longitude+=l*Math.sin(v),p[o]=f.toCartesian3(E),t.setSample({time:r.time,derivative:r.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 H(){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((r,o)=>{const s=o===t.length-1?t[0]:t[o+1];return n.Cartesian3.midpoint(r,s,new n.Cartesian3)})},onDrag({viewer:e,sampled:t,packable:r,event:o,index:s,lockCamera:d,dragging:a}){d();const v=f.canvasCoordToCartesian(o.endPosition,e.scene);if(!v)return;const p=[...r.positions??[]];i===-1?(i=s,p.splice(s+1,0,v)):p[i+1]=v,a||(i=-1),t.setSample({time:r.time,derivative:r.derivative,positions:p})},render:({position:e,action:t,active:r})=>{if(!r)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 r=[];for(let o=0;o<t.length-1;o++)r.push(n.Cartesian3.midpoint(t[o],t[o+1],new n.Cartesian3));return r},onDrag({viewer:e,sampled:t,packable:r,event:o,index:s,lockCamera:d,dragging:a}){d();const v=f.canvasCoordToCartesian(o.endPosition,e.scene);if(!v)return;const p=[...r.positions??[]];i===-1?(i=s,p.splice(s+1,0,v)):p[i+1]=v,a||(i=-1),t.setSample({time:r.time,derivative:r.derivative,positions:p})},render:({position:e,action:t})=>{const r={[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:r[t],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:n.Color.WHITE.withAlpha(.4)}}}}}const ie=`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[f.toCartesian3(t)]}},onDrag({viewer:i,sampled:e,packable:t,event:r,lockCamera:o,dragging:s}){s&&o();const d=f.canvasCoordToCartesian(r.startPosition,i.scene),a=f.canvasCoordToCartesian(r.endPosition,i.scene);if(!d||!a)return;const v=n.Cartesian3.subtract(a,d,new n.Cartesian3),p=[...t.positions??[]];e.setSample({time:t.time,derivative:t.derivative,positions:p.map(E=>n.Cartesian3.add(E,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:ie,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 ne(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,r=e.indices,o=[];for(let s=0;s<r.length;s+=3){const d=n.Cartesian3.unpack(t,r[s]*3,new n.Cartesian3),a=n.Cartesian3.unpack(t,r[s+1]*3,new n.Cartesian3),v=n.Cartesian3.unpack(t,r[s+2]*3,new n.Cartesian3);o.push([d,a,v])}return o}function oe(i,e,t){const r=n.Cartesian3.subtract(i,e,new n.Cartesian3),o=n.Cartesian3.subtract(t,e,new n.Cartesian3),s=n.Cartesian3.cross(r,o,r);return n.Cartesian3.magnitude(s)*.5}function se(i){const t=n.ClassificationType.BOTH,r=Math.floor(10);return{scene:i?.scene,clampToGround:!1,classificationType:t,terrainProvider:i?.terrainProvider,density:r}}async function re(i,e){if(i.length<2)throw new Error("positions.length must >= 2");const{density:t}=se(e);if(t<=0)throw new Error("options.density must > 0");return ne(i).reduce((o,s)=>o+=oe(...s),0)}const ae=new D({type:"measureArea",forceComplete:i=>i.positions.length>=3,skeletons:[N,H],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:r}=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=[...r.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(f.toCartesian3(n.Rectangle.center(n.Rectangle.fromCartesianArray(s)))),o.label.text=new n.ConstantProperty(""),re(s).then(d=>{let a="";d/1e3/1e3>10?a=`${(d/1e3/1e3).toFixed(2)}km\xB2`:a=`${(+d).toFixed(2)}m\xB2`,o.label.text=new n.ConstantProperty(a)}),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]}}}),le=new D({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:r,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])??r;return s.position=new n.CallbackPositionProperty(()=>d,!0),{entities:[s]}}}),de=new D({type:"label",complete:i=>i.positions.length>=1,skeletons:[k],initEntites:()=>[new n.Entity({label:{text:"Label"}})],render(i){var e,t;const{mouse:r,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])??r;return s.position=new n.CallbackPositionProperty(()=>d,!0),{entities:[s]}}}),ce=new D({type:"polygon",forceComplete:i=>i.positions.length>=3,skeletons:[N,H,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:r}=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=[...r.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]}}}),he=new D({type:"polyline",forceComplete:i=>i.positions.length>=2,skeletons:[N,U,k],initEntites:()=>[new n.Entity({polyline:{width:1}})],render(i){var e;const{mouse:t,packable:r}=i,o=((e=i.previous.entities)==null?void 0:e[0])??new n.Entity({polyline:{}});return o.polyline.positions=new n.CallbackProperty(()=>{const s=[...r.positions??[]].concat(t?[t]:[]);return s.length>=2?s:[]},!1),{entities:[o]}}}),ve=new D({type:"rectangle",complete:i=>i.positions.length>=2,skeletons:[N,H,k],initEntites:()=>[new n.Entity({rectangle:{material:n.Color.YELLOW.withAlpha(.5)}})],render(i){var e;const{mouse:t,packable:r}=i,o=((e=i.previous.entities)==null?void 0:e[0])??new n.Entity({rectangle:{material:n.Color.YELLOW.withAlpha(.5)}}),s=[...r.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 y.PlotAction=b,y.PlotFeature=I,y.PlotFeatureCollection=Q,y.PlotScheme=D,y.PlotSkeletonEntity=V,y.SampledPlotProperty=F,y.SampledPlotStrategy=Y,y.control=N,y.interval=H,y.intervalNonclosed=U,y.moved=k,y.schemeBillboard=le,y.schemeLabel=de,y.schemeMeasureArea=ae,y.schemePolygon=ce,y.schemePolyline=he,y.schemeRectangle=ve,y.usePlot=te,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"}),y}({},Cesium,Vesium,VueUse,Vue);
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
2
  //# sourceMappingURL=index.iife.min.js.map