@vesium/plot 1.0.1-beta.34 → 1.0.1-beta.37

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(T,a,g,b,E,Y,w){"use strict";var K=Object.defineProperty,q=(i,e,t)=>e in i?K(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,P=(i,e,t)=>q(i,typeof e!="symbol"?e+"":e,t),y=(i=>(i[i.IDLE=0]="IDLE",i[i.HOVER=1]="HOVER",i[i.ACTIVE=2]="ACTIVE",i))(y||{});class L extends a.Entity{constructor(e){super(e)}}function N(){return{disabled:({active:i})=>!i,cursor:"pointer",dragCursor:"crosshair",onDrag({viewer:i,sampled:e,packable:t,context:o,index:s,lockCamera:r}){r();const v=g.canvasCoordToCartesian(o.endPosition,i.scene);if(v){const l=[...t.positions??[]];l[s]=v,e.setSample({time:t.time,derivative:t.derivative,positions:l})}},onKeyPressed({viewer:i,keyEvent:e,sampled:t,packable:o,index:s}){var r;const v=(r=g.toCartographic(i.camera.position))==null?void 0:r.height;if(!v||!["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"].includes(e.key))return;e.preventDefault();let l=0;switch(e.key){case"ArrowRight":l=Math.PI/2;break;case"ArrowDown":l=Math.PI;break;case"ArrowLeft":l=-Math.PI/2;break;case"ArrowUp":l=0;break}const h=(i.camera.heading+l)%(2*Math.PI),u=[...o.positions??[]],d=g.toCartographic(u[s]),n=v/1e5*Math.PI/180/1e3;d.latitude+=n*Math.cos(h),d.longitude+=n*Math.sin(h),u[s]=g.toCartesian3(d),t.setSample({time:o.time,derivative:o.derivative,positions:u})},render:({position:i,action:e})=>{const t={[y.IDLE]:a.Color.BLUE.withAlpha(.4),[y.HOVER]:a.Color.BLUE.withAlpha(.6),[y.ACTIVE]:a.Color.AQUA.withAlpha(1)};return{position:i,point:{pixelSize:8,color:t[e],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:a.Color.WHITE.withAlpha(.4)}}}}}function j(){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((o,s)=>{const r=s===t.length-1?t[0]:t[s+1];return a.Cartesian3.midpoint(o,r,new a.Cartesian3)})},onDrag({viewer:e,sampled:t,packable:o,context:s,index:r,lockCamera:v,dragging:l}){v();const h=g.canvasCoordToCartesian(s.endPosition,e.scene);if(!h)return;const u=[...o.positions??[]];i===-1?(i=r,u.splice(r+1,0,h)):u[i+1]=h,l||(i=-1),t.setSample({time:o.time,derivative:o.derivative,positions:u})},render:({position:e,action:t,active:o})=>{if(!o)return;const s={[y.IDLE]:a.Color.GREEN.withAlpha(.4),[y.HOVER]:a.Color.GREEN.withAlpha(.6),[y.ACTIVE]:a.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:s[t],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:a.Color.WHITE.withAlpha(.4)}}}}}function z(){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 o=[];for(let s=0;s<t.length-1;s++)o.push(a.Cartesian3.midpoint(t[s],t[s+1],new a.Cartesian3));return o},onDrag({viewer:e,sampled:t,packable:o,context:s,index:r,lockCamera:v,dragging:l}){v();const h=g.canvasCoordToCartesian(s.endPosition,e.scene);if(!h)return;const u=[...o.positions??[]];i===-1?(i=r,u.splice(r+1,0,h)):u[i+1]=h,l||(i=-1),t.setSample({time:o.time,derivative:o.derivative,positions:u})},render:({position:e,action:t})=>{const o={[y.IDLE]:a.Color.GREEN.withAlpha(.4),[y.HOVER]:a.Color.GREEN.withAlpha(.6),[y.ACTIVE]:a.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:o[t],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:a.Color.WHITE.withAlpha(.4)}}}}}const Q=`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 O(){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=a.Rectangle.center(a.Rectangle.fromCartesianArray(e));return[g.toCartesian3(t)]}},onDrag({viewer:i,sampled:e,packable:t,context:o,lockCamera:s,dragging:r}){r&&s();const v=g.canvasCoordToCartesian(o.startPosition,i.scene),l=g.canvasCoordToCartesian(o.endPosition,i.scene);if(!v||!l)return;const h=a.Cartesian3.subtract(l,v,new a.Cartesian3),u=[...t.positions??[]];e.setSample({time:t.time,derivative:t.derivative,positions:u.map(d=>a.Cartesian3.add(d,h,new a.Cartesian3))})},render:({position:i,action:e})=>{const t={[y.IDLE]:a.Color.WHITE,[y.HOVER]:a.Color.WHITE,[y.ACTIVE]:a.Color.AQUA.withAlpha(1)};return{position:i,billboard:{image:Q,width:20,height:20,color:t[e],pixelOffset:new a.Cartesian3(0,-20),horizontalOrigin:a.HorizontalOrigin.CENTER,verticalOrigin:a.VerticalOrigin.BOTTOM,disableDepthTestDistance:Number.POSITIVE_INFINITY}}}}}const X={scheme:{type:"Billboard",complete:i=>i.positions.length>=1,skeletons:[O],render(i){var e,t;const{mouse:o,packable:s}=i,r=((e=i.previous.entities)==null?void 0:e[0])??new a.Entity({billboard:{}}),v=((t=s.positions)==null?void 0:t[0])??o;return r.position=new a.CallbackPositionProperty(()=>v,!0),{entities:[r]}}}},Z={scheme:{type:"Label",complete:i=>i.positions.length>=1,skeletons:[O],render(i){var e,t;const{mouse:o,packable:s}=i,r=((e=i.previous.entities)==null?void 0:e[0])??new a.Entity({label:{text:"Label"}}),v=((t=s.positions)==null?void 0:t[0])??o;return r.position=new a.CallbackPositionProperty(()=>v,!0),{entities:[r]}}}},$={scheme:{type:"LineString",forceComplete:i=>i.positions.length>=2,skeletons:[N,z,O],render(i){var e;const{mouse:t,packable:o}=i,s=((e=i.previous.entities)==null?void 0:e[0])??new a.Entity({polyline:{width:1}});return s.polyline.positions=new a.CallbackProperty(()=>{const r=[...o.positions??[]].concat(t?[t]:[]);return r.length>=2?r:[]},!1),{entities:[s]}}}},ee={scheme:{type:"Polygon",forceComplete:i=>i.positions.length>=3,skeletons:[N,j,O],render(i){var e;const{mouse:t,packable:o}=i,s=((e=i.previous.entities)==null?void 0:e[0])??new a.Entity({polyline:{material:a.Color.YELLOW.withAlpha(.5)},polygon:{material:a.Color.YELLOW.withAlpha(.5)}}),r=[...o.positions??[]];return t&&r.push(t),r.length===2?(s.polygon.hierarchy=void 0,s.polyline.positions=new a.CallbackProperty(()=>r,!1)):r.length>=3?(s.polyline.positions=void 0,s.polygon.hierarchy=new a.CallbackProperty(()=>(r.push(r[0]),r.length>=3?new a.PolygonHierarchy([...r]):void 0),!1)):(s.polygon.hierarchy=void 0,s.polyline.positions=void 0),{entities:[s]}}}},M=class A{constructor(e){P(this,"type"),P(this,"complete"),P(this,"forceComplete"),P(this,"definingCursor"),P(this,"skeletons"),P(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(o=>o()))??[],this.render=e.render}static getCacheTypes(){return[...this._record.keys()]}static getCache(e){return A._record.get(e)}static setCache(e){g.assertError(!e.type,"`scheme.type` is required"),A._record.set(e.type,e)}static resolve(e){if(typeof e=="string"){const t=A.getCache(e);return b.assert(!!t,`scheme ${e} not found`),t}else return e instanceof A?e:new A(e)}};P(M,"_record",new Map);let x=M;var G=(i=>(i[i.NEAR=0]="NEAR",i[i.CYCLE=1]="CYCLE",i[i.STRICT=2]="STRICT",i))(G||{});const te=(i,e,t,o)=>{var s,r,v;return o===0?{time:i,positions:(s=e.positions)==null?void 0:s.map(l=>l.clone()),derivative:e.derivative}:o===1?{time:i,positions:(r=t.positions)==null?void 0:r.map(l=>l.clone()),derivative:e.derivative}:{time:i,positions:(v=t.positions)==null?void 0:v.map((l,h)=>{var u;const d=(u=e.positions)==null?void 0:u[h];return d?a.Cartesian3.lerp(d,l,o,new a.Cartesian3):l}),derivative:e.derivative}},J=class U{constructor(e){P(this,"strategy"),P(this,"interpolationAlgorithm"),P(this,"_times",[]),P(this,"_sampleds",[]),P(this,"_derivatives",[]),P(this,"_definitionChanged",new a.Event);var t;this.interpolationAlgorithm=e?.interpolationAlgorithm,this.strategy=e?.strategy??0,(t=e?.packables)==null||t.forEach(o=>this.setSample(o)),this._times.length||this.setSample({time:a.JulianDate.now(),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],o=this._times[this._times.length-1];if(a.JulianDate.lessThan(e,t)||a.JulianDate.greaterThan(e,o))switch(this.strategy){case 2:return;case 0:{e=a.JulianDate.lessThan(e,this._times[0])?this._times[0].clone():this._times[this._times.length-1].clone();break}case 1:{const u=a.JulianDate.toDate(this._times[0]).getTime(),p=a.JulianDate.toDate(this._times[this._times.length-1]).getTime()-u,c=(a.JulianDate.toDate(e).getTime()-u)%p,f=new Date(u+c);e=a.JulianDate.fromDate(f);break}}const s=this._times.findIndex(u=>a.JulianDate.lessThanOrEquals(e,u)),r=Math.min(s,this._times.length-1),v=a.JulianDate.toDate(this._times[s]).getTime(),l=a.JulianDate.toDate(this._times[r]).getTime(),h=a.JulianDate.toDate(e).getTime();return{prevIndex:s,nextIndex:r,proportion:(h-v)/(l-v)||0}}getValue(e,t){var o,s;if(t??(t={time:e}),Object.assign(t,{time:e.clone(),positions:void 0,derivative:void 0}),!e)return t.time=(o=this._times[0])==null?void 0:o.clone(),t.positions=(s=this._sampleds[0])==null?void 0:s.map(n=>n.clone(n)),t.derivative=this._derivatives[0],t;const r=this.getIndexScope(e);if(!r)return t;t.time=e;const{prevIndex:v,nextIndex:l,proportion:h}=r,u={time:this._times[v],positions:this._sampleds[v],derivative:this._derivatives[v]},d={time:this._times[l],positions:this._sampleds[l],derivative:this._derivatives[l]},p=(this.interpolationAlgorithm||U.defaultInterpolationAlgorithm)(e,u,d,h);return Object.assign(t,p),t}setSample(e){var t;const o=e.time.clone(),s=((t=e.positions)==null?void 0:t.map(l=>l.clone()))??[],r=e.derivative,v=this._times.findIndex(l=>a.JulianDate.equals(o,l));v!==-1?(this._times[v]=o,this._sampleds[v]=s,this._derivatives[v]=e.derivative):this._times.length===0?(this._times[0]=o,this._sampleds[0]=s,this._derivatives[0]=e.derivative):a.JulianDate.lessThan(o,this._times[0])?(this._times.splice(0,0,o),this._sampleds.splice(0,0,s),this._derivatives.splice(0,0,r)):a.JulianDate.greaterThan(o,this._times[this._times.length-1])&&(this._times.push(o),this._sampleds.push(s),this._derivatives.push(r)),this.definitionChanged.raiseEvent(this)}setSamples(e){e.forEach(t=>this.setSample(t))}removeSample(e){const t=this._times.findIndex(o=>o.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 o=this._times[t];a.TimeInterval.contains(e,o)&&this.removeSample(o)}}equals(e){return e===this}};P(J,"defaultInterpolationAlgorithm",te);let k=J;class V{constructor(e){P(this,"_definitionChanged",new a.Event),P(this,"time"),g.assertError(!b.notNullish(e.scheme),"options.scheme is required"),this.id=e.id||a.createGuid(),g.createCesiumAttribute(this,"disabled",!!e.disabled),g.createCesiumAttribute(this,"defining",!0),g.createCesiumAttribute(this,"scheme",x.resolve(e.scheme),{readonly:!0});const t=e.sampled instanceof k?e.sampled:new k(e.sampled);g.createCesiumProperty(this,"sampled",t),g.createCesiumAttribute(this,"entities",[]),g.createCesiumAttribute(this,"primitives",[]),g.createCesiumAttribute(this,"groundPrimitives",[]),g.createCesiumAttribute(this,"skeletonEntities",[])}get definitionChanged(){return this._definitionChanged}isDefining(){return this.defining}getEntities(){return[...this.entities]}getPrimitives(){return[...this.primitives]}getGroundPrimitives(){return[...this.groundPrimitives]}getSkeletonEntities(){return[...this.skeletonEntities]}}function ie(i,e,t){const o=E.useViewer(),s=E.usePrimitive(new a.PrimitiveCollection),r=E.usePrimitive(new a.PrimitiveCollection,{collection:"ground"}),v=E.useDataSource(new a.CustomDataSource),l=E.useEntityScope({collection:()=>v.value.entities}),h=E.usePrimitiveScope({collection:()=>s.value}),u=E.usePrimitiveScope({collection:()=>r.value}),d=w.shallowRef();E.useScreenSpaceEventHandler(a.ScreenSpaceEventType.MOUSE_MOVE,g.throttle(n=>{d.value=g.canvasCoordToCartesian(n?.endPosition,o.value.scene)},10)),b.watchArray(i,(n,c,f,m=[])=>{m.forEach(C=>{l.removeWhere(_=>C.entities.includes(_)),h.removeWhere(_=>C.primitives.includes(_)),u.removeWhere(_=>C.groundPrimitives.includes(_))}),f.forEach(C=>{C.entities.forEach(_=>l.add(_)),C.primitives.forEach(_=>h.add(_)),C.groundPrimitives.forEach(_=>u.add(_))})},{immediate:!0}),E.useCesiumEventListener(()=>i.value.map(n=>n.definitionChanged),(n,c,f,m)=>{if(c==="entities"){const{added:C,removed:_}=g.arrayDiff(f,m);C.forEach(S=>l.add(S)),_.forEach(S=>l.remove(S))}else if(c==="primitives"){const{added:C,removed:_}=g.arrayDiff(f,m);C.forEach(S=>h.add(S)),_.forEach(S=>h.remove(S))}else if(c==="groundPrimitives"){const{added:C,removed:_}=g.arrayDiff(f,m);C.forEach(S=>u.add(S)),_.forEach(S=>u.remove(S))}});const p=g.throttle(async n=>{var c,f;const m=await((f=(c=n.scheme).render)==null?void 0:f.call(c,{packable:n.sampled.getValue(t()),mouse:n.defining?d.value:void 0,defining:n.defining,previous:{entities:n.entities,primitives:n.primitives,groundPrimitives:n.groundPrimitives}}));n.entities=m?.entities??[],n.primitives=m?.primitives??[],n.groundPrimitives=m?.groundPrimitives??[]},1);return w.watch(e,(n,c)=>{c&&p(c)}),E.useCesiumEventListener(()=>i.value.map(n=>n.definitionChanged),(n,c)=>{["disabled","defining","scheme","sampled","time"].includes(c)&&p(n)}),w.watch(d,()=>{i.value.forEach(n=>n.defining&&p(n))}),{primitives:w.computed(()=>Array.from(h.scope)),groundPrimitives:w.computed(()=>Array.from(h.scope)),entities:w.computed(()=>Array.from(l.scope))}}function ne(i,e){const t=E.useViewer(),o=w.ref(!1),s=w.computed(()=>{var l;return(l=i.value)==null?void 0:l.sampled.getValue(e())});E.useScreenSpaceEventHandler(a.ScreenSpaceEventType.LEFT_CLICK,async l=>{var h,u;if(await b.promiseTimeout(1),!i.value||!s.value||o.value)return;const{scheme:d,defining:p,sampled:n}=i.value;if(!p)return;const c=g.canvasCoordToCartesian(l.position,t.value.scene);if(!c)return;(h=s.value).positions??(h.positions=[]),s.value.positions.push(c),n.setSample(s.value),((u=d.complete)==null?void 0:u.call(d,s.value))&&(i.value.defining=!1)}),E.useScreenSpaceEventHandler(a.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,async l=>{var h;if(!i.value||!s.value)return;o.value=!0,await b.promiseTimeout(2),o.value=!1;const{scheme:u,defining:d}=i.value;if(!d||!g.canvasCoordToCartesian(l.position,t.value.scene))return;((h=u.forceComplete)==null?void 0:h.call(u,s.value))&&(i.value.defining=!1)}),E.useScreenSpaceEventHandler(a.ScreenSpaceEventType.RIGHT_CLICK,async()=>{var l;if(!i.value||!s.value)return;const{defining:h,sampled:u}=i.value;h&&((l=s.value).positions??(l.positions=[]),s.value.positions.length!==0&&(s.value.positions.splice(s.value.positions.length-1,1),u.setSample(s.value)))});const r=w.ref(),v=()=>{var l,h;if(!((l=i.value)!=null&&l.defining))r.value&&(r.value=void 0,t.value.container.parentElement.style.removeProperty("cursor"));else{const u=i.value.scheme.definingCursor;r.value=g.isFunction(u)?u(s.value):w.toValue(u),r.value&&((h=t.value)==null||h.container.parentElement.style.setProperty("cursor",r.value))}};E.useCesiumEventListener(()=>{var l;return(l=i.value)==null?void 0:l.definitionChanged},(l,h)=>{(h==="defining"||h==="sampled")&&v()}),w.watch(i,()=>v())}function se(i,e,t){const o=E.useViewer(),s=E.useDataSource(new a.CustomDataSource),r=E.useEntityScope({collection:()=>s.value.entities}),v=w.shallowRef(),l=w.shallowRef(),h=d=>{var p,n;return d?((p=l.value)==null?void 0:p.id)===d.id?y.ACTIVE:((n=v.value)==null?void 0:n.id)===d.id?y.HOVER:y.IDLE:y.IDLE},u=g.throttle((d,p)=>{const n=d.getSkeletonEntities(),c=[];if(p||d.disabled)d.skeletonEntities=[];else{const f=d.sampled.getValue(t()),m=d.defining,C=e.value===d;d.scheme.skeletons.forEach(S=>{var W;if(g.isFunction(S.disabled)?S.disabled({active:C,defining:m}):S.disabled)return;const B=((W=S.format)==null?void 0:W.call(S,f))??f?.positions??[];B.forEach((ae,R)=>{var F;let I=n.find(D=>D.index===R&&D.skeleton===S);const re=(F=S.render)==null?void 0:F.call(S,{defining:m,active:C,index:R,packable:f,positions:B,position:ae,action:h(I)}),H=new L(re??{});I?H.propertyNames.forEach(D=>{D!=="id"&&(I[D]=H[D])}):I=H,I.plot=d,I.skeleton=S,I.index=R,c.push(I)})})}d.skeletonEntities=c},1);return E.useGraphicDrag({cursor:d=>{var p;if(!((p=e.value)!=null&&p.defining)&&r.scope.has(d.id)){const n=d.id.skeleton;return g.isFunction(n?.cursor)?n.cursor(d):w.toValue(n?.cursor)}},dragCursor:d=>{var p;if(!((p=e.value)!=null&&p.defining)&&r.scope.has(d.id)){const n=d.id.skeleton;return g.isFunction(n?.dragCursor)?n.dragCursor(d):w.toValue(n?.dragCursor)}},listener:d=>{var p;if(d.pick.id instanceof L&&r.scope.has(d.pick.id)){const n=d.pick.id,c=n.plot;if(c.defining)return;l.value=n;const f=n.skeleton,m=n.index,C=c.sampled.getValue(t());(p=f.onDrag)==null||p.call(f,{viewer:o.value,sampled:c.sampled,packable:C,active:e.value===c,index:m,context:d.context,dragging:d.dragging,lockCamera:d.lockCamera})}else l.value=void 0}}),b.onKeyStroke(d=>{var p;if(l.value){const n=l.value,c=n.plot,f=n.skeleton,m=n.index,C=c.sampled.getValue(t());(p=f.onKeyPressed)==null||p.call(f,{viewer:o.value,sampled:c.sampled,packable:C,index:m,keyEvent:d})}}),E.useGraphicHover({listener:({hovering:d,pick:p})=>{if(d&&p.id instanceof L&&r.scope.has(p.id)){const n=p.id;v.value=n}else v.value=void 0}}),E.useGraphicLeftClick({listener:({context:d,pick:p})=>{var n;if(p.id instanceof L&&r.scope.has(p.id)){const c=p.id;l.value=c;const f=c.plot,m=c.skeleton,C=c.index,_=f.sampled.getValue(t());(n=m.onLeftClick)==null||n.call(m,{viewer:o.value,sampled:f.sampled,packable:_,active:e.value===f,defining:f.defining,index:C,context:d})}else l.value=void 0}}),b.watchArray(i,(d,p,n,c=[])=>{n.forEach(f=>u(f)),c.forEach(f=>u(f,!0))}),E.useCesiumEventListener(()=>i.value.map(d=>d.definitionChanged),(d,p,n,c)=>{if(["disabled","defining","scheme","sampled","time"].includes(p)&&u(d),p==="skeletonEntities"){const{added:f,removed:m}=g.arrayDiff(n,c);f.forEach(C=>r.add(C)),m.forEach(C=>r.remove(C))}}),w.watch(e,(d,p)=>{d&&u(d),setTimeout(()=>{p&&u(p)},2)}),{dataSource:s}}function oe(i){const e=i?.time||w.shallowRef(),t=Y.useViewer(),o=()=>{var n,c,f;return((n=e.value)==null?void 0:n.clone())||((f=(c=t.value)==null?void 0:c.clock.currentTime)==null?void 0:f.clone())||a.JulianDate.now()},s=w.shallowReactive(new Set),r=w.computed(()=>Array.from(s)),v=w.shallowRef(),l=w.shallowRef();E.useCesiumEventListener([()=>{var n;return(n=v.value)==null?void 0:n.sampled.definitionChanged}],()=>{var n;l.value=(n=v.value)==null?void 0:n.sampled.getValue(o())}),ne(v,o),ie(r,v,o),se(r,v,o),E.useScreenSpaceEventHandler(a.ScreenSpaceEventType.LEFT_CLICK,n=>{var c,f,m;if((c=v.value)!=null&&c.defining)return;const C=(f=t.value)==null?void 0:f.scene.pick(n.position.clone());if(!(((m=C?.id)==null?void 0:m.plot)instanceof V)){if(!C){v.value=void 0;return}v.value=r.value.find(_=>g.pickHitGraphic(C,[..._.entities,..._.primitives,..._.groundPrimitives]))}});let h,u;return w.watch(v,(n,c)=>{var f,m;if(c&&c.defining){const C=c.sampled.getValue(o());((m=(f=c.scheme).forceComplete)==null?void 0:m.call(f,C))?(c.defining=!1,h?.(c)):s.delete(c)}}),{plots:r,time:e,operate:async n=>new Promise((c,f)=>{h=c,u=f;const m=n instanceof V?n:new V(n);return s.has(m)||s.add(m),v.value=m,c(m)}),remove:n=>(n===v.value&&(v.value=void 0),s.has(n)?(s.delete(n),!0):!1),cancel:u}}return T.PLOT_BILLBOARD_SCHEME=X,T.PLOT_LABEL_SCHEME=Z,T.PLOT_LINE_STRING_SCHEME=$,T.PLOT_POLYGON_SCHEME=ee,T.Plot=V,T.PlotScheme=x,T.SampledPlotProperty=k,T.SampledPlotStrategy=G,T.usePlot=oe,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"}),T}({},Cesium,VesiumShared,VueUse,VesiumCore,VesiumCore,Vue);
1
+ var VesiumPlot=function(P,r,I,_,C){"use strict";var ce=Object.defineProperty,de=(i,e,t)=>e in i?ce(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,w=(i,e,t)=>de(i,typeof e!="symbol"?e+"":e,t);const ve=Symbol("CREATE_VIEWER_INJECTION_KEY"),ue=new WeakMap;async function Q(i,e={}){try{const{raw:t=!0}=e;let o;if(C.isFunction(i))o=await i();else{const n=_.toValue(i);o=C.isPromise(n)?await n:n}return t?_.toRaw(o):o}catch(t){throw console.error(t),t}}function H(i,e,t={}){const o=_.toRef(t.isActive??!0),n=_.watchEffect(l=>{const v=_.toValue(i),d=Array.isArray(v)?v:[v];if(d&&d.length&&o.value){const u=d.map(a=>{const p=_.toValue(a);return p?.addEventListener(e,p)});l(()=>u.forEach(a=>a?.()))}});return I.tryOnScopeDispose(n.stop),n.stop}function b(){const i=_.getCurrentScope(),e=i?ue.get(i):void 0;if(e)return e;{const t=_.inject(ve);if(!t)throw new Error("The `Viewer` instance injected by `createViewer` was not found in the current component or its ancestor components. Have you called `createViewer`?");return t}}function X(i,e,t){const o=_.shallowReactive(new Set),n=(u,...a)=>{const p=i(u,...a);return C.isPromise(p)?new Promise((h,s)=>{p.then(c=>{o.add(c),h(c)}).catch(c=>s(c))}):(o.add(p),p)},l=(u,...a)=>(o.delete(u),e(u,...a)),v=(u,...a)=>{o.forEach(p=>{u(p)&&l(p,...a)})},d=(...u)=>{o.forEach(a=>{l(a,...u)})};return I.tryOnScopeDispose(()=>d(...t)),{scope:_.shallowReadonly(o),add:n,remove:l,removeWhere:v,removeScope:d}}function Z(i,e={}){const{destroyOnRemove:t,collection:o,isActive:n=!0,evaluating:l}=e,v=I.computedAsync(()=>Q(i),void 0,{evaluating:l}),d=b();return _.watchEffect(u=>{var a;if(_.toValue(n)){const h=Array.isArray(v.value)?[...v.value]:[v.value],s=o??((a=d.value)==null?void 0:a.dataSources);h.forEach(c=>c&&s?.add(c)),u(()=>{const c=_.toValue(t);!s?.isDestroyed()&&h.forEach(g=>g&&s?.remove(g,c))})}}),v}function ee(i={}){const{collection:e}=i,t=b(),o=_.computed(()=>{var h;return _.toValue(e)??((h=t.value)==null?void 0:h.entities)}),n=h=>{if(!o.value)throw new Error("collection is not defined");return o.value.contains(h)||o.value.add(h),h},l=h=>{var s;return!!((s=o.value)!=null&&s.remove(h))},{scope:v,add:d,remove:u,removeWhere:a,removeScope:p}=X(n,l,[]);return{scope:v,add:d,remove:u,removeWhere:a,removeScope:p}}const te=new WeakMap;function j(i,e={}){const{width:t=3,height:o=3,throttled:n=8}=e,l=_.toRef(e.isActive??!0),v=b(),d=I.refThrottled(_.computed(()=>{var a;return(a=_.toValue(i))==null?void 0:a.clone()}),n,!1,!0),u=_.shallowRef();return _.watchEffect(()=>{var a;if(v.value&&d.value&&l.value){const p=te.get(v.value);p&&p[0].equals(d.value)?u.value=p[1]:(te.set(v.value,[d.value.clone(),u.value]),u.value=(a=v.value)==null?void 0:a.scene.pick(d.value,_.toValue(t),_.toValue(o)))}},{flush:"post"}),u}function A(i,e,t={}){const{modifier:o}=t,n=b(),l=_.toRef(t.isActive??!0),v=_.computed(()=>{var p,h;if((h=(p=n.value)==null?void 0:p.cesiumWidget)!=null&&h.canvas)return new r.ScreenSpaceEventHandler(n.value.cesiumWidget.canvas)}),d=_.watch(v,(p,h)=>{var s;(s=n.value)!=null&&s.cesiumWidget&&h?.destroy()}),u=_.watchEffect(p=>{const h=_.toValue(i),s=_.toValue(o),c=_.toValue(v);!c||!l.value||!e||C.isDef(h)&&(c.setInputAction(e,h,s),p(()=>c.removeInputAction(h,s)))}),a=()=>{d(),u()};return I.tryOnScopeDispose(a),a}function he(i){const e=_.shallowRef(),t=j(e),o=_.shallowRef(),n=_.ref(!1),l=b(),v=_.ref(!1);_.watch(v,c=>{l.value&&(l.value.scene.screenSpaceCameraController.enableRotate=!c)});const d=()=>{v.value=!0},u=(c,g,f)=>{i({event:{startPosition:g.clone(),endPosition:f.clone()},pick:c,dragging:n.value,lockCamera:d}),_.nextTick(()=>{!n.value&&v.value&&(v.value=!1)})},a=A(r.ScreenSpaceEventType.LEFT_DOWN,c=>{n.value=!0,e.value=c.position.clone()}),p=A(r.ScreenSpaceEventType.MOUSE_MOVE,C.throttle(({startPosition:c,endPosition:g})=>{var f;o.value={startPosition:((f=o.value)==null?void 0:f.endPosition.clone())||c.clone(),endPosition:g.clone()}},8,!1,!0));_.watch([t,o],([c,g])=>{if(c&&g){const{startPosition:f,endPosition:m}=g;n.value&&u(c,f,m)}});const h=A(r.ScreenSpaceEventType.LEFT_UP,c=>{n.value=!1,t.value&&o.value&&u(t.value,o.value.endPosition,c.position),e.value=void 0,o.value=void 0}),s=()=>{a(),p(),h()};return I.tryOnScopeDispose(s),s}function fe(i){const e=_.shallowRef(),t=j(()=>{var n;return(n=e.value)==null?void 0:n.endPosition}),o=(n,l,v,d)=>{i({event:{startPosition:l.clone(),endPosition:v.clone()},pick:n,hovering:d})};A(r.ScreenSpaceEventType.MOUSE_MOVE,({startPosition:n,endPosition:l})=>{var v,d;(!n.equals((v=e.value)==null?void 0:v.startPosition)||!l.equals((d=e.value)==null?void 0:d.endPosition))&&(e.value={startPosition:n.clone(),endPosition:l.clone()})}),_.watch([t,e],([n,l])=>{if(n&&l){const{startPosition:v,endPosition:d}=l;o(n,v,d,!0)}}),_.watch(t,(n,l)=>{if(l&&e.value){const{startPosition:v,endPosition:d}=e.value;o(l,v,d,!1)}})}const pe={LEFT_DOWN:r.ScreenSpaceEventType.LEFT_DOWN,LEFT_UP:r.ScreenSpaceEventType.LEFT_UP,LEFT_CLICK:r.ScreenSpaceEventType.LEFT_CLICK,LEFT_DOUBLE_CLICK:r.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,RIGHT_DOWN:r.ScreenSpaceEventType.RIGHT_DOWN,RIGHT_UP:r.ScreenSpaceEventType.RIGHT_UP,RIGHT_CLICK:r.ScreenSpaceEventType.RIGHT_CLICK,MIDDLE_DOWN:r.ScreenSpaceEventType.MIDDLE_DOWN,MIDDLE_UP:r.ScreenSpaceEventType.MIDDLE_UP,MIDDLE_CLICK:r.ScreenSpaceEventType.MIDDLE_CLICK};function ge(i,e){const t=pe[i],o=_.shallowRef(),n=j(o);A(t,l=>{o.value=l.position.clone()}),_.watch([o,n],([l,v])=>{v&&l&&e({event:{position:l},pick:v})})}const W=Symbol("GLOBAL_GRAPHIC_SYMBOL"),_e=["LEFT_DOWN","LEFT_UP","LEFT_CLICK","LEFT_DOUBLE_CLICK","RIGHT_DOWN","RIGHT_UP","RIGHT_CLICK","MIDDLE_DOWN","MIDDLE_UP","MIDDLE_CLICK"];function me(){const i=new WeakMap,e=new WeakMap,t=new WeakMap,o=(u,a,p)=>{var h,s,c,g,f,m,E,y,T,R,K,M,B,N,Y,L,z,F,O;const S=u==="global"?W:u;(s=(h=i?.get(S))==null?void 0:h.get(a))==null||s.delete(p),(g=(c=e?.get(S))==null?void 0:c.get(a))==null||g.delete(p),((m=(f=i?.get(S))==null?void 0:f.get(a))==null?void 0:m.size)===0&&i.get(S).delete(a),((E=i.get(S))==null?void 0:E.size)===0&&i.delete(S),(T=(y=e?.get(S))==null?void 0:y.get(a))==null||T.delete(p),((K=(R=e?.get(S))==null?void 0:R.get(a))==null?void 0:K.size)===0&&((M=e?.get(S))==null||M.delete(a)),((B=e?.get(S))==null?void 0:B.size)===0&&e?.delete(S),(Y=(N=t?.get(S))==null?void 0:N.get(a))==null||Y.delete(p),((z=(L=t?.get(S))==null?void 0:L.get(a))==null?void 0:z.size)===0&&((F=t?.get(S))==null||F.delete(a)),((O=t?.get(S))==null?void 0:O.size)===0&&t?.delete(S)},n=(u,a,p,h={})=>{const s=u==="global"?W:u;i.get(s)??i.set(s,new Map);const c=i.get(s);c.get(a)??c.set(a,new Set),c.get(a).add(p);let{cursor:f="pointer",dragCursor:m}=h;if(C.isDef(f)){const E=C.isFunction(f)?f:()=>f;e.get(s)??e.set(s,new Map),e.get(s).get(a)??e.get(s).set(a,new Map),e.get(s).get(a).set(p,E)}if(a==="DRAG"&&(m??(m=E=>E?.dragging?"crosshair":void 0)),C.isDef(m)){const E=C.isFunction(m)?m:()=>m;t.get(s)??t.set(s,new Map),t.get(s).get(a)??t.get(s).set(a,new Map),t.get(s).get(a).set(p,E)}return()=>o(u,a,p)},l=(u,a)=>{var p,h,s,c,g,f;const m=u==="global"?W:u;if(a==="all"){i.delete(m),e.delete(m),t.delete(m);return}(p=i.get(m))==null||p.delete(a),((h=i.get(m))==null?void 0:h.size)===0&&i.delete(m),(s=e?.get(m))==null||s.delete(a),(c=t?.get(m))==null||c.delete(a),((g=e?.get(m))==null?void 0:g.size)===0&&e?.delete(m),((f=t?.get(m))==null?void 0:f.size)===0&&t?.delete(m)};for(const u of _e)ge(u,a=>{C.resolvePick(a.pick).concat(W).forEach(h=>{var s,c;(c=(s=i.get(h))==null?void 0:s.get(u))==null||c.forEach(g=>{var f;return(f=C.tryRun(g))==null?void 0:f(a)})})});const v=_.ref(!1),d=b();return fe(u=>{C.resolvePick(u.pick).concat(W).forEach(p=>{var h,s,c;(s=(h=i.get(p))==null?void 0:h.get("HOVER"))==null||s.forEach(g=>{var f;return(f=C.tryRun(g))==null?void 0:f(u)}),v.value||(c=e.get(p))==null||c.forEach(g=>{g.forEach(f=>{var m,E;const y=u.hovering?C.tryRun(f)(u):"";(E=(m=d.value)==null?void 0:m.canvas.style)==null||E.setProperty("cursor",y)})})})}),he(u=>{const a=C.resolvePick(u.pick).concat(W);v.value=u.dragging,a.forEach(p=>{var h,s,c;(s=(h=i.get(p))==null?void 0:h.get("DRAG"))==null||s.forEach(g=>C.tryRun(g)(u)),(c=t.get(p))==null||c.forEach(g=>{g.forEach(f=>{var m,E;const y=u.dragging?C.tryRun(f)(u):"";(E=(m=d.value)==null?void 0:m.canvas.style)==null||E.setProperty("cursor",y)})})})}),{addGraphicEvent:n,removeGraphicEvent:o,clearGraphicEvent:l}}function ie(i,e={}){const{collection:t,isActive:o=!0,evaluating:n}=e,l=I.computedAsync(()=>Q(i),void 0,{evaluating:n}),v=b();return _.watchEffect(d=>{var u,a;if(_.toValue(o)){const h=Array.isArray(l.value)?[...l.value]:[l.value],s=t==="ground"?(u=v.value)==null?void 0:u.scene.groundPrimitives:t??((a=v.value)==null?void 0:a.scene.primitives);h.forEach(c=>c&&s?.add(c)),d(()=>{!s?.isDestroyed()&&h.forEach(c=>c&&s?.remove(c))})}}),l}function ne(i={}){const{collection:e}=i,t=b(),o=_.computed(()=>{var h;return _.toValue(e)??((h=t.value)==null?void 0:h.scene.primitives)}),n=h=>{if(!o.value)throw new Error("collection is not defined");return o.value.add(h)},l=h=>{var s;return!!((s=o.value)!=null&&s.remove(h))},{scope:v,add:d,remove:u,removeWhere:a,removeScope:p}=X(n,l,[]);return{scope:v,add:d,remove:u,removeWhere:a,removeScope:p}}const oe=class G{constructor(e){w(this,"type"),w(this,"complete"),w(this,"forceComplete"),w(this,"definingCursor"),w(this,"skeletons"),w(this,"initEntites"),w(this,"initPrimitives"),w(this,"initGroundPrimitives"),w(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(o=>o()))??[],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 G._record.get(e)}static setCache(e){C.assertError(!e.type,"`scheme.type` is required"),G._record.set(e.type,e)}static resolve(e){if(typeof e=="string"){const t=G.getCache(e);return I.assert(!!t,`scheme ${e} not found`),t}else return e instanceof G?e:new G(e)}};w(oe,"_record",new Map);let k=oe;var se=(i=>(i[i.NEAR=0]="NEAR",i[i.CYCLE=1]="CYCLE",i[i.STRICT=2]="STRICT",i))(se||{});const Ee=(i,e,t,o)=>{var n,l,v;return o===0?{time:i,positions:(n=e.positions)==null?void 0:n.map(d=>d.clone()),derivative:e.derivative}:o===1?{time:i,positions:(l=t.positions)==null?void 0:l.map(d=>d.clone()),derivative:e.derivative}:{time:i,positions:(v=t.positions)==null?void 0:v.map((d,u)=>{var a;const p=(a=e.positions)==null?void 0:a[u];return p?r.Cartesian3.lerp(p,d,o,new r.Cartesian3):d}),derivative:e.derivative}},le=class ae{constructor(e){w(this,"strategy"),w(this,"interpolationAlgorithm"),w(this,"_times",[]),w(this,"_sampleds",[]),w(this,"_derivatives",[]),w(this,"_definitionChanged",new r.Event);var t;this.interpolationAlgorithm=e?.interpolationAlgorithm,this.strategy=e?.strategy??0,(t=e?.packables)==null||t.forEach(o=>this.setSample(o)),this._times.length||this.setSample({time:r.JulianDate.now(),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],o=this._times[this._times.length-1];if(r.JulianDate.lessThan(e,t)||r.JulianDate.greaterThan(e,o))switch(this.strategy){case 2:return;case 0:{e=r.JulianDate.lessThan(e,this._times[0])?this._times[0].clone():this._times[this._times.length-1].clone();break}case 1:{const a=r.JulianDate.toDate(this._times[0]).getTime(),h=r.JulianDate.toDate(this._times[this._times.length-1]).getTime()-a,c=(r.JulianDate.toDate(e).getTime()-a)%h,g=new Date(a+c);e=r.JulianDate.fromDate(g);break}}const n=this._times.findIndex(a=>r.JulianDate.lessThanOrEquals(e,a)),l=Math.min(n,this._times.length-1),v=r.JulianDate.toDate(this._times[n]).getTime(),d=r.JulianDate.toDate(this._times[l]).getTime(),u=r.JulianDate.toDate(e).getTime();return{prevIndex:n,nextIndex:l,proportion:(u-v)/(d-v)||0}}getValue(e,t){var o,n;if(t??(t={time:e}),Object.assign(t,{time:e.clone(),positions:void 0,derivative:void 0}),!e)return t.time=(o=this._times[0])==null?void 0:o.clone(),t.positions=(n=this._sampleds[0])==null?void 0:n.map(s=>s.clone(s)),t.derivative=this._derivatives[0],t;const l=this.getIndexScope(e);if(!l)return t;t.time=e;const{prevIndex:v,nextIndex:d,proportion:u}=l,a={time:this._times[v],positions:this._sampleds[v],derivative:this._derivatives[v]},p={time:this._times[d],positions:this._sampleds[d],derivative:this._derivatives[d]},h=(this.interpolationAlgorithm||ae.defaultInterpolationAlgorithm)(e,a,p,u);return Object.assign(t,h),t}setSample(e){var t;const o=e.time.clone(),n=((t=e.positions)==null?void 0:t.map(d=>d.clone()))??[],l=e.derivative,v=this._times.findIndex(d=>r.JulianDate.equals(o,d));v!==-1?(this._times[v]=o,this._sampleds[v]=n,this._derivatives[v]=e.derivative):this._times.length===0?(this._times[0]=o,this._sampleds[0]=n,this._derivatives[0]=e.derivative):r.JulianDate.lessThan(o,this._times[0])?(this._times.splice(0,0,o),this._sampleds.splice(0,0,n),this._derivatives.splice(0,0,l)):r.JulianDate.greaterThan(o,this._times[this._times.length-1])&&(this._times.push(o),this._sampleds.push(n),this._derivatives.push(l)),this.definitionChanged.raiseEvent(this)}setSamples(e){e.forEach(t=>this.setSample(t))}removeSample(e){const t=this._times.findIndex(o=>o.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 o=this._times[t];r.TimeInterval.contains(e,o)&&this.removeSample(o)}}equals(e){return e===this}};w(le,"defaultInterpolationAlgorithm",Ee);let q=le;class V{constructor(e){w(this,"_id"),w(this,"_scheme"),w(this,"_definitionChanged"),w(this,"_defining"),w(this,"_disabled"),w(this,"_sampled"),w(this,"_entities"),w(this,"_primitives"),w(this,"_groundPrimitives"),w(this,"_skeletons");var t,o,n,l,v,d;const{id:u,disabled:a=!1,sampled:p}=e;this._id=u||r.createGuid(),this._scheme=k.resolve(e.scheme),this._definitionChanged=new r.Event,this._defining=!0,this._disabled=a,this._sampled=p instanceof q?p:new q(p),this._sampled.definitionChanged.addEventListener(h=>this._definitionChanged.raiseEvent(this,"sampled",h,h),this),this._entities=[...((o=(t=this._scheme).initEntites)==null?void 0:o.call(t))??[]],this._primitives=[...((l=(n=this._scheme).initPrimitives)==null?void 0:l.call(n))??[]],this._groundPrimitives=[...((d=(v=this._scheme).initGroundPrimitives)==null?void 0:d.call(v))??[]],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 Ce{constructor(e={}){w(this,"_id"),w(this,"_isDestroyed");const{id:t}=e;this._id=t||r.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 D=(i=>(i[i.IDLE=0]="IDLE",i[i.HOVER=1]="HOVER",i[i.ACTIVE=2]="ACTIVE",i))(D||{});class U extends r.Entity{constructor(e){super(e)}}function we(i,e,t){const o=b(),n=ie(new r.PrimitiveCollection),l=ie(new r.PrimitiveCollection,{collection:"ground"}),v=Z(new r.CustomDataSource),d=ee({collection:()=>v.value.entities}),u=ne({collection:()=>n.value}),a=ne({collection:()=>l.value}),p=_.shallowRef();A(r.ScreenSpaceEventType.MOUSE_MOVE,s=>{p.value=C.canvasCoordToCartesian(s?.endPosition,o.value.scene)}),I.watchArray(i,(s,c,g,f=[])=>{f.forEach(m=>{d.removeWhere(E=>m.entities.includes(E)),u.removeWhere(E=>m.primitives.includes(E)),a.removeWhere(E=>m.groundPrimitives.includes(E))}),g.forEach(m=>{m.entities.forEach(E=>d.add(E)),m.primitives.forEach(E=>u.add(E)),m.groundPrimitives.forEach(E=>a.add(E))})},{immediate:!0,flush:"post"}),H(()=>i.value.map(s=>s.definitionChanged),(s,c,g,f)=>{if(c==="entities"){const{added:m,removed:E}=C.arrayDiff(g,f);m.forEach(y=>d.add(y)),E.forEach(y=>d.remove(y))}else if(c==="primitives"){const{added:m,removed:E}=C.arrayDiff(g,f);m.forEach(y=>u.add(y)),E.forEach(y=>u.remove(y))}else if(c==="groundPrimitives"){const{added:m,removed:E}=C.arrayDiff(g,f);m.forEach(y=>a.add(y)),E.forEach(y=>a.remove(y))}});const h=async s=>{var c,g;const f=await((g=(c=s.scheme).render)==null?void 0:g.call(c,{packable:s.sampled.getValue(t()),mouse:s.defining?p.value:void 0,defining:s.defining,previous:{entities:s.entities,primitives:s.primitives,groundPrimitives:s.groundPrimitives}}));s.entities=f?.entities??[],s.primitives=f?.primitives??[],s.groundPrimitives=f?.groundPrimitives??[]};return _.watch(e,(s,c)=>{c&&h(c)}),H(()=>i.value.map(s=>s.definitionChanged),(s,c)=>{["disabled","defining","scheme","sampled","time"].includes(c)&&h(s)}),_.watch(p,()=>{i.value.forEach(s=>s.defining&&h(s))}),{primitives:_.computed(()=>Array.from(u.scope)),groundPrimitives:_.computed(()=>Array.from(u.scope)),entities:_.computed(()=>Array.from(d.scope))}}function ye(i,e){const t=b(),o=_.ref(!1),n=_.computed(()=>{var d;return(d=i.value)==null?void 0:d.sampled.getValue(e())});A(r.ScreenSpaceEventType.LEFT_CLICK,async d=>{var u,a;if(await I.promiseTimeout(1),!i.value||!n.value||o.value)return;const{scheme:p,defining:h,sampled:s}=i.value;if(!h)return;const c=C.canvasCoordToCartesian(d.position,t.value.scene);if(!c)return;(u=n.value).positions??(u.positions=[]),n.value.positions.push(c),s.setSample(n.value),((a=p.complete)==null?void 0:a.call(p,n.value))&&V.setDefining(i.value,!1)}),A(r.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,async d=>{var u;if(!i.value||!n.value)return;o.value=!0,await I.promiseTimeout(2),o.value=!1;const{scheme:a,defining:p}=i.value;if(!p||!C.canvasCoordToCartesian(d.position,t.value.scene))return;((u=a.forceComplete)==null?void 0:u.call(a,n.value))&&V.setDefining(i.value,!1)}),A(r.ScreenSpaceEventType.RIGHT_CLICK,async()=>{var d;if(!i.value||!n.value)return;const{defining:u,sampled:a}=i.value;u&&((d=n.value).positions??(d.positions=[]),n.value.positions.length!==0&&(n.value.positions.splice(n.value.positions.length-1,1),a.setSample(n.value)))});const l=_.ref(),v=()=>{var d,u;if(!((d=i.value)!=null&&d.defining))l.value&&(l.value=void 0,t.value.container.parentElement.style.removeProperty("cursor"));else{const a=i.value.scheme.definingCursor;l.value=C.isFunction(a)?a(n.value):a,l.value&&((u=t.value)==null||u.container.parentElement.style.setProperty("cursor",l.value))}};H(()=>{var d;return(d=i.value)==null?void 0:d.definitionChanged},(d,u)=>{(u==="defining"||u==="sampled")&&v()}),_.watch(i,()=>v())}function Pe(i,e,t){const o=b(),n=Z(new r.CustomDataSource),l=ee({collection:()=>n.value.entities}),v=_.shallowRef(),d=_.shallowRef(),u=h=>{var s,c;return h?((s=d.value)==null?void 0:s.id)===h.id?D.ACTIVE:((c=v.value)==null?void 0:c.id)===h.id?D.HOVER:D.IDLE:D.IDLE},a=C.throttle((h,s)=>{const c=h.skeletons,g=[];if(s||h.disabled)h.skeletons=[];else{const f=h.sampled.getValue(t()),m=h.defining,E=e.value===h;h.scheme.skeletons.forEach(T=>{var R;if(C.isFunction(T.disabled)?T.disabled({active:E,defining:m}):T.disabled)return;const M=((R=T.format)==null?void 0:R.call(T,f))??f?.positions??[];M.forEach((B,N)=>{var Y;let L=c.find(O=>O.index===N&&O.skeleton===T);const z=(Y=T.render)==null?void 0:Y.call(T,{defining:m,active:E,index:N,packable:f,positions:M,position:B,action:u(L)}),F=new U(z??{});L?F.propertyNames.forEach(O=>{O!=="id"&&(L[O]=F[O])}):L=F,L.plot=h,L.skeleton=T,L.index=N,g.push(L)})})}h.skeletons=g},1),{addGraphicEvent:p}=me();return _.watchEffect(h=>{const s=p("global","DRAG",({event:c,pick:g,dragging:f,lockCamera:m})=>{var E;if(g.id instanceof U&&l.scope.has(g.id)){const y=g.id,T=y.plot;if(T.defining)return;d.value=y;const R=y.skeleton,K=y.index,M=T.sampled.getValue(t());(E=R.onDrag)==null||E.call(R,{viewer:o.value,sampled:T.sampled,packable:M,active:e.value===T,index:K,event:c,dragging:f,lockCamera:m})}else d.value=void 0},{cursor:({pick:c})=>{var g;if(!((g=e.value)!=null&&g.defining)&&l.scope.has(c.id)){const f=c.id.skeleton;return C.isFunction(f?.cursor)?f.cursor(c):_.toValue(f?.cursor)}},dragCursor:({pick:c})=>{var g;if(!((g=e.value)!=null&&g.defining)&&l.scope.has(c.id)){const f=c.id.skeleton;return C.isFunction(f?.dragCursor)?f.dragCursor(c):_.toValue(f?.dragCursor)}}});h(s)}),I.onKeyStroke(h=>{var s;if(d.value){const c=d.value,g=c.plot,f=c.skeleton,m=c.index,E=g.sampled.getValue(t());(s=f.onKeyPressed)==null||s.call(f,{viewer:o.value,sampled:g.sampled,packable:E,index:m,keyEvent:h})}}),_.watchEffect(h=>{const s=p("global","HOVER",({hovering:c,pick:g})=>{if(c&&g.id instanceof U&&l.scope.has(g.id)){const f=g.id;v.value=f}else v.value=void 0});h(s)}),_.watchEffect(h=>{const s=p("global","LEFT_CLICK",({event:c,pick:g})=>{var f;if(g.id instanceof U&&l.scope.has(g.id)){const m=g.id;d.value=m;const E=m.plot,y=m.skeleton,T=m.index,R=E.sampled.getValue(t());(f=y.onLeftClick)==null||f.call(y,{viewer:o.value,sampled:E.sampled,packable:R,active:e.value===E,defining:E.defining,index:T,event:c})}else d.value=void 0});h(s)}),I.watchArray(i,(h,s,c,g=[])=>{c.forEach(f=>a(f)),g.forEach(f=>a(f,!0))}),H(()=>i.value.map(h=>h.definitionChanged),(h,s,c,g)=>{if(["disabled","defining","scheme","sampled","time"].includes(s)&&a(h),s==="skeletons"){const{added:f,removed:m}=C.arrayDiff(c,g);f.forEach(E=>l.add(E)),m.forEach(E=>l.remove(E))}}),_.watch(e,(h,s)=>{h&&a(h),s&&a(s)}),{dataSource:n}}function Te(i){const e=i?.time||_.shallowRef(),t=b(),o=()=>{var s,c,g;return((s=e.value)==null?void 0:s.clone())||((g=(c=t.value)==null?void 0:c.clock.currentTime)==null?void 0:g.clone())||r.JulianDate.now()},n=_.shallowReactive(new Set),l=_.computed(()=>Array.from(n)),v=_.shallowRef(),d=_.shallowRef();H([()=>{var s;return(s=v.value)==null?void 0:s.sampled.definitionChanged}],()=>{var s;d.value=(s=v.value)==null?void 0:s.sampled.getValue(o())}),ye(v,o),we(l,v,o),Pe(l,v,o),A(r.ScreenSpaceEventType.LEFT_CLICK,s=>{var c,g,f;if((c=v.value)!=null&&c.defining)return;const m=(g=t.value)==null?void 0:g.scene.pick(s.position.clone());if(!(((f=m?.id)==null?void 0:f.plot)instanceof V)){if(!m){v.value=void 0;return}v.value=l.value.find(E=>C.pickHitGraphic(m,[...E.entities,...E.primitives,...E.groundPrimitives]))}});let u,a;return _.watch(v,(s,c)=>{var g,f;if(c&&c.defining){const m=c.sampled.getValue(o());((f=(g=c.scheme).forceComplete)==null?void 0:f.call(g,m))?(V.setDefining(c,!1),u?.(c)):n.delete(c)}}),{plots:l,time:e,operate:async s=>new Promise((c,g)=>{u=c,a=g;const f=s instanceof V?s:new V(s);return n.has(f)||n.add(f),v.value=f,c(f)}),remove:s=>(s===v.value&&(v.value=void 0),n.has(s)?(n.delete(s),!0):!1),cancel:a}}function J(){return{disabled:({active:i})=>!i,cursor:"pointer",dragCursor:"crosshair",onDrag({viewer:i,sampled:e,packable:t,event:o,index:n,lockCamera:l}){l();const v=C.canvasCoordToCartesian(o.endPosition,i.scene);if(v){const d=[...t.positions??[]];d[n]=v,e.setSample({time:t.time,derivative:t.derivative,positions:d})}},onKeyPressed({viewer:i,keyEvent:e,sampled:t,packable:o,index:n}){var l;const v=(l=C.toCartographic(i.camera.position))==null?void 0:l.height;if(!v||!["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"].includes(e.key))return;e.preventDefault();let d=0;switch(e.key){case"ArrowRight":d=Math.PI/2;break;case"ArrowDown":d=Math.PI;break;case"ArrowLeft":d=-Math.PI/2;break;case"ArrowUp":d=0;break}const u=(i.camera.heading+d)%(2*Math.PI),a=[...o.positions??[]],p=C.toCartographic(a[n]),s=v/1e5*Math.PI/180/1e3;p.latitude+=s*Math.cos(u),p.longitude+=s*Math.sin(u),a[n]=C.toCartesian3(p),t.setSample({time:o.time,derivative:o.derivative,positions:a})},render:({position:i,action:e})=>{const t={[D.IDLE]:r.Color.BLUE.withAlpha(.4),[D.HOVER]:r.Color.BLUE.withAlpha(.6),[D.ACTIVE]:r.Color.AQUA.withAlpha(1)};return{position:i,point:{pixelSize:8,color:t[e],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:r.Color.WHITE.withAlpha(.4)}}}}}function $(){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((o,n)=>{const l=n===t.length-1?t[0]:t[n+1];return r.Cartesian3.midpoint(o,l,new r.Cartesian3)})},onDrag({viewer:e,sampled:t,packable:o,event:n,index:l,lockCamera:v,dragging:d}){v();const u=C.canvasCoordToCartesian(n.endPosition,e.scene);if(!u)return;const a=[...o.positions??[]];i===-1?(i=l,a.splice(l+1,0,u)):a[i+1]=u,d||(i=-1),t.setSample({time:o.time,derivative:o.derivative,positions:a})},render:({position:e,action:t,active:o})=>{if(!o)return;const n={[D.IDLE]:r.Color.GREEN.withAlpha(.4),[D.HOVER]:r.Color.GREEN.withAlpha(.6),[D.ACTIVE]:r.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:n[t],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:r.Color.WHITE.withAlpha(.4)}}}}}function re(){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 o=[];for(let n=0;n<t.length-1;n++)o.push(r.Cartesian3.midpoint(t[n],t[n+1],new r.Cartesian3));return o},onDrag({viewer:e,sampled:t,packable:o,event:n,index:l,lockCamera:v,dragging:d}){v();const u=C.canvasCoordToCartesian(n.endPosition,e.scene);if(!u)return;const a=[...o.positions??[]];i===-1?(i=l,a.splice(l+1,0,u)):a[i+1]=u,d||(i=-1),t.setSample({time:o.time,derivative:o.derivative,positions:a})},render:({position:e,action:t})=>{const o={[D.IDLE]:r.Color.GREEN.withAlpha(.4),[D.HOVER]:r.Color.GREEN.withAlpha(.6),[D.ACTIVE]:r.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:o[t],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:r.Color.WHITE.withAlpha(.4)}}}}}const De=`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 x(){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=r.Rectangle.center(r.Rectangle.fromCartesianArray(e));return[C.toCartesian3(t)]}},onDrag({viewer:i,sampled:e,packable:t,event:o,lockCamera:n,dragging:l}){l&&n();const v=C.canvasCoordToCartesian(o.startPosition,i.scene),d=C.canvasCoordToCartesian(o.endPosition,i.scene);if(!v||!d)return;const u=r.Cartesian3.subtract(d,v,new r.Cartesian3),a=[...t.positions??[]];e.setSample({time:t.time,derivative:t.derivative,positions:a.map(p=>r.Cartesian3.add(p,u,new r.Cartesian3))})},render:({position:i,action:e})=>{const t={[D.IDLE]:r.Color.WHITE,[D.HOVER]:r.Color.WHITE,[D.ACTIVE]:r.Color.AQUA.withAlpha(1)};return{position:i,billboard:{image:De,width:20,height:20,color:t[e],pixelOffset:new r.Cartesian3(0,-20),horizontalOrigin:r.HorizontalOrigin.CENTER,verticalOrigin:r.VerticalOrigin.BOTTOM,disableDepthTestDistance:Number.POSITIVE_INFINITY}}}}}function Se(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=r.CoplanarPolygonGeometry.createGeometry(r.CoplanarPolygonGeometry.fromPositions({positions:i,vertexFormat:r.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,o=e.indices,n=[];for(let l=0;l<o.length;l+=3){const v=r.Cartesian3.unpack(t,o[l]*3,new r.Cartesian3),d=r.Cartesian3.unpack(t,o[l+1]*3,new r.Cartesian3),u=r.Cartesian3.unpack(t,o[l+2]*3,new r.Cartesian3);n.push([v,d,u])}return n}function Ie(i,e,t){const o=r.Cartesian3.subtract(i,e,new r.Cartesian3),n=r.Cartesian3.subtract(t,e,new r.Cartesian3),l=r.Cartesian3.cross(o,n,o);return r.Cartesian3.magnitude(l)*.5}function be(i){const t=r.ClassificationType.BOTH,o=Math.floor(10);return{scene:i?.scene,clampToGround:!1,classificationType:t,terrainProvider:i?.terrainProvider,density:o}}async function Le(i,e){if(i.length<2)throw new Error("positions.length must >= 2");const{density:t}=be(e);if(t<=0)throw new Error("options.density must > 0");return Se(i).reduce((n,l)=>n+=Ie(...l),0)}const Ae=new k({type:"measureArea",forceComplete:i=>i.positions.length>=3,skeletons:[J,$],initEntites:()=>[new r.Entity({label:{font:"14pt"},polyline:{material:r.Color.YELLOW.withAlpha(.5)},polygon:{material:r.Color.YELLOW.withAlpha(.5)}})],render(i){var e;const{mouse:t,packable:o}=i,n=((e=i.previous.entities)==null?void 0:e[0])??new r.Entity({label:{font:"14pt"},polyline:{material:r.Color.YELLOW.withAlpha(.5)},polygon:{material:r.Color.YELLOW.withAlpha(.5)}}),l=[...o.positions??[]];return t&&l.push(t),l.length===2?(n.position=void 0,n.label.text=void 0,n.polygon.hierarchy=void 0,n.polyline.positions=new r.CallbackProperty(()=>l,!1)):l.length>=3?(l.push(l[0]),n.position=new r.ConstantPositionProperty(C.toCartesian3(r.Rectangle.center(r.Rectangle.fromCartesianArray(l)))),n.label.text=new r.ConstantProperty(""),Le(l).then(v=>{let d="";v/1e3/1e3>10?d=`${(v/1e3/1e3).toFixed(2)}km\xB2`:d=`${(+v).toFixed(2)}m\xB2`,n.label.text=new r.ConstantProperty(d)}),n.polyline.positions=void 0,n.polygon.hierarchy=new r.CallbackProperty(()=>l.length>=3?new r.PolygonHierarchy([...l]):void 0,!1)):(n.position=void 0,n.polygon.hierarchy=void 0,n.polyline.positions=void 0),{entities:[n]}}}),Re=new k({type:"billboard",complete:i=>i.positions.length>=1,skeletons:[x],initEntites:()=>[new r.Entity({billboard:{image:"/favicon.svg",width:32,height:32}})],render(i){var e,t;const{mouse:o,packable:n}=i,l=((e=i.previous.entities)==null?void 0:e[0])??new r.Entity({billboard:{}}),v=((t=n.positions)==null?void 0:t[0])??o;return l.position=new r.CallbackPositionProperty(()=>v,!0),{entities:[l]}}}),Oe=new k({type:"label",complete:i=>i.positions.length>=1,skeletons:[x],initEntites:()=>[new r.Entity({label:{text:"Label"}})],render(i){var e,t;const{mouse:o,packable:n}=i,l=((e=i.previous.entities)==null?void 0:e[0])??new r.Entity({label:{}}),v=((t=n.positions)==null?void 0:t[0])??o;return l.position=new r.CallbackPositionProperty(()=>v,!0),{entities:[l]}}}),ke=new k({type:"polygon",forceComplete:i=>i.positions.length>=3,skeletons:[J,$,x],initEntites:()=>[new r.Entity({polyline:{material:r.Color.YELLOW.withAlpha(.5)},polygon:{material:r.Color.YELLOW.withAlpha(.5)}})],render(i){var e;const{mouse:t,packable:o}=i,n=((e=i.previous.entities)==null?void 0:e[0])??new r.Entity({polyline:{material:r.Color.YELLOW.withAlpha(.5)},polygon:{material:r.Color.YELLOW.withAlpha(.5)}}),l=[...o.positions??[]];return t&&l.push(t),l.length===2?(n.polygon.hierarchy=void 0,n.polyline.positions=new r.CallbackProperty(()=>l,!1)):l.length>=3?(n.polyline.positions=void 0,n.polygon.hierarchy=new r.CallbackProperty(()=>(l.push(l[0]),l.length>=3?new r.PolygonHierarchy([...l]):void 0),!1)):(n.polygon.hierarchy=void 0,n.polyline.positions=void 0),{entities:[n]}}}),Ve=new k({type:"polyline",forceComplete:i=>i.positions.length>=2,skeletons:[J,re,x],initEntites:()=>[new r.Entity({polyline:{width:1}})],render(i){var e;const{mouse:t,packable:o}=i,n=((e=i.previous.entities)==null?void 0:e[0])??new r.Entity({polyline:{}});return n.polyline.positions=new r.CallbackProperty(()=>{const l=[...o.positions??[]].concat(t?[t]:[]);return l.length>=2?l:[]},!1),{entities:[n]}}});return P.PlotAction=D,P.PlotFeature=V,P.PlotFeatureCollection=Ce,P.PlotScheme=k,P.PlotSkeletonEntity=U,P.SampledPlotProperty=q,P.SampledPlotStrategy=se,P.control=J,P.interval=$,P.intervalNonclosed=re,P.moved=x,P.schemeBillboard=Re,P.schemeLabel=Oe,P.schemeMeasureArea=Ae,P.schemePolygon=ke,P.schemePolyline=Ve,P.usePlot=Te,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),P}({},Cesium,VueUse,Vue,VesiumShared);
2
2
  //# sourceMappingURL=index.iife.min.js.map