@xtctwins/tctwins-core
Version:
Web Programming Toolkit for 3D/2D BIM and CAD
1 lines • 2.07 MB
JavaScript
var e=r().mark(Vx),t=r().mark(ek);function i(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,s)}return i}function s(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?i(Object(s),!0).forEach((function(t){y(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):i(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */r=function(){return t};var e,t={},i=Object.prototype,s=i.hasOwnProperty,n=Object.defineProperty||function(e,t,i){e[t]=i.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",l=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function A(e,t,i){return Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{A({},"")}catch(e){A=function(e,t,i){return e[t]=i}}function c(e,t,i,s){var r=t&&t.prototype instanceof m?t:m,o=Object.create(r.prototype),a=new I(s||[]);return n(o,"_invoke",{value:k(e,i,a)}),o}function h(e,t,i){try{return{type:"normal",arg:e.call(t,i)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var d="suspendedStart",p="suspendedYield",f="executing",v="completed",g={};function m(){}function _(){}function y(){}var B={};A(B,a,(function(){return this}));var x=Object.getPrototypeOf,w=x&&x(x(S([])));w&&w!==i&&s.call(w,a)&&(B=w);var P=y.prototype=m.prototype=Object.create(B);function C(e){["next","throw","return"].forEach((function(t){A(e,t,(function(e){return this._invoke(t,e)}))}))}function M(e,t){function i(r,n,o,a){var l=h(e[r],e,n);if("throw"!==l.type){var u=l.arg,A=u.value;return A&&"object"==b(A)&&s.call(A,"__await")?t.resolve(A.__await).then((function(e){i("next",e,o,a)}),(function(e){i("throw",e,o,a)})):t.resolve(A).then((function(e){u.value=e,o(u)}),(function(e){return i("throw",e,o,a)}))}a(l.arg)}var r;n(this,"_invoke",{value:function(e,s){function n(){return new t((function(t,r){i(e,s,t,r)}))}return r=r?r.then(n,n):n()}})}function k(t,i,s){var r=d;return function(n,o){if(r===f)throw Error("Generator is already running");if(r===v){if("throw"===n)throw o;return{value:e,done:!0}}for(s.method=n,s.arg=o;;){var a=s.delegate;if(a){var l=F(a,s);if(l){if(l===g)continue;return l}}if("next"===s.method)s.sent=s._sent=s.arg;else if("throw"===s.method){if(r===d)throw r=v,s.arg;s.dispatchException(s.arg)}else"return"===s.method&&s.abrupt("return",s.arg);r=f;var u=h(t,i,s);if("normal"===u.type){if(r=s.done?v:p,u.arg===g)continue;return{value:u.arg,done:s.done}}"throw"===u.type&&(r=v,s.method="throw",s.arg=u.arg)}}}function F(t,i){var s=i.method,r=t.iterator[s];if(r===e)return i.delegate=null,"throw"===s&&t.iterator.return&&(i.method="return",i.arg=e,F(t,i),"throw"===i.method)||"return"!==s&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+s+"' method")),g;var n=h(r,t.iterator,i.arg);if("throw"===n.type)return i.method="throw",i.arg=n.arg,i.delegate=null,g;var o=n.arg;return o?o.done?(i[t.resultName]=o.value,i.next=t.nextLoc,"return"!==i.method&&(i.method="next",i.arg=e),i.delegate=null,g):o:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,g)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function S(t){if(t||""===t){var i=t[a];if(i)return i.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function i(){for(;++r<t.length;)if(s.call(t,r))return i.value=t[r],i.done=!1,i;return i.value=e,i.done=!0,i};return n.next=n}}throw new TypeError(b(t)+" is not iterable")}return _.prototype=y,n(P,"constructor",{value:y,configurable:!0}),n(y,"constructor",{value:_,configurable:!0}),_.displayName=A(y,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===_||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,A(e,u,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},C(M.prototype),A(M.prototype,l,(function(){return this})),t.AsyncIterator=M,t.async=function(e,i,s,r,n){void 0===n&&(n=Promise);var o=new M(c(e,i,s,r),n);return t.isGeneratorFunction(i)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},C(P),A(P,u,"Generator"),A(P,a,(function(){return this})),A(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),i=[];for(var s in t)i.push(s);return i.reverse(),function e(){for(;i.length;){var s=i.pop();if(s in t)return e.value=s,e.done=!1,e}return e.done=!0,e}},t.values=S,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(D),!t)for(var i in this)"t"===i.charAt(0)&&s.call(this,i)&&!isNaN(+i.slice(1))&&(this[i]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var i=this;function r(s,r){return a.type="throw",a.arg=t,i.next=s,r&&(i.method="next",i.arg=e),!!r}for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var l=s.call(o,"catchLoc"),u=s.call(o,"finallyLoc");if(l&&u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var r=this.tryEntries[i];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var n=r;break}}n&&("break"===e||"continue"===e)&&n.tryLoc<=t&&t<=n.finallyLoc&&(n=null);var o=n?n.completion:{};return o.type=e,o.arg=t,n?(this.method="next",this.next=n.finallyLoc,g):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),D(i),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var s=i.completion;if("throw"===s.type){var r=s.arg;D(i)}return r}}throw Error("illegal catch attempt")},delegateYield:function(t,i,s){return this.delegate={iterator:S(t),resultName:i,nextLoc:s},"next"===this.method&&(this.arg=e),g}},t}function n(e,t,i,s,r,n,o){try{var a=e[n](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,r)}function o(e){return function(){var t=this,i=arguments;return new Promise((function(s,r){var o=e.apply(t,i);function a(e){n(o,s,r,a,l,"next",e)}function l(e){n(o,s,r,a,l,"throw",e)}a(void 0)}))}}function a(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||A(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=A(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var s=0,r=function(){};return{s:r,n:function(){return s>=e.length?{done:!0}:{done:!1,value:e[s++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o=!0,a=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return o=e.done,e},e:function(e){a=!0,n=e},f:function(){try{o||null==i.return||i.return()}finally{if(a)throw n}}}}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var s,r,n,o,a=[],l=!0,u=!1;try{if(n=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(s=n.call(i)).done)&&(a.push(s.value),a.length!==t);l=!0);}catch(e){u=!0,r=e}finally{try{if(!l&&null!=i.return&&(o=i.return(),Object(o)!==o))return}finally{if(u)throw r}}return a}}(e,t)||A(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){if(e){if("string"==typeof e)return c(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,s=Array(t);i<t;i++)s[i]=e[i];return s}function h(e,t,i){return t=g(t),d(e,p()?Reflect.construct(t,i||[],g(e).constructor):t.apply(e,i))}function d(e,t){if(t&&("object"==b(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(p=function(){return!!e})()}function f(e,t,i,s){var r=v(g(1&s?e.prototype:e),t,i);return 2&s?function(e){return r.apply(i,e)}:r}function v(){return v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var s=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=g(e)););return e}(e,t);if(s){var r=Object.getOwnPropertyDescriptor(s,t);return r.get?r.get.call(arguments.length<3?e:i):r.value}},v.apply(null,arguments)}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}function m(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_(e,t)}function _(e,t){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_(e,t)}function y(e,t,i){return(t=P(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function b(e){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(e)}function B(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function x(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,P(s.key),s)}}function w(e,t,i){return t&&x(e.prototype,t),i&&x(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function P(e){var t=function(e,t){if("object"!=b(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,t||"default");if("object"!=b(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==b(t)?t:t+""}function C(e){return new F(e,0)}function M(e){return function(){return new k(e.apply(this,arguments))}}function k(e){var t,i;function s(t,i){try{var n=e[t](i),o=n.value,a=o instanceof F;Promise.resolve(a?o.v:o).then((function(i){if(a){var l="return"===t?"return":"next";if(!o.k||i.done)return s(l,i);i=e[l](i).value}r(n.done?"return":"normal",i)}),(function(e){s("throw",e)}))}catch(e){r("throw",e)}}function r(e,r){switch(e){case"return":t.resolve({value:r,done:!0});break;case"throw":t.reject(r);break;default:t.resolve({value:r,done:!1})}(t=t.next)?s(t.key,t.arg):i=null}this._invoke=function(e,r){return new Promise((function(n,o){var a={key:e,arg:r,resolve:n,reject:o,next:null};i?i=i.next=a:(t=i=a,s(e,r))}))},"function"!=typeof e.return&&(this.return=void 0)}function F(e,t){this.v=e,this.k=t}function E(e){var t,i,s,r=2;for("undefined"!=typeof Symbol&&(i=Symbol.asyncIterator,s=Symbol.iterator);r--;){if(i&&null!=(t=e[i]))return t.call(e);if(s&&null!=(t=e[s]))return new D(t.call(e));i="@@asyncIterator",s="@@iterator"}throw new TypeError("Object is not async iterable")}function D(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return D=function(e){this.s=e,this.n=e.next},D.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var i=this.s.return;return void 0===i?Promise.resolve({value:e,done:!0}):t(i.apply(this.s,arguments))},throw:function(e){var i=this.s.return;return void 0===i?Promise.reject(e):t(i.apply(this.s,arguments))}},new D(e)}k.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},k.prototype.next=function(e){return this._invoke("next",e)},k.prototype.throw=function(e){return this._invoke("throw",e)},k.prototype.return=function(e){return this._invoke("return",e)};var I,S,T,L,R,U,O,Q,N,V,H,j=function(){return w((function e(t){var i=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};B(this,e),this.viewer=t,this.scene=this.viewer.scene,this._lensCursorDiv=document.createElement("div"),this._lensCursorDiv.setAttribute("class","pointerLensCursor"),document.body.append(this._lensCursorDiv),this._lensCursorDiv.style.background="pink",this._lensCursorDiv.style.border="2px solid red",this._lensCursorDiv.style.borderRadius="20px",this._lensCursorDiv.style.width="10px",this._lensCursorDiv.style.height="10px",this._lensCursorDiv.style.margin="-200px -200px",this._lensCursorDiv.style.zIndex="100000",this._lensCursorDiv.style.position="absolute",this._lensCursorDiv.style.pointerEvents="none",this._lensContainer=document.createElement("div"),this._lensContainer.setAttribute("class","pointerLens"),this._lensContainer.style.border="1px solid black",this._lensContainer.style.background="white",this._lensContainer.style.borderRadius="50%",this._lensContainer.style.width="300px",this._lensContainer.style.height="300px",this._lensContainer.style.marginTop="85px",this._lensContainer.style.marginLeft="25px",this._lensContainer.style.zIndex="15000",this._lensContainer.style.position="absolute",this._lensContainer.style.pointerEvents="none",this._lensContainer.style.visibility="hidden",this._lensCanvas=document.createElement("canvas"),this._lensCanvas.style.borderRadius="50%",this._lensCanvas.style.width="300px",this._lensCanvas.style.height="300px",this._lensCanvas.style.zIndex="15000",this._lensCanvas.style.pointerEvents="none",document.body.appendChild(this._lensContainer),this._lensContainer.appendChild(this._lensCanvas),this._lensCanvasContext=this._lensCanvas.getContext("2d"),this._canvasElement=this.viewer.scene.canvas.canvas,this._canvasPos=null,this._snappedCanvasPos=null,this._lensPosToggle=!0,this._zoomLevel=void 0!==s.zoomFactor?s.zoomFactor:2,this._active=!1!==s.active,this._visible=!1,this._snapped=!1,this._onViewerRendering=this.viewer.scene.on("rendering",(function(){i._active&&i._visible&&i.update()}))}),[{key:"update",value:function(){if(this._active&&this._visible&&this._canvasPos){var e=this._lensContainer.getBoundingClientRect(),t=this._canvasElement.getBoundingClientRect(),i=this._canvasPos[0]<e.right&&this._canvasPos[0]>e.left&&this._canvasPos[1]<e.bottom&&this._canvasPos[1]>e.top;this._lensContainer.style.marginLeft="25px",i&&(this._lensPosToggle?this._lensContainer.style.marginTop="".concat(t.bottom-t.top-this._lensCanvas.height-85,"px"):this._lensContainer.style.marginTop="85px",this._lensPosToggle=!this._lensPosToggle),this._lensCanvasContext.clearRect(0,0,this._lensCanvas.width,this._lensCanvas.height);var s=Math.max(this._lensCanvas.width,this._lensCanvas.height)/this._zoomLevel;this._lensCanvasContext.drawImage(this._canvasElement,this._canvasPos[0]-s/2,this._canvasPos[1]-s/2,s,s,0,0,this._lensCanvas.width,this._lensCanvas.height);var r=[(e.left+e.right)/2,(e.top+e.bottom)/2];if(this._snappedCanvasPos){var n=this._snappedCanvasPos[0]-this._canvasPos[0],o=this._snappedCanvasPos[1]-this._canvasPos[1];this._lensCursorDiv.style.marginLeft="".concat(r[0]+n*this._zoomLevel-10,"px"),this._lensCursorDiv.style.marginTop="".concat(r[1]+o*this._zoomLevel-10,"px")}else this._lensCursorDiv.style.marginLeft="".concat(r[0]-10,"px"),this._lensCursorDiv.style.marginTop="".concat(r[1]-10,"px")}}},{key:"zoomFactor",get:function(){return this._zoomLevel},set:function(e){this._zoomLevel=e,this.update()}},{key:"canvasPos",get:function(){return this._canvasPos},set:function(e){this._canvasPos=e,this.update()}},{key:"snappedCanvasPos",get:function(){return this._snappedCanvasPos},set:function(e){this._snappedCanvasPos=e,this.update()}},{key:"snapped",get:function(){return this._snapped},set:function(e){this._snapped=e,e?(this._lensCursorDiv.style.background="greenyellow",this._lensCursorDiv.style.border="2px solid green"):(this._lensCursorDiv.style.background="pink",this._lensCursorDiv.style.border="2px solid red")}},{key:"active",get:function(){return this._active},set:function(e){this._active=e,this._lensContainer.style.visibility=e&&this._visible?"visible":"hidden",e&&this._visible||(this._lensCursorDiv.style.marginLeft="-100px",this._lensCursorDiv.style.marginTop="-100px"),this.update()}},{key:"visible",get:function(){return this._visible},set:function(e){this._visible=e,this._lensContainer.style.visibility=e&&this._active?"visible":"hidden",e&&this._active||(this._lensCursorDiv.style.marginLeft="-100px",this._lensCursorDiv.style.marginTop="-100px"),this.update()}},{key:"destroy",value:function(){this._destroyed||(this.viewer.scene.off(this._onViewerRendering),this._lensContainer.removeChild(this._lensCanvas),document.body.removeChild(this._lensContainer),this._destroyed=!0)}}])}(),G=!0,z=G?Float64Array:Float32Array,W=new z(3),K=new z(16),X=new z(16),Y=new z(4),J={setDoublePrecisionEnabled:function(e){z=(G=e)?Float64Array:Float32Array},getDoublePrecisionEnabled:function(){return G},MIN_DOUBLE:-Number.MAX_SAFE_INTEGER,MAX_DOUBLE:Number.MAX_SAFE_INTEGER,MAX_INT:1e7,DEGTORAD:.0174532925,RADTODEG:57.295779513,unglobalizeObjectId:function(e,t){var i=t.indexOf("#");return i===e.length&&t.startsWith(e)?t.substring(i+1):t},globalizeObjectId:function(e,t){return e+"#"+t},safeInv:function(e){var t=1/e;return isNaN(t)||!isFinite(t)?1:t},vec2:function(e){return new z(e||2)},vec3:function(e){return new z(e||3)},vec4:function(e){return new z(e||4)},mat3:function(e){return new z(e||9)},mat3ToMat4:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new z(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=0,t[4]=e[3],t[5]=e[4],t[6]=e[5],t[7]=0,t[8]=e[6],t[9]=e[7],t[10]=e[8],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},mat4:function(e){return new z(e||16)},mat4ToMat3:function(e,t){},doublesToFloats:function(e,t,i){for(var s=new z(2),r=0,n=e.length;r<n;r++)J.splitDouble(e[r],s),t[r]=s[0],i[r]=s[1]},splitDouble:function(e,t){var i=z.from([e])[0],s=e-i;t[0]=i,t[1]=s},createUUID:function(){for(var e=[],t=0;t<256;t++)e[t]=(t<16?"0":"")+t.toString(16);return function(){var t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,s=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return"".concat(e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255],"-").concat(e[255&i]).concat(e[i>>8&255],"-").concat(e[i>>16&15|64]).concat(e[i>>24&255],"-").concat(e[63&s|128]).concat(e[s>>8&255],"-").concat(e[s>>16&255]).concat(e[s>>24&255]).concat(e[255&r]).concat(e[r>>8&255]).concat(e[r>>16&255]).concat(e[r>>24&255])}}(),clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},fmod:function(e,t){if(e<t)return console.error("math.fmod : Attempting to find modulus within negative range - would be infinite loop - ignoring"),e;for(;t<=e;)e-=t;return e},compareVec3:function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},negateVec3:function(e,t){return t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},negateVec4:function(e,t){return t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},addVec4:function(e,t,i){return i||(i=e),i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i[3]=e[3]+t[3],i},addVec4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]+t,i[1]=e[1]+t,i[2]=e[2]+t,i[3]=e[3]+t,i},addVec3:function(e,t,i){return i||(i=e),i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i},addVec3Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]+t,i[1]=e[1]+t,i[2]=e[2]+t,i},subVec4:function(e,t,i){return i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i[3]=e[3]-t[3],i},subVec3:function(e,t,i){return i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i},subVec2:function(e,t,i){return i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i},geometricMeanVec2:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];for(var s=new z(t[0]),r=1;r<t.length;r++)s[0]+=t[r][0],s[1]+=t[r][1];return s[0]/=t.length,s[1]/=t.length,s},subVec4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]-t,i[1]=e[1]-t,i[2]=e[2]-t,i[3]=e[3]-t,i},subScalarVec4:function(e,t,i){return i||(i=e),i[0]=t-e[0],i[1]=t-e[1],i[2]=t-e[2],i[3]=t-e[3],i},mulVec3:function(e,t,i){return i||(i=e),i[0]=e[0]*t[0],i[1]=e[1]*t[1],i[2]=e[2]*t[2],i},mulVec4:function(e,t,i){return i||(i=e),i[0]=e[0]*t[0],i[1]=e[1]*t[1],i[2]=e[2]*t[2],i[3]=e[3]*t[3],i},mulVec4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i[3]=e[3]*t,i},mulVec3Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i},mulVec2Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i},divVec3:function(e,t,i){return i||(i=e),i[0]=e[0]/t[0],i[1]=e[1]/t[1],i[2]=e[2]/t[2],i},divVec4:function(e,t,i){return i||(i=e),i[0]=e[0]/t[0],i[1]=e[1]/t[1],i[2]=e[2]/t[2],i[3]=e[3]/t[3],i},divScalarVec3:function(e,t,i){return i||(i=t),i[0]=e/t[0],i[1]=e/t[1],i[2]=e/t[2],i},divVec3Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]/t,i[1]=e[1]/t,i[2]=e[2]/t,i},divVec4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]/t,i[1]=e[1]/t,i[2]=e[2]/t,i[3]=e[3]/t,i},divScalarVec4:function(e,t,i){return i||(i=t),i[0]=e/t[0],i[1]=e/t[1],i[2]=e/t[2],i[3]=e/t[3],i},dotVec4:function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},cross3Vec4:function(e,t){var i=e[0],s=e[1],r=e[2],n=t[0],o=t[1],a=t[2];return[s*a-r*o,r*n-i*a,i*o-s*n,0]},cross3Vec3:function(e,t,i){i||(i=e);var s=e[0],r=e[1],n=e[2],o=t[0],a=t[1],l=t[2];return i[0]=r*l-n*a,i[1]=n*o-s*l,i[2]=s*a-r*o,i},sqLenVec4:function(e){return J.dotVec4(e,e)},lenVec4:function(e){return Math.sqrt(J.sqLenVec4(e))},dotVec3:function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},dotVec2:function(e,t){return e[0]*t[0]+e[1]*t[1]},sqLenVec3:function(e){return J.dotVec3(e,e)},sqLenVec2:function(e){return J.dotVec2(e,e)},lenVec3:function(e){return Math.sqrt(J.sqLenVec3(e))},distVec3:(H=new z(3),function(e,t){return J.lenVec3(J.subVec3(e,t,H))}),lenVec2:function(e){return Math.sqrt(J.sqLenVec2(e))},distVec2:function(){var e=new z(2);return function(t,i){return J.lenVec2(J.subVec2(t,i,e))}}(),rcpVec3:function(e,t){return J.divScalarVec3(1,e,t)},normalizeVec4:function(e,t){var i=1/J.lenVec4(e);return J.mulVec4Scalar(e,i,t)},normalizeVec3:function(e,t){var i=1/J.lenVec3(e);return J.mulVec3Scalar(e,i,t)},normalizeVec2:function(e,t){var i=1/J.lenVec2(e);return J.mulVec2Scalar(e,i,t)},angleVec3:function(e,t){var i=J.dotVec3(e,t)/Math.sqrt(J.sqLenVec3(e)*J.sqLenVec3(t));return i=i<-1?-1:i>1?1:i,Math.acos(i)},vec3FromMat4Scale:function(){var e=new z(3);return function(t,i){return e[0]=t[0],e[1]=t[1],e[2]=t[2],i[0]=J.lenVec3(e),e[0]=t[4],e[1]=t[5],e[2]=t[6],i[1]=J.lenVec3(e),e[0]=t[8],e[1]=t[9],e[2]=t[10],i[2]=J.lenVec3(e),i}}(),vecToArray:function(){function e(e){return Math.round(1e5*e)/1e5}return function(t){for(var i=0,s=(t=Array.prototype.slice.call(t)).length;i<s;i++)t[i]=e(t[i]);return t}}(),xyzArrayToObject:function(e){return{x:e[0],y:e[1],z:e[2]}},xyzObjectToArray:function(e,t){return(t=t||J.vec3())[0]=e.x,t[1]=e.y,t[2]=e.z,t},dupMat4:function(e){return e.slice(0,16)},mat4To3:function(e){return[e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]]},m4s:function(e){return[e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e]},setMat4ToZeroes:function(){return J.m4s(0)},setMat4ToOnes:function(){return J.m4s(1)},diagonalMat4v:function(e){return new z([e[0],0,0,0,0,e[1],0,0,0,0,e[2],0,0,0,0,e[3]])},diagonalMat4c:function(e,t,i,s){return J.diagonalMat4v([e,t,i,s])},diagonalMat4s:function(e){return J.diagonalMat4c(e,e,e,e)},identityMat4:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new z(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},identityMat3:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new z(9);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},isIdentityMat4:function(e){return 1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]},negateMat4:function(e,t){return t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t[4]=-e[4],t[5]=-e[5],t[6]=-e[6],t[7]=-e[7],t[8]=-e[8],t[9]=-e[9],t[10]=-e[10],t[11]=-e[11],t[12]=-e[12],t[13]=-e[13],t[14]=-e[14],t[15]=-e[15],t},addMat4:function(e,t,i){return i||(i=e),i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i[3]=e[3]+t[3],i[4]=e[4]+t[4],i[5]=e[5]+t[5],i[6]=e[6]+t[6],i[7]=e[7]+t[7],i[8]=e[8]+t[8],i[9]=e[9]+t[9],i[10]=e[10]+t[10],i[11]=e[11]+t[11],i[12]=e[12]+t[12],i[13]=e[13]+t[13],i[14]=e[14]+t[14],i[15]=e[15]+t[15],i},addMat4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]+t,i[1]=e[1]+t,i[2]=e[2]+t,i[3]=e[3]+t,i[4]=e[4]+t,i[5]=e[5]+t,i[6]=e[6]+t,i[7]=e[7]+t,i[8]=e[8]+t,i[9]=e[9]+t,i[10]=e[10]+t,i[11]=e[11]+t,i[12]=e[12]+t,i[13]=e[13]+t,i[14]=e[14]+t,i[15]=e[15]+t,i},addScalarMat4:function(e,t,i){return J.addMat4Scalar(t,e,i)},subMat4:function(e,t,i){return i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i[3]=e[3]-t[3],i[4]=e[4]-t[4],i[5]=e[5]-t[5],i[6]=e[6]-t[6],i[7]=e[7]-t[7],i[8]=e[8]-t[8],i[9]=e[9]-t[9],i[10]=e[10]-t[10],i[11]=e[11]-t[11],i[12]=e[12]-t[12],i[13]=e[13]-t[13],i[14]=e[14]-t[14],i[15]=e[15]-t[15],i},subMat4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]-t,i[1]=e[1]-t,i[2]=e[2]-t,i[3]=e[3]-t,i[4]=e[4]-t,i[5]=e[5]-t,i[6]=e[6]-t,i[7]=e[7]-t,i[8]=e[8]-t,i[9]=e[9]-t,i[10]=e[10]-t,i[11]=e[11]-t,i[12]=e[12]-t,i[13]=e[13]-t,i[14]=e[14]-t,i[15]=e[15]-t,i},subScalarMat4:function(e,t,i){return i||(i=t),i[0]=e-t[0],i[1]=e-t[1],i[2]=e-t[2],i[3]=e-t[3],i[4]=e-t[4],i[5]=e-t[5],i[6]=e-t[6],i[7]=e-t[7],i[8]=e-t[8],i[9]=e-t[9],i[10]=e-t[10],i[11]=e-t[11],i[12]=e-t[12],i[13]=e-t[13],i[14]=e-t[14],i[15]=e-t[15],i},mulMat4:function(e,t,i){i||(i=e);var s=e[0],r=e[1],n=e[2],o=e[3],a=e[4],l=e[5],u=e[6],A=e[7],c=e[8],h=e[9],d=e[10],p=e[11],f=e[12],v=e[13],g=e[14],m=e[15],_=t[0],y=t[1],b=t[2],B=t[3],x=t[4],w=t[5],P=t[6],C=t[7],M=t[8],k=t[9],F=t[10],E=t[11],D=t[12],I=t[13],S=t[14],T=t[15];return i[0]=_*s+y*a+b*c+B*f,i[1]=_*r+y*l+b*h+B*v,i[2]=_*n+y*u+b*d+B*g,i[3]=_*o+y*A+b*p+B*m,i[4]=x*s+w*a+P*c+C*f,i[5]=x*r+w*l+P*h+C*v,i[6]=x*n+w*u+P*d+C*g,i[7]=x*o+w*A+P*p+C*m,i[8]=M*s+k*a+F*c+E*f,i[9]=M*r+k*l+F*h+E*v,i[10]=M*n+k*u+F*d+E*g,i[11]=M*o+k*A+F*p+E*m,i[12]=D*s+I*a+S*c+T*f,i[13]=D*r+I*l+S*h+T*v,i[14]=D*n+I*u+S*d+T*g,i[15]=D*o+I*A+S*p+T*m,i},mulMat3:function(e,t,i){i||(i=new z(9));var s=e[0],r=e[3],n=e[6],o=e[1],a=e[4],l=e[7],u=e[2],A=e[5],c=e[8],h=t[0],d=t[3],p=t[6],f=t[1],v=t[4],g=t[7],m=t[2],_=t[5],y=t[8];return i[0]=s*h+r*f+n*m,i[3]=s*d+r*v+n*_,i[6]=s*p+r*g+n*y,i[1]=o*h+a*f+l*m,i[4]=o*d+a*v+l*_,i[7]=o*p+a*g+l*y,i[2]=u*h+A*f+c*m,i[5]=u*d+A*v+c*_,i[8]=u*p+A*g+c*y,i},mulMat4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i[3]=e[3]*t,i[4]=e[4]*t,i[5]=e[5]*t,i[6]=e[6]*t,i[7]=e[7]*t,i[8]=e[8]*t,i[9]=e[9]*t,i[10]=e[10]*t,i[11]=e[11]*t,i[12]=e[12]*t,i[13]=e[13]*t,i[14]=e[14]*t,i[15]=e[15]*t,i},mulMat4v4:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:J.vec4(),s=t[0],r=t[1],n=t[2],o=t[3];return i[0]=e[0]*s+e[4]*r+e[8]*n+e[12]*o,i[1]=e[1]*s+e[5]*r+e[9]*n+e[13]*o,i[2]=e[2]*s+e[6]*r+e[10]*n+e[14]*o,i[3]=e[3]*s+e[7]*r+e[11]*n+e[15]*o,i},transposeMat4:function(e,t){var i=e[4],s=e[14],r=e[8],n=e[13],o=e[12],a=e[9];if(!t||e===t){var l=e[1],u=e[2],A=e[3],c=e[6],h=e[7],d=e[11];return e[1]=i,e[2]=r,e[3]=o,e[4]=l,e[6]=a,e[7]=n,e[8]=u,e[9]=c,e[11]=s,e[12]=A,e[13]=h,e[14]=d,e}return t[0]=e[0],t[1]=i,t[2]=r,t[3]=o,t[4]=e[1],t[5]=e[5],t[6]=a,t[7]=n,t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=s,t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15],t},transposeMat3:function(e,t){if(t===e){var i=e[1],s=e[2],r=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,t[5]=e[7],t[6]=s,t[7]=r}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},determinantMat4:function(e){var t=e[0],i=e[1],s=e[2],r=e[3],n=e[4],o=e[5],a=e[6],l=e[7],u=e[8],A=e[9],c=e[10],h=e[11],d=e[12],p=e[13],f=e[14],v=e[15];return d*A*a*r-u*p*a*r-d*o*c*r+n*p*c*r+u*o*f*r-n*A*f*r-d*A*s*l+u*p*s*l+d*i*c*l-t*p*c*l-u*i*f*l+t*A*f*l+d*o*s*h-n*p*s*h-d*i*a*h+t*p*a*h+n*i*f*h-t*o*f*h-u*o*s*v+n*A*s*v+u*i*a*v-t*A*a*v-n*i*c*v+t*o*c*v},inverseMat4:function(e,t){t||(t=e);var i=e[0],s=e[1],r=e[2],n=e[3],o=e[4],a=e[5],l=e[6],u=e[7],A=e[8],c=e[9],h=e[10],d=e[11],p=e[12],f=e[13],v=e[14],g=e[15],m=i*a-s*o,_=i*l-r*o,y=i*u-n*o,b=s*l-r*a,B=s*u-n*a,x=r*u-n*l,w=A*f-c*p,P=A*v-h*p,C=A*g-d*p,M=c*v-h*f,k=c*g-d*f,F=h*g-d*v,E=1/(m*F-_*k+y*M+b*C-B*P+x*w);return t[0]=(a*F-l*k+u*M)*E,t[1]=(-s*F+r*k-n*M)*E,t[2]=(f*x-v*B+g*b)*E,t[3]=(-c*x+h*B-d*b)*E,t[4]=(-o*F+l*C-u*P)*E,t[5]=(i*F-r*C+n*P)*E,t[6]=(-p*x+v*y-g*_)*E,t[7]=(A*x-h*y+d*_)*E,t[8]=(o*k-a*C+u*w)*E,t[9]=(-i*k+s*C-n*w)*E,t[10]=(p*B-f*y+g*m)*E,t[11]=(-A*B+c*y-d*m)*E,t[12]=(-o*M+a*P-l*w)*E,t[13]=(i*M-s*P+r*w)*E,t[14]=(-p*b+f*_-v*m)*E,t[15]=(A*b-c*_+h*m)*E,t},traceMat4:function(e){return e[0]+e[5]+e[10]+e[15]},translationMat4v:function(e,t){var i=t||J.identityMat4();return i[12]=e[0],i[13]=e[1],i[14]=e[2],i},translationMat3v:function(e,t){var i=t||J.identityMat3();return i[6]=e[0],i[7]=e[1],i},translationMat4c:(V=new z(3),function(e,t,i,s){return V[0]=e,V[1]=t,V[2]=i,J.translationMat4v(V,s)}),translationMat4s:function(e,t){return J.translationMat4c(e,e,e,t)},translateMat4v:function(e,t){return J.translateMat4c(e[0],e[1],e[2],t)},translateMat4c:function(e,t,i,s){var r=s[3];s[0]+=r*e,s[1]+=r*t,s[2]+=r*i;var n=s[7];s[4]+=n*e,s[5]+=n*t,s[6]+=n*i;var o=s[11];s[8]+=o*e,s[9]+=o*t,s[10]+=o*i;var a=s[15];return s[12]+=a*e,s[13]+=a*t,s[14]+=a*i,s},setMat4Translation:function(e,t,i){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=t[0],i[13]=t[1],i[14]=t[2],i[15]=e[15],i},rotationMat4v:function(e,t,i){var s,r,n,o,a,l,u=J.normalizeVec4([t[0],t[1],t[2],0],[]),A=Math.sin(e),c=Math.cos(e),h=1-c,d=u[0],p=u[1],f=u[2];return s=d*p,r=p*f,n=f*d,o=d*A,a=p*A,l=f*A,(i=i||J.mat4())[0]=h*d*d+c,i[1]=h*s+l,i[2]=h*n-a,i[3]=0,i[4]=h*s-l,i[5]=h*p*p+c,i[6]=h*r+o,i[7]=0,i[8]=h*n+a,i[9]=h*r-o,i[10]=h*f*f+c,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},rotationMat4c:function(e,t,i,s,r){return J.rotationMat4v(e,[t,i,s],r)},scalingMat4v:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J.identityMat4();return t[0]=e[0],t[5]=e[1],t[10]=e[2],t},scalingMat3v:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J.identityMat3();return t[0]=e[0],t[4]=e[1],t},scalingMat4c:function(){var e=new z(3);return function(t,i,s,r){return e[0]=t,e[1]=i,e[2]=s,J.scalingMat4v(e,r)}}(),scaleMat4c:function(e,t,i,s){return s[0]*=e,s[4]*=t,s[8]*=i,s[1]*=e,s[5]*=t,s[9]*=i,s[2]*=e,s[6]*=t,s[10]*=i,s[3]*=e,s[7]*=t,s[11]*=i,s},scaleMat4v:function(e,t){var i=e[0],s=e[1],r=e[2];return t[0]*=i,t[4]*=s,t[8]*=r,t[1]*=i,t[5]*=s,t[9]*=r,t[2]*=i,t[6]*=s,t[10]*=r,t[3]*=i,t[7]*=s,t[11]*=r,t},scalingMat4s:function(e){return J.scalingMat4c(e,e,e)},rotationTranslationMat4:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:J.mat4(),s=e[0],r=e[1],n=e[2],o=e[3],a=s+s,l=r+r,u=n+n,A=s*a,c=s*l,h=s*u,d=r*l,p=r*u,f=n*u,v=o*a,g=o*l,m=o*u;return i[0]=1-(d+f),i[1]=c+m,i[2]=h-g,i[3]=0,i[4]=c-m,i[5]=1-(A+f),i[6]=p+v,i[7]=0,i[8]=h+g,i[9]=p-v,i[10]=1-(A+d),i[11]=0,i[12]=t[0],i[13]=t[1],i[14]=t[2],i[15]=1,i},mat4ToEuler:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:J.vec4(),s=J.clamp,r=e[0],n=e[4],o=e[8],a=e[1],l=e[5],u=e[9],A=e[2],c=e[6],h=e[10];return"XYZ"===t?(i[1]=Math.asin(s(o,-1,1)),Math.abs(o)<.99999?(i[0]=Math.atan2(-u,h),i[2]=Math.atan2(-n,r)):(i[0]=Math.atan2(c,l),i[2]=0)):"YXZ"===t?(i[0]=Math.asin(-s(u,-1,1)),Math.abs(u)<.99999?(i[1]=Math.atan2(o,h),i[2]=Math.atan2(a,l)):(i[1]=Math.atan2(-A,r),i[2]=0)):"ZXY"===t?(i[0]=Math.asin(s(c,-1,1)),Math.abs(c)<.99999?(i[1]=Math.atan2(-A,h),i[2]=Math.atan2(-n,l)):(i[1]=0,i[2]=Math.atan2(a,r))):"ZYX"===t?(i[1]=Math.asin(-s(A,-1,1)),Math.abs(A)<.99999?(i[0]=Math.atan2(c,h),i[2]=Math.atan2(a,r)):(i[0]=0,i[2]=Math.atan2(-n,l))):"YZX"===t?(i[2]=Math.asin(s(a,-1,1)),Math.abs(a)<.99999?(i[0]=Math.atan2(-u,l),i[1]=Math.atan2(-A,r)):(i[0]=0,i[1]=Math.atan2(o,h))):"XZY"===t&&(i[2]=Math.asin(-s(n,-1,1)),Math.abs(n)<.99999?(i[0]=Math.atan2(c,l),i[1]=Math.atan2(o,r)):(i[0]=Math.atan2(-u,h),i[1]=0)),i},composeMat4:function(e,t,i){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:J.mat4();return J.quaternionToRotationMat4(t,s),J.scaleMat4v(i,s),J.translateMat4v(e,s),s},decomposeMat4:function(){var e=new z(3),t=new z(16);return function(i,s,r,n){e[0]=i[0],e[1]=i[1],e[2]=i[2];var o=J.lenVec3(e);e[0]=i[4],e[1]=i[5],e[2]=i[6];var a=J.lenVec3(e);e[8]=i[8],e[9]=i[9],e[10]=i[10];var l=J.lenVec3(e);J.determinantMat4(i)<0&&(o=-o),s[0]=i[12],s[1]=i[13],s[2]=i[14],t.set(i);var u=1/o,A=1/a,c=1/l;return t[0]*=u,t[1]*=u,t[2]*=u,t[4]*=A,t[5]*=A,t[6]*=A,t[8]*=c,t[9]*=c,t[10]*=c,J.mat4ToQuaternion(t,r),n[0]=o,n[1]=a,n[2]=l,this}}(),getColMat4:function(e,t){var i=4*t;return[e[i],e[i+1],e[i+2],e[i+3]]},setRowMat4:function(e,t,i){e[t]=i[0],e[t+4]=i[1],e[t+8]=i[2],e[t+12]=i[3]},lookAtMat4v:function(e,t,i,s){s||(s=J.mat4());var r,n,o,a,l,u,A,c,h,d,p=e[0],f=e[1],v=e[2],g=i[0],m=i[1],_=i[2],y=t[0],b=t[1],B=t[2];return p===y&&f===b&&v===B?J.identityMat4():(r=p-y,n=f-b,o=v-B,a=m*(o*=d=1/Math.sqrt(r*r+n*n+o*o))-_*(n*=d),l=_*(r*=d)-g*o,u=g*n-m*r,(d=Math.sqrt(a*a+l*l+u*u))?(a*=d=1/d,l*=d,u*=d):(a=0,l=0,u=0),A=n*u-o*l,c=o*a-r*u,h=r*l-n*a,(d=Math.sqrt(A*A+c*c+h*h))?(A*=d=1/d,c*=d,h*=d):(A=0,c=0,h=0),s[0]=a,s[1]=A,s[2]=r,s[3]=0,s[4]=l,s[5]=c,s[6]=n,s[7]=0,s[8]=u,s[9]=h,s[10]=o,s[11]=0,s[12]=-(a*p+l*f+u*v),s[13]=-(A*p+c*f+h*v),s[14]=-(r*p+n*f+o*v),s[15]=1,s)},lookAtMat4c:function(e,t,i,s,r,n,o,a,l){return J.lookAtMat4v([e,t,i],[s,r,n],[o,a,l],[])},orthoMat4c:function(e,t,i,s,r,n,o){o||(o=J.mat4());var a=t-e,l=s-i,u=n-r;return o[0]=2/a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=2/l,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=-2/u,o[11]=0,o[12]=-(e+t)/a,o[13]=-(s+i)/l,o[14]=-(n+r)/u,o[15]=1,o},frustumMat4v:function(e,t,i){i||(i=J.mat4());var s=[e[0],e[1],e[2],0],r=[t[0],t[1],t[2],0];J.addVec4(r,s,K),J.subVec4(r,s,X);var n=2*s[2],o=X[0],a=X[1],l=X[2];return i[0]=n/o,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=n/a,i[6]=0,i[7]=0,i[8]=K[0]/o,i[9]=K[1]/a,i[10]=-K[2]/l,i[11]=-1,i[12]=0,i[13]=0,i[14]=-n*r[2]/l,i[15]=0,i},frustumMat4:function(e,t,i,s,r,n,o){o||(o=J.mat4());var a=t-e,l=s-i,u=n-r;return o[0]=2*r/a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=2*r/l,o[6]=0,o[7]=0,o[8]=(t+e)/a,o[9]=(s+i)/l,o[10]=-(n+r)/u,o[11]=-1,o[12]=0,o[13]=0,o[14]=-n*r*2/u,o[15]=0,o},perspectiveMat4:function(e,t,i,s,r){var n=[],o=[];return n[2]=i,o[2]=s,o[1]=n[2]*Math.tan(e/2),n[1]=-o[1],o[0]=o[1]*t,n[0]=-o[0],J.frustumMat4v(n,o,r)},compareMat4:function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},transformPoint3:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:J.vec3(),s=t[0],r=t[1],n=t[2];return i[0]=e[0]*s+e[4]*r+e[8]*n+e[12],i[1]=e[1]*s+e[5]*r+e[9]*n+e[13],i[2]=e[2]*s+e[6]*r+e[10]*n+e[14],i},transformPoint4:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:J.vec4();return i[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],i[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],i[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],i[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3],i},transformPoints3:function(e,t,i){for(var s,r,n,o,a,l=i||[],u=t.length,A=e[0],c=e[1],h=e[2],d=e[3],p=e[4],f=e[5],v=e[6],g=e[7],m=e[8],_=e[9],y=e[10],b=e[11],B=e[12],x=e[13],w=e[14],P=e[15],C=0;C<u;++C)s=(o=t[C])[0],r=o[1],n=o[2],(a=l[C]||(l[C]=[0,0,0]))[0]=A*s+p*r+m*n+B,a[1]=c*s+f*r+_*n+x,a[2]=h*s+v*r+y*n+w,a[3]=d*s+g*r+b*n+P;return l.length=u,l},transformPositions3:function(e,t){var i,s,r,n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,a=t.length,l=e[0],u=e[1],A=e[2];e[3];var c=e[4],h=e[5],d=e[6];e[7];var p=e[8],f=e[9],v=e[10];e[11];var g=e[12],m=e[13],_=e[14];for(e[15],i=0;i<a;i+=3)s=t[i+0],r=t[i+1],n=t[i+2],o[i+0]=l*s+c*r+p*n+g,o[i+1]=u*s+h*r+f*n+m,o[i+2]=A*s+d*r+v*n+_;return o},transformPositions4:function(e,t){var i,s,r,n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,a=t.length,l=e[0],u=e[1],A=e[2],c=e[3],h=e[4],d=e[5],p=e[6],f=e[7],v=e[8],g=e[9],m=e[10],_=e[11],y=e[12],b=e[13],B=e[14],x=e[15];for(i=0;i<a;i+=4)s=t[i+0],r=t[i+1],n=t[i+2],o[i+0]=l*s+h*r+v*n+y,o[i+1]=u*s+d*r+g*n+b,o[i+2]=A*s+p*r+m*n+B,o[i+3]=c*s+f*r+_*n+x;return o},transformVec3:function(e,t,i){var s=t[0],r=t[1],n=t[2];return(i=i||this.vec3())[0]=e[0]*s+e[4]*r+e[8]*n,i[1]=e[1]*s+e[5]*r+e[9]*n,i[2]=e[2]*s+e[6]*r+e[10]*n,i},transformVec4:function(e,t,i){var s=t[0],r=t[1],n=t[2],o=t[3];return(i=i||J.vec4())[0]=e[0]*s+e[4]*r+e[8]*n+e[12]*o,i[1]=e[1]*s+e[5]*r+e[9]*n+e[13]*o,i[2]=e[2]*s+e[6]*r+e[10]*n+e[14]*o,i[3]=e[3]*s+e[7]*r+e[11]*n+e[15]*o,i},rotateVec2:function(e,t,i){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e,r=Math.cos(i),n=Math.sin(i),o=e[0]-t[0],a=e[1]-t[1];return s[0]=o*r-a*n+t[0],s[1]=o*n+a*r+t[1],e},rotateVec3X:function(e,t,i,s){var r=[],n=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],n[0]=r[0],n[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),n[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),s[0]=n[0]+t[0],s[1]=n[1]+t[1],s[2]=n[2]+t[2],s},rotateVec3Y:function(e,t,i,s){var r=[],n=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],n[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),n[1]=r[1],n[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),s[0]=n[0]+t[0],s[1]=n[1]+t[1],s[2]=n[2]+t[2],s},rotateVec3Z:function(e,t,i,s){var r=[],n=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],n[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),n[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),n[2]=r[2],s[0]=n[0]+t[0],s[1]=n[1]+t[1],s[2]=n[2]+t[2],s},projectVec4:function(e,t){var i=1/e[3];return(t=t||J.vec2())[0]=e[0]*i,t[1]=e[1]*i,t},unprojectVec3:(O=new z(16),Q=new z(16),N=new z(16),function(e,t,i,s){return this.transformVec3(this.mulMat4(this.inverseMat4(t,O),this.inverseMat4(i,Q),N),e,s)}),lerpVec3:function(e,t,i,s,r,n){var o=n||J.vec3(),a=(e-t)/(i-t);return o[0]=s[0]+a*(r[0]-s[0]),o[1]=s[1]+a*(r[1]-s[1]),o[2]=s[2]+a*(r[2]-s[2]),o},lerpMat4:function(e,t,i,s,r,n){var o=n||J.mat4(),a=(e-t)/(i-t);return o[0]=s[0]+a*(r[0]-s[0]),o[1]=s[1]+a*(r[1]-s[1]),o[2]=s[2]+a*(r[2]-s[2]),o[3]=s[3]+a*(r[3]-s[3]),o[4]=s[4]+a*(r[4]-s[4]),o[5]=s[5]+a*(r[5]-s[5]),o[6]=s[6]+a*(r[6]-s[6]),o[7]=s[7]+a*(r[7]-s[7]),o[8]=s[8]+a*(r[8]-s[8]),o[9]=s[9]+a*(r[9]-s[9]),o[10]=s[10]+a*(r[10]-s[10]),o[11]=s[11]+a*(r[11]-s[11]),o[12]=s[12]+a*(r[12]-s[12]),o[13]=s[13]+a*(r[13]-s[13]),o[14]=s[14]+a*(r[14]-s[14]),o[15]=s[15]+a*(r[15]-s[15]),o},flatten:function(e){var t,i,s,r,n,o=[];for(t=0,i=e.length;t<i;t++)for(s=0,r=(n=e[t]).length;s<r;s++)o.push(n[s]);return o},identityQuaternion:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:J.vec4();return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},eulerToQuaternion:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:J.vec4(),s=e[0]*J.DEGTORAD/2,r=e[1]*J.DEGTORAD/2,n=e[2]*J.DEGTORAD/2,o=Math.cos(s),a=Math.cos(r),l=Math.cos(n),u=Math.sin(s),A=Math.sin(r),c=Math.sin(n);return"XYZ"===t?(i[0]=u*a*l+o*A*c,i[1]=o*A*l-u*a*c,i[2]=o*a*c+u*A*l,i[3]=o*a*l-u*A*c):"YXZ"===t?(i[0]=u*a*l+o*A*c,i[1]=o*A*l-u*a*c,i[2]=o*a*c-u*A*l,i[3]=o*a*l+u*A*c):"ZXY"===t?(i[0]=u*a*l-o*A*c,i[1]=o*A*l+u*a*c,i[2]=o*a*c+u*A*l,i[3]=o*a*l-u*A*c):"ZYX"===t?(i[0]=u*a*l-o*A*c,i[1]=o*A*l+u*a*c,i[2]=o*a*c-u*A*l,i[3]=o*a*l+u*A*c):"YZX"===t?(i[0]=u*a*l+o*A*c,i[1]=o*A*l+u*a*c,i[2]=o*a*c-u*A*l,i[3]=o*a*l-u*A*c):"XZY"===t&&(i[0]=u*a*l-o*A*c,i[1]=o*A*l-u*a*c,i[2]=o*a*c+u*A*l,i[3]=o*a*l+u*A*c),i},mat4ToQuaternion:function(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J.vec4(),s=e[0],r=e[4],n=e[8],o=e[1],a=e[5],l=e[9],u=e[2],A=e[6],c=e[10],h=s+a+c;return h>0?(t=.5/Math.sqrt(h+1),i[3]=.25/t,i[0]=(A-l)*t,i[1]=(n-u)*t,i[2]=(o-r)*t):s>a&&s>c?(t=2*Math.sqrt(1+s-a-c),i[3]=(A-l)/t,i[0]=.25*t,i[1]=(r+o)/t,i[2]=(n+u)/t):a>c?(t=2*Math.sqrt(1+a-s-c),i[3]=(n-u)/t,i[0]=(r+o)/t,i[1]=.25*t,i[2]=(l+A)/t):(t=2*Math.sqrt(1+c-s-a),i[3]=(o-r)/t,i[0]=(n+u)/t,i[1]=(l+A)/t,i[2]=.25*t),i},vec3PairToQuaternion:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:J.vec4(),s=Math.sqrt(J.dotVec3(e,e)*J.dotVec3(t,t)),r=s+J.dotVec3(e,t);return r<1e-8*s?(r=0,Math.abs(e[0])>Math.abs(e[2])?(i[0]=-e[1],i[1]=e[0],i[2]=0):(i[0]=0,i[1]=-e[2],i[2]=e[1])):J.cross3Vec3(e,t,i),i[3]=r,J.normalizeQuaternion(i)},angleAxisToQuaternion:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J.vec4(),i=e[3]/2,s=Math.sin(i);return t[0]=s*e[0],t[1]=s*e[1],t[2]=s*e[2],t[3]=Math.cos(i),t},quaternionToEuler:function(){var e=new z(16);return function(t,i,s){return s=s||J.vec3(),J.quaternionToRotationMat4(t,e),J.mat4ToEuler(e,i,s),s}}(),mulQuaternions:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:J.vec4(),s=e[0],r=e[1],n=e[2],o=e[3],a=t[0],l=t[1],u=t[2],A=t[3];return i[0]=o*a+s*A+r*u-n*l,i[1]=o*l+r*A+n*a-s*u,i[2]=o*u+n*A+s*l-r*a,i[3]=o*A-s*a-r*l-n*u,i},vec3ApplyQuaternion:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:J.vec3(),s=t[0],r=t[1],n=t[2],o=e[0],a=e[1],l=e[2],u=e[3],A=u*s+a*n-l*r,c=u*r+l*s-o*n,h=u*n+o*r-a*s,d=-o*s-a*r-l*n;return i[0]=A*u+d*-o+c*-l-h*-a,i[1]=c*u+d*-a+h*-o-A*-l,i[2]=h*u+d*-l+A*-a-c*-o,i},quaternionToMat4:function(e,t){t=J.identityMat4(t);var i=e[0],s=e[1],r=e[2],n=e[3],o=2*i,a=2*s,l=2*r,u=o*n,A=a*n,c=l*n,h=o*i,d=a*i,p=l*i,f=a*s,v=l*s,g=l*r;return t[0]=1-(f+g),t[1]=d+c,t[2]=p-A,t[4]=d-c,t[5]=1-(h+g),t[6]=v+u,t[8]=p+A,t[9]=v-u,t[10]=1-(h+f),t},quaternionToRotationMat4:function(e,t){var i=e[0],s=e[1],r=e[2],n=e[3],o=i+i,a=s+s,l=r+r,u=i*o,A=i*a,c=i*l,h=s*a,d=s*l,p=r*l,f=n*o,v=n*a,g=n*l;return t[0]=1-(h+p),t[4]=A-g,t[8]=c+v,t[1]=A+g,t[5]=1-(u+p),t[9]=d-f,t[2]=c-v,t[6]=d+f,t[10]=1-(u+h),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},normalizeQuaternion:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,i=J.lenVec4([e[0],e[1],e[2],e[3]]);return t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i,t[3]=e[3]/i,t},conjugateQuaternion:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},inverseQuaternion:function(e,t){return J.normalizeQuaternion(J.conjugateQuaternion(e,t))},quaternionToAngleAxis:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J.vec4(),i=(e=J.normalizeQuaternion(e,Y))[3],s=2*Math.acos(i),r=Math.sqrt(1-i*i);return r<.001?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=e[0]/r,t[1]=e[1]/r,t[2]=e[2]/r),t[3]=s,t},AABB3:function(e){return new z(e||6)},AABB2:function(e){return new z(e||4)},OBB3:function(e){return new z(e||32)},OBB2:function(e){return new z(e||16)},Sphere3:function(e,t,i,s){return new z([e,t,i,s])},transformOBB3:function(e,t){var i,s,r,n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,a=t.length,l=e[0],u=e[1],A=e[2],c=e[3],h=e[4],d=e[5],p=e[6],f=e[7],v=e[8],g=e[9],m=e[10],_=e[11],y=e[12],b=e[13],B=e[14],x=e[15];for(i=0;i<a;i+=4)s=t[i+0],r=t[i+1],n=t[i+2],o[i+0]=l*s+h*r+v*n+y,o[i+1]=u*s+d*r+g*n+b,o[i+2]=A*s+p*r+m*n+B,o[i+3]=c*s+f*r+_*n+x;return o},containsAABB3:function(e,t){return e[0]<=t[0]&&t[3]<=e[3]&&e[1]<=t[1]&&t[4]<=e[4]&&e[2]<=t[2]&&t[5]<=e[5]},getAABB3Diag:function(){var e=new z(3),t=new z(3),i=new z(3);return function(s){return e[0]=s[0],e[1]=s[1],e[2]=s[2],t[0]=s[3],t[1]=s[4],t[2]=s[5],J.subVec3(t,e,i),Math.abs(J.lenVec3(i))}}(),getAABB3DiagPoint:function(){var e=new z(3),t=new z(3),i=new z(3);return function(s,r){e[0]=s[0],e[1]=s[1],e[2]=s[2],t[0]=s[3],t[1]=s[4],t[2]=s[5];var n=J.subVec3(t,e,i),o=r[0]-s[0],a=s[3]-r[0],l=r[1]-s[1],u=s[4]-r[1],A=r[2]-s[2],c=s[5]-r[2];return n[0]+=o>a?o:a,n[1]+=l>u?l:u,n[2]+=A>c?A:c,Math.abs(J.lenVec3(n))}}(),getAABB3Area:function(e){return(e[3]-e[0])*(e[4]-e[1])*(e[5]-e[2])},getAABB3Center:function(e,t){var i=t||J.vec3();return i[0]=(e[0]+e[3])/2,i[1]=(e[1]+e[4])/2,i[2]=(e[2]+e[5])/2,i},getAABB2Center:function(e,t){var i=t||J.vec2();return i[0]=(e[2]+e[0])/2,i[1]=(e[3]+e[1])/2,i},collapseAABB3:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:J.AABB3();return e[0]=J.MAX_DOUBLE,e[1]=J.MAX_DOUBLE,e[2]=J.MAX_DOUBLE,e[3]=J.MIN_DOUBLE,e[4]=J.MIN_DOUBLE,e[5]=J.MIN_DOUBLE,e},AABB3ToOBB3:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J.OBB3();return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t[4]=e[3],t[5]=e[1],t[6]=e[2],t[7]=1,t[8]=e[3],t[9]=e[4],t[10]=e[2],t[11]=1,t[12]=e[0],t[13]=e[4],t[14]=e[2],t[15]=1,t[16]=e[0],t[17]=e[1],t[18]=e[5],t[19]=1,t[20]=e[3],t[21]=e[1],t[22]=e[5],t[23]=1,t[24]=e[3],t[25]=e[4],t[26]=e[5],t[27]=1,t[28]=e[0],t[29]=e[4],t[30]=e[5],t[31]=1,t},positions3ToAABB3:function(){var e=new z(3);return function(t,i,s){i=i||J.AABB3();for(var r,n,o,a=J.MAX_DOUBLE,l=J.MAX_DOUBLE,u=J.MAX_DOUBLE,A=J.MIN_DOUBLE,c=J.MIN_DOUBLE,h=J.MIN_DOUBLE,d=0,p=t.length;d<p;d+=3)s?(e[0]=t[d+0],e[1]=t[d+1],e[2]=t[d+2],J.decompressPosition(e,s,e),r=e[0],n=e[1],o=e[2]):(r=t[d+0],n=t[d+1],o=t[d+2]),r<a&&(a=r),n<l&&(l=n),o<u&&(u=o),r>A&&(A=r),n>c&&(c=n),o>h&&(h=o);return i[0]=a,i[1]=l,i[2]=u,i[3]=A,i[4]=c,i[5]=h,i}}(),OBB3ToAABB3:function(e){for(var t,i,s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J.AABB3(),n=J.MAX_DOUBLE,o=J.MAX_DOUBLE,a=J.MAX_DOUBLE,l=J.MIN_DOUBLE,u=J.MIN_DOUBLE,A=J.MIN_DOUBLE,c=0,h=e.length;c<h;c+=4)(t=e[c+0])<n&&(n=t),(i=e[c+1])<o&&(o=i),(s=e[c+2])<a&&(a=s),t>l&&(l=t),i>u&&(u=i),s>A&&(A=s);return r[0]=n,r[1]=o,r[2]=a,r[3]=l,r[4]=u,r[5]=A,r},points3ToAABB3:function(e){for(var t,i,s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J.AABB3(),n=J.MAX_DOUBLE,o=J.MAX_DOUBLE,a=J.MAX_DOUBLE,l=J.MIN_DOUBLE,u=J.MIN_DOUBLE,A=J.MIN_DOUBLE,c=0,h=e.length;c<h;c++)(t=e[c][0])<n&&(n=t),(i=e[c][1])<o&&(o=i),(s=e[c][2])<a&&(a=s),t>l&&(l=t),i>u&&(u=i),s>A&&(A=s);return r[0]=n,r[1]=o,r[2]=a,r[3]=l,r[4]=u,r[5]=A,r},points3ToSphere3:function(){var e=new z(3);return function(t,i){i=i||J.vec4();var s,r=0,n=0,o=0,a=t.length;for(s=0;s<a;s++)r+=t[s][0],n+=t[s][1],o+=t[s][2];i[0]=r/a,i[1]=n/a,i[2]=o/a;var l,u=0;for(s=0;s<a;s++)(l=Math.abs(J.lenVec3(J.subVec3(t[s],i,e))))>u&&(u=l);return i[3]=u,i}}(),positions3ToSphere3:function(){var e=new z(3),t=new z(3);return function(i,s){s=s||J.vec4();var r,n=0,o=0,a=0,l=i.length,u=0;for(r=0;r<l;r+=3)n+=i[r],o+=i[r+1],a+=i[r+2];var A,c=l/3;for(s[0]=n/c,s[1]=o/c,s[2]=a/c,r=0;r<l;r+=3)e[0]=i[r],e[1]=i[r+1],e[2]=i[r+2],(A=Math.abs(J.lenVec3(J.subVec3(e,s,t))))>u&&(u=A);return s[3]=u,s}}(),OBB3ToSphere3:function(){var e=new z(3),t=new z(3);return function(i,s){s=s||J.vec4();var r,n=0,o=0,a=0,l=i.length,u=l/4;for(r=0;r<l;r+=4)n+=i[r+0],o+=i[r+1],a+=i[r+2];s[0]=n/u,s[1]=o/u,s[2]=a/u;var A,c=0;for(r=0;r<l;r+=4)e[0]=i[r+0],e[1]=i[r+1],e[2]=i[r+2],(A=Math.abs(J.lenVec3(J.subVec3(e,s,t))))>c&&(c=A);return s[3]=c,s}}(),getSphere3Center:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J.vec3();return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},getPositionsCenter:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J.vec3(),i=0,s=0,r=0,n=0,o=e.length;n<o;n+=3)i+=e[n+0],s+=e[n+1],r+=e[n+2];var a=e.length/3;return t[0]=i/a,t[1]=s/a,t[2]=r/a,t},expandAABB3:function(e,t){return e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]>t[2]&&(e[2]=t[2]),e[3]<t[3]&&(e[3]=t[3]),e[4]<t[4]&&(e[4]=t[4]),e[5]<t[5]&&(e[5]=t[5]),e},expandAABB3Point3:function(e,t){return e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]>t[2]&&(e[2]=t[2]),e[3]<t[0]&&(e[3]=t[0]),e[4]<t[1]&&(e[4]=t[1]),e[5]<t[2]&&(e[5]=t[2]),e},expandAABB3Points3:function(e,t){for(var i,s,r,n=0,o=t.length;n<o;n+=3)i=t[n],s=t[n+1],r=t[n+2],e[0]>i&&(e[0]=i),e[1]>s&&(e[1]=s),e[2]>r&&(e[2]=r),e[3]<i&&(e[3]=i),e[4]<s&&(e[4]=s),e[5]<r&&(e[5]=r);return e},collapseAABB2:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:J.AABB2();return e[0]=J.MAX_DOUBLE,e[1]=J.MAX_DOUBLE,e[2]=J.MIN_DOUBLE,e[3]=J.MIN_DOUBLE,e},point3AABB3Intersect:function(e,t){return e[0]>t[0]||e[3]<t[0]||e[1]>t[1]||e[4]<t[1]||e[2]>t[2]||e[5]<t[