@vesium/plot 1.0.1-beta.41 → 1.0.1-beta.44
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/dist/index.cjs +26 -566
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +26 -567
- 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 +6 -546
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
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 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};
|
|
1
|
+
var Te=Object.defineProperty,Ae=(t,e,i)=>e in t?Te(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,_=(t,e,i)=>Ae(t,typeof e!="symbol"?e+"":e,i);import{JulianDate as P,Event as ie,TimeInterval as De,Cartesian3 as w,createGuid as te,Entity as I,PrimitiveCollection as se,CustomDataSource as ne,ScreenSpaceEventType as V,Color as E,VerticalOrigin as Se,HorizontalOrigin as Le,Rectangle as U,CoplanarPolygonGeometry as oe,VertexFormat as ke,ClassificationType as xe,CallbackProperty as R,ConstantPositionProperty as Oe,ConstantProperty as re,PolygonHierarchy as ae,CallbackPositionProperty as le}from"cesium";import{useViewer as K,usePrimitive as de,useDataSource as ce,useEntityScope as he,usePrimitiveScope as ue,useScreenSpaceEventHandler as N,useCesiumEventListener as M,useGraphicEvent as Ve,toCartesian3 as Re}from"@vesium/core";import{assertError as Ne,canvasCoordToCartesian as A,arrayDiff as B,isFunction as q,pickHitGraphic as Me,toCartographic as ve,toCartesian3 as me}from"@vesium/shared";import{assert as Ge,watchArray as pe,promiseTimeout as fe,onKeyStroke as He}from"@vueuse/core";import{shallowRef as x,watch as G,computed as H,ref as ge,watchEffect as Q,toValue as _e,nextTick as We,shallowReactive as Fe}from"vue";const we=class O{constructor(e){_(this,"type"),_(this,"complete"),_(this,"forceComplete"),_(this,"definingCursor"),_(this,"skeletons"),_(this,"initEntites"),_(this,"initPrimitives"),_(this,"initGroundPrimitives"),_(this,"render");var i;this.type=e.type,this.complete=e.complete,this.forceComplete=e.forceComplete,this.definingCursor=e.definingCursor??"crosshair",this.skeletons=((i=e.skeletons)==null?void 0:i.map(n=>n()))??[],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 O._record.get(e)}static setCache(e){Ne(!e.type,"`scheme.type` is required"),O._record.set(e.type,e)}static resolve(e){if(typeof e=="string"){const i=O.getCache(e);return Ge(!!i,`scheme ${e} not found`),i}else return e instanceof O?e:new O(e)}};_(we,"_record",new Map);let S=we;var Ee=(t=>(t[t.NEAR=0]="NEAR",t[t.CYCLE=1]="CYCLE",t[t.STRICT=2]="STRICT",t))(Ee||{});const Ye=(t,e,i,n)=>{var s,o,l;return n===0?{time:t,positions:(s=e.positions)==null?void 0:s.map(a=>a.clone()),derivative:e.derivative}:n===1?{time:t,positions:(o=i.positions)==null?void 0:o.map(a=>a.clone()),derivative:e.derivative}:{time:t,positions:(l=i.positions)==null?void 0:l.map((a,v)=>{var h;const g=(h=e.positions)==null?void 0:h[v];return g?w.lerp(g,a,n,new w):a}),derivative:e.derivative}},Ce=class be{constructor(e){_(this,"strategy"),_(this,"interpolationAlgorithm"),_(this,"_times",[]),_(this,"_sampleds",[]),_(this,"_derivatives",[]),_(this,"_definitionChanged",new ie);var i;this.interpolationAlgorithm=e?.interpolationAlgorithm,this.strategy=e?.strategy??0,(i=e?.packables)==null||i.forEach(n=>this.setSample(n)),this._times.length||this.setSample({time:P.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 i=this._times[0],n=this._times[this._times.length-1];if(P.lessThan(e,i)||P.greaterThan(e,n))switch(this.strategy){case 2:return;case 0:{e=P.lessThan(e,this._times[0])?this._times[0].clone():this._times[this._times.length-1].clone();break}case 1:{const h=P.toDate(this._times[0]).getTime(),m=P.toDate(this._times[this._times.length-1]).getTime()-h,d=(P.toDate(e).getTime()-h)%m,u=new Date(h+d);e=P.fromDate(u);break}}const s=this._times.findIndex(h=>P.lessThanOrEquals(e,h)),o=Math.min(s,this._times.length-1),l=P.toDate(this._times[s]).getTime(),a=P.toDate(this._times[o]).getTime(),v=P.toDate(e).getTime();return{prevIndex:s,nextIndex:o,proportion:(v-l)/(a-l)||0}}getValue(e,i){var n,s;if(i??(i={time:e}),Object.assign(i,{time:e.clone(),positions:void 0,derivative:void 0}),!e)return i.time=(n=this._times[0])==null?void 0:n.clone(),i.positions=(s=this._sampleds[0])==null?void 0:s.map(r=>r.clone(r)),i.derivative=this._derivatives[0],i;const o=this.getIndexScope(e);if(!o)return i;i.time=e;const{prevIndex:l,nextIndex:a,proportion:v}=o,h={time:this._times[l],positions:this._sampleds[l],derivative:this._derivatives[l]},g={time:this._times[a],positions:this._sampleds[a],derivative:this._derivatives[a]},m=(this.interpolationAlgorithm||be.defaultInterpolationAlgorithm)(e,h,g,v);return Object.assign(i,m),i}setSample(e){var i;const n=e.time.clone(),s=((i=e.positions)==null?void 0:i.map(a=>a.clone()))??[],o=e.derivative,l=this._times.findIndex(a=>P.equals(n,a));l!==-1?(this._times[l]=n,this._sampleds[l]=s,this._derivatives[l]=e.derivative):this._times.length===0?(this._times[0]=n,this._sampleds[0]=s,this._derivatives[0]=e.derivative):P.lessThan(n,this._times[0])?(this._times.splice(0,0,n),this._sampleds.splice(0,0,s),this._derivatives.splice(0,0,o)):P.greaterThan(n,this._times[this._times.length-1])&&(this._times.push(n),this._sampleds.push(s),this._derivatives.push(o)),this.definitionChanged.raiseEvent(this)}setSamples(e){e.forEach(i=>this.setSample(i))}removeSample(e){const i=this._times.findIndex(n=>n.equals(e));return i!==-1&&(this._sampleds.splice(i,1),this._derivatives.splice(i,1),this._times.splice(i,1).length)?(this._definitionChanged.raiseEvent(this),!0):!1}removeSamples(e){for(let i=0;i<this._times.length;i++){const n=this._times[i];De.contains(e,n)&&this.removeSample(n)}}equals(e){return e===this}};_(Ce,"defaultInterpolationAlgorithm",Ye);let J=Ce;class L{constructor(e){_(this,"_id"),_(this,"_scheme"),_(this,"_definitionChanged"),_(this,"_defining"),_(this,"_disabled"),_(this,"_sampled"),_(this,"_entities"),_(this,"_primitives"),_(this,"_groundPrimitives"),_(this,"_skeletons");var i,n,s,o,l,a;const{id:v,disabled:h=!1,sampled:g}=e;this._id=v||te(),this._scheme=S.resolve(e.scheme),this._definitionChanged=new ie,this._defining=!0,this._disabled=h,this._sampled=g instanceof J?g:new J(g),this._sampled.definitionChanged.addEventListener(m=>this._definitionChanged.raiseEvent(this,"sampled",m,m),this),this._entities=[...((n=(i=this._scheme).initEntites)==null?void 0:n.call(i))??[]],this._primitives=[...((o=(s=this._scheme).initPrimitives)==null?void 0:o.call(s))??[]],this._groundPrimitives=[...((a=(l=this._scheme).initGroundPrimitives)==null?void 0:a.call(l))??[]],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,i){e._defining!==i&&(e._definitionChanged.raiseEvent(e,"defining",i,e._defining),e._defining=i)}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 Ue{constructor(e={}){_(this,"_id"),_(this,"_isDestroyed");const{id:i}=e;this._id=i||te(),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=(t=>(t[t.IDLE=0]="IDLE",t[t.HOVER=1]="HOVER",t[t.ACTIVE=2]="ACTIVE",t))(y||{});class W extends I{constructor(e){super(e)}}function Ke(t,e,i){const n=K(),s=de(new se),o=de(new se,{collection:"ground"}),l=ce(new ne),a=he({collection:()=>l.value.entities}),v=ue({collection:()=>s.value}),h=ue({collection:()=>o.value}),g=x();N(V.MOUSE_MOVE,r=>{g.value=A(r?.endPosition,n.value.scene)}),pe(t,(r,d,u,c=[])=>{c.forEach(f=>{a.removeWhere(p=>f.entities.includes(p)),v.removeWhere(p=>f.primitives.includes(p)),h.removeWhere(p=>f.groundPrimitives.includes(p))}),u.forEach(f=>{f.entities.forEach(p=>a.add(p)),f.primitives.forEach(p=>v.add(p)),f.groundPrimitives.forEach(p=>h.add(p))})},{immediate:!0,flush:"post"}),M(()=>t.value.map(r=>r.definitionChanged),(r,d,u,c)=>{if(d==="entities"){const{added:f,removed:p}=B(u,c);f.forEach(C=>a.add(C)),p.forEach(C=>a.remove(C))}else if(d==="primitives"){const{added:f,removed:p}=B(u,c);f.forEach(C=>v.add(C)),p.forEach(C=>v.remove(C))}else if(d==="groundPrimitives"){const{added:f,removed:p}=B(u,c);f.forEach(C=>h.add(C)),p.forEach(C=>h.remove(C))}});const m=async r=>{var d,u;const c=await((u=(d=r.scheme).render)==null?void 0:u.call(d,{packable:r.sampled.getValue(i()),mouse:r.defining?g.value:void 0,defining:r.defining,previous:{entities:r.entities,primitives:r.primitives,groundPrimitives:r.groundPrimitives}}));r.entities=c?.entities??[],r.primitives=c?.primitives??[],r.groundPrimitives=c?.groundPrimitives??[]};return G(e,(r,d)=>{d&&m(d)}),M(()=>t.value.map(r=>r.definitionChanged),(r,d)=>{["disabled","defining","scheme","sampled","time"].includes(d)&&m(r)}),G(g,()=>{t.value.forEach(r=>r.defining&&m(r))}),{primitives:H(()=>Array.from(v.scope)),groundPrimitives:H(()=>Array.from(v.scope)),entities:H(()=>Array.from(a.scope))}}function Be(t,e){const i=K(),n=ge(!1),s=H(()=>{var a;return(a=t.value)==null?void 0:a.sampled.getValue(e())});N(V.LEFT_CLICK,async a=>{var v,h;if(await fe(1),!t.value||!s.value||n.value)return;const{scheme:g,defining:m,sampled:r}=t.value;if(!m)return;const d=A(a.position,i.value.scene);if(!d)return;(v=s.value).positions??(v.positions=[]),s.value.positions.push(d),r.setSample(s.value),((h=g.complete)==null?void 0:h.call(g,s.value))&&L.setDefining(t.value,!1)}),N(V.LEFT_DOUBLE_CLICK,async a=>{var v;if(!t.value||!s.value)return;n.value=!0,await fe(2),n.value=!1;const{scheme:h,defining:g}=t.value;if(!g||!A(a.position,i.value.scene))return;((v=h.forceComplete)==null?void 0:v.call(h,s.value))&&L.setDefining(t.value,!1)}),N(V.RIGHT_CLICK,async()=>{var a;if(!t.value||!s.value)return;const{defining:v,sampled:h}=t.value;v&&((a=s.value).positions??(a.positions=[]),s.value.positions.length!==0&&(s.value.positions.splice(s.value.positions.length-1,1),h.setSample(s.value)))});const o=ge(),l=()=>{var a,v;if(!((a=t.value)!=null&&a.defining))o.value&&(o.value=void 0,i.value.container.parentElement.style.removeProperty("cursor"));else{const h=t.value.scheme.definingCursor;o.value=q(h)?h(s.value):h,o.value&&((v=i.value)==null||v.container.parentElement.style.setProperty("cursor",o.value))}};M(()=>{var a;return(a=t.value)==null?void 0:a.definitionChanged},(a,v)=>{(v==="defining"||v==="sampled")&&l()}),G(t,()=>l())}function qe(t,e,i){const n=K(),s=ce(new ne),o=he({collection:()=>s.value.entities}),l=x(),a=x(),v=m=>{var r,d;return m?((r=a.value)==null?void 0:r.id)===m.id?y.ACTIVE:((d=l.value)==null?void 0:d.id)===m.id?y.HOVER:y.IDLE:y.IDLE},h=(m,r)=>{const d=m.skeletons,u=[];if(r||m.disabled)m.skeletons=[];else{const c=m.sampled.getValue(i()),f=m.defining,p=e.value===m;m.scheme.skeletons.forEach(b=>{var D;if(q(b.disabled)?b.disabled({active:p,defining:f}):b.disabled)return;const Y=((D=b.format)==null?void 0:D.call(b,c))??c?.positions??[];Y.forEach((Pe,$)=>{var ee;let T=d.find(k=>k.index===$&&k.skeleton===b);const Ie=(ee=b.render)==null?void 0:ee.call(b,{defining:f,active:p,index:$,packable:c,positions:Y,position:Pe,action:v(T)}),j=new W(Ie??{});T?j.propertyNames.forEach(k=>{k!=="id"&&(T[k]=j[k])}):T=j,T.plot=m,T.skeleton=b,T.index=$,u.push(T)})})}m.skeletons=u},{addGraphicEvent:g}=Ve();return Q(m=>{const r=g("global","DRAG",({event:d,pick:u,dragging:c,lockCamera:f})=>{var p;if(u.id instanceof W&&o.scope.has(u.id)){const C=u.id,b=C.plot;if(b.defining)return;a.value=C;const D=C.skeleton,Z=C.index,Y=b.sampled.getValue(i());(p=D.onDrag)==null||p.call(D,{viewer:n.value,sampled:b.sampled,packable:Y,active:e.value===b,index:Z,event:d,dragging:c,lockCamera:f})}else a.value=void 0},{cursor:({pick:d})=>{var u;if(!((u=e.value)!=null&&u.defining)&&o.scope.has(d.id)){const c=d.id.skeleton;return q(c?.cursor)?c.cursor(d):_e(c?.cursor)}},dragCursor:({pick:d})=>{var u;if(!((u=e.value)!=null&&u.defining)&&o.scope.has(d.id)){const c=d.id.skeleton;return q(c?.dragCursor)?c.dragCursor(d):_e(c?.dragCursor)}}});m(r)}),He(m=>{var r;if(a.value){const d=a.value,u=d.plot,c=d.skeleton,f=d.index,p=u.sampled.getValue(i());(r=c.onKeyPressed)==null||r.call(c,{viewer:n.value,sampled:u.sampled,packable:p,index:f,keyEvent:m})}}),Q(m=>{const r=g("global","HOVER",({hovering:d,pick:u})=>{if(d&&u.id instanceof W&&o.scope.has(u.id)){const c=u.id;l.value=c}else l.value=void 0});m(r)}),Q(m=>{const r=g("global","LEFT_CLICK",({event:d,pick:u})=>{var c;if(u.id instanceof W&&o.scope.has(u.id)){const f=u.id;a.value=f;const p=f.plot,C=f.skeleton,b=f.index,D=p.sampled.getValue(i());(c=C.onLeftClick)==null||c.call(C,{viewer:n.value,sampled:p.sampled,packable:D,active:e.value===p,defining:p.defining,index:b,event:d})}else a.value=void 0});m(r)}),pe(t,(m,r,d,u=[])=>{d.forEach(c=>h(c)),u.forEach(c=>h(c,!0))}),M(()=>t.value.map(m=>m.definitionChanged),(m,r,d,u)=>{if(["disabled","defining","scheme","sampled","time"].includes(r))We(()=>h(m));else if(r==="skeletons"){const{added:c,removed:f}=B(d,u);c.forEach(p=>o.add(p)),f.forEach(p=>o.remove(p))}}),G(e,(m,r)=>{m&&h(m),r&&h(r)}),{dataSource:s}}function ze(t){const e=t?.time||x(),i=K(),n=()=>{var r,d,u;return((r=e.value)==null?void 0:r.clone())||((u=(d=i.value)==null?void 0:d.clock.currentTime)==null?void 0:u.clone())||P.now()},s=Fe(new Set),o=H(()=>Array.from(s)),l=x(),a=x();M([()=>{var r;return(r=l.value)==null?void 0:r.sampled.definitionChanged}],()=>{var r;a.value=(r=l.value)==null?void 0:r.sampled.getValue(n())}),Be(l,n),Ke(o,l,n),qe(o,l,n),N(V.LEFT_CLICK,r=>{var d,u,c;if((d=l.value)!=null&&d.defining)return;const f=(u=i.value)==null?void 0:u.scene.pick(r.position.clone());if(!(((c=f?.id)==null?void 0:c.plot)instanceof L)){if(!f){l.value=void 0;return}l.value=o.value.find(p=>Me(f,[...p.entities,...p.primitives,...p.groundPrimitives]))}});let v,h;return G(l,(r,d)=>{var u,c;if(d&&d.defining){const f=d.sampled.getValue(n());((c=(u=d.scheme).forceComplete)==null?void 0:c.call(u,f))?(L.setDefining(d,!1),v?.(d)):s.delete(d)}}),{plots:o,time:e,operate:async r=>new Promise((d,u)=>{v=d,h=u;const c=r instanceof L?r:new L(r);return s.has(c)||s.add(c),l.value=c,d(c)}),remove:r=>(r===l.value&&(l.value=void 0),s.has(r)?(s.delete(r),!0):!1),cancel:h}}function z(){return{disabled:({active:t})=>!t,cursor:"pointer",dragCursor:"crosshair",onDrag({viewer:t,sampled:e,packable:i,event:n,index:s,lockCamera:o}){o();const l=A(n.endPosition,t.scene);if(l){const a=[...i.positions??[]];a[s]=l,e.setSample({time:i.time,derivative:i.derivative,positions:a})}},onKeyPressed({viewer:t,keyEvent:e,sampled:i,packable:n,index:s}){var o;const l=(o=ve(t.camera.position))==null?void 0:o.height;if(!l||!["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"].includes(e.key))return;e.preventDefault();let a=0;switch(e.key){case"ArrowRight":a=Math.PI/2;break;case"ArrowDown":a=Math.PI;break;case"ArrowLeft":a=-Math.PI/2;break;case"ArrowUp":a=0;break}const v=(t.camera.heading+a)%(2*Math.PI),h=[...n.positions??[]],g=ve(h[s]),r=l/1e5*Math.PI/180/1e3;g.latitude+=r*Math.cos(v),g.longitude+=r*Math.sin(v),h[s]=me(g),i.setSample({time:n.time,derivative:n.derivative,positions:h})},render:({position:t,action:e})=>{const i={[y.IDLE]:E.BLUE.withAlpha(.4),[y.HOVER]:E.BLUE.withAlpha(.6),[y.ACTIVE]:E.AQUA.withAlpha(1)};return{position:t,point:{pixelSize:8,color:i[e],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:E.WHITE.withAlpha(.4)}}}}}function X(){let t=-1;return{disabled:({active:e,defining:i})=>!e||i,cursor:"pointer",dragCursor:"crosshair",format(e){const i=e.positions??[];return i.length<2?[]:i.map((n,s)=>{const o=s===i.length-1?i[0]:i[s+1];return w.midpoint(n,o,new w)})},onDrag({viewer:e,sampled:i,packable:n,event:s,index:o,lockCamera:l,dragging:a}){l();const v=A(s.endPosition,e.scene);if(!v)return;const h=[...n.positions??[]];t===-1?(t=o,h.splice(o+1,0,v)):h[t+1]=v,a||(t=-1),i.setSample({time:n.time,derivative:n.derivative,positions:h})},render:({position:e,action:i,active:n})=>{if(!n)return;const s={[y.IDLE]:E.GREEN.withAlpha(.4),[y.HOVER]:E.GREEN.withAlpha(.6),[y.ACTIVE]:E.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:s[i],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:E.WHITE.withAlpha(.4)}}}}}function ye(){let t=-1;return{disabled:({active:e,defining:i})=>!e||i,cursor:"pointer",dragCursor:"crosshair",format(e){const i=e.positions??[];if(i.length<2)return[];const n=[];for(let s=0;s<i.length-1;s++)n.push(w.midpoint(i[s],i[s+1],new w));return n},onDrag({viewer:e,sampled:i,packable:n,event:s,index:o,lockCamera:l,dragging:a}){l();const v=A(s.endPosition,e.scene);if(!v)return;const h=[...n.positions??[]];t===-1?(t=o,h.splice(o+1,0,v)):h[t+1]=v,a||(t=-1),i.setSample({time:n.time,derivative:n.derivative,positions:h})},render:({position:e,action:i})=>{const n={[y.IDLE]:E.GREEN.withAlpha(.4),[y.HOVER]:E.GREEN.withAlpha(.6),[y.ACTIVE]:E.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:n[i],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:E.WHITE.withAlpha(.4)}}}}}const $e=`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 F(){return{disabled:({active:t,defining:e})=>!t||e,cursor:"pointer",dragCursor:"crosshair",format(t){const e=t.positions??[];if(e.length===0)return[];if(e.length===1)return[e[0]];{const i=U.center(U.fromCartesianArray(e));return[me(i)]}},onDrag({viewer:t,sampled:e,packable:i,event:n,lockCamera:s,dragging:o}){o&&s();const l=A(n.startPosition,t.scene),a=A(n.endPosition,t.scene);if(!l||!a)return;const v=w.subtract(a,l,new w),h=[...i.positions??[]];e.setSample({time:i.time,derivative:i.derivative,positions:h.map(g=>w.add(g,v,new w))})},render:({position:t,action:e})=>{const i={[y.IDLE]:E.WHITE,[y.HOVER]:E.WHITE,[y.ACTIVE]:E.AQUA.withAlpha(1)};return{position:t,billboard:{image:$e,width:20,height:20,color:i[e],pixelOffset:new w(0,-20),horizontalOrigin:Le.CENTER,verticalOrigin:Se.BOTTOM,disableDepthTestDistance:Number.POSITIVE_INFINITY}}}}}function je(t){if(t.length<3)throw new Error("positions must >= 3");if(t.length===3)return[[t[0].clone(),t[1].clone(),t[2].clone()]];const e=oe.createGeometry(oe.fromPositions({positions:t,vertexFormat:ke.POSITION_ONLY}));if(!e)throw new Error("positions\u65E0\u6CD5\u7EC4\u6210\u6709\u6548\u7684geometry,\u68C0\u67E5\u70B9\u4F4D\u662F\u5426\u9519\u8BEF");const i=e.attributes.position.values,n=e.indices,s=[];for(let o=0;o<n.length;o+=3){const l=w.unpack(i,n[o]*3,new w),a=w.unpack(i,n[o+1]*3,new w),v=w.unpack(i,n[o+2]*3,new w);s.push([l,a,v])}return s}function Qe(t,e,i){const n=w.subtract(t,e,new w),s=w.subtract(i,e,new w),o=w.cross(n,s,n);return w.magnitude(o)*.5}function Je(t){const i=xe.BOTH,n=Math.floor(10);return{scene:t?.scene,clampToGround:!1,classificationType:i,terrainProvider:t?.terrainProvider,density:n}}async function Xe(t,e){if(t.length<2)throw new Error("positions.length must >= 2");const{density:i}=Je(e);if(i<=0)throw new Error("options.density must > 0");return je(t).reduce((s,o)=>s+=Qe(...o),0)}const Ze=new S({type:"measureArea",forceComplete:t=>t.positions.length>=3,skeletons:[z,X],initEntites:()=>[new I({label:{font:"14pt"},polyline:{material:E.YELLOW.withAlpha(.5)},polygon:{material:E.YELLOW.withAlpha(.5)}})],render(t){var e;const{mouse:i,packable:n}=t,s=((e=t.previous.entities)==null?void 0:e[0])??new I({label:{font:"14pt"},polyline:{material:E.YELLOW.withAlpha(.5)},polygon:{material:E.YELLOW.withAlpha(.5)}}),o=[...n.positions??[]];return i&&o.push(i),o.length===2?(s.position=void 0,s.label.text=void 0,s.polygon.hierarchy=void 0,s.polyline.positions=new R(()=>o,!1)):o.length>=3?(o.push(o[0]),s.position=new Oe(Re(U.center(U.fromCartesianArray(o)))),s.label.text=new re(""),Xe(o).then(l=>{let a="";l/1e3/1e3>10?a=`${(l/1e3/1e3).toFixed(2)}km\xB2`:a=`${(+l).toFixed(2)}m\xB2`,s.label.text=new re(a)}),s.polyline.positions=void 0,s.polygon.hierarchy=new R(()=>o.length>=3?new ae([...o]):void 0,!1)):(s.position=void 0,s.polygon.hierarchy=void 0,s.polyline.positions=void 0),{entities:[s]}}}),ei=new S({type:"billboard",complete:t=>t.positions.length>=1,skeletons:[F],initEntites:()=>[new I({billboard:{image:"/favicon.svg",width:32,height:32}})],render(t){var e,i;const{mouse:n,packable:s}=t,o=((e=t.previous.entities)==null?void 0:e[0])??new I({billboard:{}}),l=((i=s.positions)==null?void 0:i[0])??n;return o.position=new le(()=>l,!0),{entities:[o]}}}),ii=new S({type:"label",complete:t=>t.positions.length>=1,skeletons:[F],initEntites:()=>[new I({label:{text:"Label"}})],render(t){var e,i;const{mouse:n,packable:s}=t,o=((e=t.previous.entities)==null?void 0:e[0])??new I({label:{}}),l=((i=s.positions)==null?void 0:i[0])??n;return o.position=new le(()=>l,!0),{entities:[o]}}}),ti=new S({type:"polygon",forceComplete:t=>t.positions.length>=3,skeletons:[z,X,F],initEntites:()=>[new I({polyline:{material:E.YELLOW.withAlpha(.5)},polygon:{material:E.YELLOW.withAlpha(.5)}})],render(t){var e;const{mouse:i,packable:n}=t,s=((e=t.previous.entities)==null?void 0:e[0])??new I({polyline:{material:E.YELLOW.withAlpha(.5)},polygon:{material:E.YELLOW.withAlpha(.5)}}),o=[...n.positions??[]];return i&&o.push(i),o.length===2?(s.polygon.hierarchy=void 0,s.polyline.positions=new R(()=>o,!1)):o.length>=3?(s.polyline.positions=void 0,s.polygon.hierarchy=new R(()=>(o.push(o[0]),o.length>=3?new ae([...o]):void 0),!1)):(s.polygon.hierarchy=void 0,s.polyline.positions=void 0),{entities:[s]}}}),si=new S({type:"polyline",forceComplete:t=>t.positions.length>=2,skeletons:[z,ye,F],initEntites:()=>[new I({polyline:{width:1}})],render(t){var e;const{mouse:i,packable:n}=t,s=((e=t.previous.entities)==null?void 0:e[0])??new I({polyline:{}});return s.polyline.positions=new R(()=>{const o=[...n.positions??[]].concat(i?[i]:[]);return o.length>=2?o:[]},!1),{entities:[s]}}});export{y as PlotAction,L as PlotFeature,Ue as PlotFeatureCollection,S as PlotScheme,W as PlotSkeletonEntity,J as SampledPlotProperty,Ee as SampledPlotStrategy,z as control,X as interval,ye as intervalNonclosed,F as moved,ei as schemeBillboard,ii as schemeLabel,Ze as schemeMeasureArea,ti as schemePolygon,si as schemePolyline,ze as usePlot};
|
|
2
2
|
//# sourceMappingURL=index.min.mjs.map
|