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

2 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2024-01-02 14:12:39 +08:00
define(["./Math-e73894ab","./when-422ea0ae","./Check-741c5f3c","./defaultValue-81eec7ed"],(function(e,t,r,a){"use strict";class i{static upsample(t,r,a,n,s,h){var l=t.tileXYToRectangle(s.x,s.y,s.z),g=t.tileXYToRectangle(h.x,h.y,h.z);let o=new Int16Array(a*n);for(var u=0;u<n;++u)for(var c=e.CesiumMath.lerp(g.north,g.south,u/(n-1)),f=0;f<a;++f){var v=e.CesiumMath.lerp(g.west,g.east,f/(a-1)),H=i.interpolateHeight(r,1,256,1,false,l,a,n,v,c);H=1*H+0,o[u*a+f]=H}return o}static interpolateHeight(e,t,r,a,n,s,h,l,g,o){var u=(g-s.west)*(h-1)/(s.east-s.west),c=(o-s.south)*(l-1)/(s.north-s.south),f=0|u,v=f+1;v>=h&&(v=h-1,f=h-2);var H=0|c,p=H+1;p>=l&&(p=l-1,H=l-2);var w=u-f,d=c-H;H=l-1-H,p=l-1-p;var m=i.getHeight(e,t,r,a,n,H*h+f),y=i.getHeight(e,t,r,a,n,H*h+v),C=i.getHeight(e,t,r,a,n,p*h+f),I=i.getHeight(e,t,r,a,n,p*h+v);return i.triangleInterpolateHeight(w,d,m,y,C,I)}static getHeight(e,t,r,a,i,n){n*=a;var s,h=0;if(i)for(s=0;s<t;++s)h=h*r+e[n+s];else for(s=t-1;s>=0;--s)h=h*r+e[n+s];return h}static triangleInterpolateHeight(e,t,r,a,i,n){return t<e?r+e*(a-r)+t*(n-a):r+e*(n-i)+t*(i-r)}}return i}));