/** * Cesium - https://github.com/CesiumGS/cesium * * Copyright 2011-2020 Cesium Contributors * * 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 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Columbus View (Pat. Pend.) * * Portions licensed separately. * See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details. */ define(["exports","./when-8d13db60","./Check-70bec281","./Math-61ede240","./Cartographic-f27b0939","./Cartesian2-09435a6c","./BoundingSphere-c409f092","./Cartesian4-5af5bb24","./RuntimeError-ba10bc3e","./FeatureDetection-7bd32c34","./buildModuleUrl-392763e2"],function(e,S,T,g,f,u,P,i,c,t,d){function w(e,t,r,n){this.x=S.defaultValue(e,0),this.y=S.defaultValue(t,0),this.z=S.defaultValue(r,0),this.w=S.defaultValue(n,0)}var h=new f.Cartesian3;w.fromAxisAngle=function(e,t,r){T.Check.typeOf.object("axis",e),T.Check.typeOf.number("angle",t);var n=t/2,a=Math.sin(n),i=(h=f.Cartesian3.normalize(e,h)).x*a,o=h.y*a,s=h.z*a,l=Math.cos(n);return S.defined(r)?(r.x=i,r.y=o,r.z=s,r.w=l,r):new w(i,o,s,l)};var m=[1,2,0],y=new Array(3);w.fromRotationMatrix=function(e,t){var r,n,a,i,o;T.Check.typeOf.object("matrix",e);var s=e[P.Matrix3.COLUMN0ROW0],l=e[P.Matrix3.COLUMN1ROW1],u=e[P.Matrix3.COLUMN2ROW2],d=s+l+u;if(0=t?"":Array(1+t-e.length>>>0).join(r);return n?e+a:a+e},D=function(e,t,r,n,a,i){var o=n-e.length;return 0>>0;return e=(r=r&&s&&{2:"0b",8:"0",16:"0x"}[t]||"")+E(s.toString(t),i||0,"0",!1),D(e,r,n,a,o)},_=function(e,t,r,n,a,i){return null!=n&&(e=e.slice(0,n)),D(e,"",t,r,a,i)};return e.replace(/%%|%(\d+\$)?([-+\'#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuideEfFgG])/g,function(e,t,r,n,a,i,o){var s,l,u,d,f;if("%%"==e)return"%";for(var c=!1,h="",p=!1,w=!1,m=" ",y=r.length,C=0;r&&C=t.length&&(r=t.length-1);var n=t[r].offset;0=r.length)return he.addSeconds(e,-r[n-1].offset,t);var a=he.secondsDifference(r[n].julianDate,e);return 0===a?he.addSeconds(e,-r[n].offset,t):a<=1?void 0:he.addSeconds(e,-r[--n].offset,t)}function te(e,t,r){var n=t/Z.SECONDS_PER_DAY|0;return e+=n,(t-=Z.SECONDS_PER_DAY*n)<0&&(e--,t+=Z.SECONDS_PER_DAY),r.dayNumber=e,r.secondsOfDay=t,r}function re(e,t,r,n,a,i,o){var s=(t-14)/12|0,l=e+4800+s,u=(1461*l/4|0)+(367*(t-2-12*s)/12|0)-(3*((l+100)/100|0)/4|0)+r-32075;(n-=12)<0&&(n+=24);var d=i+(n*Z.SECONDS_PER_HOUR+a*Z.SECONDS_PER_MINUTE+o*Z.SECONDS_PER_MILLISECOND);return 43200<=d&&(u-=1),[u,d]}var ne=/^(\d{4})$/,ae=/^(\d{4})-(\d{2})$/,ie=/^(\d{4})-?(\d{3})$/,oe=/^(\d{4})-?W(\d{2})-?(\d{1})?$/,se=/^(\d{4})-?(\d{2})-?(\d{2})$/,le=/([Z+\-])?(\d{2})?:?(\d{2})?$/,ue=/^(\d{2})(\.\d+)?/.source+le.source,de=/^(\d{2}):?(\d{2})(\.\d+)?/.source+le.source,fe=/^(\d{2}):?(\d{2}):?(\d{2})(\.\d+)?/.source+le.source,ce="Invalid ISO 8601 date.";function he(e,t,r){this.dayNumber=void 0,this.secondsOfDay=void 0,e=S.defaultValue(e,0),t=S.defaultValue(t,0),r=S.defaultValue(r,X.UTC);var n=0|e;te(n,t+=(e-n)*Z.SECONDS_PER_DAY,this),r===X.UTC&&K(this)}he.fromGregorianDate=function(e,t){if(!(e instanceof Y))throw new T.DeveloperError("date must be a valid GregorianDate.");var r=re(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond);return S.defined(t)?(te(r[0],r[1],t),K(t),t):new he(r[0],r[1],X.UTC)},he.fromDate=function(e,t){if(!(e instanceof Date)||isNaN(e.getTime()))throw new T.DeveloperError("date must be a valid JavaScript Date.");var r=re(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds());return S.defined(t)?(te(r[0],r[1],t),K(t),t):new he(r[0],r[1],X.UTC)},he.fromIso8601=function(e,t){if("string"!=typeof e)throw new T.DeveloperError(ce);var r,n,a,i,o,s=(e=e.replace(",",".")).split("T"),l=1,u=1,d=0,f=0,c=0,h=0,p=s[0],w=s[1];if(!S.defined(p))throw new T.DeveloperError(ce);if(null!==(s=p.match(se))){if(0<(i=p.split("-").length-1)&&2!==i)throw new T.DeveloperError(ce);r=+s[1],l=+s[2],u=+s[3]}else if(null!==(s=p.match(ae)))r=+s[1],l=+s[2];else if(null!==(s=p.match(ne)))r=+s[1];else{var m;if(null!==(s=p.match(ie))){if(r=+s[1],m=+s[2],a=B(r),m<1||a&&366t.length-1)return o.xPoleWander=0,o.yPoleWander=0,o.xPoleOffset=0,o.yPoleOffset=0,o.ut1MinusUtc=0,o;var l=t[a],u=t[i];if(l.equals(u)||n.equals(l))return Ce(e,r,a,s,o),o;if(n.equals(u))return Ce(e,r,i,s,o),o;var d=he.secondsDifference(n,l)/he.secondsDifference(u,l),f=a*s,c=i*s,h=r[f+e._ut1MinusUtcSecondsColumn],p=r[c+e._ut1MinusUtcSecondsColumn],w=p-h;if(.5=this._totalSamples&&(s=this._totalSamples-1);for(var l=o/this._samplesPerXysFile|0,u=s/this._samplesPerXysFile|0,d=[],f=l;f<=u;++f)d.push(Se(this,f));return S.when.all(d)},ve.prototype.computeXysRadians=function(e,t,r){var n=Me(this,e,t);if(!(n<0)){var a=n/this._stepSizeDays|0;if(!(a>=this._totalSamples)){var i=this._interpolationOrder,o=a-(i/2|0);o<0&&(o=0);var s=o+i;s>=this._totalSamples&&(o=(s=this._totalSamples-1)-i)<0&&(o=0);var l=!1,u=this._samples;if(S.defined(u[3*o])||(Se(this,o/this._samplesPerXysFile|0),l=!0),S.defined(u[3*s])||(Se(this,s/this._samplesPerXysFile|0),l=!0),!l){S.defined(r)?(r.x=0,r.y=0,r.s=0):r=new De(0,0,0);var d,f,c=n-o*this._stepSizeDays,h=this._work,p=this._denominators,w=this._coef,m=this._xTable;for(d=0;d<=i;++d)h[d]=c-m[d];for(d=0;d<=i;++d){for(w[d]=1,f=0;f<=i;++f)f!==d&&(w[d]*=h[f]);w[d]*=p[d];var y=3*(o+d);r.x+=w[d]*u[y++],r.y+=w[d]*u[y++],r.s+=w[d]*u[y]}return r}}}};var Te={},ge={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},Pe={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},be={},Ne={east:new f.Cartesian3,north:new f.Cartesian3,up:new f.Cartesian3,west:new f.Cartesian3,south:new f.Cartesian3,down:new f.Cartesian3},Re=new f.Cartesian3,Ie=new f.Cartesian3,qe=new f.Cartesian3;Te.localFrameToFixedFrameGenerator=function(o,s){if(!ge.hasOwnProperty(o)||!ge[o].hasOwnProperty(s))throw new T.DeveloperError("firstAxis and secondAxis must be east, north, up, west, south or down.");var e,l=ge[o][s],t=o+s;return S.defined(be[t])?e=be[t]:(e=function(e,t,r){if(!S.defined(e))throw new T.DeveloperError("origin is required.");if(S.defined(r)||(r=new P.Matrix4),f.Cartesian3.equalsEpsilon(e,f.Cartesian3.ZERO,g.CesiumMath.EPSILON14))f.Cartesian3.unpack(Pe[o],0,Re),f.Cartesian3.unpack(Pe[s],0,Ie),f.Cartesian3.unpack(Pe[l],0,qe);else if(g.CesiumMath.equalsEpsilon(e.x,0,g.CesiumMath.EPSILON14)&&g.CesiumMath.equalsEpsilon(e.y,0,g.CesiumMath.EPSILON14)){var n=g.CesiumMath.sign(e.z);f.Cartesian3.unpack(Pe[o],0,Re),"east"!==o&&"west"!==o&&f.Cartesian3.multiplyByScalar(Re,n,Re),f.Cartesian3.unpack(Pe[s],0,Ie),"east"!==s&&"west"!==s&&f.Cartesian3.multiplyByScalar(Ie,n,Ie),f.Cartesian3.unpack(Pe[l],0,qe),"east"!==l&&"west"!==l&&f.Cartesian3.multiplyByScalar(qe,n,qe)}else{(t=S.defaultValue(t,u.Ellipsoid.WGS84)).geodeticSurfaceNormal(e,Ne.up);var a=Ne.up,i=Ne.east;i.x=-e.y,i.y=e.x,i.z=0,f.Cartesian3.normalize(i,Ne.east),f.Cartesian3.cross(a,i,Ne.north),f.Cartesian3.multiplyByScalar(Ne.up,-1,Ne.down),f.Cartesian3.multiplyByScalar(Ne.east,-1,Ne.west),f.Cartesian3.multiplyByScalar(Ne.north,-1,Ne.south),Re=Ne[o],Ie=Ne[s],qe=Ne[l]}return r[0]=Re.x,r[1]=Re.y,r[2]=Re.z,r[3]=0,r[4]=Ie.x,r[5]=Ie.y,r[6]=Ie.z,r[7]=0,r[8]=qe.x,r[9]=qe.y,r[10]=qe.z,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,r},be[t]=e),e},Te.eastNorthUpToFixedFrame=Te.localFrameToFixedFrameGenerator("east","north"),Te.northEastDownToFixedFrame=Te.localFrameToFixedFrameGenerator("north","east"),Te.northUpEastToFixedFrame=Te.localFrameToFixedFrameGenerator("north","up"),Te.northWestUpToFixedFrame=Te.localFrameToFixedFrameGenerator("north","west");var Ae=new w,Ue=new f.Cartesian3(1,1,1),ke=new P.Matrix4;Te.headingPitchRollToFixedFrame=function(e,t,r,n,a){T.Check.typeOf.object("HeadingPitchRoll",t),n=S.defaultValue(n,Te.eastNorthUpToFixedFrame);var i=w.fromHeadingPitchRoll(t,Ae),o=P.Matrix4.fromTranslationQuaternionRotationScale(f.Cartesian3.ZERO,i,Ue,ke);return a=n(e,r,a),P.Matrix4.multiply(a,o,a)};var je=new P.Matrix4,ze=new P.Matrix3;Te.headingPitchRollQuaternion=function(e,t,r,n,a){T.Check.typeOf.object("HeadingPitchRoll",t);var i=Te.headingPitchRollToFixedFrame(e,t,r,n,je),o=P.Matrix4.getMatrix3(i,ze);return w.fromRotationMatrix(o,a)};var Fe=new f.Cartesian3(1,1,1),We=new f.Cartesian3,Le=new P.Matrix4,Ve=new P.Matrix4,Ye=new P.Matrix3,Be=new w;Te.fixedFrameToHeadingPitchRoll=function(e,t,r,n){T.Check.defined("transform",e),t=S.defaultValue(t,u.Ellipsoid.WGS84),r=S.defaultValue(r,Te.eastNorthUpToFixedFrame),S.defined(n)||(n=new Ee);var a=P.Matrix4.getTranslation(e,We);if(f.Cartesian3.equals(a,f.Cartesian3.ZERO))return n.heading=0,n.pitch=0,n.roll=0,n;var i=P.Matrix4.inverseTransformation(r(a,t,Le),Le),o=P.Matrix4.setScale(e,Fe,Ve);o=P.Matrix4.setTranslation(o,f.Cartesian3.ZERO,o),i=P.Matrix4.multiply(i,o,i);var s=w.fromRotationMatrix(P.Matrix4.getMatrix3(i,Ye),Be);return s=w.normalize(s,s),Ee.fromQuaternion(s,n)};var Ge=g.CesiumMath.TWO_PI/86400,Ze=new he;Te.computeTemeToPseudoFixedMatrix=function(e,t){if(!S.defined(e))throw new T.DeveloperError("date is required.");var r,n=(Ze=he.addSeconds(e,-he.computeTaiMinusUtc(e),Ze)).dayNumber,a=Ze.secondsOfDay,i=n-2451545,o=(24110.54841+(r=43200<=a?(i+.5)/Z.DAYS_PER_JULIAN_CENTURY:(i-.5)/Z.DAYS_PER_JULIAN_CENTURY)*(8640184.812866+r*(.093104+-62e-7*r)))*Ge%g.CesiumMath.TWO_PI+(72921158553e-15+11772758384668e-32*(n-2451545.5))*((a+.5*Z.SECONDS_PER_DAY)%Z.SECONDS_PER_DAY),s=Math.cos(o),l=Math.sin(o);return S.defined(t)?(t[0]=s,t[1]=-l,t[2]=0,t[3]=l,t[4]=s,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t):new P.Matrix3(s,l,0,-l,s,0,0,0,1)},Te.iau2006XysData=new ve,Te.earthOrientationParameters=we.NONE;var Xe=32.184;Te.preloadIcrfFixed=function(e){var t=e.start.dayNumber,r=e.start.secondsOfDay+Xe,n=e.stop.dayNumber,a=e.stop.secondsOfDay+Xe,i=Te.iau2006XysData.preload(t,r,n,a),o=Te.earthOrientationParameters.getPromiseToLoad();return S.when.all([i,o])},Te.computeIcrfToFixedMatrix=function(e,t){if(!S.defined(e))throw new T.DeveloperError("date is required.");S.defined(t)||(t=new P.Matrix3);var r=Te.computeFixedToIcrfMatrix(e,t);if(S.defined(r))return P.Matrix3.transpose(r,t)};var Je=new De(0,0,0),He=new L(0,0,0,0,0,0),$e=new P.Matrix3,Qe=new P.Matrix3;Te.computeFixedToIcrfMatrix=function(e,t){if(!S.defined(e))throw new T.DeveloperError("date is required.");S.defined(t)||(t=new P.Matrix3);var r=Te.earthOrientationParameters.compute(e,He);if(S.defined(r)){var n=e.dayNumber,a=e.secondsOfDay+Xe,i=Te.iau2006XysData.computeXysRadians(n,a,Je);if(S.defined(i)){var o=i.x+r.xPoleOffset,s=i.y+r.yPoleOffset,l=1/(1+Math.sqrt(1-o*o-s*s)),u=$e;u[0]=1-l*o*o,u[3]=-l*o*s,u[6]=o,u[1]=-l*o*s,u[4]=1-l*s*s,u[7]=s,u[2]=-o,u[5]=-s,u[8]=1-l*(o*o+s*s);var d=P.Matrix3.fromRotationZ(-i.s,Qe),f=P.Matrix3.multiply(u,d,$e),c=e.dayNumber-2451545,h=(e.secondsOfDay-he.computeTaiMinusUtc(e)+r.ut1MinusUtc)/Z.SECONDS_PER_DAY,p=.779057273264+h+.00273781191135448*(c+h);p=p%1*g.CesiumMath.TWO_PI;var w=P.Matrix3.fromRotationZ(p,Qe),m=P.Matrix3.multiply(f,w,$e),y=Math.cos(r.xPoleWander),C=Math.cos(r.yPoleWander),x=Math.sin(r.xPoleWander),O=Math.sin(r.yPoleWander),E=n-2451545+a/Z.SECONDS_PER_DAY,D=-47e-6*(E/=36525)*g.CesiumMath.RADIANS_PER_DEGREE/3600,v=Math.cos(D),_=Math.sin(D),M=Qe;return M[0]=y*v,M[1]=y*_,M[2]=x,M[3]=-C*_+O*x*v,M[4]=C*v+O*x*_,M[5]=-O*y,M[6]=-O*_-C*x*v,M[7]=O*v-C*x*_,M[8]=C*y,P.Matrix3.multiply(m,M,t)}}};var Ke=new i.Cartesian4;Te.pointToWindowCoordinates=function(e,t,r,n){return(n=Te.pointToGLWindowCoordinates(e,t,r,n)).y=2*t[5]-n.y,n},Te.pointToGLWindowCoordinates=function(e,t,r,n){if(!S.defined(e))throw new T.DeveloperError("modelViewProjectionMatrix is required.");if(!S.defined(t))throw new T.DeveloperError("viewportTransformation is required.");if(!S.defined(r))throw new T.DeveloperError("point is required.");S.defined(n)||(n=new u.Cartesian2);var a=Ke;return P.Matrix4.multiplyByVector(e,i.Cartesian4.fromElements(r.x,r.y,r.z,1,a),a),i.Cartesian4.multiplyByScalar(a,1/a.w,a),P.Matrix4.multiplyByVector(t,a,a),u.Cartesian2.fromCartesian4(a,n)};var et=new f.Cartesian3,tt=new f.Cartesian3,rt=new f.Cartesian3;Te.rotationMatrixFromPositionVelocity=function(e,t,r,n){if(!S.defined(e))throw new T.DeveloperError("position is required.");if(!S.defined(t))throw new T.DeveloperError("velocity is required.");var a=S.defaultValue(r,u.Ellipsoid.WGS84).geodeticSurfaceNormal(e,et),i=f.Cartesian3.cross(t,a,tt);f.Cartesian3.equalsEpsilon(i,f.Cartesian3.ZERO,g.CesiumMath.EPSILON6)&&(i=f.Cartesian3.clone(f.Cartesian3.UNIT_X,i));var o=f.Cartesian3.cross(i,t,rt);return f.Cartesian3.normalize(o,o),f.Cartesian3.cross(t,o,i),f.Cartesian3.negate(i,i),f.Cartesian3.normalize(i,i),S.defined(n)||(n=new P.Matrix3),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=i.x,n[4]=i.y,n[5]=i.z,n[6]=o.x,n[7]=o.y,n[8]=o.z,n};var nt=new P.Matrix4(0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,1),at=new f.Cartographic,it=new f.Cartesian3,ot=new f.Cartesian3,st=new P.Matrix3,lt=new P.Matrix4,ut=new P.Matrix4;Te.basisTo2D=function(e,t,r){if(!S.defined(e))throw new T.DeveloperError("projection is required.");if(!S.defined(t))throw new T.DeveloperError("matrix is required.");if(!S.defined(r))throw new T.DeveloperError("result is required.");var n=P.Matrix4.getTranslation(t,ot),a=e.ellipsoid,i=a.cartesianToCartographic(n,at),o=e.project(i,it);f.Cartesian3.fromElements(o.z,o.x,o.y,o);var s=Te.eastNorthUpToFixedFrame(n,a,lt),l=P.Matrix4.inverseTransformation(s,ut),u=P.Matrix4.getMatrix3(t,st),d=P.Matrix4.multiplyByMatrix3(l,u,r);return P.Matrix4.multiply(nt,d,r),P.Matrix4.setTranslation(r,o,r),r},Te.wgs84To2DModelMatrix=function(e,t,r){if(!S.defined(e))throw new T.DeveloperError("projection is required.");if(!S.defined(t))throw new T.DeveloperError("center is required.");if(!S.defined(r))throw new T.DeveloperError("result is required.");var n=e.ellipsoid,a=Te.eastNorthUpToFixedFrame(t,n,lt),i=P.Matrix4.inverseTransformation(a,ut),o=n.cartesianToCartographic(t,at),s=e.project(o,it);f.Cartesian3.fromElements(s.z,s.x,s.y,s);var l=P.Matrix4.fromTranslation(s,lt);return P.Matrix4.multiply(nt,i,r),P.Matrix4.multiply(l,r,r),r},Te.buildUp=function(e,t){var r=t.clone(),n=e.clone();n=f.Cartesian3.normalize(n,n),1<=Math.abs(f.Cartesian3.dot(n,r))&&(n=Math.abs(f.Cartesian3.dot(r,f.Cartesian3.UNIT_Y))<1?f.Cartesian3.clone(f.Cartesian3.UNIT_Y,n):f.Cartesian3.clone(f.Cartesian3.UNIT_Z,n));var a=new f.Cartesian3;return f.Cartesian3.cross(n,r,a),a=f.Cartesian3.normalize(a,a),f.Cartesian3.cross(r,a,n),n=f.Cartesian3.normalize(n,n)},Te.getHeading=function(e,t){var r;return r=g.CesiumMath.equalsEpsilon(Math.abs(e.z),1,g.CesiumMath.EPSILON3)?Math.atan2(t.y,t.x)-g.CesiumMath.PI_OVER_TWO:Math.atan2(e.y,e.x)-g.CesiumMath.PI_OVER_TWO,g.CesiumMath.TWO_PI-g.CesiumMath.zeroToTwoPi(r)},Te.convertToColumbusCartesian=function(e){var t=new P.GeographicProjection,r=t.ellipsoid,n=new f.Cartesian3,a=new f.Cartographic;return r.cartesianToCartographic(e,a),t.project(a,n),f.Cartesian3.fromElements(n.z,n.x,n.y)},Te.convertTo3DCartesian=function(e){var t=new P.GeographicProjection,r=t.ellipsoid,n=new f.Cartesian3,a=new f.Cartographic;return n=f.Cartesian3.fromElements(e.y,e.z,e.x),t.unproject(n,a),r.cartographicToCartesian(a,n)},e.Quaternion=w,e.Transforms=Te});