Agriculture-front-end/dist/Cesium/Workers/createVerticesFromHeightmap.js

4 lines
26 KiB
JavaScript
Raw Normal View History

2023-09-11 21:56:39 +08:00
define(["./Cartesian2-47311507","./EllipsoidTangentPlane-b2b18d75","./BoundingSphere-561b54d0","./Cartographic-3309dd0d","./when-b60132fc","./Check-7b2a090c","./TerrainEncoding-e04be3ba","./Math-119be1a3","./OrientedBoundingBox-f1d7843f","./Transforms-cb0006b0","./WebMercatorProjection-01b1b5e7","./RuntimeError-4a5c8994","./createTaskProcessorWorker","./Cartesian4-3ca25aab","./IntersectionTests-0c6d0a14","./Plane-097b3a8f","./AttributeCompression-90851096","./ComponentDatatype-c140a87d","./WebGLConstants-4ae0db90","./buildModuleUrl-3addfe33","./FeatureDetection-c3b71206"],(function(e,t,a,i,r,n,s,l,o,f,u,c,d,h,m,g,p,w,x,k,y){"use strict";var b=Object.freeze({NONE:0,LERC:1}),I={};I.DEFAULT_STRUCTURE=Object.freeze({heightScale:1,heightOffset:0,elementsPerHeight:1,stride:1,elementMultiplier:256,isBigEndian:!1});var v=new i.Cartesian3,U=new a.Matrix4,T=new i.Cartesian3,M=new i.Cartesian3;I.computeVertices=function(n){var c,d,h,m,g=Math.cos,p=Math.sin,w=Math.sqrt,x=Math.atan,k=Math.exp,y=l.CesiumMath.PI_OVER_TWO,b=l.CesiumMath.toRadians,V=n.heightmap,A=n.width,B=n.height,D=n.skirtHeight,S=r.defaultValue(n.isGeographic,!0),P=r.defaultValue(n.ellipsoid,e.Ellipsoid.WGS84),E=1/P.maximumRadius,C=n.nativeRectangle,F=n.rectangle;r.defined(F)?(c=F.west,d=F.south,h=F.east,m=F.north):S?(c=b(C.west),d=b(C.south),h=b(C.east),m=b(C.north)):(c=C.west*E,d=y-2*x(k(-C.south*E)),h=C.east*E,m=y-2*x(k(-C.north*E)));var L=n.relativeToCenter,O=r.defined(L);L=O?L:i.Cartesian3.ZERO;var N=r.defaultValue(n.exaggeration,1),z=r.defaultValue(n.includeWebMercatorT,!1),R=r.defaultValue(n.structure,I.DEFAULT_STRUCTURE),_=r.defaultValue(R.heightScale,I.DEFAULT_STRUCTURE.heightScale),H=r.defaultValue(R.heightOffset,I.DEFAULT_STRUCTURE.heightOffset),Y=r.defaultValue(R.elementsPerHeight,I.DEFAULT_STRUCTURE.elementsPerHeight),W=r.defaultValue(R.stride,I.DEFAULT_STRUCTURE.stride),X=r.defaultValue(R.elementMultiplier,I.DEFAULT_STRUCTURE.elementMultiplier),Z=r.defaultValue(R.isBigEndian,I.DEFAULT_STRUCTURE.isBigEndian),j=e.Rectangle.computeWidth(C),G=e.Rectangle.computeHeight(C),q=j/(A-1),Q=G/(B-1);S||(j*=E,G*=E);var J,K,$=P.radiiSquared,ee=$.x,te=$.y,ae=$.z,ie=65536,re=-65536,ne=f.Transforms.eastNorthUpToFixedFrame(L,P),se=a.Matrix4.inverseTransformation(ne,U);z&&(J=u.WebMercatorProjection.geodeticLatitudeToMercatorAngle(d),K=1/(u.WebMercatorProjection.geodeticLatitudeToMercatorAngle(m)-J));var le=T;le.x=Number.POSITIVE_INFINITY,le.y=Number.POSITIVE_INFINITY,le.z=Number.POSITIVE_INFINITY;var oe=M;oe.x=Number.NEGATIVE_INFINITY,oe.y=Number.NEGATIVE_INFINITY,oe.z=Number.NEGATIVE_INFINITY;var fe=Number.POSITIVE_INFINITY,ue=A*B,ce=ue+(D>0?2*A+2*B:0),de=new Array(ce),he=new Array(ce),me=new Array(ce),ge=z?new Array(ce):[],pe=0,we=B,xe=0,ke=A;D>0&&(--pe,++we,--xe,++ke);for(var ye=1e-5,be=pe;be<we;++be){var Ie=be;Ie<0&&(Ie=0),Ie>=B&&(Ie=B-1);var ve=C.north-Q*Ie,Ue=((ve=S?b(ve):y-2*x(k(-ve*E)))-d)/(m-d);Ue=l.CesiumMath.clamp(Ue,0,1);var Te=be===pe,Me=be===we-1;D>0&&(Te?ve+=ye*G:Me&&(ve-=ye*G));var Ve,Ae=g(ve),Be=p(ve),De=ae*Be;z&&(Ve=(u.WebMercatorProjection.geodeticLatitudeToMercatorAngle(ve)-J)*K);for(var Se=xe;Se<ke;++Se){var Pe=Se;Pe<0&&(Pe=0),Pe>=A&&(Pe=A-1);var Ee,Ce,Fe=Ie*(A*W)+Pe*W;if(1===Y)Ee=V[Fe];else if(Ee=0,Z)for(Ce=0;Ce<Y;++Ce)Ee=Ee*X+V[Fe+Ce];else for(Ce=Y-1;Ce>=0;--Ce)Ee=Ee*X+V[Fe+Ce];Ee=(Ee*_+H)*N,re=Math.max(re,Ee),ie=Math.min(ie,Ee);var Le=C.west+q*Pe;S?Le=b(Le):Le*=E;var Oe=(Le-c)/(h-c);Oe=l.CesiumMath.clamp(Oe,0,1);var Ne=Ie*A+Pe;if(D>0){var ze=Se===xe,Re=Se===ke-1,_e=Te||Me||ze||Re;if((Te||Me)&&(ze||Re))continue;_e&&(Ee-=D,ze?(Ne=ue+(B-Ie-1),Le-=ye*j):Me?Ne=ue+B+(A-Pe-1):Re?(Ne=ue+B+A+Ie,Le+=ye*j):Te&&(Ne=ue+B+A+B+Pe))}var He=Ae*g(Le),Ye=Ae*p(Le),We=ee*He,Xe=te*Ye,Ze=1/w(We*He+Xe*Ye+De*Be),je=We*Ze,Ge=Xe*Ze,qe=De*Ze,Qe=new i.Cartesian3;Qe.x=je+He*Ee,Qe.y=Ge+Ye*Ee,Qe.z=qe+Be*Ee,de[Ne]=Qe,he[Ne]=Ee,me[Ne]=new e.Cartesian2(Oe,Ue),z&&(ge[Ne]=Ve),a.Matrix4.multiplyByPoint(se,Qe,v),i.Cartesian3.minimumByComponent(v,le,le),i.Cartesian3.maximumByComponent(v,oe,oe),fe=Math.min(fe,Ee)}}var Je,Ke,$e=a.BoundingSphere.fromPoints(de);(r.defined(F)&&(Je=o.OrientedBo
2023-04-23 09:41:12 +08:00
/* 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 */
2023-09-11 21:56:39 +08:00
var V={};!function(){var e,t,a,i,r,n,s,l,o,f,u,c,d,h,m,g,p=(e={defaultNoDataValue:-34027999387901484e22,decode:function(n,s){var l=(s=s||{}).encodedMaskData||null===s.encodedMaskData,o=r(n,s.inputOffset||0,l),f=null!==s.noDataValue?s.noDataValue:e.defaultNoDataValue,u=t(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=i(o))),c}},t=function(e,t,a,i,r){var s,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;a=a||(e.mask?e.mask.bitset:null),l=new t(e.width*e.height),r&&a&&(o=new Uint8Array(e.width*e.height));for(var p,w,x=new Float32Array(d*h),k=0;k<=c;k++){var y=k!==c?h:e.height%c;if(0!==y)for(var b=0;b<=u;b++){var I=b!==u?d:e.width%u;if(0!==I){var v,U,T,M,V=k*e.width*h+b*d,A=e.width-I,B=e.pixels.blocks[f];if(B.encoding<2?(0===B.encoding?v=B.rawData:(n(B.stuffedData,B.bitsPerPixel,B.numValidPixels,B.offset,m,x,e.pixels.maxValue),v=x),U=0):T=2===B.encoding?0:B.offset,a)for(w=0;w<y;w++){for(7&V&&(M=a[V>>3],M<<=7&V),p=0;p<I;p++)7&V||(M=a[V>>3]),128&M?(o&&(o[V]=1),g=g>(s=B.encoding<2?v[U++]:T)?s:g,l[V++]=s):(o&&(o[V]=0),l[V++]=i),M<<=1;V+=A}else if(B.encoding<2)for(w=0;w<y;w++){for(p=0;p<I;p++)g=g>(s=v[U++])?s:g,l[V++]=s;V+=A}else for(g=g>T?T:g,w=0;w<y;w++){for(p=0;p<I;p++)l[V++]=T;V+=A}if(1===B.encoding&&U!==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}}},i=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,a={},i=0;i<t;i++){var r=e.pixels.blocks[i];0===r.encoding?a.float32=!0:1===r.encoding?a[r.bitsPerPixel]=!0:a[0]=!0}return Object.keys(a)},r=function(e,t,a){var i={},r=new Uint8Array(e,t,10);if(i.fileIdentifierString=String.fromCharCode.apply(null,r),"CntZImage"!==i.fileIdentifierString.trim())throw"Unexpected file identifier string: "+i.fileIdentifierString;t+=10;var n=new DataView(e,t,24);if(i.fileVersion=n.getInt32(0,!0),i.imageType=n.getInt32(4,!0),i.height=n.getUint32(8,!0),i.width=n.getUint32(12,!0),i.maxZError=n.getFloat64(16,!0),t+=24,!a)if(n=new DataView(e,t,16),i.mask={},i.mask.numBlocksY=n.getUint32(0,!0),i.mask.numBlocksX=n.getUint32(4,!0),i.mask.numBytes=n.getUint32(8,!0),i.mask.maxValue=n.getFloat32(12,!0),t+=16,i.mask.numBytes>0){var s=new Uint8Array(Math.ceil(i.width*i.height/8)),l=(n=new DataView(e,t,i.mask.numBytes)).getInt16(0,!0),o=2,f=0;do{if(l>0)for(;l--;)s[f++]=n.getUint8(o++);else{var u=n.getUint8(o++);for(l=-l;l--;)s[f++]=u}l=n.getInt16(o,!0),o+=2}while(o<i.mask.numBytes);if(-32768!==l||f<s.length)throw"Unexpected end of mask RLE encoding";i.mask.bitset=s,t+=i.mask.numBytes}else 0==(i.mask.numBytes|i.mask.numBlocksY|i.mask.maxValue)&&(i.mask.bitset=new Uint8Array(Math.ceil(i.width*i.height/8)));n=new DataView(e,t,16),i.pixels={},i.pixels.numBlocksY=n.getUint32(0,!0),i.pixels.numBlocksX=n.getUint32(4,!0),i.pixels.numBytes=n.getUint32(8,!0),i.pixels.maxValue=n.getFloat32(12,!0),t+=16;var c=i.pixels.numBlocksX,d=i.pixels.numBlocksY,h=c+(i.width%c>0?1:0),m=d+(i.height%d>0?1:0);i.pixels.blocks=new Array(h*m);for(var g=0,p=0;p<m;p++)for(var w=0;w<h;w++){var x=0,k=e.byteLength-t;n=new DataView(e,t,Math.min(10,k));var y={};i.pixels.blocks[g++]=y;var b=n.getUint8(0);if(x++,y.encoding=63&b,y.encoding>3)throw"Invalid block encoding ("+y.encoding+")";if(2!==y.enco