qa-prevention-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/TerrainEncoding-0f7ffc20.js

2 lines
11 KiB
JavaScript

define(["exports","./BoundingSphere-9a3b5656","./Cartesian3-e0307675","./Check-741c5f3c","./defaultValue-81eec7ed","./Cartesian2-bd414876","./Rectangle-cf3e0e3e","./AttributeCompression-8f752c03","./ComponentDatatype-aaeec80f","./Math-e73894ab","./Matrix4-4c545f70"],(function(t,e,i,a,o,n,r,s,c,u,d){"use strict";function l(t,e){this._ellipsoid=t,this._cameraPosition=new i.Cartesian3,this._cameraPositionInScaledSpace=new i.Cartesian3,this._distanceToLimbInScaledSpaceSquared=0,o.defined(e)&&(this.cameraPosition=e)}Object.defineProperties(l.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},cameraPosition:{get:function(){return this._cameraPosition},set:function(t){const e=this._ellipsoid.transformPositionToScaledSpace(t,this._cameraPositionInScaledSpace),a=i.Cartesian3.magnitudeSquared(e)-1;i.Cartesian3.clone(t,this._cameraPosition),this._cameraPositionInScaledSpace=e,this._distanceToLimbInScaledSpaceSquared=a}}});const m=new i.Cartesian3;l.prototype.isPointVisible=function(t){return N(this._ellipsoid.transformPositionToScaledSpace(t,m),this._cameraPositionInScaledSpace,this._distanceToLimbInScaledSpaceSquared)},l.prototype.isScaledSpacePointVisible=function(t){return N(t,this._cameraPositionInScaledSpace,this._distanceToLimbInScaledSpaceSquared)};const h=new i.Cartesian3;l.prototype.isScaledSpacePointVisiblePossiblyUnderEllipsoid=function(t,e){const i=this._ellipsoid;let a,n;return o.defined(e)&&e<0&&i.minimumRadius>-e?(n=h,n.x=this._cameraPosition.x/(i.radii.x+e),n.y=this._cameraPosition.y/(i.radii.y+e),n.z=this._cameraPosition.z/(i.radii.z+e),a=n.x*n.x+n.y*n.y+n.z*n.z-1):(n=this._cameraPositionInScaledSpace,a=this._distanceToLimbInScaledSpaceSquared),N(t,n,a)},l.prototype.computeHorizonCullingPoint=function(t,e,i){return C(this._ellipsoid,t,e,i)};const f=n.Ellipsoid.clone(n.Ellipsoid.UNIT_SPHERE);l.prototype.computeHorizonCullingPointPossiblyUnderEllipsoid=function(t,e,i,a){return C(S(this._ellipsoid,i,f),t,e,a)},l.prototype.computeHorizonCullingPointFromVertices=function(t,e,i,a,o){return y(this._ellipsoid,t,e,i,a,o)},l.prototype.computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid=function(t,e,i,a,o,n){return y(S(this._ellipsoid,o,f),t,e,i,a,n)};const p=[];l.prototype.computeHorizonCullingPointFromRectangle=function(t,a,o){const n=r.Rectangle.subsample(t,a,0,p),s=e.BoundingSphere.fromPoints(n);if(!(i.Cartesian3.magnitude(s.center)<.1*a.minimumRadius))return this.computeHorizonCullingPoint(s.center,n,o)};const x=new i.Cartesian3;function S(t,e,a){if(o.defined(e)&&e<0&&t.minimumRadius>-e){const o=i.Cartesian3.fromElements(t.radii.x+e,t.radii.y+e,t.radii.z+e,x);t=n.Ellipsoid.fromCartesian3(o,a)}return t}function C(t,e,a,n){o.defined(n)||(n=new i.Cartesian3);const r=_(t,e);let s=0;for(let e=0,i=a.length;e<i;++e){const i=b(t,a[e],r);if(i<0)return;s=Math.max(s,i)}return P(r,s,n)}const g=new i.Cartesian3;function y(t,e,a,n,r,s){o.defined(s)||(s=new i.Cartesian3),n=o.defaultValue(n,3),r=o.defaultValue(r,i.Cartesian3.ZERO);const c=_(t,e);let u=0;for(let e=0,i=a.length;e<i;e+=n){g.x=a[e]+r.x,g.y=a[e+1]+r.y,g.z=a[e+2]+r.z;const i=b(t,g,c);if(i<0)return;u=Math.max(u,i)}return P(c,u,s)}function N(t,e,a){const o=e,n=a,r=i.Cartesian3.subtract(t,o,m),s=-i.Cartesian3.dot(r,o);return!(n<0?s>0:s>n&&s*s/i.Cartesian3.magnitudeSquared(r)>n)}const M=new i.Cartesian3,T=new i.Cartesian3;function b(t,e,a){const o=t.transformPositionToScaledSpace(e,M);let n=i.Cartesian3.magnitudeSquared(o),r=Math.sqrt(n);const s=i.Cartesian3.divideByScalar(o,r,T);n=Math.max(1,n),r=Math.max(1,r);const c=1/r;return 1/(i.Cartesian3.dot(s,a)*c-i.Cartesian3.magnitude(i.Cartesian3.cross(s,a,s))*(Math.sqrt(n-1)*c))}function P(t,e,a){if(!(e<=0||e===1/0||e!=e))return i.Cartesian3.multiplyByScalar(t,e,a)}const z=new i.Cartesian3;function _(t,e){return i.Cartesian3.equals(e,i.Cartesian3.ZERO)?e:(t.transformPositionToScaledSpace(e,z),i.Cartesian3.normalize(z,z))}const E={getHeight:function(t,e,i){return(t-i)*e+i}},H=new i.Cartesian3;E.getPosition=function(t,e,a,o,n){const r=e.cartesianToCartographic(t,H),s=E.getHeight(r.height,a,o);return i.Cartesian3.fromRadians(r.longitude,r.latitude,s,e,n)};var w=Object.freeze({NONE:0,BITS12:1});const A=new i.Cartesian3,I=new i.Cartesian3,V=new n.Cartesian2,q=new d.Matrix4,G=new d.Matrix4,B=Math.pow(2,12);function O(t,e,a,n,r,s,c,u,l,m){let h,f,p=w.NONE;if(o.defined(e)&&o.defined(a)&&o.defined(n)&&o.defined(r)){const t=e.minimum,o=e.maximum,s=i.Cartesian3.subtract(o,t,I),c=n-a;p=Math.max(i.Cartesian3.maximumComponent(s),c)<B-1?w.BITS12:w.NONE,h=d.Matrix4.inverseTransformation(r,new d.Matrix4);const u=i.Cartesian3.negate(t,A);d.Matrix4.multiply(d.Matrix4.fromTranslation(u,q),h,h);const l=A;l.x=1/s.x,l.y=1/s.y,l.z=1/s.z,d.Matrix4.multiply(d.Matrix4.fromScale(l,q),h,h),f=d.Matrix4.clone(r),d.Matrix4.setTranslation(f,i.Cartesian3.ZERO,f),r=d.Matrix4.clone(r,new d.Matrix4);const m=d.Matrix4.fromTranslation(t,q),x=d.Matrix4.fromScale(s,G),S=d.Matrix4.multiply(m,x,q);d.Matrix4.multiply(r,S,r),d.Matrix4.multiply(f,S,f)}this.quantization=p,this.minimumHeight=a,this.maximumHeight=n,this.center=i.Cartesian3.clone(t),this.toScaledENU=h,this.fromScaledENU=r,this.matrix=f,this.hasVertexNormals=s,this.hasWebMercatorT=o.defaultValue(c,!1),this.hasGeodeticSurfaceNormals=o.defaultValue(u,!1),this.exaggeration=o.defaultValue(l,1),this.exaggerationRelativeHeight=o.defaultValue(m,0),this.stride=0,this._offsetGeodeticSurfaceNormal=0,this._offsetVertexNormal=0,this._calculateStrideAndOffsets()}O.prototype.encode=function(t,e,a,o,r,c,l,m){const h=o.x,f=o.y;if(this.quantization===w.BITS12){(a=d.Matrix4.multiplyByPoint(this.toScaledENU,a,A)).x=u.CesiumMath.clamp(a.x,0,1),a.y=u.CesiumMath.clamp(a.y,0,1),a.z=u.CesiumMath.clamp(a.z,0,1);const i=this.maximumHeight-this.minimumHeight,o=u.CesiumMath.clamp((r-this.minimumHeight)/i,0,1);n.Cartesian2.fromElements(a.x,a.y,V);const c=s.AttributeCompression.compressTextureCoordinates(V);n.Cartesian2.fromElements(a.z,o,V);const m=s.AttributeCompression.compressTextureCoordinates(V);n.Cartesian2.fromElements(h,f,V);const p=s.AttributeCompression.compressTextureCoordinates(V);if(t[e++]=c,t[e++]=m,t[e++]=p,this.hasWebMercatorT){n.Cartesian2.fromElements(l,0,V);const i=s.AttributeCompression.compressTextureCoordinates(V);t[e++]=i}}else i.Cartesian3.subtract(a,this.center,A),t[e++]=A.x,t[e++]=A.y,t[e++]=A.z,t[e++]=r,t[e++]=h,t[e++]=f,this.hasWebMercatorT&&(t[e++]=l);return this.hasVertexNormals&&(t[e++]=s.AttributeCompression.octPackFloat(c)),this.hasGeodeticSurfaceNormals&&(t[e++]=m.x,t[e++]=m.y,t[e++]=m.z),e};const R=new i.Cartesian3,U=new i.Cartesian3;O.prototype.addGeodeticSurfaceNormals=function(t,e,i){if(this.hasGeodeticSurfaceNormals)return;const a=this.stride,o=t.length/a;this.hasGeodeticSurfaceNormals=!0,this._calculateStrideAndOffsets();const n=this.stride;for(let r=0;r<o;r++){for(let i=0;i<a;i++){const o=r*a+i;e[r*n+i]=t[o]}const o=this.decodePosition(e,r,R),s=i.geodeticSurfaceNormal(o,U),c=r*n+this._offsetGeodeticSurfaceNormal;e[c]=s.x,e[c+1]=s.y,e[c+2]=s.z}},O.prototype.removeGeodeticSurfaceNormals=function(t,e){if(!this.hasGeodeticSurfaceNormals)return;const i=this.stride,a=t.length/i;this.hasGeodeticSurfaceNormals=!1,this._calculateStrideAndOffsets();const o=this.stride;for(let n=0;n<a;n++)for(let a=0;a<o;a++){const r=n*i+a;e[n*o+a]=t[r]}},O.prototype.decodePosition=function(t,e,a){if(o.defined(a)||(a=new i.Cartesian3),e*=this.stride,this.quantization===w.BITS12){const i=s.AttributeCompression.decompressTextureCoordinates(t[e],V);a.x=i.x,a.y=i.y;const o=s.AttributeCompression.decompressTextureCoordinates(t[e+1],V);return a.z=o.x,d.Matrix4.multiplyByPoint(this.fromScaledENU,a,a)}return a.x=t[e],a.y=t[e+1],a.z=t[e+2],i.Cartesian3.add(a,this.center,a)},O.prototype.getExaggeratedPosition=function(t,e,i){i=this.decodePosition(t,e,i);const a=this.exaggeration,o=this.exaggerationRelativeHeight;if(1!==a&&this.hasGeodeticSurfaceNormals){const n=this.decodeGeodeticSurfaceNormal(t,e,U),r=this.decodeHeight(t,e),s=E.getHeight(r,a,o)-r;i.x+=n.x*s,i.y+=n.y*s,i.z+=n.z*s}return i},O.prototype.decodeTextureCoordinates=function(t,e,i){return o.defined(i)||(i=new n.Cartesian2),e*=this.stride,this.quantization===w.BITS12?s.AttributeCompression.decompressTextureCoordinates(t[e+2],i):n.Cartesian2.fromElements(t[e+4],t[e+5],i)},O.prototype.decodeHeight=function(t,e){if(e*=this.stride,this.quantization===w.BITS12){return s.AttributeCompression.decompressTextureCoordinates(t[e+1],V).y*(this.maximumHeight-this.minimumHeight)+this.minimumHeight}return t[e+3]},O.prototype.decodeWebMercatorT=function(t,e){return e*=this.stride,this.quantization===w.BITS12?s.AttributeCompression.decompressTextureCoordinates(t[e+3],V).x:t[e+6]},O.prototype.getOctEncodedNormal=function(t,e,i){const a=t[e=e*this.stride+this._offsetVertexNormal]/256,o=Math.floor(a),r=256*(a-o);return n.Cartesian2.fromElements(o,r,i)},O.prototype.decodeGeodeticSurfaceNormal=function(t,e,i){return e=e*this.stride+this._offsetGeodeticSurfaceNormal,i.x=t[e],i.y=t[e+1],i.z=t[e+2],i},O.prototype._calculateStrideAndOffsets=function(){let t=0;if(this.quantization===w.BITS12)t+=3;else t+=6;this.hasWebMercatorT&&(t+=1),this.hasVertexNormals&&(this._offsetVertexNormal=t,t+=1),this.hasGeodeticSurfaceNormals&&(this._offsetGeodeticSurfaceNormal=t,t+=3),this.stride=t};const W={position3DAndHeight:0,textureCoordAndEncodedNormals:1,geodeticSurfaceNormal:2},v={compressed0:0,compressed1:1,geodeticSurfaceNormal:2};O.prototype.getAttributes=function(t){const e=c.ComponentDatatype.FLOAT,i=c.ComponentDatatype.getSizeInBytes(e),a=this.stride*i;let o=0;const n=[];function r(r,s){n.push({index:r,vertexBuffer:t,componentDatatype:e,componentsPerAttribute:s,offsetInBytes:o,strideInBytes:a}),o+=s*i}if(this.quantization===w.NONE){r(W.position3DAndHeight,4);let t=2;t+=this.hasWebMercatorT?1:0,t+=this.hasVertexNormals?1:0,r(W.textureCoordAndEncodedNormals,t),this.hasGeodeticSurfaceNormals&&r(W.geodeticSurfaceNormal,3)}else{const t=this.hasWebMercatorT||this.hasVertexNormals,e=this.hasWebMercatorT&&this.hasVertexNormals;r(v.compressed0,t?4:3),e&&r(v.compressed1,1),this.hasGeodeticSurfaceNormals&&r(v.geodeticSurfaceNormal,3)}return n},O.prototype.getAttributeLocations=function(){return this.quantization===w.NONE?W:v},O.clone=function(t,e){if(o.defined(t))return o.defined(e)||(e=new O),e.quantization=t.quantization,e.minimumHeight=t.minimumHeight,e.maximumHeight=t.maximumHeight,e.center=i.Cartesian3.clone(t.center),e.toScaledENU=d.Matrix4.clone(t.toScaledENU),e.fromScaledENU=d.Matrix4.clone(t.fromScaledENU),e.matrix=d.Matrix4.clone(t.matrix),e.hasVertexNormals=t.hasVertexNormals,e.hasWebMercatorT=t.hasWebMercatorT,e.hasGeodeticSurfaceNormals=t.hasGeodeticSurfaceNormals,e.exaggeration=t.exaggeration,e.exaggerationRelativeHeight=t.exaggerationRelativeHeight,e._calculateStrideAndOffsets(),e},t.EllipsoidalOccluder=l,t.TerrainEncoding=O}));