@vesium/plot 1.0.1-beta.51 → 1.0.1-beta.54
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 +723 -200
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -69
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +73 -69
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +1887 -1370
- 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 +695 -194
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -10
package/dist/index.iife.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(exports,t,n,r,i){var a=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,d=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=c(t),a=0,l=i.length,d;a<l;a++)d=i[a],!u.call(e,d)&&d!==n&&o(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=s(t,d))||r.enumerable});return e},f=(e,t,n)=>(n=e==null?{}:a(l(e)),d(t||!e||!e.__esModule?o(n,`default`,{value:e,enumerable:!0}):n,e));t=f(t),n=f(n),r=f(r),i=f(i);var p=class e{constructor(e){this.type=e.type,this.complete=e.complete,this.allowManualComplete=e.allowManualComplete,this.definingCursor=e.definingCursor??`crosshair`,this.skeletons=e.skeletons?.map(e=>e())??[],this.initEntites=e.initEntites,this.initPrimitives=e.initPrimitives,this.initGroundPrimitives=e.initGroundPrimitives,this.render=e.render}type;complete;allowManualComplete;definingCursor;skeletons;initEntites;initPrimitives;initGroundPrimitives;render;static _record=new Map;static getCacheTypes(){return[...this._record.keys()]}static getCache(t){return e._record.get(t)}static setCache(t){(0,n.assertError)(!t.type,"`scheme.type` is required"),e._record.set(t.type,t)}static resolve(t){if(typeof t==`string`){let n=e.getCache(t);return(0,r.assert)(!!n,`scheme ${t} not found`),n}else if(t instanceof e)return t;else return new e(t)}};let m=function(e){return e[e.NEAR=0]=`NEAR`,e[e.CYCLE=1]=`CYCLE`,e[e.STRICT=2]=`STRICT`,e}({}),h=(e,n,r,i)=>i===0?{time:e,positions:n.positions?.map(e=>e.clone()),derivative:n.derivative}:i===1?{time:e,positions:r.positions?.map(e=>e.clone()),derivative:n.derivative}:{time:e,positions:r.positions?.map((e,r)=>{let a=n.positions?.[r];return a?t.Cartesian3.lerp(a,e,i,new t.Cartesian3):e}),derivative:n.derivative};var g=class e{constructor(e){this.interpolationAlgorithm=e?.interpolationAlgorithm,this.strategy=e?.strategy??m.NEAR,e?.packables?.forEach(e=>this.setSample(e)),this._times.length||this.setSample({time:new t.JulianDate(0,0),positions:[],derivative:void 0})}static defaultInterpolationAlgorithm=h;strategy;interpolationAlgorithm;_times=[];_sampleds=[];_derivatives=[];get isConstant(){return this._times.length===0}_definitionChanged=new t.Event;get definitionChanged(){return this._definitionChanged}getTimes(){return this._times.map(e=>e.clone())}getIndexScope(e){if(!this._times.length)return;let n=this._times[0],r=this._times[this._times.length-1];if(t.JulianDate.lessThan(e,n)||t.JulianDate.greaterThan(e,r))switch(this.strategy){case m.STRICT:return;case m.NEAR:e=t.JulianDate.lessThan(e,this._times[0])?this._times[0].clone():this._times[this._times.length-1].clone();break;case m.CYCLE:{let n=t.JulianDate.toDate(this._times[0]).getTime(),r=t.JulianDate.toDate(this._times[this._times.length-1]).getTime(),i=r-n,a=t.JulianDate.toDate(e).getTime(),o=(a-n)%i,s=new Date(n+o);e=t.JulianDate.fromDate(s);break}}let i=this._times.findIndex(n=>t.JulianDate.lessThanOrEquals(e,n)),a=Math.min(i,this._times.length-1),o=t.JulianDate.toDate(this._times[i]).getTime(),s=t.JulianDate.toDate(this._times[a]).getTime(),c=t.JulianDate.toDate(e).getTime();return{prevIndex:i,nextIndex:a,proportion:(c-o)/(s-o)||0}}getValue(t,n){if(n??={time:t},Object.assign(n,{time:t?.clone(),positions:void 0,derivative:void 0}),!t)return n.time=this._times[0].clone(),n.positions=this._sampleds[0]?.map(e=>e.clone(e)),n.derivative=this._derivatives[0],n;let r=this.getIndexScope(t);if(!r)return n;n.time=t;let{prevIndex:i,nextIndex:a,proportion:o}=r,s={time:this._times[i],positions:this._sampleds[i],derivative:this._derivatives[i]},c={time:this._times[a],positions:this._sampleds[a],derivative:this._derivatives[a]},l=(this.interpolationAlgorithm||e.defaultInterpolationAlgorithm)(t,s,c,o);return Object.assign(n,l),n}setSample(e){let n=e.time?.clone()??this._times[0].clone(),r=e.positions?.map(e=>e.clone())??[],i=e.derivative,a=this._times.findIndex(e=>t.JulianDate.equals(n,e));a===-1?this._times.length===0?(this._times[0]=n,this._sampleds[0]=r,this._derivatives[0]=e.derivative):t.JulianDate.lessThan(n,this._times[0])?(this._times.splice(0,0,n),this._sampleds.splice(0,0,r),this._derivatives.splice(0,0,i)):t.JulianDate.greaterThan(n,this._times[this._times.length-1])&&(this._times.push(n),this._sampleds.push(r),this._derivatives.push(i)):(this._times[a]=n,this._sampleds[a]=r,this._derivatives[a]=e.derivative),this.definitionChanged.raiseEvent(this)}setSamples(e){e.forEach(e=>this.setSample(e))}removeSample(e){let t=this._times.findIndex(t=>t.equals(e));if(t!==-1){this._sampleds.splice(t,1),this._derivatives.splice(t,1);let e=this._times.splice(t,1);if(e.length)return this._definitionChanged.raiseEvent(this),!0}return!1}removeSamples(e){for(let n=0;n<this._times.length;n++){let r=this._times[n];t.TimeInterval.contains(e,r)&&this.removeSample(r)}}equals(e){return e===this}},_=class{constructor(e){let{id:n,disabled:r=!1,sampled:i}=e;this._id=n||(0,t.createGuid)(),this._scheme=p.resolve(e.scheme),this._definitionChanged=new t.Event,this._defining=!0,this._disabled=r,this._sampled=i instanceof g?i:new g(i),this._sampled.definitionChanged.addEventListener(e=>this._definitionChanged.raiseEvent(this,`sampled`,e,e),this),this._entities=[...this._scheme.initEntites?.()??[]],this._primitives=[...this._scheme.initPrimitives?.()??[]],this._groundPrimitives=[...this._scheme.initGroundPrimitives?.()??[]],this._skeletons=[]}_id;get id(){return this._id}_scheme;get scheme(){return this._scheme}_definitionChanged;get definitionChanged(){return this._definitionChanged}_defining;get defining(){return this._defining}static setDefining(e,t){e._defining!==t&&(e._definitionChanged.raiseEvent(e,`defining`,t,e._defining),e._defining=t)}_disabled;get disabled(){return this._disabled}set disabled(e){this.disabled=e}_sampled;get sampled(){return this._sampled}_entities;get entities(){return this._entities}set entities(e){this._definitionChanged.raiseEvent(this,`entities`,e,this._entities),this._entities=e}_primitives;get primitives(){return this._primitives}set primitives(e){this._definitionChanged.raiseEvent(this,`primitives`,e,this._primitives),this._primitives=e}_groundPrimitives;get groundPrimitives(){return this._groundPrimitives}set groundPrimitives(e){this._definitionChanged.raiseEvent(this,`groundPrimitives`,e,this._groundPrimitives),this._groundPrimitives=e}_skeletons;get skeletons(){return this._skeletons}set skeletons(e){this._definitionChanged.raiseEvent(this,`skeletons`,e,this._skeletons),this._skeletons=e}};let v=function(e){return e[e.IDLE=0]=`IDLE`,e[e.HOVER=1]=`HOVER`,e[e.ACTIVE=2]=`ACTIVE`,e}({});var y=class extends t.Entity{constructor(e){super(e)}};function b(e,a,o){let s=(0,n.useViewer)(),c=(0,n.usePrimitive)(new t.PrimitiveCollection),l=(0,n.usePrimitive)(new t.PrimitiveCollection,{collection:`ground`}),u=(0,n.useDataSource)(new t.CustomDataSource),d=(0,n.useEntityScope)({collection:()=>u.value.entities}),f=(0,n.usePrimitiveScope)({collection:()=>c.value}),p=(0,n.usePrimitiveScope)({collection:()=>l.value}),m=(0,i.shallowRef)();(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.MOUSE_MOVE,e=>{m.value=(0,n.canvasCoordToCartesian)(e?.endPosition,s.value.scene)}),(0,r.watchArray)(e,(e,t,n,r=[])=>{r.forEach(e=>{d.removeWhere(t=>e.entities.includes(t)),f.removeWhere(t=>e.primitives.includes(t)),p.removeWhere(t=>e.groundPrimitives.includes(t))}),n.forEach(e=>{e.entities.forEach(e=>d.add(e)),e.primitives.forEach(e=>f.add(e)),e.groundPrimitives.forEach(e=>p.add(e))})},{immediate:!0,flush:`post`}),(0,n.useCesiumEventListener)(()=>e.value.map(e=>e.definitionChanged),(e,t,r,i)=>{if(t===`entities`){let{added:e,removed:t}=(0,n.arrayDiff)(r,i);e.forEach(e=>d.add(e)),t.forEach(e=>d.remove(e))}else if(t===`primitives`){let{added:e,removed:t}=(0,n.arrayDiff)(r,i);e.forEach(e=>f.add(e)),t.forEach(e=>f.remove(e))}else if(t===`groundPrimitives`){let{added:e,removed:t}=(0,n.arrayDiff)(r,i);e.forEach(e=>p.add(e)),t.forEach(e=>p.remove(e))}});let h=async e=>{let t=await e.scheme.render?.({packable:e.sampled.getValue(o()),mouse:e.defining?m.value:void 0,defining:e.defining,previous:{entities:e.entities,primitives:e.primitives,groundPrimitives:e.groundPrimitives}});e.entities=t?.entities??[],e.primitives=t?.primitives??[],e.groundPrimitives=t?.groundPrimitives??[]};return(0,i.watch)(a,(e,t)=>{t&&h(t)}),(0,n.useCesiumEventListener)(()=>e.value.map(e=>e.definitionChanged),(e,t)=>{[`disabled`,`defining`,`scheme`,`sampled`,`time`].includes(t)&&h(e)}),(0,i.watch)(m,()=>{e.value.forEach(e=>e.defining&&h(e))}),{primitives:(0,i.computed)(()=>Array.from(f.scope)),groundPrimitives:(0,i.computed)(()=>Array.from(f.scope)),entities:(0,i.computed)(()=>Array.from(d.scope))}}function x(e,a){let o=(0,n.useViewer)(),s=(0,i.ref)(!1),c=(0,i.computed)(()=>e.value?.sampled.getValue(a()));(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.LEFT_CLICK,async t=>{if(await(0,r.promiseTimeout)(1),!e.value||!c.value||s.value)return;let{scheme:i,defining:a,sampled:l}=e.value;if(!a)return;let u=(0,n.canvasCoordToCartesian)(t.position,o.value.scene);if(!u)return;c.value.positions??=[],c.value.positions.push(u),l.setSample(c.value);let d=i.complete?.(c.value);d&&_.setDefining(e.value,!1)}),(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,async t=>{if(!e.value||!c.value)return;s.value=!0,await(0,r.promiseTimeout)(2),s.value=!1;let{scheme:i,defining:a}=e.value;if(!a)return;let l=(0,n.canvasCoordToCartesian)(t.position,o.value.scene);if(!l)return;let u=i.allowManualComplete?.(c.value);u&&_.setDefining(e.value,!1)}),(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.RIGHT_CLICK,async()=>{if(!e.value||!c.value)return;let{defining:t,sampled:n}=e.value;t&&(c.value.positions??=[],c.value.positions.length!==0&&(c.value.positions.splice(c.value.positions.length-1,1),n.setSample(c.value)))});let l=(0,i.ref)(),u=()=>{if(!e.value?.defining)l.value&&(l.value=void 0,o.value.container.parentElement.style.removeProperty(`cursor`));else{let t=e.value.scheme.definingCursor;l.value=(0,n.isFunction)(t)?t(c.value):t,l.value&&o.value?.container.parentElement.style.setProperty(`cursor`,l.value)}};(0,n.useCesiumEventListener)(()=>e.value?.definitionChanged,(e,t)=>{(t===`defining`||t===`sampled`)&&u()}),(0,i.watch)(e,()=>u())}function S(e,a,o){let s=(0,n.useViewer)(),c=(0,n.useDataSource)(new t.CustomDataSource),l=(0,n.useEntityScope)({collection:()=>c.value.entities}),u=(0,i.shallowRef)(),d=(0,i.shallowRef)(),f=e=>e?d.value?.id===e.id?v.ACTIVE:u.value?.id===e.id?v.HOVER:v.IDLE:v.IDLE,p=(e,t)=>{let r=e.skeletons,i=[];if(t||e.disabled)e.skeletons=[];else{let t=e.sampled.getValue(o()),s=e.defining,c=a.value===e,l=e.scheme.skeletons;l.forEach(a=>{let o=(0,n.isFunction)(a.disabled)?a.disabled({active:c,defining:s}):a.disabled;if(o)return;let l=a.format?.(t)??t?.positions??[];l.forEach((n,o)=>{let u=r.find(e=>e.index===o&&e.skeleton===a),d=a.render?.({defining:s,active:c,index:o,packable:t,positions:l,position:n,action:f(u)}),p=new y(d??{});u?p.propertyNames.forEach(e=>{e!==`id`&&(u[e]=p[e])}):u=p,u.plot=e,u.skeleton=a,u.index=o,i.push(u)})})}e.skeletons=i},{addGraphicEvent:m}=(0,n.useGraphicEvent)();return(0,i.watchEffect)(e=>{let t=m(`global`,`DRAG`,({event:e,pick:t,dragging:n,lockCamera:r})=>{if(t.id instanceof y&&l.scope.has(t.id)){let i=t.id,c=i.plot;if(c.defining)return;d.value=i;let l=i.skeleton,u=i.index,f=c.sampled.getValue(o());l.onDrag?.({viewer:s.value,sampled:c.sampled,packable:f,active:a.value===c,index:u,event:e,dragging:n,lockCamera:r})}else d.value=void 0},{cursor:({pick:e})=>{if(!a.value?.defining&&l.scope.has(e.id)){let t=e.id.skeleton;return(0,n.isFunction)(t?.cursor)?t.cursor(e):(0,i.toValue)(t?.cursor)}},dragCursor:({pick:e})=>{if(!a.value?.defining&&l.scope.has(e.id)){let t=e.id.skeleton;return(0,n.isFunction)(t?.dragCursor)?t.dragCursor(e):(0,i.toValue)(t?.dragCursor)}}});e(t)}),(0,r.onKeyStroke)(e=>{if(d.value){let t=d.value,n=t.plot,r=t.skeleton,i=t.index,a=n.sampled.getValue(o());r.onKeyPressed?.({viewer:s.value,sampled:n.sampled,packable:a,index:i,keyEvent:e})}}),(0,i.watchEffect)(e=>{let t=m(`global`,`HOVER`,({hovering:e,pick:t})=>{if(e&&t.id instanceof y&&l.scope.has(t.id)){let e=t.id;u.value=e}else u.value=void 0});e(t)}),(0,i.watchEffect)(e=>{let t=m(`global`,`LEFT_CLICK`,({event:e,pick:t})=>{if(t.id instanceof y&&l.scope.has(t.id)){let n=t.id;d.value=n;let r=n.plot,i=n.skeleton,c=n.index,l=r.sampled.getValue(o());i.onLeftClick?.({viewer:s.value,sampled:r.sampled,packable:l,active:a.value===r,defining:r.defining,index:c,event:e})}else d.value=void 0});e(t)}),(0,r.watchArray)(e,(e,t,n,r=[])=>{n.forEach(e=>p(e)),r.forEach(e=>p(e,!0))}),(0,n.useCesiumEventListener)(()=>e.value.map(e=>e.definitionChanged),(e,t,r,a)=>{if([`disabled`,`defining`,`scheme`,`sampled`,`time`].includes(t))(0,i.nextTick)(()=>p(e));else if(t===`skeletons`){let{added:e,removed:t}=(0,n.arrayDiff)(r,a);e.forEach(e=>l.add(e)),t.forEach(e=>l.remove(e))}}),(0,i.watch)(a,(e,t)=>{e&&p(e),t&&p(t)}),{dataSource:c}}function C(e){let r=e?.time||(0,i.shallowRef)(),a=(0,n.useViewer)(),o=()=>r.value?.clone()||new t.JulianDate(0,0),s=(0,i.shallowReactive)(new Set),c=(0,i.computed)(()=>Array.from(s)),l=(0,i.shallowRef)(),u=(0,i.shallowRef)();(0,n.useCesiumEventListener)([()=>l.value?.sampled.definitionChanged],()=>{u.value=l.value?.sampled.getValue(o())}),x(l,o),b(c,l,o),S(c,l,o),(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.LEFT_CLICK,e=>{if(l.value?.defining)return;let t=a.value?.scene.pick(e.position.clone());if(!(t?.id?.plot instanceof _)){if(!t){l.value=void 0;return}l.value=c.value.find(e=>(0,n.pickHitGraphic)(t,[...e.entities,...e.primitives,...e.groundPrimitives]))}});let d,f;(0,i.watch)(l,(e,t)=>{if(t&&t.defining){let e=t.sampled.getValue(o()),n=t.scheme.allowManualComplete?.(e);n?(_.setDefining(t,!1),d?.(t)):s.delete(t)}});let p=async e=>new Promise((t,n)=>{d=t,f=n;let r=e instanceof _?e:new _(e);return s.has(r)||s.add(r),l.value=r,t(r)}),m=e=>(e===l.value&&(l.value=void 0),s.has(e)?(s.delete(e),!0):!1);return{plots:c,time:r,operate:p,remove:m,cancel:f}}function w(){return{disabled:({active:e})=>!e,cursor:`pointer`,dragCursor:`crosshair`,onDrag({viewer:e,sampled:t,packable:r,event:i,index:a,lockCamera:o}){o();let s=(0,n.canvasCoordToCartesian)(i.endPosition,e.scene);if(s){let e=[...r.positions??[]];e[a]=s,t.setSample({time:r.time,derivative:r.derivative,positions:e})}},onKeyPressed({viewer:e,keyEvent:t,sampled:r,packable:i,index:a}){let o=(0,n.toCartographic)(e.camera.position)?.height;if(!o||![`ArrowUp`,`ArrowRight`,`ArrowDown`,`ArrowLeft`].includes(t.key))return;t.preventDefault();let s=0;switch(t.key){case`ArrowRight`:s=Math.PI/2;break;case`ArrowDown`:s=Math.PI;break;case`ArrowLeft`:s=-Math.PI/2;break;case`ArrowUp`:s=0;break}let c=(e.camera.heading+s)%(2*Math.PI),l=[...i.positions??[]],u=(0,n.toCartographic)(l[a]),d=o/1e5,f=d*Math.PI/180/1e3;u.latitude+=f*Math.cos(c),u.longitude+=f*Math.sin(c),l[a]=(0,n.toCartesian3)(u),r.setSample({time:i.time,derivative:i.derivative,positions:l})},render:({position:e,action:n})=>{let r={[v.IDLE]:t.Color.BLUE.withAlpha(.4),[v.HOVER]:t.Color.BLUE.withAlpha(.6),[v.ACTIVE]:t.Color.AQUA.withAlpha(1)};return{position:e,point:{pixelSize:8,color:r[n],disableDepthTestDistance:1/0,outlineWidth:1,outlineColor:t.Color.WHITE.withAlpha(.4)}}}}}function T(){let e=-1;return{disabled:({active:e,defining:t})=>!e||t,cursor:`pointer`,dragCursor:`crosshair`,format(e){let n=e.positions??[];return n.length<2?[]:n.map((e,r)=>{let i=r===n.length-1?n[0]:n[r+1];return t.Cartesian3.midpoint(e,i,new t.Cartesian3)})},onDrag({viewer:t,sampled:r,packable:i,event:a,index:o,lockCamera:s,dragging:c}){s();let l=(0,n.canvasCoordToCartesian)(a.endPosition,t.scene);if(!l)return;let u=[...i.positions??[]];e===-1?(e=o,u.splice(o+1,0,l)):u[e+1]=l,c||(e=-1),r.setSample({time:i.time,derivative:i.derivative,positions:u})},render:({position:e,action:n,active:r})=>{if(!r)return;let i={[v.IDLE]:t.Color.GREEN.withAlpha(.4),[v.HOVER]:t.Color.GREEN.withAlpha(.6),[v.ACTIVE]:t.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:i[n],disableDepthTestDistance:1/0,outlineWidth:1,outlineColor:t.Color.WHITE.withAlpha(.4)}}}}}function E(){let e=-1;return{disabled:({active:e,defining:t})=>!e||t,cursor:`pointer`,dragCursor:`crosshair`,format(e){let n=e.positions??[];if(n.length<2)return[];let r=[];for(let e=0;e<n.length-1;e++)r.push(t.Cartesian3.midpoint(n[e],n[e+1],new t.Cartesian3));return r},onDrag({viewer:t,sampled:r,packable:i,event:a,index:o,lockCamera:s,dragging:c}){s();let l=(0,n.canvasCoordToCartesian)(a.endPosition,t.scene);if(!l)return;let u=[...i.positions??[]];e===-1?(e=o,u.splice(o+1,0,l)):u[e+1]=l,c||(e=-1),r.setSample({time:i.time,derivative:i.derivative,positions:u})},render:({position:e,action:n})=>{let r={[v.IDLE]:t.Color.GREEN.withAlpha(.4),[v.HOVER]:t.Color.GREEN.withAlpha(.6),[v.ACTIVE]:t.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:r[n],disableDepthTestDistance:1/0,outlineWidth:1,outlineColor:t.Color.WHITE.withAlpha(.4)}}}}}let D=`data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m18 9l3 3l-3 3m-3-3h6M6 9l-3 3l3 3m-3-3h6m0 6l3 3l3-3m-3-3v6m3-15l-3-3l-3 3m3-3v6"/></svg>`)}`;function O(){return{disabled:({active:e,defining:t})=>!e||t,cursor:`pointer`,dragCursor:`crosshair`,format(e){let r=e.positions??[];if(r.length===0)return[];if(r.length===1)return[r[0]];{let e=t.Rectangle.center(t.Rectangle.fromCartesianArray(r));return[(0,n.toCartesian3)(e)]}},onDrag({viewer:e,sampled:r,packable:i,event:a,lockCamera:o,dragging:s}){s&&o();let c=(0,n.canvasCoordToCartesian)(a.startPosition,e.scene),l=(0,n.canvasCoordToCartesian)(a.endPosition,e.scene);if(!c||!l)return;let u=t.Cartesian3.subtract(l,c,new t.Cartesian3),d=[...i.positions??[]];r.setSample({time:i.time,derivative:i.derivative,positions:d.map(e=>t.Cartesian3.add(e,u,new t.Cartesian3))})},render:({position:e,action:n})=>{let r={[v.IDLE]:t.Color.WHITE,[v.HOVER]:t.Color.WHITE,[v.ACTIVE]:t.Color.AQUA.withAlpha(1)};return{position:e,billboard:{image:D,width:20,height:20,color:r[n],pixelOffset:new t.Cartesian3(0,-20),horizontalOrigin:t.HorizontalOrigin.CENTER,verticalOrigin:t.VerticalOrigin.BOTTOM,disableDepthTestDistance:1/0}}}}}function k(e){if(e.length<3)throw Error(`positions must >= 3`);if(e.length===3)return[[e[0].clone(),e[1].clone(),e[2].clone()]];let n=t.CoplanarPolygonGeometry.createGeometry(t.CoplanarPolygonGeometry.fromPositions({positions:e,vertexFormat:t.VertexFormat.POSITION_ONLY}));if(!n)throw Error(`positions无法组成有效的geometry,检查点位是否错误`);let r=n.attributes.position.values,i=n.indices,a=[];for(let e=0;e<i.length;e+=3){let n=t.Cartesian3.unpack(r,i[e]*3,new t.Cartesian3),o=t.Cartesian3.unpack(r,i[e+1]*3,new t.Cartesian3),s=t.Cartesian3.unpack(r,i[e+2]*3,new t.Cartesian3);a.push([n,o,s])}return a}async function A(e){let{positions:n,scene:r,classificationType:i=t.ClassificationType.BOTH,terrainProvider:a=r.terrainProvider}=e,o=[t.ClassificationType.BOTH,t.ClassificationType.CESIUM_3D_TILE].includes(i),s=[t.ClassificationType.BOTH,t.ClassificationType.TERRAIN].includes(i),c=new Promise(e=>{o?r.clampToHeightMostDetailed(n.map(e=>e.clone())).then(e).catch(t=>{console.warn(t),e([])}):e([])}),l=new Promise(e=>{s&&a?(0,t.sampleTerrainMostDetailed)(a,n.map(e=>t.Cartographic.fromCartesian(e))).then(t=>e(t)).catch(t=>{console.warn(t),e([])}):e([])}),[u,d]=await Promise.all([c,l]),f=[];return n.forEach((e,n)=>{let r=u[n]||d[n]?t.Ellipsoid.WGS84.cartographicToCartesian(d[n]):e.clone();f.push(r)}),f}function j(e){let n=e?.clampToGround??!1,r=e?.classificationType??t.ClassificationType.BOTH,i=Math.floor(e?.density??10);return{scene:e?.scene,clampToGround:n,classificationType:r,terrainProvider:e?.terrainProvider,density:i}}async function M(e,n){if(e.length<3)throw Error(`positions must >= 3`);let{density:r,scene:i,clampToGround:a,classificationType:o,terrainProvider:s}=j(n);if(r<=0)throw Error(`options.density must > 0`);let c=t.Rectangle.fromCartesianArray(e),l=c.north-c.south,u=c.east-c.west,d=Math.max(u,l),f=d/r,p=t.PolygonGeometry.fromPositions({positions:e,vertexFormat:t.PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,granularity:f}),m=t.PolygonGeometry.createGeometry(p),h=m.attributes.position.values;if(!m||!h)throw Error(`positions无法组成有效的geometry,检查点位是否错误`);let g=m.indices,_=[];for(let e=0;e<g.length;e+=3){let n=t.Cartesian3.unpack(h,g[e]*3,new t.Cartesian3),r=t.Cartesian3.unpack(h,g[e+1]*3,new t.Cartesian3),i=t.Cartesian3.unpack(h,g[e+2]*3,new t.Cartesian3);_.push(n,r,i)}if(a){if(!i)throw Error("scene is required on `clampToGround == true`.");let e=await A({scene:i,terrainProvider:s,positions:_,classificationType:o});_=e}let v=[];for(;_?.length;){let[e,t,n]=_.splice(0,3);v.push([e,t,n])}return v}function N(e,n,r){let i=t.Cartesian3.subtract(e,n,new t.Cartesian3),a=t.Cartesian3.subtract(r,n,new t.Cartesian3),o=t.Cartesian3.cross(i,a,i);return t.Cartesian3.magnitude(o)*.5}function P(e){let n=e?.clampToGround??!1,r=e?.classificationType??t.ClassificationType.BOTH,i=Math.floor(e?.density??10);return{scene:e?.scene,clampToGround:n,classificationType:r,terrainProvider:e?.terrainProvider,density:i}}async function F(e,t){if(e.length<2)throw Error(`positions.length must >= 2`);let{density:n,scene:r,clampToGround:i,classificationType:a,terrainProvider:o}=P(t);if(n<=0)throw Error(`options.density must > 0`);if(!i){let t=k(e);return t.reduce((e,t)=>e+=N(...t),0)}let s=await M(e,{density:n,scene:r,clampToGround:i,classificationType:a,terrainProvider:o});return s.reduce((e,t)=>e+=N(...t),0)}let I=new p({type:`measureArea`,allowManualComplete:e=>e.positions.length>=3,skeletons:[w,T],initEntites:()=>[new t.Entity({label:{font:`14pt`},polyline:{material:t.Color.YELLOW.withAlpha(.5)},polygon:{material:t.Color.YELLOW.withAlpha(.5)}})],render(e){let{mouse:r,packable:i}=e,a=e.previous.entities?.[0]??new t.Entity({label:{font:`14pt`},polyline:{material:t.Color.YELLOW.withAlpha(.5)},polygon:{material:t.Color.YELLOW.withAlpha(.5)}}),o=[...i.positions??[]];return r&&o.push(r),o.length===2?(a.position=void 0,a.label.text=void 0,a.polygon.hierarchy=void 0,a.polyline.positions=new t.CallbackProperty(()=>o,!1)):o.length>=3?(o.push(o[0]),a.position=new t.ConstantPositionProperty((0,n.toCartesian3)(t.Rectangle.center(t.Rectangle.fromCartesianArray(o)))),a.label.text=new t.ConstantProperty(``),F(o).then(e=>{let n=``;n=e/1e3/1e3>10?`${(e/1e3/1e3).toFixed(2)}km²`:`${(+e).toFixed(2)}m²`,a.label.text=new t.ConstantProperty(n)}),a.polyline.positions=void 0,a.polygon.hierarchy=new t.CallbackProperty(()=>o.length>=3?new t.PolygonHierarchy([...o]):void 0,!1)):(a.position=void 0,a.polygon.hierarchy=void 0,a.polyline.positions=void 0),{entities:[a]}}}),L=new p({type:`billboard`,complete:e=>e.positions.length>=1,skeletons:[O],initEntites:()=>[new t.Entity({billboard:{image:`/favicon.svg`,width:32,height:32}})],render(e){let{mouse:n,packable:r}=e,i=e.previous.entities?.[0]??new t.Entity({billboard:{}}),a=r.positions?.[0]??n;return i.position=new t.CallbackPositionProperty(()=>a,!0),{entities:[i]}}}),R=new p({type:`label`,complete:e=>e.positions.length>=1,skeletons:[O],initEntites:()=>[new t.Entity({label:{text:`Label`}})],render(e){let{mouse:n,packable:r}=e,i=e.previous.entities?.[0]??new t.Entity({label:{}}),a=r.positions?.[0]??n;return i.position=new t.CallbackPositionProperty(()=>a,!0),{entities:[i]}}}),z=new p({type:`polygon`,allowManualComplete:e=>e.positions.length>=3,skeletons:[w,T,O],initEntites:()=>[new t.Entity({polyline:{material:t.Color.YELLOW.withAlpha(.5)},polygon:{material:t.Color.YELLOW.withAlpha(.5)}})],render(e){let{mouse:n,packable:r}=e,i=e.previous.entities?.[0]??new t.Entity({polyline:{material:t.Color.YELLOW.withAlpha(.5)},polygon:{material:t.Color.YELLOW.withAlpha(.5)}}),a=[...r.positions??[]];return n&&a.push(n),a.length===2?(i.polygon.hierarchy=void 0,i.polyline.positions=new t.CallbackProperty(()=>a,!1)):a.length>=3?(i.polyline.positions=void 0,i.polygon.hierarchy=new t.CallbackProperty(()=>(a.push(a[0]),a.length>=3?new t.PolygonHierarchy([...a]):void 0),!1)):(i.polygon.hierarchy=void 0,i.polyline.positions=void 0),{entities:[i]}}}),B=new p({type:`polyline`,allowManualComplete:e=>e.positions.length>=2,skeletons:[w,E,O],initEntites:()=>[new t.Entity({polyline:{width:1}})],render(e){let{mouse:n,packable:r}=e,i=e.previous.entities?.[0]??new t.Entity({polyline:{}});return i.polyline.positions=new t.CallbackProperty(()=>{let e=[...r.positions??[]].concat(n?[n]:[]);return e.length>=2?e:[]},!1),{entities:[i]}}}),V=new p({type:`rectangle`,complete:e=>e.positions.length>=2,skeletons:[w,T,O],initEntites:()=>[new t.Entity({rectangle:{material:t.Color.YELLOW.withAlpha(.5)}})],render(e){let{mouse:n,packable:r}=e,i=e.previous.entities?.[0]??new t.Entity({rectangle:{material:t.Color.YELLOW.withAlpha(.5)}}),a=[...r.positions??[]];return n&&a.push(n),a.length>=2?i.rectangle.coordinates=new t.CallbackProperty(()=>t.Rectangle.fromCartesianArray(a),!1):i.rectangle.coordinates=void 0,{entities:[i]}}});exports.PlotAction=v,exports.PlotFeature=_,exports.PlotScheme=p,exports.PlotSkeletonEntity=y,exports.SampledPlotProperty=g,exports.SampledPlotStrategy=m,exports.control=w,exports.interval=T,exports.intervalNonclosed=E,exports.moved=O,exports.schemeBillboard=L,exports.schemeLabel=R,exports.schemeMeasureArea=I,exports.schemePolygon=z,exports.schemePolyline=B,exports.schemeRectangle=V,exports.usePlot=C})(this.Vesium=this.Vesium||{},Cesium,Vesium,VueUse,Vue);
|
|
1
|
+
(function(e,t,n,r,i,a,o){var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e},m=(e,t,n)=>(n=e==null?{}:s(d(e)),p(t||!e||!e.__esModule?c(n,`default`,{value:e,enumerable:!0}):n,e));t=m(t),n=m(n),r=m(r),i=m(i),a=m(a),o=m(o);var h=class e{constructor(e){this.type=e.type,this.complete=e.complete,this.allowManualComplete=e.allowManualComplete,this.definingCursor=e.definingCursor??`crosshair`,this.skeletons=e.skeletons?.map(e=>e())??[],this.initRender=e.initRender,this.render=e.render}type;complete;allowManualComplete;definingCursor;skeletons;initRender;render;static _record=new Map;static getCacheTypes(){return[...this._record.keys()]}static getCache(t){return e._record.get(t)}static setCache(t){(0,n.assertError)(!t.type,"`scheme.type` is required"),e._record.set(t.type,t)}static resolve(t){if(typeof t==`string`){let n=e.getCache(t);return(0,r.assert)(!!n,`scheme ${t} not found`),n}else if(t instanceof e)return t;else return new e(t)}};let g=function(e){return e[e.NEAR=0]=`NEAR`,e[e.CYCLE=1]=`CYCLE`,e[e.STRICT=2]=`STRICT`,e}({}),_=(e,n,r,i)=>i===0?{time:e,positions:n.positions?.map(e=>e.clone()),derivative:n.derivative}:i===1?{time:e,positions:r.positions?.map(e=>e.clone()),derivative:n.derivative}:{time:e,positions:r.positions?.map((e,r)=>{let a=n.positions?.[r];return a?t.Cartesian3.lerp(a,e,i,new t.Cartesian3):e}),derivative:n.derivative};var v=class e{constructor(e){this.interpolationAlgorithm=e?.interpolationAlgorithm,this.strategy=e?.strategy??g.NEAR,e?.packables?.forEach(e=>this.setSample(e)),this._times.length||this.setSample({time:new t.JulianDate(0,0),positions:[],derivative:void 0})}static defaultInterpolationAlgorithm=_;strategy;interpolationAlgorithm;_times=[];_sampleds=[];_derivatives=[];get isConstant(){return this._times.length===0}_definitionChanged=new t.Event;get definitionChanged(){return this._definitionChanged}getTimes(){return this._times.map(e=>e.clone())}getIndexScope(e){if(!this._times.length)return;let n=this._times[0],r=this._times[this._times.length-1];if(t.JulianDate.lessThan(e,n)||t.JulianDate.greaterThan(e,r))switch(this.strategy){case g.STRICT:return;case g.NEAR:e=t.JulianDate.lessThan(e,this._times[0])?this._times[0].clone():this._times[this._times.length-1].clone();break;case g.CYCLE:{let n=t.JulianDate.toDate(this._times[0]).getTime(),r=t.JulianDate.toDate(this._times[this._times.length-1]).getTime()-n,i=(t.JulianDate.toDate(e).getTime()-n)%r,a=new Date(n+i);e=t.JulianDate.fromDate(a);break}}let i=this._times.findIndex(n=>t.JulianDate.lessThanOrEquals(e,n)),a=Math.min(i,this._times.length-1),o=t.JulianDate.toDate(this._times[i]).getTime(),s=t.JulianDate.toDate(this._times[a]).getTime();return{prevIndex:i,nextIndex:a,proportion:(t.JulianDate.toDate(e).getTime()-o)/(s-o)||0}}getValue(t,n){if(n??={time:t,positions:[]},Object.assign(n,{time:t?.clone(),positions:[],derivative:void 0}),!t)return n.time=this._times[0].clone(),n.positions=this._sampleds[0]?.map(e=>e.clone(e)),n.derivative=this._derivatives[0],n;let r=this.getIndexScope(t);if(!r)return n;n.time=t;let{prevIndex:i,nextIndex:a,proportion:o}=r,s={time:this._times[i],positions:this._sampleds[i],derivative:this._derivatives[i]},c={time:this._times[a],positions:this._sampleds[a],derivative:this._derivatives[a]},l=(this.interpolationAlgorithm||e.defaultInterpolationAlgorithm)(t,s,c,o);return Object.assign(n,l),n}setSample(e){let n=e.time?.clone()??this._times[0].clone(),r=e.positions?.map(e=>e.clone())??[],i=e.derivative,a=this._times.findIndex(e=>t.JulianDate.equals(n,e));a===-1?this._times.length===0?(this._times[0]=n,this._sampleds[0]=r,this._derivatives[0]=e.derivative):t.JulianDate.lessThan(n,this._times[0])?(this._times.splice(0,0,n),this._sampleds.splice(0,0,r),this._derivatives.splice(0,0,i)):t.JulianDate.greaterThan(n,this._times[this._times.length-1])&&(this._times.push(n),this._sampleds.push(r),this._derivatives.push(i)):(this._times[a]=n,this._sampleds[a]=r,this._derivatives[a]=e.derivative),this.definitionChanged.raiseEvent(this)}setSamples(e){e.forEach(e=>this.setSample(e))}removeSample(e){let t=this._times.findIndex(t=>t.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 n=0;n<this._times.length;n++){let r=this._times[n];t.TimeInterval.contains(e,r)&&this.removeSample(r)}}equals(e){return e===this}},y=class{constructor(e){let{id:n,disabled:r=!1,sampled:i}=e;this._id=n||(0,t.createGuid)(),this._scheme=h.resolve(e.scheme),this._definitionChanged=new t.Event,this._defining=!0,this._disabled=r,this._sampled=i instanceof v?i:new v(i),this._sampled.definitionChanged.addEventListener(e=>this._definitionChanged.raiseEvent(this,`sampled`,e,e),this);let a=this._scheme.initRender?.()??{};this._entities=[...a.entities??[]],this._primitives=[...a.primitives??[]],this._groundPrimitives=[...a.groundPrimitives??[]],this._skeletons=[]}_id;get id(){return this._id}_scheme;get scheme(){return this._scheme}_definitionChanged;get definitionChanged(){return this._definitionChanged}_defining;get defining(){return this._defining}static setDefining(e,t){e._defining!==t&&(e._definitionChanged.raiseEvent(e,`defining`,t,e._defining),e._defining=t)}_disabled;get disabled(){return this._disabled}set disabled(e){this.disabled=e}_sampled;get sampled(){return this._sampled}_entities;get entities(){return this._entities}set entities(e){this._definitionChanged.raiseEvent(this,`entities`,e,this._entities),this._entities=e}_primitives;get primitives(){return this._primitives}set primitives(e){this._definitionChanged.raiseEvent(this,`primitives`,e,this._primitives),this._primitives=e}_groundPrimitives;get groundPrimitives(){return this._groundPrimitives}set groundPrimitives(e){this._definitionChanged.raiseEvent(this,`groundPrimitives`,e,this._groundPrimitives),this._groundPrimitives=e}_skeletons;get skeletons(){return this._skeletons}set skeletons(e){this._definitionChanged.raiseEvent(this,`skeletons`,e,this._skeletons),this._skeletons=e}};let b=function(e){return e[e.IDLE=0]=`IDLE`,e[e.HOVER=1]=`HOVER`,e[e.ACTIVE=2]=`ACTIVE`,e}({});var x=class extends t.Entity{constructor(e){super(e)}};function S(e,a,o){let s=(0,n.useViewer)(),c=(0,n.usePrimitive)(new t.PrimitiveCollection),l=(0,n.usePrimitive)(new t.PrimitiveCollection,{collection:`ground`}),u=(0,n.useDataSource)(new t.CustomDataSource),d=(0,n.useEntityScope)({collection:()=>u.value.entities}),f=(0,n.usePrimitiveScope)({collection:()=>c.value}),p=(0,n.usePrimitiveScope)({collection:()=>l.value}),m=(0,i.shallowRef)();(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.MOUSE_MOVE,e=>{m.value=(0,n.canvasCoordToCartesian)(e?.endPosition,s.value.scene)}),(0,r.watchArray)(e,(e,t,n,r=[])=>{r.forEach(e=>{d.removeWhere(t=>e.entities.includes(t)),f.removeWhere(t=>e.primitives.includes(t)),p.removeWhere(t=>e.groundPrimitives.includes(t))}),n.forEach(e=>{e.entities.forEach(e=>d.add(e)),e.primitives.forEach(e=>f.add(e)),e.groundPrimitives.forEach(e=>p.add(e))})},{immediate:!0,flush:`post`}),(0,n.useCesiumEventListener)(()=>e.value.map(e=>e.definitionChanged),(e,t,r,i)=>{if(t===`entities`){let{added:e,removed:t}=(0,n.arrayDiff)(r,i);e.forEach(e=>d.add(e)),t.forEach(e=>d.remove(e))}else if(t===`primitives`){let{added:e,removed:t}=(0,n.arrayDiff)(r,i);e.forEach(e=>f.add(e)),t.forEach(e=>f.remove(e))}else if(t===`groundPrimitives`){let{added:e,removed:t}=(0,n.arrayDiff)(r,i);e.forEach(e=>p.add(e)),t.forEach(e=>p.remove(e))}});let h=async e=>{await(0,i.nextTick)();let t=e.sampled.getValue(o()),n=e.defining?m.value:void 0,r=await e.scheme.render?.({packable:t,mouse:n,defining:e.defining,previous:{entities:e.entities,primitives:e.primitives,groundPrimitives:e.groundPrimitives},getPositions(){let e=t.positions;return n&&e.push(n),e}});e.entities=r?.entities??[],e.primitives=r?.primitives??[],e.groundPrimitives=r?.groundPrimitives??[]};return(0,i.watch)(a,(e,t)=>{t&&h(t)}),(0,n.useCesiumEventListener)(()=>e.value.map(e=>e.definitionChanged),(e,t)=>{[`disabled`,`defining`,`scheme`,`sampled`,`time`].includes(t)&&h(e)}),(0,i.watch)(m,()=>{e.value.forEach(e=>e.defining&&h(e))}),{primitives:(0,i.computed)(()=>Array.from(f.scope)),groundPrimitives:(0,i.computed)(()=>Array.from(f.scope)),entities:(0,i.computed)(()=>Array.from(d.scope))}}function C(e,a){let o=(0,n.useViewer)(),s=(0,i.ref)(!1),c=(0,i.computed)(()=>e.value?.sampled.getValue(a()));(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.LEFT_CLICK,async t=>{if(await(0,r.promiseTimeout)(1),!e.value||!c.value||s.value)return;let{scheme:i,defining:a,sampled:l}=e.value;if(!a)return;let u=(0,n.canvasCoordToCartesian)(t.position,o.value.scene);u&&(c.value.positions??=[],c.value.positions.push(u),l.setSample(c.value),i.complete?.(c.value)&&y.setDefining(e.value,!1))}),(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,async t=>{if(!e.value||!c.value)return;s.value=!0,await(0,r.promiseTimeout)(2),s.value=!1;let{scheme:i,defining:a}=e.value;a&&(0,n.canvasCoordToCartesian)(t.position,o.value.scene)&&i.allowManualComplete?.(c.value)&&y.setDefining(e.value,!1)}),(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.RIGHT_CLICK,async()=>{if(!e.value||!c.value)return;let{defining:t,sampled:n}=e.value;t&&(c.value.positions??=[],c.value.positions.length!==0&&(c.value.positions.splice(c.value.positions.length-1,1),n.setSample(c.value)))});let l=(0,i.ref)(),u=()=>{if(!e.value?.defining)l.value&&(l.value=void 0,o.value.container.parentElement.style.removeProperty(`cursor`));else{let t=e.value.scheme.definingCursor;l.value=(0,n.isFunction)(t)?t(c.value):t,l.value&&o.value?.container.parentElement.style.setProperty(`cursor`,l.value)}};(0,n.useCesiumEventListener)(()=>e.value?.definitionChanged,(e,t)=>{(t===`defining`||t===`sampled`)&&u()}),(0,i.watch)(e,()=>u())}function w(e,a,o){let s=(0,n.useViewer)(),c=(0,n.useDataSource)(new t.CustomDataSource),l=(0,n.useEntityScope)({collection:()=>c.value.entities}),u=(0,i.shallowRef)(),d=(0,i.shallowRef)(),f=e=>e?d.value?.id===e.id?b.ACTIVE:u.value?.id===e.id?b.HOVER:b.IDLE:b.IDLE,p=(e,t)=>{let r=e.skeletons,i=[];if(t||e.disabled)e.skeletons=[];else{let t=e.sampled.getValue(o()),s=e.defining,c=a.value===e;e.scheme.skeletons.forEach(a=>{if((0,n.isFunction)(a.disabled)?a.disabled({active:c,defining:s}):a.disabled)return;let o=a.format?.(t)??t?.positions??[];o.forEach((n,l)=>{let u=r.find(e=>e.index===l&&e.skeleton===a),d=a.render?.({defining:s,active:c,index:l,packable:t,positions:o,position:n,action:f(u)}),p=new x(d??{});u?p.propertyNames.forEach(e=>{e!==`id`&&(u[e]=p[e])}):u=p,u.plot=e,u.skeleton=a,u.index=l,i.push(u)})})}e.skeletons=i},m=(0,n.useGraphicEvent)();return(0,i.watchEffect)(e=>{e(m.add(`global`,`DRAG`,({event:e,pick:t,dragging:n,lockCamera:r})=>{if(t.id instanceof x&&l.scope.has(t.id)){let i=t.id,c=i.plot;if(c.defining)return;d.value=i;let l=i.skeleton,u=i.index,f=c.sampled.getValue(o());l.onDrag?.({viewer:s.value,sampled:c.sampled,packable:f,active:a.value===c,index:u,event:e,dragging:n,lockCamera:r})}else d.value=void 0},{cursor:({pick:e})=>{if(!a.value?.defining&&l.scope.has(e.id)){let t=e.id.skeleton;return(0,n.isFunction)(t?.cursor)?t.cursor(e):(0,i.toValue)(t?.cursor)}},dragCursor:({pick:e})=>{if(!a.value?.defining&&l.scope.has(e.id)){let t=e.id.skeleton;return(0,n.isFunction)(t?.dragCursor)?t.dragCursor(e):(0,i.toValue)(t?.dragCursor)}}}))}),(0,r.onKeyStroke)(e=>{if(d.value){let t=d.value,n=t.plot,r=t.skeleton,i=t.index,a=n.sampled.getValue(o());r.onKeyPressed?.({viewer:s.value,sampled:n.sampled,packable:a,index:i,keyEvent:e})}}),(0,i.watchEffect)(e=>{e(m.add(`global`,`HOVER`,({hovering:e,pick:t})=>{e&&t.id instanceof x&&l.scope.has(t.id)?u.value=t.id:u.value=void 0}))}),(0,i.watchEffect)(e=>{e(m.add(`global`,`LEFT_CLICK`,({event:e,pick:t})=>{if(t.id instanceof x&&l.scope.has(t.id)){let n=t.id;d.value=n;let r=n.plot,i=n.skeleton,c=n.index,l=r.sampled.getValue(o());i.onLeftClick?.({viewer:s.value,sampled:r.sampled,packable:l,active:a.value===r,defining:r.defining,index:c,event:e})}else d.value=void 0}))}),(0,r.watchArray)(e,(e,t,n,r=[])=>{n.forEach(e=>p(e)),r.forEach(e=>p(e,!0))}),(0,n.useCesiumEventListener)(()=>e.value.map(e=>e.definitionChanged),(e,t,r,a)=>{if([`disabled`,`defining`,`scheme`,`sampled`,`time`].includes(t))(0,i.nextTick)(()=>p(e));else if(t===`skeletons`){let{added:e,removed:t}=(0,n.arrayDiff)(r,a);e.forEach(e=>l.add(e)),t.forEach(e=>l.remove(e))}}),(0,i.watch)(a,(e,t)=>{e&&p(e),t&&p(t)}),{dataSource:c}}function T(e){let r=e?.time||(0,i.shallowRef)(),a=(0,n.useViewer)(),o=()=>r.value?.clone()||new t.JulianDate(0,0),s=(0,i.shallowReactive)(new Set),c=(0,i.computed)(()=>Array.from(s)),l=(0,i.shallowRef)(),u=(0,i.shallowRef)();(0,n.useCesiumEventListener)([()=>l.value?.sampled.definitionChanged],()=>{u.value=l.value?.sampled.getValue(o())}),C(l,o),S(c,l,o),w(c,l,o),(0,n.useScreenSpaceEventHandler)(t.ScreenSpaceEventType.LEFT_CLICK,e=>{if(l.value?.defining)return;let t=a.value?.scene.pick(e.position.clone());if(!(t?.id?.plot instanceof y)){if(!t){l.value=void 0;return}l.value=c.value.find(e=>(0,n.pickHitGraphic)(t,[...e.entities,...e.primitives,...e.groundPrimitives]))}});let d,f;return(0,i.watch)(l,(e,t)=>{if(t&&t.defining){let e=t.sampled.getValue(o());t.scheme.allowManualComplete?.(e)?(y.setDefining(t,!1),d?.(t)):s.delete(t)}}),{plots:c,time:r,operate:async e=>new Promise((t,n)=>{d=t,f=n;let r=e instanceof y?e:new y(e);return s.has(r)||s.add(r),l.value=r,t(r)}),remove:e=>(e===l.value&&(l.value=void 0),s.has(e)?(s.delete(e),!0):!1),cancel:f}}function E(){return{disabled:({active:e})=>!e,cursor:`pointer`,dragCursor:`crosshair`,onDrag({viewer:e,sampled:t,packable:r,event:i,index:a,lockCamera:o}){o();let s=(0,n.canvasCoordToCartesian)(i.endPosition,e.scene);if(s){let e=[...r.positions??[]];e[a]=s,t.setSample({time:r.time,derivative:r.derivative,positions:e})}},onKeyPressed({viewer:e,keyEvent:t,sampled:r,packable:i,index:a}){let o=(0,n.toCartographic)(e.camera.position)?.height;if(!o||![`ArrowUp`,`ArrowRight`,`ArrowDown`,`ArrowLeft`].includes(t.key))return;t.preventDefault();let s=0;switch(t.key){case`ArrowRight`:s=Math.PI/2;break;case`ArrowDown`:s=Math.PI;break;case`ArrowLeft`:s=-Math.PI/2;break;case`ArrowUp`:s=0;break}let c=(e.camera.heading+s)%(2*Math.PI),l=[...i.positions??[]],u=(0,n.toCartographic)(l[a]),d=o/1e5*Math.PI/180/1e3;u.latitude+=d*Math.cos(c),u.longitude+=d*Math.sin(c),l[a]=(0,n.toCartesian3)(u),r.setSample({time:i.time,derivative:i.derivative,positions:l})},render:({position:e,action:n})=>({position:e,point:{pixelSize:8,color:{[b.IDLE]:t.Color.BLUE.withAlpha(.4),[b.HOVER]:t.Color.BLUE.withAlpha(.6),[b.ACTIVE]:t.Color.AQUA.withAlpha(1)}[n],disableDepthTestDistance:1/0,outlineWidth:1,outlineColor:t.Color.WHITE.withAlpha(.4)}})}}function D(){let e=-1;return{disabled:({active:e,defining:t})=>!e||t,cursor:`pointer`,dragCursor:`crosshair`,format(e){let n=e.positions??[];return n.length<2?[]:n.map((e,r)=>{let i=r===n.length-1?n[0]:n[r+1];return t.Cartesian3.midpoint(e,i,new t.Cartesian3)})},onDrag({viewer:t,sampled:r,packable:i,event:a,index:o,lockCamera:s,dragging:c}){s();let l=(0,n.canvasCoordToCartesian)(a.endPosition,t.scene);if(!l)return;let u=[...i.positions??[]];e===-1?(e=o,u.splice(o+1,0,l)):u[e+1]=l,c||(e=-1),r.setSample({time:i.time,derivative:i.derivative,positions:u})},render:({position:e,action:n,active:r})=>{if(r)return{position:e,point:{pixelSize:6,color:{[b.IDLE]:t.Color.GREEN.withAlpha(.4),[b.HOVER]:t.Color.GREEN.withAlpha(.6),[b.ACTIVE]:t.Color.GREEN.withAlpha(1)}[n],disableDepthTestDistance:1/0,outlineWidth:1,outlineColor:t.Color.WHITE.withAlpha(.4)}}}}}function O(){let e=-1;return{disabled:({active:e,defining:t})=>!e||t,cursor:`pointer`,dragCursor:`crosshair`,format(e){let n=e.positions??[];if(n.length<2)return[];let r=[];for(let e=0;e<n.length-1;e++)r.push(t.Cartesian3.midpoint(n[e],n[e+1],new t.Cartesian3));return r},onDrag({viewer:t,sampled:r,packable:i,event:a,index:o,lockCamera:s,dragging:c}){s();let l=(0,n.canvasCoordToCartesian)(a.endPosition,t.scene);if(!l)return;let u=[...i.positions??[]];e===-1?(e=o,u.splice(o+1,0,l)):u[e+1]=l,c||(e=-1),r.setSample({time:i.time,derivative:i.derivative,positions:u})},render:({position:e,action:n})=>({position:e,point:{pixelSize:6,color:{[b.IDLE]:t.Color.GREEN.withAlpha(.4),[b.HOVER]:t.Color.GREEN.withAlpha(.6),[b.ACTIVE]:t.Color.GREEN.withAlpha(1)}[n],disableDepthTestDistance:1/0,outlineWidth:1,outlineColor:t.Color.WHITE.withAlpha(.4)}})}}function k(){return{disabled:({active:e,defining:t})=>!e||t,cursor:`pointer`,dragCursor:`crosshair`,format(e){let r=e.positions??[];return r.length===0?[]:r.length===1?[r[0]]:[(0,n.toCartesian3)(t.Rectangle.center(t.Rectangle.fromCartesianArray(r)))]},onDrag({viewer:e,sampled:r,packable:i,event:a,lockCamera:o,dragging:s}){s&&o();let c=(0,n.canvasCoordToCartesian)(a.startPosition,e.scene),l=(0,n.canvasCoordToCartesian)(a.endPosition,e.scene);if(!c||!l)return;let u=t.Cartesian3.subtract(l,c,new t.Cartesian3),d=[...i.positions??[]];r.setSample({time:i.time,derivative:i.derivative,positions:d.map(e=>t.Cartesian3.add(e,u,new t.Cartesian3))})},render:({position:e,action:n})=>({position:e,billboard:{image:`data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2232%22%20height%3D%2232%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20%20stroke%3D%22%23ffffff%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20stroke-width%3D%222%22%20d%3D%22m18%209l3%203l-3%203m-3-3h6M6%209l-3%203l3%203m-3-3h6m0%206l3%203l3-3m-3-3v6m3-15l-3-3l-3%203m3-3v6%22%2F%3E%3C%2Fsvg%3E`,width:20,height:20,color:{[b.IDLE]:t.Color.WHITE,[b.HOVER]:t.Color.WHITE,[b.ACTIVE]:t.Color.AQUA.withAlpha(1)}[n],pixelOffset:new t.Cartesian3(0,-20),horizontalOrigin:t.HorizontalOrigin.CENTER,verticalOrigin:t.VerticalOrigin.BOTTOM,disableDepthTestDistance:1/0}})}}function ee(e){if(e.length<3)throw Error(`positions must >= 3`);if(e.length===3)return[[e[0].clone(),e[1].clone(),e[2].clone()]];let n=t.CoplanarPolygonGeometry.createGeometry(t.CoplanarPolygonGeometry.fromPositions({positions:e,vertexFormat:t.VertexFormat.POSITION_ONLY}));if(!n)throw Error(`positions无法组成有效的geometry,检查点位是否错误`);let r=n.attributes.position.values,i=n.indices,a=[];for(let e=0;e<i.length;e+=3){let n=t.Cartesian3.unpack(r,i[e]*3,new t.Cartesian3),o=t.Cartesian3.unpack(r,i[e+1]*3,new t.Cartesian3),s=t.Cartesian3.unpack(r,i[e+2]*3,new t.Cartesian3);a.push([n,o,s])}return a}async function A(e){let{positions:n,scene:r,classificationType:i=t.ClassificationType.BOTH,terrainProvider:a=r.terrainProvider}=e,o=[t.ClassificationType.BOTH,t.ClassificationType.CESIUM_3D_TILE].includes(i),s=[t.ClassificationType.BOTH,t.ClassificationType.TERRAIN].includes(i),c=new Promise(e=>{o?r.clampToHeightMostDetailed(n.map(e=>e.clone())).then(e).catch(t=>{console.warn(t),e([])}):e([])}),l=new Promise(e=>{s&&a?(0,t.sampleTerrainMostDetailed)(a,n.map(e=>t.Cartographic.fromCartesian(e))).then(t=>e(t)).catch(t=>{console.warn(t),e([])}):e([])}),[u,d]=await Promise.all([c,l]),f=[];return n.forEach((e,n)=>{let r=u[n]||d[n]?t.Ellipsoid.WGS84.cartographicToCartesian(d[n]):e.clone();f.push(r)}),f}function j(e){let n=e?.clampToGround??!1,r=e?.classificationType??t.ClassificationType.BOTH,i=Math.floor(e?.density??10);return{scene:e?.scene,clampToGround:n,classificationType:r,terrainProvider:e?.terrainProvider,density:i}}async function M(e,n){if(e.length<3)throw Error(`positions must >= 3`);let{density:r,scene:i,clampToGround:a,classificationType:o,terrainProvider:s}=j(n);if(r<=0)throw Error(`options.density must > 0`);let c=t.Rectangle.fromCartesianArray(e),l=c.north-c.south,u=c.east-c.west,d=Math.max(u,l)/r,f=t.PolygonGeometry.fromPositions({positions:e,vertexFormat:t.PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,granularity:d}),p=t.PolygonGeometry.createGeometry(f),m=p.attributes.position.values;if(!p||!m)throw Error(`positions无法组成有效的geometry,检查点位是否错误`);let h=p.indices,g=[];for(let e=0;e<h.length;e+=3){let n=t.Cartesian3.unpack(m,h[e]*3,new t.Cartesian3),r=t.Cartesian3.unpack(m,h[e+1]*3,new t.Cartesian3),i=t.Cartesian3.unpack(m,h[e+2]*3,new t.Cartesian3);g.push(n,r,i)}if(a){if(!i)throw Error("scene is required on `clampToGround == true`.");g=await A({scene:i,terrainProvider:s,positions:g,classificationType:o})}let _=[];for(;g?.length;){let[e,t,n]=g.splice(0,3);_.push([e,t,n])}return _}function N(e,n,r){let i=t.Cartesian3.subtract(e,n,new t.Cartesian3),a=t.Cartesian3.subtract(r,n,new t.Cartesian3),o=t.Cartesian3.cross(i,a,i);return t.Cartesian3.magnitude(o)*.5}function P(e){let n=e?.clampToGround??!1,r=e?.classificationType??t.ClassificationType.BOTH,i=Math.floor(e?.density??10);return{scene:e?.scene,clampToGround:n,classificationType:r,terrainProvider:e?.terrainProvider,density:i}}async function F(e,t){if(e.length<2)throw Error(`positions.length must >= 2`);let{density:n,scene:r,clampToGround:i,classificationType:a,terrainProvider:o}=P(t);if(n<=0)throw Error(`options.density must > 0`);return i?(await M(e,{density:n,scene:r,clampToGround:i,classificationType:a,terrainProvider:o})).reduce((e,t)=>e+=N(...t),0):ee(e).reduce((e,t)=>e+=N(...t),0)}async function I(e){let{start:n,end:r,count:i,scene:a,clampToGround:o,classificationType:s,terrainProvider:c}=e,l=[];for(let e=0;e<i;e++){let e=t.Cartesian3.lerp(n,r,1/i,new t.Cartesian3);l.push(e)}if(l.push(r.clone()),!o)return l;if(!a)throw Error("scene is required on `clampToGround == true`.");return await A({scene:a,terrainProvider:c,positions:l,classificationType:s})}function L(e){let n=e?.clampToGround??!1,r=e?.classificationType??t.ClassificationType.BOTH,i=Math.floor(e?.density??50);return{scene:e?.scene,clampToGround:n,classificationType:r,terrainProvider:e?.terrainProvider,density:i}}async function R(e,n){if(e.length<2)throw Error(`positions.length must >= 2`);let r=L(n),i=[],a=0;if(e.forEach((n,r)=>{if(r!==e.length-1){let o=e[r+1],s=t.Cartesian3.distance(n,o);i.push(s),a+=s}}),!r.clampToGround)return{stages:i,count:a};let o=r.density;if(o<=0)throw Error(`options.density must > 0`);let s=i.map(e=>Math.floor(e/a*o)),c=o-s.reduce((e,t)=>e+=t,0);c&&(s[s.length-1]+=c);let l=s.map((t,n)=>I({scene:r.scene,start:e[n],end:e[n+1],count:t,clampToGround:!0,classificationType:r.classificationType,terrainProvider:r.terrainProvider})),u=(await Promise.all(l)).map(async e=>{let{count:t}=await R(e);return t}),d=await Promise.all(u);return{stages:d,count:d.reduce((e,t)=>e+=t,0)}}let z=new h({type:`MeasureArea`,allowManualComplete:e=>e.positions.length>=3,skeletons:[E,D],initRender(){return{entities:[new t.Entity({label:{font:`14pt`},polyline:{material:t.Color.YELLOW.withAlpha(.5)},polygon:{material:t.Color.YELLOW.withAlpha(.5)}})]}},render(e){let r=e.previous.entities[0],{mouse:i,packable:a}=e,o=[...a.positions??[]];return i&&o.push(i),o.length===2?(r.position=void 0,r.label.text=void 0,r.polygon.hierarchy=void 0,r.polyline.positions=new t.CallbackProperty(()=>o,!1)):o.length>=3?(o.push(o[0]),r.position=new t.ConstantPositionProperty((0,n.toCartesian3)(t.Rectangle.center(t.Rectangle.fromCartesianArray(o)))),r.label.text=new t.ConstantProperty(``),F(o).then(e=>{let n=``;n=e/1e3/1e3>10?`${(e/1e3/1e3).toFixed(2)}km²`:`${(+e).toFixed(2)}m²`,r.label.text=new t.ConstantProperty(n)}),r.polyline.positions=void 0,r.polygon.hierarchy=new t.CallbackProperty(()=>o.length>=3?new t.PolygonHierarchy([...o]):void 0,!1)):(r.position=void 0,r.polygon.hierarchy=void 0,r.polyline.positions=void 0),{entities:[r]}}}),B=new h({type:`MeasureDistance`,allowManualComplete:e=>e.positions.length>=2,skeletons:[E],initRender(){return{entities:[new t.Entity({polyline:{width:2,material:t.Color.YELLOW.withAlpha(.5)}})]}},render(e){e.previous.entities[0];let{mouse:n,packable:r,previous:i}=e,a=i.entities,o=[...r.positions??[]];if(n&&o.push(n),o.length<2)return{entities:a};let s=a[0];return s.polyline??=new t.PolylineGraphics,s.polyline.positions=new t.CallbackProperty(()=>o,!1),o.forEach((e,n)=>{a[n+1]||(a[n+1]=new t.Entity({position:e,label:new t.LabelGraphics({backgroundColor:t.Color.fromCssColorString(`#fff`),font:`12pt sans-serif`})}))}),a.splice(o.length,a.length-o.length-1),R(o).then(({count:e,stages:n})=>{n.forEach((e,n)=>{a[n+1].position=new t.CallbackPositionProperty(()=>t.Cartesian3.midpoint(o[n],o[n+1],new t.Cartesian3),!1),a[n+1].label.text=new t.CallbackProperty(()=>`${e.toFixed(2)} m`,!1)}),n.length>1?(a[a.length-1].position=new t.CallbackPositionProperty(()=>o[o.length-1],!1),a[a.length-1].label.text=new t.CallbackProperty(()=>`${e.toFixed(2)} m`,!1)):(a[a.length-1].position=void 0,a[a.length-1].label.text=void 0)}),{entities:a}}}),V=new h({type:`Billboard`,complete:e=>e.positions.length>=1,skeletons:[k],initRender:()=>({entities:[new t.Entity({billboard:{image:`/favicon.svg`,width:32,height:32}})]}),render(e){let{mouse:n,packable:r}=e,i=e.previous.entities?.[0]??new t.Entity({billboard:{}}),a=r.positions?.[0]??n;return i.position=new t.CallbackPositionProperty(()=>a,!0),{entities:[i]}}}),H=new h({type:`BillboardPinBuilder`,complete:e=>e.positions.length>=1,skeletons:[k],initRender(){return{entities:[new t.Entity({billboard:{}})]}},render(e){let n=e.previous.entities[0],r=e.packable.positions[0]??e.mouse;return n.position=new t.CallbackPositionProperty(()=>r,!0),{entities:[n]}}}),U=new h({type:`Cylinder`,complete:e=>e.positions.length>=2,skeletons:[k,E],initRender(){return{entities:[new t.Entity({cylinder:{}})]}},render(e){let r=e.previous.entities[0],i=[...e.packable.positions];if(i.length===0)return e.previous;if(i.length===1){let t=e.mouse;t&&i.push(t)}if(i.length<2)return e.previous;r.position=new t.ConstantPositionProperty(i[0]);let a=t.Cartesian3.distance(i[0],i[1]);return r.cylinder.bottomRadius=new t.CallbackProperty(()=>a,!1),(e.defining||!(0,n.toPropertyValue)(r.cylinder.length))&&(r.cylinder.length=(0,n.toProperty)(a*2)),{entities:[r]}}}),W=new h({type:`Ellipse`,complete:e=>e.positions.length>=2,skeletons:[k,E],initRender(){return{entities:[new t.Entity({ellipse:{}})]}},render(e){let n=e.previous.entities[0],r=[...e.packable.positions];if(r.length===0)return e.previous;if(r.length===1){let t=e.mouse;t&&r.push(t)}if(r.length<2)return e.previous;n.position=new t.ConstantPositionProperty(r[0]);let i=t.Cartesian3.distance(r[0],r[1]);return n.ellipse.semiMinorAxis=new t.CallbackProperty(()=>i||1,!1),n.ellipse.semiMajorAxis=n.ellipse.semiMinorAxis,{entities:[n]}}}),G=new h({type:`Label`,complete:e=>e.positions.length>=1,skeletons:[k],initRender(){return{entities:[new t.Entity({label:{text:`Label`}})]}},render(e){let n=e.previous.entities[0],r=e.packable.positions[0]??e.mouse;return n.position=new t.CallbackPositionProperty(()=>r,!0),{entities:[n]}}}),K=new h({type:`Point`,complete:e=>e.positions.length>=1,skeletons:[k],initRender(){return{entities:[new t.Entity({point:{pixelSize:10,color:t.Color.RED}})]}},render(e){let n=e.previous.entities[0],r=e.packable.positions[0]??e.mouse;return n.position=new t.CallbackPositionProperty(()=>r,!0),{entities:[n]}}}),q=new h({type:`Polygon`,allowManualComplete:e=>e.positions.length>=2,skeletons:[k,E,D],initRender:()=>({entities:[new t.Entity({polyline:{},polygon:{}})]}),render(e){let{mouse:n,packable:r}=e,i=e.previous.entities[0],a=[...r.positions??[]];return n&&a.push(n),a.length===2?(i.polygon.hierarchy=void 0,i.polyline.positions=new t.CallbackProperty(()=>a,!1)):a.length>=3?(i.polyline.positions=void 0,i.polygon.hierarchy=new t.CallbackProperty(()=>(a.push(a[0]),a.length>=3?new t.PolygonHierarchy([...a]):void 0),!1)):(i.polygon.hierarchy=void 0,i.polyline.positions=void 0),{entities:[i]}}}),J=new h({type:`PolygonArc`,complete:e=>e.positions.length>=3,skeletons:[k,E],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;i.length<3&&e.mouse&&i.push(e.mouse.clone());let o=i.map(e=>(0,n.toCoord)(e));if(o.length<3)return r.polygon.hierarchy=void 0,e.previous;let s=new t.PolygonHierarchy((0,a.arc)(o).map(e=>(0,n.toCartesian3)(e)));return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),Y=new h({type:`PolygonArrowAttackDirection`,allowManualComplete:e=>e.positions.length>=3,skeletons:[k,E,O],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;e.mouse&&i.push(e.mouse.clone());let o=i.map(e=>(0,n.toCoord)(e));if(o.length<3)return r.polygon.hierarchy=void 0,e.previous;let s=new t.PolygonHierarchy((0,a.arrowAttackDirection)(o).map(e=>(0,n.toCartesian3)(e)));return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),X=new h({type:`PolygonArrowAttackDirectionTailed`,allowManualComplete:e=>e.positions.length>=3,skeletons:[k,E,O],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;e.mouse&&i.push(e.mouse.clone());let o=i.map(e=>(0,n.toCoord)(e));if(o.length<3)return r.polygon.hierarchy=void 0,e.previous;let s=new t.PolygonHierarchy((0,a.arrowAttackDirectionTailed)(o).map(e=>(0,n.toCartesian3)(e)));return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),Z=new h({type:`PolygonArrowClamped`,complete:e=>e.positions.length>=5,skeletons:[k,E],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;if(i.length<5){let t=e.mouse;t&&i.push(t.clone())}let o=i.map(e=>(0,n.toCoord)(e));if(o.length>=3){let e=new t.PolygonHierarchy((0,a.arrowClamped)(o).map(e=>(0,n.toCartesian3)(e)));r.polygon.hierarchy=new t.CallbackProperty(()=>e,!1)}else r.polygon.hierarchy=void 0;return{entities:[r]}}}),Q=new h({type:`PolygonArrowStraight`,complete:e=>e.positions.length>=2,skeletons:[k,E],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;if(i.length<2){let t=e.mouse;t&&i.push(t.clone())}let o=i.map(e=>(0,n.toCoord)(e));if(o.length>=2){let e=new t.PolygonHierarchy((0,a.arrowStraight)(o).map(e=>(0,n.toCartesian3)(e)));r.polygon.hierarchy=new t.CallbackProperty(()=>e,!1)}else r.polygon.hierarchy=void 0;return{entities:[r]}}}),te=new h({type:`PolygonArrowStraightSharp`,complete:e=>e.positions.length>=2,skeletons:[k,E],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;if(i.length<2){let t=e.mouse;t&&i.push(t.clone())}let o=i.map(e=>(0,n.toCoord)(e));if(o.length>=2){let e=new t.PolygonHierarchy((0,a.arrowStraightSharp)(o).map(e=>(0,n.toCartesian3)(e)));r.polygon.hierarchy=new t.CallbackProperty(()=>e,!1)}else r.polygon.hierarchy=void 0;return{entities:[r]}}}),ne=new h({type:`PolygonArrowUnitCombatOperation`,allowManualComplete:e=>e.positions.length>=2,skeletons:[k,E,O],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;e.mouse&&i.push(e.mouse.clone());let o=i.map(e=>(0,n.toCoord)(e));if(o.length<2)return r.polygon.hierarchy=void 0,e.previous;let s=new t.PolygonHierarchy((0,a.arrowUnitCombatOperation)(o).map(e=>(0,n.toCartesian3)(e)));return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),$=new h({type:`PolygonArrowUnitCombatOperationTailed`,allowManualComplete:e=>e.positions.length>=2,skeletons:[k,E,D],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;e.mouse&&i.push(e.mouse.clone());let o=i.map(e=>(0,n.toCoord)(e));if(o.length<2)return r.polygon.hierarchy=void 0,e.previous;let s=new t.PolygonHierarchy((0,a.arrowUnitCombatOperationTailed)(o).map(e=>(0,n.toCartesian3)(e)));return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),re=new h({type:`PolygonAssemblingPlace`,complete:e=>e.positions.length>=3,skeletons:[k,E,D],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions;e.mouse&&i.push(e.mouse.clone());let o=i.map(e=>(0,n.toCoord)(e));if(o.length<2)return r.polygon.hierarchy=void 0,e.previous;if(o.length===2){let e=(0,n.toCartographic)(o[0]),r=(0,n.toCartographic)(o[1]),i=e.latitude,a=e.height,s=r.longitude-(e.longitude-r.longitude);o.push((0,n.toCoord)(new t.Cartographic(s,i,a)))}let s=new t.PolygonHierarchy((0,a.assemblingPlace)(o).map(e=>(0,n.toCartesian3)(e)));return r.polygon.hierarchy=new t.CallbackProperty(()=>s,!1),{entities:[r]}}}),ie=new h({type:`PolygonSmooth`,allowManualComplete:e=>e.positions.length>=3,skeletons:[k,E,O],initRender(){return{entities:[new t.Entity({polygon:{}})]}},render(e){let r=e.previous.entities[0],i=e.packable.positions,a=e.mouse;if(a&&i.push(a.clone()),i.length<=2)return r.polygon.hierarchy=void 0,e.previous;let s=i.map(e=>(0,n.toCoord)(e));s.push(s[0]);let{features:c}=o.polygonSmooth(o.polygon([s]),{iterations:3}),l=new t.PolygonHierarchy(c[0].geometry.coordinates[0].map(e=>(0,n.toCartesian3)(e)).filter(e=>!!e));return r.polygon.hierarchy=new t.CallbackProperty(()=>l,!1),{entities:[r]}}}),ae=new h({type:`Polyline`,allowManualComplete:e=>e.positions.length>1,skeletons:[k,E,O],initRender(){return{entities:[new t.Entity({polyline:{material:t.Color.RED,width:2}})]}},render(e){let n=e.previous.entities[0],r=[...e.packable.positions],i=e.mouse;i&&r.push(i.clone());let a=r.length>=2?r:[];return n.polyline.positions=new t.CallbackProperty(()=>a,!1),{entities:[n]}}}),oe=new h({type:`PolylineCurve`,allowManualComplete:e=>e.positions.length>1,skeletons:[k,E,O],initRender(){return{entities:[new t.Entity({polyline:{material:t.Color.RED,width:2}})]}},render(e){let r=e.previous.entities[0],i=[...e.packable.positions],a=e.mouse;if(a&&i.push(a.clone()),i.length<2)return r.polyline.positions=void 0,e.previous;let s=i.map(e=>(0,n.toCoord)(e)),{geometry:{coordinates:c}}=o.bezierSpline(o.lineString(s));return r.polyline.positions=new t.CallbackProperty(()=>c.map(n.toCartesian3),!1),{entities:[r]}}}),se=new h({type:`Rectangle`,complete:e=>e.positions.length>=2,skeletons:[k,E],initRender(){return{entities:[new t.Entity({rectangle:{}})]}},render(e){let n=e.previous.entities[0],r=[...e.packable.positions],i=e.mouse;if(i&&r.push(i.clone()),r.length<2)return n.rectangle.coordinates=void 0,e.previous;let a=t.Rectangle.fromCartesianArray(r??[]);return n.rectangle.coordinates=new t.CallbackProperty(()=>a,!1),{entities:[n]}}});e.PlotAction=b,e.PlotFeature=y,e.PlotScheme=h,e.PlotSchemeBillboard=V,e.PlotSchemeBillboardPinBuilder=H,e.PlotSchemeCylinder=U,e.PlotSchemeEllipse=W,e.PlotSchemeLabel=G,e.PlotSchemePoint=K,e.PlotSchemePolygon=q,e.PlotSchemePolygonArc=J,e.PlotSchemePolygonArrowAttackDirection=Y,e.PlotSchemePolygonArrowAttackDirectionTailed=X,e.PlotSchemePolygonArrowClamped=Z,e.PlotSchemePolygonArrowStraight=Q,e.PlotSchemePolygonArrowStraightSharp=te,e.PlotSchemePolygonArrowUnitCombatOperation=ne,e.PlotSchemePolygonArrowUnitCombatOperationTailed=$,e.PlotSchemePolygonAssemblingPlace=re,e.PlotSchemePolygonSmooth=ie,e.PlotSchemePolyline=ae,e.PlotSchemePolylineCurve=oe,e.PlotSchemeRectangle=se,e.PlotSkeletonEntity=x,e.SampledPlotProperty=v,e.SampledPlotStrategy=g,e.control=E,e.interval=D,e.intervalNonclosed=O,e.moved=k,e.schemeMeasureArea=z,e.schemeMeasureDistance=B,e.usePlot=T})(this.Vesium=this.Vesium||{},Cesium,Vesium,VueUse,Vue,Vesium,turf);
|
|
2
2
|
//# sourceMappingURL=index.iife.min.js.map
|