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