@cearth/tools 2.6.0 → 2.7.0

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.
@@ -1 +1 @@
1
- (function(l,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("cesium"),require("@web-3d/tools")):typeof define=="function"&&define.amd?define(["exports","cesium","@web-3d/tools"],n):(l=typeof globalThis<"u"?globalThis:l||self,n(l.Tools={},l.cesium,l.tools))})(this,function(l,n,M){"use strict";function ht(t){return v(t)||A(t)||z(t)}function v(t){return"modelMatrix"in t}function A(t){return"position"in t}function z(t){return"positions"in t}const N={[n.WebGLConstants.BYTE]:Int8Array,[n.WebGLConstants.UNSIGNED_BYTE]:Uint8Array,[n.WebGLConstants.SHORT]:Int16Array,[n.WebGLConstants.UNSIGNED_SHORT]:Uint16Array,[n.WebGLConstants.INT]:Int32Array,[n.WebGLConstants.UNSIGNED_INT]:Uint32Array,[n.WebGLConstants.FLOAT]:Float32Array,[n.WebGLConstants.DOUBLE]:Float64Array};var F=(t=>(t[t.x=0]="x",t[t.y=1]="y",t[t.z=2]="z",t))(F||{});l.Xyz_Hpr=(t=>(t.x="roll",t.y="pitch",t.z="heading",t))(l.Xyz_Hpr||{}),(t=>{function o(r){for(let[i,s]of Object.entries(t))if(r===s)return i}t.toKey=o;function a(r){return new n.Cartesian3(r.roll,-r.pitch,-r.heading)}t.toCartesian3=a;function e(r){return new n.HeadingPitchRoll(-r[o("heading")],-r[o("pitch")],r[o("roll")])}t.toHeadingPitchRoll=e})(l.Xyz_Hpr||(l.Xyz_Hpr={}));var L=(t=>(t[t.heading=0]="heading",t[t.pitch=1]="pitch",t[t.roll=2]="roll",t))(L||{});function B(t){const o=t?.world,{translation:a,rotation:e,scale:r}=o&&typeof o=="object"?o:{translation:o,rotation:o,scale:o};return{...t,worldTranslation:a,worldRotation:e,worldScale:r}}function m(t){if(t.axis){const{axis:a,angle:e}=t;return n.Quaternion.fromAxisAngle(a,e)}const o=l.Xyz_Hpr.toHeadingPitchRoll(t);return n.Quaternion.fromHeadingPitchRoll(o)}function xt(t,o,a){const e=n.Matrix3.fromQuaternion(t),r=n.Matrix4.fromRotation(e),i=n.Matrix4.inverseTransformation(o,new n.Matrix4),s=n.Matrix4.multiply(i,r,r);return V(s)}function V(t,o){const a=n.Matrix4.getMatrix3(t,new n.Matrix3),e=n.Quaternion.fromRotationMatrix(a);return n.HeadingPitchRoll.fromQuaternion(e,o)}function Ct(t,o,a){a=a??new n.Matrix4;const e=n.Matrix4.inverse(o,new n.Matrix4);return n.Matrix4.multiply(e,t,a)}function J(t,o,a){let e=n.Quaternion.computeAxis(t,new n.Cartesian3);if(e.equals(n.Cartesian3.ZERO))return null;const r=n.Quaternion.computeAngle(t);return e=n.Matrix4.multiplyByPointAsVector(o,e,e),n.Quaternion.fromAxisAngle(e,r)}function Tt(t,o,a){let e=n.Quaternion.computeAxis(t,new n.Cartesian3);if(e.equals(n.Cartesian3.ZERO))return null;const r=n.Quaternion.computeAngle(t),i=n.Matrix4.inverse(o,new n.Matrix4);return e=n.Matrix4.multiplyByPointAsVector(i,e,e),n.Quaternion.fromAxisAngle(e,r)}function D(t,o){let{translation:a,rotation:e,scale:r}=t;const{referFrame:i,worldTranslation:s,worldRotation:c,worldScale:d}=B(o);let f=null;return a&&(s||(a=n.Matrix4.multiplyByPointAsVector(i,a,new n.Cartesian3))),e&&(f=m(e),c||(f=J(f,i))),r&&(d||(r=n.Matrix4.multiplyByPointAsVector(i,r,new n.Cartesian3))),{translation:a,rotation:f,scale:r}}function W(t,o){let{translation:a,rotation:e,scale:r}=t;const{referFrame:i,worldTranslation:s,worldRotation:c,worldScale:d}=B(o),f=i?n.Matrix4.inverse(i,new n.Matrix4):null;let u=null;if(a&&s&&(a=n.Matrix4.multiplyByPointAsVector(f,a,new n.Cartesian3)),e&&(u=m(e),c)){let y=n.Quaternion.computeAxis(u,new n.Cartesian3);if(!y.equals(n.Cartesian3.ZERO)){const p=n.Quaternion.computeAngle(u);y=n.Matrix4.multiplyByPointAsVector(f,y,y),u=n.Quaternion.fromAxisAngle(y,p)}}return r&&d&&(r=n.Matrix4.multiplyByPointAsVector(f,r,new n.Cartesian3)),{translation:a,rotation:u,scale:r}}function k(t,o){const a=o?.defaultMatrix;let{translation:e,rotation:r,scale:i}=D(t,o);if(a){if(e||(e=n.Matrix4.getTranslation(a,new n.Cartesian3)),!r){const c=n.Matrix4.getMatrix3(a,new n.Matrix3);r=n.Quaternion.fromRotationMatrix(c)}i||(i=n.Matrix4.getScale(a,new n.Cartesian3))}const s=new n.TranslationRotationScale(e??void 0,r??void 0,i??void 0);return n.Matrix4.fromTranslationRotationScale(s)}function Rt(t){const{translation:o,rotation:a,scale:e}=t,r=a?m(a):void 0,i=new n.TranslationRotationScale(o??void 0,r,e??void 0);return n.Matrix4.fromTranslationRotationScale(i)}function E(t,o,a){const e=n.Cartesian3.subtract(o,t,new n.Cartesian3),r=n.Cartesian3.subtract(a,t,new n.Cartesian3),i=n.Cartesian3.cross(e,r,e);return n.Cartesian3.normalize(i,e)}function mt(t,o,a){const e=E(t,o,a);return n.Plane.fromPointNormal(e,t)}function*Pt(t,o=!0,a,e){const r=t.length,i=o?r:r-1,s=a||e?n.Cartesian3.prototype.equalsEpsilon:n.Cartesian3.prototype.equals;for(let c=0;c<i;c++){const d=t[c];let f=(c+1)%r,u=t[f],y=c;for(;s.call(d,u,a,e);){if(f=(++y+1)%r,f===c)return;u=t[f]}c=y,yield[d,u]}}function P(t,o,a){a=a??new n.Matrix4;const e=n.Matrix4.inverse(o,new n.Matrix4),r=n.Matrix4.multiply(t,e,e);return n.Matrix4.multiply(o,r,a)}function vt(t,o,a,e){e=e??new n.Matrix4;const r=n.Matrix4.inverse(a,new n.Matrix4);let i=n.Matrix4.multiply(r,t,r);return i=n.Matrix4.multiply(o,i,i),n.Matrix4.multiply(a,i,e)}function At(t,o,a){const e=n.Matrix4.fromTranslation(t);return P(e,o,a)}function Dt(t,o,a,e){const r=n.Quaternion.fromAxisAngle(t,o),i=n.Matrix3.fromQuaternion(r),s=n.Matrix4.fromRotation(i);return P(s,a,e)}function St(t,o,a){const e=n.Matrix4.fromScale(t);return P(e,o,a)}function Ot(t,o,a){const e=n.Matrix3.fromScale(o);if(a)for(const r of t)n.Cartesian3.subtract(r,a,r),n.Matrix3.multiplyByVector(e,r,r),n.Cartesian3.add(r,a,r);else{const r=n.Matrix3.fromScale(o);for(const i of t)n.Matrix3.multiplyByVector(r,i,i)}return t}function It(t,o){const{translation:a,rotation:e,scale:r}=t;let i;if(e){const{axis:c,angle:d}=e;i=n.Quaternion.fromAxisAngle(c,d)}const s=new n.TranslationRotationScale(a??void 0,i,r??void 0);return n.Matrix4.fromTranslationRotationScale(s,o??void 0)}function b(t,o,a){a??=new n.TranslationRotationScale;const e=n.Matrix4.pack(t,[]),r=[],i=[],s=[],c=o?M.MatrixComposeOrder[o]:M.MatrixComposeOrder.trs;return M.mat4_decompose_quat(r,s,i,e,c),n.Cartesian3.unpack(r,0,a.translation),n.Cartesian3.unpack(i,0,a.scale),n.Quaternion.unpack(s,0,a.rotation),a}function Bt(t,o){return b(t,null,o)}function q(t,o,a){const e=n.Cartesian3.pack(t.translation,[]),r=n.Cartesian3.pack(t.scale,[]),i=n.Quaternion.pack(t.rotation,[]),s=o?M.MatrixComposeOrder[o]:M.MatrixComposeOrder.trs,c=M.mat4_compose_quat([],e,i,r,s);return n.Matrix4.unpack(c,0,a)}const Vt=n.Matrix4.fromTranslationRotationScale;function U(t,o){const a=n.Matrix4.inverse(t,new n.Matrix4),e=new n.Matrix4;function r(s,c){return c=q(s,o,c),n.Matrix4.multiply(t,c,c)}function i(s,c){return n.Matrix4.multiply(a,s,e),b(e,o,c)}return{compose:r,decompose:i,referInverse:a}}function j(t,o,a){const e=n.Transforms.eastNorthUpToFixedFrame(t,a??void 0);return{...U(e,o),refer:e}}function bt(t){let o=t.boundingSphere;if(o)return o;let a=t.geometryInstances;if(a){a=Array.isArray(a)?a:[a];const r=a.map(i=>i.geometry.boundingSphere);return n.BoundingSphere.fromBoundingSpheres(r)}const e=t.positions;return e?.length>0?n.BoundingSphere.fromPoints(e):null}function Qt(t,o){o=o??new n.Cartesian3;const a=t.position;if(a)return a instanceof n.Cartesian3?a:a.getValue(n.JulianDate.now(),o);const e=t.modelMatrix;if(e)return n.Matrix4.getTranslation(e,o);const r=t.positions;return r?.length>0?n.BoundingSphere.fromPoints(r).center:null}function _t(t,o,a){let{translation:e,rotation:r,scale:i}=D(o,a);const s=new n.TranslationRotationScale(e??void 0,r??void 0,i??void 0),c=n.Matrix4.fromTranslationRotationScale(s);return Y(t,c)}function Y(t,o){const a=t.modelMatrix;if(a)return n.Matrix4.multiply(o,a,a),t.modelMatrix=a,!0;const e=t.position;if(e){if("scale"in t){const i=n.Matrix4.getTranslation(o,new n.Cartesian3);n.Cartesian3.add(e,i,e);const s=t.scale??1,c=n.Matrix4.getScale(o,new n.Cartesian3);t.scale=n.Cartesian3.maximumComponent(c)*s}else n.Matrix4.multiplyByPoint(o,e,e);return t.position=e,!0}const r=t.positions;if(r?.length>0){for(const i of r)n.Matrix4.multiplyByPoint(o,i,i);return t.positions=r,!0}return!1}function Gt(t,o,a){const e=Z(t),r=k(o,{...a,defaultMatrix:e});return X(t,r)}function X(t,o){if(v(t))return t.modelMatrix=o,!0;const a=n.Matrix4.getTranslation(o,new n.Cartesian3);if(A(t)){if(t.position=a,"scale"in t){const r=n.Matrix4.getScale(o,new n.Cartesian3);t.scale=n.Cartesian3.maximumComponent(r)}return!0}const e=t.positions;if(e?.length>0){const r=n.BoundingSphere.fromPoints(e);n.Cartesian3.subtract(a,r.center,a);for(const i of e)n.Cartesian3.add(i,a,i);return t.positions=e,!0}return!1}function Z(t){if(v(t))return t.modelMatrix;if(A(t)){const a=t.position,e=t.scale??1,r=new n.TranslationRotationScale(a,void 0,new n.Cartesian3(e,e,e));return n.Matrix4.fromTranslationRotationScale(r)}const o=t.positions;if(o?.length>0){const a=n.BoundingSphere.fromPoints(o);return n.Matrix4.fromTranslation(a.center)}return null}function Ht(t,o){let{translation:a,rotation:e,scale:r}=D(o,o);const{reset:i,referFrame:s}=o,c=n.JulianDate.now(),d=!i;if(e){let h=e;if(d){const w=t.orientation?.getValue(c);w&&(h=n.Quaternion.multiply(e,w,w))}t.orientation=h}if(a){let h=a;if(d){const w=t.position?.getValue(c);w&&(h=n.Cartesian3.add(w,a,w))}t.position=h}if(!s)return;const{translation:f,rotation:u,scale:y}=W(o,o),p=new n.TranslationRotationScale(f??void 0,u??void 0,y??void 0);let g=n.Matrix4.fromTranslationRotationScale(p);if(g=P(g,s,g),y){const h=t.box;h&&K(h,y);const w=t.cylinder;w&&$(w,y);const pt=t.ellipse;pt&&tt(pt,y);const gt=t.ellipsoid;gt&&nt(gt,y);const Mt=t.model;Mt&&at(Mt,y,i);const wt=t.plane;wt&&ot(wt,y)}const x=t.corridor;x&&et(x,g,y);const T=t.polygon;T&&rt(T,g,y);const C=t.polyline;C&&it(C,g,y);const R=t.polylineVolume;R&&lt(R,g,y);const I=t.wall;I&&st(I,g,y)}function K(t,o){const a=n.JulianDate.now(),e=t.dimensions?.getValue(a);e&&(t.dimensions=n.Cartesian3.multiplyComponents(e,o,e))}function $(t,o){const a=n.JulianDate.now(),e=t.length?.getValue(a);e!=null&&(t.length=e*o.z);const r=Math.max(o.x,o.y),i=t.topRadius?.getValue(a);i!=null&&(t.topRadius=i*r);const s=o.z,c=t.bottomRadius?.getValue(a);c!=null&&(t.bottomRadius=c*s)}function tt(t,o){const a=n.JulianDate.now(),e=Math.max(o.x,o.y),r=o.z,i=t.semiMajorAxis?.getValue(a);i!=null&&(t.semiMajorAxis=i*e);const s=t.semiMinorAxis?.getValue(a);s!=null&&(t.semiMinorAxis=s*e);const c=t.height?.getValue(a);c!=null&&(t.height=c*r);const d=t.extrudedHeight?.getValue(a);d!=null&&(t.extrudedHeight=d*r)}function nt(t,o){const a=n.JulianDate.now(),e=t.radii?.getValue(a);e!=null&&(t.radii=n.Cartesian3.multiplyComponents(e,o,e));const r=t.innerRadii?.getValue(a);r!=null&&(t.innerRadii=n.Cartesian3.multiplyComponents(r,o,r))}function at(t,o,a){let e=n.Cartesian3.maximumComponent(o);if(!a){const r=n.JulianDate.now(),i=t.scale?.getValue(r)??1;e*=i}t.scale=e}function ot(t,o){const a=n.JulianDate.now(),e=n.Cartesian2.fromCartesian3(o),r=t.dimensions?.getValue(a);r&&(t.dimensions=n.Cartesian2.multiplyComponents(r,e,r))}function et(t,o,a){const e=n.JulianDate.now(),r=new n.Cartesian3,i=t.positions?.getValue(e);if(i?.length>0){for(const y of i)n.Matrix4.multiplyByPoint(o,y,y);t.dimensions=i}const s=a??n.Matrix4.getScale(o,r),c=Math.max(s.x,s.y);t.width?.getValue(e)!=null&&(t.width=c*scale);const f=t.height?.getValue(e),u=s.z;f!=null&&(t.height=f*u)}function rt(t,o,a){const e=n.JulianDate.now(),r=new n.Cartesian3,i=t.hierarchy?.getValue(e);i&&(Q(i,o),t.hierarchy=i);const c=(a??n.Matrix4.getScale(o,r)).z,d=t.height?.getValue(e);d!=null&&(t.height=d*c);const f=t.extrudedHeight?.getValue(e);f!=null&&(t.extrudedHeight=f*c)}function Q(t,o){const{positions:a,holes:e}=t;for(const r of a)n.Matrix4.multiplyByPoint(o,r,r);t.positions=a;for(const r of e)Q(r,o)}function it(t,o,a){const e=n.JulianDate.now(),r=new n.Cartesian3,i=t.positions?.getValue(e);if(i?.length>0){for(const f of i)n.Matrix4.multiplyByPoint(o,f,f);t.positions=i}const s=a??n.Matrix4.getScale(o,r),c=Math.max(s.x,s.y);t.width?.getValue(e)!=null&&(t.width=c*scale)}function lt(t,o,a){const e=n.JulianDate.now(),r=new n.Cartesian3,i=t.positions?.getValue(e);if(i?.length>0){for(const f of i)n.Matrix4.multiplyByPoint(o,f,f);t.positions=i}const s=a??n.Matrix4.getScale(o,r),c=n.Cartesian2.fromCartesian3(s),d=t.shape?.getValue(e);if(d!=null){for(const f of d)n.Cartesian2.multiplyComponents(f,c,f);t.shape=d}}function st(t,o,a){const e=n.JulianDate.now(),r=new n.Cartesian3,i=t.positions?.getValue(e);if(i?.length>0){for(const u of i)n.Matrix4.multiplyByPoint(o,u,u);t.positions=i}const c=(a??n.Matrix4.getScale(o,r)).z,d=t.minimumHeights?.getValue(e);d!=null&&(graphicsgraphics.minimumHeights=d.map(u=>u*c));const f=t.maximumHeights?.getValue(e);f!=null&&(graphicsgraphics.maximumHeights=f.map(u=>u*c))}function zt(t,o,a){const e=n.JulianDate.now(),r=t.position?.getValue(e);if(!r)return null;const i=t.orientation?.getValue(e),s=t.model?.scale?.getValue(e)??1,c=new n.Cartesian3(s,s,s),d=o(r,a),f=n.Matrix4.inverse(d,new n.Matrix4),u=n.Matrix4.multiplyByPoint(f,r,new n.Cartesian3),y={translation:u,position:r,scale:c,rotation:new n.Cartesian3};let p;if(i){const T=n.Matrix3.fromQuaternion(i),C=n.Matrix4.fromRotation(T),R=n.Matrix4.multiply(f,C,C),I=V(R);p=l.Xyz_Hpr.toCartesian3(I),y.rotation=p}const g=new n.TranslationRotationScale(u??void 0,p?m(p):void 0,c??void 0);let x=n.Matrix4.fromTranslationRotationScale(g);return y.matrix=x,y}function Nt(t){return t.values.length/t.componentsPerAttribute}function Ft(t){return n.ComponentDatatype.getSizeInBytes(t.componentDatatype)*t.componentsPerAttribute}function Lt(t){const{componentDatatype:o,vertexBuffer:a}=t,e=N[o];if(!e)throw new Error("不支持的数据类型");const r=a.sizeInBytes,i=n.ComponentDatatype.getSizeInBytes(o),s=r/i;let c=new e(s);return a.getBufferData(c,0,0,r),c}new n.Cartesian2,new n.Cartesian3,new n.Cartesian4;const _=[new n.Cartesian2,new n.Cartesian2,new n.Cartesian2,new n.Cartesian2],S=[new n.Cartesian3,new n.Cartesian3,new n.Cartesian3,new n.Cartesian3];new n.Cartesian4,new n.Cartesian4,new n.Cartesian4,new n.Cartesian4;const Jt=[new n.Cartographic,new n.Cartographic,new n.Cartographic,new n.Cartographic];new n.Rectangle,new n.Rectangle,new n.Rectangle,new n.Rectangle,new n.Matrix2,new n.Matrix2,new n.Matrix2,new n.Matrix2,new n.Matrix3,new n.Matrix3,new n.Matrix3,new n.Matrix3,new n.Matrix4,new n.Matrix4,new n.Matrix4,new n.Matrix4,new n.Quaternion,new n.Quaternion,new n.Quaternion,new n.Quaternion,new n.HeadingPitchRoll,new n.HeadingPitchRoll,new n.HeadingPitchRoll,new n.HeadingPitchRoll;function Wt(t,o=[]){const{stride:a,vertexArray:e}=t,r=e.length/a,i=S[0];for(let s=0;s<r;s++)t.encoding.decodePosition(e,s,i),n.Cartesian3.pack(i,o,o.length);return o}function kt(t,o,a){return t.encoding.decodePosition(t.vertexArray,o,a)}function ct(t){const{stride:o,vertices:a,indices:e,encoding:r}=t,i=a.length/o,s=S[0],c=new Float32Array(i*3),d=_[0],f=new Float32Array(i*2),u=new Float32Array(i);for(let y=0;y<i;y++){r.decodePosition(a,y,s),n.Cartesian3.pack(s,c,y*3);const p=r.decodeHeight(a,y);u[y]=p,r.decodeTextureCoordinates(a,y,d),n.Cartesian2.pack(d,f,y*2)}return{attributes:{position:{array:c,vectorSize:3},uv:{array:f,vectorSize:2},height:{array:u,vectorSize:1}},indices:e.slice(),count:i}}function G(t,o){const a=t._surface._tilesToRender,e=[],r=new n.Rectangle;for(const i of a){const{rectangle:s}=i;n.Rectangle.intersection(o,s,r)&&e.push(i)}return e}function Et(t){const o=t._surface._tilesToRender;return ft(o)}function ft(t){const o=new Set;for(const i of t)o.add(i.level);const a=[...o],e=Math.min.apply(Math,a),r=Math.max.apply(Math,a);return{min:e,max:r}}function H(t){return t.map(o=>{const{mesh:a,terrainData:e}=o.data,r=ct(a),{x:i,y:s,level:c}=o,d=[e._minimumHeight,e._maximumHeight];return{data:r,encoding:a.encoding,rectangle:o.rectangle,heightRange:d,x:i,y:s,level:c}})}function qt(t){const{x:o,y:a,level:e}=t;return t.data.terrainData.upsample(t.tilingScheme,o,a,e,o,a,e)}function dt(t,o,a){const{east:e,north:r,south:i,west:s}=o,c=Jt[0];c.longitude=s,c.latitude=i;const d=t.positionToTileXY(c,a,_[0]);c.longitude=e,c.latitude=r;const f=t.positionToTileXY(c,a,_[1]),[u,y]=d.x<f.x?[d.x,f.x]:[f.x,d.x],[p,g]=d.y<f.y?[d.y,f.y]:[f.y,d.y];return{min:[u,p],max:[y,g]}}const Ut=32767;function jt(t,o=new n.Cartesian3){return n.Matrix3.getScale(t.halfAxes,o),n.Cartesian3.multiplyByScalar(o,2*Ut,o),o}function O(t,o,a){return a=t.getLocalCurvature(o,a),a.x=1/a.x,a.y=1/a.y,a}function Yt(t,o,a){a=O(t,o,a);const e=Math.PI/180;return n.Cartesian2.multiplyByScalar(a,e,a)}function ut(t){const{_quantizedVertices:o,_indices:a}=t,e=o.length/3,r={type:"Float32Array",start:0,vectorSize:1},i={type:"Float32Array",start:e,vectorSize:1},s={type:"Float32Array",start:e*2,vectorSize:1};return{array:new Float32Array(o),attributes:{u:r,v:i,height:s},count:e,indices:a}}async function Xt(t,o,a,e){const r=await t.requestTileGeometry(o,a,e);if(!r)return null;const i=ut(r),s=[data._minimumHeight,data._maximumHeight],c=t.tilingScheme.tileXYToRectangle(o,a,e),d=M.getMatrixOfQuantizedMeshTerrainData(c,s),f=n.Matrix4.fromArray(d,void 0),u=["u","v","height"],y=new M.Geometry({...i,positionNames:u}),p=new n.Cartesian3;return y.mapForAggregate(u,(g,x)=>(n.Cartesian3.fromArray(g,0,p),n.Matrix4.multiplyByPoint(f,p,p),new n.Cartographic(p.x,p.y,p.z)))}async function Zt(t,o,a){const{min:e,max:r}=dt(t.tilingScheme,o,a),i=[],s=[];for(let d=e[0];d<=r[0];d++)for(let f=e[1];f<=r[1];f++){const u=yt(t,d,f,a);u&&(i.push(u),s.push({x:d,y:f}))}return(await Promise.all(i)).map(function(d,f){const{x:u,y}=s[f];return{x:u,y,level:a,data:d}})}async function yt(t,o,a,e){return t.getTileDataAvailable(o,a,e)?(await t.loadTileDataAvailability(o,a,e),t.requestTileGeometry(o,a,e)):Promise.reject("不可用")}async function Kt(t,o){const a=n.Rectangle.fromCartesianArray(o),e=n.Cartographic.toCartesian(n.Rectangle.center(a)),r=O(t.ellipsoid,e),i=[r.x,r.y,1],s=G(t,a),c=H(s),d=n.Transforms.eastNorthUpToFixedFrame(e);n.Matrix4.inverseTransformation(d,d);const f=o.map(p=>{const g=n.Matrix4.multiplyByPoint(d,p,S[2]);return[g.x,g.y]});let u=0;const y=c.map(async p=>{const{data:g,...x}=p,{position:T,uv:C,height:R}=g.attributes;u+=await M.workerApi.computeRelationAreaOfPolygon2Terrain({args:[{...g,...x,positionNames:["position"],region:f,matrix:n.Matrix4.pack(d,[]),relation:M.GeometricRelation.Contain|M.GeometricRelation.Intersect,scale:i}],transfer:[T.array.buffer,C.array.buffer,R.array.buffer,g.indices.buffer]})});if(await Promise.all(y),u===0||isNaN(u)){console.warn("贴地面积计算异常,已回退到椭球面投影面积",u);const p=o.map(g=>n.Cartesian3.pack(g,[]));return u=M.computeSignAreaOfPolygon3(p),Math.abs(u)}return u}function $t(t,o){const a=n.Rectangle.fromCartesianArray(o),e=n.Cartographic.toCartesian(n.Rectangle.center(a)),r=O(t.ellipsoid,e),i=[r.x,r.y,1],s=G(t,a),c=H(s),d=n.Transforms.eastNorthUpToFixedFrame(e);n.Matrix4.inverseTransformation(d,d);const f=o.map(y=>{const p=n.Matrix4.multiplyByPoint(d,y,S[2]);return[p.x,p.y]});let u=0;for(const y of c){const{data:p,...g}=y;u+=M.computeRelationAreaOfPolygon2Terrain({...p,...g,positionNames:["position"],region:f,matrix:n.Matrix4.pack(d,[]),relation:M.GeometricRelation.Contain|M.GeometricRelation.Intersect,scale:i})}if(u===0||isNaN(u)){console.warn("贴地面积计算异常,已回退到椭球面投影面积",u);const y=o.map(p=>n.Cartesian3.pack(p,[]));return u=M.computeSignAreaOfPolygon3(y),Math.abs(u)}return u}function tn(t,o,a){const e=n.Matrix4.inverse(t.root.transform,new n.Matrix4),{compose:r,decompose:i,...s}=j(t.boundingSphere.center,o,a);function c(f,u){return u=r(f,u),n.Matrix4.multiply(u,e,u)}function d(f){return i(t.root.computedTransform,f)}return{...s,right:e,compose:c,decompose:d}}l.CartesianAxis=F,l.HeadingPitchRollComponent=L,l.applyMatrixReferFrame=vt,l.applyTransformInPrimitive=Y,l.applyTransformInfoPrimitive=_t,l.componentDatatypeTypedArrayMap=N,l.computeAttributeSizeInBytes=Ft,l.computeNormalOfCoplanars=E,l.computeTerrainAreaOfPolygon=$t,l.computeTerrainAreaOfPolygon_worker=Kt,l.computeVertexNumOfAttribute=Nt,l.createPlaneOfCoplanars=mt,l.flatTransformInfoOptions=B,l.getAttributeData=Lt,l.getBoundingSphere=bt,l.getDecodePositionsOfTerrainMesh=Wt,l.getEntityInfo=zt,l.getGeometryDataOfQuantizedMeshTerrainData=ut,l.getGeometryDataOfTerrainMesh=ct,l.getLevelRangeOfQuadtreeTiles=ft,l.getLocalCurvatureRadius=O,l.getLocalSizePerDegrees=Yt,l.getLocalTransformInfo=W,l.getMatrix4OfTransformInfo=It,l.getNeighborPairs=Pt,l.getPosition=Qt,l.getPositionOfTerrainMesh=kt,l.getRenderedQuadtreeTilesOfIntersectRectangle=G,l.getRenderedTileLevelRange=Et,l.getScaleOfTerrainDataByOrientedBoundingBox=jt,l.getTerrainData=yt,l.getTerrainDataOfQuadtreeTile=qt,l.getTerrainDatasOfIntersectRectangle=Zt,l.getTerrainDatasOfQuadtreeTiles=H,l.getTileRangeOfIntersectRectangle=dt,l.getTransform=Z,l.getWorldDataOfQuantizedMeshTerrainData=Xt,l.getWorldMatrix=k,l.getWorldTransformInfo=D,l.isMatrixPrimitive=v,l.isPositionListPrimitive=z,l.isPositionPrimitive=A,l.isPrimitiveObject=ht,l.localQuaternionToWorld=J,l.localTRS_WorldMatrix4_Convert=U,l.localTRS_WorldMatrix4_ENU_Convert=j,l.makeMatrixReferFrame=P,l.mat4_compose=Vt,l.mat4_composeByOrder=q,l.mat4_decompose=Bt,l.mat4_decomposeByOrder=b,l.matrix4ToHeadingPitchRoll=V,l.quaternionToHeadingPitchRoll=xt,l.resetTransformInPrimitive=X,l.resetTransformInfoPrimitive=Gt,l.rotateMatrixReferFrame=Dt,l.rotationInfoToQuaternion=m,l.scaleBoxGraphics=K,l.scaleCylinderGraphics=$,l.scaleEllipseGraphics=tt,l.scaleEllipsoidGraphics=nt,l.scaleMatrixReferFrame=St,l.scaleModelGraphics=at,l.scalePlaneGraphics=ot,l.scalePoints=Ot,l.tileset_enuTRS_modelMatrix_Convert=tn,l.transformCorridorGraphics=et,l.transformEntity=Ht,l.transformInfoToMatrix=Rt,l.transformPolygonGraphics=rt,l.transformPolygonHierarchy=Q,l.transformPolylineGraphics=it,l.transformPolylineVolumeGraphics=lt,l.transformWallGraphics=st,l.translationMatrixReferFrame=At,l.worldMatrixToLocal=Ct,l.worldQuaternionToLocal=Tt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
1
+ (function(l,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("cesium"),require("@web-3d/tools")):typeof define=="function"&&define.amd?define(["exports","cesium","@web-3d/tools"],t):(l=typeof globalThis<"u"?globalThis:l||self,t(l.Tools={},l.cesium,l.tools))})(this,function(l,t,M){"use strict";function ht(n){return P(n)||A(n)||N(n)}function P(n){return"modelMatrix"in n}function A(n){return"position"in n}function N(n){return"positions"in n}const F={[t.WebGLConstants.BYTE]:Int8Array,[t.WebGLConstants.UNSIGNED_BYTE]:Uint8Array,[t.WebGLConstants.SHORT]:Int16Array,[t.WebGLConstants.UNSIGNED_SHORT]:Uint16Array,[t.WebGLConstants.INT]:Int32Array,[t.WebGLConstants.UNSIGNED_INT]:Uint32Array,[t.WebGLConstants.FLOAT]:Float32Array,[t.WebGLConstants.DOUBLE]:Float64Array};var L=(n=>(n[n.x=0]="x",n[n.y=1]="y",n[n.z=2]="z",n))(L||{});l.Xyz_Hpr=(n=>(n.x="roll",n.y="pitch",n.z="heading",n))(l.Xyz_Hpr||{}),(n=>{function a(r){for(let[i,s]of Object.entries(n))if(r===s)return i}n.toKey=a;function o(r){return new t.Cartesian3(r.roll,-r.pitch,-r.heading)}n.toCartesian3=o;function e(r){return new t.HeadingPitchRoll(-r[a("heading")],-r[a("pitch")],r[a("roll")])}n.toHeadingPitchRoll=e})(l.Xyz_Hpr||(l.Xyz_Hpr={}));var J=(n=>(n[n.heading=0]="heading",n[n.pitch=1]="pitch",n[n.roll=2]="roll",n))(J||{});function B(n){const a=n?.world,{translation:o,rotation:e,scale:r}=a&&typeof a=="object"?a:{translation:a,rotation:a,scale:a};return{...n,worldTranslation:o,worldRotation:e,worldScale:r}}function R(n){if(n.axis){const{axis:o,angle:e}=n;return t.Quaternion.fromAxisAngle(o,e)}const a=l.Xyz_Hpr.toHeadingPitchRoll(n);return t.Quaternion.fromHeadingPitchRoll(a)}function xt(n,a,o){const e=t.Matrix3.fromQuaternion(n),r=t.Matrix4.fromRotation(e),i=t.Matrix4.inverseTransformation(a,new t.Matrix4),s=t.Matrix4.multiply(i,r,r);return _(s)}function _(n,a){const o=t.Matrix4.getMatrix3(n,new t.Matrix3),e=t.Quaternion.fromRotationMatrix(o);return t.HeadingPitchRoll.fromQuaternion(e,a)}function Tt(n,a,o){o=o??new t.Matrix4;const e=t.Matrix4.inverse(a,new t.Matrix4);return t.Matrix4.multiply(e,n,o)}function W(n,a,o){let e=t.Quaternion.computeAxis(n,new t.Cartesian3);if(e.equals(t.Cartesian3.ZERO))return null;const r=t.Quaternion.computeAngle(n);return e=t.Matrix4.multiplyByPointAsVector(a,e,e),t.Quaternion.fromAxisAngle(e,r)}function Ct(n,a,o){let e=t.Quaternion.computeAxis(n,new t.Cartesian3);if(e.equals(t.Cartesian3.ZERO))return null;const r=t.Quaternion.computeAngle(n),i=t.Matrix4.inverse(a,new t.Matrix4);return e=t.Matrix4.multiplyByPointAsVector(i,e,e),t.Quaternion.fromAxisAngle(e,r)}function S(n,a){let{translation:o,rotation:e,scale:r}=n;const{referFrame:i,worldTranslation:s,worldRotation:c,worldScale:d}=B(a);let f=null;return o&&(s||(o=t.Matrix4.multiplyByPointAsVector(i,o,new t.Cartesian3))),e&&(f=R(e),c||(f=W(f,i))),r&&(d||(r=t.Matrix4.multiplyByPointAsVector(i,r,new t.Cartesian3))),{translation:o,rotation:f,scale:r}}function k(n,a){let{translation:o,rotation:e,scale:r}=n;const{referFrame:i,worldTranslation:s,worldRotation:c,worldScale:d}=B(a),f=i?t.Matrix4.inverse(i,new t.Matrix4):null;let u=null;if(o&&s&&(o=t.Matrix4.multiplyByPointAsVector(f,o,new t.Cartesian3)),e&&(u=R(e),c)){let p=t.Quaternion.computeAxis(u,new t.Cartesian3);if(!p.equals(t.Cartesian3.ZERO)){const y=t.Quaternion.computeAngle(u);p=t.Matrix4.multiplyByPointAsVector(f,p,p),u=t.Quaternion.fromAxisAngle(p,y)}}return r&&d&&(r=t.Matrix4.multiplyByPointAsVector(f,r,new t.Cartesian3)),{translation:o,rotation:u,scale:r}}function E(n,a){const o=a?.defaultMatrix;let{translation:e,rotation:r,scale:i}=S(n,a);if(o){if(e||(e=t.Matrix4.getTranslation(o,new t.Cartesian3)),!r){const c=t.Matrix4.getMatrix3(o,new t.Matrix3);r=t.Quaternion.fromRotationMatrix(c)}i||(i=t.Matrix4.getScale(o,new t.Cartesian3))}const s=new t.TranslationRotationScale(e??void 0,r??void 0,i??void 0);return t.Matrix4.fromTranslationRotationScale(s)}function mt(n){const{translation:a,rotation:o,scale:e}=n,r=o?R(o):void 0,i=new t.TranslationRotationScale(a??void 0,r,e??void 0);return t.Matrix4.fromTranslationRotationScale(i)}function q(n,a,o){const e=t.Cartesian3.subtract(a,n,new t.Cartesian3),r=t.Cartesian3.subtract(o,n,new t.Cartesian3),i=t.Cartesian3.cross(e,r,e);return t.Cartesian3.normalize(i,e)}function Rt(n,a,o){const e=q(n,a,o);return t.Plane.fromPointNormal(e,n)}function*vt(n,a=!0,o,e){const r=n.length,i=a?r:r-1,s=o||e?t.Cartesian3.prototype.equalsEpsilon:t.Cartesian3.prototype.equals;for(let c=0;c<i;c++){const d=n[c];let f=(c+1)%r,u=n[f],p=c;for(;s.call(d,u,o,e);){if(f=(++p+1)%r,f===c)return;u=n[f]}c=p,yield[d,u]}}function v(n,a,o){o=o??new t.Matrix4;const e=t.Matrix4.inverse(a,new t.Matrix4),r=t.Matrix4.multiply(n,e,e);return t.Matrix4.multiply(a,r,o)}function Pt(n,a,o,e){e=e??new t.Matrix4;const r=t.Matrix4.inverse(o,new t.Matrix4);let i=t.Matrix4.multiply(r,n,r);return i=t.Matrix4.multiply(a,i,i),t.Matrix4.multiply(o,i,e)}function At(n,a,o){const e=t.Matrix4.fromTranslation(n);return v(e,a,o)}function St(n,a,o,e){const r=t.Quaternion.fromAxisAngle(n,a),i=t.Matrix3.fromQuaternion(r),s=t.Matrix4.fromRotation(i);return v(s,o,e)}function Dt(n,a,o){const e=t.Matrix4.fromScale(n);return v(e,a,o)}function Ot(n,a,o){const e=t.Matrix3.fromScale(a);if(o)for(const r of n)t.Cartesian3.subtract(r,o,r),t.Matrix3.multiplyByVector(e,r,r),t.Cartesian3.add(r,o,r);else{const r=t.Matrix3.fromScale(a);for(const i of n)t.Matrix3.multiplyByVector(r,i,i)}return n}function It(n,a){const{translation:o,rotation:e,scale:r}=n;let i;if(e){const{axis:c,angle:d}=e;i=t.Quaternion.fromAxisAngle(c,d)}const s=new t.TranslationRotationScale(o??void 0,i,r??void 0);return t.Matrix4.fromTranslationRotationScale(s,a??void 0)}function V(n,a,o){o??=new t.TranslationRotationScale;const e=t.Matrix4.pack(n,[]),r=[],i=[],s=[],c=a?M.MatrixComposeOrder[a]:M.MatrixComposeOrder.trs;return M.mat4_decompose_quat(r,s,i,e,c),t.Cartesian3.unpack(r,0,o.translation),t.Cartesian3.unpack(i,0,o.scale),t.Quaternion.unpack(s,0,o.rotation),o}function Bt(n,a){return V(n,null,a)}function U(n,a,o){const e=t.Cartesian3.pack(n.translation,[]),r=t.Cartesian3.pack(n.scale,[]),i=t.Quaternion.pack(n.rotation,[]),s=a?M.MatrixComposeOrder[a]:M.MatrixComposeOrder.trs,c=M.mat4_compose_quat([],e,i,r,s);return t.Matrix4.unpack(c,0,o)}const _t=t.Matrix4.fromTranslationRotationScale;function j(n,a){const o=t.Matrix4.inverse(n,new t.Matrix4),e=new t.Matrix4;function r(s,c){return c=U(s,a,c),t.Matrix4.multiply(n,c,c)}function i(s,c){return t.Matrix4.multiply(o,s,e),V(e,a,c)}return{compose:r,decompose:i,referInverse:o}}function b(n,a,o){const e=t.Transforms.eastNorthUpToFixedFrame(n,o??void 0);return{...j(e,a),refer:e}}function Vt(n){let a=n.boundingSphere;if(a)return a;let o=n.geometryInstances;if(o){o=Array.isArray(o)?o:[o];const r=o.map(i=>i.geometry.boundingSphere);return t.BoundingSphere.fromBoundingSpheres(r)}const e=n.positions;return e?.length>0?t.BoundingSphere.fromPoints(e):null}function bt(n,a){a=a??new t.Cartesian3;const o=n.position;if(o)return o instanceof t.Cartesian3?o:o.getValue(t.JulianDate.now(),a);const e=n.modelMatrix;if(e)return t.Matrix4.getTranslation(e,a);const r=n.positions;return r?.length>0?t.BoundingSphere.fromPoints(r).center:null}function Qt(n,a,o){let{translation:e,rotation:r,scale:i}=S(a,o);const s=new t.TranslationRotationScale(e??void 0,r??void 0,i??void 0),c=t.Matrix4.fromTranslationRotationScale(s);return Y(n,c)}function Y(n,a){const o=n.modelMatrix;if(o)return t.Matrix4.multiply(a,o,o),n.modelMatrix=o,!0;const e=n.position;if(e){if("scale"in n){const i=t.Matrix4.getTranslation(a,new t.Cartesian3);t.Cartesian3.add(e,i,e);const s=n.scale??1,c=t.Matrix4.getScale(a,new t.Cartesian3);n.scale=t.Cartesian3.maximumComponent(c)*s}else t.Matrix4.multiplyByPoint(a,e,e);return n.position=e,!0}const r=n.positions;if(r?.length>0){for(const i of r)t.Matrix4.multiplyByPoint(a,i,i);return n.positions=r,!0}return!1}function Gt(n,a,o){const e=Z(n),r=E(a,{...o,defaultMatrix:e});return X(n,r)}function X(n,a){if(P(n))return n.modelMatrix=a,!0;const o=t.Matrix4.getTranslation(a,new t.Cartesian3);if(A(n)){if(n.position=o,"scale"in n){const r=t.Matrix4.getScale(a,new t.Cartesian3);n.scale=t.Cartesian3.maximumComponent(r)}return!0}const e=n.positions;if(e?.length>0){const r=t.BoundingSphere.fromPoints(e);t.Cartesian3.subtract(o,r.center,o);for(const i of e)t.Cartesian3.add(i,o,i);return n.positions=e,!0}return!1}function Z(n){if(P(n))return n.modelMatrix;if(A(n)){const o=n.position,e=n.scale??1,r=new t.TranslationRotationScale(o,void 0,new t.Cartesian3(e,e,e));return t.Matrix4.fromTranslationRotationScale(r)}const a=n.positions;if(a?.length>0){const o=t.BoundingSphere.fromPoints(a);return t.Matrix4.fromTranslation(o.center)}return null}function Ht(n,a){let{translation:o,rotation:e,scale:r}=S(a,a);const{reset:i,referFrame:s}=a,c=t.JulianDate.now(),d=!i;if(e){let h=e;if(d){const w=n.orientation?.getValue(c);w&&(h=t.Quaternion.multiply(e,w,w))}n.orientation=h}if(o){let h=o;if(d){const w=n.position?.getValue(c);w&&(h=t.Cartesian3.add(w,o,w))}n.position=h}if(!s)return;const{translation:f,rotation:u,scale:p}=k(a,a),y=new t.TranslationRotationScale(f??void 0,u??void 0,p??void 0);let g=t.Matrix4.fromTranslationRotationScale(y);if(g=v(g,s,g),p){const h=n.box;h&&K(h,p);const w=n.cylinder;w&&$(w,p);const yt=n.ellipse;yt&&tt(yt,p);const gt=n.ellipsoid;gt&&nt(gt,p);const Mt=n.model;Mt&&ot(Mt,p,i);const wt=n.plane;wt&&at(wt,p)}const x=n.corridor;x&&et(x,g,p);const C=n.polygon;C&&rt(C,g,p);const T=n.polyline;T&&it(T,g,p);const m=n.polylineVolume;m&&lt(m,g,p);const I=n.wall;I&&st(I,g,p)}function K(n,a){const o=t.JulianDate.now(),e=n.dimensions?.getValue(o);e&&(n.dimensions=t.Cartesian3.multiplyComponents(e,a,e))}function $(n,a){const o=t.JulianDate.now(),e=n.length?.getValue(o);e!=null&&(n.length=e*a.z);const r=Math.max(a.x,a.y),i=n.topRadius?.getValue(o);i!=null&&(n.topRadius=i*r);const s=a.z,c=n.bottomRadius?.getValue(o);c!=null&&(n.bottomRadius=c*s)}function tt(n,a){const o=t.JulianDate.now(),e=Math.max(a.x,a.y),r=a.z,i=n.semiMajorAxis?.getValue(o);i!=null&&(n.semiMajorAxis=i*e);const s=n.semiMinorAxis?.getValue(o);s!=null&&(n.semiMinorAxis=s*e);const c=n.height?.getValue(o);c!=null&&(n.height=c*r);const d=n.extrudedHeight?.getValue(o);d!=null&&(n.extrudedHeight=d*r)}function nt(n,a){const o=t.JulianDate.now(),e=n.radii?.getValue(o);e!=null&&(n.radii=t.Cartesian3.multiplyComponents(e,a,e));const r=n.innerRadii?.getValue(o);r!=null&&(n.innerRadii=t.Cartesian3.multiplyComponents(r,a,r))}function ot(n,a,o){let e=t.Cartesian3.maximumComponent(a);if(!o){const r=t.JulianDate.now(),i=n.scale?.getValue(r)??1;e*=i}n.scale=e}function at(n,a){const o=t.JulianDate.now(),e=t.Cartesian2.fromCartesian3(a),r=n.dimensions?.getValue(o);r&&(n.dimensions=t.Cartesian2.multiplyComponents(r,e,r))}function et(n,a,o){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.positions?.getValue(e);if(i?.length>0){for(const p of i)t.Matrix4.multiplyByPoint(a,p,p);n.dimensions=i}const s=o??t.Matrix4.getScale(a,r),c=Math.max(s.x,s.y);n.width?.getValue(e)!=null&&(n.width=c*scale);const f=n.height?.getValue(e),u=s.z;f!=null&&(n.height=f*u)}function rt(n,a,o){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.hierarchy?.getValue(e);i&&(Q(i,a),n.hierarchy=i);const c=(o??t.Matrix4.getScale(a,r)).z,d=n.height?.getValue(e);d!=null&&(n.height=d*c);const f=n.extrudedHeight?.getValue(e);f!=null&&(n.extrudedHeight=f*c)}function Q(n,a){const{positions:o,holes:e}=n;for(const r of o)t.Matrix4.multiplyByPoint(a,r,r);n.positions=o;for(const r of e)Q(r,a)}function it(n,a,o){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.positions?.getValue(e);if(i?.length>0){for(const f of i)t.Matrix4.multiplyByPoint(a,f,f);n.positions=i}const s=o??t.Matrix4.getScale(a,r),c=Math.max(s.x,s.y);n.width?.getValue(e)!=null&&(n.width=c*scale)}function lt(n,a,o){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.positions?.getValue(e);if(i?.length>0){for(const f of i)t.Matrix4.multiplyByPoint(a,f,f);n.positions=i}const s=o??t.Matrix4.getScale(a,r),c=t.Cartesian2.fromCartesian3(s),d=n.shape?.getValue(e);if(d!=null){for(const f of d)t.Cartesian2.multiplyComponents(f,c,f);n.shape=d}}function st(n,a,o){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.positions?.getValue(e);if(i?.length>0){for(const u of i)t.Matrix4.multiplyByPoint(a,u,u);n.positions=i}const c=(o??t.Matrix4.getScale(a,r)).z,d=n.minimumHeights?.getValue(e);d!=null&&(graphicsgraphics.minimumHeights=d.map(u=>u*c));const f=n.maximumHeights?.getValue(e);f!=null&&(graphicsgraphics.maximumHeights=f.map(u=>u*c))}function zt(n,a,o){const e=t.JulianDate.now(),r=n.position?.getValue(e);if(!r)return null;const i=n.orientation?.getValue(e),s=n.model?.scale?.getValue(e)??1,c=new t.Cartesian3(s,s,s),d=a(r,o),f=t.Matrix4.inverse(d,new t.Matrix4),u=t.Matrix4.multiplyByPoint(f,r,new t.Cartesian3),p={translation:u,position:r,scale:c,rotation:new t.Cartesian3};let y;if(i){const C=t.Matrix3.fromQuaternion(i),T=t.Matrix4.fromRotation(C),m=t.Matrix4.multiply(f,T,T),I=_(m);y=l.Xyz_Hpr.toCartesian3(I),p.rotation=y}const g=new t.TranslationRotationScale(u??void 0,y?R(y):void 0,c??void 0);let x=t.Matrix4.fromTranslationRotationScale(g);return p.matrix=x,p}function Nt(n){return n.values.length/n.componentsPerAttribute}function Ft(n){return t.ComponentDatatype.getSizeInBytes(n.componentDatatype)*n.componentsPerAttribute}function Lt(n){const{componentDatatype:a,vertexBuffer:o}=n,e=F[a];if(!e)throw new Error("不支持的数据类型");const r=o.sizeInBytes,i=t.ComponentDatatype.getSizeInBytes(a),s=r/i;let c=new e(s);return o.getBufferData(c,0,0,r),c}new t.Cartesian2,new t.Cartesian3,new t.Cartesian4;const G=[new t.Cartesian2,new t.Cartesian2,new t.Cartesian2,new t.Cartesian2],D=[new t.Cartesian3,new t.Cartesian3,new t.Cartesian3,new t.Cartesian3];new t.Cartesian4,new t.Cartesian4,new t.Cartesian4,new t.Cartesian4;const Jt=[new t.Cartographic,new t.Cartographic,new t.Cartographic,new t.Cartographic];new t.Rectangle,new t.Rectangle,new t.Rectangle,new t.Rectangle,new t.Matrix2,new t.Matrix2,new t.Matrix2,new t.Matrix2,new t.Matrix3,new t.Matrix3,new t.Matrix3,new t.Matrix3,new t.Matrix4,new t.Matrix4,new t.Matrix4,new t.Matrix4,new t.Quaternion,new t.Quaternion,new t.Quaternion,new t.Quaternion,new t.HeadingPitchRoll,new t.HeadingPitchRoll,new t.HeadingPitchRoll,new t.HeadingPitchRoll;function Wt(n,a=[]){const{stride:o,vertexArray:e}=n,r=e.length/o,i=D[0];for(let s=0;s<r;s++)n.encoding.decodePosition(e,s,i),t.Cartesian3.pack(i,a,a.length);return a}function kt(n,a,o){return n.encoding.decodePosition(n.vertexArray,a,o)}function ct(n){const{stride:a,vertices:o,indices:e,encoding:r}=n,i=o.length/a,s=D[0],c=new Float32Array(i*3),d=G[0],f=new Float32Array(i*2),u=new Float32Array(i);for(let p=0;p<i;p++){r.decodePosition(o,p,s),t.Cartesian3.pack(s,c,p*3);const y=r.decodeHeight(o,p);u[p]=y,r.decodeTextureCoordinates(o,p,d),t.Cartesian2.pack(d,f,p*2)}return{attributes:{position:{array:c,vectorSize:3},uv:{array:f,vectorSize:2},height:{array:u,vectorSize:1}},indices:e.slice(),count:i}}function H(n,a){const o=n._surface._tilesToRender,e=[],r=new t.Rectangle;for(const i of o){const{rectangle:s}=i;t.Rectangle.intersection(a,s,r)&&e.push(i)}return e}function Et(n){const a=n._surface._tilesToRender;return ft(a)}function ft(n){const a=new Set;for(const i of n)a.add(i.level);const o=[...a],e=Math.min.apply(Math,o),r=Math.max.apply(Math,o);return{min:e,max:r}}function z(n){return n.map(a=>{const{mesh:o,terrainData:e}=a.data,r=ct(o),{x:i,y:s,level:c}=a,d=[e._minimumHeight,e._maximumHeight];return{data:r,encoding:o.encoding,rectangle:a.rectangle,heightRange:d,x:i,y:s,level:c}})}function qt(n){const{x:a,y:o,level:e}=n;return n.data.terrainData.upsample(n.tilingScheme,a,o,e,a,o,e)}function dt(n,a,o){const{east:e,north:r,south:i,west:s}=a,c=Jt[0];c.longitude=s,c.latitude=i;const d=n.positionToTileXY(c,o,G[0]);c.longitude=e,c.latitude=r;const f=n.positionToTileXY(c,o,G[1]),[u,p]=d.x<f.x?[d.x,f.x]:[f.x,d.x],[y,g]=d.y<f.y?[d.y,f.y]:[f.y,d.y];return{min:[u,y],max:[p,g]}}const Ut=32767;function jt(n,a=new t.Cartesian3){return t.Matrix3.getScale(n.halfAxes,a),t.Cartesian3.multiplyByScalar(a,2*Ut,a),a}function O(n,a,o){return o=n.getLocalCurvature(a,o),o.x=1/o.x,o.y=1/o.y,o}function Yt(n,a,o){o=O(n,a,o);const e=Math.PI/180;return t.Cartesian2.multiplyByScalar(o,e,o)}function ut(n){const{_quantizedVertices:a,_indices:o}=n,e=a.length/3,r={type:"Float32Array",start:0,vectorSize:1},i={type:"Float32Array",start:e,vectorSize:1},s={type:"Float32Array",start:e*2,vectorSize:1};return{array:new Float32Array(a),attributes:{u:r,v:i,height:s},count:e,indices:o}}async function Xt(n,a,o,e){const r=await n.requestTileGeometry(a,o,e);if(!r)return null;const i=ut(r),s=[data._minimumHeight,data._maximumHeight],c=n.tilingScheme.tileXYToRectangle(a,o,e),d=M.getMatrixOfQuantizedMeshTerrainData(c,s),f=t.Matrix4.fromArray(d,void 0),u=["u","v","height"],p=new M.Geometry({...i,positionNames:u}),y=new t.Cartesian3;return p.mapForAggregate(u,(g,x)=>(t.Cartesian3.fromArray(g,0,y),t.Matrix4.multiplyByPoint(f,y,y),new t.Cartographic(y.x,y.y,y.z)))}async function Zt(n,a,o){const{min:e,max:r}=dt(n.tilingScheme,a,o),i=[],s=[];for(let d=e[0];d<=r[0];d++)for(let f=e[1];f<=r[1];f++){const u=pt(n,d,f,o);u&&(i.push(u),s.push({x:d,y:f}))}return(await Promise.all(i)).map(function(d,f){const{x:u,y:p}=s[f];return{x:u,y:p,level:o,data:d}})}async function pt(n,a,o,e){return n.getTileDataAvailable(a,o,e)?(await n.loadTileDataAvailability(a,o,e),n.requestTileGeometry(a,o,e)):Promise.reject("不可用")}async function Kt(n,a){const o=t.Rectangle.fromCartesianArray(a),e=t.Cartographic.toCartesian(t.Rectangle.center(o)),r=O(n.ellipsoid,e),i=[r.x,r.y,1],s=H(n,o),c=z(s),d=t.Transforms.eastNorthUpToFixedFrame(e);t.Matrix4.inverseTransformation(d,d);const f=a.map(y=>{const g=t.Matrix4.multiplyByPoint(d,y,D[2]);return[g.x,g.y]});let u=0;const p=c.map(async y=>{const{data:g,...x}=y,{position:C,uv:T,height:m}=g.attributes;u+=await M.workerApi.computeRelationAreaOfPolygon2Terrain({args:[{...g,...x,positionNames:["position"],region:f,matrix:t.Matrix4.pack(d,[]),relation:M.GeometricRelation.Contain|M.GeometricRelation.Intersect,scale:i}],transfer:[C.array.buffer,T.array.buffer,m.array.buffer,g.indices.buffer]})});if(await Promise.all(p),u===0||isNaN(u)){console.warn("贴地面积计算异常,已回退到椭球面投影面积",u);const y=a.map(g=>t.Cartesian3.pack(g,[]));return u=M.computeSignAreaOfPolygon3(y),Math.abs(u)}return u}function $t(n,a){const o=t.Rectangle.fromCartesianArray(a),e=t.Cartographic.toCartesian(t.Rectangle.center(o)),r=O(n.ellipsoid,e),i=[r.x,r.y,1],s=H(n,o),c=z(s),d=t.Transforms.eastNorthUpToFixedFrame(e);t.Matrix4.inverseTransformation(d,d);const f=a.map(p=>{const y=t.Matrix4.multiplyByPoint(d,p,D[2]);return[y.x,y.y]});let u=0;for(const p of c){const{data:y,...g}=p;u+=M.computeRelationAreaOfPolygon2Terrain({...y,...g,positionNames:["position"],region:f,matrix:t.Matrix4.pack(d,[]),relation:M.GeometricRelation.Contain|M.GeometricRelation.Intersect,scale:i})}if(u===0||isNaN(u)){console.warn("贴地面积计算异常,已回退到椭球面投影面积",u);const p=a.map(y=>t.Cartesian3.pack(y,[]));return u=M.computeSignAreaOfPolygon3(p),Math.abs(u)}return u}function tn(n,a,o){const e=n.transform.clone(),r=t.Matrix4.inverse(e,new t.Matrix4),i=new t.Matrix4,{compose:s,decompose:c,...d}=b(n.boundingSphere.center,a,o);function f(p,y){return y=s(p,y),t.Matrix4.multiply(y,r,y)}function u(p,y){return t.Matrix4.multiply(p,e,i),c(i,y)}return{...d,right:r,compose:f,decompose:u}}function nn(n,a,o){const e=t.Matrix4.inverse(n.root.transform,new t.Matrix4),{compose:r,decompose:i,...s}=b(n.boundingSphere.center,a,o);function c(f,u){return u=r(f,u),t.Matrix4.multiply(u,e,u)}function d(f){return i(n.root.computedTransform,f)}return{...s,right:e,compose:c,decompose:d}}l.CartesianAxis=L,l.HeadingPitchRollComponent=J,l.applyMatrixReferFrame=Pt,l.applyTransformInPrimitive=Y,l.applyTransformInfoPrimitive=Qt,l.componentDatatypeTypedArrayMap=F,l.computeAttributeSizeInBytes=Ft,l.computeNormalOfCoplanars=q,l.computeTerrainAreaOfPolygon=$t,l.computeTerrainAreaOfPolygon_worker=Kt,l.computeVertexNumOfAttribute=Nt,l.createPlaneOfCoplanars=Rt,l.flatTransformInfoOptions=B,l.getAttributeData=Lt,l.getBoundingSphere=Vt,l.getDecodePositionsOfTerrainMesh=Wt,l.getEntityInfo=zt,l.getGeometryDataOfQuantizedMeshTerrainData=ut,l.getGeometryDataOfTerrainMesh=ct,l.getLevelRangeOfQuadtreeTiles=ft,l.getLocalCurvatureRadius=O,l.getLocalSizePerDegrees=Yt,l.getLocalTransformInfo=k,l.getMatrix4OfTransformInfo=It,l.getNeighborPairs=vt,l.getPosition=bt,l.getPositionOfTerrainMesh=kt,l.getRenderedQuadtreeTilesOfIntersectRectangle=H,l.getRenderedTileLevelRange=Et,l.getScaleOfTerrainDataByOrientedBoundingBox=jt,l.getTerrainData=pt,l.getTerrainDataOfQuadtreeTile=qt,l.getTerrainDatasOfIntersectRectangle=Zt,l.getTerrainDatasOfQuadtreeTiles=z,l.getTileRangeOfIntersectRectangle=dt,l.getTransform=Z,l.getWorldDataOfQuantizedMeshTerrainData=Xt,l.getWorldMatrix=E,l.getWorldTransformInfo=S,l.isMatrixPrimitive=P,l.isPositionListPrimitive=N,l.isPositionPrimitive=A,l.isPrimitiveObject=ht,l.localQuaternionToWorld=W,l.localTRS_WorldMatrix4_Convert=j,l.localTRS_WorldMatrix4_ENU_Convert=b,l.makeMatrixReferFrame=v,l.mat4_compose=_t,l.mat4_composeByOrder=U,l.mat4_decompose=Bt,l.mat4_decomposeByOrder=V,l.matrix4ToHeadingPitchRoll=_,l.quaternionToHeadingPitchRoll=xt,l.resetTransformInPrimitive=X,l.resetTransformInfoPrimitive=Gt,l.rotateMatrixReferFrame=St,l.rotationInfoToQuaternion=R,l.scaleBoxGraphics=K,l.scaleCylinderGraphics=$,l.scaleEllipseGraphics=tt,l.scaleEllipsoidGraphics=nt,l.scaleMatrixReferFrame=Dt,l.scaleModelGraphics=ot,l.scalePlaneGraphics=at,l.scalePoints=Ot,l.tile_enuTRS_modelMatrix_Convert=tn,l.tileset_enuTRS_modelMatrix_Convert=nn,l.transformCorridorGraphics=et,l.transformEntity=Ht,l.transformInfoToMatrix=mt,l.transformPolygonGraphics=rt,l.transformPolygonHierarchy=Q,l.transformPolylineGraphics=it,l.transformPolylineVolumeGraphics=lt,l.transformWallGraphics=st,l.translationMatrixReferFrame=At,l.worldMatrixToLocal=Tt,l.worldQuaternionToLocal=Ct,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cearth/tools",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "CEarth 的 工具库",
5
5
  "main": "./dist/tools.umd.cjs",
6
6
  "module": "./dist/tools.js",