Agriculture-front-end/public/Cesium/Workers/TerrainEncoding-e04be3ba.js
2023-09-11 21:56:39 +08:00

2 lines
8.5 KiB
JavaScript

define(["exports","./BoundingSphere-561b54d0","./Cartographic-3309dd0d","./Check-7b2a090c","./when-b60132fc","./Cartesian2-47311507","./AttributeCompression-90851096","./ComponentDatatype-c140a87d","./Math-119be1a3"],(function(t,e,i,r,a,n,o,s,m){"use strict";function c(t,e){this._ellipsoid=t,this._cameraPosition=new i.Cartesian3,this._cameraPositionInScaledSpace=new i.Cartesian3,this._distanceToLimbInScaledSpaceSquared=0,a.defined(e)&&(this.cameraPosition=e)}Object.defineProperties(c.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},cameraPosition:{get:function(){return this._cameraPosition},set:function(t){var e=this._ellipsoid.transformPositionToScaledSpace(t,this._cameraPositionInScaledSpace),r=i.Cartesian3.magnitudeSquared(e)-1;i.Cartesian3.clone(t,this._cameraPosition),this._cameraPositionInScaledSpace=e,this._distanceToLimbInScaledSpaceSquared=r}}});var u=new i.Cartesian3;c.prototype.isPointVisible=function(t){return y(this._ellipsoid.transformPositionToScaledSpace(t,u),this._cameraPositionInScaledSpace,this._distanceToLimbInScaledSpaceSquared)},c.prototype.isScaledSpacePointVisible=function(t){return y(t,this._cameraPositionInScaledSpace,this._distanceToLimbInScaledSpaceSquared)};var d=new i.Cartesian3;c.prototype.isScaledSpacePointVisiblePossiblyUnderEllipsoid=function(t,e){var i,r,n=this._ellipsoid;return a.defined(e)&&e<0&&n.minimumRadius>-e?((r=d).x=this._cameraPosition.x/(n.radii.x+e),r.y=this._cameraPosition.y/(n.radii.y+e),r.z=this._cameraPosition.z/(n.radii.z+e),i=r.x*r.x+r.y*r.y+r.z*r.z-1):(r=this._cameraPositionInScaledSpace,i=this._distanceToLimbInScaledSpaceSquared),y(t,r,i)},c.prototype.computeHorizonCullingPoint=function(t,e,i){return x(this._ellipsoid,t,e,i)};var l=n.Ellipsoid.clone(n.Ellipsoid.UNIT_SPHERE);c.prototype.computeHorizonCullingPointPossiblyUnderEllipsoid=function(t,e,i,r){return x(f(this._ellipsoid,i,l),t,e,r)},c.prototype.computeHorizonCullingPointFromVertices=function(t,e,i,r,a){return S(this._ellipsoid,t,e,i,r,a)},c.prototype.computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid=function(t,e,i,r,a,n){return S(f(this._ellipsoid,a,l),t,e,i,r,n)};var p=[];c.prototype.computeHorizonCullingPointFromRectangle=function(t,r,a){var o=n.Rectangle.subsample(t,r,0,p),s=e.BoundingSphere.fromPoints(o);if(!(i.Cartesian3.magnitude(s.center)<.1*r.minimumRadius))return this.computeHorizonCullingPoint(s.center,o,a)};var h=new i.Cartesian3;function f(t,e,r){if(a.defined(e)&&e<0&&t.minimumRadius>-e){var o=i.Cartesian3.fromElements(t.radii.x+e,t.radii.y+e,t.radii.z+e,h);t=n.Ellipsoid.fromCartesian3(o,r)}return t}function x(t,e,r,n){a.defined(n)||(n=new i.Cartesian3);for(var o=P(t,e),s=0,m=0,c=r.length;m<c;++m){var u=v(t,r[m],o);if(u<0)return;s=Math.max(s,u)}return M(o,s,n)}var C=new i.Cartesian3;function S(t,e,r,n,o,s){a.defined(s)||(s=new i.Cartesian3),n=a.defaultValue(n,3),o=a.defaultValue(o,i.Cartesian3.ZERO);for(var m=P(t,e),c=0,u=0,d=r.length;u<d;u+=n){C.x=r[u]+o.x,C.y=r[u+1]+o.y,C.z=r[u+2]+o.z;var l=v(t,C,m);if(l<0)return;c=Math.max(c,l)}return M(m,c,s)}function y(t,e,r){var a=e,n=r,o=i.Cartesian3.subtract(t,a,u),s=-i.Cartesian3.dot(o,a);return!(n<0?s>0:s>n&&s*s/i.Cartesian3.magnitudeSquared(o)>n)}var b=new i.Cartesian3,g=new i.Cartesian3;function v(t,e,r){var a=t.transformPositionToScaledSpace(e,b),n=i.Cartesian3.magnitudeSquared(a),o=Math.sqrt(n),s=i.Cartesian3.divideByScalar(a,o,g);n=Math.max(1,n);var m=1/(o=Math.max(1,o));return 1/(i.Cartesian3.dot(s,r)*m-i.Cartesian3.magnitude(i.Cartesian3.cross(s,r,s))*(Math.sqrt(n-1)*m))}function M(t,e,r){if(!(e<=0||e===1/0||e!=e))return i.Cartesian3.multiplyByScalar(t,e,r)}var T=new i.Cartesian3;function P(t,e){return i.Cartesian3.equals(e,i.Cartesian3.ZERO)?e:(t.transformPositionToScaledSpace(e,T),i.Cartesian3.normalize(T,T))}var E=Object.freeze({NONE:0,BITS12:1}),z=new i.Cartesian3,N=new i.Cartesian3,I=new n.Cartesian2,B=new e.Matrix4,_=new e.Matrix4,w=Math.pow(2,12);function A(t,r,n,o,s,m){var c,u,d,l=E.NONE;if(a.defined(t)&&a.defined(r)&&a.defined(n)&&a.defined(o)){var p=t.minimum,h=t.maximum,f=i.Cartesian3.subtract(h,p,N),x=n-r;l=Math.max(i.Cartesian3.maximumComponent(f),x)<w-1?E.BITS12:E.NONE,l=E.NONE,c=t.center,u=e.Matrix4.inverseTransformation(o,new e.Matrix4);var C=i.Cartesian3.negate(p,z);e.Matrix4.multiply(e.Matrix4.fromTranslation(C,B),u,u);var S=z;S.x=1/f.x,S.y=1/f.y,S.z=1/f.z,e.Matrix4.multiply(e.Matrix4.fromScale(S,B),u,u),d=e.Matrix4.clone(o),e.Matrix4.setTranslation(d,i.Cartesian3.ZERO,d),o=e.Matrix4.clone(o,new e.Matrix4);var y=e.Matrix4.fromTranslation(p,B),b=e.Matrix4.fromScale(f,_),g=e.Matrix4.multiply(y,b,B);e.Matrix4.multiply(o,g,o),e.Matrix4.multiply(d,g,d)}this.quantization=l,this.minimumHeight=r,this.maximumHeight=n,this.center=c,this.toScaledENU=u,this.fromScaledENU=o,this.matrix=d,this.hasVertexNormals=s,this.hasWebMercatorT=a.defaultValue(m,!1)}A.prototype.encode=function(t,r,a,s,c,u,d){var l=s.x,p=s.y;if(this.quantization===E.BITS12){(a=e.Matrix4.multiplyByPoint(this.toScaledENU,a,z)).x=m.CesiumMath.clamp(a.x,0,1),a.y=m.CesiumMath.clamp(a.y,0,1),a.z=m.CesiumMath.clamp(a.z,0,1);var h=this.maximumHeight-this.minimumHeight,f=m.CesiumMath.clamp((c-this.minimumHeight)/h,0,1);n.Cartesian2.fromElements(a.x,a.y,I);var x=o.AttributeCompression.compressTextureCoordinates(I);n.Cartesian2.fromElements(a.z,f,I);var C=o.AttributeCompression.compressTextureCoordinates(I);n.Cartesian2.fromElements(l,p,I);var S=o.AttributeCompression.compressTextureCoordinates(I);if(t[r++]=x,t[r++]=C,t[r++]=S,this.hasWebMercatorT){n.Cartesian2.fromElements(d,0,I);var y=o.AttributeCompression.compressTextureCoordinates(I);t[r++]=y}}else i.Cartesian3.subtract(a,this.center,z),t[r++]=z.x,t[r++]=z.y,t[r++]=z.z,t[r++]=c,t[r++]=l,t[r++]=p,this.hasWebMercatorT&&(t[r++]=d);return this.hasVertexNormals&&(t[r++]=o.AttributeCompression.octPackFloat(u)),r},A.prototype.decodePosition=function(t,r,n){if(a.defined(n)||(n=new i.Cartesian3),r*=this.getStride(),this.quantization===E.BITS12){var s=o.AttributeCompression.decompressTextureCoordinates(t[r],I);n.x=s.x,n.y=s.y;var m=o.AttributeCompression.decompressTextureCoordinates(t[r+1],I);return n.z=m.x,e.Matrix4.multiplyByPoint(this.fromScaledENU,n,n)}return n.x=t[r],n.y=t[r+1],n.z=t[r+2],i.Cartesian3.add(n,this.center,n)},A.prototype.decodeTextureCoordinates=function(t,e,i){return a.defined(i)||(i=new n.Cartesian2),e*=this.getStride(),this.quantization===E.BITS12?o.AttributeCompression.decompressTextureCoordinates(t[e+2],i):n.Cartesian2.fromElements(t[e+4],t[e+5],i)},A.prototype.decodeHeight=function(t,e){return e*=this.getStride(),this.quantization===E.BITS12?o.AttributeCompression.decompressTextureCoordinates(t[e+1],I).y*(this.maximumHeight-this.minimumHeight)+this.minimumHeight:t[e+3]},A.prototype.decodeWebMercatorT=function(t,e){return e*=this.getStride(),this.quantization===E.BITS12?o.AttributeCompression.decompressTextureCoordinates(t[e+3],I).x:t[e+6]},A.prototype.getOctEncodedNormal=function(t,e,i){var r=t[e=(e+1)*this.getStride()-1]/256,a=Math.floor(r),o=256*(r-a);return n.Cartesian2.fromElements(a,o,i)},A.prototype.getStride=function(){var t;if(this.quantization===E.BITS12)t=3;else t=6;return this.hasWebMercatorT&&++t,this.hasVertexNormals&&++t,t};var q={position3DAndHeight:0,textureCoordAndEncodedNormals:1},H={compressed0:0,compressed1:1};A.prototype.getAttributes=function(t){var e,i=s.ComponentDatatype.FLOAT,r=s.ComponentDatatype.getSizeInBytes(i);if(this.quantization===E.NONE){var a=2;return this.hasWebMercatorT&&++a,this.hasVertexNormals&&++a,[{index:q.position3DAndHeight,vertexBuffer:t,componentDatatype:i,componentsPerAttribute:4,offsetInBytes:0,strideInBytes:e=(4+a)*r},{index:q.textureCoordAndEncodedNormals,vertexBuffer:t,componentDatatype:i,componentsPerAttribute:a,offsetInBytes:4*r,strideInBytes:e}]}var n=3,o=0;return(this.hasWebMercatorT||this.hasVertexNormals)&&++n,this.hasWebMercatorT&&this.hasVertexNormals?(++o,[{index:H.compressed0,vertexBuffer:t,componentDatatype:i,componentsPerAttribute:n,offsetInBytes:0,strideInBytes:e=(n+o)*r},{index:H.compressed1,vertexBuffer:t,componentDatatype:i,componentsPerAttribute:o,offsetInBytes:n*r,strideInBytes:e}]):[{index:H.compressed0,vertexBuffer:t,componentDatatype:i,componentsPerAttribute:n}]},A.prototype.getAttributeLocations=function(){return this.quantization===E.NONE?q:H},A.clone=function(t,r){return a.defined(r)||(r=new A),r.quantization=t.quantization,r.minimumHeight=t.minimumHeight,r.maximumHeight=t.maximumHeight,r.center=i.Cartesian3.clone(t.center),r.toScaledENU=e.Matrix4.clone(t.toScaledENU),r.fromScaledENU=e.Matrix4.clone(t.fromScaledENU),r.matrix=e.Matrix4.clone(t.matrix),r.hasVertexNormals=t.hasVertexNormals,r.hasWebMercatorT=t.hasWebMercatorT,r},t.EllipsoidalOccluder=c,t.TerrainEncoding=A}));