qa-prevention-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/createVerticesFromHeightmap.js

4 lines
26 KiB
JavaScript
Raw Permalink Normal View History

2024-01-02 14:12:39 +08:00
define(["./Cartesian2-bd414876","./AxisAlignedBoundingBox-8774439c","./BoundingSphere-9a3b5656","./Cartesian3-e0307675","./defaultValue-81eec7ed","./Check-741c5f3c","./TerrainEncoding-0f7ffc20","./Math-e73894ab","./Matrix4-4c545f70","./OrientedBoundingBox-c5d2adb7","./Rectangle-cf3e0e3e","./Transforms-5b829630","./WebMercatorProjection-44373a3d","./RuntimeError-26acdd3b","./when-422ea0ae","./createTaskProcessorWorker","./GeographicProjection-c931c7fb","./AttributeCompression-8f752c03","./ComponentDatatype-aaeec80f","./WebGLConstants-508b9636","./Matrix2-dc0c61cc","./EllipsoidTangentPlane-4d138901","./IntersectionTests-80510c7b","./Plane-bc8b6777","./Resource-8ae1a924","./combine-3c023bda"],(function(e,t,i,a,n,r,s,l,o,f,u,c,d,h,m,g,p,x,w,k,y,I,b,U,M,T){"use strict";var V=Object.freeze({NONE:0,LERC:1});const v={};v.DEFAULT_STRUCTURE=Object.freeze({heightScale:1,heightOffset:0,elementsPerHeight:1,stride:1,elementMultiplier:256,isBigEndian:!1});const A=new a.Cartesian3,B=new o.Matrix4,D=new a.Cartesian3,S=new a.Cartesian3;v.computeVertices=function(r){const h=Math.cos,m=Math.sin,g=Math.sqrt,p=Math.atan,x=Math.exp,w=l.CesiumMath.PI_OVER_TWO,k=l.CesiumMath.toRadians,y=r.heightmap,I=r.width,b=r.height,U=r.skirtHeight,M=U>0,T=n.defaultValue(r.isGeographic,!0),V=n.defaultValue(r.ellipsoid,e.Ellipsoid.WGS84),P=1/V.maximumRadius,E=u.Rectangle.clone(r.nativeRectangle),C=u.Rectangle.clone(r.rectangle);let F,R,N,O;n.defined(C)?(F=C.west,R=C.south,N=C.east,O=C.north):T?(F=k(E.west),R=k(E.south),N=k(E.east),O=k(E.north)):(F=E.west*P,R=w-2*p(x(-E.south*P)),N=E.east*P,O=w-2*p(x(-E.north*P)));let L=r.relativeToCenter;const z=n.defined(L);L=z?L:a.Cartesian3.ZERO;const H=n.defaultValue(r.includeWebMercatorT,!1),_=n.defaultValue(r.exaggeration,1),Y=n.defaultValue(r.exaggerationRelativeHeight,0),W=1!==_,X=n.defaultValue(r.structure,v.DEFAULT_STRUCTURE),Z=n.defaultValue(X.heightScale,v.DEFAULT_STRUCTURE.heightScale),j=n.defaultValue(X.heightOffset,v.DEFAULT_STRUCTURE.heightOffset),G=n.defaultValue(X.elementsPerHeight,v.DEFAULT_STRUCTURE.elementsPerHeight),q=n.defaultValue(X.stride,v.DEFAULT_STRUCTURE.stride),Q=n.defaultValue(X.elementMultiplier,v.DEFAULT_STRUCTURE.elementMultiplier),J=n.defaultValue(X.isBigEndian,v.DEFAULT_STRUCTURE.isBigEndian);let K=u.Rectangle.computeWidth(E),$=u.Rectangle.computeHeight(E);const ee=K/(I-1),te=$/(b-1);T||(K*=P,$*=P);const ie=V.radiiSquared,ae=ie.x,ne=ie.y,re=ie.z;let se=65536,le=-65536;const oe=c.Transforms.eastNorthUpToFixedFrame(L,V),fe=o.Matrix4.inverseTransformation(oe,B);let ue,ce;H&&(ue=d.WebMercatorProjection.geodeticLatitudeToMercatorAngle(R),ce=1/(d.WebMercatorProjection.geodeticLatitudeToMercatorAngle(O)-ue));const de=D;de.x=Number.POSITIVE_INFINITY,de.y=Number.POSITIVE_INFINITY,de.z=Number.POSITIVE_INFINITY;const he=S;he.x=Number.NEGATIVE_INFINITY,he.y=Number.NEGATIVE_INFINITY,he.z=Number.NEGATIVE_INFINITY;let me=Number.POSITIVE_INFINITY;const ge=I*b,pe=ge+(U>0?2*I+2*b:0),xe=new Array(pe),we=new Array(pe),ke=new Array(pe),ye=H?new Array(pe):[],Ie=W?new Array(pe):[];let be=0,Ue=b,Me=0,Te=I;M&&(--be,++Ue,--Me,++Te);const Ve=1e-5;for(let t=be;t<Ue;++t){let i=t;i<0&&(i=0),i>=b&&(i=b-1);let n=E.north-te*i;n=T?k(n):w-2*p(x(-n*P));let r=(n-R)/(O-R);r=l.CesiumMath.clamp(r,0,1);const s=t===be,f=t===Ue-1;U>0&&(s?n+=Ve*$:f&&(n-=Ve*$));const u=h(n),c=m(n),M=re*c;let v;H&&(v=(d.WebMercatorProjection.geodeticLatitudeToMercatorAngle(n)-ue)*ce);for(let t=Me;t<Te;++t){let n=t;n<0&&(n=0),n>=I&&(n=I-1);const d=i*(I*q)+n*q;let p;if(1===G)p=y[d];else{let e;if(p=0,J)for(e=0;e<G;++e)p=p*Q+y[d+e];else for(e=G-1;e>=0;--e)p=p*Q+y[d+e]}p=p*Z+j,le=Math.max(le,p),se=Math.min(se,p);let x=E.west+ee*n;T?x=k(x):x*=P;let w=(x-F)/(N-F);w=l.CesiumMath.clamp(w,0,1);let B=i*I+n;if(U>0){const e=t===Me,a=t===Te-1,r=s||f||e||a;if((s||f)&&(e||a))continue;r&&(p-=U,e?(B=ge+(b-i-1),x-=Ve*K):f?B=ge+b+(I-n-1):a?(B=ge+b+I+i,x+=Ve*K):s&&(B=ge+b+I+b+n))}const D=u*h(x),S=u*m(x),C=ae*D,R=ne*S,O=1/g(C*D+R*S+M*c),L=C*O,z=R*O,_=M*O,Y=new a.Cartesian3;Y.x=L+D*p,Y.y=z+S*p,Y.z=_+c*p,o.Matrix4.multiplyByPoint(fe,Y,A),a.Cartesian3.minimumByComponent(A,de,d
/* Copyright 2015-2018 Esri. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @preserve */
!function(){var t,i,a,n,r,s,l,o,f,u,c,d,h,m,g,p,x=(t={defaultNoDataValue:-34027999387901484e22,decode:function(e,s){var l=(s=s||{}).encodedMaskData||null===s.encodedMaskData,o=r(e,s.inputOffset||0,l),f=null!==s.noDataValue?s.noDataValue:t.defaultNoDataValue,u=i(o,s.pixelType||Float32Array,s.encodedMaskData,f,s.returnMask),c={width:o.width,height:o.height,pixelData:u.resultPixels,minValue:u.minValue,maxValue:o.pixels.maxValue,noDataValue:f};return u.resultMask&&(c.maskData=u.resultMask),s.returnEncodedMask&&o.mask&&(c.encodedMaskData=o.mask.bitset?o.mask.bitset:null),s.returnFileInfo&&(c.fileInfo=a(o),s.computeUsedBitDepths&&(c.fileInfo.bitDepths=n(o))),c}},i=function(e,t,i,a,n){var r,l,o,f=0,u=e.pixels.numBlocksX,c=e.pixels.numBlocksY,d=Math.floor(e.width/u),h=Math.floor(e.height/c),m=2*e.maxZError,g=Number.MAX_VALUE;i=i||(e.mask?e.mask.bitset:null),l=new t(e.width*e.height),n&&i&&(o=new Uint8Array(e.width*e.height));for(var p,x,w=new Float32Array(d*h),k=0;k<=c;k++){var y=k!==c?h:e.height%c;if(0!==y)for(var I=0;I<=u;I++){var b=I!==u?d:e.width%u;if(0!==b){var U,M,T,V,v=k*e.width*h+I*d,A=e.width-b,B=e.pixels.blocks[f];if(B.encoding<2?(0===B.encoding?U=B.rawData:(s(B.stuffedData,B.bitsPerPixel,B.numValidPixels,B.offset,m,w,e.pixels.maxValue),U=w),M=0):T=2===B.encoding?0:B.offset,i)for(x=0;x<y;x++){for(7&v&&(V=i[v>>3],V<<=7&v),p=0;p<b;p++)7&v||(V=i[v>>3]),128&V?(o&&(o[v]=1),g=g>(r=B.encoding<2?U[M++]:T)?r:g,l[v++]=r):(o&&(o[v]=0),l[v++]=a),V<<=1;v+=A}else if(B.encoding<2)for(x=0;x<y;x++){for(p=0;p<b;p++)g=g>(r=U[M++])?r:g,l[v++]=r;v+=A}else for(g=g>T?T:g,x=0;x<y;x++){for(p=0;p<b;p++)l[v++]=T;v+=A}if(1===B.encoding&&M!==B.numValidPixels)throw"Block and Mask do not match";f++}}}return{resultPixels:l,resultMask:o,minValue:g}},a=function(e){return{fileIdentifierString:e.fileIdentifierString,fileVersion:e.fileVersion,imageType:e.imageType,height:e.height,width:e.width,maxZError:e.maxZError,eofOffset:e.eofOffset,mask:e.mask?{numBlocksX:e.mask.numBlocksX,numBlocksY:e.mask.numBlocksY,numBytes:e.mask.numBytes,maxValue:e.mask.maxValue}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,numBytes:e.pixels.numBytes,maxValue:e.pixels.maxValue,noDataValue:e.noDataValue}}},n=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,i={},a=0;a<t;a++){var n=e.pixels.blocks[a];0===n.encoding?i.float32=!0:1===n.encoding?i[n.bitsPerPixel]=!0:i[0]=!0}return Object.keys(i)},r=function(e,t,i){var a={},n=new Uint8Array(e,t,10);if(a.fileIdentifierString=String.fromCharCode.apply(null,n),"CntZImage"!==a.fileIdentifierString.trim())throw"Unexpected file identifier string: "+a.fileIdentifierString;t+=10;var r=new DataView(e,t,24);if(a.fileVersion=r.getInt32(0,!0),a.imageType=r.getInt32(4,!0),a.height=r.getUint32(8,!0),a.width=r.getUint32(12,!0),a.maxZError=r.getFloat64(16,!0),t+=24,!i)if(r=new DataView(e,t,16),a.mask={},a.mask.numBlocksY=r.getUint32(0,!0),a.mask.numBlocksX=r.getUint32(4,!0),a.mask.numBytes=r.getUint32(8,!0),a.mask.maxValue=r.getFloat32(12,!0),t+=16,a.mask.numBytes>0){var s=new Uint8Array(Math.ceil(a.width*a.height/8)),l=(r=new DataView(e,t,a.mask.numBytes)).getInt16(0,!0),o=2,f=0;do{if(l>0)for(;l--;)s[f++]=r.getUint8(o++);else{var u=r.getUint8(o++);for(l=-l;l--;)s[f++]=u}l=r.getInt16(o,!0),o+=2}while(o<a.mask.numBytes);if(-32768!==l||f<s.length)throw"Unexpected end of mask RLE encoding";a.mask.bitset=s,t+=a.mask.numBytes}else 0==(a.mask.numBytes|a.mask.numBlocksY|a.mask.maxValue)&&(a.mask.bitset=new Uint8Array(Math.ceil(a.width*a.height/8)));r=new DataView(e,t,16),a.pixels={},a.pixels.numBlocksY=r.getUint32(0,!0),a.pixels.numBlocksX=r.getUint32(4,!0),a.pixels.numBytes=r.getUint32(8,!0),a.pixels.maxValue=r.getFloat32(12,!0),t+=16;var c=a.pixels.numBlocksX,d=a.pixels.numBlocksY,h=c+(a.width%c>0?1:0),m=d+(a.height%d>0?1:0);a.pixels.blocks=new Array(h*m);for(var g=0,p=0;p<m;p++)for(var x=0;x<h;x++){var w=0,k=e.byteLength-t;r=new DataView(e,t,Math.min(10,k));var y={};a.pixels.blocks[g++]=y;var I=r.getUint8(0);if(w++,y.encoding=63&I,y.encoding>3)throw"Invalid block encoding ("+y.encoding+")";if(2!==y.encoding){if(