cesium-city3d/Build/Cesium/Workers/S3MBTilesParser.js

98 lines
165 KiB
JavaScript
Raw Permalink Normal View History

2020-08-03 18:04:41 +08:00
/**
* Cesium - https://github.com/AnalyticalGraphicsInc/cesium
*
* Copyright 2011-2017 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/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details.
*/
/**
@license
when.js - https://github.com/cujojs/when
MIT License (c) copyright B Cavalier & J Hann
* A lightweight CommonJS Promises/A and when() implementation
* when is part of the cujo.js family of libraries (http://cujojs.com/)
*
* Licensed under the MIT License at:
* http://www.opensource.org/licenses/mit-license.php
*
* @version 1.7.1
*/
/**
@license
mersenne-twister.js - https://gist.github.com/banksean/300494
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The names of its contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*! @brief Decompresses an image in memory.
@param rgba Storage for the decompressed pixels.
@param width The width of the source image.
@param height The height of the source image.
@param blocks The compressed DXT blocks.
@param flags Compression flags.
The decompressed pixels will be written as a contiguous array of width*height
16 rgba values, with each component as 1 byte each. In memory this is:
{ r1, g1, b1, a1, .... , rn, gn, bn, an } for n = width*height
The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression,
however, DXT1 will be used by default if none is specified. All other flags
are ignored.
Internally this function calls squish::Decompress for each block.
*/
!function(){!function(e){"use strict";e("ThirdParty/when",[],function(){function e(e,r,n,a){return t(e).then(r,n,a)}function t(e){var t,r;return e instanceof n?t=e:u(e)?(r=o(),e.then(function(e){r.resolve(e)},function(e){r.reject(e)},function(e){r.progress(e)}),t=r.promise):t=a(e),t}function r(t){return e(t,i)}function n(e){this.then=e}function a(e){var r=new n(function(r){try{return t(r?r(e):e)}catch(n){return i(n)}});return r}function i(e){var r=new n(function(r,n){try{return n?t(n(e)):i(e)}catch(a){return i(a)}});return r}function o(){function e(e,t,r){return l(e,t,r)}function r(e){return d(e)}function a(e){return d(i(e))}function u(e){return y(e)}var s,c,f,E,l,y,d;return c=new n(e),s={then:e,resolve:r,reject:a,progress:u,promise:c,resolver:{resolve:r,reject:a,progress:u}},f=[],E=[],l=function(e,t,r){var n,a;return n=o(),a="function"==typeof r?function(e){try{n.progress(r(e))}catch(t){n.progress(t)}}:function(e){n.progress(e)},f.push(function(r){r.then(e,t).then(n.resolve,n.reject,a)}),E.push(a),n.promise},y=function(e){return _(E,e),e},d=function(e){return e=t(e),l=e.then,d=t,y=p,_(f,e),E=f=A,e},s}function u(e){return e&&"function"==typeof e.then}function s(t,r,n,a,i){return h(2,arguments),e(t,function(t){function u(e){_(e)}function s(e){d(e)}var c,f,E,l,y,d,_,h,T,O;if(T=t.length>>>0,c=Math.max(0,Math.min(r,T)),E=[],f=T-c+1,l=[],y=o(),c)for(h=y.progress,_=function(e){l.push(e),--f||(d=_=p,y.reject(l))},d=function(e){E.push(e),--c||(d=_=p,y.resolve(E))},O=0;T>O;++O)O in t&&e(t[O],s,u,h);else y.resolve(E);return y.then(n,a,i)})}function c(e,t,r,n){function a(e){return t?t(e[0]):e[0]}return s(e,1,a,r,n)}function f(e,t,r,n){return h(1,arguments),l(e,T).then(t,r,n)}function E(){return l(arguments,T)}function l(t,r){return e(t,function(t){var n,a,i,u,s,c;if(i=a=t.length>>>0,n=[],c=o(),i)for(u=function(t,a){e(t,r).then(function(e){n[a]=e,--i||c.resolve(n)},c.reject)},s=0;a>s;s++)s in t?u(t[s],s):--i;else c.resolve(n);return c.promise})}function y(t,r){var n=m.call(arguments,1);return e(t,function(t){var a;return a=t.length,n[0]=function(t,n,i){return e(t,function(t){return e(n,function(e){return r(t,e,i,a)})})},O.apply(t,n)})}function d(t,r,n){var a=arguments.length>2;return e(t,function(e){return e=a?n:e,r.resolve(e),e},function(e){return r.reject(e),i(e)},r.progress)}function _(e,t){for(var r,n=0;r=e[n++];)r(t)}function h(e,t){for(var r,n=t.length;n>e;)if(r=t[--n],null!=r&&"function"!=typeof r)throw new Error("arg "+n+" must be a function")}function p(){}function T(e){return e}var O,m,A;return e.defer=o,e.resolve=t,e.reject=r,e.join=E,e.all=f,e.map=l,e.reduce=y,e.any=c,e.some=s,e.chain=d,e.isPromise=u,n.prototype={always:function(e,t){return this.then(e,e,t)},otherwise:function(e){return this.then(A,e)},"yield":function(e){return this.then(function(){return e})},spread:function(e){return this.then(function(t){return f(t,function(t){return e.apply(A,t)})})}},m=[].slice,O=[].reduce||function(e){var t,r,n,a,i;if(i=0,t=Object(this),a=t.length>>>0,r=arguments,r.length<=1)for(;;){if(i in t){n=t[i++];break}if(++i>=a)throw new TypeError}else n=r[1];for(;a>i;++i)i in t&&(n=e(n,t[i],i,t));return n},e})}("function"==typeof define&&define.amd?define:function(e){"object"==typeof exports?module.exports=e():this.when=e()}),define("Core/defined",[],function(){"use strict";function e(e){return void 0!==e&&null!==e}return e}),define("Core/freezeObject",["./defined"],function(e){"use strict";var t=Object.freeze;return e(t)||(t=function(e){return e}),t}),define("Core/defaultValue",["./freezeObject"],function(e){"use strict";function t(e,t){return void 0!==e&&null!==e?e:t}return t.EMPTY_OBJECT=e({}),t}),define("Core/formatError",["./defined"],function(e){"use strict";function t(t){var r,n=t.name,a=t.message;r=e(n)&&e(a)?n+": "+a:t.toString();var i=t.stack;return e(i)&&(r+="\n"+i),r}return t}),define("Workers/createTaskProcessorWorker",["../ThirdParty/when","../Core/defaultValue","../Core/defined","../Core/formatError"],function(e,t,r,n){"use strict";function a(t,r,n){var a;try{return a=t(r,n)}catch(i){return e.reject(i)}}function i(i){var o;
t.typeOf.number.greaterThanOrEquals("index",r,0),t.typeOf.number.lessThanOrEquals("index",r,2),t.typeOf.object("cartesian",n),t.typeOf.object("result",a),a=s.clone(e,a);var i=3*r;return a[i]=n.x,a[i+1]=n.y,a[i+2]=n.z,a},s.getRow=function(e,r,n){t.typeOf.object("matrix",e),t.typeOf.number.greaterThanOrEquals("index",r,0),t.typeOf.number.lessThanOrEquals("index",r,2),t.typeOf.object("result",n);var a=e[r],i=e[r+3],o=e[r+6];return n.x=a,n.y=i,n.z=o,n},s.setRow=function(e,r,n,a){return t.typeOf.object("matrix",e),t.typeOf.number.greaterThanOrEquals("index",r,0),t.typeOf.number.lessThanOrEquals("index",r,2),t.typeOf.object("cartesian",n),t.typeOf.object("result",a),a=s.clone(e,a),a[r]=n.x,a[r+3]=n.y,a[r+6]=n.z,a};var l=new e;s.getScale=function(r,n){return t.typeOf.object("matrix",r),t.typeOf.object("result",n),n.x=e.magnitude(e.fromElements(r[0],r[1],r[2],l)),n.y=e.magnitude(e.fromElements(r[3],r[4],r[5],l)),n.z=e.magnitude(e.fromElements(r[6],r[7],r[8],l)),n};var y=new e;s.getMaximumScale=function(t){return s.getScale(t,y),e.maximumComponent(y)},s.multiply=function(e,r,n){t.typeOf.object("left",e),t.typeOf.object("right",r),t.typeOf.object("result",n);var a=e[0]*r[0]+e[3]*r[1]+e[6]*r[2],i=e[1]*r[0]+e[4]*r[1]+e[7]*r[2],o=e[2]*r[0]+e[5]*r[1]+e[8]*r[2],u=e[0]*r[3]+e[3]*r[4]+e[6]*r[5],s=e[1]*r[3]+e[4]*r[4]+e[7]*r[5],c=e[2]*r[3]+e[5]*r[4]+e[8]*r[5],f=e[0]*r[6]+e[3]*r[7]+e[6]*r[8],E=e[1]*r[6]+e[4]*r[7]+e[7]*r[8],l=e[2]*r[6]+e[5]*r[7]+e[8]*r[8];return n[0]=a,n[1]=i,n[2]=o,n[3]=u,n[4]=s,n[5]=c,n[6]=f,n[7]=E,n[8]=l,n},s.add=function(e,r,n){return t.typeOf.object("left",e),t.typeOf.object("right",r),t.typeOf.object("result",n),n[0]=e[0]+r[0],n[1]=e[1]+r[1],n[2]=e[2]+r[2],n[3]=e[3]+r[3],n[4]=e[4]+r[4],n[5]=e[5]+r[5],n[6]=e[6]+r[6],n[7]=e[7]+r[7],n[8]=e[8]+r[8],n},s.subtract=function(e,r,n){return t.typeOf.object("left",e),t.typeOf.object("right",r),t.typeOf.object("result",n),n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],n[3]=e[3]-r[3],n[4]=e[4]-r[4],n[5]=e[5]-r[5],n[6]=e[6]-r[6],n[7]=e[7]-r[7],n[8]=e[8]-r[8],n},s.multiplyByVector=function(e,r,n){t.typeOf.object("matrix",e),t.typeOf.object("cartesian",r),t.typeOf.object("result",n);var a=r.x,i=r.y,o=r.z,u=e[0]*a+e[3]*i+e[6]*o,s=e[1]*a+e[4]*i+e[7]*o,c=e[2]*a+e[5]*i+e[8]*o;return n.x=u,n.y=s,n.z=c,n},s.multiplyByScalar=function(e,r,n){return t.typeOf.object("matrix",e),t.typeOf.number("scalar",r),t.typeOf.object("result",n),n[0]=e[0]*r,n[1]=e[1]*r,n[2]=e[2]*r,n[3]=e[3]*r,n[4]=e[4]*r,n[5]=e[5]*r,n[6]=e[6]*r,n[7]=e[7]*r,n[8]=e[8]*r,n},s.multiplyByScale=function(e,r,n){return t.typeOf.object("matrix",e),t.typeOf.object("scale",r),t.typeOf.object("result",n),n[0]=e[0]*r.x,n[1]=e[1]*r.x,n[2]=e[2]*r.x,n[3]=e[3]*r.y,n[4]=e[4]*r.y,n[5]=e[5]*r.y,n[6]=e[6]*r.z,n[7]=e[7]*r.z,n[8]=e[8]*r.z,n},s.negate=function(e,r){return t.typeOf.object("matrix",e),t.typeOf.object("result",r),r[0]=-e[0],r[1]=-e[1],r[2]=-e[2],r[3]=-e[3],r[4]=-e[4],r[5]=-e[5],r[6]=-e[6],r[7]=-e[7],r[8]=-e[8],r},s.transpose=function(e,r){t.typeOf.object("matrix",e),t.typeOf.object("result",r);var n=e[0],a=e[3],i=e[6],o=e[1],u=e[4],s=e[7],c=e[2],f=e[5],E=e[8];return r[0]=n,r[1]=a,r[2]=i,r[3]=o,r[4]=u,r[5]=s,r[6]=c,r[7]=f,r[8]=E,r};var d=[1,0,0],_=[2,2,1],h=new s,p=new s;return s.computeEigenDecomposition=function(e,r){t.typeOf.object("matrix",e);var a=u.EPSILON20,i=10,o=0,l=0;n(r)||(r={});for(var y=r.unitary=s.clone(s.IDENTITY,r.unitary),d=r.diagonal=s.clone(e,r.diagonal),_=a*c(d);i>l&&f(d)>_;)E(d,h),s.transpose(h,p),s.multiply(d,h,d),s.multiply(p,d,d),s.multiply(y,h,y),++o>2&&(++l,o=0);return r},s.abs=function(e,r){return t.typeOf.object("matrix",e),t.typeOf.object("result",r),r[0]=Math.abs(e[0]),r[1]=Math.abs(e[1]),r[2]=Math.abs(e[2]),r[3]=Math.abs(e[3]),r[4]=Math.abs(e[4]),r[5]=Math.abs(e[5]),r[6]=Math.abs(e[6]),r[7]=Math.abs(e[7]),r[8]=Math.abs(e[8]),r},s.determinant=function(e){t.typeOf.object("matrix",e);var r=e[0],n=e[3],a=e[6],i=e[1],o=e[4],u=e[7],s=e[2],c=e[5],f=e[8];return r*(o*f-c*u)+i*(c*a-n*f)+s*(n*u-o*a)},s.inverse=function(e,r){t.typeOf.object("matrix",e),t.typeOf.object("result",r);var n=e[0],a=e[1],o=e[2],c=e[3],f=e[4
},a.requestFullscreen=function(e,t){a.supportsFullscreen()&&e[n.requestFullscreen]({vrDisplay:t})},a.exitFullscreen=function(){a.supportsFullscreen()&&document[n.exitFullscreen]()},a}),define("Core/FeatureDetection",["./defaultValue","./defined","./Fullscreen","./RuntimeError","../ThirdParty/when"],function(e,t,r,n,a){"use strict";function i(e){for(var t=e.split("."),r=0,n=t.length;n>r;++r)t[r]=parseInt(t[r],10);return t}function o(){if(!t(v)&&(v=!1,!d())){var e=/ Chrome\/([\.0-9]+)/.exec(g.userAgent);null!==e&&(v=!0,I=i(e[1]))}return v}function u(){return o()&&I}function s(){if(!t(M)&&(M=!1,!o()&&!d()&&/ Safari\/[\.0-9]+/.test(g.userAgent))){var e=/ Version\/([\.0-9]+)/.exec(g.userAgent);null!==e&&(M=!0,w=i(e[1]))}return M}function c(){return s()&&w}function f(){if(!t(x)){x=!1;var e=/ AppleWebKit\/([\.0-9]+)(\+?)/.exec(g.userAgent);null!==e&&(x=!0,C=i(e[1]),C.isNightly=!!e[2])}return x}function E(){return f()&&C}function l(){if(!t(P)){P=!1;var e;"Microsoft Internet Explorer"===g.appName?(e=/MSIE ([0-9]{1,}[\.0-9]{0,})/.exec(g.userAgent),null!==e&&(P=!0,L=i(e[1]))):"Netscape"===g.appName&&(e=/Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/.exec(g.userAgent),null!==e&&(P=!0,L=i(e[1])))}return P}function y(){return l()&&L}function d(){if(!t(U)){U=!1;var e=/ Edge\/([\.0-9]+)/.exec(g.userAgent);null!==e&&(U=!0,B=i(e[1]))}return U}function _(){return d()&&B}function h(){if(!t(F)){F=!1;var e=/Firefox\/([\.0-9]+)/.exec(g.userAgent);null!==e&&(F=!0,D=i(e[1]))}return F}function p(){return t(j)||(j=/Windows/i.test(g.appVersion)),j}function T(){return h()&&D}function O(){return t(z)||(z="object"==typeof process&&"[object process]"===Object.prototype.toString.call(process)),z}function m(){return t(G)||(G=!h()&&"undefined"!=typeof PointerEvent&&(!t(g.pointerEnabled)||g.pointerEnabled)),G}function A(){if(!t(q)){var e=document.createElement("canvas");e.setAttribute("style","image-rendering: -moz-crisp-edges;image-rendering: pixelated;");var r=e.style.imageRendering;q=t(r)&&""!==r,q&&(V=r)}return q}function R(){return A()?V:void 0}function b(){if(t(Y))return Y.promise;Y=a.defer(),d()&&(k=!1,Y.resolve(k));var e=new Image;return e.onload=function(){k=e.width>0&&e.height>0,Y.resolve(k)},e.onerror=function(){k=!1,Y.resolve(k)},e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",Y.promise}function N(){return t(Y)||b(),k}function S(){var e=window.navigator.userAgent.toLowerCase(),t="ipad"==e.match(/ipad/i),r="iphone os"==e.match(/iphone os/i),n="midp"==e.match(/midp/i),a="rv:1.2.3.4"==e.match(/rv:1.2.3.4/i),i="ucweb"==e.match(/ucweb/i),o="android"==e.match(/android/i),u="windows ce"==e.match(/windows ce/i),s="windows mobile"==e.match(/windows mobile/i);return t||r||n||a||i||o||u||s?!1:!0}var g;g="undefined"!=typeof navigator?navigator:{};var v,I,M,w,x,C,P,L,U,B,F,D,j,z,G,V,q,k,Y,X=[];"undefined"!=typeof ArrayBuffer&&(X.push(Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array),"undefined"!=typeof Uint8ClampedArray&&X.push(Uint8ClampedArray),"undefined"!=typeof CanvasPixelArray&&X.push(CanvasPixelArray));var H={isChrome:o,chromeVersion:u,isSafari:s,safariVersion:c,isWebkit:f,webkitVersion:E,isInternetExplorer:l,internetExplorerVersion:y,isEdge:d,edgeVersion:_,isFirefox:h,firefoxVersion:T,isWindows:p,isNodeJs:O,hardwareConcurrency:e(g.hardwareConcurrency,3),supportsPointerEvents:m,supportsImageRenderingPixelated:A,supportsWebP:b,supportsWebPSync:N,imageRenderingValue:R,typedArrayTypes:X,isPCBroswer:S};return H.supportsFullscreen=function(){return r.supportsFullscreen()},H.supportsTypedArrays=function(){return"undefined"!=typeof ArrayBuffer},H.supportsWebWorkers=function(){return"undefined"!=typeof Worker},H.supportsWebAssembly=function(){return"undefined"!=typeof WebAssembly&&!H.isEdge()},H}),define("Core/WebGLConstants",["./freezeObject"],function(e){"use strict";var t={DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_AL
s.expand=function(e,r,a){return t.typeOf.object("rectangle",e),t.typeOf.object("cartographic",r),n(a)||(a=new s),a.west=Math.min(e.west,r.longitude),a.south=Math.min(e.south,r.latitude),a.east=Math.max(e.east,r.longitude),a.north=Math.max(e.north,r.latitude),a},s.contains=function(e,r){t.typeOf.object("rectangle",e),t.typeOf.object("cartographic",r);var n=r.longitude,a=r.latitude,i=e.west,o=e.east;return i>o&&(o+=u.TWO_PI,0>n&&(n+=u.TWO_PI)),(n>i||u.equalsEpsilon(n,i,u.EPSILON14))&&(o>n||u.equalsEpsilon(n,o,u.EPSILON14))&&a>=e.south&&a<=e.north};var c=new e;return s.subsample=function(e,a,o,f){t.typeOf.object("rectangle",e),a=r(a,i.WGS84),o=r(o,0),n(f)||(f=[]);var E=0,l=e.north,y=e.south,d=e.east,_=e.west,h=c;h.height=o,h.longitude=_,h.latitude=l,f[E]=a.cartographicToCartesian(h,f[E]),E++,h.longitude=d,f[E]=a.cartographicToCartesian(h,f[E]),E++,h.latitude=y,f[E]=a.cartographicToCartesian(h,f[E]),E++,h.longitude=_,f[E]=a.cartographicToCartesian(h,f[E]),E++,0>l?h.latitude=l:y>0?h.latitude=y:h.latitude=0;for(var p=1;8>p;++p)h.longitude=-Math.PI+p*u.PI_OVER_TWO,s.contains(e,h)&&(f[E]=a.cartographicToCartesian(h,f[E]),E++);return 0===h.latitude&&(h.longitude=_,f[E]=a.cartographicToCartesian(h,f[E]),E++,h.longitude=d,f[E]=a.cartographicToCartesian(h,f[E]),E++),f.length=E,f},s.MAX_VALUE=o(new s(-Math.PI,-u.PI_OVER_TWO,Math.PI,u.PI_OVER_TWO)),s}),define("Core/BoundingSphere",["./Cartesian3","./Cartographic","./Check","./defaultValue","./defined","./Ellipsoid","./GeographicProjection","./Intersect","./Interval","./Math","./Matrix3","./Matrix4","./Rectangle"],function(e,t,r,n,a,i,o,u,s,c,f,E,l){"use strict";function y(t,r){this.center=e.clone(n(t,e.ZERO)),this.radius=n(r,0)}var d=new e,_=new e,h=new e,p=new e,T=new e,O=new e,m=new e,A=new e,R=new e,b=new e,N=new e,S=new e,g=4/3*c.PI;y.fromPoints=function(t,r){if(a(r)||(r=new y),!a(t)||0===t.length)return r.center=e.clone(e.ZERO,r.center),r.radius=0,r;var n,i=e.clone(t[0],m),o=e.clone(i,d),u=e.clone(i,_),s=e.clone(i,h),c=e.clone(i,p),f=e.clone(i,T),E=e.clone(i,O),l=t.length;for(n=1;l>n;n++){e.clone(t[n],i);var g=i.x,v=i.y,I=i.z;g<o.x&&e.clone(i,o),g>c.x&&e.clone(i,c),v<u.y&&e.clone(i,u),v>f.y&&e.clone(i,f),I<s.z&&e.clone(i,s),I>E.z&&e.clone(i,E)}var M=e.magnitudeSquared(e.subtract(c,o,A)),w=e.magnitudeSquared(e.subtract(f,u,A)),x=e.magnitudeSquared(e.subtract(E,s,A)),C=o,P=c,L=M;w>L&&(L=w,C=u,P=f),x>L&&(L=x,C=s,P=E);var U=R;U.x=.5*(C.x+P.x),U.y=.5*(C.y+P.y),U.z=.5*(C.z+P.z);var B=e.magnitudeSquared(e.subtract(P,U,A)),F=Math.sqrt(B),D=b;D.x=o.x,D.y=u.y,D.z=s.z;var j=N;j.x=c.x,j.y=f.y,j.z=E.z;var z=e.midpoint(D,j,S),G=0;for(n=0;l>n;n++){e.clone(t[n],i);var V=e.magnitude(e.subtract(i,z,A));V>G&&(G=V);var q=e.magnitudeSquared(e.subtract(i,U,A));if(q>B){var k=Math.sqrt(q);F=.5*(F+k),B=F*F;var Y=k-F;U.x=(F*U.x+Y*i.x)/k,U.y=(F*U.y+Y*i.y)/k,U.z=(F*U.z+Y*i.z)/k}}return G>F?(e.clone(U,r.center),r.radius=F):(e.clone(z,r.center),r.radius=G),r};var v=new o,I=new e,M=new e,w=new t,x=new t;y.fromRectangle2D=function(e,t,r){return y.fromRectangleWithHeights2D(e,t,0,0,r)},y.fromRectangleWithHeights2D=function(t,r,i,o,u){if(a(u)||(u=new y),!a(t))return u.center=e.clone(e.ZERO,u.center),u.radius=0,u;r=n(r,v),l.southwest(t,w),w.height=i,l.northeast(t,x),x.height=o;var s=r.project(w,I),c=r.project(x,M),f=c.x-s.x,E=c.y-s.y,d=c.z-s.z;u.radius=.5*Math.sqrt(f*f+E*E+d*d);var _=u.center;return _.x=s.x+.5*f,_.y=s.y+.5*E,_.z=s.z+.5*d,u};var C=[];y.fromRectangle3D=function(t,r,o,u){if(r=n(r,i.WGS84),o=n(o,0),a(u)||(u=new y),!a(t))return u.center=e.clone(e.ZERO,u.center),u.radius=0,u;var s=l.subsample(t,r,o,C);return y.fromPoints(s,u)},y.fromVertices=function(t,i,o,u){if(a(u)||(u=new y),!a(t)||0===t.length)return u.center=e.clone(e.ZERO,u.center),u.radius=0,u;i=n(i,e.ZERO),o=n(o,3),r.typeOf.number.greaterThanOrEquals("stride",o,3);var s=m;s.x=t[0]+i.x,s.y=t[1]+i.y,s.z=t[2]+i.z;var c,f=e.clone(s,d),E=e.clone(s,_),l=e.clone(s,h),g=e.clone(s,p),v=e.clone(s,T),I=e.clone(s,O),M=t.length;for(c=0;M>c;c+=o){var w=t[c]+i.x,x=t[c+1]+i.y,C=t[c+2]+i.z;s.x=w,s.y=x,s.z=C,w<f.x&&e.clone(s,f),w>g.x&&e.clone(s,g),x<E.y&&e.clone
i++)),s+=128>r?1:2048>r?2:65536>r?3:4;for(t=new a.Buf8(s),o=0,i=0;s>o;i++)r=e.charCodeAt(i),55296===(64512&r)&&u>i+1&&(n=e.charCodeAt(i+1),56320===(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),128>r?t[o++]=r:2048>r?(t[o++]=192|r>>>6,t[o++]=128|63&r):65536>r?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},r.buf2binstring=function(e){return n(e,e.length)},r.binstring2buf=function(e){for(var t=new a.Buf8(e.length),r=0,n=t.length;n>r;r++)t[r]=e.charCodeAt(r);return t},r.buf2string=function(e,t){var r,a,i,o,u=t||e.length,c=new Array(2*u);for(a=0,r=0;u>r;)if(i=e[r++],128>i)c[a++]=i;else if(o=s[i],o>4)c[a++]=65533,r+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&u>r;)i=i<<6|63&e[r++],o--;o>1?c[a++]=65533:65536>i?c[a++]=i:(i-=65536,c[a++]=55296|i>>10&1023,c[a++]=56320|1023&i)}return n(c,a)},r.utf8border=function(e,t){var r;for(t=t||e.length,t>e.length&&(t=e.length),r=t-1;r>=0&&128===(192&e[r]);)r--;return 0>r?t:0===r?t:r+s[e[r]]>t?r:t}},{"./common":1}],3:[function(e,t,r){"use strict";function n(e,t,r,n){for(var a=65535&e|0,i=e>>>16&65535|0,o=0;0!==r;){o=r>2e3?2e3:r,r-=o;do a=a+t[n++]|0,i=i+a|0;while(--o);a%=65521,i%=65521}return a|i<<16|0}t.exports=n},{}],4:[function(e,t,r){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(e,t,r){"use strict";function n(){for(var e,t=[],r=0;256>r;r++){e=r;for(var n=0;8>n;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}function a(e,t,r,n){var a=i,o=n+r;e^=-1;for(var u=n;o>u;u++)e=e>>>8^a[255&(e^t[u])];return-1^e}var i=n();t.exports=a},{}],6:[function(e,t,r){"use strict";function n(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}t.exports=n},{}],7:[function(e,t,r){"use strict";var n=30,a=12;t.exports=function(e,t){var r,i,o,u,s,c,f,E,l,y,d,_,h,p,T,O,m,A,R,b,N,S,g,v,I;r=e.state,i=e.next_in,v=e.input,o=i+(e.avail_in-5),u=e.next_out,I=e.output,s=u-(t-e.avail_out),c=u+(e.avail_out-257),f=r.dmax,E=r.wsize,l=r.whave,y=r.wnext,d=r.window,_=r.hold,h=r.bits,p=r.lencode,T=r.distcode,O=(1<<r.lenbits)-1,m=(1<<r.distbits)-1;e:do{15>h&&(_+=v[i++]<<h,h+=8,_+=v[i++]<<h,h+=8),A=p[_&O];t:for(;;){if(R=A>>>24,_>>>=R,h-=R,R=A>>>16&255,0===R)I[u++]=65535&A;else{if(!(16&R)){if(0===(64&R)){A=p[(65535&A)+(_&(1<<R)-1)];continue t}if(32&R){r.mode=a;break e}e.msg="invalid literal/length code",r.mode=n;break e}b=65535&A,R&=15,R&&(R>h&&(_+=v[i++]<<h,h+=8),b+=_&(1<<R)-1,_>>>=R,h-=R),15>h&&(_+=v[i++]<<h,h+=8,_+=v[i++]<<h,h+=8),A=T[_&m];r:for(;;){if(R=A>>>24,_>>>=R,h-=R,R=A>>>16&255,!(16&R)){if(0===(64&R)){A=T[(65535&A)+(_&(1<<R)-1)];continue r}e.msg="invalid distance code",r.mode=n;break e}if(N=65535&A,R&=15,R>h&&(_+=v[i++]<<h,h+=8,R>h&&(_+=v[i++]<<h,h+=8)),N+=_&(1<<R)-1,N>f){e.msg="invalid distance too far back",r.mode=n;break e}if(_>>>=R,h-=R,R=u-s,N>R){if(R=N-R,R>l&&r.sane){e.msg="invalid distance too far back",r.mode=n;break e}if(S=0,g=d,0===y){if(S+=E-R,b>R){b-=R;do I[u++]=d[S++];while(--R);S=u-N,g=I}}else if(R>y){if(S+=E+y-R,R-=y,b>R){b-=R;do I[u++]=d[S++];while(--R);if(S=0,b>y){R=y,b-=R;do I[u++]=d[S++];while(--R);S=u-N,g=I}}}else if(S+=y-R,b>R){b-=R;do I[u++]=d[S++];while(--R);S=u-N,g=I}for(;b>2;)I[u++]=g[S++],I[u++]=g[S++],I[u++]=g[S++],b-=3;b&&(I[u++]=g[S++],b>1&&(I[u++]=g[S++]))}else{S=u-N;do I[u++]=I[S++],I[u++]=I[S++],I[u++]=I[S++],b-=3;while(b>2);b&&(I[u++]=I[S++],b>1&&(I[u++]=I[S++]))}break}}break}}while(o>i&&c>u);b=h>>3,i-=b,h-=b<<3,_&=(1<<h)-1,e.next_in=i,e.next_out=u,e.avail_in=o>i?5+(o-i):5-(i-o),e.avail_out=c>u?257+(c-u):257-(u-c),r.hold=_,r.bits=h}},{}],8:[function(e,t,r){"use strict";function n(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}
o=s.bytesOffset):(s=O(t,e,o,r,a,i),o=s.bytesOffset),(u&l.SVC_TexutreCoordIsW)==l.SVC_TexutreCoordIsW&&(a.textureCoordIsW=!0),s=A(t,e,o,r,a),o=s.bytesOffset,{bytesOffset:o}}function w(e,t,r,n,a,i){var o,u=n;return o=R(e,t,r,u,a),u=o.bytesOffset,o=N(e,t,r,u,a),u=o.bytesOffset,o=g(e,t,r,u,a),u=o.bytesOffset,o=v(e,t,r,u,a),u=o.bytesOffset,o=O(t,e,u,r,a,i),u=o.bytesOffset,o=A(t,e,u,r,a),u=o.bytesOffset,{bytesOffset:u}}function x(e){return 0===e.length?!1:e[0].materialCode===q}function C(e,t,r,n,a,i){var o=e,u=0,s=t.getUint32(u+r,!0);u+=Uint32Array.BYTES_PER_ELEMENT;for(var c=0;s>c;c++){var f=T(t,r,o,u),l=f.string;u=f.bytesOffset;var y=u%4;0!==y&&(u+=4-y);var d=V.SV_Unkown;d=t.getUint32(u+r,!0),u+=Int32Array.BYTES_PER_ELEMENT;var _={};_.vertexAttributes=[],_.attrLocation={},_.instanceCount=0,_.instanceMode=0,_.instanceIndex=-1,_.ignoreNormal=a.ignoreNormal,d==V.SV_Standard?(f=w(o,t,r,u,_,i),u=f.bytesOffset):d==V.SV_Compressed&&(f=M(o,t,r,u,_,i),u=f.bytesOffset),f=I(o,t,r,u);var h=f.arrIndexPackage;x(h)&&(_.clampRegionEdge=!0);var p;n&&(p=E.createEdge(_,h)),u=f.bytesOffset,a[l]={vertexPackage:_,arrIndexPackage:h,edgeGeometry:p}}}function P(e,r,n,a){for(var i={},o=[],u=new t,s=e,c=0;16>c;c++)u[c]=r.getFloat64(n+a,!0),n+=Float64Array.BYTES_PER_ELEMENT;i.matrix=u,i.skeletonNames=o;var f=r.getUint32(n+a,!0);n+=Uint32Array.BYTES_PER_ELEMENT;for(var E=0;f>E;E++){var l=T(r,a,s,n),y=l.string;n=l.bytesOffset,o.push(y)}return{byteOffset:n,geode:i}}function L(e){var t=e.indexOf("Geometry");if(-1===t)return e;var r=e.substring(t,e.length);return e.replace(r,"")}function U(e,t,n,a){var i={},o=t.getFloat32(n+a,!0);n+=Float32Array.BYTES_PER_ELEMENT;var u=t.getUint16(n+a,!0);n+=Uint16Array.BYTES_PER_ELEMENT,i.rangeMode=u,i.rangeList=o;var s=new r;s.x=t.getFloat64(n+a,!0),n+=Float64Array.BYTES_PER_ELEMENT,s.y=t.getFloat64(n+a,!0),n+=Float64Array.BYTES_PER_ELEMENT,s.z=t.getFloat64(n+a,!0),n+=Float64Array.BYTES_PER_ELEMENT;var f=t.getFloat64(n+a,!0);n+=Float64Array.BYTES_PER_ELEMENT,i.boundingSphere=new c(s,f);var E=e,l=T(t,a,E,n),y=l.string;n=l.bytesOffset,y=y.replace(/(\.s3mbz)|(\.s3mb)/gi,""),y=L(y),i.childTile=y,i.geodes=[];var d=t.getUint32(n+a,!0);n+=Uint32Array.BYTES_PER_ELEMENT;for(var _=0;d>_;_++){var l=P(e,t,n,a);n=l.byteOffset,i.geodes.push(l.geode)}return{pageLOD:i,bytesOffset:n}}function B(e,t,r){var n=0,a={},i=[],o=t.getUint32(n+r,!0);n+=Uint32Array.BYTES_PER_ELEMENT;for(var u=0;o>u;u++){var s=U(e,t,n,r);n=s.bytesOffset,i.push(s.pageLOD)}return a.pageLods=i,a}function F(e,t,r,n,a,i){var o=0,u=r.getUint32(o+n,!0);o+=Uint32Array.BYTES_PER_ELEMENT;for(var s=0;u>s;s++){var c=T(r,n,t,o),E=c.string;o=c.bytesOffset;var l=o%4;0!==l&&(o+=4-l);r.getUint32(o+n,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var y=r.getUint32(o+n,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var h=r.getUint32(o+n,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var p=r.getUint32(o+n,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var O=r.getUint32(o+n,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var m=r.getUint32(o+n,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var A=t.subarray(o,o+O);o+=O;var R=null;p===_.enrS3TCDXTN&&1!=e?(f.decode(R,y,h,A,m),R=m>d.BGR||m===d.LUMINANCE_ALPHA?new Uint8Array(y*h*4):new Uint16Array(y*h),f.decode(R,y,h,A,m),i.push(R.buffer),p=0):R=A,a[E]={id:E,width:y,height:h,compressType:p,nFormat:m,imageBuffer:R}}}function D(e,t,r,n){var a=0,i=e,o=t.getUint32(a+r,!0);a+=Uint32Array.BYTES_PER_ELEMENT;for(var u=0;o>u;u++){var s=T(t,r,i,a),c=s.string;a=s.bytesOffset;var f=t.getUint32(a+r,!0);a+=Uint32Array.BYTES_PER_ELEMENT;var E={};n[c].pickInfo=E;var l=n[c].vertexPackage.instanceIndex;if(-1==l)for(var y=0;f>y;y++){var d=t.getUint32(a+r,!0);a+=Uint32Array.BYTES_PER_ELEMENT;var _=t.getUint32(a+r,!0);a+=Uint32Array.BYTES_PER_ELEMENT;for(var h=[],p=0;_>p;p++){var O=t.getUint32(a+r,!0);a+=Uint32Array.BYTES_PER_ELEMENT;var m=t.getUint32(a+r,!0);a+=Uint32Array.BYTES_PER_ELEMENT,h.push({vertexColorOffset:O,vertexColorCount:m})}E[d]=h}else for(var y=0;f>y;y++){var d=t.getUint32(a+r,!0);a+=Uint32Array.BYTES_PER_ELEMENT;var _=t.getUint32(a+r,!0);a+=Uint32Array.BYTES_PER_ELEMENT;for(var h=[],p=0;_>p;p++){var O=t.