cc-tools-utils 0.0.4 → 0.0.6
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/img/Transform.d.ts +3 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1 -0
- package/dist/js/bus.d.ts +8 -0
- package/dist/js/cesiumHooks.d.ts +68 -0
- package/dist/js/tools.d.ts +2 -0
- package/dist/lib/img/Transform.d.ts +3 -0
- package/dist/lib/js/Anima.d.ts +2 -0
- package/dist/lib/js/bus.d.ts +9 -0
- package/dist/lib/js/cesiumHooks.d.ts +67 -0
- package/dist/lib/js/tools.d.ts +28 -0
- package/package.json +5 -10
- package/index.js +0 -12
- package/lib/img/Transform.ts +0 -44
- package/lib/js/cesiumHooks.js +0 -1127
- package/lib/js/tools.js +0 -36
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as img from "./lib/img/Transform";
|
|
2
|
+
import * as js from "./lib/js/tools";
|
|
3
|
+
import * as bus from "./lib/js/bus";
|
|
4
|
+
import * as cesiumHooks from "./lib/js/cesiumHooks";
|
|
5
|
+
export { img, js, bus, cesiumHooks };
|
|
6
|
+
declare const _default: {
|
|
7
|
+
img: typeof img;
|
|
8
|
+
js: typeof js;
|
|
9
|
+
bus: typeof bus;
|
|
10
|
+
cesiumHooks: typeof cesiumHooks;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
((e,t)=>{"object"==typeof exports&&"object"==typeof module?module.exports=t(require("cesium")):"function"==typeof define&&define.amd?define(["cesium"],t):"object"==typeof exports?exports["cc-tools-utils"]=t(require("cesium")):e["cc-tools-utils"]=t(e.Cesium)})(self,e=>{{var t={50(t){t.exports=e}},r={};function i(e){var n=r[e];return void 0!==n||(n=r[e]={exports:{}},t[e](n,n.exports,i)),n.exports}i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={},o=(i.d(n,{default:()=>Y}),{}),a=(i.r(o),i.d(o,{debounce:()=>l,throttle:()=>c}),{}),l=(i.r(a),i.d(a,{DEFAULT_HEIGHT:()=>b,DEFAULT_POSITION:()=>v,MODEL_DISPLAY_DISTANCE:()=>y,add3DModel:()=>k,addEquatorialLine:()=>_,addHover:()=>z,addLine:()=>j,addPointer:()=>V,airRouteFn:()=>N,backToChina:()=>D,cameraAnimation:()=>H,cc:()=>U,combineIconAndLabel:()=>W,divergingWaves:()=>A,followModel:()=>L,getHeading:()=>E,getPitch:()=>O,getRhumbBearing:()=>T,initCesium:()=>x,initCluster:()=>B,initEvents:()=>F,isArrayEqual:()=>C,setCesiumAccessToken:()=>w,toCesiumColor:()=>I,toCesiumPosition:()=>M,transformCartesian3ToWGS84:()=>P,updataModelPosition:()=>S}),function(e,t){if("function"!=typeof t)throw new Error("debounce的第二个参数必须是函数");if("number"!=typeof e||e<0)throw new Error("debounce的第一个参数必须是非负数");var r=null;return function(){var i=arguments,n=this;r&&clearTimeout(r),r=setTimeout(function(){t.apply(n,i),r=null},e)}}),c=function(e,t){if("function"!=typeof t)throw new Error("throttle的第二个参数必须是函数");if("number"!=typeof e||e<0)throw new Error("throttle的第一个参数必须是非负数");var r=!1;return function(){r||(r=!0,t.apply(this,arguments),setTimeout(function(){r=!1},e))}},s=i(50);function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e,t){var r,i=Object.keys(e);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(e),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,r)),i}function f(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach(function(t){var i,n;i=e,n=r[t],(t=(e=>(e=(e=>{if("object"!=u(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if("object"!=u(t=t.call(e,"string")))return t;throw new TypeError("@@toPrimitive must return a primitive value.")})(e),"symbol"==u(e)?e:e+""))(t))in i?Object.defineProperty(i,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):i[t]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function g(e){return(e=>{if(Array.isArray(e))return m(e)})(e)||(e=>{if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)})(e)||h(e)||(()=>{throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")})()}function p(e,t){return(e=>{if(Array.isArray(e))return e})(e)||((e,t)=>{var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,o,a,l=[],c=!0,s=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(i=o.call(r)).done)&&(l.push(i.value),l.length!==t);c=!0);}catch(e){s=!0,n=e}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw n}}return l}})(e,t)||h(e,t)||(()=>{throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")})()}function h(e,t){var r;if(e)return"string"==typeof e?m(e,t):"Map"===(r="Object"===(r={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(e,t):void 0}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}var b=25e6,v=[109,35.5,b],y=5e6,w=function(e){e&&"string"==typeof e?s.Ion.defaultAccessToken=e:console.warn("setCesiumAccessToken: token必须是非空字符串")};function C(e,t){e=e.slice().sort();var r=t.slice().sort();return e.length===r.length&&e.every(function(e,t){return e===r[t]})}var E=function(e,t){var r=s.Transforms.eastNorthUpToFixedFrame(e);return t=s.Cartesian3.subtract(t,e,new s.Cartesian3),e=s.Matrix4.multiplyByPointAsVector(s.Matrix4.inverse(r,new s.Matrix4),t,new s.Cartesian3),r=s.Cartesian3.normalize(e,new s.Cartesian3),t=Math.atan2(r.y,r.x)-s.Math.PI_OVER_TWO,s.Math.TWO_PI-s.Math.zeroToTwoPi(t)},T=function(e,t){if(!Array.isArray(e)||!Array.isArray(t))throw new Error("getRhumbBearing: 参数必须是数组");if(e.length<2||t.length<2)throw new Error("getRhumbBearing: 参数数组至少需要两个元素[经度, 纬度]");var r=(e=p(e,2))[0],i=(e=e[1],(t=p(t,2))[0]);return t=t[1],e=s.Math.toRadians(e),t=s.Math.toRadians(t),i=s.Math.toRadians(i-r),r=Math.log(Math.tan(t/2+Math.PI/4)/Math.tan(e/2+Math.PI/4)),t=Math.atan2(i,r),(s.Math.toDegrees(t)+360)%360},O=function(e,t){var r=s.Transforms.eastNorthUpToFixedFrame(e);return t=s.Cartesian3.subtract(t,e,new s.Cartesian3),e=s.Matrix4.multiplyByPointAsVector(s.Matrix4.inverse(r,r),t,t),s.Cartesian3.normalize(e,e),s.Math.PI_OVER_TWO-s.Math.acosClamped(e.z)},S=function(e,t){var r=t.model,i=t.targetPosition,n=void 0===(t=t.totalDuration)?2:t;e.clock.onTick.addEventListener(function(e){var t,o=e.currentTime.secondsOfDay;o<=n&&(t=new s.Cartesian3,s.Cartesian3.lerp(r.position.getValue(e.currentTime),i,o/n,t),r.position.setValue(t))})},P=function(e){return e=s.Ellipsoid.WGS84.cartesianToCartographic(e),[s.Math.toDegrees(e.longitude),s.Math.toDegrees(e.latitude),e.height]},I=function(e){if(!e||"string"!=typeof e)return console.warn("toCesiumColor: color必须是字符串,使用默认颜色"),s.Color.WHITE;try{return s.Color.fromCssColorString(e)}catch(t){return console.warn("toCesiumColor: 无效的颜色值 ".concat(e,",使用默认颜色")),s.Color.WHITE}},M=function(e){var t;if(!Array.isArray(e))throw new Error("toCesiumPosition: position必须是数组");if(e.length<2)throw new Error("toCesiumPosition: position数组至少需要两个元素[经度, 纬度]");if(e.some(function(e){return"number"!=typeof e||isNaN(e)}))throw new Error("toCesiumPosition: position数组元素必须是有效数字");return(t=s.Cartesian3).fromDegrees.apply(t,g(e))},D=function(e,t,r){if(!e)throw new Error("backToChina: viewer参数是必需的");e.camera.flyTo({destination:M(v),duration:r||1.5,complete:function(){t&&t()}})},x=function(e,t){var r;if(e)return r=new s.Viewer(e,{contextOptions:{webgl:{alpha:!0,powerPreference:"high-performance"}},infoBox:!1,timeline:!1,geocoder:!1,homeButton:!1,sceneModePicker:!0,baseLayerPicker:!1,navigationHelpButton:!1,animation:!1,selectionIndicator:!1}),t&&setTimeout(function(){console.log("执行回调函数"),t(r)},0),{viewer:r};throw new Error("initCesium: boxID参数是必需的")},A=function(e){var t=void 0===(t=(c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).defaultPosition)?[120.38017292236532,31.480874872499374]:t,r=void 0===(l=c.r)?0:l,i=void 0===(l=c.r2)?0:l,n=void 0===(l=c.step)?2e3:l,o=void 0===(l=c.max)?8e4:l,a=void 0===(l=c.speed)?1:l,l=void 0===(l=c.defaultColor)?"#ff0000":l,c=void 0===(c=c.id)?"":c;if(!s.defined(e))throw new Error("divergingWaves: viewer参数是必需的");if(!Array.isArray(t)||t.length<2)throw new Error("divergingWaves: defaultPosition必须是有效的坐标数组");return e.entities.add({id:c,position:M(t),ellipse:{semiMinorAxis:new s.CallbackProperty(function(){return r<o?r+=n*a:r=0},!1),semiMajorAxis:new s.CallbackProperty(function(){return i<o?i+=n*a:i=0},!1),height:0,material:I(l),outline:!1}})},_=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"#DC143C",r=[[180,0,1e5],[60,0,1e5],[-60,0,1e5],[-180,0,1e5]].reduce(function(e,t){return e.concat(t)},[]);e.entities.add({id:"赤道线",polyline:{positions:s.Cartesian3.fromDegreesArrayHeights(r),width:5,material:I(t)}})},N=function(e){function t(){var e=n,t=e._times;return t.map(function(r,i){var n=P(e.getValue(r)).slice(0,2),a=t[i+1]?P(e.getValue(t[i+1])).slice(0,2):null;n=a?-s.Math.toRadians(T(n,a)):o.getValue(t[i-1]),o.addSample(r,n)}),o}var r=e.clock,i={from:[102.5,30,1e6],to:[150.5,-33,1e6],last:15,stopFlag:!1},n=new s.SampledProperty(s.Cartesian3),o=new s.SampledProperty(s.Rotation),a=r.currentTime.clone(),l=s.JulianDate.addMinutes(a,i.last,new s.JulianDate),c=(n.addSample(r.currentTime,M(i.from)),r=Array.from({length:i.last-1},function(e,t){return s.JulianDate.addMinutes(a,t+1,new s.JulianDate)}),(i.to[0]-i.from[0])/i.last),u=(i.to[1]-i.from[1])/i.last,d=Array.from({length:i.last-1},function(e,t){return M([i.from[0]+(t+1)*c,i.from[1]+(t+1)*u,i.from[2]])}),f=[i.from].concat(g(d.map(function(e){return P(e)})),[i.to]),h=(e.entities.add({id:"添加航班连线",labelVisible:!0,polyline:{positions:s.Cartesian3.fromDegreesArrayHeights(f.flat(1/0)),width:2,material:new s.PolylineDashMaterialProperty({color:I("#8A2BE2")}),loop:!0}}),n.addSamples(r,d),n.addSample(l,M(i.to)),e.entities.add({id:"空中客机",position:n,usePlain:!0,setRotation:!0,label:{text:new s.CallbackProperty(function(e){var t;return n.getValue(e)?(t=(e=p(P(n.getValue(e)),2))[0],e=e[1],"经度:".concat(t.toFixed(2),"\n纬度:").concat(e.toFixed(2))):""},!1),font:"12px Helvetica Neue",scale:1,outlineWidth:1,showBackground:!0,backgroundColor:new s.Color(.165,.165,.165,.5),fillColor:s.Color.fromCssColorString("#59cfb5"),pixelOffset:new s.Cartesian2(-20,-40),horizontalOrigin:s.HorizontalOrigin.LEFT,verticalOrigin:s.VerticalOrigin.CENTER},billboard:{width:36,height:36,image:"/plain.svg",heightReference:s.HeightReference.NONE,disableDepthTestDistance:Number.POSITIVE_INFINITY,rotation:t()},orientation:n.constructor===s.Cartesian3?null:new s.VelocityOrientationProperty(n),createRotationSampler:t()}));e.entities.add({id:"点位起点",point:{},position:M(i.from),billboard:{width:20,height:25,image:"/location.svg",heightReference:s.HeightReference.NONE,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),e.entities.add({id:"点位终点",point:{},position:M(i.to),billboard:{width:20,height:25,image:"/location.svg",heightReference:s.HeightReference.NONE,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),e.scene.postRender.addEventListener(function(t,r){var i;i=h.position.getValue(r),r=h.orientation.getValue(r),R({position:i,airPlan:h,orientation:r,allHeight:1e6},e)})},R=function(e,t){var r,i=e.position;e=e.allHeight,i&&(r=(i=g(P(i)))[0],r=M([r,i[1],i[2]]),i=s.Cartographic.fromCartesian(r),r=s.Math.toDegrees(i.longitude),i=s.Math.toDegrees(i.latitude),r=s.Cartesian3.fromDegrees(r,i),t.camera.lookAt(r,new s.Cartesian3(0,0,1.3*e)))},H=function(e,t,r){e.camera.flyTo({destination:(e=s.Cartesian3).fromDegrees.apply(e,g(t)),duration:2,orientation:f({},r)})},V=function(e){var t=(p=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).position,r=p.pointColor,i=p.pointerSize,n=p.id,o=void 0===(o=p.label)?{}:o,a=p.billboard,l=void 0===(l=p.nearScale)?1:l,c=void 0===(c=p.farScale)?.85:c,u=void 0===(u=p.nearDistance)?1e3:u,d=void 0===(d=p.farDistance)?4e8:d,p=p.hoverImage;if(!e)throw new Error("addPointer: viewer参数是必需的");if(!t)throw new Error("addPointer: position参数是必需的");if(n={id:n,position:M(g(t)),usePlain:!0,hoverImage:p||""},r&&""!==r.trim()&&0<i)try{n.point={pixelSize:i,color:I(r)}}catch(e){console.warn("创建 point 失败:",e)}return o&&(n.label=f({font:"12px Helvetica Neue",scale:1,outlineWidth:1,showBackground:!0,horizontalOrigin:s.HorizontalOrigin.LEFT,verticalOrigin:s.VerticalOrigin.CENTER,scaleByDistance:new s.NearFarScalar(u,1,d,.2)},o)),a&&(n.billboard=f({heightReference:s.HeightReference.NONE,disableDepthTestDistance:Number.POSITIVE_INFINITY,scaleByDistance:new s.NearFarScalar(u,l,d,c)},a)),e.entities.add(n)},j=function(e){e.entities.add({polyline:{width:10,material:s.Color.GREEN}})},k=function(e,t,r){t=e.entities.add({position:t,name:"飞船一号",model:{uri:"./airship.glb"}}),e.flyTo(t)},F=function(e){var t,r=e.viewer,i=e.scene,n=e.entities,o=((r.cesiumWidget.screenSpaceEventHandler.removeInputAction(s.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),n.collectionChanged.addEventListener(function(e,r,i){C(t,e.values.map(function(e){return e.id}))||(t=n.values.map(function(e){return e.id}))}),e=new s.ScreenSpaceEventHandler(i.canvas)).setInputAction(function(e){return o(e,s.ScreenSpaceEventType.LEFT_CLICK)},s.ScreenSpaceEventType.LEFT_CLICK),function(e,t){var n=s.Math.toDegrees(r.camera.heading),o=s.Math.toDegrees(r.camera.pitch),a=s.Math.toDegrees(r.camera.roll),l=r.camera.positionCartographic,c=s.Math.toDegrees(l.longitude),u=s.Math.toDegrees(l.latitude);l=l.height,(u=(console.log("位置: [".concat(c,", ").concat(u,", ").concat(l,"]")),console.log("角度: { heading: ".concat(n,", pitch: ").concat(o,", roll: ").concat(a," }")),c=i.pick(e.position)||{id:void 0,primitive:void 0}).id)&&console.log(" 点击的模型 :",u)}),a=s.Ellipsoid.WGS84;return e.setInputAction(function(e){(e=r.camera.pickEllipsoid(e.endPosition,a))&&(e=r.scene.globe.ellipsoid.cartesianToCartographic(e),s.Math.toDegrees(e.latitude).toFixed(4),s.Math.toDegrees(e.longitude).toFixed(4),(r.camera.positionCartographic.height/1e3).toFixed(2))},s.ScreenSpaceEventType.MOUSE_MOVE),t},L=function(e,t){var r=t.targetModel,i=t.selfModel,n=t.startPosition,o=(t=s.JulianDate.now(),r._position.getValue(t));i._position.getValue(t),r._position=new s.CallbackProperty(function(){return o.x+=100,o},!1),i._posistion=new s.CallbackProperty(function(){return s.Cartesian3.midpoint(M(n),o,new s.Cartesian3)},!1),i._orientation=new s.CallbackProperty(function(){var e=M(n),t=E(e,r=o),r=O(e,r),i=new s.HeadingPitchRoll(s.Math.toRadians(90),s.Math.toRadians(90),s.Math.toRadians(0));return i.pitch-=r,i.heading+=t,s.Transforms.headingPitchRollQuaternion(e,i)},!1),i._cylinder.length=new s.CallbackProperty(function(){var e=M(n);return s.Cartesian3.distance(e,o)},!1),e.scene.postRender.addEventListener(function(){})},B=function(e,t){var r=t.source,i=t.image,n=(t=p(t.imgs,4))[0],o=t[1],a=t[2],l=t[3];(new s.GeoJsonDataSource).load(r).then(function(t){e.dataSources.add(t),t.clustering.enabled=!0,t.clustering.pixelRange=60,t.clustering.minimumClusterSize=2,t.entities.values.forEach(function(e){console.log(" 每一项entity :",e),e.position._value.z+=50,e.billboard={image:i,width:32,height:32},e.label={text:"POI",font:"bold 15px Microsoft YaHei",verticalOrigin:s.VerticalOrigin.CENTER,horizontalOrigin:s.HorizontalOrigin.LEFT,pixelOffset:new s.Cartesian2(15,0)}}),t.clustering.clusterEvent.addEventListener(function(e,t){t.label.show=!1,t.billboard.show=!0,t.billboard.verticalOrigin=s.VerticalOrigin.BOTTOM,20<=e.length?(t.billboard.image=W(l,e.length,64),t.billboard.width=72,t.billboard.height=72):12<=e.length?(t.billboard.image=W(a,e.length,64),t.billboard.width=56,t.billboard.height=56):8<=e.length?(t.billboard.image=W(o,e.length,64),t.billboard.width=48,t.billboard.height=48):(t.billboard.image=W(n,e.length,64),t.billboard.width=40,t.billboard.height=40)})})},W=function(e,t,r){var i=document.createElement("canvas"),n=(i.width=r,i.height=r,i.getContext("2d"));return new s.Resource.fetchImage(e).then(function(e){try{n.drawImage(e,0,0)}catch(e){console.log(e)}return n.fillStyle=s.Color.WHITE.toCssColorString(),n.font="bold 20px Microsoft YaHei",n.textAlign="center",n.textBaseline="middle",n.fillText(t,r/2,r/2),i})},z=function(e,t){var r=new s.ScreenSpaceEventHandler(e.scene.canvas),i=null,n=null;return r.setInputAction(function(r){var o;(r=e.scene.pick(r.endPosition))&&r.id?(o=r.id,n!==o&&(i&&clearTimeout(i),n&&n.billboard&&n._originalImage&&(n.billboard.image=n._originalImage,delete n._originalImage),n=o,e.scene.canvas.style.cursor="pointer",i=setTimeout(function(){o.billboard&&o.hoverImage&&(o._originalImage=o.billboard.image,o.billboard.image=o.hoverImage),t&&t(o)},300))):(i&&clearTimeout(i),n&&n.billboard&&n._originalImage&&(n.billboard.image=n._originalImage,delete n._originalImage),e.scene.canvas.style.cursor="default",n=null)},s.ScreenSpaceEventType.MOUSE_MOVE),function(){r.destroy(),i&&clearTimeout(i)}},U=function(){return 1};let Y={tools:o,cesiumHooks:a};return n.default}});
|
package/dist/js/bus.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export function isArrayEqual(arr1: any, arr2: any): any;
|
|
2
|
+
export const DEFAULT_HEIGHT: 25000000;
|
|
3
|
+
export const DEFAULT_POSITION: number[];
|
|
4
|
+
export const MODEL_DISPLAY_DISTANCE: 5000000;
|
|
5
|
+
export const allEntitiesIds: import("vue").Ref<any[], any[]>;
|
|
6
|
+
export function setCesiumAccessToken(token: string): void;
|
|
7
|
+
export function getHeading(pointA: any, pointB: any): number;
|
|
8
|
+
export function getRhumbBearing(pos1: any[], pos2: any[]): number;
|
|
9
|
+
export function getPitch(pointA: any, pointB: any): number;
|
|
10
|
+
export function updataModelPosition(viewer: any, { model, targetPosition, totalDuration }: {
|
|
11
|
+
model: any;
|
|
12
|
+
targetPosition: any;
|
|
13
|
+
totalDuration?: number;
|
|
14
|
+
}): void;
|
|
15
|
+
export function transformCartesian3ToWGS84(cartesian3: any): number[];
|
|
16
|
+
export function toCesiumColor(color: any): Color;
|
|
17
|
+
export function toCesiumPosition(position: any): Cartesian3;
|
|
18
|
+
export function backToChina(viewer: any, callback: any, time: any): void;
|
|
19
|
+
export function initCesium(boxID: any, doSomething: any): {
|
|
20
|
+
viewer: Cesium.Viewer;
|
|
21
|
+
};
|
|
22
|
+
export function divergingWaves(viewer: any, { defaultPosition, r, r2, step, max, speed, defaultColor, id, }?: {
|
|
23
|
+
defaultPosition?: number[];
|
|
24
|
+
r?: number;
|
|
25
|
+
r2?: number;
|
|
26
|
+
step?: number;
|
|
27
|
+
max?: number;
|
|
28
|
+
speed?: number;
|
|
29
|
+
defaultColor?: string;
|
|
30
|
+
id?: string;
|
|
31
|
+
}): any;
|
|
32
|
+
export function addEquatorialLine(viewer: any, color?: string): void;
|
|
33
|
+
export function airRouteFn(viewer: any): void;
|
|
34
|
+
export function cameraAnimation(viewer: any, position: any, orientation: any): void;
|
|
35
|
+
export function addPointer(viewer: any, { position, pointColor, pointerSize, id, label, billboard, nearScale, farScale, nearDistance, farDistance, hoverImage, }?: {
|
|
36
|
+
position: any;
|
|
37
|
+
pointColor: any;
|
|
38
|
+
pointerSize: any;
|
|
39
|
+
id: any;
|
|
40
|
+
label?: {};
|
|
41
|
+
billboard: any;
|
|
42
|
+
nearScale?: number;
|
|
43
|
+
farScale?: number;
|
|
44
|
+
nearDistance?: number;
|
|
45
|
+
farDistance?: number;
|
|
46
|
+
hoverImage: any;
|
|
47
|
+
}): any;
|
|
48
|
+
export function addLine(viewer: any): void;
|
|
49
|
+
export function add3DModel(viewer: any, airShipPosition: any, cameraPosition: any): void;
|
|
50
|
+
export function initEvents({ viewer, scene, camera, entities, clock }: {
|
|
51
|
+
viewer: any;
|
|
52
|
+
scene: any;
|
|
53
|
+
camera: any;
|
|
54
|
+
entities: any;
|
|
55
|
+
clock: any;
|
|
56
|
+
}): void;
|
|
57
|
+
export function followModel(viewer: any, options: any): void;
|
|
58
|
+
export function initCluster(viewer: any, { source, image: mainImage, imgs }: {
|
|
59
|
+
source: any;
|
|
60
|
+
image: any;
|
|
61
|
+
imgs: any;
|
|
62
|
+
}): any;
|
|
63
|
+
export function combineIconAndLabel(url: any, label: any, size: any): any;
|
|
64
|
+
export function addHover(viewer: Viewer, onHover: Function): () => void;
|
|
65
|
+
export function cc(): void;
|
|
66
|
+
import { Color } from "cesium";
|
|
67
|
+
import { Cartesian3 } from "cesium";
|
|
68
|
+
import * as Cesium from "cesium";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export function isArrayEqual(arr1: any, arr2: any): any;
|
|
2
|
+
export const DEFAULT_HEIGHT: 25000000;
|
|
3
|
+
export const DEFAULT_POSITION: number[];
|
|
4
|
+
export const MODEL_DISPLAY_DISTANCE: 5000000;
|
|
5
|
+
export const Cesium_Access_Tokens: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI2Mzg2ZTAwNy0zODczLTQxYjUtODE3OS0zYzI5ZmM1MTU3MGIiLCJpZCI6Mzc4NzcwLCJpYXQiOjE3Njg0NDQyODd9.u9gpkF-dD_GHOX9dbnNR5k7Zv6oVpUcNm5WOeqvxzu0";
|
|
6
|
+
export const allEntitiesIds: import("vue").Ref<any[]>;
|
|
7
|
+
export function getHeading(pointA: any, pointB: any): number;
|
|
8
|
+
export function getPitch(pointA: any, pointB: any): number;
|
|
9
|
+
export function updataModelPosition(viewer: any, { model, targetPosition, totalDuration }: {
|
|
10
|
+
model: any;
|
|
11
|
+
targetPosition: any;
|
|
12
|
+
totalDuration?: number;
|
|
13
|
+
}): void;
|
|
14
|
+
export function transformCartesian3ToWGS84(cartesian3: any): number[];
|
|
15
|
+
export function toCesiumColor(color: any): Color;
|
|
16
|
+
export function toCesiumPosition(position: any): Cartesian3;
|
|
17
|
+
export function backToChina(viewer: any, callback: any, time: any): void;
|
|
18
|
+
export function initCesium(boxID: any, doSomething: any): {
|
|
19
|
+
viewer: Cesium.Viewer;
|
|
20
|
+
};
|
|
21
|
+
export function divergingWaves(viewer: any, { defaultPosition, r, r2, step, max, speed, defaultColor, id, }: {
|
|
22
|
+
defaultPosition?: number[];
|
|
23
|
+
r?: number;
|
|
24
|
+
r2?: number;
|
|
25
|
+
step?: number;
|
|
26
|
+
max?: number;
|
|
27
|
+
speed?: number;
|
|
28
|
+
defaultColor?: string;
|
|
29
|
+
id?: string;
|
|
30
|
+
}): any;
|
|
31
|
+
export function addEquatorialLine(viewer: any, color?: string): void;
|
|
32
|
+
export function airRouteFn(viewer: any): void;
|
|
33
|
+
export function cameraAnimation(viewer: any, position: any, orientation: any): void;
|
|
34
|
+
export function addPointer(viewer: any, { position, pointColor, pointerSize, id, label, billboard, nearScale, farScale, nearDistance, farDistance, hoverImage, }: {
|
|
35
|
+
position: any;
|
|
36
|
+
pointColor: any;
|
|
37
|
+
pointerSize: any;
|
|
38
|
+
id: any;
|
|
39
|
+
label?: {};
|
|
40
|
+
billboard: any;
|
|
41
|
+
nearScale?: number;
|
|
42
|
+
farScale?: number;
|
|
43
|
+
nearDistance?: number;
|
|
44
|
+
farDistance?: number;
|
|
45
|
+
hoverImage: any;
|
|
46
|
+
}): any;
|
|
47
|
+
export function addLine(viewer: any): void;
|
|
48
|
+
export function add3DModel(viewer: any, airShipPosition: any, cameraPosition: any): void;
|
|
49
|
+
export function initEvents({ viewer, scene, camera, entities, clock }: {
|
|
50
|
+
viewer: any;
|
|
51
|
+
scene: any;
|
|
52
|
+
camera: any;
|
|
53
|
+
entities: any;
|
|
54
|
+
clock: any;
|
|
55
|
+
}): void;
|
|
56
|
+
export function followModel(viewer: any, options: any): void;
|
|
57
|
+
export function initCluster(viewer: any, { source, image: mainImage, imgs }: {
|
|
58
|
+
source: any;
|
|
59
|
+
image: any;
|
|
60
|
+
imgs: any;
|
|
61
|
+
}): any;
|
|
62
|
+
export function combineIconAndLabel(url: any, label: any, size: any): any;
|
|
63
|
+
export function addHover(viewer: Viewer, onHover: Function): () => void;
|
|
64
|
+
export function cc(): void;
|
|
65
|
+
import { Color } from "cesium";
|
|
66
|
+
import { Cartesian3 } from "cesium";
|
|
67
|
+
import * as Cesium from "cesium";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const anima: (begin: any, end: any, time: any, onUpdate: any, onComplete: any) => any;
|
|
2
|
+
export declare const debounce: (time: number, fn: Function) => () => void;
|
|
3
|
+
export declare const throttle: (time: number, fn: Function) => () => void;
|
|
4
|
+
export declare const maskAnima: (parentDom: Element) => void;
|
|
5
|
+
export declare const callPromises: (arr: any) => any;
|
|
6
|
+
export declare const callFunctions: (arr: any) => void;
|
|
7
|
+
export declare const getIdDom: (idName: string) => Element;
|
|
8
|
+
export declare const getClassDom: (className: string) => Element;
|
|
9
|
+
export declare const hasFocus: (el: any) => boolean;
|
|
10
|
+
export declare const a: (el: any) => any;
|
|
11
|
+
export declare const getSelectedText: () => string;
|
|
12
|
+
export declare const goBack: () => void;
|
|
13
|
+
export declare const getUrlParams: (query: any) => {};
|
|
14
|
+
export declare const isDarkMode: boolean;
|
|
15
|
+
export declare const isEqualArray: (a: any, b: any) => boolean;
|
|
16
|
+
export declare const arrayToObject: (arr: any, key: any) => any;
|
|
17
|
+
export declare const countBy: (arr: any, prop: any) => any;
|
|
18
|
+
export declare const arrayIsNotEmpty: (arr: any) => boolean;
|
|
19
|
+
export declare const flat_entries: (arr: any) => any[];
|
|
20
|
+
export declare const lastItem: (arr: any) => any;
|
|
21
|
+
export declare const isEqualString: (...objects: any[]) => boolean;
|
|
22
|
+
export declare const pluck: (objs: any, property: any) => any;
|
|
23
|
+
export declare const invert: (obj: any) => {};
|
|
24
|
+
export declare const removeNullAndUndefined: (obj: any) => {};
|
|
25
|
+
export declare const sort: (obj: any) => {};
|
|
26
|
+
export declare const isArray: (obj: any) => boolean;
|
|
27
|
+
export declare const isPromise: (obj: any) => boolean;
|
|
28
|
+
export declare const exchange: (a: any, b: any) => [any, any];
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-tools-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Cesium工具库,包含常用的Cesium hooks和工具函数",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"type-check": "false",
|
|
9
9
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -22,18 +22,12 @@
|
|
|
22
22
|
"url": "https://gitee.com/chen-cheng-1998/learn_own.git"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
|
-
"
|
|
25
|
+
"dist",
|
|
26
26
|
"README.md",
|
|
27
27
|
"LICENSE",
|
|
28
|
-
"index.js",
|
|
29
|
-
"index.d.ts",
|
|
30
28
|
"vue-config-helper.js",
|
|
31
29
|
"CONSUMER_PROJECT_CONFIG.md"
|
|
32
30
|
],
|
|
33
|
-
"peerDependencies": {
|
|
34
|
-
"cesium": ">=1.100.0",
|
|
35
|
-
"vue": ">=3.0.0"
|
|
36
|
-
},
|
|
37
31
|
"devDependencies": {
|
|
38
32
|
"@vue/compiler-sfc": "^3.5.11",
|
|
39
33
|
"css-loader": "^7.1.2",
|
|
@@ -46,6 +40,7 @@
|
|
|
46
40
|
"@types/node": "^22.7.5",
|
|
47
41
|
"babel-loader": "^8.2.5",
|
|
48
42
|
"clean-webpack-plugin": "^4.0.0",
|
|
43
|
+
"process": "^0.11.10",
|
|
49
44
|
"ts-loader": "^9.2.6",
|
|
50
45
|
"typescript": "^4.5.4",
|
|
51
46
|
"webpack": "^5.65.0",
|
package/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// import * as img from "./lib/img/Transform.js";
|
|
2
|
-
import * as tools from "./lib/js/tools.js";
|
|
3
|
-
import * as cesiumHooks from "./lib/js/cesiumHooks.js";
|
|
4
|
-
|
|
5
|
-
// 命名导出
|
|
6
|
-
export { tools, cesiumHooks };
|
|
7
|
-
|
|
8
|
-
// 默认导出
|
|
9
|
-
export default {
|
|
10
|
-
tools,
|
|
11
|
-
cesiumHooks,
|
|
12
|
-
};
|
package/lib/img/Transform.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// 图片url转 base64
|
|
2
|
-
const imgUrlToBase64 = async (url, callback) => {
|
|
3
|
-
let Img = new Image(),
|
|
4
|
-
dataURL = "";
|
|
5
|
-
Img.src = url + "?v=" + Math.random();
|
|
6
|
-
Img.setAttribute("crossOrigin", "Anonymous");
|
|
7
|
-
Img.onload = function () {
|
|
8
|
-
let canvas = document.createElement("canvas"),
|
|
9
|
-
width = Img.width,
|
|
10
|
-
height = Img.height;
|
|
11
|
-
canvas.width = width;
|
|
12
|
-
canvas.height = height;
|
|
13
|
-
(canvas.getContext("2d") as any).drawImage(Img, 0, 0, width, height);
|
|
14
|
-
dataURL = canvas.toDataURL("image/webp");
|
|
15
|
-
return callback ? callback(dataURL) : null;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// 下载文件
|
|
20
|
-
const downloadFile = (content: any, fileName: string) => {
|
|
21
|
-
//下载base64图片 传入base64
|
|
22
|
-
let base64ToBlob = function (code: any) {
|
|
23
|
-
let parts = code.split(";base64,");
|
|
24
|
-
let contentType = parts[0].split(":")[1];
|
|
25
|
-
let raw = window.atob(parts[1]);
|
|
26
|
-
let rawLength = raw.length;
|
|
27
|
-
let uInt8Array = new Uint8Array(rawLength);
|
|
28
|
-
for (let i = 0; i < rawLength; ++i) {
|
|
29
|
-
uInt8Array[i] = raw.charCodeAt(i);
|
|
30
|
-
}
|
|
31
|
-
return new Blob([uInt8Array], {
|
|
32
|
-
type: contentType,
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
let aLink = document.createElement("a");
|
|
36
|
-
let blob = base64ToBlob(content); //new Blob([content]);
|
|
37
|
-
let evt = document.createEvent("HTMLEvents");
|
|
38
|
-
evt.initEvent("click", true, true); //initEvent 不加后两个参数在FF下会报错 事件类型,是否冒泡,是否阻止浏览器的默认行为
|
|
39
|
-
aLink.download = fileName;
|
|
40
|
-
aLink.href = URL.createObjectURL(blob);
|
|
41
|
-
aLink.click();
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export { imgUrlToBase64, downloadFile };
|