74 lines
39 KiB
JavaScript
74 lines
39 KiB
JavaScript
|
|
/**
|
||
|
|
* 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
|
||
|
|
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.
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
@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
|
||
|
|
*/
|
||
|
|
|
||
|
|
!function(){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 r=Object.freeze;return e(r)||(r=function(e){return e}),r}),define("Core/defaultValue",["./freezeObject"],function(e){"use strict";function r(e,r){return void 0!==e&&null!==e?e:r}return r.EMPTY_OBJECT=e({}),r}),define("Core/DeveloperError",["./defined"],function(e){"use strict";function r(e){this.name="DeveloperError",this.message=e;var r;try{throw new Error}catch(e){r=e.stack}this.stack=r}return e(Object.create)&&(r.prototype=Object.create(Error.prototype),r.prototype.constructor=r),r.prototype.toString=function(){var r=this.name+": "+this.message;return e(this.stack)&&(r+="\n"+this.stack.toString()),r},r.throwInstantiationError=function(){throw new r("This function defines an interface and should not be called directly.")},r}),define("Core/defineProperties",["./defined"],function(e){"use strict";var r=function(){try{return"x"in Object.defineProperty({},"x",{})}catch(e){return!1}}(),t=Object.defineProperties;return r&&e(t)||(t=function(e){return e}),t}),define("Core/Fullscreen",["./defined","./defineProperties"],function(e,r){"use strict";var t,E={requestFullscreen:void 0,exitFullscreen:void 0,fullscreenEnabled:void 0,fullscreenElement:void 0,fullscreenchange:void 0,fullscreenerror:void 0},n={};return r(n,{element:{get:function(){if(n.supportsFullscreen())return document[E.fullscreenElement]}},changeEventName:{get:function(){if(n.supportsFullscreen())return E.fullscreenchange}},errorEventName:{get:function(){if(n.supportsFullscreen())return E.fullscreenerror}},enabled:{get:function(){if(n.supportsFullscreen())return document[E.fullscreenEnabled]}},fullscreen:{get:function(){if(n.supportsFullscreen())return null!==n.element}}}),n.supportsFullscreen=function(){if(e(t))return t;t=!1;var r=document.body;if("function"==typeof r.requestFullscreen)return E.requestFullscreen="requestFullscreen",E.exitFullscreen="exitFullscreen",E.fullscreenEnabled="fullscreenEnabled",E.fullscreenElement="fullscreenElement",E.fullscreenchange="fullscreenchange",E.fullscreenerror="fullscreenerror",t=!0;for(var n,_=["webkit","moz","o","ms","khtml"],T=0,R=_.length;T<R;++T){var A=_[T];n=A+"RequestFullscreen","function"==typeof r[n]?(E.requestFullscreen=n,t=!0):(n=A+"RequestFullScreen","function"==typeof r[n]&&(E.requestFullscreen=n,t=!0)),n=A+"ExitFullscreen","function"==typeof document[n]?E.exitFullscreen=n:(n=A+"CancelFullScreen","function"==typeof document[n]&&(E.exitFullscreen=n)),n=A+"FullscreenEnabled",void 0!==document[n]?E.fullscreenEnabled=n:(n=A+"FullScreenEnabled",void 0!==document[n]&&(E.fullscreenEnabled=n)),n=A+"FullscreenElement",void 0!==document[n]?E.fullscreenElement=n:(n=A+"FullScreenElement",void 0!==document[n]&&(E.fullscreenElement=n)),n=A+"fullscreenchange",void 0!==document["on"+n]&&("ms"===A&&(n="MSFullscreenChange"),E.fullscreenchange=n),n=A+"fullscreenerror",void 0!==document["on"+n]&&("ms"===A&&(n="MSFullscreenError"),E.fullscreenerror=n)}return t},n.requestFullscreen=function(e,r){n.supportsFullscreen()&&e[E.requestFullscreen]({vrDisplay:r})},n.exitFullscreen=function(){n.supportsFullscreen()&&document[E.exitFullscreen]()},n}),define("Core/FeatureDetection",["./defaultValue","./defined","./Fullscreen"],function(e,r,t){"use strict";function E(e){for(var r=e.split("."),t=0,E=r.length;t<E;++t)r[t]=parseInt(r[t],10);return r}function n(){if(!r(F)&&(F=!1,!N())){var e=/ Chrome\/([\.0-9]+)/.exec(M.userAgent);null!==e&&(F=!0,U=E(e[1]))}return F}function _(){return n()&&U}function T(){if(!r(C)&&(C=!1,!n()&&!N()&&/ Safari\/[\.0-9]+/.test(M.userAgent))){var e=/ Version\/([\.0-9]+)/.exec(M.userAgent);null!==e&&(C=!0,D=E(e[1]))}return C}function R(){return T()&&D}function A(){if(!r(L)){L=!1;var e=/ AppleWebKit\/([\.0-9]+)(\+?)/.exec(M.userAgent);null!==e&&(L=!0,P=E(e[1]),P.isNightly=!!e[2])}return L}function o(){return A()&&P}function i(){if(!r(B)){B=!1;var e;"Microsoft Internet Explorer"===M.appName?null!==(e=/MSIE ([0-9]{1,}[\.0-9]{0,})/.exec(M.userAg
|
||
|
|
})})}},M=[].slice,f=[].reduce||function(e){var r,t,E,n,_;if(_=0,r=Object(this),n=r.length>>>0,t=arguments,t.length<=1)for(;;){if(_ in r){E=r[_++];break}if(++_>=n)throw new TypeError}else E=t[1];for(;_<n;++_)_ in r&&(E=e(E,r[_],_,r));return E},e})}("function"==typeof define&&define.amd?define:function(e){"object"==typeof exports?module.exports=e():this.when=e()}),define("Core/formatError",["./defined"],function(e){"use strict";function r(r){var t,E=r.name,n=r.message;t=e(E)&&e(n)?E+": "+n:r.toString();var _=r.stack;return e(_)&&(t+="\n"+_),t}return r}),define("Workers/createTaskProcessorWorker",["../ThirdParty/when","../Core/defaultValue","../Core/defined","../Core/formatError"],function(e,r,t,E){"use strict";function n(r,t,E){try{return r(t,E)}catch(r){return e.reject(r)}}function _(_){var T;return function(R){var A=R.data,o=[],i={id:A.id,result:void 0,error:void 0};return e(n(_,A.parameters,o)).then(function(e){i.result=e}).otherwise(function(e){e instanceof Error?i.error={name:e.name,message:e.message,stack:e.stack}:i.error=e}).always(function(){t(T)||(T=r(self.webkitPostMessage,self.postMessage)),A.canTransferArrayBuffer||(o.length=0);try{T(i,o)}catch(e){i.result=void 0,i.error="postMessage failed with error: "+E(e)+"\n with responseMessage: "+JSON.stringify(i),T(i)}})}}return _}),define("Workers/decodeDraco",["../Core/ComponentDatatype","../Core/defined","../Core/IndexDatatype","../Core/RuntimeError","./createTaskProcessorWorker"],function(e,r,t,E,n){"use strict";function _(e,r){for(var E=e.num_points(),n=e.num_faces(),_=new I.DracoInt32Array,T=3*n,R=t.createTypedArray(E,T),A=0,o=0;o<n;++o)r.GetFaceFromMesh(e,o,_),R[A+0]=_.GetValue(0),R[A+1]=_.GetValue(1),R[A+2]=_.GetValue(2),A+=3;return I.destroy(_),{typedArray:R,numberOfIndices:T}}function T(e,r,t,E,n){var _,T;E.quantizationBits<=8?(T=new I.DracoUInt8Array,_=new Uint8Array(n),r.GetAttributeUInt8ForAllPoints(e,t,T)):(T=new I.DracoUInt16Array,_=new Uint16Array(n),r.GetAttributeUInt16ForAllPoints(e,t,T));for(var R=0;R<n;++R)_[R]=T.GetValue(R);return I.destroy(T),_}function R(e,r,t,E){var n,_;switch(t.data_type()){case 1:case 11:_=new I.DracoInt8Array,n=new Int8Array(E),r.GetAttributeInt8ForAllPoints(e,t,_);break;case 2:_=new I.DracoUInt8Array,n=new Uint8Array(E),r.GetAttributeUInt8ForAllPoints(e,t,_);break;case 3:_=new I.DracoInt16Array,n=new Int16Array(E),r.GetAttributeInt16ForAllPoints(e,t,_);break;case 4:_=new I.DracoUInt16Array,n=new Uint16Array(E),r.GetAttributeUInt16ForAllPoints(e,t,_);break;case 5:case 7:_=new I.DracoInt32Array,n=new Int32Array(E),r.GetAttributeInt32ForAllPoints(e,t,_);break;case 6:case 8:_=new I.DracoUInt32Array,n=new Uint32Array(E),r.GetAttributeUInt32ForAllPoints(e,t,_);break;case 9:case 10:_=new I.DracoFloat32Array,n=new Float32Array(E),r.GetAttributeFloatForAllPoints(e,t,_)}for(var T=0;T<E;++T)n[T]=_.GetValue(T);return I.destroy(_),n}function A(t,E,n){var _,A=t.num_points(),o=n.num_components(),i=new I.AttributeQuantizationTransform;if(i.InitFromAttribute(n)){for(var u=new Array(o),N=0;N<o;++N)u[N]=i.min_value(N);_={quantizationBits:i.quantization_bits(),minValues:u,range:i.range(),octEncoded:!1}}I.destroy(i),i=new I.AttributeOctahedronTransform,i.InitFromAttribute(n)&&(_={quantizationBits:i.quantization_bits(),octEncoded:!0}),I.destroy(i);var a,s=A*o;a=r(_)?T(t,E,n,_,s):R(t,E,n,s);var S=e.fromTypedArray(a);return{array:a,data:{componentsPerAttribute:o,componentDatatype:S,byteOffset:n.byte_offset(),byteStride:e.getSizeInBytes(S)*o,normalized:n.normalized(),quantization:_}}}function o(e){var r=new I.Decoder;e.dequantizeInShader&&(r.SkipAttributeTransform(I.POSITION),r.SkipAttributeTransform(I.NORMAL));var t=new I.DecoderBuffer;if(t.Init(e.buffer,e.buffer.length),r.GetEncodedGeometryType(t)!==I.POINT_CLOUD)throw new E("Draco geometry type must be POINT_CLOUD.");var n=new I.PointCloud,_=r.DecodeBufferToPointCloud(t,n);if(!_.ok()||0===n.ptr)throw new E("Error decoding draco point cloud: "+_.error_msg());I.destroy(t);var T={},R=e.properties;for(var o in R)if(R.hasOwnProperty(o)){var i=R[o],u=r.GetAttributeByUniqueId(n,i);T[o]=A(n,r,u)}return
|