YZProjectCloud/yanzhu-ui-vue3/public/Engine/Workers/createVerticesFromHeightmap.js

4 lines
26 KiB
JavaScript
Raw Normal View History

2025-04-07 00:55:58 +08:00
define(["./Matrix2-e3fb4559","./AxisAlignedBoundingBox-37250ed6","./Transforms-98ffa11d","./Cartesian3-7e9cc2ff","./defaultValue-81eec7ed","./Check-741c5f3c","./TerrainEncoding-2e2628a7","./Math-5f585871","./Matrix4-d34187af","./OrientedBoundingBox-3db45505","./WebMercatorProjection-f5706bbf","./RuntimeError-26acdd3b","./_commonjsHelpers-3aae1032-26891ab7","./createTaskProcessorWorker","./combine-3c023bda","./AttributeCompression-e2e3f0dd","./ComponentDatatype-aaeec80f","./WebGLConstants-508b9636","./EllipsoidTangentPlane-fa1337e1","./IntersectionTests-73b87d72","./Plane-4f75b3df"],(function(e,t,i,a,n,r,s,l,o,f,u,c,d,h,m,g,p,x,w,k,y){"use strict";var I=Object.freeze({NONE:0,LERC:1});const b={};b.DEFAULT_STRUCTURE=Object.freeze({heightScale:1,heightOffset:0,elementsPerHeight:1,stride:1,elementMultiplier:256,isBigEndian:!1});const U=new a.Cartesian3,M=new o.Matrix4,T=new a.Cartesian3,V=new a.Cartesian3;b.computeVertices=function(r){const c=Math.cos,d=Math.sin,h=Math.sqrt,m=Math.atan,g=Math.exp,p=l.CesiumMath.PI_OVER_TWO,x=l.CesiumMath.toRadians,w=r.heightmap,k=r.width,y=r.height,I=r.skirtHeight,v=I>0,A=n.defaultValue(r.isGeographic,!0),B=n.defaultValue(r.ellipsoid,e.Ellipsoid.WGS84),D=1/B.maximumRadius,S=e.Rectangle.clone(r.nativeRectangle),P=e.Rectangle.clone(r.rectangle);let E,C,F,N;n.defined(P)?(E=P.west,C=P.south,F=P.east,N=P.north):A?(E=x(S.west),C=x(S.south),F=x(S.east),N=x(S.north)):(E=S.west*D,C=p-2*m(g(-S.south*D)),F=S.east*D,N=p-2*m(g(-S.north*D)));let O=r.relativeToCenter;const R=n.defined(O);O=R?O:a.Cartesian3.ZERO;const L=n.defaultValue(r.includeWebMercatorT,!1),z=n.defaultValue(r.exaggeration,1),H=n.defaultValue(r.exaggerationRelativeHeight,0),_=1!==z,Y=n.defaultValue(r.structure,b.DEFAULT_STRUCTURE),W=n.defaultValue(Y.heightScale,b.DEFAULT_STRUCTURE.heightScale),X=n.defaultValue(Y.heightOffset,b.DEFAULT_STRUCTURE.heightOffset),Z=n.defaultValue(Y.elementsPerHeight,b.DEFAULT_STRUCTURE.elementsPerHeight),j=n.defaultValue(Y.stride,b.DEFAULT_STRUCTURE.stride),G=n.defaultValue(Y.elementMultiplier,b.DEFAULT_STRUCTURE.elementMultiplier),q=n.defaultValue(Y.isBigEndian,b.DEFAULT_STRUCTURE.isBigEndian);let Q=e.Rectangle.computeWidth(S),J=e.Rectangle.computeHeight(S);const K=Q/(k-1),$=J/(y-1);A||(Q*=D,J*=D);const ee=B.radiiSquared,te=ee.x,ie=ee.y,ae=ee.z;let ne=65536,re=-65536;const se=i.Transforms.eastNorthUpToFixedFrame(O,B),le=o.Matrix4.inverseTransformation(se,M);let oe,fe;L&&(oe=u.WebMercatorProjection.geodeticLatitudeToMercatorAngle(C),fe=1/(u.WebMercatorProjection.geodeticLatitudeToMercatorAngle(N)-oe));const ue=T;ue.x=Number.POSITIVE_INFINITY,ue.y=Number.POSITIVE_INFINITY,ue.z=Number.POSITIVE_INFINITY;const ce=V;ce.x=Number.NEGATIVE_INFINITY,ce.y=Number.NEGATIVE_INFINITY,ce.z=Number.NEGATIVE_INFINITY;let de=Number.POSITIVE_INFINITY;const he=k*y,me=he+(I>0?2*k+2*y:0),ge=new Array(me),pe=new Array(me),xe=new Array(me),we=L?new Array(me):[],ke=_?new Array(me):[];let ye=0,Ie=y,be=0,Ue=k;v&&(--ye,++Ie,--be,++Ue);const Me=1e-5;for(let t=ye;t<Ie;++t){let i=t;i<0&&(i=0),i>=y&&(i=y-1);let n=S.north-$*i;n=A?x(n):p-2*m(g(-n*D));let r=(n-C)/(N-C);r=l.CesiumMath.clamp(r,0,1);const s=t===ye,f=t===Ie-1;I>0&&(s?n+=Me*J:f&&(n-=Me*J));const b=c(n),M=d(n),T=ae*M;let V;L&&(V=(u.WebMercatorProjection.geodeticLatitudeToMercatorAngle(n)-oe)*fe);for(let t=be;t<Ue;++t){let n=t;n<0&&(n=0),n>=k&&(n=k-1);const u=i*(k*j)+n*j;let m;if(1===Z)m=w[u];else{let e;if(m=0,q)for(e=0;e<Z;++e)m=m*G+w[u+e];else for(e=Z-1;e>=0;--e)m=m*G+w[u+e]}m=m*W+X,re=Math.max(re,m),ne=Math.min(ne,m);let g=S.west+K*n;A?g=x(g):g*=D;let p=(g-E)/(F-E);p=l.CesiumMath.clamp(p,0,1);let v=i*k+n;if(I>0){const e=t===be,a=t===Ue-1,r=s||f||e||a;if((s||f)&&(e||a))continue;r&&(m-=I,e?(v=he+(y-i-1),g-=Me*Q):f?v=he+y+(k-n-1):a?(v=he+y+k+i,g+=Me*Q):s&&(v=he+y+k+y+n))}const P=b*c(g),C=b*d(g),N=te*P,O=ie*C,R=1/h(N*P+O*C+T*M),z=N*R,H=O*R,Y=T*R,J=new a.Cartesian3;J.x=z+P*m,J.y=H+C*m,J.z=Y+M*m,o.Matrix4.multiplyByPoint(le,J,U),a.Cartesian3.minimumByComponent(U,ue,ue),a.Cartesian3.maximumByComponent(U,ce,ce),de=Math.min(de,m),ge[v]=J,xe[v]=new e.Cartesian2(p,r),pe[v]=m,L&&(we[v]=V),_&&(k
/* 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(