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