@ino-cesium/analysis 0.0.26-beta.6 → 0.0.26

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 CHANGED
@@ -1,2 +1,2 @@
1
- # ino-cesium 分析
2
- 分析
1
+ # ino-cesium 分析
2
+ 分析
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{pickPoint as e,makePositionsClose as i,numberId as t,calcLerpPosition as o,makeLnglatsToPositions as n,makePositionsToLnglats as r,calcGeodesicDistances as s,delayTime as l,calcGeodesicDistance as a,makeLnglatToPosition as c,makePositiontoLnglat as g}from"@ino-cesium/common";import*as m from"@turf/turf";import*as p from"cesium";import h from"gsap";const d=o=>{const n=[],r=()=>{n.forEach(e=>{e.vloumePrimitive.removeAll(),o.scene.primitives.remove(e.vloumePrimitive)}),n.length=0};return{set:async e=>{const r=i(e.positions),s=new p.PrimitiveCollection({destroyPrimitives:!1}),l=new p.PrimitiveCollection({destroyPrimitives:!1}),a=new p.PointPrimitiveCollection,c=new p.LabelCollection;l.add(a),s.add(c),s.add(l),o.scene.primitives.add(s);const g=t();let h={};const d=r.map(e=>{const i=p.Cartographic.fromCartesian(e);return{lng:p.Math.toDegrees(i.longitude),lat:p.Math.toDegrees(i.latitude),height:i.height}}),f=Math.min(...d.map(e=>e.height)),P=m.polygon([d.map(e=>[e.lng,e.lat])]),w=m.area(P),C=Math.sqrt(m.area(P)/200),I=m.envelope(P),H=m.centroid(P),b=m.bbox(I),T=m.pointGrid(b,C,{units:"meters"}),S=m.pointsWithinPolygon(T,P).features.map(e=>p.Cartesian3.fromDegrees(e.geometry.coordinates[0],e.geometry.coordinates[1])),M=await o.scene.clampToHeightMostDetailed(S),{maxHeight:D,minHeight:E,digVolume:x,fillVolume:A,volumeLabel:_}=v(M,C,H,c,w,f),N=u(r,f,s);return function(e,i,t,o){const n=p.WallGeometry.fromConstantHeights({positions:e,minimumHeight:t,maximumHeight:i}),r=p.WallGeometry.createGeometry(n),s=new p.GeometryInstance({geometry:r});o.add(new p.Primitive({geometryInstances:[s],asynchronous:!1,appearance:new p.MaterialAppearance({translucent:!0,faceForward:!0,material:p.Material.fromType("Color",{color:p.Color.fromCssColorString("#00ff00").withAlpha(.5)})})}))}(r,D,E,s),function(e,i,t){e.forEach((e,o)=>{t.add({position:e,text:`高程:${y(i[o].height)}米`,font:"14px sans-serif",fillColor:p.Color.WHITE,showBackground:!0,style:p.LabelStyle.FILL_AND_OUTLINE,disableDepthTestDistance:Number.POSITIVE_INFINITY})})}(r,d,c),h={id:g,maxHeight:D,minHeight:E,baseHeight:f,digVolume:x,fillVolume:A,cellsize:C,positions:r,centroid:H,area:w,heightPositions:M,polygonPrimitive:N,linePrimitive:l,labelPrimitive:c,vloumePrimitive:s,volumeLabel:_},n.push(h),h},changeBaseHeight:async i=>{const t=n.findIndex(e=>e.id===i.id);if(-1===t)return;const r=n[t];let s=(await e(o)).lnglat.height;s>i.maxHeight&&(s=i.maxHeight),s<i.minHeight&&(s=i.minHeight),r.baseHeight=Number(s.toFixed(2));const l=r.vloumePrimitive,a=r.labelPrimitive;r.polygonPrimitive&&l.remove(r.polygonPrimitive),r.volumeLabel&&a.remove(r.volumeLabel);const{positions:c,baseHeight:g,heightPositions:m,cellsize:p,centroid:h,area:d}=r,y=u(c,g,l),{digVolume:f,fillVolume:P,volumeLabel:w}=v(m,p,h,a,d,g);n[t]={...r,digVolume:f,fillVolume:P,polygonPrimitive:y,volumeLabel:w}},remove:e=>{const i=n.findIndex(i=>i.id===e.id);-1!==i&&(e.vloumePrimitive.removeAll(),o.scene.primitives.remove(e.vloumePrimitive),n.splice(i,1))},removeAll:r,destroy:()=>{r()}}};function u(e,i,t){const o=new p.PolygonGeometry({polygonHierarchy:new p.PolygonHierarchy(e),height:i}),n=new p.GeometryInstance({geometry:o});return t.add(new p.Primitive({allowPicking:!1,asynchronous:!1,geometryInstances:[n],appearance:new p.MaterialAppearance({translucent:!0,faceForward:!0,material:p.Material.fromType("Color",{color:p.Color.fromCssColorString("#0088ff").withAlpha(.5)})})}))}function v(e,i,t,o,n,r){const s=e.map(e=>p.Cartographic.fromCartesian(e).height),l=Math.min(...s),a=Math.max(...s);let c=0;for(let e=0;e<s.length;e++)s[e]-r>0&&(c+=(s[e]-r)*i*i);let g=0;for(let e=0;e<s.length;e++)r-s[e]>0&&(g+=(r-s[e])*i*i);const m=p.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],a),h={};c?h["挖方体积"]=`${y(c)}方\n`:c=0,g?h["填方体积"]=`${y(g)}方\n`:g=0,n&&(h["横切面积"]=`${y(n)}平方米\n`),l&&(h["最小高程"]=`${y(l)}米\n`),a&&(h["最大高程"]=`${y(a)}米\n`),l&&(h["基准面高程"]=`${y(r)}米`);let d="";Object.keys(h).forEach(e=>{d+=`${e}:${h[e]}`});return{maxHeight:a,minHeight:l,digVolume:c,fillVolume:g,volumeLabel:o.add({position:m,text:d,font:"16px sans-serif",fillColor:p.Color.WHITE,showBackground:!0,style:p.LabelStyle.FILL_AND_OUTLINE,disableDepthTestDistance:Number.POSITIVE_INFINITY})}}function y(e){const i=["","万","百万","千万","亿"];let t=0;for(;e>=1e4&&t<i.length-1;)e/=1e4,t++;return`${e.toFixed(2).replace(/\.?0+$/,"")}${i[t]}`}const f=e=>{const s=new p.ClippingPolygonCollection({polygons:[]});e.scene.globe.clippingPolygons=s;const l=[],a=new p.CustomDataSource("ground-clip");e.dataSources.add(a);const c=()=>{s.isDestroyed()||s.removeAll(),l.length=0,a.entities.removeAll()};return{set:async c=>{if(s.isDestroyed())throw new Error("对象已被销毁");c={interCount:50,...c};let g=o(i(c.positions),c.interCount);g=await e.scene.clampToHeightMostDetailed(g);const m=[],h=n(r(g).map(e=>(m.push(e.height),e.height=-c.depth,e))),d=m.map(e=>e-c.depth),u=Math.min(...d),v=Array.from({length:d.length}).fill(u),y=a.entities.add({wall:{positions:h,minimumHeights:v,maximumHeights:m,material:new p.ImageMaterialProperty({image:`${window.INO_CESIUM_BASE_URL}/assets/images/ground-clip/wall.jpg`})},polygon:{hierarchy:h,height:u,material:new p.ImageMaterialProperty({image:`${window.INO_CESIUM_BASE_URL}/assets/images/ground-clip/poly-soil.jpg`})}}),f=new p.ClippingPolygon({positions:g});s.add(f);const P={id:t(),positions:g,clipPolygon:f,clipEntity:y};return l.push(P),P},remove:i=>{const t=l.findIndex(e=>e.id===i.id);-1!==t&&(l.splice(t,1),a.entities.remove(i.clipEntity),e.scene.globe.clippingPolygons.remove(i.clipPolygon))},removeAll:c,destroy:()=>{c(),s.destroy(),e.scene.globe.clippingPolygons=new p.ClippingPolygonCollection}}},P=e=>{const i=[];e.scene.logarithmicDepthBuffer=!1;const o=e=>{const{tiles:i,fromHeight:t,toHeight:o}=e;return new Promise(n=>{const r=[];console.log(i),i.forEach((i,t)=>{const n=p.Cartesian3.fromElements(0,0,o*(t+1),new p.Cartesian3),s=p.Matrix4.fromTranslation(n),l=p.BoundingSphere.clone(e.originBoundingSpheres[t]),a=p.BoundingSphere.transform(l,s);r.push(a)});const s=i[0].tileset;r.push(s.boundingSphere),s._newBoundingSphere=p.BoundingSphere.fromBoundingSpheres(r);const l={value:o},a={value:t};h.to(a,{...l,duration:2,delay:.5,onUpdate:()=>{i.forEach((e,i)=>{const t=a.value*(i+1),o=p.Cartesian3.fromElements(0,0,t,new p.Cartesian3),n=p.Matrix4.fromTranslation(o);e.transform=n})},onComplete:()=>{}}),n(!0)})},n=()=>{i.forEach(e=>{e.fromHeight=e.toHeight,e.toHeight=0,o(e),e.tiles[0].tileset._newBoundingSphere=void 0}),i.length=0};return{set:async e=>{const{tiles:n,height:r}=e,s=n.map(e=>p.BoundingSphere.clone(e.boundingSphere)),l={id:t(),tiles:n,originBoundingSpheres:s,fromHeight:0,toHeight:r};return n.length&&r?(await o(l),i.push(l),l):l},changeHeight:async(e,i)=>{e.fromHeight=e.toHeight,e.toHeight=i,e.toHeight!==e.fromHeight&&await o(e)},remove:async e=>{const t=i.findIndex(i=>i.id===e.id);-1!==t&&(e.fromHeight=e.toHeight,e.toHeight=0,await o(e),e.tiles[0].tileset._newBoundingSphere=void 0,i.splice(t,1))},removeAll:n,destroy:()=>{n()}}},w=e=>{const i=[];let n;const r=()=>{i.length=0};return{set:async n=>{const{tileSetLoader:r}=n,c=r.getFeatures();let g=r.tileset.root.children;c.length||(g=[g[0]]);const m={id:t(),tiles:g,results:[]};if(!g.length||!n.positions.length)return m;n.distance||(n.distance=10);const h=n.positions,d=s(h),u=Math.floor(d/n.distance),v=o(h,u),y=[];let f=0,P=null;e.terrainProvider instanceof p.EllipsoidTerrainProvider||(P=e.terrainProvider,e.terrainProvider=new p.EllipsoidTerrainProvider);const w=g.map(e=>e._tileId);for(const i of g){r.setVisibleByTileId(w,!1),n.progress&&n.progress(f,i),await l(1e3),r.setVisibleByTileId([i._tileId],!0);let t=JSON.parse(JSON.stringify(v));t=await e.scene.clampToHeightMostDetailed(t);let o=0;const s=t.map((e,i)=>{const n=p.Cartographic.fromCartesian(e);return i>0&&(o+=a(t[i-1],e)),{height:n.height,distance:o,positionIndex:i,position:e,allDistance:d}});f+=1,y.push({datas:s,name:i._tileId,index:f})}return m.results=y,i.push(m),P&&(e.terrainProvider=P),m},changeTipPoint:i=>{if(!i)return n&&e.entities.remove(n),void(n=void 0);n||(n=e.entities.add({position:i.position,billboard:{image:"/earth/images/marker-2d.png",scale:.5,verticalOrigin:p.VerticalOrigin.BOTTOM,disableDepthTestDistance:Number.POSITIVE_INFINITY}})),n.position=i.position},remove:e=>{const t=i.findIndex(i=>i.id===e.id);-1!==t&&i.splice(t,1)},removeAll:r,destroy:()=>{r()}}},C=e=>{const i=[],o=async n=>{if(!n.tileset)return(async i=>{const t=e.scene.primitives._primitives.filter(e=>e instanceof p.Cesium3DTileset),n=[];for(const e of t){const t=await o({positions:i.positions,inverse:i.inverse,tileset:e});n.push(t)}return n})(n);const r=n.positions,s=new p.ClippingPolygon({positions:r});n.tileset.clippingPolygons?n.tileset.clippingPolygons.add(s):n.tileset.clippingPolygons=new p.ClippingPolygonCollection({polygons:[s],inverse:n.inverse});const l={id:t(),tileset:n.tileset,clipPolygon:s};return i.push(l),l},n=e=>{e?e.clippingPolygons.removeAll():(i.forEach(e=>{e.tileset.clippingPolygons.removeAll()}),i.length=0)},r=(e,i)=>{i?i.tileset.clippingPolygons&&(i.tileset.clippingPolygons=new p.ClippingPolygonCollection({polygons:i.tileset.clippingPolygons._polygons,inverse:e})):s(e)},s=e=>{i.forEach(i=>{r(e,i)})};return{set:o,remove:e=>{e.clipPolygon&&e.tileset.clippingPolygons.remove(e.clipPolygon)},setInverse:r,setInverseAll:s,removeAll:n,destroy:()=>{n()}}},I=e=>{const i=new p.PrimitiveCollection({destroyPrimitives:!1});let n,r="/icons/markers/mark-icon.png";const l=[];e.scene.primitives.add(i);const m=i=>{if(!i)return n&&e.entities.remove(n),void(n=void 0);n||(n=e.entities.add({position:c(new p.Cartographic(i.longitude,i.latitude,i.height)),billboard:{image:r,scale:.5,verticalOrigin:p.VerticalOrigin.BOTTOM,heightReference:p.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY}})),n.position=c(new p.Cartographic(i.longitude,i.latitude,i.height))};return{set:async i=>{i.tipMarkerUrl&&(r=i.tipMarkerUrl);const{positions:n}=i;let c=s(n);const m=Math.floor(c/i.pointDistance);let p=o(n,m);p=await e.scene.clampToHeightMostDetailed(p),c=0;const h=p.map((e,i)=>{let t=0;i>0&&(t=a(p[i-1],e),c+=t);return{...g(e),distance:t,allDistance:c}}),d={id:t(),datas:h};return l.push(d),d},remove:e=>{const i=l.findIndex(i=>i.id===e.id);-1!==i&&l.splice(i,1),m()},removeAll:()=>{i.removeAll(),m()},destroy:()=>{e.scene.primitives.remove(i)},changeTipPoint:m}};export{d as createFillVolumeHandler,f as createGroundClipHandler,I as createProfileAnalysis,P as createTilesExplodeHandler,w as createTilesProfileHandler,C as createTilesetClipHandler};
1
+ import{pickPoint as e,makePositionsClose as i,numberId as t,calcLerpPosition as o,makeLnglatsToPositions as n,makePositionsToLnglats as r,calcGeodesicDistances as s,delayTime as l,calcGeodesicDistance as a,makeLnglatToPosition as c,makePositionToLnglat as g}from"@ino-cesium/common";import*as m from"@turf/turf";import*as p from"cesium";import h from"gsap";const d=o=>{const n=[],r=()=>{n.forEach(e=>{e.vloumePrimitive.removeAll(),o.scene.primitives.remove(e.vloumePrimitive)}),n.length=0};return{set:async e=>{const r=i(e.positions),s=new p.PrimitiveCollection({destroyPrimitives:!1}),l=new p.PrimitiveCollection({destroyPrimitives:!1}),a=new p.PointPrimitiveCollection,c=new p.LabelCollection;l.add(a),s.add(c),s.add(l),o.scene.primitives.add(s);const g=t();let h={};const d=r.map(e=>{const i=p.Cartographic.fromCartesian(e);return{lng:p.Math.toDegrees(i.longitude),lat:p.Math.toDegrees(i.latitude),height:i.height}}),f=Math.min(...d.map(e=>e.height)),P=m.polygon([d.map(e=>[e.lng,e.lat])]),w=m.area(P),C=Math.sqrt(m.area(P)/200),I=m.envelope(P),H=m.centroid(P),b=m.bbox(I),T=m.pointGrid(b,C,{units:"meters"}),S=m.pointsWithinPolygon(T,P).features.map(e=>p.Cartesian3.fromDegrees(e.geometry.coordinates[0],e.geometry.coordinates[1])),M=await o.scene.clampToHeightMostDetailed(S),{maxHeight:D,minHeight:E,digVolume:x,fillVolume:A,volumeLabel:_}=v(M,C,H,c,w,f),N=u(r,f,s);return function(e,i,t,o){const n=p.WallGeometry.fromConstantHeights({positions:e,minimumHeight:t,maximumHeight:i}),r=p.WallGeometry.createGeometry(n),s=new p.GeometryInstance({geometry:r});o.add(new p.Primitive({geometryInstances:[s],asynchronous:!1,appearance:new p.MaterialAppearance({translucent:!0,faceForward:!0,material:p.Material.fromType("Color",{color:p.Color.fromCssColorString("#00ff00").withAlpha(.5)})})}))}(r,D,E,s),function(e,i,t){e.forEach((e,o)=>{t.add({position:e,text:`高程:${y(i[o].height)}米`,font:"14px sans-serif",fillColor:p.Color.WHITE,showBackground:!0,style:p.LabelStyle.FILL_AND_OUTLINE,disableDepthTestDistance:Number.POSITIVE_INFINITY})})}(r,d,c),h={id:g,maxHeight:D,minHeight:E,baseHeight:f,digVolume:x,fillVolume:A,cellsize:C,positions:r,centroid:H,area:w,heightPositions:M,polygonPrimitive:N,linePrimitive:l,labelPrimitive:c,vloumePrimitive:s,volumeLabel:_},n.push(h),h},changeBaseHeight:async i=>{const t=n.findIndex(e=>e.id===i.id);if(-1===t)return;const r=n[t];let s=(await e(o)).lnglat.height;s>i.maxHeight&&(s=i.maxHeight),s<i.minHeight&&(s=i.minHeight),r.baseHeight=Number(s.toFixed(2));const l=r.vloumePrimitive,a=r.labelPrimitive;r.polygonPrimitive&&l.remove(r.polygonPrimitive),r.volumeLabel&&a.remove(r.volumeLabel);const{positions:c,baseHeight:g,heightPositions:m,cellsize:p,centroid:h,area:d}=r,y=u(c,g,l),{digVolume:f,fillVolume:P,volumeLabel:w}=v(m,p,h,a,d,g);n[t]={...r,digVolume:f,fillVolume:P,polygonPrimitive:y,volumeLabel:w}},remove:e=>{const i=n.findIndex(i=>i.id===e.id);-1!==i&&(e.vloumePrimitive.removeAll(),o.scene.primitives.remove(e.vloumePrimitive),n.splice(i,1))},removeAll:r,destroy:()=>{r()}}};function u(e,i,t){const o=new p.PolygonGeometry({polygonHierarchy:new p.PolygonHierarchy(e),height:i}),n=new p.GeometryInstance({geometry:o});return t.add(new p.Primitive({allowPicking:!1,asynchronous:!1,geometryInstances:[n],appearance:new p.MaterialAppearance({translucent:!0,faceForward:!0,material:p.Material.fromType("Color",{color:p.Color.fromCssColorString("#0088ff").withAlpha(.5)})})}))}function v(e,i,t,o,n,r){const s=e.map(e=>p.Cartographic.fromCartesian(e).height),l=Math.min(...s),a=Math.max(...s);let c=0;for(let e=0;e<s.length;e++)s[e]-r>0&&(c+=(s[e]-r)*i*i);let g=0;for(let e=0;e<s.length;e++)r-s[e]>0&&(g+=(r-s[e])*i*i);const m=p.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],a),h={};c?h["挖方体积"]=`${y(c)}方\n`:c=0,g?h["填方体积"]=`${y(g)}方\n`:g=0,n&&(h["横切面积"]=`${y(n)}平方米\n`),l&&(h["最小高程"]=`${y(l)}米\n`),a&&(h["最大高程"]=`${y(a)}米\n`),l&&(h["基准面高程"]=`${y(r)}米`);let d="";Object.keys(h).forEach(e=>{d+=`${e}:${h[e]}`});return{maxHeight:a,minHeight:l,digVolume:c,fillVolume:g,volumeLabel:o.add({position:m,text:d,font:"16px sans-serif",fillColor:p.Color.WHITE,showBackground:!0,style:p.LabelStyle.FILL_AND_OUTLINE,disableDepthTestDistance:Number.POSITIVE_INFINITY})}}function y(e){const i=["","万","百万","千万","亿"];let t=0;for(;e>=1e4&&t<i.length-1;)e/=1e4,t++;return`${e.toFixed(2).replace(/\.?0+$/,"")}${i[t]}`}const f=e=>{const s=new p.ClippingPolygonCollection({polygons:[]});e.scene.globe.clippingPolygons=s;const l=[],a=new p.CustomDataSource("ground-clip");e.dataSources.add(a);const c=()=>{s.isDestroyed()||s.removeAll(),l.length=0,a.entities.removeAll()};return{set:async c=>{if(s.isDestroyed())throw new Error("对象已被销毁");c={interCount:50,...c};let g=o(i(c.positions),c.interCount);g=await e.scene.clampToHeightMostDetailed(g);const m=[],h=n(r(g).map(e=>(m.push(e.height),e.height=-c.depth,e))),d=m.map(e=>e-c.depth),u=Math.min(...d),v=Array.from({length:d.length}).fill(u),y=a.entities.add({wall:{positions:h,minimumHeights:v,maximumHeights:m,material:new p.ImageMaterialProperty({image:`${window.INO_CESIUM_BASE_URL}/assets/images/ground-clip/wall.jpg`})},polygon:{hierarchy:h,height:u,material:new p.ImageMaterialProperty({image:`${window.INO_CESIUM_BASE_URL}/assets/images/ground-clip/poly-soil.jpg`})}}),f=new p.ClippingPolygon({positions:g});s.add(f);const P={id:t(),positions:g,clipPolygon:f,clipEntity:y};return l.push(P),P},remove:i=>{const t=l.findIndex(e=>e.id===i.id);-1!==t&&(l.splice(t,1),a.entities.remove(i.clipEntity),e.scene.globe.clippingPolygons.remove(i.clipPolygon))},removeAll:c,destroy:()=>{c(),s.destroy(),e.scene.globe.clippingPolygons=new p.ClippingPolygonCollection}}},P=e=>{const i=[];e.scene.logarithmicDepthBuffer=!1;const o=e=>{const{tiles:i,fromHeight:t,toHeight:o}=e;return new Promise(n=>{const r=[];console.log(i),i.forEach((i,t)=>{const n=p.Cartesian3.fromElements(0,0,o*(t+1),new p.Cartesian3),s=p.Matrix4.fromTranslation(n),l=p.BoundingSphere.clone(e.originBoundingSpheres[t]),a=p.BoundingSphere.transform(l,s);r.push(a)});const s=i[0].tileset;r.push(s.boundingSphere),s._newBoundingSphere=p.BoundingSphere.fromBoundingSpheres(r);const l={value:o},a={value:t};h.to(a,{...l,duration:2,delay:.5,onUpdate:()=>{i.forEach((e,i)=>{const t=a.value*(i+1),o=p.Cartesian3.fromElements(0,0,t,new p.Cartesian3),n=p.Matrix4.fromTranslation(o);e.transform=n})},onComplete:()=>{}}),n(!0)})},n=()=>{i.forEach(e=>{e.fromHeight=e.toHeight,e.toHeight=0,o(e),e.tiles[0].tileset._newBoundingSphere=void 0}),i.length=0};return{set:async e=>{const{tiles:n,height:r}=e,s=n.map(e=>p.BoundingSphere.clone(e.boundingSphere)),l={id:t(),tiles:n,originBoundingSpheres:s,fromHeight:0,toHeight:r};return n.length&&r?(await o(l),i.push(l),l):l},changeHeight:async(e,i)=>{e.fromHeight=e.toHeight,e.toHeight=i,e.toHeight!==e.fromHeight&&await o(e)},remove:async e=>{const t=i.findIndex(i=>i.id===e.id);-1!==t&&(e.fromHeight=e.toHeight,e.toHeight=0,await o(e),e.tiles[0].tileset._newBoundingSphere=void 0,i.splice(t,1))},removeAll:n,destroy:()=>{n()}}},w=e=>{const i=[];let n;const r=()=>{i.length=0};return{set:async n=>{const{tileSetLoader:r}=n,c=r.getFeatures();let g=r.tileset.root.children;c.length||(g=[g[0]]);const m={id:t(),tiles:g,results:[]};if(!g.length||!n.positions.length)return m;n.distance||(n.distance=10);const h=n.positions,d=s(h),u=Math.floor(d/n.distance),v=o(h,u),y=[];let f=0,P=null;e.terrainProvider instanceof p.EllipsoidTerrainProvider||(P=e.terrainProvider,e.terrainProvider=new p.EllipsoidTerrainProvider);const w=g.map(e=>e._tileId);for(const i of g){r.setVisibleByTileId(w,!1),n.progress&&n.progress(f,i),await l(1e3),r.setVisibleByTileId([i._tileId],!0);let t=JSON.parse(JSON.stringify(v));t=await e.scene.clampToHeightMostDetailed(t);let o=0;const s=t.map((e,i)=>{const n=p.Cartographic.fromCartesian(e);return i>0&&(o+=a(t[i-1],e)),{height:n.height,distance:o,positionIndex:i,position:e,allDistance:d}});f+=1,y.push({datas:s,name:i._tileId,index:f})}return m.results=y,i.push(m),P&&(e.terrainProvider=P),m},changeTipPoint:i=>{if(!i)return n&&e.entities.remove(n),void(n=void 0);n||(n=e.entities.add({position:i.position,billboard:{image:"/earth/images/marker-2d.png",scale:.5,verticalOrigin:p.VerticalOrigin.BOTTOM,disableDepthTestDistance:Number.POSITIVE_INFINITY}})),n.position=i.position},remove:e=>{const t=i.findIndex(i=>i.id===e.id);-1!==t&&i.splice(t,1)},removeAll:r,destroy:()=>{r()}}},C=e=>{const i=[],o=async n=>{if(!n.tileset)return(async i=>{const t=e.scene.primitives._primitives.filter(e=>e instanceof p.Cesium3DTileset),n=[];for(const e of t){const t=await o({positions:i.positions,inverse:i.inverse,tileset:e});n.push(t)}return n})(n);const r=n.positions,s=new p.ClippingPolygon({positions:r});n.tileset.clippingPolygons?n.tileset.clippingPolygons.add(s):n.tileset.clippingPolygons=new p.ClippingPolygonCollection({polygons:[s],inverse:n.inverse});const l={id:t(),tileset:n.tileset,clipPolygon:s};return i.push(l),l},n=e=>{e?e.clippingPolygons.removeAll():(i.forEach(e=>{e.tileset.clippingPolygons.removeAll()}),i.length=0)},r=(e,i)=>{i?i.tileset.clippingPolygons&&(i.tileset.clippingPolygons=new p.ClippingPolygonCollection({polygons:i.tileset.clippingPolygons._polygons,inverse:e})):s(e)},s=e=>{i.forEach(i=>{r(e,i)})};return{set:o,remove:e=>{e.clipPolygon&&e.tileset.clippingPolygons.remove(e.clipPolygon)},setInverse:r,setInverseAll:s,removeAll:n,destroy:()=>{n()}}},I=e=>{const i=new p.PrimitiveCollection({destroyPrimitives:!1});let n,r="/icons/markers/mark-icon.png";const l=[];e.scene.primitives.add(i);const m=i=>{if(!i)return n&&e.entities.remove(n),void(n=void 0);n||(n=e.entities.add({position:c(new p.Cartographic(i.longitude,i.latitude,i.height)),billboard:{image:r,scale:.5,verticalOrigin:p.VerticalOrigin.BOTTOM,heightReference:p.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY}})),n.position=c(new p.Cartographic(i.longitude,i.latitude,i.height))};return{set:async i=>{i.tipMarkerUrl&&(r=i.tipMarkerUrl);const{positions:n}=i;let c=s(n);const m=Math.floor(c/i.pointDistance);let p=o(n,m);p=await e.scene.clampToHeightMostDetailed(p),c=0;const h=p.map((e,i)=>{let t=0;i>0&&(t=a(p[i-1],e),c+=t);return{...g(e),distance:t,allDistance:c}}),d={id:t(),datas:h};return l.push(d),d},remove:e=>{const i=l.findIndex(i=>i.id===e.id);-1!==i&&l.splice(i,1),m()},removeAll:()=>{i.removeAll(),m()},destroy:()=>{e.scene.primitives.remove(i)},changeTipPoint:m}};export{d as createFillVolumeHandler,f as createGroundClipHandler,I as createProfileAnalysis,P as createTilesExplodeHandler,w as createTilesProfileHandler,C as createTilesetClipHandler};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ino-cesium/analysis",
3
3
  "type": "module",
4
- "version": "0.0.26-beta.6",
4
+ "version": "0.0.26",
5
5
  "author": "koino",
6
6
  "keywords": [
7
7
  "cesium",
@@ -31,7 +31,7 @@
31
31
  "gsap": "^3.12.5"
32
32
  },
33
33
  "dependencies": {
34
- "@ino-cesium/common": "0.0.26-beta.6"
34
+ "@ino-cesium/common": "0.0.26"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "rimraf dist && rollup -c",